@axiom-lattice/gateway 4.8.3 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/a2a-BHBLACJV.mjs +17 -0
  2. package/dist/a2a-BHBLACJV.mjs.map +1 -0
  3. package/dist/{a2a-FGYX2HH3.mjs → chunk-HYYLYIMH.mjs} +59 -15
  4. package/dist/chunk-HYYLYIMH.mjs.map +1 -0
  5. package/dist/embed/{embed-page-AgentDetailSideApp-MVSXAG5S.js → embed-page-AgentDetailSideApp-BVJK7WIS.js} +1 -1
  6. package/dist/embed/{embed-page-AgentGovernanceWorkbench-ZEVAVRIQ.js → embed-page-AgentGovernanceWorkbench-L2YHPRNE.js} +1 -1
  7. package/dist/embed/{embed-page-MessageGraph-CPZJIKOD.js → embed-page-MessageGraph-JOQ46UE2.js} +1 -1
  8. package/dist/embed/{embed-page-ReactChart-7NQMTFJE.js → embed-page-ReactChart-I5AYTSII.js} +1 -1
  9. package/dist/embed/{embed-page-SkillFlow-TSBZ4V2P.js → embed-page-SkillFlow-YLB5XPFH.js} +1 -1
  10. package/dist/embed/{embed-page-TasksSideApp-CY6NI4DD.js → embed-page-TasksSideApp-QLJVB7UK.js} +1 -1
  11. package/dist/embed/{embed-page-TeamWorkspace-7GQCMJWF.js → embed-page-TeamWorkspace-BZZEAYSB.js} +1 -1
  12. package/dist/embed/{embed-page-TopologyRuntimeView-5DJPLCLQ.js → embed-page-TopologyRuntimeView-FRA3AXQQ.js} +1 -1
  13. package/dist/embed/{embed-page-WorkflowAutomationView-PDVXZXEF.js → embed-page-WorkflowAutomationView-D745PK3W.js} +1 -1
  14. package/dist/embed/{embed-page-chunk-KEL6XU6R.js → embed-page-chunk-2U4LKIE3.js} +1 -1
  15. package/dist/embed/{embed-page-chunk-AC6X2XRH.js → embed-page-chunk-3WRJEEZS.js} +1 -1
  16. package/dist/embed/{embed-page-chunk-3SV3E6X5.js → embed-page-chunk-4WBAN7QL.js} +209 -305
  17. package/dist/embed/{embed-page-chunk-Z7USDLHI.js → embed-page-chunk-6KCBXVIT.js} +1 -1
  18. package/dist/embed/embed-page-chunk-FVMSMU4J.js +242 -0
  19. package/dist/embed/{embed-page-chunk-SFHRRNYQ.js → embed-page-chunk-FWGNJMXD.js} +1 -1
  20. package/dist/embed/{embed-page-chunk-O4QK5LWZ.js → embed-page-chunk-FZRTVFHF.js} +83 -83
  21. package/dist/embed/{embed-page-chunk-UWL37DAK.js → embed-page-chunk-K5YYUAPL.js} +1 -1
  22. package/dist/embed/{embed-page-chunk-BKCIU75D.js → embed-page-chunk-M2PV36MX.js} +1 -1
  23. package/dist/embed/{embed-page-chunk-IV5C4DYL.js → embed-page-chunk-ONN5O5BX.js} +1 -1
  24. package/dist/embed/{embed-page-chunk-ULBEL4OA.js → embed-page-chunk-P5PFV3N7.js} +1 -1
  25. package/dist/embed/{embed-page-chunk-YPNSOZYW.js → embed-page-chunk-WMLR2GQK.js} +4 -4
  26. package/dist/embed/{embed-page-code-highlighter-Y6CQA4CN.js → embed-page-code-highlighter-NZBTSABL.js} +1 -1
  27. package/dist/embed/{embed-page-mermaid-CW4QCAH3.js → embed-page-mermaid-CK4ARQCM.js} +1 -1
  28. package/dist/embed/embed-page.js +1 -1
  29. package/dist/index.d.mts +383 -2
  30. package/dist/index.d.ts +383 -2
  31. package/dist/index.js +2563 -1094
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.mjs +1504 -82
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/{open-exposure-VU227IO3.mjs → open-exposure-27ESFWTB.mjs} +4 -4
  36. package/package.json +7 -7
  37. package/dist/a2a-FGYX2HH3.mjs.map +0 -1
  38. package/dist/embed/embed-page-chunk-PZCET7LJ.js +0 -245
  39. /package/dist/{open-exposure-VU227IO3.mjs.map → open-exposure-27ESFWTB.mjs.map} +0 -0
