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