Merge pull request #431 from Sycun/fix/hitl-audit-log-tool-column

fix(hitl): keep audit log tool names on one line
This commit is contained in:
公明 authored and GitHub committed 2026-11-25 15:42:01 +08:00
commit 9cd50a4fc4
39 files changed
+44 -39

No files matched your search

+4 -1
View File
@@ -152,7 +152,9 @@ export default function LogsPanel({ canWrite, detailId, onOpenDetail, onCloseDet
{
title: t('hitl.colTool', null, '工具'),
dataIndex: 'toolName',
render: value => <span className="hitl-mono">{value || '—'}</span>
width: 220,
ellipsis: true,
render: value => <span className="hitl-mono hitl-ellipsis" title={value || ''}>{value || '—'}</span>
},
{
title: t('hitl.colConversation', null, '会话'),
@@ -230,6 +232,7 @@ export default function LogsPanel({ canWrite, detailId, onOpenDetail, onCloseDet
loading={list.loading}
pagination={pagination}
size="small"
scroll={{ x: 1280 }}
emptyText={t('hitl.logsEmpty', null, '暂无审批日志')}
rowSelection={{
selectedRowKeys: selected,
+2
View File
@@ -99,6 +99,8 @@
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
word-break: normal;
overflow-wrap: normal;
vertical-align: bottom;
}
@@ -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{F as r,L as i,i as a,z as o}from"./semi-CHxO7u8f.js";import{I as s,P as c,R as l,c as u,x as d}from"./index-CuUcClXg.js";import{E as f,a as p,c as m,h,i as g,o as _,p as v,s as y,u as b}from"./assetTarget-D2PEjBAg.js";var x=e(t(),1),S=e(n(),1),C=`asset-library-editor`;function w(e,t){return{target:b(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 T({visible:e,asset:t,defaultProjectId:n=``,fixedProject:T=!1,projects:E,onClose:D,onSaved:O}){let k=c(),[A,j]=(0,x.useState)(null),[M,N]=(0,x.useState)(!1),[P,F]=(0,x.useState)(``),I=(0,x.useRef)(b(t)),L=(0,x.useMemo)(()=>w(t,n),[t,n,e]),R=!!t?.id;(0,x.useEffect)(()=>{e&&(I.current=b(t),F(``),N(!1))},[e,t]);let z=(0,x.useMemo)(()=>(E||[]).map(e=>({value:e.id,label:e.name||e.id})),[E]),B=e=>{if(!A)return null;let t=String(A.getValue(`target`)||``).trim();try{let e=y(t);return A.setValues({host:e.host,ip:e.ip,domain:e.domain,port:e.port||void 0,protocol:e.protocol}),I.current=t,e}catch(t){return e&&F(t.message),null}},V=()=>{let e=A.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!==I.current)try{let e=y(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},H=()=>{let e=m(A.getValue(`targets`));if(!e.length)throw Error(k(`assets.targetRequired`,null,`请输入资产地址`));if(e.length>200)throw Error(`一次最多添加 200 个地址`);let t=T?n:A.getValue(`project_id`)||``;return e.map(e=>{let n=y(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:[]}})},U=async()=>{if(M||!A)return;F(``);try{await A.validate()}catch{return}let e,n;try{R?e=V():n=H()}catch(e){F(e.message);return}N(!0);try{if(R)await s.put(`/assets/${encodeURIComponent(t.id)}`,e),d(k(`assets.updatedSuccessfully`,null,`资产已更新`));else{let e=await s.post(`/assets/import`,{assets:n,source:`manual`}),t=Number(e?.created||0),r=Number(e?.updated||0),i=Number(e?.skipped||0);if(!t&&!r&&i)throw Error(k(`assets.assetSkipped`,null,`资产未保存,可能已存在且你没有更新权限`));let a=[];t&&a.push(`新增 ${t}`),r&&a.push(`合并 ${r}`),i&&a.push(`跳过 ${i}`),d(a.length?`已写入资产库:${a.join(`,`)}`:k(`assets.createdSuccessfully`,null,`资产已添加`))}O?.(),D?.()}catch(e){F(l(e,k(`assets.saveFailed`,null,`保存资产失败`)))}finally{N(!1)}};return(0,S.jsxs)(u,{visible:e,title:R?k(`assets.editAssetTitle`,null,`编辑资产`):k(`assets.addAssetTitle`,null,`新增资产`),width:R?760:520,onCancel:D,onOk:U,okText:R?k(`common.save`,null,`保存`):k(`assets.addAssetAction`,null,`添加资产`),confirmLoading:M,closeOnEsc:!0,children:[P&&(0,S.jsx)(o,{type:`danger`,bordered:!0,closeIcon:null,description:P,className:`asset-library-form-error`}),(0,S.jsx)(a,{className:C,initValues:L,getFormApi:j,labelPosition:`top`,onSubmit:U,children:R?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`asset-library-form-grid asset-library-form-grid--full`,children:(0,S.jsx)(a.Input,{field:`target`,label:k(`assets.assetAddress`,null,`资产地址`),placeholder:`https://example.com:443 / example.com / 1.1.1.1:22`,helpText:k(`assets.assetAddressHint`,null,`可识别的 URL、域名、IP 和端口会自动解析`),onBlur:()=>B(!0),rules:[{required:!0,message:k(`assets.targetRequired`,null,`请输入资产地址`)},{validator:(e,t,n)=>{try{y(t),n()}catch(e){n(Error(e.message))}}}]})}),(0,S.jsxs)(`div`,{className:`asset-library-form-grid`,children:[(0,S.jsx)(a.Input,{field:`host`,label:k(`assets.hostUrl`,null,`完整 URL / Host`)}),(0,S.jsx)(a.Input,{field:`ip`,label:`IP`,rules:[{validator:(e,t,n)=>{!t||Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,L as i,i as a,z as o}from"./semi-CHxO7u8f.js";import{I as s,P as c,R as l,c as u,x as d}from"./index-BLFHsWWk.js";import{E as f,a as p,c as m,h,i as g,o as _,p as v,s as y,u as b}from"./assetTarget-D2PEjBAg.js";var x=e(t(),1),S=e(n(),1),C=`asset-library-editor`;function w(e,t){return{target:b(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 T({visible:e,asset:t,defaultProjectId:n=``,fixedProject:T=!1,projects:E,onClose:D,onSaved:O}){let k=c(),[A,j]=(0,x.useState)(null),[M,N]=(0,x.useState)(!1),[P,F]=(0,x.useState)(``),I=(0,x.useRef)(b(t)),L=(0,x.useMemo)(()=>w(t,n),[t,n,e]),R=!!t?.id;(0,x.useEffect)(()=>{e&&(I.current=b(t),F(``),N(!1))},[e,t]);let z=(0,x.useMemo)(()=>(E||[]).map(e=>({value:e.id,label:e.name||e.id})),[E]),B=e=>{if(!A)return null;let t=String(A.getValue(`target`)||``).trim();try{let e=y(t);return A.setValues({host:e.host,ip:e.ip,domain:e.domain,port:e.port||void 0,protocol:e.protocol}),I.current=t,e}catch(t){return e&&F(t.message),null}},V=()=>{let e=A.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!==I.current)try{let e=y(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},H=()=>{let e=m(A.getValue(`targets`));if(!e.length)throw Error(k(`assets.targetRequired`,null,`请输入资产地址`));if(e.length>200)throw Error(`一次最多添加 200 个地址`);let t=T?n:A.getValue(`project_id`)||``;return e.map(e=>{let n=y(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:[]}})},U=async()=>{if(M||!A)return;F(``);try{await A.validate()}catch{return}let e,n;try{R?e=V():n=H()}catch(e){F(e.message);return}N(!0);try{if(R)await s.put(`/assets/${encodeURIComponent(t.id)}`,e),d(k(`assets.updatedSuccessfully`,null,`资产已更新`));else{let e=await s.post(`/assets/import`,{assets:n,source:`manual`}),t=Number(e?.created||0),r=Number(e?.updated||0),i=Number(e?.skipped||0);if(!t&&!r&&i)throw Error(k(`assets.assetSkipped`,null,`资产未保存,可能已存在且你没有更新权限`));let a=[];t&&a.push(`新增 ${t}`),r&&a.push(`合并 ${r}`),i&&a.push(`跳过 ${i}`),d(a.length?`已写入资产库:${a.join(`,`)}`:k(`assets.createdSuccessfully`,null,`资产已添加`))}O?.(),D?.()}catch(e){F(l(e,k(`assets.saveFailed`,null,`保存资产失败`)))}finally{N(!1)}};return(0,S.jsxs)(u,{visible:e,title:R?k(`assets.editAssetTitle`,null,`编辑资产`):k(`assets.addAssetTitle`,null,`新增资产`),width:R?760:520,onCancel:D,onOk:U,okText:R?k(`common.save`,null,`保存`):k(`assets.addAssetAction`,null,`添加资产`),confirmLoading:M,closeOnEsc:!0,children:[P&&(0,S.jsx)(o,{type:`danger`,bordered:!0,closeIcon:null,description:P,className:`asset-library-form-error`}),(0,S.jsx)(a,{className:C,initValues:L,getFormApi:j,labelPosition:`top`,onSubmit:U,children:R?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`asset-library-form-grid asset-library-form-grid--full`,children:(0,S.jsx)(a.Input,{field:`target`,label:k(`assets.assetAddress`,null,`资产地址`),placeholder:`https://example.com:443 / example.com / 1.1.1.1:22`,helpText:k(`assets.assetAddressHint`,null,`可识别的 URL、域名、IP 和端口会自动解析`),onBlur:()=>B(!0),rules:[{required:!0,message:k(`assets.targetRequired`,null,`请输入资产地址`)},{validator:(e,t,n)=>{try{y(t),n()}catch(e){n(Error(e.message))}}}]})}),(0,S.jsxs)(`div`,{className:`asset-library-form-grid`,children:[(0,S.jsx)(a.Input,{field:`host`,label:k(`assets.hostUrl`,null,`完整 URL / Host`)}),(0,S.jsx)(a.Input,{field:`ip`,label:`IP`,rules:[{validator:(e,t,n)=>{!t||Line truncated
example.com:443
1.1.1.1:22`,helpText:`每行一个,或用空格、逗号隔开。直接粘贴 URL、域名或 IP:端口。`,rules:[{required:!0,validator:(e,t,n)=>{let r=m(t);if(!r.length)n(Error(k(`assets.targetRequired`,null,`请输入资产地址`)));else{for(let e of r)try{y(e)}catch(t){n(Error(`${e}:${t.message}`));return}n()}}}]}),(0,S.jsx)(a.Select,{field:`project_id`,label:k(`assets.project`,null,`所属项目`),optionList:z,disabled:T,filter:!0,showClear:!T,placeholder:k(`assets.unboundProject`,null,`暂不绑定`),style:{width:`100%`}})]})},`${t?.id||`new-asset`}-${e?`open`:`closed`}`)]})}export{T as t};
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,ot as c,st as l}from"./semi-CHxO7u8f.js";import{I as u,P as d,a as f,b as p,c as m,d as h,f as g,l as _,m as v,p as y,s as b,u as x}from"./index-CuUcClXg.js";var S=e(t(),1),C=e(n(),1),{Text:w}=s;function T(){let e=d(),[t,n]=(0,S.useState)(``),[s,T]=(0,S.useState)(null),E=f(()=>u.get(`/multi-agent/markdown-agents`),[]),D=(Array.isArray(E.data?.agents)?E.data.agents:[]).filter(e=>{if(!t)return!0;let n=t.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(n))}),O=async e=>{try{T(await u.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){p(e,`读取智能体失败`)}};return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(y,{title:e(`agents.title`,null,`智能体管理`),description:E.data?.dir?`目录:${E.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,C.jsx)(a,{icon:(0,C.jsx)(l,{}),onClick:()=>E.reload(),loading:E.loading,children:`刷新`})}),E.data?.error&&(0,C.jsx)(_,{error:E.data.error}),(0,C.jsxs)(v,{title:`智能体(${D.length})`,children:[(0,C.jsx)(_,{error:E.error,onRetry:()=>E.reload()}),(0,C.jsx)(b,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,C.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,C.jsxs)(r,{children:[(0,C.jsx)(w,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,C.jsx)(o,{size:`small`,color:`purple`,children:`编排器`})]}),(0,C.jsx)(w,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,C.jsx)(o,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,C.jsx)(w,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,C.jsx)(r,{children:(0,C.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>O(t),children:`详情`})})}],dataSource:D,rowKey:`filename`,loading:E.loading,pagination:{pageSize:20},toolbar:(0,C.jsx)(i,{prefix:(0,C.jsx)(c,{}),value:t,onChange:n,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,C.jsx)(m,{title:s?.name||`智能体详情`,visible:!!s,onCancel:()=>T(null),width:720,children:s&&(0,C.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,C.jsx)(h,{items:[{label:`文件名`,value:s.filename},{label:`ID`,value:s.id},{label:`类型`,value:s.kind},{label:`绑定角色`,value:s.bind_role||`—`},{label:`最大迭代`,value:s.max_iterations??`—`},{label:`工具`,value:Array.isArray(s.tools)&&s.tools.length?s.tools.join(`、`):`—`}]}),(0,C.jsx)(g,{content:s.instruction||s.raw||``}),(0,C.jsx)(x,{value:s.raw||s,title:`原始 Markdown`,collapsed:!0})]})})]})}export{T as default};
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,ot as c,st as l}from"./semi-CHxO7u8f.js";import{I as u,P as d,a as f,b as p,c as m,d as h,f as g,l as _,m as v,p as y,s as b,u as x}from"./index-BLFHsWWk.js";var S=e(t(),1),C=e(n(),1),{Text:w}=s;function T(){let e=d(),[t,n]=(0,S.useState)(``),[s,T]=(0,S.useState)(null),E=f(()=>u.get(`/multi-agent/markdown-agents`),[]),D=(Array.isArray(E.data?.agents)?E.data.agents:[]).filter(e=>{if(!t)return!0;let n=t.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(n))}),O=async e=>{try{T(await u.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){p(e,`读取智能体失败`)}};return(0,C.jsxs)(`div`,{children:[(0,C.jsx)(y,{title:e(`agents.title`,null,`智能体管理`),description:E.data?.dir?`目录:${E.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,C.jsx)(a,{icon:(0,C.jsx)(l,{}),onClick:()=>E.reload(),loading:E.loading,children:`刷新`})}),E.data?.error&&(0,C.jsx)(_,{error:E.data.error}),(0,C.jsxs)(v,{title:`智能体(${D.length})`,children:[(0,C.jsx)(_,{error:E.error,onRetry:()=>E.reload()}),(0,C.jsx)(b,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,C.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,C.jsxs)(r,{children:[(0,C.jsx)(w,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,C.jsx)(o,{size:`small`,color:`purple`,children:`编排器`})]}),(0,C.jsx)(w,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,C.jsx)(o,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,C.jsx)(w,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,C.jsx)(r,{children:(0,C.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>O(t),children:`详情`})})}],dataSource:D,rowKey:`filename`,loading:E.loading,pagination:{pageSize:20},toolbar:(0,C.jsx)(i,{prefix:(0,C.jsx)(c,{}),value:t,onChange:n,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,C.jsx)(m,{title:s?.name||`智能体详情`,visible:!!s,onCancel:()=>T(null),width:720,children:s&&(0,C.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,C.jsx)(h,{items:[{label:`文件名`,value:s.filename},{label:`ID`,value:s.id},{label:`类型`,value:s.kind},{label:`绑定角色`,value:s.bind_role||`—`},{label:`最大迭代`,value:s.max_iterations??`—`},{label:`工具`,value:Array.isArray(s.tools)&&s.tools.length?s.tools.join(`、`):`—`}]}),(0,C.jsx)(g,{content:s.instruction||s.raw||``}),(0,C.jsx)(x,{value:s.raw||s,title:`原始 Markdown`,collapsed:!0})]})})]})}export{T as default};
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,P as s,W as c,c as l,ot as u,st as d,v as f}from"./semi-CHxO7u8f.js";import{I as p,P as m,R as h,p as g,u as _}from"./index-CuUcClXg.js";var v=e(t(),1),y=e(n(),1),{Text:b,Paragraph:x}=c,S={get:`blue`,post:`green`,put:`orange`,delete:`red`,patch:`violet`,head:`grey`,options:`grey`};function C(e){let t=e?.paths||{},n=[];return Object.entries(t).forEach(([e,t])=>{Object.entries(t||{}).forEach(([t,r])=>{Object.hasOwn(S,t)&&r&&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 w(){let e=m(),[t,n]=(0,v.useState)(null),[c,w]=(0,v.useState)(!0),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(`all`),[j,M]=(0,v.useState)(null),N=async()=>{w(!0),E(null);try{let e=await p.get(`/openapi/spec`);n(e)}catch(e){E(e)}finally{w(!1)}};(0,v.useEffect)(()=>{N()},[]);let P=(0,v.useMemo)(()=>C(t),[t]),F=(0,v.useMemo)(()=>P.filter(e=>{if(k!==`all`&&e.method!==k)return!1;if(!D)return!0;let t=D.toLowerCase();return e.path.toLowerCase().includes(t)||e.summary.toLowerCase().includes(t)||e.method.toLowerCase().includes(t)}),[P,D,k]),I=F.find(e=>e.id===j)||F[0]||null,L=(0,v.useMemo)(()=>{let e=new Map;return F.forEach(t=>{e.has(t.tag)||e.set(t.tag,[]),e.get(t.tag).push(t)}),[...e.entries()]},[F]);return(0,y.jsxs)(`div`,{className:`api-docs-page`,children:[(0,y.jsx)(g,{title:e(`apiDocs.title`,null,`API 文档`),description:t?.info?.description||`CyberStrikeAI 开放接口`,extra:(0,y.jsx)(a,{icon:(0,y.jsx)(d,{}),onClick:N,loading:c,children:e(`common.refresh`,null,`刷新`)})}),(0,y.jsxs)(`div`,{className:`api-docs-layout`,children:[(0,y.jsxs)(s,{className:`api-docs-sidebar`,bordered:!1,children:[(0,y.jsxs)(r,{vertical:!0,style:{width:`100%`},spacing:8,children:[(0,y.jsx)(i,{prefix:(0,y.jsx)(u,{}),value:D,onChange:O,placeholder:`搜索路径或说明`}),(0,y.jsx)(f,{value:k,onChange:A,style:{width:`100%`},optionList:[{value:`all`,label:`全部方法`},...[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`].map(e=>({value:e,label:e}))]})]}),(0,y.jsxs)(`div`,{className:`api-docs-list`,children:[L.map(([e,t])=>(0,y.jsxs)(`div`,{className:`api-docs-group`,children:[(0,y.jsx)(b,{type:`tertiary`,className:`api-docs-group-title`,children:e}),t.map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`api-docs-item ${I?.id===e.id?`is-active`:``}`,onClick:()=>M(e.id),children:[(0,y.jsx)(o,{size:`small`,color:S[e.method.toLowerCase()],children:e.method}),(0,y.jsx)(`span`,{className:`api-docs-item-path`,children:e.path})]},e.id))]},e)),!c&&L.length===0&&(0,y.jsx)(b,{type:`tertiary`,children:`没有匹配的接口`})]})]}),(0,y.jsxs)(`div`,{className:`api-docs-detail`,children:[T&&(0,y.jsx)(s,{bordered:!1,children:(0,y.jsx)(b,{type:`danger`,children:h(T)})}),I?(0,y.jsxs)(s,{bordered:!1,children:[(0,y.jsxs)(`div`,{className:`api-docs-detail-head`,children:[(0,y.jsx)(o,{color:S[I.method.toLowerCase()],children:I.method}),(0,y.jsx)(`code`,{className:`api-docs-detail-path`,children:I.path})]}),(0,y.jsx)(x,{children:I.summary||`无说明`}),(0,y.jsxs)(l,{type:`line`,children:[(0,y.jsx)(l.TabPane,{itemKey:`params`,tab:`参数`,children:(0,y.jsx)(_,{value:I.operation.parameters||[],title:`Request Parameters`,collapsed:!0})}),(0,y.jsx)(l.TabPane,{itemKey:`body`,tab:`请求体`,children:(0,y.jsx)(_,{value:I.operation.requestBody||{},title:`Request Body`,collapsed:!0})}),(0,y.jsx)(l.TabPane,{itemKey:`responses`,tab:`响应`,children:(0,y.jsx)(_,{value:I.operation.responses||{},title:`Responses`,collapsed:!0})})]})]}):(0,y.jsx)(s,{bordered:!1,children:(0,y.jsx)(b,{type:`tertiary`,children:c?`加载中…`:`选择左侧接口查看详情`})})]})]})]})}export{w as default};
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,P as s,W as c,c as l,ot as u,st as d,v as f}from"./semi-CHxO7u8f.js";import{I as p,P as m,R as h,p as g,u as _}from"./index-BLFHsWWk.js";var v=e(t(),1),y=e(n(),1),{Text:b,Paragraph:x}=c,S={get:`blue`,post:`green`,put:`orange`,delete:`red`,patch:`violet`,head:`grey`,options:`grey`};function C(e){let t=e?.paths||{},n=[];return Object.entries(t).forEach(([e,t])=>{Object.entries(t||{}).forEach(([t,r])=>{Object.hasOwn(S,t)&&r&&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 w(){let e=m(),[t,n]=(0,v.useState)(null),[c,w]=(0,v.useState)(!0),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(`all`),[j,M]=(0,v.useState)(null),N=async()=>{w(!0),E(null);try{let e=await p.get(`/openapi/spec`);n(e)}catch(e){E(e)}finally{w(!1)}};(0,v.useEffect)(()=>{N()},[]);let P=(0,v.useMemo)(()=>C(t),[t]),F=(0,v.useMemo)(()=>P.filter(e=>{if(k!==`all`&&e.method!==k)return!1;if(!D)return!0;let t=D.toLowerCase();return e.path.toLowerCase().includes(t)||e.summary.toLowerCase().includes(t)||e.method.toLowerCase().includes(t)}),[P,D,k]),I=F.find(e=>e.id===j)||F[0]||null,L=(0,v.useMemo)(()=>{let e=new Map;return F.forEach(t=>{e.has(t.tag)||e.set(t.tag,[]),e.get(t.tag).push(t)}),[...e.entries()]},[F]);return(0,y.jsxs)(`div`,{className:`api-docs-page`,children:[(0,y.jsx)(g,{title:e(`apiDocs.title`,null,`API 文档`),description:t?.info?.description||`CyberStrikeAI 开放接口`,extra:(0,y.jsx)(a,{icon:(0,y.jsx)(d,{}),onClick:N,loading:c,children:e(`common.refresh`,null,`刷新`)})}),(0,y.jsxs)(`div`,{className:`api-docs-layout`,children:[(0,y.jsxs)(s,{className:`api-docs-sidebar`,bordered:!1,children:[(0,y.jsxs)(r,{vertical:!0,style:{width:`100%`},spacing:8,children:[(0,y.jsx)(i,{prefix:(0,y.jsx)(u,{}),value:D,onChange:O,placeholder:`搜索路径或说明`}),(0,y.jsx)(f,{value:k,onChange:A,style:{width:`100%`},optionList:[{value:`all`,label:`全部方法`},...[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`].map(e=>({value:e,label:e}))]})]}),(0,y.jsxs)(`div`,{className:`api-docs-list`,children:[L.map(([e,t])=>(0,y.jsxs)(`div`,{className:`api-docs-group`,children:[(0,y.jsx)(b,{type:`tertiary`,className:`api-docs-group-title`,children:e}),t.map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`api-docs-item ${I?.id===e.id?`is-active`:``}`,onClick:()=>M(e.id),children:[(0,y.jsx)(o,{size:`small`,color:S[e.method.toLowerCase()],children:e.method}),(0,y.jsx)(`span`,{className:`api-docs-item-path`,children:e.path})]},e.id))]},e)),!c&&L.length===0&&(0,y.jsx)(b,{type:`tertiary`,children:`没有匹配的接口`})]})]}),(0,y.jsxs)(`div`,{className:`api-docs-detail`,children:[T&&(0,y.jsx)(s,{bordered:!1,children:(0,y.jsx)(b,{type:`danger`,children:h(T)})}),I?(0,y.jsxs)(s,{bordered:!1,children:[(0,y.jsxs)(`div`,{className:`api-docs-detail-head`,children:[(0,y.jsx)(o,{color:S[I.method.toLowerCase()],children:I.method}),(0,y.jsx)(`code`,{className:`api-docs-detail-path`,children:I.path})]}),(0,y.jsx)(x,{children:I.summary||`无说明`}),(0,y.jsxs)(l,{type:`line`,children:[(0,y.jsx)(l.TabPane,{itemKey:`params`,tab:`参数`,children:(0,y.jsx)(_,{value:I.operation.parameters||[],title:`Request Parameters`,collapsed:!0})}),(0,y.jsx)(l.TabPane,{itemKey:`body`,tab:`请求体`,children:(0,y.jsx)(_,{value:I.operation.requestBody||{},title:`Request Body`,collapsed:!0})}),(0,y.jsx)(l.TabPane,{itemKey:`responses`,tab:`响应`,children:(0,y.jsx)(_,{value:I.operation.responses||{},title:`Responses`,collapsed:!0})})]})]}):(0,y.jsx)(s,{bordered:!1,children:(0,y.jsx)(b,{type:`tertiary`,children:c?`加载中…`:`选择左侧接口查看详情`})})]})]})]})}export{w as default};
@@ -1,3 +1,3 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,h as r,t as i,y as a}from"./react-QV7DAAIx.js";import{A as o,E as s,F as c,H as l,L as u,Pt as d,W as f,f as p,l as m,lt as h,m as g,ot as _,p as v,st as y,u as b,v as x,x as ee,z as S}from"./semi-CHxO7u8f.js";import{E as C,F as w,I as T,P as E,R as D,S as O,a as te,b as k,c as A,d as j,l as ne,m as re,n as ie,o as ae,p as oe,s as M,x as N,y as se}from"./index-CuUcClXg.js";import{A as ce,C as le,D as ue,E as de,M as fe,O as pe,S as me,T as he,_ as ge,a as _e,b as ve,d as ye,f as be,g as xe,h as P,i as F,k as I,l as L,m as Se,n as Ce,o as R,p as we,r as z,s as Te,t as B,v as V,w as H,y as U}from"./assetTarget-D2PEjBAg.js";import{a as Ee,i as W,n as De,r as G,t as Oe}from"./AssetBits-RToEHLbz.js";import{t as ke}from"./AssetEditorModal-vqUCUeiX.js";var K=e(t(),1),q=e(i(),1),Ae={q:``,protocol:``,source:``,tag:``,status:``,risk_level:``,environment:``,criticality:``,ip:``,domain:``,port:``,scan:``,sort:`last_seen_at:desc`};function je(){return{...Ae}}function Me({scope:e,filters:t,onChange:n,onReset:r,disabled:i}){let a=E(),s=(0,K.useId)(),[c,d]=(0,K.useState)(t.q||``);(0,K.useEffect)(()=>{d(t.q||``)},[t.q]);let f=[`status`,`risk_level`,`environment`,`criticality`,`ip`,`domain`,`port`,`scan`].filter(e=>t[e]).length;return(0,q.jsxs)(`div`,{className:`asset-library-filters`,children:[(0,q.jsxs)(`div`,{className:`asset-library-filter-row`,children:[(0,q.jsx)(`span`,{id:s,hidden:!0,children:a(`assets.scopeLabel`,null,`资产范围`)}),(0,q.jsx)(x,{"aria-labelledby":s,value:e.value,optionList:e.options,loading:e.loading,disabled:i,onChange:e.onChange,filter:!0}),(0,q.jsx)(l,{className:`asset-library-filter-search`,prefix:(0,q.jsx)(_,{}),value:c,disabled:i,placeholder:a(`assets.searchPlaceholder`,null,`搜索主机、IP、域名、标题、服务或标签`),onChange:e=>{d(e),n({q:e})},showClear:!0}),(0,q.jsx)(x,{value:t.protocol||void 0,placeholder:a(`assets.assetType`,null,`类型 / 协议`),optionList:ve,filter:!0,allowCreate:!0,showClear:!0,disabled:i,onChange:e=>n({protocol:e||``})}),(0,q.jsx)(l,{value:t.source,placeholder:a(`assets.source`,null,`来源`),disabled:i,onChange:e=>n({source:e}),showClear:!0}),(0,q.jsx)(l,{value:t.tag,placeholder:a(`assets.tagsLabel`,null,`标签`),disabled:i,onChange:e=>n({tag:e}),showClear:!0}),(0,q.jsx)(u,{onClick:r,disabled:i,children:a(`assets.resetFilters`,null,`重置`)})]}),(0,q.jsx)(o,{className:`asset-library-filter-advanced`,keepDOM:!1,children:(0,q.jsx)(o.Panel,{itemKey:`advanced`,header:`${a(`assets.advancedFilters`,null,`高级筛选`)}${f?`(${f})`:``}`,children:(0,q.jsxs)(`div`,{className:`asset-library-filter-grid`,children:[(0,q.jsx)(x,{value:t.status||void 0,placeholder:a(`assets.allStatuses`,null,`全部状态`),optionList:de,showClear:!0,disabled:i,onChange:e=>n({status:e||``})}),(0,q.jsx)(x,{value:t.risk_level||void 0,placeholder:a(`assets.allRisks`,null,`全部风险`),optionList:me,showClear:!0,disabled:i,onChange:e=>n({risk_level:e||``})}),(0,q.jsx)(x,{value:t.environment||void 0,placeholder:a(`assets.allEnvironments`,null,`全部环境`),optionList:P,showClear:!0,disabled:i,onChange:e=>n({environment:e||``})}),(0,q.jsx)(x,{value:t.criticality||void 0,placeholder:a(`assets.allCriticalities`,null,`全部级别`),optionList:we,showClear:!0,disabled:i,onChange:e=>n({criticality:e||``})}),(0,q.jsx)(l,{value:t.ip,placeholder:`IP`,disabled:i,onChange:e=>n({ip:e}),showClear:!0}),(0,q.jsx)(l,{value:t.domain,placeholder:a(`assets.domain`,null,`域名`),disabled:i,onChange:e=>n({domain:e}),showClear:!0}),(0,q.jsx)(l,{value:t.port,placeholder:a(`assets.port`,null,`端口`),disabled:i,onChange:e=>n({port:String(e||``).replace(/[^\d]/g,``)}),showClear:!0}),(0,q.jsx)(x,{value:t.scan||``,placeholder:a(`assets.scanState`,null,`扫描状态`),optionList:le,disabled:i,onChange:e=>n({scan:e||``})}),(0,q.jsx)(x,{value:t.sort||`last_seen_at:desc`,optionList:H,disabled:i,onChange:e=>n({sort:e||`last_seen_at:desc`})})]})})})]})}var{Text:J}=f;function Ne({assets:e,loading:t,total:n,page:r,pageSize:i,onPageChange:a,onPageSizeChange:o,selectedRowKeys:s,onSelectionChange:l,onView:d,onEdit:f,onDelete:p,onRefresh:m,canWrite:h,canDelete:g}){let _=E(),v=e=>{se({title:_(`assets.deleteConfirm`,null,`确定删除该资产吗?`),content:z(e),okText:_(`common.delete`,null,`删除`),onOk:()=>{Promise.resolve(p(e)).catch(e=>k(e,_(`assets.deleteFailed`,null,`删除资产失败`)))}})},y=[{title:_(`assets.target`,null,`目标`),dataIndex:`host`,width:260,render:(e,t)=>(0,q.jsxs)(`div`,{className:`asset-library-target`,children:[(0,q.jsx)(Ee,{text:z(t),max:38}),(0,q.jsx)(J,{type:`tertiary`,size:`small`,children:[t.ip,t.domain].filter(Boolean).join(` · `)||`—`})]})},{title:_(`assets.service`,null,`服务`),dataIndex:`protocol`,width:150,render:(e,t)=>(0,q.jsx)(De,{protocol:t.protocol,port:t.port})},{title:_(`assets.project`,null,`所属项目`),dataIndex:`project_name`,width:160,render:(e,t)=>(0,q.jsx)(Ee,{text:e||t.projeLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,h as r,t as i,y as a}from"./react-QV7DAAIx.js";import{A as o,E as s,F as c,H as l,L as u,Pt as d,W as f,f as p,l as m,lt as h,m as g,ot as _,p as v,st as y,u as b,v as x,x as ee,z as S}from"./semi-CHxO7u8f.js";import{E as C,F as w,I as T,P as E,R as D,S as O,a as te,b as k,c as A,d as j,l as ne,m as re,n as ie,o as ae,p as oe,s as M,x as N,y as se}from"./index-BLFHsWWk.js";import{A as ce,C as le,D as ue,E as de,M as fe,O as pe,S as me,T as he,_ as ge,a as _e,b as ve,d as ye,f as be,g as xe,h as P,i as F,k as I,l as L,m as Se,n as Ce,o as R,p as we,r as z,s as Te,t as B,v as V,w as H,y as U}from"./assetTarget-D2PEjBAg.js";import{a as Ee,i as W,n as De,r as G,t as Oe}from"./AssetBits-RToEHLbz.js";import{t as ke}from"./AssetEditorModal-DwPErx6-.js";var K=e(t(),1),q=e(i(),1),Ae={q:``,protocol:``,source:``,tag:``,status:``,risk_level:``,environment:``,criticality:``,ip:``,domain:``,port:``,scan:``,sort:`last_seen_at:desc`};function je(){return{...Ae}}function Me({scope:e,filters:t,onChange:n,onReset:r,disabled:i}){let a=E(),s=(0,K.useId)(),[c,d]=(0,K.useState)(t.q||``);(0,K.useEffect)(()=>{d(t.q||``)},[t.q]);let f=[`status`,`risk_level`,`environment`,`criticality`,`ip`,`domain`,`port`,`scan`].filter(e=>t[e]).length;return(0,q.jsxs)(`div`,{className:`asset-library-filters`,children:[(0,q.jsxs)(`div`,{className:`asset-library-filter-row`,children:[(0,q.jsx)(`span`,{id:s,hidden:!0,children:a(`assets.scopeLabel`,null,`资产范围`)}),(0,q.jsx)(x,{"aria-labelledby":s,value:e.value,optionList:e.options,loading:e.loading,disabled:i,onChange:e.onChange,filter:!0}),(0,q.jsx)(l,{className:`asset-library-filter-search`,prefix:(0,q.jsx)(_,{}),value:c,disabled:i,placeholder:a(`assets.searchPlaceholder`,null,`搜索主机、IP、域名、标题、服务或标签`),onChange:e=>{d(e),n({q:e})},showClear:!0}),(0,q.jsx)(x,{value:t.protocol||void 0,placeholder:a(`assets.assetType`,null,`类型 / 协议`),optionList:ve,filter:!0,allowCreate:!0,showClear:!0,disabled:i,onChange:e=>n({protocol:e||``})}),(0,q.jsx)(l,{value:t.source,placeholder:a(`assets.source`,null,`来源`),disabled:i,onChange:e=>n({source:e}),showClear:!0}),(0,q.jsx)(l,{value:t.tag,placeholder:a(`assets.tagsLabel`,null,`标签`),disabled:i,onChange:e=>n({tag:e}),showClear:!0}),(0,q.jsx)(u,{onClick:r,disabled:i,children:a(`assets.resetFilters`,null,`重置`)})]}),(0,q.jsx)(o,{className:`asset-library-filter-advanced`,keepDOM:!1,children:(0,q.jsx)(o.Panel,{itemKey:`advanced`,header:`${a(`assets.advancedFilters`,null,`高级筛选`)}${f?`(${f})`:``}`,children:(0,q.jsxs)(`div`,{className:`asset-library-filter-grid`,children:[(0,q.jsx)(x,{value:t.status||void 0,placeholder:a(`assets.allStatuses`,null,`全部状态`),optionList:de,showClear:!0,disabled:i,onChange:e=>n({status:e||``})}),(0,q.jsx)(x,{value:t.risk_level||void 0,placeholder:a(`assets.allRisks`,null,`全部风险`),optionList:me,showClear:!0,disabled:i,onChange:e=>n({risk_level:e||``})}),(0,q.jsx)(x,{value:t.environment||void 0,placeholder:a(`assets.allEnvironments`,null,`全部环境`),optionList:P,showClear:!0,disabled:i,onChange:e=>n({environment:e||``})}),(0,q.jsx)(x,{value:t.criticality||void 0,placeholder:a(`assets.allCriticalities`,null,`全部级别`),optionList:we,showClear:!0,disabled:i,onChange:e=>n({criticality:e||``})}),(0,q.jsx)(l,{value:t.ip,placeholder:`IP`,disabled:i,onChange:e=>n({ip:e}),showClear:!0}),(0,q.jsx)(l,{value:t.domain,placeholder:a(`assets.domain`,null,`域名`),disabled:i,onChange:e=>n({domain:e}),showClear:!0}),(0,q.jsx)(l,{value:t.port,placeholder:a(`assets.port`,null,`端口`),disabled:i,onChange:e=>n({port:String(e||``).replace(/[^\d]/g,``)}),showClear:!0}),(0,q.jsx)(x,{value:t.scan||``,placeholder:a(`assets.scanState`,null,`扫描状态`),optionList:le,disabled:i,onChange:e=>n({scan:e||``})}),(0,q.jsx)(x,{value:t.sort||`last_seen_at:desc`,optionList:H,disabled:i,onChange:e=>n({sort:e||`last_seen_at:desc`})})]})})})]})}var{Text:J}=f;function Ne({assets:e,loading:t,total:n,page:r,pageSize:i,onPageChange:a,onPageSizeChange:o,selectedRowKeys:s,onSelectionChange:l,onView:d,onEdit:f,onDelete:p,onRefresh:m,canWrite:h,canDelete:g}){let _=E(),v=e=>{se({title:_(`assets.deleteConfirm`,null,`确定删除该资产吗?`),content:z(e),okText:_(`common.delete`,null,`删除`),onOk:()=>{Promise.resolve(p(e)).catch(e=>k(e,_(`assets.deleteFailed`,null,`删除资产失败`)))}})},y=[{title:_(`assets.target`,null,`目标`),dataIndex:`host`,width:260,render:(e,t)=>(0,q.jsxs)(`div`,{className:`asset-library-target`,children:[(0,q.jsx)(Ee,{text:z(t),max:38}),(0,q.jsx)(J,{type:`tertiary`,size:`small`,children:[t.ip,t.domain].filter(Boolean).join(` · `)||`—`})]})},{title:_(`assets.service`,null,`服务`),dataIndex:`protocol`,width:150,render:(e,t)=>(0,q.jsx)(De,{protocol:t.protocol,port:t.port})},{title:_(`assets.project`,null,`所属项目`),dataIndex:`project_name`,width:160,render:(e,t)=>(0,q.jsx)(Ee,{text:e||t.projeLine truncated
`?(r.push(i),n.push(r),r=[],i=``):o!==`\r`&&(i+=o)}return(i!==``||r.length)&&(r.push(i),n.push(r)),n.filter(e=>e.some(e=>String(e??``).trim()!==``))}function Le(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 Re(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 ze(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=Te(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&&!F(u)&&!_e(u))return a(`IP 地址格式无效`);let d=String(e.domain||s.domain||``).trim(),f=d?R(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=Le(e.status,he,`active`);if(!m)return a(`状态仅支持 active 或 inactive`);let h=Le(e.environment,Se,``);if(h===null)return a(`环境值无效`);let g=Le(e.criticality,be,``);if(g===null)return a(`重要性值无效`);let _=Re(e.project||r,n);if(_.error)return a(_.error);if(r!==void 0&&_.projectId!==r)return a(`该行的项目与当前资产范围不一致`);let v=L(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(Fe).find(e=>Array.from(String(y[e]||``)).length>Fe[e]);if(b)return a(`字段 ${b} 内容过长`);let x=ye(y);return x?a(x):{rowNumber:t,values:e,asset:y,projectName:_.projectName,error:``}}function Be(e){let t=new Map;return e.map(e=>{if(e.error||!e.asset)return e;let n=B(e.asset);return t.has(n)?{...e,error:`与第 ${t.get(n)} 行重复`}:(t.set(n,e.rowNumber),e)})}function Ve(e,t={}){let n=Z(e);if(n.length<2)throw Error(`文件中没有可导入的数据`);let r=n[0].map(Ie);if(!r.some(Boolean))throw Error(`未识别到模板字段,请检查表头`);let i=n.slice(1);if(i.length>1e5)throw Error(`数据不能超过 ${U} 行`);return Be(i.map((e,n)=>{let i={};return r.forEach((t,n)=>{t&&i[t]==null&&(i[t]=String(e[n]??``).trim())}),ze(i,n+2,t)}))}function He(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(`数据不能超过 ${U} 行`);return Be(r.map((e,n)=>ze({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 Q(){return`${ge.join(`,`)}\r\n`}function Ue(e){let t=String(e??``);return/[",\r\n]/.test(t)?`"${t.replaceAll(`"`,`""`)}"`:t}function We(e,t){return t===`target`?z(e):t===`project`?e.project_name||e.project_id||``:t===`tags`?(e.tags||[]).join(`,`):t===`status`?fe(e.status):t===`environment`?I(e.environment):t===`criticality`?pe(e.criticality):t===`risk_level`?ce(e.risk_level):t===`vulnerability_count`?Number(e.vulnerability_count||0):e[t]??``}function Ge(e){let t=[xe.map(([,e])=>Ue(e)).join(`,`)];return(e||[]).forEach(e=>{t.push(xe.map(([t])=>Ue(We(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:$}=f,qe=e=>[{title:e(`assets.rowNumber`,null,`行号`),dataIndex:`rowNumber`,width:70},{title:e(`assets.target`,null,`目标`),dataIndex:`target`,render:(e,t)=>z(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,q.jsx)($,{type:`danger`,size:`small`,children:t}):(0,q.jsx)($,{type:`success`,size:`small`,children:e(`assets.validationPassed`,null,`通过`)})}];function Je({visible:e,projects:t,defaultProjectId:n,onClose:r,onDone:i}){let a=E(),[o,s]=(0,K.useState)(`csv`),[l,f]=(0,K.useState)(``),[p,h]=(0,K.useState)(``),[_,v]=(0,K.useState)(``),[y,b]=(0,K.useState)(!1),x=(0,K.useRef)(null),C=(0,K.useMemo)(()=>{if(!String(l||``).trim())return{records:[],error:``};try{let e={projects:t,projectId:n,source:`manual-import`};return{records:o===`csv`?Ve(l,e):He(l,e),error:``}}catch(e){return{records:[],error:e.message}}},[l,o,t,n]),w=C.records,O=w.filter(e=>!e.error),te=w.length-O.length,k=_||C.error,j=()=>{f(``),h(``),s(`csv`),v(``),b(!1)},ne=()=>{y||(j(),r?.())},re=async e=>{if(!e)return;v(``);let t=String(e.name||``),n=t.split(`.`).pop().toLowerCase();if(![`csv`,`json`,`txt`].includes(n))v(`仅支持 .csv / .json / .txt 文件`);else if(e.size>104857600)v(a(`assets.fileTooLarge`,null,`文件不能超过 100 MB`));else try{let r=await e.text();s(n===`json`?`json`:`csv`),f(r),h(t)}catch(e){v(D(e,a(`assets.fileParseFailed`,null,`无法解析文件,请确认文件格式正确`)))}};return(0,q.jsxs)(A,{visible:e,title:a(`assets.bulkImportTitle`,null,`批量导入资产`),width:880,onCancel:ne,onOk:async()=>{if(!y&&O.length){v(``),b(!0);try{let e=await T.post(`/assets/import`,{assets:O.map(e=>e.asset),source:`manual-import`,source_query:p||`paste`}),t=Number(e?.skipped||0)+te;N(a(`assets.bulkImportDone`,{created:Number(e?.created||0),updated:Number(e?.updated||0),skipped:t},`导入完成:新增 ${Number(e?.created||0)} 条,更新 ${Number(e?.updated||0)} 条,跳过 ${t} 条`)),j(),i?.(),r?.()}catch(e){v(D(e,a(`assets.importFailed`,null,`资产入库失败`)))}finally{b(!1)}}},okText:a(`assets.importValidRowsCount`,{count:O.length},`导入 ${O.length} 条有效数据`),okButtonProps:{disabled:!O.length},confirmLoading:y,children:[(0,q.jsx)($,{type:`tertiary`,children:a(`assets.bulkImportSubtitle`,null,`支持 CSV / JSON 文本粘贴或文件上传,提交前会先校验并预览数据`)}),k&&(0,q.jsx)(S,{type:`danger`,bordered:!0,closeIcon:null,description:k,className:`asset-library-form-error`}),(0,q.jsxs)(c,{vertical:!0,align:`start`,spacing:10,className:`asset-library-import-body`,children:[(0,q.jsxs)(c,{children:[(0,q.jsx)(g,{type:`button`,value:o,options:[{value:`csv`,label:`CSV`},{value:`json`,label:`JSON`}],onChange:e=>{s(e.target.value),v(``)}}),(0,q.jsx)(u,{icon:(0,q.jsx)(d,{}),onClick:()=>x.current?.click(),children:a(`assets.chooseOrDropFile`,null,`选择文件`)}),(0,q.jsx)(`input`,{ref:x,type:`file`,accept:`.csv,.json,.txt`,className:`asset-library-file-input`,onChange:e=>{re(e.target.files?.[0]),e.target.value=``}}),(0,q.jsx)(u,{theme:`borderless`,onClick:()=>Ke(`asset-import-template.csv`,Q()),children:a(`assets.downloadCsv`,null,`下载 CSV 模板`)}),p&&(0,q.jsx)($,{type:`tertiary`,size:`small`,children:p})]}),(0,q.jsx)(ee,{value:l,rows:8,className:`asset-library-import-textarea`,placeholder:o===`csv`?`target,project,tags,host,ip,domain,port,protocol,title,server,country,province,city,responsible_person,department,business_system,environment,criticality,status`:`[{"host":"https://example.com","ip":"1.1.1.1","port":443,"protocol":"https","tags":["prod"]}]`,onChange:e=>{f(e),v(``)}}),w.length>0&&(0,q.jsxs)(`div`,{className:`asset-library-import-preview`,children:[(0,q.jsx)($,{strong:!0,children:a(`assets.importPreviewSummary`,{total:w.length,valid:O.length,invalid:te},`共 ${w.length} 行,${O.length} 行有效,${te} 行需修正`)}),(0,q.jsx)(m,{columns:qe(a),dataSource:w.slice(0,10).map((e,t)=>({...e,id:t})),rowKey:`id`,size:`small`,pagination:!1}),w.length>10&&(0,q.jsx)($,{type:`tertiary`,size:`small`,children:a(`assets.previewLimitedShort`,{count:w.length},`仅展示前 10 行;提交时将处理全部 ${w.length} 行`)})]})]})]})}var{Text:Ye}=f;function Xe({visible:e,assets:t,onClose:n,onDone:r}){let i=E(),a=(0,K.useMemo)(()=>Array.isArray(t)?t:[],[t]),[o,s]=(0,K.useState)(``),[l,u]=(0,K.useState)(``),[d,f]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{e&&(s(a[0]?.id||``),u(``),f(!1))},[e,a]),(0,q.jsxs)(A,{visible:e,title:i(`asset Line truncated
@@ -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{F as i,L as a,T as o,W as s,Yt as c,h as l,m as u,ot as d,st as f,z as p}from"./semi-CHxO7u8f.js";import{D as m,F as h,I as g,P as _,_ as v,a as y,k as b,l as x,m as S,p as C,s as w}from"./index-CuUcClXg.js";import{a as T,n as E,r as D}from"./AssetBits-RToEHLbz.js";import{r as O}from"./assetTarget-D2PEjBAg.js";var k=e(t(),1),A=e(r(),1),{Text:j}=s,M=[{value:7,label:`7 天`},{value:30,label:`30 天`},{value:90,label:`90 天`}];function N(e,t){let n=Number(e||0),r=Number(t||0);return r?Math.round(n/r*1e3)/10:0}function P(){let e=_(),t=n(),{hasPermission:r,hasAnyPermission:s}=h(),P=r(`asset:read`),F=s([`asset:read`,`fofa:execute`]),[I,L]=(0,k.useState)(30),R=y(()=>g.get(`/assets/stats`,{days:I}),[I],{skip:!P}),z=y(()=>g.get(`/assets`,{page:1,page_size:10,sort_by:`last_seen_at`,sort_order:`desc`}),[],{skip:!P}),B=R.data||{},V=B.coverage||{},H=Array.isArray(B.protocols)?B.protocols:[],U=(0,k.useMemo)(()=>H.reduce((e,t)=>e+Number(t.count||0),0),[H]),W=Array.isArray(z.data?.assets)?z.data.assets:[],G=[{id:`total`,label:e(`assets.totalAssets`,null,`资产总数`),value:m(B.total||0),detail:e(`assets.totalAssetsHint`,null,`当前纳入持续监测的资产`),loading:R.loading},{id:`ips`,label:e(`assets.ipCount`,null,`IP 数量`),value:m(B.ips||0),loading:R.loading},{id:`domains`,label:e(`assets.domainCount`,null,`域名数量`),value:m(B.domains||0),loading:R.loading},{id:`ports`,label:e(`assets.portCount`,null,`端口数量`),value:m(B.ports||0),loading:R.loading},{id:`protocols`,label:e(`assets.serviceTypes`,null,`服务类型`),value:m(H.length),detail:H[0]?`${e(`assets.topProtocol`,null,`主要协议`)}:${H[0].name}`:void 0,loading:R.loading},{id:`recent`,label:e(`assets.recentCount`,null,`近 7 天发现`),value:m(B.recent||0),detail:e(`assets.recentShare`,{percent:N(B.recent,B.total)},`占当前资产总量的 ${N(B.recent,B.total)}%`),loading:R.loading}],K=e=>{let n=e?.id?`?id=${encodeURIComponent(e.id)}`:``;t(`/asset-library${n}`,e?{state:{asset:e}}:void 0)},q=[{title:e(`assets.target`,null,`目标`),dataIndex:`host`,render:(e,t)=>(0,A.jsxs)(`div`,{className:`asset-overview-target`,children:[(0,A.jsx)(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:b(t,e)})},{title:e(`common.actions`,null,`操作`),dataIndex:`id`,width:100,render:(t,n)=>(0,A.jsx)(a,{theme:`borderless`,size:`small`,onClick:()=>K(n),children:e(`common.view`,null,`查看`)})}],J=[{label:e(`assets.scannedAssets`,null,`已扫描资产`),value:m(V.scanned||0)},{label:e(`assets.recentlyScanned`,null,`近 30 天覆盖`),value:m(V.scanned_30d||0)},{label:e(`assets.neverScanned`,null,`从未扫描`),value:m(V.never_scanned||0)},{label:e(`assets.staleScans`,null,`超过 30 天未扫描`),value:m(V.stale||0)}];return(0,A.jsxs)(`div`,{className:`asset-overview-page`,children:[(0,A.jsx)(C,{title:e(`assets.overviewTitle`,null,`资产概览`),description:`汇总资产规模、服务类型、扫描覆盖与最近发现情况。`,extra:(0,A.jsxs)(i,{wrap:!0,children:[(0,A.jsx)(u,{type:`button`,value:I,options:M,onChange:e=>L(Number(e.target.value)||30)}),(0,A.jsx)(a,{icon:(0,A.jsx)(f,{}),onClick:()=>{R.reload(),z.reload()},children:e(`common.refresh`,null,`刷新`)}),(0,A.jsx)(a,{icon:(0,A.jsx)(c,{}),onClick:()=>t(`/asset-library`),children:e(`assets.viewLibrary`,null,`查看资产库`)}),F&&(0,A.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(d,{}),onClick:()=>t(`/info-collect`),children:e(`nav.infoCollect`,null,`信息收集`)})]})}),!P&&(0,A.jsx)(p,{type:`warning`,bordered:!0,closeIcon:null,description:e(`assets.readDenied`,null,`当前账号没有 asset:read 权限,无法读取资产统计;请联系管理员授权。`)}),P&&(0,A.jsx)(x,{error:R.error,onRetry:()=>R.reload()}),P&&(0,A.jsx)(v,{metrics:G,columns:6}),P&&(0,A.jsxs)(`div`,{className:`asset-overview-columns`,children:[(0,A.jsx)(S,{className:`asset-overview-card`,title:e(`assets.protocolDistribution`,null,`协议分布`),description:e(`assets.protocolDistributionHint`,null,`按已识别服务查看资产暴露构成`),extra:(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e(`assets.protocolKinds`,{count:H.length},`${H.length} 种协议`)}),children:H.length===0?(0,A.jsx)(o,{title:e(`common.noData`,null,`暂无数据`),description:null,style:{padding:24}}):(0,A.jsx)(`div`,{className:`asset-overview-bars`,children:Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r}from"./react-QV7DAAIx.js";import{F as i,L as a,T as o,W as s,Yt as c,h as l,m as u,ot as d,st as f,z as p}from"./semi-CHxO7u8f.js";import{D as m,F as h,I as g,P as _,_ as v,a as y,k as b,l as x,m as S,p as C,s as w}from"./index-BLFHsWWk.js";import{a as T,n as E,r as D}from"./AssetBits-RToEHLbz.js";import{r as O}from"./assetTarget-D2PEjBAg.js";var k=e(t(),1),A=e(r(),1),{Text:j}=s,M=[{value:7,label:`7 天`},{value:30,label:`30 天`},{value:90,label:`90 天`}];function N(e,t){let n=Number(e||0),r=Number(t||0);return r?Math.round(n/r*1e3)/10:0}function P(){let e=_(),t=n(),{hasPermission:r,hasAnyPermission:s}=h(),P=r(`asset:read`),F=s([`asset:read`,`fofa:execute`]),[I,L]=(0,k.useState)(30),R=y(()=>g.get(`/assets/stats`,{days:I}),[I],{skip:!P}),z=y(()=>g.get(`/assets`,{page:1,page_size:10,sort_by:`last_seen_at`,sort_order:`desc`}),[],{skip:!P}),B=R.data||{},V=B.coverage||{},H=Array.isArray(B.protocols)?B.protocols:[],U=(0,k.useMemo)(()=>H.reduce((e,t)=>e+Number(t.count||0),0),[H]),W=Array.isArray(z.data?.assets)?z.data.assets:[],G=[{id:`total`,label:e(`assets.totalAssets`,null,`资产总数`),value:m(B.total||0),detail:e(`assets.totalAssetsHint`,null,`当前纳入持续监测的资产`),loading:R.loading},{id:`ips`,label:e(`assets.ipCount`,null,`IP 数量`),value:m(B.ips||0),loading:R.loading},{id:`domains`,label:e(`assets.domainCount`,null,`域名数量`),value:m(B.domains||0),loading:R.loading},{id:`ports`,label:e(`assets.portCount`,null,`端口数量`),value:m(B.ports||0),loading:R.loading},{id:`protocols`,label:e(`assets.serviceTypes`,null,`服务类型`),value:m(H.length),detail:H[0]?`${e(`assets.topProtocol`,null,`主要协议`)}:${H[0].name}`:void 0,loading:R.loading},{id:`recent`,label:e(`assets.recentCount`,null,`近 7 天发现`),value:m(B.recent||0),detail:e(`assets.recentShare`,{percent:N(B.recent,B.total)},`占当前资产总量的 ${N(B.recent,B.total)}%`),loading:R.loading}],K=e=>{let n=e?.id?`?id=${encodeURIComponent(e.id)}`:``;t(`/asset-library${n}`,e?{state:{asset:e}}:void 0)},q=[{title:e(`assets.target`,null,`目标`),dataIndex:`host`,render:(e,t)=>(0,A.jsxs)(`div`,{className:`asset-overview-target`,children:[(0,A.jsx)(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:b(t,e)})},{title:e(`common.actions`,null,`操作`),dataIndex:`id`,width:100,render:(t,n)=>(0,A.jsx)(a,{theme:`borderless`,size:`small`,onClick:()=>K(n),children:e(`common.view`,null,`查看`)})}],J=[{label:e(`assets.scannedAssets`,null,`已扫描资产`),value:m(V.scanned||0)},{label:e(`assets.recentlyScanned`,null,`近 30 天覆盖`),value:m(V.scanned_30d||0)},{label:e(`assets.neverScanned`,null,`从未扫描`),value:m(V.never_scanned||0)},{label:e(`assets.staleScans`,null,`超过 30 天未扫描`),value:m(V.stale||0)}];return(0,A.jsxs)(`div`,{className:`asset-overview-page`,children:[(0,A.jsx)(C,{title:e(`assets.overviewTitle`,null,`资产概览`),description:`汇总资产规模、服务类型、扫描覆盖与最近发现情况。`,extra:(0,A.jsxs)(i,{wrap:!0,children:[(0,A.jsx)(u,{type:`button`,value:I,options:M,onChange:e=>L(Number(e.target.value)||30)}),(0,A.jsx)(a,{icon:(0,A.jsx)(f,{}),onClick:()=>{R.reload(),z.reload()},children:e(`common.refresh`,null,`刷新`)}),(0,A.jsx)(a,{icon:(0,A.jsx)(c,{}),onClick:()=>t(`/asset-library`),children:e(`assets.viewLibrary`,null,`查看资产库`)}),F&&(0,A.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(d,{}),onClick:()=>t(`/info-collect`),children:e(`nav.infoCollect`,null,`信息收集`)})]})}),!P&&(0,A.jsx)(p,{type:`warning`,bordered:!0,closeIcon:null,description:e(`assets.readDenied`,null,`当前账号没有 asset:read 权限,无法读取资产统计;请联系管理员授权。`)}),P&&(0,A.jsx)(x,{error:R.error,onRetry:()=>R.reload()}),P&&(0,A.jsx)(v,{metrics:G,columns:6}),P&&(0,A.jsxs)(`div`,{className:`asset-overview-columns`,children:[(0,A.jsx)(S,{className:`asset-overview-card`,title:e(`assets.protocolDistribution`,null,`协议分布`),description:e(`assets.protocolDistributionHint`,null,`按已识别服务查看资产暴露构成`),extra:(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e(`assets.protocolKinds`,{count:H.length},`${H.length} 种协议`)}),children:H.length===0?(0,A.jsx)(o,{title:e(`common.noData`,null,`暂无数据`),description:null,style:{padding:24}}):(0,A.jsx)(`div`,{className:`asset-overview-bars`,children:Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,f as ee,st as te,v as c}from"./semi-CHxO7u8f.js";import{E as l,F as ne,P as re,_ as ie,a as u,b as d,l as f,m as p,p as m,r as ae,s as oe,u as se,x as h,y as g}from"./index-CuUcClXg.js";import{c as _,v}from"./c2-shared-B2ZrnT2E.js";import{g as y,m as b,n as x,p as S,r as C,t as w}from"./c2-shared-Dl_EFMrT.js";var T=e(t(),1),E=e(n(),1),{Text:D}=s;function O(){let e=re(),{hasPermission:t}=ne(),n=t(`c2:delete`)||t(`c2:write`),[s,O]=(0,T.useState)(1),[k,A]=(0,T.useState)(20),[j,M]=(0,T.useState)(``),[N,P]=(0,T.useState)(``),[F,I]=(0,T.useState)(`24h`),[L,R]=(0,T.useState)(``),[z,B]=(0,T.useState)(``),[V,H]=(0,T.useState)([]),[U,W]=(0,T.useState)(null),G=(0,T.useMemo)(()=>({page:s,page_size:k,level:j||void 0,category:N||void 0,session_id:z||void 0,since:y(F)||void 0}),[s,k,j,N,z,F]),{data:K,loading:q,error:ce,reload:J}=u(()=>v(G),[G]),Y=Array.isArray(K?.events)?K.events:[],X=Number(K?.total??Y.length),Z=K?.level_counts||{};ae(()=>J({silent:!0}),5e3);let Q=()=>{B(L.trim()),O(1),H([])},le=()=>{M(``),P(``),I(`24h`),R(``),B(``),O(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=>{g({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 _(t);h(e(`c2.events.toastDeleted`,null,`已删除`).replace(`{{n}}`,String(n?.deleted??t.length))),H(e=>e.filter(e=>!t.includes(e))),J()}catch(e){d(e)}}})},de=[{title:e(`c2.events.level`,null,`级别`),dataIndex:`level`,width:90,render:t=>(0,E.jsx)(o,{size:`small`,color:x[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,E.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,E.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.events.colTask`,null,`任务`),dataIndex:`taskId`,width:150,render:e=>(0,E.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.events.time`,null,`时间`),dataIndex:`createdAt`,width:130,render:e=>(0,E.jsx)(b,{value:e})},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:130,render:(t,i)=>(0,E.jsxs)(r,{spacing:4,children:[(0,E.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>W(i),children:e(`c2.events.view`,null,`查看`)}),(0,E.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,disabled:!n,onClick:()=>$([i.id]),children:e(`c2.events.deleteOne`,null,`删除`)})]})}];return(0,E.jsxs)(`div`,{className:`c2-page`,id:`page-c2-events`,children:[(0,E.jsx)(m,{title:e(`c2.events.title`,null,`事件审计`),description:e(`c2.events.pageDesc`,null,`监听器、会话、任务与 OPSEC 事件留痕,5 秒自动刷新`),extra:[(0,E.jsx)(a,{icon:(0,E.jsx)(te,{}),onClick:()=>J(),loading:q,children:e(`c2.events.refresh`,null,`刷新`)},`refresh`),(0,E.jsx)(a,{type:`danger`,disabled:!n||!V.length,onClick:()=>$(V),children:e(`c2.events.batchDelete`,null,`批量删除`)},`delete`)]}),(0,E.jsx)(ie,{metrics:ue,columns:4}),(0,E.jsx)(f,{error:ce,onRetry:()=>J()}),(0,E.jsx)(p,{title:e(`c2.events.filterTitle`,null,`筛选`),extra:(0,E.jsx)(S,{value:F,onChange:e=>{I(e),O(1)},ns:`events`}),children:(0,E.jsxs)(`div`,{className:`c2-toolbar-fields`,children:[(0,E.jsxs)(`div`,{className:`c2-field`,children:[(0,E.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.level`,null,`级别`)}),(0,E.jsx)(c,{value:j,onChange:e=>{M(e||``),O(1)},style:{width:150},optionList:[{value:``,label:e(`c2.events.filterAllLevels`,null,`全部级别`)},...C]})]}),(0,E.jsxs)(`div`,{className:`c2-field`,children:[(0,E.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.category`,null,`类别`)}),(0,E.jsx)(c,{value:N,onChange:e=>{P(e||``),O(1)},style:{width:150},optionList:[{value:``,label:e(`c2.events.filterAllCategories`,null,`全部类别`)},...w]})]}),(0,E.jsxs)(`div`,{className:`c2-field`,children:[(0,E.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.filterSession`,null,`会话 ID`)}),(0,E.jsx)(i,{value:L,onChange:R,onEnterPress:Q,placeholder:e(`c2.events.filterSessionPlaceholder`,null,`s_xxxxxxxx`),style:{width:190}})]}),(0,E.jsxs)(r,{spacing:8,children:[(0,E.jsx)(a,{theme:`solid`,type:`primary`,onClick:Q,children:e(`c2 Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,f as ee,st as te,v as c}from"./semi-CHxO7u8f.js";import{E as l,F as ne,P as re,_ as ie,a as u,b as d,l as f,m as p,p as m,r as ae,s as oe,u as se,x as h,y as g}from"./index-BLFHsWWk.js";import{c as _,v}from"./c2-shared-DlL4rVOl.js";import{g as y,m as b,n as x,p as S,r as C,t as w}from"./c2-shared-CTf-cTfI.js";var T=e(t(),1),E=e(n(),1),{Text:D}=s;function O(){let e=re(),{hasPermission:t}=ne(),n=t(`c2:delete`)||t(`c2:write`),[s,O]=(0,T.useState)(1),[k,A]=(0,T.useState)(20),[j,M]=(0,T.useState)(``),[N,P]=(0,T.useState)(``),[F,I]=(0,T.useState)(`24h`),[L,R]=(0,T.useState)(``),[z,B]=(0,T.useState)(``),[V,H]=(0,T.useState)([]),[U,W]=(0,T.useState)(null),G=(0,T.useMemo)(()=>({page:s,page_size:k,level:j||void 0,category:N||void 0,session_id:z||void 0,since:y(F)||void 0}),[s,k,j,N,z,F]),{data:K,loading:q,error:ce,reload:J}=u(()=>v(G),[G]),Y=Array.isArray(K?.events)?K.events:[],X=Number(K?.total??Y.length),Z=K?.level_counts||{};ae(()=>J({silent:!0}),5e3);let Q=()=>{B(L.trim()),O(1),H([])},le=()=>{M(``),P(``),I(`24h`),R(``),B(``),O(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=>{g({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 _(t);h(e(`c2.events.toastDeleted`,null,`已删除`).replace(`{{n}}`,String(n?.deleted??t.length))),H(e=>e.filter(e=>!t.includes(e))),J()}catch(e){d(e)}}})},de=[{title:e(`c2.events.level`,null,`级别`),dataIndex:`level`,width:90,render:t=>(0,E.jsx)(o,{size:`small`,color:x[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,E.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,E.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.events.colTask`,null,`任务`),dataIndex:`taskId`,width:150,render:e=>(0,E.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.events.time`,null,`时间`),dataIndex:`createdAt`,width:130,render:e=>(0,E.jsx)(b,{value:e})},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:130,render:(t,i)=>(0,E.jsxs)(r,{spacing:4,children:[(0,E.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>W(i),children:e(`c2.events.view`,null,`查看`)}),(0,E.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,disabled:!n,onClick:()=>$([i.id]),children:e(`c2.events.deleteOne`,null,`删除`)})]})}];return(0,E.jsxs)(`div`,{className:`c2-page`,id:`page-c2-events`,children:[(0,E.jsx)(m,{title:e(`c2.events.title`,null,`事件审计`),description:e(`c2.events.pageDesc`,null,`监听器、会话、任务与 OPSEC 事件留痕,5 秒自动刷新`),extra:[(0,E.jsx)(a,{icon:(0,E.jsx)(te,{}),onClick:()=>J(),loading:q,children:e(`c2.events.refresh`,null,`刷新`)},`refresh`),(0,E.jsx)(a,{type:`danger`,disabled:!n||!V.length,onClick:()=>$(V),children:e(`c2.events.batchDelete`,null,`批量删除`)},`delete`)]}),(0,E.jsx)(ie,{metrics:ue,columns:4}),(0,E.jsx)(f,{error:ce,onRetry:()=>J()}),(0,E.jsx)(p,{title:e(`c2.events.filterTitle`,null,`筛选`),extra:(0,E.jsx)(S,{value:F,onChange:e=>{I(e),O(1)},ns:`events`}),children:(0,E.jsxs)(`div`,{className:`c2-toolbar-fields`,children:[(0,E.jsxs)(`div`,{className:`c2-field`,children:[(0,E.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.level`,null,`级别`)}),(0,E.jsx)(c,{value:j,onChange:e=>{M(e||``),O(1)},style:{width:150},optionList:[{value:``,label:e(`c2.events.filterAllLevels`,null,`全部级别`)},...C]})]}),(0,E.jsxs)(`div`,{className:`c2-field`,children:[(0,E.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.category`,null,`类别`)}),(0,E.jsx)(c,{value:N,onChange:e=>{P(e||``),O(1)},style:{width:150},optionList:[{value:``,label:e(`c2.events.filterAllCategories`,null,`全部类别`)},...w]})]}),(0,E.jsxs)(`div`,{className:`c2-field`,children:[(0,E.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.filterSession`,null,`会话 ID`)}),(0,E.jsx)(i,{value:L,onChange:R,onEnterPress:Q,placeholder:e(`c2.events.filterSessionPlaceholder`,null,`s_xxxxxxxx`),style:{width:190}})]}),(0,E.jsxs)(r,{spacing:8,children:[(0,E.jsx)(a,{theme:`solid`,type:`primary`,onClick:Q,children:e(`c2 Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,L as i,M as a,W as o,i as s,lt as c,st as l}from"./semi-CHxO7u8f.js";import{E as u,F as d,P 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-CuUcClXg.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-B2ZrnT2E.js";import{a as M,i as N,o as P}from"./c2-shared-Dl_EFMrT.js";var F=e(t(),1),I=e(n(),1),{Text:L}=o;function R(e){if(!e?.configJson)return{};try{return JSON.parse(e.configJson)||{}}catch{return{}}}function z(e){let t=R(e);return{name:e?.name||``,type:e?.type||`http_beacon`,project_id:e?.project_id||``,bind_host:e?.bindHost||`127.0.0.1`,bind_port:String(e?.bindPort??`4444`),callback_host:t.callback_host||``,profile_id:e?.profileId||``,remark:e?.remark||``,default_sleep:String(t.default_sleep??5),default_jitter:String(t.default_jitter??0),max_concurrent_tasks:String(t.max_concurrent_tasks??0),allow_legacy_shell:!!t.allow_legacy_shell}}function B({visible:e,record:t,projects:n,profiles:a,submitting:o,onCancel:c,onSubmit:l}){let u=f(),[d,p]=(0,F.useState)(null),[m,h]=(0,F.useState)(t?.type||`http_beacon`);return(0,I.jsx)(g,{visible:e,title:t?u(`c2.listeners.editTitle`,null,`编辑监听器`):u(`c2.listeners.modalCreateTitle`,null,`创建监听器`),footer:(0,I.jsxs)(r,{children:[(0,I.jsx)(i,{onClick:c,children:u(`c2.common.cancel`,null,`取消`)}),(0,I.jsx)(i,{theme:`solid`,type:`primary`,loading:o,onClick:()=>d?.submitForm(),children:t?u(`c2.listeners.save`,null,`保存`):u(`c2.listeners.submitCreate`,null,`创建`)})]}),width:620,onCancel:c,children:(0,I.jsxs)(s,{initValues:z(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,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.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,I.jsx)(s.Select,{field:`type`,label:u(`c2.listeners.type`,null,`类型`),optionList:P,disabled:!!t,style:{width:`100%`}})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`bind_host`,label:u(`c2.listeners.bindHost`,null,`绑定地址`),placeholder:`127.0.0.1`}),(0,I.jsx)(s.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,I.jsx)(L,{type:`tertiary`,size:`small`,children:u(`c2.listeners.bindHintExternal`,null,`使用 0.0.0.0 允许外部访问`)}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`callback_host`,label:u(`c2.listeners.callbackHost`,null,`回连地址(可选)`),placeholder:`公网 IP 或域名`}),(0,I.jsx)(s.Select,{field:`profile_id`,label:u(`c2.listeners.malleableProfile`,null,`Malleable Profile`),optionList:[{value:``,label:u(`c2.listeners.malleableProfileNone`,null,`不使用`)},...a.map(e=>({value:e.id,label:e.name||e.id}))],style:{width:`100%`}})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Select,{field:`project_id`,label:u(`c2.listeners.project`,null,`所属项目`),optionList:[{value:``,label:u(`c2.listeners.projectNone`,null,`不绑定项目`)},...n.map(e=>({value:e.id,label:e.name||e.id}))],style:{width:`100%`}}),(0,I.jsx)(s.Input,{field:`remark`,label:u(`c2.listeners.remark`,null,`备注`),placeholder:u(`c2.listeners.placeholderRemarkLong`,null,`可选的备注说明`)})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`default_sleep`,label:`默认 Sleep(秒)`,placeholder:`5`}),(0,I.jsx)(s.Input,{field:`default_jitter`,label:`默认 Jitter(%)`,placeholder:`0`})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`max_concurrent_tasks`,label:`单会话并发任务上限(0 不限)`,placeholder:`0`}),m===`tcp_reverse`&&(0,I.jsx)(s.Switch,{field:`allow_legacy_shell`,label:u(`c2.listeners.allowLegacyShell`,null,`允许未加密经典反弹 Shell(内网实验)`)})]})]},t?.id||`new`)})}var{Text:V}=o,H=e=>P.find(t=>t.value===e)?.label||e||`—`;function U(){let e=f()Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,L as i,M as a,W as o,i as s,lt as c,st as l}from"./semi-CHxO7u8f.js";import{E as u,F as d,P 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-BLFHsWWk.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-DlL4rVOl.js";import{a as M,i as N,o as P}from"./c2-shared-CTf-cTfI.js";var F=e(t(),1),I=e(n(),1),{Text:L}=o;function R(e){if(!e?.configJson)return{};try{return JSON.parse(e.configJson)||{}}catch{return{}}}function z(e){let t=R(e);return{name:e?.name||``,type:e?.type||`http_beacon`,project_id:e?.project_id||``,bind_host:e?.bindHost||`127.0.0.1`,bind_port:String(e?.bindPort??`4444`),callback_host:t.callback_host||``,profile_id:e?.profileId||``,remark:e?.remark||``,default_sleep:String(t.default_sleep??5),default_jitter:String(t.default_jitter??0),max_concurrent_tasks:String(t.max_concurrent_tasks??0),allow_legacy_shell:!!t.allow_legacy_shell}}function B({visible:e,record:t,projects:n,profiles:a,submitting:o,onCancel:c,onSubmit:l}){let u=f(),[d,p]=(0,F.useState)(null),[m,h]=(0,F.useState)(t?.type||`http_beacon`);return(0,I.jsx)(g,{visible:e,title:t?u(`c2.listeners.editTitle`,null,`编辑监听器`):u(`c2.listeners.modalCreateTitle`,null,`创建监听器`),footer:(0,I.jsxs)(r,{children:[(0,I.jsx)(i,{onClick:c,children:u(`c2.common.cancel`,null,`取消`)}),(0,I.jsx)(i,{theme:`solid`,type:`primary`,loading:o,onClick:()=>d?.submitForm(),children:t?u(`c2.listeners.save`,null,`保存`):u(`c2.listeners.submitCreate`,null,`创建`)})]}),width:620,onCancel:c,children:(0,I.jsxs)(s,{initValues:z(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,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.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,I.jsx)(s.Select,{field:`type`,label:u(`c2.listeners.type`,null,`类型`),optionList:P,disabled:!!t,style:{width:`100%`}})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`bind_host`,label:u(`c2.listeners.bindHost`,null,`绑定地址`),placeholder:`127.0.0.1`}),(0,I.jsx)(s.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,I.jsx)(L,{type:`tertiary`,size:`small`,children:u(`c2.listeners.bindHintExternal`,null,`使用 0.0.0.0 允许外部访问`)}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`callback_host`,label:u(`c2.listeners.callbackHost`,null,`回连地址(可选)`),placeholder:`公网 IP 或域名`}),(0,I.jsx)(s.Select,{field:`profile_id`,label:u(`c2.listeners.malleableProfile`,null,`Malleable Profile`),optionList:[{value:``,label:u(`c2.listeners.malleableProfileNone`,null,`不使用`)},...a.map(e=>({value:e.id,label:e.name||e.id}))],style:{width:`100%`}})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Select,{field:`project_id`,label:u(`c2.listeners.project`,null,`所属项目`),optionList:[{value:``,label:u(`c2.listeners.projectNone`,null,`不绑定项目`)},...n.map(e=>({value:e.id,label:e.name||e.id}))],style:{width:`100%`}}),(0,I.jsx)(s.Input,{field:`remark`,label:u(`c2.listeners.remark`,null,`备注`),placeholder:u(`c2.listeners.placeholderRemarkLong`,null,`可选的备注说明`)})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`default_sleep`,label:`默认 Sleep(秒)`,placeholder:`5`}),(0,I.jsx)(s.Input,{field:`default_jitter`,label:`默认 Jitter(%)`,placeholder:`0`})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`max_concurrent_tasks`,label:`单会话并发任务上限(0 不限)`,placeholder:`0`}),m===`tcp_reverse`&&(0,I.jsx)(s.Switch,{field:`allow_legacy_shell`,label:u(`c2.listeners.allowLegacyShell`,null,`允许未加密经典反弹 Shell(内网实验)`)})]})]},t?.id||`new`)})}var{Text:V}=o,H=e=>P.find(t=>t.value===e)?.label||e||`—`;function U(){let e=f()Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,v as c}from"./semi-CHxO7u8f.js";import{F as l,P as u,S as d,T as f,a as p,b as m,l as h,m as g,o as _,p as v,s as y,x as b}from"./index-CuUcClXg.js";import{m as x,n as S,t as C,y as w}from"./c2-shared-B2ZrnT2E.js";import{o as T,s as E}from"./c2-shared-Dl_EFMrT.js";var D=e(t(),1),O=e(n(),1),{Text:k,Title:ee}=s,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=>T.find(t=>t.value===e)?.label||e||`—`;function N(){let e=u(),{hasPermission:t}=l(),n=t(`c2:write`),{data:s,loading:T,error:N,reload:P}=p(()=>w(),[]),F=Array.isArray(s?.listeners)?s.listeners:[],[I,L]=(0,D.useState)({listenerId:``,kind:``,host:``}),[R,z]=(0,D.useState)(null),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)({listenerId:``,host:``,os:`linux`,arch:`amd64`}),[W,G]=(0,D.useState)(null),[K,q]=(0,D.useState)(!1),[J,Y]=(0,D.useState)([]),X=(0,D.useMemo)(()=>F.find(e=>e.id===(I.listenerId||F[0]?.id))||null,[F,I.listenerId]),Z=E[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){d(e(`c2.payloads.toastPickListener`,null,`请先选择一个监听器`));return}let n=I.kind||Z[0]?.value;if(!n)d(e(`c2.payloads.noKindOption`,null,`无可用类型`));else{V(!0);try{let e=await C({listener_id:t,kind:n,host:I.host.trim()});z(e)}catch(t){m(t,e(`c2.payloads.toastOnelinerFail`,null,`生成 Oneliner 失败`))}finally{V(!1)}}},ne=async()=>{let t=H.listenerId||F[0]?.id;if(!t)d(e(`c2.payloads.toastPickListener`,null,`请先选择一个监听器`));else{q(!0);try{let n=(await S({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]),b(e(`c2.payloads.toastBuildSuccess`,null,`构建成功`).replace(`{{bytes}}`,String(n.size_bytes||0)))}}catch(t){m(t,e(`c2.payloads.toastBuildFail`,null,`构建 Beacon 失败`))}finally{q(!1)}}},$=async t=>{if(!t.fileName?.startsWith(`beacon_`))d(e(`c2.payloads.invalidArtifact`,null,`该产物不可下载`));else try{await x(t.fileName,t.fileName),b(e(`c2.payloads.toastDownloadQueued`,null,`下载任务已排队`))}catch(t){m(t,e(`c2.payloads.download`,null,`下载失败`))}},re=[{title:e(`c2.payloads.fileName`,null,`文件`),dataIndex:`fileName`,render:e=>(0,O.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=>f(e)},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:120,render:(t,n)=>(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>$(n),children:e(`c2.payloads.download`,null,`下载`)})}];return(0,O.jsxs)(`div`,{className:`c2-page`,id:`page-c2-payloads`,children:[(0,O.jsx)(v,{title:e(`c2.payloads.title`,null,`Payload 生成`),description:e(`c2.payloads.pageDesc`,null,`生成单行反弹命令,或交叉编译完整 Beacon 二进制`),extra:[(0,O.jsx)(a,{onClick:P,loading:T,children:e(`common.refresh`,null,`刷新`)},`refresh`)]}),(0,O.jsx)(h,{error:N,onRetry:P}),(0,O.jsxs)(`div`,{className:`c2-payload-grid`,children:[(0,O.jsxs)(g,{title:e(`c2.payloads.oneliner`,null,`单行 Payload`),description:e(`c2.payloads.onelinerDesc`,null,`生成可在目标机直接执行的反弹命令`),children:[(0,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.listener`,null,`监听器`)}),(0,O.jsx)(c,{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,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.kind`,null,`类型`)}),(0,O.jsx)(c,{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,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.hostOptional`,null,`回连地址(可选)`)}),(0,O.jsx)(i,{value:I.host,onChange:e=>L(t=>({...t,host:e})),placeholder:e(`c2.payloads.placeholderListenerHost`,null,`留空则使用监听器回连地址`)})]}),(0,O.jsx)(a,{theme:`solid`,type:`primary`,block:!0,disabled:!n,loading:B,onClick:te,children:e(`c2.payloads.generateOnelinerBtn`,null,`生成 Oneliner`)}),R?.oneliner&&(0,O.jsxs)(`div`,{className:`c2-oneliner-result`,children:[(0,O.jsxs)(`div`,{className:Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,v as c}from"./semi-CHxO7u8f.js";import{F as l,P as u,S as d,T as f,a as p,b as m,l as h,m as g,o as _,p as v,s as y,x as b}from"./index-BLFHsWWk.js";import{m as x,n as S,t as C,y as w}from"./c2-shared-DlL4rVOl.js";import{o as T,s as E}from"./c2-shared-CTf-cTfI.js";var D=e(t(),1),O=e(n(),1),{Text:k,Title:ee}=s,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=>T.find(t=>t.value===e)?.label||e||`—`;function N(){let e=u(),{hasPermission:t}=l(),n=t(`c2:write`),{data:s,loading:T,error:N,reload:P}=p(()=>w(),[]),F=Array.isArray(s?.listeners)?s.listeners:[],[I,L]=(0,D.useState)({listenerId:``,kind:``,host:``}),[R,z]=(0,D.useState)(null),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)({listenerId:``,host:``,os:`linux`,arch:`amd64`}),[W,G]=(0,D.useState)(null),[K,q]=(0,D.useState)(!1),[J,Y]=(0,D.useState)([]),X=(0,D.useMemo)(()=>F.find(e=>e.id===(I.listenerId||F[0]?.id))||null,[F,I.listenerId]),Z=E[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){d(e(`c2.payloads.toastPickListener`,null,`请先选择一个监听器`));return}let n=I.kind||Z[0]?.value;if(!n)d(e(`c2.payloads.noKindOption`,null,`无可用类型`));else{V(!0);try{let e=await C({listener_id:t,kind:n,host:I.host.trim()});z(e)}catch(t){m(t,e(`c2.payloads.toastOnelinerFail`,null,`生成 Oneliner 失败`))}finally{V(!1)}}},ne=async()=>{let t=H.listenerId||F[0]?.id;if(!t)d(e(`c2.payloads.toastPickListener`,null,`请先选择一个监听器`));else{q(!0);try{let n=(await S({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]),b(e(`c2.payloads.toastBuildSuccess`,null,`构建成功`).replace(`{{bytes}}`,String(n.size_bytes||0)))}}catch(t){m(t,e(`c2.payloads.toastBuildFail`,null,`构建 Beacon 失败`))}finally{q(!1)}}},$=async t=>{if(!t.fileName?.startsWith(`beacon_`))d(e(`c2.payloads.invalidArtifact`,null,`该产物不可下载`));else try{await x(t.fileName,t.fileName),b(e(`c2.payloads.toastDownloadQueued`,null,`下载任务已排队`))}catch(t){m(t,e(`c2.payloads.download`,null,`下载失败`))}},re=[{title:e(`c2.payloads.fileName`,null,`文件`),dataIndex:`fileName`,render:e=>(0,O.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=>f(e)},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:120,render:(t,n)=>(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>$(n),children:e(`c2.payloads.download`,null,`下载`)})}];return(0,O.jsxs)(`div`,{className:`c2-page`,id:`page-c2-payloads`,children:[(0,O.jsx)(v,{title:e(`c2.payloads.title`,null,`Payload 生成`),description:e(`c2.payloads.pageDesc`,null,`生成单行反弹命令,或交叉编译完整 Beacon 二进制`),extra:[(0,O.jsx)(a,{onClick:P,loading:T,children:e(`common.refresh`,null,`刷新`)},`refresh`)]}),(0,O.jsx)(h,{error:N,onRetry:P}),(0,O.jsxs)(`div`,{className:`c2-payload-grid`,children:[(0,O.jsxs)(g,{title:e(`c2.payloads.oneliner`,null,`单行 Payload`),description:e(`c2.payloads.onelinerDesc`,null,`生成可在目标机直接执行的反弹命令`),children:[(0,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.listener`,null,`监听器`)}),(0,O.jsx)(c,{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,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.kind`,null,`类型`)}),(0,O.jsx)(c,{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,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.hostOptional`,null,`回连地址(可选)`)}),(0,O.jsx)(i,{value:I.host,onChange:e=>L(t=>({...t,host:e})),placeholder:e(`c2.payloads.placeholderListenerHost`,null,`留空则使用监听器回连地址`)})]}),(0,O.jsx)(a,{theme:`solid`,type:`primary`,block:!0,disabled:!n,loading:B,onClick:te,children:e(`c2.payloads.generateOnelinerBtn`,null,`生成 Oneliner`)}),R?.oneliner&&(0,O.jsxs)(`div`,{className:`c2-oneliner-result`,children:[(0,O.jsxs)(`div`,{className:Line truncated
@@ -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{F as r,L as i,M as a,W as o,i as s,lt as c,st as l}from"./semi-CHxO7u8f.js";import{E as u,F as d,P 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-CuUcClXg.js";import{a as T,b as E,k as D,u as O}from"./c2-shared-B2ZrnT2E.js";var k=e(t(),1),A=e(n(),1),{Text:j}=o;function M(e){return{name:e?.name||``,user_agent:e?.userAgent||``,uris:Array.isArray(e?.uris)?e.uris.join(`
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,L as i,M as a,W as o,i as s,lt as c,st as l}from"./semi-CHxO7u8f.js";import{E as u,F as d,P 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-BLFHsWWk.js";import{a as T,b as E,k as D,u as O}from"./c2-shared-DlL4rVOl.js";var k=e(t(),1),A=e(n(),1),{Text:j}=o;function M(e){return{name:e?.name||``,user_agent:e?.userAgent||``,uris:Array.isArray(e?.uris)?e.uris.join(`
`):``,jitter_min:String(e?.jitterMinMs??0),jitter_max:String(e?.jitterMaxMs??0),request_headers:e?.requestHeaders?JSON.stringify(e.requestHeaders,null,2):``,response_headers:e?.responseHeaders?JSON.stringify(e.responseHeaders,null,2):``,body_template:e?.bodyTemplate||``}}function N(e,t){let n=String(e||``).trim();if(!n)return{};try{let e=JSON.parse(n);if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`not an object`);return e}catch{return p(t(`c2.profiles.toastInvalidHeadersJson`,null,`响应头 JSON 无效`)),null}}function P({visible:e,record:t,submitting:n,onCancel:a,onSubmit:o}){let c=f(),[l,u]=(0,k.useState)(null);return(0,A.jsx)(_,{visible:e,title:t?c(`c2.profiles.editTitle`,null,`编辑 Profile`):c(`c2.profiles.modalCreateTitle`,null,`创建 Malleable Profile`),footer:(0,A.jsxs)(r,{children:[(0,A.jsx)(i,{onClick:a,children:c(`c2.common.cancel`,null,`取消`)}),(0,A.jsx)(i,{theme:`solid`,type:`primary`,loading:n,onClick:()=>l?.submitForm(),children:t?c(`c2.profiles.save`,null,`保存`):c(`c2.profiles.submitCreate`,null,`创建`)})]}),width:640,onCancel:a,children:(0,A.jsxs)(s,{initValues:M(t),onSubmit:e=>{let t=Number(e.jitter_min),n=Number(e.jitter_max);if(!Number.isInteger(t)||!Number.isInteger(n)||t<0||n<t){p(c(`c2.profiles.toastInvalidJitter`,null,`Jitter 必须为整数,且满足 0 <= 最小值 <= 最大值`));return}let r=N(e.request_headers,c);if(r===null)return;let i=N(e.response_headers,c);i!==null&&o({name:String(e.name||``).trim(),userAgent:String(e.user_agent||``).trim(),uris:String(e.uris||``).split(/\r?\n/).map(e=>e.trim()).filter(Boolean),jitterMinMs:t,jitterMaxMs:n,requestHeaders:r,responseHeaders:i,bodyTemplate:String(e.body_template||``)})},getFormApi:u,labelPosition:`top`,children:[(0,A.jsx)(s.Input,{field:`name`,label:c(`c2.profiles.profileNameLabel`,null,`Profile 名称`),placeholder:c(`c2.profiles.placeholderProfileName`,null,`例如 cdn-fronting`),rules:[{required:!0,message:c(`c2.profiles.toastNameRequired`,null,`请填写 Profile 名称`)}]}),(0,A.jsx)(s.Input,{field:`user_agent`,label:c(`c2.profiles.userAgent`,null,`User-Agent`),placeholder:`Mozilla/5.0 ...`}),(0,A.jsx)(s.TextArea,{field:`uris`,label:c(`c2.profiles.labelBeaconUris`,null,`Beacon URI(每行一个)`),placeholder:`/api/v1/ping`,autosize:{minRows:2,maxRows:5}}),(0,A.jsxs)(`div`,{className:`c2-form-row`,children:[(0,A.jsx)(s.Input,{field:`jitter_min`,label:c(`c2.profiles.labelJitterMin`,null,`Jitter 最小值 (ms)`),placeholder:`0`}),(0,A.jsx)(s.Input,{field:`jitter_max`,label:c(`c2.profiles.labelJitterMax`,null,`Jitter 最大值 (ms)`),placeholder:`0`})]}),(0,A.jsx)(s.TextArea,{field:`request_headers`,label:c(`c2.profiles.requestHeadersJson`,null,`自定义请求头 (JSON)`),placeholder:`{"X-Forwarded-For":"127.0.0.1"}`,autosize:{minRows:2,maxRows:6}}),(0,A.jsx)(s.TextArea,{field:`response_headers`,label:c(`c2.profiles.labelRespHeaders`,null,`自定义响应头 (JSON)`),placeholder:`{"Server":"nginx"}`,autosize:{minRows:2,maxRows:6}}),(0,A.jsx)(s.TextArea,{field:`body_template`,label:c(`c2.profiles.bodyTemplate`,null,`响应体模板`),placeholder:`{"status":"ok"}`,autosize:{minRows:2,maxRows:6}}),(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:c(`c2.profiles.hintHeaders`,null,`用于伪装为合法服务的 HTTP 响应头`)})]},t?.id||`new`)})}var{Text:F}=o;function I(){let e=f(),{hasPermission:t}=d(),n=t(`c2:write`),o=t(`c2:delete`)||n,[s,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{s.record?.id?(await D(s.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,childr Line truncated
@@ -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{F as i,H as a,L as o,M as s,N as c,T as l,U as u,W as d,at as f,c as p,ot as m,st as h,v as g,x as _}from"./semi-CHxO7u8f.js";import{E as v,F as y,P 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-CuUcClXg.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-B2ZrnT2E.js";import{c as ie,h as G,l as ae,m as oe,u as K}from"./c2-shared-Dl_EFMrT.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=b(),[c,l]=(0,q.useState)([]),[u,d]=(0,q.useState)(``),[p,m]=(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)},[c]);let y=(0,q.useCallback)(e=>{l(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??u).trim();if(a){if(!t)x(r(`c2.sessions.writeRequired`,null,`当前账号没有下发任务的权限`));else{d(``),y({kind:`cmd`,text:a}),m(!0);try{let t=(await ne(e.id,{task_type:`shell`,payload:{command:a,timeout_seconds:60}}))?.task?.id;if(!t){y({kind:`err`,text:r(`c2.sessions.termNoSession`,null,`下发失败:未返回任务 ID`)});return}g(t),n?.();let i=await S(t);if(!i){y({kind:`warn`,text:r(`c2.sessions.termWaitTimeout`,null,`[等待结果超时]`)});return}i.resultText&&y({kind:i.status===`success`?`out`:`warn`,text:i.resultText}),i.error&&y({kind:`err`,text:i.error}),i.status===`cancelled`&&y({kind:`warn`,text:r(`c2.tasks.cancelled`,null,`已取消`)})}catch(e){y({kind:`err`,text:e?.message||r(`c2.sessions.termStatusErr`,null,`执行失败`)}),C(e)}finally{_.current&&(m(!1),g(``))}}}};return(0,J.jsxs)(`div`,{className:`c2-terminal`,children:[(0,J.jsx)(`div`,{className:`c2-terminal-bar`,children:(0,J.jsxs)(i,{spacing:8,children:[(0,J.jsx)(s,{size:`small`,color:p?`amber`:`green`,children:p?r(`c2.sessions.termStatusExec`,null,`执行中…`):r(`c2.sessions.termStatusReady`,null,`就绪`)}),(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>l([]),children:r(`c2.sessions.clearTerminal`,null,`清屏`)}),p&&h&&(0,J.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,onClick:async()=>{if(h)try{await H(h),y({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 任务下发并等待结果`)}),c.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)(a,{value:u,onChange:d,onEnterPress:()=>p?x(r(`c2.sessions.termWaitFinish`,null,`请等待当前命令执行完成`)):w(),placeholder:r(`c2.sessions.commandPlaceholder`,null,`输入命令后回车下发`),disabled:p||!t,prefix:`$`}),(0,J.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,J.jsx)(f,{}),loading:p,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}=d,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)retLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,N as c,T as l,U as u,W as d,at as f,c as p,ot as m,st as h,v as g,x as _}from"./semi-CHxO7u8f.js";import{E as v,F as y,P 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-BLFHsWWk.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-DlL4rVOl.js";import{c as ie,h as G,l as ae,m as oe,u as K}from"./c2-shared-CTf-cTfI.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=b(),[c,l]=(0,q.useState)([]),[u,d]=(0,q.useState)(``),[p,m]=(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)},[c]);let y=(0,q.useCallback)(e=>{l(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??u).trim();if(a){if(!t)x(r(`c2.sessions.writeRequired`,null,`当前账号没有下发任务的权限`));else{d(``),y({kind:`cmd`,text:a}),m(!0);try{let t=(await ne(e.id,{task_type:`shell`,payload:{command:a,timeout_seconds:60}}))?.task?.id;if(!t){y({kind:`err`,text:r(`c2.sessions.termNoSession`,null,`下发失败:未返回任务 ID`)});return}g(t),n?.();let i=await S(t);if(!i){y({kind:`warn`,text:r(`c2.sessions.termWaitTimeout`,null,`[等待结果超时]`)});return}i.resultText&&y({kind:i.status===`success`?`out`:`warn`,text:i.resultText}),i.error&&y({kind:`err`,text:i.error}),i.status===`cancelled`&&y({kind:`warn`,text:r(`c2.tasks.cancelled`,null,`已取消`)})}catch(e){y({kind:`err`,text:e?.message||r(`c2.sessions.termStatusErr`,null,`执行失败`)}),C(e)}finally{_.current&&(m(!1),g(``))}}}};return(0,J.jsxs)(`div`,{className:`c2-terminal`,children:[(0,J.jsx)(`div`,{className:`c2-terminal-bar`,children:(0,J.jsxs)(i,{spacing:8,children:[(0,J.jsx)(s,{size:`small`,color:p?`amber`:`green`,children:p?r(`c2.sessions.termStatusExec`,null,`执行中…`):r(`c2.sessions.termStatusReady`,null,`就绪`)}),(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>l([]),children:r(`c2.sessions.clearTerminal`,null,`清屏`)}),p&&h&&(0,J.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,onClick:async()=>{if(h)try{await H(h),y({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 任务下发并等待结果`)}),c.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)(a,{value:u,onChange:d,onEnterPress:()=>p?x(r(`c2.sessions.termWaitFinish`,null,`请等待当前命令执行完成`)):w(),placeholder:r(`c2.sessions.commandPlaceholder`,null,`输入命令后回车下发`),disabled:p||!t,prefix:`$`}),(0,J.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,J.jsx)(f,{}),loading:p,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}=d,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)retLine truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{F as t,L as n,W as r}from"./semi-CHxO7u8f.js";import{E as i,P as a,k as o}from"./index-CuUcClXg.js";import"./c2-shared-B2ZrnT2E.js";import{t as s}from"./react-QV7DAAIx.js";var c=e(s(),1),{Text:l}=r,u=[{value:`http_beacon`,label:`HTTP Beacon`},{value:`https_beacon`,label:`HTTPS Beacon`},{value:`tcp_reverse`,label:`TCP 反向`},{value:`websocket`,label:`WebSocket`}],d={running:`运行中`,stopped:`已停止`,error:`异常`},f={tcp_reverse:[{value:`bash`,label:`Bash (/dev/tcp)`},{value:`nc`,label:`Netcat (-e)`},{value:`nc_mkfifo`,label:`Netcat (mkfifo)`},{value:`python`,label:`Python`},{value:`perl`,label:`Perl`},{value:`powershell`,label:`PowerShell`}],http_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],https_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],websocket:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}]},p=[{value:`shell`,label:`shell`},{value:`exec`,label:`exec`},{value:`ls`,label:`ls`},{value:`pwd`,label:`pwd`},{value:`cd`,label:`cd`},{value:`ps`,label:`ps`},{value:`kill_proc`,label:`kill_proc`},{value:`download`,label:`download`},{value:`upload`,label:`upload`},{value:`screenshot`,label:`screenshot`},{value:`sleep`,label:`sleep`},{value:`exit`,label:`exit`},{value:`self_delete`,label:`self_delete`},{value:`port_fwd`,label:`port_fwd`},{value:`socks_start`,label:`socks_start`},{value:`socks_stop`,label:`socks_stop`},{value:`load_assembly`,label:`load_assembly`},{value:`persist`,label:`persist`}],m=[{value:`queued`,label:`队列中`},{value:`sent`,label:`已发送`},{value:`running`,label:`执行中`},{value:`success`,label:`成功`},{value:`failed`,label:`失败`},{value:`cancelled`,label:`已取消`}],h=[{value:`info`,label:`信息`},{value:`warn`,label:`警告`},{value:`critical`,label:`严重`}],g=[{value:`listener`,label:`监听器`},{value:`session`,label:`会话`},{value:`task`,label:`任务`},{value:`payload`,label:`Payload`},{value:`opsec`,label:`OPSEC`}],_=[{value:`active`,label:`活跃`},{value:`sleeping`,label:`休眠`},{value:`dead`,label:`离线`},{value:`killed`,label:`已终止`}],v=[{value:`15m`,label:`最近15分钟`,ms:9e5},{value:`1h`,label:`最近1小时`,ms:36e5},{value:`24h`,label:`最近24小时`,ms:864e5},{value:`7d`,label:`最近7天`,ms:6048e5},{value:`all`,label:`全部`,ms:0}];function y(e){let t=v.find(t=>t.value===e);return!t||!t.ms?``:new Date(Date.now()-t.ms).toISOString()}function b({value:e,onChange:r,ns:i=`tasks`}){let o=a();return(0,c.jsxs)(t,{spacing:6,wrap:!0,className:`c2-time-presets`,children:[(0,c.jsx)(l,{type:`tertiary`,size:`small`,children:o(`c2.tasks.timePresets`,null,`快捷`)}),v.map(t=>(0,c.jsx)(n,{size:`small`,theme:t.value===e?`solid`:`borderless`,type:t.value===e?`primary`:`tertiary`,onClick:()=>r(t.value),children:o(`c2.${i}.preset${t.value===`all`?`All`:t.value}`,null,t.label)},t.value))]})}function x(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`—`:t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}秒`:`${Math.round(t/6e4)}分钟`}function S({value:e}){let t=a();return e?(0,c.jsx)(`span`,{className:`c2-time-text`,title:i(e),children:o(e,t)}):(0,c.jsx)(l,{type:`tertiary`,children:`—`})}var C={running:`green`,stopped:`grey`,error:`red`},w={queued:`amber`,sent:`blue`,running:`blue`,success:`green`,failed:`red`,cancelled:`grey`},T={active:`green`,sleeping:`amber`,dead:`grey`,killed:`red`},E={info:`blue`,warn:`amber`,critical:`red`};export{d as a,T as c,m as d,p as f,y as g,x as h,C as i,_ as l,S as m,E as n,u as o,b as p,h as r,f as s,g as t,w as u};
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{F as t,L as n,W as r}from"./semi-CHxO7u8f.js";import{E as i,P as a,k as o}from"./index-BLFHsWWk.js";import"./c2-shared-DlL4rVOl.js";import{t as s}from"./react-QV7DAAIx.js";var c=e(s(),1),{Text:l}=r,u=[{value:`http_beacon`,label:`HTTP Beacon`},{value:`https_beacon`,label:`HTTPS Beacon`},{value:`tcp_reverse`,label:`TCP 反向`},{value:`websocket`,label:`WebSocket`}],d={running:`运行中`,stopped:`已停止`,error:`异常`},f={tcp_reverse:[{value:`bash`,label:`Bash (/dev/tcp)`},{value:`nc`,label:`Netcat (-e)`},{value:`nc_mkfifo`,label:`Netcat (mkfifo)`},{value:`python`,label:`Python`},{value:`perl`,label:`Perl`},{value:`powershell`,label:`PowerShell`}],http_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],https_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],websocket:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}]},p=[{value:`shell`,label:`shell`},{value:`exec`,label:`exec`},{value:`ls`,label:`ls`},{value:`pwd`,label:`pwd`},{value:`cd`,label:`cd`},{value:`ps`,label:`ps`},{value:`kill_proc`,label:`kill_proc`},{value:`download`,label:`download`},{value:`upload`,label:`upload`},{value:`screenshot`,label:`screenshot`},{value:`sleep`,label:`sleep`},{value:`exit`,label:`exit`},{value:`self_delete`,label:`self_delete`},{value:`port_fwd`,label:`port_fwd`},{value:`socks_start`,label:`socks_start`},{value:`socks_stop`,label:`socks_stop`},{value:`load_assembly`,label:`load_assembly`},{value:`persist`,label:`persist`}],m=[{value:`queued`,label:`队列中`},{value:`sent`,label:`已发送`},{value:`running`,label:`执行中`},{value:`success`,label:`成功`},{value:`failed`,label:`失败`},{value:`cancelled`,label:`已取消`}],h=[{value:`info`,label:`信息`},{value:`warn`,label:`警告`},{value:`critical`,label:`严重`}],g=[{value:`listener`,label:`监听器`},{value:`session`,label:`会话`},{value:`task`,label:`任务`},{value:`payload`,label:`Payload`},{value:`opsec`,label:`OPSEC`}],_=[{value:`active`,label:`活跃`},{value:`sleeping`,label:`休眠`},{value:`dead`,label:`离线`},{value:`killed`,label:`已终止`}],v=[{value:`15m`,label:`最近15分钟`,ms:9e5},{value:`1h`,label:`最近1小时`,ms:36e5},{value:`24h`,label:`最近24小时`,ms:864e5},{value:`7d`,label:`最近7天`,ms:6048e5},{value:`all`,label:`全部`,ms:0}];function y(e){let t=v.find(t=>t.value===e);return!t||!t.ms?``:new Date(Date.now()-t.ms).toISOString()}function b({value:e,onChange:r,ns:i=`tasks`}){let o=a();return(0,c.jsxs)(t,{spacing:6,wrap:!0,className:`c2-time-presets`,children:[(0,c.jsx)(l,{type:`tertiary`,size:`small`,children:o(`c2.tasks.timePresets`,null,`快捷`)}),v.map(t=>(0,c.jsx)(n,{size:`small`,theme:t.value===e?`solid`:`borderless`,type:t.value===e?`primary`:`tertiary`,onClick:()=>r(t.value),children:o(`c2.${i}.preset${t.value===`all`?`All`:t.value}`,null,t.label)},t.value))]})}function x(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`—`:t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}秒`:`${Math.round(t/6e4)}分钟`}function S({value:e}){let t=a();return e?(0,c.jsx)(`span`,{className:`c2-time-text`,title:i(e),children:o(e,t)}):(0,c.jsx)(l,{type:`tertiary`,children:`—`})}var C={running:`green`,stopped:`grey`,error:`red`},w={queued:`amber`,sent:`blue`,running:`blue`,success:`green`,failed:`red`,cancelled:`grey`},T={active:`green`,sleeping:`amber`,dead:`grey`,killed:`red`},E={info:`blue`,warn:`amber`,critical:`red`};export{d as a,T as c,m as d,p as f,y as g,x as h,C as i,_ as l,S as m,E as n,u as o,b as p,h as r,f as s,g as t,w as u};
@@ -1 +1 @@
import{I as e,L as t}from"./index-CuUcClXg.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};
import{I as e,L as t}from"./index-BLFHsWWk.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};
@@ -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{F as i,H as a,L as o,M as s,W as c,i as l,lt as u,st as d,v as f}from"./semi-CHxO7u8f.js";import{E as ee,F as te,P as p,_ as ne,a as re,b as m,c as h,l as ie,m as g,p as ae,r as oe,s as se,x as _,y as ce}from"./index-CuUcClXg.js";import{A as le,C as ue,h as de,p as fe,r as v,s as y}from"./c2-shared-B2ZrnT2E.js";import{d as pe,f as b,g as me,h as x,m as he,p as ge,u as S}from"./c2-shared-Dl_EFMrT.js";var C=e(t(),1),w=e(n(),1),{Text:T}=c,E=new Set([`shell`,`exec`]),D=new Set([`ls`,`download`,`cd`]);function _e({visible:e,defaultSessionId:t,onCancel:n,onSubmit:r,submitting:a}){let s=p(),[c,u]=(0,C.useState)(null),[d,f]=(0,C.useState)(`shell`);return(0,w.jsx)(h,{visible:e,title:s(`c2.tasks.createTitle`,null,`下发任务`),footer:(0,w.jsxs)(i,{children:[(0,w.jsx)(o,{onClick:n,children:s(`c2.tasks.cancelFilters`,null,`取消`)}),(0,w.jsx)(o,{theme:`solid`,type:`primary`,loading:a,onClick:()=>c?.submitForm(),children:s(`c2.tasks.createSubmit`,null,`下发`)})]}),width:560,onCancel:n,children:(0,w.jsxs)(l,{initValues:{session_id:t||``,task_type:`shell`,command:``,timeout_seconds:`60`,extra:``},onSubmit:e=>{let t={},n=String(e.command||``).trim();if(E.has(e.task_type)){t.command=n;let r=Number(e.timeout_seconds);Number.isFinite(r)&&r>0&&(t.timeout_seconds=r)}else(D.has(e.task_type)||n)&&(t.path=n);let i=String(e.extra||``).trim();if(i)try{Object.assign(t,JSON.parse(i))}catch{t.raw=i}r({session_id:String(e.session_id||``).trim(),task_type:e.task_type||`shell`,payload:t,source:`manual`})},getFormApi:u,labelPosition:`top`,onValueChange:e=>{e.task_type&&f(e.task_type)},children:[(0,w.jsx)(l.Input,{field:`session_id`,label:s(`c2.tasks.labelSession`,null,`会话`),placeholder:`s_xxxxxxxx`,rules:[{required:!0,message:s(`c2.tasks.labelSession`,null,`请填写会话 ID`)}]}),(0,w.jsx)(l.Select,{field:`task_type`,label:s(`c2.tasks.labelType`,null,`类型`),optionList:b,style:{width:`100%`}}),(0,w.jsx)(l.Input,{field:`command`,label:E.has(d)?s(`c2.tasks.labelCommand`,null,`命令`):s(`c2.tasks.labelPath`,null,`路径`),placeholder:E.has(d)?`whoami`:`/etc/passwd`}),E.has(d)&&(0,w.jsx)(l.Input,{field:`timeout_seconds`,label:s(`c2.tasks.labelTimeout`,null,`超时(秒)`),placeholder:`60`}),(0,w.jsx)(l.Input,{field:`extra`,label:s(`c2.tasks.labelExtraPayload`,null,`附加参数(JSON,可选)`),placeholder:`{"key":"value"}`}),(0,w.jsx)(T,{type:`tertiary`,size:`small`,children:s(`c2.tasks.createHint`,null,`任务入队后由植入体在下次心跳拉取;危险类型可能需要人机协同审批。`)})]},e?`open`:`closed`)})}var{Text:O}=c;function k(){let e=p(),{hasPermission:t}=te(),n=t(`c2:write`),c=t(`c2:delete`)||n,[l,T]=r(),[E,D]=(0,C.useState)(1),[k,ve]=(0,C.useState)(20),[A,j]=(0,C.useState)(``),[M,N]=(0,C.useState)(``),[P,F]=(0,C.useState)(`all`),[I,L]=(0,C.useState)(l.get(`session_id`)||``),[R,z]=(0,C.useState)(l.get(`session_id`)||``),[B,V]=(0,C.useState)(null),[ye,H]=(0,C.useState)(!1),[be,U]=(0,C.useState)(!1),W=(0,C.useMemo)(()=>({page:E,page_size:k,status:A||void 0,task_type:M||void 0,session_id:R||void 0,since:me(P)||void 0}),[E,k,A,M,R,P]),{data:G,loading:K,error:xe,reload:q}=re(()=>ue(W),[W]),J=Array.isArray(G?.tasks)?G.tasks:[],Y=Number(G?.total??J.length),X=G?.status_counts||{};oe(()=>q({silent:!0}),5e3);let Z=()=>{z(I.trim()),D(1);let e=new URLSearchParams(l);I.trim()?e.set(`session_id`,I.trim()):e.delete(`session_id`),T(e,{replace:!0})},Se=()=>{j(``),N(``),F(`all`),L(``),z(``),D(1),T(new URLSearchParams,{replace:!0})},Ce=[{id:`total`,label:e(`c2.tasks.statTotal`,null,`当前筛选`),value:Y},{id:`success`,label:e(`c2.tasks.success`,null,`成功`),value:X.success||0,tone:`success`},{id:`failed`,label:e(`c2.tasks.failed`,null,`失败`),value:X.failed||0,tone:`danger`},{id:`pending`,label:e(`c2.tasks.pending`,null,`待处理`),value:(X.queued||0)+(X.sent||0)+(X.running||0),tone:`warning`}],we=async t=>{try{await v(t.id),_(e(`c2.tasks.toastCancelled`,null,`任务已取消`)),q({silent:!0})}catch(e){m(e)}},Te=t=>{ce({title:e(`c2.tasks.deleteOne`,null,`删除任务`),content:e(`c2.tasks.confirmDeleteOne`,null,`确定从服务器删除该任务记录吗?此操作不可恢复。`),onOk:async()=>{try{await fe([t.id]),_(e(`c2.tasks.toastDeleted`,null,`已删除 {{n}} 条`).replace(`{{n}}`,`1`)),q()}catch(e){m(e)}}})},Ee=async t=>{try{let n=await le(t.id,20);n?.task&&V(n.task),_(e(`c2.tasks.toastWaited`,null,`已获取最新任务状态`)),q({silent:!0})}catch(t){m(t,e(`c2.tasks.waitTimeout`,null,`等待任务完成超时`))}},Q=async t=>{try{await de(t.id),_(e(`c2.tasks.downloadOk`,null,`已开始下载`))}catch(t){m(t,e(`c2.tasks.labelResult`,null,`下载结果文件失败`))}},$=async t=>{U(!0);try{await y(t),_(e(`c2.tasks.toastCreated`,null,`任务已下发`)),H(!1),q()}catch(t){m(t,e(`c2.tasks.createFailed`,null,`下发任务失败`))}finally{U(!1)}},De=[{title:e(`c2.tasks.colTask`,null,`任 Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,W as c,i as l,lt as u,st as d,v as f}from"./semi-CHxO7u8f.js";import{E as ee,F as te,P as p,_ as ne,a as re,b as m,c as h,l as ie,m as g,p as ae,r as oe,s as se,x as _,y as ce}from"./index-BLFHsWWk.js";import{A as le,C as ue,h as de,p as fe,r as v,s as y}from"./c2-shared-DlL4rVOl.js";import{d as pe,f as b,g as me,h as x,m as he,p as ge,u as S}from"./c2-shared-CTf-cTfI.js";var C=e(t(),1),w=e(n(),1),{Text:T}=c,E=new Set([`shell`,`exec`]),D=new Set([`ls`,`download`,`cd`]);function _e({visible:e,defaultSessionId:t,onCancel:n,onSubmit:r,submitting:a}){let s=p(),[c,u]=(0,C.useState)(null),[d,f]=(0,C.useState)(`shell`);return(0,w.jsx)(h,{visible:e,title:s(`c2.tasks.createTitle`,null,`下发任务`),footer:(0,w.jsxs)(i,{children:[(0,w.jsx)(o,{onClick:n,children:s(`c2.tasks.cancelFilters`,null,`取消`)}),(0,w.jsx)(o,{theme:`solid`,type:`primary`,loading:a,onClick:()=>c?.submitForm(),children:s(`c2.tasks.createSubmit`,null,`下发`)})]}),width:560,onCancel:n,children:(0,w.jsxs)(l,{initValues:{session_id:t||``,task_type:`shell`,command:``,timeout_seconds:`60`,extra:``},onSubmit:e=>{let t={},n=String(e.command||``).trim();if(E.has(e.task_type)){t.command=n;let r=Number(e.timeout_seconds);Number.isFinite(r)&&r>0&&(t.timeout_seconds=r)}else(D.has(e.task_type)||n)&&(t.path=n);let i=String(e.extra||``).trim();if(i)try{Object.assign(t,JSON.parse(i))}catch{t.raw=i}r({session_id:String(e.session_id||``).trim(),task_type:e.task_type||`shell`,payload:t,source:`manual`})},getFormApi:u,labelPosition:`top`,onValueChange:e=>{e.task_type&&f(e.task_type)},children:[(0,w.jsx)(l.Input,{field:`session_id`,label:s(`c2.tasks.labelSession`,null,`会话`),placeholder:`s_xxxxxxxx`,rules:[{required:!0,message:s(`c2.tasks.labelSession`,null,`请填写会话 ID`)}]}),(0,w.jsx)(l.Select,{field:`task_type`,label:s(`c2.tasks.labelType`,null,`类型`),optionList:b,style:{width:`100%`}}),(0,w.jsx)(l.Input,{field:`command`,label:E.has(d)?s(`c2.tasks.labelCommand`,null,`命令`):s(`c2.tasks.labelPath`,null,`路径`),placeholder:E.has(d)?`whoami`:`/etc/passwd`}),E.has(d)&&(0,w.jsx)(l.Input,{field:`timeout_seconds`,label:s(`c2.tasks.labelTimeout`,null,`超时(秒)`),placeholder:`60`}),(0,w.jsx)(l.Input,{field:`extra`,label:s(`c2.tasks.labelExtraPayload`,null,`附加参数(JSON,可选)`),placeholder:`{"key":"value"}`}),(0,w.jsx)(T,{type:`tertiary`,size:`small`,children:s(`c2.tasks.createHint`,null,`任务入队后由植入体在下次心跳拉取;危险类型可能需要人机协同审批。`)})]},e?`open`:`closed`)})}var{Text:O}=c;function k(){let e=p(),{hasPermission:t}=te(),n=t(`c2:write`),c=t(`c2:delete`)||n,[l,T]=r(),[E,D]=(0,C.useState)(1),[k,ve]=(0,C.useState)(20),[A,j]=(0,C.useState)(``),[M,N]=(0,C.useState)(``),[P,F]=(0,C.useState)(`all`),[I,L]=(0,C.useState)(l.get(`session_id`)||``),[R,z]=(0,C.useState)(l.get(`session_id`)||``),[B,V]=(0,C.useState)(null),[ye,H]=(0,C.useState)(!1),[be,U]=(0,C.useState)(!1),W=(0,C.useMemo)(()=>({page:E,page_size:k,status:A||void 0,task_type:M||void 0,session_id:R||void 0,since:me(P)||void 0}),[E,k,A,M,R,P]),{data:G,loading:K,error:xe,reload:q}=re(()=>ue(W),[W]),J=Array.isArray(G?.tasks)?G.tasks:[],Y=Number(G?.total??J.length),X=G?.status_counts||{};oe(()=>q({silent:!0}),5e3);let Z=()=>{z(I.trim()),D(1);let e=new URLSearchParams(l);I.trim()?e.set(`session_id`,I.trim()):e.delete(`session_id`),T(e,{replace:!0})},Se=()=>{j(``),N(``),F(`all`),L(``),z(``),D(1),T(new URLSearchParams,{replace:!0})},Ce=[{id:`total`,label:e(`c2.tasks.statTotal`,null,`当前筛选`),value:Y},{id:`success`,label:e(`c2.tasks.success`,null,`成功`),value:X.success||0,tone:`success`},{id:`failed`,label:e(`c2.tasks.failed`,null,`失败`),value:X.failed||0,tone:`danger`},{id:`pending`,label:e(`c2.tasks.pending`,null,`待处理`),value:(X.queued||0)+(X.sent||0)+(X.running||0),tone:`warning`}],we=async t=>{try{await v(t.id),_(e(`c2.tasks.toastCancelled`,null,`任务已取消`)),q({silent:!0})}catch(e){m(e)}},Te=t=>{ce({title:e(`c2.tasks.deleteOne`,null,`删除任务`),content:e(`c2.tasks.confirmDeleteOne`,null,`确定从服务器删除该任务记录吗?此操作不可恢复。`),onOk:async()=>{try{await fe([t.id]),_(e(`c2.tasks.toastDeleted`,null,`已删除 {{n}} 条`).replace(`{{n}}`,`1`)),q()}catch(e){m(e)}}})},Ee=async t=>{try{let n=await le(t.id,20);n?.task&&V(n.task),_(e(`c2.tasks.toastWaited`,null,`已获取最新任务状态`)),q({silent:!0})}catch(t){m(t,e(`c2.tasks.waitTimeout`,null,`等待任务完成超时`))}},Q=async t=>{try{await de(t.id),_(e(`c2.tasks.downloadOk`,null,`已开始下载`))}catch(t){m(t,e(`c2.tasks.labelResult`,null,`下载结果文件失败`))}},$=async t=>{U(!0);try{await y(t),_(e(`c2.tasks.toastCreated`,null,`任务已下发`)),H(!1),q()}catch(t){m(t,e(`c2.tasks.createFailed`,null,`下发任务失败`))}finally{U(!1)}},De=[{title:e(`c2.tasks.colTask`,null,`任 Line truncated
@@ -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{$t as i,A as a,At as o,C as s,F as c,Ft as l,G as u,Gt as d,H as f,I as p,Jt as m,L as h,Lt as g,M as _,N as v,Nt as y,Ot as b,P as x,S,T as C,U as ee,V as w,W as T,Xt as E,Y as te,Z as D,_ as ne,d as re,dt as O,et as k,f as ie,g as A,h as ae,jt as oe,lt as se,m as ce,mt as le,nt as j,ot as ue,q as M,st as de,tt as N,v as fe,wt as P,x as pe,z as me,zt as he}from"./semi-CHxO7u8f.js";import{D as ge,E as F,F as _e,I,N as L,P as R,R as ve,S as ye,a as be,b as z,f as xe,i as Se,l as Ce,n as we,o as Te,r as Ee,u as B,x as De,y as Oe,z as ke}from"./index-CuUcClXg.js";import{n as Ae,t as je}from"./retest-EzTZPjnQ.js";import{t as Me}from"./project-form-B4r3E78D.js";import{n as Ne,r as Pe,t as Fe}from"./model-channel-mQ6lfvSO.js";var V=e(t(),1),H=e(n(),1),{Text:Ie,Title:U}=T,Le={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 Re({conversation:e,mode:t,hitlCount:n,conversationId:r,narrow:i,onToggleSidebar:a,onRefresh:o}){let s=R(),l=Le[t]||Le.single,u=e?.title||s(`chat.newChat`,null,`新对话`);return(0,H.jsxs)(`header`,{className:`chat-header`,children:[(0,H.jsxs)(`div`,{className:`chat-header-main`,children:[(0,H.jsxs)(`div`,{className:`chat-header-heading`,children:[(0,H.jsx)(U,{heading:3,className:`chat-header-title`,title:u,children:u}),(0,H.jsxs)(c,{spacing:6,wrap:!0,className:`chat-header-tags`,children:[e?.pinned&&(0,H.jsx)(_,{size:`small`,color:`amber`,children:s(`chat.pinned`,null,`已置顶`)}),(0,H.jsx)(_,{size:`small`,color:l.color,children:s(l.key,null,l.label)}),n>0&&(0,H.jsx)(_,{size:`small`,color:`orange`,children:s(`chat.pendingApprovals`,{count:n},`待审批 ${n}`)})]})]}),(0,H.jsx)(Ie,{type:`tertiary`,size:`small`,className:`chat-header-description`,children:r?s(`chat.conversationHint`,null,`会话历史与工具执行过程会自动落库`):s(`chat.newConversationHint`,null,`输入内容即可创建新对话`)})]}),(0,H.jsxs)(c,{spacing:8,wrap:!0,className:`chat-header-actions`,children:[i&&(0,H.jsx)(h,{icon:(0,H.jsx)(le,{}),onClick:a,children:s(`chat.conversations`,null,`会话`)}),r&&(0,H.jsx)(h,{theme:`borderless`,type:`tertiary`,icon:(0,H.jsx)(de,{"aria-hidden":`true`}),title:s(`chat.refreshConversationHint`,null,`重新读取会话列表、消息、待审批项和执行计划`),onClick:o,children:s(`chat.refreshConversation`,null,`刷新对话`)})]})]})}var ze=[`default`,`off`,`on`,`auto`],Be=[`low`,`medium`,`high`,`xhigh`,`max`];function Ve(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 He(e,t){let[n,r]=(0,V.useState)(()=>{try{return localStorage.getItem(e)??t}catch{return t}});return[n,t=>{r(t);try{localStorage.setItem(e,t)}catch{}}]}function Ue(e){let[t,n]=He(`cyberstrike-chat-ai-channel`,``),[r,i]=He(`cyberstrike-chat-reasoning-mode`,`default`),[a,o]=He(`cyberstrike-chat-reasoning-effort`,``),s=be(async()=>(await I.get(`/config`))?.ai,[e],{skip:!e}),c=Object.entries(s.data?.channels||{}).sort(([e],[t])=>e.localeCompare(t)),l=t.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``),u=c.find(([e])=>e===t)?.[0]||c.find(([e])=>e===l)?.[0]||``,d=(s.data?.channels?.[u||s.data?.default_channel])?.reasoning?.allow_client_reasoning===!1,f=ze.includes(r)?r:`default`,p=Be.includes(a)?a:``,m={mode:f==="default"?void 0:f,effort:f===`off`?void 0:p||void 0};return{channel:u,channels:c,setChannel:n,config:s,mode:f,setMode:i,effort:p,setEffort:o,overrideBlocked:d,waitingForChannel:!!(e&&t&&s.loading),request:{aiChannelId:e&&u||void 0,reasoning:m.mode||m.effort?m:void 0}}}var{Text:W}=T,We=[`off`,`approval`,`review_edit`],Ge=[60,300,600,0],Ke=`tool_search, skill, task, write_todos, transfer_to_agent, exit, TaskCreate, TaskGet, TaskUpdate, TaskList, upsert_project_fact, get_project_fact`;function qe(e,t){return t===!1?`off`:We.includes(e)?e:`off`}function Je(e){return e===`audit_agent`?`audit_agent`:`human`}function Ye(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 G(e){return(Array.isArray(e)?e:String(e||``).split(/[,\n\r]+/)).map(e=>String(e||``).trim()).filter(Boolean)}function Xe(e,t){let n=new Set(G(t).map(e=>e.toLowerCase()));return G(e).filter(e=>!n.has(e.toLowerCase())).join(`, `)}function Ze(e,t,n){if(n)return{mode:qe(n.mode,n.enabled),reviewer:Je(n.reviewer),timeoutSeconds:Ye(n.timeoutSeconds),sensitiveTools:G(n.sensitiveTools).join(`, `)};let r=t?e?.hitl:null;return{mode:t?qe(r?.mode,r?.enabled):qe(e?.defaulLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{$t as i,A as a,At as o,C as s,F as c,Ft as l,G as u,Gt as d,H as f,I as p,Jt as m,L as h,Lt as g,M as _,N as v,Nt as y,Ot as b,P as x,S,T as C,U as ee,V as w,W as T,Xt as E,Y as te,Z as D,_ as ne,d as re,dt as O,et as k,f as ie,g as A,h as ae,jt as oe,lt as se,m as ce,mt as le,nt as j,ot as ue,q as M,st as de,tt as N,v as fe,wt as P,x as pe,z as me,zt as he}from"./semi-CHxO7u8f.js";import{D as ge,E as F,F as _e,I,N as L,P as R,R as ve,S as ye,a as be,b as z,f as xe,i as Se,l as Ce,n as we,o as Te,r as Ee,u as B,x as De,y as Oe,z as ke}from"./index-BLFHsWWk.js";import{n as Ae,t as je}from"./retest-EzTZPjnQ.js";import{t as Me}from"./project-form-B3I4tCMR.js";import{n as Ne,r as Pe,t as Fe}from"./model-channel-mQ6lfvSO.js";var V=e(t(),1),H=e(n(),1),{Text:Ie,Title:U}=T,Le={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 Re({conversation:e,mode:t,hitlCount:n,conversationId:r,narrow:i,onToggleSidebar:a,onRefresh:o}){let s=R(),l=Le[t]||Le.single,u=e?.title||s(`chat.newChat`,null,`新对话`);return(0,H.jsxs)(`header`,{className:`chat-header`,children:[(0,H.jsxs)(`div`,{className:`chat-header-main`,children:[(0,H.jsxs)(`div`,{className:`chat-header-heading`,children:[(0,H.jsx)(U,{heading:3,className:`chat-header-title`,title:u,children:u}),(0,H.jsxs)(c,{spacing:6,wrap:!0,className:`chat-header-tags`,children:[e?.pinned&&(0,H.jsx)(_,{size:`small`,color:`amber`,children:s(`chat.pinned`,null,`已置顶`)}),(0,H.jsx)(_,{size:`small`,color:l.color,children:s(l.key,null,l.label)}),n>0&&(0,H.jsx)(_,{size:`small`,color:`orange`,children:s(`chat.pendingApprovals`,{count:n},`待审批 ${n}`)})]})]}),(0,H.jsx)(Ie,{type:`tertiary`,size:`small`,className:`chat-header-description`,children:r?s(`chat.conversationHint`,null,`会话历史与工具执行过程会自动落库`):s(`chat.newConversationHint`,null,`输入内容即可创建新对话`)})]}),(0,H.jsxs)(c,{spacing:8,wrap:!0,className:`chat-header-actions`,children:[i&&(0,H.jsx)(h,{icon:(0,H.jsx)(le,{}),onClick:a,children:s(`chat.conversations`,null,`会话`)}),r&&(0,H.jsx)(h,{theme:`borderless`,type:`tertiary`,icon:(0,H.jsx)(de,{"aria-hidden":`true`}),title:s(`chat.refreshConversationHint`,null,`重新读取会话列表、消息、待审批项和执行计划`),onClick:o,children:s(`chat.refreshConversation`,null,`刷新对话`)})]})]})}var ze=[`default`,`off`,`on`,`auto`],Be=[`low`,`medium`,`high`,`xhigh`,`max`];function Ve(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 He(e,t){let[n,r]=(0,V.useState)(()=>{try{return localStorage.getItem(e)??t}catch{return t}});return[n,t=>{r(t);try{localStorage.setItem(e,t)}catch{}}]}function Ue(e){let[t,n]=He(`cyberstrike-chat-ai-channel`,``),[r,i]=He(`cyberstrike-chat-reasoning-mode`,`default`),[a,o]=He(`cyberstrike-chat-reasoning-effort`,``),s=be(async()=>(await I.get(`/config`))?.ai,[e],{skip:!e}),c=Object.entries(s.data?.channels||{}).sort(([e],[t])=>e.localeCompare(t)),l=t.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``),u=c.find(([e])=>e===t)?.[0]||c.find(([e])=>e===l)?.[0]||``,d=(s.data?.channels?.[u||s.data?.default_channel])?.reasoning?.allow_client_reasoning===!1,f=ze.includes(r)?r:`default`,p=Be.includes(a)?a:``,m={mode:f==="default"?void 0:f,effort:f===`off`?void 0:p||void 0};return{channel:u,channels:c,setChannel:n,config:s,mode:f,setMode:i,effort:p,setEffort:o,overrideBlocked:d,waitingForChannel:!!(e&&t&&s.loading),request:{aiChannelId:e&&u||void 0,reasoning:m.mode||m.effort?m:void 0}}}var{Text:W}=T,We=[`off`,`approval`,`review_edit`],Ge=[60,300,600,0],Ke=`tool_search, skill, task, write_todos, transfer_to_agent, exit, TaskCreate, TaskGet, TaskUpdate, TaskList, upsert_project_fact, get_project_fact`;function qe(e,t){return t===!1?`off`:We.includes(e)?e:`off`}function Je(e){return e===`audit_agent`?`audit_agent`:`human`}function Ye(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 G(e){return(Array.isArray(e)?e:String(e||``).split(/[,\n\r]+/)).map(e=>String(e||``).trim()).filter(Boolean)}function Xe(e,t){let n=new Set(G(t).map(e=>e.toLowerCase()));return G(e).filter(e=>!n.has(e.toLowerCase())).join(`, `)}function Ze(e,t,n){if(n)return{mode:qe(n.mode,n.enabled),reviewer:Je(n.reviewer),timeoutSeconds:Ye(n.timeoutSeconds),sensitiveTools:G(n.sensitiveTools).join(`, `)};let r=t?e?.hitl:null;return{mode:t?qe(r?.mode,r?.enabled):qe(e?.defaulLine truncated
`),s=Number(e.totalTokens),c=[e.agentName,t(`chat.piUsageSummaryTitle`),Number.isFinite(s)&&s>0?r(s):``].filter(Boolean).join(` · `);return(0,H.jsx)(xt,{block:{title:c,message:o,data:e}})}function Ct({events:e}){return!e||!e.length?null:(0,H.jsx)(a,{className:`chat-block-collapse chat-event-log`,children:(0,H.jsx)(a.Panel,{itemKey:`1`,header:(0,H.jsxs)(`span`,{className:`chat-block-title`,children:[`🧾 原始事件 · `,e.length,` 条`]}),children:(0,H.jsx)(`pre`,{className:`chat-pre`,children:e.map((e,t)=>`${t+1}. ${JSON.stringify(e)}`).join(`
`)})})})}function wt({text:e,blocks:t,events:n,streaming:r=!1,openReasoning:i=!1,isAssistant:a=!1}){let{t:o}=L(),s=Array.isArray(t)?t:[],c=e||``,l=s.filter(e=>e.kind===`tool`).length,u=0;return(0,H.jsxs)(`div`,{className:`chat-turn-body`,children:[s.map(e=>e.kind===`reasoning`?(0,H.jsx)(yt,{block:e,defaultOpen:i},e.id):e.kind===`tool`?(u+=1,(0,H.jsx)(bt,{block:e,index:u,total:l},e.id)):e.kind===`iteration`?(0,H.jsx)(`div`,{className:`chat-iteration`,children:(0,H.jsx)(`span`,{className:`chat-iteration-label`,children:e.title})},e.id):e.kind===`note`?(0,H.jsx)(xt,{block:e},e.id):e.kind===`usage`?(0,H.jsx)(St,{data:e.data},e.id):null),(0,H.jsx)(Ct,{events:n}),c.trim()&&(a&&!r?(0,H.jsx)(`section`,{className:`chat-task-summary`,"aria-label":o(`chat.taskSummary`),"data-chat-summary":!0,children:(0,H.jsxs)(`details`,{open:!0,children:[(0,H.jsx)(`summary`,{className:`chat-task-summary-title`,children:o(`chat.taskSummary`)}),(0,H.jsx)(`div`,{className:`chat-task-summary-content`,children:(0,H.jsx)(xe,{content:c})})]},c)}):r?(0,H.jsx)(`pre`,{className:`chat-pre chat-stream-text`,children:c}):(0,H.jsx)(xe,{content:c})),!c.trim()&&r&&(0,H.jsx)(`div`,{className:`chat-stream-placeholder`,children:`正在生成…`})]})}var{Paragraph:Tt,Text:Et}=T;function Dt(){let e=R();return(0,H.jsx)(`div`,{className:`chat-welcome`,children:(0,H.jsx)(C,{image:(0,H.jsx)(`span`,{className:`chat-welcome-mark`,"aria-hidden":`true`,children:(0,H.jsx)(y,{size:`extra-large`})}),title:e(`chat.welcomeHeading`,null,`让安全探索,从对话开始`),description:(0,H.jsx)(Tt,{type:`tertiary`,className:`chat-welcome-description`,children:e(`chat.welcomeScopeDescription`,null,`描述测试目标与授权范围,或上传相关材料,即可开始对话。`)})})})}function Ot(e,t,n){let[r,i]=(0,V.useState)(()=>Date.now());if((0,V.useEffect)(()=>{if(!n)return;let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[n]),!e)return``;let a=Math.max(0,Math.round(((n?r:t||e)-e)/1e3));return a<60?`${a}s`:`${Math.floor(a/60)}m${a%60}s`}function kt({message:e,canDelete:t,onDeleteTurn:n}){let r=R(),a=e.role===`user`,o=e.role===`system`,s=(0,V.useMemo)(()=>gt(e),[e]),c=e.createdAt?F(e.createdAt):``,l=String(e.content||``);return o?(0,H.jsx)(`div`,{className:`chat-system-row`,children:(0,H.jsx)(Et,{type:`tertiary`,children:l})},e.id):(0,H.jsxs)(`div`,{className:`chat-msg ${a?`chat-msg-user`:`chat-msg-assistant`}`,children:[(0,H.jsx)(w,{size:`small`,color:a?`grey`:`blue`,className:`chat-avatar`,"aria-hidden":`true`,children:a?(0,H.jsx)(M,{}):`AI`}),(0,H.jsxs)(`div`,{className:`chat-bubble`,children:[(0,H.jsxs)(`div`,{className:`chat-bubble-head`,children:[(0,H.jsx)(`span`,{className:`chat-bubble-role`,children:a?r(`chat.you`,null,`我`):r(`chat.assistant`,null,`助手`)}),c&&(0,H.jsx)(`span`,{className:`chat-bubble-time`,children:c}),(0,H.jsxs)(`span`,{className:`chat-bubble-actions`,children:[!a&&l&&(0,H.jsx)(Te,{text:l,size:`small`}),t&&a&&e.id&&(0,H.jsx)(i,{content:r(`chat.deleteTurnTitle`,null,`删除本轮`),children:(0,H.jsx)(h,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,H.jsx)(oe,{}),"aria-label":r(`chat.deleteTurnTitle`,null,`删除本轮`),onClick:()=>n(e)})})]})]}),l||s.length>0?(0,H.jsx)(wt,{text:l,blocks:s,events:null,isAssistant:!a}):(0,H.jsx)(Et,{type:`tertiary`,children:`—`})]})]},e.id)}function At({live:e}){let t=R(),n=ht[e.status]||ht.streaming,r=Ot(e.startedAt,e.endedAt,e.status===`streaming`);return(0,H.jsxs)(`div`,{className:`chat-msg chat-msg-assistant chat-msg-live`,children:[(0,H.jsx)(w,{size:`small`,color:`blue`,className:`chat-avatar`,children:`AI`}),(0,H.jsxs)(`div`,{className:`chat-bubble`,children:[(0,H.jsxs)(`div`,{className:`chat-bubble-head`,children:[(0,H.jsx)(`span`,{className:`chat-bubble-role`,children:t(`chat.assistant`,null,`助手`)}),(0,H.jsx)(_,{size:`small`,color:n.color,shape:`circle`,children:n.label}),r&&(0,H.jsx)(`span`,{className:`chat-bubble-time`,children:r}),e.statusText&&(0,H.jsx)(`span`,{className:`chat-live-status`,children:e.statusText})]}),(0,H.jsx)(wt,{isAssistant:!0,text:e.text,blocks:e.blocks,events:e.events,streaming:e.status===`streaming`,openReasoning:e.status===`streaming`}),e.error&&(0,H.jsx)(`div`,{className:`chat-live-error`,children:e.error}),e.notice&&(0,H.jsx)(`div`,{className:`chat-live-notice`,children:e.notice}),e.finalizable===!1&&(0,H.jsx)(`div`,{className:`chat-live-notice`,children:`本轮回复未通过最终化校验,内容可能不完整。`})]})]})}function jt({conversationId:e,messages:t,live:n,loading:r,error:i,onRetry:a,canDelete:o,onDeleteTurn:s}){let c=R(),l=(0,V.useRef)(null),u=(0,V.useRef)(!0),d=(0,V.useRef)(``),[f,p]=(0,V.useState)(!0),m=Array.isArray(t)?t:[],g=m[m.length-1],_=`${m.length}:${g?.id||``}:${g?.content||``}:${g?.processDetails?.length||0}`,v=n?n.status!==`streaming`&&n.text.trim()?`live:${e}:${n.messageId||n.id}:${n.text}`:``:!r&&g?.role===`assistant`&&String(g.content||``).trim()?`history:${e}:${g.id}:${g.content}`:``,y=(0,V.useMe Line truncated
`)}`:i;L(e=>({...e,messages:[...e.messages||[],{id:`local-${Date.now()}`,role:`user`,content:a,createdAt:new Date().toISOString()}]})),ft(),B(_,()=>({draft:``,attachments:[]})),fe.current=Mt,Q.send({message:i,attachments:r,mode:j,projectId:re,role:Mt,...P.request,hitl:!_&&d&&he||void 0})},[Te,G,n,o,d,Xe,_,Ce,he,j,P,re,k,ft,Mt,At,Q,$,e,B]),Lt=(0,V.useRef)(new Set),Rt=(0,V.useRef)(``),zt=(0,V.useRef)(``);(0,V.useEffect)(()=>{if(!_)return;let t=Ae(_);if(!t)return;let r=String(t.prompt||``).trim();if(!r){je(_);return}if(F.error||!n||!o){Rt.current!==_&&(Rt.current=_,je(_),ye(e(`vulnerabilityRetest.startFailed`,null,`复测尚未成功发送,提示词已保存在分支中,请返回该分支继续。`)));return}if($||G||Xe||!At||F.conversation?.id!==_)return;je(_);let i=v.current;Lt.current.add(i),B(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),ft(),Q.send({message:r,mode:j,role:Mt,...P.request})},[_,F.conversation,F.error,$,G,Xe,At,n,o,j,P,ft,Mt,Q,e,B]),(0,V.useEffect)(()=>{let e=F.conversation,t=String(e?.retest?.pending_prompt||``).trim();_&&e?.id===_&&t&&(Lt.current.has(_)||Ae(_)||$||G||String(Ce||``).trim()||zt.current!==_&&(zt.current=_,B(_,e=>({...e,draft:t}))))},[_,F.conversation,Ce,$,G,B]);let Bt=F.conversation,Ht=(0,V.useRef)(``);(0,V.useEffect)(()=>{if(!_){Ht.current=``;return}if(Bt?.id!==_||Ht.current===_)return;Ht.current=_;let e=Bt.projectId||Xt;C&&C!==e||w===e&&E||lt(e)},[Bt,_,E,lt,C,w]);let Ut=ot.find(e=>!e.projectId)?.total||0,Wt=[{id:Xt,title:e(`chat.defaultWorkspace`,null,`默认工作区`),total:Ut},...ot.filter(e=>e.projectId).map(t=>({id:t.projectId,title:nt.find(e=>e.id===t.projectId)?.name||e(`chat.boundProject`,null,`已绑定项目`),total:t.total,projectId:t.projectId}))],rn=(0,H.jsx)(rt,{items:E?ct:[],groups:Wt.filter(e=>!C||e.id===C),expandedGroup:E?w:``,groupTotal:J,onToggleGroup:e=>{e===w&&E?te(!1):e===w?te(!0):lt(e)},loading:K.loading||!q&&!K.error,error:K.error,onRetry:()=>K.reload(),search:b,onSearch:e=>{x(e),ne(1)},projectId:C,onProjectChange:e=>{ee(e||``),lt(e||Xt)},projects:nt,page:D,pageSize:Yt,onPageChange:ne,selectedId:_,onSelect:ht,onCreate:vt,onRename:yt,onPin:bt,onDelete:xt,onBatchDelete:St,canWrite:n,canDelete:s});return(0,H.jsxs)(`div`,{className:`chat-page`,children:[!Ge&&(0,H.jsx)(`aside`,{className:`chat-sidebar`,children:rn}),(0,H.jsxs)(`section`,{className:`chat-main`,children:[(0,H.jsx)(Re,{conversation:Bt,mode:j,hitlCount:Pe.length,conversationId:_,narrow:Ge,onToggleSidebar:()=>We(!0),onRefresh:()=>{Qe.current?.(),_&&Y(_),X(),Z()}}),(0,H.jsxs)(`div`,{className:`chat-panel`,children:[(0,H.jsx)(jt,{conversationId:_,messages:F.messages,live:ut,loading:F.loading||!(!_||F.conversation||F.error),error:F.error,onRetry:()=>_?Y(_):null,canDelete:s,onDeleteTurn:Ct}),U.running&&U.total>0&&(0,H.jsxs)(`div`,{className:`chat-plan-strip`,children:[(0,H.jsx)(Jt,{size:`small`,children:e(`chat.planTasks`,null,`执行计划`)}),(0,H.jsx)(ae,{percent:Math.round(Number(U.completed||0)/Math.max(1,Number(U.total))*100),showInfo:!1,size:`small`,className:`chat-plan-strip-bar`}),(0,H.jsxs)(Jt,{size:`small`,type:`tertiary`,children:[U.completed,`/`,U.total,U.activeStep?` · ${e(`chat.planStep`,{step:U.activeStep},`第 ${U.activeStep} 步`)}`:``]}),(0,H.jsx)(h,{size:`small`,theme:`borderless`,onClick:()=>{Z(),He(!0)},children:e(`chat.planDetails`,null,`详情`)})]}),dt.length>0&&!ut&&(0,H.jsx)(a,{className:`chat-events-strip`,children:(0,H.jsx)(a.Panel,{itemKey:`1`,header:`${e(`chat.rawEvents`,null,`本轮原始事件`)} · ${dt.length}`,children:(0,H.jsx)(`pre`,{className:`chat-pre`,children:dt.map((e,t)=>`${t+1}. ${JSON.stringify(e)}`).join(`
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,J as a,L as o,M as s,U as c,W as l,f as u,lt as d,ot as f,st as p,v as m}from"./semi-CHxO7u8f.js";import{E as h,F as ee,I as g,L as _,P as v,S as te,T as y,a as ne,b,c as re,l as x,m as ie,n as ae,o as S,p as oe,s as se,x as C,y as ce}from"./index-CuUcClXg.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}=l,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=v(),[r,i]=(0,w.useState)(!1),[a,s]=(0,w.useState)(null),[l,d]=(0,w.useState)(``),[f,p]=(0,w.useState)(``),[m,h]=(0,w.useState)(`text`);return(0,w.useEffect)(()=>{let t=``,n=!1;if(!e)return d(``),p(``),s(null),()=>{};let r=j(e);return h(r),i(!0),s(null),d(``),p(``),(async()=>{try{if(r===`image`){let r=await D(e.relativePath);if(n){URL.revokeObjectURL(r.url);return}t=r.url,p(r.url)}else if(r===`text`){let t=await T(e.relativePath);if(n)return;d(t?.content??``)}}catch(e){n||(s(e),r===`text`&&h(`binary`))}finally{n||i(!1)}})(),()=>{n=!0,t&&URL.revokeObjectURL(t)}},[e]),(0,O.jsx)(u,{visible:!!e,title:e?.name||n(`chatFilesPage.previewTitle`,null,`文件预览`),width:720,onCancel:t,footer:(0,O.jsx)(o,{onClick:async()=>{if(e)try{await E(e.relativePath,e.name)}catch(e){b(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:y(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)(x,{error:m===`binary`?null:a}),r&&(0,O.jsx)(`div`,{className:`chat-files-preview-loading`,children:(0,O.jsx)(c,{})}),!r&&m===`image`&&f&&(0,O.jsx)(`img`,{className:`chat-files-preview-image`,src:f,alt:e.name}),!r&&m===`text`&&(0,O.jsx)(`pre`,{className:`chat-files-preview-text`,children:l}),!r&&m===`binary`&&(0,O.jsx)(k,{type:`tertiary`,children:n(`chatFilesPage.editBinaryHint`,null,`图片、压缩包等二进制文件无法在此以文本方式编辑,请使用「下载」后在本地查看或处理。`)})]})})}var{Text:M}=l,_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=v(),{hasPermission:t}=ee(),n=t(`files:write`),c=t(`files:delete`)||n,l=(0,w.useRef)(null),[u,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 u===`browse`?{...e,page:1,pageSize:`all`}:{...e,page:L,pageSize:z}},[u,_,T,k,W,L,z]),{data:K,loading:q,error:Se,reload:J}=ne(()=>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)(()=>u===`browse`?{folders:X.filter(e=>N(e)===F),files:Y.filter(e=>N(e.relativePath)===F)}:{folders:[],files:Y},[u,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`);aLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,J as a,L as o,M as s,U as c,W as l,f as u,lt as d,ot as f,st as p,v as m}from"./semi-CHxO7u8f.js";import{E as h,F as ee,I as g,L as _,P as v,S as te,T as y,a as ne,b,c as re,l as x,m as ie,n as ae,o as S,p as oe,s as se,x as C,y as ce}from"./index-BLFHsWWk.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}=l,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=v(),[r,i]=(0,w.useState)(!1),[a,s]=(0,w.useState)(null),[l,d]=(0,w.useState)(``),[f,p]=(0,w.useState)(``),[m,h]=(0,w.useState)(`text`);return(0,w.useEffect)(()=>{let t=``,n=!1;if(!e)return d(``),p(``),s(null),()=>{};let r=j(e);return h(r),i(!0),s(null),d(``),p(``),(async()=>{try{if(r===`image`){let r=await D(e.relativePath);if(n){URL.revokeObjectURL(r.url);return}t=r.url,p(r.url)}else if(r===`text`){let t=await T(e.relativePath);if(n)return;d(t?.content??``)}}catch(e){n||(s(e),r===`text`&&h(`binary`))}finally{n||i(!1)}})(),()=>{n=!0,t&&URL.revokeObjectURL(t)}},[e]),(0,O.jsx)(u,{visible:!!e,title:e?.name||n(`chatFilesPage.previewTitle`,null,`文件预览`),width:720,onCancel:t,footer:(0,O.jsx)(o,{onClick:async()=>{if(e)try{await E(e.relativePath,e.name)}catch(e){b(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:y(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)(x,{error:m===`binary`?null:a}),r&&(0,O.jsx)(`div`,{className:`chat-files-preview-loading`,children:(0,O.jsx)(c,{})}),!r&&m===`image`&&f&&(0,O.jsx)(`img`,{className:`chat-files-preview-image`,src:f,alt:e.name}),!r&&m===`text`&&(0,O.jsx)(`pre`,{className:`chat-files-preview-text`,children:l}),!r&&m===`binary`&&(0,O.jsx)(k,{type:`tertiary`,children:n(`chatFilesPage.editBinaryHint`,null,`图片、压缩包等二进制文件无法在此以文本方式编辑,请使用「下载」后在本地查看或处理。`)})]})})}var{Text:M}=l,_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=v(),{hasPermission:t}=ee(),n=t(`files:write`),c=t(`files:delete`)||n,l=(0,w.useRef)(null),[u,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 u===`browse`?{...e,page:1,pageSize:`all`}:{...e,page:L,pageSize:z}},[u,_,T,k,W,L,z]),{data:K,loading:q,error:Se,reload:J}=ne(()=>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)(()=>u===`browse`?{folders:X.filter(e=>N(e)===F),files:Y.filter(e=>N(e.relativePath)===F)}:{folders:[],files:Y},[u,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`);aLine truncated
@@ -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{Bt as o,F as s,Gt as c,L as l,M as u,Nt as d,Q as f,S as p,T as m,Vt as h,W as g,Yt as _,h as v,nt as y,st as b,v as x,z as S}from"./semi-CHxO7u8f.js";import{D as C,E as w,I as T,O as ee,P as E,_ as D,a as O,h as k,k as A,l as j,m as M,p as te,r as ne,w as N}from"./index-CuUcClXg.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?`—`:C(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)(u,{size:`small`,className:`dashboard-risk-tag`,children:s?n(`dashboard.risk`+s,null,c):`—`})]}),(0,F.jsx)(v,{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?`—`:`${C(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- Line truncated
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{Bt as o,F as s,Gt as c,L as l,M as u,Nt as d,Q as f,S as p,T as m,Vt as h,W as g,Yt as _,h as v,nt as y,st as b,v as x,z as S}from"./semi-CHxO7u8f.js";import{D as C,E as w,I as T,O as ee,P as E,_ as D,a as O,h as k,k as A,l as j,m as M,p as te,r as ne,w as N}from"./index-BLFHsWWk.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?`—`:C(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)(u,{size:`small`,className:`dashboard-risk-tag`,children:s?n(`dashboard.risk`+s,null,c):`—`})]}),(0,F.jsx)(v,{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?`—`:`${C(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- Line truncated
@@ -1 +1 @@
.hitl-page{flex-direction:column;display:flex}.hitl-tabs{margin-top:-4px}.hitl-tab-label{align-items:center;gap:6px;display:inline-flex}.hitl-panel-toolbar{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin:4px 0 12px;display:flex}.hitl-panel-loading{justify-content:center;padding:48px 0;display:flex}.hitl-panel-pagination{justify-content:flex-end;margin-top:12px;display:flex}.hitl-pending-list{flex-direction:column;gap:12px;display:flex}.hitl-pending-card{border:1px solid var(--semi-color-border);background:var(--semi-color-bg-1);border-radius:10px;flex-direction:column;gap:10px;padding:14px 16px;display:flex}.hitl-pending-head{flex-wrap:wrap;justify-content:space-between;align-items:flex-start;gap:8px;display:flex}.hitl-pending-meta{color:var(--semi-color-text-2);flex-wrap:wrap;align-items:center;gap:8px;font-size:12px;display:flex}.hitl-pending-meta-label{color:var(--semi-color-text-3)}.hitl-pending-deadline{background:var(--semi-color-fill-0);border-radius:999px;margin-left:auto;padding:1px 8px;font-size:12px}.hitl-pending-editor{flex-direction:column;gap:4px;display:flex}.hitl-pending-actions{justify-content:flex-end;align-items:center;gap:8px;display:flex}.hitl-context-blocks{flex-direction:column;gap:8px;display:flex}.hitl-context-block{border-left:3px solid var(--semi-color-border);flex-direction:column;gap:2px;padding-left:10px;display:flex}.hitl-context-block.hitl-state-success{border-left-color:var(--semi-color-success)}.hitl-context-block.hitl-state-failed{border-left-color:var(--semi-color-danger)}.hitl-context-label{color:var(--semi-color-text-2);font-size:12px}.hitl-context-text{white-space:pre-wrap;word-break:break-word;max-height:180px;color:var(--semi-color-text-1);margin:0;font-family:SFMono-Regular,Consolas,monospace;font-size:12px;line-height:1.5;overflow:auto}.hitl-inline-error{color:var(--semi-color-danger);background:var(--semi-color-danger-light-default);border-radius:6px;padding:8px 10px;font-size:12px}.hitl-args-textarea textarea,.hitl-whitelist-textarea textarea,.hitl-prompt-textarea textarea{font-family:SFMono-Regular,Consolas,monospace!important;font-size:12px!important;line-height:1.55!important}.hitl-mono{word-break:break-all;font-family:SFMono-Regular,Consolas,monospace;font-size:12px}.hitl-ellipsis{text-overflow:ellipsis;white-space:nowrap;vertical-align:bottom;max-width:100%;display:inline-block;overflow:hidden}.hitl-retention-hint{color:var(--semi-color-text-2);margin:0 0 10px;font-size:12px}.hitl-log-detail{flex-direction:column;gap:14px;display:flex}.hitl-log-by{flex-direction:column;gap:1px;display:flex}.hitl-log-engine{color:var(--semi-color-text-2);font-size:11px}.hitl-whitelist-meta{flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:8px;display:flex}.hitl-whitelist-tags{flex-wrap:wrap;gap:6px;max-height:160px;margin-top:10px;display:flex;overflow:auto}.hitl-strategy-panel{flex-direction:column;display:flex}.hitl-strategy-form{grid-template-columns:repeat(auto-fit,minmax(220px,1fr));align-items:start;gap:14px 20px;display:grid}.hitl-field{flex-direction:column;gap:6px;min-width:0;display:flex}.hitl-field-label{color:var(--semi-color-text-2);font-size:12px}.hitl-strategy-hint{color:var(--semi-color-text-2);margin:8px 0 0;font-size:12px}.hitl-prompt-grid{grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:16px;display:grid}.hitl-prompt-field{flex-direction:column;gap:6px;min-width:0;display:flex}.hitl-prompt-head{align-items:center;gap:8px;display:flex}.hitl-conv-query{flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:12px;display:flex}.hitl-conv-result{margin-top:4px}@media (max-width:720px){.hitl-pending-deadline{margin-left:0}.hitl-pending-actions{justify-content:stretch}.hitl-pending-actions .semi-button{flex:1 1 0}}.hitl-field-wide{grid-column:1/-1}
.hitl-page{flex-direction:column;display:flex}.hitl-tabs{margin-top:-4px}.hitl-tab-label{align-items:center;gap:6px;display:inline-flex}.hitl-panel-toolbar{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:12px;margin:4px 0 12px;display:flex}.hitl-panel-loading{justify-content:center;padding:48px 0;display:flex}.hitl-panel-pagination{justify-content:flex-end;margin-top:12px;display:flex}.hitl-pending-list{flex-direction:column;gap:12px;display:flex}.hitl-pending-card{border:1px solid var(--semi-color-border);background:var(--semi-color-bg-1);border-radius:10px;flex-direction:column;gap:10px;padding:14px 16px;display:flex}.hitl-pending-head{flex-wrap:wrap;justify-content:space-between;align-items:flex-start;gap:8px;display:flex}.hitl-pending-meta{color:var(--semi-color-text-2);flex-wrap:wrap;align-items:center;gap:8px;font-size:12px;display:flex}.hitl-pending-meta-label{color:var(--semi-color-text-3)}.hitl-pending-deadline{background:var(--semi-color-fill-0);border-radius:999px;margin-left:auto;padding:1px 8px;font-size:12px}.hitl-pending-editor{flex-direction:column;gap:4px;display:flex}.hitl-pending-actions{justify-content:flex-end;align-items:center;gap:8px;display:flex}.hitl-context-blocks{flex-direction:column;gap:8px;display:flex}.hitl-context-block{border-left:3px solid var(--semi-color-border);flex-direction:column;gap:2px;padding-left:10px;display:flex}.hitl-context-block.hitl-state-success{border-left-color:var(--semi-color-success)}.hitl-context-block.hitl-state-failed{border-left-color:var(--semi-color-danger)}.hitl-context-label{color:var(--semi-color-text-2);font-size:12px}.hitl-context-text{white-space:pre-wrap;word-break:break-word;max-height:180px;color:var(--semi-color-text-1);margin:0;font-family:SFMono-Regular,Consolas,monospace;font-size:12px;line-height:1.5;overflow:auto}.hitl-inline-error{color:var(--semi-color-danger);background:var(--semi-color-danger-light-default);border-radius:6px;padding:8px 10px;font-size:12px}.hitl-args-textarea textarea,.hitl-whitelist-textarea textarea,.hitl-prompt-textarea textarea{font-family:SFMono-Regular,Consolas,monospace!important;font-size:12px!important;line-height:1.55!important}.hitl-mono{word-break:break-all;font-family:SFMono-Regular,Consolas,monospace;font-size:12px}.hitl-ellipsis{text-overflow:ellipsis;white-space:nowrap;word-break:normal;overflow-wrap:normal;vertical-align:bottom;max-width:100%;display:inline-block;overflow:hidden}.hitl-retention-hint{color:var(--semi-color-text-2);margin:0 0 10px;font-size:12px}.hitl-log-detail{flex-direction:column;gap:14px;display:flex}.hitl-log-by{flex-direction:column;gap:1px;display:flex}.hitl-log-engine{color:var(--semi-color-text-2);font-size:11px}.hitl-whitelist-meta{flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:8px;display:flex}.hitl-whitelist-tags{flex-wrap:wrap;gap:6px;max-height:160px;margin-top:10px;display:flex;overflow:auto}.hitl-strategy-panel{flex-direction:column;display:flex}.hitl-strategy-form{grid-template-columns:repeat(auto-fit,minmax(220px,1fr));align-items:start;gap:14px 20px;display:grid}.hitl-field{flex-direction:column;gap:6px;min-width:0;display:flex}.hitl-field-label{color:var(--semi-color-text-2);font-size:12px}.hitl-strategy-hint{color:var(--semi-color-text-2);margin:8px 0 0;font-size:12px}.hitl-prompt-grid{grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:16px;display:grid}.hitl-prompt-field{flex-direction:column;gap:6px;min-width:0;display:flex}.hitl-prompt-head{align-items:center;gap:8px;display:flex}.hitl-conv-query{flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:12px;display:flex}.hitl-conv-result{margin-top:4px}@media (max-width:720px){.hitl-pending-deadline{margin-left:0}.hitl-pending-actions{justify-content:stretch}.hitl-pending-actions .semi-button{flex:1 1 0}}.hitl-field-wide{grid-column:1/-1}
@@ -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,F as a,H as o,L as s,M as c,T as l,U as u,W as d,_ as f,c as p,f as m,m as h,ot as g,p as _,st as v,v as y,x as b,z as x}from"./semi-CHxO7u8f.js";import{E as S,F as C,I as w,P as T,S as E,a as D,b as O,d as k,l as A,m as j,n as ee,o as M,p as N,s as P,u as F,x as I,y as L}from"./index-CuUcClXg.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}=d;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]),l=H(e.mode)===`review_edit`,u=W(e.reviewer),[d,f]=(0,R.useState)(``),[p,m]=(0,R.useState)(()=>l&&i?JSON.stringify(i,null,2):``),[h,g]=(0,R.useState)(``),[_,v]=(0,R.useState)(``),y=(0,R.useCallback)(async t=>{if(h)return;let r;if(l&&p.trim()){try{r=JSON.parse(p)}catch(e){v(`修改后的参数不是合法 JSON:${e.message}`);return}if(!r||typeof r!=`object`||Array.isArray(r)){v(`修改后的参数必须是 JSON 对象`);return}}v(``),g(t);try{await w.post(`/hitl/decision`,{interruptId:e.id,decision:t,comment:d.trim(),editedArguments:r}),I(t===`approve`?`已通过,工具将继续执行`:`已拒绝本次工具调用`),n?.()}catch(t){if(t?.status===409){await w.post(`/hitl/dismiss`,{interruptId:e.id}).catch(()=>null),E(`该审批已被处理,列表已刷新`),n?.();return}O(t,`提交审批失败`)}finally{g(``)}},[l,p,h,d,e.id,n]),x=(0,R.useCallback)(()=>{L({title:`忽略该审批`,content:`忽略后该审批记为取消(reject),本次工具调用 Line truncated
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,F as a,H as o,L as s,M as c,T as l,U as u,W as d,_ as f,c as p,f as m,m as h,ot as g,p as _,st as v,v as y,x as b,z as x}from"./semi-CHxO7u8f.js";import{E as S,F as C,I as w,P as T,S as E,a as D,b as O,d as k,l as A,m as j,n as ee,o as M,p as N,s as P,u as F,x as I,y as L}from"./index-BLFHsWWk.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}=d;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]),l=H(e.mode)===`review_edit`,u=W(e.reviewer),[d,f]=(0,R.useState)(``),[p,m]=(0,R.useState)(()=>l&&i?JSON.stringify(i,null,2):``),[h,g]=(0,R.useState)(``),[_,v]=(0,R.useState)(``),y=(0,R.useCallback)(async t=>{if(h)return;let r;if(l&&p.trim()){try{r=JSON.parse(p)}catch(e){v(`修改后的参数不是合法 JSON:${e.message}`);return}if(!r||typeof r!=`object`||Array.isArray(r)){v(`修改后的参数必须是 JSON 对象`);return}}v(``),g(t);try{await w.post(`/hitl/decision`,{interruptId:e.id,decision:t,comment:d.trim(),editedArguments:r}),I(t===`approve`?`已通过,工具将继续执行`:`已拒绝本次工具调用`),n?.()}catch(t){if(t?.status===409){await w.post(`/hitl/dismiss`,{interruptId:e.id}).catch(()=>null),E(`该审批已被处理,列表已刷新`),n?.();return}O(t,`提交审批失败`)}finally{g(``)}},[l,p,h,d,e.id,n]),x=(0,R.useCallback)(()=>{L({title:`忽略该审批`,content:`忽略后该审批记为取消(reject),本次工具调用 Line truncated
`))},[r]);let m=(0,R.useMemo)(()=>ce(u),[u]),h=(0,R.useMemo)(()=>(r?.toolWhitelist||[]).join(`
`),[r]),g=u.trim()!==h.trim(),_=(0,R.useCallback)(async()=>{p(`put`);try{let e=await w.put(`/hitl/tool-whitelist`,{toolWhitelist:m});I(n(`hitl.whitelistSaved`,null,`白名单已保存`)),d((e?.toolWhitelist||m).join(`
`)),l({silent:!0})}catch(e){O(e,n(`hitl.whitelistSaveFailed`,null,`保存白名单失败`))}finally{p(``)}},[l,n,m]),y=(0,R.useCallback)(async()=>{p(`post`);try{let e=await w.post(`/hitl/tool-whitelist`,{sensitiveTools:m});I(e?.hitlGlobalWhitelistMerged?`已合并到全局白名单`:`没有新增工具,白名单未变化`),d((e?.hitlGlobalToolWhitelist||m).join(`
@@ -1,4 +1,4 @@
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dashboard-CwMIbV9-.js","assets/rolldown-runtime-WkwZ5CU-.js","assets/react-QV7DAAIx.js","assets/semi-CHxO7u8f.js","assets/semi-BUXPdXzR.css","assets/dashboard-Dk6QMmtm.css","assets/chat-MQ-irScZ.js","assets/retest-EzTZPjnQ.js","assets/project-form-B4r3E78D.js","assets/model-channel-mQ6lfvSO.js","assets/chat-C3m4vsYB.css","assets/hitl-BJ5xuOA-.js","assets/hitl-ChWaPsj1.css","assets/tool-guard-Cd23V3BD.js","assets/tool-guard-DKIWLN1V.css","assets/projects-BxGCqmlN.js","assets/AssetEditorModal-vqUCUeiX.js","assets/assetTarget-D2PEjBAg.js","assets/projects-BDwUv98l.css","assets/asset-overview-DWQllfxo.js","assets/AssetBits-RToEHLbz.js","assets/asset-overview-TjcTeyEy.css","assets/asset-library-t35KG5pT.js","assets/asset-library-a5Vth3JU.css","assets/info-collect-TpjImjFX.js","assets/info-collect-BrIcieOX.css","assets/vulnerabilities-VitBnghG.js","assets/vulnerabilities-BPt2JmiL.css","assets/tasks-D_aiDva-.js","assets/tasks-BtBBHKoW.css","assets/workflows-MiEucTJL.js","assets/workflows-EsKm07MV.css","assets/webshell-BWHVSjuo.js","assets/webshell-BdcYpY5u.css","assets/c2-listeners-CMv2tbOK.js","assets/c2-shared-B2ZrnT2E.js","assets/c2-shared-B-Nz9eUh.css","assets/c2-shared-Dl_EFMrT.js","assets/c2-listeners-KjhK45yg.css","assets/c2-sessions-CwVCmo1s.js","assets/c2-sessions-DLf_n8Eq.css","assets/c2-tasks-BWE4sHWb.js","assets/c2-tasks-B5H34xZF.css","assets/c2-payloads-DWUWGBbt.js","assets/c2-payloads-CnRJmaJm.css","assets/c2-events-PxdL3axH.js","assets/c2-events-BVd4qqKy.css","assets/c2-profiles-D_mN8ZZN.js","assets/c2-profiles-BpNJlhDC.css","assets/chat-files-BqQDidG2.js","assets/chat-files-wKL7Vwmw.css","assets/mcp-monitor-Cx-olJT9.js","assets/mcp-monitor-8VvqmnVY.css","assets/mcp-management-6jMApdna.js","assets/mcp-management-CEr7J00D.css","assets/knowledge-retrieval-logs-bNJuIFex.js","assets/knowledge-management-n14i8jIK.js","assets/skills-monitor-J-TSPpgn.js","assets/skills-management-DgeBlJ44.js","assets/agents-management-g3hl4xKs.js","assets/roles-management-C2tSw-KJ.js","assets/roles-management-CAkb5FLz.css","assets/platform-rbac-DGTThFYQ.js","assets/settings-DTirHzyj.js","assets/settings-i8zJhYeE.css","assets/api-docs-BmW4sCFY.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-DOx9klvz.js","assets/rolldown-runtime-WkwZ5CU-.js","assets/react-QV7DAAIx.js","assets/semi-CHxO7u8f.js","assets/semi-BUXPdXzR.css","assets/dashboard-Dk6QMmtm.css","assets/chat-CqkBz4iv.js","assets/retest-EzTZPjnQ.js","assets/project-form-B3I4tCMR.js","assets/model-channel-mQ6lfvSO.js","assets/chat-C3m4vsYB.css","assets/hitl-CPsiijDu.js","assets/hitl-BqmzzDjt.css","assets/tool-guard-BcLXpyKh.js","assets/tool-guard-DKIWLN1V.css","assets/projects-DIuHUlX4.js","assets/AssetEditorModal-DwPErx6-.js","assets/assetTarget-D2PEjBAg.js","assets/projects-BDwUv98l.css","assets/asset-overview-C-KzDY_G.js","assets/AssetBits-RToEHLbz.js","assets/asset-overview-TjcTeyEy.css","assets/asset-library-CWmafsK0.js","assets/asset-library-a5Vth3JU.css","assets/info-collect-BNel3vxB.js","assets/info-collect-BrIcieOX.css","assets/vulnerabilities-TR0d6Es5.js","assets/vulnerabilities-BPt2JmiL.css","assets/tasks-tMvlZK9a.js","assets/tasks-BtBBHKoW.css","assets/workflows-DONfUfvI.js","assets/workflows-EsKm07MV.css","assets/webshell-DwtGbrbp.js","assets/webshell-BdcYpY5u.css","assets/c2-listeners-i__g7cx6.js","assets/c2-shared-DlL4rVOl.js","assets/c2-shared-B-Nz9eUh.css","assets/c2-shared-CTf-cTfI.js","assets/c2-listeners-KjhK45yg.css","assets/c2-sessions-DWIERsTv.js","assets/c2-sessions-DLf_n8Eq.css","assets/c2-tasks-BwrRi0Nx.js","assets/c2-tasks-B5H34xZF.css","assets/c2-payloads-CwlpCkn1.js","assets/c2-payloads-CnRJmaJm.css","assets/c2-events-DMJI0a2u.js","assets/c2-events-BVd4qqKy.css","assets/c2-profiles-BWoO0lCm.js","assets/c2-profiles-BpNJlhDC.css","assets/chat-files-TUf0CbGq.js","assets/chat-files-wKL7Vwmw.css","assets/mcp-monitor-HhCNh3CZ.js","assets/mcp-monitor-8VvqmnVY.css","assets/mcp-management-7p_1tDLM.js","assets/mcp-management-CEr7J00D.css","assets/knowledge-retrieval-logs-4p8ViYwm.js","assets/knowledge-management-Daui68Bz.js","assets/skills-monitor-BlWPK0OG.js","assets/skills-management-Clqe9TeA.js","assets/agents-management-CoKwM-Pg.js","assets/roles-management-nbqhNyx-.js","assets/roles-management-CAkb5FLz.css","assets/platform-rbac--R5Qjwqt.js","assets/settings-CIjpiQTy.js","assets/settings-i8zJhYeE.css","assets/api-docs-BTgOH4Ej.js","assets/api-docs-B_T3BEfL.css"])))=>i.map(i=>d[i]);
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{$ as t,B as n,Bt as r,C as i,D as a,Dt as o,F as s,G as c,Gt as l,Ht as u,I as d,It as f,K as p,Kt as m,L as h,Lt as ee,M as g,Mt as _,Nt as te,P as v,Q as ne,Qt as re,R as y,Rt as ie,T as b,Tt as ae,U as x,Ut as oe,V as se,W as ce,Wt as le,_t as ue,bt as de,ct as fe,f as pe,ft as me,ht as he,i as S,it as ge,j as _e,k as ve,l as ye,mt as C,n as be,nt as xe,o as Se,q as Ce,qt as we,r as Te,rt as Ee,st as De,t as Oe,vt as w,w as ke,wt as T,y as Ae,yt as E,z as je,zt as Me}from"./semi-CHxO7u8f.js";import{S as D,b as Ne,d as Pe,f as Fe,g as Ie,h as O,l as Le,m as Re,p as ze,t as Be,v as Ve}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 k=e(D(),1),He=Ne(),Ue=`cyberstrike-auth`;function We(){try{let e=localStorage.getItem(Ue);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 Ge(e){e?localStorage.setItem(Ue,JSON.stringify(e)):localStorage.removeItem(Ue)}var Ke=null;function qe(e){Ke=e||null}var Je=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 Ye(e,t){let n=`/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 Xe(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={Accept:`application/json`,...a},u=r;r!=null&&!(r instanceof FormData)&&typeof r!=`string`&&!(r instanceof Blob)&&(l[`Content-Type`]=`application/json`,u=JSON.stringify(r)),Ke&&!l.Authorization&&(l.Authorization=`Bearer ${Ke}`);let d=new AbortController,f=c?setTimeout(()=>d.abort(),c):null,p=()=>d.abort();o&&(o.aborted?d.abort():o.addEventListener(`abort`,p,{once:!0}));let m;try{m=await fetch(Ye(e,i),{method:n,headers:l,body:u,signal:d.signal})}catch(t){throw t.name===`AbortError`?new Je(`请求已取消`,{path:e}):new Je(`网络连接失败,请检查服务状态`,{path:e})}finally{f&&clearTimeout(f),o&&o.removeEventListener(`abort`,p)}if(m.status===401&&window.dispatchEvent(new CustomEvent(`csai:unauthorized`)),!m.ok){let{message:t,payload:n}=await Xe(m);throw new Je(t,{status:m.status,payload:n,path:e})}return s?m:m.status===204?null:(m.headers.get(`content-type`)||``).includes(`application/json`)?m.json():m.text()}var 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 Ze(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 Qe(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 Ke&&(s.Authorization=`Bearer ${Ke}`),(async()=>{try{let r=await fetch(Ye(e),{method:`POST`,headers:s,body:JSON.stringify(t||{}),signal:o.signal});if(rLine truncated
`))>=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 $e(e,t=`操作失败`){return e?typeof e==`string`?e:e.message||t:t}var M=e(Be(),1),et=(0,k.createContext)(null);function tt(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 nt({children:e}){let t=(0,k.useRef)(We()).current,[n,r]=(0,k.useState)(t),[i,a]=(0,k.useState)(!!t);(0,k.useEffect)(()=>{if(qe(t?.token||null),!t?.token){a(!1);return}let e=!1;return j.get(`/auth/validate`).then(n=>{if(e)return;let i=tt(n,t.token);r(i),Ge(i)}).catch(()=>{e||(r(null),Ge(null),qe(null))}).finally(()=>{e||a(!1)}),()=>{e=!0}},[]);let o=(0,k.useCallback)(()=>{r(null),qe(null),Ge(null)},[]);(0,k.useEffect)(()=>{let e=()=>o();return window.addEventListener(`csai:unauthorized`,e),()=>window.removeEventListener(`csai:unauthorized`,e)},[o]);let s=(0,k.useCallback)(async(e,t)=>{let n=await j.post(`/auth/login`,{username:String(e||``).trim(),password:t}),i=tt(n,n?.token);return qe(i?.token||null),Ge(i),r(i),i},[]),c=(0,k.useCallback)(async()=>{try{await j.post(`/auth/logout`,{})}catch{}o()},[o]),l=(0,k.useMemo)(()=>new Set(n?.permissions||[]),[n]),u=(0,k.useCallback)(e=>!e||String(e).split(/\s+/).some(e=>l.has(e)),[l]),d=(0,k.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,k.useCallback)(async()=>{if(!n?.token)return null;let e=tt(await j.get(`/auth/validate`),n.token);return r(e),Ge(e),e},[n?.token]),p=(0,k.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)(et.Provider,{value:p,children:e})}function N(){let e=(0,k.useContext)(et);if(!e)throw Error(`useAuth 必须在 AuthProvider 内使用`);return e}var rt=[{id:`zh-CN`,label:`简体中文`},{id:`en-US`,label:`English`},{id:`ru-RU`,label:`Русский`},{id:`ar-SA`,label:`العربية`}],it=`csai_lang`,at=`zh-CN`,ot=`/static/i18n`,st=new Map;function ct(){try{let e=localStorage.getItem(it);if(e&&rt.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`:at}function lt(e){return st.has(e)||st.set(e,fetch(`${ot}/${e}.json`,{cache:`no-cache`}).then(e=>e.ok?e.json():{}).catch(()=>({}))),st.get(e)}function ut(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 dt(e,t){return t?e.replace(/\{\{\s*(\w+)\s*\}\}/g,(e,n)=>t[n]===void 0?e:String(t[n])):e}var ft=(0,k.createContext)({lang:at,t:e=>e,ready:!1,setLanguage:()=>{}});function pt({children:e}){let[t,n]=(0,k.useState)(ct),[r,i]=(0,k.useState)({}),[a,o]=(0,k.useState)(!1);(0,k.useEffect)(()=>{let e=!1;Promise.all([lt(t),lt(at),lt(`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(it,t)}catch{}return()=>{e=!0}},[t]);let s=(0,k.useCallback)((e,t,n)=>{if(!e)return n??``;let i=ut(r.current,e)??ut(r.fallback,e)??ut(r.english,e);return i===void 0?n??e:dt(i,t)},[r]),c=(0,k.useCallback)(e=>{e&&e!==t&&(o(!1),n(e),window.dispatchEvent(new CustomEvent(`csai:languagechange`,{detail:{lang:e}})))},[t]),l=(0,k.useMemo)(()=>({lang:t,t:s,ready:a,setLanguage:c}),[t,s,a,c]);return(0,M.jsx)(ft.Provider,{value:l,children:e})}function mt(){return(0,k.useContext)(ft)}function P(){return(0,k.useContext)(ft).t}var ht=`cyberstrike-theme`,gt=[`system`,`light`,`dark`];function _t(){try{let e=localStorage.getItem(ht);return gt.includes(e)?e:`system`}catch{return`system`}}function vt(){return typeof window<`u`&&window.matchMedia?window.matchMedia(`(prefers-color-scheme: dark)`).matches:!1}function yt(e){return e===`dark`||e===`light`?e:vt()?`dark`:`light`}function bt(e){let t=yt(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 xt=(0,k.createContext)({preference:`system`,theme:`light`,setPreference:()=>{},toggle:()=>{}});function St({children:e}){let[t,n]=(0,k.useState)(_t),[r,i]=(0,k.useState)(()=>yt(_t()));(0,k.useLayoutEffect)(()=>{i(bt(t));try{localStorage.setItem(ht,t)}catch{}if(t!==`system`||!window.matchMedia)return;let e=window.matchMedia(`(prefers-color-scheme: darLine truncated
]`).replace(`lheading`,Ut).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},nn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,rn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,an=/^( {2,}|\\)\n(?!\s*$)/,on=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,sn=/[\p{P}\p{S}]/u,cn=/[\s\p{P}\p{S}]/u,ln=/[^\s\p{P}\p{S}]/u,un=L(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,cn).getRegex(),dn=/(?!~)[\p{P}\p{S}]/u,fn=/(?!~)[\s\p{P}\p{S}]/u,pn=/(?:[^\s\p{P}\p{S}]|~)/u,mn=L(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Ft?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),hn=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,gn=L(hn,`u`).replace(/punct/g,sn).getRegex(),_n=L(hn,`u`).replace(/punct/g,dn).getRegex(),vn=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,yn=L(vn,`gu`).replace(/notPunctSpace/g,ln).replace(/punctSpace/g,cn).replace(/punct/g,sn).getRegex(),bn=L(vn,`gu`).replace(/notPunctSpace/g,pn).replace(/punctSpace/g,fn).replace(/punct/g,dn).getRegex(),xn=L(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,ln).replace(/punctSpace/g,cn).replace(/punct/g,sn).getRegex(),Sn=L(/\\(punct)/,`gu`).replace(/punct/g,sn).getRegex(),Cn=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(),wn=L(Yt).replace(`(?:-->|$)`,`-->`).getRegex(),Tn=L(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,wn).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),En=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Dn=L(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,En).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),On=L(/^!?\[(label)\]\[(ref)\]/).replace(`label`,En).replace(`ref`,Kt).getRegex(),kn=L(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Kt).getRegex(),An=L(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,On).replace(`nolink`,kn).getRegex(),jn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Mn={_backpedal:Pt,anyPunctuation:Sn,autolink:Cn,blockSkip:mn,br:an,code:rn,del:Pt,emStrongLDelim:gn,emStrongRDelimAst:yn,emStrongRDelimUnd:xn,escape:nn,link:Dn,nolink:kn,punctuation:un,reflink:On,reflinkSearch:An,tag:Tn,text:on,url:Pt},Nn={...Mn,link:L(/^!?\[(label)\]\((.*?)\)/).replace(`label`,En).getRegex(),reflink:L(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,En).getRegex()},Pn={...Mn,emStrongRDelimAst:bn,emStrongLDelim:_n,url:L(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,jn).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]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,jn).getRegex()},Fn={...Pn,br:L(an).replace(`{2,}`,`*`).getRegex(),text:L(Pn.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},In={normal:Qt,gfm:en,pedantic:tn},Ln={normal:Mn,gfm:Pn,breaks:Fn,pedantic:Nn},Rn={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},zn=e=>Rn[e];function V(e,t){if(t){if(R.escapeTest.test(e))return e.replace(R.escapeReplace,zn)}else if(R.escapeTestNoEncode.test(e))return e.replace(R.escapeReplaceNoEncode,zn);return e}function Bn(e){try{e=encodeURI(e).replace(R.percentDecode,`%`)}catch{return null}return e}function Vn(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.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(R.slashPipe,`|`);return n}functionLine truncated
@@ -61,4 +61,4 @@ ${e}</tr>
`+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<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Yn=(At=class{constructor(e){I(this,`options`,void 0),I(this,`block`,void 0),this.options=e||Mt}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?H.lex:H.lexInline}provideParser(){return this.block?U.parse:U.parseInline}},I(At,`passThroughHooks`,new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`])),I(At,`passThroughHooksRespectAsync`,new Set([`preprocess`,`postprocess`,`processAllTokens`])),At),Xn=new class{constructor(...e){I(this,`defaults`,jt()),I(this,`options`,this.setOptions),I(this,`parse`,this.parseMarkdown(!0)),I(this,`parseInline`,this.parseMarkdown(!1)),I(this,`Parser`,U),I(this,`Renderer`,qn),I(this,`TextRenderer`,Jn),I(this,`Lexer`,H),I(this,`Tokenizer`,Kn),I(this,`Hooks`,Yn),this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(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 qn(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 Kn(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 Yn;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]=Yn.passThroughHooks.has(n)?e=>{if(this.defaults.async&&Yn.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.as Line truncated
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+V(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function W(e,t){return Xn.parse(e,t)}W.options=W.setOptions=function(e){return Xn.setOptions(e),W.defaults=Xn.defaults,Nt(W.defaults),W},W.getDefaults=jt,W.defaults=Mt,W.use=function(...e){return Xn.use(...e),W.defaults=Xn.defaults,Nt(W.defaults),W},W.walkTokens=function(e,t){return Xn.walkTokens(e,t)},W.parseInline=Xn.parseInline,W.Parser=U,W.parser=U.parse,W.Renderer=qn,W.TextRenderer=Jn,W.Lexer=H,W.lexer=H.lex,W.Tokenizer=Kn,W.Hooks=Yn,W.parse=W,W.options,W.setOptions,W.use,W.walkTokens,W.parseInline,U.parse,H.lex;function Zn(e,t){this.v=e,this.k=t}function Qn(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function $n(e){if(Array.isArray(e))return e}function er(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function tr(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nr(e,t){return $n(e)||er(e,t)||rr(e,t)||tr()}function rr(e,t){if(e){if(typeof e==`string`)return Qn(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Qn(e,t):void 0}}function ir(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof Zn;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}ir.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},ir.prototype.next=function(e){return this._invoke(`next`,e)},ir.prototype.throw=function(e){return this._invoke(`throw`,e)},ir.prototype.return=function(e){return this._invoke(`return`,e)};var ar=Object.entries,or=Object.keys,sr=Object.setPrototypeOf,cr=Object.isFrozen,lr=Object.getPrototypeOf,ur=Object.getOwnPropertyDescriptor,G=Object.freeze,K=Object.seal,dr=Object.create,fr=typeof Reflect<`u`&&Reflect,pr=fr.apply,mr=fr.construct;G||(G=function(e){return e}),K||(K=function(e){return e}),pr||(pr=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)}),mr||(mr=function(e){return new e(...[...arguments].slice(1))});var hr=Y(Array.prototype.forEach),gr=Y(Array.prototype.lastIndexOf),_r=Y(Array.prototype.pop),vr=Y(Array.prototype.push),yr=Y(Array.prototype.slice),br=Y(Array.prototype.splice),xr=Array.isArray,Sr=Rr(Set),Cr=Y(Set.prototype.add),wr=Y(Set.prototype.has),Tr=Y(String.prototype.toLowerCase),Er=Y(String.prototype.toString),Dr=Y(String.prototype.match),Or=Y(String.prototype.replace),kr=Y(String.prototype.indexOf),Ar=Y(String.prototype.trim),jr=Y(Number.prototype.toString),Mr=Y(Boolean.prototype.toString),Nr=typeof BigInt>`u`?null:Y(BigInt.prototype.toString),Pr=typeof Symbol>`u`?null:Y(Symbol.prototype.toString),q=Y(Object.prototype.hasOwnProperty),Fr=Y(Object.prototype.toString),Ir=RegExp.prototype.test,J=function(e,t){return e instanceof RegExp&&(e.lastIndex=0),pr(Ir,e,[t])},Lr=Rr(TypeError);function Y(e){return function(t){var n=[...arguments].slice(1);return pr(e,t,n)}}function Rr(e){return function(){return mr(e,[...arguments])}}function X(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Tr;if(sr&&sr(e,null),!xr(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(cr(t)||(t[r]=e),i=e)}e[i]=!0}return e}function zr(e){for(let t=0;t<e.length;t++)q(e,t)||(e[t]=null);return e}function Br(e){let t=dr(null);for(let r of ar(e)){var n=nr(r,2);let i=n[0],a=n[1];q(e,i)&&(t[i]=xr(a)?zr(a):a&&typeof a==`object`&&a.constructor===Object?Br(a):a)}return t}function Vr(e){let t=dr(null),n=or(e),r=n.length;for(;r--;)t[n[r]]=e[n[r]];return t}function Hr(e){switch(typeof e){case`string`:return e;case`number`:return jr(e);case`boolean`:return Mr(e);case`bigint`:return Nr?Nr(e):`0`;case`symbol`:return Pr?Pr(e):`Symbol()`;case`undefined`:return Fr(e);case`function`:case`object`:{if(e===null)return Fr(e);let t=e,n=Z(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Fr(e)}return Fr(e)}default:return Fr(e)}}function Z(e,t){for(;e!==null;){let n=ur(e,t);if(n){if(n.get)return Y(n.get);if(typeof n.value==`function`)return Y(n.value)}e=lr(e)}function n(){return null}return n}function Ur(e,t){for(;e!==null;){let n=ur(e,t);if(n)return n.get?Y(n.get):null;e=lr(e)}return null}function Wr(e){if(!e)return!1;try{return J(e,``),!0}catch{return!1}}var Gr=G(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Kr=G(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.filter.font.g.glyph.glyphref.hkern.image.line.lineargradient.marker.mask.metadata.mpath.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),qr=G([`feBlend`,`feColorMatrix`,`feComponentTransferLine truncated
`+p),fe(p)},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};vt(e),ze=!0,Be=w,Ve=T},t.clearConfig=function(){ht=null,ze=!1,Be=null,Ve=null,x=se,oe=``},t.isValidAttribute=function(e,t,n){ht||vt({});let r=P(e),i=P(t);return typeof n==`string`&&(tn(t,n)||!Ie&&J(gi,n))?!1:Xt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&q(C,e)&&vr(C[e],t)},t.removeHook=function(e,t){if(q(C,e)){if(t!==void 0){let n=gr(C[e],t);return n===-1?void 0:br(C[e],n,1)[0]}return _r(C[e])}},t.removeHooks=function(e){q(C,e)&&(C[e]=[])},t.removeAllHooks=function(){C=Si()},t}var Ei=Ti(),Di=[`critical`,`high`,`medium`,`low`,`info`],Oi={critical:`red`,high:`orange`,medium:`amber`,low:`blue`,info:`grey`},ki={critical:`严重`,high:`高危`,medium:`中危`,low:`低危`,info:`信息`},Ai={running:`blue`,pending:`amber`,queued:`amber`,paused:`grey`,success:`green`,succeeded:`green`,completed:`green`,done:`green`,failed:`red`,error:`red`,cancelled:`grey`,canceled:`grey`,stopped:`grey`,active:`green`,inactive:`grey`,online:`green`,offline:`grey`,open:`red`,closed:`green`,archived:`grey`};function ji(e,t=`zh-CN`){if(!e)return`—`;let n=e instanceof Date?e:new Date(e);return Number.isFinite(n.getTime())?n.toLocaleString(t,{hour12:!1}):`—`}function Mi(e,t=`zh-CN`){if(!e)return`—`;let n=e instanceof Date?e:new Date(e);return Number.isFinite(n.getTime())?n.toLocaleDateString(t):`—`}function Ni(e,t){if(!e)return`—`;let n=new Date(e);if(!Number.isFinite(n.getTime()))return`—`;let r=Date.now()-n.getTime();return r<6e4?t?.(`common.justNow`,null,`刚刚`)||`刚刚`:r<36e5?t?.(`common.minutesAgo`,{n:Math.floor(r/6e4)},`${Math.floor(r/6e4)} 分钟前`):r<864e5?t?.(`common.hoursAgo`,{n:Math.floor(r/36e5)},`${Math.floor(r/36e5)} 小时前`):r<2592e6?t?.(`common.daysAgo`,{n:Math.floor(r/864e5)},`${Math.floor(r/864e5)} 天前`):Mi(e)}function Pi(e){let t=Number(e);if(!Number.isFinite(t)||t<0)return`—`;if(t<1024)return`${t} B`;let n=[`KB`,`MB`,`GB`,`TB`],r=t/1024,i=0;for(;r>=1024&&i<n.length-1;)r/=1024,i+=1;return`${r.toFixed(r>=100?0:1)} ${n[i]}`}function Fi(e,t=`zh-CN`){let n=Number(e);return Number.isFinite(n)?n.toLocaleString(t):`—`}function Ii(e,t=1){let n=Number(e);return Number.isFinite(n)?`${(n*(n<=1?100:1)).toFixed(t)}%`:`—`}function Li(e){return Oi[String(e||``).toLowerCase()]||`grey`}function Ri(e){return Ai[String(e||``).toLowerCase()]||`grey`}function zi(e,t=120){let n=String(e??``);return n.length>t?`${n.slice(0,t)}…`:n}var{Title:Bi,Text:Vi,Paragraph:Hi}=ce;function Ui(e){Se.success({content:e,duration:2})}function Wi(e){Se.warning({content:e,duration:3})}function Gi(e,t=`操作失败`){Se.error({content:$e(e,t),duration:4})}function Ki({title:e,description:t,extra:n,children:r}){return(0,M.jsxs)(`header`,{className:`cs-page-header`,children:[(0,M.jsxs)(`div`,{className:`cs-page-header-main`,children:[(0,M.jsx)(Bi,{heading:3,className:`cs-page-title`,children:e}),t&&(0,M.jsx)(Vi,{type:`tertiary`,className:`cs-page-desc`,children:t}),r]}),n&&(0,M.jsx)(s,{className:`cs-page-header-extra`,wrap:!0,children:n})]})}function qi({title:e,description:t,extra:n,children:r,className:i=``,bodyClassName:a=``}){return(0,M.jsxs)(v,{className:`cs-section-card ${i}`,title:e?(0,M.jsx)(`span`,{className:`cs-section-title`,children:e}):void 0,headerExtraContent:n,bordered:!1,children:[t&&(0,M.jsx)(Hi,{type:`tertiary`,className:`cs-section-desc`,children:t}),(0,M.jsx)(`div`,{className:a,children:r})]})}function Ji({metrics:e,columns:t=4}){return(0,M.jsx)(`div`,{className:`cs-stat-grid`,style:{"--cs-stat-columns":t},children:e.map(e=>(0,M.jsx)(Yi,{...e},e.id||e.label))})}function Yi({label:e,value:t,valueTitle:n,detail:r,tone:i,severity:a,icon:o,onClick:s,pressed:c,loading:l=!1}){let u=(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`span`,{className:`cs-stat-head`,children:[(0,M.jsx)(Vi,{type:`tertiary`,className:`cs-stat-label`,children:e}),o&&(0,M.jsx)(`span`,{className:`cs-stat-icon ${i?`tone-${i}`:``}`,"aria-hidden":`true`,children:o})]}),(0,M.jsx)(d,{loading:l,placeholder:(0,M.jsx)(d.Title,{style:{width:`60%`,height:36,margin:`8px 0`}}),children:(0,M.jsx)(`span`,{className:`cs-stat-value ${i?`tone-${i}`:``}`,title:n,children:t??`—`})}),r&&(0,M.jsx)(`span`,{className:`cs-stat-detail`,children:r})]});return s?(0,M.jsx)(h,{className:`cs-stat-card is-clickable`,theme:`borderless`,onClick:s,"aria-label":String(e),"aria-pressed":c,"data-severity":a,children:u}):(0,M.jsx)(v,{className:`cs-stat-card`,"data-severity":a,bordered:!1,children:u})}function Xi({columns:e,dataSource:t,rowKey:n=`id`,loading:r,pagination:i,emptyText:a,onRefresh:o,toolbar:s,size:c=`default`,className:l=``,...u}){let d=P(),f=i!==!1&&{pageSize:10,showSizeChanger:!0,pageSizeOpts:[10,20,50,100],showTotal:!0,...i||{}};return(0,M.jsxs)(`div`,{className:`cs-table-wrap ${l}`,children:[(s||o)&&(0,M.jsxs)(`div`,{className:`cs-table-toolbar`,children:[(0,M.jsx)(`div`,{className:`cs-table-toolbar-main`,children:s}),o&&(0,M.jsx)(h,{icon:(0,M.jsx)(De,{}) Line truncated
`+p),fe(p)},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};vt(e),ze=!0,Be=w,Ve=T},t.clearConfig=function(){ht=null,ze=!1,Be=null,Ve=null,x=se,oe=``},t.isValidAttribute=function(e,t,n){ht||vt({});let r=P(e),i=P(t);return typeof n==`string`&&(tn(t,n)||!Ie&&J(gi,n))?!1:Xt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&q(C,e)&&vr(C[e],t)},t.removeHook=function(e,t){if(q(C,e)){if(t!==void 0){let n=gr(C[e],t);return n===-1?void 0:br(C[e],n,1)[0]}return _r(C[e])}},t.removeHooks=function(e){q(C,e)&&(C[e]=[])},t.removeAllHooks=function(){C=Si()},t}var Ei=Ti(),Di=[`critical`,`high`,`medium`,`low`,`info`],Oi={critical:`red`,high:`orange`,medium:`amber`,low:`blue`,info:`grey`},ki={critical:`严重`,high:`高危`,medium:`中危`,low:`低危`,info:`信息`},Ai={running:`blue`,pending:`amber`,queued:`amber`,paused:`grey`,success:`green`,succeeded:`green`,completed:`green`,done:`green`,failed:`red`,error:`red`,cancelled:`grey`,canceled:`grey`,stopped:`grey`,active:`green`,inactive:`grey`,online:`green`,offline:`grey`,open:`red`,closed:`green`,archived:`grey`};function ji(e,t=`zh-CN`){if(!e)return`—`;let n=e instanceof Date?e:new Date(e);return Number.isFinite(n.getTime())?n.toLocaleString(t,{hour12:!1}):`—`}function Mi(e,t=`zh-CN`){if(!e)return`—`;let n=e instanceof Date?e:new Date(e);return Number.isFinite(n.getTime())?n.toLocaleDateString(t):`—`}function Ni(e,t){if(!e)return`—`;let n=new Date(e);if(!Number.isFinite(n.getTime()))return`—`;let r=Date.now()-n.getTime();return r<6e4?t?.(`common.justNow`,null,`刚刚`)||`刚刚`:r<36e5?t?.(`common.minutesAgo`,{n:Math.floor(r/6e4)},`${Math.floor(r/6e4)} 分钟前`):r<864e5?t?.(`common.hoursAgo`,{n:Math.floor(r/36e5)},`${Math.floor(r/36e5)} 小时前`):r<2592e6?t?.(`common.daysAgo`,{n:Math.floor(r/864e5)},`${Math.floor(r/864e5)} 天前`):Mi(e)}function Pi(e){let t=Number(e);if(!Number.isFinite(t)||t<0)return`—`;if(t<1024)return`${t} B`;let n=[`KB`,`MB`,`GB`,`TB`],r=t/1024,i=0;for(;r>=1024&&i<n.length-1;)r/=1024,i+=1;return`${r.toFixed(r>=100?0:1)} ${n[i]}`}function Fi(e,t=`zh-CN`){let n=Number(e);return Number.isFinite(n)?n.toLocaleString(t):`—`}function Ii(e,t=1){let n=Number(e);return Number.isFinite(n)?`${(n*(n<=1?100:1)).toFixed(t)}%`:`—`}function Li(e){return Oi[String(e||``).toLowerCase()]||`grey`}function Ri(e){return Ai[String(e||``).toLowerCase()]||`grey`}function zi(e,t=120){let n=String(e??``);return n.length>t?`${n.slice(0,t)}…`:n}var{Title:Bi,Text:Vi,Paragraph:Hi}=ce;function Ui(e){Se.success({content:e,duration:2})}function Wi(e){Se.warning({content:e,duration:3})}function Gi(e,t=`操作失败`){Se.error({content:$e(e,t),duration:4})}function Ki({title:e,description:t,extra:n,children:r}){return(0,M.jsxs)(`header`,{className:`cs-page-header`,children:[(0,M.jsxs)(`div`,{className:`cs-page-header-main`,children:[(0,M.jsx)(Bi,{heading:3,className:`cs-page-title`,children:e}),t&&(0,M.jsx)(Vi,{type:`tertiary`,className:`cs-page-desc`,children:t}),r]}),n&&(0,M.jsx)(s,{className:`cs-page-header-extra`,wrap:!0,children:n})]})}function qi({title:e,description:t,extra:n,children:r,className:i=``,bodyClassName:a=``}){return(0,M.jsxs)(v,{className:`cs-section-card ${i}`,title:e?(0,M.jsx)(`span`,{className:`cs-section-title`,children:e}):void 0,headerExtraContent:n,bordered:!1,children:[t&&(0,M.jsx)(Hi,{type:`tertiary`,className:`cs-section-desc`,children:t}),(0,M.jsx)(`div`,{className:a,children:r})]})}function Ji({metrics:e,columns:t=4}){return(0,M.jsx)(`div`,{className:`cs-stat-grid`,style:{"--cs-stat-columns":t},children:e.map(e=>(0,M.jsx)(Yi,{...e},e.id||e.label))})}function Yi({label:e,value:t,valueTitle:n,detail:r,tone:i,severity:a,icon:o,onClick:s,pressed:c,loading:l=!1}){let u=(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`span`,{className:`cs-stat-head`,children:[(0,M.jsx)(Vi,{type:`tertiary`,className:`cs-stat-label`,children:e}),o&&(0,M.jsx)(`span`,{className:`cs-stat-icon ${i?`tone-${i}`:``}`,"aria-hidden":`true`,children:o})]}),(0,M.jsx)(d,{loading:l,placeholder:(0,M.jsx)(d.Title,{style:{width:`60%`,height:36,margin:`8px 0`}}),children:(0,M.jsx)(`span`,{className:`cs-stat-value ${i?`tone-${i}`:``}`,title:n,children:t??`—`})}),r&&(0,M.jsx)(`span`,{className:`cs-stat-detail`,children:r})]});return s?(0,M.jsx)(h,{className:`cs-stat-card is-clickable`,theme:`borderless`,onClick:s,"aria-label":String(e),"aria-pressed":c,"data-severity":a,children:u}):(0,M.jsx)(v,{className:`cs-stat-card`,"data-severity":a,bordered:!1,children:u})}function Xi({columns:e,dataSource:t,rowKey:n=`id`,loading:r,pagination:i,emptyText:a,onRefresh:o,toolbar:s,size:c=`default`,className:l=``,...u}){let d=P(),f=i!==!1&&{pageSize:10,showSizeChanger:!0,pageSizeOpts:[10,20,50,100],showTotal:!0,...i||{}};return(0,M.jsxs)(`div`,{className:`cs-table-wrap ${l}`,children:[(s||o)&&(0,M.jsxs)(`div`,{className:`cs-table-toolbar`,children:[(0,M.jsx)(`div`,{className:`cs-table-toolbar-main`,children:s}),o&&(0,M.jsx)(h,{icon:(0,M.jsx)(De,{}) Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,Pt as o,T as s,U as c,W as l,_ as u,b as d,f,ot as p,st as m,u as h,v as g,x as _,z as v}from"./semi-CHxO7u8f.js";import{F as ee,I as y,P as b,S as x,b as S,c as C,d as w,i as te,l as ne,m as re,p as ie,s as T,u as ae,x as oe}from"./index-CuUcClXg.js";import{a as E}from"./AssetBits-RToEHLbz.js";import{a as D,i as O,o as k}from"./assetTarget-D2PEjBAg.js";var A=e(t(),1),j={fofa:{label:`FOFA`,maxSize:1e4,defaultFields:`host,ip,port,domain,title,protocol,country,region,city,server`,placeholder:`app="Apache" && country="CN"`,fieldPresets:[[`最小字段`,`host,ip,port,domain`],[`Web 常用`,`host,title,ip,port,domain,protocol,server,icp,country,region,city`],[`情报增强`,`host,ip,port,domain,title,protocol,country,region,city,server,asn,org,icp,header,banner`]],queryPresets:[[`Apache + 中国`,`app="Apache" && country="CN"`],[`登录页 + 中国`,`title="登录" && country="CN"`],[`指定域名`,`domain="example.com"`],[`指定 IP`,`ip="1.1.1.1"`]],supportsFull:!0},zoomeye:{label:`ZoomEye`,maxSize:1e4,defaultFields:`ip,port,domain,hostname,title,service,app,country,city`,placeholder:`app="Apache" && country="CN"`,fieldPresets:[[`最小字段`,`ip,port,domain,hostname`],[`Web 常用`,`ip,port,domain,hostname,title,service,app,country,city`],[`情报增强`,`ip,port,domain,hostname,title,service,app,country,city,org,isp,ssl`]],queryPresets:[[`Apache + 中国`,`app="Apache" && country="CN"`],[`SSH 服务`,`service="ssh"`],[`指定域名`,`domain="example.com"`],[`指定 IP`,`ip="1.1.1.1"`]],supportsFull:!1},quake:{label:`Quake`,maxSize:1e4,defaultFields:`ip,port,domain,service.name,service.http.title,location.country_cn,location.province_cn,location.city_cn`,placeholder:`service.name:"http" AND country_cn:"中国"`,fieldPresets:[[`最小字段`,`ip,port,domain`],[`Web 常用`,`ip,port,domain,service.name,service.http.title,location.country_cn,location.city_cn`],[`情报增强`,`ip,port,domain,service.name,service.http.title,service.http.server,location.country_cn,location.province_cn,location.city_cn,asn`]],queryPresets:[[`HTTP + 中国`,`service.name:"http" AND country_cn:"中国"`],[`443 端口`,`port:443`],[`指定域名`,`domain:"example.com"`],[`指定 IP`,`ip:"1.1.1.1"`]],supportsFull:!0},shodan:{label:`Shodan`,maxSize:1e3,defaultFields:`ip_str,port,hostnames,domains,org,isp,location.country_name,location.city,product,transport`,placeholder:`product:nginx country:CN`,fieldPresets:[[`最小字段`,`ip_str,port,hostnames,domains`],[`Web 常用`,`ip_str,port,hostnames,domains,product,org,location.country_name,location.city`],[`情报增强`,`ip_str,port,hostnames,domains,org,isp,asn,location.country_name,location.city,product,transport,ssl.cert.subject.cn`]],queryPresets:[[`Nginx + 中国`,`product:nginx country:CN`],[`SSH 服务`,`port:22`],[`证书域名`,`ssl.cert.subject.cn:example.com`],[`Amazon 443`,`org:"Amazon" port:443`]],supportsFull:!1}},se=Object.entries(j).map(([e,t])=>({value:e,label:t.label}));function ce(e){return j[e]||j.fofa}function le(e,t=5){let n=[`host`,`ip`,`port`,`domain`,`title`,`protocol`,`server`,`country`,`city`].filter(t=>e.includes(t)),r=e.filter(e=>!n.includes(e));return[...n,...r].slice(0,t)}function ue(e,t){if(!e||typeof e!=`object`)return``;let n=t=>{for(let n of t){let t=e[n];if(Array.isArray(t)&&t.length)return String(t[0]);if(t)return String(t)}return``},r=n([`host`,`url`,`hostname`]);if(r)return r;let i=n([`domain`,`domains`,`hostnames`]);if(i)return i;let a=n([`ip`,`ip_str`]),o=e.port;return a?o?`${a}:${o}`:a:``}function de(e,t){let n=new Set(t.map(Number));return(e||[]).filter((e,t)=>n.has(t))}var M=e(n(),1),{Text:N}=l;function P(e){if(e==null||e===``)return(0,M.jsx)(N,{type:`tertiary`,children:`—`});let t=Array.isArray(e)?e.join(`, `):typeof e==`object`?JSON.stringify(e):String(e);return(0,M.jsx)(E,{text:t,max:44})}function F(e,t){let n=ue(e,t);return n?/^https?:\/\//i.test(n)?(0,M.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:`info-collect-target-link`,children:(0,M.jsx)(E,{text:n,max:44})}):(0,M.jsx)(E,{text:n,max:44}):(0,M.jsx)(N,{type:`tertiary`,children:`—`})}function fe({fields:e,results:t,visibleFields:n,selectedKeys:r,onSelectionChange:i,onOpenDetail:o,loading:s}){let c=b(),l=Array.isArray(e)?e:[],u=(Array.isArray(n)?n:[]).filter(e=>l.includes(e)),d=[{title:c(`assets.target`,null,`目标`),dataIndex:`__target`,width:240,render:(e,t)=>F(t,l)},...u.map(e=>({title:e,dataIndex:e,render:(t,n)=>P(n[e])})),{title:c(`common.actions`,null,`操作`),dataIndex:`__actions`,width:90,render:(e,t)=>(0,M.jsx)(a,{theme:`borderless`,size:`small`,onClick:()=>o(t),children:c(`common.view`,null,`详情`)})}],f=(t||[]).map((e,t)=>({...e,__key:String(t),__index:t}));return(0,M.jsx)(T,{columns:d,dataSource:f,rowKey:`__key`,loading:s,pagination:!1,rowSelection:{selectedRowKeys:r,onChange:e=>i(e)},emptyText:c(`infoCollect.noResults`,null,`暂 Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,Pt as o,T as s,U as c,W as l,_ as u,b as d,f,ot as p,st as m,u as h,v as g,x as _,z as v}from"./semi-CHxO7u8f.js";import{F as ee,I as y,P as b,S as x,b as S,c as C,d as w,i as te,l as ne,m as re,p as ie,s as T,u as ae,x as oe}from"./index-BLFHsWWk.js";import{a as E}from"./AssetBits-RToEHLbz.js";import{a as D,i as O,o as k}from"./assetTarget-D2PEjBAg.js";var A=e(t(),1),j={fofa:{label:`FOFA`,maxSize:1e4,defaultFields:`host,ip,port,domain,title,protocol,country,region,city,server`,placeholder:`app="Apache" && country="CN"`,fieldPresets:[[`最小字段`,`host,ip,port,domain`],[`Web 常用`,`host,title,ip,port,domain,protocol,server,icp,country,region,city`],[`情报增强`,`host,ip,port,domain,title,protocol,country,region,city,server,asn,org,icp,header,banner`]],queryPresets:[[`Apache + 中国`,`app="Apache" && country="CN"`],[`登录页 + 中国`,`title="登录" && country="CN"`],[`指定域名`,`domain="example.com"`],[`指定 IP`,`ip="1.1.1.1"`]],supportsFull:!0},zoomeye:{label:`ZoomEye`,maxSize:1e4,defaultFields:`ip,port,domain,hostname,title,service,app,country,city`,placeholder:`app="Apache" && country="CN"`,fieldPresets:[[`最小字段`,`ip,port,domain,hostname`],[`Web 常用`,`ip,port,domain,hostname,title,service,app,country,city`],[`情报增强`,`ip,port,domain,hostname,title,service,app,country,city,org,isp,ssl`]],queryPresets:[[`Apache + 中国`,`app="Apache" && country="CN"`],[`SSH 服务`,`service="ssh"`],[`指定域名`,`domain="example.com"`],[`指定 IP`,`ip="1.1.1.1"`]],supportsFull:!1},quake:{label:`Quake`,maxSize:1e4,defaultFields:`ip,port,domain,service.name,service.http.title,location.country_cn,location.province_cn,location.city_cn`,placeholder:`service.name:"http" AND country_cn:"中国"`,fieldPresets:[[`最小字段`,`ip,port,domain`],[`Web 常用`,`ip,port,domain,service.name,service.http.title,location.country_cn,location.city_cn`],[`情报增强`,`ip,port,domain,service.name,service.http.title,service.http.server,location.country_cn,location.province_cn,location.city_cn,asn`]],queryPresets:[[`HTTP + 中国`,`service.name:"http" AND country_cn:"中国"`],[`443 端口`,`port:443`],[`指定域名`,`domain:"example.com"`],[`指定 IP`,`ip:"1.1.1.1"`]],supportsFull:!0},shodan:{label:`Shodan`,maxSize:1e3,defaultFields:`ip_str,port,hostnames,domains,org,isp,location.country_name,location.city,product,transport`,placeholder:`product:nginx country:CN`,fieldPresets:[[`最小字段`,`ip_str,port,hostnames,domains`],[`Web 常用`,`ip_str,port,hostnames,domains,product,org,location.country_name,location.city`],[`情报增强`,`ip_str,port,hostnames,domains,org,isp,asn,location.country_name,location.city,product,transport,ssl.cert.subject.cn`]],queryPresets:[[`Nginx + 中国`,`product:nginx country:CN`],[`SSH 服务`,`port:22`],[`证书域名`,`ssl.cert.subject.cn:example.com`],[`Amazon 443`,`org:"Amazon" port:443`]],supportsFull:!1}},se=Object.entries(j).map(([e,t])=>({value:e,label:t.label}));function ce(e){return j[e]||j.fofa}function le(e,t=5){let n=[`host`,`ip`,`port`,`domain`,`title`,`protocol`,`server`,`country`,`city`].filter(t=>e.includes(t)),r=e.filter(e=>!n.includes(e));return[...n,...r].slice(0,t)}function ue(e,t){if(!e||typeof e!=`object`)return``;let n=t=>{for(let n of t){let t=e[n];if(Array.isArray(t)&&t.length)return String(t[0]);if(t)return String(t)}return``},r=n([`host`,`url`,`hostname`]);if(r)return r;let i=n([`domain`,`domains`,`hostnames`]);if(i)return i;let a=n([`ip`,`ip_str`]),o=e.port;return a?o?`${a}:${o}`:a:``}function de(e,t){let n=new Set(t.map(Number));return(e||[]).filter((e,t)=>n.has(t))}var M=e(n(),1),{Text:N}=l;function P(e){if(e==null||e===``)return(0,M.jsx)(N,{type:`tertiary`,children:`—`});let t=Array.isArray(e)?e.join(`, `):typeof e==`object`?JSON.stringify(e):String(e);return(0,M.jsx)(E,{text:t,max:44})}function F(e,t){let n=ue(e,t);return n?/^https?:\/\//i.test(n)?(0,M.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:`info-collect-target-link`,children:(0,M.jsx)(E,{text:n,max:44})}):(0,M.jsx)(E,{text:n,max:44}):(0,M.jsx)(N,{type:`tertiary`,children:`—`})}function fe({fields:e,results:t,visibleFields:n,selectedKeys:r,onSelectionChange:i,onOpenDetail:o,loading:s}){let c=b(),l=Array.isArray(e)?e:[],u=(Array.isArray(n)?n:[]).filter(e=>l.includes(e)),d=[{title:c(`assets.target`,null,`目标`),dataIndex:`__target`,width:240,render:(e,t)=>F(t,l)},...u.map(e=>({title:e,dataIndex:e,render:(t,n)=>P(n[e])})),{title:c(`common.actions`,null,`操作`),dataIndex:`__actions`,width:90,render:(e,t)=>(0,M.jsx)(a,{theme:`borderless`,size:`small`,onClick:()=>o(t),children:c(`common.view`,null,`详情`)})}],f=(t||[]).map((e,t)=>({...e,__key:String(t),__index:t}));return(0,M.jsx)(T,{columns:d,dataSource:f,rowKey:`__key`,loading:s,pagination:!1,rowSelection:{selectedRowKeys:r,onChange:e=>i(e)},emptyText:c(`infoCollect.noResults`,null,`暂 Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,Ot as s,W as c,i as l,jt as ee,lt as te,ot as ne,st as u,v as d}from"./semi-CHxO7u8f.js";import{D as f,E as p,F as m,I as h,P as re,_ as ie,a as g,b as _,c as v,d as y,f as b,l as x,m as S,p as C,s as w,x as T,y as E}from"./index-CuUcClXg.js";var D=e(t(),1),O=e(n(),1),{Text:k}=c;function A(){let e=re(),{hasPermission:t}=m(),n=t(`knowledge:write`),[A,ae]=(0,D.useState)(``),[j,oe]=(0,D.useState)(``),[M,N]=(0,D.useState)(1),[P,F]=(0,D.useState)(20),[I,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(null),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)(!1),[W,G]=(0,D.useState)(null),K=g(()=>h.get(`/knowledge/items`,{category:A||void 0,search:j||void 0,limit:P,offset:(M-1)*P}),[A,j,M,P]),q=g(()=>h.get(`/knowledge/stats`),[]),J=g(()=>h.get(`/knowledge/categories`),[]),Y=g(()=>h.get(`/knowledge/index-status`),[]),X=K.data?.enabled===!1,se=Array.isArray(K.data?.items)?K.data.items:[],ce=Number(K.data?.total||0),le=(Array.isArray(J.data?.categories)?J.data.categories:[]).map(e=>typeof e==`string`?{value:e,label:e}:{value:e.name||e.category,label:e.name||e.category}),Z=(0,D.useCallback)(()=>{K.reload(),q.reload(),Y.reload()},[K,q,Y]),ue=async()=>{if(B||!I?.form)return;let e=await I.form.validate().catch(()=>null);if(e){V(!0);try{let t={category:e.category.trim(),title:e.title.trim(),content:e.content};I.item?.id?await h.put(`/knowledge/items/${encodeURIComponent(I.item.id)}`,t):await h.post(`/knowledge/items`,t),T(I.item?.id?`知识项已更新`:`知识项已创建`),L(null),Z()}catch(e){_(e,`保存失败`)}finally{V(!1)}}},Q=e=>E({title:`删除知识项「${e.title}」?`,content:`删除后需要重新索引,且不可恢复。`,onOk:async()=>{await h.del(`/knowledge/items/${encodeURIComponent(e.id)}`),T(`已删除`),Z()}}),$=async e=>{try{await h.post(`/knowledge/index`,e?{full:!0}:{}),T(`索引任务已提交`),Y.reload()}catch(e){_(e,`构建索引失败`)}},de=async e=>{try{G(await h.post(`/knowledge/search`,{query:e,topK:5}))}catch(e){_(e,`检索失败`)}};return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(C,{title:e(`knowledge.title`,null,`知识管理`),description:`知识条目会参与智能体检索;修改后需要重建索引才能生效。`,extra:(0,O.jsxs)(r,{wrap:!0,children:[(0,O.jsx)(a,{icon:(0,O.jsx)(u,{}),onClick:Z,children:`刷新`}),n&&!X&&(0,O.jsx)(a,{onClick:()=>$(!1),children:`构建索引`}),n&&!X&&(0,O.jsx)(a,{onClick:()=>$(!0),children:`全量重建`}),n&&!X&&(0,O.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,O.jsx)(te,{}),onClick:()=>L({item:null,form:{}}),children:`新增知识`})]})}),X&&(0,O.jsx)(c.Paragraph,{type:`tertiary`,children:K.data.message}),(0,O.jsx)(ie,{columns:4,metrics:[{id:`items`,label:`知识条目`,value:f(q.data?.total_items||0),loading:q.loading},{id:`categories`,label:`分类数`,value:f(q.data?.total_categories||0),loading:q.loading},{id:`indexed`,label:`已索引`,value:f(Y.data?.indexed_items??Y.data?.total_indexed??0),loading:Y.loading},{id:`pending`,label:`待索引`,value:f(Y.data?.pending_items??0),loading:Y.loading}]}),(0,O.jsxs)(S,{title:`知识条目`,children:[(0,O.jsx)(x,{error:K.error,onRetry:()=>K.reload()}),(0,O.jsx)(w,{columns:[{title:`标题`,dataIndex:`title`,render:(e,t)=>(0,O.jsx)(k,{strong:!0,children:e||t.filePath})},{title:`分类`,dataIndex:`category`,width:160,render:e=>e?(0,O.jsx)(o,{size:`small`,children:e}):`—`},{title:`更新时间`,dataIndex:`updatedAt`,width:180,render:e=>p(e)},{title:`操作`,width:150,render:(e,t)=>(0,O.jsxs)(r,{children:[(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>z(t),children:`查看`}),n&&(0,O.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,O.jsx)(s,{}),onClick:()=>L({item:t,form:{}})}),n&&(0,O.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,O.jsx)(ee,{}),onClick:()=>Q(t)})]})}],dataSource:se,rowKey:`id`,loading:K.loading,pagination:{currentPage:M,pageSize:P,total:ce,onPageChange:N,onPageSizeChange:e=>{F(e),N(1)}},toolbar:(0,O.jsxs)(r,{wrap:!0,children:[(0,O.jsx)(i,{prefix:(0,O.jsx)(ne,{}),value:j,onChange:e=>{oe(e),N(1)},placeholder:`搜索标题或内容`,style:{width:220}}),(0,O.jsx)(d,{value:A,onChange:e=>{ae(e||``),N(1)},placeholder:`全部分类`,style:{width:180},showClear:!0,optionList:le}),(0,O.jsx)(a,{disabled:X,onClick:()=>U(!0),children:`检索测试`})]})})]}),(0,O.jsx)(v,{title:I?.item?`编辑知识项`:`新增知识项`,visible:!!I,onCancel:()=>L(null),onOk:ue,confirmLoading:B,width:760,children:(0,O.jsxs)(l,{getFormApi:e=>L(t=>t&&{...t,form:e}),initValues:I?.item?{category:I.item.category,title:I.item.title,content:I.item.content}:{},children:[(0,O.jsx)(l.Input,{field:`category`,label:`分类`,rules:[{required:!0,message:`请输入分类`}]}),(0,O.jsx)(l.Input,{field:`title`,label:`标题`,rules:[{required:!0,message:`请输入标题`}]}),(0,O.jsx)(l.TextArea,{field:`content`,label:`内容(Markdown)`,rules:[{required:!0,message:`请输入内容 Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,Ot as s,W as c,i as l,jt as ee,lt as te,ot as ne,st as u,v as d}from"./semi-CHxO7u8f.js";import{D as f,E as p,F as m,I as h,P as re,_ as ie,a as g,b as _,c as v,d as y,f as b,l as x,m as S,p as C,s as w,x as T,y as E}from"./index-BLFHsWWk.js";var D=e(t(),1),O=e(n(),1),{Text:k}=c;function A(){let e=re(),{hasPermission:t}=m(),n=t(`knowledge:write`),[A,ae]=(0,D.useState)(``),[j,oe]=(0,D.useState)(``),[M,N]=(0,D.useState)(1),[P,F]=(0,D.useState)(20),[I,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(null),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)(!1),[W,G]=(0,D.useState)(null),K=g(()=>h.get(`/knowledge/items`,{category:A||void 0,search:j||void 0,limit:P,offset:(M-1)*P}),[A,j,M,P]),q=g(()=>h.get(`/knowledge/stats`),[]),J=g(()=>h.get(`/knowledge/categories`),[]),Y=g(()=>h.get(`/knowledge/index-status`),[]),X=K.data?.enabled===!1,se=Array.isArray(K.data?.items)?K.data.items:[],ce=Number(K.data?.total||0),le=(Array.isArray(J.data?.categories)?J.data.categories:[]).map(e=>typeof e==`string`?{value:e,label:e}:{value:e.name||e.category,label:e.name||e.category}),Z=(0,D.useCallback)(()=>{K.reload(),q.reload(),Y.reload()},[K,q,Y]),ue=async()=>{if(B||!I?.form)return;let e=await I.form.validate().catch(()=>null);if(e){V(!0);try{let t={category:e.category.trim(),title:e.title.trim(),content:e.content};I.item?.id?await h.put(`/knowledge/items/${encodeURIComponent(I.item.id)}`,t):await h.post(`/knowledge/items`,t),T(I.item?.id?`知识项已更新`:`知识项已创建`),L(null),Z()}catch(e){_(e,`保存失败`)}finally{V(!1)}}},Q=e=>E({title:`删除知识项「${e.title}」?`,content:`删除后需要重新索引,且不可恢复。`,onOk:async()=>{await h.del(`/knowledge/items/${encodeURIComponent(e.id)}`),T(`已删除`),Z()}}),$=async e=>{try{await h.post(`/knowledge/index`,e?{full:!0}:{}),T(`索引任务已提交`),Y.reload()}catch(e){_(e,`构建索引失败`)}},de=async e=>{try{G(await h.post(`/knowledge/search`,{query:e,topK:5}))}catch(e){_(e,`检索失败`)}};return(0,O.jsxs)(`div`,{children:[(0,O.jsx)(C,{title:e(`knowledge.title`,null,`知识管理`),description:`知识条目会参与智能体检索;修改后需要重建索引才能生效。`,extra:(0,O.jsxs)(r,{wrap:!0,children:[(0,O.jsx)(a,{icon:(0,O.jsx)(u,{}),onClick:Z,children:`刷新`}),n&&!X&&(0,O.jsx)(a,{onClick:()=>$(!1),children:`构建索引`}),n&&!X&&(0,O.jsx)(a,{onClick:()=>$(!0),children:`全量重建`}),n&&!X&&(0,O.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,O.jsx)(te,{}),onClick:()=>L({item:null,form:{}}),children:`新增知识`})]})}),X&&(0,O.jsx)(c.Paragraph,{type:`tertiary`,children:K.data.message}),(0,O.jsx)(ie,{columns:4,metrics:[{id:`items`,label:`知识条目`,value:f(q.data?.total_items||0),loading:q.loading},{id:`categories`,label:`分类数`,value:f(q.data?.total_categories||0),loading:q.loading},{id:`indexed`,label:`已索引`,value:f(Y.data?.indexed_items??Y.data?.total_indexed??0),loading:Y.loading},{id:`pending`,label:`待索引`,value:f(Y.data?.pending_items??0),loading:Y.loading}]}),(0,O.jsxs)(S,{title:`知识条目`,children:[(0,O.jsx)(x,{error:K.error,onRetry:()=>K.reload()}),(0,O.jsx)(w,{columns:[{title:`标题`,dataIndex:`title`,render:(e,t)=>(0,O.jsx)(k,{strong:!0,children:e||t.filePath})},{title:`分类`,dataIndex:`category`,width:160,render:e=>e?(0,O.jsx)(o,{size:`small`,children:e}):`—`},{title:`更新时间`,dataIndex:`updatedAt`,width:180,render:e=>p(e)},{title:`操作`,width:150,render:(e,t)=>(0,O.jsxs)(r,{children:[(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>z(t),children:`查看`}),n&&(0,O.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,O.jsx)(s,{}),onClick:()=>L({item:t,form:{}})}),n&&(0,O.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,O.jsx)(ee,{}),onClick:()=>Q(t)})]})}],dataSource:se,rowKey:`id`,loading:K.loading,pagination:{currentPage:M,pageSize:P,total:ce,onPageChange:N,onPageSizeChange:e=>{F(e),N(1)}},toolbar:(0,O.jsxs)(r,{wrap:!0,children:[(0,O.jsx)(i,{prefix:(0,O.jsx)(ne,{}),value:j,onChange:e=>{oe(e),N(1)},placeholder:`搜索标题或内容`,style:{width:220}}),(0,O.jsx)(d,{value:A,onChange:e=>{ae(e||``),N(1)},placeholder:`全部分类`,style:{width:180},showClear:!0,optionList:le}),(0,O.jsx)(a,{disabled:X,onClick:()=>U(!0),children:`检索测试`})]})})]}),(0,O.jsx)(v,{title:I?.item?`编辑知识项`:`新增知识项`,visible:!!I,onCancel:()=>L(null),onOk:ue,confirmLoading:B,width:760,children:(0,O.jsxs)(l,{getFormApi:e=>L(t=>t&&{...t,form:e}),initValues:I?.item?{category:I.item.category,title:I.item.title,content:I.item.content}:{},children:[(0,O.jsx)(l.Input,{field:`category`,label:`分类`,rules:[{required:!0,message:`请输入分类`}]}),(0,O.jsx)(l.Input,{field:`title`,label:`标题`,rules:[{required:!0,message:`请输入标题`}]}),(0,O.jsx)(l.TextArea,{field:`content`,label:`内容(Markdown)`,rules:[{required:!0,message:`请输入内容 Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,jt as c,ot as l,st as u}from"./semi-CHxO7u8f.js";import{E as d,F as f,I as p,P as m,a as h,c as g,d as _,l as v,m as y,p as b,s as x,u as S,x as C,y as w}from"./index-CuUcClXg.js";var T=e(t(),1),E=e(n(),1),{Text:D}=s;function O(){let e=m(),{hasPermission:t}=f(),n=t(`knowledge:delete`),[s,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(50),[j,M]=(0,T.useState)(null),N=h(()=>p.get(`/knowledge/retrieval-logs`,{conversationId:s||void 0,limit:k}),[s,k]),P=Array.isArray(N.data?.logs)?N.data.logs:[],F=e=>w({title:`删除该检索日志?`,content:e.query||e.id,onOk:async()=>{await p.del(`/knowledge/retrieval-logs/${encodeURIComponent(e.id)}`),C(`已删除`),N.reload()}});return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(b,{title:e(`knowledge.retrievalLogsTitle`,null,`检索历史`),description:`记录智能体每次知识库检索的语句、命中项与会话,用于回溯回答依据。`,extra:(0,E.jsx)(a,{icon:(0,E.jsx)(u,{}),onClick:()=>N.reload(),loading:N.loading,children:`刷新`})}),(0,E.jsxs)(y,{title:`检索记录(${P.length})`,children:[(0,E.jsx)(v,{error:N.error,onRetry:()=>N.reload()}),(0,E.jsx)(x,{columns:[{title:`检索语句`,dataIndex:`query`,render:(e,t)=>(0,E.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>M(t),style:{background:`none`,border:`none`,padding:0,cursor:`pointer`,textAlign:`left`,color:`var(--semi-color-primary)`},children:e||`—`})},{title:`风险类型`,dataIndex:`riskType`,width:140,render:e=>e?(0,E.jsx)(o,{size:`small`,children:e}):`—`},{title:`命中知识项`,dataIndex:`retrievedItems`,width:120,render:e=>(0,E.jsxs)(D,{type:`tertiary`,children:[Array.isArray(e)?e.length:0,` 条`]})},{title:`会话`,dataIndex:`conversationId`,width:200,render:e=>(0,E.jsx)(D,{type:`tertiary`,ellipsis:{showTooltip:!0},children:e||`—`})},{title:`时间`,dataIndex:`createdAt`,width:180,render:e=>d(e)},{title:`操作`,width:110,render:(e,t)=>(0,E.jsxs)(r,{children:[(0,E.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>M(t),children:`详情`}),n&&(0,E.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,E.jsx)(c,{}),onClick:()=>F(t)})]})}],dataSource:P,rowKey:`id`,loading:N.loading,pagination:!1,toolbar:(0,E.jsxs)(r,{children:[(0,E.jsx)(i,{prefix:(0,E.jsx)(l,{}),placeholder:`按会话 ID 过滤`,value:s,onChange:O,style:{width:260}}),(0,E.jsx)(i,{placeholder:`条数`,value:String(k),onChange:e=>A(Math.min(Math.max(Number(e)||50,1),500)),style:{width:100},suffix:(0,E.jsx)(D,{type:`tertiary`,children:`条`})})]})})]}),(0,E.jsx)(g,{title:`检索日志详情`,visible:!!j,onCancel:()=>M(null),width:560,children:j&&(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,E.jsx)(_,{items:[{label:`日志 ID`,value:j.id},{label:`检索语句`,value:j.query},{label:`风险类型`,value:j.riskType||`—`},{label:`会话 ID`,value:j.conversationId||`—`},{label:`消息 ID`,value:j.messageId||`—`},{label:`时间`,value:d(j.createdAt)}]}),(0,E.jsx)(S,{value:j.retrievedItems||[],title:`命中知识项`})]})})]})}export{O as default};
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,jt as c,ot as l,st as u}from"./semi-CHxO7u8f.js";import{E as d,F as f,I as p,P as m,a as h,c as g,d as _,l as v,m as y,p as b,s as x,u as S,x as C,y as w}from"./index-BLFHsWWk.js";var T=e(t(),1),E=e(n(),1),{Text:D}=s;function O(){let e=m(),{hasPermission:t}=f(),n=t(`knowledge:delete`),[s,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(50),[j,M]=(0,T.useState)(null),N=h(()=>p.get(`/knowledge/retrieval-logs`,{conversationId:s||void 0,limit:k}),[s,k]),P=Array.isArray(N.data?.logs)?N.data.logs:[],F=e=>w({title:`删除该检索日志?`,content:e.query||e.id,onOk:async()=>{await p.del(`/knowledge/retrieval-logs/${encodeURIComponent(e.id)}`),C(`已删除`),N.reload()}});return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(b,{title:e(`knowledge.retrievalLogsTitle`,null,`检索历史`),description:`记录智能体每次知识库检索的语句、命中项与会话,用于回溯回答依据。`,extra:(0,E.jsx)(a,{icon:(0,E.jsx)(u,{}),onClick:()=>N.reload(),loading:N.loading,children:`刷新`})}),(0,E.jsxs)(y,{title:`检索记录(${P.length})`,children:[(0,E.jsx)(v,{error:N.error,onRetry:()=>N.reload()}),(0,E.jsx)(x,{columns:[{title:`检索语句`,dataIndex:`query`,render:(e,t)=>(0,E.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>M(t),style:{background:`none`,border:`none`,padding:0,cursor:`pointer`,textAlign:`left`,color:`var(--semi-color-primary)`},children:e||`—`})},{title:`风险类型`,dataIndex:`riskType`,width:140,render:e=>e?(0,E.jsx)(o,{size:`small`,children:e}):`—`},{title:`命中知识项`,dataIndex:`retrievedItems`,width:120,render:e=>(0,E.jsxs)(D,{type:`tertiary`,children:[Array.isArray(e)?e.length:0,` 条`]})},{title:`会话`,dataIndex:`conversationId`,width:200,render:e=>(0,E.jsx)(D,{type:`tertiary`,ellipsis:{showTooltip:!0},children:e||`—`})},{title:`时间`,dataIndex:`createdAt`,width:180,render:e=>d(e)},{title:`操作`,width:110,render:(e,t)=>(0,E.jsxs)(r,{children:[(0,E.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>M(t),children:`详情`}),n&&(0,E.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,E.jsx)(c,{}),onClick:()=>F(t)})]})}],dataSource:P,rowKey:`id`,loading:N.loading,pagination:!1,toolbar:(0,E.jsxs)(r,{children:[(0,E.jsx)(i,{prefix:(0,E.jsx)(l,{}),placeholder:`按会话 ID 过滤`,value:s,onChange:O,style:{width:260}}),(0,E.jsx)(i,{placeholder:`条数`,value:String(k),onChange:e=>A(Math.min(Math.max(Number(e)||50,1),500)),style:{width:100},suffix:(0,E.jsx)(D,{type:`tertiary`,children:`条`})})]})})]}),(0,E.jsx)(g,{title:`检索日志详情`,visible:!!j,onCancel:()=>M(null),width:560,children:j&&(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,E.jsx)(_,{items:[{label:`日志 ID`,value:j.id},{label:`检索语句`,value:j.query},{label:`风险类型`,value:j.riskType||`—`},{label:`会话 ID`,value:j.conversationId||`—`},{label:`消息 ID`,value:j.messageId||`—`},{label:`时间`,value:d(j.createdAt)}]}),(0,E.jsx)(S,{value:j.retrievedItems||[],title:`命中知识项`})]})})]})}export{O as default};
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,N as s,W as c,lt as l,ot as u,st as d,u as f,v as p,x as m,z as h}from"./semi-CHxO7u8f.js";import{F as g,I as _,P as v,R as y,_ as b,a as x,b as S,c as C,l as w,m as T,n as E,o as D,p as O,r as k,s as A,x as j,y as M}from"./index-CuUcClXg.js";var N=e(t(),1),P={connected:{color:`green`,label:`已连接`},connecting:{color:`blue`,label:`连接中`},disconnected:{color:`amber`,label:`未连接`},disabled:{color:`grey`,label:`已停用`},error:{color:`red`,label:`连接失败`}};function F(e){return P[String(e||``).toLowerCase()]||{color:`grey`,label:e||`未知`}}function I(e){return e?String(e.type||e.transport||(e.command?`stdio`:`http`)).toLowerCase():`http`}function L(e){return e?e.is_external&&e.external_mcp?`${e.external_mcp}::${e.name}`:e.name||``:``}function R(e){return e?e.is_external?`外部 · ${e.external_mcp||`未知`}`:`内置`:`—`}var z=e(n(),1),{Text:B}=c,V={"my-stdio-server":{command:`python3`,args:["${HOME}/mcp-servers/main.py",`--port`,"${MCP_PORT:-3000}"],env:{API_KEY:"${API_KEY}",LOG_LEVEL:"${LOG_LEVEL:-INFO}"},timeout:300},"my-http-server":{type:`http`,url:`https://mcp.example.com/mcp`,headers:{Authorization:"Bearer ${MCP_TOKEN}"}},"my-sse-server":{type:`sse`,url:`http://127.0.0.1:8081/mcp/sse`}};function H(e,{editingName:t}){if(typeof e!=`object`||!e||Array.isArray(e))return{error:`配置必须是 JSON 对象`};let n=Object.keys(e);if(!n.length)return{error:`至少需要一个 MCP 配置`};if(t&&!e[t])return{error:`编辑模式下 JSON 必须包含配置名称 "${t}"`};for(let t of n){if(!t.trim())return{error:`配置名称不能为空`};let n=e[t];if(typeof n!=`object`||!n||Array.isArray(n))return{error:`"${t}" 的配置必须是对象`};delete n.external_mcp_enable;let r=n.type||n.transport||(n.command?`stdio`:n.url?`http`:``);if(!r)return{error:`"${t}" 需要指定 command(stdio)或 url + type(http/sse)`};if(r===`stdio`&&!n.command)return{error:`"${t}" 的 stdio 模式需要 command`};if((r===`http`||r===`sse`)&&!n.url)return{error:`"${t}" 的 ${r} 模式需要 url`}}return{error:``,names:n}}function U({canWrite:e,onChanged:t,refreshKey:n=0}){let i=v(),s=x(()=>_.get(`/external-mcp`),[n]),[c,u]=(0,N.useState)(``),[f,p]=(0,N.useState)(!1),[g,b]=(0,N.useState)(null),[E,O]=(0,N.useState)(``),[A,P]=(0,N.useState)(``),[L,R]=(0,N.useState)(!1),U=(0,N.useMemo)(()=>{let e=s.data?.servers||{};return Object.entries(e).sort(([e],[t])=>e.localeCompare(t))},[s.data]),W=(0,N.useCallback)(e=>s.reload(e),[s.reload]);k(()=>{typeof document<`u`&&document.hidden||W({silent:!0})},8e3);let G=(0,N.useCallback)(()=>{b(null),O(``),P(``),p(!0)},[]),K=(0,N.useCallback)(async e=>{b(e),O(``),P(``),p(!0);try{let t={...(await _.get(`/external-mcp/${encodeURIComponent(e)}`))?.config||{}};delete t.tool_count,delete t.external_mcp_enable,O(JSON.stringify({[e]:t},null,2))}catch(e){p(!1),S(e,i(`mcp.getConfigFailed`,null,`获取外部MCP配置失败`))}},[i]),q=(0,N.useCallback)(()=>{p(!1),b(null),P(``)},[]),J=(0,N.useCallback)(async(e,n)=>{let r=n===`connected`?`stop`:`start`;u(e);try{await _.post(`/external-mcp/${encodeURIComponent(e)}/${r}`,{}),j(r===`start`?`已提交启动请求,正在后台连接`:`外部 MCP 已停止`),W({silent:!0}),t?.()}catch(e){S(e,i(`mcp.operationFailed`,null,`操作失败`))}finally{u(``)}},[t,W,i]),Y=(0,N.useCallback)(e=>{M({title:i(`mcp.deleteExternalConfirm`,{name:e},`确定要删除外部MCP "${e}" 吗?`),content:`删除后该 MCP 的工具将从对话中移除。`,okText:i(`common.delete`,null,`删除`),onOk:async()=>{try{await _.del(`/external-mcp/${encodeURIComponent(e)}`),j(i(`mcp.deleteSuccess`,null,`删除成功`)),W(),t?.()}catch(e){S(e,i(`mcp.operationFailed`,null,`删除失败`))}}})},[t,W,i]),X=(0,N.useCallback)(async()=>{let e=E.trim();if(!e){P(i(`mcp.jsonEmpty`,null,`JSON不能为空`));return}let n;try{n=JSON.parse(e)}catch(e){P(`${i(`mcp.jsonError`,null,`JSON格式错误`)}: ${e.message}`);return}let{error:r,names:a}=H(n,{editingName:g});if(r)P(r);else{P(``),R(!0);try{let e=g?[g]:a;for(let t of e)await _.put(`/external-mcp/${encodeURIComponent(t)}`,{config:n[t]});j(i(`mcp.saveSuccess`,null,`保存成功`)),q(),W(),t?.()}catch(e){P(`${i(`mcp.operationFailed`,null,`保存失败`)}: ${y(e)}`)}finally{R(!1)}}},[q,g,E,t,W,i]),Z=(0,z.jsxs)(r,{spacing:8,children:[(0,z.jsx)(a,{size:`small`,icon:(0,z.jsx)(d,{}),theme:`borderless`,onClick:()=>W(),loading:s.loading,children:i(`common.refresh`,null,`刷新`)}),(0,z.jsx)(a,{size:`small`,icon:(0,z.jsx)(l,{}),disabled:!e,onClick:G,children:i(`mcp.addExternalMCP`,null,`添加外部MCP`)})]});return(0,z.jsxs)(T,{title:i(`mcp.externalConfig`,null,`外部 MCP 配置`),description:`stdio 传 command/args/env,http 与 sse 传 url/headers;状态每 8 秒自动刷新。`,extra:Z,children:[(0,z.jsx)(w,{error:s.error,onRetry:()=>W()}),!U.length&&!s.loading&&(0,z.jsxs)(`div`,{className:`mcp-managemen Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,N as s,W as c,lt as l,ot as u,st as d,u as f,v as p,x as m,z as h}from"./semi-CHxO7u8f.js";import{F as g,I as _,P as v,R as y,_ as b,a as x,b as S,c as C,l as w,m as T,n as E,o as D,p as O,r as k,s as A,x as j,y as M}from"./index-BLFHsWWk.js";var N=e(t(),1),P={connected:{color:`green`,label:`已连接`},connecting:{color:`blue`,label:`连接中`},disconnected:{color:`amber`,label:`未连接`},disabled:{color:`grey`,label:`已停用`},error:{color:`red`,label:`连接失败`}};function F(e){return P[String(e||``).toLowerCase()]||{color:`grey`,label:e||`未知`}}function I(e){return e?String(e.type||e.transport||(e.command?`stdio`:`http`)).toLowerCase():`http`}function L(e){return e?e.is_external&&e.external_mcp?`${e.external_mcp}::${e.name}`:e.name||``:``}function R(e){return e?e.is_external?`外部 · ${e.external_mcp||`未知`}`:`内置`:`—`}var z=e(n(),1),{Text:B}=c,V={"my-stdio-server":{command:`python3`,args:["${HOME}/mcp-servers/main.py",`--port`,"${MCP_PORT:-3000}"],env:{API_KEY:"${API_KEY}",LOG_LEVEL:"${LOG_LEVEL:-INFO}"},timeout:300},"my-http-server":{type:`http`,url:`https://mcp.example.com/mcp`,headers:{Authorization:"Bearer ${MCP_TOKEN}"}},"my-sse-server":{type:`sse`,url:`http://127.0.0.1:8081/mcp/sse`}};function H(e,{editingName:t}){if(typeof e!=`object`||!e||Array.isArray(e))return{error:`配置必须是 JSON 对象`};let n=Object.keys(e);if(!n.length)return{error:`至少需要一个 MCP 配置`};if(t&&!e[t])return{error:`编辑模式下 JSON 必须包含配置名称 "${t}"`};for(let t of n){if(!t.trim())return{error:`配置名称不能为空`};let n=e[t];if(typeof n!=`object`||!n||Array.isArray(n))return{error:`"${t}" 的配置必须是对象`};delete n.external_mcp_enable;let r=n.type||n.transport||(n.command?`stdio`:n.url?`http`:``);if(!r)return{error:`"${t}" 需要指定 command(stdio)或 url + type(http/sse)`};if(r===`stdio`&&!n.command)return{error:`"${t}" 的 stdio 模式需要 command`};if((r===`http`||r===`sse`)&&!n.url)return{error:`"${t}" 的 ${r} 模式需要 url`}}return{error:``,names:n}}function U({canWrite:e,onChanged:t,refreshKey:n=0}){let i=v(),s=x(()=>_.get(`/external-mcp`),[n]),[c,u]=(0,N.useState)(``),[f,p]=(0,N.useState)(!1),[g,b]=(0,N.useState)(null),[E,O]=(0,N.useState)(``),[A,P]=(0,N.useState)(``),[L,R]=(0,N.useState)(!1),U=(0,N.useMemo)(()=>{let e=s.data?.servers||{};return Object.entries(e).sort(([e],[t])=>e.localeCompare(t))},[s.data]),W=(0,N.useCallback)(e=>s.reload(e),[s.reload]);k(()=>{typeof document<`u`&&document.hidden||W({silent:!0})},8e3);let G=(0,N.useCallback)(()=>{b(null),O(``),P(``),p(!0)},[]),K=(0,N.useCallback)(async e=>{b(e),O(``),P(``),p(!0);try{let t={...(await _.get(`/external-mcp/${encodeURIComponent(e)}`))?.config||{}};delete t.tool_count,delete t.external_mcp_enable,O(JSON.stringify({[e]:t},null,2))}catch(e){p(!1),S(e,i(`mcp.getConfigFailed`,null,`获取外部MCP配置失败`))}},[i]),q=(0,N.useCallback)(()=>{p(!1),b(null),P(``)},[]),J=(0,N.useCallback)(async(e,n)=>{let r=n===`connected`?`stop`:`start`;u(e);try{await _.post(`/external-mcp/${encodeURIComponent(e)}/${r}`,{}),j(r===`start`?`已提交启动请求,正在后台连接`:`外部 MCP 已停止`),W({silent:!0}),t?.()}catch(e){S(e,i(`mcp.operationFailed`,null,`操作失败`))}finally{u(``)}},[t,W,i]),Y=(0,N.useCallback)(e=>{M({title:i(`mcp.deleteExternalConfirm`,{name:e},`确定要删除外部MCP "${e}" 吗?`),content:`删除后该 MCP 的工具将从对话中移除。`,okText:i(`common.delete`,null,`删除`),onOk:async()=>{try{await _.del(`/external-mcp/${encodeURIComponent(e)}`),j(i(`mcp.deleteSuccess`,null,`删除成功`)),W(),t?.()}catch(e){S(e,i(`mcp.operationFailed`,null,`删除失败`))}}})},[t,W,i]),X=(0,N.useCallback)(async()=>{let e=E.trim();if(!e){P(i(`mcp.jsonEmpty`,null,`JSON不能为空`));return}let n;try{n=JSON.parse(e)}catch(e){P(`${i(`mcp.jsonError`,null,`JSON格式错误`)}: ${e.message}`);return}let{error:r,names:a}=H(n,{editingName:g});if(r)P(r);else{P(``),R(!0);try{let e=g?[g]:a;for(let t of e)await _.put(`/external-mcp/${encodeURIComponent(t)}`,{config:n[t]});j(i(`mcp.saveSuccess`,null,`保存成功`)),q(),W(),t?.()}catch(e){P(`${i(`mcp.operationFailed`,null,`保存失败`)}: ${y(e)}`)}finally{R(!1)}}},[q,g,E,t,W,i]),Z=(0,z.jsxs)(r,{spacing:8,children:[(0,z.jsx)(a,{size:`small`,icon:(0,z.jsx)(d,{}),theme:`borderless`,onClick:()=>W(),loading:s.loading,children:i(`common.refresh`,null,`刷新`)}),(0,z.jsx)(a,{size:`small`,icon:(0,z.jsx)(l,{}),disabled:!e,onClick:G,children:i(`mcp.addExternalMCP`,null,`添加外部MCP`)})]});return(0,z.jsxs)(T,{title:i(`mcp.externalConfig`,null,`外部 MCP 配置`),description:`stdio 传 command/args/env,http 与 sse 传 url/headers;状态每 8 秒自动刷新。`,extra:Z,children:[(0,z.jsx)(w,{error:s.error,onRetry:()=>W()}),!U.length&&!s.loading&&(0,z.jsxs)(`div`,{className:`mcp-managemen Line truncated
@@ -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{F as i,H as a,L as o,M as s,U as c,W as l,f as u,ot as d,st as f,v as p,w as m,x as h,z as g}from"./semi-CHxO7u8f.js";import{D as _,E as v,F as y,I as b,O as x,P as S,S as ee,_ as C,a as w,b as T,d as E,g as D,i as te,l as O,m as k,n as ne,o as A,p as re,r as ie,s as j,u as M,x as N,y as P}from"./index-CuUcClXg.js";var F=e(t(),1),I=[`completed`,`running`,`queued`,`failed`,`blocked`,`hard_timeout`,`cancelled`,`orphaned`],L={pending:`statusPending`,queued:`statusQueued`,running:`statusRunning`,completed:`statusCompleted`,failed:`statusFailed`,blocked:`statusBlocked`,cancelled:`statusCancelled`,hard_timeout:`statusHardTimeout`,orphaned:`statusOrphaned`},R={pending:`等待中`,queued:`排队中`,running:`执行中`,completed:`已完成`,failed:`失败`,blocked:`已拦截`,cancelled:`已终止`,hard_timeout:`执行超时`,orphaned:`孤儿任务`},z={completed:`green`,running:`blue`,queued:`amber`,failed:`red`,blocked:`orange`,hard_timeout:`red`,cancelled:`grey`,orphaned:`grey`};function B(e){return String(e||``).trim().toLowerCase()}function V(e,t){let n=B(t),r=L[n];return r?e(`mcpMonitor.${r}`,null,R[n]||n):t||`—`}function H(e){return z[B(e)]||`grey`}function U(e){return B(e)===`running`}function W(e){let t=String(e||``).trim();return t?t.includes(`::`)?t.replace(/::/g,`__`):t:``}function G(e){if(!e)return null;let t=Number(e.duration);if(Number.isFinite(t)&&t>0)return t/1e6;let n=e.startTime?new Date(e.startTime).getTime():NaN,r=e.endTime?new Date(e.endTime).getTime():NaN;return Number.isFinite(n)&&Number.isFinite(r)&&r>=n?r-n:null}function K(e){let t=Number(e);if(!Number.isFinite(t)||t<0)return`—`;if(t<1e3)return`${Math.round(t)} ms`;if(t<6e4)return`${(t/1e3).toFixed(2)} s`;let n=Math.floor(t/6e4),r=Math.round(t%6e4/1e3);return n<60?`${n} 分 ${r} 秒`:`${Math.floor(n/60)} 小时 ${n%60} 分`}function q(e){if(!e)return null;let t=(Number(e.totalCalls)||0)-(Number(e.blockedCalls)||0);return t<=0?null:(Number(e.successCalls)||0)/t}function J(e,t=1){return e==null||!Number.isFinite(Number(e))?`—`:`${(Number(e)*100).toFixed(t)}%`}function ae(e){let t=(e||[]).map(G).filter(e=>Number.isFinite(e)&&e>=0);return t.length?t.reduce((e,t)=>e+t,0)/t.length:null}function Y(e,t){let n=new Date(e);if(!Number.isFinite(n.getTime()))return``;let r=e=>String(e).padStart(2,`0`),i=`${r(n.getMonth()+1)}-${r(n.getDate())}`;return t===`30d`?i:t===`7d`?`${i} ${r(n.getHours())}h`:`${r(n.getHours())}:00`}function X(e,t){let n=e?.t?new Date(e.t).toLocaleString(`zh-CN`,{hour12:!1}):`—`;return t(`mcpMonitor.timelineTooltip`,{time:n,total:e?.total||0,failed:e?.failed||0,blocked:e?.blocked||0},`${n} 总调用 ${e?.total||0},失败 ${e?.failed||0},拦截 ${e?.blocked||0}`)}var Z=e(n(),1);function oe({summary:e,loading:t,avgMs:n=null,avgSamples:r=0}){let i=S(),a=q(e);return(0,Z.jsx)(C,{columns:4,metrics:[{id:`calls`,label:i(`mcpMonitor.totalCalls`,null,`调用次数`),value:e?e.totalCalls??0:`—`,detail:e?i(`mcpMonitor.statsFromAllTools`,null,`全部工具累计,含已拦截调用`):void 0,loading:t},{id:`rate`,label:i(`mcpMonitor.successRate`,null,`成功率`),value:J(a),detail:e?`${i(`common.ok`,null,`成功`)} ${e.successCalls??0} / ${i(`mcpMonitor.failedColumn`,null,`失败`)} ${e.failedCalls??0}`:void 0,tone:a===null?void 0:a>=.95?`success`:a>=.8?`warning`:`danger`,loading:t},{id:`avg`,label:`平均耗时`,value:n===null?`—`:K(n),detail:r>0?`按当前页 ${r} 条计时记录估算`:`当前页暂无可计时的执行记录`,loading:t},{id:`failed`,label:i(`mcpMonitor.failedMetric`,null,`失败数`),value:e?e.failedCalls??0:`—`,detail:e?`${i(`mcpMonitor.blockedCount`,{n:e.blockedCalls??0},`安全拦截 ${e.blockedCalls??0}`)} · ${i(`mcpMonitor.lastCall`,null,`最近调用`)} ${e.lastCallTime?v(e.lastCallTime):`—`}`:void 0,tone:e&&e.failedCalls>0?`danger`:void 0,loading:t}]})}function se({topTools:e,loading:t,onFilterTool:n,activeTool:r}){let i=S(),a=(0,F.useMemo)(()=>(e||[]).map(e=>{let t=Number(e.totalCalls)||0,n=Number(e.blockedCalls)||0,r=Number(e.successCalls)||0,i=t-n;return{...e,key:e.toolName,displayName:W(e.toolName),rate:i>0?r/i:null}}),[e]),o=[{title:i(`mcpMonitor.columnTool`,null,`工具`),dataIndex:`displayName`,render:(e,t)=>(0,Z.jsx)(`button`,{type:`button`,className:`mcp-monitor-tool-link ${r&&r===t.toolName?`mcp-monitor-link-active`:``}`,onClick:()=>n?.(t.toolName),children:e||i(`mcpMonitor.unknownTool`,null,`未知工具`)})},{title:i(`mcpMonitor.columnCalls`,null,`调用`),dataIndex:`totalCalls`,width:90,render:e=>e??0},{title:i(`mcpMonitor.successColumn`,null,`成功`),dataIndex:`successCalls`,width:90,render:e=>e??0},{title:i(`mcpMonitor.failedColumn`,null,`失败`),dataIndex:`failedCalls`,width:90,render:e=>(0,Z.jsx)(`span`,{className:e>0?`mcp-monitor-danger`:void 0,children:e??0})},{title:i(`mcpMonitor.blockedColumn`,null,`拦截`),dataIndex:`blockedCalls`,width:90,render:e=>e?(0,Z.jsx)Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,U as c,W as l,f as u,ot as d,st as f,v as p,w as m,x as h,z as g}from"./semi-CHxO7u8f.js";import{D as _,E as v,F as y,I as b,O as x,P as S,S as ee,_ as C,a as w,b as T,d as E,g as D,i as te,l as O,m as k,n as ne,o as A,p as re,r as ie,s as j,u as M,x as N,y as P}from"./index-BLFHsWWk.js";var F=e(t(),1),I=[`completed`,`running`,`queued`,`failed`,`blocked`,`hard_timeout`,`cancelled`,`orphaned`],L={pending:`statusPending`,queued:`statusQueued`,running:`statusRunning`,completed:`statusCompleted`,failed:`statusFailed`,blocked:`statusBlocked`,cancelled:`statusCancelled`,hard_timeout:`statusHardTimeout`,orphaned:`statusOrphaned`},R={pending:`等待中`,queued:`排队中`,running:`执行中`,completed:`已完成`,failed:`失败`,blocked:`已拦截`,cancelled:`已终止`,hard_timeout:`执行超时`,orphaned:`孤儿任务`},z={completed:`green`,running:`blue`,queued:`amber`,failed:`red`,blocked:`orange`,hard_timeout:`red`,cancelled:`grey`,orphaned:`grey`};function B(e){return String(e||``).trim().toLowerCase()}function V(e,t){let n=B(t),r=L[n];return r?e(`mcpMonitor.${r}`,null,R[n]||n):t||`—`}function H(e){return z[B(e)]||`grey`}function U(e){return B(e)===`running`}function W(e){let t=String(e||``).trim();return t?t.includes(`::`)?t.replace(/::/g,`__`):t:``}function G(e){if(!e)return null;let t=Number(e.duration);if(Number.isFinite(t)&&t>0)return t/1e6;let n=e.startTime?new Date(e.startTime).getTime():NaN,r=e.endTime?new Date(e.endTime).getTime():NaN;return Number.isFinite(n)&&Number.isFinite(r)&&r>=n?r-n:null}function K(e){let t=Number(e);if(!Number.isFinite(t)||t<0)return`—`;if(t<1e3)return`${Math.round(t)} ms`;if(t<6e4)return`${(t/1e3).toFixed(2)} s`;let n=Math.floor(t/6e4),r=Math.round(t%6e4/1e3);return n<60?`${n} 分 ${r} 秒`:`${Math.floor(n/60)} 小时 ${n%60} 分`}function q(e){if(!e)return null;let t=(Number(e.totalCalls)||0)-(Number(e.blockedCalls)||0);return t<=0?null:(Number(e.successCalls)||0)/t}function J(e,t=1){return e==null||!Number.isFinite(Number(e))?`—`:`${(Number(e)*100).toFixed(t)}%`}function ae(e){let t=(e||[]).map(G).filter(e=>Number.isFinite(e)&&e>=0);return t.length?t.reduce((e,t)=>e+t,0)/t.length:null}function Y(e,t){let n=new Date(e);if(!Number.isFinite(n.getTime()))return``;let r=e=>String(e).padStart(2,`0`),i=`${r(n.getMonth()+1)}-${r(n.getDate())}`;return t===`30d`?i:t===`7d`?`${i} ${r(n.getHours())}h`:`${r(n.getHours())}:00`}function X(e,t){let n=e?.t?new Date(e.t).toLocaleString(`zh-CN`,{hour12:!1}):`—`;return t(`mcpMonitor.timelineTooltip`,{time:n,total:e?.total||0,failed:e?.failed||0,blocked:e?.blocked||0},`${n} 总调用 ${e?.total||0},失败 ${e?.failed||0},拦截 ${e?.blocked||0}`)}var Z=e(n(),1);function oe({summary:e,loading:t,avgMs:n=null,avgSamples:r=0}){let i=S(),a=q(e);return(0,Z.jsx)(C,{columns:4,metrics:[{id:`calls`,label:i(`mcpMonitor.totalCalls`,null,`调用次数`),value:e?e.totalCalls??0:`—`,detail:e?i(`mcpMonitor.statsFromAllTools`,null,`全部工具累计,含已拦截调用`):void 0,loading:t},{id:`rate`,label:i(`mcpMonitor.successRate`,null,`成功率`),value:J(a),detail:e?`${i(`common.ok`,null,`成功`)} ${e.successCalls??0} / ${i(`mcpMonitor.failedColumn`,null,`失败`)} ${e.failedCalls??0}`:void 0,tone:a===null?void 0:a>=.95?`success`:a>=.8?`warning`:`danger`,loading:t},{id:`avg`,label:`平均耗时`,value:n===null?`—`:K(n),detail:r>0?`按当前页 ${r} 条计时记录估算`:`当前页暂无可计时的执行记录`,loading:t},{id:`failed`,label:i(`mcpMonitor.failedMetric`,null,`失败数`),value:e?e.failedCalls??0:`—`,detail:e?`${i(`mcpMonitor.blockedCount`,{n:e.blockedCalls??0},`安全拦截 ${e.blockedCalls??0}`)} · ${i(`mcpMonitor.lastCall`,null,`最近调用`)} ${e.lastCallTime?v(e.lastCallTime):`—`}`:void 0,tone:e&&e.failedCalls>0?`danger`:void 0,loading:t}]})}function se({topTools:e,loading:t,onFilterTool:n,activeTool:r}){let i=S(),a=(0,F.useMemo)(()=>(e||[]).map(e=>{let t=Number(e.totalCalls)||0,n=Number(e.blockedCalls)||0,r=Number(e.successCalls)||0,i=t-n;return{...e,key:e.toolName,displayName:W(e.toolName),rate:i>0?r/i:null}}),[e]),o=[{title:i(`mcpMonitor.columnTool`,null,`工具`),dataIndex:`displayName`,render:(e,t)=>(0,Z.jsx)(`button`,{type:`button`,className:`mcp-monitor-tool-link ${r&&r===t.toolName?`mcp-monitor-link-active`:``}`,onClick:()=>n?.(t.toolName),children:e||i(`mcpMonitor.unknownTool`,null,`未知工具`)})},{title:i(`mcpMonitor.columnCalls`,null,`调用`),dataIndex:`totalCalls`,width:90,render:e=>e??0},{title:i(`mcpMonitor.successColumn`,null,`成功`),dataIndex:`successCalls`,width:90,render:e=>e??0},{title:i(`mcpMonitor.failedColumn`,null,`失败`),dataIndex:`failedCalls`,width:90,render:e=>(0,Z.jsx)(`span`,{className:e>0?`mcp-monitor-danger`:void 0,children:e??0})},{title:i(`mcpMonitor.blockedColumn`,null,`拦截`),dataIndex:`blockedCalls`,width:90,render:e=>e?(0,Z.jsx)Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,N as s,Ot as c,W as l,c as u,i as d,jt as f,lt as p,st as m,v as h}from"./semi-CHxO7u8f.js";import{E as g,F as _,I as v,P as y,a as b,b as x,c as S,l as C,m as w,n as T,p as E,s as D,x as O,y as k}from"./index-CuUcClXg.js";var A=e(t(),1),j=e(n(),1),M=[[`project`,`项目`],[`conversation`,`会话`],[`asset`,`资产`],[`vulnerability`,`漏洞`],[`batch_task`,`批量任务`]];function N({users:e,onCancel:t,onSaved:n}){let o=(0,A.useId)(),[s,c]=(0,A.useState)(M[0][0]),[u,f]=(0,A.useState)(``),[p,m]=(0,A.useState)(0),[g,_]=(0,A.useState)([]),[y,x]=(0,A.useState)(null),[w,E]=(0,A.useState)(!1),D=T(u,250),k=b(async()=>({type:s,q:D,offset:p,payload:await v.get(`/rbac/resources`,{type:s,q:D,limit:20,offset:p})}),[s,D,p]),N=k.data?.type===s&&k.data.q===D&&k.data.offset===p?k.data.payload:null,P=Array.isArray(N?.resources)?N.resources:[],F=new Map([...g,...P.map(e=>[e.id,e.label||e.id])]);return(0,j.jsx)(S,{visible:!0,title:`新增资源授权`,width:560,closable:!w,maskClosable:!w,closeOnEsc:!w,onCancel:t,formId:o,okText:`保存授权`,confirmLoading:w,cancelButtonProps:{disabled:w},children:(0,j.jsxs)(d,{id:o,onSubmit:async e=>{if(w)return;x(null);let t=String(e.ids||``).split(/[\s,,;;]+/).filter(Boolean),r=[...new Set([...g.map(([e])=>e),...t])];if(!r.length||r.length>100)x(Error(`请选择或输入 1 至 100 个资源 ID`));else{E(!0);try{await v.post(`/rbac/resource-assignments`,{user_id:e.user_id,resource_type:s,resource_ids:r}),O(`资源授权已保存`),n()}catch(e){x(e)}finally{E(!1)}}},initValues:{resource_type:s},children:[(0,j.jsx)(d.Select,{field:`user_id`,label:`用户`,filter:!0,optionList:e.map(e=>({value:e.id,label:e.display_name||e.username})),rules:[{required:!0,message:`请选择用户`}]}),(0,j.jsx)(d.Select,{field:`resource_type`,label:`资源类型`,optionList:M.map(([e,t])=>({value:e,label:t})),onChange:e=>{c(e),_([]),f(``),m(0)}}),(0,j.jsx)(d.Slot,{label:`按名称或 ID 搜索`,children:(0,j.jsx)(i,{"aria-label":`搜索资源`,value:u,onChange:e=>{f(e),m(0)}})}),(0,j.jsxs)(d.Slot,{label:`选择资源`,children:[(0,j.jsxs)(r,{wrap:!0,children:[(0,j.jsx)(a,{size:`small`,disabled:p===0||k.loading,onClick:()=>m(e=>Math.max(0,e-20)),children:`上一页`}),(0,j.jsxs)(l.Text,{type:`tertiary`,children:[p+P.length,` / `,N?.total??`—`]}),(0,j.jsx)(a,{size:`small`,disabled:!N?.has_more||k.loading,onClick:()=>m(e=>e+20),children:`下一页`})]}),(0,j.jsx)(h,{multiple:!0,style:{width:`100%`,marginTop:8},loading:k.loading,value:g.map(([e])=>e),"aria-label":`选择资源`,optionList:[...F].map(([e,t])=>({value:e,label:t})),onChange:e=>_((e||[]).map(e=>[e,F.get(e)||e]))})]}),(0,j.jsx)(d.TextArea,{field:`ids`,label:`手动输入资源 ID`,placeholder:`多个 ID 用空格或换行分隔`,rows:2}),(0,j.jsx)(C,{error:y||k.error})]})})}var{Text:P}=l;function F({value:e=[],options:t,onChange:n}){let r=(0,A.useMemo)(()=>{let e=new Map;return t.forEach(t=>{let[n]=t.split(`:`);e.has(n)||e.set(n,[]),e.get(n).push(t)}),[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[t]);return(0,j.jsx)(`div`,{style:{maxHeight:320,overflow:`auto`,border:`1px solid var(--semi-color-border)`,borderRadius:8,padding:12},children:r.map(([t,r])=>(0,j.jsxs)(`div`,{style:{marginBottom:10},children:[(0,j.jsx)(P,{type:`tertiary`,style:{fontSize:12,textTransform:`uppercase`},children:t}),(0,j.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8,marginTop:4},children:r.map(t=>(0,j.jsx)(s,{checked:e.includes(t),onChange:r=>{let i=new Set(e);r.target.checked?i.add(t):i.delete(t),n([...i])},children:t.split(`:`)[1]},t))})]},t))})}function I(){let e=y(),{hasPermission:t}=_(),n=t(`rbac:write`),[i,s]=(0,A.useState)(`roles`),[l,h]=(0,A.useState)(null),[T,M]=(0,A.useState)(null),[I,L]=(0,A.useState)(!1),[R,z]=(0,A.useState)(!1),B=b(()=>v.get(`/rbac/metadata`),[]),V=b(()=>v.get(`/rbac/roles`),[]),H=b(()=>v.get(`/rbac/users`),[]),U=b(()=>v.get(`/rbac/resource-assignments`),[]),W=B.data?.permissions?Object.keys(B.data.permissions):[],G=Array.isArray(V.data?.roles)?V.data.roles:[],K=Array.isArray(H.data?.users)?H.data.users:[],q=Array.isArray(U.data?.assignments)?U.data.assignments:[],J=G.map(e=>({value:e.id,label:e.name})),Y=new Map(G.map(e=>[e.id,e.name])),X=new Map(K.map(e=>[e.id,e.display_name||e.username])),Z=async()=>{if(R||!l?.form)return;let e=await l.form.validate().catch(()=>null);if(e){z(!0);try{let t={name:e.name.trim(),description:e.description||``,scope:e.scope||``,permissions:l.permissions||[]};l.role?.id?await v.put(`/rbac/roles/${encodeURIComponent(l.role.id)}`,t):await v.post(`/rbac/roles`,t),O(`角色已保存`),h(null),V.reload(),B.reload()}catch(e){x(e,`保存角色失败`)}finally{z(!1)}}},Q=async()=>{if(R||!T?.form)return;let e=await T.form.validate().catch(()=>null);if(e){z(!0);try{let t={display_name:e.display_name||``,enabled:e.enabled!==!1,roles:e.roles||[]};T.user?.id?(e.password&&(tLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,N as s,Ot as c,W as l,c as u,i as d,jt as f,lt as p,st as m,v as h}from"./semi-CHxO7u8f.js";import{E as g,F as _,I as v,P as y,a as b,b as x,c as S,l as C,m as w,n as T,p as E,s as D,x as O,y as k}from"./index-BLFHsWWk.js";var A=e(t(),1),j=e(n(),1),M=[[`project`,`项目`],[`conversation`,`会话`],[`asset`,`资产`],[`vulnerability`,`漏洞`],[`batch_task`,`批量任务`]];function N({users:e,onCancel:t,onSaved:n}){let o=(0,A.useId)(),[s,c]=(0,A.useState)(M[0][0]),[u,f]=(0,A.useState)(``),[p,m]=(0,A.useState)(0),[g,_]=(0,A.useState)([]),[y,x]=(0,A.useState)(null),[w,E]=(0,A.useState)(!1),D=T(u,250),k=b(async()=>({type:s,q:D,offset:p,payload:await v.get(`/rbac/resources`,{type:s,q:D,limit:20,offset:p})}),[s,D,p]),N=k.data?.type===s&&k.data.q===D&&k.data.offset===p?k.data.payload:null,P=Array.isArray(N?.resources)?N.resources:[],F=new Map([...g,...P.map(e=>[e.id,e.label||e.id])]);return(0,j.jsx)(S,{visible:!0,title:`新增资源授权`,width:560,closable:!w,maskClosable:!w,closeOnEsc:!w,onCancel:t,formId:o,okText:`保存授权`,confirmLoading:w,cancelButtonProps:{disabled:w},children:(0,j.jsxs)(d,{id:o,onSubmit:async e=>{if(w)return;x(null);let t=String(e.ids||``).split(/[\s,,;;]+/).filter(Boolean),r=[...new Set([...g.map(([e])=>e),...t])];if(!r.length||r.length>100)x(Error(`请选择或输入 1 至 100 个资源 ID`));else{E(!0);try{await v.post(`/rbac/resource-assignments`,{user_id:e.user_id,resource_type:s,resource_ids:r}),O(`资源授权已保存`),n()}catch(e){x(e)}finally{E(!1)}}},initValues:{resource_type:s},children:[(0,j.jsx)(d.Select,{field:`user_id`,label:`用户`,filter:!0,optionList:e.map(e=>({value:e.id,label:e.display_name||e.username})),rules:[{required:!0,message:`请选择用户`}]}),(0,j.jsx)(d.Select,{field:`resource_type`,label:`资源类型`,optionList:M.map(([e,t])=>({value:e,label:t})),onChange:e=>{c(e),_([]),f(``),m(0)}}),(0,j.jsx)(d.Slot,{label:`按名称或 ID 搜索`,children:(0,j.jsx)(i,{"aria-label":`搜索资源`,value:u,onChange:e=>{f(e),m(0)}})}),(0,j.jsxs)(d.Slot,{label:`选择资源`,children:[(0,j.jsxs)(r,{wrap:!0,children:[(0,j.jsx)(a,{size:`small`,disabled:p===0||k.loading,onClick:()=>m(e=>Math.max(0,e-20)),children:`上一页`}),(0,j.jsxs)(l.Text,{type:`tertiary`,children:[p+P.length,` / `,N?.total??`—`]}),(0,j.jsx)(a,{size:`small`,disabled:!N?.has_more||k.loading,onClick:()=>m(e=>e+20),children:`下一页`})]}),(0,j.jsx)(h,{multiple:!0,style:{width:`100%`,marginTop:8},loading:k.loading,value:g.map(([e])=>e),"aria-label":`选择资源`,optionList:[...F].map(([e,t])=>({value:e,label:t})),onChange:e=>_((e||[]).map(e=>[e,F.get(e)||e]))})]}),(0,j.jsx)(d.TextArea,{field:`ids`,label:`手动输入资源 ID`,placeholder:`多个 ID 用空格或换行分隔`,rows:2}),(0,j.jsx)(C,{error:y||k.error})]})})}var{Text:P}=l;function F({value:e=[],options:t,onChange:n}){let r=(0,A.useMemo)(()=>{let e=new Map;return t.forEach(t=>{let[n]=t.split(`:`);e.has(n)||e.set(n,[]),e.get(n).push(t)}),[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[t]);return(0,j.jsx)(`div`,{style:{maxHeight:320,overflow:`auto`,border:`1px solid var(--semi-color-border)`,borderRadius:8,padding:12},children:r.map(([t,r])=>(0,j.jsxs)(`div`,{style:{marginBottom:10},children:[(0,j.jsx)(P,{type:`tertiary`,style:{fontSize:12,textTransform:`uppercase`},children:t}),(0,j.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8,marginTop:4},children:r.map(t=>(0,j.jsx)(s,{checked:e.includes(t),onChange:r=>{let i=new Set(e);r.target.checked?i.add(t):i.delete(t),n([...i])},children:t.split(`:`)[1]},t))})]},t))})}function I(){let e=y(),{hasPermission:t}=_(),n=t(`rbac:write`),[i,s]=(0,A.useState)(`roles`),[l,h]=(0,A.useState)(null),[T,M]=(0,A.useState)(null),[I,L]=(0,A.useState)(!1),[R,z]=(0,A.useState)(!1),B=b(()=>v.get(`/rbac/metadata`),[]),V=b(()=>v.get(`/rbac/roles`),[]),H=b(()=>v.get(`/rbac/users`),[]),U=b(()=>v.get(`/rbac/resource-assignments`),[]),W=B.data?.permissions?Object.keys(B.data.permissions):[],G=Array.isArray(V.data?.roles)?V.data.roles:[],K=Array.isArray(H.data?.users)?H.data.users:[],q=Array.isArray(U.data?.assignments)?U.data.assignments:[],J=G.map(e=>({value:e.id,label:e.name})),Y=new Map(G.map(e=>[e.id,e.name])),X=new Map(K.map(e=>[e.id,e.display_name||e.username])),Z=async()=>{if(R||!l?.form)return;let e=await l.form.validate().catch(()=>null);if(e){z(!0);try{let t={name:e.name.trim(),description:e.description||``,scope:e.scope||``,permissions:l.permissions||[]};l.role?.id?await v.put(`/rbac/roles/${encodeURIComponent(l.role.id)}`,t):await v.post(`/rbac/roles`,t),O(`角色已保存`),h(null),V.reload(),B.reload()}catch(e){x(e,`保存角色失败`)}finally{z(!1)}}},Q=async()=>{if(R||!T?.form)return;let e=await T.form.validate().catch(()=>null);if(e){z(!0);try{let t={display_name:e.display_name||``,enabled:e.enabled!==!1,roles:e.roles||[]};T.user?.id?(e.password&&(tLine truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{W as r,i}from"./semi-CHxO7u8f.js";import{I as a,P as o,c as s,l as c,x as l}from"./index-CuUcClXg.js";var u=e(t(),1),d=e(n(),1),{Text:f}=r,p=120,m=4e3;function h({visible:e,project:t,onCancel:n,onSaved:r}){let h=o(),g=(0,u.useId)(),[_,v]=(0,u.useState)(!1),[y,b]=(0,u.useState)(null),x=!!t?.id;return(0,u.useEffect)(()=>{b(null)},[e,t?.id]),(0,d.jsxs)(s,{visible:e,width:560,closable:!_,closeOnEsc:!_,onCancel:n,cancelButtonProps:{disabled:_},title:x?h(`projects.modalEditTitle`,null,`编辑项目`):h(`projects.modalNewTitle`,null,`新建项目`),formId:g,okText:x?h(`projects.saveChanges`,null,`保存修改`):h(`projects.createProject`,null,`创建项目`),confirmLoading:_,children:[(0,d.jsx)(f,{type:`tertiary`,size:`small`,children:x?h(`projects.modalEditSubtitle`,null,`修改项目名称与描述`):h(`projects.modalNewSubtitle`,null,`创建后可绑定对话,跨会话共享事实黑板`)}),(0,d.jsxs)(i,{id:g,onSubmit:async e=>{if(!_){v(!0),b(null);try{let n={name:e.name.trim(),description:(e.description||``).slice(0,m)},i=x?await a.put(`/projects/${t.id}`,n):await a.post(`/projects`,n);l(x?h(`projects.saved`,null,`已保存`):h(`projects.createProject`,null,`创建项目`)),r?.(i)}catch(e){b(e)}finally{v(!1)}}},initValues:{name:t?.name||``,description:t?.description||``},children:[(0,d.jsx)(i.Input,{id:`${g}-name`,field:`name`,maxLength:p,label:h(`projects.projectName`,null,`项目名称`),placeholder:h(`projects.projectNamePlaceholder`,null,`例如:某客户 Web 渗透`),rules:[{required:!0,whitespace:!0,message:h(`projects.enterProjectName`,null,`请输入项目名称`)}]}),(0,d.jsx)(i.TextArea,{id:`${g}-description`,field:`description`,rows:4,maxCount:m,label:h(`projects.projectDescription`,null,`项目描述`),placeholder:h(`projects.projectDescriptionPlaceholder`,null,`客户/任务备注、协作说明…`),extraText:h(`projects.descriptionLengthHint`,null,`仅供团队成员查阅,Agent 不会读取;需让 Agent 知晓的内容请写入事实黑板`)}),(0,d.jsx)(c,{error:y})]},`${e}-${t?.id||`new`}`)]})}export{h as t};
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{W as r,i}from"./semi-CHxO7u8f.js";import{I as a,P as o,c as s,l as c,x as l}from"./index-BLFHsWWk.js";var u=e(t(),1),d=e(n(),1),{Text:f}=r,p=120,m=4e3;function h({visible:e,project:t,onCancel:n,onSaved:r}){let h=o(),g=(0,u.useId)(),[_,v]=(0,u.useState)(!1),[y,b]=(0,u.useState)(null),x=!!t?.id;return(0,u.useEffect)(()=>{b(null)},[e,t?.id]),(0,d.jsxs)(s,{visible:e,width:560,closable:!_,closeOnEsc:!_,onCancel:n,cancelButtonProps:{disabled:_},title:x?h(`projects.modalEditTitle`,null,`编辑项目`):h(`projects.modalNewTitle`,null,`新建项目`),formId:g,okText:x?h(`projects.saveChanges`,null,`保存修改`):h(`projects.createProject`,null,`创建项目`),confirmLoading:_,children:[(0,d.jsx)(f,{type:`tertiary`,size:`small`,children:x?h(`projects.modalEditSubtitle`,null,`修改项目名称与描述`):h(`projects.modalNewSubtitle`,null,`创建后可绑定对话,跨会话共享事实黑板`)}),(0,d.jsxs)(i,{id:g,onSubmit:async e=>{if(!_){v(!0),b(null);try{let n={name:e.name.trim(),description:(e.description||``).slice(0,m)},i=x?await a.put(`/projects/${t.id}`,n):await a.post(`/projects`,n);l(x?h(`projects.saved`,null,`已保存`):h(`projects.createProject`,null,`创建项目`)),r?.(i)}catch(e){b(e)}finally{v(!1)}}},initValues:{name:t?.name||``,description:t?.description||``},children:[(0,d.jsx)(i.Input,{id:`${g}-name`,field:`name`,maxLength:p,label:h(`projects.projectName`,null,`项目名称`),placeholder:h(`projects.projectNamePlaceholder`,null,`例如:某客户 Web 渗透`),rules:[{required:!0,whitespace:!0,message:h(`projects.enterProjectName`,null,`请输入项目名称`)}]}),(0,d.jsx)(i.TextArea,{id:`${g}-description`,field:`description`,rows:4,maxCount:m,label:h(`projects.projectDescription`,null,`项目描述`),placeholder:h(`projects.projectDescriptionPlaceholder`,null,`客户/任务备注、协作说明…`),extraText:h(`projects.descriptionLengthHint`,null,`仅供团队成员查阅,Agent 不会读取;需让 Agent 知晓的内容请写入事实黑板`)}),(0,d.jsx)(c,{error:y})]},`${e}-${t?.id||`new`}`)]})}export{h as t};
@@ -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{E as a,Et as o,F as s,Gt as c,H as l,L as u,M as d,N as f,St as p,T as m,Tt as h,U as g,Ut as _,W as v,X as y,Zt as b,_ as x,c as S,f as C,g as w,gt as T,it as E,lt as D,ot as O,pt as k,st as ee,u as A,v as j,vt as M,x as N,xt as P}from"./semi-CHxO7u8f.js";import{E as F,F as I,I as L,P as R,_ as te,a as z,b as B,c as ne,d as re,f as ie,l as V,m as H,n as U,p as ae,s as oe,t as se,x as W,y as G}from"./index-CuUcClXg.js";import{t as ce}from"./project-form-B4r3E78D.js";import{t as le}from"./AssetEditorModal-vqUCUeiX.js";var K=e(t(),1),q=[{value:`target`,label:`target(目标)`},{value:`auth`,label:`auth(认证)`},{value:`infra`,label:`infra(基础设施)`},{value:`business`,label:`business(业务)`},{value:`finding`,label:`finding(发现)`},{value:`chain`,label:`chain(攻击链)`},{value:`exploit`,label:`exploit(利用)`},{value:`poc`,label:`poc(POC)`},{value:`note`,label:`note(备注)`}],ue={target:`目标`,auth:`认证`,infra:`基础设施`,business:`业务`,finding:`发现`,chain:`攻击链`,exploit:`利用`,poc:`POC`,note:`备注`,vuln:`漏洞`,missing:`缺失`},de=[{value:`tentative`,label:`待确认`},{value:`confirmed`,label:`已确认`},{value:`deprecated`,label:`已废弃`}],fe={confirmed:{label:`已确认`,color:`green`},tentative:{label:`待确认`,color:`amber`},deprecated:{label:`已废弃`,color:`grey`}},pe=[{value:`active`,label:`进行中`},{value:`archived`,label:`已归档`}],J={target:`#2563eb`,auth:`#0891b2`,infra:`#0d9488`,finding:`#d97706`,chain:`#db2777`,exploit:`#7c3aed`,poc:`#7c3aed`,vulnerability:`#dc2626`,note:`#64748b`,missing:`#94a3b8`},me={target:`TARGET · 目标`,auth:`AUTH · 认证`,infra:`INFRA · 基础设施`,finding:`FINDING · 发现`,chain:`CHAIN · 攻击链`,exploit:`EXPLOIT · 利用`,poc:`POC · 验证`,vulnerability:`VULN · 漏洞`,note:`NOTE · 备注`,missing:`MISSING · 缺失`},he=[`discovered_on`,`depends_on`,`leads_to`,`enables`,`exploits`];function Y(e,t=`操作失败`){if(!e)return t;if(typeof e==`string`)return e;let n=e.payload;if(n&&typeof n==`object`){let e=n.error;if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=typeof e.message==`string`?e.message:``,n=typeof e.code==`string`?e.code:``;if(t)return n?`${t}(${n})`:t}if(typeof n.message==`string`&&n.message)return n.message}return typeof e.message==`string`&&e.message&&e.message!==`[object Object]`?e.message:t}function ge(e,t=`加载失败`){return e?{message:Y(e,t)}:null}function _e(e){return!Array.isArray(e)||!e.length?``:e.map(e=>`${e.edge_type||e.type||``}: ${e.source_fact_key||e.from||``}`.trim()).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{E as a,Et as o,F as s,Gt as c,H as l,L as u,M as d,N as f,St as p,T as m,Tt as h,U as g,Ut as _,W as v,X as y,Zt as b,_ as x,c as S,f as C,g as w,gt as T,it as E,lt as D,ot as O,pt as k,st as ee,u as A,v as j,vt as M,x as N,xt as P}from"./semi-CHxO7u8f.js";import{E as F,F as I,I as L,P as R,_ as te,a as z,b as B,c as ne,d as re,f as ie,l as V,m as H,n as U,p as ae,s as oe,t as se,x as W,y as G}from"./index-BLFHsWWk.js";import{t as ce}from"./project-form-B3I4tCMR.js";import{t as le}from"./AssetEditorModal-DwPErx6-.js";var K=e(t(),1),q=[{value:`target`,label:`target(目标)`},{value:`auth`,label:`auth(认证)`},{value:`infra`,label:`infra(基础设施)`},{value:`business`,label:`business(业务)`},{value:`finding`,label:`finding(发现)`},{value:`chain`,label:`chain(攻击链)`},{value:`exploit`,label:`exploit(利用)`},{value:`poc`,label:`poc(POC)`},{value:`note`,label:`note(备注)`}],ue={target:`目标`,auth:`认证`,infra:`基础设施`,business:`业务`,finding:`发现`,chain:`攻击链`,exploit:`利用`,poc:`POC`,note:`备注`,vuln:`漏洞`,missing:`缺失`},de=[{value:`tentative`,label:`待确认`},{value:`confirmed`,label:`已确认`},{value:`deprecated`,label:`已废弃`}],fe={confirmed:{label:`已确认`,color:`green`},tentative:{label:`待确认`,color:`amber`},deprecated:{label:`已废弃`,color:`grey`}},pe=[{value:`active`,label:`进行中`},{value:`archived`,label:`已归档`}],J={target:`#2563eb`,auth:`#0891b2`,infra:`#0d9488`,finding:`#d97706`,chain:`#db2777`,exploit:`#7c3aed`,poc:`#7c3aed`,vulnerability:`#dc2626`,note:`#64748b`,missing:`#94a3b8`},me={target:`TARGET · 目标`,auth:`AUTH · 认证`,infra:`INFRA · 基础设施`,finding:`FINDING · 发现`,chain:`CHAIN · 攻击链`,exploit:`EXPLOIT · 利用`,poc:`POC · 验证`,vulnerability:`VULN · 漏洞`,note:`NOTE · 备注`,missing:`MISSING · 缺失`},he=[`discovered_on`,`depends_on`,`leads_to`,`enables`,`exploits`];function Y(e,t=`操作失败`){if(!e)return t;if(typeof e==`string`)return e;let n=e.payload;if(n&&typeof n==`object`){let e=n.error;if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=typeof e.message==`string`?e.message:``,n=typeof e.code==`string`?e.code:``;if(t)return n?`${t}(${n})`:t}if(typeof n.message==`string`&&n.message)return n.message}return typeof e.message==`string`&&e.message&&e.message!==`[object Object]`?e.message:t}function ge(e,t=`加载失败`){return e?{message:Y(e,t)}:null}function _e(e){return!Array.isArray(e)||!e.length?``:e.map(e=>`${e.edge_type||e.type||``}: ${e.source_fact_key||e.from||``}`.trim()).join(`
`)}var X=e(r(),1),{Text:ve}=v;function ye({value:e}){let t=fe[String(e||``).toLowerCase()]||{label:e||`—`,color:`grey`};return(0,X.jsx)(d,{size:`small`,color:t.color,children:t.label})}function be({projectId:e,canWrite:t,revision:n=0,onAddFact:r,onEditFact:i,onViewFact:a,onMutated:o}){let c=R(),[p,m]=(0,K.useState)(``),h=U(p,300),[g,_]=(0,K.useState)(`all`),[v,y]=(0,K.useState)(`all`),[b,x]=(0,K.useState)(!0),[S,C]=(0,K.useState)(!1),T=z(()=>L.get(`/projects/${e}/facts`,{limit:200,include_link_counts:`true`,exclude_deprecated:b?`true`:void 0,search:h.trim()||void 0,category:g===`all`?void 0:g,confidence:v===`all`?void 0:v,sparse_only:S?`true`:void 0}),[e,h,g,v,b,S,n]),E=(0,K.useMemo)(()=>Array.isArray(T.data)?T.data:[],[T.data]),k=async t=>{try{await L.post(`/projects/${e}/facts/deprecate`,{fact_key:t.fact_key}),W(c(`projects.saved`,null,`已保存`)),o?o():T.reload({silent:!0})}catch(e){B(Y(e,c(`projects.operationFailed`,null,`操作失败`)))}},A=async t=>{try{await L.post(`/projects/${e}/facts/restore`,{fact_key:t.fact_key,confidence:`tentative`}),W(c(`projects.saved`,null,`已保存`)),o?o():T.reload({silent:!0})}catch(e){B(Y(e,c(`projects.operationFailed`,null,`操作失败`)))}},M=t=>{G({title:c(`projects.deleteForeverTitle`,null,`永久删除`),content:c(`projects.confirmDeleteFact`,null,`删除该事实?`),okText:c(`common.delete`,null,`删除`),onOk:async()=>{try{await L.del(`/projects/${e}/facts/${t.id}`),W(c(`common.delete`,null,`删除`)),o?o():T.reload({silent:!0})}catch(e){B(Y(e,c(`projects.operationFailed`,null,`操作失败`)))}}})},N=[{title:`fact_key`,dataIndex:`fact_key`,width:230,render:(e,t)=>(0,X.jsxs)(`div`,{className:`project-fact-key`,children:[(0,X.jsx)(`code`,{className:`project-fact-key-chip`,title:e,children:e}),(0,X.jsxs)(`div`,{className:`project-fact-key-meta`,children:[t.pinned&&(0,X.jsx)(d,{size:`small`,color:`blue`,type:`light`,children:c(`projects.pinned`,null,`置顶`)}),t.related_vulnerability_id&&(0,X.jsx)(d,{size:`small`,color:`violet`,type:`light`,title:t.related_vulnerability_id,children:c(`projects.relatedVulnIdTitle`,null,`关联漏洞 ID`)})]})]})},{title:c(`projects.category`,null,`分类`),dataIndex:`category`,width:108,render:e=>(0,X.jsx)(d,{size:`small`,color:`cyan`,type:`light`,children:ue[String(e||``).toLowerCase()]||e||`—`})},{title:c(`projects.summary`,null,`摘要`),dataIndex:`summary`,render:(e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`project-cell-ellipsis project-link-button`,title:e,onClick:()=>a?.(t.fact_key),children:e||`—`})},{title:c(`projects.linksColumn`,null,`关系`),dataIndex:`link_counts`,width:92,render:e=>{let t=e?.outgoing||0,n=e?.incoming||0;return!t&&!n?(0,X.jsx)(ve,{type:`tertiary`,children:`—`}):(0,X.jsxs)(`span`,{className:`project-link-counts`,title:c(`projects.linkCountsTitle`,null,`出边数 / 入边数`),children:[`↑`,t,` ↓`,n]})}},{title:c(`projects.confidence`,null,`置信度`),dataIndex:`confidence`,width:92,render:e=>(0,X.jsx)(ye,{value:e})},{title:c(`projects.updated`,null,`更新`),dataIndex:`updated_at`,width:158,render:e=>(0,X.jsx)(ve,{size:`small`,children:F(e)})},{title:c(`common.actions`,null,`操作`),dataIndex:`id`,width:224,render:(e,n)=>{let r=String(n.confidence||``).toLowerCase()===`deprecated`;return(0,X.jsxs)(s,{spacing:2,wrap:!0,children:[(0,X.jsx)(u,{size:`small`,theme:`borderless`,onClick:()=>a?.(n.fact_key),children:c(`projects.details`,null,`详情`)}),(0,X.jsx)(u,{size:`small`,theme:`borderless`,disabled:!t,onClick:()=>i?.(n.fact_key),children:c(`common.edit`,null,`编辑`)}),r?(0,X.jsx)(u,{size:`small`,theme:`borderless`,disabled:!t,onClick:()=>A(n),children:c(`projects.restore`,null,`恢复`)}):(0,X.jsx)(w,{title:c(`projects.confirmDeprecateFact`,{factKey:n.fact_key},`将事实 ${n.fact_key} 标记为已废弃?`),onConfirm:()=>k(n),disabled:!t,children:(0,X.jsx)(u,{size:`small`,theme:`borderless`,disabled:!t,title:c(`projects.deprecateTitle`,null,`标记为已废弃`),children:c(`projects.deprecate`,null,`废弃`)})}),(0,X.jsx)(u,{size:`small`,theme:`borderless`,type:`danger`,disabled:!t,onClick:()=>M(n),children:c(`common.delete`,null,`删除`)})]})}}];return(0,X.jsxs)(H,{title:c(`projects.tabFacts`,null,`事实黑板`),description:c(`projects.factToolbarHint`,null,`索引仅含 key 与摘要;攻击链 / POC 写在 body,Agent 通过 get_project_fact 复现`),extra:(0,X.jsxs)(s,{children:[(0,X.jsx)(u,{icon:(0,X.jsx)(ee,{}),theme:`borderless`,loading:T.loading,onClick:()=>{o?o():T.reload()}}),(0,X.jsx)(u,{type:`primary`,icon:(0,X.jsx)(D,{}),disabled:!t,onClick:r,children:c(`projects.addFact`,null,`添加事实`)})]}),children:[(0,X.jsx)(V,{error:ge(T.error),onRetry:T.reload}),(0,X.jsxs)(`div`,{className:`project-toolbar`,children:[(0,X.jsx)(l,{prefix:(0,X.jsx)(O,{}),value:p,showClear:!0,"aria-label":c(`projects.searchFactsSr`,null,`搜索事实`),placeholder:c(`projects.searchFactsPlaceholder`,null,`搜索 key、摘要、body…`),onChange:e=>m(e),style:{width:260}}),(0,X.js Line truncated
"targets": ["https://example.com"]
}`,onChange:e=>m({scope_json:e})}),(0,X.jsx)(Q,{type:`tertiary`,size:`small`,children:o(`projects.scopeFootnote`,null,`支持 targets、exclude、notes 等字段,留空表示不限制范围。`)})]}),(0,X.jsx)(a,{margin:`12px`}),(0,X.jsxs)(`div`,{className:`project-danger-zone`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(Q,{strong:!0,children:o(`projects.dangerZoneTitle`,null,`危险操作`)}),(0,X.jsx)(`div`,{children:(0,X.jsx)(Q,{type:`tertiary`,size:`small`,children:o(`projects.dangerZoneHint`,null,`归档后需在列表勾选「显示已归档」才能查看;删除将清除全部事实且不可恢复。`)})})]}),(0,X.jsxs)(s,{children:[(0,X.jsx)(u,{disabled:!t,onClick:()=>{G({title:v?o(`projects.restoreProjectActive`,null,`恢复为进行中`):o(`projects.archiveProject`,null,`归档`),content:v?o(`projects.confirmRestoreProjectActive`,null,`恢复为 active?`):o(`projects.confirmArchiveProject`,null,`归档后默认不再出现在活跃列表,是否继续?`),okText:o(`common.confirm`,null,`确认`),danger:!v,onOk:async()=>{try{await L.put(`/projects/${e.id}`,{status:v?`active`:`archived`}),W(o(`projects.saved`,null,`已保存`)),r?.()}catch(e){B(Y(e,o(`projects.operationFailed`,null,`操作失败`)))}}})},children:v?o(`projects.restoreProjectActive`,null,`恢复为进行中`):o(`projects.archiveProject`,null,`归档`)}),(0,X.jsx)(u,{type:`danger`,disabled:!n,onClick:()=>{G({title:o(`projects.deleteProject`,null,`删除项目`),content:o(`projects.confirmDeleteProject`,null,`确定删除该项目?事实将一并删除,对话将解除绑定。`),okText:o(`common.delete`,null,`删除`),onOk:async()=>{try{await L.del(`/projects/${e.id}`),W(o(`projects.deleteProject`,null,`删除项目`)),i?.(e.id)}catch(e){B(Y(e,o(`projects.deleteFailed`,null,`删除失败`)))}}})},children:o(`projects.deleteProject`,null,`删除项目`)})]})]})]}):(0,X.jsx)(H,{title:o(`projects.tabSettings`,null,`设置`),children:(0,X.jsx)(Q,{type:`tertiary`,children:o(`projects.selectOrCreateTitle`,null,`选择或创建项目`)})})}var{Text:$}=v,Ke={fact_key:``,category:`note`,summary:``,body:``,confidence:`tentative`,pinned:!1,related_vulnerability_id:``,links_text:``};function qe({visible:e,projectId:t,factKey:n,onCancel:r,onSaved:i}){let a=R(),[o,s]=(0,K.useState)(Ke),[c,u]=(0,K.useState)(q),[d,p]=(0,K.useState)(!1),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(``),v=!!n;(0,K.useEffect)(()=>{if(!e||(s(Ke),u(q),_(``),p(!1),h(!1),!n))return;let r=!1;return p(!0),L.get(`/projects/${t}/facts`,{fact_key:n,include_links:`true`}).then(e=>{if(r||!e)return;let t=e.category||`note`;q.some(e=>e.value===t)||u([...q,{value:t,label:`${t}(自定义)`}]),_(e.id||``),s({fact_key:e.fact_key||n,category:t,summary:e.summary||``,body:e.body||``,confidence:(e.confidence||`tentative`).toLowerCase(),pinned:!!e.pinned,related_vulnerability_id:e.related_vulnerability_id||``,links_text:_e(e.incoming_links)})}).catch(e=>{r||B(Y(e,a(`projects.loadFactFailed`,null,`加载事实失败`)))}).finally(()=>{r||p(!1)}),()=>{r=!0}},[e,t,n]);let y=e=>s(t=>({...t,...e})),b=(0,K.useMemo)(()=>he.join(`、`),[]);return(0,X.jsxs)(ne,{visible:e,title:v?a(`projects.editFact`,null,`编辑事实`):a(`projects.addFact`,null,`添加事实`),onCancel:r,onOk:async()=>{let e=o.fact_key.trim(),n=o.summary.trim();if(!e||!n){B(a(`projects.factKeySummaryRequired`,null,`fact_key 与 summary 必填`));return}let r={fact_key:e,category:o.category||`note`,summary:n,body:o.body,confidence:o.confidence||`tentative`,pinned:!!o.pinned,related_vulnerability_id:o.related_vulnerability_id.trim(),links_text:o.links_text};if(v&&!g)B(a(`projects.loadFactFailed`,null,`加载事实失败`));else{h(!0);try{v&&g?await L.put(`/projects/${t}/facts/${g}`,r):await L.post(`/projects/${t}/facts`,r),W(a(`projects.saved`,null,`已保存`)),i?.()}catch(e){B(Y(e,a(`projects.saveFailed`,null,`保存失败`)))}finally{h(!1)}}},okText:v?a(`projects.saveChanges`,null,`保存修改`):a(`projects.saveFact`,null,`保存事实`),cancelText:a(`common.cancel`,null,`取消`),confirmLoading:m,width:720,children:[(0,X.jsx)($,{type:`tertiary`,size:`small`,children:a(`projects.factModalSubtitle`,null,`摘要注入黑板索引;body 沉淀攻击链与 POC,供审计复现(与漏洞记录分工)`)}),(0,X.jsxs)(`div`,{className:`project-form-grid`,children:[(0,X.jsxs)(`div`,{className:`project-form-field`,children:[(0,X.jsx)($,{strong:!0,size:`small`,children:`fact_key`}),(0,X.jsx)(l,{value:o.fact_key,disabled:d,placeholder:`target/primary_domain`,onChange:e=>y({fact_key:e})})]}),(0,X.jsxs)(`div`,{className:`project-form-field`,children:[(0,X.jsx)($,{strong:!0,size:`small`,children:a(`projects.category`,null,`分类`)}),(0,X.jsx)(j,{value:o.category,optionList:c,onChange:e=>y({category:e}),style:{width:`100%`}})]})]}),(0,X.jsxs)(`div`,{className:`project-form-field`,children:[(0,X.jsx)($,{strong:!0,size:`small`,children:a(`projects.summary`,null,`摘要`)}),(0,X.jsx)(l,{value:o.summary,placeholder:a(`projLine truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,N as s,Ot as ee,T as c,U as te,W as l,_ as u,jt as d,lt as f,m as p,ot as ne,p as m,st as h,u as re,v as g,x as ie,z as ae}from"./semi-CHxO7u8f.js";import{F as oe,I as _,P as v,a as y,b,c as se,l as x,m as S,n as ce,p as C,s as w,x as T,y as E}from"./index-CuUcClXg.js";var D=e(t(),1),O=e(n(),1),{Text:k}=l,A=`默认`;function j(e){if(!e||typeof e!=`string`)return``;let t=e.trim(),n=t.match(/^"?\\U([0-9A-F]{8})"?$/i);if(n)try{return String.fromCodePoint(parseInt(n[1],16))}catch{return t}return t}function M(e){return e?.is_external&&e?.external_mcp?`${e.external_mcp}::${e.name}`:e?.name||``}function N(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e){let e=String(r||``).trim();e&&!t.has(e)&&(t.add(e),n.push(e))}return n}var P=20;function F({visible:e,role:t,onCancel:n,onSaved:ee}){let{hasPermission:l}=oe(),d=l(`mcp:read`)||l(`config:read`),f=l(`workflow:read`),h=!!t,v=t?.name===A,[y,x]=(0,D.useState)(``),[S,C]=(0,D.useState)(``),[w,E]=(0,D.useState)(``),[F,I]=(0,D.useState)(``),[L,R]=(0,D.useState)(``),[z,B]=(0,D.useState)(`auto`),[le,ue]=(0,D.useState)(!0),[V,H]=(0,D.useState)([]),[U,de]=(0,D.useState)(``),[W,G]=(0,D.useState)(``),[fe,pe]=(0,D.useState)(!1),[me,he]=(0,D.useState)([]),[ge,_e]=(0,D.useState)(!1),[K,ve]=(0,D.useState)(``),q=ce(K,250),[J,ye]=(0,D.useState)(`all`),[Y,X]=(0,D.useState)(1),[Z,be]=(0,D.useState)([]),[Q,xe]=(0,D.useState)(0),[Se,Ce]=(0,D.useState)(!1),[we,Te]=(0,D.useState)(null);(0,D.useEffect)(()=>{if(!e)return;x(t?.name||``),C(j(t?.icon)),E(t?.description||``),I(t?.user_prompt||``),R(t?.workflow_id||``),B(t?.workflow_policy||`auto`),ue(!t||t.enabled!==!1);let n=N(t?.tools);H(n),de(n.join(`, `)),G(``),ve(``),ye(`all`),X(1)},[e,t]),(0,D.useEffect)(()=>{if(!e||!f)return;let t=!1;return _e(!0),_.get(`/workflows`,{includeDisabled:`true`}).then(e=>{t||he(Array.isArray(e?.workflows)?e.workflows:[])}).catch(()=>{t||he([])}).finally(()=>{t||_e(!1)}),()=>{t=!0}},[e,f]),(0,D.useEffect)(()=>{X(1)},[q]),(0,D.useEffect)(()=>{if(!e||v||!d||J!==`all`)return;let t=!1;return Ce(!0),Te(null),_.get(`/config/tools`,{page:Y,page_size:P,search:q.trim()||void 0}).then(e=>{t||(be(Array.isArray(e?.tools)?e.tools:[]),xe(Number(e?.total)||0))}).catch(e=>{t||(Te(e),be([]),xe(0))}).finally(()=>{t||Ce(!1)}),()=>{t=!0}},[e,v,d,J,Y,q]);let Ee=(0,D.useMemo)(()=>new Set(V),[V]),De=(0,D.useMemo)(()=>{let e=K.trim().toLowerCase();return e?V.filter(t=>t.toLowerCase().includes(e)):V},[V,K]),Oe=(0,D.useMemo)(()=>{let e=me.map(e=>({value:e.id,label:e.name?`${e.name} (${e.id})`:e.id}));return L&&!e.some(e=>e.value===L)&&e.unshift({value:L,label:L}),e},[me,L]),$=e=>{e&&H(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},ke=()=>{let e=Z.map(M).filter(Boolean);H(t=>N([...t,...e]))},Ae=()=>{let e=new Set(Z.map(M).filter(Boolean));H(t=>t.filter(t=>!e.has(t)))},je=async()=>{let e=y.trim();if(!e)G(`请输入角色名称`);else{G(``),pe(!0);try{let n=v?[]:d?V:N(U.split(`,`)),r=String(L||``).trim(),i={name:v?A:e,description:w.trim(),user_prompt:F,icon:S.trim(),tools:n,enabled:!!le};r&&(i.workflow_id=r,i.workflow_policy=z||`auto`,t?.workflow_id===r&&t?.workflow_version&&(i.workflow_version=t.workflow_version)),h?await _.put(`/roles/${encodeURIComponent(t.name)}`,i):await _.post(`/roles`,i),T(`角色已保存`),ee?.()}catch(e){b(e,`保存角色失败`)}finally{pe(!1)}}},Me=j(S)||(v?`🔵`:`👤`);return(0,O.jsx)(se,{title:h?`编辑角色:${t.name}`:`新建角色`,visible:e,onCancel:n,onOk:je,okText:`保存`,confirmLoading:fe,width:760,children:(0,O.jsxs)(`div`,{className:`cs-role-editor-form`,children:[(0,O.jsxs)(`div`,{className:`cs-role-editor-grid`,children:[(0,O.jsxs)(`div`,{className:`cs-role-field`,children:[(0,O.jsx)(`label`,{className:`cs-role-field-label`,htmlFor:`cs-role-name-input`,children:(0,O.jsx)(`span`,{className:`cs-role-field-required`,children:`角色名称`})}),(0,O.jsx)(i,{id:`cs-role-name-input`,value:y,onChange:e=>{x(e),W&&G(``)},disabled:v,placeholder:`例如:Web应用扫描`,validateStatus:W?`error`:`default`}),W&&(0,O.jsx)(k,{type:`danger`,size:`small`,children:W}),v&&(0,O.jsx)(`span`,{className:`cs-role-field-hint`,children:`默认角色名称不可修改。`})]}),(0,O.jsxs)(`div`,{className:`cs-role-field`,children:[(0,O.jsx)(`label`,{className:`cs-role-field-label`,htmlFor:`cs-role-icon-input`,children:`角色图标`}),(0,O.jsxs)(`div`,{className:`cs-role-icon-input-row`,children:[(0,O.jsx)(`span`,{className:`cs-role-icon-badge`,"aria-hidden":`true`,children:Me}),(0,O.jsx)(i,{id:`cs-role-icon-input`,value:S,onChange:C,placeholder:`Emoji,如 🔍`})]})]})]}),(0,O.jsxs)(`div`,{className:`cs-role-field`,children:[(0,O.jsx)(`label`,{className:`cs-role-field-label`,htmlFor:`cs-role-desc-input`,children:`角色描述`}),(0,O.jsx)(i,{id:`cs-role-desc-input`,value:w,onChange:E,placeholder:`简要说明该角色的职责与适用场景`})]}),(0,O.jsxs)(`div`,{clLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,N as s,Ot as ee,T as c,U as te,W as l,_ as u,jt as d,lt as f,m as p,ot as ne,p as m,st as h,u as re,v as g,x as ie,z as ae}from"./semi-CHxO7u8f.js";import{F as oe,I as _,P as v,a as y,b,c as se,l as x,m as S,n as ce,p as C,s as w,x as T,y as E}from"./index-BLFHsWWk.js";var D=e(t(),1),O=e(n(),1),{Text:k}=l,A=`默认`;function j(e){if(!e||typeof e!=`string`)return``;let t=e.trim(),n=t.match(/^"?\\U([0-9A-F]{8})"?$/i);if(n)try{return String.fromCodePoint(parseInt(n[1],16))}catch{return t}return t}function M(e){return e?.is_external&&e?.external_mcp?`${e.external_mcp}::${e.name}`:e?.name||``}function N(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e){let e=String(r||``).trim();e&&!t.has(e)&&(t.add(e),n.push(e))}return n}var P=20;function F({visible:e,role:t,onCancel:n,onSaved:ee}){let{hasPermission:l}=oe(),d=l(`mcp:read`)||l(`config:read`),f=l(`workflow:read`),h=!!t,v=t?.name===A,[y,x]=(0,D.useState)(``),[S,C]=(0,D.useState)(``),[w,E]=(0,D.useState)(``),[F,I]=(0,D.useState)(``),[L,R]=(0,D.useState)(``),[z,B]=(0,D.useState)(`auto`),[le,ue]=(0,D.useState)(!0),[V,H]=(0,D.useState)([]),[U,de]=(0,D.useState)(``),[W,G]=(0,D.useState)(``),[fe,pe]=(0,D.useState)(!1),[me,he]=(0,D.useState)([]),[ge,_e]=(0,D.useState)(!1),[K,ve]=(0,D.useState)(``),q=ce(K,250),[J,ye]=(0,D.useState)(`all`),[Y,X]=(0,D.useState)(1),[Z,be]=(0,D.useState)([]),[Q,xe]=(0,D.useState)(0),[Se,Ce]=(0,D.useState)(!1),[we,Te]=(0,D.useState)(null);(0,D.useEffect)(()=>{if(!e)return;x(t?.name||``),C(j(t?.icon)),E(t?.description||``),I(t?.user_prompt||``),R(t?.workflow_id||``),B(t?.workflow_policy||`auto`),ue(!t||t.enabled!==!1);let n=N(t?.tools);H(n),de(n.join(`, `)),G(``),ve(``),ye(`all`),X(1)},[e,t]),(0,D.useEffect)(()=>{if(!e||!f)return;let t=!1;return _e(!0),_.get(`/workflows`,{includeDisabled:`true`}).then(e=>{t||he(Array.isArray(e?.workflows)?e.workflows:[])}).catch(()=>{t||he([])}).finally(()=>{t||_e(!1)}),()=>{t=!0}},[e,f]),(0,D.useEffect)(()=>{X(1)},[q]),(0,D.useEffect)(()=>{if(!e||v||!d||J!==`all`)return;let t=!1;return Ce(!0),Te(null),_.get(`/config/tools`,{page:Y,page_size:P,search:q.trim()||void 0}).then(e=>{t||(be(Array.isArray(e?.tools)?e.tools:[]),xe(Number(e?.total)||0))}).catch(e=>{t||(Te(e),be([]),xe(0))}).finally(()=>{t||Ce(!1)}),()=>{t=!0}},[e,v,d,J,Y,q]);let Ee=(0,D.useMemo)(()=>new Set(V),[V]),De=(0,D.useMemo)(()=>{let e=K.trim().toLowerCase();return e?V.filter(t=>t.toLowerCase().includes(e)):V},[V,K]),Oe=(0,D.useMemo)(()=>{let e=me.map(e=>({value:e.id,label:e.name?`${e.name} (${e.id})`:e.id}));return L&&!e.some(e=>e.value===L)&&e.unshift({value:L,label:L}),e},[me,L]),$=e=>{e&&H(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},ke=()=>{let e=Z.map(M).filter(Boolean);H(t=>N([...t,...e]))},Ae=()=>{let e=new Set(Z.map(M).filter(Boolean));H(t=>t.filter(t=>!e.has(t)))},je=async()=>{let e=y.trim();if(!e)G(`请输入角色名称`);else{G(``),pe(!0);try{let n=v?[]:d?V:N(U.split(`,`)),r=String(L||``).trim(),i={name:v?A:e,description:w.trim(),user_prompt:F,icon:S.trim(),tools:n,enabled:!!le};r&&(i.workflow_id=r,i.workflow_policy=z||`auto`,t?.workflow_id===r&&t?.workflow_version&&(i.workflow_version=t.workflow_version)),h?await _.put(`/roles/${encodeURIComponent(t.name)}`,i):await _.post(`/roles`,i),T(`角色已保存`),ee?.()}catch(e){b(e,`保存角色失败`)}finally{pe(!1)}}},Me=j(S)||(v?`🔵`:`👤`);return(0,O.jsx)(se,{title:h?`编辑角色:${t.name}`:`新建角色`,visible:e,onCancel:n,onOk:je,okText:`保存`,confirmLoading:fe,width:760,children:(0,O.jsxs)(`div`,{className:`cs-role-editor-form`,children:[(0,O.jsxs)(`div`,{className:`cs-role-editor-grid`,children:[(0,O.jsxs)(`div`,{className:`cs-role-field`,children:[(0,O.jsx)(`label`,{className:`cs-role-field-label`,htmlFor:`cs-role-name-input`,children:(0,O.jsx)(`span`,{className:`cs-role-field-required`,children:`角色名称`})}),(0,O.jsx)(i,{id:`cs-role-name-input`,value:y,onChange:e=>{x(e),W&&G(``)},disabled:v,placeholder:`例如:Web应用扫描`,validateStatus:W?`error`:`default`}),W&&(0,O.jsx)(k,{type:`danger`,size:`small`,children:W}),v&&(0,O.jsx)(`span`,{className:`cs-role-field-hint`,children:`默认角色名称不可修改。`})]}),(0,O.jsxs)(`div`,{className:`cs-role-field`,children:[(0,O.jsx)(`label`,{className:`cs-role-field-label`,htmlFor:`cs-role-icon-input`,children:`角色图标`}),(0,O.jsxs)(`div`,{className:`cs-role-icon-input-row`,children:[(0,O.jsx)(`span`,{className:`cs-role-icon-badge`,"aria-hidden":`true`,children:Me}),(0,O.jsx)(i,{id:`cs-role-icon-input`,value:S,onChange:C,placeholder:`Emoji,如 🔍`})]})]})]}),(0,O.jsxs)(`div`,{className:`cs-role-field`,children:[(0,O.jsx)(`label`,{className:`cs-role-field-label`,htmlFor:`cs-role-desc-input`,children:`角色描述`}),(0,O.jsx)(i,{id:`cs-role-desc-input`,value:w,onChange:E,placeholder:`简要说明该角色的职责与适用场景`})]}),(0,O.jsxs)(`div`,{clLine truncated
@@ -1,4 +1,4 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,_ as n,t as r,y as i}from"./react-QV7DAAIx.js";import{$t as a,A as o,F as s,H as c,I as l,L as u,M as d,O as f,W as p,Z as m,c as h,f as g,h as _,kt as v,m as y,ot as b,p as x,s as S,st as ee,u as C,v as w,x as T,z as E}from"./semi-CHxO7u8f.js";import{A as te,D,E as O,F as ne,I as k,L as A,M as j,N as M,P as N,R as P,S as F,T as I,_ as re,a as L,b as R,d as z,j as ie,l as B,m as V,n as H,o as U,p as W,s as G,u as K,x as ae,y as oe}from"./index-CuUcClXg.js";import{n as se,r as ce,t as q}from"./model-channel-mQ6lfvSO.js";var J=e(t(),1),Y=class extends Error{constructor(e,t){super(t?`第 ${t} 行:${e}`:e),this.name=`YamlError`,this.line=t||0}},le=/^(?:[-?:,\[\]{}#&*!|>'"%@`]|.*[:\s]$|.*\s#|.*[\n\r\t])/,ue=/^(?:true|false|null|~|yes|no|on|off|[-+]?(?:\d+|\d*\.\d+)(?:[eE][-+]?\d+)?)$/i;function de(e){let t=String(e);return!(t===``||ue.test(t)||/^[-+]?(?:\d+\.\d*|\.\d+|\d+)(?:[eE][-+]?\d+)?$/.test(t)||le.test(t)||/^(?:\s)|:(?:\s|$)|[\r\n\t]/.test(t)||/[,[\]{}]/.test(t)||/^[!&*|>@`]/.test(t))}function fe(e){return JSON.stringify(String(e))}function pe(e){let t=String(e);return de(t)?t:fe(t)}function me(e){if(e==null)return`null`;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return Number.isFinite(e)?String(e):fe(String(e));let t=String(e);return de(t)?t:fe(t)}function he(e){return e==null||[`string`,`number`,`boolean`].includes(typeof e)}function ge(e,t,n,r){let i=` `.repeat(n),a=pe(e);if(he(t))r.push(`${i}${a}: ${me(t)}`);else if(Array.isArray(t)){if(!t.length){r.push(`${i}${a}: []`);return}r.push(`${i}${a}:`),ye(t,n+2,r)}else Object.entries(t).length?(r.push(`${i}${a}:`),_e(t,n+2,r)):r.push(`${i}${a}: {}`)}function _e(e,t,n){for(let[r,i]of Object.entries(e))ge(r,i,t,n)}function ve(e,t,n){let r=` `.repeat(t);if(he(e)){n.push(`${r}- ${me(e)}`);return}if(Array.isArray(e)){if(!e.length){n.push(`${r}- []`);return}n.push(`${r}-`),ye(e,t+2,n);return}let i=Object.entries(e);if(!i.length){n.push(`${r}- {}`);return}let[a,o]=i[0],s=i.slice(1);he(o)?n.push(`${r}- ${pe(a)}: ${me(o)}`):(n.push(`${r}-`),ge(a,o,t+2,n));for(let[e,r]of s)ge(e,r,t+2,n)}function ye(e,t,n){for(let r of e)ve(r,t,n)}function be(e,{header:t}={}){let n=[];if(t){for(let e of String(t).replace(/\r\n?/g,`
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,_ as n,t as r,y as i}from"./react-QV7DAAIx.js";import{$t as a,A as o,F as s,H as c,I as l,L as u,M as d,O as f,W as p,Z as m,c as h,f as g,h as _,kt as v,m as y,ot as b,p as x,s as S,st as ee,u as C,v as w,x as T,z as E}from"./semi-CHxO7u8f.js";import{A as te,D,E as O,F as ne,I as k,L as A,M as j,N as M,P as N,R as P,S as F,T as I,_ as re,a as L,b as R,d as z,j as ie,l as B,m as V,n as H,o as U,p as W,s as G,u as K,x as ae,y as oe}from"./index-BLFHsWWk.js";import{n as se,r as ce,t as q}from"./model-channel-mQ6lfvSO.js";var J=e(t(),1),Y=class extends Error{constructor(e,t){super(t?`第 ${t} 行:${e}`:e),this.name=`YamlError`,this.line=t||0}},le=/^(?:[-?:,\[\]{}#&*!|>'"%@`]|.*[:\s]$|.*\s#|.*[\n\r\t])/,ue=/^(?:true|false|null|~|yes|no|on|off|[-+]?(?:\d+|\d*\.\d+)(?:[eE][-+]?\d+)?)$/i;function de(e){let t=String(e);return!(t===``||ue.test(t)||/^[-+]?(?:\d+\.\d*|\.\d+|\d+)(?:[eE][-+]?\d+)?$/.test(t)||le.test(t)||/^(?:\s)|:(?:\s|$)|[\r\n\t]/.test(t)||/[,[\]{}]/.test(t)||/^[!&*|>@`]/.test(t))}function fe(e){return JSON.stringify(String(e))}function pe(e){let t=String(e);return de(t)?t:fe(t)}function me(e){if(e==null)return`null`;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return Number.isFinite(e)?String(e):fe(String(e));let t=String(e);return de(t)?t:fe(t)}function he(e){return e==null||[`string`,`number`,`boolean`].includes(typeof e)}function ge(e,t,n,r){let i=` `.repeat(n),a=pe(e);if(he(t))r.push(`${i}${a}: ${me(t)}`);else if(Array.isArray(t)){if(!t.length){r.push(`${i}${a}: []`);return}r.push(`${i}${a}:`),ye(t,n+2,r)}else Object.entries(t).length?(r.push(`${i}${a}:`),_e(t,n+2,r)):r.push(`${i}${a}: {}`)}function _e(e,t,n){for(let[r,i]of Object.entries(e))ge(r,i,t,n)}function ve(e,t,n){let r=` `.repeat(t);if(he(e)){n.push(`${r}- ${me(e)}`);return}if(Array.isArray(e)){if(!e.length){n.push(`${r}- []`);return}n.push(`${r}-`),ye(e,t+2,n);return}let i=Object.entries(e);if(!i.length){n.push(`${r}- {}`);return}let[a,o]=i[0],s=i.slice(1);he(o)?n.push(`${r}- ${pe(a)}: ${me(o)}`):(n.push(`${r}-`),ge(a,o,t+2,n));for(let[e,r]of s)ge(e,r,t+2,n)}function ye(e,t,n){for(let r of e)ve(r,t,n)}function be(e,{header:t}={}){let n=[];if(t){for(let e of String(t).replace(/\r\n?/g,`
`).split(`
`))n.push(`# ${e}`.trimEnd());n.length&&n.push(``)}return he(e)?(n.push(me(e)),`${n.join(`
`)}\n`):Array.isArray(e)?(e.length?ye(e,0,n):n.push(`[]`),`${n.join(`
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,S as o,W as s,i as c,jt as l,lt as u,ot as d,st as f,x as p}from"./semi-CHxO7u8f.js";import{E as m,F as h,I as g,P as _,T as v,a as y,b,c as x,d as S,f as C,l as w,m as T,n as E,p as D,s as O,x as k,y as A}from"./index-CuUcClXg.js";var j=e(t(),1),M=e(n(),1),{Text:N}=s;function P(){let e=_(),{hasPermission:t}=h(),n=t(`skills:write`),o=t(`skills:delete`),[s,p]=(0,j.useState)(``),S=E(s,300),[C,P]=(0,j.useState)(1),[I,L]=(0,j.useState)(20),[R,z]=(0,j.useState)(null),[B,V]=(0,j.useState)(null),[H,U]=(0,j.useState)(!1),W=y(()=>g.get(`/skills`,{search:S||void 0,limit:I,offset:(C-1)*I}),[S,C,I]),G=Array.isArray(W.data?.skills)?W.data.skills:[],K=Number(W.data?.total||0),q=async()=>{if(H||!B?.form)return;let e=await B.form.validate().catch(()=>null);if(e){U(!0);try{await g.post(`/skills`,{name:e.name.trim(),description:e.description.trim(),content:e.content}),k(`技能已创建`),V(null),W.reload()}catch(e){b(e,`创建技能失败`)}finally{U(!1)}}},J=e=>A({title:`删除技能「${e.name}」?`,content:`该技能目录及其全部文件会被移除。`,onOk:async()=>{await g.del(`/skills/${encodeURIComponent(e.id||e.name)}`),k(`已删除`),W.reload()}});return(0,M.jsxs)(`div`,{children:[(0,M.jsx)(D,{title:e(`skills.managementTitle`,null,`技能管理`),description:`技能以目录形式存放在技能根目录,SKILL.md 描述触发条件与用法。`,extra:(0,M.jsxs)(r,{children:[(0,M.jsx)(a,{icon:(0,M.jsx)(f,{}),onClick:()=>W.reload(),loading:W.loading,children:`刷新`}),n&&(0,M.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,M.jsx)(u,{}),onClick:()=>V({form:{}}),children:`新建技能`})]})}),(0,M.jsxs)(T,{title:`技能(${K})`,children:[(0,M.jsx)(w,{error:W.error,onRetry:()=>W.reload()}),(0,M.jsx)(O,{columns:[{title:`技能`,dataIndex:`name`,render:(e,t)=>(0,M.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,M.jsx)(N,{strong:!0,children:e||t.id}),(0,M.jsx)(N,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:420},children:t.description})]})},{title:`版本`,dataIndex:`version`,width:100,render:e=>e||`—`},{title:`文件`,dataIndex:`file_count`,width:80,render:e=>String(e??`—`)},{title:`大小`,dataIndex:`file_size`,width:100,render:e=>v(e)},{title:`更新时间`,dataIndex:`mod_time`,width:170,render:e=>e?m(e):`—`},{title:`操作`,width:140,render:(e,t)=>(0,M.jsxs)(r,{children:[(0,M.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>z(t),children:`详情`}),o&&(0,M.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,M.jsx)(l,{}),onClick:()=>J(t)})]})}],dataSource:G,rowKey:e=>e.id||e.name,loading:W.loading,pagination:{currentPage:C,pageSize:I,total:K,onPageChange:P,onPageSizeChange:e=>{L(e),P(1)}},toolbar:(0,M.jsx)(i,{prefix:(0,M.jsx)(d,{}),value:s,onChange:e=>{p(e),P(1)},placeholder:`搜索技能名称或描述`,style:{width:280}})})]}),(0,M.jsx)(x,{title:`新建技能`,visible:!!B,onCancel:()=>V(null),onOk:q,confirmLoading:H,width:720,children:(0,M.jsxs)(c,{getFormApi:e=>V(t=>t&&{...t,form:e}),children:[(0,M.jsx)(c.Input,{field:`name`,label:`目录名`,placeholder:`小写字母、数字、连字符`,rules:[{required:!0,message:`请输入目录名`},{pattern:/^[a-z0-9-]+$/,message:`只允许小写字母、数字与连字符`}]}),(0,M.jsx)(c.Input,{field:`description`,label:`描述`,rules:[{required:!0,message:`请输入描述`}]}),(0,M.jsx)(c.TextArea,{field:`content`,label:`SKILL.md 正文`,rules:[{required:!0,message:`请输入正文`}],autosize:{minRows:10,maxRows:24}})]})},`new-skill`),(0,M.jsx)(F,{skill:R,onClose:()=>z(null),canWrite:n})]})}function F({skill:e,onClose:t,canWrite:n}){let[i,s]=(0,j.useState)([]),[c,l]=(0,j.useState)(``),[u,d]=(0,j.useState)(``),[f,m]=(0,j.useState)(!1),[h,_]=(0,j.useState)(!1);(0,j.useEffect)(()=>{e&&(s([]),l(``),d(``),g.get(`/skills/${encodeURIComponent(e.id||e.name)}/files`).then(e=>s(Array.isArray(e?.files)?e.files:[])).catch(()=>s([])))},[e]);let v=async t=>{m(!0);try{let n=await g.get(`/skills/${encodeURIComponent(e.id||e.name)}/file`,{path:t});l(t),d(n?.content||``)}catch(e){b(e,`读取文件失败`)}finally{m(!1)}},y=async()=>{_(!0);try{await g.put(`/skills/${encodeURIComponent(e.id||e.name)}/file`,{path:c,content:u}),k(`文件已保存`)}catch(e){b(e,`保存文件失败`)}finally{_(!1)}},w=i.map(e=>typeof e==`string`?e:e.path||e.name);return(0,M.jsx)(x,{title:e?.name||`技能详情`,visible:!!e,onCancel:t,width:860,children:e&&(0,M.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,M.jsx)(S,{items:[{label:`目录名`,value:e.id||e.dir_name},{label:`版本`,value:e.version||`—`},{label:`路径`,value:e.path},{label:`文件数`,value:e.file_count},{label:`触发词`,value:Array.isArray(e.triggers)?e.triggers.join(`、`):`—`},{label:`标签`,value:Array.isArray(e.tags)?e.tags.join(`、`):`—`}]}),(0,M.jsx)(N,{type:`tertiary`,children:e.description}),(0,M.jsxs)(`div`,{style:{displLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,S as o,W as s,i as c,jt as l,lt as u,ot as d,st as f,x as p}from"./semi-CHxO7u8f.js";import{E as m,F as h,I as g,P as _,T as v,a as y,b,c as x,d as S,f as C,l as w,m as T,n as E,p as D,s as O,x as k,y as A}from"./index-BLFHsWWk.js";var j=e(t(),1),M=e(n(),1),{Text:N}=s;function P(){let e=_(),{hasPermission:t}=h(),n=t(`skills:write`),o=t(`skills:delete`),[s,p]=(0,j.useState)(``),S=E(s,300),[C,P]=(0,j.useState)(1),[I,L]=(0,j.useState)(20),[R,z]=(0,j.useState)(null),[B,V]=(0,j.useState)(null),[H,U]=(0,j.useState)(!1),W=y(()=>g.get(`/skills`,{search:S||void 0,limit:I,offset:(C-1)*I}),[S,C,I]),G=Array.isArray(W.data?.skills)?W.data.skills:[],K=Number(W.data?.total||0),q=async()=>{if(H||!B?.form)return;let e=await B.form.validate().catch(()=>null);if(e){U(!0);try{await g.post(`/skills`,{name:e.name.trim(),description:e.description.trim(),content:e.content}),k(`技能已创建`),V(null),W.reload()}catch(e){b(e,`创建技能失败`)}finally{U(!1)}}},J=e=>A({title:`删除技能「${e.name}」?`,content:`该技能目录及其全部文件会被移除。`,onOk:async()=>{await g.del(`/skills/${encodeURIComponent(e.id||e.name)}`),k(`已删除`),W.reload()}});return(0,M.jsxs)(`div`,{children:[(0,M.jsx)(D,{title:e(`skills.managementTitle`,null,`技能管理`),description:`技能以目录形式存放在技能根目录,SKILL.md 描述触发条件与用法。`,extra:(0,M.jsxs)(r,{children:[(0,M.jsx)(a,{icon:(0,M.jsx)(f,{}),onClick:()=>W.reload(),loading:W.loading,children:`刷新`}),n&&(0,M.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,M.jsx)(u,{}),onClick:()=>V({form:{}}),children:`新建技能`})]})}),(0,M.jsxs)(T,{title:`技能(${K})`,children:[(0,M.jsx)(w,{error:W.error,onRetry:()=>W.reload()}),(0,M.jsx)(O,{columns:[{title:`技能`,dataIndex:`name`,render:(e,t)=>(0,M.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,M.jsx)(N,{strong:!0,children:e||t.id}),(0,M.jsx)(N,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:420},children:t.description})]})},{title:`版本`,dataIndex:`version`,width:100,render:e=>e||`—`},{title:`文件`,dataIndex:`file_count`,width:80,render:e=>String(e??`—`)},{title:`大小`,dataIndex:`file_size`,width:100,render:e=>v(e)},{title:`更新时间`,dataIndex:`mod_time`,width:170,render:e=>e?m(e):`—`},{title:`操作`,width:140,render:(e,t)=>(0,M.jsxs)(r,{children:[(0,M.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>z(t),children:`详情`}),o&&(0,M.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,M.jsx)(l,{}),onClick:()=>J(t)})]})}],dataSource:G,rowKey:e=>e.id||e.name,loading:W.loading,pagination:{currentPage:C,pageSize:I,total:K,onPageChange:P,onPageSizeChange:e=>{L(e),P(1)}},toolbar:(0,M.jsx)(i,{prefix:(0,M.jsx)(d,{}),value:s,onChange:e=>{p(e),P(1)},placeholder:`搜索技能名称或描述`,style:{width:280}})})]}),(0,M.jsx)(x,{title:`新建技能`,visible:!!B,onCancel:()=>V(null),onOk:q,confirmLoading:H,width:720,children:(0,M.jsxs)(c,{getFormApi:e=>V(t=>t&&{...t,form:e}),children:[(0,M.jsx)(c.Input,{field:`name`,label:`目录名`,placeholder:`小写字母、数字、连字符`,rules:[{required:!0,message:`请输入目录名`},{pattern:/^[a-z0-9-]+$/,message:`只允许小写字母、数字与连字符`}]}),(0,M.jsx)(c.Input,{field:`description`,label:`描述`,rules:[{required:!0,message:`请输入描述`}]}),(0,M.jsx)(c.TextArea,{field:`content`,label:`SKILL.md 正文`,rules:[{required:!0,message:`请输入正文`}],autosize:{minRows:10,maxRows:24}})]})},`new-skill`),(0,M.jsx)(F,{skill:R,onClose:()=>z(null),canWrite:n})]})}function F({skill:e,onClose:t,canWrite:n}){let[i,s]=(0,j.useState)([]),[c,l]=(0,j.useState)(``),[u,d]=(0,j.useState)(``),[f,m]=(0,j.useState)(!1),[h,_]=(0,j.useState)(!1);(0,j.useEffect)(()=>{e&&(s([]),l(``),d(``),g.get(`/skills/${encodeURIComponent(e.id||e.name)}/files`).then(e=>s(Array.isArray(e?.files)?e.files:[])).catch(()=>s([])))},[e]);let v=async t=>{m(!0);try{let n=await g.get(`/skills/${encodeURIComponent(e.id||e.name)}/file`,{path:t});l(t),d(n?.content||``)}catch(e){b(e,`读取文件失败`)}finally{m(!1)}},y=async()=>{_(!0);try{await g.put(`/skills/${encodeURIComponent(e.id||e.name)}/file`,{path:c,content:u}),k(`文件已保存`)}catch(e){b(e,`保存文件失败`)}finally{_(!1)}},w=i.map(e=>typeof e==`string`?e:e.path||e.name);return(0,M.jsx)(x,{title:e?.name||`技能详情`,visible:!!e,onCancel:t,width:860,children:e&&(0,M.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,M.jsx)(S,{items:[{label:`目录名`,value:e.id||e.dir_name},{label:`版本`,value:e.version||`—`},{label:`路径`,value:e.path},{label:`文件数`,value:e.file_count},{label:`触发词`,value:Array.isArray(e.triggers)?e.triggers.join(`、`):`—`},{label:`标签`,value:Array.isArray(e.tags)?e.tags.join(`、`):`—`}]}),(0,M.jsx)(N,{type:`tertiary`,children:e.description}),(0,M.jsxs)(`div`,{style:{displLine truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{F as t,L as n,W as r,jt as i,st as a}from"./semi-CHxO7u8f.js";import{D as o,F as s,I as c,O as l,P as u,_ as d,a as f,l as p,m,p as h,s as g,x as _,y as v}from"./index-CuUcClXg.js";import{t as y}from"./react-QV7DAAIx.js";var b=e(y(),1),{Text:x}=r;function S(){let e=u(),{hasPermission:r}=s(),y=r(`skills:delete`),S=f(()=>c.get(`/skills/stats`),[]),C=Array.isArray(S.data?.stats)?S.data.stats:[],w=Number(S.data?.total_calls||0),T=Number(S.data?.total_success||0),E=w>0?T/w:null,D=()=>v({title:`清空所有技能调用统计?`,content:`只影响统计计数,不删除技能文件。`,onOk:async()=>{await c.del(`/skills/stats`),_(`统计已清空`),S.reload()}}),O=e=>v({title:`清空「${e}」的统计?`,onOk:async()=>{await c.del(`/skills/${encodeURIComponent(e)}/stats`),_(`已清空`),S.reload()}});return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(h,{title:e(`skills.monitorTitle`,null,`技能状态`),description:S.data?.skills_dir?`技能目录:${S.data.skills_dir}`:`统计技能被调用的次数、成功率与最近使用时间。`,extra:(0,b.jsxs)(t,{children:[(0,b.jsx)(n,{icon:(0,b.jsx)(a,{}),onClick:()=>S.reload(),loading:S.loading,children:`刷新`}),y&&(0,b.jsx)(n,{type:`danger`,theme:`light`,onClick:D,children:`清空全部统计`})]})}),(0,b.jsx)(d,{columns:4,metrics:[{id:`skills`,label:`技能总数`,value:o(S.data?.total_skills||0),loading:S.loading},{id:`calls`,label:`调用总数`,value:o(w),loading:S.loading},{id:`success`,label:`成功次数`,value:o(T),loading:S.loading},{id:`rate`,label:`成功率`,value:E===null?`—`:l(E),tone:E!==null&&E<.8?`warning`:`success`,loading:S.loading}]}),(0,b.jsxs)(m,{title:`按技能统计`,children:[(0,b.jsx)(p,{error:S.error,onRetry:()=>S.reload()}),(0,b.jsx)(g,{columns:[{title:`技能`,dataIndex:`skill_name`,render:e=>(0,b.jsx)(x,{strong:!0,children:e})},{title:`调用次数`,dataIndex:`total_calls`,width:120,render:e=>o(e||0)},{title:`成功`,dataIndex:`success_calls`,width:100,render:e=>o(e||0)},{title:`失败`,dataIndex:`failed_calls`,width:100,render:e=>Number(e)>0?(0,b.jsx)(x,{type:`danger`,children:o(e)}):`0`},{title:`最后调用`,dataIndex:`last_call_time`,width:180,render:e=>e||`—`},{title:`操作`,width:110,render:(e,t)=>y&&Number(t.total_calls)>0?(0,b.jsx)(n,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,b.jsx)(i,{}),onClick:()=>O(t.skill_name),children:`清空`}):null}],dataSource:C,rowKey:`skill_name`,loading:S.loading,pagination:{pageSize:20}})]})]})}export{S as default};
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{F as t,L as n,W as r,jt as i,st as a}from"./semi-CHxO7u8f.js";import{D as o,F as s,I as c,O as l,P as u,_ as d,a as f,l as p,m,p as h,s as g,x as _,y as v}from"./index-BLFHsWWk.js";import{t as y}from"./react-QV7DAAIx.js";var b=e(y(),1),{Text:x}=r;function S(){let e=u(),{hasPermission:r}=s(),y=r(`skills:delete`),S=f(()=>c.get(`/skills/stats`),[]),C=Array.isArray(S.data?.stats)?S.data.stats:[],w=Number(S.data?.total_calls||0),T=Number(S.data?.total_success||0),E=w>0?T/w:null,D=()=>v({title:`清空所有技能调用统计?`,content:`只影响统计计数,不删除技能文件。`,onOk:async()=>{await c.del(`/skills/stats`),_(`统计已清空`),S.reload()}}),O=e=>v({title:`清空「${e}」的统计?`,onOk:async()=>{await c.del(`/skills/${encodeURIComponent(e)}/stats`),_(`已清空`),S.reload()}});return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(h,{title:e(`skills.monitorTitle`,null,`技能状态`),description:S.data?.skills_dir?`技能目录:${S.data.skills_dir}`:`统计技能被调用的次数、成功率与最近使用时间。`,extra:(0,b.jsxs)(t,{children:[(0,b.jsx)(n,{icon:(0,b.jsx)(a,{}),onClick:()=>S.reload(),loading:S.loading,children:`刷新`}),y&&(0,b.jsx)(n,{type:`danger`,theme:`light`,onClick:D,children:`清空全部统计`})]})}),(0,b.jsx)(d,{columns:4,metrics:[{id:`skills`,label:`技能总数`,value:o(S.data?.total_skills||0),loading:S.loading},{id:`calls`,label:`调用总数`,value:o(w),loading:S.loading},{id:`success`,label:`成功次数`,value:o(T),loading:S.loading},{id:`rate`,label:`成功率`,value:E===null?`—`:l(E),tone:E!==null&&E<.8?`warning`:`success`,loading:S.loading}]}),(0,b.jsxs)(m,{title:`按技能统计`,children:[(0,b.jsx)(p,{error:S.error,onRetry:()=>S.reload()}),(0,b.jsx)(g,{columns:[{title:`技能`,dataIndex:`skill_name`,render:e=>(0,b.jsx)(x,{strong:!0,children:e})},{title:`调用次数`,dataIndex:`total_calls`,width:120,render:e=>o(e||0)},{title:`成功`,dataIndex:`success_calls`,width:100,render:e=>o(e||0)},{title:`失败`,dataIndex:`failed_calls`,width:100,render:e=>Number(e)>0?(0,b.jsx)(x,{type:`danger`,children:o(e)}):`0`},{title:`最后调用`,dataIndex:`last_call_time`,width:180,render:e=>e||`—`},{title:`操作`,width:110,render:(e,t)=>y&&Number(t.total_calls)>0?(0,b.jsx)(n,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,b.jsx)(i,{}),onClick:()=>O(t.skill_name),children:`清空`}):null}],dataSource:C,rowKey:`skill_name`,loading:S.loading,pagination:{pageSize:20}})]})]})}export{S as default};
@@ -1,2 +1,2 @@
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{F as a,H as o,L as s,M as c,N as l,W as u,c as ee,f as d,h as f,lt as p,ot as te,st as m,v as h,x as g}from"./semi-CHxO7u8f.js";import{E as _,F as v,I as y,P as b,_ as x,a as S,b as C,c as w,d as T,f as E,l as ne,m as D,n as O,p as k,r as re,s as ie,x as A,y as j}from"./index-CuUcClXg.js";var M=e(t(),1),N={pending:{label:`待执行`,color:`amber`},running:{label:`执行中`,color:`blue`},paused:{label:`已暂停`,color:`grey`},completed:{label:`已完成`,color:`green`},cancelled:{label:`已取消`,color:`grey`}},P={pending:{label:`待执行`,color:`amber`},running:{label:`执行中`,color:`blue`},completed:{label:`已完成`,color:`green`},failed:{label:`失败`,color:`red`},cancelled:{label:`已取消`,color:`grey`},blocked:{label:`受阻`,color:`orange`}},F=[{value:`single`,label:`单代理(Pi SDK)`},{value:`deep`,label:`Deep(DeepAgent)`},{value:`plan_execute`,label:`Plan-Execute`},{value:`supervisor`,label:`Supervisor(专家路由)`}],I=[{value:``,label:`沿用全局设置`},{value:`off`,label:`关闭审批`},{value:`human`,label:`人工审批`},{value:`audit_agent`,label:`Agent 审批`},{value:`review_edit`,label:`Agent 审查编辑`}],L=[{value:`manual`,label:`手工执行`},{value:`cron`,label:`Cron 调度`}],ae=[{value:`all`,label:`全部状态`},{value:`pending`,label:`待执行`},{value:`running`,label:`执行中`},{value:`paused`,label:`已暂停`},{value:`completed`,label:`已完成`},{value:`cancelled`,label:`已取消`}];function R(e){let t=Array.isArray(e?.tasks)?e.tasks:[],n=t.length,r=t.filter(e=>e.status===`completed`).length,i=t.filter(e=>e.status===`failed`).length,a=t.filter(e=>e.status===`cancelled`).length,o=t.filter(e=>e.status===`blocked`).length,s=t.filter(e=>e.status===`running`).length,c=t.filter(e=>e.status===`pending`).length,l=r+i+a+o;return{total:n,completed:r,failed:i,cancelled:a,blocked:o,running:s,pending:c,done:l,percent:n?Math.round(l/n*100):0}}function oe(e){return(F.find(t=>t.value===String(e||`single`))||F[0]).label}function se(e){let t=N[String(e?.status||``)]||{label:e?.status||`—`,color:`grey`},n=e?.scheduleMode===`cron`&&e?.scheduleEnabled!==!1,r=e?.nextRunAt?new Date(e.nextRunAt):null,i=r&&Number.isFinite(r.getTime())?r.toLocaleString(`zh-CN`,{hour12:!1}):``,a=R(e),o=a.blocked>0?e?.lastRunError||`${a.blocked} 项受阻`:``;if(a.blocked>0&&a.completed===0&&a.failed===0)return{...t,label:`受阻(${a.blocked} 项)`,color:`orange`,sublabel:o};if(n&&e?.status===`completed`){let e=a.failed>0||a.blocked>0;return{...t,label:e?`本轮已结束 · 定时循环中`:`本轮已完成 · 定时循环中`,color:a.failed>0?`red`:a.blocked>0?`orange`:t.color,sublabel:o||(i?`下次执行:${i}`:``),note:`定时队列:子任务已跑完,到点将自动下一轮`}}if(n&&e?.status===`pending`&&i)return{...t,sublabel:`Cron 已排程 · 下次 ${i}`};if(e?.status===`completed`&&a.failed>0){let e=a.blocked>0?`,${a.blocked} 项受阻`:``;return{...t,label:`已结束(${a.failed} 项失败${e})`,color:`red`,sublabel:o}}return e?.status===`completed`&&a.blocked>0?{...t,label:`已结束(${a.blocked} 项受阻)`,color:`orange`,sublabel:o}:{...t,sublabel:``}}function z(e,t){if(!e)return`—`;let n=new Date(e).getTime(),r=t?new Date(t).getTime():Date.now();if(!Number.isFinite(n)||!Number.isFinite(r)||r<n)return`—`;let i=Math.round((r-n)/1e3);return i<60?`${i} 秒`:i<3600?`${Math.floor(i/60)} 分 ${i%60} 秒`:`${Math.floor(i/3600)} 小时 ${Math.floor(i%3600/60)} 分`}function B(e,t=`操作失败`){if(!e)return t;if(typeof e==`string`)return e;let n=e.payload;if(n&&typeof n==`object`){let e=n.error;if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=typeof e.message==`string`?e.message:``,n=typeof e.code==`string`?e.code:``;if(t)return n?`${t}(${n})`:t}if(typeof n.message==`string`&&n.message)return n.message}return typeof e.message==`string`&&e.message&&e.message!==`[object Object]`?e.message:t}function ce(e,t=`加载失败`){return e?{message:B(e,t)}:null}var V=e(r(),1),{Text:H}=u,U={title:``,tasksText:``,role:``,projectId:``,agentMode:`single`,hitlPolicy:``,scheduleMode:`manual`,cronExpr:``,concurrency:1,executeNow:!1},W=/^\S+\s+\S+\s+\S+\s+\S+\s+\S+$/;function le({visible:e,onCancel:t,onCreated:n}){let r=b(),{hasPermission:i}=v(),[a,s]=(0,M.useState)(U),[c,u]=(0,M.useState)([]),[ee,d]=(0,M.useState)([]),[f,p]=(0,M.useState)(null),[te,m]=(0,M.useState)(!1);(0,M.useEffect)(()=>{if(!e)return;s(U),m(!1);let t=!1;return i(`roles:read`)&&y.get(`/roles`).then(e=>{t||u(Array.isArray(e?.roles)?e.roles:[])}).catch(()=>{t||u([])}),i(`project:read`)&&y.get(`/projects`,{limit:500}).then(e=>{t||d(Array.isArray(e?.projects)?e.projects:[])}).catch(()=>{t||d([])}),()=>{t=!0}},[e,i]),(0,M.useEffect)(()=>{if(!e||!a.projectId||!i(`asset:read`)){p(null);return}let t=!1;return y.get(`/assets`,{project_id:a.projectId,page:1,page_size:1}).then(eLine truncated
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{F as a,H as o,L as s,M as c,N as l,W as u,c as ee,f as d,h as f,lt as p,ot as te,st as m,v as h,x as g}from"./semi-CHxO7u8f.js";import{E as _,F as v,I as y,P as b,_ as x,a as S,b as C,c as w,d as T,f as E,l as ne,m as D,n as O,p as k,r as re,s as ie,x as A,y as j}from"./index-BLFHsWWk.js";var M=e(t(),1),N={pending:{label:`待执行`,color:`amber`},running:{label:`执行中`,color:`blue`},paused:{label:`已暂停`,color:`grey`},completed:{label:`已完成`,color:`green`},cancelled:{label:`已取消`,color:`grey`}},P={pending:{label:`待执行`,color:`amber`},running:{label:`执行中`,color:`blue`},completed:{label:`已完成`,color:`green`},failed:{label:`失败`,color:`red`},cancelled:{label:`已取消`,color:`grey`},blocked:{label:`受阻`,color:`orange`}},F=[{value:`single`,label:`单代理(Pi SDK)`},{value:`deep`,label:`Deep(DeepAgent)`},{value:`plan_execute`,label:`Plan-Execute`},{value:`supervisor`,label:`Supervisor(专家路由)`}],I=[{value:``,label:`沿用全局设置`},{value:`off`,label:`关闭审批`},{value:`human`,label:`人工审批`},{value:`audit_agent`,label:`Agent 审批`},{value:`review_edit`,label:`Agent 审查编辑`}],L=[{value:`manual`,label:`手工执行`},{value:`cron`,label:`Cron 调度`}],ae=[{value:`all`,label:`全部状态`},{value:`pending`,label:`待执行`},{value:`running`,label:`执行中`},{value:`paused`,label:`已暂停`},{value:`completed`,label:`已完成`},{value:`cancelled`,label:`已取消`}];function R(e){let t=Array.isArray(e?.tasks)?e.tasks:[],n=t.length,r=t.filter(e=>e.status===`completed`).length,i=t.filter(e=>e.status===`failed`).length,a=t.filter(e=>e.status===`cancelled`).length,o=t.filter(e=>e.status===`blocked`).length,s=t.filter(e=>e.status===`running`).length,c=t.filter(e=>e.status===`pending`).length,l=r+i+a+o;return{total:n,completed:r,failed:i,cancelled:a,blocked:o,running:s,pending:c,done:l,percent:n?Math.round(l/n*100):0}}function oe(e){return(F.find(t=>t.value===String(e||`single`))||F[0]).label}function se(e){let t=N[String(e?.status||``)]||{label:e?.status||`—`,color:`grey`},n=e?.scheduleMode===`cron`&&e?.scheduleEnabled!==!1,r=e?.nextRunAt?new Date(e.nextRunAt):null,i=r&&Number.isFinite(r.getTime())?r.toLocaleString(`zh-CN`,{hour12:!1}):``,a=R(e),o=a.blocked>0?e?.lastRunError||`${a.blocked} 项受阻`:``;if(a.blocked>0&&a.completed===0&&a.failed===0)return{...t,label:`受阻(${a.blocked} 项)`,color:`orange`,sublabel:o};if(n&&e?.status===`completed`){let e=a.failed>0||a.blocked>0;return{...t,label:e?`本轮已结束 · 定时循环中`:`本轮已完成 · 定时循环中`,color:a.failed>0?`red`:a.blocked>0?`orange`:t.color,sublabel:o||(i?`下次执行:${i}`:``),note:`定时队列:子任务已跑完,到点将自动下一轮`}}if(n&&e?.status===`pending`&&i)return{...t,sublabel:`Cron 已排程 · 下次 ${i}`};if(e?.status===`completed`&&a.failed>0){let e=a.blocked>0?`,${a.blocked} 项受阻`:``;return{...t,label:`已结束(${a.failed} 项失败${e})`,color:`red`,sublabel:o}}return e?.status===`completed`&&a.blocked>0?{...t,label:`已结束(${a.blocked} 项受阻)`,color:`orange`,sublabel:o}:{...t,sublabel:``}}function z(e,t){if(!e)return`—`;let n=new Date(e).getTime(),r=t?new Date(t).getTime():Date.now();if(!Number.isFinite(n)||!Number.isFinite(r)||r<n)return`—`;let i=Math.round((r-n)/1e3);return i<60?`${i} 秒`:i<3600?`${Math.floor(i/60)} 分 ${i%60} 秒`:`${Math.floor(i/3600)} 小时 ${Math.floor(i%3600/60)} 分`}function B(e,t=`操作失败`){if(!e)return t;if(typeof e==`string`)return e;let n=e.payload;if(n&&typeof n==`object`){let e=n.error;if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=typeof e.message==`string`?e.message:``,n=typeof e.code==`string`?e.code:``;if(t)return n?`${t}(${n})`:t}if(typeof n.message==`string`&&n.message)return n.message}return typeof e.message==`string`&&e.message&&e.message!==`[object Object]`?e.message:t}function ce(e,t=`加载失败`){return e?{message:B(e,t)}:null}var V=e(r(),1),{Text:H}=u,U={title:``,tasksText:``,role:``,projectId:``,agentMode:`single`,hitlPolicy:``,scheduleMode:`manual`,cronExpr:``,concurrency:1,executeNow:!1},W=/^\S+\s+\S+\s+\S+\s+\S+\s+\S+$/;function le({visible:e,onCancel:t,onCreated:n}){let r=b(),{hasPermission:i}=v(),[a,s]=(0,M.useState)(U),[c,u]=(0,M.useState)([]),[ee,d]=(0,M.useState)([]),[f,p]=(0,M.useState)(null),[te,m]=(0,M.useState)(!1);(0,M.useEffect)(()=>{if(!e)return;s(U),m(!1);let t=!1;return i(`roles:read`)&&y.get(`/roles`).then(e=>{t||u(Array.isArray(e?.roles)?e.roles:[])}).catch(()=>{t||u([])}),i(`project:read`)&&y.get(`/projects`,{limit:500}).then(e=>{t||d(Array.isArray(e?.projects)?e.projects:[])}).catch(()=>{t||d([])}),()=>{t=!0}},[e,i]),(0,M.useEffect)(()=>{if(!e||!a.projectId||!i(`asset:read`)){p(null);return}let t=!1;return y.get(`/assets`,{project_id:a.projectId,page:1,page_size:1}).then(eLine truncated
`).map(e=>e.trim()).filter(Boolean);if(!e.length){C(r(`tasks.noValidTask`,null,`没有有效的任务`));return}if(a.scheduleMode===`cron`){if(!a.cronExpr.trim()){C(r(`batchImportModal.cronExprRequired`,null,`请选择 Cron 调度后填写 Cron 表达式`));return}if(!W.test(a.cronExpr.trim())){C(r(`batchImportModal.cronExprInvalid`,null,`Cron 表达式格式错误,需要 5 段(分 时 日 月 周)`));return}}let t=Number(a.concurrency);(!Number.isFinite(t)||t<1)&&(t=1),t>8&&(t=8),m(!0);try{let i=await y.post(`/batch-tasks`,{title:a.title.trim(),tasks:e,role:a.role||``,projectId:a.projectId||``,agentMode:a.agentMode||`single`,hitlPolicy:a.hitlPolicy||``,scheduleMode:a.scheduleMode===`cron`?`cron`:`manual`,cronExpr:a.scheduleMode===`cron`?a.cronExpr.trim():``,concurrency:t,executeNow:!!a.executeNow});A(r(`tasks.batchQueueTitle`,null,`批量任务队列`)),n?.(i)}catch(e){C(B(e,r(`tasks.createBatchQueueFailed`,null,`创建批量任务队列失败`)))}finally{m(!1)}},okText:r(`batchImportModal.createQueue`,null,`创建队列`),cancelText:r(`common.cancel`,null,`取消`),confirmLoading:te,width:760,maskClosable:!1,children:[(0,V.jsxs)(`div`,{className:`task-form-grid`,children:[(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:r(`batchImportModal.queueTitle`,null,`任务标题`)}),(0,V.jsx)(o,{value:a.title,maxLength:200,placeholder:r(`batchImportModal.queueTitlePlaceholder`,null,`请输入任务标题(可选,用于标识和筛选)`),onChange:e=>_({title:e})})]}),(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:r(`batchImportModal.role`,null,`角色`)}),(0,V.jsx)(h,{value:a.role,style:{width:`100%`},optionList:[{value:``,label:r(`batchImportModal.defaultRole`,null,`默认`)},...c.map(e=>({value:e.name,label:e.name}))],onChange:e=>_({role:e})}),(0,V.jsx)(H,{type:`tertiary`,size:`small`,children:r(`batchImportModal.roleHint`,null,`选择一个角色,所有任务将使用该角色的配置(提示词和工具)执行。`)})]})]}),(0,V.jsxs)(`div`,{className:`task-form-grid`,children:[(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:r(`batchImportModal.project`,null,`所属项目`)}),(0,V.jsx)(h,{value:a.projectId,style:{width:`100%`},optionList:[{value:``,label:r(`batchImportModal.projectNone`,null,`(未绑定)`)},...ee.map(e=>({value:e.id,label:e.name||e.id}))],onChange:e=>_({projectId:e||``})})]}),(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:r(`batchImportModal.agentMode`,null,`代理模式`)}),(0,V.jsx)(h,{value:a.agentMode,style:{width:`100%`},optionList:F,onChange:e=>_({agentMode:e})}),(0,V.jsx)(H,{type:`tertiary`,size:`small`,children:r(`batchImportModal.agentModeHint`,null,`与对话页一致:Pi 单代理,或 Deep / Plan-Execute / Supervisor(后三种需已启用多代理)。`)})]})]}),(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:`资产范围`}),(0,V.jsx)(H,{type:`tertiary`,size:`small`,children:a.projectId?f==null?`资产库中该项目的全部资产`:`资产库中该项目的全部资产(${f})`:`选择项目后,使用资产库里该项目的资产。`})]}),(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:r(`batchImportModal.tasksList`,null,`任务列表(每行一个任务)`)}),(0,V.jsx)(g,{value:a.tasksText,rows:7,placeholder:r(`batchImportModal.tasksListPlaceholderExample`,null,`请输入任务列表,每行一个任务`),onChange:e=>_({tasksText:e})}),(0,V.jsx)(H,{type:`tertiary`,size:`small`,children:r(`batchImportModal.tasksListHint`,null,`每行输入一个任务指令,系统将按并发池执行这些任务。空行会被自动忽略。`)})]}),(0,V.jsxs)(`div`,{className:`task-form-grid`,children:[(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:r(`batchImportModal.hitlPolicy`,null,`工具审批`)}),(0,V.jsx)(h,{value:a.hitlPolicy,style:{width:`100%`},optionList:I,onChange:e=>_({hitlPolicy:e})})]}),(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:r(`batchImportModal.concurrency`,null,`并发数`)}),(0,V.jsx)(o,{type:`number`,min:1,max:8,value:String(a.concurrency),onChange:e=>_({concurrency:e})}),(0,V.jsx)(H,{type:`tertiary`,size:`small`,children:r(`batchImportModal.concurrencyHint`,null,`同时执行的子任务数量(1-8)。默认 1 为串行;含扫描类工具时建议 1-2。`)})]})]}),(0,V.jsxs)(`div`,{className:`task-form-grid`,children:[(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:r(`batchImportModal.scheduleMode`,null,`调度方式`)}),(0,V.jsx)(h,{value:a.scheduleMode,style:{width:`100%`},optionList:L,onChange:e=>_({scheduleMode:e})})]}),(0,V.jsxs)(`div`,{className:`task-fLine truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{A as r,F as i,H as a,Jt as o,L as s,M as c,W as l,Xt as u,Z as d,jt as f,lt as p,st as m,u as h,x as g,z as _}from"./semi-CHxO7u8f.js";import{F as v,I as y,P as b,b as x,l as S,m as C,p as w,x as T,y as E}from"./index-CuUcClXg.js";var D=e(t(),1),O=200,k=4096;function A(e){return JSON.parse(JSON.stringify(e))}function j(e){if(!e||typeof e.enabled!=`boolean`||e.rules!=null&&!Array.isArray(e.rules))throw Error(`服务端返回的配置格式不正确`);return{enabled:e.enabled,rules:(e.rules||[]).map(e=>({id:String(e.id||``),name:String(e.name||``),enabled:!!e.enabled,pattern:String(e.pattern||``),message:String(e.message||``)}))}}function M(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`rule-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function N(e){return new TextEncoder().encode(String(e||``)).length}function P(e){if(!e)return{index:-1,field:``,message:`请先加载拦截配置`};if(e.rules.length>100)return{index:-1,field:``,message:`最多可配置 100 条拦截规则`};for(let t=0;t<e.rules.length;t+=1){let n=e.rules[t];if(!n.name.trim())return{index:t,field:`name`,message:`第 ${t+1} 条规则缺少名称`};if(!n.pattern.trim())return{index:t,field:`pattern`,message:`第 ${t+1} 条规则缺少匹配正则`};if(N(n.name)>O)return{index:t,field:`name`,message:`第 ${t+1} 条规则名称超过 ${O} 字节`};if(N(n.pattern)>k)return{index:t,field:`pattern`,message:`第 ${t+1} 条规则正则超过 ${k} 字节`};if(N(n.message)>k)return{index:t,field:`message`,message:`第 ${t+1} 条规则提醒超过 ${k} 字节`}}return null}function F(e,t){return!e||!t?!1:JSON.stringify(e)!==JSON.stringify(t)}function I(e){return{enabled:!!e?.enabled,rules:(e?.rules||[]).map(e=>({id:e.id,name:e.name,enabled:!!e.enabled,pattern:e.pattern,message:e.message}))}}function L(e){return{enabled:!0,rules:[{id:e.id,name:e.name,enabled:!0,pattern:e.pattern,message:e.message}]}}var R=e(n(),1),{Text:z}=l,B=`http_request`,V=`{"url": "https://example.gov.cn"}`;function H({config:e,rule:t=null,disabled:n=!1,compact:r=!1}){let o=b(),l=!!t,[u,d]=(0,D.useState)(B),[f,p]=(0,D.useState)(V),[m,h]=(0,D.useState)(!1),[v,x]=(0,D.useState)(null),[C,w]=(0,D.useState)(null),T=async()=>{if(n||m)return;if(w(null),x(null),!l&&!e){w(Error(o(`toolGuard.loadFirst`,null,`请先加载拦截配置`)));return}if(!u.trim()){w(Error(o(`toolGuard.toolRequired`,null,`请填写测试工具名称`)));return}let r;try{if(r=JSON.parse(f),!r||Array.isArray(r)||typeof r!=`object`)throw Error(`not an object`)}catch{w(Error(o(`toolGuard.invalidArguments`,null,`工具参数必须是有效的 JSON 对象`)));return}h(!0);try{let n={config:l?L(t):I(e),toolName:u.trim(),arguments:r},i=await y.post(`/tool-guard/test`,n);if(!i||typeof i.blocked!=`boolean`)throw Error(o(`toolGuard.invalidTestResponse`,null,`服务端返回的测试结果格式不正确`));x(i)}catch(e){w(e)}finally{h(!1)}},E=v?.blocked,O=v?.match,k=!l&&e&&e.enabled===!1;return(0,R.jsxs)(`div`,{className:r?`tool-guard-test tool-guard-test-compact`:`tool-guard-test`,children:[(0,R.jsxs)(i,{vertical:!0,spacing:6,align:`start`,children:[(0,R.jsx)(z,{strong:!0,children:l?o(`toolGuard.testScopeSingle`,{name:t.name||o(`toolGuard.unnamedRule`,null,`未命名规则`)},`单条验证:${t.name||`未命名规则`}`):o(`toolGuard.testScopeAll`,null,`全部规则验证`)}),(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:l?o(`toolGuard.testSingleHint`,null,`仅验证本条规则,忽略总开关和规则启停;不保存、不执行工具。`):o(`toolGuard.testAllHint`,null,`按当前顺序与启停状态验证全部规则,不保存、不执行工具。`)})]}),(0,R.jsxs)(`div`,{className:`tool-guard-test-form`,children:[(0,R.jsxs)(`label`,{className:`tool-guard-field`,children:[(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:o(`toolGuard.testTool`,null,`工具名称`)}),(0,R.jsx)(a,{value:u,onChange:e=>{d(e),x(null)},placeholder:`http_request`})]}),(0,R.jsxs)(`label`,{className:`tool-guard-field tool-guard-field-wide`,children:[(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:o(`toolGuard.testArguments`,null,`工具参数(JSON 对象)`)}),(0,R.jsx)(g,{value:f,onChange:e=>{p(e),x(null)},rows:3,spellCheck:!1,className:`tool-guard-args`})]})]}),(0,R.jsx)(s,{theme:`solid`,type:`primary`,loading:m,disabled:n,onClick:T,className:`tool-guard-test-run`,children:m?o(`toolGuard.testing`,null,`验证中…`):o(`toolGuard.test`,null,`测试匹配`)}),(0,R.jsx)(S,{error:C}),v&&(0,R.jsxs)(`div`,{className:`tool-guard-test-result ${E?`is-blocked`:`is-pass`}`,children:[(0,R.jsxs)(i,{spacing:8,wrap:!0,children:[(0,R.jsx)(c,{color:E?`red`:k?`grey`:`green`,size:`small`,children:E?`blocked`:`passed`}),(0,R.jsx)(z,{strong:!0,children:l?E?o(`toolGuard.singleMatched`,null,`本条规则匹配成功`):o(`toolGuard.singleNotMatched`,null,`本条规则未匹配`):E?o(`t Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{A as r,F as i,H as a,Jt as o,L as s,M as c,W as l,Xt as u,Z as d,jt as f,lt as p,st as m,u as h,x as g,z as _}from"./semi-CHxO7u8f.js";import{F as v,I as y,P as b,b as x,l as S,m as C,p as w,x as T,y as E}from"./index-BLFHsWWk.js";var D=e(t(),1),O=200,k=4096;function A(e){return JSON.parse(JSON.stringify(e))}function j(e){if(!e||typeof e.enabled!=`boolean`||e.rules!=null&&!Array.isArray(e.rules))throw Error(`服务端返回的配置格式不正确`);return{enabled:e.enabled,rules:(e.rules||[]).map(e=>({id:String(e.id||``),name:String(e.name||``),enabled:!!e.enabled,pattern:String(e.pattern||``),message:String(e.message||``)}))}}function M(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`rule-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function N(e){return new TextEncoder().encode(String(e||``)).length}function P(e){if(!e)return{index:-1,field:``,message:`请先加载拦截配置`};if(e.rules.length>100)return{index:-1,field:``,message:`最多可配置 100 条拦截规则`};for(let t=0;t<e.rules.length;t+=1){let n=e.rules[t];if(!n.name.trim())return{index:t,field:`name`,message:`第 ${t+1} 条规则缺少名称`};if(!n.pattern.trim())return{index:t,field:`pattern`,message:`第 ${t+1} 条规则缺少匹配正则`};if(N(n.name)>O)return{index:t,field:`name`,message:`第 ${t+1} 条规则名称超过 ${O} 字节`};if(N(n.pattern)>k)return{index:t,field:`pattern`,message:`第 ${t+1} 条规则正则超过 ${k} 字节`};if(N(n.message)>k)return{index:t,field:`message`,message:`第 ${t+1} 条规则提醒超过 ${k} 字节`}}return null}function F(e,t){return!e||!t?!1:JSON.stringify(e)!==JSON.stringify(t)}function I(e){return{enabled:!!e?.enabled,rules:(e?.rules||[]).map(e=>({id:e.id,name:e.name,enabled:!!e.enabled,pattern:e.pattern,message:e.message}))}}function L(e){return{enabled:!0,rules:[{id:e.id,name:e.name,enabled:!0,pattern:e.pattern,message:e.message}]}}var R=e(n(),1),{Text:z}=l,B=`http_request`,V=`{"url": "https://example.gov.cn"}`;function H({config:e,rule:t=null,disabled:n=!1,compact:r=!1}){let o=b(),l=!!t,[u,d]=(0,D.useState)(B),[f,p]=(0,D.useState)(V),[m,h]=(0,D.useState)(!1),[v,x]=(0,D.useState)(null),[C,w]=(0,D.useState)(null),T=async()=>{if(n||m)return;if(w(null),x(null),!l&&!e){w(Error(o(`toolGuard.loadFirst`,null,`请先加载拦截配置`)));return}if(!u.trim()){w(Error(o(`toolGuard.toolRequired`,null,`请填写测试工具名称`)));return}let r;try{if(r=JSON.parse(f),!r||Array.isArray(r)||typeof r!=`object`)throw Error(`not an object`)}catch{w(Error(o(`toolGuard.invalidArguments`,null,`工具参数必须是有效的 JSON 对象`)));return}h(!0);try{let n={config:l?L(t):I(e),toolName:u.trim(),arguments:r},i=await y.post(`/tool-guard/test`,n);if(!i||typeof i.blocked!=`boolean`)throw Error(o(`toolGuard.invalidTestResponse`,null,`服务端返回的测试结果格式不正确`));x(i)}catch(e){w(e)}finally{h(!1)}},E=v?.blocked,O=v?.match,k=!l&&e&&e.enabled===!1;return(0,R.jsxs)(`div`,{className:r?`tool-guard-test tool-guard-test-compact`:`tool-guard-test`,children:[(0,R.jsxs)(i,{vertical:!0,spacing:6,align:`start`,children:[(0,R.jsx)(z,{strong:!0,children:l?o(`toolGuard.testScopeSingle`,{name:t.name||o(`toolGuard.unnamedRule`,null,`未命名规则`)},`单条验证:${t.name||`未命名规则`}`):o(`toolGuard.testScopeAll`,null,`全部规则验证`)}),(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:l?o(`toolGuard.testSingleHint`,null,`仅验证本条规则,忽略总开关和规则启停;不保存、不执行工具。`):o(`toolGuard.testAllHint`,null,`按当前顺序与启停状态验证全部规则,不保存、不执行工具。`)})]}),(0,R.jsxs)(`div`,{className:`tool-guard-test-form`,children:[(0,R.jsxs)(`label`,{className:`tool-guard-field`,children:[(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:o(`toolGuard.testTool`,null,`工具名称`)}),(0,R.jsx)(a,{value:u,onChange:e=>{d(e),x(null)},placeholder:`http_request`})]}),(0,R.jsxs)(`label`,{className:`tool-guard-field tool-guard-field-wide`,children:[(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:o(`toolGuard.testArguments`,null,`工具参数(JSON 对象)`)}),(0,R.jsx)(g,{value:f,onChange:e=>{p(e),x(null)},rows:3,spellCheck:!1,className:`tool-guard-args`})]})]}),(0,R.jsx)(s,{theme:`solid`,type:`primary`,loading:m,disabled:n,onClick:T,className:`tool-guard-test-run`,children:m?o(`toolGuard.testing`,null,`验证中…`):o(`toolGuard.test`,null,`测试匹配`)}),(0,R.jsx)(S,{error:C}),v&&(0,R.jsxs)(`div`,{className:`tool-guard-test-result ${E?`is-blocked`:`is-pass`}`,children:[(0,R.jsxs)(i,{spacing:8,wrap:!0,children:[(0,R.jsx)(c,{color:E?`red`:k?`grey`:`green`,size:`small`,children:E?`blocked`:`passed`}),(0,R.jsx)(z,{strong:!0,children:l?E?o(`toolGuard.singleMatched`,null,`本条规则匹配成功`):o(`toolGuard.singleNotMatched`,null,`本条规则未匹配`):E?o(`t Line truncated
@@ -1 +1 @@
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{A as a,Ct as o,F as s,H as c,L as l,M as u,Ot as d,U as f,W as p,a as m,c as h,f as g,i as _,jt as v,lt as y,m as ee,ot as b,p as te,s as ne,st as re,ut as ie,v as x}from"./semi-CHxO7u8f.js";import{C as ae,E as S,F as oe,I as C,L as se,P as ce,R as w,S as T,_ as le,a as E,b as D,c as O,d as k,f as A,h as ue,l as de,m as j,n as M,o as N,p as fe,s as pe,v as P,x as F,y as I}from"./index-CuUcClXg.js";import{r as me}from"./retest-EzTZPjnQ.js";var L=e(t(),1),he=[`critical`,`high`,`medium`,`low`,`info`],R=[`open`,`confirmed`,`fixed`,`ignored`,`false_positive`],z=[`q`,`severity`,`status`,`project_id`,`conversation_tag`,`task_tag`],ge=[10,20,50,100],B={critical:`dashboard.severityCritical`,high:`dashboard.severityHigh`,medium:`dashboard.severityMedium`,low:`dashboard.severityLow`,info:`dashboard.severityInfo`},V={open:`vulnerabilityPage.statusOpen`,confirmed:`vulnerabilityPage.statusConfirmed`,fixed:`vulnerabilityPage.statusFixed`,ignored:`vulnerabilityPage.statusIgnored`,false_positive:`vulnerabilityPage.statusFalsePositive`},H={open:`待处理`,confirmed:`已确认`,fixed:`已修复`,ignored:`已忽略`,false_positive:`误报`},_e={retest:`复测结果`,retest_started:`复测分支已创建`,merge:`归并上报`,split:`拆分归并组`,detach:`解除关联`},ve=[{value:``,key:`vulnerabilityPage.sortDefault`,fallback:`默认顺序`},{value:`severity`,key:`vulnerabilityPage.sortSeverity`,fallback:`高危优先`},{value:`latest`,key:`vulnerabilityPage.sortLatest`,fallback:`创建时间:最新优先`},{value:`oldest`,key:`vulnerabilityPage.sortOldest`,fallback:`创建时间:最早优先`}];function ye(e,t){if(!t)return`—`;let n=B[t];return n?e(n,null,ae[t]||t):String(t)}function U(e,t){if(!t)return`—`;let n=V[t];return n?e(n,null,H[t]||t):String(t)}function be(e,t){return t?e(`vulnerabilityPage.history_${t}`,null,_e[t]||t):`—`}function xe(e){return he.map(t=>({value:t,label:ye(e,t)}))}function Se(e){return R.map(t=>({value:t,label:U(e,t)}))}function Ce(e){return ve.map(t=>({value:t.value,label:e(t.key,null,t.fallback)}))}function we(e){let t={};return z.forEach(n=>{let r=String(e?.[n]??``).trim();r&&(t[n]=r)}),t}function Te(e){let t=we(e);return delete t.severity,t}function Ee(e){return z.some(t=>String(e?.[t]??``).trim()!==``)}function De(e,t){let n=Number(e)||0,r=Number(t)||0;return r>0?Math.round(n/r*100):0}function Oe(e){return String(e?.target||``).trim()}function W(e){return(Array.isArray(e?.targets)?e.targets:[]).map(e=>e?.host).find(Boolean)||e?.target_host||e?.target_domain||``}function ke(e){if(!e)return`—`;let t=e.host||e.id||`—`;return e.port?`${t}:${e.port}`:t}function G(e,t=8){let n=String(e||``);return n.length>t?`${n.slice(0,t)}…`:n}function Ae(e,t){let n=new Blob([t],{type:`text/markdown;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);return i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3),e}var K=e(r(),1);function q(e,t){return[{value:``,label:e},...t]}function je({t:e,filters:t,options:n,projectOptions:r,hasGroupFilters:i,onChange:a,onReset:o}){let[s,u]=(0,L.useState)(t.q),d=M(s,380),f=(0,L.useRef)(t.q);(0,L.useEffect)(()=>{d!==f.current&&(f.current=d,a(`q`,d))},[d,a]),(0,L.useEffect)(()=>{t.q!==f.current&&(f.current=t.q,u(t.q))},[t.q]);let p=Array.isArray(n?.conversation_tags)?n.conversation_tags:[],m=Array.isArray(n?.task_tags)?n.task_tags:[];return(0,K.jsxs)(`div`,{className:`vulnerability-filter-bar`,children:[(0,K.jsx)(c,{className:`vulnerability-filter-search`,prefix:(0,K.jsx)(b,{}),value:s,showClear:!0,placeholder:e(`vulnerabilityPage.searchKeyword`,null,`搜索标题、描述、类型、目标…`),"aria-label":e(`vulnerabilityPage.searchKeyword`,null,`搜索标题、描述、类型、目标…`),onChange:e=>u(e)}),(0,K.jsx)(x,{className:`vulnerability-filter-select`,value:t.severity,placeholder:e(`vulnerabilityPage.severity`,null,`严重程度`),optionList:q(e(`vulnerabilityPage.allSeverities`,null,`全部级别`),xe(e)),onChange:e=>a(`severity`,e||``)}),(0,K.jsx)(x,{className:`vulnerability-filter-select`,value:t.status,placeholder:e(`vulnerabilityPage.status`,null,`状态`),optionList:q(e(`dashboard.allStatuses`,null,`全部状态`),Se(e)),onChange:e=>a(`status`,e||``)}),(0,K.jsx)(x,{className:`vulnerability-filter-select vulnerability-filter-select--wide`,value:t.project_id,placeholder:e(`vulnerabilityPage.detailProject`,null,`所属项目`),filter:!0,optionList:q(e(`vulnerabilityPage.allProjects`,null,`全部项目`),r),onChange:e=>a(`project_id`,e||``)}),(0,K.jsx)(x,{className:`vulnerability-filter-select`,value:t.conversation_tag,placeholder:e(`vulnerabilityPage.conversationTag`,null,`来源(对话标签)`),filter:!0,optionList:q(e(`vulnerabilityPage.allSources`,null,`全部来源`),p.map(e=>({value:e,label:e}))),onChange:e=>a(`conversation_tag`,e||``)}),(0,Line truncated
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{A as a,Ct as o,F as s,H as c,L as l,M as u,Ot as d,U as f,W as p,a as m,c as h,f as g,i as _,jt as v,lt as y,m as ee,ot as b,p as te,s as ne,st as re,ut as ie,v as x}from"./semi-CHxO7u8f.js";import{C as ae,E as S,F as oe,I as C,L as se,P as ce,R as w,S as T,_ as le,a as E,b as D,c as O,d as k,f as A,h as ue,l as de,m as j,n as M,o as N,p as fe,s as pe,v as P,x as F,y as I}from"./index-BLFHsWWk.js";import{r as me}from"./retest-EzTZPjnQ.js";var L=e(t(),1),he=[`critical`,`high`,`medium`,`low`,`info`],R=[`open`,`confirmed`,`fixed`,`ignored`,`false_positive`],z=[`q`,`severity`,`status`,`project_id`,`conversation_tag`,`task_tag`],ge=[10,20,50,100],B={critical:`dashboard.severityCritical`,high:`dashboard.severityHigh`,medium:`dashboard.severityMedium`,low:`dashboard.severityLow`,info:`dashboard.severityInfo`},V={open:`vulnerabilityPage.statusOpen`,confirmed:`vulnerabilityPage.statusConfirmed`,fixed:`vulnerabilityPage.statusFixed`,ignored:`vulnerabilityPage.statusIgnored`,false_positive:`vulnerabilityPage.statusFalsePositive`},H={open:`待处理`,confirmed:`已确认`,fixed:`已修复`,ignored:`已忽略`,false_positive:`误报`},_e={retest:`复测结果`,retest_started:`复测分支已创建`,merge:`归并上报`,split:`拆分归并组`,detach:`解除关联`},ve=[{value:``,key:`vulnerabilityPage.sortDefault`,fallback:`默认顺序`},{value:`severity`,key:`vulnerabilityPage.sortSeverity`,fallback:`高危优先`},{value:`latest`,key:`vulnerabilityPage.sortLatest`,fallback:`创建时间:最新优先`},{value:`oldest`,key:`vulnerabilityPage.sortOldest`,fallback:`创建时间:最早优先`}];function ye(e,t){if(!t)return`—`;let n=B[t];return n?e(n,null,ae[t]||t):String(t)}function U(e,t){if(!t)return`—`;let n=V[t];return n?e(n,null,H[t]||t):String(t)}function be(e,t){return t?e(`vulnerabilityPage.history_${t}`,null,_e[t]||t):`—`}function xe(e){return he.map(t=>({value:t,label:ye(e,t)}))}function Se(e){return R.map(t=>({value:t,label:U(e,t)}))}function Ce(e){return ve.map(t=>({value:t.value,label:e(t.key,null,t.fallback)}))}function we(e){let t={};return z.forEach(n=>{let r=String(e?.[n]??``).trim();r&&(t[n]=r)}),t}function Te(e){let t=we(e);return delete t.severity,t}function Ee(e){return z.some(t=>String(e?.[t]??``).trim()!==``)}function De(e,t){let n=Number(e)||0,r=Number(t)||0;return r>0?Math.round(n/r*100):0}function Oe(e){return String(e?.target||``).trim()}function W(e){return(Array.isArray(e?.targets)?e.targets:[]).map(e=>e?.host).find(Boolean)||e?.target_host||e?.target_domain||``}function ke(e){if(!e)return`—`;let t=e.host||e.id||`—`;return e.port?`${t}:${e.port}`:t}function G(e,t=8){let n=String(e||``);return n.length>t?`${n.slice(0,t)}…`:n}function Ae(e,t){let n=new Blob([t],{type:`text/markdown;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);return i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3),e}var K=e(r(),1);function q(e,t){return[{value:``,label:e},...t]}function je({t:e,filters:t,options:n,projectOptions:r,hasGroupFilters:i,onChange:a,onReset:o}){let[s,u]=(0,L.useState)(t.q),d=M(s,380),f=(0,L.useRef)(t.q);(0,L.useEffect)(()=>{d!==f.current&&(f.current=d,a(`q`,d))},[d,a]),(0,L.useEffect)(()=>{t.q!==f.current&&(f.current=t.q,u(t.q))},[t.q]);let p=Array.isArray(n?.conversation_tags)?n.conversation_tags:[],m=Array.isArray(n?.task_tags)?n.task_tags:[];return(0,K.jsxs)(`div`,{className:`vulnerability-filter-bar`,children:[(0,K.jsx)(c,{className:`vulnerability-filter-search`,prefix:(0,K.jsx)(b,{}),value:s,showClear:!0,placeholder:e(`vulnerabilityPage.searchKeyword`,null,`搜索标题、描述、类型、目标…`),"aria-label":e(`vulnerabilityPage.searchKeyword`,null,`搜索标题、描述、类型、目标…`),onChange:e=>u(e)}),(0,K.jsx)(x,{className:`vulnerability-filter-select`,value:t.severity,placeholder:e(`vulnerabilityPage.severity`,null,`严重程度`),optionList:q(e(`vulnerabilityPage.allSeverities`,null,`全部级别`),xe(e)),onChange:e=>a(`severity`,e||``)}),(0,K.jsx)(x,{className:`vulnerability-filter-select`,value:t.status,placeholder:e(`vulnerabilityPage.status`,null,`状态`),optionList:q(e(`dashboard.allStatuses`,null,`全部状态`),Se(e)),onChange:e=>a(`status`,e||``)}),(0,K.jsx)(x,{className:`vulnerability-filter-select vulnerability-filter-select--wide`,value:t.project_id,placeholder:e(`vulnerabilityPage.detailProject`,null,`所属项目`),filter:!0,optionList:q(e(`vulnerabilityPage.allProjects`,null,`全部项目`),r),onChange:e=>a(`project_id`,e||``)}),(0,K.jsx)(x,{className:`vulnerability-filter-select`,value:t.conversation_tag,placeholder:e(`vulnerabilityPage.conversationTag`,null,`来源(对话标签)`),filter:!0,optionList:q(e(`vulnerabilityPage.allSources`,null,`全部来源`),p.map(e=>({value:e,label:e}))),onChange:e=>a(`conversation_tag`,e||``)}),(0,Line truncated
@@ -1,2 +1,2 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,T as c,U as l,W as u,at as d,c as f,i as p,lt as m,ot as h,st as g,x as _}from"./semi-CHxO7u8f.js";import{E as v,F as y,I as b,P as x,S,a as C,b as w,c as T,f as E,l as ee,n as te,o as D,p as O,s as k,u as ne,x as A,y as j}from"./index-CuUcClXg.js";var M=e(t(),1);function N(e){return b.get(`/webshell/connections`,e)}function P(e){return b.post(`/webshell/connections`,e)}function F(e,t){return b.put(`/webshell/connections/${encodeURIComponent(e)}`,t)}function re(e){return b.del(`/webshell/connections/${encodeURIComponent(e)}`)}function I(e){return b.get(`/webshell/connections/${encodeURIComponent(e)}/state`)}function ie(e,t){return b.put(`/webshell/connections/${encodeURIComponent(e)}/state`,{state:t})}function L({connection:e,command:t}){return b.post(`/webshell/exec`,{connection_id:e.id,url:e.url,type:e.type||`php`,method:(e.method||`post`).toLowerCase(),cmd_param:e.cmdParam||``,encoding:e.encoding||`auto`,os:e.os||`auto`,command:t})}function R({connection:e,action:t,path:n,targetPath:r,content:i,chunkIndex:a}){let o={connection_id:e.id,url:e.url,type:e.type||`php`,method:(e.method||`post`).toLowerCase(),cmd_param:e.cmdParam||``,encoding:e.encoding||`auto`,os:e.os||`auto`,action:t};return n!==void 0&&(o.path=n),r!==void 0&&(o.target_path=r),i!==void 0&&(o.content=i),a!==void 0&&(o.chunk_index=a),b.post(`/webshell/file`,o)}function z(e){return b.get(`/webshell/connections/${encodeURIComponent(e)}/ai-conversations`)}function ae(e){return b.get(`/webshell/connections/${encodeURIComponent(e)}/ai-history`)}function B(e){return b.get(`/conversations/${encodeURIComponent(e)}`,{include_process_details:0})}async function oe(){try{let e=await b.get(`/projects`,{limit:200});return Array.isArray(e?.projects)?e.projects:[]}catch{return[]}}function se(){return`__CSAI_PROBE_${Math.random().toString(36).slice(2,10)}_${Date.now().toString(36)}__`}async function ce(e){let t=se(),n=await L({connection:e,command:`echo ${t}`});return{ok:!!n?.ok&&String(n?.output||``).includes(t),output:n?.output||``,error:n?.error||``}}var V=e(n(),1),{Text:le}=u,H=[{value:`php`,label:`PHP`},{value:`asp`,label:`ASP`},{value:`aspx`,label:`ASPX`},{value:`jsp`,label:`JSP`},{value:`custom`,label:`自定义`}],U=[{value:`post`,label:`POST`},{value:`get`,label:`GET`}],W=[{value:`auto`,label:`自动检测`},{value:`utf-8`,label:`UTF-8`},{value:`gbk`,label:`GBK(中文 Windows)`},{value:`gb18030`,label:`GB18030`}],G=[{value:`auto`,label:`自动(按 Shell 类型推断)`},{value:`linux`,label:`Linux / Unix`},{value:`windows`,label:`Windows`}];function K(e){return e?{url:e.url||``,password:e.password||``,type:e.type||`php`,method:(e.method||`post`).toLowerCase(),cmd_param:e.cmdParam||``,encoding:e.encoding||`auto`,os:e.os||`auto`,remark:e.remark||``,project_id:e.project_id||``}:{url:``,password:``,type:`php`,method:`post`,cmd_param:``,encoding:`auto`,os:`auto`,remark:``,project_id:``}}function ue({visible:e,record:t,projects:n,submitting:r,onCancel:a,onSubmit:s}){let c=x(),[l,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(!1);return(0,V.jsx)(T,{visible:e,title:t?c(`webshell.editConnectionTitle`,null,`编辑连接`):c(`webshell.addConnection`,null,`添加连接`),footer:(0,V.jsxs)(i,{children:[(0,V.jsx)(o,{onClick:async()=>{let e=l?.getValues?.()||{},n=String(e.url||``).trim();if(!n)S(c(`webshell.url`,null,`请填写 Shell 地址`));else if(e.password===`********`)S(c(`webshell.testNoExpectedOutput`,null,`已保存口令不可用于新建测试,请填写口令`));else{f(!0);try{let r=await ce({id:t?.id||``,url:n,password:e.password||``,type:e.type||`php`,method:e.method||`post`,cmdParam:e.cmd_param||``,encoding:e.encoding||`auto`,os:e.os||`auto`});r.ok?A(c(`webshell.testSuccess`,null,`连通性正常,Shell 可访问`)):w(r.error||c(`webshell.testFailed`,null,`连通性测试失败`))}catch(e){w(e,c(`webshell.testFailed`,null,`连通性测试失败`))}finally{f(!1)}}},loading:d,children:c(`webshell.testConnectivity`,null,`测试连通性`)}),(0,V.jsx)(o,{onClick:a,children:c(`webshell.cancelEdit`,null,`取消`)}),(0,V.jsx)(o,{theme:`solid`,type:`primary`,loading:r,onClick:()=>l?.submitForm(),children:t?c(`webshell.saveFile`,null,`保存`):c(`webshell.addConnection`,null,`添加连接`)})]}),width:600,onCancel:a,children:(0,V.jsxs)(p,{initValues:K(t),onSubmit:e=>{s({url:String(e.url||``).trim(),password:e.password||``,type:e.type||`php`,method:e.method||`post`,cmd_param:String(e.cmd_param||``).trim(),encoding:e.encoding||`auto`,os:e.os||`auto`,remark:String(e.remark||``).trim(),project_id:e.project_id||``})},getFormApi:u,labelPosition:`top`,children:[(0,V.jsx)(p.Input,{field:`url`,label:c(`webshell.url`,null,`Shell 地址`),placeholder:`http(s)://target.com/shell.php`,rules:[{required:!0,message:c(`webshell.url`,null,`请填写 Shell 地址`)}]}),(0,V.jsx)(p.Input,{field:`password`,label:c(`webshell.password`,nLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,T as c,U as l,W as u,at as d,c as f,i as p,lt as m,ot as h,st as g,x as _}from"./semi-CHxO7u8f.js";import{E as v,F as y,I as b,P as x,S,a as C,b as w,c as T,f as E,l as ee,n as te,o as D,p as O,s as k,u as ne,x as A,y as j}from"./index-BLFHsWWk.js";var M=e(t(),1);function N(e){return b.get(`/webshell/connections`,e)}function P(e){return b.post(`/webshell/connections`,e)}function F(e,t){return b.put(`/webshell/connections/${encodeURIComponent(e)}`,t)}function re(e){return b.del(`/webshell/connections/${encodeURIComponent(e)}`)}function I(e){return b.get(`/webshell/connections/${encodeURIComponent(e)}/state`)}function ie(e,t){return b.put(`/webshell/connections/${encodeURIComponent(e)}/state`,{state:t})}function L({connection:e,command:t}){return b.post(`/webshell/exec`,{connection_id:e.id,url:e.url,type:e.type||`php`,method:(e.method||`post`).toLowerCase(),cmd_param:e.cmdParam||``,encoding:e.encoding||`auto`,os:e.os||`auto`,command:t})}function R({connection:e,action:t,path:n,targetPath:r,content:i,chunkIndex:a}){let o={connection_id:e.id,url:e.url,type:e.type||`php`,method:(e.method||`post`).toLowerCase(),cmd_param:e.cmdParam||``,encoding:e.encoding||`auto`,os:e.os||`auto`,action:t};return n!==void 0&&(o.path=n),r!==void 0&&(o.target_path=r),i!==void 0&&(o.content=i),a!==void 0&&(o.chunk_index=a),b.post(`/webshell/file`,o)}function z(e){return b.get(`/webshell/connections/${encodeURIComponent(e)}/ai-conversations`)}function ae(e){return b.get(`/webshell/connections/${encodeURIComponent(e)}/ai-history`)}function B(e){return b.get(`/conversations/${encodeURIComponent(e)}`,{include_process_details:0})}async function oe(){try{let e=await b.get(`/projects`,{limit:200});return Array.isArray(e?.projects)?e.projects:[]}catch{return[]}}function se(){return`__CSAI_PROBE_${Math.random().toString(36).slice(2,10)}_${Date.now().toString(36)}__`}async function ce(e){let t=se(),n=await L({connection:e,command:`echo ${t}`});return{ok:!!n?.ok&&String(n?.output||``).includes(t),output:n?.output||``,error:n?.error||``}}var V=e(n(),1),{Text:le}=u,H=[{value:`php`,label:`PHP`},{value:`asp`,label:`ASP`},{value:`aspx`,label:`ASPX`},{value:`jsp`,label:`JSP`},{value:`custom`,label:`自定义`}],U=[{value:`post`,label:`POST`},{value:`get`,label:`GET`}],W=[{value:`auto`,label:`自动检测`},{value:`utf-8`,label:`UTF-8`},{value:`gbk`,label:`GBK(中文 Windows)`},{value:`gb18030`,label:`GB18030`}],G=[{value:`auto`,label:`自动(按 Shell 类型推断)`},{value:`linux`,label:`Linux / Unix`},{value:`windows`,label:`Windows`}];function K(e){return e?{url:e.url||``,password:e.password||``,type:e.type||`php`,method:(e.method||`post`).toLowerCase(),cmd_param:e.cmdParam||``,encoding:e.encoding||`auto`,os:e.os||`auto`,remark:e.remark||``,project_id:e.project_id||``}:{url:``,password:``,type:`php`,method:`post`,cmd_param:``,encoding:`auto`,os:`auto`,remark:``,project_id:``}}function ue({visible:e,record:t,projects:n,submitting:r,onCancel:a,onSubmit:s}){let c=x(),[l,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(!1);return(0,V.jsx)(T,{visible:e,title:t?c(`webshell.editConnectionTitle`,null,`编辑连接`):c(`webshell.addConnection`,null,`添加连接`),footer:(0,V.jsxs)(i,{children:[(0,V.jsx)(o,{onClick:async()=>{let e=l?.getValues?.()||{},n=String(e.url||``).trim();if(!n)S(c(`webshell.url`,null,`请填写 Shell 地址`));else if(e.password===`********`)S(c(`webshell.testNoExpectedOutput`,null,`已保存口令不可用于新建测试,请填写口令`));else{f(!0);try{let r=await ce({id:t?.id||``,url:n,password:e.password||``,type:e.type||`php`,method:e.method||`post`,cmdParam:e.cmd_param||``,encoding:e.encoding||`auto`,os:e.os||`auto`});r.ok?A(c(`webshell.testSuccess`,null,`连通性正常,Shell 可访问`)):w(r.error||c(`webshell.testFailed`,null,`连通性测试失败`))}catch(e){w(e,c(`webshell.testFailed`,null,`连通性测试失败`))}finally{f(!1)}}},loading:d,children:c(`webshell.testConnectivity`,null,`测试连通性`)}),(0,V.jsx)(o,{onClick:a,children:c(`webshell.cancelEdit`,null,`取消`)}),(0,V.jsx)(o,{theme:`solid`,type:`primary`,loading:r,onClick:()=>l?.submitForm(),children:t?c(`webshell.saveFile`,null,`保存`):c(`webshell.addConnection`,null,`添加连接`)})]}),width:600,onCancel:a,children:(0,V.jsxs)(p,{initValues:K(t),onSubmit:e=>{s({url:String(e.url||``).trim(),password:e.password||``,type:e.type||`php`,method:e.method||`post`,cmd_param:String(e.cmd_param||``).trim(),encoding:e.encoding||`auto`,os:e.os||`auto`,remark:String(e.remark||``).trim(),project_id:e.project_id||``})},getFormApi:u,labelPosition:`top`,children:[(0,V.jsx)(p.Input,{field:`url`,label:c(`webshell.url`,null,`Shell 地址`),placeholder:`http(s)://target.com/shell.php`,rules:[{required:!0,message:c(`webshell.url`,null,`请填写 Shell 地址`)}]}),(0,V.jsx)(p.Input,{field:`password`,label:c(`webshell.password`,nLine truncated
`);try{await navigator.clipboard.writeText(e),A(r(`webshell.terminalCopyOk`,null,`日志已复制`))}catch(e){w(e,r(`webshell.terminalCopyFail`,null,`复制失败`))}},children:r(`webshell.copyTerminalLog`,null,`复制日志`)})]})}),(0,V.jsxs)(`div`,{className:`webshell-terminal-log`,ref:h,children:[(0,V.jsx)(`div`,{className:`webshell-terminal-welcome`,children:r(`webshell.terminalWelcome`,null,`WebShell 虚拟终端 — 输入命令后按回车执行(Ctrl+L 清屏)`)}),c.map(e=>(0,V.jsx)(`pre`,{className:`webshell-terminal-line kind-${e.kind}`,children:e.kind===`cmd`?`$ ${e.text}`:e.text},e.id)),p&&(0,V.jsx)(`div`,{className:`webshell-terminal-pending`,children:r(`webshell.running`,null,`执行中…`)})]}),(0,V.jsxs)(`div`,{className:`webshell-terminal-input`,children:[(0,V.jsx)(a,{value:u,onChange:f,onEnterPress:()=>p?S(r(`webshell.waitFinish`,null,`请等待当前命令执行完成`)):_(),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`l`&&(e.preventDefault(),l([]))},placeholder:r(`webshell.commandPlaceholder`,null,`输入命令后回车执行`),disabled:p||!t,prefix:`$`}),(0,V.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,V.jsx)(d,{}),loading:p,disabled:!t,onClick:()=>_(),children:r(`webshell.runCommand`,null,`执行`)})]})]})}var{Text:be}=u;function xe({history:e,onClear:t,onRemove:n,onRun:r}){let a=x(),s=e.map((e,t)=>({...e,rowId:`${t}-${e.at}`})),c=[{title:a(`webshell.colCommand`,null,`命令`),dataIndex:`command`,render:e=>(0,V.jsx)(`code`,{className:`webshell-history-cmd`,children:e})},{title:a(`webshell.colExecutedAt`,null,`执行时间`),dataIndex:`at`,width:200,render:e=>v(e)},{title:a(`webshell.moreActions`,null,`操作`),dataIndex:`ops`,width:220,render:(e,t)=>(0,V.jsxs)(i,{spacing:4,children:[(0,V.jsx)(D,{text:t.command,label:a(`common.copied`,null,`复制`),size:`small`}),r&&(0,V.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>r(t.command),children:a(`webshell.rerun`,null,`再执行`)}),(0,V.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,onClick:()=>j({title:a(`webshell.deleteHistory`,null,`删除该条历史`),content:t.command,onOk:()=>n(t.rowId)}),children:a(`webshell.deleteFile`,null,`删除`)})]})}];return(0,V.jsxs)(`div`,{className:`webshell-history`,children:[(0,V.jsxs)(`div`,{className:`webshell-history-toolbar`,children:[(0,V.jsx)(be,{type:`tertiary`,children:a(`webshell.historyHint`,null,`仅记录本连接在当前浏览器执行过的命令`)}),(0,V.jsx)(i,{spacing:8,children:t&&(0,V.jsx)(o,{size:`small`,disabled:!s.length,onClick:()=>t(),children:a(`webshell.clearHistory`,null,`清空历史`)})})]}),(0,V.jsx)(k,{columns:c,dataSource:s,rowKey:`rowId`,pagination:{pageSize:15},emptyText:a(`webshell.noHistory`,null,`暂无命令历史`)})]})}var{Text:Se}=u,Ce={user:`blue`,assistant:`green`,system:`grey`,tool:`violet`};function we({connection:e}){let t=x(),[n,r]=(0,M.useState)([]),[i,a]=(0,M.useState)(``),[u,d]=(0,M.useState)([]),[f,p]=(0,M.useState)(!1),[m,h]=(0,M.useState)(null),_=(0,M.useCallback)(async()=>{if(e?.id){p(!0),h(null);try{let[t,n]=await Promise.all([z(e.id).catch(()=>[]),ae(e.id).catch(()=>null)]),i=Array.isArray(t)?t:[];r(i);let o=n?.conversationId||i[0]?.id||``;if(a(o),n?.conversationId)d(Array.isArray(n.messages)?n.messages:[]);else if(o){let e=await B(o).catch(()=>null);d(Array.isArray(e?.messages)?e.messages:[])}else d([])}catch(e){h(e)}finally{p(!1)}}},[e?.id]);(0,M.useEffect)(()=>{_()},[_]);let y=async e=>{if(e){a(e),p(!0);try{let t=await B(e);d(Array.isArray(t?.messages)?t.messages:[])}catch(e){h(e),d([])}finally{p(!1)}}};return(0,V.jsxs)(`div`,{className:`webshell-ai`,children:[(0,V.jsxs)(`div`,{className:`webshell-ai-sidebar`,children:[(0,V.jsxs)(`div`,{className:`webshell-ai-sidebar-head`,children:[(0,V.jsx)(Se,{strong:!0,children:t(`webshell.aiPreviousConversation`,null,`之前的对话`)}),(0,V.jsx)(o,{size:`small`,theme:`borderless`,icon:(0,V.jsx)(g,{}),onClick:_,loading:f})]}),n.length===0?(0,V.jsx)(c,{title:t(`webshell.aiNoConversation`,null,`暂无 AI 会话`),description:null,style:{padding:24}}):(0,V.jsx)(`ul`,{className:`webshell-ai-list`,children:n.map(e=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,className:`webshell-ai-item ${e.id===i?`is-active`:``}`,onClick:()=>y(e.id),children:[(0,V.jsx)(`span`,{className:`webshell-ai-title`,children:e.title||e.id}),(0,V.jsx)(`span`,{className:`webshell-ai-time`,children:v(e.updatedAt)})]})},e.id))})]}),(0,V.jsxs)(`div`,{className:`webshell-ai-main`,children:[(0,V.jsx)(ee,{error:m,onRetry:_}),f&&(0,V.jsx)(`div`,{className:`webshell-ai-loading`,children:(0,V.jsx)(l,{})}),!f&&u.length===0&&(0,V.jsx)(c,{title:t(`webshell.aiNoMessage`,null,`暂无对话消息`),description:null,style:{padding:48}}),!f&&u.map(e=>(0,V.jsxs)(`div`,{className:`webshell-ai-message`,children:[(0,V.jsxs)(`div`,{className:`webshell-ai-message-head`,children:[(0,V.jsx)(s,{size:`small`,color:Ce[e.role]||`grey`,children:e.role||`message`}),(0,V.jsx)(Se,{type:`tertiary`,size:`small`,children:v(e Line truncated
@@ -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{F as i,H as a,L as o,M as s,N as c,W as l,b as u,c as d,f,l as p,lt as m,m as h,ot as g,p as _,s as v,st as y,u as b,x,z as S}from"./semi-CHxO7u8f.js";import{E as C,F as w,I as T,L as E,P as D,_ as ee,a as O,b as k,c as te,d as A,l as j,m as M,n as ne,p as re,r as N,s as P,u as F,x as I,y as L}from"./index-CuUcClXg.js";var R=e(t(),1),z=[{value:`start`,label:`开始`},{value:`tool`,label:`工具`},{value:`agent`,label:`Agent`},{value:`condition`,label:`条件`},{value:`hitl`,label:`审批`},{value:`output`,label:`输出`},{value:`end`,label:`结束`}],ie=Object.fromEntries(z.map(e=>[e.value,e.label])),B={running:{label:`执行中`,color:`blue`},awaiting_hitl:{label:`等待审批`,color:`amber`},completed:{label:`已完成`,color:`green`},failed:{label:`失败`,color:`red`},cancelled:{label:`已取消`,color:`grey`},pending:{label:`待执行`,color:`amber`}},V={nodes:[{id:`start`,type:`start`,label:`开始`,position:{x:80,y:140},config:{}},{id:`out`,type:`output`,label:`输出`,position:{x:380,y:140},config:{output_key:`result`}}],edges:[{id:`e1`,source:`start`,target:`out`,label:``}],config:{}},H={WFPKG_FILE_REQUIRED:`workflows.package.errors.fileRequired`,WFPKG_FILE_TOO_LARGE:`workflows.package.errors.fileTooLarge`,WFPKG_UNSUPPORTED_FORMAT:`workflows.package.errors.unsupportedFormat`,WFPKG_INVALID_ARCHIVE:`workflows.package.errors.invalidArchive`,WFPKG_INVALID_MANIFEST:`workflows.package.errors.invalidManifest`,WFPKG_CHECKSUM_MISMATCH:`workflows.package.errors.checksumMismatch`,WFPKG_MULTIPLE_WORKFLOWS:`workflows.package.errors.multipleWorkflows`,WFPKG_WORKFLOW_INVALID:`workflows.package.errors.workflowInvalid`,WFPKG_INSPECTION_NOT_FOUND:`workflows.package.errors.inspectionNotFound`,WFPKG_INSPECTION_EXPIRED:`workflows.package.errors.inspectionExpired`,WFPKG_INSPECTION_CONSUMED:`workflows.package.errors.inspectionConsumed`,WFPKG_CONFLICT_CHANGED:`workflows.package.errors.conflictChanged`,WFPKG_ID_CONFLICT:`workflows.package.errors.idConflict`,WFPKG_INVALID_ACTION:`workflows.package.errors.invalidAction`,WFPKG_INVALID_RENAME_ID:`workflows.package.errors.invalidRenameId`,WFPKG_OVERWRITE_CONFIRMATION_REQUIRED:`workflows.package.errors.overwriteConfirmationRequired`,WFPKG_IDEMPOTENCY_KEY_REQUIRED:`workflows.package.errors.idempotencyKeyRequired`,WFPKG_IDEMPOTENCY_KEY_REUSED:`workflows.package.errors.idempotencyKeyReused`,WFPKG_IMPORT_FAILED:`workflows.package.errors.importFailed`},U={create:{label:`创建导入`,hint:`导入后会创建一个新的本地工作流。`},keep_existing:{label:`保留本地版本`,hint:`不修改当前本地工作流;导入记录会保留。`},overwrite:{label:`覆盖本地版本`,hint:`替换名称、描述、图定义和启用状态;需要再次确认。`},rename:{label:`另存为新 ID`,hint:`保留当前本地工作流,并以新的 ID 创建副本。`}},W={none:[`create`],identical:[`keep_existing`],id_conflict:[`keep_existing`,`overwrite`,`rename`]};function G(e){return(W[e]||[]).slice()}function K(e){if(!e||!String(e).trim())return{graph:null,error:`图定义不能为空`};try{let t=JSON.parse(e);return!t||typeof t!=`object`?{graph:null,error:`图定义必须是 JSON 对象`}:{graph:{nodes:Array.isArray(t.nodes)?t.nodes:[],edges:Array.isArray(t.edges)?t.edges:[],config:t.config||{}},error:null}}catch(e){return{graph:null,error:e.message||`JSON 解析失败`}}}function ae(e){let{graph:t,error:n}=K(e);return t?{nodes:t.nodes,edges:t.edges,error:null}:{nodes:[],edges:[],error:n}}function q(e,t=12){let n=String(e||``);if(!n)return`—`;let r=n.startsWith(`sha256:`)?n.slice(7):n;return r.length>t?`${r.slice(0,t)}…`:r}function J(e,t=`操作失败`){if(!e)return t;if(typeof e==`string`)return e;let n=e.payload;if(n&&typeof n==`object`){let e=n.error;if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=typeof e.message==`string`?e.message:``,n=typeof e.code==`string`?e.code:``;if(t)return n?`${t}(${n})`:t}if(typeof n.message==`string`&&n.message)return n.message}return typeof e.message==`string`&&e.message&&e.message!==`[object Object]`?e.message:t}function oe(e,t=`加载失败`){return e?{message:J(e,t)}:null}function se(e){let t=e?.payload?.error;return t&&typeof t==`object`&&typeof t.code==`string`?t.code:``}function ce(e,t){let n=se(e);if(n&&H[n]){let e=t?.(H[n],null,``);if(e)return e}return J(e,`操作未完成,请稍后重试。`)}function le(){let e=typeof globalThis<`u`?globalThis.crypto:null;return!e||typeof e.randomUUID!=`function`?``:e.randomUUID()}var Y=e(n(),1),{Text:X}=l,ue=/^[A-Za-z0-9][A-Za-z0-9_-]*$/,de={id:``,name:``,description:``,version:1,enabled:!0,graph:``};function fe({visible:e,workflow:t,onCancel:n,onSaved:r}){let s=D(),{hasPermission:l}=w(),d=l(`workflow:execute`),[f,p]=(0,R.useState)(de),[m,h]=(0,R.useState)(!1),[g,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(null),b=!!t?.id;(0,R.useEffect)(()=>{if(e){if(y(null),h(!1),t){lLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,N as c,W as l,b as u,c as d,f,l as p,lt as m,m as h,ot as g,p as _,s as v,st as y,u as b,x,z as S}from"./semi-CHxO7u8f.js";import{E as C,F as w,I as T,L as E,P as D,_ as ee,a as O,b as k,c as te,d as A,l as j,m as M,n as ne,p as re,r as N,s as P,u as F,x as I,y as L}from"./index-BLFHsWWk.js";var R=e(t(),1),z=[{value:`start`,label:`开始`},{value:`tool`,label:`工具`},{value:`agent`,label:`Agent`},{value:`condition`,label:`条件`},{value:`hitl`,label:`审批`},{value:`output`,label:`输出`},{value:`end`,label:`结束`}],ie=Object.fromEntries(z.map(e=>[e.value,e.label])),B={running:{label:`执行中`,color:`blue`},awaiting_hitl:{label:`等待审批`,color:`amber`},completed:{label:`已完成`,color:`green`},failed:{label:`失败`,color:`red`},cancelled:{label:`已取消`,color:`grey`},pending:{label:`待执行`,color:`amber`}},V={nodes:[{id:`start`,type:`start`,label:`开始`,position:{x:80,y:140},config:{}},{id:`out`,type:`output`,label:`输出`,position:{x:380,y:140},config:{output_key:`result`}}],edges:[{id:`e1`,source:`start`,target:`out`,label:``}],config:{}},H={WFPKG_FILE_REQUIRED:`workflows.package.errors.fileRequired`,WFPKG_FILE_TOO_LARGE:`workflows.package.errors.fileTooLarge`,WFPKG_UNSUPPORTED_FORMAT:`workflows.package.errors.unsupportedFormat`,WFPKG_INVALID_ARCHIVE:`workflows.package.errors.invalidArchive`,WFPKG_INVALID_MANIFEST:`workflows.package.errors.invalidManifest`,WFPKG_CHECKSUM_MISMATCH:`workflows.package.errors.checksumMismatch`,WFPKG_MULTIPLE_WORKFLOWS:`workflows.package.errors.multipleWorkflows`,WFPKG_WORKFLOW_INVALID:`workflows.package.errors.workflowInvalid`,WFPKG_INSPECTION_NOT_FOUND:`workflows.package.errors.inspectionNotFound`,WFPKG_INSPECTION_EXPIRED:`workflows.package.errors.inspectionExpired`,WFPKG_INSPECTION_CONSUMED:`workflows.package.errors.inspectionConsumed`,WFPKG_CONFLICT_CHANGED:`workflows.package.errors.conflictChanged`,WFPKG_ID_CONFLICT:`workflows.package.errors.idConflict`,WFPKG_INVALID_ACTION:`workflows.package.errors.invalidAction`,WFPKG_INVALID_RENAME_ID:`workflows.package.errors.invalidRenameId`,WFPKG_OVERWRITE_CONFIRMATION_REQUIRED:`workflows.package.errors.overwriteConfirmationRequired`,WFPKG_IDEMPOTENCY_KEY_REQUIRED:`workflows.package.errors.idempotencyKeyRequired`,WFPKG_IDEMPOTENCY_KEY_REUSED:`workflows.package.errors.idempotencyKeyReused`,WFPKG_IMPORT_FAILED:`workflows.package.errors.importFailed`},U={create:{label:`创建导入`,hint:`导入后会创建一个新的本地工作流。`},keep_existing:{label:`保留本地版本`,hint:`不修改当前本地工作流;导入记录会保留。`},overwrite:{label:`覆盖本地版本`,hint:`替换名称、描述、图定义和启用状态;需要再次确认。`},rename:{label:`另存为新 ID`,hint:`保留当前本地工作流,并以新的 ID 创建副本。`}},W={none:[`create`],identical:[`keep_existing`],id_conflict:[`keep_existing`,`overwrite`,`rename`]};function G(e){return(W[e]||[]).slice()}function K(e){if(!e||!String(e).trim())return{graph:null,error:`图定义不能为空`};try{let t=JSON.parse(e);return!t||typeof t!=`object`?{graph:null,error:`图定义必须是 JSON 对象`}:{graph:{nodes:Array.isArray(t.nodes)?t.nodes:[],edges:Array.isArray(t.edges)?t.edges:[],config:t.config||{}},error:null}}catch(e){return{graph:null,error:e.message||`JSON 解析失败`}}}function ae(e){let{graph:t,error:n}=K(e);return t?{nodes:t.nodes,edges:t.edges,error:null}:{nodes:[],edges:[],error:n}}function q(e,t=12){let n=String(e||``);if(!n)return`—`;let r=n.startsWith(`sha256:`)?n.slice(7):n;return r.length>t?`${r.slice(0,t)}…`:r}function J(e,t=`操作失败`){if(!e)return t;if(typeof e==`string`)return e;let n=e.payload;if(n&&typeof n==`object`){let e=n.error;if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=typeof e.message==`string`?e.message:``,n=typeof e.code==`string`?e.code:``;if(t)return n?`${t}(${n})`:t}if(typeof n.message==`string`&&n.message)return n.message}return typeof e.message==`string`&&e.message&&e.message!==`[object Object]`?e.message:t}function oe(e,t=`加载失败`){return e?{message:J(e,t)}:null}function se(e){let t=e?.payload?.error;return t&&typeof t==`object`&&typeof t.code==`string`?t.code:``}function ce(e,t){let n=se(e);if(n&&H[n]){let e=t?.(H[n],null,``);if(e)return e}return J(e,`操作未完成,请稍后重试。`)}function le(){let e=typeof globalThis<`u`?globalThis.crypto:null;return!e||typeof e.randomUUID!=`function`?``:e.randomUUID()}var Y=e(n(),1),{Text:X}=l,ue=/^[A-Za-z0-9][A-Za-z0-9_-]*$/,de={id:``,name:``,description:``,version:1,enabled:!0,graph:``};function fe({visible:e,workflow:t,onCancel:n,onSaved:r}){let s=D(),{hasPermission:l}=w(),d=l(`workflow:execute`),[f,p]=(0,R.useState)(de),[m,h]=(0,R.useState)(!1),[g,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(null),b=!!t?.id;(0,R.useEffect)(()=>{if(e){if(y(null),h(!1),t){lLine truncated
+1 -1
View File
@@ -18,7 +18,7 @@
} catch (error) { /* first paint fallback */ }
})();
</script>
<script type="module" crossorigin src="/static/app/assets/index-CuUcClXg.js"></script>
<script type="module" crossorigin src="/static/app/assets/index-BLFHsWWk.js"></script>
<link rel="modulepreload" crossorigin href="/static/app/assets/rolldown-runtime-WkwZ5CU-.js">
<link rel="modulepreload" crossorigin href="/static/app/assets/react-QV7DAAIx.js">
<link rel="modulepreload" crossorigin href="/static/app/assets/semi-CHxO7u8f.js">