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