@axiom-lattice/react-sdk 8.3.0 → 8.3.1

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 (53) hide show
  1. package/dist/{AgentDetailSideApp-YQS5GL7P.mjs → AgentDetailSideApp-SJOQVIJA.mjs} +7 -7
  2. package/dist/{AgentGovernanceWorkbench-KYHOZTRY.mjs → AgentGovernanceWorkbench-JN4JOAI3.mjs} +8 -8
  3. package/dist/{MessageGraph-WUWP2CE3.mjs → MessageGraph-NO5GCAAS.mjs} +4 -4
  4. package/dist/MessageGraph-NO5GCAAS.mjs.map +1 -0
  5. package/dist/{ReactChart-7WQQAQ73.mjs → ReactChart-E5LP5OCH.mjs} +2 -2
  6. package/dist/{TasksSideApp-IPFBRDSJ.mjs → TasksSideApp-OEGSZUES.mjs} +4 -4
  7. package/dist/{TopologyRuntimeView-WFMC2GME.mjs → TopologyRuntimeView-XT67VRZE.mjs} +4 -4
  8. package/dist/{WorkflowAutomationView-CZIAN5D7.mjs → WorkflowAutomationView-KBY5LCTI.mjs} +6 -6
  9. package/dist/{chunk-7FWCKQNB.mjs → chunk-3YVWKHQ2.mjs} +11 -7
  10. package/dist/{chunk-7FWCKQNB.mjs.map → chunk-3YVWKHQ2.mjs.map} +1 -1
  11. package/dist/{chunk-VSNPATWP.mjs → chunk-6TXR2BBE.mjs} +2 -2
  12. package/dist/{chunk-26OKWQ4A.mjs → chunk-DB5N7NLG.mjs} +4 -4
  13. package/dist/{chunk-32DXGO5I.mjs → chunk-GRJM72F2.mjs} +4 -4
  14. package/dist/{chunk-5RHFR3E7.mjs → chunk-R2FZW4U2.mjs} +36 -29
  15. package/dist/chunk-R2FZW4U2.mjs.map +1 -0
  16. package/dist/{chunk-WQ4VG47Y.mjs → chunk-VDJVKL3E.mjs} +3 -3
  17. package/dist/{chunk-QGHDHTJT.mjs → chunk-XYW2CARX.mjs} +2 -2
  18. package/dist/{chunk-A5M2ER2U.mjs → chunk-YUYCIJXJ.mjs} +1899 -1890
  19. package/dist/chunk-YUYCIJXJ.mjs.map +1 -0
  20. package/dist/{embed-page-AgentDetailSideApp-WDDE7BEH.js → embed-page-AgentDetailSideApp-7YTMN643.js} +1 -1
  21. package/dist/{embed-page-AgentGovernanceWorkbench-7YPU3QB2.js → embed-page-AgentGovernanceWorkbench-YWJ4ZLEV.js} +1 -1
  22. package/dist/embed-page-MessageGraph-N2DXVMEK.js +6 -0
  23. package/dist/{embed-page-ReactChart-D7RZQB2H.js → embed-page-ReactChart-3QDZX2WG.js} +1 -1
  24. package/dist/{embed-page-TasksSideApp-KD4S22SL.js → embed-page-TasksSideApp-MYIRJWFM.js} +1 -1
  25. package/dist/{embed-page-TopologyRuntimeView-Z7MY6U5T.js → embed-page-TopologyRuntimeView-3O6VJUZR.js} +1 -1
  26. package/dist/{embed-page-WorkflowAutomationView-4MY4HG7R.js → embed-page-WorkflowAutomationView-YHOS4WQR.js} +1 -1
  27. package/dist/{embed-page-chunk-GSUSX54K.js → embed-page-chunk-FE6KYRCO.js} +1 -1
  28. package/dist/{embed-page-chunk-CFFDP526.js → embed-page-chunk-IBRMWDHE.js} +184 -184
  29. package/dist/{embed-page-chunk-EM6VGUZ2.js → embed-page-chunk-IELKCYQX.js} +1 -1
  30. package/dist/{embed-page-chunk-BZKAPY7M.js → embed-page-chunk-JTL73EBV.js} +1 -1
  31. package/dist/{embed-page-chunk-G5MXFDNZ.js → embed-page-chunk-PROZXFWS.js} +1 -1
  32. package/dist/{embed-page-chunk-HZZ5HNTF.js → embed-page-chunk-WGEXK773.js} +2 -2
  33. package/dist/{embed-page-chunk-G5PDHDBZ.js → embed-page-chunk-YMVKQQXJ.js} +1 -1
  34. package/dist/embed-page.js +3 -3
  35. package/dist/index.js +833 -805
  36. package/dist/index.js.map +1 -1
  37. package/dist/index.mjs +8 -8
  38. package/package.json +1 -1
  39. package/dist/MessageGraph-WUWP2CE3.mjs.map +0 -1
  40. package/dist/chunk-5RHFR3E7.mjs.map +0 -1
  41. package/dist/chunk-A5M2ER2U.mjs.map +0 -1
  42. package/dist/embed-page-MessageGraph-LNNMCH6I.js +0 -6
  43. /package/dist/{AgentDetailSideApp-YQS5GL7P.mjs.map → AgentDetailSideApp-SJOQVIJA.mjs.map} +0 -0
  44. /package/dist/{AgentGovernanceWorkbench-KYHOZTRY.mjs.map → AgentGovernanceWorkbench-JN4JOAI3.mjs.map} +0 -0
  45. /package/dist/{ReactChart-7WQQAQ73.mjs.map → ReactChart-E5LP5OCH.mjs.map} +0 -0
  46. /package/dist/{TasksSideApp-IPFBRDSJ.mjs.map → TasksSideApp-OEGSZUES.mjs.map} +0 -0
  47. /package/dist/{TopologyRuntimeView-WFMC2GME.mjs.map → TopologyRuntimeView-XT67VRZE.mjs.map} +0 -0
  48. /package/dist/{WorkflowAutomationView-CZIAN5D7.mjs.map → WorkflowAutomationView-KBY5LCTI.mjs.map} +0 -0
  49. /package/dist/{chunk-VSNPATWP.mjs.map → chunk-6TXR2BBE.mjs.map} +0 -0
  50. /package/dist/{chunk-26OKWQ4A.mjs.map → chunk-DB5N7NLG.mjs.map} +0 -0
  51. /package/dist/{chunk-32DXGO5I.mjs.map → chunk-GRJM72F2.mjs.map} +0 -0
  52. /package/dist/{chunk-WQ4VG47Y.mjs.map → chunk-VDJVKL3E.mjs.map} +0 -0
  53. /package/dist/{chunk-QGHDHTJT.mjs.map → chunk-XYW2CARX.mjs.map} +0 -0
