@axiom-lattice/gateway 10.0.0 → 10.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/embed/embed-page-AgentDetailSideApp-5L5GY5TY.js +1 -0
  2. package/dist/embed/embed-page-AgentGovernanceWorkbench-RKNSCQUM.js +1 -0
  3. package/dist/embed/{embed-page-LangfuseDashboard-NPYFMKK3.js → embed-page-LangfuseDashboard-QHWHMJVB.js} +1 -1
  4. package/dist/embed/{embed-page-MessageGraph-JUCEXYLU.js → embed-page-MessageGraph-HDJYCYZV.js} +1 -1
  5. package/dist/embed/{embed-page-ReactChart-2QJ3QRBH.js → embed-page-ReactChart-KJS73V5Q.js} +1 -1
  6. package/dist/embed/embed-page-SkillFlow-ULY3XZ3A.js +1 -0
  7. package/dist/embed/{embed-page-TasksSideApp-SBHVHNVT.js → embed-page-TasksSideApp-X2YZGU7K.js} +1 -1
  8. package/dist/embed/{embed-page-ThreadMaintenancePanel-LCCRUA75.js → embed-page-ThreadMaintenancePanel-N5IFOOFT.js} +1 -1
  9. package/dist/embed/{embed-page-TopologyRuntimeView-ATA23XXF.js → embed-page-TopologyRuntimeView-LZTSYJE5.js} +1 -1
  10. package/dist/embed/embed-page-WorkflowAutomationView-KIKV62O2.js +3 -0
  11. package/dist/embed/{embed-page-chunk-Q7Z7MHOM.js → embed-page-chunk-3FNSGFP2.js} +1 -1
  12. package/dist/embed/embed-page-chunk-3XPHW2C7.js +1 -0
  13. package/dist/embed/{embed-page-chunk-VNRFN74K.js → embed-page-chunk-4BPMGDDV.js} +1 -1
  14. package/dist/embed/{embed-page-chunk-7F5BSMP3.js → embed-page-chunk-54M4265G.js} +1 -1
  15. package/dist/embed/{embed-page-chunk-DJKD2PHO.js → embed-page-chunk-5AWYMAAX.js} +1 -1
  16. package/dist/embed/embed-page-chunk-5HWN5HSA.js +2 -0
  17. package/dist/embed/{embed-page-chunk-RFF7S4H5.js → embed-page-chunk-5QZRLAW2.js} +5 -5
  18. package/dist/embed/{embed-page-chunk-ODTY6SE7.js → embed-page-chunk-BBIV2YA2.js} +1 -1
  19. package/dist/embed/{embed-page-chunk-F7TA3LRH.js → embed-page-chunk-BUFWD6SE.js} +28 -28
  20. package/dist/embed/{embed-page-chunk-HUH33Z2E.js → embed-page-chunk-DI5UAV2I.js} +1 -1
  21. package/dist/embed/embed-page-chunk-FF2HNPMW.js +242 -0
  22. package/dist/embed/{embed-page-chunk-FE6KYRCO.js → embed-page-chunk-HQLSH3FC.js} +1 -1
  23. package/dist/embed/{embed-page-chunk-B2KNZ3EW.js → embed-page-chunk-L7GPZSYD.js} +1 -1
  24. package/dist/embed/embed-page-chunk-MVT6CPWE.js +6986 -0
  25. package/dist/embed/{embed-page-chunk-PTKGTA4B.js → embed-page-chunk-YBP3MD23.js} +1 -1
  26. package/dist/embed/{embed-page-chunk-34RWKVD7.js → embed-page-chunk-Z4Z6VCUZ.js} +1 -1
  27. package/dist/embed/{embed-page-code-highlighter-72YW5HXH.js → embed-page-code-highlighter-4XNLEZAM.js} +1 -1
  28. package/dist/embed/embed-page-en-2S7Q4NKN.js +1 -0
  29. package/dist/embed/embed-page-en-62EWM6GG.js +1 -0
  30. package/dist/embed/embed-page-en-N642QNBS.js +1 -0
  31. package/dist/embed/embed-page-en-TQ2XQQ5G.js +1 -0
  32. package/dist/embed/{embed-page-mermaid-4PZJJXQU.js → embed-page-mermaid-QZJOSGTZ.js} +1 -1
  33. package/dist/embed/embed-page-zh-55JYGLJM.js +1 -0
  34. package/dist/embed/embed-page-zh-7MFXKHQB.js +1 -0
  35. package/dist/embed/embed-page-zh-GX6IEO57.js +1 -0
  36. package/dist/embed/embed-page-zh-HRXFYKH4.js +1 -0
  37. package/dist/embed/embed-page.js +1 -1
  38. package/dist/embed/mcp-app-page.js +32 -32
  39. package/dist/index.js +46 -113
  40. package/dist/index.js.map +1 -1
  41. package/dist/index.mjs +49 -114
  42. package/dist/index.mjs.map +1 -1
  43. package/package.json +7 -7
  44. package/dist/embed/embed-page-AgentDetailSideApp-X5HKDN3N.js +0 -1
  45. package/dist/embed/embed-page-AgentGovernanceWorkbench-MFXL7BOW.js +0 -1
  46. package/dist/embed/embed-page-SkillFlow-PFEXQ75Z.js +0 -1
  47. package/dist/embed/embed-page-WorkflowAutomationView-OVGOUVXH.js +0 -3
  48. package/dist/embed/embed-page-chunk-HLBQ5JKL.js +0 -6968
  49. package/dist/embed/embed-page-chunk-LZ4ITV3M.js +0 -242
  50. package/dist/embed/embed-page-chunk-QOPHOXA7.js +0 -3
  51. package/dist/embed/embed-page-chunk-WE6PZS2N.js +0 -1
  52. package/dist/embed/embed-page-en-ISNUZBPO.js +0 -1
  53. package/dist/embed/embed-page-en-KZQZS4JN.js +0 -1
  54. package/dist/embed/embed-page-en-QJRX2NQE.js +0 -1
  55. package/dist/embed/embed-page-en-VHD2WUUG.js +0 -1
  56. package/dist/embed/embed-page-zh-A7DSGF6P.js +0 -1
  57. package/dist/embed/embed-page-zh-HTEHFCSL.js +0 -1
  58. package/dist/embed/embed-page-zh-KSZOJPOV.js +0 -1
  59. package/dist/embed/embed-page-zh-MDJTBW2K.js +0 -1
