@axiom-lattice/gateway 4.3.0 → 4.3.2

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 (26) hide show
  1. package/dist/embed/{embed-page-AgentDetailSideApp-7FH2JSZI.js → embed-page-AgentDetailSideApp-7PQ2JKG6.js} +1 -1
  2. package/dist/embed/{embed-page-AgentGovernanceWorkbench-Y5F3ZPYC.js → embed-page-AgentGovernanceWorkbench-ZNW72EEJ.js} +1 -1
  3. package/dist/embed/{embed-page-MessageGraph-ONODQPG4.js → embed-page-MessageGraph-P7DBTZCL.js} +1 -1
  4. package/dist/embed/{embed-page-ReactChart-GZQSKCUG.js → embed-page-ReactChart-XS7D26VP.js} +1 -1
  5. package/dist/embed/{embed-page-SkillFlow-TPESM4DI.js → embed-page-SkillFlow-HPH37PZH.js} +1 -1
  6. package/dist/embed/{embed-page-TasksSideApp-HYKCJ356.js → embed-page-TasksSideApp-MQTUCJO4.js} +1 -1
  7. package/dist/embed/{embed-page-TeamWorkspace-IOHS4RJV.js → embed-page-TeamWorkspace-7T2HRXLG.js} +1 -1
  8. package/dist/embed/{embed-page-TopologyRuntimeView-QLMZ4OE7.js → embed-page-TopologyRuntimeView-PU2D7VZ7.js} +1 -1
  9. package/dist/embed/{embed-page-WorkflowAutomationView-FJJSGY7Z.js → embed-page-WorkflowAutomationView-ST76M33F.js} +1 -1
  10. package/dist/embed/{embed-page-chunk-ZTRCHYWV.js → embed-page-chunk-4ZSGPIBZ.js} +1 -1
  11. package/dist/embed/{embed-page-chunk-MCUFFMAW.js → embed-page-chunk-BRETUPSG.js} +86 -86
  12. package/dist/embed/{embed-page-chunk-FXTSVMPN.js → embed-page-chunk-I42T7B7V.js} +44 -39
  13. package/dist/embed/{embed-page-chunk-SMQZEZYG.js → embed-page-chunk-LE6OFJ7R.js} +1 -1
  14. package/dist/embed/embed-page-chunk-RLP3BC7G.js +245 -0
  15. package/dist/embed/{embed-page-chunk-KFUAWYJ7.js → embed-page-chunk-T25T2YE6.js} +1 -1
  16. package/dist/embed/{embed-page-chunk-EMPMOO53.js → embed-page-chunk-VRV57DFE.js} +1 -1
  17. package/dist/embed/{embed-page-chunk-D3NRIME3.js → embed-page-chunk-Z4S4OYA4.js} +1 -1
  18. package/dist/embed/{embed-page-chunk-6LL6YULZ.js → embed-page-chunk-ZKJ7Z7P3.js} +1 -1
  19. package/dist/embed/{embed-page-chunk-VVYB3C4O.js → embed-page-chunk-ZXFZANZM.js} +1 -1
  20. package/dist/embed/embed-page.js +1 -1
  21. package/dist/index.js +2 -2
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +2 -2
  24. package/dist/index.mjs.map +1 -1
  25. package/package.json +7 -7
  26. package/dist/embed/embed-page-chunk-L7RMIQ7C.js +0 -245