@@ -1 +1 @@
1
- import{k as L}from"./embed-page-chunk-G5PDHDBZ.js";import"./embed-page-chunk-BZKAPY7M.js";import"./embed-page-chunk-G5MXFDNZ.js";import"./embed-page-chunk-EM6VGUZ2.js";import"./embed-page-chunk-GSUSX54K.js";import"./embed-page-chunk-DJKD2PHO.js";import"./embed-page-chunk-D7YTSCUO.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-HZZ5HNTF.js";import{T as E,h as P}from"./embed-page-chunk-CFFDP526.js";import"./embed-page-chunk-4XKCMM5C.js";import{a as F}from"./embed-page-chunk-PMOGSY6W.js";import"./embed-page-chunk-BSRASK7V.js";import"./embed-page-chunk-F7ZUYG42.js";import{k as T}from"./embed-page-chunk-ASEIOK7X.js";import{a as C}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-34RWKVD7.js";import"./embed-page-chunk-B2KNZ3EW.js";import{Ja as I,La as c,W as p,_ as m,za as b}from"./embed-page-chunk-F7TA3LRH.js";import{a as N}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as u}from"./embed-page-chunk-QBTAJ2YI.js";var n=u(N());var t=u(C()),O={component_key:"workspace_assistants",data:{}},$=d=>{let i=d;if(typeof d=="string")try{i=JSON.parse(d)}catch{return{}}return i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{}},W=({data:d})=>{let{assistantId:i,initialTab:R}=d??{},{get:f,put:y,del:A}=F(),e=T(),v=P(),[g,w]=(0,n.useState)(null),[B,h]=(0,n.useState)([]),[_,S]=(0,n.useState)(!1),[j,k]=(0,n.useState)(null),l=(0,n.useCallback)(()=>{v({...O,message:e("governance.detail.listCardMessage")})},[v,e]),o=(0,n.useCallback)(async()=>{S(!0),k(null);try{let s=(await f("/api/assistants")).data?.records??[];h(s),w(s.find(r=>r.id===i)??null)}catch{k(e("governance.detail.loadFailed"))}finally{S(!1)}},[f,i,e]);(0,n.useEffect)(()=>{i&&o()},[o,i]);let x=(0,n.useCallback)(async(a,s)=>{let r=$(a.graphDefinition),D;try{D=await y(`/api/assistants/${a.id}`,{name:s.name!==void 0?s.name:a.name,description:s.description!==void 0?s.description:a.description,graphDefinition:{...r,...s}})}catch(G){throw c.error(e("governance.detail.saveFailed")),G}if(!D.success)throw c.error(e("governance.detail.saveFailed")),new Error("Failed to save agent");c.success(e("common.saved")),await o()},[y,o,e]),z=(0,n.useCallback)(a=>{w(s=>s&&s.id===a.id?a:s),h(s=>s.map(r=>r.id===a.id?a:r))},[]),U=(0,n.useCallback)(async a=>{if(!(await A(`/api/assistants/${a}`)).success)throw new Error("Failed to delete agent");c.success(e("governance.detail.deleted")),l()},[A,l,e]);return i?g?(0,t.jsx)("div",{style:{height:"100%",overflow:"auto"},children:(0,t.jsx)(E,{children:(0,t.jsx)(L,{assistant:g,allAssistants:B,onBack:l,onDeleted:U,onSave:x,onAssistantUpdated:z,onAgentListInvalidated:()=>void o(),initialTab:R})},g.id)}):_?(0,t.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,t.jsx)(I,{})}):j?(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(p,{type:"error",showIcon:!0,message:e("governance.detail.loadFailed"),"data-testid":"detail-error",action:(0,t.jsxs)(b,{children:[(0,t.jsx)(m,{size:"small",onClick:()=>void o(),children:e("common.retry")}),(0,t.jsx)(m,{size:"small",type:"primary",onClick:l,children:e("governance.detail.backToList")})]})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(p,{type:"warning",showIcon:!0,message:e("governance.detail.notFound"),"data-testid":"detail-not-found",action:(0,t.jsx)(m,{size:"small",type:"primary",onClick:l,children:e("governance.detail.backToList")})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(p,{type:"warning",showIcon:!0,message:e("governance.detail.missingId"),"data-testid":"detail-missing-id"})})};export{W as AgentDetailSideApp};
1
+ import{k as L}from"./embed-page-chunk-YMVKQQXJ.js";import"./embed-page-chunk-JTL73EBV.js";import"./embed-page-chunk-PROZXFWS.js";import"./embed-page-chunk-IELKCYQX.js";import"./embed-page-chunk-FE6KYRCO.js";import"./embed-page-chunk-DJKD2PHO.js";import"./embed-page-chunk-D7YTSCUO.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-WGEXK773.js";import{T as E,h as P}from"./embed-page-chunk-IBRMWDHE.js";import"./embed-page-chunk-4XKCMM5C.js";import{a as F}from"./embed-page-chunk-PMOGSY6W.js";import"./embed-page-chunk-BSRASK7V.js";import"./embed-page-chunk-F7ZUYG42.js";import{k as T}from"./embed-page-chunk-ASEIOK7X.js";import{a as C}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-34RWKVD7.js";import"./embed-page-chunk-B2KNZ3EW.js";import{Ja as I,La as c,W as p,_ as m,za as b}from"./embed-page-chunk-F7TA3LRH.js";import{a as N}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as u}from"./embed-page-chunk-QBTAJ2YI.js";var n=u(N());var t=u(C()),O={component_key:"workspace_assistants",data:{}},$=d=>{let i=d;if(typeof d=="string")try{i=JSON.parse(d)}catch{return{}}return i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{}},W=({data:d})=>{let{assistantId:i,initialTab:R}=d??{},{get:f,put:y,del:A}=F(),e=T(),v=P(),[g,w]=(0,n.useState)(null),[B,h]=(0,n.useState)([]),[_,S]=(0,n.useState)(!1),[j,k]=(0,n.useState)(null),l=(0,n.useCallback)(()=>{v({...O,message:e("governance.detail.listCardMessage")})},[v,e]),o=(0,n.useCallback)(async()=>{S(!0),k(null);try{let s=(await f("/api/assistants")).data?.records??[];h(s),w(s.find(r=>r.id===i)??null)}catch{k(e("governance.detail.loadFailed"))}finally{S(!1)}},[f,i,e]);(0,n.useEffect)(()=>{i&&o()},[o,i]);let x=(0,n.useCallback)(async(a,s)=>{let r=$(a.graphDefinition),D;try{D=await y(`/api/assistants/${a.id}`,{name:s.name!==void 0?s.name:a.name,description:s.description!==void 0?s.description:a.description,graphDefinition:{...r,...s}})}catch(G){throw c.error(e("governance.detail.saveFailed")),G}if(!D.success)throw c.error(e("governance.detail.saveFailed")),new Error("Failed to save agent");c.success(e("common.saved")),await o()},[y,o,e]),z=(0,n.useCallback)(a=>{w(s=>s&&s.id===a.id?a:s),h(s=>s.map(r=>r.id===a.id?a:r))},[]),U=(0,n.useCallback)(async a=>{if(!(await A(`/api/assistants/${a}`)).success)throw new Error("Failed to delete agent");c.success(e("governance.detail.deleted")),l()},[A,l,e]);return i?g?(0,t.jsx)("div",{style:{height:"100%",overflow:"auto"},children:(0,t.jsx)(E,{children:(0,t.jsx)(L,{assistant:g,allAssistants:B,onBack:l,onDeleted:U,onSave:x,onAssistantUpdated:z,onAgentListInvalidated:()=>void o(),initialTab:R})},g.id)}):_?(0,t.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,t.jsx)(I,{})}):j?(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(p,{type:"error",showIcon:!0,message:e("governance.detail.loadFailed"),"data-testid":"detail-error",action:(0,t.jsxs)(b,{children:[(0,t.jsx)(m,{size:"small",onClick:()=>void o(),children:e("common.retry")}),(0,t.jsx)(m,{size:"small",type:"primary",onClick:l,children:e("governance.detail.backToList")})]})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(p,{type:"warning",showIcon:!0,message:e("governance.detail.notFound"),"data-testid":"detail-not-found",action:(0,t.jsx)(m,{size:"small",type:"primary",onClick:l,children:e("governance.detail.backToList")})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(p,{type:"warning",showIcon:!0,message:e("governance.detail.missingId"),"data-testid":"detail-missing-id"})})};export{W as AgentDetailSideApp};
@@ -1 +1 @@
1
- import{a as Ie,b as Re,c as vt,d as xt,e as wt,f as Tt,g as It,h as St,i as Ft,j as Pt,k as Rt}from"./embed-page-chunk-G5PDHDBZ.js";import{a as _e}from"./embed-page-chunk-BZKAPY7M.js";import"./embed-page-chunk-G5MXFDNZ.js";import"./embed-page-chunk-EM6VGUZ2.js";import"./embed-page-chunk-GSUSX54K.js";import{b as Oe,e as Ve,f as ft,g as yt,h as ht,i as Ct,l as At,m as bt}from"./embed-page-chunk-DJKD2PHO.js";import"./embed-page-chunk-D7YTSCUO.js";import{a as ct,b as dt,c as gt,d as pt,e as mt}from"./embed-page-chunk-SV2BM3WO.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-HZZ5HNTF.js";import{T as kt,e as lt,h as ut,r as Ne}from"./embed-page-chunk-CFFDP526.js";import{i as rt}from"./embed-page-chunk-4XKCMM5C.js";import{a as me}from"./embed-page-chunk-PMOGSY6W.js";import{o as Ze}from"./embed-page-chunk-BSRASK7V.js";import{C as et,La as st,Q as tt,U as nt,ba as at,n as Te,oa as ot,ua as it}from"./embed-page-chunk-F7ZUYG42.js";import{k as z}from"./embed-page-chunk-ASEIOK7X.js";import{a as E}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-34RWKVD7.js";import{Ja as Xe,Q as Je,g as Ye,na as Pe,za as Qe}from"./embed-page-chunk-B2KNZ3EW.js";import{Da as R,Ia as V,Ka as Le,La as w,Ma as pe,Sa as $e,Za as we,_ as W,_a as We,bb as X,fa as xe,ha as je,na as Fe,ua as Be,va as Ue,xa as qe,za as He}from"./embed-page-chunk-F7TA3LRH.js";import{a as ge}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as I}from"./embed-page-chunk-QBTAJ2YI.js";var h=I(ge());var te=I(ge());var Z=I(ge());var Dt=I(ge());var se=I(E()),Mt=60,Et=72,Ge=(0,Dt.memo)(({data:i})=>{let l=Ie(i.type),f=Math.min(12+Math.sqrt(i.subAgentCount)*10,48);return(0,se.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[(0,se.jsx)(Ve,{type:"target",position:Oe.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:0,height:0},isConnectable:!1}),(0,se.jsx)("div",{title:i.label,style:{width:f,height:f,borderRadius:"50%",background:Re(l.color),display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:Math.max(10,f*.4),fontWeight:600,cursor:"pointer",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},children:i.label.charAt(0).toUpperCase()}),(0,se.jsx)("div",{style:{fontSize:11,maxWidth:120,textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:4},children:i.label}),(0,se.jsx)(Ve,{type:"source",position:Oe.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:0,height:0},isConnectable:!1})]})});Ge.displayName="AgentGraphNode";var ee=I(E()),en=({assistants:i,onNodeClick:l})=>{let[f,c,u]=ht([]),[o,e,C]=Ct([]),[r,m]=(0,Z.useState)(null),S=(0,Z.useMemo)(()=>({agent:Ge}),[]),M=(0,Z.useMemo)(()=>wt(i),[i]);(0,Z.useEffect)(()=>{let v=M.nodes.map(g=>({id:g.id})),P=M.edges.map(g=>({source:g.source,target:g.target})),D=new Map(M.nodes.map(g=>[g.id,g])),$=pt(v).force("link",gt(P).id(g=>g.id).distance(80)).force("charge",mt().strength(-220)).force("center",ct(0,0)).force("collide",dt(45)).stop();for(let g=0;g<300;g++)$.tick();let j=v.map(g=>({id:g.id,type:"agent",data:D.get(g.id),position:{x:g.x-Mt/2,y:g.y-Et/2}})),a=M.edges.map(g=>({id:`e${g.source}-${g.target}`,source:g.source,target:g.target,style:{stroke:"#1677ff",strokeWidth:2},type:"straight"}));c(j),e(a)},[M,c,e]);let H=(0,Z.useMemo)(()=>r===null?f:f.map(v=>{let P=v.id===r||o.some(D=>D.source===r&&D.target===v.id||D.target===r&&D.source===v.id);return{...v,style:{opacity:P?1:.2,transition:"opacity 0.2s ease"}}}),[f,o,r]),d=(0,Z.useMemo)(()=>r===null?o.map(v=>({...v,style:{stroke:"#1677ff",strokeWidth:1.5,opacity:.25,transition:"opacity 0.2s ease"}})):o.map(v=>{let P=v.source===r||v.target===r;return{...v,style:{stroke:"#1677ff",strokeWidth:P?2.5:1,opacity:P?1:.04,transition:"opacity 0.2s ease"}}}),[o,r]);return(0,ee.jsx)("div",{style:{width:"100%",height:"100%",background:"#fafafa",position:"relative"},children:(0,ee.jsxs)(yt,{nodes:H,edges:d,onNodesChange:u,onEdgesChange:C,onNodeMouseEnter:(v,P)=>m(P.id),onNodeMouseLeave:()=>m(null),onNodeClick:(v,P)=>l?.(String(P.id)),nodeTypes:S,fitView:!0,fitViewOptions:{padding:.25},children:[(0,ee.jsx)(At,{color:"#eee",gap:20}),(0,ee.jsx)(bt,{})]})})},Kt=i=>(0,ee.jsx)(ft,{children:(0,ee.jsx)(en,{...i})});var T=I(E()),tn=[{key:"all",labelKey:"governance.list.tab.all"},{key:"capability",labelKey:"governance.list.tab.capability"},{key:"orchestrator",labelKey:"governance.list.tab.orchestrator"},{key:"workflow",labelKey:"governance.list.tab.workflow"}],Bt=({items:i,assistants:l=[],loading:f,onItemClick:c,onOpenPlayground:u,onOpenEval:o,onCreate:e,onDelete:C})=>{let r=z(),[m,S]=(0,te.useState)("all"),[M,H]=(0,te.useState)(null),[d,v]=(0,te.useState)(null),P=(0,te.useMemo)(()=>{let a=new Set;return i.forEach(g=>g.tags.forEach(U=>a.add(U))),Array.from(a).map(g=>({value:g,label:g}))},[i]),D=(0,te.useMemo)(()=>i.filter(a=>!(m!=="all"&&a.type!==m||M&&!a.tags.includes(M)||d&&a.status!==d)),[i,m,M,d]),$=[{key:"edit",icon:it,label:r("common.edit"),onClick:a=>c(a.id)},{key:"playground",icon:et,label:r("governance.list.action.playground"),onClick:a=>u(a.id)},{key:"eval",icon:nt,label:r("governance.list.action.eval"),onClick:a=>o(a.id)}];C&&$.push({key:"delete",icon:st,label:r("common.delete"),danger:!0,onClick:a=>C(a.id)});let j=(0,te.useMemo)(()=>[{mode:"graph",icon:ot,label:r("governance.list.viewMode.graph"),render:()=>(0,T.jsx)(Kt,{assistants:l,onNodeClick:c})}],[l,c,r]);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("span",{"data-testid":"agent-list-state","data-loading":String(f),"data-count":D.length,hidden:!0,"aria-hidden":"true"}),(0,T.jsx)(lt,{title:r("governance.list.title"),itemName:"common.item.agent",items:D,loading:f,keyExtractor:a=>a.id,tabs:tn.map(a=>({key:a.key,label:r(a.labelKey)})),activeTab:m,onTabChange:a=>S(a),headerLeft:(0,T.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[(0,T.jsx)(Ne,{value:M,onChange:H,options:P,placeholder:r("governance.list.filter.domain"),allLabel:r("governance.list.filter.allDomains")}),(0,T.jsx)(Ne,{value:d,onChange:v,options:[{value:"enabled",label:r("governance.list.status.enabled")},{value:"draft",label:r("governance.list.status.draft")},{value:"disabled",label:r("governance.list.status.disabled")}],placeholder:r("governance.list.filter.status"),allLabel:r("governance.list.filter.allStatuses")})]}),renderIcon:a=>{let g=Re(Ie(a.type).color);return(0,T.jsx)("div",{title:r("governance.list.typeIconTitle",{type:a.type}),style:{width:32,height:32,borderRadius:8,background:`${g}1A`,color:g,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,T.jsx)(Te,{size:18})})},renderPrimary:a=>(0,T.jsx)("span",{"data-testid":"agent-name","data-agent-id":a.id,children:a.name}),renderSecondary:a=>a.description||void 0,renderDetails:a=>(0,T.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,T.jsxs)("div",{style:{display:"flex",gap:4,flexWrap:"wrap",alignItems:"center"},children:[a.tags.map(g=>(0,T.jsx)(we,{color:"magenta",style:{margin:0,borderRadius:10,border:"none"},children:g},g)),(0,T.jsx)(we,{color:Ie(a.type).color,style:{margin:0,borderRadius:10,border:"none"},children:a.type})]}),(0,T.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[(0,T.jsx)(je,{title:r("governance.list.statusTooltip",{status:a.status}),children:(0,T.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:vt(a.status),display:"inline-block",cursor:"help"}})}),(0,T.jsx)("span",{style:{fontSize:12,color:"#8c8c8c"},children:a.version})]})]}),itemActions:$,actionsStyle:"icon",actionsPosition:"hover",onItemClick:a=>c(a.id),createLabel:r("governance.list.create"),onCreateClick:e,viewModeExtensions:j,emptyIcon:(0,T.jsx)(Te,{size:48,style:{opacity:.5}}),emptyTitle:r("governance.list.emptyTitle"),emptyDescription:r("governance.list.emptyDescription")})]})};var A=I(ge());var re=I(ge());var ue=I(E()),{Text:nn}=X,Lt=({onSelect:i,value:l,placeholder:f})=>{let c=z(),u=f??c("chatConfig.parentAgent.selectPlaceholder"),[o,e]=(0,re.useState)([]),[C,r]=(0,re.useState)(!1),{get:m}=me(),S=(0,re.useCallback)(async()=>{r(!0);try{let d=await m("/api/assistants");d.success&&e(d.data?.records||[])}catch(d){console.error("Failed to fetch assistants:",d)}finally{r(!1)}},[m]);return(0,re.useEffect)(()=>{S()},[S]),(0,ue.jsx)(xe,{showSearch:!0,allowClear:!0,value:l,placeholder:u,loading:C,onChange:d=>{if(!d){i(null);return}let v=o.find(P=>P.id===d);i(v||null)},onDropdownVisibleChange:d=>{d&&S()},optionFilterProp:"label",style:{width:"100%"},options:o.map(d=>({value:d.id,label:d.name||d.id,description:d.description})),optionRender:d=>(0,ue.jsxs)("div",{children:[(0,ue.jsx)("div",{children:d.label}),d.data.description&&(0,ue.jsx)(nn,{type:"secondary",style:{fontSize:12},children:d.data.description})]})})};var L=I(E()),{Text:Nt}=X,Ot=({subAgentKeys:i,decisions:l,onChange:f})=>{let{token:c}=We.useToken(),u=z(),o=(C,r)=>{let m=l.map(S=>S.originalKey===C?{...S,clone:r,cloneKey:r?`${C}_clone`:void 0}:S);f(m)},e=(C,r)=>{let m=l.map(S=>S.originalKey===C?{...S,cloneKey:r}:S);f(m)};return i.length===0?null:(0,L.jsxs)("div",{children:[(0,L.jsx)(Nt,{type:"secondary",style:{display:"block",marginBottom:8},children:u("chatConfig.subAgentInherit.hint")}),(0,L.jsx)(Le,{size:"small",bordered:!0,dataSource:l,style:{borderRadius:c.borderRadius},renderItem:C=>(0,L.jsxs)(Le.Item,{style:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8,padding:"8px 16px"},children:[(0,L.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,L.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[C.clone?(0,L.jsx)(Pe,{style:{color:c.colorPrimary}}):(0,L.jsx)(Qe,{style:{color:c.colorTextSecondary}}),(0,L.jsx)(Nt,{style:{fontFamily:"monospace"},children:C.originalKey})]}),(0,L.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,L.jsx)(we,{color:C.clone?"blue":"default",children:C.clone?u("chatConfig.subAgentInherit.clone"):u("chatConfig.subAgentInherit.reuse")}),(0,L.jsx)($e,{size:"small",checked:C.clone,onChange:r=>o(C.originalKey,r)})]})]}),C.clone&&(0,L.jsx)(V,{size:"small",placeholder:u("chatConfig.subAgentInherit.cloneKeyPlaceholder"),value:C.cloneKey,onChange:r=>e(C.originalKey,r.target.value),style:{fontFamily:"monospace",fontSize:12},addonBefore:u("chatConfig.keyValue.key")})]})})]})};function Vt(i,l){return i.mode!=="local"||i.templateKey||typeof i.executable=="string"&&i.executable.trim().length>0?null:l?l("chat.config.executableRequired"):"Choose a template or enter a custom executable"}var n=I(E()),{TextArea:_t}=V,{Text:ne}=X,Gt="/.well-known/agent-card.json",an=[{value:"http://",label:"http://"},{value:"https://",label:"https://"}],on={react:"chatConfig.createAssistant.typeDesc.react",deep_agent:"chatConfig.createAssistant.typeDesc.deepAgent",processing:"chatConfig.createAssistant.typeDesc.processing",a2a_remote:"chatConfig.createAssistant.typeDesc.a2aRemote"};function zt(i,l,f="https://"){let c=String(i??"").trim();if(!c)return"";let u=l==="http://"||l==="https://"?l:f,e=(/^https?:\/\//i.test(c)?c:`${u}${c.replace(/^\/+/,"")}`).replace(/\/+$/,"");return e.endsWith(Gt)?e:`${e}${Gt}`}function sn(i){try{return new URL(i).port||void 0}catch{return}}function rn(i){return i.some(l=>l==="--port"||l==="-p"||/^--port=/.test(l)||/^-p=/.test(l))}function jt(i,l){let f=[...i.args],c=sn(l);return c&&!rn(f)&&f.push("--port",c),{...i,args:f,...i.env?{env:{...i.env}}:{}}}var Ut=({open:i,onCancel:l,onSuccess:f,initialMode:c,initialValues:u})=>{let[o]=R.useForm(),e=z(),[C,r]=(0,A.useState)(!1),[m,S]=(0,A.useState)("learn"),[M,H]=(0,A.useState)(""),[d,v]=(0,A.useState)(null),[P,D]=(0,A.useState)([]),$=R.useWatch("type",o)||"react",j=$==="a2a_remote",[a,g]=(0,A.useState)("remote"),[U,fe]=(0,A.useState)(void 0),[le,ye]=(0,A.useState)([]),[Se,ce]=(0,A.useState)(!1),ae=(0,A.useRef)(0),[oe,ie]=(0,A.useState)(!1),[De,Y]=(0,A.useState)(!1),{get:N,post:J,put:he}=me(),Me=Ze("agent-architect"),{workspaceId:Ce,trainingProjects:Q,loading:de}=rt(),[Ee,Ae]=(0,A.useState)(null),Ke=JSON.stringify(u??null),K=Q.find(t=>t.id===Ee)??Q[0]??null,[be,ke]=(0,A.useState)([]),p=(0,A.useCallback)(()=>{v(null),D([])},[]),b=(0,A.useCallback)(()=>{o.resetFields(),p(),S("learn"),H(""),ke([]),Ae(null),g("remote"),fe(void 0),ye([]),Y(!1),ie(!1)},[o,p]);(0,A.useEffect)(()=>{if(i){b(),S(c??"learn");let t=u?.a2aMode;(t==="remote"||t==="local")&&g(t),o.setFieldsValue({type:"react",agentCardProtocol:"https://",a2aMode:"remote",timeout:3e5,...u})}},[i,o,c,Ke,b]),(0,A.useEffect)(()=>{let t=++ae.current,s=!0;return i&&j?(o.setFieldValue("prompt",""),a==="local"?(ce(!0),N("/api/local-a2a/templates").then(k=>{s&&t===ae.current&&k?.data?.records&&ye(k.data.records)}).catch(()=>{s&&t===ae.current&&ye([])}).finally(()=>{s&&t===ae.current&&ce(!1)})):ce(!1)):ce(!1),()=>{s=!1,ae.current+=1}},[o,j,a,N,i]);let x=le.find(t=>t.key===U),q=(0,A.useCallback)(()=>{let t=Vt({mode:a,templateKey:U,executable:o.getFieldValue("commandExecutable")},e);return t?(Y(!0),o.setFields([{name:"commandExecutable",errors:[t]}]),w.warning(t),!1):!0},[a,U,o,e]);(0,A.useEffect)(()=>{x&&o.setFieldsValue({agentCardProtocol:"http://"})},[o,x]);let ve=(0,A.useCallback)(async()=>{if(!q())return;let t=zt(o.getFieldValue("agentCardUrl"),o.getFieldValue("agentCardProtocol"),a==="local"?"http://":"https://");if(!t){w.warning(e("chatConfig.createAssistant.a2aUrlWarning"));return}ie(!0);try{let s={agentCardUrl:t,apiKey:o.getFieldValue("apiKey")};if(a==="local"){let y=x;if(y)s.localRuntime={label:o.getFieldValue("name")||void 0,agentCardUrl:t,command:jt(y.command,t)};else{let B=o.getFieldValue("commandArgs")||"",G=B?B.split(/\s+/).filter(Boolean):[],F=String(o.getFieldValue(["command","cwd"])||"").trim();s.localRuntime={label:o.getFieldValue("name")||void 0,agentCardUrl:t,command:{executable:String(o.getFieldValue("commandExecutable")||"").trim(),args:G,...F?{cwd:F}:{}}}}}let k=await J("/api/a2a/test-connection",s);if(k.data?.reachable){let y=k.data.agentCard;w.success(e("chatConfig.createAssistant.connectedTo",{name:k.data.agentName||t}))}else w.error(k.data?.error||e("chatConfig.createAssistant.connectionFailed"))}catch{w.error(e("chatConfig.createAssistant.connectionTestFailed"))}finally{ie(!1)}},[o,J,a,x,q,e]),$t=(0,A.useCallback)(t=>{if(v(t),!t){o.resetFields(["key","name","description","type","prompt"]),D([]);return}let s=typeof t.graphDefinition=="object"&&t.graphDefinition!==null?t.graphDefinition:{},k=s.key||t.id,y=t.name||s.name||"";o.setFieldsValue({key:`${k}_ext`,name:y?`${y} (Extended)`:"",description:t.description||s.description||"",type:s.type||"react",prompt:s.prompt||""});let B=s.subAgents||[];D(B.map(G=>({originalKey:G,clone:!1})))},[o]),Wt=async(t,s)=>{let k=await N(`/api/assistants/${t}`);if(!k.success)throw new Error(e("chatConfig.createAssistant.cloneFetchFailed",{key:t}));let y=k.data,B=typeof y.graphDefinition=="object"?y.graphDefinition:{},G={id:s,name:`${y.name} (Clone)`,description:y.description||"",graphDefinition:{...B,key:s,name:`${y.name} (Clone)`}},F=await J("/api/assistants",G);if(!F.success)throw new Error(F.message||e("chatConfig.createAssistant.cloneFailed",{key:t}));return F.data},Zt=t=>{let s={id:t.key,name:t.name,description:t.description||"",graphDefinition:{key:t.key,name:t.name,description:t.description||"",type:t.type,prompt:t.prompt||"",tools:[],skills:[],subAgents:t.type==="deep_agent"||t.type==="processing"?[]:void 0,middleware:[]}};if(t.type==="a2a_remote"&&(s.graphDefinition.agentCardUrl=zt(t.agentCardUrl,t.agentCardProtocol,(t.a2aMode||a)==="local"?"http://":"https://"),t.apiKey&&(s.graphDefinition.apiKey=t.apiKey),t.timeout&&(s.graphDefinition.timeout=t.timeout),(t.a2aMode||a)==="local")){let k=x;if(k)s.graphDefinition.localRuntime={label:t.name||void 0,agentCardUrl:s.graphDefinition.agentCardUrl,command:jt(k.command,s.graphDefinition.agentCardUrl)};else{let y=t.commandArgs||"",B=y?y.split(/\s+/).filter(Boolean):[],G=String(t.command?.cwd||"").trim();s.graphDefinition.localRuntime={label:t.name||void 0,agentCardUrl:s.graphDefinition.agentCardUrl,command:{executable:String(t.commandExecutable||"").trim(),args:B,...G?{cwd:G}:{}}}}}return s},Yt=async(t,s)=>{if(!d)throw new Error(e("chatConfig.createAssistant.noParentAgent"));let k=P.filter(F=>F.clone);for(let F of k){if(!F.cloneKey||!F.cloneKey.trim())throw new Error(e("chatConfig.createAssistant.cloneKeyRequired",{key:F.originalKey}));if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(F.cloneKey))throw new Error(e("chatConfig.createAssistant.cloneKeyInvalid",{key:F.cloneKey,originalKey:F.originalKey}))}let y=[];for(let F of P)if(F.clone){let Xt=await Wt(F.originalKey,F.cloneKey);s.push(Xt),y.push(F.cloneKey)}else y.push(F.originalKey);let B=typeof d.graphDefinition=="object"?d.graphDefinition:{},G={key:t.key,name:t.name,description:t.description||"",extendsAgent:d.id,type:t.type||B.type};return t.prompt&&t.prompt!==B.prompt&&(G.prompt=t.prompt),(y.length>0||B.subAgents&&B.subAgents.length>0)&&(G.subAgents=y),{id:t.key,name:t.name,description:t.description||"",graphDefinition:G}},Jt=async()=>{if(m==="learn"){let t=M.trim();if(!t){w.error(e("chatConfig.createAssistant.trainingGoalRequired"));return}if(!K){w.error(e("chatConfig.createAssistant.noTrainingProject"));return}r(!0);try{let s=`agent-${It(t+Date.now())}`,k=await J("/api/assistants",{id:s,name:s,graphDefinition:{key:s,name:s,description:"",type:"react",prompt:"To be trained",metadata:{trainingProjectId:K.id,learningPlaceholder:"true",architectureStatus:"undecided"}}});if(!k.data)throw new Error(e("chatConfig.createAssistant.agentCreateFailed"));let{roundTaskId:y}=await Ft({goal:t,targetAgentId:s,workspaceId:Ce??void 0,projectId:K.id,existingThreadId:St(Me.tenantId,s),files:be,post:J,put:he});w.success(e("chatConfig.createAssistant.agentCreated")),H(""),ke([]),S("learn"),f?.(k.data,{initialMessage:Pt({goal:t,roundTaskId:y,targetAgentId:s,targetMode:"placeholder",files:be,projectId:K.id,workspaceId:K.workspaceId??Ce??void 0}),projectId:K.id,initialMessageCustomRunConfig:{execution:{taskId:y}}}),l()}catch(s){w.error(s instanceof Error?s.message:e("chatConfig.createAssistant.agentCreateFailed"))}finally{r(!1)}return}try{if(m==="scratch"&&j&&!q())return;let t=await o.validateFields();r(!0);let s=[],k=m==="scratch"?Zt(t):await Yt(t,s),y=await J("/api/assistants",k);if(y.success){w.success(m==="extend"?e("chatConfig.createAssistant.createdByExtending",{name:d?.name??""}):e("chatConfig.createAssistant.created")),b();for(let B of s)f?.(B);f?.(y.data),l()}else w.error(y.message||e("chatConfig.createAssistant.createFailed"))}catch(t){if(t?.errorFields){let s={key:e("chatConfig.createAssistant.field.key"),name:e("chatConfig.createAssistant.field.name"),description:e("chatConfig.createAssistant.field.description"),prompt:e("chatConfig.createAssistant.field.systemPrompt")},k=t.errorFields.map(y=>s[String((y.name??[])[0])]??String((y.name??[])[0])).filter(Boolean);w.warning(k.length>0?e("chatConfig.createAssistant.requiredFields",{fields:[...new Set(k)].join(", ")}):e("chatConfig.createAssistant.requiredFieldsGeneric"));return}w.error(t.message||e("chatConfig.createAssistant.createError"))}finally{r(!1)}},ze=d?.graphDefinition?.subAgents||[],Qt=m==="extend"&&d&&ze.length>0;return(0,n.jsxs)(pe,{title:e("chatConfig.createAssistant.title"),open:i,onCancel:()=>{b(),l()},footer:[(0,n.jsx)(W,{onClick:()=>{b(),l()},children:e("common.cancel")},"cancel"),(0,n.jsx)(W,{type:"primary",icon:m==="extend"?(0,n.jsx)(Pe,{}):m==="learn"?(0,n.jsx)(Je,{}):(0,n.jsx)(Xe,{}),loading:C,disabled:m==="learn"&&(de||!K),onClick:Jt,children:e(m==="extend"?"chatConfig.createAssistant.createExtend":m==="learn"?"chatConfig.createAssistant.startLearning":"common.create")},"submit")],width:760,children:[m==="extend"&&(0,n.jsxs)("div",{style:{marginBottom:20},children:[(0,n.jsx)(ne,{type:"secondary",style:{display:"block",marginBottom:8},children:e("chatConfig.createAssistant.parentAgent")}),(0,n.jsx)(Lt,{value:d?.id,onSelect:$t}),d&&(0,n.jsx)(ne,{type:"secondary",style:{display:"block",marginTop:4,fontSize:12},children:e("chatConfig.createAssistant.inheritHint")})]}),m==="extend"&&d&&(0,n.jsx)(Be,{style:{margin:"12px 0"}}),m==="learn"&&(0,n.jsxs)("div",{children:[(0,n.jsx)(ne,{style:{display:"block",marginBottom:8},children:e("chatConfig.createAssistant.learnHint")}),(0,n.jsx)(V.TextArea,{rows:3,value:M,onChange:t=>H(t.target.value),placeholder:e("chatConfig.createAssistant.learnGoalPlaceholder")}),K&&(0,n.jsxs)("div",{style:{marginTop:12},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[(0,n.jsx)(ne,{type:"secondary",children:e("chatConfig.createAssistant.referenceFiles")}),(0,n.jsx)(_e,{project:K,projects:Q,value:K?.id??null,onChange:Ae,loading:de})]}),(0,n.jsx)(Tt,{projectId:K.id,value:be,onChange:ke}),(0,n.jsx)(ne,{type:"secondary",style:{display:"block",marginTop:6,fontSize:12},children:e("chatConfig.createAssistant.referenceFilesHint")})]}),!K&&!de&&(0,n.jsx)("div",{style:{marginTop:12},children:(0,n.jsx)(_e,{project:K,projects:Q,value:null,onChange:Ae,loading:de})})]}),m!=="learn"&&(0,n.jsxs)(R,{form:o,layout:"vertical",autoComplete:"off",initialValues:{type:"react",agentCardProtocol:"https://",a2aMode:"remote"},children:[(0,n.jsx)(R.Item,{name:"key",label:e("chatConfig.createAssistant.field.key"),rules:[{required:!0,message:e("chatConfig.createAssistant.validation.keyRequired")},{pattern:/^[a-zA-Z][a-zA-Z0-9_-]*$/,message:e("chatConfig.createAssistant.validation.keyPattern")}],style:{marginBottom:16},children:(0,n.jsx)(V,{placeholder:e("chatConfig.createAssistant.keyPlaceholder")})}),(0,n.jsx)(R.Item,{name:"name",label:e("chatConfig.createAssistant.field.name"),rules:[{required:!0,message:e("chatConfig.createAssistant.validation.nameRequired")}],style:{marginBottom:16},children:(0,n.jsx)(V,{placeholder:e("chatConfig.createAssistant.namePlaceholder")})}),(0,n.jsx)(R.Item,{name:"description",label:e("chatConfig.createAssistant.field.description"),rules:[{required:!0,message:e("chatConfig.createAssistant.validation.descriptionRequired")}],style:{marginBottom:16},children:(0,n.jsx)(_t,{placeholder:e("chatConfig.createAssistant.descriptionPlaceholder"),autoSize:{minRows:2,maxRows:4}})}),(0,n.jsx)(R.Item,{name:"type",label:e("chatConfig.createAssistant.field.agentType"),rules:[{required:!0}],style:{marginBottom:16},children:(0,n.jsx)(Ue,{options:[{value:"react",label:e("chatConfig.agentType.executor")},{value:"deep_agent",label:e("chatConfig.agentType.orchestrator")},{value:"processing",label:e("chatConfig.agentType.workflow")},{value:"a2a_remote",label:e("chatConfig.agentType.a2aRemote")}],block:!0})}),(0,n.jsx)(ne,{type:"secondary",style:{fontSize:12,display:"block",marginTop:-12,marginBottom:16,lineHeight:1.5},children:e(on[$]??"chatConfig.createAssistant.typeDesc.react")}),j&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(R.Item,{label:e("chatConfig.createAssistant.field.connectionMode"),style:{marginBottom:16},children:(0,n.jsxs)(Fe.Group,{value:a,onChange:t=>{let s=t.target.value;g(s),o.setFieldValue("a2aMode",s),s==="local"&&o.setFieldValue("agentCardProtocol","http://"),fe(void 0)},optionType:"button",buttonStyle:"solid",children:[(0,n.jsx)(Fe.Button,{value:"remote",children:e("chatConfig.createAssistant.mode.remoteUrl")}),(0,n.jsx)(Fe.Button,{value:"local",children:e("chatConfig.createAssistant.mode.localManaged")})]})}),(0,n.jsx)(R.Item,{name:"a2aMode",noStyle:!0,hidden:!0,children:(0,n.jsx)(V,{})}),a==="local"&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(R.Item,{label:e("chatConfig.createAssistant.field.template"),style:{marginBottom:16},children:(0,n.jsx)(xe,{placeholder:e("chatConfig.createAssistant.templatePlaceholder"),allowClear:!0,loading:Se,value:U,onChange:t=>{fe(t),t&&Y(!1)},options:le.map(t=>({value:t.key,label:t.name||t.key})),notFoundContent:Se?void 0:(0,n.jsx)(ne,{type:"secondary",style:{padding:8,display:"block"},children:e("chatConfig.createAssistant.noTemplates")})})}),!U&&(0,n.jsx)(n.Fragment,{children:De?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(R.Item,{name:"commandExecutable",label:e("chatConfig.createAssistant.field.executable"),rules:[{required:!0,whitespace:!0,message:e("chatConfig.createAssistant.validation.executableRequired")}],style:{marginBottom:16},children:(0,n.jsx)(V,{placeholder:e("chatConfig.createAssistant.executablePlaceholder")})}),(0,n.jsx)(R.Item,{name:"commandArgs",label:e("chatConfig.createAssistant.field.arguments"),style:{marginBottom:16},children:(0,n.jsx)(V,{placeholder:e("chatConfig.createAssistant.argumentsPlaceholder")})}),(0,n.jsx)(R.Item,{name:["command","cwd"],label:e("chatConfig.createAssistant.field.workingDirectory"),style:{marginBottom:16},children:(0,n.jsx)(V,{placeholder:e("chatConfig.createAssistant.workingDirectoryPlaceholder")})}),(0,n.jsx)(W,{type:"link",onClick:()=>{Y(!1),o.setFieldsValue({commandExecutable:"",commandArgs:"",command:{cwd:void 0}})},style:{padding:0,marginBottom:16,display:"block"},children:e("chatConfig.createAssistant.hideCustomCommand")})]}):(0,n.jsx)(W,{type:"link",onClick:()=>Y(!0),style:{padding:0,marginBottom:16,display:"block"},children:e("chatConfig.createAssistant.customCommand")})})]}),(0,n.jsx)(R.Item,{label:e("chatConfig.createAssistant.field.agentCardUrl"),required:!0,style:{marginBottom:16},children:(0,n.jsxs)(He.Compact,{style:{width:"100%"},children:[(0,n.jsx)(R.Item,{name:"agentCardProtocol",noStyle:!0,children:(0,n.jsx)(xe,{style:{width:100},options:an})}),(0,n.jsx)(R.Item,{name:"agentCardUrl",noStyle:!0,rules:[{required:!0,message:e("chatConfig.createAssistant.validation.urlRequired")}],children:(0,n.jsx)(V,{placeholder:a==="local"?"localhost:4301":"host:port or full URL"})}),(0,n.jsx)(W,{icon:(0,n.jsx)(Ye,{}),onClick:ve,loading:oe,children:e("chatConfig.connection.action.test")})]})}),a==="remote"&&(0,n.jsx)(R.Item,{name:"apiKey",label:e("chatConfig.createAssistant.field.apiKeyOptional"),style:{marginBottom:16},children:(0,n.jsx)(V.Password,{placeholder:e("chatConfig.createAssistant.apiKeyPlaceholder")})}),(0,n.jsx)(R.Item,{name:"timeout",label:e("chatConfig.createAssistant.field.timeout"),style:{marginBottom:16},initialValue:3e5,children:(0,n.jsx)(qe,{min:1e3,max:36e5,style:{width:"100%"},placeholder:"300000"})})]}),!j&&(0,n.jsx)(R.Item,{name:"prompt",label:e(m==="extend"&&d?"chatConfig.createAssistant.field.systemPromptInherit":"chatConfig.createAssistant.field.systemPrompt"),rules:m==="scratch"?[{required:!0,message:e("chatConfig.createAssistant.validation.systemPromptRequired")}]:[],children:(0,n.jsx)(_t,{placeholder:e(m==="extend"&&d?"chatConfig.createAssistant.systemPromptInheritPlaceholder":"chatConfig.createAssistant.systemPromptPlaceholder"),autoSize:{minRows:4,maxRows:8},style:{fontFamily:"monospace",fontSize:13,lineHeight:1.6}})})]}),Qt&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(Be,{style:{margin:"12px 0"}}),(0,n.jsx)(ne,{strong:!0,style:{display:"block",marginBottom:8},children:e("chatConfig.createAssistant.subAgents")}),(0,n.jsx)(Ot,{subAgentKeys:ze,decisions:P,onChange:D})]})]})};var O=I(E()),{Paragraph:ln,Text:qt}=X,cn=[{key:"manual",icon:Te,titleKey:"governance.creation.manual.title",descriptionKey:"governance.creation.manual.description"},{key:"external",icon:tt,titleKey:"governance.creation.external.title",descriptionKey:"governance.creation.external.description"},{key:"learn",icon:at,titleKey:"governance.creation.learn.title",descriptionKey:"governance.creation.learn.description"}],Ht=({open:i,onCancel:l,onSelectMethod:f,focusTriggerAfterClose:c=!0})=>{let u=z();return(0,O.jsx)(pe,{title:u("governance.creation.title"),open:i,onCancel:l,footer:null,width:560,centered:!0,destroyOnHidden:!0,focusTriggerAfterClose:c,children:(0,O.jsxs)("div",{style:{padding:"8px 4px 4px"},children:[(0,O.jsx)(ln,{style:{color:"#595959",fontSize:15,margin:"8px 0 24px"},children:u("governance.creation.subtitle")}),(0,O.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:cn.map(o=>{let e=o.icon,C=u(o.titleKey);return(0,O.jsxs)(W,{type:"default",onClick:()=>f(o.key),"aria-label":C,style:{display:"flex",flexDirection:"row",alignItems:"center",gap:16,width:"100%",minHeight:88,height:"auto",padding:16,borderRadius:16,textAlign:"left",whiteSpace:"normal"},children:[(0,O.jsx)("div",{style:{width:40,height:40,borderRadius:12,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"#6366f1",background:"#eeeeff"},children:(0,O.jsx)(e,{size:19})}),(0,O.jsxs)("div",{style:{minWidth:0},children:[(0,O.jsx)(qt,{strong:!0,style:{display:"block",fontSize:15,marginBottom:3},children:C}),(0,O.jsx)(qt,{style:{color:"#737373",lineHeight:1.5},children:u(o.descriptionKey)})]})]},o.key)})}),(0,O.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,flexWrap:"wrap",marginTop:24},children:(0,O.jsx)(W,{onClick:l,children:u("governance.creation.notNow")})})]})})};var _=I(E()),dn=i=>{let l=i;if(typeof i=="string")try{l=JSON.parse(i)}catch{return{}}return l!==null&&typeof l=="object"&&!Array.isArray(l)?l:{}},ka=()=>{let{get:i,del:l,put:f}=me(),c=z(),[u,o]=(0,h.useState)([]),[e,C]=(0,h.useState)(!1),[r,m]=(0,h.useState)(null),[S,M]=(0,h.useState)("graph"),[H,d]=(0,h.useState)(null),[v,P]=(0,h.useState)(null),[D,$]=(0,h.useState)(null),[j,a]=(0,h.useState)(!1),[g,U]=(0,h.useState)(!0),[fe,le]=(0,h.useState)(!1),[ye,Se]=(0,h.useState)("learn"),[ce,ae]=(0,h.useState)({}),[oe,ie]=(0,h.useState)(null),[De,Y]=(0,h.useState)(!1),N=(0,h.useCallback)(async()=>{C(!0);try{let p=await i("/api/assistants");p.success&&p.data?.records&&o(p.data.records)}catch{w.error(c("governance.workbench.loadFailed"))}finally{C(!1)}},[i,c]);(0,h.useEffect)(()=>{N()},[N]);let J=h.default.useMemo(()=>xt(u),[u]),he=u.find(p=>p.id===r)??null,Me=(0,h.useCallback)((p,b="graph")=>{m(p),M(b),d(null),$(null)},[]),Ce=ut(),Q=(0,h.useCallback)((p,b)=>{let x=u.find(q=>q.id===p)?.name??c("governance.workbench.agentFallback");Ce({component_key:"agent_detail_side_app",data:{assistantId:p,initialTab:b},message:x})},[u,Ce,c]),de=(0,h.useCallback)(()=>{U(!0),a(!0)},[]),Ee=(0,h.useCallback)(p=>{let x={manual:{mode:"scratch",values:{}},external:{mode:"scratch",values:{type:"a2a_remote"}},learn:{mode:"learn",values:{}}}[p];Se(x.mode),ae(x.values),U(!1),a(!1),le(!0)},[]),Ae=(0,h.useCallback)(async(p,b)=>{let x=dn(p.graphDefinition),q;try{q=await f(`/api/assistants/${p.id}`,{name:b.name!==void 0?b.name:p.name,description:b.description!==void 0?b.description:p.description,graphDefinition:{...x,...b}})}catch(ve){throw w.error(c("governance.detail.saveFailed")),ve}if(!q.success)throw w.error(c("governance.detail.saveFailed")),new Error("Failed to save agent");w.success(c("common.saved")),N()},[f,N,c]),Ke=(0,h.useCallback)(p=>{o(b=>b.map(x=>x.id===p.id?p:x))},[]),K=(0,h.useCallback)(p=>{ie(p)},[]),be=(0,h.useCallback)(async()=>{if(oe){Y(!0);try{(await l(`/api/assistants/${oe}`)).success?(w.success(c("governance.detail.deleted")),o(b=>b.filter(x=>x.id!==oe)),N(),ie(null)):w.error(c("governance.detail.deleteFailed"))}catch{w.error(c("governance.detail.deleteFailed"))}finally{Y(!1)}}},[oe,l,N,c]),ke=(0,h.useCallback)(async p=>{if(!(await l(`/api/assistants/${p}`)).success)throw new Error("Failed to delete agent");w.success(c("governance.detail.deleted")),o(x=>x.filter(q=>q.id!==p)),N()},[l,N,c]);return(0,_.jsxs)("div",{style:{height:"100%",background:"#fafafa",overflow:"hidden"},children:[he?(0,_.jsx)(kt,{defaultProjectId:D??void 0,children:(0,_.jsx)(Rt,{assistant:he,allAssistants:u,onBack:()=>m(null),onDeleted:ke,onSave:Ae,onAssistantUpdated:Ke,onAgentListInvalidated:N,initialTab:S,initialMessage:H,initialMessageCustomRunConfig:v,initialProjectId:D})},he.id):(0,_.jsx)(_.Fragment,{children:(0,_.jsx)(Bt,{items:J,assistants:u,loading:e,onItemClick:p=>Q(p,"graph"),onOpenPlayground:p=>Q(p,"playground"),onOpenEval:p=>Q(p,"eval"),onCreate:de,onDelete:K})}),(0,_.jsx)(Ht,{open:j,onCancel:()=>{U(!0),a(!1)},onSelectMethod:Ee,focusTriggerAfterClose:g}),(0,_.jsx)(Ut,{open:fe,initialMode:ye,initialValues:ce,onCancel:()=>le(!1),onSuccess:(p,b)=>{le(!1),o(x=>x.some(ve=>ve.id===p.id)?x:[p,...x]),Me(p.id,"graph"),d(b?.initialMessage??null),P(b?.initialMessageCustomRunConfig??null),$(b?.projectId??null),N()}}),(0,_.jsx)(pe,{title:c("governance.deleteAgent"),open:oe!==null,onCancel:()=>ie(null),onOk:be,okText:c("common.delete"),okButtonProps:{danger:!0,loading:De},cancelText:c("common.cancel"),children:(0,_.jsx)("p",{children:c("governance.delete.irreversible")})})]})};export{ka as AgentGovernanceWorkbench};
1
+ import{a as Ie,b as Re,c as vt,d as xt,e as wt,f as Tt,g as It,h as St,i as Ft,j as Pt,k as Rt}from"./embed-page-chunk-YMVKQQXJ.js";import{a as _e}from"./embed-page-chunk-JTL73EBV.js";import"./embed-page-chunk-PROZXFWS.js";import"./embed-page-chunk-IELKCYQX.js";import"./embed-page-chunk-FE6KYRCO.js";import{b as Oe,e as Ve,f as ft,g as yt,h as ht,i as Ct,l as At,m as bt}from"./embed-page-chunk-DJKD2PHO.js";import"./embed-page-chunk-D7YTSCUO.js";import{a as ct,b as dt,c as gt,d as pt,e as mt}from"./embed-page-chunk-SV2BM3WO.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-WGEXK773.js";import{T as kt,e as lt,h as ut,r as Ne}from"./embed-page-chunk-IBRMWDHE.js";import{i as rt}from"./embed-page-chunk-4XKCMM5C.js";import{a as me}from"./embed-page-chunk-PMOGSY6W.js";import{o as Ze}from"./embed-page-chunk-BSRASK7V.js";import{C as et,La as st,Q as tt,U as nt,ba as at,n as Te,oa as ot,ua as it}from"./embed-page-chunk-F7ZUYG42.js";import{k as z}from"./embed-page-chunk-ASEIOK7X.js";import{a as E}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-34RWKVD7.js";import{Ja as Xe,Q as Je,g as Ye,na as Pe,za as Qe}from"./embed-page-chunk-B2KNZ3EW.js";import{Da as R,Ia as V,Ka as Le,La as w,Ma as pe,Sa as $e,Za as we,_ as W,_a as We,bb as X,fa as xe,ha as je,na as Fe,ua as Be,va as Ue,xa as qe,za as He}from"./embed-page-chunk-F7TA3LRH.js";import{a as ge}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as I}from"./embed-page-chunk-QBTAJ2YI.js";var h=I(ge());var te=I(ge());var Z=I(ge());var Dt=I(ge());var se=I(E()),Mt=60,Et=72,Ge=(0,Dt.memo)(({data:i})=>{let l=Ie(i.type),f=Math.min(12+Math.sqrt(i.subAgentCount)*10,48);return(0,se.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[(0,se.jsx)(Ve,{type:"target",position:Oe.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:0,height:0},isConnectable:!1}),(0,se.jsx)("div",{title:i.label,style:{width:f,height:f,borderRadius:"50%",background:Re(l.color),display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:Math.max(10,f*.4),fontWeight:600,cursor:"pointer",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},children:i.label.charAt(0).toUpperCase()}),(0,se.jsx)("div",{style:{fontSize:11,maxWidth:120,textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:4},children:i.label}),(0,se.jsx)(Ve,{type:"source",position:Oe.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:0,height:0},isConnectable:!1})]})});Ge.displayName="AgentGraphNode";var ee=I(E()),en=({assistants:i,onNodeClick:l})=>{let[f,c,u]=ht([]),[o,e,C]=Ct([]),[r,m]=(0,Z.useState)(null),S=(0,Z.useMemo)(()=>({agent:Ge}),[]),M=(0,Z.useMemo)(()=>wt(i),[i]);(0,Z.useEffect)(()=>{let v=M.nodes.map(g=>({id:g.id})),P=M.edges.map(g=>({source:g.source,target:g.target})),D=new Map(M.nodes.map(g=>[g.id,g])),$=pt(v).force("link",gt(P).id(g=>g.id).distance(80)).force("charge",mt().strength(-220)).force("center",ct(0,0)).force("collide",dt(45)).stop();for(let g=0;g<300;g++)$.tick();let j=v.map(g=>({id:g.id,type:"agent",data:D.get(g.id),position:{x:g.x-Mt/2,y:g.y-Et/2}})),a=M.edges.map(g=>({id:`e${g.source}-${g.target}`,source:g.source,target:g.target,style:{stroke:"#1677ff",strokeWidth:2},type:"straight"}));c(j),e(a)},[M,c,e]);let H=(0,Z.useMemo)(()=>r===null?f:f.map(v=>{let P=v.id===r||o.some(D=>D.source===r&&D.target===v.id||D.target===r&&D.source===v.id);return{...v,style:{opacity:P?1:.2,transition:"opacity 0.2s ease"}}}),[f,o,r]),d=(0,Z.useMemo)(()=>r===null?o.map(v=>({...v,style:{stroke:"#1677ff",strokeWidth:1.5,opacity:.25,transition:"opacity 0.2s ease"}})):o.map(v=>{let P=v.source===r||v.target===r;return{...v,style:{stroke:"#1677ff",strokeWidth:P?2.5:1,opacity:P?1:.04,transition:"opacity 0.2s ease"}}}),[o,r]);return(0,ee.jsx)("div",{style:{width:"100%",height:"100%",background:"#fafafa",position:"relative"},children:(0,ee.jsxs)(yt,{nodes:H,edges:d,onNodesChange:u,onEdgesChange:C,onNodeMouseEnter:(v,P)=>m(P.id),onNodeMouseLeave:()=>m(null),onNodeClick:(v,P)=>l?.(String(P.id)),nodeTypes:S,fitView:!0,fitViewOptions:{padding:.25},children:[(0,ee.jsx)(At,{color:"#eee",gap:20}),(0,ee.jsx)(bt,{})]})})},Kt=i=>(0,ee.jsx)(ft,{children:(0,ee.jsx)(en,{...i})});var T=I(E()),tn=[{key:"all",labelKey:"governance.list.tab.all"},{key:"capability",labelKey:"governance.list.tab.capability"},{key:"orchestrator",labelKey:"governance.list.tab.orchestrator"},{key:"workflow",labelKey:"governance.list.tab.workflow"}],Bt=({items:i,assistants:l=[],loading:f,onItemClick:c,onOpenPlayground:u,onOpenEval:o,onCreate:e,onDelete:C})=>{let r=z(),[m,S]=(0,te.useState)("all"),[M,H]=(0,te.useState)(null),[d,v]=(0,te.useState)(null),P=(0,te.useMemo)(()=>{let a=new Set;return i.forEach(g=>g.tags.forEach(U=>a.add(U))),Array.from(a).map(g=>({value:g,label:g}))},[i]),D=(0,te.useMemo)(()=>i.filter(a=>!(m!=="all"&&a.type!==m||M&&!a.tags.includes(M)||d&&a.status!==d)),[i,m,M,d]),$=[{key:"edit",icon:it,label:r("common.edit"),onClick:a=>c(a.id)},{key:"playground",icon:et,label:r("governance.list.action.playground"),onClick:a=>u(a.id)},{key:"eval",icon:nt,label:r("governance.list.action.eval"),onClick:a=>o(a.id)}];C&&$.push({key:"delete",icon:st,label:r("common.delete"),danger:!0,onClick:a=>C(a.id)});let j=(0,te.useMemo)(()=>[{mode:"graph",icon:ot,label:r("governance.list.viewMode.graph"),render:()=>(0,T.jsx)(Kt,{assistants:l,onNodeClick:c})}],[l,c,r]);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)("span",{"data-testid":"agent-list-state","data-loading":String(f),"data-count":D.length,hidden:!0,"aria-hidden":"true"}),(0,T.jsx)(lt,{title:r("governance.list.title"),itemName:"common.item.agent",items:D,loading:f,keyExtractor:a=>a.id,tabs:tn.map(a=>({key:a.key,label:r(a.labelKey)})),activeTab:m,onTabChange:a=>S(a),headerLeft:(0,T.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[(0,T.jsx)(Ne,{value:M,onChange:H,options:P,placeholder:r("governance.list.filter.domain"),allLabel:r("governance.list.filter.allDomains")}),(0,T.jsx)(Ne,{value:d,onChange:v,options:[{value:"enabled",label:r("governance.list.status.enabled")},{value:"draft",label:r("governance.list.status.draft")},{value:"disabled",label:r("governance.list.status.disabled")}],placeholder:r("governance.list.filter.status"),allLabel:r("governance.list.filter.allStatuses")})]}),renderIcon:a=>{let g=Re(Ie(a.type).color);return(0,T.jsx)("div",{title:r("governance.list.typeIconTitle",{type:a.type}),style:{width:32,height:32,borderRadius:8,background:`${g}1A`,color:g,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,T.jsx)(Te,{size:18})})},renderPrimary:a=>(0,T.jsx)("span",{"data-testid":"agent-name","data-agent-id":a.id,children:a.name}),renderSecondary:a=>a.description||void 0,renderDetails:a=>(0,T.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,T.jsxs)("div",{style:{display:"flex",gap:4,flexWrap:"wrap",alignItems:"center"},children:[a.tags.map(g=>(0,T.jsx)(we,{color:"magenta",style:{margin:0,borderRadius:10,border:"none"},children:g},g)),(0,T.jsx)(we,{color:Ie(a.type).color,style:{margin:0,borderRadius:10,border:"none"},children:a.type})]}),(0,T.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[(0,T.jsx)(je,{title:r("governance.list.statusTooltip",{status:a.status}),children:(0,T.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:vt(a.status),display:"inline-block",cursor:"help"}})}),(0,T.jsx)("span",{style:{fontSize:12,color:"#8c8c8c"},children:a.version})]})]}),itemActions:$,actionsStyle:"icon",actionsPosition:"hover",onItemClick:a=>c(a.id),createLabel:r("governance.list.create"),onCreateClick:e,viewModeExtensions:j,emptyIcon:(0,T.jsx)(Te,{size:48,style:{opacity:.5}}),emptyTitle:r("governance.list.emptyTitle"),emptyDescription:r("governance.list.emptyDescription")})]})};var A=I(ge());var re=I(ge());var ue=I(E()),{Text:nn}=X,Lt=({onSelect:i,value:l,placeholder:f})=>{let c=z(),u=f??c("chatConfig.parentAgent.selectPlaceholder"),[o,e]=(0,re.useState)([]),[C,r]=(0,re.useState)(!1),{get:m}=me(),S=(0,re.useCallback)(async()=>{r(!0);try{let d=await m("/api/assistants");d.success&&e(d.data?.records||[])}catch(d){console.error("Failed to fetch assistants:",d)}finally{r(!1)}},[m]);return(0,re.useEffect)(()=>{S()},[S]),(0,ue.jsx)(xe,{showSearch:!0,allowClear:!0,value:l,placeholder:u,loading:C,onChange:d=>{if(!d){i(null);return}let v=o.find(P=>P.id===d);i(v||null)},onDropdownVisibleChange:d=>{d&&S()},optionFilterProp:"label",style:{width:"100%"},options:o.map(d=>({value:d.id,label:d.name||d.id,description:d.description})),optionRender:d=>(0,ue.jsxs)("div",{children:[(0,ue.jsx)("div",{children:d.label}),d.data.description&&(0,ue.jsx)(nn,{type:"secondary",style:{fontSize:12},children:d.data.description})]})})};var L=I(E()),{Text:Nt}=X,Ot=({subAgentKeys:i,decisions:l,onChange:f})=>{let{token:c}=We.useToken(),u=z(),o=(C,r)=>{let m=l.map(S=>S.originalKey===C?{...S,clone:r,cloneKey:r?`${C}_clone`:void 0}:S);f(m)},e=(C,r)=>{let m=l.map(S=>S.originalKey===C?{...S,cloneKey:r}:S);f(m)};return i.length===0?null:(0,L.jsxs)("div",{children:[(0,L.jsx)(Nt,{type:"secondary",style:{display:"block",marginBottom:8},children:u("chatConfig.subAgentInherit.hint")}),(0,L.jsx)(Le,{size:"small",bordered:!0,dataSource:l,style:{borderRadius:c.borderRadius},renderItem:C=>(0,L.jsxs)(Le.Item,{style:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8,padding:"8px 16px"},children:[(0,L.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,L.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[C.clone?(0,L.jsx)(Pe,{style:{color:c.colorPrimary}}):(0,L.jsx)(Qe,{style:{color:c.colorTextSecondary}}),(0,L.jsx)(Nt,{style:{fontFamily:"monospace"},children:C.originalKey})]}),(0,L.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,L.jsx)(we,{color:C.clone?"blue":"default",children:C.clone?u("chatConfig.subAgentInherit.clone"):u("chatConfig.subAgentInherit.reuse")}),(0,L.jsx)($e,{size:"small",checked:C.clone,onChange:r=>o(C.originalKey,r)})]})]}),C.clone&&(0,L.jsx)(V,{size:"small",placeholder:u("chatConfig.subAgentInherit.cloneKeyPlaceholder"),value:C.cloneKey,onChange:r=>e(C.originalKey,r.target.value),style:{fontFamily:"monospace",fontSize:12},addonBefore:u("chatConfig.keyValue.key")})]})})]})};function Vt(i,l){return i.mode!=="local"||i.templateKey||typeof i.executable=="string"&&i.executable.trim().length>0?null:l?l("chat.config.executableRequired"):"Choose a template or enter a custom executable"}var n=I(E()),{TextArea:_t}=V,{Text:ne}=X,Gt="/.well-known/agent-card.json",an=[{value:"http://",label:"http://"},{value:"https://",label:"https://"}],on={react:"chatConfig.createAssistant.typeDesc.react",deep_agent:"chatConfig.createAssistant.typeDesc.deepAgent",processing:"chatConfig.createAssistant.typeDesc.processing",a2a_remote:"chatConfig.createAssistant.typeDesc.a2aRemote"};function zt(i,l,f="https://"){let c=String(i??"").trim();if(!c)return"";let u=l==="http://"||l==="https://"?l:f,e=(/^https?:\/\//i.test(c)?c:`${u}${c.replace(/^\/+/,"")}`).replace(/\/+$/,"");return e.endsWith(Gt)?e:`${e}${Gt}`}function sn(i){try{return new URL(i).port||void 0}catch{return}}function rn(i){return i.some(l=>l==="--port"||l==="-p"||/^--port=/.test(l)||/^-p=/.test(l))}function jt(i,l){let f=[...i.args],c=sn(l);return c&&!rn(f)&&f.push("--port",c),{...i,args:f,...i.env?{env:{...i.env}}:{}}}var Ut=({open:i,onCancel:l,onSuccess:f,initialMode:c,initialValues:u})=>{let[o]=R.useForm(),e=z(),[C,r]=(0,A.useState)(!1),[m,S]=(0,A.useState)("learn"),[M,H]=(0,A.useState)(""),[d,v]=(0,A.useState)(null),[P,D]=(0,A.useState)([]),$=R.useWatch("type",o)||"react",j=$==="a2a_remote",[a,g]=(0,A.useState)("remote"),[U,fe]=(0,A.useState)(void 0),[le,ye]=(0,A.useState)([]),[Se,ce]=(0,A.useState)(!1),ae=(0,A.useRef)(0),[oe,ie]=(0,A.useState)(!1),[De,Y]=(0,A.useState)(!1),{get:N,post:J,put:he}=me(),Me=Ze("agent-architect"),{workspaceId:Ce,trainingProjects:Q,loading:de}=rt(),[Ee,Ae]=(0,A.useState)(null),Ke=JSON.stringify(u??null),K=Q.find(t=>t.id===Ee)??Q[0]??null,[be,ke]=(0,A.useState)([]),p=(0,A.useCallback)(()=>{v(null),D([])},[]),b=(0,A.useCallback)(()=>{o.resetFields(),p(),S("learn"),H(""),ke([]),Ae(null),g("remote"),fe(void 0),ye([]),Y(!1),ie(!1)},[o,p]);(0,A.useEffect)(()=>{if(i){b(),S(c??"learn");let t=u?.a2aMode;(t==="remote"||t==="local")&&g(t),o.setFieldsValue({type:"react",agentCardProtocol:"https://",a2aMode:"remote",timeout:3e5,...u})}},[i,o,c,Ke,b]),(0,A.useEffect)(()=>{let t=++ae.current,s=!0;return i&&j?(o.setFieldValue("prompt",""),a==="local"?(ce(!0),N("/api/local-a2a/templates").then(k=>{s&&t===ae.current&&k?.data?.records&&ye(k.data.records)}).catch(()=>{s&&t===ae.current&&ye([])}).finally(()=>{s&&t===ae.current&&ce(!1)})):ce(!1)):ce(!1),()=>{s=!1,ae.current+=1}},[o,j,a,N,i]);let x=le.find(t=>t.key===U),q=(0,A.useCallback)(()=>{let t=Vt({mode:a,templateKey:U,executable:o.getFieldValue("commandExecutable")},e);return t?(Y(!0),o.setFields([{name:"commandExecutable",errors:[t]}]),w.warning(t),!1):!0},[a,U,o,e]);(0,A.useEffect)(()=>{x&&o.setFieldsValue({agentCardProtocol:"http://"})},[o,x]);let ve=(0,A.useCallback)(async()=>{if(!q())return;let t=zt(o.getFieldValue("agentCardUrl"),o.getFieldValue("agentCardProtocol"),a==="local"?"http://":"https://");if(!t){w.warning(e("chatConfig.createAssistant.a2aUrlWarning"));return}ie(!0);try{let s={agentCardUrl:t,apiKey:o.getFieldValue("apiKey")};if(a==="local"){let y=x;if(y)s.localRuntime={label:o.getFieldValue("name")||void 0,agentCardUrl:t,command:jt(y.command,t)};else{let B=o.getFieldValue("commandArgs")||"",G=B?B.split(/\s+/).filter(Boolean):[],F=String(o.getFieldValue(["command","cwd"])||"").trim();s.localRuntime={label:o.getFieldValue("name")||void 0,agentCardUrl:t,command:{executable:String(o.getFieldValue("commandExecutable")||"").trim(),args:G,...F?{cwd:F}:{}}}}}let k=await J("/api/a2a/test-connection",s);if(k.data?.reachable){let y=k.data.agentCard;w.success(e("chatConfig.createAssistant.connectedTo",{name:k.data.agentName||t}))}else w.error(k.data?.error||e("chatConfig.createAssistant.connectionFailed"))}catch{w.error(e("chatConfig.createAssistant.connectionTestFailed"))}finally{ie(!1)}},[o,J,a,x,q,e]),$t=(0,A.useCallback)(t=>{if(v(t),!t){o.resetFields(["key","name","description","type","prompt"]),D([]);return}let s=typeof t.graphDefinition=="object"&&t.graphDefinition!==null?t.graphDefinition:{},k=s.key||t.id,y=t.name||s.name||"";o.setFieldsValue({key:`${k}_ext`,name:y?`${y} (Extended)`:"",description:t.description||s.description||"",type:s.type||"react",prompt:s.prompt||""});let B=s.subAgents||[];D(B.map(G=>({originalKey:G,clone:!1})))},[o]),Wt=async(t,s)=>{let k=await N(`/api/assistants/${t}`);if(!k.success)throw new Error(e("chatConfig.createAssistant.cloneFetchFailed",{key:t}));let y=k.data,B=typeof y.graphDefinition=="object"?y.graphDefinition:{},G={id:s,name:`${y.name} (Clone)`,description:y.description||"",graphDefinition:{...B,key:s,name:`${y.name} (Clone)`}},F=await J("/api/assistants",G);if(!F.success)throw new Error(F.message||e("chatConfig.createAssistant.cloneFailed",{key:t}));return F.data},Zt=t=>{let s={id:t.key,name:t.name,description:t.description||"",graphDefinition:{key:t.key,name:t.name,description:t.description||"",type:t.type,prompt:t.prompt||"",tools:[],skills:[],subAgents:t.type==="deep_agent"||t.type==="processing"?[]:void 0,middleware:[]}};if(t.type==="a2a_remote"&&(s.graphDefinition.agentCardUrl=zt(t.agentCardUrl,t.agentCardProtocol,(t.a2aMode||a)==="local"?"http://":"https://"),t.apiKey&&(s.graphDefinition.apiKey=t.apiKey),t.timeout&&(s.graphDefinition.timeout=t.timeout),(t.a2aMode||a)==="local")){let k=x;if(k)s.graphDefinition.localRuntime={label:t.name||void 0,agentCardUrl:s.graphDefinition.agentCardUrl,command:jt(k.command,s.graphDefinition.agentCardUrl)};else{let y=t.commandArgs||"",B=y?y.split(/\s+/).filter(Boolean):[],G=String(t.command?.cwd||"").trim();s.graphDefinition.localRuntime={label:t.name||void 0,agentCardUrl:s.graphDefinition.agentCardUrl,command:{executable:String(t.commandExecutable||"").trim(),args:B,...G?{cwd:G}:{}}}}}return s},Yt=async(t,s)=>{if(!d)throw new Error(e("chatConfig.createAssistant.noParentAgent"));let k=P.filter(F=>F.clone);for(let F of k){if(!F.cloneKey||!F.cloneKey.trim())throw new Error(e("chatConfig.createAssistant.cloneKeyRequired",{key:F.originalKey}));if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(F.cloneKey))throw new Error(e("chatConfig.createAssistant.cloneKeyInvalid",{key:F.cloneKey,originalKey:F.originalKey}))}let y=[];for(let F of P)if(F.clone){let Xt=await Wt(F.originalKey,F.cloneKey);s.push(Xt),y.push(F.cloneKey)}else y.push(F.originalKey);let B=typeof d.graphDefinition=="object"?d.graphDefinition:{},G={key:t.key,name:t.name,description:t.description||"",extendsAgent:d.id,type:t.type||B.type};return t.prompt&&t.prompt!==B.prompt&&(G.prompt=t.prompt),(y.length>0||B.subAgents&&B.subAgents.length>0)&&(G.subAgents=y),{id:t.key,name:t.name,description:t.description||"",graphDefinition:G}},Jt=async()=>{if(m==="learn"){let t=M.trim();if(!t){w.error(e("chatConfig.createAssistant.trainingGoalRequired"));return}if(!K){w.error(e("chatConfig.createAssistant.noTrainingProject"));return}r(!0);try{let s=`agent-${It(t+Date.now())}`,k=await J("/api/assistants",{id:s,name:s,graphDefinition:{key:s,name:s,description:"",type:"react",prompt:"To be trained",metadata:{trainingProjectId:K.id,learningPlaceholder:"true",architectureStatus:"undecided"}}});if(!k.data)throw new Error(e("chatConfig.createAssistant.agentCreateFailed"));let{roundTaskId:y}=await Ft({goal:t,targetAgentId:s,workspaceId:Ce??void 0,projectId:K.id,existingThreadId:St(Me.tenantId,s),files:be,post:J,put:he});w.success(e("chatConfig.createAssistant.agentCreated")),H(""),ke([]),S("learn"),f?.(k.data,{initialMessage:Pt({goal:t,roundTaskId:y,targetAgentId:s,targetMode:"placeholder",files:be,projectId:K.id,workspaceId:K.workspaceId??Ce??void 0}),projectId:K.id,initialMessageCustomRunConfig:{execution:{taskId:y}}}),l()}catch(s){w.error(s instanceof Error?s.message:e("chatConfig.createAssistant.agentCreateFailed"))}finally{r(!1)}return}try{if(m==="scratch"&&j&&!q())return;let t=await o.validateFields();r(!0);let s=[],k=m==="scratch"?Zt(t):await Yt(t,s),y=await J("/api/assistants",k);if(y.success){w.success(m==="extend"?e("chatConfig.createAssistant.createdByExtending",{name:d?.name??""}):e("chatConfig.createAssistant.created")),b();for(let B of s)f?.(B);f?.(y.data),l()}else w.error(y.message||e("chatConfig.createAssistant.createFailed"))}catch(t){if(t?.errorFields){let s={key:e("chatConfig.createAssistant.field.key"),name:e("chatConfig.createAssistant.field.name"),description:e("chatConfig.createAssistant.field.description"),prompt:e("chatConfig.createAssistant.field.systemPrompt")},k=t.errorFields.map(y=>s[String((y.name??[])[0])]??String((y.name??[])[0])).filter(Boolean);w.warning(k.length>0?e("chatConfig.createAssistant.requiredFields",{fields:[...new Set(k)].join(", ")}):e("chatConfig.createAssistant.requiredFieldsGeneric"));return}w.error(t.message||e("chatConfig.createAssistant.createError"))}finally{r(!1)}},ze=d?.graphDefinition?.subAgents||[],Qt=m==="extend"&&d&&ze.length>0;return(0,n.jsxs)(pe,{title:e("chatConfig.createAssistant.title"),open:i,onCancel:()=>{b(),l()},footer:[(0,n.jsx)(W,{onClick:()=>{b(),l()},children:e("common.cancel")},"cancel"),(0,n.jsx)(W,{type:"primary",icon:m==="extend"?(0,n.jsx)(Pe,{}):m==="learn"?(0,n.jsx)(Je,{}):(0,n.jsx)(Xe,{}),loading:C,disabled:m==="learn"&&(de||!K),onClick:Jt,children:e(m==="extend"?"chatConfig.createAssistant.createExtend":m==="learn"?"chatConfig.createAssistant.startLearning":"common.create")},"submit")],width:760,children:[m==="extend"&&(0,n.jsxs)("div",{style:{marginBottom:20},children:[(0,n.jsx)(ne,{type:"secondary",style:{display:"block",marginBottom:8},children:e("chatConfig.createAssistant.parentAgent")}),(0,n.jsx)(Lt,{value:d?.id,onSelect:$t}),d&&(0,n.jsx)(ne,{type:"secondary",style:{display:"block",marginTop:4,fontSize:12},children:e("chatConfig.createAssistant.inheritHint")})]}),m==="extend"&&d&&(0,n.jsx)(Be,{style:{margin:"12px 0"}}),m==="learn"&&(0,n.jsxs)("div",{children:[(0,n.jsx)(ne,{style:{display:"block",marginBottom:8},children:e("chatConfig.createAssistant.learnHint")}),(0,n.jsx)(V.TextArea,{rows:3,value:M,onChange:t=>H(t.target.value),placeholder:e("chatConfig.createAssistant.learnGoalPlaceholder")}),K&&(0,n.jsxs)("div",{style:{marginTop:12},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[(0,n.jsx)(ne,{type:"secondary",children:e("chatConfig.createAssistant.referenceFiles")}),(0,n.jsx)(_e,{project:K,projects:Q,value:K?.id??null,onChange:Ae,loading:de})]}),(0,n.jsx)(Tt,{projectId:K.id,value:be,onChange:ke}),(0,n.jsx)(ne,{type:"secondary",style:{display:"block",marginTop:6,fontSize:12},children:e("chatConfig.createAssistant.referenceFilesHint")})]}),!K&&!de&&(0,n.jsx)("div",{style:{marginTop:12},children:(0,n.jsx)(_e,{project:K,projects:Q,value:null,onChange:Ae,loading:de})})]}),m!=="learn"&&(0,n.jsxs)(R,{form:o,layout:"vertical",autoComplete:"off",initialValues:{type:"react",agentCardProtocol:"https://",a2aMode:"remote"},children:[(0,n.jsx)(R.Item,{name:"key",label:e("chatConfig.createAssistant.field.key"),rules:[{required:!0,message:e("chatConfig.createAssistant.validation.keyRequired")},{pattern:/^[a-zA-Z][a-zA-Z0-9_-]*$/,message:e("chatConfig.createAssistant.validation.keyPattern")}],style:{marginBottom:16},children:(0,n.jsx)(V,{placeholder:e("chatConfig.createAssistant.keyPlaceholder")})}),(0,n.jsx)(R.Item,{name:"name",label:e("chatConfig.createAssistant.field.name"),rules:[{required:!0,message:e("chatConfig.createAssistant.validation.nameRequired")}],style:{marginBottom:16},children:(0,n.jsx)(V,{placeholder:e("chatConfig.createAssistant.namePlaceholder")})}),(0,n.jsx)(R.Item,{name:"description",label:e("chatConfig.createAssistant.field.description"),rules:[{required:!0,message:e("chatConfig.createAssistant.validation.descriptionRequired")}],style:{marginBottom:16},children:(0,n.jsx)(_t,{placeholder:e("chatConfig.createAssistant.descriptionPlaceholder"),autoSize:{minRows:2,maxRows:4}})}),(0,n.jsx)(R.Item,{name:"type",label:e("chatConfig.createAssistant.field.agentType"),rules:[{required:!0}],style:{marginBottom:16},children:(0,n.jsx)(Ue,{options:[{value:"react",label:e("chatConfig.agentType.executor")},{value:"deep_agent",label:e("chatConfig.agentType.orchestrator")},{value:"processing",label:e("chatConfig.agentType.workflow")},{value:"a2a_remote",label:e("chatConfig.agentType.a2aRemote")}],block:!0})}),(0,n.jsx)(ne,{type:"secondary",style:{fontSize:12,display:"block",marginTop:-12,marginBottom:16,lineHeight:1.5},children:e(on[$]??"chatConfig.createAssistant.typeDesc.react")}),j&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(R.Item,{label:e("chatConfig.createAssistant.field.connectionMode"),style:{marginBottom:16},children:(0,n.jsxs)(Fe.Group,{value:a,onChange:t=>{let s=t.target.value;g(s),o.setFieldValue("a2aMode",s),s==="local"&&o.setFieldValue("agentCardProtocol","http://"),fe(void 0)},optionType:"button",buttonStyle:"solid",children:[(0,n.jsx)(Fe.Button,{value:"remote",children:e("chatConfig.createAssistant.mode.remoteUrl")}),(0,n.jsx)(Fe.Button,{value:"local",children:e("chatConfig.createAssistant.mode.localManaged")})]})}),(0,n.jsx)(R.Item,{name:"a2aMode",noStyle:!0,hidden:!0,children:(0,n.jsx)(V,{})}),a==="local"&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(R.Item,{label:e("chatConfig.createAssistant.field.template"),style:{marginBottom:16},children:(0,n.jsx)(xe,{placeholder:e("chatConfig.createAssistant.templatePlaceholder"),allowClear:!0,loading:Se,value:U,onChange:t=>{fe(t),t&&Y(!1)},options:le.map(t=>({value:t.key,label:t.name||t.key})),notFoundContent:Se?void 0:(0,n.jsx)(ne,{type:"secondary",style:{padding:8,display:"block"},children:e("chatConfig.createAssistant.noTemplates")})})}),!U&&(0,n.jsx)(n.Fragment,{children:De?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(R.Item,{name:"commandExecutable",label:e("chatConfig.createAssistant.field.executable"),rules:[{required:!0,whitespace:!0,message:e("chatConfig.createAssistant.validation.executableRequired")}],style:{marginBottom:16},children:(0,n.jsx)(V,{placeholder:e("chatConfig.createAssistant.executablePlaceholder")})}),(0,n.jsx)(R.Item,{name:"commandArgs",label:e("chatConfig.createAssistant.field.arguments"),style:{marginBottom:16},children:(0,n.jsx)(V,{placeholder:e("chatConfig.createAssistant.argumentsPlaceholder")})}),(0,n.jsx)(R.Item,{name:["command","cwd"],label:e("chatConfig.createAssistant.field.workingDirectory"),style:{marginBottom:16},children:(0,n.jsx)(V,{placeholder:e("chatConfig.createAssistant.workingDirectoryPlaceholder")})}),(0,n.jsx)(W,{type:"link",onClick:()=>{Y(!1),o.setFieldsValue({commandExecutable:"",commandArgs:"",command:{cwd:void 0}})},style:{padding:0,marginBottom:16,display:"block"},children:e("chatConfig.createAssistant.hideCustomCommand")})]}):(0,n.jsx)(W,{type:"link",onClick:()=>Y(!0),style:{padding:0,marginBottom:16,display:"block"},children:e("chatConfig.createAssistant.customCommand")})})]}),(0,n.jsx)(R.Item,{label:e("chatConfig.createAssistant.field.agentCardUrl"),required:!0,style:{marginBottom:16},children:(0,n.jsxs)(He.Compact,{style:{width:"100%"},children:[(0,n.jsx)(R.Item,{name:"agentCardProtocol",noStyle:!0,children:(0,n.jsx)(xe,{style:{width:100},options:an})}),(0,n.jsx)(R.Item,{name:"agentCardUrl",noStyle:!0,rules:[{required:!0,message:e("chatConfig.createAssistant.validation.urlRequired")}],children:(0,n.jsx)(V,{placeholder:a==="local"?"localhost:4301":"host:port or full URL"})}),(0,n.jsx)(W,{icon:(0,n.jsx)(Ye,{}),onClick:ve,loading:oe,children:e("chatConfig.connection.action.test")})]})}),a==="remote"&&(0,n.jsx)(R.Item,{name:"apiKey",label:e("chatConfig.createAssistant.field.apiKeyOptional"),style:{marginBottom:16},children:(0,n.jsx)(V.Password,{placeholder:e("chatConfig.createAssistant.apiKeyPlaceholder")})}),(0,n.jsx)(R.Item,{name:"timeout",label:e("chatConfig.createAssistant.field.timeout"),style:{marginBottom:16},initialValue:3e5,children:(0,n.jsx)(qe,{min:1e3,max:36e5,style:{width:"100%"},placeholder:"300000"})})]}),!j&&(0,n.jsx)(R.Item,{name:"prompt",label:e(m==="extend"&&d?"chatConfig.createAssistant.field.systemPromptInherit":"chatConfig.createAssistant.field.systemPrompt"),rules:m==="scratch"?[{required:!0,message:e("chatConfig.createAssistant.validation.systemPromptRequired")}]:[],children:(0,n.jsx)(_t,{placeholder:e(m==="extend"&&d?"chatConfig.createAssistant.systemPromptInheritPlaceholder":"chatConfig.createAssistant.systemPromptPlaceholder"),autoSize:{minRows:4,maxRows:8},style:{fontFamily:"monospace",fontSize:13,lineHeight:1.6}})})]}),Qt&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(Be,{style:{margin:"12px 0"}}),(0,n.jsx)(ne,{strong:!0,style:{display:"block",marginBottom:8},children:e("chatConfig.createAssistant.subAgents")}),(0,n.jsx)(Ot,{subAgentKeys:ze,decisions:P,onChange:D})]})]})};var O=I(E()),{Paragraph:ln,Text:qt}=X,cn=[{key:"manual",icon:Te,titleKey:"governance.creation.manual.title",descriptionKey:"governance.creation.manual.description"},{key:"external",icon:tt,titleKey:"governance.creation.external.title",descriptionKey:"governance.creation.external.description"},{key:"learn",icon:at,titleKey:"governance.creation.learn.title",descriptionKey:"governance.creation.learn.description"}],Ht=({open:i,onCancel:l,onSelectMethod:f,focusTriggerAfterClose:c=!0})=>{let u=z();return(0,O.jsx)(pe,{title:u("governance.creation.title"),open:i,onCancel:l,footer:null,width:560,centered:!0,destroyOnHidden:!0,focusTriggerAfterClose:c,children:(0,O.jsxs)("div",{style:{padding:"8px 4px 4px"},children:[(0,O.jsx)(ln,{style:{color:"#595959",fontSize:15,margin:"8px 0 24px"},children:u("governance.creation.subtitle")}),(0,O.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:cn.map(o=>{let e=o.icon,C=u(o.titleKey);return(0,O.jsxs)(W,{type:"default",onClick:()=>f(o.key),"aria-label":C,style:{display:"flex",flexDirection:"row",alignItems:"center",gap:16,width:"100%",minHeight:88,height:"auto",padding:16,borderRadius:16,textAlign:"left",whiteSpace:"normal"},children:[(0,O.jsx)("div",{style:{width:40,height:40,borderRadius:12,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"#6366f1",background:"#eeeeff"},children:(0,O.jsx)(e,{size:19})}),(0,O.jsxs)("div",{style:{minWidth:0},children:[(0,O.jsx)(qt,{strong:!0,style:{display:"block",fontSize:15,marginBottom:3},children:C}),(0,O.jsx)(qt,{style:{color:"#737373",lineHeight:1.5},children:u(o.descriptionKey)})]})]},o.key)})}),(0,O.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,flexWrap:"wrap",marginTop:24},children:(0,O.jsx)(W,{onClick:l,children:u("governance.creation.notNow")})})]})})};var _=I(E()),dn=i=>{let l=i;if(typeof i=="string")try{l=JSON.parse(i)}catch{return{}}return l!==null&&typeof l=="object"&&!Array.isArray(l)?l:{}},ka=()=>{let{get:i,del:l,put:f}=me(),c=z(),[u,o]=(0,h.useState)([]),[e,C]=(0,h.useState)(!1),[r,m]=(0,h.useState)(null),[S,M]=(0,h.useState)("graph"),[H,d]=(0,h.useState)(null),[v,P]=(0,h.useState)(null),[D,$]=(0,h.useState)(null),[j,a]=(0,h.useState)(!1),[g,U]=(0,h.useState)(!0),[fe,le]=(0,h.useState)(!1),[ye,Se]=(0,h.useState)("learn"),[ce,ae]=(0,h.useState)({}),[oe,ie]=(0,h.useState)(null),[De,Y]=(0,h.useState)(!1),N=(0,h.useCallback)(async()=>{C(!0);try{let p=await i("/api/assistants");p.success&&p.data?.records&&o(p.data.records)}catch{w.error(c("governance.workbench.loadFailed"))}finally{C(!1)}},[i,c]);(0,h.useEffect)(()=>{N()},[N]);let J=h.default.useMemo(()=>xt(u),[u]),he=u.find(p=>p.id===r)??null,Me=(0,h.useCallback)((p,b="graph")=>{m(p),M(b),d(null),$(null)},[]),Ce=ut(),Q=(0,h.useCallback)((p,b)=>{let x=u.find(q=>q.id===p)?.name??c("governance.workbench.agentFallback");Ce({component_key:"agent_detail_side_app",data:{assistantId:p,initialTab:b},message:x})},[u,Ce,c]),de=(0,h.useCallback)(()=>{U(!0),a(!0)},[]),Ee=(0,h.useCallback)(p=>{let x={manual:{mode:"scratch",values:{}},external:{mode:"scratch",values:{type:"a2a_remote"}},learn:{mode:"learn",values:{}}}[p];Se(x.mode),ae(x.values),U(!1),a(!1),le(!0)},[]),Ae=(0,h.useCallback)(async(p,b)=>{let x=dn(p.graphDefinition),q;try{q=await f(`/api/assistants/${p.id}`,{name:b.name!==void 0?b.name:p.name,description:b.description!==void 0?b.description:p.description,graphDefinition:{...x,...b}})}catch(ve){throw w.error(c("governance.detail.saveFailed")),ve}if(!q.success)throw w.error(c("governance.detail.saveFailed")),new Error("Failed to save agent");w.success(c("common.saved")),N()},[f,N,c]),Ke=(0,h.useCallback)(p=>{o(b=>b.map(x=>x.id===p.id?p:x))},[]),K=(0,h.useCallback)(p=>{ie(p)},[]),be=(0,h.useCallback)(async()=>{if(oe){Y(!0);try{(await l(`/api/assistants/${oe}`)).success?(w.success(c("governance.detail.deleted")),o(b=>b.filter(x=>x.id!==oe)),N(),ie(null)):w.error(c("governance.detail.deleteFailed"))}catch{w.error(c("governance.detail.deleteFailed"))}finally{Y(!1)}}},[oe,l,N,c]),ke=(0,h.useCallback)(async p=>{if(!(await l(`/api/assistants/${p}`)).success)throw new Error("Failed to delete agent");w.success(c("governance.detail.deleted")),o(x=>x.filter(q=>q.id!==p)),N()},[l,N,c]);return(0,_.jsxs)("div",{style:{height:"100%",background:"#fafafa",overflow:"hidden"},children:[he?(0,_.jsx)(kt,{defaultProjectId:D??void 0,children:(0,_.jsx)(Rt,{assistant:he,allAssistants:u,onBack:()=>m(null),onDeleted:ke,onSave:Ae,onAssistantUpdated:Ke,onAgentListInvalidated:N,initialTab:S,initialMessage:H,initialMessageCustomRunConfig:v,initialProjectId:D})},he.id):(0,_.jsx)(_.Fragment,{children:(0,_.jsx)(Bt,{items:J,assistants:u,loading:e,onItemClick:p=>Q(p,"graph"),onOpenPlayground:p=>Q(p,"playground"),onOpenEval:p=>Q(p,"eval"),onCreate:de,onDelete:K})}),(0,_.jsx)(Ht,{open:j,onCancel:()=>{U(!0),a(!1)},onSelectMethod:Ee,focusTriggerAfterClose:g}),(0,_.jsx)(Ut,{open:fe,initialMode:ye,initialValues:ce,onCancel:()=>le(!1),onSuccess:(p,b)=>{le(!1),o(x=>x.some(ve=>ve.id===p.id)?x:[p,...x]),Me(p.id,"graph"),d(b?.initialMessage??null),P(b?.initialMessageCustomRunConfig??null),$(b?.projectId??null),N()}}),(0,_.jsx)(pe,{title:c("governance.deleteAgent"),open:oe!==null,onCancel:()=>ie(null),onOk:be,okText:c("common.delete"),okButtonProps:{danger:!0,loading:De},cancelText:c("common.cancel"),children:(0,_.jsx)("p",{children:c("governance.delete.irreversible")})})]})};export{ka as AgentGovernanceWorkbench};
@@ -0,0 +1,6 @@
1
+ import{c as $,d as J}from"./embed-page-chunk-FE6KYRCO.js";import{b as R,d as V,e as S}from"./embed-page-chunk-DJKD2PHO.js";import"./embed-page-chunk-S4XZPBRM.js";import{j as N,k as H,l as L,m as U,n as W,x as A,y as K,z as Y}from"./embed-page-chunk-IBRMWDHE.js";import"./embed-page-chunk-4XKCMM5C.js";import"./embed-page-chunk-PMOGSY6W.js";import"./embed-page-chunk-BSRASK7V.js";import"./embed-page-chunk-F7ZUYG42.js";import{k as w}from"./embed-page-chunk-ASEIOK7X.js";import{a as g}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-34RWKVD7.js";import{Aa as G,Oa as _,ab as z,bb as k,eb as F,t as E,y as D}from"./embed-page-chunk-B2KNZ3EW.js";import{Za as P,_ as T,ha as B}from"./embed-page-chunk-F7TA3LRH.js";import{a as b}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f}from"./embed-page-chunk-QBTAJ2YI.js";var n=f(b());var I=f(b());var o=f(g());var ae="tracePulse 1.4s ease-in-out infinite",le={running:(0,o.jsx)(G,{style:{color:"#1890ff"}}),success:(0,o.jsx)(E,{style:{color:"#52c41a"}}),error:(0,o.jsx)(D,{style:{color:"#ff4d4f"}})};function de({kind:e}){switch(e){case"human":return(0,o.jsx)(F,{});case"agent":return(0,o.jsx)(z,{});case"tool":return(0,o.jsx)(k,{});case"ai":return(0,o.jsx)(_,{});default:return(0,o.jsx)(k,{})}}var M=I.default.createContext({}),ce=()=>I.default.useContext(M),pe=({data:e,selected:i})=>{let l=w(),{onJumpToMessage:t}=ce(),s=e.isAnswer===!0,a=e.status==="running",p=(e.parallelCount??1)>1,m=!!(t&&e.messageId&&!e.messageId.startsWith("summary:")),v=e.toolCall?L(e.toolCall.name):e.label,y=()=>{if((e.kind==="tool"||e.kind==="agent")&&e.toolCall){let h=U(e.toolCall.response);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(H,{data:{name:e.toolCall.name,parameters:e.toolCall.args,type:"tool_call"},component_key:`${e.toolCall.id}-params`,interactive:!1}),h&&(0,o.jsx)("div",{style:{marginTop:8},children:(0,o.jsx)(N,{content:h})}),(0,o.jsx)(W,{ui:e.toolCall.ui})]})}return e.content?(0,o.jsx)(N,{content:e.content}):(0,o.jsx)("span",{style:{color:"#8c8c8c"},children:e.label})};return(0,o.jsxs)("div",{"data-testid":"trace-card",style:{height:"100%",display:"flex",flexDirection:"column",border:`1px solid ${s||i?"#6366f1":a?"#91caff":"#e5e7eb"}`,borderRadius:12,background:s?"#eef2ff":"#fff",boxShadow:a?"0 0 0 2px rgba(24,144,255,0.18)":i?"0 0 0 2px rgba(99,102,241,0.2)":"none",animation:a?ae:void 0,overflow:"hidden",fontSize:13},children:[(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:"1px solid #f0f0f0",background:"rgba(0,0,0,0.02)"},children:[(0,o.jsx)(de,{kind:e.kind}),(0,o.jsx)("span",{style:{fontWeight:s?700:600,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v}),p&&(0,o.jsx)(P,{color:"purple",style:{marginInlineEnd:0,fontSize:10},children:l("chat.trace.parallelBadge",{count:e.parallelCount??1})}),le[e.status],m&&(0,o.jsx)(T,{type:"text",size:"small",onClick:()=>t?.(e.messageId),children:l("chat.trace.jumpToChat")})]}),(0,o.jsx)("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:12},children:y()})]})},fe=({data:e,selected:i})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(S,{type:"target",position:R.Top}),(0,o.jsx)(pe,{data:e,selected:i}),(0,o.jsx)(S,{type:"source",position:R.Bottom})]}),j={trace:fe};var Z=f(b());var u=f(g()),ue={running:"#1890ff",success:"#52c41a",error:"#ff4d4f"},q=({graph:e,activeNodeId:i,onSelectNode:l})=>{let t=Z.default.useMemo(()=>new Map(e.nodes.map(s=>[s.id,s])),[e.nodes]);return(0,u.jsx)("div",{"data-testid":"trace-overview-rail",style:{display:"flex",flexDirection:"column",gap:10,width:160,padding:8,overflowY:"auto",borderRight:"1px solid #f0f0f0"},children:e.phases.map(s=>(0,u.jsxs)("div",{"data-testid":"trace-rail-phase",children:[(0,u.jsx)("div",{style:{fontSize:12,color:"#8c8c8c",marginBottom:4},children:s.title}),(0,u.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:s.nodeIds.map(a=>{let p=t.get(a);if(!p)return null;let m=a===i;return(0,u.jsx)(B,{title:p.data.label,children:(0,u.jsx)("button",{type:"button","data-testid":"trace-rail-tick",onClick:()=>l?.(a),style:{width:m?12:8,height:m?12:8,borderRadius:"50%",border:"none",padding:0,cursor:"pointer",background:ue[p.data.status],outline:m?"2px solid #6366f1":"none"}})},a)})})]},s.id))})};var d=f(g()),Q=3,X=()=>{},me=`
2
+ @keyframes tracePulse {
3
+ 0%, 100% { box-shadow: 0 0 0 2px rgba(24,144,255,0.18); }
4
+ 50% { box-shadow: 0 0 0 6px rgba(24,144,255,0.05); }
5
+ }
6
+ `;function ge(e){let i=e.nodes.map(t=>({id:t.id,...A[t.data.kind]})),l=e.edges.map(t=>({from:t.from,to:t.to}));return $(i,l,{nodesep:48,ranksep:80,rankdir:"TB"})}function ye({focusNodeId:e,follow:i}){let l=V();return(0,n.useEffect)(()=>{if(!i||!e)return;let t=l.getNode(e);if(!t)return;let s=t.style?.width??0,a=t.style?.height??0;l.setCenter(t.position.x+s/2,t.position.y+a/2,{zoom:1,duration:300})},[e,i,l]),null}var _e=({messages:e,isLoading:i,onJumpToMessage:l})=>{let t=w(),[s,a]=(0,n.useState)(),[p,m]=(0,n.useState)(!1),[v,y]=(0,n.useState)(!0),h=(0,n.useDeferredValue)(e),x=(0,n.useMemo)(()=>K(h,{isLoading:i,t}),[h,i,t]),c=(0,n.useMemo)(()=>p?x:Y(x,Q,t),[x,p,t]),ee=(0,n.useMemo)(()=>`${c.nodes.map(r=>r.id).join(",")}|${c.edges.map(r=>r.id).join(",")}`,[c]),O=(0,n.useMemo)(()=>ge(c),[ee]),oe=(0,n.useMemo)(()=>c.nodes.map(r=>{let C=A[r.data.kind];return{id:r.id,type:"trace",position:O.get(r.id)??{x:0,y:0},data:r.data,draggable:!1,style:{width:C.width,height:C.height}}}),[c,O]),te=(0,n.useMemo)(()=>c.edges.map(r=>({id:r.id,source:r.from,target:r.to,animated:r.kind==="invoke",style:{stroke:r.kind==="invoke"?"#6366f1":r.kind==="result"?"#a5b4fc":"#d9d9d9"}})),[c]),re=c.nodes[c.nodes.length-1]?.id,ne=s??re,se=x.phases.length>Q,ie=(0,n.useMemo)(()=>({onJumpToMessage:l}),[l]);return(0,d.jsxs)(M.Provider,{value:ie,children:[(0,d.jsx)("style",{children:me}),(0,d.jsxs)("div",{style:{display:"flex",height:"100%",minHeight:0,width:"100%",overflow:"hidden"},children:[(0,d.jsx)(q,{graph:c,activeNodeId:s,onSelectNode:a}),(0,d.jsxs)("div",{style:{flex:1,minWidth:0,minHeight:0,display:"flex",flexDirection:"column"},children:[(0,d.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:4,padding:"4px 8px"},children:[!v&&(0,d.jsx)(T,{size:"small",type:"text",onClick:()=>{a(void 0),y(!0)},children:t("chat.trace.backToCurrent")}),se&&(0,d.jsx)(T,{size:"small",type:"text",onClick:()=>m(r=>!r),children:t(p?"chat.trace.collapseOlder":"chat.trace.expandAll")})]}),(0,d.jsx)("div",{style:{flex:1,minHeight:0},children:(0,d.jsx)(J,{nodes:oe,edges:te,nodeTypes:j,onNodesChange:X,onEdgesChange:X,nodesDraggable:!1,nodesConnectable:!1,fitView:!0,miniMap:{pannable:!0,zoomable:!0},onMoveStart:()=>y(!1),onNodeClick:(r,C)=>{a(C.id),y(!0)},children:(0,d.jsx)(ye,{focusNodeId:ne,follow:v})})})]})]})]})};export{_e as MessageGraph};
@@ -1 +1 @@
1
- import{s as D}from"./embed-page-chunk-UDSGGVJH.js";import{i as E}from"./embed-page-chunk-CFFDP526.js";import"./embed-page-chunk-4XKCMM5C.js";import"./embed-page-chunk-PMOGSY6W.js";import{a as T}from"./embed-page-chunk-BSRASK7V.js";import"./embed-page-chunk-F7ZUYG42.js";import{k as v}from"./embed-page-chunk-ASEIOK7X.js";import{a as C}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-34RWKVD7.js";import"./embed-page-chunk-B2KNZ3EW.js";import{qa as x}from"./embed-page-chunk-F7TA3LRH.js";import{a as w}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as p}from"./embed-page-chunk-QBTAJ2YI.js";var u=p(w());var R=p(T());var y=p(C());function g(l,i){if(!l||l.length===0)return{title:{text:i("genui.chart.title"),left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical"},xAxis:{type:"category",data:[]},yAxis:{type:"value"},series:[{type:"line",name:i("genui.chart.seriesDefault",{n:1}),data:[]}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}};let s=l[0],t=Object.keys(s);if(t.length===0)return g([],i);let r=t.filter(e=>{let n=s[e];return typeof n=="number"||!isNaN(Number(n))});if(r.length>0){let e=r[0],n=t.find(a=>!r.includes(a))||t[0],o=l.map((a,c)=>a[n]!==void 0?String(a[n]):i("genui.chart.itemDefault",{n:c+1})),f=l.map(a=>{let c=a[e];return typeof c=="number"?c:Number(c)||0});return{title:{text:i("genui.chart.title"),left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical",data:[e]},xAxis:{type:"category",data:o},yAxis:{type:"value"},series:[{type:"line",name:e,data:f}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}}}return{title:{text:i("genui.chart.title"),left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical"},xAxis:{type:"category",data:l.map((e,n)=>i("genui.chart.itemDefault",{n:n+1}))},yAxis:{type:"value"},series:[{type:"bar",name:i("genui.chart.countSeries"),data:l.map(()=>1)}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}}}function j(l,i){if(!l||typeof l!="object"||!l.series||!Array.isArray(l.series)||l.series.length===0)return null;let s=l.series.map((e,n)=>{if(!e||typeof e!="object"||!e.type||!e.data||!Array.isArray(e.data)||e.data.length===0)return null;let o={...e,name:e.name||i("genui.chart.seriesDefault",{n:n+1})};if(e.type==="pie"){let f=e.data.map((a,c)=>typeof a=="object"&&a!==null&&"value"in a?{value:a.value,name:a.name||i("genui.chart.itemDefault",{n:c+1})}:typeof a=="number"?{value:a,name:i("genui.chart.itemDefault",{n:c+1})}:null).filter(a=>a!==null);return f.length===0?null:{...o,data:f}}return o}).filter(e=>e!==null);if(s.length===0)return null;let t={...l,series:s},r=s[0].type;if(r!=="pie"){if(!t.xAxis)t.xAxis={type:"category",data:[]};else if(typeof t.xAxis=="object"&&!Array.isArray(t.xAxis)){let e=t.xAxis;if(e.type||(e.type="category"),e.type==="category"&&!e.data){let n=s[0].data;Array.isArray(n)&&n.length>0?Array.isArray(n[0])?e.data=n.map(o=>o[0]):e.data=n.map((o,f)=>i("genui.chart.itemDefault",{n:f+1})):e.data=[]}t.xAxis=e}t.yAxis?typeof t.yAxis=="object"&&!Array.isArray(t.yAxis)&&(t.yAxis.type||(t.yAxis.type="value")):t.yAxis={type:"value"}}if(!t.title)t.title={text:i("genui.chart.title"),left:"left"};else if(typeof t.title=="object"){let e=t.title;e.left||(e.left="left"),e.text||(e.text=i("genui.chart.title")),t.title=e}if(t.tooltip||(t.tooltip={trigger:r==="pie"?"item":"axis"}),!t.legend)s.length>1&&(t.legend={right:0,orient:"vertical"});else if(typeof t.legend=="object"){let e=t.legend;t.legend=e}return r!=="pie"&&!t.grid&&(t.grid={left:"3%",right:"4%",bottom:"3%",containLabel:!0}),t}function O(l,i){let s=null;try{let n=typeof l=="string"?l:l.join("");s=(0,R.parse)(n)}catch(n){return{data:null,error:`Failed to parse JSON: ${n instanceof Error?n.message:String(n)}`}}if(!s||typeof s!="object")return{data:null,error:"Parsed data is not an object"};let t=s.series&&Array.isArray(s.series)&&s.series.length>0,r={table:Array.isArray(s.table)?s.table:void 0},e=null;if(s.echarts?e=s.echarts:t&&(e=s),e){let n=j(e,i);if(n)r.echarts=n;else if(r.table&&r.table.length>0)r.echarts=g(r.table,i);else return{data:null,error:"ECharts configuration is invalid or incomplete. Required: series array with at least one series containing type and data."}}else r.table&&r.table.length>0?r.echarts=g(r.table,i):r.echarts=g([],i);return{data:r,error:null}}var K=l=>{let{children:i}=l,s=v(),t=(0,u.useRef)(null),r=(0,u.useRef)(null),e=(0,u.useRef)(null),[n,o]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(!t.current)return;r.current||(r.current=D(t.current));let a=null;if((typeof i=="string"||Array.isArray(i))&&(a=i),!a){r.current&&r.current.clear(),o(null);return}let{data:c,error:m}=O(a,s);if(m||!c){console.warn("ReactChart failed to parse chart data:",m||"Unknown parse error"),r.current&&r.current.clear(),o(null);return}if(c.table&&Array.isArray(c.table)&&o(c.table),c.echarts)try{r.current.setOption(c.echarts,!0)}catch(d){let A=d instanceof Error?d.message:"Failed to render chart";console.error("Failed to set ECharts option:",d),r.current&&r.current.clear(),o(null)}let h=()=>{r.current&&r.current.resize()};return e.current&&(e.current.disconnect(),e.current=null),t.current&&typeof ResizeObserver<"u"&&(e.current=new ResizeObserver(d=>{requestAnimationFrame(()=>{h()})}),e.current.observe(t.current)),window.addEventListener("resize",h),()=>{e.current&&(e.current.disconnect(),e.current=null),window.removeEventListener("resize",h)}},[i,s]),(0,u.useEffect)(()=>()=>{e.current&&(e.current.disconnect(),e.current=null),r.current&&(r.current.dispose(),r.current=null)},[]);let f=a=>{if(!a||a.length===0)return[];if(Array.isArray(a[0])){let c=a[0];return a.slice(1).map((h,d)=>{let A={};return h.forEach((S,b)=>{A[c[b]||`col_${b}`]=S}),A})}return a};return(0,y.jsxs)(x,{children:[(0,y.jsx)("div",{ref:t,style:{width:"100%",height:"400px",minHeight:"300px"}}),n&&n.length>0&&(0,y.jsx)("div",{style:{marginTop:16},children:(0,y.jsx)(E,{component_key:"chart_table_data",data:{dataSource:f(n),message:s("genui.chart.dataDetails")},interactive:!0,default_open_in_side_app:!0})})]})};export{K as ReactChart};
1
+ import{s as D}from"./embed-page-chunk-UDSGGVJH.js";import{i as E}from"./embed-page-chunk-IBRMWDHE.js";import"./embed-page-chunk-4XKCMM5C.js";import"./embed-page-chunk-PMOGSY6W.js";import{a as T}from"./embed-page-chunk-BSRASK7V.js";import"./embed-page-chunk-F7ZUYG42.js";import{k as v}from"./embed-page-chunk-ASEIOK7X.js";import{a as C}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-34RWKVD7.js";import"./embed-page-chunk-B2KNZ3EW.js";import{qa as x}from"./embed-page-chunk-F7TA3LRH.js";import{a as w}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as p}from"./embed-page-chunk-QBTAJ2YI.js";var u=p(w());var R=p(T());var y=p(C());function g(l,i){if(!l||l.length===0)return{title:{text:i("genui.chart.title"),left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical"},xAxis:{type:"category",data:[]},yAxis:{type:"value"},series:[{type:"line",name:i("genui.chart.seriesDefault",{n:1}),data:[]}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}};let s=l[0],t=Object.keys(s);if(t.length===0)return g([],i);let r=t.filter(e=>{let n=s[e];return typeof n=="number"||!isNaN(Number(n))});if(r.length>0){let e=r[0],n=t.find(a=>!r.includes(a))||t[0],o=l.map((a,c)=>a[n]!==void 0?String(a[n]):i("genui.chart.itemDefault",{n:c+1})),f=l.map(a=>{let c=a[e];return typeof c=="number"?c:Number(c)||0});return{title:{text:i("genui.chart.title"),left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical",data:[e]},xAxis:{type:"category",data:o},yAxis:{type:"value"},series:[{type:"line",name:e,data:f}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}}}return{title:{text:i("genui.chart.title"),left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical"},xAxis:{type:"category",data:l.map((e,n)=>i("genui.chart.itemDefault",{n:n+1}))},yAxis:{type:"value"},series:[{type:"bar",name:i("genui.chart.countSeries"),data:l.map(()=>1)}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}}}function j(l,i){if(!l||typeof l!="object"||!l.series||!Array.isArray(l.series)||l.series.length===0)return null;let s=l.series.map((e,n)=>{if(!e||typeof e!="object"||!e.type||!e.data||!Array.isArray(e.data)||e.data.length===0)return null;let o={...e,name:e.name||i("genui.chart.seriesDefault",{n:n+1})};if(e.type==="pie"){let f=e.data.map((a,c)=>typeof a=="object"&&a!==null&&"value"in a?{value:a.value,name:a.name||i("genui.chart.itemDefault",{n:c+1})}:typeof a=="number"?{value:a,name:i("genui.chart.itemDefault",{n:c+1})}:null).filter(a=>a!==null);return f.length===0?null:{...o,data:f}}return o}).filter(e=>e!==null);if(s.length===0)return null;let t={...l,series:s},r=s[0].type;if(r!=="pie"){if(!t.xAxis)t.xAxis={type:"category",data:[]};else if(typeof t.xAxis=="object"&&!Array.isArray(t.xAxis)){let e=t.xAxis;if(e.type||(e.type="category"),e.type==="category"&&!e.data){let n=s[0].data;Array.isArray(n)&&n.length>0?Array.isArray(n[0])?e.data=n.map(o=>o[0]):e.data=n.map((o,f)=>i("genui.chart.itemDefault",{n:f+1})):e.data=[]}t.xAxis=e}t.yAxis?typeof t.yAxis=="object"&&!Array.isArray(t.yAxis)&&(t.yAxis.type||(t.yAxis.type="value")):t.yAxis={type:"value"}}if(!t.title)t.title={text:i("genui.chart.title"),left:"left"};else if(typeof t.title=="object"){let e=t.title;e.left||(e.left="left"),e.text||(e.text=i("genui.chart.title")),t.title=e}if(t.tooltip||(t.tooltip={trigger:r==="pie"?"item":"axis"}),!t.legend)s.length>1&&(t.legend={right:0,orient:"vertical"});else if(typeof t.legend=="object"){let e=t.legend;t.legend=e}return r!=="pie"&&!t.grid&&(t.grid={left:"3%",right:"4%",bottom:"3%",containLabel:!0}),t}function O(l,i){let s=null;try{let n=typeof l=="string"?l:l.join("");s=(0,R.parse)(n)}catch(n){return{data:null,error:`Failed to parse JSON: ${n instanceof Error?n.message:String(n)}`}}if(!s||typeof s!="object")return{data:null,error:"Parsed data is not an object"};let t=s.series&&Array.isArray(s.series)&&s.series.length>0,r={table:Array.isArray(s.table)?s.table:void 0},e=null;if(s.echarts?e=s.echarts:t&&(e=s),e){let n=j(e,i);if(n)r.echarts=n;else if(r.table&&r.table.length>0)r.echarts=g(r.table,i);else return{data:null,error:"ECharts configuration is invalid or incomplete. Required: series array with at least one series containing type and data."}}else r.table&&r.table.length>0?r.echarts=g(r.table,i):r.echarts=g([],i);return{data:r,error:null}}var K=l=>{let{children:i}=l,s=v(),t=(0,u.useRef)(null),r=(0,u.useRef)(null),e=(0,u.useRef)(null),[n,o]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(!t.current)return;r.current||(r.current=D(t.current));let a=null;if((typeof i=="string"||Array.isArray(i))&&(a=i),!a){r.current&&r.current.clear(),o(null);return}let{data:c,error:m}=O(a,s);if(m||!c){console.warn("ReactChart failed to parse chart data:",m||"Unknown parse error"),r.current&&r.current.clear(),o(null);return}if(c.table&&Array.isArray(c.table)&&o(c.table),c.echarts)try{r.current.setOption(c.echarts,!0)}catch(d){let A=d instanceof Error?d.message:"Failed to render chart";console.error("Failed to set ECharts option:",d),r.current&&r.current.clear(),o(null)}let h=()=>{r.current&&r.current.resize()};return e.current&&(e.current.disconnect(),e.current=null),t.current&&typeof ResizeObserver<"u"&&(e.current=new ResizeObserver(d=>{requestAnimationFrame(()=>{h()})}),e.current.observe(t.current)),window.addEventListener("resize",h),()=>{e.current&&(e.current.disconnect(),e.current=null),window.removeEventListener("resize",h)}},[i,s]),(0,u.useEffect)(()=>()=>{e.current&&(e.current.disconnect(),e.current=null),r.current&&(r.current.dispose(),r.current=null)},[]);let f=a=>{if(!a||a.length===0)return[];if(Array.isArray(a[0])){let c=a[0];return a.slice(1).map((h,d)=>{let A={};return h.forEach((S,b)=>{A[c[b]||`col_${b}`]=S}),A})}return a};return(0,y.jsxs)(x,{children:[(0,y.jsx)("div",{ref:t,style:{width:"100%",height:"400px",minHeight:"300px"}}),n&&n.length>0&&(0,y.jsx)("div",{style:{marginTop:16},children:(0,y.jsx)(E,{component_key:"chart_table_data",data:{dataSource:f(n),message:s("genui.chart.dataDetails")},interactive:!0,default_open_in_side_app:!0})})]})};export{K as ReactChart};
@@ -1,4 +1,4 @@
1
- import{a as Ze}from"./embed-page-chunk-EM6VGUZ2.js";import{c as qe,d as Ke}from"./embed-page-chunk-GSUSX54K.js";import{b as Ne,e as Ie,h as He,i as We}from"./embed-page-chunk-DJKD2PHO.js";import"./embed-page-chunk-S4XZPBRM.js";import{C as Ve,D as Ue,E as ue,F as Re,G as Ye,H as Qe,I as Je,K as Xe,L as et,M as tt,N as ot,r as Ge}from"./embed-page-chunk-CFFDP526.js";import{g as q,i as _e}from"./embed-page-chunk-4XKCMM5C.js";import"./embed-page-chunk-PMOGSY6W.js";import{l as Ee,o as Oe}from"./embed-page-chunk-BSRASK7V.js";import{I as Fe,Qa as me,n as ce,ya as pe}from"./embed-page-chunk-F7ZUYG42.js";import{k as j}from"./embed-page-chunk-ASEIOK7X.js";import{a as A}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-34RWKVD7.js";import"./embed-page-chunk-B2KNZ3EW.js";import{Da as W,Ia as Ce,Ja as J,Ma as ze,Sa as le,Za as Me,_ as ae,aa as Be,ba as Le,bb as de,fa as be,va as De}from"./embed-page-chunk-F7TA3LRH.js";import{a as se}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as T}from"./embed-page-chunk-QBTAJ2YI.js";var n=T(se());var it=T(se());var s=T(A()),Tt=[{key:"pending",color:"#7A7A7A"},{key:"in_progress",color:"#3b82f6"},{key:"failed",color:"#ef4444"},{key:"interrupted",color:"#8b5cf6"},{key:"completed",color:"#22c55e"}],rt={high:"#ef4444",medium:"#f59e0b",low:"#22c55e"};function bt(e){return e==="high"||e==="low"?e:"medium"}function Ct(e,i){let f=typeof e=="string"?new Date(e):e,a=new Date().getTime()-f.getTime(),k=Math.floor(a/1e3),o=Math.floor(k/60),r=Math.floor(o/60),l=Math.floor(r/24);return k<60?i("common.time.justNow"):o<60?i("common.time.minutesAgo",{count:o}):r<24?i("common.time.hoursAgo",{count:r}):l<30?i("common.time.daysAgo",{count:l}):f.toLocaleDateString(i.locale)}var Nt=q(({css:e,token:i})=>({container:e`
1
+ import{a as Ze}from"./embed-page-chunk-IELKCYQX.js";import{c as qe,d as Ke}from"./embed-page-chunk-FE6KYRCO.js";import{b as Ne,e as Ie,h as He,i as We}from"./embed-page-chunk-DJKD2PHO.js";import"./embed-page-chunk-S4XZPBRM.js";import{C as Ve,D as Ue,E as ue,F as Re,G as Ye,H as Qe,I as Je,K as Xe,L as et,M as tt,N as ot,r as Ge}from"./embed-page-chunk-IBRMWDHE.js";import{g as q,i as _e}from"./embed-page-chunk-4XKCMM5C.js";import"./embed-page-chunk-PMOGSY6W.js";import{l as Ee,o as Oe}from"./embed-page-chunk-BSRASK7V.js";import{I as Fe,Qa as me,n as ce,ya as pe}from"./embed-page-chunk-F7ZUYG42.js";import{k as j}from"./embed-page-chunk-ASEIOK7X.js";import{a as A}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-34RWKVD7.js";import"./embed-page-chunk-B2KNZ3EW.js";import{Da as W,Ia as Ce,Ja as J,Ma as ze,Sa as le,Za as Me,_ as ae,aa as Be,ba as Le,bb as de,fa as be,va as De}from"./embed-page-chunk-F7TA3LRH.js";import{a as se}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as T}from"./embed-page-chunk-QBTAJ2YI.js";var n=T(se());var it=T(se());var s=T(A()),Tt=[{key:"pending",color:"#7A7A7A"},{key:"in_progress",color:"#3b82f6"},{key:"failed",color:"#ef4444"},{key:"interrupted",color:"#8b5cf6"},{key:"completed",color:"#22c55e"}],rt={high:"#ef4444",medium:"#f59e0b",low:"#22c55e"};function bt(e){return e==="high"||e==="low"?e:"medium"}function Ct(e,i){let f=typeof e=="string"?new Date(e):e,a=new Date().getTime()-f.getTime(),k=Math.floor(a/1e3),o=Math.floor(k/60),r=Math.floor(o/60),l=Math.floor(r/24);return k<60?i("common.time.justNow"):o<60?i("common.time.minutesAgo",{count:o}):r<24?i("common.time.hoursAgo",{count:r}):l<30?i("common.time.daysAgo",{count:l}):f.toLocaleDateString(i.locale)}var Nt=q(({css:e,token:i})=>({container:e`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  height: 100%;
@@ -1,4 +1,4 @@
1
- import{a as ue,c as fe}from"./embed-page-chunk-G5MXFDNZ.js";import{a as xe}from"./embed-page-chunk-GSUSX54K.js";import{a as ie,b as G,e as V,f as U,g as re,h as se,i as ae,k as le,l as de,m as ce,n as pe}from"./embed-page-chunk-DJKD2PHO.js";import"./embed-page-chunk-S4XZPBRM.js";import{j as O}from"./embed-page-chunk-CFFDP526.js";import"./embed-page-chunk-4XKCMM5C.js";import{a as j}from"./embed-page-chunk-PMOGSY6W.js";import"./embed-page-chunk-BSRASK7V.js";import{A as oe,E as $,Pa as ne,g as te,ma as H,y as L}from"./embed-page-chunk-F7ZUYG42.js";import{k as N}from"./embed-page-chunk-ASEIOK7X.js";import{a as D}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-34RWKVD7.js";import{G as Q,Ma as ee}from"./embed-page-chunk-B2KNZ3EW.js";import{Ja as M,Ka as K,Oa as Z,Sa as X,Za as I,ba as P,bb as q,ha as B,ya as J,za as F}from"./embed-page-chunk-F7TA3LRH.js";import{a as Y}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as T}from"./embed-page-chunk-QBTAJ2YI.js";var s=T(Y());var _=T(xe());var ge=T(Y());var ye=T(D()),me=({steps:t,graphDefinition:o,assistantId:r})=>{let n=(0,ge.useMemo)(()=>fe(o),[o]);return(0,ye.jsx)(ue,{dsl:n,steps:t,assistantId:r})};var e=T(D()),ve=`
1
+ import{a as ue,c as fe}from"./embed-page-chunk-PROZXFWS.js";import{a as xe}from"./embed-page-chunk-FE6KYRCO.js";import{a as ie,b as G,e as V,f as U,g as re,h as se,i as ae,k as le,l as de,m as ce,n as pe}from"./embed-page-chunk-DJKD2PHO.js";import"./embed-page-chunk-S4XZPBRM.js";import{j as O}from"./embed-page-chunk-IBRMWDHE.js";import"./embed-page-chunk-4XKCMM5C.js";import{a as j}from"./embed-page-chunk-PMOGSY6W.js";import"./embed-page-chunk-BSRASK7V.js";import{A as oe,E as $,Pa as ne,g as te,ma as H,y as L}from"./embed-page-chunk-F7ZUYG42.js";import{k as N}from"./embed-page-chunk-ASEIOK7X.js";import{a as D}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-34RWKVD7.js";import{G as Q,Ma as ee}from"./embed-page-chunk-B2KNZ3EW.js";import{Ja as M,Ka as K,Oa as Z,Sa as X,Za as I,ba as P,bb as q,ha as B,ya as J,za as F}from"./embed-page-chunk-F7TA3LRH.js";import{a as Y}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as T}from"./embed-page-chunk-QBTAJ2YI.js";var s=T(Y());var _=T(xe());var ge=T(Y());var ye=T(D()),me=({steps:t,graphDefinition:o,assistantId:r})=>{let n=(0,ge.useMemo)(()=>fe(o),[o]);return(0,ye.jsx)(ue,{dsl:n,steps:t,assistantId:r})};var e=T(D()),ve=`
2
2
  @keyframes spin {
3
3
  from { transform: rotate(0deg); }
4
4
  to { transform: rotate(360deg); }
@@ -1,3 +1,3 @@
1
- import{a as $e,b as Ge}from"./embed-page-chunk-BZKAPY7M.js";import{b as Ue,c as be}from"./embed-page-chunk-G5MXFDNZ.js";import"./embed-page-chunk-GSUSX54K.js";import{f as Ye}from"./embed-page-chunk-DJKD2PHO.js";import"./embed-page-chunk-S4XZPBRM.js";import{S as Ke,j as He}from"./embed-page-chunk-CFFDP526.js";import{i as ee}from"./embed-page-chunk-4XKCMM5C.js";import{a as te}from"./embed-page-chunk-PMOGSY6W.js";import"./embed-page-chunk-BSRASK7V.js";import{Ea as q,Ha as ue,I as ce,Ja as Ne,O as pe,Ra as me,Sa as Z,Ta as qe,Y as je,_ as ge,aa as fe,fa as Ee,ia as _e,l as Oe,na as Fe,o as de,t as Pe,za as Be}from"./embed-page-chunk-F7ZUYG42.js";import{k as P}from"./embed-page-chunk-ASEIOK7X.js";import{a as E}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-34RWKVD7.js";import{Ba as De,G as Te,Ja as le,Ra as Le,sa as Me}from"./embed-page-chunk-B2KNZ3EW.js";import{Da as X,Ia as J,Ja as ae,Ma as V,Oa as Ae,_ as $,ba as G,bb as Q,ha as U,qa as Ie}from"./embed-page-chunk-F7TA3LRH.js";import{a as se}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as A}from"./embed-page-chunk-QBTAJ2YI.js";var i=A(se());var oe=A(se());var j=A(E());function gt(r){let n=r.split(/[\n\r.。;;!!??]+/).filter(Boolean)[0]?.trim()||"";return n=n.replace(/[,,]+$/,"").trim(),n.length>50&&(n=n.slice(0,50)),n||(n=r.slice(0,50).trim()),n}function ft(r){let t=5381;for(let n=0;n<r.length;n++)t=(t<<5)+t+r.charCodeAt(n)>>>0;return t.toString(36).slice(0,6)}var we=({open:r,onCancel:t,onCreated:n,type:f="processing"})=>{let{post:D}=te(),l=P(),{trainingProjects:u,loading:w}=ee(),[g,m]=(0,oe.useState)(null),[y]=X.useForm(),b=u.find(h=>h.id===g)??u[0]??null;(0,oe.useEffect)(()=>{r&&(y.resetFields(),m(null))},[r,y]);let S=async()=>{if(f==="workflow"&&!b)return;let k=((await y.validateFields()).purpose||"").trim(),z=gt(k),I=`wf-${ft(k+Date.now())}`,p=f==="workflow"?{key:I,name:z,description:k,type:"workflow",prompt:"Complete the assigned task accurately and concisely.",metadata:{trainingProjectId:b?.id},workflowYaml:`name: ${I}
1
+ import{a as $e,b as Ge}from"./embed-page-chunk-JTL73EBV.js";import{b as Ue,c as be}from"./embed-page-chunk-PROZXFWS.js";import"./embed-page-chunk-FE6KYRCO.js";import{f as Ye}from"./embed-page-chunk-DJKD2PHO.js";import"./embed-page-chunk-S4XZPBRM.js";import{S as Ke,j as He}from"./embed-page-chunk-IBRMWDHE.js";import{i as ee}from"./embed-page-chunk-4XKCMM5C.js";import{a as te}from"./embed-page-chunk-PMOGSY6W.js";import"./embed-page-chunk-BSRASK7V.js";import{Ea as q,Ha as ue,I as ce,Ja as Ne,O as pe,Ra as me,Sa as Z,Ta as qe,Y as je,_ as ge,aa as fe,fa as Ee,ia as _e,l as Oe,na as Fe,o as de,t as Pe,za as Be}from"./embed-page-chunk-F7ZUYG42.js";import{k as P}from"./embed-page-chunk-ASEIOK7X.js";import{a as E}from"./embed-page-chunk-QV7QAJ4N.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-34RWKVD7.js";import{Ba as De,G as Te,Ja as le,Ra as Le,sa as Me}from"./embed-page-chunk-B2KNZ3EW.js";import{Da as X,Ia as J,Ja as ae,Ma as V,Oa as Ae,_ as $,ba as G,bb as Q,ha as U,qa as Ie}from"./embed-page-chunk-F7TA3LRH.js";import{a as se}from"./embed-page-chunk-R5QL57JJ.js";import"./embed-page-chunk-QOWM3LMZ.js";import"./embed-page-chunk-EUOOO2LS.js";import"./embed-page-chunk-5JDQ456X.js";import{f as A}from"./embed-page-chunk-QBTAJ2YI.js";var i=A(se());var oe=A(se());var j=A(E());function gt(r){let n=r.split(/[\n\r.。;;!!??]+/).filter(Boolean)[0]?.trim()||"";return n=n.replace(/[,,]+$/,"").trim(),n.length>50&&(n=n.slice(0,50)),n||(n=r.slice(0,50).trim()),n}function ft(r){let t=5381;for(let n=0;n<r.length;n++)t=(t<<5)+t+r.charCodeAt(n)>>>0;return t.toString(36).slice(0,6)}var we=({open:r,onCancel:t,onCreated:n,type:f="processing"})=>{let{post:D}=te(),l=P(),{trainingProjects:u,loading:w}=ee(),[g,m]=(0,oe.useState)(null),[y]=X.useForm(),b=u.find(h=>h.id===g)??u[0]??null;(0,oe.useEffect)(()=>{r&&(y.resetFields(),m(null))},[r,y]);let S=async()=>{if(f==="workflow"&&!b)return;let k=((await y.validateFields()).purpose||"").trim(),z=gt(k),I=`wf-${ft(k+Date.now())}`,p=f==="workflow"?{key:I,name:z,description:k,type:"workflow",prompt:"Complete the assigned task accurately and concisely.",metadata:{trainingProjectId:b?.id},workflowYaml:`name: ${I}
2
2
  steps: []
3
3
  `}:{key:I,name:z,description:k,type:"processing",prompt:`You are the orchestrator for workflow "${z}". Purpose: ${k}. Follow the topology to delegate tasks to sub-agents.`,tools:[],skills:[],subAgents:[],middleware:[{id:"topology",type:"topology",name:l("chatConfig.workflow.middleware.topologyName"),description:l("chatConfig.workflow.middleware.topologyDescription"),enabled:!0,config:{edges:[]}}]};await D("/api/assistants",{id:I,name:z,description:k,graphDefinition:p}),y.resetFields(),n(I,k,f==="workflow"?b?.id:void 0)};return(0,j.jsx)(V,{title:l(f==="workflow"?"chatConfig.workflow.create.title":"chatConfig.workflow.create.titleProcessing"),open:r,onCancel:t,onOk:S,okText:l("common.create"),okButtonProps:{disabled:f==="workflow"&&(w||!b)},destroyOnClose:!0,children:(0,j.jsxs)(X,{form:y,layout:"vertical",initialValues:{purpose:""},children:[(0,j.jsx)(X.Item,{name:"purpose",label:l("chatConfig.workflow.field.purpose"),rules:[{required:!0,message:l("chatConfig.workflow.validation.purposeRequired")}],children:(0,j.jsx)(J.TextArea,{placeholder:l("chatConfig.workflow.field.purposePlaceholder"),rows:4})}),f==="workflow"&&(0,j.jsx)($e,{project:b,projects:u,value:b?.id??null,onChange:m,loading:w})]})})};var Ve=A(se());var e=A(E()),{Text:ye}=Q;function ut(r){if(!r||typeof r!="object")return null;let t=r;return{modelKey:t.modelKey||t.model||void 0,tools:Array.isArray(t.tools)?t.tools:[],middleware:Array.isArray(t.middleware)?t.middleware.filter(n=>n&&typeof n=="object"&&n.type):[],subAgents:Array.isArray(t.subAgents)?t.subAgents:[],skillCategories:Array.isArray(t.skillCategories)?t.skillCategories:[],runConfig:t.runConfig&&typeof t.runConfig=="object"?t.runConfig:void 0}}var mt={filesystem:(0,e.jsx)(je,{size:12}),code_eval:(0,e.jsx)(Ne,{size:12}),browser:(0,e.jsx)(fe,{size:12}),sql:(0,e.jsx)(pe,{size:12}),skill:(0,e.jsx)(ue,{size:12}),http:(0,e.jsx)(_e,{size:12}),scheduler:(0,e.jsx)(ce,{size:12}),metrics:(0,e.jsx)(Oe,{size:12}),topology:(0,e.jsx)(ge,{size:12}),ask_user_to_clarify:(0,e.jsx)(Fe,{size:12}),widget:(0,e.jsx)(de,{size:12}),date:(0,e.jsx)(Pe,{size:12}),task:(0,e.jsx)(ge,{size:12}),custom:(0,e.jsx)(Be,{size:12}),claw:(0,e.jsx)(q,{size:12}),collection:(0,e.jsx)(Ee,{size:12})},bt={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)"}},wt={bg:"rgba(107,114,128,0.08)",text:"#4b5563",border:"rgba(107,114,128,0.2)"};function yt(r){let t=r.split(/[_-]+/).filter(Boolean);return t.length===1?t[0].slice(0,2).toUpperCase():t.map(n=>n[0]).join("").toUpperCase().slice(0,2)}var Xe=[{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 Je(r){return Xe[r%Xe.length]}var H=({icon:r,label:t,count:n,children:f})=>(0,e.jsxs)("div",{style:{marginBottom:10},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[(0,e.jsx)("span",{style:{color:"#6366f1",display:"flex",alignItems:"center"},children:r}),(0,e.jsx)(ye,{strong:!0,style:{fontSize:11,color:"#52525b",textTransform:"uppercase",letterSpacing:"0.3px"},children:t}),(0,e.jsx)("span",{style:{fontSize:9,fontWeight:600,color:"#a1a1aa",background:"rgba(0,0,0,0.04)",borderRadius:8,padding:"1px 6px",lineHeight:"16px"},children:n})]}),f]}),Qe=({graphDef:r})=>{let t=P(),n=(0,Ve.useMemo)(()=>ut(r),[r]);if(!n)return null;let f=n.middleware.filter(l=>l.enabled!==!1),D=!1;return n.tools.length===0&&f.length===0&&n.subAgents.length===0?null:(0,e.jsx)("div",{style:{pointerEvents:"auto"},children:(0,e.jsxs)("div",{style:{background:"rgba(255,255,255,0.5)",borderRadius:8,width:250,transition:"all 0.25s ease",overflow:"hidden"},children:[(0,e.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,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,e.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,e.jsx)(q,{size:13})}),(0,e.jsx)(ye,{strong:!0,style:{fontSize:12,color:"#1a1a1a"},children:t("chat.environment.title")})]})}),(0,e.jsxs)("div",{style:{padding:"10px 12px 12px",maxHeight:"calc(60vh - 48px)",overflowY:"auto"},children:[n.tools.length>0&&(0,e.jsx)(H,{icon:(0,e.jsx)(qe,{size:12}),label:t("chat.environment.tools"),count:n.tools.length,children:(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:n.tools.map((l,u)=>{let w=Je(u);return(0,e.jsx)(U,{title:l,placement:"top",children:(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:w.text,background:w.bg,cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[(0,e.jsx)("span",{style:{fontWeight:700,fontSize:9,opacity:.7},children:yt(l)}),(0,e.jsx)("span",{children:l})]})},l)})})}),f.length>0&&(0,e.jsx)(H,{icon:(0,e.jsx)(de,{size:12}),label:t("chat.environment.capabilities"),count:f.length,children:(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:f.map(l=>{let u=bt[l.type]||wt,w=mt[l.type]||(0,e.jsx)(q,{size:12});return(0,e.jsx)(U,{title:l.name||l.type,placement:"top",children:(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:u.text,background:u.bg,border:`1px solid ${u.border}`,cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[w,(0,e.jsx)("span",{children:l.name||l.type})]})},l.type)})})}),n.subAgents.length>0&&(0,e.jsx)(H,{icon:(0,e.jsx)(me,{size:12}),label:t("chat.environment.subAgents"),count:n.subAgents.length,children:(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:n.subAgents.map((l,u)=>{let w=Je(u+3);return(0,e.jsx)(U,{title:l,placement:"top",children:(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:w.text,background:w.bg,cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[(0,e.jsx)(me,{size:10}),(0,e.jsx)("span",{children:l})]})},l)})})}),(n.modelKey||n.runConfig)&&(0,e.jsx)(H,{icon:(0,e.jsx)(ce,{size:12}),label:t("chat.environment.runtime"),count:n.modelKey?1:0,children:(0,e.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[n.modelKey&&(0,e.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,e.jsx)(q,{size:10}),(0,e.jsx)("span",{children:t("chat.environment.model",{model:n.modelKey})})]}),!!n.runConfig?.databaseKey&&(0,e.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,e.jsx)(pe,{size:10}),(0,e.jsx)("span",{children:t("chat.environment.db",{db:String(n.runConfig?.databaseKey)})})]}),n.skillCategories&&n.skillCategories.length>0&&(0,e.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,e.jsx)(ue,{size:10}),(0,e.jsx)("span",{children:t("chat.environment.skills",{skills:n.skillCategories.join(", ")})})]})]})}),D&&(0,e.jsx)(H,{icon:(0,e.jsx)(fe,{size:12}),label:t("chat.environment.channels"),count:0,children:(0,e.jsx)(ye,{type:"secondary",style:{fontSize:10,fontStyle:"italic"},children:t("chat.environment.noChannels")})})]})]})})};var o=A(E()),{Text:Y}=Q,ht=300;function Ze(r){if(typeof r=="string")try{let t=JSON.parse(r);return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}return r&&typeof r=="object"&&!Array.isArray(r)?r:null}function kt(r){let t=null;if(typeof r=="string")try{t=JSON.parse(r)}catch{return null}else r&&typeof r=="object"&&(t=r);if(!t)return null;if(t.type!=="workflow")return console.warn("[extractDSL] type is not 'workflow':",t.type),null;if(typeof t.workflowYaml!="string")return console.warn("[extractDSL] workflowYaml not found or not a string, keys:",Object.keys(t)),null;try{return be(t.workflowYaml)}catch(n){return console.error("[extractDSL] expandWorkflow failed:",n.message,n),null}}function xt({workflows:r,selectedId:t,onSelect:n,onCreate:f,onDelete:D,dsl:l,agentNameMap:u,onSpecClick:w,environmentConfig:g}){let m=P(),y=r.find(p=>p.id===t),[b,S]=(0,i.useState)(!0),[h,k]=(0,i.useState)(""),z=(0,i.useMemo)(()=>{let p=h.trim().toLowerCase();return p?r.filter(x=>x.name.toLowerCase().includes(p)||x.description.toLowerCase().includes(p)):r},[r,h]);(0,i.useEffect)(()=>{t?S(!1):(S(!0),k(""))},[t]);let I=p=>{n(p),S(!1)};return(0,o.jsx)("div",{style:{display:"flex",height:"100%",width:"100%"},children:(0,o.jsxs)("div",{style:{flex:1,position:"relative"},children:[y?(0,o.jsxs)(o.Fragment,{children:[l?(0,o.jsx)(Ue,{dsl:l,agentNameMap:u}):(0,o.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,o.jsx)(ae,{tip:m("chatWorkspace.workflowAutomation.loadingDsl")})}),!b&&(0,o.jsx)("div",{style:{position:"absolute",top:12,left:12,zIndex:10},children:(0,o.jsx)($,{type:"default",icon:(0,o.jsx)(De,{}),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,o.jsxs)("div",{style:{position:"absolute",top:12,left:b?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,o.jsx)(Z,{size:16,color:"#6366f1"}),(0,o.jsx)(Y,{strong:!0,style:{fontSize:13},children:y.name}),(0,o.jsx)(Me,{style:{color:"#6366f1",cursor:"pointer",fontSize:15},onClick:w})]}),(0,o.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,o.jsx)(Ae,{title:m("chatWorkspace.workflowAutomation.deleteTitle"),description:m("chatWorkspace.workflowAutomation.deleteBody"),onConfirm:()=>D(y.id),okText:m("common.delete"),cancelText:m("common.cancel"),okButtonProps:{danger:!0},children:(0,o.jsx)(Te,{style:{color:"#ff4d4f",cursor:"pointer",fontSize:15}})})}),!b&&(0,o.jsx)("div",{style:{position:"absolute",top:52,left:b?12:56,zIndex:20},children:(0,o.jsx)(Qe,{graphDef:g},y.id)})]}):(0,o.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,o.jsx)(G,{description:m("chatWorkspace.workflowAutomation.selectWorkflow")})}),b&&(0,o.jsxs)(o.Fragment,{children:[t&&(0,o.jsx)("div",{onClick:()=>S(!1),style:{position:"absolute",inset:0,zIndex:25,background:"transparent"}}),(0,o.jsxs)(Ie,{size:"small",title:(0,o.jsx)(Y,{strong:!0,style:{fontSize:15,color:"#1a1a1a"},children:m("chatWorkspace.workflowAutomation.title")}),extra:(0,o.jsx)($,{type:"text",size:"small",icon:(0,o.jsx)(le,{}),onClick:f,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:t?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,o.jsx)("div",{style:{marginBottom:12},children:(0,o.jsx)(J,{prefix:(0,o.jsx)(Le,{style:{color:"#bbb"}}),placeholder:m("chatWorkspace.workflowAutomation.filterPlaceholder"),value:h,onChange:p=>k(p.target.value),allowClear:!0,size:"small",style:{borderRadius:10,border:"1px solid rgba(0,0,0,0.06)"}})}),z.length===0?(0,o.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px 16px",color:"#bbb"},children:[(0,o.jsx)(Z,{size:28,style:{marginBottom:10,opacity:.4}}),(0,o.jsx)(Y,{type:"secondary",style:{fontSize:13},children:h.trim()?m("chatWorkspace.workflowAutomation.noMatch"):m("chatWorkspace.workflowAutomation.emptyTitle")})]}):z.map(p=>{let x=t===p.id;return(0,o.jsxs)("div",{onClick:()=>I(p.id),style:{display:"flex",alignItems:"center",gap:12,padding:"13px 15px",borderRadius:12,cursor:"pointer",transition:"all 0.2s ease",background:x?"rgba(99, 102, 241, 0.07)":"rgba(255, 255, 255, 0.5)",border:x?"1px solid rgba(99, 102, 241, 0.25)":"1px solid transparent",marginBottom:6},onMouseEnter:R=>{x||(R.currentTarget.style.background="rgba(255, 255, 255, 0.92)",R.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.05)",R.currentTarget.style.transform="translateY(-1px)",R.currentTarget.style.borderColor="rgba(0,0,0,0.06)")},onMouseLeave:R=>{x||(R.currentTarget.style.background="rgba(255, 255, 255, 0.5)",R.currentTarget.style.boxShadow="none",R.currentTarget.style.transform="translateY(0)",R.currentTarget.style.borderColor="transparent")},children:[(0,o.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:38,height:38,borderRadius:10,background:x?"rgba(99, 102, 241, 0.12)":"rgba(0, 0, 0, 0.04)",flexShrink:0,transition:"background 0.2s ease"},children:(0,o.jsx)(Z,{size:18,color:x?"#6366f1":"#888"})}),(0,o.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,o.jsx)(Y,{strong:!0,ellipsis:{tooltip:p.name},style:{fontSize:14,color:x?"#6366f1":"#1a1a1a",transition:"color 0.2s ease"},children:p.name}),p.description&&(0,o.jsx)("div",{style:{fontSize:12,color:"#999",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:3,lineHeight:"18px"},children:p.description})]})]},p.id)})]})]})]})})}var vt=()=>{let r=P(),{get:t,del:n}=te(),{workspaceId:f,trainingProjects:D,loading:l}=ee(),[u,w]=(0,i.useState)([]),[g,m]=(0,i.useState)(null),[y,b]=(0,i.useState)(null),[S,h]=(0,i.useState)(null),[k,z]=(0,i.useState)([]),[I,p]=(0,i.useState)(new Map),x=(0,i.useCallback)(async()=>{try{let s=await t("/api/assistants");if(s.success&&s.data?.records){let c=[],a=new Map;for(let d of s.data.records){if(d.id&&d.name){let v=typeof d.graphDefinition=="object"&&d.graphDefinition!==null?d.graphDefinition:void 0;a.set(d.id,{name:d.name,type:v?.type??"unknown"})}if(d.graphDefinition)if(typeof d.graphDefinition=="string")try{c.push(JSON.parse(d.graphDefinition))}catch{}else typeof d.graphDefinition=="object"&&c.push(d.graphDefinition)}z(c),p(a)}}catch{}},[t]),[R,he]=(0,i.useState)(!0),[ne,et]=(0,i.useState)(420),_=(0,i.useRef)(null),[tt,ot]=(0,i.useState)(!0),[ke,xe]=(0,i.useState)(null),[nt,ve]=(0,i.useState)(!1),[Ce,F]=(0,i.useState)(!1),[rt,Se]=(0,i.useState)(null),it=(0,i.useMemo)(()=>["create_workflow","update_workflow","validate_workflow","create_agent","update_agent","delete_agent"],[]),T=(0,i.useCallback)(async()=>{let s=await t("/api/assistants");if(s.success&&s.data?.records){let c=s.data.records.filter(a=>(Ze(a.graphDefinition)??void 0)?.type==="workflow").map(a=>{let d=Ze(a.graphDefinition)??void 0,v=typeof d?.workflowYaml=="string"?d.workflowYaml:"",B=d?.metadata,N=0;try{N=be(v).nodes.filter(W=>W.type!=="terminal").length}catch{}return{id:a.id,name:a.name,description:a.description||"",type:"workflow",stepCount:N,trainingProjectId:typeof B?.trainingProjectId=="string"?B.trainingProjectId:void 0}});w(c)}xe(null)},[t]),K=(0,i.useCallback)(async s=>{try{let c=await t(`/api/assistants/${s}`);if(c.success&&c.data){let a=c.data.graphDefinition,d=kt(a);if(b(d),!a)h(null);else if(typeof a=="string")try{h(JSON.parse(a))}catch{h(null)}else h(typeof a=="object"?a:null)}}catch{b(null),h(null)}},[t]);(0,i.useEffect)(()=>{let s=!1;return(async()=>{try{await T(),await x()}catch(a){s||xe(a instanceof Error?a.message:r("chatWorkspace.workflowAutomation.loadFailed"))}finally{s||ot(!1)}})(),()=>{s=!0}},[T]),(0,i.useEffect)(()=>{g?K(g):b(null)},[g,K]);let st=(0,i.useCallback)(s=>{s.preventDefault(),_.current={startX:s.clientX,startWidth:ne}},[ne]);(0,i.useEffect)(()=>{let s=a=>{if(!_.current)return;let d=_.current.startX-a.clientX,v=Math.min(900,Math.max(400,_.current.startWidth+d));et(v)},c=()=>{_.current=null};return window.addEventListener("mousemove",s),window.addEventListener("mouseup",c),()=>{window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",c)}},[]);let L=(0,i.useRef)(null),Re=(0,i.useRef)({fetchWorkflows:T,fetchDSL:K});Re.current={fetchWorkflows:T,fetchDSL:K};let We=(0,i.useRef)(g);We.current=g;let at=(0,i.useCallback)(()=>{L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{L.current=null;let{fetchWorkflows:s,fetchDSL:c}=Re.current;s().catch(d=>{console.warn("Failed to refresh workflows:",d)});let a=We.current;a&&c(a).catch(d=>{console.warn("Failed to refresh workflow DSL:",d)})},ht)},[]);(0,i.useEffect)(()=>()=>{L.current&&(clearTimeout(L.current),L.current=null)},[]);let lt=(0,i.useCallback)(s=>{m(s)},[]),ze=(0,i.useCallback)((s,c,a)=>{F(!1),T().then(()=>{m(s),a&&w(d=>d.map(v=>v.id===s?{...v,trainingProjectId:a}:v)),c&&Se({requestId:s,content:c})})},[T]),dt=(0,i.useCallback)(async s=>{await n(`/api/assistants/${s}`),g===s&&m(null),await T()},[n,T,g]),O=(0,i.useMemo)(()=>u.find(s=>s.id===g)||null,[u,g]),re=O?.trainingProjectId??D[0]?.id??null,ct=(0,i.useMemo)(()=>g&&O?{id:g,name:O.name,type:"workflow"}:null,[g,O]),pt=(0,i.useMemo)(()=>{let s=y?.nodes.filter(C=>C.type!=="terminal"&&C.ref).map(C=>C.ref).filter((C,W,M)=>M.indexOf(C)===W)??[];if(s.length===0)return S;let c=k.filter(C=>{let W=C.key;return W&&s.includes(W)});if(c.length===0)return S;let a={...S??{}},d=new Set(a.tools??[]),v=[...a.middleware??[]],B=new Set(a.subAgents??[]),N=new Set(v.map(C=>C.type).filter(Boolean));for(let C of c){let W=C;for(let M of W.tools??[])d.add(M);for(let M of W.middleware??[]){let ie=M.type;ie&&!N.has(ie)&&(v.push(M),N.add(ie))}for(let M of W.subAgents??[])B.add(M)}return a.tools=Array.from(d),a.middleware=v,a.subAgents=Array.from(B),a},[y,S,k]);return tt?(0,o.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,o.jsx)(ae,{size:"large",tip:r("chatWorkspace.workflowAutomation.loading")})}):ke?(0,o.jsx)(G,{description:ke}):u.length===0?(0,o.jsxs)("div",{style:{width:"100%",height:"100%"},children:[(0,o.jsx)(we,{open:Ce,onCancel:()=>F(!1),onCreated:ze,type:"workflow"}),(0,o.jsx)(G,{description:r("chatWorkspace.workflowAutomation.noDefinitions"),children:(0,o.jsx)($,{type:"primary",icon:(0,o.jsx)(le,{}),onClick:()=>F(!0),children:r("chatWorkspace.workflowAutomation.createWorkflow")})})]}):(0,o.jsxs)("div",{style:{width:"100%",height:"100%"},children:[(0,o.jsx)(we,{open:Ce,onCancel:()=>F(!1),onCreated:ze,type:"workflow"}),(0,o.jsx)(V,{title:O?.name,open:nt,onCancel:()=>ve(!1),footer:null,width:"85vw",centered:!0,styles:{body:{maxHeight:"calc(85vh - 120px)",overflow:"auto",padding:"12px 24px 24px"}},children:O?.description?(0,o.jsx)(He,{content:O.description}):(0,o.jsx)(Y,{type:"secondary",children:r("chatWorkspace.workflowAutomation.noDescription")})}),(0,o.jsx)(Ye,{children:(0,o.jsxs)("div",{style:{height:"100%",width:"100%",position:"relative",overflow:"hidden"},children:[(0,o.jsx)(xt,{workflows:u,selectedId:g,onSelect:lt,onCreate:()=>F(!0),onDelete:dt,dsl:y,agentNameMap:I,onSpecClick:()=>ve(!0),environmentConfig:pt}),!R&&g&&(0,o.jsx)("div",{style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",zIndex:20},children:(0,o.jsx)("div",{onClick:()=>he(!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:r("chatWorkspace.workflowAutomation.copilot")})}),R&&g&&re&&!l&&(0,o.jsxs)("div",{style:{position:"absolute",right:16,top:48,bottom:12,zIndex:15,width:ne,borderRadius:16,overflow:"hidden",boxShadow:"0 4px 24px rgba(0,0,0,0.12)"},children:[(0,o.jsx)("div",{onMouseDown:st,style:{position:"absolute",left:0,top:0,bottom:0,width:6,cursor:"ew-resize",zIndex:2,background:"transparent"}}),(0,o.jsx)(Ke,{defaultWorkspaceId:f??void 0,defaultProjectId:re??void 0,children:(0,o.jsx)(Ge,{workflowContext:ct,onClose:()=>he(!1),onToolCompleted:s=>{it.includes(s)&&at()},initialMessageRequest:rt,onInitialMessageSubmitted:s=>Se(c=>c?.requestId===s?null:c)})},`${f??"default"}:${re??"default"}`)]})]})})]})},Qt=vt;export{vt as WorkflowAutomationView,Qt as default};