+ ) : null}
);
}
diff --git a/web/frontend/src/pages/deep-assessments/page.css b/web/frontend/src/pages/deep-assessments/page.css
index 4d4e8045..c11f0e19 100644
--- a/web/frontend/src/pages/deep-assessments/page.css
+++ b/web/frontend/src/pages/deep-assessments/page.css
@@ -206,6 +206,17 @@
padding-bottom: 0;
}
+.assessment-scope-preview {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 6px;
+ margin-top: 8px;
+}
+
+.assessment-scope-hint {
+ margin-top: 6px;
+}
+
.assessment-form-note {
margin-top: 8px;
}
diff --git a/web/frontend/tests/ui.spec.mjs b/web/frontend/tests/ui.spec.mjs
index 2f69d62a..0d69e1ae 100644
--- a/web/frontend/tests/ui.spec.mjs
+++ b/web/frontend/tests/ui.spec.mjs
@@ -1542,10 +1542,12 @@ test('deep assessment: create and select a new project without losing the draft'
const emptyScope = '这个项目的资产库还是空的。测评中新发现的目标会写进资产库,对话和批量任务也能看到。';
mockApi.respond('GET', '/api/assets', (_, url) => ({
json: {
- assets: [],
+ assets: url.searchParams.get('project_id') === PROJECT.id
+ ? [{ id: 'a1', domain: 'portal.example.com', port: 443 }, { id: 'a2', domain: 'api.example.com', port: 8443 }]
+ : [],
total: url.searchParams.get('project_id') === PROJECT.id ? 3 : 0,
page: 1,
- page_size: 1
+ page_size: 6
}
}));
const main = await visit(page, 'deep-assessments');
@@ -1566,7 +1568,13 @@ test('deep assessment: create and select a new project without losing the draft'
await page.getByRole('option').filter({ hasText: PROJECT.name }).click();
await expect(collectionSelect).toHaveCount(0);
await expect(drawer.getByRole('status')).toHaveText(sharedScope);
- expect(mockApi.calls('GET', '/api/assets').some(call => new URLSearchParams(call.query).get('project_id') === PROJECT.id)).toBe(true);
+ await expect(drawer.locator('.assessment-scope-preview')).toContainText('portal.example.com:443');
+ await expect(drawer.locator('.assessment-scope-preview')).toContainText('api.example.com:8443');
+ await expect(drawer.locator('.assessment-scope-preview')).toContainText('+1');
+ expect(mockApi.calls('GET', '/api/assets').some(call => {
+ const q = new URLSearchParams(call.query);
+ return q.get('project_id') === PROJECT.id && q.get('sync_project_scope') === '1';
+ })).toBe(true);
expect(mockApi.calls('GET', '/api/assets/collections')).toEqual([]);
await createProject.click();
await expect(projectDrawer).toBeVisible();
diff --git a/web/static/app/assets/AssetEditorModal-C2UJzIaS.js b/web/static/app/assets/AssetEditorModal-DXka8uV0.js
similarity index 98%
rename from web/static/app/assets/AssetEditorModal-C2UJzIaS.js
rename to web/static/app/assets/AssetEditorModal-DXka8uV0.js
index d919f451..28af3dd8 100644
--- a/web/static/app/assets/AssetEditorModal-C2UJzIaS.js
+++ b/web/static/app/assets/AssetEditorModal-DXka8uV0.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{B as r,I as i,R as a,i as o}from"./semi-65W_4I1v.js";import{F as s,L as c,S as l,c as u,x as d,z as f}from"./index-DNMXun-U.js";import{t as p}from"./project-options-CMQbwv_U.js";import{E as m,a as h,c as g,h as _,i as v,o as y,p as b,s as x,u as S}from"./assetTarget-D2PEjBAg.js";var C=e(t(),1),w=e(n(),1),T=`asset-library-editor`;function E(e,t){return{target:S(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?e.project_id||``:t,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 D({visible:e,asset:t,defaultProjectId:n=``,fixedProject:D=!1,projects:O,onClose:k,onSaved:A}){let j=s(),[M,N]=(0,C.useState)(null),[P,F]=(0,C.useState)(!1),[I,L]=(0,C.useState)(``),R=(0,C.useRef)(S(t)),z=(0,C.useMemo)(()=>E(t,n),[t,n,e]),B=!!t?.id;(0,C.useEffect)(()=>{e&&(R.current=S(t),L(``),F(!1))},[e,t]);let V=(0,C.useMemo)(()=>p(O,j,{currentId:z.project_id}),[O,j,z.project_id]),H=e=>{if(!M)return null;let t=String(M.getValue(`target`)||``).trim();try{let e=x(t);return M.setValues({host:e.host,ip:e.ip,domain:e.domain,port:e.port||void 0,protocol:e.protocol}),R.current=t,e}catch(t){return e&&L(t.message),null}},U=()=>{let e=M.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!==R.current)try{let e=x(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},W=()=>{let e=g(M.getValue(`targets`));if(!e.length)throw Error(j(`assets.targetRequired`,null,`请输入资产地址`));if(e.length>200)throw Error(`一次最多添加 200 个地址`);let t=D?n:M.getValue(`project_id`)||``;return e.map(e=>{let n=x(e);return{host:n.host||n.domain||n.ip,ip:n.ip,domain:n.domain,port:n.port,protocol:n.protocol,status:`active`,source:`manual`,project_id:t,tags:[]}})},G=async()=>{if(P||!M)return;L(``);try{await M.validate()}catch{return}let e,n;try{B?e=U():n=W()}catch(e){L(e.message);return}F(!0);try{if(B)await c.put(`/assets/${encodeURIComponent(t.id)}`,e),d(j(`assets.updatedSuccessfully`,null,`资产已更新`));else{let e=await c.post(`/assets/import`,{assets:n,source:`manual`}),t=Number(e?.created||0),r=Number(e?.updated||0),i=Number(e?.skipped||0),a=Number(e?.project_conflicts||0),o=a?j(`assets.importProjectConflicts`,{count:a},`已跳过 ${a} 条归属不同的重复资产。`):``;if(!t&&!r&&i)throw Error(o||j(`assets.assetSkipped`,null,`资产未保存,可能已存在且你没有更新权限`));let s=[];t&&s.push(`新增 ${t}`),r&&s.push(`合并 ${r}`),i&&s.push(`跳过 ${i}`),d(s.length?`已写入资产库:${s.join(`,`)}`:j(`assets.createdSuccessfully`,null,`资产已添加`)),o&&l(o)}A?.(),k?.()}catch(e){L(f(e,j(`assets.saveFailed`,null,`保存资产失败`)))}finally{F(!1)}};return(0,w.jsxs)(u,{visible:e,title:B?j(`assets.editAssetTitle`,null,`编辑资产`):j(`assets.addAssetTitle`,null,`新增资产`),width:B?760:520,onCancel:k,onOk:G,okText:B?j(`common.save`,null,`保存`):j(`assets.addAssetAction`,null,`添加资产`),confirmLoading:P,closeOnEsc:!0,children:[I&&(0,w.jsx)(r,{type:`danger`,bordered:!0,closeIcon:null,description:I,className:`asset-library-form-error`}),(0,w.jsx)(o,{className:T,initValues:z,getFormApi:N,labelPosition:`top`,onSubmit:G,children:B?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{className:`asset-library-form-grid asset-library-form-grid--full`,children:(0,w.jsx)(o.Input,{field:`target`,label:j(`assets.assetAddress`,null,`资产地址`),placeholder:`https://example.com:443 / example.com / 1.1.1.1:22`,helpText:j(`assets.assetAddressHint`,null,`可识别的 URL、域名、IP 和端口会自动解析`),onBlur:()=>H(!0),rules:[{required:!0,message:j(`assets.targetRequired`,null,`请输入资产地址`)},{validator:(e,t,n)=>{try{x(t),n()}catch(e){n(Error(e.message))}}}]})}),(0,w.jsxs)(`div`,{className:`asset-library-form-grid`,children:[(0,w.jsx)(o.Input,{field:`host`,label:j(`assets.hostUrl`,null,`完整 URL / Host`)}),(0,w.jsx)(o.Input,{field:`ip`,label:`IP`,rules:[{validator:(e,t,n)=>{!t||v(t)||h(t)?n():n(Error(j(`assets.ipInvalid`,null,`IP 地址格式无效`)))}}]}),(0,w.jsx)(o.Input,{field:`domain`,label:j(`assets.domain`,null,`域名`),rules:[{validator:(e,t,n)=>{!t||y(t)&&!v(t)&&!h(t)?n():n(Error(j(`assets.domainInvalid`,null,`域名格式无效`)))}}]}),(0,w.jsx)(o.InputNumber,{field:`port`,label:j(`assets.port`,null,`端口`),min:0,max:65535,style:{width:`100%`}}),(0,w.jsx)(o.Input,{field:`protocol`,label:j(`assets.protocol`,null,`协议`),rules:[{validator:(e,t,n)=>{!t||/^[a-z][a-z0-9+.-]{0,31}$/.test(String(t).toLowerCase())?n():n(Error(j(`assets.protocolInvalid`,null,`协议格式无效`)))}}]}),(0,w.jsx)(o.Input,{field:`title`,label:j(`assets.pageTitle`,null,`页面标题`)}),(0,w.jsx)(o.Input,{field:`server`,label:j(`assets.serverProduct`,null,`服务 / 产品`)}),(0,w.jsx)(o.Select,{field:`project_id`,label:j(`assets.project`,null,`所属项目`),optionList:V,filter:!0,showClear:!0,placeholder:j(`assets.unboundProject`,null,`暂不绑定`)}),(0,w.jsx)(o.Select,{field:`status`,label:j(`assets.status`,null,`状态`),optionList:m}),(0,w.jsx)(o.Select,{field:`environment`,label:j(`assets.environment`,null,`环境`),optionList:_,showClear:!0,placeholder:`—`}),(0,w.jsx)(o.Select,{field:`criticality`,label:j(`assets.criticality`,null,`重要性`),optionList:b,showClear:!0,placeholder:`—`}),(0,w.jsx)(o.Input,{field:`country`,label:j(`assets.country`,null,`国家/地区`)}),(0,w.jsx)(o.Input,{field:`province`,label:j(`assets.province`,null,`省份/州`)}),(0,w.jsx)(o.Input,{field:`city`,label:j(`assets.city`,null,`城市`)}),(0,w.jsx)(o.Input,{field:`responsible_person`,label:j(`assets.responsiblePerson`,null,`负责人`)}),(0,w.jsx)(o.Input,{field:`department`,label:j(`assets.department`,null,`部门`)}),(0,w.jsx)(o.Input,{field:`business_system`,label:j(`assets.businessSystem`,null,`业务系统`)})]}),(0,w.jsx)(o.TagInput,{field:`tags`,label:j(`assets.tagsLabel`,null,`标签`),placeholder:j(`assets.tagsPlaceholder`,null,`输入后按回车或逗号`),max:30,maxLength:64,addOnBlur:!0,separator:`,,`,style:{width:`100%`}}),(0,w.jsx)(i,{className:`asset-library-editor-actions`,children:(0,w.jsx)(a,{theme:`borderless`,onClick:()=>H(!0),children:j(`assets.parseTarget`,null,`解析资产地址`)})})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(o.TextArea,{field:`targets`,label:j(`assets.assetAddress`,null,`资产地址`),rows:8,placeholder:`https://example.com/login
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{B as r,I as i,R as a,i as o}from"./semi-65W_4I1v.js";import{F as s,L as c,S as l,c as u,x as d,z as f}from"./index-C6SML8F9.js";import{t as p}from"./project-options-CMQbwv_U.js";import{E as m,a as h,c as g,h as _,i as v,o as y,p as b,s as x,u as S}from"./assetTarget-D2PEjBAg.js";var C=e(t(),1),w=e(n(),1),T=`asset-library-editor`;function E(e,t){return{target:S(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?e.project_id||``:t,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 D({visible:e,asset:t,defaultProjectId:n=``,fixedProject:D=!1,projects:O,onClose:k,onSaved:A}){let j=s(),[M,N]=(0,C.useState)(null),[P,F]=(0,C.useState)(!1),[I,L]=(0,C.useState)(``),R=(0,C.useRef)(S(t)),z=(0,C.useMemo)(()=>E(t,n),[t,n,e]),B=!!t?.id;(0,C.useEffect)(()=>{e&&(R.current=S(t),L(``),F(!1))},[e,t]);let V=(0,C.useMemo)(()=>p(O,j,{currentId:z.project_id}),[O,j,z.project_id]),H=e=>{if(!M)return null;let t=String(M.getValue(`target`)||``).trim();try{let e=x(t);return M.setValues({host:e.host,ip:e.ip,domain:e.domain,port:e.port||void 0,protocol:e.protocol}),R.current=t,e}catch(t){return e&&L(t.message),null}},U=()=>{let e=M.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!==R.current)try{let e=x(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},W=()=>{let e=g(M.getValue(`targets`));if(!e.length)throw Error(j(`assets.targetRequired`,null,`请输入资产地址`));if(e.length>200)throw Error(`一次最多添加 200 个地址`);let t=D?n:M.getValue(`project_id`)||``;return e.map(e=>{let n=x(e);return{host:n.host||n.domain||n.ip,ip:n.ip,domain:n.domain,port:n.port,protocol:n.protocol,status:`active`,source:`manual`,project_id:t,tags:[]}})},G=async()=>{if(P||!M)return;L(``);try{await M.validate()}catch{return}let e,n;try{B?e=U():n=W()}catch(e){L(e.message);return}F(!0);try{if(B)await c.put(`/assets/${encodeURIComponent(t.id)}`,e),d(j(`assets.updatedSuccessfully`,null,`资产已更新`));else{let e=await c.post(`/assets/import`,{assets:n,source:`manual`}),t=Number(e?.created||0),r=Number(e?.updated||0),i=Number(e?.skipped||0),a=Number(e?.project_conflicts||0),o=a?j(`assets.importProjectConflicts`,{count:a},`已跳过 ${a} 条归属不同的重复资产。`):``;if(!t&&!r&&i)throw Error(o||j(`assets.assetSkipped`,null,`资产未保存,可能已存在且你没有更新权限`));let s=[];t&&s.push(`新增 ${t}`),r&&s.push(`合并 ${r}`),i&&s.push(`跳过 ${i}`),d(s.length?`已写入资产库:${s.join(`,`)}`:j(`assets.createdSuccessfully`,null,`资产已添加`)),o&&l(o)}A?.(),k?.()}catch(e){L(f(e,j(`assets.saveFailed`,null,`保存资产失败`)))}finally{F(!1)}};return(0,w.jsxs)(u,{visible:e,title:B?j(`assets.editAssetTitle`,null,`编辑资产`):j(`assets.addAssetTitle`,null,`新增资产`),width:B?760:520,onCancel:k,onOk:G,okText:B?j(`common.save`,null,`保存`):j(`assets.addAssetAction`,null,`添加资产`),confirmLoading:P,closeOnEsc:!0,children:[I&&(0,w.jsx)(r,{type:`danger`,bordered:!0,closeIcon:null,description:I,className:`asset-library-form-error`}),(0,w.jsx)(o,{className:T,initValues:z,getFormApi:N,labelPosition:`top`,onSubmit:G,children:B?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{className:`asset-library-form-grid asset-library-form-grid--full`,children:(0,w.jsx)(o.Input,{field:`target`,label:j(`assets.assetAddress`,null,`资产地址`),placeholder:`https://example.com:443 / example.com / 1.1.1.1:22`,helpText:j(`assets.assetAddressHint`,null,`可识别的 URL、域名、IP 和端口会自动解析`),onBlur:()=>H(!0),rules:[{required:!0,message:j(`assets.targetRequired`,null,`请输入资产地址`)},{validator:(e,t,n)=>{try{x(t),n()}catch(e){n(Error(e.message))}}}]})}),(0,w.jsxs)(`div`,{className:`asset-library-form-grid`,children:[(0,w.jsx)(o.Input,{field:`host`,label:j(`assets.hostUrl`,null,`完整 URL / Host`)}),(0,w.jsx)(o.Input,{field:`ip`,label:`IP`,rules:[{validator:(e,t,n)=>{!t||v(t)||h(t)?n():n(Error(j(`assets.ipInvalid`,null,`IP 地址格式无效`)))}}]}),(0,w.jsx)(o.Input,{field:`domain`,label:j(`assets.domain`,null,`域名`),rules:[{validator:(e,t,n)=>{!t||y(t)&&!v(t)&&!h(t)?n():n(Error(j(`assets.domainInvalid`,null,`域名格式无效`)))}}]}),(0,w.jsx)(o.InputNumber,{field:`port`,label:j(`assets.port`,null,`端口`),min:0,max:65535,style:{width:`100%`}}),(0,w.jsx)(o.Input,{field:`protocol`,label:j(`assets.protocol`,null,`协议`),rules:[{validator:(e,t,n)=>{!t||/^[a-z][a-z0-9+.-]{0,31}$/.test(String(t).toLowerCase())?n():n(Error(j(`assets.protocolInvalid`,null,`协议格式无效`)))}}]}),(0,w.jsx)(o.Input,{field:`title`,label:j(`assets.pageTitle`,null,`页面标题`)}),(0,w.jsx)(o.Input,{field:`server`,label:j(`assets.serverProduct`,null,`服务 / 产品`)}),(0,w.jsx)(o.Select,{field:`project_id`,label:j(`assets.project`,null,`所属项目`),optionList:V,filter:!0,showClear:!0,placeholder:j(`assets.unboundProject`,null,`暂不绑定`)}),(0,w.jsx)(o.Select,{field:`status`,label:j(`assets.status`,null,`状态`),optionList:m}),(0,w.jsx)(o.Select,{field:`environment`,label:j(`assets.environment`,null,`环境`),optionList:_,showClear:!0,placeholder:`—`}),(0,w.jsx)(o.Select,{field:`criticality`,label:j(`assets.criticality`,null,`重要性`),optionList:b,showClear:!0,placeholder:`—`}),(0,w.jsx)(o.Input,{field:`country`,label:j(`assets.country`,null,`国家/地区`)}),(0,w.jsx)(o.Input,{field:`province`,label:j(`assets.province`,null,`省份/州`)}),(0,w.jsx)(o.Input,{field:`city`,label:j(`assets.city`,null,`城市`)}),(0,w.jsx)(o.Input,{field:`responsible_person`,label:j(`assets.responsiblePerson`,null,`负责人`)}),(0,w.jsx)(o.Input,{field:`department`,label:j(`assets.department`,null,`部门`)}),(0,w.jsx)(o.Input,{field:`business_system`,label:j(`assets.businessSystem`,null,`业务系统`)})]}),(0,w.jsx)(o.TagInput,{field:`tags`,label:j(`assets.tagsLabel`,null,`标签`),placeholder:j(`assets.tagsPlaceholder`,null,`输入后按回车或逗号`),max:30,maxLength:64,addOnBlur:!0,separator:`,,`,style:{width:`100%`}}),(0,w.jsx)(i,{className:`asset-library-editor-actions`,children:(0,w.jsx)(a,{theme:`borderless`,onClick:()=>H(!0),children:j(`assets.parseTarget`,null,`解析资产地址`)})})]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(o.TextArea,{field:`targets`,label:j(`assets.assetAddress`,null,`资产地址`),rows:8,placeholder:`https://example.com/login
example.com:443
1.1.1.1:22`,helpText:`每行一个,或用空格、逗号隔开。直接粘贴 URL、域名或 IP:端口。`,rules:[{required:!0,validator:(e,t,n)=>{let r=g(t);if(!r.length)n(Error(j(`assets.targetRequired`,null,`请输入资产地址`)));else{for(let e of r)try{x(e)}catch(t){n(Error(`${e}:${t.message}`));return}n()}}}]}),(0,w.jsx)(o.Select,{field:`project_id`,label:j(`assets.project`,null,`所属项目`),optionList:V,disabled:D,filter:!0,showClear:!D,placeholder:j(`assets.unboundProject`,null,`暂不绑定`),style:{width:`100%`}})]})},`${t?.id||`new-asset`}-${e?`open`:`closed`}`)]})}export{D as t};
\ No newline at end of file
diff --git a/web/static/app/assets/agents-management-BH4GA4Vt.js b/web/static/app/assets/agents-management-CWCuLnSr.js
similarity index 97%
rename from web/static/app/assets/agents-management-BH4GA4Vt.js
rename to web/static/app/assets/agents-management-CWCuLnSr.js
index 21b440fb..e2a0f6f5 100644
--- a/web/static/app/assets/agents-management-BH4GA4Vt.js
+++ b/web/static/app/assets/agents-management-CWCuLnSr.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{G as r,I as i,Lt as a,N as o,Pt as s,R as c,U as l,ft as u,i as d,lt as f,ut as p}from"./semi-65W_4I1v.js";import{F as m,I as h,L as g,a as _,b as v,c as y,d as b,f as x,l as S,m as C,p as w,s as T,u as E,x as D,y as O}from"./index-DNMXun-U.js";var k=e(t(),1),A=e(n(),1),{Text:j}=r;function M(){let e=m(),{hasPermission:t}=h(),n=t(`agents:write`),r=t(`agents:delete`),[M,N]=(0,k.useState)(``),[P,F]=(0,k.useState)(null),[I,L]=(0,k.useState)(null),[R,z]=(0,k.useState)(!1),B=_(()=>g.get(`/multi-agent/markdown-agents`),[]),V=(Array.isArray(B.data?.agents)?B.data.agents:[]).filter(e=>{if(!M)return!0;let t=M.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),H=async e=>{try{F(await g.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){v(e,`读取智能体失败`)}},U=async()=>{let e=await I.form.validate();z(!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)}),D(`智能体已保存`),L(null),B.reload()}catch(e){v(e,`保存智能体失败`)}finally{z(!1)}},W=e=>O({title:`删除智能体「${e.name||e.filename}」?`,onOk:async()=>{await g.del(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`),D(`已删除`),B.reload()}});return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(w,{title:e(`agents.title`,null,`智能体管理`),description:B.data?.dir?`目录:${B.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,A.jsxs)(i,{children:[(0,A.jsx)(c,{icon:(0,A.jsx)(p,{}),onClick:()=>B.reload(),loading:B.loading,children:`刷新`}),n&&(0,A.jsx)(c,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(u,{}),onClick:()=>L({record:null,form:{}}),children:`新建智能体`})]})}),B.data?.error&&(0,A.jsx)(S,{error:B.data.error}),(0,A.jsxs)(C,{title:`智能体(${V.length})`,children:[(0,A.jsx)(S,{error:B.error,onRetry:()=>B.reload()}),(0,A.jsx)(T,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,A.jsxs)(i,{vertical:!0,spacing:0,align:`start`,children:[(0,A.jsxs)(i,{children:[(0,A.jsx)(j,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,A.jsx)(o,{size:`small`,color:`purple`,children:`编排器`})]}),(0,A.jsx)(j,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,A.jsx)(o,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,A.jsx)(j,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,A.jsxs)(i,{children:[(0,A.jsx)(c,{size:`small`,theme:`borderless`,onClick:()=>H(t),children:`详情`}),n&&(0,A.jsx)(c,{size:`small`,theme:`borderless`,icon:(0,A.jsx)(s,{}),onClick:()=>L({record:t,form:{}})}),r&&(0,A.jsx)(c,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,A.jsx)(a,{}),onClick:()=>W(t)})]})}],dataSource:V,rowKey:`filename`,loading:B.loading,pagination:{pageSize:20},toolbar:(0,A.jsx)(l,{prefix:(0,A.jsx)(f,{}),value:M,onChange:N,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,A.jsx)(y,{title:I?.record?`编辑智能体`:`新建智能体`,visible:!!I,onCancel:()=>L(null),onOk:U,confirmLoading:R,width:760,children:(0,A.jsxs)(d,{getFormApi:e=>L(t=>t&&{...t,form:e}),initValues:I?.record?{filename:I.record.filename,name:I.record.name,description:I.record.description,kind:I.record.kind||`sub`}:{kind:`sub`},children:[(0,A.jsx)(d.Input,{field:`filename`,label:`文件名(留空自动生成)`,placeholder:`例如 recon.md`}),(0,A.jsx)(d.Input,{field:`name`,label:`名称`,rules:[{required:!0,message:`请输入名称`}]}),(0,A.jsx)(d.Input,{field:`description`,label:`描述`}),(0,A.jsx)(d.Select,{field:`kind`,label:`类型`,optionList:[{value:`sub`,label:`子智能体`},{value:`orchestrator`,label:`编排器`},{value:`plan_execute`,label:`计划执行`}]}),(0,A.jsx)(d.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::tool`}),(0,A.jsx)(d.TextArea,{field:`instruction`,label:`指令(Markdown)`,autosize:{minRows:8,maxRows:20}})]})},I?.record?.filename||`new-agent`),(0,A.jsx)(y,{title:P?.name||`智能体详情`,visible:!!P,onCancel:()=>F(null),width:720,children:P&&(0,A.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,A.jsx)(b,{items:[{label:`文件名`,value:P.filename},{label:`ID`,value:P.id},{label:`类型`,value:P.kind},{label:`绑定角色`,value:P.bind_role||`—`},{label:`最大迭代`,value:P.max_iterations??`—`},{label:`工具`,value:Array.isArray(P.tools)&&P.tools.length?P.tools.join(`、`):`—`}]}),(0,A.jsx)(x,{content:P.instruction||P.raw||``}),(0,A.jsx)(E,{value:P.raw||P,title:`原始 Markdown`,collapsed:!0})]})})]})}export{M 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{G as r,I as i,Lt as a,N as o,Pt as s,R as c,U as l,ft as u,i as d,lt as f,ut as p}from"./semi-65W_4I1v.js";import{F as m,I as h,L as g,a as _,b as v,c as y,d as b,f as x,l as S,m as C,p as w,s as T,u as E,x as D,y as O}from"./index-C6SML8F9.js";var k=e(t(),1),A=e(n(),1),{Text:j}=r;function M(){let e=m(),{hasPermission:t}=h(),n=t(`agents:write`),r=t(`agents:delete`),[M,N]=(0,k.useState)(``),[P,F]=(0,k.useState)(null),[I,L]=(0,k.useState)(null),[R,z]=(0,k.useState)(!1),B=_(()=>g.get(`/multi-agent/markdown-agents`),[]),V=(Array.isArray(B.data?.agents)?B.data.agents:[]).filter(e=>{if(!M)return!0;let t=M.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),H=async e=>{try{F(await g.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){v(e,`读取智能体失败`)}},U=async()=>{let e=await I.form.validate();z(!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)}),D(`智能体已保存`),L(null),B.reload()}catch(e){v(e,`保存智能体失败`)}finally{z(!1)}},W=e=>O({title:`删除智能体「${e.name||e.filename}」?`,onOk:async()=>{await g.del(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`),D(`已删除`),B.reload()}});return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(w,{title:e(`agents.title`,null,`智能体管理`),description:B.data?.dir?`目录:${B.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,A.jsxs)(i,{children:[(0,A.jsx)(c,{icon:(0,A.jsx)(p,{}),onClick:()=>B.reload(),loading:B.loading,children:`刷新`}),n&&(0,A.jsx)(c,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(u,{}),onClick:()=>L({record:null,form:{}}),children:`新建智能体`})]})}),B.data?.error&&(0,A.jsx)(S,{error:B.data.error}),(0,A.jsxs)(C,{title:`智能体(${V.length})`,children:[(0,A.jsx)(S,{error:B.error,onRetry:()=>B.reload()}),(0,A.jsx)(T,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,A.jsxs)(i,{vertical:!0,spacing:0,align:`start`,children:[(0,A.jsxs)(i,{children:[(0,A.jsx)(j,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,A.jsx)(o,{size:`small`,color:`purple`,children:`编排器`})]}),(0,A.jsx)(j,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,A.jsx)(o,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,A.jsx)(j,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,A.jsxs)(i,{children:[(0,A.jsx)(c,{size:`small`,theme:`borderless`,onClick:()=>H(t),children:`详情`}),n&&(0,A.jsx)(c,{size:`small`,theme:`borderless`,icon:(0,A.jsx)(s,{}),onClick:()=>L({record:t,form:{}})}),r&&(0,A.jsx)(c,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,A.jsx)(a,{}),onClick:()=>W(t)})]})}],dataSource:V,rowKey:`filename`,loading:B.loading,pagination:{pageSize:20},toolbar:(0,A.jsx)(l,{prefix:(0,A.jsx)(f,{}),value:M,onChange:N,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,A.jsx)(y,{title:I?.record?`编辑智能体`:`新建智能体`,visible:!!I,onCancel:()=>L(null),onOk:U,confirmLoading:R,width:760,children:(0,A.jsxs)(d,{getFormApi:e=>L(t=>t&&{...t,form:e}),initValues:I?.record?{filename:I.record.filename,name:I.record.name,description:I.record.description,kind:I.record.kind||`sub`}:{kind:`sub`},children:[(0,A.jsx)(d.Input,{field:`filename`,label:`文件名(留空自动生成)`,placeholder:`例如 recon.md`}),(0,A.jsx)(d.Input,{field:`name`,label:`名称`,rules:[{required:!0,message:`请输入名称`}]}),(0,A.jsx)(d.Input,{field:`description`,label:`描述`}),(0,A.jsx)(d.Select,{field:`kind`,label:`类型`,optionList:[{value:`sub`,label:`子智能体`},{value:`orchestrator`,label:`编排器`},{value:`plan_execute`,label:`计划执行`}]}),(0,A.jsx)(d.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::tool`}),(0,A.jsx)(d.TextArea,{field:`instruction`,label:`指令(Markdown)`,autosize:{minRows:8,maxRows:20}})]})},I?.record?.filename||`new-agent`),(0,A.jsx)(y,{title:P?.name||`智能体详情`,visible:!!P,onCancel:()=>F(null),width:720,children:P&&(0,A.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,A.jsx)(b,{items:[{label:`文件名`,value:P.filename},{label:`ID`,value:P.id},{label:`类型`,value:P.kind},{label:`绑定角色`,value:P.bind_role||`—`},{label:`最大迭代`,value:P.max_iterations??`—`},{label:`工具`,value:Array.isArray(P.tools)&&P.tools.length?P.tools.join(`、`):`—`}]}),(0,A.jsx)(x,{content:P.instruction||P.raw||``}),(0,A.jsx)(E,{value:P.raw||P,title:`原始 Markdown`,collapsed:!0})]})})]})}export{M as default};
\ No newline at end of file
diff --git a/web/static/app/assets/api-docs-BqzLMZ8q.js b/web/static/app/assets/api-docs-DaKtgf05.js
similarity index 98%
rename from web/static/app/assets/api-docs-BqzLMZ8q.js
rename to web/static/app/assets/api-docs-DaKtgf05.js
index 1572c2b0..934a235f 100644
--- a/web/static/app/assets/api-docs-BqzLMZ8q.js
+++ b/web/static/app/assets/api-docs-DaKtgf05.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{D as r,F as i,G as a,I as o,N as s,R as c,S as l,U as u,c as d,ct as f,lt as p,ut as m,y as h}from"./semi-65W_4I1v.js";import{F as g,H as _,L as v,b as y,p as b,u as x,z as S}from"./index-DNMXun-U.js";var C=e(t(),1),w=e(n(),1),{Text:T,Paragraph:E}=a,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||[],a=k(e.path),[d,p]=(0,C.useState)({}),[m,h]=(0,C.useState)(``),[g,v]=(0,C.useState)(null),[b,E]=(0,C.useState)(!1);return(0,C.useEffect)(()=>{let e={};a.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))}),p(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{D as r,F as i,G as a,I as o,N as s,R as c,S as l,U as u,c as d,ct as f,lt as p,ut as m,y as h}from"./semi-65W_4I1v.js";import{F as g,H as _,L as v,b as y,p as b,u as x,z as S}from"./index-C6SML8F9.js";var C=e(t(),1),w=e(n(),1),{Text:T,Paragraph:E}=a,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||[],a=k(e.path),[d,p]=(0,C.useState)({}),[m,h]=(0,C.useState)(``),[g,v]=(0,C.useState)(null),[b,E]=(0,C.useState)(!1);return(0,C.useEffect)(()=>{let e={};a.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))}),p(e),h(n.requestBody?`{
}`:``),v(null)},[e.id]),(0,w.jsxs)(`div`,{className:`api-docs-try`,children:[(0,w.jsx)(r,{margin:`12px 0`}),(0,w.jsx)(T,{strong:!0,children:`在线调试`}),a.length>0&&(0,w.jsx)(`div`,{className:`api-docs-try-fields`,children:a.map(e=>(0,w.jsxs)(`label`,{className:`api-docs-try-field`,children:[(0,w.jsxs)(`span`,{children:[`路径参数 `,e]}),(0,w.jsx)(u,{size:`small`,value:d[e]??``,onChange:t=>p(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)(u,{size:`small`,value:d[`query:${e.name}`]??``,onChange:t=>p(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)(l,{value:m,onChange:h,autosize:{minRows:5,maxRows:14}})]}),(0,w.jsxs)(o,{children:[(0,w.jsx)(c,{theme:`solid`,type:`primary`,icon:(0,w.jsx)(f,{}),loading:b,onClick:async()=>{E(!0),v(null);try{if(a.some(e=>String(d[e]??``).trim()===``)){y(`请填写路径参数`);return}let t=e.path;a.forEach(e=>{t=t.replace(`{${e}}`,encodeURIComponent(d[e]??``))});let r={};i.filter(e=>e.in===`query`).forEach(e=>{let t=d[`query:${e.name}`];t!==void 0&&t!==``&&(r[e.name]=t)});let o={method:e.method,query:r,raw:!0,timeout:12e4};if(n.requestBody&&m.trim())try{o.body=JSON.parse(m)}catch{y(`请求体不是合法 JSON`),E(!1);return}if(!t.startsWith(`/`)||t.startsWith(`//`))throw Error(`接口地址必须为站内 API 路径`);let s=await _(t.startsWith(`/api/`)?t.slice(4):t,o),c=s.headers.get(`content-type`)||``,l;l=c.includes(`application/json`)?await s.json():await s.text(),v({ok:!0,status:s.status,payload:l})}catch(e){v({ok:!1,status:e.status||0,payload:S(e)})}finally{E(!1)}},children:`发送请求`}),(0,w.jsx)(c,{onClick:()=>v(null),children:`清空结果`})]}),g&&(0,w.jsxs)(`div`,{className:`api-docs-try-result`,children:[(0,w.jsx)(s,{color:g.ok?`green`:`red`,children:g.ok?`HTTP ${g.status}`:`失败 ${g.status||``}`}),(0,w.jsx)(x,{value:g.payload,title:`响应`})]})]})}function j(){let e=g(),[t,n]=(0,C.useState)(null),[r,a]=(0,C.useState)(!0),[l,f]=(0,C.useState)(null),[_,y]=(0,C.useState)(``),[k,j]=(0,C.useState)(`all`),[M,N]=(0,C.useState)(null),P=async()=>{a(!0),f(null);try{let e=await v.get(`/openapi/spec`);n(e)}catch(e){f(e)}finally{a(!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(!_)return!0;let t=_.toLowerCase();return e.path.toLowerCase().includes(t)||e.summary.toLowerCase().includes(t)||e.method.toLowerCase().includes(t)}),[F,_,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)(b,{title:e(`apiDocs.title`,null,`API 文档`),description:t?.info?.description||`CyberStrikeAI 开放接口`,extra:(0,w.jsx)(c,{icon:(0,w.jsx)(m,{}),onClick:P,loading:r,children:`重新加载`})}),(0,w.jsxs)(`div`,{className:`api-docs-layout`,children:[(0,w.jsxs)(i,{className:`api-docs-sidebar`,bordered:!1,children:[(0,w.jsxs)(o,{vertical:!0,style:{width:`100%`},spacing:8,children:[(0,w.jsx)(u,{prefix:(0,w.jsx)(p,{}),value:_,onChange:y,placeholder:`搜索路径或说明`}),(0,w.jsx)(h,{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)(s,{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)),!r&&R.length===0&&(0,w.jsx)(T,{type:`tertiary`,children:`没有匹配的接口`})]})]}),(0,w.jsxs)(`div`,{className:`api-docs-detail`,children:[l&&(0,w.jsx)(i,{bordered:!1,children:(0,w.jsx)(T,{type:`danger`,children:S(l)})}),L?(0,w.jsxs)(i,{bordered:!1,children:[(0,w.jsxs)(`div`,{className:`api-docs-detail-head`,children:[(0,w.jsx)(s,{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)(x,{value:L.operation.parameters||[],title:`Request Parameters`,collapsed:!0})}),(0,w.jsx)(d.TabPane,{itemKey:`body`,tab:`请求体`,children:(0,w.jsx)(x,{value:L.operation.requestBody||{},title:`Request Body`,collapsed:!0})}),(0,w.jsx)(d.TabPane,{itemKey:`responses`,tab:`响应`,children:(0,w.jsx)(x,{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:r?`加载中…`:`选择左侧接口查看详情`})})]})]})]})}export{j as default};
\ No newline at end of file
diff --git a/web/static/app/assets/asset-library-Btn_YOu0.js b/web/static/app/assets/asset-library-C9rUcWZc.js
similarity index 79%
rename from web/static/app/assets/asset-library-Btn_YOu0.js
rename to web/static/app/assets/asset-library-C9rUcWZc.js
index 0c2bbc22..be766a9e 100644
--- a/web/static/app/assets/asset-library-Btn_YOu0.js
+++ b/web/static/app/assets/asset-library-C9rUcWZc.js
@@ -1,3 +1,3 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,y as i}from"./react-QV7DAAIx.js";import{B as a,Bt as o,D as s,G as c,I as l,R as u,S as d,U as f,d as p,ft as m,h,j as g,lt as _,m as v,p as y,u as b,ut as x,y as S}from"./semi-65W_4I1v.js";import{E as C,F as w,I as ee,L as T,S as te,a as E,b as D,c as O,d as k,l as ne,m as re,n as ie,o as A,p as ae,s as oe,x as j,y as se,z as M}from"./index-DNMXun-U.js";import{n as ce}from"./project-options-CMQbwv_U.js";import{A as le,C as ue,D as de,E as fe,M as pe,O as me,S as he,T as ge,_ as _e,a as ve,b as ye,d as be,f as xe,g as Se,h as N,i as P,k as F,l as I,m as Ce,n as we,o as L,p as Te,r as R,s as Ee,t as De,v as z,w as B,y as V}from"./assetTarget-D2PEjBAg.js";import{a as Oe,i as H,n as ke,r as U,t as Ae}from"./AssetBits-DtqSAj0f.js";import{t as je}from"./AssetEditorModal-C2UJzIaS.js";var W=e(t(),1),G=e(r(),1),Me={q:``,protocol:``,source:``,tag:``,status:``,risk_level:``,environment:``,criticality:``,ip:``,domain:``,port:``,scan:``,sort:`last_seen_at:desc`};function Ne(){return{...Me}}function Pe({scope:e,filters:t,onChange:n,onReset:r,disabled:i}){let a=w(),o=(0,W.useId)(),[s,c]=(0,W.useState)(t.q||``);(0,W.useEffect)(()=>{c(t.q||``)},[t.q]);let l=[`status`,`risk_level`,`environment`,`criticality`,`ip`,`domain`,`port`,`scan`].filter(e=>t[e]).length;return(0,G.jsxs)(`div`,{className:`asset-library-filters`,children:[(0,G.jsxs)(`div`,{className:`asset-library-filter-row`,children:[(0,G.jsx)(`span`,{id:o,hidden:!0,children:a(`assets.scopeLabel`,null,`资产范围`)}),(0,G.jsx)(S,{"aria-labelledby":o,value:e.value,optionList:e.options,loading:e.loading,disabled:i,onChange:e.onChange,filter:!0}),(0,G.jsx)(f,{className:`asset-library-filter-search`,prefix:(0,G.jsx)(_,{}),value:s,disabled:i,placeholder:a(`assets.searchPlaceholder`,null,`搜索主机、IP、域名、标题、服务或标签`),onChange:e=>{c(e),n({q:e})},showClear:!0}),(0,G.jsx)(S,{value:t.protocol||void 0,placeholder:a(`assets.assetType`,null,`类型 / 协议`),optionList:ye,filter:!0,allowCreate:!0,showClear:!0,disabled:i,onChange:e=>n({protocol:e||``})}),(0,G.jsx)(f,{value:t.source,placeholder:a(`assets.source`,null,`来源`),disabled:i,onChange:e=>n({source:e}),showClear:!0}),(0,G.jsx)(f,{value:t.tag,placeholder:a(`assets.tagsLabel`,null,`标签`),disabled:i,onChange:e=>n({tag:e}),showClear:!0}),(0,G.jsx)(u,{onClick:r,disabled:i,children:a(`assets.resetFilters`,null,`重置`)})]}),(0,G.jsx)(g,{className:`asset-library-filter-advanced`,keepDOM:!1,children:(0,G.jsx)(g.Panel,{itemKey:`advanced`,header:`${a(`assets.advancedFilters`,null,`高级筛选`)}${l?`(${l})`:``}`,children:(0,G.jsxs)(`div`,{className:`asset-library-filter-grid`,children:[(0,G.jsx)(S,{value:t.status||void 0,placeholder:a(`assets.allStatuses`,null,`全部状态`),optionList:fe,showClear:!0,disabled:i,onChange:e=>n({status:e||``})}),(0,G.jsx)(S,{value:t.risk_level||void 0,placeholder:a(`assets.allRisks`,null,`全部风险`),optionList:he,showClear:!0,disabled:i,onChange:e=>n({risk_level:e||``})}),(0,G.jsx)(S,{value:t.environment||void 0,placeholder:a(`assets.allEnvironments`,null,`全部环境`),optionList:N,showClear:!0,disabled:i,onChange:e=>n({environment:e||``})}),(0,G.jsx)(S,{value:t.criticality||void 0,placeholder:a(`assets.allCriticalities`,null,`全部级别`),optionList:Te,showClear:!0,disabled:i,onChange:e=>n({criticality:e||``})}),(0,G.jsx)(f,{value:t.ip,placeholder:`IP`,disabled:i,onChange:e=>n({ip:e}),showClear:!0}),(0,G.jsx)(f,{value:t.domain,placeholder:a(`assets.domain`,null,`域名`),disabled:i,onChange:e=>n({domain:e}),showClear:!0}),(0,G.jsx)(f,{value:t.port,placeholder:a(`assets.port`,null,`端口`),disabled:i,onChange:e=>n({port:String(e||``).replace(/[^\d]/g,``)}),showClear:!0}),(0,G.jsx)(S,{value:t.scan||``,placeholder:a(`assets.scanState`,null,`扫描状态`),optionList:ue,disabled:i,onChange:e=>n({scan:e||``})}),(0,G.jsx)(S,{value:t.sort||`last_seen_at:desc`,optionList:B,disabled:i,onChange:e=>n({sort:e||`last_seen_at:desc`})})]})})})]})}var{Text:K}=c;function Fe({assets:e,loading:t,total:n,page:r,pageSize:i,onPageChange:a,onPageSizeChange:o,selectedRowKeys:s,onSelectionChange:c,onView:d,onEdit:f,onDelete:p,onRefresh:m,canWrite:h,canDelete:g}){let _=w(),v=e=>{se({title:_(`assets.deleteConfirm`,null,`确定删除该资产吗?`),content:R(e),okText:_(`common.delete`,null,`删除`),onOk:()=>{Promise.resolve(p(e)).catch(e=>D(e,_(`assets.deleteFailed`,null,`删除资产失败`)))}})},y=[{title:_(`assets.target`,null,`目标`),dataIndex:`host`,width:260,render:(e,t)=>(0,G.jsxs)(`div`,{className:`asset-library-target`,children:[(0,G.jsx)(Oe,{text:R(t),max:38}),(0,G.jsx)(K,{type:`tertiary`,size:`small`,children:[t.ip,t.domain].filter(Boolean).join(` · `)||`—`})]})},{title:_(`assets.service`,null,`服务`),dataIndex:`protocol`,width:150,render:(e,t)=>(0,G.jsx)(ke,{protocol:t.protocol,port:t.port})},{title:_(`assets.project`,null,`所属项目`),dataIndex:`project_name`,width:160,render:(e,t)=>(0,G.jsx)(Oe,{text:e||t.project_id||_(`assets.scopeUnassigned`,null,`未归属项目`),max:18})},{title:_(`assets.source`,null,`来源`),dataIndex:`source`,width:120,render:e=>(0,G.jsx)(Oe,{text:e,max:14})},{title:_(`assets.riskLevel`,null,`风险等级`),dataIndex:`risk_level`,width:150,render:(e,t)=>(0,G.jsxs)(l,{spacing:6,children:[(0,G.jsx)(U,{asset:t}),(0,G.jsx)(K,{type:`tertiary`,size:`small`,children:Number(t.vulnerability_count||0)})]})},{title:_(`assets.lastSeen`,null,`最近发现`),dataIndex:`last_seen_at`,width:170,render:e=>(0,G.jsx)(K,{size:`small`,children:C(e)})},{title:_(`common.actions`,null,`操作`),dataIndex:`id`,width:190,render:(e,t)=>(0,G.jsxs)(l,{spacing:4,children:[(0,G.jsx)(u,{theme:`borderless`,size:`small`,onClick:()=>d(t),children:_(`common.view`,null,`查看`)}),h&&(0,G.jsx)(u,{theme:`borderless`,size:`small`,onClick:()=>f(t),children:_(`common.edit`,null,`编辑`)}),g&&(0,G.jsx)(u,{theme:`borderless`,type:`danger`,size:`small`,onClick:()=>v(t),children:_(`common.delete`,null,`删除`)})]})}];return(0,G.jsx)(oe,{columns:y,dataSource:e,loading:t,rowKey:`id`,onRefresh:m,rowSelection:{selectedRowKeys:s,onChange:(e,t)=>c(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:q}=c;function Ie({asset:e,visible:t,onClose:r,onEdit:i,onDelete:a,canWrite:o,canDelete:c}){let d=w(),f=n(),[p,m]=(0,W.useState)([]);if((0,W.useEffect)(()=>{if(!t||!e?.id){m([]);return}let n=!1;return T.get(`/assets/${e.id}/facts`).then(e=>{n||m(Array.isArray(e?.facts)?e.facts:[])}).catch(()=>{n||m([])}),()=>{n=!0}},[t,e?.id]),!e)return null;let h=()=>{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`)},g=[{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,G.jsx)(ke,{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,G.jsx)(Ae,{status:e.status})},{label:d(`assets.riskLevel`,null,`风险等级`),value:(0,G.jsx)(U,{asset:e})},{label:d(`assets.environment`,null,`环境`),value:F(e.environment)||`—`},{label:d(`assets.criticality`,null,`重要性`),value:me(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,G.jsx)(q,{code:!0,size:`small`,children:e.source_query}):`—`},{label:d(`assets.tagsLabel`,null,`标签`),value:(0,G.jsx)(H,{tags:e.tags,max:6})},{label:d(`assets.firstSeen`,null,`首次发现`),value:C(e.first_seen_at)},{label:d(`assets.lastSeen`,null,`最近发现`),value:C(e.last_seen_at)},{label:d(`assets.lastScan`,null,`上次扫描`),value:C(e.last_scan_at)},{label:`创建时间`,value:C(e.created_at)},{label:`更新时间`,value:C(e.updated_at)},{label:`资产 ID`,value:(0,G.jsx)(q,{copyable:{content:e.id},size:`small`,children:e.id})}];return(0,G.jsxs)(y,{visible:t,onCancel:r,title:d(`assets.detailTitle`,null,`资产详情`),width:620,placement:`right`,footer:(0,G.jsxs)(l,{children:[o&&(0,G.jsx)(u,{onClick:()=>i(e),children:d(`common.edit`,null,`编辑`)}),c&&(0,G.jsx)(u,{type:`danger`,onClick:()=>a(e),children:d(`common.delete`,null,`删除`)}),(0,G.jsx)(u,{theme:`borderless`,onClick:r,children:d(`common.close`,null,`关闭`)})]}),children:[(0,G.jsxs)(`div`,{className:`asset-library-detail-target`,children:[(0,G.jsxs)(`div`,{className:`asset-library-detail-target-main`,children:[(0,G.jsx)(q,{strong:!0,size:`large`,children:R(e)}),(0,G.jsx)(A,{text:R(e)})]}),(0,G.jsx)(q,{type:`tertiary`,children:[e.ip,e.domain,we(e)].filter(Boolean).join(` · `)||`—`}),(0,G.jsxs)(l,{spacing:6,wrap:!0,className:`asset-library-detail-badges`,children:[(0,G.jsx)(Ae,{status:e.status}),(0,G.jsx)(U,{asset:e}),(0,G.jsxs)(q,{type:`tertiary`,size:`small`,children:[d(`assets.relatedVulnerabilities`,null,`相关漏洞`),`:`,Number(e.vulnerability_count||0),e.risk_level?`(${le(e.risk_level)})`:``]})]})]}),(0,G.jsx)(s,{margin:`12px`}),(0,G.jsx)(k,{items:g,columns:2}),(0,G.jsx)(s,{margin:`12px`}),(0,G.jsx)(q,{strong:!0,children:`项目事实`}),p.length===0?(0,G.jsx)(q,{type:`tertiary`,size:`small`,children:`还没有关联到这条资产的项目事实。`}):p.map(e=>(0,G.jsxs)(`div`,{className:`asset-library-detail-target`,children:[(0,G.jsx)(q,{children:e.summary||e.fact_key}),(0,G.jsxs)(l,{children:[e.source_conversation_id?(0,G.jsx)(u,{size:`small`,theme:`borderless`,onClick:()=>f(`/chat?conversation=${encodeURIComponent(e.source_conversation_id)}`),children:`打开来源会话`}):null,e.project_id?(0,G.jsx)(u,{size:`small`,theme:`borderless`,onClick:()=>f(`/projects/${e.project_id}?tab=facts`),children:`项目事实`}):null]})]},e.id)),(0,G.jsx)(s,{margin:`12px`}),(0,G.jsxs)(l,{children:[(0,G.jsx)(u,{theme:`light`,onClick:h,children:d(`assets.viewRelatedVulnerabilities`,null,`查看关联漏洞`)}),e.project_id&&(0,G.jsx)(u,{theme:`borderless`,onClick:()=>f(`/projects?id=${encodeURIComponent(e.project_id)}`),children:d(`assets.viewProject`,null,`查看项目`)})]})]})}var Le={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 J(e){return String(e??``).replace(/^\uFEFF/,``).trim().toLowerCase().replace(/[\s_\-/.()()]+/g,``)}function Re(e){let t=J(e);return t&&_e.find(e=>(z[e]||[]).some(e=>J(e)===t))||``}function Y(e){let t=String(e??``).replace(/^\uFEFF/,``),n=[],r=[],i=``,a=!1;for(let e=0;e{c(t.q||``)},[t.q]);let l=[`status`,`risk_level`,`environment`,`criticality`,`ip`,`domain`,`port`,`scan`].filter(e=>t[e]).length;return(0,G.jsxs)(`div`,{className:`asset-library-filters`,children:[(0,G.jsxs)(`div`,{className:`asset-library-filter-row`,children:[(0,G.jsx)(`span`,{id:o,hidden:!0,children:a(`assets.scopeLabel`,null,`资产范围`)}),(0,G.jsx)(S,{"aria-labelledby":o,value:e.value,optionList:e.options,loading:e.loading,disabled:i,onChange:e.onChange,filter:!0}),(0,G.jsx)(f,{className:`asset-library-filter-search`,prefix:(0,G.jsx)(_,{}),value:s,disabled:i,placeholder:a(`assets.searchPlaceholder`,null,`搜索主机、IP、域名、标题、服务或标签`),onChange:e=>{c(e),n({q:e})},showClear:!0}),(0,G.jsx)(S,{value:t.protocol||void 0,placeholder:a(`assets.assetType`,null,`类型 / 协议`),optionList:ye,filter:!0,allowCreate:!0,showClear:!0,disabled:i,onChange:e=>n({protocol:e||``})}),(0,G.jsx)(f,{value:t.source,placeholder:a(`assets.source`,null,`来源`),disabled:i,onChange:e=>n({source:e}),showClear:!0}),(0,G.jsx)(f,{value:t.tag,placeholder:a(`assets.tagsLabel`,null,`标签`),disabled:i,onChange:e=>n({tag:e}),showClear:!0}),(0,G.jsx)(u,{onClick:r,disabled:i,children:a(`assets.resetFilters`,null,`重置`)})]}),(0,G.jsx)(g,{className:`asset-library-filter-advanced`,keepDOM:!1,children:(0,G.jsx)(g.Panel,{itemKey:`advanced`,header:`${a(`assets.advancedFilters`,null,`高级筛选`)}${l?`(${l})`:``}`,children:(0,G.jsxs)(`div`,{className:`asset-library-filter-grid`,children:[(0,G.jsx)(S,{value:t.status||void 0,placeholder:a(`assets.allStatuses`,null,`全部状态`),optionList:fe,showClear:!0,disabled:i,onChange:e=>n({status:e||``})}),(0,G.jsx)(S,{value:t.risk_level||void 0,placeholder:a(`assets.allRisks`,null,`全部风险`),optionList:he,showClear:!0,disabled:i,onChange:e=>n({risk_level:e||``})}),(0,G.jsx)(S,{value:t.environment||void 0,placeholder:a(`assets.allEnvironments`,null,`全部环境`),optionList:N,showClear:!0,disabled:i,onChange:e=>n({environment:e||``})}),(0,G.jsx)(S,{value:t.criticality||void 0,placeholder:a(`assets.allCriticalities`,null,`全部级别`),optionList:Te,showClear:!0,disabled:i,onChange:e=>n({criticality:e||``})}),(0,G.jsx)(f,{value:t.ip,placeholder:`IP`,disabled:i,onChange:e=>n({ip:e}),showClear:!0}),(0,G.jsx)(f,{value:t.domain,placeholder:a(`assets.domain`,null,`域名`),disabled:i,onChange:e=>n({domain:e}),showClear:!0}),(0,G.jsx)(f,{value:t.port,placeholder:a(`assets.port`,null,`端口`),disabled:i,onChange:e=>n({port:String(e||``).replace(/[^\d]/g,``)}),showClear:!0}),(0,G.jsx)(S,{value:t.scan||``,placeholder:a(`assets.scanState`,null,`扫描状态`),optionList:ue,disabled:i,onChange:e=>n({scan:e||``})}),(0,G.jsx)(S,{value:t.sort||`last_seen_at:desc`,optionList:B,disabled:i,onChange:e=>n({sort:e||`last_seen_at:desc`})})]})})})]})}var{Text:K}=c;function Fe({assets:e,loading:t,total:n,page:r,pageSize:i,onPageChange:a,onPageSizeChange:o,selectedRowKeys:s,onSelectionChange:c,onView:d,onEdit:f,onDelete:p,onRefresh:m,canWrite:h,canDelete:g}){let _=w(),v=e=>{se({title:_(`assets.deleteConfirm`,null,`确定删除该资产吗?`),content:R(e),okText:_(`common.delete`,null,`删除`),onOk:()=>{Promise.resolve(p(e)).catch(e=>D(e,_(`assets.deleteFailed`,null,`删除资产失败`)))}})},y=[{title:_(`assets.target`,null,`目标`),dataIndex:`host`,width:260,render:(e,t)=>(0,G.jsxs)(`div`,{className:`asset-library-target`,children:[(0,G.jsx)(Oe,{text:R(t),max:38}),(0,G.jsx)(K,{type:`tertiary`,size:`small`,children:[t.ip,t.domain].filter(Boolean).join(` · `)||`—`})]})},{title:_(`assets.service`,null,`服务`),dataIndex:`protocol`,width:150,render:(e,t)=>(0,G.jsx)(ke,{protocol:t.protocol,port:t.port})},{title:_(`assets.project`,null,`所属项目`),dataIndex:`project_name`,width:160,render:(e,t)=>(0,G.jsx)(Oe,{text:e||t.project_id||_(`assets.scopeUnassigned`,null,`未归属项目`),max:18})},{title:_(`assets.source`,null,`来源`),dataIndex:`source`,width:120,render:e=>(0,G.jsx)(Oe,{text:e,max:14})},{title:_(`assets.riskLevel`,null,`风险等级`),dataIndex:`risk_level`,width:150,render:(e,t)=>(0,G.jsxs)(l,{spacing:6,children:[(0,G.jsx)(U,{asset:t}),(0,G.jsx)(K,{type:`tertiary`,size:`small`,children:Number(t.vulnerability_count||0)})]})},{title:_(`assets.lastSeen`,null,`最近发现`),dataIndex:`last_seen_at`,width:170,render:e=>(0,G.jsx)(K,{size:`small`,children:C(e)})},{title:_(`common.actions`,null,`操作`),dataIndex:`id`,width:190,render:(e,t)=>(0,G.jsxs)(l,{spacing:4,children:[(0,G.jsx)(u,{theme:`borderless`,size:`small`,onClick:()=>d(t),children:_(`common.view`,null,`查看`)}),h&&(0,G.jsx)(u,{theme:`borderless`,size:`small`,onClick:()=>f(t),children:_(`common.edit`,null,`编辑`)}),g&&(0,G.jsx)(u,{theme:`borderless`,type:`danger`,size:`small`,onClick:()=>v(t),children:_(`common.delete`,null,`删除`)})]})}];return(0,G.jsx)(oe,{columns:y,dataSource:e,loading:t,rowKey:`id`,onRefresh:m,rowSelection:{selectedRowKeys:s,onChange:(e,t)=>c(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:q}=c;function Ie({asset:e,visible:t,onClose:r,onEdit:i,onDelete:a,canWrite:o,canDelete:c}){let d=w(),f=n(),[p,m]=(0,W.useState)([]);if((0,W.useEffect)(()=>{if(!t||!e?.id){m([]);return}let n=!1;return T.get(`/assets/${e.id}/facts`).then(e=>{n||m(Array.isArray(e?.facts)?e.facts:[])}).catch(()=>{n||m([])}),()=>{n=!0}},[t,e?.id]),!e)return null;let h=()=>{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`)},g=[{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,G.jsx)(ke,{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,G.jsx)(Ae,{status:e.status})},{label:d(`assets.riskLevel`,null,`风险等级`),value:(0,G.jsx)(U,{asset:e})},{label:d(`assets.environment`,null,`环境`),value:F(e.environment)||`—`},{label:d(`assets.criticality`,null,`重要性`),value:me(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,G.jsx)(q,{code:!0,size:`small`,children:e.source_query}):`—`},{label:d(`assets.tagsLabel`,null,`标签`),value:(0,G.jsx)(H,{tags:e.tags,max:6})},{label:d(`assets.firstSeen`,null,`首次发现`),value:C(e.first_seen_at)},{label:d(`assets.lastSeen`,null,`最近发现`),value:C(e.last_seen_at)},{label:d(`assets.lastScan`,null,`上次扫描`),value:C(e.last_scan_at)},{label:`创建时间`,value:C(e.created_at)},{label:`更新时间`,value:C(e.updated_at)},{label:`资产 ID`,value:(0,G.jsx)(q,{copyable:{content:e.id},size:`small`,children:e.id})}];return(0,G.jsxs)(y,{visible:t,onCancel:r,title:d(`assets.detailTitle`,null,`资产详情`),width:620,placement:`right`,footer:(0,G.jsxs)(l,{children:[o&&(0,G.jsx)(u,{onClick:()=>i(e),children:d(`common.edit`,null,`编辑`)}),c&&(0,G.jsx)(u,{type:`danger`,onClick:()=>a(e),children:d(`common.delete`,null,`删除`)}),(0,G.jsx)(u,{theme:`borderless`,onClick:r,children:d(`common.close`,null,`关闭`)})]}),children:[(0,G.jsxs)(`div`,{className:`asset-library-detail-target`,children:[(0,G.jsxs)(`div`,{className:`asset-library-detail-target-main`,children:[(0,G.jsx)(q,{strong:!0,size:`large`,children:R(e)}),(0,G.jsx)(A,{text:R(e)})]}),(0,G.jsx)(q,{type:`tertiary`,children:[e.ip,e.domain,we(e)].filter(Boolean).join(` · `)||`—`}),(0,G.jsxs)(l,{spacing:6,wrap:!0,className:`asset-library-detail-badges`,children:[(0,G.jsx)(Ae,{status:e.status}),(0,G.jsx)(U,{asset:e}),(0,G.jsxs)(q,{type:`tertiary`,size:`small`,children:[d(`assets.relatedVulnerabilities`,null,`相关漏洞`),`:`,Number(e.vulnerability_count||0),e.risk_level?`(${le(e.risk_level)})`:``]})]})]}),(0,G.jsx)(s,{margin:`12px`}),(0,G.jsx)(k,{items:g,columns:2}),(0,G.jsx)(s,{margin:`12px`}),(0,G.jsx)(q,{strong:!0,children:`项目事实`}),p.length===0?(0,G.jsx)(q,{type:`tertiary`,size:`small`,children:`还没有关联到这条资产的项目事实。`}):p.map(e=>(0,G.jsxs)(`div`,{className:`asset-library-detail-target`,children:[(0,G.jsx)(q,{children:e.summary||e.fact_key}),(0,G.jsxs)(l,{children:[e.source_conversation_id?(0,G.jsx)(u,{size:`small`,theme:`borderless`,onClick:()=>f(`/chat?conversation=${encodeURIComponent(e.source_conversation_id)}`),children:`打开来源会话`}):null,e.project_id?(0,G.jsx)(u,{size:`small`,theme:`borderless`,onClick:()=>f(`/projects/${e.project_id}?tab=facts`),children:`项目事实`}):null]})]},e.id)),(0,G.jsx)(s,{margin:`12px`}),(0,G.jsxs)(l,{children:[(0,G.jsx)(u,{theme:`light`,onClick:h,children:d(`assets.viewRelatedVulnerabilities`,null,`查看关联漏洞`)}),e.project_id&&(0,G.jsx)(u,{theme:`borderless`,onClick:()=>f(`/projects?id=${encodeURIComponent(e.project_id)}`),children:d(`assets.viewProject`,null,`查看项目`)})]})]})}var Le={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 J(e){return String(e??``).replace(/^\uFEFF/,``).trim().toLowerCase().replace(/[\s_\-/.()()]+/g,``)}function Re(e){let t=J(e);return t&&_e.find(e=>(z[e]||[]).some(e=>J(e)===t))||``}function Y(e){let t=String(e??``).replace(/^\uFEFF/,``),n=[],r=[],i=``,a=!1;for(let e=0;ee.some(e=>String(e??``).trim()!==``))}function X(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 ze(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 Be(e,t,{projects:n,projectId:r,source:i}){let a=n=>({rowNumber:t,values:e,asset:null,error:n}),o=e.target||e.host||e.domain||e.ip||``;if(!o)return a(`缺少目标地址`);let s;try{s=Ee(o)}catch(e){return a(e.message)}let c=String(e.port??``).trim(),l=Number(c===``?s.port||0:c);if(!Number.isInteger(l)||l<0||l>65535)return a(`端口必须在 0–65535 之间`);let u=String(e.ip||s.ip||``).trim().toLowerCase();if(u&&!P(u)&&!ve(u))return a(`IP 地址格式无效`);let d=String(e.domain||s.domain||``).trim(),f=d?L(d):``;if(d&&!f)return a(`域名格式无效`);let p=String(e.protocol||s.protocol||``).trim().toLowerCase();if(p&&!/^[a-z][a-z0-9+.-]{0,31}$/.test(p))return a(`协议格式无效`);let m=X(e.status,ge,`active`);if(!m)return a(`状态仅支持 active 或 inactive`);let h=X(e.environment,Ce,``);if(h===null)return a(`环境值无效`);let g=X(e.criticality,xe,``);if(g===null)return a(`重要性值无效`);let _=ze(e.project||r,n);if(_.error)return a(_.error);if(r!==void 0&&_.projectId!==r)return a(`该行的项目与当前资产范围不一致`);let v=I(e.tags);if(v.length>30)return a(`标签最多 30 个`);if(v.some(e=>Array.from(e).length>64))return a(`单个标签最多 64 个字符`);let y={host:String(e.host||s.host||``).trim(),ip:u,domain:f,port:l,protocol:p,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:h,criticality:g,status:m,tags:v,project_id:_.projectId,source:i||`manual-import`},b=Object.keys(Le).find(e=>Array.from(String(y[e]||``)).length>Le[e]);if(b)return a(`字段 ${b} 内容过长`);let x=be(y);return x?a(x):{rowNumber:t,values:e,asset:y,projectName:_.projectName,error:``}}function Ve(e){let t=new Map;return e.map(e=>{if(e.error||!e.asset)return e;let n=De(e.asset);return t.has(n)?{...e,error:`与第 ${t.get(n)} 行重复`}:(t.set(n,e.rowNumber),e)})}function He(e,t={}){let n=Y(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(`数据不能超过 ${V} 行`);return Ve(i.map((e,n)=>{let i={};return r.forEach((t,n)=>{t&&i[t]==null&&(i[t]=String(e[n]??``).trim())}),Be(i,n+2,t)}))}function Ue(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(`数据不能超过 ${V} 行`);return Ve(r.map((e,n)=>Be({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 Z(){return`${_e.join(`,`)}\r\n`}function We(e){let t=String(e??``);return/[",\r\n]/.test(t)?`"${t.replaceAll(`"`,`""`)}"`:t}function Q(e,t){return t===`target`?R(e):t===`project`?e.project_name||e.project_id||``:t===`tags`?(e.tags||[]).join(`,`):t===`status`?pe(e.status):t===`environment`?F(e.environment):t===`criticality`?me(e.criticality):t===`risk_level`?le(e.risk_level):t===`vulnerability_count`?Number(e.vulnerability_count||0):e[t]??``}function Ge(e){let t=[Se.map(([,e])=>We(e)).join(`,`)];return(e||[]).forEach(e=>{t.push(Se.map(([t])=>We(Q(e,t))).join(`,`))}),`\uFEFF${t.join(`\r
-`)}`}function Ke(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:$}=c,qe=e=>[{title:e(`assets.rowNumber`,null,`行号`),dataIndex:`rowNumber`,width:70},{title:e(`assets.target`,null,`目标`),dataIndex:`target`,render:(e,t)=>R(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,G.jsx)($,{type:`danger`,size:`small`,children:t}):(0,G.jsx)($,{type:`success`,size:`small`,children:e(`assets.validationPassed`,null,`通过`)})}];function Je({visible:e,projects:t,defaultProjectId:n,onClose:r,onDone:i}){let s=w(),[c,f]=(0,W.useState)(`csv`),[p,m]=(0,W.useState)(``),[g,_]=(0,W.useState)(``),[v,y]=(0,W.useState)(``),[x,S]=(0,W.useState)(!1),C=(0,W.useRef)(null),ee=(0,W.useMemo)(()=>{if(!String(p||``).trim())return{records:[],error:``};try{let e={projects:t,projectId:n,source:`manual-import`};return{records:c===`csv`?He(p,e):Ue(p,e),error:``}}catch(e){return{records:[],error:e.message}}},[p,c,t,n]),E=ee.records,D=E.filter(e=>!e.error),k=E.length-D.length,ne=v||ee.error,re=()=>{m(``),_(``),f(`csv`),y(``),S(!1)},ie=()=>{x||(re(),r?.())},A=async e=>{if(!e)return;y(``);let t=String(e.name||``),n=t.split(`.`).pop().toLowerCase();if(![`csv`,`json`,`txt`].includes(n))y(`仅支持 .csv / .json / .txt 文件`);else if(e.size>104857600)y(s(`assets.fileTooLarge`,null,`文件不能超过 100 MB`));else try{let r=await e.text();f(n===`json`?`json`:`csv`),m(r),_(t)}catch(e){y(M(e,s(`assets.fileParseFailed`,null,`无法解析文件,请确认文件格式正确`)))}};return(0,G.jsxs)(O,{visible:e,title:s(`assets.bulkImportTitle`,null,`批量导入资产`),width:880,onCancel:ie,onOk:async()=>{if(!x&&D.length){y(``),S(!0);try{let e=await T.post(`/assets/import`,{assets:D.map(e=>e.asset),source:`manual-import`,source_query:g||`paste`}),t=Number(e?.skipped||0)+k,n=Number(e?.project_conflicts||0);j(s(`assets.bulkImportDone`,{created:Number(e?.created||0),updated:Number(e?.updated||0),skipped:t},`导入完成:新增 ${Number(e?.created||0)} 条,更新 ${Number(e?.updated||0)} 条,跳过 ${t} 条`)),n&&te(s(`assets.importProjectConflicts`,{count:n},`已跳过 ${n} 条归属不同的重复资产。`)),re(),i?.(),r?.()}catch(e){y(M(e,s(`assets.importFailed`,null,`资产入库失败`)))}finally{S(!1)}}},okText:s(`assets.importValidRowsCount`,{count:D.length},`导入 ${D.length} 条有效数据`),okButtonProps:{disabled:!D.length},confirmLoading:x,children:[(0,G.jsx)($,{type:`tertiary`,children:s(`assets.bulkImportSubtitle`,null,`支持 CSV / JSON 文本粘贴或文件上传,提交前会先校验并预览数据`)}),ne&&(0,G.jsx)(a,{type:`danger`,bordered:!0,closeIcon:null,description:ne,className:`asset-library-form-error`}),(0,G.jsxs)(l,{vertical:!0,align:`start`,spacing:10,className:`asset-library-import-body`,children:[(0,G.jsxs)(l,{children:[(0,G.jsx)(h,{type:`button`,value:c,options:[{value:`csv`,label:`CSV`},{value:`json`,label:`JSON`}],onChange:e=>{f(e.target.value),y(``)}}),(0,G.jsx)(u,{icon:(0,G.jsx)(o,{}),onClick:()=>C.current?.click(),children:s(`assets.chooseOrDropFile`,null,`选择文件`)}),(0,G.jsx)(`input`,{ref:C,type:`file`,accept:`.csv,.json,.txt`,className:`asset-library-file-input`,onChange:e=>{A(e.target.files?.[0]),e.target.value=``}}),(0,G.jsx)(u,{theme:`borderless`,onClick:()=>Ke(`asset-import-template.csv`,Z()),children:s(`assets.downloadCsv`,null,`下载 CSV 模板`)}),g&&(0,G.jsx)($,{type:`tertiary`,size:`small`,children:g})]}),(0,G.jsx)(d,{value:p,rows:8,className:`asset-library-import-textarea`,placeholder:c===`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=>{m(e),y(``)}}),E.length>0&&(0,G.jsxs)(`div`,{className:`asset-library-import-preview`,children:[(0,G.jsx)($,{strong:!0,children:s(`assets.importPreviewSummary`,{total:E.length,valid:D.length,invalid:k},`共 ${E.length} 行,${D.length} 行有效,${k} 行需修正`)}),(0,G.jsx)(b,{columns:qe(s),dataSource:E.slice(0,10).map((e,t)=>({...e,id:t})),rowKey:`id`,size:`small`,pagination:!1}),E.length>10&&(0,G.jsx)($,{type:`tertiary`,size:`small`,children:s(`assets.previewLimitedShort`,{count:E.length},`仅展示前 10 行;提交时将处理全部 ${E.length} 行`)})]})]})]})}var{Text:Ye}=c;function Xe({visible:e,assets:t,onClose:n,onDone:r}){let i=w(),o=(0,W.useMemo)(()=>Array.isArray(t)?t:[],[t]),[s,c]=(0,W.useState)(``),[u,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(!1);return(0,W.useEffect)(()=>{e&&(c(o[0]?.id||``),d(``),p(!1))},[e,o]),(0,G.jsxs)(O,{visible:e,title:i(`assets.mergeDuplicates`,null,`合并重复资产`),width:560,onCancel:n,onOk:async()=>{if(!(f||o.length<2)){p(!0),d(``);try{let e=await T.post(`/assets/merge`,{asset_ids:o.map(e=>e.id),primary_id:s||o[0].id});j(`已合并 ${Number(e?.merged||o.length)} 个资产`),r?.(),n?.()}catch(e){d(M(e,`合并资产失败`))}finally{p(!1)}}},okText:i(`assets.merge`,null,`合并`),okButtonProps:{disabled:o.length<2},confirmLoading:f,children:[o.length<2?(0,G.jsx)(a,{type:`warning`,bordered:!0,closeIcon:null,description:i(`assets.mergeRequiresMultiple`,null,`请至少选择两个重复资产`)}):(0,G.jsxs)(l,{vertical:!0,align:`start`,spacing:8,style:{width:`100%`},children:[(0,G.jsx)(Ye,{type:`tertiary`,children:i(`assets.mergeHint`,null,`将保留一个主资产,其余资产的空字段与标签会合并进来,然后删除被合并记录。所选资产必须共享域名、IP 或 Host。`)}),(0,G.jsx)(h,{value:s,onChange:e=>c(e.target.value),children:(0,G.jsx)(l,{vertical:!0,align:`start`,spacing:4,children:o.map(e=>(0,G.jsxs)(v,{value:e.id,children:[R(e),e.project_name?` · ${e.project_name}`:``]},e.id))})})]}),u&&(0,G.jsx)(a,{type:`danger`,bordered:!0,closeIcon:null,description:u,className:`asset-library-form-error`})]})}var{Text:Ze}=c;function Qe({visible:e,projects:t,assetIds:n,onClose:r,onDone:i}){let o=w(),[s,c]=(0,W.useState)(``),[u,d]=(0,W.useState)(!1),[f,m]=(0,W.useState)(``),[h,g]=(0,W.useState)(!1),_=(0,W.useMemo)(()=>Array.isArray(n)?n:[],[n]),v=(0,W.useMemo)(()=>(t||[]).map(e=>({value:e.id,label:e.name||e.id})),[t]);return(0,W.useEffect)(()=>{e&&(c(``),d(!1),m(``),g(!1))},[e]),(0,G.jsxs)(O,{visible:e,title:o(`assets.bindProjectTitle`,null,`绑定项目`),width:520,onCancel:r,onOk:async()=>{if(!h&&_.length){if(!u&&!s)m(o(`assets.selectProjectRequired`,null,`请选择要绑定的项目`));else{g(!0),m(``);try{await T.put(`/assets/project-binding`,{asset_ids:_,project_id:u?``:s}),j(o(`assets.bindProjectDone`,{count:_.length},`已更新 ${_.length} 个资产`)),i?.(),r?.()}catch(e){m(M(e,o(`assets.bindProjectFailed`,null,`绑定项目失败`)))}finally{g(!1)}}}},okText:u?o(`assets.unbindProject`,null,`解除绑定`):o(`assets.confirmBinding`,null,`确认绑定`),confirmLoading:h,children:[(0,G.jsxs)(l,{vertical:!0,align:`start`,spacing:10,style:{width:`100%`},children:[(0,G.jsx)(Ze,{type:`tertiary`,children:o(`assets.bindProjectCount`,{count:_.length},`将更新 ${_.length} 个资产`)}),(0,G.jsx)(S,{value:s||void 0,optionList:v,filter:!0,showClear:!0,disabled:u,placeholder:o(`assets.chooseProject`,null,`请选择项目`),onChange:e=>c(e||``),style:{width:`100%`}}),(0,G.jsxs)(l,{children:[(0,G.jsx)(p,{checked:u,onChange:d,size:`small`}),(0,G.jsx)(Ze,{size:`small`,children:o(`assets.unbindProject`,null,`解除项目绑定`)})]}),(0,G.jsx)(Ze,{type:`tertiary`,size:`small`,children:o(`assets.bindProjectHint`,null,`所选资产将统一更新为该项目归属。`)})]}),f&&(0,G.jsx)(a,{type:`danger`,bordered:!0,closeIcon:null,description:f,className:`asset-library-form-error`})]})}var{Text:$e}=c,et={status:``,environment:``,criticality:``,responsible_person:``,department:``,business_system:``,add_tags:``,remove_tags:``};function tt({visible:e,assetIds:t,onClose:n,onDone:r}){let i=w(),[o,s]=(0,W.useState)(et),[c,l]=(0,W.useState)(``),[u,d]=(0,W.useState)(!1),p=(0,W.useMemo)(()=>Array.isArray(t)?t:[],[t]);(0,W.useEffect)(()=>{e&&(s(et),l(``),d(!1))},[e]);let m=e=>s(t=>({...t,...e}));return(0,G.jsxs)(O,{visible:e,title:i(`assets.bulkEdit`,null,`批量编辑`),width:620,onCancel:n,onOk:async()=>{if(u||!p.length)return;let e={asset_ids:p};[`status`,`environment`,`criticality`,`responsible_person`,`department`,`business_system`].forEach(t=>{let n=String(o[t]||``).trim();n&&(e[t]=n)});let t=I(o.add_tags),i=I(o.remove_tags);if(t.length&&(e.add_tags=t),i.length&&(e.remove_tags=i),Object.keys(e).length===1)l(`请至少填写一项需要修改的内容`);else{d(!0),l(``);try{let t=await T.put(`/assets/bulk`,e);j(`已更新 ${Number(t?.updated||p.length)} 个资产`),r?.(),n?.()}catch(e){l(M(e,`批量编辑失败`))}finally{d(!1)}}},confirmLoading:u,children:[(0,G.jsxs)($e,{type:`tertiary`,children:[`将修改 `,p.length,` 个资产;空白字段保持原值。`]}),(0,G.jsxs)(`div`,{className:`asset-library-form-grid asset-library-form-grid--bulk`,children:[(0,G.jsx)(S,{value:o.status||void 0,placeholder:i(`assets.status`,null,`状态`),optionList:fe,showClear:!0,onChange:e=>m({status:e||``})}),(0,G.jsx)(S,{value:o.environment||void 0,placeholder:i(`assets.environment`,null,`环境`),optionList:N,showClear:!0,onChange:e=>m({environment:e||``})}),(0,G.jsx)(S,{value:o.criticality||void 0,placeholder:i(`assets.criticality`,null,`重要性`),optionList:Te,showClear:!0,onChange:e=>m({criticality:e||``})}),(0,G.jsx)(f,{value:o.responsible_person,placeholder:i(`assets.responsiblePerson`,null,`负责人`),onChange:e=>m({responsible_person:e})}),(0,G.jsx)(f,{value:o.department,placeholder:i(`assets.department`,null,`部门`),onChange:e=>m({department:e})}),(0,G.jsx)(f,{value:o.business_system,placeholder:i(`assets.businessSystem`,null,`业务系统`),onChange:e=>m({business_system:e})}),(0,G.jsx)(f,{value:o.add_tags,placeholder:`追加标签(逗号分隔)`,onChange:e=>m({add_tags:e})}),(0,G.jsx)(f,{value:o.remove_tags,placeholder:`移除标签(逗号分隔)`,onChange:e=>m({remove_tags:e})})]}),c&&(0,G.jsx)(a,{type:`danger`,bordered:!0,closeIcon:null,description:c,className:`asset-library-form-error`})]})}function nt(){let{data:e,loading:t,error:n,reload:r}=E(rt,[]);return{projects:e||[],loading:t,error:n,reload:r}}async function rt(){let e=[],t;do{let n=await T.get(`/projects`,{limit:500,offset:e.length}),r=n?.projects||[];if(e.push(...r),r.length<500)break;t=Number(n?.total||e.length)}while(e.length({project_id:e,project_unassigned:t===`unassigned`||void 0}),[e,t]),[_,v]=(0,W.useState)(()=>({...Ne(),q:r.get(`q`)||``})),[y,b]=(0,W.useState)(1),[S,C]=(0,W.useState)(20),[O,k]=(0,W.useState)({keys:[],rows:[]}),A=(0,W.useRef)(0),[oe,M]=(0,W.useState)(null),[le,ue]=(0,W.useState)(!1),[de,fe]=(0,W.useState)(null),[pe,me]=(0,W.useState)(!1),[he,ge]=(0,W.useState)(!1),[_e,ve]=(0,W.useState)(!1),[ye,be]=(0,W.useState)(!1),[xe,Se]=(0,W.useState)(!1),N=ie(_,300),P=(0,W.useMemo)(()=>({...at(N,y,S),...g}),[N,y,S,g]),{data:F,loading:I,error:Ce,reload:we}=E(()=>T.get(`/assets`,P),[P,d],{skip:!d}),{projects:L,loading:Te,error:R,reload:Ee}=n,De=(0,W.useMemo)(()=>Array.isArray(F?.assets)?F.assets:[],[F]),z=Ce?0:Number(F?.total||0),B=I||N!==_,V=[{value:`all`,label:s(`assets.scopeAll`,null,`全部资产`)},{value:`unassigned`,label:s(`assets.scopeUnassigned`,null,`未归属项目`)},...L.map(e=>({value:`project:${e.id}`,label:ce(e,s)}))];e&&!V.some(e=>e.value===t)&&V.push({value:t,label:e});let Oe=V.find(e=>e.value===t)?.label,H=(0,W.useRef)(``);(0,W.useEffect)(()=>()=>{A.current+=1},[]),(0,W.useEffect)(()=>{if(!h){H.current=``,M(null);return}if(!d||h===H.current)return;let e=!1;return T.get(`/assets`,{...g,id:h,page_size:1}).then(t=>{e||(H.current=h,M(t?.assets?.find(e=>e.id===h)||null))}).catch(t=>{e||D(t,s(`assets.loadFailed`,null,`加载资产失败`))}),()=>{e=!0}},[d,h,g,s]);let ke=e=>{if(e===t)return;let n=new URLSearchParams;e?.startsWith(`project:`)?n.set(`project_id`,e.slice(8)):e&&n.set(`scope`,e),i(n)},U=()=>{A.current+=1,k({keys:[],rows:[]})},Ae=e=>{v(t=>({...t,...e})),b(1),U()},Me=()=>{v(Ne()),b(1),U()},K=()=>{U(),we(),Ee()},q=e=>{let t=new URLSearchParams(r);e?t.set(`id`,e):t.delete(`id`),i(t,{replace:!0})},Le=e=>{H.current=e.id,M(e),e?.id&&q(e.id)},J=()=>{M(null),h&&(H.current=``,q(``))},Re=e=>{fe(e||null),ue(!0),f&&Ee()},Y=async()=>{U(),await we()},X=async e=>{await T.del(`/assets/${encodeURIComponent(e.id)}`),j(s(`assets.deleted`,null,`资产已删除`)),oe?.id===e.id&&J(),await Y()},ze=()=>{let e=O.keys;e.length&&se({title:s(`assets.deleteConfirm`,null,`确定删除所选资产吗?`),content:s(`assets.scopedDeleteConfirm`,{count:e.length,project:O.rows[0]?.project_name||O.rows[0]?.project_id||s(`assets.scopeUnassigned`,null,`未归属项目`)},`将永久删除所选的 ${e.length} 个资产。`),okText:s(`common.delete`,null,`删除`),onOk:async()=>{try{let t=await T.post(`/assets/batch-delete`,{asset_ids:e});j(`已删除 ${Number(t?.deleted||e.length)} 个资产`),await Y()}catch(e){D(e,`批量删除失败`)}}})},Be=(0,W.useMemo)(()=>{let{page:e,page_size:t,...n}=P;return n},[P]),Ve=async()=>{let e=++A.current;try{let t=await T.get(`/assets/selection`,Be);if(e!==A.current)return;let n=Array.isArray(t?.assets)?t.assets:[];k({keys:n.map(e=>e.id),rows:n}),j(s(`assets.allResultsSelected`,{count:n.length},`已选择 ${n.length} 项`))}catch(t){e===A.current&&D(t,`选择全部结果失败`)}},He=async e=>{if(!xe){Se(!0);try{let t=O.rows;if(e){let e=await T.get(`/assets/selection`,Be);t=Array.isArray(e?.assets)?e.assets:[]}else t.length||(t=De);if(!t.length){te(`没有可导出的资产`);return}Ke(`assets-${new Date().toISOString().slice(0,10)}.csv`,Ge(t)),j(`已导出 ${t.length} 个资产`)}catch(e){D(e,`导出失败`)}finally{Se(!1)}}},Ue=(e,t)=>{A.current+=1,k({keys:e||[],rows:t||[]})},Z=O.keys.length,We=new Set(O.rows.map(e=>e.project_id||``)).size>1,Q=Z>0&&!B&&!We;return d?(0,G.jsxs)(`div`,{className:`asset-library-page`,children:[(0,G.jsx)(ae,{title:s(`assets.libraryTitle`,null,`资产库`),extra:(0,G.jsxs)(l,{children:[(0,G.jsx)(u,{icon:(0,G.jsx)(x,{}),onClick:K,loading:I,children:s(`common.refresh`,null,`刷新`)}),f&&(0,G.jsx)(u,{icon:(0,G.jsx)(o,{}),onClick:()=>me(!0),children:s(`assets.bulkImport`,null,`批量导入`)}),f&&(0,G.jsx)(u,{theme:`solid`,type:`primary`,icon:(0,G.jsx)(m,{}),onClick:()=>Re(null),children:s(`assets.addAsset`,null,`新增资产`)})]})}),(0,G.jsxs)(re,{title:s(`assets.filterTitle`,null,`筛选条件`),children:[(0,G.jsx)(Pe,{scope:{value:t,options:V,loading:Te,onChange:ke},filters:_,onChange:Ae,onReset:Me}),(0,G.jsx)(ne,{error:R,onRetry:Ee})]}),(0,G.jsx)(ne,{error:Ce,onRetry:K}),(0,G.jsxs)(re,{title:`${Oe}(${z})`,extra:(0,G.jsxs)(l,{children:[(0,G.jsx)(u,{theme:`borderless`,disabled:!Z,onClick:U,children:s(`assets.clearSelection`,null,`清除选择`)}),(0,G.jsx)(u,{theme:`borderless`,disabled:B||!z,onClick:()=>He(!1),loading:xe,children:s(`assets.exportCsv`,null,`导出 CSV`)}),(0,G.jsx)(u,{theme:`borderless`,disabled:B||!z,onClick:()=>He(!0),loading:xe,children:s(`assets.exportAll`,null,`导出全部筛选结果`)})]}),children:[(0,G.jsxs)(`div`,{className:`asset-library-toolbar`,children:[(0,G.jsxs)(l,{children:[(0,G.jsx)(it,{type:`tertiary`,children:Z?s(`assets.selectedCount`,{count:Z},`已选择 ${Z} 项`):s(`assets.selectedCount`,{count:0},`已选择 0 项`)}),(0,G.jsx)(u,{theme:`borderless`,size:`small`,disabled:B||!z,onClick:Ve,children:s(`assets.selectAllResults`,{count:z},`选择全部 ${z} 项`)})]}),(0,G.jsxs)(l,{children:[f&&(0,G.jsx)(u,{size:`small`,disabled:!Q||Z<2||!p,onClick:()=>ge(!0),children:s(`assets.mergeDuplicates`,null,`合并重复资产`)}),f&&(0,G.jsx)(u,{size:`small`,disabled:!Q,onClick:()=>ve(!0),children:s(`assets.bindProject`,null,`绑定项目`)}),f&&(0,G.jsx)(u,{size:`small`,disabled:!Q,onClick:()=>be(!0),children:s(`assets.bulkEdit`,null,`批量编辑`)}),p&&(0,G.jsx)(u,{size:`small`,type:`danger`,disabled:!Q,onClick:ze,children:s(`assets.batchDelete`,null,`批量删除…`)})]})]}),We&&(f||p)&&(0,G.jsx)(it,{type:`tertiary`,size:`small`,children:s(`assets.mixedProjectSelection`,null,`批量修改前,请将选择缩小到同一项目或仅选择未归属资产。`)}),(0,G.jsx)(Fe,{assets:B||Ce?[]:De,loading:B,total:z,page:y,pageSize:S,onPageChange:e=>{b(e),U()},onPageSizeChange:e=>{C(e),b(1),U()},selectedRowKeys:O.keys,onSelectionChange:Ue,onView:Le,onEdit:Re,onDelete:X,onRefresh:K,canWrite:f,canDelete:p})]}),(0,G.jsx)(Ie,{asset:oe,visible:!!oe,onClose:J,onEdit:e=>{J(),Re(e)},onDelete:e=>{se({title:s(`assets.deleteConfirm`,null,`确定删除该资产吗?`),content:e.host||e.domain||e.ip,okText:s(`common.delete`,null,`删除`),onOk:()=>X(e).catch(e=>D(e,s(`assets.deleteFailed`,null,`删除资产失败`)))})},canWrite:f,canDelete:p}),(0,G.jsx)(je,{visible:le,asset:de,defaultProjectId:e,projects:L,onClose:()=>ue(!1),onSaved:Y}),(0,G.jsx)(Je,{visible:pe,defaultProjectId:t===`all`?void 0:e,projects:L,onClose:()=>me(!1),onDone:Y}),(0,G.jsx)(Xe,{visible:he,assets:O.rows,onClose:()=>ge(!1),onDone:Y}),(0,G.jsx)(Qe,{visible:_e,projects:L,assetIds:O.keys,onClose:()=>ve(!1),onDone:Y}),(0,G.jsx)(tt,{visible:ye,assetIds:O.keys,onClose:()=>be(!1),onDone:Y})]}):(0,G.jsxs)(`div`,{className:`asset-library-page`,children:[(0,G.jsx)(ae,{title:s(`assets.libraryTitle`,null,`资产库`),description:`资产列表、批量操作与导入需要资产读取权限。`}),(0,G.jsx)(a,{type:`warning`,bordered:!0,closeIcon:null,description:s(`assets.readDenied`,null,`当前账号没有 asset:read 权限,无法读取资产库;请联系管理员授权。`)})]})}export{at as buildAssetQuery,ot as default};
\ No newline at end of file
+`)}`}function Ke(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:$}=c,qe=e=>[{title:e(`assets.rowNumber`,null,`行号`),dataIndex:`rowNumber`,width:70},{title:e(`assets.target`,null,`目标`),dataIndex:`target`,render:(e,t)=>R(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,G.jsx)($,{type:`danger`,size:`small`,children:t}):(0,G.jsx)($,{type:`success`,size:`small`,children:e(`assets.validationPassed`,null,`通过`)})}];function Je({visible:e,projects:t,defaultProjectId:n,onClose:r,onDone:i}){let s=w(),[c,f]=(0,W.useState)(`csv`),[p,m]=(0,W.useState)(``),[g,_]=(0,W.useState)(``),[v,y]=(0,W.useState)(``),[x,S]=(0,W.useState)(!1),C=(0,W.useRef)(null),ee=(0,W.useMemo)(()=>{if(!String(p||``).trim())return{records:[],error:``};try{let e={projects:t,projectId:n,source:`manual-import`};return{records:c===`csv`?He(p,e):Ue(p,e),error:``}}catch(e){return{records:[],error:e.message}}},[p,c,t,n]),E=ee.records,D=E.filter(e=>!e.error),k=E.length-D.length,ne=v||ee.error,re=()=>{m(``),_(``),f(`csv`),y(``),S(!1)},ie=()=>{x||(re(),r?.())},A=async e=>{if(!e)return;y(``);let t=String(e.name||``),n=t.split(`.`).pop().toLowerCase();if(![`csv`,`json`,`txt`].includes(n))y(`仅支持 .csv / .json / .txt 文件`);else if(e.size>104857600)y(s(`assets.fileTooLarge`,null,`文件不能超过 100 MB`));else try{let r=await e.text();f(n===`json`?`json`:`csv`),m(r),_(t)}catch(e){y(M(e,s(`assets.fileParseFailed`,null,`无法解析文件,请确认文件格式正确`)))}};return(0,G.jsxs)(O,{visible:e,title:s(`assets.bulkImportTitle`,null,`批量导入资产`),width:880,onCancel:ie,onOk:async()=>{if(!x&&D.length){y(``),S(!0);try{let e=await T.post(`/assets/import`,{assets:D.map(e=>e.asset),source:`manual-import`,source_query:g||`paste`}),t=Number(e?.skipped||0)+k,n=Number(e?.project_conflicts||0);j(s(`assets.bulkImportDone`,{created:Number(e?.created||0),updated:Number(e?.updated||0),skipped:t},`导入完成:新增 ${Number(e?.created||0)} 条,更新 ${Number(e?.updated||0)} 条,跳过 ${t} 条`)),n&&te(s(`assets.importProjectConflicts`,{count:n},`已跳过 ${n} 条归属不同的重复资产。`)),re(),i?.(),r?.()}catch(e){y(M(e,s(`assets.importFailed`,null,`资产入库失败`)))}finally{S(!1)}}},okText:s(`assets.importValidRowsCount`,{count:D.length},`导入 ${D.length} 条有效数据`),okButtonProps:{disabled:!D.length},confirmLoading:x,children:[(0,G.jsx)($,{type:`tertiary`,children:s(`assets.bulkImportSubtitle`,null,`支持 CSV / JSON 文本粘贴或文件上传,提交前会先校验并预览数据`)}),ne&&(0,G.jsx)(a,{type:`danger`,bordered:!0,closeIcon:null,description:ne,className:`asset-library-form-error`}),(0,G.jsxs)(l,{vertical:!0,align:`start`,spacing:10,className:`asset-library-import-body`,children:[(0,G.jsxs)(l,{children:[(0,G.jsx)(h,{type:`button`,value:c,options:[{value:`csv`,label:`CSV`},{value:`json`,label:`JSON`}],onChange:e=>{f(e.target.value),y(``)}}),(0,G.jsx)(u,{icon:(0,G.jsx)(o,{}),onClick:()=>C.current?.click(),children:s(`assets.chooseOrDropFile`,null,`选择文件`)}),(0,G.jsx)(`input`,{ref:C,type:`file`,accept:`.csv,.json,.txt`,className:`asset-library-file-input`,onChange:e=>{A(e.target.files?.[0]),e.target.value=``}}),(0,G.jsx)(u,{theme:`borderless`,onClick:()=>Ke(`asset-import-template.csv`,Z()),children:s(`assets.downloadCsv`,null,`下载 CSV 模板`)}),g&&(0,G.jsx)($,{type:`tertiary`,size:`small`,children:g})]}),(0,G.jsx)(d,{value:p,rows:8,className:`asset-library-import-textarea`,placeholder:c===`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=>{m(e),y(``)}}),E.length>0&&(0,G.jsxs)(`div`,{className:`asset-library-import-preview`,children:[(0,G.jsx)($,{strong:!0,children:s(`assets.importPreviewSummary`,{total:E.length,valid:D.length,invalid:k},`共 ${E.length} 行,${D.length} 行有效,${k} 行需修正`)}),(0,G.jsx)(b,{columns:qe(s),dataSource:E.slice(0,10).map((e,t)=>({...e,id:t})),rowKey:`id`,size:`small`,pagination:!1}),E.length>10&&(0,G.jsx)($,{type:`tertiary`,size:`small`,children:s(`assets.previewLimitedShort`,{count:E.length},`仅展示前 10 行;提交时将处理全部 ${E.length} 行`)})]})]})]})}var{Text:Ye}=c;function Xe({visible:e,assets:t,onClose:n,onDone:r}){let i=w(),o=(0,W.useMemo)(()=>Array.isArray(t)?t:[],[t]),[s,c]=(0,W.useState)(``),[u,d]=(0,W.useState)(``),[f,p]=(0,W.useState)(!1);return(0,W.useEffect)(()=>{e&&(c(o[0]?.id||``),d(``),p(!1))},[e,o]),(0,G.jsxs)(O,{visible:e,title:i(`assets.mergeDuplicates`,null,`合并重复资产`),width:560,onCancel:n,onOk:async()=>{if(!(f||o.length<2)){p(!0),d(``);try{let e=await T.post(`/assets/merge`,{asset_ids:o.map(e=>e.id),primary_id:s||o[0].id});j(`已合并 ${Number(e?.merged||o.length)} 个资产`),r?.(),n?.()}catch(e){d(M(e,`合并资产失败`))}finally{p(!1)}}},okText:i(`assets.merge`,null,`合并`),okButtonProps:{disabled:o.length<2},confirmLoading:f,children:[o.length<2?(0,G.jsx)(a,{type:`warning`,bordered:!0,closeIcon:null,description:i(`assets.mergeRequiresMultiple`,null,`请至少选择两个重复资产`)}):(0,G.jsxs)(l,{vertical:!0,align:`start`,spacing:8,style:{width:`100%`},children:[(0,G.jsx)(Ye,{type:`tertiary`,children:i(`assets.mergeHint`,null,`将保留一个主资产,其余资产的空字段与标签会合并进来,然后删除被合并记录。所选资产必须共享域名、IP 或 Host。`)}),(0,G.jsx)(h,{value:s,onChange:e=>c(e.target.value),children:(0,G.jsx)(l,{vertical:!0,align:`start`,spacing:4,children:o.map(e=>(0,G.jsxs)(v,{value:e.id,children:[R(e),e.project_name?` · ${e.project_name}`:``]},e.id))})})]}),u&&(0,G.jsx)(a,{type:`danger`,bordered:!0,closeIcon:null,description:u,className:`asset-library-form-error`})]})}var{Text:Ze}=c;function Qe({visible:e,projects:t,assetIds:n,onClose:r,onDone:i}){let o=w(),[s,c]=(0,W.useState)(``),[u,d]=(0,W.useState)(!1),[f,m]=(0,W.useState)(``),[h,g]=(0,W.useState)(!1),_=(0,W.useMemo)(()=>Array.isArray(n)?n:[],[n]),v=(0,W.useMemo)(()=>(t||[]).map(e=>({value:e.id,label:e.name||e.id})),[t]);return(0,W.useEffect)(()=>{e&&(c(``),d(!1),m(``),g(!1))},[e]),(0,G.jsxs)(O,{visible:e,title:o(`assets.bindProjectTitle`,null,`绑定项目`),width:520,onCancel:r,onOk:async()=>{if(!h&&_.length){if(!u&&!s)m(o(`assets.selectProjectRequired`,null,`请选择要绑定的项目`));else{g(!0),m(``);try{await T.put(`/assets/project-binding`,{asset_ids:_,project_id:u?``:s}),j(o(`assets.bindProjectDone`,{count:_.length},`已更新 ${_.length} 个资产`)),i?.(),r?.()}catch(e){m(M(e,o(`assets.bindProjectFailed`,null,`绑定项目失败`)))}finally{g(!1)}}}},okText:u?o(`assets.unbindProject`,null,`解除绑定`):o(`assets.confirmBinding`,null,`确认绑定`),confirmLoading:h,children:[(0,G.jsxs)(l,{vertical:!0,align:`start`,spacing:10,style:{width:`100%`},children:[(0,G.jsx)(Ze,{type:`tertiary`,children:o(`assets.bindProjectCount`,{count:_.length},`将更新 ${_.length} 个资产`)}),(0,G.jsx)(S,{value:s||void 0,optionList:v,filter:!0,showClear:!0,disabled:u,placeholder:o(`assets.chooseProject`,null,`请选择项目`),onChange:e=>c(e||``),style:{width:`100%`}}),(0,G.jsxs)(l,{children:[(0,G.jsx)(p,{checked:u,onChange:d,size:`small`}),(0,G.jsx)(Ze,{size:`small`,children:o(`assets.unbindProject`,null,`解除项目绑定`)})]}),(0,G.jsx)(Ze,{type:`tertiary`,size:`small`,children:o(`assets.bindProjectHint`,null,`所选资产将统一更新为该项目归属。`)})]}),f&&(0,G.jsx)(a,{type:`danger`,bordered:!0,closeIcon:null,description:f,className:`asset-library-form-error`})]})}var{Text:$e}=c,et={status:``,environment:``,criticality:``,responsible_person:``,department:``,business_system:``,add_tags:``,remove_tags:``};function tt({visible:e,assetIds:t,onClose:n,onDone:r}){let i=w(),[o,s]=(0,W.useState)(et),[c,l]=(0,W.useState)(``),[u,d]=(0,W.useState)(!1),p=(0,W.useMemo)(()=>Array.isArray(t)?t:[],[t]);(0,W.useEffect)(()=>{e&&(s(et),l(``),d(!1))},[e]);let m=e=>s(t=>({...t,...e}));return(0,G.jsxs)(O,{visible:e,title:i(`assets.bulkEdit`,null,`批量编辑`),width:620,onCancel:n,onOk:async()=>{if(u||!p.length)return;let e={asset_ids:p};[`status`,`environment`,`criticality`,`responsible_person`,`department`,`business_system`].forEach(t=>{let n=String(o[t]||``).trim();n&&(e[t]=n)});let t=I(o.add_tags),i=I(o.remove_tags);if(t.length&&(e.add_tags=t),i.length&&(e.remove_tags=i),Object.keys(e).length===1)l(`请至少填写一项需要修改的内容`);else{d(!0),l(``);try{let t=await T.put(`/assets/bulk`,e);j(`已更新 ${Number(t?.updated||p.length)} 个资产`),r?.(),n?.()}catch(e){l(M(e,`批量编辑失败`))}finally{d(!1)}}},confirmLoading:u,children:[(0,G.jsxs)($e,{type:`tertiary`,children:[`将修改 `,p.length,` 个资产;空白字段保持原值。`]}),(0,G.jsxs)(`div`,{className:`asset-library-form-grid asset-library-form-grid--bulk`,children:[(0,G.jsx)(S,{value:o.status||void 0,placeholder:i(`assets.status`,null,`状态`),optionList:fe,showClear:!0,onChange:e=>m({status:e||``})}),(0,G.jsx)(S,{value:o.environment||void 0,placeholder:i(`assets.environment`,null,`环境`),optionList:N,showClear:!0,onChange:e=>m({environment:e||``})}),(0,G.jsx)(S,{value:o.criticality||void 0,placeholder:i(`assets.criticality`,null,`重要性`),optionList:Te,showClear:!0,onChange:e=>m({criticality:e||``})}),(0,G.jsx)(f,{value:o.responsible_person,placeholder:i(`assets.responsiblePerson`,null,`负责人`),onChange:e=>m({responsible_person:e})}),(0,G.jsx)(f,{value:o.department,placeholder:i(`assets.department`,null,`部门`),onChange:e=>m({department:e})}),(0,G.jsx)(f,{value:o.business_system,placeholder:i(`assets.businessSystem`,null,`业务系统`),onChange:e=>m({business_system:e})}),(0,G.jsx)(f,{value:o.add_tags,placeholder:`追加标签(逗号分隔)`,onChange:e=>m({add_tags:e})}),(0,G.jsx)(f,{value:o.remove_tags,placeholder:`移除标签(逗号分隔)`,onChange:e=>m({remove_tags:e})})]}),c&&(0,G.jsx)(a,{type:`danger`,bordered:!0,closeIcon:null,description:c,className:`asset-library-form-error`})]})}function nt(){let{data:e,loading:t,error:n,reload:r}=E(rt,[]);return{projects:e||[],loading:t,error:n,reload:r}}async function rt(){let e=[],t;do{let n=await T.get(`/projects`,{limit:500,offset:e.length}),r=n?.projects||[];if(e.push(...r),r.length<500)break;t=Number(n?.total||e.length)}while(e.length({project_id:e,project_unassigned:t===`unassigned`||void 0,sync_project_scope:e?1:void 0}),[e,t]),[_,v]=(0,W.useState)(()=>({...Ne(),q:r.get(`q`)||``})),[y,b]=(0,W.useState)(1),[S,C]=(0,W.useState)(20),[O,k]=(0,W.useState)({keys:[],rows:[]}),A=(0,W.useRef)(0),[oe,M]=(0,W.useState)(null),[le,ue]=(0,W.useState)(!1),[de,fe]=(0,W.useState)(null),[pe,me]=(0,W.useState)(!1),[he,ge]=(0,W.useState)(!1),[_e,ve]=(0,W.useState)(!1),[ye,be]=(0,W.useState)(!1),[xe,Se]=(0,W.useState)(!1),N=ie(_,300),P=(0,W.useMemo)(()=>({...at(N,y,S),...g}),[N,y,S,g]),{data:F,loading:I,error:Ce,reload:we}=E(()=>T.get(`/assets`,P),[P,d],{skip:!d}),{projects:L,loading:Te,error:R,reload:Ee}=n,De=(0,W.useMemo)(()=>Array.isArray(F?.assets)?F.assets:[],[F]),z=Ce?0:Number(F?.total||0),B=I||N!==_,V=[{value:`all`,label:s(`assets.scopeAll`,null,`全部资产`)},{value:`unassigned`,label:s(`assets.scopeUnassigned`,null,`未归属项目`)},...L.map(e=>({value:`project:${e.id}`,label:ce(e,s)}))];e&&!V.some(e=>e.value===t)&&V.push({value:t,label:e});let Oe=V.find(e=>e.value===t)?.label,H=(0,W.useRef)(``);(0,W.useEffect)(()=>()=>{A.current+=1},[]),(0,W.useEffect)(()=>{if(!h){H.current=``,M(null);return}if(!d||h===H.current)return;let e=!1;return T.get(`/assets`,{...g,id:h,page_size:1}).then(t=>{e||(H.current=h,M(t?.assets?.find(e=>e.id===h)||null))}).catch(t=>{e||D(t,s(`assets.loadFailed`,null,`加载资产失败`))}),()=>{e=!0}},[d,h,g,s]);let ke=e=>{if(e===t)return;let n=new URLSearchParams;e?.startsWith(`project:`)?n.set(`project_id`,e.slice(8)):e&&n.set(`scope`,e),i(n)},U=()=>{A.current+=1,k({keys:[],rows:[]})},Ae=e=>{v(t=>({...t,...e})),b(1),U()},Me=()=>{v(Ne()),b(1),U()},K=()=>{U(),we(),Ee()},q=e=>{let t=new URLSearchParams(r);e?t.set(`id`,e):t.delete(`id`),i(t,{replace:!0})},Le=e=>{H.current=e.id,M(e),e?.id&&q(e.id)},J=()=>{M(null),h&&(H.current=``,q(``))},Re=e=>{fe(e||null),ue(!0),f&&Ee()},Y=async()=>{U(),await we()},X=async e=>{await T.del(`/assets/${encodeURIComponent(e.id)}`),j(s(`assets.deleted`,null,`资产已删除`)),oe?.id===e.id&&J(),await Y()},ze=()=>{let e=O.keys;e.length&&se({title:s(`assets.deleteConfirm`,null,`确定删除所选资产吗?`),content:s(`assets.scopedDeleteConfirm`,{count:e.length,project:O.rows[0]?.project_name||O.rows[0]?.project_id||s(`assets.scopeUnassigned`,null,`未归属项目`)},`将永久删除所选的 ${e.length} 个资产。`),okText:s(`common.delete`,null,`删除`),onOk:async()=>{try{let t=await T.post(`/assets/batch-delete`,{asset_ids:e});j(`已删除 ${Number(t?.deleted||e.length)} 个资产`),await Y()}catch(e){D(e,`批量删除失败`)}}})},Be=(0,W.useMemo)(()=>{let{page:e,page_size:t,...n}=P;return n},[P]),Ve=async()=>{let e=++A.current;try{let t=await T.get(`/assets/selection`,Be);if(e!==A.current)return;let n=Array.isArray(t?.assets)?t.assets:[];k({keys:n.map(e=>e.id),rows:n}),j(s(`assets.allResultsSelected`,{count:n.length},`已选择 ${n.length} 项`))}catch(t){e===A.current&&D(t,`选择全部结果失败`)}},He=async e=>{if(!xe){Se(!0);try{let t=O.rows;if(e){let e=await T.get(`/assets/selection`,Be);t=Array.isArray(e?.assets)?e.assets:[]}else t.length||(t=De);if(!t.length){te(`没有可导出的资产`);return}Ke(`assets-${new Date().toISOString().slice(0,10)}.csv`,Ge(t)),j(`已导出 ${t.length} 个资产`)}catch(e){D(e,`导出失败`)}finally{Se(!1)}}},Ue=(e,t)=>{A.current+=1,k({keys:e||[],rows:t||[]})},Z=O.keys.length,We=new Set(O.rows.map(e=>e.project_id||``)).size>1,Q=Z>0&&!B&&!We;return d?(0,G.jsxs)(`div`,{className:`asset-library-page`,children:[(0,G.jsx)(ae,{title:s(`assets.libraryTitle`,null,`资产库`),extra:(0,G.jsxs)(l,{children:[(0,G.jsx)(u,{icon:(0,G.jsx)(x,{}),onClick:K,loading:I,children:s(`common.refresh`,null,`刷新`)}),f&&(0,G.jsx)(u,{icon:(0,G.jsx)(o,{}),onClick:()=>me(!0),children:s(`assets.bulkImport`,null,`批量导入`)}),f&&(0,G.jsx)(u,{theme:`solid`,type:`primary`,icon:(0,G.jsx)(m,{}),onClick:()=>Re(null),children:s(`assets.addAsset`,null,`新增资产`)})]})}),(0,G.jsxs)(re,{title:s(`assets.filterTitle`,null,`筛选条件`),children:[(0,G.jsx)(Pe,{scope:{value:t,options:V,loading:Te,onChange:ke},filters:_,onChange:Ae,onReset:Me}),(0,G.jsx)(ne,{error:R,onRetry:Ee})]}),(0,G.jsx)(ne,{error:Ce,onRetry:K}),(0,G.jsxs)(re,{title:`${Oe}(${z})`,extra:(0,G.jsxs)(l,{children:[(0,G.jsx)(u,{theme:`borderless`,disabled:!Z,onClick:U,children:s(`assets.clearSelection`,null,`清除选择`)}),(0,G.jsx)(u,{theme:`borderless`,disabled:B||!z,onClick:()=>He(!1),loading:xe,children:s(`assets.exportCsv`,null,`导出 CSV`)}),(0,G.jsx)(u,{theme:`borderless`,disabled:B||!z,onClick:()=>He(!0),loading:xe,children:s(`assets.exportAll`,null,`导出全部筛选结果`)})]}),children:[(0,G.jsxs)(`div`,{className:`asset-library-toolbar`,children:[(0,G.jsxs)(l,{children:[(0,G.jsx)(it,{type:`tertiary`,children:Z?s(`assets.selectedCount`,{count:Z},`已选择 ${Z} 项`):s(`assets.selectedCount`,{count:0},`已选择 0 项`)}),(0,G.jsx)(u,{theme:`borderless`,size:`small`,disabled:B||!z,onClick:Ve,children:s(`assets.selectAllResults`,{count:z},`选择全部 ${z} 项`)})]}),(0,G.jsxs)(l,{children:[f&&(0,G.jsx)(u,{size:`small`,disabled:!Q||Z<2||!p,onClick:()=>ge(!0),children:s(`assets.mergeDuplicates`,null,`合并重复资产`)}),f&&(0,G.jsx)(u,{size:`small`,disabled:!Q,onClick:()=>ve(!0),children:s(`assets.bindProject`,null,`绑定项目`)}),f&&(0,G.jsx)(u,{size:`small`,disabled:!Q,onClick:()=>be(!0),children:s(`assets.bulkEdit`,null,`批量编辑`)}),p&&(0,G.jsx)(u,{size:`small`,type:`danger`,disabled:!Q,onClick:ze,children:s(`assets.batchDelete`,null,`批量删除…`)})]})]}),We&&(f||p)&&(0,G.jsx)(it,{type:`tertiary`,size:`small`,children:s(`assets.mixedProjectSelection`,null,`批量修改前,请将选择缩小到同一项目或仅选择未归属资产。`)}),(0,G.jsx)(Fe,{assets:B||Ce?[]:De,loading:B,total:z,page:y,pageSize:S,onPageChange:e=>{b(e),U()},onPageSizeChange:e=>{C(e),b(1),U()},selectedRowKeys:O.keys,onSelectionChange:Ue,onView:Le,onEdit:Re,onDelete:X,onRefresh:K,canWrite:f,canDelete:p})]}),(0,G.jsx)(Ie,{asset:oe,visible:!!oe,onClose:J,onEdit:e=>{J(),Re(e)},onDelete:e=>{se({title:s(`assets.deleteConfirm`,null,`确定删除该资产吗?`),content:e.host||e.domain||e.ip,okText:s(`common.delete`,null,`删除`),onOk:()=>X(e).catch(e=>D(e,s(`assets.deleteFailed`,null,`删除资产失败`)))})},canWrite:f,canDelete:p}),(0,G.jsx)(je,{visible:le,asset:de,defaultProjectId:e,projects:L,onClose:()=>ue(!1),onSaved:Y}),(0,G.jsx)(Je,{visible:pe,defaultProjectId:t===`all`?void 0:e,projects:L,onClose:()=>me(!1),onDone:Y}),(0,G.jsx)(Xe,{visible:he,assets:O.rows,onClose:()=>ge(!1),onDone:Y}),(0,G.jsx)(Qe,{visible:_e,projects:L,assetIds:O.keys,onClose:()=>ve(!1),onDone:Y}),(0,G.jsx)(tt,{visible:ye,assetIds:O.keys,onClose:()=>be(!1),onDone:Y})]}):(0,G.jsxs)(`div`,{className:`asset-library-page`,children:[(0,G.jsx)(ae,{title:s(`assets.libraryTitle`,null,`资产库`),description:`资产列表、批量操作与导入需要资产读取权限。`}),(0,G.jsx)(a,{type:`warning`,bordered:!0,closeIcon:null,description:s(`assets.readDenied`,null,`当前账号没有 asset:read 权限,无法读取资产库;请联系管理员授权。`)})]})}export{at as buildAssetQuery,ot as default};
\ No newline at end of file
diff --git a/web/static/app/assets/asset-overview-ClxkP_Uu.js b/web/static/app/assets/asset-overview-BcLhuN5N.js
similarity index 98%
rename from web/static/app/assets/asset-overview-ClxkP_Uu.js
rename to web/static/app/assets/asset-overview-BcLhuN5N.js
index 57a5facf..cd1d0026 100644
--- a/web/static/app/assets/asset-overview-ClxkP_Uu.js
+++ b/web/static/app/assets/asset-overview-BcLhuN5N.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{B as i,E as a,G as o,I as s,R as c,g as l,h as u,lt as d,tn as f,ut as p}from"./semi-65W_4I1v.js";import{A as m,D as h,F as g,I as _,L as v,_ as y,a as b,l as x,m as S,p as C,s as w}from"./index-DNMXun-U.js";import{a as T,n as E,r as D}from"./AssetBits-DtqSAj0f.js";import{r as O}from"./assetTarget-D2PEjBAg.js";var k=e(t(),1),A=e(r(),1),{Text:j}=o,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=g(),t=n(),{hasPermission:r,hasAnyPermission:o}=_(),P=r(`asset:read`),F=o([`asset:read`,`fofa:execute`]),[I,L]=(0,k.useState)(30),R=b(()=>v.get(`/assets/stats`,{days:I}),[I],{skip:!P}),z=b(()=>v.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:h(B.total||0),detail:e(`assets.totalAssetsHint`,null,`当前纳入持续监测的资产`),loading:R.loading},{id:`ips`,label:e(`assets.ipCount`,null,`IP 数量`),value:h(B.ips||0),loading:R.loading},{id:`domains`,label:e(`assets.domainCount`,null,`域名数量`),value:h(B.domains||0),loading:R.loading},{id:`ports`,label:e(`assets.portCount`,null,`端口数量`),value:h(B.ports||0),loading:R.loading},{id:`protocols`,label:e(`assets.serviceTypes`,null,`服务类型`),value:h(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:h(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=new URLSearchParams({id:e.id});e.project_id?n.set(`project_id`,e.project_id):n.set(`scope`,`unassigned`),t(`/asset-library?${n}`)},q=[{title:e(`assets.target`,null,`目标`),dataIndex:`host`,render:(e,t)=>(0,A.jsxs)(`div`,{className:`asset-overview-target`,children:[(0,A.jsx)(T,{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)(E,{protocol:t.protocol,port:t.port})},{title:e(`assets.source`,null,`来源`),dataIndex:`source`,width:120,render:e=>(0,A.jsx)(T,{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:m(t,e)})},{title:e(`common.actions`,null,`操作`),dataIndex:`id`,width:100,render:(t,n)=>(0,A.jsx)(c,{theme:`borderless`,size:`small`,onClick:()=>K(n),children:e(`common.view`,null,`查看`)})}],J=[{label:e(`assets.scannedAssets`,null,`已扫描资产`),value:h(V.scanned||0)},{label:e(`assets.recentlyScanned`,null,`近 30 天覆盖`),value:h(V.scanned_30d||0)},{label:e(`assets.neverScanned`,null,`从未扫描`),value:h(V.never_scanned||0)},{label:e(`assets.staleScans`,null,`超过 30 天未扫描`),value:h(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)(s,{children:[(0,A.jsx)(u,{type:`button`,value:I,options:M,onChange:e=>L(Number(e.target.value)||30)}),(0,A.jsx)(c,{icon:(0,A.jsx)(p,{}),onClick:()=>{R.reload(),z.reload()},children:e(`common.refresh`,null,`刷新`)}),(0,A.jsx)(c,{icon:(0,A.jsx)(f,{}),onClick:()=>t(`/asset-library`),children:e(`assets.viewLibrary`,null,`查看资产库`)}),F&&(0,A.jsx)(c,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(d,{}),onClick:()=>t(`/info-collect`),children:e(`nav.infoCollect`,null,`信息收集`)})]})}),!P&&(0,A.jsx)(i,{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)(y,{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)(a,{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:[h(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))})]})}),(0,A.jsx)(S,{className:`asset-overview-card`,title:`观察覆盖`,description:`有成功回执的测评观察,或带成功工具回执的已确认项目事实。同一资产只计一次,不替代上面的扫描覆盖。`,extra:(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:`${B.observation?.observed||0} / ${B.observation?.total||B.total||0}`}),children:(0,A.jsxs)(`div`,{className:`asset-overview-coverage`,children:[(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:`已有观察证据`}),(0,A.jsx)(l,{percent:Number(B.observation?.rate||0),format:e=>`${e}%`})]})})]}),P&&(0,A.jsxs)(S,{title:e(`assets.recentAssets`,null,`最近资产`),description:`按最近发现时间排列的前 10 条资产。`,extra:(0,A.jsx)(c,{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{B as i,E as a,G as o,I as s,R as c,g as l,h as u,lt as d,tn as f,ut as p}from"./semi-65W_4I1v.js";import{A as m,D as h,F as g,I as _,L as v,_ as y,a as b,l as x,m as S,p as C,s as w}from"./index-C6SML8F9.js";import{a as T,n as E,r as D}from"./AssetBits-DtqSAj0f.js";import{r as O}from"./assetTarget-D2PEjBAg.js";var k=e(t(),1),A=e(r(),1),{Text:j}=o,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=g(),t=n(),{hasPermission:r,hasAnyPermission:o}=_(),P=r(`asset:read`),F=o([`asset:read`,`fofa:execute`]),[I,L]=(0,k.useState)(30),R=b(()=>v.get(`/assets/stats`,{days:I}),[I],{skip:!P}),z=b(()=>v.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:h(B.total||0),detail:e(`assets.totalAssetsHint`,null,`当前纳入持续监测的资产`),loading:R.loading},{id:`ips`,label:e(`assets.ipCount`,null,`IP 数量`),value:h(B.ips||0),loading:R.loading},{id:`domains`,label:e(`assets.domainCount`,null,`域名数量`),value:h(B.domains||0),loading:R.loading},{id:`ports`,label:e(`assets.portCount`,null,`端口数量`),value:h(B.ports||0),loading:R.loading},{id:`protocols`,label:e(`assets.serviceTypes`,null,`服务类型`),value:h(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:h(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=new URLSearchParams({id:e.id});e.project_id?n.set(`project_id`,e.project_id):n.set(`scope`,`unassigned`),t(`/asset-library?${n}`)},q=[{title:e(`assets.target`,null,`目标`),dataIndex:`host`,render:(e,t)=>(0,A.jsxs)(`div`,{className:`asset-overview-target`,children:[(0,A.jsx)(T,{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)(E,{protocol:t.protocol,port:t.port})},{title:e(`assets.source`,null,`来源`),dataIndex:`source`,width:120,render:e=>(0,A.jsx)(T,{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:m(t,e)})},{title:e(`common.actions`,null,`操作`),dataIndex:`id`,width:100,render:(t,n)=>(0,A.jsx)(c,{theme:`borderless`,size:`small`,onClick:()=>K(n),children:e(`common.view`,null,`查看`)})}],J=[{label:e(`assets.scannedAssets`,null,`已扫描资产`),value:h(V.scanned||0)},{label:e(`assets.recentlyScanned`,null,`近 30 天覆盖`),value:h(V.scanned_30d||0)},{label:e(`assets.neverScanned`,null,`从未扫描`),value:h(V.never_scanned||0)},{label:e(`assets.staleScans`,null,`超过 30 天未扫描`),value:h(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)(s,{children:[(0,A.jsx)(u,{type:`button`,value:I,options:M,onChange:e=>L(Number(e.target.value)||30)}),(0,A.jsx)(c,{icon:(0,A.jsx)(p,{}),onClick:()=>{R.reload(),z.reload()},children:e(`common.refresh`,null,`刷新`)}),(0,A.jsx)(c,{icon:(0,A.jsx)(f,{}),onClick:()=>t(`/asset-library`),children:e(`assets.viewLibrary`,null,`查看资产库`)}),F&&(0,A.jsx)(c,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(d,{}),onClick:()=>t(`/info-collect`),children:e(`nav.infoCollect`,null,`信息收集`)})]})}),!P&&(0,A.jsx)(i,{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)(y,{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)(a,{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:[h(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))})]})}),(0,A.jsx)(S,{className:`asset-overview-card`,title:`观察覆盖`,description:`有成功回执的测评观察,或带成功工具回执的已确认项目事实。同一资产只计一次,不替代上面的扫描覆盖。`,extra:(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:`${B.observation?.observed||0} / ${B.observation?.total||B.total||0}`}),children:(0,A.jsxs)(`div`,{className:`asset-overview-coverage`,children:[(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:`已有观察证据`}),(0,A.jsx)(l,{percent:Number(B.observation?.rate||0),format:e=>`${e}%`})]})})]}),P&&(0,A.jsxs)(S,{title:e(`assets.recentAssets`,null,`最近资产`),description:`按最近发现时间排列的前 10 条资产。`,extra:(0,A.jsx)(c,{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-Cdd7cKs8.js b/web/static/app/assets/c2-events-DoDJNoh7.js
similarity index 95%
rename from web/static/app/assets/c2-events-Cdd7cKs8.js
rename to web/static/app/assets/c2-events-DoDJNoh7.js
index b7396a2c..512013e4 100644
--- a/web/static/app/assets/c2-events-Cdd7cKs8.js
+++ b/web/static/app/assets/c2-events-DoDJNoh7.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{G as r,I as i,N as a,R as o,U as s,p as c,ut as ee,y as l}from"./semi-65W_4I1v.js";import{E as te,F as ne,I as u,_ as d,a as f,b as p,l as m,m as h,p as re,r as g,s as ie,u as ae,x as _,y as v}from"./index-DNMXun-U.js";import{c as oe,v as y}from"./c2-shared-2EAlkwn6.js";import{g as b,m as x,n as S,p as C,r as w,t as T}from"./c2-shared-BrRxH-6B.js";var E=e(t(),1),D=e(n(),1),{Text:O}=r;function k(){let e=ne(),{hasPermission:t}=u(),n=t(`c2:delete`)||t(`c2:write`),[r,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:r,page_size:A,level:j||void 0,category:N||void 0,session_id:z||void 0,since:b(F)||void 0}),[r,A,j,N,z,F]),{data:K,loading:q,error:ce,reload:J}=f(()=>y(G),[G]),Y=Array.isArray(K?.events)?K.events:[],X=Number(K?.total??Y.length),Z=K?.level_counts||{};g(()=>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=>{v({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 oe(t);_(e(`c2.events.toastDeleted`,null,`已删除`).replace(`{{n}}`,String(n?.deleted??t.length))),H(e=>e.filter(e=>!t.includes(e))),J()}catch(e){p(e)}}})},de=[{title:e(`c2.events.level`,null,`级别`),dataIndex:`level`,width:90,render:t=>(0,D.jsx)(a,{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,r)=>(0,D.jsxs)(i,{spacing:4,children:[(0,D.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>W(r),children:e(`c2.events.view`,null,`查看`)}),(0,D.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!n,onClick:()=>$([r.id]),children:e(`c2.events.deleteOne`,null,`删除`)})]})}];return(0,D.jsxs)(`div`,{className:`c2-page`,id:`page-c2-events`,children:[(0,D.jsx)(re,{title:e(`c2.events.title`,null,`事件审计`),description:e(`c2.events.pageDesc`,null,`监听器、会话、任务与 OPSEC 事件留痕,5 秒自动刷新`),extra:[(0,D.jsx)(o,{icon:(0,D.jsx)(ee,{}),onClick:()=>J(),loading:q,children:e(`c2.events.refresh`,null,`刷新`)},`refresh`),(0,D.jsx)(o,{type:`danger`,disabled:!n||!V.length,onClick:()=>$(V),children:e(`c2.events.batchDelete`,null,`批量删除`)},`delete`)]}),(0,D.jsx)(d,{metrics:ue,columns:4}),(0,D.jsx)(m,{error:ce,onRetry:()=>J()}),(0,D.jsx)(h,{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)(l,{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)(l,{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)(s,{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)(o,{theme:`solid`,type:`primary`,onClick:Q,children:e(`c2.events.applyFilters`,null,`应用筛选`)}),(0,D.jsx)(o,{onClick:le,children:e(`c2.events.resetFilters`,null,`重置`)})]})]})}),(0,D.jsx)(h,{title:e(`c2.events.listTitle`,null,`事件列表`),children:(0,D.jsx)(ie,{columns:de,dataSource:Y,rowKey:`id`,loading:q,onRefresh:()=>J(),rowSelection:{selectedRowKeys:V,onChange:e=>H(e)},pagination:{currentPage:r,pageSize:A,total:X,onPageChange:e=>k(e),onPageSizeChange:e=>{se(e),k(1)}},emptyText:e(`c2.events.empty`,null,`暂无事件`)})}),(0,D.jsx)(c,{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)(a,{size:`small`,color:S[U.level]||`grey`,children:U.level}),(0,D.jsx)(a,{size:`small`,children:U.category}),(0,D.jsx)(O,{type:`tertiary`,size:`small`,children:te(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)(ae,{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{G as r,I as i,N as a,R as o,U as s,p as c,ut as ee,y as l}from"./semi-65W_4I1v.js";import{E as te,F as ne,I as u,_ as d,a as f,b as p,l as m,m as h,p as re,r as g,s as ie,u as ae,x as _,y as v}from"./index-C6SML8F9.js";import{c as oe,v as y}from"./c2-shared-u6LJyEH4.js";import{g as b,m as x,n as S,p as C,r as w,t as T}from"./c2-shared-GD1-MSK1.js";var E=e(t(),1),D=e(n(),1),{Text:O}=r;function k(){let e=ne(),{hasPermission:t}=u(),n=t(`c2:delete`)||t(`c2:write`),[r,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:r,page_size:A,level:j||void 0,category:N||void 0,session_id:z||void 0,since:b(F)||void 0}),[r,A,j,N,z,F]),{data:K,loading:q,error:ce,reload:J}=f(()=>y(G),[G]),Y=Array.isArray(K?.events)?K.events:[],X=Number(K?.total??Y.length),Z=K?.level_counts||{};g(()=>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=>{v({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 oe(t);_(e(`c2.events.toastDeleted`,null,`已删除`).replace(`{{n}}`,String(n?.deleted??t.length))),H(e=>e.filter(e=>!t.includes(e))),J()}catch(e){p(e)}}})},de=[{title:e(`c2.events.level`,null,`级别`),dataIndex:`level`,width:90,render:t=>(0,D.jsx)(a,{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,r)=>(0,D.jsxs)(i,{spacing:4,children:[(0,D.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>W(r),children:e(`c2.events.view`,null,`查看`)}),(0,D.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!n,onClick:()=>$([r.id]),children:e(`c2.events.deleteOne`,null,`删除`)})]})}];return(0,D.jsxs)(`div`,{className:`c2-page`,id:`page-c2-events`,children:[(0,D.jsx)(re,{title:e(`c2.events.title`,null,`事件审计`),description:e(`c2.events.pageDesc`,null,`监听器、会话、任务与 OPSEC 事件留痕,5 秒自动刷新`),extra:[(0,D.jsx)(o,{icon:(0,D.jsx)(ee,{}),onClick:()=>J(),loading:q,children:e(`c2.events.refresh`,null,`刷新`)},`refresh`),(0,D.jsx)(o,{type:`danger`,disabled:!n||!V.length,onClick:()=>$(V),children:e(`c2.events.batchDelete`,null,`批量删除`)},`delete`)]}),(0,D.jsx)(d,{metrics:ue,columns:4}),(0,D.jsx)(m,{error:ce,onRetry:()=>J()}),(0,D.jsx)(h,{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)(l,{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)(l,{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)(s,{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)(o,{theme:`solid`,type:`primary`,onClick:Q,children:e(`c2.events.applyFilters`,null,`应用筛选`)}),(0,D.jsx)(o,{onClick:le,children:e(`c2.events.resetFilters`,null,`重置`)})]})]})}),(0,D.jsx)(h,{title:e(`c2.events.listTitle`,null,`事件列表`),children:(0,D.jsx)(ie,{columns:de,dataSource:Y,rowKey:`id`,loading:q,onRefresh:()=>J(),rowSelection:{selectedRowKeys:V,onChange:e=>H(e)},pagination:{currentPage:r,pageSize:A,total:X,onPageChange:e=>k(e),onPageSizeChange:e=>{se(e),k(1)}},emptyText:e(`c2.events.empty`,null,`暂无事件`)})}),(0,D.jsx)(c,{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)(a,{size:`small`,color:S[U.level]||`grey`,children:U.level}),(0,D.jsx)(a,{size:`small`,children:U.category}),(0,D.jsx)(O,{type:`tertiary`,size:`small`,children:te(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)(ae,{value:U.data})]})]})})]})}export{k as default};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-listeners-7rFR5Rx6.js b/web/static/app/assets/c2-listeners-CBuexYp6.js
similarity index 97%
rename from web/static/app/assets/c2-listeners-7rFR5Rx6.js
rename to web/static/app/assets/c2-listeners-CBuexYp6.js
index 268cfb7a..a0a6d523 100644
--- a/web/static/app/assets/c2-listeners-7rFR5Rx6.js
+++ b/web/static/app/assets/c2-listeners-CBuexYp6.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{G as r,I as i,N as a,R as o,ft as s,i as c,ut as l}from"./semi-65W_4I1v.js";import{E as u,F as d,I as f,_ as p,a as m,b as h,c as g,l as _,m as v,o as y,p as b,s as x,x as S,y as C}from"./index-DNMXun-U.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-2EAlkwn6.js";import{a as M,i as N,o as P}from"./c2-shared-BrRxH-6B.js";import{t as F}from"./project-options-CMQbwv_U.js";var I=e(t(),1),L=e(n(),1),{Text:R}=r;function z(e){if(!e?.configJson)return{};try{return JSON.parse(e.configJson)||{}}catch{return{}}}function B(e){let t=z(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 V({visible:e,record:t,projects:n,profiles:r,submitting:a,onCancel:s,onSubmit:l}){let u=d(),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(t?.type||`http_beacon`);return(0,L.jsx)(g,{visible:e,title:t?u(`c2.listeners.editTitle`,null,`编辑监听器`):u(`c2.listeners.modalCreateTitle`,null,`创建监听器`),footer:(0,L.jsxs)(i,{children:[(0,L.jsx)(o,{onClick:s,children:u(`c2.common.cancel`,null,`取消`)}),(0,L.jsx)(o,{theme:`solid`,type:`primary`,loading:a,onClick:()=>f?.submitForm(),children:t?u(`c2.listeners.save`,null,`保存`):u(`c2.listeners.submitCreate`,null,`创建`)})]}),width:620,onCancel:s,children:(0,L.jsxs)(c,{initValues:B(t),onSubmit:e=>{let t=Number(e.bind_port);l({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:p,labelPosition:`top`,onValueChange:e=>{e.type&&h(e.type)},children:[(0,L.jsxs)(`div`,{className:`c2-form-row`,children:[(0,L.jsx)(c.Input,{field:`name`,label:u(`c2.listeners.name`,null,`名称`),placeholder:u(`c2.listeners.placeholderNameExample`,null,`例如 http-beacon-01`),rules:[{required:!0,message:u(`c2.listeners.nameRequired`,null,`请输入监听器名称`)}]}),(0,L.jsx)(c.Select,{field:`type`,label:u(`c2.listeners.type`,null,`类型`),optionList:P,disabled:!!t,style:{width:`100%`}})]}),(0,L.jsxs)(`div`,{className:`c2-form-row`,children:[(0,L.jsx)(c.Input,{field:`bind_host`,label:u(`c2.listeners.bindHost`,null,`绑定地址`),placeholder:`127.0.0.1`}),(0,L.jsx)(c.Input,{field:`bind_port`,label:u(`c2.listeners.bindPort`,null,`绑定端口`),placeholder:u(`c2.listeners.placeholderPort`,null,`输入端口号`),rules:[{required:!0,validator:(e,t)=>{let n=Number(t);return Number.isInteger(n)&&n>0&&n<=65535},message:u(`c2.listeners.portInvalid`,null,`端口必须为 1–65535 的整数`)}]})]}),(0,L.jsx)(R,{type:`tertiary`,size:`small`,children:u(`c2.listeners.bindHintExternal`,null,`使用 0.0.0.0 允许外部访问`)}),(0,L.jsxs)(`div`,{className:`c2-form-row`,children:[(0,L.jsx)(c.Input,{field:`callback_host`,label:u(`c2.listeners.callbackHost`,null,`回连地址(可选)`),placeholder:`公网 IP 或域名`}),(0,L.jsx)(c.Select,{field:`profile_id`,label:u(`c2.listeners.malleableProfile`,null,`Malleable Profile`),optionList:[{value:``,label:u(`c2.listeners.malleableProfileNone`,null,`不使用`)},...r.map(e=>({value:e.id,label:e.name||e.id}))],style:{width:`100%`}})]}),(0,L.jsxs)(`div`,{className:`c2-form-row`,children:[(0,L.jsx)(c.Select,{field:`project_id`,label:u(`c2.listeners.project`,null,`所属项目`),optionList:[{value:``,label:u(`c2.listeners.projectNone`,null,`不绑定项目`)},...F(n,u,{currentId:t?.project_id||``})],style:{width:`100%`}}),(0,L.jsx)(c.Input,{field:`remark`,label:u(`c2.listeners.remark`,null,`备注`),placeholder:u(`c2.listeners.placeholderRemarkLong`,null,`可选的备注说明`)})]}),(0,L.jsxs)(`div`,{className:`c2-form-row`,children:[(0,L.jsx)(c.Input,{field:`default_sleep`,label:`默认 Sleep(秒)`,placeholder:`5`}),(0,L.jsx)(c.Input,{field:`default_jitter`,label:`默认 Jitter(%)`,placeholder:`0`})]}),(0,L.jsxs)(`div`,{className:`c2-form-row`,children:[(0,L.jsx)(c.Input,{field:`max_concurrent_tasks`,label:`单会话并发任务上限(0 不限)`,placeholder:`0`}),m===`tcp_reverse`&&(0,L.jsx)(c.Switch,{field:`allow_legacy_shell`,label:u(`c2.listeners.allowLegacyShell`,null,`允许未加密经典反弹 Shell(内网实验)`)})]})]},t?.id||`new`)})}var{Text:H}=r,U=e=>P.find(t=>t.value===e)?.label||e||`—`;function W(){let e=d(),{hasPermission:t}=f(),n=t(`c2:write`),r=t(`c2:delete`)||n,[c,P]=(0,I.useState)({visible:!1,record:null}),[F,R]=(0,I.useState)(!1),[z,B]=(0,I.useState)(``),[W,G]=(0,I.useState)(null),{data:K,loading:q,error:J,reload:Y}=m(()=>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,I.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)=>{B(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){h(t,n===`start`?e(`c2.listeners.start`,null,`启动失败`):e(`c2.listeners.stop`,null,`停止失败`))}finally{B(``)}},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){h(e)}}})},ne=async t=>{R(!0);try{if(c.record?.id)await E(c.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){h(t,e(`c2.listeners.saveFailed`,null,`监听器保存失败`))}finally{R(!1)}},re=[{title:e(`c2.listeners.name`,null,`名称`),dataIndex:`name`,render:(e,t)=>(0,L.jsxs)(`div`,{className:`c2-listener-name`,children:[(0,L.jsx)(H,{strong:!0,children:e||t.id}),t.remark&&(0,L.jsx)(H,{type:`tertiary`,size:`small`,children:t.remark})]})},{title:e(`c2.listeners.type`,null,`类型`),dataIndex:`type`,width:140,render:U},{title:e(`c2.listeners.bindEndpoint`,null,`监听地址`),dataIndex:`bindPort`,width:200,render:(e,t)=>(0,L.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,L.jsx)(`span`,{className:`c2-mono`,children:t.callback_host}):(0,L.jsx)(H,{type:`tertiary`,children:`—`})}catch{return(0,L.jsx)(H,{type:`tertiary`,children:`—`})}}},{title:e(`c2.listeners.status`,null,`状态`),dataIndex:`status`,width:120,render:(e,t)=>(0,L.jsxs)(`div`,{className:`c2-listener-status`,children:[(0,L.jsx)(a,{size:`small`,color:N[e]||`grey`,children:M[e]||e||`—`}),t.lastError&&(0,L.jsx)(H,{type:`danger`,size:`small`,children:t.lastError})]})},{title:e(`c2.listeners.startedAtPrefix`,null,`启动于`),dataIndex:`startedAt`,width:180,render:e=>e?u(e):(0,L.jsx)(H,{type:`tertiary`,children:`—`})},{title:e(`c2.listeners.actions`,null,`操作`),dataIndex:`actions`,width:220,render:(t,a)=>{let s=a.status===`running`;return(0,L.jsxs)(i,{spacing:4,wrap:!0,children:[(0,L.jsx)(o,{size:`small`,theme:`borderless`,disabled:!n,loading:z===a.id,onClick:()=>ee(a,s?`stop`:`start`),children:s?e(`c2.listeners.stop`,null,`停止`):e(`c2.listeners.start`,null,`启动`)}),(0,L.jsx)(o,{size:`small`,theme:`borderless`,disabled:!n,onClick:()=>P({visible:!0,record:a}),children:e(`c2.listeners.edit`,null,`编辑`)}),(0,L.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!r,onClick:()=>te(a),children:e(`c2.listeners.delete`,null,`删除`)})]})}}];return(0,L.jsxs)(`div`,{className:`c2-page`,id:`page-c2-listeners`,children:[(0,L.jsx)(b,{title:e(`c2.listeners.title`,null,`监听器管理`),description:e(`c2.listeners.pageDesc`,null,`创建并启停 C2 监听器,启停状态即时同步到后端`),extra:[(0,L.jsx)(o,{icon:(0,L.jsx)(l,{}),onClick:Y,loading:q,children:e(`common.refresh`,null,`刷新`)},`refresh`),(0,L.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,L.jsx)(s,{}),disabled:!n,onClick:()=>P({visible:!0,record:null}),children:e(`c2.listeners.create`,null,`创建监听器`)},`create`)]}),(0,L.jsx)(p,{metrics:$,columns:4}),(0,L.jsx)(_,{error:J,onRetry:Y}),(0,L.jsx)(v,{title:e(`c2.listeners.title`,null,`监听器列表`),children:(0,L.jsx)(x,{columns:re,dataSource:X,rowKey:`id`,loading:q,onRefresh:Y,pagination:{pageSize:10},emptyText:e(`c2.listeners.emptyTitle`,null,`暂无监听器`)})}),(0,L.jsx)(V,{visible:c.visible,record:c.record,projects:Q,profiles:Z,submitting:F,onCancel:()=>P({visible:!1,record:null}),onSubmit:ne}),(0,L.jsxs)(g,{visible:!!W,title:e(`c2.listeners.implantTokenTitle`,null,`植入体 Token`),onCancel:()=>G(null),footer:(0,L.jsx)(o,{onClick:()=>G(null),children:e(`c2.listeners.close`,null,`关闭`)}),children:[(0,L.jsx)(H,{type:`tertiary`,children:e(`c2.listeners.implantTokenHint`,null,`该 Token 仅在此处显示一次,请立即保存;后续可通过重新创建监听器获取。`)}),(0,L.jsxs)(`div`,{className:`c2-listener-token`,children:[(0,L.jsx)(`span`,{className:`c2-mono`,children:W?.token}),(0,L.jsx)(y,{text:W?.token||``})]})]})]})}export{W 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{G as r,I as i,N as a,R as o,ft as s,i as c,ut as l}from"./semi-65W_4I1v.js";import{E as u,F as d,I as f,_ as p,a as m,b as h,c as g,l as _,m as v,o as y,p as b,s as x,x as S,y as C}from"./index-C6SML8F9.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-u6LJyEH4.js";import{a as M,i as N,o as P}from"./c2-shared-GD1-MSK1.js";import{t as F}from"./project-options-CMQbwv_U.js";var I=e(t(),1),L=e(n(),1),{Text:R}=r;function z(e){if(!e?.configJson)return{};try{return JSON.parse(e.configJson)||{}}catch{return{}}}function B(e){let t=z(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 V({visible:e,record:t,projects:n,profiles:r,submitting:a,onCancel:s,onSubmit:l}){let u=d(),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(t?.type||`http_beacon`);return(0,L.jsx)(g,{visible:e,title:t?u(`c2.listeners.editTitle`,null,`编辑监听器`):u(`c2.listeners.modalCreateTitle`,null,`创建监听器`),footer:(0,L.jsxs)(i,{children:[(0,L.jsx)(o,{onClick:s,children:u(`c2.common.cancel`,null,`取消`)}),(0,L.jsx)(o,{theme:`solid`,type:`primary`,loading:a,onClick:()=>f?.submitForm(),children:t?u(`c2.listeners.save`,null,`保存`):u(`c2.listeners.submitCreate`,null,`创建`)})]}),width:620,onCancel:s,children:(0,L.jsxs)(c,{initValues:B(t),onSubmit:e=>{let t=Number(e.bind_port);l({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:p,labelPosition:`top`,onValueChange:e=>{e.type&&h(e.type)},children:[(0,L.jsxs)(`div`,{className:`c2-form-row`,children:[(0,L.jsx)(c.Input,{field:`name`,label:u(`c2.listeners.name`,null,`名称`),placeholder:u(`c2.listeners.placeholderNameExample`,null,`例如 http-beacon-01`),rules:[{required:!0,message:u(`c2.listeners.nameRequired`,null,`请输入监听器名称`)}]}),(0,L.jsx)(c.Select,{field:`type`,label:u(`c2.listeners.type`,null,`类型`),optionList:P,disabled:!!t,style:{width:`100%`}})]}),(0,L.jsxs)(`div`,{className:`c2-form-row`,children:[(0,L.jsx)(c.Input,{field:`bind_host`,label:u(`c2.listeners.bindHost`,null,`绑定地址`),placeholder:`127.0.0.1`}),(0,L.jsx)(c.Input,{field:`bind_port`,label:u(`c2.listeners.bindPort`,null,`绑定端口`),placeholder:u(`c2.listeners.placeholderPort`,null,`输入端口号`),rules:[{required:!0,validator:(e,t)=>{let n=Number(t);return Number.isInteger(n)&&n>0&&n<=65535},message:u(`c2.listeners.portInvalid`,null,`端口必须为 1–65535 的整数`)}]})]}),(0,L.jsx)(R,{type:`tertiary`,size:`small`,children:u(`c2.listeners.bindHintExternal`,null,`使用 0.0.0.0 允许外部访问`)}),(0,L.jsxs)(`div`,{className:`c2-form-row`,children:[(0,L.jsx)(c.Input,{field:`callback_host`,label:u(`c2.listeners.callbackHost`,null,`回连地址(可选)`),placeholder:`公网 IP 或域名`}),(0,L.jsx)(c.Select,{field:`profile_id`,label:u(`c2.listeners.malleableProfile`,null,`Malleable Profile`),optionList:[{value:``,label:u(`c2.listeners.malleableProfileNone`,null,`不使用`)},...r.map(e=>({value:e.id,label:e.name||e.id}))],style:{width:`100%`}})]}),(0,L.jsxs)(`div`,{className:`c2-form-row`,children:[(0,L.jsx)(c.Select,{field:`project_id`,label:u(`c2.listeners.project`,null,`所属项目`),optionList:[{value:``,label:u(`c2.listeners.projectNone`,null,`不绑定项目`)},...F(n,u,{currentId:t?.project_id||``})],style:{width:`100%`}}),(0,L.jsx)(c.Input,{field:`remark`,label:u(`c2.listeners.remark`,null,`备注`),placeholder:u(`c2.listeners.placeholderRemarkLong`,null,`可选的备注说明`)})]}),(0,L.jsxs)(`div`,{className:`c2-form-row`,children:[(0,L.jsx)(c.Input,{field:`default_sleep`,label:`默认 Sleep(秒)`,placeholder:`5`}),(0,L.jsx)(c.Input,{field:`default_jitter`,label:`默认 Jitter(%)`,placeholder:`0`})]}),(0,L.jsxs)(`div`,{className:`c2-form-row`,children:[(0,L.jsx)(c.Input,{field:`max_concurrent_tasks`,label:`单会话并发任务上限(0 不限)`,placeholder:`0`}),m===`tcp_reverse`&&(0,L.jsx)(c.Switch,{field:`allow_legacy_shell`,label:u(`c2.listeners.allowLegacyShell`,null,`允许未加密经典反弹 Shell(内网实验)`)})]})]},t?.id||`new`)})}var{Text:H}=r,U=e=>P.find(t=>t.value===e)?.label||e||`—`;function W(){let e=d(),{hasPermission:t}=f(),n=t(`c2:write`),r=t(`c2:delete`)||n,[c,P]=(0,I.useState)({visible:!1,record:null}),[F,R]=(0,I.useState)(!1),[z,B]=(0,I.useState)(``),[W,G]=(0,I.useState)(null),{data:K,loading:q,error:J,reload:Y}=m(()=>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,I.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)=>{B(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){h(t,n===`start`?e(`c2.listeners.start`,null,`启动失败`):e(`c2.listeners.stop`,null,`停止失败`))}finally{B(``)}},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){h(e)}}})},ne=async t=>{R(!0);try{if(c.record?.id)await E(c.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){h(t,e(`c2.listeners.saveFailed`,null,`监听器保存失败`))}finally{R(!1)}},re=[{title:e(`c2.listeners.name`,null,`名称`),dataIndex:`name`,render:(e,t)=>(0,L.jsxs)(`div`,{className:`c2-listener-name`,children:[(0,L.jsx)(H,{strong:!0,children:e||t.id}),t.remark&&(0,L.jsx)(H,{type:`tertiary`,size:`small`,children:t.remark})]})},{title:e(`c2.listeners.type`,null,`类型`),dataIndex:`type`,width:140,render:U},{title:e(`c2.listeners.bindEndpoint`,null,`监听地址`),dataIndex:`bindPort`,width:200,render:(e,t)=>(0,L.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,L.jsx)(`span`,{className:`c2-mono`,children:t.callback_host}):(0,L.jsx)(H,{type:`tertiary`,children:`—`})}catch{return(0,L.jsx)(H,{type:`tertiary`,children:`—`})}}},{title:e(`c2.listeners.status`,null,`状态`),dataIndex:`status`,width:120,render:(e,t)=>(0,L.jsxs)(`div`,{className:`c2-listener-status`,children:[(0,L.jsx)(a,{size:`small`,color:N[e]||`grey`,children:M[e]||e||`—`}),t.lastError&&(0,L.jsx)(H,{type:`danger`,size:`small`,children:t.lastError})]})},{title:e(`c2.listeners.startedAtPrefix`,null,`启动于`),dataIndex:`startedAt`,width:180,render:e=>e?u(e):(0,L.jsx)(H,{type:`tertiary`,children:`—`})},{title:e(`c2.listeners.actions`,null,`操作`),dataIndex:`actions`,width:220,render:(t,a)=>{let s=a.status===`running`;return(0,L.jsxs)(i,{spacing:4,wrap:!0,children:[(0,L.jsx)(o,{size:`small`,theme:`borderless`,disabled:!n,loading:z===a.id,onClick:()=>ee(a,s?`stop`:`start`),children:s?e(`c2.listeners.stop`,null,`停止`):e(`c2.listeners.start`,null,`启动`)}),(0,L.jsx)(o,{size:`small`,theme:`borderless`,disabled:!n,onClick:()=>P({visible:!0,record:a}),children:e(`c2.listeners.edit`,null,`编辑`)}),(0,L.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!r,onClick:()=>te(a),children:e(`c2.listeners.delete`,null,`删除`)})]})}}];return(0,L.jsxs)(`div`,{className:`c2-page`,id:`page-c2-listeners`,children:[(0,L.jsx)(b,{title:e(`c2.listeners.title`,null,`监听器管理`),description:e(`c2.listeners.pageDesc`,null,`创建并启停 C2 监听器,启停状态即时同步到后端`),extra:[(0,L.jsx)(o,{icon:(0,L.jsx)(l,{}),onClick:Y,loading:q,children:e(`common.refresh`,null,`刷新`)},`refresh`),(0,L.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,L.jsx)(s,{}),disabled:!n,onClick:()=>P({visible:!0,record:null}),children:e(`c2.listeners.create`,null,`创建监听器`)},`create`)]}),(0,L.jsx)(p,{metrics:$,columns:4}),(0,L.jsx)(_,{error:J,onRetry:Y}),(0,L.jsx)(v,{title:e(`c2.listeners.title`,null,`监听器列表`),children:(0,L.jsx)(x,{columns:re,dataSource:X,rowKey:`id`,loading:q,onRefresh:Y,pagination:{pageSize:10},emptyText:e(`c2.listeners.emptyTitle`,null,`暂无监听器`)})}),(0,L.jsx)(V,{visible:c.visible,record:c.record,projects:Q,profiles:Z,submitting:F,onCancel:()=>P({visible:!1,record:null}),onSubmit:ne}),(0,L.jsxs)(g,{visible:!!W,title:e(`c2.listeners.implantTokenTitle`,null,`植入体 Token`),onCancel:()=>G(null),footer:(0,L.jsx)(o,{onClick:()=>G(null),children:e(`c2.listeners.close`,null,`关闭`)}),children:[(0,L.jsx)(H,{type:`tertiary`,children:e(`c2.listeners.implantTokenHint`,null,`该 Token 仅在此处显示一次,请立即保存;后续可通过重新创建监听器获取。`)}),(0,L.jsxs)(`div`,{className:`c2-listener-token`,children:[(0,L.jsx)(`span`,{className:`c2-mono`,children:W?.token}),(0,L.jsx)(y,{text:W?.token||``})]})]})]})}export{W as default};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-payloads-DP3Iw5IZ.js b/web/static/app/assets/c2-payloads-CeftlKeV.js
similarity index 97%
rename from web/static/app/assets/c2-payloads-DP3Iw5IZ.js
rename to web/static/app/assets/c2-payloads-CeftlKeV.js
index 32fd5836..673e83e6 100644
--- a/web/static/app/assets/c2-payloads-DP3Iw5IZ.js
+++ b/web/static/app/assets/c2-payloads-CeftlKeV.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{G as r,I as ee,N as i,R as a,U as o,y as s}from"./semi-65W_4I1v.js";import{F as c,I 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-DNMXun-U.js";import{m as b,n as x,t as S,y as C}from"./c2-shared-2EAlkwn6.js";import{o as w,s as T}from"./c2-shared-BrRxH-6B.js";var E=e(t(),1),D=e(n(),1),{Text:O,Title:k}=r,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=c(),{hasPermission:t}=l(),n=t(`c2:write`),{data:r,loading:w,error:N,reload:P}=f(()=>C(),[]),F=Array.isArray(r?.listeners)?r.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)(a,{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)(a,{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)(a,{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)(ee,{spacing:6,children:[(0,D.jsx)(i,{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)(a,{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)(a,{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{G as r,I as ee,N as i,R as a,U as o,y as s}from"./semi-65W_4I1v.js";import{F as c,I 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-C6SML8F9.js";import{m as b,n as x,t as S,y as C}from"./c2-shared-u6LJyEH4.js";import{o as w,s as T}from"./c2-shared-GD1-MSK1.js";var E=e(t(),1),D=e(n(),1),{Text:O,Title:k}=r,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=c(),{hasPermission:t}=l(),n=t(`c2:write`),{data:r,loading:w,error:N,reload:P}=f(()=>C(),[]),F=Array.isArray(r?.listeners)?r.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)(a,{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)(a,{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)(a,{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)(ee,{spacing:6,children:[(0,D.jsx)(i,{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)(a,{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)(a,{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-Cxv9lUnu.js b/web/static/app/assets/c2-profiles-B7r-ajzx.js
similarity index 98%
rename from web/static/app/assets/c2-profiles-Cxv9lUnu.js
rename to web/static/app/assets/c2-profiles-B7r-ajzx.js
index 60519496..4bd15003 100644
--- a/web/static/app/assets/c2-profiles-Cxv9lUnu.js
+++ b/web/static/app/assets/c2-profiles-B7r-ajzx.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{G as r,I as i,N as a,R as o,ft as s,i as c,ut as l}from"./semi-65W_4I1v.js";import{E as u,F as d,I as f,S as p,_ as m,a as h,b as g,c as _,l as v,m as y,p as b,s as x,u as S,x as C,y as w}from"./index-DNMXun-U.js";import{a as T,b as E,k as D,u as O}from"./c2-shared-2EAlkwn6.js";var k=e(t(),1),A=e(n(),1),{Text:j}=r;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{G as r,I as i,N as a,R as o,ft as s,i as c,ut as l}from"./semi-65W_4I1v.js";import{E as u,F as d,I as f,S as p,_ as m,a as h,b as g,c as _,l as v,m as y,p as b,s as x,u as S,x as C,y as w}from"./index-C6SML8F9.js";import{a as T,b as E,k as D,u as O}from"./c2-shared-u6LJyEH4.js";var k=e(t(),1),A=e(n(),1),{Text:j}=r;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 p(t(`c2.profiles.toastInvalidHeadersJson`,null,`响应头 JSON 无效`)),null}}function P({visible:e,record:t,submitting:n,onCancel:r,onSubmit:a}){let s=d(),[l,u]=(0,k.useState)(null);return(0,A.jsx)(_,{visible:e,title:t?s(`c2.profiles.editTitle`,null,`编辑 Profile`):s(`c2.profiles.modalCreateTitle`,null,`创建 Malleable Profile`),footer:(0,A.jsxs)(i,{children:[(0,A.jsx)(o,{onClick:r,children:s(`c2.common.cancel`,null,`取消`)}),(0,A.jsx)(o,{theme:`solid`,type:`primary`,loading:n,onClick:()=>l?.submitForm(),children:t?s(`c2.profiles.save`,null,`保存`):s(`c2.profiles.submitCreate`,null,`创建`)})]}),width:640,onCancel:r,children:(0,A.jsxs)(c,{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:u,labelPosition:`top`,children:[(0,A.jsx)(c.Input,{field:`name`,label:s(`c2.profiles.profileNameLabel`,null,`Profile 名称`),placeholder:s(`c2.profiles.placeholderProfileName`,null,`例如 cdn-fronting`),rules:[{required:!0,message:s(`c2.profiles.toastNameRequired`,null,`请填写 Profile 名称`)}]}),(0,A.jsx)(c.Input,{field:`user_agent`,label:s(`c2.profiles.userAgent`,null,`User-Agent`),placeholder:`Mozilla/5.0 ...`}),(0,A.jsx)(c.TextArea,{field:`uris`,label:s(`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)(c.Input,{field:`jitter_min`,label:s(`c2.profiles.labelJitterMin`,null,`Jitter 最小值 (ms)`),placeholder:`0`}),(0,A.jsx)(c.Input,{field:`jitter_max`,label:s(`c2.profiles.labelJitterMax`,null,`Jitter 最大值 (ms)`),placeholder:`0`})]}),(0,A.jsx)(c.TextArea,{field:`request_headers`,label:s(`c2.profiles.requestHeadersJson`,null,`自定义请求头 (JSON)`),placeholder:`{"X-Forwarded-For":"127.0.0.1"}`,autosize:{minRows:2,maxRows:6}}),(0,A.jsx)(c.TextArea,{field:`response_headers`,label:s(`c2.profiles.labelRespHeaders`,null,`自定义响应头 (JSON)`),placeholder:`{"Server":"nginx"}`,autosize:{minRows:2,maxRows:6}}),(0,A.jsx)(c.TextArea,{field:`body_template`,label:s(`c2.profiles.bodyTemplate`,null,`响应体模板`),placeholder:`{"status":"ok"}`,autosize:{minRows:2,maxRows:6}}),(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:s(`c2.profiles.hintHeaders`,null,`用于伪装为合法服务的 HTTP 响应头`)})]},t?.id||`new`)})}var{Text:F}=r;function I(){let e=d(),{hasPermission:t}=f(),n=t(`c2:write`),r=t(`c2:delete`)||n,[c,p]=(0,k.useState)({visible:!1,record:null}),[_,j]=(0,k.useState)(!1),[M,N]=(0,k.useState)(null),{data:I,loading:L,error:R,reload:z}=h(()=>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{c.record?.id?(await D(c.record.id,t),C(e(`c2.profiles.toastUpdated`,null,`Profile 已更新`))):(await T(t),C(e(`c2.profiles.toastCreated`,null,`Profile 已创建`))),p({visible:!1,record:null}),z()}catch(t){g(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){g(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)(i,{spacing:4,wrap:!0,children:e.slice(0,3).map(e=>(0,A.jsx)(a,{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=>u(e)},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:180,render:(t,a)=>(0,A.jsxs)(i,{spacing:4,children:[(0,A.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>N(a),children:e(`c2.profiles.view`,null,`查看`)}),(0,A.jsx)(o,{size:`small`,theme:`borderless`,disabled:!n,onClick:()=>p({visible:!0,record:a}),children:e(`c2.profiles.edit`,null,`编辑`)}),(0,A.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!r,onClick:()=>U(a),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)(o,{icon:(0,A.jsx)(l,{}),onClick:z,loading:L,children:e(`common.refresh`,null,`刷新`)},`refresh`),(0,A.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(s,{}),disabled:!n,onClick:()=>p({visible:!0,record:null}),children:e(`c2.profiles.createBtn`,null,`创建 Profile`)},`create`)]}),(0,A.jsx)(m,{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)(o,{size:`small`,onClick:()=>N(null),children:e(`c2.profiles.close`,null,`收起`)}),children:(0,A.jsx)(S,{value:M})}),(0,A.jsx)(P,{visible:c.visible,record:c.record,submitting:_,onCancel:()=>p({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-CnBIfRAo.js b/web/static/app/assets/c2-sessions-CQrw5arR.js
similarity index 98%
rename from web/static/app/assets/c2-sessions-CnBIfRAo.js
rename to web/static/app/assets/c2-sessions-CQrw5arR.js
index c8aa84e3..45cb9266 100644
--- a/web/static/app/assets/c2-sessions-CnBIfRAo.js
+++ b/web/static/app/assets/c2-sessions-CQrw5arR.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{E as i,G as a,I as o,N as s,P as c,R as l,S as u,U as d,W as f,c as p,ct as m,lt as h,ut as g,y as _}from"./semi-65W_4I1v.js";import{E as v,F as y,I as b,S as x,a as S,b as C,c 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-DNMXun-U.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-2EAlkwn6.js";import{c as ie,h as G,l as ae,m as oe,u as K}from"./c2-shared-BrRxH-6B.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=y(),[i,a]=(0,q.useState)([]),[c,u]=(0,q.useState)(``),[f,p]=(0,q.useState)(!1),[h,g]=(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 b=(0,q.useCallback)(e=>{a(t=>[...t,{id:ce(),...e}])},[]),S=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},w=async i=>{let a=String(i??c).trim();if(a){if(!t)x(r(`c2.sessions.writeRequired`,null,`当前账号没有下发任务的权限`));else{u(``),b({kind:`cmd`,text:a}),p(!0);try{let t=(await ne(e.id,{task_type:`shell`,payload:{command:a,timeout_seconds:60}}))?.task?.id;if(!t){b({kind:`err`,text:r(`c2.sessions.termNoSession`,null,`下发失败:未返回任务 ID`)});return}g(t),n?.();let i=await S(t);if(!i){b({kind:`warn`,text:r(`c2.sessions.termWaitTimeout`,null,`[等待结果超时]`)});return}i.resultText&&b({kind:i.status===`success`?`out`:`warn`,text:i.resultText}),i.error&&b({kind:`err`,text:i.error}),i.status===`cancelled`&&b({kind:`warn`,text:r(`c2.tasks.cancelled`,null,`已取消`)})}catch(e){b({kind:`err`,text:e?.message||r(`c2.sessions.termStatusErr`,null,`执行失败`)}),C(e)}finally{_.current&&(p(!1),g(``))}}}};return(0,J.jsxs)(`div`,{className:`c2-terminal`,children:[(0,J.jsx)(`div`,{className:`c2-terminal-bar`,children:(0,J.jsxs)(o,{spacing:8,children:[(0,J.jsx)(s,{size:`small`,color:f?`amber`:`green`,children:f?r(`c2.sessions.termStatusExec`,null,`执行中…`):r(`c2.sessions.termStatusReady`,null,`就绪`)}),(0,J.jsx)(l,{size:`small`,theme:`borderless`,onClick:()=>a([]),children:r(`c2.sessions.clearTerminal`,null,`清屏`)}),f&&h&&(0,J.jsx)(l,{size:`small`,theme:`borderless`,type:`danger`,onClick:async()=>{if(h)try{await H(h),b({kind:`warn`,text:r(`c2.tasks.toastCancelled`,null,`任务已取消`)})}catch(e){C(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)(d,{value:c,onChange:u,onEnterPress:()=>f?x(r(`c2.sessions.termWaitFinish`,null,`请等待当前命令执行完成`)):w(),placeholder:r(`c2.sessions.commandPlaceholder`,null,`输入命令后回车下发`),disabled:f||!t,prefix:`$`}),(0,J.jsx)(l,{theme:`solid`,type:`primary`,icon:(0,J.jsx)(m,{}),loading:f,disabled:!t,onClick:()=>w(),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}=a,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=y(),[r,i]=(0,q.useState)(`.`),[a,s]=(0,q.useState)(`.`),[c,u]=(0,q.useState)([]),[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(!1),[_,v]=(0,q.useState)(null),[b,S]=(0,q.useState)(``),w=(0,q.useRef)(!0);(0,q.useEffect)(()=>()=>{w.current=!1},[]);let T=(0,q.useCallback)(async t=>{let a=Y(t??r);h(!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(!w.current)return;if(!r){v(n(`c2.files.timeout`,null,`加载文件超时`));return}if(r.status!==`success`){v(r.error||n(`c2.files.failed`,null,`列目录失败`)),u([]),p(r.resultText||``);return}p(r.resultText||``),u(de(r.resultText||``)),i(a),s(a)}catch(e){w.current&&v(e)}finally{w.current&&h(!1)}},[e.id,r,n]);(0,q.useEffect)(()=>{i(`.`),s(`.`),u([]),T(`.`)},[e.id]);let D=async i=>{if(!t){x(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){C(e,n(`c2.files.failed`,null,`下载失败`))}},O=c.filter(e=>{let t=b.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)(l,{size:`small`,theme:`borderless`,onClick:()=>T(X(r,i.name)),children:n(`c2.files.open`,null,`打开`)}):(0,J.jsx)(l,{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)(o,{spacing:8,wrap:!0,children:[(0,J.jsx)(l,{size:`small`,onClick:()=>T(fe(r)),children:n(`c2.files.parent`,null,`上级目录`)}),(0,J.jsx)(l,{size:`small`,icon:(0,J.jsx)(g,{}),loading:m,onClick:()=>T(r),children:n(`c2.files.refresh`,null,`刷新`)}),(0,J.jsx)(d,{size:`small`,value:a,onChange:s,onEnterPress:()=>T(a),className:`c2-files-path`}),(0,J.jsx)(l,{size:`small`,onClick:()=>T(a),children:n(`c2.files.go`,null,`跳转`)}),(0,J.jsx)(d,{size:`small`,value:b,onChange:S,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)}),c.length===0&&f.trim()&&!m?(0,J.jsx)(`pre`,{className:`c2-pre`,children:f}):(0,J.jsx)(j,{columns:k,dataSource:O,rowKey:`name`,loading:m,pagination:{pageSize:20},emptyText:n(`c2.files.emptyDir`,null,`空目录`)})]})}function _e({session:e,canDelete:t,onChanged:n}){let r=y(),[i,a]=(0,q.useState)(null),{data:c,loading:u,error:d,reload:f}=S(()=>F({session_id:e.id,limit:100}),[e.id]),p=Array.isArray(c?.tasks)?c.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){C(e)}},h=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){C(e)}}})},g=[{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)(s,{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)(o,{spacing:4,wrap:!0,children:[(0,J.jsx)(l,{size:`small`,theme:`borderless`,onClick:()=>a(n),children:r(`c2.tasks.view`,null,`查看`)}),[`queued`,`sent`,`running`].includes(n.status)&&(0,J.jsx)(l,{size:`small`,theme:`borderless`,onClick:()=>m(n),children:r(`c2.tasks.cancelBtn`,null,`取消`)}),(0,J.jsx)(l,{size:`small`,theme:`borderless`,type:`danger`,disabled:!t,onClick:()=>h(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:g,dataSource:p,rowKey:`id`,loading:u,onRefresh:()=>f(),pagination:{pageSize:10},emptyText:r(`c2.tasks.emptySession`,null,`该会话暂无任务`)}),(0,J.jsx)(w,{visible:!!i,title:r(`c2.tasks.modalTitle`,null,`任务详情`),width:720,onCancel:()=>a(null),footer:(0,J.jsx)(l,{onClick:()=>a(null),children:r(`c2.tasks.close`,null,`关闭`)}),children:i&&(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:i.id}),(0,J.jsx)(s,{size:`small`,color:K[i.status]||`grey`,children:i.status}),(0,J.jsx)(`span`,{className:`c2-muted`,children:v(i.createdAt)})]}),i.payload&&(0,J.jsx)(M,{title:r(`c2.tasks.labelPayload`,null,`参数`),value:i.payload,collapsed:!0}),i.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:i.resultText})]}),i.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:i.error})]})]})})]})}var{Text:Z}=a;function ve({session:e,canWrite:t,onEditNote:n}){let r=y(),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:v(e.firstSeenAt)},{label:r(`c2.sessions.infoLastCheckin`,null,`上次心跳`),value:v(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)(o,{children:(0,J.jsx)(l,{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}=a;function ye({session:e,canWrite:t,canDelete:n,onChanged:r,onDeleted:i}){let a=y(),[c,f]=(0,q.useState)(`terminal`),[m,h]=(0,q.useState)(null),[_,v]=(0,q.useState)(null),[b,T]=(0,q.useState)(!1),{data:D,loading:O,error:k,reload:A}=S(()=>z(e.id),[e.id]),j=D?.session||e,M=()=>h({sleepSeconds:String(j.sleepSeconds||5),jitterPercent:String(j.jitterPercent||0)}),F=()=>v({note:j.note||``}),ee=async()=>{let e=Number(m.sleepSeconds),t=Number(m.jitterPercent);if(!Number.isFinite(e)||e<1)x(a(`c2.sessions.toastSleepInvalid`,null,`Sleep 间隔至少为 1 秒`));else if(!Number.isFinite(t)||t<0||t>100)x(a(`c2.sessions.toastSleepInvalid`,null,`抖动百分比需在 0–100 之间`));else{T(!0);try{await te(j.id,{sleepSeconds:e,jitterPercent:t}),N(a(`c2.sessions.toastSleepUpdated`,null,`Sleep 设置已更新`)),h(null),A({silent:!0}),r?.()}catch(e){C(e)}finally{T(!1)}}},I=async()=>{let e=String(_.note||``).trim();if(e.length>2e3)x(a(`c2.sessions.toastNoteTooLong`,null,`备注最多 2000 字`));else{T(!0);try{await W(j.id,e),N(a(`c2.sessions.toastNoteSaved`,null,`备注已保存`)),v(null),A({silent:!0}),r?.()}catch(e){C(e)}finally{T(!1)}}},R=()=>{P({title:a(`c2.sessions.cardDeleteSession`,null,`删除会话`),content:a(`c2.sessions.confirmDeleteSession`,null,`从服务器删除此会话及其关联任务与文件记录?`),onOk:async()=>{try{await L(j.id),N(a(`c2.sessions.toastSessionDeleted`,null,`会话记录已删除`)),i?.()}catch(e){C(e)}}})},B=[{tab:a(`c2.sessions.terminal`,null,`终端`),itemKey:`terminal`,children:(0,J.jsx)(ue,{session:j,canWrite:t,onTaskCreated:A})},{tab:a(`c2.sessions.files`,null,`文件`),itemKey:`files`,children:(0,J.jsx)(ge,{session:j,canWrite:t})},{tab:a(`c2.sessions.tasks`,null,`任务`),itemKey:`tasks`,children:(0,J.jsx)(_e,{session:j,canDelete:n,onChanged:A})},{tab:a(`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||a(`c2.sessions.unknownHost`,null,`未知主机`)}),(0,J.jsxs)(o,{spacing:6,wrap:!0,children:[(0,J.jsx)(s,{size:`small`,color:ie[j.status]||`grey`,children:a(`c2.sessions.${j.status||`active`}`,null,j.status||`—`)}),(0,J.jsxs)(s,{size:`small`,children:[j.os||`—`,`/`,j.arch||`—`]}),j.isAdmin&&(0,J.jsx)(s,{size:`small`,color:`red`,children:a(`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)(o,{spacing:6,wrap:!0,children:[(0,J.jsx)(l,{size:`small`,icon:(0,J.jsx)(g,{}),loading:O,onClick:()=>A(),children:a(`common.refresh`,null,`刷新`)}),(0,J.jsx)(l,{size:`small`,disabled:!t,onClick:M,children:a(`c2.sessions.btnSleep`,null,`Sleep`)}),(0,J.jsx)(l,{size:`small`,disabled:!t,onClick:F,children:a(`c2.sessions.noteEdit`,null,`备注`)}),(0,J.jsx)(l,{size:`small`,type:`danger`,disabled:!n,onClick:R,children:a(`c2.sessions.cardDeleteSession`,null,`删除会话`)})]})]}),(0,J.jsx)(E,{error:k,onRetry:A}),(0,J.jsx)(p,{type:`button`,activeKey:c,onChange:f,items:B}),(0,J.jsxs)(w,{visible:!!m,title:a(`c2.sessions.sleepModalTitle`,null,`心跳配置`),width:440,onCancel:()=>h(null),onOk:ee,confirmLoading:b,children:[(0,J.jsx)(Q,{type:`tertiary`,size:`small`,children:a(`c2.sessions.sleepModalHint`,null,`保存后将写入服务端并下发 sleep 任务。`)}),(0,J.jsxs)(`div`,{className:`c2-session-modal-field`,children:[(0,J.jsx)(Q,{size:`small`,children:a(`c2.sessions.promptSleepSeconds`,null,`Sleep 间隔(秒)`)}),(0,J.jsx)(d,{value:m?.sleepSeconds||``,onChange:e=>h(t=>({...t,sleepSeconds:e}))})]}),(0,J.jsxs)(`div`,{className:`c2-session-modal-field`,children:[(0,J.jsx)(Q,{size:`small`,children:a(`c2.sessions.promptJitterPercent`,null,`抖动百分比(0–100)`)}),(0,J.jsx)(d,{value:m?.jitterPercent||``,onChange:e=>h(t=>({...t,jitterPercent:e}))})]})]}),(0,J.jsx)(w,{visible:!!_,title:a(`c2.sessions.infoNote`,null,`备注`),width:480,onCancel:()=>v(null),onOk:I,confirmLoading:b,children:(0,J.jsx)(u,{value:_?.note||``,onChange:e=>v(t=>({...t,note:e})),placeholder:a(`c2.sessions.notePlaceholder`,null,`添加备注,便于识别该会话…`),autosize:{minRows:4,maxRows:10}})})]})}var{Text:$}=a;function be(){let e=y(),{hasPermission:t}=b(),n=t(`c2:write`),a=t(`c2:delete`)||n,[o,u]=r(),p=o.get(`id`)||``,[m,v]=(0,q.useState)(``),[x,w]=(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:m||void 0,listener_id:x||void 0,search:I||void 0,suspicious:T?`1`:void 0,limit:200}),[m,x,I,T]),{data:z,loading:B,error:ne,reload:V}=S(()=>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===p)||null,[H,p]),G=e=>{let t=new URLSearchParams(o);e?t.set(`id`,e):t.delete(`id`),u(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)(l,{icon:(0,J.jsx)(g,{}),onClick:V,loading:B,children:e(`common.refresh`,null,`刷新`)},`refresh`),(0,J.jsx)(l,{type:`danger`,disabled:!a||!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){C(e)}}}):C(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)(_,{size:`small`,value:m,onChange:e=>v(e||``),style:{width:`100%`},optionList:[{value:``,label:e(`c2.sessions.filterAllStatus`,null,`全部状态`)},...ae]}),(0,J.jsx)(_,{size:`small`,value:x,onChange:e=>w(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)(d,{size:`small`,value:j,onChange:M,prefix:(0,J.jsx)(h,{}),placeholder:e(`c2.sessions.filterSearchPlaceholder`,null,`搜索主机名 / 用户 / IP`)}),(0,J.jsxs)(`div`,{className:`c2-session-filter-foot`,children:[(0,J.jsx)(c,{checked:T,onChange:e=>D(!!e.target.checked),children:(0,J.jsx)($,{size:`small`,children:e(`c2.sessions.filterSuspicious`,null,`疑似误报`)})}),(0,J.jsx)(c,{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)(f,{})}),!B&&H.length===0&&(0,J.jsx)(i,{title:j||m||x?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===p?`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)(s,{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)(s,{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:a,onChanged:V,onDeleted:()=>{G(``),V()}},W.id):(0,J.jsx)(i,{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{E as i,G as a,I as o,N as s,P as c,R as l,S as u,U as d,W as f,c as p,ct as m,lt as h,ut as g,y as _}from"./semi-65W_4I1v.js";import{E as v,F as y,I as b,S as x,a as S,b as C,c 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-C6SML8F9.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-u6LJyEH4.js";import{c as ie,h as G,l as ae,m as oe,u as K}from"./c2-shared-GD1-MSK1.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=y(),[i,a]=(0,q.useState)([]),[c,u]=(0,q.useState)(``),[f,p]=(0,q.useState)(!1),[h,g]=(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 b=(0,q.useCallback)(e=>{a(t=>[...t,{id:ce(),...e}])},[]),S=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},w=async i=>{let a=String(i??c).trim();if(a){if(!t)x(r(`c2.sessions.writeRequired`,null,`当前账号没有下发任务的权限`));else{u(``),b({kind:`cmd`,text:a}),p(!0);try{let t=(await ne(e.id,{task_type:`shell`,payload:{command:a,timeout_seconds:60}}))?.task?.id;if(!t){b({kind:`err`,text:r(`c2.sessions.termNoSession`,null,`下发失败:未返回任务 ID`)});return}g(t),n?.();let i=await S(t);if(!i){b({kind:`warn`,text:r(`c2.sessions.termWaitTimeout`,null,`[等待结果超时]`)});return}i.resultText&&b({kind:i.status===`success`?`out`:`warn`,text:i.resultText}),i.error&&b({kind:`err`,text:i.error}),i.status===`cancelled`&&b({kind:`warn`,text:r(`c2.tasks.cancelled`,null,`已取消`)})}catch(e){b({kind:`err`,text:e?.message||r(`c2.sessions.termStatusErr`,null,`执行失败`)}),C(e)}finally{_.current&&(p(!1),g(``))}}}};return(0,J.jsxs)(`div`,{className:`c2-terminal`,children:[(0,J.jsx)(`div`,{className:`c2-terminal-bar`,children:(0,J.jsxs)(o,{spacing:8,children:[(0,J.jsx)(s,{size:`small`,color:f?`amber`:`green`,children:f?r(`c2.sessions.termStatusExec`,null,`执行中…`):r(`c2.sessions.termStatusReady`,null,`就绪`)}),(0,J.jsx)(l,{size:`small`,theme:`borderless`,onClick:()=>a([]),children:r(`c2.sessions.clearTerminal`,null,`清屏`)}),f&&h&&(0,J.jsx)(l,{size:`small`,theme:`borderless`,type:`danger`,onClick:async()=>{if(h)try{await H(h),b({kind:`warn`,text:r(`c2.tasks.toastCancelled`,null,`任务已取消`)})}catch(e){C(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)(d,{value:c,onChange:u,onEnterPress:()=>f?x(r(`c2.sessions.termWaitFinish`,null,`请等待当前命令执行完成`)):w(),placeholder:r(`c2.sessions.commandPlaceholder`,null,`输入命令后回车下发`),disabled:f||!t,prefix:`$`}),(0,J.jsx)(l,{theme:`solid`,type:`primary`,icon:(0,J.jsx)(m,{}),loading:f,disabled:!t,onClick:()=>w(),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}=a,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=y(),[r,i]=(0,q.useState)(`.`),[a,s]=(0,q.useState)(`.`),[c,u]=(0,q.useState)([]),[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(!1),[_,v]=(0,q.useState)(null),[b,S]=(0,q.useState)(``),w=(0,q.useRef)(!0);(0,q.useEffect)(()=>()=>{w.current=!1},[]);let T=(0,q.useCallback)(async t=>{let a=Y(t??r);h(!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(!w.current)return;if(!r){v(n(`c2.files.timeout`,null,`加载文件超时`));return}if(r.status!==`success`){v(r.error||n(`c2.files.failed`,null,`列目录失败`)),u([]),p(r.resultText||``);return}p(r.resultText||``),u(de(r.resultText||``)),i(a),s(a)}catch(e){w.current&&v(e)}finally{w.current&&h(!1)}},[e.id,r,n]);(0,q.useEffect)(()=>{i(`.`),s(`.`),u([]),T(`.`)},[e.id]);let D=async i=>{if(!t){x(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){C(e,n(`c2.files.failed`,null,`下载失败`))}},O=c.filter(e=>{let t=b.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)(l,{size:`small`,theme:`borderless`,onClick:()=>T(X(r,i.name)),children:n(`c2.files.open`,null,`打开`)}):(0,J.jsx)(l,{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)(o,{spacing:8,wrap:!0,children:[(0,J.jsx)(l,{size:`small`,onClick:()=>T(fe(r)),children:n(`c2.files.parent`,null,`上级目录`)}),(0,J.jsx)(l,{size:`small`,icon:(0,J.jsx)(g,{}),loading:m,onClick:()=>T(r),children:n(`c2.files.refresh`,null,`刷新`)}),(0,J.jsx)(d,{size:`small`,value:a,onChange:s,onEnterPress:()=>T(a),className:`c2-files-path`}),(0,J.jsx)(l,{size:`small`,onClick:()=>T(a),children:n(`c2.files.go`,null,`跳转`)}),(0,J.jsx)(d,{size:`small`,value:b,onChange:S,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)}),c.length===0&&f.trim()&&!m?(0,J.jsx)(`pre`,{className:`c2-pre`,children:f}):(0,J.jsx)(j,{columns:k,dataSource:O,rowKey:`name`,loading:m,pagination:{pageSize:20},emptyText:n(`c2.files.emptyDir`,null,`空目录`)})]})}function _e({session:e,canDelete:t,onChanged:n}){let r=y(),[i,a]=(0,q.useState)(null),{data:c,loading:u,error:d,reload:f}=S(()=>F({session_id:e.id,limit:100}),[e.id]),p=Array.isArray(c?.tasks)?c.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){C(e)}},h=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){C(e)}}})},g=[{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)(s,{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)(o,{spacing:4,wrap:!0,children:[(0,J.jsx)(l,{size:`small`,theme:`borderless`,onClick:()=>a(n),children:r(`c2.tasks.view`,null,`查看`)}),[`queued`,`sent`,`running`].includes(n.status)&&(0,J.jsx)(l,{size:`small`,theme:`borderless`,onClick:()=>m(n),children:r(`c2.tasks.cancelBtn`,null,`取消`)}),(0,J.jsx)(l,{size:`small`,theme:`borderless`,type:`danger`,disabled:!t,onClick:()=>h(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:g,dataSource:p,rowKey:`id`,loading:u,onRefresh:()=>f(),pagination:{pageSize:10},emptyText:r(`c2.tasks.emptySession`,null,`该会话暂无任务`)}),(0,J.jsx)(w,{visible:!!i,title:r(`c2.tasks.modalTitle`,null,`任务详情`),width:720,onCancel:()=>a(null),footer:(0,J.jsx)(l,{onClick:()=>a(null),children:r(`c2.tasks.close`,null,`关闭`)}),children:i&&(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:i.id}),(0,J.jsx)(s,{size:`small`,color:K[i.status]||`grey`,children:i.status}),(0,J.jsx)(`span`,{className:`c2-muted`,children:v(i.createdAt)})]}),i.payload&&(0,J.jsx)(M,{title:r(`c2.tasks.labelPayload`,null,`参数`),value:i.payload,collapsed:!0}),i.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:i.resultText})]}),i.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:i.error})]})]})})]})}var{Text:Z}=a;function ve({session:e,canWrite:t,onEditNote:n}){let r=y(),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:v(e.firstSeenAt)},{label:r(`c2.sessions.infoLastCheckin`,null,`上次心跳`),value:v(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)(o,{children:(0,J.jsx)(l,{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}=a;function ye({session:e,canWrite:t,canDelete:n,onChanged:r,onDeleted:i}){let a=y(),[c,f]=(0,q.useState)(`terminal`),[m,h]=(0,q.useState)(null),[_,v]=(0,q.useState)(null),[b,T]=(0,q.useState)(!1),{data:D,loading:O,error:k,reload:A}=S(()=>z(e.id),[e.id]),j=D?.session||e,M=()=>h({sleepSeconds:String(j.sleepSeconds||5),jitterPercent:String(j.jitterPercent||0)}),F=()=>v({note:j.note||``}),ee=async()=>{let e=Number(m.sleepSeconds),t=Number(m.jitterPercent);if(!Number.isFinite(e)||e<1)x(a(`c2.sessions.toastSleepInvalid`,null,`Sleep 间隔至少为 1 秒`));else if(!Number.isFinite(t)||t<0||t>100)x(a(`c2.sessions.toastSleepInvalid`,null,`抖动百分比需在 0–100 之间`));else{T(!0);try{await te(j.id,{sleepSeconds:e,jitterPercent:t}),N(a(`c2.sessions.toastSleepUpdated`,null,`Sleep 设置已更新`)),h(null),A({silent:!0}),r?.()}catch(e){C(e)}finally{T(!1)}}},I=async()=>{let e=String(_.note||``).trim();if(e.length>2e3)x(a(`c2.sessions.toastNoteTooLong`,null,`备注最多 2000 字`));else{T(!0);try{await W(j.id,e),N(a(`c2.sessions.toastNoteSaved`,null,`备注已保存`)),v(null),A({silent:!0}),r?.()}catch(e){C(e)}finally{T(!1)}}},R=()=>{P({title:a(`c2.sessions.cardDeleteSession`,null,`删除会话`),content:a(`c2.sessions.confirmDeleteSession`,null,`从服务器删除此会话及其关联任务与文件记录?`),onOk:async()=>{try{await L(j.id),N(a(`c2.sessions.toastSessionDeleted`,null,`会话记录已删除`)),i?.()}catch(e){C(e)}}})},B=[{tab:a(`c2.sessions.terminal`,null,`终端`),itemKey:`terminal`,children:(0,J.jsx)(ue,{session:j,canWrite:t,onTaskCreated:A})},{tab:a(`c2.sessions.files`,null,`文件`),itemKey:`files`,children:(0,J.jsx)(ge,{session:j,canWrite:t})},{tab:a(`c2.sessions.tasks`,null,`任务`),itemKey:`tasks`,children:(0,J.jsx)(_e,{session:j,canDelete:n,onChanged:A})},{tab:a(`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||a(`c2.sessions.unknownHost`,null,`未知主机`)}),(0,J.jsxs)(o,{spacing:6,wrap:!0,children:[(0,J.jsx)(s,{size:`small`,color:ie[j.status]||`grey`,children:a(`c2.sessions.${j.status||`active`}`,null,j.status||`—`)}),(0,J.jsxs)(s,{size:`small`,children:[j.os||`—`,`/`,j.arch||`—`]}),j.isAdmin&&(0,J.jsx)(s,{size:`small`,color:`red`,children:a(`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)(o,{spacing:6,wrap:!0,children:[(0,J.jsx)(l,{size:`small`,icon:(0,J.jsx)(g,{}),loading:O,onClick:()=>A(),children:a(`common.refresh`,null,`刷新`)}),(0,J.jsx)(l,{size:`small`,disabled:!t,onClick:M,children:a(`c2.sessions.btnSleep`,null,`Sleep`)}),(0,J.jsx)(l,{size:`small`,disabled:!t,onClick:F,children:a(`c2.sessions.noteEdit`,null,`备注`)}),(0,J.jsx)(l,{size:`small`,type:`danger`,disabled:!n,onClick:R,children:a(`c2.sessions.cardDeleteSession`,null,`删除会话`)})]})]}),(0,J.jsx)(E,{error:k,onRetry:A}),(0,J.jsx)(p,{type:`button`,activeKey:c,onChange:f,items:B}),(0,J.jsxs)(w,{visible:!!m,title:a(`c2.sessions.sleepModalTitle`,null,`心跳配置`),width:440,onCancel:()=>h(null),onOk:ee,confirmLoading:b,children:[(0,J.jsx)(Q,{type:`tertiary`,size:`small`,children:a(`c2.sessions.sleepModalHint`,null,`保存后将写入服务端并下发 sleep 任务。`)}),(0,J.jsxs)(`div`,{className:`c2-session-modal-field`,children:[(0,J.jsx)(Q,{size:`small`,children:a(`c2.sessions.promptSleepSeconds`,null,`Sleep 间隔(秒)`)}),(0,J.jsx)(d,{value:m?.sleepSeconds||``,onChange:e=>h(t=>({...t,sleepSeconds:e}))})]}),(0,J.jsxs)(`div`,{className:`c2-session-modal-field`,children:[(0,J.jsx)(Q,{size:`small`,children:a(`c2.sessions.promptJitterPercent`,null,`抖动百分比(0–100)`)}),(0,J.jsx)(d,{value:m?.jitterPercent||``,onChange:e=>h(t=>({...t,jitterPercent:e}))})]})]}),(0,J.jsx)(w,{visible:!!_,title:a(`c2.sessions.infoNote`,null,`备注`),width:480,onCancel:()=>v(null),onOk:I,confirmLoading:b,children:(0,J.jsx)(u,{value:_?.note||``,onChange:e=>v(t=>({...t,note:e})),placeholder:a(`c2.sessions.notePlaceholder`,null,`添加备注,便于识别该会话…`),autosize:{minRows:4,maxRows:10}})})]})}var{Text:$}=a;function be(){let e=y(),{hasPermission:t}=b(),n=t(`c2:write`),a=t(`c2:delete`)||n,[o,u]=r(),p=o.get(`id`)||``,[m,v]=(0,q.useState)(``),[x,w]=(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:m||void 0,listener_id:x||void 0,search:I||void 0,suspicious:T?`1`:void 0,limit:200}),[m,x,I,T]),{data:z,loading:B,error:ne,reload:V}=S(()=>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===p)||null,[H,p]),G=e=>{let t=new URLSearchParams(o);e?t.set(`id`,e):t.delete(`id`),u(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)(l,{icon:(0,J.jsx)(g,{}),onClick:V,loading:B,children:e(`common.refresh`,null,`刷新`)},`refresh`),(0,J.jsx)(l,{type:`danger`,disabled:!a||!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){C(e)}}}):C(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)(_,{size:`small`,value:m,onChange:e=>v(e||``),style:{width:`100%`},optionList:[{value:``,label:e(`c2.sessions.filterAllStatus`,null,`全部状态`)},...ae]}),(0,J.jsx)(_,{size:`small`,value:x,onChange:e=>w(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)(d,{size:`small`,value:j,onChange:M,prefix:(0,J.jsx)(h,{}),placeholder:e(`c2.sessions.filterSearchPlaceholder`,null,`搜索主机名 / 用户 / IP`)}),(0,J.jsxs)(`div`,{className:`c2-session-filter-foot`,children:[(0,J.jsx)(c,{checked:T,onChange:e=>D(!!e.target.checked),children:(0,J.jsx)($,{size:`small`,children:e(`c2.sessions.filterSuspicious`,null,`疑似误报`)})}),(0,J.jsx)(c,{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)(f,{})}),!B&&H.length===0&&(0,J.jsx)(i,{title:j||m||x?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===p?`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)(s,{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)(s,{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:a,onChanged:V,onDeleted:()=>{G(``),V()}},W.id):(0,J.jsx)(i,{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-BrRxH-6B.js b/web/static/app/assets/c2-shared-GD1-MSK1.js
similarity index 96%
rename from web/static/app/assets/c2-shared-BrRxH-6B.js
rename to web/static/app/assets/c2-shared-GD1-MSK1.js
index 24a8c624..4132bb23 100644
--- a/web/static/app/assets/c2-shared-BrRxH-6B.js
+++ b/web/static/app/assets/c2-shared-GD1-MSK1.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{G as t,I as n,R as r}from"./semi-65W_4I1v.js";import{A as i,E as a,F as o}from"./index-DNMXun-U.js";import"./c2-shared-2EAlkwn6.js";import{t as s}from"./react-QV7DAAIx.js";var c=e(s(),1),{Text:l}=t,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:t,ns:i=`tasks`}){let a=o();return(0,c.jsxs)(n,{spacing:6,wrap:!0,className:`c2-time-presets`,children:[(0,c.jsx)(l,{type:`tertiary`,size:`small`,children:a(`c2.tasks.timePresets`,null,`快捷`)}),v.map(n=>(0,c.jsx)(r,{size:`small`,theme:n.value===e?`solid`:`borderless`,type:n.value===e?`primary`:`tertiary`,onClick:()=>t(n.value),children:a(`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=o();return e?(0,c.jsx)(`span`,{className:`c2-time-text`,title:a(e),children:i(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{G as t,I as n,R as r}from"./semi-65W_4I1v.js";import{A as i,E as a,F as o}from"./index-C6SML8F9.js";import"./c2-shared-u6LJyEH4.js";import{t as s}from"./react-QV7DAAIx.js";var c=e(s(),1),{Text:l}=t,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:t,ns:i=`tasks`}){let a=o();return(0,c.jsxs)(n,{spacing:6,wrap:!0,className:`c2-time-presets`,children:[(0,c.jsx)(l,{type:`tertiary`,size:`small`,children:a(`c2.tasks.timePresets`,null,`快捷`)}),v.map(n=>(0,c.jsx)(r,{size:`small`,theme:n.value===e?`solid`:`borderless`,type:n.value===e?`primary`:`tertiary`,onClick:()=>t(n.value),children:a(`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=o();return e?(0,c.jsx)(`span`,{className:`c2-time-text`,title:a(e),children:i(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-shared-2EAlkwn6.js b/web/static/app/assets/c2-shared-u6LJyEH4.js
similarity index 94%
rename from web/static/app/assets/c2-shared-2EAlkwn6.js
rename to web/static/app/assets/c2-shared-u6LJyEH4.js
index cf32366b..75c2b4d7 100644
--- a/web/static/app/assets/c2-shared-2EAlkwn6.js
+++ b/web/static/app/assets/c2-shared-u6LJyEH4.js
@@ -1 +1 @@
-import{L as e,R as t}from"./index-DNMXun-U.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{L as e,R as t}from"./index-C6SML8F9.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-tasks-FVvnpyKj.js b/web/static/app/assets/c2-tasks-CRV-zYmi.js
similarity index 97%
rename from web/static/app/assets/c2-tasks-FVvnpyKj.js
rename to web/static/app/assets/c2-tasks-CRV-zYmi.js
index 8bcce80a..a8f56f9a 100644
--- a/web/static/app/assets/c2-tasks-FVvnpyKj.js
+++ b/web/static/app/assets/c2-tasks-CRV-zYmi.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{G as i,I as a,N as o,R as s,U as c,ft as l,i as u,ut as d,y as f}from"./semi-65W_4I1v.js";import{E as ee,F as p,I as te,_ as ne,a as re,b as m,c as h,l as ie,m as g,p as ae,r as _,s as v,x as y,y as oe}from"./index-DNMXun-U.js";import{A as se,C as ce,h as le,p as ue,r as de,s as b}from"./c2-shared-2EAlkwn6.js";import{d as fe,f as x,g as pe,h as S,m as me,p as he,u as C}from"./c2-shared-BrRxH-6B.js";var w=e(t(),1),T=e(n(),1),{Text:E}=i,D=new Set([`shell`,`exec`]),O=new Set([`ls`,`download`,`cd`]);function ge({visible:e,defaultSessionId:t,onCancel:n,onSubmit:r,submitting:i}){let o=p(),[c,l]=(0,w.useState)(null),[d,f]=(0,w.useState)(`shell`);return(0,T.jsx)(h,{visible:e,title:o(`c2.tasks.createTitle`,null,`下发任务`),footer:(0,T.jsxs)(a,{children:[(0,T.jsx)(s,{onClick:n,children:o(`c2.tasks.cancelFilters`,null,`取消`)}),(0,T.jsx)(s,{theme:`solid`,type:`primary`,loading:i,onClick:()=>c?.submitForm(),children:o(`c2.tasks.createSubmit`,null,`下发`)})]}),width:560,onCancel:n,children:(0,T.jsxs)(u,{initValues:{session_id:t||``,task_type:`shell`,command:``,timeout_seconds:`60`,extra:``},onSubmit:e=>{let t={},n=String(e.command||``).trim();if(D.has(e.task_type)){t.command=n;let r=Number(e.timeout_seconds);Number.isFinite(r)&&r>0&&(t.timeout_seconds=r)}else(O.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:l,labelPosition:`top`,onValueChange:e=>{e.task_type&&f(e.task_type)},children:[(0,T.jsx)(u.Input,{field:`session_id`,label:o(`c2.tasks.labelSession`,null,`会话`),placeholder:`s_xxxxxxxx`,rules:[{required:!0,message:o(`c2.tasks.labelSession`,null,`请填写会话 ID`)}]}),(0,T.jsx)(u.Select,{field:`task_type`,label:o(`c2.tasks.labelType`,null,`类型`),optionList:x,style:{width:`100%`}}),(0,T.jsx)(u.Input,{field:`command`,label:D.has(d)?o(`c2.tasks.labelCommand`,null,`命令`):o(`c2.tasks.labelPath`,null,`路径`),placeholder:D.has(d)?`whoami`:`/etc/passwd`}),D.has(d)&&(0,T.jsx)(u.Input,{field:`timeout_seconds`,label:o(`c2.tasks.labelTimeout`,null,`超时(秒)`),placeholder:`60`}),(0,T.jsx)(u.Input,{field:`extra`,label:o(`c2.tasks.labelExtraPayload`,null,`附加参数(JSON,可选)`),placeholder:`{"key":"value"}`}),(0,T.jsx)(E,{type:`tertiary`,size:`small`,children:o(`c2.tasks.createHint`,null,`任务入队后由植入体在下次心跳拉取;危险类型可能需要人机协同审批。`)})]},e?`open`:`closed`)})}var{Text:k}=i;function A(){let e=p(),{hasPermission:t}=te(),n=t(`c2:write`),i=t(`c2:delete`)||n,[u,E]=r(),[D,O]=(0,w.useState)(1),[A,_e]=(0,w.useState)(20),[j,M]=(0,w.useState)(``),[N,P]=(0,w.useState)(``),[F,I]=(0,w.useState)(`all`),[L,R]=(0,w.useState)(u.get(`session_id`)||``),[z,B]=(0,w.useState)(u.get(`session_id`)||``),[V,H]=(0,w.useState)(null),[ve,U]=(0,w.useState)(!1),[ye,W]=(0,w.useState)(!1),G=(0,w.useMemo)(()=>({page:D,page_size:A,status:j||void 0,task_type:N||void 0,session_id:z||void 0,since:pe(F)||void 0}),[D,A,j,N,z,F]),{data:K,loading:q,error:be,reload:J}=re(()=>ce(G),[G]),Y=Array.isArray(K?.tasks)?K.tasks:[],X=Number(K?.total??Y.length),Z=K?.status_counts||{};_(()=>J({silent:!0}),5e3);let Q=()=>{B(L.trim()),O(1);let e=new URLSearchParams(u);L.trim()?e.set(`session_id`,L.trim()):e.delete(`session_id`),E(e,{replace:!0})},xe=()=>{M(``),P(``),I(`all`),R(``),B(``),O(1),E(new URLSearchParams,{replace:!0})},Se=[{id:`total`,label:e(`c2.tasks.statTotal`,null,`当前筛选`),value:X},{id:`success`,label:e(`c2.tasks.success`,null,`成功`),value:Z.success||0,tone:`success`},{id:`failed`,label:e(`c2.tasks.failed`,null,`失败`),value:Z.failed||0,tone:`danger`},{id:`pending`,label:e(`c2.tasks.pending`,null,`待处理`),value:(Z.queued||0)+(Z.sent||0)+(Z.running||0),tone:`warning`}],Ce=async t=>{try{await de(t.id),y(e(`c2.tasks.toastCancelled`,null,`任务已取消`)),J({silent:!0})}catch(e){m(e)}},we=t=>{oe({title:e(`c2.tasks.deleteOne`,null,`删除任务`),content:e(`c2.tasks.confirmDeleteOne`,null,`确定从服务器删除该任务记录吗?此操作不可恢复。`),onOk:async()=>{try{await ue([t.id]),y(e(`c2.tasks.toastDeleted`,null,`已删除 {{n}} 条`).replace(`{{n}}`,`1`)),J()}catch(e){m(e)}}})},Te=async t=>{try{let n=await se(t.id,20);n?.task&&H(n.task),y(e(`c2.tasks.toastWaited`,null,`已获取最新任务状态`)),J({silent:!0})}catch(t){m(t,e(`c2.tasks.waitTimeout`,null,`等待任务完成超时`))}},$=async t=>{try{await le(t.id),y(e(`c2.tasks.downloadOk`,null,`已开始下载`))}catch(t){m(t,e(`c2.tasks.labelResult`,null,`下载结果文件失败`))}},Ee=async t=>{W(!0);try{await b(t),y(e(`c2.tasks.toastCreated`,null,`任务已下发`)),U(!1),J()}catch(t){m(t,e(`c2.tasks.createFailed`,null,`下发任务失败`))}finally{W(!1)}},De=[{title:e(`c2.tasks.colTask`,null,`任务`),dataIndex:`id`,width:150,render:e=>(0,T.jsx)(`span`,{className:`c2-mono`,children:e})},{title:e(`c2.tasks.colSession`,null,`会话`),dataIndex:`sessionId`,width:150,render:e=>(0,T.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,T.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,T.jsx)(o,{size:`small`,color:C[t]||`grey`,children:e(`c2.tasks.${t||`queued`}`,null,t||`—`)})},{title:e(`c2.tasks.colDuration`,null,`耗时`),dataIndex:`durationMs`,width:100,render:e=>S(e)},{title:e(`c2.tasks.colCreated`,null,`创建时间`),dataIndex:`createdAt`,width:130,render:e=>(0,T.jsx)(me,{value:e})},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:210,render:(t,n)=>(0,T.jsxs)(a,{spacing:4,wrap:!0,children:[(0,T.jsx)(s,{size:`small`,theme:`borderless`,onClick:()=>H(n),children:e(`c2.tasks.view`,null,`查看`)}),[`queued`,`sent`,`running`].includes(n.status)&&(0,T.jsx)(s,{size:`small`,theme:`borderless`,onClick:()=>Ce(n),children:e(`c2.tasks.cancelBtn`,null,`取消`)}),n.resultBlobPath&&(0,T.jsx)(s,{size:`small`,theme:`borderless`,onClick:()=>$(n),children:e(`c2.tasks.downloadResult`,null,`结果文件`)}),(0,T.jsx)(s,{size:`small`,theme:`borderless`,type:`danger`,disabled:!i,onClick:()=>we(n),children:e(`c2.tasks.deleteBtn`,null,`删除`)})]})}];return(0,T.jsxs)(`div`,{className:`c2-page`,id:`page-c2-tasks`,children:[(0,T.jsx)(ae,{title:e(`c2.tasks.title`,null,`任务管理`),description:e(`c2.tasks.pageDesc`,null,`按状态、类型、会话与时间窗筛选任务,5 秒自动轮询最新状态`),extra:[(0,T.jsx)(s,{icon:(0,T.jsx)(d,{}),onClick:()=>J(),loading:q,children:e(`c2.tasks.refresh`,null,`刷新任务`)},`refresh`),(0,T.jsx)(s,{theme:`solid`,type:`primary`,icon:(0,T.jsx)(l,{}),disabled:!n,onClick:()=>U(!0),children:e(`c2.tasks.createTitle`,null,`下发任务`)},`create`)]}),(0,T.jsx)(ne,{metrics:Se,columns:4}),(0,T.jsx)(ie,{error:be,onRetry:()=>J()}),(0,T.jsx)(g,{title:e(`c2.tasks.filterTitle`,null,`筛选`),extra:(0,T.jsx)(he,{value:F,onChange:e=>{I(e),O(1)},ns:`tasks`}),children:(0,T.jsxs)(`div`,{className:`c2-toolbar-fields`,children:[(0,T.jsxs)(`div`,{className:`c2-field`,children:[(0,T.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.colStatus`,null,`状态`)}),(0,T.jsx)(f,{value:j,onChange:e=>{M(e||``),O(1)},style:{width:160},optionList:[{value:``,label:e(`c2.tasks.filterAllStatuses`,null,`全部状态`)},...fe]})]}),(0,T.jsxs)(`div`,{className:`c2-field`,children:[(0,T.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.colType`,null,`类型`)}),(0,T.jsx)(f,{value:N,onChange:e=>{P(e||``),O(1)},style:{width:160},optionList:[{value:``,label:e(`c2.tasks.filterAllTypes`,null,`全部类型`)},...x]})]}),(0,T.jsxs)(`div`,{className:`c2-field`,children:[(0,T.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.filterSession`,null,`会话 ID`)}),(0,T.jsx)(c,{value:L,onChange:R,onEnterPress:Q,placeholder:e(`c2.tasks.filterSessionPlaceholder`,null,`s_xxxxxxxx`),style:{width:190}})]}),(0,T.jsxs)(a,{spacing:8,children:[(0,T.jsx)(s,{theme:`solid`,type:`primary`,onClick:Q,children:e(`c2.tasks.applyFilters`,null,`应用筛选`)}),(0,T.jsx)(s,{onClick:xe,children:e(`c2.tasks.resetFilters`,null,`重置`)})]})]})}),(0,T.jsx)(g,{title:e(`c2.tasks.listTitle`,null,`任务列表`),children:(0,T.jsx)(v,{columns:De,dataSource:Y,rowKey:`id`,loading:q,onRefresh:()=>J(),pagination:{currentPage:D,pageSize:A,total:X,onPageChange:e=>O(e),onPageSizeChange:e=>{_e(e),O(1)}},emptyText:e(`c2.tasks.emptyAll`,null,`暂无任务`)})}),(0,T.jsx)(ge,{visible:ve,defaultSessionId:z,submitting:ye,onCancel:()=>U(!1),onSubmit:Ee}),(0,T.jsx)(h,{visible:!!V,title:e(`c2.tasks.modalTitle`,null,`任务详情`),width:760,onCancel:()=>H(null),footer:(0,T.jsxs)(a,{children:[V&&[`queued`,`sent`,`running`].includes(V.status)&&(0,T.jsx)(s,{onClick:()=>Te(V),children:e(`c2.tasks.waitBtn`,null,`等待完成`)}),V?.resultBlobPath&&(0,T.jsx)(s,{onClick:()=>$(V),children:e(`c2.tasks.downloadResult`,null,`下载结果文件`)}),(0,T.jsx)(s,{onClick:()=>H(null),children:e(`c2.tasks.close`,null,`关闭`)})]}),children:V&&(0,T.jsxs)(`div`,{className:`c2-task-detail`,children:[(0,T.jsxs)(`div`,{className:`c2-task-detail-meta`,children:[(0,T.jsx)(`span`,{className:`c2-mono`,children:V.id}),(0,T.jsx)(o,{size:`small`,color:C[V.status]||`grey`,children:V.status}),(0,T.jsx)(k,{type:`tertiary`,size:`small`,children:ee(V.createdAt)}),(0,T.jsx)(k,{type:`tertiary`,size:`small`,children:S(V.durationMs)})]}),(0,T.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelPayload`,null,`参数`)}),(0,T.jsx)(`pre`,{className:`c2-pre`,children:JSON.stringify(V.payload||{},null,2)}),V.resultText&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelResult`,null,`输出`)}),(0,T.jsx)(`pre`,{className:`c2-pre`,children:V.resultText})]}),V.error&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelError`,null,`错误`)}),(0,T.jsx)(`pre`,{className:`c2-pre c2-pre-error`,children:V.error})]})]})})]})}export{A 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{G as i,I as a,N as o,R as s,U as c,ft as l,i as u,ut as d,y as f}from"./semi-65W_4I1v.js";import{E as ee,F as p,I as te,_ as ne,a as re,b as m,c as h,l as ie,m as g,p as ae,r as _,s as v,x as y,y as oe}from"./index-C6SML8F9.js";import{A as se,C as ce,h as le,p as ue,r as de,s as b}from"./c2-shared-u6LJyEH4.js";import{d as fe,f as x,g as pe,h as S,m as me,p as he,u as C}from"./c2-shared-GD1-MSK1.js";var w=e(t(),1),T=e(n(),1),{Text:E}=i,D=new Set([`shell`,`exec`]),O=new Set([`ls`,`download`,`cd`]);function ge({visible:e,defaultSessionId:t,onCancel:n,onSubmit:r,submitting:i}){let o=p(),[c,l]=(0,w.useState)(null),[d,f]=(0,w.useState)(`shell`);return(0,T.jsx)(h,{visible:e,title:o(`c2.tasks.createTitle`,null,`下发任务`),footer:(0,T.jsxs)(a,{children:[(0,T.jsx)(s,{onClick:n,children:o(`c2.tasks.cancelFilters`,null,`取消`)}),(0,T.jsx)(s,{theme:`solid`,type:`primary`,loading:i,onClick:()=>c?.submitForm(),children:o(`c2.tasks.createSubmit`,null,`下发`)})]}),width:560,onCancel:n,children:(0,T.jsxs)(u,{initValues:{session_id:t||``,task_type:`shell`,command:``,timeout_seconds:`60`,extra:``},onSubmit:e=>{let t={},n=String(e.command||``).trim();if(D.has(e.task_type)){t.command=n;let r=Number(e.timeout_seconds);Number.isFinite(r)&&r>0&&(t.timeout_seconds=r)}else(O.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:l,labelPosition:`top`,onValueChange:e=>{e.task_type&&f(e.task_type)},children:[(0,T.jsx)(u.Input,{field:`session_id`,label:o(`c2.tasks.labelSession`,null,`会话`),placeholder:`s_xxxxxxxx`,rules:[{required:!0,message:o(`c2.tasks.labelSession`,null,`请填写会话 ID`)}]}),(0,T.jsx)(u.Select,{field:`task_type`,label:o(`c2.tasks.labelType`,null,`类型`),optionList:x,style:{width:`100%`}}),(0,T.jsx)(u.Input,{field:`command`,label:D.has(d)?o(`c2.tasks.labelCommand`,null,`命令`):o(`c2.tasks.labelPath`,null,`路径`),placeholder:D.has(d)?`whoami`:`/etc/passwd`}),D.has(d)&&(0,T.jsx)(u.Input,{field:`timeout_seconds`,label:o(`c2.tasks.labelTimeout`,null,`超时(秒)`),placeholder:`60`}),(0,T.jsx)(u.Input,{field:`extra`,label:o(`c2.tasks.labelExtraPayload`,null,`附加参数(JSON,可选)`),placeholder:`{"key":"value"}`}),(0,T.jsx)(E,{type:`tertiary`,size:`small`,children:o(`c2.tasks.createHint`,null,`任务入队后由植入体在下次心跳拉取;危险类型可能需要人机协同审批。`)})]},e?`open`:`closed`)})}var{Text:k}=i;function A(){let e=p(),{hasPermission:t}=te(),n=t(`c2:write`),i=t(`c2:delete`)||n,[u,E]=r(),[D,O]=(0,w.useState)(1),[A,_e]=(0,w.useState)(20),[j,M]=(0,w.useState)(``),[N,P]=(0,w.useState)(``),[F,I]=(0,w.useState)(`all`),[L,R]=(0,w.useState)(u.get(`session_id`)||``),[z,B]=(0,w.useState)(u.get(`session_id`)||``),[V,H]=(0,w.useState)(null),[ve,U]=(0,w.useState)(!1),[ye,W]=(0,w.useState)(!1),G=(0,w.useMemo)(()=>({page:D,page_size:A,status:j||void 0,task_type:N||void 0,session_id:z||void 0,since:pe(F)||void 0}),[D,A,j,N,z,F]),{data:K,loading:q,error:be,reload:J}=re(()=>ce(G),[G]),Y=Array.isArray(K?.tasks)?K.tasks:[],X=Number(K?.total??Y.length),Z=K?.status_counts||{};_(()=>J({silent:!0}),5e3);let Q=()=>{B(L.trim()),O(1);let e=new URLSearchParams(u);L.trim()?e.set(`session_id`,L.trim()):e.delete(`session_id`),E(e,{replace:!0})},xe=()=>{M(``),P(``),I(`all`),R(``),B(``),O(1),E(new URLSearchParams,{replace:!0})},Se=[{id:`total`,label:e(`c2.tasks.statTotal`,null,`当前筛选`),value:X},{id:`success`,label:e(`c2.tasks.success`,null,`成功`),value:Z.success||0,tone:`success`},{id:`failed`,label:e(`c2.tasks.failed`,null,`失败`),value:Z.failed||0,tone:`danger`},{id:`pending`,label:e(`c2.tasks.pending`,null,`待处理`),value:(Z.queued||0)+(Z.sent||0)+(Z.running||0),tone:`warning`}],Ce=async t=>{try{await de(t.id),y(e(`c2.tasks.toastCancelled`,null,`任务已取消`)),J({silent:!0})}catch(e){m(e)}},we=t=>{oe({title:e(`c2.tasks.deleteOne`,null,`删除任务`),content:e(`c2.tasks.confirmDeleteOne`,null,`确定从服务器删除该任务记录吗?此操作不可恢复。`),onOk:async()=>{try{await ue([t.id]),y(e(`c2.tasks.toastDeleted`,null,`已删除 {{n}} 条`).replace(`{{n}}`,`1`)),J()}catch(e){m(e)}}})},Te=async t=>{try{let n=await se(t.id,20);n?.task&&H(n.task),y(e(`c2.tasks.toastWaited`,null,`已获取最新任务状态`)),J({silent:!0})}catch(t){m(t,e(`c2.tasks.waitTimeout`,null,`等待任务完成超时`))}},$=async t=>{try{await le(t.id),y(e(`c2.tasks.downloadOk`,null,`已开始下载`))}catch(t){m(t,e(`c2.tasks.labelResult`,null,`下载结果文件失败`))}},Ee=async t=>{W(!0);try{await b(t),y(e(`c2.tasks.toastCreated`,null,`任务已下发`)),U(!1),J()}catch(t){m(t,e(`c2.tasks.createFailed`,null,`下发任务失败`))}finally{W(!1)}},De=[{title:e(`c2.tasks.colTask`,null,`任务`),dataIndex:`id`,width:150,render:e=>(0,T.jsx)(`span`,{className:`c2-mono`,children:e})},{title:e(`c2.tasks.colSession`,null,`会话`),dataIndex:`sessionId`,width:150,render:e=>(0,T.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,T.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,T.jsx)(o,{size:`small`,color:C[t]||`grey`,children:e(`c2.tasks.${t||`queued`}`,null,t||`—`)})},{title:e(`c2.tasks.colDuration`,null,`耗时`),dataIndex:`durationMs`,width:100,render:e=>S(e)},{title:e(`c2.tasks.colCreated`,null,`创建时间`),dataIndex:`createdAt`,width:130,render:e=>(0,T.jsx)(me,{value:e})},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:210,render:(t,n)=>(0,T.jsxs)(a,{spacing:4,wrap:!0,children:[(0,T.jsx)(s,{size:`small`,theme:`borderless`,onClick:()=>H(n),children:e(`c2.tasks.view`,null,`查看`)}),[`queued`,`sent`,`running`].includes(n.status)&&(0,T.jsx)(s,{size:`small`,theme:`borderless`,onClick:()=>Ce(n),children:e(`c2.tasks.cancelBtn`,null,`取消`)}),n.resultBlobPath&&(0,T.jsx)(s,{size:`small`,theme:`borderless`,onClick:()=>$(n),children:e(`c2.tasks.downloadResult`,null,`结果文件`)}),(0,T.jsx)(s,{size:`small`,theme:`borderless`,type:`danger`,disabled:!i,onClick:()=>we(n),children:e(`c2.tasks.deleteBtn`,null,`删除`)})]})}];return(0,T.jsxs)(`div`,{className:`c2-page`,id:`page-c2-tasks`,children:[(0,T.jsx)(ae,{title:e(`c2.tasks.title`,null,`任务管理`),description:e(`c2.tasks.pageDesc`,null,`按状态、类型、会话与时间窗筛选任务,5 秒自动轮询最新状态`),extra:[(0,T.jsx)(s,{icon:(0,T.jsx)(d,{}),onClick:()=>J(),loading:q,children:e(`c2.tasks.refresh`,null,`刷新任务`)},`refresh`),(0,T.jsx)(s,{theme:`solid`,type:`primary`,icon:(0,T.jsx)(l,{}),disabled:!n,onClick:()=>U(!0),children:e(`c2.tasks.createTitle`,null,`下发任务`)},`create`)]}),(0,T.jsx)(ne,{metrics:Se,columns:4}),(0,T.jsx)(ie,{error:be,onRetry:()=>J()}),(0,T.jsx)(g,{title:e(`c2.tasks.filterTitle`,null,`筛选`),extra:(0,T.jsx)(he,{value:F,onChange:e=>{I(e),O(1)},ns:`tasks`}),children:(0,T.jsxs)(`div`,{className:`c2-toolbar-fields`,children:[(0,T.jsxs)(`div`,{className:`c2-field`,children:[(0,T.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.colStatus`,null,`状态`)}),(0,T.jsx)(f,{value:j,onChange:e=>{M(e||``),O(1)},style:{width:160},optionList:[{value:``,label:e(`c2.tasks.filterAllStatuses`,null,`全部状态`)},...fe]})]}),(0,T.jsxs)(`div`,{className:`c2-field`,children:[(0,T.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.colType`,null,`类型`)}),(0,T.jsx)(f,{value:N,onChange:e=>{P(e||``),O(1)},style:{width:160},optionList:[{value:``,label:e(`c2.tasks.filterAllTypes`,null,`全部类型`)},...x]})]}),(0,T.jsxs)(`div`,{className:`c2-field`,children:[(0,T.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.filterSession`,null,`会话 ID`)}),(0,T.jsx)(c,{value:L,onChange:R,onEnterPress:Q,placeholder:e(`c2.tasks.filterSessionPlaceholder`,null,`s_xxxxxxxx`),style:{width:190}})]}),(0,T.jsxs)(a,{spacing:8,children:[(0,T.jsx)(s,{theme:`solid`,type:`primary`,onClick:Q,children:e(`c2.tasks.applyFilters`,null,`应用筛选`)}),(0,T.jsx)(s,{onClick:xe,children:e(`c2.tasks.resetFilters`,null,`重置`)})]})]})}),(0,T.jsx)(g,{title:e(`c2.tasks.listTitle`,null,`任务列表`),children:(0,T.jsx)(v,{columns:De,dataSource:Y,rowKey:`id`,loading:q,onRefresh:()=>J(),pagination:{currentPage:D,pageSize:A,total:X,onPageChange:e=>O(e),onPageSizeChange:e=>{_e(e),O(1)}},emptyText:e(`c2.tasks.emptyAll`,null,`暂无任务`)})}),(0,T.jsx)(ge,{visible:ve,defaultSessionId:z,submitting:ye,onCancel:()=>U(!1),onSubmit:Ee}),(0,T.jsx)(h,{visible:!!V,title:e(`c2.tasks.modalTitle`,null,`任务详情`),width:760,onCancel:()=>H(null),footer:(0,T.jsxs)(a,{children:[V&&[`queued`,`sent`,`running`].includes(V.status)&&(0,T.jsx)(s,{onClick:()=>Te(V),children:e(`c2.tasks.waitBtn`,null,`等待完成`)}),V?.resultBlobPath&&(0,T.jsx)(s,{onClick:()=>$(V),children:e(`c2.tasks.downloadResult`,null,`下载结果文件`)}),(0,T.jsx)(s,{onClick:()=>H(null),children:e(`c2.tasks.close`,null,`关闭`)})]}),children:V&&(0,T.jsxs)(`div`,{className:`c2-task-detail`,children:[(0,T.jsxs)(`div`,{className:`c2-task-detail-meta`,children:[(0,T.jsx)(`span`,{className:`c2-mono`,children:V.id}),(0,T.jsx)(o,{size:`small`,color:C[V.status]||`grey`,children:V.status}),(0,T.jsx)(k,{type:`tertiary`,size:`small`,children:ee(V.createdAt)}),(0,T.jsx)(k,{type:`tertiary`,size:`small`,children:S(V.durationMs)})]}),(0,T.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelPayload`,null,`参数`)}),(0,T.jsx)(`pre`,{className:`c2-pre`,children:JSON.stringify(V.payload||{},null,2)}),V.resultText&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelResult`,null,`输出`)}),(0,T.jsx)(`pre`,{className:`c2-pre`,children:V.resultText})]}),V.error&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelError`,null,`错误`)}),(0,T.jsx)(`pre`,{className:`c2-pre c2-pre-error`,children:V.error})]})]})})]})}export{A as default};
\ No newline at end of file
diff --git a/web/static/app/assets/chat-iFaq7TmY.js b/web/static/app/assets/chat-B-fLwI2m.js
similarity index 99%
rename from web/static/app/assets/chat-iFaq7TmY.js
rename to web/static/app/assets/chat-B-fLwI2m.js
index bd7469e4..fc4d8566 100644
--- a/web/static/app/assets/chat-iFaq7TmY.js
+++ b/web/static/app/assets/chat-B-fLwI2m.js
@@ -1,4 +1,4 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,y as i}from"./react-QV7DAAIx.js";import{$ as a,B as o,C as s,E as c,F as l,G as u,Gt as d,H as f,I as p,It as m,K as h,L as g,Lt as _,N as v,P as y,Pt as b,R as x,S,U as C,Ut as w,Vt as T,W as E,Y as D,Z as O,Zt as k,_ as ee,at as te,en as A,f as j,ft as ne,g as re,h as ie,it as ae,j as M,kt as oe,lt as N,mt as se,nn as ce,on as P,p as le,rt as ue,ut as de,v as F,vt as fe,w as pe,y as me,zt as he}from"./semi-65W_4I1v.js";import{D as I,E as L,F as R,I as ge,L as z,P as _e,S as B,V as ve,a as ye,b as V,f as be,i as xe,k as Se,l as H,n as Ce,o as we,r as Te,u as Ee,x as De,y as Oe,z as ke}from"./index-DNMXun-U.js";import{n as Ae,t as je}from"./retest-EzTZPjnQ.js";import{n as Me,t as Ne}from"./agent-handoff-DzQOcr38.js";import{t as Pe}from"./project-form-B7wV5B1p.js";import{n as Fe,r as Ie,t as U}from"./model-channel-mQ6lfvSO.js";import{n as Le,t as Re}from"./project-options-CMQbwv_U.js";var W=e(t(),1),G=e(r(),1),ze=new Set([`failed`,`timeout`,`cancelled`,`completed`,`cleanup_unconfirmed`]),Be={running:{key:`tasks.statusRunning`,fallback:`执行中`,color:`blue`},cancelling:{key:`tasks.statusCancelling`,fallback:`取消中`,color:`amber`},cleaning:{key:`tasks.statusCleaning`,fallback:`清理中`,color:`amber`},cleanup_failed:{key:`tasks.statusCleanupFailed`,fallback:`清理异常(自动重试)`,color:`orange`},cleanup_unconfirmed:{key:`tasks.statusCleanupUnconfirmed`,fallback:`远端停止状态待确认`,color:`amber`},failed:{key:`tasks.statusFailed`,fallback:`执行失败`,color:`red`},timeout:{key:`tasks.statusTimeout`,fallback:`执行超时`,color:`red`},cancelled:{key:`tasks.statusCancelled`,fallback:`已取消`,color:`grey`},completed:{key:`tasks.statusCompleted`,fallback:`已完成`,color:`green`}};function Ve(e){return(Array.isArray(e)?e:[]).filter(Boolean).slice().sort((e,t)=>{let n=Date.parse(e?.startedAt||``),r=Date.parse(t?.startedAt||``),i=Number.isFinite(n)?n:2**53-1,a=Number.isFinite(r)?r:2**53-1;if(i!==a)return i-a;let o=String(e?.conversationId||``).localeCompare(String(t?.conversationId||``));return o===0?String(e?.runId||``).localeCompare(String(t?.runId||``)):o})}function He(e,t,n,r){let i=String(e?.conversationId||``).trim();return i&&i===t&&String(n||``).trim()?String(n).trim():String(e?.title||``).trim()||String(e?.message||``).trim()||r(`tasks.unnamedTask`,null,`未命名任务`)}function Ue({tasks:e,currentConversationId:t=``,currentConversationTitle:n=``,canStop:r=!1,stoppingIds:i,onSelect:a,onStop:o}){let{lang:s,t:c}=_e(),l=(0,W.useMemo)(()=>Ve(e),[e]);return l.length?(0,G.jsx)(`div`,{className:`chat-active-tasks`,role:`region`,"aria-label":c(`dashboard.runningTasks`,null,`运行中任务`),children:l.map((e,l)=>{let u=String(e?.conversationId||``).trim(),d=String(e?.status||`running`).toLowerCase(),f=Be[d]||Be.running,p=c(f.key,null,f.fallback),m=ze.has(d),h=d===`cancelling`||!!(u&&i?.has(u)),g=!!(u&&u===t),_=He(e,t,n,c),y=Se(e?.startedAt,s),b=y===`—`?``:y,S=u?`${c(`tasks.viewConversation`,null,`查看对话`)}:${_}`:_;return(0,G.jsxs)(`div`,{className:`chat-active-task${g?` is-current`:``}${u?` is-clickable`:``}`,"data-conversation-id":u||void 0,onClick:e=>{u&&(e.target.closest(`.chat-active-task-stop`)||e.target.closest(`.chat-active-task-main`)||a?.(u))},children:[(0,G.jsxs)(`button`,{type:`button`,className:`chat-active-task-main`,disabled:!u,title:S,onClick:()=>u&&a?.(u),children:[(0,G.jsx)(v,{size:`small`,shape:`circle`,color:f.color,type:`light`,className:`chat-active-task-status`,children:p}),(0,G.jsx)(`span`,{className:`chat-active-task-title`,children:_})]}),(0,G.jsxs)(`div`,{className:`chat-active-task-actions`,children:[b?(0,G.jsx)(`span`,{className:`chat-active-task-time`,children:b}):null,!m&&(0,G.jsx)(x,{size:`small`,type:`danger`,theme:`light`,className:`chat-active-task-stop`,disabled:!r||!u||h,onClick:()=>u&&o?.(u),children:h?c(`tasks.cancelling`,null,`取消中...`):c(`tasks.stopTask`,null,`停止任务`)})]})]},e?.runId||`${u||`task`}-${l}`)})}):null}var{Text:We,Title:Ge}=u,Ke={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 qe({conversation:e,mode:t,hitlCount:n,conversationId:r,narrow:i,onToggleSidebar:a,onRefresh:o}){let s=R(),c=Ke[t]||Ke.single,l=e?.title||s(`chat.newChat`,null,`新对话`);return(0,G.jsxs)(`header`,{className:`chat-header`,children:[(0,G.jsxs)(`div`,{className:`chat-header-main`,children:[(0,G.jsxs)(`div`,{className:`chat-header-heading`,children:[(0,G.jsx)(Ge,{heading:3,className:`chat-header-title`,title:l,children:l}),(0,G.jsxs)(p,{spacing:6,wrap:!0,className:`chat-header-tags`,children:[e?.pinned&&(0,G.jsx)(v,{size:`small`,color:`amber`,children:s(`chat.pinned`,null,`已置顶`)}),(0,G.jsx)(v,{size:`small`,color:c.color,children:s(c.key,null,c.label)}),n>0&&(0,G.jsx)(v,{size:`small`,color:`orange`,children:s(`chat.pendingApprovals`,{count:n},`待审批 ${n}`)})]})]}),(0,G.jsx)(We,{type:`tertiary`,size:`small`,className:`chat-header-description`,children:r?s(`chat.conversationHint`,null,`会话历史与工具执行过程会自动落库`):s(`chat.newConversationHint`,null,`输入内容即可创建新对话`)})]}),(0,G.jsxs)(p,{spacing:8,wrap:!0,className:`chat-header-actions`,children:[i&&(0,G.jsx)(x,{icon:(0,G.jsx)(fe,{}),onClick:a,children:s(`chat.conversations`,null,`会话`)}),r&&(0,G.jsx)(x,{theme:`borderless`,type:`tertiary`,icon:(0,G.jsx)(de,{"aria-hidden":`true`}),title:s(`chat.refreshConversationHint`,null,`重新读取会话列表、消息、待审批项和执行计划`),onClick:o,children:s(`chat.refreshConversation`,null,`刷新对话`)})]})]})}var Je=[`default`,`off`,`on`,`auto`],Ye=[`low`,`medium`,`high`,`xhigh`,`max`];function Xe(e,t,n){return t!==`off`&&n?e(`chat.reasoningEffortLabels.${n}`,null,{low:`低`,medium:`中`,high:`高`,xhigh:`超高`,max:`ultra`}[n]):e(`chat.reasoningMode${t[0].toUpperCase()}${t.slice(1)}`,null,{default:`跟随系统`,off:`关闭`,on:`开启`,auto:`自动`}[t])}function Ze(e,t){let[n,r]=(0,W.useState)(()=>{try{return localStorage.getItem(e)??t}catch{return t}});return[n,t=>{r(t);try{localStorage.setItem(e,t)}catch{}}]}function Qe(e,t){return e?.image_input===`enabled`?`enabled`:e?.image_input===`disabled`?`disabled`:t===!0?`enabled`:t===!1?`disabled`:`auto`}function $e(e){let[t,n]=Ze(`cyberstrike-chat-ai-channel`,``),[r,i]=Ze(`cyberstrike-chat-reasoning-mode`,`default`),[a,o]=Ze(`cyberstrike-chat-reasoning-effort`,``),s=ye(({signal:e}={})=>z.get(`/config`,{include_tools:0},{signal:e}),[e],{skip:!e}),c=s.data?.ai,l={...s,data:c},u=Object.entries(c?.channels||{}).sort(([e],[t])=>e.localeCompare(t)),d=t.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``),f=u.find(([e])=>e===t)?.[0]||u.find(([e])=>e===d)?.[0]||``,p=f||c?.default_channel||``,m=p?c?.channels?.[p]:s.data?.openai,h=m?.reasoning?.allow_client_reasoning===!1,g=String(s.data?.vision?.model||``).trim(),_=!!(s.data?.vision?.enabled&&g),v=Qe(m,s.data?.image_input_defaults?.[p]),y=Je.includes(r)?r:`default`,b=Ye.includes(a)?a:``,x={mode:y==="default"?void 0:y,effort:y===`off`?void 0:b||void 0};return{channel:f,channels:u,setChannel:n,config:l,mode:y,setMode:i,effort:b,setEffort:o,overrideBlocked:h,vision:{ready:_,model:g,nativeMode:v},waitingForChannel:!!(e&&t&&l.loading),request:{aiChannelId:e&&f||void 0,reasoning:x.mode||x.effort?x:void 0}}}var{Text:et}=u,tt=[`off`,`approval`,`review_edit`],nt=[60,300,600,0],rt=`tool_search, skill, task, write_todos, transfer_to_agent, exit, TaskCreate, TaskGet, TaskUpdate, TaskList, upsert_project_fact, get_project_fact`;function it(e,t){return t===!1?`off`:tt.includes(e)?e:`off`}function K(e){return e===`audit_agent`?`audit_agent`:`human`}function at(e,t=300){if(e==null||e===``)return t;let n=Number(e);return Number.isFinite(n)?Math.max(0,Math.min(86400,Math.round(n))):t}function ot(e){return(Array.isArray(e)?e:String(e||``).split(/[,\n\r]+/)).map(e=>String(e||``).trim()).filter(Boolean)}function q(e,t){let n=new Set(ot(t).map(e=>e.toLowerCase()));return ot(e).filter(e=>!n.has(e.toLowerCase())).join(`, `)}function st(e,t,n){if(n)return{mode:it(n.mode,n.enabled),reviewer:K(n.reviewer),timeoutSeconds:at(n.timeoutSeconds),sensitiveTools:ot(n.sensitiveTools).join(`, `)};let r=t?e?.hitl:null;return{mode:t?it(r?.mode,r?.enabled):it(e?.defaultMode),reviewer:K(t?r?.reviewer:e?.defaultReviewer),timeoutSeconds:at(t?r?.timeoutSeconds??e?.defaultTimeoutSeconds:e?.defaultTimeoutSeconds),sensitiveTools:t?q(r?.sensitiveTools,e?.hitlGlobalToolWhitelist):rt}}function ct(e){return{enabled:e.mode!==`off`,mode:e.mode,reviewer:e.reviewer,sensitiveTools:ot(e.sensitiveTools),timeoutSeconds:e.timeoutSeconds}}function lt({label:e,...t}){let n=(0,W.useId)();return(0,G.jsxs)(`div`,{className:`chat-setting-field`,children:[(0,G.jsx)(et,{id:n,strong:!0,children:e}),(0,G.jsx)(me,{"aria-labelledby":n,...t})]})}function ut({model:e,busy:t,canReadConfig:r}){let i=R(),a=n(),o=(0,W.useId)(),s=(0,W.useRef)(null),c=e.config.data?.default_channel,l=c?U(c,e.config.data?.channels?.[c]):``,u=i(`chat.aiChannelDefault`,null,`跟随默认通道`),d=[{value:``,label:l?`${u} · ${l}`:u},...Fe(e.channels)],f=Object.fromEntries(Je.map(e=>[e,Xe(i,e,``)])),p=t||e.overrideBlocked,m=[``,...Ye],h=Object.fromEntries(m.map((e,t)=>[t,Xe(i,e?`on`:`default`,e)])),g=()=>{e.setMode(`default`),e.setEffort(``)};return(0,G.jsxs)(`div`,{className:`chat-reasoning-picker${!e.overrideBlocked&&e.mode!==`off`&&e.effort===`max`?` is-max`:``}${p?` is-disabled`:``}`,ref:s,children:[(0,G.jsxs)(`div`,{className:`chat-reasoning-heading`,children:[(0,G.jsx)(pe,{trigger:`click`,position:`bottomLeft`,className:`chat-reasoning-mode-menu`,getPopupContainer:()=>s.current,showTick:!0,menu:Je.map(t=>({node:`item`,name:f[t],active:e.mode===t,disabled:p,onClick:()=>t==="default"?g():e.setMode(t)})),children:(0,G.jsx)(x,{theme:`borderless`,type:`tertiary`,icon:(0,G.jsx)(k,{}),className:`chat-reasoning-mode`,"aria-label":i(`chat.reasoningModeLabel`,null,`模型推理`),title:`${i(`chat.reasoningModeLabel`,null,`模型推理`)} · ${f[e.overrideBlocked?`default`:e.mode]}`,disabled:p})}),(0,G.jsx)(et,{strong:!0,className:`chat-reasoning-value`,role:`status`,children:e.overrideBlocked?f.default:Xe(i,e.mode,e.effort)}),(0,G.jsx)(x,{theme:`borderless`,type:`tertiary`,icon:(0,G.jsx)(O,{}),"aria-label":i(`chat.reasoningReset`,null,`重置推理设置`),title:i(`chat.reasoningReset`,null,`重置推理设置`),disabled:p,onClick:g})]}),r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{id:o,hidden:!0,children:i(`chat.aiChannelLabel`,null,`AI 通道`)}),(0,G.jsx)(me,{className:`chat-reasoning-channel`,"aria-labelledby":o,value:e.channel,optionList:d,renderSelectedItem:e=>e.value===``?l||i(`chat.aiChannelDefaultShort`,null,`默认通道`):Ie(e),arrowIcon:(0,G.jsx)(w,{size:`small`}),borderless:!0,onSelect:e.setChannel,dropdownMatchSelectWidth:!1,dropdownStyle:{maxWidth:`calc(100vw - 32px)`},loading:e.config.loading,disabled:t||e.config.loading||!!e.config.error}),(0,G.jsx)(H,{error:e.config.error,onRetry:()=>e.config.reload()})]}):(0,G.jsx)(et,{type:`tertiary`,className:`chat-reasoning-channel-label`,children:u}),(0,G.jsx)(j,{className:`chat-reasoning-slider`,"aria-label":i(`chat.reasoningEffortLabel`,null,`推理强度`),min:0,max:m.length-1,step:1,marks:h,showMarkLabel:!1,tipFormatter:e=>h[e],getAriaValueText:t=>e.mode===`off`&&!e.overrideBlocked?f.off:h[t],value:e.overrideBlocked?0:m.indexOf(e.effort),disabled:p||e.mode===`off`,onChange:t=>{e.setEffort(m[t]),e.setMode(t===0?`default`:e.mode===`auto`?`auto`:`on`)}}),e.overrideBlocked&&(0,G.jsx)(et,{type:`tertiary`,size:`small`,className:`chat-reasoning-hint`,children:i(`chat.reasoningOverrideBlocked`,null,`此通道使用系统设置中的推理强度。`)}),r&&!e.config.loading&&!e.config.error&&(0,G.jsxs)(`div`,{className:`chat-vision-entry`,children:[(0,G.jsx)(et,{type:`tertiary`,size:`small`,className:`chat-vision-entry-status`,children:e.vision?.ready?`辅助识图:${e.vision.model}`:e.vision?.nativeMode===`enabled`?`图片识别:通道原生支持`:`当前模型不支持识图?`}),(0,G.jsx)(`button`,{type:`button`,className:`chat-vision-entry-link`,onClick:()=>a(`/settings?section=models&focus=vision`),children:e.vision?.ready?`配置`:`配置视觉模型`})]})]})}function dt({onClose:e,narrow:t,canEnableHitl:n,conversationId:r,draftHitl:i,onDraftHitlChange:a}){let o=R(),s=o(`chat.hitlTitle`,null,`人机协同`),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(!1),g=(0,W.useRef)(0),_=(0,W.useRef)(i),v=(0,W.useId)(),y=(0,W.useId)();_.current=i;let b=ye(()=>z.get(r?`/hitl/config/${encodeURIComponent(r)}`:`/hitl/default-config`),[r]);(0,W.useEffect)(()=>{b.data&&(p(st(b.data,r,_.current)),h(!1))},[b.data,r]);let x={off:o(`chat.hitlModeOff`,null,`关闭`),approval:o(`chat.hitlModeApproval`,null,`审批模式`),review_edit:o(`chat.hitlModeReviewEdit`,null,`审查编辑`)},C={60:o(`chat.hitlTimeoutOneMinute`,null,`1 分钟`),300:o(`chat.hitlTimeoutFiveMinutes`,null,`5 分钟`),600:o(`chat.hitlTimeoutTenMinutes`,null,`10 分钟`),0:o(`chat.hitlTimeoutUnlimited`,null,`不限制`)},w=nt.map(e=>({value:e,label:C[e]}));f&&!nt.includes(f.timeoutSeconds)&&w.unshift({value:f.timeoutSeconds,label:`${f.timeoutSeconds}s`});let T=!n||c,D=async e=>{let t=++g.current,n=ct(e);l(!0),d(!1);try{if(await z.put(`/hitl/config`,{conversationId:r,...n}),t!==g.current)return;b.setData(e=>({...e,hitl:n})),d(!0)}catch(e){t===g.current&&(V(e,o(`chat.hitlApplyFail`,null,`同步到服务器失败`)),b.reload({silent:!0}))}finally{t===g.current&&l(!1)}},O=e=>{let t={...f,...e};p(t),h(!1),d(!1),r?D(t):a(ct(t))};return(0,G.jsx)(le,{visible:!0,title:s,"aria-label":s,width:t?`100%`:420,closable:!c,maskClosable:!c,closeOnEsc:!c,onCancel:e,children:(0,G.jsx)(`div`,{className:`chat-settings-fields`,children:(0,G.jsxs)(`section`,{className:`chat-setting-field chat-setting-hitl`,children:[(0,G.jsx)(et,{type:`tertiary`,size:`small`,children:o(`chat.sessionSettingsHint`,null,`人机协同设置只影响后续消息。`)}),(c||u)&&(0,G.jsx)(et,{type:`tertiary`,size:`small`,role:`status`,children:c?o(`chat.systemModelSaving`,null,`正在保存…`):o(`chat.hitlApplyOkSync`,null,`人机协同配置已保存并同步到服务器。`)}),(0,G.jsx)(H,{error:b.error,onRetry:()=>b.reload()}),b.loading&&(0,G.jsx)(E,{}),f&&b.data&&!b.error&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(lt,{label:o(`chat.hitlModeLabel`,null,`模式`),value:f.mode,optionList:tt.map(e=>({value:e,label:x[e]})),onSelect:e=>O({mode:e}),disabled:T}),(0,G.jsxs)(`div`,{className:`chat-setting-field`,children:[(0,G.jsx)(et,{id:v,strong:!0,children:o(`chat.hitlReviewerLabel`,null,`审批方`)}),(0,G.jsx)(ie,{"aria-labelledby":v,type:`button`,className:`chat-setting-reviewer`,value:f.reviewer,options:[{value:`human`,label:o(`chat.hitlReviewerHuman`,null,`人工审批`)},{value:`audit_agent`,label:o(`chat.hitlReviewerAgent`,null,`审计 Agent`)}],onChange:e=>O({reviewer:e.target.value}),disabled:T}),(0,G.jsx)(et,{type:`tertiary`,size:`small`,children:o(`chat.hitlReviewerHint`,null,`可在人工与审计 Agent 之间随时切换;规则与白名单不变。人机协同为「关闭」时也可预先选择。`)})]}),(0,G.jsx)(lt,{label:o(`chat.hitlTimeoutLabel`,null,`审批等待时限`),value:f.timeoutSeconds,optionList:w,onSelect:e=>O({timeoutSeconds:Number(e)}),disabled:T}),(0,G.jsxs)(`div`,{className:`chat-setting-field`,children:[(0,G.jsx)(et,{id:y,strong:!0,children:o(`chat.hitlWhitelistTools`,null,`白名单工具(免审批,逗号分隔)`)}),(0,G.jsx)(S,{"aria-labelledby":y,value:f.sensitiveTools,placeholder:o(`chat.hitlWhitelistPlaceholder`,null,`例:read_file, grep 或每行一个工具名(与 config 全局白名单合并)`),rows:5,disabled:T,onChange:e=>{let t={...f,sensitiveTools:e};p(t),h(!0),d(!1),r||a(ct(t))},onBlur:()=>{m&&r&&!T&&(h(!1),D(f))}}),(0,G.jsx)(et,{type:`tertiary`,size:`small`,children:o(`chat.hitlWhitelistHint`,null,`白名单内工具免审批;每行一个或逗号分隔,与 config 全局白名单合并。`)})]})]})]})})})}var{Text:ft}=u;function pt({item:e,active:t,editing:n,editingTitle:r,onStartEdit:i,onEditingTitle:a,onCommitEdit:o,onCancelEdit:s,onSelect:c,onPin:l,onDelete:u,canWrite:d,canDelete:f,selected:p,onToggleSelect:m,batchMode:h}){let g=R(),v=String(e.title||g(`chat.untitled`,null,`未命名对话`));return(0,G.jsxs)(`div`,{className:`chat-conv-item ${t?`is-active`:``}`,children:[h&&(0,G.jsx)(y,{className:`chat-conv-check`,"aria-label":`${g(`chat.selectConversation`,null,`选择对话`)}:${v}`,checked:p,onChange:t=>m(e.id,t.target.checked)}),n?(0,G.jsxs)(`div`,{className:`chat-conv-edit`,children:[(0,G.jsx)(C,{size:`small`,"aria-label":g(`chat.renameConversationTitle`,null,`重命名`),value:r,autoFocus:!0,onChange:a,onEnterPress:o,onKeyDown:e=>{e.key===`Escape`&&s()}}),(0,G.jsxs)(`div`,{className:`chat-conv-edit-actions`,children:[(0,G.jsx)(x,{size:`small`,theme:`solid`,onClick:o,children:g(`common.save`,null,`保存`)}),(0,G.jsx)(x,{size:`small`,theme:`borderless`,onClick:s,children:g(`common.cancel`,null,`取消`)})]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,className:`chat-conv-main`,"aria-current":t?`true`:void 0,title:v,onClick:()=>c(e.id),children:[(0,G.jsxs)(`span`,{className:`chat-conv-title`,children:[e.pinned&&(0,G.jsx)(ae,{size:`small`,className:`chat-conv-pin`}),(0,G.jsx)(`span`,{className:`chat-conv-title-text`,children:v})]}),(0,G.jsx)(`span`,{className:`chat-conv-meta`,children:L(e.updatedAt||e.createdAt)})]}),!h&&(0,G.jsxs)(`div`,{className:`chat-conv-actions`,children:[d&&(0,G.jsx)(P,{content:g(`chat.renameConversationTitle`,null,`重命名`),children:(0,G.jsx)(x,{size:`small`,theme:`borderless`,"aria-label":g(`chat.renameConversationTitle`,null,`重命名`),icon:(0,G.jsx)(b,{}),onClick:()=>i(e)})}),d&&(0,G.jsx)(P,{content:e.pinned?g(`chat.unpin`,null,`取消置顶`):g(`chat.pin`,null,`置顶`),children:(0,G.jsx)(x,{size:`small`,theme:`borderless`,icon:(0,G.jsx)(ae,{}),"aria-label":e.pinned?g(`chat.unpin`,null,`取消置顶`):g(`chat.pin`,null,`置顶`),type:e.pinned?`warning`:`tertiary`,onClick:()=>l(e)})}),f&&(0,G.jsx)(ee,{title:g(`chat.deleteConversationConfirm`,null,`确认删除该对话?删除后不可恢复。`),onConfirm:()=>u(e),children:(0,G.jsx)(x,{size:`small`,theme:`borderless`,type:`danger`,"aria-label":g(`chat.deleteConversationTitle`,null,`删除对话`),icon:(0,G.jsx)(_,{})})})]})]})]})}function mt({items:e,groups:t,expandedGroup:n,groupTotal:r,onToggleGroup:i,loading:a,error:o,onRetry:l,search:u,onSearch:f,projectId:p,onProjectChange:m,projects:h,page:_,pageSize:v,onPageChange:b,selectedId:S,onSelect:w,onCreate:T,onRename:E,onPin:D,onDelete:O,onBatchDelete:k,canWrite:ee,canDelete:te}){let A=R(),j=e,re=(0,W.useId)(),ie=(0,W.useId)(),[ae,M]=(0,W.useState)(``),[se,ce]=(0,W.useState)(``),[P,le]=(0,W.useState)(!1),[ue,fe]=(0,W.useState)([]),pe=j.length>0&&j.every(e=>ue.includes(e.id)),he=!pe&&j.some(e=>ue.includes(e.id));(0,W.useEffect)(()=>{fe([]),le(!1)},[_,p,u,n]);let I=(0,W.useMemo)(()=>[{value:``,label:A(`chat.filterAllProjects`,null,`全部项目`)},...(Array.isArray(h)?h:[]).map(e=>({value:e.id,label:Le(e,A)}))],[h,A]),L=(e,t)=>{fe(n=>t?[...new Set([...n,e])]:n.filter(t=>t!==e))},ge=e=>{M(e.id),ce(String(e.title||``))},z=()=>{let e=ae,t=se.trim();M(``),e&&t&&E(e,t)},_e=(0,G.jsxs)(G.Fragment,{children:[a&&!j.length&&(0,G.jsx)(g,{placeholder:(0,G.jsx)(g.Paragraph,{rows:6}),loading:!0}),!a&&!o&&!j.length&&(0,G.jsx)(c,{title:A(`chat.noHistoryConversations`,null,`暂无历史对话`),description:null,className:`chat-sidebar-empty`}),(0,G.jsx)(s,{dataSource:j,split:!1,renderItem:e=>(0,G.jsx)(pt,{item:e,active:e.id===S,editing:ae===e.id,editingTitle:se,onStartEdit:ge,onEditingTitle:ce,onCommitEdit:z,onCancelEdit:()=>M(``),onSelect:w,onPin:D,onDelete:O,canWrite:ee,canDelete:te,batchMode:P,selected:ue.includes(e.id),onToggleSelect:L},e.id)})]});return(0,G.jsxs)(`div`,{className:`chat-sidebar-inner`,children:[(0,G.jsxs)(`div`,{className:`chat-sidebar-head`,children:[(0,G.jsx)(ft,{strong:!0,className:`chat-sidebar-title`,children:A(`chat.conversations`,null,`会话`)}),(0,G.jsx)(x,{icon:(0,G.jsx)(ne,{}),theme:`borderless`,className:`chat-new-chat`,onClick:T,disabled:!ee,children:A(`chat.newChat`,null,`新建对话`)})]}),(0,G.jsxs)(`div`,{className:`chat-sidebar-filters`,children:[(0,G.jsx)(C,{prefix:(0,G.jsx)(N,{}),"aria-label":A(`chat.searchHistory`,null,`搜索历史对话`),placeholder:A(`chat.searchHistory`,null,`搜索历史对话`),value:u,onChange:f,showClear:!0}),(0,G.jsx)(`span`,{id:ie,hidden:!0,children:A(`chat.filterByProject`,null,`按项目过滤`)}),(0,G.jsx)(me,{value:p,optionList:I,onChange:m,className:`chat-sidebar-project`,"aria-labelledby":ie,placeholder:A(`chat.filterByProject`,null,`按项目过滤`)})]}),(0,G.jsxs)(`div`,{className:`chat-sidebar-tools`,children:[(0,G.jsxs)(ft,{type:`tertiary`,size:`small`,children:[A(`chat.recentConversations`,null,`最近对话`),` · `,t.reduce((e,t)=>e+t.total,0)]}),(0,G.jsxs)(`div`,{className:`chat-sidebar-tools-actions`,children:[te&&j.length>0&&(0,G.jsx)(x,{size:`small`,theme:P?`solid`:`borderless`,onClick:()=>{le(!P),fe([])},children:P?A(`common.cancel`,null,`取消`):A(`chat.batchManage`,null,`批量管理`)}),(0,G.jsx)(x,{size:`small`,theme:`borderless`,"aria-label":A(`chat.refreshConversationList`,null,`刷新会话列表`),title:A(`chat.refreshConversationList`,null,`刷新会话列表`),icon:(0,G.jsx)(de,{}),onClick:l})]})]}),P&&(0,G.jsxs)(`div`,{className:`chat-batch-bar`,children:[(0,G.jsx)(y,{className:`chat-batch-select-all`,checked:pe,indeterminate:he,disabled:a||!j.length,onChange:e=>fe(e.target.checked?j.map(e=>e.id):[]),children:A(`chat.selectPage`,null,`全选本页`)}),(0,G.jsxs)(ft,{size:`small`,children:[A(`chat.selectedCount`,null,`已选`),` `,ue.length]}),(0,G.jsx)(x,{size:`small`,type:`danger`,disabled:!ue.length,onClick:async()=>{await k(ue),fe([]),le(!1)},children:A(`chat.batchDelete`,null,`批量删除`)})]}),(0,G.jsxs)(`div`,{className:`chat-conv-list`,children:[(0,G.jsx)(H,{error:o,onRetry:l}),!t.length&&!a&&!o&&(0,G.jsx)(c,{title:A(`chat.noHistoryConversations`,null,`暂无历史对话`),description:null,className:`chat-sidebar-empty`}),t.map(e=>{let t=e.id===n,r=re+`-`+e.id;return(0,G.jsxs)(`div`,{className:`chat-conv-group`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`chat-conv-group-toggle`,"aria-expanded":t,"aria-controls":r,title:e.projectId?e.title+` · `+e.projectId:e.title,onClick:()=>i(e.id),children:[(0,G.jsx)(oe,{"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`chat-conv-group-name`,children:e.title}),(0,G.jsx)(`span`,{className:`chat-conv-group-count`,children:e.total}),(0,G.jsx)(d,{"aria-hidden":`true`,className:`chat-conv-group-chevron`})]}),(0,G.jsx)(`div`,{id:r,className:`chat-conv-group-content`,hidden:!t,children:t&&_e})]},e.id)})]}),n&&r>v&&(0,G.jsx)(`div`,{className:`chat-sidebar-pager`,children:(0,G.jsx)(F,{size:`small`,total:r,pageSize:v,currentPage:_,onPageChange:b,showSizeChanger:!1})})]})}var ht=new Set([`taskcreate`,`taskupdate`,`tasklist`,`taskget`,`write_todos`]),gt=new Set([`heartbeat`,`response_delta`,`thinking_stream_delta`,`reasoning_chain_stream_delta`,`tool_result_delta`]),_t=200,vt=2e4;function J(e){return e==null?``:String(e)}function yt(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function Y(e,t=vt){let n=J(e);return n.length<=t?n:`${n.slice(0,t)}\n…(已截断,共 ${n.length} 字符)`}function X(e,t=6e3){if(e==null)return``;try{return Y(typeof e==`string`?e:JSON.stringify(e,null,2),t)}catch{return Y(String(e),t)}}function Z({conversationId:e=``,id:t}={}){return{id:t||`live-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,conversationId:e,status:`streaming`,text:``,blocks:[],toolsByCallId:new Map,events:[],error:``,notice:``,statusText:``,messageId:``,userMessageId:``,finalizable:null,startedAt:Date.now(),endedAt:0,seq:0}}function Q(e,t){return e.seq+=1,`${t}-${e.seq}`}function bt(e,t){let n=J(t.type);gt.has(n)||(e.events.push({at:Date.now(),type:n,message:J(t.message),data:t.data===void 0?null:t.data}),e.events.length>_t&&e.events.splice(0,e.events.length-_t))}function $(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===J(n))return a;let o={kind:`note`,id:Q(e,`note`),title:t,message:Y(n),tone:r,data:i};return e.blocks.push(o),o}function xt(e,t,n=`thinking`){let r=J(t)||Q(e,`reasoning`),i=r?e.blocks.find(e=>e.kind===`reasoning`&&e.key===r):null;return i||(i={kind:`reasoning`,id:Q(e,`reason`),key:r,stream:J(t),label:n,text:``},e.blocks.push(i)),i}function St(e){let t=yt(e.argumentsObj);if(t&&Object.keys(t).length)return t;let n=e.arguments??e.argumentsObj??null;if(typeof n!=`string`)return n;if(!n.trim())return null;try{return JSON.parse(n)}catch{return n}}function Ct(e){return St(yt(e?.data)||{})}function wt(e){let t=yt(e?.data)||{};return X(t.resultPreview??t.result??t.error??e?.message,8e3)}function Tt({blocks:e,toolsByCallId:t},{toolCallId:n,toolName:r,agentName:i}){let a=e=>!i||!e.agentName||e.agentName===i,o=t.get(n)?.filter(a);return o?.length?o.find(e=>!e.hasResult)||o[o.length-1]:r?e.find(e=>e.kind===`tool`&&!e.hasResult&&e.toolName===r&&a(e)&&(!n||!e.toolCallId)):null}function Et(e){let t=J(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 Dt(e,t,n,r,i,a){var o,s;let c={toolCallId:J(n.toolCallId),toolName:J(n.toolName),agentName:J(n.agentName)},l=St(n),u=t===`tool_result`,d=J(a),f=u?Tt(e,c):null;if(f?!u&&d&&!f.callDetailId&&(f.callDetailId=d):(f={kind:`tool`,id:i(`tool`),toolCallId:``,toolName:c.toolName,agentName:c.agentName,args:l,result:``,status:`running`,processDetailId:d,callDetailId:u?``:d,resultDetailId:u?d:``,argsDeferred:!!(!u&&n._argsDeferred&&d),resultDeferred:!1,hasDeferredPayload:!!(n._hasPayload||n._argsDeferred),hasResult:!1},e.blocks.push(f)),c.toolCallId&&!f.toolCallId){f.toolCallId=c.toolCallId;let t=e.toolsByCallId.get(f.toolCallId);t?t.push(f):e.toolsByCallId.set(f.toolCallId,[f])}if(!u){n._argsDeferred&&d&&(f.argsDeferred=!0,f.hasDeferredPayload=!0);return}f.hasResult=!0,(o=f).toolName||(o.toolName=c.toolName),(s=f).agentName||(s.agentName=c.agentName),d&&(f.resultDetailId=d),f.status=Et(n),l!==null&&(f.args===null||yt(f.args)&&!Object.keys(f.args).length)&&(f.args=l,f.argsDeferred=!1);let p=n.resultPreview??n.result??n.error??(J(r).trim()?r:void 0);p!=null&&J(p)!==``?(f.result=X(p,8e3),f.resultDeferred=!1):n._payloadDeferred&&n._hasPayload!==!1&&d&&(f.resultDeferred=!0,f.hasDeferredPayload=!0)}function Ot(e,t){if(!e||!t||typeof t!=`object`)return e;let n=J(t.type),r=yt(t.data)||{};switch(bt(e,t),n){case`heartbeat`:break;case`conversation`:r.conversationId&&(e.conversationId=J(r.conversationId));break;case`message_saved`:r.userMessageId&&(e.userMessageId=J(r.userMessageId));break;case`progress`:e.statusText=J(t.message)||e.statusText;break;case`iteration`:{let n=Number(r.iteration)||1,i=J(r.piScope).trim(),a=J(r.agentName).trim(),o=i===`main`?a?`主代理 · ${a}`:`主代理`:i===`sub`?`子代理${a?` · ${a}`:``}`:``;e.blocks.push({kind:`iteration`,id:Q(e,`iter`),title:`第 ${n} 轮迭代${o?` · ${o}`:``}`,message:Y(t.message,2e3)});break}case`thinking_stream_start`:case`reasoning_chain_stream_start`:{let t=xt(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=xt(e,r.streamId,n===`reasoning_chain_stream_delta`?`reasoning_chain`:`thinking`),a=typeof r.accumulated==`string`?r.accumulated:null;i.text=Y(a===null?i.text+J(t.message):a);break}case`thinking`:case`reasoning_chain`:if(r.streamId){let i=xt(e,r.streamId,n===`reasoning_chain`?`reasoning_chain`:`thinking`);J(t.message)&&(i.text=Y(t.message));break}e.blocks.push({kind:`reasoning`,id:Q(e,`reason`),key:Q(e,`reasonkey`),stream:``,label:n===`reasoning_chain`?`reasoning_chain`:`thinking`,text:Y(t.message)});break;case`response_start`:r.conversationId&&(e.conversationId=J(r.conversationId)),e.statusText||(e.statusText=`正在生成回复…`);break;case`response_delta`:{let n=typeof r.accumulated==`string`?r.accumulated:null;e.text=Y(n===null?e.text+J(t.message):n,6e4);break}case`response`:{let n=J(t.message);n&&(e.text=Y(n,6e4)),r.messageId&&(e.messageId=J(r.messageId)),r.conversationId&&(e.conversationId=J(r.conversationId)),r.finalizable===!1?e.finalizable=!1:r.finalizable===!0&&(e.finalizable=!0);break}case`tool_call`:case`tool_result`:Dt(e,n,r,t.message,t=>Q(e,t),r.processDetailId);break;case`tool_calls_detected`:$(e,{title:`🔧 检测到工具调用`,message:t.message,data:r});break;case`hitl_interrupt`:$(e,{title:`🧑⚖️ 等待人工审批`,message:`${J(r.toolName)||`工具`} · ${J(t.message)||`命中审批策略`}`,tone:`warning`,data:r});break;case`hitl_resumed`:$(e,{title:`✅ 审批通过`,message:J(t.message),tone:`success`,data:r});break;case`hitl_rejected`:$(e,{title:`⛔ 审批被拒绝`,message:J(t.message),tone:`danger`,data:r});break;case`hitl_audit_agent_started`:$(e,{title:`🛡 审计代理审查中`,message:J(t.message),tone:`info`,data:r});break;case`hitl_audit_agent`:$(e,{title:`🛡 审计代理已裁决`,message:`${J(r.decision)||`-`}${r.comment?` · ${J(r.comment)}`:``}`,tone:`info`,data:r});break;case`warning`:case`iteration_limit_reached`:case`pi_pending_orphaned`:$(e,{title:`⚠️ ${J(t.message)||`提示`}`,message:J(t.message),tone:`warning`,data:r});break;case`finalization_check`:$(e,{title:`🔎 最终化校验未通过`,message:J(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`:$(e,{title:J(t.message)||`运行提示`,message:J(t.message),tone:`warning`,data:r});break;case`agent_usage_summary`:e.blocks.push({kind:`usage`,id:Q(e,`usage`),data:r});break;case`user_interrupt_continue`:$(e,{title:`⏸️ 用户中断并继续`,message:J(t.message),tone:`info`,data:r});break;case`agent_reply`:$(e,{title:`💬 ${J(r.agentName)||`子代理`}回复`,message:J(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`:$(e,{title:`🧭 ${J(t.message)||n}`,message:J(t.message),data:r});break;case`cancelled`:e.status=`cancelled`,e.notice=J(t.message)||`任务已取消`,e.endedAt=Date.now();break;case`error`:e.status=`error`,e.error=J(t.message)||`执行失败`,e.endedAt=Date.now();break;case`done`:e.status===`streaming`&&(e.status=r.status===`blocked`||e.finalizable===!1?`blocked`:`done`),r.workflowStatus===`awaiting_hitl`&&(e.statusText=`工作流等待审批`),e.endedAt=Date.now()}return e}var kt={streaming:{label:`生成中`,color:`blue`},done:{label:`已完成`,color:`green`},blocked:{label:`未完成`,color:`orange`},disconnected:{label:`连接已结束`,color:`grey`},error:{label:`失败`,color:`red`},cancelled:{label:`已取消`,color:`grey`}};function At(e){let t=[],n={blocks:t,toolsByCallId:new Map},r=0,i=e=>(r+=1,`h-${e}-${r}`),a=J(e?.reasoningContent).trim();return a&&t.push({kind:`reasoning`,id:i(`reason`),key:`reasoningContent`,stream:``,label:`thinking`,text:Y(a)}),(Array.isArray(e?.processDetails)?e.processDetails:[]).forEach(e=>{let r=J(e?.eventType),a=yt(e?.data)||{},o=J(e?.message);switch(r){case`iteration`:{let e=Number(a.iteration)||1,n=J(a.piScope).trim(),r=J(a.agentName).trim();t.push({kind:`iteration`,id:i(`iter`),title:`第 ${e} 轮迭代${n===`main`?` · 主代理`:n===`sub`?` · 子代理`:``}${r?` · ${r}`:``}`,message:Y(o,2e3)});break}case`thinking`:case`reasoning_chain`:{let n=!!(a._payloadDeferred&&e?.id&&!o.trim());if(!o.trim()&&!n)break;t.push({kind:`reasoning`,id:i(`reason`),detailId:J(e?.id),key:J(a.streamId)||i(`reasonkey`),stream:J(a.streamId),label:r,text:n?``:Y(o),textLength:n?Number(a._textLength)||0:o.length,payloadDeferred:n});break}case`tool_call`:case`tool_result`:Dt(n,r,a,o,i,e?.id);break;case`planning`:if(!o.trim())break;t.push({kind:`note`,id:i(`note`),title:`📝 规划`,message:Y(o,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=r===`hitl_rejected`?`danger`:r===`hitl_resumed`?`success`:`info`,n=r===`hitl_interrupt`?`🧑⚖️ 人工审批`:r===`hitl_rejected`?`⛔ 审批被拒绝`:r===`hitl_resumed`?`✅ 审批通过`:`🛡 审计代理`;t.push({kind:`note`,id:i(`note`),title:n,message:`${o}${a.toolName?` · ${J(a.toolName)}`:``}${a.decision?` · ${J(a.decision)}`:``}`,tone:e,data:null});break}case`error`:case`timeout`:case`cancelled`:t.push({kind:`note`,id:i(`note`),title:r===`cancelled`?`⏹ 已取消`:`❌ 执行异常`,message:o,tone:`danger`,data:null});break;case`agent_reply`:t.push({kind:`note`,id:i(`note`),title:`💬 子代理回复`,message:Y(o,6e3),tone:`info`,data:null});break;case`agent_usage_summary`:t.push({kind:`usage`,id:i(`usage`),data:a});break;case`progress`:break;default:(o.trim()||Object.keys(a).length)&&t.push({kind:`note`,id:i(`note`),title:J(r)||`过程事件`,message:Y(o,4e3),tone:`info`,data:Object.keys(a).length?a:null})}}),t}var{Text:jt}=u,Mt={running:{color:`blue`,label:`执行中`},success:{color:`green`,label:`完成`},failed:{color:`red`,label:`失败`},cancelled:{color:`grey`,label:`已取消`},blocked:{color:`orange`,label:`已拦截`}};function Nt(e){return Array.isArray(e)?e.includes(`1`):e===`1`}function Pt({block:e,defaultOpen:t}){let[n,r]=(0,W.useState)(!!t),[i,a]=(0,W.useState)(``),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(``),u=(0,W.useRef)(null),d=e.text||i,f=d?d.length:Number(e.textLength)||0,p=!!(e.payloadDeferred&&e.detailId&&!d),m=(0,W.useCallback)(async()=>{if(!e.detailId)return;u.current?.abort();let t=new AbortController;u.current=t,s(!0),l(``);try{let n=await z.get(`/process-details/${encodeURIComponent(e.detailId)}`,null,{signal:t.signal});if(t.signal.aborted)return;let r=n?.processDetail;a(String(r?.message||``))}catch(e){t.signal.aborted||l(ke(e,`加载思考过程失败`))}finally{u.current===t&&(u.current=null,s(!1))}},[e.detailId]);(0,W.useEffect)(()=>()=>u.current?.abort(),[]),(0,W.useEffect)(()=>{n&&p&&!o&&!c&&m()},[n,p,o,c,m]);let h=(0,W.useMemo)(()=>n&&d?Y(d):``,[n,d]);if(!d.trim()&&!e.payloadDeferred)return null;let g=e.label===`reasoning_chain`?`🔗 推理过程`:`🤔 思考过程`;return(0,G.jsx)(M,{className:`chat-block-collapse`,activeKey:n?[`1`]:[],onChange:e=>r(Nt(e)),children:(0,G.jsxs)(M.Panel,{itemKey:`1`,header:(0,G.jsxs)(`span`,{className:`chat-block-title`,children:[g,` · `,f,` 字符`]}),children:[n&&o&&(0,G.jsxs)(`div`,{className:`chat-tool-loading`,children:[(0,G.jsx)(E,{size:`small`}),(0,G.jsx)(`span`,{children:`正在加载思考过程…`})]}),n&&c&&(0,G.jsxs)(`div`,{className:`chat-tool-error`,children:[(0,G.jsx)(`span`,{children:c}),(0,G.jsx)(`button`,{type:`button`,className:`chat-link-btn`,onClick:()=>void m(),children:`重试`})]}),n&&h&&(0,G.jsx)(`pre`,{className:`chat-pre`,children:h})]})})}function Ft({block:e,index:t,total:n}){let{t:r}=_e(),[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(void 0),[c,l]=(0,W.useState)(void 0),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(``),m=(0,W.useRef)(null),h=Mt[e.status]||Mt.running,g=o===void 0?e.args:o,_=c===void 0?e.result||``:c,y=!!(e.argsDeferred&&e.callDetailId&&o===void 0),b=!!(e.resultDeferred&&e.resultDetailId&&c===void 0),x=!!(g!=null&&g!==``||_||y||b||e.hasDeferredPayload),S=(0,W.useCallback)(async()=>{let t=[];if(y&&e.callDetailId&&t.push({kind:`args`,id:e.callDetailId}),b&&e.resultDetailId&&t.push({kind:`result`,id:e.resultDetailId}),!t.length)return;m.current?.abort();let n=new AbortController;m.current=n,d(!0),p(``);try{let e=await Promise.all(t.map(async e=>{let t=await z.get(`/process-details/${encodeURIComponent(e.id)}`,null,{signal:n.signal});return{kind:e.kind,detail:t?.processDetail||null}}));if(n.signal.aborted)return;for(let t of e)t.kind===`args`?s(Ct(t.detail)):t.kind===`result`&&l(wt(t.detail))}catch(e){n.signal.aborted||p(ke(e,`加载工具详情失败`))}finally{m.current===n&&(m.current=null,d(!1))}},[e.callDetailId,e.resultDetailId,y,b]);(0,W.useEffect)(()=>()=>m.current?.abort(),[]),(0,W.useEffect)(()=>{i&&(y||b)&&!u&&!f&&S()},[i,y,b,u,f,S]);let C=(0,W.useMemo)(()=>i?X(g):``,[i,g]),w=i?_:``,T=e.toolName||r(`chat.unknownTool`,null,`未知工具`),D=(0,G.jsxs)(`span`,{className:`chat-tool-head`,children:[(0,G.jsxs)(`span`,{className:`chat-tool-name`,children:[e.agentName?`${e.agentName} · `:``,r(`chat.callTool`,{name:T,index:t,total:n},`调用工具: ${T} (${t}/${n})`)]}),(0,G.jsx)(v,{size:`small`,color:h.color,shape:`circle`,children:h.label})]});return x?(0,G.jsx)(`div`,{className:`chat-tool`,children:(0,G.jsx)(M,{className:`chat-block-collapse`,activeKey:i?[`1`]:[],onChange:e=>a(Nt(e)),children:(0,G.jsxs)(M.Panel,{itemKey:`1`,header:D,children:[i&&u&&(0,G.jsxs)(`div`,{className:`chat-tool-loading`,children:[(0,G.jsx)(E,{size:`small`}),(0,G.jsx)(`span`,{children:`正在加载工具详情…`})]}),i&&f&&(0,G.jsxs)(`div`,{className:`chat-tool-error`,children:[(0,G.jsx)(`span`,{children:f}),(0,G.jsx)(`button`,{type:`button`,className:`chat-link-btn`,onClick:()=>void S(),children:`重试`})]}),i&&C&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(jt,{type:`tertiary`,size:`small`,children:`参数`}),(0,G.jsx)(`pre`,{className:`chat-pre`,children:C})]}),i&&w&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(jt,{type:`tertiary`,size:`small`,children:`结果`}),(0,G.jsx)(`pre`,{className:`chat-pre`,children:w})]})]})})}):(0,G.jsx)(`div`,{className:`chat-tool`,children:(0,G.jsx)(`div`,{className:`chat-tool-head-row`,children:D})})}function It({block:e}){let[t,n]=(0,W.useState)(!1),r=e.tone||`info`;return(0,G.jsxs)(`div`,{className:`chat-note chat-note-${r}`,children:[(0,G.jsxs)(`div`,{className:`chat-note-head`,children:[(0,G.jsx)(`span`,{className:`chat-note-title`,children:e.title}),e.data&&(0,G.jsx)(`button`,{type:`button`,className:`chat-link-btn`,onClick:()=>n(!t),children:t?`收起 JSON`:`查看 JSON`})]}),e.message&&(0,G.jsx)(`div`,{className:`chat-note-body`,children:e.message}),t&&e.data&&(0,G.jsx)(Ee,{value:e.data,collapsed:!1,title:`事件数据`})]})}function Lt({data:e}){let{t,lang:n}=_e(),r=e=>I(Math.max(0,Math.trunc(Number(e)||0)),n),i=[[`chat.piUsageModelCalls`,e.modelCalls],[`chat.piUsagePromptTokens`,e.promptTokens],[`chat.piUsageCompletionTokens`,e.completionTokens],[`chat.piUsageTotalTokens`,e.totalTokens]],a=[[`chat.piUsageCachedTokens`,e.cachedTokens],[`chat.piUsageCacheWriteTokens`,e.cacheWriteTokens],[`chat.piUsageReasoningTokens`,e.reasoningTokens]],o=[...i,...a.filter(([,e])=>Number(e)>0)].map(([e,n])=>`${t(e)}: ${r(n)}`).join(`
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,y as i}from"./react-QV7DAAIx.js";import{$ as a,B as o,C as s,E as c,F as l,G as u,Gt as d,H as f,I as p,It as m,K as h,L as g,Lt as _,N as v,P as y,Pt as b,R as x,S,U as C,Ut as w,Vt as T,W as E,Y as D,Z as O,Zt as k,_ as ee,at as te,en as A,f as j,ft as ne,g as re,h as ie,it as ae,j as M,kt as oe,lt as N,mt as se,nn as ce,on as P,p as le,rt as ue,ut as de,v as F,vt as fe,w as pe,y as me,zt as he}from"./semi-65W_4I1v.js";import{D as I,E as L,F as R,I as ge,L as z,P as _e,S as B,V as ve,a as ye,b as V,f as be,i as xe,k as Se,l as H,n as Ce,o as we,r as Te,u as Ee,x as De,y as Oe,z as ke}from"./index-C6SML8F9.js";import{n as Ae,t as je}from"./retest-EzTZPjnQ.js";import{n as Me,t as Ne}from"./agent-handoff-DzQOcr38.js";import{t as Pe}from"./project-form-BPnSRCJ9.js";import{n as Fe,r as Ie,t as U}from"./model-channel-mQ6lfvSO.js";import{n as Le,t as Re}from"./project-options-CMQbwv_U.js";var W=e(t(),1),G=e(r(),1),ze=new Set([`failed`,`timeout`,`cancelled`,`completed`,`cleanup_unconfirmed`]),Be={running:{key:`tasks.statusRunning`,fallback:`执行中`,color:`blue`},cancelling:{key:`tasks.statusCancelling`,fallback:`取消中`,color:`amber`},cleaning:{key:`tasks.statusCleaning`,fallback:`清理中`,color:`amber`},cleanup_failed:{key:`tasks.statusCleanupFailed`,fallback:`清理异常(自动重试)`,color:`orange`},cleanup_unconfirmed:{key:`tasks.statusCleanupUnconfirmed`,fallback:`远端停止状态待确认`,color:`amber`},failed:{key:`tasks.statusFailed`,fallback:`执行失败`,color:`red`},timeout:{key:`tasks.statusTimeout`,fallback:`执行超时`,color:`red`},cancelled:{key:`tasks.statusCancelled`,fallback:`已取消`,color:`grey`},completed:{key:`tasks.statusCompleted`,fallback:`已完成`,color:`green`}};function Ve(e){return(Array.isArray(e)?e:[]).filter(Boolean).slice().sort((e,t)=>{let n=Date.parse(e?.startedAt||``),r=Date.parse(t?.startedAt||``),i=Number.isFinite(n)?n:2**53-1,a=Number.isFinite(r)?r:2**53-1;if(i!==a)return i-a;let o=String(e?.conversationId||``).localeCompare(String(t?.conversationId||``));return o===0?String(e?.runId||``).localeCompare(String(t?.runId||``)):o})}function He(e,t,n,r){let i=String(e?.conversationId||``).trim();return i&&i===t&&String(n||``).trim()?String(n).trim():String(e?.title||``).trim()||String(e?.message||``).trim()||r(`tasks.unnamedTask`,null,`未命名任务`)}function Ue({tasks:e,currentConversationId:t=``,currentConversationTitle:n=``,canStop:r=!1,stoppingIds:i,onSelect:a,onStop:o}){let{lang:s,t:c}=_e(),l=(0,W.useMemo)(()=>Ve(e),[e]);return l.length?(0,G.jsx)(`div`,{className:`chat-active-tasks`,role:`region`,"aria-label":c(`dashboard.runningTasks`,null,`运行中任务`),children:l.map((e,l)=>{let u=String(e?.conversationId||``).trim(),d=String(e?.status||`running`).toLowerCase(),f=Be[d]||Be.running,p=c(f.key,null,f.fallback),m=ze.has(d),h=d===`cancelling`||!!(u&&i?.has(u)),g=!!(u&&u===t),_=He(e,t,n,c),y=Se(e?.startedAt,s),b=y===`—`?``:y,S=u?`${c(`tasks.viewConversation`,null,`查看对话`)}:${_}`:_;return(0,G.jsxs)(`div`,{className:`chat-active-task${g?` is-current`:``}${u?` is-clickable`:``}`,"data-conversation-id":u||void 0,onClick:e=>{u&&(e.target.closest(`.chat-active-task-stop`)||e.target.closest(`.chat-active-task-main`)||a?.(u))},children:[(0,G.jsxs)(`button`,{type:`button`,className:`chat-active-task-main`,disabled:!u,title:S,onClick:()=>u&&a?.(u),children:[(0,G.jsx)(v,{size:`small`,shape:`circle`,color:f.color,type:`light`,className:`chat-active-task-status`,children:p}),(0,G.jsx)(`span`,{className:`chat-active-task-title`,children:_})]}),(0,G.jsxs)(`div`,{className:`chat-active-task-actions`,children:[b?(0,G.jsx)(`span`,{className:`chat-active-task-time`,children:b}):null,!m&&(0,G.jsx)(x,{size:`small`,type:`danger`,theme:`light`,className:`chat-active-task-stop`,disabled:!r||!u||h,onClick:()=>u&&o?.(u),children:h?c(`tasks.cancelling`,null,`取消中...`):c(`tasks.stopTask`,null,`停止任务`)})]})]},e?.runId||`${u||`task`}-${l}`)})}):null}var{Text:We,Title:Ge}=u,Ke={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 qe({conversation:e,mode:t,hitlCount:n,conversationId:r,narrow:i,onToggleSidebar:a,onRefresh:o}){let s=R(),c=Ke[t]||Ke.single,l=e?.title||s(`chat.newChat`,null,`新对话`);return(0,G.jsxs)(`header`,{className:`chat-header`,children:[(0,G.jsxs)(`div`,{className:`chat-header-main`,children:[(0,G.jsxs)(`div`,{className:`chat-header-heading`,children:[(0,G.jsx)(Ge,{heading:3,className:`chat-header-title`,title:l,children:l}),(0,G.jsxs)(p,{spacing:6,wrap:!0,className:`chat-header-tags`,children:[e?.pinned&&(0,G.jsx)(v,{size:`small`,color:`amber`,children:s(`chat.pinned`,null,`已置顶`)}),(0,G.jsx)(v,{size:`small`,color:c.color,children:s(c.key,null,c.label)}),n>0&&(0,G.jsx)(v,{size:`small`,color:`orange`,children:s(`chat.pendingApprovals`,{count:n},`待审批 ${n}`)})]})]}),(0,G.jsx)(We,{type:`tertiary`,size:`small`,className:`chat-header-description`,children:r?s(`chat.conversationHint`,null,`会话历史与工具执行过程会自动落库`):s(`chat.newConversationHint`,null,`输入内容即可创建新对话`)})]}),(0,G.jsxs)(p,{spacing:8,wrap:!0,className:`chat-header-actions`,children:[i&&(0,G.jsx)(x,{icon:(0,G.jsx)(fe,{}),onClick:a,children:s(`chat.conversations`,null,`会话`)}),r&&(0,G.jsx)(x,{theme:`borderless`,type:`tertiary`,icon:(0,G.jsx)(de,{"aria-hidden":`true`}),title:s(`chat.refreshConversationHint`,null,`重新读取会话列表、消息、待审批项和执行计划`),onClick:o,children:s(`chat.refreshConversation`,null,`刷新对话`)})]})]})}var Je=[`default`,`off`,`on`,`auto`],Ye=[`low`,`medium`,`high`,`xhigh`,`max`];function Xe(e,t,n){return t!==`off`&&n?e(`chat.reasoningEffortLabels.${n}`,null,{low:`低`,medium:`中`,high:`高`,xhigh:`超高`,max:`ultra`}[n]):e(`chat.reasoningMode${t[0].toUpperCase()}${t.slice(1)}`,null,{default:`跟随系统`,off:`关闭`,on:`开启`,auto:`自动`}[t])}function Ze(e,t){let[n,r]=(0,W.useState)(()=>{try{return localStorage.getItem(e)??t}catch{return t}});return[n,t=>{r(t);try{localStorage.setItem(e,t)}catch{}}]}function Qe(e,t){return e?.image_input===`enabled`?`enabled`:e?.image_input===`disabled`?`disabled`:t===!0?`enabled`:t===!1?`disabled`:`auto`}function $e(e){let[t,n]=Ze(`cyberstrike-chat-ai-channel`,``),[r,i]=Ze(`cyberstrike-chat-reasoning-mode`,`default`),[a,o]=Ze(`cyberstrike-chat-reasoning-effort`,``),s=ye(({signal:e}={})=>z.get(`/config`,{include_tools:0},{signal:e}),[e],{skip:!e}),c=s.data?.ai,l={...s,data:c},u=Object.entries(c?.channels||{}).sort(([e],[t])=>e.localeCompare(t)),d=t.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``),f=u.find(([e])=>e===t)?.[0]||u.find(([e])=>e===d)?.[0]||``,p=f||c?.default_channel||``,m=p?c?.channels?.[p]:s.data?.openai,h=m?.reasoning?.allow_client_reasoning===!1,g=String(s.data?.vision?.model||``).trim(),_=!!(s.data?.vision?.enabled&&g),v=Qe(m,s.data?.image_input_defaults?.[p]),y=Je.includes(r)?r:`default`,b=Ye.includes(a)?a:``,x={mode:y==="default"?void 0:y,effort:y===`off`?void 0:b||void 0};return{channel:f,channels:u,setChannel:n,config:l,mode:y,setMode:i,effort:b,setEffort:o,overrideBlocked:h,vision:{ready:_,model:g,nativeMode:v},waitingForChannel:!!(e&&t&&l.loading),request:{aiChannelId:e&&f||void 0,reasoning:x.mode||x.effort?x:void 0}}}var{Text:et}=u,tt=[`off`,`approval`,`review_edit`],nt=[60,300,600,0],rt=`tool_search, skill, task, write_todos, transfer_to_agent, exit, TaskCreate, TaskGet, TaskUpdate, TaskList, upsert_project_fact, get_project_fact`;function it(e,t){return t===!1?`off`:tt.includes(e)?e:`off`}function K(e){return e===`audit_agent`?`audit_agent`:`human`}function at(e,t=300){if(e==null||e===``)return t;let n=Number(e);return Number.isFinite(n)?Math.max(0,Math.min(86400,Math.round(n))):t}function ot(e){return(Array.isArray(e)?e:String(e||``).split(/[,\n\r]+/)).map(e=>String(e||``).trim()).filter(Boolean)}function q(e,t){let n=new Set(ot(t).map(e=>e.toLowerCase()));return ot(e).filter(e=>!n.has(e.toLowerCase())).join(`, `)}function st(e,t,n){if(n)return{mode:it(n.mode,n.enabled),reviewer:K(n.reviewer),timeoutSeconds:at(n.timeoutSeconds),sensitiveTools:ot(n.sensitiveTools).join(`, `)};let r=t?e?.hitl:null;return{mode:t?it(r?.mode,r?.enabled):it(e?.defaultMode),reviewer:K(t?r?.reviewer:e?.defaultReviewer),timeoutSeconds:at(t?r?.timeoutSeconds??e?.defaultTimeoutSeconds:e?.defaultTimeoutSeconds),sensitiveTools:t?q(r?.sensitiveTools,e?.hitlGlobalToolWhitelist):rt}}function ct(e){return{enabled:e.mode!==`off`,mode:e.mode,reviewer:e.reviewer,sensitiveTools:ot(e.sensitiveTools),timeoutSeconds:e.timeoutSeconds}}function lt({label:e,...t}){let n=(0,W.useId)();return(0,G.jsxs)(`div`,{className:`chat-setting-field`,children:[(0,G.jsx)(et,{id:n,strong:!0,children:e}),(0,G.jsx)(me,{"aria-labelledby":n,...t})]})}function ut({model:e,busy:t,canReadConfig:r}){let i=R(),a=n(),o=(0,W.useId)(),s=(0,W.useRef)(null),c=e.config.data?.default_channel,l=c?U(c,e.config.data?.channels?.[c]):``,u=i(`chat.aiChannelDefault`,null,`跟随默认通道`),d=[{value:``,label:l?`${u} · ${l}`:u},...Fe(e.channels)],f=Object.fromEntries(Je.map(e=>[e,Xe(i,e,``)])),p=t||e.overrideBlocked,m=[``,...Ye],h=Object.fromEntries(m.map((e,t)=>[t,Xe(i,e?`on`:`default`,e)])),g=()=>{e.setMode(`default`),e.setEffort(``)};return(0,G.jsxs)(`div`,{className:`chat-reasoning-picker${!e.overrideBlocked&&e.mode!==`off`&&e.effort===`max`?` is-max`:``}${p?` is-disabled`:``}`,ref:s,children:[(0,G.jsxs)(`div`,{className:`chat-reasoning-heading`,children:[(0,G.jsx)(pe,{trigger:`click`,position:`bottomLeft`,className:`chat-reasoning-mode-menu`,getPopupContainer:()=>s.current,showTick:!0,menu:Je.map(t=>({node:`item`,name:f[t],active:e.mode===t,disabled:p,onClick:()=>t==="default"?g():e.setMode(t)})),children:(0,G.jsx)(x,{theme:`borderless`,type:`tertiary`,icon:(0,G.jsx)(k,{}),className:`chat-reasoning-mode`,"aria-label":i(`chat.reasoningModeLabel`,null,`模型推理`),title:`${i(`chat.reasoningModeLabel`,null,`模型推理`)} · ${f[e.overrideBlocked?`default`:e.mode]}`,disabled:p})}),(0,G.jsx)(et,{strong:!0,className:`chat-reasoning-value`,role:`status`,children:e.overrideBlocked?f.default:Xe(i,e.mode,e.effort)}),(0,G.jsx)(x,{theme:`borderless`,type:`tertiary`,icon:(0,G.jsx)(O,{}),"aria-label":i(`chat.reasoningReset`,null,`重置推理设置`),title:i(`chat.reasoningReset`,null,`重置推理设置`),disabled:p,onClick:g})]}),r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{id:o,hidden:!0,children:i(`chat.aiChannelLabel`,null,`AI 通道`)}),(0,G.jsx)(me,{className:`chat-reasoning-channel`,"aria-labelledby":o,value:e.channel,optionList:d,renderSelectedItem:e=>e.value===``?l||i(`chat.aiChannelDefaultShort`,null,`默认通道`):Ie(e),arrowIcon:(0,G.jsx)(w,{size:`small`}),borderless:!0,onSelect:e.setChannel,dropdownMatchSelectWidth:!1,dropdownStyle:{maxWidth:`calc(100vw - 32px)`},loading:e.config.loading,disabled:t||e.config.loading||!!e.config.error}),(0,G.jsx)(H,{error:e.config.error,onRetry:()=>e.config.reload()})]}):(0,G.jsx)(et,{type:`tertiary`,className:`chat-reasoning-channel-label`,children:u}),(0,G.jsx)(j,{className:`chat-reasoning-slider`,"aria-label":i(`chat.reasoningEffortLabel`,null,`推理强度`),min:0,max:m.length-1,step:1,marks:h,showMarkLabel:!1,tipFormatter:e=>h[e],getAriaValueText:t=>e.mode===`off`&&!e.overrideBlocked?f.off:h[t],value:e.overrideBlocked?0:m.indexOf(e.effort),disabled:p||e.mode===`off`,onChange:t=>{e.setEffort(m[t]),e.setMode(t===0?`default`:e.mode===`auto`?`auto`:`on`)}}),e.overrideBlocked&&(0,G.jsx)(et,{type:`tertiary`,size:`small`,className:`chat-reasoning-hint`,children:i(`chat.reasoningOverrideBlocked`,null,`此通道使用系统设置中的推理强度。`)}),r&&!e.config.loading&&!e.config.error&&(0,G.jsxs)(`div`,{className:`chat-vision-entry`,children:[(0,G.jsx)(et,{type:`tertiary`,size:`small`,className:`chat-vision-entry-status`,children:e.vision?.ready?`辅助识图:${e.vision.model}`:e.vision?.nativeMode===`enabled`?`图片识别:通道原生支持`:`当前模型不支持识图?`}),(0,G.jsx)(`button`,{type:`button`,className:`chat-vision-entry-link`,onClick:()=>a(`/settings?section=models&focus=vision`),children:e.vision?.ready?`配置`:`配置视觉模型`})]})]})}function dt({onClose:e,narrow:t,canEnableHitl:n,conversationId:r,draftHitl:i,onDraftHitlChange:a}){let o=R(),s=o(`chat.hitlTitle`,null,`人机协同`),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(!1),g=(0,W.useRef)(0),_=(0,W.useRef)(i),v=(0,W.useId)(),y=(0,W.useId)();_.current=i;let b=ye(()=>z.get(r?`/hitl/config/${encodeURIComponent(r)}`:`/hitl/default-config`),[r]);(0,W.useEffect)(()=>{b.data&&(p(st(b.data,r,_.current)),h(!1))},[b.data,r]);let x={off:o(`chat.hitlModeOff`,null,`关闭`),approval:o(`chat.hitlModeApproval`,null,`审批模式`),review_edit:o(`chat.hitlModeReviewEdit`,null,`审查编辑`)},C={60:o(`chat.hitlTimeoutOneMinute`,null,`1 分钟`),300:o(`chat.hitlTimeoutFiveMinutes`,null,`5 分钟`),600:o(`chat.hitlTimeoutTenMinutes`,null,`10 分钟`),0:o(`chat.hitlTimeoutUnlimited`,null,`不限制`)},w=nt.map(e=>({value:e,label:C[e]}));f&&!nt.includes(f.timeoutSeconds)&&w.unshift({value:f.timeoutSeconds,label:`${f.timeoutSeconds}s`});let T=!n||c,D=async e=>{let t=++g.current,n=ct(e);l(!0),d(!1);try{if(await z.put(`/hitl/config`,{conversationId:r,...n}),t!==g.current)return;b.setData(e=>({...e,hitl:n})),d(!0)}catch(e){t===g.current&&(V(e,o(`chat.hitlApplyFail`,null,`同步到服务器失败`)),b.reload({silent:!0}))}finally{t===g.current&&l(!1)}},O=e=>{let t={...f,...e};p(t),h(!1),d(!1),r?D(t):a(ct(t))};return(0,G.jsx)(le,{visible:!0,title:s,"aria-label":s,width:t?`100%`:420,closable:!c,maskClosable:!c,closeOnEsc:!c,onCancel:e,children:(0,G.jsx)(`div`,{className:`chat-settings-fields`,children:(0,G.jsxs)(`section`,{className:`chat-setting-field chat-setting-hitl`,children:[(0,G.jsx)(et,{type:`tertiary`,size:`small`,children:o(`chat.sessionSettingsHint`,null,`人机协同设置只影响后续消息。`)}),(c||u)&&(0,G.jsx)(et,{type:`tertiary`,size:`small`,role:`status`,children:c?o(`chat.systemModelSaving`,null,`正在保存…`):o(`chat.hitlApplyOkSync`,null,`人机协同配置已保存并同步到服务器。`)}),(0,G.jsx)(H,{error:b.error,onRetry:()=>b.reload()}),b.loading&&(0,G.jsx)(E,{}),f&&b.data&&!b.error&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(lt,{label:o(`chat.hitlModeLabel`,null,`模式`),value:f.mode,optionList:tt.map(e=>({value:e,label:x[e]})),onSelect:e=>O({mode:e}),disabled:T}),(0,G.jsxs)(`div`,{className:`chat-setting-field`,children:[(0,G.jsx)(et,{id:v,strong:!0,children:o(`chat.hitlReviewerLabel`,null,`审批方`)}),(0,G.jsx)(ie,{"aria-labelledby":v,type:`button`,className:`chat-setting-reviewer`,value:f.reviewer,options:[{value:`human`,label:o(`chat.hitlReviewerHuman`,null,`人工审批`)},{value:`audit_agent`,label:o(`chat.hitlReviewerAgent`,null,`审计 Agent`)}],onChange:e=>O({reviewer:e.target.value}),disabled:T}),(0,G.jsx)(et,{type:`tertiary`,size:`small`,children:o(`chat.hitlReviewerHint`,null,`可在人工与审计 Agent 之间随时切换;规则与白名单不变。人机协同为「关闭」时也可预先选择。`)})]}),(0,G.jsx)(lt,{label:o(`chat.hitlTimeoutLabel`,null,`审批等待时限`),value:f.timeoutSeconds,optionList:w,onSelect:e=>O({timeoutSeconds:Number(e)}),disabled:T}),(0,G.jsxs)(`div`,{className:`chat-setting-field`,children:[(0,G.jsx)(et,{id:y,strong:!0,children:o(`chat.hitlWhitelistTools`,null,`白名单工具(免审批,逗号分隔)`)}),(0,G.jsx)(S,{"aria-labelledby":y,value:f.sensitiveTools,placeholder:o(`chat.hitlWhitelistPlaceholder`,null,`例:read_file, grep 或每行一个工具名(与 config 全局白名单合并)`),rows:5,disabled:T,onChange:e=>{let t={...f,sensitiveTools:e};p(t),h(!0),d(!1),r||a(ct(t))},onBlur:()=>{m&&r&&!T&&(h(!1),D(f))}}),(0,G.jsx)(et,{type:`tertiary`,size:`small`,children:o(`chat.hitlWhitelistHint`,null,`白名单内工具免审批;每行一个或逗号分隔,与 config 全局白名单合并。`)})]})]})]})})})}var{Text:ft}=u;function pt({item:e,active:t,editing:n,editingTitle:r,onStartEdit:i,onEditingTitle:a,onCommitEdit:o,onCancelEdit:s,onSelect:c,onPin:l,onDelete:u,canWrite:d,canDelete:f,selected:p,onToggleSelect:m,batchMode:h}){let g=R(),v=String(e.title||g(`chat.untitled`,null,`未命名对话`));return(0,G.jsxs)(`div`,{className:`chat-conv-item ${t?`is-active`:``}`,children:[h&&(0,G.jsx)(y,{className:`chat-conv-check`,"aria-label":`${g(`chat.selectConversation`,null,`选择对话`)}:${v}`,checked:p,onChange:t=>m(e.id,t.target.checked)}),n?(0,G.jsxs)(`div`,{className:`chat-conv-edit`,children:[(0,G.jsx)(C,{size:`small`,"aria-label":g(`chat.renameConversationTitle`,null,`重命名`),value:r,autoFocus:!0,onChange:a,onEnterPress:o,onKeyDown:e=>{e.key===`Escape`&&s()}}),(0,G.jsxs)(`div`,{className:`chat-conv-edit-actions`,children:[(0,G.jsx)(x,{size:`small`,theme:`solid`,onClick:o,children:g(`common.save`,null,`保存`)}),(0,G.jsx)(x,{size:`small`,theme:`borderless`,onClick:s,children:g(`common.cancel`,null,`取消`)})]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,className:`chat-conv-main`,"aria-current":t?`true`:void 0,title:v,onClick:()=>c(e.id),children:[(0,G.jsxs)(`span`,{className:`chat-conv-title`,children:[e.pinned&&(0,G.jsx)(ae,{size:`small`,className:`chat-conv-pin`}),(0,G.jsx)(`span`,{className:`chat-conv-title-text`,children:v})]}),(0,G.jsx)(`span`,{className:`chat-conv-meta`,children:L(e.updatedAt||e.createdAt)})]}),!h&&(0,G.jsxs)(`div`,{className:`chat-conv-actions`,children:[d&&(0,G.jsx)(P,{content:g(`chat.renameConversationTitle`,null,`重命名`),children:(0,G.jsx)(x,{size:`small`,theme:`borderless`,"aria-label":g(`chat.renameConversationTitle`,null,`重命名`),icon:(0,G.jsx)(b,{}),onClick:()=>i(e)})}),d&&(0,G.jsx)(P,{content:e.pinned?g(`chat.unpin`,null,`取消置顶`):g(`chat.pin`,null,`置顶`),children:(0,G.jsx)(x,{size:`small`,theme:`borderless`,icon:(0,G.jsx)(ae,{}),"aria-label":e.pinned?g(`chat.unpin`,null,`取消置顶`):g(`chat.pin`,null,`置顶`),type:e.pinned?`warning`:`tertiary`,onClick:()=>l(e)})}),f&&(0,G.jsx)(ee,{title:g(`chat.deleteConversationConfirm`,null,`确认删除该对话?删除后不可恢复。`),onConfirm:()=>u(e),children:(0,G.jsx)(x,{size:`small`,theme:`borderless`,type:`danger`,"aria-label":g(`chat.deleteConversationTitle`,null,`删除对话`),icon:(0,G.jsx)(_,{})})})]})]})]})}function mt({items:e,groups:t,expandedGroup:n,groupTotal:r,onToggleGroup:i,loading:a,error:o,onRetry:l,search:u,onSearch:f,projectId:p,onProjectChange:m,projects:h,page:_,pageSize:v,onPageChange:b,selectedId:S,onSelect:w,onCreate:T,onRename:E,onPin:D,onDelete:O,onBatchDelete:k,canWrite:ee,canDelete:te}){let A=R(),j=e,re=(0,W.useId)(),ie=(0,W.useId)(),[ae,M]=(0,W.useState)(``),[se,ce]=(0,W.useState)(``),[P,le]=(0,W.useState)(!1),[ue,fe]=(0,W.useState)([]),pe=j.length>0&&j.every(e=>ue.includes(e.id)),he=!pe&&j.some(e=>ue.includes(e.id));(0,W.useEffect)(()=>{fe([]),le(!1)},[_,p,u,n]);let I=(0,W.useMemo)(()=>[{value:``,label:A(`chat.filterAllProjects`,null,`全部项目`)},...(Array.isArray(h)?h:[]).map(e=>({value:e.id,label:Le(e,A)}))],[h,A]),L=(e,t)=>{fe(n=>t?[...new Set([...n,e])]:n.filter(t=>t!==e))},ge=e=>{M(e.id),ce(String(e.title||``))},z=()=>{let e=ae,t=se.trim();M(``),e&&t&&E(e,t)},_e=(0,G.jsxs)(G.Fragment,{children:[a&&!j.length&&(0,G.jsx)(g,{placeholder:(0,G.jsx)(g.Paragraph,{rows:6}),loading:!0}),!a&&!o&&!j.length&&(0,G.jsx)(c,{title:A(`chat.noHistoryConversations`,null,`暂无历史对话`),description:null,className:`chat-sidebar-empty`}),(0,G.jsx)(s,{dataSource:j,split:!1,renderItem:e=>(0,G.jsx)(pt,{item:e,active:e.id===S,editing:ae===e.id,editingTitle:se,onStartEdit:ge,onEditingTitle:ce,onCommitEdit:z,onCancelEdit:()=>M(``),onSelect:w,onPin:D,onDelete:O,canWrite:ee,canDelete:te,batchMode:P,selected:ue.includes(e.id),onToggleSelect:L},e.id)})]});return(0,G.jsxs)(`div`,{className:`chat-sidebar-inner`,children:[(0,G.jsxs)(`div`,{className:`chat-sidebar-head`,children:[(0,G.jsx)(ft,{strong:!0,className:`chat-sidebar-title`,children:A(`chat.conversations`,null,`会话`)}),(0,G.jsx)(x,{icon:(0,G.jsx)(ne,{}),theme:`borderless`,className:`chat-new-chat`,onClick:T,disabled:!ee,children:A(`chat.newChat`,null,`新建对话`)})]}),(0,G.jsxs)(`div`,{className:`chat-sidebar-filters`,children:[(0,G.jsx)(C,{prefix:(0,G.jsx)(N,{}),"aria-label":A(`chat.searchHistory`,null,`搜索历史对话`),placeholder:A(`chat.searchHistory`,null,`搜索历史对话`),value:u,onChange:f,showClear:!0}),(0,G.jsx)(`span`,{id:ie,hidden:!0,children:A(`chat.filterByProject`,null,`按项目过滤`)}),(0,G.jsx)(me,{value:p,optionList:I,onChange:m,className:`chat-sidebar-project`,"aria-labelledby":ie,placeholder:A(`chat.filterByProject`,null,`按项目过滤`)})]}),(0,G.jsxs)(`div`,{className:`chat-sidebar-tools`,children:[(0,G.jsxs)(ft,{type:`tertiary`,size:`small`,children:[A(`chat.recentConversations`,null,`最近对话`),` · `,t.reduce((e,t)=>e+t.total,0)]}),(0,G.jsxs)(`div`,{className:`chat-sidebar-tools-actions`,children:[te&&j.length>0&&(0,G.jsx)(x,{size:`small`,theme:P?`solid`:`borderless`,onClick:()=>{le(!P),fe([])},children:P?A(`common.cancel`,null,`取消`):A(`chat.batchManage`,null,`批量管理`)}),(0,G.jsx)(x,{size:`small`,theme:`borderless`,"aria-label":A(`chat.refreshConversationList`,null,`刷新会话列表`),title:A(`chat.refreshConversationList`,null,`刷新会话列表`),icon:(0,G.jsx)(de,{}),onClick:l})]})]}),P&&(0,G.jsxs)(`div`,{className:`chat-batch-bar`,children:[(0,G.jsx)(y,{className:`chat-batch-select-all`,checked:pe,indeterminate:he,disabled:a||!j.length,onChange:e=>fe(e.target.checked?j.map(e=>e.id):[]),children:A(`chat.selectPage`,null,`全选本页`)}),(0,G.jsxs)(ft,{size:`small`,children:[A(`chat.selectedCount`,null,`已选`),` `,ue.length]}),(0,G.jsx)(x,{size:`small`,type:`danger`,disabled:!ue.length,onClick:async()=>{await k(ue),fe([]),le(!1)},children:A(`chat.batchDelete`,null,`批量删除`)})]}),(0,G.jsxs)(`div`,{className:`chat-conv-list`,children:[(0,G.jsx)(H,{error:o,onRetry:l}),!t.length&&!a&&!o&&(0,G.jsx)(c,{title:A(`chat.noHistoryConversations`,null,`暂无历史对话`),description:null,className:`chat-sidebar-empty`}),t.map(e=>{let t=e.id===n,r=re+`-`+e.id;return(0,G.jsxs)(`div`,{className:`chat-conv-group`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`chat-conv-group-toggle`,"aria-expanded":t,"aria-controls":r,title:e.projectId?e.title+` · `+e.projectId:e.title,onClick:()=>i(e.id),children:[(0,G.jsx)(oe,{"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`chat-conv-group-name`,children:e.title}),(0,G.jsx)(`span`,{className:`chat-conv-group-count`,children:e.total}),(0,G.jsx)(d,{"aria-hidden":`true`,className:`chat-conv-group-chevron`})]}),(0,G.jsx)(`div`,{id:r,className:`chat-conv-group-content`,hidden:!t,children:t&&_e})]},e.id)})]}),n&&r>v&&(0,G.jsx)(`div`,{className:`chat-sidebar-pager`,children:(0,G.jsx)(F,{size:`small`,total:r,pageSize:v,currentPage:_,onPageChange:b,showSizeChanger:!1})})]})}var ht=new Set([`taskcreate`,`taskupdate`,`tasklist`,`taskget`,`write_todos`]),gt=new Set([`heartbeat`,`response_delta`,`thinking_stream_delta`,`reasoning_chain_stream_delta`,`tool_result_delta`]),_t=200,vt=2e4;function J(e){return e==null?``:String(e)}function yt(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function Y(e,t=vt){let n=J(e);return n.length<=t?n:`${n.slice(0,t)}\n…(已截断,共 ${n.length} 字符)`}function X(e,t=6e3){if(e==null)return``;try{return Y(typeof e==`string`?e:JSON.stringify(e,null,2),t)}catch{return Y(String(e),t)}}function Z({conversationId:e=``,id:t}={}){return{id:t||`live-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,conversationId:e,status:`streaming`,text:``,blocks:[],toolsByCallId:new Map,events:[],error:``,notice:``,statusText:``,messageId:``,userMessageId:``,finalizable:null,startedAt:Date.now(),endedAt:0,seq:0}}function Q(e,t){return e.seq+=1,`${t}-${e.seq}`}function bt(e,t){let n=J(t.type);gt.has(n)||(e.events.push({at:Date.now(),type:n,message:J(t.message),data:t.data===void 0?null:t.data}),e.events.length>_t&&e.events.splice(0,e.events.length-_t))}function $(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===J(n))return a;let o={kind:`note`,id:Q(e,`note`),title:t,message:Y(n),tone:r,data:i};return e.blocks.push(o),o}function xt(e,t,n=`thinking`){let r=J(t)||Q(e,`reasoning`),i=r?e.blocks.find(e=>e.kind===`reasoning`&&e.key===r):null;return i||(i={kind:`reasoning`,id:Q(e,`reason`),key:r,stream:J(t),label:n,text:``},e.blocks.push(i)),i}function St(e){let t=yt(e.argumentsObj);if(t&&Object.keys(t).length)return t;let n=e.arguments??e.argumentsObj??null;if(typeof n!=`string`)return n;if(!n.trim())return null;try{return JSON.parse(n)}catch{return n}}function Ct(e){return St(yt(e?.data)||{})}function wt(e){let t=yt(e?.data)||{};return X(t.resultPreview??t.result??t.error??e?.message,8e3)}function Tt({blocks:e,toolsByCallId:t},{toolCallId:n,toolName:r,agentName:i}){let a=e=>!i||!e.agentName||e.agentName===i,o=t.get(n)?.filter(a);return o?.length?o.find(e=>!e.hasResult)||o[o.length-1]:r?e.find(e=>e.kind===`tool`&&!e.hasResult&&e.toolName===r&&a(e)&&(!n||!e.toolCallId)):null}function Et(e){let t=J(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 Dt(e,t,n,r,i,a){var o,s;let c={toolCallId:J(n.toolCallId),toolName:J(n.toolName),agentName:J(n.agentName)},l=St(n),u=t===`tool_result`,d=J(a),f=u?Tt(e,c):null;if(f?!u&&d&&!f.callDetailId&&(f.callDetailId=d):(f={kind:`tool`,id:i(`tool`),toolCallId:``,toolName:c.toolName,agentName:c.agentName,args:l,result:``,status:`running`,processDetailId:d,callDetailId:u?``:d,resultDetailId:u?d:``,argsDeferred:!!(!u&&n._argsDeferred&&d),resultDeferred:!1,hasDeferredPayload:!!(n._hasPayload||n._argsDeferred),hasResult:!1},e.blocks.push(f)),c.toolCallId&&!f.toolCallId){f.toolCallId=c.toolCallId;let t=e.toolsByCallId.get(f.toolCallId);t?t.push(f):e.toolsByCallId.set(f.toolCallId,[f])}if(!u){n._argsDeferred&&d&&(f.argsDeferred=!0,f.hasDeferredPayload=!0);return}f.hasResult=!0,(o=f).toolName||(o.toolName=c.toolName),(s=f).agentName||(s.agentName=c.agentName),d&&(f.resultDetailId=d),f.status=Et(n),l!==null&&(f.args===null||yt(f.args)&&!Object.keys(f.args).length)&&(f.args=l,f.argsDeferred=!1);let p=n.resultPreview??n.result??n.error??(J(r).trim()?r:void 0);p!=null&&J(p)!==``?(f.result=X(p,8e3),f.resultDeferred=!1):n._payloadDeferred&&n._hasPayload!==!1&&d&&(f.resultDeferred=!0,f.hasDeferredPayload=!0)}function Ot(e,t){if(!e||!t||typeof t!=`object`)return e;let n=J(t.type),r=yt(t.data)||{};switch(bt(e,t),n){case`heartbeat`:break;case`conversation`:r.conversationId&&(e.conversationId=J(r.conversationId));break;case`message_saved`:r.userMessageId&&(e.userMessageId=J(r.userMessageId));break;case`progress`:e.statusText=J(t.message)||e.statusText;break;case`iteration`:{let n=Number(r.iteration)||1,i=J(r.piScope).trim(),a=J(r.agentName).trim(),o=i===`main`?a?`主代理 · ${a}`:`主代理`:i===`sub`?`子代理${a?` · ${a}`:``}`:``;e.blocks.push({kind:`iteration`,id:Q(e,`iter`),title:`第 ${n} 轮迭代${o?` · ${o}`:``}`,message:Y(t.message,2e3)});break}case`thinking_stream_start`:case`reasoning_chain_stream_start`:{let t=xt(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=xt(e,r.streamId,n===`reasoning_chain_stream_delta`?`reasoning_chain`:`thinking`),a=typeof r.accumulated==`string`?r.accumulated:null;i.text=Y(a===null?i.text+J(t.message):a);break}case`thinking`:case`reasoning_chain`:if(r.streamId){let i=xt(e,r.streamId,n===`reasoning_chain`?`reasoning_chain`:`thinking`);J(t.message)&&(i.text=Y(t.message));break}e.blocks.push({kind:`reasoning`,id:Q(e,`reason`),key:Q(e,`reasonkey`),stream:``,label:n===`reasoning_chain`?`reasoning_chain`:`thinking`,text:Y(t.message)});break;case`response_start`:r.conversationId&&(e.conversationId=J(r.conversationId)),e.statusText||(e.statusText=`正在生成回复…`);break;case`response_delta`:{let n=typeof r.accumulated==`string`?r.accumulated:null;e.text=Y(n===null?e.text+J(t.message):n,6e4);break}case`response`:{let n=J(t.message);n&&(e.text=Y(n,6e4)),r.messageId&&(e.messageId=J(r.messageId)),r.conversationId&&(e.conversationId=J(r.conversationId)),r.finalizable===!1?e.finalizable=!1:r.finalizable===!0&&(e.finalizable=!0);break}case`tool_call`:case`tool_result`:Dt(e,n,r,t.message,t=>Q(e,t),r.processDetailId);break;case`tool_calls_detected`:$(e,{title:`🔧 检测到工具调用`,message:t.message,data:r});break;case`hitl_interrupt`:$(e,{title:`🧑⚖️ 等待人工审批`,message:`${J(r.toolName)||`工具`} · ${J(t.message)||`命中审批策略`}`,tone:`warning`,data:r});break;case`hitl_resumed`:$(e,{title:`✅ 审批通过`,message:J(t.message),tone:`success`,data:r});break;case`hitl_rejected`:$(e,{title:`⛔ 审批被拒绝`,message:J(t.message),tone:`danger`,data:r});break;case`hitl_audit_agent_started`:$(e,{title:`🛡 审计代理审查中`,message:J(t.message),tone:`info`,data:r});break;case`hitl_audit_agent`:$(e,{title:`🛡 审计代理已裁决`,message:`${J(r.decision)||`-`}${r.comment?` · ${J(r.comment)}`:``}`,tone:`info`,data:r});break;case`warning`:case`iteration_limit_reached`:case`pi_pending_orphaned`:$(e,{title:`⚠️ ${J(t.message)||`提示`}`,message:J(t.message),tone:`warning`,data:r});break;case`finalization_check`:$(e,{title:`🔎 最终化校验未通过`,message:J(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`:$(e,{title:J(t.message)||`运行提示`,message:J(t.message),tone:`warning`,data:r});break;case`agent_usage_summary`:e.blocks.push({kind:`usage`,id:Q(e,`usage`),data:r});break;case`user_interrupt_continue`:$(e,{title:`⏸️ 用户中断并继续`,message:J(t.message),tone:`info`,data:r});break;case`agent_reply`:$(e,{title:`💬 ${J(r.agentName)||`子代理`}回复`,message:J(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`:$(e,{title:`🧭 ${J(t.message)||n}`,message:J(t.message),data:r});break;case`cancelled`:e.status=`cancelled`,e.notice=J(t.message)||`任务已取消`,e.endedAt=Date.now();break;case`error`:e.status=`error`,e.error=J(t.message)||`执行失败`,e.endedAt=Date.now();break;case`done`:e.status===`streaming`&&(e.status=r.status===`blocked`||e.finalizable===!1?`blocked`:`done`),r.workflowStatus===`awaiting_hitl`&&(e.statusText=`工作流等待审批`),e.endedAt=Date.now()}return e}var kt={streaming:{label:`生成中`,color:`blue`},done:{label:`已完成`,color:`green`},blocked:{label:`未完成`,color:`orange`},disconnected:{label:`连接已结束`,color:`grey`},error:{label:`失败`,color:`red`},cancelled:{label:`已取消`,color:`grey`}};function At(e){let t=[],n={blocks:t,toolsByCallId:new Map},r=0,i=e=>(r+=1,`h-${e}-${r}`),a=J(e?.reasoningContent).trim();return a&&t.push({kind:`reasoning`,id:i(`reason`),key:`reasoningContent`,stream:``,label:`thinking`,text:Y(a)}),(Array.isArray(e?.processDetails)?e.processDetails:[]).forEach(e=>{let r=J(e?.eventType),a=yt(e?.data)||{},o=J(e?.message);switch(r){case`iteration`:{let e=Number(a.iteration)||1,n=J(a.piScope).trim(),r=J(a.agentName).trim();t.push({kind:`iteration`,id:i(`iter`),title:`第 ${e} 轮迭代${n===`main`?` · 主代理`:n===`sub`?` · 子代理`:``}${r?` · ${r}`:``}`,message:Y(o,2e3)});break}case`thinking`:case`reasoning_chain`:{let n=!!(a._payloadDeferred&&e?.id&&!o.trim());if(!o.trim()&&!n)break;t.push({kind:`reasoning`,id:i(`reason`),detailId:J(e?.id),key:J(a.streamId)||i(`reasonkey`),stream:J(a.streamId),label:r,text:n?``:Y(o),textLength:n?Number(a._textLength)||0:o.length,payloadDeferred:n});break}case`tool_call`:case`tool_result`:Dt(n,r,a,o,i,e?.id);break;case`planning`:if(!o.trim())break;t.push({kind:`note`,id:i(`note`),title:`📝 规划`,message:Y(o,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=r===`hitl_rejected`?`danger`:r===`hitl_resumed`?`success`:`info`,n=r===`hitl_interrupt`?`🧑⚖️ 人工审批`:r===`hitl_rejected`?`⛔ 审批被拒绝`:r===`hitl_resumed`?`✅ 审批通过`:`🛡 审计代理`;t.push({kind:`note`,id:i(`note`),title:n,message:`${o}${a.toolName?` · ${J(a.toolName)}`:``}${a.decision?` · ${J(a.decision)}`:``}`,tone:e,data:null});break}case`error`:case`timeout`:case`cancelled`:t.push({kind:`note`,id:i(`note`),title:r===`cancelled`?`⏹ 已取消`:`❌ 执行异常`,message:o,tone:`danger`,data:null});break;case`agent_reply`:t.push({kind:`note`,id:i(`note`),title:`💬 子代理回复`,message:Y(o,6e3),tone:`info`,data:null});break;case`agent_usage_summary`:t.push({kind:`usage`,id:i(`usage`),data:a});break;case`progress`:break;default:(o.trim()||Object.keys(a).length)&&t.push({kind:`note`,id:i(`note`),title:J(r)||`过程事件`,message:Y(o,4e3),tone:`info`,data:Object.keys(a).length?a:null})}}),t}var{Text:jt}=u,Mt={running:{color:`blue`,label:`执行中`},success:{color:`green`,label:`完成`},failed:{color:`red`,label:`失败`},cancelled:{color:`grey`,label:`已取消`},blocked:{color:`orange`,label:`已拦截`}};function Nt(e){return Array.isArray(e)?e.includes(`1`):e===`1`}function Pt({block:e,defaultOpen:t}){let[n,r]=(0,W.useState)(!!t),[i,a]=(0,W.useState)(``),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(``),u=(0,W.useRef)(null),d=e.text||i,f=d?d.length:Number(e.textLength)||0,p=!!(e.payloadDeferred&&e.detailId&&!d),m=(0,W.useCallback)(async()=>{if(!e.detailId)return;u.current?.abort();let t=new AbortController;u.current=t,s(!0),l(``);try{let n=await z.get(`/process-details/${encodeURIComponent(e.detailId)}`,null,{signal:t.signal});if(t.signal.aborted)return;let r=n?.processDetail;a(String(r?.message||``))}catch(e){t.signal.aborted||l(ke(e,`加载思考过程失败`))}finally{u.current===t&&(u.current=null,s(!1))}},[e.detailId]);(0,W.useEffect)(()=>()=>u.current?.abort(),[]),(0,W.useEffect)(()=>{n&&p&&!o&&!c&&m()},[n,p,o,c,m]);let h=(0,W.useMemo)(()=>n&&d?Y(d):``,[n,d]);if(!d.trim()&&!e.payloadDeferred)return null;let g=e.label===`reasoning_chain`?`🔗 推理过程`:`🤔 思考过程`;return(0,G.jsx)(M,{className:`chat-block-collapse`,activeKey:n?[`1`]:[],onChange:e=>r(Nt(e)),children:(0,G.jsxs)(M.Panel,{itemKey:`1`,header:(0,G.jsxs)(`span`,{className:`chat-block-title`,children:[g,` · `,f,` 字符`]}),children:[n&&o&&(0,G.jsxs)(`div`,{className:`chat-tool-loading`,children:[(0,G.jsx)(E,{size:`small`}),(0,G.jsx)(`span`,{children:`正在加载思考过程…`})]}),n&&c&&(0,G.jsxs)(`div`,{className:`chat-tool-error`,children:[(0,G.jsx)(`span`,{children:c}),(0,G.jsx)(`button`,{type:`button`,className:`chat-link-btn`,onClick:()=>void m(),children:`重试`})]}),n&&h&&(0,G.jsx)(`pre`,{className:`chat-pre`,children:h})]})})}function Ft({block:e,index:t,total:n}){let{t:r}=_e(),[i,a]=(0,W.useState)(!1),[o,s]=(0,W.useState)(void 0),[c,l]=(0,W.useState)(void 0),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(``),m=(0,W.useRef)(null),h=Mt[e.status]||Mt.running,g=o===void 0?e.args:o,_=c===void 0?e.result||``:c,y=!!(e.argsDeferred&&e.callDetailId&&o===void 0),b=!!(e.resultDeferred&&e.resultDetailId&&c===void 0),x=!!(g!=null&&g!==``||_||y||b||e.hasDeferredPayload),S=(0,W.useCallback)(async()=>{let t=[];if(y&&e.callDetailId&&t.push({kind:`args`,id:e.callDetailId}),b&&e.resultDetailId&&t.push({kind:`result`,id:e.resultDetailId}),!t.length)return;m.current?.abort();let n=new AbortController;m.current=n,d(!0),p(``);try{let e=await Promise.all(t.map(async e=>{let t=await z.get(`/process-details/${encodeURIComponent(e.id)}`,null,{signal:n.signal});return{kind:e.kind,detail:t?.processDetail||null}}));if(n.signal.aborted)return;for(let t of e)t.kind===`args`?s(Ct(t.detail)):t.kind===`result`&&l(wt(t.detail))}catch(e){n.signal.aborted||p(ke(e,`加载工具详情失败`))}finally{m.current===n&&(m.current=null,d(!1))}},[e.callDetailId,e.resultDetailId,y,b]);(0,W.useEffect)(()=>()=>m.current?.abort(),[]),(0,W.useEffect)(()=>{i&&(y||b)&&!u&&!f&&S()},[i,y,b,u,f,S]);let C=(0,W.useMemo)(()=>i?X(g):``,[i,g]),w=i?_:``,T=e.toolName||r(`chat.unknownTool`,null,`未知工具`),D=(0,G.jsxs)(`span`,{className:`chat-tool-head`,children:[(0,G.jsxs)(`span`,{className:`chat-tool-name`,children:[e.agentName?`${e.agentName} · `:``,r(`chat.callTool`,{name:T,index:t,total:n},`调用工具: ${T} (${t}/${n})`)]}),(0,G.jsx)(v,{size:`small`,color:h.color,shape:`circle`,children:h.label})]});return x?(0,G.jsx)(`div`,{className:`chat-tool`,children:(0,G.jsx)(M,{className:`chat-block-collapse`,activeKey:i?[`1`]:[],onChange:e=>a(Nt(e)),children:(0,G.jsxs)(M.Panel,{itemKey:`1`,header:D,children:[i&&u&&(0,G.jsxs)(`div`,{className:`chat-tool-loading`,children:[(0,G.jsx)(E,{size:`small`}),(0,G.jsx)(`span`,{children:`正在加载工具详情…`})]}),i&&f&&(0,G.jsxs)(`div`,{className:`chat-tool-error`,children:[(0,G.jsx)(`span`,{children:f}),(0,G.jsx)(`button`,{type:`button`,className:`chat-link-btn`,onClick:()=>void S(),children:`重试`})]}),i&&C&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(jt,{type:`tertiary`,size:`small`,children:`参数`}),(0,G.jsx)(`pre`,{className:`chat-pre`,children:C})]}),i&&w&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(jt,{type:`tertiary`,size:`small`,children:`结果`}),(0,G.jsx)(`pre`,{className:`chat-pre`,children:w})]})]})})}):(0,G.jsx)(`div`,{className:`chat-tool`,children:(0,G.jsx)(`div`,{className:`chat-tool-head-row`,children:D})})}function It({block:e}){let[t,n]=(0,W.useState)(!1),r=e.tone||`info`;return(0,G.jsxs)(`div`,{className:`chat-note chat-note-${r}`,children:[(0,G.jsxs)(`div`,{className:`chat-note-head`,children:[(0,G.jsx)(`span`,{className:`chat-note-title`,children:e.title}),e.data&&(0,G.jsx)(`button`,{type:`button`,className:`chat-link-btn`,onClick:()=>n(!t),children:t?`收起 JSON`:`查看 JSON`})]}),e.message&&(0,G.jsx)(`div`,{className:`chat-note-body`,children:e.message}),t&&e.data&&(0,G.jsx)(Ee,{value:e.data,collapsed:!1,title:`事件数据`})]})}function Lt({data:e}){let{t,lang:n}=_e(),r=e=>I(Math.max(0,Math.trunc(Number(e)||0)),n),i=[[`chat.piUsageModelCalls`,e.modelCalls],[`chat.piUsagePromptTokens`,e.promptTokens],[`chat.piUsageCompletionTokens`,e.completionTokens],[`chat.piUsageTotalTokens`,e.totalTokens]],a=[[`chat.piUsageCachedTokens`,e.cachedTokens],[`chat.piUsageCacheWriteTokens`,e.cacheWriteTokens],[`chat.piUsageReasoningTokens`,e.reasoningTokens]],o=[...i,...a.filter(([,e])=>Number(e)>0)].map(([e,n])=>`${t(e)}: ${r(n)}`).join(`
`),s=Number(e.totalTokens),c=[e.agentName,t(`chat.piUsageSummaryTitle`),Number.isFinite(s)&&s>0?r(s):``].filter(Boolean).join(` · `);return(0,G.jsx)(It,{block:{title:c,message:o,data:e}})}function Rt({events:e}){return!e||!e.length?null:(0,G.jsx)(M,{className:`chat-block-collapse chat-event-log`,children:(0,G.jsx)(M.Panel,{itemKey:`1`,header:(0,G.jsxs)(`span`,{className:`chat-block-title`,children:[`🧾 原始事件 · `,e.length,` 条`]}),children:(0,G.jsx)(`pre`,{className:`chat-pre`,children:e.map((e,t)=>`${t+1}. ${JSON.stringify(e)}`).join(`
`)})})})}var zt=(0,W.memo)(function({text:e,blocks:t,events:n,streaming:r=!1,openReasoning:i=!1,isAssistant:a=!1}){let{t:o}=_e(),s=Array.isArray(t)?t:[],c=e||``,l=s.filter(e=>e.kind===`tool`).length,u=0;return(0,G.jsxs)(`div`,{className:`chat-turn-body`,children:[s.map(e=>e.kind===`reasoning`?(0,G.jsx)(Pt,{block:e,defaultOpen:i},e.id):e.kind===`tool`?(u+=1,(0,G.jsx)(Ft,{block:e,index:u,total:l},e.id)):e.kind===`iteration`?(0,G.jsx)(`div`,{className:`chat-iteration`,children:(0,G.jsx)(`span`,{className:`chat-iteration-label`,children:e.title})},e.id):e.kind===`note`?(0,G.jsx)(It,{block:e},e.id):e.kind===`usage`?(0,G.jsx)(Lt,{data:e.data},e.id):null),(0,G.jsx)(Rt,{events:n}),c.trim()&&(a&&!r?(0,G.jsx)(`section`,{className:`chat-task-summary`,"aria-label":o(`chat.taskSummary`),"data-chat-summary":!0,children:(0,G.jsxs)(`details`,{open:!0,children:[(0,G.jsx)(`summary`,{className:`chat-task-summary-title`,children:o(`chat.taskSummary`)}),(0,G.jsx)(`div`,{className:`chat-task-summary-content`,children:(0,G.jsx)(be,{content:c})})]},c.length)}):r?(0,G.jsx)(`pre`,{className:`chat-pre chat-stream-text`,children:c}):(0,G.jsx)(be,{content:c})),!c.trim()&&r&&(0,G.jsx)(`div`,{className:`chat-stream-placeholder`,children:`正在生成…`})]})}),{Paragraph:Bt,Text:Vt}=u,Ht=40,Ut=40;function Wt(e){let t=String(e||``);return t.length<=128?t:`${t.length}:${t.slice(0,64)}:${t.slice(-64)}`}function Gt(){let e=R();return(0,G.jsx)(`div`,{className:`chat-welcome`,children:(0,G.jsx)(c,{image:(0,G.jsx)(`span`,{className:`chat-welcome-mark`,"aria-hidden":`true`,children:(0,G.jsx)(he,{size:`extra-large`})}),title:e(`chat.welcomeHeading`,null,`让安全探索,从对话开始`),description:(0,G.jsx)(Bt,{type:`tertiary`,className:`chat-welcome-description`,children:e(`chat.welcomeScopeDescription`,null,`描述测试目标与授权范围,或上传相关材料,即可开始对话。`)})})})}function Kt(e,t,n){let[r,i]=(0,W.useState)(()=>Date.now());if((0,W.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`}var qt=(0,W.memo)(function({message:e,canDelete:t,onDeleteTurn:n}){let r=R(),i=e.role===`user`,a=e.role===`system`,o=(0,W.useMemo)(()=>At(e),[e]),s=e.createdAt?L(e.createdAt):``,c=String(e.content||``);return a?(0,G.jsx)(`div`,{className:`chat-system-row`,children:(0,G.jsx)(Vt,{type:`tertiary`,children:c})},e.id):(0,G.jsxs)(`div`,{className:`chat-msg ${i?`chat-msg-user`:`chat-msg-assistant`}`,children:[(0,G.jsx)(f,{size:`small`,color:i?`grey`:`blue`,className:`chat-avatar`,"aria-hidden":`true`,children:i?(0,G.jsx)(D,{}):`AI`}),(0,G.jsxs)(`div`,{className:`chat-bubble`,children:[(0,G.jsxs)(`div`,{className:`chat-bubble-head`,children:[(0,G.jsx)(`span`,{className:`chat-bubble-role`,children:i?r(`chat.you`,null,`我`):r(`chat.assistant`,null,`助手`)}),s&&(0,G.jsx)(`span`,{className:`chat-bubble-time`,children:s}),(0,G.jsxs)(`span`,{className:`chat-bubble-actions`,children:[!i&&c&&(0,G.jsx)(we,{text:c,size:`small`}),t&&i&&e.id&&(0,G.jsx)(P,{content:r(`chat.deleteTurnTitle`,null,`删除本轮`),children:(0,G.jsx)(x,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,G.jsx)(_,{}),"aria-label":r(`chat.deleteTurnTitle`,null,`删除本轮`),onClick:()=>n(e)})})]})]}),c||o.length>0?(0,G.jsx)(zt,{text:c,blocks:o,events:null,isAssistant:!i}):(0,G.jsx)(Vt,{type:`tertiary`,children:`—`})]})]},e.id)});function Jt({live:e}){let t=R(),n=kt[e.status]||kt.streaming,r=Kt(e.startedAt,e.endedAt,e.status===`streaming`);return(0,G.jsxs)(`div`,{className:`chat-msg chat-msg-assistant chat-msg-live`,children:[(0,G.jsx)(f,{size:`small`,color:`blue`,className:`chat-avatar`,children:`AI`}),(0,G.jsxs)(`div`,{className:`chat-bubble`,children:[(0,G.jsxs)(`div`,{className:`chat-bubble-head`,children:[(0,G.jsx)(`span`,{className:`chat-bubble-role`,children:t(`chat.assistant`,null,`助手`)}),(0,G.jsx)(v,{size:`small`,color:n.color,shape:`circle`,children:n.label}),r&&(0,G.jsx)(`span`,{className:`chat-bubble-time`,children:r}),e.statusText&&(0,G.jsx)(`span`,{className:`chat-live-status`,children:e.statusText})]}),(0,G.jsx)(zt,{isAssistant:!0,text:e.text,blocks:e.blocks,events:e.events,streaming:e.status===`streaming`,openReasoning:e.status===`streaming`}),e.error&&(0,G.jsx)(`div`,{className:`chat-live-error`,children:e.error}),e.notice&&(0,G.jsx)(`div`,{className:`chat-live-notice`,children:e.notice}),e.finalizable===!1&&(0,G.jsx)(`div`,{className:`chat-live-notice`,children:`本轮回复未通过最终化校验,内容可能不完整。`})]})]})}function Yt({conversationId:e,messages:t,live:n,loading:r,error:i,onRetry:a,canDelete:o,onDeleteTurn:s}){let c=R(),l=(0,W.useRef)(null),u=(0,W.useRef)(!0),d=(0,W.useRef)(``),[f,p]=(0,W.useState)(!0),[m,h]=(0,W.useState)(Ht),g=Array.isArray(t)?t:[],_=Math.max(0,g.length-m),v=(0,W.useMemo)(()=>_>0?g.slice(_):g,[g,_]),y=g[g.length-1],b=Wt(y?.content),S=`${g.length}:${y?.id||``}:${b}:${y?.processDetails?.length||0}`,C=n?n.status!==`streaming`&&n.text.trim()?`live:${e}:${n.messageId||n.id}:${Wt(n.text)}`:``:!r&&y?.role===`assistant`&&String(y.content||``).trim()?`history:${e}:${y.id}:${b}`:``,w=(0,W.useMemo)(()=>{if(!n)return S;let e=n.blocks.map(e=>`${e.kind}:${e.id}:${e.text?e.text.length:0}:${e.status||``}`).join(`|`);return`${S}#${n.id}#${n.status}#${n.text.length}#${e}`},[S,n]),T=(0,W.useCallback)((e=!1)=>{let t=l.current;t&&t.scrollTo({top:t.scrollHeight,behavior:e?`smooth`:`auto`})},[]),D=(0,W.useCallback)((e=!1)=>{let t=l.current;if(!t)return;let n=t.querySelectorAll(`.chat-msg`),r=n[n.length-1]?.querySelector(`[data-chat-summary]`);if(!r){T(e);return}let i=r.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop-12;t.scrollTo({top:Math.max(0,i),behavior:e?`smooth`:`auto`})},[T]),O=(0,W.useCallback)(()=>{let e=l.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<120;u.current=t,p(t)},[]);return(0,W.useEffect)(()=>{u.current=!0,d.current=``,p(!0),h(Ht);let e=setTimeout(()=>D(!1),30);return()=>clearTimeout(e)},[e,D]),(0,W.useEffect)(()=>{n?.id&&(u.current=!0)},[n?.id]),(0,W.useEffect)(()=>{if(r)return;let e=C&&d.current!==C;e&&(d.current=C),(e||u.current)&&D(!1)},[w,C,r,D]),e||n||g.length?(0,G.jsxs)(`div`,{className:`chat-message-wrap`,children:[(0,G.jsxs)(`div`,{className:`chat-messages`,ref:l,onScroll:O,children:[(0,G.jsx)(H,{error:i,onRetry:a}),r&&(0,G.jsx)(`div`,{className:`chat-loading`,children:(0,G.jsx)(E,{size:`middle`})}),!r&&!g.length&&!n&&(0,G.jsx)(Gt,{}),!r&&_>0&&(0,G.jsxs)(`div`,{className:`chat-history-more`,children:[(0,G.jsx)(x,{size:`small`,theme:`light`,onClick:()=>h(e=>e+Ut),children:c(`chat.loadEarlierMessages`,{count:Math.min(Ut,_)},`显示更早的 ${Math.min(Ut,_)} 条消息`)}),(0,G.jsx)(x,{size:`small`,theme:`borderless`,onClick:()=>h(g.length),children:c(`chat.showAllMessages`,{total:g.length},`显示全部(共 ${g.length} 条)`)})]}),v.map(e=>(0,G.jsx)(qt,{message:e,canDelete:o,onDeleteTurn:s},e.id)),n&&(0,G.jsx)(Jt,{live:n}),i&&!r&&(0,G.jsx)(x,{icon:(0,G.jsx)(de,{}),theme:`borderless`,onClick:a,className:`chat-retry-inline`,children:c(`common.refresh`,null,`刷新`)})]}),!f&&(0,G.jsx)(x,{className:`chat-scroll-bottom`,icon:(0,G.jsx)(ce,{}),size:`small`,theme:`solid`,onClick:()=>{u.current=!0,p(!0),T(!0)},children:c(`chat.returnToLatest`,null,`回到底部`)})]}):(0,G.jsx)(`div`,{className:`chat-message-wrap`,children:(0,G.jsx)(`div`,{className:`chat-messages`,ref:l,children:(0,G.jsx)(Gt,{})})})}var{Text:Xt}=u,Zt=[`single`,`deep`,`plan_execute`,`supervisor`],Qt=`__create_project__`;function $t({value:e,onChange:t,onSend:r,onStop:i,canStop:a,sending:s,checkingRun:c,canWrite:l,canExecute:u,mode:f,onModeChange:p,projectId:g,onProjectChange:_,onCreateProject:y,projects:b,projectDisabled:C,role:w,onRoleChange:T,roles:E,roleDisabled:O,model:k,canReadConfig:ee,onOpenHitl:j,attachments:re,onPickFiles:ie,onRemoveAttachment:ae,uploading:M}){let N=R(),ce=n(),le=(0,W.useRef)(null),de=(0,W.useId)(),F=(0,W.useId)(),fe=(0,W.useId)(),pe=Array.isArray(re)?re:[],he=pe.some(e=>String(e?.mimeType||``).startsWith(`image/`)||/\.(?:png|jpe?g|gif|webp|bmp)$/i.test(String(e?.fileName||``))),I=(0,W.useMemo)(()=>[{value:`single`,title:N(`chat.agentModePiSingle`,null,`单代理`),description:N(`chat.agentModePiSingleHint`,null,`使用设置中选择的 Pi 或兼容运行时执行单代理任务`)},{value:`deep`,title:N(`chat.agentModeDeep`,null,`Deep(DeepAgent)`),description:N(`chat.agentModeDeepHint`,null,`Pi 多代理,适合复杂安全测试、多阶段 task 子代理委派与汇总`)},{value:`plan_execute`,title:N(`chat.agentModePlanExecuteLabel`,null,`Plan-Execute`),description:N(`chat.agentModePlanExecuteHint`,null,`规划 → 执行 → 重规划(单执行器带工具)`)},{value:`supervisor`,title:N(`chat.agentModeSupervisorLabel`,null,`Supervisor(专家路由)`),description:N(`chat.agentModeSupervisorHint`,null,`专家路由场景:监督者通过 transfer 动态分派多个专业子代理`)}].map(({value:e,title:t,description:n})=>({value:e,title:t,label:(0,G.jsxs)(`span`,{className:`chat-mode-option`,children:[(0,G.jsx)(`span`,{children:t}),(0,G.jsx)(`span`,{className:`chat-mode-option-description`,children:n})]})})),[N]),L=[{value:``,label:N(`chat.defaultWorkspace`,null,`默认工作区`)},...Re(b,N,{currentId:g,disableCurrentArchived:!0,fallbackLabel:N(`chat.boundProject`,null,`已绑定项目`)})];g&&!L.some(e=>e.value===g)&&L.push({value:g,label:N(`chat.boundProject`,null,`已绑定项目`)}),y&&L.push({value:Qt,label:`+ ${N(`projects.newProject`,null,`新建项目`)}`});let ge=(0,W.useMemo)(()=>{let e=(Array.isArray(E)?E:[]).filter(e=>e?.name),t=e.filter(e=>e.enabled!==!1&&e.name!==`默认`).sort((e,t)=>e.name.localeCompare(t.name,`zh-CN`)),n=e.find(e=>e.name===`默认`),r=e=>({value:e.name===`默认`?``:e.name,name:e.name===`默认`?N(`chat.defaultRole`,null,`默认`):e.name,icon:e.icon||``,description:e.description||``,label:(0,G.jsxs)(`span`,{className:`chat-role-option`,children:[(0,G.jsxs)(`span`,{className:`chat-role-option-title`,children:[e.icon?(0,G.jsx)(`span`,{className:`chat-role-icon`,"aria-hidden":`true`,children:e.icon}):null,(0,G.jsx)(`span`,{children:e.name===`默认`?N(`chat.defaultRole`,null,`默认`):e.name})]}),e.description?(0,G.jsx)(`span`,{className:`chat-role-option-description`,children:e.description}):null]})}),i=[r({name:`默认`,icon:n?.icon||``,description:n?.description||``})],a=new Set([``]);for(let e of t)a.has(e.name)||(a.add(e.name),i.push(r(e)));if(w&&!a.has(w)){let t=e.find(e=>e.name===w);i.push(r(t||{name:w,icon:``,description:``}))}return i},[w,E,N]),z=ge.find(e=>e.value===(w||``))||ge[0],_e=Number(M)||pe.filter(e=>e.uploading).length,B=!l||!u,ve=s||c,ye=k.channel||k.config.data?.default_channel,V=ye?U(ye,k.config.data?.channels?.[ye]):N(`chat.aiChannelDefaultShort`,null,`默认通道`),be=k.overrideBlocked?Xe(N,`default`,``):Xe(N,k.mode,k.effort);return(0,G.jsxs)(`div`,{className:`chat-composer`,children:[B&&(0,G.jsx)(o,{type:`warning`,bordered:!0,closeIcon:null,className:`chat-composer-banner`,description:l?N(`chat.noExecutePermission`,null,`当前账号没有智能体执行权限(agent:execute),发送已禁用。`):N(`chat.noWritePermission`,null,`当前账号没有对话写入权限(chat:write),发送已禁用。`)}),(0,G.jsx)(`div`,{className:`chat-composer-shell`,children:(0,G.jsxs)(`div`,{className:`chat-composer-box`,children:[(0,G.jsxs)(`div`,{className:`chat-composer-context`,children:[(0,G.jsx)(`span`,{id:de,hidden:!0,children:N(`chat.agentModeSelectAria`,null,`选择对话执行模式`)}),(0,G.jsx)(me,{value:f,optionList:I,renderSelectedItem:e=>(0,G.jsx)(`span`,{title:e.title,children:e.title}),onChange:p,prefix:(0,G.jsx)(m,{"aria-hidden":`true`}),className:`chat-context-select chat-composer-mode`,dropdownClassName:`chat-mode-dropdown`,size:`small`,position:`topLeft`,"aria-labelledby":de,disabled:ve||B}),(0,G.jsx)(`span`,{className:`chat-context-divider`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{id:F,hidden:!0,children:N(`chat.chooseWorkspace`,null,`选择会话工作区`)}),(0,G.jsx)(me,{value:g,optionList:L,onChange:e=>{e===Qt?y?.():_(e)},prefix:(0,G.jsx)(oe,{"aria-hidden":`true`}),className:`chat-context-select chat-composer-project`,dropdownClassName:`chat-project-dropdown`,dropdownMatchSelectWidth:!1,position:`topLeft`,size:`small`,renderSelectedItem:e=>(0,G.jsx)(`span`,{title:e.label,children:e.label}),"aria-labelledby":F,disabled:ve||C||!l}),T&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`chat-context-divider`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{id:fe,hidden:!0,children:N(`chat.selectRole`,null,`选择角色`)}),(0,G.jsx)(me,{value:w||``,optionList:ge,onChange:T,prefix:z?.icon?(0,G.jsx)(`span`,{className:`chat-role-icon`,"aria-hidden":`true`,children:z.icon}):(0,G.jsx)(D,{"aria-hidden":`true`}),className:`chat-context-select chat-composer-role`,dropdownClassName:`chat-role-dropdown`,dropdownMatchSelectWidth:!1,position:`topLeft`,size:`small`,renderSelectedItem:e=>(0,G.jsx)(`span`,{title:e.description||e.name,children:e.name}),"aria-labelledby":fe,disabled:ve||O||!l})]})]}),(0,G.jsx)(`input`,{ref:le,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&ie(Array.from(e.target.files)),e.target.value=``}}),pe.length>0&&(0,G.jsx)(`div`,{className:`chat-file-list`,children:pe.map(e=>(0,G.jsxs)(v,{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:()=>ae(e.id),children:[(0,G.jsx)(se,{size:`small`}),(0,G.jsx)(`span`,{className:`chat-file-name`,title:e.fileName,children:e.fileName}),(0,G.jsx)(`span`,{className:`chat-file-state`,children:e.uploading?`上传中…`:e.error?`上传失败`:`已上传`})]},e.id))}),he&&ee&&!k.config.loading&&k.vision?.nativeMode!==`enabled`&&(0,G.jsxs)(`div`,{className:`chat-image-vision-tip${k.vision?.ready?` is-ready`:``}`,children:[(0,G.jsx)(`span`,{children:k.vision?.ready?`已启用独立视觉模型(${k.vision.model}),若当前模型不支持图片输入将自动通过 analyze_image 识图。`:`若当前对话模型不支持识别图片,可开启独立「视觉分析模型」代为识图(或为支持识图的通道启用原生图片输入)。`}),(0,G.jsx)(`button`,{type:`button`,className:`chat-vision-entry-link`,onClick:()=>ce(`/settings?section=models&focus=vision`),children:k.vision?.ready?`切换视觉模型`:`去开启视觉模型`})]}),(0,G.jsx)(S,{className:`chat-textarea`,borderless:!0,value:e,onChange:t,onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent?.isComposing||(e.preventDefault(),ve||B||O||_e>0||r())},disabled:B,autosize:{minRows:2,maxRows:8},"aria-label":N(`chat.composerLabel`,null,`对话内容`),placeholder:N(`chat.composerPlaceholder`,null,`描述目标、授权范围与需求,或附上相关材料…`)}),(0,G.jsxs)(`div`,{className:`chat-composer-toolbar`,children:[(0,G.jsxs)(`div`,{className:`chat-composer-controls`,children:[(0,G.jsx)(P,{content:N(`chat.selectFile`,null,`选择附件`),children:(0,G.jsx)(x,{icon:(0,G.jsx)(ne,{}),theme:`borderless`,type:`tertiary`,"aria-label":N(`chat.attachmentsLabel`,null,`附件`),disabled:B,onClick:()=>le.current?.click()})}),(0,G.jsx)(x,{icon:(0,G.jsx)(te,{}),theme:`borderless`,type:`tertiary`,className:`chat-composer-hitl`,"aria-label":N(`chat.hitlTitle`,null,`人机协同`),disabled:!j,onClick:j,children:N(`chat.hitlTitle`,null,`人机协同`)})]}),(0,G.jsxs)(`div`,{className:`chat-composer-submit`,children:[(0,G.jsx)(h,{trigger:`click`,position:`topRight`,className:`chat-model-popover`,condition:!ve,content:(0,G.jsx)(ut,{model:k,busy:ve||B,canReadConfig:ee}),children:(0,G.jsxs)(x,{theme:`borderless`,type:`tertiary`,className:`chat-composer-model`,"aria-label":N(`chat.modelSettingsAria`,null,`选择 AI 通道、模型与推理设置`),title:`${V} · ${be}`,disabled:ve,children:[(0,G.jsx)(`span`,{className:`chat-composer-model-name`,children:V}),(0,G.jsx)(`span`,{className:`chat-composer-effort`,children:be}),(0,G.jsx)(d,{size:`small`})]})}),s?(0,G.jsx)(x,{type:`danger`,className:`chat-composer-send`,icon:(0,G.jsx)(ue,{}),"aria-label":N(`chat.stop`,null,`停止`),onClick:i,disabled:!a}):(0,G.jsx)(P,{content:N(`chat.sendHint`,null,`Enter 发送 · Shift+Enter 换行`),children:(0,G.jsx)(x,{theme:`solid`,className:`chat-composer-send`,icon:(0,G.jsx)(A,{}),"aria-label":N(`chat.send`,null,`发送`),disabled:B||c||O||_e>0,onClick:r})})]})]}),_e>0&&(0,G.jsx)(Xt,{type:`tertiary`,size:`small`,role:`status`,children:N(`chat.waitingAttachmentsUpload`,null,`附件上传中…`)})]})})]})}var{Text:en}=u,tn={approval:`仅审批`,feedback:`审批并反馈`,followup:`审批并追问`,review_edit:`审查编辑`};function nn(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 rn({item:e,busy:t,readOnly:n,onApprove:r,onReject:i,onDismiss:o}){let s=R(),c=(0,W.useMemo)(()=>nn(e),[e]),[u,d]=(0,W.useState)(``);if(!c)return null;let f=X(c.args,4e3),m=tn[c.mode]||c.mode,h=n||t||!c.interruptId;return(0,G.jsxs)(l,{className:`chat-hitl-card`,bordered:!0,title:(0,G.jsxs)(`span`,{className:`chat-hitl-title`,children:[(0,G.jsx)(`span`,{children:s(`chat.hitlTitle`,null,`人工审批`)}),(0,G.jsx)(v,{size:`small`,color:`orange`,shape:`circle`,children:m}),(0,G.jsx)(`span`,{className:`chat-hitl-tool`,children:c.toolName})]}),headerExtraContent:(0,G.jsx)(en,{type:`tertiary`,size:`small`,children:c.createdAt?L(c.createdAt):``}),children:[(0,G.jsxs)(`div`,{className:`chat-hitl-meta`,children:[c.reviewer&&(0,G.jsxs)(en,{type:`tertiary`,size:`small`,children:[`审批人:`,c.reviewer===`audit_agent`?`审计代理`:`人工`]}),c.expiresAt&&(0,G.jsxs)(en,{type:`tertiary`,size:`small`,children:[`到期:`,L(c.expiresAt)]}),c.conversationId&&(0,G.jsxs)(en,{type:`tertiary`,size:`small`,children:[`会话:`,String(c.conversationId).slice(0,8)]})]}),f&&(0,G.jsx)(M,{className:`chat-block-collapse`,children:(0,G.jsx)(M.Panel,{itemKey:`1`,header:(0,G.jsx)(`span`,{className:`chat-block-title`,children:`调用参数`}),children:(0,G.jsx)(`pre`,{className:`chat-pre`,children:f})})}),(0,G.jsxs)(`div`,{className:`chat-hitl-actions`,children:[(0,G.jsx)(C,{size:`small`,placeholder:s(`chat.hitlComment`,null,`审批备注(拒绝时建议填写原因)`),disabled:n,value:u,onChange:d,className:`chat-hitl-comment`}),(0,G.jsxs)(p,{children:[(0,G.jsx)(x,{theme:`solid`,size:`small`,icon:(0,G.jsx)(a,{}),disabled:h,onClick:()=>r(c,u),children:s(`chat.hitlApprove`,null,`批准`)}),(0,G.jsx)(x,{type:`danger`,size:`small`,icon:(0,G.jsx)(T,{}),disabled:h,onClick:()=>i(c,u),children:s(`chat.hitlReject`,null,`拒绝`)}),(0,G.jsx)(x,{size:`small`,theme:`borderless`,disabled:h,onClick:()=>o(c),children:s(`chat.hitlDismiss`,null,`忽略`)})]})]})]})}var{Text:an}=u;function on({items:e,busyId:t,readOnly:n,onRefresh:r,onDecide:i,onDismiss:a}){let o=R(),s=Array.isArray(e)?e:[];return s.length?(0,G.jsxs)(`div`,{className:`chat-hitl-dock`,children:[(0,G.jsxs)(`div`,{className:`chat-hitl-dock-head`,children:[(0,G.jsx)(an,{strong:!0,children:o(`chat.pendingApprovals`,{count:s.length},`待审批 ${s.length}`)}),(0,G.jsx)(x,{size:`small`,theme:`borderless`,icon:(0,G.jsx)(de,{}),onClick:r})]}),s.map(e=>(0,G.jsx)(rn,{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:sn}=u,cn={pending:{color:`grey`,label:`待处理`},in_progress:{color:`blue`,label:`进行中`},completed:{color:`green`,label:`已完成`},blocked:{color:`orange`,label:`阻塞`},deleted:{color:`grey`,label:`已删除`}};function ln({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,G.jsxs)(`div`,{className:`chat-plan`,children:[(0,G.jsxs)(`div`,{className:`chat-plan-toolbar`,children:[(0,G.jsx)(sn,{type:`tertiary`,size:`small`,children:e?.running?r(`chat.planRunning`,null,`任务执行中`):r(`chat.planIdle`,null,`当前没有运行中的任务`)}),(0,G.jsx)(x,{size:`small`,icon:(0,G.jsx)(de,{}),onClick:n,loading:t,children:r(`common.refresh`,null,`刷新`)})]}),(0,G.jsx)(re,{percent:s,showInfo:!0}),(0,G.jsx)(sn,{type:`tertiary`,size:`small`,children:r(`chat.planSummary`,{total:a,done:o},`共 ${a} 项,已完成 ${o} 项`)}),!i.length&&(0,G.jsx)(c,{title:r(`chat.planEmpty`,null,`暂无执行计划`),description:r(`chat.planEmptyHint`,null,`代理调用任务工具后,这里会显示任务看板。`),style:{padding:24}}),(0,G.jsx)(`div`,{className:`chat-plan-list`,children:i.map((e,t)=>{let n=String(e.status||`pending`).toLowerCase(),r=cn[n]||cn.pending;return(0,G.jsxs)(`div`,{className:`chat-plan-item ${n===`in_progress`?`is-active`:``}`,children:[(0,G.jsxs)(`div`,{className:`chat-plan-item-head`,children:[(0,G.jsx)(`span`,{className:`chat-plan-index`,children:t+1}),(0,G.jsx)(`span`,{className:`chat-plan-subject`,children:e.subject||e.activeForm||`—`}),(0,G.jsx)(v,{size:`small`,color:r.color,shape:`circle`,children:r.label})]}),e.description&&(0,G.jsx)(`div`,{className:`chat-plan-desc`,children:e.description})]},e.id||t)})})]})}function un({visible:e,onClose:t,plan:n,loading:r,onRefresh:i}){let a=R()(`chat.planTasks`,null,`执行计划`);return(0,G.jsx)(le,{title:a,"aria-label":a,visible:e,onCancel:t,width:`min(100%, 560px)`,placement:`right`,children:(0,G.jsx)(ln,{plan:n,loading:r,onRefresh:i})})}function dn({conversationRef:e,bindConversation:t,requestDetailReload:n,onTaskStarted:r,onSettled:i,onHitlEvent:a,onPlanTool:o,t:s}){let[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)([]),m=(0,W.useRef)(null),h=(0,W.useRef)(null),g=(0,W.useRef)(null),_=(0,W.useRef)(null),v=(0,W.useCallback)(()=>{_.current&&(clearTimeout(_.current),_.current=null)},[]),y=(0,W.useCallback)((e=!1)=>{let t=()=>{g.current=null,m.current&&l({...m.current})};e?(g.current&&(clearTimeout(g.current),g.current=null),t()):g.current||(g.current=setTimeout(t,80))},[]),b=(0,W.useCallback)(t=>{if(!t||t.markedFinished||h.current!==t)return;t.markedFinished=!0,v(),t.live.status===`streaming`&&(t.live.status=t.live.error?`error`:`done`,t.live.endedAt=Date.now()),y(!0),i?.(),d(!1),p(t.live.events.slice(-80));let r=t.live.conversationId||e.current;r?Promise.resolve(n?.(r,{silent:!0})).then(e=>{h.current===t&&e&&(h.current=null,m.current=null,l(null))}):(h.current=null,m.current=null,l(null))},[v,e,y,i,n]);return{live:c,sending:u,lastEvents:f,send:(0,W.useCallback)(({message:n,attachments:i,mode:c,projectId:u,role:f,aiChannelId:g,reasoning:x,hitl:S,requireHumanApproval:C})=>{v();let w={live:Z({conversationId:e.current}),markedFinished:!1,stopRequested:!1,abort:null};h.current=w,m.current=w.live,l({...w.live}),d(!0),p([]),_.current=setTimeout(()=>{_.current=null,!w.markedFinished&&h.current===w&&r?.()},200);let T=c!==`single`,E={message:n,conversationId:e.current||``,aiChannelId:g,reasoning:x,hitl:S,requireHumanApproval:C||void 0};!e.current&&u&&(E.projectId=u),f&&(E.role=f),T&&(E.orchestration=c),Array.isArray(i)&&i.length&&(E.attachments=i.map(e=>({fileName:e.fileName,mimeType:e.mimeType||``,serverPath:e.serverPath}))),w.abort=ve(T?`/multi-agent/stream`:`/agent/stream`,E,{onEvent(n){if(w.markedFinished||h.current!==w)return;Ot(w.live,n);let r=n?.type;if(r===`conversation`&&n?.data?.conversationId){let r=String(n.data.conversationId);w.live.conversationId=r,e.current!==r&&t?.(r)}(r===`hitl_interrupt`||r===`hitl_resumed`||r===`hitl_rejected`)&&a?.(),(r===`tool_call`||r===`tool_result`)&&ht.has(String(n?.data?.toolName||``).toLowerCase())&&o?.(),r===`done`||r===`error`||r===`cancelled`?b(w):y()},onError(e){w.markedFinished||h.current!==w||(w.live.status=`error`,w.live.error=ke(e,s(`chat.streamFailed`,null,`流式连接失败`)),w.live.endedAt=Date.now(),b(w))},onClose(){w.markedFinished||h.current!==w||(w.live.status=`disconnected`,w.live.endedAt=Date.now(),w.stopRequested||(w.live.notice=s(`chat.streamEndedWithoutDone`,null,`连接提前结束,未收到任务完成信号。任务可能仍在后端执行。`),B(w.live.notice)),b(w))}})},[t,v,e,b,y,a,o,r,s]),stop:(0,W.useCallback)(async(t=``)=>{let r=h.current,i=typeof t==`string`?t.trim():``,a=r&&!r.markedFinished&&(r.live?.conversationId||e.current)||``,o=i||e.current||a||``,c=!(!r||r.markedFinished||i&&o!==a);if(o)try{await z.post(`/agent-loop/cancel`,{conversationId:o}),c&&r&&(r.stopRequested=!0),De(s(`chat.stopRequested`,null,`已请求停止任务`))}catch(e){B(ke(e,s(`chat.stopFailed`,null,`停止请求失败`)))}c&&r?.abort?.(),setTimeout(()=>{o&&e.current===o&&n?.(o,{silent:!0,force:!0})},900)},[e,n,s]),reset:(0,W.useCallback)(()=>{v();let e=h.current;e&&!e.markedFinished&&e.abort?.(),h.current=null,m.current=null,g.current&&(clearTimeout(g.current),g.current=null),l(null),d(!1),p([])},[]),isStreaming:(0,W.useCallback)(e=>{let t=h.current;return!!(t&&!t.markedFinished&&e&&t.live.conversationId===e)},[])}}function fn({t:e,conversationRef:t,newProjectId:n,canWrite:r,reloadList:i,requestDetailReload:a,navigate:o,onSelectionCleared:s}){return{createConversation:(0,W.useCallback)(async()=>{if(r)try{let t=(await z.post(`/conversations`,{title:e(`chat.newChat`,null,`新对话`),projectId:n||void 0}))?.id;i(),t&&o({conversation:t}),De(e(`chat.created`,null,`已创建对话`))}catch(t){V(t,e(`chat.createFailed`,null,`创建对话失败`))}},[r,o,n,i,e]),renameConversation:(0,W.useCallback)(async(n,r)=>{try{await z.put(`/conversations/${encodeURIComponent(n)}`,{title:r}),De(e(`chat.renamed`,null,`已重命名`)),i(),n===t.current&&a(n,{silent:!0})}catch(t){V(t,e(`chat.renameFailed`,null,`重命名失败`))}},[t,i,a,e]),togglePin:(0,W.useCallback)(async t=>{try{await z.put(`/conversations/${encodeURIComponent(t.id)}/pinned`,{pinned:!t.pinned}),i()}catch(t){V(t,e(`chat.pinFailed`,null,`置顶操作失败`))}},[i,e]),deleteConversation:(0,W.useCallback)(async n=>{try{await z.del(`/conversations/${encodeURIComponent(n.id)}`),De(e(`chat.deleted`,null,`已删除对话`)),n.id===t.current&&(s(),o({},{replace:!0})),i()}catch(t){V(t,e(`chat.deleteFailed`,null,`删除对话失败`))}},[t,o,s,i,e]),batchDelete:(0,W.useCallback)(async n=>{let r=(await Promise.allSettled(n.map(e=>z.del(`/conversations/${encodeURIComponent(e)}`)))).filter(e=>e.status===`rejected`).length;r?B(e(`chat.batchDeletePartial`,{failed:r},`有 ${r} 个对话删除失败`)):De(e(`chat.batchDeleted`,{count:n.length},`已删除 ${n.length} 个对话`)),n.includes(t.current)&&(s(),o({},{replace:!0})),i()},[t,o,s,i,e]),deleteTurn:(0,W.useCallback)(n=>{let r=t.current;r&&n?.id&&Oe({title:e(`chat.deleteTurnTitle`,null,`删除本轮`),content:e(`chat.deleteTurnConfirm`,null,`将删除该轮提问与全部回答,删除后不可恢复。`),okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{await z.post(`/conversations/${encodeURIComponent(r)}/delete-turn`,{messageId:n.id}),De(e(`chat.turnDeleted`,null,`已删除该轮`)),await a(r,{silent:!0}),i()}catch(t){V(t,e(`chat.deleteTurnFailed`,null,`删除轮次失败`))}}})},[t,i,a,e])}}var{Text:pn}=u,mn=20,hn=`__none__`,gn=`csai-chat-agent-mode`,_n=`csai-chat-role`;function vn(e){let t=typeof e==`string`?e.trim():``;return!t||t===`默认`?``:t}var yn={tasks:[],total:0,completed:0,activeStep:0,running:!1},bn={conversation:null,messages:[],loading:!1,error:null};function xn(e){let[t,n]=(0,W.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(e).matches);return(0,W.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 Sn(){let e=R(),{hasPermission:t}=ge(),n=t(`chat:write`),r=t(`project:write`),a=t(`agent:execute`),o=t(`chat:delete`),s=t(`tasks:read`),c=t(`tasks:write`),l=t(`hitl:read`),u=t(`hitl:write`),d=t(`config:read`),f=t(`roles:read`),[p,m]=i(),h=p.get(`conversation`)||``,g=(0,W.useRef)(h),_=(0,W.useRef)(null);(0,W.useLayoutEffect)(()=>{g.current=h},[h]);let[v,y]=(0,W.useState)(``),b=Ce(v,350),[S,C]=(0,W.useState)(``),[w,T]=(0,W.useState)(hn),[E,D]=(0,W.useState)(!0),[O,k]=(0,W.useState)(1),[ee,te]=(0,W.useState)(``),[A,j]=(0,W.useState)(!1),[ne,ie]=(0,W.useState)(!1),[ae,oe]=xe(gn,`single`),N=Zt.includes(ae)?ae:`single`,[se,ce]=xe(_n,``),[P,ue]=(0,W.useState)(()=>new Map),de=(0,W.useRef)(``),F=$e(d),[fe,pe]=(0,W.useState)(!1),[me,he]=(0,W.useState)(null),[I,L]=(0,W.useState)(bn),[_e,ve]=(0,W.useState)(()=>new Map),{draft:be=``,attachments:Se=[]}=_e.get(h)||{},H=(0,W.useCallback)((e,t)=>{ve(n=>{let r=new Map(n);return r.set(e,t(n.get(e)||{})),r})},[]),we=e=>H(h,t=>({...t,draft:e})),[Ee,Oe]=(0,W.useState)(null),ke=l&&Ee?.id===h?Ee.items:[],[Fe,Ie]=(0,W.useState)(``),[U,Le]=(0,W.useState)(yn),[Re,Be]=(0,W.useState)(!1),[Ve,He]=(0,W.useState)(!1),[We,Ge]=(0,W.useState)(!1),Ke=xn(`(max-width: 900px)`),Je=(0,W.useRef)(0),Ye=(0,W.useRef)(null),Xe=(0,W.useRef)({id:``,active:!1}),Ze=(0,W.useRef)(0),Qe=(0,W.useRef)(0),[et,tt]=(0,W.useState)(()=>new Set),nt=ye(async({signal:e}={})=>{let t=await z.get(`/agent-loop/tasks`,null,{signal:e}),n=Array.isArray(t?.tasks)?t.tasks.filter(Boolean):[];return{checkedId:h,tasks:n}},[h,s],{skip:!s}),rt=(0,W.useRef)(nt.reload);(0,W.useEffect)(()=>{rt.current=nt.reload},[nt.reload]);let it=(0,W.useMemo)(()=>s&&Array.isArray(nt.data?.tasks)?nt.data.tasks:[],[nt.data,s]),K=!!(s&&h&&it.some(e=>e.conversationId===h&&!ze.has(String(e.status||``).toLowerCase()))),at=!!(s&&h&&nt.data?.checkedId!==h&&!nt.error),ot=(0,W.useRef)(null),q=ye(async({signal:e}={})=>({...await z.get(`/conversations`,{limit:mn,offset:(O-1)*mn,search:b||void 0,project_id:w,group_by_project:1},{signal:e}),projectGroup:w,page:O,search:b}),[O,b,w]),st=(0,W.useRef)(q.reload);(0,W.useEffect)(()=>{st.current=q.reload},[q.reload]);let ct=ye(({signal:e}={})=>z.get(`/projects`,{limit:200},{signal:e}),[]),lt=ye(({signal:e}={})=>z.get(`/roles`,null,{signal:e}),[f],{skip:!f}),ut=(0,W.useMemo)(()=>Array.isArray(ct.data?.projects)?ct.data.projects:[],[ct.data]),ft=(0,W.useMemo)(()=>(Array.isArray(lt.data?.roles)?lt.data.roles:[]).filter(e=>e&&String(e.name||``).trim()).map(e=>({name:String(e.name).trim(),description:String(e.description||``),icon:String(e.icon||``),enabled:e.enabled!==!1})),[lt.data]),pt=e=>{ie(!1),e?.id&&(ct.setData(t=>({...t,projects:[e,...t?.projects||[]]})),Dt(e.id))},ht=Array.isArray(q.data?.projectGroups)?q.data.projectGroups:[],gt=q.data?.projectGroup===w&&q.data?.search===b,_t=gt&&q.data?.page===O,vt=_t&&Array.isArray(q.data.conversations)?q.data.conversations:[],J=gt&&q.data.total||0;(0,W.useEffect)(()=>{if(!_t)return;let e=Math.max(1,Math.ceil(J/mn));O>e&&k(e)},[_t,J,O]);let yt=(0,W.useCallback)(e=>{T(e),D(!0),k(1)},[]),Y=(0,W.useCallback)(async(e,{silent:t=!1,force:n=!1}={})=>{if(!e)return Ye.current?.abort(),Ye.current=null,Xe.current={id:``,active:!1},L(bn),null;if(t&&!n&&Xe.current.active&&Xe.current.id===e)return null;Ye.current?.abort();let r=new AbortController;Ye.current=r,Xe.current={id:e,active:!0};let i=++Je.current;t||L(e=>({...e,loading:!0,error:null}));try{let t=await z.get(`/conversations/${encodeURIComponent(e)}`,{include_process_details:`summary`},{signal:r.signal});return r.signal.aborted||i!==Je.current||g.current!==e?null:(L({conversation:t||null,messages:Array.isArray(t?.messages)?t.messages:[],loading:!1,error:null}),t)}catch(t){return r.signal.aborted||i===Je.current&&g.current===e&&L(e=>({...e,loading:!1,error:t})),null}finally{Ye.current===r&&(Ye.current=null,Xe.current={id:``,active:!1})}},[]);(0,W.useEffect)(()=>()=>{Ye.current?.abort(),Ye.current=null,Xe.current={id:``,active:!1}},[]);let X=(0,W.useCallback)(async()=>{let e=g.current,t=++Ze.current;if(e&&l)try{let n=await z.get(`/hitl/pending`,{conversationId:e,pageSize:50});if(t!==Ze.current||g.current!==e)return;let r=(Array.isArray(n?.items)?n.items:[]).filter(t=>!t.conversationId||t.conversationId===e);Oe({id:e,items:r})}catch{}},[l]),Z=(0,W.useCallback)(async()=>{let e=g.current;if(!e){Le(yn);return}let t=++Qe.current;Be(!0);try{let n=await z.get(`/conversations/${encodeURIComponent(e)}/plan-tasks`);t===Qe.current&&g.current===e&&Le(n&&typeof n==`object`?n:yn)}catch{}finally{t===Qe.current&&g.current===e&&Be(!1)}},[]),Q=dn({conversationRef:g,bindConversation:(0,W.useCallback)(e=>{he(null),_.current=e,g.current=e,ue(t=>{if(t.has(e))return t;let n=new Map(t);return n.set(e,de.current),n}),m({conversation:e},{replace:!0}),st.current?.({silent:!0})},[m]),requestDetailReload:Y,onTaskStarted:(0,W.useCallback)(()=>{rt.current?.({silent:!0,force:!0})},[]),onSettled:(0,W.useCallback)(()=>{rt.current?.({silent:!0,force:!0}),st.current?.({silent:!0}),X(),Z()},[X,Z]),onHitlEvent:X,onPlanTool:Z,t:e}),{live:bt,sending:$,lastEvents:xt,reset:St,isStreaming:Ct}=Q;(0,W.useEffect)(()=>{let e=h&&_.current===h;_.current=null,e||Ct(h)||(St(),Ye.current?.abort(),Ye.current=null,Xe.current={id:``,active:!1},Je.current++,Ze.current++,Qe.current++,L(bn),Oe(null),Ie(``),Le(yn),Be(!1),He(!1),h&&(Y(h),X(),Z()))},[h,Ct,St,Y,X,Z]),Te(()=>{typeof document<`u`&&document.hidden||(($||K)&&(X(),Z()),s&&rt.current?.({silent:!0}),K&&!$&&g.current&&Y(g.current,{silent:!0}))},$||K||it.length>0?4e3:s?6e3:0),(0,W.useEffect)(()=>{if(!s||typeof document>`u`)return;let e=()=>{document.hidden||rt.current?.({silent:!0})};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[s]),(0,W.useEffect)(()=>{ot.current===h&&!K&&(Y(h,{silent:!0,force:!0}),st.current?.({silent:!0}),X(),Z()),ot.current=K?h:null},[K,h,Y,X,Z]);let wt=(0,W.useCallback)(async(e=``)=>{if(!c)return;let t=typeof e==`string`?e.trim():``,n=t||g.current||bt?.conversationId||``;n&&tt(e=>{let t=new Set(e);return t.add(n),t});try{await Q.stop(t),await rt.current?.({silent:!0,force:!0}),st.current?.({silent:!0}),X(),Z(),setTimeout(()=>{rt.current?.({silent:!0,force:!0}),st.current?.({silent:!0}),X(),Z()},950)}finally{n&&tt(e=>{if(!e.has(n))return e;let t=new Set(e);return t.delete(n),t})}},[c,bt?.conversationId,X,Z,Q]),Tt=(0,W.useCallback)(e=>{e&&(e!==g.current&&m({conversation:e}),Ge(!1))},[m]),Et=(0,W.useCallback)(()=>{st.current?.({silent:!0})},[]),Dt=async t=>{if(!n||$||K||at||A)return;let r=t||``,i=g.current;if(!i)te(r);else if(!(I.conversation?.id!==i||I.loading||I.error)){j(!0);try{await z.put(`/conversations/${encodeURIComponent(i)}/project`,{projectId:r}),L(e=>e.conversation?.id===i?{...e,conversation:{...e.conversation,projectId:r}}:e),S&&S!==r||yt(r||hn),Et()}catch(t){V(t,e(`chat.projectChangeFailed`,null,`更新对话所属项目失败`))}finally{j(!1)}}},{createConversation:Ot,renameConversation:kt,togglePin:At,deleteConversation:jt,batchDelete:Mt,deleteTurn:Nt}=fn({t:e,conversationRef:g,newProjectId:ee,canWrite:n,reloadList:Et,requestDetailReload:Y,navigate:m,onSelectionCleared:(0,W.useCallback)(()=>L(bn),[])}),Pt=(0,W.useCallback)(async(t,n,r)=>{let i=g.current;if(u&&t?.interruptId&&Ee?.id===i&&Ee.items.some(e=>String(e.id||e.interruptId)===t.interruptId)){Ie(t.interruptId);try{await z.post(`/hitl/decision`,{interruptId:t.interruptId,decision:n,comment:r||``}),De(n===`approve`?e(`chat.hitlApproved`,null,`已批准本次调用`):e(`chat.hitlRejected`,null,`已拒绝本次调用`)),Oe(e=>e?.id===i?{id:i,items:e.items.filter(e=>String(e.id||e.interruptId)!==t.interruptId)}:e)}catch(t){V(t,e(`chat.hitlDecisionFailed`,null,`提交审批失败`))}finally{g.current===i&&(Ie(``),X())}}},[Ee,u,X,e]),Ft=(0,W.useCallback)(async t=>{let n=g.current;if(u&&t?.interruptId&&Ee?.id===n&&Ee.items.some(e=>String(e.id||e.interruptId)===t.interruptId)){Ie(t.interruptId);try{await z.post(`/hitl/dismiss`,{interruptId:t.interruptId}),De(e(`chat.hitlDismissed`,null,`已忽略该审批`)),Oe(e=>e?.id===n?{id:n,items:e.items.filter(e=>String(e.id||e.interruptId)!==t.interruptId)}:e)}catch(t){V(t,e(`chat.hitlDismissFailed`,null,`忽略审批失败`))}finally{g.current===n&&(Ie(``),X())}}},[Ee,u,X,e]),It=(0,W.useCallback)(async t=>{let n=g.current,r=e=>H(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 z.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)),V(t,e(`chat.attachmentUploadFailed`,{name:i.fileName},`附件 ${i.fileName} 上传失败`))}}))},[H,e]),Lt=(0,W.useCallback)(e=>{H(h,t=>({...t,attachments:(t.attachments||[]).filter(t=>t.id!==e)}))},[h,H]),Rt=P.has(h),zt=I.conversation?.id===h?I.conversation:null,Bt=!h||Rt||!!zt,Vt=Rt?vn(P.get(h)):zt?vn(zt.roleName):h?``:vn(se),Ht=(0,W.useCallback)(e=>{let t=vn(e);ce(t),ue(e=>{let n=new Map(e);return n.set(h,t),n})},[h,ce]),Ut=(0,W.useCallback)(()=>{if(!n||!a||$||K||at||A||F.waitingForChannel||!Bt)return;let t=be.trim();if(!t&&!Se.length){B(e(`chat.emptyMessage`,null,`请输入内容或添加附件`));return}if(Se.some(e=>e.uploading)){B(e(`chat.waitingAttachmentsUpload`,null,`附件仍在上传,请稍候`));return}let r=Se.filter(e=>e.serverPath&&!e.error);if(Se.length&&r.length!==Se.length){B(e(`chat.attachmentsUploadIncomplete`,null,`存在上传失败的附件,请移除后再发送`));return}let i=t||e(`chat.filePrompt`,null,`请解析我上传的附件。`),o=r.length?`${i}\n${r.map(e=>`📎 ${e.fileName}`).join(`
`)}`:i;L(e=>({...e,messages:[...e.messages||[],{id:`local-${Date.now()}`,role:`user`,content:o,createdAt:new Date().toISOString()}]})),St(),H(h,()=>({draft:``,attachments:[]})),de.current=Vt,Q.send({message:i,attachments:r,mode:N,projectId:ee,role:Vt,...F.request,hitl:!h&&u&&me||void 0})},[Se,K,n,a,u,at,h,be,me,N,F,ee,A,St,Vt,Bt,Q,$,e,H]),Wt=(0,W.useRef)(new Set),Gt=(0,W.useRef)(``),Kt=(0,W.useRef)(``);(0,W.useEffect)(()=>{if(!h)return;let t=Ae(h);if(!t)return;let r=String(t.prompt||``).trim();if(!r){je(h);return}if(I.error||!n||!a){Gt.current!==h&&(Gt.current=h,je(h),B(e(`vulnerabilityRetest.startFailed`,null,`复测尚未成功发送,提示词已保存在分支中,请返回该分支继续。`)));return}if($||K||at||!Bt||I.conversation?.id!==h)return;je(h);let i=g.current;Wt.current.add(i),H(i,e=>({...e,draft:``,attachments:[]})),L(e=>e.conversation?.id===i?{...e,messages:[...e.messages||[],{id:`local-${Date.now()}`,role:`user`,content:r,createdAt:new Date().toISOString()}]}:e),St(),Q.send({message:r,mode:N,role:Vt,...F.request})},[h,I.conversation,I.error,$,K,at,Bt,n,a,N,F,St,Vt,Q,e,H]),(0,W.useEffect)(()=>{if(h)return;let e=Me();if(!e)return;let t=String(e.prompt||``).trim();t?$||K||at||F.waitingForChannel||!Bt||(Ne(),n&&a&&e.autoSend!==!1?(L(e=>({...e,messages:[...e.messages||[],{id:`local-${Date.now()}`,role:`user`,content:t,createdAt:new Date().toISOString()}]})),St(),H(``,()=>({draft:``,attachments:[]})),de.current=Vt,Q.send({message:t,mode:N,projectId:ee,role:Vt,...F.request,hitl:u&&me||void 0})):H(``,e=>({...e,draft:t}))):Ne()},[h,$,K,at,F,Bt,n,a,u,me,N,ee,St,Vt,Q,H]),(0,W.useEffect)(()=>{let e=I.conversation,t=String(e?.retest?.pending_prompt||``).trim();h&&e?.id===h&&t&&(Wt.current.has(h)||Ae(h)||$||K||String(be||``).trim()||Kt.current!==h&&(Kt.current=h,H(h,e=>({...e,draft:t}))))},[h,I.conversation,be,$,K,H]);let qt=I.conversation,Jt=(0,W.useRef)(``);(0,W.useEffect)(()=>{if(!h){Jt.current=``;return}if(qt?.id!==h||Jt.current===h)return;Jt.current=h;let e=qt.projectId||hn;S&&S!==e||w===e&&E||yt(e)},[qt,h,E,yt,S,w]);let Xt=ht.find(e=>!e.projectId)?.total||0,Qt=[{id:hn,title:e(`chat.defaultWorkspace`,null,`默认工作区`),total:Xt},...ht.filter(e=>e.projectId).map(t=>({id:t.projectId,title:ut.find(e=>e.id===t.projectId)?.name||e(`chat.boundProject`,null,`已绑定项目`),total:t.total,projectId:t.projectId}))],en=(0,G.jsx)(mt,{items:E?vt:[],groups:Qt.filter(e=>!S||e.id===S),expandedGroup:E?w:``,groupTotal:J,onToggleGroup:e=>{e===w&&E?D(!1):e===w?D(!0):yt(e)},loading:q.loading||!_t&&!q.error,error:q.error,onRetry:()=>q.reload(),search:v,onSearch:e=>{y(e),k(1)},projectId:S,onProjectChange:e=>{C(e||``),yt(e||hn)},projects:ut,page:O,pageSize:mn,onPageChange:k,selectedId:h,onSelect:Tt,onCreate:Ot,onRename:kt,onPin:At,onDelete:jt,onBatchDelete:Mt,canWrite:n,canDelete:o}),tn=(0,W.useCallback)(()=>h?Y(h,{force:!0}):null,[h,Y]);return(0,G.jsxs)(`div`,{className:`chat-page`,children:[!Ke&&(0,G.jsx)(`aside`,{className:`chat-sidebar`,children:en}),(0,G.jsxs)(`section`,{className:`chat-main`,children:[(0,G.jsx)(qe,{conversation:qt,mode:N,hitlCount:ke.length,conversationId:h,narrow:Ke,onToggleSidebar:()=>Ge(!0),onRefresh:()=>{rt.current?.({silent:!0,force:!0}),st.current?.(),h&&Y(h),X(),Z()}}),(0,G.jsxs)(`div`,{className:`chat-panel`,children:[(0,G.jsx)(Ue,{tasks:it,currentConversationId:h,currentConversationTitle:qt?.id===h?qt?.title:``,canStop:c,stoppingIds:et,onSelect:Tt,onStop:wt}),(0,G.jsx)(Yt,{conversationId:h,messages:I.messages,live:bt,loading:I.loading||!(!h||I.conversation||I.error),error:I.error,onRetry:tn,canDelete:o,onDeleteTurn:Nt}),U.running&&U.total>0&&(0,G.jsxs)(`div`,{className:`chat-plan-strip`,children:[(0,G.jsx)(pn,{size:`small`,children:e(`chat.planTasks`,null,`执行计划`)}),(0,G.jsx)(re,{percent:Math.round(Number(U.completed||0)/Math.max(1,Number(U.total))*100),showInfo:!1,size:`small`,className:`chat-plan-strip-bar`}),(0,G.jsxs)(pn,{size:`small`,type:`tertiary`,children:[U.completed,`/`,U.total,U.activeStep?` · ${e(`chat.planStep`,{step:U.activeStep},`第 ${U.activeStep} 步`)}`:``]}),(0,G.jsx)(x,{size:`small`,theme:`borderless`,onClick:()=>{Z(),He(!0)},children:e(`chat.planDetails`,null,`详情`)})]}),xt.length>0&&!bt&&(0,G.jsx)(M,{className:`chat-events-strip`,children:(0,G.jsx)(M.Panel,{itemKey:`1`,header:`${e(`chat.rawEvents`,null,`本轮原始事件`)} · ${xt.length}`,children:(0,G.jsx)(`pre`,{className:`chat-pre`,children:xt.map((e,t)=>`${t+1}. ${JSON.stringify(e)}`).join(`
diff --git a/web/static/app/assets/chat-files-BvkWbj5T.js b/web/static/app/assets/chat-files-2SCIFZPr.js
similarity index 99%
rename from web/static/app/assets/chat-files-BvkWbj5T.js
rename to web/static/app/assets/chat-files-2SCIFZPr.js
index 20cba5b5..fd1cfb8f 100644
--- a/web/static/app/assets/chat-files-BvkWbj5T.js
+++ b/web/static/app/assets/chat-files-2SCIFZPr.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{G as r,I as i,N as a,R as o,U as s,W as c,X as ee,ft as l,lt as u,p as d,ut as f,y as p}from"./semi-65W_4I1v.js";import{E as m,F as h,I as te,L as g,R as _,S as ne,T as v,a as re,b as y,c as ie,l as b,m as x,n as ae,o as S,p as oe,s as se,x as C,y as ce}from"./index-DNMXun-U.js";var w=e(t(),1);function le(e){return g.get(`/chat-uploads`,e)}function ue(e,{relativeDir:t}={}){let n=new FormData;return n.append(`file`,e,e.name),t&&n.append(`relativeDir`,t),g.post(`/chat-uploads`,n)}function de(e,t){return g.post(`/chat-uploads/mkdir`,{parent:e||``,name:t})}function fe(e){return g.del(`/chat-uploads`,{body:{path:e}})}function T(e){return g.get(`/chat-uploads/content`,{path:e})}function pe(e,t=`file`){return g.get(`/chat-uploads/path`,{path:e,kind:t})}function me(e){return _(`/chat-uploads/export`,{query:e,filename:`chat-files-export.zip`})}function E(e,t){return _(`/chat-uploads/download`,{query:{path:e},filename:t})}async function D(e){let t=await(await g.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}=r,he=/\.(png|jpe?g|gif|webp|bmp|svg|ico)$/i,A=/\.(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 j(e){let t=e?.name||``;return he.test(t)?`image`:A.test(t)?`text`:`binary`}function ge({item:e,onClose:t}){let n=h(),[r,i]=(0,w.useState)(!1),[a,s]=(0,w.useState)(null),[ee,l]=(0,w.useState)(``),[u,f]=(0,w.useState)(``),[p,m]=(0,w.useState)(`text`);return(0,w.useEffect)(()=>{let t=``,n=!1;if(!e)return l(``),f(``),s(null),()=>{};let r=j(e);return m(r),i(!0),s(null),l(``),f(``),(async()=>{try{if(r===`image`){let r=await D(e.relativePath);if(n){URL.revokeObjectURL(r.url);return}t=r.url,f(r.url)}else if(r===`text`){let t=await T(e.relativePath);if(n)return;l(t?.content??``)}}catch(e){n||(s(e),r===`text`&&m(`binary`))}finally{n||i(!1)}})(),()=>{n=!0,t&&URL.revokeObjectURL(t)}},[e]),(0,O.jsx)(d,{visible:!!e,title:e?.name||n(`chatFilesPage.previewTitle`,null,`文件预览`),width:720,onCancel:t,footer:(0,O.jsx)(o,{onClick:async()=>{if(e)try{await E(e.relativePath,e.name)}catch(e){y(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:v(e.size)}),(0,O.jsx)(k,{type:`tertiary`,size:`small`,className:`chat-files-mono`,children:e.relativePath}),(0,O.jsx)(S,{text:e.relativePath,label:n(`chatFilesPage.copyPath`,null,`复制路径`),size:`small`})]}),(0,O.jsx)(b,{error:p===`binary`?null:a}),r&&(0,O.jsx)(`div`,{className:`chat-files-preview-loading`,children:(0,O.jsx)(c,{})}),!r&&p===`image`&&u&&(0,O.jsx)(`img`,{className:`chat-files-preview-image`,src:u,alt:e.name}),!r&&p===`text`&&(0,O.jsx)(`pre`,{className:`chat-files-preview-text`,children:ee}),!r&&p===`binary`&&(0,O.jsx)(k,{type:`tertiary`,children:n(`chatFilesPage.editBinaryHint`,null,`图片、压缩包等二进制文件无法在此以文本方式编辑,请使用「下载」后在本地查看或处理。`)})]})})}var{Text:M}=r,_e=[{value:`all`,label:`全部`},{value:`upload`,label:`对话附件`},{value:`reduction`,label:`工具输出`},{value:`workspace`,label:`工作目录`},{value:`conversation_artifact`,label:`会话产物`}],ve={upload:`对话附件`,reduction:`工具输出`,workspace:`工作目录`,conversation_artifact:`会话产物`};function N(e){let t=String(e||``).split(`/`);return t.pop(),t.join(`/`)}function P(e){let t=String(e||``).split(`/`);return t[t.length-1]||e}function F(){let e=h(),{hasPermission:t}=te(),n=t(`files:write`),r=t(`files:delete`)||n,c=(0,w.useRef)(null),[d,g]=(0,w.useState)(`list`),[_,S]=(0,w.useState)(``),[T,D]=(0,w.useState)(``),[k,he]=(0,w.useState)(`all`),[A,j]=(0,w.useState)(``),[F,I]=(0,w.useState)(``),[L,R]=(0,w.useState)(1),[z,ye]=(0,w.useState)(20),[be,B]=(0,w.useState)(null),[V,H]=(0,w.useState)(null),[xe,U]=(0,w.useState)(!1),W=ae(A,300),G=(0,w.useMemo)(()=>{let e={conversation:_.trim()||void 0,project:T.trim()||void 0,source:k===`all`?void 0:k,search:W.trim()||void 0};return d===`browse`?{...e,page:1,pageSize:`all`}:{...e,page:L,pageSize:z}},[d,_,T,k,W,L,z]),{data:K,loading:q,error:Se,reload:J}=re(()=>le(G),[G]),Y=Array.isArray(K?.files)?K.files:[],X=Array.isArray(K?.folders)?K.folders:[],Z=Number(K?.total??Y.length),Q=(0,w.useMemo)(()=>d===`browse`?{folders:X.filter(e=>N(e)===F),files:Y.filter(e=>N(e.relativePath)===F)}:{folders:[],files:Y},[d,X,Y,F]),Ce=(0,w.useMemo)(()=>{let t=F?F.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},[F,e]),we=async t=>{try{let n=await pe(t.relativePath,`file`);await navigator.clipboard.writeText(n?.absolutePath||t.relativePath),C(e(`chatFilesPage.pathCopied`,null,`路径已复制,可到对话中粘贴使用`))}catch(t){y(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Te=async t=>{try{await E(t.relativePath,t.name)}catch(t){y(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Ee=t=>{ce({title:e(`chatFilesPage.confirmDelete`,null,`确定删除该文件?`),content:t.relativePath,onOk:async()=>{try{await fe(t.relativePath),C(e(`chatFilesPage.deleted`,null,`已删除`)),J()}catch(e){y(e)}}})},De=()=>c.current?.click(),Oe=async t=>{let n=Array.from(t.target.files||[]);if(t.target.value=``,n.length){U(!0);try{for(let e of n)await ue(e,{relativeDir:d===`browse`?F:``});C(e(`chatFilesPage.uploadOkHint`,null,`上传成功。点击「复制路径」可复制绝对路径到剪贴板。`)),J()}catch(t){y(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}finally{U(!1)}}},ke=async()=>{let t=String(V?.name||``).trim();if(!t||t.includes(`/`)||t.includes(`\\`)||t===`.`||t===`..`)ne(e(`chatFilesPage.mkdirInvalidName`,null,`名称无效:不能为空,且不能包含 /、\\ 或 . / ..`));else try{await de(d===`browse`?F:``,t),C(e(`chatFilesPage.mkdirOk`,null,`文件夹已创建`)),H(null),J()}catch(t){y(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Ae=async()=>{try{await me({conversation:_.trim()||void 0,project:T.trim()||void 0,source:k===`all`?void 0:k,search:W.trim()||void 0}),C(e(`chatFilesPage.exportStarted`,null,`已开始导出当前文件`))}catch(t){y(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:()=>B(t),title:t.relativePath,children:e||P(t.relativePath)})},{title:e(`chatFilesPage.sourceFilter`,null,`来源`),dataIndex:`source`,width:110,render:e=>(0,O.jsx)(a,{size:`small`,children:ve[e]||e||`对话附件`})},{title:e(`chatFilesPage.colConversation`,null,`会话`),dataIndex:`conversationTitle`,width:180,render:(e,t)=>(0,O.jsx)(M,{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=>v(e)},{title:e(`chatFilesPage.colModified`,null,`修改时间`),dataIndex:`modifiedUnix`,width:170,render:e=>m(e?e*1e3:null)},{title:e(`chatFilesPage.colActions`,null,`操作`),dataIndex:`actions`,width:260,render:(t,n)=>(0,O.jsxs)(i,{spacing:4,wrap:!0,children:[(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>B(n),children:e(`chatFilesPage.preview`,null,`预览`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>we(n),children:e(`chatFilesPage.copyPath`,null,`复制路径`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>Te(n),children:e(`chatFilesPage.download`,null,`下载`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!r,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:()=>I(t.path),children:[e,`/`]}):(0,O.jsx)(`button`,{type:`button`,className:`chat-files-name`,onClick:()=>B(t),title:t.relativePath,children:e})},{title:e(`chatFilesPage.colSize`,null,`大小`),dataIndex:`size`,width:110,render:e=>e===void 0?`—`:v(e)},{title:e(`chatFilesPage.colModified`,null,`修改时间`),dataIndex:`modifiedUnix`,width:180,render:e=>e?m(e*1e3):`—`},{title:e(`chatFilesPage.colActions`,null,`操作`),dataIndex:`actions`,width:240,render:(t,n)=>n.isDir?(0,O.jsx)(i,{spacing:4,children:(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>I(n.path),children:e(`chatFilesPage.enterFolder`,null,`进入`)})}):(0,O.jsxs)(i,{spacing:4,wrap:!0,children:[(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>B(n),children:e(`chatFilesPage.preview`,null,`预览`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>we(n),children:e(`chatFilesPage.copyPath`,null,`复制路径`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>Te(n),children:e(`chatFilesPage.download`,null,`下载`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!r,onClick:()=>Ee(n),children:e(`chatFilesPage.delete`,null,`删除`)})]})}],Ne=[...Q.folders.map(e=>({rowKey:`dir:${e}`,isDir:!0,path:e,name:P(e)})),...Q.files.map(e=>({...e,rowKey:e.relativePath}))],$=d===`browse`?Ne:Y;return(0,O.jsxs)(`div`,{className:`chat-files-page`,id:`page-chat-files`,children:[(0,O.jsx)(oe,{title:e(`chatFilesPage.title`,null,`文件管理`),description:e(`chatFilesPage.intro`,null,`管理在对话中上传的文件,可复制路径供 AI 引用`),extra:[(0,O.jsx)(o,{onClick:Ae,children:e(`chatFilesPage.export`,null,`导出当前结果`)},`export`),(0,O.jsx)(o,{icon:(0,O.jsx)(l,{}),disabled:!n,onClick:()=>H({name:``}),children:e(`chatFilesPage.newFolderButton`,null,`新建文件夹`)},`mkdir`),(0,O.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,O.jsx)(ee,{}),loading:xe,disabled:!n,onClick:De,children:e(`chatFilesPage.upload`,null,`上传文件`)},`upload`),(0,O.jsx)(o,{icon:(0,O.jsx)(f,{}),onClick:J,loading:q,children:e(`common.refresh`,null,`刷新`)},`refresh`)]}),(0,O.jsx)(`input`,{ref:c,type:`file`,multiple:!0,hidden:!0,onChange:Oe}),(0,O.jsx)(b,{error:Se,onRetry:J}),(0,O.jsx)(x,{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)(s,{value:_,onChange:e=>{S(e),R(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)(s,{value:T,onChange:e=>{D(e),R(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)(s,{value:A,onChange:e=>{j(e),R(1)},prefix:(0,O.jsx)(u,{}),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)(p,{value:k,onChange:e=>{he(e||`all`),R(1)},optionList:_e,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)(p,{value:d,onChange:e=>{g(e||`list`),R(1),I(``)},optionList:[{value:`list`,label:e(`chatFilesPage.groupNone`,null,`不分组(平铺)`)},{value:`browse`,label:e(`chatFilesPage.groupByFolder`,null,`按文件夹(路径浏览)`)}],style:{width:200}})]})]})}),d===`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:()=>I(e.path),children:e.label})]},e.path||`root`))}),(0,O.jsx)(x,{title:d===`browse`?e(`chatFilesPage.browseRoot`,null,`文件`):e(`chatFilesPage.listTitle`,null,`附件列表`),extra:(0,O.jsx)(M,{type:`tertiary`,size:`small`,children:e(`chatFilesPage.paginationInfo`,null,`显示 {{start}}-{{end}} / {{total}} 个文件`).replace(`{{start}}`,$.length?`1`:`0`).replace(`{{end}}`,String($.length)).replace(`{{total}}`,String(d===`browse`?$.length:Z))}),children:(0,O.jsx)(se,{columns:d===`browse`?Me:je,dataSource:$,rowKey:e=>e.rowKey||e.relativePath,loading:q,onRefresh:J,pagination:d!==`browse`&&{currentPage:L,pageSize:z,total:Z,onPageChange:e=>R(e),onPageSizeChange:e=>{ye(e),R(1)}},emptyText:d===`browse`?e(`chatFilesPage.folderEmpty`,null,`此文件夹为空`):e(`chatFilesPage.empty`,null,`暂无对话附件`)})}),(0,O.jsx)(ge,{item:be,onClose:()=>B(null)}),(0,O.jsxs)(ie,{visible:!!V,title:e(`chatFilesPage.newFolderTitle`,null,`新建文件夹`),width:420,onCancel:()=>H(null),onOk:ke,children:[(0,O.jsxs)(M,{type:`tertiary`,size:`small`,children:[e(`chatFilesPage.newFolderLocation`,null,`位置`),`:`,d===`browse`&&F?F:`/`]}),(0,O.jsx)(s,{value:V?.name||``,onChange:e=>H({name:e}),placeholder:e(`chatFilesPage.newFolderNamePlaceholder`,null,`仅名称,不含 /`),style:{marginTop:8}})]})]})}export{F 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{G as r,I as i,N as a,R as o,U as s,W as c,X as ee,ft as l,lt as u,p as d,ut as f,y as p}from"./semi-65W_4I1v.js";import{E as m,F as h,I as te,L as g,R as _,S as ne,T as v,a as re,b as y,c as ie,l as b,m as x,n as ae,o as S,p as oe,s as se,x as C,y as ce}from"./index-C6SML8F9.js";var w=e(t(),1);function le(e){return g.get(`/chat-uploads`,e)}function ue(e,{relativeDir:t}={}){let n=new FormData;return n.append(`file`,e,e.name),t&&n.append(`relativeDir`,t),g.post(`/chat-uploads`,n)}function de(e,t){return g.post(`/chat-uploads/mkdir`,{parent:e||``,name:t})}function fe(e){return g.del(`/chat-uploads`,{body:{path:e}})}function T(e){return g.get(`/chat-uploads/content`,{path:e})}function pe(e,t=`file`){return g.get(`/chat-uploads/path`,{path:e,kind:t})}function me(e){return _(`/chat-uploads/export`,{query:e,filename:`chat-files-export.zip`})}function E(e,t){return _(`/chat-uploads/download`,{query:{path:e},filename:t})}async function D(e){let t=await(await g.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}=r,he=/\.(png|jpe?g|gif|webp|bmp|svg|ico)$/i,A=/\.(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 j(e){let t=e?.name||``;return he.test(t)?`image`:A.test(t)?`text`:`binary`}function ge({item:e,onClose:t}){let n=h(),[r,i]=(0,w.useState)(!1),[a,s]=(0,w.useState)(null),[ee,l]=(0,w.useState)(``),[u,f]=(0,w.useState)(``),[p,m]=(0,w.useState)(`text`);return(0,w.useEffect)(()=>{let t=``,n=!1;if(!e)return l(``),f(``),s(null),()=>{};let r=j(e);return m(r),i(!0),s(null),l(``),f(``),(async()=>{try{if(r===`image`){let r=await D(e.relativePath);if(n){URL.revokeObjectURL(r.url);return}t=r.url,f(r.url)}else if(r===`text`){let t=await T(e.relativePath);if(n)return;l(t?.content??``)}}catch(e){n||(s(e),r===`text`&&m(`binary`))}finally{n||i(!1)}})(),()=>{n=!0,t&&URL.revokeObjectURL(t)}},[e]),(0,O.jsx)(d,{visible:!!e,title:e?.name||n(`chatFilesPage.previewTitle`,null,`文件预览`),width:720,onCancel:t,footer:(0,O.jsx)(o,{onClick:async()=>{if(e)try{await E(e.relativePath,e.name)}catch(e){y(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:v(e.size)}),(0,O.jsx)(k,{type:`tertiary`,size:`small`,className:`chat-files-mono`,children:e.relativePath}),(0,O.jsx)(S,{text:e.relativePath,label:n(`chatFilesPage.copyPath`,null,`复制路径`),size:`small`})]}),(0,O.jsx)(b,{error:p===`binary`?null:a}),r&&(0,O.jsx)(`div`,{className:`chat-files-preview-loading`,children:(0,O.jsx)(c,{})}),!r&&p===`image`&&u&&(0,O.jsx)(`img`,{className:`chat-files-preview-image`,src:u,alt:e.name}),!r&&p===`text`&&(0,O.jsx)(`pre`,{className:`chat-files-preview-text`,children:ee}),!r&&p===`binary`&&(0,O.jsx)(k,{type:`tertiary`,children:n(`chatFilesPage.editBinaryHint`,null,`图片、压缩包等二进制文件无法在此以文本方式编辑,请使用「下载」后在本地查看或处理。`)})]})})}var{Text:M}=r,_e=[{value:`all`,label:`全部`},{value:`upload`,label:`对话附件`},{value:`reduction`,label:`工具输出`},{value:`workspace`,label:`工作目录`},{value:`conversation_artifact`,label:`会话产物`}],ve={upload:`对话附件`,reduction:`工具输出`,workspace:`工作目录`,conversation_artifact:`会话产物`};function N(e){let t=String(e||``).split(`/`);return t.pop(),t.join(`/`)}function P(e){let t=String(e||``).split(`/`);return t[t.length-1]||e}function F(){let e=h(),{hasPermission:t}=te(),n=t(`files:write`),r=t(`files:delete`)||n,c=(0,w.useRef)(null),[d,g]=(0,w.useState)(`list`),[_,S]=(0,w.useState)(``),[T,D]=(0,w.useState)(``),[k,he]=(0,w.useState)(`all`),[A,j]=(0,w.useState)(``),[F,I]=(0,w.useState)(``),[L,R]=(0,w.useState)(1),[z,ye]=(0,w.useState)(20),[be,B]=(0,w.useState)(null),[V,H]=(0,w.useState)(null),[xe,U]=(0,w.useState)(!1),W=ae(A,300),G=(0,w.useMemo)(()=>{let e={conversation:_.trim()||void 0,project:T.trim()||void 0,source:k===`all`?void 0:k,search:W.trim()||void 0};return d===`browse`?{...e,page:1,pageSize:`all`}:{...e,page:L,pageSize:z}},[d,_,T,k,W,L,z]),{data:K,loading:q,error:Se,reload:J}=re(()=>le(G),[G]),Y=Array.isArray(K?.files)?K.files:[],X=Array.isArray(K?.folders)?K.folders:[],Z=Number(K?.total??Y.length),Q=(0,w.useMemo)(()=>d===`browse`?{folders:X.filter(e=>N(e)===F),files:Y.filter(e=>N(e.relativePath)===F)}:{folders:[],files:Y},[d,X,Y,F]),Ce=(0,w.useMemo)(()=>{let t=F?F.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},[F,e]),we=async t=>{try{let n=await pe(t.relativePath,`file`);await navigator.clipboard.writeText(n?.absolutePath||t.relativePath),C(e(`chatFilesPage.pathCopied`,null,`路径已复制,可到对话中粘贴使用`))}catch(t){y(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Te=async t=>{try{await E(t.relativePath,t.name)}catch(t){y(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Ee=t=>{ce({title:e(`chatFilesPage.confirmDelete`,null,`确定删除该文件?`),content:t.relativePath,onOk:async()=>{try{await fe(t.relativePath),C(e(`chatFilesPage.deleted`,null,`已删除`)),J()}catch(e){y(e)}}})},De=()=>c.current?.click(),Oe=async t=>{let n=Array.from(t.target.files||[]);if(t.target.value=``,n.length){U(!0);try{for(let e of n)await ue(e,{relativeDir:d===`browse`?F:``});C(e(`chatFilesPage.uploadOkHint`,null,`上传成功。点击「复制路径」可复制绝对路径到剪贴板。`)),J()}catch(t){y(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}finally{U(!1)}}},ke=async()=>{let t=String(V?.name||``).trim();if(!t||t.includes(`/`)||t.includes(`\\`)||t===`.`||t===`..`)ne(e(`chatFilesPage.mkdirInvalidName`,null,`名称无效:不能为空,且不能包含 /、\\ 或 . / ..`));else try{await de(d===`browse`?F:``,t),C(e(`chatFilesPage.mkdirOk`,null,`文件夹已创建`)),H(null),J()}catch(t){y(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Ae=async()=>{try{await me({conversation:_.trim()||void 0,project:T.trim()||void 0,source:k===`all`?void 0:k,search:W.trim()||void 0}),C(e(`chatFilesPage.exportStarted`,null,`已开始导出当前文件`))}catch(t){y(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:()=>B(t),title:t.relativePath,children:e||P(t.relativePath)})},{title:e(`chatFilesPage.sourceFilter`,null,`来源`),dataIndex:`source`,width:110,render:e=>(0,O.jsx)(a,{size:`small`,children:ve[e]||e||`对话附件`})},{title:e(`chatFilesPage.colConversation`,null,`会话`),dataIndex:`conversationTitle`,width:180,render:(e,t)=>(0,O.jsx)(M,{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=>v(e)},{title:e(`chatFilesPage.colModified`,null,`修改时间`),dataIndex:`modifiedUnix`,width:170,render:e=>m(e?e*1e3:null)},{title:e(`chatFilesPage.colActions`,null,`操作`),dataIndex:`actions`,width:260,render:(t,n)=>(0,O.jsxs)(i,{spacing:4,wrap:!0,children:[(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>B(n),children:e(`chatFilesPage.preview`,null,`预览`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>we(n),children:e(`chatFilesPage.copyPath`,null,`复制路径`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>Te(n),children:e(`chatFilesPage.download`,null,`下载`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!r,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:()=>I(t.path),children:[e,`/`]}):(0,O.jsx)(`button`,{type:`button`,className:`chat-files-name`,onClick:()=>B(t),title:t.relativePath,children:e})},{title:e(`chatFilesPage.colSize`,null,`大小`),dataIndex:`size`,width:110,render:e=>e===void 0?`—`:v(e)},{title:e(`chatFilesPage.colModified`,null,`修改时间`),dataIndex:`modifiedUnix`,width:180,render:e=>e?m(e*1e3):`—`},{title:e(`chatFilesPage.colActions`,null,`操作`),dataIndex:`actions`,width:240,render:(t,n)=>n.isDir?(0,O.jsx)(i,{spacing:4,children:(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>I(n.path),children:e(`chatFilesPage.enterFolder`,null,`进入`)})}):(0,O.jsxs)(i,{spacing:4,wrap:!0,children:[(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>B(n),children:e(`chatFilesPage.preview`,null,`预览`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>we(n),children:e(`chatFilesPage.copyPath`,null,`复制路径`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>Te(n),children:e(`chatFilesPage.download`,null,`下载`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!r,onClick:()=>Ee(n),children:e(`chatFilesPage.delete`,null,`删除`)})]})}],Ne=[...Q.folders.map(e=>({rowKey:`dir:${e}`,isDir:!0,path:e,name:P(e)})),...Q.files.map(e=>({...e,rowKey:e.relativePath}))],$=d===`browse`?Ne:Y;return(0,O.jsxs)(`div`,{className:`chat-files-page`,id:`page-chat-files`,children:[(0,O.jsx)(oe,{title:e(`chatFilesPage.title`,null,`文件管理`),description:e(`chatFilesPage.intro`,null,`管理在对话中上传的文件,可复制路径供 AI 引用`),extra:[(0,O.jsx)(o,{onClick:Ae,children:e(`chatFilesPage.export`,null,`导出当前结果`)},`export`),(0,O.jsx)(o,{icon:(0,O.jsx)(l,{}),disabled:!n,onClick:()=>H({name:``}),children:e(`chatFilesPage.newFolderButton`,null,`新建文件夹`)},`mkdir`),(0,O.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,O.jsx)(ee,{}),loading:xe,disabled:!n,onClick:De,children:e(`chatFilesPage.upload`,null,`上传文件`)},`upload`),(0,O.jsx)(o,{icon:(0,O.jsx)(f,{}),onClick:J,loading:q,children:e(`common.refresh`,null,`刷新`)},`refresh`)]}),(0,O.jsx)(`input`,{ref:c,type:`file`,multiple:!0,hidden:!0,onChange:Oe}),(0,O.jsx)(b,{error:Se,onRetry:J}),(0,O.jsx)(x,{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)(s,{value:_,onChange:e=>{S(e),R(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)(s,{value:T,onChange:e=>{D(e),R(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)(s,{value:A,onChange:e=>{j(e),R(1)},prefix:(0,O.jsx)(u,{}),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)(p,{value:k,onChange:e=>{he(e||`all`),R(1)},optionList:_e,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)(p,{value:d,onChange:e=>{g(e||`list`),R(1),I(``)},optionList:[{value:`list`,label:e(`chatFilesPage.groupNone`,null,`不分组(平铺)`)},{value:`browse`,label:e(`chatFilesPage.groupByFolder`,null,`按文件夹(路径浏览)`)}],style:{width:200}})]})]})}),d===`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:()=>I(e.path),children:e.label})]},e.path||`root`))}),(0,O.jsx)(x,{title:d===`browse`?e(`chatFilesPage.browseRoot`,null,`文件`):e(`chatFilesPage.listTitle`,null,`附件列表`),extra:(0,O.jsx)(M,{type:`tertiary`,size:`small`,children:e(`chatFilesPage.paginationInfo`,null,`显示 {{start}}-{{end}} / {{total}} 个文件`).replace(`{{start}}`,$.length?`1`:`0`).replace(`{{end}}`,String($.length)).replace(`{{total}}`,String(d===`browse`?$.length:Z))}),children:(0,O.jsx)(se,{columns:d===`browse`?Me:je,dataSource:$,rowKey:e=>e.rowKey||e.relativePath,loading:q,onRefresh:J,pagination:d!==`browse`&&{currentPage:L,pageSize:z,total:Z,onPageChange:e=>R(e),onPageSizeChange:e=>{ye(e),R(1)}},emptyText:d===`browse`?e(`chatFilesPage.folderEmpty`,null,`此文件夹为空`):e(`chatFilesPage.empty`,null,`暂无对话附件`)})}),(0,O.jsx)(ge,{item:be,onClose:()=>B(null)}),(0,O.jsxs)(ie,{visible:!!V,title:e(`chatFilesPage.newFolderTitle`,null,`新建文件夹`),width:420,onCancel:()=>H(null),onOk:ke,children:[(0,O.jsxs)(M,{type:`tertiary`,size:`small`,children:[e(`chatFilesPage.newFolderLocation`,null,`位置`),`:`,d===`browse`&&F?F:`/`]}),(0,O.jsx)(s,{value:V?.name||``,onChange:e=>H({name:e}),placeholder:e(`chatFilesPage.newFolderNamePlaceholder`,null,`仅名称,不含 /`),style:{marginTop:8}})]})]})}export{F as default};
\ No newline at end of file
diff --git a/web/static/app/assets/dashboard-Dwi74cCO.js b/web/static/app/assets/dashboard-D3YYrEQG.js
similarity index 99%
rename from web/static/app/assets/dashboard-Dwi74cCO.js
rename to web/static/app/assets/dashboard-D3YYrEQG.js
index 14162f96..4fa27a08 100644
--- a/web/static/app/assets/dashboard-Dwi74cCO.js
+++ b/web/static/app/assets/dashboard-D3YYrEQG.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{B as o,C as s,E as c,G as l,I as u,Kt as d,N as f,R as p,Zt as m,at as h,et as g,g as _,qt as v,tn as y,ut as b,y as x,zt as S}from"./semi-65W_4I1v.js";import{A as C,D as w,E as T,F as E,L as D,O as ee,_ as O,a as k,h as A,l as j,m as M,p as te,r as ne,w as N}from"./index-DNMXun-U.js";var P=e(t(),1),F=e(r(),1),I=[`严重`,`高危`,`中危`,`低危`,`信息`],L=[[0,`safe`,`Safe`,`安全`],[3,`low`,`Low`,`低`],[10,`medium`,`Medium`,`中`],[30,`high`,`High`,`高`],[1/0,`severe`,`Severe`,`极高`]],R=[[`open`,`Open`,`待处理`],[`confirmed`,`Confirmed`,`已确认`],[`fixed`,`Fixed`,`已修复`],[`ignored`,`Ignored`,`已忽略`],[`false_positive`,`FalsePositive`,`误报`]];function z(e){return e[0].toUpperCase()+e.slice(1)}function B(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 V(e){let t=B(e);return t===null?`—`:w(t)}function H(e,t){let n=e?.by_severity;return!n||typeof n!=`object`||Array.isArray(n)?null:B(n[t]??0)}function U(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 W(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 G(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:W(r-o,a+o)}),r=a}return n}function K({rows:e,total:t,status:n,loading:r,t:a}){let o=(0,P.useId)(),[s,c]=(0,P.useState)(``),[l,u]=(0,P.useState)(``),d=s||l,f=e.find(e=>e.key===d),p=r?`…`:V(f?f.count:t),m=G(e,t),h=e=>({onPointerEnter:()=>c(e),onPointerLeave:()=>c(``),onFocus:()=>u(e),onBlur:()=>u(``)});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`dashboard-severity-chart`,children:[(0,F.jsxs)(`svg`,{viewBox:`0 0 420 217`,role:`group`,"aria-label":a(`dashboard.severityDistribution`,null,`漏洞严重程度分布`),children:[(0,F.jsx)(`defs`,{children:e.map(e=>(0,F.jsxs)(`linearGradient`,{id:o+e.key,x1:`12%`,y1:`0%`,x2:`84%`,y2:`100%`,"data-severity":e.key,children:[(0,F.jsx)(`stop`,{offset:`0%`,stopColor:`var(--severity-light)`}),(0,F.jsx)(`stop`,{offset:`100%`,stopColor:`var(--severity-color)`})]},e.key))}),(0,F.jsx)(`path`,{className:`dashboard-ring-track`,d:W(Math.PI,0)}),m.map(e=>(0,F.jsxs)(i,{to:U(e.key,n),className:`dashboard-ring-link`,"data-severity":e.key,"aria-label":`${e.label} · ${V(e.count)}`,"data-muted":!!(d&&e.key!==d),...h(e.key),children:[(0,F.jsx)(`title`,{children:`${e.label} · ${V(e.count)} (${e.percent}%)`}),(0,F.jsx)(`path`,{d:e.d,fill:`url(#${o+e.key})`})]},e.key))]}),(0,F.jsxs)(`div`,{className:`dashboard-ring-center`,"data-severity":f?.key,children:[(0,F.jsx)(`strong`,{children:p}),(0,F.jsx)(`span`,{children:f?.label||a(`dashboard.totalVulns`,null,`总漏洞数`)})]})]}),(0,F.jsx)(`div`,{className:`dashboard-severity-legend`,children:e.map(e=>(0,F.jsxs)(i,{className:`dashboard-severity-item`,"data-severity":e.key,"data-active":d===e.key,to:U(e.key,n),...h(e.key),children:[(0,F.jsx)(`span`,{className:`dashboard-severity-dot`,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`dashboard-severity-name`,children:e.label}),(0,F.jsx)(`strong`,{children:r?`…`:V(e.count)}),(0,F.jsx)(`span`,{className:`dashboard-severity-percent`,children:!r&&e.percent!==null?`${e.percent}%`:`—`})]},e.key))})]})}function q({stats:e,latest:t,t:n}){let r=N.map(t=>H(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`,``,``]:L.find(([e])=>a<=e);return(0,F.jsxs)(`aside`,{className:`dashboard-risk-summary`,"aria-label":n(`dashboard.riskLevel`,null,`风险等级`),children:[(0,F.jsxs)(`div`,{className:`dashboard-risk-score`,"data-tone":o,children:[(0,F.jsxs)(`span`,{className:`dashboard-risk-caption`,children:[n(`dashboard.riskLevel`,null,`风险等级`),(0,F.jsx)(f,{size:`small`,className:`dashboard-risk-tag`,children:s?n(`dashboard.risk`+s,null,c):`—`})]}),(0,F.jsx)(_,{percent:Math.min(a??0,100),size:`small`,showInfo:!1,stroke:`var(--risk-accent)`,"aria-label":n(`dashboard.riskScore`,null,`加权风险分`)}),(0,F.jsxs)(`span`,{className:`dashboard-risk-caption`,children:[n(`dashboard.riskScore`,null,`加权风险分`),(0,F.jsx)(`strong`,{children:a===null?`—`:`${w(a)}${a>=100?`+`:``}`})]})]}),(0,F.jsxs)(`div`,{className:`dashboard-risk-pending`,children:[(0,F.jsx)(`span`,{children:n(`dashboard.statusOpen`,null,`待处理`)}),(0,F.jsx)(`div`,{className:`dashboard-risk-pending-links`,children:N.slice(0,2).map((e,t)=>(0,F.jsxs)(i,{to:U(e,`open`),"data-severity":e,children:[(0,F.jsx)(`strong`,{children:V(r[t])}),(0,F.jsx)(`span`,{children:n(`dashboard.severity`+z(e),null,I[t])})]},e))})]}),(0,F.jsxs)(`div`,{className:`dashboard-risk-latest`,children:[(0,F.jsx)(`span`,{children:n(`dashboard.latestFound`,null,`最近发现`)}),(0,F.jsx)(`strong`,{children:t?C(t,n):`—`})]})]})}function J({counts:e,states:t,t:n}){let r=B(e?.fixed??0)??0,a=B(e?.confirmed??0)??0,o=(B(e?.open??0)??0)+a+r,s=o?r/o*100:null;return(0,F.jsxs)(`div`,{className:`dashboard-resolution`,children:[(0,F.jsx)(`div`,{className:`dashboard-resolution-grid`,children:t.map(({value:t,label:n})=>(0,F.jsxs)(i,{to:U(``,t),"data-status":t,className:`dashboard-resolution-item`,children:[(0,F.jsx)(`strong`,{children:V(e?e[t]??0:null)}),(0,F.jsx)(`span`,{children:n})]},t))}),(0,F.jsxs)(`div`,{className:`dashboard-resolution-heading`,children:[(0,F.jsx)(`span`,{children:n(`dashboard.fixRate`,null,`修复率`)}),(0,F.jsxs)(`span`,{children:[(0,F.jsx)(`strong`,{className:`dashboard-risk-value`,children:s===null?`—`:`${s.toFixed(s===100?0:1)}%`}),e&&(0,F.jsxs)(`small`,{children:[`(`,w(r),` / `,w(o),`)`]})]})]}),(0,F.jsxs)(`div`,{className:`dashboard-resolution-track`,"aria-hidden":`true`,children:[(0,F.jsx)(`span`,{style:{width:`${s??0}%`}}),(0,F.jsx)(`span`,{style:{width:`${o?a/o*100:0}%`}})]}),(0,F.jsx)(`div`,{className:`dashboard-resolution-legend`,children:[`fixed`,`confirmed`,`open`].map(e=>(0,F.jsx)(`span`,{"data-status":e,children:t.find(t=>t.value===e).label},e))})]})}function re({stats:e,pendingStats:t,latest:n,loadedAt:r,loading:s}){let c=E(),[l,u]=a(),d=R.map(([e,t,n])=>({value:e,label:c(`dashboard.status`+t,null,n)})),f=l.get(`risk_status`),p=d.some(e=>e.value===f)?f:``,m=!!(p&&p!==`open`),h=k(async()=>{try{return{status:p,stats:await D.get(`/vulnerabilities/stats`,{status:p})}}catch(e){return{status:p,error:e}}},[p,r],{skip:!m}),g=h.data?.status===p,_=p===`open`?t:m?g?h.data.stats:null:e,v=s||m&&(h.loading||!g),b=N.map(e=>H(_,e)),S=b.some(e=>e===null)?null:Math.max(B(_?.total)??0,b.reduce((e,t)=>e+t,0)),C=N.map((e,t)=>({key:e,label:c(`dashboard.severity`+z(e),null,I[t]),count:b[t],percent:S===null?null:S===0?0:Math.round(b[t]/S*100)}));return(0,F.jsxs)(M,{className:`dashboard-vulnerability-card`,bodyClassName:`dashboard-vulnerability-body`,title:c(`dashboard.severityDistribution`,null,`漏洞严重程度分布`),extra:(0,F.jsxs)(`div`,{className:`dashboard-vulnerability-actions`,children:[(0,F.jsx)(x,{"aria-label":c(`dashboard.statusFilter`,null,`状态筛选`),size:`small`,value:p||`all`,optionList:[{value:`all`,label:c(`dashboard.allStatuses`,null,`全部状态`)},...d],onChange:e=>u(t=>{let n=new URLSearchParams(t);return e===`all`?n.delete(`risk_status`):n.set(`risk_status`,e),n},{replace:!0})}),(0,F.jsxs)(i,{className:`dashboard-vulnerability-all`,to:U(``,p),children:[c(`dashboard.viewAll`,null,`查看全部`).replace(/\s*→\s*$/,``),(0,F.jsx)(y,{"aria-hidden":`true`})]})]}),children:[m&&g&&h.data.error&&(0,F.jsx)(o,{type:`warning`,closeIcon:null,description:(0,F.jsxs)(`button`,{type:`button`,className:`dashboard-filter-retry`,onClick:()=>h.reload(),children:[c(`common.loadFailed`,null,`加载失败`),` · `,c(`common.refresh`,null,`刷新`)]})}),(0,F.jsxs)(`div`,{className:`dashboard-vulnerability-grid`,children:[(0,F.jsx)(q,{stats:t,latest:n,t:c}),(0,F.jsx)(K,{rows:C,total:S,status:p,loading:v,t:c},p)]}),(0,F.jsx)(J,{counts:e?.by_status,states:d,t:c})]})}var{Text:Y}=l,ie=new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1});async function X(e,t){try{return await D.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,F.jsx)(c,{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,F.jsx)(s,{className:`dashboard-list dashboard-feed`,loading:t,dataSource:r||[],emptyContent:(0,F.jsx)($,{loading:t,unavailable:r===null,title:`暂无漏洞记录`,description:`测评发现的漏洞会汇集到这里,便于跟进与复核。`}),renderItem:e=>(0,F.jsx)(s.Item,{main:(0,F.jsxs)(`div`,{className:`dashboard-record`,children:[(0,F.jsx)(p,{theme:`borderless`,className:`dashboard-record-link`,onClick:()=>n(e.id),children:e.title||e.name||`未命名漏洞`}),(0,F.jsxs)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:[e.host||e.target||`—`,` · `,T(e.created_at)]})]}),extra:(0,F.jsx)(A,{severity:e.severity})},e.id)})}function se({summary:e,loading:t,onOpen:n}){let r=Z(e,`recent_facts`,`facts`);return(0,F.jsx)(s,{className:`dashboard-list dashboard-feed dashboard-facts`,split:!1,loading:t,dataSource:r||[],emptyContent:(0,F.jsx)($,{loading:t,unavailable:r===null,title:`暂无近期事实`,description:`项目沉淀的事实与证据将在这里展示。`}),renderItem:(e,t)=>(0,F.jsx)(s.Item,{main:(0,F.jsxs)(`div`,{className:`dashboard-record`,children:[(0,F.jsx)(Y,{strong:!0,className:`dashboard-fact-title`,children:e.title||e.summary||e.key||e.fact_key||e.subject||`事实`}),(0,F.jsx)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:e.project_name||e.projectName||e.value||`—`})]}),extra:(0,F.jsxs)(u,{spacing:8,children:[e.status&&(0,F.jsx)(f,{size:`small`,children:e.status}),e.project_id&&(0,F.jsx)(p,{theme:`borderless`,icon:(0,F.jsx)(y,{}),"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:c}=k(ae,[]);ne(()=>c({silent:!0}),6e4);let l=(0,P.useMemo)(()=>{let n=Q(r?.agentTasks,`tasks`),a=B(r?.tokenUsage?.summary?.totalTokens),o=H(r?.vulnStats,`critical`),s=H(r?.pendingVulnStats,`high`),c=r?.monitorStats?.summary,l=B(c?.successCalls),u=B(c?.failedCalls),f=l===null||u===null?null:l+u,p=f>0?l/f:null,_=Z(r?.batchQueues,`queues`)?.filter(e=>String(e.status).toLowerCase()===`running`).length;return[{id:`tasks`,label:e(`dashboard.runningConversations`,null,`运行中任务`),value:V(n),detail:`运行中批量队列 ${V(_)}`,icon:(0,F.jsx)(d,{}),onClick:()=>t(`/tasks`)},{id:`vulnerabilities`,label:e(`dashboard.vulnTotal`,null,`漏洞总数`),value:V(r?.vulnStats?.total),detail:e(`dashboard.openHighCountLabel`,{count:V(s)},`待处理高危 ${V(s)}`),tone:o>0?`danger`:void 0,icon:(0,F.jsx)(h,{}),onClick:()=>t(`/vulnerabilities`)},{id:`calls`,label:e(`dashboard.toolCalls`,null,`工具调用`),value:V(c?.totalCalls),detail:`涉及工具 ${V(c?.toolCount)}`,icon:(0,F.jsx)(g,{}),onClick:()=>t(`/mcp-monitor`)},{id:`rate`,label:e(`dashboard.successRate`,null,`执行成功率`),value:p===null?`—`:ee(p),detail:f===null?`执行结果暂不可用`:f===0?`尚无已完成调用`:`失败 ${V(u)} 次`,tone:p!==null&&p<.8?`warning`:void 0,icon:(0,F.jsx)(v,{}),onClick:()=>t(`/mcp-monitor`)},{id:`tokens`,label:e(`dashboard.tokenUsage`,null,`Token 用量(7 天)`),value:a>=1e6?ie.format(a):V(a),valueTitle:a>=1e6?V(a):void 0,detail:`调用次数 ${V(r?.tokenUsage?.summary?.modelCalls??r?.tokenUsage?.summary?.calls)}`,icon:(0,F.jsx)(m,{}),onClick:()=>t(`/settings?section=token-usage`)}].map(e=>({...e,loading:i,detail:i?`正在刷新数据`:e.detail}))},[r,i,t,e]),f=(0,P.useMemo)(()=>{let e=[],t=H(r?.vulnStats,`critical`);t>0&&e.push({id:`critical`,text:`${V(t)} 条严重漏洞`,page:`/vulnerabilities`});let n=Q(r?.hitlPending,`items`,`pending`);n>0&&e.push({id:`pending`,text:`${V(n)} 项审批待处理`,page:`/hitl`});let i=B(r?.monitorStats?.summary?.failedCalls);i>0&&e.push({id:`failed`,text:`工具调用失败 ${V(i)} 次`,page:`/mcp-monitor`});let a=B(r?.externalMcp?.total),o=B(r?.externalMcp?.connected);return a!==null&&o!==null&&a>o&&e.push({id:`mcp`,text:`${V(a-o)} 个外部 MCP 未连接`,page:`/mcp-management`}),e},[r]),_=(0,P.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]),x=r?.loadedAt?T(r.loadedAt):`—`,C=e=>t(`/projects?id=${encodeURIComponent(e)}`);return(0,F.jsxs)(`div`,{className:`dashboard-page`,"aria-busy":i,children:[(0,F.jsx)(te,{title:e(`dashboard.title`,null,`仪表盘`),description:`最近刷新 ${x} · 每 60 秒自动刷新`,extra:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(p,{icon:(0,F.jsx)(b,{}),onClick:()=>c(),loading:i,children:e(`common.refresh`,null,`刷新`)}),(0,F.jsx)(p,{theme:`solid`,icon:(0,F.jsx)(S,{}),onClick:()=>t(`/chat`),children:`进入对话`})]})}),(0,F.jsx)(O,{metrics:l,columns:5}),(0,F.jsx)(j,{error:a,onRetry:()=>c()}),r?.unavailableCount>0&&(0,F.jsx)(o,{className:`dashboard-notice`,type:`info`,fullMode:!1,closeIcon:null,title:r.unavailableCount===r.sourceCount?`数据暂不可用`:`部分数据不可用`,description:r.unavailableCount===r.sourceCount?`本次未能取得仪表盘数据,请检查服务连接后刷新重试。`:`${r.unavailableCount} 项数据源未能加载,相关数值以 — 显示。已返回的数据仍可查看,请稍后刷新重试。`}),f.length>0&&(0,F.jsx)(o,{className:`dashboard-notice`,type:`warning`,fullMode:!1,closeIcon:null,description:(0,F.jsxs)(u,{wrap:!0,spacing:8,children:[(0,F.jsx)(Y,{strong:!0,children:`需要关注`}),f.map(e=>(0,F.jsx)(p,{theme:`borderless`,type:`warning`,icon:(0,F.jsx)(y,{}),iconPosition:`right`,onClick:()=>t(e.page),children:e.text},e.id))]})}),(0,F.jsxs)(`div`,{className:`dashboard-grid`,children:[(0,F.jsxs)(`div`,{className:`dashboard-column`,children:[(0,F.jsx)(re,{stats:r?.vulnStats,pendingStats:r?.pendingVulnStats,latest:r?.vulnList?.vulnerabilities?.[0]?.created_at,loadedAt:r?.loadedAt,loading:i}),(0,F.jsx)(M,{title:e(`dashboard.recentVulns`,null,`最近漏洞`),extra:(0,F.jsx)(p,{theme:`borderless`,size:`small`,icon:(0,F.jsx)(y,{}),iconPosition:`right`,onClick:()=>t(`/vulnerabilities`),children:`查看全部`}),children:(0,F.jsx)(oe,{data:r?.vulnList,loading:i,onOpen:e=>t(`/vulnerabilities?id=${encodeURIComponent(e)}`)})})]}),(0,F.jsxs)(`div`,{className:`dashboard-column`,children:[(0,F.jsx)(M,{title:e(`dashboard.projects`,null,`项目概览`),extra:(0,F.jsx)(p,{theme:`borderless`,size:`small`,icon:(0,F.jsx)(y,{}),iconPosition:`right`,onClick:()=>t(`/projects`),children:`全部项目`}),children:(0,F.jsx)(ue,{summary:r?.projectSummary,loading:i,onOpen:C})}),(0,F.jsx)(M,{title:e(`dashboard.toolsTop`,null,`工具调用 Top`),extra:(0,F.jsx)(p,{theme:`borderless`,size:`small`,onClick:()=>t(`/mcp-monitor`),children:`调用监控`}),children:(0,F.jsx)(le,{data:r?.monitorStats,loading:i})}),(0,F.jsx)(M,{className:`dashboard-capability-card`,bodyClassName:`dashboard-capability-body`,title:e(`dashboard.capability`,null,`能力与运行态`),children:(0,F.jsx)(s,{className:`dashboard-capabilities`,split:!1,dataSource:_,renderItem:e=>(0,F.jsx)(s.Item,{children:(0,F.jsxs)(p,{block:!0,theme:`borderless`,type:`tertiary`,className:`dashboard-capability`,onClick:()=>t(e.page),children:[(0,F.jsx)(`span`,{children:e.label}),(0,F.jsx)(`span`,{className:`dashboard-capability-value`,children:i?`…`:V(e.value)})]})},e.id)})})]})]}),(0,F.jsx)(M,{className:`dashboard-facts-card`,title:e(`dashboard.recentFacts`,null,`近期事实`),children:(0,F.jsx)(se,{summary:r?.projectSummary,loading:i,onOpen:C})})]})}function le({data:e,loading:t}){let n=Z(e,`topTools`),r=n?.slice(0,8).map(e=>({name:e.name||e.toolName||`未命名工具`,count:B(e.count??e.calls??e.totalCalls)}))||[],i=Math.max(...r.map(e=>e.count??0),1);return(0,F.jsx)(s,{className:`dashboard-list`,loading:t,dataSource:r,emptyContent:(0,F.jsx)($,{loading:t,unavailable:n===null,title:`暂无工具调用`,description:`执行任务后,可在这里查看使用最多的工具。`}),renderItem:(e,t)=>(0,F.jsxs)(s.Item,{className:`dashboard-tool-row`,children:[(0,F.jsx)(Y,{type:`tertiary`,size:`small`,className:`dashboard-tool-rank`,children:t+1}),(0,F.jsxs)(`div`,{className:`dashboard-record`,children:[(0,F.jsxs)(`div`,{className:`dashboard-tool-heading`,children:[(0,F.jsx)(Y,{className:`dashboard-tool-name`,title:e.name,children:e.name}),(0,F.jsxs)(Y,{type:`secondary`,size:`small`,className:`dashboard-count`,children:[V(e.count),` 次`]})]}),e.count!==null&&(0,F.jsx)(_,{percent:Math.round(e.count/i*100),showInfo:!1,size:`small`,stroke:`var(--semi-color-primary)`,"aria-label":`${e.name}调用次数`,"aria-valuetext":`${V(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,F.jsxs)(`div`,{children:[(0,F.jsx)(`dl`,{className:`dashboard-project-totals`,children:o.map(([e,n])=>(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:e}),(0,F.jsx)(`dd`,{children:t?`…`:V(n)})]},e))}),(0,F.jsx)(s,{className:`dashboard-list dashboard-feed`,loading:t,dataSource:r?.slice(0,6)||[],emptyContent:(0,F.jsx)($,{loading:t,unavailable:!e,title:r===null?`在项目中继续工作`:`暂无项目`,description:r===null?`当前摘要提供项目与事实统计,完整列表请查看全部项目。`:`创建项目后,在这里跟进项目进展。`}),renderItem:e=>(0,F.jsx)(s.Item,{main:(0,F.jsxs)(`div`,{className:`dashboard-record`,children:[(0,F.jsx)(p,{theme:`borderless`,className:`dashboard-record-link`,onClick:()=>n(e.id),children:e.name||`未命名项目`}),(0,F.jsxs)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:[e.status||`—`,` · `,T(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{B as o,C as s,E as c,G as l,I as u,Kt as d,N as f,R as p,Zt as m,at as h,et as g,g as _,qt as v,tn as y,ut as b,y as x,zt as S}from"./semi-65W_4I1v.js";import{A as C,D as w,E as T,F as E,L as D,O as ee,_ as O,a as k,h as A,l as j,m as M,p as te,r as ne,w as N}from"./index-C6SML8F9.js";var P=e(t(),1),F=e(r(),1),I=[`严重`,`高危`,`中危`,`低危`,`信息`],L=[[0,`safe`,`Safe`,`安全`],[3,`low`,`Low`,`低`],[10,`medium`,`Medium`,`中`],[30,`high`,`High`,`高`],[1/0,`severe`,`Severe`,`极高`]],R=[[`open`,`Open`,`待处理`],[`confirmed`,`Confirmed`,`已确认`],[`fixed`,`Fixed`,`已修复`],[`ignored`,`Ignored`,`已忽略`],[`false_positive`,`FalsePositive`,`误报`]];function z(e){return e[0].toUpperCase()+e.slice(1)}function B(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 V(e){let t=B(e);return t===null?`—`:w(t)}function H(e,t){let n=e?.by_severity;return!n||typeof n!=`object`||Array.isArray(n)?null:B(n[t]??0)}function U(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 W(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 G(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:W(r-o,a+o)}),r=a}return n}function K({rows:e,total:t,status:n,loading:r,t:a}){let o=(0,P.useId)(),[s,c]=(0,P.useState)(``),[l,u]=(0,P.useState)(``),d=s||l,f=e.find(e=>e.key===d),p=r?`…`:V(f?f.count:t),m=G(e,t),h=e=>({onPointerEnter:()=>c(e),onPointerLeave:()=>c(``),onFocus:()=>u(e),onBlur:()=>u(``)});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`dashboard-severity-chart`,children:[(0,F.jsxs)(`svg`,{viewBox:`0 0 420 217`,role:`group`,"aria-label":a(`dashboard.severityDistribution`,null,`漏洞严重程度分布`),children:[(0,F.jsx)(`defs`,{children:e.map(e=>(0,F.jsxs)(`linearGradient`,{id:o+e.key,x1:`12%`,y1:`0%`,x2:`84%`,y2:`100%`,"data-severity":e.key,children:[(0,F.jsx)(`stop`,{offset:`0%`,stopColor:`var(--severity-light)`}),(0,F.jsx)(`stop`,{offset:`100%`,stopColor:`var(--severity-color)`})]},e.key))}),(0,F.jsx)(`path`,{className:`dashboard-ring-track`,d:W(Math.PI,0)}),m.map(e=>(0,F.jsxs)(i,{to:U(e.key,n),className:`dashboard-ring-link`,"data-severity":e.key,"aria-label":`${e.label} · ${V(e.count)}`,"data-muted":!!(d&&e.key!==d),...h(e.key),children:[(0,F.jsx)(`title`,{children:`${e.label} · ${V(e.count)} (${e.percent}%)`}),(0,F.jsx)(`path`,{d:e.d,fill:`url(#${o+e.key})`})]},e.key))]}),(0,F.jsxs)(`div`,{className:`dashboard-ring-center`,"data-severity":f?.key,children:[(0,F.jsx)(`strong`,{children:p}),(0,F.jsx)(`span`,{children:f?.label||a(`dashboard.totalVulns`,null,`总漏洞数`)})]})]}),(0,F.jsx)(`div`,{className:`dashboard-severity-legend`,children:e.map(e=>(0,F.jsxs)(i,{className:`dashboard-severity-item`,"data-severity":e.key,"data-active":d===e.key,to:U(e.key,n),...h(e.key),children:[(0,F.jsx)(`span`,{className:`dashboard-severity-dot`,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`dashboard-severity-name`,children:e.label}),(0,F.jsx)(`strong`,{children:r?`…`:V(e.count)}),(0,F.jsx)(`span`,{className:`dashboard-severity-percent`,children:!r&&e.percent!==null?`${e.percent}%`:`—`})]},e.key))})]})}function q({stats:e,latest:t,t:n}){let r=N.map(t=>H(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`,``,``]:L.find(([e])=>a<=e);return(0,F.jsxs)(`aside`,{className:`dashboard-risk-summary`,"aria-label":n(`dashboard.riskLevel`,null,`风险等级`),children:[(0,F.jsxs)(`div`,{className:`dashboard-risk-score`,"data-tone":o,children:[(0,F.jsxs)(`span`,{className:`dashboard-risk-caption`,children:[n(`dashboard.riskLevel`,null,`风险等级`),(0,F.jsx)(f,{size:`small`,className:`dashboard-risk-tag`,children:s?n(`dashboard.risk`+s,null,c):`—`})]}),(0,F.jsx)(_,{percent:Math.min(a??0,100),size:`small`,showInfo:!1,stroke:`var(--risk-accent)`,"aria-label":n(`dashboard.riskScore`,null,`加权风险分`)}),(0,F.jsxs)(`span`,{className:`dashboard-risk-caption`,children:[n(`dashboard.riskScore`,null,`加权风险分`),(0,F.jsx)(`strong`,{children:a===null?`—`:`${w(a)}${a>=100?`+`:``}`})]})]}),(0,F.jsxs)(`div`,{className:`dashboard-risk-pending`,children:[(0,F.jsx)(`span`,{children:n(`dashboard.statusOpen`,null,`待处理`)}),(0,F.jsx)(`div`,{className:`dashboard-risk-pending-links`,children:N.slice(0,2).map((e,t)=>(0,F.jsxs)(i,{to:U(e,`open`),"data-severity":e,children:[(0,F.jsx)(`strong`,{children:V(r[t])}),(0,F.jsx)(`span`,{children:n(`dashboard.severity`+z(e),null,I[t])})]},e))})]}),(0,F.jsxs)(`div`,{className:`dashboard-risk-latest`,children:[(0,F.jsx)(`span`,{children:n(`dashboard.latestFound`,null,`最近发现`)}),(0,F.jsx)(`strong`,{children:t?C(t,n):`—`})]})]})}function J({counts:e,states:t,t:n}){let r=B(e?.fixed??0)??0,a=B(e?.confirmed??0)??0,o=(B(e?.open??0)??0)+a+r,s=o?r/o*100:null;return(0,F.jsxs)(`div`,{className:`dashboard-resolution`,children:[(0,F.jsx)(`div`,{className:`dashboard-resolution-grid`,children:t.map(({value:t,label:n})=>(0,F.jsxs)(i,{to:U(``,t),"data-status":t,className:`dashboard-resolution-item`,children:[(0,F.jsx)(`strong`,{children:V(e?e[t]??0:null)}),(0,F.jsx)(`span`,{children:n})]},t))}),(0,F.jsxs)(`div`,{className:`dashboard-resolution-heading`,children:[(0,F.jsx)(`span`,{children:n(`dashboard.fixRate`,null,`修复率`)}),(0,F.jsxs)(`span`,{children:[(0,F.jsx)(`strong`,{className:`dashboard-risk-value`,children:s===null?`—`:`${s.toFixed(s===100?0:1)}%`}),e&&(0,F.jsxs)(`small`,{children:[`(`,w(r),` / `,w(o),`)`]})]})]}),(0,F.jsxs)(`div`,{className:`dashboard-resolution-track`,"aria-hidden":`true`,children:[(0,F.jsx)(`span`,{style:{width:`${s??0}%`}}),(0,F.jsx)(`span`,{style:{width:`${o?a/o*100:0}%`}})]}),(0,F.jsx)(`div`,{className:`dashboard-resolution-legend`,children:[`fixed`,`confirmed`,`open`].map(e=>(0,F.jsx)(`span`,{"data-status":e,children:t.find(t=>t.value===e).label},e))})]})}function re({stats:e,pendingStats:t,latest:n,loadedAt:r,loading:s}){let c=E(),[l,u]=a(),d=R.map(([e,t,n])=>({value:e,label:c(`dashboard.status`+t,null,n)})),f=l.get(`risk_status`),p=d.some(e=>e.value===f)?f:``,m=!!(p&&p!==`open`),h=k(async()=>{try{return{status:p,stats:await D.get(`/vulnerabilities/stats`,{status:p})}}catch(e){return{status:p,error:e}}},[p,r],{skip:!m}),g=h.data?.status===p,_=p===`open`?t:m?g?h.data.stats:null:e,v=s||m&&(h.loading||!g),b=N.map(e=>H(_,e)),S=b.some(e=>e===null)?null:Math.max(B(_?.total)??0,b.reduce((e,t)=>e+t,0)),C=N.map((e,t)=>({key:e,label:c(`dashboard.severity`+z(e),null,I[t]),count:b[t],percent:S===null?null:S===0?0:Math.round(b[t]/S*100)}));return(0,F.jsxs)(M,{className:`dashboard-vulnerability-card`,bodyClassName:`dashboard-vulnerability-body`,title:c(`dashboard.severityDistribution`,null,`漏洞严重程度分布`),extra:(0,F.jsxs)(`div`,{className:`dashboard-vulnerability-actions`,children:[(0,F.jsx)(x,{"aria-label":c(`dashboard.statusFilter`,null,`状态筛选`),size:`small`,value:p||`all`,optionList:[{value:`all`,label:c(`dashboard.allStatuses`,null,`全部状态`)},...d],onChange:e=>u(t=>{let n=new URLSearchParams(t);return e===`all`?n.delete(`risk_status`):n.set(`risk_status`,e),n},{replace:!0})}),(0,F.jsxs)(i,{className:`dashboard-vulnerability-all`,to:U(``,p),children:[c(`dashboard.viewAll`,null,`查看全部`).replace(/\s*→\s*$/,``),(0,F.jsx)(y,{"aria-hidden":`true`})]})]}),children:[m&&g&&h.data.error&&(0,F.jsx)(o,{type:`warning`,closeIcon:null,description:(0,F.jsxs)(`button`,{type:`button`,className:`dashboard-filter-retry`,onClick:()=>h.reload(),children:[c(`common.loadFailed`,null,`加载失败`),` · `,c(`common.refresh`,null,`刷新`)]})}),(0,F.jsxs)(`div`,{className:`dashboard-vulnerability-grid`,children:[(0,F.jsx)(q,{stats:t,latest:n,t:c}),(0,F.jsx)(K,{rows:C,total:S,status:p,loading:v,t:c},p)]}),(0,F.jsx)(J,{counts:e?.by_status,states:d,t:c})]})}var{Text:Y}=l,ie=new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1});async function X(e,t){try{return await D.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,F.jsx)(c,{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,F.jsx)(s,{className:`dashboard-list dashboard-feed`,loading:t,dataSource:r||[],emptyContent:(0,F.jsx)($,{loading:t,unavailable:r===null,title:`暂无漏洞记录`,description:`测评发现的漏洞会汇集到这里,便于跟进与复核。`}),renderItem:e=>(0,F.jsx)(s.Item,{main:(0,F.jsxs)(`div`,{className:`dashboard-record`,children:[(0,F.jsx)(p,{theme:`borderless`,className:`dashboard-record-link`,onClick:()=>n(e.id),children:e.title||e.name||`未命名漏洞`}),(0,F.jsxs)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:[e.host||e.target||`—`,` · `,T(e.created_at)]})]}),extra:(0,F.jsx)(A,{severity:e.severity})},e.id)})}function se({summary:e,loading:t,onOpen:n}){let r=Z(e,`recent_facts`,`facts`);return(0,F.jsx)(s,{className:`dashboard-list dashboard-feed dashboard-facts`,split:!1,loading:t,dataSource:r||[],emptyContent:(0,F.jsx)($,{loading:t,unavailable:r===null,title:`暂无近期事实`,description:`项目沉淀的事实与证据将在这里展示。`}),renderItem:(e,t)=>(0,F.jsx)(s.Item,{main:(0,F.jsxs)(`div`,{className:`dashboard-record`,children:[(0,F.jsx)(Y,{strong:!0,className:`dashboard-fact-title`,children:e.title||e.summary||e.key||e.fact_key||e.subject||`事实`}),(0,F.jsx)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:e.project_name||e.projectName||e.value||`—`})]}),extra:(0,F.jsxs)(u,{spacing:8,children:[e.status&&(0,F.jsx)(f,{size:`small`,children:e.status}),e.project_id&&(0,F.jsx)(p,{theme:`borderless`,icon:(0,F.jsx)(y,{}),"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:c}=k(ae,[]);ne(()=>c({silent:!0}),6e4);let l=(0,P.useMemo)(()=>{let n=Q(r?.agentTasks,`tasks`),a=B(r?.tokenUsage?.summary?.totalTokens),o=H(r?.vulnStats,`critical`),s=H(r?.pendingVulnStats,`high`),c=r?.monitorStats?.summary,l=B(c?.successCalls),u=B(c?.failedCalls),f=l===null||u===null?null:l+u,p=f>0?l/f:null,_=Z(r?.batchQueues,`queues`)?.filter(e=>String(e.status).toLowerCase()===`running`).length;return[{id:`tasks`,label:e(`dashboard.runningConversations`,null,`运行中任务`),value:V(n),detail:`运行中批量队列 ${V(_)}`,icon:(0,F.jsx)(d,{}),onClick:()=>t(`/tasks`)},{id:`vulnerabilities`,label:e(`dashboard.vulnTotal`,null,`漏洞总数`),value:V(r?.vulnStats?.total),detail:e(`dashboard.openHighCountLabel`,{count:V(s)},`待处理高危 ${V(s)}`),tone:o>0?`danger`:void 0,icon:(0,F.jsx)(h,{}),onClick:()=>t(`/vulnerabilities`)},{id:`calls`,label:e(`dashboard.toolCalls`,null,`工具调用`),value:V(c?.totalCalls),detail:`涉及工具 ${V(c?.toolCount)}`,icon:(0,F.jsx)(g,{}),onClick:()=>t(`/mcp-monitor`)},{id:`rate`,label:e(`dashboard.successRate`,null,`执行成功率`),value:p===null?`—`:ee(p),detail:f===null?`执行结果暂不可用`:f===0?`尚无已完成调用`:`失败 ${V(u)} 次`,tone:p!==null&&p<.8?`warning`:void 0,icon:(0,F.jsx)(v,{}),onClick:()=>t(`/mcp-monitor`)},{id:`tokens`,label:e(`dashboard.tokenUsage`,null,`Token 用量(7 天)`),value:a>=1e6?ie.format(a):V(a),valueTitle:a>=1e6?V(a):void 0,detail:`调用次数 ${V(r?.tokenUsage?.summary?.modelCalls??r?.tokenUsage?.summary?.calls)}`,icon:(0,F.jsx)(m,{}),onClick:()=>t(`/settings?section=token-usage`)}].map(e=>({...e,loading:i,detail:i?`正在刷新数据`:e.detail}))},[r,i,t,e]),f=(0,P.useMemo)(()=>{let e=[],t=H(r?.vulnStats,`critical`);t>0&&e.push({id:`critical`,text:`${V(t)} 条严重漏洞`,page:`/vulnerabilities`});let n=Q(r?.hitlPending,`items`,`pending`);n>0&&e.push({id:`pending`,text:`${V(n)} 项审批待处理`,page:`/hitl`});let i=B(r?.monitorStats?.summary?.failedCalls);i>0&&e.push({id:`failed`,text:`工具调用失败 ${V(i)} 次`,page:`/mcp-monitor`});let a=B(r?.externalMcp?.total),o=B(r?.externalMcp?.connected);return a!==null&&o!==null&&a>o&&e.push({id:`mcp`,text:`${V(a-o)} 个外部 MCP 未连接`,page:`/mcp-management`}),e},[r]),_=(0,P.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]),x=r?.loadedAt?T(r.loadedAt):`—`,C=e=>t(`/projects?id=${encodeURIComponent(e)}`);return(0,F.jsxs)(`div`,{className:`dashboard-page`,"aria-busy":i,children:[(0,F.jsx)(te,{title:e(`dashboard.title`,null,`仪表盘`),description:`最近刷新 ${x} · 每 60 秒自动刷新`,extra:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(p,{icon:(0,F.jsx)(b,{}),onClick:()=>c(),loading:i,children:e(`common.refresh`,null,`刷新`)}),(0,F.jsx)(p,{theme:`solid`,icon:(0,F.jsx)(S,{}),onClick:()=>t(`/chat`),children:`进入对话`})]})}),(0,F.jsx)(O,{metrics:l,columns:5}),(0,F.jsx)(j,{error:a,onRetry:()=>c()}),r?.unavailableCount>0&&(0,F.jsx)(o,{className:`dashboard-notice`,type:`info`,fullMode:!1,closeIcon:null,title:r.unavailableCount===r.sourceCount?`数据暂不可用`:`部分数据不可用`,description:r.unavailableCount===r.sourceCount?`本次未能取得仪表盘数据,请检查服务连接后刷新重试。`:`${r.unavailableCount} 项数据源未能加载,相关数值以 — 显示。已返回的数据仍可查看,请稍后刷新重试。`}),f.length>0&&(0,F.jsx)(o,{className:`dashboard-notice`,type:`warning`,fullMode:!1,closeIcon:null,description:(0,F.jsxs)(u,{wrap:!0,spacing:8,children:[(0,F.jsx)(Y,{strong:!0,children:`需要关注`}),f.map(e=>(0,F.jsx)(p,{theme:`borderless`,type:`warning`,icon:(0,F.jsx)(y,{}),iconPosition:`right`,onClick:()=>t(e.page),children:e.text},e.id))]})}),(0,F.jsxs)(`div`,{className:`dashboard-grid`,children:[(0,F.jsxs)(`div`,{className:`dashboard-column`,children:[(0,F.jsx)(re,{stats:r?.vulnStats,pendingStats:r?.pendingVulnStats,latest:r?.vulnList?.vulnerabilities?.[0]?.created_at,loadedAt:r?.loadedAt,loading:i}),(0,F.jsx)(M,{title:e(`dashboard.recentVulns`,null,`最近漏洞`),extra:(0,F.jsx)(p,{theme:`borderless`,size:`small`,icon:(0,F.jsx)(y,{}),iconPosition:`right`,onClick:()=>t(`/vulnerabilities`),children:`查看全部`}),children:(0,F.jsx)(oe,{data:r?.vulnList,loading:i,onOpen:e=>t(`/vulnerabilities?id=${encodeURIComponent(e)}`)})})]}),(0,F.jsxs)(`div`,{className:`dashboard-column`,children:[(0,F.jsx)(M,{title:e(`dashboard.projects`,null,`项目概览`),extra:(0,F.jsx)(p,{theme:`borderless`,size:`small`,icon:(0,F.jsx)(y,{}),iconPosition:`right`,onClick:()=>t(`/projects`),children:`全部项目`}),children:(0,F.jsx)(ue,{summary:r?.projectSummary,loading:i,onOpen:C})}),(0,F.jsx)(M,{title:e(`dashboard.toolsTop`,null,`工具调用 Top`),extra:(0,F.jsx)(p,{theme:`borderless`,size:`small`,onClick:()=>t(`/mcp-monitor`),children:`调用监控`}),children:(0,F.jsx)(le,{data:r?.monitorStats,loading:i})}),(0,F.jsx)(M,{className:`dashboard-capability-card`,bodyClassName:`dashboard-capability-body`,title:e(`dashboard.capability`,null,`能力与运行态`),children:(0,F.jsx)(s,{className:`dashboard-capabilities`,split:!1,dataSource:_,renderItem:e=>(0,F.jsx)(s.Item,{children:(0,F.jsxs)(p,{block:!0,theme:`borderless`,type:`tertiary`,className:`dashboard-capability`,onClick:()=>t(e.page),children:[(0,F.jsx)(`span`,{children:e.label}),(0,F.jsx)(`span`,{className:`dashboard-capability-value`,children:i?`…`:V(e.value)})]})},e.id)})})]})]}),(0,F.jsx)(M,{className:`dashboard-facts-card`,title:e(`dashboard.recentFacts`,null,`近期事实`),children:(0,F.jsx)(se,{summary:r?.projectSummary,loading:i,onOpen:C})})]})}function le({data:e,loading:t}){let n=Z(e,`topTools`),r=n?.slice(0,8).map(e=>({name:e.name||e.toolName||`未命名工具`,count:B(e.count??e.calls??e.totalCalls)}))||[],i=Math.max(...r.map(e=>e.count??0),1);return(0,F.jsx)(s,{className:`dashboard-list`,loading:t,dataSource:r,emptyContent:(0,F.jsx)($,{loading:t,unavailable:n===null,title:`暂无工具调用`,description:`执行任务后,可在这里查看使用最多的工具。`}),renderItem:(e,t)=>(0,F.jsxs)(s.Item,{className:`dashboard-tool-row`,children:[(0,F.jsx)(Y,{type:`tertiary`,size:`small`,className:`dashboard-tool-rank`,children:t+1}),(0,F.jsxs)(`div`,{className:`dashboard-record`,children:[(0,F.jsxs)(`div`,{className:`dashboard-tool-heading`,children:[(0,F.jsx)(Y,{className:`dashboard-tool-name`,title:e.name,children:e.name}),(0,F.jsxs)(Y,{type:`secondary`,size:`small`,className:`dashboard-count`,children:[V(e.count),` 次`]})]}),e.count!==null&&(0,F.jsx)(_,{percent:Math.round(e.count/i*100),showInfo:!1,size:`small`,stroke:`var(--semi-color-primary)`,"aria-label":`${e.name}调用次数`,"aria-valuetext":`${V(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,F.jsxs)(`div`,{children:[(0,F.jsx)(`dl`,{className:`dashboard-project-totals`,children:o.map(([e,n])=>(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:e}),(0,F.jsx)(`dd`,{children:t?`…`:V(n)})]},e))}),(0,F.jsx)(s,{className:`dashboard-list dashboard-feed`,loading:t,dataSource:r?.slice(0,6)||[],emptyContent:(0,F.jsx)($,{loading:t,unavailable:!e,title:r===null?`在项目中继续工作`:`暂无项目`,description:r===null?`当前摘要提供项目与事实统计,完整列表请查看全部项目。`:`创建项目后,在这里跟进项目进展。`}),renderItem:e=>(0,F.jsx)(s.Item,{main:(0,F.jsxs)(`div`,{className:`dashboard-record`,children:[(0,F.jsx)(p,{theme:`borderless`,className:`dashboard-record-link`,onClick:()=>n(e.id),children:e.name||`未命名项目`}),(0,F.jsxs)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:[e.status||`—`,` · `,T(e.updated_at)]})]})},e.id)})]})}export{ce as default};
\ No newline at end of file
diff --git a/web/static/app/assets/deep-assessments-B2LO_dHI.css b/web/static/app/assets/deep-assessments-B2LO_dHI.css
new file mode 100644
index 00000000..3ddc05bf
--- /dev/null
+++ b/web/static/app/assets/deep-assessments-B2LO_dHI.css
@@ -0,0 +1 @@
+.assessment-page{flex-direction:column;gap:12px;display:flex}.assessment-page .cs-page-header-extra{flex-wrap:wrap;justify-content:flex-end}.assessment-meta{align-items:center;margin-top:6px}.assessment-banner{margin-bottom:0}.assessment-tabs{background:var(--semi-color-bg-1);border-radius:var(--semi-border-radius-large);padding:4px 16px 16px}.assessment-tab{flex-direction:column;gap:12px;padding-top:4px;display:flex}.assessment-status-value{letter-spacing:normal;overflow-wrap:anywhere;display:block}.assessment-loading{color:var(--semi-color-text-2);justify-content:center;align-items:center;padding:48px;display:flex}.assessment-hint{color:var(--semi-color-text-2);margin:8px 0 0;font-size:12px}.assessment-list-card .semi-card-header{flex-wrap:wrap;gap:10px}.assessment-view-options{white-space:nowrap}.assessment-toolbar{flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:12px;display:flex}.assessment-pager{justify-content:flex-end;padding-top:12px;display:flex}.assessment-list-name{flex-direction:column;gap:2px;min-width:0;display:flex}.assessment-link{text-align:left;justify-content:flex-start;height:auto;padding:0;font-weight:600}.assessment-ellipsis{text-overflow:ellipsis;white-space:nowrap;max-width:420px;overflow:hidden}.assessment-progress{flex-direction:column;gap:4px;display:flex}.assessment-progress .semi-progress-track{min-width:120px}.assessment-pre{white-space:pre-wrap;word-break:break-word;margin:0;font-family:inherit;line-height:1.6}.assessment-facts-row{flex-wrap:wrap;gap:16px;margin-top:12px;display:flex}.assessment-guidance{border-top:1px solid var(--semi-color-border);flex-direction:column;gap:8px;margin-top:16px;padding-top:12px;display:flex}.assessment-guidance-item{grid-template-columns:32px minmax(0,1fr);align-items:start;gap:8px;display:grid}.assessment-section{border-top:1px solid var(--semi-color-border);flex-direction:column;gap:8px;margin-top:4px;padding-top:12px;display:flex}.assessment-timeline{max-height:480px;padding-right:8px;overflow-y:auto}.assessment-event-head{align-items:center;gap:8px;display:flex}.assessment-event-message{white-space:pre-wrap;word-break:break-word;color:var(--semi-color-text-1);margin-top:2px;font-size:12px}.assessment-drawer{flex-direction:column;gap:12px;display:flex}.assessment-form-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:0 16px;display:grid}.assessment-role-option{align-items:center;gap:6px;min-width:0;display:inline-flex}.assessment-role-icon{flex:none;font-size:14px;line-height:1}.assessment-project-field{align-items:flex-end;gap:8px;padding-bottom:12px;display:flex}.semi-form-vertical .assessment-project-field>.semi-form-field{flex:1;min-width:0;padding-bottom:0}.assessment-scope-preview{flex-wrap:wrap;gap:6px;margin-top:8px;display:flex}.assessment-scope-hint{margin-top:6px}.assessment-form-note{margin-top:8px}.assessment-form-actions{justify-content:flex-end;gap:8px;display:flex}.assessment-graph-brief{border:1px solid var(--semi-color-border);border-radius:var(--semi-border-radius-medium);background:var(--semi-color-bg-1);margin-bottom:12px}.assessment-graph-brief>summary{cursor:pointer;padding:8px 12px}.assessment-graph-brief-counts{margin-inline-start:10px}.assessment-graph-brief-grid{border-top:1px solid var(--semi-color-border);grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;padding:12px;display:grid}.assessment-graph-brief-content{overflow-wrap:anywhere;flex-direction:column;align-items:flex-start;gap:6px;min-width:0;display:flex}.assessment-graph-summary{max-height:280px;overflow-y:auto}.assessment-graph-intents{width:100%;margin:0;padding:0;list-style:none}.assessment-graph-intents li{border-top:1px solid var(--semi-color-border);padding:4px 0}.assessment-graph-intent-head{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.assessment-graph-intent-head button{max-width:100%}.assessment-graph-intent-head .semi-button-content{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.assessment-graph-meta,.assessment-graph-toolbar,.assessment-graph-tools{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px;margin-bottom:8px;display:flex}.assessment-graph-tools{margin-top:8px}.assessment-graph-legend{color:var(--semi-color-text-1);flex-wrap:wrap;gap:5px 16px;margin:2px 0 10px;font-size:12px;display:flex}.assessment-graph-legend span{align-items:center;gap:6px;display:inline-flex}.assessment-graph-legend i{border-radius:2px;width:15px;height:2px}.assessment-graph-search{width:min(100%,340px)}.assessment-graph-layout{--assessment-graph-height:clamp(480px, 66svh, 720px);grid-template-columns:minmax(0,1fr);align-items:start;gap:12px;display:grid}.assessment-graph-layout.with-details{grid-template-columns:minmax(0,1fr) minmax(300px,350px)}.assessment-graph-viewport{height:var(--assessment-graph-height);border:1px solid var(--semi-color-border);border-radius:var(--semi-border-radius-medium);background:radial-gradient(circle, color-mix(in srgb, var(--semi-color-text-2) 17%, transparent) .8px, transparent 1px) 0 0 / 20px 20px, color-mix(in srgb, var(--semi-color-bg-1) 96%, #537cba);position:relative;overflow:hidden}.assessment-graph-canvas{direction:ltr;position:absolute;top:0;bottom:0;left:0;right:0}.assessment-node-panel{height:var(--assessment-graph-height);border:1px solid var(--semi-color-border);border-radius:var(--semi-border-radius-medium);background:var(--semi-color-bg-1);min-width:0;padding:12px;overflow-y:auto}.assessment-node-title{overflow-wrap:anywhere;justify-content:space-between;align-items:flex-start;gap:8px;display:flex}.assessment-node-title>button{flex-shrink:0}.assessment-node-body{flex-direction:column;gap:10px;display:flex}.assessment-node-head{flex-direction:column;gap:6px;display:flex}.assessment-node-content{border-radius:var(--semi-border-radius-small);background:var(--semi-color-fill-0);max-height:220px;padding:8px;overflow-y:auto}.assessment-relations{flex-wrap:wrap;gap:4px;display:flex}.assessment-path-list{flex-direction:column;gap:4px;max-height:240px;display:flex;overflow-y:auto}.assessment-path-node{border-radius:var(--semi-border-radius-small);background:var(--semi-color-fill-0);align-items:center;gap:8px;min-width:0;padding:4px 6px;display:flex}.assessment-report{max-width:960px}@media (max-width:1180px){.assessment-graph-layout.with-details{grid-template-columns:minmax(0,1fr)}.assessment-node-panel{height:auto;max-height:420px}}@media (max-width:720px){.assessment-form-grid,.assessment-graph-brief-grid{grid-template-columns:minmax(0,1fr)}.assessment-graph-layout{--assessment-graph-height:clamp(390px, 58svh, 500px)}}.assessment-error-block{flex-direction:column;align-items:flex-start;gap:8px;margin-bottom:12px;display:flex}.assessment-question-form{gap:8px;width:100%;display:grid}.assessment-question-form>button{justify-self:end}.assessment-question-turn{border-top:1px solid var(--semi-color-border);padding:12px 0}.assessment-question-turn p{white-space:pre-wrap;overflow-wrap:anywhere;margin:4px 0 12px}.assessment-coverage,.assessment-coverage .semi-table-cell{overflow-wrap:anywhere}
diff --git a/web/static/app/assets/deep-assessments-BVUI7zDD.css b/web/static/app/assets/deep-assessments-BVUI7zDD.css
deleted file mode 100644
index 8dea897f..00000000
--- a/web/static/app/assets/deep-assessments-BVUI7zDD.css
+++ /dev/null
@@ -1 +0,0 @@
-.assessment-page{flex-direction:column;gap:12px;display:flex}.assessment-page .cs-page-header-extra{flex-wrap:wrap;justify-content:flex-end}.assessment-meta{align-items:center;margin-top:6px}.assessment-banner{margin-bottom:0}.assessment-tabs{background:var(--semi-color-bg-1);border-radius:var(--semi-border-radius-large);padding:4px 16px 16px}.assessment-tab{flex-direction:column;gap:12px;padding-top:4px;display:flex}.assessment-status-value{letter-spacing:normal;overflow-wrap:anywhere;display:block}.assessment-loading{color:var(--semi-color-text-2);justify-content:center;align-items:center;padding:48px;display:flex}.assessment-hint{color:var(--semi-color-text-2);margin:8px 0 0;font-size:12px}.assessment-list-card .semi-card-header{flex-wrap:wrap;gap:10px}.assessment-view-options{white-space:nowrap}.assessment-toolbar{flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:12px;display:flex}.assessment-pager{justify-content:flex-end;padding-top:12px;display:flex}.assessment-list-name{flex-direction:column;gap:2px;min-width:0;display:flex}.assessment-link{text-align:left;justify-content:flex-start;height:auto;padding:0;font-weight:600}.assessment-ellipsis{text-overflow:ellipsis;white-space:nowrap;max-width:420px;overflow:hidden}.assessment-progress{flex-direction:column;gap:4px;display:flex}.assessment-progress .semi-progress-track{min-width:120px}.assessment-pre{white-space:pre-wrap;word-break:break-word;margin:0;font-family:inherit;line-height:1.6}.assessment-facts-row{flex-wrap:wrap;gap:16px;margin-top:12px;display:flex}.assessment-guidance{border-top:1px solid var(--semi-color-border);flex-direction:column;gap:8px;margin-top:16px;padding-top:12px;display:flex}.assessment-guidance-item{grid-template-columns:32px minmax(0,1fr);align-items:start;gap:8px;display:grid}.assessment-section{border-top:1px solid var(--semi-color-border);flex-direction:column;gap:8px;margin-top:4px;padding-top:12px;display:flex}.assessment-timeline{max-height:480px;padding-right:8px;overflow-y:auto}.assessment-event-head{align-items:center;gap:8px;display:flex}.assessment-event-message{white-space:pre-wrap;word-break:break-word;color:var(--semi-color-text-1);margin-top:2px;font-size:12px}.assessment-drawer{flex-direction:column;gap:12px;display:flex}.assessment-form-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:0 16px;display:grid}.assessment-role-option{align-items:center;gap:6px;min-width:0;display:inline-flex}.assessment-role-icon{flex:none;font-size:14px;line-height:1}.assessment-project-field{align-items:flex-end;gap:8px;padding-bottom:12px;display:flex}.semi-form-vertical .assessment-project-field>.semi-form-field{flex:1;min-width:0;padding-bottom:0}.assessment-form-note{margin-top:8px}.assessment-form-actions{justify-content:flex-end;gap:8px;display:flex}.assessment-graph-brief{border:1px solid var(--semi-color-border);border-radius:var(--semi-border-radius-medium);background:var(--semi-color-bg-1);margin-bottom:12px}.assessment-graph-brief>summary{cursor:pointer;padding:8px 12px}.assessment-graph-brief-counts{margin-inline-start:10px}.assessment-graph-brief-grid{border-top:1px solid var(--semi-color-border);grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;padding:12px;display:grid}.assessment-graph-brief-content{overflow-wrap:anywhere;flex-direction:column;align-items:flex-start;gap:6px;min-width:0;display:flex}.assessment-graph-summary{max-height:280px;overflow-y:auto}.assessment-graph-intents{width:100%;margin:0;padding:0;list-style:none}.assessment-graph-intents li{border-top:1px solid var(--semi-color-border);padding:4px 0}.assessment-graph-intent-head{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.assessment-graph-intent-head button{max-width:100%}.assessment-graph-intent-head .semi-button-content{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.assessment-graph-meta,.assessment-graph-toolbar,.assessment-graph-tools{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px;margin-bottom:8px;display:flex}.assessment-graph-tools{margin-top:8px}.assessment-graph-legend{color:var(--semi-color-text-1);flex-wrap:wrap;gap:5px 16px;margin:2px 0 10px;font-size:12px;display:flex}.assessment-graph-legend span{align-items:center;gap:6px;display:inline-flex}.assessment-graph-legend i{border-radius:2px;width:15px;height:2px}.assessment-graph-search{width:min(100%,340px)}.assessment-graph-layout{--assessment-graph-height:clamp(480px, 66svh, 720px);grid-template-columns:minmax(0,1fr);align-items:start;gap:12px;display:grid}.assessment-graph-layout.with-details{grid-template-columns:minmax(0,1fr) minmax(300px,350px)}.assessment-graph-viewport{height:var(--assessment-graph-height);border:1px solid var(--semi-color-border);border-radius:var(--semi-border-radius-medium);background:radial-gradient(circle, color-mix(in srgb, var(--semi-color-text-2) 17%, transparent) .8px, transparent 1px) 0 0 / 20px 20px, color-mix(in srgb, var(--semi-color-bg-1) 96%, #537cba);position:relative;overflow:hidden}.assessment-graph-canvas{direction:ltr;position:absolute;top:0;bottom:0;left:0;right:0}.assessment-node-panel{height:var(--assessment-graph-height);border:1px solid var(--semi-color-border);border-radius:var(--semi-border-radius-medium);background:var(--semi-color-bg-1);min-width:0;padding:12px;overflow-y:auto}.assessment-node-title{overflow-wrap:anywhere;justify-content:space-between;align-items:flex-start;gap:8px;display:flex}.assessment-node-title>button{flex-shrink:0}.assessment-node-body{flex-direction:column;gap:10px;display:flex}.assessment-node-head{flex-direction:column;gap:6px;display:flex}.assessment-node-content{border-radius:var(--semi-border-radius-small);background:var(--semi-color-fill-0);max-height:220px;padding:8px;overflow-y:auto}.assessment-relations{flex-wrap:wrap;gap:4px;display:flex}.assessment-path-list{flex-direction:column;gap:4px;max-height:240px;display:flex;overflow-y:auto}.assessment-path-node{border-radius:var(--semi-border-radius-small);background:var(--semi-color-fill-0);align-items:center;gap:8px;min-width:0;padding:4px 6px;display:flex}.assessment-report{max-width:960px}@media (max-width:1180px){.assessment-graph-layout.with-details{grid-template-columns:minmax(0,1fr)}.assessment-node-panel{height:auto;max-height:420px}}@media (max-width:720px){.assessment-form-grid,.assessment-graph-brief-grid{grid-template-columns:minmax(0,1fr)}.assessment-graph-layout{--assessment-graph-height:clamp(390px, 58svh, 500px)}}.assessment-error-block{flex-direction:column;align-items:flex-start;gap:8px;margin-bottom:12px;display:flex}.assessment-question-form{gap:8px;width:100%;display:grid}.assessment-question-form>button{justify-self:end}.assessment-question-turn{border-top:1px solid var(--semi-color-border);padding:12px 0}.assessment-question-turn p{white-space:pre-wrap;overflow-wrap:anywhere;margin:4px 0 12px}.assessment-coverage,.assessment-coverage .semi-table-cell{overflow-wrap:anywhere}
diff --git a/web/static/app/assets/deep-assessments-BwHg6NCr.js b/web/static/app/assets/deep-assessments-Cg3s64GH.js
similarity index 63%
rename from web/static/app/assets/deep-assessments-BwHg6NCr.js
rename to web/static/app/assets/deep-assessments-Cg3s64GH.js
index 52abaa66..96f0e7ad 100644
--- a/web/static/app/assets/deep-assessments-BwHg6NCr.js
+++ b/web/static/app/assets/deep-assessments-Cg3s64GH.js
@@ -1,2 +1,2 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,u as r,y as i}from"./react-QV7DAAIx.js";import{B as a,E as o,G as s,I as c,Lt as l,N as u,P as d,R as f,S as p,U as m,W as h,c as g,d as _,ft as v,g as y,h as b,i as x,lt as S,s as C,ut as w,x as T,y as ee}from"./semi-65W_4I1v.js";import{D as E,E as D,F as O,I as k,L as A,R as j,S as M,_ as N,a as P,b as F,c as I,d as L,f as R,h as te,l as z,m as B,n as ne,o as V,p as re,r as ie,s as H,t as ae,u as U,v as oe,x as W,y as se}from"./index-DNMXun-U.js";import{n as ce,r as le}from"./model-channel-mQ6lfvSO.js";import{t as ue}from"./project-form-B7wV5B1p.js";import{a as G,i as de,n as K,o as fe,r as pe,t as me}from"./graph-parents-i1hc3RVG.js";var q=e(t(),1),J={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:`已归档`},Y=[`running`,`pausing`,`cancelling`],X=[`completed`,`cancelled`],Z=[`needs_review`,`uncertain`,`cleanup_unconfirmed`],he={goal:`目标`,step:`探索意图`,observation:`观察`,receipt:`执行回执`,memory:`Pi 摘要`,digest:`历史归档`,guidance:`人工线索`,fact:`事实`,finding:`漏洞`},ge={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:`已有证据`},_e={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:`已确认核对`},ve={observed:`已观察`,inferred:`推断`},ye={observed:`green`,inferred:`amber`},be={has_evidence:`已有证据`,missing:`缺证据`,needs_review:`待人工复核`},xe={has_evidence:`green`,missing:`red`,needs_review:`amber`},Se=`assessments:write`,Ce=`assessments:delete`;function Q(e,t){return t?e(`deepAssessments.states.${t}`,null,J[t]||t):`—`}function we(e,t){return e(`deepAssessments.graphKinds.${t}`,null,he[t]||t||`节点`)}function Te(e,t){return t?e(`deepAssessments.graphStates.${t}`,null,ge[t]||Q(e,t)):`—`}function Ee(e,t){return t?e(`deepAssessments.workbench.events.${t}`,null,_e[t]||t):`事件`}function De(e,t){return e(`deepAssessments.confidence.${t}`,null,ve[t]||t||`—`)}function Oe(e,t){return e(`deepAssessments.acceptanceStatus.${t}`,null,be[t]||t||`—`)}function ke(e){return Y.includes(e?.status)}function Ae(e){return X.includes(e?.status)}function je(e){return e?Number(e.review_count)>0||Z.includes(e.status)?!0:(e.steps||[]).some(e=>Z.includes(e.status)):!1}function Me(e){return!!e&&!e.archived&&!Ae(e)&&!ke(e)&&!e.question&&e.status!==`waiting_input`}function Ne(e){return!!e&&!e.archived&&[`running`,`recovering`,`waiting_retry`,`waiting_progress`].includes(e.status)}function Pe(e){return!!e&&!e.archived&&!Ae(e)}function Fe(e){return!!e&&e.status===`cancelled`&&!e.archived}function Ie(e){return!!e&&!e.archived&&!ke(e)&&!je(e)&&![`recovering`,`needs_review`,`uncertain`,`cleanup_unconfirmed`].includes(e.status)}function Le(e){return!!e?.archived}function Re(e){return!!e&&!ke(e)}function ze(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 Be(e){let t=Math.floor(Number(e));if(!Number.isFinite(t)||t<0)return`—`;if(t<60)return`${t} 秒`;let n=`${Math.floor(t/60)%60} 分 ${t%60} 秒`;return t<3600?n:`${Math.floor(t/3600)} 小时 ${n}`}function Ve(e,t=80){let n=String(e??``);return n.length>t?`${n.slice(0,t)}…`:n}function He(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 Ue={goal:`#0066ff`,step:`#13a8a8`,fact:`#00b42a`,finding:`#f53f3f`,observation:`#722ed1`,receipt:`#86909c`,memory:`#ff7d00`,digest:`#c9cdd4`,guidance:`#eb2f96`},$=e(n(),1),We=[{value:``,label:`系统默认`},{value:`off`,label:`关闭审批`},{value:`human`,label:`人工审批`},{value:`audit_agent`,label:`审计代理审批`},{value:`review_edit`,label:`复核并允许编辑`}],Ge=[{value:``,label:`继承项目设置 / 默认不限速`},{value:`off`,label:`关闭限速提示(off)`},{value:`quiet`,label:`低噪串行(quiet · 2 RPS)`},{value:`balanced`,label:`均衡速率(balanced · 5 RPS)`},{value:`aggressive`,label:`维护窗口高吞吐(aggressive · 20 RPS)`}],Ke=`默认`;function qe(e){if(typeof e==`string`)return{name:e.trim(),icon:``};if(!e||typeof e!=`object`)return null;let t=String(e.name||``).trim();return t?{name:t,icon:String(e.icon||``).trim()}:null}function Je(e){return{value:e.name===Ke?``:e.name,name:e.name,icon:e.icon,label:(0,$.jsxs)(`span`,{className:`assessment-role-option`,children:[e.icon?(0,$.jsx)(`span`,{className:`assessment-role-icon`,"aria-hidden":`true`,children:e.icon}):null,(0,$.jsx)(`span`,{children:e.name})]})}}function Ye(e){let t=(Array.isArray(e)?e:[]).map(qe).filter(Boolean),n=t.filter(e=>e.name!==Ke),r=t.find(e=>e.name===Ke);return[...r?[Je(r)]:[],...n.map(Je)]}function Xe({projectId:e}){let t=O(),n=P(()=>A.get(`/assets`,{project_id:e,page:1,page_size:1}),[e]),r=Number.isFinite(Number(n.data?.total))?Number(n.data.total):null,i=t(`common.loading`,null,`加载中…`);return!n.loading&&n.error?i=`资产库暂时读不到。保存后仍使用该项目在资产库中的资产。`:!n.loading&&r===0?i=`这个项目的资产库还是空的。测评中新发现的目标会写进资产库,对话和批量任务也能看到。`:!n.loading&&r!=null&&(i=`资产范围是资产库里这个项目的 ${r} 个资产。对话、批量任务和这次测评用的是同一批,会自动交给模型。`),(0,$.jsx)(x.Slot,{label:t(`deepAssessments.assetScope`,null,`资产范围`),children:(0,$.jsx)(s.Text,{type:`tertiary`,role:`status`,children:i})})}function Ze({visible:e,onCancel:t,onCreated:n}){let r=O(),i=r(`deepAssessments.create`,null,`新建测评`),{hasPermission:o}=k(),s=o(`project:read`)&&o(`project:write`),c=(0,q.useId)(),l=(0,q.useRef)(null),[u,d]=(0,q.useState)(null),[p,m]=(0,q.useState)(null),[g,_]=(0,q.useState)(!1),[y,b]=(0,q.useState)(!1),[S,C]=(0,q.useState)(``),w=g||y,T=(0,q.useCallback)(()=>{d(null),m(null),C(``),A.get(`/deep-assessments/options`).then(e=>d(e||{})).catch(e=>m(e))},[]);(0,q.useEffect)(()=>{e&&T()},[e,T]);let ee=e=>{C(e||``)},E=async e=>{if(!w){_(!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||``,noise_profile:e.noise_profile||``,concurrency:Number(e.concurrency)||2,auto_resume:e.auto_resume!==!1},i=await A.post(`/deep-assessments`,t);W(r(`deepAssessments.saved`,null,`已创建测评`)),n?.(i?.task)}catch(e){F(e,r(`deepAssessments.saveFailed`,null,`创建失败`))}finally{_(!1)}}},D=e=>{b(!1),e?.id&&(d(t=>({...t,projects:[e,...t?.projects||[]]})),l.current?.setValue(`project_id`,e.id),ee(e.id))},j=ce((u?.models||[]).map(e=>[e.id,e])),M=Ye(u?.roles),N=(u?.projects||[]).map(e=>({value:e.id,label:e.name||e.id}));return(0,$.jsxs)(I,{visible:e,title:i,"aria-label":i,onCancel:t,width:680,closable:!w,closeOnEsc:!w,maskClosable:!w,footer:(0,$.jsxs)(`div`,{className:`assessment-form-actions`,children:[(0,$.jsx)(f,{theme:`borderless`,onClick:t,disabled:w,children:r(`deepAssessments.close`,null,`关闭`)}),(0,$.jsx)(f,{htmlType:`submit`,form:c,theme:`solid`,type:`primary`,loading:g,disabled:w||!u&&!p,children:r(`deepAssessments.save`,null,`保存草稿`)})]}),children:[p?(0,$.jsxs)(`div`,{className:`assessment-error-block`,children:[(0,$.jsx)(z,{error:p}),(0,$.jsx)(f,{size:`small`,onClick:T,children:`重试`})]}):null,!u&&!p?(0,$.jsx)(`div`,{className:`assessment-loading`,children:(0,$.jsx)(h,{})}):(0,$.jsxs)(x,{id:c,getFormApi:e=>{l.current=e},initValues:{concurrency:2,auto_resume:!0,hitl_policy:``,noise_profile:``,role:``},labelPosition:`top`,autoScrollToError:!0,onSubmit:E,children:[(0,$.jsx)(x.Input,{field:`name`,label:r(`deepAssessments.name`,null,`测评名称`),maxLength:200,placeholder:`留空则取目标前 80 个字符`}),(0,$.jsx)(x.TextArea,{field:`objective`,label:r(`deepAssessments.objective`,null,`目标`),rows:3,maxLength:16e3,placeholder:`要达成的最终结果,例如:评估 example.com 对外接口的认证与越权风险并给出可复现证据。`,rules:[{required:!0,message:`请填写测评目标`}]}),(0,$.jsx)(x.TextArea,{field:`scope`,label:r(`deepAssessments.scopeOptional`,null,`补充限制与排除项(选填)`),rows:2,maxLength:16e3,placeholder:`例如:排除支付接口;不修改生产数据;不做压力测试。留空表示无额外限制。`}),(0,$.jsx)(x.TextArea,{field:`criteria`,label:r(`deepAssessments.criteriaOptional`,null,`验收条件(选填)`),rows:3,maxLength:8e3,placeholder:`每行一条验收条件,例如:确认的漏洞附复现步骤和原始证据。留空沿用目标。`}),(0,$.jsxs)(`div`,{className:`assessment-form-grid`,children:[(0,$.jsx)(x.Select,{field:`model`,label:r(`deepAssessments.model`,null,`模型渠道`),optionList:[{value:``,label:`系统默认`},...j],renderSelectedItem:le,style:{width:`100%`}}),(0,$.jsx)(x.Select,{field:`role`,label:r(`deepAssessments.role`,null,`角色`),optionList:M,renderSelectedItem:e=>(0,$.jsxs)(`span`,{className:`assessment-role-option`,children:[e.icon?(0,$.jsx)(`span`,{className:`assessment-role-icon`,"aria-hidden":`true`,children:e.icon}):null,(0,$.jsx)(`span`,{children:e.name})]}),style:{width:`100%`}}),(0,$.jsxs)(`div`,{className:`assessment-project-field`,children:[(0,$.jsx)(x.Select,{field:`project_id`,label:r(`deepAssessments.project`,null,`关联项目`),optionList:[{value:``,label:`不关联`},...N],style:{width:`100%`},onChange:ee}),s&&(0,$.jsx)(f,{icon:(0,$.jsx)(v,{"aria-hidden":!0}),theme:`light`,type:`primary`,disabled:g,onClick:()=>b(!0),children:r(`projects.newProject`,null,`新建项目`)})]}),S&&(0,$.jsx)(Xe,{projectId:S},S),(0,$.jsx)(x.InputNumber,{field:`concurrency`,label:r(`deepAssessments.concurrency`,null,`并行步骤`),min:1,max:4,style:{width:`100%`}})]}),(0,$.jsxs)(`div`,{className:`assessment-form-grid`,children:[(0,$.jsx)(x.Select,{field:`hitl_policy`,label:`人工审批策略`,optionList:We,style:{width:`100%`}}),(0,$.jsx)(x.Select,{field:`noise_profile`,label:r(`deepAssessments.noiseProfile`,null,`任务速率/噪音档位`),optionList:Ge,style:{width:`100%`}})]}),(0,$.jsx)(x.Switch,{field:`auto_resume`,label:r(`deepAssessments.autoResume`,null,`服务重启后自动恢复结果明确的步骤`)}),(0,$.jsx)(a,{type:`info`,bordered:!0,closeIcon:null,className:`assessment-form-note`,description:`创建后保存为草稿,需要手动点击“开始 / 继续”才会执行。关联项目后,资产范围直接使用资产库中的项目资产。`})]}),y&&(0,$.jsx)(ue,{visible:!0,onCancel:()=>b(!1),onSaved:D})]})}var{Text:Qe}=s,$e=[`draft`,`running`,`paused`,`blocked`,`failed`,`waiting_input`,`waiting_retry`,`recovering`,`uncertain`,`cleanup_unconfirmed`,`completed`,`cancelled`].map(e=>({value:e,label:J[e]}));function et({onOpen:e}){let t=O(),{hasPermission:n}=k(),[r,i]=(0,q.useState)(``),[a,o]=(0,q.useState)(``),[s,u]=(0,q.useState)(!1),[d,p]=(0,q.useState)(0),[h,g]=(0,q.useState)(!1),[_,x]=(0,q.useState)({}),C=ne(r,300),T=n(Se),j=n(Ce),M=(0,q.useMemo)(()=>({q:C,status:a,limit:20,offset:d*20,archived:s?`true`:``}),[C,a,d,s]),N=P(()=>A.get(`/deep-assessments`,M),[M]),I=(0,q.useMemo)(()=>N.data?.tasks||[],[N.data]);(0,q.useEffect)(()=>{p(0)},[C,a,s]),(0,q.useEffect)(()=>{let e=I.filter(e=>!_[`${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&&x(e=>({...e,...r}))}),()=>{t=!0}},[I]);let L=e=>{se({title:t(`deepAssessments.delete`,null,`删除`),content:`删除测评「${e.name||e.id}」?关联执行会话仍保留。`,okText:t(`deepAssessments.delete`,null,`删除`),onOk:async()=>{try{await A.del(`/deep-assessments/${e.id}`),W(t(`deepAssessments.deleted`,null,`已删除`)),await N.reload()}catch(e){F(e,t(`deepAssessments.deleteFailed`,null,`删除失败`))}}})},R=[{title:t(`deepAssessments.name`,null,`测评名称`),dataIndex:`name`,width:260,render:(t,n)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(f,{theme:`borderless`,className:`assessment-link`,onClick:()=>e?.(n.id),children:t||n.id}),(0,$.jsx)(Qe,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:n.id})]})},{title:t(`deepAssessments.status`,null,`状态`),dataIndex:`status`,width:130,render:(e,n)=>(0,$.jsxs)(c,{spacing:4,children:[(0,$.jsx)(oe,{status:e,label:Q(t,e)}),n.archived?(0,$.jsx)(oe,{status:`archived`,label:Q(t,`archived`)}):null,je(n)?(0,$.jsx)(oe,{status:`needs_review`,label:Q(t,`needs_review`)}):null]})},{title:t(`deepAssessments.objective`,null,`目标`),dataIndex:`summary`,render:(e,t)=>{let n=_[`${t.id}:${t.updated_at}`]?.objective||e||`—`;return(0,$.jsx)(Qe,{ellipsis:{showTooltip:!0},className:`assessment-ellipsis`,children:n})}},{title:`进度`,width:190,align:`left`,render:(e,t)=>{let n=_[`${t.id}:${t.updated_at}`];if(!n)return(0,$.jsx)(Qe,{type:`tertiary`,children:`—`});let r=ze(n.counts,n.total);return(0,$.jsxs)(`div`,{className:`assessment-progress`,children:[(0,$.jsx)(y,{percent:r.percent,showInfo:!0,size:`small`,strokeWidth:6}),(0,$.jsxs)(Qe,{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,$.jsxs)(c,{spacing:4,children:[(0,$.jsx)(f,{theme:`borderless`,size:`small`,onClick:()=>e?.(r.id),children:`进入`}),(0,$.jsx)(f,{theme:`borderless`,type:`danger`,size:`small`,icon:(0,$.jsx)(l,{}),disabled:!j||!Re(r),onClick:()=>L(r),children:t(`deepAssessments.delete`,null,`删除`)})]})}];return(0,$.jsxs)(`div`,{className:`assessment-page`,children:[(0,$.jsx)(re,{title:t(`deepAssessments.title`,null,`深度测评`),description:t(`deepAssessments.subtitle`,null,`围绕一个目标持续探索,保存证据与进度,跨会话继续执行。`),extra:[(0,$.jsx)(f,{icon:(0,$.jsx)(w,{}),onClick:()=>N.reload(),loading:N.loading,children:t(`deepAssessments.refresh`,null,`刷新`)},`refresh`),(0,$.jsx)(f,{icon:(0,$.jsx)(v,{}),theme:`solid`,type:`primary`,disabled:!T,onClick:()=>g(!0),children:t(`deepAssessments.create`,null,`新建测评`)},`create`)]}),(0,$.jsx)(z,{error:N.error,onRetry:()=>N.reload()}),(0,$.jsxs)(B,{className:`assessment-list-card`,title:t(`deepAssessments.listTitle`,null,`测评列表`),extra:(0,$.jsx)(b,{className:`assessment-view-options`,"aria-label":t(`deepAssessments.archiveFilter`,null,`归档状态`),type:`button`,value:s?`archived`:`unarchived`,options:[{value:`unarchived`,label:t(`deepAssessments.unarchivedTasks`,null,`未归档`)},{value:`archived`,label:t(`deepAssessments.archivedTasks`,null,`已归档`)}],onChange:e=>u(e.target.value===`archived`)}),children:[(0,$.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,$.jsx)(m,{prefix:(0,$.jsx)(S,{}),value:r,onChange:i,placeholder:t(`deepAssessments.search`,null,`搜索测评名称`),style:{width:260},showClear:!0}),(0,$.jsx)(ee,{value:a,onChange:e=>o(e||``),optionList:[{value:``,label:t(`deepAssessments.all`,null,`全部状态`)},...$e],style:{width:160}})]}),(0,$.jsx)(H,{columns:R,dataSource:I,rowKey:`id`,loading:N.loading,pagination:!1,emptyText:t(`deepAssessments.empty`,null,`暂无测评,先创建一个目标。`)}),(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:d===0,onClick:()=>p(e=>Math.max(0,e-1)),children:t(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsxs)(Qe,{type:`tertiary`,children:[`第 `,d+1,` 页`]}),(0,$.jsx)(f,{size:`small`,disabled:!N.data?.has_more,onClick:()=>p(e=>e+1),children:t(`deepAssessments.next`,null,`下一页`)})]})})]}),(0,$.jsx)(Ze,{visible:h,onCancel:()=>g(!1),onCreated:t=>{g(!1),N.reload(),t?.id&&e?.(t.id)}})]})}var{Paragraph:tt,Text:nt}=s,rt=e=>JSON.stringify([e.surface,e.risk_area]),it=e=>JSON.stringify([e.kind,e.surface,e.risk_area,e.goal_id]);function at({id:e,reloadToken:t,onView:n}){let r=O(),i=P(()=>A.get(`/deep-assessments/${e}/coverage`),[e,t]),a=i.data,o=!!n,s=(e,t)=>r(`deepAssessments.coverage.${e}`,t),l={title:s(`surface`),dataIndex:`surface`,width:180,render:e=>e||`—`},d={title:s(`riskArea`),dataIndex:`risk_area`,width:140},p=[l,d,{title:s(`outcome`),dataIndex:`outcome`,width:150,render:e=>s(`outcomes.${e}`)},{title:s(`evidence`),dataIndex:`evidence`,width:180,render:e=>e||`—`},{title:s(`reason`),dataIndex:`reason`,render:e=>e||`—`}],m=[l,d,{title:s(`gap`),dataIndex:`kind`,render:e=>s(`gapKinds.${e}`)},{title:s(`goalRef`),dataIndex:`goal_id`,width:160,render:e=>e||`—`}];return(0,$.jsxs)(B,{title:s(`title`),extra:o?(0,$.jsx)(f,{size:`small`,onClick:n,children:s(`view`)}):(0,$.jsx)(f,{size:`small`,onClick:()=>i.reload(),loading:i.loading,children:r(`common.refresh`)}),children:[(0,$.jsx)(z,{error:i.error,onRetry:()=>i.reload()}),i.loading&&!a?(0,$.jsx)(nt,{type:`tertiary`,children:s(`loading`)}):null,a?(0,$.jsxs)(`div`,{className:`assessment-tab assessment-coverage`,children:[(0,$.jsx)(tt,{children:s(`summary`,{records:a.records.length,gaps:a.gaps.length})}),a.records.length>0?(0,$.jsx)(c,{wrap:!0,children:Object.entries(a.counts).map(([e,t])=>(0,$.jsxs)(u,{children:[s(`outcomes.${e}`),` · `,t]},e))}):null,o?(0,$.jsxs)($.Fragment,{children:[a.goals.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(nt,{strong:!0,children:s(`goals`)}),(0,$.jsx)(`ul`,{children:a.goals.map(e=>(0,$.jsxs)(`li`,{children:[e.text,` `,e.risk_class?(0,$.jsx)(u,{size:`small`,children:e.risk_class}):null]},e.goal_id))})]}):null,a.constraints.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(nt,{strong:!0,children:s(`constraints`)}),(0,$.jsx)(`ul`,{children:a.constraints.map(e=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(u,{size:`small`,children:s(`constraintKinds.${e.kind}`)}),` `,e.text,` `,(0,$.jsxs)(nt,{type:`tertiary`,children:[`(`,e.origin,`)`]})]},e.constraint_id))})]}):null]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(H,{columns:p,dataSource:a.records,rowKey:rt,pagination:a.records.length>10&&void 0,emptyText:s(`emptyRecords`)}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(nt,{strong:!0,children:s(`gaps`)}),(0,$.jsx)(tt,{type:`tertiary`,children:s(`gapHint`)}),(0,$.jsx)(H,{columns:m,dataSource:a.gaps,rowKey:it,pagination:a.gaps.length>10&&void 0,emptyText:s(`emptyGaps`)})]})]})]}):null]})}var{Text:ot,Paragraph:st}=s,ct={blocked:`error`,waiting_input:`warning`,completed:`success`,stop_requested:`warning`,retry:`warning`};function lt({startedAt:e,seconds:t}){let[n,r]=(0,q.useState)(Date.now);return ie(()=>r(Date.now()),1e3),Be(t+Math.max(0,Math.floor((n-e)/1e3)))}function ut({id:e}){let[t,n]=(0,q.useState)(null);return(0,q.useEffect)(()=>{let t=!1;return A.get(`/assets/collections/${e}`).then(e=>{t||n(e?.collection||null)}).catch(()=>{t||n(null)}),()=>{t=!0}},[e]),t?(0,$.jsxs)(ot,{type:`tertiary`,children:[`本次范围 `,t.name,`:可见资产 `,t.member_count||0,` 个,已确认观察 `,t.observed||0,` 个。项目历史观察和逐项验收分开统计,缺证据的必验项保持未完成。`]}):null}function dt({task:e,canWrite:t,events:n,eventsError:r,autoRefresh:i,onAutoRefreshChange:a,onRefreshEvents:s,onGoTab:l,onGuidance:d,onAnswer:p,reloadToken:m}){let h=O(),g={};(e.steps||[]).forEach(e=>{g[e.status]=(g[e.status]||0)+1});let v=ze(g,(e.steps||[]).length),y=e.review_count||(e.steps||[]).filter(e=>[`uncertain`,`cleanup_unconfirmed`].includes(e.status)).length,b=e.active_seconds??0,x=ke(e)?Date.parse(e.run_started_at):NaN,S=Be(b);e.archived?S=`已归档`:Number.isFinite(x)&&(S=(0,$.jsx)(lt,{startedAt:x,seconds:b},x));let w=[{id:`status`,label:h(`deepAssessments.status`,null,`状态`),value:(0,$.jsx)(`span`,{className:`assessment-status-value`,children:Q(h,e.status)}),detail:S},{id:`progress`,label:`意图完成度`,value:`${v.percent}%`,detail:`${v.done} / ${v.total} 已结束`},{id:`rounds`,label:h(`deepAssessments.rounds`,null,`规划轮次`),value:E(e.rounds||0)},{id:`tokens`,label:h(`deepAssessments.tokens`,null,`累计 Token`),value:E(e.tokens_used||0)},{id:`review`,label:`待核对`,value:E(y),detail:y?`需要人工确认工具结果`:`无待核对记录`}],T=[{label:h(`deepAssessments.objective`,null,`目标`),value:(0,$.jsx)(st,{className:`assessment-pre`,children:e.objective||`—`})},{label:h(`deepAssessments.scope`,null,`补充限制与排除项`),value:(0,$.jsx)(st,{className:`assessment-pre`,children:e.scope&&e.scope.trim()!==(e.objective||``).trim()?e.scope:`—`})},{label:h(`deepAssessments.criteria`,null,`验收条件`),value:(0,$.jsx)(st,{className:`assessment-pre`,children:e.criteria||`—`})},{label:h(`deepAssessments.strategy`,null,`最近规划路线`),value:(0,$.jsx)(st,{className:`assessment-pre`,children:e.strategy||`—`})},{label:h(`deepAssessments.summary`,null,`当前结论 / 缺口`),value:(0,$.jsx)(st,{className:`assessment-pre`,children:e.summary||`—`})}];e.question&&T.push({label:h(`deepAssessments.question`,null,`待补充信息`),value:(0,$.jsx)(st,{className:`assessment-pre`,children:e.question})});let ee=n.slice().reverse().slice(0,120);return(0,$.jsxs)(`div`,{className:`assessment-tab`,children:[(0,$.jsx)(N,{metrics:w,columns:5}),e.collection_id?(0,$.jsx)(ut,{id:e.collection_id}):null,(0,$.jsxs)(B,{title:`目标与测评要求`,extra:(0,$.jsxs)(c,{children:[t&&!e.archived&&e.status!==`completed`&&e.status!==`cancelled`?(0,$.jsx)(f,{size:`small`,onClick:d,children:`补充方向`}):null,e.question?(0,$.jsx)(f,{size:`small`,theme:`solid`,type:`primary`,onClick:p,children:`答复`}):null,(0,$.jsx)(f,{size:`small`,onClick:()=>l?.(`intents`),children:`查看意图`})]}),children:[(0,$.jsx)(L,{items:T,columns:1}),(0,$.jsxs)(`div`,{className:`assessment-facts-row`,children:[(0,$.jsxs)(ot,{type:`tertiary`,children:[`自动续跑:`,e.auto_resume?`已开启`:`已关闭`]}),(0,$.jsxs)(ot,{type:`tertiary`,children:[`并行步骤:`,e.concurrency||`—`]}),(0,$.jsxs)(ot,{type:`tertiary`,children:[`人工审批:`,e.hitl_policy||`系统默认`]}),e.noise_profile?(0,$.jsxs)(ot,{type:`tertiary`,children:[`噪音档位:`,e.noise_profile]}):null,(0,$.jsxs)(ot,{type:`tertiary`,children:[`最近更新:`,D(e.updated_at)]})]}),Array.isArray(e.guidance)&&e.guidance.length?(0,$.jsxs)(`div`,{className:`assessment-guidance`,children:[(0,$.jsx)(ot,{strong:!0,children:`人工补充`}),e.guidance.map((e,t)=>(0,$.jsxs)(`div`,{className:`assessment-guidance-item`,children:[(0,$.jsxs)(ot,{type:`tertiary`,children:[`#`,t+1]}),(0,$.jsx)(st,{className:`assessment-pre`,children:e})]},`${t}-${e.slice(0,8)}`))]}):null,(0,$.jsx)(st,{type:`tertiary`,className:`assessment-hint`,children:`打开页面不会自动启动任务;自动续跑只针对服务重启前的执行,草稿、手动暂停和待核对任务不会自动开始。`})]}),(0,$.jsx)(at,{id:e.id,reloadToken:m,onView:()=>l?.(`acceptance`)},e.id),(0,$.jsxs)(B,{title:h(`deepAssessments.activity`,null,`运行记录`),description:`事件按时间倒序展示;运行中每 10 秒自动拉取,页面隐藏时跳过。`,extra:(0,$.jsxs)(c,{children:[(0,$.jsx)(ot,{type:`tertiary`,size:`small`,children:`自动刷新`}),(0,$.jsx)(_,{size:`small`,checked:i,onChange:e=>a?.(!!e)}),(0,$.jsx)(f,{size:`small`,onClick:s,children:`立即刷新`})]}),children:[(0,$.jsx)(z,{error:r,onRetry:s}),ee.length===0?(0,$.jsx)(o,{title:`暂无运行记录`,description:`开始测评后,规划、执行与核对事件会显示在这里。`,style:{padding:32}}):(0,$.jsx)(`div`,{className:`assessment-timeline`,children:(0,$.jsx)(C,{children:ee.map(e=>(0,$.jsxs)(C.Item,{time:D(e.created_at),type:ct[e.kind]||`default`,children:[(0,$.jsxs)(`div`,{className:`assessment-event-head`,children:[(0,$.jsx)(ot,{strong:!0,children:Ee(h,e.kind)}),e.step_id?(0,$.jsx)(u,{size:`small`,color:`grey`,children:e.step_id}):null]}),e.message?(0,$.jsx)(`div`,{className:`assessment-event-message`,children:e.message}):null]},e.id))})})]})]})}var{Text:ft,Paragraph:pt}=s,mt=[`running`,`pending`,`pausing`,`paused`,`completed`,`blocked`,`failed`,`uncertain`,`cleanup_unconfirmed`,`interrupted`,`retired`,`reconciled`];function ht({id:e,reloadToken:t,status:n,onStatusChange:r,onChanged:i,archived:a,taskStatus:o,revision:s}){let l=O(),{hasPermission:d}=k(),p=d(Se),[m,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(!1),[v,y]=(0,q.useState)(0),[b,x]=(0,q.useState)(null);(0,q.useEffect)(()=>{y(0)},[n]);let S=P(()=>A.get(`/deep-assessments/${e}/intents`,{status:n,offset:v}),[e,n,v,t]),C=S.data,w=C?.intents||[],T=C?.counts||{},D=async t=>{h(!0);try{await A.post(`/deep-assessments/${e}/control/intent-pause`,{revision:s,step_id:t.id}),W(`已提交此方向的暂停请求`)}catch(e){F(e,`暂停方向失败`)}finally{h(!1),x(null),i?.()}},j=t=>{se({title:`确认已核对`,content:`确认只解除本步骤的待核对状态,不会自动执行;原有进度和证据保留。`,okText:`确认已核对`,danger:!1,onOk:async()=>{_(!0);try{let n=await A.get(`/deep-assessments/${e}/steps/${t.id}`);await A.post(`/deep-assessments/${e}/control/reconcile`,{revision:n?.revision,step_id:t.id,reconciled:!0,cleanup_confirmed:!0}),W(`已记录核对,待核对列表已更新`),x(null),await S.reload(),i?.()}catch(e){F(e,`核对失败`)}finally{_(!1)}}})},M=(0,q.useMemo)(()=>{let e=mt.filter(e=>T[e]);return Object.keys(T).forEach(t=>{e.includes(t)||e.push(t)}),[{value:``,label:`${l(`deepAssessments.all`,null,`全部状态`)} · ${C?.total??0}`},...e.map(e=>({value:e,label:`${Q(l,e)} · ${T[e]}`}))]},[T,C?.total,l]),N=[{title:l(`deepAssessments.status`,null,`状态`),dataIndex:`status`,width:140,render:e=>(0,$.jsx)(oe,{status:e,label:Q(l,e)})},{title:`意图`,dataIndex:`title`,render:(e,t)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(ft,{ellipsis:{showTooltip:!0},children:e||t.id}),t.summary?(0,$.jsx)(ft,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:Ve(t.summary,120)}):null]})},{title:l(`deepAssessments.priority`,null,`优先级`),dataIndex:`priority`,width:90,render:e=>e||100},{title:l(`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,$.jsx)(ft,{type:`tertiary`,ellipsis:{showTooltip:!0},children:e}):`—`}];return(0,$.jsxs)(`div`,{className:`assessment-tab`,children:[(0,$.jsxs)(B,{title:l(`deepAssessments.plan`,null,`意图队列`),description:`队列按优先级排序;状态只表示执行情况,不代表漏洞或完成结论。`,extra:(0,$.jsx)(f,{size:`small`,onClick:()=>S.reload(),loading:S.loading,children:`刷新`}),children:[(0,$.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,$.jsx)(ee,{value:n,onChange:e=>r?.(e||``),optionList:M,style:{width:200}}),(0,$.jsxs)(ft,{type:`tertiary`,children:[`共 `,C?.total??0,` 条意图`]})]}),(0,$.jsx)(z,{error:S.error,onRetry:()=>S.reload()}),(0,$.jsx)(H,{columns:N,dataSource:w,rowKey:`id`,loading:S.loading,pagination:!1,onRow:e=>({onClick:()=>x(e),style:{cursor:`pointer`}}),emptyText:l(`deepAssessments.noIntents`,null,`暂无意图,开始测评后由规划器逐步生成探索方向。`)}),(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:v===0,onClick:()=>y(e=>Math.max(0,e-20)),children:l(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsx)(ft,{type:`tertiary`,children:w.length?`${v+1} - ${v+w.length}`:`0`}),(0,$.jsx)(f,{size:`small`,disabled:!C?.has_more,onClick:()=>y(e=>e+20),children:l(`deepAssessments.next`,null,`下一页`)})]})})]}),(0,$.jsx)(I,{visible:!!b,onCancel:()=>x(null),title:b?.title||`意图详情`,width:560,footer:null,children:b?(0,$.jsxs)(`div`,{className:`assessment-drawer`,children:[p&&!a&&o===`running`&&[`pending`,`running`].includes(b.status)&&(0,$.jsx)(f,{onClick:()=>D(b),loading:m,disabled:m,children:`暂停此方向`}),(0,$.jsx)(L,{columns:2,items:[{label:l(`deepAssessments.status`,null,`状态`),value:(0,$.jsx)(oe,{status:b.status,label:Q(l,b.status)})},{label:`意图 ID`,value:b.id},{label:l(`deepAssessments.priority`,null,`优先级`),value:b.priority||100},{label:`执行分段`,value:b.attempts||0},{label:`手动暂停`,value:b.user_paused?`是`:`否`},{label:`执行会话`,value:b.conversation_id||`—`},{label:l(`deepAssessments.assets`,null,`关联资产`),value:(b.asset_ids||[]).join(`, `)||`—`},{label:`来源节点`,value:(b.source_ids||[]).join(`, `)||`—`},{label:`前置意图`,value:(b.depends_on||[]).join(`, `)||`—`},{label:`证据引用`,value:(b.evidence||[]).join(`, `)||`—`}]}),(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(ft,{strong:!0,children:`执行说明`}),(0,$.jsx)(pt,{className:`assessment-pre`,children:b.instruction||`—`})]}),(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(ft,{strong:!0,children:`结果摘要`}),(0,$.jsx)(pt,{className:`assessment-pre`,children:b.summary||`—`})]}),b.last_progress?(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(ft,{strong:!0,children:`最近进展`}),(0,$.jsx)(pt,{className:`assessment-pre`,children:b.last_progress})]}):null,Array.isArray(b.guidance)&&b.guidance.length?(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(ft,{strong:!0,children:`定向补充`}),b.guidance.map((e,t)=>(0,$.jsxs)(`div`,{className:`assessment-guidance-item`,children:[(0,$.jsxs)(u,{size:`small`,color:`grey`,children:[`#`,t+1]}),(0,$.jsx)(pt,{className:`assessment-pre`,children:e})]},`${t}-${e.slice(0,8)}`))]}):null,[`uncertain`,`cleanup_unconfirmed`].includes(b.status)?(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(ft,{strong:!0,children:`待核对`}),(0,$.jsx)(pt,{type:`tertiary`,className:`assessment-hint`,children:`确认只解除本步骤的待核对状态,不会自动执行;仍有结果不明的调用时请保持停止。`}),(0,$.jsx)(f,{size:`small`,theme:`solid`,type:`primary`,disabled:!p||a,loading:g,onClick:()=>j(b),children:`确认已核对`})]}):null,b.conversations?.length?(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(ft,{strong:!0,children:`历史执行会话`}),(0,$.jsx)(pt,{className:`assessment-pre`,children:b.conversations.join(`
-`)})]}):null]}):null})]})}var{Text:gt,Paragraph:_t}=s;function vt({id:e,reloadToken:t}){let n=O(),[r,i]=(0,q.useState)(``),[a,o]=(0,q.useState)(0),[s,l]=(0,q.useState)(null);(0,q.useEffect)(()=>{o(0)},[r]);let d=P(()=>A.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,$.jsx)(u,{color:ye[e]||`grey`,shape:`circle`,children:De(n,e)})},{title:`摘要`,dataIndex:`summary`,render:(e,t)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(gt,{ellipsis:{showTooltip:!0},children:e||t.id}),t.body?(0,$.jsx)(gt,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:Ve(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,$.jsx)(gt,{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,$.jsxs)(`div`,{className:`assessment-tab`,children:[(0,$.jsxs)(B,{title:n(`deepAssessments.facts`,null,`事实`),description:`observed 表示有原始成功回执支撑;inferred 只是推断,不是证据。`,extra:(0,$.jsx)(f,{size:`small`,onClick:()=>d.reload(),loading:d.loading,children:`刷新`}),children:[(0,$.jsx)(`div`,{className:`assessment-toolbar`,children:(0,$.jsx)(ee,{value:r,onChange:e=>i(e||``),optionList:[{value:``,label:n(`deepAssessments.all`,null,`全部状态`)},{value:`observed`,label:De(n,`observed`)},{value:`inferred`,label:De(n,`inferred`)}],style:{width:160}})}),(0,$.jsx)(z,{error:d.error,onRetry:()=>d.reload()}),(0,$.jsx)(H,{columns:h,dataSource:m,rowKey:`id`,loading:d.loading,pagination:!1,onRow:e=>({onClick:()=>l(e),style:{cursor:`pointer`}}),emptyText:n(`deepAssessments.noFacts`,null,`暂无事实记录。`)}),(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:a===0,onClick:()=>o(e=>Math.max(0,e-20)),children:n(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsx)(gt,{type:`tertiary`,children:m.length?`${a+1} - ${a+m.length}`:`0`}),(0,$.jsx)(f,{size:`small`,disabled:!p?.has_more,onClick:()=>o(e=>e+20),children:n(`deepAssessments.next`,null,`下一页`)})]})})]}),(0,$.jsx)(I,{visible:!!s,onCancel:()=>l(null),title:`事实详情`,width:620,footer:null,children:s?(0,$.jsxs)(`div`,{className:`assessment-drawer`,children:[(0,$.jsx)(L,{columns:2,items:[{label:`置信度`,value:(0,$.jsx)(u,{color:ye[s.confidence]||`grey`,children:De(n,s.confidence)})},{label:`事实 ID`,value:s.id},{label:`来源意图`,value:s.step_id||`—`},{label:`时间`,value:D(s.created_at)},{label:n(`deepAssessments.assets`,null,`关联资产`),value:(s.asset_ids||[]).join(`, `)||`—`},{label:`证据回执`,value:(s.evidence||[]).join(`, `)||`—`},{label:`来源节点`,value:(s.source_ids||[]).join(`, `)||`—`}]}),(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(gt,{strong:!0,children:`摘要`}),(0,$.jsx)(_t,{className:`assessment-pre`,children:s.summary||`—`})]}),(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(gt,{strong:!0,children:`正文`}),(0,$.jsx)(_t,{className:`assessment-pre`,children:s.body||`—`})]}),(0,$.jsx)(U,{title:`原始记录`,value:s,collapsed:!0})]}):null})]})}var{Text:yt}=s,bt=20,xt={cloud_access_key:`AK/SK`,credential:`账号凭据`,api_token:`API Key / Token`,other:`其他线索`};function St({endpoint:e,item:t,onClose:n,onSaved:r}){let i=O(),a=(0,q.useRef)(null),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(null),u=t.id?i(`deepAssessments.surface.edit`,null,`编辑线索`):i(`deepAssessments.surface.add`,null,`新增线索`),d=Object.entries(xt).map(([e,t])=>({value:e,label:i(`deepAssessments.surface.kinds.${e}`,null,t)}));return(0,$.jsxs)(I,{visible:!0,title:u,"aria-label":u,onCancel:n,width:520,closable:!o,closeOnEsc:!o,maskClosable:!o,footer:(0,$.jsxs)(`div`,{className:`assessment-form-actions`,children:[(0,$.jsx)(f,{onClick:n,disabled:o,children:i(`common.cancel`,null,`取消`)}),(0,$.jsx)(f,{theme:`solid`,onClick:()=>a.current?.submitForm(),loading:o,disabled:o,children:i(`common.save`,null,`保存`)})]}),children:[(0,$.jsx)(yt,{type:`tertiary`,children:i(`deepAssessments.surface.redactionHint`,null,`请填写脱敏信息。密钥、密码和令牌原文应留在原证据位置。`)}),(0,$.jsxs)(x,{getFormApi:e=>{a.current=e},initValues:t,labelPosition:`top`,onSubmit:async({kind:n,summary:a=``,location:o=``,fact_id:c=``})=>{s(!0),l(null);let u={kind:n,summary:a.trim(),location:o.trim(),fact_id:c.trim()};try{t.id?await A.put(`${e}/${encodeURIComponent(t.id)}`,{...u,revision:t.revision}):await A.post(e,u),W(i(`deepAssessments.surface.saved`,null,`已保存攻击面线索`)),r()}catch(e){l(e)}finally{s(!1)}},disabled:o,children:[(0,$.jsx)(x.RadioGroup,{field:`kind`,label:i(`deepAssessments.surface.kind`,null,`类型`),options:d,direction:`vertical`,rules:[{required:!0,message:i(`deepAssessments.surface.kindRequired`,null,`请选择线索类型`)}]}),(0,$.jsx)(x.Input,{field:`summary`,label:i(`deepAssessments.surface.summary`,null,`脱敏摘要`),maxLength:120,rules:[{required:!0,whitespace:!0,message:i(`deepAssessments.surface.summaryRequired`,null,`请填写脱敏摘要`)}]}),(0,$.jsx)(x.Input,{field:`location`,label:i(`deepAssessments.surface.location`,null,`发现位置`),maxLength:240}),(0,$.jsx)(x.Input,{field:`fact_id`,label:i(`deepAssessments.surface.factId`,null,`关联事实 ID(选填)`),placeholder:i(`deepAssessments.surface.factHint`,null,`可从本次测评的事实详情复制`),maxLength:128}),(0,$.jsx)(z,{error:c})]})]})}function Ct({id:e,canWrite:t,reloadToken:n}){let i=O(),[a,o]=(0,q.useState)(0),[s,l]=(0,q.useState)(null),d=`/deep-assessments/${e}/surface-items`,p=P(()=>A.get(d,{offset:a}),[d,a,n]),m=p.data?.items||[],h=[{title:i(`deepAssessments.surface.kind`,null,`类型`),dataIndex:`kind`,width:135,render:e=>(0,$.jsx)(u,{size:`small`,children:i(`deepAssessments.surface.kinds.${e}`,null,xt[e]||e)})},{title:i(`deepAssessments.surface.summary`,null,`脱敏摘要`),dataIndex:`summary`},{title:i(`deepAssessments.surface.location`,null,`发现位置`),dataIndex:`location`,render:e=>e||`—`},{title:i(`deepAssessments.surface.evidence`,null,`证据`),dataIndex:`fact_id`,width:145,render:t=>t?(0,$.jsx)(r,{to:`?${new URLSearchParams({id:e,tab:`evidence-path`,fact_id:t})}`,children:i(`deepAssessments.surface.viewEvidence`,null,`查看证据路径`)}):`—`},...t?[{title:i(`deepAssessments.actions`,null,`操作`),key:`actions`,width:95,render:(e,t)=>(0,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>l(t),children:i(`deepAssessments.surface.edit`,null,`编辑线索`)})}]:[]];return(0,$.jsxs)(B,{title:i(`deepAssessments.surface.title`,null,`攻击面线索`),extra:t&&(0,$.jsx)(f,{icon:(0,$.jsx)(v,{}),size:`small`,onClick:()=>l({kind:`cloud_access_key`}),children:i(`deepAssessments.surface.add`,null,`新增线索`)}),children:[(0,$.jsx)(z,{error:p.error,onRetry:p.reload}),(0,$.jsx)(H,{columns:h,dataSource:m,rowKey:`id`,loading:p.loading,pagination:!1,emptyText:i(`deepAssessments.surface.empty`,null,`暂无攻击面线索。`)}),(a>0||p.data?.has_more)&&(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:a===0,onClick:()=>o(e=>e-bt),children:i(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsx)(f,{size:`small`,disabled:!p.data?.has_more,onClick:()=>o(e=>e+bt),children:i(`deepAssessments.next`,null,`下一页`)})]})}),s&&t&&(0,$.jsx)(St,{endpoint:d,item:s,onClose:()=>l(null),onSaved:()=>{l(null),a===0?p.reload():o(0)}})]})}var{Text:wt}=s;function Tt({visible:e,task:t,onCancel:n,onSaved:r}){O();let[i,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(1),[l,u]=(0,q.useState)([]),[d,p]=(0,q.useState)(!1),h=ne(i,300);(0,q.useEffect)(()=>{e&&(a(``),s(1),u([]))},[e]),(0,q.useEffect)(()=>{s(1)},[h]);let g=P(()=>A.get(`/assets`,{page:o,page_size:10,q:h,project_id:t?.project_id||``}),[o,h,t?.project_id,e],{skip:!e}),_=g.data?.assets||[];return(0,$.jsxs)(I,{visible:e,title:`关联共享资产`,"aria-label":`关联共享资产`,onCancel:n,width:760,closable:!d,closeOnEsc:!d,maskClosable:!d,footer:(0,$.jsxs)(`div`,{className:`assessment-form-actions`,children:[(0,$.jsx)(f,{onClick:n,disabled:d,children:`取消`}),(0,$.jsx)(f,{theme:`solid`,onClick:async()=>{if(l.length){p(!0);try{await A.post(`/deep-assessments/${t.id}/assets`,{asset_ids:l}),W(`已关联资产`),r?.()}catch(e){F(e,`关联资产失败`)}finally{p(!1)}}},loading:d,disabled:!l.length||d,children:`关联${l.length?` ${l.length} 项`:``}`})]}),children:[(0,$.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,$.jsx)(m,{prefix:(0,$.jsx)(S,{}),value:i,onChange:a,placeholder:`按地址、IP 或域名搜索`,style:{width:280},showClear:!0}),(0,$.jsx)(wt,{type:`tertiary`,children:`仅显示当前账号可读、且与测评同项目的资产。`})]}),(0,$.jsx)(z,{error:g.error,onRetry:()=>g.reload()}),(0,$.jsx)(H,{columns:[{title:`资产`,dataIndex:`host`,render:(e,t)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(wt,{strong:!0,children:e||t.ip||t.domain||t.id}),(0,$.jsx)(wt,{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:_,rowKey:`id`,loading:g.loading,pagination:!1,rowSelection:{selectedRowKeys:l,onChange:e=>u((e||[]).map(String))},emptyText:`没有匹配的资产,可先在资产库登记。`}),(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:o<=1,onClick:()=>s(e=>Math.max(1,e-1)),children:`上一页`}),(0,$.jsxs)(wt,{type:`tertiary`,children:[`第 `,o,` 页`]}),(0,$.jsx)(f,{size:`small`,disabled:!g.data?.total_pages||o>=g.data.total_pages,onClick:()=>s(e=>e+1),children:`下一页`})]})})]})}function Et({taskId:e,assetId:t}){let n=P(()=>A.get(`/deep-assessments/${e}/assets`,{asset_id:t}),[e,t],{skip:!t}),r=n.data?.endpoints||[];return n.loading&&!n.data?(0,$.jsx)(wt,{type:`tertiary`,children:`正在读取端点…`}):r.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(wt,{strong:!0,children:`端点`}),r.map(e=>(0,$.jsx)(`div`,{children:(0,$.jsxs)(wt,{children:[e.method,` `,e.path]})},e.id))]}):(0,$.jsx)(wt,{type:`tertiary`,children:`这个服务在资产库里还没有端点。任务中发现的路径会写到这里。`})}var Dt=new Set([`running`,`recovering`,`waiting_progress`,`waiting_retry`,`pausing`,`cancelling`]);function Ot({id:e,task:t,observation:n,reloadToken:r}){let i=O(),{hasPermission:a}=k(),[o,s]=(0,q.useState)(0),[l,d]=(0,q.useState)(!1),[p,m]=(0,q.useState)(null),h=P(()=>A.get(`/deep-assessments/${e}/assets`,{offset:o,observation:n}),[e,o,n,r]);ie(()=>{document.hidden||h.reload({silent:!0})},Dt.has(t?.status)?1e4:0);let g=h.data,_=g?.assets||[],y=g?.coverage||{},b=y.linked??g?.total??0,x=y.with_observed_evidence??0,S=b?Math.round(x/b*100):0,C=a(Se),w=(0,q.useMemo)(()=>[{id:`linked`,label:`关联资产`,value:b},{id:`observed`,label:`已有观察证据`,value:x},{id:`coverage`,label:`观察覆盖率`,value:`${S}%`,detail:`只统计当前账号可读的关联资产`},{id:`nodes`,label:i(`deepAssessments.attackSurfaceGraphNodes`,null,`攻击面图节点`),value:g?.nodes?.length??0}],[i,b,x,S,g?.nodes?.length]);return(0,$.jsxs)(`div`,{className:`assessment-tab`,children:[(0,$.jsx)(N,{metrics:w,columns:4}),(0,$.jsx)(Ct,{id:e,canWrite:C&&!t?.archived,reloadToken:r}),(0,$.jsxs)(B,{title:i(`deepAssessments.attackSurfaceGraph`,null,`攻击面图`),description:`与资产库是同一批记录。项目资产和任务中新发现的同范围服务、端点会自动出现。观察覆盖只统计已有事实的资产。`,extra:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{icon:(0,$.jsx)(v,{}),size:`small`,disabled:!C||t?.archived,onClick:()=>d(!0),children:`从资产库补充`}),(0,$.jsx)(f,{size:`small`,onClick:()=>h.reload(),loading:h.loading,children:`刷新`})]}),children:[(0,$.jsx)(z,{error:h.error,onRetry:()=>h.reload()}),(0,$.jsx)(H,{columns:[{title:`资产`,dataIndex:`host`,render:(e,t)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(wt,{strong:!0,children:e||t.ip||t.domain||t.id}),(0,$.jsx)(wt,{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,$.jsx)(u,{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:_,rowKey:`id`,loading:h.loading,pagination:!1,onRow:e=>({onClick:()=>m(e),style:{cursor:`pointer`}}),emptyText:`资产库里还没有纳入本次测评的资产。关联项目后会自动带入该项目的资产。`}),(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:o===0,onClick:()=>s(e=>Math.max(0,e-20)),children:i(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsxs)(wt,{type:`tertiary`,children:[`共 `,g?.total??0,` 项`]}),(0,$.jsx)(f,{size:`small`,disabled:!g?.has_more,onClick:()=>s(e=>e+20),children:i(`deepAssessments.next`,null,`下一页`)})]})})]}),(0,$.jsx)(Tt,{visible:l,task:t,onCancel:()=>d(!1),onSaved:()=>{d(!1),h.reload()}}),(0,$.jsx)(I,{visible:!!p,onCancel:()=>m(null),title:`资产详情`,width:560,footer:null,children:p?(0,$.jsxs)(`div`,{className:`assessment-drawer`,children:[(0,$.jsx)(L,{columns:2,items:[{label:`资产`,value:p.host||p.ip||p.id},{label:`ID`,value:p.id},{label:`IP`,value:p.ip||`—`},{label:`域名`,value:p.domain||`—`},{label:`端口`,value:p.port||`—`},{label:`协议`,value:p.protocol||`—`},{label:`项目`,value:p.project_name||`—`},{label:`状态`,value:p.status||`—`},{label:`风险`,value:p.risk_level||`—`},{label:`最近发现`,value:D(p.last_seen_at)}]}),(0,$.jsx)(Et,{taskId:e,assetId:p.id}),(0,$.jsx)(U,{title:`原始资产记录`,value:p,collapsed:!0})]}):null})]})}var kt=[{label:`规划与依赖`,color:`#548df0`,relations:[`plans`,`depends_on`]},{label:`产出与证据`,color:`#24aa94`,relations:[`produces`,`supports`,`derives`,`reviews`]},{label:`线索与引用`,color:`#aa78e8`,relations:[`guides`,`informs`]},{label:`执行与记录`,color:`#dc913a`,relations:[`executes`,`records`,`summarizes`]},{label:`归档与其他`,color:`#8b9bb3`,relations:[]}],At=e=>e.boundary||[`receipt`,`observation`,`memory`].includes(e.kind);function jt(e,t){let n=t.get(e.source),r=t.get(e.target);return e.projection?4:n.kind===`step`&&n.step_id&&n.step_id===r.step_id?0:[`plans`,`depends_on`,`contains`,`archives`].includes(e.relation)?1:[`informs`,`supports`,`derives`].includes(e.relation)?3:2}function Mt(e,t,n){let r=[t],i=new Set;for(;r.length;){let t=r.pop();if(t===n)return!0;i.has(t)||(i.add(t),r.push(...e.get(t)))}return!1}function Nt(e){let t=new Map((e?.nodes||[]).map(e=>[e.id,e])),n=new Set,r=new Map,i=(e?.edges||[]).filter(e=>t.has(e.source)&&t.has(e.target)).map(e=>{let t=kt.find(t=>t.relations.includes(e.relation))||kt.at(-1);n.add(t);let i=JSON.stringify([e.source,e.target,e.relation,e.projection]),a=r.get(i)||0;return r.set(i,a+1),{...e,id:`edge:${i}:${a}`,color:t.color}}),a=i.map(e=>({edge:e,priority:jt(e,t)}));a.sort((e,n)=>e.priority-n.priority||Number(!!t.get(e.edge.source).boundary)-Number(!!t.get(n.edge.source).boundary)||e.edge.source.localeCompare(n.edge.source)||e.edge.target.localeCompare(n.edge.target)||(e.edge.relation||``).localeCompare(n.edge.relation||``));let o=me(a.map(e=>e.edge),e=>t.get(e).kind===`goal`),s=new Set([...o.parentEdges].map(e=>e.id)),c=new Set([...o.parentEdges].filter(e=>!At(t.get(e.target))).map(e=>e.id)),l=new Map([...t.keys()].map(e=>[e,new Set]));for(let[e,t]of o.parents)l.get(e).add(t);for(let{edge:e}of a)e.relation!==`depends_on`||e.projection||s.has(e.id)||t.get(e.target).kind===`goal`||Mt(l,e.source,e.target)||(l.get(e.target).add(e.source),s.add(e.id),At(t.get(e.target))||c.add(e.id));let u=new Set([...t.values()].filter(e=>!At(e)).map(e=>e.id));for(let e of i)c.has(e.id)&&(u.add(e.source),u.add(e.target));return{nodes:t,edges:i,upstream:l,layoutEdges:s,backbone:c,overview:u,legend:kt.filter(e=>n.has(e)),dense:t.size>20||i.length>t.size*1.5}}var Pt=27,Ft=118;function It({nodes:e,upstream:t}){let n=new Map,r=[],i=[...e.values()].some(e=>e.kind===`goal`),a=r=>{if(!n.has(r)){let o=t.get(r),s=o.size?Math.max(...[...o].map(a))+1:Number(i&&e.get(r).kind!==`goal`);n.set(r,s)}return n.get(r)};for(let t of e.keys()){let e=a(t);(r[e]??(r[e]=[])).push(t)}let o=new Map,s=Math.min(17,Math.max(3,Math.ceil(Math.sqrt(e.size*1.6)))),c=0;for(let n of r){let r=n.map(e=>{let n=t.get(e);return{id:e,center:n.size?[...n].reduce((e,t)=>e+o.get(t).y,0)/n.size:0}});r.sort((e,t)=>e.center-t.center);let i=r.map(e=>e.id),a=i.length>s?[i.filter(t=>!At(e.get(t))),i.filter(t=>At(e.get(t)))]:[i],l=0;for(let e of a){if(!e.length)continue;let t=Math.ceil(e.length/s),n=Math.ceil(e.length/t);for(let t=0;to.set(e,{x:c,y:(t-(r.length-1)/2)*Ft+i})),c+=266,l+=1}}c+=Pt}return o}function Lt(e,t){let n=It(e);if(!t.size)return n;let r=new Map([...t].filter(([t])=>e.nodes.has(t)));for(let[t,i]of n){if(r.has(t))continue;let n=[...e.upstream.get(t)].map(e=>r.get(e).x+266),a=Math.max(i.x,...n),o=[...r.values()].filter(e=>Math.abs(e.x-a)<133),s=i.y;for(let e=1;o.some(e=>Math.abs(e.y-s)1&&e.zoom(1).center(t))}function Vt(e,t){return[...[...e.nodes.values()].map(e=>({data:{id:e.id,kind:e.kind,color:Ue[e.kind]||`#86909c`},position:t.get(e.id)})),...e.edges.map(n=>{let r=t.get(n.source),i=t.get(n.target),a=i.x-r.x,o=[];return a!==0&&o.push(a>0?`forward`:`backward`),a>0&&e.layoutEdges.has(n.id)&&o.push(a>399?`long-flow`:`flow`),e.layoutEdges.has(n.id)||o.push(`cross-link`),{data:{...n,projection:n.projection||``,bend:i.y{u.current={model:e,selectedId:n,showAll:r,locate:i,onSelect:a},o.current?.sync()},[e,n,r,i,a,o]),(0,q.useEffect)(()=>{let e=c.current,n=l.current;if(!t){f([]);return}let r=!1,i,a,s,d,p,m,h,g,_=u.current.showAll;return f([]),ae(async()=>{let{default:e}=await import(`./cytoscape.esm-BPjn7guX.js`);return{default:e}},[]).then(({default:t})=>{if(r)return;i=t({container:e,style:Rt,layout:{name:`preset`,fit:!1},wheelSensitivity:.2,minZoom:.005,maxZoom:3,boxSelectionEnabled:!1,autounselectify:!0}),d=de(n,i);let c=()=>i.$id(u.current.selectedId)[0],l=()=>{cancelAnimationFrame(a),a=requestAnimationFrame(()=>f(G(i,{anchorId:p,allowCompact:e=>zt.has(e.data(`kind`))})))},v=()=>{let{model:e,selectedId:t,showAll:n,locate:r}=u.current,a=c(),o=a?.connectedEdges()||i.collection(),s=o.connectedNodes(),d=!n&&e.dense&&e.overview.size>0;if(i.batch(()=>{i.nodes().forEach(t=>{let n=t===a||s.has(t);t.toggleClass(`current`,t===a),t.toggleClass(`dim`,!(!a||n)),t.toggleClass(`hidden`,d&&!n&&!e.overview.has(t.id()))}),i.edges().forEach(t=>{let r=o.has(t);t.toggleClass(`related`,r),t.toggleClass(`dim`,!(!a||r)),t.toggleClass(`hidden`,!n&&e.dense&&!e.backbone.has(t.id())&&!r)})}),r&&r!==h&&a?.id()===r.id){h=r;let e=Math.max(i.zoom(),1);i.zoom(e).center(a)}else!a&&(n!==_||!t&&d&&g?.hidden())&&Bt(i);g=a,_=n,l()},y=(e=!1)=>{let{model:t}=u.current,n=!m;if(e||t!==m){let n=e?It(t):Lt(t,new Map(i.nodes().map(e=>[e.id(),e.position()])));m=t,p=[...t.nodes.values()].find(e=>e.kind===`goal`)?.id,i.json({elements:Vt(t,n)})}v(),(e||n&&!h)&&Bt(i)};o.current={sync:y,fit:()=>Bt(i),zoom:e=>fe(i,e),resetLayout:()=>y(!0)},y(),i.on(`pan zoom position`,l),i.on(`tap`,e=>{e.target===i?u.current.onSelect(``):e.target.isNode()&&u.current.onSelect(e.target.id())});let b=i.width(),x=i.height();s=new ResizeObserver(()=>{let e=b,t=x;i.resize();let n=i.width(),r=i.height();if(n===b&&r===x)return;i.panBy({x:(n-b)/2,y:(r-x)/2}),b=n,x=r;let a=c(),o=a?.renderedPosition();o&&(o.x<30||o.x>b-30||o.y<30||o.y>x-30)?i.center(a):!a&&(n{r||F(e,`图谱渲染失败`)}),()=>{r=!0,cancelAnimationFrame(a),s?.disconnect(),d?.(),i?.destroy(),o.current=null}},[t,o]),(0,$.jsxs)(`div`,{className:`assessment-graph-viewport`,role:`group`,"aria-label":`探索图`,children:[(0,$.jsx)(`div`,{ref:c,className:`assessment-graph-canvas`}),(0,$.jsx)(`div`,{ref:l,className:`graph-node-layer`,children:d.map(t=>{let r=e.nodes.get(t.id);if(!r)return null;let i=(r.title||r.id).replace(/\s+/g,` `).trim()||r.id;return(0,$.jsx)(K,{card:t,id:r.id,title:i,type:r.kind,category:we(s,r.kind),color:Ue[r.kind]||`#86909c`,factKey:r.id,boundary:r.boundary,selected:r.id===n,onSelect:a},r.id)})})]})}var{Text:Ut,Paragraph:Wt}=s,Gt=6;function Kt({task:e,t,onIntent:n,onGoIntents:r}){let i=e.steps||[],a=new Map(i.map(e=>[e.id,e.title||e.id])),o=i.filter(e=>e.status===`completed`).length,s=e.summary?.trim();return(0,$.jsxs)(`details`,{className:`assessment-graph-brief`,children:[(0,$.jsxs)(`summary`,{children:[(0,$.jsx)(Ut,{strong:!0,children:`目标拆解与阶段总结`}),(0,$.jsx)(Ut,{type:`tertiary`,size:`small`,className:`assessment-graph-brief-counts`,children:i.length?`${i.length} 个意图 · ${o} 个已完成`:`暂无意图`})]}),(0,$.jsxs)(`div`,{className:`assessment-graph-brief-grid`,children:[(0,$.jsxs)(`section`,{className:`assessment-graph-brief-content`,children:[(0,$.jsx)(Ut,{strong:!0,children:t(`deepAssessments.objective`,null,`目标`)}),(0,$.jsx)(Wt,{className:`assessment-pre`,children:e.objective||e.name||`—`}),i.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`ul`,{className:`assessment-graph-intents`,"aria-label":`目标拆解`,children:i.slice(-6).map(e=>{let r=(e.depends_on||[]).map(e=>a.get(e)||e);return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`div`,{className:`assessment-graph-intent-head`,children:[(0,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>n(e.id),title:a.get(e.id),children:a.get(e.id)}),e.status?(0,$.jsx)(u,{size:`small`,children:Q(t,e.status)}):null]}),r.length?(0,$.jsxs)(Ut,{size:`small`,type:`tertiary`,children:[`上游依赖 · `,r.slice(0,2).join(`、`),r.length>2?` 等 ${r.length} 项`:``]}):null]},e.id)})}),i.length>Gt?(0,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:r,children:`查看全部意图`}):null]}):(0,$.jsx)(Ut,{type:`tertiary`,size:`small`,children:`已有计划中的意图会显示在这里。`})]}),(0,$.jsxs)(`section`,{className:`assessment-graph-brief-content`,children:[(0,$.jsx)(Ut,{strong:!0,children:`阶段总结`}),(0,$.jsx)(Wt,{className:`assessment-pre assessment-graph-summary`,children:s||`当前还没有保存的阶段总结。`}),s&&e.updated_at?(0,$.jsxs)(Ut,{size:`small`,type:`tertiary`,children:[`测评更新于 `,D(e.updated_at)]}):null]})]})]})}var{Text:qt,Paragraph:Jt}=s;function Yt({id:e,task:t,reloadToken:n,onGoIntents:r,autoRefresh:i,onAutoRefreshChange:a,onRefreshTask:s,refreshPaused:l}){let d=O(),[p,m]=(0,q.useState)(`summary`),[h,g]=(0,q.useState)(``),[v,y]=(0,q.useState)(0),[x,S]=(0,q.useState)(``),[C,w]=(0,q.useState)(!1),[T,E]=(0,q.useState)(null),[k,j]=(0,q.useState)(null),[M,N]=(0,q.useState)([]),[I,R]=(0,q.useState)(0),[te,ne]=(0,q.useState)(!1),[V,re]=(0,q.useState)(0),[H,ae]=(0,q.useState)(!1),[oe,W]=(0,q.useState)(!1),[se,ce]=(0,q.useState)(null),[le,ue]=(0,q.useState)(!1),G=(0,q.useRef)(null),de=(0,q.useRef)(null),K=(0,q.useRef)(!1),fe=(0,q.useRef)(0),me=JSON.stringify([e,p,h,v]),J=P(async()=>{let t=await A.get(`/deep-assessments/${e}/graph`,{view:p,scope:h,offset:v,limit:80}),n=JSON.stringify(t),r=de.current;if(r?.key===me&&r.snapshot===n)return r;let i={key:me,snapshot:n,graph:t};return de.current=i,i},[e,p,h,v,n]),Y=J.data?.graph,X=(0,q.useMemo)(()=>Nt(Y),[Y]),Z=[...X.nodes.values()],he=X.overview.size?X.nodes.size-X.overview.size:0,ge=X.dense&&(he>0||X.edges.length>X.backbone.size),_e=(0,q.useCallback)(async(t,n={})=>{let{appendBody:r=!1,appendLinks:i=!1,center:a=!1}=n,o=++fe.current;if(S(t),a&&E({id:t}),!r&&!i&&(j(null),N([]),ce(null)),ue(!1),W(!!t),t)try{let n=await A.get(`/deep-assessments/${e}/graph/node`,{node_id:t,offset:r?V:0,links_offset:i?I:0});if(o!==fe.current)return;if(!i){let e=n?.node||null;j(t=>r&&t&&e&&t.id===e.id?{...e,body:`${t.body||``}${e.body||``}`}:e),re(Number(n?.next_offset)||0),ae(!!n?.has_more)}r||(N(e=>i?[...e,...n?.relations||[]]:n?.relations||[]),R(Number(n?.relations_next_offset)||0),ne(!!n?.relations_has_more))}catch(e){o===fe.current&&F(e,`读取节点失败`)}finally{o===fe.current&&W(!1)}},[e,V,I]),ve=async()=>{if(!k)return;let t=fe.current;ue(!0);try{let n=await A.get(`/deep-assessments/${e}/evidence-path`,{fact_id:k.id});t===fe.current&&ce(n)}catch(e){t===fe.current&&F(e,`读取证据路径失败`)}finally{t===fe.current&&ue(!1)}},ye=e=>Promise.all([J.reload(e),s(e)]);ie(async()=>{if(!(document.hidden||l||J.loading||K.current)){K.current=!0;try{await ye({silent:!0})}finally{K.current=!1}}},i?1e4:0);let be=(0,$.jsxs)(c,{wrap:!0,children:[(0,$.jsx)(b,{className:`assessment-view-options`,"aria-label":d(`deepAssessments.graphView.label`,null,`图谱视图`),type:`button`,value:p,options:[{value:`summary`,label:d(`deepAssessments.graphView.summary`,null,`主链路`)},{value:`full`,label:d(`deepAssessments.graphView.full`,null,`执行记录`)}],onChange:e=>{m(e.target.value),y(0)}}),(0,$.jsx)(f,{size:`small`,onClick:()=>{g(``),y(0)},disabled:!h&&v===0,children:`全图概览`}),(0,$.jsx)(f,{size:`small`,onClick:()=>ye(),loading:J.loading,children:`刷新`})]}),xe=Z.map(e=>({value:e.id,title:e.title||e.id,label:`${e.boundary?`引用 · `:``}${we(d,e.kind)} · ${Ve(e.title||e.id,40)}`}));return(0,$.jsx)(`div`,{className:`assessment-tab`,children:(0,$.jsxs)(B,{title:d(`deepAssessments.graph`,null,`探索图`),description:`点击节点查看原文与直接关联,放大可查看更多卡片内容。`,extra:be,children:[(0,$.jsx)(z,{error:J.error,onRetry:()=>ye()}),(0,$.jsx)(Kt,{task:t,t:d,onIntent:e=>_e(`step:${e}`,{center:!0}),onGoIntents:r}),(0,$.jsxs)(`div`,{className:`assessment-graph-meta`,children:[(0,$.jsxs)(qt,{type:`tertiary`,children:[`当前页节点 `,Y?.primary_count??Math.max(0,Z.length-1),` / `,Y?.total??0,` · `,`已折叠 `,Y?.folded??0,` · `,`隐藏明细 `,Y?.details_hidden??0,` · `,`跨页引用 `,Y?.boundary_total??0]}),h?(0,$.jsxs)(c,{children:[(0,$.jsxs)(u,{size:`small`,color:`blue`,children:[`已聚焦 `,h]}),(0,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>{g(``),y(0)},children:`返回全图`})]}):null,(0,$.jsxs)(c,{spacing:6,children:[(0,$.jsx)(qt,{size:`small`,type:`tertiary`,children:`自动刷新`}),(0,$.jsx)(_,{size:`small`,"aria-label":`自动刷新探索图`,checked:i,onChange:a})]})]}),J.loading&&!Y?(0,$.jsx)(qt,{type:`tertiary`,children:`正在读取图谱…`}):null,(0,$.jsxs)(`div`,{className:`assessment-graph-toolbar`,children:[(0,$.jsx)(ee,{"aria-label":`搜索图谱节点`,value:X.nodes.has(x)?x:void 0,onChange:e=>_e(e?String(e):``,{center:!!e}),optionList:xe,placeholder:`搜索并定位节点`,className:`assessment-graph-search`,filter:(e,t)=>`${t.label} ${t.title} ${t.value}`.toLowerCase().includes(e.toLowerCase().trim()),showClear:!0}),(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:v===0,onClick:()=>y(e=>Math.max(0,e-80)),children:d(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsxs)(qt,{type:`tertiary`,children:[`第 `,Math.floor(v/80)+1,` 页`]}),(0,$.jsx)(f,{size:`small`,disabled:!Y?.has_more,onClick:()=>y(e=>e+80),children:d(`deepAssessments.next`,null,`下一页`)})]})]}),Y&&Z.length===0&&!x?(0,$.jsx)(o,{title:`暂无图谱节点`,description:`开始测评后会生成目标、意图、事实与证据节点。`,style:{padding:48}}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`assessment-graph-layout${x?` with-details`:``}`,children:[(0,$.jsx)(Ht,{model:X,graphKey:J.data?.key,selectedId:x,showAll:C,locate:T,onSelect:_e,chartRef:G}),x?(0,$.jsx)(`div`,{className:`assessment-node-panel`,"aria-live":`polite`,children:(0,$.jsxs)(`div`,{className:`assessment-node-body`,children:[(0,$.jsxs)(`div`,{className:`assessment-node-head`,children:[(0,$.jsxs)(`div`,{className:`assessment-node-title`,children:[(0,$.jsx)(qt,{strong:!0,children:k?.title||X.nodes.get(x)?.title||x}),(0,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>_e(``),children:`关闭详情`})]}),(0,$.jsxs)(c,{spacing:4,children:[k?(0,$.jsx)(u,{size:`small`,color:`blue`,children:we(d,k.kind)}):null,k?.state?(0,$.jsx)(u,{size:`small`,color:`grey`,children:Te(d,k.state)}):null,k?.boundary?(0,$.jsx)(u,{size:`small`,color:`amber`,children:`跨页引用`}):null]})]}),oe?(0,$.jsx)(qt,{type:`tertiary`,children:`正在读取节点…`}):null,k?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Jt,{className:`assessment-pre assessment-node-content`,children:k.body||`—`}),H?(0,$.jsx)(f,{size:`small`,onClick:()=>_e(k.id,{appendBody:!0}),loading:oe,children:`继续读取原文`}):null,(0,$.jsx)(L,{columns:1,items:[{label:`节点 ID`,value:k.id},{label:`意图`,value:k.step_id||`—`},{label:`更新轮次`,value:k.updated_round??`—`},{label:`更新时间`,value:D(k.updated_at)}]}),M.length?(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(qt,{strong:!0,children:`关联节点`}),(0,$.jsx)(`div`,{className:`assessment-relations`,children:M.map((e,t)=>(0,$.jsxs)(f,{size:`small`,theme:`borderless`,onClick:()=>e.node?.id&&_e(e.node.id,{center:!0}),children:[e.direction===`upstream`?`上游`:`下游`,` · `,e.relation,` · `,Ve(e.node?.title,30)]},`${e.node?.id}-${t}`))}),te?(0,$.jsx)(f,{size:`small`,onClick:()=>_e(k.id,{appendLinks:!0}),loading:oe,children:`继续查看关联`}):null]}):null,k.kind===`fact`?(0,$.jsx)(f,{size:`small`,onClick:ve,loading:le,children:`查看证据路径`}):null,k.step_id?(0,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>{g(k.id),y(0)},children:`展开此节点分支`}):null,se?(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsxs)(qt,{strong:!0,children:[`证据路径 · `,se.title||se.root]}),(0,$.jsxs)(qt,{type:`tertiary`,size:`small`,children:[`节点 `,Array.isArray(se.nodes)?se.nodes.length:0,` · 未归属回执 `,se.unattributed_receipts||0]}),(0,$.jsx)(`div`,{className:`assessment-path-list`,children:(se.nodes||[]).map(e=>(0,$.jsxs)(`div`,{className:`assessment-path-node`,children:[(0,$.jsx)(u,{size:`small`,children:we(d,e.kind)}),(0,$.jsx)(qt,{ellipsis:{showTooltip:!0},children:e.title||e.id})]},e.id))}),(0,$.jsx)(U,{title:`证据路径原始数据`,value:se,collapsed:!0})]}):null,(0,$.jsx)(U,{title:`节点来源`,value:k.source||{},collapsed:!0})]}):null]})}):null]}),(0,$.jsxs)(`div`,{className:`assessment-graph-tools`,children:[(0,$.jsxs)(c,{wrap:!0,children:[(0,$.jsx)(f,{size:`small`,"aria-label":`缩小图谱`,disabled:!Z.length,onClick:()=>G.current?.zoom(.8),children:`−`}),(0,$.jsx)(f,{size:`small`,"aria-label":`放大图谱`,disabled:!Z.length,onClick:()=>G.current?.zoom(1.25),children:`+`}),(0,$.jsx)(f,{size:`small`,disabled:!Z.length,onClick:()=>G.current?.fit(),children:`适应画布`}),(0,$.jsx)(f,{size:`small`,disabled:!Z.length,onClick:()=>G.current?.resetLayout(),children:`重置布局`})]}),ge?(0,$.jsxs)(c,{wrap:!0,children:[(0,$.jsxs)(qt,{size:`small`,type:`tertiary`,children:[C?`全部 ${X.edges.length} 条连线`:`主干 ${X.backbone.size} / ${X.edges.length} 条连线`,!C&&he>0?` · 收起 ${he} 个明细节点`:null]}),(0,$.jsx)(f,{size:`small`,onClick:()=>w(e=>!e),children:C?`仅看主干`:`显示全部节点与连线`})]}):null]}),Z.length?(0,$.jsx)(`div`,{className:`assessment-graph-legend`,role:`group`,"aria-label":`节点图例`,children:[...new Set(Z.map(e=>e.kind))].map(e=>(0,$.jsxs)(`span`,{style:{"--graph-node-color":Ue[e]||`#86909c`},children:[(0,$.jsx)(pe,{type:e}),we(d,e)]},e))}):null,X.legend.length?(0,$.jsx)(`div`,{className:`assessment-graph-legend`,role:`group`,"aria-label":`连线图例`,children:X.legend.map(({label:e,color:t})=>(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`i`,{"aria-hidden":`true`,style:{backgroundColor:t}}),e]},e))}):null]})]})})}var{Text:Xt,Paragraph:Zt}=s,Qt={open:`待处理`,confirmed:`已确认`,fixed:`已修复`,false_positive:`误报`,ignored:`已忽略`};function $t({id:e,reloadToken:t}){let n=O(),[r,i]=(0,q.useState)(0),[a,o]=(0,q.useState)(null),[s,l]=(0,q.useState)(!1),d=P(()=>A.get(`/deep-assessments/${e}/vulnerabilities`,{limit:20,offset:r}),[e,r,t]),p=d.data,m=p?.vulnerabilities||[],h=async t=>{l(!0);try{let n=await A.get(`/deep-assessments/${e}/vulnerabilities/${t.id}`);o(n)}catch(e){F(e,`读取漏洞详情失败`)}finally{l(!1)}},g=a?.vulnerability||null,_=[{title:`漏洞标题`,dataIndex:`title`,render:(e,t)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(Xt,{strong:!0,ellipsis:{showTooltip:!0},children:e||t.id}),t.target?(0,$.jsx)(Xt,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:t.target}):null]})},{title:`严重级别`,dataIndex:`severity`,width:100,render:e=>(0,$.jsx)(te,{severity:e})},{title:n(`deepAssessments.status`,null,`状态`),dataIndex:`status`,width:100,render:e=>(0,$.jsx)(u,{size:`small`,children:Qt[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,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>h(t),loading:s,children:`详情`})}];return(0,$.jsxs)(`div`,{className:`assessment-tab`,children:[(0,$.jsxs)(B,{title:n(`deepAssessments.findings`,null,`关联漏洞`),description:`已登记的发现仍需要独立复现;报告记录不等于独立确认。`,extra:(0,$.jsx)(f,{size:`small`,onClick:()=>d.reload(),loading:d.loading,children:`刷新`}),children:[(0,$.jsx)(z,{error:d.error,onRetry:()=>d.reload()}),(0,$.jsx)(H,{columns:_,dataSource:m,rowKey:`id`,loading:d.loading,pagination:!1,onRow:e=>({onClick:()=>h(e),style:{cursor:`pointer`}}),emptyText:`暂未登记漏洞。`}),(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:r===0,onClick:()=>i(e=>Math.max(0,e-20)),children:n(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsxs)(Xt,{type:`tertiary`,children:[`共 `,p?.total??0,` 条`]}),(0,$.jsx)(f,{size:`small`,disabled:!p?.has_more,onClick:()=>i(e=>e+20),children:n(`deepAssessments.next`,null,`下一页`)})]})})]}),(0,$.jsx)(I,{visible:!!a,onCancel:()=>o(null),title:g?.title||`漏洞详情`,width:680,footer:null,children:g?(0,$.jsxs)(`div`,{className:`assessment-drawer`,children:[(0,$.jsx)(L,{columns:2,items:[{label:`严重级别`,value:(0,$.jsx)(te,{severity:g.severity})},{label:n(`deepAssessments.status`,null,`状态`),value:Qt[g.status]||g.status},{label:`类型`,value:g.type||`—`},{label:`目标`,value:g.target||`—`},{label:`来源意图`,value:a.step?.title||g.assessment_step_title||g.assessment_step_id||`—`},{label:`登记时间`,value:D(g.created_at)},{label:`漏洞 ID`,value:g.id}]}),[[`描述`,g.description],[`前置条件`,g.preconditions],[`复现步骤`,g.reproduction_steps],[`复现证据`,g.evidence],[`影响`,g.impact],[`修复建议`,g.recommendation],[`复核说明`,g.retest_notes]].filter(([,e])=>e).map(([e,t])=>(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(Xt,{strong:!0,children:e}),(0,$.jsx)(Zt,{className:`assessment-pre`,children:t})]},e)),a.step?(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(Xt,{strong:!0,children:`来源意图摘要`}),(0,$.jsx)(Zt,{className:`assessment-pre`,children:Ve(a.step.summary||a.step.instruction,600)})]}):null,(0,$.jsx)(U,{title:`原始漏洞记录`,value:a,collapsed:!0})]}):null})]})}var{Text:en,Paragraph:tn}=s,nn=[``,`has_evidence`,`missing`,`needs_review`];function rn({visible:e,id:t,onCancel:n,edit:r,onEdit:i,onSave:a,saving:o,saveError:s}){let l=O(),h=r?`编辑验收证据关联`:`证据来源`,[g,_]=(0,q.useState)(`fact`),[v,y]=(0,q.useState)(``),[b,x]=(0,q.useState)(0),C=ne(v,300);(0,q.useEffect)(()=>{x(0)},[g,C]);let w=P(()=>A.get(`/deep-assessments/${t}/acceptance/sources`,{kind:g,q:C,offset:b}),[t,g,C,b,e],{skip:!e}),T=w.data,E=T?.sources||[],k=g===`fact`?`fact_ids`:`receipt_ids`,j=(e,t)=>i(k,t?[...r[k],e]:r[k].filter(t=>t!==e)),M=[...r?[{key:`selected`,title:`关联`,width:80,render:(e,t)=>(0,$.jsx)(d,{checked:r[k].includes(t.id),disabled:o,"aria-label":`关联 ${t.title||t.id}`,onChange:e=>j(t.id,e.target.checked)})}]:[],{title:`证据`,dataIndex:`title`,render:(e,t)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(en,{ellipsis:{showTooltip:!0},children:e||t.id}),(0,$.jsx)(en,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:t.id})]})},{title:l(`deepAssessments.status`,null,`状态`),dataIndex:`state`,width:120,render:e=>(0,$.jsx)(u,{size:`small`,children:Te(l,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,$.jsxs)(I,{visible:e,title:h,"aria-label":h,onCancel:n,width:900,closable:!o,closeOnEsc:!o,maskClosable:!o,footer:r&&(0,$.jsxs)(`div`,{className:`assessment-form-actions`,children:[(0,$.jsx)(f,{onClick:n,disabled:o,children:`取消`}),(0,$.jsx)(f,{theme:`solid`,onClick:a,loading:o,disabled:o,children:`保存证据关联`})]}),children:[(0,$.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,$.jsx)(ee,{value:g,onChange:e=>_(e||`fact`),optionList:[{value:`fact`,label:`事实`},{value:`receipt`,label:`原始回执`}],style:{width:140}}),(0,$.jsx)(m,{prefix:(0,$.jsx)(S,{}),value:v,onChange:y,placeholder:`按名称、来源意图或 ID 搜索`,style:{width:280},showClear:!0}),(0,$.jsx)(en,{type:`tertiary`,children:`只有原始回执与 observed 事实可作为验收依据。`})]}),(0,$.jsx)(z,{error:w.error,onRetry:()=>w.reload()}),(0,$.jsx)(H,{columns:M,dataSource:E,rowKey:`id`,loading:w.loading,pagination:!1,emptyText:`没有匹配的证据记录。`}),(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:b===0,onClick:()=>x(e=>Math.max(0,e-20)),children:l(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsx)(en,{type:`tertiary`,children:E.length?`${b+1} - ${b+E.length}`:`0`}),(0,$.jsx)(f,{size:`small`,disabled:!T?.has_more,onClick:()=>x(e=>e+20),children:l(`deepAssessments.next`,null,`下一页`)})]})}),r&&(0,$.jsxs)(`div`,{className:`assessment-section`,children:[(0,$.jsx)(c,{wrap:!0,children:[`fact_ids`,`receipt_ids`].flatMap(e=>r[e].map(t=>(0,$.jsx)(u,{closable:!o,onClose:()=>i(e,r[e].filter(e=>e!==t)),children:(e===`fact_ids`?`事实`:`回执`)+` · `+(r.titles[t]||t)},e+t)))}),(0,$.jsx)(d,{checked:r.needs_review,disabled:o,onChange:e=>i(`needs_review`,e.target.checked),children:`标记待人工复核`}),(0,$.jsx)(p,{"aria-label":`复核说明`,placeholder:`复核说明`,value:r.review_note,disabled:o,onChange:e=>i(`review_note`,e)}),(0,$.jsx)(z,{error:s})]})]})}function an({id:e,criterion:t,canWrite:n,reloadToken:r}){let i=O(),[a,o]=(0,q.useState)(``),[s,l]=(0,q.useState)(null),[d,p]=(0,q.useState)(null),[m,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(null),v=(0,q.useRef)(null),b=(0,q.useRef)(0),[x,S]=(0,q.useState)(!1),[C,w]=(0,q.useState)(null),[T,E]=(0,q.useState)(!1),D=P(()=>A.get(`/deep-assessments/${e}/acceptance`),[e,r]),k=D.data?.rows||[],j=k.find(e=>e.number===s);(0,q.useEffect)(()=>{t&&v.current!==t&&k.some(e=>e.number===t)&&(v.current=t,b.current++,w(null),E(!1),l(t))},[t,k]);let M=(0,q.useMemo)(()=>{let e={has_evidence:0,missing:0,needs_review:0};return k.forEach(t=>{e[t.status]=(e[t.status]||0)+1}),e},[k]),R=k.length?Math.round(M.has_evidence/k.length*100):0,te=a?k.filter(e=>e.status===a):k,ne=[{id:`total`,label:`验收项`,value:k.length},{id:`has_evidence`,label:Oe(i,`has_evidence`),value:M.has_evidence||0},{id:`missing`,label:Oe(i,`missing`),value:M.missing||0},{id:`needs_review`,label:Oe(i,`needs_review`),value:M.needs_review||0}],V=e=>{b.current++,l(e?.number??null),w(null),E(!1)},re=()=>{j&&n&&(_(null),p({number:j.number,revision:j.revision,fact_ids:j.fact_ids||[],receipt_ids:j.receipt_ids||[],needs_review:!!j.needs_review,review_note:j.review_note||``,titles:Object.fromEntries([...j.facts||[],...j.receipts||[]].map(e=>[e.id,e.title]))}),S(!0))},ie=()=>{S(!1),p(null)},ae=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),_(null);try{await A.put(`/deep-assessments/${encodeURIComponent(e)}/acceptance/${t}`,{revision:r,fact_ids:i,receipt_ids:a,needs_review:o,review_note:s}),W(`验收证据关联已保存`),ie(),await D.reload()}catch(e){_(e.status===409?Error(`验收项已有修改。请取消编辑,重新打开后再保存。`):e),e.status===409&&D.reload()}finally{h(!1)}},oe=async()=>{if(!j)return;let t=++b.current;E(!0);try{let n=await A.get(`/deep-assessments/${e}/evidence-path`,{criterion:j.number});t===b.current&&w(n)}catch(e){t===b.current&&F(e,`读取证据路径失败`)}finally{t===b.current&&E(!1)}},se=[{title:`序号`,dataIndex:`number`,width:70},{title:`验收项`,dataIndex:`text`,render:(e,t)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(en,{ellipsis:{showTooltip:!0},children:e||`—`}),t.review_note?(0,$.jsxs)(en,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:[`复核说明:`,Ve(t.review_note,80)]}):null]})},{title:i(`deepAssessments.status`,null,`状态`),dataIndex:`status`,width:120,render:e=>(0,$.jsx)(u,{color:xe[e]||`grey`,shape:`circle`,children:Oe(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,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>V(t),children:`查看证据`})}];return(0,$.jsxs)(`div`,{className:`assessment-tab`,children:[(0,$.jsx)(N,{metrics:ne,columns:4}),(0,$.jsxs)(B,{title:i(`deepAssessments.acceptance`,null,`验收证据`),description:`状态反映证据关联情况,验收结论由审阅人核对;观察事实需有本意图的原始成功回执。`,extra:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,onClick:()=>D.reload(),loading:D.loading,children:`刷新`}),(0,$.jsx)(f,{size:`small`,onClick:()=>S(!0),children:`浏览证据来源`})]}),children:[(0,$.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,$.jsxs)(c,{children:[(0,$.jsx)(y,{percent:R,showInfo:!0,size:`small`,strokeWidth:8,style:{width:220}}),(0,$.jsxs)(en,{type:`tertiary`,children:[`已有证据覆盖 `,R,`%`]})]}),(0,$.jsx)(ee,{value:a,onChange:e=>o(e||``),optionList:nn.map(e=>({value:e,label:e?`${Oe(i,e)} · ${M[e]||0}`:`${i(`deepAssessments.all`,null,`全部`)} · ${k.length}`})),style:{width:190}})]}),(0,$.jsx)(z,{error:D.error,onRetry:()=>D.reload()}),(0,$.jsx)(H,{columns:se,dataSource:te,rowKey:`number`,loading:D.loading,pagination:!1,onRow:e=>({onClick:()=>V(e),style:{cursor:`pointer`}}),emptyText:`没有符合筛选条件的验收项。`})]}),(0,$.jsx)(at,{id:e,reloadToken:r},e),(0,$.jsx)(rn,{visible:x,id:e,onCancel:ie,edit:d,onEdit:(e,t)=>p(n=>({...n,[e]:t})),onSave:ae,saving:m,saveError:g}),(0,$.jsx)(I,{visible:!!j,onCancel:()=>V(null),title:j?`验收项 ${j.number}`:`验收项`,width:720,closeOnEsc:!x,footer:null,children:j?(0,$.jsxs)(`div`,{className:`assessment-drawer`,children:[(0,$.jsx)(L,{columns:1,items:[{label:`验收条件`,value:(0,$.jsx)(tn,{className:`assessment-pre`,children:j.text||`—`})},{label:i(`deepAssessments.status`,null,`状态`),value:(0,$.jsx)(u,{color:xe[j.status]||`grey`,children:Oe(i,j.status)})},{label:`复核说明`,value:j.review_note||`—`},{label:`人工标记待复核`,value:j.needs_review?`是`:`否`}]}),(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(en,{strong:!0,children:`关联事实`}),(0,$.jsx)(H,{columns:[{title:`事实`,dataIndex:`title`,render:(e,t)=>(0,$.jsx)(en,{ellipsis:{showTooltip:!0},children:e||t.id})},{title:`状态`,dataIndex:`state`,width:120,render:e=>Te(i,e)},{title:`回执引用`,dataIndex:`receipt_ids`,width:100,render:e=>(e||[]).length}],dataSource:j.facts||[],rowKey:`id`,pagination:!1,size:`small`,emptyText:`暂无关联事实。`})]}),(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(en,{strong:!0,children:`关联回执`}),(0,$.jsx)(H,{columns:[{title:`回执`,dataIndex:`title`,render:(e,t)=>(0,$.jsx)(en,{ellipsis:{showTooltip:!0},children:e||t.id})},{title:`状态`,dataIndex:`state`,width:120,render:e=>Te(i,e)},{title:`来源意图`,dataIndex:`step_id`,width:140}],dataSource:j.receipts||[],rowKey:`id`,pagination:!1,size:`small`,emptyText:`暂无关联回执。`})]}),(0,$.jsxs)(c,{children:[n&&(0,$.jsx)(f,{size:`small`,theme:`solid`,onClick:re,children:`编辑证据关联`}),(0,$.jsx)(f,{size:`small`,onClick:oe,loading:T,children:`读取局部证据图`}),(0,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>S(!0),children:`浏览证据来源`})]}),C?(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsxs)(en,{strong:!0,children:[`证据路径 · `,C.title||C.root]}),(0,$.jsx)(`div`,{className:`assessment-path-list`,children:(C.nodes||[]).map(e=>(0,$.jsxs)(`div`,{className:`assessment-path-node`,children:[(0,$.jsx)(u,{size:`small`,children:e.kind}),(0,$.jsx)(en,{ellipsis:{showTooltip:!0},children:e.title||e.id})]},e.id))}),(0,$.jsx)(U,{title:`证据路径原始数据`,value:C,collapsed:!0})]}):null]}):null})]})}var{Text:on,Paragraph:sn}=s,cn=[{value:`receipts`,label:`执行回执`},{value:`path`,label:`证据路径`},{value:`history`,label:`历次测评`,permission:`asset:read`},{value:`endpoints`,label:`端点证据`,permission:`asset:read`}],ln=2e5,un=e=>typeof e==`string`&&e.length>ln?`${e.slice(0,ln)}\n…(已截断 ${e.length-ln} 字符,完整内容请下载原始回执)`:He(e),dn=[{value:`criterion`,label:`验收项序号`},{value:`asset`,label:`资产 ID`},{value:`fact`,label:`事实 ID`}];function fn({id:e,criterion:t=0,factId:n=``,stepId:r=``,reloadToken:i}){let a=O(),{hasPermission:o}=k(),s=(0,q.useMemo)(()=>cn.filter(e=>!e.permission||o(e.permission)),[o]),[l,d]=(0,q.useState)(t>0||n?`path`:`receipts`),p=s.some(e=>e.value===l)?l:`receipts`,[h,g]=(0,q.useState)(0),[_,v]=(0,q.useState)(null),y=P(()=>A.get(`/deep-assessments/${e}/receipts`,{offset:h,step_id:r}),[e,h,r,i],{skip:p!==`receipts`}),[b,x]=(0,q.useState)(n?`fact`:`criterion`),[S,C]=(0,q.useState)(n||(t>0?String(t):``)),[w,E]=(0,q.useState)(null),[j,N]=(0,q.useState)({loading:!1,error:null}),[F,R]=(0,q.useState)(``),[te,ne]=(0,q.useState)(``),[V,re]=(0,q.useState)(null),[ie,ae]=(0,q.useState)({loading:!1,error:null}),[W,se]=(0,q.useState)(null),[ce,le]=(0,q.useState)({loading:!1,error:null});(0,q.useEffect)(()=>{g(0)},[p]);let ue=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 A.get(`/deep-assessments/${e}/evidence-path`,n);E(t),N({loading:!1,error:null})}catch(e){E(null),N({loading:!1,error:e})}};(0,q.useEffect)(()=>{(t>0||n)&&ue()},[e,t,n]);let G=async()=>{let t=F.trim();if(!t)M(`请填写资产 ID`);else{ae({loading:!0,error:null}),ne(t);try{let n=await A.get(`/deep-assessments/${e}/evidence-history`,{asset_id:t});re(n),ae({loading:!1,error:null})}catch(e){re(null),ae({loading:!1,error:e})}}},de=async()=>{let t=F.trim();if(!t)M(`请填写资产 ID`);else{le({loading:!0,error:null});try{let n=await A.get(`/deep-assessments/${e}/endpoint-evidence`,{asset_id:t});se(n),le({loading:!1,error:null})}catch(e){se(null),le({loading:!1,error:e})}}},K=y.data?.receipts||[],fe=[{title:a(`deepAssessments.status`,null,`状态`),dataIndex:`status`,width:110,render:e=>(0,$.jsx)(oe,{status:e,label:Q(a,e)})},{title:`工具`,dataIndex:`tool`,width:200,render:(e,t)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(on,{strong:!0,children:e||`—`}),(0,$.jsx)(on,{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,$.jsx)(on,{type:`tertiary`,ellipsis:{showTooltip:!0},children:e}):`—`},{title:`操作`,width:90,render:(e,t)=>(0,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>v(t),children:`查看`})}];return(0,$.jsxs)(`div`,{className:`assessment-tab`,children:[(0,$.jsxs)(B,{title:a(`deepAssessments.evidence`,null,`证据回执`),description:`回执是执行原始记录;路径与对照只读展示已保存的关联,不改变测评状态。`,extra:(0,$.jsxs)(c,{children:[(0,$.jsx)(ee,{value:p,onChange:e=>d(e||`receipts`),optionList:s.map(e=>({value:e.value,label:e.label})),style:{width:160}}),(0,$.jsx)(f,{size:`small`,onClick:()=>p===`receipts`?y.reload():void 0,disabled:p!==`receipts`,children:`刷新`})]}),children:[p===`receipts`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(z,{error:y.error,onRetry:()=>y.reload()}),(0,$.jsx)(H,{columns:fe,dataSource:K,rowKey:`id`,loading:y.loading,pagination:!1,onRow:e=>({onClick:()=>v(e),style:{cursor:`pointer`}}),emptyText:a(`deepAssessments.noRecords`,null,`暂无记录`)}),(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:h===0,onClick:()=>g(e=>Math.max(0,e-50)),children:a(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsxs)(on,{type:`tertiary`,children:[`共 `,K.length,` 条`]}),(0,$.jsx)(f,{size:`small`,disabled:!y.data?.has_more,onClick:()=>g(e=>e+50),children:a(`deepAssessments.next`,null,`下一页`)})]})})]}):null,p===`path`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,$.jsx)(ee,{value:b,onChange:e=>x(e||`criterion`),optionList:dn,style:{width:150}}),b===`criterion`?(0,$.jsx)(T,{value:S===``?void 0:Number(S),onChange:e=>C(e==null?``:String(e)),min:1,placeholder:`验收项序号`,style:{width:160}}):(0,$.jsx)(m,{value:S,onChange:C,placeholder:b===`asset`?`资产 ID`:`事实 ID`,style:{width:320},showClear:!0}),(0,$.jsx)(f,{size:`small`,theme:`solid`,type:`primary`,onClick:ue,loading:j.loading,children:`读取证据路径`})]}),(0,$.jsx)(z,{error:j.error,onRetry:ue}),w?(0,$.jsxs)($.Fragment,{children:[(0,$.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,$.jsx)(H,{columns:[{title:`类型`,dataIndex:`kind`,width:120,render:(e,t)=>we(a,e)||t.kind},{title:`标题`,dataIndex:`title`,render:(e,t)=>(0,$.jsx)(on,{ellipsis:{showTooltip:!0},children:e||t.id})},{title:`状态`,dataIndex:`state`,width:120,render:e=>Te(a,e)},{title:`来源意图`,dataIndex:`step_id`,width:150,render:e=>e||`—`}],dataSource:w.nodes||[],rowKey:`id`,pagination:!1,size:`small`,emptyText:`证据路径为空。`}),(0,$.jsxs)(on,{type:`tertiary`,size:`small`,children:[`关联边 `,Array.isArray(w.edges)?w.edges.length:0,` 条`]}),(0,$.jsx)(U,{title:`证据路径原始数据`,value:w,collapsed:!0})]}):null]}):null,p===`history`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,$.jsx)(m,{value:F,onChange:R,placeholder:`资产 ID`,style:{width:340},showClear:!0}),(0,$.jsx)(f,{size:`small`,theme:`solid`,type:`primary`,onClick:G,loading:ie.loading,children:`读取历次测评`})]}),(0,$.jsx)(z,{error:ie.error,onRetry:G}),V?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(on,{strong:!0,children:[V.title||V.asset_id,` · 本次测评`]}),(0,$.jsx)(L,{columns:3,items:[{label:`测评`,value:V.current?.name||`—`},{label:`状态`,value:Q(a,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,$.jsx)(H,{columns:[{title:`较早测评`,dataIndex:`name`,render:(e,t)=>(0,$.jsx)(on,{ellipsis:{showTooltip:!0},children:e||t.task_id})},{title:`状态`,dataIndex:`state`,width:110,render:e=>Q(a,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:te?`暂无可读的较早测评记录。`:`—`}),(0,$.jsx)(sn,{type:`tertiary`,className:`assessment-hint`,children:`差异基于两次已保存的证据记录;范围或项目口径不同时保留记录供人工对照。`}),(0,$.jsx)(U,{title:`历次测评原始数据`,value:V,collapsed:!0})]}):null]}):null,p===`endpoints`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,$.jsx)(m,{value:F,onChange:R,placeholder:`资产 ID`,style:{width:340},showClear:!0}),(0,$.jsx)(f,{size:`small`,theme:`solid`,type:`primary`,onClick:de,loading:ce.loading,children:`读取端点证据`})]}),(0,$.jsx)(z,{error:ce.error,onRetry:de}),W?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(L,{columns:4,items:[{label:`资产`,value:W.title||`—`},{label:`已有观察`,value:W.counts?.observed??0},{label:`待复核`,value:W.counts?.needs_review??0},{label:`缺证据`,value:W.counts?.missing??0}]}),(0,$.jsx)(H,{columns:[{title:`方法`,dataIndex:`method`,width:90},{title:`路径`,dataIndex:`path`,render:(e,t)=>(0,$.jsx)(on,{ellipsis:{showTooltip:!0},children:e||t.id})},{title:`名称`,dataIndex:`title`,width:220,render:e=>e||`—`},{title:`证据状态`,dataIndex:`status`,width:120,render:e=>(0,$.jsx)(u,{size:`small`,children:Te(a,e)})}],dataSource:W.endpoints||[],rowKey:`id`,pagination:!1,size:`small`,emptyText:`该资产暂无登记端点。`}),(0,$.jsx)(sn,{type:`tertiary`,className:`assessment-hint`,children:`端点状态来自明确关联的事实;服务级观察不会计入端点。端点关联的写入在攻击面图与漏洞复核流程中完成。`}),(0,$.jsx)(U,{title:`端点证据原始数据`,value:W,collapsed:!0})]}):null]}):null]}),(0,$.jsx)(I,{visible:!!_,onCancel:()=>v(null),title:_?`${_.tool||`回执`} · ${_.step_id||``}`:`回执详情`,width:720,footer:null,children:_?(0,$.jsxs)(`div`,{className:`assessment-drawer`,children:[(0,$.jsx)(L,{columns:2,items:[{label:a(`deepAssessments.status`,null,`状态`),value:(0,$.jsx)(oe,{status:_.status,label:Q(a,_.status)})},{label:`回执 ID`,value:_.id},{label:`来源意图`,value:_.step_id||`—`},{label:`执行 ID`,value:_.execution_id||`—`}]}),(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(on,{strong:!0,children:`调用参数`}),(0,$.jsx)(U,{title:`arguments`,value:un(_.arguments),collapsed:!1})]}),(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(on,{strong:!0,children:`调用结果`}),(0,$.jsx)(U,{title:`result`,value:un(_.result),collapsed:!0})]})]}):null})]})}function pn({id:e,task:t,reloadToken:n}){let r=O(),[i,a]=(0,q.useState)(!1),s=P(()=>A.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,$.jsx)(`div`,{className:`assessment-tab`,children:(0,$.jsxs)(B,{title:r(`deepAssessments.reportTitle`,null,`测评报告`),description:r(`deepAssessments.coverage.reportDescription`),extra:(0,$.jsxs)(c,{children:[(0,$.jsx)(V,{text:l,label:`复制 Markdown`}),(0,$.jsx)(f,{size:`small`,onClick:()=>s.reload(),loading:s.loading,children:`刷新`}),(0,$.jsx)(f,{size:`small`,theme:`solid`,type:`primary`,onClick:async()=>{a(!0);try{let t=await j(`/deep-assessments/${e}/report`,{filename:`assessment-${u}.md`});W(`已下载 ${t}`)}catch(e){F(e,`下载失败`)}finally{a(!1)}},loading:i,disabled:!l,children:r(`deepAssessments.report`,null,`下载报告`)})]}),children:[(0,$.jsx)(z,{error:s.error,onRetry:()=>s.reload()}),l?(0,$.jsx)(`div`,{className:`assessment-report`,children:(0,$.jsx)(R,{content:l})}):s.loading?null:(0,$.jsx)(o,{title:`报告为空`,description:`开始测评并保存进展后可生成报告。`,style:{padding:40}})]})})}function mn({id:e}){let[t,n]=(0,q.useState)(!1),[r,i]=(0,q.useState)(``),[a,o]=(0,q.useState)([]),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(null),m=(0,q.useRef)(null),h=(0,q.useRef)(null);(0,q.useEffect)(()=>()=>m.current?.abort(),[]),(0,q.useEffect)(()=>{t&&a.length&&h.current?.scrollIntoView({block:`nearest`})},[t,a]);let g=async()=>{let t=r.trim();if(!t||m.current)return;let n=new AbortController;m.current=n,l(!0),d(null);try{let r=a.slice(-3).map(e=>({question:e.question.slice(0,600),answer:e.answer.slice(0,1e3)})),s=await A.post(`/deep-assessments/${encodeURIComponent(e)}/question`,{question:t,history:r},{signal:n.signal,timeout:95e3});o(e=>[...e,{question:t,answer:s.answer,updated:s.updated_at}]),i(``)}catch(e){n.signal.aborted||d(e)}finally{m.current=null,l(!1)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(f,{onClick:()=>n(!0),children:`测评问答`}),(0,$.jsxs)(I,{visible:t,title:`测评问答`,onCancel:()=>n(!1),width:540,footer:(0,$.jsxs)(`form`,{className:`assessment-question-form`,onSubmit:e=>{e.preventDefault(),e.currentTarget.elements.namedItem(`question`)?.focus(),g()},children:[(0,$.jsx)(p,{name:`question`,"aria-label":`询问测评进展`,placeholder:`当前在做什么?有哪些方向正在等待处理?`,rows:3,maxLength:2e3,value:r,onChange:i,readOnly:c}),(0,$.jsx)(f,{htmlType:`submit`,theme:`solid`,loading:c,disabled:c||!r.trim(),children:`发送`})]}),children:[(0,$.jsx)(s.Paragraph,{type:`tertiary`,children:`只读问答。模型根据提问时的测评记录回答,离开本次测评页面后清空对话。`}),(0,$.jsxs)(`div`,{role:`log`,"aria-label":`问答记录`,"aria-live":`polite`,children:[a.map((e,t)=>(0,$.jsxs)(`section`,{className:`assessment-question-turn`,ref:t===a.length-1?h:void 0,children:[(0,$.jsx)(s.Text,{strong:!0,children:`你`}),(0,$.jsx)(`p`,{children:e.question}),(0,$.jsx)(s.Text,{strong:!0,children:`模型`}),(0,$.jsx)(`p`,{children:e.answer}),(0,$.jsxs)(s.Text,{size:`small`,type:`tertiary`,children:[`任务更新于 `,D(e.updated)]})]},t)),c?(0,$.jsx)(s.Text,{type:`tertiary`,children:`正在读取进展并生成回答…`}):null]}),(0,$.jsx)(z,{error:u,onRetry:g})]})]})}var{Text:hn}=s,gn=[{key:`overview`,i18n:`deepAssessments.overview`,fallback:`概览`},{key:`intents`,i18n:`deepAssessments.intents`,fallback:`意图`},{key:`facts`,i18n:`deepAssessments.facts`,fallback:`事实`},{key:`assets`,i18n:`deepAssessments.attackSurfaceGraph`,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 _n({id:e,tab:t,criterion:n,evidencePath:r,evidenceStepId:i,evidenceFactId:o,observation:s,onTabChange:u,onBack:d,onDeleted:m}){let h=O(),{hasPermission:_}=k(),v=P(()=>A.get(`/deep-assessments/${e}`),[e]),y=v.data?.task||null,b=y?.name?.trim(),x=y?.objective?.trim(),S=x===b||b?.length>1&&b.endsWith(`…`)&&x?.startsWith(b.slice(0,-1)),[C,T]=(0,q.useState)([]),[ee,j]=(0,q.useState)(null),[N,L]=(0,q.useState)(!0),[R,te]=(0,q.useState)(``),[B,ne]=(0,q.useState)(0),[V,H]=(0,q.useState)(``),[ae,U]=(0,q.useState)(``),[ce,le]=(0,q.useState)(``),ue=ae===`answer`?`答复并继续`:`补充线索或调整方向`,G=(0,q.useRef)(0),de=(0,q.useRef)(!1),K=_(Se),fe=_(Ce),pe=_(`agent:execute`),me=(0,q.useMemo)(()=>gn.filter(e=>!e.permission||_(e.permission)),[_]),J=me.some(e=>e.key===t)?t:`overview`,Y=(0,q.useCallback)(async(t=!1)=>{if((t||!de.current)&&(t||!document.hidden&&N)){de.current=!0;try{let n=await A.get(`/deep-assessments/${e}/events`,t?{latest:`true`}:{after:G.current}),r=Array.isArray(n?.events)?n.events:[];t?(T(r),G.current=r.length&&Number(r[r.length-1].id)||0):r.length&&(T(e=>[...e,...r].slice(-500)),G.current=Number(r[r.length-1].id)||G.current),j(null)}catch(e){t&&j(e)}finally{de.current=!1}}},[e,N]);(0,q.useEffect)(()=>(G.current=0,T([]),j(null),Y(!0),()=>{G.current=0}),[e]),(0,q.useEffect)(()=>{J===`overview`&&Y(!1)},[J]),ie(()=>{document.hidden||(Y(!1),R||v.reload({silent:!0}))},J===`overview`&&N?1e4:0);let X=async()=>{await v.reload(),ne(e=>e+1),Y(!0)},Z=async(t,n={})=>{if(y&&K){te(t);try{let r=await A.post(`/deep-assessments/${e}/control/${t}`,{revision:y.revision,...n});r?.task&&v.setData(e=>({...e,task:r.task})),r?.start_error?M(r.start_error):W(h(`deepAssessments.updated`,null,`已更新`)),ne(e=>e+1),Y(!0),v.reload({silent:!0})}catch(e){F(e,h(`deepAssessments.controlFailed`,null,`操作失败`)),v.reload()}finally{te(``)}}},he=async()=>{if(!y)return;let t=ce.trim();if(!t)M(`请填写补充内容`);else{te(`message`);try{let n=await A.post(`/deep-assessments/${e}/control/${ae}`,{revision:y.revision,message:t});n?.task&&v.setData(e=>({...e,task:n.task})),n?.start_error?M(n.start_error):W(ae===`answer`?`已答复并继续`:`已提交方向`),U(``),le(``),ne(e=>e+1),Y(!0),v.reload({silent:!0})}catch(e){F(e,`提交失败`)}finally{te(``)}}},ge=[y&&pe?(0,$.jsx)(mn,{id:e},e):null,(0,$.jsx)(f,{theme:`borderless`,onClick:d,children:`返回列表`},`back`),(0,$.jsx)(f,{icon:(0,$.jsx)(w,{}),onClick:X,loading:v.loading&&!R,children:`刷新`},`refresh`),(0,$.jsx)(f,{theme:`solid`,type:`primary`,disabled:!K||!pe||!!R||!Me(y),loading:R===`start`,onClick:()=>Z(`start`),children:h(`deepAssessments.start`,null,`开始 / 继续`)},`start`),(0,$.jsx)(f,{disabled:!K||!!R||!Ne(y),loading:R===`pause`,onClick:()=>Z(`pause`),children:h(`deepAssessments.pause`,null,`暂停`)},`pause`),(0,$.jsx)(f,{type:`danger`,disabled:!K||!!R||!Pe(y),loading:R===`cancel`,onClick:()=>Z(`cancel`),children:h(`deepAssessments.cancel`,null,`停止`)},`cancel`),Fe(y)?(0,$.jsx)(f,{disabled:!K||!pe||!!R,loading:R===`continue-stopped`,onClick:()=>Z(`continue-stopped`),children:`继续测评`},`continue`):null,(0,$.jsx)(f,{disabled:!K||!!R||(y?.archived?!Le(y):!Ie(y)),loading:R===`archive`||R===`restore`,onClick:()=>Z(y?.archived?`restore`:`archive`),children:y?.archived?`恢复到列表`:`归档`},`archive`),(0,$.jsx)(f,{type:`danger`,theme:`borderless`,icon:(0,$.jsx)(l,{}),disabled:!fe||!!R||!Re(y),onClick:()=>{y&&se({title:h(`deepAssessments.delete`,null,`删除`),content:`删除本条测评?关联执行会话仍保留。`,okText:h(`deepAssessments.delete`,null,`删除`),onOk:async()=>{try{await A.del(`/deep-assessments/${e}`),W(h(`deepAssessments.deleted`,null,`已删除`)),m?.()}catch(e){F(e,`删除失败`)}}})},children:h(`deepAssessments.delete`,null,`删除`)},`delete`)];return(0,$.jsxs)(`div`,{className:`assessment-page`,children:[(0,$.jsx)(re,{title:b||h(`deepAssessments.title`,null,`深度测评`),description:x&&!S?Ve(x,160):null,extra:ge,children:(0,$.jsxs)(c,{spacing:8,wrap:!0,className:`assessment-meta`,children:[y?(0,$.jsx)(oe,{status:y.status,label:Q(h,y.status)}):null,y?.archived?(0,$.jsx)(oe,{status:`archived`,label:Q(h,`archived`)}):null,y&&je(y)?(0,$.jsx)(oe,{status:`needs_review`,label:Q(h,`needs_review`)}):null,y?(0,$.jsxs)(hn,{type:`tertiary`,children:[`模型 `,v.data?.model_channel_name||y.model||`系统默认`]}):null,y?.role?(0,$.jsxs)(hn,{type:`tertiary`,children:[`角色 `,y.role]}):null,y?(0,$.jsxs)(hn,{type:`tertiary`,children:[`规划轮次 `,E(y.rounds||0)]}):null,y?(0,$.jsxs)(hn,{type:`tertiary`,children:[`累计 Token `,E(y.tokens_used||0)]}):null,y?.created_at?(0,$.jsxs)(hn,{type:`tertiary`,children:[`创建于 `,D(y.created_at)]}):null]})}),(0,$.jsx)(z,{error:v.error,onRetry:X}),y?.archived?(0,$.jsx)(a,{type:`info`,bordered:!0,closeIcon:null,description:`测评已归档。恢复到列表后才能继续控制、关联资产或补充方向。`}):null,y?.status===`blocked`?(0,$.jsx)(a,{type:`danger`,bordered:!0,closeIcon:null,className:`assessment-banner`,description:y.summary||`测评受阻,请查看运行记录定位原因;排除后可手动继续。`,children:(0,$.jsx)(f,{size:`small`,onClick:()=>u?.(`overview`),children:`查看运行记录`})}):null,y?.question?(0,$.jsx)(a,{type:`warning`,bordered:!0,closeIcon:null,className:`assessment-banner`,description:`执行需要人工确认:${y.question}`,children:(0,$.jsx)(f,{size:`small`,theme:`solid`,type:`primary`,disabled:!K||!pe,onClick:()=>{U(`answer`),le(``)},children:`答复并继续`})}):null,y&&!y.archived&&je(y)?(0,$.jsx)(a,{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,$.jsx)(f,{size:`small`,onClick:()=>{H(`uncertain`),u?.(`intents`)},children:`处理待核对`})}):null,(0,$.jsx)(g,{type:`line`,activeKey:J,onChange:e=>u?.(e),tabList:me.map(e=>({itemKey:e.key,tab:h(e.i18n,null,e.fallback)})),className:`assessment-tabs`,children:y?J===`overview`?(0,$.jsx)(dt,{task:y,reloadToken:B,canWrite:K&&pe,events:C,eventsError:ee,autoRefresh:N,onAutoRefreshChange:L,onRefreshEvents:()=>Y(!0),onGoTab:u,onGuidance:()=>{U(`guidance`),le(``)},onAnswer:()=>{U(`answer`),le(``)}}):J===`intents`?(0,$.jsx)(ht,{id:e,reloadToken:B,status:V,onStatusChange:H,archived:!!y.archived,taskStatus:y.status,revision:y.revision,onChanged:()=>{ne(e=>e+1),v.reload({silent:!0})}}):J===`facts`?(0,$.jsx)(vt,{id:e,reloadToken:B,task:y}):J===`assets`?(0,$.jsx)(Ot,{id:e,task:y,observation:s,reloadToken:B}):J===`graph`?(0,$.jsx)(Yt,{id:e,task:y,reloadToken:B,onGoIntents:()=>u?.(`intents`),autoRefresh:N,onAutoRefreshChange:L,onRefreshTask:v.reload,refreshPaused:!!R||v.loading}):J===`findings`?(0,$.jsx)($t,{id:e,task:y,reloadToken:B}):J===`acceptance`?(0,$.jsx)(an,{id:e,criterion:n,canWrite:K&&!y.archived,reloadToken:B}):J===`evidence`?(0,$.jsx)(fn,{id:e,criterion:r?n:0,factId:o,stepId:i,reloadToken:B},`${r}-${n}-${i}-${o}`):(0,$.jsx)(pn,{id:e,task:y,reloadToken:B}):null}),!y&&v.loading?(0,$.jsx)(`div`,{className:`assessment-loading`,children:`正在读取测评…`}):null,(0,$.jsxs)(I,{visible:!!ae,title:ue,"aria-label":ue,onCancel:()=>U(``),width:560,closable:R!==`message`,closeOnEsc:R!==`message`,maskClosable:R!==`message`,footer:(0,$.jsxs)(`div`,{className:`assessment-form-actions`,children:[(0,$.jsx)(f,{onClick:()=>U(``),disabled:R===`message`,children:`取消`}),(0,$.jsx)(f,{theme:`solid`,onClick:he,loading:R===`message`,disabled:R===`message`,children:`提交`})]}),children:[(0,$.jsx)(`p`,{className:`assessment-hint`,children:ae===`answer`?`答复会保存到人工补充并清除待答复状态,随后自动继续测评。`:`当前执行账号可以在测评运行时提交补充,下一轮规划会读取。`}),(0,$.jsx)(p,{value:ce,onChange:le,rows:5,maxLength:8e3,placeholder:`例如:优先验证登录接口的越权风险,并附上原始请求回执。`})]})]})}function vn(){let e=O(),{hasPermission:t}=k(),[n,r]=i(),a=n.get(`id`)||n.get(`assessment_id`)||``,s=n.get(`tab`)||`overview`,c=s===`evidence-path`?`evidence`:s,l=(0,q.useCallback)(e=>{let t=new URLSearchParams;t.set(`id`,e),t.set(`tab`,`overview`),r(t)},[r]),u=(0,q.useCallback)(e=>{let t=new URLSearchParams;t.set(`id`,a),t.set(`tab`,e),r(t,{replace:!0})},[a,r]),d=(0,q.useCallback)(()=>{r(new URLSearchParams,{replace:!1})},[r]);return t(`assessments:read`)?a?(0,$.jsx)(_n,{id:a,tab:c,criterion:Number(n.get(`criterion`))||0,evidencePath:s===`evidence-path`,evidenceStepId:n.get(`step_id`)||``,evidenceFactId:s===`evidence-path`&&n.get(`fact_id`)||``,observation:n.get(`observation`)||``,onTabChange:u,onBack:d,onDeleted:d},a):(0,$.jsx)(et,{onOpen:l}):(0,$.jsx)(`div`,{className:`assessment-page`,children:(0,$.jsx)(o,{title:e(`common.forbidden`,null,`当前账号没有访问该页面的权限`),description:`深度测评需要 assessments:read 权限,请联系管理员分配。`,style:{padding:64}})})}export{vn as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,u as r,y as i}from"./react-QV7DAAIx.js";import{B as a,E as o,G as s,I as c,Lt as l,N as u,P as d,R as f,S as p,U as m,W as h,c as g,d as _,ft as v,g as y,h as b,i as x,lt as S,s as C,ut as w,x as T,y as ee}from"./semi-65W_4I1v.js";import{D as E,E as D,F as O,I as k,L as A,R as j,S as M,_ as N,a as P,b as F,c as I,d as L,f as R,h as te,l as z,m as B,n as ne,o as V,p as re,r as ie,s as H,t as ae,u as U,v as oe,x as W,y as se}from"./index-C6SML8F9.js";import{n as ce,r as le}from"./model-channel-mQ6lfvSO.js";import{t as ue}from"./project-form-BPnSRCJ9.js";import{a as G,i as de,n as K,o as fe,r as pe,t as me}from"./graph-parents-i1hc3RVG.js";var q=e(t(),1),J={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:`已归档`},Y=[`running`,`pausing`,`cancelling`],X=[`completed`,`cancelled`],Z=[`needs_review`,`uncertain`,`cleanup_unconfirmed`],he={goal:`目标`,step:`探索意图`,observation:`观察`,receipt:`执行回执`,memory:`Pi 摘要`,digest:`历史归档`,guidance:`人工线索`,fact:`事实`,finding:`漏洞`},ge={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:`已有证据`},_e={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:`已确认核对`},ve={observed:`已观察`,inferred:`推断`},ye={observed:`green`,inferred:`amber`},be={has_evidence:`已有证据`,missing:`缺证据`,needs_review:`待人工复核`},xe={has_evidence:`green`,missing:`red`,needs_review:`amber`},Se=`assessments:write`,Ce=`assessments:delete`;function Q(e,t){return t?e(`deepAssessments.states.${t}`,null,J[t]||t):`—`}function we(e,t){return e(`deepAssessments.graphKinds.${t}`,null,he[t]||t||`节点`)}function Te(e,t){return t?e(`deepAssessments.graphStates.${t}`,null,ge[t]||Q(e,t)):`—`}function Ee(e,t){return t?e(`deepAssessments.workbench.events.${t}`,null,_e[t]||t):`事件`}function De(e,t){return e(`deepAssessments.confidence.${t}`,null,ve[t]||t||`—`)}function Oe(e,t){return e(`deepAssessments.acceptanceStatus.${t}`,null,be[t]||t||`—`)}function ke(e){return Y.includes(e?.status)}function Ae(e){return X.includes(e?.status)}function je(e){return e?Number(e.review_count)>0||Z.includes(e.status)?!0:(e.steps||[]).some(e=>Z.includes(e.status)):!1}function Me(e){return!!e&&!e.archived&&!Ae(e)&&!ke(e)&&!e.question&&e.status!==`waiting_input`}function Ne(e){return!!e&&!e.archived&&[`running`,`recovering`,`waiting_retry`,`waiting_progress`].includes(e.status)}function Pe(e){return!!e&&!e.archived&&!Ae(e)}function Fe(e){return!!e&&e.status===`cancelled`&&!e.archived}function Ie(e){return!!e&&!e.archived&&!ke(e)&&!je(e)&&![`recovering`,`needs_review`,`uncertain`,`cleanup_unconfirmed`].includes(e.status)}function Le(e){return!!e?.archived}function Re(e){return!!e&&!ke(e)}function ze(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 Be(e){let t=Math.floor(Number(e));if(!Number.isFinite(t)||t<0)return`—`;if(t<60)return`${t} 秒`;let n=`${Math.floor(t/60)%60} 分 ${t%60} 秒`;return t<3600?n:`${Math.floor(t/3600)} 小时 ${n}`}function Ve(e,t=80){let n=String(e??``);return n.length>t?`${n.slice(0,t)}…`:n}function He(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 Ue={goal:`#0066ff`,step:`#13a8a8`,fact:`#00b42a`,finding:`#f53f3f`,observation:`#722ed1`,receipt:`#86909c`,memory:`#ff7d00`,digest:`#c9cdd4`,guidance:`#eb2f96`},$=e(n(),1),We=[{value:``,label:`系统默认`},{value:`off`,label:`关闭审批`},{value:`human`,label:`人工审批`},{value:`audit_agent`,label:`审计代理审批`},{value:`review_edit`,label:`复核并允许编辑`}],Ge=[{value:``,label:`继承项目设置 / 默认不限速`},{value:`off`,label:`关闭限速提示(off)`},{value:`quiet`,label:`低噪串行(quiet · 2 RPS)`},{value:`balanced`,label:`均衡速率(balanced · 5 RPS)`},{value:`aggressive`,label:`维护窗口高吞吐(aggressive · 20 RPS)`}],Ke=`默认`;function qe(e){if(typeof e==`string`)return{name:e.trim(),icon:``};if(!e||typeof e!=`object`)return null;let t=String(e.name||``).trim();return t?{name:t,icon:String(e.icon||``).trim()}:null}function Je(e){return{value:e.name===Ke?``:e.name,name:e.name,icon:e.icon,label:(0,$.jsxs)(`span`,{className:`assessment-role-option`,children:[e.icon?(0,$.jsx)(`span`,{className:`assessment-role-icon`,"aria-hidden":`true`,children:e.icon}):null,(0,$.jsx)(`span`,{children:e.name})]})}}function Ye(e){let t=(Array.isArray(e)?e:[]).map(qe).filter(Boolean),n=t.filter(e=>e.name!==Ke),r=t.find(e=>e.name===Ke);return[...r?[Je(r)]:[],...n.map(Je)]}function Xe(e){if(!e||typeof e!=`object`)return``;let t=String(e.domain||e.ip||e.host||``).trim();if(!t)return``;let n=Number(e.port),r=t.includes(`:`)&&!t.startsWith(`[`);return Number.isFinite(n)&&n>0&&!r?`${t}:${n}`:t}function Ze({projectId:e}){let t=O(),n=P(()=>A.get(`/assets`,{project_id:e,page:1,page_size:6,sync_project_scope:1}),[e]),r=Number.isFinite(Number(n.data?.total))?Number(n.data.total):null,i=Number(n.data?.project_fact_count)||0,a=(Array.isArray(n.data?.assets)?n.data.assets:[]).map(Xe).filter(Boolean),o=t(`common.loading`,null,`加载中…`);return!n.loading&&n.error?o=`资产库暂时读不到。保存后仍使用该项目在资产库中的资产。`:!n.loading&&r===0?o=`这个项目的资产库还是空的。测评中新发现的目标会写进资产库,对话和批量任务也能看到。`:!n.loading&&r!=null&&(o=`资产范围是资产库里这个项目的 ${r} 个资产。对话、批量任务和这次测评用的是同一批,会自动交给模型。`),(0,$.jsxs)(x.Slot,{label:t(`deepAssessments.assetScope`,null,`资产范围`),children:[(0,$.jsx)(s.Text,{type:`tertiary`,role:`status`,children:o}),!n.loading&&!n.error&&a.length>0?(0,$.jsxs)(`div`,{className:`assessment-scope-preview`,children:[a.map(e=>(0,$.jsx)(u,{size:`small`,color:`light-blue`,children:e},e)),r>a.length?(0,$.jsx)(u,{size:`small`,color:`grey`,children:`+${r-a.length}`}):null]}):null,!n.loading&&!n.error&&r===0&&i>0?(0,$.jsx)(`div`,{className:`assessment-scope-hint`,children:(0,$.jsx)(s.Text,{type:`tertiary`,size:`small`,children:`该项目已有 ${i} 条对话沉淀事实,测评启动时会自动带入上下文。`})}):null]})}function Qe({visible:e,onCancel:t,onCreated:n}){let r=O(),i=r(`deepAssessments.create`,null,`新建测评`),{hasPermission:o}=k(),s=o(`project:read`)&&o(`project:write`),c=(0,q.useId)(),l=(0,q.useRef)(null),[u,d]=(0,q.useState)(null),[p,m]=(0,q.useState)(null),[g,_]=(0,q.useState)(!1),[y,b]=(0,q.useState)(!1),[S,C]=(0,q.useState)(``),w=g||y,T=(0,q.useCallback)(()=>{d(null),m(null),C(``),A.get(`/deep-assessments/options`).then(e=>d(e||{})).catch(e=>m(e))},[]);(0,q.useEffect)(()=>{e&&T()},[e,T]);let ee=e=>{C(e||``)},E=async e=>{if(!w){_(!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||``,noise_profile:e.noise_profile||``,concurrency:Number(e.concurrency)||2,auto_resume:e.auto_resume!==!1},i=await A.post(`/deep-assessments`,t);W(r(`deepAssessments.saved`,null,`已创建测评`)),n?.(i?.task)}catch(e){F(e,r(`deepAssessments.saveFailed`,null,`创建失败`))}finally{_(!1)}}},D=e=>{b(!1),e?.id&&(d(t=>({...t,projects:[e,...t?.projects||[]]})),l.current?.setValue(`project_id`,e.id),ee(e.id))},j=ce((u?.models||[]).map(e=>[e.id,e])),M=Ye(u?.roles),N=(u?.projects||[]).map(e=>({value:e.id,label:e.name||e.id}));return(0,$.jsxs)(I,{visible:e,title:i,"aria-label":i,onCancel:t,width:680,closable:!w,closeOnEsc:!w,maskClosable:!w,footer:(0,$.jsxs)(`div`,{className:`assessment-form-actions`,children:[(0,$.jsx)(f,{theme:`borderless`,onClick:t,disabled:w,children:r(`deepAssessments.close`,null,`关闭`)}),(0,$.jsx)(f,{htmlType:`submit`,form:c,theme:`solid`,type:`primary`,loading:g,disabled:w||!u&&!p,children:r(`deepAssessments.save`,null,`保存草稿`)})]}),children:[p?(0,$.jsxs)(`div`,{className:`assessment-error-block`,children:[(0,$.jsx)(z,{error:p}),(0,$.jsx)(f,{size:`small`,onClick:T,children:`重试`})]}):null,!u&&!p?(0,$.jsx)(`div`,{className:`assessment-loading`,children:(0,$.jsx)(h,{})}):(0,$.jsxs)(x,{id:c,getFormApi:e=>{l.current=e},initValues:{concurrency:2,auto_resume:!0,hitl_policy:``,noise_profile:``,role:``},labelPosition:`top`,autoScrollToError:!0,onSubmit:E,children:[(0,$.jsx)(x.Input,{field:`name`,label:r(`deepAssessments.name`,null,`测评名称`),maxLength:200,placeholder:`留空则取目标前 80 个字符`}),(0,$.jsx)(x.TextArea,{field:`objective`,label:r(`deepAssessments.objective`,null,`目标`),rows:3,maxLength:16e3,placeholder:`要达成的最终结果,例如:评估 example.com 对外接口的认证与越权风险并给出可复现证据。`,rules:[{required:!0,message:`请填写测评目标`}]}),(0,$.jsx)(x.TextArea,{field:`scope`,label:r(`deepAssessments.scopeOptional`,null,`补充限制与排除项(选填)`),rows:2,maxLength:16e3,placeholder:`例如:排除支付接口;不修改生产数据;不做压力测试。留空表示无额外限制。`}),(0,$.jsx)(x.TextArea,{field:`criteria`,label:r(`deepAssessments.criteriaOptional`,null,`验收条件(选填)`),rows:3,maxLength:8e3,placeholder:`每行一条验收条件,例如:确认的漏洞附复现步骤和原始证据。留空沿用目标。`}),(0,$.jsxs)(`div`,{className:`assessment-form-grid`,children:[(0,$.jsx)(x.Select,{field:`model`,label:r(`deepAssessments.model`,null,`模型渠道`),optionList:[{value:``,label:`系统默认`},...j],renderSelectedItem:le,style:{width:`100%`}}),(0,$.jsx)(x.Select,{field:`role`,label:r(`deepAssessments.role`,null,`角色`),optionList:M,renderSelectedItem:e=>(0,$.jsxs)(`span`,{className:`assessment-role-option`,children:[e.icon?(0,$.jsx)(`span`,{className:`assessment-role-icon`,"aria-hidden":`true`,children:e.icon}):null,(0,$.jsx)(`span`,{children:e.name})]}),style:{width:`100%`}}),(0,$.jsxs)(`div`,{className:`assessment-project-field`,children:[(0,$.jsx)(x.Select,{field:`project_id`,label:r(`deepAssessments.project`,null,`关联项目`),optionList:[{value:``,label:`不关联`},...N],style:{width:`100%`},onChange:ee}),s&&(0,$.jsx)(f,{icon:(0,$.jsx)(v,{"aria-hidden":!0}),theme:`light`,type:`primary`,disabled:g,onClick:()=>b(!0),children:r(`projects.newProject`,null,`新建项目`)})]}),S&&(0,$.jsx)(Ze,{projectId:S},S),(0,$.jsx)(x.InputNumber,{field:`concurrency`,label:r(`deepAssessments.concurrency`,null,`并行步骤`),min:1,max:4,style:{width:`100%`}})]}),(0,$.jsxs)(`div`,{className:`assessment-form-grid`,children:[(0,$.jsx)(x.Select,{field:`hitl_policy`,label:`人工审批策略`,optionList:We,style:{width:`100%`}}),(0,$.jsx)(x.Select,{field:`noise_profile`,label:r(`deepAssessments.noiseProfile`,null,`任务速率/噪音档位`),optionList:Ge,style:{width:`100%`}})]}),(0,$.jsx)(x.Switch,{field:`auto_resume`,label:r(`deepAssessments.autoResume`,null,`服务重启后自动恢复结果明确的步骤`)}),(0,$.jsx)(a,{type:`info`,bordered:!0,closeIcon:null,className:`assessment-form-note`,description:`创建后保存为草稿,需要手动点击“开始 / 继续”才会执行。关联项目后,资产范围直接使用资产库中的项目资产。`})]}),y&&(0,$.jsx)(ue,{visible:!0,onCancel:()=>b(!1),onSaved:D})]})}var{Text:$e}=s,et=[`draft`,`running`,`paused`,`blocked`,`failed`,`waiting_input`,`waiting_retry`,`recovering`,`uncertain`,`cleanup_unconfirmed`,`completed`,`cancelled`].map(e=>({value:e,label:J[e]}));function tt({onOpen:e}){let t=O(),{hasPermission:n}=k(),[r,i]=(0,q.useState)(``),[a,o]=(0,q.useState)(``),[s,u]=(0,q.useState)(!1),[d,p]=(0,q.useState)(0),[h,g]=(0,q.useState)(!1),[_,x]=(0,q.useState)({}),C=ne(r,300),T=n(Se),j=n(Ce),M=(0,q.useMemo)(()=>({q:C,status:a,limit:20,offset:d*20,archived:s?`true`:``}),[C,a,d,s]),N=P(()=>A.get(`/deep-assessments`,M),[M]),I=(0,q.useMemo)(()=>N.data?.tasks||[],[N.data]);(0,q.useEffect)(()=>{p(0)},[C,a,s]),(0,q.useEffect)(()=>{let e=I.filter(e=>!_[`${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&&x(e=>({...e,...r}))}),()=>{t=!0}},[I]);let L=e=>{se({title:t(`deepAssessments.delete`,null,`删除`),content:`删除测评「${e.name||e.id}」?关联执行会话仍保留。`,okText:t(`deepAssessments.delete`,null,`删除`),onOk:async()=>{try{await A.del(`/deep-assessments/${e.id}`),W(t(`deepAssessments.deleted`,null,`已删除`)),await N.reload()}catch(e){F(e,t(`deepAssessments.deleteFailed`,null,`删除失败`))}}})},R=[{title:t(`deepAssessments.name`,null,`测评名称`),dataIndex:`name`,width:260,render:(t,n)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(f,{theme:`borderless`,className:`assessment-link`,onClick:()=>e?.(n.id),children:t||n.id}),(0,$.jsx)($e,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:n.id})]})},{title:t(`deepAssessments.status`,null,`状态`),dataIndex:`status`,width:130,render:(e,n)=>(0,$.jsxs)(c,{spacing:4,children:[(0,$.jsx)(oe,{status:e,label:Q(t,e)}),n.archived?(0,$.jsx)(oe,{status:`archived`,label:Q(t,`archived`)}):null,je(n)?(0,$.jsx)(oe,{status:`needs_review`,label:Q(t,`needs_review`)}):null]})},{title:t(`deepAssessments.objective`,null,`目标`),dataIndex:`summary`,render:(e,t)=>{let n=_[`${t.id}:${t.updated_at}`]?.objective||e||`—`;return(0,$.jsx)($e,{ellipsis:{showTooltip:!0},className:`assessment-ellipsis`,children:n})}},{title:`进度`,width:190,align:`left`,render:(e,t)=>{let n=_[`${t.id}:${t.updated_at}`];if(!n)return(0,$.jsx)($e,{type:`tertiary`,children:`—`});let r=ze(n.counts,n.total);return(0,$.jsxs)(`div`,{className:`assessment-progress`,children:[(0,$.jsx)(y,{percent:r.percent,showInfo:!0,size:`small`,strokeWidth:6}),(0,$.jsxs)($e,{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,$.jsxs)(c,{spacing:4,children:[(0,$.jsx)(f,{theme:`borderless`,size:`small`,onClick:()=>e?.(r.id),children:`进入`}),(0,$.jsx)(f,{theme:`borderless`,type:`danger`,size:`small`,icon:(0,$.jsx)(l,{}),disabled:!j||!Re(r),onClick:()=>L(r),children:t(`deepAssessments.delete`,null,`删除`)})]})}];return(0,$.jsxs)(`div`,{className:`assessment-page`,children:[(0,$.jsx)(re,{title:t(`deepAssessments.title`,null,`深度测评`),description:t(`deepAssessments.subtitle`,null,`围绕一个目标持续探索,保存证据与进度,跨会话继续执行。`),extra:[(0,$.jsx)(f,{icon:(0,$.jsx)(w,{}),onClick:()=>N.reload(),loading:N.loading,children:t(`deepAssessments.refresh`,null,`刷新`)},`refresh`),(0,$.jsx)(f,{icon:(0,$.jsx)(v,{}),theme:`solid`,type:`primary`,disabled:!T,onClick:()=>g(!0),children:t(`deepAssessments.create`,null,`新建测评`)},`create`)]}),(0,$.jsx)(z,{error:N.error,onRetry:()=>N.reload()}),(0,$.jsxs)(B,{className:`assessment-list-card`,title:t(`deepAssessments.listTitle`,null,`测评列表`),extra:(0,$.jsx)(b,{className:`assessment-view-options`,"aria-label":t(`deepAssessments.archiveFilter`,null,`归档状态`),type:`button`,value:s?`archived`:`unarchived`,options:[{value:`unarchived`,label:t(`deepAssessments.unarchivedTasks`,null,`未归档`)},{value:`archived`,label:t(`deepAssessments.archivedTasks`,null,`已归档`)}],onChange:e=>u(e.target.value===`archived`)}),children:[(0,$.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,$.jsx)(m,{prefix:(0,$.jsx)(S,{}),value:r,onChange:i,placeholder:t(`deepAssessments.search`,null,`搜索测评名称`),style:{width:260},showClear:!0}),(0,$.jsx)(ee,{value:a,onChange:e=>o(e||``),optionList:[{value:``,label:t(`deepAssessments.all`,null,`全部状态`)},...et],style:{width:160}})]}),(0,$.jsx)(H,{columns:R,dataSource:I,rowKey:`id`,loading:N.loading,pagination:!1,emptyText:t(`deepAssessments.empty`,null,`暂无测评,先创建一个目标。`)}),(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:d===0,onClick:()=>p(e=>Math.max(0,e-1)),children:t(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsxs)($e,{type:`tertiary`,children:[`第 `,d+1,` 页`]}),(0,$.jsx)(f,{size:`small`,disabled:!N.data?.has_more,onClick:()=>p(e=>e+1),children:t(`deepAssessments.next`,null,`下一页`)})]})})]}),(0,$.jsx)(Qe,{visible:h,onCancel:()=>g(!1),onCreated:t=>{g(!1),N.reload(),t?.id&&e?.(t.id)}})]})}var{Paragraph:nt,Text:rt}=s,it=e=>JSON.stringify([e.surface,e.risk_area]),at=e=>JSON.stringify([e.kind,e.surface,e.risk_area,e.goal_id]);function ot({id:e,reloadToken:t,onView:n}){let r=O(),i=P(()=>A.get(`/deep-assessments/${e}/coverage`),[e,t]),a=i.data,o=!!n,s=(e,t)=>r(`deepAssessments.coverage.${e}`,t),l={title:s(`surface`),dataIndex:`surface`,width:180,render:e=>e||`—`},d={title:s(`riskArea`),dataIndex:`risk_area`,width:140},p=[l,d,{title:s(`outcome`),dataIndex:`outcome`,width:150,render:e=>s(`outcomes.${e}`)},{title:s(`evidence`),dataIndex:`evidence`,width:180,render:e=>e||`—`},{title:s(`reason`),dataIndex:`reason`,render:e=>e||`—`}],m=[l,d,{title:s(`gap`),dataIndex:`kind`,render:e=>s(`gapKinds.${e}`)},{title:s(`goalRef`),dataIndex:`goal_id`,width:160,render:e=>e||`—`}];return(0,$.jsxs)(B,{title:s(`title`),extra:o?(0,$.jsx)(f,{size:`small`,onClick:n,children:s(`view`)}):(0,$.jsx)(f,{size:`small`,onClick:()=>i.reload(),loading:i.loading,children:r(`common.refresh`)}),children:[(0,$.jsx)(z,{error:i.error,onRetry:()=>i.reload()}),i.loading&&!a?(0,$.jsx)(rt,{type:`tertiary`,children:s(`loading`)}):null,a?(0,$.jsxs)(`div`,{className:`assessment-tab assessment-coverage`,children:[(0,$.jsx)(nt,{children:s(`summary`,{records:a.records.length,gaps:a.gaps.length})}),a.records.length>0?(0,$.jsx)(c,{wrap:!0,children:Object.entries(a.counts).map(([e,t])=>(0,$.jsxs)(u,{children:[s(`outcomes.${e}`),` · `,t]},e))}):null,o?(0,$.jsxs)($.Fragment,{children:[a.goals.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(rt,{strong:!0,children:s(`goals`)}),(0,$.jsx)(`ul`,{children:a.goals.map(e=>(0,$.jsxs)(`li`,{children:[e.text,` `,e.risk_class?(0,$.jsx)(u,{size:`small`,children:e.risk_class}):null]},e.goal_id))})]}):null,a.constraints.length>0?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(rt,{strong:!0,children:s(`constraints`)}),(0,$.jsx)(`ul`,{children:a.constraints.map(e=>(0,$.jsxs)(`li`,{children:[(0,$.jsx)(u,{size:`small`,children:s(`constraintKinds.${e.kind}`)}),` `,e.text,` `,(0,$.jsxs)(rt,{type:`tertiary`,children:[`(`,e.origin,`)`]})]},e.constraint_id))})]}):null]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(H,{columns:p,dataSource:a.records,rowKey:it,pagination:a.records.length>10&&void 0,emptyText:s(`emptyRecords`)}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(rt,{strong:!0,children:s(`gaps`)}),(0,$.jsx)(nt,{type:`tertiary`,children:s(`gapHint`)}),(0,$.jsx)(H,{columns:m,dataSource:a.gaps,rowKey:at,pagination:a.gaps.length>10&&void 0,emptyText:s(`emptyGaps`)})]})]})]}):null]})}var{Text:st,Paragraph:ct}=s,lt={blocked:`error`,waiting_input:`warning`,completed:`success`,stop_requested:`warning`,retry:`warning`};function ut({startedAt:e,seconds:t}){let[n,r]=(0,q.useState)(Date.now);return ie(()=>r(Date.now()),1e3),Be(t+Math.max(0,Math.floor((n-e)/1e3)))}function dt({id:e}){let[t,n]=(0,q.useState)(null);return(0,q.useEffect)(()=>{let t=!1;return A.get(`/assets/collections/${e}`).then(e=>{t||n(e?.collection||null)}).catch(()=>{t||n(null)}),()=>{t=!0}},[e]),t?(0,$.jsxs)(st,{type:`tertiary`,children:[`本次范围 `,t.name,`:可见资产 `,t.member_count||0,` 个,已确认观察 `,t.observed||0,` 个。项目历史观察和逐项验收分开统计,缺证据的必验项保持未完成。`]}):null}function ft({task:e,canWrite:t,events:n,eventsError:r,autoRefresh:i,onAutoRefreshChange:a,onRefreshEvents:s,onGoTab:l,onGuidance:d,onAnswer:p,reloadToken:m}){let h=O(),g={};(e.steps||[]).forEach(e=>{g[e.status]=(g[e.status]||0)+1});let v=ze(g,(e.steps||[]).length),y=e.review_count||(e.steps||[]).filter(e=>[`uncertain`,`cleanup_unconfirmed`].includes(e.status)).length,b=e.active_seconds??0,x=ke(e)?Date.parse(e.run_started_at):NaN,S=Be(b);e.archived?S=`已归档`:Number.isFinite(x)&&(S=(0,$.jsx)(ut,{startedAt:x,seconds:b},x));let w=[{id:`status`,label:h(`deepAssessments.status`,null,`状态`),value:(0,$.jsx)(`span`,{className:`assessment-status-value`,children:Q(h,e.status)}),detail:S},{id:`progress`,label:`意图完成度`,value:`${v.percent}%`,detail:`${v.done} / ${v.total} 已结束`},{id:`rounds`,label:h(`deepAssessments.rounds`,null,`规划轮次`),value:E(e.rounds||0)},{id:`tokens`,label:h(`deepAssessments.tokens`,null,`累计 Token`),value:E(e.tokens_used||0)},{id:`review`,label:`待核对`,value:E(y),detail:y?`需要人工确认工具结果`:`无待核对记录`}],T=[{label:h(`deepAssessments.objective`,null,`目标`),value:(0,$.jsx)(ct,{className:`assessment-pre`,children:e.objective||`—`})},{label:h(`deepAssessments.scope`,null,`补充限制与排除项`),value:(0,$.jsx)(ct,{className:`assessment-pre`,children:e.scope&&e.scope.trim()!==(e.objective||``).trim()?e.scope:`—`})},{label:h(`deepAssessments.criteria`,null,`验收条件`),value:(0,$.jsx)(ct,{className:`assessment-pre`,children:e.criteria||`—`})},{label:h(`deepAssessments.strategy`,null,`最近规划路线`),value:(0,$.jsx)(ct,{className:`assessment-pre`,children:e.strategy||`—`})},{label:h(`deepAssessments.summary`,null,`当前结论 / 缺口`),value:(0,$.jsx)(ct,{className:`assessment-pre`,children:e.summary||`—`})}];e.question&&T.push({label:h(`deepAssessments.question`,null,`待补充信息`),value:(0,$.jsx)(ct,{className:`assessment-pre`,children:e.question})});let ee=n.slice().reverse().slice(0,120);return(0,$.jsxs)(`div`,{className:`assessment-tab`,children:[(0,$.jsx)(N,{metrics:w,columns:5}),e.collection_id?(0,$.jsx)(dt,{id:e.collection_id}):null,(0,$.jsxs)(B,{title:`目标与测评要求`,extra:(0,$.jsxs)(c,{children:[t&&!e.archived&&e.status!==`completed`&&e.status!==`cancelled`?(0,$.jsx)(f,{size:`small`,onClick:d,children:`补充方向`}):null,e.question?(0,$.jsx)(f,{size:`small`,theme:`solid`,type:`primary`,onClick:p,children:`答复`}):null,(0,$.jsx)(f,{size:`small`,onClick:()=>l?.(`intents`),children:`查看意图`})]}),children:[(0,$.jsx)(L,{items:T,columns:1}),(0,$.jsxs)(`div`,{className:`assessment-facts-row`,children:[(0,$.jsxs)(st,{type:`tertiary`,children:[`自动续跑:`,e.auto_resume?`已开启`:`已关闭`]}),(0,$.jsxs)(st,{type:`tertiary`,children:[`并行步骤:`,e.concurrency||`—`]}),(0,$.jsxs)(st,{type:`tertiary`,children:[`人工审批:`,e.hitl_policy||`系统默认`]}),e.noise_profile?(0,$.jsxs)(st,{type:`tertiary`,children:[`噪音档位:`,e.noise_profile]}):null,(0,$.jsxs)(st,{type:`tertiary`,children:[`最近更新:`,D(e.updated_at)]})]}),Array.isArray(e.guidance)&&e.guidance.length?(0,$.jsxs)(`div`,{className:`assessment-guidance`,children:[(0,$.jsx)(st,{strong:!0,children:`人工补充`}),e.guidance.map((e,t)=>(0,$.jsxs)(`div`,{className:`assessment-guidance-item`,children:[(0,$.jsxs)(st,{type:`tertiary`,children:[`#`,t+1]}),(0,$.jsx)(ct,{className:`assessment-pre`,children:e})]},`${t}-${e.slice(0,8)}`))]}):null,(0,$.jsx)(ct,{type:`tertiary`,className:`assessment-hint`,children:`打开页面不会自动启动任务;自动续跑只针对服务重启前的执行,草稿、手动暂停和待核对任务不会自动开始。`})]}),(0,$.jsx)(ot,{id:e.id,reloadToken:m,onView:()=>l?.(`acceptance`)},e.id),(0,$.jsxs)(B,{title:h(`deepAssessments.activity`,null,`运行记录`),description:`事件按时间倒序展示;运行中每 10 秒自动拉取,页面隐藏时跳过。`,extra:(0,$.jsxs)(c,{children:[(0,$.jsx)(st,{type:`tertiary`,size:`small`,children:`自动刷新`}),(0,$.jsx)(_,{size:`small`,checked:i,onChange:e=>a?.(!!e)}),(0,$.jsx)(f,{size:`small`,onClick:s,children:`立即刷新`})]}),children:[(0,$.jsx)(z,{error:r,onRetry:s}),ee.length===0?(0,$.jsx)(o,{title:`暂无运行记录`,description:`开始测评后,规划、执行与核对事件会显示在这里。`,style:{padding:32}}):(0,$.jsx)(`div`,{className:`assessment-timeline`,children:(0,$.jsx)(C,{children:ee.map(e=>(0,$.jsxs)(C.Item,{time:D(e.created_at),type:lt[e.kind]||`default`,children:[(0,$.jsxs)(`div`,{className:`assessment-event-head`,children:[(0,$.jsx)(st,{strong:!0,children:Ee(h,e.kind)}),e.step_id?(0,$.jsx)(u,{size:`small`,color:`grey`,children:e.step_id}):null]}),e.message?(0,$.jsx)(`div`,{className:`assessment-event-message`,children:e.message}):null]},e.id))})})]})]})}var{Text:pt,Paragraph:mt}=s,ht=[`running`,`pending`,`pausing`,`paused`,`completed`,`blocked`,`failed`,`uncertain`,`cleanup_unconfirmed`,`interrupted`,`retired`,`reconciled`];function gt({id:e,reloadToken:t,status:n,onStatusChange:r,onChanged:i,archived:a,taskStatus:o,revision:s}){let l=O(),{hasPermission:d}=k(),p=d(Se),[m,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(!1),[v,y]=(0,q.useState)(0),[b,x]=(0,q.useState)(null);(0,q.useEffect)(()=>{y(0)},[n]);let S=P(()=>A.get(`/deep-assessments/${e}/intents`,{status:n,offset:v}),[e,n,v,t]),C=S.data,w=C?.intents||[],T=C?.counts||{},D=async t=>{h(!0);try{await A.post(`/deep-assessments/${e}/control/intent-pause`,{revision:s,step_id:t.id}),W(`已提交此方向的暂停请求`)}catch(e){F(e,`暂停方向失败`)}finally{h(!1),x(null),i?.()}},j=t=>{se({title:`确认已核对`,content:`确认只解除本步骤的待核对状态,不会自动执行;原有进度和证据保留。`,okText:`确认已核对`,danger:!1,onOk:async()=>{_(!0);try{let n=await A.get(`/deep-assessments/${e}/steps/${t.id}`);await A.post(`/deep-assessments/${e}/control/reconcile`,{revision:n?.revision,step_id:t.id,reconciled:!0,cleanup_confirmed:!0}),W(`已记录核对,待核对列表已更新`),x(null),await S.reload(),i?.()}catch(e){F(e,`核对失败`)}finally{_(!1)}}})},M=(0,q.useMemo)(()=>{let e=ht.filter(e=>T[e]);return Object.keys(T).forEach(t=>{e.includes(t)||e.push(t)}),[{value:``,label:`${l(`deepAssessments.all`,null,`全部状态`)} · ${C?.total??0}`},...e.map(e=>({value:e,label:`${Q(l,e)} · ${T[e]}`}))]},[T,C?.total,l]),N=[{title:l(`deepAssessments.status`,null,`状态`),dataIndex:`status`,width:140,render:e=>(0,$.jsx)(oe,{status:e,label:Q(l,e)})},{title:`意图`,dataIndex:`title`,render:(e,t)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(pt,{ellipsis:{showTooltip:!0},children:e||t.id}),t.summary?(0,$.jsx)(pt,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:Ve(t.summary,120)}):null]})},{title:l(`deepAssessments.priority`,null,`优先级`),dataIndex:`priority`,width:90,render:e=>e||100},{title:l(`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,$.jsx)(pt,{type:`tertiary`,ellipsis:{showTooltip:!0},children:e}):`—`}];return(0,$.jsxs)(`div`,{className:`assessment-tab`,children:[(0,$.jsxs)(B,{title:l(`deepAssessments.plan`,null,`意图队列`),description:`队列按优先级排序;状态只表示执行情况,不代表漏洞或完成结论。`,extra:(0,$.jsx)(f,{size:`small`,onClick:()=>S.reload(),loading:S.loading,children:`刷新`}),children:[(0,$.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,$.jsx)(ee,{value:n,onChange:e=>r?.(e||``),optionList:M,style:{width:200}}),(0,$.jsxs)(pt,{type:`tertiary`,children:[`共 `,C?.total??0,` 条意图`]})]}),(0,$.jsx)(z,{error:S.error,onRetry:()=>S.reload()}),(0,$.jsx)(H,{columns:N,dataSource:w,rowKey:`id`,loading:S.loading,pagination:!1,onRow:e=>({onClick:()=>x(e),style:{cursor:`pointer`}}),emptyText:l(`deepAssessments.noIntents`,null,`暂无意图,开始测评后由规划器逐步生成探索方向。`)}),(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:v===0,onClick:()=>y(e=>Math.max(0,e-20)),children:l(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsx)(pt,{type:`tertiary`,children:w.length?`${v+1} - ${v+w.length}`:`0`}),(0,$.jsx)(f,{size:`small`,disabled:!C?.has_more,onClick:()=>y(e=>e+20),children:l(`deepAssessments.next`,null,`下一页`)})]})})]}),(0,$.jsx)(I,{visible:!!b,onCancel:()=>x(null),title:b?.title||`意图详情`,width:560,footer:null,children:b?(0,$.jsxs)(`div`,{className:`assessment-drawer`,children:[p&&!a&&o===`running`&&[`pending`,`running`].includes(b.status)&&(0,$.jsx)(f,{onClick:()=>D(b),loading:m,disabled:m,children:`暂停此方向`}),(0,$.jsx)(L,{columns:2,items:[{label:l(`deepAssessments.status`,null,`状态`),value:(0,$.jsx)(oe,{status:b.status,label:Q(l,b.status)})},{label:`意图 ID`,value:b.id},{label:l(`deepAssessments.priority`,null,`优先级`),value:b.priority||100},{label:`执行分段`,value:b.attempts||0},{label:`手动暂停`,value:b.user_paused?`是`:`否`},{label:`执行会话`,value:b.conversation_id||`—`},{label:l(`deepAssessments.assets`,null,`关联资产`),value:(b.asset_ids||[]).join(`, `)||`—`},{label:`来源节点`,value:(b.source_ids||[]).join(`, `)||`—`},{label:`前置意图`,value:(b.depends_on||[]).join(`, `)||`—`},{label:`证据引用`,value:(b.evidence||[]).join(`, `)||`—`}]}),(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(pt,{strong:!0,children:`执行说明`}),(0,$.jsx)(mt,{className:`assessment-pre`,children:b.instruction||`—`})]}),(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(pt,{strong:!0,children:`结果摘要`}),(0,$.jsx)(mt,{className:`assessment-pre`,children:b.summary||`—`})]}),b.last_progress?(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(pt,{strong:!0,children:`最近进展`}),(0,$.jsx)(mt,{className:`assessment-pre`,children:b.last_progress})]}):null,Array.isArray(b.guidance)&&b.guidance.length?(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(pt,{strong:!0,children:`定向补充`}),b.guidance.map((e,t)=>(0,$.jsxs)(`div`,{className:`assessment-guidance-item`,children:[(0,$.jsxs)(u,{size:`small`,color:`grey`,children:[`#`,t+1]}),(0,$.jsx)(mt,{className:`assessment-pre`,children:e})]},`${t}-${e.slice(0,8)}`))]}):null,[`uncertain`,`cleanup_unconfirmed`].includes(b.status)?(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(pt,{strong:!0,children:`待核对`}),(0,$.jsx)(mt,{type:`tertiary`,className:`assessment-hint`,children:`确认只解除本步骤的待核对状态,不会自动执行;仍有结果不明的调用时请保持停止。`}),(0,$.jsx)(f,{size:`small`,theme:`solid`,type:`primary`,disabled:!p||a,loading:g,onClick:()=>j(b),children:`确认已核对`})]}):null,b.conversations?.length?(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(pt,{strong:!0,children:`历史执行会话`}),(0,$.jsx)(mt,{className:`assessment-pre`,children:b.conversations.join(`
+`)})]}):null]}):null})]})}var{Text:_t,Paragraph:vt}=s;function yt({id:e,reloadToken:t}){let n=O(),[r,i]=(0,q.useState)(``),[a,o]=(0,q.useState)(0),[s,l]=(0,q.useState)(null);(0,q.useEffect)(()=>{o(0)},[r]);let d=P(()=>A.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,$.jsx)(u,{color:ye[e]||`grey`,shape:`circle`,children:De(n,e)})},{title:`摘要`,dataIndex:`summary`,render:(e,t)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(_t,{ellipsis:{showTooltip:!0},children:e||t.id}),t.body?(0,$.jsx)(_t,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:Ve(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,$.jsx)(_t,{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,$.jsxs)(`div`,{className:`assessment-tab`,children:[(0,$.jsxs)(B,{title:n(`deepAssessments.facts`,null,`事实`),description:`observed 表示有原始成功回执支撑;inferred 只是推断,不是证据。`,extra:(0,$.jsx)(f,{size:`small`,onClick:()=>d.reload(),loading:d.loading,children:`刷新`}),children:[(0,$.jsx)(`div`,{className:`assessment-toolbar`,children:(0,$.jsx)(ee,{value:r,onChange:e=>i(e||``),optionList:[{value:``,label:n(`deepAssessments.all`,null,`全部状态`)},{value:`observed`,label:De(n,`observed`)},{value:`inferred`,label:De(n,`inferred`)}],style:{width:160}})}),(0,$.jsx)(z,{error:d.error,onRetry:()=>d.reload()}),(0,$.jsx)(H,{columns:h,dataSource:m,rowKey:`id`,loading:d.loading,pagination:!1,onRow:e=>({onClick:()=>l(e),style:{cursor:`pointer`}}),emptyText:n(`deepAssessments.noFacts`,null,`暂无事实记录。`)}),(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:a===0,onClick:()=>o(e=>Math.max(0,e-20)),children:n(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsx)(_t,{type:`tertiary`,children:m.length?`${a+1} - ${a+m.length}`:`0`}),(0,$.jsx)(f,{size:`small`,disabled:!p?.has_more,onClick:()=>o(e=>e+20),children:n(`deepAssessments.next`,null,`下一页`)})]})})]}),(0,$.jsx)(I,{visible:!!s,onCancel:()=>l(null),title:`事实详情`,width:620,footer:null,children:s?(0,$.jsxs)(`div`,{className:`assessment-drawer`,children:[(0,$.jsx)(L,{columns:2,items:[{label:`置信度`,value:(0,$.jsx)(u,{color:ye[s.confidence]||`grey`,children:De(n,s.confidence)})},{label:`事实 ID`,value:s.id},{label:`来源意图`,value:s.step_id||`—`},{label:`时间`,value:D(s.created_at)},{label:n(`deepAssessments.assets`,null,`关联资产`),value:(s.asset_ids||[]).join(`, `)||`—`},{label:`证据回执`,value:(s.evidence||[]).join(`, `)||`—`},{label:`来源节点`,value:(s.source_ids||[]).join(`, `)||`—`}]}),(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(_t,{strong:!0,children:`摘要`}),(0,$.jsx)(vt,{className:`assessment-pre`,children:s.summary||`—`})]}),(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(_t,{strong:!0,children:`正文`}),(0,$.jsx)(vt,{className:`assessment-pre`,children:s.body||`—`})]}),(0,$.jsx)(U,{title:`原始记录`,value:s,collapsed:!0})]}):null})]})}var{Text:bt}=s,xt=20,St={cloud_access_key:`AK/SK`,credential:`账号凭据`,api_token:`API Key / Token`,other:`其他线索`};function Ct({endpoint:e,item:t,onClose:n,onSaved:r}){let i=O(),a=(0,q.useRef)(null),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(null),u=t.id?i(`deepAssessments.surface.edit`,null,`编辑线索`):i(`deepAssessments.surface.add`,null,`新增线索`),d=Object.entries(St).map(([e,t])=>({value:e,label:i(`deepAssessments.surface.kinds.${e}`,null,t)}));return(0,$.jsxs)(I,{visible:!0,title:u,"aria-label":u,onCancel:n,width:520,closable:!o,closeOnEsc:!o,maskClosable:!o,footer:(0,$.jsxs)(`div`,{className:`assessment-form-actions`,children:[(0,$.jsx)(f,{onClick:n,disabled:o,children:i(`common.cancel`,null,`取消`)}),(0,$.jsx)(f,{theme:`solid`,onClick:()=>a.current?.submitForm(),loading:o,disabled:o,children:i(`common.save`,null,`保存`)})]}),children:[(0,$.jsx)(bt,{type:`tertiary`,children:i(`deepAssessments.surface.redactionHint`,null,`请填写脱敏信息。密钥、密码和令牌原文应留在原证据位置。`)}),(0,$.jsxs)(x,{getFormApi:e=>{a.current=e},initValues:t,labelPosition:`top`,onSubmit:async({kind:n,summary:a=``,location:o=``,fact_id:c=``})=>{s(!0),l(null);let u={kind:n,summary:a.trim(),location:o.trim(),fact_id:c.trim()};try{t.id?await A.put(`${e}/${encodeURIComponent(t.id)}`,{...u,revision:t.revision}):await A.post(e,u),W(i(`deepAssessments.surface.saved`,null,`已保存攻击面线索`)),r()}catch(e){l(e)}finally{s(!1)}},disabled:o,children:[(0,$.jsx)(x.RadioGroup,{field:`kind`,label:i(`deepAssessments.surface.kind`,null,`类型`),options:d,direction:`vertical`,rules:[{required:!0,message:i(`deepAssessments.surface.kindRequired`,null,`请选择线索类型`)}]}),(0,$.jsx)(x.Input,{field:`summary`,label:i(`deepAssessments.surface.summary`,null,`脱敏摘要`),maxLength:120,rules:[{required:!0,whitespace:!0,message:i(`deepAssessments.surface.summaryRequired`,null,`请填写脱敏摘要`)}]}),(0,$.jsx)(x.Input,{field:`location`,label:i(`deepAssessments.surface.location`,null,`发现位置`),maxLength:240}),(0,$.jsx)(x.Input,{field:`fact_id`,label:i(`deepAssessments.surface.factId`,null,`关联事实 ID(选填)`),placeholder:i(`deepAssessments.surface.factHint`,null,`可从本次测评的事实详情复制`),maxLength:128}),(0,$.jsx)(z,{error:c})]})]})}function wt({id:e,canWrite:t,reloadToken:n}){let i=O(),[a,o]=(0,q.useState)(0),[s,l]=(0,q.useState)(null),d=`/deep-assessments/${e}/surface-items`,p=P(()=>A.get(d,{offset:a}),[d,a,n]),m=p.data?.items||[],h=[{title:i(`deepAssessments.surface.kind`,null,`类型`),dataIndex:`kind`,width:135,render:e=>(0,$.jsx)(u,{size:`small`,children:i(`deepAssessments.surface.kinds.${e}`,null,St[e]||e)})},{title:i(`deepAssessments.surface.summary`,null,`脱敏摘要`),dataIndex:`summary`},{title:i(`deepAssessments.surface.location`,null,`发现位置`),dataIndex:`location`,render:e=>e||`—`},{title:i(`deepAssessments.surface.evidence`,null,`证据`),dataIndex:`fact_id`,width:145,render:t=>t?(0,$.jsx)(r,{to:`?${new URLSearchParams({id:e,tab:`evidence-path`,fact_id:t})}`,children:i(`deepAssessments.surface.viewEvidence`,null,`查看证据路径`)}):`—`},...t?[{title:i(`deepAssessments.actions`,null,`操作`),key:`actions`,width:95,render:(e,t)=>(0,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>l(t),children:i(`deepAssessments.surface.edit`,null,`编辑线索`)})}]:[]];return(0,$.jsxs)(B,{title:i(`deepAssessments.surface.title`,null,`攻击面线索`),extra:t&&(0,$.jsx)(f,{icon:(0,$.jsx)(v,{}),size:`small`,onClick:()=>l({kind:`cloud_access_key`}),children:i(`deepAssessments.surface.add`,null,`新增线索`)}),children:[(0,$.jsx)(z,{error:p.error,onRetry:p.reload}),(0,$.jsx)(H,{columns:h,dataSource:m,rowKey:`id`,loading:p.loading,pagination:!1,emptyText:i(`deepAssessments.surface.empty`,null,`暂无攻击面线索。`)}),(a>0||p.data?.has_more)&&(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:a===0,onClick:()=>o(e=>e-xt),children:i(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsx)(f,{size:`small`,disabled:!p.data?.has_more,onClick:()=>o(e=>e+xt),children:i(`deepAssessments.next`,null,`下一页`)})]})}),s&&t&&(0,$.jsx)(Ct,{endpoint:d,item:s,onClose:()=>l(null),onSaved:()=>{l(null),a===0?p.reload():o(0)}})]})}var{Text:Tt}=s;function Et({visible:e,task:t,onCancel:n,onSaved:r}){O();let[i,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(1),[l,u]=(0,q.useState)([]),[d,p]=(0,q.useState)(!1),h=ne(i,300);(0,q.useEffect)(()=>{e&&(a(``),s(1),u([]))},[e]),(0,q.useEffect)(()=>{s(1)},[h]);let g=P(()=>A.get(`/assets`,{page:o,page_size:10,q:h,project_id:t?.project_id||``}),[o,h,t?.project_id,e],{skip:!e}),_=g.data?.assets||[];return(0,$.jsxs)(I,{visible:e,title:`关联共享资产`,"aria-label":`关联共享资产`,onCancel:n,width:760,closable:!d,closeOnEsc:!d,maskClosable:!d,footer:(0,$.jsxs)(`div`,{className:`assessment-form-actions`,children:[(0,$.jsx)(f,{onClick:n,disabled:d,children:`取消`}),(0,$.jsx)(f,{theme:`solid`,onClick:async()=>{if(l.length){p(!0);try{await A.post(`/deep-assessments/${t.id}/assets`,{asset_ids:l}),W(`已关联资产`),r?.()}catch(e){F(e,`关联资产失败`)}finally{p(!1)}}},loading:d,disabled:!l.length||d,children:`关联${l.length?` ${l.length} 项`:``}`})]}),children:[(0,$.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,$.jsx)(m,{prefix:(0,$.jsx)(S,{}),value:i,onChange:a,placeholder:`按地址、IP 或域名搜索`,style:{width:280},showClear:!0}),(0,$.jsx)(Tt,{type:`tertiary`,children:`仅显示当前账号可读、且与测评同项目的资产。`})]}),(0,$.jsx)(z,{error:g.error,onRetry:()=>g.reload()}),(0,$.jsx)(H,{columns:[{title:`资产`,dataIndex:`host`,render:(e,t)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(Tt,{strong:!0,children:e||t.ip||t.domain||t.id}),(0,$.jsx)(Tt,{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:_,rowKey:`id`,loading:g.loading,pagination:!1,rowSelection:{selectedRowKeys:l,onChange:e=>u((e||[]).map(String))},emptyText:`没有匹配的资产,可先在资产库登记。`}),(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:o<=1,onClick:()=>s(e=>Math.max(1,e-1)),children:`上一页`}),(0,$.jsxs)(Tt,{type:`tertiary`,children:[`第 `,o,` 页`]}),(0,$.jsx)(f,{size:`small`,disabled:!g.data?.total_pages||o>=g.data.total_pages,onClick:()=>s(e=>e+1),children:`下一页`})]})})]})}function Dt({taskId:e,assetId:t}){let n=P(()=>A.get(`/deep-assessments/${e}/assets`,{asset_id:t}),[e,t],{skip:!t}),r=n.data?.endpoints||[];return n.loading&&!n.data?(0,$.jsx)(Tt,{type:`tertiary`,children:`正在读取端点…`}):r.length?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Tt,{strong:!0,children:`端点`}),r.map(e=>(0,$.jsx)(`div`,{children:(0,$.jsxs)(Tt,{children:[e.method,` `,e.path]})},e.id))]}):(0,$.jsx)(Tt,{type:`tertiary`,children:`这个服务在资产库里还没有端点。任务中发现的路径会写到这里。`})}var Ot=new Set([`running`,`recovering`,`waiting_progress`,`waiting_retry`,`pausing`,`cancelling`]);function kt({id:e,task:t,observation:n,reloadToken:r}){let i=O(),{hasPermission:a}=k(),[o,s]=(0,q.useState)(0),[l,d]=(0,q.useState)(!1),[p,m]=(0,q.useState)(null),h=P(()=>A.get(`/deep-assessments/${e}/assets`,{offset:o,observation:n}),[e,o,n,r]);ie(()=>{document.hidden||h.reload({silent:!0})},Ot.has(t?.status)?1e4:0);let g=h.data,_=g?.assets||[],y=g?.coverage||{},b=y.linked??g?.total??0,x=y.with_observed_evidence??0,S=b?Math.round(x/b*100):0,C=a(Se),w=(0,q.useMemo)(()=>[{id:`linked`,label:`关联资产`,value:b},{id:`observed`,label:`已有观察证据`,value:x},{id:`coverage`,label:`观察覆盖率`,value:`${S}%`,detail:`只统计当前账号可读的关联资产`},{id:`nodes`,label:i(`deepAssessments.attackSurfaceGraphNodes`,null,`攻击面图节点`),value:g?.nodes?.length??0}],[i,b,x,S,g?.nodes?.length]);return(0,$.jsxs)(`div`,{className:`assessment-tab`,children:[(0,$.jsx)(N,{metrics:w,columns:4}),(0,$.jsx)(wt,{id:e,canWrite:C&&!t?.archived,reloadToken:r}),(0,$.jsxs)(B,{title:i(`deepAssessments.attackSurfaceGraph`,null,`攻击面图`),description:`与资产库是同一批记录。项目资产和任务中新发现的同范围服务、端点会自动出现。观察覆盖只统计已有事实的资产。`,extra:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{icon:(0,$.jsx)(v,{}),size:`small`,disabled:!C||t?.archived,onClick:()=>d(!0),children:`从资产库补充`}),(0,$.jsx)(f,{size:`small`,onClick:()=>h.reload(),loading:h.loading,children:`刷新`})]}),children:[(0,$.jsx)(z,{error:h.error,onRetry:()=>h.reload()}),(0,$.jsx)(H,{columns:[{title:`资产`,dataIndex:`host`,render:(e,t)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(Tt,{strong:!0,children:e||t.ip||t.domain||t.id}),(0,$.jsx)(Tt,{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,$.jsx)(u,{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:_,rowKey:`id`,loading:h.loading,pagination:!1,onRow:e=>({onClick:()=>m(e),style:{cursor:`pointer`}}),emptyText:`资产库里还没有纳入本次测评的资产。关联项目后会自动带入该项目的资产。`}),(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:o===0,onClick:()=>s(e=>Math.max(0,e-20)),children:i(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsxs)(Tt,{type:`tertiary`,children:[`共 `,g?.total??0,` 项`]}),(0,$.jsx)(f,{size:`small`,disabled:!g?.has_more,onClick:()=>s(e=>e+20),children:i(`deepAssessments.next`,null,`下一页`)})]})})]}),(0,$.jsx)(Et,{visible:l,task:t,onCancel:()=>d(!1),onSaved:()=>{d(!1),h.reload()}}),(0,$.jsx)(I,{visible:!!p,onCancel:()=>m(null),title:`资产详情`,width:560,footer:null,children:p?(0,$.jsxs)(`div`,{className:`assessment-drawer`,children:[(0,$.jsx)(L,{columns:2,items:[{label:`资产`,value:p.host||p.ip||p.id},{label:`ID`,value:p.id},{label:`IP`,value:p.ip||`—`},{label:`域名`,value:p.domain||`—`},{label:`端口`,value:p.port||`—`},{label:`协议`,value:p.protocol||`—`},{label:`项目`,value:p.project_name||`—`},{label:`状态`,value:p.status||`—`},{label:`风险`,value:p.risk_level||`—`},{label:`最近发现`,value:D(p.last_seen_at)}]}),(0,$.jsx)(Dt,{taskId:e,assetId:p.id}),(0,$.jsx)(U,{title:`原始资产记录`,value:p,collapsed:!0})]}):null})]})}var At=[{label:`规划与依赖`,color:`#548df0`,relations:[`plans`,`depends_on`]},{label:`产出与证据`,color:`#24aa94`,relations:[`produces`,`supports`,`derives`,`reviews`]},{label:`线索与引用`,color:`#aa78e8`,relations:[`guides`,`informs`]},{label:`执行与记录`,color:`#dc913a`,relations:[`executes`,`records`,`summarizes`]},{label:`归档与其他`,color:`#8b9bb3`,relations:[]}],jt=e=>e.boundary||[`receipt`,`observation`,`memory`].includes(e.kind);function Mt(e,t){let n=t.get(e.source),r=t.get(e.target);return e.projection?4:n.kind===`step`&&n.step_id&&n.step_id===r.step_id?0:[`plans`,`depends_on`,`contains`,`archives`].includes(e.relation)?1:[`informs`,`supports`,`derives`].includes(e.relation)?3:2}function Nt(e,t,n){let r=[t],i=new Set;for(;r.length;){let t=r.pop();if(t===n)return!0;i.has(t)||(i.add(t),r.push(...e.get(t)))}return!1}function Pt(e){let t=new Map((e?.nodes||[]).map(e=>[e.id,e])),n=new Set,r=new Map,i=(e?.edges||[]).filter(e=>t.has(e.source)&&t.has(e.target)).map(e=>{let t=At.find(t=>t.relations.includes(e.relation))||At.at(-1);n.add(t);let i=JSON.stringify([e.source,e.target,e.relation,e.projection]),a=r.get(i)||0;return r.set(i,a+1),{...e,id:`edge:${i}:${a}`,color:t.color}}),a=i.map(e=>({edge:e,priority:Mt(e,t)}));a.sort((e,n)=>e.priority-n.priority||Number(!!t.get(e.edge.source).boundary)-Number(!!t.get(n.edge.source).boundary)||e.edge.source.localeCompare(n.edge.source)||e.edge.target.localeCompare(n.edge.target)||(e.edge.relation||``).localeCompare(n.edge.relation||``));let o=me(a.map(e=>e.edge),e=>t.get(e).kind===`goal`),s=new Set([...o.parentEdges].map(e=>e.id)),c=new Set([...o.parentEdges].filter(e=>!jt(t.get(e.target))).map(e=>e.id)),l=new Map([...t.keys()].map(e=>[e,new Set]));for(let[e,t]of o.parents)l.get(e).add(t);for(let{edge:e}of a)e.relation!==`depends_on`||e.projection||s.has(e.id)||t.get(e.target).kind===`goal`||Nt(l,e.source,e.target)||(l.get(e.target).add(e.source),s.add(e.id),jt(t.get(e.target))||c.add(e.id));let u=new Set([...t.values()].filter(e=>!jt(e)).map(e=>e.id));for(let e of i)c.has(e.id)&&(u.add(e.source),u.add(e.target));return{nodes:t,edges:i,upstream:l,layoutEdges:s,backbone:c,overview:u,legend:At.filter(e=>n.has(e)),dense:t.size>20||i.length>t.size*1.5}}var Ft=27,It=118;function Lt({nodes:e,upstream:t}){let n=new Map,r=[],i=[...e.values()].some(e=>e.kind===`goal`),a=r=>{if(!n.has(r)){let o=t.get(r),s=o.size?Math.max(...[...o].map(a))+1:Number(i&&e.get(r).kind!==`goal`);n.set(r,s)}return n.get(r)};for(let t of e.keys()){let e=a(t);(r[e]??(r[e]=[])).push(t)}let o=new Map,s=Math.min(17,Math.max(3,Math.ceil(Math.sqrt(e.size*1.6)))),c=0;for(let n of r){let r=n.map(e=>{let n=t.get(e);return{id:e,center:n.size?[...n].reduce((e,t)=>e+o.get(t).y,0)/n.size:0}});r.sort((e,t)=>e.center-t.center);let i=r.map(e=>e.id),a=i.length>s?[i.filter(t=>!jt(e.get(t))),i.filter(t=>jt(e.get(t)))]:[i],l=0;for(let e of a){if(!e.length)continue;let t=Math.ceil(e.length/s),n=Math.ceil(e.length/t);for(let t=0;to.set(e,{x:c,y:(t-(r.length-1)/2)*It+i})),c+=266,l+=1}}c+=Ft}return o}function Rt(e,t){let n=Lt(e);if(!t.size)return n;let r=new Map([...t].filter(([t])=>e.nodes.has(t)));for(let[t,i]of n){if(r.has(t))continue;let n=[...e.upstream.get(t)].map(e=>r.get(e).x+266),a=Math.max(i.x,...n),o=[...r.values()].filter(e=>Math.abs(e.x-a)<133),s=i.y;for(let e=1;o.some(e=>Math.abs(e.y-s)1&&e.zoom(1).center(t))}function Ht(e,t){return[...[...e.nodes.values()].map(e=>({data:{id:e.id,kind:e.kind,color:Ue[e.kind]||`#86909c`},position:t.get(e.id)})),...e.edges.map(n=>{let r=t.get(n.source),i=t.get(n.target),a=i.x-r.x,o=[];return a!==0&&o.push(a>0?`forward`:`backward`),a>0&&e.layoutEdges.has(n.id)&&o.push(a>399?`long-flow`:`flow`),e.layoutEdges.has(n.id)||o.push(`cross-link`),{data:{...n,projection:n.projection||``,bend:i.y{u.current={model:e,selectedId:n,showAll:r,locate:i,onSelect:a},o.current?.sync()},[e,n,r,i,a,o]),(0,q.useEffect)(()=>{let e=c.current,n=l.current;if(!t){f([]);return}let r=!1,i,a,s,d,p,m,h,g,_=u.current.showAll;return f([]),ae(async()=>{let{default:e}=await import(`./cytoscape.esm-BPjn7guX.js`);return{default:e}},[]).then(({default:t})=>{if(r)return;i=t({container:e,style:zt,layout:{name:`preset`,fit:!1},wheelSensitivity:.2,minZoom:.005,maxZoom:3,boxSelectionEnabled:!1,autounselectify:!0}),d=de(n,i);let c=()=>i.$id(u.current.selectedId)[0],l=()=>{cancelAnimationFrame(a),a=requestAnimationFrame(()=>f(G(i,{anchorId:p,allowCompact:e=>Bt.has(e.data(`kind`))})))},v=()=>{let{model:e,selectedId:t,showAll:n,locate:r}=u.current,a=c(),o=a?.connectedEdges()||i.collection(),s=o.connectedNodes(),d=!n&&e.dense&&e.overview.size>0;if(i.batch(()=>{i.nodes().forEach(t=>{let n=t===a||s.has(t);t.toggleClass(`current`,t===a),t.toggleClass(`dim`,!(!a||n)),t.toggleClass(`hidden`,d&&!n&&!e.overview.has(t.id()))}),i.edges().forEach(t=>{let r=o.has(t);t.toggleClass(`related`,r),t.toggleClass(`dim`,!(!a||r)),t.toggleClass(`hidden`,!n&&e.dense&&!e.backbone.has(t.id())&&!r)})}),r&&r!==h&&a?.id()===r.id){h=r;let e=Math.max(i.zoom(),1);i.zoom(e).center(a)}else!a&&(n!==_||!t&&d&&g?.hidden())&&Vt(i);g=a,_=n,l()},y=(e=!1)=>{let{model:t}=u.current,n=!m;if(e||t!==m){let n=e?Lt(t):Rt(t,new Map(i.nodes().map(e=>[e.id(),e.position()])));m=t,p=[...t.nodes.values()].find(e=>e.kind===`goal`)?.id,i.json({elements:Ht(t,n)})}v(),(e||n&&!h)&&Vt(i)};o.current={sync:y,fit:()=>Vt(i),zoom:e=>fe(i,e),resetLayout:()=>y(!0)},y(),i.on(`pan zoom position`,l),i.on(`tap`,e=>{e.target===i?u.current.onSelect(``):e.target.isNode()&&u.current.onSelect(e.target.id())});let b=i.width(),x=i.height();s=new ResizeObserver(()=>{let e=b,t=x;i.resize();let n=i.width(),r=i.height();if(n===b&&r===x)return;i.panBy({x:(n-b)/2,y:(r-x)/2}),b=n,x=r;let a=c(),o=a?.renderedPosition();o&&(o.x<30||o.x>b-30||o.y<30||o.y>x-30)?i.center(a):!a&&(n{r||F(e,`图谱渲染失败`)}),()=>{r=!0,cancelAnimationFrame(a),s?.disconnect(),d?.(),i?.destroy(),o.current=null}},[t,o]),(0,$.jsxs)(`div`,{className:`assessment-graph-viewport`,role:`group`,"aria-label":`探索图`,children:[(0,$.jsx)(`div`,{ref:c,className:`assessment-graph-canvas`}),(0,$.jsx)(`div`,{ref:l,className:`graph-node-layer`,children:d.map(t=>{let r=e.nodes.get(t.id);if(!r)return null;let i=(r.title||r.id).replace(/\s+/g,` `).trim()||r.id;return(0,$.jsx)(K,{card:t,id:r.id,title:i,type:r.kind,category:we(s,r.kind),color:Ue[r.kind]||`#86909c`,factKey:r.id,boundary:r.boundary,selected:r.id===n,onSelect:a},r.id)})})]})}var{Text:Wt,Paragraph:Gt}=s,Kt=6;function qt({task:e,t,onIntent:n,onGoIntents:r}){let i=e.steps||[],a=new Map(i.map(e=>[e.id,e.title||e.id])),o=i.filter(e=>e.status===`completed`).length,s=e.summary?.trim();return(0,$.jsxs)(`details`,{className:`assessment-graph-brief`,children:[(0,$.jsxs)(`summary`,{children:[(0,$.jsx)(Wt,{strong:!0,children:`目标拆解与阶段总结`}),(0,$.jsx)(Wt,{type:`tertiary`,size:`small`,className:`assessment-graph-brief-counts`,children:i.length?`${i.length} 个意图 · ${o} 个已完成`:`暂无意图`})]}),(0,$.jsxs)(`div`,{className:`assessment-graph-brief-grid`,children:[(0,$.jsxs)(`section`,{className:`assessment-graph-brief-content`,children:[(0,$.jsx)(Wt,{strong:!0,children:t(`deepAssessments.objective`,null,`目标`)}),(0,$.jsx)(Gt,{className:`assessment-pre`,children:e.objective||e.name||`—`}),i.length?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`ul`,{className:`assessment-graph-intents`,"aria-label":`目标拆解`,children:i.slice(-6).map(e=>{let r=(e.depends_on||[]).map(e=>a.get(e)||e);return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`div`,{className:`assessment-graph-intent-head`,children:[(0,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>n(e.id),title:a.get(e.id),children:a.get(e.id)}),e.status?(0,$.jsx)(u,{size:`small`,children:Q(t,e.status)}):null]}),r.length?(0,$.jsxs)(Wt,{size:`small`,type:`tertiary`,children:[`上游依赖 · `,r.slice(0,2).join(`、`),r.length>2?` 等 ${r.length} 项`:``]}):null]},e.id)})}),i.length>Kt?(0,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:r,children:`查看全部意图`}):null]}):(0,$.jsx)(Wt,{type:`tertiary`,size:`small`,children:`已有计划中的意图会显示在这里。`})]}),(0,$.jsxs)(`section`,{className:`assessment-graph-brief-content`,children:[(0,$.jsx)(Wt,{strong:!0,children:`阶段总结`}),(0,$.jsx)(Gt,{className:`assessment-pre assessment-graph-summary`,children:s||`当前还没有保存的阶段总结。`}),s&&e.updated_at?(0,$.jsxs)(Wt,{size:`small`,type:`tertiary`,children:[`测评更新于 `,D(e.updated_at)]}):null]})]})]})}var{Text:Jt,Paragraph:Yt}=s;function Xt({id:e,task:t,reloadToken:n,onGoIntents:r,autoRefresh:i,onAutoRefreshChange:a,onRefreshTask:s,refreshPaused:l}){let d=O(),[p,m]=(0,q.useState)(`summary`),[h,g]=(0,q.useState)(``),[v,y]=(0,q.useState)(0),[x,S]=(0,q.useState)(``),[C,w]=(0,q.useState)(!1),[T,E]=(0,q.useState)(null),[k,j]=(0,q.useState)(null),[M,N]=(0,q.useState)([]),[I,R]=(0,q.useState)(0),[te,ne]=(0,q.useState)(!1),[V,re]=(0,q.useState)(0),[H,ae]=(0,q.useState)(!1),[oe,W]=(0,q.useState)(!1),[se,ce]=(0,q.useState)(null),[le,ue]=(0,q.useState)(!1),G=(0,q.useRef)(null),de=(0,q.useRef)(null),K=(0,q.useRef)(!1),fe=(0,q.useRef)(0),me=JSON.stringify([e,p,h,v]),J=P(async()=>{let t=await A.get(`/deep-assessments/${e}/graph`,{view:p,scope:h,offset:v,limit:80}),n=JSON.stringify(t),r=de.current;if(r?.key===me&&r.snapshot===n)return r;let i={key:me,snapshot:n,graph:t};return de.current=i,i},[e,p,h,v,n]),Y=J.data?.graph,X=(0,q.useMemo)(()=>Pt(Y),[Y]),Z=[...X.nodes.values()],he=X.overview.size?X.nodes.size-X.overview.size:0,ge=X.dense&&(he>0||X.edges.length>X.backbone.size),_e=(0,q.useCallback)(async(t,n={})=>{let{appendBody:r=!1,appendLinks:i=!1,center:a=!1}=n,o=++fe.current;if(S(t),a&&E({id:t}),!r&&!i&&(j(null),N([]),ce(null)),ue(!1),W(!!t),t)try{let n=await A.get(`/deep-assessments/${e}/graph/node`,{node_id:t,offset:r?V:0,links_offset:i?I:0});if(o!==fe.current)return;if(!i){let e=n?.node||null;j(t=>r&&t&&e&&t.id===e.id?{...e,body:`${t.body||``}${e.body||``}`}:e),re(Number(n?.next_offset)||0),ae(!!n?.has_more)}r||(N(e=>i?[...e,...n?.relations||[]]:n?.relations||[]),R(Number(n?.relations_next_offset)||0),ne(!!n?.relations_has_more))}catch(e){o===fe.current&&F(e,`读取节点失败`)}finally{o===fe.current&&W(!1)}},[e,V,I]),ve=async()=>{if(!k)return;let t=fe.current;ue(!0);try{let n=await A.get(`/deep-assessments/${e}/evidence-path`,{fact_id:k.id});t===fe.current&&ce(n)}catch(e){t===fe.current&&F(e,`读取证据路径失败`)}finally{t===fe.current&&ue(!1)}},ye=e=>Promise.all([J.reload(e),s(e)]);ie(async()=>{if(!(document.hidden||l||J.loading||K.current)){K.current=!0;try{await ye({silent:!0})}finally{K.current=!1}}},i?1e4:0);let be=(0,$.jsxs)(c,{wrap:!0,children:[(0,$.jsx)(b,{className:`assessment-view-options`,"aria-label":d(`deepAssessments.graphView.label`,null,`图谱视图`),type:`button`,value:p,options:[{value:`summary`,label:d(`deepAssessments.graphView.summary`,null,`主链路`)},{value:`full`,label:d(`deepAssessments.graphView.full`,null,`执行记录`)}],onChange:e=>{m(e.target.value),y(0)}}),(0,$.jsx)(f,{size:`small`,onClick:()=>{g(``),y(0)},disabled:!h&&v===0,children:`全图概览`}),(0,$.jsx)(f,{size:`small`,onClick:()=>ye(),loading:J.loading,children:`刷新`})]}),xe=Z.map(e=>({value:e.id,title:e.title||e.id,label:`${e.boundary?`引用 · `:``}${we(d,e.kind)} · ${Ve(e.title||e.id,40)}`}));return(0,$.jsx)(`div`,{className:`assessment-tab`,children:(0,$.jsxs)(B,{title:d(`deepAssessments.graph`,null,`探索图`),description:`点击节点查看原文与直接关联,放大可查看更多卡片内容。`,extra:be,children:[(0,$.jsx)(z,{error:J.error,onRetry:()=>ye()}),(0,$.jsx)(qt,{task:t,t:d,onIntent:e=>_e(`step:${e}`,{center:!0}),onGoIntents:r}),(0,$.jsxs)(`div`,{className:`assessment-graph-meta`,children:[(0,$.jsxs)(Jt,{type:`tertiary`,children:[`当前页节点 `,Y?.primary_count??Math.max(0,Z.length-1),` / `,Y?.total??0,` · `,`已折叠 `,Y?.folded??0,` · `,`隐藏明细 `,Y?.details_hidden??0,` · `,`跨页引用 `,Y?.boundary_total??0]}),h?(0,$.jsxs)(c,{children:[(0,$.jsxs)(u,{size:`small`,color:`blue`,children:[`已聚焦 `,h]}),(0,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>{g(``),y(0)},children:`返回全图`})]}):null,(0,$.jsxs)(c,{spacing:6,children:[(0,$.jsx)(Jt,{size:`small`,type:`tertiary`,children:`自动刷新`}),(0,$.jsx)(_,{size:`small`,"aria-label":`自动刷新探索图`,checked:i,onChange:a})]})]}),J.loading&&!Y?(0,$.jsx)(Jt,{type:`tertiary`,children:`正在读取图谱…`}):null,(0,$.jsxs)(`div`,{className:`assessment-graph-toolbar`,children:[(0,$.jsx)(ee,{"aria-label":`搜索图谱节点`,value:X.nodes.has(x)?x:void 0,onChange:e=>_e(e?String(e):``,{center:!!e}),optionList:xe,placeholder:`搜索并定位节点`,className:`assessment-graph-search`,filter:(e,t)=>`${t.label} ${t.title} ${t.value}`.toLowerCase().includes(e.toLowerCase().trim()),showClear:!0}),(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:v===0,onClick:()=>y(e=>Math.max(0,e-80)),children:d(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsxs)(Jt,{type:`tertiary`,children:[`第 `,Math.floor(v/80)+1,` 页`]}),(0,$.jsx)(f,{size:`small`,disabled:!Y?.has_more,onClick:()=>y(e=>e+80),children:d(`deepAssessments.next`,null,`下一页`)})]})]}),Y&&Z.length===0&&!x?(0,$.jsx)(o,{title:`暂无图谱节点`,description:`开始测评后会生成目标、意图、事实与证据节点。`,style:{padding:48}}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`assessment-graph-layout${x?` with-details`:``}`,children:[(0,$.jsx)(Ut,{model:X,graphKey:J.data?.key,selectedId:x,showAll:C,locate:T,onSelect:_e,chartRef:G}),x?(0,$.jsx)(`div`,{className:`assessment-node-panel`,"aria-live":`polite`,children:(0,$.jsxs)(`div`,{className:`assessment-node-body`,children:[(0,$.jsxs)(`div`,{className:`assessment-node-head`,children:[(0,$.jsxs)(`div`,{className:`assessment-node-title`,children:[(0,$.jsx)(Jt,{strong:!0,children:k?.title||X.nodes.get(x)?.title||x}),(0,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>_e(``),children:`关闭详情`})]}),(0,$.jsxs)(c,{spacing:4,children:[k?(0,$.jsx)(u,{size:`small`,color:`blue`,children:we(d,k.kind)}):null,k?.state?(0,$.jsx)(u,{size:`small`,color:`grey`,children:Te(d,k.state)}):null,k?.boundary?(0,$.jsx)(u,{size:`small`,color:`amber`,children:`跨页引用`}):null]})]}),oe?(0,$.jsx)(Jt,{type:`tertiary`,children:`正在读取节点…`}):null,k?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Yt,{className:`assessment-pre assessment-node-content`,children:k.body||`—`}),H?(0,$.jsx)(f,{size:`small`,onClick:()=>_e(k.id,{appendBody:!0}),loading:oe,children:`继续读取原文`}):null,(0,$.jsx)(L,{columns:1,items:[{label:`节点 ID`,value:k.id},{label:`意图`,value:k.step_id||`—`},{label:`更新轮次`,value:k.updated_round??`—`},{label:`更新时间`,value:D(k.updated_at)}]}),M.length?(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(Jt,{strong:!0,children:`关联节点`}),(0,$.jsx)(`div`,{className:`assessment-relations`,children:M.map((e,t)=>(0,$.jsxs)(f,{size:`small`,theme:`borderless`,onClick:()=>e.node?.id&&_e(e.node.id,{center:!0}),children:[e.direction===`upstream`?`上游`:`下游`,` · `,e.relation,` · `,Ve(e.node?.title,30)]},`${e.node?.id}-${t}`))}),te?(0,$.jsx)(f,{size:`small`,onClick:()=>_e(k.id,{appendLinks:!0}),loading:oe,children:`继续查看关联`}):null]}):null,k.kind===`fact`?(0,$.jsx)(f,{size:`small`,onClick:ve,loading:le,children:`查看证据路径`}):null,k.step_id?(0,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>{g(k.id),y(0)},children:`展开此节点分支`}):null,se?(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsxs)(Jt,{strong:!0,children:[`证据路径 · `,se.title||se.root]}),(0,$.jsxs)(Jt,{type:`tertiary`,size:`small`,children:[`节点 `,Array.isArray(se.nodes)?se.nodes.length:0,` · 未归属回执 `,se.unattributed_receipts||0]}),(0,$.jsx)(`div`,{className:`assessment-path-list`,children:(se.nodes||[]).map(e=>(0,$.jsxs)(`div`,{className:`assessment-path-node`,children:[(0,$.jsx)(u,{size:`small`,children:we(d,e.kind)}),(0,$.jsx)(Jt,{ellipsis:{showTooltip:!0},children:e.title||e.id})]},e.id))}),(0,$.jsx)(U,{title:`证据路径原始数据`,value:se,collapsed:!0})]}):null,(0,$.jsx)(U,{title:`节点来源`,value:k.source||{},collapsed:!0})]}):null]})}):null]}),(0,$.jsxs)(`div`,{className:`assessment-graph-tools`,children:[(0,$.jsxs)(c,{wrap:!0,children:[(0,$.jsx)(f,{size:`small`,"aria-label":`缩小图谱`,disabled:!Z.length,onClick:()=>G.current?.zoom(.8),children:`−`}),(0,$.jsx)(f,{size:`small`,"aria-label":`放大图谱`,disabled:!Z.length,onClick:()=>G.current?.zoom(1.25),children:`+`}),(0,$.jsx)(f,{size:`small`,disabled:!Z.length,onClick:()=>G.current?.fit(),children:`适应画布`}),(0,$.jsx)(f,{size:`small`,disabled:!Z.length,onClick:()=>G.current?.resetLayout(),children:`重置布局`})]}),ge?(0,$.jsxs)(c,{wrap:!0,children:[(0,$.jsxs)(Jt,{size:`small`,type:`tertiary`,children:[C?`全部 ${X.edges.length} 条连线`:`主干 ${X.backbone.size} / ${X.edges.length} 条连线`,!C&&he>0?` · 收起 ${he} 个明细节点`:null]}),(0,$.jsx)(f,{size:`small`,onClick:()=>w(e=>!e),children:C?`仅看主干`:`显示全部节点与连线`})]}):null]}),Z.length?(0,$.jsx)(`div`,{className:`assessment-graph-legend`,role:`group`,"aria-label":`节点图例`,children:[...new Set(Z.map(e=>e.kind))].map(e=>(0,$.jsxs)(`span`,{style:{"--graph-node-color":Ue[e]||`#86909c`},children:[(0,$.jsx)(pe,{type:e}),we(d,e)]},e))}):null,X.legend.length?(0,$.jsx)(`div`,{className:`assessment-graph-legend`,role:`group`,"aria-label":`连线图例`,children:X.legend.map(({label:e,color:t})=>(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`i`,{"aria-hidden":`true`,style:{backgroundColor:t}}),e]},e))}):null]})]})})}var{Text:Zt,Paragraph:Qt}=s,$t={open:`待处理`,confirmed:`已确认`,fixed:`已修复`,false_positive:`误报`,ignored:`已忽略`};function en({id:e,reloadToken:t}){let n=O(),[r,i]=(0,q.useState)(0),[a,o]=(0,q.useState)(null),[s,l]=(0,q.useState)(!1),d=P(()=>A.get(`/deep-assessments/${e}/vulnerabilities`,{limit:20,offset:r}),[e,r,t]),p=d.data,m=p?.vulnerabilities||[],h=async t=>{l(!0);try{let n=await A.get(`/deep-assessments/${e}/vulnerabilities/${t.id}`);o(n)}catch(e){F(e,`读取漏洞详情失败`)}finally{l(!1)}},g=a?.vulnerability||null,_=[{title:`漏洞标题`,dataIndex:`title`,render:(e,t)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(Zt,{strong:!0,ellipsis:{showTooltip:!0},children:e||t.id}),t.target?(0,$.jsx)(Zt,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:t.target}):null]})},{title:`严重级别`,dataIndex:`severity`,width:100,render:e=>(0,$.jsx)(te,{severity:e})},{title:n(`deepAssessments.status`,null,`状态`),dataIndex:`status`,width:100,render:e=>(0,$.jsx)(u,{size:`small`,children:$t[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,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>h(t),loading:s,children:`详情`})}];return(0,$.jsxs)(`div`,{className:`assessment-tab`,children:[(0,$.jsxs)(B,{title:n(`deepAssessments.findings`,null,`关联漏洞`),description:`已登记的发现仍需要独立复现;报告记录不等于独立确认。`,extra:(0,$.jsx)(f,{size:`small`,onClick:()=>d.reload(),loading:d.loading,children:`刷新`}),children:[(0,$.jsx)(z,{error:d.error,onRetry:()=>d.reload()}),(0,$.jsx)(H,{columns:_,dataSource:m,rowKey:`id`,loading:d.loading,pagination:!1,onRow:e=>({onClick:()=>h(e),style:{cursor:`pointer`}}),emptyText:`暂未登记漏洞。`}),(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:r===0,onClick:()=>i(e=>Math.max(0,e-20)),children:n(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsxs)(Zt,{type:`tertiary`,children:[`共 `,p?.total??0,` 条`]}),(0,$.jsx)(f,{size:`small`,disabled:!p?.has_more,onClick:()=>i(e=>e+20),children:n(`deepAssessments.next`,null,`下一页`)})]})})]}),(0,$.jsx)(I,{visible:!!a,onCancel:()=>o(null),title:g?.title||`漏洞详情`,width:680,footer:null,children:g?(0,$.jsxs)(`div`,{className:`assessment-drawer`,children:[(0,$.jsx)(L,{columns:2,items:[{label:`严重级别`,value:(0,$.jsx)(te,{severity:g.severity})},{label:n(`deepAssessments.status`,null,`状态`),value:$t[g.status]||g.status},{label:`类型`,value:g.type||`—`},{label:`目标`,value:g.target||`—`},{label:`来源意图`,value:a.step?.title||g.assessment_step_title||g.assessment_step_id||`—`},{label:`登记时间`,value:D(g.created_at)},{label:`漏洞 ID`,value:g.id}]}),[[`描述`,g.description],[`前置条件`,g.preconditions],[`复现步骤`,g.reproduction_steps],[`复现证据`,g.evidence],[`影响`,g.impact],[`修复建议`,g.recommendation],[`复核说明`,g.retest_notes]].filter(([,e])=>e).map(([e,t])=>(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(Zt,{strong:!0,children:e}),(0,$.jsx)(Qt,{className:`assessment-pre`,children:t})]},e)),a.step?(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(Zt,{strong:!0,children:`来源意图摘要`}),(0,$.jsx)(Qt,{className:`assessment-pre`,children:Ve(a.step.summary||a.step.instruction,600)})]}):null,(0,$.jsx)(U,{title:`原始漏洞记录`,value:a,collapsed:!0})]}):null})]})}var{Text:tn,Paragraph:nn}=s,rn=[``,`has_evidence`,`missing`,`needs_review`];function an({visible:e,id:t,onCancel:n,edit:r,onEdit:i,onSave:a,saving:o,saveError:s}){let l=O(),h=r?`编辑验收证据关联`:`证据来源`,[g,_]=(0,q.useState)(`fact`),[v,y]=(0,q.useState)(``),[b,x]=(0,q.useState)(0),C=ne(v,300);(0,q.useEffect)(()=>{x(0)},[g,C]);let w=P(()=>A.get(`/deep-assessments/${t}/acceptance/sources`,{kind:g,q:C,offset:b}),[t,g,C,b,e],{skip:!e}),T=w.data,E=T?.sources||[],k=g===`fact`?`fact_ids`:`receipt_ids`,j=(e,t)=>i(k,t?[...r[k],e]:r[k].filter(t=>t!==e)),M=[...r?[{key:`selected`,title:`关联`,width:80,render:(e,t)=>(0,$.jsx)(d,{checked:r[k].includes(t.id),disabled:o,"aria-label":`关联 ${t.title||t.id}`,onChange:e=>j(t.id,e.target.checked)})}]:[],{title:`证据`,dataIndex:`title`,render:(e,t)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(tn,{ellipsis:{showTooltip:!0},children:e||t.id}),(0,$.jsx)(tn,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:t.id})]})},{title:l(`deepAssessments.status`,null,`状态`),dataIndex:`state`,width:120,render:e=>(0,$.jsx)(u,{size:`small`,children:Te(l,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,$.jsxs)(I,{visible:e,title:h,"aria-label":h,onCancel:n,width:900,closable:!o,closeOnEsc:!o,maskClosable:!o,footer:r&&(0,$.jsxs)(`div`,{className:`assessment-form-actions`,children:[(0,$.jsx)(f,{onClick:n,disabled:o,children:`取消`}),(0,$.jsx)(f,{theme:`solid`,onClick:a,loading:o,disabled:o,children:`保存证据关联`})]}),children:[(0,$.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,$.jsx)(ee,{value:g,onChange:e=>_(e||`fact`),optionList:[{value:`fact`,label:`事实`},{value:`receipt`,label:`原始回执`}],style:{width:140}}),(0,$.jsx)(m,{prefix:(0,$.jsx)(S,{}),value:v,onChange:y,placeholder:`按名称、来源意图或 ID 搜索`,style:{width:280},showClear:!0}),(0,$.jsx)(tn,{type:`tertiary`,children:`只有原始回执与 observed 事实可作为验收依据。`})]}),(0,$.jsx)(z,{error:w.error,onRetry:()=>w.reload()}),(0,$.jsx)(H,{columns:M,dataSource:E,rowKey:`id`,loading:w.loading,pagination:!1,emptyText:`没有匹配的证据记录。`}),(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:b===0,onClick:()=>x(e=>Math.max(0,e-20)),children:l(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsx)(tn,{type:`tertiary`,children:E.length?`${b+1} - ${b+E.length}`:`0`}),(0,$.jsx)(f,{size:`small`,disabled:!T?.has_more,onClick:()=>x(e=>e+20),children:l(`deepAssessments.next`,null,`下一页`)})]})}),r&&(0,$.jsxs)(`div`,{className:`assessment-section`,children:[(0,$.jsx)(c,{wrap:!0,children:[`fact_ids`,`receipt_ids`].flatMap(e=>r[e].map(t=>(0,$.jsx)(u,{closable:!o,onClose:()=>i(e,r[e].filter(e=>e!==t)),children:(e===`fact_ids`?`事实`:`回执`)+` · `+(r.titles[t]||t)},e+t)))}),(0,$.jsx)(d,{checked:r.needs_review,disabled:o,onChange:e=>i(`needs_review`,e.target.checked),children:`标记待人工复核`}),(0,$.jsx)(p,{"aria-label":`复核说明`,placeholder:`复核说明`,value:r.review_note,disabled:o,onChange:e=>i(`review_note`,e)}),(0,$.jsx)(z,{error:s})]})]})}function on({id:e,criterion:t,canWrite:n,reloadToken:r}){let i=O(),[a,o]=(0,q.useState)(``),[s,l]=(0,q.useState)(null),[d,p]=(0,q.useState)(null),[m,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(null),v=(0,q.useRef)(null),b=(0,q.useRef)(0),[x,S]=(0,q.useState)(!1),[C,w]=(0,q.useState)(null),[T,E]=(0,q.useState)(!1),D=P(()=>A.get(`/deep-assessments/${e}/acceptance`),[e,r]),k=D.data?.rows||[],j=k.find(e=>e.number===s);(0,q.useEffect)(()=>{t&&v.current!==t&&k.some(e=>e.number===t)&&(v.current=t,b.current++,w(null),E(!1),l(t))},[t,k]);let M=(0,q.useMemo)(()=>{let e={has_evidence:0,missing:0,needs_review:0};return k.forEach(t=>{e[t.status]=(e[t.status]||0)+1}),e},[k]),R=k.length?Math.round(M.has_evidence/k.length*100):0,te=a?k.filter(e=>e.status===a):k,ne=[{id:`total`,label:`验收项`,value:k.length},{id:`has_evidence`,label:Oe(i,`has_evidence`),value:M.has_evidence||0},{id:`missing`,label:Oe(i,`missing`),value:M.missing||0},{id:`needs_review`,label:Oe(i,`needs_review`),value:M.needs_review||0}],V=e=>{b.current++,l(e?.number??null),w(null),E(!1)},re=()=>{j&&n&&(_(null),p({number:j.number,revision:j.revision,fact_ids:j.fact_ids||[],receipt_ids:j.receipt_ids||[],needs_review:!!j.needs_review,review_note:j.review_note||``,titles:Object.fromEntries([...j.facts||[],...j.receipts||[]].map(e=>[e.id,e.title]))}),S(!0))},ie=()=>{S(!1),p(null)},ae=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),_(null);try{await A.put(`/deep-assessments/${encodeURIComponent(e)}/acceptance/${t}`,{revision:r,fact_ids:i,receipt_ids:a,needs_review:o,review_note:s}),W(`验收证据关联已保存`),ie(),await D.reload()}catch(e){_(e.status===409?Error(`验收项已有修改。请取消编辑,重新打开后再保存。`):e),e.status===409&&D.reload()}finally{h(!1)}},oe=async()=>{if(!j)return;let t=++b.current;E(!0);try{let n=await A.get(`/deep-assessments/${e}/evidence-path`,{criterion:j.number});t===b.current&&w(n)}catch(e){t===b.current&&F(e,`读取证据路径失败`)}finally{t===b.current&&E(!1)}},se=[{title:`序号`,dataIndex:`number`,width:70},{title:`验收项`,dataIndex:`text`,render:(e,t)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(tn,{ellipsis:{showTooltip:!0},children:e||`—`}),t.review_note?(0,$.jsxs)(tn,{type:`tertiary`,size:`small`,className:`assessment-ellipsis`,children:[`复核说明:`,Ve(t.review_note,80)]}):null]})},{title:i(`deepAssessments.status`,null,`状态`),dataIndex:`status`,width:120,render:e=>(0,$.jsx)(u,{color:xe[e]||`grey`,shape:`circle`,children:Oe(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,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>V(t),children:`查看证据`})}];return(0,$.jsxs)(`div`,{className:`assessment-tab`,children:[(0,$.jsx)(N,{metrics:ne,columns:4}),(0,$.jsxs)(B,{title:i(`deepAssessments.acceptance`,null,`验收证据`),description:`状态反映证据关联情况,验收结论由审阅人核对;观察事实需有本意图的原始成功回执。`,extra:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,onClick:()=>D.reload(),loading:D.loading,children:`刷新`}),(0,$.jsx)(f,{size:`small`,onClick:()=>S(!0),children:`浏览证据来源`})]}),children:[(0,$.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,$.jsxs)(c,{children:[(0,$.jsx)(y,{percent:R,showInfo:!0,size:`small`,strokeWidth:8,style:{width:220}}),(0,$.jsxs)(tn,{type:`tertiary`,children:[`已有证据覆盖 `,R,`%`]})]}),(0,$.jsx)(ee,{value:a,onChange:e=>o(e||``),optionList:rn.map(e=>({value:e,label:e?`${Oe(i,e)} · ${M[e]||0}`:`${i(`deepAssessments.all`,null,`全部`)} · ${k.length}`})),style:{width:190}})]}),(0,$.jsx)(z,{error:D.error,onRetry:()=>D.reload()}),(0,$.jsx)(H,{columns:se,dataSource:te,rowKey:`number`,loading:D.loading,pagination:!1,onRow:e=>({onClick:()=>V(e),style:{cursor:`pointer`}}),emptyText:`没有符合筛选条件的验收项。`})]}),(0,$.jsx)(ot,{id:e,reloadToken:r},e),(0,$.jsx)(an,{visible:x,id:e,onCancel:ie,edit:d,onEdit:(e,t)=>p(n=>({...n,[e]:t})),onSave:ae,saving:m,saveError:g}),(0,$.jsx)(I,{visible:!!j,onCancel:()=>V(null),title:j?`验收项 ${j.number}`:`验收项`,width:720,closeOnEsc:!x,footer:null,children:j?(0,$.jsxs)(`div`,{className:`assessment-drawer`,children:[(0,$.jsx)(L,{columns:1,items:[{label:`验收条件`,value:(0,$.jsx)(nn,{className:`assessment-pre`,children:j.text||`—`})},{label:i(`deepAssessments.status`,null,`状态`),value:(0,$.jsx)(u,{color:xe[j.status]||`grey`,children:Oe(i,j.status)})},{label:`复核说明`,value:j.review_note||`—`},{label:`人工标记待复核`,value:j.needs_review?`是`:`否`}]}),(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(tn,{strong:!0,children:`关联事实`}),(0,$.jsx)(H,{columns:[{title:`事实`,dataIndex:`title`,render:(e,t)=>(0,$.jsx)(tn,{ellipsis:{showTooltip:!0},children:e||t.id})},{title:`状态`,dataIndex:`state`,width:120,render:e=>Te(i,e)},{title:`回执引用`,dataIndex:`receipt_ids`,width:100,render:e=>(e||[]).length}],dataSource:j.facts||[],rowKey:`id`,pagination:!1,size:`small`,emptyText:`暂无关联事实。`})]}),(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(tn,{strong:!0,children:`关联回执`}),(0,$.jsx)(H,{columns:[{title:`回执`,dataIndex:`title`,render:(e,t)=>(0,$.jsx)(tn,{ellipsis:{showTooltip:!0},children:e||t.id})},{title:`状态`,dataIndex:`state`,width:120,render:e=>Te(i,e)},{title:`来源意图`,dataIndex:`step_id`,width:140}],dataSource:j.receipts||[],rowKey:`id`,pagination:!1,size:`small`,emptyText:`暂无关联回执。`})]}),(0,$.jsxs)(c,{children:[n&&(0,$.jsx)(f,{size:`small`,theme:`solid`,onClick:re,children:`编辑证据关联`}),(0,$.jsx)(f,{size:`small`,onClick:oe,loading:T,children:`读取局部证据图`}),(0,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>S(!0),children:`浏览证据来源`})]}),C?(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsxs)(tn,{strong:!0,children:[`证据路径 · `,C.title||C.root]}),(0,$.jsx)(`div`,{className:`assessment-path-list`,children:(C.nodes||[]).map(e=>(0,$.jsxs)(`div`,{className:`assessment-path-node`,children:[(0,$.jsx)(u,{size:`small`,children:e.kind}),(0,$.jsx)(tn,{ellipsis:{showTooltip:!0},children:e.title||e.id})]},e.id))}),(0,$.jsx)(U,{title:`证据路径原始数据`,value:C,collapsed:!0})]}):null]}):null})]})}var{Text:sn,Paragraph:cn}=s,ln=[{value:`receipts`,label:`执行回执`},{value:`path`,label:`证据路径`},{value:`history`,label:`历次测评`,permission:`asset:read`},{value:`endpoints`,label:`端点证据`,permission:`asset:read`}],un=2e5,dn=e=>typeof e==`string`&&e.length>un?`${e.slice(0,un)}\n…(已截断 ${e.length-un} 字符,完整内容请下载原始回执)`:He(e),fn=[{value:`criterion`,label:`验收项序号`},{value:`asset`,label:`资产 ID`},{value:`fact`,label:`事实 ID`}];function pn({id:e,criterion:t=0,factId:n=``,stepId:r=``,reloadToken:i}){let a=O(),{hasPermission:o}=k(),s=(0,q.useMemo)(()=>ln.filter(e=>!e.permission||o(e.permission)),[o]),[l,d]=(0,q.useState)(t>0||n?`path`:`receipts`),p=s.some(e=>e.value===l)?l:`receipts`,[h,g]=(0,q.useState)(0),[_,v]=(0,q.useState)(null),y=P(()=>A.get(`/deep-assessments/${e}/receipts`,{offset:h,step_id:r}),[e,h,r,i],{skip:p!==`receipts`}),[b,x]=(0,q.useState)(n?`fact`:`criterion`),[S,C]=(0,q.useState)(n||(t>0?String(t):``)),[w,E]=(0,q.useState)(null),[j,N]=(0,q.useState)({loading:!1,error:null}),[F,R]=(0,q.useState)(``),[te,ne]=(0,q.useState)(``),[V,re]=(0,q.useState)(null),[ie,ae]=(0,q.useState)({loading:!1,error:null}),[W,se]=(0,q.useState)(null),[ce,le]=(0,q.useState)({loading:!1,error:null});(0,q.useEffect)(()=>{g(0)},[p]);let ue=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 A.get(`/deep-assessments/${e}/evidence-path`,n);E(t),N({loading:!1,error:null})}catch(e){E(null),N({loading:!1,error:e})}};(0,q.useEffect)(()=>{(t>0||n)&&ue()},[e,t,n]);let G=async()=>{let t=F.trim();if(!t)M(`请填写资产 ID`);else{ae({loading:!0,error:null}),ne(t);try{let n=await A.get(`/deep-assessments/${e}/evidence-history`,{asset_id:t});re(n),ae({loading:!1,error:null})}catch(e){re(null),ae({loading:!1,error:e})}}},de=async()=>{let t=F.trim();if(!t)M(`请填写资产 ID`);else{le({loading:!0,error:null});try{let n=await A.get(`/deep-assessments/${e}/endpoint-evidence`,{asset_id:t});se(n),le({loading:!1,error:null})}catch(e){se(null),le({loading:!1,error:e})}}},K=y.data?.receipts||[],fe=[{title:a(`deepAssessments.status`,null,`状态`),dataIndex:`status`,width:110,render:e=>(0,$.jsx)(oe,{status:e,label:Q(a,e)})},{title:`工具`,dataIndex:`tool`,width:200,render:(e,t)=>(0,$.jsxs)(`div`,{className:`assessment-list-name`,children:[(0,$.jsx)(sn,{strong:!0,children:e||`—`}),(0,$.jsx)(sn,{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,$.jsx)(sn,{type:`tertiary`,ellipsis:{showTooltip:!0},children:e}):`—`},{title:`操作`,width:90,render:(e,t)=>(0,$.jsx)(f,{size:`small`,theme:`borderless`,onClick:()=>v(t),children:`查看`})}];return(0,$.jsxs)(`div`,{className:`assessment-tab`,children:[(0,$.jsxs)(B,{title:a(`deepAssessments.evidence`,null,`证据回执`),description:`回执是执行原始记录;路径与对照只读展示已保存的关联,不改变测评状态。`,extra:(0,$.jsxs)(c,{children:[(0,$.jsx)(ee,{value:p,onChange:e=>d(e||`receipts`),optionList:s.map(e=>({value:e.value,label:e.label})),style:{width:160}}),(0,$.jsx)(f,{size:`small`,onClick:()=>p===`receipts`?y.reload():void 0,disabled:p!==`receipts`,children:`刷新`})]}),children:[p===`receipts`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(z,{error:y.error,onRetry:()=>y.reload()}),(0,$.jsx)(H,{columns:fe,dataSource:K,rowKey:`id`,loading:y.loading,pagination:!1,onRow:e=>({onClick:()=>v(e),style:{cursor:`pointer`}}),emptyText:a(`deepAssessments.noRecords`,null,`暂无记录`)}),(0,$.jsx)(`div`,{className:`assessment-pager`,children:(0,$.jsxs)(c,{children:[(0,$.jsx)(f,{size:`small`,disabled:h===0,onClick:()=>g(e=>Math.max(0,e-50)),children:a(`deepAssessments.previous`,null,`上一页`)}),(0,$.jsxs)(sn,{type:`tertiary`,children:[`共 `,K.length,` 条`]}),(0,$.jsx)(f,{size:`small`,disabled:!y.data?.has_more,onClick:()=>g(e=>e+50),children:a(`deepAssessments.next`,null,`下一页`)})]})})]}):null,p===`path`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,$.jsx)(ee,{value:b,onChange:e=>x(e||`criterion`),optionList:fn,style:{width:150}}),b===`criterion`?(0,$.jsx)(T,{value:S===``?void 0:Number(S),onChange:e=>C(e==null?``:String(e)),min:1,placeholder:`验收项序号`,style:{width:160}}):(0,$.jsx)(m,{value:S,onChange:C,placeholder:b===`asset`?`资产 ID`:`事实 ID`,style:{width:320},showClear:!0}),(0,$.jsx)(f,{size:`small`,theme:`solid`,type:`primary`,onClick:ue,loading:j.loading,children:`读取证据路径`})]}),(0,$.jsx)(z,{error:j.error,onRetry:ue}),w?(0,$.jsxs)($.Fragment,{children:[(0,$.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,$.jsx)(H,{columns:[{title:`类型`,dataIndex:`kind`,width:120,render:(e,t)=>we(a,e)||t.kind},{title:`标题`,dataIndex:`title`,render:(e,t)=>(0,$.jsx)(sn,{ellipsis:{showTooltip:!0},children:e||t.id})},{title:`状态`,dataIndex:`state`,width:120,render:e=>Te(a,e)},{title:`来源意图`,dataIndex:`step_id`,width:150,render:e=>e||`—`}],dataSource:w.nodes||[],rowKey:`id`,pagination:!1,size:`small`,emptyText:`证据路径为空。`}),(0,$.jsxs)(sn,{type:`tertiary`,size:`small`,children:[`关联边 `,Array.isArray(w.edges)?w.edges.length:0,` 条`]}),(0,$.jsx)(U,{title:`证据路径原始数据`,value:w,collapsed:!0})]}):null]}):null,p===`history`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,$.jsx)(m,{value:F,onChange:R,placeholder:`资产 ID`,style:{width:340},showClear:!0}),(0,$.jsx)(f,{size:`small`,theme:`solid`,type:`primary`,onClick:G,loading:ie.loading,children:`读取历次测评`})]}),(0,$.jsx)(z,{error:ie.error,onRetry:G}),V?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(sn,{strong:!0,children:[V.title||V.asset_id,` · 本次测评`]}),(0,$.jsx)(L,{columns:3,items:[{label:`测评`,value:V.current?.name||`—`},{label:`状态`,value:Q(a,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,$.jsx)(H,{columns:[{title:`较早测评`,dataIndex:`name`,render:(e,t)=>(0,$.jsx)(sn,{ellipsis:{showTooltip:!0},children:e||t.task_id})},{title:`状态`,dataIndex:`state`,width:110,render:e=>Q(a,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:te?`暂无可读的较早测评记录。`:`—`}),(0,$.jsx)(cn,{type:`tertiary`,className:`assessment-hint`,children:`差异基于两次已保存的证据记录;范围或项目口径不同时保留记录供人工对照。`}),(0,$.jsx)(U,{title:`历次测评原始数据`,value:V,collapsed:!0})]}):null]}):null,p===`endpoints`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`assessment-toolbar`,children:[(0,$.jsx)(m,{value:F,onChange:R,placeholder:`资产 ID`,style:{width:340},showClear:!0}),(0,$.jsx)(f,{size:`small`,theme:`solid`,type:`primary`,onClick:de,loading:ce.loading,children:`读取端点证据`})]}),(0,$.jsx)(z,{error:ce.error,onRetry:de}),W?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(L,{columns:4,items:[{label:`资产`,value:W.title||`—`},{label:`已有观察`,value:W.counts?.observed??0},{label:`待复核`,value:W.counts?.needs_review??0},{label:`缺证据`,value:W.counts?.missing??0}]}),(0,$.jsx)(H,{columns:[{title:`方法`,dataIndex:`method`,width:90},{title:`路径`,dataIndex:`path`,render:(e,t)=>(0,$.jsx)(sn,{ellipsis:{showTooltip:!0},children:e||t.id})},{title:`名称`,dataIndex:`title`,width:220,render:e=>e||`—`},{title:`证据状态`,dataIndex:`status`,width:120,render:e=>(0,$.jsx)(u,{size:`small`,children:Te(a,e)})}],dataSource:W.endpoints||[],rowKey:`id`,pagination:!1,size:`small`,emptyText:`该资产暂无登记端点。`}),(0,$.jsx)(cn,{type:`tertiary`,className:`assessment-hint`,children:`端点状态来自明确关联的事实;服务级观察不会计入端点。端点关联的写入在攻击面图与漏洞复核流程中完成。`}),(0,$.jsx)(U,{title:`端点证据原始数据`,value:W,collapsed:!0})]}):null]}):null]}),(0,$.jsx)(I,{visible:!!_,onCancel:()=>v(null),title:_?`${_.tool||`回执`} · ${_.step_id||``}`:`回执详情`,width:720,footer:null,children:_?(0,$.jsxs)(`div`,{className:`assessment-drawer`,children:[(0,$.jsx)(L,{columns:2,items:[{label:a(`deepAssessments.status`,null,`状态`),value:(0,$.jsx)(oe,{status:_.status,label:Q(a,_.status)})},{label:`回执 ID`,value:_.id},{label:`来源意图`,value:_.step_id||`—`},{label:`执行 ID`,value:_.execution_id||`—`}]}),(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(sn,{strong:!0,children:`调用参数`}),(0,$.jsx)(U,{title:`arguments`,value:dn(_.arguments),collapsed:!1})]}),(0,$.jsxs)(`section`,{className:`assessment-section`,children:[(0,$.jsx)(sn,{strong:!0,children:`调用结果`}),(0,$.jsx)(U,{title:`result`,value:dn(_.result),collapsed:!0})]})]}):null})]})}function mn({id:e,task:t,reloadToken:n}){let r=O(),[i,a]=(0,q.useState)(!1),s=P(()=>A.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,$.jsx)(`div`,{className:`assessment-tab`,children:(0,$.jsxs)(B,{title:r(`deepAssessments.reportTitle`,null,`测评报告`),description:r(`deepAssessments.coverage.reportDescription`),extra:(0,$.jsxs)(c,{children:[(0,$.jsx)(V,{text:l,label:`复制 Markdown`}),(0,$.jsx)(f,{size:`small`,onClick:()=>s.reload(),loading:s.loading,children:`刷新`}),(0,$.jsx)(f,{size:`small`,theme:`solid`,type:`primary`,onClick:async()=>{a(!0);try{let t=await j(`/deep-assessments/${e}/report`,{filename:`assessment-${u}.md`});W(`已下载 ${t}`)}catch(e){F(e,`下载失败`)}finally{a(!1)}},loading:i,disabled:!l,children:r(`deepAssessments.report`,null,`下载报告`)})]}),children:[(0,$.jsx)(z,{error:s.error,onRetry:()=>s.reload()}),l?(0,$.jsx)(`div`,{className:`assessment-report`,children:(0,$.jsx)(R,{content:l})}):s.loading?null:(0,$.jsx)(o,{title:`报告为空`,description:`开始测评并保存进展后可生成报告。`,style:{padding:40}})]})})}function hn({id:e}){let[t,n]=(0,q.useState)(!1),[r,i]=(0,q.useState)(``),[a,o]=(0,q.useState)([]),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(null),m=(0,q.useRef)(null),h=(0,q.useRef)(null);(0,q.useEffect)(()=>()=>m.current?.abort(),[]),(0,q.useEffect)(()=>{t&&a.length&&h.current?.scrollIntoView({block:`nearest`})},[t,a]);let g=async()=>{let t=r.trim();if(!t||m.current)return;let n=new AbortController;m.current=n,l(!0),d(null);try{let r=a.slice(-3).map(e=>({question:e.question.slice(0,600),answer:e.answer.slice(0,1e3)})),s=await A.post(`/deep-assessments/${encodeURIComponent(e)}/question`,{question:t,history:r},{signal:n.signal,timeout:95e3});o(e=>[...e,{question:t,answer:s.answer,updated:s.updated_at}]),i(``)}catch(e){n.signal.aborted||d(e)}finally{m.current=null,l(!1)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(f,{onClick:()=>n(!0),children:`测评问答`}),(0,$.jsxs)(I,{visible:t,title:`测评问答`,onCancel:()=>n(!1),width:540,footer:(0,$.jsxs)(`form`,{className:`assessment-question-form`,onSubmit:e=>{e.preventDefault(),e.currentTarget.elements.namedItem(`question`)?.focus(),g()},children:[(0,$.jsx)(p,{name:`question`,"aria-label":`询问测评进展`,placeholder:`当前在做什么?有哪些方向正在等待处理?`,rows:3,maxLength:2e3,value:r,onChange:i,readOnly:c}),(0,$.jsx)(f,{htmlType:`submit`,theme:`solid`,loading:c,disabled:c||!r.trim(),children:`发送`})]}),children:[(0,$.jsx)(s.Paragraph,{type:`tertiary`,children:`只读问答。模型根据提问时的测评记录回答,离开本次测评页面后清空对话。`}),(0,$.jsxs)(`div`,{role:`log`,"aria-label":`问答记录`,"aria-live":`polite`,children:[a.map((e,t)=>(0,$.jsxs)(`section`,{className:`assessment-question-turn`,ref:t===a.length-1?h:void 0,children:[(0,$.jsx)(s.Text,{strong:!0,children:`你`}),(0,$.jsx)(`p`,{children:e.question}),(0,$.jsx)(s.Text,{strong:!0,children:`模型`}),(0,$.jsx)(`p`,{children:e.answer}),(0,$.jsxs)(s.Text,{size:`small`,type:`tertiary`,children:[`任务更新于 `,D(e.updated)]})]},t)),c?(0,$.jsx)(s.Text,{type:`tertiary`,children:`正在读取进展并生成回答…`}):null]}),(0,$.jsx)(z,{error:u,onRetry:g})]})]})}var{Text:gn}=s,_n=[{key:`overview`,i18n:`deepAssessments.overview`,fallback:`概览`},{key:`intents`,i18n:`deepAssessments.intents`,fallback:`意图`},{key:`facts`,i18n:`deepAssessments.facts`,fallback:`事实`},{key:`assets`,i18n:`deepAssessments.attackSurfaceGraph`,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 vn({id:e,tab:t,criterion:n,evidencePath:r,evidenceStepId:i,evidenceFactId:o,observation:s,onTabChange:u,onBack:d,onDeleted:m}){let h=O(),{hasPermission:_}=k(),v=P(()=>A.get(`/deep-assessments/${e}`),[e]),y=v.data?.task||null,b=y?.name?.trim(),x=y?.objective?.trim(),S=x===b||b?.length>1&&b.endsWith(`…`)&&x?.startsWith(b.slice(0,-1)),[C,T]=(0,q.useState)([]),[ee,j]=(0,q.useState)(null),[N,L]=(0,q.useState)(!0),[R,te]=(0,q.useState)(``),[B,ne]=(0,q.useState)(0),[V,H]=(0,q.useState)(``),[ae,U]=(0,q.useState)(``),[ce,le]=(0,q.useState)(``),ue=ae===`answer`?`答复并继续`:`补充线索或调整方向`,G=(0,q.useRef)(0),de=(0,q.useRef)(!1),K=_(Se),fe=_(Ce),pe=_(`agent:execute`),me=(0,q.useMemo)(()=>_n.filter(e=>!e.permission||_(e.permission)),[_]),J=me.some(e=>e.key===t)?t:`overview`,Y=(0,q.useCallback)(async(t=!1)=>{if((t||!de.current)&&(t||!document.hidden&&N)){de.current=!0;try{let n=await A.get(`/deep-assessments/${e}/events`,t?{latest:`true`}:{after:G.current}),r=Array.isArray(n?.events)?n.events:[];t?(T(r),G.current=r.length&&Number(r[r.length-1].id)||0):r.length&&(T(e=>[...e,...r].slice(-500)),G.current=Number(r[r.length-1].id)||G.current),j(null)}catch(e){t&&j(e)}finally{de.current=!1}}},[e,N]);(0,q.useEffect)(()=>(G.current=0,T([]),j(null),Y(!0),()=>{G.current=0}),[e]),(0,q.useEffect)(()=>{J===`overview`&&Y(!1)},[J]),ie(()=>{document.hidden||(Y(!1),R||v.reload({silent:!0}))},J===`overview`&&N?1e4:0);let X=async()=>{await v.reload(),ne(e=>e+1),Y(!0)},Z=async(t,n={})=>{if(y&&K){te(t);try{let r=await A.post(`/deep-assessments/${e}/control/${t}`,{revision:y.revision,...n});r?.task&&v.setData(e=>({...e,task:r.task})),r?.start_error?M(r.start_error):W(h(`deepAssessments.updated`,null,`已更新`)),ne(e=>e+1),Y(!0),v.reload({silent:!0})}catch(e){F(e,h(`deepAssessments.controlFailed`,null,`操作失败`)),v.reload()}finally{te(``)}}},he=async()=>{if(!y)return;let t=ce.trim();if(!t)M(`请填写补充内容`);else{te(`message`);try{let n=await A.post(`/deep-assessments/${e}/control/${ae}`,{revision:y.revision,message:t});n?.task&&v.setData(e=>({...e,task:n.task})),n?.start_error?M(n.start_error):W(ae===`answer`?`已答复并继续`:`已提交方向`),U(``),le(``),ne(e=>e+1),Y(!0),v.reload({silent:!0})}catch(e){F(e,`提交失败`)}finally{te(``)}}},ge=[y&&pe?(0,$.jsx)(hn,{id:e},e):null,(0,$.jsx)(f,{theme:`borderless`,onClick:d,children:`返回列表`},`back`),(0,$.jsx)(f,{icon:(0,$.jsx)(w,{}),onClick:X,loading:v.loading&&!R,children:`刷新`},`refresh`),(0,$.jsx)(f,{theme:`solid`,type:`primary`,disabled:!K||!pe||!!R||!Me(y),loading:R===`start`,onClick:()=>Z(`start`),children:h(`deepAssessments.start`,null,`开始 / 继续`)},`start`),(0,$.jsx)(f,{disabled:!K||!!R||!Ne(y),loading:R===`pause`,onClick:()=>Z(`pause`),children:h(`deepAssessments.pause`,null,`暂停`)},`pause`),(0,$.jsx)(f,{type:`danger`,disabled:!K||!!R||!Pe(y),loading:R===`cancel`,onClick:()=>Z(`cancel`),children:h(`deepAssessments.cancel`,null,`停止`)},`cancel`),Fe(y)?(0,$.jsx)(f,{disabled:!K||!pe||!!R,loading:R===`continue-stopped`,onClick:()=>Z(`continue-stopped`),children:`继续测评`},`continue`):null,(0,$.jsx)(f,{disabled:!K||!!R||(y?.archived?!Le(y):!Ie(y)),loading:R===`archive`||R===`restore`,onClick:()=>Z(y?.archived?`restore`:`archive`),children:y?.archived?`恢复到列表`:`归档`},`archive`),(0,$.jsx)(f,{type:`danger`,theme:`borderless`,icon:(0,$.jsx)(l,{}),disabled:!fe||!!R||!Re(y),onClick:()=>{y&&se({title:h(`deepAssessments.delete`,null,`删除`),content:`删除本条测评?关联执行会话仍保留。`,okText:h(`deepAssessments.delete`,null,`删除`),onOk:async()=>{try{await A.del(`/deep-assessments/${e}`),W(h(`deepAssessments.deleted`,null,`已删除`)),m?.()}catch(e){F(e,`删除失败`)}}})},children:h(`deepAssessments.delete`,null,`删除`)},`delete`)];return(0,$.jsxs)(`div`,{className:`assessment-page`,children:[(0,$.jsx)(re,{title:b||h(`deepAssessments.title`,null,`深度测评`),description:x&&!S?Ve(x,160):null,extra:ge,children:(0,$.jsxs)(c,{spacing:8,wrap:!0,className:`assessment-meta`,children:[y?(0,$.jsx)(oe,{status:y.status,label:Q(h,y.status)}):null,y?.archived?(0,$.jsx)(oe,{status:`archived`,label:Q(h,`archived`)}):null,y&&je(y)?(0,$.jsx)(oe,{status:`needs_review`,label:Q(h,`needs_review`)}):null,y?(0,$.jsxs)(gn,{type:`tertiary`,children:[`模型 `,v.data?.model_channel_name||y.model||`系统默认`]}):null,y?.role?(0,$.jsxs)(gn,{type:`tertiary`,children:[`角色 `,y.role]}):null,y?(0,$.jsxs)(gn,{type:`tertiary`,children:[`规划轮次 `,E(y.rounds||0)]}):null,y?(0,$.jsxs)(gn,{type:`tertiary`,children:[`累计 Token `,E(y.tokens_used||0)]}):null,y?.created_at?(0,$.jsxs)(gn,{type:`tertiary`,children:[`创建于 `,D(y.created_at)]}):null]})}),(0,$.jsx)(z,{error:v.error,onRetry:X}),y?.archived?(0,$.jsx)(a,{type:`info`,bordered:!0,closeIcon:null,description:`测评已归档。恢复到列表后才能继续控制、关联资产或补充方向。`}):null,y?.status===`blocked`?(0,$.jsx)(a,{type:`danger`,bordered:!0,closeIcon:null,className:`assessment-banner`,description:y.summary||`测评受阻,请查看运行记录定位原因;排除后可手动继续。`,children:(0,$.jsx)(f,{size:`small`,onClick:()=>u?.(`overview`),children:`查看运行记录`})}):null,y?.question?(0,$.jsx)(a,{type:`warning`,bordered:!0,closeIcon:null,className:`assessment-banner`,description:`执行需要人工确认:${y.question}`,children:(0,$.jsx)(f,{size:`small`,theme:`solid`,type:`primary`,disabled:!K||!pe,onClick:()=>{U(`answer`),le(``)},children:`答复并继续`})}):null,y&&!y.archived&&je(y)?(0,$.jsx)(a,{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,$.jsx)(f,{size:`small`,onClick:()=>{H(`uncertain`),u?.(`intents`)},children:`处理待核对`})}):null,(0,$.jsx)(g,{type:`line`,activeKey:J,onChange:e=>u?.(e),tabList:me.map(e=>({itemKey:e.key,tab:h(e.i18n,null,e.fallback)})),className:`assessment-tabs`,children:y?J===`overview`?(0,$.jsx)(ft,{task:y,reloadToken:B,canWrite:K&&pe,events:C,eventsError:ee,autoRefresh:N,onAutoRefreshChange:L,onRefreshEvents:()=>Y(!0),onGoTab:u,onGuidance:()=>{U(`guidance`),le(``)},onAnswer:()=>{U(`answer`),le(``)}}):J===`intents`?(0,$.jsx)(gt,{id:e,reloadToken:B,status:V,onStatusChange:H,archived:!!y.archived,taskStatus:y.status,revision:y.revision,onChanged:()=>{ne(e=>e+1),v.reload({silent:!0})}}):J===`facts`?(0,$.jsx)(yt,{id:e,reloadToken:B,task:y}):J===`assets`?(0,$.jsx)(kt,{id:e,task:y,observation:s,reloadToken:B}):J===`graph`?(0,$.jsx)(Xt,{id:e,task:y,reloadToken:B,onGoIntents:()=>u?.(`intents`),autoRefresh:N,onAutoRefreshChange:L,onRefreshTask:v.reload,refreshPaused:!!R||v.loading}):J===`findings`?(0,$.jsx)(en,{id:e,task:y,reloadToken:B}):J===`acceptance`?(0,$.jsx)(on,{id:e,criterion:n,canWrite:K&&!y.archived,reloadToken:B}):J===`evidence`?(0,$.jsx)(pn,{id:e,criterion:r?n:0,factId:o,stepId:i,reloadToken:B},`${r}-${n}-${i}-${o}`):(0,$.jsx)(mn,{id:e,task:y,reloadToken:B}):null}),!y&&v.loading?(0,$.jsx)(`div`,{className:`assessment-loading`,children:`正在读取测评…`}):null,(0,$.jsxs)(I,{visible:!!ae,title:ue,"aria-label":ue,onCancel:()=>U(``),width:560,closable:R!==`message`,closeOnEsc:R!==`message`,maskClosable:R!==`message`,footer:(0,$.jsxs)(`div`,{className:`assessment-form-actions`,children:[(0,$.jsx)(f,{onClick:()=>U(``),disabled:R===`message`,children:`取消`}),(0,$.jsx)(f,{theme:`solid`,onClick:he,loading:R===`message`,disabled:R===`message`,children:`提交`})]}),children:[(0,$.jsx)(`p`,{className:`assessment-hint`,children:ae===`answer`?`答复会保存到人工补充并清除待答复状态,随后自动继续测评。`:`当前执行账号可以在测评运行时提交补充,下一轮规划会读取。`}),(0,$.jsx)(p,{value:ce,onChange:le,rows:5,maxLength:8e3,placeholder:`例如:优先验证登录接口的越权风险,并附上原始请求回执。`})]})]})}function yn(){let e=O(),{hasPermission:t}=k(),[n,r]=i(),a=n.get(`id`)||n.get(`assessment_id`)||``,s=n.get(`tab`)||`overview`,c=s===`evidence-path`?`evidence`:s,l=(0,q.useCallback)(e=>{let t=new URLSearchParams;t.set(`id`,e),t.set(`tab`,`overview`),r(t)},[r]),u=(0,q.useCallback)(e=>{let t=new URLSearchParams;t.set(`id`,a),t.set(`tab`,e),r(t,{replace:!0})},[a,r]),d=(0,q.useCallback)(()=>{r(new URLSearchParams,{replace:!1})},[r]);return t(`assessments:read`)?a?(0,$.jsx)(vn,{id:a,tab:c,criterion:Number(n.get(`criterion`))||0,evidencePath:s===`evidence-path`,evidenceStepId:n.get(`step_id`)||``,evidenceFactId:s===`evidence-path`&&n.get(`fact_id`)||``,observation:n.get(`observation`)||``,onTabChange:u,onBack:d,onDeleted:d},a):(0,$.jsx)(tt,{onOpen:l}):(0,$.jsx)(`div`,{className:`assessment-page`,children:(0,$.jsx)(o,{title:e(`common.forbidden`,null,`当前账号没有访问该页面的权限`),description:`深度测评需要 assessments:read 权限,请联系管理员分配。`,style:{padding:64}})})}export{yn as default};
\ No newline at end of file
diff --git a/web/static/app/assets/hitl-hVYHftcD.js b/web/static/app/assets/hitl-CF6Z_-AR.js
similarity index 99%
rename from web/static/app/assets/hitl-hVYHftcD.js
rename to web/static/app/assets/hitl-CF6Z_-AR.js
index 573e2b3e..f3aba4fb 100644
--- a/web/static/app/assets/hitl-hVYHftcD.js
+++ b/web/static/app/assets/hitl-CF6Z_-AR.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{B as i,E as a,G as o,I as s,N as c,R as l,S as u,U as d,V as f,W as p,c as m,h,lt as g,m as _,p as v,ut as y,v as b,y as x}from"./semi-65W_4I1v.js";import{E as S,F as C,I as w,L 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-DNMXun-U.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}=o;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]),a=H(e.mode)===`review_edit`,o=W(e.reviewer),[f,p]=(0,R.useState)(``),[m,h]=(0,R.useState)(()=>a&&i?JSON.stringify(i,null,2):``),[g,_]=(0,R.useState)(``),[v,y]=(0,R.useState)(``),b=(0,R.useCallback)(async t=>{if(g)return;let r;if(a&&m.trim()){try{r=JSON.parse(m)}catch(e){y(`修改后的参数不是合法 JSON:${e.message}`);return}if(!r||typeof r!=`object`||Array.isArray(r)){y(`修改后的参数必须是 JSON 对象`);return}}y(``),_(t);try{await T.post(`/hitl/decision`,{interruptId:e.id,decision:t,comment:f.trim(),editedArguments:r}),I(t===`approve`?`已通过,工具将继续执行`:`已拒绝本次工具调用`),n?.()}catch(t){if(t?.status===409){await T.post(`/hitl/dismiss`,{interruptId:e.id}).catch(()=>null),E(`该审批已被处理,列表已刷新`),n?.();return}O(t,`提交审批失败`)}finally{_(``)}},[a,m,g,f,e.id,n]),x=(0,R.useCallback)(()=>{L({title:`忽略该审批`,content:`忽略后该审批记为取消(reject),本次工具调用不会继续执行,记录可在审批日志中查看。`,okText:`忽略`,onOk:async()=>{try{await T.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)(s,{spacing:6,wrap:!0,children:[(0,Z.jsx)(c,{size:`small`,color:`blue`,shape:`square`,children:e.toolName||`—`}),(0,Z.jsx)(c,{size:`small`,color:a?`violet`:`grey`,children:U(e.mode)}),(0,Z.jsx)(c,{size:`small`,color:o===`audit_agent`?`green`:`grey`,children:G(e.reviewer)})]}),(0,Z.jsxs)(s,{spacing:6,children:[(0,Z.jsx)(le,{type:`tertiary`,size:`small`,children:Y(e.createdAt)}),(0,Z.jsx)(l,{size:`small`,theme:`borderless`,disabled:!t||!!g,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:a?`修改后的参数(可编辑,留空表示沿用原参数)`:`审批模式:仅可通过/拒绝,参数编辑已禁用`}),(0,Z.jsx)(u,{rows:a?6:3,value:a?m:i?JSON.stringify(i,null,2):``,disabled:!a,spellCheck:!1,className:`hitl-args-textarea`,onChange:e=>{h(e),v&&y(``)}})]}),v&&(0,Z.jsx)(`div`,{className:`hitl-inline-error`,children:v}),(0,Z.jsx)(d,{value:f,placeholder:`审批备注(可选),例如:只读命令,允许执行`,onChange:e=>p(e)}),(0,Z.jsxs)(`div`,{className:`hitl-pending-actions`,children:[(0,Z.jsx)(l,{type:`danger`,theme:`light`,disabled:!t||!!g,loading:g===`reject`,onClick:()=>b(`reject`),children:`拒绝`}),(0,Z.jsx)(l,{theme:`solid`,disabled:!t||!!g,loading:g===`approve`,onClick:()=>b(`approve`),children:a&&m.trim()&&m.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=C(),[i,o]=(0,R.useState)(1),[s,c]=(0,R.useState)(20),[l,u]=(0,R.useState)(``),f=ee(l,350),m=D(()=>T.get(`/hitl/pending`,{page:i,pageSize:s,q:f}),[i,s,f,n]),h=m.data?.items||[],g=Number(m.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)(d,{showClear:!0,value:l,style:{width:300},placeholder:r(`hitl.searchPlaceholder`,null,`搜索工具、会话或载荷…`),onChange:e=>{u(e),o(1)}}),(0,Z.jsxs)(le,{type:`tertiary`,size:`small`,children:[r(`hitl.pendingTitle`,null,`待审批请求`),` · `,g]})]}),(0,Z.jsx)(A,{error:m.error,onRetry:()=>m.reload()}),m.loading&&!h.length&&(0,Z.jsx)(`div`,{className:`hitl-panel-loading`,children:(0,Z.jsx)(p,{})}),!m.loading&&!h.length&&!m.error&&(0,Z.jsx)(a,{title:r(`hitl.emptyState`,null,`暂无待审批请求`),description:`工具调用命中敏感规则时会在此等待裁决。`,style:{padding:48}}),(0,Z.jsx)(`div`,{className:`hitl-pending-list`,children:h.map(t=>(0,Z.jsx)(ue,{item:t,canWrite:e,onDone:()=>{h.length<=1&&i>1?o(i-1):m.reload()}},t.id))}),g>0&&(0,Z.jsx)(`div`,{className:`hitl-panel-pagination`,children:(0,Z.jsx)(b,{currentPage:i,pageSize:s,total:g,showSizeChanger:!0,pageSizeOpts:[10,20,50],showTotal:!0,onPageChange:e=>o(e),onPageSizeChange:_})})]})}var{Text:fe}=o;function pe({logId:e,onClose:t}){let n=C(),{data:r,loading:i,error:a,reload:o}=D(()=>T.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)(v,{visible:!!e,onCancel:t,width:720,title:n(`hitl.logModalView`,null,`审批日志详情`),footer:(0,Z.jsx)(l,{onClick:t,children:n(`common.close`,null,`关闭`)}),children:[(0,Z.jsx)(A,{error:a,onRetry:o}),i&&!r&&(0,Z.jsx)(`div`,{className:`hitl-panel-loading`,children:(0,Z.jsx)(p,{})}),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)(c,{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)(s,{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 a=C(),[o,u]=(0,R.useState)(1),[f,p]=(0,R.useState)(20),[m,h]=(0,R.useState)(``),g=ee(m,350),[_,v]=(0,R.useState)(`all`),[b,S]=(0,R.useState)(`all`),[w,E]=(0,R.useState)([]),k=(0,R.useMemo)(()=>({q:g,decision:_===`all`?``:_,decidedBy:b===`all`?``:b}),[g,_,b]),j=D(()=>T.get(`/hitl/logs`,{page:o,pageSize:f,...k}),[o,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)(()=>{w.length&&L({title:`批量删除审批日志`,content:`确定删除选中的 ${w.length} 条审批日志?此操作不可恢复。`,okText:a(`common.delete`,null,`删除`),onOk:async()=>{try{await T.del(`/hitl/logs`,{body:{ids:w}}),I(`已删除 ${w.length} 条审批日志`),E([]),z()}catch(e){O(e,`批量删除审批日志失败`)}}})},[z,w,a]),B=(0,R.useCallback)(()=>{L({title:a(`hitl.clearAll`,null,`清空审计日志`),content:g||_!==`all`||b!==`all`?`将清空当前筛选条件下的全部已裁决日志(不会删除待审批项)。`:`将清空全部已裁决审批日志(不会删除待审批项)。`,okText:a(`hitl.clearAll`,null,`清空`),onOk:async()=>{try{await T.del(`/hitl/logs`,{query:k,body:{all:!0}}),I(`审批日志已清空`),E([]),u(1),z()}catch(e){O(e,`清空审批日志失败`)}}})},[b,_,g,k,z,a]),V=[{title:a(`hitl.colTool`,null,`工具`),dataIndex:`toolName`,width:220,ellipsis:!0,render:e=>(0,Z.jsx)(`span`,{className:`hitl-mono hitl-ellipsis`,title:e||``,children:e||`—`})},{title:a(`hitl.colConversation`,null,`会话`),dataIndex:`conversationId`,width:200,render:e=>(0,Z.jsx)(`span`,{className:`hitl-mono hitl-ellipsis`,title:e||``,children:e||`—`})},{title:a(`hitl.colDecision`,null,`决策`),dataIndex:`decision`,width:100,render:e=>(0,Z.jsx)(c,{size:`small`,color:q(e),children:K(e)})},{title:a(`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:a(`hitl.colTime`,null,`时间`),dataIndex:`decidedAt`,width:180,render:(e,t)=>Y(e||t.createdAt)},{title:a(`common.actions`,null,`操作`),dataIndex:`id`,width:90,render:e=>(0,Z.jsx)(l,{size:`small`,theme:`borderless`,onClick:()=>n(e),children:a(`common.view`,null,`详情`)})}],H={currentPage:o,pageSize:f,total:N,showSizeChanger:!0,pageSizeOpts:[20,50,100],showTotal:!0,onPageChange:e=>u(e),onPageSizeChange:e=>{p(e),u(1)}};return(0,Z.jsxs)(`div`,{className:`hitl-logs-panel`,children:[F>0&&(0,Z.jsx)(`p`,{className:`hitl-retention-hint`,children:a(`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`,scroll:{x:1280},emptyText:a(`hitl.logsEmpty`,null,`暂无审批日志`),rowSelection:{selectedRowKeys:w,onChange:e=>E(e||[])},toolbar:(0,Z.jsxs)(s,{spacing:8,wrap:!0,children:[(0,Z.jsx)(d,{showClear:!0,style:{width:220},value:m,placeholder:a(`hitl.searchPlaceholder`,null,`搜索工具、会话或载荷…`),onChange:e=>{h(e),u(1)}}),(0,Z.jsx)(x,{value:_,style:{width:120},optionList:[{value:`all`,label:a(`hitl.filterAll`,null,`全部`)},{value:`approve`,label:a(`hitl.decisionApprove`,null,`通过`)},{value:`reject`,label:a(`hitl.decisionReject`,null,`拒绝`)}],onChange:e=>{v(e),u(1)}}),(0,Z.jsx)(x,{value:b,style:{width:150},optionList:[{value:`all`,label:a(`hitl.filterAll`,null,`全部`)},{value:`human`,label:a(`hitl.reviewerHuman`,null,`人工`)},{value:`audit_agent`,label:a(`hitl.reviewerAgent`,null,`审计 Agent`)},{value:`system`,label:a(`hitl.reviewerSystem`,null,`系统`)},{value:`manual`,label:a(`hitl.reviewerManual`,null,`手动录入`)}],onChange:e=>{S(e),u(1)}}),(0,Z.jsx)(l,{icon:(0,Z.jsx)(y,{}),theme:`borderless`,size:`small`,onClick:z,loading:j.loading,children:a(`common.refresh`,null,`刷新`)}),(0,Z.jsxs)(l,{size:`small`,type:`danger`,theme:`borderless`,disabled:!e||!w.length,onClick:te,children:[`批量删除`,w.length?`(${w.length})`:``]}),(0,Z.jsx)(l,{size:`small`,type:`danger`,theme:`borderless`,disabled:!e||!N,onClick:B,children:a(`hitl.clearAll`,null,`清空`)})]})}),(0,Z.jsx)(pe,{logId:t,onClose:r})]})}var{Text:he}=o;function ge({canWrite:e,refreshKey:t=0}){let n=C(),{data:r,loading:i,error:a,reload:o}=D(()=>T.get(`/hitl/tool-whitelist`),[t]),[d,f]=(0,R.useState)(``),[p,m]=(0,R.useState)(``);(0,R.useEffect)(()=>{r&&f((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{B as i,E as a,G as o,I as s,N as c,R as l,S as u,U as d,V as f,W as p,c as m,h,lt as g,m as _,p as v,ut as y,v as b,y as x}from"./semi-65W_4I1v.js";import{E as S,F as C,I as w,L 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-C6SML8F9.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}=o;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]),a=H(e.mode)===`review_edit`,o=W(e.reviewer),[f,p]=(0,R.useState)(``),[m,h]=(0,R.useState)(()=>a&&i?JSON.stringify(i,null,2):``),[g,_]=(0,R.useState)(``),[v,y]=(0,R.useState)(``),b=(0,R.useCallback)(async t=>{if(g)return;let r;if(a&&m.trim()){try{r=JSON.parse(m)}catch(e){y(`修改后的参数不是合法 JSON:${e.message}`);return}if(!r||typeof r!=`object`||Array.isArray(r)){y(`修改后的参数必须是 JSON 对象`);return}}y(``),_(t);try{await T.post(`/hitl/decision`,{interruptId:e.id,decision:t,comment:f.trim(),editedArguments:r}),I(t===`approve`?`已通过,工具将继续执行`:`已拒绝本次工具调用`),n?.()}catch(t){if(t?.status===409){await T.post(`/hitl/dismiss`,{interruptId:e.id}).catch(()=>null),E(`该审批已被处理,列表已刷新`),n?.();return}O(t,`提交审批失败`)}finally{_(``)}},[a,m,g,f,e.id,n]),x=(0,R.useCallback)(()=>{L({title:`忽略该审批`,content:`忽略后该审批记为取消(reject),本次工具调用不会继续执行,记录可在审批日志中查看。`,okText:`忽略`,onOk:async()=>{try{await T.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)(s,{spacing:6,wrap:!0,children:[(0,Z.jsx)(c,{size:`small`,color:`blue`,shape:`square`,children:e.toolName||`—`}),(0,Z.jsx)(c,{size:`small`,color:a?`violet`:`grey`,children:U(e.mode)}),(0,Z.jsx)(c,{size:`small`,color:o===`audit_agent`?`green`:`grey`,children:G(e.reviewer)})]}),(0,Z.jsxs)(s,{spacing:6,children:[(0,Z.jsx)(le,{type:`tertiary`,size:`small`,children:Y(e.createdAt)}),(0,Z.jsx)(l,{size:`small`,theme:`borderless`,disabled:!t||!!g,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:a?`修改后的参数(可编辑,留空表示沿用原参数)`:`审批模式:仅可通过/拒绝,参数编辑已禁用`}),(0,Z.jsx)(u,{rows:a?6:3,value:a?m:i?JSON.stringify(i,null,2):``,disabled:!a,spellCheck:!1,className:`hitl-args-textarea`,onChange:e=>{h(e),v&&y(``)}})]}),v&&(0,Z.jsx)(`div`,{className:`hitl-inline-error`,children:v}),(0,Z.jsx)(d,{value:f,placeholder:`审批备注(可选),例如:只读命令,允许执行`,onChange:e=>p(e)}),(0,Z.jsxs)(`div`,{className:`hitl-pending-actions`,children:[(0,Z.jsx)(l,{type:`danger`,theme:`light`,disabled:!t||!!g,loading:g===`reject`,onClick:()=>b(`reject`),children:`拒绝`}),(0,Z.jsx)(l,{theme:`solid`,disabled:!t||!!g,loading:g===`approve`,onClick:()=>b(`approve`),children:a&&m.trim()&&m.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=C(),[i,o]=(0,R.useState)(1),[s,c]=(0,R.useState)(20),[l,u]=(0,R.useState)(``),f=ee(l,350),m=D(()=>T.get(`/hitl/pending`,{page:i,pageSize:s,q:f}),[i,s,f,n]),h=m.data?.items||[],g=Number(m.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)(d,{showClear:!0,value:l,style:{width:300},placeholder:r(`hitl.searchPlaceholder`,null,`搜索工具、会话或载荷…`),onChange:e=>{u(e),o(1)}}),(0,Z.jsxs)(le,{type:`tertiary`,size:`small`,children:[r(`hitl.pendingTitle`,null,`待审批请求`),` · `,g]})]}),(0,Z.jsx)(A,{error:m.error,onRetry:()=>m.reload()}),m.loading&&!h.length&&(0,Z.jsx)(`div`,{className:`hitl-panel-loading`,children:(0,Z.jsx)(p,{})}),!m.loading&&!h.length&&!m.error&&(0,Z.jsx)(a,{title:r(`hitl.emptyState`,null,`暂无待审批请求`),description:`工具调用命中敏感规则时会在此等待裁决。`,style:{padding:48}}),(0,Z.jsx)(`div`,{className:`hitl-pending-list`,children:h.map(t=>(0,Z.jsx)(ue,{item:t,canWrite:e,onDone:()=>{h.length<=1&&i>1?o(i-1):m.reload()}},t.id))}),g>0&&(0,Z.jsx)(`div`,{className:`hitl-panel-pagination`,children:(0,Z.jsx)(b,{currentPage:i,pageSize:s,total:g,showSizeChanger:!0,pageSizeOpts:[10,20,50],showTotal:!0,onPageChange:e=>o(e),onPageSizeChange:_})})]})}var{Text:fe}=o;function pe({logId:e,onClose:t}){let n=C(),{data:r,loading:i,error:a,reload:o}=D(()=>T.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)(v,{visible:!!e,onCancel:t,width:720,title:n(`hitl.logModalView`,null,`审批日志详情`),footer:(0,Z.jsx)(l,{onClick:t,children:n(`common.close`,null,`关闭`)}),children:[(0,Z.jsx)(A,{error:a,onRetry:o}),i&&!r&&(0,Z.jsx)(`div`,{className:`hitl-panel-loading`,children:(0,Z.jsx)(p,{})}),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)(c,{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)(s,{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 a=C(),[o,u]=(0,R.useState)(1),[f,p]=(0,R.useState)(20),[m,h]=(0,R.useState)(``),g=ee(m,350),[_,v]=(0,R.useState)(`all`),[b,S]=(0,R.useState)(`all`),[w,E]=(0,R.useState)([]),k=(0,R.useMemo)(()=>({q:g,decision:_===`all`?``:_,decidedBy:b===`all`?``:b}),[g,_,b]),j=D(()=>T.get(`/hitl/logs`,{page:o,pageSize:f,...k}),[o,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)(()=>{w.length&&L({title:`批量删除审批日志`,content:`确定删除选中的 ${w.length} 条审批日志?此操作不可恢复。`,okText:a(`common.delete`,null,`删除`),onOk:async()=>{try{await T.del(`/hitl/logs`,{body:{ids:w}}),I(`已删除 ${w.length} 条审批日志`),E([]),z()}catch(e){O(e,`批量删除审批日志失败`)}}})},[z,w,a]),B=(0,R.useCallback)(()=>{L({title:a(`hitl.clearAll`,null,`清空审计日志`),content:g||_!==`all`||b!==`all`?`将清空当前筛选条件下的全部已裁决日志(不会删除待审批项)。`:`将清空全部已裁决审批日志(不会删除待审批项)。`,okText:a(`hitl.clearAll`,null,`清空`),onOk:async()=>{try{await T.del(`/hitl/logs`,{query:k,body:{all:!0}}),I(`审批日志已清空`),E([]),u(1),z()}catch(e){O(e,`清空审批日志失败`)}}})},[b,_,g,k,z,a]),V=[{title:a(`hitl.colTool`,null,`工具`),dataIndex:`toolName`,width:220,ellipsis:!0,render:e=>(0,Z.jsx)(`span`,{className:`hitl-mono hitl-ellipsis`,title:e||``,children:e||`—`})},{title:a(`hitl.colConversation`,null,`会话`),dataIndex:`conversationId`,width:200,render:e=>(0,Z.jsx)(`span`,{className:`hitl-mono hitl-ellipsis`,title:e||``,children:e||`—`})},{title:a(`hitl.colDecision`,null,`决策`),dataIndex:`decision`,width:100,render:e=>(0,Z.jsx)(c,{size:`small`,color:q(e),children:K(e)})},{title:a(`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:a(`hitl.colTime`,null,`时间`),dataIndex:`decidedAt`,width:180,render:(e,t)=>Y(e||t.createdAt)},{title:a(`common.actions`,null,`操作`),dataIndex:`id`,width:90,render:e=>(0,Z.jsx)(l,{size:`small`,theme:`borderless`,onClick:()=>n(e),children:a(`common.view`,null,`详情`)})}],H={currentPage:o,pageSize:f,total:N,showSizeChanger:!0,pageSizeOpts:[20,50,100],showTotal:!0,onPageChange:e=>u(e),onPageSizeChange:e=>{p(e),u(1)}};return(0,Z.jsxs)(`div`,{className:`hitl-logs-panel`,children:[F>0&&(0,Z.jsx)(`p`,{className:`hitl-retention-hint`,children:a(`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`,scroll:{x:1280},emptyText:a(`hitl.logsEmpty`,null,`暂无审批日志`),rowSelection:{selectedRowKeys:w,onChange:e=>E(e||[])},toolbar:(0,Z.jsxs)(s,{spacing:8,wrap:!0,children:[(0,Z.jsx)(d,{showClear:!0,style:{width:220},value:m,placeholder:a(`hitl.searchPlaceholder`,null,`搜索工具、会话或载荷…`),onChange:e=>{h(e),u(1)}}),(0,Z.jsx)(x,{value:_,style:{width:120},optionList:[{value:`all`,label:a(`hitl.filterAll`,null,`全部`)},{value:`approve`,label:a(`hitl.decisionApprove`,null,`通过`)},{value:`reject`,label:a(`hitl.decisionReject`,null,`拒绝`)}],onChange:e=>{v(e),u(1)}}),(0,Z.jsx)(x,{value:b,style:{width:150},optionList:[{value:`all`,label:a(`hitl.filterAll`,null,`全部`)},{value:`human`,label:a(`hitl.reviewerHuman`,null,`人工`)},{value:`audit_agent`,label:a(`hitl.reviewerAgent`,null,`审计 Agent`)},{value:`system`,label:a(`hitl.reviewerSystem`,null,`系统`)},{value:`manual`,label:a(`hitl.reviewerManual`,null,`手动录入`)}],onChange:e=>{S(e),u(1)}}),(0,Z.jsx)(l,{icon:(0,Z.jsx)(y,{}),theme:`borderless`,size:`small`,onClick:z,loading:j.loading,children:a(`common.refresh`,null,`刷新`)}),(0,Z.jsxs)(l,{size:`small`,type:`danger`,theme:`borderless`,disabled:!e||!w.length,onClick:te,children:[`批量删除`,w.length?`(${w.length})`:``]}),(0,Z.jsx)(l,{size:`small`,type:`danger`,theme:`borderless`,disabled:!e||!N,onClick:B,children:a(`hitl.clearAll`,null,`清空`)})]})}),(0,Z.jsx)(pe,{logId:t,onClose:r})]})}var{Text:he}=o;function ge({canWrite:e,refreshKey:t=0}){let n=C(),{data:r,loading:i,error:a,reload:o}=D(()=>T.get(`/hitl/tool-whitelist`),[t]),[d,f]=(0,R.useState)(``),[p,m]=(0,R.useState)(``);(0,R.useEffect)(()=>{r&&f((r.toolWhitelist||[]).join(`
`))},[r]);let h=(0,R.useMemo)(()=>ce(d),[d]),g=(0,R.useMemo)(()=>(r?.toolWhitelist||[]).join(`
`),[r]),_=d.trim()!==g.trim(),v=(0,R.useCallback)(async()=>{m(`put`);try{let e=await T.put(`/hitl/tool-whitelist`,{toolWhitelist:h});I(n(`hitl.whitelistSaved`,null,`白名单已保存`)),f((e?.toolWhitelist||h).join(`
`)),o({silent:!0})}catch(e){O(e,n(`hitl.whitelistSaveFailed`,null,`保存白名单失败`))}finally{m(``)}},[o,n,h]),b=(0,R.useCallback)(async()=>{m(`post`);try{let e=await T.post(`/hitl/tool-whitelist`,{sensitiveTools:h});I(e?.hitlGlobalWhitelistMerged?`已合并到全局白名单`:`没有新增工具,白名单未变化`),f((e?.hitlGlobalToolWhitelist||h).join(`
diff --git a/web/static/app/assets/index-DNMXun-U.js b/web/static/app/assets/index-C6SML8F9.js
similarity index 96%
rename from web/static/app/assets/index-DNMXun-U.js
rename to web/static/app/assets/index-C6SML8F9.js
index e87e36f9..ffe68686 100644
--- a/web/static/app/assets/index-DNMXun-U.js
+++ b/web/static/app/assets/index-C6SML8F9.js
@@ -1,4 +1,4 @@
-const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dashboard-Dwi74cCO.js","assets/rolldown-runtime-WkwZ5CU-.js","assets/react-QV7DAAIx.js","assets/semi-65W_4I1v.js","assets/semi-BUXPdXzR.css","assets/dashboard-Dk6QMmtm.css","assets/chat-iFaq7TmY.js","assets/retest-EzTZPjnQ.js","assets/agent-handoff-DzQOcr38.js","assets/project-form-B7wV5B1p.js","assets/model-channel-mQ6lfvSO.js","assets/project-options-CMQbwv_U.js","assets/chat-B_1ruiFc.css","assets/deep-assessments-BwHg6NCr.js","assets/graph-parents-i1hc3RVG.js","assets/graph-parents-BbkuhUnk.css","assets/deep-assessments-BVUI7zDD.css","assets/hitl-hVYHftcD.js","assets/hitl-BqmzzDjt.css","assets/tool-guard-DY35NYks.js","assets/tool-guard-DKIWLN1V.css","assets/projects-CfcDnjFh.js","assets/AssetEditorModal-C2UJzIaS.js","assets/assetTarget-D2PEjBAg.js","assets/projects-CCzxY6zz.css","assets/asset-overview-ClxkP_Uu.js","assets/AssetBits-DtqSAj0f.js","assets/asset-overview-DEMYiRVr.css","assets/asset-library-Btn_YOu0.js","assets/asset-library-a5Vth3JU.css","assets/info-collect-CIMK0OyE.js","assets/info-collect-BrIcieOX.css","assets/vulnerabilities-BRH58_rp.js","assets/vulnerabilities-BPt2JmiL.css","assets/tasks-C9yzz-_n.js","assets/tasks-BtBBHKoW.css","assets/workflows-BgrBtPdj.js","assets/workflows-EsKm07MV.css","assets/webshell-CE6Yp5FY.js","assets/webshell-BdcYpY5u.css","assets/c2-listeners-7rFR5Rx6.js","assets/c2-shared-2EAlkwn6.js","assets/c2-shared-B-Nz9eUh.css","assets/c2-shared-BrRxH-6B.js","assets/c2-listeners-KjhK45yg.css","assets/c2-sessions-CnBIfRAo.js","assets/c2-sessions-DLf_n8Eq.css","assets/c2-tasks-FVvnpyKj.js","assets/c2-tasks-B5H34xZF.css","assets/c2-payloads-DP3Iw5IZ.js","assets/c2-payloads-CnRJmaJm.css","assets/c2-events-Cdd7cKs8.js","assets/c2-events-BVd4qqKy.css","assets/c2-profiles-Cxv9lUnu.js","assets/c2-profiles-BpNJlhDC.css","assets/chat-files-BvkWbj5T.js","assets/chat-files-wKL7Vwmw.css","assets/plugin-hub-BhSjc1VJ.js","assets/plugin-hub-Yl4AUy33.css","assets/mcp-monitor-DHXOIA-R.js","assets/mcp-monitor-8VvqmnVY.css","assets/mcp-management-Be2zIK90.js","assets/mcp-management-CEr7J00D.css","assets/knowledge-retrieval-logs-CJolZ5T-.js","assets/knowledge-management-DxjSMTdf.js","assets/skills-monitor-Bs5yNZYW.js","assets/skills-management-CBXR8d2s.js","assets/agents-management-BH4GA4Vt.js","assets/roles-management-DZI3VXhR.js","assets/roles-management-CAkb5FLz.css","assets/platform-rbac-BDY_zjz7.js","assets/settings-CgtfKueL.js","assets/settings-Cjg19I8_.css","assets/api-docs-BqzLMZ8q.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-D3YYrEQG.js","assets/rolldown-runtime-WkwZ5CU-.js","assets/react-QV7DAAIx.js","assets/semi-65W_4I1v.js","assets/semi-BUXPdXzR.css","assets/dashboard-Dk6QMmtm.css","assets/chat-B-fLwI2m.js","assets/retest-EzTZPjnQ.js","assets/agent-handoff-DzQOcr38.js","assets/project-form-BPnSRCJ9.js","assets/model-channel-mQ6lfvSO.js","assets/project-options-CMQbwv_U.js","assets/chat-B_1ruiFc.css","assets/deep-assessments-Cg3s64GH.js","assets/graph-parents-i1hc3RVG.js","assets/graph-parents-BbkuhUnk.css","assets/deep-assessments-B2LO_dHI.css","assets/hitl-CF6Z_-AR.js","assets/hitl-BqmzzDjt.css","assets/tool-guard-BOS4xdI9.js","assets/tool-guard-DKIWLN1V.css","assets/projects-DO6sc5TZ.js","assets/AssetEditorModal-DXka8uV0.js","assets/assetTarget-D2PEjBAg.js","assets/projects-CCzxY6zz.css","assets/asset-overview-BcLhuN5N.js","assets/AssetBits-DtqSAj0f.js","assets/asset-overview-DEMYiRVr.css","assets/asset-library-C9rUcWZc.js","assets/asset-library-a5Vth3JU.css","assets/info-collect-BdP-r6vN.js","assets/info-collect-BrIcieOX.css","assets/vulnerabilities-D-hL6obf.js","assets/vulnerabilities-BPt2JmiL.css","assets/tasks-BUDTyjuF.js","assets/tasks-BtBBHKoW.css","assets/workflows-zciW-yQT.js","assets/workflows-EsKm07MV.css","assets/webshell-DoNqmx5Y.js","assets/webshell-BdcYpY5u.css","assets/c2-listeners-CBuexYp6.js","assets/c2-shared-u6LJyEH4.js","assets/c2-shared-B-Nz9eUh.css","assets/c2-shared-GD1-MSK1.js","assets/c2-listeners-KjhK45yg.css","assets/c2-sessions-CQrw5arR.js","assets/c2-sessions-DLf_n8Eq.css","assets/c2-tasks-CRV-zYmi.js","assets/c2-tasks-B5H34xZF.css","assets/c2-payloads-CeftlKeV.js","assets/c2-payloads-CnRJmaJm.css","assets/c2-events-DoDJNoh7.js","assets/c2-events-BVd4qqKy.css","assets/c2-profiles-B7r-ajzx.js","assets/c2-profiles-BpNJlhDC.css","assets/chat-files-2SCIFZPr.js","assets/chat-files-wKL7Vwmw.css","assets/plugin-hub-B9IOjQeV.js","assets/plugin-hub-Yl4AUy33.css","assets/mcp-monitor-BBgO0bi_.js","assets/mcp-monitor-8VvqmnVY.css","assets/mcp-management-Dzi9sfWj.js","assets/mcp-management-CEr7J00D.css","assets/knowledge-retrieval-logs-DsoomepS.js","assets/knowledge-management-D5hNJXHy.js","assets/skills-monitor-BpZNfmmT.js","assets/skills-management-BvH4x8cd.js","assets/agents-management-CWCuLnSr.js","assets/roles-management-BLW3MY-d.js","assets/roles-management-CAkb5FLz.css","assets/platform-rbac-C1FSA_3V.js","assets/settings-BldykdDI.js","assets/settings-Cjg19I8_.css","assets/api-docs-DaKtgf05.js","assets/api-docs-B_T3BEfL.css"])))=>i.map(i=>d[i]);
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{$t as t,A as n,At as r,B as i,Ct as a,E as o,F as s,G as c,Gt as l,H as u,Ht as d,I as f,J as p,Jt as m,K as h,Kt as g,L as _,M as ee,N as te,Nt as ne,O as v,Qt as y,R as b,Rt as x,St as re,T as ie,Tt as S,Ut as ae,V as oe,W as se,Wt as ce,Xt as le,Y as ue,Yt as de,Zt as fe,an as pe,at as me,b as he,bt as ge,dt as _e,et as ve,ht as ye,i as C,kt as be,n as xe,nt as Se,o as Ce,ot as we,p as Te,r as Ee,rn as De,st as Oe,t as w,u as ke,ut as T,vt as Ae,w as E,wt as je,z as Me,zt as Ne}from"./semi-65W_4I1v.js";import{S as Pe,b as Fe,d as Ie,f as Le,g as D,h as Re,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 O=e(Pe(),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,Ye=null;function Xe(e){Je=e||null}function Ze(){return Je}function Qe(e,t){let n=Ye;Ye=e||null;try{return t()}finally{Ye=n}}var k=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 $e(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 et(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 A(e,t={}){let{method:n=`GET`,body:r,query:i,headers:a={},signal:o,raw:s=!1,timeout:c=6e4}=t,l=o===void 0?n.toUpperCase()===`GET`?Ye:void 0:o,u={Accept:`application/json`,...a},d=r;r!=null&&!(r instanceof FormData)&&typeof r!=`string`&&!(r instanceof Blob)&&(u[`Content-Type`]=`application/json`,d=JSON.stringify(r)),Je&&!u.Authorization&&(u.Authorization=`Bearer ${Je}`);let f=new AbortController,p=c?setTimeout(()=>f.abort(),c):null,m=()=>f.abort();l&&(l.aborted?f.abort():l.addEventListener(`abort`,m,{once:!0}));let h;try{h=await fetch($e(e,i),{method:n,headers:u,body:d,signal:f.signal})}catch(t){throw t.name===`AbortError`?new k(`请求已取消`,{path:e}):new k(`网络连接失败,请检查服务状态`,{path:e})}finally{p&&clearTimeout(p),l&&l.removeEventListener(`abort`,m)}if(h.status===401&&window.dispatchEvent(new CustomEvent(`csai:unauthorized`)),!h.ok){let{message:t,payload:n}=await et(h);throw new k(t,{status:h.status,payload:n,path:e})}return s?h:h.status===204?null:(h.headers.get(`content-type`)||``).includes(`application/json`)?h.json():h.text()}var j={get:(e,t,n={})=>A(e,{...n,query:t}),post:(e,t,n={})=>A(e,{...n,method:`POST`,body:t}),put:(e,t,n={})=>A(e,{...n,method:`PUT`,body:t}),patch:(e,t,n={})=>A(e,{...n,method:`PATCH`,body:t}),del:(e,t={})=>A(e,{...t,method:`DELETE`}),raw:(e,t={})=>A(e,{...t,raw:!0})};async function tt(e,{query:t,filename:n,method:r=`GET`,body:i}={}){let a=await A(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 nt(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($e(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 et(r);throw new k(t,{status:r.status,path:e})}if(!r.body)throw new k(`服务端未返回流式响应`,{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 rt(e,t=`操作失败`){return e?typeof e==`string`?e:e.message||t:t}var M=e(He(),1),it=(0,O.createContext)(null);function at(e,t){return e?{token:t||e.token,expiresAt:e.expires_at||e.expiresAt||``,appVersion:typeof e.app_version==`string`?e.app_version.trim():``,user:e.user||null,roles:Array.isArray(e.roles)?e.roles:[],permissions:Array.isArray(e.permissions)?e.permissions:[],scope:e.scope||``}:null}function ot({children:e}){let t=(0,O.useRef)(Ke()).current,[n,r]=(0,O.useState)(t),[i,a]=(0,O.useState)(!!t);(0,O.useEffect)(()=>{if(Xe(t?.token||null),!t?.token){a(!1);return}let e=!1;return j.get(`/auth/validate`).then(n=>{if(e)return;let i=at(n,t.token);r(i),qe(i)}).catch(()=>{e||(r(null),qe(null),Xe(null))}).finally(()=>{e||a(!1)}),()=>{e=!0}},[]);let o=(0,O.useCallback)(()=>{r(null),Xe(null),qe(null)},[]);(0,O.useEffect)(()=>{let e=()=>o();return window.addEventListener(`csai:unauthorized`,e),()=>window.removeEventListener(`csai:unauthorized`,e)},[o]);let s=(0,O.useCallback)(async(e,t)=>{let n=await j.post(`/auth/login`,{username:String(e||``).trim(),password:t}),i=at(n,n?.token);return Xe(i?.token||null),qe(i),r(i),i},[]),c=(0,O.useCallback)(async()=>{try{await j.post(`/auth/logout`,{})}catch{}o()},[o]),l=(0,O.useMemo)(()=>new Set(n?.permissions||[]),[n]),u=(0,O.useCallback)(e=>!e||String(e).split(/\s+/).some(e=>l.has(e)),[l]),d=(0,O.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,O.useCallback)(async()=>{if(!n?.token)return null;let e=at(await j.get(`/auth/validate`),n.token);return r(e),qe(e),e},[n?.token]),p=(0,O.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,M.jsx)(it.Provider,{value:p,children:e})}function st(){let e=(0,O.useContext)(it);if(!e)throw Error(`useAuth 必须在 AuthProvider 内使用`);return e}var ct=[{id:`zh-CN`,label:`简体中文`},{id:`en-US`,label:`English`},{id:`ru-RU`,label:`Русский`},{id:`ar-SA`,label:`العربية`}],lt=`csai_lang`,ut=`zh-CN`,dt=`/static/i18n`,ft=new Map;function pt(){try{let e=localStorage.getItem(lt);if(e&&ct.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`:ut}function mt(e){return ft.has(e)||ft.set(e,fetch(`${dt}/${e}.json`,{cache:`no-cache`}).then(e=>e.ok?e.json():{}).catch(()=>({}))),ft.get(e)}function ht(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 N(e,t){return t?e.replace(/\{\{\s*(\w+)\s*\}\}/g,(e,n)=>t[n]===void 0?e:String(t[n])):e}var gt=(0,O.createContext)({lang:ut,t:e=>e,ready:!1,setLanguage:()=>{}});function _t({children:e}){let[t,n]=(0,O.useState)(pt),[r,i]=(0,O.useState)({}),[a,o]=(0,O.useState)(!1);(0,O.useEffect)(()=>{let e=!1;Promise.all([mt(t),mt(ut),mt(`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(lt,t)}catch{}return()=>{e=!0}},[t]);let s=(0,O.useCallback)((e,t,n)=>{if(!e)return n??``;let i=ht(r.current,e)??ht(r.fallback,e)??ht(r.english,e);return i===void 0?n??e:N(i,t)},[r]),c=(0,O.useCallback)(e=>{e&&e!==t&&(o(!1),n(e),window.dispatchEvent(new CustomEvent(`csai:languagechange`,{detail:{lang:e}})))},[t]),l=(0,O.useMemo)(()=>({lang:t,t:s,ready:a,setLanguage:c}),[t,s,a,c]);return(0,M.jsx)(gt.Provider,{value:l,children:e})}function vt(){return(0,O.useContext)(gt)}function P(){return(0,O.useContext)(gt).t}var yt=`cyberstrike-theme`,bt=[`system`,`light`,`dark`];function xt(){try{let e=localStorage.getItem(yt);return bt.includes(e)?e:`system`}catch{return`system`}}function St(){return typeof window<`u`&&window.matchMedia?window.matchMedia(`(prefers-color-scheme: dark)`).matches:!1}function Ct(e){return e===`dark`||e===`light`?e:St()?`dark`:`light`}function wt(e){let t=Ct(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 F=(0,O.createContext)({preference:`system`,theme:`light`,setPreference:()=>{},toggle:()=>{}});function Tt({children:e}){let[t,n]=(0,O.useState)(xt),[r,i]=(0,O.useState)(()=>Ct(xt()));(0,O.useLayoutEffect)(()=>{i(wt(t));try{localStorage.setItem(yt,t)}catch{}if(t!==`system`||!window.matchMedia)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>i(wt(t));return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[t]),(0,O.useEffect)(()=>{document.body?.setAttribute(`theme-mode`,r===`dark`?`dark`:`light`)},[r]);let a=(0,O.useCallback)(e=>{bt.includes(e)&&n(e)},[]),o=(0,O.useCallback)(()=>{n(e=>Ct(e)===`dark`?`light`:`dark`)},[]),s=(0,O.useMemo)(()=>({preference:t,theme:r,setPreference:a,toggle:o}),[t,r,a,o]);return(0,M.jsx)(F.Provider,{value:s,children:e})}function Et(){return(0,O.useContext)(F)}var Dt=[{id:`dashboard`,i18n:`nav.dashboard`,fallback:`仪表盘`,icon:S},{id:`chat`,i18n:`nav.chat`,fallback:`对话`,icon:Ne},{id:`deep-assessments`,i18n:`nav.deepAssessments`,fallback:`深度测评`,icon:t},{id:`security`,i18n:`nav.security`,fallback:`安全防护`,icon:me,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:m},{id:`assets`,i18n:`nav.assets`,fallback:`资产管理`,icon:r,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:me},{id:`tasks`,i18n:`nav.tasks`,fallback:`任务管理`,icon:g},{id:`workflows`,i18n:`nav.workflows`,fallback:`工作流`,icon:de},{id:`webshell`,i18n:`nav.webshell`,fallback:`WebShell管理`,icon:ve},{id:`c2`,i18n:`nav.c2`,fallback:`C2`,icon:fe,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:`plugin-hub`,i18n:`nav.pluginHub`,fallback:`能力平台`,icon:De,permission:`plugins:read`},{id:`mcp`,i18n:`nav.mcp`,fallback:`MCP`,icon:Oe,children:[{id:`mcp-monitor`,i18n:`nav.mcpMonitor`,fallback:`MCP状态监控`},{id:`mcp-management`,i18n:`nav.mcpManagement`,fallback:`MCP管理`}]},{id:`knowledge`,i18n:`nav.knowledge`,fallback:`知识`,icon:le,children:[{id:`knowledge-retrieval-logs`,i18n:`nav.knowledgeRetrievalLogs`,fallback:`检索历史`},{id:`knowledge-management`,i18n:`nav.knowledgeManagement`,fallback:`知识管理`}]},{id:`skills`,i18n:`nav.skills`,fallback:`技能`,icon:_e,children:[{id:`skills-monitor`,i18n:`nav.skillsMonitor`,fallback:`技能状态`},{id:`skills-management`,i18n:`nav.skillsManagement`,fallback:`技能管理`}]},{id:`agents`,i18n:`nav.agents`,fallback:`智能体`,icon:p,children:[{id:`agents-management`,i18n:`nav.agentsManagement`,fallback:`智能体管理`}]},{id:`roles`,i18n:`nav.roles`,fallback:`角色`,icon:ue,children:[{id:`roles-management`,i18n:`nav.rolesManagement`,fallback:`角色管理`}]},{id:`platform-rbac`,i18n:`nav.platformRbac`,fallback:`平台权限`,icon:ge},{id:`settings`,i18n:`nav.settings`,fallback:`系统设置`,icon:we},{id:`api-docs`,i18n:`apiDocs.title`,fallback:`API 文档`,icon:t}],Ot=[{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:[`plugin-hub`,`mcp`,`knowledge`,`skills`,`agents`,`roles`]},{id:`platform`,i18n:`nav.groupPlatform`,fallback:`平台管理`,pages:[`platform-rbac`,`settings`,`api-docs`]}],kt=Dt.flatMap(e=>e.children?e.children.map(t=>({...t,parent:e.id})):[e]);function At(e){return kt.find(t=>t.id===e)||Dt.find(t=>t.id===e)||null}function jt(e){"@babel/helpers - typeof";return jt=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},jt(e)}function Mt(e,t){if(jt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(jt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Nt(e){var t=Mt(e,`string`);return jt(t)==`symbol`?t:t+``}function I(e,t,n){return(t=Nt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Pt;function Ft(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var It=Ft();function Lt(e){It=e}var Rt={exec:()=>null};function L(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(R.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var zt=(()=>{try{return!0}catch{return!1}})(),R={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`)},Bt=/^(?:[ \t]*(?:\n|$))+/,Vt=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Ht=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,z=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ut=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,B=/(?:[*+-]|\d{1,9}[.)])/,Wt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Gt=L(Wt).replace(/bull/g,B).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(),Kt=L(Wt).replace(/bull/g,B).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(),qt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Jt=/^[^\n]+/,Yt=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Xt=L(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Yt).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Zt=L(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,B).getRegex(),Qt=`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`,$t=/|$))/,en=L(`^ {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`,$t).replace(`tag`,Qt).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),tn=L(qt).replace(`hr`,z).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`,Qt).getRegex(),nn={blockquote:L(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,tn).getRegex(),code:Vt,def:Xt,fences:Ht,heading:Ut,hr:z,html:en,lheading:Gt,list:Zt,newline:Bt,paragraph:tn,table:Rt,text:Jt},rn=L(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,z).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`,Qt).getRegex(),an={...nn,lheading:Kt,table:rn,paragraph:L(qt).replace(`hr`,z).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,rn).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`,Qt).getRegex()},on={...nn,html:L(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?\\1> *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,$t).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:Rt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:L(qt).replace(`hr`,z).replace(`heading`,` *#{1,6} *[^
]`).replace(`lheading`,Gt).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},sn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,cn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ln=/^( {2,}|\\)\n(?!\s*$)/,un=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\`+)[^`]+\k(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,zt?"(?`+)[^`]+\k(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),yn=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,bn=L(yn,`u`).replace(/punct/g,dn).getRegex(),xn=L(yn,`u`).replace(/punct/g,hn).getRegex(),Sn=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Cn=L(Sn,`gu`).replace(/notPunctSpace/g,pn).replace(/punctSpace/g,fn).replace(/punct/g,dn).getRegex(),wn=L(Sn,`gu`).replace(/notPunctSpace/g,_n).replace(/punctSpace/g,gn).replace(/punct/g,hn).getRegex(),Tn=L(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,pn).replace(/punctSpace/g,fn).replace(/punct/g,dn).getRegex(),En=L(/\\(punct)/,`gu`).replace(/punct/g,dn).getRegex(),Dn=L(/^<(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(),On=L($t).replace(`(?:-->|$)`,`-->`).getRegex(),kn=L(`^comment|^[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^`).replace(`comment`,On).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),An=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,jn=L(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,An).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Mn=L(/^!?\[(label)\]\[(ref)\]/).replace(`label`,An).replace(`ref`,Yt).getRegex(),Nn=L(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Yt).getRegex(),Pn=L(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Mn).replace(`nolink`,Nn).getRegex(),Fn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,In={_backpedal:Rt,anyPunctuation:En,autolink:Dn,blockSkip:vn,br:ln,code:cn,del:Rt,emStrongLDelim:bn,emStrongRDelimAst:Cn,emStrongRDelimUnd:Tn,escape:sn,link:jn,nolink:Nn,punctuation:mn,reflink:Mn,reflinkSearch:Pn,tag:kn,text:un,url:Rt},Ln={...In,link:L(/^!?\[(label)\]\((.*?)\)/).replace(`label`,An).getRegex(),reflink:L(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,An).getRegex()},Rn={...In,emStrongRDelimAst:wn,emStrongLDelim:xn,url:L(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Fn).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:L(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\":`>`,'"':`"`,"'":`'`},Un=e=>Hn[e];function V(e,t){if(t){if(R.escapeTest.test(e))return e.replace(R.escapeReplace,Un)}else if(R.escapeTestNoEncode.test(e))return e.replace(R.escapeReplaceNoEncode,Un);return e}function Wn(e){try{e=encodeURI(e).replace(R.percentDecode,`%`)}catch{return null}return e}function Gn(e,t){let n=e.replace(R.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(R.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 Jn(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 Yn(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 Zn(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 Xn(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 $n;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]=$n.passThroughHooks.has(n)?e=>{if(this.defaults.async&&$n.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 H.lex(e,t??this.defaults)}parser(e,t){return U.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?H.lex:H.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?U.parse:U.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?H.lex:H.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?U.parse:U.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=`