@@ -0,0 +1,242 @@
1
+ import{a as gr,b as Pn}from"./embed-page-chunk-5HWN5HSA.js";import{b as qi,c as $i}from"./embed-page-chunk-DI5UAV2I.js";import{a as Io}from"./embed-page-chunk-4BPMGDDV.js";import{c as xo,d as To}from"./embed-page-chunk-HQLSH3FC.js";import{b as st,c as Li,d as ko,e as xt,f as wo,g as Mi,h as Cn,i as Sn,j as Ni,l as Oi,m as Fi}from"./embed-page-chunk-5AWYMAAX.js";import{a as pn}from"./embed-page-chunk-D7YTSCUO.js";import{a as Ki,b as Hi}from"./embed-page-chunk-BBIV2YA2.js";import{J as _i,K as Ro,L as Co,M as So,N as Wi,O as Ao,P as zi,Q as Bi,R as Po,S as ji,T as An,V as pr,W as Gi,b as Ci,d as mo,e as Si,f as yo,g as vo,j as Rn,o as In,p as ho,q as Ai,t as Pi,u as Ei,v as Di,w as bo}from"./embed-page-chunk-MVT6CPWE.js";import{g as Ii,i as Lt}from"./embed-page-chunk-54M4265G.js";import{a as et}from"./embed-page-chunk-3XPHW2C7.js";import{b as Yr,j as Xr,l as Jr,o as yt,t as co}from"./embed-page-chunk-5QZRLAW2.js";import{Da as wi,H as ci,J as ui,La as xi,N as pi,Q as gi,S as fi,Sa as fo,Ta as Ti,U as go,Ua as Ri,ba as mi,g as si,m as li,n as Gn,ra as yi,sa as vi,ta as hi,va as bi,wa as ki,z as di}from"./embed-page-chunk-F7ZUYG42.js";import{l as _}from"./embed-page-chunk-3FNSGFP2.js";import{a as z}from"./embed-page-chunk-QV7QAJ4N.js";import{B as ni,G as uo,Ja as Dt,Oa as ri,P as Tn,Q as oi,Qa as ii,Ra as cr,Sa as ur,bb as ai,ea as dr,i as ei,s as ti,sa as po,z as jn}from"./embed-page-chunk-L7GPZSYD.js";import{Da as fe,Ia as _e,Ja as wt,Ma as Be,W as Pt,Ya as lo,Za as He,_ as Z,_a as Vr,aa as Ve,ba as Gt,bb as Ge,db as Qr,fa as at,ha as Jt,ja as sr,ka as lr,pa as Hr,sa as un,va as Ur,ya as Zr,za as Et}from"./embed-page-chunk-BUFWD6SE.js";import{a as Pe}from"./embed-page-chunk-R5QL57JJ.js";import{f as I}from"./embed-page-chunk-QBTAJ2YI.js";var Hs={react:{label:"capability",color:"blue"},capability:{label:"capability",color:"blue"},deep_agent:{label:"orchestrator",color:"orange"},orchestrator:{label:"orchestrator",color:"orange"},processing:{label:"workflow",color:"purple"},workflow:{label:"workflow",color:"purple"},a2a_remote:{label:"remote",color:"cyan"},remote:{label:"remote",color:"cyan"}};function En(e){return Hs[e]??{label:"capability",color:"blue"}}var Us={enabled:"green",draft:"orange",disabled:"default"};function Zi(e){return Us[e]??"default"}var Ui={blue:"#3b82f6",orange:"#f59e0b",green:"#22c55e",purple:"#a855f7",cyan:"#06b6d4"};function Kn(e){return Ui[e]??Ui.cyan}function Yd(e){let t={enabled:"#22c55e",draft:"#f59e0b",disabled:"#d9d9d9"};return t[e]??t.disabled}function Dn(e){return typeof e.graphDefinition=="object"&&e.graphDefinition!==null?e.graphDefinition:{}}function mr(e){return((Dn(e).metadata??{}).tags??"").split(",").map(r=>r.trim()).filter(Boolean)}function yr(e){let o=(Dn(e).metadata??{}).version;return o?o.startsWith("v")?o:`v${o}`:"v1"}function vr(e){let o=(Dn(e).metadata??{}).status??"enabled";return o==="draft"||o==="disabled"?o:"enabled"}function fr(e){let n=Dn(e).subAgents??[],o=Array.isArray(n)?n.filter(Boolean):[];return Array.from(new Set(o))}function Xd(e){return e.map(t=>{let n=Dn(t),o=String(n.type??"react");return{id:t.id,name:t.name,description:t.description,type:En(o).label,tags:mr(t),version:yr(t),status:vr(t),subAgents:fr(t)}})}function Jd(e){let t=new Set(e.map(r=>r.id)),n=e.map(r=>({id:r.id,label:r.name,type:En(String(Dn(r).type??"react")).label,subAgentCount:fr(r).length})),o=[];for(let r of e)for(let i of fr(r))t.has(i)&&o.push({source:r.id,target:i});return{nodes:n,edges:o}}var Ee=I(Pe());var te=I(Pe());var k=I(z()),{TextArea:Zs}=_e,{Text:Tt}=Ge,Vi=["data","execution","workflow","assistant"],Qi={data:"chatConfig.agentPanel.category.data",execution:"chatConfig.agentPanel.category.execution",workflow:"chatConfig.agentPanel.category.workflow",assistant:"chatConfig.agentPanel.category.assistant",other:"chatConfig.agentPanel.category.other"},Vs={react:"chatConfig.agentPanel.typeDesc.react",deep_agent:"chatConfig.agentPanel.typeDesc.deepAgent"},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},Yi=e=>{if(typeof e!="string")return qn(e??null);try{return qn(JSON.parse(e))}catch{return e}},Xi=e=>JSON.stringify(qn({...e,tools:[...e.tools].sort(),subAgents:[...e.subAgents].sort()})),Qs=Ii(({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
+ `})),Ji=(e,t)=>t?.find(n=>n.type===e),ea=({assistant:e,allAssistants:t,visible:n,onClose:o,onSave:r,onDelete:i,embedded:d,initialSection:u="basic",onDirtyChange:l,onOverlayOpenChange:a})=>{let{message:v}=Ve.useApp(),[y]=fe.useForm(),{token:f}=Vr.useToken(),{styles:c}=Qs(),{styles:p}=zi(),s=_(),{config:b}=co(),{middlewareTypes:h,isLoading:m}=Ao(b.middlewareTypesEndpoint),{get:w}=et(),[R,P]=(0,te.useState)(u),[S,K]=(0,te.useState)(e),[C,x]=(0,te.useState)(null),[L,ce]=(0,te.useState)(!0),[J,V]=(0,te.useState)(!1),[ge,E]=(0,te.useState)(!1),[B,O]=(0,te.useState)(!1),[ne,ie]=(0,te.useState)(!1),[D,U]=(0,te.useState)([]),[ve,Y]=(0,te.useState)(""),[ke,Me]=(0,te.useState)(""),[F,re]=(0,te.useState)([]),[Re,j]=(0,te.useState)([]),[oe,G]=(0,te.useState)(""),[se,M]=(0,te.useState)(!1),[he,Ne]=(0,te.useState)("react"),[be,Se]=(0,te.useState)([]),[Fe,rt]=(0,te.useState)({name:"",description:""}),[Ze,tt]=(0,te.useState)(""),[Oe,bt]=(0,te.useState)(null),[Wt,Ct]=(0,te.useState)(!1),zt=(0,te.useRef)(0),St=(0,te.useRef)(null),$e=(0,te.useRef)(!1),wn=(0,te.useRef)(l),Zt=(0,te.useRef)(a);(0,te.useEffect)(()=>{wn.current=l},[l]),(0,te.useEffect)(()=>()=>{wn.current?.(!1)},[]),(0,te.useEffect)(()=>{Zt.current=a},[a]),(0,te.useEffect)(()=>()=>{Zt.current?.(!1)},[]);let Bt=(0,te.useMemo)(()=>Xi({form:Fe,agentType:he,tools:F,subAgents:Re,prompt:oe,middleware:be,graphDefinition:Yi(S?.graphDefinition)}),[Fe,he,F,Re,oe,be,S?.graphDefinition]),je=Wt&&Bt!==Ze,ln=Wt;$e.current=je;let kt=(0,te.useMemo)(()=>{if(!e?.graphDefinition)return null;try{let g=typeof e.graphDefinition=="string"?JSON.parse(e.graphDefinition):e.graphDefinition;return{tools:g.tools||[],prompt:g.prompt||"",subAgents:g.subAgents||[],type:g.type||"react",middleware:g.middleware||[]}}catch{return null}},[e]),dn=(0,te.useCallback)(g=>(g||[]).filter(N=>N.schema?.properties&&Object.keys(N.schema.properties).length>0||N.tools&&N.tools.length>0).map((N,ue)=>({id:`${N.type}-${ue+1}`,type:N.type,name:N.name,description:N.description,enabled:!1,config:{}})),[]),Vt=(0,te.useCallback)((g,W)=>{let N=(W||[]).filter(Te=>Te.schema?.properties&&Object.keys(Te.schema.properties).length>0||Te.tools&&Te.tools.length>0),ue=new Map(g?.map(Te=>[Te.type,Te])||[]),dt=N.map((Te,so)=>{let Wn=ue.get(Te.type);return Wn?{...Wn,name:Te.name,description:Te.description}:{id:`${Te.type}-${so+1}`,type:Te.type,name:Te.name,description:Te.description,enabled:!1,config:{}}}),mt=new Set(N.map(Te=>Te.type));return[...dt,...(g??[]).filter(Te=>!mt.has(Te.type))]},[]),nt=(0,te.useCallback)(async()=>{if(n){V(!0);try{let g=await w("/api/tools");g.success&&g.data?.records&&U(g.data.records)}catch(g){console.error("Failed to fetch tools:",g)}finally{V(!1)}}},[w,n]);(0,te.useEffect)(()=>{if(!n||!e){St.current=null,zt.current+=1,Ct(!1),K(e),bt(null);return}if(St.current===e||St.current?.id===e.id&&$e.current)return;let g=b.availableMiddlewareTypes;if(!(!g&&m)){St.current=e,zt.current+=1;{nt();let W={name:e.name??"",description:e.description??""},N=kt?.tools??[],ue=kt?.subAgents??[],dt=kt?.prompt??"",mt=kt?.type??"react",Te=kt?Vt(kt.middleware,g||h):dn(g||h);Ct(!1),K(e),rt(W),re(N),j(ue),G(dt),Ne(mt),Se(Te),y.setFieldsValue({...W,type:mt}),bt(Xi({form:W,agentType:mt,tools:N,subAgents:ue,prompt:dt,middleware:Te,graphDefinition:Yi(e.graphDefinition)}))}}},[n,e,je,kt,y,nt,dn,Vt,b.availableMiddlewareTypes,m,h]),(0,te.useEffect)(()=>{Oe!==null&&Bt===Oe&&(tt(Oe),bt(null),Ct(!0))},[Bt,Oe]),(0,te.useEffect)(()=>{l?.(je)},[je,l]),(0,te.useEffect)(()=>{Zt.current?.(se||ne)},[se,ne]);let q=async()=>{if(!S||!ln)return;let g=zt.current,W=Bt;try{E(!0);let ue={...await y.validateFields(),type:he,tools:F,subAgents:Re,prompt:oe,middleware:be};await r?.(S,ue),zt.current===g&&tt(W)}catch(N){N instanceof Error&&v.error(N.message)}finally{E(!1)}},Ce=async()=>{if(e){O(!0);try{await i?.(e),ie(!1),o()}catch(g){ie(!1),v.error(g instanceof Error?g.message:s("chatConfig.agentPanel.deleteFailed"))}finally{O(!1)}}},it=g=>{Se(W=>W.map(N=>{if(N.id!==g)return N;if(N.enabled)return{...N,enabled:!1};{let ue=(b.availableMiddlewareTypes||h)?.find(dt=>dt.type===N.type);return{...N,enabled:!0,config:ue?.defaultConfig||{}}}}))},Je=(g,W)=>{Se(N=>N.map(ue=>ue.id===g?{...ue,config:{...ue.config,...W}}:ue))},Ae=(g,W)=>{Se(N=>N.map(ue=>ue.id===g?{...ue,allowedTools:W}:ue))},me=g=>{let W=F.includes(g.id);return(0,k.jsx)(mo,{item:g,className:W?c.selectedCard:void 0,onClick:()=>re(N=>N.includes(g.id)?N.filter(ue=>ue!==g.id):[...N,g.id]),renderIcon:()=>(0,k.jsx)("span",{style:{fontSize:18,fontWeight:600},children:g.name.charAt(0).toUpperCase()}),renderPrimary:()=>(0,k.jsxs)(Et,{size:6,children:[(0,k.jsx)("span",{children:g.name}),g.needUserApprove&&(0,k.jsx)(He,{color:"warning",style:{fontSize:10,padding:"0 4px",margin:0},children:s("chatConfig.agentPanel.approve")})]}),renderDetails:()=>(0,k.jsx)(Bi,{text:g.description,className:c.toolDesc}),renderHeaderActions:()=>(0,k.jsx)(un,{checked:W,onClick:N=>N.stopPropagation(),onChange:()=>re(N=>N.includes(g.id)?N.filter(ue=>ue!==g.id):[...N,g.id])})},g.id)},xn=g=>{let W=Re.includes(g.id);return(0,k.jsx)(mo,{item:g,className:W?c.selectedCard:void 0,onClick:()=>j(N=>N.includes(g.id)?N.filter(ue=>ue!==g.id):[...N,g.id]),renderIcon:()=>(0,k.jsx)(sr,{size:36,style:{backgroundColor:W?f.colorPrimary:f.colorSuccess,fontSize:15},children:g.name?.charAt(0).toUpperCase()||"A"}),renderPrimary:()=>g.name,renderSecondary:()=>g.description||s("chatConfig.agentPanel.noDescription"),renderHeaderActions:()=>(0,k.jsx)(un,{checked:W,onClick:N=>N.stopPropagation(),onChange:()=>j(N=>N.includes(g.id)?N.filter(ue=>ue!==g.id):[...N,g.id])})},g.id)},Qt=(0,te.useCallback)(g=>Ji(g.type,b.availableMiddlewareTypes||h)?.category||"other",[b.availableMiddlewareTypes,h]),Yt=(0,te.useMemo)(()=>{let g=new Map;for(let W of be){let N=Qt(W),ue=g.get(N);ue?ue.push(W):g.set(N,[W])}return g},[be,Qt]),cn=(0,te.useMemo)(()=>{let g=Array.from(Yt.keys());return[...Vi.filter(W=>Yt.has(W)),...g.filter(W=>!Vi.includes(W))]},[Yt]),At=(0,te.useMemo)(()=>be.length===0?null:be.find(g=>g.type===C)??be.find(g=>g.enabled)??be[0],[be,C]);if(!n||!e)return null;let rr=[{key:"basic",icon:(0,k.jsx)(ur,{}),label:s("chatConfig.agentPanel.nav.basic")},{key:"prompt",icon:(0,k.jsx)(dr,{}),label:s("chatConfig.agentPanel.nav.prompt")},{key:"tools",icon:(0,k.jsx)(ai,{}),label:s("chatConfig.agentPanel.nav.tools"),badge:F.length},{key:"middleware",icon:(0,k.jsx)(ni,{}),label:s("chatConfig.agentPanel.nav.capabilities"),badge:be.filter(g=>g.enabled).length},{key:"subagents",icon:(0,k.jsx)(ri,{}),label:s("chatConfig.agentPanel.nav.subAgents"),badge:Re.length}],oo=D.filter(g=>g.name.toLowerCase().includes(ve.toLowerCase())||g.description.toLowerCase().includes(ve.toLowerCase())),Xt=t.filter(g=>g.id!==e.id),ro=Xt.filter(g=>(g.name||"").toLowerCase().includes(ke.toLowerCase())||(g.description||"").toLowerCase().includes(ke.toLowerCase())),ir=()=>(0,k.jsxs)("div",{style:{maxWidth:960},children:[(0,k.jsxs)("div",{className:c.pageHeader,children:[(0,k.jsx)("div",{className:c.pageIcon,children:(0,k.jsx)(ur,{})}),(0,k.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,k.jsx)("h2",{className:c.pageName,children:s("chatConfig.agentPanel.basic.title")}),(0,k.jsx)("p",{className:c.pageDesc,children:s("chatConfig.agentPanel.basic.desc")})]})]}),(0,k.jsxs)(fe,{form:y,layout:"vertical",autoComplete:"off",onValuesChange:(g,W)=>rt({name:W.name??"",description:W.description??""}),children:[(0,k.jsx)(fe.Item,{name:"name",label:(0,k.jsx)(Tt,{strong:!0,style:{fontSize:14},children:s("chatConfig.agentPanel.field.name")}),rules:[{required:!0,message:s("chatConfig.agentPanel.validation.nameRequired")}],style:{marginBottom:24},children:(0,k.jsx)(_e,{placeholder:s("chatConfig.agentPanel.placeholder.name")})}),(0,k.jsxs)(fe.Item,{name:"type",label:(0,k.jsx)(Tt,{strong:!0,style:{fontSize:14},children:s("chatConfig.agentPanel.field.agentType")}),rules:[{required:!0}],style:{marginBottom:24},children:[(0,k.jsx)(Ur,{value:he,onChange:g=>Ne(g),options:[{value:"react",label:s("chatConfig.agentType.executor")},{value:"deep_agent",label:s("chatConfig.agentType.orchestrator")}],block:!0}),(0,k.jsx)(Tt,{type:"secondary",style:{fontSize:13,marginTop:8,display:"block",lineHeight:1.6},children:s(Vs[he]??"chatConfig.agentPanel.typeDesc.react")})]}),(0,k.jsx)(fe.Item,{name:"description",label:(0,k.jsx)(Tt,{strong:!0,style:{fontSize:14},children:s("chatConfig.agentPanel.field.description")}),rules:[{required:!0,message:s("chatConfig.agentPanel.validation.descriptionRequired")}],style:{marginBottom:0},children:(0,k.jsx)(_e.TextArea,{placeholder:s("chatConfig.agentPanel.placeholder.description"),autoSize:{minRows:3,maxRows:6}})})]})]}),io=()=>(0,k.jsxs)("div",{style:{maxWidth:960},children:[(0,k.jsxs)("div",{className:c.pageHeader,children:[(0,k.jsx)("div",{className:c.pageIcon,children:(0,k.jsx)(dr,{})}),(0,k.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,k.jsx)("h2",{className:c.pageName,children:s("chatConfig.agentPanel.prompt.title")}),(0,k.jsx)("p",{className:c.pageDesc,children:s("chatConfig.agentPanel.prompt.desc")})]}),(0,k.jsx)(Z,{icon:(0,k.jsx)(Tn,{}),onClick:()=>M(!0),children:s("chatConfig.agentPanel.prompt.expand")})]}),(0,k.jsx)(Zs,{"aria-label":s("chatConfig.agentPanel.prompt.title"),value:oe,onChange:g=>G(g.target.value),placeholder:s("chatConfig.agentPanel.prompt.placeholder"),autoSize:{minRows:12,maxRows:24},style:{fontFamily:"monospace",fontSize:13,lineHeight:1.7}}),(0,k.jsx)("div",{style:{marginTop:8,display:"flex",justifyContent:"flex-end"},children:(0,k.jsx)(Tt,{type:"secondary",style:{fontSize:12},children:s("chatConfig.agentPanel.prompt.chars",{count:oe.length})})})]}),jt=()=>(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)("div",{className:c.sectionHeader,children:[(0,k.jsxs)("div",{children:[(0,k.jsx)("h2",{className:c.sectionTitle,children:s("chatConfig.agentPanel.tools.title")}),(0,k.jsx)("p",{className:c.sectionDesc,children:s("chatConfig.agentPanel.tools.desc")})]}),(0,k.jsxs)("div",{className:c.sectionActions,children:[(0,k.jsx)(_e,{allowClear:!0,prefix:(0,k.jsx)(cr,{}),placeholder:s("chatConfig.agentPanel.tools.search"),value:ve,onChange:g=>Y(g.target.value),className:c.searchBox}),(0,k.jsx)(Tt,{type:"secondary",style:{fontSize:13},children:s("chatConfig.agentPanel.tools.selected",{selected:F.length,total:D.length})}),(0,k.jsx)(Z,{size:"small",onClick:()=>re(F.length===D.length?[]:D.map(g=>g.id)),children:F.length===D.length?s("chatConfig.agentPanel.clear"):s("chatConfig.agentPanel.selectAll")})]})]}),J?(0,k.jsx)("div",{style:{textAlign:"center",padding:60},children:(0,k.jsx)(wt,{})}):oo.length===0?(0,k.jsx)(Gt,{description:s("chatConfig.agentPanel.noTools"),style:{padding:60}}):(0,k.jsx)("div",{className:c.cardGrid,children:oo.map(me)})]}),ao=()=>At?(0,k.jsx)(Po,{middleware:At,middlewareType:Ji(At.type,b.availableMiddlewareTypes||h),onToggle:()=>it(At.id),onConfigChange:g=>Je(At.id,g),onAllowedToolsChange:g=>Ae(At.id,g)},At.id):(0,k.jsx)(Gt,{description:s("chatConfig.agentPanel.noCapabilities"),style:{padding:60}}),ar=()=>(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)("div",{className:c.sectionHeader,children:[(0,k.jsxs)("div",{children:[(0,k.jsx)("h2",{className:c.sectionTitle,children:s("chatConfig.agentPanel.subAgents.title")}),(0,k.jsx)("p",{className:c.sectionDesc,children:s("chatConfig.agentPanel.subAgents.desc")})]}),(0,k.jsxs)("div",{className:c.sectionActions,children:[(0,k.jsx)(_e,{allowClear:!0,prefix:(0,k.jsx)(cr,{}),placeholder:s("chatConfig.agentPanel.subAgents.search"),value:ke,onChange:g=>Me(g.target.value),className:c.searchBox}),(0,k.jsx)(Tt,{type:"secondary",style:{fontSize:13},children:s("chatConfig.agentPanel.subAgents.selected",{selected:Re.length,total:Xt.length})}),(0,k.jsx)(Z,{size:"small",onClick:()=>j(Re.length===Xt.length?[]:Xt.map(g=>g.id)),children:Re.length===Xt.length?s("chatConfig.agentPanel.clear"):s("chatConfig.agentPanel.selectAll")})]})]}),Xt.length===0?(0,k.jsx)(Gt,{description:s("chatConfig.agentPanel.noOtherAgents"),style:{padding:60}}):ro.length===0?(0,k.jsx)(Gt,{description:s("chatConfig.agentPanel.noMatching"),style:{padding:60}}):(0,k.jsx)("div",{className:c.cardGrid,children:ro.map(xn)})]}),T={basic:ir(),prompt:io(),tools:jt(),middleware:ao(),subagents:ar()},A=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)("div",{className:c.modalBody,style:d?{height:"100%",width:"100%"}:void 0,children:[!d&&(0,k.jsxs)("div",{className:c.topbar,children:[(0,k.jsxs)("div",{className:c.topbarLeft,children:[(0,k.jsx)(sr,{size:40,style:{backgroundColor:f.colorPrimary,fontSize:18,flexShrink:0},children:e.name?.charAt(0).toUpperCase()||"A"}),(0,k.jsxs)("div",{style:{minWidth:0},children:[(0,k.jsx)("div",{className:c.agentName,children:e.name}),(0,k.jsx)("div",{className:c.agentDesc,children:e.description})]}),(0,k.jsx)(He,{color:"blue",style:{margin:0,fontSize:11,flexShrink:0},children:s("chatConfig.agentPanel.configWorkbench")})]}),(0,k.jsxs)(Et,{children:[i&&(0,k.jsx)(Jt,{title:s("chatConfig.agentPanel.deleteAgent"),children:(0,k.jsx)(Z,{"aria-label":s("chatConfig.agentPanel.deleteAgent"),type:"text",danger:!0,icon:(0,k.jsx)(uo,{}),onClick:()=>ie(!0)})}),(0,k.jsx)(Z,{type:"text",icon:(0,k.jsx)(jn,{}),onClick:o})]})]}),(0,k.jsxs)("div",{className:c.layout,children:[(0,k.jsx)("div",{className:p.nav,role:"tablist","aria-label":s("chatConfig.agentPanel.navAriaLabel"),children:rr.map(g=>g.key!=="middleware"?(0,k.jsxs)("button",{type:"button",role:"tab","aria-selected":R===g.key,className:`${p.navItem} ${R===g.key?"active":""}`,onClick:()=>P(g.key),children:[(0,k.jsx)("span",{style:{fontSize:16},children:g.icon}),(0,k.jsx)("span",{children:g.label}),g.badge!==void 0&&g.badge>0&&(0,k.jsx)(lr,{count:g.badge,size:"small",className:p.navBadge,style:{backgroundColor:f.colorPrimary}})]},g.key):(0,k.jsxs)(te.default.Fragment,{children:[(0,k.jsxs)("button",{type:"button",role:"tab","aria-selected":R==="middleware",className:`${p.navItem} ${R==="middleware"?"active":""}`,onClick:()=>ce(W=>!W),children:[(0,k.jsx)("span",{style:{fontSize:16},children:g.icon}),(0,k.jsx)("span",{children:g.label}),g.badge!==void 0&&g.badge>0&&(0,k.jsx)(lr,{count:g.badge,size:"small",className:p.navBadge,style:{backgroundColor:f.colorPrimary}})]}),L&&(0,k.jsx)("div",{className:p.navSub,children:cn.map(W=>(0,k.jsxs)("div",{children:[(0,k.jsx)("div",{className:p.navGroupLabel,children:Qi[W]?s(Qi[W]):W}),Yt.get(W)?.map(N=>(0,k.jsxs)("button",{type:"button",role:"option","aria-selected":R==="middleware"&&C===N.type,className:`${p.navSubItem} ${R==="middleware"&&C===N.type?"active":""}`,onClick:()=>{x(N.type),P("middleware")},children:[(0,k.jsx)("span",{className:p.navStatusDot,style:{backgroundColor:N.enabled?f.colorSuccess:f.colorBorder}}),(0,k.jsx)("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:N.name})]},N.id))]},W))})]},"middleware"))}),(0,k.jsx)("div",{className:c.content,children:ln?T[R]:(0,k.jsx)("div",{style:{minHeight:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,k.jsxs)(Et,{direction:"vertical",align:"center",children:[(0,k.jsx)(wt,{}),(0,k.jsx)(Tt,{type:"secondary",children:s("chatConfig.agentPanel.loadingConfig")})]})})})]}),(0,k.jsxs)("div",{className:c.footer,children:[(0,k.jsx)(Tt,{"data-testid":"config-footer-hint",className:c.footerHint,type:je?"warning":"secondary",children:s(je?"common.unsavedChanges":r?"chatConfig.agentPanel.footer.saveHint":"chatConfig.agentPanel.footer.viewing")}),(0,k.jsxs)(Et,{children:[(0,k.jsx)(Z,{onClick:o,children:s("common.close")}),r&&(0,k.jsx)(Z,{"aria-label":s("common.save"),type:"primary",icon:(0,k.jsx)(ii,{}),loading:ge,disabled:!ln,onClick:q,children:s("common.save")})]})]})]}),(0,k.jsx)(Be,{title:s("chatConfig.agentPanel.prompt.title"),open:se,onCancel:()=>M(!1),width:800,footer:[(0,k.jsx)(Z,{onClick:()=>M(!1),children:s("common.close")},"cancel"),(0,k.jsx)(Z,{type:"primary",onClick:()=>M(!1),children:s("chatConfig.agentPanel.done")},"done")],children:(0,k.jsx)(_e.TextArea,{"aria-label":s("chatConfig.agentPanel.prompt.title"),value:oe,onChange:g=>G(g.target.value),rows:16,style:{width:"100%",fontFamily:"monospace",fontSize:13,lineHeight:1.7,resize:"vertical",minHeight:300}})}),(0,k.jsx)(Be,{title:s("chatConfig.agentPanel.delete.title"),open:ne,onCancel:()=>ie(!1),footer:[(0,k.jsx)(Z,{onClick:()=>ie(!1),children:s("common.cancel")},"cancel"),(0,k.jsx)(Z,{type:"primary",danger:!0,loading:B,onClick:Ce,children:s("common.delete")},"delete")],children:(0,k.jsxs)(Tt,{children:[s("chatConfig.agentPanel.delete.confirmPrefix")," ",(0,k.jsx)(Tt,{strong:!0,children:e.name})," ",s("chatConfig.agentPanel.delete.confirmSuffix")]})})]});return d?(0,k.jsx)("div",{style:{width:"100%",height:"100%",overflow:"hidden"},children:A}):(0,k.jsx)(Be,{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:A})};var ot=I(Pe());function Eo(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 ye=I(z()),{Text:Ys}=Ge,Xs=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:""},Do=({assistantId:e,initial:t,navigationKey:n,onEvalInvalidated:o})=>{let{message:r}=Ve.useApp(),i=_(),{projects:d,loading:u,create:l}=bo(),a=Eo(d,e),v=a?.id??"",y=a?.name||`eval-${e}`,f=Xs(t),c=`${f.page}\0${f.suiteId}\0${f.runId}`,[p,s]=(0,ot.useState)(f),{page:b,suiteId:h,runId:m}=p;(0,ot.useEffect)(()=>{s(f)},[e,c,n]);let{start:w}=ho(v),{workspaceId:R,projectId:P}=Lt(),[S,K]=(0,ot.useState)(!1),{create:C}=In(v),[x,L]=(0,ot.useState)(!1),[ce,J]=(0,ot.useState)(""),[V,ge]=(0,ot.useState)(0),[E,B]=(0,ot.useState)(!1),[O]=fe.useForm(),[ne,ie]=(0,ot.useState)(!1),[D,U]=(0,ot.useState)([]),ve=yt("__GLOBAL__"),Y=(0,ot.useRef)(o);Y.current=o;let ke=G=>({workspaceId:R||void 0,projectId:G||P||void 0}),Me=(0,ot.useCallback)(async()=>{try{let G=await ve.request("/api/tenant-models");U(yo(G.data))}catch{}},[ve]),F=async G=>{ie(!0);try{await l({name:`eval-${e}`,judgeModelConfig:{modelKey:G.modelKey||""},targetServerConfig:{base_url:"",api_key:"",targetAgentId:e}}),await Promise.resolve(Y.current?.()).catch(()=>{}),O.resetFields(),B(!1)}catch(se){r.error(se instanceof Error?se.message:i("governance.evalPanel.createFailed"))}finally{ie(!1)}},re=(G,se,M)=>{s(he=>({page:G,suiteId:se??he.suiteId,runId:M??he.runId}))},Re=async()=>{ce.trim()&&(await C(v,{name:ce.trim()}),ge(G=>G+1),await o?.(),J(""),L(!1))},j=async G=>{let se=await w(v,ke(G.projectId));se?.run_id&&(await Promise.resolve(o?.()).catch(()=>{}),re("run",void 0,se.run_id))},oe=(0,ye.jsx)(Be,{title:i("governance.evalPanel.createTitle"),open:E,onCancel:()=>{O.resetFields(),B(!1)},footer:null,destroyOnHidden:!0,width:480,children:(0,ye.jsxs)(fe,{form:O,layout:"vertical",onFinish:F,initialValues:{name:`eval-${e}`},children:[(0,ye.jsx)(fe.Item,{name:"name",label:i("governance.evalPanel.projectName"),children:(0,ye.jsx)(_e,{disabled:!0})}),(0,ye.jsx)(fe.Item,{name:"modelKey",label:i("governance.evalPanel.judgeModel"),rules:[{required:!0,message:i("governance.evalPanel.judgeModelRequired")}],children:(0,ye.jsx)(at,{placeholder:i("governance.evalPanel.modelPlaceholder"),options:D.map(G=>({value:G.key,label:vo(G)}))})}),(0,ye.jsxs)(fe.Item,{style:{marginBottom:0,textAlign:"right"},children:[(0,ye.jsx)(Z,{onClick:()=>{O.resetFields(),B(!1)},style:{marginRight:8},children:i("common.cancel")}),(0,ye.jsx)(Z,{type:"primary",htmlType:"submit",loading:ne,children:i("common.create")})]})]})});return u?(0,ye.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,ye.jsx)(wt,{})}):a?(0,ye.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",background:"#f5f5f5"},children:[(0,ye.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 24px",background:"#fff",borderBottom:"1px solid #f0f0f0",flexShrink:0},children:[(0,ye.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,ye.jsx)(oi,{style:{color:"#6366f1",fontSize:18}}),(0,ye.jsx)("span",{style:{fontSize:15,fontWeight:600},children:y}),(0,ye.jsx)(He,{color:"purple",children:i("governance.evalPanel.kindTag")})]}),b==="suites"&&(0,ye.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,ye.jsx)(Z,{icon:(0,ye.jsx)(Dt,{}),onClick:()=>L(G=>!G),children:i("governance.evalPanel.newSuite")}),(0,ye.jsx)(Z,{type:"primary",icon:(0,ye.jsx)(ti,{}),onClick:()=>K(!0),children:i("governance.evalPanel.runAll")})]})]}),b==="suites"&&x&&(0,ye.jsxs)("div",{style:{padding:"12px 24px",borderBottom:"1px solid #f0f0f0",display:"flex",gap:8,background:"#fff"},children:[(0,ye.jsx)("input",{type:"text",placeholder:i("governance.evalPanel.suiteNamePlaceholder"),value:ce,onChange:G=>J(G.target.value),onKeyDown:G=>G.key==="Enter"&&void Re(),autoFocus:!0,style:{width:260,padding:"6px 12px",border:"1px solid #d9d9d9",borderRadius:8,fontSize:14,outline:"none"}}),(0,ye.jsx)(Z,{type:"primary",size:"small",onClick:()=>void Re(),children:i("common.create")}),(0,ye.jsx)(Z,{size:"small",onClick:()=>L(!1),children:i("common.cancel")})]}),(0,ye.jsxs)("div",{style:{flex:1,overflow:"auto",padding:28},children:[b==="suites"&&(0,ye.jsx)(Ai,{projectId:v,onSelectSuite:(G,se)=>re("suite",se),onEvalInvalidated:o},`${v}:${V}`),b==="suite"&&h&&(0,ye.jsx)(Ei,{projectId:v,suiteId:h,onBack:()=>re("suites"),onRun:G=>{Promise.resolve(o?.()).catch(()=>{}),re("run",void 0,G)},onEvalInvalidated:o}),b==="run"&&m&&(0,ye.jsx)(Di,{runId:m,onBack:()=>re("suites"),onRunSettled:o})]}),(0,ye.jsx)(Pi,{open:S,onClose:()=>K(!1),onRun:j})]}):(0,ye.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,background:"#fff"},children:[(0,ye.jsx)(Gt,{description:(0,ye.jsx)(Ys,{type:"secondary",children:i("governance.evalPanel.noProject")})}),(0,ye.jsx)(Z,{type:"primary",icon:(0,ye.jsx)(Dt,{}),onClick:()=>{Me(),B(!0)},children:i("governance.evalPanel.createProject")}),oe]})};var We=I(Pe());var $n=I(Pe());var Q=I(z()),{Text:gn}=Ge,ta={projectSelector:!1,modelSelector:!1,threadManagement:!0,attachments:!0,hitl:!0,genUI:!0,files:!1},na=({open:e,assistantId:t,value:n,projects:o,models:r,submitting:i,error:d,onCancel:u,onSubmit:l})=>{let a=_(),[v]=fe.useForm(),[y,f]=(0,$n.useState)(!1),[c,p]=(0,$n.useState)(!1);(0,$n.useEffect)(()=>{if(!e)return;let m=n?.features??ta;f(m.projectSelector),p(m.modelSelector),v.setFieldsValue({name:n?.name??"",description:n?.description,defaultProjectId:n?.scope.defaultProjectId??o[0]?.id,allowedProjectIds:n?.scope.allowedProjectIds??(o[0]?[o[0].id]:[]),defaultModelKey:n?.scope.defaultModelKey,allowedModelKeys:n?.scope.allowedModelKeys,...m,title:n?.appearance.title,welcomeMessage:n?.appearance.welcomeMessage,primaryColor:n?.appearance.primaryColor,quickPrompts:n?.appearance.quickPrompts,identityPolicy:n?.identity?.policy??"unverified",identityIssuers:n?.identity?JSON.stringify(n.identity.issuers,null,2):void 0})},[v,e,o,n]);let s=async()=>{let m=await v.validateFields(),w=m.projectSelector?Array.from(new Set(m.allowedProjectIds??[])):[m.defaultProjectId],R=m.modelSelector?Array.from(new Set([...m.defaultModelKey?[m.defaultModelKey]:[],...m.allowedModelKeys??[]])):m.defaultModelKey?[m.defaultModelKey]:void 0,P,S=m.identityPolicy??"unverified";if(S!=="unverified"){let x;try{x=JSON.parse(m.identityIssuers??"")}catch{throw new Error("Trusted issuers must be a valid JSON array")}if(!Array.isArray(x)||x.length===0)throw new Error("Verified identity requires at least one trusted issuer");P={policy:S,issuers:x}}let K=(m.quickPrompts??[]).map(x=>({label:(x?.label??"").trim(),text:(x?.text??"").trim()})).filter(x=>x.label.length>0&&x.text.length>0),C={name:m.name.trim(),description:m.description?.trim()||void 0,scope:{defaultProjectId:m.defaultProjectId,allowedProjectIds:w,defaultModelKey:m.defaultModelKey||void 0,allowedModelKeys:R},features:{projectSelector:m.projectSelector,modelSelector:m.modelSelector,threadManagement:m.threadManagement,attachments:m.attachments,hitl:m.hitl,genUI:m.genUI,files:m.files??!1},appearance:{title:m.title?.trim()||void 0,welcomeMessage:m.welcomeMessage?.trim()||void 0,primaryColor:m.primaryColor?.trim()||void 0,...K.length>0?{quickPrompts:K}:{}},identity:P};await l(n?C:{...C,assistantId:t,integration:{type:"react_sdk"}})},b=ji(o,[n?.scope.defaultProjectId,...n?.scope.allowedProjectIds??[]]),h=r.map(m=>({value:m.key,label:vo(m)}));return(0,Q.jsxs)(Be,{title:a(n?"governance.webApp.editTitle":"governance.webApp.createTitle"),open:e,onCancel:u,onOk:()=>void s().catch(()=>{}),okText:a(n?"common.save":"common.create"),confirmLoading:i,width:720,destroyOnHidden:!0,children:[d&&(0,Q.jsx)("div",{role:"alert",style:{color:"#ef4444",marginBottom:12},children:d}),(0,Q.jsxs)(fe,{form:v,layout:"vertical",initialValues:ta,children:[(0,Q.jsx)(fe.Item,{name:"name",label:a("governance.webApp.name"),rules:[{required:!0,whitespace:!0},{max:120,message:a("governance.webApp.nameMax")}],children:(0,Q.jsx)(_e,{"aria-label":a("governance.webApp.name"),maxLength:121})}),(0,Q.jsx)(fe.Item,{name:"description",label:a("governance.webApp.description"),rules:[{max:1e3,message:a("governance.webApp.descriptionMax")}],children:(0,Q.jsx)(_e.TextArea,{"aria-label":a("governance.webApp.description"),maxLength:1001})}),(0,Q.jsx)(gn,{strong:!0,children:a("governance.webApp.projectScope")}),(0,Q.jsx)(fe.Item,{name:"projectSelector",valuePropName:"checked",children:(0,Q.jsx)(un,{"aria-label":a("governance.webApp.projectSelector"),onChange:m=>f(m.target.checked),children:a("governance.webApp.projectSelector")})}),(0,Q.jsx)(fe.Item,{name:"allowedProjectIds",label:a("governance.webApp.allowedProjects"),dependencies:["defaultProjectId","projectSelector"],rules:y?[{required:!0,message:a("governance.webApp.selectProject")},{validator:(m,w)=>(w??[]).every(R=>b.some(P=>P.value===R))?Promise.resolve():Promise.reject(new Error(a("governance.webApp.selectValidProjects")))},{validator:(m,w)=>(w??[]).includes(v.getFieldValue("defaultProjectId"))?Promise.resolve():Promise.reject(new Error(a("governance.webApp.defaultInAllowed")))}]:void 0,children:(0,Q.jsx)(at,{"aria-label":a("governance.webApp.allowedProjects"),mode:"multiple",disabled:!y,options:b})}),(0,Q.jsx)(fe.Item,{name:"defaultProjectId",label:a("governance.webApp.defaultProject"),rules:[{required:!0},{validator:(m,w)=>!w||b.some(R=>R.value===w)?Promise.resolve():Promise.reject(new Error(a("governance.webApp.selectValidDefaultProject")))}],children:(0,Q.jsx)(at,{"aria-label":a("governance.webApp.defaultProject"),options:b})}),(0,Q.jsx)(gn,{strong:!0,children:a("governance.webApp.modelScope")}),(0,Q.jsx)(fe.Item,{name:"modelSelector",valuePropName:"checked",children:(0,Q.jsx)(un,{"aria-label":a("governance.webApp.modelSelector"),onChange:m=>p(m.target.checked),children:a("governance.webApp.modelSelector")})}),(0,Q.jsx)(fe.Item,{name:"allowedModelKeys",label:a("governance.webApp.allowedModels"),dependencies:["defaultModelKey","modelSelector"],rules:c?[{validator:(m,w)=>w?.length||v.getFieldValue("defaultModelKey")?Promise.resolve():Promise.reject(new Error(a("governance.webApp.selectModel")))},{validator:(m,w)=>(w??[]).every(R=>h.some(P=>P.value===R))?Promise.resolve():Promise.reject(new Error(a("governance.webApp.selectValidModels")))}]:void 0,children:(0,Q.jsx)(at,{"aria-label":a("governance.webApp.allowedModels"),mode:"multiple",allowClear:!0,disabled:!c,options:h})}),(0,Q.jsx)(fe.Item,{name:"defaultModelKey",label:a("governance.webApp.defaultModel"),rules:[{validator:(m,w)=>!w||h.some(R=>R.value===w)?Promise.resolve():Promise.reject(new Error(a("governance.webApp.selectValidDefaultModel")))}],children:(0,Q.jsx)(at,{"aria-label":a("governance.webApp.defaultModel"),allowClear:!0,options:h})}),(0,Q.jsx)(gn,{strong:!0,children:a("governance.webApp.features")}),(0,Q.jsx)(Et,{wrap:!0,children:["threadManagement","attachments","hitl","genUI","files"].map(m=>(0,Q.jsx)(fe.Item,{name:m,valuePropName:"checked",noStyle:!0,children:(0,Q.jsx)(un,{"aria-label":a(`governance.webApp.feature.${m}`),children:a(`governance.webApp.feature.${m}`)})},m))}),(0,Q.jsx)("div",{style:{marginTop:20},children:(0,Q.jsx)(gn,{strong:!0,children:a("governance.webApp.appearance")})}),(0,Q.jsx)(fe.Item,{name:"title",label:a("governance.webApp.title"),rules:[{max:120,message:a("governance.webApp.titleMax")}],children:(0,Q.jsx)(_e,{"aria-label":a("governance.webApp.title"),maxLength:121})}),(0,Q.jsx)(fe.Item,{name:"welcomeMessage",label:a("governance.webApp.welcomeMessage"),rules:[{max:1e3,message:a("governance.webApp.welcomeMessageMax")}],children:(0,Q.jsx)(_e.TextArea,{"aria-label":a("governance.webApp.welcomeMessage"),maxLength:1001})}),(0,Q.jsx)(fe.Item,{name:"primaryColor",label:a("governance.webApp.primaryColor"),rules:[{pattern:Ki,message:a("governance.webApp.colorFormat"),transform:m=>m||void 0}],children:(0,Q.jsx)(_e,{"aria-label":a("governance.webApp.primaryColor"),placeholder:"#6366f1"})}),(0,Q.jsx)("div",{style:{marginTop:12},children:(0,Q.jsx)(gn,{strong:!0,children:a("governance.webApp.quickPrompts")})}),(0,Q.jsx)(fe.List,{name:"quickPrompts",children:(m,{add:w,remove:R})=>(0,Q.jsxs)(Q.Fragment,{children:[m.map(P=>(0,Q.jsxs)(Et,{align:"baseline",style:{display:"flex",marginBottom:8},children:[(0,Q.jsx)(fe.Item,{name:[P.name,"label"],rules:[{required:!0,whitespace:!0,message:a("governance.webApp.quickPromptLabelRequired")},{max:40,message:a("governance.webApp.quickPromptLabelMax")}],children:(0,Q.jsx)(_e,{"aria-label":a("governance.webApp.quickPromptLabelAria",{index:P.name+1}),placeholder:a("governance.webApp.labelPlaceholder"),maxLength:41})}),(0,Q.jsx)(fe.Item,{name:[P.name,"text"],rules:[{required:!0,whitespace:!0,message:a("governance.webApp.quickPromptTextRequired")},{max:500,message:a("governance.webApp.quickPromptTextMax")}],children:(0,Q.jsx)(_e,{"aria-label":a("governance.webApp.quickPromptTextAria",{index:P.name+1}),placeholder:a("governance.webApp.messagePlaceholder"),maxLength:501,style:{width:360}})}),(0,Q.jsx)(Z,{"aria-label":a("governance.webApp.removeQuickPromptAria",{index:P.name+1}),onClick:()=>R(P.name),children:a("governance.webApp.remove")})]},P.key)),(0,Q.jsx)(Z,{"aria-label":a("governance.webApp.addQuickPrompt"),onClick:()=>w({label:"",text:""}),disabled:m.length>=6,children:a("governance.webApp.addQuickPrompt")})]})}),(0,Q.jsx)("div",{style:{marginTop:20},children:(0,Q.jsx)(gn,{strong:!0,children:a("governance.webApp.identity")})}),(0,Q.jsx)(fe.Item,{name:"identityPolicy",label:a("governance.webApp.identityPolicy"),initialValue:"unverified",children:(0,Q.jsx)(at,{"aria-label":a("governance.webApp.identityPolicy"),options:[{value:"unverified",label:a("governance.webApp.identityUnverified")},{value:"both",label:a("governance.webApp.identityBoth")},{value:"verified",label:a("governance.webApp.identityVerified")}]})}),(0,Q.jsx)(fe.Item,{name:"identityIssuers",label:a("governance.webApp.trustedIssuers"),tooltip:a("governance.webApp.trustedIssuersTooltip"),dependencies:["identityPolicy"],rules:[{validator:(m,w)=>{if(v.getFieldValue("identityPolicy")==="unverified"||w===void 0||w.trim()==="")return Promise.resolve();try{let R=JSON.parse(w);return Array.isArray(R)&&R.length>0?Promise.resolve():Promise.reject(new Error(a("governance.webApp.issuersEmpty")))}catch{return Promise.reject(new Error(a("governance.webApp.issuersInvalid")))}}}],children:(0,Q.jsx)(_e.TextArea,{"aria-label":a("governance.webApp.trustedIssuers"),rows:3,placeholder:'[{"iss":"https://host.example.com","aud":"<webAppId>","alg":"HS256","secret":"..."}]'})}),(0,Q.jsx)(gn,{type:"secondary",children:a("governance.webApp.integrationType")})]})]})};var ae=I(z()),{Text:Lo}=Ge,Hn=(e,t)=>e instanceof Error?e.message:t("governance.webApps.requestFailed"),Js={active:"governance.webApps.status.active",disabled:"governance.webApps.status.disabled",draft:"governance.webApps.status.draft"};function el(e,t){let n=Xr("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
+ }`}},Mo={whiteSpace:"pre-wrap",overflow:"auto",background:"#111827",color:"#e5e7eb",padding:16,borderRadius:10},tl=[{name:"webAppId",type:"string \xB7 required",descriptionKey:"governance.webApps.guide.setting.webAppId"},{name:"userId",type:"string \xB7 required",descriptionKey:"governance.webApps.guide.setting.userId"},{name:"gatewayUrl",type:"string",descriptionKey:"governance.webApps.guide.setting.gatewayUrl"},{name:"mode",type:'"bubble" | "inline"',descriptionKey:"governance.webApps.guide.setting.mode"},{name:"containerSelector",type:"string",descriptionKey:"governance.webApps.guide.setting.containerSelector"},{name:"bubble",type:"boolean \xB7 default true",descriptionKey:"governance.webApps.guide.setting.bubble"},{name:"width / height",type:"number \xB7 380 / 640",descriptionKey:"governance.webApps.guide.setting.widthHeight"},{name:"position",type:'"bottom-right" | "bottom-left"',descriptionKey:"governance.webApps.guide.setting.position"},{name:"offsetX / offsetY",type:"number \xB7 20",descriptionKey:"governance.webApps.guide.setting.offset"},{name:"zIndex",type:"number \xB7 9999",descriptionKey:"governance.webApps.guide.setting.zIndex"},{name:"welcome",type:"string",descriptionKey:"governance.webApps.guide.setting.welcome"},{name:"quicks",type:"{ label, text }[]",descriptionKey:"governance.webApps.guide.setting.quicks"}],nl=[{api:"AxiomChat.open() / hide() / toggle()",behaviorKey:"governance.webApps.guide.api.open"},{api:"AxiomChat.sendMessage(text)",behaviorKey:"governance.webApps.guide.api.sendMessage"},{api:"AxiomChat.mount(settings) / AxiomChat.get(id)",behaviorKey:"governance.webApps.guide.api.mount"}],ol=[{event:'["onReady", cb]',payload:"\u2014",whenKey:"governance.webApps.guide.event.onReady"},{event:'["onMessage", cb]',payload:'{ role: "human" | "ai", content: string }',whenKey:"governance.webApps.guide.event.onMessage"},{event:'["onError", cb]',payload:"{ code: string, message: string }",whenKey:"governance.webApps.guide.event.onError"}],oa=({assistant:e})=>{let t=_(),n=yt("__GLOBAL__"),{user:o,currentTenant:r,baseURL:i}=Jr(),{projects:d}=Lt(),[u,l]=(0,We.useState)([]),[a,v]=(0,We.useState)([]),[y,f]=(0,We.useState)(!1),[c,p]=(0,We.useState)(null),[s,b]=(0,We.useState)(null),[h,m]=(0,We.useState)(null),[w,R]=(0,We.useState)(!1),[P,S]=(0,We.useState)(null),[K,C]=(0,We.useState)(!1),[x,L]=(0,We.useState)(!1),[ce,J]=(0,We.useState)(null),[V,ge]=(0,We.useState)(null),E=(0,We.useRef)(0),B=(0,We.useRef)(0),O=(0,We.useRef)(0),ne=(0,We.useRef)(!1),ie=Array.from(new Map(d.map(F=>[F.id,F])).values()),D=(0,We.useCallback)(async()=>{let F=++E.current;f(!0),p(null);try{let re=await n.webApps.list({assistantId:e.id});F===E.current&&l(re.records)}catch(re){F===E.current&&p(Hn(re,t))}finally{F===E.current&&f(!1)}},[e.id,n,r?.id,t]);(0,We.useEffect)(()=>(l([]),b(null),S(null),J(null),ge(null),R(!1),C(!1),L(!1),ne.current=!1,O.current+=1,D(),()=>{E.current+=1,O.current+=1}),[D]),(0,We.useEffect)(()=>{let F=++B.current;return n.request("/api/tenant-models").then(re=>{F===B.current&&v(yo(re.data))}).catch(()=>{F===B.current&&v([])}),()=>{B.current+=1}},[n]);let U=async F=>{if(ne.current)return;ne.current=!0,L(!0);let re=++O.current;p(null);try{await F(),re===O.current&&await D()}catch(Re){re===O.current&&p(Hn(Re,t))}finally{re===O.current&&(ne.current=!1,L(!1))}},ve=async F=>{if(ne.current)return;ne.current=!0,L(!0);let re=++O.current;R(!0),m(null);try{s==="create"?await n.webApps.create(F):s&&await n.webApps.update(s.id,F),re===O.current&&(b(null),await D())}catch(Re){re===O.current&&m(Hn(Re,t))}finally{re===O.current&&(ne.current=!1,L(!1),R(!1))}},Y=async F=>{p(null);try{if(!navigator.clipboard)throw new Error(t("governance.webApps.clipboardUnavailable"));await navigator.clipboard.writeText(F)}catch(re){p(Hn(re,t))}},ke=F=>[{key:"edit",icon:hi,label:t("common.edit"),disabled:x,onClick:b},{key:"toggle",icon:F.status==="active"?si:di,label:F.status==="active"?t("governance.webApps.action.disable"):t("governance.webApps.action.enable"),disabled:x,onClick:re=>void U(()=>re.status==="active"?n.webApps.disable(re.id):n.webApps.enable(re.id))},{key:"preview",icon:fi,label:t("governance.webApps.action.preview"),disabled:x,onClick:J},{key:"guide",icon:ui,label:t("governance.webApps.action.integrationGuide"),disabled:x,onClick:ge},{key:"copy",icon:ci,label:t("governance.webApps.action.copyId"),disabled:x,onClick:re=>void Y(re.id)},{key:"delete",icon:xi,label:t("common.delete"),danger:!0,disabled:x,onClick:S}],Me=async()=>{if(!P||ne.current)return;ne.current=!0,L(!0);let F=++O.current;C(!0);try{await n.webApps.delete(P.id),F===O.current&&(S(null),await D())}catch(re){F===O.current&&p(Hn(re,t))}finally{F===O.current&&(ne.current=!1,L(!1),C(!1))}};return(0,ae.jsxs)("div",{style:{height:"100%",overflow:"auto",padding:16},children:[(0,ae.jsx)(Pt,{type:"warning",showIcon:!0,message:t("governance.webApps.warningTitle"),description:t("governance.webApps.warningDescription"),style:{marginBottom:16}}),c&&(0,ae.jsx)(Pt,{role:"alert",type:"error",message:c,action:(0,ae.jsx)(Z,{size:"small",onClick:()=>void D(),children:t("common.retry")}),style:{marginBottom:16}}),(0,ae.jsx)(Si,{title:t("governance.webApps.title"),itemName:"common.item.app",items:u,loading:y,keyExtractor:F=>F.id,createLabel:x?void 0:t("governance.webApps.create"),onCreateClick:x?void 0:()=>{m(null),b("create")},renderIcon:()=>(0,ae.jsx)(gi,{size:22,color:"#6366f1"}),renderPrimary:F=>F.name,renderSecondary:F=>F.description??F.id,renderHeaderActions:F=>{let re=Js[F.status];return(0,ae.jsx)(He,{color:F.status==="active"?"green":F.status==="disabled"?"default":"gold",children:re?t(re):F.status})},renderDetails:F=>(0,ae.jsx)(Lo,{type:"secondary",children:t("governance.webApps.projectsCount",{count:F.scope.allowedProjectIds.length,s:F.scope.allowedProjectIds.length===1?"":"s"})}),itemActions:ke,actionsPosition:"always",showViewToggle:!1,emptyTitle:t("governance.webApps.emptyTitle"),emptyDescription:t("governance.webApps.emptyDescription")}),(0,ae.jsx)(na,{open:s!==null,assistantId:e.id,value:s==="create"?null:s,projects:ie,models:a,submitting:w,error:h,onCancel:()=>b(null),onSubmit:ve}),(0,ae.jsx)(Be,{title:t("governance.webApps.deleteTitle"),open:P!==null,onCancel:()=>S(null),onOk:()=>void Me(),okText:t("common.delete"),okButtonProps:{danger:!0,loading:K},children:(0,ae.jsx)("p",{children:t("governance.webApps.deleteBody",{name:P?.name??""})})}),(0,ae.jsx)(Be,{title:t("governance.webApps.previewTitle"),open:ce!==null,onCancel:()=>J(null),footer:(0,ae.jsx)(Z,{onClick:()=>J(null),children:t("common.close")}),width:900,children:i?ce&&ce.status==="active"?(0,ae.jsx)("iframe",{src:`${i}/api/web-apps/${ce.id}/chat?mode=embed`,title:t("governance.webApps.previewFrameTitle"),style:{width:"100%",height:640,border:"1px solid #d9d9d9",borderRadius:8}}):ce?(0,ae.jsxs)("div",{children:[(0,ae.jsx)(Pt,{type:"info",showIcon:!0,message:t("governance.webApps.draftPreviewTitle"),description:t("governance.webApps.draftPreviewDescription"),style:{marginBottom:16}}),(0,ae.jsx)(Hi,{gatewayUrl:i,webAppId:ce.id,identity:{mode:"unverified",userId:`console-preview:${o?.id??"unknown"}:${ce.id}`,displayName:o?.name},fetch:el})]}):null:(0,ae.jsx)(Pt,{type:"warning",message:t("governance.webApps.gatewayUnavailable")})}),(0,ae.jsx)(Be,{title:t("governance.webApps.guideTitle"),open:V!==null,onCancel:()=>ge(null),footer:(0,ae.jsxs)(Et,{children:[(0,ae.jsx)(Z,{onClick:()=>V&&void Y(Object.values(Un(V,i)).join(`
230
+
231
+ `)),children:t("governance.webApps.copyExamples")}),(0,ae.jsx)(Z,{type:"primary",onClick:()=>ge(null),children:t("common.close")})]}),width:900,children:V&&(0,ae.jsx)(Hr,{defaultActiveKey:"zero-code",items:[{key:"zero-code",label:t("governance.webApps.guide.zeroCodeTab"),children:(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsx)(Ge.Paragraph,{type:"secondary",style:{marginTop:0},children:t("governance.webApps.guide.zeroCodeIntro")}),(0,ae.jsx)("pre",{style:Mo,children:Un(V,i).embed}),(0,ae.jsx)(Ge.Title,{level:5,style:{marginTop:24},children:t("governance.webApps.guide.settingsTitle")}),(0,ae.jsx)(lo,{size:"small",style:{marginBottom:8},pagination:!1,rowKey:"name",columns:[{title:t("governance.webApps.guide.col.key"),dataIndex:"name",key:"name",width:160},{title:t("governance.webApps.guide.col.type"),dataIndex:"type",key:"type",width:180},{title:t("governance.webApps.guide.col.description"),dataIndex:"descriptionKey",key:"description",render:F=>t(F)}],dataSource:tl}),(0,ae.jsx)(Ge.Title,{level:5,children:t("governance.webApps.guide.jsApiTitle")}),(0,ae.jsx)(Ge.Paragraph,{type:"secondary",children:t("governance.webApps.guide.jsApiBody",{example:'window.AxiomChat = [["onMessage", fn], ["open"]]'})}),(0,ae.jsx)(lo,{size:"small",style:{marginBottom:8},pagination:!1,rowKey:"api",columns:[{title:t("governance.webApps.guide.col.api"),dataIndex:"api",key:"api",width:280},{title:t("governance.webApps.guide.col.behavior"),dataIndex:"behaviorKey",key:"behavior",render:F=>t(F)}],dataSource:nl}),(0,ae.jsx)(Ge.Title,{level:5,children:t("governance.webApps.guide.eventsTitle")}),(0,ae.jsx)(lo,{size:"small",style:{marginBottom:8},pagination:!1,rowKey:"event",columns:[{title:t("governance.webApps.guide.col.register"),dataIndex:"event",key:"event",width:220},{title:t("governance.webApps.guide.col.payload"),dataIndex:"payload",key:"payload",width:280},{title:t("governance.webApps.guide.col.when"),dataIndex:"whenKey",key:"when",render:F=>t(F)}],dataSource:ol}),(0,ae.jsx)(Pt,{style:{marginTop:8},type:"warning",showIcon:!0,message:t("governance.webApps.guide.hostTrustTitle"),description:t("governance.webApps.guide.hostTrustBody")})]})},{key:"npm-sdk",label:t("governance.webApps.guide.npmTab"),children:(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsx)(Ge.Paragraph,{type:"secondary",style:{marginTop:0},children:t("governance.webApps.guide.npmIntro")}),(0,ae.jsx)(Lo,{strong:!0,children:t("governance.webApps.guide.fullChat")}),(0,ae.jsx)("pre",{style:Mo,children:Un(V,i).agentChat}),(0,ae.jsx)(Lo,{strong:!0,children:t("governance.webApps.guide.composable")}),(0,ae.jsx)("pre",{style:Mo,children:Un(V,i).composable}),(0,ae.jsx)(Lo,{strong:!0,children:t("governance.webApps.guide.hooks")}),(0,ae.jsx)("pre",{style:Mo,children:Un(V,i).hooks})]})}]})})]})};var $=I(Pe());var en=I(z()),No={agent:(0,en.jsx)(Gn,{size:14}),tool:(0,en.jsx)(Ti,{size:12}),capability:(0,en.jsx)(li,{size:12}),subagent:(0,en.jsx)(Gn,{size:12}),skill:(0,en.jsx)(mi,{size:12}),model:(0,en.jsx)(pi,{size:12}),eval:(0,en.jsx)(go,{size:12})},Oo={agent:"governance.nodeGroup.agent",tool:"governance.nodeGroup.tool",capability:"governance.nodeGroup.capability",subagent:"governance.nodeGroup.subagent",skill:"governance.nodeGroup.skill",model:"governance.nodeGroup.model",eval:"governance.nodeGroup.eval"};var rl={agent:"Agent",tool:"Tools",capability:"Capabilities",subagent:"Sub-Agents",skill:"Skills",model:"Model",eval:"Eval Suite"},il={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 _o(e){let t=il[e];return e==="agent"?"agent":t.color}function al(e){return typeof e=="object"&&e!==null?e:{}}var Fo=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[],hr="skill:__all__";function sl(e){let t=[],n=new Set,o=d=>{n.has(d)||(n.add(d),t.push(d))};for(let d of Fo(e.skills))o(d);let r=!1,i=Array.isArray(e.middleware)?e.middleware:[];for(let d of i){if(d.enabled===!1||d.type!=="skill")continue;let u=typeof d.config=="object"&&d.config!==null?d.config:{};u.readAll===!0&&(r=!0);for(let l of Fo(u.skills))o(l)}return{ids:t,readAll:r}}function ra(e,t){let n=t?.t,o=al(e),r=typeof o.key=="string"?o.key:"agent",i=o.type??"capability",d={id:r,type:"agent",label:o.name||r,description:o.description||void 0,config:{name:o.name||r,type:i,description:o.description||"",modelKey:o.modelKey||"",prompt:o.prompt||"",version:o.metadata?.version||""}},u=(h,m,w,R,P)=>({id:m,type:h,label:w,description:R,config:P}),l=Fo(o.tools).map(h=>u("tool",`tool:${h}`,h)),a=(Array.isArray(o.middleware)?o.middleware:[]).filter(h=>h.enabled!==!1).map(h=>{let m=typeof h.type=="string"?h.type:"unknown";return u("capability",`cap:${m}`,h.name||m,h.description||void 0,h)}),v=Fo(o.subAgents).map(h=>u("subagent",`sub:${h}`,h)),{ids:y,readAll:f}=sl(o),c=[...f?[u("skill",hr,n?n("governance.configGraph.allSkills"):"All skills",n?n("governance.configGraph.allSkillsDescription"):"Agent can load any available skill")]:[],...y.map(h=>u("skill",`skill:${h}`,h))],p=h=>n?n(Oo[h]):rl[h],s=[{id:"group:tools",type:"tool",label:p("tool"),items:l},{id:"group:capabilities",type:"capability",label:p("capability"),items:a},{id:"group:subagents",type:"subagent",label:p("subagent"),items:v},{id:"group:skills",type:"skill",label:p("skill"),items:c}],b=t?.includeEmptyGroups?s:s.filter(h=>h.items.length>0);return{agent:d,groups:b}}var ia=I(z()),Zn=({id:e,position:t,type:n="source"})=>(0,ia.jsx)(xt,{id:e,type:n,position:t,style:{opacity:0,width:0,height:0,border:"none"},isConnectable:!1});var Ie=I(z()),aa=({type:e="source"})=>(0,Ie.jsxs)(Ie.Fragment,{children:[(0,Ie.jsx)(Zn,{id:"top",position:st.Top,type:e}),(0,Ie.jsx)(Zn,{id:"bottom",position:st.Bottom,type:e}),(0,Ie.jsx)(Zn,{id:"left",position:st.Left,type:e}),(0,Ie.jsx)(Zn,{id:"right",position:st.Right,type:e})]}),sa=({data:e})=>{let{node:t,onClick:n}=e,o=Kn(En(String(t.config?.type??"react")).color),r=t.config??{};return(0,Ie.jsxs)("div",{onClick:n,style:{width:220,background:"#fff",border:`2px solid ${o}`,borderRadius:14,padding:"10px 12px",cursor:"pointer",fontFamily:"inherit"},children:[(0,Ie.jsx)(aa,{type:"source"}),(0,Ie.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[No.agent,(0,Ie.jsx)("span",{style:{fontSize:13,fontWeight:700,color:"#333",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.label})]}),r.description&&(0,Ie.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,Ie.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:6},children:[(0,Ie.jsx)(He,{bordered:!1,style:{margin:0,fontSize:10,background:`${o}1A`,color:o},children:r.type??"capability"}),r.modelKey&&(0,Ie.jsx)(He,{bordered:!1,style:{margin:0,fontSize:10},children:r.modelKey}),r.version&&(0,Ie.jsxs)(He,{bordered:!1,style:{margin:0,fontSize:10},children:["v",r.version]})]}),r.prompt&&(0,Ie.jsx)("div",{style:{fontSize:10,color:"#999",background:"#fafafa",borderRadius:6,padding:"4px 8px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.prompt})]})},la=({data:e})=>{let{group:t,onClick:n,onRemove:o}=e,r=_(),i=_o(t.type);return(0,Ie.jsxs)("div",{style:{border:`1.5px dashed ${i}66`,borderRadius:12,padding:"10px 12px",background:"rgba(255,255,255,0.8)",minWidth:170},children:[(0,Ie.jsx)(aa,{type:"target"}),(0,Ie.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:5,marginBottom:8},children:[No[t.type],(0,Ie.jsx)("span",{style:{fontSize:11,fontWeight:600,color:"#666"},children:t.label}),(0,Ie.jsxs)("span",{style:{fontSize:10,color:"#bbb"},children:["(",t.items.length,")"]})]}),t.items.length===0?(0,Ie.jsx)("div",{style:{fontSize:10,color:"#bbb",padding:"2px 0"},children:r("governance.configGraph.emptyGroup")}):(0,Ie.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:t.items.map(d=>(0,Ie.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,Ie.jsxs)("div",{onClick:u=>{u.stopPropagation(),n?.(d)},style:{display:"flex",alignItems:"center",gap:5,padding:"4px 8px",borderRadius:8,background:"#fff",border:`1px solid ${i}55`,fontSize:11,color:"#333",cursor:"pointer",position:"relative",whiteSpace:"nowrap"},children:[No[d.type],(0,Ie.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:d.label})]}),o&&(0,Ie.jsx)("button",{onClick:u=>{u.stopPropagation(),o(d)},title:r("governance.configGraph.removeItem",{label:d.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"})]},d.id))})]})};var qt=I(Pe());function Kt(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 da(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 ca(e,t=1){let n=Number.isFinite(t)?Math.abs(t):1,o=e.filter(p=>Number.isFinite(p.avgScore)&&Number.isFinite(new Date(p.createdAt).getTime())).sort(Kt),r=o.filter(p=>p.status==="completed"&&!p.holdout),i=r[r.length-1],d=i?.envProjectId!==void 0,l=(d?r.filter(p=>p.envProjectId===i.envProjectId):r).map(da),a=o.filter(p=>p.status==="completed"&&p.holdout).map(da),v=l[l.length-1],y=l[l.length-2],f=v&&y?v.score-y.score:null,c="needs-evidence";return f!==null&&(c=f>n?"improving":f<-n?"regressed":"stable"),{verdict:c,latest:v,previous:y,delta:f,passRate:v?.passRate??null,comparisonLabel:d?"Latest comparable result":"Latest recorded result",trend:l,validationTrend:a,runningRuns:o.filter(p=>p.status==="running"),failedRuns:o.filter(p=>p.status==="failed"||p.status==="aborted")}}var ya=I(z()),ua={total:0,last7d:0,last30d:0,lastActive:null,daily7d:[],daily30d:[],loading:!0,error:null},br=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),pa=(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},ll=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),ga=e=>{let t=ll(e);return Math.floor(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())/864e5)},dl=(e,t)=>ga(e)-ga(t);function fa(e){let{get:t}=et(),[n,o]=qt.default.useState(ua),r=qt.default.useRef(0),i=qt.default.useRef(e);return i.current=e,qt.default.useEffect(()=>{let d=++r.current,u=!0,l=()=>u&&r.current===d&&i.current===e;return o(a=>({...a,loading:!0,error:null})),(async()=>{try{let a=await t(`/api/assistants/${e}/threads`);if(!br(a)||a.success!==!0||!br(a.data))throw new Error("Invalid thread list response");let{records:v,total:y}=a.data;if(!Array.isArray(v)||typeof y!="number"||!Number.isSafeInteger(y)||y<0)throw new Error("Invalid thread list response");let f=Date.now(),c=new Date(f),p=null,s=0,b=0,h=new Array(7).fill(0),m=new Array(30).fill(0);for(let w of v){if(!br(w))continue;let R=pa(w.createdAt,f);if(R!==null){let S=dl(c,new Date(R));S>=0&&S<7&&(s++,h[6-S]++),S>=0&&S<30&&(b++,m[29-S]++)}let P=pa(w.updatedAt,f);P!==null&&(p===null||P>p)&&(p=P)}if(!l())return;o({total:y,last7d:s,last30d:b,lastActive:p===null?null:new Date(p),daily7d:h,daily30d:m,loading:!1,error:null})}catch(a){if(!l())return;o({...ua,loading:!1,error:a instanceof Error?a:new Error("Failed to load thread activity")})}})(),()=>{u=!1,r.current===d&&r.current++}},[t,e]),n}function Wo(e,t){if(!e)return"\u2014";let n=Date.now()-e.getTime(),o=Math.floor(n/6e4);if(o<1)return t?t("common.time.justNow"):"just now";if(o<60)return t?t("common.time.minutesAgo",{count:o}):`${o}m ago`;let r=Math.floor(o/60);if(r<24)return t?t("common.time.hoursAgo",{count:r}):`${r}h ago`;let i=Math.floor(r/24);return i<30?t?t("common.time.daysAgo",{count:i}):`${i}d ago`:i<365?t?t("common.time.monthsAgo",{count:Math.floor(i/30)}):`${Math.floor(i/30)}mo ago`:t?t("common.time.yearsAgo",{count:Math.floor(i/365)}):`${Math.floor(i/365)}y ago`}function zo(e){let t=_(),{projects:n,loading:o,error:r,refresh:i}=bo(),d=Eo(n,e),u=d?.id??"",{suites:l,loading:a,error:v,refresh:y}=In(u),{runs:f,inventoryProjectId:c,loading:p,error:s,refresh:b}=ho(u),h=(0,qt.useCallback)(async()=>{await Promise.all([i(),y(),b()])},[i,y,b]);return{...(0,qt.useMemo)(()=>{let w=l.reduce((C,x)=>C+(x.caseCount??0),0),R=c===u?f.filter(C=>C.projectId===u):[],P=[...R].sort(Kt),S=ca(R),K=S.latest?R.find(C=>C.id===S.latest?.runId):void 0;return{evalProjectId:d?.id,inventoryProjectId:c,suiteCount:l.length,caseCount:w,scores:S.trend.map(C=>C.score),latest:K,runs:P,runCount:R.length,passRate:S.passRate,score:S.latest?.score??null,hasEvalProject:!!d,suiteNames:l.map(C=>C.name??t("governance.overview.unnamed")).filter(Boolean),error:r??v??s,loading:!!(o||u&&(c!==u||a||p))}},[l,f,c,d,u,o,a,p,r,v,s,t]),refresh:h,refreshRuns:b}}var cl=(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},ul=e=>cl(e).map(t=>t.slice(5)),pl="#6366f1";var gl={left:8,right:8,top:24,bottom:24,containLabel:!0};function ma(e){return{grid:gl,tooltip:{trigger:"axis"},xAxis:{type:"category",data:ul(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:pl,borderRadius:[2,2,0,0]},barMaxWidth:10}]}}var Yn=I(Pe());var fn=I(z()),va=({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),d=t/e.length,u=d>4?1:0,l=2;return(0,fn.jsx)("svg",{width:t,height:n,style:{display:"block"},children:e.map((a,v)=>{let y=Math.max(a/i*n,l);return(0,fn.jsx)("rect",{x:v*d,y:n-y,width:Math.max(d-u,1),height:y,fill:a===0?r:o,rx:1},v)})})},ha=({values:e,width:t=200,height:n=40,color:o="#6366f1"})=>{if(e.length===0)return null;let r=Math.min(...e),d=Math.max(...e)-r||1,u=2,l=t-u*2,a=f=>e.length===1?t/2:u+f/(e.length-1)*l,v=f=>n-2-(f-r)/d*(n-4),y=e.map((f,c)=>`${a(c)},${v(f)}`).join(" ");return(0,fn.jsxs)("svg",{width:t,height:n,style:{display:"block"},children:[(0,fn.jsx)("polyline",{points:y,fill:"none",stroke:o,strokeWidth:"1.5",strokeLinecap:"round"}),e.map((f,c)=>(0,fn.jsx)("circle",{cx:a(c),cy:v(f),r:"2.5",fill:o},c))]})};var Ke=I(Pe());var nn=I(Pe());var Bo=I(Pe());var tn=I(z()),ba=({projectId:e,value:t,onChange:n})=>{let{message:o}=Ve.useApp(),{uploadFileToProject:r}=Lt(),i=_(),[d,u]=(0,Bo.useState)([]),l=(0,Bo.useRef)(e);l.current=e;let a=t.map(c=>({uid:c.uri,name:c.name||c.uri,status:"done",response:{uri:c.uri,name:c.name}})),v=async c=>{let p=c.file;try{let s=await r(e,"/project/uploads",p);c.onSuccess?.({uri:s.path,name:p.name,projectId:e})}catch(s){c.onError?.(s instanceof Error?s:new Error("Upload failed"))}},y=c=>{let{file:p}=c;if(p.status==="done"&&p.response?.uri){if(p.response.projectId&&p.response.projectId!==l.current){u(c.fileList.filter(b=>b.status==="uploading"||b.status==="error"));return}let s={uri:p.response.uri,name:p.response.name||p.name,addedBy:"user"};t.some(b=>b.uri===s.uri)||n([...t,s])}p.status==="error"&&o.error(i("governance.learning.uploadFailed",{name:p.name})),u(c.fileList.filter(s=>s.status==="uploading"||s.status==="error"))},f=c=>{if(c.status==="done"){let p=c.response?.uri;n(t.filter(s=>s.uri!==p&&s.name!==c.name))}else u(p=>p.filter(s=>s.uid!==c.uid))};return(0,tn.jsx)("div",{"data-testid":"reference-files-field",children:(0,tn.jsxs)(Qr.Dragger,{multiple:!0,fileList:[...a,...d],customRequest:v,onChange:y,onRemove:f,style:{padding:"8px 0"},children:[(0,tn.jsx)("p",{className:"ant-upload-drag-icon",style:{marginBottom:4},children:(0,tn.jsx)(yi,{size:24,style:{color:"#6366f1"}})}),(0,tn.jsx)("p",{className:"ant-upload-text",style:{fontSize:13},children:i("governance.learning.uploadHint")}),(0,tn.jsx)("p",{className:"ant-upload-hint",style:{fontSize:12},children:i("governance.learning.uploadNote")})]},e)})};function Ln(e){return(e.metadata??{}).trainingRound===!0}function $u(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 jo(e){return["pending","in_progress","review"].includes(e.status)}function Mn(e,t){return`/api/tasks?${`metadata=${encodeURIComponent(JSON.stringify({trainingRound:"true",targetAgentId:e}))}`}${t?`&projectId=${t}`:""}`}function fl(e,t){return`/api/tasks?${`parentId=${e}`}${t?`&projectId=${t}`:""}`}function ka(e,t){return`${e}:${t}`}async function wa(e){let t=e.projectId?{headers:{"x-project-id":e.projectId}}:void 0,o=(await e.post("/api/tasks",{title:e.goal.slice(0,60),description:e.goal,ownerType:"agent",ownerId:"agent-architect",workspaceId:e.workspaceId??void 0,projectId:e.projectId??void 0,context:{source:"learning"},metadata:{trainingRound:!0,targetAgentId:e.targetAgentId},files:e.files&&e.files.length>0?e.files:void 0},t)).data;if(!o)throw new Error(e.t?e.t("governance.learning.roundCreateFailed"):"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(e.t?e.t("governance.learning.threadCreateFailed"):"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 xa(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 Ta(e){let t=e.targetMode==="placeholder"?"Target form: learning placeholder (architecture undecided).":e.targetMode==="existing-workflow"?"Target form: existing Workflow.":"Target form: existing Capability or Orchestra.";return[`Learning goal (draft \u2014 confirm with the user before any observation or design): ${e.goal}`,`Exact target ID: "${e.targetAgentId}".`,`Exact round Task ID: "${e.roundTaskId}".`,"That exact Task is your bound tracking task: your main task and Belief root for this round.","Reconcile it; create every child under it; never create a new main or round task.",t,...e.files?.length?[`Reference files: ${e.files.map(n=>`${n.name||n.uri} (${n.uri})`).join(", ")}. Read them before designing; in your first reply state which files you actually read and what you took from each.`]:[]].join(`
232
+ `)}var ml=5;async function Ra(e,t,n){let o=n?.projectId,r=o?{headers:{"x-project-id":o}}:void 0,i=y=>fl(y,o??void 0),d=[],u=!1,l=new Set,a=new Set([t]),v=[t];for(let y=0;y<ml&&v.length>0;y++){let c=(await Promise.all(v.map(p=>e(i(p),r).then(s=>Array.isArray(s.data)?s.data.map(b=>b.parentId?b:{...b,parentId:p}):[]).catch(()=>(u=!0,l.add(p),[]))))).flat().filter(p=>a.has(p.id)?!1:(a.add(p.id),!0));d.push(...c),v=c.map(p=>p.id)}if(v.length>0){u=!0;for(let y of v)l.add(y)}return{tasks:d,partial:u,...l.size>0?{incompleteParentIds:[...l]}:{}}}var Qe=I(z()),Nn=({open:e,agentId:t,defaultProjectId:n,onClose:o,onCreated:r})=>{let{get:i,post:d,put:u}=et(),{message:l}=Ve.useApp(),a=_(),v=yt("agent-architect"),{trainingProjects:y,loading:f}=Lt(),c=y.find(C=>C.id===n)??null,[p]=fe.useForm(),[s,b]=(0,nn.useState)(!1),[h,m]=(0,nn.useState)(null),[w,R]=(0,nn.useState)(null),[P,S]=(0,nn.useState)([]);(0,nn.useEffect)(()=>{e&&(R(ka(v.tenantId,t)),S([]))},[e,v,t]),(0,nn.useEffect)(()=>{if(!e)return;let C=!1;return(async()=>{try{let x=await i(Mn(t,c?.id??void 0),c?{headers:{"x-project-id":c.id}}:void 0);if(C)return;let L=(x.data??[]).filter(Ln);m(L.find(jo)??null)}catch{}})(),()=>{C=!0}},[e,i,t,c]);let K=async C=>{if(!c){l.error(a("governance.learning.noProject"));return}b(!0);try{let{roundTaskId:x,threadId:L}=await wa({goal:C.goal,targetAgentId:t,workspaceId:c.workspaceId,projectId:c.id,existingThreadId:w,files:P,post:d,put:u,t:a});l.success(a("governance.learning.created")),p.resetFields(),r(x,L,C.goal,P),S([])}catch(x){l.error(x instanceof Error?x.message:a("governance.learning.createFailed"))}finally{b(!1)}};return(0,Qe.jsxs)(Be,{title:a("governance.learning.newTask"),open:e,onCancel:o,footer:null,width:520,destroyOnClose:!0,children:[h&&(0,Qe.jsx)(Pt,{type:"warning",showIcon:!0,style:{marginBottom:16},message:a("governance.learning.inProgress")}),(0,Qe.jsxs)(fe,{form:p,layout:"vertical",onFinish:K,children:[(0,Qe.jsx)(fe.Item,{label:a("governance.learning.goalLabel"),name:"goal",rules:[{required:!0,message:a("governance.learning.goalRequired")}],children:(0,Qe.jsx)(_e.TextArea,{rows:3,placeholder:a("governance.learning.goalPlaceholder")})}),c&&(0,Qe.jsx)(fe.Item,{label:(0,Qe.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,Qe.jsx)("span",{children:a("governance.learning.referenceMaterials")}),(0,Qe.jsx)(gr,{project:c,selectable:!1,loading:f})]}),extra:a("governance.learning.referenceMaterialsHint"),style:{marginBottom:16},colon:!1,children:(0,Qe.jsx)(ba,{projectId:c.id,value:P,onChange:S})}),!c&&!f&&(0,Qe.jsx)(fe.Item,{style:{marginBottom:16},children:(0,Qe.jsx)(gr,{project:c,loading:f})}),(0,Qe.jsxs)(fe.Item,{style:{marginBottom:0,textAlign:"right"},children:[(0,Qe.jsx)(Z,{onClick:o,style:{marginRight:8},children:a("common.cancel")}),(0,Qe.jsx)(Z,{type:"primary",htmlType:"submit",loading:s,disabled:!!h||f||!c,children:a("governance.learning.start")})]})]})]})};var we=I(Pe());var mn=I(z()),Ca=32,vl=8,hl=Ca-vl,bl="governance.learning.activityLoadFailed",kl="governance.learning.activityCapacity",kr=we.default.createContext(null),Sa=we.default.createContext(()=>{});function Ia(e){switch(e){case"retry":return"governance.learning.cmd.retry";case"cancel":return"governance.learning.cmd.cancel";case"start":return"governance.learning.cmd.start";case"reopen":return"governance.learning.cmd.reopen";case"delete":return"governance.learning.cmd.delete";case"comment":return"governance.learning.cmd.comment";default:return"governance.learning.cmd.updated"}}var wl={start:"in_progress",retry:"in_progress",reopen:"in_progress",cancel:"cancelled"};function xl(e,t){return new Promise((n,o)=>{let r=window.setTimeout(()=>o(new Error("Work-item request timed out")),t);e.then(i=>{window.clearTimeout(r),n(i)},i=>{window.clearTimeout(r),o(i)})})}var wr=({task:e,relatedTasks:t,onClose:n,onRefresh:o,height:r})=>{let{message:i}=Ve.useApp(),d=_(),[u,l]=(0,we.useState)(null),[a,v]=(0,we.useState)([]),[y,f]=(0,we.useState)([]),[c,p]=(0,we.useState)(!1),[s,b]=(0,we.useState)(null),h=yt("__GLOBAL__"),w=we.default.useContext(kr)??{getWorkItemRequest:(j,oe,G,se)=>E(j,oe,G,se),getDetailSession:()=>x.current,bumpDetailSession:()=>{x.current+=1}},R=(0,we.useRef)(0),P=(0,we.useRef)(null),S=(0,we.useRef)(!0),K=(0,we.useRef)(new Map),C=(0,we.useRef)(new Set),x=(0,we.useRef)(0),L=(0,we.useRef)(h);L.current=h;let ce=(0,we.useRef)(w);ce.current=w;let J=u??e,V=(0,we.useRef)(J);V.current=J;let ge=(0,we.useRef)(o);ge.current=o;let E=(j,oe,G=x.current,se=!1)=>{let M=K.current.get(j);if(M&&(!se||M.detailSession===G))return M;M&&(K.current.delete(j),C.current.add(M.promise),M.promise.finally(()=>{C.current.delete(M.promise)}).catch(()=>{}));let he=se?Ca:hl;if(K.current.size+C.current.size>=he){let Fe=Promise.reject(new Error("Work-item request capacity reached"));return Fe.catch(()=>{}),{promise:Fe,source:oe,detailSession:G}}let be;try{be=Promise.resolve(L.current.tasks.workItems.list(j))}catch(Fe){be=Promise.reject(Fe)}let Se={promise:be,source:oe,detailSession:G};return K.current.set(j,Se),be.finally(()=>{K.current.get(j)?.promise===be&&K.current.delete(j)}).catch(()=>{}),Se};(0,we.useEffect)(()=>(S.current=!0,()=>{S.current=!1,P.current=null,R.current+=1,ce.current.bumpDetailSession(),Promise.resolve().then(()=>{S.current||(K.current.clear(),C.current.clear())})}),[]);let B=(j,oe=!0)=>{let G=oe?++R.current:R.current;oe&&S.current&&p(!0);let se=w.getDetailSession(),M=w.getWorkItemRequest(j,"detail",se,oe),he=M.detailSession===se;return xl(M.promise,4e3).then(Ne=>{he&&S.current&&G===R.current&&P.current===j&&(f(Ne),b(null))}).catch(Ne=>{he&&oe&&S.current&&G===R.current&&P.current===j&&(f([]),b(Ne instanceof Error&&Ne.message==="Work-item request capacity reached"?kl:bl))}).finally(()=>{he&&S.current&&G===R.current&&P.current===j&&p(!1)})},O=(j,oe)=>{oe&&v(G=>J?[...G,J]:G),P.current=j.id,l(j),f([]),b(null),B(j.id)},ne=j=>O(j,!0),ie=()=>{if(a.length===0)return;let j=a[a.length-1];v(a.slice(0,-1)),O(j,!1)},D=()=>{w.bumpDetailSession(),P.current=null,R.current+=1,l(null),v([]),f([]),p(!1),b(null),n()},U=(0,we.useRef)(null),{run:ve,pending:Y}=Wi({onSettled:j=>{if(!S.current)return;P.current===j.id&&B(j.id,!1);let oe=ge.current,G=d(Ia(U.current??"start"));oe&&Promise.resolve().then(oe).catch(()=>{S.current&&i.warning(d("governance.learning.commandFailedSuffix",{message:G}))})}}),ke=(0,we.useCallback)(j=>{let oe=V.current;return oe?(U.current="comment",ve(oe,"comment",{content:j})):Promise.resolve(!1)},[ve]),Me=j=>{let oe=V.current;oe&&(U.current=j,ve(oe,j).then(G=>{if(!G||!S.current)return;let se=wl[j];se&&l(M=>M&&M.id===oe.id?{...M,status:se}:M),i.success(d(Ia(j)))}))};(0,we.useEffect)(()=>{P.current!==e.id&&(v([]),O(e,!1))},[e]),(0,we.useEffect)(()=>{let j=P.current;if(!j)return;let oe=t.find(se=>se.id===j);if(!oe){D();return}l(se=>se&&se.id===j?oe:se);let G=new Map(t.map(se=>[se.id,se]));v(se=>se.flatMap(M=>{let he=G.get(M.id);return he?[he]:[]})),B(j,!1)},[e,t]),(0,we.useEffect)(()=>{if(!J?.id)return;let j=J.id,oe=!1,G=async()=>{document.hidden||await B(j,!1)},se=()=>{oe||!S.current||document.hidden||G()};return document.addEventListener("visibilitychange",se),G(),()=>{oe=!0,document.removeEventListener("visibilitychange",se)}},[J?.id]);let F=So(J),re=we.default.useContext(Sa);(0,we.useEffect)(()=>{re(e,J)},[re,e,J]);let Re=J?!!Y[J.id]:!1;return(0,mn.jsx)("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"#fff",border:"1px solid rgba(5,5,5,0.15)",borderRadius:12,overflow:"hidden"},children:(0,mn.jsx)("div",{style:{flex:1,minHeight:0},children:(0,mn.jsx)(Co,{task:J,relatedTasks:t,onRelatedTaskClick:ne,workItems:y,loading:c,activityError:s?d(s):void 0,commandPending:Re,onRun:Me,onComment:ke,commentPending:Re,onViewChat:F,onBack:ie,canGoBack:a.length>0,maxHeight:r,focusKey:`${J.id}:${Re?"updating":J.status}`,subtasks:t.filter(j=>j.parentId===J.id),onSubtaskClick:ne,parent:t.find(j=>j.id===J.parentId)??null,onParentClick:ne})})})},Aa=({task:e,relatedTasks:t,onClose:n,onRefresh:o})=>{let[r,i]=(0,we.useState)(null),d=(0,we.useCallback)((l,a)=>{i({rootId:l.id,title:a.title})},[]);(0,we.useEffect)(()=>{e||i(null)},[e]);let u=e?r&&r.rootId===e.id?r.title:e.title:"";return(0,mn.jsx)(Be,{open:e!==null,onCancel:n,footer:null,title:u,width:960,style:{maxWidth:"calc(100vw - 32px)"},styles:{header:{padding:"16px 24px 0"},content:{padding:0},body:{padding:"12px 24px 24px"}},centered:!0,children:(0,mn.jsx)(Sa.Provider,{value:d,children:e&&(0,mn.jsx)(wr,{task:e,relatedTasks:t,onClose:n,onRefresh:o,height:"calc(100dvh - 96px)"})})})};var De=I(z()),xr=32,Tl=8,Rl=xr-Tl;function Il(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 Cl(e){let t=typeof e.detail?.markdown=="string"&&e.detail.markdown.length>0?e.detail.markdown:void 0;if(t){let n=Il(t);if(n)return n}return e.summary||e.action||""}function Sl(e){let t=e.context?.interruption;return e.status==="interrupted"&&typeof t=="object"&&t!==null&&t.type==="review_required"}function Al(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 Pa=({assistantId:e,projectId:t,onLearningStarted:n,round:o,subTasks:r,rounds:i,subTasksByRound:d,selectedRoundId:u,onSelectedRoundChange:l,loading:a,onRefresh:v,onStartRequest:y,onExpandWorkflow:f})=>{let{message:c}=Ve.useApp(),p=_(),[s,b]=(0,Ke.useState)(!1),[h,m]=(0,Ke.useState)(!1),[w,R]=(0,Ke.useState)(null),[P,S]=(0,Ke.useState)(null),K=yt("__GLOBAL__"),C=(0,Ke.useRef)(!0),x=(0,Ke.useRef)(new Map),L=(0,Ke.useRef)(new Set),ce=(0,Ke.useRef)(0),J=(0,Ke.useRef)(0),V=i&&i.length>0?i:o?[o]:[],[ge,E]=(0,Ke.useState)(null),B=u!==void 0,O=B?u:ge,ne=V.map(M=>M.id).join(",");(0,Ke.useEffect)(()=>{if(V.length===0){E(null);return}E(M=>M&&ne.split(",").includes(M)?M:V[0].id)},[ne]);let ie=V.find(M=>M.id===O)??V[0]??null,D=M=>{B||E(M),l?.(M)},U=d&&ie?d[ie.id]??[]:ie&&ie.id===o?.id?r:[],ve=(0,Ke.useMemo)(()=>[ie,...U].filter(M=>M!==null),[o,r,i,d,O]),Y=U.filter(M=>M.status==="in_progress"),ke=Y[0]??null,Me=ie?.status==="in_progress",F=(Y.length>0?Y.map(M=>M.id):Me&&ie?[ie.id]:[]).sort(),re=F.join(","),Re=(0,Ke.useRef)(K);Re.current=K;let j=(0,Ke.useRef)(null);j.current||(j.current={getWorkItemRequest:(M,he,Ne,be)=>oe(M,he,Ne,be),getDetailSession:()=>ce.current,bumpDetailSession:()=>{ce.current+=1}});let oe=(M,he,Ne=ce.current,be=!1)=>{let Se=x.current.get(M);if(Se&&(!be||Se.detailSession===Ne))return Se;Se&&(x.current.delete(M),L.current.add(Se.promise),Se.promise.finally(()=>{L.current.delete(Se.promise)}).catch(()=>{}));let Fe=be?xr:Rl;if(x.current.size+L.current.size>=Fe){let Oe=Promise.reject(new Error("Work-item request capacity reached"));return Oe.catch(()=>{}),{promise:Oe,source:he,detailSession:Ne}}let Ze;try{Ze=Promise.resolve(Re.current.tasks.workItems.list(M))}catch(Oe){Ze=Promise.reject(Oe)}let tt={promise:Ze,source:he,detailSession:Ne};return x.current.set(M,tt),Ze.finally(()=>{x.current.get(M)?.promise===Ze&&x.current.delete(M)}).catch(()=>{}),tt};(0,Ke.useEffect)(()=>(C.current=!0,()=>{C.current=!1,Promise.resolve().then(()=>{C.current||(x.current.clear(),L.current.clear())})}),[]),(0,Ke.useEffect)(()=>{if(F.length===0){S(null);return}S(null);let M=!1,he=()=>{if(document.hidden)return Promise.resolve();let be=J.current%F.length,Se=[...F.slice(be),...F.slice(0,be)];return J.current=(be+xr)%F.length,Promise.allSettled(Se.map(Fe=>Al(oe(Fe,"live").promise,4e3))).then(Fe=>{if(M||!C.current)return;let rt=Fe.filter(Oe=>Oe.status==="fulfilled").map(Oe=>Oe.value);if(rt.length===0)return;let tt=[...rt.flat().filter(Oe=>!/^Status changed to\b/i.test(Oe.summary??""))].sort((Oe,bt)=>new Date(bt.createdAt).getTime()-new Date(Oe.createdAt).getTime());S(tt[0]??null)})},Ne=()=>{M||!C.current||document.hidden||he()};return document.addEventListener("visibilitychange",Ne),he(),()=>{M=!0,document.removeEventListener("visibilitychange",Ne)}},[re]);let G=M=>R(M),se=(M,he,Ne,be)=>{D(M),b(!1);let Se;try{Se=Promise.resolve(v())}catch{Se=Promise.reject(new Error("Task-list refresh failed"))}Se.catch(()=>{C.current&&c.error(p("governance.learning.createdRefreshFailed"))}),n?.(Ne,M,be)};return(0,De.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:[a?(0,De.jsx)("div",{style:{fontSize:12,color:"#bbb",padding:"4px 2px"},children:p("common.loading")}):ie?(0,De.jsxs)("div",{children:[(0,De.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,De.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"#595959"},children:p("governance.learning.tasksTitle")}),(0,De.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:2},children:[f&&(0,De.jsx)(Z,{size:"small",type:"text","aria-label":p("governance.learning.openWorkflow"),icon:(0,De.jsx)(Tn,{}),onClick:f}),(0,De.jsx)(Z,{size:"small",type:"text",icon:(0,De.jsx)(Dt,{}),onClick:()=>y?y():b(!0),style:{fontSize:12},children:p("governance.learning.newTask")})]})]}),V.length>1&&(0,De.jsx)(at,{size:"small","data-testid":"round-filter",style:{width:"100%",marginBottom:6},value:ie.id,onChange:D,options:V.map(M=>({value:M.id,label:`${M.title||M.id} (${M.status})`}))}),(()=>{let M=ve.filter(Sl);return M.length>0?(0,De.jsx)(Z,{type:"text","data-testid":"review-banner","aria-label":p("governance.learning.openReviewTasks",{count:M.length,s:M.length>1?"s":""}),onClick:()=>G(M[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:p("governance.learning.reviewCount",{count:M.length,s:M.length>1?"s":""})}):null})(),P&&(0,De.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,De.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:ke?"#3b82f6":"#bbb",animation:ke?"live-pulse 1.2s ease-in-out infinite":void 0}}),(0,De.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Cl(P)}),(0,De.jsx)("style",{children:"@keyframes live-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }"})]}),(0,De.jsx)("div",{style:{maxHeight:240,overflow:"auto"},children:(0,De.jsx)(Io,{tasks:[ie,...U],loading:!1,onTaskClick:G,hideCompleted:h,onHideCompletedChange:m})})]}):(0,De.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 2px"},children:[(0,De.jsx)("span",{style:{fontSize:12,color:"#999"},children:p("governance.learning.empty")}),(0,De.jsx)(Z,{size:"small",icon:(0,De.jsx)(Dt,{}),onClick:()=>y?y():b(!0),children:p("governance.learning.newTask")})]}),!y&&(0,De.jsx)(Nn,{open:s,agentId:e,defaultProjectId:t,onClose:()=>b(!1),onCreated:se}),(0,De.jsx)(kr.Provider,{value:j.current,children:(0,De.jsx)(Aa,{task:w,relatedTasks:ve,onClose:()=>R(null),onRefresh:v})})]})};var ze=I(Pe());function Ea(e,t){let n=[...t],o=new Set(t.map(u=>`${u.from}|${u.to}`)),r=new Set(t.filter(u=>u.kind==="dependency").map(u=>u.to)),i=new Set(e.map(u=>u.id)),d=new Map;for(let u of e){if(!u.parentId||!i.has(u.parentId))continue;let l=d.get(u.parentId)??[];l.push(u),d.set(u.parentId,l)}for(let u of d.values()){let l=[...u].sort((a,v)=>new Date(a.createdAt).getTime()-new Date(v.createdAt).getTime());for(let a=1;a<l.length;a++){let v=l[a];if(r.has(v.id))continue;let y=l[a-1].id,f=`${y}|${v.id}`;o.has(f)||o.has(`${v.id}|${y}`)||(n.push({from:y,to:v.id,kind:"sequence"}),o.add(f))}}return n}function Da(e,t){return e!=="completed"?"idle":t==="in_progress"?"flowing":t==="pending"?"idle":"traversed"}function La(e){return e==="completed"?"traversed":e==="in_progress"?"flowing":"idle"}var $t={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}},Pl={pending:"governance.learning.status.pending",in_progress:"governance.learning.status.running",review:"governance.learning.status.review",failed:"governance.learning.status.failed",interrupted:"governance.learning.status.interrupted",completed:"governance.learning.status.done",cancelled:"governance.learning.status.cancelled"};function Vn(e,t){return t?t(Pl[e]):$t[e].label}var Mt=I(z()),Ma=({data:e})=>{let{task:t}=e,n=_(),o=$t[t.status];return(0,Mt.jsxs)("div",{"data-testid":"workflow-task-node","data-active":String(o.active),style:{width:180,padding:"8px 10px",borderRadius:10,border:`1.5px solid ${o.color}`,background:"#fff",animation:o.active?"workflow-node-pulse 1.6s ease-in-out infinite":void 0},children:[(0,Mt.jsx)(xt,{type:"target",position:st.Left,style:{opacity:0}}),(0,Mt.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[(0,Mt.jsx)("span",{style:{width:8,height:8,borderRadius:9999,background:o.color,flexShrink:0}}),(0,Mt.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"#262626",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t.title,children:t.title})]}),(0,Mt.jsx)("div",{style:{fontSize:10,color:"#8c8c8c"},children:Vn(t.status,n)}),(0,Mt.jsx)(xt,{type:"source",position:st.Right,style:{opacity:0}}),o.active&&(0,Mt.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 lt=I(z()),El={workflowTask:Ma},Dl=180,Ll=56,Ml={traversed:{stroke:"#22c55e",strokeWidth:1.5},flowing:{stroke:"#6366f1",strokeWidth:2},idle:{stroke:"#d1d5db",strokeWidth:1,strokeDasharray:"5 5"}},Na=({rounds:e,subTasksByRound:t,loading:n})=>{let o=yt("__GLOBAL__"),r=_(),[i,d]=(0,ze.useState)(null),[u,l]=(0,ze.useState)(null),[a,v]=(0,ze.useState)([]),[y,f]=(0,ze.useState)(!1),[c,p]=(0,ze.useState)(null),s=(0,ze.useRef)(0),b=(0,ze.useRef)(o);b.current=o;let h=e.map(D=>D.id).join(",");(0,ze.useEffect)(()=>{d(D=>D&&h.split(",").includes(D)?D:e[0]?.id??null)},[h]);let m=e.find(D=>D.id===i)??e[0]??null,w=(0,ze.useMemo)(()=>[m,...m?t[m.id]??[]:[]].filter(D=>D!==null),[m,t]),{nodes:R,edges:P}=(0,ze.useMemo)(()=>Ro(w),[w]),S=(0,ze.useMemo)(()=>Ea(w,P),[w,P]),K=(0,ze.useMemo)(()=>new Map(w.map(D=>[D.id,D])),[w]),C=(0,ze.useMemo)(()=>{let D=xo(R.map(U=>({id:U.id})),S.map(U=>({from:U.from,to:U.to})),{nodeWidth:Dl,nodeHeight:Ll,nodesep:24,ranksep:60,rankdir:"LR"});return R.map(U=>({id:U.id,type:"workflowTask",position:D.get(U.id)??{x:0,y:0},data:{task:U.task}}))},[R,S]),x=(0,ze.useMemo)(()=>S.map(D=>{let U=Da(K.get(D.from)?.status??"pending",K.get(D.to)?.status??"pending");return{id:`${D.from}->${D.to}:${D.kind}`,source:D.from,target:D.to,animated:U==="flowing",style:{...Ml[U],...D.kind==="sequence"&&U!=="idle"?{strokeDasharray:"2 3"}:{}}}}),[S,K]),[L,ce,J]=Cn(C),[V,ge,E]=Sn(x);(0,ze.useEffect)(()=>{ce(D=>{let U=D.map(Y=>Y.id).sort().join("|"),ve=C.map(Y=>Y.id).sort().join("|");if(U===ve){let Y=new Map(D.map(ke=>[ke.id,ke]));return C.map(ke=>{let Me=Y.get(ke.id);return Me?{...ke,position:Me.position}:ke})}return C}),ge(x)},[C,x,ce,ge]);let B=(0,ze.useCallback)(D=>{let U=++s.current;f(!0),p(null),b.current.tasks.workItems.list(D).then(ve=>{U===s.current&&v(ve)}).catch(()=>{U===s.current&&(v([]),p(r("governance.learning.activityLoadFailed")))}).finally(()=>{U===s.current&&f(!1)})},[r]),O=(0,ze.useCallback)((D,U)=>{let ve=U.data?.task;ve&&(v([]),l(ve),B(ve.id))},[B]),ne=(0,ze.useCallback)(()=>{s.current+=1,l(null),v([]),p(null),f(!1)},[]),ie=So(u);return n?(0,lt.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,lt.jsx)(wt,{size:"large"})}):!m||w.length===0?(0,lt.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:(0,lt.jsx)(Gt,{description:r("governance.learning.noTasks")})}):(0,lt.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[e.length>1&&(0,lt.jsx)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",paddingBottom:12,flexShrink:0},children:e.map((D,U)=>{let ve=$t[D.status],Y=D.id===m.id;return(0,lt.jsxs)("button",{type:"button","data-testid":`round-chip-${D.id}`,onClick:()=>{d(D.id),ne()},title:D.title,style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11,fontWeight:600,padding:"3px 10px",borderRadius:9999,cursor:"pointer",border:Y?"1.5px solid #6366f1":"1px solid #e5e7eb",background:Y?"rgba(99,102,241,0.08)":"#fff",color:Y?"#6366f1":"#6b7280"},children:[(0,lt.jsx)("span",{style:{width:6,height:6,borderRadius:9999,background:ve.color}}),"R",e.length-U]},D.id)})}),(0,lt.jsx)("div",{style:{flex:1,minHeight:0,position:"relative"},children:(0,lt.jsx)(To,{nodes:L,edges:V,nodeTypes:El,onNodesChange:J,onEdgesChange:E,onNodeClick:O,fitView:!0,fitViewOptions:{padding:.15},nodesDraggable:!0,nodesConnectable:!1,miniMap:!0,attributionPosition:"bottom-right"})}),u&&(0,lt.jsx)("div",{"data-testid":"workflow-detail",style:{height:"40%",minHeight:200,flexShrink:0,borderTop:"1px solid #f0f0f0",overflow:"hidden"},children:(0,lt.jsx)(Co,{task:u,relatedTasks:w,workItems:a,loading:y,activityError:c??void 0,onViewChat:ie,onBack:ne,subtasks:w.filter(D=>D.parentId===u.id),onSubtaskClick:D=>{v([]),l(D),B(D.id)},parent:w.find(D=>D.id===u.parentId)??null,onParentClick:D=>{v([]),l(D),B(D.id)}})})]})};var Rt=I(Pe());var Nt=I(z()),Nl=0,Fa=360,_a=48,Oa=16;function Tr(e){let t=typeof window>"u"?1200:window.innerWidth-_a;return Math.min(Math.max(e,Fa),t)}var ct=({open:e,width:t,mobileWidth:n,left:o,top:r=56,bottom:i=12,height:d,title:u,onClose:l,bodyStyle:a,restoreFocusRef:v,focusControlRef:y,escapeEnabled:f=!0,zIndex:c=25,children:p})=>{let s=Ci("(max-width: 720px)"),b=_(),h=(0,Rt.useRef)(null),m=(0,Rt.useRef)(null),w=(0,Rt.useRef)(null);w.current||(w.current=`canvas-dock-title-${++Nl}`);let R=w.current,[P,S]=(0,Rt.useState)(null);(0,Rt.useEffect)(()=>S(null),[t,n]);let K=!s&&typeof t=="number",C=s?n??t:P??t,x=typeof C=="number"?C:null,L=o===void 0?-1:1,ce=V=>{if(!K||x===null)return;V.preventDefault();let ge={startX:V.clientX,startWidth:x},E=O=>{S(Tr(ge.startWidth+L*(O.clientX-ge.startX)))},B=()=>{window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",B)};window.addEventListener("pointermove",E),window.addEventListener("pointerup",B)},J=V=>{!K||x===null||(V.key==="ArrowLeft"?(V.preventDefault(),S(Tr(x-L*Oa))):V.key==="ArrowRight"&&(V.preventDefault(),S(Tr(x+L*Oa))))};return(0,Rt.useEffect)(()=>{if(!e||!f)return;let V=ge=>{ge.key==="Escape"&&!ge.defaultPrevented&&l()};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[f,e,l]),(0,Rt.useEffect)(()=>{if(y)return y.current=()=>h.current?.focus(),()=>{y.current=null}},[y]),(0,Rt.useEffect)(()=>{if(!e)return;let V=v?.current??document.activeElement;return V instanceof HTMLElement&&(m.current=V),h.current?.focus(),()=>{m.current?.focus(),m.current=null}},[e]),e?(0,Nt.jsxs)("div",{"data-testid":"canvas-dock",role:"region","aria-labelledby":R,style:{position:"absolute",top:r,...o===void 0?{right:12}:{left:o},...d===void 0?{bottom:i}:{height:d},width:C,maxWidth:"calc(100% - 24px)",boxSizing:"border-box",zIndex:c,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,Nt.jsx)("style",{children:"@keyframes canvas-dock-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }"}),K&&(0,Nt.jsx)("div",{"data-testid":"canvas-dock-resize-handle",role:"separator","aria-orientation":"vertical","aria-label":b("governance.dock.resize"),"aria-valuenow":x??void 0,"aria-valuemin":Fa,"aria-valuemax":typeof window>"u"?void 0:window.innerWidth-_a,tabIndex:0,onPointerDown:ce,onKeyDown:J,style:{position:"absolute",...o===void 0?{left:0}:{right:0},top:0,bottom:0,width:6,cursor:"ew-resize",zIndex:1,touchAction:"none"}}),(0,Nt.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,Nt.jsx)("div",{id:R,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:u}),(0,Nt.jsx)("button",{ref:h,type:"button","aria-label":b("governance.dock.close"),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,Nt.jsx)(Ri,{size:14})})]}),(0,Nt.jsx)("div",{"data-testid":"canvas-dock-body",style:{flex:1,minHeight:0,overflow:"auto",padding:16,...a},children:p})]}):null};var Ft=I(Pe());var on=80;function Ot(e){return e>=80?"#22c55e":e>=50?"#f59e0b":"#ef4444"}function Qn(e){return e.filter(t=>t.status==="completed"&&t.holdout!==!0).sort(Kt)}function Wa(e){let t=Qn(e),n=t[t.length-1];if(!n)return{latestScore:null,delta:null,passRate:null,passedCases:0,totalCases:0,interruptedCases:0,latestRunId:null};let o=t[t.length-2],r=n.totalCases??0,i=n.passedCases??0;return{latestScore:n.avgScore,delta:o?Math.round(n.avgScore-o.avgScore):null,passRate:r>0?Math.round(i/r*100):null,passedCases:i,totalCases:r,interruptedCases:n.interruptedCases??0,latestRunId:n.id}}function za(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 Ol=.15,Ba={left:36,right:12,top:16,bottom:24},Rr={fontSize:9,color:"#999"};function ja(){return{type:"value",min:0,max:100,axisLabel:{...Rr},splitLine:{lineStyle:{color:"#f5f5f5"}}}}function Ga({rounds:e,runs:t,selectedRoundId:n,targetLabel:o}){let r=[...e].sort((c,p)=>new Date(c.createdAt).getTime()-new Date(p.createdAt).getTime()),i=t.filter(c=>c.status==="completed").sort(Kt),d=new Map(r.map((c,p)=>[c.id,p+1])),u=new Map;for(let c of i){let p=c.taskId?d.get(c.taskId):void 0;p!==void 0&&u.set(p,(u.get(p)??0)+1)}let l=new Map,a=[],v=new Map;for(let c of i){let p=c.taskId?d.get(c.taskId):void 0;if(p===void 0)continue;let s=l.get(p)??0;if(l.set(p,s+1),c.holdout===!0){let b=(s-((u.get(p)??1)-1)/2)*Ol;a.push([Math.round((p+b)*100)/100,c.avgScore])}else v.set(p,c.avgScore)}let y=n??null;if(y===null){for(let c=r.length-1;c>=0;c--)if(v.has(c+1)){y=r[c].id;break}}let f=r.map((c,p)=>{let s=v.get(p+1);if(s===void 0)return null;let b=c.id===y;return{value:[p+1,s],itemStyle:{color:Ot(s),borderRadius:[4,4,0,0],...b?{borderColor:"#6366f1",borderWidth:2}:{}}}});return{grid:Ba,tooltip:{trigger:"item"},xAxis:{type:"value",min:.5,max:r.length+.5,interval:1,axisLabel:{...Rr,formatter:c=>Number.isInteger(c)?`R${c}`:""},axisLine:{lineStyle:{color:"#eee"}},splitLine:{show:!1}},yAxis:ja(),series:[{type:"bar",data:f,barWidth:22,markLine:{silent:!0,symbol:"none",lineStyle:{type:"dashed",color:"#d9d9d9"},label:{fontSize:9,color:"#999",formatter:o??`target ${on}`},data:[{yAxis:on}]}},{type:"scatter",data:a,symbol:"diamond",symbolSize:9,itemStyle:{color:"#fff",borderColor:"#f59e0b",borderWidth:1.5},z:4}]}}function Ka(e,t){let n=e.filter(i=>i.status==="completed").sort(Kt),o=[],r=[];return n.forEach((i,d)=>{i.holdout===!0?r.push([d+1,i.avgScore]):o.push([d+1,i.avgScore])}),{grid:Ba,tooltip:{trigger:"item"},xAxis:{type:"value",min:.5,max:Math.max(n.length,1)+.5,interval:1,axisLabel:{...Rr,formatter:i=>Number.isInteger(i)?`#${i}`:""},axisLine:{lineStyle:{color:"#eee"}},splitLine:{show:!1}},yAxis:ja(),series:[{type:"line",data:o,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:t??`target ${on}`},data:[{yAxis:on}]}},{type:"scatter",data:r,symbol:"diamond",symbolSize:9,itemStyle:{color:"#fff",borderColor:"#f59e0b",borderWidth:1.5},z:4}]}}var ut=I(z()),Ir={fontSize:10,color:"#999"},Cr={fontSize:22,fontWeight:700,lineHeight:1.2},qa=({summary:e})=>{let t=_();return e.latestScore===null?null:(0,ut.jsxs)("div",{"data-testid":"eval-summary",style:{display:"flex",gap:28},children:[(0,ut.jsxs)("div",{children:[(0,ut.jsxs)("div",{style:{...Cr,color:Ot(e.latestScore)},children:[e.latestScore.toFixed(1),e.delta!==null&&(0,ut.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,ut.jsx)("div",{style:Ir,children:t("governance.evalQuality.latestScore")})]}),(0,ut.jsxs)("div",{children:[(0,ut.jsx)("div",{"data-testid":"summary-pass",style:{...Cr,color:"#262626"},children:e.passRate!==null?`${e.passRate}%`:"\u2014"}),(0,ut.jsx)("div",{style:Ir,children:t("governance.evalQuality.passSummary",{passed:e.passedCases,total:e.totalCases})})]}),e.interruptedCases>0&&(0,ut.jsxs)("div",{"data-testid":"summary-interrupted",children:[(0,ut.jsx)("div",{style:{...Cr,color:"#b45309"},children:e.interruptedCases}),(0,ut.jsx)("div",{style:Ir,children:t("governance.evalQuality.interrupted")})]})]})};var pt=I(Pe());var On=I(z()),$a=({agentId:e,projectId:t,runs:n,selectedRoundId:o,onSelectRound:r})=>{let{get:i}=et(),d=_(),[u,l]=(0,pt.useState)([]),[a,v]=(0,pt.useState)(!1),[y,f]=(0,pt.useState)(null),c=pt.default.useRef(i);c.current=i,(0,pt.useEffect)(()=>{let h=!1;return c.current(Mn(e,t)).then(m=>{if(h)return;let w=(m.data??[]).filter(Ln);w.sort((R,P)=>new Date(R.createdAt).getTime()-new Date(P.createdAt).getTime()),l(w),v(!0)}).catch(()=>{h||v(!0)}),()=>{h=!0}},[e,t]),(0,pt.useEffect)(()=>{y&&!u.some(h=>h.id===y)&&f(null)},[u,y]);let p=(0,pt.useMemo)(()=>Ga({rounds:u,runs:n,selectedRoundId:o??y,targetLabel:d("governance.evalQuality.target",{score:on})}),[u,n,o,y,d]),s=(0,pt.useMemo)(()=>({click:h=>{let m=h;if(m.seriesType!=="bar"||typeof m.dataIndex!="number")return;let w=u[m.dataIndex];w&&(f(w.id),r?.(w.id))}}),[u,r]),b=(0,pt.useMemo)(()=>{if(u.length===0)return!1;let h=new Set(u.map(m=>m.id));return Qn(n).some(m=>m.taskId!==void 0&&h.has(m.taskId))},[u,n]);return a?b?(0,On.jsxs)("div",{"data-testid":"round-trend-chart",style:{border:"1px solid #f0f0f0",borderRadius:12,padding:12},children:[(0,On.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"rgba(0,0,0,0.65)",marginBottom:8},children:d("governance.evalQuality.roundTrend")}),(0,On.jsx)(pn,{option:p,height:100,onEvents:s})]}):(0,On.jsx)("div",{"data-testid":"round-trend-empty",style:{display:"none"}}):null};var rn=I(z()),Ha=({dimensions:e})=>e.length===0?null:(0,rn.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,rn.jsxs)("div",{"data-testid":`dimension-row-${t.name}`,style:{display:"flex",alignItems:"center",gap:8,fontSize:11},children:[(0,rn.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,rn.jsx)("div",{style:{flex:1,height:8,background:"#f5f5f5",borderRadius:4,overflow:"hidden"},children:(0,rn.jsx)("div",{"data-testid":`dimension-fill-${t.name}`,style:{width:`${n}%`,height:"100%",background:Ot(t.avgScore),borderRadius:4}})}),(0,rn.jsx)("span",{style:{width:28,textAlign:"right",flexShrink:0,fontWeight:600,color:Ot(t.avgScore)},children:Math.round(t.avgScore)})]},t.name)})});var Ht=I(z());function Ua(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 Za=({results:e})=>{let t=_();if(e===null)return null;let n=e.filter(r=>r.interrupted).length,o=e.filter(r=>!r.pass&&!r.interrupted).flatMap(r=>r.dimensionResults??[]).sort((r,i)=>r.score-i.score).slice(0,3);return(0,Ht.jsxs)("div",{style:{marginTop:8},"data-testid":"run-insights",children:[n>0&&(0,Ht.jsx)("div",{"data-testid":"interrupted-count",style:{fontSize:12,color:"#b45309",marginBottom:6},children:t("governance.evalInsights.interrupted",{count:n})}),o.length===0?(0,Ht.jsx)("div",{style:{fontSize:12,color:"#22c55e"},children:t("governance.evalInsights.allPassed")}):o.map((r,i)=>(0,Ht.jsxs)("div",{style:{fontSize:12,padding:"3px 0",display:"flex",gap:6,alignItems:"baseline"},children:[(0,Ht.jsx)("span",{style:{color:"#333",fontWeight:600,flexShrink:0},children:r.name}),(0,Ht.jsx)("span",{style:{color:r.score>=50?"#f59e0b":"#ef4444",flexShrink:0},children:r.score}),(0,Ht.jsx)("span",{style:{color:"#888",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.reason.length>80?`${r.reason.slice(0,80)}\u2026`:r.reason})]},`${r.name}-${i}`))]})};var gt=I(z()),Va={fontSize:12,fontWeight:600,color:"rgba(0,0,0,0.65)",marginBottom:8},Qa={border:"1px solid #f0f0f0",borderRadius:12,padding:12},yn=({agentId:e,projectId:t,runs:n,showRoundTrend:o=!0})=>{let{get:r}=et(),i=_(),d=(0,Ft.useMemo)(()=>Wa(n),[n]),u=Ua(n),l=n.find(s=>s.id===u),[a,v]=(0,Ft.useState)(null),y=Ft.default.useRef(r);y.current=r,(0,Ft.useEffect)(()=>{if(!u){v(null);return}let s=!1;return y.current(`/api/eval/runs/${u}`).then(b=>!s&&v(b.data?.results??[])).catch(()=>!s&&v([])),()=>{s=!0}},[u]);let f=(0,Ft.useMemo)(()=>za(a??[]),[a]),c=(0,Ft.useMemo)(()=>Ka(n,i("governance.evalQuality.target",{score:on})),[n,i]),p=Qn(n).length>0;return d.latestScore===null?(0,gt.jsx)("div",{style:{height:120,display:"flex",alignItems:"center",justifyContent:"center",color:"#bfbfbf",fontSize:12},children:i("governance.evalQuality.noRuns")}):(0,gt.jsxs)("div",{"data-testid":"eval-quality-panel",style:{display:"flex",flexDirection:"column",gap:12},children:[(0,gt.jsx)(qa,{summary:d}),o&&(0,gt.jsx)($a,{agentId:e,projectId:t,runs:n}),p&&(0,gt.jsxs)("div",{"data-testid":"run-trend-card",style:Qa,children:[(0,gt.jsx)("div",{style:Va,children:i("governance.evalQuality.scoreByRun")}),(0,gt.jsx)(pn,{option:c,height:160})]}),u&&a!==null&&(0,gt.jsxs)("div",{"data-testid":"run-diagnosis-card",style:Qa,children:[(0,gt.jsxs)("div",{style:Va,children:[i("governance.evalQuality.latestRun"),l?` \xB7 ${Wo(new Date(l.createdAt),i)}`:""," \xB7 ",i("governance.evalQuality.passCount",{passed:d.passedCases,total:d.totalCases})]}),(0,gt.jsx)(Ha,{dimensions:f}),(0,gt.jsx)(Za,{results:a})]})]})};var le=I(z()),Ya={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"},Fl=async()=>{},_l={rounds:[],round:null,subTasks:[],subTasksByRound:{},loading:!1},Go=({assistantId:e,projectId:t,onProjectChange:n,onLearningStarted:o,learningTasks:r=_l,topOffset:i=12,onLearningRefresh:d,evalTick:u,showLearning:l=!0,variant:a="full",children:v})=>{let y=_(),[f,c]=(0,Yn.useState)(null),[p,s]=(0,Yn.useState)(!1),b=fa(e),h=zo(e);return(0,Yn.useEffect)(()=>{u!==void 0&&u>0&&h.refresh()},[u]),a==="selector"?(0,le.jsxs)("div",{style:{position:"absolute",left:12,top:i,zIndex:10,pointerEvents:"none",display:"flex",flexDirection:"column",gap:8},children:[(0,le.jsx)("div",{style:{pointerEvents:"auto"},children:(0,le.jsx)(pr,{kind:"training",interactive:!0,showWorkspace:!1,value:t,onChange:n})}),v]}):(0,le.jsxs)(le.Fragment,{children:[(0,le.jsxs)("div",{style:{position:"absolute",left:12,top:i,zIndex:10,display:"flex",flexDirection:"column",gap:8,pointerEvents:"none"},children:[(0,le.jsx)("div",{style:{pointerEvents:"auto"},children:(0,le.jsx)(pr,{kind:"training",interactive:!0,showWorkspace:!1,value:t,onChange:n})}),(0,le.jsxs)("div",{onClick:()=>c(f==="runtime"?null:"runtime"),title:y("governance.overlay.runtimeChartTitle"),style:Ya,children:[(0,le.jsx)("div",{style:{fontSize:10,fontWeight:600,color:"#999",marginBottom:4},children:y("governance.overlay.runtime")}),(0,le.jsxs)("div",{style:{display:"flex",gap:14,fontSize:12,alignItems:"center"},children:[(0,le.jsxs)("span",{children:[(0,le.jsx)("strong",{style:{color:"#595959"},children:b.total})," ",(0,le.jsx)("span",{style:{color:"#bbb"},children:y("governance.overlay.threads")})]}),(0,le.jsxs)("span",{children:[(0,le.jsx)("strong",{style:{color:"#595959"},children:b.last7d})," ",(0,le.jsx)("span",{style:{color:"#bbb"},children:"7d"})]}),(0,le.jsxs)("span",{children:[(0,le.jsx)("strong",{style:{color:"#595959"},children:b.last30d})," ",(0,le.jsx)("span",{style:{color:"#bbb"},children:"30d"})]}),(0,le.jsx)("span",{style:{color:"#999"},children:Wo(b.lastActive)}),b.daily7d.length>0&&(0,le.jsx)(va,{values:b.daily7d,width:56,height:20,color:"#8c8c8c"})]})]}),(0,le.jsxs)("div",{onClick:()=>c(f==="eval"?null:"eval"),title:y("governance.overlay.evalChartTitle"),style:Ya,children:[(0,le.jsx)("div",{style:{fontSize:10,fontWeight:600,color:"#999",marginBottom:4},children:y("governance.overlay.evalQuality")}),(0,le.jsxs)("div",{style:{display:"flex",gap:14,fontSize:12,alignItems:"center"},children:[(0,le.jsxs)("span",{children:[(0,le.jsx)("strong",{style:{color:h.score===null?"#d9d9d9":h.score>=80?"#22c55e":h.score>=50?"#f59e0b":"#ef4444"},children:h.score!==null?h.score.toFixed(1):"\u2014"})," ",(0,le.jsx)("span",{style:{color:"#bbb"},children:y("governance.overlay.stat.score")})]}),(0,le.jsxs)("span",{children:[(0,le.jsx)("strong",{style:{color:"#595959"},children:h.passRate!==null?`${h.passRate}%`:"\u2014"})," ",(0,le.jsx)("span",{style:{color:"#bbb"},children:y("governance.overlay.stat.pass")})]}),(0,le.jsxs)("span",{children:[(0,le.jsx)("strong",{style:{color:"#595959"},children:h.runCount})," ",(0,le.jsx)("span",{style:{color:"#bbb"},children:y("governance.overlay.stat.runs")})]}),h.scores.length>1&&(0,le.jsx)(ha,{values:h.scores.slice(-10),width:64,height:20,color:h.score===null?"#d9d9d9":h.score>=80?"#22c55e":h.score>=50?"#f59e0b":"#ef4444"})]})]}),l&&(0,le.jsx)(Pa,{assistantId:e,projectId:t,onLearningStarted:o,round:r.round,subTasks:r.subTasks,rounds:r.rounds,subTasksByRound:r.subTasksByRound,loading:r.loading,onRefresh:d??Fl,onExpandWorkflow:()=>s(!0)})]}),f==="runtime"&&(0,le.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,le.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"rgba(0,0,0,0.65)",marginBottom:8},children:y("governance.overlay.runtimePanel")}),(0,le.jsx)(pn,{option:ma(b.daily30d),height:220})]}),f==="eval"&&(0,le.jsx)(ct,{open:!0,width:720,title:y("governance.overlay.evalQuality"),onClose:()=>c(null),children:(0,le.jsx)(yn,{agentId:e,runs:h.runs??[]})}),p&&(0,le.jsx)(ct,{open:!0,width:860,title:y("governance.overlay.learningWorkflow"),onClose:()=>s(!1),children:(0,le.jsx)(Na,{rounds:r.rounds,subTasksByRound:r.subTasksByRound,loading:r.loading})})]})};var Xo=I(Pe());var It=I(Pe());var qo=(e,t,n,o,r)=>({id:e,label:t,x:n-o/2,y:-r/2,width:o,height:r}),vn=qo("zone:config","CONFIG",-767,900,620),Fn=qo("zone:testing","EVALUATION",-69,400,560),Ko=qo("zone:learning","LEARNING",459,560,680),Xa=qo("zone:copilot","COPILOT",1147,720,740);var Ja=[vn.id,Fn.id,Ko.id,Xa.id],es=.45,Wl=220,zl=110,Bl=200,$o=90,Ho={"group:subagents":{x:0,y:-190},"group:capabilities":{x:330,y:0},"group:tools":{x:0,y:190},"group:skills":{x:-330,y:0}},ts=e=>({x:e.x+e.width/2-Wl/2,y:e.y+e.height/2-zl/2}),ns=(e,t,n)=>{let o=Ho[t]??{x:0,y:0};return{x:e.x+e.width/2+o.x-Bl/2,y:e.y+e.height/2+o.y-n/2}},jl=310,Gl=e=>{let t=vn.x+vn.width/2,n=jl;for(let[o,r]of Object.entries(e)){let i=Ho[o];i&&(n=Math.max(n,Math.abs(i.y)+r/2+40))}return{id:vn.id,label:vn.label,x:t-vn.width/2,y:-n,width:vn.width,height:n*2}},Kl=900,Sr={x:20,y:20},Xn=110,Jn=48,ql=220,$l=560,Hl=e=>({id:Fn.id,label:Fn.label,x:Fn.x,y:Fn.y,width:Fn.width,height:Math.max($l,ql+e+24)}),os=(e,t,n)=>({x:e.x+e.width/2-Xn/2,y:e.y+e.height/2-Jn/2}),Ul=48,Zl=520,Vl=720,vt=20,Ar=150,Pr=12,rs=56,Er=12,is=e=>Math.round((e-Pr*2-Er)/2),as=(e,t,n)=>{let o={},r=Pr,i=rs,d=Er,u=is(e),l=e-r*2-d-u,a=t-i-r,v=Math.round((a-d)/2),y=n.has("learning"),f=n.has("evaluation");return n.has("copilot")?(o.copilot={width:u},y&&(o.learning=f?{left:r,top:i,width:l,height:v}:{left:r,top:i,width:l,height:a}),f&&(o.evaluation=y?{left:r,top:i+v+d,width:l,height:a-v-d}:{left:r,top:i,width:l,height:a}),o):y&&f?(o.learning={left:r,top:i,width:l,height:a},o.evaluation={left:r+l+d,top:i,width:u,height:a},o):(y&&(o.learning={width:u}),f&&(o.evaluation={width:u}),o)},Uo=260,ss=(e,t,n,o)=>{let r=Pr,i=rs,d=Er,u=r+Uo+d,l=is(e),a=e-u-r-(o?l+d:0);return{left:u,top:i,width:Math.min(n==="evaluation"?720:860,Math.max(a,0)),height:t-i-r}},ls=e=>{let t=Gl(e.groupHeights),n={...Hl(e.suitesGroupHeight),width:Zl},o=Math.max(Ko.width,e.learningDagBBox.width+vt*2),r={...Ko,width:o,height:Math.max(Ko.height,e.learningDagBBox.height+Ar+vt*2)},i={...Xa,width:Vl},d=Math.max(Kl,t.height,n.height,r.height,i.height),u=t.x,l=a=>{let v={x:u,y:-d/2,width:a.width,height:d};return u+=a.width+Ul,v};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:d}};var ee=I(z());function Mr(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 Ql(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(jo(o))return o;return e.round??n[0]??null}function Nr(e,t){let n=Ql(e,t);return n?[n,...e.subTasksByRound[n.id]??[]]:[]}var Zo=200,ds=80,Yl=40,Xl=70,Lr={width:0,height:0},Jl=e=>({headerOffset:{x:e.x+vt,y:e.y+vt},headerWidth:e.width-vt*2,dagOffset:{x:e.x+vt,y:e.y+Ar+vt}}),ed={background:"rgba(255,255,255,0.92)",border:"1px solid rgba(240,240,240,0.9)",borderRadius:14,padding:"10px 12px"},td={traversed:{stroke:"#22c55e",strokeWidth:1.5},flowing:{stroke:"#6366f1",strokeWidth:2},idle:{stroke:"#d1d5db",strokeWidth:1}},nd={stroke:"#cbd5e1",strokeOpacity:.55,strokeWidth:1,strokeDasharray:"5 4"},od={type:"arrowclosed",color:"#cbd5e1",width:16,height:16};function cs(e){let t=e.context?.interruption;return e.status==="interrupted"&&typeof t=="object"&&t!==null&&t.type==="review_required"}function us(e,t){if(!e)return null;let n=new Date(e).getTime();if(!Number.isFinite(n))return null;let o=Math.floor((Date.now()-n)/6e4);return t?o<1?t("common.time.justNow"):o<60?t("common.time.minutesAgo",{count:o}):o<1440?t("common.time.hoursAgo",{count:Math.floor(o/60)}):t("common.time.daysAgo",{count:Math.floor(o/1440)}):o<1?"just now":o<60?`${o}m ago`:o<1440?`${Math.floor(o/60)}h ago`:`${Math.floor(o/1440)}d ago`}function ps(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 d=o.get(i)??[];d.push(r),o.set(i,d)}return{byId:n,round:t,childrenOf:o}}function rd(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 id(e){return e.some(t=>t.status==="review"||cs(t))?"#f59e0b":e.some(t=>t.status==="in_progress")?"#3b82f6":"#9ca3af"}function ad(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?!_i(i.status):!1});return o.length>0?{kind:"waiting",count:o.length}:{kind:"done",count:n.length}}function gs(e,t){let n=e[0]??null;return!n||!t||t===n.id?null:e.some(o=>o.id===t)?t:null}function fs(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,a)=>new Date(l.createdAt).getTime()-new Date(a.createdAt).getTime()).map((l,a)=>[l.id,a])),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 a of l.dependencies??[])n.has(a)&&a!==l.id&&(r.get(a)?.push(l.id),i.set(l.id,(i.get(l.id)??0)+1));let d=new Set(n),u=[];for(;d.size>0;){let l=null,a=1/0;for(let y of d){if((i.get(y)??0)!==0)continue;let f=o.get(y)??1/0;f<a&&(l=y,a=f)}if(l===null)break;d.delete(l);let v=t.get(l);v&&u.push(v);for(let y of r.get(l)??[])i.set(y,(i.get(y)??0)-1)}for(let l of[...d].sort((a,v)=>(o.get(a)??1/0)-(o.get(v)??1/0))){let a=t.get(l);a&&u.push(a)}return u}function sd(e,t){let n=new Set(t.map(i=>i.id));if(t.some(i=>(i.dependencies??[]).some(d=>d!==i.id&&n.has(d))))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 Vo(e,t,n=null){let o={root:null,tasks:[],edges:[],positions:new Map,bbox:{...Lr}},r=ps(e),i=r.round;if(!i)return o;let d=gs(e,t),u=d??i.id,l=r.childrenOf.get(u)??[],a=x=>{let L=rd(r,x.id);return L.length===0?null:{count:L.length,dotColor:id(L)}},v=(x,L,ce)=>({id:x.id,task:x,seq:L,fold:ce?a(x):null,depBadge:ad(x,r.byId)}),y=[],f=[],c=x=>{let L=fs(x);return f.push(...sd(L,x)),L};c(l).forEach((x,L)=>{y.push(v(x,L+1,!1)),c(r.childrenOf.get(x.id)??[]).forEach((ce,J)=>{y.push(v(ce,J+1,!0))})});let p=d?y.map(x=>x.task):[i,...y.map(x=>x.task)],b=Ro(p).edges.map(x=>({from:x.from,to:x.to,kind:x.kind==="parent"?"structure":"dependency"}));b.push(...f);let h=null;if(!d){h={id:i.id,label:n!==null?`R${n}`:"R",title:i.title,status:i.status,doneCount:e.filter(L=>L.status==="completed").length,totalCount:e.length};let x=new Set(b.filter(L=>L.from===i.id).map(L=>`${L.to}:${L.kind}`));for(let L of l)x.has(`${L.id}:structure`)||(b.push({from:i.id,to:L.id,kind:"structure"}),x.add(`${L.id}:structure`))}let m=p.map(x=>({id:x.id})),w=xo(m,b.map(x=>({from:x.from,to:x.to})),{nodeWidth:Zo,nodeHeight:ds,nodesep:Yl,ranksep:Xl,rankdir:"TB"}),R=1/0,P=1/0;for(let x of w.values())R=Math.min(R,x.x),P=Math.min(P,x.y);let S=new Map;if(Number.isFinite(R)&&Number.isFinite(P))for(let[x,L]of w)S.set(x,{x:L.x-R,y:L.y-P});let K=0,C=0;for(let x of S.values())K=Math.max(K,x.x+Zo),C=Math.max(C,x.y+ds);return{root:h,tasks:y,edges:b,positions:S,bbox:{width:K,height:C}}}function ms(e,t=null){return e.length===0?{width:0,height:0}:Vo(e,t).bbox}var Dr={draggable:!1,selectable:!1,focusable:!1,deletable:!1,connectable:!1};function eo(e,t,n,o){let r=e.rounds,i=Nr(e,t),d=i[0]??null,u=i.filter(cs),l=ps(i),a=i.filter(b=>b.status==="completed").length,v=d?r.findIndex(b=>b.id===d.id):-1,y=d?r.length-v:null,f=r.map((b,h)=>({id:b.id,label:`R${r.length-h}`,title:b.title,status:b.status,createdAt:b.createdAt})),c=i.reduce((b,h)=>b?new Date(h.updatedAt).getTime()>new Date(b.updatedAt).getTime()?h:b:h,null),p=gs(i,n),s=[];if(d&&(s.push({id:d.id,label:`R${y}`}),p)){let b=[],h=l.byId.get(p)??null;for(;h&&h.id!==d.id;)b.unshift(h),h=h.parentId?l.byId.get(h.parentId)??null:null;for(let m of b){let R=fs(l.childrenOf.get(m.parentId??"")??[]).findIndex(P=>P.id===m.id)+1;s.push({id:m.id,label:`${R}.${m.title}`})}}return{tree:i,selectedRound:d,roundTreeById:l.byId,focusId:p,reviewTasks:u,doneCount:a,roundNumber:y,roundOptions:f,roundLatestActivity:us(c?.updatedAt,o),breadcrumb:s}}var Or=({hasRounds:e,reviewCount:t,onReviewClick:n,roundOptions:o,selectedRoundValue:r,onSelectRound:i,roundTitle:d,roundStatus:u,roundDoneCount:l,roundTotalCount:a,roundWaitingCount:v,roundLatestActivity:y,breadcrumb:f,onFocusTask:c,actions:p})=>{let s=_(),b=u?$t[u]:null,h=u?Vn(u,s):null;return(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,marginBottom:6},children:[(0,ee.jsx)("div",{className:"nodrag nopan nowheel","data-testid":"learning-round-select",children:(0,ee.jsx)(at,{size:"small",style:{width:260},placeholder:s("governance.learning.selectRound"),value:r??void 0,allowClear:!0,disabled:o.length===0,onChange:m=>i(m??null),options:o.map(m=>{let w=us(m.createdAt,s);return{value:m.id,label:`${m.label} ${m.title} \xB7 ${Vn(m.status,s)}${w?` \xB7 ${w}`:""}`}})})}),p]}),!e&&(0,ee.jsx)("div",{"data-testid":"learning-empty",style:{fontSize:12,color:"#999",paddingBottom:4},children:s("governance.learning.empty")}),b&&d&&(0,ee.jsxs)("div",{"data-testid":"learning-round-stats",style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap",marginBottom:6},children:[(0,ee.jsx)("span",{style:{width:8,height:8,borderRadius:9999,background:b.color,flexShrink:0}}),(0,ee.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"#262626"},children:h}),(0,ee.jsx)("span",{style:{fontSize:11,color:"#d1d5db"},children:"\xB7"}),(0,ee.jsx)("span",{style:{fontSize:11,color:"#8c8c8c"},children:s("governance.learning.tasksCount",{done:l,total:a})}),v>0&&(0,ee.jsxs)("span",{style:{fontSize:11,fontWeight:600,color:"#b45309",background:"rgba(245,158,11,0.12)",border:"1px solid rgba(245,158,11,0.35)",borderRadius:9999,padding:"1px 8px"},children:["\u23F8 ",s("governance.learning.waiting",{count:v})]}),y&&(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)("span",{style:{fontSize:11,color:"#d1d5db"},children:"\xB7"}),(0,ee.jsx)("span",{style:{fontSize:11,color:"#9ca3af"},children:y})]})]}),f.length>1&&(0,ee.jsxs)("div",{"data-testid":"learning-breadcrumb",style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap",marginBottom:6,fontSize:11,color:"#6b7280"},children:[f.map((m,w)=>(0,ee.jsxs)(It.default.Fragment,{children:[w>0&&(0,ee.jsx)("span",{style:{color:"#d1d5db"},children:"/"}),(0,ee.jsx)("button",{type:"button","data-testid":`learning-crumb-${w}`,onClick:()=>c(w===0?null:m.id),style:{border:"none",background:"transparent",padding:0,cursor:"pointer",fontSize:11,fontWeight:600,color:w===f.length-1?"#4b5563":"#6366f1"},children:m.label})]},m.id)),(0,ee.jsx)("button",{type:"button","data-testid":"learning-crumb-back",onClick:()=>c(f[f.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:s("governance.learning.back")})]}),t>0&&(0,ee.jsx)("button",{type:"button","data-testid":"learning-review-banner","aria-label":s("governance.learning.openReviewTasks",{count:t,s:t>1?"s":""}),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:s("governance.learning.reviewCount",{count:t,s:t>1?"s":""})})]})},ld=({data:e})=>{let t=_(),[n,o]=(0,It.useState)(!1);return(0,ee.jsxs)("div",{style:{...ed,width:e.width},children:[(0,ee.jsx)(Or,{hasRounds:e.hasRounds,reviewCount:e.reviewCount,onReviewClick:e.onReviewClick,roundOptions:e.roundOptions,selectedRoundValue:e.selectedRoundValue,onSelectRound:e.onSelectRound,roundNumber:e.roundNumber,roundTitle:e.roundTitle,roundStatus:e.roundStatus,roundDoneCount:e.roundDoneCount,roundTotalCount:e.roundTotalCount,roundWaitingCount:e.roundWaitingCount,roundLatestActivity:e.roundLatestActivity,breadcrumb:e.breadcrumb,onFocusTask:e.onFocusTask,actions:(0,ee.jsx)(Z,{size:"small",type:"text",icon:(0,ee.jsx)(Dt,{}),"data-testid":"learning-new-task",onClick:()=>o(!0),style:{fontSize:12},children:t("governance.learning.newTask")})}),(0,ee.jsx)(Nn,{open:n,agentId:e.agentId,defaultProjectId:e.projectId??void 0,onClose:()=>o(!1),onCreated:(r,i,d,u)=>{e.onLearningStarted?.(d,r,u),o(!1)}})]})},ys=It.default.memo(ld),dd=({data:e})=>{let t=_(),n=$t[e.task.status],[o,r]=(0,It.useState)(!1);return(0,ee.jsxs)("div",{"data-testid":"learning-dag-task",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{width:Zo,minHeight:46,padding:"8px 10px",borderRadius:10,cursor:"pointer",border:`1.5px solid ${o?"rgba(99,102,241,0.5)":n.color}`,background:o?"rgba(99,102,241,0.08)":"#fff",transition:"background 0.15s ease, border-color 0.15s ease",animation:n.active?"workflow-node-pulse 1.6s ease-in-out infinite":void 0},children:[(0,ee.jsx)(xt,{type:"target",position:st.Top,style:{opacity:0}}),(0,ee.jsx)(xt,{id:"left",type:"target",position:st.Left,style:{opacity:0}}),(0,ee.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:6},children:[(0,ee.jsx)("span",{style:{width:8,height:8,borderRadius:9999,background:n.color,flexShrink:0,marginTop:4}}),(0,ee.jsxs)("span",{style:{fontSize:12,fontWeight:600,color:"#262626",flexShrink:0},children:[e.seq,"."]}),(0,ee.jsx)("span",{"data-testid":"learning-task-title",title:e.task.title,style:{fontSize:12,fontWeight:600,color:"#262626",lineHeight:"17px",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},children:e.task.title})]}),(e.depBadge||e.fold)&&(0,ee.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6,marginTop:5},children:[e.depBadge?(0,ee.jsx)("span",{"data-testid":"learning-dep-badge",style:{fontSize:10,fontWeight:600,flexShrink:0,color:e.depBadge.kind==="done"?"#22c55e":"#f59e0b",background:e.depBadge.kind==="done"?"rgba(34,197,94,0.1)":"rgba(245,158,11,0.12)",borderRadius:9999,padding:"1px 6px"},children:e.depBadge.kind==="done"?t("governance.learning.depBadgeDone",{count:e.depBadge.count}):t("governance.learning.depBadgeWaiting",{count:e.depBadge.count})}):(0,ee.jsx)("span",{}),e.fold&&(0,ee.jsxs)("button",{type:"button","data-testid":"learning-fold",className:"nodrag","aria-label":t("governance.learning.expandNested",{count:e.fold.count,title:e.task.title}),onClick:i=>{i.stopPropagation(),e.onFocusTask?.(e.task.id)},style:{display:"inline-flex",alignItems:"center",gap:4,cursor:"pointer",flexShrink:0,fontSize:10,fontWeight:600,color:"#6b7280",border:"1px solid #e5e7eb",background:"#fafafa",borderRadius:9999,padding:"1px 6px"},children:[(0,ee.jsx)("span",{style:{width:6,height:6,borderRadius:9999,background:e.fold.dotColor,flexShrink:0}}),"\u25B8 ",e.fold.count]})]}),(0,ee.jsx)(xt,{type:"source",position:st.Bottom,style:{opacity:0}}),n.active&&(0,ee.jsx)("style",{children:"@keyframes workflow-node-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.35); } 50% { box-shadow: 0 0 0 6px rgba(59,130,246,0.08); } }"})]})},Qo=It.default.memo(dd),cd=({data:e})=>{let t=_(),n=$t[e.status],[o,r]=(0,It.useState)(!1);return(0,ee.jsxs)("div",{"data-testid":"learning-round-root",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{width:Zo,minHeight:46,padding:"8px 10px",borderRadius:10,cursor:"pointer",border:`1.5px solid ${o?"rgba(99,102,241,0.5)":n.color}`,background:o?"rgba(99,102,241,0.14)":"rgba(99,102,241,0.04)",transition:"background 0.15s ease, border-color 0.15s ease"},children:[(0,ee.jsx)(xt,{type:"target",position:st.Top,style:{opacity:0}}),(0,ee.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:6},children:[(0,ee.jsx)("span",{style:{width:8,height:8,borderRadius:9999,background:n.color,flexShrink:0,marginTop:4}}),(0,ee.jsxs)("span",{"data-testid":"learning-round-root-title",title:e.title,style:{fontSize:12,fontWeight:700,color:"#262626",lineHeight:"17px",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},children:[e.label," \xB7 ",e.title]})]}),(0,ee.jsx)("div",{style:{fontSize:11,color:"#8c8c8c",marginTop:4},children:t("governance.learning.tasksDone",{done:e.doneCount,total:e.totalCount})}),(0,ee.jsx)(xt,{type:"source",position:st.Bottom,style:{opacity:0}})]})},Yo=It.default.memo(cd);function Fr(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:nd,...i.kind==="dependency"?{markerEnd:od}:{}};let d=La(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:d==="flowing",style:td[d]}})}function vs(e){let{learningTasks:t,selectedRoundId:n,onSelectRound:o,onTaskClick:r,onFocusTask:i,focusTaskId:d,onLearningStarted:u,agentId:l,projectId:a,zone:v}=e,y=_();return(0,It.useMemo)(()=>{if(!l)return{nodes:[],edges:[],bbox:{...Lr},breadcrumb:[]};let f=Jl(v),c=eo(t,n,d,y),{tree:p,selectedRound:s,roundTreeById:b,focusId:h,reviewTasks:m,doneCount:w,roundNumber:R,roundOptions:P,roundLatestActivity:S,breadcrumb:K}=c,x=[{id:"learning:header",type:"learningHeader",position:f.headerOffset,data:{width:f.headerWidth,hasRounds:t.rounds.length>0,reviewCount:m.length,onReviewClick:()=>{m[0]&&r(m[0],p)},onLearningStarted:u,agentId:l,projectId:a,roundOptions:P,selectedRoundId:n,selectedRoundValue:s?.id??null,onSelectRound:o,roundNumber:R,roundTitle:s?.title??null,roundStatus:s?.status??null,roundDoneCount:w,roundTotalCount:p.length,roundWaitingCount:m.length,roundLatestActivity:S,breadcrumb:K,onFocusTask:i},...Dr}];if(!s)return{nodes:x,edges:[],bbox:{...Lr},breadcrumb:K};let L=Vo(p,h,R),ce=v.width-vt*2,J=f.dagOffset.x+Math.max(0,(ce-L.bbox.width)/2);if(L.root){let E=L.positions.get(L.root.id)??{x:0,y:0};x.push({id:"learning:round-root",type:"learningRoundRoot",position:{x:J+E.x,y:f.dagOffset.y+E.y},data:{label:L.root.label,title:L.root.title,status:L.root.status,doneCount:L.root.doneCount,totalCount:L.root.totalCount,onTaskClick:()=>r(s,p)},...Dr})}for(let E of L.tasks){let B=L.positions.get(E.id)??{x:0,y:0};x.push({id:`learning:task:${E.id}`,type:"learningTask",position:{x:J+B.x,y:f.dagOffset.y+B.y},data:{task:E.task,seq:E.seq,depBadge:E.depBadge,fold:E.fold,onTaskClick:()=>r(E.task,p),onFocusTask:E.fold?()=>i(E.id):void 0},...Dr})}let ge=Fr(L,{byId:b,nodeId:E=>E===s.id?"learning:round-root":`learning:task:${E}`,prefix:"learning:"});return{nodes:x,edges:ge,bbox:L.bbox,breadcrumb:K}},[t,n,o,r,i,d,u,l,a,v,y])}var xe=I(z()),hs={width:Uo,boxSizing:"border-box",background:"rgba(255, 255, 255, 0.6)",border:"1px solid rgba(240, 240, 240, 0.7)",borderRadius:10,padding:"8px 12px",boxShadow:"0 2px 10px rgba(0,0,0,0.06)",backdropFilter:"blur(8px)",pointerEvents:"auto"},bs={fontSize:10,fontWeight:600,color:"#999"},ud=({expanded:e,score:t,passRate:n,onToggleExpand:o,onUnpin:r})=>{let i=_();return(0,xe.jsxs)("div",{"data-testid":"eval-mini",style:{...hs,position:"relative"},children:[(0,xe.jsxs)("button",{type:"button","data-testid":"eval-mini-expand","aria-label":i("governance.pinnedRail.openEval"),"aria-pressed":e,onClick:()=>o("evaluation"),style:{display:"block",width:"100%",border:"none",background:"transparent",padding:0,cursor:"pointer",textAlign:"left"},children:[(0,xe.jsx)("div",{style:bs,children:i("governance.overlay.evalQuality")}),(0,xe.jsxs)("div",{style:{display:"flex",gap:14,fontSize:12,alignItems:"baseline"},children:[(0,xe.jsxs)("span",{children:[(0,xe.jsx)("strong",{"data-testid":"eval-mini-score",style:{fontSize:18,color:t===null?"#d9d9d9":Ot(t)},children:t!==null?t.toFixed(1):"\u2014"})," ",(0,xe.jsx)("span",{style:{color:"#bbb"},children:i("governance.overlay.stat.score")})]}),(0,xe.jsxs)("span",{children:[(0,xe.jsx)("strong",{"data-testid":"eval-mini-pass",style:{fontSize:18,color:"#262626"},children:n!==null?`${n}%`:"\u2014"})," ",(0,xe.jsx)("span",{style:{color:"#bbb"},children:i("governance.overlay.stat.pass")})]})]})]}),(0,xe.jsx)(Z,{size:"small",type:"text","aria-label":i("governance.zone.unpinAria",{zone:"evaluation"}),icon:(0,xe.jsx)(jn,{}),onClick:()=>r("evaluation"),style:{position:"absolute",top:2,right:2}})]})},pd=({expanded:e,learningTasks:t,selectedRoundId:n,onSelectRound:o,onTaskClick:r,onLearningStarted:i,onLearningRefresh:d,agentId:u,projectId:l,onToggleExpand:a,onUnpin:v})=>{let y=_(),[f,c]=(0,Xo.useState)(!1),p=(0,Xo.useMemo)(()=>eo(t,n,null),[t,n]),s=(b,h,m,w)=>{o(b),c(!1),Promise.resolve(d?.()).catch(()=>{}),i?.(m,b,w)};return(0,xe.jsxs)("div",{"data-testid":"learning-mini",style:hs,children:[(0,xe.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6,marginBottom:6},children:[(0,xe.jsx)("span",{style:bs,children:y("governance.canvas.dot.learning")}),(0,xe.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:2},children:[(0,xe.jsx)(Z,{size:"small",type:"text","aria-label":y("governance.pinnedRail.openLearning"),"aria-pressed":e,icon:(0,xe.jsx)(Tn,{}),onClick:()=>a("learning")}),(0,xe.jsx)(Z,{size:"small",type:"text","data-testid":"learning-mini-new",icon:(0,xe.jsx)(Dt,{}),disabled:!l,"aria-disabled":!l,onClick:()=>c(!0),children:y("governance.pinnedRail.new")}),(0,xe.jsx)(Z,{size:"small",type:"text","aria-label":y("governance.zone.unpinAria",{zone:"learning"}),icon:(0,xe.jsx)(jn,{}),onClick:()=>v("learning")})]})]}),p.roundOptions.length>1&&(0,xe.jsx)(at,{size:"small","data-testid":"learning-mini-round",style:{width:"100%",marginBottom:6},value:p.selectedRound?.id??void 0,allowClear:!0,placeholder:y("governance.learning.selectRound"),onChange:b=>o(b??null),options:p.roundOptions.map(b=>({value:b.id,label:`${b.label} ${b.title}`}))}),p.selectedRound?(0,xe.jsx)("div",{"data-testid":"learning-mini-tree",style:{maxHeight:240,overflow:"auto"},children:(0,xe.jsx)(Io,{tasks:p.tree,loading:t.loading,onTaskClick:r})}):(0,xe.jsx)("div",{style:{fontSize:12,color:"#999",padding:"2px 0"},children:y("governance.learning.empty")}),(0,xe.jsx)(Nn,{open:f,agentId:u,defaultProjectId:l,onClose:()=>c(!1),onCreated:s})]})},ks=e=>{let t=e.pinned.has("evaluation"),n=e.pinned.has("learning");return!t&&!n?null:(0,xe.jsxs)("div",{"data-testid":"canvas-pinned-rail",style:{display:"flex",flexDirection:"column",gap:8,width:Uo},children:[t&&(0,xe.jsx)(ud,{expanded:e.expanded==="evaluation",score:e.score,passRate:e.passRate,onToggleExpand:e.onToggleExpand,onUnpin:e.onUnpin}),n&&(0,xe.jsx)(pd,{expanded:e.expanded==="learning",learningTasks:e.learningTasks,selectedRoundId:e.selectedRoundId,onSelectRound:e.onSelectRound,onTaskClick:e.onTaskClick,onLearningStarted:e.onLearningStarted,onLearningRefresh:e.onLearningRefresh,agentId:e.agentId,projectId:e.projectId,onToggleExpand:e.onToggleExpand,onUnpin:e.onUnpin})]})};var _r=I(Pe());var hn=I(z()),gd={CONFIG:"governance.canvas.zone.config",EVALUATION:"governance.canvas.zone.evaluation",LEARNING:"governance.canvas.zone.learning",COPILOT:"governance.canvas.zone.copilot"},fd=({data:e})=>{let t=_(),[n,o]=_r.default.useState(!1),r=!!e.pinned,i=gd[e.label],d=i?t(i):e.label;return(0,hn.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,hn.jsxs)("div",{style:{position:"absolute",top:-22,left:2,display:"flex",alignItems:"center",gap:6},children:[(0,hn.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:d}),e.pinnable&&e.onPinToggle&&(0,hn.jsx)("button",{type:"button","data-testid":`canvas-zone-pin-${e.label.toLowerCase()}`,"aria-label":r?t("governance.zone.unpinAria",{zone:d}):t("governance.zone.pinAria",{zone:d}),"aria-pressed":r,onMouseDown:u=>u.stopPropagation(),onClick:u=>{u.stopPropagation(),e.onPinToggle?.()},onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,padding:0,border:"none",borderRadius:5,background:r?"rgba(99,102,241,0.12)":"transparent",color:r||n?"#6366f1":"rgba(99,102,241,0.45)",cursor:"pointer",pointerEvents:"auto",lineHeight:1},children:(0,hn.jsx)(bi,{size:11,fill:r?"currentColor":"none"})})]})})},ws=_r.default.memo(fd);var Ye=I(Pe());var Jo=I(Pe()),to="(max-width: 767px)",md=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(to).matches:!1;function xs(){let[e,t]=(0,Jo.useState)(md);return(0,Jo.useEffect)(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia(to),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 an=I(Pe()),Ts=(e,t)=>e?.requestId===t?.requestId&&e?.content===t?.content;function _n({assistantId:e,initialMessageRequest:t,onInitialMessageSubmitted:n}){let o=(0,an.useRef)(new Set),r=t??null,i=(0,an.useRef)(null);i.current===null&&(i.current={assistantId:e,observedRequest:r,request:r});let[d,u]=(0,an.useState)(i.current),l=(0,an.useRef)(d);(0,an.useLayoutEffect)(()=>{let y=l.current;if(y.assistantId===e&&Ts(y.observedRequest,r))return;let f={assistantId:e,observedRequest:r,request:r};l.current=f,u(f)},[e,r?.requestId,r?.content]);let a=d.assistantId===e&&Ts(d.observedRequest,r)?d.request:null;return{attemptedRequestIdsRef:o,effectivePendingRequest:a,handleInitialMessageSubmitted:y=>{let f=l.current;if(f.assistantId===e){if(f.request?.requestId===y){let c={...f,request:null};l.current=c,u(p=>p.assistantId===e&&p.request?.requestId===y?{...p,request:null}:p)}n?.(y)}}}}var ht=I(z()),Rs=()=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(to).matches:!1,er=({assistantId:e,assistantName:t,workspaceId:n,projectId:o,contextType:r,initialMessageRequest:i,onInitialMessageSubmitted:d,onToolCompleted:u,label:l,temporarilyHidden:a=!1,openSignal:v=0,showMobileTrigger:y=!0,restoreFocusRef:f})=>{let c=_(),p=l??c("governance.copilot.label"),[s,b]=(0,Ye.useState)(Rs),[h,m]=(0,Ye.useState)(()=>!Rs()),[w,R]=(0,Ye.useState)(360),P=(0,Ye.useRef)(null),S=(0,Ye.useRef)(null),K=(0,Ye.useRef)(null),C=i??null,{attemptedRequestIdsRef:x,effectivePendingRequest:L,handleInitialMessageSubmitted:ce}=_n({assistantId:e,initialMessageRequest:i,onInitialMessageSubmitted:d});(0,Ye.useEffect)(()=>{P.current&&(P.current.inert=a||!h)},[s,a,h]),(0,Ye.useEffect)(()=>{s&&a&&m(!1)},[s,a]),(0,Ye.useEffect)(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;let E=window.matchMedia(to),B=O=>{b(O.matches),m(!O.matches)};return b(E.matches),typeof E.addEventListener=="function"?(E.addEventListener("change",B),()=>E.removeEventListener("change",B)):(E.addListener(B),()=>E.removeListener(B))},[]),(0,Ye.useEffect)(()=>{v>0&&m(!0)},[v]),(0,Ye.useEffect)(()=>{C&&!s&&m(!0)},[e,C?.requestId,C?.content,s]);let J=(0,Ye.useCallback)(E=>{E.preventDefault(),K.current={startX:E.clientX,startWidth:w}},[w]);(0,Ye.useEffect)(()=>{let E=O=>{if(!K.current)return;let ne=K.current.startX-O.clientX,ie=Math.min(900,Math.max(320,K.current.startWidth+ne));R(ie)},B=()=>{K.current=null};return window.addEventListener("mousemove",E),window.addEventListener("mouseup",B),()=>{window.removeEventListener("mousemove",E),window.removeEventListener("mouseup",B)}},[]);let V=(0,ht.jsxs)("div",{ref:P,"data-testid":"architect-copilot-container","aria-hidden":a||!h||void 0,style:s?{width:"100%",height:"100%",overflow:"hidden",visibility:a||!h?"hidden":"visible",pointerEvents:a||!h?"none":void 0}:{position:"absolute",right:12,top:56,bottom:12,width:w,zIndex:15,borderRadius:12,overflow:"hidden",boxShadow:"0 4px 24px rgba(0,0,0,0.12)",visibility:a||!h?"hidden":"visible",pointerEvents:a||!h?"none":void 0},children:[!s&&(0,ht.jsx)("div",{onMouseDown:J,style:{position:"absolute",left:0,top:0,bottom:0,width:6,cursor:"ew-resize",zIndex:2,background:"transparent"}}),(0,ht.jsx)(An,{defaultWorkspaceId:n??void 0,defaultProjectId:o??void 0,children:(0,ht.jsx)(Pn,{workflowContext:{id:e,name:t??"",type:r},onClose:()=>m(!1),onToolCompleted:u,initialMessageRequest:L,attemptedInitialMessageRequestIdsRef:x,rawInitialMessage:!0,onInitialMessageSubmitted:ce},e)},`${n??"default"}:${o??"default"}`)]}),ge=!h&&!a&&(!s||y)?(0,ht.jsx)("div",{style:s?{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:S,type:"button","aria-label":c("governance.copilot.open"),onClick:()=>m(!0),style:s?{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:p})}):null;return(0,ht.jsxs)(ht.Fragment,{children:[ge,s?(0,ht.jsx)(Zr,{title:p,"aria-label":p,placement:"right",width:"100vw",open:h&&!a,onClose:()=>m(!1),forceRender:!0,destroyOnHidden:!1,styles:{body:{padding:0,overflow:"hidden",height:"100%"}},afterOpenChange:E=>{!E&&!h&&(f?.current??S.current)?.focus()},children:V}):V]})};var bn=I(Pe());var sn=I(z()),no="node:architect-copilot",yd=({data:e})=>{let{assistantId:t,assistantName:n,workspaceId:o,projectId:r,initialMessageRequest:i,onInitialMessageSubmitted:d,onToolCompleted:u,temporarilyHidden:l=!1,openSignal:a=0,width:v,height:y,center:f}=e,c=ko(),p=_(),s=(0,bn.useRef)(null),{attemptedRequestIdsRef:b,effectivePendingRequest:h,handleInitialMessageSubmitted:m}=_n({assistantId:t,initialMessageRequest:i,onInitialMessageSubmitted:d}),w=l,R=()=>c.setCenter(f.x,f.y,{zoom:1,duration:400});return(0,bn.useEffect)(()=>{s.current&&(s.current.inert=w)},[w]),(0,bn.useEffect)(()=>{a>0&&R()},[a]),(0,sn.jsxs)("div",{style:{width:v,height:y,position:"relative",fontFamily:"inherit"},children:[(0,sn.jsx)("div",{ref:s,"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,sn.jsx)(An,{defaultWorkspaceId:o??void 0,defaultProjectId:r??void 0,children:(0,sn.jsx)(Pn,{workflowContext:{id:t,name:n??"",type:"agent"},onToolCompleted:u,initialMessageRequest:h,attemptedInitialMessageRequestIdsRef:b,rawInitialMessage:!0,showHeader:!1,onInitialMessageSubmitted:m},t)},`${o??"default"}:${r??"default"}`)}),w&&(0,sn.jsxs)("button",{type:"button","data-testid":"architect-copilot-node-badge","aria-label":p("governance.copilot.expand"),onClick:R,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,sn.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:"#22c55e",display:"inline-block"}}),p("governance.copilot.label")]})]})},Is=bn.default.memo(yd);var Wr=I(Pe());var ft=I(z()),vd=.4,hd=.45,Cs=(e,t)=>t==="badge"?e>=hd?"overview":"badge":e<vd?"badge":"overview",bd={background:"rgba(255,255,255,0.92)",border:"1px solid rgba(240,240,240,0.9)",borderRadius:14},kd=({data:e})=>{let t=_();return(0,ft.jsxs)("div",{"data-testid":"testing-panel",style:{...bd,width:e.width,minHeight:e.height,boxSizing:"border-box",padding:12,overflow:"auto",display:"flex",flexDirection:"column",gap:12},children:[(0,ft.jsx)(yn,{agentId:e.agentId,runs:e.runs}),e.suites.length>0&&(0,ft.jsxs)("div",{"data-testid":"testing-suites",style:{borderTop:"1px solid #f0f0f0",paddingTop:10,display:"flex",flexDirection:"column",gap:8},children:[(0,ft.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"rgba(0,0,0,0.65)"},children:t("governance.testing.suites")}),(0,ft.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e.suites.map(n=>(0,ft.jsxs)("div",{"data-testid":"testing-suite-chip",onClick:()=>e.onSuiteClick(n),style:{display:"inline-flex",alignItems:"center",gap:5,padding:"4px 10px",borderRadius:9999,background:"#fff",border:`1px solid ${_o("eval")}55`,fontSize:11,color:"#333",cursor:"pointer",whiteSpace:"nowrap"},children:[(0,ft.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:n.label}),n.description&&(0,ft.jsx)("span",{style:{fontSize:10,color:"#999"},children:n.description})]},n.id))})]})]})},Ss=Wr.default.memo(kd),wd=({data:e})=>(0,ft.jsxs)("div",{"data-testid":"testing-badge",style:{width:Xn,height:Jn,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,ft.jsx)("span",{style:{width:10,height:10,borderRadius:9999,background:e.score===null?"#d1d5db":Ot(e.score),flexShrink:0}}),(0,ft.jsx)("span",{style:{fontSize:12,fontWeight:600,color:"#6b7280"},children:e.suiteCount})]}),As=Wr.default.memo(wd);var _t=I(Pe());var kn=I(z()),xd={learningTask:Qo,learningRoundRoot:Yo},zr=({learningTasks:e,selectedRoundId:t,onSelectRound:n,onTaskClick:o,height:r="100%"})=>{let i=_(),[d,u]=(0,_t.useState)(null);(0,_t.useEffect)(()=>{u(null)},[t]);let l=(0,_t.useMemo)(()=>eo(e,t,d,i),[e,t,d,i]),{dagNodes:a,dagEdges:v}=(0,_t.useMemo)(()=>{let m=Vo(l.tree,l.focusId,l.roundNumber),w=l.tree,R=[];m.root&&l.selectedRound&&R.push({id:m.root.id,type:"learningRoundRoot",position:m.positions.get(m.root.id)??{x:0,y:0},data:{label:m.root.label,title:m.root.title,status:m.root.status,doneCount:m.root.doneCount,totalCount:m.root.totalCount,onTaskClick:()=>o(l.selectedRound,w)}});for(let S of m.tasks)R.push({id:S.id,type:"learningTask",position:m.positions.get(S.id)??{x:0,y:0},data:{task:S.task,seq:S.seq,depBadge:S.depBadge,fold:S.fold,onTaskClick:()=>o(S.task,w),onFocusTask:S.fold?()=>u(S.id):void 0}});let P=Fr(m,{byId:l.roundTreeById,nodeId:S=>S});return{dagNodes:R,dagEdges:P}},[l,o]),[y,f,c]=Cn(a),[p,s,b]=Sn(v);(0,_t.useEffect)(()=>{f(a),s(v)},[a,v,f,s]);let h=(0,_t.useCallback)((m,w)=>{w.data.onTaskClick?.()},[]);return(0,kn.jsxs)("div",{style:{width:"100%",height:r,display:"flex",flexDirection:"column",minHeight:0},children:[(0,kn.jsx)("div",{className:"nodrag nowheel nopan",style:{flexShrink:0,padding:"12px 16px 4px"},children:(0,kn.jsx)(Or,{hasRounds:e.rounds.length>0,reviewCount:l.reviewTasks.length,onReviewClick:()=>{l.reviewTasks[0]&&o(l.reviewTasks[0],l.tree)},roundOptions:l.roundOptions,selectedRoundValue:l.selectedRound?.id??null,onSelectRound:n,roundNumber:l.roundNumber,roundTitle:l.selectedRound?.title??null,roundStatus:l.selectedRound?.status??null,roundDoneCount:l.doneCount,roundTotalCount:l.tree.length,roundWaitingCount:l.reviewTasks.length,roundLatestActivity:l.roundLatestActivity,breadcrumb:l.breadcrumb,onFocusTask:u})}),(0,kn.jsx)("div",{style:{flex:1,minHeight:0,position:"relative"},children:(0,kn.jsx)(To,{nodes:y,edges:p,nodeTypes:xd,onNodesChange:c,onEdgesChange:b,onNodeClick:h,fitView:!0,fitViewOptions:{padding:.15,maxZoom:1.2},nodesDraggable:!1,nodesConnectable:!1,miniMap:!1})})]})};var de=I(z()),Td={"zone:copilot":"copilot","zone:learning":"learning","zone:testing":"evaluation"},Rd={copilot:"governance.canvas.zone.copilot",learning:"governance.canvas.zone.learning",evaluation:"governance.canvas.zone.evaluation"},Ps={copilot:"copilot",learning:"learning",testing:"evaluation"},Id=(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}},Cd={rounds:[],round:null,subTasks:[],subTasksByRound:{},loading:!1},tr={padding:"1px 6px",marginRight:6,border:"1px solid #e0e0e0",borderRadius:4,background:"#fafafa",fontSize:11,fontFamily:"monospace",color:"#595959"},Ms="axiom.trainingCanvas.guideDismissed",Sd=()=>{try{return typeof window<"u"&&window.localStorage?.getItem(Ms)==="1"}catch{return!1}},Ad=e=>{try{window.localStorage?.setItem(Ms,e?"1":"0")}catch{}},Br="axiom.trainingCanvas.layout",Pd=["copilot","learning","evaluation"],Es=["copilot","learning","evaluation"],Ed=new Set(Ja),Dd=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)},Ds=()=>{try{if(typeof window>"u")return null;let e=window.localStorage?.getItem(Br);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))Dd(i)&&(o[r]=i);return{version:1,pinned:Array.isArray(n.pinned)?n.pinned.filter(r=>typeof r=="string"):[],origins:o}}catch{return null}},Ls=(e,t)=>{try{let n={version:1,pinned:[...e],origins:t};window.localStorage?.setItem(Br,JSON.stringify(n))}catch{}},Ld=()=>{try{window.localStorage?.removeItem(Br)}catch{}},Ns=({graphDefinition:e,onSelectNode:t,assistantId:n,assistantName:o,workspaceId:r,onRemoveNode:i,initialMessageRequest:d,onInitialMessageSubmitted:u,projectId:l,onProjectChange:a,onLearningStarted:v,onToolActivity:y,learningTasks:f,onLearningRefresh:c,evalTick:p,evalData:s,hudTopOffset:b,copilotTemporarilyHidden:h,onOpenArchitect:m,architectOpenSignal:w=0,architectRestoreFocusRef:R})=>{let[P,S,K]=Cn([]),C=_(),[x,L,ce]=Sn([]),[J,V]=(0,$.useState)(null),ge=xs(),E=ko(),B=(0,$.useRef)(!1),[O,ne]=(0,$.useState)(!Sd()),[ie,D]=(0,$.useState)(null),U=(0,$.useRef)(null),ve=(0,$.useRef)({onInitialMessageSubmitted:u,onToolActivity:y,onLearningStarted:v});ve.current={onInitialMessageSubmitted:u,onToolActivity:y,onLearningStarted:v};let[Y,ke]=(0,$.useState)(()=>{let T=Ds(),A=T?T.pinned:ge?[]:Es,g=new Set;for(let W of A)Pd.includes(W)&&g.add(W);return g}),[Me,F]=(0,$.useState)(()=>{let T={};for(let[A,g]of Object.entries(Ds()?.origins??{}))Ed.has(A)&&(T[A]=g);return T}),[re,Re]=(0,$.useState)(null),j=(0,$.useRef)(Y);j.current=Y;let oe=(0,$.useRef)(Me);oe.current=Me;let G=(0,$.useCallback)(T=>{let A=new Set(j.current);A.has(T)?(A.delete(T),Re(g=>g===T?null:g)):A.add(T),j.current=A,ke(A),Ls([...A],oe.current)},[]),se=(0,$.useRef)(null),[M,he]=(0,$.useState)(()=>({width:typeof window>"u"?1200:window.innerWidth,height:typeof window>"u"?800:window.innerHeight}));(0,$.useEffect)(()=>{let T=se.current;if(!T||typeof ResizeObserver>"u")return;let A=()=>{let W=T.getBoundingClientRect();he({width:W.width,height:W.height})},g=new ResizeObserver(A);return g.observe(T),A(),()=>g.disconnect()},[]);let Ne=(0,$.useMemo)(()=>as(M.width,M.height,Y),[M,Y]),be=_n({assistantId:n??"",initialMessageRequest:d,onInitialMessageSubmitted:T=>ve.current.onInitialMessageSubmitted?.(T)}),Se=(0,$.useCallback)(T=>{D(T),U.current!==null&&window.clearTimeout(U.current),U.current=window.setTimeout(()=>D(null),700)},[]);(0,$.useEffect)(()=>()=>{U.current!==null&&window.clearTimeout(U.current)},[]);let[Fe,rt]=(0,$.useState)(null),[Ze,tt]=(0,$.useState)(null),[Oe,bt]=(0,$.useState)(null),Wt=(0,$.useCallback)(T=>bt(T.id),[]),Ct=(0,$.useCallback)(()=>bt(null),[]),zt=(0,$.useCallback)(T=>tt(T),[]),St=(0,$.useCallback)((T,A,g)=>ve.current.onLearningStarted?.(T,A,g),[]),{suites:$e}=In(s.evalProjectId??""),wn=$e.map(T=>`${T.name}:${T.caseCount??0}`).join("|"),Zt=(0,$.useMemo)(()=>{let T={};for(let A of $e)T[A.name]=A.caseCount??0;return T},[wn]),Bt=(0,$.useMemo)(()=>s.suiteNames.map(T=>({id:`suite:${T}`,type:"eval",label:T,description:C("governance.testing.caseCount",{count:Zt[T]??0})})),[s.suiteNames,Zt,C]),je=(0,$.useMemo)(()=>ra(e,{includeEmptyGroups:!0,t:C}),[e,C]),ln=(0,$.useMemo)(()=>({zone:ws,config:la,agent:sa,copilot:Is,testingPanel:Ss,testingBadge:As,learningHeader:ys,learningTask:Qo,learningRoundRoot:Yo}),[]),kt=Li(T=>T.transform[2]),dn=(0,$.useRef)("overview"),Vt=Cs(kt,dn.current);dn.current=Vt;let nt=f??Cd,q=(0,$.useMemo)(()=>{let T=new Map(je.groups.map(g=>[g.id,g])),A={};for(let g of je.groups)T.get(g.id)&&(A[g.id]=Math.max($o,56+g.items.length*30));return A},[je.groups]),Ce=(0,$.useMemo)(()=>s.suiteNames.length>0?Math.max($o,56+s.suiteNames.length*30):0,[s.suiteNames]),it=(0,$.useMemo)(()=>Nr(nt,Fe),[nt,Fe]),Je=(0,$.useMemo)(()=>ms(it,Ze),[it,Ze]),Ae=(0,$.useMemo)(()=>ls({groupHeights:q,suitesGroupHeight:Ce,learningDagBBox:Je}),[q,Ce,Je]),me=(0,$.useMemo)(()=>Id(Ae,Me),[Ae,Me]),xn=(0,$.useRef)({}),Qt=(0,$.useRef)({}),Yt=(0,$.useRef)(null),[cn,At]=(0,$.useState)({x:0,y:0}),rr=(0,$.useMemo)(()=>{let T=me.learning;return cn.x===0&&cn.y===0?T:{...T,x:T.x+cn.x,y:T.y+cn.y}},[me,cn]),oo=(0,$.useCallback)((T,A)=>{T.startsWith("zone:")&&(Yt.current=T,Qt.current[T]={x:A.x,y:A.y})},[]),Xt=(0,$.useCallback)((T,A)=>{if(!T.startsWith("zone:"))return;let g=Qt.current[T],W={x:A.x,y:A.y};if(Qt.current[T]=W,!g)return;let N=W.x-g.x,ue=W.y-g.y;if(N===0&&ue===0)return;let dt=xn.current[T]??[];T==="zone:learning"&&At(mt=>({x:mt.x+N,y:mt.y+ue})),dt.length>0&&S(mt=>mt.map(Te=>Te.position&&dt.indexOf(Te.id)>=0?{...Te,position:{x:Te.position.x+N,y:Te.position.y+ue}}:Te))},[S]),ro=(0,$.useCallback)((T,A)=>{if(!T.startsWith("zone:"))return;Yt.current=null,delete Qt.current[T],T==="zone:learning"&&At({x:0,y:0});let g=Object.keys(oe.current).length===0?{"zone:config":{x:Ae.config.x,y:Ae.config.y},"zone:copilot":{x:Ae.copilot.x,y:Ae.copilot.y},"zone:learning":{x:Ae.learning.x,y:Ae.learning.y},"zone:testing":{x:Ae.testing.x,y:Ae.testing.y}}:{...oe.current};g[T]={x:A.x,y:A.y},oe.current=g,F(g),Ls([...j.current],g)},[Ae]),ir=(0,$.useCallback)(()=>{Ld();let T=ge?new Set:new Set(Es);j.current=T,ke(T),Re(null),oe.current={},F({})},[ge]),io=vs({learningTasks:nt,selectedRoundId:Fe,zone:rr,onSelectRound:rt,onTaskClick:Wt,onFocusTask:zt,focusTaskId:Ze,onLearningStarted:St,agentId:n??"",projectId:l}),jt=Oe?Mr(nt,Oe):null;(0,$.useEffect)(()=>{Oe&&!jt&&bt(null)},[Oe,jt]),(0,$.useEffect)(()=>{tt(null)},[Fe]),(0,$.useEffect)(()=>{Ze&&!Mr(nt,Ze)&&tt(null)},[Ze,nt]),(0,$.useEffect)(()=>{let T=je.groups,A=new Map(T.map(pe=>[pe.id,pe])),g=[],W=!!n&&!ge,N=me.config,ue=me.testing,dt=Y.has("copilot"),mt=Y.has("learning"),Te=Y.has("evaluation"),so=[me.config,me.testing,me.learning,me.copilot].filter(pe=>pe.id!==me.copilot.id||W&&!dt).filter(pe=>pe.id!==me.learning.id||!!n&&!mt).filter(pe=>pe.id!==me.testing.id||!Te).map(pe=>{let qe=Td[pe.id];return{id:pe.id,type:"zone",position:{x:pe.x,y:pe.y},data:{label:pe.label,width:pe.width,height:pe.height,pinnable:qe!==void 0,pinned:qe!==void 0&&Y.has(qe),onPinToggle:qe!==void 0?()=>G(qe):void 0},draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1,zIndex:-1,style:{pointerEvents:"none"}}});g.push(...so);let Wn={[me.config.id]:[],[me.testing.id]:[],[me.learning.id]:[],[me.copilot.id]:[]},zn=(pe,qe)=>{let Bn=Wn[pe];Bn&&Bn.indexOf(qe)<0&&Bn.push(qe)};zn(me.config.id,je.agent.id),g.push({id:je.agent.id,type:"agent",draggable:!1,data:{node:je.agent,onClick:()=>t?.(je.agent)},position:ts(N)});for(let pe of T){let qe=A.get(pe.id);if(!qe)continue;let Bn=q[pe.id]??Math.max($o,56+pe.items.length*30);zn(me.config.id,pe.id),g.push({id:pe.id,type:"config",draggable:!1,data:{group:qe,onClick:$s=>t?.($s),onRemove:i},position:ns(N,pe.id,Bn)})}Y.has("evaluation")||(Vt==="badge"?s.suiteNames.length>0&&(zn(me.testing.id,"testing:badge"),g.push({id:"testing:badge",type:"testingBadge",draggable:!1,data:{score:s.score,suiteCount:s.suiteNames.length},position:os(ue,Xn,Jn)})):(zn(me.testing.id,"testing:panel"),g.push({id:"testing:panel",type:"testingPanel",draggable:!1,data:{agentId:n??"",runs:s.runs,width:ue.width-vt*2,height:ue.height-vt*2,suites:Bt,onSuiteClick:pe=>t?.(pe)},position:{x:ue.x+Sr.x,y:ue.y+Sr.y}}))),W&&!Y.has("copilot")&&(zn(me.copilot.id,no),g.push({id:no,type:"copilot",draggable:!1,data:{assistantId:n,assistantName:o??"",workspaceId:r,projectId:l,initialMessageRequest:d??null,onInitialMessageSubmitted:pe=>ve.current.onInitialMessageSubmitted?.(pe),onToolCompleted:pe=>ve.current.onToolActivity?.(pe),temporarilyHidden:h??!1,openSignal:w,width:me.copilot.width,height:me.copilot.height,center:{x:me.copilot.x+me.copilot.width/2,y:me.copilot.y+me.copilot.height/2}},position:{x:me.copilot.x,y:me.copilot.y}})),xn.current=Wn;for(let pe of so)Yt.current!==pe.id&&(Qt.current[pe.id]={x:pe.position.x,y:pe.position.y});S(g);let $r=(pe,qe)=>Math.abs(pe)>Math.abs(qe)?pe<0?"left":"right":qe<0?"top":"bottom";L(T.map(pe=>{let qe=Ho[pe.id]??{x:0,y:0};return{id:`e${je.agent.id}-${pe.id}`,source:je.agent.id,target:pe.id,sourceHandle:$r(qe.x,qe.y),targetHandle:$r(-qe.x,-qe.y),style:{stroke:"#c7c7c7",strokeWidth:1.2},type:"bezier"}}))},[je,S,L,i,n,ge,r,l,o,h,w,d?.requestId,d?.content,Vt,Bt,s.score,s.suiteNames,s.runs.map(T=>T.id).join(","),me,q,Y,G]);let ao=Ni();(0,$.useEffect)(()=>{if(!ao||B.current)return;B.current=!0;let T=E.getNodes().filter(A=>!A.id.startsWith("zone:"));E.fitView({padding:.2,nodes:T}).then(A=>{A&&E.getZoom()<es&&E.fitView({padding:.2,nodes:E.getNodes().filter(g=>g.type==="agent"||g.type==="config")})})},[ao,E]),(0,$.useEffect)(()=>{let T=[["1","zone:config","config"],["2","zone:learning","learning"],["3","zone:testing","testing"],["4","zone:copilot","copilot"]],A=g=>{if(!(g.ctrlKey||g.metaKey))return;let W=T.find(([dt])=>g.key===dt);if(!W)return;let N=g.target;if(N&&(N.tagName==="INPUT"||N.tagName==="TEXTAREA"||N.tagName==="SELECT"||N.isContentEditable))return;g.preventDefault();let ue=Ps[W[2]];ue&&Y.has(ue)||(Se(W[2]),E.fitView({padding:.4,duration:400,nodes:[{id:W[1]}]}))};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[E,Se,Y]);let ar=(0,$.useMemo)(()=>{let T=P.some(A=>A.id===J)?J:null;return T===null?P:P.map(A=>{if(A.id===no||A.id.startsWith("zone:")||A.id.startsWith("testing:"))return A;let g=A.id===T||x.some(W=>W.source===T&&W.target===A.id||W.target===T&&W.source===A.id);return{...A,style:{opacity:g?1:.4,transition:"opacity 0.2s ease"}}})},[P,x,J]);return(0,de.jsxs)("div",{ref:se,style:{width:"100%",height:"100%",position:"relative",background:"#fafafa"},children:[(0,de.jsx)("style",{children:`.axiom-training-canvas .react-flow__pane { cursor: default; }
234
+ .axiom-training-canvas .react-flow__pane.dragging { cursor: grabbing; }
235
+ @keyframes zone-dot-pulse { 0% { box-shadow: 0 0 0 0 rgba(99,102,241,0.5); } 100% { box-shadow: 0 0 0 8px rgba(99,102,241,0); } }
236
+ .zone-dot-active { animation: zone-dot-pulse 0.7s ease-out; }
237
+ .zone-help-toggle:hover { color: #6366f1; }`}),(0,de.jsxs)(Mi,{className:"axiom-training-canvas",nodes:[...ar,...Y.has("learning")?[]:io.nodes],edges:[...x,...Y.has("learning")?[]:io.edges],onNodesChange:K,onEdgesChange:ce,onNodeDragStart:(T,A)=>oo(A.id,A.position),onNodeDrag:(T,A)=>Xt(A.id,A.position),onNodeDragStop:(T,A)=>ro(A.id,A.position),onNodeMouseEnter:(T,A)=>{A.id===no||A.id.startsWith("zone:")||A.id.startsWith("testing:")||A.type?.startsWith("learning")||V(A.id)},onNodeMouseLeave:()=>V(null),onPaneClick:()=>t?.(null),onNodeClick:(T,A)=>{if(A.type!=="learningTask"&&A.type!=="learningRoundRoot")return;A.data.onTaskClick?.()},nodeTypes:ln,children:[(0,de.jsx)(Oi,{color:"#eee",gap:20}),(0,de.jsx)(Fi,{})]}),(0,de.jsx)(ct,{open:jt!==null,width:860,title:jt?.task.title??"",onClose:Ct,bodyStyle:{padding:0,overflow:"hidden"},children:jt&&(0,de.jsx)(wr,{task:jt.task,relatedTasks:jt.related,onClose:Ct,onRefresh:c,height:"100%"})}),(ge?["copilot","learning","evaluation"]:["copilot"]).map(T=>{let A=Ne[T];return A?(0,de.jsxs)(ct,{open:!0,width:A.width,left:A.left,top:A.top,height:A.height,escapeEnabled:!1,zIndex:20,title:C(Rd[T]),onClose:()=>G(T),bodyStyle:{padding:0},children:[T==="copilot"&&n&&(0,de.jsx)("div",{style:{width:"100%",height:"100%",userSelect:"text",WebkitUserSelect:"text"},children:(0,de.jsx)(An,{defaultWorkspaceId:r??void 0,defaultProjectId:l??void 0,children:(0,de.jsx)(Pn,{workflowContext:{id:n,name:o??"",type:"agent"},onToolCompleted:g=>ve.current.onToolActivity?.(g),initialMessageRequest:be.effectivePendingRequest,attemptedInitialMessageRequestIdsRef:be.attemptedRequestIdsRef,rawInitialMessage:!0,showHeader:!1,onInitialMessageSubmitted:be.handleInitialMessageSubmitted},n)},`${r??"default"}:${l??"default"}`)}),T==="learning"&&(0,de.jsx)(zr,{learningTasks:nt,selectedRoundId:Fe,onSelectRound:rt,agentId:n??"",projectId:l,onTaskClick:Wt,height:"100%"}),T==="evaluation"&&(0,de.jsx)(yn,{agentId:n??"",runs:s.runs})]},T):null}),!ge&&(()=>{let T=re;if(T!=="learning"&&T!=="evaluation")return null;let A=ss(M.width,M.height,T,Y.has("copilot"));return(0,de.jsx)(ct,{open:!0,width:A.width,left:A.left,top:A.top,height:A.height,escapeEnabled:!1,zIndex:20,title:C(T==="evaluation"?"governance.overlay.evalQuality":"governance.canvas.dock.learningTasks"),onClose:()=>Re(null),bodyStyle:{padding:0},children:T==="evaluation"?(0,de.jsx)(yn,{agentId:n??"",runs:s.runs}):(0,de.jsx)(zr,{learningTasks:nt,selectedRoundId:Fe,onSelectRound:rt,agentId:n??"",projectId:l,onTaskClick:Wt,height:"100%"})})})(),n&&(0,de.jsx)(Go,{assistantId:n,projectId:l,onProjectChange:a,onLearningStarted:v,learningTasks:f,topOffset:b,onLearningRefresh:c,evalTick:p,showLearning:!1,variant:"selector",children:!ge&&(0,de.jsx)(ks,{pinned:Y,expanded:re,onToggleExpand:T=>Re(A=>A===T?null:T),onUnpin:G,score:s.score,passRate:s.passRate,learningTasks:nt,selectedRoundId:Fe,onSelectRound:rt,onTaskClick:Wt,onLearningStarted:St,onLearningRefresh:c,agentId:n,projectId:l})}),n&&ge&&(0,de.jsx)(er,{assistantId:n,assistantName:o??"",workspaceId:r,projectId:l,contextType:"agent",initialMessageRequest:d,onInitialMessageSubmitted:u,onToolCompleted:T=>y?.(T),temporarilyHidden:h,openSignal:w,restoreFocusRef:R,showMobileTrigger:m===void 0}),O&&(0,de.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,de.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[(0,de.jsx)("span",{style:{fontSize:13,fontWeight:600,color:"#262626"},children:C("governance.canvas.quickNav.title")}),(0,de.jsx)("span",{"data-testid":"zone-help-close",onClick:()=>{Ad(!0),ne(!1)},style:{cursor:"pointer",color:"#8c8c8c",fontSize:12,lineHeight:1},children:"\u2715"})]}),(0,de.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,fontSize:12,color:"#595959"},children:[(0,de.jsxs)("div",{children:[(0,de.jsx)("span",{style:tr,children:C("governance.canvas.quickNav.kbdShortcut")})," ",C("governance.canvas.quickNav.focusZone")]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("span",{style:tr,children:C("governance.canvas.quickNav.clickDot")})," ",C("governance.canvas.quickNav.focusZone")]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("span",{style:tr,children:C("governance.canvas.quickNav.dragLabel")})," ",C("governance.canvas.quickNav.moveBlock")]}),(0,de.jsxs)("div",{children:[(0,de.jsx)("span",{style:tr,children:C("governance.canvas.quickNav.pinLabel")})," ",C("governance.canvas.quickNav.pinHelp")]}),(0,de.jsx)("div",{style:{color:"#8c8c8c"},children:C("governance.canvas.quickNav.legend")})]}),(0,de.jsx)("div",{style:{marginTop:8,paddingTop:8,borderTop:"1px solid #f0f0f0",display:"flex",justifyContent:"flex-end",gap:8},children:(0,de.jsx)("button",{type:"button","data-testid":"layout-reset",onClick:ir,style:{cursor:"pointer",border:"1px solid #e0e0e0",borderRadius:4,background:"#fafafa",padding:"2px 10px",fontSize:12,color:"#595959"},children:C("governance.canvas.resetLayout")})})]}),(0,de.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","governance.canvas.dot.config"],["learning","governance.canvas.dot.learning"],["testing","governance.canvas.dot.testing"],["copilot","governance.canvas.dot.copilot"]].map(([T,A])=>{let g=Ps[T],W=g!==void 0&&Y.has(g);return(0,de.jsx)("button",{type:"button","aria-label":C("governance.canvas.fitZoneAria",{zone:C(A)}),"data-testid":`zone-dot-${T}`,className:ie===T?"zone-dot-active":void 0,onClick:()=>{Se(T),E.fitView({padding:.4,duration:400,nodes:[{id:me[T].id}]})},style:{width:10,height:10,borderRadius:"9999px",border:"none",padding:0,cursor:"pointer",background:ie===T||W?"#6366f1":"#d9d9d9"}},T)}),(0,de.jsx)("span",{"aria-hidden":"true",style:{width:1,alignSelf:"stretch",background:"#f0f0f0"}}),(0,de.jsx)("span",{"data-testid":"zone-help-toggle",className:"zone-help-toggle","aria-label":C("governance.canvas.helpToggleAria"),onClick:()=>ne(T=>!T),style:{cursor:"pointer",color:"#8c8c8c",fontSize:12,lineHeight:"10px",userSelect:"none"},children:"\u24D8"})]})]})},Md=e=>{let t=zo(e.assistantId??""),n=(0,$.useRef)(e.evalTick??0);return(0,$.useEffect)(()=>{let o=e.evalTick??0,r=n.current;n.current=o,o>0&&o!==r&&t.refresh().catch(()=>{})},[e.evalTick]),(0,de.jsx)(Ns,{...e,evalData:t})},Nd=({evalData:e,...t})=>(0,de.jsx)(Ns,{...t,evalData:e}),Os=({evalData:e,...t})=>(0,de.jsx)(wo,{children:e?(0,de.jsx)(Nd,{...t,evalData:e}):(0,de.jsx)(Md,{...t})});var nr=I(Pe());var Xe=I(z()),{Text:jr}=Ge;function Od(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 $i(t.workflowYaml)}catch{return null}}var Fs=({graphDefinition:e,assistantId:t,assistantName:n,workspaceId:o,description:r,initialMessageRequest:i,onInitialMessageSubmitted:d,projectId:u,onProjectChange:l,onLearningStarted:a,onToolActivity:v,learningTasks:y,onLearningRefresh:f,evalTick:c,hideTitleBar:p=!1,hudTopOffset:s,copilotTemporarilyHidden:b,onOpenArchitect:h,architectOpenSignal:m=0,architectRestoreFocusRef:w})=>{let R=_(),[P,S]=(0,nr.useState)(!1),K=(0,nr.useMemo)(()=>Od(e),[e]);return(0,Xe.jsxs)("div",{style:{width:"100%",height:"100%",position:"relative",background:"#fafafa"},children:[(0,Xe.jsx)(wo,{children:(0,Xe.jsx)("div",{style:{width:"100%",height:"100%"},children:K?(0,Xe.jsx)(qi,{dsl:K}):(0,Xe.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,Xe.jsx)(jr,{type:"secondary",children:R("governance.workflow.noDsl")})})})}),!p&&(0,Xe.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,Xe.jsx)(fo,{size:16,color:"#6366f1"}),(0,Xe.jsx)(jr,{strong:!0,style:{fontSize:13},children:n}),(0,Xe.jsx)(po,{style:{color:"#6366f1",cursor:"pointer",fontSize:15},onClick:()=>S(!0)})]}),(0,Xe.jsx)(Go,{assistantId:t,projectId:u,onProjectChange:l,onLearningStarted:a,learningTasks:y,topOffset:s,onLearningRefresh:f,evalTick:c}),(0,Xe.jsx)(er,{assistantId:t,assistantName:n,workspaceId:o,projectId:u,contextType:"workflow",label:R("governance.workflow.builderLabel"),initialMessageRequest:i,onInitialMessageSubmitted:d,onToolCompleted:C=>v?.(C),temporarilyHidden:b,openSignal:m,restoreFocusRef:w,showMobileTrigger:h===void 0}),(0,Xe.jsx)(Be,{title:n,open:P,onCancel:()=>S(!1),footer:null,width:"85vw",centered:!0,styles:{body:{maxHeight:"calc(85vh - 120px)",overflow:"auto",padding:"12px 24px 24px"}},children:r?(0,Xe.jsx)(Rn,{content:r}):(0,Xe.jsx)(jr,{type:"secondary",children:R("governance.detail.noDescription")})})]})};var Ue=I(Pe());var H=I(z()),{Text:Gr}=Ge;function _s(e){switch(e.type){case"capability":case"agent":return 560;case"eval":return 860;default:return 400}}function Ws(e){return e.label}var Fd=({label:e,confirmLabel:t,onConfirm:n})=>{let[o,r]=(0,Ue.useState)(!1);return o?(0,H.jsx)(Z,{danger:!0,size:"small",onClick:n,children:t}):(0,H.jsx)(Z,{danger:!0,size:"small",type:"text",onClick:()=>r(!0),children:e})},Ut=({title:e,children:t})=>(0,H.jsxs)("div",{style:{marginBottom:16},children:[(0,H.jsx)("div",{style:{fontSize:12,fontWeight:600,color:"#999",marginBottom:6},children:e}),t]}),_d=({node:e})=>{let{get:t}=et(),n=_(),[o,r]=(0,Ue.useState)(null),[i,d]=(0,Ue.useState)(!0);if((0,Ue.useEffect)(()=>{let a=!1;return d(!0),t("/api/tools").then(v=>{if(a)return;let y=v.data?.records?.find(f=>f.name===e.label)??null;r(y)}).catch(()=>!a&&r(null)).finally(()=>!a&&d(!1)),()=>{a=!0}},[t,e.label]),i)return(0,H.jsx)(wt,{size:"small"});if(!o)return(0,H.jsx)(Gr,{type:"secondary",style:{fontSize:13},children:n("governance.nodeDock.toolUnavailable")});let u=o.schema?.properties??{},l=new Set(o.schema?.required??[]);return(0,H.jsxs)(H.Fragment,{children:[o.description&&(0,H.jsx)(Ut,{title:n("governance.nodeDock.description"),children:o.description}),Object.keys(u).length>0&&(0,H.jsx)(Ut,{title:n("governance.nodeDock.parameters"),children:Object.entries(u).map(([a,v])=>(0,H.jsxs)("div",{style:{display:"flex",gap:8,fontSize:12,padding:"4px 0",alignItems:"baseline"},children:[(0,H.jsxs)("span",{style:{color:"#333",fontWeight:600},children:[a,l.has(a)&&(0,H.jsx)("span",{style:{color:"#ef4444"},children:" *"})]}),(0,H.jsx)("span",{style:{color:"#999"},children:v.type??"any"}),v.description&&(0,H.jsx)("span",{style:{color:"#666",flex:1},children:v.description})]},a))})]})},Wd=({node:e})=>{let{get:t}=et(),n=_(),[o,r]=(0,Ue.useState)(null),[i,d]=(0,Ue.useState)(!0);return(0,Ue.useEffect)(()=>{let u=!1;return d(!0),t(`/api/assistants/${e.label}`).then(l=>!u&&r(l.data??null)).catch(()=>!u&&r(null)).finally(()=>!u&&d(!1)),()=>{u=!0}},[t,e.label]),i?(0,H.jsx)(wt,{size:"small"}):o?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Ut,{title:n("governance.nodeDock.description"),children:o.description||n("governance.nodeDock.noDescription")}),o.graphDefinition?.modelKey&&(0,H.jsx)(Ut,{title:n("governance.nodeDock.model"),children:o.graphDefinition.modelKey})]}):(0,H.jsx)(Gr,{type:"secondary",style:{fontSize:13},children:n("governance.nodeDock.subagentUnavailable")})},zd=({node:e})=>{let{get:t}=et(),n=_(),[o,r]=(0,Ue.useState)(null),[i,d]=(0,Ue.useState)(!0);return(0,Ue.useEffect)(()=>{let u=!1;return d(!0),t(`/api/skills/${e.label}`).then(l=>!u&&r(l.data??null)).catch(()=>!u&&r(null)).finally(()=>!u&&d(!1)),()=>{u=!0}},[t,e.label]),i?(0,H.jsx)(wt,{size:"small"}):o?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Ut,{title:n("governance.nodeDock.description"),children:o.description||n("governance.nodeDock.noDescription")}),o.content&&(0,H.jsx)(Ut,{title:n("governance.nodeDock.content"),children:(0,H.jsx)(Rn,{content:o.content})})]}):(0,H.jsx)(Gr,{type:"secondary",style:{fontSize:13},children:n("governance.nodeDock.skillUnavailable")})},Bd=({node:e,graphDefinition:t,onSaveGraph:n})=>{let{message:o}=Ve.useApp(),{config:r}=co(),i=_(),{middlewareTypes:d}=Ao(r.middlewareTypesEndpoint),u=e.config??{},[l,a]=(0,Ue.useState)({id:u.type??e.id,type:u.type??"unknown",name:u.name??e.label,description:u.description??"",enabled:u.enabled!==!1,config:u.config??{},allowedTools:u.allowedTools}),[v,y]=(0,Ue.useState)(!1),f=(r.availableMiddlewareTypes||d)?.find(p=>p.type===l.type),c=async()=>{if(n){y(!0);try{let p=typeof t=="object"&&t!==null?t:{},s=Array.isArray(p.middleware)?p.middleware:[],b={...u,name:l.name,description:l.description,enabled:l.enabled,config:l.config,...l.allowedTools!==void 0?{allowedTools:l.allowedTools}:{}},h=s.some(m=>m.type===l.type)?s.map(m=>m.type===l.type?b:m):[...s,b];await n({...p,middleware:h}),o.success(i("governance.nodeDock.capabilitySaved"))}catch{o.error(i("governance.nodeDock.capabilitySaveFailed"))}finally{y(!1)}}};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Po,{middleware:l,middlewareType:f,onToggle:()=>a(p=>({...p,enabled:!p.enabled})),onConfigChange:p=>a(s=>({...s,config:{...s.config,...p}})),onAllowedToolsChange:p=>a(s=>({...s,allowedTools:p}))}),(0,H.jsx)("div",{style:{marginTop:16,textAlign:"right"},children:(0,H.jsx)(Z,{type:"primary",size:"small",loading:v,onClick:()=>void c(),children:i("common.save")})})]})},jd=({graphDefinition:e,onSaveGraph:t})=>{let{message:n}=Ve.useApp(),o=_(),r=typeof e=="object"&&e!==null?e:{},[i,d]=(0,Ue.useState)(r.description??""),[u,l]=(0,Ue.useState)(r.prompt??""),[a,v]=(0,Ue.useState)(r.modelKey??""),[y,f]=(0,Ue.useState)(!1),c=async()=>{if(t){f(!0);try{await t({...r,description:i,prompt:u,modelKey:a}),n.success(o("governance.nodeDock.agentSaved"))}catch{n.error(o("governance.detail.saveFailed"))}finally{f(!1)}}};return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Ut,{title:o("governance.nodeDock.description"),children:(0,H.jsx)(_e.TextArea,{"aria-label":o("governance.nodeDock.description"),rows:2,value:i,onChange:p=>d(p.target.value)})}),(0,H.jsx)(Ut,{title:o("governance.nodeDock.model"),children:(0,H.jsx)(_e,{"aria-label":o("governance.nodeDock.model"),size:"small",value:a,onChange:p=>v(p.target.value)})}),(0,H.jsx)(Ut,{title:o("governance.nodeDock.prompt"),children:(0,H.jsx)(_e.TextArea,{"aria-label":o("governance.nodeDock.prompt"),rows:8,value:u,onChange:p=>l(p.target.value)})}),(0,H.jsx)("div",{style:{textAlign:"right"},children:(0,H.jsx)(Z,{type:"primary",size:"small",loading:y,onClick:()=>void c(),children:o("common.save")})})]})},zs=({node:e,graphDefinition:t,assistantId:n,onRemoveNode:o,onSaveGraph:r})=>{let i=_(),d=e.type==="tool"||e.type==="subagent"||e.type==="skill";return(0,H.jsxs)("div",{children:[(0,H.jsx)("div",{style:{marginBottom:12},children:(0,H.jsx)(He,{bordered:!1,style:{margin:0,fontSize:10},children:i(Oo[e.type])})}),e.type==="tool"&&(0,H.jsx)(_d,{node:e},e.id),e.type==="subagent"&&(0,H.jsx)(Wd,{node:e},e.id),e.type==="skill"&&(0,H.jsx)(zd,{node:e},e.id),e.type==="capability"&&(0,H.jsx)(Bd,{node:e,graphDefinition:t,onSaveGraph:r},e.id),e.type==="agent"&&(0,H.jsx)(jd,{graphDefinition:t,onSaveGraph:r},e.id),e.type==="eval"&&n&&(0,H.jsx)(Do,{assistantId:n},e.id),d&&o&&(0,H.jsx)("div",{style:{marginTop:16,borderTop:"1px solid #f0f0f0",paddingTop:12},children:(0,H.jsx)(Fd,{label:i("governance.nodeDock.removeFromAgent"),confirmLabel:i("governance.nodeDock.confirmRemove"),onConfirm:()=>o(e)})})]})};function Bs(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 Le=I(Pe());var Gd=new Set(["create_agent","update_agent","delete_agent","create_workflow","update_workflow"]),Kd=new Set(["manage_task"]),qd=new Set(["manage_eval","run_eval"]),$d=new Set(["create_agent","delete_agent"]);function js(e){return $d.has(e)}function Gs(e){let t=[];return Gd.has(e)&&t.push("config"),Kd.has(e)&&t.push("tasks"),qd.has(e)&&t.push("eval"),t}var Hd=300,Kr=()=>({rounds:[],round:null,subTasks:[],subTasksByRound:{},loading:!0}),qr=()=>({config:{error:null,updatedAt:null},tasks:{error:null,updatedAt:null,partial:!1}});function Ud(e,t,n){let o=new Set(n),r=new Map(e.map(u=>[u.id,u])),i=u=>{let l=u.parentId,a=new Set;for(;l&&!a.has(l);){if(o.has(l))return!0;a.add(l),l=r.get(l)?.parentId}return!1},d=new Set(t.map(u=>u.id));return[...t,...e.filter(u=>!d.has(u.id)&&i(u))]}function Ks(e){let{agentId:t,projectId:n,onAssistantUpdated:o,onAgentListInvalidated:r}=e,{get:i}=et(),d=`${t}\0${n??""}`,[u,l]=(0,Le.useState)(()=>({scope:d,value:Kr()})),[a,v]=(0,Le.useState)(()=>({scope:d,value:0})),[y,f]=(0,Le.useState)(()=>({scope:d,value:qr()})),c=(0,Le.useRef)({}),p=(0,Le.useRef)(0),s=(0,Le.useRef)(null),b=(0,Le.useRef)(null),h=(0,Le.useRef)(0),m=(0,Le.useRef)({}),w=(0,Le.useRef)(!1),R=(0,Le.useRef)(d),P=(0,Le.useRef)({onAssistantUpdated:o,onAgentListInvalidated:r});(0,Le.useLayoutEffect)(()=>{P.current={onAssistantUpdated:o,onAgentListInvalidated:r}},[o,r]),(0,Le.useLayoutEffect)(()=>{if(R.current!==d){R.current=d,p.current+=1,h.current+=1,m.current={},s.current=null,b.current=null,w.current=!1;for(let E of Object.values(c.current))E&&clearTimeout(E);c.current={},l({scope:d,value:Kr()}),f({scope:d,value:qr()}),v({scope:d,value:0})}},[d]);let S=u.scope===d?u.value:Kr(),K=y.scope===d?y.value:qr(),C=a.scope===d?a.value:0,x=E=>{f(B=>B.scope===d?{scope:d,value:E(B.value)}:B)},L=(0,Le.useCallback)(async()=>{let E=++h.current,B=d;try{let O=await i(`/api/assistants/${t}`);if(E!==h.current||B!==R.current)return;O.success&&O.data?(w.current=!1,P.current.onAssistantUpdated?.(O.data),x(ne=>({...ne,config:{error:null,updatedAt:new Date}}))):(w.current=!1,x(ne=>({...ne,config:{...ne.config,error:new Error("Configuration refresh returned no agent")}})))}catch(O){if(E!==h.current||B!==R.current)return;if(O instanceof Yr&&O.statusCode===404){w.current||P.current.onAgentListInvalidated?.(),w.current=!1,x(ie=>({...ie,config:{...ie.config,error:O}}));return}w.current=!1,console.warn("[useEntityRefresher] config refresh failed",O);let ne=O instanceof Error?O:new Error(String(O));x(ie=>({...ie,config:{...ie.config,error:ne}}))}},[i,t,d]),ce=(0,Le.useCallback)(()=>{let E=s.current;if(E?.scope===d)return E.promise;let B=++p.current,O=d,ne=(async()=>{try{let D=((await i(Mn(t,n))).data??[]).filter(Ln),U={},ve=!1;if(await Promise.all(D.map(async ke=>{let Me=await Ra(i,ke.id,{projectId:n});ve||=Me.partial,U[ke.id]=Me.partial?Ud(m.current[ke.id]??[],Me.tasks,Me.incompleteParentIds??[]):Me.tasks})),B!==p.current||O!==R.current)return;m.current=Object.fromEntries(D.map(ke=>[ke.id,U[ke.id]??[]]));let Y=D[0]??null;l({scope:d,value:{rounds:D,round:Y,subTasks:Y?U[Y.id]??[]:[],subTasksByRound:U,loading:!1}}),x(ke=>({...ke,tasks:{error:null,updatedAt:new Date,partial:ve}}))}catch(ie){if(console.warn("[useEntityRefresher] task refresh failed",ie),B!==p.current||O!==R.current)return;l(U=>U.scope===d?{scope:d,value:{...U.value,loading:!1}}:U);let D=ie instanceof Error?ie:new Error(String(ie));x(U=>({...U,tasks:{...U.tasks,error:D}}))}})().finally(()=>{s.current?.promise===ne&&(s.current=null,b.current===O&&R.current===O&&(b.current=null,J.current.refreshLearningTasks()))});return s.current={scope:d,promise:ne},ne},[i,t,n,d]),J=(0,Le.useRef)({refreshAgent:L,refreshLearningTasks:ce});(0,Le.useEffect)(()=>{J.current={refreshAgent:L,refreshLearningTasks:ce}});let V=(0,Le.useCallback)((E,B)=>{let O=c.current;O[E]&&clearTimeout(O[E]),O[E]=setTimeout(B,Hd)},[]),ge=(0,Le.useCallback)(E=>{for(let B of Gs(E))B==="config"&&V(B,()=>{js(E)&&(w.current=!0,P.current.onAgentListInvalidated?.()),J.current.refreshAgent()}),B==="tasks"&&V(B,()=>{let O=R.current;s.current?.scope===O?b.current=O:J.current.refreshLearningTasks()}),B==="eval"&&V(B,()=>{let O=R.current;v(ne=>ne.scope===O?{scope:O,value:ne.value+1}:ne)})},[V]);return(0,Le.useEffect)(()=>{ce()},[ce]),(0,Le.useEffect)(()=>()=>{for(let E of Object.values(c.current))E&&clearTimeout(E)},[]),{handleToolCompleted:ge,learningTasks:S,refreshLearningTasks:ce,refreshAgent:L,freshness:K,evalTick:C}}var X=I(z()),{Text:qs}=Ge,or={color:"#4f46e5",background:"#eef2ff"},Zd=`
238
+ @media (max-width: 767px) {
239
+ .agent-detail__identity-pill { max-width: calc(100% - 24px) !important; right: 12px; }
240
+ .agent-detail__actions-pill { top: 52px !important; left: 12px; right: auto !important; }
241
+ }
242
+ `,Vd=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,Qd=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:{}},ny=({assistant:e,allAssistants:t,onBack:n,onDeleted:o,initialTab:r="graph",onSave:i,onAssistantUpdated:d,onAgentListInvalidated:u,initialMessage:l=null,initialMessageCustomRunConfig:a=null,initialProjectId:v=null})=>{let{message:y}=Ve.useApp(),f=_(),[c,p]=(0,Ee.useState)(()=>Vd(r)),[s,b]=(0,Ee.useState)(!1),[h,m]=(0,Ee.useState)(!1),[w,R]=(0,Ee.useState)(null),[P,S]=(0,Ee.useState)(0),K=(0,Ee.useRef)(null),C=(0,Ee.useRef)(()=>{}),x=(0,Ee.useRef)(0),L=(0,Ee.useRef)(null),ce=(0,Ee.useRef)(null),J=(0,Ee.useRef)(null),V=(0,Ee.useRef)(null),ge=(0,Ee.useRef)(null),E=(0,Ee.useRef)(null),B=(0,Ee.useRef)(null),[O,ne]=(0,Ee.useState)(()=>l?{requestId:`initial:${e.id}`,content:l,...a?{customRunConfig:a}:{}}:null),{workspaceId:ie,trainingProjects:D,loading:U}=Lt(),ve=Bs(e.graphDefinition),[Y,ke]=(0,Ee.useState)(v??ve??D[0]?.id??null),Me=q=>{ke(q)},F=(q,Ce,it)=>{let Je=D.find(Ae=>Ae.id===Y)??null;ne({requestId:Ce,content:Ta({goal:q,roundTaskId:Ce,targetAgentId:e.id,targetMode:xa(e),files:it,projectId:Y??void 0,workspaceId:Je?.workspaceId??ie??void 0}),customRunConfig:{execution:{taskId:Ce}}})},re=q=>{ne(Ce=>Ce?.requestId===q?null:Ce)};(0,Ee.useEffect)(()=>{!Y&&D.length>0&&ke(D[0].id)},[Y,D]);let[Re,j]=(0,Ee.useState)(!1),[oe,G]=(0,Ee.useState)(!1),[se,M]=(0,Ee.useState)(!1),[he,Ne]=(0,Ee.useState)(e.graphDefinition),{handleToolCompleted:be,learningTasks:Se,refreshLearningTasks:Fe,evalTick:rt}=Ks({agentId:e.id,projectId:Y,onAssistantUpdated:d,onAgentListInvalidated:u});(0,Ee.useEffect)(()=>{Ne(e.graphDefinition)},[e]);let Ze=typeof e.graphDefinition=="object"?e.graphDefinition:{},tt=String(Ze.type??"react"),Oe=En(tt),bt=tt==="workflow"?fo:Gn,Wt=mr(e),Ct=vr(e),zt=Zi(Ct),St=q=>{q.kind==="back"?n():q.kind==="close"?p(null):q.kind==="architect"?(p(null),S(Ce=>Ce+1)):p(q.view)},$e=q=>{if(!K.current&&!(q.kind==="dock"&&q.view.kind!=="node"&&c?.kind===q.view.kind&&q.view.kind!=="eval")){if(c?.kind==="configuration"&&s){K.current=q,R(q);return}St(q)}};C.current=$e;let wn=q=>{let Ce=q??(document.activeElement instanceof HTMLElement?document.activeElement:void 0);return Ce?{current:Ce}:void 0},Zt=(0,Ee.useCallback)(q=>{let Ce=++x.current;C.current({kind:"dock",view:{kind:"eval",initial:{page:"suites"},navigationKey:Ce,restoreFocusRef:wn(q)}})},[]),Bt=()=>{K.current=null,R(null),requestAnimationFrame(()=>B.current?.())},je=()=>{let q=K.current;q&&(K.current=null,R(null),b(!1),St(q))},ln=()=>{G(!0)},kt=async()=>{j(!0);try{await o(e.id),G(!1)}finally{j(!1)}},dn=q=>(Ne(q),i?.(e,q)),Vt=i?async(q,Ce)=>{await i(q,Ce),Ne({...Qd(q.graphDefinition),...Ce})}:void 0,nt=q=>{let Ce=typeof he=="object"&&he!==null?he:{},it={...Ce};if(q.type==="tool"&&q.id.startsWith("tool:"))it.tools=(Ce.tools??[]).filter(Je=>Je!==q.id.slice(5));else if(q.type==="subagent"&&q.id.startsWith("sub:"))it.subAgents=(Ce.subAgents??[]).filter(Je=>Je!==q.id.slice(4));else if(q.type==="skill"&&q.id.startsWith("skill:")){let Je=q.id.slice(6);it.skills=(Ce.skills??[]).filter(Ae=>Ae!==Je),Array.isArray(Ce.middleware)&&(it.middleware=Ce.middleware.map(Ae=>{if(Ae.type!=="skill")return Ae;let me=typeof Ae.config=="object"&&Ae.config!==null?Ae.config:{};return q.id===hr?{...Ae,config:{...me,readAll:!1}}:!Array.isArray(me.skills)||!me.skills.includes(Je)?Ae:{...Ae,config:{...me,skills:me.skills.filter(xn=>xn!==Je)}}}))}else if(q.type==="capability"&&q.id.startsWith("cap:")){let Je=q.id.slice(4);it.middleware=(Ce.middleware??[]).filter(Ae=>Ae.type!==Je)}else return;Ne(it),i?.(e,it).catch(()=>y.error(f("governance.detail.removeNodeSaveFailed")))};return(0,X.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",background:"#fff"},children:[(0,X.jsx)("style",{"data-agent-detail-responsive":!0,children:Zd}),(0,X.jsxs)("div",{style:{flex:1,minHeight:0,position:"relative"},children:[(0,X.jsxs)("div",{"data-testid":"agent-header-pill",className:"agent-detail__identity-pill",style:{position:"absolute",top:12,left:12,zIndex:12,display:"flex",alignItems:"center",gap:8,height:32,padding:"0 10px 0 4px",background:"rgba(255,255,255,0.95)",borderRadius:10,boxShadow:"0 2px 12px rgba(0,0,0,0.08)",border:"1px solid #f0f0f0",maxWidth:"calc(100% - 176px)",minWidth:0},children:[(0,X.jsx)(Z,{type:"text",size:"small",icon:(0,X.jsx)(ei,{}),onClick:()=>$e({kind:"back"}),"aria-label":f("common.back")}),(0,X.jsx)(bt,{size:15,color:Kn(Oe.color)}),(0,X.jsx)(qs,{strong:!0,style:{fontSize:13,maxWidth:220,minWidth:0,flex:"1 1 auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),(0,X.jsx)("span",{"data-testid":"agent-status-dot",title:Ct,style:{width:8,height:8,borderRadius:"50%",background:Kn(zt),flexShrink:0}}),(0,X.jsx)(Z,{type:"text",size:"small","aria-label":f("governance.detail.viewDescription"),icon:(0,X.jsx)(po,{}),style:{color:"#6366f1"},onClick:()=>M(!0)})]}),(0,X.jsxs)("div",{"data-testid":"agent-actions-pill",className:"agent-detail__actions-pill",style:{position:"absolute",top:12,right:12,zIndex:12,display:"flex",alignItems:"center",gap:2,height:32,padding:"0 6px",background:"rgba(255,255,255,0.95)",borderRadius:10,boxShadow:"0 2px 12px rgba(0,0,0,0.08)",border:"1px solid #f0f0f0"},children:[(0,X.jsx)(Jt,{title:f("governance.detail.testInPlayground"),children:(0,X.jsx)(Z,{ref:L,type:"text",size:"small",icon:(0,X.jsx)(ki,{size:14}),onClick:()=>$e({kind:"dock",view:{kind:"playground"}}),"aria-label":f("governance.detail.testInPlayground"),"aria-pressed":c?.kind==="playground",style:c?.kind==="playground"?or:void 0})}),(0,X.jsx)(Jt,{title:f("governance.detail.evalSuite"),children:(0,X.jsx)(Z,{ref:ce,type:"text",size:"small",icon:(0,X.jsx)(go,{size:14}),onClick:()=>Zt(ce.current??void 0),"aria-label":f("governance.detail.evalSuite"),"aria-pressed":c?.kind==="eval",style:c?.kind==="eval"?or:void 0})}),(0,X.jsx)(Jt,{title:f("governance.detail.webApps"),children:(0,X.jsx)(Z,{ref:J,type:"text",size:"small",icon:(0,X.jsx)(vi,{size:14}),onClick:()=>$e({kind:"dock",view:{kind:"web-apps"}}),"aria-label":f("governance.detail.webApps"),"aria-pressed":c?.kind==="web-apps",style:c?.kind==="web-apps"?or:void 0})}),(0,X.jsx)(Jt,{title:f("governance.detail.configuration"),children:(0,X.jsx)(Z,{ref:V,type:"text",size:"small",icon:(0,X.jsx)(wi,{size:14}),onClick:()=>$e({kind:"dock",view:{kind:"configuration"}}),"aria-label":f("governance.detail.configuration"),"aria-pressed":c?.kind==="configuration",style:c?.kind==="configuration"?or:void 0})}),(0,X.jsx)(Jt,{title:f("governance.deleteAgent"),children:(0,X.jsx)(Z,{type:"text",size:"small",danger:!0,icon:(0,X.jsx)(uo,{}),loading:Re,onClick:ln,"aria-label":f("governance.deleteAgent")})})]}),!U&&D.length===0&&(0,X.jsx)(Pt,{type:"warning",showIcon:!0,style:{position:"absolute",top:100,left:16,right:16,zIndex:40,margin:0},message:f("governance.learning.noProject"),description:f("governance.learning.noProjectDescription")}),tt==="workflow"?(0,X.jsx)(Fs,{graphDefinition:he,assistantId:e.id,assistantName:e.name,workspaceId:ie,description:e.description,hideTitleBar:!0,hudTopOffset:56,initialMessageRequest:O,onInitialMessageSubmitted:re,projectId:Y,onProjectChange:Me,onLearningStarted:F,onToolActivity:be,learningTasks:Se,onLearningRefresh:Fe,evalTick:rt,architectOpenSignal:P,architectRestoreFocusRef:E,copilotTemporarilyHidden:c!==null}):(0,X.jsx)(Os,{graphDefinition:he,assistantId:e.id,assistantName:e.name,workspaceId:ie,hudTopOffset:56,onSelectNode:q=>{q?$e({kind:"dock",view:{kind:"node",node:q}}):c?.kind==="node"&&$e({kind:"close"})},onRemoveNode:nt,initialMessageRequest:O,onInitialMessageSubmitted:re,projectId:Y,onProjectChange:Me,onLearningStarted:F,onToolActivity:be,learningTasks:Se,onLearningRefresh:Fe,evalTick:rt,architectOpenSignal:P,architectRestoreFocusRef:E,copilotTemporarilyHidden:c!==null}),c?.kind==="node"&&(0,X.jsx)(ct,{open:!0,width:_s(c.node),title:Ws(c.node),onClose:()=>p(null),children:(0,X.jsx)(zs,{node:c.node,graphDefinition:he,assistantId:e.id,onRemoveNode:q=>{nt(q),p(null)},onSaveGraph:dn})}),c?.kind==="playground"&&(0,X.jsx)(ct,{open:!0,width:720,title:f("governance.detail.playground"),onClose:()=>$e({kind:"close"}),restoreFocusRef:L,children:(0,X.jsx)(Gi,{assistant_id:e.id})}),c?.kind==="eval"&&(0,X.jsx)(ct,{open:!0,width:860,title:c.initial?.page==="run"?f("governance.detail.runResults"):f("governance.detail.evalSuite"),onClose:()=>$e({kind:"close"}),restoreFocusRef:c.restoreFocusRef??ce,children:(0,X.jsx)(Do,{assistantId:e.id,initial:c.initial,navigationKey:c.navigationKey})},c.navigationKey),c?.kind==="web-apps"&&(0,X.jsx)(ct,{open:!0,width:960,title:f("governance.detail.webApps"),onClose:()=>$e({kind:"close"}),restoreFocusRef:J,bodyStyle:{padding:0,overflow:"hidden"},children:(0,X.jsx)(oa,{assistant:e})}),c?.kind==="configuration"&&(0,X.jsx)(ct,{open:!0,width:"80%",mobileWidth:"calc(100% - 24px)",title:f("governance.detail.configuration"),onClose:()=>$e({kind:"close"}),bodyStyle:{padding:0,overflow:"hidden"},restoreFocusRef:ge,focusControlRef:B,escapeEnabled:!h&&!se&&!oe&&w===null,children:(0,X.jsx)(ea,{assistant:{...e,graphDefinition:he},allAssistants:t,visible:!0,onClose:()=>$e({kind:"close"}),onSave:Vt,onDirtyChange:b,onOverlayOpenChange:m,embedded:!0})})]}),(0,X.jsx)(Be,{title:f("governance.detail.discardTitle"),open:w!==null,onCancel:Bt,onOk:je,okText:f("governance.detail.discard"),okButtonProps:{danger:!0},cancelText:f("governance.detail.continueEditing"),children:(0,X.jsx)("p",{children:f("governance.detail.discardBody")})}),(0,X.jsxs)(Be,{title:e.name,open:se,onCancel:()=>M(!1),footer:null,width:640,centered:!0,children:[(0,X.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:12},children:[(0,X.jsx)(He,{color:Oe.color,style:{margin:0},children:Oe.label}),Wt.map(q=>(0,X.jsx)(He,{color:"magenta",style:{margin:0},children:q},q)),(0,X.jsx)(He,{style:{margin:0},children:yr(e)}),(0,X.jsx)(He,{color:zt,style:{margin:0},children:Ct})]}),e.description?(0,X.jsx)(Rn,{content:e.description}):(0,X.jsx)(qs,{type:"secondary",children:f("governance.detail.noDescription")})]}),(0,X.jsx)(Be,{title:f("governance.deleteAgent"),open:oe,onCancel:()=>G(!1),onOk:kt,okText:f("common.delete"),okButtonProps:{danger:!0,loading:Re},cancelText:f("common.cancel"),children:(0,X.jsx)("p",{children:f("governance.detail.deleteConfirm",{name:e.name})})})]})};export{En as a,Kn as b,Yd as c,Xd as d,Jd as e,ba as f,$u as g,ka as h,wa as i,Ta as j,ny as k};