@axiom-lattice/gateway 4.7.0 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/{OrphanRecoveryRuntime-MQDEJX3M.mjs → OrphanRecoveryRuntime-BEFILJMU.mjs} +2 -2
  2. package/dist/{chunk-2POW27EI.mjs → chunk-7CG57LEF.mjs} +2 -2
  3. package/dist/{chunk-WKNZ7GBC.mjs → chunk-EXPERMZR.mjs} +1 -1
  4. package/dist/chunk-EXPERMZR.mjs.map +1 -0
  5. package/dist/{chunk-52SUWMOX.mjs → chunk-JUA3VJE7.mjs} +3 -2
  6. package/dist/chunk-JUA3VJE7.mjs.map +1 -0
  7. package/dist/{chunk-TJAUXMYJ.mjs → chunk-URXZPI2F.mjs} +8 -1
  8. package/dist/chunk-URXZPI2F.mjs.map +1 -0
  9. package/dist/{chunk-KDQKTU3N.mjs → chunk-ZBTG3T7K.mjs} +44 -8
  10. package/dist/chunk-ZBTG3T7K.mjs.map +1 -0
  11. package/dist/embed/{embed-page-AgentDetailSideApp-2C2ZR62Q.js → embed-page-AgentDetailSideApp-NTLAFO5C.js} +1 -1
  12. package/dist/embed/{embed-page-AgentGovernanceWorkbench-GG4ONSTS.js → embed-page-AgentGovernanceWorkbench-QPVBOMLH.js} +1 -1
  13. package/dist/embed/{embed-page-MessageGraph-WMYTVUUC.js → embed-page-MessageGraph-JAJGMYKH.js} +1 -1
  14. package/dist/embed/{embed-page-ReactChart-7XCMDMH6.js → embed-page-ReactChart-WUG6TEAZ.js} +1 -1
  15. package/dist/embed/{embed-page-SkillFlow-XMMHEHQL.js → embed-page-SkillFlow-TSBZ4V2P.js} +1 -1
  16. package/dist/embed/{embed-page-TasksSideApp-4ZJ4Q4CL.js → embed-page-TasksSideApp-TJI22YGD.js} +1 -1
  17. package/dist/embed/{embed-page-TeamWorkspace-H5OOEN3K.js → embed-page-TeamWorkspace-OJJLN5VI.js} +1 -1
  18. package/dist/embed/{embed-page-TopologyRuntimeView-QMXWERVC.js → embed-page-TopologyRuntimeView-ZFU4N6TV.js} +1 -1
  19. package/dist/embed/{embed-page-WorkflowAutomationView-L2OEGCA5.js → embed-page-WorkflowAutomationView-ALXV7VQQ.js} +1 -1
  20. package/dist/embed/{embed-page-chunk-CZE4IEB3.js → embed-page-chunk-DZQBVJ7Z.js} +1 -1
  21. package/dist/embed/{embed-page-chunk-N2ISCAS7.js → embed-page-chunk-IPIJ2SG6.js} +1 -1
  22. package/dist/embed/{embed-page-chunk-SUMYB6ZA.js → embed-page-chunk-N22EGQAJ.js} +1 -1
  23. package/dist/embed/{embed-page-chunk-OHDEKFTU.js → embed-page-chunk-O72XBKQH.js} +2 -2
  24. package/dist/embed/{embed-page-chunk-XIXSRYJY.js → embed-page-chunk-QMVIL4BJ.js} +190 -185
  25. package/dist/embed/{embed-page-chunk-2G54EIW2.js → embed-page-chunk-UT3WYBZH.js} +1 -1
  26. package/dist/embed/embed-page-chunk-YPNSOZYW.js +8 -0
  27. package/dist/embed/embed-page.js +1 -1
  28. package/dist/index.d.mts +146 -17
  29. package/dist/index.d.ts +146 -17
  30. package/dist/index.js +1190 -328
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +649 -97
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/{open-STFMNRO5.mjs → open-UVKMONVE.mjs} +5 -4
  35. package/dist/open-UVKMONVE.mjs.map +1 -0
  36. package/dist/{open-files-NPNQQ6TY.mjs → open-files-X3HXVEEM.mjs} +4 -4
  37. package/dist/{open-session-IHDGAXL3.mjs → open-session-2Y7XJJW2.mjs} +3 -3
  38. package/dist/{resources-DXPXAXEZ.mjs → resources-2L3KSUUU.mjs} +2 -2
  39. package/dist/sandboxOpenCredentialProvider-USIU7Z7H.mjs +275 -0
  40. package/dist/sandboxOpenCredentialProvider-USIU7Z7H.mjs.map +1 -0
  41. package/dist/{sandboxProvider-I3P66VXT.mjs → sandboxProvider-DUYWHYJN.mjs} +2 -2
  42. package/package.json +14 -8
  43. package/dist/chunk-52SUWMOX.mjs.map +0 -1
  44. package/dist/chunk-KDQKTU3N.mjs.map +0 -1
  45. package/dist/chunk-TJAUXMYJ.mjs.map +0 -1
  46. package/dist/chunk-WKNZ7GBC.mjs.map +0 -1
  47. package/dist/embed/embed-page-chunk-HEMNMC4X.js +0 -7
  48. package/dist/open-STFMNRO5.mjs.map +0 -1
  49. /package/dist/{OrphanRecoveryRuntime-MQDEJX3M.mjs.map → OrphanRecoveryRuntime-BEFILJMU.mjs.map} +0 -0
  50. /package/dist/{chunk-2POW27EI.mjs.map → chunk-7CG57LEF.mjs.map} +0 -0
  51. /package/dist/{open-files-NPNQQ6TY.mjs.map → open-files-X3HXVEEM.mjs.map} +0 -0
  52. /package/dist/{open-session-IHDGAXL3.mjs.map → open-session-2Y7XJJW2.mjs.map} +0 -0
  53. /package/dist/{resources-DXPXAXEZ.mjs.map → resources-2L3KSUUU.mjs.map} +0 -0
  54. /package/dist/{sandboxProvider-I3P66VXT.mjs.map → sandboxProvider-DUYWHYJN.mjs.map} +0 -0
@@ -1,3 +1,3 @@
1
- import{a as Fe,b as qe}from"./embed-page-chunk-SUMYB6ZA.js";import{b as He,c as fe}from"./embed-page-chunk-N2ISCAS7.js";import"./embed-page-chunk-KEL6XU6R.js";import{f as _e}from"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import{C as ae,F as le,Ha as Ne,K as Te,M as de,O as ce,S as De,W as Le,_ as Pe,ha as je,i as Me,l as se,la as _,m as Ae,ma as ge,na as Oe,qb as Be,ra as pe,sa as X,ta as Ee,wa as J}from"./embed-page-chunk-XIXSRYJY.js";import{r as V}from"./embed-page-chunk-HEMNMC4X.js";import{a as P}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Aa as Se,Gc as We,La as U,W as q,Z as H,aa as Y,fc as ze,ga as Ce,pc as Ie,ra as $,ta as K,tb as Re,va as re,ya as G,yc as ie}from"./embed-page-chunk-O4QK5LWZ.js";import{a as oe}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as W}from"./embed-page-chunk-6Y3UYJ6Z.js";var i=W(oe());var Q=W(oe());var L=W(P());function st(o){let s=o.split(/[\n\r.。;;!!??]+/).filter(Boolean)[0]?.trim()||"";return s=s.replace(/[,,]+$/,"").trim(),s.length>50&&(s=s.slice(0,50)),s||(s=o.slice(0,50).trim()),s}function at(o){let e=5381;for(let s=0;s<o.length;s++)e=(e<<5)+e+o.charCodeAt(s)>>>0;return e.toString(36).slice(0,6)}var ue=({open:o,onCancel:e,onCreated:s,type:m="processing"})=>{let{post:d}=V(),{trainingProjects:p,loading:b}=J(),[f,M]=(0,Q.useState)(null),[y]=$.useForm(),u=p.find(w=>w.id===f)??p[0]??null;return(0,Q.useEffect)(()=>{o&&(y.resetFields(),M(null))},[o,y]),(0,L.jsx)(G,{title:m==="workflow"?"New Workflow":"New Processing Workflow",open:o,onCancel:e,onOk:async()=>{if(m==="workflow"&&!u)return;let x=((await y.validateFields()).purpose||"").trim(),z=st(x),I=`wf-${at(x+Date.now())}`,g=m==="workflow"?{key:I,name:z,description:x,type:"workflow",prompt:"Complete the assigned task accurately and concisely.",metadata:{trainingProjectId:u?.id},workflowYaml:`name: ${I}
1
+ import{a as Fe,b as qe}from"./embed-page-chunk-N22EGQAJ.js";import{b as He,c as fe}from"./embed-page-chunk-IPIJ2SG6.js";import"./embed-page-chunk-KEL6XU6R.js";import{f as _e}from"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import{B as le,Da as Ne,G as Te,I as de,K as ce,O as De,S as Le,W as Pe,da as je,e as Me,h as se,ha as _,i as Ae,ia as ge,ja as Oe,mb as Be,na as pe,oa as X,pa as Ee,sa as J,y as ae}from"./embed-page-chunk-QMVIL4BJ.js";import{y as V}from"./embed-page-chunk-YPNSOZYW.js";import{a as P}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Aa as Se,Gc as We,La as U,W as q,Z as H,aa as Y,fc as ze,ga as Ce,pc as Ie,ra as $,ta as K,tb as Re,va as re,ya as G,yc as ie}from"./embed-page-chunk-O4QK5LWZ.js";import{a as oe}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as W}from"./embed-page-chunk-6Y3UYJ6Z.js";var i=W(oe());var Q=W(oe());var L=W(P());function st(o){let s=o.split(/[\n\r.。;;!!??]+/).filter(Boolean)[0]?.trim()||"";return s=s.replace(/[,,]+$/,"").trim(),s.length>50&&(s=s.slice(0,50)),s||(s=o.slice(0,50).trim()),s}function at(o){let e=5381;for(let s=0;s<o.length;s++)e=(e<<5)+e+o.charCodeAt(s)>>>0;return e.toString(36).slice(0,6)}var ue=({open:o,onCancel:e,onCreated:s,type:m="processing"})=>{let{post:d}=V(),{trainingProjects:p,loading:b}=J(),[f,M]=(0,Q.useState)(null),[y]=$.useForm(),u=p.find(w=>w.id===f)??p[0]??null;return(0,Q.useEffect)(()=>{o&&(y.resetFields(),M(null))},[o,y]),(0,L.jsx)(G,{title:m==="workflow"?"New Workflow":"New Processing Workflow",open:o,onCancel:e,onOk:async()=>{if(m==="workflow"&&!u)return;let x=((await y.validateFields()).purpose||"").trim(),z=st(x),I=`wf-${at(x+Date.now())}`,g=m==="workflow"?{key:I,name:z,description:x,type:"workflow",prompt:"Complete the assigned task accurately and concisely.",metadata:{trainingProjectId:u?.id},workflowYaml:`name: ${I}
2
2
  steps: []
