From a4b7fdce9e8ef1c8cd170e68dcc57bd8eb40928e Mon Sep 17 00:00:00 2001
From: Sycun <165354365+Sycun@users.noreply.github.com>
Date: Thu, 19 Nov 2026 10:55:26 +0800
Subject: [PATCH] fix(frontend): improve vulnerability severity badge contrast
---
web/frontend/src/components/ui.jsx | 6 +++++-
web/frontend/src/styles/app.css | 8 ++++++++
...nagement-CsADEV29.js => agents-management-8Q9eU0Fw.js} | 2 +-
.../assets/{api-docs-BLHNGrWi.js => api-docs-Cq--SCZD.js} | 2 +-
...sset-library-KPChFll7.js => asset-library-BAx0Ul3g.js} | 2 +-
...et-overview-DNWfmRJG.js => asset-overview-BmQ_1q6a.js} | 2 +-
.../{c2-events-DTCXaUlN.js => c2-events-CoH3yyOa.js} | 2 +-
...{c2-listeners-D_Bx-B-I.js => c2-listeners-Czsz18uH.js} | 2 +-
.../{c2-payloads-C_C_YA7N.js => c2-payloads-DvqcThjq.js} | 2 +-
.../{c2-profiles-C1JrB05z.js => c2-profiles-CoAwMcjF.js} | 2 +-
.../{c2-sessions-C4zx-oqJ.js => c2-sessions-CzZrurOn.js} | 2 +-
.../{c2-shared-DQceLFCe.js => c2-shared-B5kg9aBy.js} | 2 +-
.../{c2-shared-BkIzs15k.js => c2-shared-BBQQ9OoL.js} | 2 +-
.../assets/{c2-tasks-t5h6GDhv.js => c2-tasks-gSo_kNWy.js} | 2 +-
.../app/assets/{chat-QPrSpZt5.js => chat-4zuVcYax.js} | 2 +-
.../{chat-files-CTTAptxF.js => chat-files-BYjs9VE-.js} | 2 +-
.../{dashboard-D1HqCY0Z.js => dashboard-Bc2usnZH.js} | 2 +-
...sessments-ClJUMWIn.js => deep-assessments-cnrXHaFd.js} | 2 +-
.../app/assets/{hitl-CKnRMfmB.js => hitl-DCNZaIEz.js} | 2 +-
.../app/assets/{index-B_jDLAQv.css => index-DPO43fe5.css} | 2 +-
.../app/assets/{index-BoFwOeaz.js => index-smFoxEJu.js} | 4 ++--
...{info-collect-C3MqtyT0.js => info-collect-3BNPr4lS.js} | 2 +-
...ement-COpgsLN2.js => knowledge-management-CBCh6sv1.js} | 2 +-
...s-DkihRY3X.js => knowledge-retrieval-logs-D4Ccl_5u.js} | 2 +-
...-management-ClIRzGxS.js => mcp-management-CpurAL-_.js} | 2 +-
.../{mcp-monitor-BENVJarN.js => mcp-monitor-CcafUVpf.js} | 2 +-
...latform-rbac-CCzPRjms.js => platform-rbac-BG70WbmN.js} | 2 +-
.../assets/{projects-C64S62xe.js => projects-DwN7tLJD.js} | 2 +-
...anagement-BVS050uQ.js => roles-management-BjLBenwe.js} | 2 +-
.../assets/{settings-BEsIqHkk.js => settings-BOqxpbJE.js} | 2 +-
...nagement-h0lK3HYq.js => skills-management-CZ3ZF0wd.js} | 2 +-
...lls-monitor-BiZ6uLnX.js => skills-monitor-L6Gdi19j.js} | 2 +-
.../app/assets/{tasks-CqEzUceO.js => tasks-VQP5hHjc.js} | 2 +-
.../{tool-guard-N0U5tG4f.js => tool-guard-BvyFvMCC.js} | 2 +-
...rabilities-CrqPtr3j.js => vulnerabilities-BdUlHMo2.js} | 2 +-
.../assets/{webshell-BKoDG5yt.js => webshell-BFjIk3Ns.js} | 2 +-
.../{workflows-BdNfetHA.js => workflows-BMEk6u8D.js} | 2 +-
web/static/app/index.html | 4 ++--
38 files changed, 51 insertions(+), 39 deletions(-)
rename web/static/app/assets/{agents-management-CsADEV29.js => agents-management-8Q9eU0Fw.js} (97%)
rename web/static/app/assets/{api-docs-BLHNGrWi.js => api-docs-Cq--SCZD.js} (98%)
rename web/static/app/assets/{asset-library-KPChFll7.js => asset-library-BAx0Ul3g.js} (99%)
rename web/static/app/assets/{asset-overview-DNWfmRJG.js => asset-overview-BmQ_1q6a.js} (98%)
rename web/static/app/assets/{c2-events-DTCXaUlN.js => c2-events-CoH3yyOa.js} (96%)
rename web/static/app/assets/{c2-listeners-D_Bx-B-I.js => c2-listeners-Czsz18uH.js} (97%)
rename web/static/app/assets/{c2-payloads-C_C_YA7N.js => c2-payloads-DvqcThjq.js} (97%)
rename web/static/app/assets/{c2-profiles-C1JrB05z.js => c2-profiles-CoAwMcjF.js} (97%)
rename web/static/app/assets/{c2-sessions-C4zx-oqJ.js => c2-sessions-CzZrurOn.js} (98%)
rename web/static/app/assets/{c2-shared-DQceLFCe.js => c2-shared-B5kg9aBy.js} (94%)
rename web/static/app/assets/{c2-shared-BkIzs15k.js => c2-shared-BBQQ9OoL.js} (96%)
rename web/static/app/assets/{c2-tasks-t5h6GDhv.js => c2-tasks-gSo_kNWy.js} (98%)
rename web/static/app/assets/{chat-QPrSpZt5.js => chat-4zuVcYax.js} (99%)
rename web/static/app/assets/{chat-files-CTTAptxF.js => chat-files-BYjs9VE-.js} (99%)
rename web/static/app/assets/{dashboard-D1HqCY0Z.js => dashboard-Bc2usnZH.js} (99%)
rename web/static/app/assets/{deep-assessments-ClJUMWIn.js => deep-assessments-cnrXHaFd.js} (99%)
rename web/static/app/assets/{hitl-CKnRMfmB.js => hitl-DCNZaIEz.js} (99%)
rename web/static/app/assets/{index-B_jDLAQv.css => index-DPO43fe5.css} (57%)
rename web/static/app/assets/{index-BoFwOeaz.js => index-smFoxEJu.js} (77%)
rename web/static/app/assets/{info-collect-C3MqtyT0.js => info-collect-3BNPr4lS.js} (99%)
rename web/static/app/assets/{knowledge-management-COpgsLN2.js => knowledge-management-CBCh6sv1.js} (98%)
rename web/static/app/assets/{knowledge-retrieval-logs-DkihRY3X.js => knowledge-retrieval-logs-D4Ccl_5u.js} (96%)
rename web/static/app/assets/{mcp-management-ClIRzGxS.js => mcp-management-CpurAL-_.js} (99%)
rename web/static/app/assets/{mcp-monitor-BENVJarN.js => mcp-monitor-CcafUVpf.js} (99%)
rename web/static/app/assets/{platform-rbac-CCzPRjms.js => platform-rbac-BG70WbmN.js} (99%)
rename web/static/app/assets/{projects-C64S62xe.js => projects-DwN7tLJD.js} (99%)
rename web/static/app/assets/{roles-management-BVS050uQ.js => roles-management-BjLBenwe.js} (96%)
rename web/static/app/assets/{settings-BEsIqHkk.js => settings-BOqxpbJE.js} (99%)
rename web/static/app/assets/{skills-management-h0lK3HYq.js => skills-management-CZ3ZF0wd.js} (98%)
rename web/static/app/assets/{skills-monitor-BiZ6uLnX.js => skills-monitor-L6Gdi19j.js} (95%)
rename web/static/app/assets/{tasks-CqEzUceO.js => tasks-VQP5hHjc.js} (99%)
rename web/static/app/assets/{tool-guard-N0U5tG4f.js => tool-guard-BvyFvMCC.js} (99%)
rename web/static/app/assets/{vulnerabilities-CrqPtr3j.js => vulnerabilities-BdUlHMo2.js} (99%)
rename web/static/app/assets/{webshell-BKoDG5yt.js => webshell-BFjIk3Ns.js} (99%)
rename web/static/app/assets/{workflows-BdNfetHA.js => workflows-BMEk6u8D.js} (99%)
diff --git a/web/frontend/src/components/ui.jsx b/web/frontend/src/components/ui.jsx
index 5f0e96c1..657536b4 100644
--- a/web/frontend/src/components/ui.jsx
+++ b/web/frontend/src/components/ui.jsx
@@ -143,7 +143,11 @@ export function ErrorBanner({ error, onRetry }) {
export function SeverityTag({ severity, size = 'small' }) {
const key = String(severity || '').toLowerCase();
- return {SEVERITY_LABEL[key] || severity || '—'};
+ return (
+
+ {SEVERITY_LABEL[key] || severity || '—'}
+
+ );
}
export function StatusTag({ status, label, size = 'small' }) {
diff --git a/web/frontend/src/styles/app.css b/web/frontend/src/styles/app.css
index 1767de7f..cf1d9c60 100644
--- a/web/frontend/src/styles/app.css
+++ b/web/frontend/src/styles/app.css
@@ -135,6 +135,14 @@ body[theme-mode="dark"] .semi-button-primary.semi-button-solid:not(.semi-button-
.cs-table-empty { padding: 40px 16px; color: var(--semi-color-text-3); }
.cs-table-empty .semi-empty-image { padding: 14px; border-radius: 16px; background: var(--semi-color-fill-0); }
.cs-error-banner { margin-bottom: 16px; border-radius: 8px; }
+
+.cs-severity-tag[data-severity="low"] { color: #154d91; background-color: #dceafe; }
+.cs-severity-tag[data-severity="medium"] { color: #744900; background-color: #ffebbb; }
+.cs-severity-tag[data-severity="high"] { color: #8f2e19; background-color: #ffccb6; }
+body[theme-mode="dark"] .cs-severity-tag[data-severity="low"] { color: #bcdcff; background-color: #224875; }
+body[theme-mode="dark"] .cs-severity-tag[data-severity="medium"] { color: #ffe09a; background-color: #63491b; }
+body[theme-mode="dark"] .cs-severity-tag[data-severity="high"] { color: #ffbe9e; background-color: #662f20; }
+
.cs-description-list { width: 100%; }
.cs-description-list table { width: 100%; table-layout: fixed; }
.cs-description-list td { word-break: break-word; vertical-align: top; }
diff --git a/web/static/app/assets/agents-management-CsADEV29.js b/web/static/app/assets/agents-management-8Q9eU0Fw.js
similarity index 97%
rename from web/static/app/assets/agents-management-CsADEV29.js
rename to web/static/app/assets/agents-management-8Q9eU0Fw.js
index 275c62c9..bc20545a 100644
--- a/web/static/app/assets/agents-management-CsADEV29.js
+++ b/web/static/app/assets/agents-management-8Q9eU0Fw.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{C as r,I as i,P as a,U as o,V as s,i as c,it as l,j as u,ot as d,rt as f,xt as p,yt as m}from"./semi-DNxeCrHm.js";import{F as h,I as g,P as _,a as v,b as y,c as b,d as x,f as S,l as C,m as w,p as T,s as E,u as D,x as O,y as k}from"./index-BoFwOeaz.js";var A=e(t(),1),j=e(n(),1),{Text:M}=o;function N(){let e=_(),{hasPermission:t}=h(),n=t(`agents:write`),o=t(`agents:delete`),[N,P]=(0,A.useState)(``),[F,I]=(0,A.useState)(null),[L,R]=(0,A.useState)(null),[z,B]=(0,A.useState)(!1),V=v(()=>g.get(`/multi-agent/markdown-agents`),[]),H=(Array.isArray(V.data?.agents)?V.data.agents:[]).filter(e=>{if(!N)return!0;let t=N.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),U=async e=>{try{I(await g.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){y(e,`读取智能体失败`)}},W=async()=>{let e=await L.form.validate();B(!0);try{await g.post(`/multi-agent/markdown-agents`,{filename:e.filename?.trim()||``,name:e.name.trim(),description:e.description?.trim()||``,instruction:e.instruction,kind:e.kind||`sub`,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean)}),O(`智能体已保存`),R(null),V.reload()}catch(e){y(e,`保存智能体失败`)}finally{B(!1)}},G=e=>k({title:`删除智能体「${e.name||e.filename}」?`,onOk:async()=>{await g.del(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`),O(`已删除`),V.reload()}});return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(T,{title:e(`agents.title`,null,`智能体管理`),description:V.data?.dir?`目录:${V.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,j.jsxs)(a,{children:[(0,j.jsx)(i,{icon:(0,j.jsx)(l,{}),onClick:()=>V.reload(),loading:V.loading,children:`刷新`}),n&&(0,j.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,j.jsx)(d,{}),onClick:()=>R({record:null,form:{}}),children:`新建智能体`})]})}),V.data?.error&&(0,j.jsx)(C,{error:V.data.error}),(0,j.jsxs)(w,{title:`智能体(${H.length})`,children:[(0,j.jsx)(C,{error:V.error,onRetry:()=>V.reload()}),(0,j.jsx)(E,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,j.jsxs)(a,{vertical:!0,spacing:0,align:`start`,children:[(0,j.jsxs)(a,{children:[(0,j.jsx)(M,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,j.jsx)(u,{size:`small`,color:`purple`,children:`编排器`})]}),(0,j.jsx)(M,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,j.jsx)(u,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,j.jsx)(M,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,j.jsxs)(a,{children:[(0,j.jsx)(i,{size:`small`,theme:`borderless`,onClick:()=>U(t),children:`详情`}),n&&(0,j.jsx)(i,{size:`small`,theme:`borderless`,icon:(0,j.jsx)(m,{}),onClick:()=>R({record:t,form:{}})}),o&&(0,j.jsx)(i,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,j.jsx)(p,{}),onClick:()=>G(t)})]})}],dataSource:H,rowKey:`filename`,loading:V.loading,pagination:{pageSize:20},toolbar:(0,j.jsx)(s,{prefix:(0,j.jsx)(f,{}),value:N,onChange:P,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,j.jsx)(r,{title:L?.record?`编辑智能体`:`新建智能体`,visible:!!L,onCancel:()=>R(null),onOk:W,confirmLoading:z,width:760,children:(0,j.jsxs)(c,{getFormApi:e=>R(t=>t&&{...t,form:e}),initValues:L?.record?{filename:L.record.filename,name:L.record.name,description:L.record.description,kind:L.record.kind||`sub`}:{kind:`sub`},children:[(0,j.jsx)(c.Input,{field:`filename`,label:`文件名(留空自动生成)`,placeholder:`例如 recon.md`}),(0,j.jsx)(c.Input,{field:`name`,label:`名称`,rules:[{required:!0,message:`请输入名称`}]}),(0,j.jsx)(c.Input,{field:`description`,label:`描述`}),(0,j.jsx)(c.Select,{field:`kind`,label:`类型`,optionList:[{value:`sub`,label:`子智能体`},{value:`orchestrator`,label:`编排器`},{value:`plan_execute`,label:`计划执行`}]}),(0,j.jsx)(c.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::tool`}),(0,j.jsx)(c.TextArea,{field:`instruction`,label:`指令(Markdown)`,autosize:{minRows:8,maxRows:20}})]})},L?.record?.filename||`new-agent`),(0,j.jsx)(b,{title:F?.name||`智能体详情`,visible:!!F,onCancel:()=>I(null),width:720,children:F&&(0,j.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,j.jsx)(x,{items:[{label:`文件名`,value:F.filename},{label:`ID`,value:F.id},{label:`类型`,value:F.kind},{label:`绑定角色`,value:F.bind_role||`—`},{label:`最大迭代`,value:F.max_iterations??`—`},{label:`工具`,value:Array.isArray(F.tools)&&F.tools.length?F.tools.join(`、`):`—`}]}),(0,j.jsx)(S,{content:F.instruction||F.raw||``}),(0,j.jsx)(D,{value:F.raw||F,title:`原始 Markdown`,collapsed:!0})]})})]})}export{N as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{C as r,I as i,P as a,U as o,V as s,i as c,it as l,j as u,ot as d,rt as f,xt as p,yt as m}from"./semi-DNxeCrHm.js";import{F as h,I as g,P as _,a as v,b as y,c as b,d as x,f as S,l as C,m as w,p as T,s as E,u as D,x as O,y as k}from"./index-smFoxEJu.js";var A=e(t(),1),j=e(n(),1),{Text:M}=o;function N(){let e=_(),{hasPermission:t}=h(),n=t(`agents:write`),o=t(`agents:delete`),[N,P]=(0,A.useState)(``),[F,I]=(0,A.useState)(null),[L,R]=(0,A.useState)(null),[z,B]=(0,A.useState)(!1),V=v(()=>g.get(`/multi-agent/markdown-agents`),[]),H=(Array.isArray(V.data?.agents)?V.data.agents:[]).filter(e=>{if(!N)return!0;let t=N.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),U=async e=>{try{I(await g.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){y(e,`读取智能体失败`)}},W=async()=>{let e=await L.form.validate();B(!0);try{await g.post(`/multi-agent/markdown-agents`,{filename:e.filename?.trim()||``,name:e.name.trim(),description:e.description?.trim()||``,instruction:e.instruction,kind:e.kind||`sub`,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean)}),O(`智能体已保存`),R(null),V.reload()}catch(e){y(e,`保存智能体失败`)}finally{B(!1)}},G=e=>k({title:`删除智能体「${e.name||e.filename}」?`,onOk:async()=>{await g.del(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`),O(`已删除`),V.reload()}});return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(T,{title:e(`agents.title`,null,`智能体管理`),description:V.data?.dir?`目录:${V.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,j.jsxs)(a,{children:[(0,j.jsx)(i,{icon:(0,j.jsx)(l,{}),onClick:()=>V.reload(),loading:V.loading,children:`刷新`}),n&&(0,j.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,j.jsx)(d,{}),onClick:()=>R({record:null,form:{}}),children:`新建智能体`})]})}),V.data?.error&&(0,j.jsx)(C,{error:V.data.error}),(0,j.jsxs)(w,{title:`智能体(${H.length})`,children:[(0,j.jsx)(C,{error:V.error,onRetry:()=>V.reload()}),(0,j.jsx)(E,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,j.jsxs)(a,{vertical:!0,spacing:0,align:`start`,children:[(0,j.jsxs)(a,{children:[(0,j.jsx)(M,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,j.jsx)(u,{size:`small`,color:`purple`,children:`编排器`})]}),(0,j.jsx)(M,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,j.jsx)(u,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,j.jsx)(M,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,j.jsxs)(a,{children:[(0,j.jsx)(i,{size:`small`,theme:`borderless`,onClick:()=>U(t),children:`详情`}),n&&(0,j.jsx)(i,{size:`small`,theme:`borderless`,icon:(0,j.jsx)(m,{}),onClick:()=>R({record:t,form:{}})}),o&&(0,j.jsx)(i,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,j.jsx)(p,{}),onClick:()=>G(t)})]})}],dataSource:H,rowKey:`filename`,loading:V.loading,pagination:{pageSize:20},toolbar:(0,j.jsx)(s,{prefix:(0,j.jsx)(f,{}),value:N,onChange:P,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,j.jsx)(r,{title:L?.record?`编辑智能体`:`新建智能体`,visible:!!L,onCancel:()=>R(null),onOk:W,confirmLoading:z,width:760,children:(0,j.jsxs)(c,{getFormApi:e=>R(t=>t&&{...t,form:e}),initValues:L?.record?{filename:L.record.filename,name:L.record.name,description:L.record.description,kind:L.record.kind||`sub`}:{kind:`sub`},children:[(0,j.jsx)(c.Input,{field:`filename`,label:`文件名(留空自动生成)`,placeholder:`例如 recon.md`}),(0,j.jsx)(c.Input,{field:`name`,label:`名称`,rules:[{required:!0,message:`请输入名称`}]}),(0,j.jsx)(c.Input,{field:`description`,label:`描述`}),(0,j.jsx)(c.Select,{field:`kind`,label:`类型`,optionList:[{value:`sub`,label:`子智能体`},{value:`orchestrator`,label:`编排器`},{value:`plan_execute`,label:`计划执行`}]}),(0,j.jsx)(c.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::tool`}),(0,j.jsx)(c.TextArea,{field:`instruction`,label:`指令(Markdown)`,autosize:{minRows:8,maxRows:20}})]})},L?.record?.filename||`new-agent`),(0,j.jsx)(b,{title:F?.name||`智能体详情`,visible:!!F,onCancel:()=>I(null),width:720,children:F&&(0,j.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,j.jsx)(x,{items:[{label:`文件名`,value:F.filename},{label:`ID`,value:F.id},{label:`类型`,value:F.kind},{label:`绑定角色`,value:F.bind_role||`—`},{label:`最大迭代`,value:F.max_iterations??`—`},{label:`工具`,value:Array.isArray(F.tools)&&F.tools.length?F.tools.join(`、`):`—`}]}),(0,j.jsx)(S,{content:F.instruction||F.raw||``}),(0,j.jsx)(D,{value:F.raw||F,title:`原始 Markdown`,collapsed:!0})]})})]})}export{N as default};
\ No newline at end of file
diff --git a/web/static/app/assets/api-docs-BLHNGrWi.js b/web/static/app/assets/api-docs-Cq--SCZD.js
similarity index 98%
rename from web/static/app/assets/api-docs-BLHNGrWi.js
rename to web/static/app/assets/api-docs-Cq--SCZD.js
index 49653fbe..04b40d4f 100644
--- a/web/static/app/assets/api-docs-BLHNGrWi.js
+++ b/web/static/app/assets/api-docs-Cq--SCZD.js
@@ -1,3 +1,3 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{I as r,N as i,P as a,T as o,U as s,V as c,_ as l,b as u,c as d,it as f,j as p,nt as m,rt as h}from"./semi-DNxeCrHm.js";import{B as g,I as _,P as v,R as y,b,p as x,u as S}from"./index-BoFwOeaz.js";var C=e(t(),1),w=e(n(),1),{Text:T,Paragraph:E}=s,D={get:`blue`,post:`green`,put:`orange`,delete:`red`,patch:`violet`,head:`grey`,options:`grey`};function O(e){let t=e?.paths||{},n=[];return Object.entries(t).forEach(([e,t])=>{Object.entries(t||{}).forEach(([t,r])=>{r&&typeof r==`object`&&n.push({id:`${t.toUpperCase()} ${e}`,method:t.toUpperCase(),path:e,summary:r.summary||r.description||``,tag:r.tags&&r.tags[0]||`default`,operation:r})})}),n.sort((e,t)=>e.path.localeCompare(t.path)||e.method.localeCompare(t.method))}function k(e){return Array.from(e.matchAll(/\{([^}]+)\}/g)).map(e=>e[1])}function A({operation:e,spec:t}){let n=e.operation||{},i=n.parameters||[],s=k(e.path),[l,d]=(0,C.useState)({}),[f,h]=(0,C.useState)(``),[_,v]=(0,C.useState)(null),[x,E]=(0,C.useState)(!1);return(0,C.useEffect)(()=>{let e={};s.forEach(t=>{let n=i.find(e=>e.name===t&&e.in===`path`);e[t]=n?.schema?.default??n?.example??``}),i.filter(e=>e.in===`query`).forEach(t=>{t.schema?.default!==void 0&&(e[`query:${t.name}`]=String(t.schema.default))}),d(e),h(n.requestBody?`{
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{I as r,N as i,P as a,T as o,U as s,V as c,_ as l,b as u,c as d,it as f,j as p,nt as m,rt as h}from"./semi-DNxeCrHm.js";import{B as g,I as _,P as v,R as y,b,p as x,u as S}from"./index-smFoxEJu.js";var C=e(t(),1),w=e(n(),1),{Text:T,Paragraph:E}=s,D={get:`blue`,post:`green`,put:`orange`,delete:`red`,patch:`violet`,head:`grey`,options:`grey`};function O(e){let t=e?.paths||{},n=[];return Object.entries(t).forEach(([e,t])=>{Object.entries(t||{}).forEach(([t,r])=>{r&&typeof r==`object`&&n.push({id:`${t.toUpperCase()} ${e}`,method:t.toUpperCase(),path:e,summary:r.summary||r.description||``,tag:r.tags&&r.tags[0]||`default`,operation:r})})}),n.sort((e,t)=>e.path.localeCompare(t.path)||e.method.localeCompare(t.method))}function k(e){return Array.from(e.matchAll(/\{([^}]+)\}/g)).map(e=>e[1])}function A({operation:e,spec:t}){let n=e.operation||{},i=n.parameters||[],s=k(e.path),[l,d]=(0,C.useState)({}),[f,h]=(0,C.useState)(``),[_,v]=(0,C.useState)(null),[x,E]=(0,C.useState)(!1);return(0,C.useEffect)(()=>{let e={};s.forEach(t=>{let n=i.find(e=>e.name===t&&e.in===`path`);e[t]=n?.schema?.default??n?.example??``}),i.filter(e=>e.in===`query`).forEach(t=>{t.schema?.default!==void 0&&(e[`query:${t.name}`]=String(t.schema.default))}),d(e),h(n.requestBody?`{
}`:``),v(null)},[e.id]),(0,w.jsxs)(`div`,{className:`api-docs-try`,children:[(0,w.jsx)(o,{margin:`12px 0`}),(0,w.jsx)(T,{strong:!0,children:`在线调试`}),s.length>0&&(0,w.jsx)(`div`,{className:`api-docs-try-fields`,children:s.map(e=>(0,w.jsxs)(`label`,{className:`api-docs-try-field`,children:[(0,w.jsxs)(`span`,{children:[`路径参数 `,e]}),(0,w.jsx)(c,{size:`small`,value:l[e]??``,onChange:t=>d(n=>({...n,[e]:t}))})]},e))}),i.filter(e=>e.in===`query`).length>0&&(0,w.jsx)(`div`,{className:`api-docs-try-fields`,children:i.filter(e=>e.in===`query`).map(e=>(0,w.jsxs)(`label`,{className:`api-docs-try-field`,children:[(0,w.jsxs)(`span`,{children:[`查询参数 `,e.name,e.required?` *`:``]}),(0,w.jsx)(c,{size:`small`,value:l[`query:${e.name}`]??``,onChange:t=>d(n=>({...n,[`query:${e.name}`]:t})),placeholder:e.description||``})]},e.name))}),n.requestBody&&(0,w.jsxs)(`div`,{className:`api-docs-try-body`,children:[(0,w.jsx)(`span`,{children:`请求体(JSON)`}),(0,w.jsx)(u,{value:f,onChange:h,autosize:{minRows:5,maxRows:14}})]}),(0,w.jsxs)(a,{children:[(0,w.jsx)(r,{theme:`solid`,type:`primary`,icon:(0,w.jsx)(m,{}),loading:x,onClick:async()=>{E(!0),v(null);try{if(s.some(e=>String(l[e]??``).trim()===``)){b(`请填写路径参数`);return}let t=e.path;s.forEach(e=>{t=t.replace(`{${e}}`,encodeURIComponent(l[e]??``))});let r={};i.filter(e=>e.in===`query`).forEach(e=>{let t=l[`query:${e.name}`];t!==void 0&&t!==``&&(r[e.name]=t)});let a={method:e.method,query:r,raw:!0,timeout:12e4};if(n.requestBody&&f.trim())try{a.body=JSON.parse(f)}catch{b(`请求体不是合法 JSON`),E(!1);return}if(!t.startsWith(`/`)||t.startsWith(`//`))throw Error(`接口地址必须为站内 API 路径`);let o=await g(t.startsWith(`/api/`)?t.slice(4):t,a),c=o.headers.get(`content-type`)||``,u;u=c.includes(`application/json`)?await o.json():await o.text(),v({ok:!0,status:o.status,payload:u})}catch(e){v({ok:!1,status:e.status||0,payload:y(e)})}finally{E(!1)}},children:`发送请求`}),(0,w.jsx)(r,{onClick:()=>v(null),children:`清空结果`})]}),_&&(0,w.jsxs)(`div`,{className:`api-docs-try-result`,children:[(0,w.jsx)(p,{color:_.ok?`green`:`red`,children:_.ok?`HTTP ${_.status}`:`失败 ${_.status||``}`}),(0,w.jsx)(S,{value:_.payload,title:`响应`})]})]})}function j(){let e=v(),[t,n]=(0,C.useState)(null),[o,s]=(0,C.useState)(!0),[u,m]=(0,C.useState)(null),[g,b]=(0,C.useState)(``),[k,j]=(0,C.useState)(`all`),[M,N]=(0,C.useState)(null),P=async()=>{s(!0),m(null);try{let e=await _.get(`/openapi/spec`);n(e)}catch(e){m(e)}finally{s(!1)}};(0,C.useEffect)(()=>{P()},[]);let F=(0,C.useMemo)(()=>O(t),[t]),I=(0,C.useMemo)(()=>F.filter(e=>{if(k!==`all`&&e.method!==k)return!1;if(!g)return!0;let t=g.toLowerCase();return e.path.toLowerCase().includes(t)||e.summary.toLowerCase().includes(t)||e.method.toLowerCase().includes(t)}),[F,g,k]),L=I.find(e=>e.id===M)||I[0]||null,R=(0,C.useMemo)(()=>{let e=new Map;return I.forEach(t=>{e.has(t.tag)||e.set(t.tag,[]),e.get(t.tag).push(t)}),[...e.entries()]},[I]);return(0,w.jsxs)(`div`,{className:`api-docs-page`,children:[(0,w.jsx)(x,{title:e(`apiDocs.title`,null,`API 文档`),description:t?.info?.description||`CyberStrikeAI 开放接口`,extra:(0,w.jsx)(r,{icon:(0,w.jsx)(f,{}),onClick:P,loading:o,children:`重新加载`})}),(0,w.jsxs)(`div`,{className:`api-docs-layout`,children:[(0,w.jsxs)(i,{className:`api-docs-sidebar`,bordered:!1,children:[(0,w.jsxs)(a,{vertical:!0,style:{width:`100%`},spacing:8,children:[(0,w.jsx)(c,{prefix:(0,w.jsx)(h,{}),value:g,onChange:b,placeholder:`搜索路径或说明`}),(0,w.jsx)(l,{value:k,onChange:j,style:{width:`100%`},optionList:[{value:`all`,label:`全部方法`},...[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`].map(e=>({value:e,label:e}))]})]}),(0,w.jsxs)(`div`,{className:`api-docs-list`,children:[R.map(([e,t])=>(0,w.jsxs)(`div`,{className:`api-docs-group`,children:[(0,w.jsx)(T,{type:`tertiary`,className:`api-docs-group-title`,children:e}),t.map(e=>(0,w.jsxs)(`button`,{type:`button`,className:`api-docs-item ${L?.id===e.id?`is-active`:``}`,onClick:()=>N(e.id),children:[(0,w.jsx)(p,{size:`small`,color:D[e.method.toLowerCase()],children:e.method}),(0,w.jsx)(`span`,{className:`api-docs-item-path`,children:e.path})]},e.id))]},e)),!o&&R.length===0&&(0,w.jsx)(T,{type:`tertiary`,children:`没有匹配的接口`})]})]}),(0,w.jsxs)(`div`,{className:`api-docs-detail`,children:[u&&(0,w.jsx)(i,{bordered:!1,children:(0,w.jsx)(T,{type:`danger`,children:y(u)})}),L?(0,w.jsxs)(i,{bordered:!1,children:[(0,w.jsxs)(`div`,{className:`api-docs-detail-head`,children:[(0,w.jsx)(p,{color:D[L.method.toLowerCase()],children:L.method}),(0,w.jsx)(`code`,{className:`api-docs-detail-path`,children:L.path})]}),(0,w.jsx)(E,{children:L.summary||`无说明`}),(0,w.jsxs)(d,{type:`line`,children:[(0,w.jsx)(d.TabPane,{itemKey:`params`,tab:`参数`,children:(0,w.jsx)(S,{value:L.operation.parameters||[],title:`Request Parameters`,collapsed:!0})}),(0,w.jsx)(d.TabPane,{itemKey:`body`,tab:`请求体`,children:(0,w.jsx)(S,{value:L.operation.requestBody||{},title:`Request Body`,collapsed:!0})}),(0,w.jsx)(d.TabPane,{itemKey:`responses`,tab:`响应`,children:(0,w.jsx)(S,{value:L.operation.responses||{},title:`Responses`,collapsed:!0})})]}),(0,w.jsx)(A,{operation:L,spec:t})]}):(0,w.jsx)(i,{bordered:!1,children:(0,w.jsx)(T,{type:`tertiary`,children:o?`加载中…`:`选择左侧接口查看详情`})})]})]})]})}export{j as default};
\ No newline at end of file
diff --git a/web/static/app/assets/asset-library-KPChFll7.js b/web/static/app/assets/asset-library-BAx0Ul3g.js
similarity index 99%
rename from web/static/app/assets/asset-library-KPChFll7.js
rename to web/static/app/assets/asset-library-BAx0Ul3g.js
index 8ee62198..33f32f74 100644
--- a/web/static/app/assets/asset-library-KPChFll7.js
+++ b/web/static/app/assets/asset-library-BAx0Ul3g.js
@@ -1,3 +1,3 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,h as r,t as i,y as a}from"./react-QV7DAAIx.js";import{C as o,I as s,P as c,R as l,T as u,U as d,V as f,_ as p,b as m,d as h,f as g,i as _,it as v,k as y,l as b,ot as x,p as S,rt as C,u as w,wt as ee}from"./semi-DNxeCrHm.js";import{E as T,F as te,I as E,P as D,R as O,S as ne,a as k,b as A,d as j,l as re,m as ie,n as ae,o as M,p as oe,s as se,x as N,y as ce}from"./index-BoFwOeaz.js";import{A as le,C as ue,D as de,E as fe,M as pe,N as me,O as he,P as ge,S as _e,T as ve,_ as P,a as F,b as I,c as L,d as R,f as z,g as ye,h as B,i as be,j as V,k as H,l as U,m as W,n as G,o as xe,p as Se,r as K,s as q,t as Ce,u as we,v as Te,w as J,x as Ee,y as De}from"./assetTarget-CAuOtA9X.js";var Y=e(t(),1),X=e(i(),1),Oe={q:``,protocol:``,source:``,project_id:``,tag:``,status:``,risk_level:``,environment:``,criticality:``,ip:``,domain:``,port:``,scan:``,sort:`last_seen_at:desc`};function ke(){return{...Oe}}function Ae({filters:e,projects:t,onChange:n,onReset:r,disabled:i}){let a=D(),[o,l]=(0,Y.useState)(e.q||``);(0,Y.useEffect)(()=>{l(e.q||``)},[e.q]);let u=(0,Y.useMemo)(()=>(t||[]).map(e=>({value:e.id,label:e.name||e.id})),[t]),d=[`status`,`risk_level`,`environment`,`criticality`,`ip`,`domain`,`port`,`scan`].filter(t=>e[t]).length;return(0,X.jsxs)(`div`,{className:`asset-library-filters`,children:[(0,X.jsxs)(`div`,{className:`asset-library-filter-grid`,children:[(0,X.jsx)(f,{prefix:(0,X.jsx)(C,{}),value:o,disabled:i,placeholder:a(`assets.searchPlaceholder`,null,`搜索主机、IP、域名、标题、服务或标签`),onChange:e=>{l(e),n({q:e})},showClear:!0}),(0,X.jsx)(p,{value:e.protocol||void 0,placeholder:a(`assets.assetType`,null,`类型 / 协议`),optionList:J,filter:!0,allowCreate:!0,showClear:!0,disabled:i,onChange:e=>n({protocol:e||``})}),(0,X.jsx)(f,{value:e.source,placeholder:a(`assets.source`,null,`来源`),disabled:i,onChange:e=>n({source:e}),showClear:!0}),(0,X.jsx)(p,{value:e.project_id||void 0,placeholder:a(`assets.project`,null,`所属项目`),optionList:u,filter:!0,showClear:!0,disabled:i,onChange:e=>n({project_id:e||``})}),(0,X.jsx)(f,{value:e.tag,placeholder:a(`assets.tagsLabel`,null,`标签`),disabled:i,onChange:e=>n({tag:e}),showClear:!0}),(0,X.jsx)(c,{spacing:8,className:`asset-library-filter-actions`,children:(0,X.jsx)(s,{onClick:r,disabled:i,children:a(`assets.resetFilters`,null,`重置`)})})]}),(0,X.jsx)(y,{className:`asset-library-filter-advanced`,keepDOM:!1,children:(0,X.jsx)(y.Panel,{itemKey:`advanced`,header:`${a(`assets.advancedFilters`,null,`高级筛选`)}${d?`(${d})`:``}`,children:(0,X.jsxs)(`div`,{className:`asset-library-filter-grid asset-library-filter-grid--advanced`,children:[(0,X.jsx)(p,{value:e.status||void 0,placeholder:a(`assets.allStatuses`,null,`全部状态`),optionList:H,showClear:!0,disabled:i,onChange:e=>n({status:e||``})}),(0,X.jsx)(p,{value:e.risk_level||void 0,placeholder:a(`assets.allRisks`,null,`全部风险`),optionList:ve,showClear:!0,disabled:i,onChange:e=>n({risk_level:e||``})}),(0,X.jsx)(p,{value:e.environment||void 0,placeholder:a(`assets.allEnvironments`,null,`全部环境`),optionList:De,showClear:!0,disabled:i,onChange:e=>n({environment:e||``})}),(0,X.jsx)(p,{value:e.criticality||void 0,placeholder:a(`assets.allCriticalities`,null,`全部级别`),optionList:P,showClear:!0,disabled:i,onChange:e=>n({criticality:e||``})}),(0,X.jsx)(f,{value:e.ip,placeholder:`IP`,disabled:i,onChange:e=>n({ip:e}),showClear:!0}),(0,X.jsx)(f,{value:e.domain,placeholder:a(`assets.domain`,null,`域名`),disabled:i,onChange:e=>n({domain:e}),showClear:!0}),(0,X.jsx)(f,{value:e.port,placeholder:a(`assets.port`,null,`端口`),disabled:i,onChange:e=>n({port:String(e||``).replace(/[^\d]/g,``)}),showClear:!0}),(0,X.jsx)(p,{value:e.scan||``,placeholder:a(`assets.scanState`,null,`扫描状态`),optionList:fe,disabled:i,onChange:e=>n({scan:e||``})}),(0,X.jsx)(p,{value:e.sort||`last_seen_at:desc`,optionList:de,disabled:i,onChange:e=>n({sort:e||`last_seen_at:desc`})})]})})})]})}var{Text:je}=d;function Me({assets:e,loading:t,total:n,page:r,pageSize:i,onPageChange:a,onPageSizeChange:o,selectedRowKeys:l,onSelectionChange:u,onView:d,onEdit:f,onDelete:p,onRefresh:m,canWrite:h,canDelete:g}){let _=D(),v=e=>{ce({title:_(`assets.deleteConfirm`,null,`确定删除该资产吗?`),content:K(e),okText:_(`common.delete`,null,`删除`),onOk:()=>{Promise.resolve(p(e)).catch(e=>A(e,_(`assets.deleteFailed`,null,`删除资产失败`)))}})},y=[{title:_(`assets.target`,null,`目标`),dataIndex:`host`,width:260,render:(e,t)=>(0,X.jsxs)(`div`,{className:`asset-library-target`,children:[(0,X.jsx)(B,{text:K(t),max:38}),(0,X.jsx)(je,{type:`tertiary`,size:`small`,children:[t.ip,t.domain].filter(Boolean).join(` · `)||`—`})]})},{title:_(`assets.service`,null,`服务`),dataIndex:`protocol`,width:150,render:(e,t)=>(0,X.jsx)(z,{protocol:t.protocol,port:t.port})},{title:_(`assets.project`,null,`所属项目`),dataIndex:`project_name`,width:160,render:e=>(0,X.jsx)(B,{text:e,max:18})},{title:_(`assets.source`,null,`来源`),dataIndex:`source`,width:120,render:e=>(0,X.jsx)(B,{text:e,max:14})},{title:_(`assets.riskLevel`,null,`风险等级`),dataIndex:`risk_level`,width:150,render:(e,t)=>(0,X.jsxs)(c,{spacing:6,children:[(0,X.jsx)(Se,{asset:t}),(0,X.jsx)(je,{type:`tertiary`,size:`small`,children:Number(t.vulnerability_count||0)})]})},{title:_(`assets.lastSeen`,null,`最近发现`),dataIndex:`last_seen_at`,width:170,render:e=>(0,X.jsx)(je,{size:`small`,children:T(e)})},{title:_(`common.actions`,null,`操作`),dataIndex:`id`,width:190,render:(e,t)=>(0,X.jsxs)(c,{spacing:4,children:[(0,X.jsx)(s,{theme:`borderless`,size:`small`,onClick:()=>d(t),children:_(`common.view`,null,`查看`)}),h&&(0,X.jsx)(s,{theme:`borderless`,size:`small`,onClick:()=>f(t),children:_(`common.edit`,null,`编辑`)}),g&&(0,X.jsx)(s,{theme:`borderless`,type:`danger`,size:`small`,onClick:()=>v(t),children:_(`common.delete`,null,`删除`)})]})}];return(0,X.jsx)(se,{columns:y,dataSource:e,loading:t,rowKey:`id`,onRefresh:m,rowSelection:{selectedRowKeys:l,onChange:(e,t)=>u(e,t)},pagination:{currentPage:r,pageSize:i,total:n||0,showSizeChanger:!0,pageSizeOpts:[10,20,50,100],onPageChange:a,onPageSizeChange:o},emptyText:_(`common.noData`,null,`暂无数据`)})}var{Text:Z}=d;function Ne({asset:e,visible:t,onClose:r,onEdit:i,onDelete:a,canWrite:o,canDelete:l}){let d=D(),f=n();if(!e)return null;let p=()=>{if(e.last_scan_task_id){f(`/vulnerabilities?task_id=${encodeURIComponent(e.last_scan_task_id)}`);return}if(e.last_scan_conversation_id){f(`/vulnerabilities?conversation_id=${encodeURIComponent(e.last_scan_conversation_id)}`);return}let t=e.host||e.domain||e.ip||``;f(t?`/vulnerabilities?host_q=${encodeURIComponent(t)}`:`/vulnerabilities`)},m=[{label:`Host`,value:e.host||`—`},{label:`IP`,value:e.ip||`—`},{label:d(`assets.domain`,null,`域名`),value:e.domain||`—`},{label:d(`assets.service`,null,`服务`),value:(0,X.jsx)(z,{protocol:e.protocol,port:e.port})},{label:d(`assets.project`,null,`所属项目`),value:e.project_name||e.project_id||`—`},{label:d(`assets.status`,null,`状态`),value:(0,X.jsx)(R,{status:e.status})},{label:d(`assets.riskLevel`,null,`风险等级`),value:(0,X.jsx)(Se,{asset:e})},{label:d(`assets.environment`,null,`环境`),value:pe(e.environment)||`—`},{label:d(`assets.criticality`,null,`重要性`),value:V(e.criticality)||`—`},{label:d(`assets.location`,null,`地区`),value:[e.country,e.province,e.city].filter(Boolean).join(` / `)||`—`},{label:d(`assets.responsiblePerson`,null,`负责人`),value:e.responsible_person||`—`},{label:d(`assets.department`,null,`部门`),value:e.department||`—`},{label:d(`assets.businessSystem`,null,`业务系统`),value:e.business_system||`—`},{label:d(`assets.title`,null,`标题/指纹`),value:e.title||`—`},{label:d(`assets.server`,null,`服务指纹`),value:e.server||`—`},{label:d(`assets.source`,null,`来源`),value:e.source||`—`},{label:d(`assets.sourceQuery`,null,`来源查询`),value:e.source_query?(0,X.jsx)(Z,{code:!0,size:`small`,children:e.source_query}):`—`},{label:d(`assets.tagsLabel`,null,`标签`),value:(0,X.jsx)(W,{tags:e.tags,max:6})},{label:d(`assets.firstSeen`,null,`首次发现`),value:T(e.first_seen_at)},{label:d(`assets.lastSeen`,null,`最近发现`),value:T(e.last_seen_at)},{label:d(`assets.lastScan`,null,`上次扫描`),value:T(e.last_scan_at)},{label:`创建时间`,value:T(e.created_at)},{label:`更新时间`,value:T(e.updated_at)},{label:`资产 ID`,value:(0,X.jsx)(Z,{copyable:{content:e.id},size:`small`,children:e.id})}];return(0,X.jsxs)(h,{visible:t,onCancel:r,title:d(`assets.detailTitle`,null,`资产详情`),width:620,placement:`right`,footer:(0,X.jsxs)(c,{children:[o&&(0,X.jsx)(s,{onClick:()=>i(e),children:d(`common.edit`,null,`编辑`)}),l&&(0,X.jsx)(s,{type:`danger`,onClick:()=>a(e),children:d(`common.delete`,null,`删除`)}),(0,X.jsx)(s,{theme:`borderless`,onClick:r,children:d(`common.close`,null,`关闭`)})]}),children:[(0,X.jsxs)(`div`,{className:`asset-library-detail-target`,children:[(0,X.jsxs)(`div`,{className:`asset-library-detail-target-main`,children:[(0,X.jsx)(Z,{strong:!0,size:`large`,children:K(e)}),(0,X.jsx)(M,{text:K(e)})]}),(0,X.jsx)(Z,{type:`tertiary`,children:[e.ip,e.domain,G(e)].filter(Boolean).join(` · `)||`—`}),(0,X.jsxs)(c,{spacing:6,wrap:!0,className:`asset-library-detail-badges`,children:[(0,X.jsx)(R,{status:e.status}),(0,X.jsx)(Se,{asset:e}),(0,X.jsxs)(Z,{type:`tertiary`,size:`small`,children:[d(`assets.relatedVulnerabilities`,null,`相关漏洞`),`:`,Number(e.vulnerability_count||0),e.risk_level?`(${me(e.risk_level)})`:``]})]})]}),(0,X.jsx)(u,{margin:`12px`}),(0,X.jsx)(j,{items:m,columns:2}),(0,X.jsx)(u,{margin:`12px`}),(0,X.jsxs)(c,{children:[(0,X.jsx)(s,{theme:`light`,onClick:p,children:d(`assets.viewRelatedVulnerabilities`,null,`查看关联漏洞`)}),e.project_id&&(0,X.jsx)(s,{theme:`borderless`,onClick:()=>f(`/projects?id=${encodeURIComponent(e.project_id)}`),children:d(`assets.viewProject`,null,`查看项目`)})]})]})}var Pe=`asset-library-editor`;function Q(e){return{target:U(e),host:e?.host||``,ip:e?.ip||``,domain:e?.domain||``,port:e?.port??void 0,protocol:e?.protocol||``,title:e?.title||``,server:e?.server||``,project_id:e?.project_id||``,status:e?.status||`active`,environment:e?.environment||``,criticality:e?.criticality||``,country:e?.country||``,province:e?.province||``,city:e?.city||``,responsible_person:e?.responsible_person||``,department:e?.department||``,business_system:e?.business_system||``,tags:Array.isArray(e?.tags)?e.tags:[]}}function Fe({visible:e,asset:t,projects:n,onClose:r,onSaved:i}){let a=D(),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(``),g=(0,Y.useRef)(U(t)),v=(0,Y.useMemo)(()=>Q(t),[t,e]),y=!!t?.id;(0,Y.useEffect)(()=>{e&&(g.current=U(t),h(``),p(!1))},[e,t]);let b=(0,Y.useMemo)(()=>(n||[]).map(e=>({value:e.id,label:e.name||e.id})),[n]),x=e=>{if(!u)return null;let t=String(u.getValue(`target`)||``).trim();try{let e=q(t);return u.setValues({host:e.host,ip:e.ip,domain:e.domain,port:e.port||void 0,protocol:e.protocol}),g.current=t,e}catch(t){return e&&h(t.message),null}},S=()=>{let e=u.getValue(),n=String(e.target||``).trim(),r={host:String(e.host||``).trim(),ip:String(e.ip||``).trim().toLowerCase(),domain:String(e.domain||``).trim(),port:Number(e.port||0),protocol:String(e.protocol||``).trim().toLowerCase(),title:String(e.title||``).trim(),server:String(e.server||``).trim(),status:e.status||`active`,source:t?.source||`manual`,source_query:t?.source_query||``,country:String(e.country||``).trim(),province:String(e.province||``).trim(),city:String(e.city||``).trim(),responsible_person:String(e.responsible_person||``).trim(),department:String(e.department||``).trim(),business_system:String(e.business_system||``).trim(),environment:e.environment||``,criticality:e.criticality||``,project_id:e.project_id||``,tags:Array.isArray(e.tags)?e.tags.map(e=>String(e).trim()).filter(Boolean):[]};if(n&&n!==g.current)try{let e=q(n);r={...r,host:r.host||e.host,ip:e.ip||r.ip,domain:e.domain||r.domain,port:e.port||r.port,protocol:e.protocol||r.protocol}}catch(e){throw Error(e.message)}return r},C=async()=>{if(f||!u)return;h(``);try{await u.validate()}catch{return}let e;try{e=S()}catch(e){h(e.message);return}p(!0);try{if(y)await E.put(`/assets/${encodeURIComponent(t.id)}`,e),N(a(`assets.updatedSuccessfully`,null,`资产已更新`));else{let t=await E.post(`/assets/import`,{assets:[e],source:`manual`}),n=Number(t?.created||0),r=Number(t?.updated||0),i=Number(t?.skipped||0);if(!n&&!r&&i)throw Error(a(`assets.assetSkipped`,null,`资产未保存,可能已存在且你没有更新权限`));N(n?a(`assets.createdSuccessfully`,null,`资产已添加`):a(`assets.duplicateMerged`,null,`资产已存在,信息已安全合并`))}i?.(),r?.()}catch(e){h(O(e,a(`assets.saveFailed`,null,`保存资产失败`)))}finally{p(!1)}};return(0,X.jsxs)(o,{visible:e,title:y?a(`assets.editAssetTitle`,null,`编辑资产`):a(`assets.addAssetTitle`,null,`新增资产`),width:760,onCancel:r,onOk:C,okText:y?a(`common.save`,null,`保存`):a(`assets.addAssetAction`,null,`添加资产`),confirmLoading:f,closeOnEsc:!0,maskClosable:!1,children:[m&&(0,X.jsx)(l,{type:`danger`,bordered:!0,closeIcon:null,description:m,className:`asset-library-form-error`}),(0,X.jsxs)(_,{className:Pe,initValues:v,getFormApi:d,labelPosition:`top`,onSubmit:C,children:[(0,X.jsx)(`div`,{className:`asset-library-form-grid asset-library-form-grid--full`,children:(0,X.jsx)(_.Input,{field:`target`,label:a(`assets.assetAddress`,null,`资产地址`),placeholder:`https://example.com:443 / example.com / 1.1.1.1:22`,helpText:a(`assets.assetAddressHint`,null,`可识别的 URL、域名、IP 和端口会自动解析`),onBlur:()=>x(!0),rules:[{required:!0,message:a(`assets.targetRequired`,null,`请输入资产地址`)},{validator:(e,t,n)=>{try{q(t),n()}catch(e){n(Error(e.message))}}}]})}),(0,X.jsxs)(`div`,{className:`asset-library-form-grid`,children:[(0,X.jsx)(_.Input,{field:`host`,label:a(`assets.hostUrl`,null,`完整 URL / Host`)}),(0,X.jsx)(_.Input,{field:`ip`,label:`IP`,rules:[{validator:(e,t,n)=>{!t||be(t)||F(t)?n():n(Error(a(`assets.ipInvalid`,null,`IP 地址格式无效`)))}}]}),(0,X.jsx)(_.Input,{field:`domain`,label:a(`assets.domain`,null,`域名`),rules:[{validator:(e,t,n)=>{!t||xe(t)&&!be(t)&&!F(t)?n():n(Error(a(`assets.domainInvalid`,null,`域名格式无效`)))}}]}),(0,X.jsx)(_.InputNumber,{field:`port`,label:a(`assets.port`,null,`端口`),min:0,max:65535,style:{width:`100%`}}),(0,X.jsx)(_.Input,{field:`protocol`,label:a(`assets.protocol`,null,`协议`),rules:[{validator:(e,t,n)=>{!t||/^[a-z][a-z0-9+.-]{0,31}$/.test(String(t).toLowerCase())?n():n(Error(a(`assets.protocolInvalid`,null,`协议格式无效`)))}}]}),(0,X.jsx)(_.Input,{field:`title`,label:a(`assets.pageTitle`,null,`页面标题`)}),(0,X.jsx)(_.Input,{field:`server`,label:a(`assets.serverProduct`,null,`服务 / 产品`)}),(0,X.jsx)(_.Select,{field:`project_id`,label:a(`assets.project`,null,`所属项目`),optionList:b,filter:!0,showClear:!0,placeholder:a(`assets.unboundProject`,null,`暂不绑定`)}),(0,X.jsx)(_.Select,{field:`status`,label:a(`assets.status`,null,`状态`),optionList:H}),(0,X.jsx)(_.Select,{field:`environment`,label:a(`assets.environment`,null,`环境`),optionList:De,showClear:!0,placeholder:`—`}),(0,X.jsx)(_.Select,{field:`criticality`,label:a(`assets.criticality`,null,`重要性`),optionList:P,showClear:!0,placeholder:`—`}),(0,X.jsx)(_.Input,{field:`country`,label:a(`assets.country`,null,`国家/地区`)}),(0,X.jsx)(_.Input,{field:`province`,label:a(`assets.province`,null,`省份/州`)}),(0,X.jsx)(_.Input,{field:`city`,label:a(`assets.city`,null,`城市`)}),(0,X.jsx)(_.Input,{field:`responsible_person`,label:a(`assets.responsiblePerson`,null,`负责人`)}),(0,X.jsx)(_.Input,{field:`department`,label:a(`assets.department`,null,`部门`)}),(0,X.jsx)(_.Input,{field:`business_system`,label:a(`assets.businessSystem`,null,`业务系统`)})]}),(0,X.jsx)(_.TagInput,{field:`tags`,label:a(`assets.tagsLabel`,null,`标签`),placeholder:a(`assets.tagsPlaceholder`,null,`输入后按回车或逗号`),max:30,maxLength:64,addOnBlur:!0,separator:`,,`,style:{width:`100%`}}),(0,X.jsx)(c,{className:`asset-library-editor-actions`,children:(0,X.jsx)(s,{theme:`borderless`,onClick:()=>x(!0),children:a(`assets.parseTarget`,null,`解析资产地址`)})})]},`${t?.id||`new-asset`}-${e?`open`:`closed`}`)]})}var Ie={host:500,title:500,domain:253,protocol:32,server:255,country:255,province:255,city:255,responsible_person:255,department:255,business_system:255};function Le(e){return String(e??``).replace(/^\uFEFF/,``).trim().toLowerCase().replace(/[\s_\-/.()()]+/g,``)}function Re(e){let t=Le(e);return t&&Ee.find(e=>(_e[e]||[]).some(e=>Le(e)===t))||``}function ze(e){let t=String(e??``).replace(/^\uFEFF/,``),n=[],r=[],i=``,a=!1;for(let e=0;e{l(e.q||``)},[e.q]);let u=(0,Y.useMemo)(()=>(t||[]).map(e=>({value:e.id,label:e.name||e.id})),[t]),d=[`status`,`risk_level`,`environment`,`criticality`,`ip`,`domain`,`port`,`scan`].filter(t=>e[t]).length;return(0,X.jsxs)(`div`,{className:`asset-library-filters`,children:[(0,X.jsxs)(`div`,{className:`asset-library-filter-grid`,children:[(0,X.jsx)(f,{prefix:(0,X.jsx)(C,{}),value:o,disabled:i,placeholder:a(`assets.searchPlaceholder`,null,`搜索主机、IP、域名、标题、服务或标签`),onChange:e=>{l(e),n({q:e})},showClear:!0}),(0,X.jsx)(p,{value:e.protocol||void 0,placeholder:a(`assets.assetType`,null,`类型 / 协议`),optionList:J,filter:!0,allowCreate:!0,showClear:!0,disabled:i,onChange:e=>n({protocol:e||``})}),(0,X.jsx)(f,{value:e.source,placeholder:a(`assets.source`,null,`来源`),disabled:i,onChange:e=>n({source:e}),showClear:!0}),(0,X.jsx)(p,{value:e.project_id||void 0,placeholder:a(`assets.project`,null,`所属项目`),optionList:u,filter:!0,showClear:!0,disabled:i,onChange:e=>n({project_id:e||``})}),(0,X.jsx)(f,{value:e.tag,placeholder:a(`assets.tagsLabel`,null,`标签`),disabled:i,onChange:e=>n({tag:e}),showClear:!0}),(0,X.jsx)(c,{spacing:8,className:`asset-library-filter-actions`,children:(0,X.jsx)(s,{onClick:r,disabled:i,children:a(`assets.resetFilters`,null,`重置`)})})]}),(0,X.jsx)(y,{className:`asset-library-filter-advanced`,keepDOM:!1,children:(0,X.jsx)(y.Panel,{itemKey:`advanced`,header:`${a(`assets.advancedFilters`,null,`高级筛选`)}${d?`(${d})`:``}`,children:(0,X.jsxs)(`div`,{className:`asset-library-filter-grid asset-library-filter-grid--advanced`,children:[(0,X.jsx)(p,{value:e.status||void 0,placeholder:a(`assets.allStatuses`,null,`全部状态`),optionList:H,showClear:!0,disabled:i,onChange:e=>n({status:e||``})}),(0,X.jsx)(p,{value:e.risk_level||void 0,placeholder:a(`assets.allRisks`,null,`全部风险`),optionList:ve,showClear:!0,disabled:i,onChange:e=>n({risk_level:e||``})}),(0,X.jsx)(p,{value:e.environment||void 0,placeholder:a(`assets.allEnvironments`,null,`全部环境`),optionList:De,showClear:!0,disabled:i,onChange:e=>n({environment:e||``})}),(0,X.jsx)(p,{value:e.criticality||void 0,placeholder:a(`assets.allCriticalities`,null,`全部级别`),optionList:P,showClear:!0,disabled:i,onChange:e=>n({criticality:e||``})}),(0,X.jsx)(f,{value:e.ip,placeholder:`IP`,disabled:i,onChange:e=>n({ip:e}),showClear:!0}),(0,X.jsx)(f,{value:e.domain,placeholder:a(`assets.domain`,null,`域名`),disabled:i,onChange:e=>n({domain:e}),showClear:!0}),(0,X.jsx)(f,{value:e.port,placeholder:a(`assets.port`,null,`端口`),disabled:i,onChange:e=>n({port:String(e||``).replace(/[^\d]/g,``)}),showClear:!0}),(0,X.jsx)(p,{value:e.scan||``,placeholder:a(`assets.scanState`,null,`扫描状态`),optionList:fe,disabled:i,onChange:e=>n({scan:e||``})}),(0,X.jsx)(p,{value:e.sort||`last_seen_at:desc`,optionList:de,disabled:i,onChange:e=>n({sort:e||`last_seen_at:desc`})})]})})})]})}var{Text:je}=d;function Me({assets:e,loading:t,total:n,page:r,pageSize:i,onPageChange:a,onPageSizeChange:o,selectedRowKeys:l,onSelectionChange:u,onView:d,onEdit:f,onDelete:p,onRefresh:m,canWrite:h,canDelete:g}){let _=D(),v=e=>{ce({title:_(`assets.deleteConfirm`,null,`确定删除该资产吗?`),content:K(e),okText:_(`common.delete`,null,`删除`),onOk:()=>{Promise.resolve(p(e)).catch(e=>A(e,_(`assets.deleteFailed`,null,`删除资产失败`)))}})},y=[{title:_(`assets.target`,null,`目标`),dataIndex:`host`,width:260,render:(e,t)=>(0,X.jsxs)(`div`,{className:`asset-library-target`,children:[(0,X.jsx)(B,{text:K(t),max:38}),(0,X.jsx)(je,{type:`tertiary`,size:`small`,children:[t.ip,t.domain].filter(Boolean).join(` · `)||`—`})]})},{title:_(`assets.service`,null,`服务`),dataIndex:`protocol`,width:150,render:(e,t)=>(0,X.jsx)(z,{protocol:t.protocol,port:t.port})},{title:_(`assets.project`,null,`所属项目`),dataIndex:`project_name`,width:160,render:e=>(0,X.jsx)(B,{text:e,max:18})},{title:_(`assets.source`,null,`来源`),dataIndex:`source`,width:120,render:e=>(0,X.jsx)(B,{text:e,max:14})},{title:_(`assets.riskLevel`,null,`风险等级`),dataIndex:`risk_level`,width:150,render:(e,t)=>(0,X.jsxs)(c,{spacing:6,children:[(0,X.jsx)(Se,{asset:t}),(0,X.jsx)(je,{type:`tertiary`,size:`small`,children:Number(t.vulnerability_count||0)})]})},{title:_(`assets.lastSeen`,null,`最近发现`),dataIndex:`last_seen_at`,width:170,render:e=>(0,X.jsx)(je,{size:`small`,children:T(e)})},{title:_(`common.actions`,null,`操作`),dataIndex:`id`,width:190,render:(e,t)=>(0,X.jsxs)(c,{spacing:4,children:[(0,X.jsx)(s,{theme:`borderless`,size:`small`,onClick:()=>d(t),children:_(`common.view`,null,`查看`)}),h&&(0,X.jsx)(s,{theme:`borderless`,size:`small`,onClick:()=>f(t),children:_(`common.edit`,null,`编辑`)}),g&&(0,X.jsx)(s,{theme:`borderless`,type:`danger`,size:`small`,onClick:()=>v(t),children:_(`common.delete`,null,`删除`)})]})}];return(0,X.jsx)(se,{columns:y,dataSource:e,loading:t,rowKey:`id`,onRefresh:m,rowSelection:{selectedRowKeys:l,onChange:(e,t)=>u(e,t)},pagination:{currentPage:r,pageSize:i,total:n||0,showSizeChanger:!0,pageSizeOpts:[10,20,50,100],onPageChange:a,onPageSizeChange:o},emptyText:_(`common.noData`,null,`暂无数据`)})}var{Text:Z}=d;function Ne({asset:e,visible:t,onClose:r,onEdit:i,onDelete:a,canWrite:o,canDelete:l}){let d=D(),f=n();if(!e)return null;let p=()=>{if(e.last_scan_task_id){f(`/vulnerabilities?task_id=${encodeURIComponent(e.last_scan_task_id)}`);return}if(e.last_scan_conversation_id){f(`/vulnerabilities?conversation_id=${encodeURIComponent(e.last_scan_conversation_id)}`);return}let t=e.host||e.domain||e.ip||``;f(t?`/vulnerabilities?host_q=${encodeURIComponent(t)}`:`/vulnerabilities`)},m=[{label:`Host`,value:e.host||`—`},{label:`IP`,value:e.ip||`—`},{label:d(`assets.domain`,null,`域名`),value:e.domain||`—`},{label:d(`assets.service`,null,`服务`),value:(0,X.jsx)(z,{protocol:e.protocol,port:e.port})},{label:d(`assets.project`,null,`所属项目`),value:e.project_name||e.project_id||`—`},{label:d(`assets.status`,null,`状态`),value:(0,X.jsx)(R,{status:e.status})},{label:d(`assets.riskLevel`,null,`风险等级`),value:(0,X.jsx)(Se,{asset:e})},{label:d(`assets.environment`,null,`环境`),value:pe(e.environment)||`—`},{label:d(`assets.criticality`,null,`重要性`),value:V(e.criticality)||`—`},{label:d(`assets.location`,null,`地区`),value:[e.country,e.province,e.city].filter(Boolean).join(` / `)||`—`},{label:d(`assets.responsiblePerson`,null,`负责人`),value:e.responsible_person||`—`},{label:d(`assets.department`,null,`部门`),value:e.department||`—`},{label:d(`assets.businessSystem`,null,`业务系统`),value:e.business_system||`—`},{label:d(`assets.title`,null,`标题/指纹`),value:e.title||`—`},{label:d(`assets.server`,null,`服务指纹`),value:e.server||`—`},{label:d(`assets.source`,null,`来源`),value:e.source||`—`},{label:d(`assets.sourceQuery`,null,`来源查询`),value:e.source_query?(0,X.jsx)(Z,{code:!0,size:`small`,children:e.source_query}):`—`},{label:d(`assets.tagsLabel`,null,`标签`),value:(0,X.jsx)(W,{tags:e.tags,max:6})},{label:d(`assets.firstSeen`,null,`首次发现`),value:T(e.first_seen_at)},{label:d(`assets.lastSeen`,null,`最近发现`),value:T(e.last_seen_at)},{label:d(`assets.lastScan`,null,`上次扫描`),value:T(e.last_scan_at)},{label:`创建时间`,value:T(e.created_at)},{label:`更新时间`,value:T(e.updated_at)},{label:`资产 ID`,value:(0,X.jsx)(Z,{copyable:{content:e.id},size:`small`,children:e.id})}];return(0,X.jsxs)(h,{visible:t,onCancel:r,title:d(`assets.detailTitle`,null,`资产详情`),width:620,placement:`right`,footer:(0,X.jsxs)(c,{children:[o&&(0,X.jsx)(s,{onClick:()=>i(e),children:d(`common.edit`,null,`编辑`)}),l&&(0,X.jsx)(s,{type:`danger`,onClick:()=>a(e),children:d(`common.delete`,null,`删除`)}),(0,X.jsx)(s,{theme:`borderless`,onClick:r,children:d(`common.close`,null,`关闭`)})]}),children:[(0,X.jsxs)(`div`,{className:`asset-library-detail-target`,children:[(0,X.jsxs)(`div`,{className:`asset-library-detail-target-main`,children:[(0,X.jsx)(Z,{strong:!0,size:`large`,children:K(e)}),(0,X.jsx)(M,{text:K(e)})]}),(0,X.jsx)(Z,{type:`tertiary`,children:[e.ip,e.domain,G(e)].filter(Boolean).join(` · `)||`—`}),(0,X.jsxs)(c,{spacing:6,wrap:!0,className:`asset-library-detail-badges`,children:[(0,X.jsx)(R,{status:e.status}),(0,X.jsx)(Se,{asset:e}),(0,X.jsxs)(Z,{type:`tertiary`,size:`small`,children:[d(`assets.relatedVulnerabilities`,null,`相关漏洞`),`:`,Number(e.vulnerability_count||0),e.risk_level?`(${me(e.risk_level)})`:``]})]})]}),(0,X.jsx)(u,{margin:`12px`}),(0,X.jsx)(j,{items:m,columns:2}),(0,X.jsx)(u,{margin:`12px`}),(0,X.jsxs)(c,{children:[(0,X.jsx)(s,{theme:`light`,onClick:p,children:d(`assets.viewRelatedVulnerabilities`,null,`查看关联漏洞`)}),e.project_id&&(0,X.jsx)(s,{theme:`borderless`,onClick:()=>f(`/projects?id=${encodeURIComponent(e.project_id)}`),children:d(`assets.viewProject`,null,`查看项目`)})]})]})}var Pe=`asset-library-editor`;function Q(e){return{target:U(e),host:e?.host||``,ip:e?.ip||``,domain:e?.domain||``,port:e?.port??void 0,protocol:e?.protocol||``,title:e?.title||``,server:e?.server||``,project_id:e?.project_id||``,status:e?.status||`active`,environment:e?.environment||``,criticality:e?.criticality||``,country:e?.country||``,province:e?.province||``,city:e?.city||``,responsible_person:e?.responsible_person||``,department:e?.department||``,business_system:e?.business_system||``,tags:Array.isArray(e?.tags)?e.tags:[]}}function Fe({visible:e,asset:t,projects:n,onClose:r,onSaved:i}){let a=D(),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(``),g=(0,Y.useRef)(U(t)),v=(0,Y.useMemo)(()=>Q(t),[t,e]),y=!!t?.id;(0,Y.useEffect)(()=>{e&&(g.current=U(t),h(``),p(!1))},[e,t]);let b=(0,Y.useMemo)(()=>(n||[]).map(e=>({value:e.id,label:e.name||e.id})),[n]),x=e=>{if(!u)return null;let t=String(u.getValue(`target`)||``).trim();try{let e=q(t);return u.setValues({host:e.host,ip:e.ip,domain:e.domain,port:e.port||void 0,protocol:e.protocol}),g.current=t,e}catch(t){return e&&h(t.message),null}},S=()=>{let e=u.getValue(),n=String(e.target||``).trim(),r={host:String(e.host||``).trim(),ip:String(e.ip||``).trim().toLowerCase(),domain:String(e.domain||``).trim(),port:Number(e.port||0),protocol:String(e.protocol||``).trim().toLowerCase(),title:String(e.title||``).trim(),server:String(e.server||``).trim(),status:e.status||`active`,source:t?.source||`manual`,source_query:t?.source_query||``,country:String(e.country||``).trim(),province:String(e.province||``).trim(),city:String(e.city||``).trim(),responsible_person:String(e.responsible_person||``).trim(),department:String(e.department||``).trim(),business_system:String(e.business_system||``).trim(),environment:e.environment||``,criticality:e.criticality||``,project_id:e.project_id||``,tags:Array.isArray(e.tags)?e.tags.map(e=>String(e).trim()).filter(Boolean):[]};if(n&&n!==g.current)try{let e=q(n);r={...r,host:r.host||e.host,ip:e.ip||r.ip,domain:e.domain||r.domain,port:e.port||r.port,protocol:e.protocol||r.protocol}}catch(e){throw Error(e.message)}return r},C=async()=>{if(f||!u)return;h(``);try{await u.validate()}catch{return}let e;try{e=S()}catch(e){h(e.message);return}p(!0);try{if(y)await E.put(`/assets/${encodeURIComponent(t.id)}`,e),N(a(`assets.updatedSuccessfully`,null,`资产已更新`));else{let t=await E.post(`/assets/import`,{assets:[e],source:`manual`}),n=Number(t?.created||0),r=Number(t?.updated||0),i=Number(t?.skipped||0);if(!n&&!r&&i)throw Error(a(`assets.assetSkipped`,null,`资产未保存,可能已存在且你没有更新权限`));N(n?a(`assets.createdSuccessfully`,null,`资产已添加`):a(`assets.duplicateMerged`,null,`资产已存在,信息已安全合并`))}i?.(),r?.()}catch(e){h(O(e,a(`assets.saveFailed`,null,`保存资产失败`)))}finally{p(!1)}};return(0,X.jsxs)(o,{visible:e,title:y?a(`assets.editAssetTitle`,null,`编辑资产`):a(`assets.addAssetTitle`,null,`新增资产`),width:760,onCancel:r,onOk:C,okText:y?a(`common.save`,null,`保存`):a(`assets.addAssetAction`,null,`添加资产`),confirmLoading:f,closeOnEsc:!0,maskClosable:!1,children:[m&&(0,X.jsx)(l,{type:`danger`,bordered:!0,closeIcon:null,description:m,className:`asset-library-form-error`}),(0,X.jsxs)(_,{className:Pe,initValues:v,getFormApi:d,labelPosition:`top`,onSubmit:C,children:[(0,X.jsx)(`div`,{className:`asset-library-form-grid asset-library-form-grid--full`,children:(0,X.jsx)(_.Input,{field:`target`,label:a(`assets.assetAddress`,null,`资产地址`),placeholder:`https://example.com:443 / example.com / 1.1.1.1:22`,helpText:a(`assets.assetAddressHint`,null,`可识别的 URL、域名、IP 和端口会自动解析`),onBlur:()=>x(!0),rules:[{required:!0,message:a(`assets.targetRequired`,null,`请输入资产地址`)},{validator:(e,t,n)=>{try{q(t),n()}catch(e){n(Error(e.message))}}}]})}),(0,X.jsxs)(`div`,{className:`asset-library-form-grid`,children:[(0,X.jsx)(_.Input,{field:`host`,label:a(`assets.hostUrl`,null,`完整 URL / Host`)}),(0,X.jsx)(_.Input,{field:`ip`,label:`IP`,rules:[{validator:(e,t,n)=>{!t||be(t)||F(t)?n():n(Error(a(`assets.ipInvalid`,null,`IP 地址格式无效`)))}}]}),(0,X.jsx)(_.Input,{field:`domain`,label:a(`assets.domain`,null,`域名`),rules:[{validator:(e,t,n)=>{!t||xe(t)&&!be(t)&&!F(t)?n():n(Error(a(`assets.domainInvalid`,null,`域名格式无效`)))}}]}),(0,X.jsx)(_.InputNumber,{field:`port`,label:a(`assets.port`,null,`端口`),min:0,max:65535,style:{width:`100%`}}),(0,X.jsx)(_.Input,{field:`protocol`,label:a(`assets.protocol`,null,`协议`),rules:[{validator:(e,t,n)=>{!t||/^[a-z][a-z0-9+.-]{0,31}$/.test(String(t).toLowerCase())?n():n(Error(a(`assets.protocolInvalid`,null,`协议格式无效`)))}}]}),(0,X.jsx)(_.Input,{field:`title`,label:a(`assets.pageTitle`,null,`页面标题`)}),(0,X.jsx)(_.Input,{field:`server`,label:a(`assets.serverProduct`,null,`服务 / 产品`)}),(0,X.jsx)(_.Select,{field:`project_id`,label:a(`assets.project`,null,`所属项目`),optionList:b,filter:!0,showClear:!0,placeholder:a(`assets.unboundProject`,null,`暂不绑定`)}),(0,X.jsx)(_.Select,{field:`status`,label:a(`assets.status`,null,`状态`),optionList:H}),(0,X.jsx)(_.Select,{field:`environment`,label:a(`assets.environment`,null,`环境`),optionList:De,showClear:!0,placeholder:`—`}),(0,X.jsx)(_.Select,{field:`criticality`,label:a(`assets.criticality`,null,`重要性`),optionList:P,showClear:!0,placeholder:`—`}),(0,X.jsx)(_.Input,{field:`country`,label:a(`assets.country`,null,`国家/地区`)}),(0,X.jsx)(_.Input,{field:`province`,label:a(`assets.province`,null,`省份/州`)}),(0,X.jsx)(_.Input,{field:`city`,label:a(`assets.city`,null,`城市`)}),(0,X.jsx)(_.Input,{field:`responsible_person`,label:a(`assets.responsiblePerson`,null,`负责人`)}),(0,X.jsx)(_.Input,{field:`department`,label:a(`assets.department`,null,`部门`)}),(0,X.jsx)(_.Input,{field:`business_system`,label:a(`assets.businessSystem`,null,`业务系统`)})]}),(0,X.jsx)(_.TagInput,{field:`tags`,label:a(`assets.tagsLabel`,null,`标签`),placeholder:a(`assets.tagsPlaceholder`,null,`输入后按回车或逗号`),max:30,maxLength:64,addOnBlur:!0,separator:`,,`,style:{width:`100%`}}),(0,X.jsx)(c,{className:`asset-library-editor-actions`,children:(0,X.jsx)(s,{theme:`borderless`,onClick:()=>x(!0),children:a(`assets.parseTarget`,null,`解析资产地址`)})})]},`${t?.id||`new-asset`}-${e?`open`:`closed`}`)]})}var Ie={host:500,title:500,domain:253,protocol:32,server:255,country:255,province:255,city:255,responsible_person:255,department:255,business_system:255};function Le(e){return String(e??``).replace(/^\uFEFF/,``).trim().toLowerCase().replace(/[\s_\-/.()()]+/g,``)}function Re(e){let t=Le(e);return t&&Ee.find(e=>(_e[e]||[]).some(e=>Le(e)===t))||``}function ze(e){let t=String(e??``).replace(/^\uFEFF/,``),n=[],r=[],i=``,a=!1;for(let e=0;ee.some(e=>String(e??``).trim()!==``))}function Be(e,t,n=``){let r=String(e??``).trim();if(!r)return n;let i=r.toLowerCase();if(t[i])return i;let a=Object.entries(t).find(([,e])=>e===r);return a?a[0]:null}function Ve(e,t){let n=String(e??``).trim();if(!n)return{projectId:``,projectName:``,error:``};let r=n.toLowerCase(),i=(t||[]).find(e=>String(e.id).toLowerCase()===r||String(e.name||``).trim().toLowerCase()===r);return i?{projectId:i.id,projectName:i.name,error:``}:{projectId:``,projectName:``,error:`项目不存在或无权访问:${n}`}}function He(e,t,{projects:n,source:r}){let i=n=>({rowNumber:t,values:e,asset:null,error:n}),a=e.target||e.host||e.domain||e.ip||``;if(!a)return i(`缺少目标地址`);let o;try{o=q(a)}catch(e){return i(e.message)}let s=String(e.port??``).trim(),c=Number(s===``?o.port||0:s);if(!Number.isInteger(c)||c<0||c>65535)return i(`端口必须在 0–65535 之间`);let l=String(e.ip||o.ip||``).trim().toLowerCase();if(l&&!be(l)&&!F(l))return i(`IP 地址格式无效`);let u=String(e.domain||o.domain||``).trim(),d=u?xe(u):``;if(u&&!d)return i(`域名格式无效`);let f=String(e.protocol||o.protocol||``).trim().toLowerCase();if(f&&!/^[a-z][a-z0-9+.-]{0,31}$/.test(f))return i(`协议格式无效`);let p=Be(e.status,he,`active`);if(!p)return i(`状态仅支持 active 或 inactive`);let m=Be(e.environment,Te,``);if(m===null)return i(`环境值无效`);let h=Be(e.criticality,ye,``);if(h===null)return i(`重要性值无效`);let g=Ve(e.project,n);if(g.error)return i(g.error);let _=L(e.tags);if(_.length>30)return i(`标签最多 30 个`);if(_.some(e=>Array.from(e).length>64))return i(`单个标签最多 64 个字符`);let v={host:String(e.host||o.host||``).trim(),ip:l,domain:d,port:c,protocol:f,title:String(e.title||``).trim(),server:String(e.server||``).trim(),country:String(e.country||``).trim(),province:String(e.province||``).trim(),city:String(e.city||``).trim(),responsible_person:String(e.responsible_person||``).trim(),department:String(e.department||``).trim(),business_system:String(e.business_system||``).trim(),environment:m,criticality:h,status:p,tags:_,project_id:g.projectId,source:r||`manual-import`},y=Object.keys(Ie).find(e=>Array.from(String(v[e]||``)).length>Ie[e]);if(y)return i(`字段 ${y} 内容过长`);let b=we(v);return b?i(b):{rowNumber:t,values:e,asset:v,projectName:g.projectName,error:``}}function Ue(e){let t=new Map;return e.map(e=>{if(e.error||!e.asset)return e;let n=Ce(e.asset);return t.has(n)?{...e,error:`与第 ${t.get(n)} 行重复`}:(t.set(n,e.rowNumber),e)})}function We(e,t={}){let n=ze(e);if(n.length<2)throw Error(`文件中没有可导入的数据`);let r=n[0].map(Re);if(!r.some(Boolean))throw Error(`未识别到模板字段,请检查表头`);let i=n.slice(1);if(i.length>1e5)throw Error(`数据不能超过 ${ue} 行`);return Ue(i.map((e,n)=>{let i={};return r.forEach((t,n)=>{t&&i[t]==null&&(i[t]=String(e[n]??``).trim())}),He(i,n+2,t)}))}function Ge(e,t={}){let n;try{n=JSON.parse(String(e??``))}catch(e){throw Error(`JSON 解析失败:`+e.message)}let r=(Array.isArray(n)?n:Array.isArray(n?.assets)?n.assets:[n]).filter(e=>e&&typeof e==`object`);if(!r.length)throw Error(`文件中没有可导入的数据`);if(r.length>1e5)throw Error(`数据不能超过 ${ue} 行`);return Ue(r.map((e,n)=>He({target:e.target||e.host||e.domain||e.ip||``,host:e.host,ip:e.ip,domain:e.domain,port:e.port,protocol:e.protocol,title:e.title,server:e.server,country:e.country,province:e.province,city:e.city,responsible_person:e.responsible_person,department:e.department,business_system:e.business_system,environment:e.environment,criticality:e.criticality,status:e.status,tags:Array.isArray(e.tags)?e.tags.join(`,`):e.tags,project:e.project_id||e.project||e.project_name},n+1,t)))}function Ke(){return`${Ee.join(`,`)}\r\n`}function qe(e){let t=String(e??``);return/[",\r\n]/.test(t)?`"${t.replaceAll(`"`,`""`)}"`:t}function Je(e,t){return t===`target`?K(e):t===`project`?e.project_name||e.project_id||``:t===`tags`?(e.tags||[]).join(`,`):t===`status`?ge(e.status):t===`environment`?pe(e.environment):t===`criticality`?V(e.criticality):t===`risk_level`?me(e.risk_level):t===`vulnerability_count`?Number(e.vulnerability_count||0):e[t]??``}function Ye(e){let t=[I.map(([,e])=>qe(e)).join(`,`)];return(e||[]).forEach(e=>{t.push(I.map(([t])=>qe(Je(e,t))).join(`,`))}),`\uFEFF${t.join(`\r
`)}`}function Xe(e,t,n=`text/csv;charset=utf-8`){let r=new Blob([t],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}var{Text:$}=d,Ze=e=>[{title:e(`assets.rowNumber`,null,`行号`),dataIndex:`rowNumber`,width:70},{title:e(`assets.target`,null,`目标`),dataIndex:`target`,render:(e,t)=>K(t.asset||{target:t.values?.target})},{title:e(`assets.project`,null,`所属项目`),dataIndex:`project`,render:(e,t)=>t.projectName||t.values?.project||`—`},{title:e(`assets.status`,null,`状态`),dataIndex:`status`,render:(e,t)=>t.asset?.status||t.values?.status||`—`},{title:e(`assets.validationResult`,null,`校验结果`),dataIndex:`error`,render:t=>t?(0,X.jsx)($,{type:`danger`,size:`small`,children:t}):(0,X.jsx)($,{type:`success`,size:`small`,children:e(`assets.validationPassed`,null,`通过`)})}];function Qe({visible:e,projects:t,onClose:n,onDone:r}){let i=D(),[a,u]=(0,Y.useState)(`csv`),[d,f]=(0,Y.useState)(``),[p,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(``),[v,y]=(0,Y.useState)(!1),x=(0,Y.useRef)(null),C=(0,Y.useMemo)(()=>{if(!String(d||``).trim())return{records:[],error:``};try{return{records:a===`csv`?We(d,{projects:t,source:`manual-import`}):Ge(d,{projects:t,source:`manual-import`}),error:``}}catch(e){return{records:[],error:e.message}}},[d,a,t]),w=C.records,T=w.filter(e=>!e.error),te=w.length-T.length,ne=g||C.error,k=()=>{f(``),h(``),u(`csv`),_(``),y(!1)},A=()=>{v||(k(),n?.())},j=async e=>{if(!e)return;_(``);let t=String(e.name||``),n=t.split(`.`).pop().toLowerCase();if(![`csv`,`json`,`txt`].includes(n))_(`仅支持 .csv / .json / .txt 文件`);else if(e.size>104857600)_(i(`assets.fileTooLarge`,null,`文件不能超过 100 MB`));else try{let r=await e.text();u(n===`json`?`json`:`csv`),f(r),h(t)}catch(e){_(O(e,i(`assets.fileParseFailed`,null,`无法解析文件,请确认文件格式正确`)))}};return(0,X.jsxs)(o,{visible:e,title:i(`assets.bulkImportTitle`,null,`批量导入资产`),width:880,onCancel:A,onOk:async()=>{if(!v&&T.length){_(``),y(!0);try{let e=await E.post(`/assets/import`,{assets:T.map(e=>e.asset),source:`manual-import`,source_query:p||`paste`}),t=Number(e?.skipped||0)+te;N(i(`assets.bulkImportDone`,{created:Number(e?.created||0),updated:Number(e?.updated||0),skipped:t},`导入完成:新增 ${Number(e?.created||0)} 条,更新 ${Number(e?.updated||0)} 条,跳过 ${t} 条`)),k(),r?.(),n?.()}catch(e){_(O(e,i(`assets.importFailed`,null,`资产入库失败`)))}finally{y(!1)}}},okText:i(`assets.importValidRowsCount`,{count:T.length},`导入 ${T.length} 条有效数据`),okButtonProps:{disabled:!T.length},confirmLoading:v,maskClosable:!1,children:[(0,X.jsx)($,{type:`tertiary`,children:i(`assets.bulkImportSubtitle`,null,`支持 CSV / JSON 文本粘贴或文件上传,提交前会先校验并预览数据`)}),ne&&(0,X.jsx)(l,{type:`danger`,bordered:!0,closeIcon:null,description:ne,className:`asset-library-form-error`}),(0,X.jsxs)(c,{vertical:!0,align:`start`,spacing:10,className:`asset-library-import-body`,children:[(0,X.jsxs)(c,{children:[(0,X.jsx)(S,{type:`button`,value:a,options:[{value:`csv`,label:`CSV`},{value:`json`,label:`JSON`}],onChange:e=>{u(e.target.value),_(``)}}),(0,X.jsx)(s,{icon:(0,X.jsx)(ee,{}),onClick:()=>x.current?.click(),children:i(`assets.chooseOrDropFile`,null,`选择文件`)}),(0,X.jsx)(`input`,{ref:x,type:`file`,accept:`.csv,.json,.txt`,className:`asset-library-file-input`,onChange:e=>{j(e.target.files?.[0]),e.target.value=``}}),(0,X.jsx)(s,{theme:`borderless`,onClick:()=>Xe(`asset-import-template.csv`,Ke()),children:i(`assets.downloadCsv`,null,`下载 CSV 模板`)}),p&&(0,X.jsx)($,{type:`tertiary`,size:`small`,children:p})]}),(0,X.jsx)(m,{value:d,rows:8,className:`asset-library-import-textarea`,placeholder:a===`csv`?`target,project,tags,host,ip,domain,port,protocol,title,server,country,province,city,responsible_person,department,business_system,environment,criticality,status`:`[{"host":"https://example.com","ip":"1.1.1.1","port":443,"protocol":"https","tags":["prod"]}]`,onChange:e=>{f(e),_(``)}}),w.length>0&&(0,X.jsxs)(`div`,{className:`asset-library-import-preview`,children:[(0,X.jsx)($,{strong:!0,children:i(`assets.importPreviewSummary`,{total:w.length,valid:T.length,invalid:te},`共 ${w.length} 行,${T.length} 行有效,${te} 行需修正`)}),(0,X.jsx)(b,{columns:Ze(i),dataSource:w.slice(0,10).map((e,t)=>({...e,id:t})),rowKey:`id`,size:`small`,pagination:!1}),w.length>10&&(0,X.jsx)($,{type:`tertiary`,size:`small`,children:i(`assets.previewLimitedShort`,{count:w.length},`仅展示前 10 行;提交时将处理全部 ${w.length} 行`)})]})]})]})}var{Text:$e}=d;function et({visible:e,assets:t,onClose:n,onDone:r}){let i=D(),a=(0,Y.useMemo)(()=>Array.isArray(t)?t:[],[t]),[s,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{e&&(u(a[0]?.id||``),f(``),m(!1))},[e,a]),(0,X.jsxs)(o,{visible:e,title:i(`assets.mergeDuplicates`,null,`合并重复资产`),width:560,onCancel:n,onOk:async()=>{if(!(p||a.length<2)){m(!0),f(``);try{let e=await E.post(`/assets/merge`,{asset_ids:a.map(e=>e.id),primary_id:s||a[0].id});N(`已合并 ${Number(e?.merged||a.length)} 个资产`),r?.(),n?.()}catch(e){f(O(e,`合并资产失败`))}finally{m(!1)}}},okText:i(`assets.merge`,null,`合并`),okButtonProps:{disabled:a.length<2},confirmLoading:p,maskClosable:!1,children:[a.length<2?(0,X.jsx)(l,{type:`warning`,bordered:!0,closeIcon:null,description:i(`assets.mergeRequiresMultiple`,null,`请至少选择两个重复资产`)}):(0,X.jsxs)(c,{vertical:!0,align:`start`,spacing:8,style:{width:`100%`},children:[(0,X.jsx)($e,{type:`tertiary`,children:i(`assets.mergeHint`,null,`将保留一个主资产,其余资产的空字段与标签会合并进来,然后删除被合并记录。所选资产必须共享域名、IP 或 Host。`)}),(0,X.jsx)(S,{value:s,onChange:e=>u(e.target.value),children:(0,X.jsx)(c,{vertical:!0,align:`start`,spacing:4,children:a.map(e=>(0,X.jsxs)(g,{value:e.id,children:[K(e),e.project_name?` · ${e.project_name}`:``]},e.id))})})]}),d&&(0,X.jsx)(l,{type:`danger`,bordered:!0,closeIcon:null,description:d,className:`asset-library-form-error`})]})}var{Text:tt}=d;function nt({visible:e,projects:t,assetIds:n,onClose:r,onDone:i}){let a=D(),[s,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(!1),v=(0,Y.useMemo)(()=>Array.isArray(n)?n:[],[n]),y=(0,Y.useMemo)(()=>(t||[]).map(e=>({value:e.id,label:e.name||e.id})),[t]);return(0,Y.useEffect)(()=>{e&&(u(``),f(!1),h(``),_(!1))},[e]),(0,X.jsxs)(o,{visible:e,title:a(`assets.bindProjectTitle`,null,`绑定项目`),width:520,onCancel:r,onOk:async()=>{if(!g&&v.length){if(!d&&!s)h(a(`assets.selectProjectRequired`,null,`请选择要绑定的项目`));else{_(!0),h(``);try{await E.put(`/assets/project-binding`,{asset_ids:v,project_id:d?``:s}),N(a(`assets.bindProjectDone`,{count:v.length},`已更新 ${v.length} 个资产`)),i?.(),r?.()}catch(e){h(O(e,a(`assets.bindProjectFailed`,null,`绑定项目失败`)))}finally{_(!1)}}}},okText:d?a(`assets.unbindProject`,null,`解除绑定`):a(`assets.confirmBinding`,null,`确认绑定`),confirmLoading:g,maskClosable:!1,children:[(0,X.jsxs)(c,{vertical:!0,align:`start`,spacing:10,style:{width:`100%`},children:[(0,X.jsx)(tt,{type:`tertiary`,children:a(`assets.bindProjectCount`,{count:v.length},`将更新 ${v.length} 个资产`)}),(0,X.jsx)(p,{value:s||void 0,optionList:y,filter:!0,showClear:!0,disabled:d,placeholder:a(`assets.chooseProject`,null,`请选择项目`),onChange:e=>u(e||``),style:{width:`100%`}}),(0,X.jsxs)(c,{children:[(0,X.jsx)(w,{checked:d,onChange:f,size:`small`}),(0,X.jsx)(tt,{size:`small`,children:a(`assets.unbindProject`,null,`解除项目绑定`)})]}),(0,X.jsx)(tt,{type:`tertiary`,size:`small`,children:a(`assets.bindProjectHint`,null,`所选资产将统一更新为该项目归属。`)})]}),m&&(0,X.jsx)(l,{type:`danger`,bordered:!0,closeIcon:null,description:m,className:`asset-library-form-error`})]})}var{Text:rt}=d,it={status:``,environment:``,criticality:``,responsible_person:``,department:``,business_system:``,add_tags:``,remove_tags:``};function at({visible:e,assetIds:t,onClose:n,onDone:r}){let i=D(),[a,s]=(0,Y.useState)(it),[c,u]=(0,Y.useState)(``),[d,m]=(0,Y.useState)(!1),h=(0,Y.useMemo)(()=>Array.isArray(t)?t:[],[t]);(0,Y.useEffect)(()=>{e&&(s(it),u(``),m(!1))},[e]);let g=e=>s(t=>({...t,...e}));return(0,X.jsxs)(o,{visible:e,title:i(`assets.bulkEdit`,null,`批量编辑`),width:620,onCancel:n,onOk:async()=>{if(d||!h.length)return;let e={asset_ids:h};[`status`,`environment`,`criticality`,`responsible_person`,`department`,`business_system`].forEach(t=>{let n=String(a[t]||``).trim();n&&(e[t]=n)});let t=L(a.add_tags),i=L(a.remove_tags);if(t.length&&(e.add_tags=t),i.length&&(e.remove_tags=i),Object.keys(e).length===1)u(`请至少填写一项需要修改的内容`);else{m(!0),u(``);try{let t=await E.put(`/assets/bulk`,e);N(`已更新 ${Number(t?.updated||h.length)} 个资产`),r?.(),n?.()}catch(e){u(O(e,`批量编辑失败`))}finally{m(!1)}}},confirmLoading:d,maskClosable:!1,children:[(0,X.jsxs)(rt,{type:`tertiary`,children:[`将修改 `,h.length,` 个资产;空白字段保持原值。`]}),(0,X.jsxs)(`div`,{className:`asset-library-form-grid asset-library-form-grid--bulk`,children:[(0,X.jsx)(p,{value:a.status||void 0,placeholder:i(`assets.status`,null,`状态`),optionList:H,showClear:!0,onChange:e=>g({status:e||``})}),(0,X.jsx)(p,{value:a.environment||void 0,placeholder:i(`assets.environment`,null,`环境`),optionList:De,showClear:!0,onChange:e=>g({environment:e||``})}),(0,X.jsx)(p,{value:a.criticality||void 0,placeholder:i(`assets.criticality`,null,`重要性`),optionList:P,showClear:!0,onChange:e=>g({criticality:e||``})}),(0,X.jsx)(f,{value:a.responsible_person,placeholder:i(`assets.responsiblePerson`,null,`负责人`),onChange:e=>g({responsible_person:e})}),(0,X.jsx)(f,{value:a.department,placeholder:i(`assets.department`,null,`部门`),onChange:e=>g({department:e})}),(0,X.jsx)(f,{value:a.business_system,placeholder:i(`assets.businessSystem`,null,`业务系统`),onChange:e=>g({business_system:e})}),(0,X.jsx)(f,{value:a.add_tags,placeholder:`追加标签(逗号分隔)`,onChange:e=>g({add_tags:e})}),(0,X.jsx)(f,{value:a.remove_tags,placeholder:`移除标签(逗号分隔)`,onChange:e=>g({remove_tags:e})})]}),c&&(0,X.jsx)(l,{type:`danger`,bordered:!0,closeIcon:null,description:c,className:`asset-library-form-error`})]})}function ot(){let{data:e,loading:t,reload:n}=k(()=>E.get(`/projects`,{limit:200}),[],{initial:{projects:[]}});return{projects:Array.isArray(e?.projects)?e.projects:[],loading:t,reload:n}}var{Text:st}=d;function ct(e,t,n){let r={page:t,page_size:n,q:e.q,protocol:e.protocol,source:e.source,project_id:e.project_id,tag:e.tag,status:e.status,risk_level:e.risk_level,environment:e.environment,criticality:e.criticality,ip:e.ip,domain:e.domain,port:e.port};r=le(r,e.scan);let[i,a]=String(e.sort||`last_seen_at:desc`).split(`:`);return r.sort_by=i,r.sort_order=a||`desc`,r}function lt(){let e=D(),{hasPermission:t}=te(),n=t(`asset:read`),i=t(`asset:write`),o=t(`asset:delete`),[u,d]=a(),f=r(),p=u.get(`id`)||``,m=f.state?.asset||null,[h,g]=(0,Y.useState)(()=>({...ke(),q:u.get(`q`)||``})),[_,y]=(0,Y.useState)(1),[b,S]=(0,Y.useState)(20),[C,w]=(0,Y.useState)(0),[T,O]=(0,Y.useState)({keys:[],rows:[]}),[j,M]=(0,Y.useState)(null),[se,le]=(0,Y.useState)(!1),[ue,de]=(0,Y.useState)(null),[fe,pe]=(0,Y.useState)(!1),[me,he]=(0,Y.useState)(!1),[ge,_e]=(0,Y.useState)(!1),[ve,P]=(0,Y.useState)(!1),[F,I]=(0,Y.useState)(!1),L=ae(h,300),R=(0,Y.useMemo)(()=>ct(L,_,b),[L,_,b]),{data:z,loading:ye,error:B,reload:be}=k(()=>E.get(`/assets`,R),[R,C],{skip:!n}),{projects:V,reload:H}=ot(),U=(0,Y.useMemo)(()=>Array.isArray(z?.assets)?z.assets:[],[z]),W=Number(z?.total||0),G=(0,Y.useRef)(``);(0,Y.useEffect)(()=>{p&&m?.id&&m.id===p&&G.current!==p&&(G.current=p,M(m))},[p,m]),(0,Y.useEffect)(()=>{if(!p||p===G.current)return;let e=U.find(e=>e.id===p);if(e){G.current=p,M(e);return}let t=!1;return(async()=>{for(let e=1;e<=5&&!t;e+=1){let n=await E.get(`/assets`,{page_size:100,page:e}),r=(n?.assets||[]).find(e=>e.id===p);if(r){t||(G.current=p,M(r));return}if(e>=Number(n?.total_pages||1))break}t||(G.current=p)})().catch(()=>{G.current=p}),()=>{t=!0}},[p,U]);let xe=e=>{g(t=>({...t,...e})),y(1),O({keys:[],rows:[]})},Se=()=>{g(ke()),y(1),O({keys:[],rows:[]})},K=()=>w(e=>e+1),q=e=>{let t=new URLSearchParams(u);e?t.set(`id`,e):t.delete(`id`),d(t,{replace:!0})},Ce=e=>{M(e),e?.id&&q(e.id)},we=()=>{M(null),p&&(G.current=``,q(``))},Te=e=>{de(e||null),le(!0),i&&H()},J=async()=>{O({keys:[],rows:[]}),await be()},Ee=async t=>{await E.del(`/assets/${encodeURIComponent(t.id)}`),N(e(`assets.deleted`,null,`资产已删除`)),j?.id===t.id&&we(),await J()},De=()=>{let t=T.keys;t.length&&ce({title:e(`assets.deleteConfirm`,null,`确定删除所选资产吗?`),content:`将永久删除 ${t.length} 个资产。`,okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{let e=await E.post(`/assets/batch-delete`,{asset_ids:t});N(`已删除 ${Number(e?.deleted||t.length)} 个资产`),await J()}catch(e){A(e,`批量删除失败`)}}})},Oe=(0,Y.useMemo)(()=>{let{page:e,page_size:t,...n}=ct(L,1,b);return n},[L,b]),je=async()=>{try{let t=await E.get(`/assets/selection`,Oe),n=Array.isArray(t?.assets)?t.assets:[];O({keys:n.map(e=>e.id),rows:n}),N(e(`assets.allResultsSelected`,{count:n.length},`已选择 ${n.length} 项`))}catch(e){A(e,`选择全部结果失败`)}},Z=async e=>{if(!F){I(!0);try{let t=T.rows;if(e){let e=await E.get(`/assets/selection`,Oe);t=Array.isArray(e?.assets)?e.assets:[]}else t.length||(t=U);if(!t.length){ne(`没有可导出的资产`);return}Xe(`assets-${new Date().toISOString().slice(0,10)}.csv`,Ye(t)),N(`已导出 ${t.length} 个资产`)}catch(e){A(e,`导出失败`)}finally{I(!1)}}},Pe=(e,t)=>{O({keys:e||[],rows:t||[]})},Q=T.keys.length;return n?(0,X.jsxs)(`div`,{className:`asset-library-page`,children:[(0,X.jsx)(oe,{title:e(`assets.libraryTitle`,null,`资产库`),description:`统一维护域名、IP、端口与服务资产,支持批量入库、合并与项目绑定。`,extra:(0,X.jsxs)(c,{children:[(0,X.jsx)(s,{icon:(0,X.jsx)(v,{}),onClick:K,loading:ye,children:e(`common.refresh`,null,`刷新`)}),i&&(0,X.jsx)(s,{icon:(0,X.jsx)(ee,{}),onClick:()=>pe(!0),children:e(`assets.bulkImport`,null,`批量导入`)}),i&&(0,X.jsx)(s,{theme:`solid`,type:`primary`,icon:(0,X.jsx)(x,{}),onClick:()=>Te(null),children:e(`assets.addAsset`,null,`新增资产`)})]})}),(0,X.jsx)(re,{error:B,onRetry:K}),(0,X.jsx)(ie,{title:e(`assets.filterTitle`,null,`筛选条件`),children:(0,X.jsx)(Ae,{filters:h,projects:V,onChange:xe,onReset:Se})}),(0,X.jsxs)(ie,{title:`${e(`assets.libraryTitle`,null,`资产库`)}(${W})`,extra:(0,X.jsxs)(c,{children:[(0,X.jsx)(s,{theme:`borderless`,disabled:!Q,onClick:()=>O({keys:[],rows:[]}),children:e(`assets.clearSelection`,null,`清除选择`)}),(0,X.jsx)(s,{theme:`borderless`,onClick:()=>Z(!1),loading:F,children:e(`assets.exportCsv`,null,`导出 CSV`)}),(0,X.jsx)(s,{theme:`borderless`,onClick:()=>Z(!0),loading:F,children:e(`assets.exportAll`,null,`导出全部筛选结果`)})]}),children:[(0,X.jsxs)(`div`,{className:`asset-library-toolbar`,children:[(0,X.jsxs)(c,{children:[(0,X.jsx)(st,{type:`tertiary`,children:Q?e(`assets.selectedCount`,{count:Q},`已选择 ${Q} 项`):e(`assets.selectedCount`,{count:0},`已选择 0 项`)}),(0,X.jsx)(s,{theme:`borderless`,size:`small`,onClick:je,children:e(`assets.selectAllResults`,{count:W},`选择全部 ${W} 项`)})]}),(0,X.jsxs)(c,{children:[i&&(0,X.jsx)(s,{size:`small`,disabled:Q<2,onClick:()=>he(!0),children:e(`assets.mergeDuplicates`,null,`合并重复资产`)}),i&&(0,X.jsx)(s,{size:`small`,disabled:!Q,onClick:()=>_e(!0),children:e(`assets.bindProject`,null,`绑定项目`)}),i&&(0,X.jsx)(s,{size:`small`,disabled:!Q,onClick:()=>P(!0),children:e(`assets.bulkEdit`,null,`批量编辑`)}),o&&(0,X.jsx)(s,{size:`small`,type:`danger`,disabled:!Q,onClick:De,children:e(`assets.batchDelete`,null,`批量删除…`)})]})]}),(0,X.jsx)(Me,{assets:U,loading:ye,total:W,page:_,pageSize:b,onPageChange:e=>{y(e),O({keys:[],rows:[]})},onPageSizeChange:e=>{S(e),y(1),O({keys:[],rows:[]})},selectedRowKeys:T.keys,onSelectionChange:Pe,onView:Ce,onEdit:Te,onDelete:Ee,onRefresh:K,canWrite:i,canDelete:o})]}),(0,X.jsx)(Ne,{asset:j,visible:!!j,onClose:we,onEdit:e=>{we(),Te(e)},onDelete:t=>{ce({title:e(`assets.deleteConfirm`,null,`确定删除该资产吗?`),content:t.host||t.domain||t.ip,okText:e(`common.delete`,null,`删除`),onOk:()=>Ee(t).catch(t=>A(t,e(`assets.deleteFailed`,null,`删除资产失败`)))})},canWrite:i,canDelete:o}),(0,X.jsx)(Fe,{visible:se,asset:ue,projects:V,onClose:()=>le(!1),onSaved:J}),(0,X.jsx)(Qe,{visible:fe,projects:V,onClose:()=>pe(!1),onDone:J}),(0,X.jsx)(et,{visible:me,assets:T.rows,onClose:()=>he(!1),onDone:J}),(0,X.jsx)(nt,{visible:ge,projects:V,assetIds:T.keys,onClose:()=>_e(!1),onDone:J}),(0,X.jsx)(at,{visible:ve,assetIds:T.keys,onClose:()=>P(!1),onDone:J})]}):(0,X.jsxs)(`div`,{className:`asset-library-page`,children:[(0,X.jsx)(oe,{title:e(`assets.libraryTitle`,null,`资产库`),description:`资产列表、批量操作与导入需要资产读取权限。`}),(0,X.jsx)(l,{type:`warning`,bordered:!0,closeIcon:null,description:e(`assets.readDenied`,null,`当前账号没有 asset:read 权限,无法读取资产库;请联系管理员授权。`)})]})}export{ct as buildAssetQuery,lt as default};
\ No newline at end of file
diff --git a/web/static/app/assets/asset-overview-DNWfmRJG.js b/web/static/app/assets/asset-overview-BmQ_1q6a.js
similarity index 98%
rename from web/static/app/assets/asset-overview-DNWfmRJG.js
rename to web/static/app/assets/asset-overview-BmQ_1q6a.js
index 93af9070..00ee4c54 100644
--- a/web/static/app/assets/asset-overview-DNWfmRJG.js
+++ b/web/static/app/assets/asset-overview-BmQ_1q6a.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r}from"./react-QV7DAAIx.js";import{I as i,P as a,R as o,U as s,it as c,m as l,p as u,rt as d,w as f,zt as p}from"./semi-DNxeCrHm.js";import{D as m,F as h,I as g,P as _,_ as v,a as y,k as b,l as x,m as S,p as C,s as w}from"./index-BoFwOeaz.js";import{f as T,h as E,p as D,r as O}from"./assetTarget-CAuOtA9X.js";var k=e(t(),1),A=e(r(),1),{Text:j}=s,M=[{value:7,label:`7 天`},{value:30,label:`30 天`},{value:90,label:`90 天`}];function N(e,t){let n=Number(e||0),r=Number(t||0);return r?Math.round(n/r*1e3)/10:0}function P(){let e=_(),t=n(),{hasPermission:r,hasAnyPermission:s}=h(),P=r(`asset:read`),F=s([`asset:read`,`fofa:execute`]),[I,L]=(0,k.useState)(30),R=y(()=>g.get(`/assets/stats`,{days:I}),[I],{skip:!P}),z=y(()=>g.get(`/assets`,{page:1,page_size:10,sort_by:`last_seen_at`,sort_order:`desc`}),[],{skip:!P}),B=R.data||{},V=B.coverage||{},H=Array.isArray(B.protocols)?B.protocols:[],U=(0,k.useMemo)(()=>H.reduce((e,t)=>e+Number(t.count||0),0),[H]),W=Array.isArray(z.data?.assets)?z.data.assets:[],G=[{id:`total`,label:e(`assets.totalAssets`,null,`资产总数`),value:m(B.total||0),detail:e(`assets.totalAssetsHint`,null,`当前纳入持续监测的资产`),loading:R.loading},{id:`ips`,label:e(`assets.ipCount`,null,`IP 数量`),value:m(B.ips||0),loading:R.loading},{id:`domains`,label:e(`assets.domainCount`,null,`域名数量`),value:m(B.domains||0),loading:R.loading},{id:`ports`,label:e(`assets.portCount`,null,`端口数量`),value:m(B.ports||0),loading:R.loading},{id:`protocols`,label:e(`assets.serviceTypes`,null,`服务类型`),value:m(H.length),detail:H[0]?`${e(`assets.topProtocol`,null,`主要协议`)}:${H[0].name}`:void 0,loading:R.loading},{id:`recent`,label:e(`assets.recentCount`,null,`近 7 天发现`),value:m(B.recent||0),detail:e(`assets.recentShare`,{percent:N(B.recent,B.total)},`占当前资产总量的 ${N(B.recent,B.total)}%`),loading:R.loading}],K=e=>{let n=e?.id?`?id=${encodeURIComponent(e.id)}`:``;t(`/asset-library${n}`,e?{state:{asset:e}}:void 0)},q=[{title:e(`assets.target`,null,`目标`),dataIndex:`host`,render:(e,t)=>(0,A.jsxs)(`div`,{className:`asset-overview-target`,children:[(0,A.jsx)(E,{text:O(t),max:34}),(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:[t.ip,t.domain].filter(Boolean).join(` · `)||`—`})]})},{title:e(`assets.service`,null,`服务`),dataIndex:`protocol`,width:150,render:(e,t)=>(0,A.jsx)(T,{protocol:t.protocol,port:t.port})},{title:e(`assets.source`,null,`来源`),dataIndex:`source`,width:120,render:e=>(0,A.jsx)(E,{text:e,max:14})},{title:e(`assets.riskLevel`,null,`风险等级`),dataIndex:`risk_level`,width:120,render:(e,t)=>(0,A.jsx)(D,{asset:t})},{title:e(`assets.lastSeen`,null,`最近发现`),dataIndex:`last_seen_at`,width:130,render:t=>(0,A.jsx)(j,{size:`small`,children:b(t,e)})},{title:e(`common.actions`,null,`操作`),dataIndex:`id`,width:100,render:(t,n)=>(0,A.jsx)(i,{theme:`borderless`,size:`small`,onClick:()=>K(n),children:e(`common.view`,null,`查看`)})}],J=[{label:e(`assets.scannedAssets`,null,`已扫描资产`),value:m(V.scanned||0)},{label:e(`assets.recentlyScanned`,null,`近 30 天覆盖`),value:m(V.scanned_30d||0)},{label:e(`assets.neverScanned`,null,`从未扫描`),value:m(V.never_scanned||0)},{label:e(`assets.staleScans`,null,`超过 30 天未扫描`),value:m(V.stale||0)}];return(0,A.jsxs)(`div`,{className:`asset-overview-page`,children:[(0,A.jsx)(C,{title:e(`assets.overviewTitle`,null,`资产概览`),description:`汇总资产规模、服务类型、扫描覆盖与最近发现情况。`,extra:(0,A.jsxs)(a,{children:[(0,A.jsx)(u,{type:`button`,value:I,options:M,onChange:e=>L(Number(e.target.value)||30)}),(0,A.jsx)(i,{icon:(0,A.jsx)(c,{}),onClick:()=>{R.reload(),z.reload()},children:e(`common.refresh`,null,`刷新`)}),(0,A.jsx)(i,{icon:(0,A.jsx)(p,{}),onClick:()=>t(`/asset-library`),children:e(`assets.viewLibrary`,null,`查看资产库`)}),F&&(0,A.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(d,{}),onClick:()=>t(`/info-collect`),children:e(`nav.infoCollect`,null,`信息收集`)})]})}),!P&&(0,A.jsx)(o,{type:`warning`,bordered:!0,closeIcon:null,description:e(`assets.readDenied`,null,`当前账号没有 asset:read 权限,无法读取资产统计;请联系管理员授权。`)}),P&&(0,A.jsx)(x,{error:R.error,onRetry:()=>R.reload()}),P&&(0,A.jsx)(v,{metrics:G,columns:6}),P&&(0,A.jsxs)(`div`,{className:`asset-overview-columns`,children:[(0,A.jsx)(S,{className:`asset-overview-card`,title:e(`assets.protocolDistribution`,null,`协议分布`),description:e(`assets.protocolDistributionHint`,null,`按已识别服务查看资产暴露构成`),extra:(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e(`assets.protocolKinds`,{count:H.length},`${H.length} 种协议`)}),children:H.length===0?(0,A.jsx)(f,{title:e(`common.noData`,null,`暂无数据`),description:null,style:{padding:24}}):(0,A.jsx)(`div`,{className:`asset-overview-bars`,children:H.map(e=>{let t=N(e.count,B.total||U);return(0,A.jsxs)(`div`,{className:`asset-overview-bar-row`,children:[(0,A.jsx)(j,{size:`small`,className:`asset-overview-bar-label`,children:e.name||`unknown`}),(0,A.jsx)(l,{percent:t,showInfo:!1,stroke:`var(--semi-color-primary)`}),(0,A.jsxs)(j,{type:`tertiary`,size:`small`,className:`asset-overview-bar-value`,children:[m(e.count||0),` · `,t,`%`]})]},e.name)})})}),(0,A.jsx)(S,{className:`asset-overview-card`,title:e(`assets.scanCoverage`,null,`扫描覆盖`),description:e(`assets.scanCoverageHint`,null,`识别未扫描与长期未复查的资产缺口`),extra:(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e(`assets.coverageMeta`,{scanned:V.scanned||0,total:B.total||0},`${V.scanned||0} / ${B.total||0} 已覆盖`)}),children:(0,A.jsxs)(`div`,{className:`asset-overview-coverage`,children:[(0,A.jsxs)(`div`,{className:`asset-overview-coverage-main`,children:[(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e(`assets.overallCoverage`,null,`总体覆盖率`)}),(0,A.jsx)(l,{percent:Number(V.rate||0),stroke:Number(V.rate||0)>=80?`var(--semi-color-success)`:void 0,format:e=>`${e}%`})]}),(0,A.jsx)(`div`,{className:`asset-overview-coverage-grid`,children:J.map(e=>(0,A.jsxs)(`div`,{className:`asset-overview-coverage-item`,children:[(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e.label}),(0,A.jsx)(j,{strong:!0,children:e.value})]},e.label))})]})})]}),P&&(0,A.jsxs)(S,{title:e(`assets.recentAssets`,null,`最近资产`),description:`按最近发现时间排列的前 10 条资产。`,extra:(0,A.jsx)(i,{theme:`borderless`,onClick:()=>t(`/asset-library`),children:e(`assets.viewLibrary`,null,`查看资产库`)}),children:[(0,A.jsx)(x,{error:z.error,onRetry:()=>z.reload()}),(0,A.jsx)(w,{columns:q,dataSource:W,loading:z.loading,rowKey:`id`,pagination:!1,onRefresh:()=>z.reload(),emptyText:e(`common.noData`,null,`暂无数据`)})]})]})}export{P as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r}from"./react-QV7DAAIx.js";import{I as i,P as a,R as o,U as s,it as c,m as l,p as u,rt as d,w as f,zt as p}from"./semi-DNxeCrHm.js";import{D as m,F as h,I as g,P as _,_ as v,a as y,k as b,l as x,m as S,p as C,s as w}from"./index-smFoxEJu.js";import{f as T,h as E,p as D,r as O}from"./assetTarget-CAuOtA9X.js";var k=e(t(),1),A=e(r(),1),{Text:j}=s,M=[{value:7,label:`7 天`},{value:30,label:`30 天`},{value:90,label:`90 天`}];function N(e,t){let n=Number(e||0),r=Number(t||0);return r?Math.round(n/r*1e3)/10:0}function P(){let e=_(),t=n(),{hasPermission:r,hasAnyPermission:s}=h(),P=r(`asset:read`),F=s([`asset:read`,`fofa:execute`]),[I,L]=(0,k.useState)(30),R=y(()=>g.get(`/assets/stats`,{days:I}),[I],{skip:!P}),z=y(()=>g.get(`/assets`,{page:1,page_size:10,sort_by:`last_seen_at`,sort_order:`desc`}),[],{skip:!P}),B=R.data||{},V=B.coverage||{},H=Array.isArray(B.protocols)?B.protocols:[],U=(0,k.useMemo)(()=>H.reduce((e,t)=>e+Number(t.count||0),0),[H]),W=Array.isArray(z.data?.assets)?z.data.assets:[],G=[{id:`total`,label:e(`assets.totalAssets`,null,`资产总数`),value:m(B.total||0),detail:e(`assets.totalAssetsHint`,null,`当前纳入持续监测的资产`),loading:R.loading},{id:`ips`,label:e(`assets.ipCount`,null,`IP 数量`),value:m(B.ips||0),loading:R.loading},{id:`domains`,label:e(`assets.domainCount`,null,`域名数量`),value:m(B.domains||0),loading:R.loading},{id:`ports`,label:e(`assets.portCount`,null,`端口数量`),value:m(B.ports||0),loading:R.loading},{id:`protocols`,label:e(`assets.serviceTypes`,null,`服务类型`),value:m(H.length),detail:H[0]?`${e(`assets.topProtocol`,null,`主要协议`)}:${H[0].name}`:void 0,loading:R.loading},{id:`recent`,label:e(`assets.recentCount`,null,`近 7 天发现`),value:m(B.recent||0),detail:e(`assets.recentShare`,{percent:N(B.recent,B.total)},`占当前资产总量的 ${N(B.recent,B.total)}%`),loading:R.loading}],K=e=>{let n=e?.id?`?id=${encodeURIComponent(e.id)}`:``;t(`/asset-library${n}`,e?{state:{asset:e}}:void 0)},q=[{title:e(`assets.target`,null,`目标`),dataIndex:`host`,render:(e,t)=>(0,A.jsxs)(`div`,{className:`asset-overview-target`,children:[(0,A.jsx)(E,{text:O(t),max:34}),(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:[t.ip,t.domain].filter(Boolean).join(` · `)||`—`})]})},{title:e(`assets.service`,null,`服务`),dataIndex:`protocol`,width:150,render:(e,t)=>(0,A.jsx)(T,{protocol:t.protocol,port:t.port})},{title:e(`assets.source`,null,`来源`),dataIndex:`source`,width:120,render:e=>(0,A.jsx)(E,{text:e,max:14})},{title:e(`assets.riskLevel`,null,`风险等级`),dataIndex:`risk_level`,width:120,render:(e,t)=>(0,A.jsx)(D,{asset:t})},{title:e(`assets.lastSeen`,null,`最近发现`),dataIndex:`last_seen_at`,width:130,render:t=>(0,A.jsx)(j,{size:`small`,children:b(t,e)})},{title:e(`common.actions`,null,`操作`),dataIndex:`id`,width:100,render:(t,n)=>(0,A.jsx)(i,{theme:`borderless`,size:`small`,onClick:()=>K(n),children:e(`common.view`,null,`查看`)})}],J=[{label:e(`assets.scannedAssets`,null,`已扫描资产`),value:m(V.scanned||0)},{label:e(`assets.recentlyScanned`,null,`近 30 天覆盖`),value:m(V.scanned_30d||0)},{label:e(`assets.neverScanned`,null,`从未扫描`),value:m(V.never_scanned||0)},{label:e(`assets.staleScans`,null,`超过 30 天未扫描`),value:m(V.stale||0)}];return(0,A.jsxs)(`div`,{className:`asset-overview-page`,children:[(0,A.jsx)(C,{title:e(`assets.overviewTitle`,null,`资产概览`),description:`汇总资产规模、服务类型、扫描覆盖与最近发现情况。`,extra:(0,A.jsxs)(a,{children:[(0,A.jsx)(u,{type:`button`,value:I,options:M,onChange:e=>L(Number(e.target.value)||30)}),(0,A.jsx)(i,{icon:(0,A.jsx)(c,{}),onClick:()=>{R.reload(),z.reload()},children:e(`common.refresh`,null,`刷新`)}),(0,A.jsx)(i,{icon:(0,A.jsx)(p,{}),onClick:()=>t(`/asset-library`),children:e(`assets.viewLibrary`,null,`查看资产库`)}),F&&(0,A.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(d,{}),onClick:()=>t(`/info-collect`),children:e(`nav.infoCollect`,null,`信息收集`)})]})}),!P&&(0,A.jsx)(o,{type:`warning`,bordered:!0,closeIcon:null,description:e(`assets.readDenied`,null,`当前账号没有 asset:read 权限,无法读取资产统计;请联系管理员授权。`)}),P&&(0,A.jsx)(x,{error:R.error,onRetry:()=>R.reload()}),P&&(0,A.jsx)(v,{metrics:G,columns:6}),P&&(0,A.jsxs)(`div`,{className:`asset-overview-columns`,children:[(0,A.jsx)(S,{className:`asset-overview-card`,title:e(`assets.protocolDistribution`,null,`协议分布`),description:e(`assets.protocolDistributionHint`,null,`按已识别服务查看资产暴露构成`),extra:(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e(`assets.protocolKinds`,{count:H.length},`${H.length} 种协议`)}),children:H.length===0?(0,A.jsx)(f,{title:e(`common.noData`,null,`暂无数据`),description:null,style:{padding:24}}):(0,A.jsx)(`div`,{className:`asset-overview-bars`,children:H.map(e=>{let t=N(e.count,B.total||U);return(0,A.jsxs)(`div`,{className:`asset-overview-bar-row`,children:[(0,A.jsx)(j,{size:`small`,className:`asset-overview-bar-label`,children:e.name||`unknown`}),(0,A.jsx)(l,{percent:t,showInfo:!1,stroke:`var(--semi-color-primary)`}),(0,A.jsxs)(j,{type:`tertiary`,size:`small`,className:`asset-overview-bar-value`,children:[m(e.count||0),` · `,t,`%`]})]},e.name)})})}),(0,A.jsx)(S,{className:`asset-overview-card`,title:e(`assets.scanCoverage`,null,`扫描覆盖`),description:e(`assets.scanCoverageHint`,null,`识别未扫描与长期未复查的资产缺口`),extra:(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e(`assets.coverageMeta`,{scanned:V.scanned||0,total:B.total||0},`${V.scanned||0} / ${B.total||0} 已覆盖`)}),children:(0,A.jsxs)(`div`,{className:`asset-overview-coverage`,children:[(0,A.jsxs)(`div`,{className:`asset-overview-coverage-main`,children:[(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e(`assets.overallCoverage`,null,`总体覆盖率`)}),(0,A.jsx)(l,{percent:Number(V.rate||0),stroke:Number(V.rate||0)>=80?`var(--semi-color-success)`:void 0,format:e=>`${e}%`})]}),(0,A.jsx)(`div`,{className:`asset-overview-coverage-grid`,children:J.map(e=>(0,A.jsxs)(`div`,{className:`asset-overview-coverage-item`,children:[(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e.label}),(0,A.jsx)(j,{strong:!0,children:e.value})]},e.label))})]})})]}),P&&(0,A.jsxs)(S,{title:e(`assets.recentAssets`,null,`最近资产`),description:`按最近发现时间排列的前 10 条资产。`,extra:(0,A.jsx)(i,{theme:`borderless`,onClick:()=>t(`/asset-library`),children:e(`assets.viewLibrary`,null,`查看资产库`)}),children:[(0,A.jsx)(x,{error:z.error,onRetry:()=>z.reload()}),(0,A.jsx)(w,{columns:q,dataSource:W,loading:z.loading,rowKey:`id`,pagination:!1,onRefresh:()=>z.reload(),emptyText:e(`common.noData`,null,`暂无数据`)})]})]})}export{P as default};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-events-DTCXaUlN.js b/web/static/app/assets/c2-events-CoH3yyOa.js
similarity index 96%
rename from web/static/app/assets/c2-events-DTCXaUlN.js
rename to web/static/app/assets/c2-events-CoH3yyOa.js
index 59c23750..8517f65f 100644
--- a/web/static/app/assets/c2-events-DTCXaUlN.js
+++ b/web/static/app/assets/c2-events-CoH3yyOa.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{I as r,P as i,U as a,V as ee,_ as o,d as s,it as te,j as c}from"./semi-DNxeCrHm.js";import{E as ne,F as re,P as l,_ as u,a as d,b as f,l as p,m,p as ie,r as h,s as ae,u as oe,x as g,y as _}from"./index-BoFwOeaz.js";import{c as v,v as y}from"./c2-shared-DQceLFCe.js";import{g as b,m as x,n as S,p as C,r as w,t as T}from"./c2-shared-BkIzs15k.js";var E=e(t(),1),D=e(n(),1),{Text:O}=a;function k(){let e=l(),{hasPermission:t}=re(),n=t(`c2:delete`)||t(`c2:write`),[a,k]=(0,E.useState)(1),[A,se]=(0,E.useState)(20),[j,M]=(0,E.useState)(``),[N,P]=(0,E.useState)(``),[F,I]=(0,E.useState)(`24h`),[L,R]=(0,E.useState)(``),[z,B]=(0,E.useState)(``),[V,H]=(0,E.useState)([]),[U,W]=(0,E.useState)(null),G=(0,E.useMemo)(()=>({page:a,page_size:A,level:j||void 0,category:N||void 0,session_id:z||void 0,since:b(F)||void 0}),[a,A,j,N,z,F]),{data:K,loading:q,error:ce,reload:J}=d(()=>y(G),[G]),Y=Array.isArray(K?.events)?K.events:[],X=Number(K?.total??Y.length),Z=K?.level_counts||{};h(()=>J({silent:!0}),5e3);let Q=()=>{B(L.trim()),k(1),H([])},le=()=>{M(``),P(``),I(`24h`),R(``),B(``),k(1),H([])},ue=[{id:`total`,label:e(`c2.events.statTotal`,null,`当前筛选`),value:X},{id:`info`,label:e(`c2.events.info`,null,`信息`),value:Z.info||0},{id:`warn`,label:e(`c2.events.warn`,null,`警告`),value:Z.warn||0,tone:`warning`},{id:`critical`,label:e(`c2.events.critical`,null,`严重`),value:Z.critical||0,tone:`danger`}],$=t=>{_({title:e(`c2.events.batchDelete`,null,`删除事件`),content:t.length>1?e(`c2.events.confirmBatchDelete`,null,`确定删除选中的事件吗?此操作不可恢复。`).replace(`{{n}}`,String(t.length)):e(`c2.events.confirmDeleteOne`,null,`确定删除该条事件吗?此操作不可恢复。`),onOk:async()=>{try{let n=await v(t);g(e(`c2.events.toastDeleted`,null,`已删除`).replace(`{{n}}`,String(n?.deleted??t.length))),H(e=>e.filter(e=>!t.includes(e))),J()}catch(e){f(e)}}})},de=[{title:e(`c2.events.level`,null,`级别`),dataIndex:`level`,width:90,render:t=>(0,D.jsx)(c,{size:`small`,color:S[t]||`grey`,children:e(`c2.events.${t||`info`}`,null,t||`—`)})},{title:e(`c2.events.category`,null,`类别`),dataIndex:`category`,width:110},{title:e(`c2.events.message`,null,`消息`),dataIndex:`message`,render:(e,t)=>(0,D.jsx)(`button`,{type:`button`,className:`c2-event-message`,onClick:()=>W(t),title:e,children:e||`—`})},{title:e(`c2.events.colSession`,null,`会话`),dataIndex:`sessionId`,width:150,render:e=>(0,D.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.events.colTask`,null,`任务`),dataIndex:`taskId`,width:150,render:e=>(0,D.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.events.time`,null,`时间`),dataIndex:`createdAt`,width:130,render:e=>(0,D.jsx)(x,{value:e})},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:130,render:(t,a)=>(0,D.jsxs)(i,{spacing:4,children:[(0,D.jsx)(r,{size:`small`,theme:`borderless`,onClick:()=>W(a),children:e(`c2.events.view`,null,`查看`)}),(0,D.jsx)(r,{size:`small`,theme:`borderless`,type:`danger`,disabled:!n,onClick:()=>$([a.id]),children:e(`c2.events.deleteOne`,null,`删除`)})]})}];return(0,D.jsxs)(`div`,{className:`c2-page`,id:`page-c2-events`,children:[(0,D.jsx)(ie,{title:e(`c2.events.title`,null,`事件审计`),description:e(`c2.events.pageDesc`,null,`监听器、会话、任务与 OPSEC 事件留痕,5 秒自动刷新`),extra:[(0,D.jsx)(r,{icon:(0,D.jsx)(te,{}),onClick:()=>J(),loading:q,children:e(`c2.events.refresh`,null,`刷新`)},`refresh`),(0,D.jsx)(r,{type:`danger`,disabled:!n||!V.length,onClick:()=>$(V),children:e(`c2.events.batchDelete`,null,`批量删除`)},`delete`)]}),(0,D.jsx)(u,{metrics:ue,columns:4}),(0,D.jsx)(p,{error:ce,onRetry:()=>J()}),(0,D.jsx)(m,{title:e(`c2.events.filterTitle`,null,`筛选`),extra:(0,D.jsx)(C,{value:F,onChange:e=>{I(e),k(1)},ns:`events`}),children:(0,D.jsxs)(`div`,{className:`c2-toolbar-fields`,children:[(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.level`,null,`级别`)}),(0,D.jsx)(o,{value:j,onChange:e=>{M(e||``),k(1)},style:{width:150},optionList:[{value:``,label:e(`c2.events.filterAllLevels`,null,`全部级别`)},...w]})]}),(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.category`,null,`类别`)}),(0,D.jsx)(o,{value:N,onChange:e=>{P(e||``),k(1)},style:{width:150},optionList:[{value:``,label:e(`c2.events.filterAllCategories`,null,`全部类别`)},...T]})]}),(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.filterSession`,null,`会话 ID`)}),(0,D.jsx)(ee,{value:L,onChange:R,onEnterPress:Q,placeholder:e(`c2.events.filterSessionPlaceholder`,null,`s_xxxxxxxx`),style:{width:190}})]}),(0,D.jsxs)(i,{spacing:8,children:[(0,D.jsx)(r,{theme:`solid`,type:`primary`,onClick:Q,children:e(`c2.events.applyFilters`,null,`应用筛选`)}),(0,D.jsx)(r,{onClick:le,children:e(`c2.events.resetFilters`,null,`重置`)})]})]})}),(0,D.jsx)(m,{title:e(`c2.events.listTitle`,null,`事件列表`),children:(0,D.jsx)(ae,{columns:de,dataSource:Y,rowKey:`id`,loading:q,onRefresh:()=>J(),rowSelection:{selectedRowKeys:V,onChange:e=>H(e)},pagination:{currentPage:a,pageSize:A,total:X,onPageChange:e=>k(e),onPageSizeChange:e=>{se(e),k(1)}},emptyText:e(`c2.events.empty`,null,`暂无事件`)})}),(0,D.jsx)(s,{visible:!!U,title:e(`c2.events.detailTitle`,null,`事件详情`),width:560,onCancel:()=>W(null),children:U&&(0,D.jsxs)(`div`,{className:`c2-event-detail`,children:[(0,D.jsxs)(`div`,{className:`c2-event-detail-head`,children:[(0,D.jsx)(c,{size:`small`,color:S[U.level]||`grey`,children:U.level}),(0,D.jsx)(c,{size:`small`,children:U.category}),(0,D.jsx)(O,{type:`tertiary`,size:`small`,children:ne(U.createdAt)})]}),(0,D.jsx)(O,{children:U.message}),(0,D.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.events.colId`,null,`事件 ID`)}),(0,D.jsx)(O,{className:`c2-mono`,copyable:{text:U.id},children:U.id}),U.sessionId&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.events.colSession`,null,`会话`)}),(0,D.jsx)(O,{className:`c2-mono`,children:U.sessionId})]}),U.data&&Object.keys(U.data).length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.events.detailData`,null,`附加数据`)}),(0,D.jsx)(oe,{value:U.data})]})]})})]})}export{k as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{I as r,P as i,U as a,V as ee,_ as o,d as s,it as te,j as c}from"./semi-DNxeCrHm.js";import{E as ne,F as re,P as l,_ as u,a as d,b as f,l as p,m,p as ie,r as h,s as ae,u as oe,x as g,y as _}from"./index-smFoxEJu.js";import{c as v,v as y}from"./c2-shared-B5kg9aBy.js";import{g as b,m as x,n as S,p as C,r as w,t as T}from"./c2-shared-BBQQ9OoL.js";var E=e(t(),1),D=e(n(),1),{Text:O}=a;function k(){let e=l(),{hasPermission:t}=re(),n=t(`c2:delete`)||t(`c2:write`),[a,k]=(0,E.useState)(1),[A,se]=(0,E.useState)(20),[j,M]=(0,E.useState)(``),[N,P]=(0,E.useState)(``),[F,I]=(0,E.useState)(`24h`),[L,R]=(0,E.useState)(``),[z,B]=(0,E.useState)(``),[V,H]=(0,E.useState)([]),[U,W]=(0,E.useState)(null),G=(0,E.useMemo)(()=>({page:a,page_size:A,level:j||void 0,category:N||void 0,session_id:z||void 0,since:b(F)||void 0}),[a,A,j,N,z,F]),{data:K,loading:q,error:ce,reload:J}=d(()=>y(G),[G]),Y=Array.isArray(K?.events)?K.events:[],X=Number(K?.total??Y.length),Z=K?.level_counts||{};h(()=>J({silent:!0}),5e3);let Q=()=>{B(L.trim()),k(1),H([])},le=()=>{M(``),P(``),I(`24h`),R(``),B(``),k(1),H([])},ue=[{id:`total`,label:e(`c2.events.statTotal`,null,`当前筛选`),value:X},{id:`info`,label:e(`c2.events.info`,null,`信息`),value:Z.info||0},{id:`warn`,label:e(`c2.events.warn`,null,`警告`),value:Z.warn||0,tone:`warning`},{id:`critical`,label:e(`c2.events.critical`,null,`严重`),value:Z.critical||0,tone:`danger`}],$=t=>{_({title:e(`c2.events.batchDelete`,null,`删除事件`),content:t.length>1?e(`c2.events.confirmBatchDelete`,null,`确定删除选中的事件吗?此操作不可恢复。`).replace(`{{n}}`,String(t.length)):e(`c2.events.confirmDeleteOne`,null,`确定删除该条事件吗?此操作不可恢复。`),onOk:async()=>{try{let n=await v(t);g(e(`c2.events.toastDeleted`,null,`已删除`).replace(`{{n}}`,String(n?.deleted??t.length))),H(e=>e.filter(e=>!t.includes(e))),J()}catch(e){f(e)}}})},de=[{title:e(`c2.events.level`,null,`级别`),dataIndex:`level`,width:90,render:t=>(0,D.jsx)(c,{size:`small`,color:S[t]||`grey`,children:e(`c2.events.${t||`info`}`,null,t||`—`)})},{title:e(`c2.events.category`,null,`类别`),dataIndex:`category`,width:110},{title:e(`c2.events.message`,null,`消息`),dataIndex:`message`,render:(e,t)=>(0,D.jsx)(`button`,{type:`button`,className:`c2-event-message`,onClick:()=>W(t),title:e,children:e||`—`})},{title:e(`c2.events.colSession`,null,`会话`),dataIndex:`sessionId`,width:150,render:e=>(0,D.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.events.colTask`,null,`任务`),dataIndex:`taskId`,width:150,render:e=>(0,D.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.events.time`,null,`时间`),dataIndex:`createdAt`,width:130,render:e=>(0,D.jsx)(x,{value:e})},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:130,render:(t,a)=>(0,D.jsxs)(i,{spacing:4,children:[(0,D.jsx)(r,{size:`small`,theme:`borderless`,onClick:()=>W(a),children:e(`c2.events.view`,null,`查看`)}),(0,D.jsx)(r,{size:`small`,theme:`borderless`,type:`danger`,disabled:!n,onClick:()=>$([a.id]),children:e(`c2.events.deleteOne`,null,`删除`)})]})}];return(0,D.jsxs)(`div`,{className:`c2-page`,id:`page-c2-events`,children:[(0,D.jsx)(ie,{title:e(`c2.events.title`,null,`事件审计`),description:e(`c2.events.pageDesc`,null,`监听器、会话、任务与 OPSEC 事件留痕,5 秒自动刷新`),extra:[(0,D.jsx)(r,{icon:(0,D.jsx)(te,{}),onClick:()=>J(),loading:q,children:e(`c2.events.refresh`,null,`刷新`)},`refresh`),(0,D.jsx)(r,{type:`danger`,disabled:!n||!V.length,onClick:()=>$(V),children:e(`c2.events.batchDelete`,null,`批量删除`)},`delete`)]}),(0,D.jsx)(u,{metrics:ue,columns:4}),(0,D.jsx)(p,{error:ce,onRetry:()=>J()}),(0,D.jsx)(m,{title:e(`c2.events.filterTitle`,null,`筛选`),extra:(0,D.jsx)(C,{value:F,onChange:e=>{I(e),k(1)},ns:`events`}),children:(0,D.jsxs)(`div`,{className:`c2-toolbar-fields`,children:[(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.level`,null,`级别`)}),(0,D.jsx)(o,{value:j,onChange:e=>{M(e||``),k(1)},style:{width:150},optionList:[{value:``,label:e(`c2.events.filterAllLevels`,null,`全部级别`)},...w]})]}),(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.category`,null,`类别`)}),(0,D.jsx)(o,{value:N,onChange:e=>{P(e||``),k(1)},style:{width:150},optionList:[{value:``,label:e(`c2.events.filterAllCategories`,null,`全部类别`)},...T]})]}),(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.filterSession`,null,`会话 ID`)}),(0,D.jsx)(ee,{value:L,onChange:R,onEnterPress:Q,placeholder:e(`c2.events.filterSessionPlaceholder`,null,`s_xxxxxxxx`),style:{width:190}})]}),(0,D.jsxs)(i,{spacing:8,children:[(0,D.jsx)(r,{theme:`solid`,type:`primary`,onClick:Q,children:e(`c2.events.applyFilters`,null,`应用筛选`)}),(0,D.jsx)(r,{onClick:le,children:e(`c2.events.resetFilters`,null,`重置`)})]})]})}),(0,D.jsx)(m,{title:e(`c2.events.listTitle`,null,`事件列表`),children:(0,D.jsx)(ae,{columns:de,dataSource:Y,rowKey:`id`,loading:q,onRefresh:()=>J(),rowSelection:{selectedRowKeys:V,onChange:e=>H(e)},pagination:{currentPage:a,pageSize:A,total:X,onPageChange:e=>k(e),onPageSizeChange:e=>{se(e),k(1)}},emptyText:e(`c2.events.empty`,null,`暂无事件`)})}),(0,D.jsx)(s,{visible:!!U,title:e(`c2.events.detailTitle`,null,`事件详情`),width:560,onCancel:()=>W(null),children:U&&(0,D.jsxs)(`div`,{className:`c2-event-detail`,children:[(0,D.jsxs)(`div`,{className:`c2-event-detail-head`,children:[(0,D.jsx)(c,{size:`small`,color:S[U.level]||`grey`,children:U.level}),(0,D.jsx)(c,{size:`small`,children:U.category}),(0,D.jsx)(O,{type:`tertiary`,size:`small`,children:ne(U.createdAt)})]}),(0,D.jsx)(O,{children:U.message}),(0,D.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.events.colId`,null,`事件 ID`)}),(0,D.jsx)(O,{className:`c2-mono`,copyable:{text:U.id},children:U.id}),U.sessionId&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.events.colSession`,null,`会话`)}),(0,D.jsx)(O,{className:`c2-mono`,children:U.sessionId})]}),U.data&&Object.keys(U.data).length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.events.detailData`,null,`附加数据`)}),(0,D.jsx)(oe,{value:U.data})]})]})})]})}export{k as default};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-listeners-D_Bx-B-I.js b/web/static/app/assets/c2-listeners-Czsz18uH.js
similarity index 97%
rename from web/static/app/assets/c2-listeners-D_Bx-B-I.js
rename to web/static/app/assets/c2-listeners-Czsz18uH.js
index c6ddf650..0587c261 100644
--- a/web/static/app/assets/c2-listeners-D_Bx-B-I.js
+++ b/web/static/app/assets/c2-listeners-Czsz18uH.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{C as r,I as i,P as a,U as o,i as s,it as c,j as l,ot as u}from"./semi-DNxeCrHm.js";import{E as d,F as f,P as p,_ as m,a as h,b as g,l as _,m as v,o as y,p as b,s as x,x as S,y as C}from"./index-BoFwOeaz.js";import{D as w,E as T,O as E,b as D,i as O,l as k,x as A,y as j}from"./c2-shared-DQceLFCe.js";import{a as M,i as N,o as P}from"./c2-shared-BkIzs15k.js";var F=e(t(),1),I=e(n(),1),{Text:L}=o;function R(e){if(!e?.configJson)return{};try{return JSON.parse(e.configJson)||{}}catch{return{}}}function z(e){let t=R(e);return{name:e?.name||``,type:e?.type||`http_beacon`,project_id:e?.project_id||``,bind_host:e?.bindHost||`127.0.0.1`,bind_port:String(e?.bindPort??`4444`),callback_host:t.callback_host||``,profile_id:e?.profileId||``,remark:e?.remark||``,default_sleep:String(t.default_sleep??5),default_jitter:String(t.default_jitter??0),max_concurrent_tasks:String(t.max_concurrent_tasks??0),allow_legacy_shell:!!t.allow_legacy_shell}}function B({visible:e,record:t,projects:n,profiles:o,submitting:c,onCancel:l,onSubmit:u}){let d=p(),[f,m]=(0,F.useState)(null),[h,g]=(0,F.useState)(t?.type||`http_beacon`);return(0,I.jsx)(r,{visible:e,title:t?d(`c2.listeners.editTitle`,null,`编辑监听器`):d(`c2.listeners.modalCreateTitle`,null,`创建监听器`),footer:null,width:620,onCancel:l,children:(0,I.jsxs)(s,{initValues:z(t),onSubmit:e=>{let t=Number(e.bind_port);u({name:String(e.name||``).trim(),type:e.type,project_id:e.project_id||``,bind_host:String(e.bind_host||``).trim()||`127.0.0.1`,bind_port:Number.isFinite(t)?t:0,callback_host:String(e.callback_host||``).trim(),profile_id:e.profile_id||``,remark:String(e.remark||``).trim(),config:{callback_host:String(e.callback_host||``).trim(),default_sleep:Number(e.default_sleep)||5,default_jitter:Number(e.default_jitter)||0,max_concurrent_tasks:Number(e.max_concurrent_tasks)||0,allow_legacy_shell:!!e.allow_legacy_shell}})},getFormApi:m,labelPosition:`top`,onValueChange:e=>{e.type&&g(e.type)},children:[(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`name`,label:d(`c2.listeners.name`,null,`名称`),placeholder:d(`c2.listeners.placeholderNameExample`,null,`例如 http-beacon-01`),rules:[{required:!0,message:d(`c2.listeners.nameRequired`,null,`请输入监听器名称`)}]}),(0,I.jsx)(s.Select,{field:`type`,label:d(`c2.listeners.type`,null,`类型`),optionList:P,disabled:!!t,style:{width:`100%`}})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`bind_host`,label:d(`c2.listeners.bindHost`,null,`绑定地址`),placeholder:`127.0.0.1`}),(0,I.jsx)(s.Input,{field:`bind_port`,label:d(`c2.listeners.bindPort`,null,`绑定端口`),placeholder:d(`c2.listeners.placeholderPort`,null,`输入端口号`),rules:[{required:!0,validator:(e,t)=>{let n=Number(t);return Number.isInteger(n)&&n>0&&n<=65535},message:d(`c2.listeners.portInvalid`,null,`端口必须为 1–65535 的整数`)}]})]}),(0,I.jsx)(L,{type:`tertiary`,size:`small`,children:d(`c2.listeners.bindHintExternal`,null,`使用 0.0.0.0 允许外部访问`)}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`callback_host`,label:d(`c2.listeners.callbackHost`,null,`回连地址(可选)`),placeholder:`公网 IP 或域名`}),(0,I.jsx)(s.Select,{field:`profile_id`,label:d(`c2.listeners.malleableProfile`,null,`Malleable Profile`),optionList:[{value:``,label:d(`c2.listeners.malleableProfileNone`,null,`不使用`)},...o.map(e=>({value:e.id,label:e.name||e.id}))],style:{width:`100%`}})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Select,{field:`project_id`,label:d(`c2.listeners.project`,null,`所属项目`),optionList:[{value:``,label:d(`c2.listeners.projectNone`,null,`不绑定项目`)},...n.map(e=>({value:e.id,label:e.name||e.id}))],style:{width:`100%`}}),(0,I.jsx)(s.Input,{field:`remark`,label:d(`c2.listeners.remark`,null,`备注`),placeholder:d(`c2.listeners.placeholderRemarkLong`,null,`可选的备注说明`)})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`default_sleep`,label:`默认 Sleep(秒)`,placeholder:`5`}),(0,I.jsx)(s.Input,{field:`default_jitter`,label:`默认 Jitter(%)`,placeholder:`0`})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`max_concurrent_tasks`,label:`单会话并发任务上限(0 不限)`,placeholder:`0`}),h===`tcp_reverse`&&(0,I.jsx)(s.Switch,{field:`allow_legacy_shell`,label:d(`c2.listeners.allowLegacyShell`,null,`允许未加密经典反弹 Shell(内网实验)`)})]}),(0,I.jsxs)(a,{className:`c2-form-actions`,children:[(0,I.jsx)(i,{onClick:l,children:d(`c2.common.cancel`,null,`取消`)}),(0,I.jsx)(i,{theme:`solid`,type:`primary`,loading:c,onClick:()=>f?.submitForm(),children:t?d(`c2.listeners.save`,null,`保存`):d(`c2.listeners.submitCreate`,null,`创建`)})]})]},t?.id||`new`)})}var{Text:V}=o,H=e=>P.find(t=>t.value===e)?.label||e||`—`;function U(){let e=p(),{hasPermission:t}=f(),n=t(`c2:write`),o=t(`c2:delete`)||n,[s,P]=(0,F.useState)({visible:!1,record:null}),[L,R]=(0,F.useState)(!1),[z,U]=(0,F.useState)(``),[W,G]=(0,F.useState)(null),{data:K,loading:q,error:J,reload:Y}=h(()=>Promise.all([j(),D().catch(()=>({profiles:[]})),A()]),[]),X=Array.isArray(K?.[0]?.listeners)?K[0].listeners:[],Z=Array.isArray(K?.[1]?.profiles)?K[1].profiles:[],Q=Array.isArray(K?.[2])?K[2]:[],$=(0,F.useMemo)(()=>{let t=X.filter(e=>e.status===`running`).length,n=X.filter(e=>e.status===`error`).length;return[{id:`total`,label:e(`c2.listeners.statTotal`,null,`监听器总数`),value:X.length},{id:`running`,label:e(`c2.listeners.running`,null,`运行中`),value:t,tone:t?`success`:void 0},{id:`stopped`,label:e(`c2.listeners.stopped`,null,`已停止`),value:X.length-t-n},{id:`error`,label:e(`c2.listeners.statusError`,null,`异常`),value:n,tone:n?`danger`:void 0}]},[X,e]),ee=async(t,n)=>{U(t.id);try{n===`start`?(await T(t.id),S(e(`c2.listeners.toastStarted`,null,`监听器已启动`))):(await w(t.id),S(e(`c2.listeners.toastStopped`,null,`监听器已停止`))),Y()}catch(t){g(t,n===`start`?e(`c2.listeners.start`,null,`启动失败`):e(`c2.listeners.stop`,null,`停止失败`))}finally{U(``)}},te=t=>{C({title:e(`c2.listeners.delete`,null,`删除监听器`),content:e(`c2.listeners.confirmDelete`,null,`确定删除此监听器?相关会话与任务将被清除。`),onOk:async()=>{try{await k(t.id),S(e(`c2.listeners.toastDeleted`,null,`监听器已删除`)),Y()}catch(e){g(e)}}})},ne=async t=>{R(!0);try{if(s.record?.id)await E(s.record.id,t),S(e(`c2.listeners.toastUpdated`,null,`监听器已更新`));else{let n=await O(t);S(e(`c2.listeners.toastCreated`,null,`监听器已创建`)),n?.implant_token&&G({name:n.listener?.name||t.name,token:n.implant_token})}P({visible:!1,record:null}),Y()}catch(t){g(t,e(`c2.listeners.saveFailed`,null,`监听器保存失败`))}finally{R(!1)}},re=[{title:e(`c2.listeners.name`,null,`名称`),dataIndex:`name`,render:(e,t)=>(0,I.jsxs)(`div`,{className:`c2-listener-name`,children:[(0,I.jsx)(V,{strong:!0,children:e||t.id}),t.remark&&(0,I.jsx)(V,{type:`tertiary`,size:`small`,children:t.remark})]})},{title:e(`c2.listeners.type`,null,`类型`),dataIndex:`type`,width:140,render:H},{title:e(`c2.listeners.bindEndpoint`,null,`监听地址`),dataIndex:`bindPort`,width:200,render:(e,t)=>(0,I.jsxs)(`span`,{className:`c2-mono`,children:[t.bindHost,`:`,e]})},{title:e(`c2.listeners.callbackShort`,null,`回连`),dataIndex:`configJson`,width:160,render:e=>{try{let t=JSON.parse(e||`{}`);return t.callback_host?(0,I.jsx)(`span`,{className:`c2-mono`,children:t.callback_host}):(0,I.jsx)(V,{type:`tertiary`,children:`—`})}catch{return(0,I.jsx)(V,{type:`tertiary`,children:`—`})}}},{title:e(`c2.listeners.status`,null,`状态`),dataIndex:`status`,width:120,render:(e,t)=>(0,I.jsxs)(`div`,{className:`c2-listener-status`,children:[(0,I.jsx)(l,{size:`small`,color:N[e]||`grey`,children:M[e]||e||`—`}),t.lastError&&(0,I.jsx)(V,{type:`danger`,size:`small`,children:t.lastError})]})},{title:e(`c2.listeners.startedAtPrefix`,null,`启动于`),dataIndex:`startedAt`,width:180,render:e=>e?d(e):(0,I.jsx)(V,{type:`tertiary`,children:`—`})},{title:e(`c2.listeners.actions`,null,`操作`),dataIndex:`actions`,width:220,render:(t,r)=>{let s=r.status===`running`;return(0,I.jsxs)(a,{spacing:4,wrap:!0,children:[(0,I.jsx)(i,{size:`small`,theme:`borderless`,disabled:!n,loading:z===r.id,onClick:()=>ee(r,s?`stop`:`start`),children:s?e(`c2.listeners.stop`,null,`停止`):e(`c2.listeners.start`,null,`启动`)}),(0,I.jsx)(i,{size:`small`,theme:`borderless`,disabled:!n,onClick:()=>P({visible:!0,record:r}),children:e(`c2.listeners.edit`,null,`编辑`)}),(0,I.jsx)(i,{size:`small`,theme:`borderless`,type:`danger`,disabled:!o,onClick:()=>te(r),children:e(`c2.listeners.delete`,null,`删除`)})]})}}];return(0,I.jsxs)(`div`,{className:`c2-page`,id:`page-c2-listeners`,children:[(0,I.jsx)(b,{title:e(`c2.listeners.title`,null,`监听器管理`),description:e(`c2.listeners.pageDesc`,null,`创建并启停 C2 监听器,启停状态即时同步到后端`),extra:[(0,I.jsx)(i,{icon:(0,I.jsx)(c,{}),onClick:Y,loading:q,children:e(`common.refresh`,null,`刷新`)},`refresh`),(0,I.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,I.jsx)(u,{}),disabled:!n,onClick:()=>P({visible:!0,record:null}),children:e(`c2.listeners.create`,null,`创建监听器`)},`create`)]}),(0,I.jsx)(m,{metrics:$,columns:4}),(0,I.jsx)(_,{error:J,onRetry:Y}),(0,I.jsx)(v,{title:e(`c2.listeners.title`,null,`监听器列表`),children:(0,I.jsx)(x,{columns:re,dataSource:X,rowKey:`id`,loading:q,onRefresh:Y,pagination:{pageSize:10},emptyText:e(`c2.listeners.emptyTitle`,null,`暂无监听器`)})}),(0,I.jsx)(B,{visible:s.visible,record:s.record,projects:Q,profiles:Z,submitting:L,onCancel:()=>P({visible:!1,record:null}),onSubmit:ne}),(0,I.jsxs)(r,{visible:!!W,title:e(`c2.listeners.implantTokenTitle`,null,`植入体 Token`),onCancel:()=>G(null),footer:(0,I.jsx)(i,{onClick:()=>G(null),children:e(`c2.listeners.close`,null,`关闭`)}),children:[(0,I.jsx)(V,{type:`tertiary`,children:e(`c2.listeners.implantTokenHint`,null,`该 Token 仅在此处显示一次,请立即保存;后续可通过重新创建监听器获取。`)}),(0,I.jsxs)(`div`,{className:`c2-listener-token`,children:[(0,I.jsx)(`span`,{className:`c2-mono`,children:W?.token}),(0,I.jsx)(y,{text:W?.token||``})]})]})]})}export{U as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{C as r,I as i,P as a,U as o,i as s,it as c,j as l,ot as u}from"./semi-DNxeCrHm.js";import{E as d,F as f,P as p,_ as m,a as h,b as g,l as _,m as v,o as y,p as b,s as x,x as S,y as C}from"./index-smFoxEJu.js";import{D as w,E as T,O as E,b as D,i as O,l as k,x as A,y as j}from"./c2-shared-B5kg9aBy.js";import{a as M,i as N,o as P}from"./c2-shared-BBQQ9OoL.js";var F=e(t(),1),I=e(n(),1),{Text:L}=o;function R(e){if(!e?.configJson)return{};try{return JSON.parse(e.configJson)||{}}catch{return{}}}function z(e){let t=R(e);return{name:e?.name||``,type:e?.type||`http_beacon`,project_id:e?.project_id||``,bind_host:e?.bindHost||`127.0.0.1`,bind_port:String(e?.bindPort??`4444`),callback_host:t.callback_host||``,profile_id:e?.profileId||``,remark:e?.remark||``,default_sleep:String(t.default_sleep??5),default_jitter:String(t.default_jitter??0),max_concurrent_tasks:String(t.max_concurrent_tasks??0),allow_legacy_shell:!!t.allow_legacy_shell}}function B({visible:e,record:t,projects:n,profiles:o,submitting:c,onCancel:l,onSubmit:u}){let d=p(),[f,m]=(0,F.useState)(null),[h,g]=(0,F.useState)(t?.type||`http_beacon`);return(0,I.jsx)(r,{visible:e,title:t?d(`c2.listeners.editTitle`,null,`编辑监听器`):d(`c2.listeners.modalCreateTitle`,null,`创建监听器`),footer:null,width:620,onCancel:l,children:(0,I.jsxs)(s,{initValues:z(t),onSubmit:e=>{let t=Number(e.bind_port);u({name:String(e.name||``).trim(),type:e.type,project_id:e.project_id||``,bind_host:String(e.bind_host||``).trim()||`127.0.0.1`,bind_port:Number.isFinite(t)?t:0,callback_host:String(e.callback_host||``).trim(),profile_id:e.profile_id||``,remark:String(e.remark||``).trim(),config:{callback_host:String(e.callback_host||``).trim(),default_sleep:Number(e.default_sleep)||5,default_jitter:Number(e.default_jitter)||0,max_concurrent_tasks:Number(e.max_concurrent_tasks)||0,allow_legacy_shell:!!e.allow_legacy_shell}})},getFormApi:m,labelPosition:`top`,onValueChange:e=>{e.type&&g(e.type)},children:[(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`name`,label:d(`c2.listeners.name`,null,`名称`),placeholder:d(`c2.listeners.placeholderNameExample`,null,`例如 http-beacon-01`),rules:[{required:!0,message:d(`c2.listeners.nameRequired`,null,`请输入监听器名称`)}]}),(0,I.jsx)(s.Select,{field:`type`,label:d(`c2.listeners.type`,null,`类型`),optionList:P,disabled:!!t,style:{width:`100%`}})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`bind_host`,label:d(`c2.listeners.bindHost`,null,`绑定地址`),placeholder:`127.0.0.1`}),(0,I.jsx)(s.Input,{field:`bind_port`,label:d(`c2.listeners.bindPort`,null,`绑定端口`),placeholder:d(`c2.listeners.placeholderPort`,null,`输入端口号`),rules:[{required:!0,validator:(e,t)=>{let n=Number(t);return Number.isInteger(n)&&n>0&&n<=65535},message:d(`c2.listeners.portInvalid`,null,`端口必须为 1–65535 的整数`)}]})]}),(0,I.jsx)(L,{type:`tertiary`,size:`small`,children:d(`c2.listeners.bindHintExternal`,null,`使用 0.0.0.0 允许外部访问`)}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`callback_host`,label:d(`c2.listeners.callbackHost`,null,`回连地址(可选)`),placeholder:`公网 IP 或域名`}),(0,I.jsx)(s.Select,{field:`profile_id`,label:d(`c2.listeners.malleableProfile`,null,`Malleable Profile`),optionList:[{value:``,label:d(`c2.listeners.malleableProfileNone`,null,`不使用`)},...o.map(e=>({value:e.id,label:e.name||e.id}))],style:{width:`100%`}})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Select,{field:`project_id`,label:d(`c2.listeners.project`,null,`所属项目`),optionList:[{value:``,label:d(`c2.listeners.projectNone`,null,`不绑定项目`)},...n.map(e=>({value:e.id,label:e.name||e.id}))],style:{width:`100%`}}),(0,I.jsx)(s.Input,{field:`remark`,label:d(`c2.listeners.remark`,null,`备注`),placeholder:d(`c2.listeners.placeholderRemarkLong`,null,`可选的备注说明`)})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`default_sleep`,label:`默认 Sleep(秒)`,placeholder:`5`}),(0,I.jsx)(s.Input,{field:`default_jitter`,label:`默认 Jitter(%)`,placeholder:`0`})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`max_concurrent_tasks`,label:`单会话并发任务上限(0 不限)`,placeholder:`0`}),h===`tcp_reverse`&&(0,I.jsx)(s.Switch,{field:`allow_legacy_shell`,label:d(`c2.listeners.allowLegacyShell`,null,`允许未加密经典反弹 Shell(内网实验)`)})]}),(0,I.jsxs)(a,{className:`c2-form-actions`,children:[(0,I.jsx)(i,{onClick:l,children:d(`c2.common.cancel`,null,`取消`)}),(0,I.jsx)(i,{theme:`solid`,type:`primary`,loading:c,onClick:()=>f?.submitForm(),children:t?d(`c2.listeners.save`,null,`保存`):d(`c2.listeners.submitCreate`,null,`创建`)})]})]},t?.id||`new`)})}var{Text:V}=o,H=e=>P.find(t=>t.value===e)?.label||e||`—`;function U(){let e=p(),{hasPermission:t}=f(),n=t(`c2:write`),o=t(`c2:delete`)||n,[s,P]=(0,F.useState)({visible:!1,record:null}),[L,R]=(0,F.useState)(!1),[z,U]=(0,F.useState)(``),[W,G]=(0,F.useState)(null),{data:K,loading:q,error:J,reload:Y}=h(()=>Promise.all([j(),D().catch(()=>({profiles:[]})),A()]),[]),X=Array.isArray(K?.[0]?.listeners)?K[0].listeners:[],Z=Array.isArray(K?.[1]?.profiles)?K[1].profiles:[],Q=Array.isArray(K?.[2])?K[2]:[],$=(0,F.useMemo)(()=>{let t=X.filter(e=>e.status===`running`).length,n=X.filter(e=>e.status===`error`).length;return[{id:`total`,label:e(`c2.listeners.statTotal`,null,`监听器总数`),value:X.length},{id:`running`,label:e(`c2.listeners.running`,null,`运行中`),value:t,tone:t?`success`:void 0},{id:`stopped`,label:e(`c2.listeners.stopped`,null,`已停止`),value:X.length-t-n},{id:`error`,label:e(`c2.listeners.statusError`,null,`异常`),value:n,tone:n?`danger`:void 0}]},[X,e]),ee=async(t,n)=>{U(t.id);try{n===`start`?(await T(t.id),S(e(`c2.listeners.toastStarted`,null,`监听器已启动`))):(await w(t.id),S(e(`c2.listeners.toastStopped`,null,`监听器已停止`))),Y()}catch(t){g(t,n===`start`?e(`c2.listeners.start`,null,`启动失败`):e(`c2.listeners.stop`,null,`停止失败`))}finally{U(``)}},te=t=>{C({title:e(`c2.listeners.delete`,null,`删除监听器`),content:e(`c2.listeners.confirmDelete`,null,`确定删除此监听器?相关会话与任务将被清除。`),onOk:async()=>{try{await k(t.id),S(e(`c2.listeners.toastDeleted`,null,`监听器已删除`)),Y()}catch(e){g(e)}}})},ne=async t=>{R(!0);try{if(s.record?.id)await E(s.record.id,t),S(e(`c2.listeners.toastUpdated`,null,`监听器已更新`));else{let n=await O(t);S(e(`c2.listeners.toastCreated`,null,`监听器已创建`)),n?.implant_token&&G({name:n.listener?.name||t.name,token:n.implant_token})}P({visible:!1,record:null}),Y()}catch(t){g(t,e(`c2.listeners.saveFailed`,null,`监听器保存失败`))}finally{R(!1)}},re=[{title:e(`c2.listeners.name`,null,`名称`),dataIndex:`name`,render:(e,t)=>(0,I.jsxs)(`div`,{className:`c2-listener-name`,children:[(0,I.jsx)(V,{strong:!0,children:e||t.id}),t.remark&&(0,I.jsx)(V,{type:`tertiary`,size:`small`,children:t.remark})]})},{title:e(`c2.listeners.type`,null,`类型`),dataIndex:`type`,width:140,render:H},{title:e(`c2.listeners.bindEndpoint`,null,`监听地址`),dataIndex:`bindPort`,width:200,render:(e,t)=>(0,I.jsxs)(`span`,{className:`c2-mono`,children:[t.bindHost,`:`,e]})},{title:e(`c2.listeners.callbackShort`,null,`回连`),dataIndex:`configJson`,width:160,render:e=>{try{let t=JSON.parse(e||`{}`);return t.callback_host?(0,I.jsx)(`span`,{className:`c2-mono`,children:t.callback_host}):(0,I.jsx)(V,{type:`tertiary`,children:`—`})}catch{return(0,I.jsx)(V,{type:`tertiary`,children:`—`})}}},{title:e(`c2.listeners.status`,null,`状态`),dataIndex:`status`,width:120,render:(e,t)=>(0,I.jsxs)(`div`,{className:`c2-listener-status`,children:[(0,I.jsx)(l,{size:`small`,color:N[e]||`grey`,children:M[e]||e||`—`}),t.lastError&&(0,I.jsx)(V,{type:`danger`,size:`small`,children:t.lastError})]})},{title:e(`c2.listeners.startedAtPrefix`,null,`启动于`),dataIndex:`startedAt`,width:180,render:e=>e?d(e):(0,I.jsx)(V,{type:`tertiary`,children:`—`})},{title:e(`c2.listeners.actions`,null,`操作`),dataIndex:`actions`,width:220,render:(t,r)=>{let s=r.status===`running`;return(0,I.jsxs)(a,{spacing:4,wrap:!0,children:[(0,I.jsx)(i,{size:`small`,theme:`borderless`,disabled:!n,loading:z===r.id,onClick:()=>ee(r,s?`stop`:`start`),children:s?e(`c2.listeners.stop`,null,`停止`):e(`c2.listeners.start`,null,`启动`)}),(0,I.jsx)(i,{size:`small`,theme:`borderless`,disabled:!n,onClick:()=>P({visible:!0,record:r}),children:e(`c2.listeners.edit`,null,`编辑`)}),(0,I.jsx)(i,{size:`small`,theme:`borderless`,type:`danger`,disabled:!o,onClick:()=>te(r),children:e(`c2.listeners.delete`,null,`删除`)})]})}}];return(0,I.jsxs)(`div`,{className:`c2-page`,id:`page-c2-listeners`,children:[(0,I.jsx)(b,{title:e(`c2.listeners.title`,null,`监听器管理`),description:e(`c2.listeners.pageDesc`,null,`创建并启停 C2 监听器,启停状态即时同步到后端`),extra:[(0,I.jsx)(i,{icon:(0,I.jsx)(c,{}),onClick:Y,loading:q,children:e(`common.refresh`,null,`刷新`)},`refresh`),(0,I.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,I.jsx)(u,{}),disabled:!n,onClick:()=>P({visible:!0,record:null}),children:e(`c2.listeners.create`,null,`创建监听器`)},`create`)]}),(0,I.jsx)(m,{metrics:$,columns:4}),(0,I.jsx)(_,{error:J,onRetry:Y}),(0,I.jsx)(v,{title:e(`c2.listeners.title`,null,`监听器列表`),children:(0,I.jsx)(x,{columns:re,dataSource:X,rowKey:`id`,loading:q,onRefresh:Y,pagination:{pageSize:10},emptyText:e(`c2.listeners.emptyTitle`,null,`暂无监听器`)})}),(0,I.jsx)(B,{visible:s.visible,record:s.record,projects:Q,profiles:Z,submitting:L,onCancel:()=>P({visible:!1,record:null}),onSubmit:ne}),(0,I.jsxs)(r,{visible:!!W,title:e(`c2.listeners.implantTokenTitle`,null,`植入体 Token`),onCancel:()=>G(null),footer:(0,I.jsx)(i,{onClick:()=>G(null),children:e(`c2.listeners.close`,null,`关闭`)}),children:[(0,I.jsx)(V,{type:`tertiary`,children:e(`c2.listeners.implantTokenHint`,null,`该 Token 仅在此处显示一次,请立即保存;后续可通过重新创建监听器获取。`)}),(0,I.jsxs)(`div`,{className:`c2-listener-token`,children:[(0,I.jsx)(`span`,{className:`c2-mono`,children:W?.token}),(0,I.jsx)(y,{text:W?.token||``})]})]})]})}export{U as default};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-payloads-C_C_YA7N.js b/web/static/app/assets/c2-payloads-DvqcThjq.js
similarity index 97%
rename from web/static/app/assets/c2-payloads-C_C_YA7N.js
rename to web/static/app/assets/c2-payloads-DvqcThjq.js
index 4fb7674e..caffd4ca 100644
--- a/web/static/app/assets/c2-payloads-C_C_YA7N.js
+++ b/web/static/app/assets/c2-payloads-DvqcThjq.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{I as r,P as i,U as a,V as o,_ as s,j as ee}from"./semi-DNxeCrHm.js";import{F as c,P as l,S as u,T as d,a as f,b as p,l as m,m as h,o as g,p as _,s as v,x as y}from"./index-BoFwOeaz.js";import{m as b,n as x,t as S,y as C}from"./c2-shared-DQceLFCe.js";import{o as w,s as T}from"./c2-shared-BkIzs15k.js";var E=e(t(),1),D=e(n(),1),{Text:O,Title:k}=a,A=[{value:`linux`,label:`Linux`},{value:`windows`,label:`Windows`},{value:`darwin`,label:`macOS`}],j=[{value:`amd64`,label:`AMD64`},{value:`arm64`,label:`ARM64`},{value:`386`,label:`386`}],M=e=>w.find(t=>t.value===e)?.label||e||`—`;function N(){let e=l(),{hasPermission:t}=c(),n=t(`c2:write`),{data:a,loading:w,error:N,reload:P}=f(()=>C(),[]),F=Array.isArray(a?.listeners)?a.listeners:[],[I,L]=(0,E.useState)({listenerId:``,kind:``,host:``}),[R,z]=(0,E.useState)(null),[B,V]=(0,E.useState)(!1),[H,U]=(0,E.useState)({listenerId:``,host:``,os:`linux`,arch:`amd64`}),[W,G]=(0,E.useState)(null),[K,q]=(0,E.useState)(!1),[J,Y]=(0,E.useState)([]),X=(0,E.useMemo)(()=>F.find(e=>e.id===(I.listenerId||F[0]?.id))||null,[F,I.listenerId]),Z=T[X?.type]||[],Q=F.map(e=>({value:e.id,label:`${e.name||e.id} · ${M(e.type)}`})),te=async()=>{let t=I.listenerId||F[0]?.id;if(!t){u(e(`c2.payloads.toastPickListener`,null,`请先选择一个监听器`));return}let n=I.kind||Z[0]?.value;if(!n)u(e(`c2.payloads.noKindOption`,null,`无可用类型`));else{V(!0);try{let e=await S({listener_id:t,kind:n,host:I.host.trim()});z(e)}catch(t){p(t,e(`c2.payloads.toastOnelinerFail`,null,`生成 Oneliner 失败`))}finally{V(!1)}}},ne=async()=>{let t=H.listenerId||F[0]?.id;if(!t)u(e(`c2.payloads.toastPickListener`,null,`请先选择一个监听器`));else{q(!0);try{let n=(await x({listener_id:t,host:H.host.trim(),os:H.os,arch:H.arch,sleep_seconds:5,jitter_percent:0}))?.payload||null;if(G(n),n){let r=String(n.output_path||``).split(/[\\/]/).pop();Y(e=>[{id:n.payload_id||r,fileName:r,listenerId:t,os:n.os,arch:n.arch,size:n.size_bytes},...e]),y(e(`c2.payloads.toastBuildSuccess`,null,`构建成功`).replace(`{{bytes}}`,String(n.size_bytes||0)))}}catch(t){p(t,e(`c2.payloads.toastBuildFail`,null,`构建 Beacon 失败`))}finally{q(!1)}}},$=async t=>{if(!t.fileName?.startsWith(`beacon_`))u(e(`c2.payloads.invalidArtifact`,null,`该产物不可下载`));else try{await b(t.fileName,t.fileName),y(e(`c2.payloads.toastDownloadQueued`,null,`下载任务已排队`))}catch(t){p(t,e(`c2.payloads.download`,null,`下载失败`))}},re=[{title:e(`c2.payloads.fileName`,null,`文件`),dataIndex:`fileName`,render:e=>(0,D.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.payloads.os`,null,`系统`),dataIndex:`os`,width:100},{title:e(`c2.payloads.arch`,null,`架构`),dataIndex:`arch`,width:100},{title:e(`c2.payloads.size`,null,`大小`),dataIndex:`size`,width:110,render:e=>d(e)},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:120,render:(t,n)=>(0,D.jsx)(r,{size:`small`,theme:`borderless`,onClick:()=>$(n),children:e(`c2.payloads.download`,null,`下载`)})}];return(0,D.jsxs)(`div`,{className:`c2-page`,id:`page-c2-payloads`,children:[(0,D.jsx)(_,{title:e(`c2.payloads.title`,null,`Payload 生成`),description:e(`c2.payloads.pageDesc`,null,`生成单行反弹命令,或交叉编译完整 Beacon 二进制`),extra:[(0,D.jsx)(r,{onClick:P,loading:w,children:e(`common.refresh`,null,`刷新`)},`refresh`)]}),(0,D.jsx)(m,{error:N,onRetry:P}),(0,D.jsxs)(`div`,{className:`c2-payload-grid`,children:[(0,D.jsxs)(h,{title:e(`c2.payloads.oneliner`,null,`单行 Payload`),description:e(`c2.payloads.onelinerDesc`,null,`生成可在目标机直接执行的反弹命令`),children:[(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.listener`,null,`监听器`)}),(0,D.jsx)(s,{value:I.listenerId||F[0]?.id||``,onChange:e=>L(t=>({...t,listenerId:e,kind:``})),optionList:Q,placeholder:e(`c2.payloads.noListenersOption`,null,`暂无可用监听器`),style:{width:`100%`}})]}),(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.kind`,null,`类型`)}),(0,D.jsx)(s,{value:I.kind||Z[0]?.value||``,onChange:e=>L(t=>({...t,kind:e})),optionList:Z,placeholder:e(`c2.payloads.noKindOption`,null,`无可用类型`),style:{width:`100%`}})]}),(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.hostOptional`,null,`回连地址(可选)`)}),(0,D.jsx)(o,{value:I.host,onChange:e=>L(t=>({...t,host:e})),placeholder:e(`c2.payloads.placeholderListenerHost`,null,`留空则使用监听器回连地址`)})]}),(0,D.jsx)(r,{theme:`solid`,type:`primary`,block:!0,disabled:!n,loading:B,onClick:te,children:e(`c2.payloads.generateOnelinerBtn`,null,`生成 Oneliner`)}),R?.oneliner&&(0,D.jsxs)(`div`,{className:`c2-oneliner-result`,children:[(0,D.jsxs)(`div`,{className:`c2-oneliner-head`,children:[(0,D.jsxs)(i,{spacing:6,children:[(0,D.jsx)(ee,{size:`small`,children:R.kind}),(0,D.jsxs)(O,{type:`tertiary`,size:`small`,children:[R.host,`:`,R.port]})]}),(0,D.jsx)(g,{text:R.oneliner,label:e(`c2.payloads.copy`,null,`复制`),size:`small`})]}),(0,D.jsx)(`pre`,{className:`c2-pre`,children:R.oneliner})]})]}),(0,D.jsxs)(h,{title:e(`c2.payloads.build`,null,`编译 Beacon`),description:e(`c2.payloads.buildDesc`,null,`交叉编译多平台完整 Beacon 可执行文件`),children:[(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.listener`,null,`监听器`)}),(0,D.jsx)(s,{value:H.listenerId||F[0]?.id||``,onChange:e=>U(t=>({...t,listenerId:e})),optionList:Q,placeholder:e(`c2.payloads.noListenersOption`,null,`暂无可用监听器`),style:{width:`100%`}})]}),(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.hostOptional`,null,`回连地址(可选)`)}),(0,D.jsx)(o,{value:H.host,onChange:e=>U(t=>({...t,host:e})),placeholder:e(`c2.payloads.placeholderListenerHost`,null,`留空则使用监听器回连地址`)})]}),(0,D.jsxs)(`div`,{className:`c2-form-row`,children:[(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.os`,null,`目标系统`)}),(0,D.jsx)(s,{value:H.os,onChange:e=>U(t=>({...t,os:e})),optionList:A,style:{width:`100%`}})]}),(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.arch`,null,`目标架构`)}),(0,D.jsx)(s,{value:H.arch,onChange:e=>U(t=>({...t,arch:e})),optionList:j,style:{width:`100%`}})]})]}),(0,D.jsx)(r,{theme:`solid`,type:`primary`,block:!0,disabled:!n,loading:K,onClick:ne,children:e(`c2.payloads.buildBeaconBtn`,null,`构建 Beacon`)}),W&&(0,D.jsxs)(`div`,{className:`c2-build-result`,children:[(0,D.jsx)(k,{heading:6,children:e(`c2.payloads.buildSuccessTitle`,null,`构建成功`)}),(0,D.jsx)(O,{type:`tertiary`,size:`small`,children:e(`c2.payloads.buildMetaOsArch`,null,`系统 / 架构`).replace(`{{os}}`,W.os||`—`).replace(`{{arch}}`,W.arch||`—`)}),(0,D.jsx)(O,{type:`tertiary`,size:`small`,children:e(`c2.payloads.buildSize`,null,`大小`).replace(`{{bytes}}`,String(W.size_bytes||0))}),(0,D.jsx)(`pre`,{className:`c2-pre`,children:W.output_path}),(0,D.jsx)(r,{size:`small`,onClick:()=>$({fileName:String(W.output_path||``).split(/[\\/]/).pop(),...W}),children:e(`c2.payloads.download`,null,`下载`)})]})]})]}),(0,D.jsx)(h,{title:e(`c2.payloads.artifacts`,null,`本次会话构建产物`),children:(0,D.jsx)(v,{columns:re,dataSource:J,rowKey:`id`,pagination:{pageSize:10},emptyText:e(`c2.payloads.noArtifacts`,null,`暂无构建产物`)})})]})}export{N as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{I as r,P as i,U as a,V as o,_ as s,j as ee}from"./semi-DNxeCrHm.js";import{F as c,P as l,S as u,T as d,a as f,b as p,l as m,m as h,o as g,p as _,s as v,x as y}from"./index-smFoxEJu.js";import{m as b,n as x,t as S,y as C}from"./c2-shared-B5kg9aBy.js";import{o as w,s as T}from"./c2-shared-BBQQ9OoL.js";var E=e(t(),1),D=e(n(),1),{Text:O,Title:k}=a,A=[{value:`linux`,label:`Linux`},{value:`windows`,label:`Windows`},{value:`darwin`,label:`macOS`}],j=[{value:`amd64`,label:`AMD64`},{value:`arm64`,label:`ARM64`},{value:`386`,label:`386`}],M=e=>w.find(t=>t.value===e)?.label||e||`—`;function N(){let e=l(),{hasPermission:t}=c(),n=t(`c2:write`),{data:a,loading:w,error:N,reload:P}=f(()=>C(),[]),F=Array.isArray(a?.listeners)?a.listeners:[],[I,L]=(0,E.useState)({listenerId:``,kind:``,host:``}),[R,z]=(0,E.useState)(null),[B,V]=(0,E.useState)(!1),[H,U]=(0,E.useState)({listenerId:``,host:``,os:`linux`,arch:`amd64`}),[W,G]=(0,E.useState)(null),[K,q]=(0,E.useState)(!1),[J,Y]=(0,E.useState)([]),X=(0,E.useMemo)(()=>F.find(e=>e.id===(I.listenerId||F[0]?.id))||null,[F,I.listenerId]),Z=T[X?.type]||[],Q=F.map(e=>({value:e.id,label:`${e.name||e.id} · ${M(e.type)}`})),te=async()=>{let t=I.listenerId||F[0]?.id;if(!t){u(e(`c2.payloads.toastPickListener`,null,`请先选择一个监听器`));return}let n=I.kind||Z[0]?.value;if(!n)u(e(`c2.payloads.noKindOption`,null,`无可用类型`));else{V(!0);try{let e=await S({listener_id:t,kind:n,host:I.host.trim()});z(e)}catch(t){p(t,e(`c2.payloads.toastOnelinerFail`,null,`生成 Oneliner 失败`))}finally{V(!1)}}},ne=async()=>{let t=H.listenerId||F[0]?.id;if(!t)u(e(`c2.payloads.toastPickListener`,null,`请先选择一个监听器`));else{q(!0);try{let n=(await x({listener_id:t,host:H.host.trim(),os:H.os,arch:H.arch,sleep_seconds:5,jitter_percent:0}))?.payload||null;if(G(n),n){let r=String(n.output_path||``).split(/[\\/]/).pop();Y(e=>[{id:n.payload_id||r,fileName:r,listenerId:t,os:n.os,arch:n.arch,size:n.size_bytes},...e]),y(e(`c2.payloads.toastBuildSuccess`,null,`构建成功`).replace(`{{bytes}}`,String(n.size_bytes||0)))}}catch(t){p(t,e(`c2.payloads.toastBuildFail`,null,`构建 Beacon 失败`))}finally{q(!1)}}},$=async t=>{if(!t.fileName?.startsWith(`beacon_`))u(e(`c2.payloads.invalidArtifact`,null,`该产物不可下载`));else try{await b(t.fileName,t.fileName),y(e(`c2.payloads.toastDownloadQueued`,null,`下载任务已排队`))}catch(t){p(t,e(`c2.payloads.download`,null,`下载失败`))}},re=[{title:e(`c2.payloads.fileName`,null,`文件`),dataIndex:`fileName`,render:e=>(0,D.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.payloads.os`,null,`系统`),dataIndex:`os`,width:100},{title:e(`c2.payloads.arch`,null,`架构`),dataIndex:`arch`,width:100},{title:e(`c2.payloads.size`,null,`大小`),dataIndex:`size`,width:110,render:e=>d(e)},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:120,render:(t,n)=>(0,D.jsx)(r,{size:`small`,theme:`borderless`,onClick:()=>$(n),children:e(`c2.payloads.download`,null,`下载`)})}];return(0,D.jsxs)(`div`,{className:`c2-page`,id:`page-c2-payloads`,children:[(0,D.jsx)(_,{title:e(`c2.payloads.title`,null,`Payload 生成`),description:e(`c2.payloads.pageDesc`,null,`生成单行反弹命令,或交叉编译完整 Beacon 二进制`),extra:[(0,D.jsx)(r,{onClick:P,loading:w,children:e(`common.refresh`,null,`刷新`)},`refresh`)]}),(0,D.jsx)(m,{error:N,onRetry:P}),(0,D.jsxs)(`div`,{className:`c2-payload-grid`,children:[(0,D.jsxs)(h,{title:e(`c2.payloads.oneliner`,null,`单行 Payload`),description:e(`c2.payloads.onelinerDesc`,null,`生成可在目标机直接执行的反弹命令`),children:[(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.listener`,null,`监听器`)}),(0,D.jsx)(s,{value:I.listenerId||F[0]?.id||``,onChange:e=>L(t=>({...t,listenerId:e,kind:``})),optionList:Q,placeholder:e(`c2.payloads.noListenersOption`,null,`暂无可用监听器`),style:{width:`100%`}})]}),(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.kind`,null,`类型`)}),(0,D.jsx)(s,{value:I.kind||Z[0]?.value||``,onChange:e=>L(t=>({...t,kind:e})),optionList:Z,placeholder:e(`c2.payloads.noKindOption`,null,`无可用类型`),style:{width:`100%`}})]}),(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.hostOptional`,null,`回连地址(可选)`)}),(0,D.jsx)(o,{value:I.host,onChange:e=>L(t=>({...t,host:e})),placeholder:e(`c2.payloads.placeholderListenerHost`,null,`留空则使用监听器回连地址`)})]}),(0,D.jsx)(r,{theme:`solid`,type:`primary`,block:!0,disabled:!n,loading:B,onClick:te,children:e(`c2.payloads.generateOnelinerBtn`,null,`生成 Oneliner`)}),R?.oneliner&&(0,D.jsxs)(`div`,{className:`c2-oneliner-result`,children:[(0,D.jsxs)(`div`,{className:`c2-oneliner-head`,children:[(0,D.jsxs)(i,{spacing:6,children:[(0,D.jsx)(ee,{size:`small`,children:R.kind}),(0,D.jsxs)(O,{type:`tertiary`,size:`small`,children:[R.host,`:`,R.port]})]}),(0,D.jsx)(g,{text:R.oneliner,label:e(`c2.payloads.copy`,null,`复制`),size:`small`})]}),(0,D.jsx)(`pre`,{className:`c2-pre`,children:R.oneliner})]})]}),(0,D.jsxs)(h,{title:e(`c2.payloads.build`,null,`编译 Beacon`),description:e(`c2.payloads.buildDesc`,null,`交叉编译多平台完整 Beacon 可执行文件`),children:[(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.listener`,null,`监听器`)}),(0,D.jsx)(s,{value:H.listenerId||F[0]?.id||``,onChange:e=>U(t=>({...t,listenerId:e})),optionList:Q,placeholder:e(`c2.payloads.noListenersOption`,null,`暂无可用监听器`),style:{width:`100%`}})]}),(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.hostOptional`,null,`回连地址(可选)`)}),(0,D.jsx)(o,{value:H.host,onChange:e=>U(t=>({...t,host:e})),placeholder:e(`c2.payloads.placeholderListenerHost`,null,`留空则使用监听器回连地址`)})]}),(0,D.jsxs)(`div`,{className:`c2-form-row`,children:[(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.os`,null,`目标系统`)}),(0,D.jsx)(s,{value:H.os,onChange:e=>U(t=>({...t,os:e})),optionList:A,style:{width:`100%`}})]}),(0,D.jsxs)(`div`,{className:`c2-field`,children:[(0,D.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.arch`,null,`目标架构`)}),(0,D.jsx)(s,{value:H.arch,onChange:e=>U(t=>({...t,arch:e})),optionList:j,style:{width:`100%`}})]})]}),(0,D.jsx)(r,{theme:`solid`,type:`primary`,block:!0,disabled:!n,loading:K,onClick:ne,children:e(`c2.payloads.buildBeaconBtn`,null,`构建 Beacon`)}),W&&(0,D.jsxs)(`div`,{className:`c2-build-result`,children:[(0,D.jsx)(k,{heading:6,children:e(`c2.payloads.buildSuccessTitle`,null,`构建成功`)}),(0,D.jsx)(O,{type:`tertiary`,size:`small`,children:e(`c2.payloads.buildMetaOsArch`,null,`系统 / 架构`).replace(`{{os}}`,W.os||`—`).replace(`{{arch}}`,W.arch||`—`)}),(0,D.jsx)(O,{type:`tertiary`,size:`small`,children:e(`c2.payloads.buildSize`,null,`大小`).replace(`{{bytes}}`,String(W.size_bytes||0))}),(0,D.jsx)(`pre`,{className:`c2-pre`,children:W.output_path}),(0,D.jsx)(r,{size:`small`,onClick:()=>$({fileName:String(W.output_path||``).split(/[\\/]/).pop(),...W}),children:e(`c2.payloads.download`,null,`下载`)})]})]})]}),(0,D.jsx)(h,{title:e(`c2.payloads.artifacts`,null,`本次会话构建产物`),children:(0,D.jsx)(v,{columns:re,dataSource:J,rowKey:`id`,pagination:{pageSize:10},emptyText:e(`c2.payloads.noArtifacts`,null,`暂无构建产物`)})})]})}export{N as default};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-profiles-C1JrB05z.js b/web/static/app/assets/c2-profiles-CoAwMcjF.js
similarity index 97%
rename from web/static/app/assets/c2-profiles-C1JrB05z.js
rename to web/static/app/assets/c2-profiles-CoAwMcjF.js
index 2ec043ab..53ef5d7f 100644
--- a/web/static/app/assets/c2-profiles-C1JrB05z.js
+++ b/web/static/app/assets/c2-profiles-CoAwMcjF.js
@@ -1,2 +1,2 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{C as r,I as i,P as a,U as o,i as s,it as c,j as l,ot as u}from"./semi-DNxeCrHm.js";import{E as d,F as f,P as p,S as m,_ as h,a as g,b as _,l as v,m as y,p as b,s as x,u as S,x as C,y as w}from"./index-BoFwOeaz.js";import{a as T,b as E,k as D,u as O}from"./c2-shared-DQceLFCe.js";var k=e(t(),1),A=e(n(),1),{Text:j}=o;function M(e){return{name:e?.name||``,user_agent:e?.userAgent||``,uris:Array.isArray(e?.uris)?e.uris.join(`
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{C as r,I as i,P as a,U as o,i as s,it as c,j as l,ot as u}from"./semi-DNxeCrHm.js";import{E as d,F as f,P as p,S as m,_ as h,a as g,b as _,l as v,m as y,p as b,s as x,u as S,x as C,y as w}from"./index-smFoxEJu.js";import{a as T,b as E,k as D,u as O}from"./c2-shared-B5kg9aBy.js";var k=e(t(),1),A=e(n(),1),{Text:j}=o;function M(e){return{name:e?.name||``,user_agent:e?.userAgent||``,uris:Array.isArray(e?.uris)?e.uris.join(`
`):``,jitter_min:String(e?.jitterMinMs??0),jitter_max:String(e?.jitterMaxMs??0),request_headers:e?.requestHeaders?JSON.stringify(e.requestHeaders,null,2):``,response_headers:e?.responseHeaders?JSON.stringify(e.responseHeaders,null,2):``,body_template:e?.bodyTemplate||``}}function N(e,t){let n=String(e||``).trim();if(!n)return{};try{let e=JSON.parse(n);if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`not an object`);return e}catch{return m(t(`c2.profiles.toastInvalidHeadersJson`,null,`响应头 JSON 无效`)),null}}function P({visible:e,record:t,submitting:n,onCancel:o,onSubmit:c}){let l=p(),[u,d]=(0,k.useState)(null);return(0,A.jsx)(r,{visible:e,title:t?l(`c2.profiles.editTitle`,null,`编辑 Profile`):l(`c2.profiles.modalCreateTitle`,null,`创建 Malleable Profile`),footer:null,width:640,onCancel:o,children:(0,A.jsxs)(s,{initValues:M(t),onSubmit:e=>{let t=Number(e.jitter_min),n=Number(e.jitter_max);if(!Number.isInteger(t)||!Number.isInteger(n)||t<0||ne.trim()).filter(Boolean),jitterMinMs:t,jitterMaxMs:n,requestHeaders:r,responseHeaders:i,bodyTemplate:String(e.body_template||``)})},getFormApi:d,labelPosition:`top`,children:[(0,A.jsx)(s.Input,{field:`name`,label:l(`c2.profiles.profileNameLabel`,null,`Profile 名称`),placeholder:l(`c2.profiles.placeholderProfileName`,null,`例如 cdn-fronting`),rules:[{required:!0,message:l(`c2.profiles.toastNameRequired`,null,`请填写 Profile 名称`)}]}),(0,A.jsx)(s.Input,{field:`user_agent`,label:l(`c2.profiles.userAgent`,null,`User-Agent`),placeholder:`Mozilla/5.0 ...`}),(0,A.jsx)(s.TextArea,{field:`uris`,label:l(`c2.profiles.labelBeaconUris`,null,`Beacon URI(每行一个)`),placeholder:`/api/v1/ping`,autosize:{minRows:2,maxRows:5}}),(0,A.jsxs)(`div`,{className:`c2-form-row`,children:[(0,A.jsx)(s.Input,{field:`jitter_min`,label:l(`c2.profiles.labelJitterMin`,null,`Jitter 最小值 (ms)`),placeholder:`0`}),(0,A.jsx)(s.Input,{field:`jitter_max`,label:l(`c2.profiles.labelJitterMax`,null,`Jitter 最大值 (ms)`),placeholder:`0`})]}),(0,A.jsx)(s.TextArea,{field:`request_headers`,label:l(`c2.profiles.requestHeadersJson`,null,`自定义请求头 (JSON)`),placeholder:`{"X-Forwarded-For":"127.0.0.1"}`,autosize:{minRows:2,maxRows:6}}),(0,A.jsx)(s.TextArea,{field:`response_headers`,label:l(`c2.profiles.labelRespHeaders`,null,`自定义响应头 (JSON)`),placeholder:`{"Server":"nginx"}`,autosize:{minRows:2,maxRows:6}}),(0,A.jsx)(s.TextArea,{field:`body_template`,label:l(`c2.profiles.bodyTemplate`,null,`响应体模板`),placeholder:`{"status":"ok"}`,autosize:{minRows:2,maxRows:6}}),(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:l(`c2.profiles.hintHeaders`,null,`用于伪装为合法服务的 HTTP 响应头`)}),(0,A.jsxs)(a,{className:`c2-form-actions`,children:[(0,A.jsx)(i,{onClick:o,children:l(`c2.common.cancel`,null,`取消`)}),(0,A.jsx)(i,{theme:`solid`,type:`primary`,loading:n,onClick:()=>u?.submitForm(),children:t?l(`c2.profiles.save`,null,`保存`):l(`c2.profiles.submitCreate`,null,`创建`)})]})]},t?.id||`new`)})}var{Text:F}=o;function I(){let e=p(),{hasPermission:t}=f(),n=t(`c2:write`),r=t(`c2:delete`)||n,[o,s]=(0,k.useState)({visible:!1,record:null}),[m,j]=(0,k.useState)(!1),[M,N]=(0,k.useState)(null),{data:I,loading:L,error:R,reload:z}=g(()=>E(),[]),B=Array.isArray(I?.profiles)?I.profiles:[],V=(0,k.useMemo)(()=>[{id:`total`,label:e(`c2.profiles.total`,null,`Profile 总数`),value:B.length},{id:`jitter`,label:e(`c2.profiles.withJitter`,null,`启用 Jitter`),value:B.filter(e=>Number(e.jitterMaxMs)>0).length},{id:`uris`,label:e(`c2.profiles.withUris`,null,`自定义 URI`),value:B.filter(e=>Array.isArray(e.uris)&&e.uris.length>0).length},{id:`headers`,label:e(`c2.profiles.withHeaders`,null,`自定义响应头`),value:B.filter(e=>e.responseHeaders&&Object.keys(e.responseHeaders).length>0).length}],[B,e]),H=async t=>{j(!0);try{o.record?.id?(await D(o.record.id,t),C(e(`c2.profiles.toastUpdated`,null,`Profile 已更新`))):(await T(t),C(e(`c2.profiles.toastCreated`,null,`Profile 已创建`))),s({visible:!1,record:null}),z()}catch(t){_(t,e(`c2.profiles.saveFailed`,null,`Profile 保存失败`))}finally{j(!1)}},U=t=>{w({title:e(`c2.profiles.delete`,null,`删除 Profile`),content:e(`c2.profiles.confirmDelete`,null,`确定删除此 Profile?`),onOk:async()=>{try{await O(t.id),C(e(`c2.profiles.toastDeleted`,null,`Profile 已删除`)),z()}catch(e){_(e)}}})},W=[{title:e(`c2.profiles.name`,null,`名称`),dataIndex:`name`,render:(e,t)=>(0,A.jsx)(`button`,{type:`button`,className:`c2-profile-name`,onClick:()=>N(t),children:e||t.id})},{title:e(`c2.profiles.userAgent`,null,`User-Agent`),dataIndex:`userAgent`,render:e=>(0,A.jsx)(`span`,{className:`c2-mono c2-profile-ua`,title:e,children:e||`—`})},{title:e(`c2.profiles.uris`,null,`URI 路径`),dataIndex:`uris`,width:220,render:e=>Array.isArray(e)&&e.length?(0,A.jsx)(a,{spacing:4,wrap:!0,children:e.slice(0,3).map(e=>(0,A.jsx)(l,{size:`small`,children:e},e))}):(0,A.jsx)(F,{type:`tertiary`,children:`—`})},{title:e(`c2.profiles.jitter`,null,`Jitter 范围`),dataIndex:`jitterMinMs`,width:140,render:(e,t)=>`${e||0} – ${t.jitterMaxMs||0} ms`},{title:e(`c2.profiles.createdAt`,null,`创建时间`),dataIndex:`createdAt`,width:170,render:e=>d(e)},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:180,render:(t,o)=>(0,A.jsxs)(a,{spacing:4,children:[(0,A.jsx)(i,{size:`small`,theme:`borderless`,onClick:()=>N(o),children:e(`c2.profiles.view`,null,`查看`)}),(0,A.jsx)(i,{size:`small`,theme:`borderless`,disabled:!n,onClick:()=>s({visible:!0,record:o}),children:e(`c2.profiles.edit`,null,`编辑`)}),(0,A.jsx)(i,{size:`small`,theme:`borderless`,type:`danger`,disabled:!r,onClick:()=>U(o),children:e(`c2.profiles.delete`,null,`删除`)})]})}];return(0,A.jsxs)(`div`,{className:`c2-page`,id:`page-c2-profiles`,children:[(0,A.jsx)(b,{title:e(`c2.profiles.title`,null,`流量伪装`),description:e(`c2.profiles.pageDesc`,null,`维护 HTTP/HTTPS Beacon 的 UA、URI 与响应头模板`),extra:[(0,A.jsx)(i,{icon:(0,A.jsx)(c,{}),onClick:z,loading:L,children:e(`common.refresh`,null,`刷新`)},`refresh`),(0,A.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(u,{}),disabled:!n,onClick:()=>s({visible:!0,record:null}),children:e(`c2.profiles.createBtn`,null,`创建 Profile`)},`create`)]}),(0,A.jsx)(h,{metrics:V,columns:4}),(0,A.jsx)(v,{error:R,onRetry:z}),(0,A.jsx)(y,{title:e(`c2.profiles.listTitle`,null,`Profile 列表`),children:(0,A.jsx)(x,{columns:W,dataSource:B,rowKey:`id`,loading:L,onRefresh:z,pagination:{pageSize:10},emptyText:e(`c2.profiles.empty`,null,`暂无 Profile`)})}),M&&(0,A.jsx)(y,{title:`${e(`c2.profiles.detailTitle`,null,`Profile 详情`)} · ${M.name||M.id}`,extra:(0,A.jsx)(i,{size:`small`,onClick:()=>N(null),children:e(`c2.profiles.close`,null,`收起`)}),children:(0,A.jsx)(S,{value:M})}),(0,A.jsx)(P,{visible:o.visible,record:o.record,submitting:m,onCancel:()=>s({visible:!1,record:null}),onSubmit:H})]})}export{I as default};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-sessions-C4zx-oqJ.js b/web/static/app/assets/c2-sessions-CzZrurOn.js
similarity index 98%
rename from web/static/app/assets/c2-sessions-C4zx-oqJ.js
rename to web/static/app/assets/c2-sessions-CzZrurOn.js
index 8a936ed8..57cd7a6b 100644
--- a/web/static/app/assets/c2-sessions-C4zx-oqJ.js
+++ b/web/static/app/assets/c2-sessions-CzZrurOn.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{C as i,H as a,I as o,M as s,P as c,U as l,V as u,_ as d,b as f,c as p,it as m,j as h,nt as g,rt as _,w as v}from"./semi-DNxeCrHm.js";import{E as y,F as b,P as x,S,a as C,b as w,d as T,l as E,m as D,n as O,p as k,r as A,s as j,u as M,x as N,y as P}from"./index-BoFwOeaz.js";import{C as F,S as ee,T as te,_ as I,d as L,f as R,g as z,h as B,o as ne,p as V,r as H,s as U,w as W,y as re}from"./c2-shared-DQceLFCe.js";import{c as ie,h as G,l as ae,m as oe,u as K}from"./c2-shared-BkIzs15k.js";var q=e(t(),1),J=e(n(),1),se=0,ce=()=>(se+=1,se),le=e=>new Promise(t=>setTimeout(t,e));function ue({session:e,canWrite:t,onTaskCreated:n}){let r=x(),[i,a]=(0,q.useState)([]),[s,l]=(0,q.useState)(``),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(``),_=(0,q.useRef)(!0),v=(0,q.useRef)(null);(0,q.useEffect)(()=>()=>{_.current=!1},[]),(0,q.useEffect)(()=>{let e=v.current;e&&(e.scrollTop=e.scrollHeight)},[i]);let y=(0,q.useCallback)(e=>{a(t=>[...t,{id:ce(),...e}])},[]),b=async e=>{let t=600;for(let n=0;n<40;n+=1){if(!_.current)return null;let n=(await I(e))?.task;if(!n)return null;if([`success`,`failed`,`cancelled`].includes(n.status))return n;await le(t),t=Math.min(Math.round(t*1.4),4e3)}return null},C=async i=>{let a=String(i??s).trim();if(a){if(!t)S(r(`c2.sessions.writeRequired`,null,`当前账号没有下发任务的权限`));else{l(``),y({kind:`cmd`,text:a}),f(!0);try{let t=(await ne(e.id,{task_type:`shell`,payload:{command:a,timeout_seconds:60}}))?.task?.id;if(!t){y({kind:`err`,text:r(`c2.sessions.termNoSession`,null,`下发失败:未返回任务 ID`)});return}m(t),n?.();let i=await b(t);if(!i){y({kind:`warn`,text:r(`c2.sessions.termWaitTimeout`,null,`[等待结果超时]`)});return}i.resultText&&y({kind:i.status===`success`?`out`:`warn`,text:i.resultText}),i.error&&y({kind:`err`,text:i.error}),i.status===`cancelled`&&y({kind:`warn`,text:r(`c2.tasks.cancelled`,null,`已取消`)})}catch(e){y({kind:`err`,text:e?.message||r(`c2.sessions.termStatusErr`,null,`执行失败`)}),w(e)}finally{_.current&&(f(!1),m(``))}}}};return(0,J.jsxs)(`div`,{className:`c2-terminal`,children:[(0,J.jsx)(`div`,{className:`c2-terminal-bar`,children:(0,J.jsxs)(c,{spacing:8,children:[(0,J.jsx)(h,{size:`small`,color:d?`amber`:`green`,children:d?r(`c2.sessions.termStatusExec`,null,`执行中…`):r(`c2.sessions.termStatusReady`,null,`就绪`)}),(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>a([]),children:r(`c2.sessions.clearTerminal`,null,`清屏`)}),d&&p&&(0,J.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,onClick:async()=>{if(p)try{await H(p),y({kind:`warn`,text:r(`c2.tasks.toastCancelled`,null,`任务已取消`)})}catch(e){w(e)}},children:r(`c2.tasks.cancelBtn`,null,`取消`)})]})}),(0,J.jsxs)(`div`,{className:`c2-terminal-log`,ref:v,children:[(0,J.jsx)(`div`,{className:`c2-terminal-welcome`,children:r(`c2.sessions.terminalWelcome`,null,`C2 终端 — 回车执行;命令以 shell 任务下发并等待结果`)}),i.map(e=>(0,J.jsx)(`pre`,{className:`c2-terminal-line kind-${e.kind}`,children:e.kind===`cmd`?`$ ${e.text}`:e.text},e.id))]}),(0,J.jsxs)(`div`,{className:`c2-terminal-input`,children:[(0,J.jsx)(u,{value:s,onChange:l,onEnterPress:()=>d?S(r(`c2.sessions.termWaitFinish`,null,`请等待当前命令执行完成`)):C(),placeholder:r(`c2.sessions.commandPlaceholder`,null,`输入命令后回车下发`),disabled:d||!t,prefix:`$`}),(0,J.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,J.jsx)(g,{}),loading:d,disabled:!t,onClick:()=>C(),children:r(`c2.sessions.execute`,null,`执行命令`)})]})]})}function de(e){let t=String(e||``).split(/\r?\n/),n=[];for(let e of t){let t=e.trim();if(!t||/^total\s+\d+/i.test(t))continue;let r=t.split(` `);if(r.length>=4){let e=r.slice(3).join(` `).trim();if(!e||e===`.`||e===`..`)continue;let t=r[0].trim(),i=r[1].trim();n.push({name:e,size:r[2].trim(),mode:i||t,isDir:t.startsWith(`d`)||i.startsWith(`d`)});continue}let i=t.match(/^\S{1,10}\s+\d+\s+\S+\s+\S+\s+\d+\s+\S+\s+\S+\s+\S+\s+(.+)$/);if(!i)continue;let a=i[1].trim(),o=a.indexOf(` -> `);if(o>0&&(a=a.slice(0,o).trim()),!a||a===`.`||a===`..`)continue;let s=t.split(/\s+/);n.push({name:a,size:s[4]||``,mode:s[0]||``,isDir:(s[0]||``).startsWith(`d`)})}return n}function Y(e){let t=String(e??``).trim();return t?/^[A-Za-z]:/.test(t)?t.replace(/\\+$/,``)||t:(t=t.replace(/\\/g,`/`).replace(/\/{2,}/g,`/`),t.length>1&&(t=t.replace(/\/+$/,``)),t||`.`):`.`}function X(e,t){let n=Y(e);return t?/^[A-Za-z]:/.test(t)||t.startsWith(`/`)||n===`.`||n===``?Y(t):Y(`${n}${n.includes(`\\`)?`\\`:`/`}${t}`):n}function fe(e){let t=Y(e);if(t===`.`||t===`/`||/^[A-Za-z]:$/.test(t))return t;let n=t.includes(`\\`)?`\\`:`/`,r=t.lastIndexOf(n);if(r<0)return`.`;if(r===0)return`/`;let i=t.slice(0,r);return/^[A-Za-z]:$/.test(i)?`${i}${n}`:i}var{Text:pe}=l,me=e=>new Promise(t=>setTimeout(t,e));async function he(e){let t=600;for(let n=0;n<40;n+=1){let n=(await I(e))?.task;if(!n)return null;if([`success`,`failed`,`cancelled`].includes(n.status))return n;await me(t),t=Math.min(Math.round(t*1.4),4e3)}return null}function ge({session:e,canWrite:t}){let n=x(),[r,i]=(0,q.useState)(`.`),[a,s]=(0,q.useState)(`.`),[l,d]=(0,q.useState)([]),[f,p]=(0,q.useState)(``),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(null),[y,b]=(0,q.useState)(``),C=(0,q.useRef)(!0);(0,q.useEffect)(()=>()=>{C.current=!1},[]);let T=(0,q.useCallback)(async t=>{let a=Y(t??r);g(!0),v(null);try{let t=(await U({session_id:e.id,task_type:`ls`,payload:{path:a}}))?.task?.id;if(!t)throw Error(n(`c2.files.failed`,null,`列目录失败`));let r=await he(t);if(!C.current)return;if(!r){v(n(`c2.files.timeout`,null,`加载文件超时`));return}if(r.status!==`success`){v(r.error||n(`c2.files.failed`,null,`列目录失败`)),d([]),p(r.resultText||``);return}p(r.resultText||``),d(de(r.resultText||``)),i(a),s(a)}catch(e){C.current&&v(e)}finally{C.current&&g(!1)}},[e.id,r,n]);(0,q.useEffect)(()=>{i(`.`),s(`.`),d([]),T(`.`)},[e.id]);let D=async i=>{if(!t){S(n(`c2.files.writeRequired`,null,`当前账号没有下发任务的权限`));return}let a=X(r,i.name);try{let t=(await U({session_id:e.id,task_type:`download`,payload:{path:a}}))?.task?.id;if(!t)throw Error(n(`c2.files.failed`,null,`下载失败`));let r=await he(t);if(!r||r.status!==`success`)throw Error(r?.error||n(`c2.files.failed`,null,`下载失败`));await B(r.id,i.name),N(n(`c2.files.downloadOk`,null,`下载成功`))}catch(e){w(e,n(`c2.files.failed`,null,`下载失败`))}},O=l.filter(e=>{let t=y.trim().toLowerCase();return!t||e.name.toLowerCase().includes(t)}),k=[{title:n(`c2.files.colName`,null,`名称`),dataIndex:`name`,render:(e,t)=>(0,J.jsxs)(`button`,{type:`button`,className:`c2-file-name ${t.isDir?`is-dir`:``}`,onClick:()=>t.isDir?T(X(r,e)):D(t),children:[e,t.isDir?`/`:``]})},{title:n(`c2.files.colSize`,null,`大小`),dataIndex:`size`,width:120},{title:n(`c2.files.colMode`,null,`权限`),dataIndex:`mode`,width:160},{title:n(`c2.files.colActions`,null,`操作`),dataIndex:`actions`,width:160,render:(e,i)=>i.isDir?(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>T(X(r,i.name)),children:n(`c2.files.open`,null,`打开`)}):(0,J.jsx)(o,{size:`small`,theme:`borderless`,disabled:!t,onClick:()=>D(i),children:n(`c2.files.download`,null,`下载`)})}];return(0,J.jsxs)(`div`,{className:`c2-files`,children:[(0,J.jsx)(`div`,{className:`c2-files-toolbar`,children:(0,J.jsxs)(c,{spacing:8,wrap:!0,children:[(0,J.jsx)(o,{size:`small`,onClick:()=>T(fe(r)),children:n(`c2.files.parent`,null,`上级目录`)}),(0,J.jsx)(o,{size:`small`,icon:(0,J.jsx)(m,{}),loading:h,onClick:()=>T(r),children:n(`c2.files.refresh`,null,`刷新`)}),(0,J.jsx)(u,{size:`small`,value:a,onChange:s,onEnterPress:()=>T(a),className:`c2-files-path`}),(0,J.jsx)(o,{size:`small`,onClick:()=>T(a),children:n(`c2.files.go`,null,`跳转`)}),(0,J.jsx)(u,{size:`small`,value:y,onChange:b,placeholder:n(`c2.files.filter`,null,`过滤名称`),className:`c2-files-filter`})]})}),(0,J.jsxs)(pe,{type:`tertiary`,size:`small`,children:[n(`c2.files.currentPath`,null,`当前目录`),`:`,r]}),(0,J.jsx)(E,{error:_,onRetry:()=>T(r)}),l.length===0&&f.trim()&&!h?(0,J.jsx)(`pre`,{className:`c2-pre`,children:f}):(0,J.jsx)(j,{columns:k,dataSource:O,rowKey:`name`,loading:h,pagination:{pageSize:20},emptyText:n(`c2.files.emptyDir`,null,`空目录`)})]})}function _e({session:e,canDelete:t,onChanged:n}){let r=x(),[a,s]=(0,q.useState)(null),{data:l,loading:u,error:d,reload:f}=C(()=>F({session_id:e.id,limit:100}),[e.id]),p=Array.isArray(l?.tasks)?l.tasks:[];A(()=>f({silent:!0}),5e3);let m=async e=>{try{await H(e.id),N(r(`c2.tasks.toastCancelled`,null,`任务已取消`)),f({silent:!0}),n?.()}catch(e){w(e)}},g=e=>{P({title:r(`c2.tasks.deleteOne`,null,`删除任务`),content:r(`c2.tasks.confirmDeleteOne`,null,`确定从服务器删除该任务记录吗?此操作不可恢复。`),onOk:async()=>{try{await V([e.id]),N(r(`c2.tasks.toastDeleted`,null,`已删除 {{n}} 条`).replace(`{{n}}`,`1`)),f({silent:!0}),n?.()}catch(e){w(e)}}})},_=[{title:r(`c2.tasks.colType`,null,`类型`),dataIndex:`taskType`,width:120},{title:r(`c2.tasks.colCommand`,null,`命令`),dataIndex:`payload`,render:e=>{let t=e?.command||e?.path||``;return(0,J.jsx)(`span`,{className:`c2-mono`,children:t||`—`})}},{title:r(`c2.tasks.colStatus`,null,`状态`),dataIndex:`status`,width:110,render:e=>(0,J.jsx)(h,{size:`small`,color:K[e]||`grey`,children:r(`c2.tasks.${e||`queued`}`,null,e||`—`)})},{title:r(`c2.tasks.colDuration`,null,`耗时`),dataIndex:`durationMs`,width:100,render:e=>G(e)},{title:r(`c2.tasks.colCreated`,null,`创建时间`),dataIndex:`createdAt`,width:140,render:e=>(0,J.jsx)(oe,{value:e})},{title:r(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:200,render:(e,n)=>(0,J.jsxs)(c,{spacing:4,wrap:!0,children:[(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>s(n),children:r(`c2.tasks.view`,null,`查看`)}),[`queued`,`sent`,`running`].includes(n.status)&&(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>m(n),children:r(`c2.tasks.cancelBtn`,null,`取消`)}),(0,J.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!t,onClick:()=>g(n),children:r(`c2.tasks.deleteBtn`,null,`删除`)})]})}];return(0,J.jsxs)(`div`,{className:`c2-session-tasks`,children:[(0,J.jsx)(E,{error:d,onRetry:()=>f()}),(0,J.jsx)(j,{columns:_,dataSource:p,rowKey:`id`,loading:u,onRefresh:()=>f(),pagination:{pageSize:10},emptyText:r(`c2.tasks.emptySession`,null,`该会话暂无任务`)}),(0,J.jsx)(i,{visible:!!a,title:r(`c2.tasks.modalTitle`,null,`任务详情`),width:720,onCancel:()=>s(null),footer:(0,J.jsx)(o,{onClick:()=>s(null),children:r(`c2.tasks.close`,null,`关闭`)}),children:a&&(0,J.jsxs)(`div`,{className:`c2-task-detail`,children:[(0,J.jsxs)(`div`,{className:`c2-task-detail-meta`,children:[(0,J.jsx)(`span`,{className:`c2-mono`,children:a.id}),(0,J.jsx)(h,{size:`small`,color:K[a.status]||`grey`,children:a.status}),(0,J.jsx)(`span`,{className:`c2-muted`,children:y(a.createdAt)})]}),a.payload&&(0,J.jsx)(M,{title:r(`c2.tasks.labelPayload`,null,`参数`),value:a.payload,collapsed:!0}),a.resultText&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`c2-field-label`,children:r(`c2.tasks.labelResult`,null,`输出`)}),(0,J.jsx)(`pre`,{className:`c2-pre`,children:a.resultText})]}),a.error&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`c2-field-label`,children:r(`c2.tasks.labelError`,null,`错误`)}),(0,J.jsx)(`pre`,{className:`c2-pre c2-pre-error`,children:a.error})]})]})})]})}var{Text:Z}=l;function ve({session:e,canWrite:t,onEditNote:n}){let r=x(),i=[{label:r(`c2.sessions.infoSessionId`,null,`会话 ID`),value:(0,J.jsx)(Z,{copyable:{text:e.id},className:`c2-mono`,children:e.id})},{label:r(`c2.sessions.infoImplantUuid`,null,`植入体 UUID`),value:(0,J.jsx)(Z,{className:`c2-mono`,children:e.implantUuid||`—`})},{label:r(`c2.sessions.infoHostname`,null,`主机名`),value:e.hostname||`—`},{label:r(`c2.sessions.infoUsername`,null,`用户名`),value:e.username||`—`},{label:r(`c2.sessions.infoProcess`,null,`进程`),value:e.processName||`—`},{label:r(`c2.sessions.infoPid`,null,`PID`),value:e.pid||`—`}],a=[{label:r(`c2.sessions.infoOs`,null,`操作系统`),value:e.os||`—`},{label:r(`c2.sessions.infoArch`,null,`架构`),value:e.arch||`—`},{label:r(`c2.sessions.infoAdmin`,null,`管理员`),value:e.isAdmin?r(`c2.sessions.adminYes`,null,`是`):r(`c2.sessions.adminNo`,null,`否`)},{label:r(`c2.sessions.infoInternalIp`,null,`内网 IP`),value:(0,J.jsx)(`span`,{className:`c2-mono`,children:e.internalIp||`—`})},{label:r(`c2.sessions.ip`,null,`外网 IP`),value:(0,J.jsx)(`span`,{className:`c2-mono`,children:e.externalIp||`—`})},{label:r(`c2.sessions.infoSleep`,null,`Sleep`),value:`${e.sleepSeconds||0}s ± ${e.jitterPercent||0}%`}],s=[{label:r(`c2.sessions.infoFirstSeen`,null,`首次上线`),value:y(e.firstSeenAt)},{label:r(`c2.sessions.infoLastCheckin`,null,`上次心跳`),value:y(e.lastCheckIn)},{label:r(`c2.sessions.status`,null,`状态`),value:e.status||`—`},{label:r(`c2.sessions.listener`,null,`监听器`),value:(0,J.jsx)(`span`,{className:`c2-mono`,children:e.listenerId||`—`})}];return(0,J.jsxs)(`div`,{className:`c2-session-info`,children:[(0,J.jsx)(D,{title:r(`c2.sessions.infoSectionIdentity`,null,`身份信息`),children:(0,J.jsx)(T,{items:i,columns:2})}),(0,J.jsx)(D,{title:r(`c2.sessions.infoSectionSystem`,null,`系统环境`),children:(0,J.jsx)(T,{items:a,columns:2})}),(0,J.jsx)(D,{title:r(`c2.sessions.infoSectionNetwork`,null,`网络与信标`),children:(0,J.jsx)(T,{items:s,columns:2})}),(0,J.jsx)(D,{title:r(`c2.sessions.infoSectionNote`,null,`备注`),extra:(0,J.jsx)(c,{children:(0,J.jsx)(o,{size:`small`,disabled:!t,onClick:n,children:r(`c2.sessions.noteEdit`,null,`编辑`)})}),children:(0,J.jsx)(Z,{type:e.note?void 0:`tertiary`,children:e.note||r(`c2.sessions.infoNoteEmpty`,null,`暂无备注`)})}),e.metadata&&Object.keys(e.metadata).length>0&&(0,J.jsx)(D,{title:r(`c2.sessions.infoMetadata`,null,`原始元数据`),children:(0,J.jsx)(M,{value:e.metadata,collapsed:!0})})]})}var{Text:Q}=l;function ye({session:e,canWrite:t,canDelete:n,onChanged:r,onDeleted:a}){let s=x(),[l,d]=(0,q.useState)(`terminal`),[g,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(null),[b,T]=(0,q.useState)(!1),{data:D,loading:O,error:k,reload:A}=C(()=>z(e.id),[e.id]),j=D?.session||e,M=()=>_({sleepSeconds:String(j.sleepSeconds||5),jitterPercent:String(j.jitterPercent||0)}),F=()=>y({note:j.note||``}),ee=async()=>{let e=Number(g.sleepSeconds),t=Number(g.jitterPercent);if(!Number.isFinite(e)||e<1)S(s(`c2.sessions.toastSleepInvalid`,null,`Sleep 间隔至少为 1 秒`));else if(!Number.isFinite(t)||t<0||t>100)S(s(`c2.sessions.toastSleepInvalid`,null,`抖动百分比需在 0–100 之间`));else{T(!0);try{await te(j.id,{sleepSeconds:e,jitterPercent:t}),N(s(`c2.sessions.toastSleepUpdated`,null,`Sleep 设置已更新`)),_(null),A({silent:!0}),r?.()}catch(e){w(e)}finally{T(!1)}}},I=async()=>{let e=String(v.note||``).trim();if(e.length>2e3)S(s(`c2.sessions.toastNoteTooLong`,null,`备注最多 2000 字`));else{T(!0);try{await W(j.id,e),N(s(`c2.sessions.toastNoteSaved`,null,`备注已保存`)),y(null),A({silent:!0}),r?.()}catch(e){w(e)}finally{T(!1)}}},R=()=>{P({title:s(`c2.sessions.cardDeleteSession`,null,`删除会话`),content:s(`c2.sessions.confirmDeleteSession`,null,`从服务器删除此会话及其关联任务与文件记录?`),onOk:async()=>{try{await L(j.id),N(s(`c2.sessions.toastSessionDeleted`,null,`会话记录已删除`)),a?.()}catch(e){w(e)}}})},B=[{tab:s(`c2.sessions.terminal`,null,`终端`),itemKey:`terminal`,children:(0,J.jsx)(ue,{session:j,canWrite:t,onTaskCreated:A})},{tab:s(`c2.sessions.files`,null,`文件`),itemKey:`files`,children:(0,J.jsx)(ge,{session:j,canWrite:t})},{tab:s(`c2.sessions.tasks`,null,`任务`),itemKey:`tasks`,children:(0,J.jsx)(_e,{session:j,canDelete:n,onChanged:A})},{tab:s(`c2.sessions.info`,null,`信息`),itemKey:`info`,children:(0,J.jsx)(ve,{session:j,canWrite:t,onEditNote:F})}];return(0,J.jsxs)(`div`,{className:`c2-session-detail`,children:[(0,J.jsxs)(`div`,{className:`c2-session-head`,children:[(0,J.jsxs)(`div`,{className:`c2-session-title`,children:[(0,J.jsx)(Q,{strong:!0,className:`c2-session-hostname`,children:j.hostname||s(`c2.sessions.unknownHost`,null,`未知主机`)}),(0,J.jsxs)(c,{spacing:6,wrap:!0,children:[(0,J.jsx)(h,{size:`small`,color:ie[j.status]||`grey`,children:s(`c2.sessions.${j.status||`active`}`,null,j.status||`—`)}),(0,J.jsxs)(h,{size:`small`,children:[j.os||`—`,`/`,j.arch||`—`]}),j.isAdmin&&(0,J.jsx)(h,{size:`small`,color:`red`,children:s(`c2.sessions.rootBadge`,null,`ROOT`)}),(0,J.jsxs)(Q,{type:`tertiary`,size:`small`,children:[j.username||`—`,`@`,j.internalIp||j.externalIp||`—`]}),(0,J.jsxs)(Q,{type:`tertiary`,size:`small`,children:[`sleep `,j.sleepSeconds||0,`s ± `,j.jitterPercent||0,`%`]})]})]}),(0,J.jsxs)(c,{spacing:6,wrap:!0,children:[(0,J.jsx)(o,{size:`small`,icon:(0,J.jsx)(m,{}),loading:O,onClick:()=>A(),children:s(`common.refresh`,null,`刷新`)}),(0,J.jsx)(o,{size:`small`,disabled:!t,onClick:M,children:s(`c2.sessions.btnSleep`,null,`Sleep`)}),(0,J.jsx)(o,{size:`small`,disabled:!t,onClick:F,children:s(`c2.sessions.noteEdit`,null,`备注`)}),(0,J.jsx)(o,{size:`small`,type:`danger`,disabled:!n,onClick:R,children:s(`c2.sessions.cardDeleteSession`,null,`删除会话`)})]})]}),(0,J.jsx)(E,{error:k,onRetry:A}),(0,J.jsx)(p,{type:`button`,activeKey:l,onChange:d,items:B}),(0,J.jsxs)(i,{visible:!!g,title:s(`c2.sessions.sleepModalTitle`,null,`心跳配置`),width:440,onCancel:()=>_(null),onOk:ee,confirmLoading:b,children:[(0,J.jsx)(Q,{type:`tertiary`,size:`small`,children:s(`c2.sessions.sleepModalHint`,null,`保存后将写入服务端并下发 sleep 任务。`)}),(0,J.jsxs)(`div`,{className:`c2-session-modal-field`,children:[(0,J.jsx)(Q,{size:`small`,children:s(`c2.sessions.promptSleepSeconds`,null,`Sleep 间隔(秒)`)}),(0,J.jsx)(u,{value:g?.sleepSeconds||``,onChange:e=>_(t=>({...t,sleepSeconds:e}))})]}),(0,J.jsxs)(`div`,{className:`c2-session-modal-field`,children:[(0,J.jsx)(Q,{size:`small`,children:s(`c2.sessions.promptJitterPercent`,null,`抖动百分比(0–100)`)}),(0,J.jsx)(u,{value:g?.jitterPercent||``,onChange:e=>_(t=>({...t,jitterPercent:e}))})]})]}),(0,J.jsx)(i,{visible:!!v,title:s(`c2.sessions.infoNote`,null,`备注`),width:480,onCancel:()=>y(null),onOk:I,confirmLoading:b,children:(0,J.jsx)(f,{value:v?.note||``,onChange:e=>y(t=>({...t,note:e})),placeholder:s(`c2.sessions.notePlaceholder`,null,`添加备注,便于识别该会话…`),autosize:{minRows:4,maxRows:10}})})]})}var{Text:$}=l;function be(){let e=x(),{hasPermission:t}=b(),n=t(`c2:write`),i=t(`c2:delete`)||n,[c,l]=r(),f=c.get(`id`)||``,[p,g]=(0,q.useState)(``),[y,S]=(0,q.useState)(``),[T,D]=(0,q.useState)(!1),[j,M]=(0,q.useState)(``),[F,te]=(0,q.useState)(!0),I=O(j,300),L=(0,q.useMemo)(()=>({status:p||void 0,listener_id:y||void 0,search:I||void 0,suspicious:T?`1`:void 0,limit:200}),[p,y,I,T]),{data:z,loading:B,error:ne,reload:V}=C(()=>Promise.all([ee(L),re().catch(()=>({listeners:[]}))]),[L]),H=Array.isArray(z?.[0]?.sessions)?z[0].sessions:[],U=Array.isArray(z?.[1]?.listeners)?z[1].listeners:[];A(()=>{F&&V({silent:!0})},F?1e4:0);let W=(0,q.useMemo)(()=>H.find(e=>e.id===f)||null,[H,f]),G=e=>{let t=new URLSearchParams(c);e?t.set(`id`,e):t.delete(`id`),l(t,{replace:!0})};return(0,J.jsxs)(`div`,{className:`c2-page`,id:`page-c2-sessions`,children:[(0,J.jsx)(k,{title:e(`c2.sessions.title`,null,`会话管理`),description:e(`c2.sessions.pageDesc`,null,`查看上线会话,下发命令、浏览文件并管理任务历史`),extra:[(0,J.jsx)(o,{icon:(0,J.jsx)(m,{}),onClick:V,loading:B,children:e(`common.refresh`,null,`刷新`)},`refresh`),(0,J.jsx)(o,{type:`danger`,disabled:!i||!H.length,onClick:()=>{H.length?P({title:e(`c2.sessions.deleteFiltered`,null,`删除筛选结果`),content:e(`c2.sessions.confirmDeleteFiltered`,null,`确定删除当前筛选结果中的全部会话?`).replace(`{{n}}`,String(H.length)),onOk:async()=>{try{let t=await R(H.map(e=>e.id));N(e(`c2.sessions.toastBatchDeleted`,null,`已删除 {{n}} 个会话`).replace(`{{n}}`,String(t?.deleted??H.length))),G(``),V()}catch(e){w(e)}}}):w(e(`c2.sessions.toastSelectFirst`,null,`没有可删除的会话`))},children:e(`c2.sessions.deleteFiltered`,null,`删除筛选结果`)},`delete`)]}),(0,J.jsx)(E,{error:ne,onRetry:V}),(0,J.jsxs)(`div`,{className:`c2-session-layout`,children:[(0,J.jsxs)(`aside`,{className:`c2-session-sidebar`,children:[(0,J.jsxs)(`div`,{className:`c2-session-filters`,children:[(0,J.jsx)(d,{size:`small`,value:p,onChange:e=>g(e||``),style:{width:`100%`},optionList:[{value:``,label:e(`c2.sessions.filterAllStatus`,null,`全部状态`)},...ae]}),(0,J.jsx)(d,{size:`small`,value:y,onChange:e=>S(e||``),style:{width:`100%`},optionList:[{value:``,label:e(`c2.sessions.filterAllListeners`,null,`全部监听器`)},...U.map(e=>({value:e.id,label:e.name||e.id}))]}),(0,J.jsx)(u,{size:`small`,value:j,onChange:M,prefix:(0,J.jsx)(_,{}),placeholder:e(`c2.sessions.filterSearchPlaceholder`,null,`搜索主机名 / 用户 / IP`)}),(0,J.jsxs)(`div`,{className:`c2-session-filter-foot`,children:[(0,J.jsx)(s,{checked:T,onChange:e=>D(!!e.target.checked),children:(0,J.jsx)($,{size:`small`,children:e(`c2.sessions.filterSuspicious`,null,`疑似误报`)})}),(0,J.jsx)(s,{checked:F,onChange:e=>te(!!e.target.checked),children:(0,J.jsx)($,{size:`small`,children:e(`c2.sessions.autoRefresh`,null,`自动刷新`)})})]}),(0,J.jsx)($,{type:`tertiary`,size:`small`,children:e(`c2.sessions.listCount`,null,`共 {{n}} 条`).replace(`{{n}}`,String(H.length))})]}),(0,J.jsxs)(`div`,{className:`c2-session-list`,children:[B&&!H.length&&(0,J.jsx)(`div`,{className:`c2-session-loading`,children:(0,J.jsx)(a,{})}),!B&&H.length===0&&(0,J.jsx)(v,{title:j||p||y?e(`c2.sessions.emptyFilter`,null,`没有符合筛选条件的会话`):e(`c2.sessions.listEmpty`,null,`暂无会话`),description:null,style:{padding:24}}),H.map(t=>(0,J.jsxs)(`button`,{type:`button`,className:`c2-session-item ${t.id===f?`is-active`:``}`,onClick:()=>G(t.id),children:[(0,J.jsxs)(`div`,{className:`c2-session-item-head`,children:[(0,J.jsx)(`span`,{className:`c2-session-host`,children:t.hostname||e(`c2.sessions.unknownHost`,null,`未知`)}),(0,J.jsx)(h,{size:`small`,color:ie[t.status]||`grey`,children:e(`c2.sessions.${t.status||`active`}`,null,t.status||`—`)})]}),(0,J.jsxs)(`div`,{className:`c2-session-item-meta`,children:[(0,J.jsx)(`span`,{children:t.username||`—`}),(0,J.jsxs)(`span`,{children:[t.os||`—`,`/`,t.arch||`—`]}),t.isAdmin&&(0,J.jsx)(h,{size:`small`,color:`red`,children:`ROOT`})]}),(0,J.jsxs)(`div`,{className:`c2-session-item-foot`,children:[(0,J.jsx)(`span`,{className:`c2-mono`,children:t.internalIp||t.externalIp||`—`}),(0,J.jsx)(oe,{value:t.lastCheckIn})]})]},t.id))]})]}),(0,J.jsx)(`section`,{className:`c2-session-main`,children:W?(0,J.jsx)(ye,{session:W,canWrite:n,canDelete:i,onChanged:V,onDeleted:()=>{G(``),V()}},W.id):(0,J.jsx)(v,{title:e(`c2.sessions.selectPromptTitle`,null,`选择会话`),description:e(`c2.sessions.selectPromptHint`,null,`在左侧列表中点击一个会话,查看终端、文件与任务详情。`),style:{padding:64}})})]})]})}export{be as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{C as i,H as a,I as o,M as s,P as c,U as l,V as u,_ as d,b as f,c as p,it as m,j as h,nt as g,rt as _,w as v}from"./semi-DNxeCrHm.js";import{E as y,F as b,P as x,S,a as C,b as w,d as T,l as E,m as D,n as O,p as k,r as A,s as j,u as M,x as N,y as P}from"./index-smFoxEJu.js";import{C as F,S as ee,T as te,_ as I,d as L,f as R,g as z,h as B,o as ne,p as V,r as H,s as U,w as W,y as re}from"./c2-shared-B5kg9aBy.js";import{c as ie,h as G,l as ae,m as oe,u as K}from"./c2-shared-BBQQ9OoL.js";var q=e(t(),1),J=e(n(),1),se=0,ce=()=>(se+=1,se),le=e=>new Promise(t=>setTimeout(t,e));function ue({session:e,canWrite:t,onTaskCreated:n}){let r=x(),[i,a]=(0,q.useState)([]),[s,l]=(0,q.useState)(``),[d,f]=(0,q.useState)(!1),[p,m]=(0,q.useState)(``),_=(0,q.useRef)(!0),v=(0,q.useRef)(null);(0,q.useEffect)(()=>()=>{_.current=!1},[]),(0,q.useEffect)(()=>{let e=v.current;e&&(e.scrollTop=e.scrollHeight)},[i]);let y=(0,q.useCallback)(e=>{a(t=>[...t,{id:ce(),...e}])},[]),b=async e=>{let t=600;for(let n=0;n<40;n+=1){if(!_.current)return null;let n=(await I(e))?.task;if(!n)return null;if([`success`,`failed`,`cancelled`].includes(n.status))return n;await le(t),t=Math.min(Math.round(t*1.4),4e3)}return null},C=async i=>{let a=String(i??s).trim();if(a){if(!t)S(r(`c2.sessions.writeRequired`,null,`当前账号没有下发任务的权限`));else{l(``),y({kind:`cmd`,text:a}),f(!0);try{let t=(await ne(e.id,{task_type:`shell`,payload:{command:a,timeout_seconds:60}}))?.task?.id;if(!t){y({kind:`err`,text:r(`c2.sessions.termNoSession`,null,`下发失败:未返回任务 ID`)});return}m(t),n?.();let i=await b(t);if(!i){y({kind:`warn`,text:r(`c2.sessions.termWaitTimeout`,null,`[等待结果超时]`)});return}i.resultText&&y({kind:i.status===`success`?`out`:`warn`,text:i.resultText}),i.error&&y({kind:`err`,text:i.error}),i.status===`cancelled`&&y({kind:`warn`,text:r(`c2.tasks.cancelled`,null,`已取消`)})}catch(e){y({kind:`err`,text:e?.message||r(`c2.sessions.termStatusErr`,null,`执行失败`)}),w(e)}finally{_.current&&(f(!1),m(``))}}}};return(0,J.jsxs)(`div`,{className:`c2-terminal`,children:[(0,J.jsx)(`div`,{className:`c2-terminal-bar`,children:(0,J.jsxs)(c,{spacing:8,children:[(0,J.jsx)(h,{size:`small`,color:d?`amber`:`green`,children:d?r(`c2.sessions.termStatusExec`,null,`执行中…`):r(`c2.sessions.termStatusReady`,null,`就绪`)}),(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>a([]),children:r(`c2.sessions.clearTerminal`,null,`清屏`)}),d&&p&&(0,J.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,onClick:async()=>{if(p)try{await H(p),y({kind:`warn`,text:r(`c2.tasks.toastCancelled`,null,`任务已取消`)})}catch(e){w(e)}},children:r(`c2.tasks.cancelBtn`,null,`取消`)})]})}),(0,J.jsxs)(`div`,{className:`c2-terminal-log`,ref:v,children:[(0,J.jsx)(`div`,{className:`c2-terminal-welcome`,children:r(`c2.sessions.terminalWelcome`,null,`C2 终端 — 回车执行;命令以 shell 任务下发并等待结果`)}),i.map(e=>(0,J.jsx)(`pre`,{className:`c2-terminal-line kind-${e.kind}`,children:e.kind===`cmd`?`$ ${e.text}`:e.text},e.id))]}),(0,J.jsxs)(`div`,{className:`c2-terminal-input`,children:[(0,J.jsx)(u,{value:s,onChange:l,onEnterPress:()=>d?S(r(`c2.sessions.termWaitFinish`,null,`请等待当前命令执行完成`)):C(),placeholder:r(`c2.sessions.commandPlaceholder`,null,`输入命令后回车下发`),disabled:d||!t,prefix:`$`}),(0,J.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,J.jsx)(g,{}),loading:d,disabled:!t,onClick:()=>C(),children:r(`c2.sessions.execute`,null,`执行命令`)})]})]})}function de(e){let t=String(e||``).split(/\r?\n/),n=[];for(let e of t){let t=e.trim();if(!t||/^total\s+\d+/i.test(t))continue;let r=t.split(` `);if(r.length>=4){let e=r.slice(3).join(` `).trim();if(!e||e===`.`||e===`..`)continue;let t=r[0].trim(),i=r[1].trim();n.push({name:e,size:r[2].trim(),mode:i||t,isDir:t.startsWith(`d`)||i.startsWith(`d`)});continue}let i=t.match(/^\S{1,10}\s+\d+\s+\S+\s+\S+\s+\d+\s+\S+\s+\S+\s+\S+\s+(.+)$/);if(!i)continue;let a=i[1].trim(),o=a.indexOf(` -> `);if(o>0&&(a=a.slice(0,o).trim()),!a||a===`.`||a===`..`)continue;let s=t.split(/\s+/);n.push({name:a,size:s[4]||``,mode:s[0]||``,isDir:(s[0]||``).startsWith(`d`)})}return n}function Y(e){let t=String(e??``).trim();return t?/^[A-Za-z]:/.test(t)?t.replace(/\\+$/,``)||t:(t=t.replace(/\\/g,`/`).replace(/\/{2,}/g,`/`),t.length>1&&(t=t.replace(/\/+$/,``)),t||`.`):`.`}function X(e,t){let n=Y(e);return t?/^[A-Za-z]:/.test(t)||t.startsWith(`/`)||n===`.`||n===``?Y(t):Y(`${n}${n.includes(`\\`)?`\\`:`/`}${t}`):n}function fe(e){let t=Y(e);if(t===`.`||t===`/`||/^[A-Za-z]:$/.test(t))return t;let n=t.includes(`\\`)?`\\`:`/`,r=t.lastIndexOf(n);if(r<0)return`.`;if(r===0)return`/`;let i=t.slice(0,r);return/^[A-Za-z]:$/.test(i)?`${i}${n}`:i}var{Text:pe}=l,me=e=>new Promise(t=>setTimeout(t,e));async function he(e){let t=600;for(let n=0;n<40;n+=1){let n=(await I(e))?.task;if(!n)return null;if([`success`,`failed`,`cancelled`].includes(n.status))return n;await me(t),t=Math.min(Math.round(t*1.4),4e3)}return null}function ge({session:e,canWrite:t}){let n=x(),[r,i]=(0,q.useState)(`.`),[a,s]=(0,q.useState)(`.`),[l,d]=(0,q.useState)([]),[f,p]=(0,q.useState)(``),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(null),[y,b]=(0,q.useState)(``),C=(0,q.useRef)(!0);(0,q.useEffect)(()=>()=>{C.current=!1},[]);let T=(0,q.useCallback)(async t=>{let a=Y(t??r);g(!0),v(null);try{let t=(await U({session_id:e.id,task_type:`ls`,payload:{path:a}}))?.task?.id;if(!t)throw Error(n(`c2.files.failed`,null,`列目录失败`));let r=await he(t);if(!C.current)return;if(!r){v(n(`c2.files.timeout`,null,`加载文件超时`));return}if(r.status!==`success`){v(r.error||n(`c2.files.failed`,null,`列目录失败`)),d([]),p(r.resultText||``);return}p(r.resultText||``),d(de(r.resultText||``)),i(a),s(a)}catch(e){C.current&&v(e)}finally{C.current&&g(!1)}},[e.id,r,n]);(0,q.useEffect)(()=>{i(`.`),s(`.`),d([]),T(`.`)},[e.id]);let D=async i=>{if(!t){S(n(`c2.files.writeRequired`,null,`当前账号没有下发任务的权限`));return}let a=X(r,i.name);try{let t=(await U({session_id:e.id,task_type:`download`,payload:{path:a}}))?.task?.id;if(!t)throw Error(n(`c2.files.failed`,null,`下载失败`));let r=await he(t);if(!r||r.status!==`success`)throw Error(r?.error||n(`c2.files.failed`,null,`下载失败`));await B(r.id,i.name),N(n(`c2.files.downloadOk`,null,`下载成功`))}catch(e){w(e,n(`c2.files.failed`,null,`下载失败`))}},O=l.filter(e=>{let t=y.trim().toLowerCase();return!t||e.name.toLowerCase().includes(t)}),k=[{title:n(`c2.files.colName`,null,`名称`),dataIndex:`name`,render:(e,t)=>(0,J.jsxs)(`button`,{type:`button`,className:`c2-file-name ${t.isDir?`is-dir`:``}`,onClick:()=>t.isDir?T(X(r,e)):D(t),children:[e,t.isDir?`/`:``]})},{title:n(`c2.files.colSize`,null,`大小`),dataIndex:`size`,width:120},{title:n(`c2.files.colMode`,null,`权限`),dataIndex:`mode`,width:160},{title:n(`c2.files.colActions`,null,`操作`),dataIndex:`actions`,width:160,render:(e,i)=>i.isDir?(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>T(X(r,i.name)),children:n(`c2.files.open`,null,`打开`)}):(0,J.jsx)(o,{size:`small`,theme:`borderless`,disabled:!t,onClick:()=>D(i),children:n(`c2.files.download`,null,`下载`)})}];return(0,J.jsxs)(`div`,{className:`c2-files`,children:[(0,J.jsx)(`div`,{className:`c2-files-toolbar`,children:(0,J.jsxs)(c,{spacing:8,wrap:!0,children:[(0,J.jsx)(o,{size:`small`,onClick:()=>T(fe(r)),children:n(`c2.files.parent`,null,`上级目录`)}),(0,J.jsx)(o,{size:`small`,icon:(0,J.jsx)(m,{}),loading:h,onClick:()=>T(r),children:n(`c2.files.refresh`,null,`刷新`)}),(0,J.jsx)(u,{size:`small`,value:a,onChange:s,onEnterPress:()=>T(a),className:`c2-files-path`}),(0,J.jsx)(o,{size:`small`,onClick:()=>T(a),children:n(`c2.files.go`,null,`跳转`)}),(0,J.jsx)(u,{size:`small`,value:y,onChange:b,placeholder:n(`c2.files.filter`,null,`过滤名称`),className:`c2-files-filter`})]})}),(0,J.jsxs)(pe,{type:`tertiary`,size:`small`,children:[n(`c2.files.currentPath`,null,`当前目录`),`:`,r]}),(0,J.jsx)(E,{error:_,onRetry:()=>T(r)}),l.length===0&&f.trim()&&!h?(0,J.jsx)(`pre`,{className:`c2-pre`,children:f}):(0,J.jsx)(j,{columns:k,dataSource:O,rowKey:`name`,loading:h,pagination:{pageSize:20},emptyText:n(`c2.files.emptyDir`,null,`空目录`)})]})}function _e({session:e,canDelete:t,onChanged:n}){let r=x(),[a,s]=(0,q.useState)(null),{data:l,loading:u,error:d,reload:f}=C(()=>F({session_id:e.id,limit:100}),[e.id]),p=Array.isArray(l?.tasks)?l.tasks:[];A(()=>f({silent:!0}),5e3);let m=async e=>{try{await H(e.id),N(r(`c2.tasks.toastCancelled`,null,`任务已取消`)),f({silent:!0}),n?.()}catch(e){w(e)}},g=e=>{P({title:r(`c2.tasks.deleteOne`,null,`删除任务`),content:r(`c2.tasks.confirmDeleteOne`,null,`确定从服务器删除该任务记录吗?此操作不可恢复。`),onOk:async()=>{try{await V([e.id]),N(r(`c2.tasks.toastDeleted`,null,`已删除 {{n}} 条`).replace(`{{n}}`,`1`)),f({silent:!0}),n?.()}catch(e){w(e)}}})},_=[{title:r(`c2.tasks.colType`,null,`类型`),dataIndex:`taskType`,width:120},{title:r(`c2.tasks.colCommand`,null,`命令`),dataIndex:`payload`,render:e=>{let t=e?.command||e?.path||``;return(0,J.jsx)(`span`,{className:`c2-mono`,children:t||`—`})}},{title:r(`c2.tasks.colStatus`,null,`状态`),dataIndex:`status`,width:110,render:e=>(0,J.jsx)(h,{size:`small`,color:K[e]||`grey`,children:r(`c2.tasks.${e||`queued`}`,null,e||`—`)})},{title:r(`c2.tasks.colDuration`,null,`耗时`),dataIndex:`durationMs`,width:100,render:e=>G(e)},{title:r(`c2.tasks.colCreated`,null,`创建时间`),dataIndex:`createdAt`,width:140,render:e=>(0,J.jsx)(oe,{value:e})},{title:r(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:200,render:(e,n)=>(0,J.jsxs)(c,{spacing:4,wrap:!0,children:[(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>s(n),children:r(`c2.tasks.view`,null,`查看`)}),[`queued`,`sent`,`running`].includes(n.status)&&(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>m(n),children:r(`c2.tasks.cancelBtn`,null,`取消`)}),(0,J.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!t,onClick:()=>g(n),children:r(`c2.tasks.deleteBtn`,null,`删除`)})]})}];return(0,J.jsxs)(`div`,{className:`c2-session-tasks`,children:[(0,J.jsx)(E,{error:d,onRetry:()=>f()}),(0,J.jsx)(j,{columns:_,dataSource:p,rowKey:`id`,loading:u,onRefresh:()=>f(),pagination:{pageSize:10},emptyText:r(`c2.tasks.emptySession`,null,`该会话暂无任务`)}),(0,J.jsx)(i,{visible:!!a,title:r(`c2.tasks.modalTitle`,null,`任务详情`),width:720,onCancel:()=>s(null),footer:(0,J.jsx)(o,{onClick:()=>s(null),children:r(`c2.tasks.close`,null,`关闭`)}),children:a&&(0,J.jsxs)(`div`,{className:`c2-task-detail`,children:[(0,J.jsxs)(`div`,{className:`c2-task-detail-meta`,children:[(0,J.jsx)(`span`,{className:`c2-mono`,children:a.id}),(0,J.jsx)(h,{size:`small`,color:K[a.status]||`grey`,children:a.status}),(0,J.jsx)(`span`,{className:`c2-muted`,children:y(a.createdAt)})]}),a.payload&&(0,J.jsx)(M,{title:r(`c2.tasks.labelPayload`,null,`参数`),value:a.payload,collapsed:!0}),a.resultText&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`c2-field-label`,children:r(`c2.tasks.labelResult`,null,`输出`)}),(0,J.jsx)(`pre`,{className:`c2-pre`,children:a.resultText})]}),a.error&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`c2-field-label`,children:r(`c2.tasks.labelError`,null,`错误`)}),(0,J.jsx)(`pre`,{className:`c2-pre c2-pre-error`,children:a.error})]})]})})]})}var{Text:Z}=l;function ve({session:e,canWrite:t,onEditNote:n}){let r=x(),i=[{label:r(`c2.sessions.infoSessionId`,null,`会话 ID`),value:(0,J.jsx)(Z,{copyable:{text:e.id},className:`c2-mono`,children:e.id})},{label:r(`c2.sessions.infoImplantUuid`,null,`植入体 UUID`),value:(0,J.jsx)(Z,{className:`c2-mono`,children:e.implantUuid||`—`})},{label:r(`c2.sessions.infoHostname`,null,`主机名`),value:e.hostname||`—`},{label:r(`c2.sessions.infoUsername`,null,`用户名`),value:e.username||`—`},{label:r(`c2.sessions.infoProcess`,null,`进程`),value:e.processName||`—`},{label:r(`c2.sessions.infoPid`,null,`PID`),value:e.pid||`—`}],a=[{label:r(`c2.sessions.infoOs`,null,`操作系统`),value:e.os||`—`},{label:r(`c2.sessions.infoArch`,null,`架构`),value:e.arch||`—`},{label:r(`c2.sessions.infoAdmin`,null,`管理员`),value:e.isAdmin?r(`c2.sessions.adminYes`,null,`是`):r(`c2.sessions.adminNo`,null,`否`)},{label:r(`c2.sessions.infoInternalIp`,null,`内网 IP`),value:(0,J.jsx)(`span`,{className:`c2-mono`,children:e.internalIp||`—`})},{label:r(`c2.sessions.ip`,null,`外网 IP`),value:(0,J.jsx)(`span`,{className:`c2-mono`,children:e.externalIp||`—`})},{label:r(`c2.sessions.infoSleep`,null,`Sleep`),value:`${e.sleepSeconds||0}s ± ${e.jitterPercent||0}%`}],s=[{label:r(`c2.sessions.infoFirstSeen`,null,`首次上线`),value:y(e.firstSeenAt)},{label:r(`c2.sessions.infoLastCheckin`,null,`上次心跳`),value:y(e.lastCheckIn)},{label:r(`c2.sessions.status`,null,`状态`),value:e.status||`—`},{label:r(`c2.sessions.listener`,null,`监听器`),value:(0,J.jsx)(`span`,{className:`c2-mono`,children:e.listenerId||`—`})}];return(0,J.jsxs)(`div`,{className:`c2-session-info`,children:[(0,J.jsx)(D,{title:r(`c2.sessions.infoSectionIdentity`,null,`身份信息`),children:(0,J.jsx)(T,{items:i,columns:2})}),(0,J.jsx)(D,{title:r(`c2.sessions.infoSectionSystem`,null,`系统环境`),children:(0,J.jsx)(T,{items:a,columns:2})}),(0,J.jsx)(D,{title:r(`c2.sessions.infoSectionNetwork`,null,`网络与信标`),children:(0,J.jsx)(T,{items:s,columns:2})}),(0,J.jsx)(D,{title:r(`c2.sessions.infoSectionNote`,null,`备注`),extra:(0,J.jsx)(c,{children:(0,J.jsx)(o,{size:`small`,disabled:!t,onClick:n,children:r(`c2.sessions.noteEdit`,null,`编辑`)})}),children:(0,J.jsx)(Z,{type:e.note?void 0:`tertiary`,children:e.note||r(`c2.sessions.infoNoteEmpty`,null,`暂无备注`)})}),e.metadata&&Object.keys(e.metadata).length>0&&(0,J.jsx)(D,{title:r(`c2.sessions.infoMetadata`,null,`原始元数据`),children:(0,J.jsx)(M,{value:e.metadata,collapsed:!0})})]})}var{Text:Q}=l;function ye({session:e,canWrite:t,canDelete:n,onChanged:r,onDeleted:a}){let s=x(),[l,d]=(0,q.useState)(`terminal`),[g,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(null),[b,T]=(0,q.useState)(!1),{data:D,loading:O,error:k,reload:A}=C(()=>z(e.id),[e.id]),j=D?.session||e,M=()=>_({sleepSeconds:String(j.sleepSeconds||5),jitterPercent:String(j.jitterPercent||0)}),F=()=>y({note:j.note||``}),ee=async()=>{let e=Number(g.sleepSeconds),t=Number(g.jitterPercent);if(!Number.isFinite(e)||e<1)S(s(`c2.sessions.toastSleepInvalid`,null,`Sleep 间隔至少为 1 秒`));else if(!Number.isFinite(t)||t<0||t>100)S(s(`c2.sessions.toastSleepInvalid`,null,`抖动百分比需在 0–100 之间`));else{T(!0);try{await te(j.id,{sleepSeconds:e,jitterPercent:t}),N(s(`c2.sessions.toastSleepUpdated`,null,`Sleep 设置已更新`)),_(null),A({silent:!0}),r?.()}catch(e){w(e)}finally{T(!1)}}},I=async()=>{let e=String(v.note||``).trim();if(e.length>2e3)S(s(`c2.sessions.toastNoteTooLong`,null,`备注最多 2000 字`));else{T(!0);try{await W(j.id,e),N(s(`c2.sessions.toastNoteSaved`,null,`备注已保存`)),y(null),A({silent:!0}),r?.()}catch(e){w(e)}finally{T(!1)}}},R=()=>{P({title:s(`c2.sessions.cardDeleteSession`,null,`删除会话`),content:s(`c2.sessions.confirmDeleteSession`,null,`从服务器删除此会话及其关联任务与文件记录?`),onOk:async()=>{try{await L(j.id),N(s(`c2.sessions.toastSessionDeleted`,null,`会话记录已删除`)),a?.()}catch(e){w(e)}}})},B=[{tab:s(`c2.sessions.terminal`,null,`终端`),itemKey:`terminal`,children:(0,J.jsx)(ue,{session:j,canWrite:t,onTaskCreated:A})},{tab:s(`c2.sessions.files`,null,`文件`),itemKey:`files`,children:(0,J.jsx)(ge,{session:j,canWrite:t})},{tab:s(`c2.sessions.tasks`,null,`任务`),itemKey:`tasks`,children:(0,J.jsx)(_e,{session:j,canDelete:n,onChanged:A})},{tab:s(`c2.sessions.info`,null,`信息`),itemKey:`info`,children:(0,J.jsx)(ve,{session:j,canWrite:t,onEditNote:F})}];return(0,J.jsxs)(`div`,{className:`c2-session-detail`,children:[(0,J.jsxs)(`div`,{className:`c2-session-head`,children:[(0,J.jsxs)(`div`,{className:`c2-session-title`,children:[(0,J.jsx)(Q,{strong:!0,className:`c2-session-hostname`,children:j.hostname||s(`c2.sessions.unknownHost`,null,`未知主机`)}),(0,J.jsxs)(c,{spacing:6,wrap:!0,children:[(0,J.jsx)(h,{size:`small`,color:ie[j.status]||`grey`,children:s(`c2.sessions.${j.status||`active`}`,null,j.status||`—`)}),(0,J.jsxs)(h,{size:`small`,children:[j.os||`—`,`/`,j.arch||`—`]}),j.isAdmin&&(0,J.jsx)(h,{size:`small`,color:`red`,children:s(`c2.sessions.rootBadge`,null,`ROOT`)}),(0,J.jsxs)(Q,{type:`tertiary`,size:`small`,children:[j.username||`—`,`@`,j.internalIp||j.externalIp||`—`]}),(0,J.jsxs)(Q,{type:`tertiary`,size:`small`,children:[`sleep `,j.sleepSeconds||0,`s ± `,j.jitterPercent||0,`%`]})]})]}),(0,J.jsxs)(c,{spacing:6,wrap:!0,children:[(0,J.jsx)(o,{size:`small`,icon:(0,J.jsx)(m,{}),loading:O,onClick:()=>A(),children:s(`common.refresh`,null,`刷新`)}),(0,J.jsx)(o,{size:`small`,disabled:!t,onClick:M,children:s(`c2.sessions.btnSleep`,null,`Sleep`)}),(0,J.jsx)(o,{size:`small`,disabled:!t,onClick:F,children:s(`c2.sessions.noteEdit`,null,`备注`)}),(0,J.jsx)(o,{size:`small`,type:`danger`,disabled:!n,onClick:R,children:s(`c2.sessions.cardDeleteSession`,null,`删除会话`)})]})]}),(0,J.jsx)(E,{error:k,onRetry:A}),(0,J.jsx)(p,{type:`button`,activeKey:l,onChange:d,items:B}),(0,J.jsxs)(i,{visible:!!g,title:s(`c2.sessions.sleepModalTitle`,null,`心跳配置`),width:440,onCancel:()=>_(null),onOk:ee,confirmLoading:b,children:[(0,J.jsx)(Q,{type:`tertiary`,size:`small`,children:s(`c2.sessions.sleepModalHint`,null,`保存后将写入服务端并下发 sleep 任务。`)}),(0,J.jsxs)(`div`,{className:`c2-session-modal-field`,children:[(0,J.jsx)(Q,{size:`small`,children:s(`c2.sessions.promptSleepSeconds`,null,`Sleep 间隔(秒)`)}),(0,J.jsx)(u,{value:g?.sleepSeconds||``,onChange:e=>_(t=>({...t,sleepSeconds:e}))})]}),(0,J.jsxs)(`div`,{className:`c2-session-modal-field`,children:[(0,J.jsx)(Q,{size:`small`,children:s(`c2.sessions.promptJitterPercent`,null,`抖动百分比(0–100)`)}),(0,J.jsx)(u,{value:g?.jitterPercent||``,onChange:e=>_(t=>({...t,jitterPercent:e}))})]})]}),(0,J.jsx)(i,{visible:!!v,title:s(`c2.sessions.infoNote`,null,`备注`),width:480,onCancel:()=>y(null),onOk:I,confirmLoading:b,children:(0,J.jsx)(f,{value:v?.note||``,onChange:e=>y(t=>({...t,note:e})),placeholder:s(`c2.sessions.notePlaceholder`,null,`添加备注,便于识别该会话…`),autosize:{minRows:4,maxRows:10}})})]})}var{Text:$}=l;function be(){let e=x(),{hasPermission:t}=b(),n=t(`c2:write`),i=t(`c2:delete`)||n,[c,l]=r(),f=c.get(`id`)||``,[p,g]=(0,q.useState)(``),[y,S]=(0,q.useState)(``),[T,D]=(0,q.useState)(!1),[j,M]=(0,q.useState)(``),[F,te]=(0,q.useState)(!0),I=O(j,300),L=(0,q.useMemo)(()=>({status:p||void 0,listener_id:y||void 0,search:I||void 0,suspicious:T?`1`:void 0,limit:200}),[p,y,I,T]),{data:z,loading:B,error:ne,reload:V}=C(()=>Promise.all([ee(L),re().catch(()=>({listeners:[]}))]),[L]),H=Array.isArray(z?.[0]?.sessions)?z[0].sessions:[],U=Array.isArray(z?.[1]?.listeners)?z[1].listeners:[];A(()=>{F&&V({silent:!0})},F?1e4:0);let W=(0,q.useMemo)(()=>H.find(e=>e.id===f)||null,[H,f]),G=e=>{let t=new URLSearchParams(c);e?t.set(`id`,e):t.delete(`id`),l(t,{replace:!0})};return(0,J.jsxs)(`div`,{className:`c2-page`,id:`page-c2-sessions`,children:[(0,J.jsx)(k,{title:e(`c2.sessions.title`,null,`会话管理`),description:e(`c2.sessions.pageDesc`,null,`查看上线会话,下发命令、浏览文件并管理任务历史`),extra:[(0,J.jsx)(o,{icon:(0,J.jsx)(m,{}),onClick:V,loading:B,children:e(`common.refresh`,null,`刷新`)},`refresh`),(0,J.jsx)(o,{type:`danger`,disabled:!i||!H.length,onClick:()=>{H.length?P({title:e(`c2.sessions.deleteFiltered`,null,`删除筛选结果`),content:e(`c2.sessions.confirmDeleteFiltered`,null,`确定删除当前筛选结果中的全部会话?`).replace(`{{n}}`,String(H.length)),onOk:async()=>{try{let t=await R(H.map(e=>e.id));N(e(`c2.sessions.toastBatchDeleted`,null,`已删除 {{n}} 个会话`).replace(`{{n}}`,String(t?.deleted??H.length))),G(``),V()}catch(e){w(e)}}}):w(e(`c2.sessions.toastSelectFirst`,null,`没有可删除的会话`))},children:e(`c2.sessions.deleteFiltered`,null,`删除筛选结果`)},`delete`)]}),(0,J.jsx)(E,{error:ne,onRetry:V}),(0,J.jsxs)(`div`,{className:`c2-session-layout`,children:[(0,J.jsxs)(`aside`,{className:`c2-session-sidebar`,children:[(0,J.jsxs)(`div`,{className:`c2-session-filters`,children:[(0,J.jsx)(d,{size:`small`,value:p,onChange:e=>g(e||``),style:{width:`100%`},optionList:[{value:``,label:e(`c2.sessions.filterAllStatus`,null,`全部状态`)},...ae]}),(0,J.jsx)(d,{size:`small`,value:y,onChange:e=>S(e||``),style:{width:`100%`},optionList:[{value:``,label:e(`c2.sessions.filterAllListeners`,null,`全部监听器`)},...U.map(e=>({value:e.id,label:e.name||e.id}))]}),(0,J.jsx)(u,{size:`small`,value:j,onChange:M,prefix:(0,J.jsx)(_,{}),placeholder:e(`c2.sessions.filterSearchPlaceholder`,null,`搜索主机名 / 用户 / IP`)}),(0,J.jsxs)(`div`,{className:`c2-session-filter-foot`,children:[(0,J.jsx)(s,{checked:T,onChange:e=>D(!!e.target.checked),children:(0,J.jsx)($,{size:`small`,children:e(`c2.sessions.filterSuspicious`,null,`疑似误报`)})}),(0,J.jsx)(s,{checked:F,onChange:e=>te(!!e.target.checked),children:(0,J.jsx)($,{size:`small`,children:e(`c2.sessions.autoRefresh`,null,`自动刷新`)})})]}),(0,J.jsx)($,{type:`tertiary`,size:`small`,children:e(`c2.sessions.listCount`,null,`共 {{n}} 条`).replace(`{{n}}`,String(H.length))})]}),(0,J.jsxs)(`div`,{className:`c2-session-list`,children:[B&&!H.length&&(0,J.jsx)(`div`,{className:`c2-session-loading`,children:(0,J.jsx)(a,{})}),!B&&H.length===0&&(0,J.jsx)(v,{title:j||p||y?e(`c2.sessions.emptyFilter`,null,`没有符合筛选条件的会话`):e(`c2.sessions.listEmpty`,null,`暂无会话`),description:null,style:{padding:24}}),H.map(t=>(0,J.jsxs)(`button`,{type:`button`,className:`c2-session-item ${t.id===f?`is-active`:``}`,onClick:()=>G(t.id),children:[(0,J.jsxs)(`div`,{className:`c2-session-item-head`,children:[(0,J.jsx)(`span`,{className:`c2-session-host`,children:t.hostname||e(`c2.sessions.unknownHost`,null,`未知`)}),(0,J.jsx)(h,{size:`small`,color:ie[t.status]||`grey`,children:e(`c2.sessions.${t.status||`active`}`,null,t.status||`—`)})]}),(0,J.jsxs)(`div`,{className:`c2-session-item-meta`,children:[(0,J.jsx)(`span`,{children:t.username||`—`}),(0,J.jsxs)(`span`,{children:[t.os||`—`,`/`,t.arch||`—`]}),t.isAdmin&&(0,J.jsx)(h,{size:`small`,color:`red`,children:`ROOT`})]}),(0,J.jsxs)(`div`,{className:`c2-session-item-foot`,children:[(0,J.jsx)(`span`,{className:`c2-mono`,children:t.internalIp||t.externalIp||`—`}),(0,J.jsx)(oe,{value:t.lastCheckIn})]})]},t.id))]})]}),(0,J.jsx)(`section`,{className:`c2-session-main`,children:W?(0,J.jsx)(ye,{session:W,canWrite:n,canDelete:i,onChanged:V,onDeleted:()=>{G(``),V()}},W.id):(0,J.jsx)(v,{title:e(`c2.sessions.selectPromptTitle`,null,`选择会话`),description:e(`c2.sessions.selectPromptHint`,null,`在左侧列表中点击一个会话,查看终端、文件与任务详情。`),style:{padding:64}})})]})]})}export{be as default};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-shared-DQceLFCe.js b/web/static/app/assets/c2-shared-B5kg9aBy.js
similarity index 94%
rename from web/static/app/assets/c2-shared-DQceLFCe.js
rename to web/static/app/assets/c2-shared-B5kg9aBy.js
index ad36588e..7fcd38d4 100644
--- a/web/static/app/assets/c2-shared-DQceLFCe.js
+++ b/web/static/app/assets/c2-shared-B5kg9aBy.js
@@ -1 +1 @@
-import{I as e,L as t}from"./index-BoFwOeaz.js";var n=encodeURIComponent,r=t=>e.get(`/c2/listeners`,t),i=t=>e.post(`/c2/listeners`,t),a=(t,r)=>e.put(`/c2/listeners/${n(t)}`,r),o=t=>e.del(`/c2/listeners/${n(t)}`),s=t=>e.post(`/c2/listeners/${n(t)}/start`,{}),c=t=>e.post(`/c2/listeners/${n(t)}/stop`,{}),l=t=>e.get(`/c2/sessions`,t),u=t=>e.get(`/c2/sessions/${n(t)}`),d=t=>e.del(`/c2/sessions/${n(t)}`),f=t=>e.del(`/c2/sessions`,{body:{ids:t}}),p=(t,{sleepSeconds:r,jitterPercent:i})=>e.put(`/c2/sessions/${n(t)}/sleep`,{sleep_seconds:r,jitter_percent:i}),m=(t,r)=>e.put(`/c2/sessions/${n(t)}/note`,{note:r}),h=t=>e.get(`/c2/tasks`,t),g=t=>e.get(`/c2/tasks/${n(t)}`),_=t=>e.post(`/c2/tasks`,t),v=(t,r)=>e.post(`/c2/sessions/${n(t)}/tasks`,r),y=t=>e.post(`/c2/tasks/${n(t)}/cancel`,{}),b=(t,r=30)=>e.get(`/c2/tasks/${n(t)}/wait`,{timeout:r},{timeout:(r+10)*1e3}),x=t=>e.del(`/c2/tasks`,{body:{ids:t}}),S=(e,r)=>t(`/c2/tasks/${n(e)}/result-file`,{filename:r}),C=t=>e.post(`/c2/payloads/oneliner`,t),w=t=>e.post(`/c2/payloads/build`,t),T=(e,r)=>t(`/c2/payloads/${n(e)}/download`,{filename:r}),E=t=>e.get(`/c2/events`,t),D=t=>e.del(`/c2/events`,{body:{ids:t}}),O=()=>e.get(`/c2/profiles`),k=t=>e.post(`/c2/profiles`,t),A=(t,r)=>e.put(`/c2/profiles/${n(t)}`,r),j=t=>e.del(`/c2/profiles/${n(t)}`);async function M(){try{let t=await e.get(`/projects`,{limit:200});return Array.isArray(t?.projects)?t.projects:[]}catch{return[]}}export{b as A,h as C,c as D,s as E,a as O,l as S,p as T,g as _,k as a,O as b,D as c,d,f,u as g,S as h,i,A as k,o as l,T as m,w as n,v as o,x as p,y as r,_ as s,C as t,j as u,E as v,m as w,M as x,r as y};
\ No newline at end of file
+import{I as e,L as t}from"./index-smFoxEJu.js";var n=encodeURIComponent,r=t=>e.get(`/c2/listeners`,t),i=t=>e.post(`/c2/listeners`,t),a=(t,r)=>e.put(`/c2/listeners/${n(t)}`,r),o=t=>e.del(`/c2/listeners/${n(t)}`),s=t=>e.post(`/c2/listeners/${n(t)}/start`,{}),c=t=>e.post(`/c2/listeners/${n(t)}/stop`,{}),l=t=>e.get(`/c2/sessions`,t),u=t=>e.get(`/c2/sessions/${n(t)}`),d=t=>e.del(`/c2/sessions/${n(t)}`),f=t=>e.del(`/c2/sessions`,{body:{ids:t}}),p=(t,{sleepSeconds:r,jitterPercent:i})=>e.put(`/c2/sessions/${n(t)}/sleep`,{sleep_seconds:r,jitter_percent:i}),m=(t,r)=>e.put(`/c2/sessions/${n(t)}/note`,{note:r}),h=t=>e.get(`/c2/tasks`,t),g=t=>e.get(`/c2/tasks/${n(t)}`),_=t=>e.post(`/c2/tasks`,t),v=(t,r)=>e.post(`/c2/sessions/${n(t)}/tasks`,r),y=t=>e.post(`/c2/tasks/${n(t)}/cancel`,{}),b=(t,r=30)=>e.get(`/c2/tasks/${n(t)}/wait`,{timeout:r},{timeout:(r+10)*1e3}),x=t=>e.del(`/c2/tasks`,{body:{ids:t}}),S=(e,r)=>t(`/c2/tasks/${n(e)}/result-file`,{filename:r}),C=t=>e.post(`/c2/payloads/oneliner`,t),w=t=>e.post(`/c2/payloads/build`,t),T=(e,r)=>t(`/c2/payloads/${n(e)}/download`,{filename:r}),E=t=>e.get(`/c2/events`,t),D=t=>e.del(`/c2/events`,{body:{ids:t}}),O=()=>e.get(`/c2/profiles`),k=t=>e.post(`/c2/profiles`,t),A=(t,r)=>e.put(`/c2/profiles/${n(t)}`,r),j=t=>e.del(`/c2/profiles/${n(t)}`);async function M(){try{let t=await e.get(`/projects`,{limit:200});return Array.isArray(t?.projects)?t.projects:[]}catch{return[]}}export{b as A,h as C,c as D,s as E,a as O,l as S,p as T,g as _,k as a,O as b,D as c,d,f,u as g,S as h,i,A as k,o as l,T as m,w as n,v as o,x as p,y as r,_ as s,C as t,j as u,E as v,m as w,M as x,r as y};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-shared-BkIzs15k.js b/web/static/app/assets/c2-shared-BBQQ9OoL.js
similarity index 96%
rename from web/static/app/assets/c2-shared-BkIzs15k.js
rename to web/static/app/assets/c2-shared-BBQQ9OoL.js
index 3e343e9a..23ed3456 100644
--- a/web/static/app/assets/c2-shared-BkIzs15k.js
+++ b/web/static/app/assets/c2-shared-BBQQ9OoL.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{I as t,P as n,U as r}from"./semi-DNxeCrHm.js";import{E as i,P as a,k as o}from"./index-BoFwOeaz.js";import"./c2-shared-DQceLFCe.js";import{t as s}from"./react-QV7DAAIx.js";var c=e(s(),1),{Text:l}=r,u=[{value:`http_beacon`,label:`HTTP Beacon`},{value:`https_beacon`,label:`HTTPS Beacon`},{value:`tcp_reverse`,label:`TCP 反向`},{value:`websocket`,label:`WebSocket`}],d={running:`运行中`,stopped:`已停止`,error:`异常`},f={tcp_reverse:[{value:`bash`,label:`Bash (/dev/tcp)`},{value:`nc`,label:`Netcat (-e)`},{value:`nc_mkfifo`,label:`Netcat (mkfifo)`},{value:`python`,label:`Python`},{value:`perl`,label:`Perl`},{value:`powershell`,label:`PowerShell`}],http_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],https_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],websocket:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}]},p=[{value:`shell`,label:`shell`},{value:`exec`,label:`exec`},{value:`ls`,label:`ls`},{value:`pwd`,label:`pwd`},{value:`cd`,label:`cd`},{value:`ps`,label:`ps`},{value:`kill_proc`,label:`kill_proc`},{value:`download`,label:`download`},{value:`upload`,label:`upload`},{value:`screenshot`,label:`screenshot`},{value:`sleep`,label:`sleep`},{value:`exit`,label:`exit`},{value:`self_delete`,label:`self_delete`},{value:`port_fwd`,label:`port_fwd`},{value:`socks_start`,label:`socks_start`},{value:`socks_stop`,label:`socks_stop`},{value:`load_assembly`,label:`load_assembly`},{value:`persist`,label:`persist`}],m=[{value:`queued`,label:`队列中`},{value:`sent`,label:`已发送`},{value:`running`,label:`执行中`},{value:`success`,label:`成功`},{value:`failed`,label:`失败`},{value:`cancelled`,label:`已取消`}],h=[{value:`info`,label:`信息`},{value:`warn`,label:`警告`},{value:`critical`,label:`严重`}],g=[{value:`listener`,label:`监听器`},{value:`session`,label:`会话`},{value:`task`,label:`任务`},{value:`payload`,label:`Payload`},{value:`opsec`,label:`OPSEC`}],_=[{value:`active`,label:`活跃`},{value:`sleeping`,label:`休眠`},{value:`dead`,label:`离线`},{value:`killed`,label:`已终止`}],v=[{value:`15m`,label:`最近15分钟`,ms:9e5},{value:`1h`,label:`最近1小时`,ms:36e5},{value:`24h`,label:`最近24小时`,ms:864e5},{value:`7d`,label:`最近7天`,ms:6048e5},{value:`all`,label:`全部`,ms:0}];function y(e){let t=v.find(t=>t.value===e);return!t||!t.ms?``:new Date(Date.now()-t.ms).toISOString()}function b({value:e,onChange:r,ns:i=`tasks`}){let o=a();return(0,c.jsxs)(n,{spacing:6,wrap:!0,className:`c2-time-presets`,children:[(0,c.jsx)(l,{type:`tertiary`,size:`small`,children:o(`c2.tasks.timePresets`,null,`快捷`)}),v.map(n=>(0,c.jsx)(t,{size:`small`,theme:n.value===e?`solid`:`borderless`,type:n.value===e?`primary`:`tertiary`,onClick:()=>r(n.value),children:o(`c2.${i}.preset${n.value===`all`?`All`:n.value}`,null,n.label)},n.value))]})}function x(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`—`:t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}秒`:`${Math.round(t/6e4)}分钟`}function S({value:e}){let t=a();return e?(0,c.jsx)(`span`,{className:`c2-time-text`,title:i(e),children:o(e,t)}):(0,c.jsx)(l,{type:`tertiary`,children:`—`})}var C={running:`green`,stopped:`grey`,error:`red`},w={queued:`amber`,sent:`blue`,running:`blue`,success:`green`,failed:`red`,cancelled:`grey`},T={active:`green`,sleeping:`amber`,dead:`grey`,killed:`red`},E={info:`blue`,warn:`amber`,critical:`red`};export{d as a,T as c,m as d,p as f,y as g,x as h,C as i,_ as l,S as m,E as n,u as o,b as p,h as r,f as s,g as t,w as u};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{I as t,P as n,U as r}from"./semi-DNxeCrHm.js";import{E as i,P as a,k as o}from"./index-smFoxEJu.js";import"./c2-shared-B5kg9aBy.js";import{t as s}from"./react-QV7DAAIx.js";var c=e(s(),1),{Text:l}=r,u=[{value:`http_beacon`,label:`HTTP Beacon`},{value:`https_beacon`,label:`HTTPS Beacon`},{value:`tcp_reverse`,label:`TCP 反向`},{value:`websocket`,label:`WebSocket`}],d={running:`运行中`,stopped:`已停止`,error:`异常`},f={tcp_reverse:[{value:`bash`,label:`Bash (/dev/tcp)`},{value:`nc`,label:`Netcat (-e)`},{value:`nc_mkfifo`,label:`Netcat (mkfifo)`},{value:`python`,label:`Python`},{value:`perl`,label:`Perl`},{value:`powershell`,label:`PowerShell`}],http_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],https_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],websocket:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}]},p=[{value:`shell`,label:`shell`},{value:`exec`,label:`exec`},{value:`ls`,label:`ls`},{value:`pwd`,label:`pwd`},{value:`cd`,label:`cd`},{value:`ps`,label:`ps`},{value:`kill_proc`,label:`kill_proc`},{value:`download`,label:`download`},{value:`upload`,label:`upload`},{value:`screenshot`,label:`screenshot`},{value:`sleep`,label:`sleep`},{value:`exit`,label:`exit`},{value:`self_delete`,label:`self_delete`},{value:`port_fwd`,label:`port_fwd`},{value:`socks_start`,label:`socks_start`},{value:`socks_stop`,label:`socks_stop`},{value:`load_assembly`,label:`load_assembly`},{value:`persist`,label:`persist`}],m=[{value:`queued`,label:`队列中`},{value:`sent`,label:`已发送`},{value:`running`,label:`执行中`},{value:`success`,label:`成功`},{value:`failed`,label:`失败`},{value:`cancelled`,label:`已取消`}],h=[{value:`info`,label:`信息`},{value:`warn`,label:`警告`},{value:`critical`,label:`严重`}],g=[{value:`listener`,label:`监听器`},{value:`session`,label:`会话`},{value:`task`,label:`任务`},{value:`payload`,label:`Payload`},{value:`opsec`,label:`OPSEC`}],_=[{value:`active`,label:`活跃`},{value:`sleeping`,label:`休眠`},{value:`dead`,label:`离线`},{value:`killed`,label:`已终止`}],v=[{value:`15m`,label:`最近15分钟`,ms:9e5},{value:`1h`,label:`最近1小时`,ms:36e5},{value:`24h`,label:`最近24小时`,ms:864e5},{value:`7d`,label:`最近7天`,ms:6048e5},{value:`all`,label:`全部`,ms:0}];function y(e){let t=v.find(t=>t.value===e);return!t||!t.ms?``:new Date(Date.now()-t.ms).toISOString()}function b({value:e,onChange:r,ns:i=`tasks`}){let o=a();return(0,c.jsxs)(n,{spacing:6,wrap:!0,className:`c2-time-presets`,children:[(0,c.jsx)(l,{type:`tertiary`,size:`small`,children:o(`c2.tasks.timePresets`,null,`快捷`)}),v.map(n=>(0,c.jsx)(t,{size:`small`,theme:n.value===e?`solid`:`borderless`,type:n.value===e?`primary`:`tertiary`,onClick:()=>r(n.value),children:o(`c2.${i}.preset${n.value===`all`?`All`:n.value}`,null,n.label)},n.value))]})}function x(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`—`:t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}秒`:`${Math.round(t/6e4)}分钟`}function S({value:e}){let t=a();return e?(0,c.jsx)(`span`,{className:`c2-time-text`,title:i(e),children:o(e,t)}):(0,c.jsx)(l,{type:`tertiary`,children:`—`})}var C={running:`green`,stopped:`grey`,error:`red`},w={queued:`amber`,sent:`blue`,running:`blue`,success:`green`,failed:`red`,cancelled:`grey`},T={active:`green`,sleeping:`amber`,dead:`grey`,killed:`red`},E={info:`blue`,warn:`amber`,critical:`red`};export{d as a,T as c,m as d,p as f,y as g,x as h,C as i,_ as l,S as m,E as n,u as o,b as p,h as r,f as s,g as t,w as u};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-tasks-t5h6GDhv.js b/web/static/app/assets/c2-tasks-gSo_kNWy.js
similarity index 98%
rename from web/static/app/assets/c2-tasks-t5h6GDhv.js
rename to web/static/app/assets/c2-tasks-gSo_kNWy.js
index 536c7c83..f73bc6a9 100644
--- a/web/static/app/assets/c2-tasks-t5h6GDhv.js
+++ b/web/static/app/assets/c2-tasks-gSo_kNWy.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{C as i,I as a,P as o,U as s,V as c,_ as l,i as u,it as d,j as f,ot as p}from"./semi-DNxeCrHm.js";import{E as ee,F as te,P as m,_ as ne,a as h,b as g,l as re,m as _,p as ie,r as ae,s as oe,x as v,y as se}from"./index-BoFwOeaz.js";import{A as ce,C as le,h as ue,p as de,r as fe,s as pe}from"./c2-shared-DQceLFCe.js";import{d as y,f as b,g as me,h as x,m as he,p as ge,u as S}from"./c2-shared-BkIzs15k.js";var C=e(t(),1),w=e(n(),1),{Text:T}=s,E=new Set([`shell`,`exec`]),D=new Set([`ls`,`download`,`cd`]);function _e({visible:e,defaultSessionId:t,onCancel:n,onSubmit:r,submitting:s}){let c=m(),[l,d]=(0,C.useState)(null),[f,p]=(0,C.useState)(`shell`);return(0,w.jsx)(i,{visible:e,title:c(`c2.tasks.createTitle`,null,`下发任务`),footer:null,width:560,onCancel:n,children:(0,w.jsxs)(u,{initValues:{session_id:t||``,task_type:`shell`,command:``,timeout_seconds:`60`,extra:``},onSubmit:e=>{let t={},n=String(e.command||``).trim();if(E.has(e.task_type)){t.command=n;let r=Number(e.timeout_seconds);Number.isFinite(r)&&r>0&&(t.timeout_seconds=r)}else(D.has(e.task_type)||n)&&(t.path=n);let i=String(e.extra||``).trim();if(i)try{Object.assign(t,JSON.parse(i))}catch{t.raw=i}r({session_id:String(e.session_id||``).trim(),task_type:e.task_type||`shell`,payload:t,source:`manual`})},getFormApi:d,labelPosition:`top`,onValueChange:e=>{e.task_type&&p(e.task_type)},children:[(0,w.jsx)(u.Input,{field:`session_id`,label:c(`c2.tasks.labelSession`,null,`会话`),placeholder:`s_xxxxxxxx`,rules:[{required:!0,message:c(`c2.tasks.labelSession`,null,`请填写会话 ID`)}]}),(0,w.jsx)(u.Select,{field:`task_type`,label:c(`c2.tasks.labelType`,null,`类型`),optionList:b,style:{width:`100%`}}),(0,w.jsx)(u.Input,{field:`command`,label:E.has(f)?c(`c2.tasks.labelCommand`,null,`命令`):c(`c2.tasks.labelPath`,null,`路径`),placeholder:E.has(f)?`whoami`:`/etc/passwd`}),E.has(f)&&(0,w.jsx)(u.Input,{field:`timeout_seconds`,label:c(`c2.tasks.labelTimeout`,null,`超时(秒)`),placeholder:`60`}),(0,w.jsx)(u.Input,{field:`extra`,label:c(`c2.tasks.labelExtraPayload`,null,`附加参数(JSON,可选)`),placeholder:`{"key":"value"}`}),(0,w.jsx)(T,{type:`tertiary`,size:`small`,children:c(`c2.tasks.createHint`,null,`任务入队后由植入体在下次心跳拉取;危险类型可能需要人机协同审批。`)}),(0,w.jsxs)(o,{className:`c2-form-actions`,children:[(0,w.jsx)(a,{onClick:n,children:c(`c2.tasks.cancelFilters`,null,`取消`)}),(0,w.jsx)(a,{theme:`solid`,type:`primary`,loading:s,onClick:()=>l?.submitForm(),children:c(`c2.tasks.createSubmit`,null,`下发`)})]})]},e?`open`:`closed`)})}var{Text:O}=s;function k(){let e=m(),{hasPermission:t}=te(),n=t(`c2:write`),s=t(`c2:delete`)||n,[u,T]=r(),[E,D]=(0,C.useState)(1),[k,ve]=(0,C.useState)(20),[A,j]=(0,C.useState)(``),[M,N]=(0,C.useState)(``),[P,F]=(0,C.useState)(`all`),[I,L]=(0,C.useState)(u.get(`session_id`)||``),[R,z]=(0,C.useState)(u.get(`session_id`)||``),[B,V]=(0,C.useState)(null),[ye,H]=(0,C.useState)(!1),[be,U]=(0,C.useState)(!1),W=(0,C.useMemo)(()=>({page:E,page_size:k,status:A||void 0,task_type:M||void 0,session_id:R||void 0,since:me(P)||void 0}),[E,k,A,M,R,P]),{data:G,loading:K,error:xe,reload:q}=h(()=>le(W),[W]),J=Array.isArray(G?.tasks)?G.tasks:[],Y=Number(G?.total??J.length),X=G?.status_counts||{};ae(()=>q({silent:!0}),5e3);let Z=()=>{z(I.trim()),D(1);let e=new URLSearchParams(u);I.trim()?e.set(`session_id`,I.trim()):e.delete(`session_id`),T(e,{replace:!0})},Q=()=>{j(``),N(``),F(`all`),L(``),z(``),D(1),T(new URLSearchParams,{replace:!0})},Se=[{id:`total`,label:e(`c2.tasks.statTotal`,null,`当前筛选`),value:Y},{id:`success`,label:e(`c2.tasks.success`,null,`成功`),value:X.success||0,tone:`success`},{id:`failed`,label:e(`c2.tasks.failed`,null,`失败`),value:X.failed||0,tone:`danger`},{id:`pending`,label:e(`c2.tasks.pending`,null,`待处理`),value:(X.queued||0)+(X.sent||0)+(X.running||0),tone:`warning`}],Ce=async t=>{try{await fe(t.id),v(e(`c2.tasks.toastCancelled`,null,`任务已取消`)),q({silent:!0})}catch(e){g(e)}},we=t=>{se({title:e(`c2.tasks.deleteOne`,null,`删除任务`),content:e(`c2.tasks.confirmDeleteOne`,null,`确定从服务器删除该任务记录吗?此操作不可恢复。`),onOk:async()=>{try{await de([t.id]),v(e(`c2.tasks.toastDeleted`,null,`已删除 {{n}} 条`).replace(`{{n}}`,`1`)),q()}catch(e){g(e)}}})},Te=async t=>{try{let n=await ce(t.id,20);n?.task&&V(n.task),v(e(`c2.tasks.toastWaited`,null,`已获取最新任务状态`)),q({silent:!0})}catch(t){g(t,e(`c2.tasks.waitTimeout`,null,`等待任务完成超时`))}},$=async t=>{try{await ue(t.id),v(e(`c2.tasks.downloadOk`,null,`已开始下载`))}catch(t){g(t,e(`c2.tasks.labelResult`,null,`下载结果文件失败`))}},Ee=async t=>{U(!0);try{await pe(t),v(e(`c2.tasks.toastCreated`,null,`任务已下发`)),H(!1),q()}catch(t){g(t,e(`c2.tasks.createFailed`,null,`下发任务失败`))}finally{U(!1)}},De=[{title:e(`c2.tasks.colTask`,null,`任务`),dataIndex:`id`,width:150,render:e=>(0,w.jsx)(`span`,{className:`c2-mono`,children:e})},{title:e(`c2.tasks.colSession`,null,`会话`),dataIndex:`sessionId`,width:150,render:e=>(0,w.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.tasks.colType`,null,`类型`),dataIndex:`taskType`,width:110},{title:e(`c2.tasks.colCommand`,null,`命令`),dataIndex:`payload`,render:e=>{let t=e?.command||e?.path||``;return(0,w.jsx)(`span`,{className:`c2-mono c2-task-command`,title:t,children:t||`—`})}},{title:e(`c2.tasks.colStatus`,null,`状态`),dataIndex:`status`,width:110,render:t=>(0,w.jsx)(f,{size:`small`,color:S[t]||`grey`,children:e(`c2.tasks.${t||`queued`}`,null,t||`—`)})},{title:e(`c2.tasks.colDuration`,null,`耗时`),dataIndex:`durationMs`,width:100,render:e=>x(e)},{title:e(`c2.tasks.colCreated`,null,`创建时间`),dataIndex:`createdAt`,width:130,render:e=>(0,w.jsx)(he,{value:e})},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:210,render:(t,n)=>(0,w.jsxs)(o,{spacing:4,wrap:!0,children:[(0,w.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>V(n),children:e(`c2.tasks.view`,null,`查看`)}),[`queued`,`sent`,`running`].includes(n.status)&&(0,w.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>Ce(n),children:e(`c2.tasks.cancelBtn`,null,`取消`)}),n.resultBlobPath&&(0,w.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>$(n),children:e(`c2.tasks.downloadResult`,null,`结果文件`)}),(0,w.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,disabled:!s,onClick:()=>we(n),children:e(`c2.tasks.deleteBtn`,null,`删除`)})]})}];return(0,w.jsxs)(`div`,{className:`c2-page`,id:`page-c2-tasks`,children:[(0,w.jsx)(ie,{title:e(`c2.tasks.title`,null,`任务管理`),description:e(`c2.tasks.pageDesc`,null,`按状态、类型、会话与时间窗筛选任务,5 秒自动轮询最新状态`),extra:[(0,w.jsx)(a,{icon:(0,w.jsx)(d,{}),onClick:()=>q(),loading:K,children:e(`c2.tasks.refresh`,null,`刷新任务`)},`refresh`),(0,w.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,w.jsx)(p,{}),disabled:!n,onClick:()=>H(!0),children:e(`c2.tasks.createTitle`,null,`下发任务`)},`create`)]}),(0,w.jsx)(ne,{metrics:Se,columns:4}),(0,w.jsx)(re,{error:xe,onRetry:()=>q()}),(0,w.jsx)(_,{title:e(`c2.tasks.filterTitle`,null,`筛选`),extra:(0,w.jsx)(ge,{value:P,onChange:e=>{F(e),D(1)},ns:`tasks`}),children:(0,w.jsxs)(`div`,{className:`c2-toolbar-fields`,children:[(0,w.jsxs)(`div`,{className:`c2-field`,children:[(0,w.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.colStatus`,null,`状态`)}),(0,w.jsx)(l,{value:A,onChange:e=>{j(e||``),D(1)},style:{width:160},optionList:[{value:``,label:e(`c2.tasks.filterAllStatuses`,null,`全部状态`)},...y]})]}),(0,w.jsxs)(`div`,{className:`c2-field`,children:[(0,w.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.colType`,null,`类型`)}),(0,w.jsx)(l,{value:M,onChange:e=>{N(e||``),D(1)},style:{width:160},optionList:[{value:``,label:e(`c2.tasks.filterAllTypes`,null,`全部类型`)},...b]})]}),(0,w.jsxs)(`div`,{className:`c2-field`,children:[(0,w.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.filterSession`,null,`会话 ID`)}),(0,w.jsx)(c,{value:I,onChange:L,onEnterPress:Z,placeholder:e(`c2.tasks.filterSessionPlaceholder`,null,`s_xxxxxxxx`),style:{width:190}})]}),(0,w.jsxs)(o,{spacing:8,children:[(0,w.jsx)(a,{theme:`solid`,type:`primary`,onClick:Z,children:e(`c2.tasks.applyFilters`,null,`应用筛选`)}),(0,w.jsx)(a,{onClick:Q,children:e(`c2.tasks.resetFilters`,null,`重置`)})]})]})}),(0,w.jsx)(_,{title:e(`c2.tasks.listTitle`,null,`任务列表`),children:(0,w.jsx)(oe,{columns:De,dataSource:J,rowKey:`id`,loading:K,onRefresh:()=>q(),pagination:{currentPage:E,pageSize:k,total:Y,onPageChange:e=>D(e),onPageSizeChange:e=>{ve(e),D(1)}},emptyText:e(`c2.tasks.emptyAll`,null,`暂无任务`)})}),(0,w.jsx)(_e,{visible:ye,defaultSessionId:R,submitting:be,onCancel:()=>H(!1),onSubmit:Ee}),(0,w.jsx)(i,{visible:!!B,title:e(`c2.tasks.modalTitle`,null,`任务详情`),width:760,onCancel:()=>V(null),footer:(0,w.jsxs)(o,{children:[B&&[`queued`,`sent`,`running`].includes(B.status)&&(0,w.jsx)(a,{onClick:()=>Te(B),children:e(`c2.tasks.waitBtn`,null,`等待完成`)}),B?.resultBlobPath&&(0,w.jsx)(a,{onClick:()=>$(B),children:e(`c2.tasks.downloadResult`,null,`下载结果文件`)}),(0,w.jsx)(a,{onClick:()=>V(null),children:e(`c2.tasks.close`,null,`关闭`)})]}),children:B&&(0,w.jsxs)(`div`,{className:`c2-task-detail`,children:[(0,w.jsxs)(`div`,{className:`c2-task-detail-meta`,children:[(0,w.jsx)(`span`,{className:`c2-mono`,children:B.id}),(0,w.jsx)(f,{size:`small`,color:S[B.status]||`grey`,children:B.status}),(0,w.jsx)(O,{type:`tertiary`,size:`small`,children:ee(B.createdAt)}),(0,w.jsx)(O,{type:`tertiary`,size:`small`,children:x(B.durationMs)})]}),(0,w.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelPayload`,null,`参数`)}),(0,w.jsx)(`pre`,{className:`c2-pre`,children:JSON.stringify(B.payload||{},null,2)}),B.resultText&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelResult`,null,`输出`)}),(0,w.jsx)(`pre`,{className:`c2-pre`,children:B.resultText})]}),B.error&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelError`,null,`错误`)}),(0,w.jsx)(`pre`,{className:`c2-pre c2-pre-error`,children:B.error})]})]})})]})}export{k as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{C as i,I as a,P as o,U as s,V as c,_ as l,i as u,it as d,j as f,ot as p}from"./semi-DNxeCrHm.js";import{E as ee,F as te,P as m,_ as ne,a as h,b as g,l as re,m as _,p as ie,r as ae,s as oe,x as v,y as se}from"./index-smFoxEJu.js";import{A as ce,C as le,h as ue,p as de,r as fe,s as pe}from"./c2-shared-B5kg9aBy.js";import{d as y,f as b,g as me,h as x,m as he,p as ge,u as S}from"./c2-shared-BBQQ9OoL.js";var C=e(t(),1),w=e(n(),1),{Text:T}=s,E=new Set([`shell`,`exec`]),D=new Set([`ls`,`download`,`cd`]);function _e({visible:e,defaultSessionId:t,onCancel:n,onSubmit:r,submitting:s}){let c=m(),[l,d]=(0,C.useState)(null),[f,p]=(0,C.useState)(`shell`);return(0,w.jsx)(i,{visible:e,title:c(`c2.tasks.createTitle`,null,`下发任务`),footer:null,width:560,onCancel:n,children:(0,w.jsxs)(u,{initValues:{session_id:t||``,task_type:`shell`,command:``,timeout_seconds:`60`,extra:``},onSubmit:e=>{let t={},n=String(e.command||``).trim();if(E.has(e.task_type)){t.command=n;let r=Number(e.timeout_seconds);Number.isFinite(r)&&r>0&&(t.timeout_seconds=r)}else(D.has(e.task_type)||n)&&(t.path=n);let i=String(e.extra||``).trim();if(i)try{Object.assign(t,JSON.parse(i))}catch{t.raw=i}r({session_id:String(e.session_id||``).trim(),task_type:e.task_type||`shell`,payload:t,source:`manual`})},getFormApi:d,labelPosition:`top`,onValueChange:e=>{e.task_type&&p(e.task_type)},children:[(0,w.jsx)(u.Input,{field:`session_id`,label:c(`c2.tasks.labelSession`,null,`会话`),placeholder:`s_xxxxxxxx`,rules:[{required:!0,message:c(`c2.tasks.labelSession`,null,`请填写会话 ID`)}]}),(0,w.jsx)(u.Select,{field:`task_type`,label:c(`c2.tasks.labelType`,null,`类型`),optionList:b,style:{width:`100%`}}),(0,w.jsx)(u.Input,{field:`command`,label:E.has(f)?c(`c2.tasks.labelCommand`,null,`命令`):c(`c2.tasks.labelPath`,null,`路径`),placeholder:E.has(f)?`whoami`:`/etc/passwd`}),E.has(f)&&(0,w.jsx)(u.Input,{field:`timeout_seconds`,label:c(`c2.tasks.labelTimeout`,null,`超时(秒)`),placeholder:`60`}),(0,w.jsx)(u.Input,{field:`extra`,label:c(`c2.tasks.labelExtraPayload`,null,`附加参数(JSON,可选)`),placeholder:`{"key":"value"}`}),(0,w.jsx)(T,{type:`tertiary`,size:`small`,children:c(`c2.tasks.createHint`,null,`任务入队后由植入体在下次心跳拉取;危险类型可能需要人机协同审批。`)}),(0,w.jsxs)(o,{className:`c2-form-actions`,children:[(0,w.jsx)(a,{onClick:n,children:c(`c2.tasks.cancelFilters`,null,`取消`)}),(0,w.jsx)(a,{theme:`solid`,type:`primary`,loading:s,onClick:()=>l?.submitForm(),children:c(`c2.tasks.createSubmit`,null,`下发`)})]})]},e?`open`:`closed`)})}var{Text:O}=s;function k(){let e=m(),{hasPermission:t}=te(),n=t(`c2:write`),s=t(`c2:delete`)||n,[u,T]=r(),[E,D]=(0,C.useState)(1),[k,ve]=(0,C.useState)(20),[A,j]=(0,C.useState)(``),[M,N]=(0,C.useState)(``),[P,F]=(0,C.useState)(`all`),[I,L]=(0,C.useState)(u.get(`session_id`)||``),[R,z]=(0,C.useState)(u.get(`session_id`)||``),[B,V]=(0,C.useState)(null),[ye,H]=(0,C.useState)(!1),[be,U]=(0,C.useState)(!1),W=(0,C.useMemo)(()=>({page:E,page_size:k,status:A||void 0,task_type:M||void 0,session_id:R||void 0,since:me(P)||void 0}),[E,k,A,M,R,P]),{data:G,loading:K,error:xe,reload:q}=h(()=>le(W),[W]),J=Array.isArray(G?.tasks)?G.tasks:[],Y=Number(G?.total??J.length),X=G?.status_counts||{};ae(()=>q({silent:!0}),5e3);let Z=()=>{z(I.trim()),D(1);let e=new URLSearchParams(u);I.trim()?e.set(`session_id`,I.trim()):e.delete(`session_id`),T(e,{replace:!0})},Q=()=>{j(``),N(``),F(`all`),L(``),z(``),D(1),T(new URLSearchParams,{replace:!0})},Se=[{id:`total`,label:e(`c2.tasks.statTotal`,null,`当前筛选`),value:Y},{id:`success`,label:e(`c2.tasks.success`,null,`成功`),value:X.success||0,tone:`success`},{id:`failed`,label:e(`c2.tasks.failed`,null,`失败`),value:X.failed||0,tone:`danger`},{id:`pending`,label:e(`c2.tasks.pending`,null,`待处理`),value:(X.queued||0)+(X.sent||0)+(X.running||0),tone:`warning`}],Ce=async t=>{try{await fe(t.id),v(e(`c2.tasks.toastCancelled`,null,`任务已取消`)),q({silent:!0})}catch(e){g(e)}},we=t=>{se({title:e(`c2.tasks.deleteOne`,null,`删除任务`),content:e(`c2.tasks.confirmDeleteOne`,null,`确定从服务器删除该任务记录吗?此操作不可恢复。`),onOk:async()=>{try{await de([t.id]),v(e(`c2.tasks.toastDeleted`,null,`已删除 {{n}} 条`).replace(`{{n}}`,`1`)),q()}catch(e){g(e)}}})},Te=async t=>{try{let n=await ce(t.id,20);n?.task&&V(n.task),v(e(`c2.tasks.toastWaited`,null,`已获取最新任务状态`)),q({silent:!0})}catch(t){g(t,e(`c2.tasks.waitTimeout`,null,`等待任务完成超时`))}},$=async t=>{try{await ue(t.id),v(e(`c2.tasks.downloadOk`,null,`已开始下载`))}catch(t){g(t,e(`c2.tasks.labelResult`,null,`下载结果文件失败`))}},Ee=async t=>{U(!0);try{await pe(t),v(e(`c2.tasks.toastCreated`,null,`任务已下发`)),H(!1),q()}catch(t){g(t,e(`c2.tasks.createFailed`,null,`下发任务失败`))}finally{U(!1)}},De=[{title:e(`c2.tasks.colTask`,null,`任务`),dataIndex:`id`,width:150,render:e=>(0,w.jsx)(`span`,{className:`c2-mono`,children:e})},{title:e(`c2.tasks.colSession`,null,`会话`),dataIndex:`sessionId`,width:150,render:e=>(0,w.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.tasks.colType`,null,`类型`),dataIndex:`taskType`,width:110},{title:e(`c2.tasks.colCommand`,null,`命令`),dataIndex:`payload`,render:e=>{let t=e?.command||e?.path||``;return(0,w.jsx)(`span`,{className:`c2-mono c2-task-command`,title:t,children:t||`—`})}},{title:e(`c2.tasks.colStatus`,null,`状态`),dataIndex:`status`,width:110,render:t=>(0,w.jsx)(f,{size:`small`,color:S[t]||`grey`,children:e(`c2.tasks.${t||`queued`}`,null,t||`—`)})},{title:e(`c2.tasks.colDuration`,null,`耗时`),dataIndex:`durationMs`,width:100,render:e=>x(e)},{title:e(`c2.tasks.colCreated`,null,`创建时间`),dataIndex:`createdAt`,width:130,render:e=>(0,w.jsx)(he,{value:e})},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:210,render:(t,n)=>(0,w.jsxs)(o,{spacing:4,wrap:!0,children:[(0,w.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>V(n),children:e(`c2.tasks.view`,null,`查看`)}),[`queued`,`sent`,`running`].includes(n.status)&&(0,w.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>Ce(n),children:e(`c2.tasks.cancelBtn`,null,`取消`)}),n.resultBlobPath&&(0,w.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>$(n),children:e(`c2.tasks.downloadResult`,null,`结果文件`)}),(0,w.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,disabled:!s,onClick:()=>we(n),children:e(`c2.tasks.deleteBtn`,null,`删除`)})]})}];return(0,w.jsxs)(`div`,{className:`c2-page`,id:`page-c2-tasks`,children:[(0,w.jsx)(ie,{title:e(`c2.tasks.title`,null,`任务管理`),description:e(`c2.tasks.pageDesc`,null,`按状态、类型、会话与时间窗筛选任务,5 秒自动轮询最新状态`),extra:[(0,w.jsx)(a,{icon:(0,w.jsx)(d,{}),onClick:()=>q(),loading:K,children:e(`c2.tasks.refresh`,null,`刷新任务`)},`refresh`),(0,w.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,w.jsx)(p,{}),disabled:!n,onClick:()=>H(!0),children:e(`c2.tasks.createTitle`,null,`下发任务`)},`create`)]}),(0,w.jsx)(ne,{metrics:Se,columns:4}),(0,w.jsx)(re,{error:xe,onRetry:()=>q()}),(0,w.jsx)(_,{title:e(`c2.tasks.filterTitle`,null,`筛选`),extra:(0,w.jsx)(ge,{value:P,onChange:e=>{F(e),D(1)},ns:`tasks`}),children:(0,w.jsxs)(`div`,{className:`c2-toolbar-fields`,children:[(0,w.jsxs)(`div`,{className:`c2-field`,children:[(0,w.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.colStatus`,null,`状态`)}),(0,w.jsx)(l,{value:A,onChange:e=>{j(e||``),D(1)},style:{width:160},optionList:[{value:``,label:e(`c2.tasks.filterAllStatuses`,null,`全部状态`)},...y]})]}),(0,w.jsxs)(`div`,{className:`c2-field`,children:[(0,w.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.colType`,null,`类型`)}),(0,w.jsx)(l,{value:M,onChange:e=>{N(e||``),D(1)},style:{width:160},optionList:[{value:``,label:e(`c2.tasks.filterAllTypes`,null,`全部类型`)},...b]})]}),(0,w.jsxs)(`div`,{className:`c2-field`,children:[(0,w.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.filterSession`,null,`会话 ID`)}),(0,w.jsx)(c,{value:I,onChange:L,onEnterPress:Z,placeholder:e(`c2.tasks.filterSessionPlaceholder`,null,`s_xxxxxxxx`),style:{width:190}})]}),(0,w.jsxs)(o,{spacing:8,children:[(0,w.jsx)(a,{theme:`solid`,type:`primary`,onClick:Z,children:e(`c2.tasks.applyFilters`,null,`应用筛选`)}),(0,w.jsx)(a,{onClick:Q,children:e(`c2.tasks.resetFilters`,null,`重置`)})]})]})}),(0,w.jsx)(_,{title:e(`c2.tasks.listTitle`,null,`任务列表`),children:(0,w.jsx)(oe,{columns:De,dataSource:J,rowKey:`id`,loading:K,onRefresh:()=>q(),pagination:{currentPage:E,pageSize:k,total:Y,onPageChange:e=>D(e),onPageSizeChange:e=>{ve(e),D(1)}},emptyText:e(`c2.tasks.emptyAll`,null,`暂无任务`)})}),(0,w.jsx)(_e,{visible:ye,defaultSessionId:R,submitting:be,onCancel:()=>H(!1),onSubmit:Ee}),(0,w.jsx)(i,{visible:!!B,title:e(`c2.tasks.modalTitle`,null,`任务详情`),width:760,onCancel:()=>V(null),footer:(0,w.jsxs)(o,{children:[B&&[`queued`,`sent`,`running`].includes(B.status)&&(0,w.jsx)(a,{onClick:()=>Te(B),children:e(`c2.tasks.waitBtn`,null,`等待完成`)}),B?.resultBlobPath&&(0,w.jsx)(a,{onClick:()=>$(B),children:e(`c2.tasks.downloadResult`,null,`下载结果文件`)}),(0,w.jsx)(a,{onClick:()=>V(null),children:e(`c2.tasks.close`,null,`关闭`)})]}),children:B&&(0,w.jsxs)(`div`,{className:`c2-task-detail`,children:[(0,w.jsxs)(`div`,{className:`c2-task-detail-meta`,children:[(0,w.jsx)(`span`,{className:`c2-mono`,children:B.id}),(0,w.jsx)(f,{size:`small`,color:S[B.status]||`grey`,children:B.status}),(0,w.jsx)(O,{type:`tertiary`,size:`small`,children:ee(B.createdAt)}),(0,w.jsx)(O,{type:`tertiary`,size:`small`,children:x(B.durationMs)})]}),(0,w.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelPayload`,null,`参数`)}),(0,w.jsx)(`pre`,{className:`c2-pre`,children:JSON.stringify(B.payload||{},null,2)}),B.resultText&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelResult`,null,`输出`)}),(0,w.jsx)(`pre`,{className:`c2-pre`,children:B.resultText})]}),B.error&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelError`,null,`错误`)}),(0,w.jsx)(`pre`,{className:`c2-pre c2-pre-error`,children:B.error})]})]})})]})}export{k as default};
\ No newline at end of file
diff --git a/web/static/app/assets/chat-QPrSpZt5.js b/web/static/app/assets/chat-4zuVcYax.js
similarity index 99%
rename from web/static/app/assets/chat-QPrSpZt5.js
rename to web/static/app/assets/chat-4zuVcYax.js
index 56523489..3987fbf9 100644
--- a/web/static/app/assets/chat-QPrSpZt5.js
+++ b/web/static/app/assets/chat-4zuVcYax.js
@@ -1,4 +1,4 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{$ as i,B as a,Bt as o,Ct as s,F as c,Ft as l,H as u,Ht as d,I as f,J as p,K as m,M as h,N as g,P as _,Q as v,R as y,Tt as b,U as x,V as ee,Z as S,_ as C,b as te,d as w,et as T,g as E,h as D,ht as O,it as ne,j as k,k as A,l as j,lt as M,m as re,nt as N,ot as ie,rt as ae,st as oe,w as se,x as ce,xt as P,yt as le}from"./semi-DNxeCrHm.js";import{D as F,E as I,F as ue,I as L,P as R,R as de,S as fe,a as pe,b as z,f as me,i as he,l as B,n as ge,o as V,r as _e,u as ve,x as ye,y as be,z as xe}from"./index-BoFwOeaz.js";import{n as Se,r as Ce,t as we}from"./model-channel-mQ6lfvSO.js";var H=e(t(),1),U=e(n(),1),{Text:Te,Title:Ee}=x,De={single:{key:`chat.agentModePiSingle`,label:`单代理`,color:`blue`},deep:{key:`chat.agentModeDeep`,label:`Deep`,color:`purple`},plan_execute:{key:`chat.agentModePlanExecuteLabel`,label:`Plan-Execute`,color:`orange`},supervisor:{key:`chat.agentModeSupervisorLabel`,label:`Supervisor`,color:`green`}};function Oe({conversation:e,mode:t,hitlCount:n,conversationId:r,plan:i,narrow:a,onToggleSidebar:o,onOpenUsage:s,onOpenPlan:c,onRefresh:u}){let d=R(),p=De[t]||De.single,m=e?.title||d(`chat.newChat`,null,`新对话`);return(0,U.jsxs)(`header`,{className:`chat-header`,children:[(0,U.jsxs)(`div`,{className:`chat-header-main`,children:[(0,U.jsxs)(`div`,{className:`chat-header-heading`,children:[(0,U.jsx)(Ee,{heading:3,className:`chat-header-title`,title:m,children:m}),(0,U.jsxs)(_,{spacing:6,wrap:!0,className:`chat-header-tags`,children:[e?.pinned&&(0,U.jsx)(k,{size:`small`,color:`amber`,children:d(`chat.pinned`,null,`已置顶`)}),(0,U.jsx)(k,{size:`small`,color:p.color,children:d(p.key,null,p.label)}),e?.projectId&&(0,U.jsxs)(k,{size:`small`,type:`ghost`,children:[`项目 `,String(e.projectId).slice(0,8)]}),n>0&&(0,U.jsx)(k,{size:`small`,color:`orange`,children:d(`chat.pendingApprovals`,{count:n},`待审批 ${n}`)})]})]}),(0,U.jsx)(Te,{type:`tertiary`,size:`small`,className:`chat-header-description`,children:r?d(`chat.conversationHint`,null,`会话历史与工具执行过程会自动落库`):d(`chat.newConversationHint`,null,`输入内容即可创建新对话`)})]}),(0,U.jsxs)(_,{spacing:8,wrap:!0,className:`chat-header-actions`,children:[a&&(0,U.jsx)(f,{icon:(0,U.jsx)(M,{}),onClick:o,children:d(`chat.conversations`,null,`会话`)}),(0,U.jsx)(f,{theme:`borderless`,type:`tertiary`,icon:(0,U.jsx)(O,{}),disabled:!r,onClick:s,children:d(`chat.tokenUsage`,null,`Token 用量`)}),(0,U.jsxs)(f,{theme:`borderless`,type:`tertiary`,icon:(0,U.jsx)(l,{}),disabled:!r,onClick:c,children:[d(`chat.planTasks`,null,`计划任务`),i?.total?` (${i.completed}/${i.total})`:``]}),(0,U.jsx)(f,{theme:`borderless`,type:`tertiary`,icon:(0,U.jsx)(ne,{}),onClick:u,children:d(`common.refresh`,null,`刷新`)})]})]})}var ke=[`default`,`off`,`on`,`auto`],Ae=[`low`,`medium`,`high`,`xhigh`,`max`];function je(e,t){let[n,r]=(0,H.useState)(()=>{try{return localStorage.getItem(e)??t}catch{return t}});return[n,t=>{r(t);try{localStorage.setItem(e,t)}catch{}}]}function Me(e){let[t,n]=je(`cyberstrike-chat-ai-channel`,``),[r,i]=je(`cyberstrike-chat-reasoning-mode`,`default`),[a,o]=je(`cyberstrike-chat-reasoning-effort`,``),s=pe(async()=>(await L.get(`/config`))?.ai,[e],{skip:!e}),c=Object.entries(s.data?.channels||{}).sort(([e],[t])=>e.localeCompare(t)),l=t.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``),u=c.find(([e])=>e===t)?.[0]||c.find(([e])=>e===l)?.[0]||``,d=ke.includes(r)?r:`default`,f=Ae.includes(a)?a:``,p={mode:d==="default"?void 0:d,effort:d===`off`?void 0:f||void 0};return{channel:u,channels:c,setChannel:n,config:s,mode:d,setMode:i,effort:f,setEffort:o,waitingForChannel:!!(e&&t&&s.loading),request:{aiChannelId:e&&u||void 0,reasoning:p.mode||p.effort?p:void 0}}}var{Text:Ne}=x;function W({label:e,...t}){let n=(0,H.useId)();return(0,U.jsxs)(`div`,{className:`chat-setting-field`,children:[(0,U.jsx)(Ne,{id:n,strong:!0,children:e}),(0,U.jsx)(C,{"aria-labelledby":n,...t})]})}function Pe({onClose:e,narrow:t,busy:n,canReadConfig:r,canReadHitl:i,canEnableHitl:a,model:o,conversationId:s,draftApproval:c,onEnableDraftApproval:l}){let d=R(),[p,m]=(0,H.useState)(!1),h=pe(()=>L.get(s?`/hitl/config/${encodeURIComponent(s)}`:`/hitl/default-config`),[s,i],{skip:!i}),g=c?`approval`:s?h.data?.hitl?.enabled?h.data.hitl.mode:`off`:h.data?.defaultMode,_=g===`approval`||g===`review_edit`,v=c?`human`:s?h.data?.hitl?.reviewer:h.data?.defaultReviewer,y=v===`audit_agent`,b=a&&h.data?.conversationHumanApproval&&!c&&(!s||g!==`approval`||v!==`human`),x=g===`review_edit`?d(`chat.hitlModeReviewEdit`,null,`审查编辑`):d(`chat.hitlModeApproval`,null,`审批模式`),ee=y?d(`chat.hitlReviewerAgent`,null,`审计 Agent`):d(`chat.hitlReviewerHuman`,null,`人工审批`),S=o.config.data?.default_channel,C=S?we(S,o.config.data?.channels?.[S]):``,te=d(`chat.aiChannelDefault`,null,`跟随默认通道`),T=[{value:``,label:C?`${te} · ${C}`:te},...Se(o.channels)],E={default:d(`chat.reasoningModeDefault`,null,`跟随系统`),off:d(`chat.reasoningModeOff`,null,`关闭`),on:d(`chat.reasoningModeOn`,null,`开启`),auto:d(`chat.reasoningModeAuto`,null,`自动`)},D=async()=>{if(!s)l();else{m(!0);try{let e=await L.put(`/hitl/config/${encodeURIComponent(s)}/human-approval`);h.setData(t=>({...t,hitl:e.hitl}))}catch(e){z(e,d(`chat.hitlApplyFail`,null,`同步到服务器失败`))}finally{m(!1)}}};return(0,U.jsx)(w,{visible:!0,title:d(`chat.sessionSettingsTitle`,null,`会话设置`),width:t?`100%`:420,closable:!p,maskClosable:!p,closeOnEsc:!p,onCancel:e,children:(0,U.jsxs)(`div`,{className:`chat-settings-fields`,children:[r&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(W,{label:d(`chat.aiChannelLabel`,null,`AI 通道`),value:o.channel,optionList:T,renderSelectedItem:Ce,onSelect:o.setChannel,loading:o.config.loading,disabled:n||o.config.loading||!!o.config.error}),(0,U.jsx)(B,{error:o.config.error,onRetry:()=>o.config.reload()})]}),(0,U.jsx)(W,{label:d(`chat.reasoningModeLabel`,null,`模型推理`),value:o.mode,optionList:ke.map(e=>({value:e,label:E[e]})),onSelect:o.setMode,disabled:n}),(0,U.jsx)(W,{label:d(`chat.reasoningEffortLabel`,null,`推理强度`),value:o.mode===`off`?``:o.effort,optionList:[{value:``,label:d(`chat.reasoningEffortUnset`,null,`不指定`)},...Ae.map(e=>({value:e,label:e}))],onSelect:o.setEffort,disabled:n||o.mode===`off`}),i&&(0,U.jsxs)(`section`,{className:`chat-setting-field`,children:[(0,U.jsx)(Ne,{strong:!0,children:d(`chat.hitlTitle`,null,`人机协同`)}),(0,U.jsx)(B,{error:h.error,onRetry:()=>h.reload()}),h.loading&&(0,U.jsx)(u,{}),h.data&&!h.error&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`chat-setting-approval`,children:[(0,U.jsx)(k,{color:_?`green`:`grey`,children:_?x:d(`chat.hitlModeOff`,null,`关闭`)}),_&&v&&(0,U.jsx)(Ne,{type:`secondary`,children:d(`chat.hitlCurrentReviewer`,{reviewer:ee},`审批方 · {{reviewer}}`)})]}),c&&(0,U.jsx)(Ne,{type:`tertiary`,size:`small`,children:d(`chat.hitlConversationApprovalPending`,null,`发送后将为此会话保存人工审批。`)}),b&&(0,U.jsx)(f,{disabled:n||p,loading:p,onClick:D,children:d(`chat.hitlRequireHumanForConversation`,null,`此会话使用人工审批`)})]})]})]})})}var{Text:G}=x;function Fe({item:e,active:t,editing:n,editingTitle:r,onStartEdit:i,onEditingTitle:a,onCommitEdit:o,onCancelEdit:s,onSelect:c,onPin:l,onDelete:u,canWrite:p,canDelete:m,selected:g,onToggleSelect:_,batchMode:y}){let b=R(),x=String(e.title||b(`chat.untitled`,null,`未命名对话`));return(0,U.jsxs)(`div`,{className:`chat-conv-item ${t?`is-active`:``}`,children:[y&&(0,U.jsx)(h,{className:`chat-conv-check`,"aria-label":`${b(`chat.selectConversation`,null,`选择对话`)}:${x}`,checked:g,onChange:t=>_(e.id,t.target.checked)}),n?(0,U.jsxs)(`div`,{className:`chat-conv-edit`,children:[(0,U.jsx)(ee,{size:`small`,"aria-label":b(`chat.renameConversationTitle`,null,`重命名`),value:r,autoFocus:!0,onChange:a,onEnterPress:o,onKeyDown:e=>{e.key===`Escape`&&s()}}),(0,U.jsxs)(`div`,{className:`chat-conv-edit-actions`,children:[(0,U.jsx)(f,{size:`small`,theme:`solid`,onClick:o,children:b(`common.save`,null,`保存`)}),(0,U.jsx)(f,{size:`small`,theme:`borderless`,onClick:s,children:b(`common.cancel`,null,`取消`)})]})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`button`,{type:`button`,className:`chat-conv-main`,"aria-current":t?`true`:void 0,title:x,onClick:()=>c(e.id),children:[(0,U.jsxs)(`span`,{className:`chat-conv-title`,children:[e.pinned&&(0,U.jsx)(v,{size:`small`,className:`chat-conv-pin`}),(0,U.jsx)(`span`,{className:`chat-conv-title-text`,children:x})]}),(0,U.jsxs)(`span`,{className:`chat-conv-meta`,children:[I(e.updatedAt||e.createdAt),e.projectId&&(0,U.jsx)(k,{size:`small`,type:`ghost`,className:`chat-conv-project`,children:String(e.projectId).slice(0,8)})]})]}),!y&&(0,U.jsxs)(`div`,{className:`chat-conv-actions`,children:[p&&(0,U.jsx)(d,{content:b(`chat.renameConversationTitle`,null,`重命名`),children:(0,U.jsx)(f,{size:`small`,theme:`borderless`,"aria-label":b(`chat.renameConversationTitle`,null,`重命名`),icon:(0,U.jsx)(le,{}),onClick:()=>i(e)})}),p&&(0,U.jsx)(d,{content:e.pinned?b(`chat.unpin`,null,`取消置顶`):b(`chat.pin`,null,`置顶`),children:(0,U.jsx)(f,{size:`small`,theme:`borderless`,icon:(0,U.jsx)(v,{}),"aria-label":e.pinned?b(`chat.unpin`,null,`取消置顶`):b(`chat.pin`,null,`置顶`),type:e.pinned?`warning`:`tertiary`,onClick:()=>l(e)})}),m&&(0,U.jsx)(D,{title:b(`chat.deleteConversationConfirm`,null,`确认删除该对话?删除后不可恢复。`),onConfirm:()=>u(e),children:(0,U.jsx)(f,{size:`small`,theme:`borderless`,type:`danger`,"aria-label":b(`chat.deleteConversationTitle`,null,`删除对话`),icon:(0,U.jsx)(P,{})})})]})]})]})}function Ie({items:e,total:t,loading:n,error:r,onRetry:i,search:a,onSearch:o,projectId:s,onProjectChange:l,projects:u,page:d,pageSize:p,onPageChange:m,selectedId:h,onSelect:g,onCreate:_,onRename:v,onPin:y,onDelete:b,onBatchDelete:x,canWrite:S,canDelete:te}){let w=R(),T=Array.isArray(e)?e:[],[D,O]=(0,H.useState)(``),[k,A]=(0,H.useState)(``),[j,M]=(0,H.useState)(!1),[re,N]=(0,H.useState)([]);(0,H.useEffect)(()=>{N([]),M(!1)},[d,s,a]);let oe=(0,H.useMemo)(()=>[{value:``,label:w(`chat.filterAllProjects`,null,`全部项目`)},...(Array.isArray(u)?u:[]).map(e=>({value:e.id,label:e.name||e.id}))],[u,w]),P=(e,t)=>{N(n=>t?[...new Set([...n,e])]:n.filter(t=>t!==e))},le=e=>{O(e.id),A(String(e.title||``))},F=()=>{let e=D,t=k.trim();O(``),e&&t&&v(e,t)};return(0,U.jsxs)(`div`,{className:`chat-sidebar-inner`,children:[(0,U.jsxs)(`div`,{className:`chat-sidebar-head`,children:[(0,U.jsx)(G,{strong:!0,className:`chat-sidebar-title`,children:w(`chat.conversations`,null,`会话`)}),(0,U.jsx)(f,{icon:(0,U.jsx)(ie,{}),theme:`solid`,onClick:_,disabled:!S,children:w(`chat.newChat`,null,`新建对话`)})]}),(0,U.jsxs)(`div`,{className:`chat-sidebar-filters`,children:[(0,U.jsx)(ee,{prefix:(0,U.jsx)(ae,{}),"aria-label":w(`chat.searchHistory`,null,`搜索历史对话`),placeholder:w(`chat.searchHistory`,null,`搜索历史对话`),value:a,onChange:o,showClear:!0}),(0,U.jsx)(C,{value:s,optionList:oe,onChange:l,className:`chat-sidebar-project`,"aria-label":w(`chat.filterByProject`,null,`按项目过滤`),placeholder:w(`chat.filterByProject`,null,`按项目过滤`)})]}),(0,U.jsxs)(`div`,{className:`chat-sidebar-tools`,children:[(0,U.jsxs)(G,{type:`tertiary`,size:`small`,children:[w(`chat.recentConversations`,null,`最近对话`),` · `,t??T.length]}),(0,U.jsxs)(`div`,{className:`chat-sidebar-tools-actions`,children:[te&&T.length>0&&(0,U.jsx)(f,{size:`small`,theme:j?`solid`:`borderless`,onClick:()=>{M(!j),N([])},children:j?w(`common.cancel`,null,`取消`):w(`chat.batchManage`,null,`批量管理`)}),(0,U.jsx)(f,{size:`small`,theme:`borderless`,"aria-label":w(`common.refresh`,null,`刷新`),icon:(0,U.jsx)(ne,{}),onClick:i})]})]}),j&&(0,U.jsxs)(`div`,{className:`chat-batch-bar`,children:[(0,U.jsxs)(G,{size:`small`,children:[w(`chat.selectedCount`,null,`已选`),` `,re.length]}),(0,U.jsx)(f,{size:`small`,type:`danger`,disabled:!re.length,onClick:async()=>{await x(re),N([]),M(!1)},children:w(`chat.batchDelete`,null,`批量删除`)})]}),(0,U.jsxs)(`div`,{className:`chat-conv-list`,children:[(0,U.jsx)(B,{error:r,onRetry:i}),n&&!T.length&&(0,U.jsx)(c,{placeholder:(0,U.jsx)(c.Paragraph,{rows:6}),loading:!0}),!n&&!T.length&&(0,U.jsx)(se,{title:w(`chat.noHistoryConversations`,null,`暂无历史对话`),description:null,className:`chat-sidebar-empty`}),(0,U.jsx)(ce,{dataSource:T,split:!1,renderItem:e=>(0,U.jsx)(Fe,{item:e,active:e.id===h,editing:D===e.id,editingTitle:k,onStartEdit:le,onEditingTitle:A,onCommitEdit:F,onCancelEdit:()=>O(``),onSelect:g,onPin:y,onDelete:b,canWrite:S,canDelete:te,batchMode:j,selected:re.includes(e.id),onToggleSelect:P},e.id)})]}),(t||0)>p&&(0,U.jsx)(`div`,{className:`chat-sidebar-pager`,children:(0,U.jsx)(E,{size:`small`,total:t||0,pageSize:p,currentPage:d,onPageChange:m,showSizeChanger:!1})})]})}var Le=new Set([`taskcreate`,`taskupdate`,`tasklist`,`taskget`,`write_todos`]),K=new Set([`heartbeat`,`response_delta`,`thinking_stream_delta`,`reasoning_chain_stream_delta`,`tool_result_delta`]),Re=200,ze=2e4;function q(e){return e==null?``:String(e)}function Be(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function J(e,t=ze){let n=q(e);return n.length<=t?n:`${n.slice(0,t)}\n…(已截断,共 ${n.length} 字符)`}function Y(e,t=6e3){if(e==null)return``;try{return J(typeof e==`string`?e:JSON.stringify(e,null,2),t)}catch{return J(String(e),t)}}function X({conversationId:e=``,id:t}={}){return{id:t||`live-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,conversationId:e,status:`streaming`,text:``,blocks:[],events:[],error:``,notice:``,statusText:``,messageId:``,userMessageId:``,finalizable:null,startedAt:Date.now(),endedAt:0,seq:0}}function Z(e,t){return e.seq+=1,`${t}-${e.seq}`}function Ve(e,t){let n=q(t.type);K.has(n)||(e.events.push({at:Date.now(),type:n,message:q(t.message),data:t.data===void 0?null:t.data}),e.events.length>Re&&e.events.splice(0,e.events.length-Re))}function Q(e,{title:t,message:n,tone:r=`info`,data:i=null}){let a=e.blocks[e.blocks.length-1];if(a&&a.kind===`note`&&a.title===t&&a.message===q(n))return a;let o={kind:`note`,id:Z(e,`note`),title:t,message:J(n),tone:r,data:i};return e.blocks.push(o),o}function He(e,t,n=`thinking`){let r=q(t)||Z(e,`reasoning`),i=r?e.blocks.find(e=>e.kind===`reasoning`&&e.key===r):null;return i||(i={kind:`reasoning`,id:Z(e,`reason`),key:r,stream:q(t),label:n,text:``},e.blocks.push(i)),i}function Ue(e,t){let n=q(t.toolCallId),r=null;return n&&(r=e.blocks.find(e=>e.kind===`tool`&&e.toolCallId===n)),r||(r={kind:`tool`,id:Z(e,`tool`),toolCallId:n,toolName:q(t.toolName)||`未知工具`,args:null,result:``,status:`running`,processDetailId:q(t.processDetailId),agentName:q(t.agentName)},e.blocks.push(r)),t.toolName&&(r.toolName===`未知工具`||!r.toolName)&&(r.toolName=q(t.toolName)),t.agentName&&!r.agentName&&(r.agentName=q(t.agentName)),t.processDetailId&&!r.processDetailId&&(r.processDetailId=q(t.processDetailId)),r}function We(e){let t=q(e.displayStatus||e.status).toLowerCase();return t===`cancelled`||t===`canceled`?`cancelled`:t===`background_running`?`running`:t===`blocked`?`blocked`:e.isError===!0||e.success===!1?`failed`:`success`}function Ge(e,t){if(!e||!t||typeof t!=`object`)return e;let n=q(t.type),r=Be(t.data)||{};switch(Ve(e,t),n){case`heartbeat`:break;case`conversation`:r.conversationId&&(e.conversationId=q(r.conversationId));break;case`message_saved`:r.userMessageId&&(e.userMessageId=q(r.userMessageId));break;case`progress`:e.statusText=q(t.message)||e.statusText;break;case`iteration`:{let n=Number(r.iteration)||1,i=q(r.piScope).trim(),a=q(r.agentName).trim(),o=i===`main`?a?`主代理 · ${a}`:`主代理`:i===`sub`?`子代理${a?` · ${a}`:``}`:``;e.blocks.push({kind:`iteration`,id:Z(e,`iter`),title:`第 ${n} 轮迭代${o?` · ${o}`:``}`,message:J(t.message,2e3)});break}case`thinking_stream_start`:case`reasoning_chain_stream_start`:{let t=He(e,r.streamId,n===`reasoning_chain_stream_start`?`reasoning_chain`:`thinking`);t.text=``;break}case`thinking_stream_delta`:case`reasoning_chain_stream_delta`:{let i=He(e,r.streamId,n===`reasoning_chain_stream_delta`?`reasoning_chain`:`thinking`),a=typeof r.accumulated==`string`?r.accumulated:null;i.text=J(a===null?i.text+q(t.message):a);break}case`thinking`:case`reasoning_chain`:if(r.streamId){let i=He(e,r.streamId,n===`reasoning_chain`?`reasoning_chain`:`thinking`);q(t.message)&&(i.text=J(t.message));break}e.blocks.push({kind:`reasoning`,id:Z(e,`reason`),key:Z(e,`reasonkey`),stream:``,label:n===`reasoning_chain`?`reasoning_chain`:`thinking`,text:J(t.message)});break;case`response_start`:r.conversationId&&(e.conversationId=q(r.conversationId)),e.statusText||(e.statusText=`正在生成回复…`);break;case`response_delta`:{let n=typeof r.accumulated==`string`?r.accumulated:null;e.text=J(n===null?e.text+q(t.message):n,6e4);break}case`response`:{let n=q(t.message);n&&(e.text=J(n,6e4)),r.messageId&&(e.messageId=q(r.messageId)),r.conversationId&&(e.conversationId=q(r.conversationId)),r.finalizable===!1?e.finalizable=!1:r.finalizable===!0&&(e.finalizable=!0);break}case`tool_call`:{let t=Ue(e,r);t.args=r.argumentsObj===void 0?r.arguments===void 0?t.args:r.arguments:r.argumentsObj;break}case`tool_result`:{let n=Ue(e,r);n.status=We(r),n.result=J((r.resultPreview===void 0?r.result:r.resultPreview)??t.message,8e3);break}case`tool_calls_detected`:Q(e,{title:`🔧 检测到工具调用`,message:t.message,data:r});break;case`hitl_interrupt`:Q(e,{title:`🧑⚖️ 等待人工审批`,message:`${q(r.toolName)||`工具`} · ${q(t.message)||`命中审批策略`}`,tone:`warning`,data:r});break;case`hitl_resumed`:Q(e,{title:`✅ 审批通过`,message:q(t.message),tone:`success`,data:r});break;case`hitl_rejected`:Q(e,{title:`⛔ 审批被拒绝`,message:q(t.message),tone:`danger`,data:r});break;case`hitl_audit_agent_started`:Q(e,{title:`🛡 审计代理审查中`,message:q(t.message),tone:`info`,data:r});break;case`hitl_audit_agent`:Q(e,{title:`🛡 审计代理已裁决`,message:`${q(r.decision)||`-`}${r.comment?` · ${q(r.comment)}`:``}`,tone:`info`,data:r});break;case`warning`:case`iteration_limit_reached`:case`pi_pending_orphaned`:Q(e,{title:`⚠️ ${q(t.message)||`提示`}`,message:q(t.message),tone:`warning`,data:r});break;case`finalization_check`:Q(e,{title:`🔎 最终化校验未通过`,message:q(t.message),tone:`warning`,data:r}),r.finalizable===!1&&(e.finalizable=!1);break;case`finalization_auto_continue`:case`finalization_pending_tools_cancelled`:case`agent_empty_response_continue`:case`agent_run_retry`:case`pi_model_retry`:case`pi_model_failover`:case`pi_stream_error`:Q(e,{title:q(t.message)||`运行提示`,message:q(t.message),tone:`warning`,data:r});break;case`agent_usage_summary`:Q(e,{title:`📊 本轮用量`,message:`${Number(r.modelCalls)||0} 次模型调用 · ${Number(r.totalTokens)||0} tokens`,tone:`info`,data:r});break;case`user_interrupt_continue`:Q(e,{title:`⏸️ 用户中断并继续`,message:q(t.message),tone:`info`,data:r});break;case`agent_reply`:Q(e,{title:`💬 ${q(r.agentName)||`子代理`}回复`,message:q(t.message),data:r});break;case`workflow_start`:case`workflow_done`:case`workflow_node_start`:case`workflow_node_result`:case`workflow_branch_taken`:case`workflow_branch_skipped`:case`workflow_tool_start`:case`workflow_agent_output`:case`workflow_hitl_checkpoint`:case`workflow_hitl_waiting`:case`workflow_hitl_resumed`:case`workflow_hitl_rejected`:case`workflow_paused`:Q(e,{title:`🧭 ${q(t.message)||n}`,message:q(t.message),data:r});break;case`cancelled`:e.status=`cancelled`,e.notice=q(t.message)||`任务已取消`,e.endedAt=Date.now();break;case`error`:e.status=`error`,e.error=q(t.message)||`执行失败`,e.endedAt=Date.now();break;case`done`:e.status===`streaming`&&(e.status=`done`),r.workflowStatus===`awaiting_hitl`&&(e.statusText=`工作流等待审批`),e.endedAt=Date.now()}return e}var Ke={streaming:{label:`生成中`,color:`blue`},done:{label:`已完成`,color:`green`},error:{label:`失败`,color:`red`},cancelled:{label:`已取消`,color:`grey`}};function qe(e){let t=[],n=0,r=e=>(n+=1,`h-${e}-${n}`),i=q(e?.reasoningContent).trim();i&&t.push({kind:`reasoning`,id:r(`reason`),key:`reasoningContent`,stream:``,label:`thinking`,text:J(i)});let a=Array.isArray(e?.processDetails)?e.processDetails:[],o=new Map;return a.forEach(e=>{let n=q(e?.eventType),i=Be(e?.data)||{},a=q(e?.message);switch(n){case`iteration`:{let e=Number(i.iteration)||1,n=q(i.piScope).trim(),o=q(i.agentName).trim();t.push({kind:`iteration`,id:r(`iter`),title:`第 ${e} 轮迭代${n===`main`?` · 主代理`:n===`sub`?` · 子代理`:``}${o?` · ${o}`:``}`,message:J(a,2e3)});break}case`thinking`:case`reasoning_chain`:if(!a.trim())break;t.push({kind:`reasoning`,id:r(`reason`),key:q(i.streamId)||r(`reasonkey`),stream:q(i.streamId),label:n,text:J(a)});break;case`tool_call`:{let n=q(i.toolCallId),a={kind:`tool`,id:r(`tool`),toolCallId:n,toolName:q(i.toolName)||`未知工具`,args:i.argumentsObj===void 0?i.arguments===void 0?null:i.arguments:i.argumentsObj,result:``,status:`running`,processDetailId:q(e?.id),agentName:q(i.agentName)};n&&o.set(n,a),t.push(a);break}case`tool_result`:{let e=q(i.toolCallId),n=e?o.get(e):null;n||(n={kind:`tool`,id:r(`tool`),toolCallId:e,toolName:q(i.toolName)||`未知工具`,args:null,result:``,status:`running`,processDetailId:``,agentName:q(i.agentName)},e&&o.set(e,n),t.push(n)),n.status=We(i);let s=i.resultPreview===void 0?i.result:i.resultPreview;n.result=J(s??a,8e3);break}case`planning`:if(!a.trim())break;t.push({kind:`note`,id:r(`note`),title:`📝 规划`,message:J(a,4e3),tone:`info`,data:null});break;case`hitl_interrupt`:case`hitl_resumed`:case`hitl_rejected`:case`hitl_audit_agent`:case`hitl_audit_agent_started`:{let e=n===`hitl_rejected`?`danger`:n===`hitl_resumed`?`success`:`info`,o=n===`hitl_interrupt`?`🧑⚖️ 人工审批`:n===`hitl_rejected`?`⛔ 审批被拒绝`:n===`hitl_resumed`?`✅ 审批通过`:`🛡 审计代理`;t.push({kind:`note`,id:r(`note`),title:o,message:`${a}${i.toolName?` · ${q(i.toolName)}`:``}${i.decision?` · ${q(i.decision)}`:``}`,tone:e,data:null});break}case`error`:case`timeout`:case`cancelled`:t.push({kind:`note`,id:r(`note`),title:n===`cancelled`?`⏹ 已取消`:`❌ 执行异常`,message:a,tone:`danger`,data:null});break;case`agent_reply`:t.push({kind:`note`,id:r(`note`),title:`💬 子代理回复`,message:J(a,6e3),tone:`info`,data:null});break;case`progress`:break;default:(a.trim()||Object.keys(i).length)&&t.push({kind:`note`,id:r(`note`),title:q(n)||`过程事件`,message:J(a,4e3),tone:`info`,data:Object.keys(i).length?i:null})}}),t}var{Text:Je}=x,Ye={running:{color:`blue`,label:`执行中`},success:{color:`green`,label:`完成`},failed:{color:`red`,label:`失败`},cancelled:{color:`grey`,label:`已取消`},blocked:{color:`orange`,label:`已拦截`}};function Xe({block:e,defaultOpen:t}){let n=e.text||``;if(!n.trim())return null;let r=e.label===`reasoning_chain`?`🔗 推理过程`:`🤔 思考过程`;return(0,U.jsx)(A,{className:`chat-block-collapse`,defaultActiveKey:t?[`1`]:[],children:(0,U.jsx)(A.Panel,{itemKey:`1`,header:(0,U.jsxs)(`span`,{className:`chat-block-title`,children:[r,` · `,n.length,` 字符`]}),children:(0,U.jsx)(`pre`,{className:`chat-pre`,children:J(n)})})})}function Ze({block:e}){let t=Ye[e.status]||Ye.running,n=Y(e.args),r=e.result||``,i=!!(n||r),a=(0,U.jsxs)(`span`,{className:`chat-tool-head`,children:[(0,U.jsxs)(`span`,{className:`chat-tool-name`,children:[e.agentName?`${e.agentName} · `:``,e.toolName||`未知工具`]}),(0,U.jsx)(k,{size:`small`,color:t.color,shape:`circle`,children:t.label})]});return i?(0,U.jsx)(`div`,{className:`chat-tool`,children:(0,U.jsx)(A,{className:`chat-block-collapse`,children:(0,U.jsxs)(A.Panel,{itemKey:`1`,header:a,children:[n&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Je,{type:`tertiary`,size:`small`,children:`参数`}),(0,U.jsx)(`pre`,{className:`chat-pre`,children:n})]}),r&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Je,{type:`tertiary`,size:`small`,children:`结果`}),(0,U.jsx)(`pre`,{className:`chat-pre`,children:r})]})]})})}):(0,U.jsx)(`div`,{className:`chat-tool`,children:(0,U.jsx)(`div`,{className:`chat-tool-head-row`,children:a})})}function Qe({block:e}){let[t,n]=(0,H.useState)(!1),r=e.tone||`info`;return(0,U.jsxs)(`div`,{className:`chat-note chat-note-${r}`,children:[(0,U.jsxs)(`div`,{className:`chat-note-head`,children:[(0,U.jsx)(`span`,{className:`chat-note-title`,children:e.title}),e.data&&(0,U.jsx)(`button`,{type:`button`,className:`chat-link-btn`,onClick:()=>n(!t),children:t?`收起 JSON`:`查看 JSON`})]}),e.message&&(0,U.jsx)(`div`,{className:`chat-note-body`,children:e.message}),t&&e.data&&(0,U.jsx)(ve,{value:e.data,collapsed:!1,title:`事件数据`})]})}function $e({events:e}){return!e||!e.length?null:(0,U.jsx)(A,{className:`chat-block-collapse chat-event-log`,children:(0,U.jsx)(A.Panel,{itemKey:`1`,header:(0,U.jsxs)(`span`,{className:`chat-block-title`,children:[`🧾 原始事件 · `,e.length,` 条`]}),children:(0,U.jsx)(`pre`,{className:`chat-pre`,children:e.map((e,t)=>`${t+1}. ${JSON.stringify(e)}`).join(`
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{$ as i,B as a,Bt as o,Ct as s,F as c,Ft as l,H as u,Ht as d,I as f,J as p,K as m,M as h,N as g,P as _,Q as v,R as y,Tt as b,U as x,V as ee,Z as S,_ as C,b as te,d as w,et as T,g as E,h as D,ht as O,it as ne,j as k,k as A,l as j,lt as M,m as re,nt as N,ot as ie,rt as ae,st as oe,w as se,x as ce,xt as P,yt as le}from"./semi-DNxeCrHm.js";import{D as F,E as I,F as ue,I as L,P as R,R as de,S as fe,a as pe,b as z,f as me,i as he,l as B,n as ge,o as V,r as _e,u as ve,x as ye,y as be,z as xe}from"./index-smFoxEJu.js";import{n as Se,r as Ce,t as we}from"./model-channel-mQ6lfvSO.js";var H=e(t(),1),U=e(n(),1),{Text:Te,Title:Ee}=x,De={single:{key:`chat.agentModePiSingle`,label:`单代理`,color:`blue`},deep:{key:`chat.agentModeDeep`,label:`Deep`,color:`purple`},plan_execute:{key:`chat.agentModePlanExecuteLabel`,label:`Plan-Execute`,color:`orange`},supervisor:{key:`chat.agentModeSupervisorLabel`,label:`Supervisor`,color:`green`}};function Oe({conversation:e,mode:t,hitlCount:n,conversationId:r,plan:i,narrow:a,onToggleSidebar:o,onOpenUsage:s,onOpenPlan:c,onRefresh:u}){let d=R(),p=De[t]||De.single,m=e?.title||d(`chat.newChat`,null,`新对话`);return(0,U.jsxs)(`header`,{className:`chat-header`,children:[(0,U.jsxs)(`div`,{className:`chat-header-main`,children:[(0,U.jsxs)(`div`,{className:`chat-header-heading`,children:[(0,U.jsx)(Ee,{heading:3,className:`chat-header-title`,title:m,children:m}),(0,U.jsxs)(_,{spacing:6,wrap:!0,className:`chat-header-tags`,children:[e?.pinned&&(0,U.jsx)(k,{size:`small`,color:`amber`,children:d(`chat.pinned`,null,`已置顶`)}),(0,U.jsx)(k,{size:`small`,color:p.color,children:d(p.key,null,p.label)}),e?.projectId&&(0,U.jsxs)(k,{size:`small`,type:`ghost`,children:[`项目 `,String(e.projectId).slice(0,8)]}),n>0&&(0,U.jsx)(k,{size:`small`,color:`orange`,children:d(`chat.pendingApprovals`,{count:n},`待审批 ${n}`)})]})]}),(0,U.jsx)(Te,{type:`tertiary`,size:`small`,className:`chat-header-description`,children:r?d(`chat.conversationHint`,null,`会话历史与工具执行过程会自动落库`):d(`chat.newConversationHint`,null,`输入内容即可创建新对话`)})]}),(0,U.jsxs)(_,{spacing:8,wrap:!0,className:`chat-header-actions`,children:[a&&(0,U.jsx)(f,{icon:(0,U.jsx)(M,{}),onClick:o,children:d(`chat.conversations`,null,`会话`)}),(0,U.jsx)(f,{theme:`borderless`,type:`tertiary`,icon:(0,U.jsx)(O,{}),disabled:!r,onClick:s,children:d(`chat.tokenUsage`,null,`Token 用量`)}),(0,U.jsxs)(f,{theme:`borderless`,type:`tertiary`,icon:(0,U.jsx)(l,{}),disabled:!r,onClick:c,children:[d(`chat.planTasks`,null,`计划任务`),i?.total?` (${i.completed}/${i.total})`:``]}),(0,U.jsx)(f,{theme:`borderless`,type:`tertiary`,icon:(0,U.jsx)(ne,{}),onClick:u,children:d(`common.refresh`,null,`刷新`)})]})]})}var ke=[`default`,`off`,`on`,`auto`],Ae=[`low`,`medium`,`high`,`xhigh`,`max`];function je(e,t){let[n,r]=(0,H.useState)(()=>{try{return localStorage.getItem(e)??t}catch{return t}});return[n,t=>{r(t);try{localStorage.setItem(e,t)}catch{}}]}function Me(e){let[t,n]=je(`cyberstrike-chat-ai-channel`,``),[r,i]=je(`cyberstrike-chat-reasoning-mode`,`default`),[a,o]=je(`cyberstrike-chat-reasoning-effort`,``),s=pe(async()=>(await L.get(`/config`))?.ai,[e],{skip:!e}),c=Object.entries(s.data?.channels||{}).sort(([e],[t])=>e.localeCompare(t)),l=t.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``),u=c.find(([e])=>e===t)?.[0]||c.find(([e])=>e===l)?.[0]||``,d=ke.includes(r)?r:`default`,f=Ae.includes(a)?a:``,p={mode:d==="default"?void 0:d,effort:d===`off`?void 0:f||void 0};return{channel:u,channels:c,setChannel:n,config:s,mode:d,setMode:i,effort:f,setEffort:o,waitingForChannel:!!(e&&t&&s.loading),request:{aiChannelId:e&&u||void 0,reasoning:p.mode||p.effort?p:void 0}}}var{Text:Ne}=x;function W({label:e,...t}){let n=(0,H.useId)();return(0,U.jsxs)(`div`,{className:`chat-setting-field`,children:[(0,U.jsx)(Ne,{id:n,strong:!0,children:e}),(0,U.jsx)(C,{"aria-labelledby":n,...t})]})}function Pe({onClose:e,narrow:t,busy:n,canReadConfig:r,canReadHitl:i,canEnableHitl:a,model:o,conversationId:s,draftApproval:c,onEnableDraftApproval:l}){let d=R(),[p,m]=(0,H.useState)(!1),h=pe(()=>L.get(s?`/hitl/config/${encodeURIComponent(s)}`:`/hitl/default-config`),[s,i],{skip:!i}),g=c?`approval`:s?h.data?.hitl?.enabled?h.data.hitl.mode:`off`:h.data?.defaultMode,_=g===`approval`||g===`review_edit`,v=c?`human`:s?h.data?.hitl?.reviewer:h.data?.defaultReviewer,y=v===`audit_agent`,b=a&&h.data?.conversationHumanApproval&&!c&&(!s||g!==`approval`||v!==`human`),x=g===`review_edit`?d(`chat.hitlModeReviewEdit`,null,`审查编辑`):d(`chat.hitlModeApproval`,null,`审批模式`),ee=y?d(`chat.hitlReviewerAgent`,null,`审计 Agent`):d(`chat.hitlReviewerHuman`,null,`人工审批`),S=o.config.data?.default_channel,C=S?we(S,o.config.data?.channels?.[S]):``,te=d(`chat.aiChannelDefault`,null,`跟随默认通道`),T=[{value:``,label:C?`${te} · ${C}`:te},...Se(o.channels)],E={default:d(`chat.reasoningModeDefault`,null,`跟随系统`),off:d(`chat.reasoningModeOff`,null,`关闭`),on:d(`chat.reasoningModeOn`,null,`开启`),auto:d(`chat.reasoningModeAuto`,null,`自动`)},D=async()=>{if(!s)l();else{m(!0);try{let e=await L.put(`/hitl/config/${encodeURIComponent(s)}/human-approval`);h.setData(t=>({...t,hitl:e.hitl}))}catch(e){z(e,d(`chat.hitlApplyFail`,null,`同步到服务器失败`))}finally{m(!1)}}};return(0,U.jsx)(w,{visible:!0,title:d(`chat.sessionSettingsTitle`,null,`会话设置`),width:t?`100%`:420,closable:!p,maskClosable:!p,closeOnEsc:!p,onCancel:e,children:(0,U.jsxs)(`div`,{className:`chat-settings-fields`,children:[r&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(W,{label:d(`chat.aiChannelLabel`,null,`AI 通道`),value:o.channel,optionList:T,renderSelectedItem:Ce,onSelect:o.setChannel,loading:o.config.loading,disabled:n||o.config.loading||!!o.config.error}),(0,U.jsx)(B,{error:o.config.error,onRetry:()=>o.config.reload()})]}),(0,U.jsx)(W,{label:d(`chat.reasoningModeLabel`,null,`模型推理`),value:o.mode,optionList:ke.map(e=>({value:e,label:E[e]})),onSelect:o.setMode,disabled:n}),(0,U.jsx)(W,{label:d(`chat.reasoningEffortLabel`,null,`推理强度`),value:o.mode===`off`?``:o.effort,optionList:[{value:``,label:d(`chat.reasoningEffortUnset`,null,`不指定`)},...Ae.map(e=>({value:e,label:e}))],onSelect:o.setEffort,disabled:n||o.mode===`off`}),i&&(0,U.jsxs)(`section`,{className:`chat-setting-field`,children:[(0,U.jsx)(Ne,{strong:!0,children:d(`chat.hitlTitle`,null,`人机协同`)}),(0,U.jsx)(B,{error:h.error,onRetry:()=>h.reload()}),h.loading&&(0,U.jsx)(u,{}),h.data&&!h.error&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`chat-setting-approval`,children:[(0,U.jsx)(k,{color:_?`green`:`grey`,children:_?x:d(`chat.hitlModeOff`,null,`关闭`)}),_&&v&&(0,U.jsx)(Ne,{type:`secondary`,children:d(`chat.hitlCurrentReviewer`,{reviewer:ee},`审批方 · {{reviewer}}`)})]}),c&&(0,U.jsx)(Ne,{type:`tertiary`,size:`small`,children:d(`chat.hitlConversationApprovalPending`,null,`发送后将为此会话保存人工审批。`)}),b&&(0,U.jsx)(f,{disabled:n||p,loading:p,onClick:D,children:d(`chat.hitlRequireHumanForConversation`,null,`此会话使用人工审批`)})]})]})]})})}var{Text:G}=x;function Fe({item:e,active:t,editing:n,editingTitle:r,onStartEdit:i,onEditingTitle:a,onCommitEdit:o,onCancelEdit:s,onSelect:c,onPin:l,onDelete:u,canWrite:p,canDelete:m,selected:g,onToggleSelect:_,batchMode:y}){let b=R(),x=String(e.title||b(`chat.untitled`,null,`未命名对话`));return(0,U.jsxs)(`div`,{className:`chat-conv-item ${t?`is-active`:``}`,children:[y&&(0,U.jsx)(h,{className:`chat-conv-check`,"aria-label":`${b(`chat.selectConversation`,null,`选择对话`)}:${x}`,checked:g,onChange:t=>_(e.id,t.target.checked)}),n?(0,U.jsxs)(`div`,{className:`chat-conv-edit`,children:[(0,U.jsx)(ee,{size:`small`,"aria-label":b(`chat.renameConversationTitle`,null,`重命名`),value:r,autoFocus:!0,onChange:a,onEnterPress:o,onKeyDown:e=>{e.key===`Escape`&&s()}}),(0,U.jsxs)(`div`,{className:`chat-conv-edit-actions`,children:[(0,U.jsx)(f,{size:`small`,theme:`solid`,onClick:o,children:b(`common.save`,null,`保存`)}),(0,U.jsx)(f,{size:`small`,theme:`borderless`,onClick:s,children:b(`common.cancel`,null,`取消`)})]})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`button`,{type:`button`,className:`chat-conv-main`,"aria-current":t?`true`:void 0,title:x,onClick:()=>c(e.id),children:[(0,U.jsxs)(`span`,{className:`chat-conv-title`,children:[e.pinned&&(0,U.jsx)(v,{size:`small`,className:`chat-conv-pin`}),(0,U.jsx)(`span`,{className:`chat-conv-title-text`,children:x})]}),(0,U.jsxs)(`span`,{className:`chat-conv-meta`,children:[I(e.updatedAt||e.createdAt),e.projectId&&(0,U.jsx)(k,{size:`small`,type:`ghost`,className:`chat-conv-project`,children:String(e.projectId).slice(0,8)})]})]}),!y&&(0,U.jsxs)(`div`,{className:`chat-conv-actions`,children:[p&&(0,U.jsx)(d,{content:b(`chat.renameConversationTitle`,null,`重命名`),children:(0,U.jsx)(f,{size:`small`,theme:`borderless`,"aria-label":b(`chat.renameConversationTitle`,null,`重命名`),icon:(0,U.jsx)(le,{}),onClick:()=>i(e)})}),p&&(0,U.jsx)(d,{content:e.pinned?b(`chat.unpin`,null,`取消置顶`):b(`chat.pin`,null,`置顶`),children:(0,U.jsx)(f,{size:`small`,theme:`borderless`,icon:(0,U.jsx)(v,{}),"aria-label":e.pinned?b(`chat.unpin`,null,`取消置顶`):b(`chat.pin`,null,`置顶`),type:e.pinned?`warning`:`tertiary`,onClick:()=>l(e)})}),m&&(0,U.jsx)(D,{title:b(`chat.deleteConversationConfirm`,null,`确认删除该对话?删除后不可恢复。`),onConfirm:()=>u(e),children:(0,U.jsx)(f,{size:`small`,theme:`borderless`,type:`danger`,"aria-label":b(`chat.deleteConversationTitle`,null,`删除对话`),icon:(0,U.jsx)(P,{})})})]})]})]})}function Ie({items:e,total:t,loading:n,error:r,onRetry:i,search:a,onSearch:o,projectId:s,onProjectChange:l,projects:u,page:d,pageSize:p,onPageChange:m,selectedId:h,onSelect:g,onCreate:_,onRename:v,onPin:y,onDelete:b,onBatchDelete:x,canWrite:S,canDelete:te}){let w=R(),T=Array.isArray(e)?e:[],[D,O]=(0,H.useState)(``),[k,A]=(0,H.useState)(``),[j,M]=(0,H.useState)(!1),[re,N]=(0,H.useState)([]);(0,H.useEffect)(()=>{N([]),M(!1)},[d,s,a]);let oe=(0,H.useMemo)(()=>[{value:``,label:w(`chat.filterAllProjects`,null,`全部项目`)},...(Array.isArray(u)?u:[]).map(e=>({value:e.id,label:e.name||e.id}))],[u,w]),P=(e,t)=>{N(n=>t?[...new Set([...n,e])]:n.filter(t=>t!==e))},le=e=>{O(e.id),A(String(e.title||``))},F=()=>{let e=D,t=k.trim();O(``),e&&t&&v(e,t)};return(0,U.jsxs)(`div`,{className:`chat-sidebar-inner`,children:[(0,U.jsxs)(`div`,{className:`chat-sidebar-head`,children:[(0,U.jsx)(G,{strong:!0,className:`chat-sidebar-title`,children:w(`chat.conversations`,null,`会话`)}),(0,U.jsx)(f,{icon:(0,U.jsx)(ie,{}),theme:`solid`,onClick:_,disabled:!S,children:w(`chat.newChat`,null,`新建对话`)})]}),(0,U.jsxs)(`div`,{className:`chat-sidebar-filters`,children:[(0,U.jsx)(ee,{prefix:(0,U.jsx)(ae,{}),"aria-label":w(`chat.searchHistory`,null,`搜索历史对话`),placeholder:w(`chat.searchHistory`,null,`搜索历史对话`),value:a,onChange:o,showClear:!0}),(0,U.jsx)(C,{value:s,optionList:oe,onChange:l,className:`chat-sidebar-project`,"aria-label":w(`chat.filterByProject`,null,`按项目过滤`),placeholder:w(`chat.filterByProject`,null,`按项目过滤`)})]}),(0,U.jsxs)(`div`,{className:`chat-sidebar-tools`,children:[(0,U.jsxs)(G,{type:`tertiary`,size:`small`,children:[w(`chat.recentConversations`,null,`最近对话`),` · `,t??T.length]}),(0,U.jsxs)(`div`,{className:`chat-sidebar-tools-actions`,children:[te&&T.length>0&&(0,U.jsx)(f,{size:`small`,theme:j?`solid`:`borderless`,onClick:()=>{M(!j),N([])},children:j?w(`common.cancel`,null,`取消`):w(`chat.batchManage`,null,`批量管理`)}),(0,U.jsx)(f,{size:`small`,theme:`borderless`,"aria-label":w(`common.refresh`,null,`刷新`),icon:(0,U.jsx)(ne,{}),onClick:i})]})]}),j&&(0,U.jsxs)(`div`,{className:`chat-batch-bar`,children:[(0,U.jsxs)(G,{size:`small`,children:[w(`chat.selectedCount`,null,`已选`),` `,re.length]}),(0,U.jsx)(f,{size:`small`,type:`danger`,disabled:!re.length,onClick:async()=>{await x(re),N([]),M(!1)},children:w(`chat.batchDelete`,null,`批量删除`)})]}),(0,U.jsxs)(`div`,{className:`chat-conv-list`,children:[(0,U.jsx)(B,{error:r,onRetry:i}),n&&!T.length&&(0,U.jsx)(c,{placeholder:(0,U.jsx)(c.Paragraph,{rows:6}),loading:!0}),!n&&!T.length&&(0,U.jsx)(se,{title:w(`chat.noHistoryConversations`,null,`暂无历史对话`),description:null,className:`chat-sidebar-empty`}),(0,U.jsx)(ce,{dataSource:T,split:!1,renderItem:e=>(0,U.jsx)(Fe,{item:e,active:e.id===h,editing:D===e.id,editingTitle:k,onStartEdit:le,onEditingTitle:A,onCommitEdit:F,onCancelEdit:()=>O(``),onSelect:g,onPin:y,onDelete:b,canWrite:S,canDelete:te,batchMode:j,selected:re.includes(e.id),onToggleSelect:P},e.id)})]}),(t||0)>p&&(0,U.jsx)(`div`,{className:`chat-sidebar-pager`,children:(0,U.jsx)(E,{size:`small`,total:t||0,pageSize:p,currentPage:d,onPageChange:m,showSizeChanger:!1})})]})}var Le=new Set([`taskcreate`,`taskupdate`,`tasklist`,`taskget`,`write_todos`]),K=new Set([`heartbeat`,`response_delta`,`thinking_stream_delta`,`reasoning_chain_stream_delta`,`tool_result_delta`]),Re=200,ze=2e4;function q(e){return e==null?``:String(e)}function Be(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function J(e,t=ze){let n=q(e);return n.length<=t?n:`${n.slice(0,t)}\n…(已截断,共 ${n.length} 字符)`}function Y(e,t=6e3){if(e==null)return``;try{return J(typeof e==`string`?e:JSON.stringify(e,null,2),t)}catch{return J(String(e),t)}}function X({conversationId:e=``,id:t}={}){return{id:t||`live-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,conversationId:e,status:`streaming`,text:``,blocks:[],events:[],error:``,notice:``,statusText:``,messageId:``,userMessageId:``,finalizable:null,startedAt:Date.now(),endedAt:0,seq:0}}function Z(e,t){return e.seq+=1,`${t}-${e.seq}`}function Ve(e,t){let n=q(t.type);K.has(n)||(e.events.push({at:Date.now(),type:n,message:q(t.message),data:t.data===void 0?null:t.data}),e.events.length>Re&&e.events.splice(0,e.events.length-Re))}function Q(e,{title:t,message:n,tone:r=`info`,data:i=null}){let a=e.blocks[e.blocks.length-1];if(a&&a.kind===`note`&&a.title===t&&a.message===q(n))return a;let o={kind:`note`,id:Z(e,`note`),title:t,message:J(n),tone:r,data:i};return e.blocks.push(o),o}function He(e,t,n=`thinking`){let r=q(t)||Z(e,`reasoning`),i=r?e.blocks.find(e=>e.kind===`reasoning`&&e.key===r):null;return i||(i={kind:`reasoning`,id:Z(e,`reason`),key:r,stream:q(t),label:n,text:``},e.blocks.push(i)),i}function Ue(e,t){let n=q(t.toolCallId),r=null;return n&&(r=e.blocks.find(e=>e.kind===`tool`&&e.toolCallId===n)),r||(r={kind:`tool`,id:Z(e,`tool`),toolCallId:n,toolName:q(t.toolName)||`未知工具`,args:null,result:``,status:`running`,processDetailId:q(t.processDetailId),agentName:q(t.agentName)},e.blocks.push(r)),t.toolName&&(r.toolName===`未知工具`||!r.toolName)&&(r.toolName=q(t.toolName)),t.agentName&&!r.agentName&&(r.agentName=q(t.agentName)),t.processDetailId&&!r.processDetailId&&(r.processDetailId=q(t.processDetailId)),r}function We(e){let t=q(e.displayStatus||e.status).toLowerCase();return t===`cancelled`||t===`canceled`?`cancelled`:t===`background_running`?`running`:t===`blocked`?`blocked`:e.isError===!0||e.success===!1?`failed`:`success`}function Ge(e,t){if(!e||!t||typeof t!=`object`)return e;let n=q(t.type),r=Be(t.data)||{};switch(Ve(e,t),n){case`heartbeat`:break;case`conversation`:r.conversationId&&(e.conversationId=q(r.conversationId));break;case`message_saved`:r.userMessageId&&(e.userMessageId=q(r.userMessageId));break;case`progress`:e.statusText=q(t.message)||e.statusText;break;case`iteration`:{let n=Number(r.iteration)||1,i=q(r.piScope).trim(),a=q(r.agentName).trim(),o=i===`main`?a?`主代理 · ${a}`:`主代理`:i===`sub`?`子代理${a?` · ${a}`:``}`:``;e.blocks.push({kind:`iteration`,id:Z(e,`iter`),title:`第 ${n} 轮迭代${o?` · ${o}`:``}`,message:J(t.message,2e3)});break}case`thinking_stream_start`:case`reasoning_chain_stream_start`:{let t=He(e,r.streamId,n===`reasoning_chain_stream_start`?`reasoning_chain`:`thinking`);t.text=``;break}case`thinking_stream_delta`:case`reasoning_chain_stream_delta`:{let i=He(e,r.streamId,n===`reasoning_chain_stream_delta`?`reasoning_chain`:`thinking`),a=typeof r.accumulated==`string`?r.accumulated:null;i.text=J(a===null?i.text+q(t.message):a);break}case`thinking`:case`reasoning_chain`:if(r.streamId){let i=He(e,r.streamId,n===`reasoning_chain`?`reasoning_chain`:`thinking`);q(t.message)&&(i.text=J(t.message));break}e.blocks.push({kind:`reasoning`,id:Z(e,`reason`),key:Z(e,`reasonkey`),stream:``,label:n===`reasoning_chain`?`reasoning_chain`:`thinking`,text:J(t.message)});break;case`response_start`:r.conversationId&&(e.conversationId=q(r.conversationId)),e.statusText||(e.statusText=`正在生成回复…`);break;case`response_delta`:{let n=typeof r.accumulated==`string`?r.accumulated:null;e.text=J(n===null?e.text+q(t.message):n,6e4);break}case`response`:{let n=q(t.message);n&&(e.text=J(n,6e4)),r.messageId&&(e.messageId=q(r.messageId)),r.conversationId&&(e.conversationId=q(r.conversationId)),r.finalizable===!1?e.finalizable=!1:r.finalizable===!0&&(e.finalizable=!0);break}case`tool_call`:{let t=Ue(e,r);t.args=r.argumentsObj===void 0?r.arguments===void 0?t.args:r.arguments:r.argumentsObj;break}case`tool_result`:{let n=Ue(e,r);n.status=We(r),n.result=J((r.resultPreview===void 0?r.result:r.resultPreview)??t.message,8e3);break}case`tool_calls_detected`:Q(e,{title:`🔧 检测到工具调用`,message:t.message,data:r});break;case`hitl_interrupt`:Q(e,{title:`🧑⚖️ 等待人工审批`,message:`${q(r.toolName)||`工具`} · ${q(t.message)||`命中审批策略`}`,tone:`warning`,data:r});break;case`hitl_resumed`:Q(e,{title:`✅ 审批通过`,message:q(t.message),tone:`success`,data:r});break;case`hitl_rejected`:Q(e,{title:`⛔ 审批被拒绝`,message:q(t.message),tone:`danger`,data:r});break;case`hitl_audit_agent_started`:Q(e,{title:`🛡 审计代理审查中`,message:q(t.message),tone:`info`,data:r});break;case`hitl_audit_agent`:Q(e,{title:`🛡 审计代理已裁决`,message:`${q(r.decision)||`-`}${r.comment?` · ${q(r.comment)}`:``}`,tone:`info`,data:r});break;case`warning`:case`iteration_limit_reached`:case`pi_pending_orphaned`:Q(e,{title:`⚠️ ${q(t.message)||`提示`}`,message:q(t.message),tone:`warning`,data:r});break;case`finalization_check`:Q(e,{title:`🔎 最终化校验未通过`,message:q(t.message),tone:`warning`,data:r}),r.finalizable===!1&&(e.finalizable=!1);break;case`finalization_auto_continue`:case`finalization_pending_tools_cancelled`:case`agent_empty_response_continue`:case`agent_run_retry`:case`pi_model_retry`:case`pi_model_failover`:case`pi_stream_error`:Q(e,{title:q(t.message)||`运行提示`,message:q(t.message),tone:`warning`,data:r});break;case`agent_usage_summary`:Q(e,{title:`📊 本轮用量`,message:`${Number(r.modelCalls)||0} 次模型调用 · ${Number(r.totalTokens)||0} tokens`,tone:`info`,data:r});break;case`user_interrupt_continue`:Q(e,{title:`⏸️ 用户中断并继续`,message:q(t.message),tone:`info`,data:r});break;case`agent_reply`:Q(e,{title:`💬 ${q(r.agentName)||`子代理`}回复`,message:q(t.message),data:r});break;case`workflow_start`:case`workflow_done`:case`workflow_node_start`:case`workflow_node_result`:case`workflow_branch_taken`:case`workflow_branch_skipped`:case`workflow_tool_start`:case`workflow_agent_output`:case`workflow_hitl_checkpoint`:case`workflow_hitl_waiting`:case`workflow_hitl_resumed`:case`workflow_hitl_rejected`:case`workflow_paused`:Q(e,{title:`🧭 ${q(t.message)||n}`,message:q(t.message),data:r});break;case`cancelled`:e.status=`cancelled`,e.notice=q(t.message)||`任务已取消`,e.endedAt=Date.now();break;case`error`:e.status=`error`,e.error=q(t.message)||`执行失败`,e.endedAt=Date.now();break;case`done`:e.status===`streaming`&&(e.status=`done`),r.workflowStatus===`awaiting_hitl`&&(e.statusText=`工作流等待审批`),e.endedAt=Date.now()}return e}var Ke={streaming:{label:`生成中`,color:`blue`},done:{label:`已完成`,color:`green`},error:{label:`失败`,color:`red`},cancelled:{label:`已取消`,color:`grey`}};function qe(e){let t=[],n=0,r=e=>(n+=1,`h-${e}-${n}`),i=q(e?.reasoningContent).trim();i&&t.push({kind:`reasoning`,id:r(`reason`),key:`reasoningContent`,stream:``,label:`thinking`,text:J(i)});let a=Array.isArray(e?.processDetails)?e.processDetails:[],o=new Map;return a.forEach(e=>{let n=q(e?.eventType),i=Be(e?.data)||{},a=q(e?.message);switch(n){case`iteration`:{let e=Number(i.iteration)||1,n=q(i.piScope).trim(),o=q(i.agentName).trim();t.push({kind:`iteration`,id:r(`iter`),title:`第 ${e} 轮迭代${n===`main`?` · 主代理`:n===`sub`?` · 子代理`:``}${o?` · ${o}`:``}`,message:J(a,2e3)});break}case`thinking`:case`reasoning_chain`:if(!a.trim())break;t.push({kind:`reasoning`,id:r(`reason`),key:q(i.streamId)||r(`reasonkey`),stream:q(i.streamId),label:n,text:J(a)});break;case`tool_call`:{let n=q(i.toolCallId),a={kind:`tool`,id:r(`tool`),toolCallId:n,toolName:q(i.toolName)||`未知工具`,args:i.argumentsObj===void 0?i.arguments===void 0?null:i.arguments:i.argumentsObj,result:``,status:`running`,processDetailId:q(e?.id),agentName:q(i.agentName)};n&&o.set(n,a),t.push(a);break}case`tool_result`:{let e=q(i.toolCallId),n=e?o.get(e):null;n||(n={kind:`tool`,id:r(`tool`),toolCallId:e,toolName:q(i.toolName)||`未知工具`,args:null,result:``,status:`running`,processDetailId:``,agentName:q(i.agentName)},e&&o.set(e,n),t.push(n)),n.status=We(i);let s=i.resultPreview===void 0?i.result:i.resultPreview;n.result=J(s??a,8e3);break}case`planning`:if(!a.trim())break;t.push({kind:`note`,id:r(`note`),title:`📝 规划`,message:J(a,4e3),tone:`info`,data:null});break;case`hitl_interrupt`:case`hitl_resumed`:case`hitl_rejected`:case`hitl_audit_agent`:case`hitl_audit_agent_started`:{let e=n===`hitl_rejected`?`danger`:n===`hitl_resumed`?`success`:`info`,o=n===`hitl_interrupt`?`🧑⚖️ 人工审批`:n===`hitl_rejected`?`⛔ 审批被拒绝`:n===`hitl_resumed`?`✅ 审批通过`:`🛡 审计代理`;t.push({kind:`note`,id:r(`note`),title:o,message:`${a}${i.toolName?` · ${q(i.toolName)}`:``}${i.decision?` · ${q(i.decision)}`:``}`,tone:e,data:null});break}case`error`:case`timeout`:case`cancelled`:t.push({kind:`note`,id:r(`note`),title:n===`cancelled`?`⏹ 已取消`:`❌ 执行异常`,message:a,tone:`danger`,data:null});break;case`agent_reply`:t.push({kind:`note`,id:r(`note`),title:`💬 子代理回复`,message:J(a,6e3),tone:`info`,data:null});break;case`progress`:break;default:(a.trim()||Object.keys(i).length)&&t.push({kind:`note`,id:r(`note`),title:q(n)||`过程事件`,message:J(a,4e3),tone:`info`,data:Object.keys(i).length?i:null})}}),t}var{Text:Je}=x,Ye={running:{color:`blue`,label:`执行中`},success:{color:`green`,label:`完成`},failed:{color:`red`,label:`失败`},cancelled:{color:`grey`,label:`已取消`},blocked:{color:`orange`,label:`已拦截`}};function Xe({block:e,defaultOpen:t}){let n=e.text||``;if(!n.trim())return null;let r=e.label===`reasoning_chain`?`🔗 推理过程`:`🤔 思考过程`;return(0,U.jsx)(A,{className:`chat-block-collapse`,defaultActiveKey:t?[`1`]:[],children:(0,U.jsx)(A.Panel,{itemKey:`1`,header:(0,U.jsxs)(`span`,{className:`chat-block-title`,children:[r,` · `,n.length,` 字符`]}),children:(0,U.jsx)(`pre`,{className:`chat-pre`,children:J(n)})})})}function Ze({block:e}){let t=Ye[e.status]||Ye.running,n=Y(e.args),r=e.result||``,i=!!(n||r),a=(0,U.jsxs)(`span`,{className:`chat-tool-head`,children:[(0,U.jsxs)(`span`,{className:`chat-tool-name`,children:[e.agentName?`${e.agentName} · `:``,e.toolName||`未知工具`]}),(0,U.jsx)(k,{size:`small`,color:t.color,shape:`circle`,children:t.label})]});return i?(0,U.jsx)(`div`,{className:`chat-tool`,children:(0,U.jsx)(A,{className:`chat-block-collapse`,children:(0,U.jsxs)(A.Panel,{itemKey:`1`,header:a,children:[n&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Je,{type:`tertiary`,size:`small`,children:`参数`}),(0,U.jsx)(`pre`,{className:`chat-pre`,children:n})]}),r&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Je,{type:`tertiary`,size:`small`,children:`结果`}),(0,U.jsx)(`pre`,{className:`chat-pre`,children:r})]})]})})}):(0,U.jsx)(`div`,{className:`chat-tool`,children:(0,U.jsx)(`div`,{className:`chat-tool-head-row`,children:a})})}function Qe({block:e}){let[t,n]=(0,H.useState)(!1),r=e.tone||`info`;return(0,U.jsxs)(`div`,{className:`chat-note chat-note-${r}`,children:[(0,U.jsxs)(`div`,{className:`chat-note-head`,children:[(0,U.jsx)(`span`,{className:`chat-note-title`,children:e.title}),e.data&&(0,U.jsx)(`button`,{type:`button`,className:`chat-link-btn`,onClick:()=>n(!t),children:t?`收起 JSON`:`查看 JSON`})]}),e.message&&(0,U.jsx)(`div`,{className:`chat-note-body`,children:e.message}),t&&e.data&&(0,U.jsx)(ve,{value:e.data,collapsed:!1,title:`事件数据`})]})}function $e({events:e}){return!e||!e.length?null:(0,U.jsx)(A,{className:`chat-block-collapse chat-event-log`,children:(0,U.jsx)(A.Panel,{itemKey:`1`,header:(0,U.jsxs)(`span`,{className:`chat-block-title`,children:[`🧾 原始事件 · `,e.length,` 条`]}),children:(0,U.jsx)(`pre`,{className:`chat-pre`,children:e.map((e,t)=>`${t+1}. ${JSON.stringify(e)}`).join(`
`)})})})}function et({text:e,blocks:t,events:n,streaming:r=!1,openReasoning:i=!1}){let a=Array.isArray(t)?t:[],o=e||``;return(0,U.jsxs)(`div`,{className:`chat-turn-body`,children:[o&&(r?(0,U.jsx)(`pre`,{className:`chat-pre chat-stream-text`,children:o}):(0,U.jsx)(me,{content:o})),!o&&r&&(0,U.jsx)(`div`,{className:`chat-stream-placeholder`,children:`正在生成…`}),a.map(e=>e.kind===`reasoning`?(0,U.jsx)(Xe,{block:e,defaultOpen:i},e.id):e.kind===`tool`?(0,U.jsx)(Ze,{block:e},e.id):e.kind===`iteration`?(0,U.jsx)(`div`,{className:`chat-iteration`,children:(0,U.jsx)(`span`,{className:`chat-iteration-label`,children:e.title})},e.id):e.kind===`note`?(0,U.jsx)(Qe,{block:e},e.id):null),(0,U.jsx)($e,{events:n})]})}var{Paragraph:tt,Text:nt}=x;function rt(){let e=R();return(0,U.jsxs)(`div`,{className:`chat-welcome`,children:[(0,U.jsx)(nt,{type:`tertiary`,className:`chat-welcome-brand`,children:`CyberStrikeAI`}),(0,U.jsx)(se,{image:(0,U.jsx)(`span`,{className:`chat-welcome-mark`,"aria-hidden":`true`,children:(0,U.jsx)(s,{size:`extra-large`})}),title:e(`chat.welcomeHeading`,null,`让安全探索,从对话开始`),description:(0,U.jsx)(tt,{type:`tertiary`,className:`chat-welcome-description`,children:e(`chat.welcomeScopeDescription`,null,`描述测试目标与授权范围,或上传相关材料,即可开始对话。`)}),children:(0,U.jsxs)(_,{spacing:8,wrap:!0,className:`chat-welcome-tags`,children:[(0,U.jsx)(k,{size:`large`,type:`light`,color:`blue`,prefixIcon:(0,U.jsx)(i,{}),children:e(`chat.welcomeScopeTag`,null,`明确授权范围`)}),(0,U.jsx)(k,{size:`large`,type:`light`,color:`grey`,prefixIcon:(0,U.jsx)(oe,{}),children:e(`chat.welcomeMaterialsTag`,null,`附上相关材料`)})]})})]})}function it(e,t,n){let[r,i]=(0,H.useState)(()=>Date.now());if((0,H.useEffect)(()=>{if(!n)return;let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[n]),!e)return``;let a=Math.max(0,Math.round(((n?r:t||e)-e)/1e3));return a<60?`${a}s`:`${Math.floor(a/60)}m${a%60}s`}function at({message:e,canDelete:t,onDeleteTurn:n}){let r=R(),i=e.role===`user`,o=e.role===`system`,s=(0,H.useMemo)(()=>qe(e),[e]),c=e.createdAt?I(e.createdAt):``,l=String(e.content||``);return o?(0,U.jsx)(`div`,{className:`chat-system-row`,children:(0,U.jsx)(nt,{type:`tertiary`,children:l})},e.id):(0,U.jsxs)(`div`,{className:`chat-msg ${i?`chat-msg-user`:`chat-msg-assistant`}`,children:[(0,U.jsx)(a,{size:`small`,color:i?`grey`:`blue`,className:`chat-avatar`,"aria-hidden":`true`,children:i?(0,U.jsx)(m,{}):`AI`}),(0,U.jsxs)(`div`,{className:`chat-bubble`,children:[(0,U.jsxs)(`div`,{className:`chat-bubble-head`,children:[(0,U.jsx)(`span`,{className:`chat-bubble-role`,children:i?r(`chat.you`,null,`我`):r(`chat.assistant`,null,`助手`)}),c&&(0,U.jsx)(`span`,{className:`chat-bubble-time`,children:c}),(0,U.jsxs)(`span`,{className:`chat-bubble-actions`,children:[!i&&l&&(0,U.jsx)(V,{text:l,size:`small`}),t&&i&&e.id&&(0,U.jsx)(d,{content:r(`chat.deleteTurnTitle`,null,`删除本轮`),children:(0,U.jsx)(f,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,U.jsx)(P,{}),"aria-label":r(`chat.deleteTurnTitle`,null,`删除本轮`),onClick:()=>n(e)})})]})]}),l&&(0,U.jsx)(et,{text:l,blocks:s,events:null}),!l&&!s.length&&(0,U.jsx)(nt,{type:`tertiary`,children:`—`})]})]},e.id)}function ot({live:e}){let t=R(),n=Ke[e.status]||Ke.streaming,r=it(e.startedAt,e.endedAt,e.status===`streaming`);return(0,U.jsxs)(`div`,{className:`chat-msg chat-msg-assistant chat-msg-live`,children:[(0,U.jsx)(a,{size:`small`,color:`blue`,className:`chat-avatar`,children:`AI`}),(0,U.jsxs)(`div`,{className:`chat-bubble`,children:[(0,U.jsxs)(`div`,{className:`chat-bubble-head`,children:[(0,U.jsx)(`span`,{className:`chat-bubble-role`,children:t(`chat.assistant`,null,`助手`)}),(0,U.jsx)(k,{size:`small`,color:n.color,shape:`circle`,children:n.label}),r&&(0,U.jsx)(`span`,{className:`chat-bubble-time`,children:r}),e.statusText&&(0,U.jsx)(`span`,{className:`chat-live-status`,children:e.statusText})]}),(0,U.jsx)(et,{text:e.text,blocks:e.blocks,events:e.events,streaming:e.status===`streaming`,openReasoning:e.status===`streaming`}),e.error&&(0,U.jsx)(`div`,{className:`chat-live-error`,children:e.error}),e.notice&&(0,U.jsx)(`div`,{className:`chat-live-notice`,children:e.notice}),e.finalizable===!1&&(0,U.jsx)(`div`,{className:`chat-live-notice`,children:`本轮回复未通过最终化校验,内容可能不完整。`})]})]})}function st({conversationId:e,messages:t,live:n,loading:r,error:i,onRetry:a,canDelete:s,onDeleteTurn:c}){let l=R(),d=(0,H.useRef)(null),p=(0,H.useRef)(!0),[m,h]=(0,H.useState)(!0),g=Array.isArray(t)?t:[],_=(0,H.useMemo)(()=>{if(!n)return`${g.length}`;let e=n.blocks.map(e=>`${e.kind}:${e.id}:${e.text?e.text.length:0}:${e.status||``}`).join(`|`);return`${g.length}#${n.status}#${n.text.length}#${e}`},[g.length,n]),v=(0,H.useCallback)((e=!1)=>{let t=d.current;t&&t.scrollTo({top:t.scrollHeight,behavior:e?`smooth`:`auto`})},[]),y=(0,H.useCallback)(()=>{let e=d.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<120;p.current=t,h(t)},[]);return(0,H.useEffect)(()=>{p.current=!0,h(!0);let e=setTimeout(()=>v(!1),30);return()=>clearTimeout(e)},[e,v]),(0,H.useEffect)(()=>{p.current&&v(!1)},[_,v]),e||n||g.length?(0,U.jsxs)(`div`,{className:`chat-message-wrap`,children:[(0,U.jsxs)(`div`,{className:`chat-messages`,ref:d,onScroll:y,children:[(0,U.jsx)(B,{error:i,onRetry:a}),r&&(0,U.jsx)(`div`,{className:`chat-loading`,children:(0,U.jsx)(u,{size:`middle`})}),!r&&!g.length&&!n&&(0,U.jsx)(rt,{}),g.map(e=>(0,U.jsx)(at,{message:e,canDelete:s,onDeleteTurn:c},e.id)),n&&(0,U.jsx)(ot,{live:n}),i&&!r&&(0,U.jsx)(f,{icon:(0,U.jsx)(ne,{}),theme:`borderless`,onClick:a,className:`chat-retry-inline`,children:l(`common.refresh`,null,`刷新`)})]}),!m&&(0,U.jsx)(f,{className:`chat-scroll-bottom`,icon:(0,U.jsx)(o,{}),size:`small`,theme:`solid`,onClick:()=>{p.current=!0,h(!0),v(!0)},children:l(`chat.returnToLatest`,null,`回到底部`)})]}):(0,U.jsx)(`div`,{className:`chat-message-wrap`,children:(0,U.jsx)(`div`,{className:`chat-messages`,ref:d,children:(0,U.jsx)(rt,{})})})}var{Text:ct}=x,lt=[`single`,`deep`,`plan_execute`,`supervisor`];function ut({value:e,onChange:t,onSend:n,onStop:r,canStop:i,sending:a,checkingRun:o,canWrite:s,canExecute:c,mode:l,onModeChange:u,onOpenSettings:p,projectId:m,onProjectChange:h,projects:g,showProjectSelect:v,attachments:b,onPickFiles:x,onRemoveAttachment:ee,uploading:w}){let E=R(),D=(0,H.useRef)(null),O=Array.isArray(b)?b:[],ne=[{value:`single`,label:E(`chat.agentModePiSingle`,null,`单代理`)},{value:`deep`,label:E(`chat.agentModeDeep`,null,`深度协作(deep)`)},{value:`plan_execute`,label:E(`chat.agentModePlanExecuteLabel`,null,`先规划再执行`)},{value:`supervisor`,label:E(`chat.agentModeSupervisorLabel`,null,`监督者(supervisor)`)}],A=[{value:``,label:E(`chat.noProject`,null,`不绑定项目`)},...(Array.isArray(g)?g:[]).map(e=>({value:e.id,label:e.name||e.id}))],j=Number(w)||O.filter(e=>e.uploading).length,M=!s||!c;return(0,U.jsxs)(`div`,{className:`chat-composer`,children:[M&&(0,U.jsx)(y,{type:`warning`,bordered:!0,closeIcon:null,className:`chat-composer-banner`,description:s?E(`chat.noExecutePermission`,null,`当前账号没有智能体执行权限(agent:execute),发送已禁用。`):E(`chat.noWritePermission`,null,`当前账号没有对话写入权限(chat:write),发送已禁用。`)}),O.length>0&&(0,U.jsx)(`div`,{className:`chat-file-list`,children:O.map(e=>(0,U.jsxs)(k,{className:`chat-file-chip ${e.error?`is-error`:``} ${e.uploading?`is-uploading`:``}`,size:`large`,color:e.error?`red`:e.uploading?`amber`:`blue`,closable:!0,onClose:()=>ee(e.id),children:[(0,U.jsx)(oe,{size:`small`}),(0,U.jsx)(`span`,{className:`chat-file-name`,title:e.fileName,children:e.fileName}),(0,U.jsx)(`span`,{className:`chat-file-state`,children:e.uploading?`上传中…`:e.error?`上传失败`:`已上传`})]},e.id))}),(0,U.jsxs)(`div`,{className:`chat-composer-box`,children:[(0,U.jsx)(`input`,{ref:D,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&x(Array.from(e.target.files)),e.target.value=``}}),(0,U.jsx)(te,{className:`chat-textarea`,borderless:!0,value:e,onChange:t,onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent?.isComposing||(e.preventDefault(),a||o||M||j>0||n())},disabled:M,autosize:{minRows:2,maxRows:8},"aria-label":E(`chat.composerLabel`,null,`对话内容`),placeholder:E(`chat.composerPlaceholder`,null,`描述目标、授权范围与需求,或附上相关材料…`)}),(0,U.jsxs)(`div`,{className:`chat-composer-toolbar`,children:[(0,U.jsxs)(_,{spacing:8,wrap:!0,className:`chat-composer-controls`,children:[(0,U.jsx)(d,{content:E(`chat.selectFile`,null,`选择附件`),children:(0,U.jsx)(f,{icon:(0,U.jsx)(oe,{}),theme:`borderless`,disabled:M,onClick:()=>D.current?.click(),children:E(`chat.attachmentsLabel`,null,`附件`)})}),(0,U.jsx)(C,{value:l,optionList:ne,onChange:u,className:`chat-composer-select`,"aria-label":E(`chat.agentModeSelectAria`,null,`选择对话执行模式`),disabled:a}),v&&(0,U.jsx)(C,{value:m,optionList:A,onChange:h,className:`chat-composer-select`,"aria-label":E(`chat.filterByProject`,null,`选择项目`),placeholder:E(`chat.filterByProject`,null,`选择项目`),disabled:a}),p&&(0,U.jsx)(f,{icon:(0,U.jsx)(T,{"aria-hidden":`true`}),theme:`borderless`,onClick:p,children:E(`chat.sessionSettingsTitle`,null,`会话设置`)})]}),(0,U.jsxs)(_,{spacing:8,wrap:!0,className:`chat-composer-submit`,children:[(0,U.jsx)(ct,{type:`tertiary`,size:`small`,className:`chat-composer-hint`,children:j>0?E(`chat.waitingAttachmentsUpload`,null,`附件上传中…`):E(`chat.sendHint`,null,`Enter 发送 · Shift+Enter 换行`)}),a?(0,U.jsx)(f,{type:`danger`,icon:(0,U.jsx)(S,{}),onClick:r,disabled:!i,children:E(`chat.stop`,null,`停止`)}):(0,U.jsx)(f,{theme:`solid`,icon:(0,U.jsx)(N,{}),disabled:M||o||j>0,onClick:n,children:E(`chat.send`,null,`发送`)})]})]})]})]})}var{Text:dt}=x,ft={approval:`仅审批`,feedback:`审批并反馈`,followup:`审批并追问`,review_edit:`审查编辑`};function pt(e){if(!e)return null;let t=e.payload;if(typeof t==`string`)try{t=JSON.parse(t)}catch{t=null}t&&typeof t==`object`||(t={});let n=t.argumentsObj&&typeof t.argumentsObj==`object`?t.argumentsObj:t.arguments||null;return{...e,payload:t,interruptId:String(e.id||e.interruptId||``),toolName:String(e.toolName||t.toolName||`未知工具`),mode:String(e.mode||t.mode||`approval`).toLowerCase(),args:n}}function mt({item:e,busy:t,readOnly:n,onApprove:r,onReject:i,onDismiss:a}){let o=R(),s=(0,H.useMemo)(()=>pt(e),[e]),[c,l]=(0,H.useState)(``);if(!s)return null;let u=Y(s.args,4e3),d=ft[s.mode]||s.mode,m=n||t||!s.interruptId;return(0,U.jsxs)(g,{className:`chat-hitl-card`,bordered:!0,title:(0,U.jsxs)(`span`,{className:`chat-hitl-title`,children:[(0,U.jsx)(`span`,{children:o(`chat.hitlTitle`,null,`人工审批`)}),(0,U.jsx)(k,{size:`small`,color:`orange`,shape:`circle`,children:d}),(0,U.jsx)(`span`,{className:`chat-hitl-tool`,children:s.toolName})]}),headerExtraContent:(0,U.jsx)(dt,{type:`tertiary`,size:`small`,children:s.createdAt?I(s.createdAt):``}),children:[(0,U.jsxs)(`div`,{className:`chat-hitl-meta`,children:[s.reviewer&&(0,U.jsxs)(dt,{type:`tertiary`,size:`small`,children:[`审批人:`,s.reviewer===`audit_agent`?`审计代理`:`人工`]}),s.expiresAt&&(0,U.jsxs)(dt,{type:`tertiary`,size:`small`,children:[`到期:`,I(s.expiresAt)]}),s.conversationId&&(0,U.jsxs)(dt,{type:`tertiary`,size:`small`,children:[`会话:`,String(s.conversationId).slice(0,8)]})]}),u&&(0,U.jsx)(A,{className:`chat-block-collapse`,children:(0,U.jsx)(A.Panel,{itemKey:`1`,header:(0,U.jsx)(`span`,{className:`chat-block-title`,children:`调用参数`}),children:(0,U.jsx)(`pre`,{className:`chat-pre`,children:u})})}),(0,U.jsxs)(`div`,{className:`chat-hitl-actions`,children:[(0,U.jsx)(ee,{size:`small`,placeholder:o(`chat.hitlComment`,null,`审批备注(拒绝时建议填写原因)`),disabled:n,value:c,onChange:l,className:`chat-hitl-comment`}),(0,U.jsxs)(_,{children:[(0,U.jsx)(f,{theme:`solid`,size:`small`,icon:(0,U.jsx)(p,{}),disabled:m,onClick:()=>r(s,c),children:o(`chat.hitlApprove`,null,`批准`)}),(0,U.jsx)(f,{type:`danger`,size:`small`,icon:(0,U.jsx)(b,{}),disabled:m,onClick:()=>i(s,c),children:o(`chat.hitlReject`,null,`拒绝`)}),(0,U.jsx)(f,{size:`small`,theme:`borderless`,disabled:m,onClick:()=>a(s),children:o(`chat.hitlDismiss`,null,`忽略`)})]})]})]})}var{Text:ht}=x;function gt({items:e,busyId:t,readOnly:n,onRefresh:r,onDecide:i,onDismiss:a}){let o=R(),s=Array.isArray(e)?e:[];return s.length?(0,U.jsxs)(`div`,{className:`chat-hitl-dock`,children:[(0,U.jsxs)(`div`,{className:`chat-hitl-dock-head`,children:[(0,U.jsx)(ht,{strong:!0,children:o(`chat.pendingApprovals`,{count:s.length},`待审批 ${s.length}`)}),(0,U.jsx)(f,{size:`small`,theme:`borderless`,icon:(0,U.jsx)(ne,{}),onClick:r})]}),s.map(e=>(0,U.jsx)(mt,{item:e,readOnly:n,busy:t===String(e.id||e.interruptId),onApprove:(e,t)=>i(e,`approve`,t),onReject:(e,t)=>i(e,`reject`,t),onDismiss:a},e.id||e.interruptId))]}):null}var{Text:$}=x,_t={pending:{color:`grey`,label:`待处理`},in_progress:{color:`blue`,label:`进行中`},completed:{color:`green`,label:`已完成`},blocked:{color:`orange`,label:`阻塞`},deleted:{color:`grey`,label:`已删除`}};function vt({label:e,value:t}){return(0,U.jsxs)(`div`,{className:`chat-usage-cell`,children:[(0,U.jsx)($,{type:`tertiary`,size:`small`,children:e}),(0,U.jsx)(`div`,{className:`chat-usage-value`,children:F(t||0)})]})}function yt({conversationId:e}){let t=R(),[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(null),c=(0,H.useCallback)(async()=>{if(e){a(!0),s(null);try{let t=await L.get(`/conversations/${encodeURIComponent(e)}/token-usage`,{days:365,limit:200});r(t)}catch(e){s(e),r(null)}finally{a(!1)}}},[e]);(0,H.useEffect)(()=>{c()},[c]);let l=n?.summary||{},d=Array.isArray(n?.byModel)?n.byModel:[],p=Array.isArray(n?.recent)?n.recent:[],m=[{title:t(`chat.usageModel`,null,`模型`),dataIndex:`key`,render:e=>(0,U.jsx)($,{size:`small`,children:e||`—`})},{title:t(`chat.usageCalls`,null,`调用`),dataIndex:`modelCalls`,width:80,render:e=>F(e||0)},{title:t(`chat.usagePrompt`,null,`输入`),dataIndex:`promptTokens`,width:100,render:e=>F(e||0)},{title:t(`chat.usageCompletion`,null,`输出`),dataIndex:`completionTokens`,width:100,render:e=>F(e||0)},{title:t(`chat.usageTotal`,null,`合计`),dataIndex:`totalTokens`,width:100,render:e=>(0,U.jsx)($,{strong:!0,children:F(e||0)})}],h=[{title:t(`chat.usageTime`,null,`时间`),dataIndex:`createdAt`,render:e=>(0,U.jsx)($,{size:`small`,children:I(e)})},{title:t(`chat.usageModel`,null,`模型`),dataIndex:`model`},{title:t(`chat.usageOrchestration`,null,`编排`),dataIndex:`orchestration`,render:e=>e?(0,U.jsx)(k,{size:`small`,children:e}):`—`},{title:t(`chat.usageTotal`,null,`合计`),dataIndex:`totalTokens`,width:90,render:e=>F(e||0)}];return(0,U.jsxs)(`div`,{className:`chat-usage`,children:[(0,U.jsxs)(`div`,{className:`chat-usage-toolbar`,children:[(0,U.jsx)($,{type:`tertiary`,size:`small`,children:t(`chat.usageScopeHint`,null,`统计范围为该会话近 365 天的模型调用。`)}),(0,U.jsx)(f,{size:`small`,icon:(0,U.jsx)(ne,{}),onClick:c,loading:i,children:t(`common.refresh`,null,`刷新`)})]}),(0,U.jsx)(B,{error:o,onRetry:c}),i&&!n&&(0,U.jsx)(`div`,{className:`chat-loading`,children:(0,U.jsx)(u,{})}),n&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`chat-usage-grid`,children:[(0,U.jsx)(vt,{label:t(`chat.piUsageModelCalls`,null,`模型调用`),value:l.modelCalls}),(0,U.jsx)(vt,{label:t(`chat.piUsagePromptTokens`,null,`输入 tokens`),value:l.promptTokens}),(0,U.jsx)(vt,{label:t(`chat.piUsageCompletionTokens`,null,`输出 tokens`),value:l.completionTokens}),(0,U.jsx)(vt,{label:t(`chat.piUsageTotalTokens`,null,`总 tokens`),value:l.totalTokens}),(0,U.jsx)(vt,{label:t(`chat.piUsageCachedTokens`,null,`缓存 tokens`),value:l.cachedTokens}),(0,U.jsx)(vt,{label:t(`chat.piUsageReasoningTokens`,null,`推理 tokens`),value:l.reasoningTokens})]}),(0,U.jsx)($,{strong:!0,className:`chat-sheet-subtitle`,children:t(`chat.usageByModel`,null,`按模型`)}),(0,U.jsx)(j,{size:`small`,rowKey:`key`,columns:m,dataSource:d,pagination:!1,empty:(0,U.jsx)(se,{title:t(`common.noData`,null,`暂无数据`),description:null,style:{padding:16}})}),(0,U.jsx)($,{strong:!0,className:`chat-sheet-subtitle`,children:t(`chat.usageRecent`,null,`最近调用`)}),(0,U.jsx)(j,{size:`small`,rowKey:(e,t)=>`${e.createdAt||``}-${t}`,columns:h,dataSource:p,pagination:{pageSize:8},empty:(0,U.jsx)(se,{title:t(`common.noData`,null,`暂无数据`),description:null,style:{padding:16}})})]})]})}function bt({visible:e,onClose:t,conversationId:n}){let r=R();return(0,U.jsx)(w,{title:r(`chat.tokenUsage`,null,`Token 用量`),visible:e,onCancel:t,width:680,placement:`right`,children:(0,U.jsx)(yt,{conversationId:n})})}function xt({plan:e,loading:t,onRefresh:n}){let r=R(),i=Array.isArray(e?.tasks)?e.tasks.filter(e=>String(e.status||``).toLowerCase()!==`deleted`):[],a=Number(e?.total)||i.length,o=Number(e?.completed)||i.filter(e=>e.status===`completed`).length,s=a?Math.round(o/a*100):0;return(0,U.jsxs)(`div`,{className:`chat-plan`,children:[(0,U.jsxs)(`div`,{className:`chat-usage-toolbar`,children:[(0,U.jsx)($,{type:`tertiary`,size:`small`,children:e?.running?r(`chat.planRunning`,null,`任务执行中`):r(`chat.planIdle`,null,`当前没有运行中的任务`)}),(0,U.jsx)(f,{size:`small`,icon:(0,U.jsx)(ne,{}),onClick:n,loading:t,children:r(`common.refresh`,null,`刷新`)})]}),(0,U.jsx)(re,{percent:s,showInfo:!0}),(0,U.jsx)($,{type:`tertiary`,size:`small`,children:r(`chat.planSummary`,null,`共 {{total}} 项,已完成 {{done}} 项`,{total:a,done:o})}),!i.length&&(0,U.jsx)(se,{title:r(`chat.planEmpty`,null,`暂无计划任务`),description:r(`chat.planEmptyHint`,null,`代理调用任务工具后,这里会显示任务看板。`),style:{padding:24}}),(0,U.jsx)(`div`,{className:`chat-plan-list`,children:i.map((e,t)=>{let n=String(e.status||`pending`).toLowerCase(),r=_t[n]||_t.pending;return(0,U.jsxs)(`div`,{className:`chat-plan-item ${n===`in_progress`?`is-active`:``}`,children:[(0,U.jsxs)(`div`,{className:`chat-plan-item-head`,children:[(0,U.jsx)(`span`,{className:`chat-plan-index`,children:t+1}),(0,U.jsx)(`span`,{className:`chat-plan-subject`,children:e.subject||e.activeForm||`—`}),(0,U.jsx)(k,{size:`small`,color:r.color,shape:`circle`,children:r.label})]}),e.description&&(0,U.jsx)(`div`,{className:`chat-plan-desc`,children:e.description})]},e.id||t)})})]})}function St({visible:e,onClose:t,plan:n,loading:r,onRefresh:i}){let a=R();return(0,U.jsx)(w,{title:a(`chat.planTasks`,null,`计划任务`),visible:e,onCancel:t,width:560,placement:`right`,children:(0,U.jsx)(xt,{plan:n,loading:r,onRefresh:i})})}function Ct({conversationRef:e,bindConversation:t,requestDetailReload:n,onSettled:r,onHitlEvent:i,onPlanTool:a,t:o}){let[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)([]),p=(0,H.useRef)(null),m=(0,H.useRef)(null),h=(0,H.useRef)(null),g=(0,H.useCallback)((e=!1)=>{let t=()=>{h.current=null,p.current&&c({...p.current})};e?(h.current&&(clearTimeout(h.current),h.current=null),t()):h.current||(h.current=setTimeout(t,80))},[]),_=(0,H.useCallback)(t=>{if(!t||t.markedFinished||m.current!==t)return;t.markedFinished=!0,t.live.status===`streaming`&&(t.live.status=t.live.error?`error`:`done`,t.live.endedAt=Date.now()),g(!0),r?.(),u(!1),f(t.live.events.slice(-80));let i=t.live.conversationId||e.current;i?Promise.resolve(n?.(i,{silent:!0})).then(e=>{m.current===t&&e&&(m.current=null,p.current=null,c(null))}):(m.current=null,p.current=null,c(null))},[e,g,r,n]);return{live:s,sending:l,lastEvents:d,send:(0,H.useCallback)(({message:n,attachments:r,mode:s,projectId:l,aiChannelId:d,reasoning:h,requireHumanApproval:v})=>{let y={live:X({conversationId:e.current}),markedFinished:!1,abort:null};m.current=y,p.current=y.live,c({...y.live}),u(!0),f([]);let b=s!==`single`,x={message:n,conversationId:e.current||``,aiChannelId:d,reasoning:h,requireHumanApproval:v||void 0};!e.current&&l&&(x.projectId=l),b&&(x.orchestration=s),Array.isArray(r)&&r.length&&(x.attachments=r.map(e=>({fileName:e.fileName,mimeType:e.mimeType||``,serverPath:e.serverPath}))),y.abort=xe(b?`/multi-agent/stream`:`/agent/stream`,x,{onEvent(n){if(y.markedFinished||m.current!==y)return;Ge(y.live,n);let r=n?.type;if(r===`conversation`&&n?.data?.conversationId){let r=String(n.data.conversationId);y.live.conversationId=r,e.current!==r&&t?.(r)}(r===`hitl_interrupt`||r===`hitl_resumed`||r===`hitl_rejected`)&&i?.(),(r===`tool_call`||r===`tool_result`)&&Le.has(String(n?.data?.toolName||``).toLowerCase())&&a?.(),r===`done`||r===`error`||r===`cancelled`?_(y):g()},onError(e){y.markedFinished||m.current!==y||(y.live.status=`error`,y.live.error=de(e,o(`chat.streamFailed`,null,`流式连接失败`)),y.live.endedAt=Date.now(),_(y))},onClose(){_(y)}})},[t,e,_,g,i,a,o]),stop:(0,H.useCallback)(async()=>{let t=m.current,r=e.current||t?.live?.conversationId||``;if(r)try{await L.post(`/agent-loop/cancel`,{conversationId:r}),ye(o(`chat.stopRequested`,null,`已请求停止任务`))}catch(e){fe(de(e,o(`chat.stopFailed`,null,`停止请求失败`)))}t?.abort?.(),setTimeout(()=>{r&&e.current===r&&n?.(r,{silent:!0})},900)},[e,n,o]),reset:(0,H.useCallback)(()=>{let e=m.current;e&&!e.markedFinished&&e.abort?.(),m.current=null,p.current=null,h.current&&(clearTimeout(h.current),h.current=null),c(null),u(!1),f([])},[]),isStreaming:(0,H.useCallback)(e=>{let t=m.current;return!!(t&&!t.markedFinished&&e&&t.live.conversationId===e)},[])}}function wt({t:e,conversationRef:t,newProjectId:n,canWrite:r,reloadList:i,requestDetailReload:a,navigate:o,onSelectionCleared:s}){return{createConversation:(0,H.useCallback)(async()=>{if(r)try{let t=(await L.post(`/conversations`,{title:e(`chat.newChat`,null,`新对话`),projectId:n||void 0}))?.id;i(),t&&o({conversation:t}),ye(e(`chat.created`,null,`已创建对话`))}catch(t){z(t,e(`chat.createFailed`,null,`创建对话失败`))}},[r,o,n,i,e]),renameConversation:(0,H.useCallback)(async(n,r)=>{try{await L.put(`/conversations/${encodeURIComponent(n)}`,{title:r}),ye(e(`chat.renamed`,null,`已重命名`)),i(),n===t.current&&a(n,{silent:!0})}catch(t){z(t,e(`chat.renameFailed`,null,`重命名失败`))}},[t,i,a,e]),togglePin:(0,H.useCallback)(async t=>{try{await L.put(`/conversations/${encodeURIComponent(t.id)}/pinned`,{pinned:!t.pinned}),i()}catch(t){z(t,e(`chat.pinFailed`,null,`置顶操作失败`))}},[i,e]),deleteConversation:(0,H.useCallback)(async n=>{try{await L.del(`/conversations/${encodeURIComponent(n.id)}`),ye(e(`chat.deleted`,null,`已删除对话`)),n.id===t.current&&(s(),o({},{replace:!0})),i()}catch(t){z(t,e(`chat.deleteFailed`,null,`删除对话失败`))}},[t,o,s,i,e]),batchDelete:(0,H.useCallback)(async n=>{let r=(await Promise.allSettled(n.map(e=>L.del(`/conversations/${encodeURIComponent(e)}`)))).filter(e=>e.status===`rejected`).length;r?fe(e(`chat.batchDeletePartial`,{failed:r},`有 ${r} 个对话删除失败`)):ye(e(`chat.batchDeleted`,{count:n.length},`已删除 ${n.length} 个对话`)),n.includes(t.current)&&(s(),o({},{replace:!0})),i()},[t,o,s,i,e]),deleteTurn:(0,H.useCallback)(n=>{let r=t.current;r&&n?.id&&be({title:e(`chat.deleteTurnTitle`,null,`删除本轮`),content:e(`chat.deleteTurnConfirm`,null,`将删除该轮提问与全部回答,删除后不可恢复。`),okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{await L.post(`/conversations/${encodeURIComponent(r)}/delete-turn`,{messageId:n.id}),ye(e(`chat.turnDeleted`,null,`已删除该轮`)),await a(r,{silent:!0}),i()}catch(t){z(t,e(`chat.deleteTurnFailed`,null,`删除轮次失败`))}}})},[t,i,a,e])}}var{Text:Tt}=x,Et=20,Dt=`csai-chat-agent-mode`,Ot={tasks:[],total:0,completed:0,activeStep:0,running:!1},kt={conversation:null,messages:[],loading:!1,error:null};function At(e){let[t,n]=(0,H.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(e).matches);return(0,H.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=e=>n(e.matches);return n(t.matches),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}function jt(){let e=R(),{hasPermission:t}=ue(),n=t(`chat:write`),i=t(`agent:execute`),a=t(`chat:delete`),o=t(`tasks:read`),s=t(`tasks:write`),c=t(`hitl:read`),l=t(`hitl:write`),u=t(`config:read`),[d,p]=r(),m=d.get(`conversation`)||``,h=(0,H.useRef)(m),g=(0,H.useRef)(null);(0,H.useLayoutEffect)(()=>{h.current=m},[m]);let[_,v]=(0,H.useState)(``),y=ge(_,350),[b,x]=(0,H.useState)(``),[ee,S]=(0,H.useState)(1),[C,te]=(0,H.useState)(``),[T,E]=he(Dt,`single`),D=lt.includes(T)?T:`single`,O=Me(u),[ne,k]=(0,H.useState)(!1),[j,M]=(0,H.useState)(!1),[N,ie]=(0,H.useState)(kt),[ae,oe]=(0,H.useState)(()=>new Map),{draft:se=``,attachments:ce=[]}=ae.get(m)||{},P=(0,H.useCallback)((e,t)=>{oe(n=>{let r=new Map(n);return r.set(e,t(n.get(e)||{})),r})},[]),le=e=>P(m,t=>({...t,draft:e})),[F,I]=(0,H.useState)(null),de=c&&F?.id===m?F.items:[],[me,B]=(0,H.useState)(``),[V,ve]=(0,H.useState)(Ot),[be,xe]=(0,H.useState)(!1),[Se,Ce]=(0,H.useState)(!1),[we,Te]=(0,H.useState)(!1),[Ee,De]=(0,H.useState)(!1),ke=At(`(max-width: 900px)`),Ae=(0,H.useRef)(0),je=(0,H.useRef)(0),Ne=(0,H.useRef)(0),W=pe(async()=>{let e=await L.get(`/agent-loop/tasks`);return{id:m,running:Array.isArray(e?.tasks)&&e.tasks.some(e=>e.conversationId===m)}},[m,o],{skip:!m||!o}),G=o&&W.data?.id===m&&W.data.running,Fe=!!(o&&m&&W.data?.id!==m&&!W.error),Le=(0,H.useRef)(null),K=pe(()=>L.get(`/conversations`,{limit:Et,offset:(ee-1)*Et,search:y||void 0,project_id:b||void 0}),[ee,y,b]),Re=(0,H.useRef)(K.reload);(0,H.useEffect)(()=>{Re.current=K.reload},[K.reload]);let ze=pe(()=>L.get(`/projects`,{limit:200}),[]),q=(0,H.useMemo)(()=>Array.isArray(ze.data?.projects)?ze.data.projects:[],[ze.data]),Be=Array.isArray(K.data?.conversations)?K.data.conversations:[],J=(0,H.useCallback)(async(e,{silent:t=!1}={})=>{let n=++Ae.current;if(!e)return ie(kt),null;t||ie(e=>({...e,loading:!0,error:null}));try{let t=await L.get(`/conversations/${encodeURIComponent(e)}`,{include_process_details:1});return n!==Ae.current||h.current!==e?null:(ie({conversation:t||null,messages:Array.isArray(t?.messages)?t.messages:[],loading:!1,error:null}),t)}catch(t){return n===Ae.current&&h.current===e&&ie(e=>({...e,loading:!1,error:t})),null}},[]),Y=(0,H.useCallback)(async()=>{let e=h.current,t=++je.current;if(e&&c)try{let n=await L.get(`/hitl/pending`,{conversationId:e,pageSize:50});if(t!==je.current||h.current!==e)return;let r=(Array.isArray(n?.items)?n.items:[]).filter(t=>!t.conversationId||t.conversationId===e);I({id:e,items:r})}catch{}},[c]),X=(0,H.useCallback)(async()=>{let e=h.current;if(!e){ve(Ot);return}let t=++Ne.current;xe(!0);try{let n=await L.get(`/conversations/${encodeURIComponent(e)}/plan-tasks`);t===Ne.current&&h.current===e&&ve(n&&typeof n==`object`?n:Ot)}catch{}finally{t===Ne.current&&h.current===e&&xe(!1)}},[]),Z=Ct({conversationRef:h,bindConversation:(0,H.useCallback)(e=>{M(!1),g.current=e,h.current=e,p({conversation:e},{replace:!0}),Re.current?.({silent:!0})},[p]),requestDetailReload:J,onSettled:(0,H.useCallback)(()=>{Re.current?.({silent:!0}),Y(),X()},[Y,X]),onHitlEvent:Y,onPlanTool:X,t:e}),{live:Ve,sending:Q,lastEvents:He,reset:Ue,isStreaming:We}=Z;(0,H.useEffect)(()=>{let e=m&&g.current===m;g.current=null,e||We(m)||(Ue(),Ae.current++,je.current++,Ne.current++,ie(kt),I(null),B(``),ve(Ot),xe(!1),Te(!1),m&&(J(m),Y(),X()))},[m,We,Ue,J,Y,X]),_e(()=>{Y(),X(),G&&(W.reload({silent:!0}),!Q&&h.current&&J(h.current,{silent:!0}))},Q||G?4e3:0),(0,H.useEffect)(()=>{Le.current===m&&!G&&(J(m,{silent:!0}),Re.current?.({silent:!0})),Le.current=G?m:null},[G,m,J]);let Ge=async()=>{s&&(await Z.stop(),W.reload({silent:!0}))},Ke=(0,H.useCallback)(e=>{e&&(e!==h.current&&p({conversation:e}),De(!1))},[p]),{createConversation:qe,renameConversation:Je,togglePin:Ye,deleteConversation:Xe,batchDelete:Ze,deleteTurn:Qe}=wt({t:e,conversationRef:h,newProjectId:C,canWrite:n,reloadList:(0,H.useCallback)(()=>{Re.current?.({silent:!0})},[]),requestDetailReload:J,navigate:p,onSelectionCleared:(0,H.useCallback)(()=>ie(kt),[])}),$e=(0,H.useCallback)(async(t,n,r)=>{let i=h.current;if(l&&t?.interruptId&&F?.id===i&&F.items.some(e=>String(e.id||e.interruptId)===t.interruptId)){B(t.interruptId);try{await L.post(`/hitl/decision`,{interruptId:t.interruptId,decision:n,comment:r||``}),ye(n===`approve`?e(`chat.hitlApproved`,null,`已批准本次调用`):e(`chat.hitlRejected`,null,`已拒绝本次调用`)),I(e=>e?.id===i?{id:i,items:e.items.filter(e=>String(e.id||e.interruptId)!==t.interruptId)}:e)}catch(t){z(t,e(`chat.hitlDecisionFailed`,null,`提交审批失败`))}finally{h.current===i&&(B(``),Y())}}},[F,l,Y,e]),et=(0,H.useCallback)(async t=>{let n=h.current;if(l&&t?.interruptId&&F?.id===n&&F.items.some(e=>String(e.id||e.interruptId)===t.interruptId)){B(t.interruptId);try{await L.post(`/hitl/dismiss`,{interruptId:t.interruptId}),ye(e(`chat.hitlDismissed`,null,`已忽略该审批`)),I(e=>e?.id===n?{id:n,items:e.items.filter(e=>String(e.id||e.interruptId)!==t.interruptId)}:e)}catch(t){z(t,e(`chat.hitlDismissFailed`,null,`忽略审批失败`))}finally{h.current===n&&(B(``),Y())}}},[F,l,Y,e]),tt=(0,H.useCallback)(async t=>{let n=h.current,r=e=>P(n,t=>({...t,attachments:e(t.attachments||[])})),i=t.map((e,t)=>({id:`att-${Date.now()}-${t}`,fileName:e.name,mimeType:e.type||``,serverPath:``,uploading:!0,error:!1}));r(e=>[...e,...i]),await Promise.all(i.map(async(i,a)=>{let o=new FormData;o.append(`file`,t[a]),n&&o.append(`conversationId`,n);try{let e=await L.post(`/chat-uploads`,o),t=String(e?.absolutePath||``).trim();if(!t)throw Error(`服务端未返回文件路径`);r(e=>e.map(e=>e.id===i.id?{...e,serverPath:t,uploading:!1,error:!1}:e))}catch(t){r(e=>e.map(e=>e.id===i.id?{...e,uploading:!1,error:!0}:e)),z(t,e(`chat.attachmentUploadFailed`,{name:i.fileName},`附件 ${i.fileName} 上传失败`))}}))},[P,e]),nt=(0,H.useCallback)(e=>{P(m,t=>({...t,attachments:(t.attachments||[]).filter(t=>t.id!==e)}))},[m,P]),rt=(0,H.useCallback)(()=>{if(!n||!i||Q||G||Fe||O.waitingForChannel)return;let t=se.trim();if(!t&&!ce.length){fe(e(`chat.emptyMessage`,null,`请输入内容或添加附件`));return}if(ce.some(e=>e.uploading)){fe(e(`chat.waitingAttachmentsUpload`,null,`附件仍在上传,请稍候`));return}let r=ce.filter(e=>e.serverPath&&!e.error);if(ce.length&&r.length!==ce.length){fe(e(`chat.attachmentsUploadIncomplete`,null,`存在上传失败的附件,请移除后再发送`));return}let a=t||e(`chat.filePrompt`,null,`请解析我上传的附件。`),o=r.length?`${a}\n${r.map(e=>`📎 ${e.fileName}`).join(`
`)}`:a;ie(e=>({...e,messages:[...e.messages||[],{id:`local-${Date.now()}`,role:`user`,content:o,createdAt:new Date().toISOString()}]})),Ue(),P(m,()=>({draft:``,attachments:[]})),Z.send({message:a,attachments:r,mode:D,projectId:C,...O.request,requireHumanApproval:!m&&j})},[ce,G,n,i,Fe,m,se,j,D,O,C,Ue,Z,Q,e,P]),it=N.conversation,at=(0,U.jsx)(Ie,{items:Be,total:K.data?.total||0,loading:K.loading,error:K.error,onRetry:()=>K.reload(),search:_,onSearch:e=>{v(e),S(1)},projectId:b,onProjectChange:e=>{x(e||``),S(1)},projects:q,page:ee,pageSize:Et,onPageChange:S,selectedId:m,onSelect:Ke,onCreate:qe,onRename:Je,onPin:Ye,onDelete:Xe,onBatchDelete:Ze,canWrite:n,canDelete:a});return(0,U.jsxs)(`div`,{className:`chat-page`,children:[!ke&&(0,U.jsx)(`aside`,{className:`chat-sidebar`,children:at}),(0,U.jsxs)(`section`,{className:`chat-main`,children:[(0,U.jsx)(Oe,{conversation:it,mode:D,hitlCount:de.length,conversationId:m,plan:V,narrow:ke,onToggleSidebar:()=>De(!0),onOpenUsage:()=>Ce(!0),onOpenPlan:()=>{X(),Te(!0)},onRefresh:()=>{Re.current?.(),m&&J(m),Y(),X()}}),(0,U.jsxs)(`div`,{className:`chat-panel`,children:[(0,U.jsx)(st,{conversationId:m,messages:N.messages,live:Ve,loading:N.loading||!(!m||N.conversation||N.error),error:N.error,onRetry:()=>m?J(m):null,canDelete:a,onDeleteTurn:Qe}),V.running&&V.total>0&&(0,U.jsxs)(`div`,{className:`chat-plan-strip`,children:[(0,U.jsx)(Tt,{size:`small`,children:e(`chat.planTasks`,null,`计划任务`)}),(0,U.jsx)(re,{percent:Math.round(Number(V.completed||0)/Math.max(1,Number(V.total))*100),showInfo:!1,size:`small`,className:`chat-plan-strip-bar`}),(0,U.jsxs)(Tt,{size:`small`,type:`tertiary`,children:[V.completed,`/`,V.total,V.activeStep?` · ${e(`chat.planStep`,{step:V.activeStep},`第 ${V.activeStep} 步`)}`:``]}),(0,U.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>{X(),Te(!0)},children:e(`chat.planDetails`,null,`详情`)})]}),He.length>0&&!Ve&&(0,U.jsx)(A,{className:`chat-events-strip`,children:(0,U.jsx)(A.Panel,{itemKey:`1`,header:`${e(`chat.rawEvents`,null,`本轮原始事件`)} · ${He.length}`,children:(0,U.jsx)(`pre`,{className:`chat-pre`,children:He.map((e,t)=>`${t+1}. ${JSON.stringify(e)}`).join(`
`)})})}),(0,U.jsx)(gt,{items:de,readOnly:!l,busyId:me,onRefresh:Y,onDecide:$e,onDismiss:et}),(0,U.jsx)(ut,{value:se,onChange:le,onSend:rt,onStop:Ge,canStop:s,sending:Q||G,checkingRun:Fe||O.waitingForChannel,canWrite:n,canExecute:i,mode:D,onModeChange:e=>E(lt.includes(e)?e:`single`),onOpenSettings:u||c||n&&i?()=>k(!0):void 0,projectId:C,onProjectChange:e=>te(e||``),projects:q,showProjectSelect:!m,attachments:ce,onPickFiles:tt,onRemoveAttachment:nt,uploading:ce.filter(e=>e.uploading).length})]})]}),ne&&(0,U.jsx)(Pe,{onClose:()=>k(!1),narrow:ke,busy:Q||G||Fe||!(n&&i),canReadConfig:u,canReadHitl:c,canEnableHitl:l,model:O,conversationId:m,draftApproval:!m&&j,onEnableDraftApproval:()=>M(!0)},m),(0,U.jsx)(w,{visible:ke&&Ee,placement:`left`,width:300,onCancel:()=>De(!1),title:e(`chat.conversations`,null,`会话列表`),bodyStyle:{padding:0},children:at}),(0,U.jsx)(bt,{visible:Se,onClose:()=>Ce(!1),conversationId:m}),(0,U.jsx)(St,{visible:we,onClose:()=>Te(!1),plan:V,loading:be,onRefresh:X})]})}export{jt as default};
\ No newline at end of file
diff --git a/web/static/app/assets/chat-files-CTTAptxF.js b/web/static/app/assets/chat-files-BYjs9VE-.js
similarity index 99%
rename from web/static/app/assets/chat-files-CTTAptxF.js
rename to web/static/app/assets/chat-files-BYjs9VE-.js
index 9d17c69a..b2a6b745 100644
--- a/web/static/app/assets/chat-files-CTTAptxF.js
+++ b/web/static/app/assets/chat-files-BYjs9VE-.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{C as r,H as i,I as a,P as o,U as s,V as c,_ as l,d as u,it as d,j as f,ot as p,q as m,rt as h}from"./semi-DNxeCrHm.js";import{E as g,F as ee,I as _,L as v,P as y,S as te,T as b,a as ne,b as x,l as S,m as re,n as ie,o as C,p as ae,s as oe,x as w,y as se}from"./index-BoFwOeaz.js";var T=e(t(),1);function ce(e){return _.get(`/chat-uploads`,e)}function le(e,{relativeDir:t}={}){let n=new FormData;return n.append(`file`,e,e.name),t&&n.append(`relativeDir`,t),_.post(`/chat-uploads`,n)}function ue(e,t){return _.post(`/chat-uploads/mkdir`,{parent:e||``,name:t})}function de(e){return _.del(`/chat-uploads`,{body:{path:e}})}function E(e){return _.get(`/chat-uploads/content`,{path:e})}function fe(e,t=`file`){return _.get(`/chat-uploads/path`,{path:e,kind:t})}function pe(e){return v(`/chat-uploads/export`,{query:e,filename:`chat-files-export.zip`})}function D(e,t){return v(`/chat-uploads/download`,{query:{path:e},filename:t})}async function me(e){let t=await(await _.raw(`/chat-uploads/download`,{query:{path:e},timeout:12e4})).blob();return{url:URL.createObjectURL(t),type:t.type,size:t.size}}var O=e(n(),1),{Text:k}=s,A=/\.(png|jpe?g|gif|webp|bmp|svg|ico)$/i,j=/\.(txt|log|md|markdown|json|ya?ml|csv|tsv|xml|html?|css|jsx?|tsx?|py|go|java|c|h|cpp|sh|sql|ini|conf|toml|env|pem)$/i;function M(e){let t=e?.name||``;return A.test(t)?`image`:j.test(t)?`text`:`binary`}function he({item:e,onClose:t}){let n=y(),[r,o]=(0,T.useState)(!1),[s,c]=(0,T.useState)(null),[l,d]=(0,T.useState)(``),[f,p]=(0,T.useState)(``),[m,h]=(0,T.useState)(`text`);return(0,T.useEffect)(()=>{let t=``,n=!1;if(!e)return d(``),p(``),c(null),()=>{};let r=M(e);return h(r),o(!0),c(null),d(``),p(``),(async()=>{try{if(r===`image`){let r=await me(e.relativePath);if(n){URL.revokeObjectURL(r.url);return}t=r.url,p(r.url)}else if(r===`text`){let t=await E(e.relativePath);if(n)return;d(t?.content??``)}}catch(e){n||(c(e),r===`text`&&h(`binary`))}finally{n||o(!1)}})(),()=>{n=!0,t&&URL.revokeObjectURL(t)}},[e]),(0,O.jsx)(u,{visible:!!e,title:e?.name||n(`chatFilesPage.previewTitle`,null,`文件预览`),width:720,onCancel:t,footer:(0,O.jsx)(a,{onClick:async()=>{if(e)try{await D(e.relativePath,e.name)}catch(e){x(e,n(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},children:n(`chatFilesPage.download`,null,`下载`)}),children:e&&(0,O.jsxs)(`div`,{className:`chat-files-preview`,children:[(0,O.jsxs)(`div`,{className:`chat-files-preview-meta`,children:[(0,O.jsx)(k,{type:`tertiary`,size:`small`,children:b(e.size)}),(0,O.jsx)(k,{type:`tertiary`,size:`small`,className:`chat-files-mono`,children:e.relativePath}),(0,O.jsx)(C,{text:e.relativePath,label:n(`chatFilesPage.copyPath`,null,`复制路径`),size:`small`})]}),(0,O.jsx)(S,{error:m===`binary`?null:s}),r&&(0,O.jsx)(`div`,{className:`chat-files-preview-loading`,children:(0,O.jsx)(i,{})}),!r&&m===`image`&&f&&(0,O.jsx)(`img`,{className:`chat-files-preview-image`,src:f,alt:e.name}),!r&&m===`text`&&(0,O.jsx)(`pre`,{className:`chat-files-preview-text`,children:l}),!r&&m===`binary`&&(0,O.jsx)(k,{type:`tertiary`,children:n(`chatFilesPage.editBinaryHint`,null,`图片、压缩包等二进制文件无法在此以文本方式编辑,请使用「下载」后在本地查看或处理。`)})]})})}var{Text:N}=s,ge=[{value:`all`,label:`全部`},{value:`upload`,label:`对话附件`},{value:`reduction`,label:`工具输出`},{value:`workspace`,label:`工作目录`},{value:`conversation_artifact`,label:`会话产物`}],_e={upload:`对话附件`,reduction:`工具输出`,workspace:`工作目录`,conversation_artifact:`会话产物`};function P(e){let t=String(e||``).split(`/`);return t.pop(),t.join(`/`)}function F(e){let t=String(e||``).split(`/`);return t[t.length-1]||e}function I(){let e=y(),{hasPermission:t}=ee(),n=t(`files:write`),i=t(`files:delete`)||n,s=(0,T.useRef)(null),[u,_]=(0,T.useState)(`list`),[v,C]=(0,T.useState)(``),[E,me]=(0,T.useState)(``),[k,A]=(0,T.useState)(`all`),[j,M]=(0,T.useState)(``),[I,L]=(0,T.useState)(``),[R,z]=(0,T.useState)(1),[B,ve]=(0,T.useState)(20),[ye,V]=(0,T.useState)(null),[H,U]=(0,T.useState)(null),[be,W]=(0,T.useState)(!1),G=ie(j,300),K=(0,T.useMemo)(()=>{let e={conversation:v.trim()||void 0,project:E.trim()||void 0,source:k===`all`?void 0:k,search:G.trim()||void 0};return u===`browse`?{...e,page:1,pageSize:`all`}:{...e,page:R,pageSize:B}},[u,v,E,k,G,R,B]),{data:q,loading:J,error:xe,reload:Y}=ne(()=>ce(K),[K]),X=Array.isArray(q?.files)?q.files:[],Z=Array.isArray(q?.folders)?q.folders:[],Q=Number(q?.total??X.length),Se=(0,T.useMemo)(()=>u===`browse`?{folders:Z.filter(e=>P(e)===I),files:X.filter(e=>P(e.relativePath)===I)}:{folders:[],files:X},[u,Z,X,I]),Ce=(0,T.useMemo)(()=>{let t=I?I.split(`/`):[],n=[{label:e(`chatFilesPage.browseRoot`,null,`文件`),path:``}];return t.forEach((e,r)=>n.push({label:e,path:t.slice(0,r+1).join(`/`)})),n},[I,e]),we=async t=>{try{let n=await fe(t.relativePath,`file`);await navigator.clipboard.writeText(n?.absolutePath||t.relativePath),w(e(`chatFilesPage.pathCopied`,null,`路径已复制,可到对话中粘贴使用`))}catch(t){x(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Te=async t=>{try{await D(t.relativePath,t.name)}catch(t){x(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Ee=t=>{se({title:e(`chatFilesPage.confirmDelete`,null,`确定删除该文件?`),content:t.relativePath,onOk:async()=>{try{await de(t.relativePath),w(e(`chatFilesPage.deleted`,null,`已删除`)),Y()}catch(e){x(e)}}})},De=()=>s.current?.click(),Oe=async t=>{let n=Array.from(t.target.files||[]);if(t.target.value=``,n.length){W(!0);try{for(let e of n)await le(e,{relativeDir:u===`browse`?I:``});w(e(`chatFilesPage.uploadOkHint`,null,`上传成功。点击「复制路径」可复制绝对路径到剪贴板。`)),Y()}catch(t){x(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}finally{W(!1)}}},ke=async()=>{let t=String(H?.name||``).trim();if(!t||t.includes(`/`)||t.includes(`\\`)||t===`.`||t===`..`)te(e(`chatFilesPage.mkdirInvalidName`,null,`名称无效:不能为空,且不能包含 /、\\ 或 . / ..`));else try{await ue(u===`browse`?I:``,t),w(e(`chatFilesPage.mkdirOk`,null,`文件夹已创建`)),U(null),Y()}catch(t){x(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Ae=async()=>{try{await pe({conversation:v.trim()||void 0,project:E.trim()||void 0,source:k===`all`?void 0:k,search:G.trim()||void 0}),w(e(`chatFilesPage.exportStarted`,null,`已开始导出当前文件`))}catch(t){x(t,e(`chatFilesPage.exportEmpty`,null,`没有可导出的文件`))}},je=[{title:e(`chatFilesPage.colName`,null,`文件名`),dataIndex:`name`,render:(e,t)=>(0,O.jsx)(`button`,{type:`button`,className:`chat-files-name`,onClick:()=>V(t),title:t.relativePath,children:e||F(t.relativePath)})},{title:e(`chatFilesPage.sourceFilter`,null,`来源`),dataIndex:`source`,width:110,render:e=>(0,O.jsx)(f,{size:`small`,children:_e[e]||e||`对话附件`})},{title:e(`chatFilesPage.colConversation`,null,`会话`),dataIndex:`conversationTitle`,width:180,render:(e,t)=>(0,O.jsx)(N,{type:`tertiary`,size:`small`,ellipsis:{showTooltip:!0},children:e||t.conversationId||`—`})},{title:e(`chatFilesPage.colSubPath`,null,`路径`),dataIndex:`relativePath`,width:220,render:e=>(0,O.jsx)(`span`,{className:`chat-files-path`,children:e})},{title:e(`chatFilesPage.colSize`,null,`大小`),dataIndex:`size`,width:100,render:e=>b(e)},{title:e(`chatFilesPage.colModified`,null,`修改时间`),dataIndex:`modifiedUnix`,width:170,render:e=>g(e?e*1e3:null)},{title:e(`chatFilesPage.colActions`,null,`操作`),dataIndex:`actions`,width:260,render:(t,n)=>(0,O.jsxs)(o,{spacing:4,wrap:!0,children:[(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>V(n),children:e(`chatFilesPage.preview`,null,`预览`)}),(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>we(n),children:e(`chatFilesPage.copyPath`,null,`复制路径`)}),(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>Te(n),children:e(`chatFilesPage.download`,null,`下载`)}),(0,O.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,disabled:!i,onClick:()=>Ee(n),children:e(`chatFilesPage.delete`,null,`删除`)})]})}],Me=[{title:e(`chatFilesPage.colName`,null,`文件名`),dataIndex:`name`,render:(e,t)=>t.isDir?(0,O.jsxs)(`button`,{type:`button`,className:`chat-files-name is-dir`,onClick:()=>L(t.path),children:[e,`/`]}):(0,O.jsx)(`button`,{type:`button`,className:`chat-files-name`,onClick:()=>V(t),title:t.relativePath,children:e})},{title:e(`chatFilesPage.colSize`,null,`大小`),dataIndex:`size`,width:110,render:e=>e===void 0?`—`:b(e)},{title:e(`chatFilesPage.colModified`,null,`修改时间`),dataIndex:`modifiedUnix`,width:180,render:e=>e?g(e*1e3):`—`},{title:e(`chatFilesPage.colActions`,null,`操作`),dataIndex:`actions`,width:240,render:(t,n)=>n.isDir?(0,O.jsx)(o,{spacing:4,children:(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>L(n.path),children:e(`chatFilesPage.enterFolder`,null,`进入`)})}):(0,O.jsxs)(o,{spacing:4,wrap:!0,children:[(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>V(n),children:e(`chatFilesPage.preview`,null,`预览`)}),(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>we(n),children:e(`chatFilesPage.copyPath`,null,`复制路径`)}),(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>Te(n),children:e(`chatFilesPage.download`,null,`下载`)}),(0,O.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,disabled:!i,onClick:()=>Ee(n),children:e(`chatFilesPage.delete`,null,`删除`)})]})}],Ne=[...Se.folders.map(e=>({rowKey:`dir:${e}`,isDir:!0,path:e,name:F(e)})),...Se.files.map(e=>({...e,rowKey:e.relativePath}))],$=u===`browse`?Ne:X;return(0,O.jsxs)(`div`,{className:`chat-files-page`,id:`page-chat-files`,children:[(0,O.jsx)(ae,{title:e(`chatFilesPage.title`,null,`文件管理`),description:e(`chatFilesPage.intro`,null,`管理在对话中上传的文件,可复制路径供 AI 引用`),extra:[(0,O.jsx)(a,{onClick:Ae,children:e(`chatFilesPage.export`,null,`导出当前结果`)},`export`),(0,O.jsx)(a,{icon:(0,O.jsx)(p,{}),disabled:!n,onClick:()=>U({name:``}),children:e(`chatFilesPage.newFolderButton`,null,`新建文件夹`)},`mkdir`),(0,O.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,O.jsx)(m,{}),loading:be,disabled:!n,onClick:De,children:e(`chatFilesPage.upload`,null,`上传文件`)},`upload`),(0,O.jsx)(a,{icon:(0,O.jsx)(d,{}),onClick:Y,loading:J,children:e(`common.refresh`,null,`刷新`)},`refresh`)]}),(0,O.jsx)(`input`,{ref:s,type:`file`,multiple:!0,hidden:!0,onChange:Oe}),(0,O.jsx)(S,{error:xe,onRetry:Y}),(0,O.jsx)(re,{title:e(`chatFilesPage.filterTitle`,null,`筛选`),children:(0,O.jsxs)(`div`,{className:`chat-files-fields`,children:[(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.conversationFilter`,null,`会话 ID`)}),(0,O.jsx)(c,{value:v,onChange:e=>{C(e),z(1)},placeholder:e(`chatFilesPage.conversationPlaceholder`,null,`留空表示全部`),style:{width:200}})]}),(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.projectFilter`,null,`项目 ID`)}),(0,O.jsx)(c,{value:E,onChange:e=>{me(e),z(1)},placeholder:e(`chatFilesPage.projectPlaceholder`,null,`留空表示全部`),style:{width:200}})]}),(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.searchName`,null,`文件名`)}),(0,O.jsx)(c,{value:j,onChange:e=>{M(e),z(1)},prefix:(0,O.jsx)(h,{}),placeholder:e(`chatFilesPage.searchNamePlaceholder`,null,`筛选文件名`),style:{width:200}})]}),(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.sourceFilter`,null,`来源`)}),(0,O.jsx)(l,{value:k,onChange:e=>{A(e||`all`),z(1)},optionList:ge,style:{width:160}})]}),(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.groupBy`,null,`分组方式`)}),(0,O.jsx)(l,{value:u,onChange:e=>{_(e||`list`),z(1),L(``)},optionList:[{value:`list`,label:e(`chatFilesPage.groupNone`,null,`不分组(平铺)`)},{value:`browse`,label:e(`chatFilesPage.groupByFolder`,null,`按文件夹(路径浏览)`)}],style:{width:200}})]})]})}),u===`browse`&&(0,O.jsx)(`nav`,{className:`chat-files-breadcrumb`,"aria-label":`breadcrumb`,children:Ce.map((e,t)=>(0,O.jsxs)(`span`,{className:`chat-files-breadcrumb-item`,children:[t>0&&(0,O.jsx)(`span`,{className:`chat-files-breadcrumb-sep`,children:`/`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>L(e.path),children:e.label})]},e.path||`root`))}),(0,O.jsx)(re,{title:u===`browse`?e(`chatFilesPage.browseRoot`,null,`文件`):e(`chatFilesPage.listTitle`,null,`附件列表`),extra:(0,O.jsx)(N,{type:`tertiary`,size:`small`,children:e(`chatFilesPage.paginationInfo`,null,`显示 {{start}}-{{end}} / {{total}} 个文件`).replace(`{{start}}`,$.length?`1`:`0`).replace(`{{end}}`,String($.length)).replace(`{{total}}`,String(u===`browse`?$.length:Q))}),children:(0,O.jsx)(oe,{columns:u===`browse`?Me:je,dataSource:$,rowKey:e=>e.rowKey||e.relativePath,loading:J,onRefresh:Y,pagination:u!==`browse`&&{currentPage:R,pageSize:B,total:Q,onPageChange:e=>z(e),onPageSizeChange:e=>{ve(e),z(1)}},emptyText:u===`browse`?e(`chatFilesPage.folderEmpty`,null,`此文件夹为空`):e(`chatFilesPage.empty`,null,`暂无对话附件`)})}),(0,O.jsx)(he,{item:ye,onClose:()=>V(null)}),(0,O.jsxs)(r,{visible:!!H,title:e(`chatFilesPage.newFolderTitle`,null,`新建文件夹`),width:420,onCancel:()=>U(null),onOk:ke,children:[(0,O.jsxs)(N,{type:`tertiary`,size:`small`,children:[e(`chatFilesPage.newFolderLocation`,null,`位置`),`:`,u===`browse`&&I?I:`/`]}),(0,O.jsx)(c,{value:H?.name||``,onChange:e=>U({name:e}),placeholder:e(`chatFilesPage.newFolderNamePlaceholder`,null,`仅名称,不含 /`),style:{marginTop:8}})]})]})}export{I as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{C as r,H as i,I as a,P as o,U as s,V as c,_ as l,d as u,it as d,j as f,ot as p,q as m,rt as h}from"./semi-DNxeCrHm.js";import{E as g,F as ee,I as _,L as v,P as y,S as te,T as b,a as ne,b as x,l as S,m as re,n as ie,o as C,p as ae,s as oe,x as w,y as se}from"./index-smFoxEJu.js";var T=e(t(),1);function ce(e){return _.get(`/chat-uploads`,e)}function le(e,{relativeDir:t}={}){let n=new FormData;return n.append(`file`,e,e.name),t&&n.append(`relativeDir`,t),_.post(`/chat-uploads`,n)}function ue(e,t){return _.post(`/chat-uploads/mkdir`,{parent:e||``,name:t})}function de(e){return _.del(`/chat-uploads`,{body:{path:e}})}function E(e){return _.get(`/chat-uploads/content`,{path:e})}function fe(e,t=`file`){return _.get(`/chat-uploads/path`,{path:e,kind:t})}function pe(e){return v(`/chat-uploads/export`,{query:e,filename:`chat-files-export.zip`})}function D(e,t){return v(`/chat-uploads/download`,{query:{path:e},filename:t})}async function me(e){let t=await(await _.raw(`/chat-uploads/download`,{query:{path:e},timeout:12e4})).blob();return{url:URL.createObjectURL(t),type:t.type,size:t.size}}var O=e(n(),1),{Text:k}=s,A=/\.(png|jpe?g|gif|webp|bmp|svg|ico)$/i,j=/\.(txt|log|md|markdown|json|ya?ml|csv|tsv|xml|html?|css|jsx?|tsx?|py|go|java|c|h|cpp|sh|sql|ini|conf|toml|env|pem)$/i;function M(e){let t=e?.name||``;return A.test(t)?`image`:j.test(t)?`text`:`binary`}function he({item:e,onClose:t}){let n=y(),[r,o]=(0,T.useState)(!1),[s,c]=(0,T.useState)(null),[l,d]=(0,T.useState)(``),[f,p]=(0,T.useState)(``),[m,h]=(0,T.useState)(`text`);return(0,T.useEffect)(()=>{let t=``,n=!1;if(!e)return d(``),p(``),c(null),()=>{};let r=M(e);return h(r),o(!0),c(null),d(``),p(``),(async()=>{try{if(r===`image`){let r=await me(e.relativePath);if(n){URL.revokeObjectURL(r.url);return}t=r.url,p(r.url)}else if(r===`text`){let t=await E(e.relativePath);if(n)return;d(t?.content??``)}}catch(e){n||(c(e),r===`text`&&h(`binary`))}finally{n||o(!1)}})(),()=>{n=!0,t&&URL.revokeObjectURL(t)}},[e]),(0,O.jsx)(u,{visible:!!e,title:e?.name||n(`chatFilesPage.previewTitle`,null,`文件预览`),width:720,onCancel:t,footer:(0,O.jsx)(a,{onClick:async()=>{if(e)try{await D(e.relativePath,e.name)}catch(e){x(e,n(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},children:n(`chatFilesPage.download`,null,`下载`)}),children:e&&(0,O.jsxs)(`div`,{className:`chat-files-preview`,children:[(0,O.jsxs)(`div`,{className:`chat-files-preview-meta`,children:[(0,O.jsx)(k,{type:`tertiary`,size:`small`,children:b(e.size)}),(0,O.jsx)(k,{type:`tertiary`,size:`small`,className:`chat-files-mono`,children:e.relativePath}),(0,O.jsx)(C,{text:e.relativePath,label:n(`chatFilesPage.copyPath`,null,`复制路径`),size:`small`})]}),(0,O.jsx)(S,{error:m===`binary`?null:s}),r&&(0,O.jsx)(`div`,{className:`chat-files-preview-loading`,children:(0,O.jsx)(i,{})}),!r&&m===`image`&&f&&(0,O.jsx)(`img`,{className:`chat-files-preview-image`,src:f,alt:e.name}),!r&&m===`text`&&(0,O.jsx)(`pre`,{className:`chat-files-preview-text`,children:l}),!r&&m===`binary`&&(0,O.jsx)(k,{type:`tertiary`,children:n(`chatFilesPage.editBinaryHint`,null,`图片、压缩包等二进制文件无法在此以文本方式编辑,请使用「下载」后在本地查看或处理。`)})]})})}var{Text:N}=s,ge=[{value:`all`,label:`全部`},{value:`upload`,label:`对话附件`},{value:`reduction`,label:`工具输出`},{value:`workspace`,label:`工作目录`},{value:`conversation_artifact`,label:`会话产物`}],_e={upload:`对话附件`,reduction:`工具输出`,workspace:`工作目录`,conversation_artifact:`会话产物`};function P(e){let t=String(e||``).split(`/`);return t.pop(),t.join(`/`)}function F(e){let t=String(e||``).split(`/`);return t[t.length-1]||e}function I(){let e=y(),{hasPermission:t}=ee(),n=t(`files:write`),i=t(`files:delete`)||n,s=(0,T.useRef)(null),[u,_]=(0,T.useState)(`list`),[v,C]=(0,T.useState)(``),[E,me]=(0,T.useState)(``),[k,A]=(0,T.useState)(`all`),[j,M]=(0,T.useState)(``),[I,L]=(0,T.useState)(``),[R,z]=(0,T.useState)(1),[B,ve]=(0,T.useState)(20),[ye,V]=(0,T.useState)(null),[H,U]=(0,T.useState)(null),[be,W]=(0,T.useState)(!1),G=ie(j,300),K=(0,T.useMemo)(()=>{let e={conversation:v.trim()||void 0,project:E.trim()||void 0,source:k===`all`?void 0:k,search:G.trim()||void 0};return u===`browse`?{...e,page:1,pageSize:`all`}:{...e,page:R,pageSize:B}},[u,v,E,k,G,R,B]),{data:q,loading:J,error:xe,reload:Y}=ne(()=>ce(K),[K]),X=Array.isArray(q?.files)?q.files:[],Z=Array.isArray(q?.folders)?q.folders:[],Q=Number(q?.total??X.length),Se=(0,T.useMemo)(()=>u===`browse`?{folders:Z.filter(e=>P(e)===I),files:X.filter(e=>P(e.relativePath)===I)}:{folders:[],files:X},[u,Z,X,I]),Ce=(0,T.useMemo)(()=>{let t=I?I.split(`/`):[],n=[{label:e(`chatFilesPage.browseRoot`,null,`文件`),path:``}];return t.forEach((e,r)=>n.push({label:e,path:t.slice(0,r+1).join(`/`)})),n},[I,e]),we=async t=>{try{let n=await fe(t.relativePath,`file`);await navigator.clipboard.writeText(n?.absolutePath||t.relativePath),w(e(`chatFilesPage.pathCopied`,null,`路径已复制,可到对话中粘贴使用`))}catch(t){x(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Te=async t=>{try{await D(t.relativePath,t.name)}catch(t){x(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Ee=t=>{se({title:e(`chatFilesPage.confirmDelete`,null,`确定删除该文件?`),content:t.relativePath,onOk:async()=>{try{await de(t.relativePath),w(e(`chatFilesPage.deleted`,null,`已删除`)),Y()}catch(e){x(e)}}})},De=()=>s.current?.click(),Oe=async t=>{let n=Array.from(t.target.files||[]);if(t.target.value=``,n.length){W(!0);try{for(let e of n)await le(e,{relativeDir:u===`browse`?I:``});w(e(`chatFilesPage.uploadOkHint`,null,`上传成功。点击「复制路径」可复制绝对路径到剪贴板。`)),Y()}catch(t){x(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}finally{W(!1)}}},ke=async()=>{let t=String(H?.name||``).trim();if(!t||t.includes(`/`)||t.includes(`\\`)||t===`.`||t===`..`)te(e(`chatFilesPage.mkdirInvalidName`,null,`名称无效:不能为空,且不能包含 /、\\ 或 . / ..`));else try{await ue(u===`browse`?I:``,t),w(e(`chatFilesPage.mkdirOk`,null,`文件夹已创建`)),U(null),Y()}catch(t){x(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Ae=async()=>{try{await pe({conversation:v.trim()||void 0,project:E.trim()||void 0,source:k===`all`?void 0:k,search:G.trim()||void 0}),w(e(`chatFilesPage.exportStarted`,null,`已开始导出当前文件`))}catch(t){x(t,e(`chatFilesPage.exportEmpty`,null,`没有可导出的文件`))}},je=[{title:e(`chatFilesPage.colName`,null,`文件名`),dataIndex:`name`,render:(e,t)=>(0,O.jsx)(`button`,{type:`button`,className:`chat-files-name`,onClick:()=>V(t),title:t.relativePath,children:e||F(t.relativePath)})},{title:e(`chatFilesPage.sourceFilter`,null,`来源`),dataIndex:`source`,width:110,render:e=>(0,O.jsx)(f,{size:`small`,children:_e[e]||e||`对话附件`})},{title:e(`chatFilesPage.colConversation`,null,`会话`),dataIndex:`conversationTitle`,width:180,render:(e,t)=>(0,O.jsx)(N,{type:`tertiary`,size:`small`,ellipsis:{showTooltip:!0},children:e||t.conversationId||`—`})},{title:e(`chatFilesPage.colSubPath`,null,`路径`),dataIndex:`relativePath`,width:220,render:e=>(0,O.jsx)(`span`,{className:`chat-files-path`,children:e})},{title:e(`chatFilesPage.colSize`,null,`大小`),dataIndex:`size`,width:100,render:e=>b(e)},{title:e(`chatFilesPage.colModified`,null,`修改时间`),dataIndex:`modifiedUnix`,width:170,render:e=>g(e?e*1e3:null)},{title:e(`chatFilesPage.colActions`,null,`操作`),dataIndex:`actions`,width:260,render:(t,n)=>(0,O.jsxs)(o,{spacing:4,wrap:!0,children:[(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>V(n),children:e(`chatFilesPage.preview`,null,`预览`)}),(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>we(n),children:e(`chatFilesPage.copyPath`,null,`复制路径`)}),(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>Te(n),children:e(`chatFilesPage.download`,null,`下载`)}),(0,O.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,disabled:!i,onClick:()=>Ee(n),children:e(`chatFilesPage.delete`,null,`删除`)})]})}],Me=[{title:e(`chatFilesPage.colName`,null,`文件名`),dataIndex:`name`,render:(e,t)=>t.isDir?(0,O.jsxs)(`button`,{type:`button`,className:`chat-files-name is-dir`,onClick:()=>L(t.path),children:[e,`/`]}):(0,O.jsx)(`button`,{type:`button`,className:`chat-files-name`,onClick:()=>V(t),title:t.relativePath,children:e})},{title:e(`chatFilesPage.colSize`,null,`大小`),dataIndex:`size`,width:110,render:e=>e===void 0?`—`:b(e)},{title:e(`chatFilesPage.colModified`,null,`修改时间`),dataIndex:`modifiedUnix`,width:180,render:e=>e?g(e*1e3):`—`},{title:e(`chatFilesPage.colActions`,null,`操作`),dataIndex:`actions`,width:240,render:(t,n)=>n.isDir?(0,O.jsx)(o,{spacing:4,children:(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>L(n.path),children:e(`chatFilesPage.enterFolder`,null,`进入`)})}):(0,O.jsxs)(o,{spacing:4,wrap:!0,children:[(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>V(n),children:e(`chatFilesPage.preview`,null,`预览`)}),(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>we(n),children:e(`chatFilesPage.copyPath`,null,`复制路径`)}),(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>Te(n),children:e(`chatFilesPage.download`,null,`下载`)}),(0,O.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,disabled:!i,onClick:()=>Ee(n),children:e(`chatFilesPage.delete`,null,`删除`)})]})}],Ne=[...Se.folders.map(e=>({rowKey:`dir:${e}`,isDir:!0,path:e,name:F(e)})),...Se.files.map(e=>({...e,rowKey:e.relativePath}))],$=u===`browse`?Ne:X;return(0,O.jsxs)(`div`,{className:`chat-files-page`,id:`page-chat-files`,children:[(0,O.jsx)(ae,{title:e(`chatFilesPage.title`,null,`文件管理`),description:e(`chatFilesPage.intro`,null,`管理在对话中上传的文件,可复制路径供 AI 引用`),extra:[(0,O.jsx)(a,{onClick:Ae,children:e(`chatFilesPage.export`,null,`导出当前结果`)},`export`),(0,O.jsx)(a,{icon:(0,O.jsx)(p,{}),disabled:!n,onClick:()=>U({name:``}),children:e(`chatFilesPage.newFolderButton`,null,`新建文件夹`)},`mkdir`),(0,O.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,O.jsx)(m,{}),loading:be,disabled:!n,onClick:De,children:e(`chatFilesPage.upload`,null,`上传文件`)},`upload`),(0,O.jsx)(a,{icon:(0,O.jsx)(d,{}),onClick:Y,loading:J,children:e(`common.refresh`,null,`刷新`)},`refresh`)]}),(0,O.jsx)(`input`,{ref:s,type:`file`,multiple:!0,hidden:!0,onChange:Oe}),(0,O.jsx)(S,{error:xe,onRetry:Y}),(0,O.jsx)(re,{title:e(`chatFilesPage.filterTitle`,null,`筛选`),children:(0,O.jsxs)(`div`,{className:`chat-files-fields`,children:[(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.conversationFilter`,null,`会话 ID`)}),(0,O.jsx)(c,{value:v,onChange:e=>{C(e),z(1)},placeholder:e(`chatFilesPage.conversationPlaceholder`,null,`留空表示全部`),style:{width:200}})]}),(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.projectFilter`,null,`项目 ID`)}),(0,O.jsx)(c,{value:E,onChange:e=>{me(e),z(1)},placeholder:e(`chatFilesPage.projectPlaceholder`,null,`留空表示全部`),style:{width:200}})]}),(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.searchName`,null,`文件名`)}),(0,O.jsx)(c,{value:j,onChange:e=>{M(e),z(1)},prefix:(0,O.jsx)(h,{}),placeholder:e(`chatFilesPage.searchNamePlaceholder`,null,`筛选文件名`),style:{width:200}})]}),(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.sourceFilter`,null,`来源`)}),(0,O.jsx)(l,{value:k,onChange:e=>{A(e||`all`),z(1)},optionList:ge,style:{width:160}})]}),(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.groupBy`,null,`分组方式`)}),(0,O.jsx)(l,{value:u,onChange:e=>{_(e||`list`),z(1),L(``)},optionList:[{value:`list`,label:e(`chatFilesPage.groupNone`,null,`不分组(平铺)`)},{value:`browse`,label:e(`chatFilesPage.groupByFolder`,null,`按文件夹(路径浏览)`)}],style:{width:200}})]})]})}),u===`browse`&&(0,O.jsx)(`nav`,{className:`chat-files-breadcrumb`,"aria-label":`breadcrumb`,children:Ce.map((e,t)=>(0,O.jsxs)(`span`,{className:`chat-files-breadcrumb-item`,children:[t>0&&(0,O.jsx)(`span`,{className:`chat-files-breadcrumb-sep`,children:`/`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>L(e.path),children:e.label})]},e.path||`root`))}),(0,O.jsx)(re,{title:u===`browse`?e(`chatFilesPage.browseRoot`,null,`文件`):e(`chatFilesPage.listTitle`,null,`附件列表`),extra:(0,O.jsx)(N,{type:`tertiary`,size:`small`,children:e(`chatFilesPage.paginationInfo`,null,`显示 {{start}}-{{end}} / {{total}} 个文件`).replace(`{{start}}`,$.length?`1`:`0`).replace(`{{end}}`,String($.length)).replace(`{{total}}`,String(u===`browse`?$.length:Q))}),children:(0,O.jsx)(oe,{columns:u===`browse`?Me:je,dataSource:$,rowKey:e=>e.rowKey||e.relativePath,loading:J,onRefresh:Y,pagination:u!==`browse`&&{currentPage:R,pageSize:B,total:Q,onPageChange:e=>z(e),onPageSizeChange:e=>{ve(e),z(1)}},emptyText:u===`browse`?e(`chatFilesPage.folderEmpty`,null,`此文件夹为空`):e(`chatFilesPage.empty`,null,`暂无对话附件`)})}),(0,O.jsx)(he,{item:ye,onClose:()=>V(null)}),(0,O.jsxs)(r,{visible:!!H,title:e(`chatFilesPage.newFolderTitle`,null,`新建文件夹`),width:420,onCancel:()=>U(null),onOk:ke,children:[(0,O.jsxs)(N,{type:`tertiary`,size:`small`,children:[e(`chatFilesPage.newFolderLocation`,null,`位置`),`:`,u===`browse`&&I?I:`/`]}),(0,O.jsx)(c,{value:H?.name||``,onChange:e=>U({name:e}),placeholder:e(`chatFilesPage.newFolderNamePlaceholder`,null,`仅名称,不含 /`),style:{marginTop:8}})]})]})}export{I as default};
\ No newline at end of file
diff --git a/web/static/app/assets/dashboard-D1HqCY0Z.js b/web/static/app/assets/dashboard-Bc2usnZH.js
similarity index 99%
rename from web/static/app/assets/dashboard-D1HqCY0Z.js
rename to web/static/app/assets/dashboard-Bc2usnZH.js
index bca062f8..54f19d65 100644
--- a/web/static/app/assets/dashboard-D1HqCY0Z.js
+++ b/web/static/app/assets/dashboard-Bc2usnZH.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,u as i,y as a}from"./react-QV7DAAIx.js";import{$ as o,At as s,Ct as c,Ft as l,I as u,P as d,R as f,U as p,Y as m,_ as h,it as g,j as _,jt as v,m as y,w as b,x,zt as S}from"./semi-DNxeCrHm.js";import{D as C,E as w,I as T,O as ee,P as E,_ as te,a as D,h as O,k,l as A,m as j,p as ne,r as re,w as M}from"./index-BoFwOeaz.js";var N=e(t(),1),P=e(r(),1),F=[`严重`,`高危`,`中危`,`低危`,`信息`],I=[[0,`safe`,`Safe`,`安全`],[3,`low`,`Low`,`低`],[10,`medium`,`Medium`,`中`],[30,`high`,`High`,`高`],[1/0,`severe`,`Severe`,`极高`]],L=[[`open`,`Open`,`待处理`],[`confirmed`,`Confirmed`,`已确认`],[`fixed`,`Fixed`,`已修复`],[`ignored`,`Ignored`,`已忽略`],[`false_positive`,`FalsePositive`,`误报`]];function R(e){return e[0].toUpperCase()+e.slice(1)}function z(e){if(e==null||e===``||![`number`,`string`].includes(typeof e))return null;let t=Number(e);return Number.isFinite(t)&&t>=0?t:null}function B(e){let t=z(e);return t===null?`—`:C(t)}function V(e,t){let n=e?.by_severity;return!n||typeof n!=`object`||Array.isArray(n)?null:z(n[t]??0)}function H(e,t){let n=new URLSearchParams;e&&n.set(`severity`,e),t&&n.set(`status`,t);let r=n.toString();return`/vulnerabilities`+(r?`?`+r:``)}function U(e,t){let n=(e,t)=>`${(210+e*Math.cos(t)).toFixed(3)} ${(201-e*Math.sin(t)).toFixed(3)}`;return`M ${n(188,e)} A 188 188 0 0 1 ${n(188,t)} L ${n(137,t)} A 137 137 0 0 0 ${n(137,e)} Z`}function W(e,t){if(!t)return[];let n=[],r=Math.PI;for(let i of e){if(!i.count)continue;let e=Math.PI*i.count/t,a=r-e,o=Math.min(.014,e/5);n.push({...i,d:U(r-o,a+o)}),r=a}return n}function G({rows:e,total:t,status:n,loading:r,t:a}){let o=(0,N.useId)(),[s,c]=(0,N.useState)(``),[l,u]=(0,N.useState)(``),d=s||l,f=e.find(e=>e.key===d),p=r?`…`:B(f?f.count:t),m=W(e,t),h=e=>({onPointerEnter:()=>c(e),onPointerLeave:()=>c(``),onFocus:()=>u(e),onBlur:()=>u(``)});return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`dashboard-severity-chart`,children:[(0,P.jsxs)(`svg`,{viewBox:`0 0 420 217`,role:`group`,"aria-label":a(`dashboard.severityDistribution`,null,`漏洞严重程度分布`),children:[(0,P.jsx)(`defs`,{children:e.map(e=>(0,P.jsxs)(`linearGradient`,{id:o+e.key,x1:`12%`,y1:`0%`,x2:`84%`,y2:`100%`,"data-severity":e.key,children:[(0,P.jsx)(`stop`,{offset:`0%`,stopColor:`var(--severity-light)`}),(0,P.jsx)(`stop`,{offset:`100%`,stopColor:`var(--severity-color)`})]},e.key))}),(0,P.jsx)(`path`,{className:`dashboard-ring-track`,d:U(Math.PI,0)}),m.map(e=>(0,P.jsxs)(i,{to:H(e.key,n),className:`dashboard-ring-link`,"data-severity":e.key,"aria-label":`${e.label} · ${B(e.count)}`,"data-muted":!!(d&&e.key!==d),...h(e.key),children:[(0,P.jsx)(`title`,{children:`${e.label} · ${B(e.count)} (${e.percent}%)`}),(0,P.jsx)(`path`,{d:e.d,fill:`url(#${o+e.key})`})]},e.key))]}),(0,P.jsxs)(`div`,{className:`dashboard-ring-center`,"data-severity":f?.key,children:[(0,P.jsx)(`strong`,{children:p}),(0,P.jsx)(`span`,{children:f?.label||a(`dashboard.totalVulns`,null,`总漏洞数`)})]})]}),(0,P.jsx)(`div`,{className:`dashboard-severity-legend`,children:e.map(e=>(0,P.jsxs)(i,{className:`dashboard-severity-item`,"data-severity":e.key,"data-active":d===e.key,to:H(e.key,n),...h(e.key),children:[(0,P.jsx)(`span`,{className:`dashboard-severity-dot`,"aria-hidden":`true`}),(0,P.jsx)(`span`,{className:`dashboard-severity-name`,children:e.label}),(0,P.jsx)(`strong`,{children:r?`…`:B(e.count)}),(0,P.jsx)(`span`,{className:`dashboard-severity-percent`,children:!r&&e.percent!==null?`${e.percent}%`:`—`})]},e.key))})]})}function K({stats:e,latest:t,t:n}){let r=M.map(t=>V(e,t)),a=r.some(e=>e===null)?null:r[0]*10+r[1]*5+r[2]*2+r[3]*.5,[,o,s,c]=a===null?[null,`unknown`,``,``]:I.find(([e])=>a<=e);return(0,P.jsxs)(`aside`,{className:`dashboard-risk-summary`,"aria-label":n(`dashboard.riskLevel`,null,`风险等级`),children:[(0,P.jsxs)(`div`,{className:`dashboard-risk-score`,"data-tone":o,children:[(0,P.jsxs)(`span`,{className:`dashboard-risk-caption`,children:[n(`dashboard.riskLevel`,null,`风险等级`),(0,P.jsx)(_,{size:`small`,className:`dashboard-risk-tag`,children:s?n(`dashboard.risk`+s,null,c):`—`})]}),(0,P.jsx)(y,{percent:Math.min(a??0,100),size:`small`,showInfo:!1,stroke:`var(--risk-accent)`,"aria-label":n(`dashboard.riskScore`,null,`加权风险分`)}),(0,P.jsxs)(`span`,{className:`dashboard-risk-caption`,children:[n(`dashboard.riskScore`,null,`加权风险分`),(0,P.jsx)(`strong`,{children:a===null?`—`:`${C(a)}${a>=100?`+`:``}`})]})]}),(0,P.jsxs)(`div`,{className:`dashboard-risk-pending`,children:[(0,P.jsx)(`span`,{children:n(`dashboard.statusOpen`,null,`待处理`)}),(0,P.jsx)(`div`,{className:`dashboard-risk-pending-links`,children:M.slice(0,2).map((e,t)=>(0,P.jsxs)(i,{to:H(e,`open`),"data-severity":e,children:[(0,P.jsx)(`strong`,{children:B(r[t])}),(0,P.jsx)(`span`,{children:n(`dashboard.severity`+R(e),null,F[t])})]},e))})]}),(0,P.jsxs)(`div`,{className:`dashboard-risk-latest`,children:[(0,P.jsx)(`span`,{children:n(`dashboard.latestFound`,null,`最近发现`)}),(0,P.jsx)(`strong`,{children:t?k(t,n):`—`})]})]})}function q({counts:e,states:t,t:n}){let r=z(e?.fixed??0)??0,a=z(e?.confirmed??0)??0,o=(z(e?.open??0)??0)+a+r,s=o?r/o*100:null;return(0,P.jsxs)(`div`,{className:`dashboard-resolution`,children:[(0,P.jsx)(`div`,{className:`dashboard-resolution-grid`,children:t.map(({value:t,label:n})=>(0,P.jsxs)(i,{to:H(``,t),"data-status":t,className:`dashboard-resolution-item`,children:[(0,P.jsx)(`strong`,{children:B(e?e[t]??0:null)}),(0,P.jsx)(`span`,{children:n})]},t))}),(0,P.jsxs)(`div`,{className:`dashboard-resolution-heading`,children:[(0,P.jsx)(`span`,{children:n(`dashboard.fixRate`,null,`修复率`)}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{className:`dashboard-risk-value`,children:s===null?`—`:`${s.toFixed(s===100?0:1)}%`}),e&&(0,P.jsxs)(`small`,{children:[`(`,C(r),` / `,C(o),`)`]})]})]}),(0,P.jsxs)(`div`,{className:`dashboard-resolution-track`,"aria-hidden":`true`,children:[(0,P.jsx)(`span`,{style:{width:`${s??0}%`}}),(0,P.jsx)(`span`,{style:{width:`${o?a/o*100:0}%`}})]}),(0,P.jsx)(`div`,{className:`dashboard-resolution-legend`,children:[`fixed`,`confirmed`,`open`].map(e=>(0,P.jsx)(`span`,{"data-status":e,children:t.find(t=>t.value===e).label},e))})]})}function J({stats:e,pendingStats:t,latest:n,loadedAt:r,loading:o}){let s=E(),[c,l]=a(),u=L.map(([e,t,n])=>({value:e,label:s(`dashboard.status`+t,null,n)})),d=c.get(`risk_status`),p=u.some(e=>e.value===d)?d:``,m=!!(p&&p!==`open`),g=D(async()=>{try{return{status:p,stats:await T.get(`/vulnerabilities/stats`,{status:p})}}catch(e){return{status:p,error:e}}},[p,r],{skip:!m}),_=g.data?.status===p,v=p===`open`?t:m?_?g.data.stats:null:e,y=o||m&&(g.loading||!_),b=M.map(e=>V(v,e)),x=b.some(e=>e===null)?null:Math.max(z(v?.total)??0,b.reduce((e,t)=>e+t,0)),C=M.map((e,t)=>({key:e,label:s(`dashboard.severity`+R(e),null,F[t]),count:b[t],percent:x===null?null:x===0?0:Math.round(b[t]/x*100)}));return(0,P.jsxs)(j,{className:`dashboard-vulnerability-card`,bodyClassName:`dashboard-vulnerability-body`,title:s(`dashboard.severityDistribution`,null,`漏洞严重程度分布`),extra:(0,P.jsxs)(`div`,{className:`dashboard-vulnerability-actions`,children:[(0,P.jsx)(h,{"aria-label":s(`dashboard.statusFilter`,null,`状态筛选`),size:`small`,value:p||`all`,optionList:[{value:`all`,label:s(`dashboard.allStatuses`,null,`全部状态`)},...u],onChange:e=>l(t=>{let n=new URLSearchParams(t);return e===`all`?n.delete(`risk_status`):n.set(`risk_status`,e),n},{replace:!0})}),(0,P.jsxs)(i,{className:`dashboard-vulnerability-all`,to:H(``,p),children:[s(`dashboard.viewAll`,null,`查看全部`).replace(/\s*→\s*$/,``),(0,P.jsx)(S,{"aria-hidden":`true`})]})]}),children:[m&&_&&g.data.error&&(0,P.jsx)(f,{type:`warning`,closeIcon:null,description:(0,P.jsxs)(`button`,{type:`button`,className:`dashboard-filter-retry`,onClick:()=>g.reload(),children:[s(`common.loadFailed`,null,`加载失败`),` · `,s(`common.refresh`,null,`刷新`)]})}),(0,P.jsxs)(`div`,{className:`dashboard-vulnerability-grid`,children:[(0,P.jsx)(K,{stats:t,latest:n,t:s}),(0,P.jsx)(G,{rows:C,total:x,status:p,loading:y,t:s},p)]}),(0,P.jsx)(q,{counts:e?.by_status,states:u,t:s})]})}var{Text:Y}=p,ie=new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1});async function X(e,t){try{return await T.get(e,t)}catch{return null}}async function ae(){let[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_]=await Promise.all([X(`/agent-loop/tasks`),X(`/vulnerabilities/stats`),X(`/vulnerabilities/stats`,{status:`open`}),X(`/vulnerabilities`,{limit:8,page:1}),X(`/batch-tasks`,{limit:200,page:1}),X(`/monitor/stats`,{top:8}),X(`/usage/tokens`,{days:7,limit:20}),X(`/knowledge/stats`),X(`/skills/stats`),X(`/roles`),X(`/multi-agent/markdown-agents`),X(`/hitl/pending`),X(`/external-mcp/stats`),X(`/webshell/connections`),X(`/c2/listeners`),X(`/c2/sessions`,{limit:200}),X(`/projects/dashboard-summary`,{fact_limit:8}),X(`/config/tools`,{page:1,page_size:1,include_external:!1})]),v={agentTasks:e,vulnStats:t,pendingVulnStats:n,vulnList:r,batchQueues:i,monitorStats:a,tokenUsage:o,knowledgeStats:s,skillsStats:c,roles:l,agents:u,hitlPending:d,externalMcp:f,webshell:p,c2Listeners:m,c2Sessions:h,projectSummary:g,toolsConfig:_};return{...v,unavailableCount:Object.values(v).filter(e=>e==null).length,sourceCount:Object.keys(v).length,loadedAt:new Date().toISOString()}}function Z(e,...t){if(Array.isArray(e))return e;for(let n of t)if(Array.isArray(e?.[n]))return e[n];return null}function Q(e,...t){return Z(e,...t)?.length??null}function $({loading:e,unavailable:t,title:n,description:r}){return(0,P.jsx)(b,{className:`dashboard-empty`,title:e?`正在加载数据`:t?`数据暂不可用`:n,description:e?`正在读取最新记录,请稍候。`:t?`未能取得数据,请稍后刷新重试。`:r})}function oe({data:e,loading:t,onOpen:n}){let r=Z(e,`vulnerabilities`);return(0,P.jsx)(x,{className:`dashboard-list dashboard-feed`,loading:t,dataSource:r||[],emptyContent:(0,P.jsx)($,{loading:t,unavailable:r===null,title:`暂无漏洞记录`,description:`测评发现的漏洞会汇集到这里,便于跟进与复核。`}),renderItem:e=>(0,P.jsx)(x.Item,{main:(0,P.jsxs)(`div`,{className:`dashboard-record`,children:[(0,P.jsx)(u,{theme:`borderless`,className:`dashboard-record-link`,onClick:()=>n(e.id),children:e.title||e.name||`未命名漏洞`}),(0,P.jsxs)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:[e.host||e.target||`—`,` · `,w(e.created_at)]})]}),extra:(0,P.jsx)(O,{severity:e.severity})},e.id)})}function se({summary:e,loading:t,onOpen:n}){let r=Z(e,`recent_facts`,`facts`);return(0,P.jsx)(x,{className:`dashboard-list dashboard-feed`,loading:t,dataSource:r||[],emptyContent:(0,P.jsx)($,{loading:t,unavailable:r===null,title:`暂无近期事实`,description:`项目沉淀的事实与证据将在这里展示。`}),renderItem:(e,t)=>(0,P.jsx)(x.Item,{main:(0,P.jsxs)(`div`,{className:`dashboard-record`,children:[(0,P.jsx)(Y,{strong:!0,className:`dashboard-fact-title`,children:e.title||e.summary||e.key||e.fact_key||e.subject||`事实`}),(0,P.jsx)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:e.project_name||e.projectName||e.value||`—`})]}),extra:(0,P.jsxs)(d,{spacing:8,children:[e.status&&(0,P.jsx)(_,{size:`small`,children:e.status}),e.project_id&&(0,P.jsx)(u,{theme:`borderless`,icon:(0,P.jsx)(S,{}),"aria-label":`查看所属项目`,onClick:()=>n(e.project_id)})]})},e.id||e.key||e.fact_key||t)})}function ce(){let e=E(),t=n(),{data:r,loading:i,error:a,reload:p}=D(ae,[]);re(()=>p({silent:!0}),6e4);let h=(0,N.useMemo)(()=>{let n=Q(r?.agentTasks,`tasks`),a=z(r?.tokenUsage?.summary?.totalTokens),c=V(r?.vulnStats,`critical`),u=V(r?.pendingVulnStats,`high`),d=r?.monitorStats?.summary,f=z(d?.successCalls),p=z(d?.failedCalls),h=f===null||p===null?null:f+p,g=h>0?f/h:null,_=Z(r?.batchQueues,`queues`)?.filter(e=>String(e.status).toLowerCase()===`running`).length;return[{id:`tasks`,label:e(`dashboard.runningConversations`,null,`运行中任务`),value:B(n),detail:`运行中批量队列 ${B(_)}`,icon:(0,P.jsx)(s,{}),onClick:()=>t(`/tasks`)},{id:`vulnerabilities`,label:e(`dashboard.vulnTotal`,null,`漏洞总数`),value:B(r?.vulnStats?.total),detail:e(`dashboard.openHighCountLabel`,{count:B(u)},`待处理高危 ${B(u)}`),tone:c>0?`danger`:void 0,icon:(0,P.jsx)(o,{}),onClick:()=>t(`/vulnerabilities`)},{id:`calls`,label:e(`dashboard.toolCalls`,null,`工具调用`),value:B(d?.totalCalls),detail:`涉及工具 ${B(d?.toolCount)}`,icon:(0,P.jsx)(m,{}),onClick:()=>t(`/mcp-monitor`)},{id:`rate`,label:e(`dashboard.successRate`,null,`执行成功率`),value:g===null?`—`:ee(g),detail:h===null?`执行结果暂不可用`:h===0?`尚无已完成调用`:`失败 ${B(p)} 次`,tone:g!==null&&g<.8?`warning`:void 0,icon:(0,P.jsx)(v,{}),onClick:()=>t(`/mcp-monitor`)},{id:`tokens`,label:e(`dashboard.tokenUsage`,null,`Token 用量(7 天)`),value:a>=1e6?ie.format(a):B(a),valueTitle:a>=1e6?B(a):void 0,detail:`调用次数 ${B(r?.tokenUsage?.summary?.modelCalls??r?.tokenUsage?.summary?.calls)}`,icon:(0,P.jsx)(l,{}),onClick:()=>t(`/settings?section=token-usage`)}].map(e=>({...e,loading:i,detail:i?`正在刷新数据`:e.detail}))},[r,i,t,e]),_=(0,N.useMemo)(()=>{let e=[],t=V(r?.vulnStats,`critical`);t>0&&e.push({id:`critical`,text:`${B(t)} 条严重漏洞`,page:`/vulnerabilities`});let n=Q(r?.hitlPending,`items`,`pending`);n>0&&e.push({id:`pending`,text:`${B(n)} 项审批待处理`,page:`/hitl`});let i=z(r?.monitorStats?.summary?.failedCalls);i>0&&e.push({id:`failed`,text:`工具调用失败 ${B(i)} 次`,page:`/mcp-monitor`});let a=z(r?.externalMcp?.total),o=z(r?.externalMcp?.connected);return a!==null&&o!==null&&a>o&&e.push({id:`mcp`,text:`${B(a-o)} 个外部 MCP 未连接`,page:`/mcp-management`}),e},[r]),y=(0,N.useMemo)(()=>[{id:`tools`,label:`MCP 工具`,value:r?.toolsConfig?.total,page:`/mcp-management`},{id:`knowledge`,label:`知识条目`,value:r?.knowledgeStats?.total_items,page:`/knowledge-management`},{id:`skills`,label:`技能`,value:r?.skillsStats?.total_skills,page:`/skills-management`},{id:`roles`,label:`角色`,value:Q(r?.roles,`roles`),page:`/roles-management`},{id:`agents`,label:`智能体`,value:Q(r?.agents,`agents`),page:`/agents-management`},{id:`webshell`,label:`WebShell 连接`,value:Q(r?.webshell,`connections`),page:`/webshell`},{id:`listeners`,label:`C2 监听器`,value:Q(r?.c2Listeners,`listeners`),page:`/c2-listeners`},{id:`sessions`,label:`C2 会话`,value:Q(r?.c2Sessions,`sessions`,`items`),page:`/c2-sessions`}],[r]),b=r?.loadedAt?w(r.loadedAt):`—`,C=e=>t(`/projects?id=${encodeURIComponent(e)}`);return(0,P.jsxs)(`div`,{className:`dashboard-page`,"aria-busy":i,children:[(0,P.jsx)(ne,{title:e(`dashboard.title`,null,`仪表盘`),description:`最近刷新 ${b} · 每 60 秒自动刷新`,extra:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(u,{icon:(0,P.jsx)(g,{}),onClick:()=>p(),loading:i,children:e(`common.refresh`,null,`刷新`)}),(0,P.jsx)(u,{theme:`solid`,icon:(0,P.jsx)(c,{}),onClick:()=>t(`/chat`),children:`进入对话`})]})}),(0,P.jsx)(te,{metrics:h,columns:5}),(0,P.jsx)(A,{error:a,onRetry:()=>p()}),r?.unavailableCount>0&&(0,P.jsx)(f,{className:`dashboard-notice`,type:`info`,fullMode:!1,closeIcon:null,title:r.unavailableCount===r.sourceCount?`数据暂不可用`:`部分数据不可用`,description:r.unavailableCount===r.sourceCount?`本次未能取得仪表盘数据,请检查服务连接后刷新重试。`:`${r.unavailableCount} 项数据源未能加载,相关数值以 — 显示。已返回的数据仍可查看,请稍后刷新重试。`}),_.length>0&&(0,P.jsx)(f,{className:`dashboard-notice`,type:`warning`,fullMode:!1,closeIcon:null,description:(0,P.jsxs)(d,{wrap:!0,spacing:8,children:[(0,P.jsx)(Y,{strong:!0,children:`需要关注`}),_.map(e=>(0,P.jsx)(u,{theme:`borderless`,type:`warning`,icon:(0,P.jsx)(S,{}),iconPosition:`right`,onClick:()=>t(e.page),children:e.text},e.id))]})}),(0,P.jsxs)(`div`,{className:`dashboard-grid`,children:[(0,P.jsxs)(`div`,{className:`dashboard-column`,children:[(0,P.jsx)(J,{stats:r?.vulnStats,pendingStats:r?.pendingVulnStats,latest:r?.vulnList?.vulnerabilities?.[0]?.created_at,loadedAt:r?.loadedAt,loading:i}),(0,P.jsx)(j,{title:e(`dashboard.recentVulns`,null,`最近漏洞`),extra:(0,P.jsx)(u,{theme:`borderless`,size:`small`,icon:(0,P.jsx)(S,{}),iconPosition:`right`,onClick:()=>t(`/vulnerabilities`),children:`查看全部`}),children:(0,P.jsx)(oe,{data:r?.vulnList,loading:i,onOpen:e=>t(`/vulnerabilities?id=${encodeURIComponent(e)}`)})}),(0,P.jsx)(j,{title:e(`dashboard.recentFacts`,null,`近期事实`),children:(0,P.jsx)(se,{summary:r?.projectSummary,loading:i,onOpen:C})})]}),(0,P.jsxs)(`div`,{className:`dashboard-column`,children:[(0,P.jsx)(j,{title:e(`dashboard.projects`,null,`项目概览`),extra:(0,P.jsx)(u,{theme:`borderless`,size:`small`,icon:(0,P.jsx)(S,{}),iconPosition:`right`,onClick:()=>t(`/projects`),children:`全部项目`}),children:(0,P.jsx)(ue,{summary:r?.projectSummary,loading:i,onOpen:C})}),(0,P.jsx)(j,{title:e(`dashboard.toolsTop`,null,`工具调用 Top`),extra:(0,P.jsx)(u,{theme:`borderless`,size:`small`,onClick:()=>t(`/mcp-monitor`),children:`调用监控`}),children:(0,P.jsx)(le,{data:r?.monitorStats,loading:i})}),(0,P.jsx)(j,{title:e(`dashboard.capability`,null,`能力与运行态`),children:(0,P.jsx)(x,{className:`dashboard-capabilities`,split:!1,dataSource:y,renderItem:e=>(0,P.jsx)(x.Item,{children:(0,P.jsxs)(u,{block:!0,theme:`borderless`,type:`tertiary`,className:`dashboard-capability`,onClick:()=>t(e.page),children:[(0,P.jsx)(`span`,{children:e.label}),(0,P.jsx)(`span`,{className:`dashboard-capability-value`,children:i?`…`:B(e.value)})]})},e.id)})})]})]})]})}function le({data:e,loading:t}){let n=Z(e,`topTools`),r=n?.slice(0,8).map(e=>({name:e.name||e.toolName||`未命名工具`,count:z(e.count??e.calls??e.totalCalls)}))||[],i=Math.max(...r.map(e=>e.count??0),1);return(0,P.jsx)(x,{className:`dashboard-list`,loading:t,dataSource:r,emptyContent:(0,P.jsx)($,{loading:t,unavailable:n===null,title:`暂无工具调用`,description:`执行任务后,可在这里查看使用最多的工具。`}),renderItem:(e,t)=>(0,P.jsxs)(x.Item,{className:`dashboard-tool-row`,children:[(0,P.jsx)(Y,{type:`tertiary`,size:`small`,className:`dashboard-tool-rank`,children:t+1}),(0,P.jsxs)(`div`,{className:`dashboard-record`,children:[(0,P.jsxs)(`div`,{className:`dashboard-tool-heading`,children:[(0,P.jsx)(Y,{className:`dashboard-tool-name`,title:e.name,children:e.name}),(0,P.jsxs)(Y,{type:`secondary`,size:`small`,className:`dashboard-count`,children:[B(e.count),` 次`]})]}),e.count!==null&&(0,P.jsx)(y,{percent:Math.round(e.count/i*100),showInfo:!1,size:`small`,stroke:`var(--semi-color-primary)`,"aria-label":`${e.name}调用次数`,"aria-valuetext":`${B(e.count)} 次`})]})]},`${e.name}-${t}`)})}function ue({summary:e,loading:t,onOpen:n}){let r=Z(e,`projects`),i=Z(e,`recent_facts`,`facts`),a=e?.totals||e,o=[[`活跃项目`,a?.active_projects??a?.activeProjects],[`事实总数`,a?.total_facts??a?.totalFacts],[`最近事实`,i?.length]];return(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`dl`,{className:`dashboard-project-totals`,children:o.map(([e,n])=>(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`dt`,{children:e}),(0,P.jsx)(`dd`,{children:t?`…`:B(n)})]},e))}),(0,P.jsx)(x,{className:`dashboard-list dashboard-feed`,loading:t,dataSource:r?.slice(0,6)||[],emptyContent:(0,P.jsx)($,{loading:t,unavailable:!e,title:r===null?`在项目中继续工作`:`暂无项目`,description:r===null?`当前摘要提供项目与事实统计,完整列表请查看全部项目。`:`创建项目后,在这里跟进项目进展。`}),renderItem:e=>(0,P.jsx)(x.Item,{main:(0,P.jsxs)(`div`,{className:`dashboard-record`,children:[(0,P.jsx)(u,{theme:`borderless`,className:`dashboard-record-link`,onClick:()=>n(e.id),children:e.name||`未命名项目`}),(0,P.jsxs)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:[e.status||`—`,` · `,w(e.updated_at)]})]})},e.id)})]})}export{ce as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,u as i,y as a}from"./react-QV7DAAIx.js";import{$ as o,At as s,Ct as c,Ft as l,I as u,P as d,R as f,U as p,Y as m,_ as h,it as g,j as _,jt as v,m as y,w as b,x,zt as S}from"./semi-DNxeCrHm.js";import{D as C,E as w,I as T,O as ee,P as E,_ as te,a as D,h as O,k,l as A,m as j,p as ne,r as re,w as M}from"./index-smFoxEJu.js";var N=e(t(),1),P=e(r(),1),F=[`严重`,`高危`,`中危`,`低危`,`信息`],I=[[0,`safe`,`Safe`,`安全`],[3,`low`,`Low`,`低`],[10,`medium`,`Medium`,`中`],[30,`high`,`High`,`高`],[1/0,`severe`,`Severe`,`极高`]],L=[[`open`,`Open`,`待处理`],[`confirmed`,`Confirmed`,`已确认`],[`fixed`,`Fixed`,`已修复`],[`ignored`,`Ignored`,`已忽略`],[`false_positive`,`FalsePositive`,`误报`]];function R(e){return e[0].toUpperCase()+e.slice(1)}function z(e){if(e==null||e===``||![`number`,`string`].includes(typeof e))return null;let t=Number(e);return Number.isFinite(t)&&t>=0?t:null}function B(e){let t=z(e);return t===null?`—`:C(t)}function V(e,t){let n=e?.by_severity;return!n||typeof n!=`object`||Array.isArray(n)?null:z(n[t]??0)}function H(e,t){let n=new URLSearchParams;e&&n.set(`severity`,e),t&&n.set(`status`,t);let r=n.toString();return`/vulnerabilities`+(r?`?`+r:``)}function U(e,t){let n=(e,t)=>`${(210+e*Math.cos(t)).toFixed(3)} ${(201-e*Math.sin(t)).toFixed(3)}`;return`M ${n(188,e)} A 188 188 0 0 1 ${n(188,t)} L ${n(137,t)} A 137 137 0 0 0 ${n(137,e)} Z`}function W(e,t){if(!t)return[];let n=[],r=Math.PI;for(let i of e){if(!i.count)continue;let e=Math.PI*i.count/t,a=r-e,o=Math.min(.014,e/5);n.push({...i,d:U(r-o,a+o)}),r=a}return n}function G({rows:e,total:t,status:n,loading:r,t:a}){let o=(0,N.useId)(),[s,c]=(0,N.useState)(``),[l,u]=(0,N.useState)(``),d=s||l,f=e.find(e=>e.key===d),p=r?`…`:B(f?f.count:t),m=W(e,t),h=e=>({onPointerEnter:()=>c(e),onPointerLeave:()=>c(``),onFocus:()=>u(e),onBlur:()=>u(``)});return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`dashboard-severity-chart`,children:[(0,P.jsxs)(`svg`,{viewBox:`0 0 420 217`,role:`group`,"aria-label":a(`dashboard.severityDistribution`,null,`漏洞严重程度分布`),children:[(0,P.jsx)(`defs`,{children:e.map(e=>(0,P.jsxs)(`linearGradient`,{id:o+e.key,x1:`12%`,y1:`0%`,x2:`84%`,y2:`100%`,"data-severity":e.key,children:[(0,P.jsx)(`stop`,{offset:`0%`,stopColor:`var(--severity-light)`}),(0,P.jsx)(`stop`,{offset:`100%`,stopColor:`var(--severity-color)`})]},e.key))}),(0,P.jsx)(`path`,{className:`dashboard-ring-track`,d:U(Math.PI,0)}),m.map(e=>(0,P.jsxs)(i,{to:H(e.key,n),className:`dashboard-ring-link`,"data-severity":e.key,"aria-label":`${e.label} · ${B(e.count)}`,"data-muted":!!(d&&e.key!==d),...h(e.key),children:[(0,P.jsx)(`title`,{children:`${e.label} · ${B(e.count)} (${e.percent}%)`}),(0,P.jsx)(`path`,{d:e.d,fill:`url(#${o+e.key})`})]},e.key))]}),(0,P.jsxs)(`div`,{className:`dashboard-ring-center`,"data-severity":f?.key,children:[(0,P.jsx)(`strong`,{children:p}),(0,P.jsx)(`span`,{children:f?.label||a(`dashboard.totalVulns`,null,`总漏洞数`)})]})]}),(0,P.jsx)(`div`,{className:`dashboard-severity-legend`,children:e.map(e=>(0,P.jsxs)(i,{className:`dashboard-severity-item`,"data-severity":e.key,"data-active":d===e.key,to:H(e.key,n),...h(e.key),children:[(0,P.jsx)(`span`,{className:`dashboard-severity-dot`,"aria-hidden":`true`}),(0,P.jsx)(`span`,{className:`dashboard-severity-name`,children:e.label}),(0,P.jsx)(`strong`,{children:r?`…`:B(e.count)}),(0,P.jsx)(`span`,{className:`dashboard-severity-percent`,children:!r&&e.percent!==null?`${e.percent}%`:`—`})]},e.key))})]})}function K({stats:e,latest:t,t:n}){let r=M.map(t=>V(e,t)),a=r.some(e=>e===null)?null:r[0]*10+r[1]*5+r[2]*2+r[3]*.5,[,o,s,c]=a===null?[null,`unknown`,``,``]:I.find(([e])=>a<=e);return(0,P.jsxs)(`aside`,{className:`dashboard-risk-summary`,"aria-label":n(`dashboard.riskLevel`,null,`风险等级`),children:[(0,P.jsxs)(`div`,{className:`dashboard-risk-score`,"data-tone":o,children:[(0,P.jsxs)(`span`,{className:`dashboard-risk-caption`,children:[n(`dashboard.riskLevel`,null,`风险等级`),(0,P.jsx)(_,{size:`small`,className:`dashboard-risk-tag`,children:s?n(`dashboard.risk`+s,null,c):`—`})]}),(0,P.jsx)(y,{percent:Math.min(a??0,100),size:`small`,showInfo:!1,stroke:`var(--risk-accent)`,"aria-label":n(`dashboard.riskScore`,null,`加权风险分`)}),(0,P.jsxs)(`span`,{className:`dashboard-risk-caption`,children:[n(`dashboard.riskScore`,null,`加权风险分`),(0,P.jsx)(`strong`,{children:a===null?`—`:`${C(a)}${a>=100?`+`:``}`})]})]}),(0,P.jsxs)(`div`,{className:`dashboard-risk-pending`,children:[(0,P.jsx)(`span`,{children:n(`dashboard.statusOpen`,null,`待处理`)}),(0,P.jsx)(`div`,{className:`dashboard-risk-pending-links`,children:M.slice(0,2).map((e,t)=>(0,P.jsxs)(i,{to:H(e,`open`),"data-severity":e,children:[(0,P.jsx)(`strong`,{children:B(r[t])}),(0,P.jsx)(`span`,{children:n(`dashboard.severity`+R(e),null,F[t])})]},e))})]}),(0,P.jsxs)(`div`,{className:`dashboard-risk-latest`,children:[(0,P.jsx)(`span`,{children:n(`dashboard.latestFound`,null,`最近发现`)}),(0,P.jsx)(`strong`,{children:t?k(t,n):`—`})]})]})}function q({counts:e,states:t,t:n}){let r=z(e?.fixed??0)??0,a=z(e?.confirmed??0)??0,o=(z(e?.open??0)??0)+a+r,s=o?r/o*100:null;return(0,P.jsxs)(`div`,{className:`dashboard-resolution`,children:[(0,P.jsx)(`div`,{className:`dashboard-resolution-grid`,children:t.map(({value:t,label:n})=>(0,P.jsxs)(i,{to:H(``,t),"data-status":t,className:`dashboard-resolution-item`,children:[(0,P.jsx)(`strong`,{children:B(e?e[t]??0:null)}),(0,P.jsx)(`span`,{children:n})]},t))}),(0,P.jsxs)(`div`,{className:`dashboard-resolution-heading`,children:[(0,P.jsx)(`span`,{children:n(`dashboard.fixRate`,null,`修复率`)}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`strong`,{className:`dashboard-risk-value`,children:s===null?`—`:`${s.toFixed(s===100?0:1)}%`}),e&&(0,P.jsxs)(`small`,{children:[`(`,C(r),` / `,C(o),`)`]})]})]}),(0,P.jsxs)(`div`,{className:`dashboard-resolution-track`,"aria-hidden":`true`,children:[(0,P.jsx)(`span`,{style:{width:`${s??0}%`}}),(0,P.jsx)(`span`,{style:{width:`${o?a/o*100:0}%`}})]}),(0,P.jsx)(`div`,{className:`dashboard-resolution-legend`,children:[`fixed`,`confirmed`,`open`].map(e=>(0,P.jsx)(`span`,{"data-status":e,children:t.find(t=>t.value===e).label},e))})]})}function J({stats:e,pendingStats:t,latest:n,loadedAt:r,loading:o}){let s=E(),[c,l]=a(),u=L.map(([e,t,n])=>({value:e,label:s(`dashboard.status`+t,null,n)})),d=c.get(`risk_status`),p=u.some(e=>e.value===d)?d:``,m=!!(p&&p!==`open`),g=D(async()=>{try{return{status:p,stats:await T.get(`/vulnerabilities/stats`,{status:p})}}catch(e){return{status:p,error:e}}},[p,r],{skip:!m}),_=g.data?.status===p,v=p===`open`?t:m?_?g.data.stats:null:e,y=o||m&&(g.loading||!_),b=M.map(e=>V(v,e)),x=b.some(e=>e===null)?null:Math.max(z(v?.total)??0,b.reduce((e,t)=>e+t,0)),C=M.map((e,t)=>({key:e,label:s(`dashboard.severity`+R(e),null,F[t]),count:b[t],percent:x===null?null:x===0?0:Math.round(b[t]/x*100)}));return(0,P.jsxs)(j,{className:`dashboard-vulnerability-card`,bodyClassName:`dashboard-vulnerability-body`,title:s(`dashboard.severityDistribution`,null,`漏洞严重程度分布`),extra:(0,P.jsxs)(`div`,{className:`dashboard-vulnerability-actions`,children:[(0,P.jsx)(h,{"aria-label":s(`dashboard.statusFilter`,null,`状态筛选`),size:`small`,value:p||`all`,optionList:[{value:`all`,label:s(`dashboard.allStatuses`,null,`全部状态`)},...u],onChange:e=>l(t=>{let n=new URLSearchParams(t);return e===`all`?n.delete(`risk_status`):n.set(`risk_status`,e),n},{replace:!0})}),(0,P.jsxs)(i,{className:`dashboard-vulnerability-all`,to:H(``,p),children:[s(`dashboard.viewAll`,null,`查看全部`).replace(/\s*→\s*$/,``),(0,P.jsx)(S,{"aria-hidden":`true`})]})]}),children:[m&&_&&g.data.error&&(0,P.jsx)(f,{type:`warning`,closeIcon:null,description:(0,P.jsxs)(`button`,{type:`button`,className:`dashboard-filter-retry`,onClick:()=>g.reload(),children:[s(`common.loadFailed`,null,`加载失败`),` · `,s(`common.refresh`,null,`刷新`)]})}),(0,P.jsxs)(`div`,{className:`dashboard-vulnerability-grid`,children:[(0,P.jsx)(K,{stats:t,latest:n,t:s}),(0,P.jsx)(G,{rows:C,total:x,status:p,loading:y,t:s},p)]}),(0,P.jsx)(q,{counts:e?.by_status,states:u,t:s})]})}var{Text:Y}=p,ie=new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1});async function X(e,t){try{return await T.get(e,t)}catch{return null}}async function ae(){let[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_]=await Promise.all([X(`/agent-loop/tasks`),X(`/vulnerabilities/stats`),X(`/vulnerabilities/stats`,{status:`open`}),X(`/vulnerabilities`,{limit:8,page:1}),X(`/batch-tasks`,{limit:200,page:1}),X(`/monitor/stats`,{top:8}),X(`/usage/tokens`,{days:7,limit:20}),X(`/knowledge/stats`),X(`/skills/stats`),X(`/roles`),X(`/multi-agent/markdown-agents`),X(`/hitl/pending`),X(`/external-mcp/stats`),X(`/webshell/connections`),X(`/c2/listeners`),X(`/c2/sessions`,{limit:200}),X(`/projects/dashboard-summary`,{fact_limit:8}),X(`/config/tools`,{page:1,page_size:1,include_external:!1})]),v={agentTasks:e,vulnStats:t,pendingVulnStats:n,vulnList:r,batchQueues:i,monitorStats:a,tokenUsage:o,knowledgeStats:s,skillsStats:c,roles:l,agents:u,hitlPending:d,externalMcp:f,webshell:p,c2Listeners:m,c2Sessions:h,projectSummary:g,toolsConfig:_};return{...v,unavailableCount:Object.values(v).filter(e=>e==null).length,sourceCount:Object.keys(v).length,loadedAt:new Date().toISOString()}}function Z(e,...t){if(Array.isArray(e))return e;for(let n of t)if(Array.isArray(e?.[n]))return e[n];return null}function Q(e,...t){return Z(e,...t)?.length??null}function $({loading:e,unavailable:t,title:n,description:r}){return(0,P.jsx)(b,{className:`dashboard-empty`,title:e?`正在加载数据`:t?`数据暂不可用`:n,description:e?`正在读取最新记录,请稍候。`:t?`未能取得数据,请稍后刷新重试。`:r})}function oe({data:e,loading:t,onOpen:n}){let r=Z(e,`vulnerabilities`);return(0,P.jsx)(x,{className:`dashboard-list dashboard-feed`,loading:t,dataSource:r||[],emptyContent:(0,P.jsx)($,{loading:t,unavailable:r===null,title:`暂无漏洞记录`,description:`测评发现的漏洞会汇集到这里,便于跟进与复核。`}),renderItem:e=>(0,P.jsx)(x.Item,{main:(0,P.jsxs)(`div`,{className:`dashboard-record`,children:[(0,P.jsx)(u,{theme:`borderless`,className:`dashboard-record-link`,onClick:()=>n(e.id),children:e.title||e.name||`未命名漏洞`}),(0,P.jsxs)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:[e.host||e.target||`—`,` · `,w(e.created_at)]})]}),extra:(0,P.jsx)(O,{severity:e.severity})},e.id)})}function se({summary:e,loading:t,onOpen:n}){let r=Z(e,`recent_facts`,`facts`);return(0,P.jsx)(x,{className:`dashboard-list dashboard-feed`,loading:t,dataSource:r||[],emptyContent:(0,P.jsx)($,{loading:t,unavailable:r===null,title:`暂无近期事实`,description:`项目沉淀的事实与证据将在这里展示。`}),renderItem:(e,t)=>(0,P.jsx)(x.Item,{main:(0,P.jsxs)(`div`,{className:`dashboard-record`,children:[(0,P.jsx)(Y,{strong:!0,className:`dashboard-fact-title`,children:e.title||e.summary||e.key||e.fact_key||e.subject||`事实`}),(0,P.jsx)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:e.project_name||e.projectName||e.value||`—`})]}),extra:(0,P.jsxs)(d,{spacing:8,children:[e.status&&(0,P.jsx)(_,{size:`small`,children:e.status}),e.project_id&&(0,P.jsx)(u,{theme:`borderless`,icon:(0,P.jsx)(S,{}),"aria-label":`查看所属项目`,onClick:()=>n(e.project_id)})]})},e.id||e.key||e.fact_key||t)})}function ce(){let e=E(),t=n(),{data:r,loading:i,error:a,reload:p}=D(ae,[]);re(()=>p({silent:!0}),6e4);let h=(0,N.useMemo)(()=>{let n=Q(r?.agentTasks,`tasks`),a=z(r?.tokenUsage?.summary?.totalTokens),c=V(r?.vulnStats,`critical`),u=V(r?.pendingVulnStats,`high`),d=r?.monitorStats?.summary,f=z(d?.successCalls),p=z(d?.failedCalls),h=f===null||p===null?null:f+p,g=h>0?f/h:null,_=Z(r?.batchQueues,`queues`)?.filter(e=>String(e.status).toLowerCase()===`running`).length;return[{id:`tasks`,label:e(`dashboard.runningConversations`,null,`运行中任务`),value:B(n),detail:`运行中批量队列 ${B(_)}`,icon:(0,P.jsx)(s,{}),onClick:()=>t(`/tasks`)},{id:`vulnerabilities`,label:e(`dashboard.vulnTotal`,null,`漏洞总数`),value:B(r?.vulnStats?.total),detail:e(`dashboard.openHighCountLabel`,{count:B(u)},`待处理高危 ${B(u)}`),tone:c>0?`danger`:void 0,icon:(0,P.jsx)(o,{}),onClick:()=>t(`/vulnerabilities`)},{id:`calls`,label:e(`dashboard.toolCalls`,null,`工具调用`),value:B(d?.totalCalls),detail:`涉及工具 ${B(d?.toolCount)}`,icon:(0,P.jsx)(m,{}),onClick:()=>t(`/mcp-monitor`)},{id:`rate`,label:e(`dashboard.successRate`,null,`执行成功率`),value:g===null?`—`:ee(g),detail:h===null?`执行结果暂不可用`:h===0?`尚无已完成调用`:`失败 ${B(p)} 次`,tone:g!==null&&g<.8?`warning`:void 0,icon:(0,P.jsx)(v,{}),onClick:()=>t(`/mcp-monitor`)},{id:`tokens`,label:e(`dashboard.tokenUsage`,null,`Token 用量(7 天)`),value:a>=1e6?ie.format(a):B(a),valueTitle:a>=1e6?B(a):void 0,detail:`调用次数 ${B(r?.tokenUsage?.summary?.modelCalls??r?.tokenUsage?.summary?.calls)}`,icon:(0,P.jsx)(l,{}),onClick:()=>t(`/settings?section=token-usage`)}].map(e=>({...e,loading:i,detail:i?`正在刷新数据`:e.detail}))},[r,i,t,e]),_=(0,N.useMemo)(()=>{let e=[],t=V(r?.vulnStats,`critical`);t>0&&e.push({id:`critical`,text:`${B(t)} 条严重漏洞`,page:`/vulnerabilities`});let n=Q(r?.hitlPending,`items`,`pending`);n>0&&e.push({id:`pending`,text:`${B(n)} 项审批待处理`,page:`/hitl`});let i=z(r?.monitorStats?.summary?.failedCalls);i>0&&e.push({id:`failed`,text:`工具调用失败 ${B(i)} 次`,page:`/mcp-monitor`});let a=z(r?.externalMcp?.total),o=z(r?.externalMcp?.connected);return a!==null&&o!==null&&a>o&&e.push({id:`mcp`,text:`${B(a-o)} 个外部 MCP 未连接`,page:`/mcp-management`}),e},[r]),y=(0,N.useMemo)(()=>[{id:`tools`,label:`MCP 工具`,value:r?.toolsConfig?.total,page:`/mcp-management`},{id:`knowledge`,label:`知识条目`,value:r?.knowledgeStats?.total_items,page:`/knowledge-management`},{id:`skills`,label:`技能`,value:r?.skillsStats?.total_skills,page:`/skills-management`},{id:`roles`,label:`角色`,value:Q(r?.roles,`roles`),page:`/roles-management`},{id:`agents`,label:`智能体`,value:Q(r?.agents,`agents`),page:`/agents-management`},{id:`webshell`,label:`WebShell 连接`,value:Q(r?.webshell,`connections`),page:`/webshell`},{id:`listeners`,label:`C2 监听器`,value:Q(r?.c2Listeners,`listeners`),page:`/c2-listeners`},{id:`sessions`,label:`C2 会话`,value:Q(r?.c2Sessions,`sessions`,`items`),page:`/c2-sessions`}],[r]),b=r?.loadedAt?w(r.loadedAt):`—`,C=e=>t(`/projects?id=${encodeURIComponent(e)}`);return(0,P.jsxs)(`div`,{className:`dashboard-page`,"aria-busy":i,children:[(0,P.jsx)(ne,{title:e(`dashboard.title`,null,`仪表盘`),description:`最近刷新 ${b} · 每 60 秒自动刷新`,extra:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(u,{icon:(0,P.jsx)(g,{}),onClick:()=>p(),loading:i,children:e(`common.refresh`,null,`刷新`)}),(0,P.jsx)(u,{theme:`solid`,icon:(0,P.jsx)(c,{}),onClick:()=>t(`/chat`),children:`进入对话`})]})}),(0,P.jsx)(te,{metrics:h,columns:5}),(0,P.jsx)(A,{error:a,onRetry:()=>p()}),r?.unavailableCount>0&&(0,P.jsx)(f,{className:`dashboard-notice`,type:`info`,fullMode:!1,closeIcon:null,title:r.unavailableCount===r.sourceCount?`数据暂不可用`:`部分数据不可用`,description:r.unavailableCount===r.sourceCount?`本次未能取得仪表盘数据,请检查服务连接后刷新重试。`:`${r.unavailableCount} 项数据源未能加载,相关数值以 — 显示。已返回的数据仍可查看,请稍后刷新重试。`}),_.length>0&&(0,P.jsx)(f,{className:`dashboard-notice`,type:`warning`,fullMode:!1,closeIcon:null,description:(0,P.jsxs)(d,{wrap:!0,spacing:8,children:[(0,P.jsx)(Y,{strong:!0,children:`需要关注`}),_.map(e=>(0,P.jsx)(u,{theme:`borderless`,type:`warning`,icon:(0,P.jsx)(S,{}),iconPosition:`right`,onClick:()=>t(e.page),children:e.text},e.id))]})}),(0,P.jsxs)(`div`,{className:`dashboard-grid`,children:[(0,P.jsxs)(`div`,{className:`dashboard-column`,children:[(0,P.jsx)(J,{stats:r?.vulnStats,pendingStats:r?.pendingVulnStats,latest:r?.vulnList?.vulnerabilities?.[0]?.created_at,loadedAt:r?.loadedAt,loading:i}),(0,P.jsx)(j,{title:e(`dashboard.recentVulns`,null,`最近漏洞`),extra:(0,P.jsx)(u,{theme:`borderless`,size:`small`,icon:(0,P.jsx)(S,{}),iconPosition:`right`,onClick:()=>t(`/vulnerabilities`),children:`查看全部`}),children:(0,P.jsx)(oe,{data:r?.vulnList,loading:i,onOpen:e=>t(`/vulnerabilities?id=${encodeURIComponent(e)}`)})}),(0,P.jsx)(j,{title:e(`dashboard.recentFacts`,null,`近期事实`),children:(0,P.jsx)(se,{summary:r?.projectSummary,loading:i,onOpen:C})})]}),(0,P.jsxs)(`div`,{className:`dashboard-column`,children:[(0,P.jsx)(j,{title:e(`dashboard.projects`,null,`项目概览`),extra:(0,P.jsx)(u,{theme:`borderless`,size:`small`,icon:(0,P.jsx)(S,{}),iconPosition:`right`,onClick:()=>t(`/projects`),children:`全部项目`}),children:(0,P.jsx)(ue,{summary:r?.projectSummary,loading:i,onOpen:C})}),(0,P.jsx)(j,{title:e(`dashboard.toolsTop`,null,`工具调用 Top`),extra:(0,P.jsx)(u,{theme:`borderless`,size:`small`,onClick:()=>t(`/mcp-monitor`),children:`调用监控`}),children:(0,P.jsx)(le,{data:r?.monitorStats,loading:i})}),(0,P.jsx)(j,{title:e(`dashboard.capability`,null,`能力与运行态`),children:(0,P.jsx)(x,{className:`dashboard-capabilities`,split:!1,dataSource:y,renderItem:e=>(0,P.jsx)(x.Item,{children:(0,P.jsxs)(u,{block:!0,theme:`borderless`,type:`tertiary`,className:`dashboard-capability`,onClick:()=>t(e.page),children:[(0,P.jsx)(`span`,{children:e.label}),(0,P.jsx)(`span`,{className:`dashboard-capability-value`,children:i?`…`:B(e.value)})]})},e.id)})})]})]})]})}function le({data:e,loading:t}){let n=Z(e,`topTools`),r=n?.slice(0,8).map(e=>({name:e.name||e.toolName||`未命名工具`,count:z(e.count??e.calls??e.totalCalls)}))||[],i=Math.max(...r.map(e=>e.count??0),1);return(0,P.jsx)(x,{className:`dashboard-list`,loading:t,dataSource:r,emptyContent:(0,P.jsx)($,{loading:t,unavailable:n===null,title:`暂无工具调用`,description:`执行任务后,可在这里查看使用最多的工具。`}),renderItem:(e,t)=>(0,P.jsxs)(x.Item,{className:`dashboard-tool-row`,children:[(0,P.jsx)(Y,{type:`tertiary`,size:`small`,className:`dashboard-tool-rank`,children:t+1}),(0,P.jsxs)(`div`,{className:`dashboard-record`,children:[(0,P.jsxs)(`div`,{className:`dashboard-tool-heading`,children:[(0,P.jsx)(Y,{className:`dashboard-tool-name`,title:e.name,children:e.name}),(0,P.jsxs)(Y,{type:`secondary`,size:`small`,className:`dashboard-count`,children:[B(e.count),` 次`]})]}),e.count!==null&&(0,P.jsx)(y,{percent:Math.round(e.count/i*100),showInfo:!1,size:`small`,stroke:`var(--semi-color-primary)`,"aria-label":`${e.name}调用次数`,"aria-valuetext":`${B(e.count)} 次`})]})]},`${e.name}-${t}`)})}function ue({summary:e,loading:t,onOpen:n}){let r=Z(e,`projects`),i=Z(e,`recent_facts`,`facts`),a=e?.totals||e,o=[[`活跃项目`,a?.active_projects??a?.activeProjects],[`事实总数`,a?.total_facts??a?.totalFacts],[`最近事实`,i?.length]];return(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`dl`,{className:`dashboard-project-totals`,children:o.map(([e,n])=>(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`dt`,{children:e}),(0,P.jsx)(`dd`,{children:t?`…`:B(n)})]},e))}),(0,P.jsx)(x,{className:`dashboard-list dashboard-feed`,loading:t,dataSource:r?.slice(0,6)||[],emptyContent:(0,P.jsx)($,{loading:t,unavailable:!e,title:r===null?`在项目中继续工作`:`暂无项目`,description:r===null?`当前摘要提供项目与事实统计,完整列表请查看全部项目。`:`创建项目后,在这里跟进项目进展。`}),renderItem:e=>(0,P.jsx)(x.Item,{main:(0,P.jsxs)(`div`,{className:`dashboard-record`,children:[(0,P.jsx)(u,{theme:`borderless`,className:`dashboard-record-link`,onClick:()=>n(e.id),children:e.name||`未命名项目`}),(0,P.jsxs)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:[e.status||`—`,` · `,w(e.updated_at)]})]})},e.id)})]})}export{ce as default};
\ No newline at end of file
diff --git a/web/static/app/assets/deep-assessments-ClJUMWIn.js b/web/static/app/assets/deep-assessments-cnrXHaFd.js
similarity index 99%
rename from web/static/app/assets/deep-assessments-ClJUMWIn.js
rename to web/static/app/assets/deep-assessments-cnrXHaFd.js
index d49d869e..7be23d59 100644
--- a/web/static/app/assets/deep-assessments-ClJUMWIn.js
+++ b/web/static/app/assets/deep-assessments-cnrXHaFd.js
@@ -1,2 +1,2 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{C as i,H as a,I as o,M as s,P as c,R as l,U as u,V as d,_ as f,b as p,c as m,i as h,it as g,j as _,m as v,ot as y,rt as b,s as x,u as S,w as C,xt as w,y as T}from"./semi-DNxeCrHm.js";import{D as E,E as D,F as O,I as k,L as A,P as j,S as M,_ as N,a as P,b as F,c as I,d as L,f as R,h as ee,l as z,m as B,n as te,o as V,p as H,r as ne,s as U,t as re,u as W,v as G,x as K,y as q}from"./index-BoFwOeaz.js";import{n as ie,r as J}from"./model-channel-mQ6lfvSO.js";var Y=e(t(),1),ae={draft:`草稿`,running:`执行中`,pending:`待执行`,completed:`已完成`,blocked:`受阻`,failed:`失败`,paused:`已暂停`,pausing:`暂停中`,cancelling:`停止中`,cancelled:`已停止`,recovering:`待恢复`,waiting_retry:`等待模型恢复`,waiting_input:`待答复`,waiting_progress:`等待新进展`,needs_review:`待核对`,uncertain:`结果不明`,interrupted:`已中断`,cleanup_unconfirmed:`待确认资源停止`,retired:`已撤下`,reconciled:`已核对`,yielded:`分段完成`,archived:`已归档`},oe=[`running`,`pausing`,`cancelling`],se=[`completed`,`cancelled`],X=[`needs_review`,`uncertain`,`cleanup_unconfirmed`],ce={goal:`目标`,step:`探索意图`,observation:`观察`,receipt:`执行回执`,memory:`Pi 摘要`,digest:`历史归档`,guidance:`人工线索`,fact:`事实`,finding:`漏洞`},le={observed:`直接观察`,inferred:`推断待证`,reported:`待独立复核`,confirmed:`复核确认`,refuted:`复核否定`,inconclusive:`复核未定`,unreviewed:`历史记录待核对`,summary:`压缩摘要`,note:`观察记录`,user:`用户提供`,folded:`已折叠`,superseded:`已替代的归档`,completed:`已完成`,running:`处理中`,failed:`失败`,uncertain:`结果待核对`,cancelled:`已取消`,reconciled:`已核对`,interrupted:`已中断`,error:`执行失败`,missing:`缺证据`,needs_review:`待复核`,has_evidence:`已有证据`},ue={started:`开始/继续测评`,reopened:`继续已停止的测评`,step_started:`意图开始执行`,planning:`更新计划`,plan_updated:`计划已更新`,checkpoint:`已保存进展`,step_result:`意图执行结果`,settled:`调度已结束`,stop_requested:`暂停/停止请求`,intent_pause:`暂停此意图`,intent_resume:`意图已恢复排队`,intent_priority:`优先级已调整`,intent_guidance:`收到定向补充`,waiting_progress:`等待新进展`,waiting_retry:`等待模型恢复`,waiting_input:`等待答复`,blocked:`执行受阻`,guidance:`收到补充方向`,retry_scheduled:`稍后重试模型`,review_gap:`验收仍有缺口`,shutdown:`保存进度并关闭`,retry:`步骤已重新排队`,reconciled:`已确认核对`},de={observed:`已观察`,inferred:`推断`},fe={observed:`green`,inferred:`amber`},pe={has_evidence:`已有证据`,missing:`缺证据`,needs_review:`待人工复核`},me={has_evidence:`green`,missing:`red`,needs_review:`amber`},he=`assessments:write`,ge=`assessments:delete`;function Z(e,t){return t?e(`deepAssessments.states.${t}`,null,ae[t]||t):`—`}function _e(e,t){return e(`deepAssessments.graphKinds.${t}`,null,ce[t]||t||`节点`)}function ve(e,t){return t?e(`deepAssessments.graphStates.${t}`,null,le[t]||Z(e,t)):`—`}function ye(e,t){return t?e(`deepAssessments.workbench.events.${t}`,null,ue[t]||t):`事件`}function be(e,t){return e(`deepAssessments.confidence.${t}`,null,de[t]||t||`—`)}function xe(e,t){return e(`deepAssessments.acceptanceStatus.${t}`,null,pe[t]||t||`—`)}function Se(e){return oe.includes(e?.status)}function Ce(e){return se.includes(e?.status)}function we(e){return e?Number(e.review_count)>0||X.includes(e.status)?!0:(e.steps||[]).some(e=>X.includes(e.status)):!1}function Te(e){return!!e&&!e.archived&&!Ce(e)&&!Se(e)&&!e.question&&e.status!==`waiting_input`}function Ee(e){return!!e&&!e.archived&&[`running`,`recovering`,`waiting_retry`,`waiting_progress`].includes(e.status)}function De(e){return!!e&&!e.archived&&!Ce(e)}function Oe(e){return!!e&&e.status===`cancelled`&&!e.archived}function ke(e){return!!e&&!e.archived&&!Se(e)&&!we(e)&&![`recovering`,`needs_review`,`uncertain`,`cleanup_unconfirmed`].includes(e.status)}function Ae(e){return!!e?.archived}function je(e){return!!e&&!Se(e)}function Me(e,t){let n=e||{},r=(n.completed||0)+(n.retired||0),i=Number.isFinite(t)&&t>0?t:Object.values(n).reduce((e,t)=>e+Number(t||0),0),a=i>0?Math.round(r/i*100):0;return{done:r,total:i,percent:Math.min(100,Math.max(0,a))}}function Ne(e){let t=Number(e);return!Number.isFinite(t)||t<0?`—`:t<60?`${Math.round(t)} 秒`:t<3600?`${Math.floor(t/60)} 分 ${Math.round(t%60)} 秒`:`${Math.floor(t/3600)} 小时 ${Math.round(t%3600/60)} 分`}function Pe(e,t=80){let n=String(e??``);return n.length>t?`${n.slice(0,t)}…`:n}function Fe(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t||t[0]!==`{`&&t[0]!==`[`)return e;try{return JSON.parse(t)}catch{return e}}var Ie={goal:`#0066ff`,step:`#13a8a8`,fact:`#00b42a`,finding:`#f53f3f`,observation:`#722ed1`,receipt:`#86909c`,memory:`#ff7d00`,digest:`#c9cdd4`,guidance:`#eb2f96`},Q=e(n(),1),Le=[{value:``,label:`系统默认`},{value:`off`,label:`关闭审批`},{value:`human`,label:`人工审批`},{value:`audit_agent`,label:`审计代理审批`},{value:`review_edit`,label:`复核并允许编辑`}];function Re({visible:e,onCancel:t,onCreated:n}){let r=j(),[s,c]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(!1),m=(0,Y.useCallback)(()=>{c(null),d(null),k.get(`/deep-assessments/options`).then(e=>c(e||{})).catch(e=>d(e))},[]);(0,Y.useEffect)(()=>{e&&m()},[e,m]);let g=async e=>{p(!0);try{let t={name:String(e.name||``).trim(),objective:String(e.objective||``).trim(),scope:String(e.scope||``).trim(),criteria:String(e.criteria||``).trim(),project_id:e.project_id||``,role:e.role||``,model:e.model||``,hitl_policy:e.hitl_policy||``,concurrency:Number(e.concurrency)||2,auto_resume:e.auto_resume!==!1},i=await k.post(`/deep-assessments`,t);K(r(`deepAssessments.saved`,null,`已创建测评`)),n?.(i?.task)}catch(e){F(e,r(`deepAssessments.saveFailed`,null,`创建失败`))}finally{p(!1)}},_=ie((s?.models||[]).map(e=>[e.id,e])),v=(s?.roles||[]).map(e=>({value:e,label:e})),y=(s?.projects||[]).map(e=>({value:e.id,label:e.name||e.id}));return(0,Q.jsxs)(i,{visible:e,title:r(`deepAssessments.create`,null,`新建测评`),onCancel:t,footer:null,width:680,closeOnEsc:!f,maskClosable:!f,children:[u?(0,Q.jsxs)(`div`,{className:`assessment-error-block`,children:[(0,Q.jsx)(z,{error:u}),(0,Q.jsx)(o,{size:`small`,onClick:m,children:`重试`})]}):null,!s&&!u?(0,Q.jsx)(`div`,{className:`assessment-loading`,children:(0,Q.jsx)(a,{})}):(0,Q.jsxs)(h,{initValues:{concurrency:2,auto_resume:!0,hitl_policy:``},labelPosition:`top`,onSubmit:g,children:[(0,Q.jsx)(h.Input,{field:`name`,label:r(`deepAssessments.name`,null,`测评名称`),maxLength:200,placeholder:`留空则取目标前 80 个字符`}),(0,Q.jsx)(h.TextArea,{field:`objective`,label:r(`deepAssessments.objective`,null,`目标`),rows:3,maxLength:16e3,placeholder:`要达成的最终结果,例如:评估 example.com 对外接口的认证与越权风险并给出可复现证据。`,rules:[{required:!0,message:`请填写测评目标`}]}),(0,Q.jsx)(h.TextArea,{field:`scope`,label:r(`deepAssessments.scopeOptional`,null,`补充限制与排除项(选填)`),rows:2,maxLength:16e3,placeholder:`例如:排除支付接口;不修改生产数据;不做压力测试。留空沿用目标。`}),(0,Q.jsx)(h.TextArea,{field:`criteria`,label:r(`deepAssessments.criteriaOptional`,null,`验收条件(选填)`),rows:3,maxLength:8e3,placeholder:`每行一条验收条件,例如:确认的漏洞附复现步骤和原始证据。留空沿用目标。`}),(0,Q.jsxs)(`div`,{className:`assessment-form-grid`,children:[(0,Q.jsx)(h.Select,{field:`model`,label:r(`deepAssessments.model`,null,`模型渠道`),optionList:[{value:``,label:`系统默认`},..._],renderSelectedItem:J,style:{width:`100%`}}),(0,Q.jsx)(h.Select,{field:`role`,label:r(`deepAssessments.role`,null,`角色`),optionList:[{value:``,label:`系统默认`},...v],style:{width:`100%`}}),(0,Q.jsx)(h.Select,{field:`project_id`,label:r(`deepAssessments.project`,null,`关联项目`),optionList:[{value:``,label:`不关联`},...y],style:{width:`100%`}}),(0,Q.jsx)(h.InputNumber,{field:`concurrency`,label:r(`deepAssessments.concurrency`,null,`并行步骤`),min:1,max:4,style:{width:`100%`}})]}),(0,Q.jsx)(h.Select,{field:`hitl_policy`,label:`人工审批策略`,optionList:Le,style:{width:`100%`}}),(0,Q.jsx)(h.Switch,{field:`auto_resume`,label:r(`deepAssessments.autoResume`,null,`服务重启后自动恢复结果明确的步骤`)}),(0,Q.jsx)(l,{type:`info`,bordered:!0,closeIcon:null,className:`assessment-form-note`,description:`创建后保存为草稿;打开页面不会自动启动,需要手动点击“开始 / 继续”。`}),(0,Q.jsxs)(`div`,{className:`assessment-form-actions`,children:[(0,Q.jsx)(o,{theme:`borderless`,onClick:t,disabled:f,children:r(`deepAssessments.close`,null,`关闭`)}),(0,Q.jsx)(o,{htmlType:`submit`,theme:`solid`,type:`primary`,loading:f,children:r(`deepAssessments.save`,null,`保存草稿`)})]})]})]})}var{Text:ze}=u,Be=[`draft`,`running`,`paused`,`blocked`,`failed`,`waiting_input`,`waiting_retry`,`recovering`,`uncertain`,`cleanup_unconfirmed`,`completed`,`cancelled`].map(e=>({value:e,label:ae[e]}));function Ve({onOpen:e}){let t=j(),{hasPermission:n}=O(),[r,i]=(0,Y.useState)(``),[a,s]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(0),[h,_]=(0,Y.useState)(!1),[x,C]=(0,Y.useState)({}),T=te(r,300),A=n(he),M=n(ge),N=(0,Y.useMemo)(()=>({q:T,status:a,limit:20,offset:p*20,archived:l?`true`:``}),[T,a,p,l]),I=P(()=>k.get(`/deep-assessments`,N),[N]),L=(0,Y.useMemo)(()=>I.data?.tasks||[],[I.data]);(0,Y.useEffect)(()=>{m(0)},[T,a,l]),(0,Y.useEffect)(()=>{let e=L.filter(e=>!x[`${e.id}:${e.updated_at}`]);if(!e.length)return;let t=!1,n=0,r={},i=async()=>{for(;!t&&n{!t&&Object.keys(r).length&&C(e=>({...e,...r}))}),()=>{t=!0}},[L]);let R=e=>{q({title:t(`deepAssessments.delete`,null,`删除`),content:`删除测评「${e.name||e.id}」?关联执行会话仍保留。`,okText:t(`deepAssessments.delete`,null,`删除`),onOk:async()=>{try{await k.del(`/deep-assessments/${e.id}`),K(t(`deepAssessments.deleted`,null,`已删除`)),await I.reload()}catch(e){F(e,t(`deepAssessments.deleteFailed`,null,`删除失败`))}}})},ee=[{title:t(`deepAssessments.name`,null,`测评名称`),dataIndex:`name`,width:260,render:(t,n)=>(0,Q.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,Q.jsx)(o,{theme:`borderless`,className:`assessment-link`,onClick:()=>e?.(n.id),children:t||n.id}),(0,Q.jsx)(ze,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:n.id})]})},{title:t(`deepAssessments.status`,null,`状态`),dataIndex:`status`,width:130,render:(e,n)=>(0,Q.jsxs)(c,{spacing:4,children:[(0,Q.jsx)(G,{status:e,label:Z(t,e)}),n.archived?(0,Q.jsx)(G,{status:`archived`,label:Z(t,`archived`)}):null,we(n)?(0,Q.jsx)(G,{status:`needs_review`,label:Z(t,`needs_review`)}):null]})},{title:t(`deepAssessments.objective`,null,`目标`),dataIndex:`summary`,render:(e,t)=>{let n=x[`${t.id}:${t.updated_at}`]?.objective||e||`—`;return(0,Q.jsx)(ze,{ellipsis:{showTooltip:!0},className:`assessment-ellipsis`,children:n})}},{title:`进度`,width:190,align:`left`,render:(e,t)=>{let n=x[`${t.id}:${t.updated_at}`];if(!n)return(0,Q.jsx)(ze,{type:`tertiary`,children:`—`});let r=Me(n.counts,n.total);return(0,Q.jsxs)(`div`,{className:`assessment-progress`,children:[(0,Q.jsx)(v,{percent:r.percent,showInfo:!0,size:`small`,strokeWidth:6}),(0,Q.jsxs)(ze,{type:`tertiary`,size:`small`,children:[r.done,` / `,r.total,` 意图`]})]})}},{title:t(`deepAssessments.rounds`,null,`规划轮次`),dataIndex:`rounds`,width:100,render:e=>E(e||0)},{title:t(`deepAssessments.createdAt`,null,`创建时间`),dataIndex:`created_at`,width:170,render:e=>D(e)},{title:`操作`,width:150,render:(n,r)=>(0,Q.jsxs)(c,{spacing:4,children:[(0,Q.jsx)(o,{theme:`borderless`,size:`small`,onClick:()=>e?.(r.id),children:`进入`}),(0,Q.jsx)(o,{theme:`borderless`,type:`danger`,size:`small`,icon:(0,Q.jsx)(w,{}),disabled:!M||!je(r),onClick:()=>R(r),children:t(`deepAssessments.delete`,null,`删除`)})]})}];return(0,Q.jsxs)(`div`,{className:`assessment-page`,children:[(0,Q.jsx)(H,{title:t(`deepAssessments.title`,null,`深度测评`),description:t(`deepAssessments.subtitle`,null,`围绕一个目标持续探索,保存证据与进度,跨会话继续执行。`),extra:[(0,Q.jsx)(o,{icon:(0,Q.jsx)(g,{}),onClick:()=>I.reload(),loading:I.loading,children:t(`deepAssessments.refresh`,null,`刷新`)},`refresh`),(0,Q.jsx)(o,{icon:(0,Q.jsx)(y,{}),theme:`solid`,type:`primary`,disabled:!A,onClick:()=>_(!0),children:t(`deepAssessments.create`,null,`新建测评`)},`create`)]}),(0,Q.jsx)(z,{error:I.error,onRetry:()=>I.reload()}),(0,Q.jsxs)(B,{title:t(`deepAssessments.listTitle`,null,`测评列表`),extra:(0,Q.jsx)(S,{checked:l,onChange:e=>u(!!e),checkedText:`已归档`,uncheckedText:`进行中`}),children:[(0,Q.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,Q.jsx)(d,{prefix:(0,Q.jsx)(b,{}),value:r,onChange:i,placeholder:t(`deepAssessments.search`,null,`搜索测评名称`),style:{width:260},showClear:!0}),(0,Q.jsx)(f,{value:a,onChange:e=>s(e||``),optionList:[{value:``,label:t(`deepAssessments.all`,null,`全部状态`)},...Be],style:{width:160}})]}),(0,Q.jsx)(U,{columns:ee,dataSource:L,rowKey:`id`,loading:I.loading,pagination:!1,emptyText:t(`deepAssessments.empty`,null,`暂无测评,先创建一个目标。`)}),(0,Q.jsx)(`div`,{className:`assessment-pager`,children:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(o,{size:`small`,disabled:p===0,onClick:()=>m(e=>Math.max(0,e-1)),children:t(`deepAssessments.previous`,null,`上一页`)}),(0,Q.jsxs)(ze,{type:`tertiary`,children:[`第 `,p+1,` 页`]}),(0,Q.jsx)(o,{size:`small`,disabled:!I.data?.has_more,onClick:()=>m(e=>e+1),children:t(`deepAssessments.next`,null,`下一页`)})]})})]}),(0,Q.jsx)(Re,{visible:h,onCancel:()=>_(!1),onCreated:t=>{_(!1),I.reload(),t?.id&&e?.(t.id)}})]})}var{Text:He,Paragraph:Ue}=u,We={blocked:`error`,waiting_input:`warning`,completed:`success`,stop_requested:`warning`,retry:`warning`};function Ge({task:e,canWrite:t,events:n,eventsError:r,autoRefresh:i,onAutoRefreshChange:a,onRefreshEvents:s,onGoTab:l,onGuidance:u,onAnswer:d}){let f=j(),p={};(e.steps||[]).forEach(e=>{p[e.status]=(p[e.status]||0)+1});let m=Me(p,(e.steps||[]).length),h=e.review_count||(e.steps||[]).filter(e=>[`uncertain`,`cleanup_unconfirmed`].includes(e.status)).length,g=[{id:`status`,label:f(`deepAssessments.status`,null,`状态`),value:(0,Q.jsx)(G,{status:e.status,label:Z(f,e.status)}),detail:e.archived?`已归档`:Ne(e.active_seconds)},{id:`progress`,label:`意图完成度`,value:`${m.percent}%`,detail:`${m.done} / ${m.total} 已结束`},{id:`rounds`,label:f(`deepAssessments.rounds`,null,`规划轮次`),value:E(e.rounds||0)},{id:`tokens`,label:f(`deepAssessments.tokens`,null,`累计 Token`),value:E(e.tokens_used||0)},{id:`review`,label:`待核对`,value:E(h),detail:h?`需要人工确认工具结果`:`无待核对记录`}],v=[{label:f(`deepAssessments.objective`,null,`目标`),value:(0,Q.jsx)(Ue,{className:`assessment-pre`,children:e.objective||`—`})},{label:f(`deepAssessments.scope`,null,`补充限制与排除项`),value:(0,Q.jsx)(Ue,{className:`assessment-pre`,children:e.scope||`—`})},{label:f(`deepAssessments.criteria`,null,`验收条件`),value:(0,Q.jsx)(Ue,{className:`assessment-pre`,children:e.criteria||`—`})},{label:f(`deepAssessments.strategy`,null,`最近规划路线`),value:(0,Q.jsx)(Ue,{className:`assessment-pre`,children:e.strategy||`—`})},{label:f(`deepAssessments.summary`,null,`当前结论 / 缺口`),value:(0,Q.jsx)(Ue,{className:`assessment-pre`,children:e.summary||`—`})}];e.question&&v.push({label:f(`deepAssessments.question`,null,`待补充信息`),value:(0,Q.jsx)(Ue,{className:`assessment-pre`,children:e.question})});let y=n.slice().reverse().slice(0,120);return(0,Q.jsxs)(`div`,{className:`assessment-tab`,children:[(0,Q.jsx)(N,{metrics:g,columns:5}),(0,Q.jsxs)(B,{title:`目标与测评要求`,extra:(0,Q.jsxs)(c,{children:[t&&!e.archived&&e.status!==`completed`&&e.status!==`cancelled`?(0,Q.jsx)(o,{size:`small`,onClick:u,children:`补充方向`}):null,e.question?(0,Q.jsx)(o,{size:`small`,theme:`solid`,type:`primary`,onClick:d,children:`答复`}):null,(0,Q.jsx)(o,{size:`small`,onClick:()=>l?.(`intents`),children:`查看意图`})]}),children:[(0,Q.jsx)(L,{items:v,columns:1}),(0,Q.jsxs)(`div`,{className:`assessment-facts-row`,children:[(0,Q.jsxs)(He,{type:`tertiary`,children:[`自动续跑:`,e.auto_resume?`已开启`:`已关闭`]}),(0,Q.jsxs)(He,{type:`tertiary`,children:[`并行步骤:`,e.concurrency||`—`]}),(0,Q.jsxs)(He,{type:`tertiary`,children:[`人工审批:`,e.hitl_policy||`系统默认`]}),(0,Q.jsxs)(He,{type:`tertiary`,children:[`最近更新:`,D(e.updated_at)]})]}),Array.isArray(e.guidance)&&e.guidance.length?(0,Q.jsxs)(`div`,{className:`assessment-guidance`,children:[(0,Q.jsx)(He,{strong:!0,children:`人工补充`}),e.guidance.map((e,t)=>(0,Q.jsxs)(`div`,{className:`assessment-guidance-item`,children:[(0,Q.jsxs)(He,{type:`tertiary`,children:[`#`,t+1]}),(0,Q.jsx)(Ue,{className:`assessment-pre`,children:e})]},`${t}-${e.slice(0,8)}`))]}):null,(0,Q.jsx)(Ue,{type:`tertiary`,className:`assessment-hint`,children:`打开页面不会自动启动任务;自动续跑只针对服务重启前的执行,草稿、手动暂停和待核对任务不会自动开始。`})]}),(0,Q.jsxs)(B,{title:f(`deepAssessments.activity`,null,`运行记录`),description:`事件按时间倒序展示;运行中每 10 秒自动拉取,页面隐藏时跳过。`,extra:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(He,{type:`tertiary`,size:`small`,children:`自动刷新`}),(0,Q.jsx)(S,{size:`small`,checked:i,onChange:e=>a?.(!!e)}),(0,Q.jsx)(o,{size:`small`,onClick:s,children:`立即刷新`})]}),children:[(0,Q.jsx)(z,{error:r,onRetry:s}),y.length===0?(0,Q.jsx)(C,{title:`暂无运行记录`,description:`开始测评后,规划、执行与核对事件会显示在这里。`,style:{padding:32}}):(0,Q.jsx)(`div`,{className:`assessment-timeline`,children:(0,Q.jsx)(x,{children:y.map(e=>(0,Q.jsxs)(x.Item,{time:D(e.created_at),type:We[e.kind]||`default`,children:[(0,Q.jsxs)(`div`,{className:`assessment-event-head`,children:[(0,Q.jsx)(He,{strong:!0,children:ye(f,e.kind)}),e.step_id?(0,Q.jsx)(_,{size:`small`,color:`grey`,children:e.step_id}):null]}),e.message?(0,Q.jsx)(`div`,{className:`assessment-event-message`,children:e.message}):null]},e.id))})})]})]})}var{Text:Ke,Paragraph:qe}=u,Je=[`running`,`pending`,`pausing`,`paused`,`completed`,`blocked`,`failed`,`uncertain`,`cleanup_unconfirmed`,`interrupted`,`retired`,`reconciled`];function Ye({id:e,reloadToken:t,status:n,onStatusChange:r,onChanged:i,archived:a}){let s=j(),{hasPermission:l}=O(),u=l(he),[d,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(0),[g,v]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{h(0)},[n]);let y=P(()=>k.get(`/deep-assessments/${e}/intents`,{status:n,offset:m}),[e,n,m,t]),b=y.data,x=b?.intents||[],S=b?.counts||{},C=t=>{q({title:`确认已核对`,content:`确认只解除本步骤的待核对状态,不会自动执行;原有进度和证据保留。`,okText:`确认已核对`,danger:!1,onOk:async()=>{p(!0);try{let n=await k.get(`/deep-assessments/${e}/steps/${t.id}`);await k.post(`/deep-assessments/${e}/control/reconcile`,{revision:n?.revision,step_id:t.id,reconciled:!0,cleanup_confirmed:!0}),K(`已记录核对,待核对列表已更新`),v(null),await y.reload(),i?.()}catch(e){F(e,`核对失败`)}finally{p(!1)}}})},w=(0,Y.useMemo)(()=>{let e=Je.filter(e=>S[e]);return Object.keys(S).forEach(t=>{e.includes(t)||e.push(t)}),[{value:``,label:`${s(`deepAssessments.all`,null,`全部状态`)} · ${b?.total??0}`},...e.map(e=>({value:e,label:`${Z(s,e)} · ${S[e]}`}))]},[S,b?.total,s]),T=[{title:s(`deepAssessments.status`,null,`状态`),dataIndex:`status`,width:140,render:e=>(0,Q.jsx)(G,{status:e,label:Z(s,e)})},{title:`意图`,dataIndex:`title`,render:(e,t)=>(0,Q.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,Q.jsx)(Ke,{ellipsis:{showTooltip:!0},children:e||t.id}),t.summary?(0,Q.jsx)(Ke,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:Pe(t.summary,120)}):null]})},{title:s(`deepAssessments.priority`,null,`优先级`),dataIndex:`priority`,width:90,render:e=>e||100},{title:s(`deepAssessments.assets`,null,`关联资产`),dataIndex:`asset_ids`,width:100,render:e=>(e||[]).length||`—`},{title:`证据回执`,dataIndex:`evidence`,width:100,render:e=>(e||[]).length||`—`},{title:`执行分段`,dataIndex:`attempts`,width:90,render:e=>E(e||0)},{title:`最近进展`,dataIndex:`last_progress`,render:e=>e?(0,Q.jsx)(Ke,{type:`tertiary`,ellipsis:{showTooltip:!0},children:e}):`—`}];return(0,Q.jsxs)(`div`,{className:`assessment-tab`,children:[(0,Q.jsxs)(B,{title:s(`deepAssessments.plan`,null,`意图队列`),description:`队列按优先级排序;状态只表示执行情况,不代表漏洞或完成结论。`,extra:(0,Q.jsx)(o,{size:`small`,onClick:()=>y.reload(),loading:y.loading,children:`刷新`}),children:[(0,Q.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,Q.jsx)(f,{value:n,onChange:e=>r?.(e||``),optionList:w,style:{width:200}}),(0,Q.jsxs)(Ke,{type:`tertiary`,children:[`共 `,b?.total??0,` 条意图`]})]}),(0,Q.jsx)(z,{error:y.error,onRetry:()=>y.reload()}),(0,Q.jsx)(U,{columns:T,dataSource:x,rowKey:`id`,loading:y.loading,pagination:!1,onRow:e=>({onClick:()=>v(e),style:{cursor:`pointer`}}),emptyText:s(`deepAssessments.noIntents`,null,`暂无意图,开始测评后由规划器逐步生成探索方向。`)}),(0,Q.jsx)(`div`,{className:`assessment-pager`,children:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(o,{size:`small`,disabled:m===0,onClick:()=>h(e=>Math.max(0,e-20)),children:s(`deepAssessments.previous`,null,`上一页`)}),(0,Q.jsx)(Ke,{type:`tertiary`,children:x.length?`${m+1} - ${m+x.length}`:`0`}),(0,Q.jsx)(o,{size:`small`,disabled:!b?.has_more,onClick:()=>h(e=>e+20),children:s(`deepAssessments.next`,null,`下一页`)})]})})]}),(0,Q.jsx)(I,{visible:!!g,onCancel:()=>v(null),title:g?.title||`意图详情`,width:560,footer:null,children:g?(0,Q.jsxs)(`div`,{className:`assessment-drawer`,children:[(0,Q.jsx)(L,{columns:2,items:[{label:s(`deepAssessments.status`,null,`状态`),value:(0,Q.jsx)(G,{status:g.status,label:Z(s,g.status)})},{label:`意图 ID`,value:g.id},{label:s(`deepAssessments.priority`,null,`优先级`),value:g.priority||100},{label:`执行分段`,value:g.attempts||0},{label:`手动暂停`,value:g.user_paused?`是`:`否`},{label:`执行会话`,value:g.conversation_id||`—`},{label:s(`deepAssessments.assets`,null,`关联资产`),value:(g.asset_ids||[]).join(`, `)||`—`},{label:`来源节点`,value:(g.source_ids||[]).join(`, `)||`—`},{label:`前置意图`,value:(g.depends_on||[]).join(`, `)||`—`},{label:`证据引用`,value:(g.evidence||[]).join(`, `)||`—`}]}),(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(Ke,{strong:!0,children:`执行说明`}),(0,Q.jsx)(qe,{className:`assessment-pre`,children:g.instruction||`—`})]}),(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(Ke,{strong:!0,children:`结果摘要`}),(0,Q.jsx)(qe,{className:`assessment-pre`,children:g.summary||`—`})]}),g.last_progress?(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(Ke,{strong:!0,children:`最近进展`}),(0,Q.jsx)(qe,{className:`assessment-pre`,children:g.last_progress})]}):null,Array.isArray(g.guidance)&&g.guidance.length?(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(Ke,{strong:!0,children:`定向补充`}),g.guidance.map((e,t)=>(0,Q.jsxs)(`div`,{className:`assessment-guidance-item`,children:[(0,Q.jsxs)(_,{size:`small`,color:`grey`,children:[`#`,t+1]}),(0,Q.jsx)(qe,{className:`assessment-pre`,children:e})]},`${t}-${e.slice(0,8)}`))]}):null,[`uncertain`,`cleanup_unconfirmed`].includes(g.status)?(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(Ke,{strong:!0,children:`待核对`}),(0,Q.jsx)(qe,{type:`tertiary`,className:`assessment-hint`,children:`确认只解除本步骤的待核对状态,不会自动执行;仍有结果不明的调用时请保持停止。`}),(0,Q.jsx)(o,{size:`small`,theme:`solid`,type:`primary`,disabled:!u||a,loading:d,onClick:()=>C(g),children:`确认已核对`})]}):null,g.conversations?.length?(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(Ke,{strong:!0,children:`历史执行会话`}),(0,Q.jsx)(qe,{className:`assessment-pre`,children:g.conversations.join(`
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{C as i,H as a,I as o,M as s,P as c,R as l,U as u,V as d,_ as f,b as p,c as m,i as h,it as g,j as _,m as v,ot as y,rt as b,s as x,u as S,w as C,xt as w,y as T}from"./semi-DNxeCrHm.js";import{D as E,E as D,F as O,I as k,L as A,P as j,S as M,_ as N,a as P,b as F,c as I,d as L,f as R,h as ee,l as z,m as B,n as te,o as V,p as H,r as ne,s as U,t as re,u as W,v as G,x as K,y as q}from"./index-smFoxEJu.js";import{n as ie,r as J}from"./model-channel-mQ6lfvSO.js";var Y=e(t(),1),ae={draft:`草稿`,running:`执行中`,pending:`待执行`,completed:`已完成`,blocked:`受阻`,failed:`失败`,paused:`已暂停`,pausing:`暂停中`,cancelling:`停止中`,cancelled:`已停止`,recovering:`待恢复`,waiting_retry:`等待模型恢复`,waiting_input:`待答复`,waiting_progress:`等待新进展`,needs_review:`待核对`,uncertain:`结果不明`,interrupted:`已中断`,cleanup_unconfirmed:`待确认资源停止`,retired:`已撤下`,reconciled:`已核对`,yielded:`分段完成`,archived:`已归档`},oe=[`running`,`pausing`,`cancelling`],se=[`completed`,`cancelled`],X=[`needs_review`,`uncertain`,`cleanup_unconfirmed`],ce={goal:`目标`,step:`探索意图`,observation:`观察`,receipt:`执行回执`,memory:`Pi 摘要`,digest:`历史归档`,guidance:`人工线索`,fact:`事实`,finding:`漏洞`},le={observed:`直接观察`,inferred:`推断待证`,reported:`待独立复核`,confirmed:`复核确认`,refuted:`复核否定`,inconclusive:`复核未定`,unreviewed:`历史记录待核对`,summary:`压缩摘要`,note:`观察记录`,user:`用户提供`,folded:`已折叠`,superseded:`已替代的归档`,completed:`已完成`,running:`处理中`,failed:`失败`,uncertain:`结果待核对`,cancelled:`已取消`,reconciled:`已核对`,interrupted:`已中断`,error:`执行失败`,missing:`缺证据`,needs_review:`待复核`,has_evidence:`已有证据`},ue={started:`开始/继续测评`,reopened:`继续已停止的测评`,step_started:`意图开始执行`,planning:`更新计划`,plan_updated:`计划已更新`,checkpoint:`已保存进展`,step_result:`意图执行结果`,settled:`调度已结束`,stop_requested:`暂停/停止请求`,intent_pause:`暂停此意图`,intent_resume:`意图已恢复排队`,intent_priority:`优先级已调整`,intent_guidance:`收到定向补充`,waiting_progress:`等待新进展`,waiting_retry:`等待模型恢复`,waiting_input:`等待答复`,blocked:`执行受阻`,guidance:`收到补充方向`,retry_scheduled:`稍后重试模型`,review_gap:`验收仍有缺口`,shutdown:`保存进度并关闭`,retry:`步骤已重新排队`,reconciled:`已确认核对`},de={observed:`已观察`,inferred:`推断`},fe={observed:`green`,inferred:`amber`},pe={has_evidence:`已有证据`,missing:`缺证据`,needs_review:`待人工复核`},me={has_evidence:`green`,missing:`red`,needs_review:`amber`},he=`assessments:write`,ge=`assessments:delete`;function Z(e,t){return t?e(`deepAssessments.states.${t}`,null,ae[t]||t):`—`}function _e(e,t){return e(`deepAssessments.graphKinds.${t}`,null,ce[t]||t||`节点`)}function ve(e,t){return t?e(`deepAssessments.graphStates.${t}`,null,le[t]||Z(e,t)):`—`}function ye(e,t){return t?e(`deepAssessments.workbench.events.${t}`,null,ue[t]||t):`事件`}function be(e,t){return e(`deepAssessments.confidence.${t}`,null,de[t]||t||`—`)}function xe(e,t){return e(`deepAssessments.acceptanceStatus.${t}`,null,pe[t]||t||`—`)}function Se(e){return oe.includes(e?.status)}function Ce(e){return se.includes(e?.status)}function we(e){return e?Number(e.review_count)>0||X.includes(e.status)?!0:(e.steps||[]).some(e=>X.includes(e.status)):!1}function Te(e){return!!e&&!e.archived&&!Ce(e)&&!Se(e)&&!e.question&&e.status!==`waiting_input`}function Ee(e){return!!e&&!e.archived&&[`running`,`recovering`,`waiting_retry`,`waiting_progress`].includes(e.status)}function De(e){return!!e&&!e.archived&&!Ce(e)}function Oe(e){return!!e&&e.status===`cancelled`&&!e.archived}function ke(e){return!!e&&!e.archived&&!Se(e)&&!we(e)&&![`recovering`,`needs_review`,`uncertain`,`cleanup_unconfirmed`].includes(e.status)}function Ae(e){return!!e?.archived}function je(e){return!!e&&!Se(e)}function Me(e,t){let n=e||{},r=(n.completed||0)+(n.retired||0),i=Number.isFinite(t)&&t>0?t:Object.values(n).reduce((e,t)=>e+Number(t||0),0),a=i>0?Math.round(r/i*100):0;return{done:r,total:i,percent:Math.min(100,Math.max(0,a))}}function Ne(e){let t=Number(e);return!Number.isFinite(t)||t<0?`—`:t<60?`${Math.round(t)} 秒`:t<3600?`${Math.floor(t/60)} 分 ${Math.round(t%60)} 秒`:`${Math.floor(t/3600)} 小时 ${Math.round(t%3600/60)} 分`}function Pe(e,t=80){let n=String(e??``);return n.length>t?`${n.slice(0,t)}…`:n}function Fe(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t||t[0]!==`{`&&t[0]!==`[`)return e;try{return JSON.parse(t)}catch{return e}}var Ie={goal:`#0066ff`,step:`#13a8a8`,fact:`#00b42a`,finding:`#f53f3f`,observation:`#722ed1`,receipt:`#86909c`,memory:`#ff7d00`,digest:`#c9cdd4`,guidance:`#eb2f96`},Q=e(n(),1),Le=[{value:``,label:`系统默认`},{value:`off`,label:`关闭审批`},{value:`human`,label:`人工审批`},{value:`audit_agent`,label:`审计代理审批`},{value:`review_edit`,label:`复核并允许编辑`}];function Re({visible:e,onCancel:t,onCreated:n}){let r=j(),[s,c]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(!1),m=(0,Y.useCallback)(()=>{c(null),d(null),k.get(`/deep-assessments/options`).then(e=>c(e||{})).catch(e=>d(e))},[]);(0,Y.useEffect)(()=>{e&&m()},[e,m]);let g=async e=>{p(!0);try{let t={name:String(e.name||``).trim(),objective:String(e.objective||``).trim(),scope:String(e.scope||``).trim(),criteria:String(e.criteria||``).trim(),project_id:e.project_id||``,role:e.role||``,model:e.model||``,hitl_policy:e.hitl_policy||``,concurrency:Number(e.concurrency)||2,auto_resume:e.auto_resume!==!1},i=await k.post(`/deep-assessments`,t);K(r(`deepAssessments.saved`,null,`已创建测评`)),n?.(i?.task)}catch(e){F(e,r(`deepAssessments.saveFailed`,null,`创建失败`))}finally{p(!1)}},_=ie((s?.models||[]).map(e=>[e.id,e])),v=(s?.roles||[]).map(e=>({value:e,label:e})),y=(s?.projects||[]).map(e=>({value:e.id,label:e.name||e.id}));return(0,Q.jsxs)(i,{visible:e,title:r(`deepAssessments.create`,null,`新建测评`),onCancel:t,footer:null,width:680,closeOnEsc:!f,maskClosable:!f,children:[u?(0,Q.jsxs)(`div`,{className:`assessment-error-block`,children:[(0,Q.jsx)(z,{error:u}),(0,Q.jsx)(o,{size:`small`,onClick:m,children:`重试`})]}):null,!s&&!u?(0,Q.jsx)(`div`,{className:`assessment-loading`,children:(0,Q.jsx)(a,{})}):(0,Q.jsxs)(h,{initValues:{concurrency:2,auto_resume:!0,hitl_policy:``},labelPosition:`top`,onSubmit:g,children:[(0,Q.jsx)(h.Input,{field:`name`,label:r(`deepAssessments.name`,null,`测评名称`),maxLength:200,placeholder:`留空则取目标前 80 个字符`}),(0,Q.jsx)(h.TextArea,{field:`objective`,label:r(`deepAssessments.objective`,null,`目标`),rows:3,maxLength:16e3,placeholder:`要达成的最终结果,例如:评估 example.com 对外接口的认证与越权风险并给出可复现证据。`,rules:[{required:!0,message:`请填写测评目标`}]}),(0,Q.jsx)(h.TextArea,{field:`scope`,label:r(`deepAssessments.scopeOptional`,null,`补充限制与排除项(选填)`),rows:2,maxLength:16e3,placeholder:`例如:排除支付接口;不修改生产数据;不做压力测试。留空沿用目标。`}),(0,Q.jsx)(h.TextArea,{field:`criteria`,label:r(`deepAssessments.criteriaOptional`,null,`验收条件(选填)`),rows:3,maxLength:8e3,placeholder:`每行一条验收条件,例如:确认的漏洞附复现步骤和原始证据。留空沿用目标。`}),(0,Q.jsxs)(`div`,{className:`assessment-form-grid`,children:[(0,Q.jsx)(h.Select,{field:`model`,label:r(`deepAssessments.model`,null,`模型渠道`),optionList:[{value:``,label:`系统默认`},..._],renderSelectedItem:J,style:{width:`100%`}}),(0,Q.jsx)(h.Select,{field:`role`,label:r(`deepAssessments.role`,null,`角色`),optionList:[{value:``,label:`系统默认`},...v],style:{width:`100%`}}),(0,Q.jsx)(h.Select,{field:`project_id`,label:r(`deepAssessments.project`,null,`关联项目`),optionList:[{value:``,label:`不关联`},...y],style:{width:`100%`}}),(0,Q.jsx)(h.InputNumber,{field:`concurrency`,label:r(`deepAssessments.concurrency`,null,`并行步骤`),min:1,max:4,style:{width:`100%`}})]}),(0,Q.jsx)(h.Select,{field:`hitl_policy`,label:`人工审批策略`,optionList:Le,style:{width:`100%`}}),(0,Q.jsx)(h.Switch,{field:`auto_resume`,label:r(`deepAssessments.autoResume`,null,`服务重启后自动恢复结果明确的步骤`)}),(0,Q.jsx)(l,{type:`info`,bordered:!0,closeIcon:null,className:`assessment-form-note`,description:`创建后保存为草稿;打开页面不会自动启动,需要手动点击“开始 / 继续”。`}),(0,Q.jsxs)(`div`,{className:`assessment-form-actions`,children:[(0,Q.jsx)(o,{theme:`borderless`,onClick:t,disabled:f,children:r(`deepAssessments.close`,null,`关闭`)}),(0,Q.jsx)(o,{htmlType:`submit`,theme:`solid`,type:`primary`,loading:f,children:r(`deepAssessments.save`,null,`保存草稿`)})]})]})]})}var{Text:ze}=u,Be=[`draft`,`running`,`paused`,`blocked`,`failed`,`waiting_input`,`waiting_retry`,`recovering`,`uncertain`,`cleanup_unconfirmed`,`completed`,`cancelled`].map(e=>({value:e,label:ae[e]}));function Ve({onOpen:e}){let t=j(),{hasPermission:n}=O(),[r,i]=(0,Y.useState)(``),[a,s]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(0),[h,_]=(0,Y.useState)(!1),[x,C]=(0,Y.useState)({}),T=te(r,300),A=n(he),M=n(ge),N=(0,Y.useMemo)(()=>({q:T,status:a,limit:20,offset:p*20,archived:l?`true`:``}),[T,a,p,l]),I=P(()=>k.get(`/deep-assessments`,N),[N]),L=(0,Y.useMemo)(()=>I.data?.tasks||[],[I.data]);(0,Y.useEffect)(()=>{m(0)},[T,a,l]),(0,Y.useEffect)(()=>{let e=L.filter(e=>!x[`${e.id}:${e.updated_at}`]);if(!e.length)return;let t=!1,n=0,r={},i=async()=>{for(;!t&&n{!t&&Object.keys(r).length&&C(e=>({...e,...r}))}),()=>{t=!0}},[L]);let R=e=>{q({title:t(`deepAssessments.delete`,null,`删除`),content:`删除测评「${e.name||e.id}」?关联执行会话仍保留。`,okText:t(`deepAssessments.delete`,null,`删除`),onOk:async()=>{try{await k.del(`/deep-assessments/${e.id}`),K(t(`deepAssessments.deleted`,null,`已删除`)),await I.reload()}catch(e){F(e,t(`deepAssessments.deleteFailed`,null,`删除失败`))}}})},ee=[{title:t(`deepAssessments.name`,null,`测评名称`),dataIndex:`name`,width:260,render:(t,n)=>(0,Q.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,Q.jsx)(o,{theme:`borderless`,className:`assessment-link`,onClick:()=>e?.(n.id),children:t||n.id}),(0,Q.jsx)(ze,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:n.id})]})},{title:t(`deepAssessments.status`,null,`状态`),dataIndex:`status`,width:130,render:(e,n)=>(0,Q.jsxs)(c,{spacing:4,children:[(0,Q.jsx)(G,{status:e,label:Z(t,e)}),n.archived?(0,Q.jsx)(G,{status:`archived`,label:Z(t,`archived`)}):null,we(n)?(0,Q.jsx)(G,{status:`needs_review`,label:Z(t,`needs_review`)}):null]})},{title:t(`deepAssessments.objective`,null,`目标`),dataIndex:`summary`,render:(e,t)=>{let n=x[`${t.id}:${t.updated_at}`]?.objective||e||`—`;return(0,Q.jsx)(ze,{ellipsis:{showTooltip:!0},className:`assessment-ellipsis`,children:n})}},{title:`进度`,width:190,align:`left`,render:(e,t)=>{let n=x[`${t.id}:${t.updated_at}`];if(!n)return(0,Q.jsx)(ze,{type:`tertiary`,children:`—`});let r=Me(n.counts,n.total);return(0,Q.jsxs)(`div`,{className:`assessment-progress`,children:[(0,Q.jsx)(v,{percent:r.percent,showInfo:!0,size:`small`,strokeWidth:6}),(0,Q.jsxs)(ze,{type:`tertiary`,size:`small`,children:[r.done,` / `,r.total,` 意图`]})]})}},{title:t(`deepAssessments.rounds`,null,`规划轮次`),dataIndex:`rounds`,width:100,render:e=>E(e||0)},{title:t(`deepAssessments.createdAt`,null,`创建时间`),dataIndex:`created_at`,width:170,render:e=>D(e)},{title:`操作`,width:150,render:(n,r)=>(0,Q.jsxs)(c,{spacing:4,children:[(0,Q.jsx)(o,{theme:`borderless`,size:`small`,onClick:()=>e?.(r.id),children:`进入`}),(0,Q.jsx)(o,{theme:`borderless`,type:`danger`,size:`small`,icon:(0,Q.jsx)(w,{}),disabled:!M||!je(r),onClick:()=>R(r),children:t(`deepAssessments.delete`,null,`删除`)})]})}];return(0,Q.jsxs)(`div`,{className:`assessment-page`,children:[(0,Q.jsx)(H,{title:t(`deepAssessments.title`,null,`深度测评`),description:t(`deepAssessments.subtitle`,null,`围绕一个目标持续探索,保存证据与进度,跨会话继续执行。`),extra:[(0,Q.jsx)(o,{icon:(0,Q.jsx)(g,{}),onClick:()=>I.reload(),loading:I.loading,children:t(`deepAssessments.refresh`,null,`刷新`)},`refresh`),(0,Q.jsx)(o,{icon:(0,Q.jsx)(y,{}),theme:`solid`,type:`primary`,disabled:!A,onClick:()=>_(!0),children:t(`deepAssessments.create`,null,`新建测评`)},`create`)]}),(0,Q.jsx)(z,{error:I.error,onRetry:()=>I.reload()}),(0,Q.jsxs)(B,{title:t(`deepAssessments.listTitle`,null,`测评列表`),extra:(0,Q.jsx)(S,{checked:l,onChange:e=>u(!!e),checkedText:`已归档`,uncheckedText:`进行中`}),children:[(0,Q.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,Q.jsx)(d,{prefix:(0,Q.jsx)(b,{}),value:r,onChange:i,placeholder:t(`deepAssessments.search`,null,`搜索测评名称`),style:{width:260},showClear:!0}),(0,Q.jsx)(f,{value:a,onChange:e=>s(e||``),optionList:[{value:``,label:t(`deepAssessments.all`,null,`全部状态`)},...Be],style:{width:160}})]}),(0,Q.jsx)(U,{columns:ee,dataSource:L,rowKey:`id`,loading:I.loading,pagination:!1,emptyText:t(`deepAssessments.empty`,null,`暂无测评,先创建一个目标。`)}),(0,Q.jsx)(`div`,{className:`assessment-pager`,children:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(o,{size:`small`,disabled:p===0,onClick:()=>m(e=>Math.max(0,e-1)),children:t(`deepAssessments.previous`,null,`上一页`)}),(0,Q.jsxs)(ze,{type:`tertiary`,children:[`第 `,p+1,` 页`]}),(0,Q.jsx)(o,{size:`small`,disabled:!I.data?.has_more,onClick:()=>m(e=>e+1),children:t(`deepAssessments.next`,null,`下一页`)})]})})]}),(0,Q.jsx)(Re,{visible:h,onCancel:()=>_(!1),onCreated:t=>{_(!1),I.reload(),t?.id&&e?.(t.id)}})]})}var{Text:He,Paragraph:Ue}=u,We={blocked:`error`,waiting_input:`warning`,completed:`success`,stop_requested:`warning`,retry:`warning`};function Ge({task:e,canWrite:t,events:n,eventsError:r,autoRefresh:i,onAutoRefreshChange:a,onRefreshEvents:s,onGoTab:l,onGuidance:u,onAnswer:d}){let f=j(),p={};(e.steps||[]).forEach(e=>{p[e.status]=(p[e.status]||0)+1});let m=Me(p,(e.steps||[]).length),h=e.review_count||(e.steps||[]).filter(e=>[`uncertain`,`cleanup_unconfirmed`].includes(e.status)).length,g=[{id:`status`,label:f(`deepAssessments.status`,null,`状态`),value:(0,Q.jsx)(G,{status:e.status,label:Z(f,e.status)}),detail:e.archived?`已归档`:Ne(e.active_seconds)},{id:`progress`,label:`意图完成度`,value:`${m.percent}%`,detail:`${m.done} / ${m.total} 已结束`},{id:`rounds`,label:f(`deepAssessments.rounds`,null,`规划轮次`),value:E(e.rounds||0)},{id:`tokens`,label:f(`deepAssessments.tokens`,null,`累计 Token`),value:E(e.tokens_used||0)},{id:`review`,label:`待核对`,value:E(h),detail:h?`需要人工确认工具结果`:`无待核对记录`}],v=[{label:f(`deepAssessments.objective`,null,`目标`),value:(0,Q.jsx)(Ue,{className:`assessment-pre`,children:e.objective||`—`})},{label:f(`deepAssessments.scope`,null,`补充限制与排除项`),value:(0,Q.jsx)(Ue,{className:`assessment-pre`,children:e.scope||`—`})},{label:f(`deepAssessments.criteria`,null,`验收条件`),value:(0,Q.jsx)(Ue,{className:`assessment-pre`,children:e.criteria||`—`})},{label:f(`deepAssessments.strategy`,null,`最近规划路线`),value:(0,Q.jsx)(Ue,{className:`assessment-pre`,children:e.strategy||`—`})},{label:f(`deepAssessments.summary`,null,`当前结论 / 缺口`),value:(0,Q.jsx)(Ue,{className:`assessment-pre`,children:e.summary||`—`})}];e.question&&v.push({label:f(`deepAssessments.question`,null,`待补充信息`),value:(0,Q.jsx)(Ue,{className:`assessment-pre`,children:e.question})});let y=n.slice().reverse().slice(0,120);return(0,Q.jsxs)(`div`,{className:`assessment-tab`,children:[(0,Q.jsx)(N,{metrics:g,columns:5}),(0,Q.jsxs)(B,{title:`目标与测评要求`,extra:(0,Q.jsxs)(c,{children:[t&&!e.archived&&e.status!==`completed`&&e.status!==`cancelled`?(0,Q.jsx)(o,{size:`small`,onClick:u,children:`补充方向`}):null,e.question?(0,Q.jsx)(o,{size:`small`,theme:`solid`,type:`primary`,onClick:d,children:`答复`}):null,(0,Q.jsx)(o,{size:`small`,onClick:()=>l?.(`intents`),children:`查看意图`})]}),children:[(0,Q.jsx)(L,{items:v,columns:1}),(0,Q.jsxs)(`div`,{className:`assessment-facts-row`,children:[(0,Q.jsxs)(He,{type:`tertiary`,children:[`自动续跑:`,e.auto_resume?`已开启`:`已关闭`]}),(0,Q.jsxs)(He,{type:`tertiary`,children:[`并行步骤:`,e.concurrency||`—`]}),(0,Q.jsxs)(He,{type:`tertiary`,children:[`人工审批:`,e.hitl_policy||`系统默认`]}),(0,Q.jsxs)(He,{type:`tertiary`,children:[`最近更新:`,D(e.updated_at)]})]}),Array.isArray(e.guidance)&&e.guidance.length?(0,Q.jsxs)(`div`,{className:`assessment-guidance`,children:[(0,Q.jsx)(He,{strong:!0,children:`人工补充`}),e.guidance.map((e,t)=>(0,Q.jsxs)(`div`,{className:`assessment-guidance-item`,children:[(0,Q.jsxs)(He,{type:`tertiary`,children:[`#`,t+1]}),(0,Q.jsx)(Ue,{className:`assessment-pre`,children:e})]},`${t}-${e.slice(0,8)}`))]}):null,(0,Q.jsx)(Ue,{type:`tertiary`,className:`assessment-hint`,children:`打开页面不会自动启动任务;自动续跑只针对服务重启前的执行,草稿、手动暂停和待核对任务不会自动开始。`})]}),(0,Q.jsxs)(B,{title:f(`deepAssessments.activity`,null,`运行记录`),description:`事件按时间倒序展示;运行中每 10 秒自动拉取,页面隐藏时跳过。`,extra:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(He,{type:`tertiary`,size:`small`,children:`自动刷新`}),(0,Q.jsx)(S,{size:`small`,checked:i,onChange:e=>a?.(!!e)}),(0,Q.jsx)(o,{size:`small`,onClick:s,children:`立即刷新`})]}),children:[(0,Q.jsx)(z,{error:r,onRetry:s}),y.length===0?(0,Q.jsx)(C,{title:`暂无运行记录`,description:`开始测评后,规划、执行与核对事件会显示在这里。`,style:{padding:32}}):(0,Q.jsx)(`div`,{className:`assessment-timeline`,children:(0,Q.jsx)(x,{children:y.map(e=>(0,Q.jsxs)(x.Item,{time:D(e.created_at),type:We[e.kind]||`default`,children:[(0,Q.jsxs)(`div`,{className:`assessment-event-head`,children:[(0,Q.jsx)(He,{strong:!0,children:ye(f,e.kind)}),e.step_id?(0,Q.jsx)(_,{size:`small`,color:`grey`,children:e.step_id}):null]}),e.message?(0,Q.jsx)(`div`,{className:`assessment-event-message`,children:e.message}):null]},e.id))})})]})]})}var{Text:Ke,Paragraph:qe}=u,Je=[`running`,`pending`,`pausing`,`paused`,`completed`,`blocked`,`failed`,`uncertain`,`cleanup_unconfirmed`,`interrupted`,`retired`,`reconciled`];function Ye({id:e,reloadToken:t,status:n,onStatusChange:r,onChanged:i,archived:a}){let s=j(),{hasPermission:l}=O(),u=l(he),[d,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(0),[g,v]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{h(0)},[n]);let y=P(()=>k.get(`/deep-assessments/${e}/intents`,{status:n,offset:m}),[e,n,m,t]),b=y.data,x=b?.intents||[],S=b?.counts||{},C=t=>{q({title:`确认已核对`,content:`确认只解除本步骤的待核对状态,不会自动执行;原有进度和证据保留。`,okText:`确认已核对`,danger:!1,onOk:async()=>{p(!0);try{let n=await k.get(`/deep-assessments/${e}/steps/${t.id}`);await k.post(`/deep-assessments/${e}/control/reconcile`,{revision:n?.revision,step_id:t.id,reconciled:!0,cleanup_confirmed:!0}),K(`已记录核对,待核对列表已更新`),v(null),await y.reload(),i?.()}catch(e){F(e,`核对失败`)}finally{p(!1)}}})},w=(0,Y.useMemo)(()=>{let e=Je.filter(e=>S[e]);return Object.keys(S).forEach(t=>{e.includes(t)||e.push(t)}),[{value:``,label:`${s(`deepAssessments.all`,null,`全部状态`)} · ${b?.total??0}`},...e.map(e=>({value:e,label:`${Z(s,e)} · ${S[e]}`}))]},[S,b?.total,s]),T=[{title:s(`deepAssessments.status`,null,`状态`),dataIndex:`status`,width:140,render:e=>(0,Q.jsx)(G,{status:e,label:Z(s,e)})},{title:`意图`,dataIndex:`title`,render:(e,t)=>(0,Q.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,Q.jsx)(Ke,{ellipsis:{showTooltip:!0},children:e||t.id}),t.summary?(0,Q.jsx)(Ke,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:Pe(t.summary,120)}):null]})},{title:s(`deepAssessments.priority`,null,`优先级`),dataIndex:`priority`,width:90,render:e=>e||100},{title:s(`deepAssessments.assets`,null,`关联资产`),dataIndex:`asset_ids`,width:100,render:e=>(e||[]).length||`—`},{title:`证据回执`,dataIndex:`evidence`,width:100,render:e=>(e||[]).length||`—`},{title:`执行分段`,dataIndex:`attempts`,width:90,render:e=>E(e||0)},{title:`最近进展`,dataIndex:`last_progress`,render:e=>e?(0,Q.jsx)(Ke,{type:`tertiary`,ellipsis:{showTooltip:!0},children:e}):`—`}];return(0,Q.jsxs)(`div`,{className:`assessment-tab`,children:[(0,Q.jsxs)(B,{title:s(`deepAssessments.plan`,null,`意图队列`),description:`队列按优先级排序;状态只表示执行情况,不代表漏洞或完成结论。`,extra:(0,Q.jsx)(o,{size:`small`,onClick:()=>y.reload(),loading:y.loading,children:`刷新`}),children:[(0,Q.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,Q.jsx)(f,{value:n,onChange:e=>r?.(e||``),optionList:w,style:{width:200}}),(0,Q.jsxs)(Ke,{type:`tertiary`,children:[`共 `,b?.total??0,` 条意图`]})]}),(0,Q.jsx)(z,{error:y.error,onRetry:()=>y.reload()}),(0,Q.jsx)(U,{columns:T,dataSource:x,rowKey:`id`,loading:y.loading,pagination:!1,onRow:e=>({onClick:()=>v(e),style:{cursor:`pointer`}}),emptyText:s(`deepAssessments.noIntents`,null,`暂无意图,开始测评后由规划器逐步生成探索方向。`)}),(0,Q.jsx)(`div`,{className:`assessment-pager`,children:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(o,{size:`small`,disabled:m===0,onClick:()=>h(e=>Math.max(0,e-20)),children:s(`deepAssessments.previous`,null,`上一页`)}),(0,Q.jsx)(Ke,{type:`tertiary`,children:x.length?`${m+1} - ${m+x.length}`:`0`}),(0,Q.jsx)(o,{size:`small`,disabled:!b?.has_more,onClick:()=>h(e=>e+20),children:s(`deepAssessments.next`,null,`下一页`)})]})})]}),(0,Q.jsx)(I,{visible:!!g,onCancel:()=>v(null),title:g?.title||`意图详情`,width:560,footer:null,children:g?(0,Q.jsxs)(`div`,{className:`assessment-drawer`,children:[(0,Q.jsx)(L,{columns:2,items:[{label:s(`deepAssessments.status`,null,`状态`),value:(0,Q.jsx)(G,{status:g.status,label:Z(s,g.status)})},{label:`意图 ID`,value:g.id},{label:s(`deepAssessments.priority`,null,`优先级`),value:g.priority||100},{label:`执行分段`,value:g.attempts||0},{label:`手动暂停`,value:g.user_paused?`是`:`否`},{label:`执行会话`,value:g.conversation_id||`—`},{label:s(`deepAssessments.assets`,null,`关联资产`),value:(g.asset_ids||[]).join(`, `)||`—`},{label:`来源节点`,value:(g.source_ids||[]).join(`, `)||`—`},{label:`前置意图`,value:(g.depends_on||[]).join(`, `)||`—`},{label:`证据引用`,value:(g.evidence||[]).join(`, `)||`—`}]}),(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(Ke,{strong:!0,children:`执行说明`}),(0,Q.jsx)(qe,{className:`assessment-pre`,children:g.instruction||`—`})]}),(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(Ke,{strong:!0,children:`结果摘要`}),(0,Q.jsx)(qe,{className:`assessment-pre`,children:g.summary||`—`})]}),g.last_progress?(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(Ke,{strong:!0,children:`最近进展`}),(0,Q.jsx)(qe,{className:`assessment-pre`,children:g.last_progress})]}):null,Array.isArray(g.guidance)&&g.guidance.length?(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(Ke,{strong:!0,children:`定向补充`}),g.guidance.map((e,t)=>(0,Q.jsxs)(`div`,{className:`assessment-guidance-item`,children:[(0,Q.jsxs)(_,{size:`small`,color:`grey`,children:[`#`,t+1]}),(0,Q.jsx)(qe,{className:`assessment-pre`,children:e})]},`${t}-${e.slice(0,8)}`))]}):null,[`uncertain`,`cleanup_unconfirmed`].includes(g.status)?(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(Ke,{strong:!0,children:`待核对`}),(0,Q.jsx)(qe,{type:`tertiary`,className:`assessment-hint`,children:`确认只解除本步骤的待核对状态,不会自动执行;仍有结果不明的调用时请保持停止。`}),(0,Q.jsx)(o,{size:`small`,theme:`solid`,type:`primary`,disabled:!u||a,loading:d,onClick:()=>C(g),children:`确认已核对`})]}):null,g.conversations?.length?(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(Ke,{strong:!0,children:`历史执行会话`}),(0,Q.jsx)(qe,{className:`assessment-pre`,children:g.conversations.join(`
`)})]}):null]}):null})]})}var{Text:Xe,Paragraph:Ze}=u;function Qe({id:e,reloadToken:t}){let n=j(),[r,i]=(0,Y.useState)(``),[a,s]=(0,Y.useState)(0),[l,u]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{s(0)},[r]);let d=P(()=>k.get(`/deep-assessments/${e}/facts`,{confidence:r,offset:a}),[e,r,a,t]),p=d.data,m=p?.facts||[],h=[{title:`置信度`,dataIndex:`confidence`,width:110,render:e=>(0,Q.jsx)(_,{color:fe[e]||`grey`,shape:`circle`,children:be(n,e)})},{title:`摘要`,dataIndex:`summary`,render:(e,t)=>(0,Q.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,Q.jsx)(Xe,{ellipsis:{showTooltip:!0},children:e||t.id}),t.body?(0,Q.jsx)(Xe,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:Pe(t.body,140)}):null]})},{title:`来源意图`,dataIndex:`step_id`,width:140,render:e=>e||`—`},{title:n(`deepAssessments.assets`,null,`关联资产`),dataIndex:`asset_ids`,width:140,render:e=>(e||[]).length?(0,Q.jsx)(Xe,{ellipsis:{showTooltip:!0},children:e.join(`, `)}):`—`},{title:`证据回执`,dataIndex:`evidence`,width:100,render:e=>(e||[]).length||`—`},{title:`时间`,dataIndex:`created_at`,width:170,render:e=>D(e)}];return(0,Q.jsxs)(`div`,{className:`assessment-tab`,children:[(0,Q.jsxs)(B,{title:n(`deepAssessments.facts`,null,`事实`),description:`observed 表示有原始成功回执支撑;inferred 只是推断,不是证据。`,extra:(0,Q.jsx)(o,{size:`small`,onClick:()=>d.reload(),loading:d.loading,children:`刷新`}),children:[(0,Q.jsx)(`div`,{className:`assessment-toolbar`,children:(0,Q.jsx)(f,{value:r,onChange:e=>i(e||``),optionList:[{value:``,label:n(`deepAssessments.all`,null,`全部状态`)},{value:`observed`,label:be(n,`observed`)},{value:`inferred`,label:be(n,`inferred`)}],style:{width:160}})}),(0,Q.jsx)(z,{error:d.error,onRetry:()=>d.reload()}),(0,Q.jsx)(U,{columns:h,dataSource:m,rowKey:`id`,loading:d.loading,pagination:!1,onRow:e=>({onClick:()=>u(e),style:{cursor:`pointer`}}),emptyText:n(`deepAssessments.noFacts`,null,`暂无事实记录。`)}),(0,Q.jsx)(`div`,{className:`assessment-pager`,children:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(o,{size:`small`,disabled:a===0,onClick:()=>s(e=>Math.max(0,e-20)),children:n(`deepAssessments.previous`,null,`上一页`)}),(0,Q.jsx)(Xe,{type:`tertiary`,children:m.length?`${a+1} - ${a+m.length}`:`0`}),(0,Q.jsx)(o,{size:`small`,disabled:!p?.has_more,onClick:()=>s(e=>e+20),children:n(`deepAssessments.next`,null,`下一页`)})]})})]}),(0,Q.jsx)(I,{visible:!!l,onCancel:()=>u(null),title:`事实详情`,width:620,footer:null,children:l?(0,Q.jsxs)(`div`,{className:`assessment-drawer`,children:[(0,Q.jsx)(L,{columns:2,items:[{label:`置信度`,value:(0,Q.jsx)(_,{color:fe[l.confidence]||`grey`,children:be(n,l.confidence)})},{label:`事实 ID`,value:l.id},{label:`来源意图`,value:l.step_id||`—`},{label:`时间`,value:D(l.created_at)},{label:n(`deepAssessments.assets`,null,`关联资产`),value:(l.asset_ids||[]).join(`, `)||`—`},{label:`证据回执`,value:(l.evidence||[]).join(`, `)||`—`},{label:`来源节点`,value:(l.source_ids||[]).join(`, `)||`—`}]}),(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(Xe,{strong:!0,children:`摘要`}),(0,Q.jsx)(Ze,{className:`assessment-pre`,children:l.summary||`—`})]}),(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(Xe,{strong:!0,children:`正文`}),(0,Q.jsx)(Ze,{className:`assessment-pre`,children:l.body||`—`})]}),(0,Q.jsx)(W,{title:`原始记录`,value:l,collapsed:!0})]}):null})]})}var{Text:$e}=u;function et({visible:e,task:t,onCancel:n,onSaved:r}){j();let[a,s]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(1),[f,p]=(0,Y.useState)([]),[m,h]=(0,Y.useState)(!1),g=te(a,300);(0,Y.useEffect)(()=>{e&&(s(``),u(1),p([]))},[e]),(0,Y.useEffect)(()=>{u(1)},[g]);let _=P(()=>k.get(`/assets`,{page:l,page_size:10,q:g,project_id:t?.project_id||``}),[l,g,t?.project_id,e],{skip:!e}),v=_.data?.assets||[];return(0,Q.jsxs)(i,{visible:e,title:`关联共享资产`,onCancel:n,onOk:async()=>{if(f.length){h(!0);try{await k.post(`/deep-assessments/${t.id}/assets`,{asset_ids:f}),K(`已关联资产`),r?.()}catch(e){F(e,`关联资产失败`)}finally{h(!1)}}},confirmLoading:m,okText:`关联${f.length?` ${f.length} 项`:``}`,cancelText:`取消`,okButtonProps:{disabled:!f.length},width:760,children:[(0,Q.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,Q.jsx)(d,{prefix:(0,Q.jsx)(b,{}),value:a,onChange:s,placeholder:`按地址、IP 或域名搜索`,style:{width:280},showClear:!0}),(0,Q.jsx)($e,{type:`tertiary`,children:`仅显示当前账号可读、且与测评同项目的资产。`})]}),(0,Q.jsx)(z,{error:_.error,onRetry:()=>_.reload()}),(0,Q.jsx)(U,{columns:[{title:`资产`,dataIndex:`host`,render:(e,t)=>(0,Q.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,Q.jsx)($e,{strong:!0,children:e||t.ip||t.domain||t.id}),(0,Q.jsx)($e,{type:`tertiary`,size:`small`,children:[t.ip,t.port?`:${t.port}`:``,t.protocol].filter(Boolean).join(` `)})]})},{title:`项目`,dataIndex:`project_name`,width:160,render:e=>e||`—`},{title:`状态`,dataIndex:`status`,width:90,render:e=>e||`—`}],dataSource:v,rowKey:`id`,loading:_.loading,pagination:!1,rowSelection:{selectedRowKeys:f,onChange:e=>p((e||[]).map(String))},emptyText:`没有匹配的资产,可先在资产库登记。`}),(0,Q.jsx)(`div`,{className:`assessment-pager`,children:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(o,{size:`small`,disabled:l<=1,onClick:()=>u(e=>Math.max(1,e-1)),children:`上一页`}),(0,Q.jsxs)($e,{type:`tertiary`,children:[`第 `,l,` 页`]}),(0,Q.jsx)(o,{size:`small`,disabled:!_.data?.total_pages||l>=_.data.total_pages,onClick:()=>u(e=>e+1),children:`下一页`})]})})]})}function tt({id:e,task:t,observation:n,reloadToken:r}){let i=j(),{hasPermission:a}=O(),[s,l]=(0,Y.useState)(0),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(null),m=P(()=>k.get(`/deep-assessments/${e}/assets`,{offset:s,observation:n}),[e,s,n,r]),h=m.data,g=h?.assets||[],v=h?.coverage||{},b=v.linked??h?.total??0,x=v.with_observed_evidence??0,S=b?Math.round(x/b*100):0,C=a(he),w=(0,Y.useMemo)(()=>[{id:`linked`,label:`关联资产`,value:b},{id:`observed`,label:`已有观察证据`,value:x},{id:`coverage`,label:`观察覆盖率`,value:`${S}%`,detail:`只统计当前账号可读的关联资产`},{id:`nodes`,label:`资产图节点`,value:h?.nodes?.length??0}],[b,x,S,h?.nodes?.length]);return(0,Q.jsxs)(`div`,{className:`assessment-tab`,children:[(0,Q.jsx)(N,{metrics:w,columns:4}),(0,Q.jsxs)(B,{title:i(`deepAssessments.assets`,null,`资产图`),description:`覆盖情况按已保存的 observed 事实计算,不代表测试穷尽或无漏洞。`,extra:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(o,{icon:(0,Q.jsx)(y,{}),size:`small`,disabled:!C||t?.archived,onClick:()=>d(!0),children:`添加资产`}),(0,Q.jsx)(o,{size:`small`,onClick:()=>m.reload(),loading:m.loading,children:`刷新`})]}),children:[(0,Q.jsx)(z,{error:m.error,onRetry:()=>m.reload()}),(0,Q.jsx)(U,{columns:[{title:`资产`,dataIndex:`host`,render:(e,t)=>(0,Q.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,Q.jsx)($e,{strong:!0,children:e||t.ip||t.domain||t.id}),(0,Q.jsx)($e,{type:`tertiary`,size:`small`,children:[t.ip,t.domain].filter(Boolean).join(` · `)||t.id})]})},{title:`项目`,dataIndex:`project_name`,width:160,render:e=>e||`—`},{title:`端口 / 协议`,width:130,render:(e,t)=>[t.port||null,t.protocol||null].filter(Boolean).join(` / `)||`—`},{title:`状态`,dataIndex:`status`,width:100,render:e=>e?(0,Q.jsx)(_,{size:`small`,children:e}):`—`},{title:`风险`,dataIndex:`risk_level`,width:90,render:e=>e||`—`},{title:`最近发现`,dataIndex:`last_seen_at`,width:170,render:e=>D(e)}],dataSource:g,rowKey:`id`,loading:m.loading,pagination:!1,onRow:e=>({onClick:()=>p(e),style:{cursor:`pointer`}}),emptyText:`本次测评尚未关联资产。`}),(0,Q.jsx)(`div`,{className:`assessment-pager`,children:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(o,{size:`small`,disabled:s===0,onClick:()=>l(e=>Math.max(0,e-20)),children:i(`deepAssessments.previous`,null,`上一页`)}),(0,Q.jsxs)($e,{type:`tertiary`,children:[`共 `,h?.total??0,` 项`]}),(0,Q.jsx)(o,{size:`small`,disabled:!h?.has_more,onClick:()=>l(e=>e+20),children:i(`deepAssessments.next`,null,`下一页`)})]})})]}),(0,Q.jsx)(et,{visible:u,task:t,onCancel:()=>d(!1),onSaved:()=>{d(!1),m.reload()}}),(0,Q.jsx)(I,{visible:!!f,onCancel:()=>p(null),title:`资产详情`,width:560,footer:null,children:f?(0,Q.jsxs)(`div`,{className:`assessment-drawer`,children:[(0,Q.jsx)(L,{columns:2,items:[{label:`资产`,value:f.host||f.ip||f.id},{label:`ID`,value:f.id},{label:`IP`,value:f.ip||`—`},{label:`域名`,value:f.domain||`—`},{label:`端口`,value:f.port||`—`},{label:`协议`,value:f.protocol||`—`},{label:`项目`,value:f.project_name||`—`},{label:`状态`,value:f.status||`—`},{label:`风险`,value:f.risk_level||`—`},{label:`最近发现`,value:D(f.last_seen_at)}]}),(0,Q.jsx)(W,{title:`原始资产记录`,value:f,collapsed:!0})]}):null})]})}var{Text:nt,Paragraph:rt}=u,it=[{selector:`node`,style:{"background-color":`data(color)`,label:`data(label)`,"font-size":10,"text-wrap":`wrap`,"text-max-width":120,"text-valign":`bottom`,"text-margin-y":5,color:`#4e5969`,width:26,height:26,"border-width":2,"border-color":`#ffffff`}},{selector:`node[boundary = 1]`,style:{shape:`round-rectangle`,width:18,height:18,opacity:.7}},{selector:`node:selected`,style:{"border-color":`#0066ff`,"border-width":4}},{selector:`edge`,style:{width:1,"line-color":`#c9cdd4`,"target-arrow-color":`#c9cdd4`,"target-arrow-shape":`triangle`,"arrow-scale":.7,"curve-style":`bezier`,opacity:.85}},{selector:`edge[projection = "archive"]`,style:{"line-style":`dashed`,"line-color":`#d9d9d9`}},{selector:`edge[projection = "details"]`,style:{"line-style":`dotted`}}];function at({id:e,reloadToken:t}){let n=j(),[r,i]=(0,Y.useState)(`summary`),[a,s]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(0),[d,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(null),[g,v]=(0,Y.useState)([]),[y,b]=(0,Y.useState)(0),[x,w]=(0,Y.useState)(!1),[T,E]=(0,Y.useState)(0),[O,A]=(0,Y.useState)(!1),[M,N]=(0,Y.useState)(!1),[I,R]=(0,Y.useState)(null),[ee,te]=(0,Y.useState)(!1),V=(0,Y.useRef)(null),H=(0,Y.useRef)(null),ne=(0,Y.useRef)(()=>{}),U=P(()=>k.get(`/deep-assessments/${e}/graph`,{view:r,scope:a,offset:l,limit:80}),[e,r,a,l,t]),G=U.data,K=G?.nodes||[],q=(0,Y.useCallback)(async(t,n={})=>{let{appendBody:r=!1,appendLinks:i=!1}=n;if(!t)return;p(t);let a=H.current;a&&(a.elements().unselect(),a.$id(t).select()),N(!0);try{let n=await k.get(`/deep-assessments/${e}/graph/node`,{node_id:t,offset:r?T:0,links_offset:i?y:0}),a=n?.node||null;h(e=>r&&e&&a&&e.id===a.id?{...a,body:`${e.body||``}${a.body||``}`}:a),E(Number(n?.next_offset)||0),A(!!n?.has_more),v(e=>i?[...e,...n?.relations||[]]:n?.relations||[]),b(Number(n?.relations_next_offset)||0),w(!!n?.relations_has_more),R(null)}catch(e){F(e,`读取节点失败`)}finally{N(!1)}},[e,T,y]);(0,Y.useEffect)(()=>{ne.current=q},[q]),(0,Y.useEffect)(()=>{let e=G?.nodes||[];if(!e.length||!V.current){H.current&&(H.current.destroy(),H.current=null);return}let t=!1,n=null,r=[],i=new Set;return e.forEach(e=>{i.has(e.id)||(i.add(e.id),r.push(e))}),re(()=>import(`./cytoscape.esm-BPjn7guX.js`).then(e=>{let a=e.default||e;if(t||!V.current)return;let o=[...r.map(e=>({data:{id:e.id,label:Pe(e.title||e.id,32),kind:e.kind,state:e.state,color:Ie[e.kind]||`#86909c`,boundary:+!!e.boundary}})),...(G.edges||[]).filter(e=>i.has(e.source)&&i.has(e.target)).map((e,t)=>({data:{id:`edge-${t}`,source:e.source,target:e.target,relation:e.relation,projection:e.projection||``}}))];n=a({container:V.current,elements:o,style:it,layout:{name:r.length>45?`cose`:`breadthfirst`,directed:!0,padding:28,animate:!1,spacingFactor:1.2},wheelSensitivity:.2,minZoom:.15,maxZoom:3}),n.on(`tap`,`node`,e=>ne.current?.(e.target.id())),H.current=n}),[]).catch(e=>{F(e,`图谱渲染失败`)}),()=>{t=!0,n&&n.destroy(),H.current===n&&(H.current=null)}},[G]);let ie=async()=>{if(m){te(!0);try{let t=await k.get(`/deep-assessments/${e}/evidence-path`,{fact_id:m.id});R(t)}catch(e){F(e,`读取证据路径失败`)}finally{te(!1)}}},J=(0,Q.jsxs)(c,{wrap:!0,children:[(0,Q.jsx)(S,{checkedText:`执行记录`,uncheckedText:`主链路`,checked:r===`full`,onChange:e=>{i(e?`full`:`summary`),u(0)}}),(0,Q.jsx)(o,{size:`small`,onClick:()=>{s(``),u(0)},disabled:!a&&l===0,children:`全图概览`}),(0,Q.jsx)(o,{size:`small`,onClick:()=>H.current?.fit(void 0,30),children:`适应画布`}),(0,Q.jsx)(o,{size:`small`,onClick:()=>{let e=H.current;e&&e.layout({name:e.nodes().length>45?`cose`:`breadthfirst`,directed:!0,padding:28,animate:!0,spacingFactor:1.2}).run()},children:`重新布局`}),(0,Q.jsx)(o,{size:`small`,onClick:()=>U.reload(),loading:U.loading,children:`刷新`})]}),ae=K.map(e=>({value:e.id,label:`${e.boundary?`引用 · `:``}${_e(n,e.kind)} · ${Pe(e.title||e.id,40)}`}));return(0,Q.jsx)(`div`,{className:`assessment-tab`,children:(0,Q.jsxs)(B,{title:n(`deepAssessments.graph`,null,`探索图`),description:`摘要用于续接;原始观察、执行回执与证据路径可展开查看。点击节点读取原文。`,extra:J,children:[(0,Q.jsx)(z,{error:U.error,onRetry:()=>U.reload()}),(0,Q.jsxs)(`div`,{className:`assessment-graph-meta`,children:[(0,Q.jsxs)(nt,{type:`tertiary`,children:[`当前页节点 `,G?.primary_count??Math.max(0,K.length-1),` / `,G?.total??0,` · `,`已折叠 `,G?.folded??0,` · `,`隐藏明细 `,G?.details_hidden??0,` · `,`跨页引用 `,G?.boundary_total??0]}),a?(0,Q.jsxs)(c,{children:[(0,Q.jsxs)(_,{size:`small`,color:`blue`,children:[`已聚焦 `,a]}),(0,Q.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>{s(``),u(0)},children:`返回全图`})]}):null]}),U.loading&&!G?(0,Q.jsx)(nt,{type:`tertiary`,children:`正在读取图谱…`}):null,(0,Q.jsxs)(`div`,{className:`assessment-graph-toolbar`,children:[(0,Q.jsx)(f,{value:d||``,onChange:e=>{e&&q(String(e))},optionList:ae,placeholder:`选择节点查看详情`,style:{width:320},showClear:!1}),(0,Q.jsxs)(c,{children:[(0,Q.jsx)(o,{size:`small`,disabled:l===0,onClick:()=>u(e=>Math.max(0,e-80)),children:n(`deepAssessments.previous`,null,`上一页`)}),(0,Q.jsxs)(nt,{type:`tertiary`,children:[`偏移 `,l]}),(0,Q.jsx)(o,{size:`small`,disabled:!G?.has_more,onClick:()=>u(e=>e+80),children:n(`deepAssessments.next`,null,`下一页`)})]})]}),G&&K.length===0?(0,Q.jsx)(C,{title:`暂无图谱节点`,description:`开始测评后会生成目标、意图、事实与证据节点。`,style:{padding:48}}):(0,Q.jsxs)(`div`,{className:`assessment-graph-layout`,children:[(0,Q.jsx)(`div`,{ref:V,className:`assessment-graph-canvas`,role:`img`,"aria-label":`探索图`}),(0,Q.jsx)(`div`,{className:`assessment-node-panel`,"aria-live":`polite`,children:d?(0,Q.jsxs)(`div`,{className:`assessment-node-body`,children:[(0,Q.jsxs)(`div`,{className:`assessment-node-head`,children:[(0,Q.jsx)(nt,{strong:!0,children:m?.title||d}),(0,Q.jsxs)(c,{spacing:4,children:[m?(0,Q.jsx)(_,{size:`small`,color:`blue`,children:_e(n,m.kind)}):null,m?.state?(0,Q.jsx)(_,{size:`small`,color:`grey`,children:ve(n,m.state)}):null,m?.boundary?(0,Q.jsx)(_,{size:`small`,color:`amber`,children:`跨页引用`}):null]})]}),M?(0,Q.jsx)(nt,{type:`tertiary`,children:`正在读取节点…`}):null,m?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(rt,{className:`assessment-pre assessment-node-content`,children:m.body||`—`}),O?(0,Q.jsx)(o,{size:`small`,onClick:()=>q(m.id,{appendBody:!0}),loading:M,children:`继续读取原文`}):null,(0,Q.jsx)(L,{columns:1,items:[{label:`节点 ID`,value:m.id},{label:`意图`,value:m.step_id||`—`},{label:`更新轮次`,value:m.updated_round??`—`},{label:`更新时间`,value:D(m.updated_at)}]}),g.length?(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(nt,{strong:!0,children:`关联节点`}),(0,Q.jsx)(`div`,{className:`assessment-relations`,children:g.map((e,t)=>(0,Q.jsxs)(o,{size:`small`,theme:`borderless`,onClick:()=>q(e.node?.id),children:[e.direction===`upstream`?`上游`:`下游`,` · `,e.relation,` · `,Pe(e.node?.title,30)]},`${e.node?.id}-${t}`))}),x?(0,Q.jsx)(o,{size:`small`,onClick:()=>q(m.id,{appendLinks:!0}),loading:M,children:`继续查看关联`}):null]}):null,m.kind===`fact`?(0,Q.jsx)(o,{size:`small`,onClick:ie,loading:ee,children:`查看证据路径`}):null,m.step_id?(0,Q.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>{s(m.id),u(0)},children:`展开此节点分支`}):null,I?(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsxs)(nt,{strong:!0,children:[`证据路径 · `,I.title||I.root]}),(0,Q.jsxs)(nt,{type:`tertiary`,size:`small`,children:[`节点 `,Array.isArray(I.nodes)?I.nodes.length:0,` · 未归属回执 `,I.unattributed_receipts||0]}),(0,Q.jsx)(`div`,{className:`assessment-path-list`,children:(I.nodes||[]).map(e=>(0,Q.jsxs)(`div`,{className:`assessment-path-node`,children:[(0,Q.jsx)(_,{size:`small`,children:_e(n,e.kind)}),(0,Q.jsx)(nt,{ellipsis:{showTooltip:!0},children:e.title||e.id})]},e.id))}),(0,Q.jsx)(W,{title:`证据路径原始数据`,value:I,collapsed:!0})]}):null,(0,Q.jsx)(W,{title:`节点来源`,value:m.source||{},collapsed:!0})]}):null]}):(0,Q.jsx)(C,{title:`选择节点`,description:`点击图中节点或上方下拉框,读取节点原文与证据路径。`,style:{padding:24}})})]})]})})}var{Text:ot,Paragraph:st}=u,ct={open:`待处理`,confirmed:`已确认`,fixed:`已修复`,false_positive:`误报`,ignored:`已忽略`};function lt({id:e,reloadToken:t}){let n=j(),[r,i]=(0,Y.useState)(0),[a,s]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!1),d=P(()=>k.get(`/deep-assessments/${e}/vulnerabilities`,{limit:20,offset:r}),[e,r,t]),f=d.data,p=f?.vulnerabilities||[],m=async t=>{u(!0);try{let n=await k.get(`/deep-assessments/${e}/vulnerabilities/${t.id}`);s(n)}catch(e){F(e,`读取漏洞详情失败`)}finally{u(!1)}},h=a?.vulnerability||null,g=[{title:`漏洞标题`,dataIndex:`title`,render:(e,t)=>(0,Q.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,Q.jsx)(ot,{strong:!0,ellipsis:{showTooltip:!0},children:e||t.id}),t.target?(0,Q.jsx)(ot,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:t.target}):null]})},{title:`严重级别`,dataIndex:`severity`,width:100,render:e=>(0,Q.jsx)(ee,{severity:e})},{title:n(`deepAssessments.status`,null,`状态`),dataIndex:`status`,width:100,render:e=>(0,Q.jsx)(_,{size:`small`,children:ct[e]||e||`—`})},{title:`来源意图`,dataIndex:`assessment_step_title`,width:220,render:(e,t)=>e||t.assessment_step_id||`—`},{title:`登记时间`,dataIndex:`created_at`,width:170,render:e=>D(e)},{title:`操作`,width:90,render:(e,t)=>(0,Q.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>m(t),loading:l,children:`详情`})}];return(0,Q.jsxs)(`div`,{className:`assessment-tab`,children:[(0,Q.jsxs)(B,{title:n(`deepAssessments.findings`,null,`关联漏洞`),description:`已登记的发现仍需要独立复现;报告记录不等于独立确认。`,extra:(0,Q.jsx)(o,{size:`small`,onClick:()=>d.reload(),loading:d.loading,children:`刷新`}),children:[(0,Q.jsx)(z,{error:d.error,onRetry:()=>d.reload()}),(0,Q.jsx)(U,{columns:g,dataSource:p,rowKey:`id`,loading:d.loading,pagination:!1,onRow:e=>({onClick:()=>m(e),style:{cursor:`pointer`}}),emptyText:`暂未登记漏洞。`}),(0,Q.jsx)(`div`,{className:`assessment-pager`,children:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(o,{size:`small`,disabled:r===0,onClick:()=>i(e=>Math.max(0,e-20)),children:n(`deepAssessments.previous`,null,`上一页`)}),(0,Q.jsxs)(ot,{type:`tertiary`,children:[`共 `,f?.total??0,` 条`]}),(0,Q.jsx)(o,{size:`small`,disabled:!f?.has_more,onClick:()=>i(e=>e+20),children:n(`deepAssessments.next`,null,`下一页`)})]})})]}),(0,Q.jsx)(I,{visible:!!a,onCancel:()=>s(null),title:h?.title||`漏洞详情`,width:680,footer:null,children:h?(0,Q.jsxs)(`div`,{className:`assessment-drawer`,children:[(0,Q.jsx)(L,{columns:2,items:[{label:`严重级别`,value:(0,Q.jsx)(ee,{severity:h.severity})},{label:n(`deepAssessments.status`,null,`状态`),value:ct[h.status]||h.status},{label:`类型`,value:h.type||`—`},{label:`目标`,value:h.target||`—`},{label:`来源意图`,value:a.step?.title||h.assessment_step_title||h.assessment_step_id||`—`},{label:`登记时间`,value:D(h.created_at)},{label:`漏洞 ID`,value:h.id}]}),[[`描述`,h.description],[`前置条件`,h.preconditions],[`复现步骤`,h.reproduction_steps],[`复现证据`,h.evidence],[`影响`,h.impact],[`修复建议`,h.recommendation],[`复核说明`,h.retest_notes]].filter(([,e])=>e).map(([e,t])=>(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(ot,{strong:!0,children:e}),(0,Q.jsx)(st,{className:`assessment-pre`,children:t})]},e)),a.step?(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(ot,{strong:!0,children:`来源意图摘要`}),(0,Q.jsx)(st,{className:`assessment-pre`,children:Pe(a.step.summary||a.step.instruction,600)})]}):null,(0,Q.jsx)(W,{title:`原始漏洞记录`,value:a,collapsed:!0})]}):null})]})}var{Text:$,Paragraph:ut}=u,dt=[``,`has_evidence`,`missing`,`needs_review`];function ft({visible:e,id:t,onCancel:n,edit:r,onEdit:a,onSave:l,saving:u,saveError:m}){let h=j(),[g,v]=(0,Y.useState)(`fact`),[y,x]=(0,Y.useState)(``),[S,C]=(0,Y.useState)(0),w=te(y,300);(0,Y.useEffect)(()=>{C(0)},[g,w]);let T=P(()=>k.get(`/deep-assessments/${t}/acceptance/sources`,{kind:g,q:w,offset:S}),[t,g,w,S,e],{skip:!e}),E=T.data,O=E?.sources||[],A=g===`fact`?`fact_ids`:`receipt_ids`,M=(e,t)=>a(A,t?[...r[A],e]:r[A].filter(t=>t!==e)),N=[...r?[{key:`selected`,title:`关联`,width:80,render:(e,t)=>(0,Q.jsx)(s,{checked:r[A].includes(t.id),disabled:u,"aria-label":`关联 ${t.title||t.id}`,onChange:e=>M(t.id,e.target.checked)})}]:[],{title:`证据`,dataIndex:`title`,render:(e,t)=>(0,Q.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,Q.jsx)($,{ellipsis:{showTooltip:!0},children:e||t.id}),(0,Q.jsx)($,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:t.id})]})},{title:h(`deepAssessments.status`,null,`状态`),dataIndex:`state`,width:120,render:e=>(0,Q.jsx)(_,{size:`small`,children:ve(h,e)})},{title:`来源意图`,dataIndex:`step_id`,width:140,render:e=>e||`—`},{title:`回执引用`,dataIndex:`receipt_ids`,width:100,render:e=>(e||[]).length||`—`},{title:`时间`,dataIndex:`created_at`,width:170,render:e=>D(e)}];return(0,Q.jsxs)(i,{visible:e,title:r?`编辑验收证据关联`:`证据来源`,onCancel:()=>{u||n()},footer:null,width:900,children:[(0,Q.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,Q.jsx)(f,{value:g,onChange:e=>v(e||`fact`),optionList:[{value:`fact`,label:`事实`},{value:`receipt`,label:`原始回执`}],style:{width:140}}),(0,Q.jsx)(d,{prefix:(0,Q.jsx)(b,{}),value:y,onChange:x,placeholder:`按名称、来源意图或 ID 搜索`,style:{width:280},showClear:!0}),(0,Q.jsx)($,{type:`tertiary`,children:`只有原始回执与 observed 事实可作为验收依据。`})]}),(0,Q.jsx)(z,{error:T.error,onRetry:()=>T.reload()}),(0,Q.jsx)(U,{columns:N,dataSource:O,rowKey:`id`,loading:T.loading,pagination:!1,emptyText:`没有匹配的证据记录。`}),(0,Q.jsx)(`div`,{className:`assessment-pager`,children:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(o,{size:`small`,disabled:S===0,onClick:()=>C(e=>Math.max(0,e-20)),children:h(`deepAssessments.previous`,null,`上一页`)}),(0,Q.jsx)($,{type:`tertiary`,children:O.length?`${S+1} - ${S+O.length}`:`0`}),(0,Q.jsx)(o,{size:`small`,disabled:!E?.has_more,onClick:()=>C(e=>e+20),children:h(`deepAssessments.next`,null,`下一页`)})]})}),r&&(0,Q.jsxs)(`div`,{className:`assessment-section`,children:[(0,Q.jsx)(c,{wrap:!0,children:[`fact_ids`,`receipt_ids`].flatMap(e=>r[e].map(t=>(0,Q.jsx)(_,{closable:!u,onClose:()=>a(e,r[e].filter(e=>e!==t)),children:(e===`fact_ids`?`事实`:`回执`)+` · `+(r.titles[t]||t)},e+t)))}),(0,Q.jsx)(s,{checked:r.needs_review,disabled:u,onChange:e=>a(`needs_review`,e.target.checked),children:`标记待人工复核`}),(0,Q.jsx)(p,{"aria-label":`复核说明`,placeholder:`复核说明`,value:r.review_note,disabled:u,onChange:e=>a(`review_note`,e)}),(0,Q.jsx)(z,{error:m}),(0,Q.jsxs)(c,{children:[(0,Q.jsx)(o,{onClick:n,disabled:u,children:`取消`}),(0,Q.jsx)(o,{theme:`solid`,onClick:l,loading:u,children:`保存证据关联`})]})]})]})}function pt({id:e,criterion:t,canWrite:n,reloadToken:r}){let i=j(),[a,s]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(null),[d,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(!1),[g,y]=(0,Y.useState)(null),b=(0,Y.useRef)(null),x=(0,Y.useRef)(0),[S,C]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(null),[E,D]=(0,Y.useState)(!1),O=P(()=>k.get(`/deep-assessments/${e}/acceptance`),[e,r]),A=O.data?.rows||[],M=A.find(e=>e.number===l);(0,Y.useEffect)(()=>{t&&b.current!==t&&A.some(e=>e.number===t)&&(b.current=t,x.current++,T(null),D(!1),u(t))},[t,A]);let R=(0,Y.useMemo)(()=>{let e={has_evidence:0,missing:0,needs_review:0};return A.forEach(t=>{e[t.status]=(e[t.status]||0)+1}),e},[A]),ee=A.length?Math.round(R.has_evidence/A.length*100):0,te=a?A.filter(e=>e.status===a):A,V=[{id:`total`,label:`验收项`,value:A.length},{id:`has_evidence`,label:xe(i,`has_evidence`),value:R.has_evidence||0},{id:`missing`,label:xe(i,`missing`),value:R.missing||0},{id:`needs_review`,label:xe(i,`needs_review`),value:R.needs_review||0}],H=e=>{x.current++,u(e?.number??null),T(null),D(!1)},ne=()=>{M&&n&&(y(null),p({number:M.number,revision:M.revision,fact_ids:M.fact_ids||[],receipt_ids:M.receipt_ids||[],needs_review:!!M.needs_review,review_note:M.review_note||``,titles:Object.fromEntries([...M.facts||[],...M.receipts||[]].map(e=>[e.id,e.title]))}),C(!0))},re=()=>{C(!1),p(null)},G=async()=>{if(!n||!d||m)return;let{number:t,revision:r,fact_ids:i,receipt_ids:a,needs_review:o,review_note:s}=d;h(!0),y(null);try{await k.put(`/deep-assessments/${encodeURIComponent(e)}/acceptance/${t}`,{revision:r,fact_ids:i,receipt_ids:a,needs_review:o,review_note:s}),K(`验收证据关联已保存`),re(),await O.reload()}catch(e){y(e.status===409?Error(`验收项已有修改。请取消编辑,重新打开后再保存。`):e),e.status===409&&O.reload()}finally{h(!1)}},q=async()=>{if(!M)return;let t=++x.current;D(!0);try{let n=await k.get(`/deep-assessments/${e}/evidence-path`,{criterion:M.number});t===x.current&&T(n)}catch(e){t===x.current&&F(e,`读取证据路径失败`)}finally{t===x.current&&D(!1)}},ie=[{title:`序号`,dataIndex:`number`,width:70},{title:`验收项`,dataIndex:`text`,render:(e,t)=>(0,Q.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,Q.jsx)($,{ellipsis:{showTooltip:!0},children:e||`—`}),t.review_note?(0,Q.jsxs)($,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:[`复核说明:`,Pe(t.review_note,80)]}):null]})},{title:i(`deepAssessments.status`,null,`状态`),dataIndex:`status`,width:120,render:e=>(0,Q.jsx)(_,{color:me[e]||`grey`,shape:`circle`,children:xe(i,e)})},{title:`事实`,dataIndex:`facts`,width:80,render:e=>(e||[]).length},{title:`回执`,dataIndex:`receipts`,width:80,render:e=>(e||[]).length},{title:`操作`,width:110,render:(e,t)=>(0,Q.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>H(t),children:`查看证据`})}];return(0,Q.jsxs)(`div`,{className:`assessment-tab`,children:[(0,Q.jsx)(N,{metrics:V,columns:4}),(0,Q.jsxs)(B,{title:i(`deepAssessments.acceptance`,null,`验收证据`),description:`状态反映证据关联情况,验收结论由审阅人核对;观察事实需有本意图的原始成功回执。`,extra:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(o,{size:`small`,onClick:()=>O.reload(),loading:O.loading,children:`刷新`}),(0,Q.jsx)(o,{size:`small`,onClick:()=>C(!0),children:`浏览证据来源`})]}),children:[(0,Q.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,Q.jsxs)(c,{children:[(0,Q.jsx)(v,{percent:ee,showInfo:!0,size:`small`,strokeWidth:8,style:{width:220}}),(0,Q.jsxs)($,{type:`tertiary`,children:[`已有证据覆盖 `,ee,`%`]})]}),(0,Q.jsx)(f,{value:a,onChange:e=>s(e||``),optionList:dt.map(e=>({value:e,label:e?`${xe(i,e)} · ${R[e]||0}`:`${i(`deepAssessments.all`,null,`全部`)} · ${A.length}`})),style:{width:190}})]}),(0,Q.jsx)(z,{error:O.error,onRetry:()=>O.reload()}),(0,Q.jsx)(U,{columns:ie,dataSource:te,rowKey:`number`,loading:O.loading,pagination:!1,onRow:e=>({onClick:()=>H(e),style:{cursor:`pointer`}}),emptyText:`没有符合筛选条件的验收项。`})]}),(0,Q.jsx)(ft,{visible:S,id:e,onCancel:re,edit:d,onEdit:(e,t)=>p(n=>({...n,[e]:t})),onSave:G,saving:m,saveError:g}),(0,Q.jsx)(I,{visible:!!M,onCancel:()=>H(null),title:M?`验收项 ${M.number}`:`验收项`,width:720,footer:null,children:M?(0,Q.jsxs)(`div`,{className:`assessment-drawer`,children:[(0,Q.jsx)(L,{columns:1,items:[{label:`验收条件`,value:(0,Q.jsx)(ut,{className:`assessment-pre`,children:M.text||`—`})},{label:i(`deepAssessments.status`,null,`状态`),value:(0,Q.jsx)(_,{color:me[M.status]||`grey`,children:xe(i,M.status)})},{label:`复核说明`,value:M.review_note||`—`},{label:`人工标记待复核`,value:M.needs_review?`是`:`否`}]}),(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)($,{strong:!0,children:`关联事实`}),(0,Q.jsx)(U,{columns:[{title:`事实`,dataIndex:`title`,render:(e,t)=>(0,Q.jsx)($,{ellipsis:{showTooltip:!0},children:e||t.id})},{title:`状态`,dataIndex:`state`,width:120,render:e=>ve(i,e)},{title:`回执引用`,dataIndex:`receipt_ids`,width:100,render:e=>(e||[]).length}],dataSource:M.facts||[],rowKey:`id`,pagination:!1,size:`small`,emptyText:`暂无关联事实。`})]}),(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)($,{strong:!0,children:`关联回执`}),(0,Q.jsx)(U,{columns:[{title:`回执`,dataIndex:`title`,render:(e,t)=>(0,Q.jsx)($,{ellipsis:{showTooltip:!0},children:e||t.id})},{title:`状态`,dataIndex:`state`,width:120,render:e=>ve(i,e)},{title:`来源意图`,dataIndex:`step_id`,width:140}],dataSource:M.receipts||[],rowKey:`id`,pagination:!1,size:`small`,emptyText:`暂无关联回执。`})]}),(0,Q.jsxs)(c,{children:[n&&(0,Q.jsx)(o,{size:`small`,theme:`solid`,onClick:ne,children:`编辑证据关联`}),(0,Q.jsx)(o,{size:`small`,onClick:q,loading:E,children:`读取局部证据图`}),(0,Q.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>C(!0),children:`浏览证据来源`})]}),w?(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsxs)($,{strong:!0,children:[`证据路径 · `,w.title||w.root]}),(0,Q.jsx)(`div`,{className:`assessment-path-list`,children:(w.nodes||[]).map(e=>(0,Q.jsxs)(`div`,{className:`assessment-path-node`,children:[(0,Q.jsx)(_,{size:`small`,children:e.kind}),(0,Q.jsx)($,{ellipsis:{showTooltip:!0},children:e.title||e.id})]},e.id))}),(0,Q.jsx)(W,{title:`证据路径原始数据`,value:w,collapsed:!0})]}):null]}):null})]})}var{Text:mt,Paragraph:ht}=u,gt=[{value:`receipts`,label:`执行回执`},{value:`path`,label:`证据路径`},{value:`history`,label:`历次测评`,permission:`asset:read`},{value:`endpoints`,label:`端点证据`,permission:`asset:read`}],_t=2e5,vt=e=>typeof e==`string`&&e.length>_t?`${e.slice(0,_t)}\n…(已截断 ${e.length-_t} 字符,完整内容请下载原始回执)`:Fe(e),yt=[{value:`criterion`,label:`验收项序号`},{value:`asset`,label:`资产 ID`},{value:`fact`,label:`事实 ID`}];function bt({id:e,criterion:t=0,stepId:n=``,reloadToken:r}){let i=j(),{hasPermission:a}=O(),s=(0,Y.useMemo)(()=>gt.filter(e=>!e.permission||a(e.permission)),[a]),[l,u]=(0,Y.useState)(t>0?`path`:`receipts`),p=s.some(e=>e.value===l)?l:`receipts`,[m,h]=(0,Y.useState)(0),[g,v]=(0,Y.useState)(null),y=P(()=>k.get(`/deep-assessments/${e}/receipts`,{offset:m,step_id:n}),[e,m,n,r],{skip:p!==`receipts`}),[b,x]=(0,Y.useState)(`criterion`),[S,C]=(0,Y.useState)(t>0?String(t):``),[w,E]=(0,Y.useState)(null),[A,N]=(0,Y.useState)({loading:!1,error:null}),[F,R]=(0,Y.useState)(``),[ee,te]=(0,Y.useState)(``),[V,H]=(0,Y.useState)(null),[ne,re]=(0,Y.useState)({loading:!1,error:null}),[K,q]=(0,Y.useState)(null),[ie,J]=(0,Y.useState)({loading:!1,error:null});(0,Y.useEffect)(()=>{h(0)},[p]);let ae=async()=>{let t=S.trim(),n=null;if(b===`criterion`){let e=Number(t);if(!Number.isFinite(e)||e<1){M(`请填写有效的验收项序号`);return}n={criterion:Math.floor(e)}}else if(b===`asset`){if(!t){M(`请填写资产 ID`);return}n={asset_id:t}}else{if(!t){M(`请填写事实 ID`);return}n={fact_id:t}}N({loading:!0,error:null});try{let t=await k.get(`/deep-assessments/${e}/evidence-path`,n);E(t),N({loading:!1,error:null})}catch(e){E(null),N({loading:!1,error:e})}};(0,Y.useEffect)(()=>{t>0&&ae()},[e,t]);let oe=async()=>{let t=F.trim();if(!t)M(`请填写资产 ID`);else{re({loading:!0,error:null}),te(t);try{let n=await k.get(`/deep-assessments/${e}/evidence-history`,{asset_id:t});H(n),re({loading:!1,error:null})}catch(e){H(null),re({loading:!1,error:e})}}},se=async()=>{let t=F.trim();if(!t)M(`请填写资产 ID`);else{J({loading:!0,error:null});try{let n=await k.get(`/deep-assessments/${e}/endpoint-evidence`,{asset_id:t});q(n),J({loading:!1,error:null})}catch(e){q(null),J({loading:!1,error:e})}}},X=y.data?.receipts||[],ce=[{title:i(`deepAssessments.status`,null,`状态`),dataIndex:`status`,width:110,render:e=>(0,Q.jsx)(G,{status:e,label:Z(i,e)})},{title:`工具`,dataIndex:`tool`,width:200,render:(e,t)=>(0,Q.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,Q.jsx)(mt,{strong:!0,children:e||`—`}),(0,Q.jsx)(mt,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:t.id})]})},{title:`来源意图`,dataIndex:`step_id`,width:160,render:e=>e||`—`},{title:`执行 ID`,dataIndex:`execution_id`,render:e=>e?(0,Q.jsx)(mt,{type:`tertiary`,ellipsis:{showTooltip:!0},children:e}):`—`},{title:`操作`,width:90,render:(e,t)=>(0,Q.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>v(t),children:`查看`})}];return(0,Q.jsxs)(`div`,{className:`assessment-tab`,children:[(0,Q.jsxs)(B,{title:i(`deepAssessments.evidence`,null,`证据回执`),description:`回执是执行原始记录;路径与对照只读展示已保存的关联,不改变测评状态。`,extra:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(f,{value:p,onChange:e=>u(e||`receipts`),optionList:s.map(e=>({value:e.value,label:e.label})),style:{width:160}}),(0,Q.jsx)(o,{size:`small`,onClick:()=>p===`receipts`?y.reload():void 0,disabled:p!==`receipts`,children:`刷新`})]}),children:[p===`receipts`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{error:y.error,onRetry:()=>y.reload()}),(0,Q.jsx)(U,{columns:ce,dataSource:X,rowKey:`id`,loading:y.loading,pagination:!1,onRow:e=>({onClick:()=>v(e),style:{cursor:`pointer`}}),emptyText:i(`deepAssessments.noRecords`,null,`暂无记录`)}),(0,Q.jsx)(`div`,{className:`assessment-pager`,children:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(o,{size:`small`,disabled:m===0,onClick:()=>h(e=>Math.max(0,e-50)),children:i(`deepAssessments.previous`,null,`上一页`)}),(0,Q.jsxs)(mt,{type:`tertiary`,children:[`共 `,X.length,` 条`]}),(0,Q.jsx)(o,{size:`small`,disabled:!y.data?.has_more,onClick:()=>h(e=>e+50),children:i(`deepAssessments.next`,null,`下一页`)})]})})]}):null,p===`path`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,Q.jsx)(f,{value:b,onChange:e=>x(e||`criterion`),optionList:yt,style:{width:150}}),b===`criterion`?(0,Q.jsx)(T,{value:S===``?void 0:Number(S),onChange:e=>C(e==null?``:String(e)),min:1,placeholder:`验收项序号`,style:{width:160}}):(0,Q.jsx)(d,{value:S,onChange:C,placeholder:b===`asset`?`资产 ID`:`事实 ID`,style:{width:320},showClear:!0}),(0,Q.jsx)(o,{size:`small`,theme:`solid`,type:`primary`,onClick:ae,loading:A.loading,children:`读取证据路径`})]}),(0,Q.jsx)(z,{error:A.error,onRetry:ae}),w?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L,{columns:3,items:[{label:`根节点`,value:w.title||w.root},{label:`节点数`,value:w.total??(w.nodes||[]).length},{label:`已折叠`,value:w.folded??0},{label:`未归属回执`,value:w.unattributed_receipts??0},{label:`相关意图`,value:w.related_intent_count??0},{label:`还有更多`,value:w.has_more?`是`:`否`}]}),(0,Q.jsx)(U,{columns:[{title:`类型`,dataIndex:`kind`,width:120,render:(e,t)=>_e(i,e)||t.kind},{title:`标题`,dataIndex:`title`,render:(e,t)=>(0,Q.jsx)(mt,{ellipsis:{showTooltip:!0},children:e||t.id})},{title:`状态`,dataIndex:`state`,width:120,render:e=>ve(i,e)},{title:`来源意图`,dataIndex:`step_id`,width:150,render:e=>e||`—`}],dataSource:w.nodes||[],rowKey:`id`,pagination:!1,size:`small`,emptyText:`证据路径为空。`}),(0,Q.jsxs)(mt,{type:`tertiary`,size:`small`,children:[`关联边 `,Array.isArray(w.edges)?w.edges.length:0,` 条`]}),(0,Q.jsx)(W,{title:`证据路径原始数据`,value:w,collapsed:!0})]}):null]}):null,p===`history`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,Q.jsx)(d,{value:F,onChange:R,placeholder:`资产 ID`,style:{width:340},showClear:!0}),(0,Q.jsx)(o,{size:`small`,theme:`solid`,type:`primary`,onClick:oe,loading:ne.loading,children:`读取历次测评`})]}),(0,Q.jsx)(z,{error:ne.error,onRetry:oe}),V?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(mt,{strong:!0,children:[V.title||V.asset_id,` · 本次测评`]}),(0,Q.jsx)(L,{columns:3,items:[{label:`测评`,value:V.current?.name||`—`},{label:`状态`,value:Z(i,V.current?.state)},{label:`有效观察`,value:V.current?.observed_facts??0},{label:`证据端点`,value:V.current?.observed_endpoints??0},{label:`待复核验收项`,value:(V.current?.pending_criteria||[]).join(`, `)||`—`},{label:`最近观察`,value:D(V.current?.last_observation)}]}),(0,Q.jsx)(U,{columns:[{title:`较早测评`,dataIndex:`name`,render:(e,t)=>(0,Q.jsx)(mt,{ellipsis:{showTooltip:!0},children:e||t.task_id})},{title:`状态`,dataIndex:`state`,width:110,render:e=>Z(i,e)},{title:`有效观察`,dataIndex:`observed_facts`,width:100},{title:`证据端点`,dataIndex:`observed_endpoints`,width:100},{title:`新增观察`,dataIndex:`new_observations`,width:100},{title:`新增端点`,dataIndex:`new_endpoints`,width:100},{title:`前次有本次无`,dataIndex:`unseen_now`,width:120},{title:`可比较`,dataIndex:`comparable`,width:90,render:e=>e?`是`:`否`},{title:`创建时间`,dataIndex:`created_at`,width:170,render:e=>D(e)}],dataSource:V.prior||[],rowKey:`task_id`,pagination:!1,size:`small`,emptyText:ee?`暂无可读的较早测评记录。`:`—`}),(0,Q.jsx)(ht,{type:`tertiary`,className:`assessment-hint`,children:`差异基于两次已保存的证据记录;范围或项目口径不同时保留记录供人工对照。`}),(0,Q.jsx)(W,{title:`历次测评原始数据`,value:V,collapsed:!0})]}):null]}):null,p===`endpoints`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,Q.jsx)(d,{value:F,onChange:R,placeholder:`资产 ID`,style:{width:340},showClear:!0}),(0,Q.jsx)(o,{size:`small`,theme:`solid`,type:`primary`,onClick:se,loading:ie.loading,children:`读取端点证据`})]}),(0,Q.jsx)(z,{error:ie.error,onRetry:se}),K?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L,{columns:4,items:[{label:`资产`,value:K.title||`—`},{label:`已有观察`,value:K.counts?.observed??0},{label:`待复核`,value:K.counts?.needs_review??0},{label:`缺证据`,value:K.counts?.missing??0}]}),(0,Q.jsx)(U,{columns:[{title:`方法`,dataIndex:`method`,width:90},{title:`路径`,dataIndex:`path`,render:(e,t)=>(0,Q.jsx)(mt,{ellipsis:{showTooltip:!0},children:e||t.id})},{title:`名称`,dataIndex:`title`,width:220,render:e=>e||`—`},{title:`证据状态`,dataIndex:`status`,width:120,render:e=>(0,Q.jsx)(_,{size:`small`,children:ve(i,e)})}],dataSource:K.endpoints||[],rowKey:`id`,pagination:!1,size:`small`,emptyText:`该资产暂无登记端点。`}),(0,Q.jsx)(ht,{type:`tertiary`,className:`assessment-hint`,children:`端点状态来自明确关联的事实;服务级观察不会计入端点。端点关联的写入在资产图与漏洞复核流程中完成。`}),(0,Q.jsx)(W,{title:`端点证据原始数据`,value:K,collapsed:!0})]}):null]}):null]}),(0,Q.jsx)(I,{visible:!!g,onCancel:()=>v(null),title:g?`${g.tool||`回执`} · ${g.step_id||``}`:`回执详情`,width:720,footer:null,children:g?(0,Q.jsxs)(`div`,{className:`assessment-drawer`,children:[(0,Q.jsx)(L,{columns:2,items:[{label:i(`deepAssessments.status`,null,`状态`),value:(0,Q.jsx)(G,{status:g.status,label:Z(i,g.status)})},{label:`回执 ID`,value:g.id},{label:`来源意图`,value:g.step_id||`—`},{label:`执行 ID`,value:g.execution_id||`—`}]}),(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(mt,{strong:!0,children:`调用参数`}),(0,Q.jsx)(W,{title:`arguments`,value:vt(g.arguments),collapsed:!1})]}),(0,Q.jsxs)(`section`,{className:`assessment-section`,children:[(0,Q.jsx)(mt,{strong:!0,children:`调用结果`}),(0,Q.jsx)(W,{title:`result`,value:vt(g.result),collapsed:!0})]})]}):null})]})}function xt({id:e,task:t,reloadToken:n}){let r=j(),[i,a]=(0,Y.useState)(!1),s=P(()=>k.get(`/deep-assessments/${e}/report`),[e,n]),l=typeof s.data==`string`?s.data:``,u=String(t?.name||e).replace(/[\\/:*?"<>|\s]+/g,`_`).slice(0,60)||e;return(0,Q.jsx)(`div`,{className:`assessment-tab`,children:(0,Q.jsxs)(B,{title:r(`deepAssessments.reportTitle`,null,`测评报告`),description:`报告按当前已保存状态生成,包含验收矩阵、证据对照与运行记录。`,extra:(0,Q.jsxs)(c,{children:[(0,Q.jsx)(V,{text:l,label:`复制 Markdown`}),(0,Q.jsx)(o,{size:`small`,onClick:()=>s.reload(),loading:s.loading,children:`刷新`}),(0,Q.jsx)(o,{size:`small`,theme:`solid`,type:`primary`,onClick:async()=>{a(!0);try{let t=await A(`/deep-assessments/${e}/report`,{filename:`assessment-${u}.md`});K(`已下载 ${t}`)}catch(e){F(e,`下载失败`)}finally{a(!1)}},loading:i,disabled:!l,children:r(`deepAssessments.report`,null,`下载报告`)})]}),children:[(0,Q.jsx)(z,{error:s.error,onRetry:()=>s.reload()}),l?(0,Q.jsx)(`div`,{className:`assessment-report`,children:(0,Q.jsx)(R,{content:l})}):s.loading?null:(0,Q.jsx)(C,{title:`报告为空`,description:`开始测评并保存进展后可生成报告。`,style:{padding:40}})]})})}var{Text:St}=u,Ct=[{key:`overview`,i18n:`deepAssessments.overview`,fallback:`概览`},{key:`intents`,i18n:`deepAssessments.intents`,fallback:`意图`},{key:`facts`,i18n:`deepAssessments.facts`,fallback:`事实`},{key:`assets`,i18n:`deepAssessments.assets`,fallback:`资产`,permission:`asset:read`},{key:`graph`,i18n:`deepAssessments.graph`,fallback:`图谱`},{key:`findings`,i18n:`deepAssessments.findings`,fallback:`漏洞`,permission:`vulnerability:read`},{key:`acceptance`,i18n:`deepAssessments.acceptance`,fallback:`验收`},{key:`evidence`,i18n:`deepAssessments.evidence`,fallback:`证据`},{key:`report`,i18n:`deepAssessments.reportTab`,fallback:`报告`}];function wt({id:e,tab:t,criterion:n,evidencePath:r,evidenceStepId:a,observation:s,onTabChange:u,onBack:d,onDeleted:f}){let h=j(),{hasPermission:_}=O(),v=P(()=>k.get(`/deep-assessments/${e}`),[e]),y=v.data?.task||null,[b,x]=(0,Y.useState)([]),[S,C]=(0,Y.useState)(null),[T,A]=(0,Y.useState)(!0),[N,I]=(0,Y.useState)(``),[L,R]=(0,Y.useState)(0),[ee,B]=(0,Y.useState)(``),[te,V]=(0,Y.useState)(``),[U,re]=(0,Y.useState)(``),W=(0,Y.useRef)(0),ie=(0,Y.useRef)(!1),J=_(he),ae=_(ge),oe=_(`agent:execute`),se=(0,Y.useMemo)(()=>Ct.filter(e=>!e.permission||_(e.permission)),[_]),X=se.some(e=>e.key===t)?t:`overview`,ce=(0,Y.useCallback)(async(t=!1)=>{if((t||!ie.current)&&(t||!document.hidden&&T)){ie.current=!0;try{let n=await k.get(`/deep-assessments/${e}/events`,t?{latest:`true`}:{after:W.current}),r=Array.isArray(n?.events)?n.events:[];t?(x(r),W.current=r.length&&Number(r[r.length-1].id)||0):r.length&&(x(e=>[...e,...r].slice(-500)),W.current=Number(r[r.length-1].id)||W.current),C(null)}catch(e){t&&C(e)}finally{ie.current=!1}}},[e,T]);(0,Y.useEffect)(()=>(W.current=0,x([]),C(null),ce(!0),()=>{W.current=0}),[e]),(0,Y.useEffect)(()=>{X===`overview`&&ce(!1)},[X]),ne(()=>{document.hidden||(ce(!1),N||v.reload({silent:!0}))},X===`overview`&&T?1e4:0);let le=async()=>{await v.reload(),R(e=>e+1),ce(!0)},ue=async(t,n={})=>{if(y&&J){I(t);try{let r=await k.post(`/deep-assessments/${e}/control/${t}`,{revision:y.revision,...n});r?.task&&v.setData({task:r.task}),r?.start_error?M(r.start_error):K(h(`deepAssessments.updated`,null,`已更新`)),R(e=>e+1),ce(!0),v.reload({silent:!0})}catch(e){F(e,h(`deepAssessments.controlFailed`,null,`操作失败`)),v.reload()}finally{I(``)}}},de=async()=>{if(!y)return;let t=U.trim();if(!t)M(`请填写补充内容`);else{I(`message`);try{let n=await k.post(`/deep-assessments/${e}/control/${te}`,{revision:y.revision,message:t});n?.task&&v.setData({task:n.task}),n?.start_error?M(n.start_error):K(te===`answer`?`已答复并继续`:`已提交方向`),V(``),re(``),R(e=>e+1),ce(!0),v.reload({silent:!0})}catch(e){F(e,`提交失败`)}finally{I(``)}}},fe=[(0,Q.jsx)(o,{theme:`borderless`,onClick:d,children:`返回列表`},`back`),(0,Q.jsx)(o,{icon:(0,Q.jsx)(g,{}),onClick:le,loading:v.loading&&!N,children:`刷新`},`refresh`),(0,Q.jsx)(o,{theme:`solid`,type:`primary`,disabled:!J||!oe||!!N||!Te(y),loading:N===`start`,onClick:()=>ue(`start`),children:h(`deepAssessments.start`,null,`开始 / 继续`)},`start`),(0,Q.jsx)(o,{disabled:!J||!!N||!Ee(y),loading:N===`pause`,onClick:()=>ue(`pause`),children:h(`deepAssessments.pause`,null,`暂停`)},`pause`),(0,Q.jsx)(o,{type:`danger`,disabled:!J||!!N||!De(y),loading:N===`cancel`,onClick:()=>ue(`cancel`),children:h(`deepAssessments.cancel`,null,`停止`)},`cancel`),Oe(y)?(0,Q.jsx)(o,{disabled:!J||!oe||!!N,loading:N===`continue-stopped`,onClick:()=>ue(`continue-stopped`),children:`继续测评`},`continue`):null,(0,Q.jsx)(o,{disabled:!J||!!N||(y?.archived?!Ae(y):!ke(y)),loading:N===`archive`||N===`restore`,onClick:()=>ue(y?.archived?`restore`:`archive`),children:y?.archived?`恢复到列表`:`归档`},`archive`),(0,Q.jsx)(o,{type:`danger`,theme:`borderless`,icon:(0,Q.jsx)(w,{}),disabled:!ae||!!N||!je(y),onClick:()=>{y&&q({title:h(`deepAssessments.delete`,null,`删除`),content:`删除本条测评?关联执行会话仍保留。`,okText:h(`deepAssessments.delete`,null,`删除`),onOk:async()=>{try{await k.del(`/deep-assessments/${e}`),K(h(`deepAssessments.deleted`,null,`已删除`)),f?.()}catch(e){F(e,`删除失败`)}}})},children:h(`deepAssessments.delete`,null,`删除`)},`delete`)];return(0,Q.jsxs)(`div`,{className:`assessment-page`,children:[(0,Q.jsx)(H,{title:y?.name||h(`deepAssessments.title`,null,`深度测评`),description:y?.objective?Pe(y.objective,160):null,extra:fe,children:(0,Q.jsxs)(c,{spacing:8,wrap:!0,className:`assessment-meta`,children:[y?(0,Q.jsx)(G,{status:y.status,label:Z(h,y.status)}):null,y?.archived?(0,Q.jsx)(G,{status:`archived`,label:Z(h,`archived`)}):null,y&&we(y)?(0,Q.jsx)(G,{status:`needs_review`,label:Z(h,`needs_review`)}):null,y?(0,Q.jsxs)(St,{type:`tertiary`,children:[`模型 `,y.model||`系统默认`]}):null,y?.role?(0,Q.jsxs)(St,{type:`tertiary`,children:[`角色 `,y.role]}):null,y?(0,Q.jsxs)(St,{type:`tertiary`,children:[`规划轮次 `,E(y.rounds||0)]}):null,y?(0,Q.jsxs)(St,{type:`tertiary`,children:[`累计 Token `,E(y.tokens_used||0)]}):null,y?.created_at?(0,Q.jsxs)(St,{type:`tertiary`,children:[`创建于 `,D(y.created_at)]}):null]})}),(0,Q.jsx)(z,{error:v.error,onRetry:le}),y?.archived?(0,Q.jsx)(l,{type:`info`,bordered:!0,closeIcon:null,description:`测评已归档。恢复到列表后才能继续控制、关联资产或补充方向。`}):null,y?.status===`blocked`?(0,Q.jsx)(l,{type:`danger`,bordered:!0,closeIcon:null,className:`assessment-banner`,description:y.summary||`测评受阻,请查看运行记录定位原因;排除后可手动继续。`,children:(0,Q.jsx)(o,{size:`small`,onClick:()=>u?.(`overview`),children:`查看运行记录`})}):null,y?.question?(0,Q.jsx)(l,{type:`warning`,bordered:!0,closeIcon:null,className:`assessment-banner`,description:`执行需要人工确认:${y.question}`,children:(0,Q.jsx)(o,{size:`small`,theme:`solid`,type:`primary`,disabled:!J||!oe,onClick:()=>{V(`answer`),re(``)},children:`答复并继续`})}):null,y&&!y.archived&&we(y)?(0,Q.jsx)(l,{type:`warning`,bordered:!0,closeIcon:null,className:`assessment-banner`,description:`有结果不明的工具调用待核对(${y.review_count||(y.steps||[]).filter(e=>[`uncertain`,`cleanup_unconfirmed`].includes(e.status)).length} 项)。核对只更新记录,不会自动执行。`,children:(0,Q.jsx)(o,{size:`small`,onClick:()=>{B(`uncertain`),u?.(`intents`)},children:`处理待核对`})}):null,(0,Q.jsx)(m,{type:`line`,activeKey:X,onChange:e=>u?.(e),tabList:se.map(e=>({itemKey:e.key,tab:h(e.i18n,null,e.fallback)})),className:`assessment-tabs`,children:y?X===`overview`?(0,Q.jsx)(Ge,{task:y,canWrite:J&&oe,events:b,eventsError:S,autoRefresh:T,onAutoRefreshChange:A,onRefreshEvents:()=>ce(!0),onGoTab:u,onGuidance:()=>{V(`guidance`),re(``)},onAnswer:()=>{V(`answer`),re(``)}}):X===`intents`?(0,Q.jsx)(Ye,{id:e,reloadToken:L,status:ee,onStatusChange:B,archived:!!y.archived,onChanged:()=>{R(e=>e+1),v.reload({silent:!0})}}):X===`facts`?(0,Q.jsx)(Qe,{id:e,reloadToken:L,task:y}):X===`assets`?(0,Q.jsx)(tt,{id:e,task:y,observation:s,reloadToken:L}):X===`graph`?(0,Q.jsx)(at,{id:e,reloadToken:L}):X===`findings`?(0,Q.jsx)(lt,{id:e,task:y,reloadToken:L}):X===`acceptance`?(0,Q.jsx)(pt,{id:e,criterion:n,canWrite:J&&!y.archived,reloadToken:L}):X===`evidence`?(0,Q.jsx)(bt,{id:e,criterion:r?n:0,stepId:a,reloadToken:L},`${r}-${n}-${a}`):(0,Q.jsx)(xt,{id:e,task:y,reloadToken:L}):null}),!y&&v.loading?(0,Q.jsx)(`div`,{className:`assessment-loading`,children:`正在读取测评…`}):null,(0,Q.jsxs)(i,{visible:!!te,title:te===`answer`?`答复并继续`:`补充线索或调整方向`,onCancel:()=>V(``),onOk:de,confirmLoading:N===`message`,okText:`提交`,cancelText:`取消`,width:560,children:[(0,Q.jsx)(`p`,{className:`assessment-hint`,children:te===`answer`?`答复会保存到人工补充并清除待答复状态,随后自动继续测评。`:`补充方向会在下一轮规划中使用;执行中的测评需当前账号继续后才可补充。`}),(0,Q.jsx)(p,{value:U,onChange:re,rows:5,maxLength:8e3,placeholder:`例如:优先验证登录接口的越权风险,并附上原始请求回执。`})]})]})}function Tt(){let e=j(),{hasPermission:t}=O(),[n,i]=r(),a=n.get(`id`)||n.get(`assessment_id`)||``,o=n.get(`tab`)||`overview`,s=o===`evidence-path`?`evidence`:o,c=(0,Y.useCallback)(e=>{let t=new URLSearchParams;t.set(`id`,e),t.set(`tab`,`overview`),i(t)},[i]),l=(0,Y.useCallback)(e=>{let t=new URLSearchParams;t.set(`id`,a),t.set(`tab`,e),i(t,{replace:!0})},[a,i]),u=(0,Y.useCallback)(()=>{i(new URLSearchParams,{replace:!1})},[i]);return t(`assessments:read`)?a?(0,Q.jsx)(wt,{id:a,tab:s,criterion:Number(n.get(`criterion`))||0,evidencePath:o===`evidence-path`,evidenceStepId:n.get(`step_id`)||``,observation:n.get(`observation`)||``,onTabChange:l,onBack:u,onDeleted:u},a):(0,Q.jsx)(Ve,{onOpen:c}):(0,Q.jsx)(`div`,{className:`assessment-page`,children:(0,Q.jsx)(C,{title:e(`common.forbidden`,null,`当前账号没有访问该页面的权限`),description:`深度测评需要 assessments:read 权限,请联系管理员分配。`,style:{padding:64}})})}export{Tt as default};
\ No newline at end of file
diff --git a/web/static/app/assets/hitl-CKnRMfmB.js b/web/static/app/assets/hitl-DCNZaIEz.js
similarity index 99%
rename from web/static/app/assets/hitl-CKnRMfmB.js
rename to web/static/app/assets/hitl-DCNZaIEz.js
index ed166460..d15976f8 100644
--- a/web/static/app/assets/hitl-CKnRMfmB.js
+++ b/web/static/app/assets/hitl-DCNZaIEz.js
@@ -1,4 +1,4 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{H as i,I as a,P as o,R as s,U as c,V as l,_ as u,b as d,c as f,d as p,f as m,g as h,it as g,j as _,p as v,rt as y,w as b,z as x}from"./semi-DNxeCrHm.js";import{E as S,F as C,I as w,P as T,S as E,a as D,b as O,d as k,l as A,m as j,n as ee,o as M,p as N,s as P,u as F,x as I,y as L}from"./index-BoFwOeaz.js";var R=e(t(),1),z=[{value:`off`,label:`关闭`,hint:`不拦截工具调用`},{value:`approval`,label:`审批模式`,hint:`只裁决通过/拒绝`},{value:`review_edit`,label:`审查编辑模式`,hint:`可收窄参数后放行`}],te={approve:`通过`,reject:`拒绝`},B={approve:`green`,reject:`red`},V={human:`人工`,audit_agent:`审计 Agent`,system:`系统`,manual:`手动录入`};function H(e){let t=String(e||``).trim().toLowerCase().replace(/-/g,`_`);return t===`feedback`||t===`followup`?`approval`:[`off`,`approval`,`review_edit`].includes(t)?t:`off`}function U(e){let t=H(e),n=z.find(e=>e.value===t);return n?n.label:t}function W(e){let t=String(e||``).trim().toLowerCase();return t===`audit_agent`||t===`agent`||t===`ai`?`audit_agent`:`human`}function G(e){return W(e)===`audit_agent`?`审计 Agent`:`人工审批`}function K(e){let t=String(e||``).trim().toLowerCase();return te[t]||t||`—`}function q(e){return B[String(e||``).toLowerCase()]||`grey`}function ne(e){return V[String(e||``).trim().toLowerCase()]||e||`—`}function re(e){let t=String(e||``).trim().toLowerCase();return t===`pending`?`待审批`:t===`decided`?`已裁决`:t===`timeout`?`超时自动拒绝`:t===`cancelled`?`已取消`:e||`—`}function J(e){if(!e)return{};if(typeof e==`object`)return e;try{let t=JSON.parse(String(e));return t&&typeof t==`object`?t:{}}catch{return{}}}function ie(e){if(!e||typeof e!=`object`)return null;if(e.argumentsObj&&typeof e.argumentsObj==`object`)return e.argumentsObj;if(typeof e.arguments==`string`&&e.arguments.trim())try{let t=JSON.parse(e.arguments);if(t&&typeof t==`object`)return t}catch{return{raw:e.arguments}}return e.arguments&&typeof e.arguments==`object`?e.arguments:null}function ae(e){return!e||typeof e!=`object`?[]:[{key:`userMessage`,label:`用户消息`,value:e.userMessage},{key:`thinking`,label:`思考`,value:e.thinking},{key:`reasoningChain`,label:`推理链`,value:e.reasoningChain},{key:`planning`,label:`计划`,value:e.planning}].filter(e=>String(e.value||``).trim())}function oe(e){let t=e?.executionResult;if(!t||typeof t!=`object`)return null;let n=String(t.result||``).trim();return n?{success:t.success===!0,text:n}:null}function se(e){let t=e?.hitlApproval;if(!t||typeof t!=`object`)return``;let n=Number(t.timeoutSeconds)||0;if(n<=0)return`无超时限制`;let r=t.expiresAt?new Date(t.expiresAt):null;return r&&Number.isFinite(r.getTime())?r.getTime()<=Date.now()?`已于 ${S(r)} 到期`:`${S(r)} 截止`:`${n} 秒内需裁决`}function Y(e){return e?S(e):`—`}function ce(e){return String(e||``).split(/[\n,,;;]/).map(e=>e.trim()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t)}function X(e){let t=[];return e?.userMessage&&t.push(`用户消息`),e?.thinking&&t.push(`思考`),e?.executionResult&&t.push(`执行结果`),t.length?t.join(` · `):`—`}var Z=e(n(),1);function Q({payload:e}){let t=ae(e),n=oe(e);return!t.length&&!n?null:(0,Z.jsxs)(`div`,{className:`hitl-context-blocks`,children:[t.map(e=>(0,Z.jsxs)(`div`,{className:`hitl-context-block`,children:[(0,Z.jsx)(`span`,{className:`hitl-context-label`,children:e.label}),(0,Z.jsx)(`pre`,{className:`hitl-context-text`,children:String(e.value)})]},e.key)),n&&(0,Z.jsxs)(`div`,{className:`hitl-context-block ${n.success?`hitl-state-success`:`hitl-state-failed`}`,children:[(0,Z.jsx)(`span`,{className:`hitl-context-label`,children:`执行结果(${n.success?`成功`:`失败`})`}),(0,Z.jsx)(`pre`,{className:`hitl-context-text`,children:n.text})]})]})}var{Text:le}=c;function ue({item:e,canWrite:t,onDone:n}){let r=(0,R.useMemo)(()=>J(e.payload),[e.payload]),i=(0,R.useMemo)(()=>ie(r),[r]),s=H(e.mode)===`review_edit`,c=W(e.reviewer),[u,f]=(0,R.useState)(``),[p,m]=(0,R.useState)(()=>s&&i?JSON.stringify(i,null,2):``),[h,g]=(0,R.useState)(``),[v,y]=(0,R.useState)(``),b=(0,R.useCallback)(async t=>{if(h)return;let r;if(s&&p.trim()){try{r=JSON.parse(p)}catch(e){y(`修改后的参数不是合法 JSON:${e.message}`);return}if(!r||typeof r!=`object`||Array.isArray(r)){y(`修改后的参数必须是 JSON 对象`);return}}y(``),g(t);try{await w.post(`/hitl/decision`,{interruptId:e.id,decision:t,comment:u.trim(),editedArguments:r}),I(t===`approve`?`已通过,工具将继续执行`:`已拒绝本次工具调用`),n?.()}catch(t){if(t?.status===409){await w.post(`/hitl/dismiss`,{interruptId:e.id}).catch(()=>null),E(`该审批已被处理,列表已刷新`),n?.();return}O(t,`提交审批失败`)}finally{g(``)}},[s,p,h,u,e.id,n]),x=(0,R.useCallback)(()=>{L({title:`忽略该审批`,content:`忽略后该审批记为取消(reject),本次工具调用不会继续执行,记录可在审批日志中查看。`,okText:`忽略`,onOk:async()=>{try{await w.post(`/hitl/dismiss`,{interruptId:e.id}),I(`已忽略该审批`),n?.()}catch(e){O(e,`忽略审批失败`)}}})},[e.id,n]);return(0,Z.jsxs)(`div`,{className:`hitl-pending-card`,children:[(0,Z.jsxs)(`div`,{className:`hitl-pending-head`,children:[(0,Z.jsxs)(o,{spacing:6,wrap:!0,children:[(0,Z.jsx)(_,{size:`small`,color:`blue`,shape:`square`,children:e.toolName||`—`}),(0,Z.jsx)(_,{size:`small`,color:s?`violet`:`grey`,children:U(e.mode)}),(0,Z.jsx)(_,{size:`small`,color:c===`audit_agent`?`green`:`grey`,children:G(e.reviewer)})]}),(0,Z.jsxs)(o,{spacing:6,children:[(0,Z.jsx)(le,{type:`tertiary`,size:`small`,children:Y(e.createdAt)}),(0,Z.jsx)(a,{size:`small`,theme:`borderless`,disabled:!t||!!h,onClick:x,children:`忽略`})]})]}),(0,Z.jsxs)(`div`,{className:`hitl-pending-meta`,children:[(0,Z.jsx)(`span`,{className:`hitl-pending-meta-label`,children:`会话`}),(0,Z.jsx)(`span`,{className:`hitl-mono`,children:e.conversationId||`—`}),e.conversationId&&(0,Z.jsx)(M,{text:e.conversationId,size:`small`}),(0,Z.jsx)(`span`,{className:`hitl-pending-deadline`,children:se(r)})]}),(0,Z.jsx)(Q,{payload:r}),i&&(0,Z.jsx)(F,{title:`请求参数`,value:i,collapsed:!0}),(0,Z.jsxs)(`div`,{className:`hitl-pending-editor`,children:[(0,Z.jsx)(`span`,{className:`hitl-context-label`,children:s?`修改后的参数(可编辑,留空表示沿用原参数)`:`审批模式:仅可通过/拒绝,参数编辑已禁用`}),(0,Z.jsx)(d,{rows:s?6:3,value:s?p:i?JSON.stringify(i,null,2):``,disabled:!s,spellCheck:!1,className:`hitl-args-textarea`,onChange:e=>{m(e),v&&y(``)}})]}),v&&(0,Z.jsx)(`div`,{className:`hitl-inline-error`,children:v}),(0,Z.jsx)(l,{value:u,placeholder:`审批备注(可选),例如:只读命令,允许执行`,onChange:e=>f(e)}),(0,Z.jsxs)(`div`,{className:`hitl-pending-actions`,children:[(0,Z.jsx)(a,{type:`danger`,theme:`light`,disabled:!t||!!h,loading:h===`reject`,onClick:()=>b(`reject`),children:`拒绝`}),(0,Z.jsx)(a,{theme:`solid`,disabled:!t||!!h,loading:h===`approve`,onClick:()=>b(`approve`),children:s&&p.trim()&&p.trim()!==(i?JSON.stringify(i,null,2):``)?`保存修改并放行`:`通过`})]}),(0,Z.jsx)(F,{title:`完整载荷`,value:r,collapsed:!0})]})}function de({canWrite:e,onCountChange:t,refreshKey:n=0}){let r=T(),[a,o]=(0,R.useState)(1),[s,c]=(0,R.useState)(20),[u,d]=(0,R.useState)(``),f=ee(u,350),p=D(()=>w.get(`/hitl/pending`,{page:a,pageSize:s,q:f}),[a,s,f,n]),m=p.data?.items||[],g=Number(p.data?.total)||0;(0,R.useEffect)(()=>{t?.(g)},[t,g]);let _=(0,R.useCallback)(e=>{c(e),o(1)},[]);return(0,Z.jsxs)(`div`,{className:`hitl-pending-panel`,children:[(0,Z.jsxs)(`div`,{className:`hitl-panel-toolbar`,children:[(0,Z.jsx)(l,{showClear:!0,value:u,style:{width:300},placeholder:r(`hitl.searchPlaceholder`,null,`搜索工具、会话或载荷…`),onChange:e=>{d(e),o(1)}}),(0,Z.jsxs)(le,{type:`tertiary`,size:`small`,children:[r(`hitl.pendingTitle`,null,`待审批请求`),` · `,g]})]}),(0,Z.jsx)(A,{error:p.error,onRetry:()=>p.reload()}),p.loading&&!m.length&&(0,Z.jsx)(`div`,{className:`hitl-panel-loading`,children:(0,Z.jsx)(i,{})}),!p.loading&&!m.length&&!p.error&&(0,Z.jsx)(b,{title:r(`hitl.emptyState`,null,`暂无待审批请求`),description:`工具调用命中敏感规则时会在此等待裁决。`,style:{padding:48}}),(0,Z.jsx)(`div`,{className:`hitl-pending-list`,children:m.map(t=>(0,Z.jsx)(ue,{item:t,canWrite:e,onDone:()=>{m.length<=1&&a>1?o(a-1):p.reload()}},t.id))}),g>0&&(0,Z.jsx)(`div`,{className:`hitl-panel-pagination`,children:(0,Z.jsx)(h,{currentPage:a,pageSize:s,total:g,showSizeChanger:!0,pageSizeOpts:[10,20,50],showTotal:!0,onPageChange:e=>o(e),onPageSizeChange:_})})]})}var{Text:fe}=c;function pe({logId:e,onClose:t}){let n=T(),{data:r,loading:s,error:c,reload:l}=D(()=>w.get(`/hitl/logs/${encodeURIComponent(e)}`),[e],{skip:!e}),u=(0,R.useMemo)(()=>J(r?.payload),[r?.payload]),d=[r?.auditBackend,r?.auditModel].filter(Boolean).join(` · `);return(0,Z.jsxs)(p,{visible:!!e,onCancel:t,width:720,title:n(`hitl.logModalView`,null,`审批日志详情`),footer:(0,Z.jsx)(a,{onClick:t,children:n(`common.close`,null,`关闭`)}),children:[(0,Z.jsx)(A,{error:c,onRetry:l}),s&&!r&&(0,Z.jsx)(`div`,{className:`hitl-panel-loading`,children:(0,Z.jsx)(i,{})}),r&&(0,Z.jsxs)(`div`,{className:`hitl-log-detail`,children:[(0,Z.jsx)(k,{columns:2,items:[{label:n(`hitl.colTool`,null,`工具`),value:(0,Z.jsx)(fe,{strong:!0,children:r.toolName||`—`})},{label:n(`hitl.colDecision`,null,`决策`),value:(0,Z.jsx)(_,{size:`small`,color:q(r.decision),children:K(r.decision)})},{label:`状态`,value:re(r.status)},{label:n(`hitl.colDecidedBy`,null,`审批方`),value:ne(r.decidedBy)},{label:`审批方类型`,value:G(r.reviewer)},{label:`审批引擎`,value:d||`—`},{label:n(`hitl.colConversation`,null,`会话`),value:r.conversationId?(0,Z.jsxs)(o,{spacing:4,children:[(0,Z.jsx)(`span`,{className:`hitl-mono`,children:r.conversationId}),(0,Z.jsx)(M,{text:r.conversationId,size:`small`})]}):`—`},{label:`模式`,value:r.mode||`—`},{label:`创建时间`,value:Y(r.createdAt)},{label:`裁决时间`,value:Y(r.decidedAt)},{label:`ID`,value:(0,Z.jsx)(`span`,{className:`hitl-mono`,children:r.id})},{label:n(`hitl.fieldComment`,null,`备注`),value:r.comment||`—`}]}),(0,Z.jsx)(Q,{payload:u}),(0,Z.jsx)(F,{title:n(`hitl.fieldPayload`,null,`载荷`),value:u,collapsed:!0})]})]})}function me({canWrite:e,detailId:t,onOpenDetail:n,onCloseDetail:r,refreshKey:i=0}){let s=T(),[c,d]=(0,R.useState)(1),[f,p]=(0,R.useState)(20),[m,h]=(0,R.useState)(``),v=ee(m,350),[y,b]=(0,R.useState)(`all`),[x,S]=(0,R.useState)(`all`),[C,E]=(0,R.useState)([]),k=(0,R.useMemo)(()=>({q:v,decision:y===`all`?``:y,decidedBy:x===`all`?``:x}),[v,y,x]),j=D(()=>w.get(`/hitl/logs`,{page:c,pageSize:f,...k}),[c,f,k,i]),M=j.data?.items||[],N=Number(j.data?.total)||0,F=Number(j.data?.retentionDays)||0,z=(0,R.useCallback)(()=>j.reload(),[j.reload]),te=(0,R.useCallback)(()=>{C.length&&L({title:`批量删除审批日志`,content:`确定删除选中的 ${C.length} 条审批日志?此操作不可恢复。`,okText:s(`common.delete`,null,`删除`),onOk:async()=>{try{await w.del(`/hitl/logs`,{body:{ids:C}}),I(`已删除 ${C.length} 条审批日志`),E([]),z()}catch(e){O(e,`批量删除审批日志失败`)}}})},[z,C,s]),B=(0,R.useCallback)(()=>{L({title:s(`hitl.clearAll`,null,`清空审计日志`),content:v||y!==`all`||x!==`all`?`将清空当前筛选条件下的全部已裁决日志(不会删除待审批项)。`:`将清空全部已裁决审批日志(不会删除待审批项)。`,okText:s(`hitl.clearAll`,null,`清空`),onOk:async()=>{try{await w.del(`/hitl/logs`,{query:k,body:{all:!0}}),I(`审批日志已清空`),E([]),d(1),z()}catch(e){O(e,`清空审批日志失败`)}}})},[x,y,v,k,z,s]),V=[{title:s(`hitl.colTool`,null,`工具`),dataIndex:`toolName`,render:e=>(0,Z.jsx)(`span`,{className:`hitl-mono`,children:e||`—`})},{title:s(`hitl.colConversation`,null,`会话`),dataIndex:`conversationId`,width:200,render:e=>(0,Z.jsx)(`span`,{className:`hitl-mono hitl-ellipsis`,title:e||``,children:e||`—`})},{title:s(`hitl.colDecision`,null,`决策`),dataIndex:`decision`,width:100,render:e=>(0,Z.jsx)(_,{size:`small`,color:q(e),children:K(e)})},{title:s(`hitl.colDecidedBy`,null,`审批方`),dataIndex:`decidedBy`,width:140,render:(e,t)=>(0,Z.jsxs)(`div`,{className:`hitl-log-by`,children:[(0,Z.jsx)(`span`,{children:ne(e)}),t.auditBackend&&(0,Z.jsx)(`span`,{className:`hitl-log-engine`,children:[t.auditBackend,t.auditModel].filter(Boolean).join(` · `)})]})},{title:`备注`,dataIndex:`comment`,render:(e,t)=>(0,Z.jsx)(`span`,{title:e||``,children:e||X(J(t.payload))})},{title:s(`hitl.colTime`,null,`时间`),dataIndex:`decidedAt`,width:180,render:(e,t)=>Y(e||t.createdAt)},{title:s(`common.actions`,null,`操作`),dataIndex:`id`,width:90,render:e=>(0,Z.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>n(e),children:s(`common.view`,null,`详情`)})}],H={currentPage:c,pageSize:f,total:N,showSizeChanger:!0,pageSizeOpts:[20,50,100],showTotal:!0,onPageChange:e=>d(e),onPageSizeChange:e=>{p(e),d(1)}};return(0,Z.jsxs)(`div`,{className:`hitl-logs-panel`,children:[F>0&&(0,Z.jsx)(`p`,{className:`hitl-retention-hint`,children:s(`hitl.retentionHint`,{days:F},`审批日志保留 ${F} 天,到期自动清理。`)}),(0,Z.jsx)(A,{error:j.error,onRetry:z}),(0,Z.jsx)(P,{columns:V,dataSource:M,rowKey:`id`,loading:j.loading,pagination:H,size:`small`,emptyText:s(`hitl.logsEmpty`,null,`暂无审批日志`),rowSelection:{selectedRowKeys:C,onChange:e=>E(e||[])},toolbar:(0,Z.jsxs)(o,{spacing:8,wrap:!0,children:[(0,Z.jsx)(l,{showClear:!0,style:{width:220},value:m,placeholder:s(`hitl.searchPlaceholder`,null,`搜索工具、会话或载荷…`),onChange:e=>{h(e),d(1)}}),(0,Z.jsx)(u,{value:y,style:{width:120},optionList:[{value:`all`,label:s(`hitl.filterAll`,null,`全部`)},{value:`approve`,label:s(`hitl.decisionApprove`,null,`通过`)},{value:`reject`,label:s(`hitl.decisionReject`,null,`拒绝`)}],onChange:e=>{b(e),d(1)}}),(0,Z.jsx)(u,{value:x,style:{width:150},optionList:[{value:`all`,label:s(`hitl.filterAll`,null,`全部`)},{value:`human`,label:s(`hitl.reviewerHuman`,null,`人工`)},{value:`audit_agent`,label:s(`hitl.reviewerAgent`,null,`审计 Agent`)},{value:`system`,label:s(`hitl.reviewerSystem`,null,`系统`)},{value:`manual`,label:s(`hitl.reviewerManual`,null,`手动录入`)}],onChange:e=>{S(e),d(1)}}),(0,Z.jsx)(a,{icon:(0,Z.jsx)(g,{}),theme:`borderless`,size:`small`,onClick:z,loading:j.loading,children:s(`common.refresh`,null,`刷新`)}),(0,Z.jsxs)(a,{size:`small`,type:`danger`,theme:`borderless`,disabled:!e||!C.length,onClick:te,children:[`批量删除`,C.length?`(${C.length})`:``]}),(0,Z.jsx)(a,{size:`small`,type:`danger`,theme:`borderless`,disabled:!e||!N,onClick:B,children:s(`hitl.clearAll`,null,`清空`)})]})}),(0,Z.jsx)(pe,{logId:t,onClose:r})]})}var{Text:he}=c;function ge({canWrite:e,refreshKey:t=0}){let n=T(),{data:r,loading:i,error:s,reload:c}=D(()=>w.get(`/hitl/tool-whitelist`),[t]),[l,u]=(0,R.useState)(``),[f,p]=(0,R.useState)(``);(0,R.useEffect)(()=>{r&&u((r.toolWhitelist||[]).join(`
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{H as i,I as a,P as o,R as s,U as c,V as l,_ as u,b as d,c as f,d as p,f as m,g as h,it as g,j as _,p as v,rt as y,w as b,z as x}from"./semi-DNxeCrHm.js";import{E as S,F as C,I as w,P as T,S as E,a as D,b as O,d as k,l as A,m as j,n as ee,o as M,p as N,s as P,u as F,x as I,y as L}from"./index-smFoxEJu.js";var R=e(t(),1),z=[{value:`off`,label:`关闭`,hint:`不拦截工具调用`},{value:`approval`,label:`审批模式`,hint:`只裁决通过/拒绝`},{value:`review_edit`,label:`审查编辑模式`,hint:`可收窄参数后放行`}],te={approve:`通过`,reject:`拒绝`},B={approve:`green`,reject:`red`},V={human:`人工`,audit_agent:`审计 Agent`,system:`系统`,manual:`手动录入`};function H(e){let t=String(e||``).trim().toLowerCase().replace(/-/g,`_`);return t===`feedback`||t===`followup`?`approval`:[`off`,`approval`,`review_edit`].includes(t)?t:`off`}function U(e){let t=H(e),n=z.find(e=>e.value===t);return n?n.label:t}function W(e){let t=String(e||``).trim().toLowerCase();return t===`audit_agent`||t===`agent`||t===`ai`?`audit_agent`:`human`}function G(e){return W(e)===`audit_agent`?`审计 Agent`:`人工审批`}function K(e){let t=String(e||``).trim().toLowerCase();return te[t]||t||`—`}function q(e){return B[String(e||``).toLowerCase()]||`grey`}function ne(e){return V[String(e||``).trim().toLowerCase()]||e||`—`}function re(e){let t=String(e||``).trim().toLowerCase();return t===`pending`?`待审批`:t===`decided`?`已裁决`:t===`timeout`?`超时自动拒绝`:t===`cancelled`?`已取消`:e||`—`}function J(e){if(!e)return{};if(typeof e==`object`)return e;try{let t=JSON.parse(String(e));return t&&typeof t==`object`?t:{}}catch{return{}}}function ie(e){if(!e||typeof e!=`object`)return null;if(e.argumentsObj&&typeof e.argumentsObj==`object`)return e.argumentsObj;if(typeof e.arguments==`string`&&e.arguments.trim())try{let t=JSON.parse(e.arguments);if(t&&typeof t==`object`)return t}catch{return{raw:e.arguments}}return e.arguments&&typeof e.arguments==`object`?e.arguments:null}function ae(e){return!e||typeof e!=`object`?[]:[{key:`userMessage`,label:`用户消息`,value:e.userMessage},{key:`thinking`,label:`思考`,value:e.thinking},{key:`reasoningChain`,label:`推理链`,value:e.reasoningChain},{key:`planning`,label:`计划`,value:e.planning}].filter(e=>String(e.value||``).trim())}function oe(e){let t=e?.executionResult;if(!t||typeof t!=`object`)return null;let n=String(t.result||``).trim();return n?{success:t.success===!0,text:n}:null}function se(e){let t=e?.hitlApproval;if(!t||typeof t!=`object`)return``;let n=Number(t.timeoutSeconds)||0;if(n<=0)return`无超时限制`;let r=t.expiresAt?new Date(t.expiresAt):null;return r&&Number.isFinite(r.getTime())?r.getTime()<=Date.now()?`已于 ${S(r)} 到期`:`${S(r)} 截止`:`${n} 秒内需裁决`}function Y(e){return e?S(e):`—`}function ce(e){return String(e||``).split(/[\n,,;;]/).map(e=>e.trim()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t)}function X(e){let t=[];return e?.userMessage&&t.push(`用户消息`),e?.thinking&&t.push(`思考`),e?.executionResult&&t.push(`执行结果`),t.length?t.join(` · `):`—`}var Z=e(n(),1);function Q({payload:e}){let t=ae(e),n=oe(e);return!t.length&&!n?null:(0,Z.jsxs)(`div`,{className:`hitl-context-blocks`,children:[t.map(e=>(0,Z.jsxs)(`div`,{className:`hitl-context-block`,children:[(0,Z.jsx)(`span`,{className:`hitl-context-label`,children:e.label}),(0,Z.jsx)(`pre`,{className:`hitl-context-text`,children:String(e.value)})]},e.key)),n&&(0,Z.jsxs)(`div`,{className:`hitl-context-block ${n.success?`hitl-state-success`:`hitl-state-failed`}`,children:[(0,Z.jsx)(`span`,{className:`hitl-context-label`,children:`执行结果(${n.success?`成功`:`失败`})`}),(0,Z.jsx)(`pre`,{className:`hitl-context-text`,children:n.text})]})]})}var{Text:le}=c;function ue({item:e,canWrite:t,onDone:n}){let r=(0,R.useMemo)(()=>J(e.payload),[e.payload]),i=(0,R.useMemo)(()=>ie(r),[r]),s=H(e.mode)===`review_edit`,c=W(e.reviewer),[u,f]=(0,R.useState)(``),[p,m]=(0,R.useState)(()=>s&&i?JSON.stringify(i,null,2):``),[h,g]=(0,R.useState)(``),[v,y]=(0,R.useState)(``),b=(0,R.useCallback)(async t=>{if(h)return;let r;if(s&&p.trim()){try{r=JSON.parse(p)}catch(e){y(`修改后的参数不是合法 JSON:${e.message}`);return}if(!r||typeof r!=`object`||Array.isArray(r)){y(`修改后的参数必须是 JSON 对象`);return}}y(``),g(t);try{await w.post(`/hitl/decision`,{interruptId:e.id,decision:t,comment:u.trim(),editedArguments:r}),I(t===`approve`?`已通过,工具将继续执行`:`已拒绝本次工具调用`),n?.()}catch(t){if(t?.status===409){await w.post(`/hitl/dismiss`,{interruptId:e.id}).catch(()=>null),E(`该审批已被处理,列表已刷新`),n?.();return}O(t,`提交审批失败`)}finally{g(``)}},[s,p,h,u,e.id,n]),x=(0,R.useCallback)(()=>{L({title:`忽略该审批`,content:`忽略后该审批记为取消(reject),本次工具调用不会继续执行,记录可在审批日志中查看。`,okText:`忽略`,onOk:async()=>{try{await w.post(`/hitl/dismiss`,{interruptId:e.id}),I(`已忽略该审批`),n?.()}catch(e){O(e,`忽略审批失败`)}}})},[e.id,n]);return(0,Z.jsxs)(`div`,{className:`hitl-pending-card`,children:[(0,Z.jsxs)(`div`,{className:`hitl-pending-head`,children:[(0,Z.jsxs)(o,{spacing:6,wrap:!0,children:[(0,Z.jsx)(_,{size:`small`,color:`blue`,shape:`square`,children:e.toolName||`—`}),(0,Z.jsx)(_,{size:`small`,color:s?`violet`:`grey`,children:U(e.mode)}),(0,Z.jsx)(_,{size:`small`,color:c===`audit_agent`?`green`:`grey`,children:G(e.reviewer)})]}),(0,Z.jsxs)(o,{spacing:6,children:[(0,Z.jsx)(le,{type:`tertiary`,size:`small`,children:Y(e.createdAt)}),(0,Z.jsx)(a,{size:`small`,theme:`borderless`,disabled:!t||!!h,onClick:x,children:`忽略`})]})]}),(0,Z.jsxs)(`div`,{className:`hitl-pending-meta`,children:[(0,Z.jsx)(`span`,{className:`hitl-pending-meta-label`,children:`会话`}),(0,Z.jsx)(`span`,{className:`hitl-mono`,children:e.conversationId||`—`}),e.conversationId&&(0,Z.jsx)(M,{text:e.conversationId,size:`small`}),(0,Z.jsx)(`span`,{className:`hitl-pending-deadline`,children:se(r)})]}),(0,Z.jsx)(Q,{payload:r}),i&&(0,Z.jsx)(F,{title:`请求参数`,value:i,collapsed:!0}),(0,Z.jsxs)(`div`,{className:`hitl-pending-editor`,children:[(0,Z.jsx)(`span`,{className:`hitl-context-label`,children:s?`修改后的参数(可编辑,留空表示沿用原参数)`:`审批模式:仅可通过/拒绝,参数编辑已禁用`}),(0,Z.jsx)(d,{rows:s?6:3,value:s?p:i?JSON.stringify(i,null,2):``,disabled:!s,spellCheck:!1,className:`hitl-args-textarea`,onChange:e=>{m(e),v&&y(``)}})]}),v&&(0,Z.jsx)(`div`,{className:`hitl-inline-error`,children:v}),(0,Z.jsx)(l,{value:u,placeholder:`审批备注(可选),例如:只读命令,允许执行`,onChange:e=>f(e)}),(0,Z.jsxs)(`div`,{className:`hitl-pending-actions`,children:[(0,Z.jsx)(a,{type:`danger`,theme:`light`,disabled:!t||!!h,loading:h===`reject`,onClick:()=>b(`reject`),children:`拒绝`}),(0,Z.jsx)(a,{theme:`solid`,disabled:!t||!!h,loading:h===`approve`,onClick:()=>b(`approve`),children:s&&p.trim()&&p.trim()!==(i?JSON.stringify(i,null,2):``)?`保存修改并放行`:`通过`})]}),(0,Z.jsx)(F,{title:`完整载荷`,value:r,collapsed:!0})]})}function de({canWrite:e,onCountChange:t,refreshKey:n=0}){let r=T(),[a,o]=(0,R.useState)(1),[s,c]=(0,R.useState)(20),[u,d]=(0,R.useState)(``),f=ee(u,350),p=D(()=>w.get(`/hitl/pending`,{page:a,pageSize:s,q:f}),[a,s,f,n]),m=p.data?.items||[],g=Number(p.data?.total)||0;(0,R.useEffect)(()=>{t?.(g)},[t,g]);let _=(0,R.useCallback)(e=>{c(e),o(1)},[]);return(0,Z.jsxs)(`div`,{className:`hitl-pending-panel`,children:[(0,Z.jsxs)(`div`,{className:`hitl-panel-toolbar`,children:[(0,Z.jsx)(l,{showClear:!0,value:u,style:{width:300},placeholder:r(`hitl.searchPlaceholder`,null,`搜索工具、会话或载荷…`),onChange:e=>{d(e),o(1)}}),(0,Z.jsxs)(le,{type:`tertiary`,size:`small`,children:[r(`hitl.pendingTitle`,null,`待审批请求`),` · `,g]})]}),(0,Z.jsx)(A,{error:p.error,onRetry:()=>p.reload()}),p.loading&&!m.length&&(0,Z.jsx)(`div`,{className:`hitl-panel-loading`,children:(0,Z.jsx)(i,{})}),!p.loading&&!m.length&&!p.error&&(0,Z.jsx)(b,{title:r(`hitl.emptyState`,null,`暂无待审批请求`),description:`工具调用命中敏感规则时会在此等待裁决。`,style:{padding:48}}),(0,Z.jsx)(`div`,{className:`hitl-pending-list`,children:m.map(t=>(0,Z.jsx)(ue,{item:t,canWrite:e,onDone:()=>{m.length<=1&&a>1?o(a-1):p.reload()}},t.id))}),g>0&&(0,Z.jsx)(`div`,{className:`hitl-panel-pagination`,children:(0,Z.jsx)(h,{currentPage:a,pageSize:s,total:g,showSizeChanger:!0,pageSizeOpts:[10,20,50],showTotal:!0,onPageChange:e=>o(e),onPageSizeChange:_})})]})}var{Text:fe}=c;function pe({logId:e,onClose:t}){let n=T(),{data:r,loading:s,error:c,reload:l}=D(()=>w.get(`/hitl/logs/${encodeURIComponent(e)}`),[e],{skip:!e}),u=(0,R.useMemo)(()=>J(r?.payload),[r?.payload]),d=[r?.auditBackend,r?.auditModel].filter(Boolean).join(` · `);return(0,Z.jsxs)(p,{visible:!!e,onCancel:t,width:720,title:n(`hitl.logModalView`,null,`审批日志详情`),footer:(0,Z.jsx)(a,{onClick:t,children:n(`common.close`,null,`关闭`)}),children:[(0,Z.jsx)(A,{error:c,onRetry:l}),s&&!r&&(0,Z.jsx)(`div`,{className:`hitl-panel-loading`,children:(0,Z.jsx)(i,{})}),r&&(0,Z.jsxs)(`div`,{className:`hitl-log-detail`,children:[(0,Z.jsx)(k,{columns:2,items:[{label:n(`hitl.colTool`,null,`工具`),value:(0,Z.jsx)(fe,{strong:!0,children:r.toolName||`—`})},{label:n(`hitl.colDecision`,null,`决策`),value:(0,Z.jsx)(_,{size:`small`,color:q(r.decision),children:K(r.decision)})},{label:`状态`,value:re(r.status)},{label:n(`hitl.colDecidedBy`,null,`审批方`),value:ne(r.decidedBy)},{label:`审批方类型`,value:G(r.reviewer)},{label:`审批引擎`,value:d||`—`},{label:n(`hitl.colConversation`,null,`会话`),value:r.conversationId?(0,Z.jsxs)(o,{spacing:4,children:[(0,Z.jsx)(`span`,{className:`hitl-mono`,children:r.conversationId}),(0,Z.jsx)(M,{text:r.conversationId,size:`small`})]}):`—`},{label:`模式`,value:r.mode||`—`},{label:`创建时间`,value:Y(r.createdAt)},{label:`裁决时间`,value:Y(r.decidedAt)},{label:`ID`,value:(0,Z.jsx)(`span`,{className:`hitl-mono`,children:r.id})},{label:n(`hitl.fieldComment`,null,`备注`),value:r.comment||`—`}]}),(0,Z.jsx)(Q,{payload:u}),(0,Z.jsx)(F,{title:n(`hitl.fieldPayload`,null,`载荷`),value:u,collapsed:!0})]})]})}function me({canWrite:e,detailId:t,onOpenDetail:n,onCloseDetail:r,refreshKey:i=0}){let s=T(),[c,d]=(0,R.useState)(1),[f,p]=(0,R.useState)(20),[m,h]=(0,R.useState)(``),v=ee(m,350),[y,b]=(0,R.useState)(`all`),[x,S]=(0,R.useState)(`all`),[C,E]=(0,R.useState)([]),k=(0,R.useMemo)(()=>({q:v,decision:y===`all`?``:y,decidedBy:x===`all`?``:x}),[v,y,x]),j=D(()=>w.get(`/hitl/logs`,{page:c,pageSize:f,...k}),[c,f,k,i]),M=j.data?.items||[],N=Number(j.data?.total)||0,F=Number(j.data?.retentionDays)||0,z=(0,R.useCallback)(()=>j.reload(),[j.reload]),te=(0,R.useCallback)(()=>{C.length&&L({title:`批量删除审批日志`,content:`确定删除选中的 ${C.length} 条审批日志?此操作不可恢复。`,okText:s(`common.delete`,null,`删除`),onOk:async()=>{try{await w.del(`/hitl/logs`,{body:{ids:C}}),I(`已删除 ${C.length} 条审批日志`),E([]),z()}catch(e){O(e,`批量删除审批日志失败`)}}})},[z,C,s]),B=(0,R.useCallback)(()=>{L({title:s(`hitl.clearAll`,null,`清空审计日志`),content:v||y!==`all`||x!==`all`?`将清空当前筛选条件下的全部已裁决日志(不会删除待审批项)。`:`将清空全部已裁决审批日志(不会删除待审批项)。`,okText:s(`hitl.clearAll`,null,`清空`),onOk:async()=>{try{await w.del(`/hitl/logs`,{query:k,body:{all:!0}}),I(`审批日志已清空`),E([]),d(1),z()}catch(e){O(e,`清空审批日志失败`)}}})},[x,y,v,k,z,s]),V=[{title:s(`hitl.colTool`,null,`工具`),dataIndex:`toolName`,render:e=>(0,Z.jsx)(`span`,{className:`hitl-mono`,children:e||`—`})},{title:s(`hitl.colConversation`,null,`会话`),dataIndex:`conversationId`,width:200,render:e=>(0,Z.jsx)(`span`,{className:`hitl-mono hitl-ellipsis`,title:e||``,children:e||`—`})},{title:s(`hitl.colDecision`,null,`决策`),dataIndex:`decision`,width:100,render:e=>(0,Z.jsx)(_,{size:`small`,color:q(e),children:K(e)})},{title:s(`hitl.colDecidedBy`,null,`审批方`),dataIndex:`decidedBy`,width:140,render:(e,t)=>(0,Z.jsxs)(`div`,{className:`hitl-log-by`,children:[(0,Z.jsx)(`span`,{children:ne(e)}),t.auditBackend&&(0,Z.jsx)(`span`,{className:`hitl-log-engine`,children:[t.auditBackend,t.auditModel].filter(Boolean).join(` · `)})]})},{title:`备注`,dataIndex:`comment`,render:(e,t)=>(0,Z.jsx)(`span`,{title:e||``,children:e||X(J(t.payload))})},{title:s(`hitl.colTime`,null,`时间`),dataIndex:`decidedAt`,width:180,render:(e,t)=>Y(e||t.createdAt)},{title:s(`common.actions`,null,`操作`),dataIndex:`id`,width:90,render:e=>(0,Z.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>n(e),children:s(`common.view`,null,`详情`)})}],H={currentPage:c,pageSize:f,total:N,showSizeChanger:!0,pageSizeOpts:[20,50,100],showTotal:!0,onPageChange:e=>d(e),onPageSizeChange:e=>{p(e),d(1)}};return(0,Z.jsxs)(`div`,{className:`hitl-logs-panel`,children:[F>0&&(0,Z.jsx)(`p`,{className:`hitl-retention-hint`,children:s(`hitl.retentionHint`,{days:F},`审批日志保留 ${F} 天,到期自动清理。`)}),(0,Z.jsx)(A,{error:j.error,onRetry:z}),(0,Z.jsx)(P,{columns:V,dataSource:M,rowKey:`id`,loading:j.loading,pagination:H,size:`small`,emptyText:s(`hitl.logsEmpty`,null,`暂无审批日志`),rowSelection:{selectedRowKeys:C,onChange:e=>E(e||[])},toolbar:(0,Z.jsxs)(o,{spacing:8,wrap:!0,children:[(0,Z.jsx)(l,{showClear:!0,style:{width:220},value:m,placeholder:s(`hitl.searchPlaceholder`,null,`搜索工具、会话或载荷…`),onChange:e=>{h(e),d(1)}}),(0,Z.jsx)(u,{value:y,style:{width:120},optionList:[{value:`all`,label:s(`hitl.filterAll`,null,`全部`)},{value:`approve`,label:s(`hitl.decisionApprove`,null,`通过`)},{value:`reject`,label:s(`hitl.decisionReject`,null,`拒绝`)}],onChange:e=>{b(e),d(1)}}),(0,Z.jsx)(u,{value:x,style:{width:150},optionList:[{value:`all`,label:s(`hitl.filterAll`,null,`全部`)},{value:`human`,label:s(`hitl.reviewerHuman`,null,`人工`)},{value:`audit_agent`,label:s(`hitl.reviewerAgent`,null,`审计 Agent`)},{value:`system`,label:s(`hitl.reviewerSystem`,null,`系统`)},{value:`manual`,label:s(`hitl.reviewerManual`,null,`手动录入`)}],onChange:e=>{S(e),d(1)}}),(0,Z.jsx)(a,{icon:(0,Z.jsx)(g,{}),theme:`borderless`,size:`small`,onClick:z,loading:j.loading,children:s(`common.refresh`,null,`刷新`)}),(0,Z.jsxs)(a,{size:`small`,type:`danger`,theme:`borderless`,disabled:!e||!C.length,onClick:te,children:[`批量删除`,C.length?`(${C.length})`:``]}),(0,Z.jsx)(a,{size:`small`,type:`danger`,theme:`borderless`,disabled:!e||!N,onClick:B,children:s(`hitl.clearAll`,null,`清空`)})]})}),(0,Z.jsx)(pe,{logId:t,onClose:r})]})}var{Text:he}=c;function ge({canWrite:e,refreshKey:t=0}){let n=T(),{data:r,loading:i,error:s,reload:c}=D(()=>w.get(`/hitl/tool-whitelist`),[t]),[l,u]=(0,R.useState)(``),[f,p]=(0,R.useState)(``);(0,R.useEffect)(()=>{r&&u((r.toolWhitelist||[]).join(`
`))},[r]);let m=(0,R.useMemo)(()=>ce(l),[l]),h=(0,R.useMemo)(()=>(r?.toolWhitelist||[]).join(`
`),[r]),v=l.trim()!==h.trim(),y=(0,R.useCallback)(async()=>{p(`put`);try{let e=await w.put(`/hitl/tool-whitelist`,{toolWhitelist:m});I(n(`hitl.whitelistSaved`,null,`白名单已保存`)),u((e?.toolWhitelist||m).join(`
`)),c({silent:!0})}catch(e){O(e,n(`hitl.whitelistSaveFailed`,null,`保存白名单失败`))}finally{p(``)}},[c,n,m]),b=(0,R.useCallback)(async()=>{p(`post`);try{let e=await w.post(`/hitl/tool-whitelist`,{sensitiveTools:m});I(e?.hitlGlobalWhitelistMerged?`已合并到全局白名单`:`没有新增工具,白名单未变化`),u((e?.hitlGlobalToolWhitelist||m).join(`
diff --git a/web/static/app/assets/index-B_jDLAQv.css b/web/static/app/assets/index-DPO43fe5.css
similarity index 57%
rename from web/static/app/assets/index-B_jDLAQv.css
rename to web/static/app/assets/index-DPO43fe5.css
index a7d6e940..eb1d55c5 100644
--- a/web/static/app/assets/index-B_jDLAQv.css
+++ b/web/static/app/assets/index-DPO43fe5.css
@@ -1 +1 @@
-:root,body[theme-mode]{--cs-header-height:60px;--cs-sider-width:224px;--cs-sider-collapsed:64px;--cs-radius:12px;--cs-gap:20px;--cs-accent:var(--semi-color-primary);--semi-color-primary:#3266e3;--semi-color-primary-hover:#2758cc;--semi-color-primary-active:#2049ae;--semi-color-primary-disabled:#b6c8f3;--semi-color-primary-light-default:#edf2ff;--semi-color-primary-light-hover:#e3ebff;--semi-color-primary-light-active:#d6e2ff;--semi-color-focus-border:#3266e3;--semi-color-bg-0:#f5f7fb;--semi-color-bg-1:#fff;--semi-color-bg-2:#f9fafe;--semi-color-nav-bg:#fff;--semi-color-text-0:#192438;--semi-color-text-1:#465269;--semi-color-text-2:#737f93;--semi-color-text-3:#a0a9b8;--semi-color-border:#2437581a;--semi-color-fill-0:#24375809;--semi-color-fill-1:#24375811;--semi-border-radius-small:6px;--semi-border-radius-medium:8px;--semi-border-radius-large:12px}html[data-theme=dark],body[theme-mode=dark]{--semi-color-primary:#81a7ff;--semi-color-primary-hover:#a0bdff;--semi-color-primary-active:#b9ceff;--semi-color-primary-disabled:#34486e;--semi-color-primary-light-default:#202d48;--semi-color-primary-light-hover:#293954;--semi-color-primary-light-active:#32486d;--semi-color-focus-border:#81a7ff;--semi-color-bg-0:#111620;--semi-color-bg-1:#1a212e;--semi-color-bg-2:#202837;--semi-color-nav-bg:#161c27;--semi-color-text-0:#e8edf6;--semi-color-text-1:#bdc7d8;--semi-color-text-2:#929fb5;--semi-color-text-3:#66738b;--semi-color-border:#a7b8d71f;--semi-color-fill-0:#a7b8d70b;--semi-color-fill-1:#a7b8d716}html,body,#root{height:100%}body{background:var(--semi-color-bg-0);color:var(--semi-color-text-0);-webkit-font-smoothing:antialiased;margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,Microsoft YaHei,sans-serif}*{box-sizing:border-box}:focus-visible{outline:2px solid var(--semi-color-focus-border);outline-offset:3px}::selection{background:var(--semi-color-primary-light-active)}body[theme-mode=dark] .semi-button-primary.semi-button-solid:not(.semi-button-disabled){color:var(--semi-color-bg-0)}.cs-shell{background:var(--semi-color-bg-0);height:100dvh;display:flex;overflow:hidden}.cs-sider{flex:0 0 var(--cs-sider-width);width:var(--cs-sider-width);border-inline-end:1px solid var(--semi-color-border);background:var(--semi-color-nav-bg);height:100%;transition:width .18s,flex-basis .18s;overflow:hidden}.cs-shell.is-collapsed .cs-sider{flex-basis:var(--cs-sider-collapsed);width:var(--cs-sider-collapsed)}.cs-sidebar-inner{background:var(--semi-color-nav-bg);flex-direction:column;height:100%;display:flex}.cs-brand.semi-button{border-radius:0;flex:0 0 76px;justify-content:flex-start;height:76px;padding:0 20px}.cs-brand.semi-button:hover{background:0 0}.cs-brand .semi-button-content{gap:10px}.cs-brand-logo{object-fit:contain;border-radius:8px;width:30px;height:30px}.cs-brand-name{letter-spacing:-.6px;color:var(--semi-color-text-0);font-size:17px;font-weight:750}.cs-brand-name>span{color:var(--semi-color-primary)}.is-compact .cs-brand{padding:0 17px}.cs-nav-scroll{scrollbar-width:thin;scrollbar-color:var(--semi-color-border) transparent;flex:1;min-height:0;padding-bottom:16px;overflow-y:auto}.cs-nav-section+.cs-nav-section{margin-top:20px}.cs-nav-section-label{color:var(--semi-color-text-2);letter-spacing:.8px;padding:0 24px 10px;font-size:11px;font-weight:500}.cs-nav.semi-navigation{background:0 0;border:0;padding-inline-start:12px;padding-inline-end:12px}.cs-nav .semi-navigation-item,.cs-nav .semi-navigation-sub-title{border-radius:7px;margin-bottom:3px;font-size:13px;font-weight:450}.cs-nav .semi-navigation-list>.semi-navigation-item-normal{height:36px}.cs-nav .semi-navigation-list>.semi-navigation-item,.cs-nav .semi-navigation-list>.semi-navigation-item>.semi-navigation-sub-title{font-weight:450}.cs-nav .semi-navigation-item-selected{color:var(--semi-color-primary);font-weight:600!important}.cs-nav .semi-navigation-item-icon-info{min-width:18px;margin-inline-end:10px}.cs-nav .semi-navigation-item-sub{padding:0}.cs-nav.semi-navigation-collapsed{padding-inline-start:8px;padding-inline-end:8px}.is-compact .cs-nav-section+.cs-nav-section{border-top:1px solid var(--semi-color-border);margin-top:12px;padding-top:12px}.cs-nav-footer{border-top:1px solid var(--semi-color-border);padding:10px 12px}.cs-nav-footer .semi-button{justify-content:flex-start;font-size:12px}.is-compact .cs-nav-footer{padding-inline-start:8px;padding-inline-end:8px}.is-compact .cs-nav-footer .semi-button{justify-content:center}.cs-mobile-nav .semi-sidesheet-body{overflow:hidden}.cs-main{flex-direction:column;flex:1;min-width:0;height:100%;display:flex}.cs-header{height:var(--cs-header-height);flex:0 0 var(--cs-header-height);border-bottom:1px solid var(--semi-color-border);background:var(--semi-color-bg-1);justify-content:space-between;align-items:center;gap:12px;padding:0 28px;display:flex}.cs-header-left{align-items:center;gap:8px;min-width:0;display:flex}.cs-header-crumb{min-width:0;font-size:12px}.cs-header-actions{flex-shrink:0}.cs-header-actions>.semi-space-item:last-child{border-inline-start:1px solid var(--semi-color-border);padding-inline-start:8px;margin-inline-start:8px!important}.cs-user-trigger.semi-button{height:36px;padding-inline-start:6px;padding-inline-end:6px}.cs-user-trigger .semi-button-content{gap:8px}.cs-user-name{text-overflow:ellipsis;white-space:nowrap;max-width:120px;font-size:12px;font-weight:500;overflow:hidden}.cs-content{flex:1;min-height:0;padding:28px 28px 36px;overflow:auto}.cs-content-workspace{padding:18px;overflow:hidden}.cs-page-loading{justify-content:center;align-items:center;height:60vh;display:flex}.cs-page-header{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:16px;margin-bottom:24px;display:flex}.cs-page-header-main{flex-direction:column;gap:6px;min-width:0;display:flex}.cs-page-title{letter-spacing:-.5px;margin:0!important;font-size:24px!important;font-weight:650!important}.cs-page-desc{font-size:13px;line-height:1.7}.cs-page-header-extra{flex-wrap:wrap}.cs-section-card{background:var(--semi-color-bg-1);margin-bottom:var(--cs-gap);border:1px solid var(--semi-color-border);border-radius:var(--cs-radius);min-width:0;box-shadow:0 2px 6px #12203a06}.cs-section-card .semi-card-header{padding:18px 20px 4px}.cs-section-card .semi-card-body{padding:16px 20px 20px}.cs-section-title{font-size:14px;font-weight:600}.cs-section-desc{font-size:12px;margin:0 0 12px!important}.cs-stat-grid{grid-template-columns:repeat(var(--cs-stat-columns,4), minmax(0, 1fr));margin-bottom:var(--cs-gap);gap:16px;display:grid}.cs-stat-card{border-radius:var(--cs-radius);background:var(--semi-color-bg-1);border:1px solid var(--semi-color-border);min-width:0}.cs-stat-card .semi-card-body{padding:18px 20px}.cs-stat-card.semi-button{text-align:start;white-space:normal;width:100%;height:auto;color:var(--semi-color-text-0);padding:18px 20px;display:block}.cs-stat-card.semi-button .semi-button-content{display:block}.cs-stat-card.is-clickable{transition:border-color .15s,box-shadow .15s}.cs-stat-card.is-clickable:hover{background:var(--semi-color-bg-1);border-color:var(--semi-color-primary-disabled);box-shadow:0 4px 16px var(--semi-color-fill-0)}.cs-stat-head{justify-content:space-between;align-items:center;gap:8px;display:flex}.cs-stat-label{font-size:12px;font-weight:400}.cs-stat-icon{color:var(--semi-color-primary);background:var(--semi-color-primary-light-default);border-radius:8px;padding:6px;display:inline-flex}.cs-stat-value{letter-spacing:-.8px;font-variant-numeric:tabular-nums;margin:8px 0 6px;font-size:30px;font-weight:650;line-height:1.3;display:block}.cs-stat-value.tone-danger,.cs-stat-icon.tone-danger{color:var(--semi-color-danger)}.cs-stat-value.tone-success,.cs-stat-icon.tone-success{color:var(--semi-color-success)}.cs-stat-value.tone-warning,.cs-stat-icon.tone-warning{color:var(--semi-color-warning)}.cs-stat-detail{color:var(--semi-color-text-2);font-size:11px;font-weight:400;line-height:1.6;display:block}.cs-table-wrap{width:100%;min-width:0}.cs-table-scroll{overflow-x:auto}.cs-table-toolbar{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin-bottom:16px;display:flex}.cs-table-toolbar-main{flex-wrap:wrap;align-items:center;gap:8px;min-width:0;display:flex}.cs-table-wrap .semi-table-thead>tr>th{color:var(--semi-color-text-2);background:var(--semi-color-fill-0);border-bottom-color:var(--semi-color-border);font-size:12px;font-weight:500}.cs-table-wrap .semi-table-tbody>tr>td{border-bottom-color:var(--semi-color-border);font-size:13px}.cs-table-empty{color:var(--semi-color-text-3);padding:40px 16px}.cs-table-empty .semi-empty-image{background:var(--semi-color-fill-0);border-radius:16px;padding:14px}.cs-error-banner{border-radius:8px;margin-bottom:16px}.cs-description-list{width:100%}.cs-description-list table{table-layout:fixed;width:100%}.cs-description-list td{word-break:break-word;vertical-align:top}.cs-description-list .semi-descriptions-item{padding:0 20px 16px 0}.cs-description-list .semi-descriptions-key{text-align:start;white-space:normal;font-size:12px;display:block}.cs-description-list .semi-descriptions-value{padding:4px 0 0;font-size:13px;display:block}.cs-drawer .semi-sidesheet-inner,.semi-sidesheet-inner,.semi-modal{max-width:100vw}.cs-markdown{overflow-wrap:anywhere;font-size:13px;line-height:1.8}.cs-markdown pre{background:var(--semi-color-fill-0);border:1px solid var(--semi-color-border);border-radius:8px;padding:14px;overflow:auto}.cs-markdown code{font-family:SFMono-Regular,Consolas,monospace;font-size:12px}.cs-markdown table{border-collapse:collapse;max-width:100%;display:block;overflow-x:auto}.cs-markdown th,.cs-markdown td{border:1px solid var(--semi-color-border);padding:8px 12px}.cs-markdown img{max-width:100%}.cs-json-viewer{border:1px solid var(--semi-color-border);border-radius:8px;overflow:hidden}.cs-json-viewer-head{background:var(--semi-color-fill-0);justify-content:space-between;align-items:center;padding:8px 12px;display:flex}.cs-json-viewer-body{max-height:420px;margin:0;padding:16px;font-family:SFMono-Regular,Consolas,monospace;font-size:12px;line-height:1.65;overflow:auto}.cs-notification-panel{flex-direction:column;width:min(340px,100vw - 48px);max-height:420px;display:flex}.cs-notification-head{border-bottom:1px solid var(--semi-color-border);justify-content:space-between;align-items:center;padding-bottom:10px;display:flex}.cs-notification-list{flex-direction:column;gap:4px;padding-top:12px;display:flex;overflow:auto}.cs-notification-item{text-align:start;cursor:pointer;color:inherit;background:0 0;border:none;border-radius:8px;align-items:flex-start;gap:10px;padding:10px 8px;display:flex}.cs-notification-item:hover{background:var(--semi-color-fill-0)}.cs-notification-dot{background:var(--semi-color-primary);border-radius:50%;flex:0 0 6px;width:6px;height:6px;margin-top:6px}.cs-notification-dot.level-p0{background:var(--semi-color-danger)}.cs-notification-dot.level-p1{background:var(--semi-color-warning)}.cs-notification-body{flex-direction:column;gap:4px;min-width:0;display:flex}.cs-notification-title{font-size:13px;line-height:1.5}.cs-notification-meta{color:var(--semi-color-text-2);font-size:11px}.cs-login-page{background:var(--semi-color-bg-1);grid-template-columns:1fr 1fr;min-height:100dvh;display:grid}.cs-login-story{background:var(--semi-color-bg-0);border-inline-end:1px solid var(--semi-color-border);flex-direction:column;justify-content:space-between;padding:40px clamp(32px,6vw,96px);display:flex}.cs-login-brand{align-items:center;gap:10px;display:flex}.cs-login-logo{border-radius:10px;width:36px;height:36px}.cs-login-intro{max-width:480px;margin-block-start:64px;margin-block-end:64px}.cs-login-emblem{color:var(--semi-color-primary);background:var(--semi-color-primary-light-default);border:1px solid var(--semi-color-primary-light-active);border-radius:16px;margin-bottom:28px;padding:16px;display:inline-flex}.cs-login-headline{text-wrap:balance;letter-spacing:-1px;margin:0 0 18px!important;font-size:clamp(30px,3vw,44px)!important;line-height:1.4!important}.cs-login-features{flex-direction:column;gap:20px;margin-top:40px;display:flex}.cs-login-feature{color:var(--semi-color-text-2);align-items:center;gap:14px;font-size:13px;display:flex}.cs-login-feature strong{color:var(--semi-color-text-1);margin-bottom:4px;font-weight:550;display:block}.cs-login-form-panel{justify-content:center;align-items:center;padding:40px;display:flex}.cs-login-card.semi-card{width:100%;max-width:390px;box-shadow:none;background:0 0}.cs-login-card .semi-card-body{padding:0}.cs-login-form-heading{letter-spacing:-.5px;margin:0 0 8px!important;font-size:28px!important}.cs-login-form{margin-top:32px}.cs-login-form .semi-form-field{padding-top:0;padding-bottom:24px}.cs-login-form .semi-input-wrapper{background:var(--semi-color-bg-1);border:1px solid var(--semi-color-border)}.cs-login-note{text-align:center;margin-top:24px;font-size:12px;display:block}@media (max-width:1200px){.cs-stat-grid{--cs-stat-columns:2!important}.cs-content{padding:22px}.cs-content-workspace{padding:14px}}@media (max-width:900px){.cs-content{padding:18px 16px 28px}.cs-content-workspace{padding:10px}.cs-header{padding-inline-start:12px;padding-inline-end:12px}.cs-user-name,.cs-header-crumb .semi-breadcrumb-item:not(:last-child),.cs-header-crumb .semi-breadcrumb-separator{display:none}.cs-page-title{font-size:22px!important}.cs-login-story{padding:32px}}@media (max-width:640px){.cs-stat-grid{gap:10px}.cs-stat-card.semi-button,.cs-stat-card .semi-card-body{padding:14px}.cs-stat-value{font-size:26px}.cs-stat-icon{padding:4px}.cs-page-header{flex-direction:column;align-items:stretch;gap:12px;margin-bottom:18px}.cs-page-header-extra{align-self:flex-start}.cs-table-wrap .semi-table-pagination-outer{flex-wrap:wrap;gap:12px;padding-block-start:12px;padding-block-end:12px}.cs-table-wrap .semi-table-pagination-info{white-space:nowrap;font-size:12px}.cs-table-wrap .semi-pagination{flex-wrap:wrap}.cs-section-card .semi-card-header{padding-inline-start:16px;padding-inline-end:16px}.cs-section-card .semi-card-body{padding:12px 16px 16px}.cs-description-list table,.cs-description-list tr,.cs-description-list tbody{display:block}.cs-description-list td,.cs-description-list th{width:100%;display:block}.cs-login-page{grid-template-columns:1fr;align-content:center;padding:28px}.cs-login-story{background:0 0;border:0;align-items:center;padding:0}.cs-login-intro,.cs-login-story>.semi-typography{display:none}.cs-login-form-panel{padding:44px 0 0}.cs-login-form-heading{font-size:24px!important}}@media (prefers-reduced-motion:reduce){.cs-sider,.cs-stat-card,.cs-nav{transition:none}}
+:root,body[theme-mode]{--cs-header-height:60px;--cs-sider-width:224px;--cs-sider-collapsed:64px;--cs-radius:12px;--cs-gap:20px;--cs-accent:var(--semi-color-primary);--semi-color-primary:#3266e3;--semi-color-primary-hover:#2758cc;--semi-color-primary-active:#2049ae;--semi-color-primary-disabled:#b6c8f3;--semi-color-primary-light-default:#edf2ff;--semi-color-primary-light-hover:#e3ebff;--semi-color-primary-light-active:#d6e2ff;--semi-color-focus-border:#3266e3;--semi-color-bg-0:#f5f7fb;--semi-color-bg-1:#fff;--semi-color-bg-2:#f9fafe;--semi-color-nav-bg:#fff;--semi-color-text-0:#192438;--semi-color-text-1:#465269;--semi-color-text-2:#737f93;--semi-color-text-3:#a0a9b8;--semi-color-border:#2437581a;--semi-color-fill-0:#24375809;--semi-color-fill-1:#24375811;--semi-border-radius-small:6px;--semi-border-radius-medium:8px;--semi-border-radius-large:12px}html[data-theme=dark],body[theme-mode=dark]{--semi-color-primary:#81a7ff;--semi-color-primary-hover:#a0bdff;--semi-color-primary-active:#b9ceff;--semi-color-primary-disabled:#34486e;--semi-color-primary-light-default:#202d48;--semi-color-primary-light-hover:#293954;--semi-color-primary-light-active:#32486d;--semi-color-focus-border:#81a7ff;--semi-color-bg-0:#111620;--semi-color-bg-1:#1a212e;--semi-color-bg-2:#202837;--semi-color-nav-bg:#161c27;--semi-color-text-0:#e8edf6;--semi-color-text-1:#bdc7d8;--semi-color-text-2:#929fb5;--semi-color-text-3:#66738b;--semi-color-border:#a7b8d71f;--semi-color-fill-0:#a7b8d70b;--semi-color-fill-1:#a7b8d716}html,body,#root{height:100%}body{background:var(--semi-color-bg-0);color:var(--semi-color-text-0);-webkit-font-smoothing:antialiased;margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,Microsoft YaHei,sans-serif}*{box-sizing:border-box}:focus-visible{outline:2px solid var(--semi-color-focus-border);outline-offset:3px}::selection{background:var(--semi-color-primary-light-active)}body[theme-mode=dark] .semi-button-primary.semi-button-solid:not(.semi-button-disabled){color:var(--semi-color-bg-0)}.cs-shell{background:var(--semi-color-bg-0);height:100dvh;display:flex;overflow:hidden}.cs-sider{flex:0 0 var(--cs-sider-width);width:var(--cs-sider-width);border-inline-end:1px solid var(--semi-color-border);background:var(--semi-color-nav-bg);height:100%;transition:width .18s,flex-basis .18s;overflow:hidden}.cs-shell.is-collapsed .cs-sider{flex-basis:var(--cs-sider-collapsed);width:var(--cs-sider-collapsed)}.cs-sidebar-inner{background:var(--semi-color-nav-bg);flex-direction:column;height:100%;display:flex}.cs-brand.semi-button{border-radius:0;flex:0 0 76px;justify-content:flex-start;height:76px;padding:0 20px}.cs-brand.semi-button:hover{background:0 0}.cs-brand .semi-button-content{gap:10px}.cs-brand-logo{object-fit:contain;border-radius:8px;width:30px;height:30px}.cs-brand-name{letter-spacing:-.6px;color:var(--semi-color-text-0);font-size:17px;font-weight:750}.cs-brand-name>span{color:var(--semi-color-primary)}.is-compact .cs-brand{padding:0 17px}.cs-nav-scroll{scrollbar-width:thin;scrollbar-color:var(--semi-color-border) transparent;flex:1;min-height:0;padding-bottom:16px;overflow-y:auto}.cs-nav-section+.cs-nav-section{margin-top:20px}.cs-nav-section-label{color:var(--semi-color-text-2);letter-spacing:.8px;padding:0 24px 10px;font-size:11px;font-weight:500}.cs-nav.semi-navigation{background:0 0;border:0;padding-inline-start:12px;padding-inline-end:12px}.cs-nav .semi-navigation-item,.cs-nav .semi-navigation-sub-title{border-radius:7px;margin-bottom:3px;font-size:13px;font-weight:450}.cs-nav .semi-navigation-list>.semi-navigation-item-normal{height:36px}.cs-nav .semi-navigation-list>.semi-navigation-item,.cs-nav .semi-navigation-list>.semi-navigation-item>.semi-navigation-sub-title{font-weight:450}.cs-nav .semi-navigation-item-selected{color:var(--semi-color-primary);font-weight:600!important}.cs-nav .semi-navigation-item-icon-info{min-width:18px;margin-inline-end:10px}.cs-nav .semi-navigation-item-sub{padding:0}.cs-nav.semi-navigation-collapsed{padding-inline-start:8px;padding-inline-end:8px}.is-compact .cs-nav-section+.cs-nav-section{border-top:1px solid var(--semi-color-border);margin-top:12px;padding-top:12px}.cs-nav-footer{border-top:1px solid var(--semi-color-border);padding:10px 12px}.cs-nav-footer .semi-button{justify-content:flex-start;font-size:12px}.is-compact .cs-nav-footer{padding-inline-start:8px;padding-inline-end:8px}.is-compact .cs-nav-footer .semi-button{justify-content:center}.cs-mobile-nav .semi-sidesheet-body{overflow:hidden}.cs-main{flex-direction:column;flex:1;min-width:0;height:100%;display:flex}.cs-header{height:var(--cs-header-height);flex:0 0 var(--cs-header-height);border-bottom:1px solid var(--semi-color-border);background:var(--semi-color-bg-1);justify-content:space-between;align-items:center;gap:12px;padding:0 28px;display:flex}.cs-header-left{align-items:center;gap:8px;min-width:0;display:flex}.cs-header-crumb{min-width:0;font-size:12px}.cs-header-actions{flex-shrink:0}.cs-header-actions>.semi-space-item:last-child{border-inline-start:1px solid var(--semi-color-border);padding-inline-start:8px;margin-inline-start:8px!important}.cs-user-trigger.semi-button{height:36px;padding-inline-start:6px;padding-inline-end:6px}.cs-user-trigger .semi-button-content{gap:8px}.cs-user-name{text-overflow:ellipsis;white-space:nowrap;max-width:120px;font-size:12px;font-weight:500;overflow:hidden}.cs-content{flex:1;min-height:0;padding:28px 28px 36px;overflow:auto}.cs-content-workspace{padding:18px;overflow:hidden}.cs-page-loading{justify-content:center;align-items:center;height:60vh;display:flex}.cs-page-header{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:16px;margin-bottom:24px;display:flex}.cs-page-header-main{flex-direction:column;gap:6px;min-width:0;display:flex}.cs-page-title{letter-spacing:-.5px;margin:0!important;font-size:24px!important;font-weight:650!important}.cs-page-desc{font-size:13px;line-height:1.7}.cs-page-header-extra{flex-wrap:wrap}.cs-section-card{background:var(--semi-color-bg-1);margin-bottom:var(--cs-gap);border:1px solid var(--semi-color-border);border-radius:var(--cs-radius);min-width:0;box-shadow:0 2px 6px #12203a06}.cs-section-card .semi-card-header{padding:18px 20px 4px}.cs-section-card .semi-card-body{padding:16px 20px 20px}.cs-section-title{font-size:14px;font-weight:600}.cs-section-desc{font-size:12px;margin:0 0 12px!important}.cs-stat-grid{grid-template-columns:repeat(var(--cs-stat-columns,4), minmax(0, 1fr));margin-bottom:var(--cs-gap);gap:16px;display:grid}.cs-stat-card{border-radius:var(--cs-radius);background:var(--semi-color-bg-1);border:1px solid var(--semi-color-border);min-width:0}.cs-stat-card .semi-card-body{padding:18px 20px}.cs-stat-card.semi-button{text-align:start;white-space:normal;width:100%;height:auto;color:var(--semi-color-text-0);padding:18px 20px;display:block}.cs-stat-card.semi-button .semi-button-content{display:block}.cs-stat-card.is-clickable{transition:border-color .15s,box-shadow .15s}.cs-stat-card.is-clickable:hover{background:var(--semi-color-bg-1);border-color:var(--semi-color-primary-disabled);box-shadow:0 4px 16px var(--semi-color-fill-0)}.cs-stat-head{justify-content:space-between;align-items:center;gap:8px;display:flex}.cs-stat-label{font-size:12px;font-weight:400}.cs-stat-icon{color:var(--semi-color-primary);background:var(--semi-color-primary-light-default);border-radius:8px;padding:6px;display:inline-flex}.cs-stat-value{letter-spacing:-.8px;font-variant-numeric:tabular-nums;margin:8px 0 6px;font-size:30px;font-weight:650;line-height:1.3;display:block}.cs-stat-value.tone-danger,.cs-stat-icon.tone-danger{color:var(--semi-color-danger)}.cs-stat-value.tone-success,.cs-stat-icon.tone-success{color:var(--semi-color-success)}.cs-stat-value.tone-warning,.cs-stat-icon.tone-warning{color:var(--semi-color-warning)}.cs-stat-detail{color:var(--semi-color-text-2);font-size:11px;font-weight:400;line-height:1.6;display:block}.cs-table-wrap{width:100%;min-width:0}.cs-table-scroll{overflow-x:auto}.cs-table-toolbar{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin-bottom:16px;display:flex}.cs-table-toolbar-main{flex-wrap:wrap;align-items:center;gap:8px;min-width:0;display:flex}.cs-table-wrap .semi-table-thead>tr>th{color:var(--semi-color-text-2);background:var(--semi-color-fill-0);border-bottom-color:var(--semi-color-border);font-size:12px;font-weight:500}.cs-table-wrap .semi-table-tbody>tr>td{border-bottom-color:var(--semi-color-border);font-size:13px}.cs-table-empty{color:var(--semi-color-text-3);padding:40px 16px}.cs-table-empty .semi-empty-image{background:var(--semi-color-fill-0);border-radius:16px;padding:14px}.cs-error-banner{border-radius:8px;margin-bottom:16px}.cs-severity-tag[data-severity=low]{color:#154d91;background-color:#dceafe}.cs-severity-tag[data-severity=medium]{color:#744900;background-color:#ffebbb}.cs-severity-tag[data-severity=high]{color:#8f2e19;background-color:#ffccb6}body[theme-mode=dark] .cs-severity-tag[data-severity=low]{color:#bcdcff;background-color:#224875}body[theme-mode=dark] .cs-severity-tag[data-severity=medium]{color:#ffe09a;background-color:#63491b}body[theme-mode=dark] .cs-severity-tag[data-severity=high]{color:#ffbe9e;background-color:#662f20}.cs-description-list{width:100%}.cs-description-list table{table-layout:fixed;width:100%}.cs-description-list td{word-break:break-word;vertical-align:top}.cs-description-list .semi-descriptions-item{padding:0 20px 16px 0}.cs-description-list .semi-descriptions-key{text-align:start;white-space:normal;font-size:12px;display:block}.cs-description-list .semi-descriptions-value{padding:4px 0 0;font-size:13px;display:block}.cs-drawer .semi-sidesheet-inner,.semi-sidesheet-inner,.semi-modal{max-width:100vw}.cs-markdown{overflow-wrap:anywhere;font-size:13px;line-height:1.8}.cs-markdown pre{background:var(--semi-color-fill-0);border:1px solid var(--semi-color-border);border-radius:8px;padding:14px;overflow:auto}.cs-markdown code{font-family:SFMono-Regular,Consolas,monospace;font-size:12px}.cs-markdown table{border-collapse:collapse;max-width:100%;display:block;overflow-x:auto}.cs-markdown th,.cs-markdown td{border:1px solid var(--semi-color-border);padding:8px 12px}.cs-markdown img{max-width:100%}.cs-json-viewer{border:1px solid var(--semi-color-border);border-radius:8px;overflow:hidden}.cs-json-viewer-head{background:var(--semi-color-fill-0);justify-content:space-between;align-items:center;padding:8px 12px;display:flex}.cs-json-viewer-body{max-height:420px;margin:0;padding:16px;font-family:SFMono-Regular,Consolas,monospace;font-size:12px;line-height:1.65;overflow:auto}.cs-notification-panel{flex-direction:column;width:min(340px,100vw - 48px);max-height:420px;display:flex}.cs-notification-head{border-bottom:1px solid var(--semi-color-border);justify-content:space-between;align-items:center;padding-bottom:10px;display:flex}.cs-notification-list{flex-direction:column;gap:4px;padding-top:12px;display:flex;overflow:auto}.cs-notification-item{text-align:start;cursor:pointer;color:inherit;background:0 0;border:none;border-radius:8px;align-items:flex-start;gap:10px;padding:10px 8px;display:flex}.cs-notification-item:hover{background:var(--semi-color-fill-0)}.cs-notification-dot{background:var(--semi-color-primary);border-radius:50%;flex:0 0 6px;width:6px;height:6px;margin-top:6px}.cs-notification-dot.level-p0{background:var(--semi-color-danger)}.cs-notification-dot.level-p1{background:var(--semi-color-warning)}.cs-notification-body{flex-direction:column;gap:4px;min-width:0;display:flex}.cs-notification-title{font-size:13px;line-height:1.5}.cs-notification-meta{color:var(--semi-color-text-2);font-size:11px}.cs-login-page{background:var(--semi-color-bg-1);grid-template-columns:1fr 1fr;min-height:100dvh;display:grid}.cs-login-story{background:var(--semi-color-bg-0);border-inline-end:1px solid var(--semi-color-border);flex-direction:column;justify-content:space-between;padding:40px clamp(32px,6vw,96px);display:flex}.cs-login-brand{align-items:center;gap:10px;display:flex}.cs-login-logo{border-radius:10px;width:36px;height:36px}.cs-login-intro{max-width:480px;margin-block-start:64px;margin-block-end:64px}.cs-login-emblem{color:var(--semi-color-primary);background:var(--semi-color-primary-light-default);border:1px solid var(--semi-color-primary-light-active);border-radius:16px;margin-bottom:28px;padding:16px;display:inline-flex}.cs-login-headline{text-wrap:balance;letter-spacing:-1px;margin:0 0 18px!important;font-size:clamp(30px,3vw,44px)!important;line-height:1.4!important}.cs-login-features{flex-direction:column;gap:20px;margin-top:40px;display:flex}.cs-login-feature{color:var(--semi-color-text-2);align-items:center;gap:14px;font-size:13px;display:flex}.cs-login-feature strong{color:var(--semi-color-text-1);margin-bottom:4px;font-weight:550;display:block}.cs-login-form-panel{justify-content:center;align-items:center;padding:40px;display:flex}.cs-login-card.semi-card{width:100%;max-width:390px;box-shadow:none;background:0 0}.cs-login-card .semi-card-body{padding:0}.cs-login-form-heading{letter-spacing:-.5px;margin:0 0 8px!important;font-size:28px!important}.cs-login-form{margin-top:32px}.cs-login-form .semi-form-field{padding-top:0;padding-bottom:24px}.cs-login-form .semi-input-wrapper{background:var(--semi-color-bg-1);border:1px solid var(--semi-color-border)}.cs-login-note{text-align:center;margin-top:24px;font-size:12px;display:block}@media (max-width:1200px){.cs-stat-grid{--cs-stat-columns:2!important}.cs-content{padding:22px}.cs-content-workspace{padding:14px}}@media (max-width:900px){.cs-content{padding:18px 16px 28px}.cs-content-workspace{padding:10px}.cs-header{padding-inline-start:12px;padding-inline-end:12px}.cs-user-name,.cs-header-crumb .semi-breadcrumb-item:not(:last-child),.cs-header-crumb .semi-breadcrumb-separator{display:none}.cs-page-title{font-size:22px!important}.cs-login-story{padding:32px}}@media (max-width:640px){.cs-stat-grid{gap:10px}.cs-stat-card.semi-button,.cs-stat-card .semi-card-body{padding:14px}.cs-stat-value{font-size:26px}.cs-stat-icon{padding:4px}.cs-page-header{flex-direction:column;align-items:stretch;gap:12px;margin-bottom:18px}.cs-page-header-extra{align-self:flex-start}.cs-table-wrap .semi-table-pagination-outer{flex-wrap:wrap;gap:12px;padding-block-start:12px;padding-block-end:12px}.cs-table-wrap .semi-table-pagination-info{white-space:nowrap;font-size:12px}.cs-table-wrap .semi-pagination{flex-wrap:wrap}.cs-section-card .semi-card-header{padding-inline-start:16px;padding-inline-end:16px}.cs-section-card .semi-card-body{padding:12px 16px 16px}.cs-description-list table,.cs-description-list tr,.cs-description-list tbody{display:block}.cs-description-list td,.cs-description-list th{width:100%;display:block}.cs-login-page{grid-template-columns:1fr;align-content:center;padding:28px}.cs-login-story{background:0 0;border:0;align-items:center;padding:0}.cs-login-intro,.cs-login-story>.semi-typography{display:none}.cs-login-form-panel{padding:44px 0 0}.cs-login-form-heading{font-size:24px!important}}@media (prefers-reduced-motion:reduce){.cs-sider,.cs-stat-card,.cs-nav{transition:none}}
diff --git a/web/static/app/assets/index-BoFwOeaz.js b/web/static/app/assets/index-smFoxEJu.js
similarity index 77%
rename from web/static/app/assets/index-BoFwOeaz.js
rename to web/static/app/assets/index-smFoxEJu.js
index c109f16d..9f4c4642 100644
--- a/web/static/app/assets/index-BoFwOeaz.js
+++ b/web/static/app/assets/index-smFoxEJu.js
@@ -1,4 +1,4 @@
-const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dashboard-D1HqCY0Z.js","assets/rolldown-runtime-WkwZ5CU-.js","assets/react-QV7DAAIx.js","assets/semi-DNxeCrHm.js","assets/semi-BUXPdXzR.css","assets/dashboard-D9e788e7.css","assets/chat-QPrSpZt5.js","assets/model-channel-mQ6lfvSO.js","assets/chat-Cev5dYVZ.css","assets/deep-assessments-ClJUMWIn.js","assets/deep-assessments-BozGnBS7.css","assets/hitl-CKnRMfmB.js","assets/hitl-ChWaPsj1.css","assets/tool-guard-N0U5tG4f.js","assets/tool-guard-DKIWLN1V.css","assets/projects-C64S62xe.js","assets/projects-DtTkHn99.css","assets/asset-overview-DNWfmRJG.js","assets/assetTarget-CAuOtA9X.js","assets/asset-overview-DEMYiRVr.css","assets/asset-library-KPChFll7.js","assets/asset-library-Cj3Xw0tX.css","assets/info-collect-C3MqtyT0.js","assets/info-collect-S9i-bIJW.css","assets/vulnerabilities-CrqPtr3j.js","assets/vulnerabilities-GARkqqsQ.css","assets/tasks-CqEzUceO.js","assets/tasks-BtBBHKoW.css","assets/workflows-BdNfetHA.js","assets/workflows-EsKm07MV.css","assets/webshell-BKoDG5yt.js","assets/webshell-BVuBPlfW.css","assets/c2-listeners-D_Bx-B-I.js","assets/c2-shared-DQceLFCe.js","assets/c2-shared-BRGOsG9Y.css","assets/c2-shared-BkIzs15k.js","assets/c2-listeners-KjhK45yg.css","assets/c2-sessions-C4zx-oqJ.js","assets/c2-sessions-DLf_n8Eq.css","assets/c2-tasks-t5h6GDhv.js","assets/c2-tasks-B5H34xZF.css","assets/c2-payloads-C_C_YA7N.js","assets/c2-payloads-CnRJmaJm.css","assets/c2-events-DTCXaUlN.js","assets/c2-events-BVd4qqKy.css","assets/c2-profiles-C1JrB05z.js","assets/c2-profiles-BpNJlhDC.css","assets/chat-files-CTTAptxF.js","assets/chat-files-wKL7Vwmw.css","assets/mcp-monitor-BENVJarN.js","assets/mcp-monitor-8VvqmnVY.css","assets/mcp-management-ClIRzGxS.js","assets/mcp-management-CEr7J00D.css","assets/knowledge-retrieval-logs-DkihRY3X.js","assets/knowledge-management-COpgsLN2.js","assets/skills-monitor-BiZ6uLnX.js","assets/skills-management-h0lK3HYq.js","assets/agents-management-CsADEV29.js","assets/roles-management-BVS050uQ.js","assets/platform-rbac-CCzPRjms.js","assets/settings-BEsIqHkk.js","assets/settings-NkpD57yG.css","assets/api-docs-BLHNGrWi.js","assets/api-docs-B_T3BEfL.css"])))=>i.map(i=>d[i]);
+const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dashboard-Bc2usnZH.js","assets/rolldown-runtime-WkwZ5CU-.js","assets/react-QV7DAAIx.js","assets/semi-DNxeCrHm.js","assets/semi-BUXPdXzR.css","assets/dashboard-D9e788e7.css","assets/chat-4zuVcYax.js","assets/model-channel-mQ6lfvSO.js","assets/chat-Cev5dYVZ.css","assets/deep-assessments-cnrXHaFd.js","assets/deep-assessments-BozGnBS7.css","assets/hitl-DCNZaIEz.js","assets/hitl-ChWaPsj1.css","assets/tool-guard-BvyFvMCC.js","assets/tool-guard-DKIWLN1V.css","assets/projects-DwN7tLJD.js","assets/projects-DtTkHn99.css","assets/asset-overview-BmQ_1q6a.js","assets/assetTarget-CAuOtA9X.js","assets/asset-overview-DEMYiRVr.css","assets/asset-library-BAx0Ul3g.js","assets/asset-library-Cj3Xw0tX.css","assets/info-collect-3BNPr4lS.js","assets/info-collect-S9i-bIJW.css","assets/vulnerabilities-BdUlHMo2.js","assets/vulnerabilities-GARkqqsQ.css","assets/tasks-VQP5hHjc.js","assets/tasks-BtBBHKoW.css","assets/workflows-BMEk6u8D.js","assets/workflows-EsKm07MV.css","assets/webshell-BFjIk3Ns.js","assets/webshell-BVuBPlfW.css","assets/c2-listeners-Czsz18uH.js","assets/c2-shared-B5kg9aBy.js","assets/c2-shared-BRGOsG9Y.css","assets/c2-shared-BBQQ9OoL.js","assets/c2-listeners-KjhK45yg.css","assets/c2-sessions-CzZrurOn.js","assets/c2-sessions-DLf_n8Eq.css","assets/c2-tasks-gSo_kNWy.js","assets/c2-tasks-B5H34xZF.css","assets/c2-payloads-DvqcThjq.js","assets/c2-payloads-CnRJmaJm.css","assets/c2-events-CoH3yyOa.js","assets/c2-events-BVd4qqKy.css","assets/c2-profiles-CoAwMcjF.js","assets/c2-profiles-BpNJlhDC.css","assets/chat-files-BYjs9VE-.js","assets/chat-files-wKL7Vwmw.css","assets/mcp-monitor-CcafUVpf.js","assets/mcp-monitor-8VvqmnVY.css","assets/mcp-management-CpurAL-_.js","assets/mcp-management-CEr7J00D.css","assets/knowledge-retrieval-logs-D4Ccl_5u.js","assets/knowledge-management-CBCh6sv1.js","assets/skills-monitor-L6Gdi19j.js","assets/skills-management-CZ3ZF0wd.js","assets/agents-management-8Q9eU0Fw.js","assets/roles-management-BjLBenwe.js","assets/platform-rbac-BG70WbmN.js","assets/settings-BOqxpbJE.js","assets/settings-NkpD57yG.css","assets/api-docs-Cq--SCZD.js","assets/api-docs-B_T3BEfL.css"])))=>i.map(i=>d[i]);
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{$ as t,A as n,At as r,B as i,C as a,Ct as o,Dt as s,E as c,Et as l,F as u,Ft as d,G as f,H as p,I as m,It as h,K as ee,L as g,Lt as te,Mt as ne,N as re,Nt as _,O as ie,Ot as v,P as y,Pt as ae,R as oe,S as b,St as se,U as ce,Vt as le,W as ue,X as de,Y as fe,_t as pe,at as me,ct as he,d as ge,dt as _e,et as ve,ft as ye,gt as be,i as xe,it as x,j as Se,kt as Ce,l as we,lt as Te,mt as Ee,n as De,o as Oe,pt as ke,r as Ae,t as S,tt as je,ut as C,v as Me,vt as w,w as Ne,z as Pe}from"./semi-DNxeCrHm.js";import{S as T,b as Fe,d as Ie,f as Le,g as Re,h as E,l as ze,m as Be,p as Ve,t as He,v as Ue}from"./react-QV7DAAIx.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var D=e(T(),1),We=Fe(),Ge=`cyberstrike-auth`;function Ke(){try{let e=localStorage.getItem(Ge);if(!e)return null;let t=JSON.parse(e);if(!t?.token||!t?.expiresAt)return null;let n=new Date(t.expiresAt);return!Number.isFinite(n.getTime())||n.getTime()<=Date.now()?null:{token:t.token,expiresAt:n.toISOString(),user:t.user||null,roles:Array.isArray(t.roles)?t.roles:[],permissions:Array.isArray(t.permissions)?t.permissions:[],scope:t.scope||``}}catch(e){return console.warn(`读取会话失败:`,e),null}}function qe(e){e?localStorage.setItem(Ge,JSON.stringify(e)):localStorage.removeItem(Ge)}var Je=null;function Ye(e){Je=e||null}var Xe=class extends Error{constructor(e,{status:t=0,payload:n=null,path:r=``}={}){super(e),this.name=`ApiError`,this.status=t,this.payload=n,this.path=r}};function Ze(e,t){let n=e.startsWith(`http`)?e:`/api${e.startsWith(`/`)?e:`/${e}`}`;if(!t)return n;let r=new URLSearchParams;for(let[e,n]of Object.entries(t))n!=null&&n!==``&&(Array.isArray(n)?n.forEach(t=>r.append(e,t)):r.append(e,String(n)));let i=r.toString();return i?`${n}${n.includes(`?`)?`&`:`?`}${i}`:n}async function Qe(e){let t=e.headers.get(`content-type`)||``;try{if(t.includes(`application/json`)){let t=await e.json();return{message:t.error||t.message||`请求失败(HTTP ${e.status})`,payload:t}}let n=await e.text();return{message:n?.slice(0,300)||`请求失败(HTTP ${e.status})`,payload:n}}catch{return{message:`请求失败(HTTP ${e.status})`,payload:null}}}async function O(e,t={}){let{method:n=`GET`,body:r,query:i,headers:a={},signal:o,raw:s=!1,timeout:c=6e4}=t,l={Accept:`application/json`,...a},u=r;r!=null&&!(r instanceof FormData)&&typeof r!=`string`&&!(r instanceof Blob)&&(l[`Content-Type`]=`application/json`,u=JSON.stringify(r)),Je&&!l.Authorization&&(l.Authorization=`Bearer ${Je}`);let d=new AbortController,f=c?setTimeout(()=>d.abort(),c):null,p=()=>d.abort();o&&(o.aborted?d.abort():o.addEventListener(`abort`,p,{once:!0}));let m;try{m=await fetch(Ze(e,i),{method:n,headers:l,body:u,signal:d.signal})}catch(t){throw t.name===`AbortError`?new Xe(`请求已取消`,{path:e}):new Xe(`网络连接失败,请检查服务状态`,{path:e})}finally{f&&clearTimeout(f),o&&o.removeEventListener(`abort`,p)}if(m.status===401&&window.dispatchEvent(new CustomEvent(`csai:unauthorized`)),!m.ok){let{message:t,payload:n}=await Qe(m);throw new Xe(t,{status:m.status,payload:n,path:e})}return s?m:m.status===204?null:(m.headers.get(`content-type`)||``).includes(`application/json`)?m.json():m.text()}var k={get:(e,t,n={})=>O(e,{...n,query:t}),post:(e,t,n={})=>O(e,{...n,method:`POST`,body:t}),put:(e,t,n={})=>O(e,{...n,method:`PUT`,body:t}),patch:(e,t,n={})=>O(e,{...n,method:`PATCH`,body:t}),del:(e,t={})=>O(e,{...t,method:`DELETE`}),raw:(e,t={})=>O(e,{...t,raw:!0})};async function $e(e,{query:t,filename:n,method:r=`GET`,body:i}={}){let a=await O(e,{method:r,body:i,query:t,raw:!0,timeout:12e4}),o=await a.blob(),s=a.headers.get(`content-disposition`)||``,c=s.match(/filename\*=UTF-8''([^;]+)/i),l=s.match(/filename="?([^";]+)"?/i),u=n||(c?decodeURIComponent(c[1]):l?.[1])||`download.bin`,d=URL.createObjectURL(o),f=document.createElement(`a`);return f.href=d,f.download=u,document.body.appendChild(f),f.click(),f.remove(),setTimeout(()=>URL.revokeObjectURL(d),1e3),u}function et(e,t,{onEvent:n,onError:r,onClose:i,signal:a}={}){let o=new AbortController;a&&(a.aborted?o.abort():a.addEventListener(`abort`,()=>o.abort(),{once:!0}));let s={"Content-Type":`application/json`,Accept:`text/event-stream`};return Je&&(s.Authorization=`Bearer ${Je}`),(async()=>{try{let r=await fetch(Ze(e),{method:`POST`,headers:s,body:JSON.stringify(t||{}),signal:o.signal});if(r.status===401&&window.dispatchEvent(new CustomEvent(`csai:unauthorized`)),!r.ok){let{message:t}=await Qe(r);throw new Xe(t,{status:r.status,path:e})}if(!r.body)throw new Xe(`服务端未返回流式响应`,{path:e});let a=r.body.getReader(),c=new TextDecoder,l=``,u=!1;for(;!u;){let{done:e,value:t}=await a.read();if(e)break;l+=c.decode(t,{stream:!0});let r;for(;(r=l.indexOf(`
`))>=0;){let e=l.slice(0,r).replace(/\r$/,``);if(l=l.slice(r+1),!e.startsWith(`data:`))continue;let t=e.slice(5).trim();if(!t)continue;if(t===`[DONE]`){u=!0;break}let i;try{i=JSON.parse(t)}catch{continue}n?.(i)}}i?.()}catch(e){if(e.name===`AbortError`){i?.();return}r?.(e)}})(),()=>o.abort()}function tt(e,t=`操作失败`){return e?typeof e==`string`?e:e.message||t:t}var A=e(He(),1),nt=(0,D.createContext)(null);function rt(e,t){return e?{token:t||e.token,expiresAt:e.expires_at||e.expiresAt||``,user:e.user||null,roles:Array.isArray(e.roles)?e.roles:[],permissions:Array.isArray(e.permissions)?e.permissions:[],scope:e.scope||``}:null}function it({children:e}){let t=(0,D.useRef)(Ke()).current,[n,r]=(0,D.useState)(t),[i,a]=(0,D.useState)(!!t);(0,D.useEffect)(()=>{if(Ye(t?.token||null),!t?.token){a(!1);return}let e=!1;return k.get(`/auth/validate`).then(n=>{if(e)return;let i=rt(n,t.token);r(i),qe(i)}).catch(()=>{e||(r(null),qe(null),Ye(null))}).finally(()=>{e||a(!1)}),()=>{e=!0}},[]);let o=(0,D.useCallback)(()=>{r(null),Ye(null),qe(null)},[]);(0,D.useEffect)(()=>{let e=()=>o();return window.addEventListener(`csai:unauthorized`,e),()=>window.removeEventListener(`csai:unauthorized`,e)},[o]);let s=(0,D.useCallback)(async(e,t)=>{let n=await k.post(`/auth/login`,{username:String(e||``).trim(),password:t}),i=rt(n,n?.token);return Ye(i?.token||null),qe(i),r(i),i},[]),c=(0,D.useCallback)(async()=>{try{await k.post(`/auth/logout`,{})}catch{}o()},[o]),l=(0,D.useMemo)(()=>new Set(n?.permissions||[]),[n]),u=(0,D.useCallback)(e=>!e||String(e).split(/\s+/).some(e=>l.has(e)),[l]),d=(0,D.useCallback)(e=>{let t=Array.isArray(e)?e:String(e||``).split(/\s+/).filter(Boolean);return!t.length||t.some(e=>l.has(e))},[l]),f=(0,D.useCallback)(async()=>{if(!n?.token)return null;let e=rt(await k.get(`/auth/validate`),n.token);return r(e),qe(e),e},[n?.token]),p=(0,D.useMemo)(()=>({session:n,user:n?.user||null,roles:n?.roles||[],permissions:l,hasPermission:u,hasAnyPermission:d,checking:i,authenticated:!!n?.token,login:s,logout:c,refresh:f}),[n,l,u,d,i,s,c,f]);return(0,A.jsx)(nt.Provider,{value:p,children:e})}function j(){let e=(0,D.useContext)(nt);if(!e)throw Error(`useAuth 必须在 AuthProvider 内使用`);return e}var M=[{id:`zh-CN`,label:`简体中文`},{id:`en-US`,label:`English`},{id:`ru-RU`,label:`Русский`},{id:`ar-SA`,label:`العربية`}],at=`csai_lang`,ot=`zh-CN`,st=`/static/i18n`,ct=new Map;function lt(){try{let e=localStorage.getItem(at);if(e&&M.some(t=>t.id===e))return e}catch{}let e=String(navigator.language||``).toLowerCase();return e.startsWith(`zh`)?`zh-CN`:e.startsWith(`ru`)?`ru-RU`:e.startsWith(`ar`)?`ar-SA`:e.startsWith(`en`)?`en-US`:ot}function ut(e){return ct.has(e)||ct.set(e,fetch(`${st}/${e}.json`,{cache:`no-cache`}).then(e=>e.ok?e.json():{}).catch(()=>({}))),ct.get(e)}function dt(e,t){if(!e)return;let n=e;for(let e of String(t).split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return typeof n==`string`?n:void 0}function ft(e,t){return t?e.replace(/\{\{\s*(\w+)\s*\}\}/g,(e,n)=>t[n]===void 0?e:String(t[n])):e}var pt=(0,D.createContext)({lang:ot,t:e=>e,ready:!1,setLanguage:()=>{}});function mt({children:e}){let[t,n]=(0,D.useState)(lt),[r,i]=(0,D.useState)({}),[a,o]=(0,D.useState)(!1);(0,D.useEffect)(()=>{let e=!1;Promise.all([ut(t),ut(ot),ut(`en-US`)]).then(([t,n,r])=>{e||(i({current:t,fallback:n,english:r}),o(!0))}),document.documentElement.lang=t,document.documentElement.dir=t===`ar-SA`?`rtl`:`ltr`;try{localStorage.setItem(at,t)}catch{}return()=>{e=!0}},[t]);let s=(0,D.useCallback)((e,t,n)=>{if(!e)return n??``;let i=dt(r.current,e)??dt(r.fallback,e)??dt(r.english,e);return i===void 0?n??e:ft(i,t)},[r]),c=(0,D.useCallback)(e=>{e&&e!==t&&(o(!1),n(e),window.dispatchEvent(new CustomEvent(`csai:languagechange`,{detail:{lang:e}})))},[t]),l=(0,D.useMemo)(()=>({lang:t,t:s,ready:a,setLanguage:c}),[t,s,a,c]);return(0,A.jsx)(pt.Provider,{value:l,children:e})}function ht(){return(0,D.useContext)(pt)}function N(){return(0,D.useContext)(pt).t}var gt=`cyberstrike-theme`,_t=[`system`,`light`,`dark`];function vt(){try{let e=localStorage.getItem(gt);return _t.includes(e)?e:`system`}catch{return`system`}}function yt(){return typeof window<`u`&&window.matchMedia?window.matchMedia(`(prefers-color-scheme: dark)`).matches:!1}function bt(e){return e===`dark`||e===`light`?e:yt()?`dark`:`light`}function xt(e){let t=bt(e),n=document.documentElement;return n.setAttribute(`data-theme`,t),n.setAttribute(`data-theme-preference`,e),n.style.colorScheme=t,document.body?.setAttribute(`theme-mode`,t===`dark`?`dark`:`light`),t}var St=(0,D.createContext)({preference:`system`,theme:`light`,setPreference:()=>{},toggle:()=>{}});function Ct({children:e}){let[t,n]=(0,D.useState)(vt),[r,i]=(0,D.useState)(()=>bt(vt()));(0,D.useLayoutEffect)(()=>{i(xt(t));try{localStorage.setItem(gt,t)}catch{}if(t!==`system`||!window.matchMedia)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>i(xt(t));return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[t]),(0,D.useEffect)(()=>{document.body?.setAttribute(`theme-mode`,r===`dark`?`dark`:`light`)},[r]);let a=(0,D.useCallback)(e=>{_t.includes(e)&&n(e)},[]),o=(0,D.useCallback)(()=>{n(e=>bt(e)===`dark`?`light`:`dark`)},[]),s=(0,D.useMemo)(()=>({preference:t,theme:r,setPreference:a,toggle:o}),[t,r,a,o]);return(0,A.jsx)(St.Provider,{value:s,children:e})}function wt(){return(0,D.useContext)(St)}var Tt=[{id:`dashboard`,i18n:`nav.dashboard`,fallback:`仪表盘`,icon:Ee},{id:`chat`,i18n:`nav.chat`,fallback:`对话`,icon:o},{id:`deep-assessments`,i18n:`nav.deepAssessments`,fallback:`深度测评`,icon:te},{id:`security`,i18n:`nav.security`,fallback:`安全防护`,icon:t,anyPermission:[`hitl:read`,`config:read`],children:[{id:`hitl`,i18n:`nav.hitl`,fallback:`人机协同`,permission:`hitl:read`},{id:`tool-guard`,i18n:`nav.toolGuard`,fallback:`调用拦截`,permission:`config:read`}]},{id:`projects`,i18n:`nav.projects`,fallback:`项目管理`,icon:ne},{id:`assets`,i18n:`nav.assets`,fallback:`资产管理`,icon:pe,anyPermission:[`asset:read`,`fofa:execute`],children:[{id:`asset-overview`,i18n:`nav.assetOverview`,fallback:`资产概览`},{id:`asset-library`,i18n:`nav.assetLibrary`,fallback:`资产库`},{id:`info-collect`,i18n:`nav.infoCollect`,fallback:`信息收集`}]},{id:`vulnerabilities`,i18n:`nav.vulnerabilities`,fallback:`漏洞管理`,icon:t},{id:`tasks`,i18n:`nav.tasks`,fallback:`任务管理`,icon:r},{id:`workflows`,i18n:`nav.workflows`,fallback:`工作流`,icon:_},{id:`webshell`,i18n:`nav.webshell`,fallback:`WebShell管理`,icon:fe},{id:`c2`,i18n:`nav.c2`,fallback:`C2`,icon:d,children:[{id:`c2-listeners`,i18n:`nav.c2Listeners`,fallback:`监听器`},{id:`c2-sessions`,i18n:`nav.c2Sessions`,fallback:`会话`},{id:`c2-tasks`,i18n:`nav.c2Tasks`,fallback:`任务`},{id:`c2-payloads`,i18n:`nav.c2Payloads`,fallback:`载荷`},{id:`c2-events`,i18n:`nav.c2Events`,fallback:`事件`},{id:`c2-profiles`,i18n:`nav.c2Profiles`,fallback:`流量伪装`}]},{id:`chat-files`,i18n:`nav.chatFiles`,fallback:`文件管理`,icon:be},{id:`mcp`,i18n:`nav.mcp`,fallback:`MCP`,icon:je,children:[{id:`mcp-monitor`,i18n:`nav.mcpMonitor`,fallback:`MCP状态监控`},{id:`mcp-management`,i18n:`nav.mcpManagement`,fallback:`MCP管理`}]},{id:`knowledge`,i18n:`nav.knowledge`,fallback:`知识`,icon:ae,children:[{id:`knowledge-retrieval-logs`,i18n:`nav.knowledgeRetrievalLogs`,fallback:`检索历史`},{id:`knowledge-management`,i18n:`nav.knowledgeManagement`,fallback:`知识管理`}]},{id:`skills`,i18n:`nav.skills`,fallback:`技能`,icon:me,children:[{id:`skills-monitor`,i18n:`nav.skillsMonitor`,fallback:`技能状态`},{id:`skills-management`,i18n:`nav.skillsManagement`,fallback:`技能管理`}]},{id:`agents`,i18n:`nav.agents`,fallback:`智能体`,icon:f,children:[{id:`agents-management`,i18n:`nav.agentsManagement`,fallback:`智能体管理`}]},{id:`roles`,i18n:`nav.roles`,fallback:`角色`,icon:ee,children:[{id:`roles-management`,i18n:`nav.rolesManagement`,fallback:`角色管理`}]},{id:`platform-rbac`,i18n:`nav.platformRbac`,fallback:`平台权限`,icon:C},{id:`settings`,i18n:`nav.settings`,fallback:`系统设置`,icon:ve},{id:`api-docs`,i18n:`apiDocs.title`,fallback:`API 文档`,icon:te}],Et=[{id:`workspace`,i18n:`nav.groupWorkspace`,fallback:`工作台`,pages:[`dashboard`,`chat`,`deep-assessments`,`security`]},{id:`operations`,i18n:`nav.groupOperations`,fallback:`安全作业`,pages:[`projects`,`assets`,`vulnerabilities`,`tasks`,`workflows`,`webshell`,`c2`,`chat-files`]},{id:`capabilities`,i18n:`nav.groupCapabilities`,fallback:`能力中心`,pages:[`mcp`,`knowledge`,`skills`,`agents`,`roles`]},{id:`platform`,i18n:`nav.groupPlatform`,fallback:`平台管理`,pages:[`platform-rbac`,`settings`,`api-docs`]}],Dt=Tt.flatMap(e=>e.children?e.children.map(t=>({...t,parent:e.id})):[e]);function Ot(e){return Dt.find(t=>t.id===e)||Tt.find(t=>t.id===e)||null}function P(e){"@babel/helpers - typeof";return P=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},P(e)}function kt(e,t){if(P(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(P(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function At(e){var t=kt(e,`string`);return P(t)==`symbol`?t:t+``}function F(e,t,n){return(t=At(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var jt;function Mt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Nt=Mt();function Pt(e){Nt=e}var Ft={exec:()=>null};function I(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(L.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var It=(()=>{try{return!0}catch{return!1}})(),L={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`)},Lt=/^(?:[ \t]*(?:\n|$))+/,Rt=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,zt=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Bt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Vt=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ht=/(?:[*+-]|\d{1,9}[.)])/,Ut=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Wt=I(Ut).replace(/bull/g,Ht).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Gt=I(Ut).replace(/bull/g,Ht).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),R=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Kt=/^[^\n]+/,qt=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Jt=I(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,qt).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Yt=I(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Ht).getRegex(),z=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Xt=/|$))/,Zt=I(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Xt).replace(`tag`,z).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Qt=I(R).replace(`hr`,Bt).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,z).getRegex(),$t={blockquote:I(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Qt).getRegex(),code:Rt,def:Jt,fences:zt,heading:Vt,hr:Bt,html:Zt,lheading:Wt,list:Yt,newline:Lt,paragraph:Qt,table:Ft,text:Kt},en=I(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Bt).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,z).getRegex(),tn={...$t,lheading:Gt,table:en,paragraph:I(R).replace(`hr`,Bt).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,en).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,z).getRegex()},nn={...$t,html:I(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?\\1> *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Xt).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ft,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:I(R).replace(`hr`,Bt).replace(`heading`,` *#{1,6} *[^
]`).replace(`lheading`,Wt).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},rn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,an=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,on=/^( {2,}|\\)\n(?!\s*$)/,sn=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\`+)[^`]+\k(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,It?"(?`+)[^`]+\k(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),gn=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,_n=I(gn,`u`).replace(/punct/g,cn).getRegex(),vn=I(gn,`u`).replace(/punct/g,fn).getRegex(),yn=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,bn=I(yn,`gu`).replace(/notPunctSpace/g,un).replace(/punctSpace/g,ln).replace(/punct/g,cn).getRegex(),xn=I(yn,`gu`).replace(/notPunctSpace/g,mn).replace(/punctSpace/g,pn).replace(/punct/g,fn).getRegex(),Sn=I(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,un).replace(/punctSpace/g,ln).replace(/punct/g,cn).getRegex(),Cn=I(/\\(punct)/,`gu`).replace(/punct/g,cn).getRegex(),wn=I(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Tn=I(Xt).replace(`(?:-->|$)`,`-->`).getRegex(),En=I(`^comment|^[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^`).replace(`comment`,Tn).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Dn=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,On=I(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,Dn).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),kn=I(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Dn).replace(`ref`,qt).getRegex(),An=I(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,qt).getRegex(),jn=I(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,kn).replace(`nolink`,An).getRegex(),Mn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Nn={_backpedal:Ft,anyPunctuation:Cn,autolink:wn,blockSkip:hn,br:on,code:an,del:Ft,emStrongLDelim:_n,emStrongRDelimAst:bn,emStrongRDelimUnd:Sn,escape:rn,link:On,nolink:An,punctuation:dn,reflink:kn,reflinkSearch:jn,tag:En,text:sn,url:Ft},Pn={...Nn,link:I(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Dn).getRegex(),reflink:I(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Dn).getRegex()},Fn={...Nn,emStrongRDelimAst:xn,emStrongLDelim:vn,url:I(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Mn).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:I(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\":`>`,'"':`"`,"'":`'`},Bn=e=>zn[e];function B(e,t){if(t){if(L.escapeTest.test(e))return e.replace(L.escapeReplace,Bn)}else if(L.escapeTestNoEncode.test(e))return e.replace(L.escapeReplaceNoEncode,Bn);return e}function Vn(e){try{e=encodeURI(e).replace(L.percentDecode,`%`)}catch{return null}return e}function Hn(e,t){let n=e.replace(L.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(L.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length0?-2:-1}function Gn(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function Kn(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
@@ -61,4 +61,4 @@ ${e}
`+this.renderer.text(i);n+=t?this.renderer.paragraph({type:`paragraph`,raw:o,text:o,tokens:[{type:`text`,raw:o,text:o,escaped:!0}]}):o;continue}default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}parseInline(e,t=this.renderer){let n=``;for(let r=0;r{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Jn(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new qn(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Xn;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=Xn.passThroughHooks.has(n)?e=>{if(this.defaults.async&&Xn.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return V.lex(e,t??this.defaults)}parser(e,t){return H.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?V.lex:V.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser():e?H.parse:H.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?V.lex:V.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?H.parse:H.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
Please report this to https://github.com/markedjs/marked.`,e){let e=`