@@ -0,0 +1,242 @@
1
+ import{a as ko}from"./embed-page-chunk-K5YYUAPL.js";import{a as lr,b as In}from"./embed-page-chunk-P5PFV3N7.js";import{b as zi,c as Bi}from"./embed-page-chunk-FWGNJMXD.js";import{c as ho,d as bo}from"./embed-page-chunk-2U4LKIE3.js";import{b as it,c as Ai,d as mo,e as xt,f as yo,g as Ei,h as xn,i as Tn,j as Pi,l as Di,m as Li}from"./embed-page-chunk-3WRJEEZS.js";import{a as Wi,b as ji}from"./embed-page-chunk-M2PV36MX.js";import{A as li,Aa as Ti,C as di,D as ci,Da as kn,F as co,Ja as wn,Ka as go,L as ui,La as Ri,Oa as Ii,Pa as Ci,Qa as Si,Ra as fo,Y as pi,Z as gi,_ as fi,aa as mi,ba as yi,d as oi,db as Ni,eb as vo,f as ri,fb as wo,g as Bn,ga as hi,gb as xo,hb as Mi,ib as To,jb as Oi,ka as bi,kb as _i,lb as Ro,mb as Rn,oa as uo,ob as sr,p as ii,pa as vi,pb as Fi,qa as ki,ra as wi,sa as Lt,x as ai,xa as xi,z as si,za as po}from"./embed-page-chunk-4WBAN7QL.js";import{i as Ur,p as Zr,q as Vr,t as mt,x as ao,y as Xe}from"./embed-page-chunk-WMLR2GQK.js";import{a as M}from"./embed-page-chunk-MB65DZAX.js";import{Bb as vn,Cb as Jr,Cc as ei,Ec as ti,Fc as ir,Gc as ar,Ha as io,Ia as qe,Ja as Hr,La as We,Ma as Kr,Rc as ni,Sb as rr,U as Vt,W as V,Wa as Qr,Y as bn,Z as Bt,_ as ot,aa as Qt,ca as nr,da as or,eb as Yr,ec as lo,fa as Gr,ia as sn,la as $r,lb as zn,na as qr,nb as Xr,oa as Pt,ra as pe,sb as so,ta as De,va as wt,xa as rt,xc as Dt,ya as _e}from"./embed-page-chunk-FZRTVFHF.js";import{a as xe}from"./embed-page-chunk-4BKXE5ON.js";import{e as R}from"./embed-page-chunk-6Y3UYJ6Z.js";var Gs={react:{label:"capability",color:"blue"},capability:{label:"capability",color:"blue"},deep_agent:{label:"orchestrator",color:"orange"},orchestrator:{label:"orchestrator",color:"orange"},team:{label:"team",color:"green"},processing:{label:"workflow",color:"purple"},workflow:{label:"workflow",color:"purple"},a2a_remote:{label:"remote",color:"cyan"},remote:{label:"remote",color:"cyan"}};function Cn(e){return Gs[e]??{label:"capability",color:"blue"}}var $s={enabled:"green",draft:"orange",disabled:"default"};function $i(e){return $s[e]??"default"}var Gi={blue:"#3b82f6",orange:"#f59e0b",green:"#22c55e",purple:"#a855f7",cyan:"#06b6d4"};function jn(e){return Gi[e]??Gi.cyan}function $d(e){let t={enabled:"#22c55e",draft:"#f59e0b",disabled:"#d9d9d9"};return t[e]??t.disabled}function Sn(e){return typeof e.graphDefinition=="object"&&e.graphDefinition!==null?e.graphDefinition:{}}function cr(e){return((Sn(e).metadata??{}).tags??"").split(",").map(r=>r.trim()).filter(Boolean)}function ur(e){let o=(Sn(e).metadata??{}).version;return o?o.startsWith("v")?o:`v${o}`:"v1"}function pr(e){let o=(Sn(e).metadata??{}).status??"enabled";return o==="draft"||o==="disabled"?o:"enabled"}function dr(e){let n=Sn(e).subAgents??[],o=Array.isArray(n)?n.filter(Boolean):[];return Array.from(new Set(o))}function qd(e){return e.map(t=>{let n=Sn(t),o=String(n.type??"react");return{id:t.id,name:t.name,description:t.description,type:Cn(o).label,tags:cr(t),version:ur(t),status:pr(t),subAgents:dr(t)}})}function Hd(e){let t=new Set(e.map(r=>r.id)),n=e.map(r=>({id:r.id,label:r.name,type:Cn(String(Sn(r).type??"react")).label,subAgentCount:dr(r).length})),o=[];for(let r of e)for(let i of dr(r))t.has(i)&&o.push({source:r.id,target:i});return{nodes:n,edges:o}}var Re=R(xe());var te=R(xe());var b=R(M()),{TextArea:qs}=De,{Text:Tt}=We,qi=["data","execution","workflow","assistant"],Hs={data:"Data & Knowledge",execution:"Execution & Interaction",workflow:"Workflow & Orchestration",assistant:"Assistant & Evaluation",other:"Other"},Gn=(e,t)=>{if(Array.isArray(e)){let n=e.map(o=>Gn(o));return(t==="tools"||t==="subAgents")&&n.every(o=>typeof o=="string")?[...n].sort():n}return e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).sort(([n],[o])=>n.localeCompare(o)).map(([n,o])=>[n,Gn(o,n)])):e},Hi=e=>{if(typeof e!="string")return Gn(e??null);try{return Gn(JSON.parse(e))}catch{return e}},Ki=e=>JSON.stringify(Gn({...e,tools:[...e.tools].sort(),subAgents:[...e.subAgents].sort()})),Ks=wi(({token:e,css:t})=>({modalBody:t`
2
+ padding: 0;
3
+ height: 92vh;
4
+ width: 100%;
5
+ display: flex;
6
+ flex-direction: column;
7
+ overflow: hidden;
8
+ `,topbar:t`
9
+ display: flex;
10
+ align-items: center;
11
+ justify-content: space-between;
12
+ padding: 20px 32px;
13
+ border-bottom: 1px solid ${e.colorBorderSecondary};
14
+ background: ${e.colorBgContainer};
15
+ flex-shrink: 0;
16
+ `,topbarLeft:t`
17
+ display: flex;
18
+ align-items: center;
19
+ gap: 16px;
20
+ min-width: 0;
21
+ `,agentName:t`
22
+ font-size: 20px;
23
+ font-weight: 600;
24
+ color: ${e.colorText};
25
+ white-space: nowrap;
26
+ overflow: hidden;
27
+ text-overflow: ellipsis;
28
+ `,agentDesc:t`
29
+ font-size: 13px;
30
+ color: ${e.colorTextSecondary};
31
+ white-space: nowrap;
32
+ overflow: hidden;
33
+ text-overflow: ellipsis;
34
+ max-width: 480px;
35
+ `,layout:t`
36
+ display: flex;
37
+ flex: 1;
38
+ min-height: 0;
39
+
40
+ @media (max-width: 720px) {
41
+ flex-direction: column;
42
+ }
43
+ `,pageHeader:t`
44
+ display: flex;
45
+ align-items: center;
46
+ gap: 16px;
47
+ padding-bottom: 20px;
48
+ border-bottom: 1px solid ${e.colorBorderSecondary};
49
+ margin-bottom: 24px;
50
+ `,pageIcon:t`
51
+ width: 48px;
52
+ height: 48px;
53
+ border-radius: 12px;
54
+ background: ${e.colorPrimaryBg};
55
+ display: flex;
56
+ align-items: center;
57
+ justify-content: center;
58
+ font-size: 22px;
59
+ flex-shrink: 0;
60
+ `,pageName:t`
61
+ font-size: 20px;
62
+ font-weight: 600;
63
+ color: ${e.colorText};
64
+ margin: 0;
65
+ `,pageDesc:t`
66
+ font-size: 13px;
67
+ color: ${e.colorTextSecondary};
68
+ margin: 4px 0 0;
69
+ `,blockTitle:t`
70
+ font-size: 14px;
71
+ font-weight: 600;
72
+ color: ${e.colorTextSecondary};
73
+ margin: 0;
74
+ `,content:t`
75
+ flex: 1;
76
+ min-width: 0;
77
+ overflow-y: auto;
78
+ padding: 32px 40px;
79
+ background: ${e.colorBgLayout};
80
+
81
+ @media (max-width: 720px) {
82
+ padding: 20px 16px;
83
+ }
84
+ `,sectionHeader:t`
85
+ display: flex;
86
+ align-items: flex-end;
87
+ justify-content: space-between;
88
+ margin-bottom: 20px;
89
+ gap: 16px;
90
+ `,sectionTitle:t`
91
+ font-size: 20px;
92
+ font-weight: 600;
93
+ color: ${e.colorText};
94
+ margin: 0;
95
+ `,sectionDesc:t`
96
+ font-size: 13px;
97
+ color: ${e.colorTextSecondary};
98
+ margin: 4px 0 0;
99
+ `,sectionActions:t`
100
+ display: flex;
101
+ align-items: center;
102
+ gap: 12px;
103
+ flex-shrink: 0;
104
+ `,cardGrid:t`
105
+ display: grid;
106
+ grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
107
+ gap: 16px;
108
+ align-items: start;
109
+
110
+ @media (max-width: 720px) {
111
+ grid-template-columns: minmax(0, 1fr);
112
+ }
113
+ `,footer:t`
114
+ display: flex;
115
+ align-items: center;
116
+ justify-content: space-between;
117
+ padding: 16px 32px;
118
+ border-top: 1px solid ${e.colorBorderSecondary};
119
+ background: ${e.colorBgContainer};
120
+ flex-shrink: 0;
121
+
122
+ @media (max-width: 720px) {
123
+ justify-content: flex-end;
124
+ }
125
+ `,footerHint:t`
126
+ font-size: 13px;
127
+
128
+ @media (max-width: 720px) {
129
+ display: none;
130
+ }
131
+ `,selectedCard:t`
132
+ border-color: ${e.colorPrimary} !important;
133
+ background: ${e.colorPrimaryBg} !important;
134
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
135
+ `,dataSection:t`
136
+ border-top: 1px solid ${e.colorBorderSecondary};
137
+ margin-top: 16px;
138
+ padding-top: 16px;
139
+ `,dataSectionHeader:t`
140
+ display: flex;
141
+ align-items: center;
142
+ justify-content: space-between;
143
+ gap: 8px;
144
+ margin-bottom: 10px;
145
+ `,dataList:t`
146
+ max-height: 240px;
147
+ overflow-y: auto;
148
+ border-radius: 10px;
149
+ background: ${e.colorFillQuaternary};
150
+ padding: 4px 8px;
151
+ `,toolsGrid:t`
152
+ display: grid;
153
+ grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
154
+ gap: 12px;
155
+ align-items: start;
156
+ `,toolDesc:t`
157
+ font-size: 13px;
158
+ line-height: 1.5;
159
+ color: ${e.colorTextSecondary};
160
+ display: -webkit-box;
161
+ -webkit-line-clamp: 1;
162
+ -webkit-box-orient: vertical;
163
+ overflow: hidden;
164
+ `,configGrid:t`
165
+ display: grid;
166
+ grid-template-columns: repeat(2, minmax(0, 1fr));
167
+ gap: 12px 16px;
168
+ padding: 8px 0;
169
+ `,searchBox:t`
170
+ width: 220px;
171
+ `})),Ui=(e,t)=>t?.find(n=>n.type===e),Zi=({assistant:e,allAssistants:t,visible:n,onClose:o,onSave:r,onDelete:i,embedded:a,initialSection:u="basic",onDirtyChange:d,onOverlayOpenChange:p})=>{let[h]=pe.useForm(),{token:c}=Hr.useToken(),{styles:s}=Ks(),{styles:f}=Oi(),{config:y}=ao(),{middlewareTypes:g,isLoading:v}=To(y.middlewareTypesEndpoint),{get:m}=Xe(),[w,C]=(0,te.useState)(u),[A,T]=(0,te.useState)(e),[O,_]=(0,te.useState)(null),[D,x]=(0,te.useState)(!0),[B,Z]=(0,te.useState)(!1),[Y,H]=(0,te.useState)(!1),[j,z]=(0,te.useState)(!1),[K,F]=(0,te.useState)(!1),[ne,P]=(0,te.useState)([]),[G,le]=(0,te.useState)(""),[oe,Ie]=(0,te.useState)(""),[fe,L]=(0,te.useState)([]),[ie,Ee]=(0,te.useState)([]),[W,N]=(0,te.useState)(""),[X,de]=(0,te.useState)(!1),[S,Pe]=(0,te.useState)("react"),[he,Te]=(0,te.useState)([]),[Ae,Le]=(0,te.useState)({name:"",description:""}),[nt,Fe]=(0,te.useState)(""),[Je,Ne]=(0,te.useState)(null),[gt,bt]=(0,te.useState)(!1),Ct=(0,te.useRef)(0),Be=(0,te.useRef)(null),on=(0,te.useRef)(!1),rn=(0,te.useRef)(d),an=(0,te.useRef)(p);(0,te.useEffect)(()=>{rn.current=d},[d]),(0,te.useEffect)(()=>()=>{rn.current?.(!1)},[]),(0,te.useEffect)(()=>{an.current=p},[p]),(0,te.useEffect)(()=>()=>{an.current?.(!1)},[]);let Wt=(0,te.useMemo)(()=>Ki({form:Ae,agentType:S,tools:fe,subAgents:ie,prompt:W,middleware:he,graphDefinition:Hi(A?.graphDefinition)}),[Ae,S,fe,ie,W,he,A?.graphDefinition]),vt=gt&&Wt!==nt,Ke=gt;on.current=vt;let kt=(0,te.useMemo)(()=>{if(!e?.graphDefinition)return null;try{let l=typeof e.graphDefinition=="string"?JSON.parse(e.graphDefinition):e.graphDefinition;return{tools:l.tools||[],prompt:l.prompt||"",subAgents:l.subAgents||[],type:l.type||"react",middleware:l.middleware||[]}}catch{return null}},[e]),hn=(0,te.useCallback)(l=>(l||[]).filter(E=>E.schema?.properties&&Object.keys(E.schema.properties).length>0||E.tools&&E.tools.length>0).map((E,ce)=>({id:`${E.type}-${ce+1}`,type:E.type,name:E.name,description:E.description,enabled:!1,config:{}})),[]),Ut=(0,te.useCallback)((l,I)=>{let E=(I||[]).filter(we=>we.schema?.properties&&Object.keys(we.schema.properties).length>0||we.tools&&we.tools.length>0),ce=new Map(l?.map(we=>[we.type,we])||[]),Ge=E.map((we,Et)=>{let _n=ce.get(we.type);return _n?{..._n,name:we.name,description:we.description}:{id:`${we.type}-${Et+1}`,type:we.type,name:we.name,description:we.description,enabled:!1,config:{}}}),ft=new Set(E.map(we=>we.type));return[...Ge,...(l??[]).filter(we=>!ft.has(we.type))]},[]),$=(0,te.useCallback)(async()=>{if(n){Z(!0);try{let l=await m("/api/tools");l.success&&l.data?.records&&P(l.data.records)}catch(l){console.error("Failed to fetch tools:",l)}finally{Z(!1)}}},[m,n]);(0,te.useEffect)(()=>{if(!n||!e){Be.current=null,Ct.current+=1,bt(!1),T(e),Ne(null);return}if(Be.current===e||Be.current?.id===e.id&&on.current)return;let l=y.availableMiddlewareTypes;if(!(!l&&v)){Be.current=e,Ct.current+=1;{$();let I={name:e.name??"",description:e.description??""},E=kt?.tools??[],ce=kt?.subAgents??[],Ge=kt?.prompt??"",ft=kt?.type??"react",we=kt?Ut(kt.middleware,l||g):hn(l||g);bt(!1),T(e),Le(I),L(E),Ee(ce),N(Ge),Pe(ft),Te(we),h.setFieldsValue({...I,type:ft}),Ne(Ki({form:I,agentType:ft,tools:E,subAgents:ce,prompt:Ge,middleware:we,graphDefinition:Hi(e.graphDefinition)}))}}},[n,e,vt,kt,h,$,hn,Ut,y.availableMiddlewareTypes,v,g]),(0,te.useEffect)(()=>{Je!==null&&Wt===Je&&(Fe(Je),Ne(null),bt(!0))},[Wt,Je]),(0,te.useEffect)(()=>{d?.(vt)},[vt,d]),(0,te.useEffect)(()=>{an.current?.(X||K)},[X,K]);let me=async()=>{if(!A||!Ke)return;let l=Ct.current,I=Wt;try{H(!0);let ce={...await h.validateFields(),type:S,tools:fe,subAgents:ie,prompt:W,middleware:he};await r?.(A,ce),Ct.current===l&&Fe(I)}catch(E){E instanceof Error&&rt.error(E.message)}finally{H(!1)}},Qe=async()=>{if(e){z(!0);try{await i?.(e),F(!1),o()}catch(l){F(!1),rt.error(l instanceof Error?l.message:"Failed to delete assistant")}finally{z(!1)}}},Ye=l=>{Te(I=>I.map(E=>{if(E.id!==l)return E;if(E.enabled)return{...E,enabled:!1};{let ce=(y.availableMiddlewareTypes||g)?.find(Ge=>Ge.type===E.type);return{...E,enabled:!0,config:ce?.defaultConfig||{}}}}))},je=(l,I)=>{Te(E=>E.map(ce=>ce.id===l?{...ce,config:{...ce.config,...I}}:ce))},St=(l,I)=>{Te(E=>E.map(ce=>ce.id===l?{...ce,allowedTools:I}:ce))},et=l=>{let I=fe.includes(l.id);return(0,b.jsx)(po,{item:l,className:I?s.selectedCard:void 0,onClick:()=>L(E=>E.includes(l.id)?E.filter(ce=>ce!==l.id):[...E,l.id]),renderIcon:()=>(0,b.jsx)("span",{style:{fontSize:18,fontWeight:600},children:l.name.charAt(0).toUpperCase()}),renderPrimary:()=>(0,b.jsxs)(Pt,{size:6,children:[(0,b.jsx)("span",{children:l.name}),l.needUserApprove&&(0,b.jsx)(qe,{color:"warning",style:{fontSize:10,padding:"0 4px",margin:0},children:"Approve"})]}),renderDetails:()=>(0,b.jsx)(_i,{text:l.description,className:s.toolDesc}),renderHeaderActions:()=>(0,b.jsx)(sn,{checked:I,onClick:E=>E.stopPropagation(),onChange:()=>L(E=>E.includes(l.id)?E.filter(ce=>ce!==l.id):[...E,l.id])})},l.id)},be=l=>{let I=ie.includes(l.id);return(0,b.jsx)(po,{item:l,className:I?s.selectedCard:void 0,onClick:()=>Ee(E=>E.includes(l.id)?E.filter(ce=>ce!==l.id):[...E,l.id]),renderIcon:()=>(0,b.jsx)(nr,{size:36,style:{backgroundColor:I?c.colorPrimary:c.colorSuccess,fontSize:15},children:l.name?.charAt(0).toUpperCase()||"A"}),renderPrimary:()=>l.name,renderSecondary:()=>l.description||"No description",renderHeaderActions:()=>(0,b.jsx)(sn,{checked:I,onClick:E=>E.stopPropagation(),onChange:()=>Ee(E=>E.includes(l.id)?E.filter(ce=>ce!==l.id):[...E,l.id])})},l.id)},Mn=(0,te.useCallback)(l=>Ui(l.type,y.availableMiddlewareTypes||g)?.category||"other",[y.availableMiddlewareTypes,g]),At=(0,te.useMemo)(()=>{let l=new Map;for(let I of he){let E=Mn(I),ce=l.get(E);ce?ce.push(I):l.set(E,[I])}return l},[he,Mn]),On=(0,te.useMemo)(()=>{let l=Array.from(At.keys());return[...qi.filter(I=>At.has(I)),...l.filter(I=>!qi.includes(I))]},[At]),st=(0,te.useMemo)(()=>he.length===0?null:he.find(l=>l.type===O)??he.find(l=>l.enabled)??he[0],[he,O]);if(!n||!e)return null;let eo=[{key:"basic",icon:(0,b.jsx)(ar,{}),label:"Basic Info"},{key:"prompt",icon:(0,b.jsx)(rr,{}),label:"System Prompt"},{key:"tools",icon:(0,b.jsx)(ni,{}),label:"Common Tools",badge:fe.length},{key:"middleware",icon:(0,b.jsx)(Xr,{}),label:"Capabilities",badge:he.filter(l=>l.enabled).length},{key:"subagents",icon:(0,b.jsx)(ei,{}),label:"Sub-Agents",badge:ie.length}],to=ne.filter(l=>l.name.toLowerCase().includes(G.toLowerCase())||l.description.toLowerCase().includes(G.toLowerCase())),Zt=t.filter(l=>l.id!==e.id),no=Zt.filter(l=>(l.name||"").toLowerCase().includes(oe.toLowerCase())||(l.description||"").toLowerCase().includes(oe.toLowerCase())),Jo=()=>(0,b.jsxs)("div",{style:{maxWidth:960},children:[(0,b.jsxs)("div",{className:s.pageHeader,children:[(0,b.jsx)("div",{className:s.pageIcon,children:(0,b.jsx)(ar,{})}),(0,b.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,b.jsx)("h2",{className:s.pageName,children:"Basic Info"}),(0,b.jsx)("p",{className:s.pageDesc,children:"Core identity and behavior of this agent"})]})]}),(0,b.jsxs)(pe,{form:h,layout:"vertical",autoComplete:"off",onValuesChange:(l,I)=>Le({name:I.name??"",description:I.description??""}),children:[(0,b.jsx)(pe.Item,{name:"name",label:(0,b.jsx)(Tt,{strong:!0,style:{fontSize:14},children:"Name"}),rules:[{required:!0,message:"Please enter agent name"}],style:{marginBottom:24},children:(0,b.jsx)(De,{placeholder:"Enter agent name\u2026"})}),(0,b.jsxs)(pe.Item,{name:"type",label:(0,b.jsx)(Tt,{strong:!0,style:{fontSize:14},children:"Agent Type"}),rules:[{required:!0}],style:{marginBottom:24},children:[(0,b.jsx)($r,{value:S,onChange:l=>Pe(l),options:[{value:"react",label:"Executor"},{value:"deep_agent",label:"Orchestrator"},{value:"team",label:"Team"},{value:"processing",label:"Workflow"}],block:!0}),(0,b.jsx)(Tt,{type:"secondary",style:{fontSize:13,marginTop:8,display:"block",lineHeight:1.6},children:S==="react"?"Executor: Executes tasks directly using tools. Best for single-step operations like search, code execution, and data retrieval.":S==="deep_agent"?"Orchestrator: Maintains a todo list to plan and delegate tasks to sub-agents. Best for structured multi-step workflows.":S==="processing"?"Workflow: Delegates to sub-agents in a predefined topology order. Best for deterministic multi-step processes.":"Team: Creates tasks with dependencies and dynamically spawns teammates who communicate via mailbox. Best for exploration and divergent thinking."})]}),(0,b.jsx)(pe.Item,{name:"description",label:(0,b.jsx)(Tt,{strong:!0,style:{fontSize:14},children:"Description"}),rules:[{required:!0,message:"Please enter agent description"}],style:{marginBottom:0},children:(0,b.jsx)(De.TextArea,{placeholder:"Enter agent description\u2026",autoSize:{minRows:3,maxRows:6}})})]})]}),er=()=>(0,b.jsxs)("div",{style:{maxWidth:960},children:[(0,b.jsxs)("div",{className:s.pageHeader,children:[(0,b.jsx)("div",{className:s.pageIcon,children:(0,b.jsx)(rr,{})}),(0,b.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,b.jsx)("h2",{className:s.pageName,children:"System Prompt"}),(0,b.jsx)("p",{className:s.pageDesc,children:"Define the agent's behavior, capabilities, and constraints"})]}),(0,b.jsx)(V,{icon:(0,b.jsx)(vn,{}),onClick:()=>de(!0),children:"Expand"})]}),(0,b.jsx)(qs,{"aria-label":"System Prompt",value:W,onChange:l=>N(l.target.value),placeholder:"Enter the system prompt for this agent\u2026",autoSize:{minRows:12,maxRows:24},style:{fontFamily:"monospace",fontSize:13,lineHeight:1.7}}),(0,b.jsx)("div",{style:{marginTop:8,display:"flex",justifyContent:"flex-end"},children:(0,b.jsxs)(Tt,{type:"secondary",style:{fontSize:12},children:[W.length," chars"]})})]}),oo=()=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:s.sectionHeader,children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("h2",{className:s.sectionTitle,children:"Common Tools"}),(0,b.jsx)("p",{className:s.sectionDesc,children:"Choose the tools this agent can call directly"})]}),(0,b.jsxs)("div",{className:s.sectionActions,children:[(0,b.jsx)(De,{allowClear:!0,prefix:(0,b.jsx)(ir,{}),placeholder:"Search tools\u2026",value:G,onChange:l=>le(l.target.value),className:s.searchBox}),(0,b.jsxs)(Tt,{type:"secondary",style:{fontSize:13},children:["Selected ",fe.length," / ",ne.length]}),(0,b.jsx)(V,{size:"small",onClick:()=>L(fe.length===ne.length?[]:ne.map(l=>l.id)),children:fe.length===ne.length?"Clear":"Select All"})]})]}),B?(0,b.jsx)("div",{style:{textAlign:"center",padding:60},children:(0,b.jsx)(wt,{})}):to.length===0?(0,b.jsx)(Bt,{description:"No tools available",style:{padding:60}}):(0,b.jsx)("div",{className:s.cardGrid,children:to.map(et)})]}),zt=()=>st?(0,b.jsx)(Ro,{middleware:st,middlewareType:Ui(st.type,y.availableMiddlewareTypes||g),onToggle:()=>Ye(st.id),onConfigChange:l=>je(st.id,l),onAllowedToolsChange:l=>St(st.id,l)},st.id):(0,b.jsx)(Bt,{description:"No capabilities available",style:{padding:60}}),ro=()=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:s.sectionHeader,children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("h2",{className:s.sectionTitle,children:"Sub-Agents"}),(0,b.jsx)("p",{className:s.sectionDesc,children:"Choose sub-agents this agent can delegate to"})]}),(0,b.jsxs)("div",{className:s.sectionActions,children:[(0,b.jsx)(De,{allowClear:!0,prefix:(0,b.jsx)(ir,{}),placeholder:"Search sub-agents\u2026",value:oe,onChange:l=>Ie(l.target.value),className:s.searchBox}),(0,b.jsxs)(Tt,{type:"secondary",style:{fontSize:13},children:["Selected ",ie.length," / ",Zt.length]}),(0,b.jsx)(V,{size:"small",onClick:()=>Ee(ie.length===Zt.length?[]:Zt.map(l=>l.id)),children:ie.length===Zt.length?"Clear":"Select All"})]})]}),Zt.length===0?(0,b.jsx)(Bt,{description:"No other agents available",style:{padding:60}}):no.length===0?(0,b.jsx)(Bt,{description:"No matching results",style:{padding:60}}):(0,b.jsx)("div",{className:s.cardGrid,children:no.map(be)})]}),tr={basic:Jo(),prompt:er(),tools:oo(),middleware:zt(),subagents:ro()},k=(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:s.modalBody,style:a?{height:"100%",width:"100%"}:void 0,children:[!a&&(0,b.jsxs)("div",{className:s.topbar,children:[(0,b.jsxs)("div",{className:s.topbarLeft,children:[(0,b.jsx)(nr,{size:40,style:{backgroundColor:c.colorPrimary,fontSize:18,flexShrink:0},children:e.name?.charAt(0).toUpperCase()||"A"}),(0,b.jsxs)("div",{style:{minWidth:0},children:[(0,b.jsx)("div",{className:s.agentName,children:e.name}),(0,b.jsx)("div",{className:s.agentDesc,children:e.description})]}),(0,b.jsx)(qe,{color:"blue",style:{margin:0,fontSize:11,flexShrink:0},children:"Config Workbench"})]}),(0,b.jsxs)(Pt,{children:[i&&(0,b.jsx)(Qt,{title:"Delete Agent",children:(0,b.jsx)(V,{"aria-label":"Delete Agent",type:"text",danger:!0,icon:(0,b.jsx)(so,{}),onClick:()=>F(!0)})}),(0,b.jsx)(V,{type:"text",icon:(0,b.jsx)(zn,{}),onClick:o})]})]}),(0,b.jsxs)("div",{className:s.layout,children:[(0,b.jsx)("div",{className:f.nav,role:"tablist","aria-label":"Agent configuration sections",children:eo.map(l=>l.key!=="middleware"?(0,b.jsxs)("button",{type:"button",role:"tab","aria-selected":w===l.key,className:`${f.navItem} ${w===l.key?"active":""}`,onClick:()=>C(l.key),children:[(0,b.jsx)("span",{style:{fontSize:16},children:l.icon}),(0,b.jsx)("span",{children:l.label}),l.badge!==void 0&&l.badge>0&&(0,b.jsx)(or,{count:l.badge,size:"small",className:f.navBadge,style:{backgroundColor:c.colorPrimary}})]},l.key):(0,b.jsxs)(te.default.Fragment,{children:[(0,b.jsxs)("button",{type:"button",role:"tab","aria-selected":w==="middleware",className:`${f.navItem} ${w==="middleware"?"active":""}`,onClick:()=>x(I=>!I),children:[(0,b.jsx)("span",{style:{fontSize:16},children:l.icon}),(0,b.jsx)("span",{children:l.label}),l.badge!==void 0&&l.badge>0&&(0,b.jsx)(or,{count:l.badge,size:"small",className:f.navBadge,style:{backgroundColor:c.colorPrimary}})]}),D&&(0,b.jsx)("div",{className:f.navSub,children:On.map(I=>(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:f.navGroupLabel,children:Hs[I]||I}),At.get(I)?.map(E=>(0,b.jsxs)("button",{type:"button",role:"option","aria-selected":w==="middleware"&&O===E.type,className:`${f.navSubItem} ${w==="middleware"&&O===E.type?"active":""}`,onClick:()=>{_(E.type),C("middleware")},children:[(0,b.jsx)("span",{className:f.navStatusDot,style:{backgroundColor:E.enabled?c.colorSuccess:c.colorBorder}}),(0,b.jsx)("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:E.name})]},E.id))]},I))})]},"middleware"))}),(0,b.jsx)("div",{className:s.content,children:Ke?tr[w]:(0,b.jsx)("div",{style:{minHeight:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,b.jsxs)(Pt,{direction:"vertical",align:"center",children:[(0,b.jsx)(wt,{}),(0,b.jsx)(Tt,{type:"secondary",children:"Loading agent configuration..."})]})})})]}),(0,b.jsxs)("div",{className:s.footer,children:[(0,b.jsx)(Tt,{"data-testid":"config-footer-hint",className:s.footerHint,type:vt?"warning":"secondary",children:vt?"Unsaved changes":r?"Changes will be saved to this agent":"Viewing agent configuration"}),(0,b.jsxs)(Pt,{children:[(0,b.jsx)(V,{onClick:o,children:"Close"}),r&&(0,b.jsx)(V,{"aria-label":"Save",type:"primary",icon:(0,b.jsx)(ti,{}),loading:Y,disabled:!Ke,onClick:me,children:"Save"})]})]})]}),(0,b.jsx)(_e,{title:"System Prompt",open:X,onCancel:()=>de(!1),width:800,footer:[(0,b.jsx)(V,{onClick:()=>de(!1),children:"Close"},"cancel"),(0,b.jsx)(V,{type:"primary",onClick:()=>de(!1),children:"Done"},"done")],children:(0,b.jsx)(De.TextArea,{"aria-label":"System Prompt",value:W,onChange:l=>N(l.target.value),rows:16,style:{width:"100%",fontFamily:"monospace",fontSize:13,lineHeight:1.7,resize:"vertical",minHeight:300}})}),(0,b.jsx)(_e,{title:"Delete Agent",open:K,onCancel:()=>F(!1),footer:[(0,b.jsx)(V,{onClick:()=>F(!1),children:"Cancel"},"cancel"),(0,b.jsx)(V,{type:"primary",danger:!0,loading:j,onClick:Qe,children:"Delete"},"delete")],children:(0,b.jsxs)(Tt,{children:["Are you sure you want to delete ",(0,b.jsx)(Tt,{strong:!0,children:e.name})," ? This action cannot be undone."]})})]});return a?(0,b.jsx)("div",{style:{width:"100%",height:"100%",overflow:"hidden"},children:k}):(0,b.jsx)(_e,{open:n,onCancel:o,width:"88vw",footer:null,closable:!1,centered:!0,styles:{body:{padding:0},content:{borderRadius:20,overflow:"hidden",padding:0},mask:{backdropFilter:"blur(4px)"}},destroyOnHidden:!0,children:k})};var tt=R(xe());function Io(e,t){return e.find(n=>n.targetServerConfig?.targetAgentId===t)??e.find(n=>n.name===`eval-${t}`)??e.find(n=>typeof n.description=="string"&&n.description.includes(t))??null}var ge=R(M()),{Text:Us}=We,Zs=e=>e?.page==="suite"&&e.suiteId?.trim()?{page:"suite",suiteId:e.suiteId,runId:""}:e?.page==="run"&&e.runId?.trim()?{page:"run",suiteId:"",runId:e.runId}:{page:"suites",suiteId:"",runId:""},Co=({assistantId:e,initial:t,navigationKey:n,onEvalInvalidated:o})=>{let{projects:r,loading:i,create:a}=fo(),u=Io(r,e),d=u?.id??"",p=u?.name||`eval-${e}`,h=Zs(t),c=`${h.page}\0${h.suiteId}\0${h.runId}`,[s,f]=(0,tt.useState)(h),{page:y,suiteId:g,runId:v}=s;(0,tt.useEffect)(()=>{f(h)},[e,c,n]);let{start:m}=go(d),{workspaceId:w,projectId:C}=Lt(),[A,T]=(0,tt.useState)(!1),{create:O}=wn(d),[_,D]=(0,tt.useState)(!1),[x,B]=(0,tt.useState)(""),[Z,Y]=(0,tt.useState)(0),[H,j]=(0,tt.useState)(!1),[z]=pe.useForm(),[K,F]=(0,tt.useState)(!1),[ne,P]=(0,tt.useState)([]),G=mt("__GLOBAL__"),le=(0,tt.useRef)(o);le.current=o;let oe=N=>({workspaceId:w||void 0,projectId:N||C||void 0}),Ie=(0,tt.useCallback)(async()=>{let N=G,X=N.config?.baseURL||N.baseUrl||"";try{let S=await(await fetch(`${X}/api/models`,{headers:{Authorization:`Bearer ${N.config?.apiKey||""}`}})).json();S.success&&P(S.data||[])}catch{}},[G]),fe=async N=>{F(!0);try{await a({name:`eval-${e}`,judgeModelConfig:{modelKey:N.modelKey||""},targetServerConfig:{base_url:"",api_key:"",targetAgentId:e}}),await Promise.resolve(le.current?.()).catch(()=>{}),z.resetFields(),j(!1)}catch(X){rt.error(X instanceof Error?X.message:"Failed to create eval project")}finally{F(!1)}},L=(N,X,de)=>{f(S=>({page:N,suiteId:X??S.suiteId,runId:de??S.runId}))},ie=async()=>{x.trim()&&(await O(d,{name:x.trim()}),Y(N=>N+1),await o?.(),B(""),D(!1))},Ee=async N=>{let X=await m(d,oe(N.projectId));X?.run_id&&(await Promise.resolve(o?.()).catch(()=>{}),L("run",void 0,X.run_id))},W=(0,ge.jsx)(_e,{title:"Create Eval Project",open:H,onCancel:()=>{z.resetFields(),j(!1)},footer:null,destroyOnHidden:!0,width:480,children:(0,ge.jsxs)(pe,{form:z,layout:"vertical",onFinish:fe,initialValues:{name:`eval-${e}`},children:[(0,ge.jsx)(pe.Item,{name:"name",label:"Project Name",children:(0,ge.jsx)(De,{disabled:!0})}),(0,ge.jsx)(pe.Item,{name:"modelKey",label:"Judge Model",rules:[{required:!0,message:"Please select a judge model"}],children:(0,ge.jsx)(ot,{placeholder:"Select a registered model",options:ne.map(N=>{let X=N;return{value:X.key,label:`${X.displayName||X.key} (${X.model||""})`}})})}),(0,ge.jsxs)(pe.Item,{style:{marginBottom:0,textAlign:"right"},children:[(0,ge.jsx)(V,{onClick:()=>{z.resetFields(),j(!1)},style:{marginRight:8},children:"Cancel"}),(0,ge.jsx)(V,{type:"primary",htmlType:"submit",loading:K,children:"Create"})]})]})});return i?(0,ge.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,ge.jsx)(wt,{})}):u?(0,ge.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",background:"#f5f5f5"},children:[(0,ge.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 24px",background:"#fff",borderBottom:"1px solid #f0f0f0",flexShrink:0},children:[(0,ge.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,ge.jsx)(Jr,{style:{color:"#6366f1",fontSize:18}}),(0,ge.jsx)("span",{style:{fontSize:15,fontWeight:600},children:p}),(0,ge.jsx)(qe,{color:"purple",children:"eval"})]}),y==="suites"&&(0,ge.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,ge.jsx)(V,{icon:(0,ge.jsx)(Dt,{}),onClick:()=>D(N=>!N),children:"New Suite"}),(0,ge.jsx)(V,{type:"primary",icon:(0,ge.jsx)(Yr,{}),onClick:()=>T(!0),children:"Run All"})]})]}),y==="suites"&&_&&(0,ge.jsxs)("div",{style:{padding:"12px 24px",borderBottom:"1px solid #f0f0f0",display:"flex",gap:8,background:"#fff"},children:[(0,ge.jsx)("input",{type:"text",placeholder:"Suite name",value:x,onChange:N=>B(N.target.value),onKeyDown:N=>N.key==="Enter"&&void ie(),autoFocus:!0,style:{width:260,padding:"6px 12px",border:"1px solid #d9d9d9",borderRadius:8,fontSize:14,outline:"none"}}),(0,ge.jsx)(V,{type:"primary",size:"small",onClick:()=>void ie(),children:"Create"}),(0,ge.jsx)(V,{size:"small",onClick:()=>D(!1),children:"Cancel"})]}),(0,ge.jsxs)("div",{style:{flex:1,overflow:"auto",padding:28},children:[y==="suites"&&(0,ge.jsx)(Ri,{projectId:d,onSelectSuite:(N,X)=>L("suite",X),onEvalInvalidated:o},`${d}:${Z}`),y==="suite"&&g&&(0,ge.jsx)(Ci,{projectId:d,suiteId:g,onBack:()=>L("suites"),onRun:N=>{Promise.resolve(o?.()).catch(()=>{}),L("run",void 0,N)},onEvalInvalidated:o}),y==="run"&&v&&(0,ge.jsx)(Si,{runId:v,onBack:()=>L("suites"),onRunSettled:o})]}),(0,ge.jsx)(Ii,{open:A,onClose:()=>T(!1),onRun:Ee})]}):(0,ge.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,background:"#fff"},children:[(0,ge.jsx)(Bt,{description:(0,ge.jsx)(Us,{type:"secondary",children:"This agent has no eval project yet"})}),(0,ge.jsx)(V,{type:"primary",icon:(0,ge.jsx)(Dt,{}),onClick:()=>{Ie(),j(!0)},children:"Create eval project"}),W]})};var Me=R(xe());var $n=R(xe());var Q=R(M()),{Text:ln}=We,Vi={projectSelector:!1,modelSelector:!1,threadManagement:!0,attachments:!0,hitl:!0,genUI:!0,files:!1},Qi=({open:e,assistantId:t,value:n,projects:o,models:r,submitting:i,error:a,onCancel:u,onSubmit:d})=>{let[p]=pe.useForm(),[h,c]=(0,$n.useState)(!1),[s,f]=(0,$n.useState)(!1);(0,$n.useEffect)(()=>{if(!e)return;let m=n?.features??Vi;c(m.projectSelector),f(m.modelSelector),p.setFieldsValue({name:n?.name??"",description:n?.description,defaultProjectId:n?.scope.defaultProjectId??o[0]?.id,allowedProjectIds:n?.scope.allowedProjectIds??(o[0]?[o[0].id]:[]),defaultModelKey:n?.scope.defaultModelKey,allowedModelKeys:n?.scope.allowedModelKeys,...m,title:n?.appearance.title,welcomeMessage:n?.appearance.welcomeMessage,primaryColor:n?.appearance.primaryColor,quickPrompts:n?.appearance.quickPrompts,identityPolicy:n?.identity?.policy??"unverified",identityIssuers:n?.identity?JSON.stringify(n.identity.issuers,null,2):void 0})},[p,e,o,n]);let y=async()=>{let m=await p.validateFields(),w=m.projectSelector?Array.from(new Set(m.allowedProjectIds??[])):[m.defaultProjectId],C=m.modelSelector?Array.from(new Set([...m.defaultModelKey?[m.defaultModelKey]:[],...m.allowedModelKeys??[]])):m.defaultModelKey?[m.defaultModelKey]:void 0,A,T=m.identityPolicy??"unverified";if(T!=="unverified"){let D;try{D=JSON.parse(m.identityIssuers??"")}catch{throw new Error("Trusted issuers must be a valid JSON array")}if(!Array.isArray(D)||D.length===0)throw new Error("Verified identity requires at least one trusted issuer");A={policy:T,issuers:D}}let O=(m.quickPrompts??[]).map(D=>({label:(D?.label??"").trim(),text:(D?.text??"").trim()})).filter(D=>D.label.length>0&&D.text.length>0),_={name:m.name.trim(),description:m.description?.trim()||void 0,scope:{defaultProjectId:m.defaultProjectId,allowedProjectIds:w,defaultModelKey:m.defaultModelKey||void 0,allowedModelKeys:C},features:{projectSelector:m.projectSelector,modelSelector:m.modelSelector,threadManagement:m.threadManagement,attachments:m.attachments,hitl:m.hitl,genUI:m.genUI,files:m.files??!1},appearance:{title:m.title?.trim()||void 0,welcomeMessage:m.welcomeMessage?.trim()||void 0,primaryColor:m.primaryColor?.trim()||void 0,...O.length>0?{quickPrompts:O}:{}},identity:A};await d(n?_:{..._,assistantId:t,integration:{type:"react_sdk"}})},g=o.map(m=>({value:m.id,label:m.name})),v=r.map(m=>({value:m.key,label:m.displayName??m.model??m.key}));return(0,Q.jsxs)(_e,{title:n?"Edit Web App":"Create Web App",open:e,onCancel:u,onOk:()=>void y().catch(()=>{}),okText:n?"Save":"Create",confirmLoading:i,width:720,destroyOnHidden:!0,children:[a&&(0,Q.jsx)("div",{role:"alert",style:{color:"#ef4444",marginBottom:12},children:a}),(0,Q.jsxs)(pe,{form:p,layout:"vertical",initialValues:Vi,children:[(0,Q.jsx)(pe.Item,{name:"name",label:"Name",rules:[{required:!0,whitespace:!0},{max:120,message:"Name must be 120 characters or fewer"}],children:(0,Q.jsx)(De,{"aria-label":"Name",maxLength:121})}),(0,Q.jsx)(pe.Item,{name:"description",label:"Description",rules:[{max:1e3,message:"Description must be 1000 characters or fewer"}],children:(0,Q.jsx)(De.TextArea,{"aria-label":"Description",maxLength:1001})}),(0,Q.jsx)(ln,{strong:!0,children:"Project scope"}),(0,Q.jsx)(pe.Item,{name:"projectSelector",valuePropName:"checked",children:(0,Q.jsx)(sn,{"aria-label":"Project selector",onChange:m=>c(m.target.checked),children:"Project selector"})}),(0,Q.jsx)(pe.Item,{name:"allowedProjectIds",label:"Allowed projects",dependencies:["defaultProjectId","projectSelector"],rules:h?[{required:!0,message:"Select at least one project"},{validator:(m,w)=>(w??[]).every(C=>g.some(A=>A.value===C))?Promise.resolve():Promise.reject(new Error("Select valid allowed projects"))},{validator:(m,w)=>(w??[]).includes(p.getFieldValue("defaultProjectId"))?Promise.resolve():Promise.reject(new Error("Default project must be in allowed projects"))}]:void 0,children:(0,Q.jsx)(ot,{"aria-label":"Allowed projects",mode:"multiple",disabled:!h,options:g})}),(0,Q.jsx)(pe.Item,{name:"defaultProjectId",label:"Default project",rules:[{required:!0},{validator:(m,w)=>!w||g.some(C=>C.value===w)?Promise.resolve():Promise.reject(new Error("Select a valid default project"))}],children:(0,Q.jsx)(ot,{"aria-label":"Default project",options:g})}),(0,Q.jsx)(ln,{strong:!0,children:"Model scope (optional)"}),(0,Q.jsx)(pe.Item,{name:"modelSelector",valuePropName:"checked",children:(0,Q.jsx)(sn,{"aria-label":"Model selector",onChange:m=>f(m.target.checked),children:"Model selector"})}),(0,Q.jsx)(pe.Item,{name:"allowedModelKeys",label:"Allowed models",dependencies:["defaultModelKey","modelSelector"],rules:s?[{validator:(m,w)=>w?.length||p.getFieldValue("defaultModelKey")?Promise.resolve():Promise.reject(new Error("Select at least one model"))},{validator:(m,w)=>(w??[]).every(C=>v.some(A=>A.value===C))?Promise.resolve():Promise.reject(new Error("Select valid allowed models"))}]:void 0,children:(0,Q.jsx)(ot,{"aria-label":"Allowed models",mode:"multiple",allowClear:!0,disabled:!s,options:v})}),(0,Q.jsx)(pe.Item,{name:"defaultModelKey",label:"Default model",rules:[{validator:(m,w)=>!w||v.some(C=>C.value===w)?Promise.resolve():Promise.reject(new Error("Select a valid default model"))}],children:(0,Q.jsx)(ot,{"aria-label":"Default model",allowClear:!0,options:v})}),(0,Q.jsx)(ln,{strong:!0,children:"Features"}),(0,Q.jsx)(Pt,{wrap:!0,children:["threadManagement","attachments","hitl","genUI","files"].map(m=>(0,Q.jsx)(pe.Item,{name:m,valuePropName:"checked",noStyle:!0,children:(0,Q.jsx)(sn,{"aria-label":m,children:m})},m))}),(0,Q.jsx)("div",{style:{marginTop:20},children:(0,Q.jsx)(ln,{strong:!0,children:"Appearance"})}),(0,Q.jsx)(pe.Item,{name:"title",label:"Title",rules:[{max:120,message:"Title must be 120 characters or fewer"}],children:(0,Q.jsx)(De,{"aria-label":"Title",maxLength:121})}),(0,Q.jsx)(pe.Item,{name:"welcomeMessage",label:"Welcome message",rules:[{max:1e3,message:"Welcome message must be 1000 characters or fewer"}],children:(0,Q.jsx)(De.TextArea,{"aria-label":"Welcome message",maxLength:1001})}),(0,Q.jsx)(pe.Item,{name:"primaryColor",label:"Primary color",rules:[{pattern:Wi,message:"Use a #RRGGBB color",transform:m=>m||void 0}],children:(0,Q.jsx)(De,{"aria-label":"Primary color",placeholder:"#6366f1"})}),(0,Q.jsx)("div",{style:{marginTop:12},children:(0,Q.jsx)(ln,{strong:!0,children:"Quick prompts"})}),(0,Q.jsx)(pe.List,{name:"quickPrompts",children:(m,{add:w,remove:C})=>(0,Q.jsxs)(Q.Fragment,{children:[m.map(A=>(0,Q.jsxs)(Pt,{align:"baseline",style:{display:"flex",marginBottom:8},children:[(0,Q.jsx)(pe.Item,{name:[A.name,"label"],rules:[{required:!0,whitespace:!0,message:"Quick prompt label is required"},{max:40,message:"Quick prompt label must be 40 characters or fewer"}],children:(0,Q.jsx)(De,{"aria-label":`Quick prompt label ${A.name+1}`,placeholder:"Label",maxLength:41})}),(0,Q.jsx)(pe.Item,{name:[A.name,"text"],rules:[{required:!0,whitespace:!0,message:"Quick prompt message is required"},{max:500,message:"Quick prompt message must be 500 characters or fewer"}],children:(0,Q.jsx)(De,{"aria-label":`Quick prompt message ${A.name+1}`,placeholder:"Message text",maxLength:501,style:{width:360}})}),(0,Q.jsx)(V,{"aria-label":`Remove quick prompt ${A.name+1}`,onClick:()=>C(A.name),children:"Remove"})]},A.key)),(0,Q.jsx)(V,{"aria-label":"Add quick prompt",onClick:()=>w({label:"",text:""}),disabled:m.length>=6,children:"Add quick prompt"})]})}),(0,Q.jsx)("div",{style:{marginTop:20},children:(0,Q.jsx)(ln,{strong:!0,children:"Identity"})}),(0,Q.jsx)(pe.Item,{name:"identityPolicy",label:"Identity policy",initialValue:"unverified",children:(0,Q.jsx)(ot,{"aria-label":"Identity policy",options:[{value:"unverified",label:"Unverified (header)"},{value:"both",label:"Verified token or header (migration)"},{value:"verified",label:"Verified tokens only"}]})}),(0,Q.jsx)(pe.Item,{name:"identityIssuers",label:"Trusted issuers (JSON)",tooltip:'Required when the policy includes verified tokens. Example: [{"iss":"https://host.example.com","aud":"<webAppId>","alg":"HS256","secret":"..."}]',dependencies:["identityPolicy"],rules:[{validator:(m,w)=>{if(p.getFieldValue("identityPolicy")==="unverified"||w===void 0||w.trim()==="")return Promise.resolve();try{let C=JSON.parse(w);return Array.isArray(C)&&C.length>0?Promise.resolve():Promise.reject(new Error("Provide a non-empty JSON array of issuers"))}catch{return Promise.reject(new Error("Trusted issuers must be a valid JSON array"))}}}],children:(0,Q.jsx)(De.TextArea,{"aria-label":"Trusted issuers",rows:3,placeholder:'[{"iss":"https://host.example.com","aud":"<webAppId>","alg":"HS256","secret":"..."}]'})}),(0,Q.jsx)(ln,{type:"secondary",children:"Integration type: react_sdk"})]})]})};var re=R(M()),{Text:So}=We,qn=e=>e instanceof Error?e.message:"Request failed";function Vs(e,t){let n=Zr("lattice_token"),o=new Headers(t?.headers);return n&&o.set("Authorization",`Bearer ${n}`),o.set("X-Axiom-Web-App-Preview","true"),globalThis.fetch(e,{...t,headers:o})}var Hn=(e,t)=>{let n=`import '@axiom-lattice/react-sdk/web-app/styles.css';
172
+
173
+ interface ExampleProps {
174
+ currentUser: { id: string; name?: string };
175
+ }`,o=r=>`<AgentWebAppProvider gatewayUrl="${t}" webAppId="${e.id}" identity={{ mode: 'unverified', userId: currentUser.id, displayName: currentUser.name }}>
176
+ ${r}
177
+ </AgentWebAppProvider>`;return{embed:`<script>
178
+ window.AxiomChatSettings = {
179
+ gatewayUrl: "${t}",
180
+ webAppId: "${e.id}",
181
+ userId: "current-user-id" // stable per-user subject
182
+ };
183
+ <\/script>
184
+ <script src="${t}/embed/agent-chat-loader.js" defer><\/script>`,agentChat:`import { AgentChatApp } from '@axiom-lattice/react-sdk';
185
+ import '@axiom-lattice/react-sdk/styles.css';
186
+ import 'antd/dist/reset.css';
187
+
188
+ interface ExampleProps {
189
+ currentUser: { id: string; name?: string };
190
+ }
191
+
192
+ export function AgentChatExample({ currentUser }: ExampleProps) {
193
+ // Runs the full Console chat stack (LatticeChat + thread history) against
194
+ // this web app over the runtime mirror \u2014 npm SDK path with full control.
195
+ return (
196
+ <AgentChatApp
197
+ gatewayUrl="${t}"
198
+ webAppId="${e.id}"
199
+ identity={{ mode: 'unverified', userId: currentUser.id, displayName: currentUser.name }}
200
+ />
201
+ );
202
+ }`,composable:`import { AgentWebAppProvider, WidgetProjectSelector, WidgetThreadList, WidgetMessageList, WidgetComposer } from '@axiom-lattice/react-sdk/web-app';
203
+ ${n}
204
+
205
+ export function ComposableExample({ currentUser }: ExampleProps) {
206
+ return (
207
+ ${o(` <main>
208
+ <WidgetProjectSelector />
209
+ <WidgetThreadList />
210
+ <WidgetMessageList />
211
+ <WidgetComposer />
212
+ </main>`)}
213
+ );
214
+ }`,hooks:`import { AgentWebAppProvider, useAgentWebApp, useWidgetProject, useWidgetThreads, useWidgetChat } from '@axiom-lattice/react-sdk/web-app';
215
+ ${n}
216
+
217
+ function RuntimeStatus() {
218
+ const runtime = useAgentWebApp();
219
+ const project = useWidgetProject();
220
+ const threads = useWidgetThreads();
221
+ const chat = useWidgetChat();
222
+ return <p>{runtime.bootstrap?.webApp.name}: {project.projectId ?? 'No project'}, {threads.threads.length} threads, {chat.messages.length} messages</p>;
223
+ }
224
+
225
+ export function HooksExample({ currentUser }: ExampleProps) {
226
+ return (
227
+ ${o(" <RuntimeStatus />")}
228
+ );
229
+ }`}},Ao={whiteSpace:"pre-wrap",overflow:"auto",background:"#111827",color:"#e5e7eb",padding:16,borderRadius:10},Qs=[{name:"webAppId",type:"string \xB7 required",description:"Publication id (not the Agent id). Missing \u2192 the loader warns and does not start."},{name:"userId",type:"string \xB7 required",description:"Stable per-user subject. ^[A-Za-z0-9._:@-]+$, \u2264128 chars. Missing/invalid \u2192 the chat does not start and onError fires with USER_ID_REQUIRED."},{name:"gatewayUrl",type:"string",description:"Gateway URL (defaults to the loader script's own origin). Trailing slashes are trimmed."},{name:"mode",type:'"bubble" | "inline"',description:"Bubble popup (default) or embed into the containerSelector element."},{name:"containerSelector",type:"string",description:"Required for inline mode. Falls back to body with a console warning when not found."},{name:"bubble",type:"boolean \xB7 default true",description:"false = no launcher button; drive the panel with open()/hide()."},{name:"width / height",type:"number \xB7 380 / 640",description:"Bubble panel size, clamped to the viewport (min 240)."},{name:"position",type:'"bottom-right" | "bottom-left"',description:"Horizontal anchor for the launcher and panel."},{name:"offsetX / offsetY",type:"number \xB7 20",description:"Viewport margin. Nested form also supported: offset: { x, y }."},{name:"zIndex",type:"number \xB7 9999",description:"Panel stacking (the launcher sits at zIndex + 1)."},{name:"welcome",type:"string",description:"Chat empty-state welcome; overrides the publication appearance.welcomeMessage."},{name:"quicks",type:"{ label, text }[]",description:"Chat empty-state quick prompts (\u22646; label 1-40, text 1-500; invalid entries dropped). Overrides appearance.quickPrompts entirely when provided; clicking one sends its text."}],Ys=[{api:"AxiomChat.open() / hide() / toggle()",behavior:"Show, hide, or toggle the panel. No-ops in inline mode (the chat is always visible in its container)."},{api:"AxiomChat.sendMessage(text)",behavior:"Send a message programmatically \u2014 rendered in the UI like a typed message and streamed from the server. Trimmed non-empty, \u226432768 chars; automatically queued while the chat is busy; before onReady it is buffered and flushed on ready. Send failures show the chat's own inline error banner."},{api:"AxiomChat.mount(settings) / AxiomChat.get(id)",behavior:"Mount additional independent chats (different webAppIds) on one page; returns an instance handle with the full API (open/hide/toggle/sendMessage/onReady/onMessage/onError). get(id) retrieves a mounted handle; without global settings the default-instance delegates warn and no-op."}],Xs=[{event:'["onReady", cb]',payload:"\u2014",when:"The chat can send/receive (handshake complete, thread ready). Buffered sends flush immediately after."},{event:'["onMessage", cb]',payload:'{ role: "human" | "ai", content: string }',when:"Per accepted message: your sent message (server echo) and each completed AI reply (final text \u2014 not per-token). Boot-time history is not replayed; the baseline resets per thread. Structured content is not included."},{event:'["onError", cb]',payload:"{ code: string, message: string }",when:"WEB_APP_NOT_FOUND \xB7 WEB_APP_DISABLED \xB7 USER_ID_REQUIRED \xB7 PROJECT_NOT_ALLOWED \xB7 MODEL_NOT_ALLOWED \xB7 FEATURE_DISABLED \xB7 INVALID_REQUEST \xB7 STREAM_FAILED"}],Yi=({assistant:e})=>{let t=mt("__GLOBAL__"),{user:n,currentTenant:o,baseURL:r}=Vr(),{projects:i}=Lt(),[a,u]=(0,Me.useState)([]),[d,p]=(0,Me.useState)([]),[h,c]=(0,Me.useState)(!1),[s,f]=(0,Me.useState)(null),[y,g]=(0,Me.useState)(null),[v,m]=(0,Me.useState)(null),[w,C]=(0,Me.useState)(!1),[A,T]=(0,Me.useState)(null),[O,_]=(0,Me.useState)(!1),[D,x]=(0,Me.useState)(!1),[B,Z]=(0,Me.useState)(null),[Y,H]=(0,Me.useState)(null),j=(0,Me.useRef)(0),z=(0,Me.useRef)(0),K=(0,Me.useRef)(0),F=(0,Me.useRef)(!1),ne=Array.from(new Map(i.map(L=>[L.id,L])).values()),P=(0,Me.useCallback)(async()=>{let L=++j.current;c(!0),f(null);try{let ie=await t.webApps.list({assistantId:e.id});L===j.current&&u(ie.records)}catch(ie){L===j.current&&f(qn(ie))}finally{L===j.current&&c(!1)}},[e.id,t,o?.id]);(0,Me.useEffect)(()=>(u([]),g(null),T(null),Z(null),H(null),C(!1),_(!1),x(!1),F.current=!1,K.current+=1,P(),()=>{j.current+=1,K.current+=1}),[P]),(0,Me.useEffect)(()=>{let L=++z.current;return t.request("/api/models").then(ie=>{L===z.current&&p(ie.data??[])}).catch(()=>{L===z.current&&p([])}),()=>{z.current+=1}},[t]);let G=async L=>{if(F.current)return;F.current=!0,x(!0);let ie=++K.current;f(null);try{await L(),ie===K.current&&await P()}catch(Ee){ie===K.current&&f(qn(Ee))}finally{ie===K.current&&(F.current=!1,x(!1))}},le=async L=>{if(F.current)return;F.current=!0,x(!0);let ie=++K.current;C(!0),m(null);try{y==="create"?await t.webApps.create(L):y&&await t.webApps.update(y.id,L),ie===K.current&&(g(null),await P())}catch(Ee){ie===K.current&&m(qn(Ee))}finally{ie===K.current&&(F.current=!1,x(!1),C(!1))}},oe=async L=>{f(null);try{if(!navigator.clipboard)throw new Error("Clipboard unavailable");await navigator.clipboard.writeText(L)}catch(ie){f(qn(ie))}},Ie=L=>[{key:"edit",icon:fi,label:"Edit",disabled:D,onClick:g},{key:"toggle",icon:L.status==="active"?oi:ii,label:L.status==="active"?"Disable":"Enable",disabled:D,onClick:ie=>void G(()=>ie.status==="active"?t.webApps.disable(ie.id):t.webApps.enable(ie.id))},{key:"preview",icon:ci,label:"Preview",disabled:D,onClick:Z},{key:"guide",icon:si,label:"Integration guide",disabled:D,onClick:H},{key:"copy",icon:ai,label:"Copy Web App ID",disabled:D,onClick:ie=>void oe(ie.id)},{key:"delete",icon:bi,label:"Delete",danger:!0,disabled:D,onClick:T}],fe=async()=>{if(!A||F.current)return;F.current=!0,x(!0);let L=++K.current;_(!0);try{await t.webApps.delete(A.id),L===K.current&&(T(null),await P())}catch(ie){L===K.current&&f(qn(ie))}finally{L===K.current&&(F.current=!1,x(!1),_(!1))}};return(0,re.jsxs)("div",{style:{height:"100%",overflow:"auto",padding:16},children:[(0,re.jsx)(Vt,{type:"warning",showIcon:!0,message:"Unverified identity",description:"Web Apps trust the external user ID supplied by the embedding application. Do not use it as proof of authentication.",style:{marginBottom:16}}),s&&(0,re.jsx)(Vt,{role:"alert",type:"error",message:s,action:(0,re.jsx)(V,{size:"small",onClick:()=>void P(),children:"Retry"}),style:{marginBottom:16}}),(0,re.jsx)(Ti,{title:"Web Apps",itemName:"app",items:a,loading:h,keyExtractor:L=>L.id,createLabel:D?void 0:"Create Web App",onCreateClick:D?void 0:()=>{m(null),g("create")},renderIcon:()=>(0,re.jsx)(di,{size:22,color:"#6366f1"}),renderPrimary:L=>L.name,renderSecondary:L=>L.description??L.id,renderHeaderActions:L=>(0,re.jsx)(qe,{color:L.status==="active"?"green":L.status==="disabled"?"default":"gold",children:L.status}),renderDetails:L=>(0,re.jsxs)(So,{type:"secondary",children:[L.scope.allowedProjectIds.length," project",L.scope.allowedProjectIds.length===1?"":"s"," \xB7 react_sdk"]}),itemActions:Ie,actionsPosition:"always",showViewToggle:!1,emptyTitle:"No Web Apps",emptyDescription:"Create a React SDK publication for this agent."}),(0,re.jsx)(Qi,{open:y!==null,assistantId:e.id,value:y==="create"?null:y,projects:ne,models:d,submitting:w,error:v,onCancel:()=>g(null),onSubmit:le}),(0,re.jsx)(_e,{title:"Delete Web App",open:A!==null,onCancel:()=>T(null),onOk:()=>void fe(),okText:"Delete",okButtonProps:{danger:!0,loading:O},children:(0,re.jsxs)("p",{children:["Delete \u201C",A?.name,"\u201D? This action cannot be undone."]})}),(0,re.jsx)(_e,{title:"Preview",open:B!==null,onCancel:()=>Z(null),footer:(0,re.jsx)(V,{onClick:()=>Z(null),children:"Close"}),width:900,children:r?B&&B.status==="active"?(0,re.jsx)("iframe",{src:`${r}/api/web-apps/${B.id}/chat?mode=embed`,title:"Web App preview",style:{width:"100%",height:640,border:"1px solid #d9d9d9",borderRadius:8}}):B?(0,re.jsxs)("div",{children:[(0,re.jsx)(Vt,{type:"info",showIcon:!0,message:"Draft preview",description:"This renders the in-page console chat so you can inspect draft content. Enable the publication to preview the exact embed experience external users get.",style:{marginBottom:16}}),(0,re.jsx)(ji,{gatewayUrl:r,webAppId:B.id,identity:{mode:"unverified",userId:`console-preview:${n?.id??"unknown"}:${B.id}`,displayName:n?.name},fetch:Vs})]}):null:(0,re.jsx)(Vt,{type:"warning",message:"Gateway URL unavailable"})}),(0,re.jsx)(_e,{title:"Integration guide",open:Y!==null,onCancel:()=>H(null),footer:(0,re.jsxs)(Pt,{children:[(0,re.jsx)(V,{onClick:()=>Y&&void oe(Object.values(Hn(Y,r)).join(`
230
+
231
+ `)),children:"Copy examples"}),(0,re.jsx)(V,{type:"primary",onClick:()=>H(null),children:"Close"})]}),width:900,children:Y&&(0,re.jsx)(Gr,{defaultActiveKey:"zero-code",items:[{key:"zero-code",label:"Zero-code script loader",children:(0,re.jsxs)(re.Fragment,{children:[(0,re.jsx)(We.Paragraph,{type:"secondary",style:{marginTop:0},children:"One script tag \u2014 the full Console-style chat runs in an isolated iframe on the gateway origin. No build step, no npm install."}),(0,re.jsx)("pre",{style:Ao,children:Hn(Y,r).embed}),(0,re.jsx)(We.Title,{level:5,style:{marginTop:24},children:"Configuration \u2014 window.AxiomChatSettings"}),(0,re.jsx)(io,{size:"small",style:{marginBottom:8},pagination:!1,rowKey:"name",columns:[{title:"Key",dataIndex:"name",key:"name",width:160},{title:"Type",dataIndex:"type",key:"type",width:180},{title:"Description",dataIndex:"description",key:"description"}],dataSource:Qs}),(0,re.jsx)(We.Title,{level:5,children:"JS API \u2014 window.AxiomChat"}),(0,re.jsxs)(We.Paragraph,{type:"secondary",children:["Property and command forms are equivalent; register callbacks or actions before the loader loads with the array form (",'window.AxiomChat = [["onMessage", fn], ["open"]]'," \u2014 replayed in order on load)."]}),(0,re.jsx)(io,{size:"small",style:{marginBottom:8},pagination:!1,rowKey:"api",columns:[{title:"API",dataIndex:"api",key:"api",width:280},{title:"Behavior",dataIndex:"behavior",key:"behavior"}],dataSource:Ys}),(0,re.jsx)(We.Title,{level:5,children:"Events"}),(0,re.jsx)(io,{size:"small",style:{marginBottom:8},pagination:!1,rowKey:"event",columns:[{title:"Register",dataIndex:"event",key:"event",width:220},{title:"Payload",dataIndex:"payload",key:"payload",width:280},{title:"When",dataIndex:"when",key:"when"}],dataSource:Xs}),(0,re.jsx)(Vt,{style:{marginTop:8},type:"warning",showIcon:!0,message:"Host trust and limits",description:"The host page can send messages and read new conversation content \u2014 only embed on trusted pages. One streaming reply at a time; loading the loader twice is unsupported. Not available yet: unread callbacks, runtime theme updates, verified setIdentity, token-level streaming events."})]})},{key:"npm-sdk",label:"npm SDK",children:(0,re.jsxs)(re.Fragment,{children:[(0,re.jsx)(We.Paragraph,{type:"secondary",style:{marginTop:0},children:"React applications \u2014 the same chat stack as a first-class component in your page, fully composable."}),(0,re.jsx)(So,{strong:!0,children:"Full chat \u2014 AgentChatApp"}),(0,re.jsx)("pre",{style:Ao,children:Hn(Y,r).agentChat}),(0,re.jsx)(So,{strong:!0,children:"Composable widgets"}),(0,re.jsx)("pre",{style:Ao,children:Hn(Y,r).composable}),(0,re.jsx)(So,{strong:!0,children:"Hooks"}),(0,re.jsx)("pre",{style:Ao,children:Hn(Y,r).hooks})]})}]})})]})};var q=R(xe());var Js={agent:{color:"agent"},tool:{color:"#06b6d4",section:"tools"},capability:{color:"#6366f1",section:"middleware"},subagent:{color:"#22c55e",section:"subagents"},skill:{color:"#a855f7",section:"skills"},model:{color:"#8c8c8c"},eval:{color:"#f59e0b"}};function Po(e){let t=Js[e];return e==="agent"?"agent":t.color}function el(e){return typeof e=="object"&&e!==null?e:{}}var Eo=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[],gr="skill:__all__";function tl(e){let t=[],n=new Set,o=a=>{n.has(a)||(n.add(a),t.push(a))};for(let a of Eo(e.skills))o(a);let r=!1,i=Array.isArray(e.middleware)?e.middleware:[];for(let a of i){if(a.enabled===!1||a.type!=="skill")continue;let u=typeof a.config=="object"&&a.config!==null?a.config:{};u.readAll===!0&&(r=!0);for(let d of Eo(u.skills))o(d)}return{ids:t,readAll:r}}function Xi(e,t){let n=el(e),o=typeof n.key=="string"?n.key:"agent",r=n.type??"capability",i={id:o,type:"agent",label:n.name||o,description:n.description||void 0,config:{name:n.name||o,type:r,description:n.description||"",modelKey:n.modelKey||"",prompt:n.prompt||"",version:n.metadata?.version||""}},a=(g,v,m,w,C)=>({id:v,type:g,label:m,description:w,config:C}),u=Eo(n.tools).map(g=>a("tool",`tool:${g}`,g)),d=(Array.isArray(n.middleware)?n.middleware:[]).filter(g=>g.enabled!==!1).map(g=>{let v=typeof g.type=="string"?g.type:"unknown";return a("capability",`cap:${v}`,g.name||v,g.description||void 0,g)}),p=Eo(n.subAgents).map(g=>a("subagent",`sub:${g}`,g)),{ids:h,readAll:c}=tl(n),s=[...c?[a("skill",gr,"All skills","Agent can load any available skill")]:[],...h.map(g=>a("skill",`skill:${g}`,g))],f=[{id:"group:tools",type:"tool",label:"Tools",items:u},{id:"group:capabilities",type:"capability",label:"Capabilities",items:d},{id:"group:subagents",type:"subagent",label:"Sub-Agents",items:p},{id:"group:skills",type:"skill",label:"Skills",items:s}],y=t?.includeEmptyGroups?f:f.filter(g=>g.items.length>0);return{agent:i,groups:y}}var Ji=R(M()),Kn=({id:e,position:t,type:n="source"})=>(0,Ji.jsx)(xt,{id:e,type:n,position:t,style:{opacity:0,width:0,height:0,border:"none"},isConnectable:!1});var Yt=R(M()),Do={agent:(0,Yt.jsx)(Bn,{size:14}),tool:(0,Yt.jsx)(vi,{size:12}),capability:(0,Yt.jsx)(ri,{size:12}),subagent:(0,Yt.jsx)(Bn,{size:12}),skill:(0,Yt.jsx)(ui,{size:12}),model:(0,Yt.jsx)(li,{size:12}),eval:(0,Yt.jsx)(co,{size:12})},ea={agent:"Agent",tool:"Tool",capability:"Capability",subagent:"Sub-Agent",skill:"Skill",model:"Model",eval:"Eval Suite"};var ke=R(M()),ta=({type:e="source"})=>(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(Kn,{id:"top",position:it.Top,type:e}),(0,ke.jsx)(Kn,{id:"bottom",position:it.Bottom,type:e}),(0,ke.jsx)(Kn,{id:"left",position:it.Left,type:e}),(0,ke.jsx)(Kn,{id:"right",position:it.Right,type:e})]}),na=({data:e})=>{let{node:t,onClick:n}=e,o=jn(Cn(String(t.config?.type??"react")).color),r=t.config??{};return(0,ke.jsxs)("div",{onClick:n,style:{width:220,background:"#fff",border:`2px solid ${o}`,borderRadius:14,padding:"10px 12px",cursor:"pointer",fontFamily:"inherit"},children:[(0,ke.jsx)(ta,{type:"source"}),(0,ke.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[Do.agent,(0,ke.jsx)("span",{style:{fontSize:13,fontWeight:700,color:"#333",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.label})]}),r.description&&(0,ke.jsx)("div",{style:{fontSize:11,color:"rgba(0,0,0,0.55)",marginBottom:6,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:r.description}),(0,ke.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:6},children:[(0,ke.jsx)(qe,{bordered:!1,style:{margin:0,fontSize:10,background:`${o}1A`,color:o},children:r.type??"capability"}),r.modelKey&&(0,ke.jsx)(qe,{bordered:!1,style:{margin:0,fontSize:10},children:r.modelKey}),r.version&&(0,ke.jsxs)(qe,{bordered:!1,style:{margin:0,fontSize:10},children:["v",r.version]})]}),r.prompt&&(0,ke.jsx)("div",{style:{fontSize:10,color:"#999",background:"#fafafa",borderRadius:6,padding:"4px 8px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.prompt})]})},oa=({data:e})=>{let{group:t,onClick:n,onRemove:o}=e,r=Po(t.type);return(0,ke.jsxs)("div",{style:{border:`1.5px dashed ${r}66`,borderRadius:12,padding:"10px 12px",background:"rgba(255,255,255,0.8)",minWidth:170},children:[(0,ke.jsx)(ta,{type:"target"}),(0,ke.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:8},children:[Do[t.type],(0,ke.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"#666"},children:t.label}),(0,ke.jsxs)("span",{style:{fontSize:10,color:"#bbb"},children:["(",t.items.length,")"]})]}),t.items.length===0?(0,ke.jsx)("div",{style:{fontSize:10,color:"#bbb",padding:"2px 0"},children:"empty"}):(0,ke.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:t.items.map(i=>(0,ke.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,ke.jsxs)("div",{onClick:a=>{a.stopPropagation(),n?.(i)},style:{display:"flex",alignItems:"center",gap:5,padding:"4px 8px",borderRadius:8,background:"#fff",border:`1px solid ${r}55`,fontSize:11,color:"#333",cursor:"pointer",position:"relative",whiteSpace:"nowrap"},children:[Do[i.type],(0,ke.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:i.label})]}),o&&(0,ke.jsx)("button",{onClick:a=>{a.stopPropagation(),o(i)},title:`Remove ${i.label}`,style:{width:14,height:14,borderRadius:"50%",border:"none",background:"transparent",color:"#ccc",fontSize:9,lineHeight:1,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0,flexShrink:0},children:"\u2715"})]},i.id))})]})};var $t=R(xe());function jt(e,t){let n=new Date(e.createdAt).getTime(),o=new Date(t.createdAt).getTime(),r=Number.isFinite(n),i=Number.isFinite(o);return r&&!i?-1:!r&&i?1:r&&i&&n!==o?n-o:e.id<t.id?-1:e.id>t.id?1:0}function ra(e){return{runId:e.id,score:e.avgScore,passRate:e.totalCases>0?Math.round(e.passedCases/e.totalCases*100):null,createdAt:e.createdAt,...e.taskId?{taskId:e.taskId}:{}}}function ia(e,t=1){let n=Number.isFinite(t)?Math.abs(t):1,o=e.filter(y=>Number.isFinite(y.avgScore)&&Number.isFinite(new Date(y.createdAt).getTime())).sort(jt),r=o.filter(y=>y.status==="completed"&&!y.holdout),i=r[r.length-1],a=i?.envProjectId!==void 0,d=(a?r.filter(y=>y.envProjectId===i.envProjectId):r).map(ra),p=o.filter(y=>y.status==="completed"&&y.holdout).map(ra),h=d[d.length-1],c=d[d.length-2],s=h&&c?h.score-c.score:null,f="needs-evidence";return s!==null&&(f=s>n?"improving":s<-n?"regressed":"stable"),{verdict:f,latest:h,previous:c,delta:s,passRate:h?.passRate??null,comparisonLabel:a?"Latest comparable result":"Latest recorded result",trend:d,validationTrend:p,runningRuns:o.filter(y=>y.status==="running"),failedRuns:o.filter(y=>y.status==="failed"||y.status==="aborted")}}var Gt=R(xe()),aa=R(M()),dn=({option:e,height:t=200,onEvents:n})=>{let o=(0,Gt.useRef)(null),r=(0,Gt.useRef)(null),i=(0,Gt.useRef)(e),a=(0,Gt.useRef)(n);return(0,Gt.useEffect)(()=>{i.current=e,r.current?.setOption(e,!0)},[e]),(0,Gt.useEffect)(()=>{a.current=n;let u=r.current;if(!u||!n)return;let d=Object.entries(n);for(let[p,h]of d)u.on(p,h);return()=>{for(let[p,h]of d)u.off(p,h)}},[n]),(0,Gt.useEffect)(()=>{let u=!1,d=null;return(async()=>{let p=await import("./embed-page-echarts-7KZDMH4F.js");if(u||!o.current)return;let h=p.init(o.current);r.current=h,h.setOption(i.current,!0);let c=a.current;if(c)for(let[s,f]of Object.entries(c))h.on(s,f);d=new ResizeObserver(()=>r.current?.resize()),d.observe(o.current)})().catch(p=>{console.error("[EChart] async init failed:",p)}),()=>{u=!0,d?.disconnect(),r.current?.dispose(),r.current=null}},[]),(0,aa.jsx)("div",{ref:o,style:{width:"100%",height:t}})};var pa=R(M()),sa={total:0,last7d:0,last30d:0,lastActive:null,daily7d:[],daily30d:[],loading:!0,error:null},fr=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),la=(e,t)=>{if(!(typeof e=="string"||typeof e=="number"||e instanceof Date))return null;let n=new Date(e).getTime();return Number.isFinite(n)&&n<=t?n:null},nl=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),da=e=>{let t=nl(e);return Math.floor(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())/864e5)},ol=(e,t)=>da(e)-da(t);function ca(e){let{get:t}=Xe(),[n,o]=$t.default.useState(sa),r=$t.default.useRef(0),i=$t.default.useRef(e);return i.current=e,$t.default.useEffect(()=>{let a=++r.current,u=!0,d=()=>u&&r.current===a&&i.current===e;return o(p=>({...p,loading:!0,error:null})),(async()=>{try{let p=await t(`/api/assistants/${e}/threads`);if(!fr(p)||p.success!==!0||!fr(p.data))throw new Error("Invalid thread list response");let{records:h,total:c}=p.data;if(!Array.isArray(h)||typeof c!="number"||!Number.isSafeInteger(c)||c<0)throw new Error("Invalid thread list response");let s=Date.now(),f=new Date(s),y=null,g=0,v=0,m=new Array(7).fill(0),w=new Array(30).fill(0);for(let C of h){if(!fr(C))continue;let A=la(C.createdAt,s);if(A!==null){let O=ol(f,new Date(A));O>=0&&O<7&&(g++,m[6-O]++),O>=0&&O<30&&(v++,w[29-O]++)}let T=la(C.updatedAt,s);T!==null&&(y===null||T>y)&&(y=T)}if(!d())return;o({total:c,last7d:g,last30d:v,lastActive:y===null?null:new Date(y),daily7d:m,daily30d:w,loading:!1,error:null})}catch(p){if(!d())return;o({...sa,loading:!1,error:p instanceof Error?p:new Error("Failed to load thread activity")})}})(),()=>{u=!1,r.current===a&&r.current++}},[t,e]),n}function Lo(e){if(!e)return"\u2014";let t=Date.now()-e.getTime(),n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;let o=Math.floor(n/60);if(o<24)return`${o}h ago`;let r=Math.floor(o/24);return r<30?`${r}d ago`:r<365?`${Math.floor(r/30)}mo ago`:`${Math.floor(r/365)}y ago`}function No(e){let{projects:t,loading:n,error:o,refresh:r}=fo(),i=Io(t,e),a=i?.id??"",{suites:u,loading:d,error:p,refresh:h}=wn(a),{runs:c,inventoryProjectId:s,loading:f,error:y,refresh:g}=go(a),v=(0,$t.useCallback)(async()=>{await Promise.all([r(),h(),g()])},[r,h,g]);return{...(0,$t.useMemo)(()=>{let w=u.reduce((_,D)=>_+(D.caseCount??0),0),C=s===a?c.filter(_=>_.projectId===a):[],A=[...C].sort(jt),T=ia(C),O=T.latest?C.find(_=>_.id===T.latest?.runId):void 0;return{evalProjectId:i?.id,inventoryProjectId:s,suiteCount:u.length,caseCount:w,scores:T.trend.map(_=>_.score),latest:O,runs:A,runCount:C.length,passRate:T.passRate,score:T.latest?.score??null,hasEvalProject:!!i,suiteNames:u.map(_=>_.name??"Unnamed").filter(Boolean),error:o??p??y,loading:!!(n||a&&(s!==a||d||f))}},[u,c,s,i,a,n,d,f,o,p,y]),refresh:v,refreshRuns:g}}var rl=(e,t=new Date)=>{let n=[];for(let o=e-1;o>=0;o--){let r=new Date(t.getFullYear(),t.getMonth(),t.getDate()-o);n.push([String(r.getFullYear()).padStart(4,"0"),String(r.getMonth()+1).padStart(2,"0"),String(r.getDate()).padStart(2,"0")].join("-"))}return n},il=e=>rl(e).map(t=>t.slice(5)),al="#6366f1";var sl={left:8,right:8,top:24,bottom:24,containLabel:!0};function ua(e){return{grid:sl,tooltip:{trigger:"axis"},xAxis:{type:"category",data:il(e.length),axisLabel:{fontSize:9,interval:4,color:"#999"},axisLine:{lineStyle:{color:"#eee"}}},yAxis:{type:"value",minInterval:1,axisLabel:{fontSize:9,color:"#999"},splitLine:{lineStyle:{color:"#f5f5f5"}}},series:[{type:"bar",data:e,itemStyle:{color:al,borderRadius:[2,2,0,0]},barMaxWidth:10}]}}var Zn=R(xe());var cn=R(M()),ga=({values:e,width:t=120,height:n=32,color:o="#6366f1",placeholderColor:r="#e5e5e5"})=>{if(e.length===0)return null;let i=Math.max(...e,1),a=t/e.length,u=a>4?1:0,d=2;return(0,cn.jsx)("svg",{width:t,height:n,style:{display:"block"},children:e.map((p,h)=>{let c=Math.max(p/i*n,d);return(0,cn.jsx)("rect",{x:h*a,y:n-c,width:Math.max(a-u,1),height:c,fill:p===0?r:o,rx:1},h)})})},fa=({values:e,width:t=200,height:n=40,color:o="#6366f1"})=>{if(e.length===0)return null;let r=Math.min(...e),a=Math.max(...e)-r||1,u=2,d=t-u*2,p=s=>e.length===1?t/2:u+s/(e.length-1)*d,h=s=>n-2-(s-r)/a*(n-4),c=e.map((s,f)=>`${p(f)},${h(s)}`).join(" ");return(0,cn.jsxs)("svg",{width:t,height:n,style:{display:"block"},children:[(0,cn.jsx)("polyline",{points:c,fill:"none",stroke:o,strokeWidth:"1.5",strokeLinecap:"round"}),e.map((s,f)=>(0,cn.jsx)("circle",{cx:p(f),cy:h(s),r:"2.5",fill:o},f))]})};var ze=R(xe());var Jt=R(xe());var Mo=R(xe());var Xt=R(M()),ma=({projectId:e,value:t,onChange:n})=>{let{uploadFileToProject:o}=Lt(),[r,i]=(0,Mo.useState)([]),a=(0,Mo.useRef)(e);a.current=e;let u=t.map(c=>({uid:c.uri,name:c.name||c.uri,status:"done",response:{uri:c.uri,name:c.name}})),d=async c=>{let s=c.file;try{let f=await o(e,"/project/uploads",s);c.onSuccess?.({uri:f.path,name:s.name,projectId:e})}catch(f){c.onError?.(f instanceof Error?f:new Error("Upload failed"))}},p=c=>{let{file:s}=c;if(s.status==="done"&&s.response?.uri){if(s.response.projectId&&s.response.projectId!==a.current){i(c.fileList.filter(y=>y.status==="uploading"||y.status==="error"));return}let f={uri:s.response.uri,name:s.response.name||s.name,addedBy:"user"};t.some(y=>y.uri===f.uri)||n([...t,f])}s.status==="error"&&rt.error(`Failed to upload "${s.name}"`),i(c.fileList.filter(f=>f.status==="uploading"||f.status==="error"))},h=c=>{if(c.status==="done"){let s=c.response?.uri;n(t.filter(f=>f.uri!==s&&f.name!==c.name))}else i(s=>s.filter(f=>f.uid!==c.uid))};return(0,Xt.jsx)("div",{"data-testid":"reference-files-field",children:(0,Xt.jsxs)(Kr.Dragger,{multiple:!0,fileList:[...u,...r],customRequest:d,onChange:p,onRemove:h,style:{padding:"8px 0"},children:[(0,Xt.jsx)("p",{className:"ant-upload-drag-icon",style:{marginBottom:4},children:(0,Xt.jsx)(pi,{size:24,style:{color:"#6366f1"}})}),(0,Xt.jsx)("p",{className:"ant-upload-text",style:{fontSize:13},children:"Click or drag files to this area to upload"}),(0,Xt.jsx)("p",{className:"ant-upload-hint",style:{fontSize:12},children:"Files are stored in the selected project under /project/uploads"})]},e)})};function An(e){return(e.metadata??{}).trainingRound===!0}function Su(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)>>>0;return t.toString(36).slice(0,6)}function Oo(e){return["pending","in_progress","review"].includes(e.status)}function En(e,t){return`/api/tasks?${`metadata=${encodeURIComponent(JSON.stringify({trainingRound:"true",targetAgentId:e}))}`}${t?`&projectId=${t}`:""}`}function ll(e,t){return`/api/tasks?${`parentId=${e}`}${t?`&projectId=${t}`:""}`}function ya(e,t){return`${e}:${t}`}async function ha(e){let t=e.projectId?{headers:{"x-project-id":e.projectId}}:void 0,o=(await e.post("/api/tasks",{title:e.goal.slice(0,60),description:e.goal,ownerType:"agent",ownerId:"agent-architect",workspaceId:e.workspaceId??void 0,projectId:e.projectId??void 0,context:{source:"learning"},metadata:{trainingRound:!0,targetAgentId:e.targetAgentId},files:e.files&&e.files.length>0?e.files:void 0},t)).data;if(!o)throw new Error("Failed to create learning round task");let r=e.existingThreadId??null;if(!r&&(r=(await e.post("/api/assistants/agent-architect/threads",{metadata:{training:!0,targetAgentId:e.targetAgentId}})).data?.id??null,!r))throw new Error("Failed to create training thread");return await e.put(`/api/tasks/${o.id}`,{metadata:{trainingRound:!0,targetAgentId:e.targetAgentId,trainingSessionId:r}},t),{roundTaskId:o.id,threadId:r}}function ba(e){let t=e.graphDefinition,n=t;if(typeof t=="string")try{n=JSON.parse(t)}catch{n={}}let o=n!==null&&typeof n=="object"&&!Array.isArray(n)?n:{},r=o.metadata!==null&&typeof o.metadata=="object"&&!Array.isArray(o.metadata)?o.metadata:{};return r.learningPlaceholder==="true"&&r.architectureStatus==="undecided"?"placeholder":o.type==="workflow"?"existing-workflow":"existing-agent"}function va(e){let t=e.targetMode==="placeholder"?"Target form: learning placeholder (architecture undecided).":e.targetMode==="existing-workflow"?"Target form: existing Workflow.":"Target form: existing Capability or Orchestra.";return[`Learning goal (draft \u2014 confirm with the user before any observation or design): ${e.goal}`,`Exact target ID: "${e.targetAgentId}".`,`Exact round Task ID: "${e.roundTaskId}".`,"That exact Task is your bound tracking task: your main task and Belief root for this round.","Reconcile it; create every child under it; never create a new main or round task.",t,...e.files?.length?[`Reference files: ${e.files.map(n=>`${n.name||n.uri} (${n.uri})`).join(", ")}. Read them before designing; in your first reply state which files you actually read and what you took from each.`]:[]].join(`
232
+ `)}var dl=5;async function ka(e,t,n){let o=n?.projectId,r=o?{headers:{"x-project-id":o}}:void 0,i=c=>ll(c,o??void 0),a=[],u=!1,d=new Set,p=new Set([t]),h=[t];for(let c=0;c<dl&&h.length>0;c++){let f=(await Promise.all(h.map(y=>e(i(y),r).then(g=>Array.isArray(g.data)?g.data.map(v=>v.parentId?v:{...v,parentId:y}):[]).catch(()=>(u=!0,d.add(y),[]))))).flat().filter(y=>p.has(y.id)?!1:(p.add(y.id),!0));a.push(...f),h=f.map(y=>y.id)}if(h.length>0){u=!0;for(let c of h)d.add(c)}return{tasks:a,partial:u,...d.size>0?{incompleteParentIds:[...d]}:{}}}var Ue=R(M()),Pn=({open:e,agentId:t,defaultProjectId:n,onClose:o,onCreated:r})=>{let{get:i,post:a,put:u}=Xe(),{message:d}=bn.useApp(),p=mt("agent-architect"),{trainingProjects:h,loading:c}=Lt(),s=h.find(_=>_.id===n)??null,[f]=pe.useForm(),[y,g]=(0,Jt.useState)(!1),[v,m]=(0,Jt.useState)(null),[w,C]=(0,Jt.useState)(null),[A,T]=(0,Jt.useState)([]);return(0,Jt.useEffect)(()=>{e&&(C(ya(p.tenantId,t)),T([]))},[e,p,t]),(0,Jt.useEffect)(()=>{if(!e)return;let _=!1;return(async()=>{try{let D=await i(En(t,s?.id??void 0),s?{headers:{"x-project-id":s.id}}:void 0);if(_)return;let x=(D.data??[]).filter(An);m(x.find(Oo)??null)}catch{}})(),()=>{_=!0}},[e,i,t,s]),(0,Ue.jsxs)(_e,{title:"New Learning Task",open:e,onCancel:o,footer:null,width:520,destroyOnClose:!0,children:[v&&(0,Ue.jsx)(Vt,{type:"warning",showIcon:!0,style:{marginBottom:16},message:"A learning task is already in progress. Complete it before starting a new one."}),(0,Ue.jsxs)(pe,{form:f,layout:"vertical",onFinish:async _=>{if(!s){d.error("No learning project is available");return}g(!0);try{let{roundTaskId:D,threadId:x}=await ha({goal:_.goal,targetAgentId:t,workspaceId:s.workspaceId,projectId:s.id,existingThreadId:w,files:A,post:a,put:u});d.success("Learning task created. Preparing the Architect\u2026"),f.resetFields(),r(D,x,_.goal,A),T([])}catch(D){d.error(D instanceof Error?D.message:"Failed to create the learning task. Please try again.")}finally{g(!1)}},children:[(0,Ue.jsx)(pe.Item,{label:"Learning Goal for This Round",name:"goal",rules:[{required:!0,message:"Please describe what you want this agent to learn or improve in this round"}],children:(0,Ue.jsx)(De.TextArea,{rows:3,placeholder:"e.g. Improve the agent's accuracy when handling price disputes based on the price protection policy"})}),s&&(0,Ue.jsx)(pe.Item,{label:(0,Ue.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,Ue.jsx)("span",{children:"Reference Materials"}),(0,Ue.jsx)(lr,{project:s,selectable:!1,loading:c})]}),extra:"Optional. These materials will be used as reference for this learning round.",style:{marginBottom:16},colon:!1,children:(0,Ue.jsx)(ma,{projectId:s.id,value:A,onChange:T})}),!s&&!c&&(0,Ue.jsx)(pe.Item,{style:{marginBottom:16},children:(0,Ue.jsx)(lr,{project:s,projects:h,loading:c})}),(0,Ue.jsxs)(pe.Item,{style:{marginBottom:0,textAlign:"right"},children:[(0,Ue.jsx)(V,{onClick:o,style:{marginRight:8},children:"Cancel"}),(0,Ue.jsx)(V,{type:"primary",htmlType:"submit",loading:y,disabled:!!v||c||!s,children:"Start Learning"})]})]})]})};var ye=R(xe());var un=R(M()),xa=32,ul=8,pl=xa-ul,gl="Activity could not be loaded. Please try again shortly.",fl="Too many activity requests are still pending. Please try again shortly.",mr=ye.default.createContext(null),Ta=ye.default.createContext(()=>{});function wa(e){switch(e){case"retry":return"Task retry started";case"cancel":return"Task cancelled";case"start":return"Task started";case"reopen":return"Task reopened";case"delete":return"Task deleted";case"comment":return"Comment added";default:return"Task updated"}}var ml={start:"in_progress",retry:"in_progress",reopen:"in_progress",cancel:"cancelled"};function yl(e,t){return new Promise((n,o)=>{let r=window.setTimeout(()=>o(new Error("Work-item request timed out")),t);e.then(i=>{window.clearTimeout(r),n(i)},i=>{window.clearTimeout(r),o(i)})})}var yr=({task:e,relatedTasks:t,onClose:n,onRefresh:o,height:r})=>{let{message:i}=bn.useApp(),[a,u]=(0,ye.useState)(null),[d,p]=(0,ye.useState)([]),[h,c]=(0,ye.useState)([]),[s,f]=(0,ye.useState)(!1),[y,g]=(0,ye.useState)(null),v=mt("__GLOBAL__"),w=ye.default.useContext(mr)??{getWorkItemRequest:(W,N,X,de)=>j(W,N,X,de),getDetailSession:()=>D.current,bumpDetailSession:()=>{D.current+=1}},C=(0,ye.useRef)(0),A=(0,ye.useRef)(null),T=(0,ye.useRef)(!0),O=(0,ye.useRef)(new Map),_=(0,ye.useRef)(new Set),D=(0,ye.useRef)(0),x=(0,ye.useRef)(v);x.current=v;let B=(0,ye.useRef)(w);B.current=w;let Z=a??e,Y=(0,ye.useRef)(Z);Y.current=Z;let H=(0,ye.useRef)(o);H.current=o;let j=(W,N,X=D.current,de=!1)=>{let S=O.current.get(W);if(S&&(!de||S.detailSession===X))return S;S&&(O.current.delete(W),_.current.add(S.promise),S.promise.finally(()=>{_.current.delete(S.promise)}).catch(()=>{}));let Pe=de?xa:pl;if(O.current.size+_.current.size>=Pe){let Le=Promise.reject(new Error("Work-item request capacity reached"));return Le.catch(()=>{}),{promise:Le,source:N,detailSession:X}}let Te;try{Te=Promise.resolve(x.current.tasks.workItems.list(W))}catch(Le){Te=Promise.reject(Le)}let Ae={promise:Te,source:N,detailSession:X};return O.current.set(W,Ae),Te.finally(()=>{O.current.get(W)?.promise===Te&&O.current.delete(W)}).catch(()=>{}),Ae};(0,ye.useEffect)(()=>(T.current=!0,()=>{T.current=!1,A.current=null,C.current+=1,B.current.bumpDetailSession(),Promise.resolve().then(()=>{T.current||(O.current.clear(),_.current.clear())})}),[]);let z=(W,N=!0)=>{let X=N?++C.current:C.current;N&&T.current&&f(!0);let de=w.getDetailSession(),S=w.getWorkItemRequest(W,"detail",de,N),Pe=S.detailSession===de;return yl(S.promise,4e3).then(he=>{Pe&&T.current&&X===C.current&&A.current===W&&(c(he),g(null))}).catch(he=>{Pe&&N&&T.current&&X===C.current&&A.current===W&&(c([]),g(he instanceof Error&&he.message==="Work-item request capacity reached"?fl:gl))}).finally(()=>{Pe&&T.current&&X===C.current&&A.current===W&&f(!1)})},K=(W,N)=>{N&&p(X=>Z?[...X,Z]:X),A.current=W.id,u(W),c([]),g(null),z(W.id)},F=W=>K(W,!0),ne=()=>{if(d.length===0)return;let W=d[d.length-1];p(d.slice(0,-1)),K(W,!1)},P=()=>{w.bumpDetailSession(),A.current=null,C.current+=1,u(null),p([]),c([]),f(!1),g(null),n()},G=(0,ye.useRef)(null),{run:le,pending:oe}=Mi({onSettled:W=>{if(!T.current)return;A.current===W.id&&z(W.id,!1);let N=H.current,X=wa(G.current??"start");N&&Promise.resolve().then(N).catch(()=>{T.current&&i.warning(`${X}, but the task list could not be refreshed`)})}}),Ie=(0,ye.useCallback)(W=>{let N=Y.current;return N?(G.current="comment",le(N,"comment",{content:W})):Promise.resolve(!1)},[le]),fe=W=>{let N=Y.current;N&&(G.current=W,le(N,W).then(X=>{if(!X||!T.current)return;let de=ml[W];de&&u(S=>S&&S.id===N.id?{...S,status:de}:S),i.success(wa(W))}))};(0,ye.useEffect)(()=>{A.current!==e.id&&(p([]),K(e,!1))},[e]),(0,ye.useEffect)(()=>{let W=A.current;if(!W)return;let N=t.find(de=>de.id===W);if(!N){P();return}u(de=>de&&de.id===W?N:de);let X=new Map(t.map(de=>[de.id,de]));p(de=>de.flatMap(S=>{let Pe=X.get(S.id);return Pe?[Pe]:[]})),z(W,!1)},[e,t]),(0,ye.useEffect)(()=>{if(!Z?.id)return;let W=Z.id,N=!1,X=async()=>{document.hidden||await z(W,!1)},de=()=>{N||!T.current||document.hidden||X()};return document.addEventListener("visibilitychange",de),X(),()=>{N=!0,document.removeEventListener("visibilitychange",de)}},[Z?.id]);let L=xo(Z),ie=ye.default.useContext(Ta);(0,ye.useEffect)(()=>{ie(e,Z)},[ie,e,Z]);let Ee=Z?!!oe[Z.id]:!1;return(0,un.jsx)("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"#fff",border:"1px solid rgba(5,5,5,0.15)",borderRadius:12,overflow:"hidden"},children:(0,un.jsx)("div",{style:{flex:1,minHeight:0},children:(0,un.jsx)(wo,{task:Z,relatedTasks:t,onRelatedTaskClick:F,workItems:h,loading:s,activityError:y??void 0,commandPending:Ee,onRun:fe,onComment:Ie,commentPending:Ee,onViewChat:L,onBack:ne,canGoBack:d.length>0,maxHeight:r,focusKey:`${Z.id}:${Ee?"updating":Z.status}`,subtasks:t.filter(W=>W.parentId===Z.id),onSubtaskClick:F,parent:t.find(W=>W.id===Z.parentId)??null,onParentClick:F})})})},Ra=({task:e,relatedTasks:t,onClose:n,onRefresh:o})=>{let[r,i]=(0,ye.useState)(null),a=(0,ye.useCallback)((d,p)=>{i({rootId:d.id,title:p.title})},[]);(0,ye.useEffect)(()=>{e||i(null)},[e]);let u=e?r&&r.rootId===e.id?r.title:e.title:"";return(0,un.jsx)(_e,{open:e!==null,onCancel:n,footer:null,title:u,width:960,style:{maxWidth:"calc(100vw - 32px)"},styles:{header:{padding:"16px 24px 0"},content:{padding:0},body:{padding:"12px 24px 24px"}},centered:!0,children:(0,un.jsx)(Ta.Provider,{value:a,children:e&&(0,un.jsx)(yr,{task:e,relatedTasks:t,onClose:n,onRefresh:o,height:"calc(100dvh - 96px)"})})})};var Ce=R(M()),hr=32,hl=8,bl=hr-hl;function vl(e){for(let t of e.split(`
233
+ `)){let n=t.trim().match(/^#{1,6}\s+(.*)$/);if(n){let o=n[1].trim();if(o.length>0)return o}}}function kl(e){let t=typeof e.detail?.markdown=="string"&&e.detail.markdown.length>0?e.detail.markdown:void 0;if(t){let n=vl(t);if(n)return n}return e.summary||e.action||""}function wl(e){let t=e.context?.interruption;return e.status==="interrupted"&&typeof t=="object"&&t!==null&&t.type==="review_required"}function xl(e,t){return new Promise((n,o)=>{let r=window.setTimeout(()=>o(new Error("Work-item request timed out")),t);e.then(i=>{window.clearTimeout(r),n(i)},i=>{window.clearTimeout(r),o(i)})})}var Ia=({assistantId:e,projectId:t,onLearningStarted:n,round:o,subTasks:r,rounds:i,subTasksByRound:a,selectedRoundId:u,onSelectedRoundChange:d,loading:p,onRefresh:h,onStartRequest:c,onExpandWorkflow:s})=>{let{message:f}=bn.useApp(),[y,g]=(0,ze.useState)(!1),[v,m]=(0,ze.useState)(!1),[w,C]=(0,ze.useState)(null),[A,T]=(0,ze.useState)(null),O=mt("__GLOBAL__"),_=(0,ze.useRef)(!0),D=(0,ze.useRef)(new Map),x=(0,ze.useRef)(new Set),B=(0,ze.useRef)(0),Z=(0,ze.useRef)(0),Y=i&&i.length>0?i:o?[o]:[],[H,j]=(0,ze.useState)(null),z=u!==void 0,K=z?u:H,F=Y.map(S=>S.id).join(",");(0,ze.useEffect)(()=>{if(Y.length===0){j(null);return}j(S=>S&&F.split(",").includes(S)?S:Y[0].id)},[F]);let ne=Y.find(S=>S.id===K)??Y[0]??null,P=S=>{z||j(S),d?.(S)},G=a&&ne?a[ne.id]??[]:ne&&ne.id===o?.id?r:[],le=(0,ze.useMemo)(()=>[ne,...G].filter(S=>S!==null),[o,r,i,a,K]),oe=G.filter(S=>S.status==="in_progress"),Ie=oe[0]??null,fe=ne?.status==="in_progress",L=(oe.length>0?oe.map(S=>S.id):fe&&ne?[ne.id]:[]).sort(),ie=L.join(","),Ee=(0,ze.useRef)(O);Ee.current=O;let W=(0,ze.useRef)(null);W.current||(W.current={getWorkItemRequest:(S,Pe,he,Te)=>N(S,Pe,he,Te),getDetailSession:()=>B.current,bumpDetailSession:()=>{B.current+=1}});let N=(S,Pe,he=B.current,Te=!1)=>{let Ae=D.current.get(S);if(Ae&&(!Te||Ae.detailSession===he))return Ae;Ae&&(D.current.delete(S),x.current.add(Ae.promise),Ae.promise.finally(()=>{x.current.delete(Ae.promise)}).catch(()=>{}));let Le=Te?hr:bl;if(D.current.size+x.current.size>=Le){let Ne=Promise.reject(new Error("Work-item request capacity reached"));return Ne.catch(()=>{}),{promise:Ne,source:Pe,detailSession:he}}let Fe;try{Fe=Promise.resolve(Ee.current.tasks.workItems.list(S))}catch(Ne){Fe=Promise.reject(Ne)}let Je={promise:Fe,source:Pe,detailSession:he};return D.current.set(S,Je),Fe.finally(()=>{D.current.get(S)?.promise===Fe&&D.current.delete(S)}).catch(()=>{}),Je};(0,ze.useEffect)(()=>(_.current=!0,()=>{_.current=!1,Promise.resolve().then(()=>{_.current||(D.current.clear(),x.current.clear())})}),[]),(0,ze.useEffect)(()=>{if(L.length===0){T(null);return}T(null);let S=!1,Pe=()=>{if(document.hidden)return Promise.resolve();let Te=Z.current%L.length,Ae=[...L.slice(Te),...L.slice(0,Te)];return Z.current=(Te+hr)%L.length,Promise.allSettled(Ae.map(Le=>xl(N(Le,"live").promise,4e3))).then(Le=>{if(S||!_.current)return;let nt=Le.filter(Ne=>Ne.status==="fulfilled").map(Ne=>Ne.value);if(nt.length===0)return;let Je=[...nt.flat().filter(Ne=>!/^Status changed to\b/i.test(Ne.summary??""))].sort((Ne,gt)=>new Date(gt.createdAt).getTime()-new Date(Ne.createdAt).getTime());T(Je[0]??null)})},he=()=>{S||!_.current||document.hidden||Pe()};return document.addEventListener("visibilitychange",he),Pe(),()=>{S=!0,document.removeEventListener("visibilitychange",he)}},[ie]);let X=S=>C(S),de=(S,Pe,he,Te)=>{P(S),g(!1);let Ae;try{Ae=Promise.resolve(h())}catch{Ae=Promise.reject(new Error("Task-list refresh failed"))}Ae.catch(()=>{_.current&&f.error("Task created, but the task list could not be refreshed")}),n?.(he,S,Te)};return(0,Ce.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.6)",border:"1px solid rgba(240, 240, 240, 0.7)",borderRadius:10,padding:"8px 10px",boxShadow:"0 2px 10px rgba(0,0,0,0.06)",backdropFilter:"blur(8px)",pointerEvents:"auto",width:300},children:[p?(0,Ce.jsx)("div",{style:{fontSize:12,color:"#bbb",padding:"4px 2px"},children:"Loading..."}):ne?(0,Ce.jsxs)("div",{children:[(0,Ce.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6,padding:"0 2px 6px",borderBottom:"1px solid rgba(240,240,240,0.7)",marginBottom:6},children:[(0,Ce.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"#595959"},children:"Learning Tasks"}),(0,Ce.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:2},children:[s&&(0,Ce.jsx)(V,{size:"small",type:"text","aria-label":"Open workflow view",icon:(0,Ce.jsx)(vn,{}),onClick:s}),(0,Ce.jsx)(V,{size:"small",type:"text",icon:(0,Ce.jsx)(Dt,{}),onClick:()=>c?c():g(!0),style:{fontSize:12},children:"New Learning Task"})]})]}),Y.length>1&&(0,Ce.jsx)(ot,{size:"small","data-testid":"round-filter",style:{width:"100%",marginBottom:6},value:ne.id,onChange:P,options:Y.map(S=>({value:S.id,label:`${S.title||S.id} (${S.status})`}))}),(()=>{let S=le.filter(wl);return S.length>0?(0,Ce.jsxs)(V,{type:"text","data-testid":"review-banner","aria-label":`Open ${S.length} task${S.length>1?"s":""} waiting for approval`,onClick:()=>X(S[0]),style:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:6,cursor:"pointer",width:"100%",height:"auto",fontSize:12,fontWeight:600,color:"#b45309",background:"rgba(245,158,11,0.12)",border:"1px solid rgba(245,158,11,0.35)",borderRadius:8,padding:"5px 8px",marginBottom:6},children:[S.length," item",S.length>1?"s":""," waiting for approval"]}):null})(),A&&(0,Ce.jsxs)("div",{"data-testid":"live-status",style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:"#666",padding:"2px 2px 6px",borderBottom:"1px solid rgba(240,240,240,0.7)",marginBottom:4},children:[(0,Ce.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:Ie?"#3b82f6":"#bbb",animation:Ie?"live-pulse 1.2s ease-in-out infinite":void 0}}),(0,Ce.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:kl(A)}),(0,Ce.jsx)("style",{children:"@keyframes live-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }"})]}),(0,Ce.jsx)("div",{style:{maxHeight:240,overflow:"auto"},children:(0,Ce.jsx)(ko,{tasks:[ne,...G],loading:!1,onTaskClick:X,hideCompleted:v,onHideCompletedChange:m})})]}):(0,Ce.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 2px"},children:[(0,Ce.jsx)("span",{style:{fontSize:12,color:"#999"},children:"No learning tasks yet"}),(0,Ce.jsx)(V,{size:"small",icon:(0,Ce.jsx)(Dt,{}),onClick:()=>c?c():g(!0),children:"New Learning Task"})]}),!c&&(0,Ce.jsx)(Pn,{open:y,agentId:e,defaultProjectId:t,onClose:()=>g(!1),onCreated:de}),(0,Ce.jsx)(mr.Provider,{value:W.current,children:(0,Ce.jsx)(Ra,{task:w,relatedTasks:le,onClose:()=>C(null),onRefresh:h})})]})};var Oe=R(xe());function Ca(e,t){let n=[...t],o=new Set(t.map(u=>`${u.from}|${u.to}`)),r=new Set(t.filter(u=>u.kind==="dependency").map(u=>u.to)),i=new Set(e.map(u=>u.id)),a=new Map;for(let u of e){if(!u.parentId||!i.has(u.parentId))continue;let d=a.get(u.parentId)??[];d.push(u),a.set(u.parentId,d)}for(let u of a.values()){let d=[...u].sort((p,h)=>new Date(p.createdAt).getTime()-new Date(h.createdAt).getTime());for(let p=1;p<d.length;p++){let h=d[p];if(r.has(h.id))continue;let c=d[p-1].id,s=`${c}|${h.id}`;o.has(s)||o.has(`${h.id}|${c}`)||(n.push({from:c,to:h.id,kind:"sequence"}),o.add(s))}}return n}function Sa(e,t){return e!=="completed"?"idle":t==="in_progress"?"flowing":t==="pending"?"idle":"traversed"}function Aa(e){return e==="completed"?"traversed":e==="in_progress"?"flowing":"idle"}var qt={pending:{label:"Pending",color:"#9ca3af",active:!1},in_progress:{label:"Running",color:"#3b82f6",active:!0},review:{label:"Review",color:"#8b5cf6",active:!1},failed:{label:"Failed",color:"#ef4444",active:!1},interrupted:{label:"Interrupted",color:"#f59e0b",active:!1},completed:{label:"Done",color:"#22c55e",active:!1},cancelled:{label:"Cancelled",color:"#9ca3af",active:!1}};var Nt=R(M()),Ea=({data:e})=>{let{task:t}=e,n=qt[t.status];return(0,Nt.jsxs)("div",{"data-testid":"workflow-task-node","data-active":String(n.active),style:{width:180,padding:"8px 10px",borderRadius:10,border:`1.5px solid ${n.color}`,background:"#fff",animation:n.active?"workflow-node-pulse 1.6s ease-in-out infinite":void 0},children:[(0,Nt.jsx)(xt,{type:"target",position:it.Left,style:{opacity:0}}),(0,Nt.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[(0,Nt.jsx)("span",{style:{width:8,height:8,borderRadius:9999,background:n.color,flexShrink:0}}),(0,Nt.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"#262626",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t.title,children:t.title})]}),(0,Nt.jsx)("div",{style:{fontSize:10,color:"#8c8c8c"},children:n.label}),(0,Nt.jsx)(xt,{type:"source",position:it.Right,style:{opacity:0}}),n.active&&(0,Nt.jsx)("style",{children:"@keyframes workflow-node-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.35); } 50% { box-shadow: 0 0 0 6px rgba(59,130,246,0.08); } }"})]})};var at=R(M()),Tl={workflowTask:Ea},Rl=180,Il=56,Cl={traversed:{stroke:"#22c55e",strokeWidth:1.5},flowing:{stroke:"#6366f1",strokeWidth:2},idle:{stroke:"#d1d5db",strokeWidth:1,strokeDasharray:"5 5"}},Pa=({rounds:e,subTasksByRound:t,loading:n})=>{let o=mt("__GLOBAL__"),[r,i]=(0,Oe.useState)(null),[a,u]=(0,Oe.useState)(null),[d,p]=(0,Oe.useState)([]),[h,c]=(0,Oe.useState)(!1),[s,f]=(0,Oe.useState)(null),y=(0,Oe.useRef)(0),g=(0,Oe.useRef)(o);g.current=o;let v=e.map(P=>P.id).join(",");(0,Oe.useEffect)(()=>{i(P=>P&&v.split(",").includes(P)?P:e[0]?.id??null)},[v]);let m=e.find(P=>P.id===r)??e[0]??null,w=(0,Oe.useMemo)(()=>[m,...m?t[m.id]??[]:[]].filter(P=>P!==null),[m,t]),{nodes:C,edges:A}=(0,Oe.useMemo)(()=>vo(w),[w]),T=(0,Oe.useMemo)(()=>Ca(w,A),[w,A]),O=(0,Oe.useMemo)(()=>new Map(w.map(P=>[P.id,P])),[w]),_=(0,Oe.useMemo)(()=>{let P=ho(C.map(G=>({id:G.id})),T.map(G=>({from:G.from,to:G.to})),{nodeWidth:Rl,nodeHeight:Il,nodesep:24,ranksep:60,rankdir:"LR"});return C.map(G=>({id:G.id,type:"workflowTask",position:P.get(G.id)??{x:0,y:0},data:{task:G.task}}))},[C,T]),D=(0,Oe.useMemo)(()=>T.map(P=>{let G=Sa(O.get(P.from)?.status??"pending",O.get(P.to)?.status??"pending");return{id:`${P.from}->${P.to}:${P.kind}`,source:P.from,target:P.to,animated:G==="flowing",style:{...Cl[G],...P.kind==="sequence"&&G!=="idle"?{strokeDasharray:"2 3"}:{}}}}),[T,O]),[x,B,Z]=xn(_),[Y,H,j]=Tn(D);(0,Oe.useEffect)(()=>{B(P=>{let G=P.map(oe=>oe.id).sort().join("|"),le=_.map(oe=>oe.id).sort().join("|");if(G===le){let oe=new Map(P.map(Ie=>[Ie.id,Ie]));return _.map(Ie=>{let fe=oe.get(Ie.id);return fe?{...Ie,position:fe.position}:Ie})}return _}),H(D)},[_,D,B,H]);let z=(0,Oe.useCallback)(P=>{let G=++y.current;c(!0),f(null),g.current.tasks.workItems.list(P).then(le=>{G===y.current&&p(le)}).catch(()=>{G===y.current&&(p([]),f("Activity could not be loaded. Please try again shortly."))}).finally(()=>{G===y.current&&c(!1)})},[]),K=(0,Oe.useCallback)((P,G)=>{let le=G.data?.task;le&&(p([]),u(le),z(le.id))},[z]),F=(0,Oe.useCallback)(()=>{y.current+=1,u(null),p([]),f(null),c(!1)},[]),ne=xo(a);return n?(0,at.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,at.jsx)(wt,{size:"large"})}):!m||w.length===0?(0,at.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,at.jsx)(Bt,{description:"No tasks"})}):(0,at.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[e.length>1&&(0,at.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",paddingBottom:12,flexShrink:0},children:e.map((P,G)=>{let le=qt[P.status],oe=P.id===m.id;return(0,at.jsxs)("button",{type:"button","data-testid":`round-chip-${P.id}`,onClick:()=>{i(P.id),F()},title:P.title,style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11,fontWeight:600,padding:"3px 10px",borderRadius:9999,cursor:"pointer",border:oe?"1.5px solid #6366f1":"1px solid #e5e7eb",background:oe?"rgba(99,102,241,0.08)":"#fff",color:oe?"#6366f1":"#6b7280"},children:[(0,at.jsx)("span",{style:{width:6,height:6,borderRadius:9999,background:le.color}}),"R",e.length-G]},P.id)})}),(0,at.jsx)("div",{style:{flex:1,minHeight:0,position:"relative"},children:(0,at.jsx)(bo,{nodes:x,edges:Y,nodeTypes:Tl,onNodesChange:Z,onEdgesChange:j,onNodeClick:K,fitView:!0,fitViewOptions:{padding:.15},nodesDraggable:!0,nodesConnectable:!1,miniMap:!0,attributionPosition:"bottom-right"})}),a&&(0,at.jsx)("div",{"data-testid":"workflow-detail",style:{height:"40%",minHeight:200,flexShrink:0,borderTop:"1px solid #f0f0f0",overflow:"hidden"},children:(0,at.jsx)(wo,{task:a,relatedTasks:w,workItems:d,loading:h,activityError:s??void 0,onViewChat:ne,onBack:F,subtasks:w.filter(P=>P.parentId===a.id),onSubtaskClick:P=>{p([]),u(P),z(P.id)},parent:w.find(P=>P.id===a.parentId)??null,onParentClick:P=>{p([]),u(P),z(P.id)}})})]})};var Rt=R(xe());var Mt=R(M()),Sl=0,La=360,Na=48,Da=16;function br(e){let t=typeof window>"u"?1200:window.innerWidth-Na;return Math.min(Math.max(e,La),t)}var lt=({open:e,width:t,mobileWidth:n,left:o,top:r=56,bottom:i=12,height:a,title:u,onClose:d,bodyStyle:p,restoreFocusRef:h,focusControlRef:c,escapeEnabled:s=!0,zIndex:f=25,children:y})=>{let g=xi("(max-width: 720px)"),v=(0,Rt.useRef)(null),m=(0,Rt.useRef)(null),w=(0,Rt.useRef)(null);w.current||(w.current=`canvas-dock-title-${++Sl}`);let C=w.current,[A,T]=(0,Rt.useState)(null);(0,Rt.useEffect)(()=>T(null),[t,n]);let O=!g&&typeof t=="number",_=g?n??t:A??t,D=typeof _=="number"?_:null,x=o===void 0?-1:1,B=Y=>{if(!O||D===null)return;Y.preventDefault();let H={startX:Y.clientX,startWidth:D},j=K=>{T(br(H.startWidth+x*(K.clientX-H.startX)))},z=()=>{window.removeEventListener("pointermove",j),window.removeEventListener("pointerup",z)};window.addEventListener("pointermove",j),window.addEventListener("pointerup",z)},Z=Y=>{!O||D===null||(Y.key==="ArrowLeft"?(Y.preventDefault(),T(br(D-x*Da))):Y.key==="ArrowRight"&&(Y.preventDefault(),T(br(D+x*Da))))};return(0,Rt.useEffect)(()=>{if(!e||!s)return;let Y=H=>{H.key==="Escape"&&!H.defaultPrevented&&d()};return document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)},[s,e,d]),(0,Rt.useEffect)(()=>{if(c)return c.current=()=>v.current?.focus(),()=>{c.current=null}},[c]),(0,Rt.useEffect)(()=>{if(!e)return;let Y=h?.current??document.activeElement;return Y instanceof HTMLElement&&(m.current=Y),v.current?.focus(),()=>{m.current?.focus(),m.current=null}},[e]),e?(0,Mt.jsxs)("div",{"data-testid":"canvas-dock",role:"region","aria-labelledby":C,style:{position:"absolute",top:r,...o===void 0?{right:12}:{left:o},...a===void 0?{bottom:i}:{height:a},width:_,maxWidth:"calc(100% - 24px)",boxSizing:"border-box",zIndex:f,display:"flex",flexDirection:"column",background:"rgba(255,255,255,0.92)",backdropFilter:"blur(12px)",borderRadius:16,border:"1px solid rgba(240,240,240,0.9)",boxShadow:"0 8px 32px rgba(0,0,0,0.12)",animation:"canvas-dock-in 0.2s ease",overflow:"hidden"},children:[(0,Mt.jsx)("style",{children:"@keyframes canvas-dock-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }"}),O&&(0,Mt.jsx)("div",{"data-testid":"canvas-dock-resize-handle",role:"separator","aria-orientation":"vertical","aria-label":"Resize panel","aria-valuenow":D??void 0,"aria-valuemin":La,"aria-valuemax":typeof window>"u"?void 0:window.innerWidth-Na,tabIndex:0,onPointerDown:B,onKeyDown:Z,style:{position:"absolute",...o===void 0?{left:0}:{right:0},top:0,bottom:0,width:6,cursor:"ew-resize",zIndex:1,touchAction:"none"}}),(0,Mt.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"12px 16px",borderBottom:"1px solid rgba(240,240,240,0.9)",flexShrink:0,fontSize:13,fontWeight:600,color:"#333"},children:[(0,Mt.jsx)("div",{id:C,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:u}),(0,Mt.jsx)("button",{ref:v,type:"button","aria-label":"Close dock",onClick:d,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:24,height:24,border:"none",borderRadius:6,background:"transparent",color:"#999",cursor:"pointer",flexShrink:0},children:(0,Mt.jsx)(ki,{size:14})})]}),(0,Mt.jsx)("div",{"data-testid":"canvas-dock-body",style:{flex:1,minHeight:0,overflow:"auto",padding:16,...p},children:y})]}):null};var _t=R(xe());var _o=80;function Ot(e){return e>=80?"#22c55e":e>=50?"#f59e0b":"#ef4444"}function Un(e){return e.filter(t=>t.status==="completed"&&t.holdout!==!0).sort(jt)}function Ma(e){let t=Un(e),n=t[t.length-1];if(!n)return{latestScore:null,delta:null,passRate:null,passedCases:0,totalCases:0,interruptedCases:0,latestRunId:null};let o=t[t.length-2],r=n.totalCases??0,i=n.passedCases??0;return{latestScore:n.avgScore,delta:o?Math.round(n.avgScore-o.avgScore):null,passRate:r>0?Math.round(i/r*100):null,passedCases:i,totalCases:r,interruptedCases:n.interruptedCases??0,latestRunId:n.id}}function Oa(e){let t=new Map;for(let n of e)if(!n.interrupted)for(let o of n.dimensionResults??[]){let r=t.get(o.name)??{sum:0,count:0};r.sum+=o.score,r.count+=1,t.set(o.name,r)}return[...t.entries()].map(([n,{sum:o,count:r}])=>({name:n,avgScore:Math.round(o/r*10)/10,count:r})).sort((n,o)=>n.avgScore-o.avgScore)}var Al=.15,_a={left:36,right:12,top:16,bottom:24},vr={fontSize:9,color:"#999"};function Fa(){return{type:"value",min:0,max:100,axisLabel:{...vr},splitLine:{lineStyle:{color:"#f5f5f5"}}}}function Wa({rounds:e,runs:t,selectedRoundId:n}){let o=[...e].sort((s,f)=>new Date(s.createdAt).getTime()-new Date(f.createdAt).getTime()),r=t.filter(s=>s.status==="completed").sort(jt),i=new Map(o.map((s,f)=>[s.id,f+1])),a=new Map;for(let s of r){let f=s.taskId?i.get(s.taskId):void 0;f!==void 0&&a.set(f,(a.get(f)??0)+1)}let u=new Map,d=[],p=new Map;for(let s of r){let f=s.taskId?i.get(s.taskId):void 0;if(f===void 0)continue;let y=u.get(f)??0;if(u.set(f,y+1),s.holdout===!0){let g=(y-((a.get(f)??1)-1)/2)*Al;d.push([Math.round((f+g)*100)/100,s.avgScore])}else p.set(f,s.avgScore)}let h=n??null;if(h===null){for(let s=o.length-1;s>=0;s--)if(p.has(s+1)){h=o[s].id;break}}let c=o.map((s,f)=>{let y=p.get(f+1);if(y===void 0)return null;let g=s.id===h;return{value:[f+1,y],itemStyle:{color:Ot(y),borderRadius:[4,4,0,0],...g?{borderColor:"#6366f1",borderWidth:2}:{}}}});return{grid:_a,tooltip:{trigger:"item"},xAxis:{type:"value",min:.5,max:o.length+.5,interval:1,axisLabel:{...vr,formatter:s=>Number.isInteger(s)?`R${s}`:""},axisLine:{lineStyle:{color:"#eee"}},splitLine:{show:!1}},yAxis:Fa(),series:[{type:"bar",data:c,barWidth:22,markLine:{silent:!0,symbol:"none",lineStyle:{type:"dashed",color:"#d9d9d9"},label:{fontSize:9,color:"#999",formatter:`target ${_o}`},data:[{yAxis:_o}]}},{type:"scatter",data:d,symbol:"diamond",symbolSize:9,itemStyle:{color:"#fff",borderColor:"#f59e0b",borderWidth:1.5},z:4}]}}function za(e){let t=e.filter(r=>r.status==="completed").sort(jt),n=[],o=[];return t.forEach((r,i)=>{r.holdout===!0?o.push([i+1,r.avgScore]):n.push([i+1,r.avgScore])}),{grid:_a,tooltip:{trigger:"item"},xAxis:{type:"value",min:.5,max:Math.max(t.length,1)+.5,interval:1,axisLabel:{...vr,formatter:r=>Number.isInteger(r)?`#${r}`:""},axisLine:{lineStyle:{color:"#eee"}},splitLine:{show:!1}},yAxis:Fa(),series:[{type:"line",data:n,symbol:"circle",symbolSize:6,lineStyle:{color:"#6366f1",width:1.5},itemStyle:{color:"#6366f1"},markLine:{silent:!0,symbol:"none",lineStyle:{type:"dashed",color:"#d9d9d9"},label:{fontSize:9,color:"#999",formatter:`target ${_o}`},data:[{yAxis:_o}]}},{type:"scatter",data:o,symbol:"diamond",symbolSize:9,itemStyle:{color:"#fff",borderColor:"#f59e0b",borderWidth:1.5},z:4}]}}var dt=R(M()),kr={fontSize:10,color:"#999"},wr={fontSize:22,fontWeight:700,lineHeight:1.2},Ba=({summary:e})=>e.latestScore===null?null:(0,dt.jsxs)("div",{"data-testid":"eval-summary",style:{display:"flex",gap:28},children:[(0,dt.jsxs)("div",{children:[(0,dt.jsxs)("div",{style:{...wr,color:Ot(e.latestScore)},children:[e.latestScore.toFixed(1),e.delta!==null&&(0,dt.jsxs)("span",{"data-testid":"summary-delta",style:{fontSize:11,fontWeight:600,color:e.delta>=0?"#22c55e":"#ef4444",marginLeft:6},children:[e.delta>=0?"\u25B2":"\u25BC"," ",Math.abs(e.delta)]})]}),(0,dt.jsx)("div",{style:kr,children:"latest score"})]}),(0,dt.jsxs)("div",{children:[(0,dt.jsx)("div",{"data-testid":"summary-pass",style:{...wr,color:"#262626"},children:e.passRate!==null?`${e.passRate}%`:"\u2014"}),(0,dt.jsxs)("div",{style:kr,children:["pass \xB7 ",e.passedCases,"/",e.totalCases]})]}),e.interruptedCases>0&&(0,dt.jsxs)("div",{"data-testid":"summary-interrupted",children:[(0,dt.jsx)("div",{style:{...wr,color:"#b45309"},children:e.interruptedCases}),(0,dt.jsx)("div",{style:kr,children:"interrupted"})]})]});var ct=R(xe());var Dn=R(M()),ja=({agentId:e,projectId:t,runs:n,selectedRoundId:o,onSelectRound:r})=>{let{get:i}=Xe(),[a,u]=(0,ct.useState)([]),[d,p]=(0,ct.useState)(!1),[h,c]=(0,ct.useState)(null),s=ct.default.useRef(i);s.current=i,(0,ct.useEffect)(()=>{let v=!1;return s.current(En(e,t)).then(m=>{if(v)return;let w=(m.data??[]).filter(An);w.sort((C,A)=>new Date(C.createdAt).getTime()-new Date(A.createdAt).getTime()),u(w),p(!0)}).catch(()=>{v||p(!0)}),()=>{v=!0}},[e,t]),(0,ct.useEffect)(()=>{h&&!a.some(v=>v.id===h)&&c(null)},[a,h]);let f=(0,ct.useMemo)(()=>Wa({rounds:a,runs:n,selectedRoundId:o??h}),[a,n,o,h]),y=(0,ct.useMemo)(()=>({click:v=>{let m=v;if(m.seriesType!=="bar"||typeof m.dataIndex!="number")return;let w=a[m.dataIndex];w&&(c(w.id),r?.(w.id))}}),[a,r]),g=(0,ct.useMemo)(()=>{if(a.length===0)return!1;let v=new Set(a.map(m=>m.id));return Un(n).some(m=>m.taskId!==void 0&&v.has(m.taskId))},[a,n]);return d?g?(0,Dn.jsxs)("div",{"data-testid":"round-trend-chart",style:{border:"1px solid #f0f0f0",borderRadius:12,padding:12},children:[(0,Dn.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"rgba(0,0,0,0.65)",marginBottom:8},children:"Score by learning round"}),(0,Dn.jsx)(dn,{option:f,height:100,onEvents:y})]}):(0,Dn.jsx)("div",{"data-testid":"round-trend-empty",style:{display:"none"}}):null};var en=R(M()),Ga=({dimensions:e})=>e.length===0?null:(0,en.jsx)("div",{"data-testid":"dimension-panorama",style:{display:"flex",flexDirection:"column",gap:4},children:e.map(t=>{let n=Math.min(Math.max(t.avgScore,0),100);return(0,en.jsxs)("div",{"data-testid":`dimension-row-${t.name}`,style:{display:"flex",alignItems:"center",gap:8,fontSize:11},children:[(0,en.jsx)("span",{"data-testid":`dimension-label-${t.name}`,style:{flexShrink:0,maxWidth:"60%",color:"#595959",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t.name,children:t.name}),(0,en.jsx)("div",{style:{flex:1,height:8,background:"#f5f5f5",borderRadius:4,overflow:"hidden"},children:(0,en.jsx)("div",{"data-testid":`dimension-fill-${t.name}`,style:{width:`${n}%`,height:"100%",background:Ot(t.avgScore),borderRadius:4}})}),(0,en.jsx)("span",{style:{width:28,textAlign:"right",flexShrink:0,fontWeight:600,color:Ot(t.avgScore)},children:Math.round(t.avgScore)})]},t.name)})});var Ht=R(M());function $a(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!n.holdout&&n.status==="completed"&&typeof n.id=="string")return n.id}return null}var qa=({results:e})=>{if(e===null)return null;let t=e.filter(o=>o.interrupted).length,n=e.filter(o=>!o.pass&&!o.interrupted).flatMap(o=>o.dimensionResults??[]).sort((o,r)=>o.score-r.score).slice(0,3);return(0,Ht.jsxs)("div",{style:{marginTop:8},"data-testid":"run-insights",children:[t>0&&(0,Ht.jsxs)("div",{"data-testid":"interrupted-count",style:{fontSize:12,color:"#b45309",marginBottom:6},children:[t," interrupted"]}),n.length===0?(0,Ht.jsx)("div",{style:{fontSize:12,color:"#22c55e"},children:"All cases passed"}):n.map((o,r)=>(0,Ht.jsxs)("div",{style:{fontSize:12,padding:"3px 0",display:"flex",gap:6,alignItems:"baseline"},children:[(0,Ht.jsx)("span",{style:{color:"#333",fontWeight:600,flexShrink:0},children:o.name}),(0,Ht.jsx)("span",{style:{color:o.score>=50?"#f59e0b":"#ef4444",flexShrink:0},children:o.score}),(0,Ht.jsx)("span",{style:{color:"#888",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.reason.length>80?`${o.reason.slice(0,80)}\u2026`:o.reason})]},`${o.name}-${r}`))]})};var ut=R(M()),Ha={fontSize:12,fontWeight:600,color:"rgba(0,0,0,0.65)",marginBottom:8},Ka={border:"1px solid #f0f0f0",borderRadius:12,padding:12},pn=({agentId:e,projectId:t,runs:n,showRoundTrend:o=!0})=>{let{get:r}=Xe(),i=(0,_t.useMemo)(()=>Ma(n),[n]),a=$a(n),u=n.find(y=>y.id===a),[d,p]=(0,_t.useState)(null),h=_t.default.useRef(r);h.current=r,(0,_t.useEffect)(()=>{if(!a){p(null);return}let y=!1;return h.current(`/api/eval/runs/${a}`).then(g=>!y&&p(g.data?.results??[])).catch(()=>!y&&p([])),()=>{y=!0}},[a]);let c=(0,_t.useMemo)(()=>Oa(d??[]),[d]),s=(0,_t.useMemo)(()=>za(n),[n]),f=Un(n).length>0;return i.latestScore===null?(0,ut.jsx)("div",{style:{height:120,display:"flex",alignItems:"center",justifyContent:"center",color:"#bfbfbf",fontSize:12},children:"No eval runs yet"}):(0,ut.jsxs)("div",{"data-testid":"eval-quality-panel",style:{display:"flex",flexDirection:"column",gap:12},children:[(0,ut.jsx)(Ba,{summary:i}),o&&(0,ut.jsx)(ja,{agentId:e,projectId:t,runs:n}),f&&(0,ut.jsxs)("div",{"data-testid":"run-trend-card",style:Ka,children:[(0,ut.jsx)("div",{style:Ha,children:"Score by run"}),(0,ut.jsx)(dn,{option:s,height:160})]}),a&&d!==null&&(0,ut.jsxs)("div",{"data-testid":"run-diagnosis-card",style:Ka,children:[(0,ut.jsxs)("div",{style:Ha,children:["Latest run",u?` \xB7 ${Lo(new Date(u.createdAt))}`:""," \xB7 ",i.passedCases,"/",i.totalCases," passed"]}),(0,ut.jsx)(Ga,{dimensions:c}),(0,ut.jsx)(qa,{results:d})]})]})};var ae=R(M()),Ua={background:"rgba(255, 255, 255, 0.6)",border:"1px solid rgba(240, 240, 240, 0.7)",borderRadius:10,padding:"8px 12px",boxShadow:"0 2px 10px rgba(0,0,0,0.06)",backdropFilter:"blur(8px)",pointerEvents:"auto",cursor:"pointer"},El=async()=>{},Pl={rounds:[],round:null,subTasks:[],subTasksByRound:{},loading:!1},Fo=({assistantId:e,projectId:t,onProjectChange:n,onLearningStarted:o,learningTasks:r=Pl,topOffset:i=12,onLearningRefresh:a,evalTick:u,showLearning:d=!0,variant:p="full",children:h})=>{let[c,s]=(0,Zn.useState)(null),[f,y]=(0,Zn.useState)(!1),g=ca(e),v=No(e);return(0,Zn.useEffect)(()=>{u!==void 0&&u>0&&v.refresh()},[u]),p==="selector"?(0,ae.jsxs)("div",{style:{position:"absolute",left:12,top:i,zIndex:10,pointerEvents:"none",display:"flex",flexDirection:"column",gap:8},children:[(0,ae.jsx)("div",{style:{pointerEvents:"auto"},children:(0,ae.jsx)(sr,{kind:"training",disableDropdown:!1,showWorkspace:!1,value:t,onChange:n})}),h]}):(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsxs)("div",{style:{position:"absolute",left:12,top:i,zIndex:10,display:"flex",flexDirection:"column",gap:8,pointerEvents:"none"},children:[(0,ae.jsx)("div",{style:{pointerEvents:"auto"},children:(0,ae.jsx)(sr,{kind:"training",disableDropdown:!1,showWorkspace:!1,value:t,onChange:n})}),(0,ae.jsxs)("div",{onClick:()=>s(c==="runtime"?null:"runtime"),title:"Click for 30-day chart",style:Ua,children:[(0,ae.jsx)("div",{style:{fontSize:10,fontWeight:600,color:"#999",marginBottom:4},children:"Runtime"}),(0,ae.jsxs)("div",{style:{display:"flex",gap:14,fontSize:12,alignItems:"center"},children:[(0,ae.jsxs)("span",{children:[(0,ae.jsx)("strong",{style:{color:"#595959"},children:g.total})," ",(0,ae.jsx)("span",{style:{color:"#bbb"},children:"threads"})]}),(0,ae.jsxs)("span",{children:[(0,ae.jsx)("strong",{style:{color:"#595959"},children:g.last7d})," ",(0,ae.jsx)("span",{style:{color:"#bbb"},children:"7d"})]}),(0,ae.jsxs)("span",{children:[(0,ae.jsx)("strong",{style:{color:"#595959"},children:g.last30d})," ",(0,ae.jsx)("span",{style:{color:"#bbb"},children:"30d"})]}),(0,ae.jsx)("span",{style:{color:"#999"},children:Lo(g.lastActive)}),g.daily7d.length>0&&(0,ae.jsx)(ga,{values:g.daily7d,width:56,height:20,color:"#8c8c8c"})]})]}),(0,ae.jsxs)("div",{onClick:()=>s(c==="eval"?null:"eval"),title:"Click for score trend",style:Ua,children:[(0,ae.jsx)("div",{style:{fontSize:10,fontWeight:600,color:"#999",marginBottom:4},children:"Eval quality"}),(0,ae.jsxs)("div",{style:{display:"flex",gap:14,fontSize:12,alignItems:"center"},children:[(0,ae.jsxs)("span",{children:[(0,ae.jsx)("strong",{style:{color:v.score===null?"#d9d9d9":v.score>=80?"#22c55e":v.score>=50?"#f59e0b":"#ef4444"},children:v.score!==null?v.score.toFixed(1):"\u2014"})," ",(0,ae.jsx)("span",{style:{color:"#bbb"},children:"score"})]}),(0,ae.jsxs)("span",{children:[(0,ae.jsx)("strong",{style:{color:"#595959"},children:v.passRate!==null?`${v.passRate}%`:"\u2014"})," ",(0,ae.jsx)("span",{style:{color:"#bbb"},children:"pass"})]}),(0,ae.jsxs)("span",{children:[(0,ae.jsx)("strong",{style:{color:"#595959"},children:v.runCount})," ",(0,ae.jsx)("span",{style:{color:"#bbb"},children:"runs"})]}),v.scores.length>1&&(0,ae.jsx)(fa,{values:v.scores.slice(-10),width:64,height:20,color:v.score===null?"#d9d9d9":v.score>=80?"#22c55e":v.score>=50?"#f59e0b":"#ef4444"})]})]}),d&&(0,ae.jsx)(Ia,{assistantId:e,projectId:t,onLearningStarted:o,round:r.round,subTasks:r.subTasks,rounds:r.rounds,subTasksByRound:r.subTasksByRound,loading:r.loading,onRefresh:a??El,onExpandWorkflow:()=>y(!0)})]}),c==="runtime"&&(0,ae.jsxs)("div",{style:{position:"absolute",left:340,top:12,zIndex:11,background:"#fff",borderRadius:12,padding:16,border:"1px solid #f0f0f0",boxShadow:"0 6px 24px rgba(0,0,0,0.15)",width:420},children:[(0,ae.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"rgba(0,0,0,0.65)",marginBottom:8},children:"Runtime \u2014 last 30 days"}),(0,ae.jsx)(dn,{option:ua(g.daily30d),height:220})]}),c==="eval"&&(0,ae.jsx)(lt,{open:!0,width:720,title:"Eval quality",onClose:()=>s(null),children:(0,ae.jsx)(pn,{agentId:e,runs:v.runs??[]})}),f&&(0,ae.jsx)(lt,{open:!0,width:860,title:"Learning workflow",onClose:()=>y(!1),children:(0,ae.jsx)(Pa,{rounds:r.rounds,subTasksByRound:r.subTasksByRound,loading:r.loading})})]})};var Uo=R(xe());var It=R(xe());var zo=(e,t,n,o,r)=>({id:e,label:t,x:n-o/2,y:-r/2,width:o,height:r}),gn=zo("zone:config","CONFIG",-767,900,620),Ln=zo("zone:testing","EVALUATION",-69,400,560),Wo=zo("zone:learning","LEARNING",459,560,680),Za=zo("zone:copilot","COPILOT",1147,720,740);var Va=[gn.id,Ln.id,Wo.id,Za.id],Qa=.45,Dl=220,Ll=110,Nl=200,Bo=90,jo={"group:subagents":{x:0,y:-190},"group:capabilities":{x:330,y:0},"group:tools":{x:0,y:190},"group:skills":{x:-330,y:0}},Ya=e=>({x:e.x+e.width/2-Dl/2,y:e.y+e.height/2-Ll/2}),Xa=(e,t,n)=>{let o=jo[t]??{x:0,y:0};return{x:e.x+e.width/2+o.x-Nl/2,y:e.y+e.height/2+o.y-n/2}},Ml=310,Ol=e=>{let t=gn.x+gn.width/2,n=Ml;for(let[o,r]of Object.entries(e)){let i=jo[o];i&&(n=Math.max(n,Math.abs(i.y)+r/2+40))}return{id:gn.id,label:gn.label,x:t-gn.width/2,y:-n,width:gn.width,height:n*2}},_l=900,xr={x:20,y:20},Vn=110,Qn=48,Fl=220,Wl=560,zl=e=>({id:Ln.id,label:Ln.label,x:Ln.x,y:Ln.y,width:Ln.width,height:Math.max(Wl,Fl+e+24)}),Ja=(e,t,n)=>({x:e.x+e.width/2-Vn/2,y:e.y+e.height/2-Qn/2}),Bl=48,jl=520,Gl=720,yt=20,Tr=150,Rr=12,es=56,Ir=12,ts=e=>Math.round((e-Rr*2-Ir)/2),ns=(e,t,n)=>{let o={},r=Rr,i=es,a=Ir,u=ts(e),d=e-r*2-a-u,p=t-i-r,h=Math.round((p-a)/2),c=n.has("learning"),s=n.has("evaluation");return n.has("copilot")?(o.copilot={width:u},c&&(o.learning=s?{left:r,top:i,width:d,height:h}:{left:r,top:i,width:d,height:p}),s&&(o.evaluation=c?{left:r,top:i+h+a,width:d,height:p-h-a}:{left:r,top:i,width:d,height:p}),o):c&&s?(o.learning={left:r,top:i,width:d,height:p},o.evaluation={left:r+d+a,top:i,width:u,height:p},o):(c&&(o.learning={width:u}),s&&(o.evaluation={width:u}),o)},Go=260,os=(e,t,n,o)=>{let r=Rr,i=es,a=Ir,u=r+Go+a,d=ts(e),p=e-u-r-(o?d+a:0);return{left:u,top:i,width:Math.min(n==="evaluation"?720:860,Math.max(p,0)),height:t-i-r}},rs=e=>{let t=Ol(e.groupHeights),n={...zl(e.suitesGroupHeight),width:jl},o=Math.max(Wo.width,e.learningDagBBox.width+yt*2),r={...Wo,width:o,height:Math.max(Wo.height,e.learningDagBBox.height+Tr+yt*2)},i={...Za,width:Gl},a=Math.max(_l,t.height,n.height,r.height,i.height),u=t.x,d=p=>{let h={x:u,y:-a/2,width:p.width,height:a};return u+=p.width+Bl,h};return{config:{...d(t),label:t.label,id:t.id},learning:{...d(r),label:r.label,id:r.id},testing:{...d(n),label:n.label,id:n.id},copilot:{...d(i),label:i.label,id:i.id},height:a}};var ee=R(M());function Ar(e,t){for(let n of e.rounds){let o=e.subTasksByRound[n.id]??[];if(n.id===t)return{task:n,related:[n,...o]};let r=o.find(i=>i.id===t);if(r)return{task:r,related:[n,...o]}}return null}function $l(e,t){let n=e.rounds;if(t){let o=n.find(r=>r.id===t);if(o)return o}for(let o of n)if(Oo(o))return o;return e.round??n[0]??null}function Er(e,t){let n=$l(e,t);return n?[n,...e.subTasksByRound[n.id]??[]]:[]}var $o=200,is=80,ql=40,Hl=70,Sr={width:0,height:0},Kl=e=>({headerOffset:{x:e.x+yt,y:e.y+yt},headerWidth:e.width-yt*2,dagOffset:{x:e.x+yt,y:e.y+Tr+yt}}),Ul={background:"rgba(255,255,255,0.92)",border:"1px solid rgba(240,240,240,0.9)",borderRadius:14,padding:"10px 12px"},Zl={traversed:{stroke:"#22c55e",strokeWidth:1.5},flowing:{stroke:"#6366f1",strokeWidth:2},idle:{stroke:"#d1d5db",strokeWidth:1}},Vl={stroke:"#cbd5e1",strokeOpacity:.55,strokeWidth:1,strokeDasharray:"5 4"},Ql={type:"arrowclosed",color:"#cbd5e1",width:16,height:16};function as(e){let t=e.context?.interruption;return e.status==="interrupted"&&typeof t=="object"&&t!==null&&t.type==="review_required"}function ss(e){if(!e)return null;let t=new Date(e).getTime();if(!Number.isFinite(t))return null;let n=Math.floor((Date.now()-t)/6e4);return n<1?"just now":n<60?`${n}m ago`:n<1440?`${Math.floor(n/60)}h ago`:`${Math.floor(n/1440)}d ago`}function ls(e){let t=e.length>0?e[0]:null,n=new Map(e.map(r=>[r.id,r])),o=new Map;for(let r of e){if(t&&r.id===t.id)continue;let i=r.parentId&&r.parentId!==r.id&&n.has(r.parentId)?r.parentId:t?.id;if(!i)continue;let a=o.get(i)??[];a.push(r),o.set(i,a)}return{byId:n,round:t,childrenOf:o}}function Yl(e,t){let n=[],o=[...e.childrenOf.get(t)??[]];for(;o.length>0;){let r=o.pop();if(!r)break;n.push(r),o.push(...e.childrenOf.get(r.id)??[])}return n}function Xl(e){return e.some(t=>t.status==="review"||as(t))?"#f59e0b":e.some(t=>t.status==="in_progress")?"#3b82f6":"#9ca3af"}function Jl(e,t){let n=(e.dependencies??[]).filter(r=>t.has(r));if(n.length===0)return null;let o=n.filter(r=>{let i=t.get(r);return i?!Ni(i.status):!1});return o.length>0?{kind:"waiting",count:o.length}:{kind:"done",count:n.length}}function ds(e,t){let n=e[0]??null;return!n||!t||t===n.id?null:e.some(o=>o.id===t)?t:null}function cs(e){let t=new Map(e.map(d=>[d.id,d])),n=new Set(e.map(d=>d.id)),o=new Map([...e].sort((d,p)=>new Date(d.createdAt).getTime()-new Date(p.createdAt).getTime()).map((d,p)=>[d.id,p])),r=new Map,i=new Map;for(let d of e)r.set(d.id,[]),i.set(d.id,0);for(let d of e)for(let p of d.dependencies??[])n.has(p)&&p!==d.id&&(r.get(p)?.push(d.id),i.set(d.id,(i.get(d.id)??0)+1));let a=new Set(n),u=[];for(;a.size>0;){let d=null,p=1/0;for(let c of a){if((i.get(c)??0)!==0)continue;let s=o.get(c)??1/0;s<p&&(d=c,p=s)}if(d===null)break;a.delete(d);let h=t.get(d);h&&u.push(h);for(let c of r.get(d)??[])i.set(c,(i.get(c)??0)-1)}for(let d of[...a].sort((p,h)=>(o.get(p)??1/0)-(o.get(h)??1/0))){let p=t.get(d);p&&u.push(p)}return u}function ed(e,t){let n=new Set(t.map(i=>i.id));if(t.some(i=>(i.dependencies??[]).some(a=>a!==i.id&&n.has(a))))return[];let r=[];for(let i=0;i+1<e.length;i++)r.push({from:e[i].id,to:e[i+1].id,kind:"sequence"});return r}function qo(e,t,n=null){let o={root:null,tasks:[],edges:[],positions:new Map,bbox:{...Sr}},r=ls(e),i=r.round;if(!i)return o;let a=ds(e,t),u=a??i.id,d=r.childrenOf.get(u)??[],p=x=>{let B=Yl(r,x.id);return B.length===0?null:{count:B.length,dotColor:Xl(B)}},h=(x,B,Z)=>({id:x.id,task:x,seq:B,fold:Z?p(x):null,depBadge:Jl(x,r.byId)}),c=[],s=[],f=x=>{let B=cs(x);return s.push(...ed(B,x)),B};f(d).forEach((x,B)=>{c.push(h(x,B+1,!1)),f(r.childrenOf.get(x.id)??[]).forEach((Z,Y)=>{c.push(h(Z,Y+1,!0))})});let y=a?c.map(x=>x.task):[i,...c.map(x=>x.task)],v=vo(y).edges.map(x=>({from:x.from,to:x.to,kind:x.kind==="parent"?"structure":"dependency"}));v.push(...s);let m=null;if(!a){m={id:i.id,label:n!==null?`R${n}`:"R",title:i.title,status:i.status,doneCount:e.filter(B=>B.status==="completed").length,totalCount:e.length};let x=new Set(v.filter(B=>B.from===i.id).map(B=>`${B.to}:${B.kind}`));for(let B of d)x.has(`${B.id}:structure`)||(v.push({from:i.id,to:B.id,kind:"structure"}),x.add(`${B.id}:structure`))}let w=y.map(x=>({id:x.id})),C=ho(w,v.map(x=>({from:x.from,to:x.to})),{nodeWidth:$o,nodeHeight:is,nodesep:ql,ranksep:Hl,rankdir:"TB"}),A=1/0,T=1/0;for(let x of C.values())A=Math.min(A,x.x),T=Math.min(T,x.y);let O=new Map;if(Number.isFinite(A)&&Number.isFinite(T))for(let[x,B]of C)O.set(x,{x:B.x-A,y:B.y-T});let _=0,D=0;for(let x of O.values())_=Math.max(_,x.x+$o),D=Math.max(D,x.y+is);return{root:m,tasks:c,edges:v,positions:O,bbox:{width:_,height:D}}}function us(e,t=null){return e.length===0?{width:0,height:0}:qo(e,t).bbox}var Cr={draggable:!1,selectable:!1,focusable:!1,deletable:!1,connectable:!1};function Yn(e,t,n){let o=e.rounds,r=Er(e,t),i=r[0]??null,a=r.filter(as),u=ls(r),d=r.filter(g=>g.status==="completed").length,p=i?o.findIndex(g=>g.id===i.id):-1,h=i?o.length-p:null,c=o.map((g,v)=>({id:g.id,label:`R${o.length-v}`,title:g.title,status:g.status,createdAt:g.createdAt})),s=r.reduce((g,v)=>g?new Date(v.updatedAt).getTime()>new Date(g.updatedAt).getTime()?v:g:v,null),f=ds(r,n),y=[];if(i&&(y.push({id:i.id,label:`R${h}`}),f)){let g=[],v=u.byId.get(f)??null;for(;v&&v.id!==i.id;)g.unshift(v),v=v.parentId?u.byId.get(v.parentId)??null:null;for(let m of g){let C=cs(u.childrenOf.get(m.parentId??"")??[]).findIndex(A=>A.id===m.id)+1;y.push({id:m.id,label:`${C}.${m.title}`})}}return{tree:r,selectedRound:i,roundTreeById:u.byId,focusId:f,reviewTasks:a,doneCount:d,roundNumber:h,roundOptions:c,roundLatestActivity:ss(s?.updatedAt),breadcrumb:y}}var Pr=({hasRounds:e,reviewCount:t,onReviewClick:n,roundOptions:o,selectedRoundValue:r,onSelectRound:i,roundTitle:a,roundStatus:u,roundDoneCount:d,roundTotalCount:p,roundWaitingCount:h,roundLatestActivity:c,breadcrumb:s,onFocusTask:f,actions:y})=>{let g=u?qt[u]:null;return(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,marginBottom:6},children:[(0,ee.jsx)("div",{className:"nodrag nopan nowheel","data-testid":"learning-round-select",children:(0,ee.jsx)(ot,{size:"small",style:{width:260},placeholder:"Select round",value:r??void 0,allowClear:!0,disabled:o.length===0,onChange:v=>i(v??null),options:o.map(v=>{let m=qt[v.status],w=ss(v.createdAt);return{value:v.id,label:`${v.label} ${v.title} \xB7 ${m.label}${w?` \xB7 ${w}`:""}`}})})}),y]}),!e&&(0,ee.jsx)("div",{"data-testid":"learning-empty",style:{fontSize:12,color:"#999",paddingBottom:4},children:"No learning tasks yet"}),g&&a&&(0,ee.jsxs)("div",{"data-testid":"learning-round-stats",style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap",marginBottom:6},children:[(0,ee.jsx)("span",{style:{width:8,height:8,borderRadius:9999,background:g.color,flexShrink:0}}),(0,ee.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"#262626"},children:g.label}),(0,ee.jsx)("span",{style:{fontSize:11,color:"#d1d5db"},children:"\xB7"}),(0,ee.jsxs)("span",{style:{fontSize:11,color:"#8c8c8c"},children:[d,"/",p," tasks"]}),h>0&&(0,ee.jsxs)("span",{style:{fontSize:11,fontWeight:600,color:"#b45309",background:"rgba(245,158,11,0.12)",border:"1px solid rgba(245,158,11,0.35)",borderRadius:9999,padding:"1px 8px"},children:["\u23F8 ",h," waiting"]}),c&&(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)("span",{style:{fontSize:11,color:"#d1d5db"},children:"\xB7"}),(0,ee.jsx)("span",{style:{fontSize:11,color:"#9ca3af"},children:c})]})]}),s.length>1&&(0,ee.jsxs)("div",{"data-testid":"learning-breadcrumb",style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap",marginBottom:6,fontSize:11,color:"#6b7280"},children:[s.map((v,m)=>(0,ee.jsxs)(It.default.Fragment,{children:[m>0&&(0,ee.jsx)("span",{style:{color:"#d1d5db"},children:"/"}),(0,ee.jsx)("button",{type:"button","data-testid":`learning-crumb-${m}`,onClick:()=>f(m===0?null:v.id),style:{border:"none",background:"transparent",padding:0,cursor:"pointer",fontSize:11,fontWeight:600,color:m===s.length-1?"#4b5563":"#6366f1"},children:v.label})]},v.id)),(0,ee.jsx)("button",{type:"button","data-testid":"learning-crumb-back",onClick:()=>f(s[s.length-2]?.id??null),style:{border:"none",background:"rgba(99,102,241,0.08)",borderRadius:9999,padding:"1px 8px",cursor:"pointer",fontSize:11,fontWeight:600,color:"#6366f1"},children:"\u2039 Back"})]}),t>0&&(0,ee.jsxs)("button",{type:"button","data-testid":"learning-review-banner","aria-label":`Open ${t} task${t>1?"s":""} waiting for approval`,onClick:n,style:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:6,cursor:"pointer",width:"100%",fontSize:12,fontWeight:600,color:"#b45309",background:"rgba(245,158,11,0.12)",border:"1px solid rgba(245,158,11,0.35)",borderRadius:8,padding:"5px 8px",marginBottom:6},children:[t," item",t>1?"s":""," waiting for approval"]})]})},td=({data:e})=>{let[t,n]=(0,It.useState)(!1);return(0,ee.jsxs)("div",{style:{...Ul,width:e.width},children:[(0,ee.jsx)(Pr,{hasRounds:e.hasRounds,reviewCount:e.reviewCount,onReviewClick:e.onReviewClick,roundOptions:e.roundOptions,selectedRoundValue:e.selectedRoundValue,onSelectRound:e.onSelectRound,roundNumber:e.roundNumber,roundTitle:e.roundTitle,roundStatus:e.roundStatus,roundDoneCount:e.roundDoneCount,roundTotalCount:e.roundTotalCount,roundWaitingCount:e.roundWaitingCount,roundLatestActivity:e.roundLatestActivity,breadcrumb:e.breadcrumb,onFocusTask:e.onFocusTask,actions:(0,ee.jsx)(V,{size:"small",type:"text",icon:(0,ee.jsx)(Dt,{}),"data-testid":"learning-new-task",onClick:()=>n(!0),style:{fontSize:12},children:"New Learning Task"})}),(0,ee.jsx)(Pn,{open:t,agentId:e.agentId,defaultProjectId:e.projectId??void 0,onClose:()=>n(!1),onCreated:(o,r,i,a)=>{e.onLearningStarted?.(i,o,a),n(!1)}})]})},ps=It.default.memo(td),nd=({data:e})=>{let t=qt[e.task.status],[n,o]=(0,It.useState)(!1);return(0,ee.jsxs)("div",{"data-testid":"learning-dag-task",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{width:$o,minHeight:46,padding:"8px 10px",borderRadius:10,cursor:"pointer",border:`1.5px solid ${n?"rgba(99,102,241,0.5)":t.color}`,background:n?"rgba(99,102,241,0.08)":"#fff",transition:"background 0.15s ease, border-color 0.15s ease",animation:t.active?"workflow-node-pulse 1.6s ease-in-out infinite":void 0},children:[(0,ee.jsx)(xt,{type:"target",position:it.Top,style:{opacity:0}}),(0,ee.jsx)(xt,{id:"left",type:"target",position:it.Left,style:{opacity:0}}),(0,ee.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:6},children:[(0,ee.jsx)("span",{style:{width:8,height:8,borderRadius:9999,background:t.color,flexShrink:0,marginTop:4}}),(0,ee.jsxs)("span",{style:{fontSize:12,fontWeight:600,color:"#262626",flexShrink:0},children:[e.seq,"."]}),(0,ee.jsx)("span",{"data-testid":"learning-task-title",title:e.task.title,style:{fontSize:12,fontWeight:600,color:"#262626",lineHeight:"17px",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},children:e.task.title})]}),(e.depBadge||e.fold)&&(0,ee.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6,marginTop:5},children:[e.depBadge?(0,ee.jsx)("span",{"data-testid":"learning-dep-badge",style:{fontSize:10,fontWeight:600,flexShrink:0,color:e.depBadge.kind==="done"?"#22c55e":"#f59e0b",background:e.depBadge.kind==="done"?"rgba(34,197,94,0.1)":"rgba(245,158,11,0.12)",borderRadius:9999,padding:"1px 6px"},children:e.depBadge.kind==="done"?`\u2B26 ${e.depBadge.count} deps \u2713`:`\u2B26 waits ${e.depBadge.count}`}):(0,ee.jsx)("span",{}),e.fold&&(0,ee.jsxs)("button",{type:"button","data-testid":"learning-fold",className:"nodrag","aria-label":`Expand ${e.fold.count} nested tasks in ${e.task.title}`,onClick:r=>{r.stopPropagation(),e.onFocusTask?.(e.task.id)},style:{display:"inline-flex",alignItems:"center",gap:4,cursor:"pointer",flexShrink:0,fontSize:10,fontWeight:600,color:"#6b7280",border:"1px solid #e5e7eb",background:"#fafafa",borderRadius:9999,padding:"1px 6px"},children:[(0,ee.jsx)("span",{style:{width:6,height:6,borderRadius:9999,background:e.fold.dotColor,flexShrink:0}}),"\u25B8 ",e.fold.count]})]}),(0,ee.jsx)(xt,{type:"source",position:it.Bottom,style:{opacity:0}}),t.active&&(0,ee.jsx)("style",{children:"@keyframes workflow-node-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.35); } 50% { box-shadow: 0 0 0 6px rgba(59,130,246,0.08); } }"})]})},Ho=It.default.memo(nd),od=({data:e})=>{let t=qt[e.status],[n,o]=(0,It.useState)(!1);return(0,ee.jsxs)("div",{"data-testid":"learning-round-root",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{width:$o,minHeight:46,padding:"8px 10px",borderRadius:10,cursor:"pointer",border:`1.5px solid ${n?"rgba(99,102,241,0.5)":t.color}`,background:n?"rgba(99,102,241,0.14)":"rgba(99,102,241,0.04)",transition:"background 0.15s ease, border-color 0.15s ease"},children:[(0,ee.jsx)(xt,{type:"target",position:it.Top,style:{opacity:0}}),(0,ee.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:6},children:[(0,ee.jsx)("span",{style:{width:8,height:8,borderRadius:9999,background:t.color,flexShrink:0,marginTop:4}}),(0,ee.jsxs)("span",{"data-testid":"learning-round-root-title",title:e.title,style:{fontSize:12,fontWeight:700,color:"#262626",lineHeight:"17px",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},children:[e.label," \xB7 ",e.title]})]}),(0,ee.jsxs)("div",{style:{fontSize:11,color:"#8c8c8c",marginTop:4},children:[e.doneCount,"/",e.totalCount," tasks done"]}),(0,ee.jsx)(xt,{type:"source",position:it.Bottom,style:{opacity:0}})]})},Ko=It.default.memo(od);function Dr(e,t){let{nodeId:n,byId:o,prefix:r=""}=t;return e.edges.map(i=>{if(i.kind==="dependency"||i.kind==="sequence")return{id:`${r}${i.from}->${i.to}:${i.kind}`,source:n(i.from),target:n(i.to),type:"bezier",animated:!1,style:Vl,...i.kind==="dependency"?{markerEnd:Ql}:{}};let a=Aa(o.get(i.to)?.status??"pending");return{id:`${r}${i.from}->${i.to}:structure`,source:n(i.from),target:n(i.to),targetHandle:"left",animated:a==="flowing",style:Zl[a]}})}function gs(e){let{learningTasks:t,selectedRoundId:n,onSelectRound:o,onTaskClick:r,onFocusTask:i,focusTaskId:a,onLearningStarted:u,agentId:d,projectId:p,zone:h}=e;return(0,It.useMemo)(()=>{if(!d)return{nodes:[],edges:[],bbox:{...Sr},breadcrumb:[]};let c=Kl(h),s=Yn(t,n,a),{tree:f,selectedRound:y,roundTreeById:g,focusId:v,reviewTasks:m,doneCount:w,roundNumber:C,roundOptions:A,roundLatestActivity:T,breadcrumb:O}=s,D=[{id:"learning:header",type:"learningHeader",position:c.headerOffset,data:{width:c.headerWidth,hasRounds:t.rounds.length>0,reviewCount:m.length,onReviewClick:()=>{m[0]&&r(m[0],f)},onLearningStarted:u,agentId:d,projectId:p,roundOptions:A,selectedRoundId:n,selectedRoundValue:y?.id??null,onSelectRound:o,roundNumber:C,roundTitle:y?.title??null,roundStatus:y?.status??null,roundDoneCount:w,roundTotalCount:f.length,roundWaitingCount:m.length,roundLatestActivity:T,breadcrumb:O,onFocusTask:i},...Cr}];if(!y)return{nodes:D,edges:[],bbox:{...Sr},breadcrumb:O};let x=qo(f,v,C),B=h.width-yt*2,Z=c.dagOffset.x+Math.max(0,(B-x.bbox.width)/2);if(x.root){let j=x.positions.get(x.root.id)??{x:0,y:0};D.push({id:"learning:round-root",type:"learningRoundRoot",position:{x:Z+j.x,y:c.dagOffset.y+j.y},data:{label:x.root.label,title:x.root.title,status:x.root.status,doneCount:x.root.doneCount,totalCount:x.root.totalCount,onTaskClick:()=>r(y,f)},...Cr})}for(let j of x.tasks){let z=x.positions.get(j.id)??{x:0,y:0};D.push({id:`learning:task:${j.id}`,type:"learningTask",position:{x:Z+z.x,y:c.dagOffset.y+z.y},data:{task:j.task,seq:j.seq,depBadge:j.depBadge,fold:j.fold,onTaskClick:()=>r(j.task,f),onFocusTask:j.fold?()=>i(j.id):void 0},...Cr})}let H=Dr(x,{byId:g,nodeId:j=>j===y.id?"learning:round-root":`learning:task:${j}`,prefix:"learning:"});return{nodes:D,edges:H,bbox:x.bbox,breadcrumb:O}},[t,n,o,r,i,a,u,d,p,h])}var ve=R(M()),fs={width:Go,boxSizing:"border-box",background:"rgba(255, 255, 255, 0.6)",border:"1px solid rgba(240, 240, 240, 0.7)",borderRadius:10,padding:"8px 12px",boxShadow:"0 2px 10px rgba(0,0,0,0.06)",backdropFilter:"blur(8px)",pointerEvents:"auto"},ms={fontSize:10,fontWeight:600,color:"#999"},rd=({expanded:e,score:t,passRate:n,onToggleExpand:o,onUnpin:r})=>(0,ve.jsxs)("div",{"data-testid":"eval-mini",style:{...fs,position:"relative"},children:[(0,ve.jsxs)("button",{type:"button","data-testid":"eval-mini-expand","aria-label":"Open eval quality","aria-pressed":e,onClick:()=>o("evaluation"),style:{display:"block",width:"100%",border:"none",background:"transparent",padding:0,cursor:"pointer",textAlign:"left"},children:[(0,ve.jsx)("div",{style:ms,children:"Eval quality"}),(0,ve.jsxs)("div",{style:{display:"flex",gap:14,fontSize:12,alignItems:"baseline"},children:[(0,ve.jsxs)("span",{children:[(0,ve.jsx)("strong",{"data-testid":"eval-mini-score",style:{fontSize:18,color:t===null?"#d9d9d9":Ot(t)},children:t!==null?t.toFixed(1):"\u2014"})," ",(0,ve.jsx)("span",{style:{color:"#bbb"},children:"score"})]}),(0,ve.jsxs)("span",{children:[(0,ve.jsx)("strong",{"data-testid":"eval-mini-pass",style:{fontSize:18,color:"#262626"},children:n!==null?`${n}%`:"\u2014"})," ",(0,ve.jsx)("span",{style:{color:"#bbb"},children:"pass"})]})]})]}),(0,ve.jsx)(V,{size:"small",type:"text","aria-label":"Unpin evaluation zone",icon:(0,ve.jsx)(zn,{}),onClick:()=>r("evaluation"),style:{position:"absolute",top:2,right:2}})]}),id=({expanded:e,learningTasks:t,selectedRoundId:n,onSelectRound:o,onTaskClick:r,onLearningStarted:i,onLearningRefresh:a,agentId:u,projectId:d,onToggleExpand:p,onUnpin:h})=>{let[c,s]=(0,Uo.useState)(!1),f=(0,Uo.useMemo)(()=>Yn(t,n,null),[t,n]),y=(g,v,m,w)=>{o(g),s(!1),Promise.resolve(a?.()).catch(()=>{}),i?.(m,g,w)};return(0,ve.jsxs)("div",{"data-testid":"learning-mini",style:fs,children:[(0,ve.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6,marginBottom:6},children:[(0,ve.jsx)("span",{style:ms,children:"Learning"}),(0,ve.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:2},children:[(0,ve.jsx)(V,{size:"small",type:"text","aria-label":"Open full learning graph","aria-pressed":e,icon:(0,ve.jsx)(vn,{}),onClick:()=>p("learning")}),(0,ve.jsx)(V,{size:"small",type:"text","data-testid":"learning-mini-new",icon:(0,ve.jsx)(Dt,{}),onClick:()=>s(!0),children:"New"}),(0,ve.jsx)(V,{size:"small",type:"text","aria-label":"Unpin learning zone",icon:(0,ve.jsx)(zn,{}),onClick:()=>h("learning")})]})]}),f.roundOptions.length>1&&(0,ve.jsx)(ot,{size:"small","data-testid":"learning-mini-round",style:{width:"100%",marginBottom:6},value:f.selectedRound?.id??void 0,allowClear:!0,placeholder:"Select round",onChange:g=>o(g??null),options:f.roundOptions.map(g=>({value:g.id,label:`${g.label} ${g.title}`}))}),f.selectedRound?(0,ve.jsx)("div",{"data-testid":"learning-mini-tree",style:{maxHeight:240,overflow:"auto"},children:(0,ve.jsx)(ko,{tasks:f.tree,loading:t.loading,onTaskClick:r})}):(0,ve.jsx)("div",{style:{fontSize:12,color:"#999",padding:"2px 0"},children:"No learning tasks yet"}),(0,ve.jsx)(Pn,{open:c,agentId:u,defaultProjectId:d,onClose:()=>s(!1),onCreated:y})]})},ys=e=>{let t=e.pinned.has("evaluation"),n=e.pinned.has("learning");return!t&&!n?null:(0,ve.jsxs)("div",{"data-testid":"canvas-pinned-rail",style:{display:"flex",flexDirection:"column",gap:8,width:Go},children:[t&&(0,ve.jsx)(rd,{expanded:e.expanded==="evaluation",score:e.score,passRate:e.passRate,onToggleExpand:e.onToggleExpand,onUnpin:e.onUnpin}),n&&(0,ve.jsx)(id,{expanded:e.expanded==="learning",learningTasks:e.learningTasks,selectedRoundId:e.selectedRoundId,onSelectRound:e.onSelectRound,onTaskClick:e.onTaskClick,onLearningStarted:e.onLearningStarted,onLearningRefresh:e.onLearningRefresh,agentId:e.agentId,projectId:e.projectId,onToggleExpand:e.onToggleExpand,onUnpin:e.onUnpin})]})};var Lr=R(xe());var fn=R(M()),ad=({data:e})=>{let[t,n]=Lr.default.useState(!1),o=!!e.pinned;return(0,fn.jsx)("div",{"data-testid":`canvas-zone-${e.label.toLowerCase()}`,style:{width:e.width,height:e.height,borderRadius:18,border:"1.5px dashed rgba(99,102,241,0.28)",background:"rgba(99,102,241,0.04)",pointerEvents:"none",position:"relative"},children:(0,fn.jsxs)("div",{style:{position:"absolute",top:-22,left:2,display:"flex",alignItems:"center",gap:6},children:[(0,fn.jsx)("span",{"data-testid":`canvas-zone-chip-${e.label.toLowerCase()}`,style:{fontSize:11,fontWeight:600,letterSpacing:1,color:"rgba(99,102,241,0.65)",userSelect:"none",pointerEvents:"auto",cursor:"grab"},children:e.label}),e.pinnable&&e.onPinToggle&&(0,fn.jsx)("button",{type:"button","data-testid":`canvas-zone-pin-${e.label.toLowerCase()}`,"aria-label":o?`Unpin ${e.label} zone`:`Pin ${e.label} zone`,"aria-pressed":o,onMouseDown:r=>r.stopPropagation(),onClick:r=>{r.stopPropagation(),e.onPinToggle?.()},onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,padding:0,border:"none",borderRadius:5,background:o?"rgba(99,102,241,0.12)":"transparent",color:o||t?"#6366f1":"rgba(99,102,241,0.45)",cursor:"pointer",pointerEvents:"auto",lineHeight:1},children:(0,fn.jsx)(mi,{size:11,fill:o?"currentColor":"none"})})]})})},hs=Lr.default.memo(ad);var Ze=R(xe());var Zo=R(xe()),Xn="(max-width: 767px)",sd=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(Xn).matches:!1;function bs(){let[e,t]=(0,Zo.useState)(sd);return(0,Zo.useEffect)(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia(Xn),o=r=>{t(r.matches)};return t(n.matches),typeof n.addEventListener=="function"?(n.addEventListener("change",o),()=>n.removeEventListener("change",o)):(n.addListener(o),()=>n.removeListener(o))},[]),e}var tn=R(xe()),vs=(e,t)=>e?.requestId===t?.requestId&&e?.content===t?.content;function Nn({assistantId:e,initialMessageRequest:t,onInitialMessageSubmitted:n}){let o=(0,tn.useRef)(new Set),r=t??null,i=(0,tn.useRef)(null);i.current===null&&(i.current={assistantId:e,observedRequest:r,request:r});let[a,u]=(0,tn.useState)(i.current),d=(0,tn.useRef)(a);(0,tn.useLayoutEffect)(()=>{let c=d.current;if(c.assistantId===e&&vs(c.observedRequest,r))return;let s={assistantId:e,observedRequest:r,request:r};d.current=s,u(s)},[e,r?.requestId,r?.content]);let p=a.assistantId===e&&vs(a.observedRequest,r)?a.request:null;return{attemptedRequestIdsRef:o,effectivePendingRequest:p,handleInitialMessageSubmitted:c=>{let s=d.current;if(s.assistantId===e){if(s.request?.requestId===c){let f={...s,request:null};d.current=f,u(y=>y.assistantId===e&&y.request?.requestId===c?{...y,request:null}:y)}n?.(c)}}}}var ht=R(M()),ks=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(Xn).matches:!1,Vo=({assistantId:e,assistantName:t,workspaceId:n,projectId:o,contextType:r,initialMessageRequest:i,onInitialMessageSubmitted:a,onToolCompleted:u,label:d="Architect",temporarilyHidden:p=!1,openSignal:h=0,showMobileTrigger:c=!0,restoreFocusRef:s})=>{let[f,y]=(0,Ze.useState)(ks),[g,v]=(0,Ze.useState)(()=>!ks()),[m,w]=(0,Ze.useState)(360),C=(0,Ze.useRef)(null),A=(0,Ze.useRef)(null),T=(0,Ze.useRef)(null),O=i??null,{attemptedRequestIdsRef:_,effectivePendingRequest:D,handleInitialMessageSubmitted:x}=Nn({assistantId:e,initialMessageRequest:i,onInitialMessageSubmitted:a});(0,Ze.useEffect)(()=>{C.current&&(C.current.inert=p||!g)},[f,p,g]),(0,Ze.useEffect)(()=>{f&&p&&v(!1)},[f,p]),(0,Ze.useEffect)(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;let H=window.matchMedia(Xn),j=z=>{y(z.matches),v(!z.matches)};return y(H.matches),typeof H.addEventListener=="function"?(H.addEventListener("change",j),()=>H.removeEventListener("change",j)):(H.addListener(j),()=>H.removeListener(j))},[]),(0,Ze.useEffect)(()=>{h>0&&v(!0)},[h]),(0,Ze.useEffect)(()=>{O&&!f&&v(!0)},[e,O?.requestId,O?.content,f]);let B=(0,Ze.useCallback)(H=>{H.preventDefault(),T.current={startX:H.clientX,startWidth:m}},[m]);(0,Ze.useEffect)(()=>{let H=z=>{if(!T.current)return;let K=T.current.startX-z.clientX,F=Math.min(900,Math.max(320,T.current.startWidth+K));w(F)},j=()=>{T.current=null};return window.addEventListener("mousemove",H),window.addEventListener("mouseup",j),()=>{window.removeEventListener("mousemove",H),window.removeEventListener("mouseup",j)}},[]);let Z=(0,ht.jsxs)("div",{ref:C,"data-testid":"architect-copilot-container","aria-hidden":p||!g||void 0,style:f?{width:"100%",height:"100%",overflow:"hidden",visibility:p||!g?"hidden":"visible",pointerEvents:p||!g?"none":void 0}:{position:"absolute",right:12,top:56,bottom:12,width:m,zIndex:15,borderRadius:12,overflow:"hidden",boxShadow:"0 4px 24px rgba(0,0,0,0.12)",visibility:p||!g?"hidden":"visible",pointerEvents:p||!g?"none":void 0},children:[!f&&(0,ht.jsx)("div",{onMouseDown:B,style:{position:"absolute",left:0,top:0,bottom:0,width:6,cursor:"ew-resize",zIndex:2,background:"transparent"}}),(0,ht.jsx)(Rn,{defaultWorkspaceId:n??void 0,defaultProjectId:o??void 0,children:(0,ht.jsx)(In,{workflowContext:{id:e,name:t??"",type:r},onClose:()=>v(!1),onToolCompleted:u,initialMessageRequest:D,attemptedInitialMessageRequestIdsRef:_,rawInitialMessage:!0,onInitialMessageSubmitted:x},e)},`${n??"default"}:${o??"default"}`)]});return(0,ht.jsxs)(ht.Fragment,{children:[!g&&!p&&(!f||c)?(0,ht.jsx)("div",{style:f?{position:"absolute",right:12,bottom:16,zIndex:20}:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",zIndex:20},children:(0,ht.jsx)("button",{ref:A,type:"button","aria-label":"Open copilot",onClick:()=>v(!0),style:f?{padding:"9px 14px",background:"#6366f1",color:"#fff",borderRadius:9999,cursor:"pointer",fontSize:12,fontWeight:500,userSelect:"none",border:"none",boxShadow:"0 4px 16px rgba(79,70,229,0.28)"}:{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",border:"none"},children:d})}):null,f?(0,ht.jsx)(qr,{title:d,"aria-label":d,placement:"right",width:"100vw",open:g&&!p,onClose:()=>v(!1),forceRender:!0,destroyOnHidden:!1,styles:{body:{padding:0,overflow:"hidden",height:"100%"}},afterOpenChange:H=>{!H&&!g&&(s?.current??A.current)?.focus()},children:Z}):Z]})};var mn=R(xe());var nn=R(M()),Jn="node:architect-copilot",ld=({data:e})=>{let{assistantId:t,assistantName:n,workspaceId:o,projectId:r,initialMessageRequest:i,onInitialMessageSubmitted:a,onToolCompleted:u,temporarilyHidden:d=!1,openSignal:p=0,width:h,height:c,center:s}=e,f=mo(),y=(0,mn.useRef)(null),{attemptedRequestIdsRef:g,effectivePendingRequest:v,handleInitialMessageSubmitted:m}=Nn({assistantId:t,initialMessageRequest:i,onInitialMessageSubmitted:a}),w=d,C=()=>f.setCenter(s.x,s.y,{zoom:1,duration:400});return(0,mn.useEffect)(()=>{y.current&&(y.current.inert=w)},[w]),(0,mn.useEffect)(()=>{p>0&&C()},[p]),(0,nn.jsxs)("div",{style:{width:h,height:c,position:"relative",fontFamily:"inherit"},children:[(0,nn.jsx)("div",{ref:y,"data-testid":"architect-copilot-node-panel","aria-hidden":w||void 0,className:"nodrag nowheel nopan",style:{position:"absolute",top:0,left:0,right:0,bottom:0,borderRadius:12,overflow:"hidden",background:"#fff",visibility:w?"hidden":"visible",pointerEvents:w?"none":void 0,userSelect:"text",WebkitUserSelect:"text"},children:(0,nn.jsx)(Rn,{defaultWorkspaceId:o??void 0,defaultProjectId:r??void 0,children:(0,nn.jsx)(In,{workflowContext:{id:t,name:n??"",type:"agent"},onToolCompleted:u,initialMessageRequest:v,attemptedInitialMessageRequestIdsRef:g,rawInitialMessage:!0,showHeader:!1,onInitialMessageSubmitted:m},t)},`${o??"default"}:${r??"default"}`)}),w&&(0,nn.jsxs)("button",{type:"button","data-testid":"architect-copilot-node-badge","aria-label":"Expand architect copilot",onClick:C,style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",gap:6,padding:"9px 14px",background:"#6366f1",color:"#fff",borderRadius:9999,border:"none",cursor:"pointer",fontSize:12,fontWeight:500,userSelect:"none"},children:[(0,nn.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:"#22c55e",display:"inline-block"}}),"Architect"]})]})},ws=mn.default.memo(ld);var Nr=R(xe());var pt=R(M()),dd=.4,cd=.45,xs=(e,t)=>t==="badge"?e>=cd?"overview":"badge":e<dd?"badge":"overview",ud={background:"rgba(255,255,255,0.92)",border:"1px solid rgba(240,240,240,0.9)",borderRadius:14},pd=({data:e})=>(0,pt.jsxs)("div",{"data-testid":"testing-panel",style:{...ud,width:e.width,minHeight:e.height,boxSizing:"border-box",padding:12,overflow:"auto",display:"flex",flexDirection:"column",gap:12},children:[(0,pt.jsx)(pn,{agentId:e.agentId,runs:e.runs}),e.suites.length>0&&(0,pt.jsxs)("div",{"data-testid":"testing-suites",style:{borderTop:"1px solid #f0f0f0",paddingTop:10,display:"flex",flexDirection:"column",gap:8},children:[(0,pt.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"rgba(0,0,0,0.65)"},children:"Evaluation suites"}),(0,pt.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e.suites.map(t=>(0,pt.jsxs)("div",{"data-testid":"testing-suite-chip",onClick:()=>e.onSuiteClick(t),style:{display:"inline-flex",alignItems:"center",gap:5,padding:"4px 10px",borderRadius:9999,background:"#fff",border:`1px solid ${Po("eval")}55`,fontSize:11,color:"#333",cursor:"pointer",whiteSpace:"nowrap"},children:[(0,pt.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:t.label}),t.description&&(0,pt.jsx)("span",{style:{fontSize:10,color:"#999"},children:t.description})]},t.id))})]})]}),Ts=Nr.default.memo(pd),gd=({data:e})=>(0,pt.jsxs)("div",{"data-testid":"testing-badge",style:{width:Vn,height:Qn,borderRadius:10,background:"rgba(255,255,255,0.92)",border:"1px solid rgba(240,240,240,0.9)",display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[(0,pt.jsx)("span",{style:{width:10,height:10,borderRadius:9999,background:e.score===null?"#d1d5db":Ot(e.score),flexShrink:0}}),(0,pt.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"#6b7280"},children:e.suiteCount})]}),Rs=Nr.default.memo(gd);var Ft=R(xe());var yn=R(M()),fd={learningTask:Ho,learningRoundRoot:Ko},Mr=({learningTasks:e,selectedRoundId:t,onSelectRound:n,onTaskClick:o,height:r="100%"})=>{let[i,a]=(0,Ft.useState)(null);(0,Ft.useEffect)(()=>{a(null)},[t]);let u=(0,Ft.useMemo)(()=>Yn(e,t,i),[e,t,i]),{dagNodes:d,dagEdges:p}=(0,Ft.useMemo)(()=>{let m=qo(u.tree,u.focusId,u.roundNumber),w=u.tree,C=[];m.root&&u.selectedRound&&C.push({id:m.root.id,type:"learningRoundRoot",position:m.positions.get(m.root.id)??{x:0,y:0},data:{label:m.root.label,title:m.root.title,status:m.root.status,doneCount:m.root.doneCount,totalCount:m.root.totalCount,onTaskClick:()=>o(u.selectedRound,w)}});for(let T of m.tasks)C.push({id:T.id,type:"learningTask",position:m.positions.get(T.id)??{x:0,y:0},data:{task:T.task,seq:T.seq,depBadge:T.depBadge,fold:T.fold,onTaskClick:()=>o(T.task,w),onFocusTask:T.fold?()=>a(T.id):void 0}});let A=Dr(m,{byId:u.roundTreeById,nodeId:T=>T});return{dagNodes:C,dagEdges:A}},[u,o]),[h,c,s]=xn(d),[f,y,g]=Tn(p);(0,Ft.useEffect)(()=>{c(d),y(p)},[d,p,c,y]);let v=(0,Ft.useCallback)((m,w)=>{w.data.onTaskClick?.()},[]);return(0,yn.jsxs)("div",{style:{width:"100%",height:r,display:"flex",flexDirection:"column",minHeight:0},children:[(0,yn.jsx)("div",{className:"nodrag nowheel nopan",style:{flexShrink:0,padding:"12px 16px 4px"},children:(0,yn.jsx)(Pr,{hasRounds:e.rounds.length>0,reviewCount:u.reviewTasks.length,onReviewClick:()=>{u.reviewTasks[0]&&o(u.reviewTasks[0],u.tree)},roundOptions:u.roundOptions,selectedRoundValue:u.selectedRound?.id??null,onSelectRound:n,roundNumber:u.roundNumber,roundTitle:u.selectedRound?.title??null,roundStatus:u.selectedRound?.status??null,roundDoneCount:u.doneCount,roundTotalCount:u.tree.length,roundWaitingCount:u.reviewTasks.length,roundLatestActivity:u.roundLatestActivity,breadcrumb:u.breadcrumb,onFocusTask:a})}),(0,yn.jsx)("div",{style:{flex:1,minHeight:0,position:"relative"},children:(0,yn.jsx)(bo,{nodes:h,edges:f,nodeTypes:fd,onNodesChange:s,onEdgesChange:g,onNodeClick:v,fitView:!0,fitViewOptions:{padding:.15,maxZoom:1.2},nodesDraggable:!1,nodesConnectable:!1,miniMap:!1})})]})};var se=R(M()),md={"zone:copilot":"copilot","zone:learning":"learning","zone:testing":"evaluation"},yd={copilot:"COPILOT",learning:"LEARNING",evaluation:"EVALUATION"},Is={copilot:"copilot",learning:"learning",testing:"evaluation"},hd=(e,t)=>{if(Object.keys(t).length===0)return e;let n=o=>{let r=t[o.id];return r?{...o,x:r.x,y:r.y}:o};return{config:n(e.config),copilot:n(e.copilot),learning:n(e.learning),testing:n(e.testing),height:e.height}},bd={rounds:[],round:null,subTasks:[],subTasksByRound:{},loading:!1},Qo={padding:"1px 6px",marginRight:6,border:"1px solid #e0e0e0",borderRadius:4,background:"#fafafa",fontSize:11,fontFamily:"monospace",color:"#595959"},Es="axiom.trainingCanvas.guideDismissed",vd=()=>{try{return typeof window<"u"&&window.localStorage?.getItem(Es)==="1"}catch{return!1}},kd=e=>{try{window.localStorage?.setItem(Es,e?"1":"0")}catch{}},Or="axiom.trainingCanvas.layout",wd=["copilot","learning","evaluation"],Cs=["copilot","learning","evaluation"],xd=new Set(Va),Td=e=>{if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.x=="number"&&Number.isFinite(t.x)&&typeof t.y=="number"&&Number.isFinite(t.y)},Ss=()=>{try{if(typeof window>"u")return null;let e=window.localStorage?.getItem(Or);if(!e)return null;let t=JSON.parse(e);if(typeof t!="object"||t===null)return null;let n=t;if(n.version!==1)return null;let o={};if(typeof n.origins=="object"&&n.origins!==null)for(let[r,i]of Object.entries(n.origins))Td(i)&&(o[r]=i);return{version:1,pinned:Array.isArray(n.pinned)?n.pinned.filter(r=>typeof r=="string"):[],origins:o}}catch{return null}},As=(e,t)=>{try{let n={version:1,pinned:[...e],origins:t};window.localStorage?.setItem(Or,JSON.stringify(n))}catch{}},Rd=()=>{try{window.localStorage?.removeItem(Or)}catch{}},Ps=({graphDefinition:e,onSelectNode:t,assistantId:n,assistantName:o,workspaceId:r,onRemoveNode:i,initialMessageRequest:a,onInitialMessageSubmitted:u,projectId:d,onProjectChange:p,onLearningStarted:h,onToolActivity:c,learningTasks:s,onLearningRefresh:f,evalTick:y,evalData:g,hudTopOffset:v,copilotTemporarilyHidden:m,onOpenArchitect:w,architectOpenSignal:C=0,architectRestoreFocusRef:A})=>{let[T,O,_]=xn([]),[D,x,B]=Tn([]),[Z,Y]=(0,q.useState)(null),H=bs(),j=mo(),z=(0,q.useRef)(!1),[K,F]=(0,q.useState)(!vd()),[ne,P]=(0,q.useState)(null),G=(0,q.useRef)(null),le=(0,q.useRef)({onInitialMessageSubmitted:u,onToolActivity:c,onLearningStarted:h});le.current={onInitialMessageSubmitted:u,onToolActivity:c,onLearningStarted:h};let[oe,Ie]=(0,q.useState)(()=>{let k=Ss(),l=k?k.pinned:H?[]:Cs,I=new Set;for(let E of l)wd.includes(E)&&I.add(E);return I}),[fe,L]=(0,q.useState)(()=>{let k={};for(let[l,I]of Object.entries(Ss()?.origins??{}))xd.has(l)&&(k[l]=I);return k}),[ie,Ee]=(0,q.useState)(null),W=(0,q.useRef)(oe);W.current=oe;let N=(0,q.useRef)(fe);N.current=fe;let X=(0,q.useCallback)(k=>{let l=new Set(W.current);l.has(k)?(l.delete(k),Ee(I=>I===k?null:I)):l.add(k),W.current=l,Ie(l),As([...l],N.current)},[]),de=(0,q.useRef)(null),[S,Pe]=(0,q.useState)(()=>({width:typeof window>"u"?1200:window.innerWidth,height:typeof window>"u"?800:window.innerHeight}));(0,q.useEffect)(()=>{let k=de.current;if(!k||typeof ResizeObserver>"u")return;let l=()=>{let E=k.getBoundingClientRect();Pe({width:E.width,height:E.height})},I=new ResizeObserver(l);return I.observe(k),l(),()=>I.disconnect()},[]);let he=(0,q.useMemo)(()=>ns(S.width,S.height,oe),[S,oe]),Te=Nn({assistantId:n??"",initialMessageRequest:a,onInitialMessageSubmitted:k=>le.current.onInitialMessageSubmitted?.(k)}),Ae=(0,q.useCallback)(k=>{P(k),G.current!==null&&window.clearTimeout(G.current),G.current=window.setTimeout(()=>P(null),700)},[]);(0,q.useEffect)(()=>()=>{G.current!==null&&window.clearTimeout(G.current)},[]);let[Le,nt]=(0,q.useState)(null),[Fe,Je]=(0,q.useState)(null),[Ne,gt]=(0,q.useState)(null),bt=(0,q.useCallback)(k=>gt(k.id),[]),Ct=(0,q.useCallback)(()=>gt(null),[]),Be=(0,q.useCallback)(k=>Je(k),[]),on=(0,q.useCallback)((k,l,I)=>le.current.onLearningStarted?.(k,l,I),[]),{suites:rn}=wn(g.evalProjectId??""),an=rn.map(k=>`${k.name}:${k.caseCount??0}`).join("|"),Wt=(0,q.useMemo)(()=>{let k={};for(let l of rn)k[l.name]=l.caseCount??0;return k},[an]),vt=(0,q.useMemo)(()=>g.suiteNames.map(k=>({id:`suite:${k}`,type:"eval",label:k,description:`${Wt[k]??0} cases`})),[g.suiteNames,Wt]),Ke=(0,q.useMemo)(()=>Xi(e,{includeEmptyGroups:!0}),[e]),kt=(0,q.useMemo)(()=>({zone:hs,config:oa,agent:na,copilot:ws,testingPanel:Ts,testingBadge:Rs,learningHeader:ps,learningTask:Ho,learningRoundRoot:Ko}),[]),hn=Ai(k=>k.transform[2]),Ut=(0,q.useRef)("overview"),$=xs(hn,Ut.current);Ut.current=$;let me=s??bd,Qe=(0,q.useMemo)(()=>{let k=new Map(Ke.groups.map(I=>[I.id,I])),l={};for(let I of Ke.groups)k.get(I.id)&&(l[I.id]=Math.max(Bo,56+I.items.length*30));return l},[Ke.groups]),Ye=(0,q.useMemo)(()=>g.suiteNames.length>0?Math.max(Bo,56+g.suiteNames.length*30):0,[g.suiteNames]),je=(0,q.useMemo)(()=>Er(me,Le),[me,Le]),St=(0,q.useMemo)(()=>us(je,Fe),[je,Fe]),et=(0,q.useMemo)(()=>rs({groupHeights:Qe,suitesGroupHeight:Ye,learningDagBBox:St}),[Qe,Ye,St]),be=(0,q.useMemo)(()=>hd(et,fe),[et,fe]),Mn=(0,q.useRef)({}),At=(0,q.useRef)({}),On=(0,q.useRef)(null),[st,eo]=(0,q.useState)({x:0,y:0}),to=(0,q.useMemo)(()=>{let k=be.learning;return st.x===0&&st.y===0?k:{...k,x:k.x+st.x,y:k.y+st.y}},[be,st]),Zt=(0,q.useCallback)((k,l)=>{k.startsWith("zone:")&&(On.current=k,At.current[k]={x:l.x,y:l.y})},[]),no=(0,q.useCallback)((k,l)=>{if(!k.startsWith("zone:"))return;let I=At.current[k],E={x:l.x,y:l.y};if(At.current[k]=E,!I)return;let ce=E.x-I.x,Ge=E.y-I.y;if(ce===0&&Ge===0)return;let ft=Mn.current[k]??[];k==="zone:learning"&&eo(we=>({x:we.x+ce,y:we.y+Ge})),ft.length>0&&O(we=>we.map(Et=>Et.position&&ft.indexOf(Et.id)>=0?{...Et,position:{x:Et.position.x+ce,y:Et.position.y+Ge}}:Et))},[O]),Jo=(0,q.useCallback)((k,l)=>{if(!k.startsWith("zone:"))return;On.current=null,delete At.current[k],k==="zone:learning"&&eo({x:0,y:0});let I=Object.keys(N.current).length===0?{"zone:config":{x:et.config.x,y:et.config.y},"zone:copilot":{x:et.copilot.x,y:et.copilot.y},"zone:learning":{x:et.learning.x,y:et.learning.y},"zone:testing":{x:et.testing.x,y:et.testing.y}}:{...N.current};I[k]={x:l.x,y:l.y},N.current=I,L(I),As([...W.current],I)},[et]),er=(0,q.useCallback)(()=>{Rd();let k=H?new Set:new Set(Cs);W.current=k,Ie(k),Ee(null),N.current={},L({})},[H]),oo=gs({learningTasks:me,selectedRoundId:Le,zone:to,onSelectRound:nt,onTaskClick:bt,onFocusTask:Be,focusTaskId:Fe,onLearningStarted:on,agentId:n??"",projectId:d}),zt=Ne?Ar(me,Ne):null;(0,q.useEffect)(()=>{Ne&&!zt&&gt(null)},[Ne,zt]),(0,q.useEffect)(()=>{Je(null)},[Le]),(0,q.useEffect)(()=>{Fe&&!Ar(me,Fe)&&Je(null)},[Fe,me]),(0,q.useEffect)(()=>{let k=Ke.groups,l=new Map(k.map(ue=>[ue.id,ue])),I=[],E=!!n&&!H,ce=be.config,Ge=be.testing,ft=oe.has("copilot"),we=oe.has("learning"),Et=oe.has("evaluation"),_n=[be.config,be.testing,be.learning,be.copilot].filter(ue=>ue.id!==be.copilot.id||E&&!ft).filter(ue=>ue.id!==be.learning.id||!!n&&!we).filter(ue=>ue.id!==be.testing.id||!Et).map(ue=>{let $e=md[ue.id];return{id:ue.id,type:"zone",position:{x:ue.x,y:ue.y},data:{label:ue.label,width:ue.width,height:ue.height,pinnable:$e!==void 0,pinned:$e!==void 0&&oe.has($e),onPinToggle:$e!==void 0?()=>X($e):void 0},draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1,zIndex:-1,style:{pointerEvents:"none"}}});I.push(..._n);let Br={[be.config.id]:[],[be.testing.id]:[],[be.learning.id]:[],[be.copilot.id]:[]},Fn=(ue,$e)=>{let Wn=Br[ue];Wn&&Wn.indexOf($e)<0&&Wn.push($e)};Fn(be.config.id,Ke.agent.id),I.push({id:Ke.agent.id,type:"agent",draggable:!1,data:{node:Ke.agent,onClick:()=>t?.(Ke.agent)},position:Ya(ce)});for(let ue of k){let $e=l.get(ue.id);if(!$e)continue;let Wn=Qe[ue.id]??Math.max(Bo,56+ue.items.length*30);Fn(be.config.id,ue.id),I.push({id:ue.id,type:"config",draggable:!1,data:{group:$e,onClick:js=>t?.(js),onRemove:i},position:Xa(ce,ue.id,Wn)})}oe.has("evaluation")||($==="badge"?g.suiteNames.length>0&&(Fn(be.testing.id,"testing:badge"),I.push({id:"testing:badge",type:"testingBadge",draggable:!1,data:{score:g.score,suiteCount:g.suiteNames.length},position:Ja(Ge,Vn,Qn)})):(Fn(be.testing.id,"testing:panel"),I.push({id:"testing:panel",type:"testingPanel",draggable:!1,data:{agentId:n??"",runs:g.runs,width:Ge.width-yt*2,height:Ge.height-yt*2,suites:vt,onSuiteClick:ue=>t?.(ue)},position:{x:Ge.x+xr.x,y:Ge.y+xr.y}}))),E&&!oe.has("copilot")&&(Fn(be.copilot.id,Jn),I.push({id:Jn,type:"copilot",draggable:!1,data:{assistantId:n,assistantName:o??"",workspaceId:r,projectId:d,initialMessageRequest:a??null,onInitialMessageSubmitted:ue=>le.current.onInitialMessageSubmitted?.(ue),onToolCompleted:ue=>le.current.onToolActivity?.(ue),temporarilyHidden:m??!1,openSignal:C,width:be.copilot.width,height:be.copilot.height,center:{x:be.copilot.x+be.copilot.width/2,y:be.copilot.y+be.copilot.height/2}},position:{x:be.copilot.x,y:be.copilot.y}})),Mn.current=Br;for(let ue of _n)On.current!==ue.id&&(At.current[ue.id]={x:ue.position.x,y:ue.position.y});O(I);let jr=(ue,$e)=>Math.abs(ue)>Math.abs($e)?ue<0?"left":"right":$e<0?"top":"bottom";x(k.map(ue=>{let $e=jo[ue.id]??{x:0,y:0};return{id:`e${Ke.agent.id}-${ue.id}`,source:Ke.agent.id,target:ue.id,sourceHandle:jr($e.x,$e.y),targetHandle:jr(-$e.x,-$e.y),style:{stroke:"#c7c7c7",strokeWidth:1.2},type:"bezier"}}))},[Ke,O,x,i,n,H,r,d,o,m,C,a?.requestId,a?.content,$,vt,g.score,g.suiteNames,g.runs.map(k=>k.id).join(","),be,Qe,oe,X]);let ro=Pi();(0,q.useEffect)(()=>{if(!ro||z.current)return;z.current=!0;let k=j.getNodes().filter(l=>!l.id.startsWith("zone:"));j.fitView({padding:.2,nodes:k}).then(l=>{l&&j.getZoom()<Qa&&j.fitView({padding:.2,nodes:j.getNodes().filter(I=>I.type==="agent"||I.type==="config")})})},[ro,j]),(0,q.useEffect)(()=>{let k=[["1","zone:config","config"],["2","zone:learning","learning"],["3","zone:testing","testing"],["4","zone:copilot","copilot"]],l=I=>{if(!(I.ctrlKey||I.metaKey))return;let E=k.find(([ft])=>I.key===ft);if(!E)return;let ce=I.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable))return;I.preventDefault();let Ge=Is[E[2]];Ge&&oe.has(Ge)||(Ae(E[2]),j.fitView({padding:.4,duration:400,nodes:[{id:E[1]}]}))};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[j,Ae,oe]);let tr=(0,q.useMemo)(()=>{let k=T.some(l=>l.id===Z)?Z:null;return k===null?T:T.map(l=>{if(l.id===Jn||l.id.startsWith("zone:")||l.id.startsWith("testing:"))return l;let I=l.id===k||D.some(E=>E.source===k&&E.target===l.id||E.target===k&&E.source===l.id);return{...l,style:{opacity:I?1:.4,transition:"opacity 0.2s ease"}}})},[T,D,Z]);return(0,se.jsxs)("div",{ref:de,style:{width:"100%",height:"100%",position:"relative",background:"#fafafa"},children:[(0,se.jsx)("style",{children:`.axiom-training-canvas .react-flow__pane { cursor: default; }
234
+ .axiom-training-canvas .react-flow__pane.dragging { cursor: grabbing; }
235
+ @keyframes zone-dot-pulse { 0% { box-shadow: 0 0 0 0 rgba(99,102,241,0.5); } 100% { box-shadow: 0 0 0 8px rgba(99,102,241,0); } }
236
+ .zone-dot-active { animation: zone-dot-pulse 0.7s ease-out; }
237
+ .zone-help-toggle:hover { color: #6366f1; }`}),(0,se.jsxs)(Ei,{className:"axiom-training-canvas",nodes:[...tr,...oe.has("learning")?[]:oo.nodes],edges:[...D,...oe.has("learning")?[]:oo.edges],onNodesChange:_,onEdgesChange:B,onNodeDragStart:(k,l)=>Zt(l.id,l.position),onNodeDrag:(k,l)=>no(l.id,l.position),onNodeDragStop:(k,l)=>Jo(l.id,l.position),onNodeMouseEnter:(k,l)=>{l.id===Jn||l.id.startsWith("zone:")||l.id.startsWith("testing:")||l.type?.startsWith("learning")||Y(l.id)},onNodeMouseLeave:()=>Y(null),onPaneClick:()=>t?.(null),onNodeClick:(k,l)=>{if(l.type!=="learningTask"&&l.type!=="learningRoundRoot")return;l.data.onTaskClick?.()},nodeTypes:kt,children:[(0,se.jsx)(Di,{color:"#eee",gap:20}),(0,se.jsx)(Li,{})]}),(0,se.jsx)(lt,{open:zt!==null,width:860,title:zt?.task.title??"",onClose:Ct,bodyStyle:{padding:0,overflow:"hidden"},children:zt&&(0,se.jsx)(yr,{task:zt.task,relatedTasks:zt.related,onClose:Ct,onRefresh:f,height:"100%"})}),(H?["copilot","learning","evaluation"]:["copilot"]).map(k=>{let l=he[k];return l?(0,se.jsxs)(lt,{open:!0,width:l.width,left:l.left,top:l.top,height:l.height,escapeEnabled:!1,zIndex:20,title:yd[k],onClose:()=>X(k),bodyStyle:{padding:0},children:[k==="copilot"&&n&&(0,se.jsx)("div",{style:{width:"100%",height:"100%",userSelect:"text",WebkitUserSelect:"text"},children:(0,se.jsx)(Rn,{defaultWorkspaceId:r??void 0,defaultProjectId:d??void 0,children:(0,se.jsx)(In,{workflowContext:{id:n,name:o??"",type:"agent"},onToolCompleted:I=>le.current.onToolActivity?.(I),initialMessageRequest:Te.effectivePendingRequest,attemptedInitialMessageRequestIdsRef:Te.attemptedRequestIdsRef,rawInitialMessage:!0,showHeader:!1,onInitialMessageSubmitted:Te.handleInitialMessageSubmitted},n)},`${r??"default"}:${d??"default"}`)}),k==="learning"&&(0,se.jsx)(Mr,{learningTasks:me,selectedRoundId:Le,onSelectRound:nt,agentId:n??"",projectId:d,onTaskClick:bt,height:"100%"}),k==="evaluation"&&(0,se.jsx)(pn,{agentId:n??"",runs:g.runs})]},k):null}),!H&&(()=>{let k=ie;if(k!=="learning"&&k!=="evaluation")return null;let l=os(S.width,S.height,k,oe.has("copilot"));return(0,se.jsx)(lt,{open:!0,width:l.width,left:l.left,top:l.top,height:l.height,escapeEnabled:!1,zIndex:20,title:k==="evaluation"?"Eval quality":"Learning tasks",onClose:()=>Ee(null),bodyStyle:{padding:0},children:k==="evaluation"?(0,se.jsx)(pn,{agentId:n??"",runs:g.runs}):(0,se.jsx)(Mr,{learningTasks:me,selectedRoundId:Le,onSelectRound:nt,agentId:n??"",projectId:d,onTaskClick:bt,height:"100%"})})})(),n&&(0,se.jsx)(Fo,{assistantId:n,projectId:d,onProjectChange:p,onLearningStarted:h,learningTasks:s,topOffset:v,onLearningRefresh:f,evalTick:y,showLearning:!1,variant:"selector",children:!H&&(0,se.jsx)(ys,{pinned:oe,expanded:ie,onToggleExpand:k=>Ee(l=>l===k?null:k),onUnpin:X,score:g.score,passRate:g.passRate,learningTasks:me,selectedRoundId:Le,onSelectRound:nt,onTaskClick:bt,onLearningStarted:on,onLearningRefresh:f,agentId:n,projectId:d})}),n&&H&&(0,se.jsx)(Vo,{assistantId:n,assistantName:o??"",workspaceId:r,projectId:d,contextType:"agent",initialMessageRequest:a,onInitialMessageSubmitted:u,onToolCompleted:k=>c?.(k),temporarilyHidden:m,openSignal:C,restoreFocusRef:A,showMobileTrigger:w===void 0}),K&&(0,se.jsxs)("div",{"data-testid":"zone-help-card",style:{position:"absolute",bottom:58,left:"50%",transform:"translateX(-50%)",zIndex:13,width:300,padding:"12px 14px",background:"#fff",borderRadius:12,border:"1px solid #f0f0f0",boxShadow:"0 4px 16px rgba(0,0,0,0.10)"},children:[(0,se.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[(0,se.jsx)("span",{style:{fontSize:13,fontWeight:600,color:"#262626"},children:"Quick navigation"}),(0,se.jsx)("span",{"data-testid":"zone-help-close",onClick:()=>{kd(!0),F(!1)},style:{cursor:"pointer",color:"#8c8c8c",fontSize:12,lineHeight:1},children:"\u2715"})]}),(0,se.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,fontSize:12,color:"#595959"},children:[(0,se.jsxs)("div",{children:[(0,se.jsx)("span",{style:Qo,children:"\u2318/Ctrl + 1\u20134"})," focus a zone"]}),(0,se.jsxs)("div",{children:[(0,se.jsx)("span",{style:Qo,children:"Click a dot"})," focus a zone"]}),(0,se.jsxs)("div",{children:[(0,se.jsx)("span",{style:Qo,children:"Drag a zone label"})," move the block"]}),(0,se.jsxs)("div",{children:[(0,se.jsx)("span",{style:Qo,children:"\u{1F4CC} Click a zone label"})," pin it into the side split (click again to unpin)"]}),(0,se.jsx)("div",{style:{color:"#8c8c8c"},children:"\u2460 Config \u2461 Learning \u2462 Evaluation \u2463 Copilot"})]}),(0,se.jsx)("div",{style:{marginTop:8,paddingTop:8,borderTop:"1px solid #f0f0f0",display:"flex",justifyContent:"flex-end",gap:8},children:(0,se.jsx)("button",{type:"button","data-testid":"layout-reset",onClick:er,style:{cursor:"pointer",border:"1px solid #e0e0e0",borderRadius:4,background:"#fafafa",padding:"2px 10px",fontSize:12,color:"#595959"},children:"Reset layout"})})]}),(0,se.jsxs)("div",{"data-testid":"zone-quick-nav",style:{position:"absolute",bottom:16,left:"50%",transform:"translateX(-50%)",zIndex:12,display:"flex",gap:10,padding:"8px 14px",background:"#fff",borderRadius:9999,border:"1px solid #f0f0f0",boxShadow:"0 2px 12px rgba(0,0,0,0.08)"},children:[[["config","Config"],["learning","Learning"],["testing","Evaluation"],["copilot","Copilot"]].map(([k,l])=>{let I=Is[k],E=I!==void 0&&oe.has(I);return(0,se.jsx)("button",{type:"button","aria-label":`Fit ${l} zone`,"data-testid":`zone-dot-${k}`,className:ne===k?"zone-dot-active":void 0,onClick:()=>{Ae(k),j.fitView({padding:.4,duration:400,nodes:[{id:be[k].id}]})},style:{width:10,height:10,borderRadius:"9999px",border:"none",padding:0,cursor:"pointer",background:ne===k||E?"#6366f1":"#d9d9d9"}},k)}),(0,se.jsx)("span",{"aria-hidden":"true",style:{width:1,alignSelf:"stretch",background:"#f0f0f0"}}),(0,se.jsx)("span",{"data-testid":"zone-help-toggle",className:"zone-help-toggle","aria-label":"Quick navigation guide",onClick:()=>F(k=>!k),style:{cursor:"pointer",color:"#8c8c8c",fontSize:12,lineHeight:"10px",userSelect:"none"},children:"\u24D8"})]})]})},Id=e=>{let t=No(e.assistantId??""),n=(0,q.useRef)(e.evalTick??0);return(0,q.useEffect)(()=>{let o=e.evalTick??0,r=n.current;n.current=o,o>0&&o!==r&&t.refresh().catch(()=>{})},[e.evalTick]),(0,se.jsx)(Ps,{...e,evalData:t})},Cd=({evalData:e,...t})=>(0,se.jsx)(Ps,{...t,evalData:e}),Ds=({evalData:e,...t})=>(0,se.jsx)(yo,{children:e?(0,se.jsx)(Cd,{...t,evalData:e}):(0,se.jsx)(Id,{...t})});var Yo=R(xe());var Ve=R(M()),{Text:_r}=We;function Sd(e){let t=null;if(typeof e=="string")try{t=JSON.parse(e)}catch{return null}else e&&typeof e=="object"&&(t=e);if(!t||typeof t.workflowYaml!="string")return null;try{return Bi(t.workflowYaml)}catch{return null}}var Ls=({graphDefinition:e,assistantId:t,assistantName:n,workspaceId:o,description:r,initialMessageRequest:i,onInitialMessageSubmitted:a,projectId:u,onProjectChange:d,onLearningStarted:p,onToolActivity:h,learningTasks:c,onLearningRefresh:s,evalTick:f,hideTitleBar:y=!1,hudTopOffset:g,copilotTemporarilyHidden:v,onOpenArchitect:m,architectOpenSignal:w=0,architectRestoreFocusRef:C})=>{let[A,T]=(0,Yo.useState)(!1),O=(0,Yo.useMemo)(()=>Sd(e),[e]);return(0,Ve.jsxs)("div",{style:{width:"100%",height:"100%",position:"relative",background:"#fafafa"},children:[(0,Ve.jsx)(yo,{children:(0,Ve.jsx)("div",{style:{width:"100%",height:"100%"},children:O?(0,Ve.jsx)(zi,{dsl:O}):(0,Ve.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,Ve.jsx)(_r,{type:"secondary",children:"No workflow DSL yet \u2014 ask the architect to design one"})})})}),!y&&(0,Ve.jsxs)("div",{style:{position:"absolute",top:12,right:12,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,Ve.jsx)(uo,{size:16,color:"#6366f1"}),(0,Ve.jsx)(_r,{strong:!0,style:{fontSize:13},children:n}),(0,Ve.jsx)(lo,{style:{color:"#6366f1",cursor:"pointer",fontSize:15},onClick:()=>T(!0)})]}),(0,Ve.jsx)(Fo,{assistantId:t,projectId:u,onProjectChange:d,onLearningStarted:p,learningTasks:c,topOffset:g,onLearningRefresh:s,evalTick:f}),(0,Ve.jsx)(Vo,{assistantId:t,assistantName:n,workspaceId:o,projectId:u,contextType:"workflow",label:"Builder",initialMessageRequest:i,onInitialMessageSubmitted:a,onToolCompleted:_=>h?.(_),temporarilyHidden:v,openSignal:w,restoreFocusRef:C,showMobileTrigger:m===void 0}),(0,Ve.jsx)(_e,{title:n,open:A,onCancel:()=>T(!1),footer:null,width:"85vw",centered:!0,styles:{body:{maxHeight:"calc(85vh - 120px)",overflow:"auto",padding:"12px 24px 24px"}},children:r?(0,Ve.jsx)(kn,{content:r}):(0,Ve.jsx)(_r,{type:"secondary",children:"No description set."})})]})};var He=R(xe());var U=R(M()),{Text:Fr}=We;function Ns(e){switch(e.type){case"capability":case"agent":return 560;case"eval":return 860;default:return 400}}function Ms(e){return e.label}var Ad=({label:e,confirmLabel:t,onConfirm:n})=>{let[o,r]=(0,He.useState)(!1);return o?(0,U.jsx)(V,{danger:!0,size:"small",onClick:n,children:t}):(0,U.jsx)(V,{danger:!0,size:"small",type:"text",onClick:()=>r(!0),children:e})},Kt=({title:e,children:t})=>(0,U.jsxs)("div",{style:{marginBottom:16},children:[(0,U.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"#999",marginBottom:6},children:e}),t]}),Ed=({node:e})=>{let{get:t}=Xe(),[n,o]=(0,He.useState)(null),[r,i]=(0,He.useState)(!0);if((0,He.useEffect)(()=>{let d=!1;return i(!0),t("/api/tools").then(p=>{if(d)return;let h=p.data?.records?.find(c=>c.name===e.label)??null;o(h)}).catch(()=>!d&&o(null)).finally(()=>!d&&i(!1)),()=>{d=!0}},[t,e.label]),r)return(0,U.jsx)(wt,{size:"small"});if(!n)return(0,U.jsx)(Fr,{type:"secondary",style:{fontSize:13},children:"Tool details unavailable."});let a=n.schema?.properties??{},u=new Set(n.schema?.required??[]);return(0,U.jsxs)(U.Fragment,{children:[n.description&&(0,U.jsx)(Kt,{title:"Description",children:n.description}),Object.keys(a).length>0&&(0,U.jsx)(Kt,{title:"Parameters",children:Object.entries(a).map(([d,p])=>(0,U.jsxs)("div",{style:{display:"flex",gap:8,fontSize:12,padding:"4px 0",alignItems:"baseline"},children:[(0,U.jsxs)("span",{style:{color:"#333",fontWeight:600},children:[d,u.has(d)&&(0,U.jsx)("span",{style:{color:"#ef4444"},children:" *"})]}),(0,U.jsx)("span",{style:{color:"#999"},children:p.type??"any"}),p.description&&(0,U.jsx)("span",{style:{color:"#666",flex:1},children:p.description})]},d))})]})},Pd=({node:e})=>{let{get:t}=Xe(),[n,o]=(0,He.useState)(null),[r,i]=(0,He.useState)(!0);return(0,He.useEffect)(()=>{let a=!1;return i(!0),t(`/api/assistants/${e.label}`).then(u=>!a&&o(u.data??null)).catch(()=>!a&&o(null)).finally(()=>!a&&i(!1)),()=>{a=!0}},[t,e.label]),r?(0,U.jsx)(wt,{size:"small"}):n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Kt,{title:"Description",children:n.description||"No description"}),n.graphDefinition?.modelKey&&(0,U.jsx)(Kt,{title:"Model",children:n.graphDefinition.modelKey})]}):(0,U.jsx)(Fr,{type:"secondary",style:{fontSize:13},children:"Sub-agent details unavailable."})},Dd=({node:e})=>{let{get:t}=Xe(),[n,o]=(0,He.useState)(null),[r,i]=(0,He.useState)(!0);return(0,He.useEffect)(()=>{let a=!1;return i(!0),t(`/api/skills/${e.label}`).then(u=>!a&&o(u.data??null)).catch(()=>!a&&o(null)).finally(()=>!a&&i(!1)),()=>{a=!0}},[t,e.label]),r?(0,U.jsx)(wt,{size:"small"}):n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Kt,{title:"Description",children:n.description||"No description"}),n.content&&(0,U.jsx)(Kt,{title:"Content",children:(0,U.jsx)(kn,{content:n.content})})]}):(0,U.jsx)(Fr,{type:"secondary",style:{fontSize:13},children:"Skill details unavailable."})},Ld=({node:e,graphDefinition:t,onSaveGraph:n})=>{let{config:o}=ao(),{middlewareTypes:r}=To(o.middlewareTypesEndpoint),i=e.config??{},[a,u]=(0,He.useState)({id:i.type??e.id,type:i.type??"unknown",name:i.name??e.label,description:i.description??"",enabled:i.enabled!==!1,config:i.config??{},allowedTools:i.allowedTools}),[d,p]=(0,He.useState)(!1),h=(o.availableMiddlewareTypes||r)?.find(s=>s.type===a.type),c=async()=>{if(n){p(!0);try{let s=typeof t=="object"&&t!==null?t:{},f=Array.isArray(s.middleware)?s.middleware:[],y={...i,name:a.name,description:a.description,enabled:a.enabled,config:a.config,...a.allowedTools!==void 0?{allowedTools:a.allowedTools}:{}},g=f.some(v=>v.type===a.type)?f.map(v=>v.type===a.type?y:v):[...f,y];await n({...s,middleware:g}),rt.success("Capability saved")}catch{rt.error("Failed to save capability")}finally{p(!1)}}};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ro,{middleware:a,middlewareType:h,onToggle:()=>u(s=>({...s,enabled:!s.enabled})),onConfigChange:s=>u(f=>({...f,config:{...f.config,...s}})),onAllowedToolsChange:s=>u(f=>({...f,allowedTools:s}))}),(0,U.jsx)("div",{style:{marginTop:16,textAlign:"right"},children:(0,U.jsx)(V,{type:"primary",size:"small",loading:d,onClick:()=>void c(),children:"Save"})})]})},Nd=({graphDefinition:e,onSaveGraph:t})=>{let n=typeof e=="object"&&e!==null?e:{},[o,r]=(0,He.useState)(n.description??""),[i,a]=(0,He.useState)(n.prompt??""),[u,d]=(0,He.useState)(n.modelKey??""),[p,h]=(0,He.useState)(!1),c=async()=>{if(t){h(!0);try{await t({...n,description:o,prompt:i,modelKey:u}),rt.success("Agent saved")}catch{rt.error("Failed to save agent")}finally{h(!1)}}};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Kt,{title:"Description",children:(0,U.jsx)(De.TextArea,{"aria-label":"Description",rows:2,value:o,onChange:s=>r(s.target.value)})}),(0,U.jsx)(Kt,{title:"Model",children:(0,U.jsx)(De,{"aria-label":"Model",size:"small",value:u,onChange:s=>d(s.target.value)})}),(0,U.jsx)(Kt,{title:"Prompt",children:(0,U.jsx)(De.TextArea,{"aria-label":"Prompt",rows:8,value:i,onChange:s=>a(s.target.value)})}),(0,U.jsx)("div",{style:{textAlign:"right"},children:(0,U.jsx)(V,{type:"primary",size:"small",loading:p,onClick:()=>void c(),children:"Save"})})]})},Os=({node:e,graphDefinition:t,assistantId:n,onRemoveNode:o,onSaveGraph:r})=>{let i=e.type==="tool"||e.type==="subagent"||e.type==="skill";return(0,U.jsxs)("div",{children:[(0,U.jsx)("div",{style:{marginBottom:12},children:(0,U.jsx)(qe,{bordered:!1,style:{margin:0,fontSize:10},children:ea[e.type]})}),e.type==="tool"&&(0,U.jsx)(Ed,{node:e},e.id),e.type==="subagent"&&(0,U.jsx)(Pd,{node:e},e.id),e.type==="skill"&&(0,U.jsx)(Dd,{node:e},e.id),e.type==="capability"&&(0,U.jsx)(Ld,{node:e,graphDefinition:t,onSaveGraph:r},e.id),e.type==="agent"&&(0,U.jsx)(Nd,{graphDefinition:t,onSaveGraph:r},e.id),e.type==="eval"&&n&&(0,U.jsx)(Co,{assistantId:n},e.id),i&&o&&(0,U.jsx)("div",{style:{marginTop:16,borderTop:"1px solid #f0f0f0",paddingTop:12},children:(0,U.jsx)(Ad,{label:"Remove from agent",confirmLabel:"Confirm remove",onConfirm:()=>o(e)})})]})};function _s(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return}if(!t||typeof t!="object"||Array.isArray(t))return;let n=t.metadata;if(!n||typeof n!="object"||Array.isArray(n))return;let o=n.trainingProjectId;return typeof o=="string"?o:void 0}var Se=R(xe());var Md=new Set(["create_agent","update_agent","delete_agent","create_workflow","update_workflow"]),Od=new Set(["manage_task"]),_d=new Set(["manage_eval","run_eval"]),Fd=new Set(["create_agent","delete_agent"]);function Fs(e){return Fd.has(e)}function Ws(e){let t=[];return Md.has(e)&&t.push("config"),Od.has(e)&&t.push("tasks"),_d.has(e)&&t.push("eval"),t}var Wd=300,Wr=()=>({rounds:[],round:null,subTasks:[],subTasksByRound:{},loading:!0}),zr=()=>({config:{error:null,updatedAt:null},tasks:{error:null,updatedAt:null,partial:!1}});function zd(e,t,n){let o=new Set(n),r=new Map(e.map(u=>[u.id,u])),i=u=>{let d=u.parentId,p=new Set;for(;d&&!p.has(d);){if(o.has(d))return!0;p.add(d),d=r.get(d)?.parentId}return!1},a=new Set(t.map(u=>u.id));return[...t,...e.filter(u=>!a.has(u.id)&&i(u))]}function zs(e){let{agentId:t,projectId:n,onAssistantUpdated:o,onAgentListInvalidated:r}=e,{get:i}=Xe(),a=`${t}\0${n??""}`,[u,d]=(0,Se.useState)(()=>({scope:a,value:Wr()})),[p,h]=(0,Se.useState)(()=>({scope:a,value:0})),[c,s]=(0,Se.useState)(()=>({scope:a,value:zr()})),f=(0,Se.useRef)({}),y=(0,Se.useRef)(0),g=(0,Se.useRef)(null),v=(0,Se.useRef)(null),m=(0,Se.useRef)(0),w=(0,Se.useRef)({}),C=(0,Se.useRef)(!1),A=(0,Se.useRef)(a),T=(0,Se.useRef)({onAssistantUpdated:o,onAgentListInvalidated:r});(0,Se.useLayoutEffect)(()=>{T.current={onAssistantUpdated:o,onAgentListInvalidated:r}},[o,r]),(0,Se.useLayoutEffect)(()=>{if(A.current!==a){A.current=a,y.current+=1,m.current+=1,w.current={},g.current=null,v.current=null,C.current=!1;for(let z of Object.values(f.current))z&&clearTimeout(z);f.current={},d({scope:a,value:Wr()}),s({scope:a,value:zr()}),h({scope:a,value:0})}},[a]);let O=u.scope===a?u.value:Wr(),_=c.scope===a?c.value:zr(),D=p.scope===a?p.value:0,x=z=>{s(K=>K.scope===a?{scope:a,value:z(K.value)}:K)},B=(0,Se.useCallback)(async()=>{let z=++m.current,K=a;try{let F=await i(`/api/assistants/${t}`);if(z!==m.current||K!==A.current)return;F.success&&F.data?(C.current=!1,T.current.onAssistantUpdated?.(F.data),x(ne=>({...ne,config:{error:null,updatedAt:new Date}}))):(C.current=!1,x(ne=>({...ne,config:{...ne.config,error:new Error("Configuration refresh returned no agent")}})))}catch(F){if(z!==m.current||K!==A.current)return;if(F instanceof Ur&&F.statusCode===404){C.current||T.current.onAgentListInvalidated?.(),C.current=!1,x(P=>({...P,config:{...P.config,error:F}}));return}C.current=!1,console.warn("[useEntityRefresher] config refresh failed",F);let ne=F instanceof Error?F:new Error(String(F));x(P=>({...P,config:{...P.config,error:ne}}))}},[i,t,a]),Z=(0,Se.useCallback)(()=>{let z=g.current;if(z?.scope===a)return z.promise;let K=++y.current,F=a,ne=(async()=>{try{let G=((await i(En(t,n))).data??[]).filter(An),le={},oe=!1;if(await Promise.all(G.map(async fe=>{let L=await ka(i,fe.id,{projectId:n});oe||=L.partial,le[fe.id]=L.partial?zd(w.current[fe.id]??[],L.tasks,L.incompleteParentIds??[]):L.tasks})),K!==y.current||F!==A.current)return;w.current=Object.fromEntries(G.map(fe=>[fe.id,le[fe.id]??[]]));let Ie=G[0]??null;d({scope:a,value:{rounds:G,round:Ie,subTasks:Ie?le[Ie.id]??[]:[],subTasksByRound:le,loading:!1}}),x(fe=>({...fe,tasks:{error:null,updatedAt:new Date,partial:oe}}))}catch(P){if(console.warn("[useEntityRefresher] task refresh failed",P),K!==y.current||F!==A.current)return;d(le=>le.scope===a?{scope:a,value:{...le.value,loading:!1}}:le);let G=P instanceof Error?P:new Error(String(P));x(le=>({...le,tasks:{...le.tasks,error:G}}))}})().finally(()=>{g.current?.promise===ne&&(g.current=null,v.current===F&&A.current===F&&(v.current=null,Y.current.refreshLearningTasks()))});return g.current={scope:a,promise:ne},ne},[i,t,n,a]),Y=(0,Se.useRef)({refreshAgent:B,refreshLearningTasks:Z});(0,Se.useEffect)(()=>{Y.current={refreshAgent:B,refreshLearningTasks:Z}});let H=(0,Se.useCallback)((z,K)=>{let F=f.current;F[z]&&clearTimeout(F[z]),F[z]=setTimeout(K,Wd)},[]),j=(0,Se.useCallback)(z=>{for(let K of Ws(z))K==="config"&&H(K,()=>{Fs(z)&&(C.current=!0,T.current.onAgentListInvalidated?.()),Y.current.refreshAgent()}),K==="tasks"&&H(K,()=>{let F=A.current;g.current?.scope===F?v.current=F:Y.current.refreshLearningTasks()}),K==="eval"&&H(K,()=>{let F=A.current;h(ne=>ne.scope===F?{scope:F,value:ne.value+1}:ne)})},[H]);return(0,Se.useEffect)(()=>{Z()},[Z]),(0,Se.useEffect)(()=>()=>{for(let z of Object.values(f.current))z&&clearTimeout(z)},[]),{handleToolCompleted:j,learningTasks:O,refreshLearningTasks:Z,refreshAgent:B,freshness:_,evalTick:D}}var J=R(M()),{Text:Bs}=We,Xo={color:"#4f46e5",background:"#eef2ff"},Bd=`
238
+ @media (max-width: 767px) {
239
+ .agent-detail__identity-pill { max-width: calc(100% - 24px) !important; right: 12px; }
240
+ .agent-detail__actions-pill { top: 52px !important; left: 12px; right: auto !important; }
241
+ }
242
+ `,jd=e=>e==="configuration"?{kind:"configuration"}:e==="playground"?{kind:"playground"}:e==="eval"?{kind:"eval",initial:{page:"suites"},navigationKey:0}:e==="web-apps"?{kind:"web-apps"}:null,Gd=e=>{let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return{}}return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}},ym=({assistant:e,allAssistants:t,onBack:n,onDeleted:o,initialTab:r="graph",onSave:i,onAssistantUpdated:a,onAgentListInvalidated:u,initialMessage:d=null,initialMessageCustomRunConfig:p=null,initialProjectId:h=null})=>{let[c,s]=(0,Re.useState)(()=>jd(r)),[f,y]=(0,Re.useState)(!1),[g,v]=(0,Re.useState)(!1),[m,w]=(0,Re.useState)(null),[C,A]=(0,Re.useState)(0),T=(0,Re.useRef)(null),O=(0,Re.useRef)(()=>{}),_=(0,Re.useRef)(0),D=(0,Re.useRef)(null),x=(0,Re.useRef)(null),B=(0,Re.useRef)(null),Z=(0,Re.useRef)(null),Y=(0,Re.useRef)(null),H=(0,Re.useRef)(null),j=(0,Re.useRef)(null),[z,K]=(0,Re.useState)(()=>d?{requestId:`initial:${e.id}`,content:d,...p?{customRunConfig:p}:{}}:null),{workspaceId:F,trainingProjects:ne}=Lt(),P=_s(e.graphDefinition),[G,le]=(0,Re.useState)(h??P??ne[0]?.id??null),oe=$=>{le($)},Ie=($,me,Qe)=>{let Ye=ne.find(je=>je.id===G)??null;K({requestId:me,content:va({goal:$,roundTaskId:me,targetAgentId:e.id,targetMode:ba(e),files:Qe,projectId:G??void 0,workspaceId:Ye?.workspaceId??F??void 0}),customRunConfig:{execution:{taskId:me}}})},fe=$=>{K(me=>me?.requestId===$?null:me)};(0,Re.useEffect)(()=>{!G&&ne.length>0&&le(ne[0].id)},[G,ne]);let[L,ie]=(0,Re.useState)(!1),[Ee,W]=(0,Re.useState)(!1),[N,X]=(0,Re.useState)(!1),[de,S]=(0,Re.useState)(e.graphDefinition),{handleToolCompleted:Pe,learningTasks:he,refreshLearningTasks:Te,evalTick:Ae}=zs({agentId:e.id,projectId:G,onAssistantUpdated:a,onAgentListInvalidated:u});(0,Re.useEffect)(()=>{S(e.graphDefinition)},[e]);let Le=typeof e.graphDefinition=="object"?e.graphDefinition:{},nt=String(Le.type??"react"),Fe=Cn(nt),Je=nt==="workflow"?uo:Bn,Ne=cr(e),gt=pr(e),bt=$i(gt),Ct=$=>{$.kind==="back"?n():$.kind==="close"?s(null):$.kind==="architect"?(s(null),A(me=>me+1)):s($.view)},Be=$=>{if(!T.current&&!($.kind==="dock"&&$.view.kind!=="node"&&c?.kind===$.view.kind&&$.view.kind!=="eval")){if(c?.kind==="configuration"&&f){T.current=$,w($);return}Ct($)}};O.current=Be;let on=$=>{let me=$??(document.activeElement instanceof HTMLElement?document.activeElement:void 0);return me?{current:me}:void 0},rn=(0,Re.useCallback)($=>{let me=++_.current;O.current({kind:"dock",view:{kind:"eval",initial:{page:"suites"},navigationKey:me,restoreFocusRef:on($)}})},[]),an=()=>{T.current=null,w(null),requestAnimationFrame(()=>j.current?.())},Wt=()=>{let $=T.current;$&&(T.current=null,w(null),y(!1),Ct($))},vt=()=>{W(!0)},Ke=async()=>{ie(!0);try{await o(e.id),W(!1)}finally{ie(!1)}},kt=$=>(S($),i?.(e,$)),hn=i?async($,me)=>{await i($,me),S({...Gd($.graphDefinition),...me})}:void 0,Ut=$=>{let me=typeof de=="object"&&de!==null?de:{},Qe={...me};if($.type==="tool"&&$.id.startsWith("tool:"))Qe.tools=(me.tools??[]).filter(Ye=>Ye!==$.id.slice(5));else if($.type==="subagent"&&$.id.startsWith("sub:"))Qe.subAgents=(me.subAgents??[]).filter(Ye=>Ye!==$.id.slice(4));else if($.type==="skill"&&$.id.startsWith("skill:")){let Ye=$.id.slice(6);Qe.skills=(me.skills??[]).filter(je=>je!==Ye),Array.isArray(me.middleware)&&(Qe.middleware=me.middleware.map(je=>{if(je.type!=="skill")return je;let St=typeof je.config=="object"&&je.config!==null?je.config:{};return $.id===gr?{...je,config:{...St,readAll:!1}}:!Array.isArray(St.skills)||!St.skills.includes(Ye)?je:{...je,config:{...St,skills:St.skills.filter(et=>et!==Ye)}}}))}else if($.type==="capability"&&$.id.startsWith("cap:")){let Ye=$.id.slice(4);Qe.middleware=(me.middleware??[]).filter(je=>je.type!==Ye)}else return;S(Qe),i?.(e,Qe).catch(()=>rt.error("Failed to save after removing node"))};return(0,J.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",background:"#fff"},children:[(0,J.jsx)("style",{"data-agent-detail-responsive":!0,children:Bd}),(0,J.jsxs)("div",{style:{flex:1,minHeight:0,position:"relative"},children:[(0,J.jsxs)("div",{"data-testid":"agent-header-pill",className:"agent-detail__identity-pill",style:{position:"absolute",top:12,left:12,zIndex:12,display:"flex",alignItems:"center",gap:8,height:32,padding:"0 10px 0 4px",background:"rgba(255,255,255,0.95)",borderRadius:10,boxShadow:"0 2px 12px rgba(0,0,0,0.08)",border:"1px solid #f0f0f0",maxWidth:"calc(100% - 176px)",minWidth:0},children:[(0,J.jsx)(V,{type:"text",size:"small",icon:(0,J.jsx)(Qr,{}),onClick:()=>Be({kind:"back"}),"aria-label":"Back"}),(0,J.jsx)(Je,{size:15,color:jn(Fe.color)}),(0,J.jsx)(Bs,{strong:!0,style:{fontSize:13,maxWidth:220,minWidth:0,flex:"1 1 auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),(0,J.jsx)("span",{"data-testid":"agent-status-dot",title:gt,style:{width:8,height:8,borderRadius:"50%",background:jn(bt),flexShrink:0}}),(0,J.jsx)(V,{type:"text",size:"small","aria-label":"View description",icon:(0,J.jsx)(lo,{}),style:{color:"#6366f1"},onClick:()=>X(!0)})]}),(0,J.jsxs)("div",{"data-testid":"agent-actions-pill",className:"agent-detail__actions-pill",style:{position:"absolute",top:12,right:12,zIndex:12,display:"flex",alignItems:"center",gap:2,height:32,padding:"0 6px",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,J.jsx)(Qt,{title:"Test in Playground",children:(0,J.jsx)(V,{ref:D,type:"text",size:"small",icon:(0,J.jsx)(yi,{size:14}),onClick:()=>Be({kind:"dock",view:{kind:"playground"}}),"aria-label":"Test in Playground","aria-pressed":c?.kind==="playground",style:c?.kind==="playground"?Xo:void 0})}),(0,J.jsx)(Qt,{title:"Eval Suite",children:(0,J.jsx)(V,{ref:x,type:"text",size:"small",icon:(0,J.jsx)(co,{size:14}),onClick:()=>rn(x.current??void 0),"aria-label":"Eval Suite","aria-pressed":c?.kind==="eval",style:c?.kind==="eval"?Xo:void 0})}),(0,J.jsx)(Qt,{title:"Web Apps",children:(0,J.jsx)(V,{ref:B,type:"text",size:"small",icon:(0,J.jsx)(gi,{size:14}),onClick:()=>Be({kind:"dock",view:{kind:"web-apps"}}),"aria-label":"Web Apps","aria-pressed":c?.kind==="web-apps",style:c?.kind==="web-apps"?Xo:void 0})}),(0,J.jsx)(Qt,{title:"Configuration",children:(0,J.jsx)(V,{ref:Z,type:"text",size:"small",icon:(0,J.jsx)(hi,{size:14}),onClick:()=>Be({kind:"dock",view:{kind:"configuration"}}),"aria-label":"Configuration","aria-pressed":c?.kind==="configuration",style:c?.kind==="configuration"?Xo:void 0})}),(0,J.jsx)(Qt,{title:"Delete Agent",children:(0,J.jsx)(V,{type:"text",size:"small",danger:!0,icon:(0,J.jsx)(so,{}),loading:L,onClick:vt,"aria-label":"Delete Agent"})})]}),nt==="workflow"?(0,J.jsx)(Ls,{graphDefinition:de,assistantId:e.id,assistantName:e.name,workspaceId:F,description:e.description,hideTitleBar:!0,hudTopOffset:56,initialMessageRequest:z,onInitialMessageSubmitted:fe,projectId:G,onProjectChange:oe,onLearningStarted:Ie,onToolActivity:Pe,learningTasks:he,onLearningRefresh:Te,evalTick:Ae,architectOpenSignal:C,architectRestoreFocusRef:H,copilotTemporarilyHidden:c!==null}):(0,J.jsx)(Ds,{graphDefinition:de,assistantId:e.id,assistantName:e.name,workspaceId:F,hudTopOffset:56,onSelectNode:$=>{$?Be({kind:"dock",view:{kind:"node",node:$}}):c?.kind==="node"&&Be({kind:"close"})},onRemoveNode:Ut,initialMessageRequest:z,onInitialMessageSubmitted:fe,projectId:G,onProjectChange:oe,onLearningStarted:Ie,onToolActivity:Pe,learningTasks:he,onLearningRefresh:Te,evalTick:Ae,architectOpenSignal:C,architectRestoreFocusRef:H,copilotTemporarilyHidden:c!==null}),c?.kind==="node"&&(0,J.jsx)(lt,{open:!0,width:Ns(c.node),title:Ms(c.node),onClose:()=>s(null),children:(0,J.jsx)(Os,{node:c.node,graphDefinition:de,assistantId:e.id,onRemoveNode:$=>{Ut($),s(null)},onSaveGraph:kt})}),c?.kind==="playground"&&(0,J.jsx)(lt,{open:!0,width:720,title:"Playground",onClose:()=>Be({kind:"close"}),restoreFocusRef:D,children:(0,J.jsx)(Fi,{assistant_id:e.id})}),c?.kind==="eval"&&(0,J.jsx)(lt,{open:!0,width:860,title:c.initial?.page==="run"?"Run Results":"Eval Suite",onClose:()=>Be({kind:"close"}),restoreFocusRef:c.restoreFocusRef??x,children:(0,J.jsx)(Co,{assistantId:e.id,initial:c.initial,navigationKey:c.navigationKey})},c.navigationKey),c?.kind==="web-apps"&&(0,J.jsx)(lt,{open:!0,width:960,title:"Web Apps",onClose:()=>Be({kind:"close"}),restoreFocusRef:B,bodyStyle:{padding:0,overflow:"hidden"},children:(0,J.jsx)(Yi,{assistant:e})}),c?.kind==="configuration"&&(0,J.jsx)(lt,{open:!0,width:"80%",mobileWidth:"calc(100% - 24px)",title:"Configuration",onClose:()=>Be({kind:"close"}),bodyStyle:{padding:0,overflow:"hidden"},restoreFocusRef:Y,focusControlRef:j,escapeEnabled:!g&&!N&&!Ee&&m===null,children:(0,J.jsx)(Zi,{assistant:{...e,graphDefinition:de},allAssistants:t,visible:!0,onClose:()=>Be({kind:"close"}),onSave:hn,onDirtyChange:y,onOverlayOpenChange:v,embedded:!0})})]}),(0,J.jsx)(_e,{title:"Discard unsaved configuration?",open:m!==null,onCancel:an,onOk:Wt,okText:"Discard",okButtonProps:{danger:!0},cancelText:"Continue editing",children:(0,J.jsx)("p",{children:"You have unsaved configuration changes. Discard them and continue?"})}),(0,J.jsxs)(_e,{title:e.name,open:N,onCancel:()=>X(!1),footer:null,width:640,centered:!0,children:[(0,J.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:12},children:[(0,J.jsx)(qe,{color:Fe.color,style:{margin:0},children:Fe.label}),Ne.map($=>(0,J.jsx)(qe,{color:"magenta",style:{margin:0},children:$},$)),(0,J.jsx)(qe,{style:{margin:0},children:ur(e)}),(0,J.jsx)(qe,{color:bt,style:{margin:0},children:gt})]}),e.description?(0,J.jsx)(kn,{content:e.description}):(0,J.jsx)(Bs,{type:"secondary",children:"No description set."})]}),(0,J.jsx)(_e,{title:"Delete Agent",open:Ee,onCancel:()=>W(!1),onOk:Ke,okText:"Delete",okButtonProps:{danger:!0,loading:L},cancelText:"Cancel",children:(0,J.jsxs)("p",{children:['Are you sure you want to delete "',e.name,'"? This action cannot be undone.']})})]})};export{Cn as a,jn as b,$d as c,qd as d,Hd as e,ga as f,ma as g,Su as h,ya as i,ha as j,va as k,ym as l};