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