@axiom-lattice/gateway 4.4.0 → 4.4.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/{a2a-standard-P7JDL6ZA.mjs → a2a-standard-RWR5JTMH.mjs} +2 -2
- package/dist/a2a-standard-RWR5JTMH.mjs.map +1 -0
- package/dist/embed/{embed-page-AgentDetailSideApp-PSRQVFNR.js → embed-page-AgentDetailSideApp-2BDEWFQ6.js} +1 -1
- package/dist/embed/embed-page-AgentGovernanceWorkbench-WG7E3G5T.js +5 -0
- package/dist/embed/{embed-page-MessageGraph-PDNQ67T4.js → embed-page-MessageGraph-5SWPEQ4V.js} +1 -1
- package/dist/embed/{embed-page-ReactChart-25KAFLQ3.js → embed-page-ReactChart-ZYWRXIMC.js} +1 -1
- package/dist/embed/{embed-page-TasksSideApp-DLH5LRMS.js → embed-page-TasksSideApp-X6255GEF.js} +1 -1
- package/dist/embed/{embed-page-TeamWorkspace-2WJJWF25.js → embed-page-TeamWorkspace-XNZM7AV7.js} +1 -1
- package/dist/embed/{embed-page-TopologyRuntimeView-WDQRHDMO.js → embed-page-TopologyRuntimeView-DGSHSTIU.js} +1 -1
- package/dist/embed/{embed-page-WorkflowAutomationView-BAMJ2WVB.js → embed-page-WorkflowAutomationView-BHIRIWV3.js} +1 -1
- package/dist/embed/embed-page-chunk-DEDTYRZE.js +245 -0
- package/dist/embed/{embed-page-chunk-XVUA7UHE.js → embed-page-chunk-HEO7X7LH.js} +1 -1
- package/dist/embed/{embed-page-chunk-TL2AYM76.js → embed-page-chunk-JMZ7OODN.js} +1 -1
- package/dist/embed/{embed-page-chunk-OBM5EUWZ.js → embed-page-chunk-SPC4BYNU.js} +192 -192
- package/dist/embed/{embed-page-chunk-LOXLXZNP.js → embed-page-chunk-XUXEGF3S.js} +1 -1
- package/dist/embed/{embed-page-chunk-MQDYZS3S.js → embed-page-chunk-YCX5YZRP.js} +1 -1
- package/dist/embed/embed-page.js +1 -1
- package/dist/index.js +9 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/dist/a2a-standard-P7JDL6ZA.mjs.map +0 -1
- package/dist/embed/embed-page-AgentGovernanceWorkbench-UPQHJZD7.js +0 -5
- package/dist/embed/embed-page-chunk-SSC7ANWV.js +0 -245
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import{e as Fi}from"./embed-page-chunk-HEO7X7LH.js";import{a as cr,b as Pn}from"./embed-page-chunk-YCX5YZRP.js";import{b as Bi,c as ji}from"./embed-page-chunk-XUXEGF3S.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 Rt,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 Gi}from"./embed-page-chunk-JMZ7OODN.js";import{B as li,Ba as Ri,D as di,E as ci,Fa as In,G as ui,H as pi,J as uo,La as Sn,Ma as go,Na as fo,Oa as Ii,P as gi,Pa as Si,Sa as Ci,Ta as Ai,Ua as Ei,Va as mo,aa as fi,ab as Oi,ba as mi,bb as ko,ca as yi,cb as wo,db as xo,ea as hi,eb as To,fa as bi,fb as Wi,gb as _i,h as ii,hb as Ro,ib as En,j as ai,k as $n,ka as vi,kb as dr,lb as zi,oa as ki,sa as po,t as si,ta as wi,ua as xi,va as Ti,wa as Pt}from"./embed-page-chunk-SPC4BYNU.js";import{b as Zr,i as Vr,j as Qr,m as yt,q as ao,r as Ze}from"./embed-page-chunk-HMTKPZ5B.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 $e,Ja as Hr,La as _e,Ma as Ur,Sc as ri,Tb as ar,U as Vt,W as ee,Wa as Yr,Y as Rn,Z as _t,_ as mt,aa as Qt,ca as rr,da as ir,eb as Xr,fa as $r,fc as co,ia as cn,la as qr,mb as Jr,na as Kr,oa as Et,ob as ei,ra as pe,ta as Pe,tb as so,va as Tt,xa as rt,ya as Fe,yc as Yt}from"./embed-page-chunk-O4QK5LWZ.js";import{a as Te}from"./embed-page-chunk-4BKXE5ON.js";import{e as T}from"./embed-page-chunk-6Y3UYJ6Z.js";var 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 Gd(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 $d(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 qd(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 Re=T(Te());var oe=T(Te());var h=T(W()),{TextArea:js}=Pe,{Text:It}=_e,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:c="basic",onDirtyChange:l,onOverlayOpenChange:u})=>{let[y]=pe.useForm(),{token:d}=Hr.useToken(),{styles:s}=$s(),{styles:p}=Wi(),{config:m}=ao(),{middlewareTypes:g,isLoading:v}=To(m.middlewareTypesEndpoint),{get:f}=Ze(),[w,S]=(0,oe.useState)(c),[A,R]=(0,oe.useState)(e),[O,_]=(0,oe.useState)(null),[C,x]=(0,oe.useState)(!0),[B,ce]=(0,oe.useState)(!1),[V,X]=(0,oe.useState)(!1),[D,$]=(0,oe.useState)(!1),[K,z]=(0,oe.useState)(!1),[J,P]=(0,oe.useState)([]),[H,ue]=(0,oe.useState)(""),[be,Ie]=(0,oe.useState)(""),[me,F]=(0,oe.useState)([]),[E,ae]=(0,oe.useState)([]),[Q,L]=(0,oe.useState)(""),[ne,he]=(0,oe.useState)(!1),[N,Ee]=(0,oe.useState)("react"),[ye,Se]=(0,oe.useState)([]),[Me,tt]=(0,oe.useState)({name:"",description:""}),[kt,Ve]=(0,oe.useState)(""),[Qe,Oe]=(0,oe.useState)(null),[nt,Ot]=(0,oe.useState)(!1),ot=(0,oe.useRef)(0),We=(0,oe.useRef)(null),Ft=(0,oe.useRef)(!1),Kt=(0,oe.useRef)(l),Ht=(0,oe.useRef)(u);(0,oe.useEffect)(()=>{Kt.current=l},[l]),(0,oe.useEffect)(()=>()=>{Kt.current?.(!1)},[]),(0,oe.useEffect)(()=>{Ht.current=u},[u]),(0,oe.useEffect)(()=>()=>{Ht.current?.(!1)},[]);let Wt=(0,oe.useMemo)(()=>Ui({form:Me,agentType:N,tools:me,subAgents:E,prompt:Q,middleware:ye,graphDefinition:Hi(A?.graphDefinition)}),[Me,N,me,E,Q,ye,A?.graphDefinition]),At=nt&&Wt!==kt,sn=nt;Ft.current=At;let pt=(0,oe.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]),vn=(0,oe.useCallback)(b=>(b||[]).filter(j=>j.schema?.properties&&Object.keys(j.schema.properties).length>0||j.tools&&j.tools.length>0).map((j,ke)=>({id:`${j.type}-${ke+1}`,type:j.type,name:j.name,description:j.description,enabled:!1,config:{}})),[]),Ut=(0,oe.useCallback)((b,re)=>{let j=(re||[]).filter(M=>M.schema?.properties&&Object.keys(M.schema.properties).length>0||M.tools&&M.tools.length>0),ke=new Map(b?.map(M=>[M.type,M])||[]),k=j.map((M,De)=>{let Xe=ke.get(M.type);return Xe?{...Xe,name:M.name,description:M.description}:{id:`${M.type}-${De+1}`,type:M.type,name:M.name,description:M.description,enabled:!1,config:{}}}),I=new Set(j.map(M=>M.type));return[...k,...(b??[]).filter(M=>!I.has(M.type))]},[]),q=(0,oe.useCallback)(async()=>{if(n){ce(!0);try{let b=await f("/api/tools");b.success&&b.data?.records&&P(b.data.records)}catch(b){console.error("Failed to fetch tools:",b)}finally{ce(!1)}}},[f,n]);(0,oe.useEffect)(()=>{if(!n||!e){We.current=null,ot.current+=1,Ot(!1),R(e),Oe(null);return}if(We.current===e||We.current?.id===e.id&&Ft.current)return;let b=m.availableMiddlewareTypes;if(!(!b&&v)){We.current=e,ot.current+=1;{q();let re={name:e.name??"",description:e.description??""},j=pt?.tools??[],ke=pt?.subAgents??[],k=pt?.prompt??"",I=pt?.type??"react",M=pt?Ut(pt.middleware,b||g):vn(b||g);Ot(!1),R(e),tt(re),F(j),ae(ke),L(k),Ee(I),Se(M),y.setFieldsValue({...re,type:I}),Oe(Ui({form:re,agentType:I,tools:j,subAgents:ke,prompt:k,middleware:M,graphDefinition:Hi(e.graphDefinition)}))}}},[n,e,At,pt,y,q,vn,Ut,m.availableMiddlewareTypes,v,g]),(0,oe.useEffect)(()=>{Qe!==null&&Wt===Qe&&(Ve(Qe),Oe(null),Ot(!0))},[Wt,Qe]),(0,oe.useEffect)(()=>{l?.(At)},[At,l]),(0,oe.useEffect)(()=>{Ht.current?.(ne||K)},[ne,K]);let ge=async()=>{if(!A||!sn)return;let b=ot.current,re=Wt;try{X(!0);let ke={...await y.validateFields(),type:N,tools:me,subAgents:E,prompt:Q,middleware:ye};await r?.(A,ke),ot.current===b&&Ve(re)}catch(j){j instanceof Error&&rt.error(j.message)}finally{X(!1)}},st=async()=>{if(e){$(!0);try{await i?.(e),z(!1),o()}catch(b){z(!1),rt.error(b instanceof Error?b.message:"Failed to delete assistant")}finally{$(!1)}}},Ye=b=>{Se(re=>re.map(j=>{if(j.id!==b)return j;if(j.enabled)return{...j,enabled:!1};{let ke=(m.availableMiddlewareTypes||g)?.find(k=>k.type===j.type);return{...j,enabled:!0,config:ke?.defaultConfig||{}}}}))},Be=(b,re)=>{Se(j=>j.map(ke=>ke.id===b?{...ke,config:{...ke.config,...re}}:ke))},wt=(b,re)=>{Se(j=>j.map(ke=>ke.id===b?{...ke,allowedTools:re}:ke))},xt=b=>{let re=me.includes(b.id);return(0,h.jsx)(fo,{item:b,className:re?s.selectedCard:void 0,onClick:()=>F(j=>j.includes(b.id)?j.filter(ke=>ke!==b.id):[...j,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)($e,{color:"warning",style:{fontSize:10,padding:"0 4px",margin:0},children:"Approve"})]}),renderDetails:()=>(0,h.jsx)(_i,{text:b.description,className:s.toolDesc}),renderHeaderActions:()=>(0,h.jsx)(cn,{checked:re,onClick:j=>j.stopPropagation(),onChange:()=>F(j=>j.includes(b.id)?j.filter(ke=>ke!==b.id):[...j,b.id])})},b.id)},kn=b=>{let re=E.includes(b.id);return(0,h.jsx)(fo,{item:b,className:re?s.selectedCard:void 0,onClick:()=>ae(j=>j.includes(b.id)?j.filter(ke=>ke!==b.id):[...j,b.id]),renderIcon:()=>(0,h.jsx)(rr,{size:36,style:{backgroundColor:re?d.colorPrimary:d.colorSuccess,fontSize:15},children:b.name?.charAt(0).toUpperCase()||"A"}),renderPrimary:()=>b.name,renderSecondary:()=>b.description||"No description",renderHeaderActions:()=>(0,h.jsx)(cn,{checked:re,onClick:j=>j.stopPropagation(),onChange:()=>ae(j=>j.includes(b.id)?j.filter(ke=>ke!==b.id):[...j,b.id])})},b.id)},zn=(0,oe.useCallback)(b=>Zi(b.type,m.availableMiddlewareTypes||g)?.category||"other",[m.availableMiddlewareTypes,g]),ln=(0,oe.useMemo)(()=>{let b=new Map;for(let re of ye){let j=zn(re),ke=b.get(j);ke?ke.push(re):b.set(j,[re])}return b},[ye,zn]),no=(0,oe.useMemo)(()=>{let b=Array.from(ln.keys());return[...Ki.filter(re=>ln.has(re)),...b.filter(re=>!Ki.includes(re))]},[ln]),je=(0,oe.useMemo)(()=>ye.length===0?null:ye.find(b=>b.type===O)??ye.find(b=>b.enabled)??ye[0],[ye,O]);if(!n||!e)return null;let ve=[{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:ye.filter(b=>b.enabled).length},{key:"subagents",icon:(0,h.jsx)(ni,{}),label:"Sub-Agents",badge:E.length}],Bn=J.filter(b=>b.name.toLowerCase().includes(H.toLowerCase())||b.description.toLowerCase().includes(H.toLowerCase())),gt=t.filter(b=>b.id!==e.id),wn=gt.filter(b=>(b.name||"").toLowerCase().includes(be.toLowerCase())||(b.description||"").toLowerCase().includes(be.toLowerCase())),dn=()=>(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:y,layout:"vertical",autoComplete:"off",onValuesChange:(b,re)=>tt({name:re.name??"",description:re.description??""}),children:[(0,h.jsx)(pe.Item,{name:"name",label:(0,h.jsx)(It,{strong:!0,style:{fontSize:14},children:"Name"}),rules:[{required:!0,message:"Please enter agent name"}],style:{marginBottom:24},children:(0,h.jsx)(Pe,{placeholder:"Enter agent name\u2026"})}),(0,h.jsxs)(pe.Item,{name:"type",label:(0,h.jsx)(It,{strong:!0,style:{fontSize:14},children:"Agent Type"}),rules:[{required:!0}],style:{marginBottom:24},children:[(0,h.jsx)(qr,{value:N,onChange:b=>Ee(b),options:[{value:"react",label:"Executor"},{value:"deep_agent",label:"Orchestrator"},{value:"team",label:"Team"},{value:"processing",label:"Workflow"}],block:!0}),(0,h.jsx)(It,{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)(It,{strong:!0,style:{fontSize:14},children:"Description"}),rules:[{required:!0,message:"Please enter agent description"}],style:{marginBottom:0},children:(0,h.jsx)(Pe.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:()=>he(!0),children:"Expand"})]}),(0,h.jsx)(js,{"aria-label":"System Prompt",value:Q,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)(It,{type:"secondary",style:{fontSize:12},children:[Q.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)(Pe,{allowClear:!0,prefix:(0,h.jsx)(sr,{}),placeholder:"Search tools\u2026",value:H,onChange:b=>ue(b.target.value),className:s.searchBox}),(0,h.jsxs)(It,{type:"secondary",style:{fontSize:13},children:["Selected ",me.length," / ",J.length]}),(0,h.jsx)(ee,{size:"small",onClick:()=>F(me.length===J.length?[]:J.map(b=>b.id)),children:me.length===J.length?"Clear":"Select All"})]})]}),B?(0,h.jsx)("div",{style:{textAlign:"center",padding:60},children:(0,h.jsx)(Tt,{})}):Bn.length===0?(0,h.jsx)(_t,{description:"No tools available",style:{padding:60}}):(0,h.jsx)("div",{className:s.cardGrid,children:Bn.map(xt)})]}),tr=()=>je?(0,h.jsx)(Ro,{middleware:je,middlewareType:Zi(je.type,m.availableMiddlewareTypes||g),onToggle:()=>Ye(je.id),onConfigChange:b=>Be(je.id,b),onAllowedToolsChange:b=>wt(je.id,b)},je.id):(0,h.jsx)(_t,{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)(Pe,{allowClear:!0,prefix:(0,h.jsx)(sr,{}),placeholder:"Search sub-agents\u2026",value:be,onChange:b=>Ie(b.target.value),className:s.searchBox}),(0,h.jsxs)(It,{type:"secondary",style:{fontSize:13},children:["Selected ",E.length," / ",gt.length]}),(0,h.jsx)(ee,{size:"small",onClick:()=>ae(E.length===gt.length?[]:gt.map(b=>b.id)),children:E.length===gt.length?"Clear":"Select All"})]})]}),gt.length===0?(0,h.jsx)(_t,{description:"No other agents available",style:{padding:60}}):wn.length===0?(0,h.jsx)(_t,{description:"No matching results",style:{padding:60}}):(0,h.jsx)("div",{className:s.cardGrid,children:wn.map(kn)})]}),or={basic:dn(),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:d.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)($e,{color:"blue",style:{margin:0,fontSize:11,flexShrink:0},children:"Config Workbench"})]}),(0,h.jsxs)(Et,{children:[i&&(0,h.jsx)(Qt,{title:"Delete Agent",children:(0,h.jsx)(ee,{"aria-label":"Delete Agent",type:"text",danger:!0,icon:(0,h.jsx)(so,{}),onClick:()=>z(!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:ve.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:()=>S(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:d.colorPrimary}})]},b.key):(0,h.jsxs)(oe.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:d.colorPrimary}})]}),C&&(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}),ln.get(re)?.map(j=>(0,h.jsxs)("button",{type:"button",role:"option","aria-selected":w==="middleware"&&O===j.type,className:`${p.navSubItem} ${w==="middleware"&&O===j.type?"active":""}`,onClick:()=>{_(j.type),S("middleware")},children:[(0,h.jsx)("span",{className:p.navStatusDot,style:{backgroundColor:j.enabled?d.colorSuccess:d.colorBorder}}),(0,h.jsx)("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:j.name})]},j.id))]},re))})]},"middleware"))}),(0,h.jsx)("div",{className:s.content,children:sn?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)(Tt,{}),(0,h.jsx)(It,{type:"secondary",children:"Loading agent configuration..."})]})})})]}),(0,h.jsxs)("div",{className:s.footer,children:[(0,h.jsx)(It,{"data-testid":"config-footer-hint",className:s.footerHint,type:At?"warning":"secondary",children:At?"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:!sn,onClick:ge,children:"Save"})]})]})]}),(0,h.jsx)(Fe,{title:"System Prompt",open:ne,onCancel:()=>he(!1),width:800,footer:[(0,h.jsx)(ee,{onClick:()=>he(!1),children:"Close"},"cancel"),(0,h.jsx)(ee,{type:"primary",onClick:()=>he(!1),children:"Done"},"done")],children:(0,h.jsx)(Pe.TextArea,{"aria-label":"System Prompt",value:Q,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:K,onCancel:()=>z(!1),footer:[(0,h.jsx)(ee,{onClick:()=>z(!1),children:"Cancel"},"cancel"),(0,h.jsx)(ee,{type:"primary",danger:!0,loading:D,onClick:st,children:"Delete"},"delete")],children:(0,h.jsxs)(It,{children:["Are you sure you want to delete ",(0,h.jsx)(It,{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 Je=T(Te());function Io(e,t){return e.find(n=>n.targetServerConfig?.targetAgentId===t)??e.find(n=>n.name===`eval-${t}`)??e.find(n=>typeof n.description=="string"&&n.description.includes(t))??null}var fe=T(W()),{Text:qs}=_e,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(),c=Io(r,e),l=c?.id??"",u=c?.name||`eval-${e}`,y=Ks(t),d=`${y.page}\0${y.suiteId}\0${y.runId}`,[s,p]=(0,Je.useState)(y),{page:m,suiteId:g,runId:v}=s;(0,Je.useEffect)(()=>{p(y)},[e,d,n]);let{start:f}=go(l),{workspaceId:w,projectId:S}=Pt(),[A,R]=(0,Je.useState)(!1),{create:O}=Sn(l),[_,C]=(0,Je.useState)(!1),[x,B]=(0,Je.useState)(""),[ce,V]=(0,Je.useState)(0),[X,D]=(0,Je.useState)(!1),[$]=pe.useForm(),[K,z]=(0,Je.useState)(!1),[J,P]=(0,Je.useState)([]),H=yt("__GLOBAL__"),ue=(0,Je.useRef)(o);ue.current=o;let be=L=>({workspaceId:w||void 0,projectId:L||S||void 0}),Ie=(0,Je.useCallback)(async()=>{let L=H,ne=L.config?.baseURL||L.baseUrl||"";try{let N=await(await fetch(`${ne}/api/models`,{headers:{Authorization:`Bearer ${L.config?.apiKey||""}`}})).json();N.success&&P(N.data||[])}catch{}},[H]),me=async L=>{z(!0);try{await a({name:`eval-${e}`,judgeModelConfig:{modelKey:L.modelKey||""},targetServerConfig:{base_url:"",api_key:"",targetAgentId:e}}),await Promise.resolve(ue.current?.()).catch(()=>{}),$.resetFields(),D(!1)}catch(ne){rt.error(ne instanceof Error?ne.message:"Failed to create eval project")}finally{z(!1)}},F=(L,ne,he)=>{p(N=>({page:L,suiteId:ne??N.suiteId,runId:he??N.runId}))},E=async()=>{x.trim()&&(await O(l,{name:x.trim()}),V(L=>L+1),await o?.(),B(""),C(!1))},ae=async L=>{let ne=await f(l,be(L.projectId));ne?.run_id&&(await Promise.resolve(o?.()).catch(()=>{}),F("run",void 0,ne.run_id))},Q=(0,fe.jsx)(Fe,{title:"Create Eval Project",open:X,onCancel:()=>{$.resetFields(),D(!1)},footer:null,destroyOnHidden:!0,width:480,children:(0,fe.jsxs)(pe,{form:$,layout:"vertical",onFinish:me,initialValues:{name:`eval-${e}`},children:[(0,fe.jsx)(pe.Item,{name:"name",label:"Project Name",children:(0,fe.jsx)(Pe,{disabled:!0})}),(0,fe.jsx)(pe.Item,{name:"modelKey",label:"Judge Model",rules:[{required:!0,message:"Please select a judge model"}],children:(0,fe.jsx)(mt,{placeholder:"Select a registered model",options:J.map(L=>{let ne=L;return{value:ne.key,label:`${ne.displayName||ne.key} (${ne.model||""})`}})})}),(0,fe.jsxs)(pe.Item,{style:{marginBottom:0,textAlign:"right"},children:[(0,fe.jsx)(ee,{onClick:()=>{$.resetFields(),D(!1)},style:{marginRight:8},children:"Cancel"}),(0,fe.jsx)(ee,{type:"primary",htmlType:"submit",loading:K,children:"Create"})]})]})});return i?(0,fe.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,fe.jsx)(Tt,{})}):c?(0,fe.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",background:"#f5f5f5"},children:[(0,fe.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 24px",background:"#fff",borderBottom:"1px solid #f0f0f0",flexShrink:0},children:[(0,fe.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,fe.jsx)(ti,{style:{color:"#6366f1",fontSize:18}}),(0,fe.jsx)("span",{style:{fontSize:15,fontWeight:600},children:u}),(0,fe.jsx)($e,{color:"purple",children:"eval"})]}),m==="suites"&&(0,fe.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,fe.jsx)(ee,{icon:(0,fe.jsx)(Yt,{}),onClick:()=>C(L=>!L),children:"New Suite"}),(0,fe.jsx)(ee,{type:"primary",icon:(0,fe.jsx)(Xr,{}),onClick:()=>R(!0),children:"Run All"})]})]}),m==="suites"&&_&&(0,fe.jsxs)("div",{style:{padding:"12px 24px",borderBottom:"1px solid #f0f0f0",display:"flex",gap:8,background:"#fff"},children:[(0,fe.jsx)("input",{type:"text",placeholder:"Suite name",value:x,onChange:L=>B(L.target.value),onKeyDown:L=>L.key==="Enter"&&void E(),autoFocus:!0,style:{width:260,padding:"6px 12px",border:"1px solid #d9d9d9",borderRadius:8,fontSize:14,outline:"none"}}),(0,fe.jsx)(ee,{type:"primary",size:"small",onClick:()=>void E(),children:"Create"}),(0,fe.jsx)(ee,{size:"small",onClick:()=>C(!1),children:"Cancel"})]}),(0,fe.jsxs)("div",{style:{flex:1,overflow:"auto",padding:28},children:[m==="suites"&&(0,fe.jsx)(Ii,{projectId:l,onSelectSuite:(L,ne)=>F("suite",ne),onEvalInvalidated:o},`${l}:${ce}`),m==="suite"&&g&&(0,fe.jsx)(Ai,{projectId:l,suiteId:g,onBack:()=>F("suites"),onRun:L=>{Promise.resolve(o?.()).catch(()=>{}),F("run",void 0,L)},onEvalInvalidated:o}),m==="run"&&v&&(0,fe.jsx)(Ei,{runId:v,onBack:()=>F("suites"),onRunSettled:o})]}),(0,fe.jsx)(Ci,{open:A,onClose:()=>R(!1),onRun:ae})]}):(0,fe.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,background:"#fff"},children:[(0,fe.jsx)(_t,{description:(0,fe.jsx)(qs,{type:"secondary",children:"This agent has no eval project yet"})}),(0,fe.jsx)(ee,{type:"primary",icon:(0,fe.jsx)(Yt,{}),onClick:()=>{Ie(),D(!0)},children:"Create eval project"}),Q]})};var Le=T(Te());var Hn=T(Te());var Z=T(W()),{Text:un}=_e,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:c,onSubmit:l})=>{let[u]=pe.useForm(),[y,d]=(0,Hn.useState)(!1),[s,p]=(0,Hn.useState)(!1);(0,Hn.useEffect)(()=>{if(!e)return;let f=n?.features??Qi;d(f.projectSelector),p(f.modelSelector),u.setFieldsValue({name:n?.name??"",description:n?.description,defaultProjectId:n?.scope.defaultProjectId??o[0]?.id,allowedProjectIds:n?.scope.allowedProjectIds??(o[0]?[o[0].id]:[]),defaultModelKey:n?.scope.defaultModelKey,allowedModelKeys:n?.scope.allowedModelKeys,...f,title:n?.appearance.title,welcomeMessage:n?.appearance.welcomeMessage,primaryColor:n?.appearance.primaryColor,quickPrompts:n?.appearance.quickPrompts,identityPolicy:n?.identity?.policy??"unverified",identityIssuers:n?.identity?JSON.stringify(n.identity.issuers,null,2):void 0})},[u,e,o,n]);let m=async()=>{let f=await u.validateFields(),w=f.projectSelector?Array.from(new Set(f.allowedProjectIds??[])):[f.defaultProjectId],S=f.modelSelector?Array.from(new Set([...f.defaultModelKey?[f.defaultModelKey]:[],...f.allowedModelKeys??[]])):f.defaultModelKey?[f.defaultModelKey]:void 0,A,R=f.identityPolicy??"unverified";if(R!=="unverified"){let C;try{C=JSON.parse(f.identityIssuers??"")}catch{throw new Error("Trusted issuers must be a valid JSON array")}if(!Array.isArray(C)||C.length===0)throw new Error("Verified identity requires at least one trusted issuer");A={policy:R,issuers:C}}let O=(f.quickPrompts??[]).map(C=>({label:(C?.label??"").trim(),text:(C?.text??"").trim()})).filter(C=>C.label.length>0&&C.text.length>0),_={name:f.name.trim(),description:f.description?.trim()||void 0,scope:{defaultProjectId:f.defaultProjectId,allowedProjectIds:w,defaultModelKey:f.defaultModelKey||void 0,allowedModelKeys:S},features:{projectSelector:f.projectSelector,modelSelector:f.modelSelector,threadManagement:f.threadManagement,attachments:f.attachments,hitl:f.hitl,genUI:f.genUI,files:f.files??!1},appearance:{title:f.title?.trim()||void 0,welcomeMessage:f.welcomeMessage?.trim()||void 0,primaryColor:f.primaryColor?.trim()||void 0,...O.length>0?{quickPrompts:O}:{}},identity:A};await l(n?_:{..._,assistantId:t,integration:{type:"react_sdk"}})},g=o.map(f=>({value:f.id,label:f.name})),v=r.map(f=>({value:f.key,label:f.displayName??f.model??f.key}));return(0,Z.jsxs)(Fe,{title:n?"Edit Web App":"Create Web App",open:e,onCancel:c,onOk:()=>void m().catch(()=>{}),okText:n?"Save":"Create",confirmLoading:i,width:720,destroyOnHidden:!0,children:[a&&(0,Z.jsx)("div",{role:"alert",style:{color:"#ef4444",marginBottom:12},children:a}),(0,Z.jsxs)(pe,{form:u,layout:"vertical",initialValues:Qi,children:[(0,Z.jsx)(pe.Item,{name:"name",label:"Name",rules:[{required:!0,whitespace:!0},{max:120,message:"Name must be 120 characters or fewer"}],children:(0,Z.jsx)(Pe,{"aria-label":"Name",maxLength:121})}),(0,Z.jsx)(pe.Item,{name:"description",label:"Description",rules:[{max:1e3,message:"Description must be 1000 characters or fewer"}],children:(0,Z.jsx)(Pe.TextArea,{"aria-label":"Description",maxLength:1001})}),(0,Z.jsx)(un,{strong:!0,children:"Project scope"}),(0,Z.jsx)(pe.Item,{name:"projectSelector",valuePropName:"checked",children:(0,Z.jsx)(cn,{"aria-label":"Project selector",onChange:f=>d(f.target.checked),children:"Project selector"})}),(0,Z.jsx)(pe.Item,{name:"allowedProjectIds",label:"Allowed projects",dependencies:["defaultProjectId","projectSelector"],rules:y?[{required:!0,message:"Select at least one project"},{validator:(f,w)=>(w??[]).every(S=>g.some(A=>A.value===S))?Promise.resolve():Promise.reject(new Error("Select valid allowed projects"))},{validator:(f,w)=>(w??[]).includes(u.getFieldValue("defaultProjectId"))?Promise.resolve():Promise.reject(new Error("Default project must be in allowed projects"))}]:void 0,children:(0,Z.jsx)(mt,{"aria-label":"Allowed projects",mode:"multiple",disabled:!y,options:g})}),(0,Z.jsx)(pe.Item,{name:"defaultProjectId",label:"Default project",rules:[{required:!0},{validator:(f,w)=>!w||g.some(S=>S.value===w)?Promise.resolve():Promise.reject(new Error("Select a valid default project"))}],children:(0,Z.jsx)(mt,{"aria-label":"Default project",options:g})}),(0,Z.jsx)(un,{strong:!0,children:"Model scope (optional)"}),(0,Z.jsx)(pe.Item,{name:"modelSelector",valuePropName:"checked",children:(0,Z.jsx)(cn,{"aria-label":"Model selector",onChange:f=>p(f.target.checked),children:"Model selector"})}),(0,Z.jsx)(pe.Item,{name:"allowedModelKeys",label:"Allowed models",dependencies:["defaultModelKey","modelSelector"],rules:s?[{validator:(f,w)=>w?.length||u.getFieldValue("defaultModelKey")?Promise.resolve():Promise.reject(new Error("Select at least one model"))},{validator:(f,w)=>(w??[]).every(S=>v.some(A=>A.value===S))?Promise.resolve():Promise.reject(new Error("Select valid allowed models"))}]:void 0,children:(0,Z.jsx)(mt,{"aria-label":"Allowed models",mode:"multiple",allowClear:!0,disabled:!s,options:v})}),(0,Z.jsx)(pe.Item,{name:"defaultModelKey",label:"Default model",rules:[{validator:(f,w)=>!w||v.some(S=>S.value===w)?Promise.resolve():Promise.reject(new Error("Select a valid default model"))}],children:(0,Z.jsx)(mt,{"aria-label":"Default model",allowClear:!0,options:v})}),(0,Z.jsx)(un,{strong:!0,children:"Features"}),(0,Z.jsx)(Et,{wrap:!0,children:["threadManagement","attachments","hitl","genUI","files"].map(f=>(0,Z.jsx)(pe.Item,{name:f,valuePropName:"checked",noStyle:!0,children:(0,Z.jsx)(cn,{"aria-label":f,children:f})},f))}),(0,Z.jsx)("div",{style:{marginTop:20},children:(0,Z.jsx)(un,{strong:!0,children:"Appearance"})}),(0,Z.jsx)(pe.Item,{name:"title",label:"Title",rules:[{max:120,message:"Title must be 120 characters or fewer"}],children:(0,Z.jsx)(Pe,{"aria-label":"Title",maxLength:121})}),(0,Z.jsx)(pe.Item,{name:"welcomeMessage",label:"Welcome message",rules:[{max:1e3,message:"Welcome message must be 1000 characters or fewer"}],children:(0,Z.jsx)(Pe.TextArea,{"aria-label":"Welcome message",maxLength:1001})}),(0,Z.jsx)(pe.Item,{name:"primaryColor",label:"Primary color",rules:[{pattern:/^#[0-9A-Fa-f]{6}$/,message:"Use a #RRGGBB color",transform:f=>f||void 0}],children:(0,Z.jsx)(Pe,{"aria-label":"Primary color",placeholder:"#6366f1"})}),(0,Z.jsx)("div",{style:{marginTop:12},children:(0,Z.jsx)(un,{strong:!0,children:"Quick prompts"})}),(0,Z.jsx)(pe.List,{name:"quickPrompts",children:(f,{add:w,remove:S})=>(0,Z.jsxs)(Z.Fragment,{children:[f.map(A=>(0,Z.jsxs)(Et,{align:"baseline",style:{display:"flex",marginBottom:8},children:[(0,Z.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,Z.jsx)(Pe,{"aria-label":`Quick prompt label ${A.name+1}`,placeholder:"Label",maxLength:41})}),(0,Z.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,Z.jsx)(Pe,{"aria-label":`Quick prompt message ${A.name+1}`,placeholder:"Message text",maxLength:501,style:{width:360}})}),(0,Z.jsx)(ee,{"aria-label":`Remove quick prompt ${A.name+1}`,onClick:()=>S(A.name),children:"Remove"})]},A.key)),(0,Z.jsx)(ee,{"aria-label":"Add quick prompt",onClick:()=>w({label:"",text:""}),disabled:f.length>=6,children:"Add quick prompt"})]})}),(0,Z.jsx)("div",{style:{marginTop:20},children:(0,Z.jsx)(un,{strong:!0,children:"Identity"})}),(0,Z.jsx)(pe.Item,{name:"identityPolicy",label:"Identity policy",initialValue:"unverified",children:(0,Z.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,Z.jsx)(pe.Item,{name:"identityIssuers",label:"Trusted issuers (JSON)",tooltip:'Required when the policy includes verified tokens. Example: [{"iss":"https://host.example.com","aud":"<webAppId>","alg":"HS256","secret":"..."}]',dependencies:["identityPolicy"],rules:[{validator:(f,w)=>{if(u.getFieldValue("identityPolicy")==="unverified"||w===void 0||w.trim()==="")return Promise.resolve();try{let S=JSON.parse(w);return Array.isArray(S)&&S.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,Z.jsx)(Pe.TextArea,{"aria-label":"Trusted issuers",rows:3,placeholder:'[{"iss":"https://host.example.com","aud":"<webAppId>","alg":"HS256","secret":"..."}]'})}),(0,Z.jsx)(un,{type:"secondary",children:"Integration type: react_sdk"})]})]})};var ie=T(W()),{Text:Co}=_e,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,c]=(0,Le.useState)([]),[l,u]=(0,Le.useState)([]),[y,d]=(0,Le.useState)(!1),[s,p]=(0,Le.useState)(null),[m,g]=(0,Le.useState)(null),[v,f]=(0,Le.useState)(null),[w,S]=(0,Le.useState)(!1),[A,R]=(0,Le.useState)(null),[O,_]=(0,Le.useState)(!1),[C,x]=(0,Le.useState)(!1),[B,ce]=(0,Le.useState)(null),[V,X]=(0,Le.useState)(null),D=(0,Le.useRef)(0),$=(0,Le.useRef)(0),K=(0,Le.useRef)(0),z=(0,Le.useRef)(!1),J=Array.from(new Map(i.map(F=>[F.id,F])).values()),P=(0,Le.useCallback)(async()=>{let F=++D.current;d(!0),p(null);try{let E=await t.webApps.list({assistantId:e.id});F===D.current&&c(E.records)}catch(E){F===D.current&&p(Un(E))}finally{F===D.current&&d(!1)}},[e.id,t,o?.id]);(0,Le.useEffect)(()=>(c([]),g(null),R(null),ce(null),X(null),S(!1),_(!1),x(!1),z.current=!1,K.current+=1,P(),()=>{D.current+=1,K.current+=1}),[P]),(0,Le.useEffect)(()=>{let F=++$.current;return t.request("/api/models").then(E=>{F===$.current&&u(E.data??[])}).catch(()=>{F===$.current&&u([])}),()=>{$.current+=1}},[t]);let H=async F=>{if(z.current)return;z.current=!0,x(!0);let E=++K.current;p(null);try{await F(),E===K.current&&await P()}catch(ae){E===K.current&&p(Un(ae))}finally{E===K.current&&(z.current=!1,x(!1))}},ue=async F=>{if(z.current)return;z.current=!0,x(!0);let E=++K.current;S(!0),f(null);try{m==="create"?await t.webApps.create(F):m&&await t.webApps.update(m.id,F),E===K.current&&(g(null),await P())}catch(ae){E===K.current&&f(Un(ae))}finally{E===K.current&&(z.current=!1,x(!1),S(!1))}},be=async F=>{p(null);try{if(!navigator.clipboard)throw new Error("Clipboard unavailable");await navigator.clipboard.writeText(F)}catch(E){p(Un(E))}},Ie=F=>[{key:"edit",icon:yi,label:"Edit",disabled:C,onClick:g},{key:"toggle",icon:F.status==="active"?ii:si,label:F.status==="active"?"Disable":"Enable",disabled:C,onClick:E=>void H(()=>E.status==="active"?t.webApps.disable(E.id):t.webApps.enable(E.id))},{key:"preview",icon:pi,label:"Preview",disabled:C,onClick:ce},{key:"guide",icon:di,label:"Integration guide",disabled:C,onClick:X},{key:"copy",icon:li,label:"Copy Web App ID",disabled:C,onClick:E=>void be(E.id)},{key:"delete",icon:ki,label:"Delete",danger:!0,disabled:C,onClick:R}],me=async()=>{if(!A||z.current)return;z.current=!0,x(!0);let F=++K.current;_(!0);try{await t.webApps.delete(A.id),F===K.current&&(R(null),await P())}catch(E){F===K.current&&p(Un(E))}finally{F===K.current&&(z.current=!1,x(!1),_(!1))}};return(0,ie.jsxs)("div",{style:{height:"100%",overflow:"auto",padding:16},children:[(0,ie.jsx)(Vt,{type:"warning",showIcon:!0,message:"Unverified identity",description:"Web Apps trust the external user ID supplied by the embedding application. Do not use it as proof of authentication.",style:{marginBottom:16}}),s&&(0,ie.jsx)(Vt,{role:"alert",type:"error",message:s,action:(0,ie.jsx)(ee,{size:"small",onClick:()=>void P(),children:"Retry"}),style:{marginBottom:16}}),(0,ie.jsx)(Si,{title:"Web Apps",itemName:"app",items:a,loading:y,keyExtractor:F=>F.id,createLabel:C?void 0:"Create Web App",onCreateClick:C?void 0:()=>{f(null),g("create")},renderIcon:()=>(0,ie.jsx)(ui,{size:22,color:"#6366f1"}),renderPrimary:F=>F.name,renderSecondary:F=>F.description??F.id,renderHeaderActions:F=>(0,ie.jsx)($e,{color:F.status==="active"?"green":F.status==="disabled"?"default":"gold",children:F.status}),renderDetails:F=>(0,ie.jsxs)(Co,{type:"secondary",children:[F.scope.allowedProjectIds.length," project",F.scope.allowedProjectIds.length===1?"":"s"," \xB7 react_sdk"]}),itemActions:Ie,actionsPosition:"always",showViewToggle:!1,emptyTitle:"No Web Apps",emptyDescription:"Create a React SDK publication for this agent."}),(0,ie.jsx)(Yi,{open:m!==null,assistantId:e.id,value:m==="create"?null:m,projects:J,models:l,submitting:w,error:v,onCancel:()=>g(null),onSubmit:ue}),(0,ie.jsx)(Fe,{title:"Delete Web App",open:A!==null,onCancel:()=>R(null),onOk:()=>void me(),okText:"Delete",okButtonProps:{danger:!0,loading:O},children:(0,ie.jsxs)("p",{children:["Delete \u201C",A?.name,"\u201D? This action cannot be undone."]})}),(0,ie.jsx)(Fe,{title:"Preview",open:B!==null,onCancel:()=>ce(null),footer:(0,ie.jsx)(ee,{onClick:()=>ce(null),children:"Close"}),width:900,children:r?B&&B.status==="active"?(0,ie.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,ie.jsxs)("div",{children:[(0,ie.jsx)(Vt,{type:"info",showIcon:!0,message:"Draft preview",description:"This renders the in-page console chat so you can inspect draft content. Enable the publication to preview the exact embed experience external users get.",style:{marginBottom:16}}),(0,ie.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,ie.jsx)(Vt,{type:"warning",message:"Gateway URL unavailable"})}),(0,ie.jsx)(Fe,{title:"Integration guide",open:V!==null,onCancel:()=>X(null),footer:(0,ie.jsxs)(Et,{children:[(0,ie.jsx)(ee,{onClick:()=>V&&void be(Object.values(Zn(V,r)).join(`
|
|
230
|
+
|
|
231
|
+
`)),children:"Copy examples"}),(0,ie.jsx)(ee,{type:"primary",onClick:()=>X(null),children:"Close"})]}),width:900,children:V&&(0,ie.jsx)($r,{defaultActiveKey:"zero-code",items:[{key:"zero-code",label:"Zero-code script loader",children:(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)(_e.Paragraph,{type:"secondary",style:{marginTop:0},children:"One script tag \u2014 the full Console-style chat runs in an isolated iframe on the gateway origin. No build step, no npm install."}),(0,ie.jsx)("pre",{style:Ao,children:Zn(V,r).embed}),(0,ie.jsx)(_e.Title,{level:5,style:{marginTop:24},children:"Configuration \u2014 window.AxiomChatSettings"}),(0,ie.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,ie.jsx)(_e.Title,{level:5,children:"JS API \u2014 window.AxiomChat"}),(0,ie.jsxs)(_e.Paragraph,{type:"secondary",children:["Property and command forms are equivalent; register callbacks or actions before the loader loads with the array form (",'window.AxiomChat = [["onMessage", fn], ["open"]]'," \u2014 replayed in order on load)."]}),(0,ie.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,ie.jsx)(_e.Title,{level:5,children:"Events"}),(0,ie.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,ie.jsx)(Vt,{style:{marginTop:8},type:"warning",showIcon:!0,message:"Host trust and limits",description:"The host page can send messages and read new conversation content \u2014 only embed on trusted pages. One streaming reply at a time; loading the loader twice is unsupported. Not available yet: unread callbacks, runtime theme updates, verified setIdentity, token-level streaming events."})]})},{key:"npm-sdk",label:"npm SDK",children:(0,ie.jsxs)(ie.Fragment,{children:[(0,ie.jsx)(_e.Paragraph,{type:"secondary",style:{marginTop:0},children:"React applications \u2014 the same chat stack as a first-class component in your page, fully composable."}),(0,ie.jsx)(Co,{strong:!0,children:"Full chat \u2014 AgentChatApp"}),(0,ie.jsx)("pre",{style:Ao,children:Zn(V,r).agentChat}),(0,ie.jsx)(Co,{strong:!0,children:"Composable widgets"}),(0,ie.jsx)("pre",{style:Ao,children:Zn(V,r).composable}),(0,ie.jsx)(Co,{strong:!0,children:"Hooks"}),(0,ie.jsx)("pre",{style:Ao,children:Zn(V,r).hooks})]})}]})})]})};var G=T(Te());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 c=typeof a.config=="object"&&a.config!==null?a.config:{};c.readAll===!0&&(r=!0);for(let l of Eo(c.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=(g,v,f,w,S)=>({id:v,type:g,label:f,description:w,config:S}),c=Eo(n.tools).map(g=>a("tool",`tool:${g}`,g)),l=(Array.isArray(n.middleware)?n.middleware:[]).filter(g=>g.enabled!==!1).map(g=>{let v=typeof g.type=="string"?g.type:"unknown";return a("capability",`cap:${v}`,g.name||v,g.description||void 0,g)}),u=Eo(n.subAgents).map(g=>a("subagent",`sub:${g}`,g)),{ids:y,readAll:d}=Xs(n),s=[...d?[a("skill",mr,"All skills","Agent can load any available skill")]:[],...y.map(g=>a("skill",`skill:${g}`,g))],p=[{id:"group:tools",type:"tool",label:"Tools",items:c},{id:"group:capabilities",type:"capability",label:"Capabilities",items:l},{id:"group:subagents",type:"subagent",label:"Sub-Agents",items:u},{id:"group:skills",type:"skill",label:"Skills",items:s}],m=t?.includeEmptyGroups?p:p.filter(g=>g.items.length>0);return{agent:i,groups:m}}var ea=T(W()),Vn=({id:e,position:t,type:n="source"})=>(0,ea.jsx)(Rt,{id:e,type:n,position:t,style:{opacity:0,width:0,height:0,border:"none"},isConnectable:!1});var Xt=T(W()),Do={agent:(0,Xt.jsx)($n,{size:14}),tool:(0,Xt.jsx)(wi,{size:12}),capability:(0,Xt.jsx)(ai,{size:12}),subagent:(0,Xt.jsx)($n,{size:12}),skill:(0,Xt.jsx)(gi,{size:12}),model:(0,Xt.jsx)(ci,{size:12}),eval:(0,Xt.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)($e,{bordered:!1,style:{margin:0,fontSize:10,background:`${o}1A`,color:o},children:r.type??"capability"}),r.modelKey&&(0,xe.jsx)($e,{bordered:!1,style:{margin:0,fontSize:10},children:r.modelKey}),r.version&&(0,xe.jsxs)($e,{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(Te());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(m=>Number.isFinite(m.avgScore)&&Number.isFinite(new Date(m.createdAt).getTime())).sort(zt),r=o.filter(m=>m.status==="completed"&&!m.holdout),i=r[r.length-1],a=i?.envProjectId!==void 0,l=(a?r.filter(m=>m.envProjectId===i.envProjectId):r).map(ia),u=o.filter(m=>m.status==="completed"&&m.holdout).map(ia),y=l[l.length-1],d=l[l.length-2],s=y&&d?y.score-d.score:null,p="needs-evidence";return s!==null&&(p=s>n?"improving":s<-n?"regressed":"stable"),{verdict:p,latest:y,previous:d,delta:s,passRate:y?.passRate??null,comparisonLabel:a?"Latest comparable result":"Latest recorded result",trend:l,validationTrend:u,runningRuns:o.filter(m=>m.status==="running"),failedRuns:o.filter(m=>m.status==="failed"||m.status==="aborted")}}var Bt=T(Te()),sa=T(W()),pn=({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 c=r.current;if(!c||!n)return;let l=Object.entries(n);for(let[u,y]of l)c.on(u,y);return()=>{for(let[u,y]of l)c.off(u,y)}},[n]),(0,Bt.useEffect)(()=>{let c=!1,l=null;return(async()=>{let u=await import("./embed-page-echarts-7KZDMH4F.js");if(c||!o.current)return;let y=u.init(o.current);r.current=y,y.setOption(i.current,!0);let d=a.current;if(d)for(let[s,p]of Object.entries(d))y.on(s,p);l=new ResizeObserver(()=>r.current?.resize()),l.observe(o.current)})().catch(u=>{console.error("[EChart] async init failed:",u)}),()=>{c=!0,l?.disconnect(),r.current?.dispose(),r.current=null}},[]),(0,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}=Ze(),[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,c=!0,l=()=>c&&r.current===a&&i.current===e;return o(u=>({...u,loading:!0,error:null})),(async()=>{try{let u=await t(`/api/assistants/${e}/threads`);if(!yr(u)||u.success!==!0||!yr(u.data))throw new Error("Invalid thread list response");let{records:y,total:d}=u.data;if(!Array.isArray(y)||typeof d!="number"||!Number.isSafeInteger(d)||d<0)throw new Error("Invalid thread list response");let s=Date.now(),p=new Date(s),m=null,g=0,v=0,f=new Array(7).fill(0),w=new Array(30).fill(0);for(let S of y){if(!yr(S))continue;let A=da(S.createdAt,s);if(A!==null){let O=el(p,new Date(A));O>=0&&O<7&&(g++,f[6-O]++),O>=0&&O<30&&(v++,w[29-O]++)}let R=da(S.updatedAt,s);R!==null&&(m===null||R>m)&&(m=R)}if(!l())return;o({total:d,last7d:g,last30d:v,lastActive:m===null?null:new Date(m),daily7d:f,daily30d:w,loading:!1,error:null})}catch(u){if(!l())return;o({...la,loading:!1,error:u instanceof Error?u:new Error("Failed to load thread activity")})}})(),()=>{c=!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:c,loading:l,error:u,refresh:y}=Sn(a),{runs:d,inventoryProjectId:s,loading:p,error:m,refresh:g}=go(a),v=(0,jt.useCallback)(async()=>{await Promise.all([r(),y(),g()])},[r,y,g]);return{...(0,jt.useMemo)(()=>{let w=c.reduce((_,C)=>_+(C.caseCount??0),0),S=s===a?d.filter(_=>_.projectId===a):[],A=[...S].sort(zt),R=aa(S),O=R.latest?S.find(_=>_.id===R.latest?.runId):void 0;return{evalProjectId:i?.id,inventoryProjectId:s,suiteCount:c.length,caseCount:w,scores:R.trend.map(_=>_.score),latest:O,runs:A,runCount:S.length,passRate:R.passRate,score:R.latest?.score??null,hasEvalProject:!!i,suiteNames:c.map(_=>_.name??"Unnamed").filter(Boolean),error:o??u??m,loading:!!(n||a&&(s!==a||l||p))}},[c,d,s,i,a,n,l,p,o,u,m]),refresh:v,refreshRuns:g}}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(Te());var gn=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,c=a>4?1:0,l=2;return(0,gn.jsx)("svg",{width:t,height:n,style:{display:"block"},children:e.map((u,y)=>{let d=Math.max(u/i*n,l);return(0,gn.jsx)("rect",{x:y*a,y:n-d,width:Math.max(a-c,1),height:d,fill:u===0?r:o,rx:1},y)})})},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,c=2,l=t-c*2,u=s=>e.length===1?t/2:c+s/(e.length-1)*l,y=s=>n-2-(s-r)/a*(n-4),d=e.map((s,p)=>`${u(p)},${y(s)}`).join(" ");return(0,gn.jsxs)("svg",{width:t,height:n,style:{display:"block"},children:[(0,gn.jsx)("polyline",{points:d,fill:"none",stroke:o,strokeWidth:"1.5",strokeLinecap:"round"}),e.map((s,p)=>(0,gn.jsx)("circle",{cx:u(p),cy:y(s),r:"2.5",fill:o},p))]})};var ze=T(Te());var en=T(Te());var Mo=T(Te());var Jt=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 c=t.map(d=>({uid:d.uri,name:d.name||d.uri,status:"done",response:{uri:d.uri,name:d.name}})),l=async d=>{let s=d.file;try{let p=await o(e,"/project/uploads",s);d.onSuccess?.({uri:p.path,name:s.name,projectId:e})}catch(p){d.onError?.(p instanceof Error?p:new Error("Upload failed"))}},u=d=>{let{file:s}=d;if(s.status==="done"&&s.response?.uri){if(s.response.projectId&&s.response.projectId!==a.current){i(d.fileList.filter(m=>m.status==="uploading"||m.status==="error"));return}let p={uri:s.response.uri,name:s.response.name||s.name,addedBy:"user"};t.some(m=>m.uri===p.uri)||n([...t,p])}s.status==="error"&&rt.error(`Failed to upload "${s.name}"`),i(d.fileList.filter(p=>p.status==="uploading"||p.status==="error"))},y=d=>{if(d.status==="done"){let s=d.response?.uri;n(t.filter(p=>p.uri!==s&&p.name!==d.name))}else i(s=>s.filter(p=>p.uid!==d.uid))};return(0,Jt.jsx)("div",{"data-testid":"reference-files-field",children:(0,Jt.jsxs)(Ur.Dragger,{multiple:!0,fileList:[...c,...r],customRequest:l,onChange:u,onRemove:y,style:{padding:"8px 0"},children:[(0,Jt.jsx)("p",{className:"ant-upload-drag-icon",style:{marginBottom:4},children:(0,Jt.jsx)(fi,{size:24,style:{color:"#6366f1"}})}),(0,Jt.jsx)("p",{className:"ant-upload-text",style:{fontSize:13},children:"Click or drag files to this area to upload"}),(0,Jt.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 Iu(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?${`metadata=${encodeURIComponent(JSON.stringify({trainingRound:"true",targetAgentId:e}))}`}${t?`&projectId=${t}`:""}`}function il(e,t){return`/api/tasks?${`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,context:{source:"learning"},metadata:{trainingRound:!0,targetAgentId:e.targetAgentId},files:e.files&&e.files.length>0?e.files:void 0},t)).data;if(!o)throw new Error("Failed to create learning round task");let r=e.existingThreadId??null;if(!r&&(r=(await e.post("/api/assistants/agent-architect/threads",{metadata:{training:!0,targetAgentId:e.targetAgentId}})).data?.id??null,!r))throw new Error("Failed to create training thread");return await e.put(`/api/tasks/${o.id}`,{metadata:{trainingRound:!0,targetAgentId:e.targetAgentId,trainingSessionId:r}},t),{roundTaskId:o.id,threadId:r}}function 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"?"Target form: learning placeholder (architecture undecided).":e.targetMode==="existing-workflow"?"Target form: existing Workflow.":"Target form: existing Capability or Orchestra.";return[`Learning goal (draft \u2014 confirm with the user before any observation or design): ${e.goal}`,`Exact target ID: "${e.targetAgentId}".`,`Exact round Task ID: "${e.roundTaskId}".`,"That exact Task is your bound tracking task: your main task and Belief root for this round.","Reconcile it; create every child under it; never create a new main or round task.",t,...e.files?.length?[`Reference files: ${e.files.map(n=>`${n.name||n.uri} (${n.uri})`).join(", ")}. Read them before designing; in your first reply state which files you actually read and what you took from each.`]:[]].join(`
|
|
232
|
+
`)}var al=5;async function wa(e,t,n){let o=n?.projectId,r=o?{headers:{"x-project-id":o}}:void 0,i=d=>il(d,o??void 0),a=[],c=!1,l=new Set,u=new Set([t]),y=[t];for(let d=0;d<al&&y.length>0;d++){let p=(await Promise.all(y.map(m=>e(i(m),r).then(g=>Array.isArray(g.data)?g.data.map(v=>v.parentId?v:{...v,parentId:m}):[]).catch(()=>(c=!0,l.add(m),[]))))).flat().filter(m=>u.has(m.id)?!1:(u.add(m.id),!0));a.push(...p),y=p.map(m=>m.id)}if(y.length>0){c=!0;for(let d of y)l.add(d)}return{tasks:a,partial:c,...l.size>0?{incompleteParentIds:[...l]}:{}}}var Ke=T(W()),Fo=({open:e,agentId:t,defaultProjectId:n,onClose:o,onCreated:r})=>{let{get:i,post:a,put:c}=Ze(),{message:l}=Rn.useApp(),u=yt("agent-architect"),{trainingProjects:y,loading:d}=Pt(),s=y.find(_=>_.id===n)??null,[p]=pe.useForm(),[m,g]=(0,en.useState)(!1),[v,f]=(0,en.useState)(null),[w,S]=(0,en.useState)(null),[A,R]=(0,en.useState)([]);return(0,en.useEffect)(()=>{e&&(S(ha(u.tenantId,t)),R([]))},[e,u,t]),(0,en.useEffect)(()=>{if(!e)return;let _=!1;return(async()=>{try{let C=await i(Mn(t,s?.id??void 0),s?{headers:{"x-project-id":s.id}}:void 0);if(_)return;let x=(C.data??[]).filter(Nn);f(x.find(Oo)??null)}catch{}})(),()=>{_=!0}},[e,i,t,s]),(0,Ke.jsxs)(Fe,{title:"New Learning Task",open:e,onCancel:o,footer:null,width:520,destroyOnClose:!0,children:[v&&(0,Ke.jsx)(Vt,{type:"warning",showIcon:!0,style:{marginBottom:16},message:"A learning task is already in progress. Complete it before starting a new one."}),(0,Ke.jsxs)(pe,{form:p,layout:"vertical",onFinish:async _=>{if(!s){l.error("No learning project is available");return}g(!0);try{let{roundTaskId:C,threadId:x}=await ba({goal:_.goal,targetAgentId:t,workspaceId:s.workspaceId,projectId:s.id,existingThreadId:w,files:A,post:a,put:c});l.success("Learning task created. Preparing the Architect\u2026"),p.resetFields(),r(C,x,_.goal,A),R([])}catch(C){l.error(C instanceof Error?C.message:"Failed to create the learning task. Please try again.")}finally{g(!1)}},children:[(0,Ke.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,Ke.jsx)(Pe.TextArea,{rows:3,placeholder:"e.g. Improve the agent's accuracy when handling price disputes based on the price protection policy"})}),s&&(0,Ke.jsx)(pe.Item,{label:(0,Ke.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,Ke.jsx)("span",{children:"Reference Materials"}),(0,Ke.jsx)(cr,{project:s,selectable:!1,loading:d})]}),extra:"Optional. These materials will be used as reference for this learning round.",style:{marginBottom:16},colon:!1,children:(0,Ke.jsx)(ya,{projectId:s.id,value:A,onChange:R})}),!s&&!d&&(0,Ke.jsx)(pe.Item,{style:{marginBottom:16},children:(0,Ke.jsx)(cr,{project:s,projects:y,loading:d})}),(0,Ke.jsxs)(pe.Item,{style:{marginBottom:0,textAlign:"right"},children:[(0,Ke.jsx)(ee,{onClick:o,style:{marginRight:8},children:"Cancel"}),(0,Ke.jsx)(ee,{type:"primary",htmlType:"submit",loading:m,disabled:!!v||d||!s,children:"Start Learning"})]})]})]})};var we=T(Te());var fn=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=we.default.createContext(null),Ta=we.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,c]=(0,we.useState)(null),[l,u]=(0,we.useState)([]),[y,d]=(0,we.useState)([]),[s,p]=(0,we.useState)(!1),[m,g]=(0,we.useState)(null),[v,f]=(0,we.useState)(()=>new Set),w=yt("__GLOBAL__"),A=we.default.useContext(hr)??{getWorkItemRequest:(E,ae,Q,L)=>$(E,ae,Q,L),getDetailSession:()=>ce.current,bumpDetailSession:()=>{ce.current+=1}},R=(0,we.useRef)(0),O=(0,we.useRef)(null),_=(0,we.useRef)(new Set),C=(0,we.useRef)(!0),x=(0,we.useRef)(new Map),B=(0,we.useRef)(new Set),ce=(0,we.useRef)(0),V=(0,we.useRef)(w);V.current=w;let X=(0,we.useRef)(A);X.current=A;let D=a??e,$=(E,ae,Q=ce.current,L=!1)=>{let ne=x.current.get(E);if(ne&&(!L||ne.detailSession===Q))return ne;ne&&(x.current.delete(E),B.current.add(ne.promise),ne.promise.finally(()=>{B.current.delete(ne.promise)}).catch(()=>{}));let he=L?xa:dl;if(x.current.size+B.current.size>=he){let Se=Promise.reject(new Error("Work-item request capacity reached"));return Se.catch(()=>{}),{promise:Se,source:ae,detailSession:Q}}let Ee;try{Ee=Promise.resolve(V.current.tasks.workItems.list(E))}catch(Se){Ee=Promise.reject(Se)}let ye={promise:Ee,source:ae,detailSession:Q};return x.current.set(E,ye),Ee.finally(()=>{x.current.get(E)?.promise===Ee&&x.current.delete(E)}).catch(()=>{}),ye};(0,we.useEffect)(()=>(C.current=!0,()=>{C.current=!1,O.current=null,R.current+=1,X.current.bumpDetailSession(),Promise.resolve().then(()=>{C.current||(x.current.clear(),B.current.clear(),_.current.clear())})}),[]);let K=(E,ae=!0)=>{let Q=ae?++R.current:R.current;ae&&C.current&&p(!0);let L=A.getDetailSession(),ne=A.getWorkItemRequest(E,"detail",L,ae),he=ne.detailSession===L;return gl(ne.promise,4e3).then(N=>{he&&C.current&&Q===R.current&&O.current===E&&(d(N),g(null))}).catch(N=>{he&&ae&&C.current&&Q===R.current&&O.current===E&&(d([]),g(N instanceof Error&&N.message==="Work-item request capacity reached"?ul:cl))}).finally(()=>{he&&C.current&&Q===R.current&&O.current===E&&p(!1)})},z=(E,ae)=>{ae&&u(Q=>D?[...Q,D]:Q),O.current=E.id,c(E),d([]),g(null),K(E.id)},J=E=>z(E,!0),P=()=>{if(l.length===0)return;let E=l[l.length-1];u(l.slice(0,-1)),z(E,!1)},H=()=>{A.bumpDetailSession(),O.current=null,R.current+=1,c(null),u([]),d([]),p(!1),g(null),n()},ue=async(E,ae)=>{let Q=O.current;if(!Q||_.current.has(Q))return;let L=pl(E);_.current.add(Q),f(ne=>new Set(ne).add(Q));try{try{await V.current.tasks.update(Q,ae?{status:E,failureReason:ae}:{status:E})}catch{C.current&&i.error("Operation failed, please retry");return}if(!C.current)return;O.current===Q&&c(ne=>!C.current||ne?.id!==Q||O.current!==Q?ne:(K(Q,!1),{...ne,status:E,...ae?{failureReason:ae}:{}})),C.current&&i.success(L),o&&Promise.resolve().then(o).catch(()=>{C.current&&i.warning(`${L}, but the task list could not be refreshed`)})}finally{_.current.delete(Q),C.current&&f(ne=>{let he=new Set(ne);return he.delete(Q),he})}};(0,we.useEffect)(()=>{O.current!==e.id&&(u([]),z(e,!1))},[e]),(0,we.useEffect)(()=>{let E=O.current;if(!E)return;let ae=t.find(L=>L.id===E);if(!ae){H();return}c(L=>L&&L.id===E?ae:L);let Q=new Map(t.map(L=>[L.id,L]));u(L=>L.flatMap(ne=>{let he=Q.get(ne.id);return he?[he]:[]})),K(E,!1)},[e,t]),(0,we.useEffect)(()=>{if(!D?.id)return;let E=D.id,ae=!1,Q=async()=>{document.hidden||await K(E,!1)},L=()=>{ae||!C.current||document.hidden||Q()};return document.addEventListener("visibilitychange",L),Q(),()=>{ae=!0,document.removeEventListener("visibilitychange",L)}},[D?.id]);let be=xo(D),Ie=we.default.useContext(Ta);(0,we.useEffect)(()=>{Ie(e,D)},[Ie,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,fn.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,fn.jsx)("div",{style:{flex:1,minHeight:0},children:(0,fn.jsx)(wo,{task:D,relatedTasks:t,onRelatedTaskClick:J,workItems:y,loading:s,activityError:m??void 0,transitionPending:me,...F,onViewChat:be,onBack:P,canGoBack:l.length>0,maxHeight:r,focusKey:`${D.id}:${me?"updating":D.status}`,subtasks:t.filter(E=>E.parentId===D.id),onSubtaskClick:J,parent:t.find(E=>E.id===D.parentId)??null,onParentClick:J})})})},Ra=({task:e,relatedTasks:t,onClose:n,onRefresh:o})=>{let[r,i]=(0,we.useState)(null),a=(0,we.useCallback)((l,u)=>{i({rootId:l.id,title:u.title})},[]);(0,we.useEffect)(()=>{e||i(null)},[e]);let c=e?r&&r.rootId===e.id?r.title:e.title:"";return(0,fn.jsx)(Fe,{open:e!==null,onCancel:n,footer:null,title:c,width:960,style:{maxWidth:"calc(100vw - 32px)"},styles:{header:{padding:"16px 24px 0"},content:{padding:0},body:{padding:"12px 24px 24px"}},centered:!0,children:(0,fn.jsx)(Ta.Provider,{value:a,children:e&&(0,fn.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:c,onSelectedRoundChange:l,loading:u,onRefresh:y,onStartRequest:d,onExpandWorkflow:s})=>{let{message:p}=Rn.useApp(),[m,g]=(0,ze.useState)(!1),[v,f]=(0,ze.useState)(!1),[w,S]=(0,ze.useState)(null),[A,R]=(0,ze.useState)(null),O=yt("__GLOBAL__"),_=(0,ze.useRef)(!0),C=(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]:[],[X,D]=(0,ze.useState)(null),$=c!==void 0,K=$?c:X,z=V.map(N=>N.id).join(",");(0,ze.useEffect)(()=>{if(V.length===0){D(null);return}D(N=>N&&z.split(",").includes(N)?N:V[0].id)},[z]);let J=V.find(N=>N.id===K)??V[0]??null,P=N=>{$||D(N),l?.(N)},H=a&&J?a[J.id]??[]:J&&J.id===o?.id?r:[],ue=(0,ze.useMemo)(()=>[J,...H].filter(N=>N!==null),[o,r,i,a,K]),be=H.filter(N=>N.status==="in_progress"),Ie=be[0]??null,me=J?.status==="in_progress",F=(be.length>0?be.map(N=>N.id):me&&J?[J.id]:[]).sort(),E=F.join(","),ae=(0,ze.useRef)(O);ae.current=O;let Q=(0,ze.useRef)(null);Q.current||(Q.current={getWorkItemRequest:(N,Ee,ye,Se)=>L(N,Ee,ye,Se),getDetailSession:()=>B.current,bumpDetailSession:()=>{B.current+=1}});let L=(N,Ee,ye=B.current,Se=!1)=>{let Me=C.current.get(N);if(Me&&(!Se||Me.detailSession===ye))return Me;Me&&(C.current.delete(N),x.current.add(Me.promise),Me.promise.finally(()=>{x.current.delete(Me.promise)}).catch(()=>{}));let tt=Se?vr:ml;if(C.current.size+x.current.size>=tt){let Oe=Promise.reject(new Error("Work-item request capacity reached"));return Oe.catch(()=>{}),{promise:Oe,source:Ee,detailSession:ye}}let Ve;try{Ve=Promise.resolve(ae.current.tasks.workItems.list(N))}catch(Oe){Ve=Promise.reject(Oe)}let Qe={promise:Ve,source:Ee,detailSession:ye};return C.current.set(N,Qe),Ve.finally(()=>{C.current.get(N)?.promise===Ve&&C.current.delete(N)}).catch(()=>{}),Qe};(0,ze.useEffect)(()=>(_.current=!0,()=>{_.current=!1,Promise.resolve().then(()=>{_.current||(C.current.clear(),x.current.clear())})}),[]),(0,ze.useEffect)(()=>{if(F.length===0){R(null);return}R(null);let N=!1,Ee=()=>{if(document.hidden)return Promise.resolve();let Se=ce.current%F.length,Me=[...F.slice(Se),...F.slice(0,Se)];return ce.current=(Se+vr)%F.length,Promise.allSettled(Me.map(tt=>vl(L(tt,"live").promise,4e3))).then(tt=>{if(N||!_.current)return;let kt=tt.filter(Oe=>Oe.status==="fulfilled").map(Oe=>Oe.value);if(kt.length===0)return;let Qe=[...kt.flat().filter(Oe=>!/^Status changed to\b/i.test(Oe.summary??""))].sort((Oe,nt)=>new Date(nt.createdAt).getTime()-new Date(Oe.createdAt).getTime());R(Qe[0]??null)})},ye=()=>{N||!_.current||document.hidden||Ee()};return document.addEventListener("visibilitychange",ye),Ee(),()=>{N=!0,document.removeEventListener("visibilitychange",ye)}},[E]);let ne=N=>S(N),he=(N,Ee,ye,Se)=>{P(N),g(!1);let Me;try{Me=Promise.resolve(y())}catch{Me=Promise.reject(new Error("Task-list refresh failed"))}Me.catch(()=>{_.current&&p.error("Task created, but the task list could not be refreshed")}),n?.(ye,N,Se)};return(0,Ce.jsxs)("div",{style:{background:"rgba(255, 255, 255, 0.6)",border:"1px solid rgba(240, 240, 240, 0.7)",borderRadius:10,padding:"8px 10px",boxShadow:"0 2px 10px rgba(0,0,0,0.06)",backdropFilter:"blur(8px)",pointerEvents:"auto",width:300},children:[u?(0,Ce.jsx)("div",{style:{fontSize:12,color:"#bbb",padding:"4px 2px"},children:"Loading..."}):J?(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)(Yt,{}),onClick:()=>d?d():g(!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:J.id,onChange:P,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:()=>ne(N[0]),style:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:6,cursor:"pointer",width:"100%",height:"auto",fontSize:12,fontWeight:600,color:"#b45309",background:"rgba(245,158,11,0.12)",border:"1px solid rgba(245,158,11,0.35)",borderRadius:8,padding:"5px 8px",marginBottom:6},children:[N.length," item",N.length>1?"s":""," waiting for approval"]}):null})(),A&&(0,Ce.jsxs)("div",{"data-testid":"live-status",style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:"#666",padding:"2px 2px 6px",borderBottom:"1px solid rgba(240,240,240,0.7)",marginBottom:4},children:[(0,Ce.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:Ie?"#3b82f6":"#bbb",animation:Ie?"live-pulse 1.2s ease-in-out infinite":void 0}}),(0,Ce.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children: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)(Fi,{tasks:[J,...H],loading:!1,onTaskClick:ne,hideCompleted:v,onHideCompletedChange:f})})]}):(0,Ce.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 2px"},children:[(0,Ce.jsx)("span",{style:{fontSize:12,color:"#999"},children:"No learning tasks yet"}),(0,Ce.jsx)(ee,{size:"small",icon:(0,Ce.jsx)(Yt,{}),onClick:()=>d?d():g(!0),children:"New Learning Task"})]}),!d&&(0,Ce.jsx)(Fo,{open:m,agentId:e,defaultProjectId:t,onClose:()=>g(!1),onCreated:he}),(0,Ce.jsx)(hr.Provider,{value:Q.current,children:(0,Ce.jsx)(Ra,{task:w,relatedTasks:ue,onClose:()=>S(null),onRefresh:y})})]})};var Ne=T(Te());function Sa(e,t){let n=[...t],o=new Set(t.map(c=>`${c.from}|${c.to}`)),r=new Set(t.filter(c=>c.kind==="dependency").map(c=>c.to)),i=new Set(e.map(c=>c.id)),a=new Map;for(let c of e){if(!c.parentId||!i.has(c.parentId))continue;let l=a.get(c.parentId)??[];l.push(c),a.set(c.parentId,l)}for(let c of a.values()){let l=[...c].sort((u,y)=>new Date(u.createdAt).getTime()-new Date(y.createdAt).getTime());for(let u=1;u<l.length;u++){let y=l[u];if(r.has(y.id))continue;let d=l[u-1].id,s=`${d}|${y.id}`;o.has(s)||o.has(`${y.id}|${d}`)||(n.push({from:d,to:y.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)(Rt,{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)(Rt,{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,Ne.useState)(null),[a,c]=(0,Ne.useState)(null),[l,u]=(0,Ne.useState)([]),[y,d]=(0,Ne.useState)(!1),[s,p]=(0,Ne.useState)(null),m=(0,Ne.useRef)(0),g=(0,Ne.useRef)(o);g.current=o;let v=e.map(P=>P.id).join(",");(0,Ne.useEffect)(()=>{i(P=>P&&v.split(",").includes(P)?P:e[0]?.id??null)},[v]);let f=e.find(P=>P.id===r)??e[0]??null,w=(0,Ne.useMemo)(()=>[f,...f?t[f.id]??[]:[]].filter(P=>P!==null),[f,t]),{nodes:S,edges:A}=(0,Ne.useMemo)(()=>ko(w),[w]),R=(0,Ne.useMemo)(()=>Sa(w,A),[w,A]),O=(0,Ne.useMemo)(()=>new Map(w.map(P=>[P.id,P])),[w]),_=(0,Ne.useMemo)(()=>{let P=bo(S.map(H=>({id:H.id})),R.map(H=>({from:H.from,to:H.to})),{nodeWidth:wl,nodeHeight:xl,nodesep:24,ranksep:60,rankdir:"LR"});return S.map(H=>({id:H.id,type:"workflowTask",position:P.get(H.id)??{x:0,y:0},data:{task:H.task}}))},[S,R]),C=(0,Ne.useMemo)(()=>R.map(P=>{let H=Ca(O.get(P.from)?.status??"pending",O.get(P.to)?.status??"pending");return{id:`${P.from}->${P.to}:${P.kind}`,source:P.from,target:P.to,animated:H==="flowing",style:{...Tl[H],...P.kind==="sequence"&&H!=="idle"?{strokeDasharray:"2 3"}:{}}}}),[R,O]),[x,B,ce]=Cn(_),[V,X,D]=An(C);(0,Ne.useEffect)(()=>{B(P=>{let H=P.map(be=>be.id).sort().join("|"),ue=_.map(be=>be.id).sort().join("|");if(H===ue){let be=new Map(P.map(Ie=>[Ie.id,Ie]));return _.map(Ie=>{let me=be.get(Ie.id);return me?{...Ie,position:me.position}:Ie})}return _}),X(C)},[_,C,B,X]);let $=(0,Ne.useCallback)(P=>{let H=++m.current;d(!0),p(null),g.current.tasks.workItems.list(P).then(ue=>{H===m.current&&u(ue)}).catch(()=>{H===m.current&&(u([]),p("Activity could not be loaded. Please try again shortly."))}).finally(()=>{H===m.current&&d(!1)})},[]),K=(0,Ne.useCallback)((P,H)=>{let ue=H.data?.task;ue&&(u([]),c(ue),$(ue.id))},[$]),z=(0,Ne.useCallback)(()=>{m.current+=1,c(null),u([]),p(null),d(!1)},[]),J=xo(a);return n?(0,at.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,at.jsx)(Tt,{size:"large"})}):!f||w.length===0?(0,at.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,at.jsx)(_t,{description:"No tasks"})}):(0,at.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[e.length>1&&(0,at.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",paddingBottom:12,flexShrink:0},children:e.map((P,H)=>{let ue=Gt[P.status],be=P.id===f.id;return(0,at.jsxs)("button",{type:"button","data-testid":`round-chip-${P.id}`,onClick:()=>{i(P.id),z()},title:P.title,style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11,fontWeight:600,padding:"3px 10px",borderRadius:9999,cursor:"pointer",border:be?"1.5px solid #6366f1":"1px solid #e5e7eb",background:be?"rgba(99,102,241,0.08)":"#fff",color:be?"#6366f1":"#6b7280"},children:[(0,at.jsx)("span",{style:{width:6,height:6,borderRadius:9999,background:ue.color}}),"R",e.length-H]},P.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:K,fitView:!0,fitViewOptions:{padding:.15},nodesDraggable:!0,nodesConnectable:!1,miniMap:!0,attributionPosition:"bottom-right"})}),a&&(0,at.jsx)("div",{"data-testid":"workflow-detail",style:{height:"40%",minHeight:200,flexShrink:0,borderTop:"1px solid #f0f0f0",overflow:"hidden"},children:(0,at.jsx)(wo,{task:a,relatedTasks:w,workItems:l,loading:y,activityError:s??void 0,onApprove:void 0,onReject:void 0,onRetry:void 0,onCancel:void 0,onViewChat:J,onBack:z,subtasks:w.filter(P=>P.parentId===a.id),onSubtaskClick:P=>{u([]),c(P),$(P.id)},parent:w.find(P=>P.id===a.parentId)??null,onParentClick:P=>{u([]),c(P),$(P.id)}})})]})};var St=T(Te());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:c,onClose:l,bodyStyle:u,restoreFocusRef:y,focusControlRef:d,escapeEnabled:s=!0,zIndex:p=25,children:m})=>{let g=Ri("(max-width: 720px)"),v=(0,St.useRef)(null),f=(0,St.useRef)(null),w=(0,St.useRef)(null);w.current||(w.current=`canvas-dock-title-${++Rl}`);let S=w.current,[A,R]=(0,St.useState)(null);(0,St.useEffect)(()=>R(null),[t,n]);let O=!g&&typeof t=="number",_=g?n??t:A??t,C=typeof _=="number"?_:null,x=o===void 0?-1:1,B=V=>{if(!O||C===null)return;V.preventDefault();let X={startX:V.clientX,startWidth:C},D=K=>{R(kr(X.startWidth+x*(K.clientX-X.startX)))},$=()=>{window.removeEventListener("pointermove",D),window.removeEventListener("pointerup",$)};window.addEventListener("pointermove",D),window.addEventListener("pointerup",$)},ce=V=>{!O||C===null||(V.key==="ArrowLeft"?(V.preventDefault(),R(kr(C-x*Da))):V.key==="ArrowRight"&&(V.preventDefault(),R(kr(C+x*Da))))};return(0,St.useEffect)(()=>{if(!e||!s)return;let V=X=>{X.key==="Escape"&&!X.defaultPrevented&&l()};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[s,e,l]),(0,St.useEffect)(()=>{if(d)return d.current=()=>v.current?.focus(),()=>{d.current=null}},[d]),(0,St.useEffect)(()=>{if(!e)return;let V=y?.current??document.activeElement;return V instanceof HTMLElement&&(f.current=V),v.current?.focus(),()=>{f.current?.focus(),f.current=null}},[e]),e?(0,Lt.jsxs)("div",{"data-testid":"canvas-dock",role:"region","aria-labelledby":S,style:{position:"absolute",top:r,...o===void 0?{right:12}:{left:o},...a===void 0?{bottom:i}:{height:a},width:_,maxWidth:"calc(100% - 24px)",boxSizing:"border-box",zIndex: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); } }"}),O&&(0,Lt.jsx)("div",{"data-testid":"canvas-dock-resize-handle",role:"separator","aria-orientation":"vertical","aria-label":"Resize panel","aria-valuenow":C??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:S,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:c}),(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,...u},children:m})]}):null};var Nt=T(Te());var Wo=80;function tn(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,Fa={left:36,right:12,top:16,bottom:24},wr={fontSize:9,color:"#999"};function Wa(){return{type:"value",min:0,max:100,axisLabel:{...wr},splitLine:{lineStyle:{color:"#f5f5f5"}}}}function _a({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 c=new Map,l=[],u=new Map;for(let s of r){let p=s.taskId?i.get(s.taskId):void 0;if(p===void 0)continue;let m=c.get(p)??0;if(c.set(p,m+1),s.holdout===!0){let g=(m-((a.get(p)??1)-1)/2)*Il;l.push([Math.round((p+g)*100)/100,s.avgScore])}else u.set(p,s.avgScore)}let y=n??null;if(y===null){for(let s=o.length-1;s>=0;s--)if(u.has(s+1)){y=o[s].id;break}}let d=o.map((s,p)=>{let m=u.get(p+1);if(m===void 0)return null;let g=s.id===y;return{value:[p+1,m],itemStyle:{color:tn(m),borderRadius:[4,4,0,0],...g?{borderColor:"#6366f1",borderWidth:2}:{}}}});return{grid:Fa,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:Wa(),series:[{type:"bar",data:d,barWidth:22,markLine:{silent:!0,symbol:"none",lineStyle:{type:"dashed",color:"#d9d9d9"},label:{fontSize:9,color:"#999",formatter:`target ${Wo}`},data:[{yAxis:Wo}]}},{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:Fa,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:Wa(),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 ${Wo}`},data:[{yAxis:Wo}]}},{type:"scatter",data:o,symbol:"diamond",symbolSize:9,itemStyle:{color:"#fff",borderColor:"#f59e0b",borderWidth:1.5},z:4}]}}var lt=T(W()),xr={fontSize:10,color:"#999"},Tr={fontSize:22,fontWeight:700,lineHeight:1.2},Ba=({summary:e})=>e.latestScore===null?null:(0,lt.jsxs)("div",{"data-testid":"eval-summary",style:{display:"flex",gap:28},children:[(0,lt.jsxs)("div",{children:[(0,lt.jsxs)("div",{style:{...Tr,color:tn(e.latestScore)},children:[e.latestScore.toFixed(1),e.delta!==null&&(0,lt.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,lt.jsx)("div",{style:xr,children:"latest score"})]}),(0,lt.jsxs)("div",{children:[(0,lt.jsx)("div",{"data-testid":"summary-pass",style:{...Tr,color:"#262626"},children:e.passRate!==null?`${e.passRate}%`:"\u2014"}),(0,lt.jsxs)("div",{style:xr,children:["pass \xB7 ",e.passedCases,"/",e.totalCases]})]}),e.interruptedCases>0&&(0,lt.jsxs)("div",{"data-testid":"summary-interrupted",children:[(0,lt.jsx)("div",{style:{...Tr,color:"#b45309"},children:e.interruptedCases}),(0,lt.jsx)("div",{style:xr,children:"interrupted"})]})]});var dt=T(Te());var On=T(W()),ja=({agentId:e,projectId:t,runs:n,selectedRoundId:o,onSelectRound:r})=>{let{get:i}=Ze(),[a,c]=(0,dt.useState)([]),[l,u]=(0,dt.useState)(!1),[y,d]=(0,dt.useState)(null),s=dt.default.useRef(i);s.current=i,(0,dt.useEffect)(()=>{let v=!1;return s.current(Mn(e,t)).then(f=>{if(v)return;let w=(f.data??[]).filter(Nn);w.sort((S,A)=>new Date(S.createdAt).getTime()-new Date(A.createdAt).getTime()),c(w),u(!0)}).catch(()=>{v||u(!0)}),()=>{v=!0}},[e,t]),(0,dt.useEffect)(()=>{y&&!a.some(v=>v.id===y)&&d(null)},[a,y]);let p=(0,dt.useMemo)(()=>_a({rounds:a,runs:n,selectedRoundId:o??y}),[a,n,o,y]),m=(0,dt.useMemo)(()=>({click:v=>{let f=v;if(f.seriesType!=="bar"||typeof f.dataIndex!="number")return;let w=a[f.dataIndex];w&&(d(w.id),r?.(w.id))}}),[a,r]),g=(0,dt.useMemo)(()=>{if(a.length===0)return!1;let v=new Set(a.map(f=>f.id));return Qn(n).some(f=>f.taskId!==void 0&&v.has(f.taskId))},[a,n]);return l?g?(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)(pn,{option:p,height:100,onEvents:m})]}):(0,On.jsx)("div",{"data-testid":"round-trend-empty",style:{display:"none"}}):null};var nn=T(W()),Ga=({dimensions:e})=>e.length===0?null:(0,nn.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,nn.jsxs)("div",{"data-testid":`dimension-row-${t.name}`,style:{display:"flex",alignItems:"center",gap:8,fontSize:11},children:[(0,nn.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,nn.jsx)("div",{style:{flex:1,height:8,background:"#f5f5f5",borderRadius:4,overflow:"hidden"},children:(0,nn.jsx)("div",{"data-testid":`dimension-fill-${t.name}`,style:{width:`${n}%`,height:"100%",background:tn(t.avgScore),borderRadius:4}})}),(0,nn.jsx)("span",{style:{width:28,textAlign:"right",flexShrink:0,fontWeight:600,color:tn(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 ct=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},Fn=({agentId:e,projectId:t,runs:n,showRoundTrend:o=!0})=>{let{get:r}=Ze(),i=(0,Nt.useMemo)(()=>Ma(n),[n]),a=$a(n),c=n.find(m=>m.id===a),[l,u]=(0,Nt.useState)(null),y=Nt.default.useRef(r);y.current=r,(0,Nt.useEffect)(()=>{if(!a){u(null);return}let m=!1;return y.current(`/api/eval/runs/${a}`).then(g=>!m&&u(g.data?.results??[])).catch(()=>!m&&u([])),()=>{m=!0}},[a]);let d=(0,Nt.useMemo)(()=>Oa(l??[]),[l]),s=(0,Nt.useMemo)(()=>za(n),[n]),p=Qn(n).length>0;return i.latestScore===null?(0,ct.jsx)("div",{style:{height:120,display:"flex",alignItems:"center",justifyContent:"center",color:"#bfbfbf",fontSize:12},children:"No eval runs yet"}):(0,ct.jsxs)("div",{"data-testid":"eval-quality-panel",style:{display:"flex",flexDirection:"column",gap:12},children:[(0,ct.jsx)(Ba,{summary:i}),o&&(0,ct.jsx)(ja,{agentId:e,projectId:t,runs:n}),p&&(0,ct.jsxs)("div",{"data-testid":"run-trend-card",style:Ha,children:[(0,ct.jsx)("div",{style:Ka,children:"Score by run"}),(0,ct.jsx)(pn,{option:s,height:160})]}),a&&l!==null&&(0,ct.jsxs)("div",{"data-testid":"run-diagnosis-card",style:Ha,children:[(0,ct.jsxs)("div",{style:Ka,children:["Latest run",c?` \xB7 ${Lo(new Date(c.createdAt))}`:""," \xB7 ",i.passedCases,"/",i.totalCases," passed"]}),(0,ct.jsx)(Ga,{dimensions:d}),(0,ct.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},_o=({assistantId:e,projectId:t,onProjectChange:n,onLearningStarted:o,learningTasks:r=Cl,topOffset:i=12,onLearningRefresh:a,evalTick:c,showLearning:l=!0,variant:u="full"})=>{let[y,d]=(0,Yn.useState)(null),[s,p]=(0,Yn.useState)(!1),m=ua(e),g=No(e);return(0,Yn.useEffect)(()=>{c!==void 0&&c>0&&g.refresh()},[c]),u==="selector"?(0,se.jsx)("div",{style:{position:"absolute",left:12,top:i,zIndex:10,pointerEvents:"none"},children:(0,se.jsx)("div",{style:{pointerEvents:"auto"},children:(0,se.jsx)(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:()=>d(y==="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:m.total})," ",(0,se.jsx)("span",{style:{color:"#bbb"},children:"threads"})]}),(0,se.jsxs)("span",{children:[(0,se.jsx)("strong",{style:{color:"#595959"},children:m.last7d})," ",(0,se.jsx)("span",{style:{color:"#bbb"},children:"7d"})]}),(0,se.jsxs)("span",{children:[(0,se.jsx)("strong",{style:{color:"#595959"},children:m.last30d})," ",(0,se.jsx)("span",{style:{color:"#bbb"},children:"30d"})]}),(0,se.jsx)("span",{style:{color:"#999"},children:Lo(m.lastActive)}),m.daily7d.length>0&&(0,se.jsx)(fa,{values:m.daily7d,width:56,height:20,color:"#8c8c8c"})]})]}),(0,se.jsxs)("div",{onClick:()=>d(y==="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:g.score===null?"#d9d9d9":g.score>=80?"#22c55e":g.score>=50?"#f59e0b":"#ef4444"},children:g.score!==null?g.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:g.passRate!==null?`${g.passRate}%`:"\u2014"})," ",(0,se.jsx)("span",{style:{color:"#bbb"},children:"pass"})]}),(0,se.jsxs)("span",{children:[(0,se.jsx)("strong",{style:{color:"#595959"},children:g.runCount})," ",(0,se.jsx)("span",{style:{color:"#bbb"},children:"runs"})]}),g.scores.length>1&&(0,se.jsx)(ma,{values:g.scores.slice(-10),width:64,height:20,color:g.score===null?"#d9d9d9":g.score>=80?"#22c55e":g.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)})]}),y==="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)(pn,{option:pa(m.daily30d),height:220})]}),y==="eval"&&(0,se.jsx)(ht,{open:!0,width:720,title:"Eval quality",onClose:()=>d(null),children:(0,se.jsx)(Fn,{agentId:e,runs:g.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(Te());var mn=T(W()),Al=({data:e})=>{let[t,n]=Rr.default.useState(!1),o=!!e.pinned;return(0,mn.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,mn.jsxs)("div",{style:{position:"absolute",top:-22,left:2,display:"flex",alignItems:"center",gap:6},children:[(0,mn.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,mn.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,mn.jsx)(hi,{size:11,fill:o?"currentColor":"none"})})]})})},Za=Rr.default.memo(Al);var He=T(Te());var zo=T(Te()),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 on=T(Te()),Qa=(e,t)=>e?.requestId===t?.requestId&&e?.content===t?.content;function Wn({assistantId:e,initialMessageRequest:t,onInitialMessageSubmitted:n}){let o=(0,on.useRef)(new Set),r=t??null,i=(0,on.useRef)(null);i.current===null&&(i.current={assistantId:e,observedRequest:r,request:r});let[a,c]=(0,on.useState)(i.current),l=(0,on.useRef)(a);(0,on.useLayoutEffect)(()=>{let d=l.current;if(d.assistantId===e&&Qa(d.observedRequest,r))return;let s={assistantId:e,observedRequest:r,request:r};l.current=s,c(s)},[e,r?.requestId,r?.content]);let u=a.assistantId===e&&Qa(a.observedRequest,r)?a.request:null;return{attemptedRequestIdsRef:o,effectivePendingRequest:u,handleInitialMessageSubmitted:d=>{let s=l.current;if(s.assistantId===e){if(s.request?.requestId===d){let p={...s,request:null};l.current=p,c(m=>m.assistantId===e&&m.request?.requestId===d?{...m,request:null}:m)}n?.(d)}}}}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:c,label:l="Architect",temporarilyHidden:u=!1,openSignal:y=0,showMobileTrigger:d=!0,restoreFocusRef:s})=>{let[p,m]=(0,He.useState)(Ya),[g,v]=(0,He.useState)(()=>!Ya()),[f,w]=(0,He.useState)(360),S=(0,He.useRef)(null),A=(0,He.useRef)(null),R=(0,He.useRef)(null),O=i??null,{attemptedRequestIdsRef:_,effectivePendingRequest:C,handleInitialMessageSubmitted:x}=Wn({assistantId:e,initialMessageRequest:i,onInitialMessageSubmitted:a});(0,He.useEffect)(()=>{S.current&&(S.current.inert=u||!g)},[p,u,g]),(0,He.useEffect)(()=>{p&&u&&v(!1)},[p,u]),(0,He.useEffect)(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;let X=window.matchMedia(Xn),D=$=>{m($.matches),v(!$.matches)};return m(X.matches),typeof X.addEventListener=="function"?(X.addEventListener("change",D),()=>X.removeEventListener("change",D)):(X.addListener(D),()=>X.removeListener(D))},[]),(0,He.useEffect)(()=>{y>0&&v(!0)},[y]),(0,He.useEffect)(()=>{O&&!p&&v(!0)},[e,O?.requestId,O?.content,p]);let B=(0,He.useCallback)(X=>{X.preventDefault(),R.current={startX:X.clientX,startWidth:f}},[f]);(0,He.useEffect)(()=>{let X=$=>{if(!R.current)return;let K=R.current.startX-$.clientX,z=Math.min(900,Math.max(320,R.current.startWidth+K));w(z)},D=()=>{R.current=null};return window.addEventListener("mousemove",X),window.addEventListener("mouseup",D),()=>{window.removeEventListener("mousemove",X),window.removeEventListener("mouseup",D)}},[]);let ce=(0,bt.jsxs)("div",{ref:S,"data-testid":"architect-copilot-container","aria-hidden":u||!g||void 0,style:p?{width:"100%",height:"100%",overflow:"hidden",visibility:u||!g?"hidden":"visible",pointerEvents:u||!g?"none":void 0}:{position:"absolute",right:12,top:56,bottom:12,width:f,zIndex:15,borderRadius:12,overflow:"hidden",boxShadow:"0 4px 24px rgba(0,0,0,0.12)",visibility:u||!g?"hidden":"visible",pointerEvents:u||!g?"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:c,initialMessageRequest:C,attemptedInitialMessageRequestIdsRef:_,rawInitialMessage:!0,onInitialMessageSubmitted:x},e)},`${n??"default"}:${o??"default"}`)]});return(0,bt.jsxs)(bt.Fragment,{children:[!g&&!u&&(!p||d)?(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:g&&!u,onClose:()=>v(!1),forceRender:!0,destroyOnHidden:!1,styles:{body:{padding:0,overflow:"hidden",height:"100%"}},afterOpenChange:X=>{!X&&!g&&(s?.current??A.current)?.focus()},children:ce}):ce]})};var yn=T(Te());var rn=T(W()),Jn="node:architect-copilot",Pl=({data:e})=>{let{assistantId:t,assistantName:n,workspaceId:o,projectId:r,initialMessageRequest:i,onInitialMessageSubmitted:a,onToolCompleted:c,temporarilyHidden:l=!1,openSignal:u=0,width:y,height:d,center:s}=e,p=yo(),m=(0,yn.useRef)(null),{attemptedRequestIdsRef:g,effectivePendingRequest:v,handleInitialMessageSubmitted:f}=Wn({assistantId:t,initialMessageRequest:i,onInitialMessageSubmitted:a}),w=l,S=()=>p.setCenter(s.x,s.y,{zoom:1,duration:400});return(0,yn.useEffect)(()=>{m.current&&(m.current.inert=w)},[w]),(0,yn.useEffect)(()=>{u>0&&S()},[u]),(0,rn.jsxs)("div",{style:{width:y,height:d,position:"relative",fontFamily:"inherit"},children:[(0,rn.jsx)("div",{ref:m,"data-testid":"architect-copilot-node-panel","aria-hidden":w||void 0,className:"nodrag nowheel nopan",style:{position:"absolute",top:0,left:0,right:0,bottom:0,borderRadius:12,overflow:"hidden",background:"#fff",visibility:w?"hidden":"visible",pointerEvents:w?"none":void 0,userSelect:"text",WebkitUserSelect:"text"},children:(0,rn.jsx)(En,{defaultWorkspaceId:o??void 0,defaultProjectId:r??void 0,children:(0,rn.jsx)(Pn,{workflowContext:{id:t,name:n??"",type:"agent"},onToolCompleted:c,initialMessageRequest:v,attemptedInitialMessageRequestIdsRef:g,rawInitialMessage:!0,showHeader:!1,onInitialMessageSubmitted:f},t)},`${o??"default"}:${r??"default"}`)}),w&&(0,rn.jsxs)("button",{type:"button","data-testid":"architect-copilot-node-badge","aria-label":"Expand architect copilot",onClick:S,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,rn.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:"#22c55e",display:"inline-block"}}),"Architect"]})]})},Xa=yn.default.memo(Pl);var Cr=T(Te());var Go=(e,t,n,o,r)=>({id:e,label:t,x:n-o/2,y:-r/2,width:o,height:r}),hn=Go("zone:config","CONFIG",-767,900,620),_n=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=[hn.id,_n.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=hn.x+hn.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:hn.id,label:hn.label,x:t-hn.width/2,y:-n,width:hn.width,height:n*2}},Fl=900,Ir={x:20,y:20},eo=110,to=48,Wl=220,_l=560,zl=e=>({id:_n.id,label:_n.label,x:_n.x,y:_n.y,width:_n.width,height:Math.max(_l,Wl+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,c=Math.round((e-r*2-a)/2),l=e-r*2-a-c,u=t-i-r,y=Math.round((u-a)/2),d=n.has("learning"),s=n.has("evaluation");return n.has("copilot")?(o.copilot={width:c},d&&(o.learning=s?{left:r,top:i,width:l,height:y}:{left:r,top:i,width:l,height:u}),s&&(o.evaluation=d?{left:r,top:i+y+a,width:l,height:u-y-a}:{left:r,top:i,width:l,height:u}),o):d&&s?(o.learning={left:r,top:i,width:l,height:u},o.evaluation={left:r+l+a,top:i,width:c,height:u},o):(d&&(o.learning={width:c}),s&&(o.evaluation={width:c}),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(Fl,t.height,n.height,r.height,i.height),c=t.x,l=u=>{let y={x:c,y:-a/2,width:u.width,height:a};return c+=u.width+Bl,y};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 ut=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,ut.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,ut.jsx)(Fn,{agentId:e.agentId,runs:e.runs}),e.suites.length>0&&(0,ut.jsxs)("div",{"data-testid":"testing-suites",style:{borderTop:"1px solid #f0f0f0",paddingTop:10,display:"flex",flexDirection:"column",gap:8},children:[(0,ut.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"rgba(0,0,0,0.65)"},children:"Evaluation suites"}),(0,ut.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e.suites.map(t=>(0,ut.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,ut.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:t.label}),t.description&&(0,ut.jsx)("span",{style:{fontSize:10,color:"#999"},children:t.description})]},t.id))})]})]}),ls=Cr.default.memo(Vl),Ql=({data:e})=>(0,ut.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,ut.jsx)("span",{style:{width:10,height:10,borderRadius:9999,background:e.score===null?"#d1d5db":tn(e.score),flexShrink:0}}),(0,ut.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"#6b7280"},children:e.suiteCount})]}),ds=Cr.default.memo(Ql);var Ct=T(Te());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,u)=>new Date(l.createdAt).getTime()-new Date(u.createdAt).getTime()).map((l,u)=>[l.id,u])),r=new Map,i=new Map;for(let l of e)r.set(l.id,[]),i.set(l.id,0);for(let l of e)for(let u of l.dependencies??[])n.has(u)&&u!==l.id&&(r.get(u)?.push(l.id),i.set(l.id,(i.get(l.id)??0)+1));let a=new Set(n),c=[];for(;a.size>0;){let l=null,u=1/0;for(let d of a){if((i.get(d)??0)!==0)continue;let s=o.get(d)??1/0;s<u&&(l=d,u=s)}if(l===null)break;a.delete(l);let y=t.get(l);y&&c.push(y);for(let d of r.get(l)??[])i.set(d,(i.get(d)??0)-1)}for(let l of[...a].sort((u,y)=>(o.get(u)??1/0)-(o.get(y)??1/0))){let u=t.get(l);u&&c.push(u)}return c}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),c=a??i.id,l=r.childrenOf.get(c)??[],u=x=>{let B=id(r,x.id);return B.length===0?null:{count:B.length,dotColor:ad(B)}},y=(x,B,ce)=>({id:x.id,task:x,seq:B,fold:ce?u(x):null,depBadge:sd(x,r.byId)}),d=[],s=[],p=x=>{let B=ms(x);return s.push(...ld(B,x)),B};p(l).forEach((x,B)=>{d.push(y(x,B+1,!1)),p(r.childrenOf.get(x.id)??[]).forEach((ce,V)=>{d.push(y(ce,V+1,!0))})});let m=a?d.map(x=>x.task):[i,...d.map(x=>x.task)],v=ko(m).edges.map(x=>({from:x.from,to:x.to,kind:x.kind==="parent"?"structure":"dependency"}));v.push(...s);let f=null;if(!a){f={id:i.id,label:n!==null?`R${n}`:"R",title:i.title,status:i.status,doneCount:e.filter(B=>B.status==="completed").length,totalCount:e.length};let x=new Set(v.filter(B=>B.from===i.id).map(B=>`${B.to}:${B.kind}`));for(let B of l)x.has(`${B.id}:structure`)||(v.push({from:i.id,to:B.id,kind:"structure"}),x.add(`${B.id}:structure`))}let w=m.map(x=>({id:x.id})),S=bo(w,v.map(x=>({from:x.from,to:x.to})),{nodeWidth:Ko,nodeHeight:cs,nodesep:Xl,ranksep:Jl,rankdir:"TB"}),A=1/0,R=1/0;for(let x of S.values())A=Math.min(A,x.x),R=Math.min(R,x.y);let O=new Map;if(Number.isFinite(A)&&Number.isFinite(R))for(let[x,B]of S)O.set(x,{x:B.x-A,y:B.y-R});let _=0,C=0;for(let x of O.values())_=Math.max(_,x.x+Ko),C=Math.max(C,x.y+cs);return{root:f,tasks:d,edges:v,positions:O,bbox:{width:_,height:C}}}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),c=gs(r),l=r.filter(g=>g.status==="completed").length,u=i?o.findIndex(g=>g.id===i.id):-1,y=i?o.length-u:null,d=o.map((g,v)=>({id:g.id,label:`R${o.length-v}`,title:g.title,status:g.status,createdAt:g.createdAt})),s=r.reduce((g,v)=>g?new Date(v.updatedAt).getTime()>new Date(g.updatedAt).getTime()?v:g:v,null),p=fs(r,n),m=[];if(i&&(m.push({id:i.id,label:`R${y}`}),p)){let g=[],v=c.byId.get(p)??null;for(;v&&v.id!==i.id;)g.unshift(v),v=v.parentId?c.byId.get(v.parentId)??null:null;for(let f of g){let S=ms(c.childrenOf.get(f.parentId??"")??[]).findIndex(A=>A.id===f.id)+1;m.push({id:f.id,label:`${S}.${f.title}`})}}return{tree:r,selectedRound:i,roundTreeById:c.byId,focusId:p,reviewTasks:a,doneCount:l,roundNumber:y,roundOptions:d,roundLatestActivity:ps(s?.updatedAt),breadcrumb:m}}var Nr=({hasRounds:e,reviewCount:t,onReviewClick:n,roundOptions:o,selectedRoundValue:r,onSelectRound:i,roundTitle:a,roundStatus:c,roundDoneCount:l,roundTotalCount:u,roundWaitingCount:y,roundLatestActivity:d,breadcrumb:s,onFocusTask:p,actions:m})=>{let g=c?Gt[c]:null;return(0,te.jsxs)(te.Fragment,{children:[(0,te.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,marginBottom:6},children:[(0,te.jsx)("div",{className:"nodrag nopan nowheel","data-testid":"learning-round-select",children:(0,te.jsx)(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 f=Gt[v.status],w=ps(v.createdAt);return{value:v.id,label:`${v.label} ${v.title} \xB7 ${f.label}${w?` \xB7 ${w}`:""}`}})})}),m]}),!e&&(0,te.jsx)("div",{"data-testid":"learning-empty",style:{fontSize:12,color:"#999",paddingBottom:4},children:"No learning tasks yet"}),g&&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:g.color,flexShrink:0}}),(0,te.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"#262626"},children:g.label}),(0,te.jsx)("span",{style:{fontSize:11,color:"#d1d5db"},children:"\xB7"}),(0,te.jsxs)("span",{style:{fontSize:11,color:"#8c8c8c"},children:[l,"/",u," tasks"]}),y>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 ",y," waiting"]}),d&&(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:d})]})]}),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,f)=>(0,te.jsxs)(Ct.default.Fragment,{children:[f>0&&(0,te.jsx)("span",{style:{color:"#d1d5db"},children:"/"}),(0,te.jsx)("button",{type:"button","data-testid":`learning-crumb-${f}`,onClick:()=>p(f===0?null:v.id),style:{border:"none",background:"transparent",padding:0,cursor:"pointer",fontSize:11,fontWeight:600,color:f===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,Ct.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)(Yt,{}),"data-testid":"learning-new-task",onClick:()=>n(!0),style:{fontSize:12},children:"New Learning Task"})}),(0,te.jsx)(Fo,{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=Ct.default.memo(dd),cd=({data:e})=>{let t=Gt[e.task.status],[n,o]=(0,Ct.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)(Rt,{type:"target",position:it.Top,style:{opacity:0}}),(0,te.jsx)(Rt,{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)(Rt,{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=Ct.default.memo(cd),ud=({data:e})=>{let t=Gt[e.status],[n,o]=(0,Ct.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)(Rt,{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)(Rt,{type:"source",position:it.Bottom,style:{opacity:0}})]})},Zo=Ct.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:c,agentId:l,projectId:u,zone:y}=e;return(0,Ct.useMemo)(()=>{if(!l)return{nodes:[],edges:[],bbox:{...Er},breadcrumb:[]};let d=ed(y),s=Lr(t,n,a),{tree:p,selectedRound:m,roundTreeById:g,focusId:v,reviewTasks:f,doneCount:w,roundNumber:S,roundOptions:A,roundLatestActivity:R,breadcrumb:O}=s,C=[{id:"learning:header",type:"learningHeader",position:d.headerOffset,data:{width:d.headerWidth,hasRounds:t.rounds.length>0,reviewCount:f.length,onReviewClick:()=>{f[0]&&r(f[0],p)},onLearningStarted:c,agentId:l,projectId:u,roundOptions:A,selectedRoundId:n,selectedRoundValue:m?.id??null,onSelectRound:o,roundNumber:S,roundTitle:m?.title??null,roundStatus:m?.status??null,roundDoneCount:w,roundTotalCount:p.length,roundWaitingCount:f.length,roundLatestActivity:R,breadcrumb:O,onFocusTask:i},...Ar}];if(!m)return{nodes:C,edges:[],bbox:{...Er},breadcrumb:O};let x=Ho(p,v,S),B=y.width-vt*2,ce=d.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};C.push({id:"learning:round-root",type:"learningRoundRoot",position:{x:ce+D.x,y:d.dagOffset.y+D.y},data:{label:x.root.label,title:x.root.title,status:x.root.status,doneCount:x.root.doneCount,totalCount:x.root.totalCount,onTaskClick:()=>r(m,p)},...Ar})}for(let D of x.tasks){let $=x.positions.get(D.id)??{x:0,y:0};C.push({id:`learning:task:${D.id}`,type:"learningTask",position:{x:ce+$.x,y:d.dagOffset.y+$.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 X=Mr(x,{byId:g,nodeId:D=>D===m.id?"learning:round-root":`learning:task:${D}`,prefix:"learning:"});return{nodes:C,edges:X,bbox:x.bbox,breadcrumb:O}},[t,n,o,r,i,a,c,l,u,y])}var an=T(Te()),et=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,[c,l]=(0,an.useState)(null),u=e&&a?a.targetSelector:null;(0,an.useEffect)(()=>{if(!u){l(null);return}let s=0,p=null,m=()=>{let v=document.querySelector(u);if(!v){p!==null&&(p=null,l(null));return}let f=v.getBoundingClientRect(),w={left:f.left-Qo,top:f.top-Qo,width:f.width+Qo*2,height:f.height+Qo*2},S=`${w.left}|${w.top}|${w.width}|${w.height}`;S!==p&&(p=S,l(w))};m();let g=()=>{m(),s=window.requestAnimationFrame(g)};return s=window.requestAnimationFrame(g),window.addEventListener("resize",m),()=>{window.cancelAnimationFrame(s),window.removeEventListener("resize",m)}},[u]);let y=(0,an.useRef)(r);if((0,an.useEffect)(()=>{let s=y.current;if(y.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,an.useEffect)(()=>{if(!e||!a)return;let s=a.eventKind;s&&r[s]&&i(s)},[e,t]),!e||!a)return null;let d=t>=Vo.length-1;return(0,et.jsxs)(et.Fragment,{children:[(0,et.jsx)("style",{children:`
|
|
234
|
+
.axiom-onboarding-next:hover { background: #4f46e5 !important; }
|
|
235
|
+
.axiom-onboarding-skip:hover { color: #e5e7eb !important; }
|
|
236
|
+
`}),c&&(0,et.jsx)("div",{"data-testid":"onboarding-tour-ring",style:{position:"fixed",left:c.left,top:c.top,width:c.width,height:c.height,border:"2px solid #6366f1",borderRadius:10,pointerEvents:"none",boxShadow:"0 0 0 9999px rgba(0,0,0,0.35)",zIndex:59}}),(0,et.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,et.jsx)("div",{"data-testid":"onboarding-tour-dots",style:{display:"flex",gap:6,marginBottom:8},children:Vo.map((s,p)=>(0,et.jsx)("span",{style:{width:6,height:6,borderRadius:"9999px",background:p===t?"#6366f1":"rgba(255,255,255,0.28)"}},p))}),(0,et.jsx)("div",{style:{fontSize:14,fontWeight:600,marginBottom:4},children:a.title}),(0,et.jsx)("div",{style:{fontSize:12,lineHeight:1.5,color:"rgba(255,255,255,0.82)"},children:a.description}),(0,et.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:8,marginTop:10},children:[(0,et.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,et.jsx)("button",{type:"button","data-testid":"onboarding-tour-next",className:"axiom-onboarding-next",onClick:()=>d?o():n(t+1),style:{cursor:"pointer",border:"none",borderRadius:6,background:"#6366f1",padding:"5px 14px",fontSize:12,fontWeight:600,color:"#fff"},children:d?"Done":"Next"})]})]})]})};var Mt=T(Te());var bn=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 c=(0,Mt.useMemo)(()=>Lr(e,t,i),[e,t,i]),{dagNodes:l,dagEdges:u}=(0,Mt.useMemo)(()=>{let f=Ho(c.tree,c.focusId,c.roundNumber),w=c.tree,S=[];f.root&&c.selectedRound&&S.push({id:f.root.id,type:"learningRoundRoot",position:f.positions.get(f.root.id)??{x:0,y:0},data:{label:f.root.label,title:f.root.title,status:f.root.status,doneCount:f.root.doneCount,totalCount:f.root.totalCount,onTaskClick:()=>o(c.selectedRound,w)}});for(let R of f.tasks)S.push({id:R.id,type:"learningTask",position:f.positions.get(R.id)??{x:0,y:0},data:{task:R.task,seq:R.seq,depBadge:R.depBadge,fold:R.fold,onTaskClick:()=>o(R.task,w),onFocusTask:R.fold?()=>a(R.id):void 0}});let A=Mr(f,{byId:c.roundTreeById,nodeId:R=>R});return{dagNodes:S,dagEdges:A}},[c,o]),[y,d,s]=Cn(l),[p,m,g]=An(u);(0,Mt.useEffect)(()=>{d(l),m(u)},[l,u,d,m]);let v=(0,Mt.useCallback)((f,w)=>{w.data.onTaskClick?.()},[]);return(0,bn.jsxs)("div",{style:{width:"100%",height:r,display:"flex",flexDirection:"column",minHeight:0},children:[(0,bn.jsx)("div",{className:"nodrag nowheel nopan",style:{flexShrink:0,padding:"12px 16px 4px"},children:(0,bn.jsx)(Nr,{hasRounds:e.rounds.length>0,reviewCount:c.reviewTasks.length,onReviewClick:()=>{c.reviewTasks[0]&&o(c.reviewTasks[0],c.tree)},roundOptions:c.roundOptions,selectedRoundValue:c.selectedRound?.id??null,onSelectRound:n,roundNumber:c.roundNumber,roundTitle:c.selectedRound?.title??null,roundStatus:c.selectedRound?.status??null,roundDoneCount:c.doneCount,roundTotalCount:c.tree.length,roundWaitingCount:c.reviewTasks.length,roundLatestActivity:c.roundLatestActivity,breadcrumb:c.breadcrumb,onFocusTask:a})}),(0,bn.jsx)("div",{style:{flex:1,minHeight:0,position:"relative"},children:(0,bn.jsx)(vo,{nodes:y,edges:p,nodeTypes:pd,onNodesChange:s,onEdgesChange:g,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:c,projectId:l,onProjectChange:u,onLearningStarted:y,onToolActivity:d,learningTasks:s,onLearningRefresh:p,evalTick:m,evalData:g,hudTopOffset:v,copilotTemporarilyHidden:f,onOpenArchitect:w,architectOpenSignal:S=0,architectRestoreFocusRef:A})=>{let[R,O,_]=Cn([]),[C,x,B]=An([]),[ce,V]=(0,G.useState)(null),X=Va(),D=yo(),$=(0,G.useRef)(!1),[K,z]=(0,G.useState)(!hd()),[J,P]=(0,G.useState)(null),H=(0,G.useRef)(null),[ue,be]=(0,G.useState)(()=>!vd()),[Ie,me]=(0,G.useState)(0),[F,E]=(0,G.useState)({zoneActivated:!1,zoneDragged:!1,copilotPinned:!1}),ae=(0,G.useCallback)(k=>{E(I=>I[k]?I:{...I,[k]:!0})},[]),Q=(0,G.useRef)({onInitialMessageSubmitted:c,onToolActivity:d,onLearningStarted:y});Q.current={onInitialMessageSubmitted:c,onToolActivity:d,onLearningStarted:y};let[L,ne]=(0,G.useState)(()=>{let k=new Set;for(let I of Ts()?.pinned??[])kd.includes(I)&&k.add(I);return k}),[he,N]=(0,G.useState)(()=>{let k={};for(let[I,M]of Object.entries(Ts()?.origins??{}))wd.has(I)&&(k[I]=M);return k}),Ee=(0,G.useRef)(L);Ee.current=L;let ye=(0,G.useRef)(he);ye.current=he;let Se=(0,G.useCallback)(k=>{let I=new Set(Ee.current);I.has(k)?I.delete(k):(I.add(k),k==="copilot"&&ae("copilotPinned")),Ee.current=I,ne(I),Rs([...I],ye.current)},[ae]),Me=(0,G.useRef)(null),[tt,kt]=(0,G.useState)(()=>({width:typeof window>"u"?1200:window.innerWidth,height:typeof window>"u"?800:window.innerHeight}));(0,G.useEffect)(()=>{let k=Me.current;if(!k||typeof ResizeObserver>"u")return;let I=()=>{let De=k.getBoundingClientRect();kt({width:De.width,height:De.height})},M=new ResizeObserver(I);return M.observe(k),I(),()=>M.disconnect()},[]);let Ve=(0,G.useMemo)(()=>is(tt.width,tt.height,L),[tt,L]),Qe=Wn({assistantId:n??"",initialMessageRequest:a,onInitialMessageSubmitted:k=>Q.current.onInitialMessageSubmitted?.(k)}),Oe=(0,G.useCallback)(k=>{P(k),ae("zoneActivated"),H.current!==null&&window.clearTimeout(H.current),H.current=window.setTimeout(()=>P(null),700)},[ae]);(0,G.useEffect)(()=>()=>{H.current!==null&&window.clearTimeout(H.current)},[]);let[nt,Ot]=(0,G.useState)(null),[ot,We]=(0,G.useState)(null),[Ft,Kt]=(0,G.useState)(null),Ht=(0,G.useCallback)(k=>Kt(k.id),[]),Wt=(0,G.useCallback)(()=>Kt(null),[]),At=(0,G.useCallback)(k=>We(k),[]),sn=(0,G.useCallback)((k,I,M)=>Q.current.onLearningStarted?.(k,I,M),[]),{suites:pt}=Sn(g.evalProjectId??""),vn=pt.map(k=>`${k.name}:${k.caseCount??0}`).join("|"),Ut=(0,G.useMemo)(()=>{let k={};for(let I of pt)k[I.name]=I.caseCount??0;return k},[vn]),q=(0,G.useMemo)(()=>g.suiteNames.map(k=>({id:`suite:${k}`,type:"eval",label:k,description:`${Ut[k]??0} cases`})),[g.suiteNames,Ut]),ge=(0,G.useMemo)(()=>Ji(e,{includeEmptyGroups:!0}),[e]),st=(0,G.useMemo)(()=>({zone:Za,config:ra,agent:oa,copilot:Xa,testingPanel:ls,testingBadge:ds,learningHeader:hs,learningTask:Uo,learningRoundRoot:Zo}),[]),Ye=Pi(k=>k.transform[2]),Be=(0,G.useRef)("overview"),wt=ss(Ye,Be.current);Be.current=wt;let xt=s??yd,kn=(0,G.useMemo)(()=>{let k=new Map(ge.groups.map(M=>[M.id,M])),I={};for(let M of ge.groups)k.get(M.id)&&(I[M.id]=Math.max($o,56+M.items.length*30));return I},[ge.groups]),zn=(0,G.useMemo)(()=>g.suiteNames.length>0?Math.max($o,56+g.suiteNames.length*30):0,[g.suiteNames]),ln=(0,G.useMemo)(()=>Dr(xt,nt),[xt,nt]),no=(0,G.useMemo)(()=>ys(ln,ot),[ln,ot]),je=(0,G.useMemo)(()=>as({groupHeights:kn,suitesGroupHeight:zn,learningDagBBox:no}),[kn,zn,no]),ve=(0,G.useMemo)(()=>md(je,he),[je,he]),Bn=(0,G.useRef)({}),gt=(0,G.useRef)({}),wn=(0,G.useRef)(null),[dn,oo]=(0,G.useState)({x:0,y:0}),er=(0,G.useMemo)(()=>{let k=ve.learning;return dn.x===0&&dn.y===0?k:{...k,x:k.x+dn.x,y:k.y+dn.y}},[ve,dn]),tr=(0,G.useCallback)((k,I)=>{k.startsWith("zone:")&&(wn.current=k,gt.current[k]={x:I.x,y:I.y})},[]),nr=(0,G.useCallback)((k,I)=>{if(!k.startsWith("zone:"))return;let M=gt.current[k],De={x:I.x,y:I.y};if(gt.current[k]=De,!M)return;let Xe=De.x-M.x,ft=De.y-M.y;if(Xe===0&&ft===0)return;let xn=Bn.current[k]??[];k==="zone:learning"&&oo(Tn=>({x:Tn.x+Xe,y:Tn.y+ft})),xn.length>0&&O(Tn=>Tn.map(Zt=>Zt.position&&xn.indexOf(Zt.id)>=0?{...Zt,position:{x:Zt.position.x+Xe,y:Zt.position.y+ft}}:Zt))},[O]),or=(0,G.useCallback)((k,I)=>{if(!k.startsWith("zone:"))return;wn.current=null,delete gt.current[k],k==="zone:learning"&&oo({x:0,y:0}),ae("zoneDragged");let M=Object.keys(ye.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}}:{...ye.current};M[k]={x:I.x,y:I.y},ye.current=M,N(M),Rs([...Ee.current],M)},[je,ae]),ro=(0,G.useCallback)(()=>{Td(),Ee.current=new Set,ne(new Set),ye.current={},N({})},[]),b=bs({learningTasks:xt,selectedRoundId:nt,zone:er,onSelectRound:Ot,onTaskClick:Ht,onFocusTask:At,focusTaskId:ot,onLearningStarted:sn,agentId:n??"",projectId:l}),re=Ft?Pr(xt,Ft):null;(0,G.useEffect)(()=>{Ft&&!re&&Kt(null)},[Ft,re]),(0,G.useEffect)(()=>{We(null)},[nt]),(0,G.useEffect)(()=>{ot&&!Pr(xt,ot)&&We(null)},[ot,xt]),(0,G.useEffect)(()=>{let k=ge.groups,I=new Map(k.map(de=>[de.id,de])),M=[],De=!!n&&!X,Xe=ve.config,ft=ve.testing,xn=L.has("copilot"),Tn=L.has("learning"),Zt=L.has("evaluation"),Br=[ve.config,ve.testing,ve.learning,ve.copilot].filter(de=>de.id!==ve.copilot.id||De&&!xn).filter(de=>de.id!==ve.learning.id||!!n&&!Tn).filter(de=>de.id!==ve.testing.id||!Zt).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?()=>Se(Ge):void 0},draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1,zIndex:-1,style:{pointerEvents:"none"}}});M.push(...Br);let jr={[ve.config.id]:[],[ve.testing.id]:[],[ve.learning.id]:[],[ve.copilot.id]:[]},jn=(de,Ge)=>{let Gn=jr[de];Gn&&Gn.indexOf(Ge)<0&&Gn.push(Ge)};jn(ve.config.id,ge.agent.id),M.push({id:ge.agent.id,type:"agent",draggable:!1,data:{node:ge.agent,onClick:()=>t?.(ge.agent)},position:ns(Xe)});for(let de of k){let Ge=I.get(de.id);if(!Ge)continue;let Gn=kn[de.id]??Math.max($o,56+de.items.length*30);jn(ve.config.id,de.id),M.push({id:de.id,type:"config",draggable:!1,data:{group:Ge,onClick:_s=>t?.(_s),onRemove:i},position:os(Xe,de.id,Gn)})}L.has("evaluation")||(wt==="badge"?g.suiteNames.length>0&&(jn(ve.testing.id,"testing:badge"),M.push({id:"testing:badge",type:"testingBadge",draggable:!1,data:{score:g.score,suiteCount:g.suiteNames.length},position:rs(ft,eo,to)})):(jn(ve.testing.id,"testing:panel"),M.push({id:"testing:panel",type:"testingPanel",draggable:!1,data:{agentId:n??"",runs:g.runs,width:ft.width-vt*2,height:ft.height-vt*2,suites:q,onSuiteClick:de=>t?.(de)},position:{x:ft.x+Ir.x,y:ft.y+Ir.y}}))),De&&!L.has("copilot")&&(jn(ve.copilot.id,Jn),M.push({id:Jn,type:"copilot",draggable:!1,data:{assistantId:n,assistantName:o??"",workspaceId:r,projectId:l,initialMessageRequest:a??null,onInitialMessageSubmitted:de=>Q.current.onInitialMessageSubmitted?.(de),onToolCompleted:de=>Q.current.onToolActivity?.(de),temporarilyHidden:f??!1,openSignal:S,width:ve.copilot.width,height:ve.copilot.height,center:{x:ve.copilot.x+ve.copilot.width/2,y:ve.copilot.y+ve.copilot.height/2}},position:{x:ve.copilot.x,y:ve.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(M);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${ge.agent.id}-${de.id}`,source:ge.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"}}))},[ge,O,x,i,n,X,r,l,o,f,S,a?.requestId,a?.content,wt,q,g.score,g.suiteNames,g.runs.map(k=>k.id).join(","),ve,kn,L,Se]);let j=Li();(0,G.useEffect)(()=>{if(!j||$.current)return;$.current=!0;let k=D.getNodes().filter(I=>!I.id.startsWith("zone:"));D.fitView({padding:.2,nodes:k}).then(I=>{I&&D.getZoom()<ts&&D.fitView({padding:.2,nodes:D.getNodes().filter(M=>M.type==="agent"||M.type==="config")})})},[j,D]),(0,G.useEffect)(()=>{let k=[["1","zone:config","config"],["2","zone:learning","learning"],["3","zone:testing","testing"],["4","zone:copilot","copilot"]],I=M=>{if(!(M.ctrlKey||M.metaKey))return;let De=k.find(([xn])=>M.key===xn);if(!De)return;let Xe=M.target;if(Xe&&(Xe.tagName==="INPUT"||Xe.tagName==="TEXTAREA"||Xe.tagName==="SELECT"||Xe.isContentEditable))return;M.preventDefault();let ft=ws[De[2]];ft&&L.has(ft)||(Oe(De[2]),D.fitView({padding:.4,duration:400,nodes:[{id:De[1]}]}))};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[D,Oe,L]);let ke=(0,G.useMemo)(()=>{let k=R.some(I=>I.id===ce)?ce:null;return k===null?R:R.map(I=>{if(I.id===Jn||I.id.startsWith("zone:")||I.id.startsWith("testing:"))return I;let M=I.id===k||C.some(De=>De.source===k&&De.target===I.id||De.target===k&&De.source===I.id);return{...I,style:{opacity:M?1:.4,transition:"opacity 0.2s ease"}}})},[R,C,ce]);return(0,le.jsxs)("div",{ref:Me,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:[...ke,...L.has("learning")?[]:b.nodes],edges:[...C,...L.has("learning")?[]:b.edges],onNodesChange:_,onEdgesChange:B,onNodeDragStart:(k,I)=>tr(I.id,I.position),onNodeDrag:(k,I)=>nr(I.id,I.position),onNodeDragStop:(k,I)=>or(I.id,I.position),onNodeMouseEnter:(k,I)=>{I.id===Jn||I.id.startsWith("zone:")||I.id.startsWith("testing:")||I.type?.startsWith("learning")||V(I.id)},onNodeMouseLeave:()=>V(null),onPaneClick:()=>t?.(null),onNodeClick:(k,I)=>{if(I.type!=="learningTask"&&I.type!=="learningRoundRoot")return;I.data.onTaskClick?.()},nodeTypes:st,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:Wt,bodyStyle:{padding:0,overflow:"hidden"},children:re&&(0,le.jsx)(br,{task:re.task,relatedTasks:re.related,onClose:Wt,onRefresh:p,height:"100%"})}),["copilot","learning","evaluation"].map(k=>{let I=Ve[k];return I?(0,le.jsxs)(ht,{open:!0,width:I.width,left:I.left,top:I.top,height:I.height,escapeEnabled:!1,zIndex:20,title:fd[k],onClose:()=>Se(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:M=>Q.current.onToolActivity?.(M),initialMessageRequest:Qe.effectivePendingRequest,attemptedInitialMessageRequestIdsRef:Qe.attemptedRequestIdsRef,rawInitialMessage:!0,showHeader:!1,onInitialMessageSubmitted:Qe.handleInitialMessageSubmitted},n)},`${r??"default"}:${l??"default"}`)}),k==="learning"&&(0,le.jsx)(ks,{learningTasks:xt,selectedRoundId:nt,onSelectRound:Ot,agentId:n??"",projectId:l,onTaskClick:Ht,height:"100%"}),k==="evaluation"&&(0,le.jsx)(Fn,{agentId:n??"",runs:g.runs})]},k):null}),n&&(0,le.jsx)(_o,{assistantId:n,projectId:l,onProjectChange:u,onLearningStarted:y,learningTasks:s,topOffset:v,onLearningRefresh:p,evalTick:m,showLearning:!1,variant:"selector"}),n&&X&&(0,le.jsx)(Bo,{assistantId:n,assistantName:o??"",workspaceId:r,projectId:l,contextType:"agent",initialMessageRequest:a,onInitialMessageSubmitted:c,onToolCompleted:k=>d?.(k),temporarilyHidden:f,openSignal:S,restoreFocusRef:A,showMobileTrigger:w===void 0}),K&&(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),z(!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),be(!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,I])=>{let M=ws[k],De=M!==void 0&&L.has(M);return(0,le.jsx)("button",{type:"button","aria-label":`Fit ${I} zone`,"data-testid":`zone-dot-${k}`,className:J===k?"zone-dot-active":void 0,onClick:()=>{Oe(k),D.fitView({padding:.4,duration:400,nodes:[{id:ve[k].id}]})},style:{width:10,height:10,borderRadius:"9999px",border:"none",padding:0,cursor:"pointer",background:J===k||De?"#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:()=>z(k=>!k),style:{cursor:"pointer",color:"#8c8c8c",fontSize:12,lineHeight:"10px",userSelect:"none"},children:"\u24D8"})]}),(0,le.jsx)(vs,{open:ue,step:Ie,onStep:me,onDone:()=>{xs(!0),be(!1)},events:F,onEventConsumed:k=>E(I=>({...I,[k]:!1}))})]})},Rd=e=>{let t=No(e.assistantId??""),n=(0,G.useRef)(e.evalTick??0);return(0,G.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(Te());var Ue=T(W()),{Text:Fr}=_e;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:c,onProjectChange:l,onLearningStarted:u,onToolActivity:y,learningTasks:d,onLearningRefresh:s,evalTick:p,hideTitleBar:m=!1,hudTopOffset:g,copilotTemporarilyHidden:v,onOpenArchitect:f,architectOpenSignal:w=0,architectRestoreFocusRef:S})=>{let[A,R]=(0,Xo.useState)(!1),O=(0,Xo.useMemo)(()=>Sd(e),[e]);return(0,Ue.jsxs)("div",{style:{width:"100%",height:"100%",position:"relative",background:"#fafafa"},children:[(0,Ue.jsx)(ho,{children:(0,Ue.jsx)("div",{style:{width:"100%",height:"100%"},children:O?(0,Ue.jsx)(Bi,{dsl:O}):(0,Ue.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,Ue.jsx)(Fr,{type:"secondary",children:"No workflow DSL yet \u2014 ask the architect to design one"})})})}),!m&&(0,Ue.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,Ue.jsx)(po,{size:16,color:"#6366f1"}),(0,Ue.jsx)(Fr,{strong:!0,style:{fontSize:13},children:n}),(0,Ue.jsx)(co,{style:{color:"#6366f1",cursor:"pointer",fontSize:15},onClick:()=>R(!0)})]}),(0,Ue.jsx)(_o,{assistantId:t,projectId:c,onProjectChange:l,onLearningStarted:u,learningTasks:d,topOffset:g,onLearningRefresh:s,evalTick:p}),(0,Ue.jsx)(Bo,{assistantId:t,assistantName:n,workspaceId:o,projectId:c,contextType:"workflow",label:"Builder",initialMessageRequest:i,onInitialMessageSubmitted:a,onToolCompleted:_=>y?.(_),temporarilyHidden:v,openSignal:w,restoreFocusRef:S,showMobileTrigger:f===void 0}),(0,Ue.jsx)(Fe,{title:n,open:A,onCancel:()=>R(!1),footer:null,width:"85vw",centered:!0,styles:{body:{maxHeight:"calc(85vh - 120px)",overflow:"auto",padding:"12px 24px 24px"}},children:r?(0,Ue.jsx)(In,{content:r}):(0,Ue.jsx)(Fr,{type:"secondary",children:"No description set."})})]})};var qe=T(Te());var U=T(W()),{Text:Wr}=_e;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,qe.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}=Ze(),[n,o]=(0,qe.useState)(null),[r,i]=(0,qe.useState)(!0);if((0,qe.useEffect)(()=>{let l=!1;return i(!0),t("/api/tools").then(u=>{if(l)return;let y=u.data?.records?.find(d=>d.name===e.label)??null;o(y)}).catch(()=>!l&&o(null)).finally(()=>!l&&i(!1)),()=>{l=!0}},[t,e.label]),r)return(0,U.jsx)(Tt,{size:"small"});if(!n)return(0,U.jsx)(Wr,{type:"secondary",style:{fontSize:13},children:"Tool details unavailable."});let a=n.schema?.properties??{},c=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,u])=>(0,U.jsxs)("div",{style:{display:"flex",gap:8,fontSize:12,padding:"4px 0",alignItems:"baseline"},children:[(0,U.jsxs)("span",{style:{color:"#333",fontWeight:600},children:[l,c.has(l)&&(0,U.jsx)("span",{style:{color:"#ef4444"},children:" *"})]}),(0,U.jsx)("span",{style:{color:"#999"},children:u.type??"any"}),u.description&&(0,U.jsx)("span",{style:{color:"#666",flex:1},children:u.description})]},l))})]})},Ed=({node:e})=>{let{get:t}=Ze(),[n,o]=(0,qe.useState)(null),[r,i]=(0,qe.useState)(!0);return(0,qe.useEffect)(()=>{let a=!1;return i(!0),t(`/api/assistants/${e.label}`).then(c=>!a&&o(c.data??null)).catch(()=>!a&&o(null)).finally(()=>!a&&i(!1)),()=>{a=!0}},[t,e.label]),r?(0,U.jsx)(Tt,{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)(Wr,{type:"secondary",style:{fontSize:13},children:"Sub-agent details unavailable."})},Pd=({node:e})=>{let{get:t}=Ze(),[n,o]=(0,qe.useState)(null),[r,i]=(0,qe.useState)(!0);return(0,qe.useEffect)(()=>{let a=!1;return i(!0),t(`/api/skills/${e.label}`).then(c=>!a&&o(c.data??null)).catch(()=>!a&&o(null)).finally(()=>!a&&i(!1)),()=>{a=!0}},[t,e.label]),r?(0,U.jsx)(Tt,{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)(Wr,{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,c]=(0,qe.useState)({id:i.type??e.id,type:i.type??"unknown",name:i.name??e.label,description:i.description??"",enabled:i.enabled!==!1,config:i.config??{},allowedTools:i.allowedTools}),[l,u]=(0,qe.useState)(!1),y=(o.availableMiddlewareTypes||r)?.find(s=>s.type===a.type),d=async()=>{if(n){u(!0);try{let s=typeof t=="object"&&t!==null?t:{},p=Array.isArray(s.middleware)?s.middleware:[],m={...i,name:a.name,description:a.description,enabled:a.enabled,config:a.config,...a.allowedTools!==void 0?{allowedTools:a.allowedTools}:{}},g=p.some(v=>v.type===a.type)?p.map(v=>v.type===a.type?m:v):[...p,m];await n({...s,middleware:g}),rt.success("Capability saved")}catch{rt.error("Failed to save capability")}finally{u(!1)}}};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ro,{middleware:a,middlewareType:y,onToggle:()=>c(s=>({...s,enabled:!s.enabled})),onConfigChange:s=>c(p=>({...p,config:{...p.config,...s}})),onAllowedToolsChange:s=>c(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 d(),children:"Save"})})]})},Ld=({graphDefinition:e,onSaveGraph:t})=>{let n=typeof e=="object"&&e!==null?e:{},[o,r]=(0,qe.useState)(n.description??""),[i,a]=(0,qe.useState)(n.prompt??""),[c,l]=(0,qe.useState)(n.modelKey??""),[u,y]=(0,qe.useState)(!1),d=async()=>{if(t){y(!0);try{await t({...n,description:o,prompt:i,modelKey:c}),rt.success("Agent saved")}catch{rt.error("Failed to save agent")}finally{y(!1)}}};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(qt,{title:"Description",children:(0,U.jsx)(Pe.TextArea,{"aria-label":"Description",rows:2,value:o,onChange:s=>r(s.target.value)})}),(0,U.jsx)(qt,{title:"Model",children:(0,U.jsx)(Pe,{"aria-label":"Model",size:"small",value:c,onChange:s=>l(s.target.value)})}),(0,U.jsx)(qt,{title:"Prompt",children:(0,U.jsx)(Pe.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:u,onClick:()=>void d(),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)($e,{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(Te());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"]),Fd=new Set(["create_agent","delete_agent"]);function Ms(e){return Fd.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 Wd=300,_r=()=>({rounds:[],round:null,subTasks:[],subTasksByRound:{},loading:!0}),zr=()=>({config:{error:null,updatedAt:null},tasks:{error:null,updatedAt:null,partial:!1}});function _d(e,t,n){let o=new Set(n),r=new Map(e.map(c=>[c.id,c])),i=c=>{let l=c.parentId,u=new Set;for(;l&&!u.has(l);){if(o.has(l))return!0;u.add(l),l=r.get(l)?.parentId}return!1},a=new Set(t.map(c=>c.id));return[...t,...e.filter(c=>!a.has(c.id)&&i(c))]}function Fs(e){let{agentId:t,projectId:n,onAssistantUpdated:o,onAgentListInvalidated:r}=e,{get:i}=Ze(),a=`${t}\0${n??""}`,[c,l]=(0,Ae.useState)(()=>({scope:a,value:_r()})),[u,y]=(0,Ae.useState)(()=>({scope:a,value:0})),[d,s]=(0,Ae.useState)(()=>({scope:a,value:zr()})),p=(0,Ae.useRef)({}),m=(0,Ae.useRef)(0),g=(0,Ae.useRef)(null),v=(0,Ae.useRef)(null),f=(0,Ae.useRef)(0),w=(0,Ae.useRef)({}),S=(0,Ae.useRef)(!1),A=(0,Ae.useRef)(a),R=(0,Ae.useRef)({onAssistantUpdated:o,onAgentListInvalidated:r});(0,Ae.useLayoutEffect)(()=>{R.current={onAssistantUpdated:o,onAgentListInvalidated:r}},[o,r]),(0,Ae.useLayoutEffect)(()=>{if(A.current!==a){A.current=a,m.current+=1,f.current+=1,w.current={},g.current=null,v.current=null,S.current=!1;for(let $ of Object.values(p.current))$&&clearTimeout($);p.current={},l({scope:a,value:_r()}),s({scope:a,value:zr()}),y({scope:a,value:0})}},[a]);let O=c.scope===a?c.value:_r(),_=d.scope===a?d.value:zr(),C=u.scope===a?u.value:0,x=$=>{s(K=>K.scope===a?{scope:a,value:$(K.value)}:K)},B=(0,Ae.useCallback)(async()=>{let $=++f.current,K=a;try{let z=await i(`/api/assistants/${t}`);if($!==f.current||K!==A.current)return;z.success&&z.data?(S.current=!1,R.current.onAssistantUpdated?.(z.data),x(J=>({...J,config:{error:null,updatedAt:new Date}}))):(S.current=!1,x(J=>({...J,config:{...J.config,error:new Error("Configuration refresh returned no agent")}})))}catch(z){if($!==f.current||K!==A.current)return;if(z instanceof Zr&&z.statusCode===404){S.current||R.current.onAgentListInvalidated?.(),S.current=!1,x(P=>({...P,config:{...P.config,error:z}}));return}S.current=!1,console.warn("[useEntityRefresher] config refresh failed",z);let J=z instanceof Error?z:new Error(String(z));x(P=>({...P,config:{...P.config,error:J}}))}},[i,t,a]),ce=(0,Ae.useCallback)(()=>{let $=g.current;if($?.scope===a)return $.promise;let K=++m.current,z=a,J=(async()=>{try{let H=((await i(Mn(t,n))).data??[]).filter(Nn),ue={},be=!1;if(await Promise.all(H.map(async me=>{let F=await wa(i,me.id,{projectId:n});be||=F.partial,ue[me.id]=F.partial?_d(w.current[me.id]??[],F.tasks,F.incompleteParentIds??[]):F.tasks})),K!==m.current||z!==A.current)return;w.current=Object.fromEntries(H.map(me=>[me.id,ue[me.id]??[]]));let Ie=H[0]??null;l({scope:a,value:{rounds:H,round:Ie,subTasks:Ie?ue[Ie.id]??[]:[],subTasksByRound:ue,loading:!1}}),x(me=>({...me,tasks:{error:null,updatedAt:new Date,partial:be}}))}catch(P){if(console.warn("[useEntityRefresher] task refresh failed",P),K!==m.current||z!==A.current)return;l(ue=>ue.scope===a?{scope:a,value:{...ue.value,loading:!1}}:ue);let H=P instanceof Error?P:new Error(String(P));x(ue=>({...ue,tasks:{...ue.tasks,error:H}}))}})().finally(()=>{g.current?.promise===J&&(g.current=null,v.current===z&&A.current===z&&(v.current=null,V.current.refreshLearningTasks()))});return g.current={scope:a,promise:J},J},[i,t,n,a]),V=(0,Ae.useRef)({refreshAgent:B,refreshLearningTasks:ce});(0,Ae.useEffect)(()=>{V.current={refreshAgent:B,refreshLearningTasks:ce}});let X=(0,Ae.useCallback)(($,K)=>{let z=p.current;z[$]&&clearTimeout(z[$]),z[$]=setTimeout(K,Wd)},[]),D=(0,Ae.useCallback)($=>{for(let K of Os($))K==="config"&&X(K,()=>{Ms($)&&(S.current=!0,R.current.onAgentListInvalidated?.()),V.current.refreshAgent()}),K==="tasks"&&X(K,()=>{let z=A.current;g.current?.scope===z?v.current=z:V.current.refreshLearningTasks()}),K==="eval"&&X(K,()=>{let z=A.current;y(J=>J.scope===z?{scope:z,value:J.value+1}:J)})},[X]);return(0,Ae.useEffect)(()=>{ce()},[ce]),(0,Ae.useEffect)(()=>()=>{for(let $ of Object.values(p.current))$&&clearTimeout($)},[]),{handleToolCompleted:D,learningTasks:O,refreshLearningTasks:ce,refreshAgent:B,freshness:_,evalTick:C}}var Y=T(W()),{Text:Ws}=_e,Jo={color:"#4f46e5",background:"#eef2ff"},zd=`
|
|
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
|
+
`,Bd=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,jd=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:{}},am=({assistant:e,allAssistants:t,onBack:n,onDeleted:o,initialTab:r="graph",onSave:i,onAssistantUpdated:a,onAgentListInvalidated:c,initialMessage:l=null,initialMessageCustomRunConfig:u=null,initialProjectId:y=null})=>{let[d,s]=(0,Re.useState)(()=>Bd(r)),[p,m]=(0,Re.useState)(!1),[g,v]=(0,Re.useState)(!1),[f,w]=(0,Re.useState)(null),[S,A]=(0,Re.useState)(0),R=(0,Re.useRef)(null),O=(0,Re.useRef)(()=>{}),_=(0,Re.useRef)(0),C=(0,Re.useRef)(null),x=(0,Re.useRef)(null),B=(0,Re.useRef)(null),ce=(0,Re.useRef)(null),V=(0,Re.useRef)(null),X=(0,Re.useRef)(null),D=(0,Re.useRef)(null),[$,K]=(0,Re.useState)(()=>l?{requestId:`initial:${e.id}`,content:l,...u?{customRunConfig:u}:{}}:null),{workspaceId:z,trainingProjects:J}=Pt(),P=Ns(e.graphDefinition),[H,ue]=(0,Re.useState)(y??P??J[0]?.id??null),be=q=>{ue(q)},Ie=(q,ge,st)=>{let Ye=J.find(Be=>Be.id===H)??null;K({requestId:ge,content:ka({goal:q,roundTaskId:ge,targetAgentId:e.id,targetMode:va(e),files:st,projectId:H??void 0,workspaceId:Ye?.workspaceId??z??void 0}),customRunConfig:{execution:{taskId:ge}}})},me=q=>{K(ge=>ge?.requestId===q?null:ge)};(0,Re.useEffect)(()=>{!H&&J.length>0&&ue(J[0].id)},[H,J]);let[F,E]=(0,Re.useState)(!1),[ae,Q]=(0,Re.useState)(!1),[L,ne]=(0,Re.useState)(!1),[he,N]=(0,Re.useState)(e.graphDefinition),{handleToolCompleted:Ee,learningTasks:ye,refreshLearningTasks:Se,evalTick:Me}=Fs({agentId:e.id,projectId:H,onAssistantUpdated:a,onAgentListInvalidated:c});(0,Re.useEffect)(()=>{N(e.graphDefinition)},[e]);let tt=typeof e.graphDefinition=="object"?e.graphDefinition:{},kt=String(tt.type??"react"),Ve=Dn(kt),Qe=kt==="workflow"?po:$n,Oe=pr(e),nt=fr(e),Ot=qi(nt),ot=q=>{q.kind==="back"?n():q.kind==="close"?s(null):q.kind==="architect"?(s(null),A(ge=>ge+1)):s(q.view)},We=q=>{if(!R.current&&!(q.kind==="dock"&&q.view.kind!=="node"&&d?.kind===q.view.kind&&q.view.kind!=="eval")){if(d?.kind==="configuration"&&p){R.current=q,w(q);return}ot(q)}};O.current=We;let Ft=q=>{let ge=q??(document.activeElement instanceof HTMLElement?document.activeElement:void 0);return ge?{current:ge}:void 0},Kt=(0,Re.useCallback)(q=>{let ge=++_.current;O.current({kind:"dock",view:{kind:"eval",initial:{page:"suites"},navigationKey:ge,restoreFocusRef:Ft(q)}})},[]),Ht=()=>{R.current=null,w(null),requestAnimationFrame(()=>D.current?.())},Wt=()=>{let q=R.current;q&&(R.current=null,w(null),m(!1),ot(q))},At=()=>{Q(!0)},sn=async()=>{E(!0);try{await o(e.id),Q(!1)}finally{E(!1)}},pt=q=>(N(q),i?.(e,q)),vn=i?async(q,ge)=>{await i(q,ge),N({...jd(q.graphDefinition),...ge})}:void 0,Ut=q=>{let ge=typeof he=="object"&&he!==null?he:{},st={...ge};if(q.type==="tool"&&q.id.startsWith("tool:"))st.tools=(ge.tools??[]).filter(Ye=>Ye!==q.id.slice(5));else if(q.type==="subagent"&&q.id.startsWith("sub:"))st.subAgents=(ge.subAgents??[]).filter(Ye=>Ye!==q.id.slice(4));else if(q.type==="skill"&&q.id.startsWith("skill:")){let Ye=q.id.slice(6);st.skills=(ge.skills??[]).filter(Be=>Be!==Ye),Array.isArray(ge.middleware)&&(st.middleware=ge.middleware.map(Be=>{if(Be.type!=="skill")return Be;let wt=typeof Be.config=="object"&&Be.config!==null?Be.config:{};return q.id===mr?{...Be,config:{...wt,readAll:!1}}:!Array.isArray(wt.skills)||!wt.skills.includes(Ye)?Be:{...Be,config:{...wt,skills:wt.skills.filter(xt=>xt!==Ye)}}}))}else if(q.type==="capability"&&q.id.startsWith("cap:")){let Ye=q.id.slice(4);st.middleware=(ge.middleware??[]).filter(Be=>Be.type!==Ye)}else return;N(st),i?.(e,st).catch(()=>rt.error("Failed to save after removing node"))};return(0,Y.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",background:"#fff"},children:[(0,Y.jsx)("style",{"data-agent-detail-responsive":!0,children:zd}),(0,Y.jsxs)("div",{style:{flex:1,minHeight:0,position:"relative"},children:[(0,Y.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,Y.jsx)(ee,{type:"text",size:"small",icon:(0,Y.jsx)(Yr,{}),onClick:()=>We({kind:"back"}),"aria-label":"Back"}),(0,Y.jsx)(Qe,{size:15,color:qn(Ve.color)}),(0,Y.jsx)(Ws,{strong:!0,style:{fontSize:13,maxWidth:220,minWidth:0,flex:"1 1 auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),(0,Y.jsx)("span",{"data-testid":"agent-status-dot",title:nt,style:{width:8,height:8,borderRadius:"50%",background:qn(Ot),flexShrink:0}}),(0,Y.jsx)(ee,{type:"text",size:"small","aria-label":"View description",icon:(0,Y.jsx)(co,{}),style:{color:"#6366f1"},onClick:()=>ne(!0)})]}),(0,Y.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,Y.jsx)(Qt,{title:"Test in Playground",children:(0,Y.jsx)(ee,{ref:C,type:"text",size:"small",icon:(0,Y.jsx)(bi,{size:14}),onClick:()=>We({kind:"dock",view:{kind:"playground"}}),"aria-label":"Test in Playground","aria-pressed":d?.kind==="playground",style:d?.kind==="playground"?Jo:void 0})}),(0,Y.jsx)(Qt,{title:"Eval Suite",children:(0,Y.jsx)(ee,{ref:x,type:"text",size:"small",icon:(0,Y.jsx)(uo,{size:14}),onClick:()=>Kt(x.current??void 0),"aria-label":"Eval Suite","aria-pressed":d?.kind==="eval",style:d?.kind==="eval"?Jo:void 0})}),(0,Y.jsx)(Qt,{title:"Web Apps",children:(0,Y.jsx)(ee,{ref:B,type:"text",size:"small",icon:(0,Y.jsx)(mi,{size:14}),onClick:()=>We({kind:"dock",view:{kind:"web-apps"}}),"aria-label":"Web Apps","aria-pressed":d?.kind==="web-apps",style:d?.kind==="web-apps"?Jo:void 0})}),(0,Y.jsx)(Qt,{title:"Configuration",children:(0,Y.jsx)(ee,{ref:ce,type:"text",size:"small",icon:(0,Y.jsx)(vi,{size:14}),onClick:()=>We({kind:"dock",view:{kind:"configuration"}}),"aria-label":"Configuration","aria-pressed":d?.kind==="configuration",style:d?.kind==="configuration"?Jo:void 0})}),(0,Y.jsx)(Qt,{title:"Delete Agent",children:(0,Y.jsx)(ee,{type:"text",size:"small",danger:!0,icon:(0,Y.jsx)(so,{}),loading:F,onClick:At,"aria-label":"Delete Agent"})})]}),kt==="workflow"?(0,Y.jsx)(Es,{graphDefinition:he,assistantId:e.id,assistantName:e.name,workspaceId:z,description:e.description,hideTitleBar:!0,hudTopOffset:56,initialMessageRequest:$,onInitialMessageSubmitted:me,projectId:H,onProjectChange:be,onLearningStarted:Ie,onToolActivity:Ee,learningTasks:ye,onLearningRefresh:Se,evalTick:Me,architectOpenSignal:S,architectRestoreFocusRef:X,copilotTemporarilyHidden:d!==null}):(0,Y.jsx)(As,{graphDefinition:he,assistantId:e.id,assistantName:e.name,workspaceId:z,hudTopOffset:56,onSelectNode:q=>{q?We({kind:"dock",view:{kind:"node",node:q}}):d?.kind==="node"&&We({kind:"close"})},onRemoveNode:Ut,initialMessageRequest:$,onInitialMessageSubmitted:me,projectId:H,onProjectChange:be,onLearningStarted:Ie,onToolActivity:Ee,learningTasks:ye,onLearningRefresh:Se,evalTick:Me,architectOpenSignal:S,architectRestoreFocusRef:X,copilotTemporarilyHidden:d!==null}),d?.kind==="node"&&(0,Y.jsx)(ht,{open:!0,width:Ps(d.node),title:Ds(d.node),onClose:()=>s(null),children:(0,Y.jsx)(Ls,{node:d.node,graphDefinition:he,assistantId:e.id,onRemoveNode:q=>{Ut(q),s(null)},onSaveGraph:pt})}),d?.kind==="playground"&&(0,Y.jsx)(ht,{open:!0,width:720,title:"Playground",onClose:()=>We({kind:"close"}),restoreFocusRef:C,children:(0,Y.jsx)(zi,{assistant_id:e.id})}),d?.kind==="eval"&&(0,Y.jsx)(ht,{open:!0,width:860,title:d.initial?.page==="run"?"Run Results":"Eval Suite",onClose:()=>We({kind:"close"}),restoreFocusRef:d.restoreFocusRef??x,children:(0,Y.jsx)(So,{assistantId:e.id,initial:d.initial,navigationKey:d.navigationKey})},d.navigationKey),d?.kind==="web-apps"&&(0,Y.jsx)(ht,{open:!0,width:960,title:"Web Apps",onClose:()=>We({kind:"close"}),restoreFocusRef:B,bodyStyle:{padding:0,overflow:"hidden"},children:(0,Y.jsx)(Xi,{assistant:e})}),d?.kind==="configuration"&&(0,Y.jsx)(ht,{open:!0,width:"80%",mobileWidth:"calc(100% - 24px)",title:"Configuration",onClose:()=>We({kind:"close"}),bodyStyle:{padding:0,overflow:"hidden"},restoreFocusRef:V,focusControlRef:D,escapeEnabled:!g&&!L&&!ae&&f===null,children:(0,Y.jsx)(Vi,{assistant:{...e,graphDefinition:he},allAssistants:t,visible:!0,onClose:()=>We({kind:"close"}),onSave:vn,onDirtyChange:m,onOverlayOpenChange:v,embedded:!0})})]}),(0,Y.jsx)(Fe,{title:"Discard unsaved configuration?",open:f!==null,onCancel:Ht,onOk:Wt,okText:"Discard",okButtonProps:{danger:!0},cancelText:"Continue editing",children:(0,Y.jsx)("p",{children:"You have unsaved configuration changes. Discard them and continue?"})}),(0,Y.jsxs)(Fe,{title:e.name,open:L,onCancel:()=>ne(!1),footer:null,width:640,centered:!0,children:[(0,Y.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:12},children:[(0,Y.jsx)($e,{color:Ve.color,style:{margin:0},children:Ve.label}),Oe.map(q=>(0,Y.jsx)($e,{color:"magenta",style:{margin:0},children:q},q)),(0,Y.jsx)($e,{style:{margin:0},children:gr(e)}),(0,Y.jsx)($e,{color:Ot,style:{margin:0},children:nt})]}),e.description?(0,Y.jsx)(In,{content:e.description}):(0,Y.jsx)(Ws,{type:"secondary",children:"No description set."})]}),(0,Y.jsx)(Fe,{title:"Delete Agent",open:ae,onCancel:()=>Q(!1),onOk:sn,okText:"Delete",okButtonProps:{danger:!0,loading:F},cancelText:"Cancel",children:(0,Y.jsxs)("p",{children:['Are you sure you want to delete "',e.name,'"? This action cannot be undone.']})})]})};export{Dn as a,qn as b,Gd as c,$d as d,qd as e,fa as f,ya as g,Iu as h,ha as i,ba as j,ka as k,am as l};
|