@@ -1,245 +0,0 @@
1
- import{e as Mi}from"./embed-page-chunk-SMQZEZYG.js";import{a as dr,b as An}from"./embed-page-chunk-D3NRIME3.js";import{b as _i,c as zi}from"./embed-page-chunk-6LL6YULZ.js";import{c as bo,d as vo}from"./embed-page-chunk-KEL6XU6R.js";import{b as ot,c as Ai,d as yo,e as wt,f as ho,g as Ei,h as In,i as Sn,j as Pi,l as Di,m as Li}from"./embed-page-chunk-AC6X2XRH.js";import{a as xi,b as To,c as Oi,d as Fi,e as Ro,f as lr,g as Wi,h as Bi}from"./embed-page-chunk-FXTSVMPN.js";import{a as Ni,b as ko,c as wo,d as xo}from"./embed-page-chunk-EMPMOO53.js";import{a as Cn}from"./embed-page-chunk-VVYB3C4O.js";import{Da as bi,H as ai,Ia as po,J as si,Ja as vi,K as li,Ka as ki,M as di,Ma as wi,N as ci,Oa as At,P as uo,X as ui,_a as Tn,cb as Rn,db as go,eb as fo,fb as Ti,gb as Ri,jb as Ii,kb as Si,l as oi,lb as Ci,ma as pi,mb as mo,n as ri,na as gi,o as Gn,oa as fi,qa as mi,ra as yi,xa as hi,z as ii}from"./embed-page-chunk-MCUFFMAW.js";import{b as Ur,i as Zr,l as mt,p as ao,q as Ve}from"./embed-page-chunk-KFUAWYJ7.js";import{a as _}from"./embed-page-chunk-MB65DZAX.js";import{Cb as lo,Db as Jr,Dc as ei,Fc as ti,Gc as ar,Ha as io,Hc as sr,Ia as qe,Ja as Kr,La as _e,Ma as Hr,Sc as ni,Tb as ir,U as Ht,W as ee,Wa as Vr,Y as xn,Z as Ft,_ as ft,aa as Ut,ca as or,da as rr,eb as Qr,fa as Gr,fc as co,ia as dn,la as $r,mb as Yr,na as qr,oa as Ct,ob as Xr,ra as pe,ta as De,tb as so,va as kt,xa as nt,ya as We,yc as Zt}from"./embed-page-chunk-O4QK5LWZ.js";import{a as Te}from"./embed-page-chunk-4BKXE5ON.js";import{e as T}from"./embed-page-chunk-6Y3UYJ6Z.js";var Ws={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 En(e){return Ws[e]??{label:"capability",color:"blue"}}var _s={enabled:"green",draft:"orange",disabled:"default"};function Gi(e){return _s[e]??"default"}var ji={blue:"#3b82f6",orange:"#f59e0b",green:"#22c55e",purple:"#a855f7",cyan:"#06b6d4"};function $n(e){return ji[e]??ji.cyan}function Bd(e){let t={enabled:"#22c55e",draft:"#f59e0b",disabled:"#d9d9d9"};return t[e]??t.disabled}function Pn(e){return typeof e.graphDefinition=="object"&&e.graphDefinition!==null?e.graphDefinition:{}}function ur(e){return((Pn(e).metadata??{}).tags??"").split(",").map(r=>r.trim()).filter(Boolean)}function pr(e){let o=(Pn(e).metadata??{}).version;return o?o.startsWith("v")?o:`v${o}`:"v1"}function gr(e){let o=(Pn(e).metadata??{}).status??"enabled";return o==="draft"||o==="disabled"?o:"enabled"}function cr(e){let n=Pn(e).subAgents??[],o=Array.isArray(n)?n.filter(Boolean):[];return Array.from(new Set(o))}function jd(e){return e.map(t=>{let n=Pn(t),o=String(n.type??"react");return{id:t.id,name:t.name,description:t.description,type:En(o).label,tags:ur(t),version:pr(t),status:gr(t),subAgents:cr(t)}})}function Gd(e){let t=new Set(e.map(r=>r.id)),n=e.map(r=>({id:r.id,label:r.name,type:En(String(Pn(r).type??"react")).label,subAgentCount:cr(r).length})),o=[];for(let r of e)for(let i of cr(r))t.has(i)&&o.push({source:r.id,target:i});return{nodes:n,edges:o}}var Re=T(Te());var ne=T(Te());var h=T(_()),{TextArea:zs}=De,{Text:xt}=_e,$i=["data","execution","workflow","assistant"],Bs={data:"Data & Knowledge",execution:"Execution & Interaction",workflow:"Workflow & Orchestration",assistant:"Assistant & Evaluation",other:"Other"},qn=(e,t)=>{if(Array.isArray(e)){let n=e.map(o=>qn(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,qn(o,n)])):e},qi=e=>{if(typeof e!="string")return qn(e??null);try{return qn(JSON.parse(e))}catch{return e}},Ki=e=>JSON.stringify(qn({...e,tools:[...e.tools].sort(),subAgents:[...e.subAgents].sort()})),js=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
- `})),Hi=(e,t)=>t?.find(n=>n.type===e),Ui=({assistant:e,allAssistants:t,visible:n,onClose:o,onSave:r,onDelete:i,embedded:s,initialSection:c="basic",onDirtyChange:l,onOverlayOpenChange:u})=>{let[g]=pe.useForm(),{token:p}=Kr.useToken(),{styles:a}=js(),{styles:d}=Oi(),{config:m}=ao(),{middlewareTypes:y,isLoading:v}=To(m.middlewareTypesEndpoint),{get:f}=Ve(),[w,C]=(0,ne.useState)(c),[A,I]=(0,ne.useState)(e),[F,z]=(0,ne.useState)(null),[S,x]=(0,ne.useState)(!0),[B,ce]=(0,ne.useState)(!1),[V,J]=(0,ne.useState)(!1),[D,j]=(0,ne.useState)(!1),[G,M]=(0,ne.useState)(!1),[ie,E]=(0,ne.useState)([]),[Y,ue]=(0,ne.useState)(""),[ye,Ie]=(0,ne.useState)(""),[me,W]=(0,ne.useState)([]),[P,oe]=(0,ne.useState)([]),[Z,L]=(0,ne.useState)(""),[K,ke]=(0,ne.useState)(!1),[N,we]=(0,ne.useState)("react"),[fe,Ee]=(0,ne.useState)([]),[Le,et]=(0,ne.useState)({name:"",description:""}),[ct,Qe]=(0,ne.useState)(""),[tt,$e]=(0,ne.useState)(null),[Be,vt]=(0,ne.useState)(!1),Pe=(0,ne.useRef)(0),It=(0,ne.useRef)(null),Nt=(0,ne.useRef)(!1),$t=(0,ne.useRef)(l),qt=(0,ne.useRef)(u);(0,ne.useEffect)(()=>{$t.current=l},[l]),(0,ne.useEffect)(()=>()=>{$t.current?.(!1)},[]),(0,ne.useEffect)(()=>{qt.current=u},[u]),(0,ne.useEffect)(()=>()=>{qt.current?.(!1)},[]);let Mt=(0,ne.useMemo)(()=>Ki({form:Le,agentType:N,tools:me,subAgents:P,prompt:Z,middleware:fe,graphDefinition:qi(A?.graphDefinition)}),[Le,N,me,P,Z,fe,A?.graphDefinition]),St=Be&&Mt!==ct,on=Be;Nt.current=St;let ut=(0,ne.useMemo)(()=>{if(!e?.graphDefinition)return null;try{let b=typeof e.graphDefinition=="string"?JSON.parse(e.graphDefinition):e.graphDefinition;return{tools:b.tools||[],prompt:b.prompt||"",subAgents:b.subAgents||[],type:b.type||"react",middleware:b.middleware||[]}}catch{return null}},[e]),rn=(0,ne.useCallback)(b=>(b||[]).filter($=>$.schema?.properties&&Object.keys($.schema.properties).length>0||$.tools&&$.tools.length>0).map(($,be)=>({id:`${$.type}-${be+1}`,type:$.type,name:$.name,description:$.description,enabled:!1,config:{}})),[]),H=(0,ne.useCallback)((b,re)=>{let $=(re||[]).filter(O=>O.schema?.properties&&Object.keys(O.schema.properties).length>0||O.tools&&O.tools.length>0),be=new Map(b?.map(O=>[O.type,O])||[]),k=$.map((O,Ne)=>{let Ye=be.get(O.type);return Ye?{...Ye,name:O.name,description:O.description}:{id:`${O.type}-${Ne+1}`,type:O.type,name:O.name,description:O.description,enabled:!1,config:{}}}),R=new Set($.map(O=>O.type));return[...k,...(b??[]).filter(O=>!R.has(O.type))]},[]),Se=(0,ne.useCallback)(async()=>{if(n){ce(!0);try{let b=await f("/api/tools");b.success&&b.data?.records&&E(b.data.records)}catch(b){console.error("Failed to fetch tools:",b)}finally{ce(!1)}}},[f,n]);(0,ne.useEffect)(()=>{if(!n||!e){It.current=null,Pe.current+=1,vt(!1),I(e),$e(null);return}if(It.current===e||It.current?.id===e.id&&Nt.current)return;let b=m.availableMiddlewareTypes;if(!(!b&&v)){It.current=e,Pe.current+=1;{Se();let re={name:e.name??"",description:e.description??""},$=ut?.tools??[],be=ut?.subAgents??[],k=ut?.prompt??"",R=ut?.type??"react",O=ut?H(ut.middleware,b||y):rn(b||y);vt(!1),I(e),et(re),W($),oe(be),L(k),we(R),Ee(O),g.setFieldsValue({...re,type:R}),$e(Ki({form:re,agentType:R,tools:$,subAgents:be,prompt:k,middleware:O,graphDefinition:qi(e.graphDefinition)}))}}},[n,e,St,ut,g,Se,rn,H,m.availableMiddlewareTypes,v,y]),(0,ne.useEffect)(()=>{tt!==null&&Mt===tt&&(Qe(tt),$e(null),vt(!0))},[Mt,tt]),(0,ne.useEffect)(()=>{l?.(St)},[St,l]),(0,ne.useEffect)(()=>{qt.current?.(K||G)},[K,G]);let Fe=async()=>{if(!A||!on)return;let b=Pe.current,re=Mt;try{J(!0);let be={...await g.validateFields(),type:N,tools:me,subAgents:P,prompt:Z,middleware:fe};await r?.(A,be),Pe.current===b&&Qe(re)}catch($){$ instanceof Error&&nt.error($.message)}finally{J(!1)}},it=async()=>{if(e){j(!0);try{await i?.(e),M(!1),o()}catch(b){M(!1),nt.error(b instanceof Error?b.message:"Failed to delete assistant")}finally{j(!1)}}},an=b=>{Ee(re=>re.map($=>{if($.id!==b)return $;if($.enabled)return{...$,enabled:!1};{let be=(m.availableMiddlewareTypes||y)?.find(k=>k.type===$.type);return{...$,enabled:!0,config:be?.defaultConfig||{}}}}))},to=(b,re)=>{Ee($=>$.map(be=>be.id===b?{...be,config:{...be.config,...re}}:be))},Wn=(b,re)=>{Ee($=>$.map(be=>be.id===b?{...be,allowedTools:re}:be))},Ot=b=>{let re=me.includes(b.id);return(0,h.jsx)(fo,{item:b,className:re?a.selectedCard:void 0,onClick:()=>W($=>$.includes(b.id)?$.filter(be=>be!==b.id):[...$,b.id]),renderIcon:()=>(0,h.jsx)("span",{style:{fontSize:18,fontWeight:600},children:b.name.charAt(0).toUpperCase()}),renderPrimary:()=>(0,h.jsxs)(Ct,{size:6,children:[(0,h.jsx)("span",{children:b.name}),b.needUserApprove&&(0,h.jsx)(qe,{color:"warning",style:{fontSize:10,padding:"0 4px",margin:0},children:"Approve"})]}),renderDetails:()=>(0,h.jsx)(Fi,{text:b.description,className:a.toolDesc}),renderHeaderActions:()=>(0,h.jsx)(dn,{checked:re,onClick:$=>$.stopPropagation(),onChange:()=>W($=>$.includes(b.id)?$.filter(be=>be!==b.id):[...$,b.id])})},b.id)},bn=b=>{let re=P.includes(b.id);return(0,h.jsx)(fo,{item:b,className:re?a.selectedCard:void 0,onClick:()=>oe($=>$.includes(b.id)?$.filter(be=>be!==b.id):[...$,b.id]),renderIcon:()=>(0,h.jsx)(or,{size:36,style:{backgroundColor:re?p.colorPrimary:p.colorSuccess,fontSize:15},children:b.name?.charAt(0).toUpperCase()||"A"}),renderPrimary:()=>b.name,renderSecondary:()=>b.description||"No description",renderHeaderActions:()=>(0,h.jsx)(dn,{checked:re,onClick:$=>$.stopPropagation(),onChange:()=>oe($=>$.includes(b.id)?$.filter(be=>be!==b.id):[...$,b.id])})},b.id)},_n=(0,ne.useCallback)(b=>Hi(b.type,m.availableMiddlewareTypes||y)?.category||"other",[m.availableMiddlewareTypes,y]),sn=(0,ne.useMemo)(()=>{let b=new Map;for(let re of fe){let $=_n(re),be=b.get($);be?be.push(re):b.set($,[re])}return b},[fe,_n]),no=(0,ne.useMemo)(()=>{let b=Array.from(sn.keys());return[...$i.filter(re=>sn.has(re)),...b.filter(re=>!$i.includes(re))]},[sn]),je=(0,ne.useMemo)(()=>fe.length===0?null:fe.find(b=>b.type===F)??fe.find(b=>b.enabled)??fe[0],[fe,F]);if(!n||!e)return null;let he=[{key:"basic",icon:(0,h.jsx)(sr,{}),label:"Basic Info"},{key:"prompt",icon:(0,h.jsx)(ir,{}),label:"System Prompt"},{key:"tools",icon:(0,h.jsx)(ni,{}),label:"Common Tools",badge:me.length},{key:"middleware",icon:(0,h.jsx)(Xr,{}),label:"Capabilities",badge:fe.filter(b=>b.enabled).length},{key:"subagents",icon:(0,h.jsx)(ei,{}),label:"Sub-Agents",badge:P.length}],zn=ie.filter(b=>b.name.toLowerCase().includes(Y.toLowerCase())||b.description.toLowerCase().includes(Y.toLowerCase())),pt=t.filter(b=>b.id!==e.id),vn=pt.filter(b=>(b.name||"").toLowerCase().includes(ye.toLowerCase())||(b.description||"").toLowerCase().includes(ye.toLowerCase())),ln=()=>(0,h.jsxs)("div",{style:{maxWidth:960},children:[(0,h.jsxs)("div",{className:a.pageHeader,children:[(0,h.jsx)("div",{className:a.pageIcon,children:(0,h.jsx)(sr,{})}),(0,h.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,h.jsx)("h2",{className:a.pageName,children:"Basic Info"}),(0,h.jsx)("p",{className:a.pageDesc,children:"Core identity and behavior of this agent"})]})]}),(0,h.jsxs)(pe,{form:g,layout:"vertical",autoComplete:"off",onValuesChange:(b,re)=>et({name:re.name??"",description:re.description??""}),children:[(0,h.jsx)(pe.Item,{name:"name",label:(0,h.jsx)(xt,{strong:!0,style:{fontSize:14},children:"Name"}),rules:[{required:!0,message:"Please enter agent name"}],style:{marginBottom:24},children:(0,h.jsx)(De,{placeholder:"Enter agent name\u2026"})}),(0,h.jsxs)(pe.Item,{name:"type",label:(0,h.jsx)(xt,{strong:!0,style:{fontSize:14},children:"Agent Type"}),rules:[{required:!0}],style:{marginBottom:24},children:[(0,h.jsx)($r,{value:N,onChange:b=>we(b),options:[{value:"react",label:"Executor"},{value:"deep_agent",label:"Orchestrator"},{value:"team",label:"Team"},{value:"processing",label:"Workflow"}],block:!0}),(0,h.jsx)(xt,{type:"secondary",style:{fontSize:13,marginTop:8,display:"block",lineHeight:1.6},children:N==="react"?"Executor: Executes tasks directly using tools. Best for single-step operations like search, code execution, and data retrieval.":N==="deep_agent"?"Orchestrator: Maintains a todo list to plan and delegate tasks to sub-agents. Best for structured multi-step workflows.":N==="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,h.jsx)(pe.Item,{name:"description",label:(0,h.jsx)(xt,{strong:!0,style:{fontSize:14},children:"Description"}),rules:[{required:!0,message:"Please enter agent description"}],style:{marginBottom:0},children:(0,h.jsx)(De.TextArea,{placeholder:"Enter agent description\u2026",autoSize:{minRows:3,maxRows:6}})})]})]}),oo=()=>(0,h.jsxs)("div",{style:{maxWidth:960},children:[(0,h.jsxs)("div",{className:a.pageHeader,children:[(0,h.jsx)("div",{className:a.pageIcon,children:(0,h.jsx)(ir,{})}),(0,h.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,h.jsx)("h2",{className:a.pageName,children:"System Prompt"}),(0,h.jsx)("p",{className:a.pageDesc,children:"Define the agent's behavior, capabilities, and constraints"})]}),(0,h.jsx)(ee,{icon:(0,h.jsx)(lo,{}),onClick:()=>ke(!0),children:"Expand"})]}),(0,h.jsx)(zs,{"aria-label":"System Prompt",value:Z,onChange:b=>L(b.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,h.jsx)("div",{style:{marginTop:8,display:"flex",justifyContent:"flex-end"},children:(0,h.jsxs)(xt,{type:"secondary",style:{fontSize:12},children:[Z.length," chars"]})})]}),Jo=()=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:a.sectionHeader,children:[(0,h.jsxs)("div",{children:[(0,h.jsx)("h2",{className:a.sectionTitle,children:"Common Tools"}),(0,h.jsx)("p",{className:a.sectionDesc,children:"Choose the tools this agent can call directly"})]}),(0,h.jsxs)("div",{className:a.sectionActions,children:[(0,h.jsx)(De,{allowClear:!0,prefix:(0,h.jsx)(ar,{}),placeholder:"Search tools\u2026",value:Y,onChange:b=>ue(b.target.value),className:a.searchBox}),(0,h.jsxs)(xt,{type:"secondary",style:{fontSize:13},children:["Selected ",me.length," / ",ie.length]}),(0,h.jsx)(ee,{size:"small",onClick:()=>W(me.length===ie.length?[]:ie.map(b=>b.id)),children:me.length===ie.length?"Clear":"Select All"})]})]}),B?(0,h.jsx)("div",{style:{textAlign:"center",padding:60},children:(0,h.jsx)(kt,{})}):zn.length===0?(0,h.jsx)(Ft,{description:"No tools available",style:{padding:60}}):(0,h.jsx)("div",{className:a.cardGrid,children:zn.map(Ot)})]}),er=()=>je?(0,h.jsx)(Ro,{middleware:je,middlewareType:Hi(je.type,m.availableMiddlewareTypes||y),onToggle:()=>an(je.id),onConfigChange:b=>to(je.id,b),onAllowedToolsChange:b=>Wn(je.id,b)},je.id):(0,h.jsx)(Ft,{description:"No capabilities available",style:{padding:60}}),tr=()=>(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:a.sectionHeader,children:[(0,h.jsxs)("div",{children:[(0,h.jsx)("h2",{className:a.sectionTitle,children:"Sub-Agents"}),(0,h.jsx)("p",{className:a.sectionDesc,children:"Choose sub-agents this agent can delegate to"})]}),(0,h.jsxs)("div",{className:a.sectionActions,children:[(0,h.jsx)(De,{allowClear:!0,prefix:(0,h.jsx)(ar,{}),placeholder:"Search sub-agents\u2026",value:ye,onChange:b=>Ie(b.target.value),className:a.searchBox}),(0,h.jsxs)(xt,{type:"secondary",style:{fontSize:13},children:["Selected ",P.length," / ",pt.length]}),(0,h.jsx)(ee,{size:"small",onClick:()=>oe(P.length===pt.length?[]:pt.map(b=>b.id)),children:P.length===pt.length?"Clear":"Select All"})]})]}),pt.length===0?(0,h.jsx)(Ft,{description:"No other agents available",style:{padding:60}}):vn.length===0?(0,h.jsx)(Ft,{description:"No matching results",style:{padding:60}}):(0,h.jsx)("div",{className:a.cardGrid,children:vn.map(bn)})]}),nr={basic:ln(),prompt:oo(),tools:Jo(),middleware:er(),subagents:tr()},ro=(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)("div",{className:a.modalBody,style:s?{height:"100%",width:"100%"}:void 0,children:[!s&&(0,h.jsxs)("div",{className:a.topbar,children:[(0,h.jsxs)("div",{className:a.topbarLeft,children:[(0,h.jsx)(or,{size:40,style:{backgroundColor:p.colorPrimary,fontSize:18,flexShrink:0},children:e.name?.charAt(0).toUpperCase()||"A"}),(0,h.jsxs)("div",{style:{minWidth:0},children:[(0,h.jsx)("div",{className:a.agentName,children:e.name}),(0,h.jsx)("div",{className:a.agentDesc,children:e.description})]}),(0,h.jsx)(qe,{color:"blue",style:{margin:0,fontSize:11,flexShrink:0},children:"Config Workbench"})]}),(0,h.jsxs)(Ct,{children:[i&&(0,h.jsx)(Ut,{title:"Delete Agent",children:(0,h.jsx)(ee,{"aria-label":"Delete Agent",type:"text",danger:!0,icon:(0,h.jsx)(so,{}),onClick:()=>M(!0)})}),(0,h.jsx)(ee,{type:"text",icon:(0,h.jsx)(Yr,{}),onClick:o})]})]}),(0,h.jsxs)("div",{className:a.layout,children:[(0,h.jsx)("div",{className:d.nav,role:"tablist","aria-label":"Agent configuration sections",children:he.map(b=>b.key!=="middleware"?(0,h.jsxs)("button",{type:"button",role:"tab","aria-selected":w===b.key,className:`${d.navItem} ${w===b.key?"active":""}`,onClick:()=>C(b.key),children:[(0,h.jsx)("span",{style:{fontSize:16},children:b.icon}),(0,h.jsx)("span",{children:b.label}),b.badge!==void 0&&b.badge>0&&(0,h.jsx)(rr,{count:b.badge,size:"small",className:d.navBadge,style:{backgroundColor:p.colorPrimary}})]},b.key):(0,h.jsxs)(ne.default.Fragment,{children:[(0,h.jsxs)("button",{type:"button",role:"tab","aria-selected":w==="middleware",className:`${d.navItem} ${w==="middleware"?"active":""}`,onClick:()=>x(re=>!re),children:[(0,h.jsx)("span",{style:{fontSize:16},children:b.icon}),(0,h.jsx)("span",{children:b.label}),b.badge!==void 0&&b.badge>0&&(0,h.jsx)(rr,{count:b.badge,size:"small",className:d.navBadge,style:{backgroundColor:p.colorPrimary}})]}),S&&(0,h.jsx)("div",{className:d.navSub,children:no.map(re=>(0,h.jsxs)("div",{children:[(0,h.jsx)("div",{className:d.navGroupLabel,children:Bs[re]||re}),sn.get(re)?.map($=>(0,h.jsxs)("button",{type:"button",role:"option","aria-selected":w==="middleware"&&F===$.type,className:`${d.navSubItem} ${w==="middleware"&&F===$.type?"active":""}`,onClick:()=>{z($.type),C("middleware")},children:[(0,h.jsx)("span",{className:d.navStatusDot,style:{backgroundColor:$.enabled?p.colorSuccess:p.colorBorder}}),(0,h.jsx)("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$.name})]},$.id))]},re))})]},"middleware"))}),(0,h.jsx)("div",{className:a.content,children:on?nr[w]:(0,h.jsx)("div",{style:{minHeight:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,h.jsxs)(Ct,{direction:"vertical",align:"center",children:[(0,h.jsx)(kt,{}),(0,h.jsx)(xt,{type:"secondary",children:"Loading agent configuration..."})]})})})]}),(0,h.jsxs)("div",{className:a.footer,children:[(0,h.jsx)(xt,{"data-testid":"config-footer-hint",className:a.footerHint,type:St?"warning":"secondary",children:St?"Unsaved changes":r?"Changes will be saved to this agent":"Viewing agent configuration"}),(0,h.jsxs)(Ct,{children:[(0,h.jsx)(ee,{onClick:o,children:"Close"}),r&&(0,h.jsx)(ee,{"aria-label":"Save",type:"primary",icon:(0,h.jsx)(ti,{}),loading:V,disabled:!on,onClick:Fe,children:"Save"})]})]})]}),(0,h.jsx)(We,{title:"System Prompt",open:K,onCancel:()=>ke(!1),width:800,footer:[(0,h.jsx)(ee,{onClick:()=>ke(!1),children:"Close"},"cancel"),(0,h.jsx)(ee,{type:"primary",onClick:()=>ke(!1),children:"Done"},"done")],children:(0,h.jsx)(De.TextArea,{"aria-label":"System Prompt",value:Z,onChange:b=>L(b.target.value),rows:16,style:{width:"100%",fontFamily:"monospace",fontSize:13,lineHeight:1.7,resize:"vertical",minHeight:300}})}),(0,h.jsx)(We,{title:"Delete Agent",open:G,onCancel:()=>M(!1),footer:[(0,h.jsx)(ee,{onClick:()=>M(!1),children:"Cancel"},"cancel"),(0,h.jsx)(ee,{type:"primary",danger:!0,loading:D,onClick:it,children:"Delete"},"delete")],children:(0,h.jsxs)(xt,{children:["Are you sure you want to delete ",(0,h.jsx)(xt,{strong:!0,children:e.name})," ? This action cannot be undone."]})})]});return s?(0,h.jsx)("div",{style:{width:"100%",height:"100%",overflow:"hidden"},children:ro}):(0,h.jsx)(We,{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:ro})};var Xe=T(Te());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=T(_()),{Text:Gs}=_e,$s=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:""},So=({assistantId:e,initial:t,navigationKey:n,onEvalInvalidated:o})=>{let{projects:r,loading:i,create:s}=mo(),c=Io(r,e),l=c?.id??"",u=c?.name||`eval-${e}`,g=$s(t),p=`${g.page}\0${g.suiteId}\0${g.runId}`,[a,d]=(0,Xe.useState)(g),{page:m,suiteId:y,runId:v}=a;(0,Xe.useEffect)(()=>{d(g)},[e,p,n]);let{start:f}=go(l),{workspaceId:w,projectId:C}=At(),[A,I]=(0,Xe.useState)(!1),{create:F}=Rn(l),[z,S]=(0,Xe.useState)(!1),[x,B]=(0,Xe.useState)(""),[ce,V]=(0,Xe.useState)(0),[J,D]=(0,Xe.useState)(!1),[j]=pe.useForm(),[G,M]=(0,Xe.useState)(!1),[ie,E]=(0,Xe.useState)([]),Y=mt("__GLOBAL__"),ue=(0,Xe.useRef)(o);ue.current=o;let ye=L=>({workspaceId:w||void 0,projectId:L||C||void 0}),Ie=(0,Xe.useCallback)(async()=>{let L=Y,K=L.config?.baseURL||L.baseUrl||"";try{let N=await(await fetch(`${K}/api/models`,{headers:{Authorization:`Bearer ${L.config?.apiKey||""}`}})).json();N.success&&E(N.data||[])}catch{}},[Y]),me=async L=>{M(!0);try{await s({name:`eval-${e}`,judgeModelConfig:{modelKey:L.modelKey||""},targetServerConfig:{base_url:"",api_key:"",targetAgentId:e}}),await Promise.resolve(ue.current?.()).catch(()=>{}),j.resetFields(),D(!1)}catch(K){nt.error(K instanceof Error?K.message:"Failed to create eval project")}finally{M(!1)}},W=(L,K,ke)=>{d(N=>({page:L,suiteId:K??N.suiteId,runId:ke??N.runId}))},P=async()=>{x.trim()&&(await F(l,{name:x.trim()}),V(L=>L+1),await o?.(),B(""),S(!1))},oe=async L=>{let K=await f(l,ye(L.projectId));K?.run_id&&(await Promise.resolve(o?.()).catch(()=>{}),W("run",void 0,K.run_id))},Z=(0,ge.jsx)(We,{title:"Create Eval Project",open:J,onCancel:()=>{j.resetFields(),D(!1)},footer:null,destroyOnHidden:!0,width:480,children:(0,ge.jsxs)(pe,{form:j,layout:"vertical",onFinish:me,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)(ft,{placeholder:"Select a registered model",options:ie.map(L=>{let K=L;return{value:K.key,label:`${K.displayName||K.key} (${K.model||""})`}})})}),(0,ge.jsxs)(pe.Item,{style:{marginBottom:0,textAlign:"right"},children:[(0,ge.jsx)(ee,{onClick:()=>{j.resetFields(),D(!1)},style:{marginRight:8},children:"Cancel"}),(0,ge.jsx)(ee,{type:"primary",htmlType:"submit",loading:G,children:"Create"})]})]})});return i?(0,ge.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,ge.jsx)(kt,{})}):c?(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:u}),(0,ge.jsx)(qe,{color:"purple",children:"eval"})]}),m==="suites"&&(0,ge.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,ge.jsx)(ee,{icon:(0,ge.jsx)(Zt,{}),onClick:()=>S(L=>!L),children:"New Suite"}),(0,ge.jsx)(ee,{type:"primary",icon:(0,ge.jsx)(Qr,{}),onClick:()=>I(!0),children:"Run All"})]})]}),m==="suites"&&z&&(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:L=>B(L.target.value),onKeyDown:L=>L.key==="Enter"&&void P(),autoFocus:!0,style:{width:260,padding:"6px 12px",border:"1px solid #d9d9d9",borderRadius:8,fontSize:14,outline:"none"}}),(0,ge.jsx)(ee,{type:"primary",size:"small",onClick:()=>void P(),children:"Create"}),(0,ge.jsx)(ee,{size:"small",onClick:()=>S(!1),children:"Cancel"})]}),(0,ge.jsxs)("div",{style:{flex:1,overflow:"auto",padding:28},children:[m==="suites"&&(0,ge.jsx)(Ti,{projectId:l,onSelectSuite:(L,K)=>W("suite",K),onEvalInvalidated:o},`${l}:${ce}`),m==="suite"&&y&&(0,ge.jsx)(Si,{projectId:l,suiteId:y,onBack:()=>W("suites"),onRun:L=>{Promise.resolve(o?.()).catch(()=>{}),W("run",void 0,L)},onEvalInvalidated:o}),m==="run"&&v&&(0,ge.jsx)(Ci,{runId:v,onBack:()=>W("suites"),onRunSettled:o})]}),(0,ge.jsx)(Ii,{open:A,onClose:()=>I(!1),onRun:oe})]}):(0,ge.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,background:"#fff"},children:[(0,ge.jsx)(Ft,{description:(0,ge.jsx)(Gs,{type:"secondary",children:"This agent has no eval project yet"})}),(0,ge.jsx)(ee,{type:"primary",icon:(0,ge.jsx)(Zt,{}),onClick:()=>{Ie(),D(!0)},children:"Create eval project"}),Z]})};var Me=T(Te());var Kn=T(Te());var Q=T(_()),{Text:cn}=_e,Zi={projectSelector:!1,modelSelector:!1,threadManagement:!0,attachments:!0,hitl:!0,genUI:!0,files:!1},Vi=({open:e,assistantId:t,value:n,projects:o,models:r,submitting:i,error:s,onCancel:c,onSubmit:l})=>{let[u]=pe.useForm(),[g,p]=(0,Kn.useState)(!1),[a,d]=(0,Kn.useState)(!1);(0,Kn.useEffect)(()=>{if(!e)return;let f=n?.features??Zi;p(f.projectSelector),d(f.modelSelector),u.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,...f,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})},[u,e,o,n]);let m=async()=>{let f=await u.validateFields(),w=f.projectSelector?Array.from(new Set(f.allowedProjectIds??[])):[f.defaultProjectId],C=f.modelSelector?Array.from(new Set([...f.defaultModelKey?[f.defaultModelKey]:[],...f.allowedModelKeys??[]])):f.defaultModelKey?[f.defaultModelKey]:void 0,A,I=f.identityPolicy??"unverified";if(I!=="unverified"){let S;try{S=JSON.parse(f.identityIssuers??"")}catch{throw new Error("Trusted issuers must be a valid JSON array")}if(!Array.isArray(S)||S.length===0)throw new Error("Verified identity requires at least one trusted issuer");A={policy:I,issuers:S}}let F=(f.quickPrompts??[]).map(S=>({label:(S?.label??"").trim(),text:(S?.text??"").trim()})).filter(S=>S.label.length>0&&S.text.length>0),z={name:f.name.trim(),description:f.description?.trim()||void 0,scope:{defaultProjectId:f.defaultProjectId,allowedProjectIds:w,defaultModelKey:f.defaultModelKey||void 0,allowedModelKeys:C},features:{projectSelector:f.projectSelector,modelSelector:f.modelSelector,threadManagement:f.threadManagement,attachments:f.attachments,hitl:f.hitl,genUI:f.genUI,files:f.files??!1},appearance:{title:f.title?.trim()||void 0,welcomeMessage:f.welcomeMessage?.trim()||void 0,primaryColor:f.primaryColor?.trim()||void 0,...F.length>0?{quickPrompts:F}:{}},identity:A};await l(n?z:{...z,assistantId:t,integration:{type:"react_sdk"}})},y=o.map(f=>({value:f.id,label:f.name})),v=r.map(f=>({value:f.key,label:f.displayName??f.model??f.key}));return(0,Q.jsxs)(We,{title:n?"Edit Web App":"Create Web App",open:e,onCancel:c,onOk:()=>void m().catch(()=>{}),okText:n?"Save":"Create",confirmLoading:i,width:720,destroyOnHidden:!0,children:[s&&(0,Q.jsx)("div",{role:"alert",style:{color:"#ef4444",marginBottom:12},children:s}),(0,Q.jsxs)(pe,{form:u,layout:"vertical",initialValues:Zi,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)(cn,{strong:!0,children:"Project scope"}),(0,Q.jsx)(pe.Item,{name:"projectSelector",valuePropName:"checked",children:(0,Q.jsx)(dn,{"aria-label":"Project selector",onChange:f=>p(f.target.checked),children:"Project selector"})}),(0,Q.jsx)(pe.Item,{name:"allowedProjectIds",label:"Allowed projects",dependencies:["defaultProjectId","projectSelector"],rules:g?[{required:!0,message:"Select at least one project"},{validator:(f,w)=>(w??[]).every(C=>y.some(A=>A.value===C))?Promise.resolve():Promise.reject(new Error("Select valid allowed projects"))},{validator:(f,w)=>(w??[]).includes(u.getFieldValue("defaultProjectId"))?Promise.resolve():Promise.reject(new Error("Default project must be in allowed projects"))}]:void 0,children:(0,Q.jsx)(ft,{"aria-label":"Allowed projects",mode:"multiple",disabled:!g,options:y})}),(0,Q.jsx)(pe.Item,{name:"defaultProjectId",label:"Default project",rules:[{required:!0},{validator:(f,w)=>!w||y.some(C=>C.value===w)?Promise.resolve():Promise.reject(new Error("Select a valid default project"))}],children:(0,Q.jsx)(ft,{"aria-label":"Default project",options:y})}),(0,Q.jsx)(cn,{strong:!0,children:"Model scope (optional)"}),(0,Q.jsx)(pe.Item,{name:"modelSelector",valuePropName:"checked",children:(0,Q.jsx)(dn,{"aria-label":"Model selector",onChange:f=>d(f.target.checked),children:"Model selector"})}),(0,Q.jsx)(pe.Item,{name:"allowedModelKeys",label:"Allowed models",dependencies:["defaultModelKey","modelSelector"],rules:a?[{validator:(f,w)=>w?.length||u.getFieldValue("defaultModelKey")?Promise.resolve():Promise.reject(new Error("Select at least one model"))},{validator:(f,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)(ft,{"aria-label":"Allowed models",mode:"multiple",allowClear:!0,disabled:!a,options:v})}),(0,Q.jsx)(pe.Item,{name:"defaultModelKey",label:"Default model",rules:[{validator:(f,w)=>!w||v.some(C=>C.value===w)?Promise.resolve():Promise.reject(new Error("Select a valid default model"))}],children:(0,Q.jsx)(ft,{"aria-label":"Default model",allowClear:!0,options:v})}),(0,Q.jsx)(cn,{strong:!0,children:"Features"}),(0,Q.jsx)(Ct,{wrap:!0,children:["threadManagement","attachments","hitl","genUI","files"].map(f=>(0,Q.jsx)(pe.Item,{name:f,valuePropName:"checked",noStyle:!0,children:(0,Q.jsx)(dn,{"aria-label":f,children:f})},f))}),(0,Q.jsx)("div",{style:{marginTop:20},children:(0,Q.jsx)(cn,{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:/^#[0-9A-Fa-f]{6}$/,message:"Use a #RRGGBB color",transform:f=>f||void 0}],children:(0,Q.jsx)(De,{"aria-label":"Primary color",placeholder:"#6366f1"})}),(0,Q.jsx)("div",{style:{marginTop:12},children:(0,Q.jsx)(cn,{strong:!0,children:"Quick prompts"})}),(0,Q.jsx)(pe.List,{name:"quickPrompts",children:(f,{add:w,remove:C})=>(0,Q.jsxs)(Q.Fragment,{children:[f.map(A=>(0,Q.jsxs)(Ct,{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)(ee,{"aria-label":`Remove quick prompt ${A.name+1}`,onClick:()=>C(A.name),children:"Remove"})]},A.key)),(0,Q.jsx)(ee,{"aria-label":"Add quick prompt",onClick:()=>w({label:"",text:""}),disabled:f.length>=6,children:"Add quick prompt"})]})}),(0,Q.jsx)("div",{style:{marginTop:20},children:(0,Q.jsx)(cn,{strong:!0,children:"Identity"})}),(0,Q.jsx)(pe.Item,{name:"identityPolicy",label:"Identity policy",initialValue:"unverified",children:(0,Q.jsx)(ft,{"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:(f,w)=>{if(u.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)(cn,{type:"secondary",children:"Integration type: react_sdk"})]})]})};var ae=T(_()),{Text:Co}=_e,Hn=e=>e instanceof Error?e.message:"Request failed";function qs(e,t){let n=typeof sessionStorage>"u"?null:sessionStorage.getItem("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 Un=(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},Ks=[{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."}],Hs=[{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."}],Us=[{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"}],Qi=({assistant:e})=>{let t=mt("__GLOBAL__"),{user:n,currentTenant:o,baseURL:r}=Zr(),{projects:i}=At(),[s,c]=(0,Me.useState)([]),[l,u]=(0,Me.useState)([]),[g,p]=(0,Me.useState)(!1),[a,d]=(0,Me.useState)(null),[m,y]=(0,Me.useState)(null),[v,f]=(0,Me.useState)(null),[w,C]=(0,Me.useState)(!1),[A,I]=(0,Me.useState)(null),[F,z]=(0,Me.useState)(!1),[S,x]=(0,Me.useState)(!1),[B,ce]=(0,Me.useState)(null),[V,J]=(0,Me.useState)(null),D=(0,Me.useRef)(0),j=(0,Me.useRef)(0),G=(0,Me.useRef)(0),M=(0,Me.useRef)(!1),ie=Array.from(new Map(i.map(W=>[W.id,W])).values()),E=(0,Me.useCallback)(async()=>{let W=++D.current;p(!0),d(null);try{let P=await t.webApps.list({assistantId:e.id});W===D.current&&c(P.records)}catch(P){W===D.current&&d(Hn(P))}finally{W===D.current&&p(!1)}},[e.id,t,o?.id]);(0,Me.useEffect)(()=>(c([]),y(null),I(null),ce(null),J(null),C(!1),z(!1),x(!1),M.current=!1,G.current+=1,E(),()=>{D.current+=1,G.current+=1}),[E]),(0,Me.useEffect)(()=>{let W=++j.current;return t.request("/api/models").then(P=>{W===j.current&&u(P.data??[])}).catch(()=>{W===j.current&&u([])}),()=>{j.current+=1}},[t]);let Y=async W=>{if(M.current)return;M.current=!0,x(!0);let P=++G.current;d(null);try{await W(),P===G.current&&await E()}catch(oe){P===G.current&&d(Hn(oe))}finally{P===G.current&&(M.current=!1,x(!1))}},ue=async W=>{if(M.current)return;M.current=!0,x(!0);let P=++G.current;C(!0),f(null);try{m==="create"?await t.webApps.create(W):m&&await t.webApps.update(m.id,W),P===G.current&&(y(null),await E())}catch(oe){P===G.current&&f(Hn(oe))}finally{P===G.current&&(M.current=!1,x(!1),C(!1))}},ye=async W=>{d(null);try{if(!navigator.clipboard)throw new Error("Clipboard unavailable");await navigator.clipboard.writeText(W)}catch(P){d(Hn(P))}},Ie=W=>[{key:"edit",icon:fi,label:"Edit",disabled:S,onClick:y},{key:"toggle",icon:W.status==="active"?oi:ii,label:W.status==="active"?"Disable":"Enable",disabled:S,onClick:P=>void Y(()=>P.status==="active"?t.webApps.disable(P.id):t.webApps.enable(P.id))},{key:"preview",icon:ci,label:"Preview",disabled:S,onClick:ce},{key:"guide",icon:si,label:"Integration guide",disabled:S,onClick:J},{key:"copy",icon:ai,label:"Copy Web App ID",disabled:S,onClick:P=>void ye(P.id)},{key:"delete",icon:bi,label:"Delete",danger:!0,disabled:S,onClick:I}],me=async()=>{if(!A||M.current)return;M.current=!0,x(!0);let W=++G.current;z(!0);try{await t.webApps.delete(A.id),W===G.current&&(I(null),await E())}catch(P){W===G.current&&d(Hn(P))}finally{W===G.current&&(M.current=!1,x(!1),z(!1))}};return(0,ae.jsxs)("div",{style:{height:"100%",overflow:"auto",padding:16},children:[(0,ae.jsx)(Ht,{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}}),a&&(0,ae.jsx)(Ht,{role:"alert",type:"error",message:a,action:(0,ae.jsx)(ee,{size:"small",onClick:()=>void E(),children:"Retry"}),style:{marginBottom:16}}),(0,ae.jsx)(Ri,{title:"Web Apps",itemName:"app",items:s,loading:g,keyExtractor:W=>W.id,createLabel:S?void 0:"Create Web App",onCreateClick:S?void 0:()=>{f(null),y("create")},renderIcon:()=>(0,ae.jsx)(di,{size:22,color:"#6366f1"}),renderPrimary:W=>W.name,renderSecondary:W=>W.description??W.id,renderHeaderActions:W=>(0,ae.jsx)(qe,{color:W.status==="active"?"green":W.status==="disabled"?"default":"gold",children:W.status}),renderDetails:W=>(0,ae.jsxs)(Co,{type:"secondary",children:[W.scope.allowedProjectIds.length," project",W.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,ae.jsx)(Vi,{open:m!==null,assistantId:e.id,value:m==="create"?null:m,projects:ie,models:l,submitting:w,error:v,onCancel:()=>y(null),onSubmit:ue}),(0,ae.jsx)(We,{title:"Delete Web App",open:A!==null,onCancel:()=>I(null),onOk:()=>void me(),okText:"Delete",okButtonProps:{danger:!0,loading:F},children:(0,ae.jsxs)("p",{children:["Delete \u201C",A?.name,"\u201D? This action cannot be undone."]})}),(0,ae.jsx)(We,{title:"Preview",open:B!==null,onCancel:()=>ce(null),footer:(0,ae.jsx)(ee,{onClick:()=>ce(null),children:"Close"}),width:900,children:r?B&&B.status==="active"?(0,ae.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,ae.jsxs)("div",{children:[(0,ae.jsx)(Ht,{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,ae.jsx)(Bi,{gatewayUrl:r,webAppId:B.id,identity:{mode:"unverified",userId:`console-preview:${n?.id??"unknown"}:${B.id}`,displayName:n?.name},fetch:qs})]}):null:(0,ae.jsx)(Ht,{type:"warning",message:"Gateway URL unavailable"})}),(0,ae.jsx)(We,{title:"Integration guide",open:V!==null,onCancel:()=>J(null),footer:(0,ae.jsxs)(Ct,{children:[(0,ae.jsx)(ee,{onClick:()=>V&&void ye(Object.values(Un(V,r)).join(`
230
-
231
- `)),children:"Copy examples"}),(0,ae.jsx)(ee,{type:"primary",onClick:()=>J(null),children:"Close"})]}),width:900,children:V&&(0,ae.jsx)(Gr,{defaultActiveKey:"zero-code",items:[{key:"zero-code",label:"Zero-code script loader",children:(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsx)(_e.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,ae.jsx)("pre",{style:Ao,children:Un(V,r).embed}),(0,ae.jsx)(_e.Title,{level:5,style:{marginTop:24},children:"Configuration \u2014 window.AxiomChatSettings"}),(0,ae.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:Ks}),(0,ae.jsx)(_e.Title,{level:5,children:"JS API \u2014 window.AxiomChat"}),(0,ae.jsxs)(_e.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,ae.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:Hs}),(0,ae.jsx)(_e.Title,{level:5,children:"Events"}),(0,ae.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:Us}),(0,ae.jsx)(Ht,{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,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsx)(_e.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,ae.jsx)(Co,{strong:!0,children:"Full chat \u2014 AgentChatApp"}),(0,ae.jsx)("pre",{style:Ao,children:Un(V,r).agentChat}),(0,ae.jsx)(Co,{strong:!0,children:"Composable widgets"}),(0,ae.jsx)("pre",{style:Ao,children:Un(V,r).composable}),(0,ae.jsx)(Co,{strong:!0,children:"Hooks"}),(0,ae.jsx)("pre",{style:Ao,children:Un(V,r).hooks})]})}]})})]})};var q=T(Te());var Zs={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 Eo(e){let t=Zs[e];return e==="agent"?"agent":t.color}function Vs(e){return typeof e=="object"&&e!==null?e:{}}var fr=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[];function Yi(e,t){let n=Vs(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||""}},s=(d,m,y,v,f)=>({id:m,type:d,label:y,description:v,config:f}),c=fr(n.tools).map(d=>s("tool",`tool:${d}`,d)),l=(Array.isArray(n.middleware)?n.middleware:[]).filter(d=>d.enabled!==!1).map(d=>{let m=typeof d.type=="string"?d.type:"unknown";return s("capability",`cap:${m}`,d.name||m,d.description||void 0,d)}),u=fr(n.subAgents).map(d=>s("subagent",`sub:${d}`,d)),g=fr(n.skills).map(d=>s("skill",`skill:${d}`,d)),p=[{id:"group:tools",type:"tool",label:"Tools",items:c},{id:"group:capabilities",type:"capability",label:"Capabilities",items:l},{id:"group:subagents",type:"subagent",label:"Sub-Agents",items:u},{id:"group:skills",type:"skill",label:"Skills",items:g}],a=t?.includeEmptyGroups?p:p.filter(d=>d.items.length>0);return{agent:i,groups:a}}var Xi=T(_()),Zn=({id:e,position:t,type:n="source"})=>(0,Xi.jsx)(wt,{id:e,type:n,position:t,style:{opacity:0,width:0,height:0,border:"none"},isConnectable:!1});var Vt=T(_()),Po={agent:(0,Vt.jsx)(Gn,{size:14}),tool:(0,Vt.jsx)(vi,{size:12}),capability:(0,Vt.jsx)(ri,{size:12}),subagent:(0,Vt.jsx)(Gn,{size:12}),skill:(0,Vt.jsx)(ui,{size:12}),model:(0,Vt.jsx)(li,{size:12}),eval:(0,Vt.jsx)(uo,{size:12})},Ji={agent:"Agent",tool:"Tool",capability:"Capability",subagent:"Sub-Agent",skill:"Skill",model:"Model",eval:"Eval Suite"};var xe=T(_()),ea=({type:e="source"})=>(0,xe.jsxs)(xe.Fragment,{children:[(0,xe.jsx)(Zn,{id:"top",position:ot.Top,type:e}),(0,xe.jsx)(Zn,{id:"bottom",position:ot.Bottom,type:e}),(0,xe.jsx)(Zn,{id:"left",position:ot.Left,type:e}),(0,xe.jsx)(Zn,{id:"right",position:ot.Right,type:e})]}),ta=({data:e})=>{let{node:t,onClick:n}=e,o=$n(En(String(t.config?.type??"react")).color),r=t.config??{};return(0,xe.jsxs)("div",{onClick:n,style:{width:220,background:"#fff",border:`2px solid ${o}`,borderRadius:14,padding:"10px 12px",cursor:"pointer",fontFamily:"inherit"},children:[(0,xe.jsx)(ea,{type:"source"}),(0,xe.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[Po.agent,(0,xe.jsx)("span",{style:{fontSize:13,fontWeight:700,color:"#333",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.label})]}),r.description&&(0,xe.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,xe.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:6},children:[(0,xe.jsx)(qe,{bordered:!1,style:{margin:0,fontSize:10,background:`${o}1A`,color:o},children:r.type??"capability"}),r.modelKey&&(0,xe.jsx)(qe,{bordered:!1,style:{margin:0,fontSize:10},children:r.modelKey}),r.version&&(0,xe.jsxs)(qe,{bordered:!1,style:{margin:0,fontSize:10},children:["v",r.version]})]}),r.prompt&&(0,xe.jsx)("div",{style:{fontSize:10,color:"#999",background:"#fafafa",borderRadius:6,padding:"4px 8px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.prompt})]})},na=({data:e})=>{let{group:t,onClick:n,onRemove:o}=e,r=Eo(t.type);return(0,xe.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,xe.jsx)(ea,{type:"target"}),(0,xe.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:8},children:[Po[t.type],(0,xe.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"#666"},children:t.label}),(0,xe.jsxs)("span",{style:{fontSize:10,color:"#bbb"},children:["(",t.items.length,")"]})]}),t.items.length===0?(0,xe.jsx)("div",{style:{fontSize:10,color:"#bbb",padding:"2px 0"},children:"empty"}):(0,xe.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:t.items.map(i=>(0,xe.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,xe.jsxs)("div",{onClick:s=>{s.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:[Po[i.type],(0,xe.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:i.label})]}),o&&(0,xe.jsx)("button",{onClick:s=>{s.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 zt=T(Te());function Wt(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 oa(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 ra(e,t=1){let n=Number.isFinite(t)?Math.abs(t):1,o=e.filter(m=>Number.isFinite(m.avgScore)&&Number.isFinite(new Date(m.createdAt).getTime())).sort(Wt),r=o.filter(m=>m.status==="completed"&&!m.holdout),i=r[r.length-1],s=i?.envProjectId!==void 0,l=(s?r.filter(m=>m.envProjectId===i.envProjectId):r).map(oa),u=o.filter(m=>m.status==="completed"&&m.holdout).map(oa),g=l[l.length-1],p=l[l.length-2],a=g&&p?g.score-p.score:null,d="needs-evidence";return a!==null&&(d=a>n?"improving":a<-n?"regressed":"stable"),{verdict:d,latest:g,previous:p,delta:a,passRate:g?.passRate??null,comparisonLabel:s?"Latest comparable result":"Latest recorded result",trend:l,validationTrend:u,runningRuns:o.filter(m=>m.status==="running"),failedRuns:o.filter(m=>m.status==="failed"||m.status==="aborted")}}var _t=T(Te()),ia=T(_()),un=({option:e,height:t=200,onEvents:n})=>{let o=(0,_t.useRef)(null),r=(0,_t.useRef)(null),i=(0,_t.useRef)(e),s=(0,_t.useRef)(n);return(0,_t.useEffect)(()=>{i.current=e,r.current?.setOption(e,!0)},[e]),(0,_t.useEffect)(()=>{s.current=n;let c=r.current;if(!c||!n)return;let l=Object.entries(n);for(let[u,g]of l)c.on(u,g);return()=>{for(let[u,g]of l)c.off(u,g)}},[n]),(0,_t.useEffect)(()=>{let c=!1,l=null;return(async()=>{let u=await import("./embed-page-echarts-7KZDMH4F.js");if(c||!o.current)return;let g=u.init(o.current);r.current=g,g.setOption(i.current,!0);let p=s.current;if(p)for(let[a,d]of Object.entries(p))g.on(a,d);l=new ResizeObserver(()=>r.current?.resize()),l.observe(o.current)})().catch(u=>{console.error("[EChart] async init failed:",u)}),()=>{c=!0,l?.disconnect(),r.current?.dispose(),r.current=null}},[]),(0,ia.jsx)("div",{ref:o,style:{width:"100%",height:t}})};var ua=T(_()),aa={total:0,last7d:0,last30d:0,lastActive:null,daily7d:[],daily30d:[],loading:!0,error:null},mr=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),sa=(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},Qs=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),la=e=>{let t=Qs(e);return Math.floor(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())/864e5)},Ys=(e,t)=>la(e)-la(t);function da(e){let{get:t}=Ve(),[n,o]=zt.default.useState(aa),r=zt.default.useRef(0),i=zt.default.useRef(e);return i.current=e,zt.default.useEffect(()=>{let s=++r.current,c=!0,l=()=>c&&r.current===s&&i.current===e;return o(u=>({...u,loading:!0,error:null})),(async()=>{try{let u=await t(`/api/assistants/${e}/threads`);if(!mr(u)||u.success!==!0||!mr(u.data))throw new Error("Invalid thread list response");let{records:g,total:p}=u.data;if(!Array.isArray(g)||typeof p!="number"||!Number.isSafeInteger(p)||p<0)throw new Error("Invalid thread list response");let a=Date.now(),d=new Date(a),m=null,y=0,v=0,f=new Array(7).fill(0),w=new Array(30).fill(0);for(let C of g){if(!mr(C))continue;let A=sa(C.createdAt,a);if(A!==null){let F=Ys(d,new Date(A));F>=0&&F<7&&(y++,f[6-F]++),F>=0&&F<30&&(v++,w[29-F]++)}let I=sa(C.updatedAt,a);I!==null&&(m===null||I>m)&&(m=I)}if(!l())return;o({total:p,last7d:y,last30d:v,lastActive:m===null?null:new Date(m),daily7d:f,daily30d:w,loading:!1,error:null})}catch(u){if(!l())return;o({...aa,loading:!1,error:u instanceof Error?u:new Error("Failed to load thread activity")})}})(),()=>{c=!1,r.current===s&&r.current++}},[t,e]),n}function Do(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 Lo(e){let{projects:t,loading:n,error:o,refresh:r}=mo(),i=Io(t,e),s=i?.id??"",{suites:c,loading:l,error:u,refresh:g}=Rn(s),{runs:p,inventoryProjectId:a,loading:d,error:m,refresh:y}=go(s),v=(0,zt.useCallback)(async()=>{await Promise.all([r(),g(),y()])},[r,g,y]);return{...(0,zt.useMemo)(()=>{let w=c.reduce((z,S)=>z+(S.caseCount??0),0),C=a===s?p.filter(z=>z.projectId===s):[],A=[...C].sort(Wt),I=ra(C),F=I.latest?C.find(z=>z.id===I.latest?.runId):void 0;return{evalProjectId:i?.id,inventoryProjectId:a,suiteCount:c.length,caseCount:w,scores:I.trend.map(z=>z.score),latest:F,runs:A,runCount:C.length,passRate:I.passRate,score:I.latest?.score??null,hasEvalProject:!!i,suiteNames:c.map(z=>z.name??"Unnamed").filter(Boolean),error:o??u??m,loading:!!(n||s&&(a!==s||l||d))}},[c,p,a,i,s,n,l,d,o,u,m]),refresh:v,refreshRuns:y}}var Xs=(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},Js=e=>Xs(e).map(t=>t.slice(5)),el="#6366f1";var tl={left:8,right:8,top:24,bottom:24,containLabel:!0};function ca(e){return{grid:tl,tooltip:{trigger:"axis"},xAxis:{type:"category",data:Js(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:el,borderRadius:[2,2,0,0]},barMaxWidth:10}]}}var Qn=T(Te());var pn=T(_()),pa=({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),s=t/e.length,c=s>4?1:0,l=2;return(0,pn.jsx)("svg",{width:t,height:n,style:{display:"block"},children:e.map((u,g)=>{let p=Math.max(u/i*n,l);return(0,pn.jsx)("rect",{x:g*s,y:n-p,width:Math.max(s-c,1),height:p,fill:u===0?r:o,rx:1},g)})})},ga=({values:e,width:t=200,height:n=40,color:o="#6366f1"})=>{if(e.length===0)return null;let r=Math.min(...e),s=Math.max(...e)-r||1,c=2,l=t-c*2,u=a=>e.length===1?t/2:c+a/(e.length-1)*l,g=a=>n-2-(a-r)/s*(n-4),p=e.map((a,d)=>`${u(d)},${g(a)}`).join(" ");return(0,pn.jsxs)("svg",{width:t,height:n,style:{display:"block"},children:[(0,pn.jsx)("polyline",{points:p,fill:"none",stroke:o,strokeWidth:"1.5",strokeLinecap:"round"}),e.map((a,d)=>(0,pn.jsx)("circle",{cx:u(d),cy:g(a),r:"2.5",fill:o},d))]})};var ze=T(Te());var Yt=T(Te());var No=T(Te());var Qt=T(_()),fa=({projectId:e,value:t,onChange:n})=>{let{uploadFileToProject:o}=At(),[r,i]=(0,No.useState)([]),s=(0,No.useRef)(e);s.current=e;let c=t.map(p=>({uid:p.uri,name:p.name||p.uri,status:"done",response:{uri:p.uri,name:p.name}})),l=async p=>{let a=p.file;try{let d=await o(e,"/project/uploads",a);p.onSuccess?.({uri:d.path,name:a.name,projectId:e})}catch(d){p.onError?.(d instanceof Error?d:new Error("Upload failed"))}},u=p=>{let{file:a}=p;if(a.status==="done"&&a.response?.uri){if(a.response.projectId&&a.response.projectId!==s.current){i(p.fileList.filter(m=>m.status==="uploading"||m.status==="error"));return}let d={uri:a.response.uri,name:a.response.name||a.name,addedBy:"user"};t.some(m=>m.uri===d.uri)||n([...t,d])}a.status==="error"&&nt.error(`Failed to upload "${a.name}"`),i(p.fileList.filter(d=>d.status==="uploading"||d.status==="error"))},g=p=>{if(p.status==="done"){let a=p.response?.uri;n(t.filter(d=>d.uri!==a&&d.name!==p.name))}else i(a=>a.filter(d=>d.uid!==p.uid))};return(0,Qt.jsx)("div",{"data-testid":"reference-files-field",children:(0,Qt.jsxs)(Hr.Dragger,{multiple:!0,fileList:[...c,...r],customRequest:l,onChange:u,onRemove:g,style:{padding:"8px 0"},children:[(0,Qt.jsx)("p",{className:"ant-upload-drag-icon",style:{marginBottom:4},children:(0,Qt.jsx)(pi,{size:24,style:{color:"#6366f1"}})}),(0,Qt.jsx)("p",{className:"ant-upload-text",style:{fontSize:13},children:"Click or drag files to this area to upload"}),(0,Qt.jsx)("p",{className:"ant-upload-hint",style:{fontSize:12},children:"Files are stored in the selected project under /project/uploads"})]},e)})};function Dn(e){return(e.metadata??{}).trainingRound===!0}function xu(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 Mo(e){return["pending","in_progress","review"].includes(e.status)}function Ln(e,t){return`/api/tasks?${`ownerId=agent-architect&metadata=${encodeURIComponent(JSON.stringify({trainingRound:"true",targetAgentId:e}))}`}${t?`&projectId=${t}`:""}`}function nl(e,t){return`/api/tasks?${`ownerId=agent-architect&parentId=${e}`}${t?`&projectId=${t}`:""}`}function ma(e,t){return`${e}:${t}`}async function ya(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,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 ha(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 ba(e){let t=e.targetMode==="placeholder"?"This is a marked learning placeholder and its architecture is undecided. Select and explicitly approve its initial architecture, then materialize this exact ID through agent-build or design-workflow.":e.targetMode==="existing-workflow"?"This is an existing Workflow. Keep its architecture and use the design-workflow procedure skill for exact-ID update_workflow followed by validate_workflow.":"This is an existing Capability or Orchestra. Keep its architecture and use the agent-build procedure skill for a same-form exact-ID update_agent.";return[`Learning goal: ${e.goal}`,`Exact target ID: "${e.targetAgentId}".`,`Exact round Task ID: "${e.roundTaskId}".`,t,"Load [[agent-architecture]] and the routed procedure skill.",`Reconcile the round task itself first: one manage_task update on task "${e.roundTaskId}" that writes the confirmed Objective / Acceptance Criteria / Belief State into its description before creating any child. Keep reconciling this same task as evidence arrives. Never create a parallel replacement main task. For status transitions always use manage_task set_status, never update with a status field.`,"The round task's Acceptance Criteria MUST include the eval quality bar as decidable criteria \u2014 all development eval cases pass, and hold-out pass rate \u2265 80% baseline per [[eval-verify]] / [[completion-gate]]. The round task is completed only when these criteria are met by evidence; a low eval score means keep iterating the FEP loop, never mark complete.",`Create your work as children of the round task with parentId: "${e.roundTaskId}" and ownerType: "agent".`,`Pass taskId: "${e.roundTaskId}" to every Eval run for this round.`,...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 ol=5;async function va(e,t,n){let o=n?.projectId,r=o?{headers:{"x-project-id":o}}:void 0,i=p=>nl(p,o??void 0),s=[],c=!1,l=new Set,u=new Set([t]),g=[t];for(let p=0;p<ol&&g.length>0;p++){let d=(await Promise.all(g.map(m=>e(i(m),r).then(y=>Array.isArray(y.data)?y.data.map(v=>v.parentId?v:{...v,parentId:m}):[]).catch(()=>(c=!0,l.add(m),[]))))).flat().filter(m=>u.has(m.id)?!1:(u.add(m.id),!0));s.push(...d),g=d.map(m=>m.id)}if(g.length>0){c=!0;for(let p of g)l.add(p)}return{tasks:s,partial:c,...l.size>0?{incompleteParentIds:[...l]}:{}}}var He=T(_()),Oo=({open:e,agentId:t,defaultProjectId:n,onClose:o,onCreated:r})=>{let{get:i,post:s,put:c}=Ve(),{message:l}=xn.useApp(),u=mt("agent-architect"),{trainingProjects:g,loading:p}=At(),a=g.find(z=>z.id===n)??null,[d]=pe.useForm(),[m,y]=(0,Yt.useState)(!1),[v,f]=(0,Yt.useState)(null),[w,C]=(0,Yt.useState)(null),[A,I]=(0,Yt.useState)([]);return(0,Yt.useEffect)(()=>{e&&(C(ma(u.tenantId,t)),I([]))},[e,u,t]),(0,Yt.useEffect)(()=>{if(!e)return;let z=!1;return(async()=>{try{let S=await i(Ln(t,a?.id??void 0),a?{headers:{"x-project-id":a.id}}:void 0);if(z)return;let x=(S.data??[]).filter(Dn);f(x.find(Mo)??null)}catch{}})(),()=>{z=!0}},[e,i,t,a]),(0,He.jsxs)(We,{title:"New Learning Task",open:e,onCancel:o,footer:null,width:520,destroyOnClose:!0,children:[v&&(0,He.jsx)(Ht,{type:"warning",showIcon:!0,style:{marginBottom:16},message:"A learning task is already in progress. Complete it before starting a new one."}),(0,He.jsxs)(pe,{form:d,layout:"vertical",onFinish:async z=>{if(!a){l.error("No learning project is available");return}y(!0);try{let{roundTaskId:S,threadId:x}=await ya({goal:z.goal,targetAgentId:t,workspaceId:a.workspaceId,projectId:a.id,existingThreadId:w,files:A,post:s,put:c});l.success("Learning task created. Preparing the Architect\u2026"),d.resetFields(),r(S,x,z.goal,A),I([])}catch(S){l.error(S instanceof Error?S.message:"Failed to create the learning task. Please try again.")}finally{y(!1)}},children:[(0,He.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,He.jsx)(De.TextArea,{rows:3,placeholder:"e.g. Improve the agent's accuracy when handling price disputes based on the price protection policy"})}),a&&(0,He.jsx)(pe.Item,{label:(0,He.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,He.jsx)("span",{children:"Reference Materials"}),(0,He.jsx)(dr,{project:a,selectable:!1,loading:p})]}),extra:"Optional. These materials will be used as reference for this learning round.",style:{marginBottom:16},colon:!1,children:(0,He.jsx)(fa,{projectId:a.id,value:A,onChange:I})}),!a&&!p&&(0,He.jsx)(pe.Item,{style:{marginBottom:16},children:(0,He.jsx)(dr,{project:a,projects:g,loading:p})}),(0,He.jsxs)(pe.Item,{style:{marginBottom:0,textAlign:"right"},children:[(0,He.jsx)(ee,{onClick:o,style:{marginRight:8},children:"Cancel"}),(0,He.jsx)(ee,{type:"primary",htmlType:"submit",loading:m,disabled:!!v||p||!a,children:"Start Learning"})]})]})]})};var ve=T(Te());var gn=T(_()),ka=32,il=8,al=ka-il,sl="Activity could not be loaded. Please try again shortly.",ll="Too many activity requests are still pending. Please try again shortly.",yr=ve.default.createContext(null),wa=ve.default.createContext(()=>{});function dl(e){return e==="in_progress"?"Task retry started":e==="cancelled"?"Task cancelled":"Task updated"}function cl(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 hr=({task:e,relatedTasks:t,onClose:n,onRefresh:o,height:r})=>{let{message:i}=xn.useApp(),[s,c]=(0,ve.useState)(null),[l,u]=(0,ve.useState)([]),[g,p]=(0,ve.useState)([]),[a,d]=(0,ve.useState)(!1),[m,y]=(0,ve.useState)(null),[v,f]=(0,ve.useState)(()=>new Set),w=mt("__GLOBAL__"),A=ve.default.useContext(yr)??{getWorkItemRequest:(P,oe,Z,L)=>j(P,oe,Z,L),getDetailSession:()=>ce.current,bumpDetailSession:()=>{ce.current+=1}},I=(0,ve.useRef)(0),F=(0,ve.useRef)(null),z=(0,ve.useRef)(new Set),S=(0,ve.useRef)(!0),x=(0,ve.useRef)(new Map),B=(0,ve.useRef)(new Set),ce=(0,ve.useRef)(0),V=(0,ve.useRef)(w);V.current=w;let J=(0,ve.useRef)(A);J.current=A;let D=s??e,j=(P,oe,Z=ce.current,L=!1)=>{let K=x.current.get(P);if(K&&(!L||K.detailSession===Z))return K;K&&(x.current.delete(P),B.current.add(K.promise),K.promise.finally(()=>{B.current.delete(K.promise)}).catch(()=>{}));let ke=L?ka:al;if(x.current.size+B.current.size>=ke){let Ee=Promise.reject(new Error("Work-item request capacity reached"));return Ee.catch(()=>{}),{promise:Ee,source:oe,detailSession:Z}}let we;try{we=Promise.resolve(V.current.tasks.workItems.list(P))}catch(Ee){we=Promise.reject(Ee)}let fe={promise:we,source:oe,detailSession:Z};return x.current.set(P,fe),we.finally(()=>{x.current.get(P)?.promise===we&&x.current.delete(P)}).catch(()=>{}),fe};(0,ve.useEffect)(()=>(S.current=!0,()=>{S.current=!1,F.current=null,I.current+=1,J.current.bumpDetailSession(),Promise.resolve().then(()=>{S.current||(x.current.clear(),B.current.clear(),z.current.clear())})}),[]);let G=(P,oe=!0)=>{let Z=oe?++I.current:I.current;oe&&S.current&&d(!0);let L=A.getDetailSession(),K=A.getWorkItemRequest(P,"detail",L,oe),ke=K.detailSession===L;return cl(K.promise,4e3).then(N=>{ke&&S.current&&Z===I.current&&F.current===P&&(p(N),y(null))}).catch(N=>{ke&&oe&&S.current&&Z===I.current&&F.current===P&&(p([]),y(N instanceof Error&&N.message==="Work-item request capacity reached"?ll:sl))}).finally(()=>{ke&&S.current&&Z===I.current&&F.current===P&&d(!1)})},M=(P,oe)=>{oe&&u(Z=>D?[...Z,D]:Z),F.current=P.id,c(P),p([]),y(null),G(P.id)},ie=P=>M(P,!0),E=()=>{if(l.length===0)return;let P=l[l.length-1];u(l.slice(0,-1)),M(P,!1)},Y=()=>{A.bumpDetailSession(),F.current=null,I.current+=1,c(null),u([]),p([]),d(!1),y(null),n()},ue=async(P,oe)=>{let Z=F.current;if(!Z||z.current.has(Z))return;let L=dl(P);z.current.add(Z),f(K=>new Set(K).add(Z));try{try{await V.current.tasks.update(Z,oe?{status:P,failureReason:oe}:{status:P})}catch{S.current&&i.error("Operation failed, please retry");return}if(!S.current)return;F.current===Z&&c(K=>!S.current||K?.id!==Z||F.current!==Z?K:(G(Z,!1),{...K,status:P,...oe?{failureReason:oe}:{}})),S.current&&i.success(L),o&&Promise.resolve().then(o).catch(()=>{S.current&&i.warning(`${L}, but the task list could not be refreshed`)})}finally{z.current.delete(Z),S.current&&f(K=>{let ke=new Set(K);return ke.delete(Z),ke})}};(0,ve.useEffect)(()=>{F.current!==e.id&&(u([]),M(e,!1))},[e]),(0,ve.useEffect)(()=>{let P=F.current;if(!P)return;let oe=t.find(L=>L.id===P);if(!oe){Y();return}c(L=>L&&L.id===P?oe:L);let Z=new Map(t.map(L=>[L.id,L]));u(L=>L.flatMap(K=>{let ke=Z.get(K.id);return ke?[ke]:[]})),G(P,!1)},[e,t]),(0,ve.useEffect)(()=>{if(!D?.id)return;let P=D.id,oe=!1,Z,L=async()=>{document.hidden||(await G(P,!1),!oe&&S.current&&F.current===P&&!document.hidden&&(Z=window.setTimeout(()=>void L(),5e3)))},K=()=>{oe||!S.current||document.hidden||(Z!==void 0&&window.clearTimeout(Z),Z=void 0,L())};return document.addEventListener("visibilitychange",K),L(),()=>{oe=!0,Z!==void 0&&window.clearTimeout(Z),document.removeEventListener("visibilitychange",K)}},[D?.id]);let ye=xo(D),Ie=ve.default.useContext(wa);(0,ve.useEffect)(()=>{Ie(e,D)},[Ie,e,D]);let me=D?v.has(D.id):!1,W=D?.ownerType==="agent"?{onApprove:void 0,onReject:void 0,onRetry:void 0,onCancel:void 0}:{onApprove:void 0,onReject:void 0,onRetry:()=>void ue("in_progress"),onCancel:()=>void ue("cancelled")};return(0,gn.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,gn.jsx)("div",{style:{flex:1,minHeight:0},children:(0,gn.jsx)(wo,{task:D,relatedTasks:t,onRelatedTaskClick:ie,workItems:g,loading:a,activityError:m??void 0,transitionPending:me,...W,onViewChat:ye,onBack:E,canGoBack:l.length>0,maxHeight:r,focusKey:`${D.id}:${me?"updating":D.status}`,subtasks:t.filter(P=>P.parentId===D.id),onSubtaskClick:ie,parent:t.find(P=>P.id===D.parentId)??null,onParentClick:ie})})})},xa=({task:e,relatedTasks:t,onClose:n,onRefresh:o})=>{let[r,i]=(0,ve.useState)(null),s=(0,ve.useCallback)((l,u)=>{i({rootId:l.id,title:u.title})},[]);(0,ve.useEffect)(()=>{e||i(null)},[e]);let c=e?r&&r.rootId===e.id?r.title:e.title:"";return(0,gn.jsx)(We,{open:e!==null,onCancel:n,footer:null,title:c,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,gn.jsx)(wa.Provider,{value:s,children:e&&(0,gn.jsx)(hr,{task:e,relatedTasks:t,onClose:n,onRefresh:o,height:"calc(100dvh - 96px)"})})})};var Ce=T(_()),br=32,ul=8,pl=br-ul;function gl(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 fl(e){let t=typeof e.detail?.markdown=="string"&&e.detail.markdown.length>0?e.detail.markdown:void 0;if(t){let n=gl(t);if(n)return n}return e.summary||e.action||""}function ml(e){let t=e.context?.interruption;return e.status==="interrupted"&&typeof t=="object"&&t!==null&&t.type==="review_required"}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 Ta=({assistantId:e,projectId:t,onLearningStarted:n,round:o,subTasks:r,rounds:i,subTasksByRound:s,selectedRoundId:c,onSelectedRoundChange:l,loading:u,onRefresh:g,onStartRequest:p,onExpandWorkflow:a})=>{let{message:d}=xn.useApp(),[m,y]=(0,ze.useState)(!1),[v,f]=(0,ze.useState)(!1),[w,C]=(0,ze.useState)(null),[A,I]=(0,ze.useState)(null),F=mt("__GLOBAL__"),z=(0,ze.useRef)(!0),S=(0,ze.useRef)(new Map),x=(0,ze.useRef)(new Set),B=(0,ze.useRef)(0),ce=(0,ze.useRef)(0),V=i&&i.length>0?i:o?[o]:[],[J,D]=(0,ze.useState)(null),j=c!==void 0,G=j?c:J,M=V.map(N=>N.id).join(",");(0,ze.useEffect)(()=>{if(V.length===0){D(null);return}D(N=>N&&M.split(",").includes(N)?N:V[0].id)},[M]);let ie=V.find(N=>N.id===G)??V[0]??null,E=N=>{j||D(N),l?.(N)},Y=s&&ie?s[ie.id]??[]:ie&&ie.id===o?.id?r:[],ue=(0,ze.useMemo)(()=>[ie,...Y].filter(N=>N!==null),[o,r,i,s,G]),ye=Y.filter(N=>N.status==="in_progress"),Ie=ye[0]??null,me=ie?.status==="in_progress",W=(ye.length>0?ye.map(N=>N.id):me&&ie?[ie.id]:[]).sort(),P=W.join(","),oe=(0,ze.useRef)(F);oe.current=F;let Z=(0,ze.useRef)(null);Z.current||(Z.current={getWorkItemRequest:(N,we,fe,Ee)=>L(N,we,fe,Ee),getDetailSession:()=>B.current,bumpDetailSession:()=>{B.current+=1}});let L=(N,we,fe=B.current,Ee=!1)=>{let Le=S.current.get(N);if(Le&&(!Ee||Le.detailSession===fe))return Le;Le&&(S.current.delete(N),x.current.add(Le.promise),Le.promise.finally(()=>{x.current.delete(Le.promise)}).catch(()=>{}));let et=Ee?br:pl;if(S.current.size+x.current.size>=et){let $e=Promise.reject(new Error("Work-item request capacity reached"));return $e.catch(()=>{}),{promise:$e,source:we,detailSession:fe}}let Qe;try{Qe=Promise.resolve(oe.current.tasks.workItems.list(N))}catch($e){Qe=Promise.reject($e)}let tt={promise:Qe,source:we,detailSession:fe};return S.current.set(N,tt),Qe.finally(()=>{S.current.get(N)?.promise===Qe&&S.current.delete(N)}).catch(()=>{}),tt};(0,ze.useEffect)(()=>(z.current=!0,()=>{z.current=!1,Promise.resolve().then(()=>{z.current||(S.current.clear(),x.current.clear())})}),[]),(0,ze.useEffect)(()=>{if(W.length===0){I(null);return}I(null);let N=!1,we,fe=()=>{if(document.hidden)return Promise.resolve();let Le=ce.current%W.length,et=[...W.slice(Le),...W.slice(0,Le)];return ce.current=(Le+br)%W.length,Promise.allSettled(et.map(ct=>yl(L(ct,"live").promise,4e3))).then(ct=>{if(N||!z.current)return;let Qe=ct.filter(Be=>Be.status==="fulfilled").map(Be=>Be.value);if(Qe.length===0)return;let $e=[...Qe.flat().filter(Be=>!/^Status changed to\b/i.test(Be.summary??""))].sort((Be,vt)=>new Date(vt.createdAt).getTime()-new Date(Be.createdAt).getTime());I($e[0]??null)}).finally(()=>{!N&&z.current&&!document.hidden&&(we=window.setTimeout(()=>void fe(),5e3))})},Ee=()=>{N||!z.current||document.hidden||(we!==void 0&&window.clearTimeout(we),we=void 0,fe())};return document.addEventListener("visibilitychange",Ee),fe(),()=>{N=!0,we!==void 0&&window.clearTimeout(we),document.removeEventListener("visibilitychange",Ee)}},[P]);let K=N=>C(N),ke=(N,we,fe,Ee)=>{E(N),y(!1);let Le;try{Le=Promise.resolve(g())}catch{Le=Promise.reject(new Error("Task-list refresh failed"))}Le.catch(()=>{z.current&&d.error("Task created, but the task list could not be refreshed")}),n?.(fe,N,Ee)};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:[u?(0,Ce.jsx)("div",{style:{fontSize:12,color:"#bbb",padding:"4px 2px"},children:"Loading..."}):ie?(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:[a&&(0,Ce.jsx)(ee,{size:"small",type:"text","aria-label":"Open workflow view",icon:(0,Ce.jsx)(lo,{}),onClick:a}),(0,Ce.jsx)(ee,{size:"small",type:"text",icon:(0,Ce.jsx)(Zt,{}),onClick:()=>p?p():y(!0),style:{fontSize:12},children:"New Learning Task"})]})]}),V.length>1&&(0,Ce.jsx)(ft,{size:"small","data-testid":"round-filter",style:{width:"100%",marginBottom:6},value:ie.id,onChange:E,options:V.map(N=>({value:N.id,label:`${N.title||N.id} (${N.status})`}))}),(()=>{let N=ue.filter(ml);return N.length>0?(0,Ce.jsxs)(ee,{type:"text","data-testid":"review-banner","aria-label":`Open ${N.length} task${N.length>1?"s":""} waiting for approval`,onClick:()=>K(N[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:[N.length," item",N.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:fl(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)(Mi,{tasks:[ie,...Y],loading:!1,onTaskClick:K,hideCompleted:v,onHideCompletedChange:f})})]}):(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)(ee,{size:"small",icon:(0,Ce.jsx)(Zt,{}),onClick:()=>p?p():y(!0),children:"New Learning Task"})]}),!p&&(0,Ce.jsx)(Oo,{open:m,agentId:e,defaultProjectId:t,onClose:()=>y(!1),onCreated:ke}),(0,Ce.jsx)(yr.Provider,{value:Z.current,children:(0,Ce.jsx)(xa,{task:w,relatedTasks:ue,onClose:()=>C(null),onRefresh:g})})]})};var Oe=T(Te());function Ra(e,t){let n=[...t],o=new Set(t.map(c=>`${c.from}|${c.to}`)),r=new Set(t.filter(c=>c.kind==="dependency").map(c=>c.to)),i=new Set(e.map(c=>c.id)),s=new Map;for(let c of e){if(!c.parentId||!i.has(c.parentId))continue;let l=s.get(c.parentId)??[];l.push(c),s.set(c.parentId,l)}for(let c of s.values()){let l=[...c].sort((u,g)=>new Date(u.createdAt).getTime()-new Date(g.createdAt).getTime());for(let u=1;u<l.length;u++){let g=l[u];if(r.has(g.id))continue;let p=l[u-1].id,a=`${p}|${g.id}`;o.has(a)||o.has(`${g.id}|${p}`)||(n.push({from:p,to:g.id,kind:"sequence"}),o.add(a))}}return n}function Ia(e,t){return e!=="completed"?"idle":t==="in_progress"?"flowing":t==="pending"?"idle":"traversed"}function Sa(e){return e==="completed"?"traversed":e==="in_progress"?"flowing":"idle"}var Bt={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 Et=T(_()),Ca=({data:e})=>{let{task:t}=e,n=Bt[t.status];return(0,Et.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,Et.jsx)(wt,{type:"target",position:ot.Left,style:{opacity:0}}),(0,Et.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[(0,Et.jsx)("span",{style:{width:8,height:8,borderRadius:9999,background:n.color,flexShrink:0}}),(0,Et.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"#262626",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t.title,children:t.title})]}),(0,Et.jsx)("div",{style:{fontSize:10,color:"#8c8c8c"},children:n.label}),(0,Et.jsx)(wt,{type:"source",position:ot.Right,style:{opacity:0}}),n.active&&(0,Et.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 rt=T(_()),hl={workflowTask:Ca},bl=180,vl=56,kl={traversed:{stroke:"#22c55e",strokeWidth:1.5},flowing:{stroke:"#6366f1",strokeWidth:2},idle:{stroke:"#d1d5db",strokeWidth:1,strokeDasharray:"5 5"}},Aa=({rounds:e,subTasksByRound:t,loading:n})=>{let o=mt("__GLOBAL__"),[r,i]=(0,Oe.useState)(null),[s,c]=(0,Oe.useState)(null),[l,u]=(0,Oe.useState)([]),[g,p]=(0,Oe.useState)(!1),[a,d]=(0,Oe.useState)(null),m=(0,Oe.useRef)(0),y=(0,Oe.useRef)(o);y.current=o;let v=e.map(E=>E.id).join(",");(0,Oe.useEffect)(()=>{i(E=>E&&v.split(",").includes(E)?E:e[0]?.id??null)},[v]);let f=e.find(E=>E.id===r)??e[0]??null,w=(0,Oe.useMemo)(()=>[f,...f?t[f.id]??[]:[]].filter(E=>E!==null),[f,t]),{nodes:C,edges:A}=(0,Oe.useMemo)(()=>ko(w),[w]),I=(0,Oe.useMemo)(()=>Ra(w,A),[w,A]),F=(0,Oe.useMemo)(()=>new Map(w.map(E=>[E.id,E])),[w]),z=(0,Oe.useMemo)(()=>{let E=bo(C.map(Y=>({id:Y.id})),I.map(Y=>({from:Y.from,to:Y.to})),{nodeWidth:bl,nodeHeight:vl,nodesep:24,ranksep:60,rankdir:"LR"});return C.map(Y=>({id:Y.id,type:"workflowTask",position:E.get(Y.id)??{x:0,y:0},data:{task:Y.task}}))},[C,I]),S=(0,Oe.useMemo)(()=>I.map(E=>{let Y=Ia(F.get(E.from)?.status??"pending",F.get(E.to)?.status??"pending");return{id:`${E.from}->${E.to}:${E.kind}`,source:E.from,target:E.to,animated:Y==="flowing",style:{...kl[Y],...E.kind==="sequence"&&Y!=="idle"?{strokeDasharray:"2 3"}:{}}}}),[I,F]),[x,B,ce]=In(z),[V,J,D]=Sn(S);(0,Oe.useEffect)(()=>{B(E=>{let Y=E.map(ye=>ye.id).sort().join("|"),ue=z.map(ye=>ye.id).sort().join("|");if(Y===ue){let ye=new Map(E.map(Ie=>[Ie.id,Ie]));return z.map(Ie=>{let me=ye.get(Ie.id);return me?{...Ie,position:me.position}:Ie})}return z}),J(S)},[z,S,B,J]);let j=(0,Oe.useCallback)(E=>{let Y=++m.current;p(!0),d(null),y.current.tasks.workItems.list(E).then(ue=>{Y===m.current&&u(ue)}).catch(()=>{Y===m.current&&(u([]),d("Activity could not be loaded. Please try again shortly."))}).finally(()=>{Y===m.current&&p(!1)})},[]),G=(0,Oe.useCallback)((E,Y)=>{let ue=Y.data?.task;ue&&(u([]),c(ue),j(ue.id))},[j]),M=(0,Oe.useCallback)(()=>{m.current+=1,c(null),u([]),d(null),p(!1)},[]),ie=xo(s);return n?(0,rt.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,rt.jsx)(kt,{size:"large"})}):!f||w.length===0?(0,rt.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,rt.jsx)(Ft,{description:"No tasks"})}):(0,rt.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[e.length>1&&(0,rt.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",paddingBottom:12,flexShrink:0},children:e.map((E,Y)=>{let ue=Bt[E.status],ye=E.id===f.id;return(0,rt.jsxs)("button",{type:"button","data-testid":`round-chip-${E.id}`,onClick:()=>{i(E.id),M()},title:E.title,style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11,fontWeight:600,padding:"3px 10px",borderRadius:9999,cursor:"pointer",border:ye?"1.5px solid #6366f1":"1px solid #e5e7eb",background:ye?"rgba(99,102,241,0.08)":"#fff",color:ye?"#6366f1":"#6b7280"},children:[(0,rt.jsx)("span",{style:{width:6,height:6,borderRadius:9999,background:ue.color}}),"R",e.length-Y]},E.id)})}),(0,rt.jsx)("div",{style:{flex:1,minHeight:0,position:"relative"},children:(0,rt.jsx)(vo,{nodes:x,edges:V,nodeTypes:hl,onNodesChange:ce,onEdgesChange:D,onNodeClick:G,fitView:!0,fitViewOptions:{padding:.15},nodesDraggable:!0,nodesConnectable:!1,miniMap:!0,attributionPosition:"bottom-right"})}),s&&(0,rt.jsx)("div",{"data-testid":"workflow-detail",style:{height:"40%",minHeight:200,flexShrink:0,borderTop:"1px solid #f0f0f0",overflow:"hidden"},children:(0,rt.jsx)(wo,{task:s,relatedTasks:w,workItems:l,loading:g,activityError:a??void 0,onApprove:void 0,onReject:void 0,onRetry:void 0,onCancel:void 0,onViewChat:ie,onBack:M,subtasks:w.filter(E=>E.parentId===s.id),onSubtaskClick:E=>{u([]),c(E),j(E.id)},parent:w.find(E=>E.id===s.parentId)??null,onParentClick:E=>{u([]),c(E),j(E.id)}})})]})};var Tt=T(Te());var Pt=T(_()),wl=0,Pa=360,Da=48,Ea=16;function vr(e){let t=typeof window>"u"?1200:window.innerWidth-Da;return Math.min(Math.max(e,Pa),t)}var yt=({open:e,width:t,mobileWidth:n,left:o,top:r=56,bottom:i=12,height:s,title:c,onClose:l,bodyStyle:u,restoreFocusRef:g,focusControlRef:p,escapeEnabled:a=!0,zIndex:d=25,children:m})=>{let y=xi("(max-width: 720px)"),v=(0,Tt.useRef)(null),f=(0,Tt.useRef)(null),w=(0,Tt.useRef)(null);w.current||(w.current=`canvas-dock-title-${++wl}`);let C=w.current,[A,I]=(0,Tt.useState)(null);(0,Tt.useEffect)(()=>I(null),[t,n]);let F=!y&&typeof t=="number",z=y?n??t:A??t,S=typeof z=="number"?z:null,x=o===void 0?-1:1,B=V=>{if(!F||S===null)return;V.preventDefault();let J={startX:V.clientX,startWidth:S},D=G=>{I(vr(J.startWidth+x*(G.clientX-J.startX)))},j=()=>{window.removeEventListener("pointermove",D),window.removeEventListener("pointerup",j)};window.addEventListener("pointermove",D),window.addEventListener("pointerup",j)},ce=V=>{!F||S===null||(V.key==="ArrowLeft"?(V.preventDefault(),I(vr(S-x*Ea))):V.key==="ArrowRight"&&(V.preventDefault(),I(vr(S+x*Ea))))};return(0,Tt.useEffect)(()=>{if(!e||!a)return;let V=J=>{J.key==="Escape"&&!J.defaultPrevented&&l()};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[a,e,l]),(0,Tt.useEffect)(()=>{if(p)return p.current=()=>v.current?.focus(),()=>{p.current=null}},[p]),(0,Tt.useEffect)(()=>{if(!e)return;let V=g?.current??document.activeElement;return V instanceof HTMLElement&&(f.current=V),v.current?.focus(),()=>{f.current?.focus(),f.current=null}},[e]),e?(0,Pt.jsxs)("div",{"data-testid":"canvas-dock",role:"region","aria-labelledby":C,style:{position:"absolute",top:r,...o===void 0?{right:12}:{left:o},...s===void 0?{bottom:i}:{height:s},width:z,maxWidth:"calc(100% - 24px)",boxSizing:"border-box",zIndex:d,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,Pt.jsx)("style",{children:"@keyframes canvas-dock-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }"}),F&&(0,Pt.jsx)("div",{"data-testid":"canvas-dock-resize-handle",role:"separator","aria-orientation":"vertical","aria-label":"Resize panel","aria-valuenow":S??void 0,"aria-valuemin":Pa,"aria-valuemax":typeof window>"u"?void 0:window.innerWidth-Da,tabIndex:0,onPointerDown:B,onKeyDown:ce,style:{position:"absolute",...o===void 0?{left:0}:{right:0},top:0,bottom:0,width:6,cursor:"ew-resize",zIndex:1,touchAction:"none"}}),(0,Pt.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,Pt.jsx)("div",{id:C,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:c}),(0,Pt.jsx)("button",{ref:v,type:"button","aria-label":"Close dock",onClick:l,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,Pt.jsx)(ki,{size:14})})]}),(0,Pt.jsx)("div",{"data-testid":"canvas-dock-body",style:{flex:1,minHeight:0,overflow:"auto",padding:16,...u},children:m})]}):null};var Dt=T(Te());var Fo=80;function Xt(e){return e>=80?"#22c55e":e>=50?"#f59e0b":"#ef4444"}function Vn(e){return e.filter(t=>t.status==="completed"&&t.holdout!==!0).sort(Wt)}function La(e){let t=Vn(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 Na(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 xl=.15,Ma={left:36,right:12,top:16,bottom:24},kr={fontSize:9,color:"#999"};function Oa(){return{type:"value",min:0,max:100,axisLabel:{...kr},splitLine:{lineStyle:{color:"#f5f5f5"}}}}function Fa({rounds:e,runs:t,selectedRoundId:n}){let o=[...e].sort((a,d)=>new Date(a.createdAt).getTime()-new Date(d.createdAt).getTime()),r=t.filter(a=>a.status==="completed").sort(Wt),i=new Map(o.map((a,d)=>[a.id,d+1])),s=new Map;for(let a of r){let d=a.taskId?i.get(a.taskId):void 0;d!==void 0&&s.set(d,(s.get(d)??0)+1)}let c=new Map,l=[],u=new Map;for(let a of r){let d=a.taskId?i.get(a.taskId):void 0;if(d===void 0)continue;let m=c.get(d)??0;if(c.set(d,m+1),a.holdout===!0){let y=(m-((s.get(d)??1)-1)/2)*xl;l.push([Math.round((d+y)*100)/100,a.avgScore])}else u.set(d,a.avgScore)}let g=n??null;if(g===null){for(let a=o.length-1;a>=0;a--)if(u.has(a+1)){g=o[a].id;break}}let p=o.map((a,d)=>{let m=u.get(d+1);if(m===void 0)return null;let y=a.id===g;return{value:[d+1,m],itemStyle:{color:Xt(m),borderRadius:[4,4,0,0],...y?{borderColor:"#6366f1",borderWidth:2}:{}}}});return{grid:Ma,tooltip:{trigger:"item"},xAxis:{type:"value",min:.5,max:o.length+.5,interval:1,axisLabel:{...kr,formatter:a=>Number.isInteger(a)?`R${a}`:""},axisLine:{lineStyle:{color:"#eee"}},splitLine:{show:!1}},yAxis:Oa(),series:[{type:"bar",data:p,barWidth:22,markLine:{silent:!0,symbol:"none",lineStyle:{type:"dashed",color:"#d9d9d9"},label:{fontSize:9,color:"#999",formatter:`target ${Fo}`},data:[{yAxis:Fo}]}},{type:"scatter",data:l,symbol:"diamond",symbolSize:9,itemStyle:{color:"#fff",borderColor:"#f59e0b",borderWidth:1.5},z:4}]}}function Wa(e){let t=e.filter(r=>r.status==="completed").sort(Wt),n=[],o=[];return t.forEach((r,i)=>{r.holdout===!0?o.push([i+1,r.avgScore]):n.push([i+1,r.avgScore])}),{grid:Ma,tooltip:{trigger:"item"},xAxis:{type:"value",min:.5,max:Math.max(t.length,1)+.5,interval:1,axisLabel:{...kr,formatter:r=>Number.isInteger(r)?`#${r}`:""},axisLine:{lineStyle:{color:"#eee"}},splitLine:{show:!1}},yAxis:Oa(),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 ${Fo}`},data:[{yAxis:Fo}]}},{type:"scatter",data:o,symbol:"diamond",symbolSize:9,itemStyle:{color:"#fff",borderColor:"#f59e0b",borderWidth:1.5},z:4}]}}var at=T(_()),wr={fontSize:10,color:"#999"},xr={fontSize:22,fontWeight:700,lineHeight:1.2},_a=({summary:e})=>e.latestScore===null?null:(0,at.jsxs)("div",{"data-testid":"eval-summary",style:{display:"flex",gap:28},children:[(0,at.jsxs)("div",{children:[(0,at.jsxs)("div",{style:{...xr,color:Xt(e.latestScore)},children:[e.latestScore.toFixed(1),e.delta!==null&&(0,at.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,at.jsx)("div",{style:wr,children:"latest score"})]}),(0,at.jsxs)("div",{children:[(0,at.jsx)("div",{"data-testid":"summary-pass",style:{...xr,color:"#262626"},children:e.passRate!==null?`${e.passRate}%`:"\u2014"}),(0,at.jsxs)("div",{style:wr,children:["pass \xB7 ",e.passedCases,"/",e.totalCases]})]}),e.interruptedCases>0&&(0,at.jsxs)("div",{"data-testid":"summary-interrupted",children:[(0,at.jsx)("div",{style:{...xr,color:"#b45309"},children:e.interruptedCases}),(0,at.jsx)("div",{style:wr,children:"interrupted"})]})]});var st=T(Te());var Nn=T(_()),za=({agentId:e,projectId:t,runs:n,selectedRoundId:o,onSelectRound:r})=>{let{get:i}=Ve(),[s,c]=(0,st.useState)([]),[l,u]=(0,st.useState)(!1),[g,p]=(0,st.useState)(null),a=st.default.useRef(i);a.current=i,(0,st.useEffect)(()=>{let v=!1;return a.current(Ln(e,t)).then(f=>{if(v)return;let w=(f.data??[]).filter(Dn);w.sort((C,A)=>new Date(C.createdAt).getTime()-new Date(A.createdAt).getTime()),c(w),u(!0)}).catch(()=>{v||u(!0)}),()=>{v=!0}},[e,t]),(0,st.useEffect)(()=>{g&&!s.some(v=>v.id===g)&&p(null)},[s,g]);let d=(0,st.useMemo)(()=>Fa({rounds:s,runs:n,selectedRoundId:o??g}),[s,n,o,g]),m=(0,st.useMemo)(()=>({click:v=>{let f=v;if(f.seriesType!=="bar"||typeof f.dataIndex!="number")return;let w=s[f.dataIndex];w&&(p(w.id),r?.(w.id))}}),[s,r]),y=(0,st.useMemo)(()=>{if(s.length===0)return!1;let v=new Set(s.map(f=>f.id));return Vn(n).some(f=>f.taskId!==void 0&&v.has(f.taskId))},[s,n]);return l?y?(0,Nn.jsxs)("div",{"data-testid":"round-trend-chart",style:{border:"1px solid #f0f0f0",borderRadius:12,padding:12},children:[(0,Nn.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"rgba(0,0,0,0.65)",marginBottom:8},children:"Score by learning round"}),(0,Nn.jsx)(un,{option:d,height:100,onEvents:m})]}):(0,Nn.jsx)("div",{"data-testid":"round-trend-empty",style:{display:"none"}}):null};var Jt=T(_()),Ba=({dimensions:e})=>e.length===0?null:(0,Jt.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,Jt.jsxs)("div",{"data-testid":`dimension-row-${t.name}`,style:{display:"flex",alignItems:"center",gap:8,fontSize:11},children:[(0,Jt.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,Jt.jsx)("div",{style:{flex:1,height:8,background:"#f5f5f5",borderRadius:4,overflow:"hidden"},children:(0,Jt.jsx)("div",{"data-testid":`dimension-fill-${t.name}`,style:{width:`${n}%`,height:"100%",background:Xt(t.avgScore),borderRadius:4}})}),(0,Jt.jsx)("span",{style:{width:28,textAlign:"right",flexShrink:0,fontWeight:600,color:Xt(t.avgScore)},children:Math.round(t.avgScore)})]},t.name)})});var jt=T(_());function ja(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 Ga=({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,jt.jsxs)("div",{style:{marginTop:8},"data-testid":"run-insights",children:[t>0&&(0,jt.jsxs)("div",{"data-testid":"interrupted-count",style:{fontSize:12,color:"#b45309",marginBottom:6},children:[t," interrupted"]}),n.length===0?(0,jt.jsx)("div",{style:{fontSize:12,color:"#22c55e"},children:"All cases passed"}):n.map((o,r)=>(0,jt.jsxs)("div",{style:{fontSize:12,padding:"3px 0",display:"flex",gap:6,alignItems:"baseline"},children:[(0,jt.jsx)("span",{style:{color:"#333",fontWeight:600,flexShrink:0},children:o.name}),(0,jt.jsx)("span",{style:{color:o.score>=50?"#f59e0b":"#ef4444",flexShrink:0},children:o.score}),(0,jt.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 lt=T(_()),$a={fontSize:12,fontWeight:600,color:"rgba(0,0,0,0.65)",marginBottom:8},qa={border:"1px solid #f0f0f0",borderRadius:12,padding:12},Mn=({agentId:e,projectId:t,runs:n,showRoundTrend:o=!0})=>{let{get:r}=Ve(),i=(0,Dt.useMemo)(()=>La(n),[n]),s=ja(n),c=n.find(m=>m.id===s),[l,u]=(0,Dt.useState)(null),g=Dt.default.useRef(r);g.current=r,(0,Dt.useEffect)(()=>{if(!s){u(null);return}let m=!1;return g.current(`/api/eval/runs/${s}`).then(y=>!m&&u(y.data?.results??[])).catch(()=>!m&&u([])),()=>{m=!0}},[s]);let p=(0,Dt.useMemo)(()=>Na(l??[]),[l]),a=(0,Dt.useMemo)(()=>Wa(n),[n]),d=Vn(n).length>0;return i.latestScore===null?(0,lt.jsx)("div",{style:{height:120,display:"flex",alignItems:"center",justifyContent:"center",color:"#bfbfbf",fontSize:12},children:"No eval runs yet"}):(0,lt.jsxs)("div",{"data-testid":"eval-quality-panel",style:{display:"flex",flexDirection:"column",gap:12},children:[(0,lt.jsx)(_a,{summary:i}),o&&(0,lt.jsx)(za,{agentId:e,projectId:t,runs:n}),d&&(0,lt.jsxs)("div",{"data-testid":"run-trend-card",style:qa,children:[(0,lt.jsx)("div",{style:$a,children:"Score by run"}),(0,lt.jsx)(un,{option:a,height:160})]}),s&&l!==null&&(0,lt.jsxs)("div",{"data-testid":"run-diagnosis-card",style:qa,children:[(0,lt.jsxs)("div",{style:$a,children:["Latest run",c?` \xB7 ${Do(new Date(c.createdAt))}`:""," \xB7 ",i.passedCases,"/",i.totalCases," passed"]}),(0,lt.jsx)(Ba,{dimensions:p}),(0,lt.jsx)(Ga,{results:l})]})]})};var se=T(_()),Ka={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"},Tl=async()=>{},Rl={rounds:[],round:null,subTasks:[],subTasksByRound:{},loading:!1},Wo=({assistantId:e,projectId:t,onProjectChange:n,onLearningStarted:o,learningTasks:r=Rl,topOffset:i=12,onLearningRefresh:s,evalTick:c,showLearning:l=!0,variant:u="full"})=>{let[g,p]=(0,Qn.useState)(null),[a,d]=(0,Qn.useState)(!1),m=da(e),y=Lo(e);return(0,Qn.useEffect)(()=>{c!==void 0&&c>0&&y.refresh()},[c]),u==="selector"?(0,se.jsx)("div",{style:{position:"absolute",left:12,top:i,zIndex:10,pointerEvents:"none"},children:(0,se.jsx)("div",{style:{pointerEvents:"auto"},children:(0,se.jsx)(lr,{kind:"training",disableDropdown:!1,showWorkspace:!1,value:t,onChange:n})})}):(0,se.jsxs)(se.Fragment,{children:[(0,se.jsxs)("div",{style:{position:"absolute",left:12,top:i,zIndex:10,display:"flex",flexDirection:"column",gap:8,pointerEvents:"none"},children:[(0,se.jsx)("div",{style:{pointerEvents:"auto"},children:(0,se.jsx)(lr,{kind:"training",disableDropdown:!1,showWorkspace:!1,value:t,onChange:n})}),(0,se.jsxs)("div",{onClick:()=>p(g==="runtime"?null:"runtime"),title:"Click for 30-day chart",style:Ka,children:[(0,se.jsx)("div",{style:{fontSize:10,fontWeight:600,color:"#999",marginBottom:4},children:"Runtime"}),(0,se.jsxs)("div",{style:{display:"flex",gap:14,fontSize:12,alignItems:"center"},children:[(0,se.jsxs)("span",{children:[(0,se.jsx)("strong",{style:{color:"#595959"},children:m.total})," ",(0,se.jsx)("span",{style:{color:"#bbb"},children:"threads"})]}),(0,se.jsxs)("span",{children:[(0,se.jsx)("strong",{style:{color:"#595959"},children:m.last7d})," ",(0,se.jsx)("span",{style:{color:"#bbb"},children:"7d"})]}),(0,se.jsxs)("span",{children:[(0,se.jsx)("strong",{style:{color:"#595959"},children:m.last30d})," ",(0,se.jsx)("span",{style:{color:"#bbb"},children:"30d"})]}),(0,se.jsx)("span",{style:{color:"#999"},children:Do(m.lastActive)}),m.daily7d.length>0&&(0,se.jsx)(pa,{values:m.daily7d,width:56,height:20,color:"#8c8c8c"})]})]}),(0,se.jsxs)("div",{onClick:()=>p(g==="eval"?null:"eval"),title:"Click for score trend",style:Ka,children:[(0,se.jsx)("div",{style:{fontSize:10,fontWeight:600,color:"#999",marginBottom:4},children:"Eval quality"}),(0,se.jsxs)("div",{style:{display:"flex",gap:14,fontSize:12,alignItems:"center"},children:[(0,se.jsxs)("span",{children:[(0,se.jsx)("strong",{style:{color:y.score===null?"#d9d9d9":y.score>=80?"#22c55e":y.score>=50?"#f59e0b":"#ef4444"},children:y.score!==null?y.score.toFixed(1):"\u2014"})," ",(0,se.jsx)("span",{style:{color:"#bbb"},children:"score"})]}),(0,se.jsxs)("span",{children:[(0,se.jsx)("strong",{style:{color:"#595959"},children:y.passRate!==null?`${y.passRate}%`:"\u2014"})," ",(0,se.jsx)("span",{style:{color:"#bbb"},children:"pass"})]}),(0,se.jsxs)("span",{children:[(0,se.jsx)("strong",{style:{color:"#595959"},children:y.runCount})," ",(0,se.jsx)("span",{style:{color:"#bbb"},children:"runs"})]}),y.scores.length>1&&(0,se.jsx)(ga,{values:y.scores.slice(-10),width:64,height:20,color:y.score===null?"#d9d9d9":y.score>=80?"#22c55e":y.score>=50?"#f59e0b":"#ef4444"})]})]}),l&&(0,se.jsx)(Ta,{assistantId:e,projectId:t,onLearningStarted:o,round:r.round,subTasks:r.subTasks,rounds:r.rounds,subTasksByRound:r.subTasksByRound,loading:r.loading,onRefresh:s??Tl,onExpandWorkflow:()=>d(!0)})]}),g==="runtime"&&(0,se.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,se.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"rgba(0,0,0,0.65)",marginBottom:8},children:"Runtime \u2014 last 30 days"}),(0,se.jsx)(un,{option:ca(m.daily30d),height:220})]}),g==="eval"&&(0,se.jsx)(yt,{open:!0,width:720,title:"Eval quality",onClose:()=>p(null),children:(0,se.jsx)(Mn,{agentId:e,runs:y.runs??[]})}),a&&(0,se.jsx)(yt,{open:!0,width:860,title:"Learning workflow",onClose:()=>d(!1),children:(0,se.jsx)(Aa,{rounds:r.rounds,subTasksByRound:r.subTasksByRound,loading:r.loading})})]})};var Tr=T(Te());var fn=T(_()),Il=({data:e})=>{let[t,n]=Tr.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"})})]})})},Ha=Tr.default.memo(Il);var Ue=T(Te());var _o=T(Te()),Yn="(max-width: 767px)",Sl=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(Yn).matches:!1;function Ua(){let[e,t]=(0,_o.useState)(Sl);return(0,_o.useEffect)(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia(Yn),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 en=T(Te()),Za=(e,t)=>e?.requestId===t?.requestId&&e?.content===t?.content;function On({assistantId:e,initialMessageRequest:t,onInitialMessageSubmitted:n}){let o=(0,en.useRef)(new Set),r=t??null,i=(0,en.useRef)(null);i.current===null&&(i.current={assistantId:e,observedRequest:r,request:r});let[s,c]=(0,en.useState)(i.current),l=(0,en.useRef)(s);(0,en.useLayoutEffect)(()=>{let p=l.current;if(p.assistantId===e&&Za(p.observedRequest,r))return;let a={assistantId:e,observedRequest:r,request:r};l.current=a,c(a)},[e,r?.requestId,r?.content]);let u=s.assistantId===e&&Za(s.observedRequest,r)?s.request:null;return{attemptedRequestIdsRef:o,effectivePendingRequest:u,handleInitialMessageSubmitted:p=>{let a=l.current;if(a.assistantId===e){if(a.request?.requestId===p){let d={...a,request:null};l.current=d,c(m=>m.assistantId===e&&m.request?.requestId===p?{...m,request:null}:m)}n?.(p)}}}}var ht=T(_()),Va=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(Yn).matches:!1,zo=({assistantId:e,assistantName:t,workspaceId:n,projectId:o,contextType:r,initialMessageRequest:i,onInitialMessageSubmitted:s,onToolCompleted:c,label:l="Architect",temporarilyHidden:u=!1,openSignal:g=0,showMobileTrigger:p=!0,restoreFocusRef:a})=>{let[d,m]=(0,Ue.useState)(Va),[y,v]=(0,Ue.useState)(()=>!Va()),[f,w]=(0,Ue.useState)(360),C=(0,Ue.useRef)(null),A=(0,Ue.useRef)(null),I=(0,Ue.useRef)(null),F=i??null,{attemptedRequestIdsRef:z,effectivePendingRequest:S,handleInitialMessageSubmitted:x}=On({assistantId:e,initialMessageRequest:i,onInitialMessageSubmitted:s});(0,Ue.useEffect)(()=>{C.current&&(C.current.inert=u||!y)},[d,u,y]),(0,Ue.useEffect)(()=>{d&&u&&v(!1)},[d,u]),(0,Ue.useEffect)(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;let J=window.matchMedia(Yn),D=j=>{m(j.matches),v(!j.matches)};return m(J.matches),typeof J.addEventListener=="function"?(J.addEventListener("change",D),()=>J.removeEventListener("change",D)):(J.addListener(D),()=>J.removeListener(D))},[]),(0,Ue.useEffect)(()=>{g>0&&v(!0)},[g]),(0,Ue.useEffect)(()=>{F&&!d&&v(!0)},[e,F?.requestId,F?.content,d]);let B=(0,Ue.useCallback)(J=>{J.preventDefault(),I.current={startX:J.clientX,startWidth:f}},[f]);(0,Ue.useEffect)(()=>{let J=j=>{if(!I.current)return;let G=I.current.startX-j.clientX,M=Math.min(900,Math.max(320,I.current.startWidth+G));w(M)},D=()=>{I.current=null};return window.addEventListener("mousemove",J),window.addEventListener("mouseup",D),()=>{window.removeEventListener("mousemove",J),window.removeEventListener("mouseup",D)}},[]);let ce=(0,ht.jsxs)("div",{ref:C,"data-testid":"architect-copilot-container","aria-hidden":u||!y||void 0,style:d?{width:"100%",height:"100%",overflow:"hidden",visibility:u||!y?"hidden":"visible",pointerEvents:u||!y?"none":void 0}:{position:"absolute",right:12,top:56,bottom:12,width:f,zIndex:15,borderRadius:12,overflow:"hidden",boxShadow:"0 4px 24px rgba(0,0,0,0.12)",visibility:u||!y?"hidden":"visible",pointerEvents:u||!y?"none":void 0},children:[!d&&(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)(Cn,{defaultWorkspaceId:n??void 0,defaultProjectId:o??void 0,children:(0,ht.jsx)(An,{workflowContext:{id:e,name:t??"",type:r},onClose:()=>v(!1),onToolCompleted:c,initialMessageRequest:S,attemptedInitialMessageRequestIdsRef:z,rawInitialMessage:!0,onInitialMessageSubmitted:x},e)},`${n??"default"}:${o??"default"}`)]});return(0,ht.jsxs)(ht.Fragment,{children:[!y&&!u&&(!d||p)?(0,ht.jsx)("div",{style:d?{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:d?{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:l})}):null,d?(0,ht.jsx)(qr,{title:l,"aria-label":l,placement:"right",width:"100vw",open:y&&!u,onClose:()=>v(!1),forceRender:!0,destroyOnHidden:!1,styles:{body:{padding:0,overflow:"hidden",height:"100%"}},afterOpenChange:J=>{!J&&!y&&(a?.current??A.current)?.focus()},children:ce}):ce]})};var mn=T(Te());var tn=T(_()),Xn="node:architect-copilot",Cl=({data:e})=>{let{assistantId:t,assistantName:n,workspaceId:o,projectId:r,initialMessageRequest:i,onInitialMessageSubmitted:s,onToolCompleted:c,temporarilyHidden:l=!1,openSignal:u=0,width:g,height:p,center:a}=e,d=yo(),m=(0,mn.useRef)(null),{attemptedRequestIdsRef:y,effectivePendingRequest:v,handleInitialMessageSubmitted:f}=On({assistantId:t,initialMessageRequest:i,onInitialMessageSubmitted:s}),w=l,C=()=>d.setCenter(a.x,a.y,{zoom:1,duration:400});return(0,mn.useEffect)(()=>{m.current&&(m.current.inert=w)},[w]),(0,mn.useEffect)(()=>{u>0&&C()},[u]),(0,tn.jsxs)("div",{style:{width:g,height:p,position:"relative",fontFamily:"inherit"},children:[(0,tn.jsx)("div",{ref:m,"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,tn.jsx)(Cn,{defaultWorkspaceId:o??void 0,defaultProjectId:r??void 0,children:(0,tn.jsx)(An,{workflowContext:{id:t,name:n??"",type:"agent"},onToolCompleted:c,initialMessageRequest:v,attemptedInitialMessageRequestIdsRef:y,rawInitialMessage:!0,showHeader:!1,onInitialMessageSubmitted:f},t)},`${o??"default"}:${r??"default"}`)}),w&&(0,tn.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,tn.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:"#22c55e",display:"inline-block"}}),"Architect"]})]})},Qa=mn.default.memo(Cl);var Sr=T(Te());var jo=(e,t,n,o,r)=>({id:e,label:t,x:n-o/2,y:-r/2,width:o,height:r}),yn=jo("zone:config","CONFIG",-767,900,620),Fn=jo("zone:testing","EVALUATION",-69,400,560),Bo=jo("zone:learning","LEARNING",459,560,680),Ya=jo("zone:copilot","COPILOT",1147,720,740);var Xa=[yn.id,Fn.id,Bo.id,Ya.id],Ja=.45,Al=220,El=110,Pl=200,Go=90,$o={"group:subagents":{x:0,y:-190},"group:capabilities":{x:330,y:0},"group:tools":{x:0,y:190},"group:skills":{x:-330,y:0}},es=e=>({x:e.x+e.width/2-Al/2,y:e.y+e.height/2-El/2}),ts=(e,t,n)=>{let o=$o[t]??{x:0,y:0};return{x:e.x+e.width/2+o.x-Pl/2,y:e.y+e.height/2+o.y-n/2}},Dl=310,Ll=e=>{let t=yn.x+yn.width/2,n=Dl;for(let[o,r]of Object.entries(e)){let i=$o[o];i&&(n=Math.max(n,Math.abs(i.y)+r/2+40))}return{id:yn.id,label:yn.label,x:t-yn.width/2,y:-n,width:yn.width,height:n*2}},Nl=900,Rr={x:20,y:20},Jn=110,eo=48,Ml=220,Ol=560,Fl=e=>({id:Fn.id,label:Fn.label,x:Fn.x,y:Fn.y,width:Fn.width,height:Math.max(Ol,Ml+e+24)}),ns=(e,t,n)=>({x:e.x+e.width/2-Jn/2,y:e.y+e.height/2-eo/2}),Wl=48,_l=520,zl=720,bt=20,Ir=150,Bl=12,jl=56,Gl=12,os=(e,t,n)=>{let o={},r=Bl,i=jl,s=Gl,c=Math.round((e-r*2-s)/2),l=e-r*2-s-c,u=t-i-r,g=Math.round((u-s)/2),p=n.has("learning"),a=n.has("evaluation");return n.has("copilot")?(o.copilot={width:c},p&&(o.learning=a?{left:r,top:i,width:l,height:g}:{left:r,top:i,width:l,height:u}),a&&(o.evaluation=p?{left:r,top:i+g+s,width:l,height:u-g-s}:{left:r,top:i,width:l,height:u}),o):p&&a?(o.learning={left:r,top:i,width:l,height:u},o.evaluation={left:r+l+s,top:i,width:c,height:u},o):(p&&(o.learning={width:c}),a&&(o.evaluation={width:c}),o)},rs=e=>{let t=Ll(e.groupHeights),n={...Fl(e.suitesGroupHeight),width:_l},o=Math.max(Bo.width,e.learningDagBBox.width+bt*2),r={...Bo,width:o,height:Math.max(Bo.height,e.learningDagBBox.height+Ir+bt*2)},i={...Ya,width:zl},s=Math.max(Nl,t.height,n.height,r.height,i.height),c=t.x,l=u=>{let g={x:c,y:-s/2,width:u.width,height:s};return c+=u.width+Wl,g};return{config:{...l(t),label:t.label,id:t.id},learning:{...l(r),label:r.label,id:r.id},testing:{...l(n),label:n.label,id:n.id},copilot:{...l(i),label:i.label,id:i.id},height:s}};var dt=T(_()),$l=.4,ql=.45,is=(e,t)=>t==="badge"?e>=ql?"overview":"badge":e<$l?"badge":"overview",Kl={background:"rgba(255,255,255,0.92)",border:"1px solid rgba(240,240,240,0.9)",borderRadius:14},Hl=({data:e})=>(0,dt.jsxs)("div",{"data-testid":"testing-panel",style:{...Kl,width:e.width,minHeight:e.height,boxSizing:"border-box",padding:12,overflow:"auto",display:"flex",flexDirection:"column",gap:12},children:[(0,dt.jsx)(Mn,{agentId:e.agentId,runs:e.runs}),e.suites.length>0&&(0,dt.jsxs)("div",{"data-testid":"testing-suites",style:{borderTop:"1px solid #f0f0f0",paddingTop:10,display:"flex",flexDirection:"column",gap:8},children:[(0,dt.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"rgba(0,0,0,0.65)"},children:"Evaluation suites"}),(0,dt.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e.suites.map(t=>(0,dt.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 ${Eo("eval")}55`,fontSize:11,color:"#333",cursor:"pointer",whiteSpace:"nowrap"},children:[(0,dt.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:t.label}),t.description&&(0,dt.jsx)("span",{style:{fontSize:10,color:"#999"},children:t.description})]},t.id))})]})]}),as=Sr.default.memo(Hl),Ul=({data:e})=>(0,dt.jsxs)("div",{"data-testid":"testing-badge",style:{width:Jn,height:eo,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,dt.jsx)("span",{style:{width:10,height:10,borderRadius:9999,background:e.score===null?"#d1d5db":Xt(e.score),flexShrink:0}}),(0,dt.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"#6b7280"},children:e.suiteCount})]}),ss=Sr.default.memo(Ul);var Rt=T(Te());var te=T(_());function Er(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 Zl(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(Mo(o))return o;return e.round??n[0]??null}function Pr(e,t){let n=Zl(e,t);return n?[n,...e.subTasksByRound[n.id]??[]]:[]}var qo=200,ls=80,Vl=40,Ql=70,Ar={width:0,height:0},Yl=e=>({headerOffset:{x:e.x+bt,y:e.y+bt},headerWidth:e.width-bt*2,dagOffset:{x:e.x+bt,y:e.y+Ir+bt}}),Xl={background:"rgba(255,255,255,0.92)",border:"1px solid rgba(240,240,240,0.9)",borderRadius:14,padding:"10px 12px"},Jl={traversed:{stroke:"#22c55e",strokeWidth:1.5},flowing:{stroke:"#6366f1",strokeWidth:2},idle:{stroke:"#d1d5db",strokeWidth:1}},ed={stroke:"#cbd5e1",strokeOpacity:.55,strokeWidth:1,strokeDasharray:"5 4"},td={type:"arrowclosed",color:"#cbd5e1",width:16,height:16};function ds(e){let t=e.context?.interruption;return e.status==="interrupted"&&typeof t=="object"&&t!==null&&t.type==="review_required"}function cs(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 us(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 s=o.get(i)??[];s.push(r),o.set(i,s)}return{byId:n,round:t,childrenOf:o}}function nd(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 od(e){return e.some(t=>t.status==="review"||ds(t))?"#f59e0b":e.some(t=>t.status==="in_progress")?"#3b82f6":"#9ca3af"}function rd(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 ps(e,t){let n=e[0]??null;return!n||!t||t===n.id?null:e.some(o=>o.id===t)?t:null}function gs(e){let t=new Map(e.map(l=>[l.id,l])),n=new Set(e.map(l=>l.id)),o=new Map([...e].sort((l,u)=>new Date(l.createdAt).getTime()-new Date(u.createdAt).getTime()).map((l,u)=>[l.id,u])),r=new Map,i=new Map;for(let l of e)r.set(l.id,[]),i.set(l.id,0);for(let l of e)for(let u of l.dependencies??[])n.has(u)&&u!==l.id&&(r.get(u)?.push(l.id),i.set(l.id,(i.get(l.id)??0)+1));let s=new Set(n),c=[];for(;s.size>0;){let l=null,u=1/0;for(let p of s){if((i.get(p)??0)!==0)continue;let a=o.get(p)??1/0;a<u&&(l=p,u=a)}if(l===null)break;s.delete(l);let g=t.get(l);g&&c.push(g);for(let p of r.get(l)??[])i.set(p,(i.get(p)??0)-1)}for(let l of[...s].sort((u,g)=>(o.get(u)??1/0)-(o.get(g)??1/0))){let u=t.get(l);u&&c.push(u)}return c}function id(e,t){let n=new Set(t.map(i=>i.id));if(t.some(i=>(i.dependencies??[]).some(s=>s!==i.id&&n.has(s))))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 Ko(e,t,n=null){let o={root:null,tasks:[],edges:[],positions:new Map,bbox:{...Ar}},r=us(e),i=r.round;if(!i)return o;let s=ps(e,t),c=s??i.id,l=r.childrenOf.get(c)??[],u=x=>{let B=nd(r,x.id);return B.length===0?null:{count:B.length,dotColor:od(B)}},g=(x,B,ce)=>({id:x.id,task:x,seq:B,fold:ce?u(x):null,depBadge:rd(x,r.byId)}),p=[],a=[],d=x=>{let B=gs(x);return a.push(...id(B,x)),B};d(l).forEach((x,B)=>{p.push(g(x,B+1,!1)),d(r.childrenOf.get(x.id)??[]).forEach((ce,V)=>{p.push(g(ce,V+1,!0))})});let m=s?p.map(x=>x.task):[i,...p.map(x=>x.task)],v=ko(m).edges.map(x=>({from:x.from,to:x.to,kind:x.kind==="parent"?"structure":"dependency"}));v.push(...a);let f=null;if(!s){f={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 l)x.has(`${B.id}:structure`)||(v.push({from:i.id,to:B.id,kind:"structure"}),x.add(`${B.id}:structure`))}let w=m.map(x=>({id:x.id})),C=bo(w,v.map(x=>({from:x.from,to:x.to})),{nodeWidth:qo,nodeHeight:ls,nodesep:Vl,ranksep:Ql,rankdir:"TB"}),A=1/0,I=1/0;for(let x of C.values())A=Math.min(A,x.x),I=Math.min(I,x.y);let F=new Map;if(Number.isFinite(A)&&Number.isFinite(I))for(let[x,B]of C)F.set(x,{x:B.x-A,y:B.y-I});let z=0,S=0;for(let x of F.values())z=Math.max(z,x.x+qo),S=Math.max(S,x.y+ls);return{root:f,tasks:p,edges:v,positions:F,bbox:{width:z,height:S}}}function fs(e,t=null){return e.length===0?{width:0,height:0}:Ko(e,t).bbox}var Cr={draggable:!1,selectable:!1,focusable:!1,deletable:!1,connectable:!1};function Dr(e,t,n){let o=e.rounds,r=Pr(e,t),i=r[0]??null,s=r.filter(ds),c=us(r),l=r.filter(y=>y.status==="completed").length,u=i?o.findIndex(y=>y.id===i.id):-1,g=i?o.length-u:null,p=o.map((y,v)=>({id:y.id,label:`R${o.length-v}`,title:y.title,status:y.status,createdAt:y.createdAt})),a=r.reduce((y,v)=>y?new Date(v.updatedAt).getTime()>new Date(y.updatedAt).getTime()?v:y:v,null),d=ps(r,n),m=[];if(i&&(m.push({id:i.id,label:`R${g}`}),d)){let y=[],v=c.byId.get(d)??null;for(;v&&v.id!==i.id;)y.unshift(v),v=v.parentId?c.byId.get(v.parentId)??null:null;for(let f of y){let C=gs(c.childrenOf.get(f.parentId??"")??[]).findIndex(A=>A.id===f.id)+1;m.push({id:f.id,label:`${C}.${f.title}`})}}return{tree:r,selectedRound:i,roundTreeById:c.byId,focusId:d,reviewTasks:s,doneCount:l,roundNumber:g,roundOptions:p,roundLatestActivity:cs(a?.updatedAt),breadcrumb:m}}var Lr=({hasRounds:e,reviewCount:t,onReviewClick:n,roundOptions:o,selectedRoundValue:r,onSelectRound:i,roundTitle:s,roundStatus:c,roundDoneCount:l,roundTotalCount:u,roundWaitingCount:g,roundLatestActivity:p,breadcrumb:a,onFocusTask:d,actions:m})=>{let y=c?Bt[c]:null;return(0,te.jsxs)(te.Fragment,{children:[(0,te.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,marginBottom:6},children:[(0,te.jsx)("div",{className:"nodrag nopan nowheel","data-testid":"learning-round-select",children:(0,te.jsx)(ft,{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 f=Bt[v.status],w=cs(v.createdAt);return{value:v.id,label:`${v.label} ${v.title} \xB7 ${f.label}${w?` \xB7 ${w}`:""}`}})})}),m]}),!e&&(0,te.jsx)("div",{"data-testid":"learning-empty",style:{fontSize:12,color:"#999",paddingBottom:4},children:"No learning tasks yet"}),y&&s&&(0,te.jsxs)("div",{"data-testid":"learning-round-stats",style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap",marginBottom:6},children:[(0,te.jsx)("span",{style:{width:8,height:8,borderRadius:9999,background:y.color,flexShrink:0}}),(0,te.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"#262626"},children:y.label}),(0,te.jsx)("span",{style:{fontSize:11,color:"#d1d5db"},children:"\xB7"}),(0,te.jsxs)("span",{style:{fontSize:11,color:"#8c8c8c"},children:[l,"/",u," tasks"]}),g>0&&(0,te.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 ",g," waiting"]}),p&&(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)("span",{style:{fontSize:11,color:"#d1d5db"},children:"\xB7"}),(0,te.jsx)("span",{style:{fontSize:11,color:"#9ca3af"},children:p})]})]}),a.length>1&&(0,te.jsxs)("div",{"data-testid":"learning-breadcrumb",style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap",marginBottom:6,fontSize:11,color:"#6b7280"},children:[a.map((v,f)=>(0,te.jsxs)(Rt.default.Fragment,{children:[f>0&&(0,te.jsx)("span",{style:{color:"#d1d5db"},children:"/"}),(0,te.jsx)("button",{type:"button","data-testid":`learning-crumb-${f}`,onClick:()=>d(f===0?null:v.id),style:{border:"none",background:"transparent",padding:0,cursor:"pointer",fontSize:11,fontWeight:600,color:f===a.length-1?"#4b5563":"#6366f1"},children:v.label})]},v.id)),(0,te.jsx)("button",{type:"button","data-testid":"learning-crumb-back",onClick:()=>d(a[a.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,te.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"]})]})},ad=({data:e})=>{let[t,n]=(0,Rt.useState)(!1);return(0,te.jsxs)("div",{style:{...Xl,width:e.width},children:[(0,te.jsx)(Lr,{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,te.jsx)(ee,{size:"small",type:"text",icon:(0,te.jsx)(Zt,{}),"data-testid":"learning-new-task",onClick:()=>n(!0),style:{fontSize:12},children:"New Learning Task"})}),(0,te.jsx)(Oo,{open:t,agentId:e.agentId,defaultProjectId:e.projectId??void 0,onClose:()=>n(!1),onCreated:(o,r,i,s)=>{e.onLearningStarted?.(i,o,s),n(!1)}})]})},ms=Rt.default.memo(ad),sd=({data:e})=>{let t=Bt[e.task.status],[n,o]=(0,Rt.useState)(!1);return(0,te.jsxs)("div",{"data-testid":"learning-dag-task",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{width:qo,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,te.jsx)(wt,{type:"target",position:ot.Top,style:{opacity:0}}),(0,te.jsx)(wt,{id:"left",type:"target",position:ot.Left,style:{opacity:0}}),(0,te.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:6},children:[(0,te.jsx)("span",{style:{width:8,height:8,borderRadius:9999,background:t.color,flexShrink:0,marginTop:4}}),(0,te.jsxs)("span",{style:{fontSize:12,fontWeight:600,color:"#262626",flexShrink:0},children:[e.seq,"."]}),(0,te.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,te.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6,marginTop:5},children:[e.depBadge?(0,te.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,te.jsx)("span",{}),e.fold&&(0,te.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,te.jsx)("span",{style:{width:6,height:6,borderRadius:9999,background:e.fold.dotColor,flexShrink:0}}),"\u25B8 ",e.fold.count]})]}),(0,te.jsx)(wt,{type:"source",position:ot.Bottom,style:{opacity:0}}),t.active&&(0,te.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=Rt.default.memo(sd),ld=({data:e})=>{let t=Bt[e.status],[n,o]=(0,Rt.useState)(!1);return(0,te.jsxs)("div",{"data-testid":"learning-round-root",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{width:qo,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,te.jsx)(wt,{type:"target",position:ot.Top,style:{opacity:0}}),(0,te.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:6},children:[(0,te.jsx)("span",{style:{width:8,height:8,borderRadius:9999,background:t.color,flexShrink:0,marginTop:4}}),(0,te.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,te.jsxs)("div",{style:{fontSize:11,color:"#8c8c8c",marginTop:4},children:[e.doneCount,"/",e.totalCount," tasks done"]}),(0,te.jsx)(wt,{type:"source",position:ot.Bottom,style:{opacity:0}})]})},Uo=Rt.default.memo(ld);function Nr(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:ed,...i.kind==="dependency"?{markerEnd:td}:{}};let s=Sa(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:s==="flowing",style:Jl[s]}})}function ys(e){let{learningTasks:t,selectedRoundId:n,onSelectRound:o,onTaskClick:r,onFocusTask:i,focusTaskId:s,onLearningStarted:c,agentId:l,projectId:u,zone:g}=e;return(0,Rt.useMemo)(()=>{if(!l)return{nodes:[],edges:[],bbox:{...Ar},breadcrumb:[]};let p=Yl(g),a=Dr(t,n,s),{tree:d,selectedRound:m,roundTreeById:y,focusId:v,reviewTasks:f,doneCount:w,roundNumber:C,roundOptions:A,roundLatestActivity:I,breadcrumb:F}=a,S=[{id:"learning:header",type:"learningHeader",position:p.headerOffset,data:{width:p.headerWidth,hasRounds:t.rounds.length>0,reviewCount:f.length,onReviewClick:()=>{f[0]&&r(f[0],d)},onLearningStarted:c,agentId:l,projectId:u,roundOptions:A,selectedRoundId:n,selectedRoundValue:m?.id??null,onSelectRound:o,roundNumber:C,roundTitle:m?.title??null,roundStatus:m?.status??null,roundDoneCount:w,roundTotalCount:d.length,roundWaitingCount:f.length,roundLatestActivity:I,breadcrumb:F,onFocusTask:i},...Cr}];if(!m)return{nodes:S,edges:[],bbox:{...Ar},breadcrumb:F};let x=Ko(d,v,C),B=g.width-bt*2,ce=p.dagOffset.x+Math.max(0,(B-x.bbox.width)/2);if(x.root){let D=x.positions.get(x.root.id)??{x:0,y:0};S.push({id:"learning:round-root",type:"learningRoundRoot",position:{x:ce+D.x,y:p.dagOffset.y+D.y},data:{label:x.root.label,title:x.root.title,status:x.root.status,doneCount:x.root.doneCount,totalCount:x.root.totalCount,onTaskClick:()=>r(m,d)},...Cr})}for(let D of x.tasks){let j=x.positions.get(D.id)??{x:0,y:0};S.push({id:`learning:task:${D.id}`,type:"learningTask",position:{x:ce+j.x,y:p.dagOffset.y+j.y},data:{task:D.task,seq:D.seq,depBadge:D.depBadge,fold:D.fold,onTaskClick:()=>r(D.task,d),onFocusTask:D.fold?()=>i(D.id):void 0},...Cr})}let J=Nr(x,{byId:y,nodeId:D=>D===m.id?"learning:round-root":`learning:task:${D}`,prefix:"learning:"});return{nodes:S,edges:J,bbox:x.bbox,breadcrumb:F}},[t,n,o,r,i,s,c,l,u,g])}var nn=T(Te()),Je=T(_()),Zo=[{title:"Welcome to the training canvas",description:"Four zones you can arrange freely. Press Next to learn the basics in 3 quick steps.",targetSelector:null,eventKind:null},{title:"Switch zones",description:"Press \u2318/Ctrl + 2 or 4 \u2014 or click a dot in the pill below \u2014 to jump between zones.",targetSelector:'[data-testid="zone-quick-nav"]',eventKind:"zoneActivated"},{title:"Move a zone",description:"Grab a zone label above any block and drag it anywhere. Positions reset next session.",targetSelector:'[data-testid^="canvas-zone-chip-"]',eventKind:"zoneDragged"},{title:"Pin the copilot",description:"Click \u{1F4CC} on the COPILOT label to dock it into the right split. Click again to unpin.",targetSelector:'[data-testid="canvas-zone-pin-copilot"]',eventKind:"copilotPinned"}],Vo=6,hs=({open:e,step:t,onStep:n,onDone:o,events:r,onEventConsumed:i})=>{let s=Zo[t]??null,[c,l]=(0,nn.useState)(null),u=e&&s?s.targetSelector:null;(0,nn.useEffect)(()=>{if(!u){l(null);return}let a=0,d=null,m=()=>{let v=document.querySelector(u);if(!v){d!==null&&(d=null,l(null));return}let f=v.getBoundingClientRect(),w={left:f.left-Vo,top:f.top-Vo,width:f.width+Vo*2,height:f.height+Vo*2},C=`${w.left}|${w.top}|${w.width}|${w.height}`;C!==d&&(d=C,l(w))};m();let y=()=>{m(),a=window.requestAnimationFrame(y)};return a=window.requestAnimationFrame(y),window.addEventListener("resize",m),()=>{window.cancelAnimationFrame(a),window.removeEventListener("resize",m)}},[u]);let g=(0,nn.useRef)(r);if((0,nn.useEffect)(()=>{let a=g.current;if(g.current=r,!e||!s)return;let d=s.eventKind;!d||!r[d]||a[d]||(i(d),t>=Zo.length-1?o():n(t+1))}),(0,nn.useEffect)(()=>{if(!e||!s)return;let a=s.eventKind;a&&r[a]&&i(a)},[e,t]),!e||!s)return null;let p=t>=Zo.length-1;return(0,Je.jsxs)(Je.Fragment,{children:[(0,Je.jsx)("style",{children:`
234
- .axiom-onboarding-next:hover { background: #4f46e5 !important; }
235
- .axiom-onboarding-skip:hover { color: #e5e7eb !important; }
236
- `}),c&&(0,Je.jsx)("div",{"data-testid":"onboarding-tour-ring",style:{position:"fixed",left:c.left,top:c.top,width:c.width,height:c.height,border:"2px solid #6366f1",borderRadius:10,pointerEvents:"none",boxShadow:"0 0 0 9999px rgba(0,0,0,0.35)",zIndex:59}}),(0,Je.jsxs)("div",{"data-testid":"onboarding-tour-card",style:{position:"fixed",top:16,left:"50%",transform:"translateX(-50%)",zIndex:60,width:360,padding:"12px 16px",background:"rgba(17,24,39,0.92)",color:"#fff",borderRadius:12,boxShadow:"0 8px 24px rgba(0,0,0,0.25)",pointerEvents:"auto"},children:[(0,Je.jsx)("div",{"data-testid":"onboarding-tour-dots",style:{display:"flex",gap:6,marginBottom:8},children:Zo.map((a,d)=>(0,Je.jsx)("span",{style:{width:6,height:6,borderRadius:"9999px",background:d===t?"#6366f1":"rgba(255,255,255,0.28)"}},d))}),(0,Je.jsx)("div",{style:{fontSize:14,fontWeight:600,marginBottom:4},children:s.title}),(0,Je.jsx)("div",{style:{fontSize:12,lineHeight:1.5,color:"rgba(255,255,255,0.82)"},children:s.description}),(0,Je.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:8,marginTop:10},children:[(0,Je.jsx)("button",{type:"button","data-testid":"onboarding-tour-skip",className:"axiom-onboarding-skip",onClick:o,style:{cursor:"pointer",border:"none",background:"transparent",padding:"4px 8px",fontSize:12,color:"rgba(255,255,255,0.6)"},children:"Skip tour"}),(0,Je.jsx)("button",{type:"button","data-testid":"onboarding-tour-next",className:"axiom-onboarding-next",onClick:()=>p?o():n(t+1),style:{cursor:"pointer",border:"none",borderRadius:6,background:"#6366f1",padding:"5px 14px",fontSize:12,fontWeight:600,color:"#fff"},children:p?"Done":"Next"})]})]})]})};var Lt=T(Te());var hn=T(_()),dd={learningTask:Ho,learningRoundRoot:Uo},bs=({learningTasks:e,selectedRoundId:t,onSelectRound:n,onTaskClick:o,height:r="100%"})=>{let[i,s]=(0,Lt.useState)(null);(0,Lt.useEffect)(()=>{s(null)},[t]);let c=(0,Lt.useMemo)(()=>Dr(e,t,i),[e,t,i]),{dagNodes:l,dagEdges:u}=(0,Lt.useMemo)(()=>{let f=Ko(c.tree,c.focusId,c.roundNumber),w=c.tree,C=[];f.root&&c.selectedRound&&C.push({id:f.root.id,type:"learningRoundRoot",position:f.positions.get(f.root.id)??{x:0,y:0},data:{label:f.root.label,title:f.root.title,status:f.root.status,doneCount:f.root.doneCount,totalCount:f.root.totalCount,onTaskClick:()=>o(c.selectedRound,w)}});for(let I of f.tasks)C.push({id:I.id,type:"learningTask",position:f.positions.get(I.id)??{x:0,y:0},data:{task:I.task,seq:I.seq,depBadge:I.depBadge,fold:I.fold,onTaskClick:()=>o(I.task,w),onFocusTask:I.fold?()=>s(I.id):void 0}});let A=Nr(f,{byId:c.roundTreeById,nodeId:I=>I});return{dagNodes:C,dagEdges:A}},[c,o]),[g,p,a]=In(l),[d,m,y]=Sn(u);(0,Lt.useEffect)(()=>{p(l),m(u)},[l,u,p,m]);let v=(0,Lt.useCallback)((f,w)=>{w.data.onTaskClick?.()},[]);return(0,hn.jsxs)("div",{style:{width:"100%",height:r,display:"flex",flexDirection:"column",minHeight:0},children:[(0,hn.jsx)("div",{className:"nodrag nowheel nopan",style:{flexShrink:0,padding:"12px 16px 4px"},children:(0,hn.jsx)(Lr,{hasRounds:e.rounds.length>0,reviewCount:c.reviewTasks.length,onReviewClick:()=>{c.reviewTasks[0]&&o(c.reviewTasks[0],c.tree)},roundOptions:c.roundOptions,selectedRoundValue:c.selectedRound?.id??null,onSelectRound:n,roundNumber:c.roundNumber,roundTitle:c.selectedRound?.title??null,roundStatus:c.selectedRound?.status??null,roundDoneCount:c.doneCount,roundTotalCount:c.tree.length,roundWaitingCount:c.reviewTasks.length,roundLatestActivity:c.roundLatestActivity,breadcrumb:c.breadcrumb,onFocusTask:s})}),(0,hn.jsx)("div",{style:{flex:1,minHeight:0,position:"relative"},children:(0,hn.jsx)(vo,{nodes:g,edges:d,nodeTypes:dd,onNodesChange:a,onEdgesChange:y,onNodeClick:v,fitView:!0,fitViewOptions:{padding:.15,maxZoom:1.2},nodesDraggable:!1,nodesConnectable:!1,miniMap:!1})})]})};var le=T(_()),cd={"zone:copilot":"copilot","zone:learning":"learning","zone:testing":"evaluation"},ud={copilot:"COPILOT",learning:"LEARNING",evaluation:"EVALUATION"},vs={copilot:"copilot",learning:"learning",testing:"evaluation"},pd=(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}},gd={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"},Ts="axiom.trainingCanvas.guideDismissed",fd=()=>{try{return typeof window<"u"&&window.localStorage?.getItem(Ts)==="1"}catch{return!1}},md=e=>{try{window.localStorage?.setItem(Ts,e?"1":"0")}catch{}},Rs="axiom.trainingCanvas.tutorialDone",yd=()=>{try{return typeof window<"u"&&window.localStorage?.getItem(Rs)==="1"}catch{return!1}},ks=e=>{try{window.localStorage?.setItem(Rs,e?"1":"0")}catch{}},Mr="axiom.trainingCanvas.layout",hd=["copilot","learning","evaluation"],bd=new Set(Xa),vd=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)},ws=()=>{try{if(typeof window>"u")return null;let e=window.localStorage?.getItem(Mr);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))vd(i)&&(o[r]=i);return{version:1,pinned:Array.isArray(n.pinned)?n.pinned.filter(r=>typeof r=="string"):[],origins:o}}catch{return null}},xs=(e,t)=>{try{let n={version:1,pinned:[...e],origins:t};window.localStorage?.setItem(Mr,JSON.stringify(n))}catch{}},kd=()=>{try{window.localStorage?.removeItem(Mr)}catch{}},Is=({graphDefinition:e,onSelectNode:t,assistantId:n,assistantName:o,workspaceId:r,onRemoveNode:i,initialMessageRequest:s,onInitialMessageSubmitted:c,projectId:l,onProjectChange:u,onLearningStarted:g,onToolActivity:p,learningTasks:a,onLearningRefresh:d,evalTick:m,evalData:y,hudTopOffset:v,copilotTemporarilyHidden:f,onOpenArchitect:w,architectOpenSignal:C=0,architectRestoreFocusRef:A})=>{let[I,F,z]=In([]),[S,x,B]=Sn([]),[ce,V]=(0,q.useState)(null),J=Ua(),D=yo(),j=(0,q.useRef)(!1),[G,M]=(0,q.useState)(!fd()),[ie,E]=(0,q.useState)(null),Y=(0,q.useRef)(null),[ue,ye]=(0,q.useState)(()=>!yd()),[Ie,me]=(0,q.useState)(0),[W,P]=(0,q.useState)({zoneActivated:!1,zoneDragged:!1,copilotPinned:!1}),oe=(0,q.useCallback)(k=>{P(R=>R[k]?R:{...R,[k]:!0})},[]),Z=(0,q.useRef)({onInitialMessageSubmitted:c,onToolActivity:p,onLearningStarted:g});Z.current={onInitialMessageSubmitted:c,onToolActivity:p,onLearningStarted:g};let[L,K]=(0,q.useState)(()=>{let k=new Set;for(let R of ws()?.pinned??[])hd.includes(R)&&k.add(R);return k}),[ke,N]=(0,q.useState)(()=>{let k={};for(let[R,O]of Object.entries(ws()?.origins??{}))bd.has(R)&&(k[R]=O);return k}),we=(0,q.useRef)(L);we.current=L;let fe=(0,q.useRef)(ke);fe.current=ke;let Ee=(0,q.useCallback)(k=>{let R=new Set(we.current);R.has(k)?R.delete(k):(R.add(k),k==="copilot"&&oe("copilotPinned")),we.current=R,K(R),xs([...R],fe.current)},[oe]),Le=(0,q.useRef)(null),[et,ct]=(0,q.useState)(()=>({width:typeof window>"u"?1200:window.innerWidth,height:typeof window>"u"?800:window.innerHeight}));(0,q.useEffect)(()=>{let k=Le.current;if(!k||typeof ResizeObserver>"u")return;let R=()=>{let Ne=k.getBoundingClientRect();ct({width:Ne.width,height:Ne.height})},O=new ResizeObserver(R);return O.observe(k),R(),()=>O.disconnect()},[]);let Qe=(0,q.useMemo)(()=>os(et.width,et.height,L),[et,L]),tt=On({assistantId:n??"",initialMessageRequest:s,onInitialMessageSubmitted:k=>Z.current.onInitialMessageSubmitted?.(k)}),$e=(0,q.useCallback)(k=>{E(k),oe("zoneActivated"),Y.current!==null&&window.clearTimeout(Y.current),Y.current=window.setTimeout(()=>E(null),700)},[oe]);(0,q.useEffect)(()=>()=>{Y.current!==null&&window.clearTimeout(Y.current)},[]);let[Be,vt]=(0,q.useState)(null),[Pe,It]=(0,q.useState)(null),[Nt,$t]=(0,q.useState)(null),qt=(0,q.useCallback)(k=>$t(k.id),[]),Mt=(0,q.useCallback)(()=>$t(null),[]),St=(0,q.useCallback)(k=>It(k),[]),on=(0,q.useCallback)((k,R,O)=>Z.current.onLearningStarted?.(k,R,O),[]),{suites:ut}=Rn(y.evalProjectId??""),rn=ut.map(k=>`${k.name}:${k.caseCount??0}`).join("|"),H=(0,q.useMemo)(()=>{let k={};for(let R of ut)k[R.name]=R.caseCount??0;return k},[rn]),Se=(0,q.useMemo)(()=>y.suiteNames.map(k=>({id:`suite:${k}`,type:"eval",label:k,description:`${H[k]??0} cases`})),[y.suiteNames,H]),Fe=(0,q.useMemo)(()=>Yi(e,{includeEmptyGroups:!0}),[e]),it=(0,q.useMemo)(()=>({zone:Ha,config:na,agent:ta,copilot:Qa,testingPanel:as,testingBadge:ss,learningHeader:ms,learningTask:Ho,learningRoundRoot:Uo}),[]),an=Ai(k=>k.transform[2]),to=(0,q.useRef)("overview"),Wn=is(an,to.current);to.current=Wn;let Ot=a??gd,bn=(0,q.useMemo)(()=>{let k=new Map(Fe.groups.map(O=>[O.id,O])),R={};for(let O of Fe.groups)k.get(O.id)&&(R[O.id]=Math.max(Go,56+O.items.length*30));return R},[Fe.groups]),_n=(0,q.useMemo)(()=>y.suiteNames.length>0?Math.max(Go,56+y.suiteNames.length*30):0,[y.suiteNames]),sn=(0,q.useMemo)(()=>Pr(Ot,Be),[Ot,Be]),no=(0,q.useMemo)(()=>fs(sn,Pe),[sn,Pe]),je=(0,q.useMemo)(()=>rs({groupHeights:bn,suitesGroupHeight:_n,learningDagBBox:no}),[bn,_n,no]),he=(0,q.useMemo)(()=>pd(je,ke),[je,ke]),zn=(0,q.useRef)({}),pt=(0,q.useRef)({}),vn=(0,q.useRef)(null),[ln,oo]=(0,q.useState)({x:0,y:0}),Jo=(0,q.useMemo)(()=>{let k=he.learning;return ln.x===0&&ln.y===0?k:{...k,x:k.x+ln.x,y:k.y+ln.y}},[he,ln]),er=(0,q.useCallback)((k,R)=>{k.startsWith("zone:")&&(vn.current=k,pt.current[k]={x:R.x,y:R.y})},[]),tr=(0,q.useCallback)((k,R)=>{if(!k.startsWith("zone:"))return;let O=pt.current[k],Ne={x:R.x,y:R.y};if(pt.current[k]=Ne,!O)return;let Ye=Ne.x-O.x,gt=Ne.y-O.y;if(Ye===0&&gt===0)return;let kn=zn.current[k]??[];k==="zone:learning"&&oo(wn=>({x:wn.x+Ye,y:wn.y+gt})),kn.length>0&&F(wn=>wn.map(Kt=>Kt.position&&kn.indexOf(Kt.id)>=0?{...Kt,position:{x:Kt.position.x+Ye,y:Kt.position.y+gt}}:Kt))},[F]),nr=(0,q.useCallback)((k,R)=>{if(!k.startsWith("zone:"))return;vn.current=null,delete pt.current[k],k==="zone:learning"&&oo({x:0,y:0}),oe("zoneDragged");let O=Object.keys(fe.current).length===0?{"zone:config":{x:je.config.x,y:je.config.y},"zone:copilot":{x:je.copilot.x,y:je.copilot.y},"zone:learning":{x:je.learning.x,y:je.learning.y},"zone:testing":{x:je.testing.x,y:je.testing.y}}:{...fe.current};O[k]={x:R.x,y:R.y},fe.current=O,N(O),xs([...we.current],O)},[je,oe]),ro=(0,q.useCallback)(()=>{kd(),we.current=new Set,K(new Set),fe.current={},N({})},[]),b=ys({learningTasks:Ot,selectedRoundId:Be,zone:Jo,onSelectRound:vt,onTaskClick:qt,onFocusTask:St,focusTaskId:Pe,onLearningStarted:on,agentId:n??"",projectId:l}),re=Nt?Er(Ot,Nt):null;(0,q.useEffect)(()=>{Nt&&!re&&$t(null)},[Nt,re]),(0,q.useEffect)(()=>{It(null)},[Be]),(0,q.useEffect)(()=>{Pe&&!Er(Ot,Pe)&&It(null)},[Pe,Ot]),(0,q.useEffect)(()=>{let k=Fe.groups,R=new Map(k.map(de=>[de.id,de])),O=[],Ne=!!n&&!J,Ye=he.config,gt=he.testing,kn=L.has("copilot"),wn=L.has("learning"),Kt=L.has("evaluation"),zr=[he.config,he.testing,he.learning,he.copilot].filter(de=>de.id!==he.copilot.id||Ne&&!kn).filter(de=>de.id!==he.learning.id||!!n&&!wn).filter(de=>de.id!==he.testing.id||!Kt).map(de=>{let Ge=cd[de.id];return{id:de.id,type:"zone",position:{x:de.x,y:de.y},data:{label:de.label,width:de.width,height:de.height,pinnable:Ge!==void 0,pinned:Ge!==void 0&&L.has(Ge),onPinToggle:Ge!==void 0?()=>Ee(Ge):void 0},draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1,zIndex:-1,style:{pointerEvents:"none"}}});O.push(...zr);let Br={[he.config.id]:[],[he.testing.id]:[],[he.learning.id]:[],[he.copilot.id]:[]},Bn=(de,Ge)=>{let jn=Br[de];jn&&jn.indexOf(Ge)<0&&jn.push(Ge)};Bn(he.config.id,Fe.agent.id),O.push({id:Fe.agent.id,type:"agent",draggable:!1,data:{node:Fe.agent,onClick:()=>t?.(Fe.agent)},position:es(Ye)});for(let de of k){let Ge=R.get(de.id);if(!Ge)continue;let jn=bn[de.id]??Math.max(Go,56+de.items.length*30);Bn(he.config.id,de.id),O.push({id:de.id,type:"config",draggable:!1,data:{group:Ge,onClick:Fs=>t?.(Fs),onRemove:i},position:ts(Ye,de.id,jn)})}L.has("evaluation")||(Wn==="badge"?y.suiteNames.length>0&&(Bn(he.testing.id,"testing:badge"),O.push({id:"testing:badge",type:"testingBadge",draggable:!1,data:{score:y.score,suiteCount:y.suiteNames.length},position:ns(gt,Jn,eo)})):(Bn(he.testing.id,"testing:panel"),O.push({id:"testing:panel",type:"testingPanel",draggable:!1,data:{agentId:n??"",runs:y.runs,width:gt.width-bt*2,height:gt.height-bt*2,suites:Se,onSuiteClick:de=>t?.(de)},position:{x:gt.x+Rr.x,y:gt.y+Rr.y}}))),Ne&&!L.has("copilot")&&(Bn(he.copilot.id,Xn),O.push({id:Xn,type:"copilot",draggable:!1,data:{assistantId:n,assistantName:o??"",workspaceId:r,projectId:l,initialMessageRequest:s??null,onInitialMessageSubmitted:de=>Z.current.onInitialMessageSubmitted?.(de),onToolCompleted:de=>Z.current.onToolActivity?.(de),temporarilyHidden:f??!1,openSignal:C,width:he.copilot.width,height:he.copilot.height,center:{x:he.copilot.x+he.copilot.width/2,y:he.copilot.y+he.copilot.height/2}},position:{x:he.copilot.x,y:he.copilot.y}})),zn.current=Br;for(let de of zr)vn.current!==de.id&&(pt.current[de.id]={x:de.position.x,y:de.position.y});F(O);let jr=(de,Ge)=>Math.abs(de)>Math.abs(Ge)?de<0?"left":"right":Ge<0?"top":"bottom";x(k.map(de=>{let Ge=$o[de.id]??{x:0,y:0};return{id:`e${Fe.agent.id}-${de.id}`,source:Fe.agent.id,target:de.id,sourceHandle:jr(Ge.x,Ge.y),targetHandle:jr(-Ge.x,-Ge.y),style:{stroke:"#c7c7c7",strokeWidth:1.2},type:"bezier"}}))},[Fe,F,x,i,n,J,r,l,o,f,C,s?.requestId,s?.content,Wn,Se,y.score,y.suiteNames,y.runs.map(k=>k.id).join(","),he,bn,L,Ee]);let $=Pi();(0,q.useEffect)(()=>{if(!$||j.current)return;j.current=!0;let k=D.getNodes().filter(R=>!R.id.startsWith("zone:"));D.fitView({padding:.2,nodes:k}).then(R=>{R&&D.getZoom()<Ja&&D.fitView({padding:.2,nodes:D.getNodes().filter(O=>O.type==="agent"||O.type==="config")})})},[$,D]),(0,q.useEffect)(()=>{let k=[["1","zone:config","config"],["2","zone:learning","learning"],["3","zone:testing","testing"],["4","zone:copilot","copilot"]],R=O=>{if(!(O.ctrlKey||O.metaKey))return;let Ne=k.find(([kn])=>O.key===kn);if(!Ne)return;let Ye=O.target;if(Ye&&(Ye.tagName==="INPUT"||Ye.tagName==="TEXTAREA"||Ye.tagName==="SELECT"||Ye.isContentEditable))return;O.preventDefault();let gt=vs[Ne[2]];gt&&L.has(gt)||($e(Ne[2]),D.fitView({padding:.4,duration:400,nodes:[{id:Ne[1]}]}))};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[D,$e,L]);let be=(0,q.useMemo)(()=>{let k=I.some(R=>R.id===ce)?ce:null;return k===null?I:I.map(R=>{if(R.id===Xn||R.id.startsWith("zone:")||R.id.startsWith("testing:"))return R;let O=R.id===k||S.some(Ne=>Ne.source===k&&Ne.target===R.id||Ne.target===k&&Ne.source===R.id);return{...R,style:{opacity:O?1:.4,transition:"opacity 0.2s ease"}}})},[I,S,ce]);return(0,le.jsxs)("div",{ref:Le,style:{width:"100%",height:"100%",position:"relative",background:"#fafafa"},children:[(0,le.jsx)("style",{children:`.axiom-training-canvas .react-flow__pane { cursor: default; }
237
- .axiom-training-canvas .react-flow__pane.dragging { cursor: grabbing; }
238
- @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); } }
239
- .zone-dot-active { animation: zone-dot-pulse 0.7s ease-out; }
240
- .zone-help-toggle:hover { color: #6366f1; }`}),(0,le.jsxs)(Ei,{className:"axiom-training-canvas",nodes:[...be,...L.has("learning")?[]:b.nodes],edges:[...S,...L.has("learning")?[]:b.edges],onNodesChange:z,onEdgesChange:B,onNodeDragStart:(k,R)=>er(R.id,R.position),onNodeDrag:(k,R)=>tr(R.id,R.position),onNodeDragStop:(k,R)=>nr(R.id,R.position),onNodeMouseEnter:(k,R)=>{R.id===Xn||R.id.startsWith("zone:")||R.id.startsWith("testing:")||R.type?.startsWith("learning")||V(R.id)},onNodeMouseLeave:()=>V(null),onPaneClick:()=>t?.(null),onNodeClick:(k,R)=>{if(R.type!=="learningTask"&&R.type!=="learningRoundRoot")return;R.data.onTaskClick?.()},nodeTypes:it,children:[(0,le.jsx)(Di,{color:"#eee",gap:20}),(0,le.jsx)(Li,{})]}),(0,le.jsx)(yt,{open:re!==null,width:860,title:re?.task.title??"",onClose:Mt,bodyStyle:{padding:0,overflow:"hidden"},children:re&&(0,le.jsx)(hr,{task:re.task,relatedTasks:re.related,onClose:Mt,onRefresh:d,height:"100%"})}),["copilot","learning","evaluation"].map(k=>{let R=Qe[k];return R?(0,le.jsxs)(yt,{open:!0,width:R.width,left:R.left,top:R.top,height:R.height,escapeEnabled:!1,zIndex:20,title:ud[k],onClose:()=>Ee(k),bodyStyle:{padding:0},children:[k==="copilot"&&n&&(0,le.jsx)("div",{style:{width:"100%",height:"100%",userSelect:"text",WebkitUserSelect:"text"},children:(0,le.jsx)(Cn,{defaultWorkspaceId:r??void 0,defaultProjectId:l??void 0,children:(0,le.jsx)(An,{workflowContext:{id:n,name:o??"",type:"agent"},onToolCompleted:O=>Z.current.onToolActivity?.(O),initialMessageRequest:tt.effectivePendingRequest,attemptedInitialMessageRequestIdsRef:tt.attemptedRequestIdsRef,rawInitialMessage:!0,showHeader:!1,onInitialMessageSubmitted:tt.handleInitialMessageSubmitted},n)},`${r??"default"}:${l??"default"}`)}),k==="learning"&&(0,le.jsx)(bs,{learningTasks:Ot,selectedRoundId:Be,onSelectRound:vt,agentId:n??"",projectId:l,onTaskClick:qt,height:"100%"}),k==="evaluation"&&(0,le.jsx)(Mn,{agentId:n??"",runs:y.runs})]},k):null}),n&&(0,le.jsx)(Wo,{assistantId:n,projectId:l,onProjectChange:u,onLearningStarted:g,learningTasks:a,topOffset:v,onLearningRefresh:d,evalTick:m,showLearning:!1,variant:"selector"}),n&&J&&(0,le.jsx)(zo,{assistantId:n,assistantName:o??"",workspaceId:r,projectId:l,contextType:"agent",initialMessageRequest:s,onInitialMessageSubmitted:c,onToolCompleted:k=>p?.(k),temporarilyHidden:f,openSignal:C,restoreFocusRef:A,showMobileTrigger:w===void 0}),G&&(0,le.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,le.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[(0,le.jsx)("span",{style:{fontSize:13,fontWeight:600,color:"#262626"},children:"Quick navigation"}),(0,le.jsx)("span",{"data-testid":"zone-help-close",onClick:()=>{md(!0),M(!1)},style:{cursor:"pointer",color:"#8c8c8c",fontSize:12,lineHeight:1},children:"\u2715"})]}),(0,le.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,fontSize:12,color:"#595959"},children:[(0,le.jsxs)("div",{children:[(0,le.jsx)("span",{style:Qo,children:"\u2318/Ctrl + 1\u20134"})," focus a zone"]}),(0,le.jsxs)("div",{children:[(0,le.jsx)("span",{style:Qo,children:"Click a dot"})," focus a zone"]}),(0,le.jsxs)("div",{children:[(0,le.jsx)("span",{style:Qo,children:"Drag a zone label"})," move the block"]}),(0,le.jsxs)("div",{children:[(0,le.jsx)("span",{style:Qo,children:"\u{1F4CC} Click a zone label"})," pin it into the side split (click again to unpin)"]}),(0,le.jsx)("div",{style:{color:"#8c8c8c"},children:"\u2460 Config \u2461 Learning \u2462 Evaluation \u2463 Copilot"})]}),(0,le.jsxs)("div",{style:{marginTop:8,paddingTop:8,borderTop:"1px solid #f0f0f0",display:"flex",justifyContent:"flex-end",gap:8},children:[(0,le.jsx)("button",{type:"button","data-testid":"start-tutorial",onClick:()=>{ks(!1),me(0),ye(!0)},style:{cursor:"pointer",border:"1px solid #6366f1",borderRadius:4,background:"#6366f1",padding:"2px 10px",fontSize:12,color:"#fff"},children:"Start tutorial"}),(0,le.jsx)("button",{type:"button","data-testid":"layout-reset",onClick:ro,style:{cursor:"pointer",border:"1px solid #e0e0e0",borderRadius:4,background:"#fafafa",padding:"2px 10px",fontSize:12,color:"#595959"},children:"Reset layout"})]})]}),(0,le.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,R])=>{let O=vs[k],Ne=O!==void 0&&L.has(O);return(0,le.jsx)("button",{type:"button","aria-label":`Fit ${R} zone`,"data-testid":`zone-dot-${k}`,className:ie===k?"zone-dot-active":void 0,onClick:()=>{$e(k),D.fitView({padding:.4,duration:400,nodes:[{id:he[k].id}]})},style:{width:10,height:10,borderRadius:"9999px",border:"none",padding:0,cursor:"pointer",background:ie===k||Ne?"#6366f1":"#d9d9d9"}},k)}),(0,le.jsx)("span",{"aria-hidden":"true",style:{width:1,alignSelf:"stretch",background:"#f0f0f0"}}),(0,le.jsx)("span",{"data-testid":"zone-help-toggle",className:"zone-help-toggle","aria-label":"Quick navigation guide",onClick:()=>M(k=>!k),style:{cursor:"pointer",color:"#8c8c8c",fontSize:12,lineHeight:"10px",userSelect:"none"},children:"\u24D8"})]}),(0,le.jsx)(hs,{open:ue,step:Ie,onStep:me,onDone:()=>{ks(!0),ye(!1)},events:W,onEventConsumed:k=>P(R=>({...R,[k]:!1}))})]})},wd=e=>{let t=Lo(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,le.jsx)(Is,{...e,evalData:t})},xd=({evalData:e,...t})=>(0,le.jsx)(Is,{...t,evalData:e}),Ss=({evalData:e,...t})=>(0,le.jsx)(ho,{children:e?(0,le.jsx)(xd,{...t,evalData:e}):(0,le.jsx)(wd,{...t})});var Yo=T(Te());var Ze=T(_()),{Text:Or}=_e;function Td(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 zi(t.workflowYaml)}catch{return null}}var Cs=({graphDefinition:e,assistantId:t,assistantName:n,workspaceId:o,description:r,initialMessageRequest:i,onInitialMessageSubmitted:s,projectId:c,onProjectChange:l,onLearningStarted:u,onToolActivity:g,learningTasks:p,onLearningRefresh:a,evalTick:d,hideTitleBar:m=!1,hudTopOffset:y,copilotTemporarilyHidden:v,onOpenArchitect:f,architectOpenSignal:w=0,architectRestoreFocusRef:C})=>{let[A,I]=(0,Yo.useState)(!1),F=(0,Yo.useMemo)(()=>Td(e),[e]);return(0,Ze.jsxs)("div",{style:{width:"100%",height:"100%",position:"relative",background:"#fafafa"},children:[(0,Ze.jsx)(ho,{children:(0,Ze.jsx)("div",{style:{width:"100%",height:"100%"},children:F?(0,Ze.jsx)(_i,{dsl:F}):(0,Ze.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,Ze.jsx)(Or,{type:"secondary",children:"No workflow DSL yet \u2014 ask the architect to design one"})})})}),!m&&(0,Ze.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,Ze.jsx)(po,{size:16,color:"#6366f1"}),(0,Ze.jsx)(Or,{strong:!0,style:{fontSize:13},children:n}),(0,Ze.jsx)(co,{style:{color:"#6366f1",cursor:"pointer",fontSize:15},onClick:()=>I(!0)})]}),(0,Ze.jsx)(Wo,{assistantId:t,projectId:c,onProjectChange:l,onLearningStarted:u,learningTasks:p,topOffset:y,onLearningRefresh:a,evalTick:d}),(0,Ze.jsx)(zo,{assistantId:t,assistantName:n,workspaceId:o,projectId:c,contextType:"workflow",label:"Builder",initialMessageRequest:i,onInitialMessageSubmitted:s,onToolCompleted:z=>g?.(z),temporarilyHidden:v,openSignal:w,restoreFocusRef:C,showMobileTrigger:f===void 0}),(0,Ze.jsx)(We,{title:n,open:A,onCancel:()=>I(!1),footer:null,width:"85vw",centered:!0,styles:{body:{maxHeight:"calc(85vh - 120px)",overflow:"auto",padding:"12px 24px 24px"}},children:r?(0,Ze.jsx)(Tn,{content:r}):(0,Ze.jsx)(Or,{type:"secondary",children:"No description set."})})]})};var Ke=T(Te());var U=T(_()),{Text:Fr}=_e;function As(e){switch(e.type){case"capability":case"agent":return 560;case"eval":return 860;default:return 400}}function Es(e){return e.label}var Rd=({label:e,confirmLabel:t,onConfirm:n})=>{let[o,r]=(0,Ke.useState)(!1);return o?(0,U.jsx)(ee,{danger:!0,size:"small",onClick:n,children:t}):(0,U.jsx)(ee,{danger:!0,size:"small",type:"text",onClick:()=>r(!0),children:e})},Gt=({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]}),Id=({node:e})=>{let{get:t}=Ve(),[n,o]=(0,Ke.useState)(null),[r,i]=(0,Ke.useState)(!0);if((0,Ke.useEffect)(()=>{let l=!1;return i(!0),t("/api/tools").then(u=>{if(l)return;let g=u.data?.records?.find(p=>p.name===e.label)??null;o(g)}).catch(()=>!l&&o(null)).finally(()=>!l&&i(!1)),()=>{l=!0}},[t,e.label]),r)return(0,U.jsx)(kt,{size:"small"});if(!n)return(0,U.jsx)(Fr,{type:"secondary",style:{fontSize:13},children:"Tool details unavailable."});let s=n.schema?.properties??{},c=new Set(n.schema?.required??[]);return(0,U.jsxs)(U.Fragment,{children:[n.description&&(0,U.jsx)(Gt,{title:"Description",children:n.description}),Object.keys(s).length>0&&(0,U.jsx)(Gt,{title:"Parameters",children:Object.entries(s).map(([l,u])=>(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:[l,c.has(l)&&(0,U.jsx)("span",{style:{color:"#ef4444"},children:" *"})]}),(0,U.jsx)("span",{style:{color:"#999"},children:u.type??"any"}),u.description&&(0,U.jsx)("span",{style:{color:"#666",flex:1},children:u.description})]},l))})]})},Sd=({node:e})=>{let{get:t}=Ve(),[n,o]=(0,Ke.useState)(null),[r,i]=(0,Ke.useState)(!0);return(0,Ke.useEffect)(()=>{let s=!1;return i(!0),t(`/api/assistants/${e.label}`).then(c=>!s&&o(c.data??null)).catch(()=>!s&&o(null)).finally(()=>!s&&i(!1)),()=>{s=!0}},[t,e.label]),r?(0,U.jsx)(kt,{size:"small"}):n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Gt,{title:"Description",children:n.description||"No description"}),n.graphDefinition?.modelKey&&(0,U.jsx)(Gt,{title:"Model",children:n.graphDefinition.modelKey})]}):(0,U.jsx)(Fr,{type:"secondary",style:{fontSize:13},children:"Sub-agent details unavailable."})},Cd=({node:e})=>{let{get:t}=Ve(),[n,o]=(0,Ke.useState)(null),[r,i]=(0,Ke.useState)(!0);return(0,Ke.useEffect)(()=>{let s=!1;return i(!0),t(`/api/skills/${e.label}`).then(c=>!s&&o(c.data??null)).catch(()=>!s&&o(null)).finally(()=>!s&&i(!1)),()=>{s=!0}},[t,e.label]),r?(0,U.jsx)(kt,{size:"small"}):n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Gt,{title:"Description",children:n.description||"No description"}),n.content&&(0,U.jsx)(Gt,{title:"Content",children:(0,U.jsx)(Tn,{content:n.content})})]}):(0,U.jsx)(Fr,{type:"secondary",style:{fontSize:13},children:"Skill details unavailable."})},Ad=({node:e,graphDefinition:t,onSaveGraph:n})=>{let{config:o}=ao(),{middlewareTypes:r}=To(o.middlewareTypesEndpoint),i=e.config??{},[s,c]=(0,Ke.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}),[l,u]=(0,Ke.useState)(!1),g=(o.availableMiddlewareTypes||r)?.find(a=>a.type===s.type),p=async()=>{if(n){u(!0);try{let a=typeof t=="object"&&t!==null?t:{},d=Array.isArray(a.middleware)?a.middleware:[],m={...i,name:s.name,description:s.description,enabled:s.enabled,config:s.config,...s.allowedTools!==void 0?{allowedTools:s.allowedTools}:{}},y=d.some(v=>v.type===s.type)?d.map(v=>v.type===s.type?m:v):[...d,m];await n({...a,middleware:y}),nt.success("Capability saved")}catch{nt.error("Failed to save capability")}finally{u(!1)}}};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ro,{middleware:s,middlewareType:g,onToggle:()=>c(a=>({...a,enabled:!a.enabled})),onConfigChange:a=>c(d=>({...d,config:{...d.config,...a}})),onAllowedToolsChange:a=>c(d=>({...d,allowedTools:a}))}),(0,U.jsx)("div",{style:{marginTop:16,textAlign:"right"},children:(0,U.jsx)(ee,{type:"primary",size:"small",loading:l,onClick:()=>void p(),children:"Save"})})]})},Ed=({graphDefinition:e,onSaveGraph:t})=>{let n=typeof e=="object"&&e!==null?e:{},[o,r]=(0,Ke.useState)(n.description??""),[i,s]=(0,Ke.useState)(n.prompt??""),[c,l]=(0,Ke.useState)(n.modelKey??""),[u,g]=(0,Ke.useState)(!1),p=async()=>{if(t){g(!0);try{await t({...n,description:o,prompt:i,modelKey:c}),nt.success("Agent saved")}catch{nt.error("Failed to save agent")}finally{g(!1)}}};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Gt,{title:"Description",children:(0,U.jsx)(De.TextArea,{"aria-label":"Description",rows:2,value:o,onChange:a=>r(a.target.value)})}),(0,U.jsx)(Gt,{title:"Model",children:(0,U.jsx)(De,{"aria-label":"Model",size:"small",value:c,onChange:a=>l(a.target.value)})}),(0,U.jsx)(Gt,{title:"Prompt",children:(0,U.jsx)(De.TextArea,{"aria-label":"Prompt",rows:8,value:i,onChange:a=>s(a.target.value)})}),(0,U.jsx)("div",{style:{textAlign:"right"},children:(0,U.jsx)(ee,{type:"primary",size:"small",loading:u,onClick:()=>void p(),children:"Save"})})]})},Ps=({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:Ji[e.type]})}),e.type==="tool"&&(0,U.jsx)(Id,{node:e},e.id),e.type==="subagent"&&(0,U.jsx)(Sd,{node:e},e.id),e.type==="skill"&&(0,U.jsx)(Cd,{node:e},e.id),e.type==="capability"&&(0,U.jsx)(Ad,{node:e,graphDefinition:t,onSaveGraph:r},e.id),e.type==="agent"&&(0,U.jsx)(Ed,{graphDefinition:t,onSaveGraph:r},e.id),e.type==="eval"&&n&&(0,U.jsx)(So,{assistantId:n},e.id),i&&o&&(0,U.jsx)("div",{style:{marginTop:16,borderTop:"1px solid #f0f0f0",paddingTop:12},children:(0,U.jsx)(Rd,{label:"Remove from agent",confirmLabel:"Confirm remove",onConfirm:()=>o(e)})})]})};function Ds(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 Ae=T(Te());var Pd=new Set(["create_agent","update_agent","delete_agent","create_workflow","update_workflow"]),Dd=new Set(["manage_task"]),Ld=new Set(["manage_eval","run_eval"]),Nd=new Set(["create_agent","delete_agent"]);function Ls(e){return Nd.has(e)}function Ns(e){let t=[];return Pd.has(e)&&t.push("config"),Dd.has(e)&&t.push("tasks"),Ld.has(e)&&t.push("eval"),t}var Md=300,Od=3e5,Wr=()=>({rounds:[],round:null,subTasks:[],subTasksByRound:{},loading:!0}),_r=()=>({config:{error:null,updatedAt:null},tasks:{error:null,updatedAt:null,partial:!1}});function Fd(e,t,n){let o=new Set(n),r=new Map(e.map(c=>[c.id,c])),i=c=>{let l=c.parentId,u=new Set;for(;l&&!u.has(l);){if(o.has(l))return!0;u.add(l),l=r.get(l)?.parentId}return!1},s=new Set(t.map(c=>c.id));return[...t,...e.filter(c=>!s.has(c.id)&&i(c))]}function Ms(e){let{agentId:t,projectId:n,onAssistantUpdated:o,onAgentListInvalidated:r}=e,{get:i}=Ve(),s=`${t}\0${n??""}`,[c,l]=(0,Ae.useState)(()=>({scope:s,value:Wr()})),[u,g]=(0,Ae.useState)(()=>({scope:s,value:0})),[p,a]=(0,Ae.useState)(()=>({scope:s,value:_r()})),d=(0,Ae.useRef)({}),m=(0,Ae.useRef)(0),y=(0,Ae.useRef)(null),v=(0,Ae.useRef)(null),f=(0,Ae.useRef)(0),w=(0,Ae.useRef)({}),C=(0,Ae.useRef)(!1),A=(0,Ae.useRef)(s),I=(0,Ae.useRef)({onAssistantUpdated:o,onAgentListInvalidated:r});(0,Ae.useLayoutEffect)(()=>{I.current={onAssistantUpdated:o,onAgentListInvalidated:r}},[o,r]),(0,Ae.useLayoutEffect)(()=>{if(A.current!==s){A.current=s,m.current+=1,f.current+=1,w.current={},y.current=null,v.current=null,C.current=!1;for(let j of Object.values(d.current))j&&clearTimeout(j);d.current={},l({scope:s,value:Wr()}),a({scope:s,value:_r()}),g({scope:s,value:0})}},[s]);let F=c.scope===s?c.value:Wr(),z=p.scope===s?p.value:_r(),S=u.scope===s?u.value:0,x=j=>{a(G=>G.scope===s?{scope:s,value:j(G.value)}:G)},B=(0,Ae.useCallback)(async()=>{let j=++f.current,G=s;try{let M=await i(`/api/assistants/${t}`);if(j!==f.current||G!==A.current)return;M.success&&M.data?(C.current=!1,I.current.onAssistantUpdated?.(M.data),x(ie=>({...ie,config:{error:null,updatedAt:new Date}}))):(C.current=!1,x(ie=>({...ie,config:{...ie.config,error:new Error("Configuration refresh returned no agent")}})))}catch(M){if(j!==f.current||G!==A.current)return;if(M instanceof Ur&&M.statusCode===404){C.current||I.current.onAgentListInvalidated?.(),C.current=!1,x(E=>({...E,config:{...E.config,error:M}}));return}C.current=!1,console.warn("[useEntityRefresher] config refresh failed",M);let ie=M instanceof Error?M:new Error(String(M));x(E=>({...E,config:{...E.config,error:ie}}))}},[i,t,s]),ce=(0,Ae.useCallback)(()=>{let j=y.current;if(j?.scope===s)return j.promise;let G=++m.current,M=s,ie=(async()=>{try{let Y=((await i(Ln(t,n))).data??[]).filter(Dn),ue={},ye=!1;if(await Promise.all(Y.map(async me=>{let W=await va(i,me.id,{projectId:n});ye||=W.partial,ue[me.id]=W.partial?Fd(w.current[me.id]??[],W.tasks,W.incompleteParentIds??[]):W.tasks})),G!==m.current||M!==A.current)return;w.current=Object.fromEntries(Y.map(me=>[me.id,ue[me.id]??[]]));let Ie=Y[0]??null;l({scope:s,value:{rounds:Y,round:Ie,subTasks:Ie?ue[Ie.id]??[]:[],subTasksByRound:ue,loading:!1}}),x(me=>({...me,tasks:{error:null,updatedAt:new Date,partial:ye}}))}catch(E){if(console.warn("[useEntityRefresher] task refresh failed",E),G!==m.current||M!==A.current)return;l(ue=>ue.scope===s?{scope:s,value:{...ue.value,loading:!1}}:ue);let Y=E instanceof Error?E:new Error(String(E));x(ue=>({...ue,tasks:{...ue.tasks,error:Y}}))}})().finally(()=>{y.current?.promise===ie&&(y.current=null,v.current===M&&A.current===M&&(v.current=null,V.current.refreshLearningTasks()))});return y.current={scope:s,promise:ie},ie},[i,t,n,s]),V=(0,Ae.useRef)({refreshAgent:B,refreshLearningTasks:ce});(0,Ae.useEffect)(()=>{V.current={refreshAgent:B,refreshLearningTasks:ce}});let J=(0,Ae.useCallback)((j,G)=>{let M=d.current;M[j]&&clearTimeout(M[j]),M[j]=setTimeout(G,Md)},[]),D=(0,Ae.useCallback)(j=>{for(let G of Ns(j))G==="config"&&J(G,()=>{Ls(j)&&(C.current=!0,I.current.onAgentListInvalidated?.()),V.current.refreshAgent()}),G==="tasks"&&J(G,()=>{let M=A.current;y.current?.scope===M?v.current=M:V.current.refreshLearningTasks()}),G==="eval"&&J(G,()=>{let M=A.current;g(ie=>ie.scope===M?{scope:M,value:ie.value+1}:ie)})},[J]);return(0,Ae.useEffect)(()=>{let j=!1,G,M=async()=>{await ce(),j||(G=setTimeout(()=>{M()},Od))};return M(),()=>{j=!0,G&&clearTimeout(G)}},[ce]),(0,Ae.useEffect)(()=>()=>{for(let j of Object.values(d.current))j&&clearTimeout(j)},[]),{handleToolCompleted:D,learningTasks:F,refreshLearningTasks:ce,refreshAgent:B,freshness:z,evalTick:S}}var X=T(_()),{Text:Os}=_e,Xo={color:"#4f46e5",background:"#eef2ff"},Wd=`
241
- @media (max-width: 767px) {
242
- .agent-detail__identity-pill { max-width: calc(100% - 24px) !important; right: 12px; }
243
- .agent-detail__actions-pill { top: 52px !important; left: 12px; right: auto !important; }
244
- }
245
- `,_d=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,zd=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:{}},nm=({assistant:e,allAssistants:t,onBack:n,onDeleted:o,initialTab:r="graph",onSave:i,onAssistantUpdated:s,onAgentListInvalidated:c,initialMessage:l=null,initialProjectId:u=null})=>{let[g,p]=(0,Re.useState)(()=>_d(r)),[a,d]=(0,Re.useState)(!1),[m,y]=(0,Re.useState)(!1),[v,f]=(0,Re.useState)(null),[w,C]=(0,Re.useState)(0),A=(0,Re.useRef)(null),I=(0,Re.useRef)(()=>{}),F=(0,Re.useRef)(0),z=(0,Re.useRef)(null),S=(0,Re.useRef)(null),x=(0,Re.useRef)(null),B=(0,Re.useRef)(null),ce=(0,Re.useRef)(null),V=(0,Re.useRef)(null),J=(0,Re.useRef)(null),[D,j]=(0,Re.useState)(()=>l?{requestId:`initial:${e.id}`,content:l}:null),{workspaceId:G,trainingProjects:M}=At(),ie=Ds(e.graphDefinition),[E,Y]=(0,Re.useState)(u??ie??M[0]?.id??null),ue=H=>{Y(H)},ye=(H,Se,Fe)=>{let it=M.find(an=>an.id===E)??null;j({requestId:Se,content:ba({goal:H,roundTaskId:Se,targetAgentId:e.id,targetMode:ha(e),files:Fe,projectId:E??void 0,workspaceId:it?.workspaceId??G??void 0})})},Ie=H=>{j(Se=>Se?.requestId===H?null:Se)};(0,Re.useEffect)(()=>{!E&&M.length>0&&Y(M[0].id)},[E,M]);let[me,W]=(0,Re.useState)(!1),[P,oe]=(0,Re.useState)(!1),[Z,L]=(0,Re.useState)(!1),[K,ke]=(0,Re.useState)(e.graphDefinition),{handleToolCompleted:N,learningTasks:we,refreshLearningTasks:fe,evalTick:Ee}=Ms({agentId:e.id,projectId:E,onAssistantUpdated:s,onAgentListInvalidated:c});(0,Re.useEffect)(()=>{ke(e.graphDefinition)},[e]);let Le=typeof e.graphDefinition=="object"?e.graphDefinition:{},et=String(Le.type??"react"),ct=En(et),Qe=et==="workflow"?po:Gn,tt=ur(e),$e=gr(e),Be=Gi($e),vt=H=>{H.kind==="back"?n():H.kind==="close"?p(null):H.kind==="architect"?(p(null),C(Se=>Se+1)):p(H.view)},Pe=H=>{if(!A.current&&!(H.kind==="dock"&&H.view.kind!=="node"&&g?.kind===H.view.kind&&H.view.kind!=="eval")){if(g?.kind==="configuration"&&a){A.current=H,f(H);return}vt(H)}};I.current=Pe;let It=H=>{let Se=H??(document.activeElement instanceof HTMLElement?document.activeElement:void 0);return Se?{current:Se}:void 0},Nt=(0,Re.useCallback)(H=>{let Se=++F.current;I.current({kind:"dock",view:{kind:"eval",initial:{page:"suites"},navigationKey:Se,restoreFocusRef:It(H)}})},[]),$t=()=>{A.current=null,f(null),requestAnimationFrame(()=>J.current?.())},qt=()=>{let H=A.current;H&&(A.current=null,f(null),d(!1),vt(H))},Mt=()=>{oe(!0)},St=async()=>{W(!0);try{await o(e.id),oe(!1)}finally{W(!1)}},on=H=>(ke(H),i?.(e,H)),ut=i?async(H,Se)=>{await i(H,Se),ke({...zd(H.graphDefinition),...Se})}:void 0,rn=H=>{let Se=typeof K=="object"&&K!==null?K:{},Fe={...Se};if(H.type==="tool"&&H.id.startsWith("tool:"))Fe.tools=(Se.tools??[]).filter(it=>it!==H.id.slice(5));else if(H.type==="subagent"&&H.id.startsWith("sub:"))Fe.subAgents=(Se.subAgents??[]).filter(it=>it!==H.id.slice(4));else if(H.type==="skill"&&H.id.startsWith("skill:"))Fe.skills=(Se.skills??[]).filter(it=>it!==H.id.slice(6));else if(H.type==="capability"&&H.id.startsWith("cap:")){let it=H.id.slice(4);Fe.middleware=(Se.middleware??[]).filter(an=>an.type!==it)}else return;ke(Fe),i?.(e,Fe).catch(()=>nt.error("Failed to save after removing node"))};return(0,X.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",background:"#fff"},children:[(0,X.jsx)("style",{"data-agent-detail-responsive":!0,children:Wd}),(0,X.jsxs)("div",{style:{flex:1,minHeight:0,position:"relative"},children:[(0,X.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,X.jsx)(ee,{type:"text",size:"small",icon:(0,X.jsx)(Vr,{}),onClick:()=>Pe({kind:"back"}),"aria-label":"Back"}),(0,X.jsx)(Qe,{size:15,color:$n(ct.color)}),(0,X.jsx)(Os,{strong:!0,style:{fontSize:13,maxWidth:220,minWidth:0,flex:"1 1 auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),(0,X.jsx)("span",{"data-testid":"agent-status-dot",title:$e,style:{width:8,height:8,borderRadius:"50%",background:$n(Be),flexShrink:0}}),(0,X.jsx)(ee,{type:"text",size:"small","aria-label":"View description",icon:(0,X.jsx)(co,{}),style:{color:"#6366f1"},onClick:()=>L(!0)})]}),(0,X.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,X.jsx)(Ut,{title:"Test in Playground",children:(0,X.jsx)(ee,{ref:z,type:"text",size:"small",icon:(0,X.jsx)(yi,{size:14}),onClick:()=>Pe({kind:"dock",view:{kind:"playground"}}),"aria-label":"Test in Playground","aria-pressed":g?.kind==="playground",style:g?.kind==="playground"?Xo:void 0})}),(0,X.jsx)(Ut,{title:"Eval Suite",children:(0,X.jsx)(ee,{ref:S,type:"text",size:"small",icon:(0,X.jsx)(uo,{size:14}),onClick:()=>Nt(S.current??void 0),"aria-label":"Eval Suite","aria-pressed":g?.kind==="eval",style:g?.kind==="eval"?Xo:void 0})}),(0,X.jsx)(Ut,{title:"Web Apps",children:(0,X.jsx)(ee,{ref:x,type:"text",size:"small",icon:(0,X.jsx)(gi,{size:14}),onClick:()=>Pe({kind:"dock",view:{kind:"web-apps"}}),"aria-label":"Web Apps","aria-pressed":g?.kind==="web-apps",style:g?.kind==="web-apps"?Xo:void 0})}),(0,X.jsx)(Ut,{title:"Configuration",children:(0,X.jsx)(ee,{ref:B,type:"text",size:"small",icon:(0,X.jsx)(hi,{size:14}),onClick:()=>Pe({kind:"dock",view:{kind:"configuration"}}),"aria-label":"Configuration","aria-pressed":g?.kind==="configuration",style:g?.kind==="configuration"?Xo:void 0})}),(0,X.jsx)(Ut,{title:"Delete Agent",children:(0,X.jsx)(ee,{type:"text",size:"small",danger:!0,icon:(0,X.jsx)(so,{}),loading:me,onClick:Mt,"aria-label":"Delete Agent"})})]}),et==="workflow"?(0,X.jsx)(Cs,{graphDefinition:K,assistantId:e.id,assistantName:e.name,workspaceId:G,description:e.description,hideTitleBar:!0,hudTopOffset:56,initialMessageRequest:D,onInitialMessageSubmitted:Ie,projectId:E,onProjectChange:ue,onLearningStarted:ye,onToolActivity:N,learningTasks:we,onLearningRefresh:fe,evalTick:Ee,architectOpenSignal:w,architectRestoreFocusRef:V,copilotTemporarilyHidden:g!==null}):(0,X.jsx)(Ss,{graphDefinition:K,assistantId:e.id,assistantName:e.name,workspaceId:G,hudTopOffset:56,onSelectNode:H=>{H?Pe({kind:"dock",view:{kind:"node",node:H}}):g?.kind==="node"&&Pe({kind:"close"})},onRemoveNode:rn,initialMessageRequest:D,onInitialMessageSubmitted:Ie,projectId:E,onProjectChange:ue,onLearningStarted:ye,onToolActivity:N,learningTasks:we,onLearningRefresh:fe,evalTick:Ee,architectOpenSignal:w,architectRestoreFocusRef:V,copilotTemporarilyHidden:g!==null}),g?.kind==="node"&&(0,X.jsx)(yt,{open:!0,width:As(g.node),title:Es(g.node),onClose:()=>p(null),children:(0,X.jsx)(Ps,{node:g.node,graphDefinition:K,assistantId:e.id,onRemoveNode:H=>{rn(H),p(null)},onSaveGraph:on})}),g?.kind==="playground"&&(0,X.jsx)(yt,{open:!0,width:720,title:"Playground",onClose:()=>Pe({kind:"close"}),restoreFocusRef:z,children:(0,X.jsx)(Wi,{assistant_id:e.id})}),g?.kind==="eval"&&(0,X.jsx)(yt,{open:!0,width:860,title:g.initial?.page==="run"?"Run Results":"Eval Suite",onClose:()=>Pe({kind:"close"}),restoreFocusRef:g.restoreFocusRef??S,children:(0,X.jsx)(So,{assistantId:e.id,initial:g.initial,navigationKey:g.navigationKey})},g.navigationKey),g?.kind==="web-apps"&&(0,X.jsx)(yt,{open:!0,width:960,title:"Web Apps",onClose:()=>Pe({kind:"close"}),restoreFocusRef:x,bodyStyle:{padding:0,overflow:"hidden"},children:(0,X.jsx)(Qi,{assistant:e})}),g?.kind==="configuration"&&(0,X.jsx)(yt,{open:!0,width:"80%",mobileWidth:"calc(100% - 24px)",title:"Configuration",onClose:()=>Pe({kind:"close"}),bodyStyle:{padding:0,overflow:"hidden"},restoreFocusRef:ce,focusControlRef:J,escapeEnabled:!m&&!Z&&!P&&v===null,children:(0,X.jsx)(Ui,{assistant:{...e,graphDefinition:K},allAssistants:t,visible:!0,onClose:()=>Pe({kind:"close"}),onSave:ut,onDirtyChange:d,onOverlayOpenChange:y,embedded:!0})})]}),(0,X.jsx)(We,{title:"Discard unsaved configuration?",open:v!==null,onCancel:$t,onOk:qt,okText:"Discard",okButtonProps:{danger:!0},cancelText:"Continue editing",children:(0,X.jsx)("p",{children:"You have unsaved configuration changes. Discard them and continue?"})}),(0,X.jsxs)(We,{title:e.name,open:Z,onCancel:()=>L(!1),footer:null,width:640,centered:!0,children:[(0,X.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:12},children:[(0,X.jsx)(qe,{color:ct.color,style:{margin:0},children:ct.label}),tt.map(H=>(0,X.jsx)(qe,{color:"magenta",style:{margin:0},children:H},H)),(0,X.jsx)(qe,{style:{margin:0},children:pr(e)}),(0,X.jsx)(qe,{color:Be,style:{margin:0},children:$e})]}),e.description?(0,X.jsx)(Tn,{content:e.description}):(0,X.jsx)(Os,{type:"secondary",children:"No description set."})]}),(0,X.jsx)(We,{title:"Delete Agent",open:P,onCancel:()=>oe(!1),onOk:St,okText:"Delete",okButtonProps:{danger:!0,loading:me},cancelText:"Cancel",children:(0,X.jsxs)("p",{children:['Are you sure you want to delete "',e.name,'"? This action cannot be undone.']})})]})};export{En as a,$n as b,Bd as c,jd as d,Gd as e,pa as f,fa as g,xu as h,ma as i,ya as j,ba as k,nm as l};