@axiom-lattice/gateway 4.5.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/embed/{embed-page-AgentDetailSideApp-I4ZT3MQQ.js → embed-page-AgentDetailSideApp-7NYLPLAX.js} +1 -1
- package/dist/embed/{embed-page-AgentGovernanceWorkbench-HVFB6EPY.js → embed-page-AgentGovernanceWorkbench-LNGNSI7X.js} +2 -2
- package/dist/embed/{embed-page-MessageGraph-CZQROEO7.js → embed-page-MessageGraph-E6DZDT65.js} +1 -1
- package/dist/embed/{embed-page-ReactChart-WMWBSL54.js → embed-page-ReactChart-3VE7F5VJ.js} +1 -1
- package/dist/embed/{embed-page-SkillFlow-5JLJ5R57.js → embed-page-SkillFlow-XMMHEHQL.js} +1 -1
- package/dist/embed/{embed-page-TasksSideApp-5BYTO4KT.js → embed-page-TasksSideApp-QM5TZ7EG.js} +1 -1
- package/dist/embed/{embed-page-TeamWorkspace-5KN7ZZWQ.js → embed-page-TeamWorkspace-E7RFY3ZY.js} +1 -1
- package/dist/embed/{embed-page-TopologyRuntimeView-S6XAQHDF.js → embed-page-TopologyRuntimeView-DLPDUB7Z.js} +1 -1
- package/dist/embed/{embed-page-WorkflowAutomationView-E6G446HW.js → embed-page-WorkflowAutomationView-FKSVOHHB.js} +1 -1
- package/dist/embed/embed-page-chunk-EXCJ42IB.js +2 -0
- package/dist/embed/{embed-page-chunk-MUE3GWJV.js → embed-page-chunk-H6TK3FAR.js} +1 -1
- package/dist/embed/{embed-page-chunk-QU52HUXW.js → embed-page-chunk-HEMNMC4X.js} +4 -4
- package/dist/embed/{embed-page-chunk-2JOGNXZT.js → embed-page-chunk-I7PWCKAG.js} +9 -9
- package/dist/embed/{embed-page-chunk-KDWA6VOG.js → embed-page-chunk-KN7D66KL.js} +1 -1
- package/dist/embed/{embed-page-chunk-7GAD6Q52.js → embed-page-chunk-U276WBDI.js} +2078 -2078
- package/dist/embed/{embed-page-chunk-YQ3BA27D.js → embed-page-chunk-WWTU55RX.js} +1 -1
- package/dist/embed/embed-page.js +1 -1
- package/dist/index.js +1830 -644
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1335 -147
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/dist/embed/embed-page-chunk-DSQ4DIQY.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as C}from"./embed-page-chunk-
|
|
1
|
+
import{l as C}from"./embed-page-chunk-I7PWCKAG.js";import"./embed-page-chunk-H6TK3FAR.js";import"./embed-page-chunk-KN7D66KL.js";import"./embed-page-chunk-WWTU55RX.js";import"./embed-page-chunk-KEL6XU6R.js";import"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-EXCJ42IB.js";import{Fa as T,rb as B}from"./embed-page-chunk-U276WBDI.js";import{r as P}from"./embed-page-chunk-HEMNMC4X.js";import{a as I}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{U as c,W as p,oa as D,va as b,xa as l}from"./embed-page-chunk-O4QK5LWZ.js";import{a as U}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as u}from"./embed-page-chunk-6Y3UYJ6Z.js";var e=u(U());var t=u(I()),G={component_key:"workspace_assistants",data:{},message:"Assistants"},N=r=>{let i=r;if(typeof r=="string")try{i=JSON.parse(r)}catch{return{}}return i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{}},H=({data:r})=>{let{assistantId:i,initialTab:F}=r??{},{get:m,put:f,del:A}=P(),y=T(),[g,w]=(0,e.useState)(null),[R,h]=(0,e.useState)([]),[E,v]=(0,e.useState)(!1),[L,S]=(0,e.useState)(null),d=(0,e.useCallback)(()=>{y(G)},[y]),a=(0,e.useCallback)(async()=>{v(!0),S(null);try{let s=(await m("/api/assistants")).data?.records??[];h(s),w(s.find(o=>o.id===i)??null)}catch{S("Failed to load agent")}finally{v(!1)}},[m,i]);(0,e.useEffect)(()=>{i&&a()},[a,i]);let _=(0,e.useCallback)(async(n,s)=>{let o=N(n.graphDefinition),k;try{k=await f(`/api/assistants/${n.id}`,{name:s.name!==void 0?s.name:n.name,description:s.description!==void 0?s.description:n.description,graphDefinition:{...o,...s}})}catch(z){throw l.error("Failed to save agent"),z}if(!k.success)throw l.error("Failed to save agent"),new Error("Failed to save agent");l.success("Saved"),await a()},[f,a]),j=(0,e.useCallback)(n=>{w(s=>s&&s.id===n.id?n:s),h(s=>s.map(o=>o.id===n.id?n:o))},[]),x=(0,e.useCallback)(async n=>{if(!(await A(`/api/assistants/${n}`)).success)throw new Error("Failed to delete agent");l.success("Agent deleted"),d()},[A,d]);return i?g?(0,t.jsx)("div",{style:{height:"100%",overflow:"auto"},children:(0,t.jsx)(B,{children:(0,t.jsx)(C,{assistant:g,allAssistants:R,onBack:d,onDeleted:x,onSave:_,onAssistantUpdated:j,onAgentListInvalidated:()=>void a(),initialTab:F})},g.id)}):E?(0,t.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,t.jsx)(b,{})}):L?(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(c,{type:"error",showIcon:!0,message:"Failed to load agent","data-testid":"detail-error",action:(0,t.jsxs)(D,{children:[(0,t.jsx)(p,{size:"small",onClick:()=>void a(),children:"Retry"}),(0,t.jsx)(p,{size:"small",type:"primary",onClick:d,children:"Back to list"})]})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(c,{type:"warning",showIcon:!0,message:"Agent not found","data-testid":"detail-not-found",action:(0,t.jsx)(p,{size:"small",type:"primary",onClick:d,children:"Back to list"})})}):(0,t.jsx)("div",{style:{padding:24},children:(0,t.jsx)(c,{type:"warning",showIcon:!0,message:"Missing agent id","data-testid":"detail-missing-id"})})};export{H as AgentDetailSideApp};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as Re,b as Ne,c as Dt,d as Rt,e as Pt,f as Ft,g as Mt,h as Et,i as Nt,j as Lt,k as Bt,l as Ot}from"./embed-page-chunk-
|
|
1
|
+
import{a as Re,b as Ne,c as Dt,d as Rt,e as Pt,f as Ft,g as Mt,h as Et,i as Nt,j as Lt,k as Bt,l as Ot}from"./embed-page-chunk-I7PWCKAG.js";import"./embed-page-chunk-H6TK3FAR.js";import{a as Ue}from"./embed-page-chunk-KN7D66KL.js";import"./embed-page-chunk-WWTU55RX.js";import"./embed-page-chunk-KEL6XU6R.js";import{b as Ge,e as ze,f as xt,g as wt,h as vt,i as kt,l as St,m as It}from"./embed-page-chunk-AC6X2XRH.js";import{a as ft,b as yt,c as ht,d as bt,e as At}from"./embed-page-chunk-SV2BM3WO.js";import"./embed-page-chunk-S4XZPBRM.js";import"./embed-page-chunk-EXCJ42IB.js";import{$ as dt,Ea as ut,Fa as Ct,G as st,J as it,P as lt,Qa as Ve,da as ct,k as De,oa as pt,rb as Tt,va as mt,w as rt,wa as gt}from"./embed-page-chunk-U276WBDI.js";import{m as et,r as ye}from"./embed-page-chunk-HEMNMC4X.js";import{a as M}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Db as nt,Fa as Qe,Ia as Te,Ja as Xe,La as X,Ua as tt,W as J,_ as Se,aa as Ie,ac as Ee,ea as Me,ka as Ke,la as Ze,ma as Je,mc as at,oa as Ye,ra as R,ta as V,wa as _e,xa as v,ya as fe,yc as ot}from"./embed-page-chunk-O4QK5LWZ.js";import{a as ue}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as x}from"./embed-page-chunk-6Y3UYJ6Z.js";var u=x(ue());var te=x(ue());var Y=x(ue());var $t=x(ue());var ie=x(M()),Kt=60,_t=72,je=(0,$t.memo)(({data:n})=>{let r=Re(n.type),p=Math.min(12+Math.sqrt(n.subAgentCount)*10,48);return(0,ie.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[(0,ie.jsx)(ze,{type:"target",position:Ge.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:0,height:0},isConnectable:!1}),(0,ie.jsx)("div",{title:n.label,style:{width:p,height:p,borderRadius:"50%",background:Ne(r.color),display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:Math.max(10,p*.4),fontWeight:600,cursor:"pointer",boxShadow:"0 2px 8px rgba(0,0,0,0.15)"},children:n.label.charAt(0).toUpperCase()}),(0,ie.jsx)("div",{style:{fontSize:11,maxWidth:120,textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:4},children:n.label}),(0,ie.jsx)(ze,{type:"source",position:Ge.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:0,height:0},isConnectable:!1})]})});je.displayName="AgentGraphNode";var ee=x(M()),sn=({assistants:n,onNodeClick:r})=>{let[p,l,g]=vt([]),[o,f,k]=kt([]),[d,S]=(0,Y.useState)(null),H=(0,Y.useMemo)(()=>({agent:je}),[]),m=(0,Y.useMemo)(()=>Pt(n),[n]);(0,Y.useEffect)(()=>{let w=m.nodes.map(i=>({id:i.id})),P=m.edges.map(i=>({source:i.source,target:i.target})),N=new Map(m.nodes.map(i=>[i.id,i])),z=bt(w).force("link",ht(P).id(i=>i.id).distance(80)).force("charge",At().strength(-220)).force("center",ft(0,0)).force("collide",yt(45)).stop();for(let i=0;i<300;i++)z.tick();let F=w.map(i=>({id:i.id,type:"agent",data:N.get(i.id),position:{x:i.x-Kt/2,y:i.y-_t/2}})),s=m.edges.map(i=>({id:`e${i.source}-${i.target}`,source:i.source,target:i.target,style:{stroke:"#1677ff",strokeWidth:2},type:"straight"}));l(F),f(s)},[m,l,f]);let T=(0,Y.useMemo)(()=>d===null?p:p.map(w=>{let P=w.id===d||o.some(N=>N.source===d&&N.target===w.id||N.target===d&&N.source===w.id);return{...w,style:{opacity:P?1:.2,transition:"opacity 0.2s ease"}}}),[p,o,d]),K=(0,Y.useMemo)(()=>d===null?o.map(w=>({...w,style:{stroke:"#1677ff",strokeWidth:1.5,opacity:.25,transition:"opacity 0.2s ease"}})):o.map(w=>{let P=w.source===d||w.target===d;return{...w,style:{stroke:"#1677ff",strokeWidth:P?2.5:1,opacity:P?1:.04,transition:"opacity 0.2s ease"}}}),[o,d]);return(0,ee.jsx)("div",{style:{width:"100%",height:"100%",background:"#fafafa",position:"relative"},children:(0,ee.jsxs)(wt,{nodes:T,edges:K,onNodesChange:g,onEdgesChange:k,onNodeMouseEnter:(w,P)=>S(P.id),onNodeMouseLeave:()=>S(null),onNodeClick:(w,P)=>r?.(String(P.id)),nodeTypes:H,fitView:!0,fitViewOptions:{padding:.25},children:[(0,ee.jsx)(St,{color:"#eee",gap:20}),(0,ee.jsx)(It,{})]})})},Vt=n=>(0,ee.jsx)(xt,{children:(0,ee.jsx)(sn,{...n})});var E=x(M()),ln=n=>{if(!n)return"\u2014";let r=Date.now()-new Date(n).getTime(),p=Math.floor(r/6e4);if(p<1)return"just now";if(p<60)return`${p}m ago`;let l=Math.floor(p/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`},dn=n=>n===null?"#d9d9d9":n>=80?"#22c55e":n>=50?"#f59e0b":"#ef4444",cn=mt(({css:n})=>({row:n`
|
|
2
2
|
display: flex;
|
|
3
3
|
justify-content: space-between;
|
|
4
4
|
align-items: flex-end;
|
|
5
|
-
`})),Gt={fontSize:16,fontWeight:700,lineHeight:1.2,cursor:"help"},He={fontSize:10,color:"rgba(0, 0, 0, 0.45)",whiteSpace:"nowrap",marginTop:1},We={display:"flex",flexDirection:"column",alignItems:"center"},zt=({stats:n})=>{let{styles:r}=cn();if(!n)return(0,E.jsxs)("div",{style:{display:"flex",fontSize:11,color:"#d9d9d9"},children:[(0,E.jsx)("span",{style:{flex:1},children:"score \u2014"}),(0,E.jsx)("span",{style:{flex:1},children:"threads \u2014"})]});let p=n.evalScore!==null?Number(n.evalScore).toFixed(1):"\u2014",l=n.threadCount>0?n.threadCount:"\u2014",g=dn(n.evalScore),o=n.evalPassRate!==null?`${n.evalPassRate}%`:"\u2014";return(0,E.jsxs)("div",{className:r.row,children:[(0,E.jsxs)("div",{style:{display:"flex",gap:16,alignItems:"flex-end"},children:[(0,E.jsx)(Ie,{title:`Eval score: ${p} \xB7 pass rate ${o} \xB7 ${n.evalRuns} runs`,children:(0,E.jsxs)("div",{style:We,children:[(0,E.jsx)("span",{style:{...Gt,color:g},children:p}),(0,E.jsx)("span",{className:"lattice-stat-label",style:He,children:"eval score"})]})}),(0,E.jsx)(Ie,{title:`Conversations: ${n.threadCount} total \xB7 ${n.last7d} in 7d \xB7 ${n.last30d} in 30d${n.lastActive?` \xB7 last active ${ln(n.lastActive)}`:""}`,children:(0,E.jsxs)("div",{style:We,children:[(0,E.jsx)("span",{style:{...Gt,color:l==="\u2014"?"#d9d9d9":"#595959"},children:l}),(0,E.jsx)("span",{className:"lattice-stat-label",style:He,children:"threads"})]})})]}),n.daily7d.length>0&&(0,E.jsxs)("div",{style:We,children:[(0,E.jsx)(Ft,{values:n.daily7d,width:40,height:24,color:"#8c8c8c"}),(0,E.jsx)("span",{className:"lattice-stat-label",style:He,children:"7d threads"})]})]})};var C=x(M()),pn=[{key:"all",label:"All"},{key:"capability",label:"Capability"},{key:"orchestrator",label:"Orchestrator"},{key:"team",label:"Team"},{key:"workflow",label:"Workflow"}],Ut=({items:n,assistants:r=[],stats:p,loading:l,onItemClick:g,onOpenPlayground:o,onOpenEval:f,onCreate:k,onDelete:d})=>{let[S,H]=(0,te.useState)("all"),[m,T]=(0,te.useState)(null),[K,w]=(0,te.useState)(null),P=(0,te.useMemo)(()=>{let s=new Set;return n.forEach(i=>i.tags.forEach(ae=>s.add(ae))),Array.from(s).map(i=>({value:i,label:i}))},[n]),N=(0,te.useMemo)(()=>n.filter(s=>!(S!=="all"&&s.type!==S||m&&!s.tags.includes(m)||K&&s.status!==K)),[n,S,m,K]),z=[{key:"edit",icon:ct,label:"Edit",onClick:s=>g(s.id)},{key:"playground",icon:rt,label:"Playground",onClick:s=>o(s.id)},{key:"eval",icon:it,label:"Eval",onClick:s=>f(s.id)}];d&&z.push({key:"delete",icon:pt,label:"Delete",danger:!0,onClick:s=>d(s.id)});let F=(0,te.useMemo)(()=>[{mode:"graph",icon:dt,label:"Graph",render:()=>(0,C.jsx)(Vt,{assistants:r,onNodeClick:g})}],[r,g]);return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("span",{"data-testid":"agent-list-state","data-loading":String(l),"data-count":N.length,hidden:!0,"aria-hidden":"true"}),(0,C.jsx)(Ct,{title:"Agents",itemName:"agent",items:N,loading:l,keyExtractor:s=>s.id,tabs:pn,activeTab:S,onTabChange:s=>H(s),headerLeft:(0,C.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[(0,C.jsx)(Ve,{value:m,onChange:T,options:P,placeholder:"Domain",allLabel:"All domains"}),(0,C.jsx)(Ve,{value:K,onChange:w,options:[{value:"enabled",label:"Enabled"},{value:"draft",label:"Draft"},{value:"disabled",label:"Disabled"}],placeholder:"Status",allLabel:"All statuses"})]}),renderIcon:s=>{let i=Ne(Re(s.type).color);return(0,C.jsx)("div",{title:`${s.type} agent`,style:{width:32,height:32,borderRadius:8,background:`${i}1A`,color:i,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,C.jsx)(De,{size:18})})},renderPrimary:s=>(0,C.jsx)("span",{"data-testid":"agent-name","data-agent-id":s.id,children:s.name}),renderSecondary:s=>s.description||void 0,renderDetails:s=>(0,C.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,C.jsxs)("div",{style:{display:"flex",gap:4,flexWrap:"wrap",alignItems:"center"},children:[s.tags.map(i=>(0,C.jsx)(Te,{color:"magenta",style:{margin:0,borderRadius:10,border:"none"},children:i},i)),(0,C.jsx)(Te,{color:Re(s.type).color,style:{margin:0,borderRadius:10,border:"none"},children:s.type})]}),(0,C.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[(0,C.jsx)(Ie,{title:`Status: ${s.status}`,children:(0,C.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:Dt(s.status),display:"inline-block",cursor:"help"}})}),(0,C.jsx)("span",{style:{fontSize:12,color:"#8c8c8c"},children:s.version})]})]}),renderFooter:s=>(0,C.jsx)("div",{style:{borderTop:"1px dashed #f0f0f0",paddingTop:10},children:(0,C.jsx)(zt,{stats:p?.[s.id]})}),itemActions:z,actionsStyle:"icon",actionsPosition:"hover",onItemClick:s=>g(s.id),createLabel:"New Agent",onCreateClick:k,viewModeExtensions:F,emptyIcon:(0,C.jsx)(De,{size:48,style:{opacity:.5}}),emptyTitle:"No agents yet",emptyDescription:'Click "New Agent" to create one'})]})};var b=x(ue());var le=x(ue());var he=x(M()),{Text:mn}=X,jt=({onSelect:n,value:r,placeholder:p="Select a parent agent to extend..."})=>{let[l,g]=(0,le.useState)([]),[o,f]=(0,le.useState)(!1),{get:k}=ye(),d=(0,le.useCallback)(async()=>{f(!0);try{let m=await k("/api/assistants");m.success&&g(m.data?.records||[])}catch(m){console.error("Failed to fetch assistants:",m)}finally{f(!1)}},[k]);return(0,le.useEffect)(()=>{d()},[d]),(0,he.jsx)(Se,{showSearch:!0,allowClear:!0,value:r,placeholder:p,loading:o,onChange:m=>{if(!m){n(null);return}let T=l.find(K=>K.id===m);n(T||null)},onDropdownVisibleChange:m=>{m&&d()},optionFilterProp:"label",style:{width:"100%"},options:l.map(m=>({value:m.id,label:m.name||m.id,description:m.description})),optionRender:m=>(0,he.jsxs)("div",{children:[(0,he.jsx)("div",{children:m.label}),m.data.description&&(0,he.jsx)(mn,{type:"secondary",style:{fontSize:12},children:m.data.description})]})})};var O=x(M()),{Text:Ht}=X,Wt=({subAgentKeys:n,decisions:r,onChange:p})=>{let{token:l}=Xe.useToken(),g=(f,k)=>{let d=r.map(S=>S.originalKey===f?{...S,clone:k,cloneKey:k?`${f}_clone`:void 0}:S);p(d)},o=(f,k)=>{let d=r.map(S=>S.originalKey===f?{...S,cloneKey:k}:S);p(d)};return n.length===0?null:(0,O.jsxs)("div",{children:[(0,O.jsx)(Ht,{type:"secondary",style:{display:"block",marginBottom:8},children:"Choose how to handle each sub-agent from the parent:"}),(0,O.jsx)(_e,{size:"small",bordered:!0,dataSource:r,style:{borderRadius:l.borderRadius},renderItem:f=>(0,O.jsxs)(_e.Item,{style:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8,padding:"8px 16px"},children:[(0,O.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,O.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[f.clone?(0,O.jsx)(Ee,{style:{color:l.colorPrimary}}):(0,O.jsx)(at,{style:{color:l.colorTextSecondary}}),(0,O.jsx)(Ht,{style:{fontFamily:"monospace"},children:f.originalKey})]}),(0,O.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,O.jsx)(Te,{color:f.clone?"blue":"default",children:f.clone?"Clone as new":"Reuse"}),(0,O.jsx)(Qe,{size:"small",checked:f.clone,onChange:k=>g(f.originalKey,k)})]})]}),f.clone&&(0,O.jsx)(V,{size:"small",placeholder:"Enter key for the cloned agent",value:f.cloneKey,onChange:k=>o(f.originalKey,k.target.value),style:{fontFamily:"monospace",fontSize:12},addonBefore:"Key"})]})})]})};function qt(n){return n.mode!=="local"||n.templateKey||typeof n.executable=="string"&&n.executable.trim().length>0?null:"Choose a template or enter a custom executable"}var t=x(M()),{TextArea:Zt}=V,{Text:ne}=X,Jt="/.well-known/agent-card.json",gn=[{value:"http://",label:"http://"},{value:"https://",label:"https://"}],Yt={react:"Executor: Directly executes tasks using tools. Best for single-step operations like search, code execution, and data retrieval.",deep_agent:"Orchestrator: Manages a sequential todo list to plan and assign todo items to sub-agents. Best for structured multi-step workflows.",team:"Team: Creates tasks with dependencies and dynamically spawns teammates. Like a swarm, teammates communicate via mailbox. Best for tasks requiring exploration and divergent thinking.",processing:"Workflow: Enforces a fixed workflow topology by delegating to sub-agents in a predefined order. Best for deterministic multi-step processes with validated delegation paths.",a2a_remote:"A2A Remote: Delegates to an external A2A-compatible agent server. Use for local CLI tools (Claude Code, Codex, OpenCode) or remote agents."};function Qt(n,r,p="https://"){let l=String(n??"").trim();if(!l)return"";let g=r==="http://"||r==="https://"?r:p,f=(/^https?:\/\//i.test(l)?l:`${g}${l.replace(/^\/+/,"")}`).replace(/\/+$/,"");return f.endsWith(Jt)?f:`${f}${Jt}`}function un(n){try{return new URL(n).port||void 0}catch{return}}function fn(n){return n.some(r=>r==="--port"||r==="-p"||/^--port=/.test(r)||/^-p=/.test(r))}function Xt(n,r){let p=[...n.args],l=un(r);return l&&!fn(p)&&p.push("--port",l),{...n,args:p,...n.env?{env:{...n.env}}:{}}}var en=({open:n,onCancel:r,onSuccess:p,initialMode:l,initialValues:g})=>{let[o]=R.useForm(),[f,k]=(0,b.useState)(!1),[d,S]=(0,b.useState)("learn"),[H,m]=(0,b.useState)(""),[T,K]=(0,b.useState)(null),[w,P]=(0,b.useState)([]),N=R.useWatch("type",o)||"react",z=N==="a2a_remote",[F,s]=(0,b.useState)("remote"),[i,ae]=(0,b.useState)(void 0),[de,be]=(0,b.useState)([]),[ce,pe]=(0,b.useState)(!1),q=(0,b.useRef)(0),[Le,Ae]=(0,b.useState)(!1),[Be,oe]=(0,b.useState)(!1),{get:Z,post:W,put:Oe}=ye(),Pe=et("agent-architect"),{workspaceId:_,trainingProjects:me,loading:Q}=gt(),[$e,ge]=(0,b.useState)(null),Ce=JSON.stringify(g??null),L=me.find(e=>e.id===$e)??me[0]??null,[xe,we]=(0,b.useState)([]),Fe=(0,b.useCallback)(()=>{K(null),P([])},[]),re=(0,b.useCallback)(()=>{o.resetFields(),Fe(),S("learn"),m(""),we([]),ge(null),s("remote"),ae(void 0),be([]),oe(!1),Ae(!1)},[o,Fe]);(0,b.useEffect)(()=>{if(n){re(),S(l??"learn");let e=g?.a2aMode;(e==="remote"||e==="local")&&s(e),o.setFieldsValue({type:"react",agentCardProtocol:"https://",a2aMode:"remote",timeout:3e5,...g})}},[n,o,l,Ce,re]),(0,b.useEffect)(()=>{let e=++q.current,a=!0;return n&&z?(o.setFieldValue("prompt",""),F==="local"?(pe(!0),Z("/api/local-a2a/templates").then(A=>{a&&e===q.current&&A?.data?.records&&be(A.data.records)}).catch(()=>{a&&e===q.current&&be([])}).finally(()=>{a&&e===q.current&&pe(!1)})):pe(!1)):pe(!1),()=>{a=!1,q.current+=1}},[o,z,F,Z,n]);let se=de.find(e=>e.key===i),ve=(0,b.useCallback)(()=>{let e=qt({mode:F,templateKey:i,executable:o.getFieldValue("commandExecutable")});return e?(oe(!0),o.setFields([{name:"commandExecutable",errors:[e]}]),v.warning(e),!1):!0},[F,i,o]);(0,b.useEffect)(()=>{se&&o.setFieldsValue({agentCardProtocol:"http://"})},[o,se]);let c=(0,b.useCallback)(async()=>{if(!ve())return;let e=Qt(o.getFieldValue("agentCardUrl"),o.getFieldValue("agentCardProtocol"),F==="local"?"http://":"https://");if(!e){v.warning("Please enter an A2A server URL first");return}Ae(!0);try{let a={agentCardUrl:e,apiKey:o.getFieldValue("apiKey")};if(F==="local"){let y=se;if(y)a.localRuntime={label:o.getFieldValue("name")||void 0,agentCardUrl:e,command:Xt(y.command,e)};else{let B=o.getFieldValue("commandArgs")||"",j=B?B.split(/\s+/).filter(Boolean):[],D=String(o.getFieldValue(["command","cwd"])||"").trim();a.localRuntime={label:o.getFieldValue("name")||void 0,agentCardUrl:e,command:{executable:String(o.getFieldValue("commandExecutable")||"").trim(),args:j,...D?{cwd:D}:{}}}}}let A=await W("/api/a2a/test-connection",a);if(A.data?.reachable){let y=A.data.agentCard;v.success(`Connected to "${A.data.agentName||e}"`)}else v.error(A.data?.error||"Connection failed")}catch{v.error("Connection test failed")}finally{Ae(!1)}},[o,W,F,se,ve]),h=(0,b.useCallback)(e=>{if(K(e),!e){o.resetFields(["key","name","description","type","prompt"]),P([]);return}let a=typeof e.graphDefinition=="object"&&e.graphDefinition!==null?e.graphDefinition:{},A=a.key||e.id,y=e.name||a.name||"";o.setFieldsValue({key:`${A}_ext`,name:y?`${y} (Extended)`:"",description:e.description||a.description||"",type:a.type||"react",prompt:a.prompt||""});let B=a.subAgents||[];P(B.map(j=>({originalKey:j,clone:!1})))},[o]),I=async(e,a)=>{let A=await Z(`/api/assistants/${e}`);if(!A.success)throw new Error(`Failed to fetch sub-agent "${e}" for cloning`);let y=A.data,B=typeof y.graphDefinition=="object"?y.graphDefinition:{},j={id:a,name:`${y.name} (Clone)`,description:y.description||"",graphDefinition:{...B,key:a,name:`${y.name} (Clone)`}},D=await W("/api/assistants",j);if(!D.success)throw new Error(D.message||`Failed to clone sub-agent "${e}"`);return D.data},U=e=>{let a={id:e.key,name:e.name,description:e.description||"",graphDefinition:{key:e.key,name:e.name,description:e.description||"",type:e.type,prompt:e.prompt||"",tools:[],skills:[],subAgents:e.type==="deep_agent"||e.type==="processing"?[]:void 0,middleware:[]}};if(e.type==="a2a_remote"&&(a.graphDefinition.agentCardUrl=Qt(e.agentCardUrl,e.agentCardProtocol,(e.a2aMode||F)==="local"?"http://":"https://"),e.apiKey&&(a.graphDefinition.apiKey=e.apiKey),e.timeout&&(a.graphDefinition.timeout=e.timeout),(e.a2aMode||F)==="local")){let A=se;if(A)a.graphDefinition.localRuntime={label:e.name||void 0,agentCardUrl:a.graphDefinition.agentCardUrl,command:Xt(A.command,a.graphDefinition.agentCardUrl)};else{let y=e.commandArgs||"",B=y?y.split(/\s+/).filter(Boolean):[],j=String(e.command?.cwd||"").trim();a.graphDefinition.localRuntime={label:e.name||void 0,agentCardUrl:a.graphDefinition.agentCardUrl,command:{executable:String(e.commandExecutable||"").trim(),args:B,...j?{cwd:j}:{}}}}}return a},ke=async(e,a)=>{if(!T)throw new Error("No parent agent selected");let A=w.filter(D=>D.clone);for(let D of A){if(!D.cloneKey||!D.cloneKey.trim())throw new Error(`Please provide a key for the cloned sub-agent "${D.originalKey}"`);if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(D.cloneKey))throw new Error(`Invalid key "${D.cloneKey}" for cloned sub-agent "${D.originalKey}". Key must start with a letter and contain only letters, numbers, underscores, or hyphens.`)}let y=[];for(let D of w)if(D.clone){let rn=await I(D.originalKey,D.cloneKey);a.push(rn),y.push(D.cloneKey)}else y.push(D.originalKey);let B=typeof T.graphDefinition=="object"?T.graphDefinition:{},j={key:e.key,name:e.name,description:e.description||"",extendsAgent:T.id,type:e.type||B.type};return e.prompt&&e.prompt!==B.prompt&&(j.prompt=e.prompt),(y.length>0||B.subAgents&&B.subAgents.length>0)&&(j.subAgents=y),{id:e.key,name:e.name,description:e.description||"",graphDefinition:j}},an=async()=>{if(d==="learn"){let e=H.trim();if(!e){v.error("Please describe the training goal");return}if(!L){v.error("No shared training project available");return}k(!0);try{let a=`agent-${Et(e+Date.now())}`,A=await W("/api/assistants",{id:a,name:a,graphDefinition:{key:a,name:a,description:"",type:"react",prompt:"To be trained",metadata:{trainingProjectId:L.id,learningPlaceholder:"true",architectureStatus:"undecided"}}});if(!A.data)throw new Error("Failed to create agent");let{roundTaskId:y}=await Lt({goal:e,targetAgentId:a,workspaceId:_??void 0,projectId:L.id,existingThreadId:Nt(Pe.tenantId,a),files:xe,post:W,put:Oe});v.success("Agent created \u2014 architect started building"),m(""),we([]),S("learn"),p?.(A.data,{initialMessage:Bt({goal:e,roundTaskId:y,targetAgentId:a,targetMode:"placeholder",files:xe,projectId:L.id,workspaceId:L.workspaceId??_??void 0}),projectId:L.id,initialMessageCustomRunConfig:{execution:{taskId:y}}}),r()}catch(a){v.error(a instanceof Error?a.message:"Failed to create agent")}finally{k(!1)}return}try{if(d==="scratch"&&z&&!ve())return;let e=await o.validateFields();k(!0);let a=[],A=d==="scratch"?U(e):await ke(e,a),y=await W("/api/assistants",A);if(y.success){v.success(d==="extend"?`Assistant created by extending "${T?.name}"`:"Assistant created successfully"),re();for(let B of a)p?.(B);p?.(y.data),r()}else v.error(y.message||"Failed to create assistant")}catch(e){if(e?.errorFields){let a={key:"Key (ID)",name:"Name",description:"Description",prompt:"System Prompt"},A=e.errorFields.map(y=>a[String((y.name??[])[0])]??String((y.name??[])[0])).filter(Boolean);v.warning(A.length>0?`Please complete the required fields: ${[...new Set(A)].join(", ")}`:"Please complete the required fields");return}v.error(e.message||"An error occurred while creating the assistant")}finally{k(!1)}},qe=T?.graphDefinition?.subAgents||[],on=d==="extend"&&T&&qe.length>0;return(0,t.jsxs)(fe,{title:"Create New Assistant",open:n,onCancel:()=>{re(),r()},footer:[(0,t.jsx)(J,{onClick:()=>{re(),r()},children:"Cancel"},"cancel"),(0,t.jsx)(J,{type:"primary",icon:d==="extend"?(0,t.jsx)(Ee,{}):d==="learn"?(0,t.jsx)(nt,{}):(0,t.jsx)(ot,{}),loading:f,disabled:d==="learn"&&(Q||!L),onClick:an,children:d==="extend"?"Create (Extend)":d==="learn"?"Start Learning":"Create"},"submit")],width:760,children:[d==="extend"&&(0,t.jsxs)("div",{style:{marginBottom:20},children:[(0,t.jsx)(ne,{type:"secondary",style:{display:"block",marginBottom:8},children:"Parent Agent"}),(0,t.jsx)(jt,{value:T?.id,onSelect:h}),T&&(0,t.jsx)(ne,{type:"secondary",style:{display:"block",marginTop:4,fontSize:12},children:"Fields left unchanged will be inherited from the parent agent."})]}),d==="extend"&&T&&(0,t.jsx)(Ke,{style:{margin:"12px 0"}}),d==="learn"&&(0,t.jsxs)("div",{children:[(0,t.jsx)(ne,{style:{display:"block",marginBottom:8},children:"Describe what the agent should do."}),(0,t.jsx)(V.TextArea,{rows:3,value:H,onChange:e=>m(e.target.value),placeholder:"e.g. Handle price disputes using the price protection policy"}),L&&(0,t.jsxs)("div",{style:{marginTop:12},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[(0,t.jsx)(ne,{type:"secondary",children:"Reference Files"}),(0,t.jsx)(Ue,{project:L,projects:me,value:L?.id??null,onChange:ge,loading:Q})]}),(0,t.jsx)(Mt,{projectId:L.id,value:xe,onChange:we}),(0,t.jsx)(ne,{type:"secondary",style:{display:"block",marginTop:6,fontSize:12},children:"Optional \u2014 uploaded to the shared training workspace and attached to the learning round; the architect reads them as round material."})]}),!L&&!Q&&(0,t.jsx)("div",{style:{marginTop:12},children:(0,t.jsx)(Ue,{project:L,projects:me,value:null,onChange:ge,loading:Q})})]}),d!=="learn"&&(0,t.jsxs)(R,{form:o,layout:"vertical",autoComplete:"off",initialValues:{type:"react",agentCardProtocol:"https://",a2aMode:"remote"},children:[(0,t.jsx)(R.Item,{name:"key",label:"Key (ID)",rules:[{required:!0,message:"Please enter a unique key"},{pattern:/^[a-zA-Z][a-zA-Z0-9_-]*$/,message:"Key must start with a letter and contain only letters, numbers, underscores, or hyphens"}],style:{marginBottom:16},children:(0,t.jsx)(V,{placeholder:"e.g., my_assistant"})}),(0,t.jsx)(R.Item,{name:"name",label:"Name",rules:[{required:!0,message:"Please enter a name"}],style:{marginBottom:16},children:(0,t.jsx)(V,{placeholder:"e.g., My Assistant"})}),(0,t.jsx)(R.Item,{name:"description",label:"Description",rules:[{required:!0,message:"Please enter a description"}],style:{marginBottom:16},children:(0,t.jsx)(Zt,{placeholder:"Enter a description for this assistant...",autoSize:{minRows:2,maxRows:4}})}),(0,t.jsx)(R.Item,{name:"type",label:"Agent Type",rules:[{required:!0}],style:{marginBottom:16},children:(0,t.jsx)(Ze,{options:[{value:"react",label:"Executor"},{value:"deep_agent",label:"Orchestrator"},{value:"team",label:"Team"},{value:"processing",label:"Workflow"},{value:"a2a_remote",label:"A2A Remote"}],block:!0})}),(0,t.jsx)(ne,{type:"secondary",style:{fontSize:12,display:"block",marginTop:-12,marginBottom:16,lineHeight:1.5},children:Yt[N]||Yt.react}),z&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(R.Item,{label:"Connection Mode",style:{marginBottom:16},children:(0,t.jsxs)(Me.Group,{value:F,onChange:e=>{let a=e.target.value;s(a),o.setFieldValue("a2aMode",a),a==="local"&&o.setFieldValue("agentCardProtocol","http://"),ae(void 0)},optionType:"button",buttonStyle:"solid",children:[(0,t.jsx)(Me.Button,{value:"remote",children:"Remote URL"}),(0,t.jsx)(Me.Button,{value:"local",children:"Local Managed"})]})}),(0,t.jsx)(R.Item,{name:"a2aMode",noStyle:!0,hidden:!0,children:(0,t.jsx)(V,{})}),F==="local"&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(R.Item,{label:"Template",style:{marginBottom:16},children:(0,t.jsx)(Se,{placeholder:"Choose a template...",allowClear:!0,loading:ce,value:i,onChange:e=>{ae(e),e&&oe(!1)},options:de.map(e=>({value:e.key,label:e.name||e.key})),notFoundContent:ce?void 0:(0,t.jsx)(ne,{type:"secondary",style:{padding:8,display:"block"},children:'No templates. Use "Custom Command" below.'})})}),!i&&(0,t.jsx)(t.Fragment,{children:Be?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(R.Item,{name:"commandExecutable",label:"Executable",rules:[{required:!0,whitespace:!0,message:"Executable is required"}],style:{marginBottom:16},children:(0,t.jsx)(V,{placeholder:"e.g. node, opencode, /usr/local/bin/my-server"})}),(0,t.jsx)(R.Item,{name:"commandArgs",label:"Arguments",style:{marginBottom:16},children:(0,t.jsx)(V,{placeholder:"e.g. --serve --port 4301"})}),(0,t.jsx)(R.Item,{name:["command","cwd"],label:"Working directory",style:{marginBottom:16},children:(0,t.jsx)(V,{placeholder:"e.g. /Users/me/project"})}),(0,t.jsx)(J,{type:"link",onClick:()=>{oe(!1),o.setFieldsValue({commandExecutable:"",commandArgs:"",command:{cwd:void 0}})},style:{padding:0,marginBottom:16,display:"block"},children:"- Hide Custom Command"})]}):(0,t.jsx)(J,{type:"link",onClick:()=>oe(!0),style:{padding:0,marginBottom:16,display:"block"},children:"+ Custom Command"})})]}),(0,t.jsx)(R.Item,{label:"Agent Card URL",required:!0,style:{marginBottom:16},children:(0,t.jsxs)(Ye.Compact,{style:{width:"100%"},children:[(0,t.jsx)(R.Item,{name:"agentCardProtocol",noStyle:!0,children:(0,t.jsx)(Se,{style:{width:100},options:gn})}),(0,t.jsx)(R.Item,{name:"agentCardUrl",noStyle:!0,rules:[{required:!0,message:"Please enter the A2A server URL"}],children:(0,t.jsx)(V,{placeholder:F==="local"?"localhost:4301":"host:port or full URL"})}),(0,t.jsx)(J,{icon:(0,t.jsx)(tt,{}),onClick:c,loading:Le,children:"Test"})]})}),F==="remote"&&(0,t.jsx)(R.Item,{name:"apiKey",label:"API Key (optional)",style:{marginBottom:16},children:(0,t.jsx)(V.Password,{placeholder:"API key for authentication"})}),(0,t.jsx)(R.Item,{name:"timeout",label:"Timeout (ms)",style:{marginBottom:16},initialValue:3e5,children:(0,t.jsx)(Je,{min:1e3,max:36e5,style:{width:"100%"},placeholder:"300000"})})]}),!z&&(0,t.jsx)(R.Item,{name:"prompt",label:d==="extend"&&T?"System Prompt (leave unchanged to inherit from parent)":"System Prompt",rules:d==="scratch"?[{required:!0,message:"Please enter a system prompt"}]:[],children:(0,t.jsx)(Zt,{placeholder:d==="extend"&&T?"Leave empty to inherit parent's prompt, or enter a new prompt to override...":"Enter the system prompt for this agent...",autoSize:{minRows:4,maxRows:8},style:{fontFamily:"monospace",fontSize:13,lineHeight:1.6}})})]}),on&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Ke,{style:{margin:"12px 0"}}),(0,t.jsx)(ne,{strong:!0,style:{display:"block",marginBottom:8},children:"Sub-Agents"}),(0,t.jsx)(Wt,{subAgentKeys:qe,decisions:w,onChange:P})]})]})};var $=x(M()),{Paragraph:yn,Text:tn}=X,hn=[{key:"manual",icon:De,title:"Manual Configuration",description:"Define the agent's identity, type, tools, and system prompt yourself."},{key:"external",icon:st,title:"External Agent",description:"Connect an existing A2A-compatible agent by URL or manage a local runtime."},{key:"learn",icon:lt,title:"Learn with Agent Architect",description:"Describe the goal and let Agent Architect build and evaluate the agent with training context."}],nn=({open:n,onCancel:r,onSelectMethod:p,focusTriggerAfterClose:l=!0})=>(0,$.jsx)(fe,{title:"Choose how to create your agent",open:n,onCancel:r,footer:null,width:560,centered:!0,destroyOnHidden:!0,focusTriggerAfterClose:l,children:(0,$.jsxs)("div",{style:{padding:"8px 4px 4px"},children:[(0,$.jsx)(yn,{style:{color:"#595959",fontSize:15,margin:"8px 0 24px"},children:"Choose the path that best fits the agent you want to build."}),(0,$.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:hn.map(g=>{let o=g.icon;return(0,$.jsxs)(J,{type:"default",onClick:()=>p(g.key),"aria-label":g.title,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,$.jsx)("div",{style:{width:40,height:40,borderRadius:12,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"#6366f1",background:"#eeeeff"},children:(0,$.jsx)(o,{size:19})}),(0,$.jsxs)("div",{style:{minWidth:0},children:[(0,$.jsx)(tn,{strong:!0,style:{display:"block",fontSize:15,marginBottom:3},children:g.title}),(0,$.jsx)(tn,{style:{color:"#737373",lineHeight:1.5},children:g.description})]})]},g.key)})}),(0,$.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,flexWrap:"wrap",marginTop:24},children:(0,$.jsx)(J,{onClick:r,children:"Not now"})})]})});var G=x(M()),bn=n=>{let r=n;if(typeof n=="string")try{r=JSON.parse(n)}catch{return{}}return r!==null&&typeof r=="object"&&!Array.isArray(r)?r:{}},Da=()=>{let{get:n,del:r,put:p}=ye(),[l,g]=(0,u.useState)([]),[o,f]=(0,u.useState)({}),[k,d]=(0,u.useState)(null),[S,H]=(0,u.useState)(!1),[m,T]=(0,u.useState)(null),[K,w]=(0,u.useState)("graph"),[P,N]=(0,u.useState)(null),[z,F]=(0,u.useState)(null),[s,i]=(0,u.useState)(null),[ae,de]=(0,u.useState)(!1),[be,ce]=(0,u.useState)(!0),[pe,q]=(0,u.useState)(!1),[Le,Ae]=(0,u.useState)("learn"),[Be,oe]=(0,u.useState)({}),[Z,W]=(0,u.useState)(null),[Oe,Pe]=(0,u.useState)(!1),_=(0,u.useCallback)(async()=>{H(!0);try{let[c,h]=await Promise.all([n("/api/assistants"),n("/api/assistants/stats").catch(()=>null)]);if(c.success&&c.data?.records&&g(c.data.records),h?.success&&h.data?.records){let I={};for(let U of h.data.records)I[U.id]=U;f(I),d(h.cache?.expiresAt??null)}}catch{v.error("Failed to load agents")}finally{H(!1)}},[n]);(0,u.useEffect)(()=>{_()},[_]);let me=u.default.useMemo(()=>Rt(l),[l]),Q=l.find(c=>c.id===m)??null,$e=(0,u.useCallback)((c,h="graph")=>{T(c),w(h),N(null),i(null)},[]),ge=At(),Ce=(0,u.useCallback)((c,h)=>{let I=l.find(U=>U.id===c)?.name??"Agent";ge({component_key:"agent_detail_side_app",data:{assistantId:c,initialTab:h},message:I})},[l,ge]),L=(0,u.useCallback)(()=>{ce(!0),de(!0)},[]),xe=(0,u.useCallback)(c=>{let I={manual:{mode:"scratch",values:{}},external:{mode:"scratch",values:{type:"a2a_remote"}},learn:{mode:"learn",values:{}}}[c];Ae(I.mode),oe(I.values),ce(!1),de(!1),q(!0)},[]),we=(0,u.useCallback)(async(c,h)=>{let I=bn(c.graphDefinition),U;try{U=await p(`/api/assistants/${c.id}`,{name:h.name!==void 0?h.name:c.name,description:h.description!==void 0?h.description:c.description,graphDefinition:{...I,...h}})}catch(ke){throw v.error("Failed to save agent"),ke}if(!U.success)throw v.error("Failed to save agent"),new Error("Failed to save agent");v.success("Saved"),_()},[p,_]),Fe=(0,u.useCallback)(c=>{g(h=>h.map(I=>I.id===c.id?c:I))},[]),re=(0,u.useCallback)(c=>{W(c)},[]),se=(0,u.useCallback)(async()=>{if(Z){Pe(!0);try{(await r(`/api/assistants/${Z}`)).success?(v.success("Agent deleted"),g(h=>h.filter(I=>I.id!==Z)),_(),W(null)):v.error("Failed to delete agent")}catch{v.error("Failed to delete agent")}finally{Pe(!1)}}},[Z,r,_]),ve=(0,u.useCallback)(async c=>{if(!(await r(`/api/assistants/${c}`)).success)throw new Error("Failed to delete agent");v.success("Agent deleted"),g(I=>I.filter(U=>U.id!==c)),_()},[r,_]);return(0,G.jsxs)("div",{style:{height:"100%",background:"#fafafa",overflow:"hidden"},children:[Q?(0,G.jsx)(Tt,{defaultProjectId:s??void 0,children:(0,G.jsx)(Ot,{assistant:Q,allAssistants:l,onBack:()=>T(null),onDeleted:ve,onSave:we,onAssistantUpdated:Fe,onAgentListInvalidated:_,initialTab:K,initialMessage:P,initialMessageCustomRunConfig:z,initialProjectId:s})},Q.id):(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(Ut,{items:me,assistants:l,stats:o,statsExpiresAt:k,loading:S,onItemClick:c=>Ce(c,"graph"),onOpenPlayground:c=>Ce(c,"playground"),onOpenEval:c=>Ce(c,"eval"),onCreate:L,onDelete:re})}),(0,G.jsx)(nn,{open:ae,onCancel:()=>{ce(!0),de(!1)},onSelectMethod:xe,focusTriggerAfterClose:be}),(0,G.jsx)(en,{open:pe,initialMode:Le,initialValues:Be,onCancel:()=>q(!1),onSuccess:(c,h)=>{q(!1),g(I=>I.some(ke=>ke.id===c.id)?I:[c,...I]),$e(c.id,"graph"),N(h?.initialMessage??null),F(h?.initialMessageCustomRunConfig??null),i(h?.projectId??null),_()}}),(0,G.jsx)(fe,{title:"Delete Agent",open:Z!==null,onCancel:()=>W(null),onOk:se,okText:"Delete",okButtonProps:{danger:!0,loading:Oe},cancelText:"Cancel",children:(0,G.jsx)("p",{children:"This action cannot be undone."})})]})};export{Da as AgentGovernanceWorkbench};
|
|
5
|
+
`})),Gt={fontSize:16,fontWeight:700,lineHeight:1.2,cursor:"help"},He={fontSize:10,color:"rgba(0, 0, 0, 0.45)",whiteSpace:"nowrap",marginTop:1},We={display:"flex",flexDirection:"column",alignItems:"center"},zt=({stats:n})=>{let{styles:r}=cn();if(!n)return(0,E.jsxs)("div",{style:{display:"flex",fontSize:11,color:"#d9d9d9"},children:[(0,E.jsx)("span",{style:{flex:1},children:"score \u2014"}),(0,E.jsx)("span",{style:{flex:1},children:"threads \u2014"})]});let p=n.evalScore!==null?Number(n.evalScore).toFixed(1):"\u2014",l=n.threadCount>0?n.threadCount:"\u2014",g=dn(n.evalScore),o=n.evalPassRate!==null?`${n.evalPassRate}%`:"\u2014";return(0,E.jsxs)("div",{className:r.row,children:[(0,E.jsxs)("div",{style:{display:"flex",gap:16,alignItems:"flex-end"},children:[(0,E.jsx)(Ie,{title:`Eval score: ${p} \xB7 pass rate ${o} \xB7 ${n.evalRuns} runs`,children:(0,E.jsxs)("div",{style:We,children:[(0,E.jsx)("span",{style:{...Gt,color:g},children:p}),(0,E.jsx)("span",{className:"lattice-stat-label",style:He,children:"eval score"})]})}),(0,E.jsx)(Ie,{title:`Conversations: ${n.threadCount} total \xB7 ${n.last7d} in 7d \xB7 ${n.last30d} in 30d${n.lastActive?` \xB7 last active ${ln(n.lastActive)}`:""}`,children:(0,E.jsxs)("div",{style:We,children:[(0,E.jsx)("span",{style:{...Gt,color:l==="\u2014"?"#d9d9d9":"#595959"},children:l}),(0,E.jsx)("span",{className:"lattice-stat-label",style:He,children:"threads"})]})})]}),n.daily7d.length>0&&(0,E.jsxs)("div",{style:We,children:[(0,E.jsx)(Ft,{values:n.daily7d,width:40,height:24,color:"#8c8c8c"}),(0,E.jsx)("span",{className:"lattice-stat-label",style:He,children:"7d threads"})]})]})};var C=x(M()),pn=[{key:"all",label:"All"},{key:"capability",label:"Capability"},{key:"orchestrator",label:"Orchestrator"},{key:"team",label:"Team"},{key:"workflow",label:"Workflow"}],Ut=({items:n,assistants:r=[],stats:p,loading:l,onItemClick:g,onOpenPlayground:o,onOpenEval:f,onCreate:k,onDelete:d})=>{let[S,H]=(0,te.useState)("all"),[m,T]=(0,te.useState)(null),[K,w]=(0,te.useState)(null),P=(0,te.useMemo)(()=>{let s=new Set;return n.forEach(i=>i.tags.forEach(ae=>s.add(ae))),Array.from(s).map(i=>({value:i,label:i}))},[n]),N=(0,te.useMemo)(()=>n.filter(s=>!(S!=="all"&&s.type!==S||m&&!s.tags.includes(m)||K&&s.status!==K)),[n,S,m,K]),z=[{key:"edit",icon:ct,label:"Edit",onClick:s=>g(s.id)},{key:"playground",icon:rt,label:"Playground",onClick:s=>o(s.id)},{key:"eval",icon:it,label:"Eval",onClick:s=>f(s.id)}];d&&z.push({key:"delete",icon:pt,label:"Delete",danger:!0,onClick:s=>d(s.id)});let F=(0,te.useMemo)(()=>[{mode:"graph",icon:dt,label:"Graph",render:()=>(0,C.jsx)(Vt,{assistants:r,onNodeClick:g})}],[r,g]);return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("span",{"data-testid":"agent-list-state","data-loading":String(l),"data-count":N.length,hidden:!0,"aria-hidden":"true"}),(0,C.jsx)(ut,{title:"Agents",itemName:"agent",items:N,loading:l,keyExtractor:s=>s.id,tabs:pn,activeTab:S,onTabChange:s=>H(s),headerLeft:(0,C.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[(0,C.jsx)(Ve,{value:m,onChange:T,options:P,placeholder:"Domain",allLabel:"All domains"}),(0,C.jsx)(Ve,{value:K,onChange:w,options:[{value:"enabled",label:"Enabled"},{value:"draft",label:"Draft"},{value:"disabled",label:"Disabled"}],placeholder:"Status",allLabel:"All statuses"})]}),renderIcon:s=>{let i=Ne(Re(s.type).color);return(0,C.jsx)("div",{title:`${s.type} agent`,style:{width:32,height:32,borderRadius:8,background:`${i}1A`,color:i,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,C.jsx)(De,{size:18})})},renderPrimary:s=>(0,C.jsx)("span",{"data-testid":"agent-name","data-agent-id":s.id,children:s.name}),renderSecondary:s=>s.description||void 0,renderDetails:s=>(0,C.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,C.jsxs)("div",{style:{display:"flex",gap:4,flexWrap:"wrap",alignItems:"center"},children:[s.tags.map(i=>(0,C.jsx)(Te,{color:"magenta",style:{margin:0,borderRadius:10,border:"none"},children:i},i)),(0,C.jsx)(Te,{color:Re(s.type).color,style:{margin:0,borderRadius:10,border:"none"},children:s.type})]}),(0,C.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[(0,C.jsx)(Ie,{title:`Status: ${s.status}`,children:(0,C.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:Dt(s.status),display:"inline-block",cursor:"help"}})}),(0,C.jsx)("span",{style:{fontSize:12,color:"#8c8c8c"},children:s.version})]})]}),renderFooter:s=>(0,C.jsx)("div",{style:{borderTop:"1px dashed #f0f0f0",paddingTop:10},children:(0,C.jsx)(zt,{stats:p?.[s.id]})}),itemActions:z,actionsStyle:"icon",actionsPosition:"hover",onItemClick:s=>g(s.id),createLabel:"New Agent",onCreateClick:k,viewModeExtensions:F,emptyIcon:(0,C.jsx)(De,{size:48,style:{opacity:.5}}),emptyTitle:"No agents yet",emptyDescription:'Click "New Agent" to create one'})]})};var b=x(ue());var le=x(ue());var he=x(M()),{Text:mn}=X,jt=({onSelect:n,value:r,placeholder:p="Select a parent agent to extend..."})=>{let[l,g]=(0,le.useState)([]),[o,f]=(0,le.useState)(!1),{get:k}=ye(),d=(0,le.useCallback)(async()=>{f(!0);try{let m=await k("/api/assistants");m.success&&g(m.data?.records||[])}catch(m){console.error("Failed to fetch assistants:",m)}finally{f(!1)}},[k]);return(0,le.useEffect)(()=>{d()},[d]),(0,he.jsx)(Se,{showSearch:!0,allowClear:!0,value:r,placeholder:p,loading:o,onChange:m=>{if(!m){n(null);return}let T=l.find(K=>K.id===m);n(T||null)},onDropdownVisibleChange:m=>{m&&d()},optionFilterProp:"label",style:{width:"100%"},options:l.map(m=>({value:m.id,label:m.name||m.id,description:m.description})),optionRender:m=>(0,he.jsxs)("div",{children:[(0,he.jsx)("div",{children:m.label}),m.data.description&&(0,he.jsx)(mn,{type:"secondary",style:{fontSize:12},children:m.data.description})]})})};var O=x(M()),{Text:Ht}=X,Wt=({subAgentKeys:n,decisions:r,onChange:p})=>{let{token:l}=Xe.useToken(),g=(f,k)=>{let d=r.map(S=>S.originalKey===f?{...S,clone:k,cloneKey:k?`${f}_clone`:void 0}:S);p(d)},o=(f,k)=>{let d=r.map(S=>S.originalKey===f?{...S,cloneKey:k}:S);p(d)};return n.length===0?null:(0,O.jsxs)("div",{children:[(0,O.jsx)(Ht,{type:"secondary",style:{display:"block",marginBottom:8},children:"Choose how to handle each sub-agent from the parent:"}),(0,O.jsx)(_e,{size:"small",bordered:!0,dataSource:r,style:{borderRadius:l.borderRadius},renderItem:f=>(0,O.jsxs)(_e.Item,{style:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8,padding:"8px 16px"},children:[(0,O.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,O.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[f.clone?(0,O.jsx)(Ee,{style:{color:l.colorPrimary}}):(0,O.jsx)(at,{style:{color:l.colorTextSecondary}}),(0,O.jsx)(Ht,{style:{fontFamily:"monospace"},children:f.originalKey})]}),(0,O.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,O.jsx)(Te,{color:f.clone?"blue":"default",children:f.clone?"Clone as new":"Reuse"}),(0,O.jsx)(Qe,{size:"small",checked:f.clone,onChange:k=>g(f.originalKey,k)})]})]}),f.clone&&(0,O.jsx)(V,{size:"small",placeholder:"Enter key for the cloned agent",value:f.cloneKey,onChange:k=>o(f.originalKey,k.target.value),style:{fontFamily:"monospace",fontSize:12},addonBefore:"Key"})]})})]})};function qt(n){return n.mode!=="local"||n.templateKey||typeof n.executable=="string"&&n.executable.trim().length>0?null:"Choose a template or enter a custom executable"}var t=x(M()),{TextArea:Zt}=V,{Text:ne}=X,Jt="/.well-known/agent-card.json",gn=[{value:"http://",label:"http://"},{value:"https://",label:"https://"}],Yt={react:"Executor: Directly executes tasks using tools. Best for single-step operations like search, code execution, and data retrieval.",deep_agent:"Orchestrator: Manages a sequential todo list to plan and assign todo items to sub-agents. Best for structured multi-step workflows.",team:"Team: Creates tasks with dependencies and dynamically spawns teammates. Like a swarm, teammates communicate via mailbox. Best for tasks requiring exploration and divergent thinking.",processing:"Workflow: Enforces a fixed workflow topology by delegating to sub-agents in a predefined order. Best for deterministic multi-step processes with validated delegation paths.",a2a_remote:"A2A Remote: Delegates to an external A2A-compatible agent server. Use for local CLI tools (Claude Code, Codex, OpenCode) or remote agents."};function Qt(n,r,p="https://"){let l=String(n??"").trim();if(!l)return"";let g=r==="http://"||r==="https://"?r:p,f=(/^https?:\/\//i.test(l)?l:`${g}${l.replace(/^\/+/,"")}`).replace(/\/+$/,"");return f.endsWith(Jt)?f:`${f}${Jt}`}function un(n){try{return new URL(n).port||void 0}catch{return}}function fn(n){return n.some(r=>r==="--port"||r==="-p"||/^--port=/.test(r)||/^-p=/.test(r))}function Xt(n,r){let p=[...n.args],l=un(r);return l&&!fn(p)&&p.push("--port",l),{...n,args:p,...n.env?{env:{...n.env}}:{}}}var en=({open:n,onCancel:r,onSuccess:p,initialMode:l,initialValues:g})=>{let[o]=R.useForm(),[f,k]=(0,b.useState)(!1),[d,S]=(0,b.useState)("learn"),[H,m]=(0,b.useState)(""),[T,K]=(0,b.useState)(null),[w,P]=(0,b.useState)([]),N=R.useWatch("type",o)||"react",z=N==="a2a_remote",[F,s]=(0,b.useState)("remote"),[i,ae]=(0,b.useState)(void 0),[de,be]=(0,b.useState)([]),[ce,pe]=(0,b.useState)(!1),q=(0,b.useRef)(0),[Le,Ae]=(0,b.useState)(!1),[Be,oe]=(0,b.useState)(!1),{get:Z,post:W,put:Oe}=ye(),Pe=et("agent-architect"),{workspaceId:_,trainingProjects:me,loading:Q}=gt(),[$e,ge]=(0,b.useState)(null),Ce=JSON.stringify(g??null),L=me.find(e=>e.id===$e)??me[0]??null,[xe,we]=(0,b.useState)([]),Fe=(0,b.useCallback)(()=>{K(null),P([])},[]),re=(0,b.useCallback)(()=>{o.resetFields(),Fe(),S("learn"),m(""),we([]),ge(null),s("remote"),ae(void 0),be([]),oe(!1),Ae(!1)},[o,Fe]);(0,b.useEffect)(()=>{if(n){re(),S(l??"learn");let e=g?.a2aMode;(e==="remote"||e==="local")&&s(e),o.setFieldsValue({type:"react",agentCardProtocol:"https://",a2aMode:"remote",timeout:3e5,...g})}},[n,o,l,Ce,re]),(0,b.useEffect)(()=>{let e=++q.current,a=!0;return n&&z?(o.setFieldValue("prompt",""),F==="local"?(pe(!0),Z("/api/local-a2a/templates").then(A=>{a&&e===q.current&&A?.data?.records&&be(A.data.records)}).catch(()=>{a&&e===q.current&&be([])}).finally(()=>{a&&e===q.current&&pe(!1)})):pe(!1)):pe(!1),()=>{a=!1,q.current+=1}},[o,z,F,Z,n]);let se=de.find(e=>e.key===i),ve=(0,b.useCallback)(()=>{let e=qt({mode:F,templateKey:i,executable:o.getFieldValue("commandExecutable")});return e?(oe(!0),o.setFields([{name:"commandExecutable",errors:[e]}]),v.warning(e),!1):!0},[F,i,o]);(0,b.useEffect)(()=>{se&&o.setFieldsValue({agentCardProtocol:"http://"})},[o,se]);let c=(0,b.useCallback)(async()=>{if(!ve())return;let e=Qt(o.getFieldValue("agentCardUrl"),o.getFieldValue("agentCardProtocol"),F==="local"?"http://":"https://");if(!e){v.warning("Please enter an A2A server URL first");return}Ae(!0);try{let a={agentCardUrl:e,apiKey:o.getFieldValue("apiKey")};if(F==="local"){let y=se;if(y)a.localRuntime={label:o.getFieldValue("name")||void 0,agentCardUrl:e,command:Xt(y.command,e)};else{let B=o.getFieldValue("commandArgs")||"",j=B?B.split(/\s+/).filter(Boolean):[],D=String(o.getFieldValue(["command","cwd"])||"").trim();a.localRuntime={label:o.getFieldValue("name")||void 0,agentCardUrl:e,command:{executable:String(o.getFieldValue("commandExecutable")||"").trim(),args:j,...D?{cwd:D}:{}}}}}let A=await W("/api/a2a/test-connection",a);if(A.data?.reachable){let y=A.data.agentCard;v.success(`Connected to "${A.data.agentName||e}"`)}else v.error(A.data?.error||"Connection failed")}catch{v.error("Connection test failed")}finally{Ae(!1)}},[o,W,F,se,ve]),h=(0,b.useCallback)(e=>{if(K(e),!e){o.resetFields(["key","name","description","type","prompt"]),P([]);return}let a=typeof e.graphDefinition=="object"&&e.graphDefinition!==null?e.graphDefinition:{},A=a.key||e.id,y=e.name||a.name||"";o.setFieldsValue({key:`${A}_ext`,name:y?`${y} (Extended)`:"",description:e.description||a.description||"",type:a.type||"react",prompt:a.prompt||""});let B=a.subAgents||[];P(B.map(j=>({originalKey:j,clone:!1})))},[o]),I=async(e,a)=>{let A=await Z(`/api/assistants/${e}`);if(!A.success)throw new Error(`Failed to fetch sub-agent "${e}" for cloning`);let y=A.data,B=typeof y.graphDefinition=="object"?y.graphDefinition:{},j={id:a,name:`${y.name} (Clone)`,description:y.description||"",graphDefinition:{...B,key:a,name:`${y.name} (Clone)`}},D=await W("/api/assistants",j);if(!D.success)throw new Error(D.message||`Failed to clone sub-agent "${e}"`);return D.data},U=e=>{let a={id:e.key,name:e.name,description:e.description||"",graphDefinition:{key:e.key,name:e.name,description:e.description||"",type:e.type,prompt:e.prompt||"",tools:[],skills:[],subAgents:e.type==="deep_agent"||e.type==="processing"?[]:void 0,middleware:[]}};if(e.type==="a2a_remote"&&(a.graphDefinition.agentCardUrl=Qt(e.agentCardUrl,e.agentCardProtocol,(e.a2aMode||F)==="local"?"http://":"https://"),e.apiKey&&(a.graphDefinition.apiKey=e.apiKey),e.timeout&&(a.graphDefinition.timeout=e.timeout),(e.a2aMode||F)==="local")){let A=se;if(A)a.graphDefinition.localRuntime={label:e.name||void 0,agentCardUrl:a.graphDefinition.agentCardUrl,command:Xt(A.command,a.graphDefinition.agentCardUrl)};else{let y=e.commandArgs||"",B=y?y.split(/\s+/).filter(Boolean):[],j=String(e.command?.cwd||"").trim();a.graphDefinition.localRuntime={label:e.name||void 0,agentCardUrl:a.graphDefinition.agentCardUrl,command:{executable:String(e.commandExecutable||"").trim(),args:B,...j?{cwd:j}:{}}}}}return a},ke=async(e,a)=>{if(!T)throw new Error("No parent agent selected");let A=w.filter(D=>D.clone);for(let D of A){if(!D.cloneKey||!D.cloneKey.trim())throw new Error(`Please provide a key for the cloned sub-agent "${D.originalKey}"`);if(!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(D.cloneKey))throw new Error(`Invalid key "${D.cloneKey}" for cloned sub-agent "${D.originalKey}". Key must start with a letter and contain only letters, numbers, underscores, or hyphens.`)}let y=[];for(let D of w)if(D.clone){let rn=await I(D.originalKey,D.cloneKey);a.push(rn),y.push(D.cloneKey)}else y.push(D.originalKey);let B=typeof T.graphDefinition=="object"?T.graphDefinition:{},j={key:e.key,name:e.name,description:e.description||"",extendsAgent:T.id,type:e.type||B.type};return e.prompt&&e.prompt!==B.prompt&&(j.prompt=e.prompt),(y.length>0||B.subAgents&&B.subAgents.length>0)&&(j.subAgents=y),{id:e.key,name:e.name,description:e.description||"",graphDefinition:j}},an=async()=>{if(d==="learn"){let e=H.trim();if(!e){v.error("Please describe the training goal");return}if(!L){v.error("No shared training project available");return}k(!0);try{let a=`agent-${Et(e+Date.now())}`,A=await W("/api/assistants",{id:a,name:a,graphDefinition:{key:a,name:a,description:"",type:"react",prompt:"To be trained",metadata:{trainingProjectId:L.id,learningPlaceholder:"true",architectureStatus:"undecided"}}});if(!A.data)throw new Error("Failed to create agent");let{roundTaskId:y}=await Lt({goal:e,targetAgentId:a,workspaceId:_??void 0,projectId:L.id,existingThreadId:Nt(Pe.tenantId,a),files:xe,post:W,put:Oe});v.success("Agent created \u2014 architect started building"),m(""),we([]),S("learn"),p?.(A.data,{initialMessage:Bt({goal:e,roundTaskId:y,targetAgentId:a,targetMode:"placeholder",files:xe,projectId:L.id,workspaceId:L.workspaceId??_??void 0}),projectId:L.id,initialMessageCustomRunConfig:{execution:{taskId:y}}}),r()}catch(a){v.error(a instanceof Error?a.message:"Failed to create agent")}finally{k(!1)}return}try{if(d==="scratch"&&z&&!ve())return;let e=await o.validateFields();k(!0);let a=[],A=d==="scratch"?U(e):await ke(e,a),y=await W("/api/assistants",A);if(y.success){v.success(d==="extend"?`Assistant created by extending "${T?.name}"`:"Assistant created successfully"),re();for(let B of a)p?.(B);p?.(y.data),r()}else v.error(y.message||"Failed to create assistant")}catch(e){if(e?.errorFields){let a={key:"Key (ID)",name:"Name",description:"Description",prompt:"System Prompt"},A=e.errorFields.map(y=>a[String((y.name??[])[0])]??String((y.name??[])[0])).filter(Boolean);v.warning(A.length>0?`Please complete the required fields: ${[...new Set(A)].join(", ")}`:"Please complete the required fields");return}v.error(e.message||"An error occurred while creating the assistant")}finally{k(!1)}},qe=T?.graphDefinition?.subAgents||[],on=d==="extend"&&T&&qe.length>0;return(0,t.jsxs)(fe,{title:"Create New Assistant",open:n,onCancel:()=>{re(),r()},footer:[(0,t.jsx)(J,{onClick:()=>{re(),r()},children:"Cancel"},"cancel"),(0,t.jsx)(J,{type:"primary",icon:d==="extend"?(0,t.jsx)(Ee,{}):d==="learn"?(0,t.jsx)(nt,{}):(0,t.jsx)(ot,{}),loading:f,disabled:d==="learn"&&(Q||!L),onClick:an,children:d==="extend"?"Create (Extend)":d==="learn"?"Start Learning":"Create"},"submit")],width:760,children:[d==="extend"&&(0,t.jsxs)("div",{style:{marginBottom:20},children:[(0,t.jsx)(ne,{type:"secondary",style:{display:"block",marginBottom:8},children:"Parent Agent"}),(0,t.jsx)(jt,{value:T?.id,onSelect:h}),T&&(0,t.jsx)(ne,{type:"secondary",style:{display:"block",marginTop:4,fontSize:12},children:"Fields left unchanged will be inherited from the parent agent."})]}),d==="extend"&&T&&(0,t.jsx)(Ke,{style:{margin:"12px 0"}}),d==="learn"&&(0,t.jsxs)("div",{children:[(0,t.jsx)(ne,{style:{display:"block",marginBottom:8},children:"Describe what the agent should do."}),(0,t.jsx)(V.TextArea,{rows:3,value:H,onChange:e=>m(e.target.value),placeholder:"e.g. Handle price disputes using the price protection policy"}),L&&(0,t.jsxs)("div",{style:{marginTop:12},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[(0,t.jsx)(ne,{type:"secondary",children:"Reference Files"}),(0,t.jsx)(Ue,{project:L,projects:me,value:L?.id??null,onChange:ge,loading:Q})]}),(0,t.jsx)(Mt,{projectId:L.id,value:xe,onChange:we}),(0,t.jsx)(ne,{type:"secondary",style:{display:"block",marginTop:6,fontSize:12},children:"Optional \u2014 uploaded to the shared training workspace and attached to the learning round; the architect reads them as round material."})]}),!L&&!Q&&(0,t.jsx)("div",{style:{marginTop:12},children:(0,t.jsx)(Ue,{project:L,projects:me,value:null,onChange:ge,loading:Q})})]}),d!=="learn"&&(0,t.jsxs)(R,{form:o,layout:"vertical",autoComplete:"off",initialValues:{type:"react",agentCardProtocol:"https://",a2aMode:"remote"},children:[(0,t.jsx)(R.Item,{name:"key",label:"Key (ID)",rules:[{required:!0,message:"Please enter a unique key"},{pattern:/^[a-zA-Z][a-zA-Z0-9_-]*$/,message:"Key must start with a letter and contain only letters, numbers, underscores, or hyphens"}],style:{marginBottom:16},children:(0,t.jsx)(V,{placeholder:"e.g., my_assistant"})}),(0,t.jsx)(R.Item,{name:"name",label:"Name",rules:[{required:!0,message:"Please enter a name"}],style:{marginBottom:16},children:(0,t.jsx)(V,{placeholder:"e.g., My Assistant"})}),(0,t.jsx)(R.Item,{name:"description",label:"Description",rules:[{required:!0,message:"Please enter a description"}],style:{marginBottom:16},children:(0,t.jsx)(Zt,{placeholder:"Enter a description for this assistant...",autoSize:{minRows:2,maxRows:4}})}),(0,t.jsx)(R.Item,{name:"type",label:"Agent Type",rules:[{required:!0}],style:{marginBottom:16},children:(0,t.jsx)(Ze,{options:[{value:"react",label:"Executor"},{value:"deep_agent",label:"Orchestrator"},{value:"team",label:"Team"},{value:"processing",label:"Workflow"},{value:"a2a_remote",label:"A2A Remote"}],block:!0})}),(0,t.jsx)(ne,{type:"secondary",style:{fontSize:12,display:"block",marginTop:-12,marginBottom:16,lineHeight:1.5},children:Yt[N]||Yt.react}),z&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(R.Item,{label:"Connection Mode",style:{marginBottom:16},children:(0,t.jsxs)(Me.Group,{value:F,onChange:e=>{let a=e.target.value;s(a),o.setFieldValue("a2aMode",a),a==="local"&&o.setFieldValue("agentCardProtocol","http://"),ae(void 0)},optionType:"button",buttonStyle:"solid",children:[(0,t.jsx)(Me.Button,{value:"remote",children:"Remote URL"}),(0,t.jsx)(Me.Button,{value:"local",children:"Local Managed"})]})}),(0,t.jsx)(R.Item,{name:"a2aMode",noStyle:!0,hidden:!0,children:(0,t.jsx)(V,{})}),F==="local"&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(R.Item,{label:"Template",style:{marginBottom:16},children:(0,t.jsx)(Se,{placeholder:"Choose a template...",allowClear:!0,loading:ce,value:i,onChange:e=>{ae(e),e&&oe(!1)},options:de.map(e=>({value:e.key,label:e.name||e.key})),notFoundContent:ce?void 0:(0,t.jsx)(ne,{type:"secondary",style:{padding:8,display:"block"},children:'No templates. Use "Custom Command" below.'})})}),!i&&(0,t.jsx)(t.Fragment,{children:Be?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(R.Item,{name:"commandExecutable",label:"Executable",rules:[{required:!0,whitespace:!0,message:"Executable is required"}],style:{marginBottom:16},children:(0,t.jsx)(V,{placeholder:"e.g. node, opencode, /usr/local/bin/my-server"})}),(0,t.jsx)(R.Item,{name:"commandArgs",label:"Arguments",style:{marginBottom:16},children:(0,t.jsx)(V,{placeholder:"e.g. --serve --port 4301"})}),(0,t.jsx)(R.Item,{name:["command","cwd"],label:"Working directory",style:{marginBottom:16},children:(0,t.jsx)(V,{placeholder:"e.g. /Users/me/project"})}),(0,t.jsx)(J,{type:"link",onClick:()=>{oe(!1),o.setFieldsValue({commandExecutable:"",commandArgs:"",command:{cwd:void 0}})},style:{padding:0,marginBottom:16,display:"block"},children:"- Hide Custom Command"})]}):(0,t.jsx)(J,{type:"link",onClick:()=>oe(!0),style:{padding:0,marginBottom:16,display:"block"},children:"+ Custom Command"})})]}),(0,t.jsx)(R.Item,{label:"Agent Card URL",required:!0,style:{marginBottom:16},children:(0,t.jsxs)(Ye.Compact,{style:{width:"100%"},children:[(0,t.jsx)(R.Item,{name:"agentCardProtocol",noStyle:!0,children:(0,t.jsx)(Se,{style:{width:100},options:gn})}),(0,t.jsx)(R.Item,{name:"agentCardUrl",noStyle:!0,rules:[{required:!0,message:"Please enter the A2A server URL"}],children:(0,t.jsx)(V,{placeholder:F==="local"?"localhost:4301":"host:port or full URL"})}),(0,t.jsx)(J,{icon:(0,t.jsx)(tt,{}),onClick:c,loading:Le,children:"Test"})]})}),F==="remote"&&(0,t.jsx)(R.Item,{name:"apiKey",label:"API Key (optional)",style:{marginBottom:16},children:(0,t.jsx)(V.Password,{placeholder:"API key for authentication"})}),(0,t.jsx)(R.Item,{name:"timeout",label:"Timeout (ms)",style:{marginBottom:16},initialValue:3e5,children:(0,t.jsx)(Je,{min:1e3,max:36e5,style:{width:"100%"},placeholder:"300000"})})]}),!z&&(0,t.jsx)(R.Item,{name:"prompt",label:d==="extend"&&T?"System Prompt (leave unchanged to inherit from parent)":"System Prompt",rules:d==="scratch"?[{required:!0,message:"Please enter a system prompt"}]:[],children:(0,t.jsx)(Zt,{placeholder:d==="extend"&&T?"Leave empty to inherit parent's prompt, or enter a new prompt to override...":"Enter the system prompt for this agent...",autoSize:{minRows:4,maxRows:8},style:{fontFamily:"monospace",fontSize:13,lineHeight:1.6}})})]}),on&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Ke,{style:{margin:"12px 0"}}),(0,t.jsx)(ne,{strong:!0,style:{display:"block",marginBottom:8},children:"Sub-Agents"}),(0,t.jsx)(Wt,{subAgentKeys:qe,decisions:w,onChange:P})]})]})};var $=x(M()),{Paragraph:yn,Text:tn}=X,hn=[{key:"manual",icon:De,title:"Manual Configuration",description:"Define the agent's identity, type, tools, and system prompt yourself."},{key:"external",icon:st,title:"External Agent",description:"Connect an existing A2A-compatible agent by URL or manage a local runtime."},{key:"learn",icon:lt,title:"Learn with Agent Architect",description:"Describe the goal and let Agent Architect build and evaluate the agent with training context."}],nn=({open:n,onCancel:r,onSelectMethod:p,focusTriggerAfterClose:l=!0})=>(0,$.jsx)(fe,{title:"Choose how to create your agent",open:n,onCancel:r,footer:null,width:560,centered:!0,destroyOnHidden:!0,focusTriggerAfterClose:l,children:(0,$.jsxs)("div",{style:{padding:"8px 4px 4px"},children:[(0,$.jsx)(yn,{style:{color:"#595959",fontSize:15,margin:"8px 0 24px"},children:"Choose the path that best fits the agent you want to build."}),(0,$.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:12},children:hn.map(g=>{let o=g.icon;return(0,$.jsxs)(J,{type:"default",onClick:()=>p(g.key),"aria-label":g.title,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,$.jsx)("div",{style:{width:40,height:40,borderRadius:12,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:"#6366f1",background:"#eeeeff"},children:(0,$.jsx)(o,{size:19})}),(0,$.jsxs)("div",{style:{minWidth:0},children:[(0,$.jsx)(tn,{strong:!0,style:{display:"block",fontSize:15,marginBottom:3},children:g.title}),(0,$.jsx)(tn,{style:{color:"#737373",lineHeight:1.5},children:g.description})]})]},g.key)})}),(0,$.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,flexWrap:"wrap",marginTop:24},children:(0,$.jsx)(J,{onClick:r,children:"Not now"})})]})});var G=x(M()),bn=n=>{let r=n;if(typeof n=="string")try{r=JSON.parse(n)}catch{return{}}return r!==null&&typeof r=="object"&&!Array.isArray(r)?r:{}},Da=()=>{let{get:n,del:r,put:p}=ye(),[l,g]=(0,u.useState)([]),[o,f]=(0,u.useState)({}),[k,d]=(0,u.useState)(null),[S,H]=(0,u.useState)(!1),[m,T]=(0,u.useState)(null),[K,w]=(0,u.useState)("graph"),[P,N]=(0,u.useState)(null),[z,F]=(0,u.useState)(null),[s,i]=(0,u.useState)(null),[ae,de]=(0,u.useState)(!1),[be,ce]=(0,u.useState)(!0),[pe,q]=(0,u.useState)(!1),[Le,Ae]=(0,u.useState)("learn"),[Be,oe]=(0,u.useState)({}),[Z,W]=(0,u.useState)(null),[Oe,Pe]=(0,u.useState)(!1),_=(0,u.useCallback)(async()=>{H(!0);try{let[c,h]=await Promise.all([n("/api/assistants"),n("/api/assistants/stats").catch(()=>null)]);if(c.success&&c.data?.records&&g(c.data.records),h?.success&&h.data?.records){let I={};for(let U of h.data.records)I[U.id]=U;f(I),d(h.cache?.expiresAt??null)}}catch{v.error("Failed to load agents")}finally{H(!1)}},[n]);(0,u.useEffect)(()=>{_()},[_]);let me=u.default.useMemo(()=>Rt(l),[l]),Q=l.find(c=>c.id===m)??null,$e=(0,u.useCallback)((c,h="graph")=>{T(c),w(h),N(null),i(null)},[]),ge=Ct(),Ce=(0,u.useCallback)((c,h)=>{let I=l.find(U=>U.id===c)?.name??"Agent";ge({component_key:"agent_detail_side_app",data:{assistantId:c,initialTab:h},message:I})},[l,ge]),L=(0,u.useCallback)(()=>{ce(!0),de(!0)},[]),xe=(0,u.useCallback)(c=>{let I={manual:{mode:"scratch",values:{}},external:{mode:"scratch",values:{type:"a2a_remote"}},learn:{mode:"learn",values:{}}}[c];Ae(I.mode),oe(I.values),ce(!1),de(!1),q(!0)},[]),we=(0,u.useCallback)(async(c,h)=>{let I=bn(c.graphDefinition),U;try{U=await p(`/api/assistants/${c.id}`,{name:h.name!==void 0?h.name:c.name,description:h.description!==void 0?h.description:c.description,graphDefinition:{...I,...h}})}catch(ke){throw v.error("Failed to save agent"),ke}if(!U.success)throw v.error("Failed to save agent"),new Error("Failed to save agent");v.success("Saved"),_()},[p,_]),Fe=(0,u.useCallback)(c=>{g(h=>h.map(I=>I.id===c.id?c:I))},[]),re=(0,u.useCallback)(c=>{W(c)},[]),se=(0,u.useCallback)(async()=>{if(Z){Pe(!0);try{(await r(`/api/assistants/${Z}`)).success?(v.success("Agent deleted"),g(h=>h.filter(I=>I.id!==Z)),_(),W(null)):v.error("Failed to delete agent")}catch{v.error("Failed to delete agent")}finally{Pe(!1)}}},[Z,r,_]),ve=(0,u.useCallback)(async c=>{if(!(await r(`/api/assistants/${c}`)).success)throw new Error("Failed to delete agent");v.success("Agent deleted"),g(I=>I.filter(U=>U.id!==c)),_()},[r,_]);return(0,G.jsxs)("div",{style:{height:"100%",background:"#fafafa",overflow:"hidden"},children:[Q?(0,G.jsx)(Tt,{defaultProjectId:s??void 0,children:(0,G.jsx)(Ot,{assistant:Q,allAssistants:l,onBack:()=>T(null),onDeleted:ve,onSave:we,onAssistantUpdated:Fe,onAgentListInvalidated:_,initialTab:K,initialMessage:P,initialMessageCustomRunConfig:z,initialProjectId:s})},Q.id):(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(Ut,{items:me,assistants:l,stats:o,statsExpiresAt:k,loading:S,onItemClick:c=>Ce(c,"graph"),onOpenPlayground:c=>Ce(c,"playground"),onOpenEval:c=>Ce(c,"eval"),onCreate:L,onDelete:re})}),(0,G.jsx)(nn,{open:ae,onCancel:()=>{ce(!0),de(!1)},onSelectMethod:xe,focusTriggerAfterClose:be}),(0,G.jsx)(en,{open:pe,initialMode:Le,initialValues:Be,onCancel:()=>q(!1),onSuccess:(c,h)=>{q(!1),g(I=>I.some(ke=>ke.id===c.id)?I:[c,...I]),$e(c.id,"graph"),N(h?.initialMessage??null),F(h?.initialMessageCustomRunConfig??null),i(h?.projectId??null),_()}}),(0,G.jsx)(fe,{title:"Delete Agent",open:Z!==null,onCancel:()=>W(null),onOk:se,okText:"Delete",okButtonProps:{danger:!0,loading:Oe},cancelText:"Cancel",children:(0,G.jsx)("p",{children:"This action cannot be undone."})})]})};export{Da as AgentGovernanceWorkbench};
|
package/dist/embed/{embed-page-MessageGraph-CZQROEO7.js → embed-page-MessageGraph-E6DZDT65.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as W,d as V}from"./embed-page-chunk-KEL6XU6R.js";import{b as N,d as U,e as k}from"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import{
|
|
1
|
+
import{c as W,d as V}from"./embed-page-chunk-KEL6XU6R.js";import{b as N,d as U,e as k}from"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import{Ha as b,Ja as z,Ka as F,La as H,Ma as L,Wa as R,Xa as $,Ya as J}from"./embed-page-chunk-U276WBDI.js";import"./embed-page-chunk-HEMNMC4X.js";import{a as g}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Dc as D,Ia as O,Rc as G,Sc as w,Vc as _,W as v,aa as M,gb as P,lb as B,nc as E}from"./embed-page-chunk-O4QK5LWZ.js";import{a as C}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as p}from"./embed-page-chunk-6Y3UYJ6Z.js";var s=p(C());var S=p(C());var o=p(g());var se="tracePulse 1.4s ease-in-out infinite",ie={running:(0,o.jsx)(E,{style:{color:"#1890ff"}}),success:(0,o.jsx)(P,{style:{color:"#52c41a"}}),error:(0,o.jsx)(B,{style:{color:"#ff4d4f"}})};function ae({kind:e}){switch(e){case"human":return(0,o.jsx)(_,{});case"agent":return(0,o.jsx)(G,{});case"tool":return(0,o.jsx)(w,{});case"ai":return(0,o.jsx)(D,{});default:return(0,o.jsx)(w,{})}}var I=S.default.createContext({}),le=()=>S.default.useContext(I),de=({data:e,selected:i})=>{let{onJumpToMessage:a}=le(),t=e.isAnswer===!0,r=e.status==="running",d=(e.parallelCount??1)>1,m=!!(a&&e.messageId&&!e.messageId.startsWith("summary:")),f=e.toolCall?F(e.toolCall.name):e.label,y=()=>{if((e.kind==="tool"||e.kind==="agent")&&e.toolCall){let h=H(e.toolCall.response);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(z,{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)(b,{content:h})}),(0,o.jsx)(L,{ui:e.toolCall.ui})]})}return e.content?(0,o.jsx)(b,{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 ${t||i?"#6366f1":r?"#91caff":"#e5e7eb"}`,borderRadius:12,background:t?"#eef2ff":"#fff",boxShadow:r?"0 0 0 2px rgba(24,144,255,0.18)":i?"0 0 0 2px rgba(99,102,241,0.2)":"none",animation:r?se: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)(ae,{kind:e.kind}),(0,o.jsx)("span",{style:{fontWeight:t?700:600,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f}),d&&(0,o.jsxs)(O,{color:"purple",style:{marginInlineEnd:0,fontSize:10},children:["\u5E76\u53D1 \xD7",e.parallelCount]}),ie[e.status],m&&(0,o.jsx)(v,{type:"text",size:"small",onClick:()=>a?.(e.messageId),children:"\u5BF9\u8BDD"})]}),(0,o.jsx)("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:12},children:y()})]})},ce=({data:e,selected:i})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(k,{type:"target",position:N.Top}),(0,o.jsx)(de,{data:e,selected:i}),(0,o.jsx)(k,{type:"source",position:N.Bottom})]}),K={trace:ce};var Y=p(C());var u=p(g()),pe={running:"#1890ff",success:"#52c41a",error:"#ff4d4f"},Z=({graph:e,activeNodeId:i,onSelectNode:a})=>{let t=Y.default.useMemo(()=>new Map(e.nodes.map(r=>[r.id,r])),[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(r=>(0,u.jsxs)("div",{"data-testid":"trace-rail-phase",children:[(0,u.jsx)("div",{style:{fontSize:12,color:"#8c8c8c",marginBottom:4},children:r.title}),(0,u.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:r.nodeIds.map(d=>{let m=t.get(d);if(!m)return null;let f=d===i;return(0,u.jsx)(M,{title:m.data.label,children:(0,u.jsx)("button",{type:"button","data-testid":"trace-rail-tick",onClick:()=>a?.(d),style:{width:f?12:8,height:f?12:8,borderRadius:"50%",border:"none",padding:0,cursor:"pointer",background:pe[m.data.status],outline:f?"2px solid #6366f1":"none"}})},d)})})]},r.id))})};var l=p(g()),j=3,q=()=>{},fe=`
|
|
2
2
|
@keyframes tracePulse {
|
|
3
3
|
0%, 100% { box-shadow: 0 0 0 2px rgba(24,144,255,0.18); }
|
|
4
4
|
50% { box-shadow: 0 0 0 6px rgba(24,144,255,0.05); }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as C}from"./embed-page-chunk-OOZDPBUK.js";import{
|
|
1
|
+
import{s as C}from"./embed-page-chunk-OOZDPBUK.js";import{Ga as v}from"./embed-page-chunk-U276WBDI.js";import{a as w}from"./embed-page-chunk-HEMNMC4X.js";import{a as x}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{ga as b}from"./embed-page-chunk-O4QK5LWZ.js";import{a as D}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as d}from"./embed-page-chunk-6Y3UYJ6Z.js";var c=d(D());var E=d(w());var f=d(x());function p(s){if(!s||s.length===0)return{title:{text:"Chart",left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical"},xAxis:{type:"category",data:[]},yAxis:{type:"value"},series:[{type:"line",name:"Series 1",data:[]}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}};let i=s[0],t=Object.keys(i);if(t.length===0)return p([]);let r=t.filter(e=>{let n=i[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=s.map((a,l)=>a[n]!==void 0?String(a[n]):`Item ${l+1}`),u=s.map(a=>{let l=a[e];return typeof l=="number"?l:Number(l)||0});return{title:{text:"Chart",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:u}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}}}return{title:{text:"Chart",left:"left"},tooltip:{trigger:"axis"},legend:{right:0,orient:"vertical"},xAxis:{type:"category",data:s.map((e,n)=>`Item ${n+1}`)},yAxis:{type:"value"},series:[{type:"bar",name:"Count",data:s.map(()=>1)}],grid:{left:"3%",right:"4%",bottom:"3%",containLabel:!0}}}function S(s){if(!s||typeof s!="object"||!s.series||!Array.isArray(s.series)||s.series.length===0)return null;let i=s.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||`Series ${n+1}`};if(e.type==="pie"){let u=e.data.map((a,l)=>typeof a=="object"&&a!==null&&"value"in a?{value:a.value,name:a.name||`Item ${l+1}`}:typeof a=="number"?{value:a,name:`Item ${l+1}`}:null).filter(a=>a!==null);return u.length===0?null:{...o,data:u}}return o}).filter(e=>e!==null);if(i.length===0)return null;let t={...s,series:i},r=i[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=i[0].data;Array.isArray(n)&&n.length>0?Array.isArray(n[0])?e.data=n.map(o=>o[0]):e.data=n.map((o,u)=>`Item ${u+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:"Chart",left:"left"};else if(typeof t.title=="object"){let e=t.title;e.left||(e.left="left"),e.text||(e.text="Chart"),t.title=e}if(t.tooltip||(t.tooltip={trigger:r==="pie"?"item":"axis"}),!t.legend)i.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 j(s){let i=null;try{let n=typeof s=="string"?s:s.join("");i=(0,E.parse)(n)}catch(n){return{data:null,error:`Failed to parse JSON: ${n instanceof Error?n.message:String(n)}`}}if(!i||typeof i!="object")return{data:null,error:"Parsed data is not an object"};let t=i.series&&Array.isArray(i.series)&&i.series.length>0,r={table:Array.isArray(i.table)?i.table:void 0},e=null;if(i.echarts?e=i.echarts:t&&(e=i),e){let n=S(e);if(n)r.echarts=n;else if(r.table&&r.table.length>0)r.echarts=p(r.table);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=p(r.table):r.echarts=p([]);return{data:r,error:null}}var T=s=>{let{children:i}=s,t=(0,c.useRef)(null),r=(0,c.useRef)(null),e=(0,c.useRef)(null),[n,o]=(0,c.useState)(null);(0,c.useEffect)(()=>{if(!t.current)return;r.current||(r.current=C(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:l,error:g}=j(a);if(g||!l){console.warn("ReactChart failed to parse chart data:",g||"Unknown parse error"),r.current&&r.current.clear(),o(null);return}if(l.table&&Array.isArray(l.table)&&o(l.table),l.echarts)try{r.current.setOption(l.echarts,!0)}catch(h){let m=h instanceof Error?h.message:"Failed to render chart";console.error("Failed to set ECharts option:",h),r.current&&r.current.clear(),o(null)}let y=()=>{r.current&&r.current.resize()};return e.current&&(e.current.disconnect(),e.current=null),t.current&&typeof ResizeObserver<"u"&&(e.current=new ResizeObserver(h=>{requestAnimationFrame(()=>{y()})}),e.current.observe(t.current)),window.addEventListener("resize",y),()=>{e.current&&(e.current.disconnect(),e.current=null),window.removeEventListener("resize",y)}},[i]),(0,c.useEffect)(()=>()=>{e.current&&(e.current.disconnect(),e.current=null),r.current&&(r.current.dispose(),r.current=null)},[]);let u=a=>{if(!a||a.length===0)return[];if(Array.isArray(a[0])){let l=a[0];return a.slice(1).map((y,h)=>{let m={};return y.forEach((R,A)=>{m[l[A]||`col_${A}`]=R}),m})}return a};return(0,f.jsxs)(b,{children:[(0,f.jsx)("div",{ref:t,style:{width:"100%",height:"400px",minHeight:"300px"}}),n&&n.length>0&&(0,f.jsx)("div",{style:{marginTop:16},children:(0,f.jsx)(v,{component_key:"chart_table_data",data:{dataSource:u(n),message:"Data Details"},interactive:!0,default_open_in_side_app:!0})})]})};export{T as ReactChart};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as J,c as me,e as Q,f as Se,g as he,h as xe,i as ke,l as ve,m as be}from"./embed-page-chunk-AC6X2XRH.js";import{a as pe,b as ye,c as ge,d as fe,e as ue}from"./embed-page-chunk-SV2BM3WO.js";import"./embed-page-chunk-S4XZPBRM.js";import{m as le,q as ne,r as U,s as Te}from"./embed-page-chunk-QU52HUXW.js";import{a as _}from"./embed-page-chunk-MB65DZAX.js";import{Ia as D,Ja as j,La as ie,Tb as de,W as k,ab as ae,fc as ce,ka as te,oa as I,qb as re,rb as se,ta as N,xa as T,ya as oe,yc as K}from"./embed-page-chunk-O4QK5LWZ.js";import{a as ee}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as B}from"./embed-page-chunk-6Y3UYJ6Z.js";var S=B(ee());var m=B(ee());var e=B(_()),{Text:d}=ie,{TextArea:Ce}=N,Me=({data:v})=>{let{token:o}=j.useToken(),{config:C}=ne(),{put:V}=U(),R=me(t=>t.transform[2])>.6,q=le("__GLOBAL__");if(!v)return null;let{skill:g,onClick:F,onDelete:h}=v;if(!g)return null;let[i,A]=(0,m.useState)(g),O=i.subSkills&&i.subSkills.length>0,f=i.subSkills?.length||0,E=(0,m.useMemo)(()=>Math.min(12+Math.sqrt(f)*10,48),[f]),Y=i.metadata&&i.metadata.category||"global",b=(0,m.useMemo)(()=>i.metadata?Object.entries(i.metadata).filter(([t,n])=>t&&n):[],[i.metadata]),L=t=>{if(!t)return"";let n=t instanceof Date?t:new Date(t);return Number.isNaN(n.getTime())?"":n.toLocaleString()},G=t=>{navigator.clipboard.writeText(t)},[z,x]=(0,m.useState)(!1),[c,a]=(0,m.useState)({...g,id:g.name}),[s,u]=(0,m.useState)(b.map(([t,n])=>({key:t,value:n}))),[W,M]=(0,m.useState)(!1),[X,P]=(0,m.useState)(!1);(0,m.useEffect)(()=>{x(!1),A(g),a({...g,id:g.name}),u(Object.entries(g.metadata||{}).map(([t,n])=>({key:t,value:n})))},[g]);let l=(t,n)=>{if(t==="name"){a(r=>({...r,name:n,id:n}));return}a(r=>({...r,[t]:n}))},$=async t=>{t?.stopPropagation(),t?.preventDefault();try{let n=i.id||i.name;if(!n){T.error("Skill ID is missing");return}await q.skills.delete(n),T.success("Skill deleted successfully"),M(!1),h&&await h()}catch(n){T.error(n?.message||"An error occurred while deleting the skill")}},H=t=>{u(t);let n=t.reduce((r,p)=>(p.key&&(r[p.key]=p.value),r),{});a(r=>({...r,metadata:n}))},Z=(t,n,r)=>{let p=[...s];p[t]={...p[t],[n]:r},H(p)},ze=()=>{H([...s,{key:"",value:""}])},Be=async()=>{try{P(!0);let t={"Content-Type":"application/json"};C.apiKey&&(t.Authorization=`Bearer ${C.apiKey}`);let n={name:c.name,description:c.description,license:c.license||void 0,compatibility:c.compatibility||void 0,metadata:c.metadata||void 0,content:c.content||void 0,subSkills:c.subSkills||void 0},r=await V(`/api/skills/${i.id}`,n);if(r.success){T.success("Skill updated successfully");let p=r.data||c;A(p),a({...p,id:p.name}),u(Object.entries(p.metadata||{}).map(([Re,Ee])=>({key:Re,value:Ee}))),x(!1),F?.(p)}else T.error(r.message||"Failed to update skill")}catch(t){T.error(t.message||"An error occurred while updating the skill")}finally{P(!1)}},Ie=(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"row",gap:24},children:[(0,e.jsxs)("div",{style:{flex:"0 0 320px",display:"flex",flexDirection:"column",gap:12},children:[(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary},children:"Description"}),(0,e.jsx)(Ce,{value:c.description,onChange:t=>l("description",t.target.value),placeholder:"Description",rows:3})]}),(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary},children:"License"}),(0,e.jsx)(N,{value:c.license,onChange:t=>l("license",t.target.value),placeholder:"License"})]}),(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary},children:"Compatibility"}),(0,e.jsx)(N,{value:c.compatibility,onChange:t=>l("compatibility",t.target.value),placeholder:"Compatibility"})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:500},children:"Metadata"}),(0,e.jsx)(k,{size:"small",icon:(0,e.jsx)(K,{}),onClick:ze,children:"Add"})]}),(0,e.jsxs)(I,{direction:"vertical",size:8,style:{width:"100%"},children:[s.length===0&&(0,e.jsx)(d,{style:{fontSize:11,color:o.colorTextTertiary},children:"No metadata yet. Use Add to create one."}),s.map((t,n)=>(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[(0,e.jsxs)(d,{style:{fontSize:11,color:o.colorTextSecondary},children:["Meta ",n+1]}),(0,e.jsxs)(I,{style:{width:"100%"},size:8,wrap:!0,children:[(0,e.jsx)(N,{value:t.key,placeholder:"Key",style:{width:120},onChange:r=>Z(n,"key",r.target.value)}),(0,e.jsx)(N,{value:t.value,placeholder:"Value",style:{flex:1,minWidth:160},onChange:r=>Z(n,"value",r.target.value)})]})]},n))]})]}),(0,e.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6,minWidth:400},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary},children:"Content"}),(0,e.jsx)(Ce,{value:c.content,onChange:t=>l("content",t.target.value),placeholder:"Enter skill content here...",rows:30,style:{fontFamily:"monospace",fontSize:13,flex:1,minHeight:600}})]})]}),Ne=(0,e.jsxs)("div",{style:{width:z?960:720,maxHeight:"95vh",overflowY:"auto",padding:24},children:[(0,e.jsx)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:16},children:(0,e.jsxs)("div",{style:{flex:1},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[(0,e.jsx)(d,{strong:!0,style:{fontSize:18,fontWeight:600,color:o.colorText},children:i.name}),(0,e.jsx)(D,{style:{margin:0,fontSize:10,padding:"2px 8px",fontWeight:600},color:"geekblue",children:Y.toUpperCase()})]}),(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",gap:6},children:(0,e.jsx)(d,{style:{fontSize:11,color:o.colorTextTertiary,fontFamily:"monospace"},children:`>_ ${i.id}`})})]})}),z?Ie:(0,e.jsxs)(e.Fragment,{children:[i.description&&(0,e.jsx)("div",{style:{marginBottom:16},children:(0,e.jsxs)(d,{style:{fontSize:12,color:o.colorText,lineHeight:1.6,fontStyle:"italic"},children:['"',i.description,'"']})}),b.length>0&&(0,e.jsxs)("div",{style:{marginBottom:16},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[(0,e.jsx)(ce,{style:{fontSize:14,color:o.colorTextSecondary}}),(0,e.jsxs)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:500},children:["Metadata (",b.length,")"]})]}),(0,e.jsx)("div",{style:{border:`1px solid ${o.colorBorderSecondary}`,borderRadius:6,overflow:"hidden"},children:b.map(([t,n],r)=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"stretch",borderBottom:r===b.length-1?"none":`1px solid ${o.colorBorderSecondary}`},children:[(0,e.jsx)("div",{style:{width:140,padding:"8px 10px",background:o.colorFillTertiary,borderRight:`1px solid ${o.colorBorderSecondary}`,fontSize:11,color:o.colorTextSecondary,fontWeight:600,textTransform:"capitalize"},children:t}),(0,e.jsx)("div",{style:{flex:1,padding:"8px 10px",fontSize:11,color:o.colorText,wordBreak:"break-word"},children:n})]},t))})]}),O&&(0,e.jsxs)("div",{style:{marginBottom:16},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[(0,e.jsx)(ae,{style:{fontSize:14,color:o.colorTextSecondary}}),(0,e.jsxs)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:500},children:["Sub-Skills (",i.subSkills.length,")"]})]}),(0,e.jsx)(I,{size:[8,8],wrap:!0,children:i.subSkills.map((t,n)=>(0,e.jsx)(D,{style:{fontSize:11,padding:"4px 12px",backgroundColor:o.colorFillTertiary,color:o.colorText,border:`1px solid ${o.colorBorderSecondary}`},children:t},n))})]}),(i.license||i.compatibility)&&(0,e.jsx)("div",{style:{marginBottom:16},children:(0,e.jsxs)(I,{size:[8,8],wrap:!0,children:[i.license&&(0,e.jsx)(D,{icon:(0,e.jsx)(se,{}),style:{margin:0,fontSize:11,padding:"4px 12px",borderRadius:6,backgroundColor:o.colorInfoBg,color:o.colorInfo,border:`1px solid ${o.colorInfoBorder}`,fontWeight:500,lineHeight:"16px"},children:i.license}),i.compatibility&&(0,e.jsx)(D,{style:{margin:0,fontSize:11,padding:"4px 12px",borderRadius:6,backgroundColor:o.colorSuccessBg,color:o.colorSuccess,border:`1px solid ${o.colorSuccessBorder}`,fontWeight:500,lineHeight:"16px",display:"inline-flex",alignItems:"center",gap:4},children:i.compatibility})]})}),(i.createdAt||i.updatedAt)&&(0,e.jsx)("div",{style:{marginBottom:16},children:(0,e.jsxs)(I,{direction:"vertical",size:4,children:[i.createdAt&&(0,e.jsxs)(d,{style:{fontSize:11,color:o.colorTextTertiary,fontFamily:"monospace"},children:["Created: ",L(i.createdAt)]}),i.updatedAt&&(0,e.jsxs)(d,{style:{fontSize:11,color:o.colorTextTertiary,fontFamily:"monospace"},children:["Updated: ",L(i.updatedAt)]})]})}),i.content&&(0,e.jsxs)("div",{style:{marginBottom:0},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[(0,e.jsx)(de,{style:{fontSize:14,color:o.colorTextSecondary}}),(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:600,letterSpacing:.5},children:"CONTENT"})]}),(0,e.jsx)("div",{style:{padding:16,background:o.colorFillTertiary,border:`1px solid ${o.colorBorderSecondary}`,borderRadius:6,maxHeight:400,overflowY:"auto"},children:(0,e.jsx)(d,{style:{fontSize:12,color:o.colorText,lineHeight:1.7,whiteSpace:"pre-wrap",fontFamily:"monospace"},children:i.content})})]})]}),(0,e.jsx)(te,{style:{margin:"16px 0"}}),(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:z?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(k,{block:!0,onClick:()=>{x(!1),a(g)},style:{flex:1},children:"Cancel"}),(0,e.jsx)(k,{type:"primary",block:!0,onClick:Be,loading:X,style:{flex:1},children:"Save"})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(k,{type:"primary",block:!0,onClick:()=>x(!0),style:{flex:1},children:"Edit Skill"}),(0,e.jsx)(k,{danger:!0,onClick:t=>{t.stopPropagation(),$(t)},children:"Delete"}),(0,e.jsx)(k,{icon:(0,e.jsx)(re,{}),onClick:()=>G(i.id),title:"Copy ID"})]})})]});return(0,e.jsxs)("div",{style:{position:"relative",padding:4,overflow:"visible"},children:[(0,e.jsx)(Q,{type:"source",position:J.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:1,height:1,borderRadius:"50%",pointerEvents:"none"},isConnectable:!1}),(0,e.jsx)(Q,{type:"target",position:J.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:1,height:1,borderRadius:"50%",pointerEvents:"none"},isConnectable:!1}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",position:"relative"},onClick:()=>M(!0),children:[(0,e.jsx)("div",{style:{width:E,height:E,borderRadius:"50%",background:"#999",flexShrink:0,boxShadow:"0 1px 4px rgba(0,0,0,0.15)",transition:"transform 0.15s ease"},onMouseEnter:t=>{t.currentTarget.style.transform="scale(1.15)"},onMouseLeave:t=>{t.currentTarget.style.transform="scale(1)"}}),R&&(0,e.jsx)(d,{style:{position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:4,fontSize:10,color:o.colorTextSecondary,opacity:.45,whiteSpace:"nowrap",pointerEvents:"none",userSelect:"none"},children:i.name})]}),(0,e.jsx)(oe,{open:W,onCancel:()=>{M(!1),x(!1),a({...i,id:i.name})},footer:null,width:z?1e3:760,destroyOnClose:!0,title:null,styles:{body:{padding:0}},children:Ne})]})},we=Me;var y=B(_()),De=({onNodeClick:v})=>{let[o,C,V]=xe([]),[w,R,q]=ke([]),[g,F]=(0,S.useState)(!1),[h,i]=(0,S.useState)([]),[A,O]=(0,S.useState)(!1),[f,E]=(0,S.useState)(null),{token:Y}=j.useToken(),{get:b}=U(),L=(0,S.useMemo)(()=>({skill:we}),[]),G=(0,S.useMemo)(()=>f===null?o:o.map(a=>{let s=a.id===f||w.some(u=>u.source===f&&u.target===a.id||u.target===f&&u.source===a.id);return{...a,style:{opacity:s?1:.2,transition:"opacity 0.2s ease"}}}),[o,w,f]),z=(0,S.useMemo)(()=>f===null?w.map(a=>({...a,style:{stroke:"#1677ff",strokeWidth:1.5,opacity:.25,transition:"opacity 0.2s ease"}})):w.map(a=>{let s=a.source===f||a.target===f;return{...a,style:{stroke:"#1677ff",strokeWidth:s?2.5:1,opacity:s?1:.04,transition:"opacity 0.2s ease"}}}),[w,f]),x=async()=>{O(!0);try{let a=await b("/api/skills");a.success&&a.data&&Array.isArray(a.data.records)&&i(a.data.records)}catch(a){console.error("Failed to fetch skills:",a),i([])}finally{O(!1)}};(0,S.useEffect)(()=>{x()},[]),(0,S.useEffect)(()=>{if(!h||h.length===0){C([]),R([]);return}let a=[],s=new Map,u=[];h.forEach(l=>{s.set(l.name,l),l.subSkills&&l.subSkills.length>0&&l.subSkills.forEach($=>{h.find(H=>H.name===$)&&u.push({source:l.name,target:$})})});let W=h.map(l=>({id:l.name})),M=u.map(l=>({source:l.source,target:l.target})),X=fe(W).force("link",ge(M).id(l=>l.id).distance(80)).force("charge",ue().strength(-300)).force("center",pe(0,0)).force("collide",ye(30)).stop();for(let l=0;l<300;l++)X.tick();let P=W.map(l=>({id:l.id,type:"skill",data:{skill:s.get(l.id),onClick:()=>v?.(s.get(l.id)),onDelete:x},position:{x:l.x,y:l.y}}));u.forEach(l=>{s.has(l.source)&&s.has(l.target)&&a.push({id:`e${l.source}-${l.target}`,source:l.source,target:l.target,style:{stroke:"#1677ff",strokeWidth:2},type:"straight"})}),C(P),R(a)},[h,C,R,v]);let c=async()=>{await x()};return A?(0,y.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",background:"#fafafa"},children:"Loading skills..."}):(0,y.jsxs)("div",{style:{width:"100%",height:"100%",background:"#fafafa",position:"relative"},children:[(0,y.jsxs)(he,{nodes:G,edges:z,onNodesChange:V,onEdgesChange:q,onNodeMouseEnter:(a,s)=>E(s.id),onNodeMouseLeave:()=>E(null),nodeTypes:L,fitView:!0,children:[(0,y.jsx)(ve,{color:"#eee",gap:20}),(0,y.jsx)(be,{})]}),(0,y.jsx)("div",{style:{position:"absolute",top:20,right:20,zIndex:10},children:(0,y.jsx)(k,{type:"primary",size:"large",icon:(0,y.jsx)(K,{}),onClick:()=>F(!0),style:{height:48,width:48,borderRadius:"50%",boxShadow:Y.boxShadowTertiary,display:"flex",alignItems:"center",justifyContent:"center",padding:0}})}),(0,y.jsx)(Te,{open:g,onCancel:()=>F(!1),onSuccess:c})]})},Fe=v=>(0,y.jsx)(Se,{children:(0,y.jsx)(De,{...v})}),it=Fe;export{it as default};
|
|
1
|
+
import{b as J,c as me,e as Q,f as Se,g as he,h as xe,i as ke,l as ve,m as be}from"./embed-page-chunk-AC6X2XRH.js";import{a as pe,b as ye,c as ge,d as fe,e as ue}from"./embed-page-chunk-SV2BM3WO.js";import"./embed-page-chunk-S4XZPBRM.js";import{m as le,q as ne,r as U,s as Te}from"./embed-page-chunk-HEMNMC4X.js";import{a as _}from"./embed-page-chunk-MB65DZAX.js";import{Ia as D,Ja as j,La as ie,Tb as de,W as k,ab as ae,fc as ce,ka as te,oa as I,qb as re,rb as se,ta as N,xa as T,ya as oe,yc as K}from"./embed-page-chunk-O4QK5LWZ.js";import{a as ee}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as B}from"./embed-page-chunk-6Y3UYJ6Z.js";var S=B(ee());var m=B(ee());var e=B(_()),{Text:d}=ie,{TextArea:Ce}=N,Me=({data:v})=>{let{token:o}=j.useToken(),{config:C}=ne(),{put:V}=U(),R=me(t=>t.transform[2])>.6,q=le("__GLOBAL__");if(!v)return null;let{skill:g,onClick:F,onDelete:h}=v;if(!g)return null;let[i,A]=(0,m.useState)(g),O=i.subSkills&&i.subSkills.length>0,f=i.subSkills?.length||0,E=(0,m.useMemo)(()=>Math.min(12+Math.sqrt(f)*10,48),[f]),Y=i.metadata&&i.metadata.category||"global",b=(0,m.useMemo)(()=>i.metadata?Object.entries(i.metadata).filter(([t,n])=>t&&n):[],[i.metadata]),L=t=>{if(!t)return"";let n=t instanceof Date?t:new Date(t);return Number.isNaN(n.getTime())?"":n.toLocaleString()},G=t=>{navigator.clipboard.writeText(t)},[z,x]=(0,m.useState)(!1),[c,a]=(0,m.useState)({...g,id:g.name}),[s,u]=(0,m.useState)(b.map(([t,n])=>({key:t,value:n}))),[W,M]=(0,m.useState)(!1),[X,P]=(0,m.useState)(!1);(0,m.useEffect)(()=>{x(!1),A(g),a({...g,id:g.name}),u(Object.entries(g.metadata||{}).map(([t,n])=>({key:t,value:n})))},[g]);let l=(t,n)=>{if(t==="name"){a(r=>({...r,name:n,id:n}));return}a(r=>({...r,[t]:n}))},$=async t=>{t?.stopPropagation(),t?.preventDefault();try{let n=i.id||i.name;if(!n){T.error("Skill ID is missing");return}await q.skills.delete(n),T.success("Skill deleted successfully"),M(!1),h&&await h()}catch(n){T.error(n?.message||"An error occurred while deleting the skill")}},H=t=>{u(t);let n=t.reduce((r,p)=>(p.key&&(r[p.key]=p.value),r),{});a(r=>({...r,metadata:n}))},Z=(t,n,r)=>{let p=[...s];p[t]={...p[t],[n]:r},H(p)},ze=()=>{H([...s,{key:"",value:""}])},Be=async()=>{try{P(!0);let t={"Content-Type":"application/json"};C.apiKey&&(t.Authorization=`Bearer ${C.apiKey}`);let n={name:c.name,description:c.description,license:c.license||void 0,compatibility:c.compatibility||void 0,metadata:c.metadata||void 0,content:c.content||void 0,subSkills:c.subSkills||void 0},r=await V(`/api/skills/${i.id}`,n);if(r.success){T.success("Skill updated successfully");let p=r.data||c;A(p),a({...p,id:p.name}),u(Object.entries(p.metadata||{}).map(([Re,Ee])=>({key:Re,value:Ee}))),x(!1),F?.(p)}else T.error(r.message||"Failed to update skill")}catch(t){T.error(t.message||"An error occurred while updating the skill")}finally{P(!1)}},Ie=(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"row",gap:24},children:[(0,e.jsxs)("div",{style:{flex:"0 0 320px",display:"flex",flexDirection:"column",gap:12},children:[(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary},children:"Description"}),(0,e.jsx)(Ce,{value:c.description,onChange:t=>l("description",t.target.value),placeholder:"Description",rows:3})]}),(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary},children:"License"}),(0,e.jsx)(N,{value:c.license,onChange:t=>l("license",t.target.value),placeholder:"License"})]}),(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary},children:"Compatibility"}),(0,e.jsx)(N,{value:c.compatibility,onChange:t=>l("compatibility",t.target.value),placeholder:"Compatibility"})]}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:500},children:"Metadata"}),(0,e.jsx)(k,{size:"small",icon:(0,e.jsx)(K,{}),onClick:ze,children:"Add"})]}),(0,e.jsxs)(I,{direction:"vertical",size:8,style:{width:"100%"},children:[s.length===0&&(0,e.jsx)(d,{style:{fontSize:11,color:o.colorTextTertiary},children:"No metadata yet. Use Add to create one."}),s.map((t,n)=>(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[(0,e.jsxs)(d,{style:{fontSize:11,color:o.colorTextSecondary},children:["Meta ",n+1]}),(0,e.jsxs)(I,{style:{width:"100%"},size:8,wrap:!0,children:[(0,e.jsx)(N,{value:t.key,placeholder:"Key",style:{width:120},onChange:r=>Z(n,"key",r.target.value)}),(0,e.jsx)(N,{value:t.value,placeholder:"Value",style:{flex:1,minWidth:160},onChange:r=>Z(n,"value",r.target.value)})]})]},n))]})]}),(0,e.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6,minWidth:400},children:[(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary},children:"Content"}),(0,e.jsx)(Ce,{value:c.content,onChange:t=>l("content",t.target.value),placeholder:"Enter skill content here...",rows:30,style:{fontFamily:"monospace",fontSize:13,flex:1,minHeight:600}})]})]}),Ne=(0,e.jsxs)("div",{style:{width:z?960:720,maxHeight:"95vh",overflowY:"auto",padding:24},children:[(0,e.jsx)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:16},children:(0,e.jsxs)("div",{style:{flex:1},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[(0,e.jsx)(d,{strong:!0,style:{fontSize:18,fontWeight:600,color:o.colorText},children:i.name}),(0,e.jsx)(D,{style:{margin:0,fontSize:10,padding:"2px 8px",fontWeight:600},color:"geekblue",children:Y.toUpperCase()})]}),(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",gap:6},children:(0,e.jsx)(d,{style:{fontSize:11,color:o.colorTextTertiary,fontFamily:"monospace"},children:`>_ ${i.id}`})})]})}),z?Ie:(0,e.jsxs)(e.Fragment,{children:[i.description&&(0,e.jsx)("div",{style:{marginBottom:16},children:(0,e.jsxs)(d,{style:{fontSize:12,color:o.colorText,lineHeight:1.6,fontStyle:"italic"},children:['"',i.description,'"']})}),b.length>0&&(0,e.jsxs)("div",{style:{marginBottom:16},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[(0,e.jsx)(ce,{style:{fontSize:14,color:o.colorTextSecondary}}),(0,e.jsxs)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:500},children:["Metadata (",b.length,")"]})]}),(0,e.jsx)("div",{style:{border:`1px solid ${o.colorBorderSecondary}`,borderRadius:6,overflow:"hidden"},children:b.map(([t,n],r)=>(0,e.jsxs)("div",{style:{display:"flex",alignItems:"stretch",borderBottom:r===b.length-1?"none":`1px solid ${o.colorBorderSecondary}`},children:[(0,e.jsx)("div",{style:{width:140,padding:"8px 10px",background:o.colorFillTertiary,borderRight:`1px solid ${o.colorBorderSecondary}`,fontSize:11,color:o.colorTextSecondary,fontWeight:600,textTransform:"capitalize"},children:t}),(0,e.jsx)("div",{style:{flex:1,padding:"8px 10px",fontSize:11,color:o.colorText,wordBreak:"break-word"},children:n})]},t))})]}),O&&(0,e.jsxs)("div",{style:{marginBottom:16},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[(0,e.jsx)(ae,{style:{fontSize:14,color:o.colorTextSecondary}}),(0,e.jsxs)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:500},children:["Sub-Skills (",i.subSkills.length,")"]})]}),(0,e.jsx)(I,{size:[8,8],wrap:!0,children:i.subSkills.map((t,n)=>(0,e.jsx)(D,{style:{fontSize:11,padding:"4px 12px",backgroundColor:o.colorFillTertiary,color:o.colorText,border:`1px solid ${o.colorBorderSecondary}`},children:t},n))})]}),(i.license||i.compatibility)&&(0,e.jsx)("div",{style:{marginBottom:16},children:(0,e.jsxs)(I,{size:[8,8],wrap:!0,children:[i.license&&(0,e.jsx)(D,{icon:(0,e.jsx)(se,{}),style:{margin:0,fontSize:11,padding:"4px 12px",borderRadius:6,backgroundColor:o.colorInfoBg,color:o.colorInfo,border:`1px solid ${o.colorInfoBorder}`,fontWeight:500,lineHeight:"16px"},children:i.license}),i.compatibility&&(0,e.jsx)(D,{style:{margin:0,fontSize:11,padding:"4px 12px",borderRadius:6,backgroundColor:o.colorSuccessBg,color:o.colorSuccess,border:`1px solid ${o.colorSuccessBorder}`,fontWeight:500,lineHeight:"16px",display:"inline-flex",alignItems:"center",gap:4},children:i.compatibility})]})}),(i.createdAt||i.updatedAt)&&(0,e.jsx)("div",{style:{marginBottom:16},children:(0,e.jsxs)(I,{direction:"vertical",size:4,children:[i.createdAt&&(0,e.jsxs)(d,{style:{fontSize:11,color:o.colorTextTertiary,fontFamily:"monospace"},children:["Created: ",L(i.createdAt)]}),i.updatedAt&&(0,e.jsxs)(d,{style:{fontSize:11,color:o.colorTextTertiary,fontFamily:"monospace"},children:["Updated: ",L(i.updatedAt)]})]})}),i.content&&(0,e.jsxs)("div",{style:{marginBottom:0},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[(0,e.jsx)(de,{style:{fontSize:14,color:o.colorTextSecondary}}),(0,e.jsx)(d,{style:{fontSize:12,color:o.colorTextSecondary,fontWeight:600,letterSpacing:.5},children:"CONTENT"})]}),(0,e.jsx)("div",{style:{padding:16,background:o.colorFillTertiary,border:`1px solid ${o.colorBorderSecondary}`,borderRadius:6,maxHeight:400,overflowY:"auto"},children:(0,e.jsx)(d,{style:{fontSize:12,color:o.colorText,lineHeight:1.7,whiteSpace:"pre-wrap",fontFamily:"monospace"},children:i.content})})]})]}),(0,e.jsx)(te,{style:{margin:"16px 0"}}),(0,e.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:z?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(k,{block:!0,onClick:()=>{x(!1),a(g)},style:{flex:1},children:"Cancel"}),(0,e.jsx)(k,{type:"primary",block:!0,onClick:Be,loading:X,style:{flex:1},children:"Save"})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(k,{type:"primary",block:!0,onClick:()=>x(!0),style:{flex:1},children:"Edit Skill"}),(0,e.jsx)(k,{danger:!0,onClick:t=>{t.stopPropagation(),$(t)},children:"Delete"}),(0,e.jsx)(k,{icon:(0,e.jsx)(re,{}),onClick:()=>G(i.id),title:"Copy ID"})]})})]});return(0,e.jsxs)("div",{style:{position:"relative",padding:4,overflow:"visible"},children:[(0,e.jsx)(Q,{type:"source",position:J.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:1,height:1,borderRadius:"50%",pointerEvents:"none"},isConnectable:!1}),(0,e.jsx)(Q,{type:"target",position:J.Top,style:{left:"50%",top:"50%",transform:"translate(-50%, -50%)",background:"transparent",border:"none",width:1,height:1,borderRadius:"50%",pointerEvents:"none"},isConnectable:!1}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",position:"relative"},onClick:()=>M(!0),children:[(0,e.jsx)("div",{style:{width:E,height:E,borderRadius:"50%",background:"#999",flexShrink:0,boxShadow:"0 1px 4px rgba(0,0,0,0.15)",transition:"transform 0.15s ease"},onMouseEnter:t=>{t.currentTarget.style.transform="scale(1.15)"},onMouseLeave:t=>{t.currentTarget.style.transform="scale(1)"}}),R&&(0,e.jsx)(d,{style:{position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:4,fontSize:10,color:o.colorTextSecondary,opacity:.45,whiteSpace:"nowrap",pointerEvents:"none",userSelect:"none"},children:i.name})]}),(0,e.jsx)(oe,{open:W,onCancel:()=>{M(!1),x(!1),a({...i,id:i.name})},footer:null,width:z?1e3:760,destroyOnClose:!0,title:null,styles:{body:{padding:0}},children:Ne})]})},we=Me;var y=B(_()),De=({onNodeClick:v})=>{let[o,C,V]=xe([]),[w,R,q]=ke([]),[g,F]=(0,S.useState)(!1),[h,i]=(0,S.useState)([]),[A,O]=(0,S.useState)(!1),[f,E]=(0,S.useState)(null),{token:Y}=j.useToken(),{get:b}=U(),L=(0,S.useMemo)(()=>({skill:we}),[]),G=(0,S.useMemo)(()=>f===null?o:o.map(a=>{let s=a.id===f||w.some(u=>u.source===f&&u.target===a.id||u.target===f&&u.source===a.id);return{...a,style:{opacity:s?1:.2,transition:"opacity 0.2s ease"}}}),[o,w,f]),z=(0,S.useMemo)(()=>f===null?w.map(a=>({...a,style:{stroke:"#1677ff",strokeWidth:1.5,opacity:.25,transition:"opacity 0.2s ease"}})):w.map(a=>{let s=a.source===f||a.target===f;return{...a,style:{stroke:"#1677ff",strokeWidth:s?2.5:1,opacity:s?1:.04,transition:"opacity 0.2s ease"}}}),[w,f]),x=async()=>{O(!0);try{let a=await b("/api/skills");a.success&&a.data&&Array.isArray(a.data.records)&&i(a.data.records)}catch(a){console.error("Failed to fetch skills:",a),i([])}finally{O(!1)}};(0,S.useEffect)(()=>{x()},[]),(0,S.useEffect)(()=>{if(!h||h.length===0){C([]),R([]);return}let a=[],s=new Map,u=[];h.forEach(l=>{s.set(l.name,l),l.subSkills&&l.subSkills.length>0&&l.subSkills.forEach($=>{h.find(H=>H.name===$)&&u.push({source:l.name,target:$})})});let W=h.map(l=>({id:l.name})),M=u.map(l=>({source:l.source,target:l.target})),X=fe(W).force("link",ge(M).id(l=>l.id).distance(80)).force("charge",ue().strength(-300)).force("center",pe(0,0)).force("collide",ye(30)).stop();for(let l=0;l<300;l++)X.tick();let P=W.map(l=>({id:l.id,type:"skill",data:{skill:s.get(l.id),onClick:()=>v?.(s.get(l.id)),onDelete:x},position:{x:l.x,y:l.y}}));u.forEach(l=>{s.has(l.source)&&s.has(l.target)&&a.push({id:`e${l.source}-${l.target}`,source:l.source,target:l.target,style:{stroke:"#1677ff",strokeWidth:2},type:"straight"})}),C(P),R(a)},[h,C,R,v]);let c=async()=>{await x()};return A?(0,y.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center",background:"#fafafa"},children:"Loading skills..."}):(0,y.jsxs)("div",{style:{width:"100%",height:"100%",background:"#fafafa",position:"relative"},children:[(0,y.jsxs)(he,{nodes:G,edges:z,onNodesChange:V,onEdgesChange:q,onNodeMouseEnter:(a,s)=>E(s.id),onNodeMouseLeave:()=>E(null),nodeTypes:L,fitView:!0,children:[(0,y.jsx)(ve,{color:"#eee",gap:20}),(0,y.jsx)(be,{})]}),(0,y.jsx)("div",{style:{position:"absolute",top:20,right:20,zIndex:10},children:(0,y.jsx)(k,{type:"primary",size:"large",icon:(0,y.jsx)(K,{}),onClick:()=>F(!0),style:{height:48,width:48,borderRadius:"50%",boxShadow:Y.boxShadowTertiary,display:"flex",alignItems:"center",justifyContent:"center",padding:0}})}),(0,y.jsx)(Te,{open:g,onCancel:()=>F(!1),onSuccess:c})]})},Fe=v=>(0,y.jsx)(Se,{children:(0,y.jsx)(De,{...v})}),it=Fe;export{it as default};
|
package/dist/embed/{embed-page-TasksSideApp-5BYTO4KT.js → embed-page-TasksSideApp-QM5TZ7EG.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Je}from"./embed-page-chunk-
|
|
1
|
+
import{a as Je}from"./embed-page-chunk-H6TK3FAR.js";import{c as Ge,d as We}from"./embed-page-chunk-KEL6XU6R.js";import{b as be,e as Ce,h as _e,i as Fe}from"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import{C as ze,Qa as He,ab as Ve,bb as qe,cb as pe,db as Ne,eb as Ke,fb as Ue,ga as de,gb as Ye,ib as Qe,jb as Xe,k as le,kb as Ze,lb as et,qa as ce,va as G,wa as Oe}from"./embed-page-chunk-U276WBDI.js";import{j as Me,m as Ee}from"./embed-page-chunk-HEMNMC4X.js";import{a as $}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Fa as ae,Ia as De,La as se,W as ne,Y as Ae,Z as Be,_ as we,la as je,ra as F,ta as Te,va as Y,ya as Le}from"./embed-page-chunk-O4QK5LWZ.js";import{a as ie}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as v}from"./embed-page-chunk-6Y3UYJ6Z.js";var i=v(ie());var ot=v(ie());var a=v($()),vt=[{key:"pending",label:"Pending",color:"#7A7A7A"},{key:"in_progress",label:"In Progress",color:"#3b82f6"},{key:"review",label:"Review",color:"#f59e0b"},{key:"failed",label:"Failed",color:"#ef4444"},{key:"interrupted",label:"Interrupted",color:"#8b5cf6"},{key:"completed",label:"Completed",color:"#22c55e"}],tt={high:{label:"High",color:"#ef4444"},medium:{label:"Medium",color:"#f59e0b"},low:{label:"Low",color:"#22c55e"}};function wt(e){let o=typeof e=="string"?new Date(e):e,u=new Date().getTime()-o.getTime(),n=Math.floor(u/1e3),g=Math.floor(n/60),s=Math.floor(g/60),r=Math.floor(s/24);return n<60?"just now":g<60?`${g}m ago`:s<24?`${s}h ago`:r<30?`${r}d ago`:o.toLocaleDateString("en-US")}var Tt=G(({css:e,token:o})=>({container:e`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
height: 100%;
|
package/dist/embed/{embed-page-TeamWorkspace-5KN7ZZWQ.js → embed-page-TeamWorkspace-E7RFY3ZY.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as Pe,f as Ge,g as Be,h as _e,i as Fe,l as We,m as je}from"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import{$ as Ae,$a as He,A as ye,C as Z,
|
|
1
|
+
import{d as Pe,f as Ge,g as Be,h as _e,i as Fe,l as We,m as je}from"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import{$ as Ae,$a as He,A as ye,C as Z,I as Ce,Ia as Ee,N as Se,R as $e,T as Ne,U as Ie,W as we,X as Me,Y as B,Z as oe,_ as De,_a as Oe,g as he,ia as Le,n as J,o as ve,p as Te,q as Q,qa as se,r as O,ra as Re,t as G,va as I,z as be,za as ze}from"./embed-page-chunk-U276WBDI.js";import"./embed-page-chunk-HEMNMC4X.js";import{a as N}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Da as re,Ea as V,Ia as E,Ka as xe,La as R,W as ce,Z as X,aa as z,da as K,fa as me,ga as W,ja as j,ka as pe,oa as q,ua as ge,va as fe,ya as ue}from"./embed-page-chunk-O4QK5LWZ.js";import{a as H}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as h}from"./embed-page-chunk-6Y3UYJ6Z.js";var ie=h(H());var ee=h(H());var f=h(N()),pt=I(({token:e,css:t})=>({container:t`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
height: 100%;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as ce,c as pe}from"./embed-page-chunk-
|
|
1
|
+
import{a as ce,c as pe}from"./embed-page-chunk-WWTU55RX.js";import{a as xe}from"./embed-page-chunk-KEL6XU6R.js";import{a as ne,b as O,e as j,f as G,g as oe,h as ie,i as re,k as se,l as ae,m as le,n as de}from"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import{Ha as H,Y as L,h as Q,pa as te,s as F,u as ee,y as M}from"./embed-page-chunk-U276WBDI.js";import{r as $}from"./embed-page-chunk-HEMNMC4X.js";import{a as I}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Aa as J,Bc as K,Fa as Z,Ia as D,La as X,Z as E,aa as P,na as _,oa as A,tb as q,va as B,wa as Y}from"./embed-page-chunk-O4QK5LWZ.js";import{a as U}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as k}from"./embed-page-chunk-6Y3UYJ6Z.js";var r=k(U());var V=k(xe());var ue=k(U());var ge=k(I()),fe=({steps:t,graphDefinition:o,assistantId:n})=>{let l=(0,ue.useMemo)(()=>pe(o),[o]);return(0,ge.jsx)(ce,{dsl:l,steps:t,assistantId:n})};var e=k(I()),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 Fe,b as qe}from"./embed-page-chunk-
|
|
1
|
+
import{a as Fe,b as qe}from"./embed-page-chunk-KN7D66KL.js";import{b as He,c as fe}from"./embed-page-chunk-WWTU55RX.js";import"./embed-page-chunk-KEL6XU6R.js";import{f as _e}from"./embed-page-chunk-AC6X2XRH.js";import"./embed-page-chunk-S4XZPBRM.js";import{C as ae,F as le,Ha as Ne,K as Te,M as de,O as ce,S as De,W as Le,_ as Pe,ha as je,i as Me,l as se,la as _,m as Ae,ma as ge,na as Oe,qb as Be,ra as pe,sa as X,ta as Ee,wa as J}from"./embed-page-chunk-U276WBDI.js";import{r as V}from"./embed-page-chunk-HEMNMC4X.js";import{a as P}from"./embed-page-chunk-MB65DZAX.js";import"./embed-page-chunk-VW3NF5NT.js";import"./embed-page-chunk-5JDQ456X.js";import"./embed-page-chunk-Z7USDLHI.js";import{Aa as Se,Gc as We,La as U,W as q,Z as H,aa as Y,fc as ze,ga as Ce,pc as Ie,ra as $,ta as K,tb as Re,va as re,ya as G,yc as ie}from"./embed-page-chunk-O4QK5LWZ.js";import{a as oe}from"./embed-page-chunk-4BKXE5ON.js";import"./embed-page-chunk-IX4WLWCY.js";import"./embed-page-chunk-EUOOO2LS.js";import{e as W}from"./embed-page-chunk-6Y3UYJ6Z.js";var i=W(oe());var Q=W(oe());var L=W(P());function st(o){let s=o.split(/[\n\r.。;;!!??]+/).filter(Boolean)[0]?.trim()||"";return s=s.replace(/[,,]+$/,"").trim(),s.length>50&&(s=s.slice(0,50)),s||(s=o.slice(0,50).trim()),s}function at(o){let e=5381;for(let s=0;s<o.length;s++)e=(e<<5)+e+o.charCodeAt(s)>>>0;return e.toString(36).slice(0,6)}var ue=({open:o,onCancel:e,onCreated:s,type:m="processing"})=>{let{post:d}=V(),{trainingProjects:p,loading:b}=J(),[f,M]=(0,Q.useState)(null),[y]=$.useForm(),u=p.find(w=>w.id===f)??p[0]??null;return(0,Q.useEffect)(()=>{o&&(y.resetFields(),M(null))},[o,y]),(0,L.jsx)(G,{title:m==="workflow"?"New Workflow":"New Processing Workflow",open:o,onCancel:e,onOk:async()=>{if(m==="workflow"&&!u)return;let x=((await y.validateFields()).purpose||"").trim(),z=st(x),I=`wf-${at(x+Date.now())}`,g=m==="workflow"?{key:I,name:z,description:x,type:"workflow",prompt:"Complete the assigned task accurately and concisely.",metadata:{trainingProjectId:u?.id},workflowYaml:`name: ${I}
|
|
2
2
|
steps: []
|
|
3
3
|
`}:{key:I,name:z,description:x,type:"processing",prompt:`You are the orchestrator for workflow "${z}". Purpose: ${x}. Follow the topology to delegate tasks to sub-agents.`,tools:[],skills:[],subAgents:[],middleware:[{id:"topology",type:"topology",name:"Topology",description:"Workflow topology",enabled:!0,config:{edges:[]}}]};await d("/api/assistants",{id:I,name:z,description:x,graphDefinition:g}),y.resetFields(),s(I,x,m==="workflow"?u?.id:void 0)},okText:"Create",okButtonProps:{disabled:m==="workflow"&&(b||!u)},destroyOnClose:!0,children:(0,L.jsxs)($,{form:y,layout:"vertical",initialValues:{purpose:""},children:[(0,L.jsx)($.Item,{name:"purpose",label:"Purpose",rules:[{required:!0,message:"Please describe the workflow purpose"}],children:(0,L.jsx)(K.TextArea,{placeholder:"Describe what this workflow should do. Name and key will be generated automatically.",rows:4})}),m==="workflow"&&(0,L.jsx)(Fe,{project:u,projects:p,value:u?.id??null,onChange:M,loading:b})]})})};var Ke=W(oe());var t=W(P()),{Text:be}=U;function lt(o){if(!o||typeof o!="object")return null;let e=o;return{modelKey:e.modelKey||e.model||void 0,tools:Array.isArray(e.tools)?e.tools:[],middleware:Array.isArray(e.middleware)?e.middleware.filter(s=>s&&typeof s=="object"&&s.type):[],subAgents:Array.isArray(e.subAgents)?e.subAgents:[],skillCategories:Array.isArray(e.skillCategories)?e.skillCategories:[],runConfig:e.runConfig&&typeof e.runConfig=="object"?e.runConfig:void 0}}var dt={filesystem:(0,t.jsx)(Te,{size:12}),code_eval:(0,t.jsx)(Oe,{size:12}),browser:(0,t.jsx)(ce,{size:12}),sql:(0,t.jsx)(le,{size:12}),skill:(0,t.jsx)(ge,{size:12}),http:(0,t.jsx)(Le,{size:12}),scheduler:(0,t.jsx)(ae,{size:12}),metrics:(0,t.jsx)(Me,{size:12}),topology:(0,t.jsx)(de,{size:12}),ask_user_to_clarify:(0,t.jsx)(Pe,{size:12}),widget:(0,t.jsx)(se,{size:12}),date:(0,t.jsx)(Ae,{size:12}),task:(0,t.jsx)(de,{size:12}),custom:(0,t.jsx)(je,{size:12}),claw:(0,t.jsx)(_,{size:12}),collection:(0,t.jsx)(De,{size:12})},ct={filesystem:{bg:"rgba(34,197,94,0.08)",text:"#16a34a",border:"rgba(34,197,94,0.2)"},code_eval:{bg:"rgba(99,102,241,0.08)",text:"#4f46e5",border:"rgba(99,102,241,0.2)"},browser:{bg:"rgba(59,130,246,0.08)",text:"#2563eb",border:"rgba(59,130,246,0.2)"},sql:{bg:"rgba(249,115,22,0.08)",text:"#ea580c",border:"rgba(249,115,22,0.2)"},skill:{bg:"rgba(168,85,247,0.08)",text:"#9333ea",border:"rgba(168,85,247,0.2)"},http:{bg:"rgba(20,184,166,0.08)",text:"#0d9488",border:"rgba(20,184,166,0.2)"},scheduler:{bg:"rgba(245,158,11,0.08)",text:"#d97706",border:"rgba(245,158,11,0.2)"},metrics:{bg:"rgba(236,72,153,0.08)",text:"#db2777",border:"rgba(236,72,153,0.2)"},topology:{bg:"rgba(99,102,241,0.08)",text:"#4f46e5",border:"rgba(99,102,241,0.2)"},ask_user_to_clarify:{bg:"rgba(245,158,11,0.08)",text:"#d97706",border:"rgba(245,158,11,0.2)"},widget:{bg:"rgba(20,184,166,0.08)",text:"#0d9488",border:"rgba(20,184,166,0.2)"},date:{bg:"rgba(139,92,246,0.08)",text:"#7c3aed",border:"rgba(139,92,246,0.2)"},task:{bg:"rgba(99,102,241,0.08)",text:"#4f46e5",border:"rgba(99,102,241,0.2)"},custom:{bg:"rgba(107,114,128,0.08)",text:"#4b5563",border:"rgba(107,114,128,0.2)"},claw:{bg:"rgba(107,114,128,0.08)",text:"#4b5563",border:"rgba(107,114,128,0.2)"},collection:{bg:"rgba(6,182,212,0.08)",text:"#0891b2",border:"rgba(6,182,212,0.2)"}},gt={bg:"rgba(107,114,128,0.08)",text:"#4b5563",border:"rgba(107,114,128,0.2)"};function pt(o){let e=o.split(/[_-]+/).filter(Boolean);return e.length===1?e[0].slice(0,2).toUpperCase():e.map(s=>s[0]).join("").toUpperCase().slice(0,2)}var Ye=[{bg:"rgba(99,102,241,0.1)",text:"#6366f1"},{bg:"rgba(34,197,94,0.1)",text:"#22c55e"},{bg:"rgba(245,158,11,0.1)",text:"#f59e0b"},{bg:"rgba(59,130,246,0.1)",text:"#3b82f6"},{bg:"rgba(239,68,68,0.1)",text:"#ef4444"},{bg:"rgba(168,85,247,0.1)",text:"#a855f7"},{bg:"rgba(20,184,166,0.1)",text:"#14b8a6"},{bg:"rgba(236,72,153,0.1)",text:"#ec4899"}];function $e(o){return Ye[o%Ye.length]}var B=({icon:o,label:e,count:s,children:m})=>(0,t.jsxs)("div",{style:{marginBottom:10},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[(0,t.jsx)("span",{style:{color:"#6366f1",display:"flex",alignItems:"center"},children:o}),(0,t.jsx)(be,{strong:!0,style:{fontSize:11,color:"#52525b",textTransform:"uppercase",letterSpacing:"0.3px"},children:e}),(0,t.jsx)("span",{style:{fontSize:9,fontWeight:600,color:"#a1a1aa",background:"rgba(0,0,0,0.04)",borderRadius:8,padding:"1px 6px",lineHeight:"16px"},children:s})]}),m]}),Ge=({graphDef:o})=>{let e=(0,Ke.useMemo)(()=>lt(o),[o]);if(!e)return null;let s=e.middleware.filter(d=>d.enabled!==!1),m=!1;return e.tools.length===0&&s.length===0&&e.subAgents.length===0?null:(0,t.jsx)("div",{style:{pointerEvents:"auto"},children:(0,t.jsxs)("div",{style:{background:"rgba(255,255,255,0.5)",borderRadius:8,width:250,transition:"all 0.25s ease",overflow:"hidden"},children:[(0,t.jsx)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",background:"rgba(99,102,241,0.02)",borderBottom:"1px solid rgba(0,0,0,0.03)"},children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,t.jsx)("div",{style:{width:24,height:24,borderRadius:6,background:"rgba(99,102,241,0.05)",display:"flex",alignItems:"center",justifyContent:"center",color:"#6366f1"},children:(0,t.jsx)(_,{size:13})}),(0,t.jsx)(be,{strong:!0,style:{fontSize:12,color:"#1a1a1a"},children:"Environment"})]})}),(0,t.jsxs)("div",{style:{padding:"10px 12px 12px",maxHeight:"calc(60vh - 48px)",overflowY:"auto"},children:[e.tools.length>0&&(0,t.jsx)(B,{icon:(0,t.jsx)(Ee,{size:12}),label:"Tools",count:e.tools.length,children:(0,t.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:e.tools.map((d,p)=>{let b=$e(p);return(0,t.jsx)(Y,{title:d,placement:"top",children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:b.text,background:b.bg,cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[(0,t.jsx)("span",{style:{fontWeight:700,fontSize:9,opacity:.7},children:pt(d)}),(0,t.jsx)("span",{children:d})]})},d)})})}),s.length>0&&(0,t.jsx)(B,{icon:(0,t.jsx)(se,{size:12}),label:"Capabilities",count:s.length,children:(0,t.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:s.map(d=>{let p=ct[d.type]||gt,b=dt[d.type]||(0,t.jsx)(_,{size:12});return(0,t.jsx)(Y,{title:d.name||d.type,placement:"top",children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:p.text,background:p.bg,border:`1px solid ${p.border}`,cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[b,(0,t.jsx)("span",{children:d.name||d.type})]})},d.type)})})}),e.subAgents.length>0&&(0,t.jsx)(B,{icon:(0,t.jsx)(pe,{size:12}),label:"Sub-agents",count:e.subAgents.length,children:(0,t.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:e.subAgents.map((d,p)=>{let b=$e(p+3);return(0,t.jsx)(Y,{title:d,placement:"top",children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:b.text,background:b.bg,cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[(0,t.jsx)(pe,{size:10}),(0,t.jsx)("span",{children:d})]})},d)})})}),(e.modelKey||e.runConfig)&&(0,t.jsx)(B,{icon:(0,t.jsx)(ae,{size:12}),label:"Runtime",count:e.modelKey?1:0,children:(0,t.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[e.modelKey&&(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:"#4f46e5",background:"rgba(99,102,241,0.08)",border:"1px solid rgba(99,102,241,0.2)",cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[(0,t.jsx)(_,{size:10}),(0,t.jsxs)("span",{children:["Model: ",e.modelKey]})]}),!!e.runConfig?.databaseKey&&(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:"#ea580c",background:"rgba(249,115,22,0.08)",border:"1px solid rgba(249,115,22,0.2)",cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[(0,t.jsx)(le,{size:10}),(0,t.jsxs)("span",{children:["DB: ",String(e.runConfig?.databaseKey)]})]}),e.skillCategories&&e.skillCategories.length>0&&(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:6,fontSize:10,fontWeight:500,color:"#9333ea",background:"rgba(168,85,247,0.08)",border:"1px solid rgba(168,85,247,0.2)",cursor:"default",whiteSpace:"nowrap",lineHeight:"16px"},children:[(0,t.jsx)(ge,{size:10}),(0,t.jsxs)("span",{children:["Skills: ",e.skillCategories.join(", ")]})]})]})}),m&&(0,t.jsx)(B,{icon:(0,t.jsx)(ce,{size:12}),label:"Channels",count:0,children:(0,t.jsx)(be,{type:"secondary",style:{fontSize:10,fontStyle:"italic"},children:"No channels configured"})})]})]})})};var n=W(P()),{Text:F}=U;function Ue(o){if(typeof o=="string")try{let e=JSON.parse(o);return e&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}return o&&typeof o=="object"&&!Array.isArray(o)?o:null}function ft(o){let e=null;if(typeof o=="string")try{e=JSON.parse(o)}catch{return null}else o&&typeof o=="object"&&(e=o);if(!e)return null;if(e.type!=="workflow")return console.warn("[extractDSL] type is not 'workflow':",e.type),null;if(typeof e.workflowYaml!="string")return console.warn("[extractDSL] workflowYaml not found or not a string, keys:",Object.keys(e)),null;try{return fe(e.workflowYaml)}catch(s){return console.error("[extractDSL] expandWorkflow failed:",s.message,s),null}}function ut({workflows:o,selectedId:e,onSelect:s,onCreate:m,onDelete:d,dsl:p,agentNameMap:b,onSpecClick:f,environmentConfig:M}){let y=o.find(g=>g.id===e),[u,S]=(0,i.useState)(!0),[w,x]=(0,i.useState)(""),z=(0,i.useMemo)(()=>{let g=w.trim().toLowerCase();return g?o.filter(h=>h.name.toLowerCase().includes(g)||h.description.toLowerCase().includes(g)):o},[o,w]);(0,i.useEffect)(()=>{e?S(!1):(S(!0),x(""))},[e]);let I=g=>{s(g),S(!1)};return(0,n.jsx)("div",{style:{display:"flex",height:"100%",width:"100%"},children:(0,n.jsxs)("div",{style:{flex:1,position:"relative"},children:[y?(0,n.jsxs)(n.Fragment,{children:[p?(0,n.jsx)(He,{dsl:p,agentNameMap:b}):(0,n.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,n.jsx)(re,{tip:"Loading workflow DSL..."})}),!u&&(0,n.jsx)("div",{style:{position:"absolute",top:12,left:12,zIndex:10},children:(0,n.jsx)(q,{type:"default",icon:(0,n.jsx)(Ie,{}),onClick:()=>S(!0),style:{width:32,height:32,borderRadius:10,boxShadow:"0 2px 12px rgba(0,0,0,0.08)",border:"1px solid #f0f0f0",background:"rgba(255,255,255,0.95)",color:"#6366f1",display:"flex",alignItems:"center",justifyContent:"center"}})}),(0,n.jsxs)("div",{style:{position:"absolute",top:12,left:u?12:56,zIndex:10,display:"flex",alignItems:"center",gap:6,height:32,padding:"0 14px",background:"rgba(255,255,255,0.95)",borderRadius:10,boxShadow:"0 2px 12px rgba(0,0,0,0.08)",border:"1px solid #f0f0f0"},children:[(0,n.jsx)(X,{size:16,color:"#6366f1"}),(0,n.jsx)(F,{strong:!0,style:{fontSize:13},children:y.name}),(0,n.jsx)(ze,{style:{color:"#6366f1",cursor:"pointer",fontSize:15},onClick:f})]}),(0,n.jsx)("div",{style:{position:"absolute",top:12,right:12,zIndex:10,display:"flex",alignItems:"center",height:32,padding:"0 14px",background:"rgba(255,255,255,0.95)",borderRadius:10,boxShadow:"0 2px 12px rgba(0,0,0,0.08)",border:"1px solid #f0f0f0"},children:(0,n.jsx)(Se,{title:"Delete workflow",description:"This will permanently delete this workflow agent.",onConfirm:()=>d(y.id),okText:"Delete",cancelText:"Cancel",okButtonProps:{danger:!0},children:(0,n.jsx)(Re,{style:{color:"#ff4d4f",cursor:"pointer",fontSize:15}})})}),!u&&(0,n.jsx)("div",{style:{position:"absolute",top:52,left:u?12:56,zIndex:20},children:(0,n.jsx)(Ge,{graphDef:M},y.id)})]}):(0,n.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,n.jsx)(H,{description:"Select a workflow to view its graph"})}),u&&(0,n.jsxs)(n.Fragment,{children:[e&&(0,n.jsx)("div",{onClick:()=>S(!1),style:{position:"absolute",inset:0,zIndex:25,background:"transparent"}}),(0,n.jsxs)(Ce,{size:"small",title:(0,n.jsx)(F,{strong:!0,style:{fontSize:15,color:"#1a1a1a"},children:"Workflows"}),extra:(0,n.jsx)(q,{type:"text",size:"small",icon:(0,n.jsx)(ie,{}),onClick:m,style:{color:"#6366f1"}}),styles:{body:{padding:"12px 16px 16px"},header:{padding:"14px 16px 10px",borderBottom:"1px solid rgba(0,0,0,0.04)"}},style:{position:"absolute",left:16,top:e?56:48,bottom:16,width:300,zIndex:30,borderRadius:16,boxShadow:"0 4px 24px rgba(0,0,0,0.12)",border:"1px solid #f0f0f0",overflow:"auto",background:"rgba(255, 255, 255, 0.92)"},children:[(0,n.jsx)("div",{style:{marginBottom:12},children:(0,n.jsx)(K,{prefix:(0,n.jsx)(We,{style:{color:"#bbb"}}),placeholder:"Filter workflows...",value:w,onChange:g=>x(g.target.value),allowClear:!0,size:"small",style:{borderRadius:10,border:"1px solid rgba(0,0,0,0.06)"}})}),z.length===0?(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"32px 16px",color:"#bbb"},children:[(0,n.jsx)(X,{size:28,style:{marginBottom:10,opacity:.4}}),(0,n.jsx)(F,{type:"secondary",style:{fontSize:13},children:w.trim()?"No workflows match your search":"No workflows yet"})]}):z.map(g=>{let h=e===g.id;return(0,n.jsxs)("div",{onClick:()=>I(g.id),style:{display:"flex",alignItems:"center",gap:12,padding:"13px 15px",borderRadius:12,cursor:"pointer",transition:"all 0.2s ease",background:h?"rgba(99, 102, 241, 0.07)":"rgba(255, 255, 255, 0.5)",border:h?"1px solid rgba(99, 102, 241, 0.25)":"1px solid transparent",marginBottom:6},onMouseEnter:C=>{h||(C.currentTarget.style.background="rgba(255, 255, 255, 0.92)",C.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.05)",C.currentTarget.style.transform="translateY(-1px)",C.currentTarget.style.borderColor="rgba(0,0,0,0.06)")},onMouseLeave:C=>{h||(C.currentTarget.style.background="rgba(255, 255, 255, 0.5)",C.currentTarget.style.boxShadow="none",C.currentTarget.style.transform="translateY(0)",C.currentTarget.style.borderColor="transparent")},children:[(0,n.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:38,height:38,borderRadius:10,background:h?"rgba(99, 102, 241, 0.12)":"rgba(0, 0, 0, 0.04)",flexShrink:0,transition:"background 0.2s ease"},children:(0,n.jsx)(X,{size:18,color:h?"#6366f1":"#888"})}),(0,n.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,n.jsx)(F,{strong:!0,ellipsis:{tooltip:g.name},style:{fontSize:14,color:h?"#6366f1":"#1a1a1a",transition:"color 0.2s ease"},children:g.name}),g.description&&(0,n.jsx)("div",{style:{fontSize:12,color:"#999",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:3,lineHeight:"18px"},children:g.description})]})]},g.id)})]})]})]})})}var bt=()=>{let{get:o,del:e}=V(),{workspaceId:s,trainingProjects:m,loading:d}=J(),[p,b]=(0,i.useState)([]),[f,M]=(0,i.useState)(null),[y,u]=(0,i.useState)(null),[S,w]=(0,i.useState)(null),[x,z]=(0,i.useState)([]),[I,g]=(0,i.useState)(new Map),h=(0,i.useCallback)(async()=>{try{let r=await o("/api/assistants");if(r.success&&r.data?.records){let c=[],a=new Map;for(let l of r.data.records){if(l.id&&l.name){let k=typeof l.graphDefinition=="object"&&l.graphDefinition!==null?l.graphDefinition:void 0;a.set(l.id,{name:l.name,type:k?.type??"unknown"})}if(l.graphDefinition)if(typeof l.graphDefinition=="string")try{c.push(JSON.parse(l.graphDefinition))}catch{}else typeof l.graphDefinition=="object"&&c.push(l.graphDefinition)}z(c),g(a)}}catch{}},[o]),[C,me]=(0,i.useState)(!0),[Z,Xe]=(0,i.useState)(420),j=(0,i.useRef)(null),[Je,Ve]=(0,i.useState)(!0),[ye,we]=(0,i.useState)(null),[Qe,xe]=(0,i.useState)(!1),[he,O]=(0,i.useState)(!1),[Ze,ke]=(0,i.useState)(null),et=(0,i.useMemo)(()=>["create_workflow","update_workflow","validate_workflow","create_agent","update_agent","delete_agent"],[]),T=(0,i.useCallback)(async()=>{let r=await o("/api/assistants");if(r.success&&r.data?.records){let c=r.data.records.filter(a=>(Ue(a.graphDefinition)??void 0)?.type==="workflow").map(a=>{let l=Ue(a.graphDefinition)??void 0,k=typeof l?.workflowYaml=="string"?l.workflowYaml:"",E=l?.metadata,N=0;try{N=fe(k).nodes.filter(R=>R.type!=="terminal").length}catch{}return{id:a.id,name:a.name,description:a.description||"",type:"workflow",stepCount:N,trainingProjectId:typeof E?.trainingProjectId=="string"?E.trainingProjectId:void 0}});b(c)}we(null)},[o]),ee=(0,i.useCallback)(async r=>{try{let c=await o(`/api/assistants/${r}`);if(c.success&&c.data){let a=c.data.graphDefinition,l=ft(a);if(u(l),!a)w(null);else if(typeof a=="string")try{w(JSON.parse(a))}catch{w(null)}else w(typeof a=="object"?a:null)}}catch{u(null),w(null)}},[o]);(0,i.useEffect)(()=>{let r=!1;return(async()=>{try{await T(),await h()}catch(a){r||we(a instanceof Error?a.message:"Failed to load workflows")}finally{r||Ve(!1)}})(),()=>{r=!0}},[T]),(0,i.useEffect)(()=>{f?ee(f):u(null)},[f,ee]);let tt=(0,i.useCallback)(r=>{r.preventDefault(),j.current={startX:r.clientX,startWidth:Z}},[Z]);(0,i.useEffect)(()=>{let r=a=>{if(!j.current)return;let l=j.current.startX-a.clientX,k=Math.min(900,Math.max(400,j.current.startWidth+l));Xe(k)},c=()=>{j.current=null};return window.addEventListener("mousemove",r),window.addEventListener("mouseup",c),()=>{window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",c)}},[]);let nt=(0,i.useCallback)(r=>{M(r)},[]),ve=(0,i.useCallback)((r,c,a)=>{O(!1),T().then(()=>{M(r),a&&b(l=>l.map(k=>k.id===r?{...k,trainingProjectId:a}:k)),c&&ke({requestId:r,content:c})})},[T]),ot=(0,i.useCallback)(async r=>{await e(`/api/assistants/${r}`),f===r&&M(null),await T()},[e,T,f]),D=(0,i.useMemo)(()=>p.find(r=>r.id===f)||null,[p,f]),te=D?.trainingProjectId??m[0]?.id??null,rt=(0,i.useMemo)(()=>f&&D?{id:f,name:D.name,type:"workflow"}:null,[f,D]),it=(0,i.useMemo)(()=>{let r=y?.nodes.filter(v=>v.type!=="terminal"&&v.ref).map(v=>v.ref).filter((v,R,A)=>A.indexOf(v)===R)??[];if(r.length===0)return S;let c=x.filter(v=>{let R=v.key;return R&&r.includes(R)});if(c.length===0)return S;let a={...S??{}},l=new Set(a.tools??[]),k=[...a.middleware??[]],E=new Set(a.subAgents??[]),N=new Set(k.map(v=>v.type).filter(Boolean));for(let v of c){let R=v;for(let A of R.tools??[])l.add(A);for(let A of R.middleware??[]){let ne=A.type;ne&&!N.has(ne)&&(k.push(A),N.add(ne))}for(let A of R.subAgents??[])E.add(A)}return a.tools=Array.from(l),a.middleware=k,a.subAgents=Array.from(E),a},[y,S,x]);return Je?(0,n.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,n.jsx)(re,{size:"large",tip:"Loading workflows..."})}):ye?(0,n.jsx)(H,{description:ye}):p.length===0?(0,n.jsxs)("div",{style:{width:"100%",height:"100%"},children:[(0,n.jsx)(ue,{open:he,onCancel:()=>O(!1),onCreated:ve,type:"workflow"}),(0,n.jsx)(H,{description:"No workflow definitions found.",children:(0,n.jsx)(q,{type:"primary",icon:(0,n.jsx)(ie,{}),onClick:()=>O(!0),children:"Create Workflow"})})]}):(0,n.jsxs)("div",{style:{width:"100%",height:"100%"},children:[(0,n.jsx)(ue,{open:he,onCancel:()=>O(!1),onCreated:ve,type:"workflow"}),(0,n.jsx)(G,{title:D?.name,open:Qe,onCancel:()=>xe(!1),footer:null,width:"85vw",centered:!0,styles:{body:{maxHeight:"calc(85vh - 120px)",overflow:"auto",padding:"12px 24px 24px"}},children:D?.description?(0,n.jsx)(Ne,{content:D.description}):(0,n.jsx)(F,{type:"secondary",children:"No description set."})}),(0,n.jsx)(_e,{children:(0,n.jsxs)("div",{style:{height:"100%",width:"100%",position:"relative",overflow:"hidden"},children:[(0,n.jsx)(ut,{workflows:p,selectedId:f,onSelect:nt,onCreate:()=>O(!0),onDelete:ot,dsl:y,agentNameMap:I,onSpecClick:()=>xe(!0),environmentConfig:it}),!C&&f&&(0,n.jsx)("div",{style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",zIndex:20},children:(0,n.jsx)("div",{onClick:()=>me(!0),style:{writingMode:"vertical-rl",textOrientation:"mixed",padding:"16px 8px",background:"#6366f1",color:"#fff",borderRadius:"8px 0 0 8px",cursor:"pointer",fontSize:12,fontWeight:500,userSelect:"none"},children:"Copilot"})}),C&&f&&te&&!d&&(0,n.jsxs)("div",{style:{position:"absolute",right:16,top:48,bottom:12,zIndex:15,width:Z,borderRadius:16,overflow:"hidden",boxShadow:"0 4px 24px rgba(0,0,0,0.12)"},children:[(0,n.jsx)("div",{onMouseDown:tt,style:{position:"absolute",left:0,top:0,bottom:0,width:6,cursor:"ew-resize",zIndex:2,background:"transparent"}}),(0,n.jsx)(Be,{defaultWorkspaceId:s??void 0,defaultProjectId:te??void 0,children:(0,n.jsx)(qe,{workflowContext:rt,onClose:()=>me(!1),onToolCompleted:r=>{et.includes(r)&&(T(),f&&ee(f))},initialMessageRequest:Ze,onInitialMessageSubmitted:r=>ke(c=>c?.requestId===r?null:c)})},`${s??"default"}:${te??"default"}`)]})]})})]})},qt=bt;export{bt as WorkflowAutomationView,qt as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Aa as Y,Ca as Z,Q as N,a as C,b as P,c as F,d as X,e as G,f as Q,ub as ee,v as V,vb as te,xa as J,ya as x}from"./embed-page-chunk-U276WBDI.js";import{f as $,l as z,p as K}from"./embed-page-chunk-HEMNMC4X.js";import{a as L}from"./embed-page-chunk-MB65DZAX.js";import{M as j,va as B}from"./embed-page-chunk-O4QK5LWZ.js";import{a as H}from"./embed-page-chunk-4BKXE5ON.js";import{e as I}from"./embed-page-chunk-6Y3UYJ6Z.js";var l=I(H());var g=class extends Error{code;retryable;status;constructor(n,t,r,o){super(t),this.name="AgentWebAppRuntimeClientError",this.code=n,this.retryable=r,this.status=o}};function R(){return new g("STREAM_FAILED","Stream failed",!0)}var ce=new Set(["WEB_APP_NOT_FOUND","WEB_APP_DISABLED","USER_ID_REQUIRED","INVALID_USER_ID","PROJECT_NOT_ALLOWED","PROJECT_SELECTOR_DISABLED","MODEL_NOT_ALLOWED","FEATURE_DISABLED","THREAD_NOT_FOUND","STREAM_CONFLICT","STREAM_FAILED","INVALID_REQUEST","INTERNAL_ERROR"]);function k(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function b(e,n){return Object.keys(e).length===n.length&&n.every(r=>r in e)}function ue(e){return k(e)&&b(e,["code","message","retryable"])&&typeof e.code=="string"&&ce.has(e.code)&&typeof e.message=="string"&&typeof e.retryable=="boolean"}function le(e){if(!k(e))return!1;let n=e.data===void 0?["id","type","prompt"]:["id","type","prompt","data"];return b(e,n)&&typeof e.id=="string"&&typeof e.type=="string"&&typeof e.prompt=="string"&&(e.data===void 0||k(e.data))}var fe=new Set([C.HUMAN,C.AI,C.TOOL,C.INTERRUPT,C.MESSAGE_COMPLETED,C.MESSAGE_FAILED,C.THREAD_IDLE]);function Ae(e,n){let t;try{t=JSON.parse(e)}catch{throw R()}if(!k(t)||typeof t.type!="string")throw R();if(fe.has(t.type)||t.type==="error"&&k(t.data)&&!k(t.error)){let r=X(t,n);return r.length===0?[]:r}switch(t.type){case"message.delta":if(b(t,["type","text"])&&typeof t.text=="string")return[t];break;case"message.completed":if(b(t,["type","messageId"])&&typeof t.messageId=="string")return[t];break;case"tool.started":if(b(t,["type","id","name"])&&typeof t.id=="string"&&typeof t.name=="string")return[t];break;case"tool.completed":if(b(t,["type","id"])&&typeof t.id=="string")return[t];break;case"interrupt.created":if(b(t,["type","interrupt"])&&le(t.interrupt))return[t];break;case"genui.render":if(b(t,["type","block"])&&P(t.block))return[t];break;case"error":if(b(t,["type","error"])&&ue(t.error))return[t];break;case"stream.completed":if(b(t,["type"]))return[t];break}throw R()}function me(e){return e instanceof Error&&e.name==="AbortError"}async function ne(e,n){let t=F({allowGenUI:!0,allowInterrupts:!0}),r=e.getReader(),o=new TextDecoder,s="",i=!1,a=!1;try{for(;!i;){let p;try{p=await r.read()}catch(A){if(me(A))return;throw R()}p.done&&(a=!0);try{s+=o.decode(p.value,{stream:!p.done})}catch{throw R()}let c=s.split(/\r?\n\r?\n/);s=p.done?"":c.pop()??"";for(let A of c){let y=A.split(/\r?\n/).filter(m=>m==="data"||m.startsWith("data:")).map(m=>m==="data"?"":m.slice(5).replace(/^ /,""));if(y.length!==0){for(let m of Ae(y.join(`
|
|
2
|
+
`),t))if(await n(m),i=m.type==="stream.completed",i)break;if(i)break}}if(p.done)break}if(!i)throw R()}finally{if(!a)try{await r.cancel()}catch{}r.releaseLock()}}var ge=new Set(["WEB_APP_NOT_FOUND","WEB_APP_DISABLED","USER_ID_REQUIRED","INVALID_USER_ID","PROJECT_NOT_ALLOWED","PROJECT_SELECTOR_DISABLED","MODEL_NOT_ALLOWED","FEATURE_DISABLED","THREAD_NOT_FOUND","STREAM_CONFLICT","STREAM_FAILED","INVALID_REQUEST","INTERNAL_ERROR"]);function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function h(e,n,t=[]){let r=Object.keys(e);return n.every(o=>o in e)&&r.every(o=>n.includes(o)||t.includes(o))}function d(e){return typeof e=="string"}function M(e){if(!f(e)||!h(e,["id","projectId","createdAt","updatedAt"],["label"])||!d(e.id)||!d(e.projectId)||e.label!==void 0&&!d(e.label)||!d(e.createdAt)||!d(e.updatedAt))return;let n=new Date(e.createdAt),t=new Date(e.updatedAt);if(!(Number.isNaN(n.getTime())||Number.isNaN(t.getTime())))return{id:e.id,projectId:e.projectId,...e.label===void 0?{}:{label:e.label},createdAt:n,updatedAt:t}}function re(e){if(!f(e)||e.success!==!1||!f(e.error))return!1;let n=e.error;return h(e,["success","error"])&&h(n,["code","message","retryable"])&&typeof n.code=="string"&&ge.has(n.code)&&typeof n.message=="string"&&typeof n.retryable=="boolean"}function he(e){if(!f(e))return!1;let n=["projectSelector","modelSelector","threadManagement","attachments","hitl","genUI"];return h(e,n,["files"])&&n.every(t=>typeof e[t]=="boolean")&&(e.files===void 0||typeof e.files=="boolean")}function ye(e){return Array.isArray(e)&&e.length<=6&&e.every(n=>f(n)&&h(n,["label","text"])&&d(n.label)&&n.label.length>=1&&n.label.length<=40&&d(n.text)&&n.text.length>=1&&n.text.length<=500)}function be(e){return f(e)&&h(e,[],["title","welcomeMessage","primaryColor","quickPrompts"])&&(e.title===void 0||d(e.title))&&(e.welcomeMessage===void 0||d(e.welcomeMessage))&&(e.primaryColor===void 0||d(e.primaryColor))&&(e.quickPrompts===void 0||ye(e.quickPrompts))}function we(e){if(!f(e)||!h(e,["webApp","projects","models"],["thread"])||!f(e.webApp))return;let n=e.webApp;if(!h(n,["id","name","assistant","defaultProjectId","features","appearance","identityAssurance"],["description","defaultModelKey"])||!d(n.id)||!d(n.name)||!d(n.defaultProjectId)||n.description!==void 0&&!d(n.description)||n.defaultModelKey!==void 0&&!d(n.defaultModelKey)||n.identityAssurance!=="unverified"||!f(n.assistant)||!h(n.assistant,["id","name"],["description"])||!d(n.assistant.id)||!d(n.assistant.name)||n.assistant.description!==void 0&&!d(n.assistant.description)||!he(n.features)||!be(n.appearance)||!Array.isArray(e.projects)||!e.projects.every(r=>f(r)&&h(r,["id","name"])&&d(r.id)&&d(r.name))||!Array.isArray(e.models)||!e.models.every(r=>f(r)&&h(r,["key","label"])&&d(r.key)&&d(r.label)))return;let t=e.thread===void 0?void 0:M(e.thread);if(!(e.thread!==void 0&&!t))return{...e,...t?{thread:t}:{}}}function Ee(e){if(!f(e)||!h(e,["records","total"])||!Array.isArray(e.records)||typeof e.total!="number")return;let n=e.records.map(M);return n.every(t=>t!==void 0)?{records:n,total:e.total}:void 0}function Ce(e){return f(e)&&d(e.id)&&(e.role==="human"||e.role==="ai")&&(e.content===void 0||d(e.content)||Array.isArray(e.content)&&e.content.every(n=>P(n)!==void 0))}function Re(e){return f(e)&&h(e,["messages"])&&Array.isArray(e.messages)&&e.messages.every(Ce)?e:void 0}function Se(e){return f(e)&&h(e,["ref","name","mimeType","size"])&&d(e.ref)&&d(e.name)&&d(e.mimeType)&&typeof e.size=="number"?e:void 0}function oe(e,n){return t=>f(t)&&h(t,e)&&n(t)?t:void 0}var D=class{constructor(n){this.options=n;this.baseUrl=`${n.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(n.webAppId)}/runtime`,this.fetchImplementation=n.fetch??globalThis.fetch.bind(globalThis)}baseUrl;fetchImplementation;async bootstrap(n={},t){return this.request("bootstrap",we,{query:n,signal:t})}async listThreads(n={},t){return this.request("threads",Ee,{query:n,signal:t})}async createThread(n={},t){return this.request("threads",M,{method:"POST",body:n,signal:t})}async updateThread(n,t,r){return this.request(`threads/${encodeURIComponent(n)}`,M,{method:"PATCH",body:t,signal:r})}async deleteThread(n,t={},r){await this.request(`threads/${encodeURIComponent(n)}`,oe(["id"],o=>d(o.id)),{method:"DELETE",query:t,signal:r})}async getMessages(n,t={},r){return this.request(`threads/${encodeURIComponent(n)}/messages`,Re,{query:t,signal:r})}async streamMessage(n,t,r,o){return this.streamRequest(`threads/${encodeURIComponent(n)}/messages/stream`,t,r,o)}async resumeInterrupt(n,t,r,o,s){return this.streamRequest(`threads/${encodeURIComponent(n)}/interrupts/${encodeURIComponent(t)}/resume`,r,o,s)}async streamRequest(n,t,r,o){let s;try{s=await this.fetchRequest(n,{method:"POST",body:t,signal:o})}catch(i){throw se(i)||i instanceof g?i:new g("STREAM_FAILED","Stream failed",!0)}if(s.ok||await this.throwResponseError(s),!s.body||!s.headers.get("content-type")?.toLowerCase().includes("text/event-stream")){if(s.body)try{await s.body.cancel()}catch{}throw new g("STREAM_FAILED","Stream failed",!0,s.status)}await ne(s.body,r)}async abort(n,t={},r){await this.request(`threads/${encodeURIComponent(n)}/abort`,oe(["aborted"],o=>typeof o.aborted=="boolean"),{method:"POST",query:t,signal:r})}async uploadAttachment(n,t,r={},o){let s=new FormData,i=typeof File<"u"&&t instanceof File?t.name:"attachment";return s.append("file",t,i),this.request(`threads/${encodeURIComponent(n)}/attachments`,Se,{method:"POST",query:r,body:s,signal:o})}async request(n,t,r={}){let o;try{o=await this.fetchRequest(n,r)}catch(a){throw se(a)||a instanceof g?a:new g("INTERNAL_ERROR","Request failed",!0)}let s;try{s=await o.json()}catch{throw this.internalError(o.status)}if(re(s))throw new g(s.error.code,s.error.message,s.error.retryable,o.status);if(!o.ok||!f(s)||!h(s,["success","data"])||s.success!==!0)throw this.internalError(o.status);let i=t(s.data);if(i===void 0)throw this.internalError(o.status);return i}async fetchRequest(n,t){let r=await this.options.identityProvider.getIdentity(t.signal),o=new URL(`${this.baseUrl}/${n}`);for(let[a,p]of Object.entries(t.query??{}))p!==void 0&&o.searchParams.set(a,p);let s=new Headers;r.bearerToken!==void 0?s.set("Authorization",`Bearer ${r.bearerToken}`):s.set("X-Axiom-External-User-Id",r.externalUserId??"");let i;return t.body instanceof FormData?i=t.body:t.body!==void 0&&(s.set("Content-Type","application/json"),i=JSON.stringify(t.body)),this.fetchImplementation(o,{method:t.method??"GET",headers:s,body:i,signal:t.signal,credentials:"omit"})}async throwResponseError(n){let t;try{t=await n.json()}catch{throw this.internalError(n.status)}throw re(t)?new g(t.error.code,t.error.message,t.error.retryable,n.status):this.internalError(n.status)}internalError(n){return new g("INTERNAL_ERROR","Invalid server response",!1,n)}};function se(e){return typeof e=="object"&&e!==null&&"name"in e&&e.name==="AbortError"}var _=I(H());var W=I(L());function ie(){let{createThread:e}=x(),{menuCollapsed:n,setMenuCollapsed:t}=Y();(0,_.useEffect)(()=>{n===void 0&&t(!0)},[n,t]);let r=(0,_.useCallback)(async()=>{try{await e("New Thread")}catch(c){console.error("Failed to create new thread:",c)}},[e]),o=n??!0,p=[{id:"new-analysis",builtin:"new-analysis",type:"action",name:"New Thread",icon:(0,W.jsx)(V,{size:20}),order:0},...o?[{id:"thread-history-toggle",type:"action",name:"History",icon:(0,W.jsx)(N,{size:20}),order:1}]:[{id:"thread-history",builtin:"thread-history",type:"drawer",name:"History",icon:(0,W.jsx)(N,{size:20}),order:1,title:"Conversation History",width:320,inline:!0,inlineDefaultExpanded:!0,content:(0,W.jsx)(ee,{})}]];return(0,W.jsx)(Z,{items:p,showBranding:!1,showToggle:!0,showNewAnalysis:!1,defaultExpanded:!o,collapsed:o,onCollapsedChange:t,onNewAnalysis:r,onItemClick:c=>{c.type==="action"&&c.builtin==="new-analysis"?r():c.type==="action"&&c.id==="thread-history-toggle"&&t(!1)}},o?"agent-chat-sidebar-collapsed":"agent-chat-sidebar-expanded")}function ae(e){if(typeof window>"u"||typeof XMLHttpRequest>"u")return()=>{};let n=`${e.gatewayUrl.replace(/\/+$/,"")}/api/web-apps/${encodeURIComponent(e.webAppId)}/runtime/`,t=XMLHttpRequest.prototype.open,r=XMLHttpRequest.prototype.send,o=new WeakMap;return XMLHttpRequest.prototype.open=function(i,a){o.set(this,String(a)),t.call(this,i,a,!0)},XMLHttpRequest.prototype.send=function(i){let a=o.get(this)??"";if(!a.startsWith(n)||!/\/sandbox\/uploadfile$/.test(a)){r.call(this,i);return}if(e.identity.mode==="unverified"){this.setRequestHeader("X-Axiom-External-User-Id",e.identity.userId),r.call(this,i);return}e.identity.tokenProvider().then(p=>{this.setRequestHeader("Authorization",`Bearer ${p}`),r.call(this,i)}).catch(()=>{r.call(this,i)})},()=>{XMLHttpRequest.prototype.open=t,XMLHttpRequest.prototype.send=r}}var Ie=/^#[0-9A-Fa-f]{6}$/;function ke(e){return typeof e=="string"&&Ie.test(e)}function de(e){return ke(e)?e:void 0}function U(e,n){let t=parseInt(e.replace("#",""),16),r=Math.round(2.55*n),o=(t>>16)+r,s=(t>>8&255)+r,i=(t&255)+r;return"#"+(16777216+(o<255?o<1?0:o:255)*65536+(s<255?s<1?0:s:255)*256+(i<255?i<1?0:i:255)).toString(16).slice(1)}function pe(e){if(e!==void 0)return{token:{colorPrimary:e,colorPrimaryHover:U(e,20),colorPrimaryActive:U(e,-15),colorPrimaryBg:U(e,45)+"20"}}}var u=I(L());function We(e,n){let t=O(e.welcome),r=O(n.title),o=t??O(n.welcomeMessage),s=e.quickPrompts??n.quickPrompts??[],i=de(n.primaryColor);return{...r!==void 0?{title:r}:{},...o!==void 0?{welcome:o}:{},quickPrompts:s,...i!==void 0?{primaryColor:i}:{}}}function O(e){return typeof e=="string"&&e.length>0?e:void 0}function Te(e){if(!e.gatewayUrl.trim())throw new Error("AgentChatApp requires gatewayUrl");try{new URL(e.gatewayUrl)}catch{throw new Error("AgentChatApp gatewayUrl must be a valid URL")}if(!e.webAppId.trim())throw new Error("AgentChatApp requires webAppId");if(e.identity.mode==="unverified"){if(!e.identity.userId.trim())throw new Error("AgentChatApp requires identity.userId")}else if(typeof e.identity.tokenProvider!="function")throw new Error("AgentChatApp requires identity.tokenProvider");if(!e.fetch&&typeof globalThis.fetch!="function")throw new Error("AgentChatApp requires a fetch implementation")}function Pe(e){return e instanceof g?e:new g("INTERNAL_ERROR","Request failed",!0)}function Le(e){return e.mode==="unverified"?`unverified:${e.userId}`:"verified:token"}function At(e){Te(e);let n=`${e.gatewayUrl}\0${e.webAppId}\0${Le(e.identity)}`;return(0,u.jsx)(xe,{...e},n)}function xe({gatewayUrl:e,webAppId:n,identity:t,onError:r,onChatReady:o,onChatMessage:s,fetch:i,className:a,welcome:p,quickPrompts:c}){let[A,y]=(0,l.useState)({status:"loading"}),m=(0,l.useRef)(t);m.current=t;let T=(0,l.useRef)(r);T.current=r;let S=(0,l.useRef)();return S.current||(S.current=new D({gatewayUrl:e,webAppId:n,identityProvider:{getIdentity:async()=>{let w=m.current;if(w.mode!=="verified")return{externalUserId:w.userId};try{return{bearerToken:await w.tokenProvider()}}catch{throw new g("USER_ID_REQUIRED","Identity token provider failed",!0)}}},...i?{fetch:i}:{}})),(0,l.useEffect)(()=>ae({gatewayUrl:e,webAppId:n,identity:t}),[e,n,t]),(0,l.useEffect)(()=>{let w=!1,E=S.current;return(async()=>{try{let q=await E.bootstrap({});if(w)return;y({status:"ready",bootstrap:q})}catch(q){if(w)return;let v=Pe(q);y({status:"error",error:v}),T.current?.(v)}})(),()=>{w=!0}},[]),A.status==="loading"?(0,u.jsx)("div",{className:a}):A.status==="error"?(0,u.jsxs)("div",{className:a,role:"alert",children:[(0,u.jsx)("strong",{children:"Unable to load the assistant"}),(0,u.jsx)("div",{children:A.error.code}),(0,u.jsx)("button",{type:"button",onClick:()=>y({status:"loading"}),children:"Retry"})]}):(0,u.jsx)(De,{className:a,gatewayUrl:e,webAppId:n,identity:t,bootstrap:A.bootstrap,onChatReady:o,onChatMessage:s,welcome:p,quickPrompts:c})}function Me(e){return{id:e.id,name:e.name,...e.description!==void 0?{description:e.description}:{},graphDefinition:void 0,createdAt:new Date(0),updatedAt:new Date(0)}}function De({gatewayUrl:e,webAppId:n,identity:t,bootstrap:r,onChatReady:o,onChatMessage:s,className:i,welcome:a,quickPrompts:p}){let c=(0,l.useMemo)(()=>Me(r.webApp.assistant),[r.webApp.assistant]),A=(0,l.useMemo)(()=>We({welcome:a,quickPrompts:p},r.webApp.appearance),[a,p,r.webApp.appearance]),y=(0,l.useMemo)(()=>pe(A.primaryColor),[A.primaryColor]),m=(0,l.useMemo)(()=>t.mode==="unverified"?{mode:"unverified",userId:t.userId}:{mode:"verified",tokenProvider:t.tokenProvider},[t]),T=(0,l.useCallback)(E=>new $({gatewayUrl:e,webAppId:n,identity:m,assistantId:E.assistantId,transport:E.transport,...E.timeout!==void 0?{timeout:E.timeout}:{},...E.headers!==void 0?{headers:E.headers}:{}}),[e,n,m]),S=(0,l.useMemo)(()=>({baseURL:`${e.replace(/\/$/,"")}/api/web-apps/${n}/runtime`,apiKey:"",transport:"sse",assistantId:c.id,enableSkillSlot:!1,enableDatabaseSlot:!1,enableAgentSlot:!1,enableMetricsDataSourceSlot:!1,enableModelSelector:!1,enableWorkspace:!1,enableCustomMenu:!1,showSideMenu:!1,enableAssistantCreation:!1,enableAssistantEditing:!1,enableThreadCreation:!0,enableThreadList:!0}),[c.id,e,n]),w=(0,l.useMemo)(()=>({assistants:[c],currentAssistant:c,isLoading:!1,error:null,listAssistants:async()=>{},getAssistant:async()=>c,createAssistant:async()=>{throw new Error("Not implemented in a Web App")},updateAssistant:async()=>{throw new Error("Not implemented in a Web App")},deleteAssistant:async()=>{},selectAssistant:async()=>{},clearCurrentAssistant:()=>{},refresh:async()=>{}}),[c]);return(0,u.jsx)(j,{theme:y,children:(0,u.jsx)(z,{config:{baseURL:S.baseURL,apiKey:"",assistantId:"__BASE__",transport:"sse"},createClient:T,children:(0,u.jsx)(K,{initialConfig:S,persistToLocalStorage:!1,children:(0,u.jsx)(G.Provider,{value:w,children:(0,u.jsx)(J,{children:(0,u.jsx)(_e,{className:i,onChatReady:o,onChatMessage:s,title:A.title,welcome:A.welcome,quickPrompts:A.quickPrompts})})})})})})}function _e({className:e,onChatReady:n,onChatMessage:t,title:r,welcome:o,quickPrompts:s=[]}){let{threadId:i}=x(),{currentAssistant:a}=Q();if(!a)return null;let p=i??"";if(!p)return(0,u.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,u.jsx)(B,{tip:"Creating conversation..."})});let c=r??o,A=r!==void 0&&o!==void 0?o:"";return(0,u.jsx)("div",{className:e,children:(0,u.jsx)(te,{thread_id:p,assistant_id:a.id,name:a.name,description:a.description,menu:(0,u.jsx)(ie,{}),showProjectSelector:!1,showSkillSlot:!1,showDatabaseSlot:!1,showAgentSlot:!1,showMetricsDataSourceSlot:!1,headerRight:null,emptyStateGreeting:c?(0,u.jsx)("span",{children:c}):void 0,emptyStateQuestion:A,senderPromptsItems:s.length>0?s.map((y,m)=>({key:`quick-${m}`,label:y.label,description:y.text})):void 0,showSkillPrompts:!1,showQuickAnalysis:!1,onChatReady:n,onChatMessage:t})})}export{Ie as a,At as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{ab as L,cb as I,db as v,gb as M,hb as b,o as R,q as B,va as O}from"./embed-page-chunk-
|
|
1
|
+
import{ab as L,cb as I,db as v,gb as M,hb as b,o as R,q as B,va as O}from"./embed-page-chunk-U276WBDI.js";import{a as P}from"./embed-page-chunk-MB65DZAX.js";import{Fa as C,La as $,Z as N,va as S}from"./embed-page-chunk-O4QK5LWZ.js";import{a as V}from"./embed-page-chunk-4BKXE5ON.js";import{e as w}from"./embed-page-chunk-6Y3UYJ6Z.js";var m=w(V());function X(t,o){if(t.parentId&&t.parentId!==t.id&&o.has(t.parentId))return t.parentId;for(let c of t.dependencies??[])if(c!==t.id&&o.has(c))return c}function D(t,o){let u=o?.hideCompleted??!1?t.filter(e=>!b(e.status)):t,g=new Map(u.map(e=>[e.id,e])),d=new Map;for(let e of u)d.set(e.id,X(e,g));let r=new Set;for(let e of d.keys()){if(r.has(e))continue;let l=new Map,p=e,h=0;for(;p!==void 0&&!r.has(p)&&!l.has(p);)l.set(p,h),h+=1,p=d.get(p);if(p!==void 0&&l.has(p)){let y=l.get(p);for(let[i,f]of l)f>=y&&r.add(i)}}for(let e of r)d.set(e,void 0);let x=new Map;for(let e of u)x.set(e.id,[]);for(let e of u){let l=d.get(e.id);l!==void 0&&x.get(l).push(e.id)}let s=e=>({task:g.get(e),children:(x.get(e)??[]).map(s)});return u.filter(e=>d.get(e.id)===void 0).map(e=>s(e.id))}var n=w(P()),{Text:z}=$,Y=16,q=3,J=O(({css:t,token:o})=>({root:t`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
height: 100%;
|