3
3
  `}:{key:I,name:z,description:x,type:"processing",prompt:`You are the orchestrator for workflow "${z}". Purpose: ${x}. Follow the topology to delegate tasks to sub-agents.`,tools:[],skills:[],subAgents:[],middleware:[{id:"topology",type:"topology",name:"Topology",description:"Workflow topology",enabled:!0,config:{edges:[]}}]};await d("/api/assistants",{id:I,name:z,description:x,graphDefinition:g}),y.resetFields(),s(I,x,m==="workflow"?u?.id:void 0)},okText:"Create",okButtonProps:{disabled:m==="workflow"&&(b||!u)},destroyOnClose:!0,children:(0,L.jsxs)($,{form:y,layout:"vertical",initialValues:{purpose:""},children:[(0,L.jsx)($.Item,{name:"purpose",label:"Purpose",rules:[{required:!0,message:"Please describe the workflow purpose"}],children:(0,L.jsx)(K.TextArea,{placeholder:"Describe what this workflow should do. Name and key will be generated automatically.",rows:4})}),m==="workflow"&&(0,L.jsx)(Fe,{project:u,projects:p,value:u?.id??null,onChange:M,loading:b})]})})};var Ke=W(oe());var t=W(P()),{Text:be}=U;function lt(o){if(!o||typeof o!="object")return null;let e=o;return{modelKey:e.modelKey||e.model||void 0,tools:Array.isArray(e.tools)?e.tools:[],middleware:Array.isArray(e.middleware)?e.middleware.filter(s=>s&&typeof s=="object"&&s.type):[],subAgents:Array.isArray(e.subAgents)?e.subAgents:[],skillCategories:Array.isArray(e.skillCategories)?e.skillCategories:[],runConfig:e.runConfig&&typeof e.runConfig=="object"?e.runConfig:void 0}}var dt={filesystem:(0,t.jsx)(Te,{size:12}),code_eval:(0,t.jsx)(Oe,{size:12}),browser:(0,t.jsx)(ce,{size:12}),sql:(0,t.jsx)(le,{size:12}),skill:(0,t.jsx)(ge,{size:12}),http:(0,t.jsx)(Le,{size:12}),scheduler:(0,t.jsx)(ae,{size:12}),metrics:(0,t.jsx)(Me,{size:12}),topology:(0,t.jsx)(de,{size:12}),ask_user_to_clarify:(0,t.jsx)(Pe,{size:12}),widget:(0,t.jsx)(se,{size:12}),date:(0,t.jsx)(Ae,{size:12}),task:(0,t.jsx)(de,{size:12}),custom:(0,t.jsx)(je,{size:12}),claw:(0,t.jsx)(_,{size:12}),collection:(0,t.jsx)(De,{size:12})},ct={filesystem:{bg:"rgba(34,197,94,0.08)",text:"#16a34a",border:"rgba(34,197,94,0.2)"},code_eval:{bg:"rgba(99,102,241,0.08)",text:"#4f46e5",border:"rgba(99,102,241,0.2)"},browser:{bg:"rgba(59,130,246,0.08)",text:"#2563eb",border:"rgba(59,130,246,0.2)"},sql:{bg:"rgba(249,115,22,0.08)",text:"#ea580c",border:"rgba(249,115,22,0.2)"},skill:{bg:"rgba(168,85,247,0.08)",text:"#9333ea",border:"rgba(168,85,247,0.2)"},http:{bg:"rgba(20,184,166,0.08)",text:"#0d9488",border:"rgba(20,184,166,0.2)"},scheduler:{bg:"rgba(245,158,11,0.08)",text:"#d97706",border:"rgba(245,158,11,0.2)"},metrics:{bg:"rgba(236,72,153,0.08)",text:"#db2777",border:"rgba(236,72,153,0.2)"},topology:{bg:"rgba(99,102,241,0.08)",text:"#4f46e5",border:"rgba(99,102,241,0.2)"},ask_user_to_clarify:{bg:"rgba(245,158,11,0.08)",text:"#d97706",border:"rgba(245,158,11,0.2)"},widget:{bg:"rgba(20,184,166,0.08)",text:"#0d9488",border:"rgba(20,184,166,0.2)"},date:{bg:"rgba(139,92,246,0.08)",text:"#7c3aed",border:"rgba(139,92,246,0.2)"},task:{bg:"rgba(99,102,241,0.08)",text:"#4f46e5",border:"rgba(99,102,241,0.2)"},custom:{bg:"rgba(107,114,128,0.08)",text:"#4b5563",border:"rgba(107,114,128,0.2)"},claw:{bg:"rgba(107,114,128,0.08)",text:"#4b5563",border:"rgba(107,114,128,0.2)"},collection:{bg:"rgba(6,182,212,0.08)",text:"#0891b2",border:"rgba(6,182,212,0.2)"}},gt={bg:"rgba(107,114,128,0.08)",text:"#4b5563",border:"rgba(107,114,128,0.2)"};function pt(o){let e=o.split(/[_-]+/).filter(Boolean);return e.length===1?e[0].slice(0,2).toUpperCase():e.map(s=>s[0]).join("").toUpperCase().slice(0,2)}var Ye=[{bg:"rgba(99,102,241,0.1)",text:"#6366f1"},{bg:"rgba(34,197,94,0.1)",text:"#22c55e"},{bg:"rgba(245,158,11,0.1)",text:"#f59e0b"},{bg:"rgba(59,130,246,0.1)",text:"#3b82f6"},{bg:"rgba(239,68,68,0.1)",text:"#ef4444"},{bg:"rgba(168,85,247,0.1)",text:"#a855f7"},{bg:"rgba(20,184,166,0.1)",text:"#14b8a6"},{bg:"rgba(236,72,153,0.1)",text:"#ec4899"}];function $e(o){return Ye[o%Ye.length]}var B=({icon:o,label:e,count:s,children:m})=>(0,t.jsxs)("div",{style:{marginBottom:10},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[(0,t.jsx)("span",{style:{color:"#6366f1",display:"flex",alignItems:"center"},children:o}),(0,t.jsx)(be,{strong:!0,style:{fontSize:11,color:"#52525b",textTransform:"uppercase",letterSpacing:"0.3px"},children:e}),(0,t.jsx)("span",{style:{fontSize:9,fontWeight:600,color:"#a1a1aa",background:"rgba(0,0,0,0.04)",borderRadius:8,padding:"1px 6px",lineHeight:"16px"},children:s})]}),m]}),Ge=({graphDef:o})=>{let e=(0,Ke.useMemo)(()=>lt(o),[o]);if(!e)return null;let s=e.middleware.filter(d=>d.enabled!==!1),m=!1;return e.tools.length===0&&s.length===0&&e.subAgents.length===0?null:(0,t.jsx)("div",{style:{pointerEvents:"auto"},children:(0,t.jsxs)("div",{style:{background:"rgba(255,255,255,0.5)",borderRadius:8,width:250,transition:"all 0.25s ease",overflow:"hidden"},children:[(0,t.jsx)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",background:"rgba(99,102,241,0.02)",borderBottom:"1px solid rgba(0,0,0,0.03)"},children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,t.jsx)("div",{style:{width:24,height:24,borderRadius:6,background:"rgba(99,102,241,0.05)",display:"flex",alignItems:"center",justifyContent:"center",color:"#6366f1"},children:(0,t.jsx)(_,{size:13})}),(0,t.jsx)(be,{strong:!0,style:{fontSize:12,color:"#1a1a1a"},children:"Environment"})]})}),(0,t.jsxs)("div",{style:{padding:"10px 12px 12px",maxHeight:"calc(60vh - 48px)",overflowY:"auto"},children:[e.tools.length>0&&(0,t.jsx)(B,{icon:(0,t.jsx)(Ee,{size:12}),label:"Tools",count:e.tools.length,children:(0,t.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:e.tools.map((d,p)=>{let b=$e(p);return(0,t.jsx)(Y,{title:d,placement:"top",children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:b.text,background:b.bg,cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[(0,t.jsx)("span",{style:{fontWeight:700,fontSize:9,opacity:.7},children:pt(d)}),(0,t.jsx)("span",{children:d})]})},d)})})}),s.length>0&&(0,t.jsx)(B,{icon:(0,t.jsx)(se,{size:12}),label:"Capabilities",count:s.length,children:(0,t.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:s.map(d=>{let p=ct[d.type]||gt,b=dt[d.type]||(0,t.jsx)(_,{size:12});return(0,t.jsx)(Y,{title:d.name||d.type,placement:"top",children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:p.text,background:p.bg,border:`1px solid ${p.border}`,cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[b,(0,t.jsx)("span",{children:d.name||d.type})]})},d.type)})})}),e.subAgents.length>0&&(0,t.jsx)(B,{icon:(0,t.jsx)(pe,{size:12}),label:"Sub-agents",count:e.subAgents.length,children:(0,t.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:e.subAgents.map((d,p)=>{let b=$e(p+3);return(0,t.jsx)(Y,{title:d,placement:"top",children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:b.text,background:b.bg,cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[(0,t.jsx)(pe,{size:10}),(0,t.jsx)("span",{children:d})]})},d)})})}),(e.modelKey||e.runConfig)&&(0,t.jsx)(B,{icon:(0,t.jsx)(ae,{size:12}),label:"Runtime",count:e.modelKey?1:0,children:(0,t.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[e.modelKey&&(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:"#4f46e5",background:"rgba(99,102,241,0.08)",border:"1px solid rgba(99,102,241,0.2)",cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[(0,t.jsx)(_,{size:10}),(0,t.jsxs)("span",{children:["Model: ",e.modelKey]})]}),!!e.runConfig?.databaseKey&&(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:"#ea580c",background:"rgba(249,115,22,0.08)",border:"1px solid rgba(249,115,22,0.2)",cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[(0,t.jsx)(le,{size:10}),(0,t.jsxs)("span",{children:["DB: ",String(e.runConfig?.databaseKey)]})]}),e.skillCategories&&e.skillCategories.length>0&&(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:"#9333ea",background:"rgba(168,85,247,0.08)",border:"1px solid rgba(168,85,247,0.2)",cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[(0,t.jsx)(ge,{size:10}),(0,t.jsxs)("span",{children:["Skills: ",e.skillCategories.join(", ")]})]})]})}),m&&(0,t.jsx)(B,{icon:(0,t.jsx)(ce,{size:12}),label:"Channels",count:0,children:(0,t.jsx)(be,{type:"secondary",style:{fontSize:10,fontStyle:"italic"},children:"No channels configured"})})]})]})})};var n=W(P()),{Text:F}=U;function Ue(o){if(typeof o=="string")try{let e=JSON.parse(o);return e&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}return o&&typeof o=="object"&&!Array.isArray(o)?o:null}function ft(o){let e=null;if(typeof o=="string")try{e=JSON.parse(o)}catch{return null}else o&&typeof o=="object"&&(e=o);if(!e)return null;if(e.type!=="workflow")return console.warn("[extractDSL] type is not 'workflow':",e.type),null;if(typeof e.workflowYaml!="string")return console.warn("[extractDSL] workflowYaml not found or not a string, keys:",Object.keys(e)),null;try{return fe(e.workflowYaml)}catch(s){return console.error("[extractDSL] expandWorkflow failed:",s.message,s),null}}function ut({workflows:o,selectedId:e,onSelect:s,onCreate:m,onDelete:d,dsl:p,agentNameMap:b,onSpecClick:f,environmentConfig:M}){let y=o.find(g=>g.id===e),[u,S]=(0,i.useState)(!0),[w,x]=(0,i.useState)(""),z=(0,i.useMemo)(()=>{let g=w.trim().toLowerCase();return g?o.filter(h=>h.name.toLowerCase().includes(g)||h.description.toLowerCase().includes(g)):o},[o,w]);(0,i.useEffect)(()=>{e?S(!1):(S(!0),x(""))},[e]);let I=g=>{s(g),S(!1)};return(0,n.jsx)("div",{style:{display:"flex",height:"100%",width:"100%"},children:(0,n.jsxs)("div",{style:{flex:1,position:"relative"},children:[y?(0,n.jsxs)(n.Fragment,{children:[p?(0,n.jsx)(He,{dsl:p,agentNameMap:b}):(0,n.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,n.jsx)(re,{tip:"Loading workflow DSL..."})}),!u&&(0,n.jsx)("div",{style:{position:"absolute",top:12,left:12,zIndex:10},children:(0,n.jsx)(q,{type:"default",icon:(0,n.jsx)(Ie,{}),onClick:()=>S(!0),style:{width:32,height:32,borderRadius:10,boxShadow:"0 2px 12px rgba(0,0,0,0.08)",border:"1px solid #f0f0f0",background:"rgba(255,255,255,0.95)",color:"#6366f1",display:"flex",alignItems:"center",justifyContent:"center"}})}),(0,n.jsxs)("div",{style:{position:"absolute",top:12,left:u?12:56,zIndex:10,display:"flex",alignItems:"center",gap:6,height:32,padding:"0 14px",background:"rgba(255,255,255,0.95)",borderRadius:10,boxShadow:"0 2px 12px rgba(0,0,0,0.08)",border:"1px solid #f0f0f0"},children:[(0,n.jsx)(X,{size:16,color:"#6366f1"}),(0,n.jsx)(F,{strong:!0,style:{fontSize:13},children:y.name}),(0,n.jsx)(ze,{style:{color:"#6366f1",cursor:"pointer",fontSize:15},onClick:f})]}),(0,n.jsx)("div",{style:{position:"absolute",top:12,right:12,zIndex:10,display:"flex",alignItems:"center",height:32,padding:"0 14px",background:"rgba(255,255,255,0.95)",borderRadius:10,boxShadow:"0 2px 12px rgba(0,0,0,0.08)",border:"1px solid #f0f0f0"},children:(0,n.jsx)(Se,{title:"Delete workflow",description:"This will permanently delete this workflow agent.",onConfirm:()=>d(y.id),okText:"Delete",cancelText:"Cancel",okButtonProps:{danger:!0},children:(0,n.jsx)(Re,{style:{color:"#ff4d4f",cursor:"pointer",fontSize:15}})})}),!u&&(0,n.jsx)("div",{style:{position:"absolute",top:52,left:u?12:56,zIndex:20},children:(0,n.jsx)(Ge,{graphDef:M},y.id)})]}):(0,n.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,n.jsx)(H,{description:"Select a workflow to view its graph"})}),u&&(0,n.jsxs)(n.Fragment,{children:[e&&(0,n.jsx)("div",{onClick:()=>S(!1),style:{position:"absolute",inset:0,zIndex:25,background:"transparent"}}),(0,n.jsxs)(Ce,{size:"small",title:(0,n.jsx)(F,{strong:!0,style:{fontSize:15,color:"#1a1a1a"},children:"Workflows"}),extra:(0,n.jsx)(q,{type:"text",size:"small",icon:(0,n.jsx)(ie,{}),onClick:m,style:{color:"#6366f1"}}),styles:{body:{padding:"12px 16px 16px"},header:{padding:"14px 16px 10px",borderBottom:"1px solid rgba(0,0,0,0.04)"}},style:{position:"absolute",left:16,top:e?56:48,bottom:16,width:300,zIndex:30,borderRadius:16,boxShadow:"0 4px 24px rgba(0,0,0,0.12)",border:"1px solid #f0f0f0",overflow:"auto",background:"rgba(255, 255, 255, 0.92)"},children:[(0,n.jsx)("div",{style:{marginBottom:12},children:(0,n.jsx)(K,{prefix:(0,n.jsx)(We,{style:{color:"#bbb"}}),placeholder:"Filter workflows...",value:w,onChange:g=>x(g.target.value),allowClear:!0,size:"small",style:{borderRadius:10,border:"1px solid rgba(0,0,0,0.06)"}})}),z.length===0?(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px 16px",color:"#bbb"},children:[(0,n.jsx)(X,{size:28,style:{marginBottom:10,opacity:.4}}),(0,n.jsx)(F,{type:"secondary",style:{fontSize:13},children:w.trim()?"No workflows match your search":"No workflows yet"})]}):z.map(g=>{let h=e===g.id;return(0,n.jsxs)("div",{onClick:()=>I(g.id),style:{display:"flex",alignItems:"center",gap:12,padding:"13px 15px",borderRadius:12,cursor:"pointer",transition:"all 0.2s ease",background:h?"rgba(99, 102, 241, 0.07)":"rgba(255, 255, 255, 0.5)",border:h?"1px solid rgba(99, 102, 241, 0.25)":"1px solid transparent",marginBottom:6},onMouseEnter:C=>{h||(C.currentTarget.style.background="rgba(255, 255, 255, 0.92)",C.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.05)",C.currentTarget.style.transform="translateY(-1px)",C.currentTarget.style.borderColor="rgba(0,0,0,0.06)")},onMouseLeave:C=>{h||(C.currentTarget.style.background="rgba(255, 255, 255, 0.5)",C.currentTarget.style.boxShadow="none",C.currentTarget.style.transform="translateY(0)",C.currentTarget.style.borderColor="transparent")},children:[(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:38,height:38,borderRadius:10,background:h?"rgba(99, 102, 241, 0.12)":"rgba(0, 0, 0, 0.04)",flexShrink:0,transition:"background 0.2s ease"},children:(0,n.jsx)(X,{size:18,color:h?"#6366f1":"#888"})}),(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsx)(F,{strong:!0,ellipsis:{tooltip:g.name},style:{fontSize:14,color:h?"#6366f1":"#1a1a1a",transition:"color 0.2s ease"},children:g.name}),g.description&&(0,n.jsx)("div",{style:{fontSize:12,color:"#999",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:3,lineHeight:"18px"},children:g.description})]})]},g.id)})]})]})]})})}var bt=()=>{let{get:o,del:e}=V(),{workspaceId:s,trainingProjects:m,loading:d}=J(),[p,b]=(0,i.useState)([]),[f,M]=(0,i.useState)(null),[y,u]=(0,i.useState)(null),[S,w]=(0,i.useState)(null),[x,z]=(0,i.useState)([]),[I,g]=(0,i.useState)(new Map),h=(0,i.useCallback)(async()=>{try{let r=await o("/api/assistants");if(r.success&&r.data?.records){let c=[],a=new Map;for(let l of r.data.records){if(l.id&&l.name){let k=typeof l.graphDefinition=="object"&&l.graphDefinition!==null?l.graphDefinition:void 0;a.set(l.id,{name:l.name,type:k?.type??"unknown"})}if(l.graphDefinition)if(typeof l.graphDefinition=="string")try{c.push(JSON.parse(l.graphDefinition))}catch{}else typeof l.graphDefinition=="object"&&c.push(l.graphDefinition)}z(c),g(a)}}catch{}},[o]),[C,me]=(0,i.useState)(!0),[Z,Xe]=(0,i.useState)(420),j=(0,i.useRef)(null),[Je,Ve]=(0,i.useState)(!0),[ye,we]=(0,i.useState)(null),[Qe,xe]=(0,i.useState)(!1),[he,O]=(0,i.useState)(!1),[Ze,ke]=(0,i.useState)(null),et=(0,i.useMemo)(()=>["create_workflow","update_workflow","validate_workflow","create_agent","update_agent","delete_agent"],[]),T=(0,i.useCallback)(async()=>{let r=await o("/api/assistants");if(r.success&&r.data?.records){let c=r.data.records.filter(a=>(Ue(a.graphDefinition)??void 0)?.type==="workflow").map(a=>{let l=Ue(a.graphDefinition)??void 0,k=typeof l?.workflowYaml=="string"?l.workflowYaml:"",E=l?.metadata,N=0;try{N=fe(k).nodes.filter(R=>R.type!=="terminal").length}catch{}return{id:a.id,name:a.name,description:a.description||"",type:"workflow",stepCount:N,trainingProjectId:typeof E?.trainingProjectId=="string"?E.trainingProjectId:void 0}});b(c)}we(null)},[o]),ee=(0,i.useCallback)(async r=>{try{let c=await o(`/api/assistants/${r}`);if(c.success&&c.data){let a=c.data.graphDefinition,l=ft(a);if(u(l),!a)w(null);else if(typeof a=="string")try{w(JSON.parse(a))}catch{w(null)}else w(typeof a=="object"?a:null)}}catch{u(null),w(null)}},[o]);(0,i.useEffect)(()=>{let r=!1;return(async()=>{try{await T(),await h()}catch(a){r||we(a instanceof Error?a.message:"Failed to load workflows")}finally{r||Ve(!1)}})(),()=>{r=!0}},[T]),(0,i.useEffect)(()=>{f?ee(f):u(null)},[f,ee]);let tt=(0,i.useCallback)(r=>{r.preventDefault(),j.current={startX:r.clientX,startWidth:Z}},[Z]);(0,i.useEffect)(()=>{let r=a=>{if(!j.current)return;let l=j.current.startX-a.clientX,k=Math.min(900,Math.max(400,j.current.startWidth+l));Xe(k)},c=()=>{j.current=null};return window.addEventListener("mousemove",r),window.addEventListener("mouseup",c),()=>{window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",c)}},[]);let nt=(0,i.useCallback)(r=>{M(r)},[]),ve=(0,i.useCallback)((r,c,a)=>{O(!1),T().then(()=>{M(r),a&&b(l=>l.map(k=>k.id===r?{...k,trainingProjectId:a}:k)),c&&ke({requestId:r,content:c})})},[T]),ot=(0,i.useCallback)(async r=>{await e(`/api/assistants/${r}`),f===r&&M(null),await T()},[e,T,f]),D=(0,i.useMemo)(()=>p.find(r=>r.id===f)||null,[p,f]),te=D?.trainingProjectId??m[0]?.id??null,rt=(0,i.useMemo)(()=>f&&D?{id:f,name:D.name,type:"workflow"}:null,[f,D]),it=(0,i.useMemo)(()=>{let r=y?.nodes.filter(v=>v.type!=="terminal"&&v.ref).map(v=>v.ref).filter((v,R,A)=>A.indexOf(v)===R)??[];if(r.length===0)return S;let c=x.filter(v=>{let R=v.key;return R&&r.includes(R)});if(c.length===0)return S;let a={...S??{}},l=new Set(a.tools??[]),k=[...a.middleware??[]],E=new Set(a.subAgents??[]),N=new Set(k.map(v=>v.type).filter(Boolean));for(let v of c){let R=v;for(let A of R.tools??[])l.add(A);for(let A of R.middleware??[]){let ne=A.type;ne&&!N.has(ne)&&(k.push(A),N.add(ne))}for(let A of R.subAgents??[])E.add(A)}return a.tools=Array.from(l),a.middleware=k,a.subAgents=Array.from(E),a},[y,S,x]);return Je?(0,n.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,n.jsx)(re,{size:"large",tip:"Loading workflows..."})}):ye?(0,n.jsx)(H,{description:ye}):p.length===0?(0,n.jsxs)("div",{style:{width:"100%",height:"100%"},children:[(0,n.jsx)(ue,{open:he,onCancel:()=>O(!1),onCreated:ve,type:"workflow"}),(0,n.jsx)(H,{description:"No workflow definitions found.",children:(0,n.jsx)(q,{type:"primary",icon:(0,n.jsx)(ie,{}),onClick:()=>O(!0),children:"Create Workflow"})})]}):(0,n.jsxs)("div",{style:{width:"100%",height:"100%"},children:[(0,n.jsx)(ue,{open:he,onCancel:()=>O(!1),onCreated:ve,type:"workflow"}),(0,n.jsx)(G,{title:D?.name,open:Qe,onCancel:()=>xe(!1),footer:null,width:"85vw",centered:!0,styles:{body:{maxHeight:"calc(85vh - 120px)",overflow:"auto",padding:"12px 24px 24px"}},children:D?.description?(0,n.jsx)(Ne,{content:D.description}):(0,n.jsx)(F,{type:"secondary",children:"No description set."})}),(0,n.jsx)(_e,{children:(0,n.jsxs)("div",{style:{height:"100%",width:"100%",position:"relative",overflow:"hidden"},children:[(0,n.jsx)(ut,{workflows:p,selectedId:f,onSelect:nt,onCreate:()=>O(!0),onDelete:ot,dsl:y,agentNameMap:I,onSpecClick:()=>xe(!0),environmentConfig:it}),!C&&f&&(0,n.jsx)("div",{style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",zIndex:20},children:(0,n.jsx)("div",{onClick:()=>me(!0),style:{writingMode:"vertical-rl",textOrientation:"mixed",padding:"16px 8px",background:"#6366f1",color:"#fff",borderRadius:"8px 0 0 8px",cursor:"pointer",fontSize:12,fontWeight:500,userSelect:"none"},children:"Copilot"})}),C&&f&&te&&!d&&(0,n.jsxs)("div",{style:{position:"absolute",right:16,top:48,bottom:12,zIndex:15,width:Z,borderRadius:16,overflow:"hidden",boxShadow:"0 4px 24px rgba(0,0,0,0.12)"},children:[(0,n.jsx)("div",{onMouseDown:tt,style:{position:"absolute",left:0,top:0,bottom:0,width:6,cursor:"ew-resize",zIndex:2,background:"transparent"}}),(0,n.jsx)(Be,{defaultWorkspaceId:s??void 0,defaultProjectId:te??void 0,children:(0,n.jsx)(qe,{workflowContext:rt,onClose:()=>me(!1),onToolCompleted:r=>{et.includes(r)&&(T(),f&&ee(f))},initialMessageRequest:Ze,onInitialMessageSubmitted:r=>ke(c=>c?.requestId===r?null:c)})},`${s??"default"}:${te??"default"}`)]})]})})]})},qt=bt;export{bt as WorkflowAutomationView,qt as default};
@@ -1,4 +1,4 @@
1
- import{a as _i}from"./embed-page-chunk-2G54EIW2.js";import{a as cr,b as Pn}from"./embed-page-chunk-SUMYB6ZA.js";import{b as Gi,c as $i}from"./embed-page-chunk-N2ISCAS7.js";import{c as bo,d as vo}from"./embed-page-chunk-KEL6XU6R.js";import{b as it,c as Pi,d as yo,e as Rt,f as ho,g as Di,h as Cn,i as An,j as Li,l as Ni,m as Mi}from"./embed-page-chunk-AC6X2XRH.js";import{a as ji,b as qi}from"./embed-page-chunk-OHDEKFTU.js";import{B as li,Ba as Ri,D as di,Da as go,E as ci,Ea as Ii,G as ui,H as pi,Ha as In,J as uo,Na as Sn,Oa as fo,P as gi,Pa as Si,Sa as Ci,Ta as Ai,Ua as Ei,Va as mo,aa as fi,ba as mi,ca as yi,ea as hi,fa as bi,h as ii,hb as Oi,ib as ko,j as ai,jb as wo,k as $n,ka as vi,kb as xo,lb as Fi,mb as To,nb as Wi,oa as ki,ob as zi,pb as Ro,qb as En,sa as po,sb as dr,t as si,ta as wi,tb as Bi,ua as xi,va as Ti,wa as Pt}from"./embed-page-chunk-XIXSRYJY.js";import{b as Zr,i as Vr,j as Qr,m as yt,q as ao,r as Ve}from"./embed-page-chunk-HEMNMC4X.js";import{a as M}from"./embed-page-chunk-MB65DZAX.js";import{Cb as lo,Db as ti,Dc as ni,Fc as oi,Gc as sr,Ha as io,Hc as lr,Ia as qe,Ja as Kr,La as We,Ma as Ur,Sc as ri,Tb as ar,U as Vt,W as ee,Wa as Yr,Y as Rn,Z as Wt,_ as mt,aa as Qt,ca as rr,da as ir,eb as Xr,fa as $r,fc as co,ia as cn,la as qr,mb as Jr,na as Hr,oa as Et,ob as ei,ra as pe,ta as De,tb as so,va as Tt,xa as rt,ya as _e,yc as Yt}from"./embed-page-chunk-O4QK5LWZ.js";import{a as Te}from"./embed-page-chunk-4BKXE5ON.js";import{e as R}from"./embed-page-chunk-6Y3UYJ6Z.js";var Gs={react:{label:"capability",color:"blue"},capability:{label:"capability",color:"blue"},deep_agent:{label:"orchestrator",color:"orange"},orchestrator:{label:"orchestrator",color:"orange"},team:{label:"team",color:"green"},processing:{label:"workflow",color:"purple"},workflow:{label:"workflow",color:"purple"},a2a_remote:{label:"remote",color:"cyan"},remote:{label:"remote",color:"cyan"}};function Dn(e){return Gs[e]??{label:"capability",color:"blue"}}var $s={enabled:"green",draft:"orange",disabled:"default"};function Ki(e){return $s[e]??"default"}var Hi={blue:"#3b82f6",orange:"#f59e0b",green:"#22c55e",purple:"#a855f7",cyan:"#06b6d4"};function qn(e){return Hi[e]??Hi.cyan}function Hd(e){let t={enabled:"#22c55e",draft:"#f59e0b",disabled:"#d9d9d9"};return t[e]??t.disabled}function Ln(e){return typeof e.graphDefinition=="object"&&e.graphDefinition!==null?e.graphDefinition:{}}function pr(e){return((Ln(e).metadata??{}).tags??"").split(",").map(r=>r.trim()).filter(Boolean)}function gr(e){let o=(Ln(e).metadata??{}).version;return o?o.startsWith("v")?o:`v${o}`:"v1"}function fr(e){let o=(Ln(e).metadata??{}).status??"enabled";return o==="draft"||o==="disabled"?o:"enabled"}function ur(e){let n=Ln(e).subAgents??[],o=Array.isArray(n)?n.filter(Boolean):[];return Array.from(new Set(o))}function Kd(e){return e.map(t=>{let n=Ln(t),o=String(n.type??"react");return{id:t.id,name:t.name,description:t.description,type:Dn(o).label,tags:pr(t),version:gr(t),status:fr(t),subAgents:ur(t)}})}function Ud(e){let t=new Set(e.map(r=>r.id)),n=e.map(r=>({id:r.id,label:r.name,type:Dn(String(Ln(r).type??"react")).label,subAgentCount:ur(r).length})),o=[];for(let r of e)for(let i of ur(r))t.has(i)&&o.push({source:r.id,target:i});return{nodes:n,edges:o}}var Ie=R(Te());var ne=R(Te());var h=R(M()),{TextArea:qs}=De,{Text:It}=We,Ui=["data","execution","workflow","assistant"],Hs={data:"Data & Knowledge",execution:"Execution & Interaction",workflow:"Workflow & Orchestration",assistant:"Assistant & Evaluation",other:"Other"},Hn=(e,t)=>{if(Array.isArray(e)){let n=e.map(o=>Hn(o));return(t==="tools"||t==="subAgents")&&n.every(o=>typeof o=="string")?[...n].sort():n}return e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).sort(([n],[o])=>n.localeCompare(o)).map(([n,o])=>[n,Hn(o,n)])):e},Zi=e=>{if(typeof e!="string")return Hn(e??null);try{return Hn(JSON.parse(e))}catch{return e}},Vi=e=>JSON.stringify(Hn({...e,tools:[...e.tools].sort(),subAgents:[...e.subAgents].sort()})),Ks=Ti(({token:e,css:t})=>({modalBody:t`
1
+ import{a as _i}from"./embed-page-chunk-UT3WYBZH.js";import{a as cr,b as Pn}from"./embed-page-chunk-N22EGQAJ.js";import{b as Gi,c as $i}from"./embed-page-chunk-IPIJ2SG6.js";import{c as bo,d as vo}from"./embed-page-chunk-KEL6XU6R.js";import{b as it,c as Pi,d as yo,e as Rt,f as ho,g as Di,h as Cn,i as An,j as Li,l as Ni,m as Mi}from"./embed-page-chunk-AC6X2XRH.js";import{a as ji,b as qi}from"./embed-page-chunk-O72XBKQH.js";import{A as ci,Aa as Ii,C as ui,D as pi,Da as In,F as uo,Ja as Sn,Ka as fo,L as gi,La as Si,Oa as Ci,Pa as Ai,Qa as Ei,Ra as mo,Y as fi,Z as mi,_ as yi,aa as hi,ba as bi,d as ii,db as Oi,eb as ko,f as ai,fb as wo,g as $n,ga as vi,gb as xo,hb as Fi,ib as To,jb as Wi,ka as ki,kb as zi,lb as Ro,mb as En,oa as po,ob as dr,p as si,pa as wi,pb as Bi,qa as xi,ra as Ti,sa as Pt,x as li,xa as Ri,z as di,za as go}from"./embed-page-chunk-QMVIL4BJ.js";import{i as Zr,p as Vr,q as Qr,t as yt,x as ao,y as Ve}from"./embed-page-chunk-YPNSOZYW.js";import{a as M}from"./embed-page-chunk-MB65DZAX.js";import{Cb as lo,Db as ti,Dc as ni,Fc as oi,Gc as sr,Ha as io,Hc as lr,Ia as qe,Ja as Kr,La as We,Ma as Ur,Sc as ri,Tb as ar,U as Vt,W as ee,Wa as Yr,Y as Rn,Z as Wt,_ as mt,aa as Qt,ca as rr,da as ir,eb as Xr,fa as $r,fc as co,ia as cn,la as qr,mb as Jr,na as Hr,oa as Et,ob as ei,ra as pe,ta as De,tb as so,va as Tt,xa as rt,ya as _e,yc as Yt}from"./embed-page-chunk-O4QK5LWZ.js";import{a as Te}from"./embed-page-chunk-4BKXE5ON.js";import{e as R}from"./embed-page-chunk-6Y3UYJ6Z.js";var Gs={react:{label:"capability",color:"blue"},capability:{label:"capability",color:"blue"},deep_agent:{label:"orchestrator",color:"orange"},orchestrator:{label:"orchestrator",color:"orange"},team:{label:"team",color:"green"},processing:{label:"workflow",color:"purple"},workflow:{label:"workflow",color:"purple"},a2a_remote:{label:"remote",color:"cyan"},remote:{label:"remote",color:"cyan"}};function Dn(e){return Gs[e]??{label:"capability",color:"blue"}}var $s={enabled:"green",draft:"orange",disabled:"default"};function Ki(e){return $s[e]??"default"}var Hi={blue:"#3b82f6",orange:"#f59e0b",green:"#22c55e",purple:"#a855f7",cyan:"#06b6d4"};function qn(e){return Hi[e]??Hi.cyan}function Hd(e){let t={enabled:"#22c55e",draft:"#f59e0b",disabled:"#d9d9d9"};return t[e]??t.disabled}function Ln(e){return typeof e.graphDefinition=="object"&&e.graphDefinition!==null?e.graphDefinition:{}}function pr(e){return((Ln(e).metadata??{}).tags??"").split(",").map(r=>r.trim()).filter(Boolean)}function gr(e){let o=(Ln(e).metadata??{}).version;return o?o.startsWith("v")?o:`v${o}`:"v1"}function fr(e){let o=(Ln(e).metadata??{}).status??"enabled";return o==="draft"||o==="disabled"?o:"enabled"}function ur(e){let n=Ln(e).subAgents??[],o=Array.isArray(n)?n.filter(Boolean):[];return Array.from(new Set(o))}function Kd(e){return e.map(t=>{let n=Ln(t),o=String(n.type??"react");return{id:t.id,name:t.name,description:t.description,type:Dn(o).label,tags:pr(t),version:gr(t),status:fr(t),subAgents:ur(t)}})}function Ud(e){let t=new Set(e.map(r=>r.id)),n=e.map(r=>({id:r.id,label:r.name,type:Dn(String(Ln(r).type??"react")).label,subAgentCount:ur(r).length})),o=[];for(let r of e)for(let i of ur(r))t.has(i)&&o.push({source:r.id,target:i});return{nodes:n,edges:o}}var Ie=R(Te());var ne=R(Te());var h=R(M()),{TextArea:qs}=De,{Text:It}=We,Ui=["data","execution","workflow","assistant"],Hs={data:"Data & Knowledge",execution:"Execution & Interaction",workflow:"Workflow & Orchestration",assistant:"Assistant & Evaluation",other:"Other"},Hn=(e,t)=>{if(Array.isArray(e)){let n=e.map(o=>Hn(o));return(t==="tools"||t==="subAgents")&&n.every(o=>typeof o=="string")?[...n].sort():n}return e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).sort(([n],[o])=>n.localeCompare(o)).map(([n,o])=>[n,Hn(o,n)])):e},Zi=e=>{if(typeof e!="string")return Hn(e??null);try{return Hn(JSON.parse(e))}catch{return e}},Vi=e=>JSON.stringify(Hn({...e,tools:[...e.tools].sort(),subAgents:[...e.subAgents].sort()})),Ks=Ti(({token:e,css:t})=>({modalBody:t`
2
2
  padding: 0;
3
3
  height: 92vh;
4
4
  width: 100%;
@@ -1,4 +1,4 @@
1
- import{b as cn,c as sn,d as _n}from"./embed-page-chunk-KEL6XU6R.js";import{a as ln,b as be,e as Ae,f as vn,h as Cn,i as kn}from"./embed-page-chunk-AC6X2XRH.js";import{Ha as on,L as xn,V as Sn,Y as bn,ja as An,pa as wn,s as Re,sa as Tn,u as mn,x as yn,y as Oe,z as Me}from"./embed-page-chunk-XIXSRYJY.js";import{a as Xe}from"./embed-page-chunk-MB65DZAX.js";import{Ia as se,La as Ke,Z as fn,aa as ve,ba as dn,fa as gn,va as hn}from"./embed-page-chunk-O4QK5LWZ.js";import{a as or}from"./embed-page-chunk-4BKXE5ON.js";import{e as Le}from"./embed-page-chunk-6Y3UYJ6Z.js";var te=Le(or());var _=Le(Xe());if(typeof document<"u"){let p="workflow-node-spin-keyframes";if(!document.getElementById(p)){let o=document.createElement("style");o.id=p,o.textContent="@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }",document.head.appendChild(o)}}var{Text:ue}=Ke,Ve={opacity:0},Fe={running:{color:"#1677ff",icon:(0,_.jsx)(bn,{size:14,style:{animation:"spin 1s linear infinite"}})},completed:{color:"#52c41a",icon:(0,_.jsx)(Re,{size:14})},failed:{color:"#ff4d4f",icon:(0,_.jsx)(Oe,{size:14})},interrupted:{color:"#faad14",icon:(0,_.jsx)(mn,{size:14})},skipped:{color:"#8c8c8c",icon:(0,_.jsx)(Me,{size:14})}},En={running:"This step is currently executing",completed:"This step completed successfully",failed:"This step encountered an error",interrupted:"This step is waiting for human input",skipped:"This step was skipped (condition not met)"},In={color:"#d9d9d9",icon:(0,_.jsx)(Me,{size:14})},Nn={agent:{color:"#6366f1",bg:"#EEF2FF",border:"#6366f1"},map:{color:"#10b981",bg:"#ECFDF5",border:"#10b981"},terminal:{color:"#64748b",bg:"#F8FAFC",border:"#94a3b8"}},Ln={success:{color:"#22c55e",bg:"#F0FDF4",label:"Success"},failed:{color:"#ef4444",bg:"#FEF2F2",label:"Failed"},__default:{color:"#94a3b8",bg:"#F8FAFC",label:"Stop"}};function lr(p){return(p||"?").split(/[\s_-]+/).filter(Boolean).map(o=>o[0]).join("").toUpperCase().slice(0,2)}function un({schema:p}){let o=p;if(!o||typeof o!="object")return(0,_.jsx)(ue,{type:"secondary",style:{fontSize:11},children:"No schema defined"});let d=o.properties,S=o.required||[],b=o.items,O=l=>l==="string"?"green":l==="number"||l==="integer"?"orange":l==="boolean"?"purple":l==="array"?"cyan":l==="object"?"blue":"default",a=l=>{let u=l.type;if(u==="array"&&l.items){let c=l.items.type;return c?`Array<${c}>`:"Array"}return u||"any"};return(0,_.jsxs)("div",{style:{maxWidth:340,maxHeight:360,overflow:"auto",fontSize:12},children:[d&&(0,_.jsxs)("div",{children:[(0,_.jsx)(ue,{type:"secondary",style:{fontSize:10,textTransform:"uppercase",letterSpacing:.5,display:"block",marginBottom:6},children:"Properties"}),Object.entries(d).map(([l,u])=>{let c=S.includes(l),h=u.description,r=a(u),s=u.properties,w=u.items,I=!!(s||w);return(0,_.jsx)(ve,{title:I?(0,_.jsx)(un,{schema:I?s?u:w:void 0}):h||void 0,placement:"left",overlayStyle:{maxWidth:360},children:(0,_.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"3px 6px",borderRadius:4,marginBottom:2,background:c?"rgba(99,102,241,0.04)":"transparent",cursor:I?"pointer":"default"},children:[(0,_.jsx)(ue,{style:{fontSize:11,fontWeight:c?600:400,fontFamily:"monospace"},children:l}),c&&(0,_.jsx)("span",{style:{color:"#ef4444",fontSize:9},children:"*"}),h&&!I&&(0,_.jsx)(ue,{type:"secondary",style:{fontSize:10,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h}),(0,_.jsx)(se,{color:O(r),style:{margin:0,fontSize:9,padding:"0 4px",lineHeight:"16px",marginLeft:"auto"},children:r})]})},l)})]}),!d&&b&&(0,_.jsxs)("div",{children:[(0,_.jsx)(ue,{type:"secondary",style:{fontSize:10,textTransform:"uppercase",letterSpacing:.5,display:"block",marginBottom:4},children:"Items"}),(0,_.jsx)(un,{schema:b})]})]})}var Rn=72,cr=3,sr=({data:p})=>{if(!p)return null;let{nodeType:o,name:d,description:S,ref:b,refAgentName:O,refAgentType:a,refDeleted:l,outputKey:u,nodeSchema:c,config:h,status:r,source:s,innerRef:w,inputTemplate:I,ask:B,condition:X,runState:P,pending:L}=p,z=Nn[o]||Nn.agent,k=Ln[r||""]||Ln.__default,j=P?Fe[P.status]||Fe.running:null,M=j?.color,Y=j?.icon,q=r==="success"?(0,_.jsx)(Re,{size:14,color:"#22c55e"}):r==="failed"?(0,_.jsx)(Oe,{size:14,color:"#ef4444"}):(0,_.jsx)(Me,{size:14,color:"#94a3b8"}),ne=r==="success"?(0,_.jsx)(Re,{size:32,color:k.color}):r==="failed"?(0,_.jsx)(Oe,{size:32,color:k.color}):(0,_.jsx)(yn,{size:32,color:k.color}),de=h?.title,ie=h?.maxRetries,oe=h?.timeout,J=h?.batchSize,le=h?.maxConcurrency,V=h?.innerConcurrency,G=P?.selected,U=!!P||L;function E($){return $==null?"-":$<1e3?`${$}ms`:`${($/1e3).toFixed(1)}s`}if(o==="terminal"){let $=k.color,Te=k.bg,ee=k.label,ae=ne;U&&(P?($=M||$,ee=P.status,ae=(0,_.jsx)("span",{style:{fontSize:18},children:Y})):L&&($=In.color,Te="#fafafa",ee="pending",ae=(0,_.jsx)(Me,{size:18,style:{color:In.color}})));let pe=G&&M?`0 4px 16px ${M}30`:"0 2px 8px rgba(0,0,0,0.06)";return(0,_.jsxs)("div",{style:{padding:4,display:"flex",flexDirection:"column",alignItems:"center",opacity:L?.5:1},children:[(0,_.jsx)(Ae,{type:"target",position:be.Top,style:Ve}),(0,_.jsx)(ve,{title:U&&P?En[P.status]:d,children:(0,_.jsx)("div",{style:{width:Rn,height:Rn,borderRadius:"50%",background:Te,border:`${cr}px solid ${L?`${$}80`:$}`,borderStyle:L?"dashed":"solid",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:pe,transition:"all 0.2s ease",cursor:"default"},onMouseEnter:L?void 0:fe=>{fe.currentTarget.style.transform="scale(1.08)",fe.currentTarget.style.boxShadow=`0 4px 16px ${$}30`},onMouseLeave:L?void 0:fe=>{fe.currentTarget.style.transform="scale(1)",fe.currentTarget.style.boxShadow=pe},children:ae})}),(0,_.jsx)(ue,{style:{fontSize:11,color:$,marginTop:6,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px"},children:ee}),(0,_.jsx)(Ae,{type:"source",position:be.Bottom,style:Ve})]})}let ge=U&&M?M:z.border,ce=U&&M?M:z.color,_e=o==="agent"?(0,_.jsx)(Tn,{size:14}):o==="map"?(0,_.jsx)(An,{size:14}):lr(d),he=P?E(P.durationMs):null,Ce=G&&M?`0 4px 14px ${M}20`:"0 1px 6px rgba(0,0,0,0.08)",we=U&&M?M:z.color;return(0,_.jsxs)("div",{style:{padding:4},children:[(0,_.jsx)(Ae,{type:"target",position:be.Top,style:Ve}),(0,_.jsxs)("div",{style:{width:260,minHeight:90,boxSizing:"border-box",background:"#fff",borderRadius:12,boxShadow:Ce,border:"1px solid #e5e7eb",borderLeft:`3px solid ${ge}`,borderStyle:b?"dashed":"solid",overflow:"hidden",transition:"all 0.2s ease",...L?{opacity:.5,borderStyle:"dashed"}:{}},onMouseEnter:L?void 0:$=>{$.currentTarget.style.transform="translateY(-2px)",$.currentTarget.style.boxShadow=`0 4px 12px ${we}20`},onMouseLeave:L?void 0:$=>{$.currentTarget.style.transform="translateY(0)",$.currentTarget.style.boxShadow=Ce},children:[(0,_.jsxs)("div",{style:{background:z.bg,padding:"6px 12px",display:"flex",alignItems:"center",gap:6,borderBottom:"1px solid #f1f5f9"},children:[(0,_.jsx)("div",{style:{width:24,height:24,borderRadius:"50%",backgroundColor:ce,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:600,flexShrink:0},children:_e}),(0,_.jsx)("div",{style:{flex:1,minWidth:0},children:(0,_.jsx)(ue,{strong:!0,style:{fontSize:12,color:z.color},ellipsis:{tooltip:d},children:d})}),U&&Y&&(0,_.jsx)(ve,{title:P?En[P.status]:void 0,children:(0,_.jsx)("span",{style:{color:M,fontSize:12,display:"flex",flexShrink:0},children:Y})})]}),(0,_.jsxs)("div",{style:{padding:"10px 12px"},children:[S&&(0,_.jsx)(ue,{type:"secondary",style:{fontSize:11,display:"block",marginTop:2,lineHeight:1.4},ellipsis:{tooltip:S},children:S}),o==="map"&&s&&(0,_.jsxs)(ue,{type:"secondary",style:{fontSize:11,display:"block",marginTop:4,lineHeight:1.4,color:z.color,background:z.bg,padding:"2px 6px",borderRadius:4,maxHeight:32,overflow:"hidden"},ellipsis:{tooltip:s},children:["\u2190 ",s]}),o!=="map"&&I&&(0,_.jsx)(ue,{type:"secondary",style:{fontSize:11,display:"block",marginTop:4,lineHeight:1.4,color:z.color,background:z.bg,padding:"2px 6px",borderRadius:4,maxHeight:32,overflow:"hidden"},ellipsis:{tooltip:I},children:I}),(0,_.jsxs)("div",{style:{display:"flex",gap:4,marginTop:6,flexWrap:"wrap"},children:[!U&&o==="agent"&&b&&(0,_.jsx)(ve,{title:l?`Agent "${b}" no longer exists`:`Delegated to agent: ${O??b}`,children:(0,_.jsx)(se,{color:l?"red":"purple",style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px"},icon:(0,_.jsx)(Sn,{size:10}),children:l?`[\u5DF2\u5220\u9664] ${b}`:`\u2192 ${O??b}`})}),!U&&o==="agent"&&!b&&(0,_.jsx)(se,{color:"default",style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px"},children:"inline"}),B&&(0,_.jsx)(ve,{title:"This step requires human approval before continuing",children:(0,_.jsx)("div",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,borderRadius:"50%",background:"#fff7e6",border:"1px solid #ffd591",cursor:"default"},children:(0,_.jsx)(wn,{size:12,style:{color:"#fa8c16"}})})}),X&&(0,_.jsx)(ve,{title:`When: ${X}`,children:(0,_.jsx)("div",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,borderRadius:"50%",background:"#f0f5ff",border:"1px solid #adc6ff",cursor:"default"},children:(0,_.jsx)(xn,{size:12,style:{color:"#2f54eb"}})})}),!U&&o==="map"&&w&&(0,_.jsx)(se,{color:"purple",style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px"},children:w}),!U&&o==="map"&&I&&(0,_.jsx)(se,{color:"default",style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px",maxWidth:120},title:I,children:I.length>20?I.slice(0,18)+"\u2026":I}),!U&&o==="map"&&(J||le||V)&&(0,_.jsxs)(se,{color:"cyan",style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px"},children:[J??50,"\xD7",le??10,"\xD7",V??5]}),!U&&ie?(0,_.jsxs)(se,{style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px"},children:["\u21BB ",ie]}):null,!U&&oe?(0,_.jsxs)(se,{style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px"},children:["\u23F1 ",oe,"s"]}):null,he&&(0,_.jsx)(se,{color:P?"blue":"default",style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px"},children:he}),u&&(0,_.jsx)("span",{style:{marginLeft:"auto"}}),u&&(0,_.jsx)(dn,{trigger:"hover",placement:"right",mouseEnterDelay:.2,title:(0,_.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,_.jsx)(ue,{strong:!0,style:{fontSize:12},children:"Output"}),(0,_.jsx)(ue,{style:{fontSize:11,fontFamily:"monospace",color:"#6366f1"},children:u})]}),content:c?(0,_.jsx)(un,{schema:c}):(0,_.jsx)(ue,{type:"secondary",style:{fontSize:11},children:"No schema defined"}),children:(0,_.jsxs)(se,{style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px",flexShrink:0,cursor:"default"},children:["\u2192 ",u]})})]})]})]}),(0,_.jsx)(Ae,{type:"source",position:be.Bottom,style:Ve})]})},On=sr;var H=Le(Xe()),{Text:me}=Ke;function Mn(p){return new Date(p).toLocaleString()}function ur(p){return p.input?typeof p.input.rendered=="string"?p.input.rendered:typeof p.input.description=="string"?p.input.description:JSON.stringify(p.input,null,2):null}function ar(p){return p.output?typeof p.output.result=="string"?p.output.result:typeof p.output=="object"?JSON.stringify(p.output,null,2):String(p.output):null}function pr({step:p}){let o=ur(p),d=ar(p),S=Fe[p.status]||Fe.running,b=[{key:"io",label:"Input / Output",children:(0,H.jsxs)(H.Fragment,{children:[o&&(0,H.jsxs)("div",{style:{marginBottom:d?12:0},children:[(0,H.jsx)(me,{type:"secondary",style:{fontSize:10,textTransform:"uppercase",letterSpacing:.5},children:"Input"}),(0,H.jsx)("div",{style:{background:"rgba(0,0,0,0.02)",borderRadius:8,padding:"8px 10px",marginTop:4,maxHeight:200,overflow:"auto"},children:p.input?.description?(0,H.jsx)(on,{content:o}):(0,H.jsx)("pre",{style:{margin:0,fontSize:11,whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"monospace"},children:o})})]}),d&&(0,H.jsxs)("div",{children:[(0,H.jsx)(me,{type:"secondary",style:{fontSize:10,textTransform:"uppercase",letterSpacing:.5},children:"Output"}),(0,H.jsx)("div",{style:{background:"linear-gradient(135deg, rgba(99,102,241,0.04) 0%, rgba(99,102,241,0.01) 100%)",borderRadius:8,padding:"8px 10px",marginTop:4,maxHeight:200,overflow:"auto"},children:p.output?.result?(0,H.jsx)(on,{content:d}):(0,H.jsx)("pre",{style:{margin:0,fontSize:11,whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"monospace"},children:d})})]}),!o&&!d&&(0,H.jsx)(me,{type:"secondary",style:{fontSize:11},children:"No input/output data"})]})}];return(0,H.jsxs)("div",{style:{maxWidth:480},children:[(0,H.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[(0,H.jsx)("span",{style:{color:S.color,fontSize:14},children:S.icon}),(0,H.jsx)(me,{strong:!0,style:{fontSize:14},children:p.stepName}),(0,H.jsx)(se,{color:"purple",style:{fontSize:11},children:p.stepType})]}),p.edgePurpose&&(0,H.jsx)("div",{style:{marginBottom:10},children:(0,H.jsxs)(me,{type:"secondary",style:{fontSize:11},children:["Purpose: ",p.edgePurpose]})}),p.errorMessage&&(0,H.jsx)("div",{style:{background:"#FEF2F2",border:"1px solid #FECACA",borderRadius:8,padding:"8px 12px",marginBottom:12,overflow:"hidden"},children:(0,H.jsx)(me,{type:"danger",style:{fontSize:11,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:p.errorMessage})}),(0,H.jsx)(gn,{activeKey:"io",items:b,size:"small",style:{marginBottom:-8}}),(0,H.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",marginTop:12,paddingTop:8,borderTop:"1px solid #f0f0f0"},children:[(0,H.jsxs)(me,{type:"secondary",style:{fontSize:10},children:["Started: ",Mn(p.startedAt)]}),p.completedAt&&(0,H.jsxs)(me,{type:"secondary",style:{fontSize:10},children:["Ended: ",Mn(p.completedAt)]})]})]})}function De(p,o){return p.find(d=>d.stepName===o.name)??null}function Qe(p,o,d,S){let b=p.ref&&S?S.get(p.ref):void 0;return{nodeType:p.type,name:p.name,description:p.description,ref:p.ref,refAgentName:b?.name,refAgentType:b?.type,refDeleted:p.ref&&S?!b:void 0,outputKey:p.output?.key,nodeSchema:p.output?.schema,config:p.config,status:p.status,source:p.source,innerRef:p.node?.ref,inputTemplate:p.input?.template,ask:p.ask,condition:p.condition,runState:o,pending:d}}function Fn(p){let o=new Map;for(let d of p)if(d.parentGroup&&d.type!=="terminal"){let S=o.get(d.parentGroup)||[];S.push(d.id),o.set(d.parentGroup,S)}return Array.from(o.entries()).map(([d,S])=>({sourceId:d,childIds:S}))}function fr(){return(0,H.jsxs)("div",{style:{width:"100%",height:"100%",position:"relative",pointerEvents:"none"},children:[(0,H.jsx)(Ae,{type:"target",position:be.Top,style:{opacity:0}}),(0,H.jsx)(Ae,{type:"source",position:be.Bottom,style:{opacity:0}}),(0,H.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,border:"2px dashed #a78bfa",borderRadius:12,background:"rgba(167, 139, 250, 0.04)"}}),(0,H.jsx)("div",{style:{position:"absolute",top:8,left:12,fontSize:12,fontWeight:600,color:"#7c3aed",padding:"2px 8px",background:"rgba(167, 139, 250, 0.08)",borderRadius:6,whiteSpace:"nowrap",zIndex:2},children:"Parallel"})]})}function dr(p,o){let d=p.nodes,S=p.edges,b=Fn(d),O=new Set(b.map(L=>L.sourceId)),a=new Set(b.flatMap(L=>L.childIds)),l=268,u=100,c=40;for(let L of b){let z=d.find(k=>k.id===L.sourceId);if(z){let k=L.childIds.length;z.width=k*l+(k-1)*c+40,z.height=u+100}}let h=d.filter(L=>!a.has(L.id)),r=sn(h,S,{nodeWidth:l,nodeHeight:u,ranksep:120}),s=h.find(L=>!O.has(L.id)&&L.type!=="terminal"),w=s?r.get(s.id):void 0,I=s?s.width??l:l,B=w?w.x+I/2:0;for(let L of h){if(O.has(L.id))continue;let z=r.get(L.id);if(!z)continue;let k=L.width??l;z.x=B-k/2}let X=h.filter(L=>r.has(L.id)&&!O.has(L.id)&&L.type!=="terminal").map(L=>{let z=r.get(L.id);return{id:L.id,type:"workflow",position:z,data:{...Qe(L,void 0,void 0,o)}}});for(let L of b){let z=d.find(J=>J.id===L.sourceId),k=r.get(L.sourceId);if(!z||!k)continue;let j=z.width,M=z.height,Y=L.childIds.length,q=B-j/2,ne=Y*l+(Y-1)*c,de=B-ne/2,ie=k.y+(M-u)/2;for(let J=0;J<Y;J++){let le=L.childIds[J],V=d.find(G=>G.id===le);V&&X.push({id:V.id,type:"workflow",position:{x:de+J*(l+c),y:ie},data:{...Qe(V,void 0,void 0,o),parallelGroup:!0},style:{zIndex:2}})}let oe=`group_${L.sourceId}`;X.push({id:oe,type:"groupLabel",position:{x:q,y:k.y},data:{},selectable:!1,draggable:!1,style:{zIndex:0,width:j,height:M}})}let P=[];for(let L of S){let z=cn(L);for(let k of z){let j=d.find(q=>q.id===k);if(j?.type==="terminal"&&j.name==="__end"||O.has(L.from)&&d.find(ne=>ne.id===k)?.parentGroup===L.from)continue;let M=O.has(L.from)?`group_${L.from}`:L.from,Y=O.has(k)?`group_${k}`:k;P.push({id:`${M}-${Y}`,source:M,target:Y,type:"straight",markerEnd:{type:ln.ArrowClosed}})}}return{nodes:X,edges:P}}function gr(p,o,d,S){let b=p.nodes,O=p.edges,a=Fn(b),l=new Set(a.map(k=>k.sourceId)),u=new Set(a.flatMap(k=>k.childIds)),c=268,h=100,r=40;for(let k of a){let j=b.find(M=>M.id===k.sourceId);if(j){let M=k.childIds.length;j.width=M*c+(M-1)*r+40,j.height=h+100}}let s=b.filter(k=>!u.has(k.id)),w=sn(s,O,{nodeWidth:c,nodeHeight:h,ranksep:120}),I=s.find(k=>!l.has(k.id)&&k.type!=="terminal"),B=I?w.get(I.id):void 0,X=I?I.width??c:c,P=B?B.x+X/2:0;for(let k of s){if(l.has(k.id))continue;let j=w.get(k.id);if(!j)continue;let M=k.width??c;j.x=P-M/2}let L=s.filter(k=>w.has(k.id)&&!l.has(k.id)).map(k=>{let j=w.get(k.id),M=De(o,k),Y=k.type==="terminal",q=M&&(!Y||M.status!=="running")?{status:M.status,stepType:M.stepType,durationMs:M.durationMs,selected:!1}:void 0;return{id:k.id,type:"workflow",position:j,style:Y?{width:c,height:h}:void 0,data:Qe(k,q,!M&&!Y,S)}});for(let k of a){let j=b.find(V=>V.id===k.sourceId),M=w.get(k.sourceId);if(!j||!M)continue;let Y=j.width,q=j.height,ne=k.childIds.length,de=ne*c+(ne-1)*r,ie=P-de/2,oe=M.y+(q-h)/2;for(let V=0;V<ne;V++){let G=k.childIds[V],U=b.find(ce=>ce.id===G);if(!U)continue;let E=De(o,U),ge=E?{status:E.status,stepType:E.stepType,durationMs:E.durationMs,selected:!1}:void 0;L.push({id:U.id,type:"workflow",position:{x:ie+V*(c+r),y:oe},data:{...Qe(U,ge,!E,S),parallelGroup:!0},style:{zIndex:2}})}let J=P-Y/2,le=`group_${k.sourceId}`;L.push({id:le,type:"groupLabel",position:{x:J,y:M.y},data:{},selectable:!1,draggable:!1,style:{zIndex:0,width:Y,height:q}})}let z=[];for(let k of O){let j=cn(k);for(let M of j){if(l.has(k.from)&&b.find(E=>E.id===M)?.parentGroup===k.from)continue;let Y=l.has(k.from)?`group_${k.from}`:k.from,q=l.has(M)?`group_${M}`:M,ne=b.find(U=>U.id===k.from),ie=(ne?De(o,ne):void 0)!==void 0,oe=b.find(U=>U.id===M),le=(oe?De(o,oe):void 0)!==void 0,V=ie&&le,G=V?"#6366f1":"#d9d9d9";z.push({id:`${Y}-${q}`,source:Y,target:q,type:"straight",animated:V,style:V?{stroke:G,strokeWidth:2}:{stroke:G,strokeWidth:2,strokeDasharray:"6 4",opacity:.25},markerEnd:{type:ln.ArrowClosed,color:G,width:20,height:20}})}}return{nodes:L,edges:z}}var hr=({dsl:p,steps:o,assistantId:d,agentNameMap:S,onNodeClick:b,height:O="100%"})=>{let a=!!o,l=(0,te.useMemo)(()=>({workflow:On,groupLabel:fr}),[]),{nodes:u,edges:c}=(0,te.useMemo)(()=>a?gr(p,o,void 0,S):dr(p,S),[p,o,a,S]),[h,r,s]=Cn(u),[w,I,B]=kn(c),[X,P]=(0,te.useState)(null),L=(0,te.useMemo)(()=>{if(!a||!X)return null;let Y=p.nodes.find(q=>q.id===X);return Y?De(o,Y):null},[p.nodes,o,X,a]);(0,te.useEffect)(()=>{r(u),I(c)},[u,c,r,I]);let z=(0,te.useCallback)(()=>{r(Y=>Y.map(q=>({...q,data:{...q.data,runState:q.data.runState?{...q.data.runState,selected:!1}:void 0}})))},[r]);(0,te.useEffect)(()=>{a&&r(Y=>Y.map(q=>({...q,data:{...q.data,runState:q.data.runState?{...q.data.runState,selected:q.id===X}:void 0}})))},[X,r,a]);let k=(0,te.useCallback)((Y,q)=>{a?P(q.id):b?.(q.id)},[a,b]),j=(0,te.useCallback)(()=>{a&&(z(),P(null))},[a,z]),M=(0,te.useCallback)(()=>{z(),P(null)},[z]);return!p.nodes||p.nodes.length===0?a?(0,H.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:300},children:(0,H.jsx)(hn,{size:"large"})}):(0,H.jsx)(fn,{description:"No nodes in workflow"}):(0,H.jsx)(vn,{children:(0,H.jsx)(_n,{nodes:h,edges:w,nodeTypes:l,onNodesChange:s,onEdgesChange:B,onNodeClick:k,onPaneClick:a?j:void 0,height:O,fitView:!0,fitViewOptions:a?{padding:.3}:void 0,minZoom:a?.3:void 0,maxZoom:a?1.5:void 0,nodesDraggable:!1,nodesConnectable:a?!1:void 0,defaultEdgeOptions:a?void 0:{style:{strokeWidth:2}},backgroundGap:a?20:void 0,miniMap:a?{nodeStrokeWidth:3,pannable:!0,zoomable:!0,style:{backgroundColor:"#f5f5f5"}}:void 0,children:a&&L&&X&&(0,H.jsxs)("div",{style:{position:"absolute",right:24,top:24,width:460,maxHeight:"calc(100% - 48px)",background:"#fff",borderRadius:16,boxShadow:"0 8px 30px rgba(0,0,0,0.12)",border:"1px solid #e5e7eb",zIndex:10,overflow:"auto",padding:20},children:[(0,H.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[(0,H.jsx)(me,{type:"secondary",style:{fontSize:11,textTransform:"uppercase",letterSpacing:.5},children:"Step Detail"}),(0,H.jsx)(me,{type:"secondary",style:{fontSize:11,cursor:"pointer"},onClick:M,children:"Close"})]}),(0,H.jsx)(pr,{step:L})]})})})},Yr=hr;var mr=Object.create,Dn=Object.defineProperty,yr=Object.getOwnPropertyDescriptor,xr=Object.getOwnPropertyNames,Sr=Object.getPrototypeOf,br=Object.prototype.hasOwnProperty,K=(p,o)=>()=>(o||(p((o={exports:{}}).exports,o),p=null),o.exports),Ar=(p,o,d,S)=>{if(o&&typeof o=="object"||typeof o=="function")for(var b=xr(o),O=0,a=b.length,l;O<a;O++)l=b[O],!br.call(p,l)&&l!==d&&Dn(p,l,{get:(u=>o[u]).bind(null,l),enumerable:!(S=yr(o,l))||S.enumerable});return p},wr=(p,o,d)=>(d=p!=null?mr(Sr(p)):{},Ar(o||!p||!p.__esModule?Dn(d,"default",{value:p,enumerable:!0}):d,p)),Pe=K(((p,o)=>{function d(u){return typeof u>"u"||u===null}function S(u){return typeof u=="object"&&u!==null}function b(u){return Array.isArray(u)?u:d(u)?[]:[u]}function O(u,c){if(c){let h=Object.keys(c);for(let r=0,s=h.length;r<s;r+=1){let w=h[r];u[w]=c[w]}}return u}function a(u,c){let h="";for(let r=0;r<c;r+=1)h+=u;return h}function l(u){return u===0&&Number.NEGATIVE_INFINITY===1/u}o.exports.isNothing=d,o.exports.isObject=S,o.exports.toArray=b,o.exports.repeat=a,o.exports.isNegativeZero=l,o.exports.extend=O})),He=K(((p,o)=>{function d(b,O){let a="",l=b.reason||"(unknown reason)";return b.mark?(b.mark.name&&(a+='in "'+b.mark.name+'" '),a+="("+(b.mark.line+1)+":"+(b.mark.column+1)+")",!O&&b.mark.snippet&&(a+=`
1
+ import{b as cn,c as sn,d as _n}from"./embed-page-chunk-KEL6XU6R.js";import{a as ln,b as be,e as Ae,f as vn,h as Cn,i as kn}from"./embed-page-chunk-AC6X2XRH.js";import{Da as on,H as xn,R as Sn,U as bn,fa as An,la as wn,o as Re,oa as Tn,q as mn,t as yn,u as Oe,v as Me}from"./embed-page-chunk-QMVIL4BJ.js";import{a as Xe}from"./embed-page-chunk-MB65DZAX.js";import{Ia as se,La as Ke,Z as fn,aa as ve,ba as dn,fa as gn,va as hn}from"./embed-page-chunk-O4QK5LWZ.js";import{a as or}from"./embed-page-chunk-4BKXE5ON.js";import{e as Le}from"./embed-page-chunk-6Y3UYJ6Z.js";var te=Le(or());var _=Le(Xe());if(typeof document<"u"){let p="workflow-node-spin-keyframes";if(!document.getElementById(p)){let o=document.createElement("style");o.id=p,o.textContent="@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }",document.head.appendChild(o)}}var{Text:ue}=Ke,Ve={opacity:0},Fe={running:{color:"#1677ff",icon:(0,_.jsx)(bn,{size:14,style:{animation:"spin 1s linear infinite"}})},completed:{color:"#52c41a",icon:(0,_.jsx)(Re,{size:14})},failed:{color:"#ff4d4f",icon:(0,_.jsx)(Oe,{size:14})},interrupted:{color:"#faad14",icon:(0,_.jsx)(mn,{size:14})},skipped:{color:"#8c8c8c",icon:(0,_.jsx)(Me,{size:14})}},En={running:"This step is currently executing",completed:"This step completed successfully",failed:"This step encountered an error",interrupted:"This step is waiting for human input",skipped:"This step was skipped (condition not met)"},In={color:"#d9d9d9",icon:(0,_.jsx)(Me,{size:14})},Nn={agent:{color:"#6366f1",bg:"#EEF2FF",border:"#6366f1"},map:{color:"#10b981",bg:"#ECFDF5",border:"#10b981"},terminal:{color:"#64748b",bg:"#F8FAFC",border:"#94a3b8"}},Ln={success:{color:"#22c55e",bg:"#F0FDF4",label:"Success"},failed:{color:"#ef4444",bg:"#FEF2F2",label:"Failed"},__default:{color:"#94a3b8",bg:"#F8FAFC",label:"Stop"}};function lr(p){return(p||"?").split(/[\s_-]+/).filter(Boolean).map(o=>o[0]).join("").toUpperCase().slice(0,2)}function un({schema:p}){let o=p;if(!o||typeof o!="object")return(0,_.jsx)(ue,{type:"secondary",style:{fontSize:11},children:"No schema defined"});let d=o.properties,S=o.required||[],b=o.items,O=l=>l==="string"?"green":l==="number"||l==="integer"?"orange":l==="boolean"?"purple":l==="array"?"cyan":l==="object"?"blue":"default",a=l=>{let u=l.type;if(u==="array"&&l.items){let c=l.items.type;return c?`Array<${c}>`:"Array"}return u||"any"};return(0,_.jsxs)("div",{style:{maxWidth:340,maxHeight:360,overflow:"auto",fontSize:12},children:[d&&(0,_.jsxs)("div",{children:[(0,_.jsx)(ue,{type:"secondary",style:{fontSize:10,textTransform:"uppercase",letterSpacing:.5,display:"block",marginBottom:6},children:"Properties"}),Object.entries(d).map(([l,u])=>{let c=S.includes(l),h=u.description,r=a(u),s=u.properties,w=u.items,I=!!(s||w);return(0,_.jsx)(ve,{title:I?(0,_.jsx)(un,{schema:I?s?u:w:void 0}):h||void 0,placement:"left",overlayStyle:{maxWidth:360},children:(0,_.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"3px 6px",borderRadius:4,marginBottom:2,background:c?"rgba(99,102,241,0.04)":"transparent",cursor:I?"pointer":"default"},children:[(0,_.jsx)(ue,{style:{fontSize:11,fontWeight:c?600:400,fontFamily:"monospace"},children:l}),c&&(0,_.jsx)("span",{style:{color:"#ef4444",fontSize:9},children:"*"}),h&&!I&&(0,_.jsx)(ue,{type:"secondary",style:{fontSize:10,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h}),(0,_.jsx)(se,{color:O(r),style:{margin:0,fontSize:9,padding:"0 4px",lineHeight:"16px",marginLeft:"auto"},children:r})]})},l)})]}),!d&&b&&(0,_.jsxs)("div",{children:[(0,_.jsx)(ue,{type:"secondary",style:{fontSize:10,textTransform:"uppercase",letterSpacing:.5,display:"block",marginBottom:4},children:"Items"}),(0,_.jsx)(un,{schema:b})]})]})}var Rn=72,cr=3,sr=({data:p})=>{if(!p)return null;let{nodeType:o,name:d,description:S,ref:b,refAgentName:O,refAgentType:a,refDeleted:l,outputKey:u,nodeSchema:c,config:h,status:r,source:s,innerRef:w,inputTemplate:I,ask:B,condition:X,runState:P,pending:L}=p,z=Nn[o]||Nn.agent,k=Ln[r||""]||Ln.__default,j=P?Fe[P.status]||Fe.running:null,M=j?.color,Y=j?.icon,q=r==="success"?(0,_.jsx)(Re,{size:14,color:"#22c55e"}):r==="failed"?(0,_.jsx)(Oe,{size:14,color:"#ef4444"}):(0,_.jsx)(Me,{size:14,color:"#94a3b8"}),ne=r==="success"?(0,_.jsx)(Re,{size:32,color:k.color}):r==="failed"?(0,_.jsx)(Oe,{size:32,color:k.color}):(0,_.jsx)(yn,{size:32,color:k.color}),de=h?.title,ie=h?.maxRetries,oe=h?.timeout,J=h?.batchSize,le=h?.maxConcurrency,V=h?.innerConcurrency,G=P?.selected,U=!!P||L;function E($){return $==null?"-":$<1e3?`${$}ms`:`${($/1e3).toFixed(1)}s`}if(o==="terminal"){let $=k.color,Te=k.bg,ee=k.label,ae=ne;U&&(P?($=M||$,ee=P.status,ae=(0,_.jsx)("span",{style:{fontSize:18},children:Y})):L&&($=In.color,Te="#fafafa",ee="pending",ae=(0,_.jsx)(Me,{size:18,style:{color:In.color}})));let pe=G&&M?`0 4px 16px ${M}30`:"0 2px 8px rgba(0,0,0,0.06)";return(0,_.jsxs)("div",{style:{padding:4,display:"flex",flexDirection:"column",alignItems:"center",opacity:L?.5:1},children:[(0,_.jsx)(Ae,{type:"target",position:be.Top,style:Ve}),(0,_.jsx)(ve,{title:U&&P?En[P.status]:d,children:(0,_.jsx)("div",{style:{width:Rn,height:Rn,borderRadius:"50%",background:Te,border:`${cr}px solid ${L?`${$}80`:$}`,borderStyle:L?"dashed":"solid",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:pe,transition:"all 0.2s ease",cursor:"default"},onMouseEnter:L?void 0:fe=>{fe.currentTarget.style.transform="scale(1.08)",fe.currentTarget.style.boxShadow=`0 4px 16px ${$}30`},onMouseLeave:L?void 0:fe=>{fe.currentTarget.style.transform="scale(1)",fe.currentTarget.style.boxShadow=pe},children:ae})}),(0,_.jsx)(ue,{style:{fontSize:11,color:$,marginTop:6,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px"},children:ee}),(0,_.jsx)(Ae,{type:"source",position:be.Bottom,style:Ve})]})}let ge=U&&M?M:z.border,ce=U&&M?M:z.color,_e=o==="agent"?(0,_.jsx)(Tn,{size:14}):o==="map"?(0,_.jsx)(An,{size:14}):lr(d),he=P?E(P.durationMs):null,Ce=G&&M?`0 4px 14px ${M}20`:"0 1px 6px rgba(0,0,0,0.08)",we=U&&M?M:z.color;return(0,_.jsxs)("div",{style:{padding:4},children:[(0,_.jsx)(Ae,{type:"target",position:be.Top,style:Ve}),(0,_.jsxs)("div",{style:{width:260,minHeight:90,boxSizing:"border-box",background:"#fff",borderRadius:12,boxShadow:Ce,border:"1px solid #e5e7eb",borderLeft:`3px solid ${ge}`,borderStyle:b?"dashed":"solid",overflow:"hidden",transition:"all 0.2s ease",...L?{opacity:.5,borderStyle:"dashed"}:{}},onMouseEnter:L?void 0:$=>{$.currentTarget.style.transform="translateY(-2px)",$.currentTarget.style.boxShadow=`0 4px 12px ${we}20`},onMouseLeave:L?void 0:$=>{$.currentTarget.style.transform="translateY(0)",$.currentTarget.style.boxShadow=Ce},children:[(0,_.jsxs)("div",{style:{background:z.bg,padding:"6px 12px",display:"flex",alignItems:"center",gap:6,borderBottom:"1px solid #f1f5f9"},children:[(0,_.jsx)("div",{style:{width:24,height:24,borderRadius:"50%",backgroundColor:ce,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:600,flexShrink:0},children:_e}),(0,_.jsx)("div",{style:{flex:1,minWidth:0},children:(0,_.jsx)(ue,{strong:!0,style:{fontSize:12,color:z.color},ellipsis:{tooltip:d},children:d})}),U&&Y&&(0,_.jsx)(ve,{title:P?En[P.status]:void 0,children:(0,_.jsx)("span",{style:{color:M,fontSize:12,display:"flex",flexShrink:0},children:Y})})]}),(0,_.jsxs)("div",{style:{padding:"10px 12px"},children:[S&&(0,_.jsx)(ue,{type:"secondary",style:{fontSize:11,display:"block",marginTop:2,lineHeight:1.4},ellipsis:{tooltip:S},children:S}),o==="map"&&s&&(0,_.jsxs)(ue,{type:"secondary",style:{fontSize:11,display:"block",marginTop:4,lineHeight:1.4,color:z.color,background:z.bg,padding:"2px 6px",borderRadius:4,maxHeight:32,overflow:"hidden"},ellipsis:{tooltip:s},children:["\u2190 ",s]}),o!=="map"&&I&&(0,_.jsx)(ue,{type:"secondary",style:{fontSize:11,display:"block",marginTop:4,lineHeight:1.4,color:z.color,background:z.bg,padding:"2px 6px",borderRadius:4,maxHeight:32,overflow:"hidden"},ellipsis:{tooltip:I},children:I}),(0,_.jsxs)("div",{style:{display:"flex",gap:4,marginTop:6,flexWrap:"wrap"},children:[!U&&o==="agent"&&b&&(0,_.jsx)(ve,{title:l?`Agent "${b}" no longer exists`:`Delegated to agent: ${O??b}`,children:(0,_.jsx)(se,{color:l?"red":"purple",style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px"},icon:(0,_.jsx)(Sn,{size:10}),children:l?`[\u5DF2\u5220\u9664] ${b}`:`\u2192 ${O??b}`})}),!U&&o==="agent"&&!b&&(0,_.jsx)(se,{color:"default",style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px"},children:"inline"}),B&&(0,_.jsx)(ve,{title:"This step requires human approval before continuing",children:(0,_.jsx)("div",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,borderRadius:"50%",background:"#fff7e6",border:"1px solid #ffd591",cursor:"default"},children:(0,_.jsx)(wn,{size:12,style:{color:"#fa8c16"}})})}),X&&(0,_.jsx)(ve,{title:`When: ${X}`,children:(0,_.jsx)("div",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,borderRadius:"50%",background:"#f0f5ff",border:"1px solid #adc6ff",cursor:"default"},children:(0,_.jsx)(xn,{size:12,style:{color:"#2f54eb"}})})}),!U&&o==="map"&&w&&(0,_.jsx)(se,{color:"purple",style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px"},children:w}),!U&&o==="map"&&I&&(0,_.jsx)(se,{color:"default",style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px",maxWidth:120},title:I,children:I.length>20?I.slice(0,18)+"\u2026":I}),!U&&o==="map"&&(J||le||V)&&(0,_.jsxs)(se,{color:"cyan",style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px"},children:[J??50,"\xD7",le??10,"\xD7",V??5]}),!U&&ie?(0,_.jsxs)(se,{style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px"},children:["\u21BB ",ie]}):null,!U&&oe?(0,_.jsxs)(se,{style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px"},children:["\u23F1 ",oe,"s"]}):null,he&&(0,_.jsx)(se,{color:P?"blue":"default",style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px"},children:he}),u&&(0,_.jsx)("span",{style:{marginLeft:"auto"}}),u&&(0,_.jsx)(dn,{trigger:"hover",placement:"right",mouseEnterDelay:.2,title:(0,_.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,_.jsx)(ue,{strong:!0,style:{fontSize:12},children:"Output"}),(0,_.jsx)(ue,{style:{fontSize:11,fontFamily:"monospace",color:"#6366f1"},children:u})]}),content:c?(0,_.jsx)(un,{schema:c}):(0,_.jsx)(ue,{type:"secondary",style:{fontSize:11},children:"No schema defined"}),children:(0,_.jsxs)(se,{style:{margin:0,fontSize:10,padding:"0 5px",lineHeight:"16px",flexShrink:0,cursor:"default"},children:["\u2192 ",u]})})]})]})]}),(0,_.jsx)(Ae,{type:"source",position:be.Bottom,style:Ve})]})},On=sr;var H=Le(Xe()),{Text:me}=Ke;function Mn(p){return new Date(p).toLocaleString()}function ur(p){return p.input?typeof p.input.rendered=="string"?p.input.rendered:typeof p.input.description=="string"?p.input.description:JSON.stringify(p.input,null,2):null}function ar(p){return p.output?typeof p.output.result=="string"?p.output.result:typeof p.output=="object"?JSON.stringify(p.output,null,2):String(p.output):null}function pr({step:p}){let o=ur(p),d=ar(p),S=Fe[p.status]||Fe.running,b=[{key:"io",label:"Input / Output",children:(0,H.jsxs)(H.Fragment,{children:[o&&(0,H.jsxs)("div",{style:{marginBottom:d?12:0},children:[(0,H.jsx)(me,{type:"secondary",style:{fontSize:10,textTransform:"uppercase",letterSpacing:.5},children:"Input"}),(0,H.jsx)("div",{style:{background:"rgba(0,0,0,0.02)",borderRadius:8,padding:"8px 10px",marginTop:4,maxHeight:200,overflow:"auto"},children:p.input?.description?(0,H.jsx)(on,{content:o}):(0,H.jsx)("pre",{style:{margin:0,fontSize:11,whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"monospace"},children:o})})]}),d&&(0,H.jsxs)("div",{children:[(0,H.jsx)(me,{type:"secondary",style:{fontSize:10,textTransform:"uppercase",letterSpacing:.5},children:"Output"}),(0,H.jsx)("div",{style:{background:"linear-gradient(135deg, rgba(99,102,241,0.04) 0%, rgba(99,102,241,0.01) 100%)",borderRadius:8,padding:"8px 10px",marginTop:4,maxHeight:200,overflow:"auto"},children:p.output?.result?(0,H.jsx)(on,{content:d}):(0,H.jsx)("pre",{style:{margin:0,fontSize:11,whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"monospace"},children:d})})]}),!o&&!d&&(0,H.jsx)(me,{type:"secondary",style:{fontSize:11},children:"No input/output data"})]})}];return(0,H.jsxs)("div",{style:{maxWidth:480},children:[(0,H.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[(0,H.jsx)("span",{style:{color:S.color,fontSize:14},children:S.icon}),(0,H.jsx)(me,{strong:!0,style:{fontSize:14},children:p.stepName}),(0,H.jsx)(se,{color:"purple",style:{fontSize:11},children:p.stepType})]}),p.edgePurpose&&(0,H.jsx)("div",{style:{marginBottom:10},children:(0,H.jsxs)(me,{type:"secondary",style:{fontSize:11},children:["Purpose: ",p.edgePurpose]})}),p.errorMessage&&(0,H.jsx)("div",{style:{background:"#FEF2F2",border:"1px solid #FECACA",borderRadius:8,padding:"8px 12px",marginBottom:12,overflow:"hidden"},children:(0,H.jsx)(me,{type:"danger",style:{fontSize:11,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:p.errorMessage})}),(0,H.jsx)(gn,{activeKey:"io",items:b,size:"small",style:{marginBottom:-8}}),(0,H.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",marginTop:12,paddingTop:8,borderTop:"1px solid #f0f0f0"},children:[(0,H.jsxs)(me,{type:"secondary",style:{fontSize:10},children:["Started: ",Mn(p.startedAt)]}),p.completedAt&&(0,H.jsxs)(me,{type:"secondary",style:{fontSize:10},children:["Ended: ",Mn(p.completedAt)]})]})]})}function De(p,o){return p.find(d=>d.stepName===o.name)??null}function Qe(p,o,d,S){let b=p.ref&&S?S.get(p.ref):void 0;return{nodeType:p.type,name:p.name,description:p.description,ref:p.ref,refAgentName:b?.name,refAgentType:b?.type,refDeleted:p.ref&&S?!b:void 0,outputKey:p.output?.key,nodeSchema:p.output?.schema,config:p.config,status:p.status,source:p.source,innerRef:p.node?.ref,inputTemplate:p.input?.template,ask:p.ask,condition:p.condition,runState:o,pending:d}}function Fn(p){let o=new Map;for(let d of p)if(d.parentGroup&&d.type!=="terminal"){let S=o.get(d.parentGroup)||[];S.push(d.id),o.set(d.parentGroup,S)}return Array.from(o.entries()).map(([d,S])=>({sourceId:d,childIds:S}))}function fr(){return(0,H.jsxs)("div",{style:{width:"100%",height:"100%",position:"relative",pointerEvents:"none"},children:[(0,H.jsx)(Ae,{type:"target",position:be.Top,style:{opacity:0}}),(0,H.jsx)(Ae,{type:"source",position:be.Bottom,style:{opacity:0}}),(0,H.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,border:"2px dashed #a78bfa",borderRadius:12,background:"rgba(167, 139, 250, 0.04)"}}),(0,H.jsx)("div",{style:{position:"absolute",top:8,left:12,fontSize:12,fontWeight:600,color:"#7c3aed",padding:"2px 8px",background:"rgba(167, 139, 250, 0.08)",borderRadius:6,whiteSpace:"nowrap",zIndex:2},children:"Parallel"})]})}function dr(p,o){let d=p.nodes,S=p.edges,b=Fn(d),O=new Set(b.map(L=>L.sourceId)),a=new Set(b.flatMap(L=>L.childIds)),l=268,u=100,c=40;for(let L of b){let z=d.find(k=>k.id===L.sourceId);if(z){let k=L.childIds.length;z.width=k*l+(k-1)*c+40,z.height=u+100}}let h=d.filter(L=>!a.has(L.id)),r=sn(h,S,{nodeWidth:l,nodeHeight:u,ranksep:120}),s=h.find(L=>!O.has(L.id)&&L.type!=="terminal"),w=s?r.get(s.id):void 0,I=s?s.width??l:l,B=w?w.x+I/2:0;for(let L of h){if(O.has(L.id))continue;let z=r.get(L.id);if(!z)continue;let k=L.width??l;z.x=B-k/2}let X=h.filter(L=>r.has(L.id)&&!O.has(L.id)&&L.type!=="terminal").map(L=>{let z=r.get(L.id);return{id:L.id,type:"workflow",position:z,data:{...Qe(L,void 0,void 0,o)}}});for(let L of b){let z=d.find(J=>J.id===L.sourceId),k=r.get(L.sourceId);if(!z||!k)continue;let j=z.width,M=z.height,Y=L.childIds.length,q=B-j/2,ne=Y*l+(Y-1)*c,de=B-ne/2,ie=k.y+(M-u)/2;for(let J=0;J<Y;J++){let le=L.childIds[J],V=d.find(G=>G.id===le);V&&X.push({id:V.id,type:"workflow",position:{x:de+J*(l+c),y:ie},data:{...Qe(V,void 0,void 0,o),parallelGroup:!0},style:{zIndex:2}})}let oe=`group_${L.sourceId}`;X.push({id:oe,type:"groupLabel",position:{x:q,y:k.y},data:{},selectable:!1,draggable:!1,style:{zIndex:0,width:j,height:M}})}let P=[];for(let L of S){let z=cn(L);for(let k of z){let j=d.find(q=>q.id===k);if(j?.type==="terminal"&&j.name==="__end"||O.has(L.from)&&d.find(ne=>ne.id===k)?.parentGroup===L.from)continue;let M=O.has(L.from)?`group_${L.from}`:L.from,Y=O.has(k)?`group_${k}`:k;P.push({id:`${M}-${Y}`,source:M,target:Y,type:"straight",markerEnd:{type:ln.ArrowClosed}})}}return{nodes:X,edges:P}}function gr(p,o,d,S){let b=p.nodes,O=p.edges,a=Fn(b),l=new Set(a.map(k=>k.sourceId)),u=new Set(a.flatMap(k=>k.childIds)),c=268,h=100,r=40;for(let k of a){let j=b.find(M=>M.id===k.sourceId);if(j){let M=k.childIds.length;j.width=M*c+(M-1)*r+40,j.height=h+100}}let s=b.filter(k=>!u.has(k.id)),w=sn(s,O,{nodeWidth:c,nodeHeight:h,ranksep:120}),I=s.find(k=>!l.has(k.id)&&k.type!=="terminal"),B=I?w.get(I.id):void 0,X=I?I.width??c:c,P=B?B.x+X/2:0;for(let k of s){if(l.has(k.id))continue;let j=w.get(k.id);if(!j)continue;let M=k.width??c;j.x=P-M/2}let L=s.filter(k=>w.has(k.id)&&!l.has(k.id)).map(k=>{let j=w.get(k.id),M=De(o,k),Y=k.type==="terminal",q=M&&(!Y||M.status!=="running")?{status:M.status,stepType:M.stepType,durationMs:M.durationMs,selected:!1}:void 0;return{id:k.id,type:"workflow",position:j,style:Y?{width:c,height:h}:void 0,data:Qe(k,q,!M&&!Y,S)}});for(let k of a){let j=b.find(V=>V.id===k.sourceId),M=w.get(k.sourceId);if(!j||!M)continue;let Y=j.width,q=j.height,ne=k.childIds.length,de=ne*c+(ne-1)*r,ie=P-de/2,oe=M.y+(q-h)/2;for(let V=0;V<ne;V++){let G=k.childIds[V],U=b.find(ce=>ce.id===G);if(!U)continue;let E=De(o,U),ge=E?{status:E.status,stepType:E.stepType,durationMs:E.durationMs,selected:!1}:void 0;L.push({id:U.id,type:"workflow",position:{x:ie+V*(c+r),y:oe},data:{...Qe(U,ge,!E,S),parallelGroup:!0},style:{zIndex:2}})}let J=P-Y/2,le=`group_${k.sourceId}`;L.push({id:le,type:"groupLabel",position:{x:J,y:M.y},data:{},selectable:!1,draggable:!1,style:{zIndex:0,width:Y,height:q}})}let z=[];for(let k of O){let j=cn(k);for(let M of j){if(l.has(k.from)&&b.find(E=>E.id===M)?.parentGroup===k.from)continue;let Y=l.has(k.from)?`group_${k.from}`:k.from,q=l.has(M)?`group_${M}`:M,ne=b.find(U=>U.id===k.from),ie=(ne?De(o,ne):void 0)!==void 0,oe=b.find(U=>U.id===M),le=(oe?De(o,oe):void 0)!==void 0,V=ie&&le,G=V?"#6366f1":"#d9d9d9";z.push({id:`${Y}-${q}`,source:Y,target:q,type:"straight",animated:V,style:V?{stroke:G,strokeWidth:2}:{stroke:G,strokeWidth:2,strokeDasharray:"6 4",opacity:.25},markerEnd:{type:ln.ArrowClosed,color:G,width:20,height:20}})}}return{nodes:L,edges:z}}var hr=({dsl:p,steps:o,assistantId:d,agentNameMap:S,onNodeClick:b,height:O="100%"})=>{let a=!!o,l=(0,te.useMemo)(()=>({workflow:On,groupLabel:fr}),[]),{nodes:u,edges:c}=(0,te.useMemo)(()=>a?gr(p,o,void 0,S):dr(p,S),[p,o,a,S]),[h,r,s]=Cn(u),[w,I,B]=kn(c),[X,P]=(0,te.useState)(null),L=(0,te.useMemo)(()=>{if(!a||!X)return null;let Y=p.nodes.find(q=>q.id===X);return Y?De(o,Y):null},[p.nodes,o,X,a]);(0,te.useEffect)(()=>{r(u),I(c)},[u,c,r,I]);let z=(0,te.useCallback)(()=>{r(Y=>Y.map(q=>({...q,data:{...q.data,runState:q.data.runState?{...q.data.runState,selected:!1}:void 0}})))},[r]);(0,te.useEffect)(()=>{a&&r(Y=>Y.map(q=>({...q,data:{...q.data,runState:q.data.runState?{...q.data.runState,selected:q.id===X}:void 0}})))},[X,r,a]);let k=(0,te.useCallback)((Y,q)=>{a?P(q.id):b?.(q.id)},[a,b]),j=(0,te.useCallback)(()=>{a&&(z(),P(null))},[a,z]),M=(0,te.useCallback)(()=>{z(),P(null)},[z]);return!p.nodes||p.nodes.length===0?a?(0,H.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:300},children:(0,H.jsx)(hn,{size:"large"})}):(0,H.jsx)(fn,{description:"No nodes in workflow"}):(0,H.jsx)(vn,{children:(0,H.jsx)(_n,{nodes:h,edges:w,nodeTypes:l,onNodesChange:s,onEdgesChange:B,onNodeClick:k,onPaneClick:a?j:void 0,height:O,fitView:!0,fitViewOptions:a?{padding:.3}:void 0,minZoom:a?.3:void 0,maxZoom:a?1.5:void 0,nodesDraggable:!1,nodesConnectable:a?!1:void 0,defaultEdgeOptions:a?void 0:{style:{strokeWidth:2}},backgroundGap:a?20:void 0,miniMap:a?{nodeStrokeWidth:3,pannable:!0,zoomable:!0,style:{backgroundColor:"#f5f5f5"}}:void 0,children:a&&L&&X&&(0,H.jsxs)("div",{style:{position:"absolute",right:24,top:24,width:460,maxHeight:"calc(100% - 48px)",background:"#fff",borderRadius:16,boxShadow:"0 8px 30px rgba(0,0,0,0.12)",border:"1px solid #e5e7eb",zIndex:10,overflow:"auto",padding:20},children:[(0,H.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[(0,H.jsx)(me,{type:"secondary",style:{fontSize:11,textTransform:"uppercase",letterSpacing:.5},children:"Step Detail"}),(0,H.jsx)(me,{type:"secondary",style:{fontSize:11,cursor:"pointer"},onClick:M,children:"Close"})]}),(0,H.jsx)(pr,{step:L})]})})})},Yr=hr;var mr=Object.create,Dn=Object.defineProperty,yr=Object.getOwnPropertyDescriptor,xr=Object.getOwnPropertyNames,Sr=Object.getPrototypeOf,br=Object.prototype.hasOwnProperty,K=(p,o)=>()=>(o||(p((o={exports:{}}).exports,o),p=null),o.exports),Ar=(p,o,d,S)=>{if(o&&typeof o=="object"||typeof o=="function")for(var b=xr(o),O=0,a=b.length,l;O<a;O++)l=b[O],!br.call(p,l)&&l!==d&&Dn(p,l,{get:(u=>o[u]).bind(null,l),enumerable:!(S=yr(o,l))||S.enumerable});return p},wr=(p,o,d)=>(d=p!=null?mr(Sr(p)):{},Ar(o||!p||!p.__esModule?Dn(d,"default",{value:p,enumerable:!0}):d,p)),Pe=K(((p,o)=>{function d(u){return typeof u>"u"||u===null}function S(u){return typeof u=="object"&&u!==null}function b(u){return Array.isArray(u)?u:d(u)?[]:[u]}function O(u,c){if(c){let h=Object.keys(c);for(let r=0,s=h.length;r<s;r+=1){let w=h[r];u[w]=c[w]}}return u}function a(u,c){let h="";for(let r=0;r<c;r+=1)h+=u;return h}function l(u){return u===0&&Number.NEGATIVE_INFINITY===1/u}o.exports.isNothing=d,o.exports.isObject=S,o.exports.toArray=b,o.exports.repeat=a,o.exports.isNegativeZero=l,o.exports.extend=O})),He=K(((p,o)=>{function d(b,O){let a="",l=b.reason||"(unknown reason)";return b.mark?(b.mark.name&&(a+='in "'+b.mark.name+'" '),a+="("+(b.mark.line+1)+":"+(b.mark.column+1)+")",!O&&b.mark.snippet&&(a+=`
2
2
 
3
3
  `+b.mark.snippet),l+" "+a):l}function S(b,O){Error.call(this),this.name="YAMLException",this.reason=b,this.mark=O,this.message=d(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}S.prototype=Object.create(Error.prototype),S.prototype.constructor=S,S.prototype.toString=function(O){return this.name+": "+d(this,O)},o.exports=S})),Tr=K(((p,o)=>{var d=Pe();function S(a,l,u,c,h){let r="",s="",w=Math.floor(h/2)-1;return c-l>w&&(r=" ... ",l=c-w+r.length),u-c>w&&(s=" ...",u=c+w-s.length),{str:r+a.slice(l,u).replace(/\t/g,"\u2192")+s,pos:c-l+r.length}}function b(a,l){return d.repeat(" ",l-a.length)+a}function O(a,l){if(l=Object.create(l||null),!a.buffer)return null;l.maxLength||(l.maxLength=79),typeof l.indent!="number"&&(l.indent=1),typeof l.linesBefore!="number"&&(l.linesBefore=3),typeof l.linesAfter!="number"&&(l.linesAfter=2);let u=/\r?\n|\r|\0/g,c=[0],h=[],r,s=-1;for(;r=u.exec(a.buffer);)h.push(r.index),c.push(r.index+r[0].length),a.position<=r.index&&s<0&&(s=c.length-2);s<0&&(s=c.length-1);let w="",I=Math.min(a.line+l.linesAfter,h.length).toString().length,B=l.maxLength-(l.indent+I+3);for(let P=1;P<=l.linesBefore&&!(s-P<0);P++){let L=S(a.buffer,c[s-P],h[s-P],a.position-(c[s]-c[s-P]),B);w=d.repeat(" ",l.indent)+b((a.line-P+1).toString(),I)+" | "+L.str+`
4
4
  `+w}let X=S(a.buffer,c[s],h[s],a.position,B);w+=d.repeat(" ",l.indent)+b((a.line+1).toString(),I)+" | "+X.str+`
@@ -1,3 +1,3 @@
1
- import{Ra as S,Za as x,_a as P,za as I}from"./embed-page-chunk-XIXSRYJY.js";import{m as v}from"./embed-page-chunk-HEMNMC4X.js";import{a as s}from"./embed-page-chunk-MB65DZAX.js";import{La as y,U as f,W as h,mb as b}from"./embed-page-chunk-O4QK5LWZ.js";import{a as $}from"./embed-page-chunk-4BKXE5ON.js";import{e as a}from"./embed-page-chunk-6Y3UYJ6Z.js";var m=a($());var t=a(s()),{Text:l}=y,z=({workflowContext:e,onClose:d,onToolCompleted:p,initialMessageRequest:i,onInitialMessageSubmitted:g,attemptedInitialMessageRequestIdsRef:c,rawInitialMessage:r,showHeader:C=!0})=>{let T=v("agent-architect"),u=e?.id?`${T.tenantId}:${e.id}`:null,A=(0,m.useMemo)(()=>{if(e?.id&&e?.name)return e.type==="agent"?`[Context: You're viewing agent "${e.name}" (assistant: ${e.id})]`:`[Context: You're viewing workflow "${e.name}" (agent: ${e.id})]`},[e]),j=(0,m.useMemo)(()=>{if(!i||!e?.id)return null;if(r)return i;let o;return e.type==="workflow"?o=[`Purpose: ${i.content.trim()}`,"",`Workflow "${e.id}" has been created with an empty YAML DSL. Based on the purpose above, load the 'create-workflow' skill, design the workflow using the YAML needs+if DSL, and update it via update_workflow. Make sure to include a descriptive name.`].join(`
1
+ import{Na as S,Va as x,Wa as P,va as I}from"./embed-page-chunk-QMVIL4BJ.js";import{t as v}from"./embed-page-chunk-YPNSOZYW.js";import{a as s}from"./embed-page-chunk-MB65DZAX.js";import{La as y,U as f,W as h,mb as b}from"./embed-page-chunk-O4QK5LWZ.js";import{a as $}from"./embed-page-chunk-4BKXE5ON.js";import{e as a}from"./embed-page-chunk-6Y3UYJ6Z.js";var m=a($());var t=a(s()),{Text:l}=y,z=({workflowContext:e,onClose:d,onToolCompleted:p,initialMessageRequest:i,onInitialMessageSubmitted:g,attemptedInitialMessageRequestIdsRef:c,rawInitialMessage:r,showHeader:C=!0})=>{let T=v("agent-architect"),u=e?.id?`${T.tenantId}:${e.id}`:null,A=(0,m.useMemo)(()=>{if(e?.id&&e?.name)return e.type==="agent"?`[Context: You're viewing agent "${e.name}" (assistant: ${e.id})]`:`[Context: You're viewing workflow "${e.name}" (agent: ${e.id})]`},[e]),j=(0,m.useMemo)(()=>{if(!i||!e?.id)return null;if(r)return i;let o;return e.type==="workflow"?o=[`Purpose: ${i.content.trim()}`,"",`Workflow "${e.id}" has been created with an empty YAML DSL. Based on the purpose above, load the 'create-workflow' skill, design the workflow using the YAML needs+if DSL, and update it via update_workflow. Make sure to include a descriptive name.`].join(`
2
2
  `):o=[`Purpose: ${i.content.trim()}`,"",`Configure the topology for workflow "${e.id}" based on this purpose. Create sub-agents, set up the processing pipeline, and wire them together with topology edges.`,"The current name is a placeholder \u2014 feel free to update it via update_processing_agent if you have a better one."].join(`
3
3
  `),{...i,content:o}},[i?.requestId,i?.content,e?.id,e?.type,r]);return(0,t.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",borderLeft:"1px solid #f0f0f0",background:"rgba(255, 255, 255, 0.92)"},children:[C&&(0,t.jsxs)("div",{style:{padding:"12px 12px",borderBottom:"1px solid #f0f0f0",display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(l,{strong:!0,children:"Agent Builder"}),e&&(0,t.jsx)("div",{children:(0,t.jsxs)(l,{type:"secondary",style:{fontSize:12},children:["Viewing: ",e.name]})})]}),d&&(0,t.jsx)(h,{type:"text",size:"small","aria-label":"Close copilot",icon:(0,t.jsx)(b,{}),onClick:d})]}),u?(0,t.jsxs)(I,{threadId:u,assistantId:"agent-architect",options:{streaming:!0},onToolCompleted:p,children:[(0,t.jsx)(x,{request:j,onSubmitted:g,attemptedRequestIdsRef:c}),(0,t.jsx)(P,{showHeader:!1,showEmptyState:!1,showDatabaseSlot:!1,showSkillSlot:!1,showAgentSlot:!1,showMetricsDataSourceSlot:!1,systemContext:A})]}):(0,t.jsxs)("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",height:"100%",textAlign:"center",gap:4,padding:"0 8px"},children:[(0,t.jsx)(l,{strong:!0,children:"Agent Builder"}),(0,t.jsx)(l,{type:"secondary",children:"Select a workflow to start"})]})]})};var n=a(s()),_=({project:e,projects:d,value:p,onChange:i,selectable:g=!0,loading:c})=>e?(0,n.jsxs)("div",{"data-testid":"training-context-card",style:{display:"flex",alignItems:"center",gap:8},children:[(0,n.jsx)("span",{style:{fontSize:12,color:"rgba(0,0,0,0.45)",flexShrink:0},children:"Learning project"}),g?(0,n.jsx)(S,{kind:"training",value:p??e.id,onChange:r=>{r&&i?.(r)},style:{minWidth:0}}):(0,n.jsx)("span",{style:{fontSize:12,fontWeight:500},children:e.name})]}):c?null:(0,n.jsx)(f,{type:"warning",showIcon:!0,message:"No learning project is available",description:"A learning project is required before starting a learning task."});export{_ as a,z as b};
@@ -1,2 +1,2 @@
1
- import{Aa as Y,Ca as Z,Q as N,a as C,b as P,c as F,d as X,e as G,f as Q,ub as ee,v as V,vb as te,xa as J,ya as x}from"./embed-page-chunk-XIXSRYJY.js";import{f as $,l as z,p as K}from"./embed-page-chunk-HEMNMC4X.js";import{a as L}from"./embed-page-chunk-MB65DZAX.js";import{M as j,va as B}from"./embed-page-chunk-O4QK5LWZ.js";import{a as H}from"./embed-page-chunk-4BKXE5ON.js";import{e as I}from"./embed-page-chunk-6Y3UYJ6Z.js";var l=I(H());var g=class extends Error{code;retryable;status;constructor(n,t,r,o){super(t),this.name="AgentWebAppRuntimeClientError",this.code=n,this.retryable=r,this.status=o}};function R(){return new g("STREAM_FAILED","Stream failed",!0)}var ce=new Set(["WEB_APP_NOT_FOUND","WEB_APP_DISABLED","USER_ID_REQUIRED","INVALID_USER_ID","PROJECT_NOT_ALLOWED","PROJECT_SELECTOR_DISABLED","MODEL_NOT_ALLOWED","FEATURE_DISABLED","THREAD_NOT_FOUND","STREAM_CONFLICT","STREAM_FAILED","INVALID_REQUEST","INTERNAL_ERROR"]);function k(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function b(e,n){return Object.keys(e).length===n.length&&n.every(r=>r in e)}function ue(e){return k(e)&&b(e,["code","message","retryable"])&&typeof e.code=="string"&&ce.has(e.code)&&typeof e.message=="string"&&typeof e.retryable=="boolean"}function le(e){if(!k(e))return!1;let n=e.data===void 0?["id","type","prompt"]:["id","type","prompt","data"];return b(e,n)&&typeof e.id=="string"&&typeof e.type=="string"&&typeof e.prompt=="string"&&(e.data===void 0||k(e.data))}var fe=new Set([C.HUMAN,C.AI,C.TOOL,C.INTERRUPT,C.MESSAGE_COMPLETED,C.MESSAGE_FAILED,C.THREAD_IDLE]);function Ae(e,n){let t;try{t=JSON.parse(e)}catch{throw R()}if(!k(t)||typeof t.type!="string")throw R();if(fe.has(t.type)||t.type==="error"&&k(t.data)&&!k(t.error)){let r=X(t,n);return r.length===0?[]:r}switch(t.type){case"message.delta":if(b(t,["type","text"])&&typeof t.text=="string")return[t];break;case"message.completed":if(b(t,["type","messageId"])&&typeof t.messageId=="string")return[t];break;case"tool.started":if(b(t,["type","id","name"])&&typeof t.id=="string"&&typeof t.name=="string")return[t];break;case"tool.completed":if(b(t,["type","id"])&&typeof t.id=="string")return[t];break;case"interrupt.created":if(b(t,["type","interrupt"])&&le(t.interrupt))return[t];break;case"genui.render":if(b(t,["type","block"])&&P(t.block))return[t];break;case"error":if(b(t,["type","error"])&&ue(t.error))return[t];break;case"stream.completed":if(b(t,["type"]))return[t];break}throw R()}function me(e){return e instanceof Error&&e.name==="AbortError"}async function ne(e,n){let t=F({allowGenUI:!0,allowInterrupts:!0}),r=e.getReader(),o=new TextDecoder,s="",i=!1,a=!1;try{for(;!i;){let p;try{p=await r.read()}catch(A){if(me(A))return;throw R()}p.done&&(a=!0);try{s+=o.decode(p.value,{stream:!p.done})}catch{throw R()}let c=s.split(/\r?\n\r?\n/);s=p.done?"":c.pop()??"";for(let A of c){let y=A.split(/\r?\n/).filter(m=>m==="data"||m.startsWith("data:")).map(m=>m==="data"?"":m.slice(5).replace(/^ /,""));if(y.length!==0){for(let m of Ae(y.join(`
2
- `),t))if(await n(m),i=m.type==="stream.completed",i)break;if(i)break}}if(p.done)break}if(!i)throw R()}finally{if(!a)try{await r.cancel()}catch{}r.releaseLock()}}var ge=new Set(["WEB_APP_NOT_FOUND","WEB_APP_DISABLED","USER_ID_REQUIRED","INVALID_USER_ID","PROJECT_NOT_ALLOWED","PROJECT_SELECTOR_DISABLED","MODEL_NOT_ALLOWED","FEATURE_DISABLED","THREAD_NOT_FOUND","STREAM_CONFLICT","STREAM_FAILED","INVALID_REQUEST","INTERNAL_ERROR"]);function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function h(e,n,t=[]){let r=Object.keys(e);return n.every(o=>o in e)&&r.every(o=>n.includes(o)||t.includes(o))}function d(e){return typeof e=="string"}function M(e){if(!f(e)||!h(e,["id","projectId","createdAt","updatedAt"],["label"])||!d(e.id)||!d(e.projectId)||e.label!==void 0&&!d(e.label)||!d(e.createdAt)||!d(e.updatedAt))return;let n=new Date(e.createdAt),t=new Date(e.updatedAt);if(!(Number.isNaN(n.getTime())||Number.isNaN(t.getTime())))return{id:e.id,projectId:e.projectId,...e.label===void 0?{}:{label:e.label},createdAt:n,updatedAt:t}}function re(e){if(!f(e)||e.success!==!1||!f(e.error))return!1;let n=e.error;return h(e,["success","error"])&&h(n,["code","message","retryable"])&&typeof n.code=="string"&&ge.has(n.code)&&typeof n.message=="string"&&typeof n.retryable=="boolean"}function he(e){if(!f(e))return!1;let n=["projectSelector","modelSelector","threadManagement","attachments","hitl","genUI"];return h(e,n,["files"])&&n.every(t=>typeof e[t]=="boolean")&&(e.files===void 0||typeof e.files=="boolean")}function ye(e){return Array.isArray(e)&&e.length<=6&&e.every(n=>f(n)&&h(n,["label","text"])&&d(n.label)&&n.label.length>=1&&n.label.length<=40&&d(n.text)&&n.text.length>=1&&n.text.length<=500)}function be(e){return f(e)&&h(e,[],["title","welcomeMessage","primaryColor","quickPrompts"])&&(e.title===void 0||d(e.title))&&(e.welcomeMessage===void 0||d(e.welcomeMessage))&&(e.primaryColor===void 0||d(e.primaryColor))&&(e.quickPrompts===void 0||ye(e.quickPrompts))}function we(e){if(!f(e)||!h(e,["webApp","projects","models"],["thread"])||!f(e.webApp))return;let n=e.webApp;if(!h(n,["id","name","assistant","defaultProjectId","features","appearance","identityAssurance"],["description","defaultModelKey"])||!d(n.id)||!d(n.name)||!d(n.defaultProjectId)||n.description!==void 0&&!d(n.description)||n.defaultModelKey!==void 0&&!d(n.defaultModelKey)||n.identityAssurance!=="unverified"||!f(n.assistant)||!h(n.assistant,["id","name"],["description"])||!d(n.assistant.id)||!d(n.assistant.name)||n.assistant.description!==void 0&&!d(n.assistant.description)||!he(n.features)||!be(n.appearance)||!Array.isArray(e.projects)||!e.projects.every(r=>f(r)&&h(r,["id","name"])&&d(r.id)&&d(r.name))||!Array.isArray(e.models)||!e.models.every(r=>f(r)&&h(r,["key","label"])&&d(r.key)&&d(r.label)))return;let t=e.thread===void 0?void 0:M(e.thread);if(!(e.thread!==void 0&&!t))return{...e,...t?{thread:t}:{}}}function Ee(e){if(!f(e)||!h(e,["records","total"])||!Array.isArray(e.records)||typeof e.total!="number")return;let n=e.records.map(M);return n.every(t=>t!==void 0)?{records:n,total:e.total}:void 0}function Ce(e){return f(e)&&d(e.id)&&(e.role==="human"||e.role==="ai")&&(e.content===void 0||d(e.content)||Array.isArray(e.content)&&e.content.every(n=>P(n)!==void 0))}function Re(e){return f(e)&&h(e,["messages"])&&Array.isArray(e.messages)&&e.messages.every(Ce)?e:void 0}function Se(e){return f(e)&&h(e,["ref","name","mimeType","size"])&&d(e.ref)&&d(e.name)&&d(e.mimeType)&&typeof e.size=="number"?e:void 0}function oe(e,n){return t=>f(t)&&h(t,e)&&n(t)?t:void 0}var D=class{constructor(n){this.options=n;this.baseUrl=`${n.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(n.webAppId)}/runtime`,this.fetchImplementation=n.fetch??globalThis.fetch.bind(globalThis)}baseUrl;fetchImplementation;async bootstrap(n={},t){return this.request("bootstrap",we,{query:n,signal:t})}async listThreads(n={},t){return this.request("threads",Ee,{query:n,signal:t})}async createThread(n={},t){return this.request("threads",M,{method:"POST",body:n,signal:t})}async updateThread(n,t,r){return this.request(`threads/${encodeURIComponent(n)}`,M,{method:"PATCH",body:t,signal:r})}async deleteThread(n,t={},r){await this.request(`threads/${encodeURIComponent(n)}`,oe(["id"],o=>d(o.id)),{method:"DELETE",query:t,signal:r})}async getMessages(n,t={},r){return this.request(`threads/${encodeURIComponent(n)}/messages`,Re,{query:t,signal:r})}async streamMessage(n,t,r,o){return this.streamRequest(`threads/${encodeURIComponent(n)}/messages/stream`,t,r,o)}async resumeInterrupt(n,t,r,o,s){return this.streamRequest(`threads/${encodeURIComponent(n)}/interrupts/${encodeURIComponent(t)}/resume`,r,o,s)}async streamRequest(n,t,r,o){let s;try{s=await this.fetchRequest(n,{method:"POST",body:t,signal:o})}catch(i){throw se(i)||i instanceof g?i:new g("STREAM_FAILED","Stream failed",!0)}if(s.ok||await this.throwResponseError(s),!s.body||!s.headers.get("content-type")?.toLowerCase().includes("text/event-stream")){if(s.body)try{await s.body.cancel()}catch{}throw new g("STREAM_FAILED","Stream failed",!0,s.status)}await ne(s.body,r)}async abort(n,t={},r){await this.request(`threads/${encodeURIComponent(n)}/abort`,oe(["aborted"],o=>typeof o.aborted=="boolean"),{method:"POST",query:t,signal:r})}async uploadAttachment(n,t,r={},o){let s=new FormData,i=typeof File<"u"&&t instanceof File?t.name:"attachment";return s.append("file",t,i),this.request(`threads/${encodeURIComponent(n)}/attachments`,Se,{method:"POST",query:r,body:s,signal:o})}async request(n,t,r={}){let o;try{o=await this.fetchRequest(n,r)}catch(a){throw se(a)||a instanceof g?a:new g("INTERNAL_ERROR","Request failed",!0)}let s;try{s=await o.json()}catch{throw this.internalError(o.status)}if(re(s))throw new g(s.error.code,s.error.message,s.error.retryable,o.status);if(!o.ok||!f(s)||!h(s,["success","data"])||s.success!==!0)throw this.internalError(o.status);let i=t(s.data);if(i===void 0)throw this.internalError(o.status);return i}async fetchRequest(n,t){let r=await this.options.identityProvider.getIdentity(t.signal),o=new URL(`${this.baseUrl}/${n}`);for(let[a,p]of Object.entries(t.query??{}))p!==void 0&&o.searchParams.set(a,p);let s=new Headers;r.bearerToken!==void 0?s.set("Authorization",`Bearer ${r.bearerToken}`):s.set("X-Axiom-External-User-Id",r.externalUserId??"");let i;return t.body instanceof FormData?i=t.body:t.body!==void 0&&(s.set("Content-Type","application/json"),i=JSON.stringify(t.body)),this.fetchImplementation(o,{method:t.method??"GET",headers:s,body:i,signal:t.signal,credentials:"omit"})}async throwResponseError(n){let t;try{t=await n.json()}catch{throw this.internalError(n.status)}throw re(t)?new g(t.error.code,t.error.message,t.error.retryable,n.status):this.internalError(n.status)}internalError(n){return new g("INTERNAL_ERROR","Invalid server response",!1,n)}};function se(e){return typeof e=="object"&&e!==null&&"name"in e&&e.name==="AbortError"}var _=I(H());var W=I(L());function ie(){let{createThread:e}=x(),{menuCollapsed:n,setMenuCollapsed:t}=Y();(0,_.useEffect)(()=>{n===void 0&&t(!0)},[n,t]);let r=(0,_.useCallback)(async()=>{try{await e("New Thread")}catch(c){console.error("Failed to create new thread:",c)}},[e]),o=n??!0,p=[{id:"new-analysis",builtin:"new-analysis",type:"action",name:"New Thread",icon:(0,W.jsx)(V,{size:20}),order:0},...o?[{id:"thread-history-toggle",type:"action",name:"History",icon:(0,W.jsx)(N,{size:20}),order:1}]:[{id:"thread-history",builtin:"thread-history",type:"drawer",name:"History",icon:(0,W.jsx)(N,{size:20}),order:1,title:"Conversation History",width:320,inline:!0,inlineDefaultExpanded:!0,content:(0,W.jsx)(ee,{})}]];return(0,W.jsx)(Z,{items:p,showBranding:!1,showToggle:!0,showNewAnalysis:!1,defaultExpanded:!o,collapsed:o,onCollapsedChange:t,onNewAnalysis:r,onItemClick:c=>{c.type==="action"&&c.builtin==="new-analysis"?r():c.type==="action"&&c.id==="thread-history-toggle"&&t(!1)}},o?"agent-chat-sidebar-collapsed":"agent-chat-sidebar-expanded")}function ae(e){if(typeof window>"u"||typeof XMLHttpRequest>"u")return()=>{};let n=`${e.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(e.webAppId)}/runtime/`,t=XMLHttpRequest.prototype.open,r=XMLHttpRequest.prototype.send,o=new WeakMap;return XMLHttpRequest.prototype.open=function(i,a){o.set(this,String(a)),t.call(this,i,a,!0)},XMLHttpRequest.prototype.send=function(i){let a=o.get(this)??"";if(!a.startsWith(n)||!/\/sandbox\/uploadfile$/.test(a)){r.call(this,i);return}if(e.identity.mode==="unverified"){this.setRequestHeader("X-Axiom-External-User-Id",e.identity.userId),r.call(this,i);return}e.identity.tokenProvider().then(p=>{this.setRequestHeader("Authorization",`Bearer ${p}`),r.call(this,i)}).catch(()=>{r.call(this,i)})},()=>{XMLHttpRequest.prototype.open=t,XMLHttpRequest.prototype.send=r}}var Ie=/^#[0-9A-Fa-f]{6}$/;function ke(e){return typeof e=="string"&&Ie.test(e)}function de(e){return ke(e)?e:void 0}function U(e,n){let t=parseInt(e.replace("#",""),16),r=Math.round(2.55*n),o=(t>>16)+r,s=(t>>8&255)+r,i=(t&255)+r;return"#"+(16777216+(o<255?o<1?0:o:255)*65536+(s<255?s<1?0:s:255)*256+(i<255?i<1?0:i:255)).toString(16).slice(1)}function pe(e){if(e!==void 0)return{token:{colorPrimary:e,colorPrimaryHover:U(e,20),colorPrimaryActive:U(e,-15),colorPrimaryBg:U(e,45)+"20"}}}var u=I(L());function We(e,n){let t=O(e.welcome),r=O(n.title),o=t??O(n.welcomeMessage),s=e.quickPrompts??n.quickPrompts??[],i=de(n.primaryColor);return{...r!==void 0?{title:r}:{},...o!==void 0?{welcome:o}:{},quickPrompts:s,...i!==void 0?{primaryColor:i}:{}}}function O(e){return typeof e=="string"&&e.length>0?e:void 0}function Te(e){if(!e.gatewayUrl.trim())throw new Error("AgentChatApp requires gatewayUrl");try{new URL(e.gatewayUrl)}catch{throw new Error("AgentChatApp gatewayUrl must be a valid URL")}if(!e.webAppId.trim())throw new Error("AgentChatApp requires webAppId");if(e.identity.mode==="unverified"){if(!e.identity.userId.trim())throw new Error("AgentChatApp requires identity.userId")}else if(typeof e.identity.tokenProvider!="function")throw new Error("AgentChatApp requires identity.tokenProvider");if(!e.fetch&&typeof globalThis.fetch!="function")throw new Error("AgentChatApp requires a fetch implementation")}function Pe(e){return e instanceof g?e:new g("INTERNAL_ERROR","Request failed",!0)}function Le(e){return e.mode==="unverified"?`unverified:${e.userId}`:"verified:token"}function At(e){Te(e);let n=`${e.gatewayUrl}\0${e.webAppId}\0${Le(e.identity)}`;return(0,u.jsx)(xe,{...e},n)}function xe({gatewayUrl:e,webAppId:n,identity:t,onError:r,onChatReady:o,onChatMessage:s,fetch:i,className:a,welcome:p,quickPrompts:c}){let[A,y]=(0,l.useState)({status:"loading"}),m=(0,l.useRef)(t);m.current=t;let T=(0,l.useRef)(r);T.current=r;let S=(0,l.useRef)();return S.current||(S.current=new D({gatewayUrl:e,webAppId:n,identityProvider:{getIdentity:async()=>{let w=m.current;if(w.mode!=="verified")return{externalUserId:w.userId};try{return{bearerToken:await w.tokenProvider()}}catch{throw new g("USER_ID_REQUIRED","Identity token provider failed",!0)}}},...i?{fetch:i}:{}})),(0,l.useEffect)(()=>ae({gatewayUrl:e,webAppId:n,identity:t}),[e,n,t]),(0,l.useEffect)(()=>{let w=!1,E=S.current;return(async()=>{try{let q=await E.bootstrap({});if(w)return;y({status:"ready",bootstrap:q})}catch(q){if(w)return;let v=Pe(q);y({status:"error",error:v}),T.current?.(v)}})(),()=>{w=!0}},[]),A.status==="loading"?(0,u.jsx)("div",{className:a}):A.status==="error"?(0,u.jsxs)("div",{className:a,role:"alert",children:[(0,u.jsx)("strong",{children:"Unable to load the assistant"}),(0,u.jsx)("div",{children:A.error.code}),(0,u.jsx)("button",{type:"button",onClick:()=>y({status:"loading"}),children:"Retry"})]}):(0,u.jsx)(De,{className:a,gatewayUrl:e,webAppId:n,identity:t,bootstrap:A.bootstrap,onChatReady:o,onChatMessage:s,welcome:p,quickPrompts:c})}function Me(e){return{id:e.id,name:e.name,...e.description!==void 0?{description:e.description}:{},graphDefinition:void 0,createdAt:new Date(0),updatedAt:new Date(0)}}function De({gatewayUrl:e,webAppId:n,identity:t,bootstrap:r,onChatReady:o,onChatMessage:s,className:i,welcome:a,quickPrompts:p}){let c=(0,l.useMemo)(()=>Me(r.webApp.assistant),[r.webApp.assistant]),A=(0,l.useMemo)(()=>We({welcome:a,quickPrompts:p},r.webApp.appearance),[a,p,r.webApp.appearance]),y=(0,l.useMemo)(()=>pe(A.primaryColor),[A.primaryColor]),m=(0,l.useMemo)(()=>t.mode==="unverified"?{mode:"unverified",userId:t.userId}:{mode:"verified",tokenProvider:t.tokenProvider},[t]),T=(0,l.useCallback)(E=>new $({gatewayUrl:e,webAppId:n,identity:m,assistantId:E.assistantId,transport:E.transport,...E.timeout!==void 0?{timeout:E.timeout}:{},...E.headers!==void 0?{headers:E.headers}:{}}),[e,n,m]),S=(0,l.useMemo)(()=>({baseURL:`${e.replace(/\/$/,"")}/api/web-apps/${n}/runtime`,apiKey:"",transport:"sse",assistantId:c.id,enableSkillSlot:!1,enableDatabaseSlot:!1,enableAgentSlot:!1,enableMetricsDataSourceSlot:!1,enableModelSelector:!1,enableWorkspace:!1,enableCustomMenu:!1,showSideMenu:!1,enableAssistantCreation:!1,enableAssistantEditing:!1,enableThreadCreation:!0,enableThreadList:!0}),[c.id,e,n]),w=(0,l.useMemo)(()=>({assistants:[c],currentAssistant:c,isLoading:!1,error:null,listAssistants:async()=>{},getAssistant:async()=>c,createAssistant:async()=>{throw new Error("Not implemented in a Web App")},updateAssistant:async()=>{throw new Error("Not implemented in a Web App")},deleteAssistant:async()=>{},selectAssistant:async()=>{},clearCurrentAssistant:()=>{},refresh:async()=>{}}),[c]);return(0,u.jsx)(j,{theme:y,children:(0,u.jsx)(z,{config:{baseURL:S.baseURL,apiKey:"",assistantId:"__BASE__",transport:"sse"},createClient:T,children:(0,u.jsx)(K,{initialConfig:S,persistToLocalStorage:!1,children:(0,u.jsx)(G.Provider,{value:w,children:(0,u.jsx)(J,{children:(0,u.jsx)(_e,{className:i,onChatReady:o,onChatMessage:s,title:A.title,welcome:A.welcome,quickPrompts:A.quickPrompts})})})})})})}function _e({className:e,onChatReady:n,onChatMessage:t,title:r,welcome:o,quickPrompts:s=[]}){let{threadId:i}=x(),{currentAssistant:a}=Q();if(!a)return null;let p=i??"";if(!p)return(0,u.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,u.jsx)(B,{tip:"Creating conversation..."})});let c=r??o,A=r!==void 0&&o!==void 0?o:"";return(0,u.jsx)("div",{className:e,children:(0,u.jsx)(te,{thread_id:p,assistant_id:a.id,name:a.name,description:a.description,menu:(0,u.jsx)(ie,{}),showProjectSelector:!1,showSkillSlot:!1,showDatabaseSlot:!1,showAgentSlot:!1,showMetricsDataSourceSlot:!1,headerRight:null,emptyStateGreeting:c?(0,u.jsx)("span",{children:c}):void 0,emptyStateQuestion:A,senderPromptsItems:s.length>0?s.map((y,m)=>({key:`quick-${m}`,label:y.label,description:y.text})):void 0,showSkillPrompts:!1,showQuickAnalysis:!1,onChatReady:n,onChatMessage:t})})}export{Ie as a,At as b};
1
+ import{M as N,a as G,b as Q,qb as ee,r as V,rb as te,ta as J,ua as x,wa as Y,ya as Z}from"./embed-page-chunk-QMVIL4BJ.js";import{a as C,d as P,e as $,f as F,m as X,s as z,w as K}from"./embed-page-chunk-YPNSOZYW.js";import{a as L}from"./embed-page-chunk-MB65DZAX.js";import{M as j,va as B}from"./embed-page-chunk-O4QK5LWZ.js";import{a as H}from"./embed-page-chunk-4BKXE5ON.js";import{e as I}from"./embed-page-chunk-6Y3UYJ6Z.js";var l=I(H());var g=class extends Error{code;retryable;status;constructor(n,t,r,o){super(t),this.name="AgentWebAppRuntimeClientError",this.code=n,this.retryable=r,this.status=o}};function R(){return new g("STREAM_FAILED","Stream failed",!0)}var ce=new Set(["WEB_APP_NOT_FOUND","WEB_APP_DISABLED","USER_ID_REQUIRED","INVALID_USER_ID","PROJECT_NOT_ALLOWED","PROJECT_SELECTOR_DISABLED","MODEL_NOT_ALLOWED","FEATURE_DISABLED","THREAD_NOT_FOUND","STREAM_CONFLICT","STREAM_FAILED","INVALID_REQUEST","INTERNAL_ERROR"]);function k(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function b(e,n){return Object.keys(e).length===n.length&&n.every(r=>r in e)}function ue(e){return k(e)&&b(e,["code","message","retryable"])&&typeof e.code=="string"&&ce.has(e.code)&&typeof e.message=="string"&&typeof e.retryable=="boolean"}function le(e){if(!k(e))return!1;let n=e.data===void 0?["id","type","prompt"]:["id","type","prompt","data"];return b(e,n)&&typeof e.id=="string"&&typeof e.type=="string"&&typeof e.prompt=="string"&&(e.data===void 0||k(e.data))}var fe=new Set([C.HUMAN,C.AI,C.TOOL,C.INTERRUPT,C.MESSAGE_COMPLETED,C.MESSAGE_FAILED,C.THREAD_IDLE]);function Ae(e,n){let t;try{t=JSON.parse(e)}catch{throw R()}if(!k(t)||typeof t.type!="string")throw R();if(fe.has(t.type)||t.type==="error"&&k(t.data)&&!k(t.error)){let r=F(t,n);return r.length===0?[]:r}switch(t.type){case"message.delta":if(b(t,["type","text"])&&typeof t.text=="string")return[t];break;case"message.completed":if(b(t,["type","messageId"])&&typeof t.messageId=="string")return[t];break;case"tool.started":if(b(t,["type","id","name"])&&typeof t.id=="string"&&typeof t.name=="string")return[t];break;case"tool.completed":if(b(t,["type","id"])&&typeof t.id=="string")return[t];break;case"interrupt.created":if(b(t,["type","interrupt"])&&le(t.interrupt))return[t];break;case"genui.render":if(b(t,["type","block"])&&P(t.block))return[t];break;case"error":if(b(t,["type","error"])&&ue(t.error))return[t];break;case"stream.completed":if(b(t,["type"]))return[t];break}throw R()}function me(e){return e instanceof Error&&e.name==="AbortError"}async function ne(e,n){let t=$({allowGenUI:!0,allowInterrupts:!0}),r=e.getReader(),o=new TextDecoder,s="",i=!1,a=!1;try{for(;!i;){let p;try{p=await r.read()}catch(A){if(me(A))return;throw R()}p.done&&(a=!0);try{s+=o.decode(p.value,{stream:!p.done})}catch{throw R()}let c=s.split(/\r?\n\r?\n/);s=p.done?"":c.pop()??"";for(let A of c){let y=A.split(/\r?\n/).filter(m=>m==="data"||m.startsWith("data:")).map(m=>m==="data"?"":m.slice(5).replace(/^ /,""));if(y.length!==0){for(let m of Ae(y.join(`
2
+ `),t))if(await n(m),i=m.type==="stream.completed",i)break;if(i)break}}if(p.done)break}if(!i)throw R()}finally{if(!a)try{await r.cancel()}catch{}r.releaseLock()}}var ge=new Set(["WEB_APP_NOT_FOUND","WEB_APP_DISABLED","USER_ID_REQUIRED","INVALID_USER_ID","PROJECT_NOT_ALLOWED","PROJECT_SELECTOR_DISABLED","MODEL_NOT_ALLOWED","FEATURE_DISABLED","THREAD_NOT_FOUND","STREAM_CONFLICT","STREAM_FAILED","INVALID_REQUEST","INTERNAL_ERROR"]);function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function h(e,n,t=[]){let r=Object.keys(e);return n.every(o=>o in e)&&r.every(o=>n.includes(o)||t.includes(o))}function d(e){return typeof e=="string"}function M(e){if(!f(e)||!h(e,["id","projectId","createdAt","updatedAt"],["label"])||!d(e.id)||!d(e.projectId)||e.label!==void 0&&!d(e.label)||!d(e.createdAt)||!d(e.updatedAt))return;let n=new Date(e.createdAt),t=new Date(e.updatedAt);if(!(Number.isNaN(n.getTime())||Number.isNaN(t.getTime())))return{id:e.id,projectId:e.projectId,...e.label===void 0?{}:{label:e.label},createdAt:n,updatedAt:t}}function re(e){if(!f(e)||e.success!==!1||!f(e.error))return!1;let n=e.error;return h(e,["success","error"])&&h(n,["code","message","retryable"])&&typeof n.code=="string"&&ge.has(n.code)&&typeof n.message=="string"&&typeof n.retryable=="boolean"}function he(e){if(!f(e))return!1;let n=["projectSelector","modelSelector","threadManagement","attachments","hitl","genUI"];return h(e,n,["files"])&&n.every(t=>typeof e[t]=="boolean")&&(e.files===void 0||typeof e.files=="boolean")}function ye(e){return Array.isArray(e)&&e.length<=6&&e.every(n=>f(n)&&h(n,["label","text"])&&d(n.label)&&n.label.length>=1&&n.label.length<=40&&d(n.text)&&n.text.length>=1&&n.text.length<=500)}function be(e){return f(e)&&h(e,[],["title","welcomeMessage","primaryColor","quickPrompts"])&&(e.title===void 0||d(e.title))&&(e.welcomeMessage===void 0||d(e.welcomeMessage))&&(e.primaryColor===void 0||d(e.primaryColor))&&(e.quickPrompts===void 0||ye(e.quickPrompts))}function we(e){if(!f(e)||!h(e,["webApp","projects","models"],["thread"])||!f(e.webApp))return;let n=e.webApp;if(!h(n,["id","name","assistant","defaultProjectId","features","appearance","identityAssurance"],["description","defaultModelKey"])||!d(n.id)||!d(n.name)||!d(n.defaultProjectId)||n.description!==void 0&&!d(n.description)||n.defaultModelKey!==void 0&&!d(n.defaultModelKey)||n.identityAssurance!=="unverified"||!f(n.assistant)||!h(n.assistant,["id","name"],["description"])||!d(n.assistant.id)||!d(n.assistant.name)||n.assistant.description!==void 0&&!d(n.assistant.description)||!he(n.features)||!be(n.appearance)||!Array.isArray(e.projects)||!e.projects.every(r=>f(r)&&h(r,["id","name"])&&d(r.id)&&d(r.name))||!Array.isArray(e.models)||!e.models.every(r=>f(r)&&h(r,["key","label"])&&d(r.key)&&d(r.label)))return;let t=e.thread===void 0?void 0:M(e.thread);if(!(e.thread!==void 0&&!t))return{...e,...t?{thread:t}:{}}}function Ee(e){if(!f(e)||!h(e,["records","total"])||!Array.isArray(e.records)||typeof e.total!="number")return;let n=e.records.map(M);return n.every(t=>t!==void 0)?{records:n,total:e.total}:void 0}function Ce(e){return f(e)&&d(e.id)&&(e.role==="human"||e.role==="ai")&&(e.content===void 0||d(e.content)||Array.isArray(e.content)&&e.content.every(n=>P(n)!==void 0))}function Re(e){return f(e)&&h(e,["messages"])&&Array.isArray(e.messages)&&e.messages.every(Ce)?e:void 0}function Se(e){return f(e)&&h(e,["ref","name","mimeType","size"])&&d(e.ref)&&d(e.name)&&d(e.mimeType)&&typeof e.size=="number"?e:void 0}function oe(e,n){return t=>f(t)&&h(t,e)&&n(t)?t:void 0}var D=class{constructor(n){this.options=n;this.baseUrl=`${n.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(n.webAppId)}/runtime`,this.fetchImplementation=n.fetch??globalThis.fetch.bind(globalThis)}baseUrl;fetchImplementation;async bootstrap(n={},t){return this.request("bootstrap",we,{query:n,signal:t})}async listThreads(n={},t){return this.request("threads",Ee,{query:n,signal:t})}async createThread(n={},t){return this.request("threads",M,{method:"POST",body:n,signal:t})}async updateThread(n,t,r){return this.request(`threads/${encodeURIComponent(n)}`,M,{method:"PATCH",body:t,signal:r})}async deleteThread(n,t={},r){await this.request(`threads/${encodeURIComponent(n)}`,oe(["id"],o=>d(o.id)),{method:"DELETE",query:t,signal:r})}async getMessages(n,t={},r){return this.request(`threads/${encodeURIComponent(n)}/messages`,Re,{query:t,signal:r})}async streamMessage(n,t,r,o){return this.streamRequest(`threads/${encodeURIComponent(n)}/messages/stream`,t,r,o)}async resumeInterrupt(n,t,r,o,s){return this.streamRequest(`threads/${encodeURIComponent(n)}/interrupts/${encodeURIComponent(t)}/resume`,r,o,s)}async streamRequest(n,t,r,o){let s;try{s=await this.fetchRequest(n,{method:"POST",body:t,signal:o})}catch(i){throw se(i)||i instanceof g?i:new g("STREAM_FAILED","Stream failed",!0)}if(s.ok||await this.throwResponseError(s),!s.body||!s.headers.get("content-type")?.toLowerCase().includes("text/event-stream")){if(s.body)try{await s.body.cancel()}catch{}throw new g("STREAM_FAILED","Stream failed",!0,s.status)}await ne(s.body,r)}async abort(n,t={},r){await this.request(`threads/${encodeURIComponent(n)}/abort`,oe(["aborted"],o=>typeof o.aborted=="boolean"),{method:"POST",query:t,signal:r})}async uploadAttachment(n,t,r={},o){let s=new FormData,i=typeof File<"u"&&t instanceof File?t.name:"attachment";return s.append("file",t,i),this.request(`threads/${encodeURIComponent(n)}/attachments`,Se,{method:"POST",query:r,body:s,signal:o})}async request(n,t,r={}){let o;try{o=await this.fetchRequest(n,r)}catch(a){throw se(a)||a instanceof g?a:new g("INTERNAL_ERROR","Request failed",!0)}let s;try{s=await o.json()}catch{throw this.internalError(o.status)}if(re(s))throw new g(s.error.code,s.error.message,s.error.retryable,o.status);if(!o.ok||!f(s)||!h(s,["success","data"])||s.success!==!0)throw this.internalError(o.status);let i=t(s.data);if(i===void 0)throw this.internalError(o.status);return i}async fetchRequest(n,t){let r=await this.options.identityProvider.getIdentity(t.signal),o=new URL(`${this.baseUrl}/${n}`);for(let[a,p]of Object.entries(t.query??{}))p!==void 0&&o.searchParams.set(a,p);let s=new Headers;r.bearerToken!==void 0?s.set("Authorization",`Bearer ${r.bearerToken}`):s.set("X-Axiom-External-User-Id",r.externalUserId??"");let i;return t.body instanceof FormData?i=t.body:t.body!==void 0&&(s.set("Content-Type","application/json"),i=JSON.stringify(t.body)),this.fetchImplementation(o,{method:t.method??"GET",headers:s,body:i,signal:t.signal,credentials:"omit"})}async throwResponseError(n){let t;try{t=await n.json()}catch{throw this.internalError(n.status)}throw re(t)?new g(t.error.code,t.error.message,t.error.retryable,n.status):this.internalError(n.status)}internalError(n){return new g("INTERNAL_ERROR","Invalid server response",!1,n)}};function se(e){return typeof e=="object"&&e!==null&&"name"in e&&e.name==="AbortError"}var _=I(H());var W=I(L());function ie(){let{createThread:e}=x(),{menuCollapsed:n,setMenuCollapsed:t}=Y();(0,_.useEffect)(()=>{n===void 0&&t(!0)},[n,t]);let r=(0,_.useCallback)(async()=>{try{await e("New Thread")}catch(c){console.error("Failed to create new thread:",c)}},[e]),o=n??!0,p=[{id:"new-analysis",builtin:"new-analysis",type:"action",name:"New Thread",icon:(0,W.jsx)(V,{size:20}),order:0},...o?[{id:"thread-history-toggle",type:"action",name:"History",icon:(0,W.jsx)(N,{size:20}),order:1}]:[{id:"thread-history",builtin:"thread-history",type:"drawer",name:"History",icon:(0,W.jsx)(N,{size:20}),order:1,title:"Conversation History",width:320,inline:!0,inlineDefaultExpanded:!0,content:(0,W.jsx)(ee,{})}]];return(0,W.jsx)(Z,{items:p,showBranding:!1,showToggle:!0,showNewAnalysis:!1,defaultExpanded:!o,collapsed:o,onCollapsedChange:t,onNewAnalysis:r,onItemClick:c=>{c.type==="action"&&c.builtin==="new-analysis"?r():c.type==="action"&&c.id==="thread-history-toggle"&&t(!1)}},o?"agent-chat-sidebar-collapsed":"agent-chat-sidebar-expanded")}function ae(e){if(typeof window>"u"||typeof XMLHttpRequest>"u")return()=>{};let n=`${e.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(e.webAppId)}/runtime/`,t=XMLHttpRequest.prototype.open,r=XMLHttpRequest.prototype.send,o=new WeakMap;return XMLHttpRequest.prototype.open=function(i,a){o.set(this,String(a)),t.call(this,i,a,!0)},XMLHttpRequest.prototype.send=function(i){let a=o.get(this)??"";if(!a.startsWith(n)||!/\/sandbox\/uploadfile$/.test(a)){r.call(this,i);return}if(e.identity.mode==="unverified"){this.setRequestHeader("X-Axiom-External-User-Id",e.identity.userId),r.call(this,i);return}e.identity.tokenProvider().then(p=>{this.setRequestHeader("Authorization",`Bearer ${p}`),r.call(this,i)}).catch(()=>{r.call(this,i)})},()=>{XMLHttpRequest.prototype.open=t,XMLHttpRequest.prototype.send=r}}var Ie=/^#[0-9A-Fa-f]{6}$/;function ke(e){return typeof e=="string"&&Ie.test(e)}function de(e){return ke(e)?e:void 0}function U(e,n){let t=parseInt(e.replace("#",""),16),r=Math.round(2.55*n),o=(t>>16)+r,s=(t>>8&255)+r,i=(t&255)+r;return"#"+(16777216+(o<255?o<1?0:o:255)*65536+(s<255?s<1?0:s:255)*256+(i<255?i<1?0:i:255)).toString(16).slice(1)}function pe(e){if(e!==void 0)return{token:{colorPrimary:e,colorPrimaryHover:U(e,20),colorPrimaryActive:U(e,-15),colorPrimaryBg:U(e,45)+"20"}}}var u=I(L());function We(e,n){let t=O(e.welcome),r=O(n.title),o=t??O(n.welcomeMessage),s=e.quickPrompts??n.quickPrompts??[],i=de(n.primaryColor);return{...r!==void 0?{title:r}:{},...o!==void 0?{welcome:o}:{},quickPrompts:s,...i!==void 0?{primaryColor:i}:{}}}function O(e){return typeof e=="string"&&e.length>0?e:void 0}function Te(e){if(!e.gatewayUrl.trim())throw new Error("AgentChatApp requires gatewayUrl");try{new URL(e.gatewayUrl)}catch{throw new Error("AgentChatApp gatewayUrl must be a valid URL")}if(!e.webAppId.trim())throw new Error("AgentChatApp requires webAppId");if(e.identity.mode==="unverified"){if(!e.identity.userId.trim())throw new Error("AgentChatApp requires identity.userId")}else if(typeof e.identity.tokenProvider!="function")throw new Error("AgentChatApp requires identity.tokenProvider");if(!e.fetch&&typeof globalThis.fetch!="function")throw new Error("AgentChatApp requires a fetch implementation")}function Pe(e){return e instanceof g?e:new g("INTERNAL_ERROR","Request failed",!0)}function Le(e){return e.mode==="unverified"?`unverified:${e.userId}`:"verified:token"}function At(e){Te(e);let n=`${e.gatewayUrl}\0${e.webAppId}\0${Le(e.identity)}`;return(0,u.jsx)(xe,{...e},n)}function xe({gatewayUrl:e,webAppId:n,identity:t,onError:r,onChatReady:o,onChatMessage:s,fetch:i,className:a,welcome:p,quickPrompts:c}){let[A,y]=(0,l.useState)({status:"loading"}),m=(0,l.useRef)(t);m.current=t;let T=(0,l.useRef)(r);T.current=r;let S=(0,l.useRef)();return S.current||(S.current=new D({gatewayUrl:e,webAppId:n,identityProvider:{getIdentity:async()=>{let w=m.current;if(w.mode!=="verified")return{externalUserId:w.userId};try{return{bearerToken:await w.tokenProvider()}}catch{throw new g("USER_ID_REQUIRED","Identity token provider failed",!0)}}},...i?{fetch:i}:{}})),(0,l.useEffect)(()=>ae({gatewayUrl:e,webAppId:n,identity:t}),[e,n,t]),(0,l.useEffect)(()=>{let w=!1,E=S.current;return(async()=>{try{let q=await E.bootstrap({});if(w)return;y({status:"ready",bootstrap:q})}catch(q){if(w)return;let v=Pe(q);y({status:"error",error:v}),T.current?.(v)}})(),()=>{w=!0}},[]),A.status==="loading"?(0,u.jsx)("div",{className:a}):A.status==="error"?(0,u.jsxs)("div",{className:a,role:"alert",children:[(0,u.jsx)("strong",{children:"Unable to load the assistant"}),(0,u.jsx)("div",{children:A.error.code}),(0,u.jsx)("button",{type:"button",onClick:()=>y({status:"loading"}),children:"Retry"})]}):(0,u.jsx)(De,{className:a,gatewayUrl:e,webAppId:n,identity:t,bootstrap:A.bootstrap,onChatReady:o,onChatMessage:s,welcome:p,quickPrompts:c})}function Me(e){return{id:e.id,name:e.name,...e.description!==void 0?{description:e.description}:{},graphDefinition:void 0,createdAt:new Date(0),updatedAt:new Date(0)}}function De({gatewayUrl:e,webAppId:n,identity:t,bootstrap:r,onChatReady:o,onChatMessage:s,className:i,welcome:a,quickPrompts:p}){let c=(0,l.useMemo)(()=>Me(r.webApp.assistant),[r.webApp.assistant]),A=(0,l.useMemo)(()=>We({welcome:a,quickPrompts:p},r.webApp.appearance),[a,p,r.webApp.appearance]),y=(0,l.useMemo)(()=>pe(A.primaryColor),[A.primaryColor]),m=(0,l.useMemo)(()=>t.mode==="unverified"?{mode:"unverified",userId:t.userId}:{mode:"verified",tokenProvider:t.tokenProvider},[t]),T=(0,l.useCallback)(E=>new X({gatewayUrl:e,webAppId:n,identity:m,assistantId:E.assistantId,transport:E.transport,...E.timeout!==void 0?{timeout:E.timeout}:{},...E.headers!==void 0?{headers:E.headers}:{}}),[e,n,m]),S=(0,l.useMemo)(()=>({baseURL:`${e.replace(/\/$/,"")}/api/web-apps/${n}/runtime`,apiKey:"",transport:"sse",assistantId:c.id,enableSkillSlot:!1,enableDatabaseSlot:!1,enableAgentSlot:!1,enableMetricsDataSourceSlot:!1,enableModelSelector:!1,enableWorkspace:!1,enableCustomMenu:!1,showSideMenu:!1,enableAssistantCreation:!1,enableAssistantEditing:!1,enableThreadCreation:!0,enableThreadList:!0}),[c.id,e,n]),w=(0,l.useMemo)(()=>({assistants:[c],currentAssistant:c,isLoading:!1,error:null,listAssistants:async()=>{},getAssistant:async()=>c,createAssistant:async()=>{throw new Error("Not implemented in a Web App")},updateAssistant:async()=>{throw new Error("Not implemented in a Web App")},deleteAssistant:async()=>{},selectAssistant:async()=>{},clearCurrentAssistant:()=>{},refresh:async()=>{}}),[c]);return(0,u.jsx)(j,{theme:y,children:(0,u.jsx)(z,{config:{baseURL:S.baseURL,apiKey:"",assistantId:"__BASE__",transport:"sse"},createClient:T,children:(0,u.jsx)(K,{initialConfig:S,persistToLocalStorage:!1,children:(0,u.jsx)(G.Provider,{value:w,children:(0,u.jsx)(J,{children:(0,u.jsx)(_e,{className:i,onChatReady:o,onChatMessage:s,title:A.title,welcome:A.welcome,quickPrompts:A.quickPrompts})})})})})})}function _e({className:e,onChatReady:n,onChatMessage:t,title:r,welcome:o,quickPrompts:s=[]}){let{threadId:i}=x(),{currentAssistant:a}=Q();if(!a)return null;let p=i??"";if(!p)return(0,u.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,u.jsx)(B,{tip:"Creating conversation..."})});let c=r??o,A=r!==void 0&&o!==void 0?o:"";return(0,u.jsx)("div",{className:e,children:(0,u.jsx)(te,{thread_id:p,assistant_id:a.id,name:a.name,description:a.description,menu:(0,u.jsx)(ie,{}),showProjectSelector:!1,showSkillSlot:!1,showDatabaseSlot:!1,showAgentSlot:!1,showMetricsDataSourceSlot:!1,headerRight:null,emptyStateGreeting:c?(0,u.jsx)("span",{children:c}):void 0,emptyStateQuestion:A,senderPromptsItems:s.length>0?s.map((y,m)=>({key:`quick-${m}`,label:y.label,description:y.text})):void 0,showSkillPrompts:!1,showQuickAnalysis:!1,onChatReady:n,onChatMessage:t})})}export{Ie as a,At as b};