+`+r+``+i+`>
+`}listitem(e){let t=``;if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type===`paragraph`?(e.tokens[0].text=n+` `+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type===`text`&&(e.tokens[0].tokens[0].text=n+` `+V(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:`text`,raw:n+` `,text:n+` `,escaped:!0}):t+=n+` `}return t+=this.parser.parse(e.tokens,!!e.loose),`${t}
+`}checkbox({checked:e}){return``}paragraph({tokens:e}){return`${this.parser.parseInline(e)}
+`}table(e){let t=``,n=``;for(let t=0;t${r}`),`
+`}tablerow({text:e}){return`
+${e}
+`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`${n}>
+`}strong({tokens:e}){return`${this.parser.parseInline(e)}`}em({tokens:e}){return`${this.parser.parseInline(e)}`}codespan({text:e}){return`${V(e,!0)}`}br(e){return`
`}del({tokens:e}){return`${this.parser.parseInline(e)}`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Bn(e);if(i===null)return r;e=i;let a=``+r+``,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Bn(e);if(i===null)return V(n);e=i;let a=`
`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:V(e.text)}},Jn=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}},U=class e{constructor(e){I(this,`options`,void 0),I(this,`renderer`,void 0),I(this,`textRenderer`,void 0),this.options=e||Mt,this.options.renderer=this.options.renderer||new qn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Jn}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n=``;for(let r=0;r{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new 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.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?H.lex:H.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser():e?U.parse:U.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?H.lex:H.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?U.parse:U.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
+Please report this to https://github.com/markedjs/marked.`,e){let e=`An error occurred:
`+V(n.message+``,!0)+`
`;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`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/g),ii=K(/\${[\w\W]*/g),ai=K(/{{|}}|\${|<%|%>|<%|%>/),oi=K(/^data-[\-\w.\u00B7-\uFFFF]+$/),si=K(/^aria-[\-\w]+$/),ci=K(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),li=K(/^(?:\w+script|data):/i),ui=K(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),di=K(/^html$/i),fi=K(/^[a-z][.\w]*(-[.\w]+)+$/i),pi=K(/<[/\w!]/g),mi=K(/<[/\w]/g),hi=K(/<\/no(script|embed|frames)/i),gi=K(/\/>/i),_i=K(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i),vi=K(/^[\r\n\t ]+/),Q={element:1,text:3,processingInstruction:7,comment:8,document:9,documentFragment:11},yi=G(X({},[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`])),bi=function(){return typeof window>`u`?null:window},xi=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Si=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ci=function(e,t,n,r){return q(e,t)&&xr(e[t])?X(r.base?Vr(r.base):{},e[t],r.transform):n},wi=function(e,t,n){let r=q(e,t)?e[t]:void 0;return r&&typeof r==`object`?Br(r):n};function Ti(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:bi(),t=e=>Ti(e);if(t.version=`3.4.18`,t.removed=[],!e||!e.document||e.document.nodeType!==Q.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript,a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter,l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=Z(d,`cloneNode`),p=Z(d,`remove`),m=Z(d,`removeAttributeNode`),ee=Z(d,`nextSibling`),h=Z(d,`childNodes`),g=Z(d,`parentNode`),_=Z(d,`shadowRoot`),te=Z(d,`attributes`),v=o&&o.prototype?Z(o.prototype,`nodeType`):null,ne=o&&o.prototype?Z(o.prototype,`nodeName`):null,re=o&&o.prototype?Z(o.prototype,`ownerDocument`):null,y=function(e){return v?v(e):e.nodeType},b=function(e){return ne?ne(e):e.nodeName},ie=Ur(d,`namespaceURI`),ae=function(e){return ie?ie(e):e.namespaceURI};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,oe,se=!1,ce=0,le=function(){if(ce>0)throw Lr(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},ue=function(e){le(),ce++;try{return x.createHTML(e)}finally{ce--}},de=function(e){return x&&Ge?ue(e):e},fe=function(e){le(),ce++;try{return x.createScriptURL(e)}finally{ce--}},pe=function(){return se||(oe=xi(u,i),se=!0),oe},me=n,he=me.implementation,ge=me.createNodeIterator,_e=me.createDocumentFragment,ve=me.getElementsByTagName,ye=r.importNode,C=Si();t.isSupported=typeof ar==`function`&&typeof g==`function`&&he&&he.createHTMLDocument!==void 0;let be=ni,xe=ri,Se=ii,Ce=oi,we=si,Te=li,Ee=ui,De=fi,Oe=ci,w=null,ke=X({},[...Gr,...Kr,...qr,...Yr,...Zr]),T=null,Ae=X({},[...Qr,...$r,...ei,...ti]),E=null,je=null,Me=null,Ne=Object.seal(dr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Pe=!0,Fe=!0,Ie=!1,Le=!0,D=!1,Re=!0,ze=!1,Be=!1,Ve=null,He=null,O=!1,Ue=!1,We=!1,Ge=!1,Ke=!0,qe=!1,Je=`user-content-`,Ye=!0,Xe=!1,Ze=null,k=!1,A=null,Qe=X({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),$e=null,et=X({},[`audio`,`video`,`img`,`source`,`image`,`track`]),j=null,tt=X({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),nt=`http://www.w3.org/1998/Math/MathML`,rt=`http://www.w3.org/2000/svg`,M=`http://www.w3.org/1999/xhtml`,N=M,it=!1,at=null,ot=X({},[nt,rt,M],Er),st=G(X({},[`mi`,`mo`,`mn`,`ms`,`mtext`])),ct=null,lt=G(X({},[`annotation-xml`])),ut=null,dt=G(dr(null)),ft=X({},[`title`,`style`,`font`,`a`,`script`]),pt=null,mt=[`application/xhtml+xml`,`text/html`],P=null,ht=null,gt=n.createElement(`form`),_t=function(e){return e instanceof RegExp||e instanceof Function},vt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e&&typeof e==`object`||(e={}),e=Br(e),pt=mt.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,P=pt===`application/xhtml+xml`?Er:Tr,w=Ci(e,`ALLOWED_TAGS`,ke,{transform:P}),T=Ci(e,`ALLOWED_ATTR`,Ae,{transform:P}),at=Ci(e,`ALLOWED_NAMESPACES`,ot,{transform:Er}),j=Ci(e,`ADD_URI_SAFE_ATTR`,tt,{transform:P,base:tt}),$e=Ci(e,`ADD_DATA_URI_TAGS`,et,{transform:P,base:et}),A=Ci(e,`FORBID_CONTENTS`,Qe,{transform:P}),je=Ci(e,`FORBID_TAGS`,dr(null),{transform:P}),Me=Ci(e,`FORBID_ATTR`,dr(null),{transform:P}),k=q(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Br(e.USE_PROFILES):e.USE_PROFILES:!1,Pe=e.ALLOW_ARIA_ATTR!==!1,Fe=e.ALLOW_DATA_ATTR!==!1,Ie=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Le=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,D=e.SAFE_FOR_TEMPLATES||!1,Re=e.SAFE_FOR_XML!==!1,ze=e.WHOLE_DOCUMENT||!1,Ue=e.RETURN_DOM||!1,We=e.RETURN_DOM_FRAGMENT||!1,Ge=e.RETURN_TRUSTED_TYPE||!1,O=e.FORCE_BODY||!1,Ke=e.SANITIZE_DOM!==!1,qe=e.SANITIZE_NAMED_PROPS||!1,Ye=e.KEEP_CONTENT!==!1,Xe=e.IN_PLACE||!1,Oe=Wr(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:ci,N=typeof e.NAMESPACE==`string`?e.NAMESPACE:M,ct=wi(e,`MATHML_TEXT_INTEGRATION_POINTS`,st),ut=wi(e,`HTML_INTEGRATION_POINTS`,lt);let t=wi(e,`CUSTOM_ELEMENT_HANDLING`,dt);if(E=dr(null),q(t,`tagNameCheck`)&&_t(t.tagNameCheck)&&(E.tagNameCheck=t.tagNameCheck),q(t,`attributeNameCheck`)&&_t(t.attributeNameCheck)&&(E.attributeNameCheck=t.attributeNameCheck),q(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(E.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),K(E),D&&(Fe=!1),We&&(Ue=!0),k&&((q(e,`ALLOWED_TAGS`)||q(e,`ALLOWED_ATTR`))&&typeof console<`u`&&typeof console.warn==`function`&&console.warn(`DOMPurify: USE_PROFILES overrides ALLOWED_TAGS and ALLOWED_ATTR. Do not use these options together.`),w=X({},Zr),T=dr(null),k.html===!0&&(X(w,Gr),X(T,Qr)),k.svg===!0&&(X(w,Kr),X(T,$r),X(T,ti)),k.svgFilters===!0&&(X(w,qr),X(T,$r),X(T,ti)),k.mathMl===!0&&(X(w,Yr),X(T,ei),X(T,ti))),Ne.tagCheck=null,Ne.attributeCheck=null,q(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?Ne.tagCheck=e.ADD_TAGS:xr(e.ADD_TAGS)&&(w===ke&&(w=Vr(w)),X(w,e.ADD_TAGS,P))),q(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?Ne.attributeCheck=e.ADD_ATTR:xr(e.ADD_ATTR)&&(T===Ae&&(T=Vr(T)),X(T,e.ADD_ATTR,P))),q(e,`ADD_FORBID_CONTENTS`)&&xr(e.ADD_FORBID_CONTENTS)&&(A===Qe&&(A=Vr(A)),X(A,e.ADD_FORBID_CONTENTS,P)),Ye&&(w[`#text`]=!0),ze&&X(w,[`html`,`head`,`body`]),w.table&&(w.tbody=!0,delete je.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Lr(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Lr(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=ue(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=pe()),x&&typeof S==`string`&&(S=ue(``)));ht=G(e)},yt=X({},[...Kr,...qr,...Jr]),bt=X({},[...Yr,...Xr]),xt=function(e,t,n){return t===M?e===`svg`:t===nt?e===`svg`&&(n===`annotation-xml`||ct[n]):!!yt[e]},St=function(e,t,n){return t===M?e===`math`:t===rt?e===`math`&&ut[n]:!!bt[e]},Ct=function(e,t,n){return t===rt&&!ut[n]||t===nt&&!ct[n]?!1:!bt[e]&&(ft[e]||!yt[e])},wt=function(e){let t=ae(e),n=Tr(b(e)),r=g(e),i=N,a=`template`;return r&&y(r)===Q.element&&(i=ae(r),a=Tr(b(r))),at[t]?t===rt?xt(n,i,a):t===nt?St(n,i,a):t===M?Ct(n,i,a):pt===`application/xhtml+xml`:!1},Tt=function(e){vr(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw Lr(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},Et=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},Dt=function(e){I(e);let t=h(e);t&&hr(yr(t),e=>{try{p(e)}catch{}}),y(e)===Q.element&&Ot(e,!1)},F=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}if(vr(t.removed,{attribute:r||null,from:n}),r)Et(n,r,e);else try{n.removeAttribute(e)}catch{}if(e===`is`){if(Ue||We)try{Tt(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},Ot=function(e,t){let n=te(e);if(n)for(let r=n.length-1;r>=0;--r){let i=n[r],a=i&&i.name;typeof a==`string`&&!(t&&T[P(a)])&&Et(e,i,a)}},kt=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=[e];for(;r.length>0;){let e=r.pop();if(t(e)===!1)continue;if(n&&y(e)===Q.element){let t=_(e);Ut(t)&&r.push(t)}let i=h(e);if(i)for(let e=i.length-1;e>=0;--e)r.push(i[e])}},I=function(e){kt(e,e=>{y(e)===Q.element&&Ot(e,!0)})},At=function(e){let t=[];return kt(e,e=>{t.push(e)},!0),t},jt=function(e,t){let n=Sr();hr(At(e),e=>{y(e)===Q.element&&Cr(n,e)}),hr(t,e=>{y(e)===Q.element&&!wr(n,e)&&Ot(e,!0)})},Mt=function(e,n){let r=!1;return hr(t.removed,t=>{t.element&&(r=r||t.element===e,I(t.element))}),jt(e,n),r},Nt=function(e,t){let n=Ze,r=null,i=()=>(r||(r=Sr(),hr(t,e=>{Cr(r,e)})),r);for(let t=0;;t++){let r=At(e),a=[e],o=!1;if(hr(r,e=>{y(e)===Q.documentFragment?vr(a,e):!o&&!wr(n,e)&&(o=wr(i(),e))}),!o)return;if(t>=8)throw Lr(`the tree kept changing during in-place sanitization; refusing to return it`);hr(a,(t,n)=>{Pt(t,n>0,e,i())})}},Pt=function(e,t,n,r){let i=Lt(e),a;for(;a=i.nextNode();)wr(r,a)&&!wr(Ze,a)&&(t&&z(C.uponSanitizeShadowNode,a,null),rn(a,n))},L=function(e){Ze&&Cr(Ze,e)},Ft=function(e,t){return Re?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},R=function(e){Re&&kt(e,e=>{let t=y(e);if(t===Q.processingInstruction||t===Q.comment&&J(mi,e.data)){try{p(e)}catch{}return!1}if(t===Q.element){let t=e,n=P(b(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Ft(`for`,n)&&t.removeAttribute(`for`)}catch{}}return!0})},It=function(e){let t=null,r=null;if(O)e=``+e;else{let t=Dr(e,vi);r=t&&t[0]}pt===`application/xhtml+xml`&&N===M&&(e=``+e+``);let i=x?ue(e):e;if(N===M)try{t=new l().parseFromString(i,pt)}catch{}if(!t||!t.documentElement){t=he.createDocument(N,`template`,null);try{t.documentElement.innerHTML=it?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),N===M?ve.call(t,ze?`html`:`body`)[0]:ze?t.documentElement:a},Lt=function(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=re?re(e):e.ownerDocument;return ge.call(n||e,e,(t?0:c.SHOW_ELEMENT)|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Rt=function(e){return e=Or(e,be,` `),e=Or(e,xe,` `),e=Or(e,Se,` `),e},zt=function(e){Bt(e);let t=e.querySelectorAll?.call(e,`template`);t&&hr(t,e=>{Ut(e.content)&&zt(e.content)})},Bt=function(e){e.normalize();let t=Lt(e,!0),n=t.nextNode();for(;n;)n.data=Rt(n.data),n=t.nextNode()},Vt=function(e){let t=ne?ne(e):null;return typeof t!=`string`||P(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==te(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==v(e)||e.childNodes!==h(e)},Ht=function(e){if(!v||typeof e!=`object`||!e)return null;try{let t=v(e);return typeof t==`number`?t:null}catch{return null}},Ut=function(e){return Ht(e)===Q.documentFragment},Wt=function(e){return Ht(e)!==null};function z(e,n,r){e.length!==0&&hr(e,e=>{e.call(t,n,r,ht)})}let Gt=function(e,t,n){return!!(Re&&n===Q.element&&e.hasChildNodes()&&!Wt(e.firstElementChild)&&J(pi,e.textContent)&&J(pi,e.innerHTML)||Re&&yi[t]&&n===Q.element&&ae(e)===M&&(Wt(e.firstElementChild)||typeof e.textContent==`string`&&J(pi,e.textContent))||n===Q.processingInstruction||Re&&n===Q.comment&&J(mi,e.data))},Kt=function(e,t){return e instanceof RegExp?J(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},qt=function(e,t,n){if(!je[t]&&Qt(t)&&Kt(E.tagNameCheck,t))return!1;if(Ye&&!A[t]&&!A[Tr(t)]){let t=g(e),r=h(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,ee(e))}}}return Tt(e),!0},Jt=function(e,t,n,r){return e.length===0?t:t===n||t===r?Vr(t):t},B=function(e,t){return e===t||g(e)!==null?!1:(Xe&&I(e),!0)},Yt=function(e,n){if(L(e),z(C.beforeSanitizeElements,e,null),B(e,n))return!0;if(Vt(e))return Tt(e),!0;let r=P(b(e)),i=y(e);if(w=Jt(C.uponSanitizeElement,w,ke,Ve),z(C.uponSanitizeElement,e,{tagName:r,allowedTags:w}),B(e,n))return!0;if(Gt(e,r,i))return Tt(e),!0;if(je[r]||!(Ne.tagCheck instanceof Function&&Ne.tagCheck(r))&&!w[r]){let t=qt(e,r,n);return t===!1&&(z(C.afterSanitizeElements,e,null),B(e,n))?!0:t}if(i===Q.element&&!wt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&J(hi,e.innerHTML))return Tt(e),!0;if(D&&i===Q.text){let n=e.textContent,r=Rt(n);n!==r&&(vr(t.removed,{element:e.cloneNode()}),e.textContent=r)}return z(C.afterSanitizeElements,e,null),B(e,n)},Xt=function(e,t,r){if(Me[t]||Ft(t,e)||Ke&&(t===`id`||t===`name`)&&(r in n||r in gt))return!1;let i=T[t]||Ne.attributeCheck instanceof Function&&Ne.attributeCheck(t,e);if(Fe&&J(Ce,t)||Pe&&J(we,t))return!0;if(!i)return Qt(e)&&Kt(E.tagNameCheck,e)&&Kt(E.attributeNameCheck,t,e)||t===`is`&&E.allowCustomizedBuiltInElements&&Kt(E.tagNameCheck,r);if(j[t])return!0;let a=Or(r,Ee,``);return J(Oe,a)||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&kr(r,`data:`)===0&&$e[e]||Ie&&!J(Te,a)?!0:!r},Zt=X({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Qt=function(e){return!Zt[Tr(e)]&&J(De,e)},$t=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ue(r);case`TrustedScriptURL`:return fe(r)}return r},en=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!Vt(e)||(Tt(e),!1)}catch{return F(t,e),!1}},tn=function(e,t){return Re&&J(_i,t)?!0:Tr(e)===`attributename`&&kr(t,`href`)!==-1},nn=function(e,n){if(z(C.beforeSanitizeAttributes,e,null),B(e,n))return;let r=e.attributes;if(!r||Vt(e))return;T=Jt(C.uponSanitizeAttribute,T,Ae,He);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:T,forceKeepAttr:void 0},a=r.length,o=P(b(e));for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=P(s),d=l,f=s===`value`?d:Ar(d),p=!1;i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,z(C.uponSanitizeAttribute,e,i),f=i.attrValue,qe&&(u===`id`||u===`name`)&&kr(f,Je)!==0&&(F(s,e,n),f=Je+f,p=!0),tn(s,f)?F(s,e,n):i.forceKeepAttr||(i.keepAttr?!Le&&J(gi,f)?F(s,e,n):(D&&(f=Rt(f)),Xt(o,u,f)?(f=$t(o,u,c,f),f!==d&&en(e,s,c,f)&&p&&_r(t.removed)):F(s,e,n)):F(s,e,n))}z(C.afterSanitizeAttributes,e,null),B(e,n)},rn=function(e,t){Yt(e,t),nn(e,t),Ut(e.content)&&an(e.content)},an=function(e){let t=null,n=Lt(e);for(z(C.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(z(C.uponSanitizeShadowNode,t,null),rn(t,e),y(t)===Q.element){let e=_(t);Ut(e)&&(on(e),an(e))}D&&Bt(e),z(C.afterSanitizeShadowDOM,e,null)},on=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){an(e.shadow);continue}let n=e.node,r=y(n)===Q.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=ne?ne(n):null;if(typeof e==`string`&&P(e)===`template`){let e=n.content;Ut(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);Ut(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(it=!e,it&&(e=``),typeof e!=`string`&&!Wt(e)&&(e=Hr(e),typeof e!=`string`))throw Lr(`dirty is not a string, aborting`);if(!t.isSupported)return e;Be?(w=Ve,T=He):vt(n),t.removed=[];let c=Xe&&typeof e!=`string`&&Wt(e),l=[],u=Ze;if(c){R(e);let t=b(e);if(typeof t==`string`){let n=P(t);if(!w[n]||je[n])throw Dt(e),Lr(`root node is forbidden and cannot be sanitized in-place`)}if(Vt(e))throw Dt(e),Lr(`root node is clobbered and cannot be sanitized in-place`);l=At(e),Ze=Sr()}else if(Wt(e))i=It(``),a=i.ownerDocument.importNode(e,!0),a.nodeType===Q.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),on(i);else{if(!Ue&&!D&&!ze&&e.indexOf(`<`)===-1)return de(e);if(i=It(e),!i)return Ue?null:Ge?S:``}i&&O&&Tt(i.firstChild);let d=c?e:i;try{c&&on(e);let t=Lt(d);for(;o=t.nextNode();)rn(o,d);c&&Nt(e,l)}catch(t){throw c&&(Dt(e),Mt(e,l)),t}finally{Ze=u}if(c){if(Mt(e,l))throw Lr(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return D&&zt(e),e}if(Ue){if(D&&zt(i),We)for(s=_e.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(T.shadowroot||T.shadowrootmode)&&(s=ye.call(r,s,!0)),s}let f=()=>ze?i.outerHTML:i.innerHTML,p=f();return D&&J(ai,p)&&(Bt(i),p=f()),ze&&w[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&J(di,i.ownerDocument.doctype.name)&&(p=`
+`+p),de(p)},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};vt(e),Be=!0,Ve=w,He=T},t.clearConfig=function(){ht=null,Be=!1,Ve=null,He=null,x=oe,S=``},t.isValidAttribute=function(e,t,n){ht||vt({});let r=P(e),i=P(t);return typeof n==`string`&&(tn(t,n)||!Le&&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=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}=S;function Ui(e){be.success({content:e,duration:2})}function Wi(e){be.warning({content:e,duration:3})}function Gi(e,t=`操作失败`){be.error({content:et(e,t),duration:4})}function Ki({title:e,description:t,extra:n,children:r}){return(0,j.jsxs)(`header`,{className:`cs-page-header`,children:[(0,j.jsxs)(`div`,{className:`cs-page-header-main`,children:[(0,j.jsx)(Bi,{heading:3,className:`cs-page-title`,children:e}),t&&(0,j.jsx)(Vi,{type:`tertiary`,className:`cs-page-desc`,children:t}),r]}),n&&(0,j.jsx)(c,{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,j.jsxs)(te,{className:`cs-section-card ${i}`,title:e?(0,j.jsx)(`span`,{className:`cs-section-title`,children:e}):void 0,headerExtraContent:n,bordered:!1,children:[t&&(0,j.jsx)(Hi,{type:`tertiary`,className:`cs-section-desc`,children:t}),(0,j.jsx)(`div`,{className:a,children:r})]})}function Ji({metrics:e,columns:t=4}){return(0,j.jsx)(`div`,{className:`cs-stat-grid`,style:{"--cs-stat-columns":t},children:e.map(e=>(0,j.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,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`span`,{className:`cs-stat-head`,children:[(0,j.jsx)(Vi,{type:`tertiary`,className:`cs-stat-label`,children:e}),o&&(0,j.jsx)(`span`,{className:`cs-stat-icon ${i?`tone-${i}`:``}`,"aria-hidden":`true`,children:o})]}),(0,j.jsx)(d,{loading:l,placeholder:(0,j.jsx)(d.Title,{style:{width:`60%`,height:36,margin:`8px 0`}}),children:(0,j.jsx)(`span`,{className:`cs-stat-value ${i?`tone-${i}`:``}`,title:n,children:t??`—`})}),r&&(0,j.jsx)(`span`,{className:`cs-stat-detail`,children:r})]});return s?(0,j.jsx)(m,{className:`cs-stat-card is-clickable`,theme:`borderless`,onClick:s,"aria-label":String(e),"aria-pressed":c,"data-severity":a,children:u}):(0,j.jsx)(te,{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,j.jsxs)(`div`,{className:`cs-table-wrap ${l}`,children:[(s||o)&&(0,j.jsxs)(`div`,{className:`cs-table-toolbar`,children:[(0,j.jsx)(`div`,{className:`cs-table-toolbar-main`,children:s}),o&&(0,j.jsx)(m,{icon:(0,j.jsx)(xe,{}),theme:`borderless`,onClick:o,loading:r,children:d(`common.refresh`,null,`刷新`)})]}),(0,j.jsx)(`div`,{className:`cs-table-scroll`,children:(0,j.jsx)(_e,{columns:e,dataSource:t||[],rowKey:n,loading:r,pagination:f,size:c,empty:(0,j.jsx)(b,{image:(0,j.jsx)(de,{size:`extra-large`}),title:a||d(`common.noData`,null,`暂无数据`),description:null,className:`cs-table-empty`}),...u})})]})}function Zi({error:e,onRetry:t}){let n=P();return e?(0,j.jsx)(je,{type:`danger`,bordered:!0,closeIcon:null,className:`cs-error-banner`,description:(0,j.jsxs)(c,{wrap:!0,children:[(0,j.jsx)(`span`,{children:et(e,n(`common.loadFailed`,null,`加载失败`))}),t&&(0,j.jsx)(m,{size:`small`,onClick:t,children:n(`common.refresh`,null,`刷新`)})]})}):null}function Qi({severity:e,size:t=`small`}){let n=String(e||``).toLowerCase();return(0,j.jsx)(h,{size:t,color:Li(n),shape:`circle`,className:`cs-severity-tag`,"data-severity":Di.includes(n)?n:void 0,children:ki[n]||e||`—`})}function $i({status:e,label:t,size:n=`small`}){let r=String(e||``).toLowerCase();return(0,j.jsx)(h,{size:n,color:Ri(r),shape:`square`,children:t||e||`—`})}function ea({text:e,label:t,size:n=`default`,theme:r=`borderless`}){let i=P();return(0,j.jsx)(m,{size:n,theme:r,icon:(0,j.jsx)(s,{}),"aria-label":t||i(`common.copy`,null,`复制`),onClick:async()=>{try{await navigator.clipboard.writeText(String(e??``)),Ui(i(`common.copied`,null,`已复制`))}catch(e){Gi(e,i(`common.copyFailed`,null,`复制失败`))}},children:t})}function ta({content:e,className:t=``}){let n=(0,O.useMemo)(()=>{let t=W.parse(String(e??``),{breaks:!0,gfm:!0});return Ei.sanitize(t,{ADD_ATTR:[`target`,`rel`]})},[e]);return(0,j.jsx)(`div`,{className:`cs-markdown ${t}`,dangerouslySetInnerHTML:{__html:n}})}function na({value:e,collapsed:n=!1,title:r}){let[i,a]=(0,O.useState)(!n),o=P(),s=(0,O.useMemo)(()=>{try{return JSON.stringify(e,null,2)}catch{return String(e)}},[e]);return(0,j.jsxs)(`div`,{className:`cs-json-viewer`,children:[(0,j.jsxs)(`div`,{className:`cs-json-viewer-head`,children:[(0,j.jsx)(Vi,{strong:!0,children:r||`JSON`}),(0,j.jsxs)(c,{spacing:4,children:[(0,j.jsx)(ea,{text:s}),(0,j.jsx)(m,{theme:`borderless`,size:`small`,icon:i?(0,j.jsx)(t,{}):(0,j.jsx)(_,{}),"aria-expanded":i,"aria-label":o(i?`common.collapse`:`common.expand`,null,i?`收起`:`展开`),onClick:()=>a(e=>!e)})]})]}),(0,j.jsx)(me,{isOpen:i,children:(0,j.jsx)(`pre`,{className:`cs-json-viewer-body`,children:s})})]})}function ra({items:e,columns:t=2}){return(0,j.jsx)(a,{className:`cs-description-list`,layout:`horizontal`,align:`plain`,column:t,data:e.filter(Boolean).map(e=>({key:e.label,value:e.value??`—`}))})}function ia({title:e,content:t,okText:n,danger:r=!0,onOk:i}){ke.confirm({title:e,content:t,okText:n||`确定`,cancelText:`取消`,okButtonProps:r?{type:`danger`}:void 0,onOk:i})}var aa=`a[href], button, input, select, textarea, iframe, [tabindex], [contenteditable="true"]`;function oa({title:e,visible:t,onCancel:n,width:r=560,footer:i,children:a,className:o,closeOnEsc:s=!0,mask:c=!0,maskClosable:l=!0,onOk:u,formId:d,okText:f,cancelText:p,okButtonProps:ee,cancelButtonProps:h,confirmLoading:g,..._}){let te=P(),v=(0,O.useRef)(null),[ne,re]=(0,O.useState)(!1),y=g??ne,b=(0,O.useCallback)(e=>{let t=e?.closest(`[role="dialog"]`);if(!t)return;v.current=t;let n=document.activeElement;return c&&(t.setAttribute(`aria-modal`,`true`),queueMicrotask(()=>{v.current===t&&!t.contains(document.activeElement)&&t.focus({preventScroll:!0})})),()=>{if(v.current=null,!c)return;t.removeAttribute(`aria-modal`);let e=document.activeElement;n?.isConnected&&(t.contains(e)||e===document.body)&&n.focus({preventScroll:!0})}},[c]);(0,O.useEffect)(()=>{if(!t)return;let e=e=>{let t=v.current,r=document.activeElement;if(e.defaultPrevented||!t?.contains(r)||(e.key===`Escape`&&s&&n&&(e.preventDefault(),n(e)),e.key!==`Tab`||!c))return;let i=[...t.querySelectorAll(aa)].filter(e=>e.tabIndex>=0&&!e.matches(`:disabled`)&&e.getClientRects().length),a=i[0],o=i.at(-1);(!a||(e.shiftKey?r===a||r===t:r===o))&&(e.preventDefault(),(e.shiftKey?o:a)?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[s,c,n,t]);let ie=e=>{if(y)return;let t=u?.(e);if(g===void 0&&typeof t?.then==`function`){re(!0);let e=()=>re(!1);Promise.resolve(t).then(e,e)}},ae=i===void 0&&(u||d)?(0,j.jsxs)(j.Fragment,{children:[n&&(0,j.jsx)(m,{type:`tertiary`,onClick:n,...h,children:p||te(`common.cancel`,null,`取消`)}),(0,j.jsx)(m,{theme:`solid`,type:`primary`,...ee,loading:y,disabled:y||ee?.disabled,onClick:d?void 0:ie,form:d,htmlType:d?`submit`:`button`,children:f||te(`common.ok`,null,`确定`)})]}):i;return(0,j.jsxs)(le,{title:e,visible:t,onCancel:n,width:r,footer:ae,mask:c,maskClosable:l&&!y,closeOnEsc:!1,className:`cs-drawer ${o||``}`,"aria-label":typeof e==`string`?e:void 0,..._,children:[(0,j.jsx)(`span`,{hidden:!0,ref:b}),a]})}function sa(e,t=[],{initial:n=null,skip:r=!1}={}){let[i,a]=(0,O.useState)(n),[o,s]=(0,O.useState)(!r),[c,l]=(0,O.useState)(null),u=(0,O.useRef)(0),d=(0,O.useCallback)(async(t={})=>{if(r)return null;let n=++u.current;t.silent||s(!0),l(null);try{let t=await e();return n===u.current&&a(t),t}catch(e){return n===u.current&&l(e),null}finally{n===u.current&&s(!1)}},t);return(0,O.useEffect)(()=>{if(r)s(!1);else return d(),()=>{u.current+=1}},[d,r]),{data:i,setData:a,loading:o,error:c,reload:d}}function ca(e,t=300){let[n,r]=(0,O.useState)(e);return(0,O.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}function la(e,t){let n=(0,O.useRef)(e);(0,O.useEffect)(()=>{n.current=e},[e]),(0,O.useEffect)(()=>{if(!t)return;let e=setInterval(()=>n.current(),t);return()=>clearInterval(e)},[t])}function ua(e,t){let[n,r]=(0,O.useState)(()=>{try{let n=localStorage.getItem(e);return n===null?t:JSON.parse(n)}catch{return t}});return(0,O.useEffect)(()=>{try{localStorage.setItem(e,JSON.stringify(n))}catch{}},[e,n]),[n,r]}var{Text:da}=S,fa={position:`right`,contentClassName:`cs-nav-flyout`};function pa(){let[e,t]=(0,O.useState)(()=>window.matchMedia(`(max-width: 900px)`).matches);return(0,O.useEffect)(()=>{let e=window.matchMedia(`(max-width: 900px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function ma(e,t,n,r){return e.filter(e=>(!e.anyPermission||r(e.anyPermission))&&(!e.permission||n(e.permission))).map(e=>{let r=e.children?e.children.filter(e=>!e.permission||n(e.permission)):null;return r&&r.length===0?null:{itemKey:e.id,text:t(e.i18n,null,e.fallback),icon:e.icon?(0,j.jsx)(e.icon,{"aria-hidden":`true`}):void 0,items:r?r.map(e=>({itemKey:e.id,text:t(e.i18n,null,e.fallback)})):void 0}}).filter(Boolean)}function ha(){let{preference:e,setPreference:t}=Ct(),n=P(),r=[{key:`system`,label:n(`theme.system`,null,`跟随系统`)},{key:`light`,label:n(`theme.light`,null,`浅色`)},{key:`dark`,label:n(`theme.dark`,null,`暗色`)}],a=r.find(t=>t.key===e)||r[0];return(0,j.jsx)(i,{trigger:`click`,position:`bottomRight`,menu:r.map(n=>({node:`item`,name:n.label,active:n.key===e,onClick:()=>t(n.key)})),children:(0,j.jsx)(m,{theme:`borderless`,type:`tertiary`,icon:e===`dark`?(0,j.jsx)(w,{}):(0,j.jsx)(ne,{}),"aria-label":a.label})})}function ga(){let{lang:e,setLanguage:t}=mt();return(0,j.jsx)(i,{trigger:`click`,position:`bottomRight`,menu:N.map(n=>({node:`item`,name:n.label,active:n.id===e,onClick:()=>t(n.id)})),children:(0,j.jsx)(m,{theme:`borderless`,type:`tertiary`,icon:(0,j.jsx)(ve,{}),"aria-label":e})})}function _a({navigate:e}){let t=P(),[i,a]=(0,O.useState)([]),[o,s]=(0,O.useState)(0),[c,u]=(0,O.useState)(!1),[d,f]=(0,O.useState)(!1),p=async()=>{try{let e=await A.get(`/notifications/summary`,{limit:80,lang:document.documentElement.lang||`zh-CN`}),t=Array.isArray(e?.items)?e.items:[];a(t),s(e?.unreadCount??t.filter(e=>!e.read).length)}catch{}};(0,O.useEffect)(()=>{p()},[]),la(p,6e4);let ee=async()=>{let e=i.filter(e=>!e.read).map(e=>e.id).filter(Boolean);if(e.length&&!d){f(!0);try{await A.post(`/notifications/read`,{eventIds:e}),await p()}catch(e){Gi(e)}finally{f(!1)}}},h=t=>{u(!1),t.type===`vulnerability_created`&&t.vulnerabilityId?e(`/vulnerabilities?id=${encodeURIComponent(t.vulnerabilityId)}`):(t.type===`task_completed`||t.type===`long_running_tasks`)&&t.conversationId?e(`/chat?conversation=${encodeURIComponent(t.conversationId)}`):t.type===`task_failed`?e(`/mcp-monitor`):t.type===`hitl_pending`?e(`/hitl`):t.type===`c2_session_online`&&e(`/c2-sessions`)},g=(0,j.jsxs)(`div`,{className:`cs-notification-panel`,children:[(0,j.jsxs)(`div`,{className:`cs-notification-head`,children:[(0,j.jsx)(da,{strong:!0,children:t(`notifications.title`,null,`通知`)}),(0,j.jsx)(m,{size:`small`,theme:`borderless`,onClick:ee,loading:d,children:t(`notifications.markAllRead`,null,`全部标记已读`)})]}),(0,j.jsxs)(`div`,{className:`cs-notification-list`,children:[i.length===0&&(0,j.jsx)(da,{type:`tertiary`,children:t(`notifications.empty`,null,`暂无新通知`)}),i.map(e=>(0,j.jsxs)(`button`,{type:`button`,className:`cs-notification-item`,onClick:()=>h(e),children:[(0,j.jsx)(`span`,{className:`cs-notification-dot level-${e.level||`p2`}`}),(0,j.jsxs)(`span`,{className:`cs-notification-body`,children:[(0,j.jsx)(`span`,{className:`cs-notification-title`,children:e.title||e.message||e.type}),(0,j.jsxs)(`span`,{className:`cs-notification-meta`,children:[e.ts?ji(e.ts):``,e.count>1?` · ×${e.count}`:``]})]})]},e.id||`${e.type}-${e.ts}`))]})]});return(0,j.jsx)(l,{content:g,trigger:`click`,position:`bottomRight`,visible:c,onVisibleChange:u,children:(0,j.jsx)(n,{count:o||null,overflowCount:99,type:`danger`,children:(0,j.jsx)(m,{theme:`borderless`,type:`tertiary`,icon:(0,j.jsx)(r,{}),"aria-label":t(`notifications.title`,null,`通知`)})})})}function va({navigate:e}){let{user:t,logout:n,refresh:r}=M(),a=P(),[o,s]=(0,O.useState)(!1),c=(0,O.useId)(),[l,u]=(0,O.useState)(null),[d,f]=(0,O.useState)(!1);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i,{trigger:`click`,position:`bottomRight`,menu:[{node:`title`,name:t?.display_name||t?.username||`admin`},{node:`item`,name:a(`auth.changePassword`,null,`修改密码`),icon:(0,j.jsx)(fe,{}),onClick:()=>s(!0)},{node:`item`,name:a(`auth.refreshSession`,null,`刷新会话权限`),onClick:()=>r().then(()=>Ui(a(`auth.sessionRefreshed`,null,`会话已刷新`))).catch(e=>Gi(e))},{node:`divider`},{node:`item`,name:a(`auth.logout`,null,`退出登录`),icon:(0,j.jsx)(T,{}),onClick:async()=>{await n(),e(`/dashboard`)}}],children:(0,j.jsxs)(m,{theme:`borderless`,type:`tertiary`,className:`cs-user-trigger`,"aria-label":a(`auth.userMenu`,null,`用户菜单`),children:[(0,j.jsx)(ae,{size:`extra-small`,color:`blue`,children:(t?.display_name||t?.username||`A`).slice(0,1).toUpperCase()}),(0,j.jsx)(`span`,{className:`cs-user-name`,children:t?.display_name||t?.username||`admin`})]})}),(0,j.jsx)(oa,{title:a(`auth.changePassword`,null,`修改密码`),visible:o,onCancel:()=>s(!1),formId:c,okText:a(`common.save`,null,`保存`),confirmLoading:d,width:420,children:(0,j.jsxs)(pe,{id:c,onSubmit:async e=>{f(!0);try{await A.post(`/auth/change-password`,{oldPassword:e.oldPassword,newPassword:e.newPassword}),Ui(a(`auth.passwordChanged`,null,`密码已更新`)),s(!1),l?.reset()}catch(e){Gi(e,a(`auth.changeFailed`,null,`修改密码失败`))}finally{f(!1)}},getFormApi:u,children:[(0,j.jsx)(pe.Input,{field:`oldPassword`,label:a(`auth.currentPassword`,null,`当前密码`),type:`password`,rules:[{required:!0,message:a(`auth.required`,null,`必填`)}]}),(0,j.jsx)(pe.Input,{field:`newPassword`,label:a(`auth.newPassword`,null,`新密码`),type:`password`,rules:[{required:!0,min:8,message:a(`auth.passwordMin`,null,`至少 8 位`)}]}),(0,j.jsx)(pe.Input,{field:`confirmPassword`,label:a(`auth.confirmPassword`,null,`确认新密码`),type:`password`,rules:[{required:!0,message:a(`auth.required`,null,`必填`)},{validator:(e,t)=>t===l?.getValue(`newPassword`),message:a(`auth.passwordMismatch`,null,`两次输入不一致`)}]})]})})]})}function ya(){let{session:e,hasPermission:t,hasAnyPermission:n}=M(),r=(0,O.useId)(),i=P(),a=D(),o=Le(),s=pa(),[l,u]=(0,O.useState)(()=>localStorage.getItem(`csai-nav-collapsed`)===`1`),[d,f]=(0,O.useState)(!1),[p,ee]=(0,O.useState)([]),h=a.pathname.replace(/^\//,``).split(`/`)[0]||`dashboard`,_=Dt(h),te=(0,O.useMemo)(()=>[h],[h]),v=(0,O.useMemo)(()=>ma(wt,i,t,n),[i,t,n]);(0,O.useEffect)(()=>{f(!1),_?.parent&&ee(e=>e.includes(_.parent)?e:[...e,_.parent])},[a.pathname,_?.parent]),(0,O.useEffect)(()=>{document.title=`${_?i(_.i18n,null,_.fallback):`工作台`} · CyberStrikeAI`},[_,i]);let ne=({itemKey:e})=>{let t=a.search,n=[`chat`,`vulnerabilities`,`settings`,`deep-assessments`].includes(e)&&h===e?t:``;o(`/${e}${n}`)},y=()=>{u(e=>(localStorage.setItem(`csai-nav-collapsed`,e?`0`:`1`),!e))},b=l&&!s,ie=!b&&e?.appVersion,ae=(0,j.jsxs)(`div`,{className:`cs-sidebar-inner ${b?`is-compact`:``}`,children:[(0,j.jsxs)(m,{className:`cs-brand`,theme:`borderless`,type:`tertiary`,onClick:()=>o(`/dashboard`),"aria-label":`CyberStrikeAI`,"aria-describedby":ie?r:void 0,children:[(0,j.jsx)(`img`,{src:`/static/logo.png`,alt:``,className:`cs-brand-logo`}),!b&&(0,j.jsxs)(`span`,{className:`cs-brand-copy`,children:[(0,j.jsxs)(`span`,{className:`cs-brand-name`,children:[`CyberStrike`,(0,j.jsx)(`span`,{children:`AI`})]}),ie&&(0,j.jsx)(`span`,{id:r,className:`cs-brand-version`,dir:`ltr`,title:`${i(`header.version`,null,`当前版本`)} ${ie}`,children:ie})]})]}),(0,j.jsx)(`div`,{className:`cs-nav-scroll`,children:Tt.map(e=>{let t=v.filter(t=>e.pages.includes(t.itemKey));return t.length?(0,j.jsxs)(`section`,{className:`cs-nav-section`,"aria-label":i(e.i18n,null,e.fallback),children:[!b&&(0,j.jsx)(`div`,{className:`cs-nav-section-label`,children:i(e.i18n,null,e.fallback)}),(0,j.jsx)(Ae,{className:`cs-nav`,style:{width:`100%`},items:t,selectedKeys:te,onSelect:ne,isCollapsed:b,subDropdownProps:fa,openKeys:p,onOpenChange:({openKeys:e})=>ee(e)})]},e.id):null})}),!s&&(0,j.jsx)(`div`,{className:`cs-nav-footer`,children:(0,j.jsx)(m,{theme:`borderless`,type:`tertiary`,block:!0,icon:b?(0,j.jsx)(he,{}):(0,j.jsx)(g,{}),"aria-label":i(b?`nav.expand`:`nav.collapse`,null,b?`展开菜单`:`收起菜单`),onClick:y,children:!b&&i(`nav.collapse`,null,`收起菜单`)})})]}),x=_?i(_.i18n,null,_.fallback):`CyberStrikeAI`,S=_?.parent?Dt(_.parent):null,oe=S?i(S.i18n,null,S.fallback):``;return(0,j.jsxs)(`div`,{className:`cs-shell ${l&&!s?`is-collapsed`:``}`,children:[!s&&(0,j.jsx)(`aside`,{className:`cs-sider`,children:ae}),s&&(0,j.jsx)(le,{visible:d,onCancel:()=>f(!1),placement:`left`,width:264,title:i(`nav.navigation`,null,`导航`),bodyStyle:{padding:0},className:`cs-mobile-nav`,children:ae}),(0,j.jsxs)(`div`,{className:`cs-main`,children:[(0,j.jsxs)(`header`,{className:`cs-header`,children:[(0,j.jsxs)(`div`,{className:`cs-header-left`,children:[s&&(0,j.jsx)(m,{theme:`borderless`,icon:(0,j.jsx)(ue,{}),onClick:()=>f(!0),"aria-label":i(`common.expandPanel`,null,`展开面板`)}),(0,j.jsxs)(re,{className:`cs-header-crumb`,compact:!1,children:[(0,j.jsx)(re.Item,{onClick:()=>o(`/dashboard`),children:i(`nav.groupWorkspace`,null,`工作台`)}),oe&&(0,j.jsx)(re.Item,{children:oe}),(0,j.jsx)(re.Item,{children:x})]})]}),(0,j.jsxs)(c,{className:`cs-header-actions`,spacing:4,children:[(0,j.jsx)(_a,{navigate:o}),(0,j.jsx)(ga,{}),(0,j.jsx)(ha,{}),(0,j.jsx)(va,{navigate:o})]})]}),(0,j.jsx)(`main`,{className:`cs-content ${h===`chat`?`cs-content-workspace`:``}`,id:`main-content`,children:(0,j.jsx)(Ie,{context:{navigate:o,pageId:h,mobile:s}})})]})]})}var{Title:ba,Text:xa,Paragraph:Sa}=S;function Ca(){let{login:e}=M(),t=P(),[n,r]=(0,O.useState)(!1),[i,a]=(0,O.useState)(``);async function o(n){r(!0),a(``);try{await e(n.username,n.password)}catch(e){a(et(e,t(`login.loginFailed`,null,`登录失败`)))}finally{r(!1)}}return(0,j.jsxs)(`main`,{className:`cs-login-page`,children:[(0,j.jsxs)(`section`,{className:`cs-login-story`,children:[(0,j.jsxs)(`div`,{className:`cs-login-brand`,children:[(0,j.jsx)(`img`,{src:`/static/logo.png`,alt:``,className:`cs-login-logo`}),(0,j.jsxs)(`span`,{className:`cs-brand-name`,children:[`CyberStrike`,(0,j.jsx)(`span`,{children:`AI`})]})]}),(0,j.jsxs)(`div`,{className:`cs-login-intro`,children:[(0,j.jsx)(`span`,{className:`cs-login-emblem`,"aria-hidden":`true`,children:(0,j.jsx)(Oe,{size:`extra-large`})}),(0,j.jsx)(ba,{heading:1,className:`cs-login-headline`,children:t(`login.headline`,null,`让每一次探索,都有据可循。`)}),(0,j.jsx)(Sa,{type:`tertiary`,children:t(`login.intro`,null,`从目标梳理到证据归档,在一个工作台中完成你的安全研究。`)}),(0,j.jsxs)(`div`,{className:`cs-login-features`,children:[(0,j.jsxs)(`div`,{className:`cs-login-feature`,children:[(0,j.jsx)(f,{size:`large`}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`strong`,{children:t(`login.projectTitle`,null,`围绕项目协作`)}),t(`login.projectHint`,null,`跨会话共享目标、上下文与研究进展`)]})]}),(0,j.jsxs)(`div`,{className:`cs-login-feature`,children:[(0,j.jsx)(ee,{size:`large`}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`strong`,{children:t(`login.assessmentTitle`,null,`让探索持续推进`)}),t(`login.assessmentHint`,null,`规划、执行与人工复核,始终保持可控`)]})]}),(0,j.jsxs)(`div`,{className:`cs-login-feature`,children:[(0,j.jsx)(x,{size:`large`}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`strong`,{children:t(`login.evidenceTitle`,null,`以证据支撑结论`)}),t(`login.evidenceHint`,null,`保留发现、来源与验收记录`)]})]})]})]}),(0,j.jsx)(xa,{type:`tertiary`,size:`small`,children:t(`login.platformTagline`,null,`AI 驱动的安全研究工作台`)})]}),(0,j.jsx)(`section`,{className:`cs-login-form-panel`,children:(0,j.jsxs)(te,{className:`cs-login-card`,bordered:!1,children:[(0,j.jsx)(ba,{heading:2,className:`cs-login-form-heading`,children:t(`login.welcome`,null,`欢迎回来`)}),(0,j.jsx)(xa,{type:`tertiary`,children:t(`login.welcomeHint`,null,`登录你的安全工作台,继续探索。`)}),(0,j.jsxs)(pe,{onSubmit:o,className:`cs-login-form`,children:[i&&(0,j.jsx)(je,{type:`danger`,description:i,closeIcon:null,className:`cs-error-banner`}),(0,j.jsx)(pe.Input,{field:`username`,label:t(`login.username`,null,`用户名`),prefix:(0,j.jsx)(Ce,{}),placeholder:t(`login.usernamePlaceholder`,null,`请输入用户名`),size:`large`,autoComplete:`username`,rules:[{required:!0,message:t(`login.usernameRequired`,null,`请输入用户名`)}]}),(0,j.jsx)(pe.Input,{field:`password`,label:t(`login.password`,null,`密码`),prefix:(0,j.jsx)(Se,{}),type:`password`,size:`large`,autoComplete:`current-password`,placeholder:t(`login.passwordPlaceholder`,null,`请输入密码`),rules:[{required:!0,message:t(`login.passwordRequired`,null,`请输入密码`)}]}),(0,j.jsx)(m,{htmlType:`submit`,theme:`solid`,type:`primary`,size:`large`,block:!0,loading:n,children:t(`login.submit`,null,`登录`)})]}),(0,j.jsx)(xa,{type:`tertiary`,className:`cs-login-note`,children:t(`login.authorizedOnly`,null,`仅在明确授权的范围内开展安全测试`)})]})})]})}var wa=`modulepreload`,Ta=function(e){return`/static/app/`+e},Ea={},Da=function(e){return e.pathname.endsWith(`.css`)},Oa=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},$=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=Ta(t,n);let r=s(t),i=Da(r);return Oa(Ea,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:wa,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},ka={dashboard:(0,O.lazy)(()=>$(()=>import(`./dashboard-D0Gj_VvA.js`),__vite__mapDeps([0,1,2,3,4,5]))),chat:(0,O.lazy)(()=>$(()=>import(`./chat-DvMikSKw.js`),__vite__mapDeps([6,1,2,3,4,7,8,9]))),"deep-assessments":(0,O.lazy)(()=>$(()=>import(`./deep-assessments-DBf-B00i.js`),__vite__mapDeps([10,1,2,3,4,8,7,11]))),hitl:(0,O.lazy)(()=>$(()=>import(`./hitl-D4yWTtt-.js`),__vite__mapDeps([12,1,2,3,4,13]))),"tool-guard":(0,O.lazy)(()=>$(()=>import(`./tool-guard-C1gYGedw.js`),__vite__mapDeps([14,1,2,3,4,15]))),projects:(0,O.lazy)(()=>$(()=>import(`./projects-DSC8ZgPs.js`),__vite__mapDeps([16,1,2,3,4,7,17]))),"asset-overview":(0,O.lazy)(()=>$(()=>import(`./asset-overview-BWCv3vZq.js`),__vite__mapDeps([18,1,2,3,4,19,20]))),"asset-library":(0,O.lazy)(()=>$(()=>import(`./asset-library-IxsQ4-c7.js`),__vite__mapDeps([21,1,2,3,4,19,22]))),"info-collect":(0,O.lazy)(()=>$(()=>import(`./info-collect-BzmoQvla.js`),__vite__mapDeps([23,1,2,3,4,19,24]))),vulnerabilities:(0,O.lazy)(()=>$(()=>import(`./vulnerabilities-C-hePmba.js`),__vite__mapDeps([25,1,2,3,4,26]))),tasks:(0,O.lazy)(()=>$(()=>import(`./tasks-BdwIaYpM.js`),__vite__mapDeps([27,1,2,3,4,28]))),workflows:(0,O.lazy)(()=>$(()=>import(`./workflows-BD0hFUmU.js`),__vite__mapDeps([29,1,2,3,4,30]))),webshell:(0,O.lazy)(()=>$(()=>import(`./webshell-ByRhMULc.js`),__vite__mapDeps([31,1,2,3,4,32]))),"c2-listeners":(0,O.lazy)(()=>$(()=>import(`./c2-listeners-dPhhN-if.js`),__vite__mapDeps([33,1,2,3,4,34,35,36,37]))),"c2-sessions":(0,O.lazy)(()=>$(()=>import(`./c2-sessions-TyC9bZaJ.js`),__vite__mapDeps([38,1,2,3,4,34,35,36,39]))),"c2-tasks":(0,O.lazy)(()=>$(()=>import(`./c2-tasks-BVR8FzK0.js`),__vite__mapDeps([40,1,2,3,4,34,35,36,41]))),"c2-payloads":(0,O.lazy)(()=>$(()=>import(`./c2-payloads-B7lfPd_-.js`),__vite__mapDeps([42,1,2,3,4,34,35,36,43]))),"c2-events":(0,O.lazy)(()=>$(()=>import(`./c2-events-DRz3plo4.js`),__vite__mapDeps([44,1,2,3,4,34,35,36,45]))),"c2-profiles":(0,O.lazy)(()=>$(()=>import(`./c2-profiles-BEwdqcm8.js`),__vite__mapDeps([46,1,2,3,4,34,35,47]))),"chat-files":(0,O.lazy)(()=>$(()=>import(`./chat-files-B-UzzQPb.js`),__vite__mapDeps([48,1,2,3,4,49]))),"mcp-monitor":(0,O.lazy)(()=>$(()=>import(`./mcp-monitor-Dd86uZML.js`),__vite__mapDeps([50,1,2,3,4,51]))),"mcp-management":(0,O.lazy)(()=>$(()=>import(`./mcp-management-BJ29mUCm.js`),__vite__mapDeps([52,1,2,3,4,53]))),"knowledge-retrieval-logs":(0,O.lazy)(()=>$(()=>import(`./knowledge-retrieval-logs-BLDiNz53.js`),__vite__mapDeps([54,1,2,3,4]))),"knowledge-management":(0,O.lazy)(()=>$(()=>import(`./knowledge-management-9curLpIK.js`),__vite__mapDeps([55,1,2,3,4]))),"skills-monitor":(0,O.lazy)(()=>$(()=>import(`./skills-monitor-CDBoFfMC.js`),__vite__mapDeps([56,1,3,2,4]))),"skills-management":(0,O.lazy)(()=>$(()=>import(`./skills-management-LgaUlqmE.js`),__vite__mapDeps([57,1,2,3,4]))),"agents-management":(0,O.lazy)(()=>$(()=>import(`./agents-management-DZvmdp-D.js`),__vite__mapDeps([58,1,2,3,4]))),"roles-management":(0,O.lazy)(()=>$(()=>import(`./roles-management-BY9GENyG.js`),__vite__mapDeps([59,1,2,3,4]))),"platform-rbac":(0,O.lazy)(()=>$(()=>import(`./platform-rbac-CTE3UjWt.js`),__vite__mapDeps([60,1,2,3,4]))),settings:(0,O.lazy)(()=>$(()=>import(`./settings-DmYw0tf_.js`),__vite__mapDeps([61,1,2,3,4,8,62]))),"api-docs":(0,O.lazy)(()=>$(()=>import(`./api-docs-CUn7eCAU.js`),__vite__mapDeps([63,1,2,3,4,64])))},{Title:Aa,Text:ja}=S;function Ma(){return(0,j.jsx)(`div`,{className:`cs-page-loading`,children:(0,j.jsx)(ie,{size:`large`})})}function Na({code:e,title:t,description:n}){return(0,j.jsxs)(`div`,{className:`cs-page-loading`,style:{flexDirection:`column`,gap:8},children:[(0,j.jsx)(Aa,{heading:2,style:{margin:0},children:e}),(0,j.jsx)(ja,{strong:!0,children:t}),n&&(0,j.jsx)(ja,{type:`tertiary`,children:n})]})}function Pa(){let{pageId:e}=He(),{hasPermission:t,hasAnyPermission:n}=M(),r=P(),i=Dt(e),a=e?ka[e]:null,o=(0,O.useMemo)(()=>{if(!i)return!0;if(i.anyPermission)return n(i.anyPermission);if(i.permission)return t(i.permission);let e=i.parent?Dt(i.parent):null;return!e?.anyPermission||n(e.anyPermission)},[i,t,n]);return i?a?o?(0,j.jsx)(O.Suspense,{fallback:(0,j.jsx)(Ma,{}),children:(0,j.jsx)(a,{})}):(0,j.jsx)(Na,{code:`403`,title:r(`common.forbidden`,null,`当前账号没有访问该页面的权限`)}):(0,j.jsx)(Na,{code:`404`,title:i.fallback,description:r(`common.pagePending`,null,`页面尚未注册`)}):(0,j.jsx)(Na,{code:`404`,title:r(`common.pageNotFound`,null,`页面不存在`)})}function Fa(){let{authenticated:e,checking:t}=M();return t?(0,j.jsx)(Ma,{}):e?(0,j.jsx)(ze,{children:(0,j.jsxs)(Be,{element:(0,j.jsx)(ya,{}),children:[(0,j.jsx)(Be,{path:`/`,element:(0,j.jsx)(Fe,{to:`/dashboard`,replace:!0})}),(0,j.jsx)(Be,{path:`/system-update`,element:(0,j.jsx)(Fe,{to:`/settings?section=update`,replace:!0})}),(0,j.jsx)(Be,{path:`/:pageId`,element:(0,j.jsx)(Pa,{})}),(0,j.jsx)(Be,{path:`*`,element:(0,j.jsx)(Fe,{to:`/dashboard`,replace:!0})})]})}):(0,j.jsx)(Ca,{})}var Ia={"zh-CN":u,"en-US":we,"ru-RU":ye,"ar-SA":De};function La(){let{lang:e}=mt();return(0,j.jsx)(ge,{locale:Ia[e]||u,direction:e===`ar-SA`?`rtl`:`ltr`,children:(0,j.jsx)(rt,{children:(0,j.jsx)(Re,{children:(0,j.jsx)(Fa,{})})})})}(0,Ue.createRoot)(document.getElementById(`root`)).render((0,j.jsx)(O.StrictMode,{children:(0,j.jsx)(St,{children:(0,j.jsx)(pt,{children:(0,j.jsx)(La,{})})})}));export{zi as A,k as B,ki as C,Fi as D,ji as E,M as F,A as I,Qe as L,N as M,mt as N,Ii as O,P,et as R,Wi as S,Pi as T,Ji as _,sa as a,Gi as b,oa as c,ra as d,ta as f,Yi as g,Qi as h,ua as i,Ct as j,Ni as k,Zi as l,qi as m,ca as n,ea as o,Ki as p,la as r,Xi as s,$ as t,na as u,$i as v,Di as w,Ui as x,ia as y,$e as z};
\ No newline at end of file
diff --git a/web/static/app/assets/info-collect-BNimgyDP.js b/web/static/app/assets/info-collect-BzmoQvla.js
similarity index 99%
rename from web/static/app/assets/info-collect-BNimgyDP.js
rename to web/static/app/assets/info-collect-BzmoQvla.js
index f944df7d..0e971fba 100644
--- a/web/static/app/assets/info-collect-BNimgyDP.js
+++ b/web/static/app/assets/info-collect-BzmoQvla.js
@@ -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,Ot as o,T as s,U as c,W as l,_ as u,at as d,b as f,f as p,ot as m,u as h,v as g,x as _,z as v}from"./semi-CXF9U6uC.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-CrDogtQS.js";import{a as E,h as D,i as O,o as k}from"./assetTarget-EXnMPa2I.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 M(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 ue(e,t){let n=new Set(t.map(Number));return(e||[]).filter((e,t)=>n.has(t))}var N=e(n(),1),{Text:P}=l;function F(e){if(e==null||e===``)return(0,N.jsx)(P,{type:`tertiary`,children:`—`});let t=Array.isArray(e)?e.join(`, `):typeof e==`object`?JSON.stringify(e):String(e);return(0,N.jsx)(D,{text:t,max:44})}function I(e,t){let n=M(e,t);return n?/^https?:\/\//i.test(n)?(0,N.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:`info-collect-target-link`,children:(0,N.jsx)(D,{text:n,max:44})}):(0,N.jsx)(D,{text:n,max:44}):(0,N.jsx)(P,{type:`tertiary`,children:`—`})}function de({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)=>I(t,l)},...u.map(e=>({title:e,dataIndex:e,render:(t,n)=>F(n[e])})),{title:c(`common.actions`,null,`操作`),dataIndex:`__actions`,width:90,render:(e,t)=>(0,N.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,N.jsx)(T,{columns:d,dataSource:f,rowKey:`__key`,loading:s,pagination:!1,rowSelection:{selectedRowKeys:r,onChange:e=>i(e)},emptyText:c(`infoCollect.noResults`,null,`暂无结果`)})}var{Text:L}=l;function fe({visible:e,provider:t,text:n,onClose:i,onApply:o}){let s=b(),[l,u]=(0,A.useState)(!1),[d,f]=(0,A.useState)(null),[p,m]=(0,A.useState)(null),[h,g]=(0,A.useState)(``),[ee,x]=(0,A.useState)(0);(0,A.useEffect)(()=>{if(!e)return;let r=String(n||``).trim();if(!r)return;let i=!1;return u(!0),f(null),m(null),g(``),y.post(`/fofa/parse`,{provider:t,text:r}).then(e=>{i||(m(e||{}),g(String(e?.query||``)))}).catch(e=>{i||f(e)}).finally(()=>{i||u(!1)}),()=>{i=!0}},[e,t,n,ee]);let S=e=>{let t=String(h||``).trim();t&&o?.(t,!!e)},w=Array.isArray(p?.warnings)?p.warnings.filter(Boolean):[];return(0,N.jsx)(C,{visible:e,title:s(`infoCollect.parseResultTitle`,null,`语法解析结果`),width:640,onCancel:i,footer:(0,N.jsxs)(r,{children:[(0,N.jsx)(a,{theme:`borderless`,onClick:i,children:s(`common.cancel`,null,`取消`)}),(0,N.jsx)(a,{onClick:()=>S(!1),disabled:!h.trim()||l,children:s(`infoCollect.parseModalApply`,null,`填入查询框`)}),(0,N.jsx)(a,{theme:`solid`,type:`primary`,onClick:()=>S(!0),disabled:!h.trim()||l,children:s(`infoCollect.parseModalApplyRun`,null,`填入并查询`)})]}),children:(0,N.jsxs)(r,{vertical:!0,align:`start`,spacing:10,style:{width:`100%`},children:[(0,N.jsxs)(L,{type:`tertiary`,children:[s(`infoCollect.naturalLanguageLabel`,null,`自然语言`),`:`,String(n||``).trim()||`—`]}),l&&(0,N.jsxs)(r,{children:[(0,N.jsx)(c,{size:`small`}),(0,N.jsx)(L,{type:`tertiary`,children:s(`infoCollect.parsePending`,null,`正在解析,请稍候…`)})]}),(0,N.jsx)(ne,{error:d,onRetry:()=>x(e=>e+1)}),p&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(_,{value:h,rows:3,className:`info-collect-parse-query`,onChange:g}),p.explanation&&(0,N.jsxs)(`div`,{className:`info-collect-parse-block`,children:[(0,N.jsx)(L,{strong:!0,size:`small`,children:s(`infoCollect.explanation`,null,`字段映射说明`)}),(0,N.jsx)(L,{type:`tertiary`,size:`small`,children:p.explanation})]}),w.length>0&&(0,N.jsx)(v,{type:`warning`,bordered:!0,closeIcon:null,description:w.join(`;`)})]})]})})}function R(e,t,n){if(e&&!Array.isArray(e)&&typeof e==`object`){let t=e[n];return Array.isArray(t)?t.filter(Boolean).join(`,`):t==null?``:String(t).trim()}let r=Array.isArray(t)?t.indexOf(n):-1;if(r<0||!Array.isArray(e))return``;let i=e[r];return i==null?``:String(i).trim()}function z(e,t,n){for(let r of n){let n=R(e,t,r);if(n)return n}return``}function B(e,t,n=`fofa`){let r=Number.parseInt(R(e,t,`port`),10),i=z(e,t,[`ip`,`ip_str`]),a=O(i)||E(i)?i.toLowerCase():``,o=z(e,t,[`domain`,`hostname`,`hostnames`,`domains`]).split(`,`)[0].replace(/^\[|\]$/g,``).replace(/^"|"$/g,``),s=o&&!O(o)&&!E(o)?k(o):``,c=z(e,t,[`protocol`,`service.name`,`transport`]).toLowerCase();return{host:z(e,t,[`host`,`hostname`]).split(`,`)[0].trim(),ip:a,port:Number.isFinite(r)?r:0,domain:s,protocol:/^[a-z][a-z0-9+.-]{0,31}$/.test(c)?c:``,title:z(e,t,[`title`,`service.http.title`]),server:z(e,t,[`server`,`product`]),country:z(e,t,[`country`,`location.country_cn`,`location.country_name`]),province:z(e,t,[`region`,`province`,`location.province_cn`]),city:z(e,t,[`city`,`location.city_cn`,`location.city`]),source:n||`fofa`,status:`active`}}async function pe(e,{fields:t,provider:n,query:r}){let i=(e||[]).map(e=>B(e,t,n)),a=i.filter(e=>e.host||e.ip||e.domain),o=i.length-a.length;if(!a.length)return{assets:a,invalidCount:o,created:0,updated:0,skipped:0};let s=await y.post(`/assets/import`,{assets:a,source:n||`fofa`,source_query:r||``});return{assets:a,invalidCount:o,created:Number(s?.created||0),updated:Number(s?.updated||0),skipped:Number(s?.skipped||0)}}var{Text:V}=l,me=`csf.info-collect.form`,H={provider:`fofa`,query:``,size:100,fields:j.fofa.defaultFields,full:!1};function U(){let e=b(),{hasPermission:t}=ee(),n=t(`fofa:execute`),c=t(`asset:write`),[l,C]=te(me,H),[T,E]=(0,A.useState)(``),[D,O]=(0,A.useState)(!1),[k,j]=(0,A.useState)(null),[P,F]=(0,A.useState)(!1),[I,L]=(0,A.useState)(null),[R,z]=(0,A.useState)([]),[B,U]=(0,A.useState)([]),[W,he]=(0,A.useState)(null),[ge,_e]=(0,A.useState)(!1),G=ce(l.provider),ve=G.label;(0,A.useEffect)(()=>{U([]),z([]),j(null),L(null)},[l.provider]);let K=e=>C(t=>({...H,...t,...e})),ye=e=>{let t=ce(e);K({provider:e,fields:t.defaultFields,size:Math.min(Number(l.size||100),t.maxSize),full:!1})},q=Math.min(Math.max(Number(l.size||100),1),G.maxSize),J=async(t=1,r)=>{if(!n){x(e(`infoCollect.permissionDenied`,null,`当前账号没有 fofa:execute 权限`));return}let i=String(r??l.query??``).trim();if(!i)x(e(`infoCollect.enterFofaQuery`,null,`请输入查询语法`));else{F(!0),L(null);try{let e=await y.post(`/fofa/search`,{provider:l.provider,query:i,size:q,page:t,fields:l.fields,full:!!l.full});j(e),z([]),U(le(e?.fields||[],5))}catch(e){L(e),j(null)}finally{F(!1)}}},be=()=>{C({...H}),j(null),L(null),z([]),U([]),E(``)},Y=Array.isArray(k?.fields)?k.fields:[],X=Array.isArray(k?.results)?k.results:[],Z=Number(k?.total||0),Q=Number(k?.size||q),$=Number(k?.page||1),xe=async()=>{if(ge)return;if(!c){x(e(`infoCollect.noImportPermission`,null,`当前账号没有 asset:write 权限`));return}if(!R.length){x(e(`infoCollect.selectRowsFirst`,null,`请先选择需要入库的结果`));return}let t=ue(X,R);_e(!0);try{let n=await pe(t,{fields:Y,provider:k?.provider||l.provider,query:k?.query||l.query});if(!n.assets.length){x(e(`assets.noValidImportTarget`,null,`所选结果中没有可入库的有效资产目标`));return}let r=n.invalidCount?e(`assets.importDoneWithInvalid`,{created:n.created,updated:n.updated,invalid:n.invalidCount},`已新增 ${n.created} 条,更新 ${n.updated} 条,跳过 ${n.invalidCount} 条无有效目标的结果`):e(`assets.importDone`,{created:n.created,updated:n.updated},`已新增 ${n.created} 条,更新 ${n.updated} 条`);oe(r),z([])}catch(t){S(t,e(`assets.importFailed`,null,`资产入库失败`))}finally{_e(!1)}},Se=(e,t)=>{K({query:e}),O(!1),t&&J(1,e)},Ce=(0,A.useMemo)(()=>W?Y.map(e=>{let t=W[e];return{label:e,value:Array.isArray(t)?t.join(`, `):t==null?`—`:String(t)}}):[],[W,Y]),we=k?e(`infoCollect.resultsMeta`,{total:Z,count:X.length,page:$,size:Q},`${ve} · 共 ${Z} 条 · 第 ${$} 页 · 每页 ${Q} 条 · 返回 ${X.length} 条`):``;return(0,N.jsxs)(`div`,{className:`info-collect-page`,children:[(0,N.jsx)(ie,{title:e(`infoCollectPage.title`,null,`信息收集`),description:`使用 FOFA 等空间测绘语法检索资产,并把结果直接入库。`,extra:(0,N.jsxs)(r,{children:[(0,N.jsx)(a,{icon:(0,N.jsx)(m,{}),onClick:()=>{k&&J($)},children:e(`common.refresh`,null,`刷新`)}),(0,N.jsx)(a,{onClick:be,children:e(`infoCollectPage.reset`,null,`重置`)})]})}),!n&&(0,N.jsx)(v,{type:`warning`,bordered:!0,closeIcon:null,className:`info-collect-permission`,description:e(`infoCollect.permissionDeniedHint`,null,`当前账号没有 fofa:execute 权限:查询、列字段与入库操作不可用,请联系管理员授权。`)}),(0,N.jsx)(ne,{error:I,onRetry:()=>J($)}),(0,N.jsx)(re,{title:e(`infoCollectPage.fofaQuerySyntax`,null,`查询语法`),children:(0,N.jsxs)(`div`,{className:`info-collect-form`,children:[(0,N.jsxs)(r,{className:`info-collect-form-row`,children:[(0,N.jsx)(g,{value:l.provider,optionList:se,onChange:ye,style:{width:150}}),(0,N.jsxs)(`span`,{className:`info-collect-size`,children:[(0,N.jsx)(V,{type:`tertiary`,size:`small`,children:e(`infoCollectPage.returnCount`,null,`返回数量`)}),(0,N.jsx)(f,{value:q,min:1,max:G.maxSize,onChange:e=>K({size:e}),style:{width:120}})]}),(0,N.jsx)(h,{checked:!!l.full,disabled:!G.supportsFull,onChange:e=>K({full:e})}),(0,N.jsx)(V,{type:`tertiary`,size:`small`,children:`full`}),(0,N.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,N.jsx)(d,{}),onClick:()=>J(1),loading:P,disabled:!n,children:e(`infoCollectPage.confirm`,null,`查询`)}),(0,N.jsx)(a,{disabled:!T.trim()||!n,onClick:()=>O(!0),title:e(`infoCollectPage.parseBtnTitle`,null,`将自然语言解析为查询语法`),children:e(`infoCollectPage.parseBtn`,null,`AI 解析`)})]}),(0,N.jsx)(_,{value:l.query,rows:3,placeholder:`${ve}:${G.placeholder}`,className:`info-collect-query`,onChange:e=>K({query:e})}),(0,N.jsxs)(r,{wrap:!0,className:`info-collect-presets`,children:[(0,N.jsxs)(V,{type:`tertiary`,size:`small`,children:[e(`infoCollectPage.fillExample`,null,`示例`),`:`]}),G.queryPresets.map(([e,t])=>(0,N.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>K({query:t}),children:e},e))]}),(0,N.jsxs)(r,{className:`info-collect-form-row`,children:[(0,N.jsx)(V,{type:`tertiary`,size:`small`,children:e(`infoCollectPage.returnFields`,null,`返回字段`)}),(0,N.jsx)(i,{value:l.fields,onChange:e=>K({fields:e}),className:`info-collect-fields`,style:{width:420}}),G.fieldPresets.map(([e,t])=>(0,N.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>K({fields:t}),children:e},e))]}),(0,N.jsx)(_,{value:T,rows:2,placeholder:e(`infoCollectPage.nlPlaceholder`,null,`自然语言:例如 找中国 Apache 站点,标题包含登录`),className:`info-collect-natural`,onChange:E})]})}),(0,N.jsxs)(re,{title:e(`infoCollectPage.queryResults`,null,`查询结果`),extra:(0,N.jsxs)(r,{children:[(0,N.jsx)(V,{type:`tertiary`,size:`small`,children:we}),(0,N.jsx)(g,{multiple:!0,value:B,optionList:Y.map(e=>({value:e,label:e})),disabled:!Y.length,placeholder:e(`infoCollectPage.showColumns`,null,`显示字段`),maxTagCount:5,style:{minWidth:220},onChange:e=>{let t=(e||[]).slice(0,5);(e||[]).length>5&&x(`最多显示 5 个字段`),U(t)}}),(0,N.jsx)(a,{icon:(0,N.jsx)(o,{}),disabled:!c||!R.length,loading:ge,onClick:xe,children:e(`assets.importSelected`,null,`入库所选`)})]}),children:[k?.warning&&(0,N.jsx)(v,{type:`warning`,bordered:!0,closeIcon:null,className:`info-collect-warning`,description:k.warning}),!k&&!P&&!I?(0,N.jsx)(s,{title:e(`infoCollect.noResults`,null,`暂无结果`),description:n?`输入查询语法后点击“查询”。`:`当前账号缺少 fofa:execute 权限。`,style:{padding:40}}):(0,N.jsx)(de,{fields:Y,results:X,visibleFields:B,selectedKeys:R,onSelectionChange:z,onOpenDetail:he,loading:P}),k&&Z>Q&&(0,N.jsx)(`div`,{className:`info-collect-pagination`,children:(0,N.jsx)(u,{total:Z,pageSize:Q,currentPage:$,onPageChange:e=>J(e),showTotal:!0})}),k&&(0,N.jsx)(V,{type:`tertiary`,size:`small`,className:`info-collect-selected-meta`,children:e(`infoCollectPage.selectedRows`,{count:R.length},`已选择 ${R.length} 条`)})]}),(0,N.jsx)(p,{visible:!!W,onCancel:()=>he(null),title:e(`infoCollect.detailTitle`,null,`结果详情`),width:600,placement:`right`,children:W&&(0,N.jsxs)(`div`,{className:`info-collect-detail`,children:[(0,N.jsx)(V,{strong:!0,children:M(W,Y)||`—`}),(0,N.jsx)(w,{items:Ce,columns:1}),(0,N.jsx)(ae,{value:W,title:`原始 JSON`})]})}),(0,N.jsx)(fe,{visible:D,provider:l.provider,text:T,onClose:()=>O(!1),onApply:Se})]})}export{U as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,Ot as o,T as s,U as c,W as l,_ as u,at as d,b as f,f as p,ot as m,u as h,v as g,x as _,z as v}from"./semi-CXF9U6uC.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-LQJrYSgy.js";import{a as E,h as D,i as O,o as k}from"./assetTarget-EXnMPa2I.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 M(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 ue(e,t){let n=new Set(t.map(Number));return(e||[]).filter((e,t)=>n.has(t))}var N=e(n(),1),{Text:P}=l;function F(e){if(e==null||e===``)return(0,N.jsx)(P,{type:`tertiary`,children:`—`});let t=Array.isArray(e)?e.join(`, `):typeof e==`object`?JSON.stringify(e):String(e);return(0,N.jsx)(D,{text:t,max:44})}function I(e,t){let n=M(e,t);return n?/^https?:\/\//i.test(n)?(0,N.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:`info-collect-target-link`,children:(0,N.jsx)(D,{text:n,max:44})}):(0,N.jsx)(D,{text:n,max:44}):(0,N.jsx)(P,{type:`tertiary`,children:`—`})}function de({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)=>I(t,l)},...u.map(e=>({title:e,dataIndex:e,render:(t,n)=>F(n[e])})),{title:c(`common.actions`,null,`操作`),dataIndex:`__actions`,width:90,render:(e,t)=>(0,N.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,N.jsx)(T,{columns:d,dataSource:f,rowKey:`__key`,loading:s,pagination:!1,rowSelection:{selectedRowKeys:r,onChange:e=>i(e)},emptyText:c(`infoCollect.noResults`,null,`暂无结果`)})}var{Text:L}=l;function fe({visible:e,provider:t,text:n,onClose:i,onApply:o}){let s=b(),[l,u]=(0,A.useState)(!1),[d,f]=(0,A.useState)(null),[p,m]=(0,A.useState)(null),[h,g]=(0,A.useState)(``),[ee,x]=(0,A.useState)(0);(0,A.useEffect)(()=>{if(!e)return;let r=String(n||``).trim();if(!r)return;let i=!1;return u(!0),f(null),m(null),g(``),y.post(`/fofa/parse`,{provider:t,text:r}).then(e=>{i||(m(e||{}),g(String(e?.query||``)))}).catch(e=>{i||f(e)}).finally(()=>{i||u(!1)}),()=>{i=!0}},[e,t,n,ee]);let S=e=>{let t=String(h||``).trim();t&&o?.(t,!!e)},w=Array.isArray(p?.warnings)?p.warnings.filter(Boolean):[];return(0,N.jsx)(C,{visible:e,title:s(`infoCollect.parseResultTitle`,null,`语法解析结果`),width:640,onCancel:i,footer:(0,N.jsxs)(r,{children:[(0,N.jsx)(a,{theme:`borderless`,onClick:i,children:s(`common.cancel`,null,`取消`)}),(0,N.jsx)(a,{onClick:()=>S(!1),disabled:!h.trim()||l,children:s(`infoCollect.parseModalApply`,null,`填入查询框`)}),(0,N.jsx)(a,{theme:`solid`,type:`primary`,onClick:()=>S(!0),disabled:!h.trim()||l,children:s(`infoCollect.parseModalApplyRun`,null,`填入并查询`)})]}),children:(0,N.jsxs)(r,{vertical:!0,align:`start`,spacing:10,style:{width:`100%`},children:[(0,N.jsxs)(L,{type:`tertiary`,children:[s(`infoCollect.naturalLanguageLabel`,null,`自然语言`),`:`,String(n||``).trim()||`—`]}),l&&(0,N.jsxs)(r,{children:[(0,N.jsx)(c,{size:`small`}),(0,N.jsx)(L,{type:`tertiary`,children:s(`infoCollect.parsePending`,null,`正在解析,请稍候…`)})]}),(0,N.jsx)(ne,{error:d,onRetry:()=>x(e=>e+1)}),p&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(_,{value:h,rows:3,className:`info-collect-parse-query`,onChange:g}),p.explanation&&(0,N.jsxs)(`div`,{className:`info-collect-parse-block`,children:[(0,N.jsx)(L,{strong:!0,size:`small`,children:s(`infoCollect.explanation`,null,`字段映射说明`)}),(0,N.jsx)(L,{type:`tertiary`,size:`small`,children:p.explanation})]}),w.length>0&&(0,N.jsx)(v,{type:`warning`,bordered:!0,closeIcon:null,description:w.join(`;`)})]})]})})}function R(e,t,n){if(e&&!Array.isArray(e)&&typeof e==`object`){let t=e[n];return Array.isArray(t)?t.filter(Boolean).join(`,`):t==null?``:String(t).trim()}let r=Array.isArray(t)?t.indexOf(n):-1;if(r<0||!Array.isArray(e))return``;let i=e[r];return i==null?``:String(i).trim()}function z(e,t,n){for(let r of n){let n=R(e,t,r);if(n)return n}return``}function B(e,t,n=`fofa`){let r=Number.parseInt(R(e,t,`port`),10),i=z(e,t,[`ip`,`ip_str`]),a=O(i)||E(i)?i.toLowerCase():``,o=z(e,t,[`domain`,`hostname`,`hostnames`,`domains`]).split(`,`)[0].replace(/^\[|\]$/g,``).replace(/^"|"$/g,``),s=o&&!O(o)&&!E(o)?k(o):``,c=z(e,t,[`protocol`,`service.name`,`transport`]).toLowerCase();return{host:z(e,t,[`host`,`hostname`]).split(`,`)[0].trim(),ip:a,port:Number.isFinite(r)?r:0,domain:s,protocol:/^[a-z][a-z0-9+.-]{0,31}$/.test(c)?c:``,title:z(e,t,[`title`,`service.http.title`]),server:z(e,t,[`server`,`product`]),country:z(e,t,[`country`,`location.country_cn`,`location.country_name`]),province:z(e,t,[`region`,`province`,`location.province_cn`]),city:z(e,t,[`city`,`location.city_cn`,`location.city`]),source:n||`fofa`,status:`active`}}async function pe(e,{fields:t,provider:n,query:r}){let i=(e||[]).map(e=>B(e,t,n)),a=i.filter(e=>e.host||e.ip||e.domain),o=i.length-a.length;if(!a.length)return{assets:a,invalidCount:o,created:0,updated:0,skipped:0};let s=await y.post(`/assets/import`,{assets:a,source:n||`fofa`,source_query:r||``});return{assets:a,invalidCount:o,created:Number(s?.created||0),updated:Number(s?.updated||0),skipped:Number(s?.skipped||0)}}var{Text:V}=l,me=`csf.info-collect.form`,H={provider:`fofa`,query:``,size:100,fields:j.fofa.defaultFields,full:!1};function U(){let e=b(),{hasPermission:t}=ee(),n=t(`fofa:execute`),c=t(`asset:write`),[l,C]=te(me,H),[T,E]=(0,A.useState)(``),[D,O]=(0,A.useState)(!1),[k,j]=(0,A.useState)(null),[P,F]=(0,A.useState)(!1),[I,L]=(0,A.useState)(null),[R,z]=(0,A.useState)([]),[B,U]=(0,A.useState)([]),[W,he]=(0,A.useState)(null),[ge,_e]=(0,A.useState)(!1),G=ce(l.provider),ve=G.label;(0,A.useEffect)(()=>{U([]),z([]),j(null),L(null)},[l.provider]);let K=e=>C(t=>({...H,...t,...e})),ye=e=>{let t=ce(e);K({provider:e,fields:t.defaultFields,size:Math.min(Number(l.size||100),t.maxSize),full:!1})},q=Math.min(Math.max(Number(l.size||100),1),G.maxSize),J=async(t=1,r)=>{if(!n){x(e(`infoCollect.permissionDenied`,null,`当前账号没有 fofa:execute 权限`));return}let i=String(r??l.query??``).trim();if(!i)x(e(`infoCollect.enterFofaQuery`,null,`请输入查询语法`));else{F(!0),L(null);try{let e=await y.post(`/fofa/search`,{provider:l.provider,query:i,size:q,page:t,fields:l.fields,full:!!l.full});j(e),z([]),U(le(e?.fields||[],5))}catch(e){L(e),j(null)}finally{F(!1)}}},be=()=>{C({...H}),j(null),L(null),z([]),U([]),E(``)},Y=Array.isArray(k?.fields)?k.fields:[],X=Array.isArray(k?.results)?k.results:[],Z=Number(k?.total||0),Q=Number(k?.size||q),$=Number(k?.page||1),xe=async()=>{if(ge)return;if(!c){x(e(`infoCollect.noImportPermission`,null,`当前账号没有 asset:write 权限`));return}if(!R.length){x(e(`infoCollect.selectRowsFirst`,null,`请先选择需要入库的结果`));return}let t=ue(X,R);_e(!0);try{let n=await pe(t,{fields:Y,provider:k?.provider||l.provider,query:k?.query||l.query});if(!n.assets.length){x(e(`assets.noValidImportTarget`,null,`所选结果中没有可入库的有效资产目标`));return}let r=n.invalidCount?e(`assets.importDoneWithInvalid`,{created:n.created,updated:n.updated,invalid:n.invalidCount},`已新增 ${n.created} 条,更新 ${n.updated} 条,跳过 ${n.invalidCount} 条无有效目标的结果`):e(`assets.importDone`,{created:n.created,updated:n.updated},`已新增 ${n.created} 条,更新 ${n.updated} 条`);oe(r),z([])}catch(t){S(t,e(`assets.importFailed`,null,`资产入库失败`))}finally{_e(!1)}},Se=(e,t)=>{K({query:e}),O(!1),t&&J(1,e)},Ce=(0,A.useMemo)(()=>W?Y.map(e=>{let t=W[e];return{label:e,value:Array.isArray(t)?t.join(`, `):t==null?`—`:String(t)}}):[],[W,Y]),we=k?e(`infoCollect.resultsMeta`,{total:Z,count:X.length,page:$,size:Q},`${ve} · 共 ${Z} 条 · 第 ${$} 页 · 每页 ${Q} 条 · 返回 ${X.length} 条`):``;return(0,N.jsxs)(`div`,{className:`info-collect-page`,children:[(0,N.jsx)(ie,{title:e(`infoCollectPage.title`,null,`信息收集`),description:`使用 FOFA 等空间测绘语法检索资产,并把结果直接入库。`,extra:(0,N.jsxs)(r,{children:[(0,N.jsx)(a,{icon:(0,N.jsx)(m,{}),onClick:()=>{k&&J($)},children:e(`common.refresh`,null,`刷新`)}),(0,N.jsx)(a,{onClick:be,children:e(`infoCollectPage.reset`,null,`重置`)})]})}),!n&&(0,N.jsx)(v,{type:`warning`,bordered:!0,closeIcon:null,className:`info-collect-permission`,description:e(`infoCollect.permissionDeniedHint`,null,`当前账号没有 fofa:execute 权限:查询、列字段与入库操作不可用,请联系管理员授权。`)}),(0,N.jsx)(ne,{error:I,onRetry:()=>J($)}),(0,N.jsx)(re,{title:e(`infoCollectPage.fofaQuerySyntax`,null,`查询语法`),children:(0,N.jsxs)(`div`,{className:`info-collect-form`,children:[(0,N.jsxs)(r,{className:`info-collect-form-row`,children:[(0,N.jsx)(g,{value:l.provider,optionList:se,onChange:ye,style:{width:150}}),(0,N.jsxs)(`span`,{className:`info-collect-size`,children:[(0,N.jsx)(V,{type:`tertiary`,size:`small`,children:e(`infoCollectPage.returnCount`,null,`返回数量`)}),(0,N.jsx)(f,{value:q,min:1,max:G.maxSize,onChange:e=>K({size:e}),style:{width:120}})]}),(0,N.jsx)(h,{checked:!!l.full,disabled:!G.supportsFull,onChange:e=>K({full:e})}),(0,N.jsx)(V,{type:`tertiary`,size:`small`,children:`full`}),(0,N.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,N.jsx)(d,{}),onClick:()=>J(1),loading:P,disabled:!n,children:e(`infoCollectPage.confirm`,null,`查询`)}),(0,N.jsx)(a,{disabled:!T.trim()||!n,onClick:()=>O(!0),title:e(`infoCollectPage.parseBtnTitle`,null,`将自然语言解析为查询语法`),children:e(`infoCollectPage.parseBtn`,null,`AI 解析`)})]}),(0,N.jsx)(_,{value:l.query,rows:3,placeholder:`${ve}:${G.placeholder}`,className:`info-collect-query`,onChange:e=>K({query:e})}),(0,N.jsxs)(r,{wrap:!0,className:`info-collect-presets`,children:[(0,N.jsxs)(V,{type:`tertiary`,size:`small`,children:[e(`infoCollectPage.fillExample`,null,`示例`),`:`]}),G.queryPresets.map(([e,t])=>(0,N.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>K({query:t}),children:e},e))]}),(0,N.jsxs)(r,{className:`info-collect-form-row`,children:[(0,N.jsx)(V,{type:`tertiary`,size:`small`,children:e(`infoCollectPage.returnFields`,null,`返回字段`)}),(0,N.jsx)(i,{value:l.fields,onChange:e=>K({fields:e}),className:`info-collect-fields`,style:{width:420}}),G.fieldPresets.map(([e,t])=>(0,N.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>K({fields:t}),children:e},e))]}),(0,N.jsx)(_,{value:T,rows:2,placeholder:e(`infoCollectPage.nlPlaceholder`,null,`自然语言:例如 找中国 Apache 站点,标题包含登录`),className:`info-collect-natural`,onChange:E})]})}),(0,N.jsxs)(re,{title:e(`infoCollectPage.queryResults`,null,`查询结果`),extra:(0,N.jsxs)(r,{children:[(0,N.jsx)(V,{type:`tertiary`,size:`small`,children:we}),(0,N.jsx)(g,{multiple:!0,value:B,optionList:Y.map(e=>({value:e,label:e})),disabled:!Y.length,placeholder:e(`infoCollectPage.showColumns`,null,`显示字段`),maxTagCount:5,style:{minWidth:220},onChange:e=>{let t=(e||[]).slice(0,5);(e||[]).length>5&&x(`最多显示 5 个字段`),U(t)}}),(0,N.jsx)(a,{icon:(0,N.jsx)(o,{}),disabled:!c||!R.length,loading:ge,onClick:xe,children:e(`assets.importSelected`,null,`入库所选`)})]}),children:[k?.warning&&(0,N.jsx)(v,{type:`warning`,bordered:!0,closeIcon:null,className:`info-collect-warning`,description:k.warning}),!k&&!P&&!I?(0,N.jsx)(s,{title:e(`infoCollect.noResults`,null,`暂无结果`),description:n?`输入查询语法后点击“查询”。`:`当前账号缺少 fofa:execute 权限。`,style:{padding:40}}):(0,N.jsx)(de,{fields:Y,results:X,visibleFields:B,selectedKeys:R,onSelectionChange:z,onOpenDetail:he,loading:P}),k&&Z>Q&&(0,N.jsx)(`div`,{className:`info-collect-pagination`,children:(0,N.jsx)(u,{total:Z,pageSize:Q,currentPage:$,onPageChange:e=>J(e),showTotal:!0})}),k&&(0,N.jsx)(V,{type:`tertiary`,size:`small`,className:`info-collect-selected-meta`,children:e(`infoCollectPage.selectedRows`,{count:R.length},`已选择 ${R.length} 条`)})]}),(0,N.jsx)(p,{visible:!!W,onCancel:()=>he(null),title:e(`infoCollect.detailTitle`,null,`结果详情`),width:600,placement:`right`,children:W&&(0,N.jsxs)(`div`,{className:`info-collect-detail`,children:[(0,N.jsx)(V,{strong:!0,children:M(W,Y)||`—`}),(0,N.jsx)(w,{items:Ce,columns:1}),(0,N.jsx)(ae,{value:W,title:`原始 JSON`})]})}),(0,N.jsx)(fe,{visible:D,provider:l.provider,text:T,onClose:()=>O(!1),onApply:Se})]})}export{U as default};
\ No newline at end of file
diff --git a/web/static/app/assets/knowledge-management-BPIYf1Sv.js b/web/static/app/assets/knowledge-management-9curLpIK.js
similarity index 98%
rename from web/static/app/assets/knowledge-management-BPIYf1Sv.js
rename to web/static/app/assets/knowledge-management-9curLpIK.js
index 95459381..c4781b12 100644
--- a/web/static/app/assets/knowledge-management-BPIYf1Sv.js
+++ b/web/static/app/assets/knowledge-management-9curLpIK.js
@@ -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,St as s,Tt as c,W as l,at as ee,ct as te,i as u,ot as d,v as f}from"./semi-CXF9U6uC.js";import{D as p,E as m,F as h,I as g,P as ne,_ as re,a as _,b as v,c as y,d as b,f as x,l as S,m as C,p as w,s as T,x as E,y as D}from"./index-CrDogtQS.js";var O=e(t(),1),k=e(n(),1),{Text:A}=l;function j(){let e=ne(),{hasPermission:t}=h(),n=t(`knowledge:write`),[l,j]=(0,O.useState)(``),[M,ie]=(0,O.useState)(``),[N,P]=(0,O.useState)(1),[F,I]=(0,O.useState)(20),[L,R]=(0,O.useState)(null),[z,B]=(0,O.useState)(null),[V,H]=(0,O.useState)(!1),[U,W]=(0,O.useState)(!1),[G,K]=(0,O.useState)(null),q=_(()=>g.get(`/knowledge/items`,{category:l||void 0,search:M||void 0,limit:F,offset:(N-1)*F}),[l,M,N,F]),J=_(()=>g.get(`/knowledge/stats`),[]),Y=_(()=>g.get(`/knowledge/categories`),[]),X=_(()=>g.get(`/knowledge/index-status`),[]),ae=Array.isArray(q.data?.items)?q.data.items:[],oe=Number(q.data?.total||0),se=(Array.isArray(Y.data?.categories)?Y.data.categories:[]).map(e=>typeof e==`string`?{value:e,label:e}:{value:e.name||e.category,label:e.name||e.category}),Z=(0,O.useCallback)(()=>{q.reload(),J.reload(),X.reload()},[q,J,X]),Q=async()=>{let e=await L.form.validate();H(!0);try{let t={category:e.category.trim(),title:e.title.trim(),content:e.content};L.item?.id?await g.put(`/knowledge/items/${encodeURIComponent(L.item.id)}`,t):await g.post(`/knowledge/items`,t),E(L.item?.id?`知识项已更新`:`知识项已创建`),R(null),Z()}catch(e){v(e,`保存失败`)}finally{H(!1)}},ce=e=>D({title:`删除知识项「${e.title}」?`,content:`删除后需要重新索引,且不可恢复。`,onOk:async()=>{await g.del(`/knowledge/items/${encodeURIComponent(e.id)}`),E(`已删除`),Z()}}),$=async e=>{try{await g.post(`/knowledge/index`,e?{full:!0}:{}),E(`索引任务已提交`),X.reload()}catch(e){v(e,`构建索引失败`)}},le=async e=>{try{K(await g.post(`/knowledge/search`,{query:e,topK:5}))}catch(e){v(e,`检索失败`)}};return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(w,{title:e(`knowledge.title`,null,`知识管理`),description:`知识条目会参与智能体检索;修改后需要重建索引才能生效。`,extra:(0,k.jsxs)(r,{children:[(0,k.jsx)(a,{icon:(0,k.jsx)(d,{}),onClick:Z,children:`刷新`}),n&&(0,k.jsx)(a,{onClick:()=>$(!1),children:`构建索引`}),n&&(0,k.jsx)(a,{onClick:()=>$(!0),children:`全量重建`}),n&&(0,k.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,k.jsx)(te,{}),onClick:()=>R({item:null,form:{}}),children:`新增知识`})]})}),(0,k.jsx)(re,{columns:4,metrics:[{id:`items`,label:`知识条目`,value:p(J.data?.total_items||0),loading:J.loading},{id:`categories`,label:`分类数`,value:p(J.data?.total_categories||0),loading:J.loading},{id:`indexed`,label:`已索引`,value:p(X.data?.indexed_items??X.data?.total_indexed??0),loading:X.loading},{id:`pending`,label:`待索引`,value:p(X.data?.pending_items??0),loading:X.loading}]}),(0,k.jsxs)(C,{title:`知识条目`,children:[(0,k.jsx)(S,{error:q.error,onRetry:()=>q.reload()}),(0,k.jsx)(T,{columns:[{title:`标题`,dataIndex:`title`,render:(e,t)=>(0,k.jsx)(A,{strong:!0,children:e||t.filePath})},{title:`分类`,dataIndex:`category`,width:160,render:e=>e?(0,k.jsx)(o,{size:`small`,children:e}):`—`},{title:`更新时间`,dataIndex:`updatedAt`,width:180,render:e=>m(e)},{title:`操作`,width:150,render:(e,t)=>(0,k.jsxs)(r,{children:[(0,k.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>B(t),children:`查看`}),n&&(0,k.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,k.jsx)(s,{}),onClick:()=>R({item:t,form:{}})}),n&&(0,k.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,k.jsx)(c,{}),onClick:()=>ce(t)})]})}],dataSource:ae,rowKey:`id`,loading:q.loading,pagination:{currentPage:N,pageSize:F,total:oe,onPageChange:P,onPageSizeChange:e=>{I(e),P(1)}},toolbar:(0,k.jsxs)(r,{children:[(0,k.jsx)(i,{prefix:(0,k.jsx)(ee,{}),value:M,onChange:e=>{ie(e),P(1)},placeholder:`搜索标题或内容`,style:{width:220}}),(0,k.jsx)(f,{value:l,onChange:e=>{j(e||``),P(1)},placeholder:`全部分类`,style:{width:180},showClear:!0,optionList:se}),(0,k.jsx)(a,{onClick:()=>W(!0),children:`检索测试`})]})})]}),(0,k.jsx)(y,{title:L?.item?`编辑知识项`:`新增知识项`,visible:!!L,onCancel:()=>R(null),onOk:Q,confirmLoading:V,width:760,children:(0,k.jsxs)(u,{getFormApi:e=>R(t=>t&&{...t,form:e}),initValues:L?.item?{category:L.item.category,title:L.item.title,content:L.item.content}:{},children:[(0,k.jsx)(u.Input,{field:`category`,label:`分类`,rules:[{required:!0,message:`请输入分类`}],placeholder:`例如 sql_injection`}),(0,k.jsx)(u.Input,{field:`title`,label:`标题`,rules:[{required:!0,message:`请输入标题`}]}),(0,k.jsx)(u.TextArea,{field:`content`,label:`内容(Markdown)`,rules:[{required:!0,message:`请输入内容`}],autosize:{minRows:10,maxRows:24}})]})},L?.item?.id||`new`),(0,k.jsx)(y,{title:z?.title||`知识项`,visible:!!z,onCancel:()=>B(null),width:640,children:z&&(0,k.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,k.jsx)(b,{items:[{label:`分类`,value:z.category},{label:`文件路径`,value:z.filePath},{label:`创建时间`,value:m(z.createdAt)},{label:`更新时间`,value:m(z.updatedAt)}]}),(0,k.jsx)(x,{content:z.content||`(内容需要打开原文查看)`})]})}),(0,k.jsxs)(y,{title:`知识检索测试`,visible:U,onCancel:()=>{W(!1),K(null)},footer:null,width:720,children:[(0,k.jsxs)(u,{onSubmit:({query:e})=>le(e),children:[(0,k.jsx)(u.Input,{field:`query`,label:`检索语句`,rules:[{required:!0,message:`请输入检索语句`}]}),(0,k.jsx)(a,{htmlType:`submit`,theme:`solid`,type:`primary`,children:`检索`})]}),G&&(0,k.jsxs)(`div`,{style:{marginTop:16,display:`flex`,flexDirection:`column`,gap:8},children:[(G.results||[]).map((e,t)=>(0,k.jsxs)(`div`,{style:{border:`1px solid var(--semi-color-border)`,borderRadius:8,padding:12},children:[(0,k.jsxs)(r,{children:[(0,k.jsxs)(o,{color:`blue`,children:[`#`,t+1]}),(0,k.jsx)(A,{strong:!0,children:e.item?.title||e.title||e.id}),e.score!==void 0&&(0,k.jsxs)(A,{type:`tertiary`,children:[`相似度 `,Number(e.score).toFixed(3)]})]}),(0,k.jsx)(`div`,{style:{marginTop:8},children:(0,k.jsx)(x,{content:String(e.content||e.item?.content||``).slice(0,600)})})]},e.id||t)),(G.results||[]).length===0&&(0,k.jsx)(A,{type:`tertiary`,children:`没有命中结果`})]})]})]})}export{j as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,St as s,Tt as c,W as l,at as ee,ct as te,i as u,ot as d,v as f}from"./semi-CXF9U6uC.js";import{D as p,E as m,F as h,I as g,P as ne,_ as re,a as _,b as v,c as y,d as b,f as x,l as S,m as C,p as w,s as T,x as E,y as D}from"./index-LQJrYSgy.js";var O=e(t(),1),k=e(n(),1),{Text:A}=l;function j(){let e=ne(),{hasPermission:t}=h(),n=t(`knowledge:write`),[l,j]=(0,O.useState)(``),[M,ie]=(0,O.useState)(``),[N,P]=(0,O.useState)(1),[F,I]=(0,O.useState)(20),[L,R]=(0,O.useState)(null),[z,B]=(0,O.useState)(null),[V,H]=(0,O.useState)(!1),[U,W]=(0,O.useState)(!1),[G,K]=(0,O.useState)(null),q=_(()=>g.get(`/knowledge/items`,{category:l||void 0,search:M||void 0,limit:F,offset:(N-1)*F}),[l,M,N,F]),J=_(()=>g.get(`/knowledge/stats`),[]),Y=_(()=>g.get(`/knowledge/categories`),[]),X=_(()=>g.get(`/knowledge/index-status`),[]),ae=Array.isArray(q.data?.items)?q.data.items:[],oe=Number(q.data?.total||0),se=(Array.isArray(Y.data?.categories)?Y.data.categories:[]).map(e=>typeof e==`string`?{value:e,label:e}:{value:e.name||e.category,label:e.name||e.category}),Z=(0,O.useCallback)(()=>{q.reload(),J.reload(),X.reload()},[q,J,X]),Q=async()=>{let e=await L.form.validate();H(!0);try{let t={category:e.category.trim(),title:e.title.trim(),content:e.content};L.item?.id?await g.put(`/knowledge/items/${encodeURIComponent(L.item.id)}`,t):await g.post(`/knowledge/items`,t),E(L.item?.id?`知识项已更新`:`知识项已创建`),R(null),Z()}catch(e){v(e,`保存失败`)}finally{H(!1)}},ce=e=>D({title:`删除知识项「${e.title}」?`,content:`删除后需要重新索引,且不可恢复。`,onOk:async()=>{await g.del(`/knowledge/items/${encodeURIComponent(e.id)}`),E(`已删除`),Z()}}),$=async e=>{try{await g.post(`/knowledge/index`,e?{full:!0}:{}),E(`索引任务已提交`),X.reload()}catch(e){v(e,`构建索引失败`)}},le=async e=>{try{K(await g.post(`/knowledge/search`,{query:e,topK:5}))}catch(e){v(e,`检索失败`)}};return(0,k.jsxs)(`div`,{children:[(0,k.jsx)(w,{title:e(`knowledge.title`,null,`知识管理`),description:`知识条目会参与智能体检索;修改后需要重建索引才能生效。`,extra:(0,k.jsxs)(r,{children:[(0,k.jsx)(a,{icon:(0,k.jsx)(d,{}),onClick:Z,children:`刷新`}),n&&(0,k.jsx)(a,{onClick:()=>$(!1),children:`构建索引`}),n&&(0,k.jsx)(a,{onClick:()=>$(!0),children:`全量重建`}),n&&(0,k.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,k.jsx)(te,{}),onClick:()=>R({item:null,form:{}}),children:`新增知识`})]})}),(0,k.jsx)(re,{columns:4,metrics:[{id:`items`,label:`知识条目`,value:p(J.data?.total_items||0),loading:J.loading},{id:`categories`,label:`分类数`,value:p(J.data?.total_categories||0),loading:J.loading},{id:`indexed`,label:`已索引`,value:p(X.data?.indexed_items??X.data?.total_indexed??0),loading:X.loading},{id:`pending`,label:`待索引`,value:p(X.data?.pending_items??0),loading:X.loading}]}),(0,k.jsxs)(C,{title:`知识条目`,children:[(0,k.jsx)(S,{error:q.error,onRetry:()=>q.reload()}),(0,k.jsx)(T,{columns:[{title:`标题`,dataIndex:`title`,render:(e,t)=>(0,k.jsx)(A,{strong:!0,children:e||t.filePath})},{title:`分类`,dataIndex:`category`,width:160,render:e=>e?(0,k.jsx)(o,{size:`small`,children:e}):`—`},{title:`更新时间`,dataIndex:`updatedAt`,width:180,render:e=>m(e)},{title:`操作`,width:150,render:(e,t)=>(0,k.jsxs)(r,{children:[(0,k.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>B(t),children:`查看`}),n&&(0,k.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,k.jsx)(s,{}),onClick:()=>R({item:t,form:{}})}),n&&(0,k.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,k.jsx)(c,{}),onClick:()=>ce(t)})]})}],dataSource:ae,rowKey:`id`,loading:q.loading,pagination:{currentPage:N,pageSize:F,total:oe,onPageChange:P,onPageSizeChange:e=>{I(e),P(1)}},toolbar:(0,k.jsxs)(r,{children:[(0,k.jsx)(i,{prefix:(0,k.jsx)(ee,{}),value:M,onChange:e=>{ie(e),P(1)},placeholder:`搜索标题或内容`,style:{width:220}}),(0,k.jsx)(f,{value:l,onChange:e=>{j(e||``),P(1)},placeholder:`全部分类`,style:{width:180},showClear:!0,optionList:se}),(0,k.jsx)(a,{onClick:()=>W(!0),children:`检索测试`})]})})]}),(0,k.jsx)(y,{title:L?.item?`编辑知识项`:`新增知识项`,visible:!!L,onCancel:()=>R(null),onOk:Q,confirmLoading:V,width:760,children:(0,k.jsxs)(u,{getFormApi:e=>R(t=>t&&{...t,form:e}),initValues:L?.item?{category:L.item.category,title:L.item.title,content:L.item.content}:{},children:[(0,k.jsx)(u.Input,{field:`category`,label:`分类`,rules:[{required:!0,message:`请输入分类`}],placeholder:`例如 sql_injection`}),(0,k.jsx)(u.Input,{field:`title`,label:`标题`,rules:[{required:!0,message:`请输入标题`}]}),(0,k.jsx)(u.TextArea,{field:`content`,label:`内容(Markdown)`,rules:[{required:!0,message:`请输入内容`}],autosize:{minRows:10,maxRows:24}})]})},L?.item?.id||`new`),(0,k.jsx)(y,{title:z?.title||`知识项`,visible:!!z,onCancel:()=>B(null),width:640,children:z&&(0,k.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,k.jsx)(b,{items:[{label:`分类`,value:z.category},{label:`文件路径`,value:z.filePath},{label:`创建时间`,value:m(z.createdAt)},{label:`更新时间`,value:m(z.updatedAt)}]}),(0,k.jsx)(x,{content:z.content||`(内容需要打开原文查看)`})]})}),(0,k.jsxs)(y,{title:`知识检索测试`,visible:U,onCancel:()=>{W(!1),K(null)},footer:null,width:720,children:[(0,k.jsxs)(u,{onSubmit:({query:e})=>le(e),children:[(0,k.jsx)(u.Input,{field:`query`,label:`检索语句`,rules:[{required:!0,message:`请输入检索语句`}]}),(0,k.jsx)(a,{htmlType:`submit`,theme:`solid`,type:`primary`,children:`检索`})]}),G&&(0,k.jsxs)(`div`,{style:{marginTop:16,display:`flex`,flexDirection:`column`,gap:8},children:[(G.results||[]).map((e,t)=>(0,k.jsxs)(`div`,{style:{border:`1px solid var(--semi-color-border)`,borderRadius:8,padding:12},children:[(0,k.jsxs)(r,{children:[(0,k.jsxs)(o,{color:`blue`,children:[`#`,t+1]}),(0,k.jsx)(A,{strong:!0,children:e.item?.title||e.title||e.id}),e.score!==void 0&&(0,k.jsxs)(A,{type:`tertiary`,children:[`相似度 `,Number(e.score).toFixed(3)]})]}),(0,k.jsx)(`div`,{style:{marginTop:8},children:(0,k.jsx)(x,{content:String(e.content||e.item?.content||``).slice(0,600)})})]},e.id||t)),(G.results||[]).length===0&&(0,k.jsx)(A,{type:`tertiary`,children:`没有命中结果`})]})]})]})}export{j as default};
\ No newline at end of file
diff --git a/web/static/app/assets/knowledge-retrieval-logs-DqT0Q9uP.js b/web/static/app/assets/knowledge-retrieval-logs-BLDiNz53.js
similarity index 96%
rename from web/static/app/assets/knowledge-retrieval-logs-DqT0Q9uP.js
rename to web/static/app/assets/knowledge-retrieval-logs-BLDiNz53.js
index 9baf9215..00cea341 100644
--- a/web/static/app/assets/knowledge-retrieval-logs-DqT0Q9uP.js
+++ b/web/static/app/assets/knowledge-retrieval-logs-BLDiNz53.js
@@ -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,Tt as s,W as c,at as l,ot as u}from"./semi-CXF9U6uC.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-CrDogtQS.js";var T=e(t(),1),E=e(n(),1),{Text:D}=c;function O(){let e=m(),{hasPermission:t}=f(),n=t(`knowledge:delete`),[c,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(50),[j,M]=(0,T.useState)(null),N=h(()=>p.get(`/knowledge/retrieval-logs`,{conversationId:c||void 0,limit:k}),[c,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)(s,{}),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:c,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};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,Tt as s,W as c,at as l,ot as u}from"./semi-CXF9U6uC.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-LQJrYSgy.js";var T=e(t(),1),E=e(n(),1),{Text:D}=c;function O(){let e=m(),{hasPermission:t}=f(),n=t(`knowledge:delete`),[c,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(50),[j,M]=(0,T.useState)(null),N=h(()=>p.get(`/knowledge/retrieval-logs`,{conversationId:c||void 0,limit:k}),[c,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)(s,{}),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:c,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};
\ No newline at end of file
diff --git a/web/static/app/assets/mcp-management-WdRbQfaA.js b/web/static/app/assets/mcp-management-BJ29mUCm.js
similarity index 99%
rename from web/static/app/assets/mcp-management-WdRbQfaA.js
rename to web/static/app/assets/mcp-management-BJ29mUCm.js
index c515f535..8e900a35 100644
--- a/web/static/app/assets/mcp-management-WdRbQfaA.js
+++ b/web/static/app/assets/mcp-management-BJ29mUCm.js
@@ -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,at as l,ct as u,ot as d,u as f,v as p,x as m,z as h}from"./semi-CXF9U6uC.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-CrDogtQS.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,l]=(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`;l(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{l(``)}},[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)(u,{}),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-management-empty`,children:[(0,z.jsx)(`p`,{children:i(`mcp.noExternalMCP`,null,`暂无外部 MCP`)}),(0,z.jsx)(a,{size:`small`,disabled:!e,onClick:G,children:i(`mcp.clickToAddExternal`,null,`点击添加外部 MCP`)})]}),(0,z.jsx)(`div`,{className:`mcp-management-mcp-grid`,children:U.map(([t,n])=>{let s=n?.config||{},l=String(n?.status||`disconnected`),u=F(l),d=I(s),f=l===`connected`;return(0,z.jsxs)(`div`,{className:`mcp-management-mcp-card`,children:[(0,z.jsxs)(`div`,{className:`mcp-management-mcp-head`,children:[(0,z.jsxs)(`div`,{className:`mcp-management-mcp-title`,children:[(0,z.jsx)(B,{strong:!0,children:t}),(0,z.jsx)(o,{size:`small`,color:u.color,children:u.label}),(0,z.jsx)(o,{size:`small`,color:`grey`,children:d.toUpperCase()}),Number(n?.tool_count)>0&&(0,z.jsx)(o,{size:`small`,color:`blue`,children:`${n.tool_count} 个工具`})]}),(0,z.jsxs)(r,{spacing:4,wrap:!0,children:[(0,z.jsx)(a,{size:`small`,theme:`borderless`,disabled:!e||c===t||l===`connecting`,loading:c===t,onClick:()=>J(t,l),children:l===`connecting`?i(`mcp.connecting`,null,`连接中`):f?i(`mcp.stop`,null,`停止`):i(`mcp.start`,null,`启动`)}),(0,z.jsx)(a,{size:`small`,theme:`borderless`,disabled:!e,onClick:()=>K(t),children:i(`common.edit`,null,`编辑`)}),(0,z.jsx)(a,{size:`small`,type:`danger`,theme:`borderless`,disabled:!e,onClick:()=>Y(t),children:i(`common.delete`,null,`删除`)})]})]}),(l===`error`||l===`disconnected`)&&n?.error&&(0,z.jsx)(h,{type:l===`error`?`danger`:`warning`,className:`mcp-management-mcp-error`,description:(0,z.jsx)(`span`,{className:`mcp-management-mono`,children:n.error})}),(0,z.jsxs)(`div`,{className:`mcp-management-mcp-meta`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`mcp-management-meta-label`,children:i(`mcp.transportMode`,null,`传输方式`)}),(0,z.jsx)(`span`,{children:d.toUpperCase()})]}),s.description&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`mcp-management-meta-label`,children:i(`mcp.description`,null,`描述`)}),(0,z.jsx)(`span`,{children:s.description})]}),d===`stdio`&&s.command&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`mcp-management-meta-label`,children:i(`mcp.command`,null,`命令`)}),(0,z.jsx)(`span`,{className:`mcp-management-mono`,children:s.command})]}),d!==`stdio`&&s.url&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`mcp-management-meta-label`,children:`URL`}),(0,z.jsx)(`span`,{className:`mcp-management-mono`,children:s.url})]}),Number(s.timeout)>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`mcp-management-meta-label`,children:i(`mcp.timeout`,null,`超时`)}),(0,z.jsxs)(`span`,{children:[s.timeout,` `,i(`mcp.secondsUnit`,null,`秒`)]})]})]})]},t)})}),(0,z.jsx)(C,{title:g?`${i(`mcp.editExternalMCP`,null,`编辑外部MCP`)} · ${g}`:i(`mcp.addExternalMCP`,null,`添加外部 MCP`),visible:f,onCancel:q,onOk:X,confirmLoading:L,width:760,okText:i(`common.save`,null,`保存`),cancelText:i(`common.cancel`,null,`取消`),children:(0,z.jsxs)(`div`,{className:`mcp-management-form`,children:[(0,z.jsxs)(`div`,{className:`mcp-management-form-head`,children:[(0,z.jsx)(B,{type:`tertiary`,children:g?`编辑模式下只提交当前名称的配置;external_mcp_enable 由启停按钮维护。`:`支持一次粘贴多个 MCP:{"name": {...}};保存后逐个写入 config.yaml。`}),!g&&(0,z.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>O(JSON.stringify(V,null,2)),children:`载入示例`}),E&&(0,z.jsx)(D,{text:E,size:`small`})]}),(0,z.jsx)(m,{className:`mcp-management-json`,rows:16,value:E,spellCheck:!1,placeholder:`{"my-http-server": {"type": "http", "url": "https://mcp.example.com/mcp"}}`,onChange:e=>{O(e),A&&P(``)}}),A&&(0,z.jsx)(`div`,{className:`mcp-management-form-error`,children:A})]})})]})}var{Text:W}=c;function G({canWrite:e,refreshKey:t=0}){let n=v(),[c,u]=(0,N.useState)(1),[m,h]=(0,N.useState)(20),[g,y]=(0,N.useState)(``),b=E(g,350),[C,D]=(0,N.useState)(`all`),[O,k]=(0,N.useState)(!0),[M,P]=(0,N.useState)({}),[F,I]=(0,N.useState)(!1),B=(0,N.useRef)(new Map),V=x(()=>_.get(`/config/tools`,{page:c,page_size:m,search:b,tool_filter:C===`all`?``:C,include_external:O?``:`0`}),[c,m,b,C,O,t]),H=V.data?.tools||[],U=Number(V.data?.total)||0,G=(0,N.useDeferredValue)(H);(0,N.useEffect)(()=>{(H||[]).forEach(e=>B.current.set(L(e),e))},[H]);let K=(0,N.useMemo)(()=>Object.keys(M),[M]),q=(0,N.useCallback)(e=>Object.prototype.hasOwnProperty.call(M,L(e))?M[L(e)]:e.enabled,[M]),J=(0,N.useCallback)((e,t)=>{let n=L(e);P(r=>{let i={...r};return t===e.enabled?delete i[n]:i[n]=t,i})},[]),Y=(0,N.useCallback)(e=>{P(t=>{let n={...t};return(H||[]).forEach(t=>{let r=L(t);t.enabled===e?delete n[r]:n[r]=e}),n})},[H]),X=(0,N.useCallback)(()=>P({}),[]),Z=(0,N.useCallback)(async()=>{let e=Object.entries(M);if(e.length){I(!0);try{let t=e.map(([e,t])=>{let n=B.current.get(e);return{name:n?.name||e.split(`::`).pop()||e,enabled:t,is_external:!!n?.is_external,external_mcp:n?.external_mcp||``}});await _.put(`/config`,{tools:t}),await _.post(`/config/apply`,{}),j(n(`mcp.toolsConfigSaved`,null,`工具配置已成功保存`)),P({}),V.reload({silent:!0})}catch(e){S(e,n(`mcp.saveToolsConfigFailed`,null,`保存工具配置失败`))}finally{I(!1)}}},[M,V.reload,n]),Q=[{title:n(`mcpMonitor.columnTool`,null,`工具`),dataIndex:`name`,render:e=>(0,z.jsx)(`span`,{className:`mcp-management-mono mcp-management-tool-name`,children:e})},{title:`来源`,dataIndex:`is_external`,width:180,render:(e,t)=>(0,z.jsx)(o,{size:`small`,color:e?`blue`:`grey`,children:R(t)})},{title:n(`mcp.filterEnabled`,null,`已启用`),dataIndex:`enabled`,width:110,render:(t,n)=>(0,z.jsx)(f,{size:`small`,checked:q(n),disabled:!e,onChange:e=>J(n,e)})},{title:n(`mcp.description`,null,`描述`),dataIndex:`description`,render:e=>(0,z.jsx)(W,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:560},children:e||n(`mcp.noDescription`,null,`暂无描述`)})}],$={currentPage:c,pageSize:m,total:U,showSizeChanger:!0,pageSizeOpts:[20,50,100],showTotal:!0,onPageChange:e=>u(e),onPageSizeChange:e=>{h(e),u(1)}},ee=[{value:`all`,label:n(`mcp.filterAll`,null,`全部`)},{value:`on`,label:n(`mcp.filterEnabled`,null,`已启用`)},{value:`off`,label:n(`mcp.filterDisabled`,null,`已停用`)}];return(0,z.jsxs)(T,{title:n(`mcp.toolConfig`,null,`MCP 工具配置`),description:`${n(`mcp.currentPageEnabled`,null,`当前页已启用`)} ${(G||[]).filter(e=>q(e)).length} / ${G.length} · ${n(`mcp.totalEnabled`,null,`已启用工具总数`)} ${V.data?.total_enabled??`—`}`,extra:(0,z.jsxs)(r,{spacing:8,children:[K.length>0&&(0,z.jsx)(o,{size:`small`,color:`amber`,children:`未保存 ${K.length} 项`}),K.length>0&&(0,z.jsx)(a,{size:`small`,theme:`borderless`,onClick:X,disabled:F,children:`放弃修改`}),(0,z.jsx)(a,{size:`small`,icon:(0,z.jsx)(d,{}),theme:`borderless`,onClick:()=>V.reload(),loading:V.loading,children:n(`common.refresh`,null,`刷新`)}),(0,z.jsx)(a,{size:`small`,theme:`solid`,disabled:!e||!K.length,loading:F,onClick:Z,children:n(`mcp.saveToolConfig`,null,`保存工具配置`)})]}),children:[(0,z.jsx)(w,{error:V.error,onRetry:()=>V.reload()}),(0,z.jsx)(A,{columns:Q,dataSource:H,rowKey:e=>L(e),loading:V.loading,pagination:$,size:`small`,emptyText:n(`mcp.noTools`,null,`暂无工具`),toolbar:(0,z.jsxs)(r,{spacing:8,wrap:!0,children:[(0,z.jsx)(i,{prefix:(0,z.jsx)(l,{}),showClear:!0,style:{width:240},value:g,placeholder:n(`mcp.toolSearchPlaceholder`,null,`搜索工具…`),onChange:e=>{y(e),u(1)}}),(0,z.jsx)(p,{value:C,style:{width:140},optionList:ee,onChange:e=>{D(e),u(1)}}),(0,z.jsx)(s,{checked:O,onChange:e=>{k(e.target.checked),u(1)},children:`包含外部 MCP 工具`}),(0,z.jsx)(a,{size:`small`,theme:`borderless`,disabled:!e,onClick:()=>Y(!0),children:n(`mcp.selectAll`,null,`全选`)}),(0,z.jsx)(a,{size:`small`,theme:`borderless`,disabled:!e,onClick:()=>Y(!1),children:n(`mcp.deselectAll`,null,`全不选`)})]})}),(0,z.jsx)(`p`,{className:`mcp-management-hint`,children:`保存只提交本次改动的工具项;应用后由后端重新注册 MCP 工具。直接注册(未写入 config.yaml)的工具切换不会落盘。`})]})}function K(){let e=v(),{hasPermission:t}=g(),n=t(`mcp:write`),[i,o]=(0,N.useState)(0),s=x(()=>_.get(`/external-mcp/stats`),[i]),c=s.data||{},l=(0,N.useCallback)(()=>{o(e=>e+1),s.reload({silent:!0})},[s.reload]);return(0,z.jsxs)(`div`,{className:`mcp-management-page`,children:[(0,z.jsx)(O,{title:e(`mcp.managementTitle`,null,`MCP 管理`),description:`维护外部 MCP 连接与工具启用状态;改动写入 config.yaml 后立即生效。`,extra:(0,z.jsx)(r,{children:(0,z.jsx)(a,{icon:(0,z.jsx)(d,{}),onClick:l,loading:s.loading,children:e(`common.refresh`,null,`刷新`)})})}),(0,z.jsx)(b,{columns:4,metrics:[{id:`total`,label:e(`mcp.totalCount`,null,`总数`),value:s.error?`—`:c.total??0,detail:e(`mcp.externalConfig`,null,`外部 MCP 配置`),loading:s.loading&&!s.data},{id:`enabled`,label:e(`mcp.enabledCount`,null,`已启用`),value:s.error?`—`:c.enabled??0,tone:`success`,loading:s.loading&&!s.data},{id:`connected`,label:e(`mcp.connectedCount`,null,`已连接`),value:s.error?`—`:c.connected??0,tone:c.connected>0?`success`:void 0,loading:s.loading&&!s.data},{id:`disabled`,label:e(`mcp.disabledCount`,null,`已停用`),value:s.error?`—`:c.disabled??0,loading:s.loading&&!s.data}]}),(0,z.jsx)(w,{error:s.error,onRetry:l}),(0,z.jsx)(U,{canWrite:n,onChanged:l,refreshKey:i}),(0,z.jsx)(G,{canWrite:n,refreshKey:i})]})}export{K as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,N as s,W as c,at as l,ct as u,ot as d,u as f,v as p,x as m,z as h}from"./semi-CXF9U6uC.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-LQJrYSgy.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,l]=(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`;l(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{l(``)}},[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)(u,{}),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-management-empty`,children:[(0,z.jsx)(`p`,{children:i(`mcp.noExternalMCP`,null,`暂无外部 MCP`)}),(0,z.jsx)(a,{size:`small`,disabled:!e,onClick:G,children:i(`mcp.clickToAddExternal`,null,`点击添加外部 MCP`)})]}),(0,z.jsx)(`div`,{className:`mcp-management-mcp-grid`,children:U.map(([t,n])=>{let s=n?.config||{},l=String(n?.status||`disconnected`),u=F(l),d=I(s),f=l===`connected`;return(0,z.jsxs)(`div`,{className:`mcp-management-mcp-card`,children:[(0,z.jsxs)(`div`,{className:`mcp-management-mcp-head`,children:[(0,z.jsxs)(`div`,{className:`mcp-management-mcp-title`,children:[(0,z.jsx)(B,{strong:!0,children:t}),(0,z.jsx)(o,{size:`small`,color:u.color,children:u.label}),(0,z.jsx)(o,{size:`small`,color:`grey`,children:d.toUpperCase()}),Number(n?.tool_count)>0&&(0,z.jsx)(o,{size:`small`,color:`blue`,children:`${n.tool_count} 个工具`})]}),(0,z.jsxs)(r,{spacing:4,wrap:!0,children:[(0,z.jsx)(a,{size:`small`,theme:`borderless`,disabled:!e||c===t||l===`connecting`,loading:c===t,onClick:()=>J(t,l),children:l===`connecting`?i(`mcp.connecting`,null,`连接中`):f?i(`mcp.stop`,null,`停止`):i(`mcp.start`,null,`启动`)}),(0,z.jsx)(a,{size:`small`,theme:`borderless`,disabled:!e,onClick:()=>K(t),children:i(`common.edit`,null,`编辑`)}),(0,z.jsx)(a,{size:`small`,type:`danger`,theme:`borderless`,disabled:!e,onClick:()=>Y(t),children:i(`common.delete`,null,`删除`)})]})]}),(l===`error`||l===`disconnected`)&&n?.error&&(0,z.jsx)(h,{type:l===`error`?`danger`:`warning`,className:`mcp-management-mcp-error`,description:(0,z.jsx)(`span`,{className:`mcp-management-mono`,children:n.error})}),(0,z.jsxs)(`div`,{className:`mcp-management-mcp-meta`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`mcp-management-meta-label`,children:i(`mcp.transportMode`,null,`传输方式`)}),(0,z.jsx)(`span`,{children:d.toUpperCase()})]}),s.description&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`mcp-management-meta-label`,children:i(`mcp.description`,null,`描述`)}),(0,z.jsx)(`span`,{children:s.description})]}),d===`stdio`&&s.command&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`mcp-management-meta-label`,children:i(`mcp.command`,null,`命令`)}),(0,z.jsx)(`span`,{className:`mcp-management-mono`,children:s.command})]}),d!==`stdio`&&s.url&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`mcp-management-meta-label`,children:`URL`}),(0,z.jsx)(`span`,{className:`mcp-management-mono`,children:s.url})]}),Number(s.timeout)>0&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`span`,{className:`mcp-management-meta-label`,children:i(`mcp.timeout`,null,`超时`)}),(0,z.jsxs)(`span`,{children:[s.timeout,` `,i(`mcp.secondsUnit`,null,`秒`)]})]})]})]},t)})}),(0,z.jsx)(C,{title:g?`${i(`mcp.editExternalMCP`,null,`编辑外部MCP`)} · ${g}`:i(`mcp.addExternalMCP`,null,`添加外部 MCP`),visible:f,onCancel:q,onOk:X,confirmLoading:L,width:760,okText:i(`common.save`,null,`保存`),cancelText:i(`common.cancel`,null,`取消`),children:(0,z.jsxs)(`div`,{className:`mcp-management-form`,children:[(0,z.jsxs)(`div`,{className:`mcp-management-form-head`,children:[(0,z.jsx)(B,{type:`tertiary`,children:g?`编辑模式下只提交当前名称的配置;external_mcp_enable 由启停按钮维护。`:`支持一次粘贴多个 MCP:{"name": {...}};保存后逐个写入 config.yaml。`}),!g&&(0,z.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>O(JSON.stringify(V,null,2)),children:`载入示例`}),E&&(0,z.jsx)(D,{text:E,size:`small`})]}),(0,z.jsx)(m,{className:`mcp-management-json`,rows:16,value:E,spellCheck:!1,placeholder:`{"my-http-server": {"type": "http", "url": "https://mcp.example.com/mcp"}}`,onChange:e=>{O(e),A&&P(``)}}),A&&(0,z.jsx)(`div`,{className:`mcp-management-form-error`,children:A})]})})]})}var{Text:W}=c;function G({canWrite:e,refreshKey:t=0}){let n=v(),[c,u]=(0,N.useState)(1),[m,h]=(0,N.useState)(20),[g,y]=(0,N.useState)(``),b=E(g,350),[C,D]=(0,N.useState)(`all`),[O,k]=(0,N.useState)(!0),[M,P]=(0,N.useState)({}),[F,I]=(0,N.useState)(!1),B=(0,N.useRef)(new Map),V=x(()=>_.get(`/config/tools`,{page:c,page_size:m,search:b,tool_filter:C===`all`?``:C,include_external:O?``:`0`}),[c,m,b,C,O,t]),H=V.data?.tools||[],U=Number(V.data?.total)||0,G=(0,N.useDeferredValue)(H);(0,N.useEffect)(()=>{(H||[]).forEach(e=>B.current.set(L(e),e))},[H]);let K=(0,N.useMemo)(()=>Object.keys(M),[M]),q=(0,N.useCallback)(e=>Object.prototype.hasOwnProperty.call(M,L(e))?M[L(e)]:e.enabled,[M]),J=(0,N.useCallback)((e,t)=>{let n=L(e);P(r=>{let i={...r};return t===e.enabled?delete i[n]:i[n]=t,i})},[]),Y=(0,N.useCallback)(e=>{P(t=>{let n={...t};return(H||[]).forEach(t=>{let r=L(t);t.enabled===e?delete n[r]:n[r]=e}),n})},[H]),X=(0,N.useCallback)(()=>P({}),[]),Z=(0,N.useCallback)(async()=>{let e=Object.entries(M);if(e.length){I(!0);try{let t=e.map(([e,t])=>{let n=B.current.get(e);return{name:n?.name||e.split(`::`).pop()||e,enabled:t,is_external:!!n?.is_external,external_mcp:n?.external_mcp||``}});await _.put(`/config`,{tools:t}),await _.post(`/config/apply`,{}),j(n(`mcp.toolsConfigSaved`,null,`工具配置已成功保存`)),P({}),V.reload({silent:!0})}catch(e){S(e,n(`mcp.saveToolsConfigFailed`,null,`保存工具配置失败`))}finally{I(!1)}}},[M,V.reload,n]),Q=[{title:n(`mcpMonitor.columnTool`,null,`工具`),dataIndex:`name`,render:e=>(0,z.jsx)(`span`,{className:`mcp-management-mono mcp-management-tool-name`,children:e})},{title:`来源`,dataIndex:`is_external`,width:180,render:(e,t)=>(0,z.jsx)(o,{size:`small`,color:e?`blue`:`grey`,children:R(t)})},{title:n(`mcp.filterEnabled`,null,`已启用`),dataIndex:`enabled`,width:110,render:(t,n)=>(0,z.jsx)(f,{size:`small`,checked:q(n),disabled:!e,onChange:e=>J(n,e)})},{title:n(`mcp.description`,null,`描述`),dataIndex:`description`,render:e=>(0,z.jsx)(W,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:560},children:e||n(`mcp.noDescription`,null,`暂无描述`)})}],$={currentPage:c,pageSize:m,total:U,showSizeChanger:!0,pageSizeOpts:[20,50,100],showTotal:!0,onPageChange:e=>u(e),onPageSizeChange:e=>{h(e),u(1)}},ee=[{value:`all`,label:n(`mcp.filterAll`,null,`全部`)},{value:`on`,label:n(`mcp.filterEnabled`,null,`已启用`)},{value:`off`,label:n(`mcp.filterDisabled`,null,`已停用`)}];return(0,z.jsxs)(T,{title:n(`mcp.toolConfig`,null,`MCP 工具配置`),description:`${n(`mcp.currentPageEnabled`,null,`当前页已启用`)} ${(G||[]).filter(e=>q(e)).length} / ${G.length} · ${n(`mcp.totalEnabled`,null,`已启用工具总数`)} ${V.data?.total_enabled??`—`}`,extra:(0,z.jsxs)(r,{spacing:8,children:[K.length>0&&(0,z.jsx)(o,{size:`small`,color:`amber`,children:`未保存 ${K.length} 项`}),K.length>0&&(0,z.jsx)(a,{size:`small`,theme:`borderless`,onClick:X,disabled:F,children:`放弃修改`}),(0,z.jsx)(a,{size:`small`,icon:(0,z.jsx)(d,{}),theme:`borderless`,onClick:()=>V.reload(),loading:V.loading,children:n(`common.refresh`,null,`刷新`)}),(0,z.jsx)(a,{size:`small`,theme:`solid`,disabled:!e||!K.length,loading:F,onClick:Z,children:n(`mcp.saveToolConfig`,null,`保存工具配置`)})]}),children:[(0,z.jsx)(w,{error:V.error,onRetry:()=>V.reload()}),(0,z.jsx)(A,{columns:Q,dataSource:H,rowKey:e=>L(e),loading:V.loading,pagination:$,size:`small`,emptyText:n(`mcp.noTools`,null,`暂无工具`),toolbar:(0,z.jsxs)(r,{spacing:8,wrap:!0,children:[(0,z.jsx)(i,{prefix:(0,z.jsx)(l,{}),showClear:!0,style:{width:240},value:g,placeholder:n(`mcp.toolSearchPlaceholder`,null,`搜索工具…`),onChange:e=>{y(e),u(1)}}),(0,z.jsx)(p,{value:C,style:{width:140},optionList:ee,onChange:e=>{D(e),u(1)}}),(0,z.jsx)(s,{checked:O,onChange:e=>{k(e.target.checked),u(1)},children:`包含外部 MCP 工具`}),(0,z.jsx)(a,{size:`small`,theme:`borderless`,disabled:!e,onClick:()=>Y(!0),children:n(`mcp.selectAll`,null,`全选`)}),(0,z.jsx)(a,{size:`small`,theme:`borderless`,disabled:!e,onClick:()=>Y(!1),children:n(`mcp.deselectAll`,null,`全不选`)})]})}),(0,z.jsx)(`p`,{className:`mcp-management-hint`,children:`保存只提交本次改动的工具项;应用后由后端重新注册 MCP 工具。直接注册(未写入 config.yaml)的工具切换不会落盘。`})]})}function K(){let e=v(),{hasPermission:t}=g(),n=t(`mcp:write`),[i,o]=(0,N.useState)(0),s=x(()=>_.get(`/external-mcp/stats`),[i]),c=s.data||{},l=(0,N.useCallback)(()=>{o(e=>e+1),s.reload({silent:!0})},[s.reload]);return(0,z.jsxs)(`div`,{className:`mcp-management-page`,children:[(0,z.jsx)(O,{title:e(`mcp.managementTitle`,null,`MCP 管理`),description:`维护外部 MCP 连接与工具启用状态;改动写入 config.yaml 后立即生效。`,extra:(0,z.jsx)(r,{children:(0,z.jsx)(a,{icon:(0,z.jsx)(d,{}),onClick:l,loading:s.loading,children:e(`common.refresh`,null,`刷新`)})})}),(0,z.jsx)(b,{columns:4,metrics:[{id:`total`,label:e(`mcp.totalCount`,null,`总数`),value:s.error?`—`:c.total??0,detail:e(`mcp.externalConfig`,null,`外部 MCP 配置`),loading:s.loading&&!s.data},{id:`enabled`,label:e(`mcp.enabledCount`,null,`已启用`),value:s.error?`—`:c.enabled??0,tone:`success`,loading:s.loading&&!s.data},{id:`connected`,label:e(`mcp.connectedCount`,null,`已连接`),value:s.error?`—`:c.connected??0,tone:c.connected>0?`success`:void 0,loading:s.loading&&!s.data},{id:`disabled`,label:e(`mcp.disabledCount`,null,`已停用`),value:s.error?`—`:c.disabled??0,loading:s.loading&&!s.data}]}),(0,z.jsx)(w,{error:s.error,onRetry:l}),(0,z.jsx)(U,{canWrite:n,onChanged:l,refreshKey:i}),(0,z.jsx)(G,{canWrite:n,refreshKey:i})]})}export{K as default};
\ No newline at end of file
diff --git a/web/static/app/assets/mcp-monitor-Dd86uZML.js b/web/static/app/assets/mcp-monitor-Dd86uZML.js
new file mode 100644
index 00000000..9feb34ba
--- /dev/null
+++ b/web/static/app/assets/mcp-monitor-Dd86uZML.js
@@ -0,0 +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,at as u,f as d,ot as f,v as p,w as m,x as h,z as g}from"./semi-CXF9U6uC.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-LQJrYSgy.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)(s,{size:`small`,color:`orange`,children:e}):0},{title:i(`mcpMonitor.columnSuccessRate`,null,`成功率`),dataIndex:`rate`,width:110,render:e=>e===null?`—`:x(e,1)}];return(0,Z.jsx)(k,{title:i(`mcpMonitor.toolStatsTitle`,null,`工具统计`),description:i(`mcpMonitor.toolStatsHint`,null,`点击工具名筛选下方执行记录`),children:(0,Z.jsx)(j,{columns:o,dataSource:a,rowKey:`key`,loading:t,pagination:!1,size:`small`,emptyText:i(`mcpMonitor.noStatsData`,null,`暂无统计数据`)})})}var ce=[{value:`24h`,labelKey:`timelineRange24h`,fallback:`24 小时`},{value:`7d`,labelKey:`timelineRange7d`,fallback:`7 天`},{value:`30d`,labelKey:`timelineRange30d`,fallback:`30 天`}];function le({data:e,loading:t,error:n,range:r,onRangeChange:i,onRetry:a}){let o=S(),s=Array.isArray(e?.points)?e.points:[],c=e?.summary||{},l=Number(c.peak)||0,u=(0,F.useMemo)(()=>s.reduce((e,t)=>Math.max(e,Number(t.total)||0),0),[s]),d=Number(c.totalCalls)||0,f=Math.max(1,Math.ceil(s.length/8)),m=ce.map(e=>({value:e.value,label:o(`mcpMonitor.${e.labelKey}`,null,e.fallback)}));return(0,Z.jsxs)(k,{title:o(`mcpMonitor.timelineTitle`,null,`调用趋势`),description:o(`mcpMonitor.timelineHint`,null,`全部工具合计,失败与拦截单独着色`),extra:(0,Z.jsx)(p,{size:`small`,value:r,optionList:m,style:{width:120},onChange:i}),children:[(0,Z.jsx)(O,{error:n,onRetry:a}),(0,Z.jsxs)(`div`,{className:`mcp-monitor-timeline-summary`,children:[(0,Z.jsx)(D,{label:o(`mcpMonitor.timelineTotalLegend`,null,`总调用`),value:_(d),loading:t}),(0,Z.jsx)(D,{label:`峰值 / 桶`,value:_(l),detail:o(`mcpMonitor.scopeTimeline`,null,`当前时间范围`),loading:t}),(0,Z.jsxs)(`div`,{className:`mcp-monitor-timeline-legend`,children:[(0,Z.jsxs)(`span`,{className:`mcp-monitor-legend-item`,children:[(0,Z.jsx)(`i`,{className:`mcp-monitor-legend-dot mcp-monitor-legend-total`}),o(`mcpMonitor.timelineTotalLegend`,null,`总调用`)]}),(0,Z.jsxs)(`span`,{className:`mcp-monitor-legend-item`,children:[(0,Z.jsx)(`i`,{className:`mcp-monitor-legend-dot mcp-monitor-legend-failed`}),o(`mcpMonitor.timelineFailedLegend`,null,`失败`)]}),(0,Z.jsxs)(`span`,{className:`mcp-monitor-legend-item`,children:[(0,Z.jsx)(`i`,{className:`mcp-monitor-legend-dot mcp-monitor-legend-blocked`}),o(`mcpMonitor.timelineBlockedLegend`,null,`安全拦截`)]})]})]}),t&&!s.length?(0,Z.jsx)(`div`,{className:`mcp-monitor-timeline-empty`,children:o(`mcpMonitor.timelineLoading`,null,`趋势加载中…`)}):d===0||u===0?(0,Z.jsxs)(`div`,{className:`mcp-monitor-timeline-empty`,children:[(0,Z.jsx)(`p`,{children:o(`mcpMonitor.timelineNoData`,null,`该时段暂无调用`)}),(0,Z.jsx)(`p`,{className:`mcp-monitor-timeline-hint`,children:o(`mcpMonitor.timelineEmptyHint`,null,`调用 MCP 工具后此处会出现趋势`)})]}):(0,Z.jsx)(`div`,{className:`mcp-monitor-timeline-chart`,role:`img`,"aria-label":o(`mcpMonitor.timelineTitle`,null,`调用趋势`),children:s.map((e,t)=>{let n=Number(e.total)||0,i=Number(e.failed)||0,a=Number(e.blocked)||0,s=n>0?Math.max(3,n/u*100):0,c=n>0?i/n*100:0,l=n>0?a/n*100:0,d=Y(e.t,r);return(0,Z.jsxs)(`div`,{className:`mcp-monitor-timeline-slot`,title:X(e,o),children:[(0,Z.jsx)(`div`,{className:`mcp-monitor-timeline-bar-wrap`,children:(0,Z.jsxs)(`div`,{className:`mcp-monitor-timeline-bar`,style:{height:`${s}%`},children:[l>0&&(0,Z.jsx)(`span`,{className:`mcp-monitor-timeline-seg mcp-monitor-seg-blocked`,style:{height:`${l}%`}}),c>0&&(0,Z.jsx)(`span`,{className:`mcp-monitor-timeline-seg mcp-monitor-seg-failed`,style:{height:`${c}%`}})]})}),(0,Z.jsx)(`span`,{className:`mcp-monitor-timeline-tick`,children:t%f===0?d:``})]},e.t||t)})})]})}function Q({status:e}){let t=S();return(0,Z.jsx)(s,{size:`small`,color:H(e),shape:`square`,children:V(t,e)})}function ue({data:e,loading:t,error:n,page:r,pageSize:s,status:c,toolInput:l,selected:d,onQuery:f,onPageChange:m,onRefresh:h,onOpenDetail:g,onCancel:_,onDelete:y,onSelectionChange:b,canWrite:x,canDelete:ee}){let C=S(),w=e?.executions||[],T=Number(e?.total)||0,E=[{value:`all`,label:C(`mcp.filterAll`,null,`全部`)},...I.map(e=>({value:e,label:V(C,e)}))],D=[{title:C(`mcpMonitor.columnTool`,null,`工具`),dataIndex:`toolName`,render:e=>(0,Z.jsx)(`span`,{className:`mcp-monitor-cell-tool`,children:W(e)||C(`mcpMonitor.unknownTool`,null,`未知工具`)})},{title:C(`mcpMonitor.columnStatus`,null,`状态`),dataIndex:`status`,width:110,render:e=>(0,Z.jsx)(Q,{status:e})},{title:C(`mcpMonitor.columnStartTime`,null,`开始时间`),dataIndex:`startTime`,width:180,render:e=>v(e)},{title:C(`mcpMonitor.columnDuration`,null,`耗时`),dataIndex:`duration`,width:110,render:(e,t)=>K(G(t))},{title:C(`common.actions`,null,`操作`),dataIndex:`id`,width:230,render:(e,t)=>(0,Z.jsxs)(i,{spacing:4,wrap:!0,children:[(0,Z.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>g(e),children:C(`mcpMonitor.viewDetail`,null,`详情`)}),U(t.status)&&(0,Z.jsx)(o,{size:`small`,theme:`borderless`,disabled:!x,onClick:()=>_(t),children:C(`mcpMonitor.terminateExecution`,null,`终止`)}),(0,Z.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!ee,onClick:()=>y(t),children:C(`common.delete`,null,`删除`)})]})}];return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(O,{error:n,onRetry:h}),(0,Z.jsx)(j,{columns:D,dataSource:w,rowKey:`id`,loading:t,pagination:{currentPage:r,pageSize:s,total:T,showSizeChanger:!0,pageSizeOpts:[20,50,100],showTotal:!0,onPageChange:e=>m(e,s),onPageSizeChange:e=>m(1,e)},onRefresh:h,emptyText:C(`mcpMonitor.noExecutions`,null,`暂无执行记录`),rowSelection:{selectedRowKeys:d,onChange:e=>b(e||[])},toolbar:(0,Z.jsxs)(i,{spacing:8,wrap:!0,children:[(0,Z.jsx)(a,{prefix:(0,Z.jsx)(u,{}),value:l,showClear:!0,style:{width:220},placeholder:C(`mcp.toolSearchPlaceholder`,null,`输入工具名称…`),onChange:e=>f({toolInput:e})}),(0,Z.jsx)(p,{value:c,style:{width:150},optionList:E,onChange:e=>f({status:e})})]})})]})}var{Text:$}=l;function de({executionId:e,onClose:t,canWrite:n,onCancelRequest:r}){let a=S(),{data:s,loading:l,error:u,reload:f}=w(()=>b.get(`/monitor/execution/${encodeURIComponent(e)}`),[e],{skip:!e}),p=e?s:null,m=p?U(p.status):!1;return(0,Z.jsxs)(d,{visible:!!e,onCancel:t,title:a(`mcpMonitor.viewDetail`,null,`执行详情`),width:720,footer:p?(0,Z.jsxs)(i,{children:[m&&(0,Z.jsx)(o,{theme:`solid`,disabled:!n,onClick:()=>r(p),children:a(`mcpMonitor.terminateExecution`,null,`终止`)}),(0,Z.jsx)(o,{onClick:t,children:a(`common.close`,null,`关闭`)})]}):null,children:[!p&&l&&(0,Z.jsx)(`div`,{className:`mcp-monitor-detail-loading`,children:(0,Z.jsx)(c,{})}),(0,Z.jsx)(O,{error:u,onRetry:f}),p&&(0,Z.jsxs)(`div`,{className:`mcp-monitor-detail`,children:[(0,Z.jsx)(E,{columns:2,items:[{label:`工具`,value:(0,Z.jsx)($,{strong:!0,children:W(p.toolName)||`—`})},{label:a(`mcpMonitor.columnStatus`,null,`状态`),value:(0,Z.jsx)(Q,{status:p.status})},{label:`执行 ID`,value:(0,Z.jsx)(`span`,{className:`mcp-monitor-mono`,children:p.id})},{label:a(`mcpMonitor.columnStartTime`,null,`开始时间`),value:v(p.startTime)},{label:`结束时间`,value:p.endTime?v(p.endTime):`—`},{label:a(`mcpMonitor.columnDuration`,null,`耗时`),value:K(G(p))},{label:`关联会话`,value:p.conversationId?(0,Z.jsxs)(i,{spacing:4,children:[(0,Z.jsx)(`span`,{className:`mcp-monitor-mono`,children:p.conversationId}),(0,Z.jsx)(A,{text:p.conversationId,size:`small`})]}):`—`},{label:`结果状态`,value:p.result?p.result.isError?`错误结果`:p.result.blocked?`已拦截`:`正常返回`:`无返回`}]}),p.error&&(0,Z.jsx)(g,{type:`danger`,className:`mcp-monitor-detail-error`,description:(0,Z.jsx)(`span`,{className:`mcp-monitor-mono`,children:p.error})}),(0,Z.jsx)(`div`,{className:`mcp-monitor-detail-section`,children:(0,Z.jsx)(M,{title:a(`mcpDetailModal.requestParams`,null,`入参`),value:p.arguments??{}})}),(0,Z.jsx)(`div`,{className:`mcp-monitor-detail-section`,children:p.result?(0,Z.jsx)(M,{title:a(`mcpDetailModal.responseResult`,null,`出参`),value:p.result}):(0,Z.jsx)(`div`,{className:`mcp-monitor-detail-empty`,children:m?a(`mcpDetailModal.runningNoResponseYet`,null,`尚无返回,工具可能仍在执行。`):a(`chat.noResponseData`,null,`暂无响应数据`)})}),p.partialOutput&&(0,Z.jsxs)(`div`,{className:`mcp-monitor-detail-section`,children:[(0,Z.jsxs)(`div`,{className:`mcp-monitor-detail-section-head`,children:[(0,Z.jsx)($,{strong:!0,children:`实时输出尾部`}),(0,Z.jsxs)(i,{spacing:4,children:[p.partialOutputBytes?(0,Z.jsxs)($,{type:`tertiary`,children:[p.partialOutputBytes,` B`]}):null,(0,Z.jsx)(A,{text:p.partialOutput,size:`small`})]})]}),(0,Z.jsx)(`pre`,{className:`mcp-monitor-detail-pre`,children:p.partialOutput})]}),(0,Z.jsxs)(`div`,{className:`mcp-monitor-detail-footnote`,children:[V(a,p.status),` · `,a(`mcpMonitor.statsFromAllTools`,null,`全部工具累计`)]})]})]})}function fe(){let e=S(),{hasPermission:t}=y(),[n,a]=r(),s=t(`monitor:write`)||t(`mcp:write`),c=t(`monitor:delete`),[l,u]=(0,F.useState)(1),[d,p]=(0,F.useState)(20),[g,_]=(0,F.useState)(`all`),[v,x]=(0,F.useState)(``),C=ne(v,350),[E,D]=(0,F.useState)([]),[O,A]=te(`mcp-monitor-timeline-range`,`7d`),[j,M]=(0,F.useState)(null),[I,L]=(0,F.useState)(``),[R,z]=(0,F.useState)(!1),B=n.get(`id`)||``,V=[`24h`,`7d`,`30d`].includes(O)?O:`7d`,H=w(()=>b.get(`/monitor`,{page:l,page_size:d,status:g===`all`?``:g,tool:C}),[l,d,g,C]),U=w(()=>b.get(`/monitor/stats`,{top:12}),[]),K=w(()=>b.get(`/monitor/calls-timeline`,{range:V}),[V]),q=H.data?.executions||[],J=U.data?.summary||H.data?.summary||null,Y=U.data?.topTools||H.data?.topTools||[],X=Number(H.data?.retentionDays)||0,ce=(0,F.useMemo)(()=>q.filter(e=>G(e)!==null).length,[q]),Q=(0,F.useMemo)(()=>ae(q),[q]);ie(()=>{typeof document<`u`&&document.hidden||(H.reload({silent:!0}),K.reload({silent:!0}))},5e3),ie(()=>{typeof document<`u`&&document.hidden||U.reload({silent:!0})},2e4);let $=(0,F.useCallback)(()=>{H.reload(),U.reload({silent:!0}),K.reload({silent:!0})},[H.reload,U.reload,K.reload]),fe=(0,F.useCallback)(e=>{let t=new URLSearchParams(n);t.set(`id`,e),a(t,{replace:!0})},[n,a]),pe=(0,F.useCallback)(()=>{let e=new URLSearchParams(n);e.delete(`id`),a(e,{replace:!0})},[n,a]),me=(0,F.useCallback)(e=>{Object.prototype.hasOwnProperty.call(e,`toolInput`)&&x(e.toolInput),e.status!==void 0&&_(e.status),u(1),D([])},[]),he=(0,F.useCallback)((e,t)=>{u(e),t&&t!==d&&p(t)},[d]),ge=(0,F.useCallback)(e=>{x(W(e)),u(1),D([])},[]),_e=(0,F.useCallback)(t=>{P({title:e(`mcpMonitor.deleteExecTitle`,null,`删除此执行记录`),content:`确定删除 ${W(t.toolName)||`该`} 的执行记录?此操作不可恢复。`,okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{await b.del(`/monitor/execution/${encodeURIComponent(t.id)}`),D(e=>e.filter(e=>e!==t.id)),N(e(`mcpMonitor.execDeleted`,null,`执行记录已删除`)),$()}catch(t){T(t,e(`mcpMonitor.deleteExecFailed`,null,`删除执行记录失败`))}}})},[$,e]),ve=(0,F.useCallback)(async()=>{if(!E.length){ee(e(`mcpMonitor.selectExecFirst`,null,`请先选择要删除的执行记录`));return}let t=[];try{let e=await b.post(`/monitor/executions/names`,{ids:E});t=[...new Set(Object.values(e||{}).map(e=>W(e?.toolName)).filter(Boolean))]}catch{t=[]}let n=t.length?`涉及工具:${t.slice(0,3).join(`、`)}${t.length>3?` 等`:``}。`:``;P({title:e(`mcpMonitor.batchDeleteConfirm`,{count:E.length},`确定删除选中的 ${E.length} 条执行记录?`),content:`${n}此操作不可恢复。`,okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{await b.del(`/monitor/executions`,{body:{ids:E}}),N(`已删除 ${E.length} 条执行记录`),D([]),$()}catch(t){T(t,e(`mcp.batchDeleteFailed`,null,`批量删除执行记录失败`))}}})},[$,E,e]),ye=(0,F.useCallback)(e=>{M(e),L(``)},[]),be=(0,F.useCallback)(async()=>{if(j?.id){z(!0);try{await b.post(`/monitor/execution/${encodeURIComponent(j.id)}/cancel`,{note:I.trim()}),N(e(`mcpDetailModal.abortSuccess`,null,`已发送终止请求`)),M(null),$()}catch(t){T(t,e(`mcpDetailModal.abortFailed`,null,`终止失败`))}finally{z(!1)}}},[I,j,$,e]),xe=X>0?e(`mcpMonitor.retentionHint`,{days:X},`执行记录保留 ${X} 天,失败与拦截调用单独标记。`):`统计全部 MCP 工具调用,失败与拦截调用单独标记。`;return(0,Z.jsxs)(`div`,{className:`mcp-monitor-page`,children:[(0,Z.jsx)(re,{title:e(`mcp.monitorTitle`,null,`MCP 状态监控`),description:xe,extra:(0,Z.jsx)(i,{children:(0,Z.jsx)(o,{icon:(0,Z.jsx)(f,{}),onClick:$,loading:H.loading||U.loading,children:e(`common.refresh`,null,`刷新`)})})}),(0,Z.jsx)(oe,{summary:J,loading:U.loading&&!J,avgMs:Q,avgSamples:ce}),(0,Z.jsx)(le,{data:K.data,loading:K.loading,error:K.error,range:V,onRangeChange:e=>{e&&A(e)},onRetry:()=>K.reload()}),(0,Z.jsx)(se,{topTools:Y,loading:U.loading&&!Y.length,onFilterTool:ge,activeTool:C}),(0,Z.jsx)(k,{title:e(`mcp.latestExecutions`,null,`最新执行记录`),description:e(`mcpMonitor.emptyHint`,null,`在对话或任务中调用 MCP 工具后,执行记录将显示在此处`),extra:E.length>0?(0,Z.jsxs)(i,{spacing:8,children:[(0,Z.jsx)(`span`,{className:`mcp-monitor-selected`,children:e(`mcp.selectedCount`,{count:E.length},`已选择 ${E.length} 项`)}),(0,Z.jsx)(o,{size:`small`,disabled:!c,type:`danger`,onClick:ve,children:e(`mcp.deleteSelected`,null,`批量删除`)}),(0,Z.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>D([]),children:e(`mcpMonitor.deselectAll`,null,`取消全选`)})]}):null,children:(0,Z.jsx)(ue,{data:H.data,loading:H.loading,error:H.error,page:l,pageSize:d,status:g,toolInput:v,selected:E,onQuery:me,onPageChange:he,onRefresh:()=>H.reload(),onOpenDetail:fe,onCancel:ye,onDelete:_e,onSelectionChange:D,canWrite:s,canDelete:c})}),(0,Z.jsx)(de,{executionId:B,onClose:pe,canWrite:s,onCancelRequest:e=>{pe(),ye(e)}}),(0,Z.jsxs)(m,{title:e(`mcpMonitor.terminateExecution`,null,`终止执行`),visible:!!j,confirmLoading:R,maskClosable:!R,okText:e(`mcpMonitor.terminateExecution`,null,`终止`),cancelText:e(`common.cancel`,null,`取消`),onCancel:()=>M(null),onOk:be,children:[(0,Z.jsx)(`p`,{className:`mcp-monitor-cancel-hint`,children:e(`mcpDetailModal.abortHint`,null,`终止仅取消本次工具调用,不会停止整条对话;说明会与工具输出一起交给模型。`)}),(0,Z.jsx)(h,{rows:4,value:I,placeholder:e(`mcpDetailModal.abortNotePlaceholder`,null,`终止说明(可选),例如:命令执行时间过长,先终止。`),onChange:e=>L(e)})]})]})}export{fe as default};
\ No newline at end of file
diff --git a/web/static/app/assets/mcp-monitor-QKVbRd7N.js b/web/static/app/assets/mcp-monitor-QKVbRd7N.js
deleted file mode 100644
index 6a2bba14..00000000
--- a/web/static/app/assets/mcp-monitor-QKVbRd7N.js
+++ /dev/null
@@ -1 +0,0 @@
-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,at as u,f as d,ot as f,v as p,w as m,x as h,z as g}from"./semi-CXF9U6uC.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 j,s as M,u as N,x as P,y as F}from"./index-CrDogtQS.js";var I=e(t(),1),L=[`completed`,`running`,`queued`,`failed`,`blocked`,`hard_timeout`,`cancelled`,`orphaned`],R={pending:`statusPending`,queued:`statusQueued`,running:`statusRunning`,completed:`statusCompleted`,failed:`statusFailed`,blocked:`statusBlocked`,cancelled:`statusCancelled`,hard_timeout:`statusHardTimeout`,orphaned:`statusOrphaned`},ie={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=R[n];return r?e(`mcpMonitor.${r}`,null,ie[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,I.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)(s,{size:`small`,color:`orange`,children:e}):0},{title:i(`mcpMonitor.columnSuccessRate`,null,`成功率`),dataIndex:`rate`,width:110,render:e=>e===null?`—`:x(e,1)}];return(0,Z.jsx)(k,{title:i(`mcpMonitor.toolStatsTitle`,null,`工具统计`),description:i(`mcpMonitor.toolStatsHint`,null,`点击工具名筛选下方执行记录`),children:(0,Z.jsx)(M,{columns:o,dataSource:a,rowKey:`key`,loading:t,pagination:!1,size:`small`,emptyText:i(`mcpMonitor.noStatsData`,null,`暂无统计数据`)})})}var ce=[{value:`24h`,labelKey:`timelineRange24h`,fallback:`24 小时`},{value:`7d`,labelKey:`timelineRange7d`,fallback:`7 天`},{value:`30d`,labelKey:`timelineRange30d`,fallback:`30 天`}];function le({data:e,loading:t,error:n,range:r,onRangeChange:i,onRetry:a}){let o=S(),s=Array.isArray(e?.points)?e.points:[],c=e?.summary||{},l=Number(c.peak)||0,u=(0,I.useMemo)(()=>s.reduce((e,t)=>Math.max(e,Number(t.total)||0),0),[s]),d=Number(c.totalCalls)||0,f=Math.max(1,Math.ceil(s.length/8)),m=ce.map(e=>({value:e.value,label:o(`mcpMonitor.${e.labelKey}`,null,e.fallback)}));return(0,Z.jsxs)(k,{title:o(`mcpMonitor.timelineTitle`,null,`调用趋势`),description:o(`mcpMonitor.timelineHint`,null,`全部工具合计,失败与拦截单独着色`),extra:(0,Z.jsx)(p,{size:`small`,value:r,optionList:m,style:{width:120},onChange:i}),children:[(0,Z.jsx)(O,{error:n,onRetry:a}),(0,Z.jsxs)(`div`,{className:`mcp-monitor-timeline-summary`,children:[(0,Z.jsx)(D,{label:o(`mcpMonitor.timelineTotalLegend`,null,`总调用`),value:_(d),loading:t}),(0,Z.jsx)(D,{label:`峰值 / 桶`,value:_(l),detail:o(`mcpMonitor.scopeTimeline`,null,`当前时间范围`),loading:t}),(0,Z.jsxs)(`div`,{className:`mcp-monitor-timeline-legend`,children:[(0,Z.jsxs)(`span`,{className:`mcp-monitor-legend-item`,children:[(0,Z.jsx)(`i`,{className:`mcp-monitor-legend-dot mcp-monitor-legend-total`}),o(`mcpMonitor.timelineTotalLegend`,null,`总调用`)]}),(0,Z.jsxs)(`span`,{className:`mcp-monitor-legend-item`,children:[(0,Z.jsx)(`i`,{className:`mcp-monitor-legend-dot mcp-monitor-legend-failed`}),o(`mcpMonitor.timelineFailedLegend`,null,`失败`)]}),(0,Z.jsxs)(`span`,{className:`mcp-monitor-legend-item`,children:[(0,Z.jsx)(`i`,{className:`mcp-monitor-legend-dot mcp-monitor-legend-blocked`}),o(`mcpMonitor.timelineBlockedLegend`,null,`安全拦截`)]})]})]}),t&&!s.length?(0,Z.jsx)(`div`,{className:`mcp-monitor-timeline-empty`,children:o(`mcpMonitor.timelineLoading`,null,`趋势加载中…`)}):d===0||u===0?(0,Z.jsxs)(`div`,{className:`mcp-monitor-timeline-empty`,children:[(0,Z.jsx)(`p`,{children:o(`mcpMonitor.timelineNoData`,null,`该时段暂无调用`)}),(0,Z.jsx)(`p`,{className:`mcp-monitor-timeline-hint`,children:o(`mcpMonitor.timelineEmptyHint`,null,`调用 MCP 工具后此处会出现趋势`)})]}):(0,Z.jsx)(`div`,{className:`mcp-monitor-timeline-chart`,role:`img`,"aria-label":o(`mcpMonitor.timelineTitle`,null,`调用趋势`),children:s.map((e,t)=>{let n=Number(e.total)||0,i=Number(e.failed)||0,a=Number(e.blocked)||0,s=n>0?Math.max(3,n/u*100):0,c=n>0?i/n*100:0,l=n>0?a/n*100:0,d=Y(e.t,r);return(0,Z.jsxs)(`div`,{className:`mcp-monitor-timeline-slot`,title:X(e,o),children:[(0,Z.jsx)(`div`,{className:`mcp-monitor-timeline-bar-wrap`,children:(0,Z.jsxs)(`div`,{className:`mcp-monitor-timeline-bar`,style:{height:`${s}%`},children:[l>0&&(0,Z.jsx)(`span`,{className:`mcp-monitor-timeline-seg mcp-monitor-seg-blocked`,style:{height:`${l}%`}}),c>0&&(0,Z.jsx)(`span`,{className:`mcp-monitor-timeline-seg mcp-monitor-seg-failed`,style:{height:`${c}%`}})]})}),(0,Z.jsx)(`span`,{className:`mcp-monitor-timeline-tick`,children:t%f===0?d:``})]},e.t||t)})})]})}function Q({status:e}){let t=S();return(0,Z.jsx)(s,{size:`small`,color:H(e),shape:`square`,children:V(t,e)})}function ue({data:e,loading:t,error:n,page:r,pageSize:s,status:c,toolInput:l,selected:d,onQuery:f,onPageChange:m,onRefresh:h,onOpenDetail:g,onCancel:_,onDelete:y,onSelectionChange:b,canWrite:x,canDelete:ee}){let C=S(),w=e?.executions||[],T=Number(e?.total)||0,E=[{value:`all`,label:C(`mcp.filterAll`,null,`全部`)},...L.map(e=>({value:e,label:V(C,e)}))],D=[{title:C(`mcpMonitor.columnTool`,null,`工具`),dataIndex:`toolName`,render:e=>(0,Z.jsx)(`span`,{className:`mcp-monitor-cell-tool`,children:W(e)||C(`mcpMonitor.unknownTool`,null,`未知工具`)})},{title:C(`mcpMonitor.columnStatus`,null,`状态`),dataIndex:`status`,width:110,render:e=>(0,Z.jsx)(Q,{status:e})},{title:C(`mcpMonitor.columnStartTime`,null,`开始时间`),dataIndex:`startTime`,width:180,render:e=>v(e)},{title:C(`mcpMonitor.columnDuration`,null,`耗时`),dataIndex:`duration`,width:110,render:(e,t)=>K(G(t))},{title:C(`common.actions`,null,`操作`),dataIndex:`id`,width:230,render:(e,t)=>(0,Z.jsxs)(i,{spacing:4,wrap:!0,children:[(0,Z.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>g(e),children:C(`mcpMonitor.viewDetail`,null,`详情`)}),U(t.status)&&(0,Z.jsx)(o,{size:`small`,theme:`borderless`,disabled:!x,onClick:()=>_(t),children:C(`mcpMonitor.terminateExecution`,null,`终止`)}),(0,Z.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!ee,onClick:()=>y(t),children:C(`common.delete`,null,`删除`)})]})}];return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(O,{error:n,onRetry:h}),(0,Z.jsx)(M,{columns:D,dataSource:w,rowKey:`id`,loading:t,pagination:{currentPage:r,pageSize:s,total:T,showSizeChanger:!0,pageSizeOpts:[20,50,100],showTotal:!0,onPageChange:e=>m(e,s),onPageSizeChange:e=>m(1,e)},onRefresh:h,emptyText:C(`mcpMonitor.noExecutions`,null,`暂无执行记录`),rowSelection:{selectedRowKeys:d,onChange:e=>b(e||[])},toolbar:(0,Z.jsxs)(i,{spacing:8,wrap:!0,children:[(0,Z.jsx)(a,{prefix:(0,Z.jsx)(u,{}),value:l,showClear:!0,style:{width:220},placeholder:C(`mcp.toolSearchPlaceholder`,null,`输入工具名称…`),onChange:e=>f({toolInput:e})}),(0,Z.jsx)(p,{value:c,style:{width:150},optionList:E,onChange:e=>f({status:e})})]})})]})}var{Text:$}=l;function de({executionId:e,onClose:t,canWrite:n,onCancelRequest:r}){let a=S(),{data:s,loading:l,error:u,reload:f}=w(()=>b.get(`/monitor/execution/${encodeURIComponent(e)}`),[e],{skip:!e}),p=e?s:null,m=p?U(p.status):!1;return(0,Z.jsxs)(d,{visible:!!e,onCancel:t,title:a(`mcpMonitor.viewDetail`,null,`执行详情`),width:720,footer:p?(0,Z.jsxs)(i,{children:[m&&(0,Z.jsx)(o,{theme:`solid`,disabled:!n,onClick:()=>r(p),children:a(`mcpMonitor.terminateExecution`,null,`终止`)}),(0,Z.jsx)(o,{onClick:t,children:a(`common.close`,null,`关闭`)})]}):null,children:[!p&&l&&(0,Z.jsx)(`div`,{className:`mcp-monitor-detail-loading`,children:(0,Z.jsx)(c,{})}),(0,Z.jsx)(O,{error:u,onRetry:f}),p&&(0,Z.jsxs)(`div`,{className:`mcp-monitor-detail`,children:[(0,Z.jsx)(E,{columns:2,items:[{label:`工具`,value:(0,Z.jsx)($,{strong:!0,children:W(p.toolName)||`—`})},{label:a(`mcpMonitor.columnStatus`,null,`状态`),value:(0,Z.jsx)(Q,{status:p.status})},{label:`执行 ID`,value:(0,Z.jsx)(`span`,{className:`mcp-monitor-mono`,children:p.id})},{label:a(`mcpMonitor.columnStartTime`,null,`开始时间`),value:v(p.startTime)},{label:`结束时间`,value:p.endTime?v(p.endTime):`—`},{label:a(`mcpMonitor.columnDuration`,null,`耗时`),value:K(G(p))},{label:`关联会话`,value:p.conversationId?(0,Z.jsxs)(i,{spacing:4,children:[(0,Z.jsx)(`span`,{className:`mcp-monitor-mono`,children:p.conversationId}),(0,Z.jsx)(A,{text:p.conversationId,size:`small`})]}):`—`},{label:`结果状态`,value:p.result?p.result.isError?`错误结果`:p.result.blocked?`已拦截`:`正常返回`:`无返回`}]}),p.error&&(0,Z.jsx)(g,{type:`danger`,className:`mcp-monitor-detail-error`,description:(0,Z.jsx)(`span`,{className:`mcp-monitor-mono`,children:p.error})}),(0,Z.jsx)(`div`,{className:`mcp-monitor-detail-section`,children:(0,Z.jsx)(N,{title:a(`mcpDetailModal.requestParams`,null,`入参`),value:p.arguments??{}})}),(0,Z.jsx)(`div`,{className:`mcp-monitor-detail-section`,children:p.result?(0,Z.jsx)(N,{title:a(`mcpDetailModal.responseResult`,null,`出参`),value:p.result}):(0,Z.jsx)(`div`,{className:`mcp-monitor-detail-empty`,children:m?a(`mcpDetailModal.runningNoResponseYet`,null,`尚无返回,工具可能仍在执行。`):a(`chat.noResponseData`,null,`暂无响应数据`)})}),p.partialOutput&&(0,Z.jsxs)(`div`,{className:`mcp-monitor-detail-section`,children:[(0,Z.jsxs)(`div`,{className:`mcp-monitor-detail-section-head`,children:[(0,Z.jsx)($,{strong:!0,children:`实时输出尾部`}),(0,Z.jsxs)(i,{spacing:4,children:[p.partialOutputBytes?(0,Z.jsxs)($,{type:`tertiary`,children:[p.partialOutputBytes,` B`]}):null,(0,Z.jsx)(A,{text:p.partialOutput,size:`small`})]})]}),(0,Z.jsx)(`pre`,{className:`mcp-monitor-detail-pre`,children:p.partialOutput})]}),(0,Z.jsxs)(`div`,{className:`mcp-monitor-detail-footnote`,children:[V(a,p.status),` · `,a(`mcpMonitor.statsFromAllTools`,null,`全部工具累计`)]})]})]})}function fe(){let e=S(),{hasPermission:t}=y(),[n,a]=r(),s=t(`monitor:write`)||t(`mcp:write`),c=t(`monitor:delete`),[l,u]=(0,I.useState)(1),[d,p]=(0,I.useState)(20),[g,_]=(0,I.useState)(`all`),[v,x]=(0,I.useState)(``),C=ne(v,350),[E,D]=(0,I.useState)([]),[O,A]=te(`mcp-monitor-timeline-range`,`7d`),[M,N]=(0,I.useState)(null),[L,R]=(0,I.useState)(``),[ie,z]=(0,I.useState)(!1),B=n.get(`id`)||``,V=[`24h`,`7d`,`30d`].includes(O)?O:`7d`,H=w(()=>b.get(`/monitor`,{page:l,page_size:d,status:g===`all`?``:g,tool:C}),[l,d,g,C]),U=w(()=>b.get(`/monitor/stats`,{top:12}),[]),K=w(()=>b.get(`/monitor/calls-timeline`,{range:V}),[V]),q=H.data?.executions||[],J=U.data?.summary||H.data?.summary||null,Y=U.data?.topTools||H.data?.topTools||[],X=Number(H.data?.retentionDays)||0,ce=(0,I.useMemo)(()=>q.filter(e=>G(e)!==null).length,[q]),Q=(0,I.useMemo)(()=>ae(q),[q]);j(()=>{typeof document<`u`&&document.hidden||(H.reload({silent:!0}),K.reload({silent:!0}))},5e3),j(()=>{typeof document<`u`&&document.hidden||U.reload({silent:!0})},2e4);let $=(0,I.useCallback)(()=>{H.reload(),U.reload({silent:!0}),K.reload({silent:!0})},[H.reload,U.reload,K.reload]),fe=(0,I.useCallback)(e=>{let t=new URLSearchParams(n);t.set(`id`,e),a(t,{replace:!0})},[n,a]),pe=(0,I.useCallback)(()=>{let e=new URLSearchParams(n);e.delete(`id`),a(e,{replace:!0})},[n,a]),me=(0,I.useCallback)(e=>{Object.prototype.hasOwnProperty.call(e,`toolInput`)&&x(e.toolInput),e.status!==void 0&&_(e.status),u(1),D([])},[]),he=(0,I.useCallback)((e,t)=>{u(e),t&&t!==d&&p(t)},[d]),ge=(0,I.useCallback)(e=>{x(W(e)),u(1),D([])},[]),_e=(0,I.useCallback)(t=>{F({title:e(`mcpMonitor.deleteExecTitle`,null,`删除此执行记录`),content:`确定删除 ${W(t.toolName)||`该`} 的执行记录?此操作不可恢复。`,okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{await b.del(`/monitor/execution/${encodeURIComponent(t.id)}`),D(e=>e.filter(e=>e!==t.id)),P(e(`mcpMonitor.execDeleted`,null,`执行记录已删除`)),$()}catch(t){T(t,e(`mcpMonitor.deleteExecFailed`,null,`删除执行记录失败`))}}})},[$,e]),ve=(0,I.useCallback)(async()=>{if(!E.length){ee(e(`mcpMonitor.selectExecFirst`,null,`请先选择要删除的执行记录`));return}let t=[];try{let e=await b.post(`/monitor/executions/names`,{ids:E});t=[...new Set(Object.values(e||{}).map(e=>W(e?.toolName)).filter(Boolean))]}catch{t=[]}let n=t.length?`涉及工具:${t.slice(0,3).join(`、`)}${t.length>3?` 等`:``}。`:``;F({title:e(`mcpMonitor.batchDeleteConfirm`,{count:E.length},`确定删除选中的 ${E.length} 条执行记录?`),content:`${n}此操作不可恢复。`,okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{await b.del(`/monitor/executions`,{body:{ids:E}}),P(`已删除 ${E.length} 条执行记录`),D([]),$()}catch(t){T(t,e(`mcp.batchDeleteFailed`,null,`批量删除执行记录失败`))}}})},[$,E,e]),ye=(0,I.useCallback)(e=>{N(e),R(``)},[]),be=(0,I.useCallback)(async()=>{if(M?.id){z(!0);try{await b.post(`/monitor/execution/${encodeURIComponent(M.id)}/cancel`,{note:L.trim()}),P(e(`mcpDetailModal.abortSuccess`,null,`已发送终止请求`)),N(null),$()}catch(t){T(t,e(`mcpDetailModal.abortFailed`,null,`终止失败`))}finally{z(!1)}}},[L,M,$,e]),xe=X>0?e(`mcpMonitor.retentionHint`,{days:X},`执行记录保留 ${X} 天,失败与拦截调用单独标记。`):`统计全部 MCP 工具调用,失败与拦截调用单独标记。`;return(0,Z.jsxs)(`div`,{className:`mcp-monitor-page`,children:[(0,Z.jsx)(re,{title:e(`mcp.monitorTitle`,null,`MCP 状态监控`),description:xe,extra:(0,Z.jsx)(i,{children:(0,Z.jsx)(o,{icon:(0,Z.jsx)(f,{}),onClick:$,loading:H.loading||U.loading,children:e(`common.refresh`,null,`刷新`)})})}),(0,Z.jsx)(oe,{summary:J,loading:U.loading&&!J,avgMs:Q,avgSamples:ce}),(0,Z.jsx)(le,{data:K.data,loading:K.loading,error:K.error,range:V,onRangeChange:e=>{e&&A(e)},onRetry:()=>K.reload()}),(0,Z.jsx)(se,{topTools:Y,loading:U.loading&&!Y.length,onFilterTool:ge,activeTool:C}),(0,Z.jsx)(k,{title:e(`mcp.latestExecutions`,null,`最新执行记录`),description:e(`mcpMonitor.emptyHint`,null,`在对话或任务中调用 MCP 工具后,执行记录将显示在此处`),extra:E.length>0?(0,Z.jsxs)(i,{spacing:8,children:[(0,Z.jsx)(`span`,{className:`mcp-monitor-selected`,children:e(`mcp.selectedCount`,{count:E.length},`已选择 ${E.length} 项`)}),(0,Z.jsx)(o,{size:`small`,disabled:!c,type:`danger`,onClick:ve,children:e(`mcp.deleteSelected`,null,`批量删除`)}),(0,Z.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>D([]),children:e(`mcpMonitor.deselectAll`,null,`取消全选`)})]}):null,children:(0,Z.jsx)(ue,{data:H.data,loading:H.loading,error:H.error,page:l,pageSize:d,status:g,toolInput:v,selected:E,onQuery:me,onPageChange:he,onRefresh:()=>H.reload(),onOpenDetail:fe,onCancel:ye,onDelete:_e,onSelectionChange:D,canWrite:s,canDelete:c})}),(0,Z.jsx)(de,{executionId:B,onClose:pe,canWrite:s,onCancelRequest:e=>{pe(),ye(e)}}),(0,Z.jsxs)(m,{title:e(`mcpMonitor.terminateExecution`,null,`终止执行`),visible:!!M,confirmLoading:ie,okText:e(`mcpMonitor.terminateExecution`,null,`终止`),cancelText:e(`common.cancel`,null,`取消`),onCancel:()=>N(null),onOk:be,children:[(0,Z.jsx)(`p`,{className:`mcp-monitor-cancel-hint`,children:e(`mcpDetailModal.abortHint`,null,`终止仅取消本次工具调用,不会停止整条对话;说明会与工具输出一起交给模型。`)}),(0,Z.jsx)(h,{rows:4,value:L,placeholder:e(`mcpDetailModal.abortNotePlaceholder`,null,`终止说明(可选),例如:命令执行时间过长,先终止。`),onChange:e=>R(e)})]})]})}export{fe as default};
\ No newline at end of file
diff --git a/web/static/app/assets/platform-rbac-CfMJo_yg.js b/web/static/app/assets/platform-rbac-CTE3UjWt.js
similarity index 99%
rename from web/static/app/assets/platform-rbac-CfMJo_yg.js
rename to web/static/app/assets/platform-rbac-CTE3UjWt.js
index 7e3e7179..cddc82e0 100644
--- a/web/static/app/assets/platform-rbac-CfMJo_yg.js
+++ b/web/static/app/assets/platform-rbac-CTE3UjWt.js
@@ -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,St as c,Tt as l,W as u,c as d,ct as f,i as p,ot as m,v as h}from"./semi-CXF9U6uC.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-CrDogtQS.js";var A=e(t(),1),j=e(n(),1),M=[[`project`,`项目`],[`conversation`,`会话`],[`asset`,`资产`],[`vulnerability`,`漏洞`],[`deep_assessment`,`深度测评`],[`batch_task`,`批量任务`]];function N({users:e,onCancel:t,onSaved:n}){let o=(0,A.useId)(),[s,c]=(0,A.useState)(M[0][0]),[l,d]=(0,A.useState)(``),[f,m]=(0,A.useState)(0),[g,_]=(0,A.useState)([]),[y,x]=(0,A.useState)(null),[w,E]=(0,A.useState)(!1),D=T(l,250),k=b(async()=>({type:s,q:D,offset:f,payload:await v.get(`/rbac/resources`,{type:s,q:D,limit:20,offset:f})}),[s,D,f]),N=k.data?.type===s&&k.data.q===D&&k.data.offset===f?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)(p,{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)(p.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)(p.Select,{field:`resource_type`,label:`资源类型`,optionList:M.map(([e,t])=>({value:e,label:t})),onChange:e=>{c(e),_([]),d(``),m(0)}}),(0,j.jsx)(p.Slot,{label:`按名称或 ID 搜索`,children:(0,j.jsx)(i,{"aria-label":`搜索资源`,value:l,onChange:e=>{d(e),m(0)}})}),(0,j.jsxs)(p.Slot,{label:`选择资源`,children:[(0,j.jsxs)(r,{wrap:!0,children:[(0,j.jsx)(a,{size:`small`,disabled:f===0||k.loading,onClick:()=>m(e=>Math.max(0,e-20)),children:`上一页`}),(0,j.jsxs)(u.Text,{type:`tertiary`,children:[f+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)(p.TextArea,{field:`ids`,label:`手动输入资源 ID`,placeholder:`多个 ID 用空格或换行分隔`,rows:2}),(0,j.jsx)(C,{error:y||k.error})]})})}var{Text:P}=u;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`),[u,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()=>{let e=await u.form.validate();z(!0);try{let t={name:e.name.trim(),description:e.description||``,scope:e.scope||``,permissions:u.permissions||[]};u.role?.id?await v.put(`/rbac/roles/${encodeURIComponent(u.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()=>{let e=await T.form.validate();z(!0);try{let t={display_name:e.display_name||``,enabled:e.enabled!==!1,roles:e.roles||[]};T.user?.id?(e.password&&(t.password=e.password),await v.put(`/rbac/users/${encodeURIComponent(T.user.id)}`,t)):await v.post(`/rbac/users`,{...t,username:e.username.trim(),password:e.password}),O(`用户已保存`),M(null),H.reload()}catch(e){x(e,`保存用户失败`)}finally{z(!1)}},$=e=>k({title:`删除角色「${e.name}」?`,onOk:async()=>{await v.del(`/rbac/roles/${encodeURIComponent(e.id)}`),O(`已删除`),V.reload()}}),ee=e=>k({title:`删除用户「${e.username}」?`,onOk:async()=>{await v.del(`/rbac/users/${encodeURIComponent(e.id)}`),O(`已删除`),H.reload()}}),te=e=>k({title:`删除该资源授权?`,content:`${e.resourceType||``} ${e.resourceId||``}`,onOk:async()=>{await v.del(`/rbac/resource-assignments/${encodeURIComponent(e.id)}`),O(`已删除`),U.reload()}});return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(E,{title:e(`auth.rbacTitle`,null,`平台权限`),description:`平台账号、角色与资源授权;角色决定接口权限键,资源授权决定可见数据范围。`,extra:(0,j.jsx)(a,{icon:(0,j.jsx)(m,{}),onClick:()=>{V.reload(),H.reload(),U.reload(),B.reload()},children:`刷新`})}),(0,j.jsxs)(d,{type:`line`,activeKey:i,onChange:s,children:[(0,j.jsx)(d.TabPane,{itemKey:`roles`,tab:`角色权限(${G.length})`,children:(0,j.jsxs)(w,{extra:n&&(0,j.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,j.jsx)(f,{}),onClick:()=>h({role:null,permissions:[],form:{}}),children:`新建角色`}),children:[(0,j.jsx)(C,{error:V.error,onRetry:()=>V.reload()}),(0,j.jsx)(D,{columns:[{title:`角色`,dataIndex:`name`,render:(e,t)=>(0,j.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,j.jsx)(P,{strong:!0,children:e}),(0,j.jsx)(P,{type:`tertiary`,children:t.description||`—`})]})},{title:`数据范围`,dataIndex:`scope`,width:130,render:e=>e?(0,j.jsx)(o,{size:`small`,children:e}):`—`},{title:`权限数`,dataIndex:`permissions`,width:100,render:e=>Array.isArray(e)?e.length:0},{title:`系统内置`,dataIndex:`is_system`,width:100,render:e=>e?(0,j.jsx)(o,{size:`small`,color:`blue`,children:`是`}):`否`},{title:`操作`,width:160,render:(e,t)=>(0,j.jsxs)(r,{children:[n&&!t.is_system&&(0,j.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,j.jsx)(c,{}),onClick:()=>h({role:t,permissions:t.permissions||[],form:{}}),children:`编辑`}),n&&!t.is_system&&(0,j.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,j.jsx)(l,{}),onClick:()=>$(t)})]})}],dataSource:G,rowKey:`id`,loading:V.loading,pagination:{pageSize:20}})]})}),(0,j.jsx)(d.TabPane,{itemKey:`users`,tab:`平台用户(${K.length})`,children:(0,j.jsxs)(w,{extra:n&&(0,j.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,j.jsx)(f,{}),onClick:()=>M({user:null,form:{}}),children:`新建用户`}),children:[(0,j.jsx)(C,{error:H.error,onRetry:()=>H.reload()}),(0,j.jsx)(D,{columns:[{title:`用户名`,dataIndex:`username`,render:(e,t)=>(0,j.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,j.jsx)(P,{strong:!0,children:e}),(0,j.jsx)(P,{type:`tertiary`,children:t.display_name||`—`})]})},{title:`角色`,dataIndex:`roles`,width:260,render:e=>Array.isArray(e)&&e.length?(0,j.jsx)(r,{wrap:!0,spacing:4,children:e.map(e=>(0,j.jsx)(o,{size:`small`,children:Y.get(e)||e},e))}):`—`},{title:`状态`,dataIndex:`enabled`,width:100,render:e=>e===!1?(0,j.jsx)(o,{size:`small`,color:`grey`,children:`停用`}):(0,j.jsx)(o,{size:`small`,color:`green`,children:`启用`})},{title:`操作`,width:160,render:(e,t)=>(0,j.jsxs)(r,{children:[n&&(0,j.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,j.jsx)(c,{}),onClick:()=>M({user:t,form:{}}),children:`编辑`}),n&&(0,j.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,j.jsx)(l,{}),onClick:()=>ee(t)})]})}],dataSource:K,rowKey:`id`,loading:H.loading,pagination:{pageSize:20}})]})}),(0,j.jsx)(d.TabPane,{itemKey:`assignments`,tab:`资源授权(${q.length})`,children:(0,j.jsxs)(w,{extra:n&&(0,j.jsx)(a,{theme:`solid`,icon:(0,j.jsx)(f,{}),onClick:()=>L(!0),children:`新增资源授权`}),children:[(0,j.jsx)(C,{error:U.error,onRetry:()=>U.reload()}),(0,j.jsx)(D,{columns:[{title:`资源类型`,dataIndex:`resourceType`,width:140,render:e=>e||`—`},{title:`资源`,dataIndex:`resourceId`,render:(e,t)=>t.resourceLabel||e||`—`},{title:`用户`,dataIndex:`userId`,render:e=>X.get(e)||e||`—`},{title:`创建时间`,dataIndex:`createdAt`,width:180,render:e=>g(e)},{title:`操作`,width:100,render:(e,t)=>n&&(0,j.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,j.jsx)(l,{}),onClick:()=>te(t)})}],dataSource:q,rowKey:`id`,loading:U.loading,pagination:{pageSize:20}})]})})]}),n&&I&&(0,j.jsx)(N,{users:K,onCancel:()=>L(!1),onSaved:()=>{L(!1),U.reload()}}),(0,j.jsx)(S,{title:u?.role?`编辑角色`:`新建角色`,visible:!!u,onCancel:()=>h(null),onOk:Z,confirmLoading:R,width:820,children:u&&(0,j.jsxs)(p,{getFormApi:e=>h(t=>t&&{...t,form:e}),initValues:u.role?{name:u.role.name,description:u.role.description,scope:u.role.scope}:{},children:[(0,j.jsx)(p.Input,{field:`name`,label:`角色名称`,rules:[{required:!0,message:`请输入角色名称`}]}),(0,j.jsx)(p.Input,{field:`description`,label:`描述`}),(0,j.jsx)(p.Select,{field:`scope`,label:`数据范围`,optionList:(B.data?.scopes||[`all`,`assigned`,`own`]).map(e=>({value:e,label:e}))}),(0,j.jsx)(p.Slot,{label:`权限`,children:(0,j.jsx)(F,{value:u.permissions,options:W,onChange:e=>h(t=>({...t,permissions:e}))})})]})},u?.role?.id||`new-rbac-role`),(0,j.jsx)(S,{title:T?.user?`编辑用户`:`新建用户`,visible:!!T,onCancel:()=>M(null),onOk:Q,confirmLoading:R,width:620,children:T&&(0,j.jsxs)(p,{getFormApi:e=>M(t=>t&&{...t,form:e}),initValues:T.user?{username:T.user.username,display_name:T.user.display_name,enabled:T.user.enabled!==!1,roles:T.user.roles||[]}:{enabled:!0,roles:[]},children:[(0,j.jsx)(p.Input,{field:`username`,label:`用户名`,disabled:!!T.user,rules:[{required:!0,message:`请输入用户名`}]}),(0,j.jsx)(p.Input,{field:`display_name`,label:`显示名称`}),(0,j.jsx)(p.Input,{field:`password`,label:T.user?`重置密码(留空不修改)`:`密码`,mode:`password`,rules:T.user?[]:[{required:!0,min:8,message:`至少 8 位`}]}),(0,j.jsx)(p.Select,{field:`roles`,label:`角色`,multiple:!0,optionList:J}),(0,j.jsx)(p.Slot,{label:`启用`,children:(0,j.jsx)(p.Switch,{field:`enabled`})})]})},T?.user?.id||`new-rbac-user`)]})}export{I as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,N as s,St as c,Tt as l,W as u,c as d,ct as f,i as p,ot as m,v as h}from"./semi-CXF9U6uC.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-LQJrYSgy.js";var A=e(t(),1),j=e(n(),1),M=[[`project`,`项目`],[`conversation`,`会话`],[`asset`,`资产`],[`vulnerability`,`漏洞`],[`deep_assessment`,`深度测评`],[`batch_task`,`批量任务`]];function N({users:e,onCancel:t,onSaved:n}){let o=(0,A.useId)(),[s,c]=(0,A.useState)(M[0][0]),[l,d]=(0,A.useState)(``),[f,m]=(0,A.useState)(0),[g,_]=(0,A.useState)([]),[y,x]=(0,A.useState)(null),[w,E]=(0,A.useState)(!1),D=T(l,250),k=b(async()=>({type:s,q:D,offset:f,payload:await v.get(`/rbac/resources`,{type:s,q:D,limit:20,offset:f})}),[s,D,f]),N=k.data?.type===s&&k.data.q===D&&k.data.offset===f?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)(p,{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)(p.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)(p.Select,{field:`resource_type`,label:`资源类型`,optionList:M.map(([e,t])=>({value:e,label:t})),onChange:e=>{c(e),_([]),d(``),m(0)}}),(0,j.jsx)(p.Slot,{label:`按名称或 ID 搜索`,children:(0,j.jsx)(i,{"aria-label":`搜索资源`,value:l,onChange:e=>{d(e),m(0)}})}),(0,j.jsxs)(p.Slot,{label:`选择资源`,children:[(0,j.jsxs)(r,{wrap:!0,children:[(0,j.jsx)(a,{size:`small`,disabled:f===0||k.loading,onClick:()=>m(e=>Math.max(0,e-20)),children:`上一页`}),(0,j.jsxs)(u.Text,{type:`tertiary`,children:[f+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)(p.TextArea,{field:`ids`,label:`手动输入资源 ID`,placeholder:`多个 ID 用空格或换行分隔`,rows:2}),(0,j.jsx)(C,{error:y||k.error})]})})}var{Text:P}=u;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`),[u,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()=>{let e=await u.form.validate();z(!0);try{let t={name:e.name.trim(),description:e.description||``,scope:e.scope||``,permissions:u.permissions||[]};u.role?.id?await v.put(`/rbac/roles/${encodeURIComponent(u.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()=>{let e=await T.form.validate();z(!0);try{let t={display_name:e.display_name||``,enabled:e.enabled!==!1,roles:e.roles||[]};T.user?.id?(e.password&&(t.password=e.password),await v.put(`/rbac/users/${encodeURIComponent(T.user.id)}`,t)):await v.post(`/rbac/users`,{...t,username:e.username.trim(),password:e.password}),O(`用户已保存`),M(null),H.reload()}catch(e){x(e,`保存用户失败`)}finally{z(!1)}},$=e=>k({title:`删除角色「${e.name}」?`,onOk:async()=>{await v.del(`/rbac/roles/${encodeURIComponent(e.id)}`),O(`已删除`),V.reload()}}),ee=e=>k({title:`删除用户「${e.username}」?`,onOk:async()=>{await v.del(`/rbac/users/${encodeURIComponent(e.id)}`),O(`已删除`),H.reload()}}),te=e=>k({title:`删除该资源授权?`,content:`${e.resourceType||``} ${e.resourceId||``}`,onOk:async()=>{await v.del(`/rbac/resource-assignments/${encodeURIComponent(e.id)}`),O(`已删除`),U.reload()}});return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(E,{title:e(`auth.rbacTitle`,null,`平台权限`),description:`平台账号、角色与资源授权;角色决定接口权限键,资源授权决定可见数据范围。`,extra:(0,j.jsx)(a,{icon:(0,j.jsx)(m,{}),onClick:()=>{V.reload(),H.reload(),U.reload(),B.reload()},children:`刷新`})}),(0,j.jsxs)(d,{type:`line`,activeKey:i,onChange:s,children:[(0,j.jsx)(d.TabPane,{itemKey:`roles`,tab:`角色权限(${G.length})`,children:(0,j.jsxs)(w,{extra:n&&(0,j.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,j.jsx)(f,{}),onClick:()=>h({role:null,permissions:[],form:{}}),children:`新建角色`}),children:[(0,j.jsx)(C,{error:V.error,onRetry:()=>V.reload()}),(0,j.jsx)(D,{columns:[{title:`角色`,dataIndex:`name`,render:(e,t)=>(0,j.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,j.jsx)(P,{strong:!0,children:e}),(0,j.jsx)(P,{type:`tertiary`,children:t.description||`—`})]})},{title:`数据范围`,dataIndex:`scope`,width:130,render:e=>e?(0,j.jsx)(o,{size:`small`,children:e}):`—`},{title:`权限数`,dataIndex:`permissions`,width:100,render:e=>Array.isArray(e)?e.length:0},{title:`系统内置`,dataIndex:`is_system`,width:100,render:e=>e?(0,j.jsx)(o,{size:`small`,color:`blue`,children:`是`}):`否`},{title:`操作`,width:160,render:(e,t)=>(0,j.jsxs)(r,{children:[n&&!t.is_system&&(0,j.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,j.jsx)(c,{}),onClick:()=>h({role:t,permissions:t.permissions||[],form:{}}),children:`编辑`}),n&&!t.is_system&&(0,j.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,j.jsx)(l,{}),onClick:()=>$(t)})]})}],dataSource:G,rowKey:`id`,loading:V.loading,pagination:{pageSize:20}})]})}),(0,j.jsx)(d.TabPane,{itemKey:`users`,tab:`平台用户(${K.length})`,children:(0,j.jsxs)(w,{extra:n&&(0,j.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,j.jsx)(f,{}),onClick:()=>M({user:null,form:{}}),children:`新建用户`}),children:[(0,j.jsx)(C,{error:H.error,onRetry:()=>H.reload()}),(0,j.jsx)(D,{columns:[{title:`用户名`,dataIndex:`username`,render:(e,t)=>(0,j.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,j.jsx)(P,{strong:!0,children:e}),(0,j.jsx)(P,{type:`tertiary`,children:t.display_name||`—`})]})},{title:`角色`,dataIndex:`roles`,width:260,render:e=>Array.isArray(e)&&e.length?(0,j.jsx)(r,{wrap:!0,spacing:4,children:e.map(e=>(0,j.jsx)(o,{size:`small`,children:Y.get(e)||e},e))}):`—`},{title:`状态`,dataIndex:`enabled`,width:100,render:e=>e===!1?(0,j.jsx)(o,{size:`small`,color:`grey`,children:`停用`}):(0,j.jsx)(o,{size:`small`,color:`green`,children:`启用`})},{title:`操作`,width:160,render:(e,t)=>(0,j.jsxs)(r,{children:[n&&(0,j.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,j.jsx)(c,{}),onClick:()=>M({user:t,form:{}}),children:`编辑`}),n&&(0,j.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,j.jsx)(l,{}),onClick:()=>ee(t)})]})}],dataSource:K,rowKey:`id`,loading:H.loading,pagination:{pageSize:20}})]})}),(0,j.jsx)(d.TabPane,{itemKey:`assignments`,tab:`资源授权(${q.length})`,children:(0,j.jsxs)(w,{extra:n&&(0,j.jsx)(a,{theme:`solid`,icon:(0,j.jsx)(f,{}),onClick:()=>L(!0),children:`新增资源授权`}),children:[(0,j.jsx)(C,{error:U.error,onRetry:()=>U.reload()}),(0,j.jsx)(D,{columns:[{title:`资源类型`,dataIndex:`resourceType`,width:140,render:e=>e||`—`},{title:`资源`,dataIndex:`resourceId`,render:(e,t)=>t.resourceLabel||e||`—`},{title:`用户`,dataIndex:`userId`,render:e=>X.get(e)||e||`—`},{title:`创建时间`,dataIndex:`createdAt`,width:180,render:e=>g(e)},{title:`操作`,width:100,render:(e,t)=>n&&(0,j.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,j.jsx)(l,{}),onClick:()=>te(t)})}],dataSource:q,rowKey:`id`,loading:U.loading,pagination:{pageSize:20}})]})})]}),n&&I&&(0,j.jsx)(N,{users:K,onCancel:()=>L(!1),onSaved:()=>{L(!1),U.reload()}}),(0,j.jsx)(S,{title:u?.role?`编辑角色`:`新建角色`,visible:!!u,onCancel:()=>h(null),onOk:Z,confirmLoading:R,width:820,children:u&&(0,j.jsxs)(p,{getFormApi:e=>h(t=>t&&{...t,form:e}),initValues:u.role?{name:u.role.name,description:u.role.description,scope:u.role.scope}:{},children:[(0,j.jsx)(p.Input,{field:`name`,label:`角色名称`,rules:[{required:!0,message:`请输入角色名称`}]}),(0,j.jsx)(p.Input,{field:`description`,label:`描述`}),(0,j.jsx)(p.Select,{field:`scope`,label:`数据范围`,optionList:(B.data?.scopes||[`all`,`assigned`,`own`]).map(e=>({value:e,label:e}))}),(0,j.jsx)(p.Slot,{label:`权限`,children:(0,j.jsx)(F,{value:u.permissions,options:W,onChange:e=>h(t=>({...t,permissions:e}))})})]})},u?.role?.id||`new-rbac-role`),(0,j.jsx)(S,{title:T?.user?`编辑用户`:`新建用户`,visible:!!T,onCancel:()=>M(null),onOk:Q,confirmLoading:R,width:620,children:T&&(0,j.jsxs)(p,{getFormApi:e=>M(t=>t&&{...t,form:e}),initValues:T.user?{username:T.user.username,display_name:T.user.display_name,enabled:T.user.enabled!==!1,roles:T.user.roles||[]}:{enabled:!0,roles:[]},children:[(0,j.jsx)(p.Input,{field:`username`,label:`用户名`,disabled:!!T.user,rules:[{required:!0,message:`请输入用户名`}]}),(0,j.jsx)(p.Input,{field:`display_name`,label:`显示名称`}),(0,j.jsx)(p.Input,{field:`password`,label:T.user?`重置密码(留空不修改)`:`密码`,mode:`password`,rules:T.user?[]:[{required:!0,min:8,message:`至少 8 位`}]}),(0,j.jsx)(p.Select,{field:`roles`,label:`角色`,multiple:!0,optionList:J}),(0,j.jsx)(p.Slot,{label:`启用`,children:(0,j.jsx)(p.Switch,{field:`enabled`})})]})},T?.user?.id||`new-rbac-user`)]})}export{I as default};
\ No newline at end of file
diff --git a/web/static/app/assets/project-form-B4sIa9Js.js b/web/static/app/assets/project-form-B4sIa9Js.js
deleted file mode 100644
index dc87a52d..00000000
--- a/web/static/app/assets/project-form-B4sIa9Js.js
+++ /dev/null
@@ -1 +0,0 @@
-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-CXF9U6uC.js";import{I as a,P as o,c as s,l as c,x as l}from"./index-CrDogtQS.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,maskClosable:h=!1}){let g=o(),_=(0,u.useId)(),[v,y]=(0,u.useState)(!1),[b,x]=(0,u.useState)(null),S=!!t?.id;return(0,u.useEffect)(()=>{x(null)},[e,t?.id]),(0,d.jsxs)(s,{visible:e,width:560,maskClosable:h&&!v,closable:!v,closeOnEsc:!v,onCancel:n,cancelButtonProps:{disabled:v},title:S?g(`projects.modalEditTitle`,null,`编辑项目`):g(`projects.modalNewTitle`,null,`新建项目`),formId:_,okText:S?g(`projects.saveChanges`,null,`保存修改`):g(`projects.createProject`,null,`创建项目`),confirmLoading:v,children:[(0,d.jsx)(f,{type:`tertiary`,size:`small`,children:S?g(`projects.modalEditSubtitle`,null,`修改项目名称与描述`):g(`projects.modalNewSubtitle`,null,`创建后可绑定对话,跨会话共享事实黑板`)}),(0,d.jsxs)(i,{id:_,onSubmit:async e=>{if(!v){y(!0),x(null);try{let n={name:e.name.trim(),description:(e.description||``).slice(0,m)},i=S?await a.put(`/projects/${t.id}`,n):await a.post(`/projects`,n);l(S?g(`projects.saved`,null,`已保存`):g(`projects.createProject`,null,`创建项目`)),r?.(i)}catch(e){x(e)}finally{y(!1)}}},initValues:{name:t?.name||``,description:t?.description||``},children:[(0,d.jsx)(i.Input,{id:`${_}-name`,field:`name`,maxLength:p,label:g(`projects.projectName`,null,`项目名称`),placeholder:g(`projects.projectNamePlaceholder`,null,`例如:某客户 Web 渗透`),rules:[{required:!0,whitespace:!0,message:g(`projects.enterProjectName`,null,`请输入项目名称`)}]}),(0,d.jsx)(i.TextArea,{id:`${_}-description`,field:`description`,rows:4,maxCount:m,label:g(`projects.projectDescription`,null,`项目描述`),placeholder:g(`projects.projectDescriptionPlaceholder`,null,`客户/任务备注、协作说明…`),extraText:g(`projects.descriptionLengthHint`,null,`仅供团队成员查阅,Agent 不会读取;需让 Agent 知晓的内容请写入事实黑板`)}),(0,d.jsx)(c,{error:b})]},`${e}-${t?.id||`new`}`)]})}export{h as t};
\ No newline at end of file
diff --git a/web/static/app/assets/project-form-eK0l0IHN.js b/web/static/app/assets/project-form-eK0l0IHN.js
new file mode 100644
index 00000000..173727a1
--- /dev/null
+++ b/web/static/app/assets/project-form-eK0l0IHN.js
@@ -0,0 +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-CXF9U6uC.js";import{I as a,P as o,c as s,l as c,x as l}from"./index-LQJrYSgy.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};
\ No newline at end of file
diff --git a/web/static/app/assets/projects-DbZBh5FW.js b/web/static/app/assets/projects-DSC8ZgPs.js
similarity index 65%
rename from web/static/app/assets/projects-DbZBh5FW.js
rename to web/static/app/assets/projects-DSC8ZgPs.js
index 72d5c0e9..245244ac 100644
--- a/web/static/app/assets/projects-DbZBh5FW.js
+++ b/web/static/app/assets/projects-DSC8ZgPs.js
@@ -1,4 +1,4 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,y as i}from"./react-QV7DAAIx.js";import{E as a,F as o,H as s,L as c,M as l,N as u,T as d,U as f,W as p,_ as m,at as h,c as g,ct as _,dt as v,f as y,g as b,ot as x,u as S,v as C,x as w}from"./semi-CXF9U6uC.js";import{E as T,F as E,I as D,P as O,_ as ee,a as k,b as A,c as j,d as M,f as N,l as P,m as F,n as I,p as te,s as L,t as R,x as z,y as B}from"./index-CrDogtQS.js";import{t as V}from"./project-form-B4sIa9Js.js";var H=e(t(),1),U=[{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(备注)`}],W={target:`目标`,auth:`认证`,infra:`基础设施`,business:`业务`,finding:`发现`,chain:`攻击链`,exploit:`利用`,poc:`POC`,note:`备注`,vuln:`漏洞`,missing:`缺失`},G=[{value:`tentative`,label:`待确认`},{value:`confirmed`,label:`已确认`},{value:`deprecated`,label:`已废弃`}],K={confirmed:{label:`已确认`,color:`green`},tentative:{label:`待确认`,color:`amber`},deprecated:{label:`已废弃`,color:`grey`}},q=[{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`},ne={target:`TARGET · 目标`,auth:`AUTH · 认证`,infra:`INFRA · 基础设施`,finding:`FINDING · 发现`,chain:`CHAIN · 攻击链`,exploit:`EXPLOIT · 利用`,poc:`POC · 验证`,vulnerability:`VULN · 漏洞`,note:`NOTE · 备注`,missing:`MISSING · 缺失`},re=[`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 ie(e,t=`加载失败`){return e?{message:Y(e,t)}:null}function ae(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,F as o,H as s,L as c,M as l,N as u,T as d,U as f,W as p,_ as m,at as h,c as g,ct as _,dt as v,f as y,g as b,ot as x,u as S,v as C,x as w}from"./semi-CXF9U6uC.js";import{E as T,F as E,I as D,P as O,_ as ee,a as k,b as A,c as j,d as M,f as N,l as P,m as F,n as I,p as te,s as L,t as R,x as z,y as B}from"./index-LQJrYSgy.js";import{t as V}from"./project-form-eK0l0IHN.js";var H=e(t(),1),U=[{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(备注)`}],W={target:`目标`,auth:`认证`,infra:`基础设施`,business:`业务`,finding:`发现`,chain:`攻击链`,exploit:`利用`,poc:`POC`,note:`备注`,vuln:`漏洞`,missing:`缺失`},G=[{value:`tentative`,label:`待确认`},{value:`confirmed`,label:`已确认`},{value:`deprecated`,label:`已废弃`}],K={confirmed:{label:`已确认`,color:`green`},tentative:{label:`待确认`,color:`amber`},deprecated:{label:`已废弃`,color:`grey`}},q=[{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`},ne={target:`TARGET · 目标`,auth:`AUTH · 认证`,infra:`INFRA · 基础设施`,finding:`FINDING · 发现`,chain:`CHAIN · 攻击链`,exploit:`EXPLOIT · 利用`,poc:`POC · 验证`,vulnerability:`VULN · 漏洞`,note:`NOTE · 备注`,missing:`MISSING · 缺失`},re=[`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 ie(e,t=`加载失败`){return e?{message:Y(e,t)}:null}function ae(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:oe}=p;function se({value:e}){let t=K[String(e||``).toLowerCase()]||{label:e||`—`,color:`grey`};return(0,X.jsx)(l,{size:`small`,color:t.color,children:t.label})}function ce({projectId:e,canWrite:t,revision:n=0,onAddFact:r,onEditFact:i,onViewFact:a,onMutated:d}){let f=O(),[p,m]=(0,H.useState)(``),g=I(p,300),[v,y]=(0,H.useState)(`all`),[S,w]=(0,H.useState)(`all`),[E,ee]=(0,H.useState)(!0),[j,M]=(0,H.useState)(!1),N=k(()=>D.get(`/projects/${e}/facts`,{limit:200,include_link_counts:`true`,exclude_deprecated:E?`true`:void 0,search:g.trim()||void 0,category:v===`all`?void 0:v,confidence:S===`all`?void 0:S,sparse_only:j?`true`:void 0}),[e,g,v,S,E,j,n]),te=(0,H.useMemo)(()=>Array.isArray(N.data)?N.data:[],[N.data]),R=async t=>{try{await D.post(`/projects/${e}/facts/deprecate`,{fact_key:t.fact_key}),z(f(`projects.saved`,null,`已保存`)),d?d():N.reload({silent:!0})}catch(e){A(Y(e,f(`projects.operationFailed`,null,`操作失败`)))}},V=async t=>{try{await D.post(`/projects/${e}/facts/restore`,{fact_key:t.fact_key,confidence:`tentative`}),z(f(`projects.saved`,null,`已保存`)),d?d():N.reload({silent:!0})}catch(e){A(Y(e,f(`projects.operationFailed`,null,`操作失败`)))}},K=t=>{B({title:f(`projects.deleteForeverTitle`,null,`永久删除`),content:f(`projects.confirmDeleteFact`,null,`删除该事实?`),okText:f(`common.delete`,null,`删除`),onOk:async()=>{try{await D.del(`/projects/${e}/facts/${t.id}`),z(f(`common.delete`,null,`删除`)),d?d():N.reload({silent:!0})}catch(e){A(Y(e,f(`projects.operationFailed`,null,`操作失败`)))}}})},q=[{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)(l,{size:`small`,color:`blue`,type:`light`,children:f(`projects.pinned`,null,`置顶`)}),t.related_vulnerability_id&&(0,X.jsx)(l,{size:`small`,color:`violet`,type:`light`,title:t.related_vulnerability_id,children:f(`projects.relatedVulnIdTitle`,null,`关联漏洞 ID`)})]})]})},{title:f(`projects.category`,null,`分类`),dataIndex:`category`,width:108,render:e=>(0,X.jsx)(l,{size:`small`,color:`cyan`,type:`light`,children:W[String(e||``).toLowerCase()]||e||`—`})},{title:f(`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:f(`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)(oe,{type:`tertiary`,children:`—`}):(0,X.jsxs)(`span`,{className:`project-link-counts`,title:f(`projects.linkCountsTitle`,null,`出边数 / 入边数`),children:[`↑`,t,` ↓`,n]})}},{title:f(`projects.confidence`,null,`置信度`),dataIndex:`confidence`,width:92,render:e=>(0,X.jsx)(se,{value:e})},{title:f(`projects.updated`,null,`更新`),dataIndex:`updated_at`,width:158,render:e=>(0,X.jsx)(oe,{size:`small`,children:T(e)})},{title:f(`common.actions`,null,`操作`),dataIndex:`id`,width:224,render:(e,n)=>{let r=String(n.confidence||``).toLowerCase()===`deprecated`;return(0,X.jsxs)(o,{spacing:2,wrap:!0,children:[(0,X.jsx)(c,{size:`small`,theme:`borderless`,onClick:()=>a?.(n.fact_key),children:f(`projects.details`,null,`详情`)}),(0,X.jsx)(c,{size:`small`,theme:`borderless`,disabled:!t,onClick:()=>i?.(n.fact_key),children:f(`common.edit`,null,`编辑`)}),r?(0,X.jsx)(c,{size:`small`,theme:`borderless`,disabled:!t,onClick:()=>V(n),children:f(`projects.restore`,null,`恢复`)}):(0,X.jsx)(b,{title:f(`projects.confirmDeprecateFact`,{factKey:n.fact_key},`将事实 ${n.fact_key} 标记为已废弃?`),onConfirm:()=>R(n),disabled:!t,children:(0,X.jsx)(c,{size:`small`,theme:`borderless`,disabled:!t,title:f(`projects.deprecateTitle`,null,`标记为已废弃`),children:f(`projects.deprecate`,null,`废弃`)})}),(0,X.jsx)(c,{size:`small`,theme:`borderless`,type:`danger`,disabled:!t,onClick:()=>K(n),children:f(`common.delete`,null,`删除`)})]})}}];return(0,X.jsxs)(F,{title:f(`projects.tabFacts`,null,`事实黑板`),description:f(`projects.factToolbarHint`,null,`索引仅含 key 与摘要;攻击链 / POC 写在 body,Agent 通过 get_project_fact 复现`),extra:(0,X.jsxs)(o,{children:[(0,X.jsx)(c,{icon:(0,X.jsx)(x,{}),theme:`borderless`,loading:N.loading,onClick:()=>{d?d():N.reload()}}),(0,X.jsx)(c,{type:`primary`,icon:(0,X.jsx)(_,{}),disabled:!t,onClick:r,children:f(`projects.addFact`,null,`添加事实`)})]}),children:[(0,X.jsx)(P,{error:ie(N.error),onRetry:N.reload}),(0,X.jsxs)(`div`,{className:`project-toolbar`,children:[(0,X.jsx)(s,{prefix:(0,X.jsx)(h,{}),value:p,showClear:!0,"aria-label":f(`projects.searchFactsSr`,null,`搜索事实`),placeholder:f(`projects.searchFactsPlaceholder`,null,`搜索 key、摘要、body…`),onChange:e=>m(e),style:{width:260}}),(0,X.jsx)(C,{value:v,onChange:y,style:{width:146},optionList:[{value:`all`,label:f(`projects.all`,null,`全部`)},...U]}),(0,X.jsx)(C,{value:S,onChange:w,style:{width:128},optionList:[{value:`all`,label:f(`projects.all`,null,`全部`)},...G]}),(0,X.jsx)(u,{checked:E,onChange:e=>ee(e.target.checked),children:f(`projects.hideDeprecated`,null,`隐藏废弃`)}),(0,X.jsx)(u,{checked:j,onChange:e=>M(e.target.checked),children:f(`projects.sparseOnly`,null,`仅待补全`)})]}),(0,X.jsx)(L,{columns:q,dataSource:te,rowKey:`id`,loading:N.loading,pagination:{pageSize:20},emptyText:p||v!==`all`||S!==`all`?f(`projects.noMatchingFacts`,null,`无匹配事实,请调整筛选条件`):f(`projects.noFacts`,null,`暂无事实,点击「添加事实」或由 Agent 自动写入`)})]})}var le={target:0,infra:1,auth:1,finding:2,chain:3,exploit:3,poc:3,vulnerability:4},ue=144,de=23,fe=(e,t)=>e.x[e.id,new Set])),i=new Set;for(let e of t)r.get(e.source).add(e.target),r.get(e.target).add(e.source),e.source===n&&i.add(e.target);let a=e=>le[e.type]??5,o=e=>n?e.id===n?1:i.has(e.id)?2:0:a(e),s=[...e].sort((e,t)=>a(e)-a(t)||e.id.localeCompare(t.id)),c=new Map(s.map(e=>[e.id,e])),l=new Map,u=new Set;for(let e of s){if(u.has(e.id))continue;let t=[e.id];u.add(e.id);for(let e of t){let n=o(c.get(e));l.has(n)||l.set(n,[]),l.get(n).push(e);for(let n of[...r.get(e)].sort())u.has(n)||(u.add(n),t.push(n))}}let d=new Map,f=Math.max(5,Math.min(32,Math.ceil(Math.sqrt(e.length)*1.25))),p=0;for(let e of[...l.keys()].sort((e,t)=>e-t)){let t=l.get(e),n=Math.ceil(t.length/Math.ceil(t.length/f));for(let e=0;ed.set(e,{x:p,y:(t-(r.length-1)/2)*63})),p+=172}p+=34}return d}var me=[{selector:`node`,style:{"background-color":`data(color)`,width:21,height:21}},{selector:`node[type = "target"]`,style:{width:25,height:25}},{selector:`node[type = "missing"]`,style:{"background-opacity":.15,"border-width":2,"border-color":`data(color)`,"border-style":`dashed`}},{selector:`node.current`,style:{width:30,height:30,"underlay-color":`data(color)`,"underlay-opacity":.22,"underlay-padding":6}},{selector:`edge`,style:{width:1.75,"line-color":`#8191a9`,"target-arrow-color":`#8191a9`,"target-arrow-shape":`triangle`,"arrow-scale":.9,"curve-style":`bezier`,opacity:.55}},{selector:`edge.focused`,style:{width:2,opacity:.92}},{selector:`edge[type = "links_vuln"]`,style:{"line-color":`#d45363`,"target-arrow-color":`#d45363`}},{selector:`edge[confidence = "tentative"]`,style:{"line-style":`dashed`,"line-dash-pattern":[5,4]}}];function he(e,t,n,r,i){let a=e.width(),o=e.height(),s=e.zoom(),c=e.nodes().map(e=>{let{x:t,y:n}=e.renderedPosition();return{id:e.id(),x:t,y:n,radius:Math.max(3,e.renderedOuterWidth()/2)}}).filter(({x:e,y:t})=>e>=0&&e<=a&&t>=0&&t<=o),l=c.map(({x:e,y:t,radius:n})=>({x:e-n-1,y:t-n-1,width:n*2+2,height:n*2+2})),u=({id:e})=>{if(e===n)return 0;if(e===r)return 1;let i=t.get(e).type;return i===`target`?2:i===`chain`?3:4},d=[];for(let e of c.sort((e,t)=>u(e)-u(t))){let{id:c,x:f,y:p,radius:m}=e;if(s<.46&&u(e)>3)continue;let h=t.get(c),g=(h.label!==`—`&&h.label||h.fact_key||c).replace(/\s+/g,` `).trim()||c,_=Math.min(s<.55&&r!==c&&n!==c?96:ue,Math.ceil(i(g))+21),v=Math.max(4,Math.min(f-_/2,a-_-4)),y=[{x:v,y:p+m+4},{x:v,y:p-m-de-4},{x:f+m+5,y:p-de/2},{x:f-m-_-5,y:p-de/2}];n||y.push(...y.splice(0,2));let b=y.map(e=>({...e,width:_,height:de})).find(e=>e.x>=3&&e.x+e.width<=a-3&&e.y>=3&&e.y+e.height<=o-3&&!l.some(t=>fe(e,t)));b&&(l.push({x:b.x-3,y:b.y-2,width:b.width+6,height:b.height+4}),d.push({id:c,title:g,box:b}))}return d}function ge({nodes:e,edges:t,selectedId:n,onSelect:r,chartRef:i,label:a,errorText:o}){let s=(0,H.useRef)(null),[c,l]=(0,H.useState)([]),[u,d]=(0,H.useState)(!1);return(0,H.useEffect)(()=>{let a=s.current,o=!1,c,u,f,p,m=!0,h=!1;return l([]),d(!1),R(async()=>{let{default:e}=await import(`./cytoscape.esm-BPjn7guX.js`);return{default:e}},[]).then(({default:s})=>{if(o)return;let d=new Map(e.map(e=>[e.id,e])),g=pe(e,t,n);c=s({container:a,elements:[...e.map(e=>({group:`nodes`,data:{id:e.id,type:e.type||`note`,color:J[e.type]||J.missing},position:g.get(e.id),classes:e.id===n?`current`:``})),...t.map((e,t)=>({group:`edges`,classes:n?`focused`:``,data:{...e,id:`edge|${t}|${e.id||``}`}}))],style:me,layout:{name:`preset`,fit:!1},minZoom:.006,maxZoom:3,wheelSensitivity:.2,boxSelectionEnabled:!1,autounselectify:!0,autoungrabify:!0});let _=document.createElement(`canvas`).getContext(`2d`);_.font=`500 12px ${getComputedStyle(a).fontFamily}`;let v=()=>{cancelAnimationFrame(f),f=requestAnimationFrame(()=>l(he(c,d,n,p,e=>_.measureText(e).width)))},y=()=>{h=!0,m=!0,c.fit(c.elements(),Math.min(56,c.width()/8)),c.zoom()>1&&c.zoom(1).center(),h=!1,v()};i.current={fit:y,zoom:e=>c.zoom({level:c.zoom()*e,renderedPosition:{x:c.width()/2,y:c.height()/2}})},c.on(`viewport`,()=>{h||(m=!1),v()}),c.on(`tap`,`node`,e=>r(e.target.id())),c.on(`mouseover`,`node`,e=>{p=e.target.id(),v()}),c.on(`mouseout`,`node`,()=>{p=void 0,v()});let b=c.width(),x=c.height();u=new ResizeObserver(()=>{c.resize();let e=c.width(),t=c.height();(b!==e||x!==t)&&(m?y():c.panBy({x:(e-b)/2,y:(t-x)/2}),b=e,x=t)}),u.observe(a),y()}).catch(()=>{o||d(!0)}),()=>{o=!0,cancelAnimationFrame(f),u?.disconnect(),c?.destroy(),i.current=null}},[e,t,n,r,i]),(0,X.jsxs)(`div`,{className:`project-graph-canvas-wrap`,role:`group`,"aria-label":a,children:[(0,X.jsx)(`div`,{ref:s,className:`project-graph-canvas`}),(0,X.jsx)(`div`,{className:`project-graph-labels`,children:c.map(({id:e,title:t,box:i})=>(0,X.jsx)(`button`,{type:`button`,className:`project-graph-label`,title:t,"aria-pressed":e===n,style:{left:i.x,top:i.y,width:i.width},onClick:()=>r(e),dir:`auto`,children:t},e))}),u&&(0,X.jsx)(`div`,{className:`project-graph-overlay`,role:`alert`,children:o})]})}var{Text:Z}=p,_e=[],ve=e=>e.summary||e.label||e.fact_key||e.id;function ye({nodes:e,onSelect:t,t:n}){let[r,i]=(0,H.useState)(``),[a,o]=(0,H.useState)(!1),c=(0,H.useId)(),l=r.trim().toLowerCase(),u=(0,H.useMemo)(()=>[...e].sort((e,t)=>(e.fact_key||e.id).localeCompare(t.fact_key||t.id)),[e]),d=(0,H.useMemo)(()=>{if(!l)return u;let e=u.filter(e=>[e.fact_key,e.label,e.summary,e.category].join(` `).toLowerCase().includes(l)),t=e.findIndex(e=>(e.fact_key||e.id).toLowerCase()===l);return t>0&&e.unshift(...e.splice(t,1)),e},[u,l]),f=e=>{t(e),o(!1),i(``)};return(0,X.jsxs)(`div`,{className:`project-graph-search`,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||o(!1)},children:[(0,X.jsx)(s,{prefix:(0,X.jsx)(h,{}),value:r,showClear:!0,placeholder:n(`projects.graphSearchPlaceholder`,null,`搜索节点…`),"aria-label":n(`projects.graphSearchSr`,null,`搜索节点`),"aria-controls":a?c:void 0,onChange:e=>{i(e),o(!0)},onFocus:()=>o(!0),onClick:()=>o(!0),onKeyDown:e=>{e.key===`Escape`&&a&&o(!1),e.key===`Enter`&&a&&d.length&&!e.nativeEvent.isComposing&&(e.preventDefault(),f(d[0].id))}}),a&&(0,X.jsxs)(`div`,{className:`project-graph-search-results`,id:c,children:[(0,X.jsx)(`div`,{className:`project-graph-search-count`,role:`status`,children:d.length?n(`projects.graphSearchCount`,{count:d.length},`${d.length} 个节点`):n(`projects.graphNoMatches`,null,`未找到匹配节点`)}),d.length>0&&(0,X.jsx)(`ul`,{className:`project-graph-search-list`,children:d.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{className:`project-graph-search-hit`,type:`button`,onClick:()=>f(e.id),children:[(0,X.jsx)(`span`,{title:ve(e),children:ve(e)}),(0,X.jsx)(`code`,{dir:`auto`,children:e.fact_key||e.id})]})},e.id))})]})]})}function be({projectId:e,canWrite:t,revision:n=0,onOpenFact:r,onEditFact:i,onAddFact:a,onChanged:s}){let p=O(),[m,h]=(0,H.useState)(`path`),[g,y]=(0,H.useState)(!0),[b,S]=(0,H.useState)(``),[w,T]=(0,H.useState)(!1),E=(0,H.useRef)(null),ee=(0,H.useRef)(null),j=`${m}:${g}`,M=k(async()=>({scope:j,data:await D.get(`/projects/${e}/fact-graph`,{view:m,exclude_deprecated:g?`1`:`0`})}),[e,j,n]),N=M.data?.scope===j?M.data.data:null,I=N?.nodes||_e,te=(0,H.useMemo)(()=>new Map(I.map(e=>[e.id,e])),[I]),L=(0,H.useMemo)(()=>(N?.edges||_e).filter(e=>te.has(e.source)&&te.has(e.target)),[N,te]),R=te.get(b);(0,H.useEffect)(()=>{ee.current&&(ee.current.scrollTop=0)},[R?.id]);let V=(0,H.useMemo)(()=>R?L.filter(e=>e.source===R.id||e.target===R.id):L,[L,R]),U=(0,H.useMemo)(()=>{if(!R)return I;let e=new Set([R.id]);for(let t of V)e.add(t.source),e.add(t.target);return I.filter(t=>e.has(t.id))},[I,R,V]),W=Object.keys(J).filter(e=>U.some(t=>t.type===e)),G=e=>p(`projects.graphNodeTypes.${e}`,null,ne[e]||e),q=(0,H.useCallback)(e=>S(e),[]),re=k(()=>w?D.get(`/projects/${e}/fact-edges`):Promise.resolve(null),[e,w,n]),ae=()=>{s?s():(M.reload(),w&&re.reload())},oe=t=>{B({title:p(`projects.graphDeleteEdge`,null,`删边`),content:p(`projects.confirmDeleteGraphEdge`,null,`确定删除此关系边?`),okText:p(`common.delete`,null,`删除`),onOk:async()=>{try{await D.del(`/projects/${e}/fact-edges/${t.id}`),z(p(`projects.graphEdgeDeleteSuccess`,null,`边已删除`)),ae()}catch(e){A(Y(e,p(`projects.graphEdgeDeleteFailed`,null,`删除边失败`)))}}})},se=(e,t)=>p(`projects.graphStats`,{nodes:e,edges:t},`${e} 个节点 · ${t} 条关系`),ce=p(`projects.tabGraph`,null,`攻击路径`),le=R&&R.type!==`missing`&&!R.id.startsWith(`vuln:`);return(0,X.jsxs)(F,{title:ce,className:`project-graph-card`,extra:(0,X.jsxs)(o,{children:[(0,X.jsx)(Z,{type:`tertiary`,size:`small`,children:se(I.length,L.length)}),(0,X.jsx)(c,{icon:(0,X.jsx)(x,{}),"aria-label":p(`common.refresh`,null,`刷新`),theme:`borderless`,loading:M.loading,onClick:ae})]}),children:[(0,X.jsx)(P,{error:ie(M.error),onRetry:M.reload}),(0,X.jsxs)(`div`,{className:`project-toolbar project-graph-toolbar`,children:[(0,X.jsx)(C,{value:m,"aria-label":p(`projects.graphScope`,null,`关系范围`),onChange:e=>{S(``),h(e)},style:{width:134},optionList:[{value:`path`,label:p(`projects.graphViewPath`,null,`攻击路径`)},{value:`full`,label:p(`projects.graphViewFull`,null,`完整关系`)}]}),(0,X.jsx)(ye,{nodes:I,onSelect:q,t:p}),(0,X.jsx)(u,{checked:g,onChange:e=>{S(``),y(e.target.checked)},children:p(`projects.hideDeprecated`,null,`隐藏废弃`)}),(0,X.jsx)(c,{className:`project-graph-edges-toggle`,"aria-expanded":w,onClick:()=>T(e=>!e),children:p(`projects.graphEdgesTitle`,null,`关系边`)})]}),I.length>0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`project-graph-status`,children:R?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(c,{size:`small`,theme:`light`,type:`primary`,onClick:()=>S(``),children:p(`projects.graphBackToOverview`,null,`返回全图`)}),(0,X.jsx)(Z,{size:`small`,"aria-live":`polite`,children:p(`projects.graphFocus`,{stats:se(U.length,V.length)},`聚焦直接关系 · ${se(U.length,V.length)}`)})]}):(0,X.jsx)(Z,{type:`tertiary`,size:`small`,children:p(`projects.graphOverviewHint`,null,`点选节点查看直接关系,放大后显示更多标签。`)})}),(0,X.jsxs)(`div`,{className:`project-graph-layout${R&&U.length<=6?` is-compact`:``}`,children:[(0,X.jsxs)(`div`,{className:`project-graph-viewport`,children:[(0,X.jsx)(ge,{nodes:U,edges:V,selectedId:R?.id,onSelect:q,chartRef:E,label:p(`projects.graphCanvas`,null,`攻击路径画布`),errorText:p(`projects.graphRenderError`,null,`图谱加载失败,请刷新重试。`)}),(0,X.jsxs)(`div`,{className:`project-graph-footer`,children:[(0,X.jsxs)(`div`,{className:`project-graph-legend`,children:[W.map(e=>(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`i`,{"aria-hidden":`true`,style:{background:J[e]}}),G(e)]},e)),V.some(e=>e.confidence===`tentative`)&&(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`i`,{className:`project-graph-legend-dash`,"aria-hidden":`true`}),p(`projects.graphTentativeEdge`,null,`待确认关系`)]})]}),(0,X.jsxs)(o,{spacing:4,children:[(0,X.jsx)(c,{size:`small`,icon:(0,X.jsx)(v,{}),"aria-label":p(`projects.graphZoomOut`,null,`缩小`),onClick:()=>E.current?.zoom(1/1.3)}),(0,X.jsx)(c,{size:`small`,icon:(0,X.jsx)(_,{}),"aria-label":p(`projects.graphZoomIn`,null,`放大`),onClick:()=>E.current?.zoom(1.3)}),(0,X.jsx)(c,{size:`small`,onClick:()=>E.current?.fit(),children:p(`projects.graphFit`,null,`适合画布`)})]})]})]}),R&&(0,X.jsx)(`aside`,{ref:ee,className:`project-graph-side`,"aria-label":p(`projects.graphNodeDetails`,null,`节点详情`),children:(0,X.jsxs)(`div`,{className:`project-detail-stack`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(Z,{strong:!0,children:ve(R)}),(0,X.jsx)(`code`,{className:`project-graph-node-key`,dir:`auto`,children:R.fact_key||R.id}),(0,X.jsxs)(`div`,{className:`project-graph-side-tags`,children:[(0,X.jsx)(l,{size:`small`,color:`blue`,type:`light`,children:G(R.type)}),(0,X.jsx)(l,{size:`small`,color:K[R.confidence]?.color||`grey`,children:K[R.confidence]?p(`projects.graphConfidence.${R.confidence}`,null,K[R.confidence].label):R.confidence||`—`})]})]}),le&&(0,X.jsxs)(o,{children:[(0,X.jsx)(c,{size:`small`,onClick:()=>r(R.fact_key),children:p(`projects.details`,null,`详情`)}),(0,X.jsx)(c,{size:`small`,disabled:!t,onClick:()=>i(R.fact_key),children:p(`common.edit`,null,`编辑`)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(Z,{strong:!0,size:`small`,children:[p(`projects.graphDirectLinks`,null,`直接关系`),` · `,V.length]}),V.length?(0,X.jsx)(`ul`,{className:`project-graph-neighbors`,children:V.map((e,t)=>{let n=e.source===R.id,r=te.get(n?e.target:e.source);return(0,X.jsxs)(`li`,{children:[(0,X.jsxs)(`div`,{className:`project-graph-edge-meta`,children:[(0,X.jsxs)(`span`,{children:[n?`→`:`←`,` `,n?p(`projects.graphEdgeOutgoing`,null,`出边`):p(`projects.graphEdgeIncoming`,null,`入边`)]}),(0,X.jsx)(`code`,{children:e.type}),e.confidence===`tentative`&&(0,X.jsx)(`span`,{children:p(`projects.graphConfidence.tentative`,null,`待确认`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`project-graph-peer project-link-button`,onClick:()=>q(r.id),title:r.fact_key,children:ve(r)})]},e.id||t)})}):(0,X.jsx)(`div`,{children:(0,X.jsx)(Z,{type:`tertiary`,size:`small`,children:p(`projects.graphEdgesEmpty`,null,`暂无关系边`)})})]})]})})]})]}):M.loading?(0,X.jsx)(`div`,{className:`project-graph-loading`,children:(0,X.jsx)(f,{})}):N&&!M.error?(0,X.jsxs)(d,{title:p(`projects.graphEmptyTitle`,null,`构建攻击路径图`),description:p(`projects.graphEmpty`,null,`暂无路径图数据。为 finding/exploit 类事实添加关系边(discovered_on → target/*)后将在此展示。`),style:{padding:40},children:[(0,X.jsxs)(`div`,{className:`project-graph-empty-steps`,children:[(0,X.jsx)(Z,{type:`tertiary`,children:p(`projects.graphEmptyStep1`,null,`添加 target 类事实(目标、域名、入口)`)}),(0,X.jsx)(Z,{type:`tertiary`,children:p(`projects.graphEmptyStep2`,null,`记录 finding / exploit 并在 links 中连边`)}),(0,X.jsx)(Z,{type:`tertiary`,children:p(`projects.graphEmptyStep3`,null,`使用「连边」模式或编辑事实手动补关系`)})]}),(0,X.jsx)(c,{type:`primary`,disabled:!t,onClick:a,children:p(`projects.graphEmptyCta`,null,`添加第一条事实`)})]}):null,w?(0,X.jsxs)(`div`,{className:`project-edge-table`,children:[(0,X.jsx)(P,{error:ie(re.error),onRetry:()=>re.reload()}),(re.data||[]).length?(0,X.jsx)(`ul`,{className:`project-edge-rows`,children:re.data.map(e=>(0,X.jsxs)(`li`,{className:`project-edge-row`,children:[(0,X.jsx)(`code`,{children:e.source_fact_key}),(0,X.jsx)(`span`,{className:`project-edge-type`,children:e.edge_type}),(0,X.jsx)(`span`,{className:`project-edge-arrow`,children:`→`}),(0,X.jsx)(`code`,{children:e.target_fact_key}),(0,X.jsx)(l,{size:`small`,color:e.confidence===`tentative`?`amber`:`green`,children:(K[e.confidence]||{}).label||e.confidence||`—`}),(0,X.jsx)(c,{size:`small`,theme:`borderless`,type:`danger`,disabled:!t,onClick:()=>oe(e),children:p(`projects.graphDeleteEdge`,null,`删边`)})]},e.id))}):(0,X.jsx)(Z,{type:`tertiary`,size:`small`,children:p(`projects.graphEdgesEmpty`,null,`暂无关系边`)})]}):null]})}var{Text:xe}=p;function Se({projectId:e,canWrite:t,onChanged:r}){let i=O(),a=n(),{hasPermission:s}=E(),u=s(`chat:write`),d=k(()=>D.get(`/projects/${e}/conversations`,{limit:100}),[e]),f=d.data?.conversations||[],p=t=>{B({title:i(`projects.promoteAttackChain`,null,`沉淀攻击链`),content:i(`projects.confirmPromoteAttackChain`,null,`将该对话的攻击链沉淀到本项目?会创建/更新事实与关系边。`),okText:i(`projects.promoteAttackChain`,null,`沉淀攻击链`),danger:!1,onOk:async()=>{try{let n=await D.post(`/projects/${e}/promote-attack-chain/${t.id}`);z(i(`projects.promoteAttackChainSuccess`,{facts_created:n?.facts_created||0,facts_updated:n?.facts_updated||0,edges_created:n?.edges_created||0},`已沉淀:新建 ${n?.facts_created||0} / 更新 ${n?.facts_updated||0} / 边 ${n?.edges_created||0}`)),d.reload({silent:!0}),r?.()}catch(e){A(Y(e,i(`projects.promoteAttackChainFailed`,null,`沉淀失败`)))}}})},m=e=>{B({title:i(`projects.unbind`,null,`解绑`),content:i(`projects.confirmUnbindConversation`,null,`解除该对话与当前项目的绑定?`),okText:i(`projects.unbind`,null,`解绑`),onOk:async()=>{try{await D.put(`/conversations/${e.id}/project`,{projectId:``}),z(i(`projects.projectUnbound`,null,`已解除项目绑定`)),d.reload({silent:!0}),r?.()}catch(e){A(Y(e,i(`projects.unbindFailed`,null,`解绑失败`)))}}})},h=[{title:i(`projects.titleLabel`,null,`标题`),dataIndex:`title`,render:(e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`project-link-button`,onClick:()=>a(`/chat?conversation=${encodeURIComponent(t.id)}`),title:e||t.id,children:e||i(`projects.untitledConversation`,null,`未命名对话`)})},{title:`ID`,dataIndex:`id`,width:240,render:e=>(0,X.jsx)(xe,{type:`tertiary`,size:`small`,children:(0,X.jsx)(`code`,{children:e})})},{title:i(`projects.updated`,null,`更新`),dataIndex:`updated_at`,width:170,render:(e,t)=>(0,X.jsx)(xe,{size:`small`,children:T(e||t.updatedAt||t.created_at||t.createdAt)})},{title:i(`common.actions`,null,`操作`),dataIndex:`id`,width:280,render:(e,n)=>(0,X.jsxs)(o,{spacing:2,wrap:!0,children:[(0,X.jsx)(c,{size:`small`,theme:`borderless`,onClick:()=>a(`/chat?conversation=${encodeURIComponent(n.id)}`),children:i(`projects.open`,null,`打开`)}),(0,X.jsx)(c,{size:`small`,theme:`borderless`,disabled:!t,title:i(`projects.promoteAttackChainTitle`,null,`将对话攻击链沉淀为项目事实与边`),onClick:()=>p(n),children:i(`projects.promoteAttackChain`,null,`沉淀攻击链`)}),(0,X.jsx)(c,{size:`small`,theme:`borderless`,disabled:!u,title:i(`projects.unbindProjectTitle`,null,`解除项目绑定`),onClick:()=>m(n),children:i(`projects.unbind`,null,`解绑`)})]})}];return(0,X.jsxs)(F,{title:i(`projects.tabConversations`,null,`关联对话`),description:i(`projects.boundConversationsHint`,null,`绑定到本项目的对话;点击可打开会话`),extra:(0,X.jsx)(l,{size:`small`,color:`blue`,type:`light`,children:f.length}),children:[(0,X.jsx)(P,{error:ie(d.error),onRetry:d.reload}),(0,X.jsx)(L,{columns:h,dataSource:f,rowKey:`id`,loading:d.loading,pagination:{pageSize:10},emptyText:i(`projects.noBoundConversations`,null,`暂无绑定对话;在对话页选择本项目即可关联`),onRefresh:()=>d.reload()})]})}var{Text:Q}=p,Ce={targets:[`https://example.com`],exclude:[`*.cdn.example.com`],notes:`仅授权 Web 应用层测试`};function we({project:e,canWrite:t,canDelete:n,onChanged:r,onDeleted:i}){let l=O(),[u,d]=(0,H.useState)({name:``,description:``,scope_json:``,status:`active`,pinned:!1}),[f,p]=(0,H.useState)(!1);(0,H.useEffect)(()=>{e&&d({name:e.name||``,description:e.description||``,scope_json:e.scope_json||``,status:e.status||`active`,pinned:!!e.pinned})},[e]);let m=e=>d(t=>({...t,...e})),h=()=>{let e=u.scope_json.trim();if(e)try{m({scope_json:JSON.stringify(JSON.parse(e),null,2)})}catch(e){A(l(`projects.invalidJson`,null,`JSON 格式无效`)+`:`+Y(e,``))}},g=()=>m({scope_json:JSON.stringify(Ce,null,2)}),_=async()=>{let t=u.name.trim();if(!t){A(l(`projects.enterProjectName`,null,`请输入项目名称`));return}let n=u.scope_json.trim();if(n)try{JSON.parse(n)}catch{A(l(`projects.invalidScopeJson`,null,`测试范围 JSON 无效,请先修正或点击「格式化」`));return}p(!0);try{await D.put(`/projects/${e.id}`,{name:t,description:u.description,scope_json:n,status:u.status,pinned:!!u.pinned}),z(l(`projects.saved`,null,`已保存`)),r?.()}catch(e){A(Y(e,l(`projects.saveFailed`,null,`保存失败`)))}finally{p(!1)}},v=(e?.status||`active`)===`archived`;return e?(0,X.jsxs)(F,{title:l(`projects.settingsIntroTitle`,null,`项目设置`),description:l(`projects.settingsIntroHint`,null,`配置项目元数据与 Agent 授权边界,保存后即时生效于绑定对话。`),extra:(0,X.jsx)(c,{type:`primary`,loading:f,disabled:!t,onClick:_,children:l(`projects.saveSettings`,null,`保存更改`)}),children:[(0,X.jsxs)(`div`,{className:`project-form-grid`,children:[(0,X.jsxs)(`div`,{className:`project-form-field`,children:[(0,X.jsx)(Q,{strong:!0,size:`small`,children:l(`projects.projectName`,null,`项目名称`)}),(0,X.jsx)(s,{value:u.name,disabled:!t,onChange:e=>m({name:e})}),(0,X.jsx)(Q,{type:`tertiary`,size:`small`,children:l(`projects.saveChangesHint`,null,`修改后请点击保存以同步到服务器`)})]}),(0,X.jsxs)(`div`,{className:`project-form-field`,children:[(0,X.jsx)(Q,{strong:!0,size:`small`,children:l(`projects.status`,null,`状态`)}),(0,X.jsx)(C,{value:u.status,disabled:!t,optionList:q,onChange:e=>m({status:e}),style:{width:`100%`}}),(0,X.jsxs)(`div`,{className:`project-switch-row`,children:[(0,X.jsx)(S,{checked:u.pinned,disabled:!t,onChange:e=>m({pinned:e})}),(0,X.jsx)(Q,{size:`small`,children:l(`projects.pinProject`,null,`置顶项目(列表优先显示)`)})]})]})]}),(0,X.jsxs)(`div`,{className:`project-form-field`,children:[(0,X.jsx)(Q,{strong:!0,size:`small`,children:l(`projects.projectDescription`,null,`项目描述`)}),(0,X.jsx)(w,{value:u.description,rows:3,maxCount:4e3,disabled:!t,placeholder:l(`projects.editDescriptionPlaceholder`,null,`客户/任务备注、协作说明、联系人…`),onChange:e=>m({description:e})})]}),(0,X.jsxs)(`div`,{className:`project-form-field`,children:[(0,X.jsxs)(o,{children:[(0,X.jsx)(Q,{strong:!0,size:`small`,children:l(`projects.scopeJsonLabel`,null,`范围 JSON`)}),(0,X.jsx)(c,{size:`small`,theme:`borderless`,disabled:!t,onClick:h,children:l(`projects.formatJson`,null,`格式化`)}),(0,X.jsx)(c,{size:`small`,theme:`borderless`,disabled:!t,onClick:g,children:l(`projects.example`,null,`示例`)})]}),(0,X.jsx)(w,{value:u.scope_json,rows:8,disabled:!t,placeholder:`{
"targets": ["https://example.com"]
-}`,onChange:e=>m({scope_json:e})}),(0,X.jsx)(Q,{type:`tertiary`,size:`small`,children:l(`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:l(`projects.dangerZoneTitle`,null,`危险操作`)}),(0,X.jsx)(`div`,{children:(0,X.jsx)(Q,{type:`tertiary`,size:`small`,children:l(`projects.dangerZoneHint`,null,`归档后需在列表勾选「显示已归档」才能查看;删除将清除全部事实且不可恢复。`)})})]}),(0,X.jsxs)(o,{children:[(0,X.jsx)(c,{disabled:!t,onClick:()=>{B({title:v?l(`projects.restoreProjectActive`,null,`恢复为进行中`):l(`projects.archiveProject`,null,`归档`),content:v?l(`projects.confirmRestoreProjectActive`,null,`恢复为 active?`):l(`projects.confirmArchiveProject`,null,`归档后默认不再出现在活跃列表,是否继续?`),okText:l(`common.confirm`,null,`确认`),danger:!v,onOk:async()=>{try{await D.put(`/projects/${e.id}`,{status:v?`active`:`archived`}),z(l(`projects.saved`,null,`已保存`)),r?.()}catch(e){A(Y(e,l(`projects.operationFailed`,null,`操作失败`)))}}})},children:v?l(`projects.restoreProjectActive`,null,`恢复为进行中`):l(`projects.archiveProject`,null,`归档`)}),(0,X.jsx)(c,{type:`danger`,disabled:!n,onClick:()=>{B({title:l(`projects.deleteProject`,null,`删除项目`),content:l(`projects.confirmDeleteProject`,null,`确定删除该项目?事实将一并删除,对话将解除绑定。`),okText:l(`common.delete`,null,`删除`),onOk:async()=>{try{await D.del(`/projects/${e.id}`),z(l(`projects.deleteProject`,null,`删除项目`)),i?.(e.id)}catch(e){A(Y(e,l(`projects.deleteFailed`,null,`删除失败`)))}}})},children:l(`projects.deleteProject`,null,`删除项目`)})]})]})]}):(0,X.jsx)(F,{title:l(`projects.tabSettings`,null,`设置`),children:(0,X.jsx)(Q,{type:`tertiary`,children:l(`projects.selectOrCreateTitle`,null,`选择或创建项目`)})})}var{Text:$}=p,Te={fact_key:``,category:`note`,summary:``,body:``,confidence:`tentative`,pinned:!1,related_vulnerability_id:``,links_text:``};function Ee({visible:e,projectId:t,factKey:n,onCancel:r,onSaved:i}){let a=O(),[o,c]=(0,H.useState)(Te),[l,d]=(0,H.useState)(U),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(``),v=!!n;(0,H.useEffect)(()=>{if(!e||(c(Te),d(U),_(``),p(!1),h(!1),!n))return;let r=!1;return p(!0),D.get(`/projects/${t}/facts`,{fact_key:n,include_links:`true`}).then(e=>{if(r||!e)return;let t=e.category||`note`;U.some(e=>e.value===t)||d([...U,{value:t,label:`${t}(自定义)`}]),_(e.id||``),c({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:ae(e.incoming_links)})}).catch(e=>{r||A(Y(e,a(`projects.loadFactFailed`,null,`加载事实失败`)))}).finally(()=>{r||p(!1)}),()=>{r=!0}},[e,t,n]);let y=e=>c(t=>({...t,...e})),b=(0,H.useMemo)(()=>re.join(`、`),[]);return(0,X.jsxs)(j,{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){A(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)A(a(`projects.loadFactFailed`,null,`加载事实失败`));else{h(!0);try{v&&g?await D.put(`/projects/${t}/facts/${g}`,r):await D.post(`/projects/${t}/facts`,r),z(a(`projects.saved`,null,`已保存`)),i?.()}catch(e){A(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,maskClosable:!1,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)(s,{value:o.fact_key,disabled:f,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)(C,{value:o.category,optionList:l,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)(s,{value:o.summary,placeholder:a(`projects.summary`,null,`摘要`)+`:什么 + 在哪 + 如何验证`,onChange:e=>y({summary:e})})]}),(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:a(`projects.confidence`,null,`置信度`)}),(0,X.jsx)(C,{value:o.confidence,optionList:G,onChange:e=>y({confidence:e}),style:{width:`100%`}})]}),(0,X.jsxs)(`div`,{className:`project-form-field`,children:[(0,X.jsx)($,{strong:!0,size:`small`,children:a(`projects.relatedVulnIdLabel`,null,`关联漏洞 ID`)}),(0,X.jsx)(s,{value:o.related_vulnerability_id,placeholder:a(`projects.optional`,null,`可选`),onChange:e=>y({related_vulnerability_id:e})})]})]}),(0,X.jsxs)(`div`,{className:`project-form-field`,children:[(0,X.jsx)($,{strong:!0,size:`small`,children:`body`}),(0,X.jsx)(w,{value:o.body,rows:10,placeholder:"## 验证步骤\n1. …\n\n```http\nGET /path HTTP/1.1\n```",onChange:e=>y({body:e})}),(0,X.jsx)($,{type:`tertiary`,size:`small`,children:a(`projects.factBodyRelationsHint`,null,`正文中的 discovered_on 等关系请填写到下方“关系边”字段,才能生成图谱连线。`)})]}),(0,X.jsxs)(`div`,{className:`project-form-field`,children:[(0,X.jsx)($,{strong:!0,size:`small`,children:a(`projects.factLinksLabel`,null,`关系边(from → 本事实)`)}),(0,X.jsx)(w,{value:o.links_text,rows:3,placeholder:a(`projects.factLinksPlaceholder`,null,`discovered_on: target/primary_domain`),onChange:e=>y({links_text:e})}),(0,X.jsxs)($,{type:`tertiary`,size:`small`,children:[a(`projects.factLinksHint`,null,`每行一条:type: source_fact_key(来源 → 当前事实)。`),` `,`常用 type:`,b,`。`]})]}),(0,X.jsx)(u,{checked:o.pinned,onChange:e=>y({pinned:e.target.checked}),children:a(`projects.pinFact`,null,`置顶事实(列表与黑板索引优先)`)})]})}var{Text:De,Paragraph:Oe}=p;function ke({value:e}){let t=K[String(e||``).toLowerCase()]||{label:e||`—`,color:`grey`};return(0,X.jsx)(l,{size:`small`,color:t.color,children:t.label})}function Ae({projectId:e,factKey:t,visible:n,canWrite:r,revision:i=0,onClose:a,onEdit:s}){let u=O(),f=k(()=>t?D.get(`/projects/${e}/facts`,{fact_key:t,include_links:`true`}):Promise.resolve(null),[e,t,i]),p=f.data;return(0,X.jsxs)(y,{visible:n,width:640,title:u(`projects.factDetails`,null,`事实详情`),onCancel:a,footer:(0,X.jsxs)(o,{children:[(0,X.jsx)(c,{disabled:!r||!p,onClick:()=>s?.(t),children:u(`common.edit`,null,`编辑`)}),(0,X.jsx)(c,{onClick:a,children:u(`common.close`,null,`关闭`)})]}),children:[(0,X.jsx)(P,{error:ie(f.error),onRetry:f.reload}),p?(0,X.jsxs)(`div`,{className:`project-detail-stack`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(De,{strong:!0,children:p.fact_key}),(0,X.jsxs)(`div`,{className:`project-graph-side-tags`,children:[(0,X.jsx)(l,{size:`small`,color:`cyan`,type:`light`,children:W[String(p.category||``).toLowerCase()]||p.category||`—`}),(0,X.jsx)(ke,{value:p.confidence}),p.pinned?(0,X.jsx)(l,{size:`small`,color:`blue`,type:`light`,children:u(`projects.pinned`,null,`置顶`)}):null]})]}),(0,X.jsx)(M,{items:[{label:u(`projects.updated`,null,`更新`),value:T(p.updated_at)},{label:u(`projects.confidence`,null,`置信度`),value:(0,X.jsx)(ke,{value:p.confidence})},p.related_vulnerability_id?{label:u(`projects.relatedVulnIdTitle`,null,`关联漏洞 ID`),value:p.related_vulnerability_id}:null,p.source_conversation_id?{label:u(`projects.factMetaSourceConversation`,{value:``},`来源对话`),value:p.source_conversation_id}:null]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(De,{strong:!0,children:u(`projects.summary`,null,`摘要`)}),(0,X.jsx)(Oe,{className:`project-fact-summary`,children:p.summary||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(De,{strong:!0,children:`body`}),p.body?(0,X.jsx)(N,{content:p.body}):(0,X.jsx)(De,{type:`tertiary`,children:u(`projects.emptyBody`,null,`(无 body)`)})]}),(p.incoming_links||[]).length>0&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(De,{strong:!0,children:u(`projects.factIncomingLinksLabel`,null,`入边(只读)`)}),(0,X.jsx)(`ul`,{className:`project-link-list`,children:p.incoming_links.map(e=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`code`,{children:e.edge_type}),` ← `,(0,X.jsx)(`code`,{children:e.source_fact_key})]},e.id))})]}),(p.outgoing_links||[]).length>0&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(De,{strong:!0,children:u(`projects.graphEdgeFromSelf`,null,`本节点指出`)}),(0,X.jsx)(`ul`,{className:`project-link-list`,children:p.outgoing_links.map(e=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`code`,{children:e.edge_type}),` → `,(0,X.jsx)(`code`,{children:e.target_fact_key})]},e.id))})]})]}):!f.loading&&!f.error?(0,X.jsx)(d,{title:u(`projects.noFacts`,null,`暂无事实`)}):null]})}var{Title:je,Text:Me,Paragraph:Ne}=p;function Pe({projectId:e,tab:t,refreshToken:n=0,onTabChange:r,onChanged:i,onDeleted:a}){let s=O(),{hasPermission:u}=E(),d=u(`project:write`),f=u(`project:delete`),[p,m]=(0,H.useState)(0),[h,_]=(0,H.useState)({visible:!1,factKey:``}),[v,y]=(0,H.useState)(``),b=k(()=>D.get(`/projects/${e}`),[e,p,n]),S=k(()=>D.get(`/projects/${e}/stats`),[e,p,n]),C=(0,H.useCallback)(()=>{m(e=>e+1),i?.()},[i]),w=(0,H.useCallback)(e=>_({visible:!0,factKey:e||``}),[]),A=(0,H.useCallback)(e=>y(e||``),[]),j=(0,H.useMemo)(()=>[{itemKey:`facts`,tab:s(`projects.tabFacts`,null,`事实黑板`)},{itemKey:`graph`,tab:s(`projects.tabGraph`,null,`攻击路径`)},{itemKey:`conversations`,tab:s(`projects.tabConversations`,null,`关联对话`)},{itemKey:`settings`,tab:s(`projects.tabSettings`,null,`设置`)}],[s]),M=[{id:`facts`,label:s(`projects.facts`,null,`事实`),value:S.data?.fact_count??`—`,loading:S.loading},{id:`vulns`,label:s(`projects.vulnerabilityManagement`,null,`漏洞`),value:S.data?.vuln_count??`—`,loading:S.loading},{id:`conversations`,label:s(`projects.tabConversations`,null,`关联对话`),value:S.data?.conversation_count??`—`,loading:S.loading},{id:`sparse`,label:s(`projects.factBodySparse`,null,`待补全`),value:S.data?.sparse_fact_count??`—`,tone:(S.data?.sparse_fact_count||0)>0?`warning`:void 0,loading:S.loading}],N=b.data;return(0,X.jsxs)(`div`,{className:`project-detail`,children:[(0,X.jsxs)(`div`,{className:`project-detail-summary`,children:[(0,X.jsx)(P,{error:ie(b.error),onRetry:b.reload}),(0,X.jsxs)(F,{className:`project-detail-head`,children:[(0,X.jsxs)(`div`,{className:`project-detail-head-main`,children:[(0,X.jsxs)(`div`,{className:`project-detail-title-row`,children:[(0,X.jsx)(je,{heading:4,className:`project-detail-title`,children:N?.name||s(`projects.projectNotFound`,null,`项目不存在`)}),N?.pinned?(0,X.jsx)(l,{size:`small`,color:`blue`,children:s(`projects.pinned`,null,`置顶`)}):null,(0,X.jsx)(l,{size:`small`,color:(N?.status||`active`)===`archived`?`grey`:`green`,children:(N?.status||`active`)===`archived`?s(`projects.statusArchived`,null,`已归档`):s(`projects.statusActive`,null,`进行中`)})]}),N?.description?(0,X.jsx)(Ne,{className:`project-detail-desc`,children:N.description}):(0,X.jsx)(Me,{type:`tertiary`,size:`small`,children:s(`projects.noProjectDescription`,null,`暂无项目描述`)}),(0,X.jsxs)(Me,{type:`tertiary`,size:`small`,children:[s(`projects.updatedPrefix`,{time:T(N?.updated_at)},`更新于 ${T(N?.updated_at)}`),` · `,`ID: `,(0,X.jsx)(`code`,{children:e})]})]}),(0,X.jsxs)(o,{children:[(0,X.jsx)(c,{icon:(0,X.jsx)(x,{}),theme:`borderless`,loading:b.loading||S.loading,onClick:()=>{b.reload(),S.reload()}}),(0,X.jsx)(c,{type:`primary`,disabled:!d,onClick:()=>w(``),children:s(`projects.addFactCta`,null,`+ 添加事实`)})]})]}),(0,X.jsx)(ee,{metrics:M,columns:4}),(0,X.jsx)(g,{type:`line`,tabList:j,activeKey:t||`facts`,onChange:e=>r?.(e),className:`project-tabs`})]}),(!t||t===`facts`)&&(0,X.jsx)(ce,{projectId:e,canWrite:d,revision:p,onAddFact:()=>w(``),onEditFact:w,onViewFact:A,onMutated:C}),t===`graph`&&(0,X.jsx)(be,{projectId:e,canWrite:d,revision:p,onOpenFact:A,onEditFact:w,onAddFact:()=>w(``),onChanged:C}),t===`conversations`&&(0,X.jsx)(Se,{projectId:e,canWrite:d,onChanged:C}),t===`settings`&&(0,X.jsx)(we,{project:N,canWrite:d,canDelete:f,onChanged:C,onDeleted:e=>a?.(e)}),(0,X.jsx)(Ee,{visible:h.visible,projectId:e,factKey:h.factKey,onCancel:()=>_({visible:!1,factKey:``}),onSaved:()=>{_({visible:!1,factKey:``}),C()}}),(0,X.jsx)(Ae,{projectId:e,factKey:v,visible:!!v,canWrite:d,revision:p,onClose:()=>y(``),onEdit:e=>{y(``),w(e)}})]})}var{Text:Fe}=p,Ie=10;async function Le(){let[e,t]=await Promise.all([D.get(`/projects`,{limit:500}),D.get(`/projects/dashboard-summary`,{fact_limit:6}).catch(()=>null)]);return{projects:Array.isArray(e?.projects)?e.projects:[],total:e?.total??0,summary:t}}function Re(){let e=O(),{hasPermission:t}=E(),n=t(`project:write`),r=t(`project:delete`),[a,u]=i(),f=a.get(`id`)||``,p=a.get(`tab`)||`facts`,[g,v]=(0,H.useState)(``),y=I(g,250),[b,S]=(0,H.useState)(`all`),[w,j]=(0,H.useState)(1),[M,N]=(0,H.useState)({visible:!1,project:null}),[R,U]=(0,H.useState)(0),W=k(Le,[]),G=W.data?.projects||[],K=W.data?.summary,q=(0,H.useCallback)((e,t)=>{let n=new URLSearchParams(a);e?n.set(`id`,e):n.delete(`id`),t?n.set(`tab`,t):n.delete(`tab`),u(n,{replace:!!e})},[a,u]),J=(0,H.useMemo)(()=>{let e=y.trim().toLowerCase();return G.filter(t=>{let n=t.status||`active`;return b!==`all`&&n!==b?!1:!e||[t.name,t.description,t.id].join(` `).toLowerCase().includes(e)})},[G,y,b]),ne=Math.min(w,Math.max(1,Math.ceil(J.length/Ie))),re=J.slice((ne-1)*Ie,ne*Ie);(0,H.useEffect)(()=>{!f&&J.length&&q(J[0].id,p)},[f,J,p,q]);let ae=(0,H.useMemo)(()=>G.filter(e=>(e.status||`active`)===`archived`).length,[G]),oe=[{id:`active`,label:e(`projects.statusActive`,null,`进行中`),value:K?.totals?.active_projects??G.filter(e=>(e.status||`active`)===`active`).length,loading:W.loading},{id:`facts`,label:e(`projects.facts`,null,`事实`),value:K?.totals?.total_facts??`—`,detail:e(`projects.sharedFactBoard`,null,`共享事实黑板`),loading:W.loading},{id:`total`,label:e(`projects.projectList`,null,`项目列表`),value:W.data?.total??G.length,loading:W.loading},{id:`archived`,label:e(`projects.statusArchived`,null,`已归档`),value:ae,loading:W.loading}],se=t=>{B({title:e(`projects.deleteProject`,null,`删除项目`),content:e(`projects.confirmDeleteProject`,null,`确定删除该项目?事实将一并删除,对话将解除绑定。`),okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{await D.del(`/projects/${t.id}`),z(e(`projects.deleteProject`,null,`删除项目`)),f===t.id&&q(``),W.reload({silent:!0}),U(e=>e+1)}catch(t){A(Y(t,e(`projects.deleteFailed`,null,`删除失败`)))}}})},ce=t=>{let n=(t.status||`active`)===`archived`;B({title:n?e(`projects.restoreProjectActive`,null,`恢复为进行中`):e(`projects.archiveProject`,null,`归档`),content:n?e(`projects.confirmRestoreProjectActive`,null,`恢复为 active?`):e(`projects.confirmArchiveProject`,null,`归档后默认不再出现在活跃列表,是否继续?`),okText:e(`common.confirm`,null,`确认`),danger:!n,onOk:async()=>{try{await D.put(`/projects/${t.id}`,{status:n?`active`:`archived`}),z(e(`projects.saved`,null,`已保存`)),W.reload({silent:!0}),U(e=>e+1)}catch(t){A(Y(t,e(`projects.operationFailed`,null,`操作失败`)))}}})},le=[{title:e(`projects.projectName`,null,`项目名称`),dataIndex:`name`,render:(t,n)=>(0,X.jsxs)(`div`,{className:`project-list-name`,children:[(0,X.jsxs)(`div`,{className:`project-list-name-row`,children:[(0,X.jsx)(`span`,{className:`project-list-name-text${n.id===f?` is-active`:``}`,children:t||n.id}),n.pinned?(0,X.jsx)(l,{size:`small`,color:`blue`,type:`light`,children:e(`projects.pinned`,null,`置顶`)}):null]}),n.description?(0,X.jsx)(Fe,{type:`tertiary`,size:`small`,className:`project-list-desc`,children:n.description}):null]})},{title:e(`projects.status`,null,`状态`),dataIndex:`status`,width:92,render:t=>{let n=(t||`active`)===`archived`;return(0,X.jsx)(l,{size:`small`,color:n?`grey`:`green`,children:n?e(`projects.statusArchived`,null,`已归档`):e(`projects.statusActive`,null,`进行中`)})}},{title:e(`projects.updated`,null,`更新`),dataIndex:`updated_at`,width:150,render:e=>(0,X.jsx)(Fe,{type:`tertiary`,size:`small`,children:T(e)})},{title:e(`common.actions`,null,`操作`),dataIndex:`id`,width:176,render:(t,i)=>(0,X.jsxs)(o,{spacing:2,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(c,{size:`small`,theme:`borderless`,onClick:()=>N({visible:!0,project:i}),disabled:!n,children:e(`common.edit`,null,`编辑`)}),(0,X.jsx)(c,{size:`small`,theme:`borderless`,onClick:()=>ce(i),disabled:!n,children:(i.status||`active`)===`archived`?e(`projects.restore`,null,`恢复`):e(`projects.archiveProject`,null,`归档`)}),(0,X.jsx)(c,{size:`small`,theme:`borderless`,type:`danger`,onClick:()=>se(i),disabled:!r,children:e(`common.delete`,null,`删除`)})]})}];return(0,X.jsxs)(`div`,{className:`project-page`,children:[(0,X.jsx)(te,{title:e(`projects.title`,null,`项目管理`),description:e(`projects.selectOrCreateHint`,null,`项目用于跨对话共享「事实黑板」:目标、环境、认证等信息会在绑定项目的对话中自动注入。`),extra:(0,X.jsxs)(o,{children:[(0,X.jsx)(c,{icon:(0,X.jsx)(x,{}),theme:`borderless`,loading:W.loading,onClick:()=>W.reload(),children:e(`common.refresh`,null,`刷新`)}),(0,X.jsx)(c,{type:`primary`,icon:(0,X.jsx)(_,{}),disabled:!n,onClick:()=>N({visible:!0,project:null}),children:e(`projects.newProjectCta`,null,`+ 新建项目`)})]})}),(0,X.jsx)(P,{error:ie(W.error),onRetry:W.reload}),(0,X.jsx)(ee,{metrics:oe,columns:4}),(0,X.jsxs)(`div`,{className:`project-layout${f&&p===`graph`?` project-layout--graph`:``}`,children:[(0,X.jsxs)(F,{title:e(`projects.projectList`,null,`项目列表`),className:`project-list-card`,bodyClassName:`project-list-body`,extra:(0,X.jsxs)(Fe,{type:`tertiary`,size:`small`,children:[J.length,` / `,G.length]}),children:[(0,X.jsxs)(`div`,{className:`project-toolbar project-toolbar--stack`,children:[(0,X.jsx)(s,{prefix:(0,X.jsx)(h,{}),value:g,showClear:!0,placeholder:e(`projects.searchProjectsPlaceholder`,null,`搜索项目…`),onChange:e=>{v(e),j(1)},style:{width:`100%`}}),(0,X.jsx)(C,{value:b,onChange:e=>{S(e),j(1)},style:{width:`100%`},optionList:[{value:`all`,label:e(`projects.all`,null,`全部`)},{value:`active`,label:e(`projects.statusActive`,null,`进行中`)},{value:`archived`,label:e(`projects.statusArchived`,null,`已归档`)}]})]}),(0,X.jsx)(L,{columns:le,dataSource:re,rowKey:`id`,loading:W.loading,pagination:!1,emptyText:g||b!==`all`?e(`projects.noMatchingProjects`,null,`无匹配项目`):e(`projects.noProjects`,null,`暂无项目`),onRow:e=>({onClick:()=>q(e.id,p),style:{cursor:`pointer`}})}),J.length>0&&(0,X.jsx)(`div`,{className:`project-list-pagination`,children:(0,X.jsx)(m,{size:`small`,currentPage:ne,pageSize:Ie,total:J.length,onPageChange:j})})]}),(0,X.jsx)(`div`,{className:`project-detail-col`,children:f?(0,X.jsx)(Pe,{projectId:f,tab:p,refreshToken:R,onTabChange:e=>q(f,e),onChanged:()=>W.reload({silent:!0}),onDeleted:()=>{q(``),W.reload({silent:!0})}},f):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(F,{title:e(`projects.selectOrCreateTitle`,null,`选择或创建项目`),extra:n?null:(0,X.jsx)(Fe,{type:`tertiary`,size:`small`,children:e(`projects.writePermissionDenied`,null,`当前账号仅有只读权限,无法创建或修改项目`)}),children:(0,X.jsx)(`div`,{className:`project-empty-state`,children:(0,X.jsx)(d,{title:e(`projects.noProjectsClickCreate`,null,`暂无项目,点击下方「新建项目」`),description:e(`projects.selectOrCreateHint`,null,`项目用于跨对话共享「事实黑板」:目标、环境、认证等信息会在绑定项目的对话中自动注入。`),style:{padding:24},children:(0,X.jsx)(c,{type:`primary`,disabled:!n,onClick:()=>N({visible:!0,project:null}),children:e(`projects.createFirstProject`,null,`创建第一个项目`)})})})}),(0,X.jsx)(F,{title:e(`projects.sharedFactBoard`,null,`共享事实黑板`),description:e(`projects.factToolbarHint`,null,`索引仅含 key 与摘要;攻击链 / POC 写在 body,Agent 通过 get_project_fact 复现`),children:(K?.recent_facts||[]).length?(0,X.jsx)(`ul`,{className:`project-recent-facts`,children:K.recent_facts.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`project-recent-fact`,onClick:()=>q(e.project_id,`facts`),children:[(0,X.jsxs)(`span`,{className:`project-recent-fact-key`,children:[(0,X.jsx)(`code`,{children:e.fact_key}),(0,X.jsx)(l,{size:`small`,color:`cyan`,type:`light`,children:e.project_name||e.project_id})]}),(0,X.jsx)(`span`,{className:`project-recent-fact-summary`,title:e.summary,children:e.summary}),(0,X.jsx)(`span`,{className:`project-recent-fact-time`,children:T(e.updated_at)})]})},e.id))}):(0,X.jsx)(Fe,{type:`tertiary`,children:e(`projects.noFacts`,null,`暂无事实`)})})]})})]}),(0,X.jsx)(V,{visible:M.visible,project:M.project,onCancel:()=>N({visible:!1,project:null}),onSaved:e=>{let t=!!M.project;N({visible:!1,project:null}),W.reload({silent:!0}),U(e=>e+1),e?.id&&!t&&q(e.id,`facts`)}})]})}export{Re as default};
\ No newline at end of file
+}`,onChange:e=>m({scope_json:e})}),(0,X.jsx)(Q,{type:`tertiary`,size:`small`,children:l(`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:l(`projects.dangerZoneTitle`,null,`危险操作`)}),(0,X.jsx)(`div`,{children:(0,X.jsx)(Q,{type:`tertiary`,size:`small`,children:l(`projects.dangerZoneHint`,null,`归档后需在列表勾选「显示已归档」才能查看;删除将清除全部事实且不可恢复。`)})})]}),(0,X.jsxs)(o,{children:[(0,X.jsx)(c,{disabled:!t,onClick:()=>{B({title:v?l(`projects.restoreProjectActive`,null,`恢复为进行中`):l(`projects.archiveProject`,null,`归档`),content:v?l(`projects.confirmRestoreProjectActive`,null,`恢复为 active?`):l(`projects.confirmArchiveProject`,null,`归档后默认不再出现在活跃列表,是否继续?`),okText:l(`common.confirm`,null,`确认`),danger:!v,onOk:async()=>{try{await D.put(`/projects/${e.id}`,{status:v?`active`:`archived`}),z(l(`projects.saved`,null,`已保存`)),r?.()}catch(e){A(Y(e,l(`projects.operationFailed`,null,`操作失败`)))}}})},children:v?l(`projects.restoreProjectActive`,null,`恢复为进行中`):l(`projects.archiveProject`,null,`归档`)}),(0,X.jsx)(c,{type:`danger`,disabled:!n,onClick:()=>{B({title:l(`projects.deleteProject`,null,`删除项目`),content:l(`projects.confirmDeleteProject`,null,`确定删除该项目?事实将一并删除,对话将解除绑定。`),okText:l(`common.delete`,null,`删除`),onOk:async()=>{try{await D.del(`/projects/${e.id}`),z(l(`projects.deleteProject`,null,`删除项目`)),i?.(e.id)}catch(e){A(Y(e,l(`projects.deleteFailed`,null,`删除失败`)))}}})},children:l(`projects.deleteProject`,null,`删除项目`)})]})]})]}):(0,X.jsx)(F,{title:l(`projects.tabSettings`,null,`设置`),children:(0,X.jsx)(Q,{type:`tertiary`,children:l(`projects.selectOrCreateTitle`,null,`选择或创建项目`)})})}var{Text:$}=p,Te={fact_key:``,category:`note`,summary:``,body:``,confidence:`tentative`,pinned:!1,related_vulnerability_id:``,links_text:``};function Ee({visible:e,projectId:t,factKey:n,onCancel:r,onSaved:i}){let a=O(),[o,c]=(0,H.useState)(Te),[l,d]=(0,H.useState)(U),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(``),v=!!n;(0,H.useEffect)(()=>{if(!e||(c(Te),d(U),_(``),p(!1),h(!1),!n))return;let r=!1;return p(!0),D.get(`/projects/${t}/facts`,{fact_key:n,include_links:`true`}).then(e=>{if(r||!e)return;let t=e.category||`note`;U.some(e=>e.value===t)||d([...U,{value:t,label:`${t}(自定义)`}]),_(e.id||``),c({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:ae(e.incoming_links)})}).catch(e=>{r||A(Y(e,a(`projects.loadFactFailed`,null,`加载事实失败`)))}).finally(()=>{r||p(!1)}),()=>{r=!0}},[e,t,n]);let y=e=>c(t=>({...t,...e})),b=(0,H.useMemo)(()=>re.join(`、`),[]);return(0,X.jsxs)(j,{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){A(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)A(a(`projects.loadFactFailed`,null,`加载事实失败`));else{h(!0);try{v&&g?await D.put(`/projects/${t}/facts/${g}`,r):await D.post(`/projects/${t}/facts`,r),z(a(`projects.saved`,null,`已保存`)),i?.()}catch(e){A(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)(s,{value:o.fact_key,disabled:f,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)(C,{value:o.category,optionList:l,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)(s,{value:o.summary,placeholder:a(`projects.summary`,null,`摘要`)+`:什么 + 在哪 + 如何验证`,onChange:e=>y({summary:e})})]}),(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:a(`projects.confidence`,null,`置信度`)}),(0,X.jsx)(C,{value:o.confidence,optionList:G,onChange:e=>y({confidence:e}),style:{width:`100%`}})]}),(0,X.jsxs)(`div`,{className:`project-form-field`,children:[(0,X.jsx)($,{strong:!0,size:`small`,children:a(`projects.relatedVulnIdLabel`,null,`关联漏洞 ID`)}),(0,X.jsx)(s,{value:o.related_vulnerability_id,placeholder:a(`projects.optional`,null,`可选`),onChange:e=>y({related_vulnerability_id:e})})]})]}),(0,X.jsxs)(`div`,{className:`project-form-field`,children:[(0,X.jsx)($,{strong:!0,size:`small`,children:`body`}),(0,X.jsx)(w,{value:o.body,rows:10,placeholder:"## 验证步骤\n1. …\n\n```http\nGET /path HTTP/1.1\n```",onChange:e=>y({body:e})}),(0,X.jsx)($,{type:`tertiary`,size:`small`,children:a(`projects.factBodyRelationsHint`,null,`正文中的 discovered_on 等关系请填写到下方“关系边”字段,才能生成图谱连线。`)})]}),(0,X.jsxs)(`div`,{className:`project-form-field`,children:[(0,X.jsx)($,{strong:!0,size:`small`,children:a(`projects.factLinksLabel`,null,`关系边(from → 本事实)`)}),(0,X.jsx)(w,{value:o.links_text,rows:3,placeholder:a(`projects.factLinksPlaceholder`,null,`discovered_on: target/primary_domain`),onChange:e=>y({links_text:e})}),(0,X.jsxs)($,{type:`tertiary`,size:`small`,children:[a(`projects.factLinksHint`,null,`每行一条:type: source_fact_key(来源 → 当前事实)。`),` `,`常用 type:`,b,`。`]})]}),(0,X.jsx)(u,{checked:o.pinned,onChange:e=>y({pinned:e.target.checked}),children:a(`projects.pinFact`,null,`置顶事实(列表与黑板索引优先)`)})]})}var{Text:De,Paragraph:Oe}=p;function ke({value:e}){let t=K[String(e||``).toLowerCase()]||{label:e||`—`,color:`grey`};return(0,X.jsx)(l,{size:`small`,color:t.color,children:t.label})}function Ae({projectId:e,factKey:t,visible:n,canWrite:r,revision:i=0,onClose:a,onEdit:s}){let u=O(),f=k(()=>t?D.get(`/projects/${e}/facts`,{fact_key:t,include_links:`true`}):Promise.resolve(null),[e,t,i]),p=f.data;return(0,X.jsxs)(y,{visible:n,width:640,title:u(`projects.factDetails`,null,`事实详情`),onCancel:a,footer:(0,X.jsxs)(o,{children:[(0,X.jsx)(c,{disabled:!r||!p,onClick:()=>s?.(t),children:u(`common.edit`,null,`编辑`)}),(0,X.jsx)(c,{onClick:a,children:u(`common.close`,null,`关闭`)})]}),children:[(0,X.jsx)(P,{error:ie(f.error),onRetry:f.reload}),p?(0,X.jsxs)(`div`,{className:`project-detail-stack`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(De,{strong:!0,children:p.fact_key}),(0,X.jsxs)(`div`,{className:`project-graph-side-tags`,children:[(0,X.jsx)(l,{size:`small`,color:`cyan`,type:`light`,children:W[String(p.category||``).toLowerCase()]||p.category||`—`}),(0,X.jsx)(ke,{value:p.confidence}),p.pinned?(0,X.jsx)(l,{size:`small`,color:`blue`,type:`light`,children:u(`projects.pinned`,null,`置顶`)}):null]})]}),(0,X.jsx)(M,{items:[{label:u(`projects.updated`,null,`更新`),value:T(p.updated_at)},{label:u(`projects.confidence`,null,`置信度`),value:(0,X.jsx)(ke,{value:p.confidence})},p.related_vulnerability_id?{label:u(`projects.relatedVulnIdTitle`,null,`关联漏洞 ID`),value:p.related_vulnerability_id}:null,p.source_conversation_id?{label:u(`projects.factMetaSourceConversation`,{value:``},`来源对话`),value:p.source_conversation_id}:null]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(De,{strong:!0,children:u(`projects.summary`,null,`摘要`)}),(0,X.jsx)(Oe,{className:`project-fact-summary`,children:p.summary||`—`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(De,{strong:!0,children:`body`}),p.body?(0,X.jsx)(N,{content:p.body}):(0,X.jsx)(De,{type:`tertiary`,children:u(`projects.emptyBody`,null,`(无 body)`)})]}),(p.incoming_links||[]).length>0&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(De,{strong:!0,children:u(`projects.factIncomingLinksLabel`,null,`入边(只读)`)}),(0,X.jsx)(`ul`,{className:`project-link-list`,children:p.incoming_links.map(e=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`code`,{children:e.edge_type}),` ← `,(0,X.jsx)(`code`,{children:e.source_fact_key})]},e.id))})]}),(p.outgoing_links||[]).length>0&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(De,{strong:!0,children:u(`projects.graphEdgeFromSelf`,null,`本节点指出`)}),(0,X.jsx)(`ul`,{className:`project-link-list`,children:p.outgoing_links.map(e=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`code`,{children:e.edge_type}),` → `,(0,X.jsx)(`code`,{children:e.target_fact_key})]},e.id))})]})]}):!f.loading&&!f.error?(0,X.jsx)(d,{title:u(`projects.noFacts`,null,`暂无事实`)}):null]})}var{Title:je,Text:Me,Paragraph:Ne}=p;function Pe({projectId:e,tab:t,refreshToken:n=0,onTabChange:r,onChanged:i,onDeleted:a}){let s=O(),{hasPermission:u}=E(),d=u(`project:write`),f=u(`project:delete`),[p,m]=(0,H.useState)(0),[h,_]=(0,H.useState)({visible:!1,factKey:``}),[v,y]=(0,H.useState)(``),b=k(()=>D.get(`/projects/${e}`),[e,p,n]),S=k(()=>D.get(`/projects/${e}/stats`),[e,p,n]),C=(0,H.useCallback)(()=>{m(e=>e+1),i?.()},[i]),w=(0,H.useCallback)(e=>_({visible:!0,factKey:e||``}),[]),A=(0,H.useCallback)(e=>y(e||``),[]),j=(0,H.useMemo)(()=>[{itemKey:`facts`,tab:s(`projects.tabFacts`,null,`事实黑板`)},{itemKey:`graph`,tab:s(`projects.tabGraph`,null,`攻击路径`)},{itemKey:`conversations`,tab:s(`projects.tabConversations`,null,`关联对话`)},{itemKey:`settings`,tab:s(`projects.tabSettings`,null,`设置`)}],[s]),M=[{id:`facts`,label:s(`projects.facts`,null,`事实`),value:S.data?.fact_count??`—`,loading:S.loading},{id:`vulns`,label:s(`projects.vulnerabilityManagement`,null,`漏洞`),value:S.data?.vuln_count??`—`,loading:S.loading},{id:`conversations`,label:s(`projects.tabConversations`,null,`关联对话`),value:S.data?.conversation_count??`—`,loading:S.loading},{id:`sparse`,label:s(`projects.factBodySparse`,null,`待补全`),value:S.data?.sparse_fact_count??`—`,tone:(S.data?.sparse_fact_count||0)>0?`warning`:void 0,loading:S.loading}],N=b.data;return(0,X.jsxs)(`div`,{className:`project-detail`,children:[(0,X.jsxs)(`div`,{className:`project-detail-summary`,children:[(0,X.jsx)(P,{error:ie(b.error),onRetry:b.reload}),(0,X.jsxs)(F,{className:`project-detail-head`,children:[(0,X.jsxs)(`div`,{className:`project-detail-head-main`,children:[(0,X.jsxs)(`div`,{className:`project-detail-title-row`,children:[(0,X.jsx)(je,{heading:4,className:`project-detail-title`,children:N?.name||s(`projects.projectNotFound`,null,`项目不存在`)}),N?.pinned?(0,X.jsx)(l,{size:`small`,color:`blue`,children:s(`projects.pinned`,null,`置顶`)}):null,(0,X.jsx)(l,{size:`small`,color:(N?.status||`active`)===`archived`?`grey`:`green`,children:(N?.status||`active`)===`archived`?s(`projects.statusArchived`,null,`已归档`):s(`projects.statusActive`,null,`进行中`)})]}),N?.description?(0,X.jsx)(Ne,{className:`project-detail-desc`,children:N.description}):(0,X.jsx)(Me,{type:`tertiary`,size:`small`,children:s(`projects.noProjectDescription`,null,`暂无项目描述`)}),(0,X.jsxs)(Me,{type:`tertiary`,size:`small`,children:[s(`projects.updatedPrefix`,{time:T(N?.updated_at)},`更新于 ${T(N?.updated_at)}`),` · `,`ID: `,(0,X.jsx)(`code`,{children:e})]})]}),(0,X.jsxs)(o,{children:[(0,X.jsx)(c,{icon:(0,X.jsx)(x,{}),theme:`borderless`,loading:b.loading||S.loading,onClick:()=>{b.reload(),S.reload()}}),(0,X.jsx)(c,{type:`primary`,disabled:!d,onClick:()=>w(``),children:s(`projects.addFactCta`,null,`+ 添加事实`)})]})]}),(0,X.jsx)(ee,{metrics:M,columns:4}),(0,X.jsx)(g,{type:`line`,tabList:j,activeKey:t||`facts`,onChange:e=>r?.(e),className:`project-tabs`})]}),(!t||t===`facts`)&&(0,X.jsx)(ce,{projectId:e,canWrite:d,revision:p,onAddFact:()=>w(``),onEditFact:w,onViewFact:A,onMutated:C}),t===`graph`&&(0,X.jsx)(be,{projectId:e,canWrite:d,revision:p,onOpenFact:A,onEditFact:w,onAddFact:()=>w(``),onChanged:C}),t===`conversations`&&(0,X.jsx)(Se,{projectId:e,canWrite:d,onChanged:C}),t===`settings`&&(0,X.jsx)(we,{project:N,canWrite:d,canDelete:f,onChanged:C,onDeleted:e=>a?.(e)}),(0,X.jsx)(Ee,{visible:h.visible,projectId:e,factKey:h.factKey,onCancel:()=>_({visible:!1,factKey:``}),onSaved:()=>{_({visible:!1,factKey:``}),C()}}),(0,X.jsx)(Ae,{projectId:e,factKey:v,visible:!!v,canWrite:d,revision:p,onClose:()=>y(``),onEdit:e=>{y(``),w(e)}})]})}var{Text:Fe}=p,Ie=10;async function Le(){let[e,t]=await Promise.all([D.get(`/projects`,{limit:500}),D.get(`/projects/dashboard-summary`,{fact_limit:6}).catch(()=>null)]);return{projects:Array.isArray(e?.projects)?e.projects:[],total:e?.total??0,summary:t}}function Re(){let e=O(),{hasPermission:t}=E(),n=t(`project:write`),r=t(`project:delete`),[a,u]=i(),f=a.get(`id`)||``,p=a.get(`tab`)||`facts`,[g,v]=(0,H.useState)(``),y=I(g,250),[b,S]=(0,H.useState)(`all`),[w,j]=(0,H.useState)(1),[M,N]=(0,H.useState)({visible:!1,project:null}),[R,U]=(0,H.useState)(0),W=k(Le,[]),G=W.data?.projects||[],K=W.data?.summary,q=(0,H.useCallback)((e,t)=>{let n=new URLSearchParams(a);e?n.set(`id`,e):n.delete(`id`),t?n.set(`tab`,t):n.delete(`tab`),u(n,{replace:!!e})},[a,u]),J=(0,H.useMemo)(()=>{let e=y.trim().toLowerCase();return G.filter(t=>{let n=t.status||`active`;return b!==`all`&&n!==b?!1:!e||[t.name,t.description,t.id].join(` `).toLowerCase().includes(e)})},[G,y,b]),ne=Math.min(w,Math.max(1,Math.ceil(J.length/Ie))),re=J.slice((ne-1)*Ie,ne*Ie);(0,H.useEffect)(()=>{!f&&J.length&&q(J[0].id,p)},[f,J,p,q]);let ae=(0,H.useMemo)(()=>G.filter(e=>(e.status||`active`)===`archived`).length,[G]),oe=[{id:`active`,label:e(`projects.statusActive`,null,`进行中`),value:K?.totals?.active_projects??G.filter(e=>(e.status||`active`)===`active`).length,loading:W.loading},{id:`facts`,label:e(`projects.facts`,null,`事实`),value:K?.totals?.total_facts??`—`,detail:e(`projects.sharedFactBoard`,null,`共享事实黑板`),loading:W.loading},{id:`total`,label:e(`projects.projectList`,null,`项目列表`),value:W.data?.total??G.length,loading:W.loading},{id:`archived`,label:e(`projects.statusArchived`,null,`已归档`),value:ae,loading:W.loading}],se=t=>{B({title:e(`projects.deleteProject`,null,`删除项目`),content:e(`projects.confirmDeleteProject`,null,`确定删除该项目?事实将一并删除,对话将解除绑定。`),okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{await D.del(`/projects/${t.id}`),z(e(`projects.deleteProject`,null,`删除项目`)),f===t.id&&q(``),W.reload({silent:!0}),U(e=>e+1)}catch(t){A(Y(t,e(`projects.deleteFailed`,null,`删除失败`)))}}})},ce=t=>{let n=(t.status||`active`)===`archived`;B({title:n?e(`projects.restoreProjectActive`,null,`恢复为进行中`):e(`projects.archiveProject`,null,`归档`),content:n?e(`projects.confirmRestoreProjectActive`,null,`恢复为 active?`):e(`projects.confirmArchiveProject`,null,`归档后默认不再出现在活跃列表,是否继续?`),okText:e(`common.confirm`,null,`确认`),danger:!n,onOk:async()=>{try{await D.put(`/projects/${t.id}`,{status:n?`active`:`archived`}),z(e(`projects.saved`,null,`已保存`)),W.reload({silent:!0}),U(e=>e+1)}catch(t){A(Y(t,e(`projects.operationFailed`,null,`操作失败`)))}}})},le=[{title:e(`projects.projectName`,null,`项目名称`),dataIndex:`name`,render:(t,n)=>(0,X.jsxs)(`div`,{className:`project-list-name`,children:[(0,X.jsxs)(`div`,{className:`project-list-name-row`,children:[(0,X.jsx)(`span`,{className:`project-list-name-text${n.id===f?` is-active`:``}`,children:t||n.id}),n.pinned?(0,X.jsx)(l,{size:`small`,color:`blue`,type:`light`,children:e(`projects.pinned`,null,`置顶`)}):null]}),n.description?(0,X.jsx)(Fe,{type:`tertiary`,size:`small`,className:`project-list-desc`,children:n.description}):null]})},{title:e(`projects.status`,null,`状态`),dataIndex:`status`,width:92,render:t=>{let n=(t||`active`)===`archived`;return(0,X.jsx)(l,{size:`small`,color:n?`grey`:`green`,children:n?e(`projects.statusArchived`,null,`已归档`):e(`projects.statusActive`,null,`进行中`)})}},{title:e(`projects.updated`,null,`更新`),dataIndex:`updated_at`,width:150,render:e=>(0,X.jsx)(Fe,{type:`tertiary`,size:`small`,children:T(e)})},{title:e(`common.actions`,null,`操作`),dataIndex:`id`,width:176,render:(t,i)=>(0,X.jsxs)(o,{spacing:2,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(c,{size:`small`,theme:`borderless`,onClick:()=>N({visible:!0,project:i}),disabled:!n,children:e(`common.edit`,null,`编辑`)}),(0,X.jsx)(c,{size:`small`,theme:`borderless`,onClick:()=>ce(i),disabled:!n,children:(i.status||`active`)===`archived`?e(`projects.restore`,null,`恢复`):e(`projects.archiveProject`,null,`归档`)}),(0,X.jsx)(c,{size:`small`,theme:`borderless`,type:`danger`,onClick:()=>se(i),disabled:!r,children:e(`common.delete`,null,`删除`)})]})}];return(0,X.jsxs)(`div`,{className:`project-page`,children:[(0,X.jsx)(te,{title:e(`projects.title`,null,`项目管理`),description:e(`projects.selectOrCreateHint`,null,`项目用于跨对话共享「事实黑板」:目标、环境、认证等信息会在绑定项目的对话中自动注入。`),extra:(0,X.jsxs)(o,{children:[(0,X.jsx)(c,{icon:(0,X.jsx)(x,{}),theme:`borderless`,loading:W.loading,onClick:()=>W.reload(),children:e(`common.refresh`,null,`刷新`)}),(0,X.jsx)(c,{type:`primary`,icon:(0,X.jsx)(_,{}),disabled:!n,onClick:()=>N({visible:!0,project:null}),children:e(`projects.newProjectCta`,null,`+ 新建项目`)})]})}),(0,X.jsx)(P,{error:ie(W.error),onRetry:W.reload}),(0,X.jsx)(ee,{metrics:oe,columns:4}),(0,X.jsxs)(`div`,{className:`project-layout${f&&p===`graph`?` project-layout--graph`:``}`,children:[(0,X.jsxs)(F,{title:e(`projects.projectList`,null,`项目列表`),className:`project-list-card`,bodyClassName:`project-list-body`,extra:(0,X.jsxs)(Fe,{type:`tertiary`,size:`small`,children:[J.length,` / `,G.length]}),children:[(0,X.jsxs)(`div`,{className:`project-toolbar project-toolbar--stack`,children:[(0,X.jsx)(s,{prefix:(0,X.jsx)(h,{}),value:g,showClear:!0,placeholder:e(`projects.searchProjectsPlaceholder`,null,`搜索项目…`),onChange:e=>{v(e),j(1)},style:{width:`100%`}}),(0,X.jsx)(C,{value:b,onChange:e=>{S(e),j(1)},style:{width:`100%`},optionList:[{value:`all`,label:e(`projects.all`,null,`全部`)},{value:`active`,label:e(`projects.statusActive`,null,`进行中`)},{value:`archived`,label:e(`projects.statusArchived`,null,`已归档`)}]})]}),(0,X.jsx)(L,{columns:le,dataSource:re,rowKey:`id`,loading:W.loading,pagination:!1,emptyText:g||b!==`all`?e(`projects.noMatchingProjects`,null,`无匹配项目`):e(`projects.noProjects`,null,`暂无项目`),onRow:e=>({onClick:()=>q(e.id,p),style:{cursor:`pointer`}})}),J.length>0&&(0,X.jsx)(`div`,{className:`project-list-pagination`,children:(0,X.jsx)(m,{size:`small`,currentPage:ne,pageSize:Ie,total:J.length,onPageChange:j})})]}),(0,X.jsx)(`div`,{className:`project-detail-col`,children:f?(0,X.jsx)(Pe,{projectId:f,tab:p,refreshToken:R,onTabChange:e=>q(f,e),onChanged:()=>W.reload({silent:!0}),onDeleted:()=>{q(``),W.reload({silent:!0})}},f):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(F,{title:e(`projects.selectOrCreateTitle`,null,`选择或创建项目`),extra:n?null:(0,X.jsx)(Fe,{type:`tertiary`,size:`small`,children:e(`projects.writePermissionDenied`,null,`当前账号仅有只读权限,无法创建或修改项目`)}),children:(0,X.jsx)(`div`,{className:`project-empty-state`,children:(0,X.jsx)(d,{title:e(`projects.noProjectsClickCreate`,null,`暂无项目,点击下方「新建项目」`),description:e(`projects.selectOrCreateHint`,null,`项目用于跨对话共享「事实黑板」:目标、环境、认证等信息会在绑定项目的对话中自动注入。`),style:{padding:24},children:(0,X.jsx)(c,{type:`primary`,disabled:!n,onClick:()=>N({visible:!0,project:null}),children:e(`projects.createFirstProject`,null,`创建第一个项目`)})})})}),(0,X.jsx)(F,{title:e(`projects.sharedFactBoard`,null,`共享事实黑板`),description:e(`projects.factToolbarHint`,null,`索引仅含 key 与摘要;攻击链 / POC 写在 body,Agent 通过 get_project_fact 复现`),children:(K?.recent_facts||[]).length?(0,X.jsx)(`ul`,{className:`project-recent-facts`,children:K.recent_facts.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`project-recent-fact`,onClick:()=>q(e.project_id,`facts`),children:[(0,X.jsxs)(`span`,{className:`project-recent-fact-key`,children:[(0,X.jsx)(`code`,{children:e.fact_key}),(0,X.jsx)(l,{size:`small`,color:`cyan`,type:`light`,children:e.project_name||e.project_id})]}),(0,X.jsx)(`span`,{className:`project-recent-fact-summary`,title:e.summary,children:e.summary}),(0,X.jsx)(`span`,{className:`project-recent-fact-time`,children:T(e.updated_at)})]})},e.id))}):(0,X.jsx)(Fe,{type:`tertiary`,children:e(`projects.noFacts`,null,`暂无事实`)})})]})})]}),(0,X.jsx)(V,{visible:M.visible,project:M.project,onCancel:()=>N({visible:!1,project:null}),onSaved:e=>{let t=!!M.project;N({visible:!1,project:null}),W.reload({silent:!0}),U(e=>e+1),e?.id&&!t&&q(e.id,`facts`)}})]})}export{Re as default};
\ No newline at end of file
diff --git a/web/static/app/assets/roles-management-iHZfZYg9.js b/web/static/app/assets/roles-management-BY9GENyG.js
similarity index 96%
rename from web/static/app/assets/roles-management-iHZfZYg9.js
rename to web/static/app/assets/roles-management-BY9GENyG.js
index 38b61e0d..ebc5b574 100644
--- a/web/static/app/assets/roles-management-iHZfZYg9.js
+++ b/web/static/app/assets/roles-management-BY9GENyG.js
@@ -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,St as s,Tt as c,W as l,at as u,ct as d,i as f,ot as p}from"./semi-CXF9U6uC.js";import{F as m,I as h,P as g,a as _,b as v,c as y,l as b,m as x,p as S,s as C,x as w,y as T}from"./index-CrDogtQS.js";var E=e(t(),1),D=e(n(),1),{Text:O}=l;function k(){let e=g(),{hasPermission:t}=m(),n=t(`roles:write`),l=t(`roles:delete`),[k,A]=(0,E.useState)(``),[j,M]=(0,E.useState)(null),[N,P]=(0,E.useState)(!1),F=_(()=>h.get(`/roles`),[]),I=(Array.isArray(F.data?.roles)?F.data.roles:[]).filter(e=>{if(!k)return!0;let t=k.toLowerCase();return[e.name,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),L=async()=>{let e=await j.form.validate();P(!0);try{let t={name:e.name.trim(),description:e.description?.trim()||``,user_prompt:e.user_prompt||``,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean),enabled:e.enabled!==!1},n=j.role?.name;n&&n!==t.name?(await h.post(`/roles`,t),await h.del(`/roles/${encodeURIComponent(n)}`)):n?await h.put(`/roles/${encodeURIComponent(n)}`,t):await h.post(`/roles`,t),w(`角色已保存`),M(null),F.reload()}catch(e){v(e,`保存角色失败`)}finally{P(!1)}},R=e=>T({title:`删除角色「${e.name}」?`,content:`已绑定该角色的对话将失去对应提示词与工具配置。`,onOk:async()=>{await h.del(`/roles/${encodeURIComponent(e.name)}`),w(`已删除`),F.reload()}});return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(S,{title:e(`roles.title`,null,`角色管理`),description:`角色定义对话的系统提示词、可用工具与绑定工作流。`,extra:(0,D.jsxs)(r,{children:[(0,D.jsx)(a,{icon:(0,D.jsx)(p,{}),onClick:()=>F.reload(),loading:F.loading,children:`刷新`}),n&&(0,D.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,D.jsx)(d,{}),onClick:()=>M({role:null,form:{}}),children:`新建角色`})]})}),(0,D.jsxs)(x,{title:`角色(${I.length})`,children:[(0,D.jsx)(b,{error:F.error,onRetry:()=>F.reload()}),(0,D.jsx)(C,{columns:[{title:`角色`,dataIndex:`name`,render:(e,t)=>(0,D.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,D.jsxs)(r,{children:[(0,D.jsx)(O,{strong:!0,children:e}),t.enabled===!1&&(0,D.jsx)(o,{size:`small`,color:`grey`,children:`已停用`})]}),(0,D.jsx)(O,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:t.description||`—`})]})},{title:`工具`,dataIndex:`tools`,width:260,render:e=>Array.isArray(e)&&e.length?(0,D.jsxs)(r,{wrap:!0,spacing:4,children:[e.slice(0,4).map(e=>(0,D.jsx)(o,{size:`small`,children:e},e)),e.length>4&&(0,D.jsxs)(O,{type:`tertiary`,children:[`+`,e.length-4]})]}):(0,D.jsx)(O,{type:`tertiary`,children:`未绑定`})},{title:`工作流`,dataIndex:`workflow_id`,width:160,render:e=>e||`—`},{title:`操作`,width:150,render:(e,t)=>(0,D.jsxs)(r,{children:[n&&(0,D.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,D.jsx)(s,{}),onClick:()=>M({role:t,form:{}}),children:`编辑`}),l&&(0,D.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,D.jsx)(c,{}),onClick:()=>R(t)})]})}],dataSource:I,rowKey:`name`,loading:F.loading,pagination:{pageSize:20},toolbar:(0,D.jsx)(i,{prefix:(0,D.jsx)(u,{}),value:k,onChange:A,placeholder:`搜索角色名称`,style:{width:260}})})]}),(0,D.jsx)(y,{title:j?.role?`编辑角色`:`新建角色`,visible:!!j,onCancel:()=>M(null),onOk:L,confirmLoading:N,width:760,children:(0,D.jsxs)(f,{getFormApi:e=>M(t=>t&&{...t,form:e}),initValues:j?.role?{name:j.role.name,description:j.role.description,user_prompt:j.role.user_prompt,tools:Array.isArray(j.role.tools)?j.role.tools.join(`, `):``,enabled:j.role.enabled!==!1}:{enabled:!0},children:[(0,D.jsx)(f.Input,{field:`name`,label:`角色名称`,rules:[{required:!0,message:`请输入角色名称`}]}),(0,D.jsx)(f.Input,{field:`description`,label:`描述`}),(0,D.jsx)(f.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::toolName`}),(0,D.jsx)(f.TextArea,{field:`user_prompt`,label:`用户提示词(追加到用户消息前)`,autosize:{minRows:6,maxRows:18}}),(0,D.jsx)(f.Slot,{label:`启用`,children:(0,D.jsx)(f.Switch,{field:`enabled`})})]})},j?.role?.name||`new-role`)]})}export{k as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,St as s,Tt as c,W as l,at as u,ct as d,i as f,ot as p}from"./semi-CXF9U6uC.js";import{F as m,I as h,P as g,a as _,b as v,c as y,l as b,m as x,p as S,s as C,x as w,y as T}from"./index-LQJrYSgy.js";var E=e(t(),1),D=e(n(),1),{Text:O}=l;function k(){let e=g(),{hasPermission:t}=m(),n=t(`roles:write`),l=t(`roles:delete`),[k,A]=(0,E.useState)(``),[j,M]=(0,E.useState)(null),[N,P]=(0,E.useState)(!1),F=_(()=>h.get(`/roles`),[]),I=(Array.isArray(F.data?.roles)?F.data.roles:[]).filter(e=>{if(!k)return!0;let t=k.toLowerCase();return[e.name,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),L=async()=>{let e=await j.form.validate();P(!0);try{let t={name:e.name.trim(),description:e.description?.trim()||``,user_prompt:e.user_prompt||``,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean),enabled:e.enabled!==!1},n=j.role?.name;n&&n!==t.name?(await h.post(`/roles`,t),await h.del(`/roles/${encodeURIComponent(n)}`)):n?await h.put(`/roles/${encodeURIComponent(n)}`,t):await h.post(`/roles`,t),w(`角色已保存`),M(null),F.reload()}catch(e){v(e,`保存角色失败`)}finally{P(!1)}},R=e=>T({title:`删除角色「${e.name}」?`,content:`已绑定该角色的对话将失去对应提示词与工具配置。`,onOk:async()=>{await h.del(`/roles/${encodeURIComponent(e.name)}`),w(`已删除`),F.reload()}});return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(S,{title:e(`roles.title`,null,`角色管理`),description:`角色定义对话的系统提示词、可用工具与绑定工作流。`,extra:(0,D.jsxs)(r,{children:[(0,D.jsx)(a,{icon:(0,D.jsx)(p,{}),onClick:()=>F.reload(),loading:F.loading,children:`刷新`}),n&&(0,D.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,D.jsx)(d,{}),onClick:()=>M({role:null,form:{}}),children:`新建角色`})]})}),(0,D.jsxs)(x,{title:`角色(${I.length})`,children:[(0,D.jsx)(b,{error:F.error,onRetry:()=>F.reload()}),(0,D.jsx)(C,{columns:[{title:`角色`,dataIndex:`name`,render:(e,t)=>(0,D.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,D.jsxs)(r,{children:[(0,D.jsx)(O,{strong:!0,children:e}),t.enabled===!1&&(0,D.jsx)(o,{size:`small`,color:`grey`,children:`已停用`})]}),(0,D.jsx)(O,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:t.description||`—`})]})},{title:`工具`,dataIndex:`tools`,width:260,render:e=>Array.isArray(e)&&e.length?(0,D.jsxs)(r,{wrap:!0,spacing:4,children:[e.slice(0,4).map(e=>(0,D.jsx)(o,{size:`small`,children:e},e)),e.length>4&&(0,D.jsxs)(O,{type:`tertiary`,children:[`+`,e.length-4]})]}):(0,D.jsx)(O,{type:`tertiary`,children:`未绑定`})},{title:`工作流`,dataIndex:`workflow_id`,width:160,render:e=>e||`—`},{title:`操作`,width:150,render:(e,t)=>(0,D.jsxs)(r,{children:[n&&(0,D.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,D.jsx)(s,{}),onClick:()=>M({role:t,form:{}}),children:`编辑`}),l&&(0,D.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,D.jsx)(c,{}),onClick:()=>R(t)})]})}],dataSource:I,rowKey:`name`,loading:F.loading,pagination:{pageSize:20},toolbar:(0,D.jsx)(i,{prefix:(0,D.jsx)(u,{}),value:k,onChange:A,placeholder:`搜索角色名称`,style:{width:260}})})]}),(0,D.jsx)(y,{title:j?.role?`编辑角色`:`新建角色`,visible:!!j,onCancel:()=>M(null),onOk:L,confirmLoading:N,width:760,children:(0,D.jsxs)(f,{getFormApi:e=>M(t=>t&&{...t,form:e}),initValues:j?.role?{name:j.role.name,description:j.role.description,user_prompt:j.role.user_prompt,tools:Array.isArray(j.role.tools)?j.role.tools.join(`, `):``,enabled:j.role.enabled!==!1}:{enabled:!0},children:[(0,D.jsx)(f.Input,{field:`name`,label:`角色名称`,rules:[{required:!0,message:`请输入角色名称`}]}),(0,D.jsx)(f.Input,{field:`description`,label:`描述`}),(0,D.jsx)(f.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::toolName`}),(0,D.jsx)(f.TextArea,{field:`user_prompt`,label:`用户提示词(追加到用户消息前)`,autosize:{minRows:6,maxRows:18}}),(0,D.jsx)(f.Slot,{label:`启用`,children:(0,D.jsx)(f.Switch,{field:`enabled`})})]})},j?.role?.name||`new-role`)]})}export{k as default};
\ No newline at end of file
diff --git a/web/static/app/assets/settings-Cf9k1ETl.js b/web/static/app/assets/settings-DmYw0tf_.js
similarity index 99%
rename from web/static/app/assets/settings-Cf9k1ETl.js
rename to web/static/app/assets/settings-DmYw0tf_.js
index 5c2c1417..063fe47a 100644
--- a/web/static/app/assets/settings-Cf9k1ETl.js
+++ b/web/static/app/assets/settings-DmYw0tf_.js
@@ -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{A as a,Ct as o,F as s,H as c,I as l,Kt as u,L as d,M as f,O as p,W as m,X as h,at as g,c as _,f as v,h as y,m as b,ot as ee,p as x,s as S,u as C,v as w,x as T,z as E}from"./semi-CXF9U6uC.js";import{A as D,D as O,E as k,F as A,I as j,L as M,M as N,N as P,P as F,R as I,S as L,T as R,_ as te,a as z,b as B,d as V,j as ne,l as H,m as U,n as re,o as ie,p as ae,s as W,u as G,x as K,y as oe}from"./index-CrDogtQS.js";import{n as se,r as ce,t as le}from"./model-channel-mQ6lfvSO.js";var q=e(t(),1),J=class extends Error{constructor(e,t){super(t?`第 ${t} 行:${e}`:e),this.name=`YamlError`,this.line=t||0}},ue=/^(?:[-?:,\[\]{}#&*!|>'"%@`]|.*[:\s]$|.*\s#|.*[\n\r\t])/,de=/^(?:true|false|null|~|yes|no|on|off|[-+]?(?:\d+|\d*\.\d+)(?:[eE][-+]?\d+)?)$/i;function fe(e){let t=String(e);return!(t===``||de.test(t)||/^[-+]?(?:\d+\.\d*|\.\d+|\d+)(?:[eE][-+]?\d+)?$/.test(t)||ue.test(t)||/^(?:\s)|:(?:\s|$)|[\r\n\t]/.test(t)||/[,[\]{}]/.test(t)||/^[!&*|>@`]/.test(t))}function pe(e){return JSON.stringify(String(e))}function me(e){let t=String(e);return fe(t)?t:pe(t)}function he(e){if(e==null)return`null`;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return Number.isFinite(e)?String(e):pe(String(e));let t=String(e);return fe(t)?t:pe(t)}function ge(e){return e==null||[`string`,`number`,`boolean`].includes(typeof e)}function _e(e,t,n,r){let i=` `.repeat(n),a=me(e);if(ge(t))r.push(`${i}${a}: ${he(t)}`);else if(Array.isArray(t)){if(!t.length){r.push(`${i}${a}: []`);return}r.push(`${i}${a}:`),be(t,n+2,r)}else Object.entries(t).length?(r.push(`${i}${a}:`),ve(t,n+2,r)):r.push(`${i}${a}: {}`)}function ve(e,t,n){for(let[r,i]of Object.entries(e))_e(r,i,t,n)}function ye(e,t,n){let r=` `.repeat(t);if(ge(e)){n.push(`${r}- ${he(e)}`);return}if(Array.isArray(e)){if(!e.length){n.push(`${r}- []`);return}n.push(`${r}-`),be(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);ge(o)?n.push(`${r}- ${me(a)}: ${he(o)}`):(n.push(`${r}-`),_e(a,o,t+2,n));for(let[e,r]of s)_e(e,r,t+2,n)}function be(e,t,n){for(let r of e)ye(r,t,n)}function xe(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{A as a,Ct as o,F as s,H as c,I as l,Kt as u,L as d,M as f,O as p,W as m,X as h,at as g,c as _,f as v,h as y,m as b,ot as ee,p as x,s as S,u as C,v as w,x as T,z as E}from"./semi-CXF9U6uC.js";import{A as D,D as O,E as k,F as A,I as j,L as M,M as N,N as P,P as F,R as I,S as L,T as R,_ as te,a as z,b as B,d as V,j as ne,l as H,m as U,n as re,o as ie,p as ae,s as W,u as G,x as K,y as oe}from"./index-LQJrYSgy.js";import{n as se,r as ce,t as le}from"./model-channel-mQ6lfvSO.js";var q=e(t(),1),J=class extends Error{constructor(e,t){super(t?`第 ${t} 行:${e}`:e),this.name=`YamlError`,this.line=t||0}},ue=/^(?:[-?:,\[\]{}#&*!|>'"%@`]|.*[:\s]$|.*\s#|.*[\n\r\t])/,de=/^(?:true|false|null|~|yes|no|on|off|[-+]?(?:\d+|\d*\.\d+)(?:[eE][-+]?\d+)?)$/i;function fe(e){let t=String(e);return!(t===``||de.test(t)||/^[-+]?(?:\d+\.\d*|\.\d+|\d+)(?:[eE][-+]?\d+)?$/.test(t)||ue.test(t)||/^(?:\s)|:(?:\s|$)|[\r\n\t]/.test(t)||/[,[\]{}]/.test(t)||/^[!&*|>@`]/.test(t))}function pe(e){return JSON.stringify(String(e))}function me(e){let t=String(e);return fe(t)?t:pe(t)}function he(e){if(e==null)return`null`;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return Number.isFinite(e)?String(e):pe(String(e));let t=String(e);return fe(t)?t:pe(t)}function ge(e){return e==null||[`string`,`number`,`boolean`].includes(typeof e)}function _e(e,t,n,r){let i=` `.repeat(n),a=me(e);if(ge(t))r.push(`${i}${a}: ${he(t)}`);else if(Array.isArray(t)){if(!t.length){r.push(`${i}${a}: []`);return}r.push(`${i}${a}:`),be(t,n+2,r)}else Object.entries(t).length?(r.push(`${i}${a}:`),ve(t,n+2,r)):r.push(`${i}${a}: {}`)}function ve(e,t,n){for(let[r,i]of Object.entries(e))_e(r,i,t,n)}function ye(e,t,n){let r=` `.repeat(t);if(ge(e)){n.push(`${r}- ${he(e)}`);return}if(Array.isArray(e)){if(!e.length){n.push(`${r}- []`);return}n.push(`${r}-`),be(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);ge(o)?n.push(`${r}- ${me(a)}: ${he(o)}`):(n.push(`${r}-`),_e(a,o,t+2,n));for(let[e,r]of s)_e(e,r,t+2,n)}function be(e,t,n){for(let r of e)ye(r,t,n)}function xe(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 ge(e)?(n.push(he(e)),`${n.join(`
`)}\n`):Array.isArray(e)?(e.length?be(e,0,n):n.push(`[]`),`${n.join(`
diff --git a/web/static/app/assets/skills-management-B7WxOtMe.js b/web/static/app/assets/skills-management-LgaUlqmE.js
similarity index 97%
rename from web/static/app/assets/skills-management-B7WxOtMe.js
rename to web/static/app/assets/skills-management-LgaUlqmE.js
index a94876e1..e51c3078 100644
--- a/web/static/app/assets/skills-management-B7WxOtMe.js
+++ b/web/static/app/assets/skills-management-LgaUlqmE.js
@@ -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,Tt as s,W as c,at as l,ct as u,i as d,ot as f,x as p}from"./semi-CXF9U6uC.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-CrDogtQS.js";var j=e(t(),1),M=e(n(),1),{Text:N}=c;function P(){let e=_(),{hasPermission:t}=h(),n=t(`skills:write`),o=t(`skills:delete`),[c,p]=(0,j.useState)(``),S=E(c,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()=>{let e=await B.form.validate();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)(s,{}),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)(l,{}),value:c,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)(d,{getFormApi:e=>V(t=>t&&{...t,form:e}),children:[(0,M.jsx)(d.Input,{field:`name`,label:`目录名`,placeholder:`小写字母、数字、连字符`,rules:[{required:!0,message:`请输入目录名`},{pattern:/^[a-z0-9-]+$/,message:`只允许小写字母、数字与连字符`}]}),(0,M.jsx)(d.Input,{field:`description`,label:`描述`,rules:[{required:!0,message:`请输入描述`}]}),(0,M.jsx)(d.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:{display:`grid`,gridTemplateColumns:`220px minmax(0, 1fr)`,gap:12},children:[(0,M.jsx)(`div`,{style:{border:`1px solid var(--semi-color-border)`,borderRadius:8,maxHeight:420,overflow:`auto`},children:(0,M.jsx)(o,{dataSource:w,renderItem:e=>(0,M.jsx)(o.Item,{main:(0,M.jsx)(N,{size:`small`,ellipsis:{showTooltip:!0},children:e}),onClick:()=>v(e),style:{cursor:`pointer`,background:e===c?`var(--semi-color-primary-light-default)`:void 0}}),emptyContent:`暂无文件`})}),(0,M.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[(0,M.jsxs)(r,{children:[(0,M.jsx)(N,{strong:!0,children:c||`选择左侧文件查看内容`}),n&&c&&(0,M.jsx)(a,{size:`small`,loading:h,onClick:y,children:`保存`})]}),c?(0,M.jsx)(p,{value:u,onChange:d,autosize:{minRows:20,maxRows:30},disabled:!n}):(0,M.jsx)(C,{content:e.description||`—`}),f&&(0,M.jsx)(N,{type:`tertiary`,children:`读取中…`})]})]})]})})}export{P as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,S as o,Tt as s,W as c,at as l,ct as u,i as d,ot as f,x as p}from"./semi-CXF9U6uC.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-LQJrYSgy.js";var j=e(t(),1),M=e(n(),1),{Text:N}=c;function P(){let e=_(),{hasPermission:t}=h(),n=t(`skills:write`),o=t(`skills:delete`),[c,p]=(0,j.useState)(``),S=E(c,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()=>{let e=await B.form.validate();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)(s,{}),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)(l,{}),value:c,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)(d,{getFormApi:e=>V(t=>t&&{...t,form:e}),children:[(0,M.jsx)(d.Input,{field:`name`,label:`目录名`,placeholder:`小写字母、数字、连字符`,rules:[{required:!0,message:`请输入目录名`},{pattern:/^[a-z0-9-]+$/,message:`只允许小写字母、数字与连字符`}]}),(0,M.jsx)(d.Input,{field:`description`,label:`描述`,rules:[{required:!0,message:`请输入描述`}]}),(0,M.jsx)(d.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:{display:`grid`,gridTemplateColumns:`220px minmax(0, 1fr)`,gap:12},children:[(0,M.jsx)(`div`,{style:{border:`1px solid var(--semi-color-border)`,borderRadius:8,maxHeight:420,overflow:`auto`},children:(0,M.jsx)(o,{dataSource:w,renderItem:e=>(0,M.jsx)(o.Item,{main:(0,M.jsx)(N,{size:`small`,ellipsis:{showTooltip:!0},children:e}),onClick:()=>v(e),style:{cursor:`pointer`,background:e===c?`var(--semi-color-primary-light-default)`:void 0}}),emptyContent:`暂无文件`})}),(0,M.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:[(0,M.jsxs)(r,{children:[(0,M.jsx)(N,{strong:!0,children:c||`选择左侧文件查看内容`}),n&&c&&(0,M.jsx)(a,{size:`small`,loading:h,onClick:y,children:`保存`})]}),c?(0,M.jsx)(p,{value:u,onChange:d,autosize:{minRows:20,maxRows:30},disabled:!n}):(0,M.jsx)(C,{content:e.description||`—`}),f&&(0,M.jsx)(N,{type:`tertiary`,children:`读取中…`})]})]})]})})}export{P as default};
\ No newline at end of file
diff --git a/web/static/app/assets/skills-monitor-BaFwqRtT.js b/web/static/app/assets/skills-monitor-CDBoFfMC.js
similarity index 95%
rename from web/static/app/assets/skills-monitor-BaFwqRtT.js
rename to web/static/app/assets/skills-monitor-CDBoFfMC.js
index 89032af7..7050197e 100644
--- a/web/static/app/assets/skills-monitor-BaFwqRtT.js
+++ b/web/static/app/assets/skills-monitor-CDBoFfMC.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{F as t,L as n,Tt as r,W as i,ot as a}from"./semi-CXF9U6uC.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-CrDogtQS.js";import{t as y}from"./react-QV7DAAIx.js";var b=e(y(),1),{Text:x}=i;function S(){let e=u(),{hasPermission:i}=s(),y=i(`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)(r,{}),onClick:()=>O(t.skill_name),children:`清空`}):null}],dataSource:C,rowKey:`skill_name`,loading:S.loading,pagination:{pageSize:20}})]})]})}export{S as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{F as t,L as n,Tt as r,W as i,ot as a}from"./semi-CXF9U6uC.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-LQJrYSgy.js";import{t as y}from"./react-QV7DAAIx.js";var b=e(y(),1),{Text:x}=i;function S(){let e=u(),{hasPermission:i}=s(),y=i(`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)(r,{}),onClick:()=>O(t.skill_name),children:`清空`}):null}],dataSource:C,rowKey:`skill_name`,loading:S.loading,pagination:{pageSize:20}})]})]})}export{S as default};
\ No newline at end of file
diff --git a/web/static/app/assets/tasks-BdwIaYpM.js b/web/static/app/assets/tasks-BdwIaYpM.js
new file mode 100644
index 00000000..f84620ff
--- /dev/null
+++ b/web/static/app/assets/tasks-BdwIaYpM.js
@@ -0,0 +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,at as ee,c as d,ct as te,f,h as p,ot as ne,v as m,x as h}from"./semi-CXF9U6uC.js";import{E as g,F as _,I as v,P as y,_ as b,a as x,b as S,c as C,d as w,f as T,l as re,m as E,n as D,p as O,r as ie,s as ae,x as k,y as A}from"./index-LQJrYSgy.js";var j=e(t(),1),M={pending:{label:`待执行`,color:`amber`},running:{label:`执行中`,color:`blue`},paused:{label:`已暂停`,color:`grey`},completed:{label:`已完成`,color:`green`},cancelled:{label:`已取消`,color:`grey`}},N={pending:{label:`待执行`,color:`amber`},running:{label:`执行中`,color:`blue`},completed:{label:`已完成`,color:`green`},failed:{label:`失败`,color:`red`},cancelled:{label:`已取消`,color:`grey`}},P=[{value:`single`,label:`单代理(Pi SDK)`},{value:`deep`,label:`Deep(DeepAgent)`},{value:`plan_execute`,label:`Plan-Execute`},{value:`supervisor`,label:`Supervisor(专家路由)`}],F=[{value:``,label:`沿用全局设置`},{value:`off`,label:`关闭审批`},{value:`human`,label:`人工审批`},{value:`audit_agent`,label:`Agent 审批`},{value:`review_edit`,label:`Agent 审查编辑`}],I=[{value:`manual`,label:`手工执行`},{value:`cron`,label:`Cron 调度`}],oe=[{value:`all`,label:`全部状态`},{value:`pending`,label:`待执行`},{value:`running`,label:`执行中`},{value:`paused`,label:`已暂停`},{value:`completed`,label:`已完成`},{value:`cancelled`,label:`已取消`}];function L(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===`running`).length,s=t.filter(e=>e.status===`pending`).length,c=r+i+a;return{total:n,completed:r,failed:i,cancelled:a,running:o,pending:s,done:c,percent:n?Math.round(c/n*100):0}}function se(e){return(P.find(t=>t.value===String(e||`single`))||P[0]).label}function ce(e){let t=M[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=L(e);return n&&e?.status===`completed`?{...t,label:`本轮已完成 · 定时循环中`,sublabel:i?`下次执行:${i}`:``,note:`定时队列:子任务已跑完,到点将自动下一轮`}:n&&e?.status===`pending`&&i?{...t,sublabel:`Cron 已排程 · 下次 ${i}`}:e?.status===`completed`&&a.failed>0?{...t,label:`已结束(${a.failed} 项失败)`,color:`red`}:{...t,sublabel:``}}function R(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{if(!e)return;s(H),f(!1);let t=!1;return i(`roles:read`)&&v.get(`/roles`).then(e=>{t||u(Array.isArray(e?.roles)?e.roles:[])}).catch(()=>{t||u([])}),i(`project:read`)&&v.get(`/projects`,{limit:500}).then(e=>{t||d(Array.isArray(e?.projects)?e.projects:[])}).catch(()=>{t||d([])}),()=>{t=!0}},[e,i]);let p=e=>s(t=>({...t,...e}));return(0,B.jsxs)(C,{visible:e,title:r(`batchImportModal.title`,null,`新建任务`),onCancel:t,onOk:async()=>{let e=a.tasksText.split(`
+`).map(e=>e.trim()).filter(Boolean);if(!e.length){S(r(`tasks.noValidTask`,null,`没有有效的任务`));return}if(a.scheduleMode===`cron`){if(!a.cronExpr.trim()){S(r(`batchImportModal.cronExprRequired`,null,`请选择 Cron 调度后填写 Cron 表达式`));return}if(!U.test(a.cronExpr.trim())){S(r(`batchImportModal.cronExprInvalid`,null,`Cron 表达式格式错误,需要 5 段(分 时 日 月 周)`));return}}let t=Number(a.concurrency);(!Number.isFinite(t)||t<1)&&(t=1),t>8&&(t=8),f(!0);try{let i=await v.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});k(r(`tasks.batchQueueTitle`,null,`批量任务队列`)),n?.(i)}catch(e){S(z(e,r(`tasks.createBatchQueueFailed`,null,`创建批量任务队列失败`)))}finally{f(!1)}},okText:r(`batchImportModal.createQueue`,null,`创建队列`),cancelText:r(`common.cancel`,null,`取消`),confirmLoading:te,width:760,children:[(0,B.jsxs)(`div`,{className:`task-form-grid`,children:[(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.queueTitle`,null,`任务标题`)}),(0,B.jsx)(o,{value:a.title,maxLength:200,placeholder:r(`batchImportModal.queueTitlePlaceholder`,null,`请输入任务标题(可选,用于标识和筛选)`),onChange:e=>p({title:e})})]}),(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.role`,null,`角色`)}),(0,B.jsx)(m,{value:a.role,style:{width:`100%`},optionList:[{value:``,label:r(`batchImportModal.defaultRole`,null,`默认`)},...c.map(e=>({value:e.name,label:e.name}))],onChange:e=>p({role:e})}),(0,B.jsx)(V,{type:`tertiary`,size:`small`,children:r(`batchImportModal.roleHint`,null,`选择一个角色,所有任务将使用该角色的配置(提示词和工具)执行。`)})]})]}),(0,B.jsxs)(`div`,{className:`task-form-grid`,children:[(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.project`,null,`所属项目`)}),(0,B.jsx)(m,{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=>p({projectId:e})})]}),(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.agentMode`,null,`代理模式`)}),(0,B.jsx)(m,{value:a.agentMode,style:{width:`100%`},optionList:P,onChange:e=>p({agentMode:e})}),(0,B.jsx)(V,{type:`tertiary`,size:`small`,children:r(`batchImportModal.agentModeHint`,null,`与对话页一致:Pi 单代理,或 Deep / Plan-Execute / Supervisor(后三种需已启用多代理)。`)})]})]}),(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.tasksList`,null,`任务列表(每行一个任务)`)}),(0,B.jsx)(h,{value:a.tasksText,rows:7,placeholder:r(`batchImportModal.tasksListPlaceholderExample`,null,`请输入任务列表,每行一个任务`),onChange:e=>p({tasksText:e})}),(0,B.jsx)(V,{type:`tertiary`,size:`small`,children:r(`batchImportModal.tasksListHint`,null,`每行输入一个任务指令,系统将按并发池执行这些任务。空行会被自动忽略。`)})]}),(0,B.jsxs)(`div`,{className:`task-form-grid`,children:[(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.hitlPolicy`,null,`工具审批`)}),(0,B.jsx)(m,{value:a.hitlPolicy,style:{width:`100%`},optionList:F,onChange:e=>p({hitlPolicy:e})})]}),(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.concurrency`,null,`并发数`)}),(0,B.jsx)(o,{type:`number`,min:1,max:8,value:String(a.concurrency),onChange:e=>p({concurrency:e})}),(0,B.jsx)(V,{type:`tertiary`,size:`small`,children:r(`batchImportModal.concurrencyHint`,null,`同时执行的子任务数量(1-8)。默认 1 为串行;含扫描类工具时建议 1-2。`)})]})]}),(0,B.jsxs)(`div`,{className:`task-form-grid`,children:[(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.scheduleMode`,null,`调度方式`)}),(0,B.jsx)(m,{value:a.scheduleMode,style:{width:`100%`},optionList:I,onChange:e=>p({scheduleMode:e})})]}),(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.cronExpr`,null,`Cron 表达式`)}),(0,B.jsx)(o,{value:a.cronExpr,disabled:a.scheduleMode!==`cron`,placeholder:r(`batchImportModal.cronExprPlaceholder`,null,`例如:0 */2 * * *(每2小时执行一次)`),onChange:e=>p({cronExpr:e})}),(0,B.jsx)(V,{type:`tertiary`,size:`small`,children:r(`batchImportModal.cronExprHint`,null,`采用标准 5 段 Cron:分 时 日 月 周。`)})]})]}),(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(l,{checked:a.executeNow,onChange:e=>p({executeNow:e.target.checked}),children:r(`batchImportModal.executeNow`,null,`创建后立即执行`)}),(0,B.jsx)(V,{type:`tertiary`,size:`small`,children:r(`batchImportModal.executeNowHint`,null,`默认不立即执行;关闭后队列保持待执行,可在需要时手动开始。`)})]})]})}var{Text:W}=u;function G({status:e}){let t=N[String(e||``)]||{label:e||`—`,color:`grey`};return(0,B.jsx)(c,{size:`small`,color:t.color,children:t.label})}function de({queueId:e,visible:t,canWrite:r,canDelete:i,onClose:o,onChanged:l}){let u=y(),ee=n(),[d,m]=(0,j.useState)(0),[_,b]=(0,j.useState)({visible:!1,taskId:``,message:``}),[E,D]=(0,j.useState)({visible:!1,task:null}),O=x(()=>e?v.get(`/batch-tasks/${e}`):Promise.resolve(null),[e,d]),M=O.data?.queue||null,N=(0,j.useMemo)(()=>L(M),[M]);ie(()=>{t&&M?.status===`running`&&O.reload({silent:!0})},t&&M?.status===`running`?4e3:0),(0,j.useEffect)(()=>{t&&e&&O.reload({silent:!0})},[t,e]),(0,j.useEffect)(()=>{t||(b({visible:!1,taskId:``,message:``}),D({visible:!1,task:null}))},[t]);let I=()=>{m(e=>e+1),l?.()},oe=async(t,n)=>{try{await v.post(`/batch-tasks/${e}/${t}`),k(n),I()}catch(e){S(z(e,n+`失败`))}},se=()=>oe(`start`,`已开始执行`),V=()=>A({title:u(`tasks.statusPaused`,null,`已暂停`),content:u(`tasks.pauseQueueConfirm`,null,`确定要暂停这个批量任务队列吗?当前正在执行的任务将被停止,后续任务将保留待执行状态。`),okText:u(`common.confirm`,null,`确认`),onOk:async()=>{try{await v.post(`/batch-tasks/${e}/pause`),k(u(`tasks.statusPaused`,null,`已暂停`)),I()}catch(e){S(z(e,u(`tasks.pauseQueueFailed`,null,`暂停批量任务失败`)))}}}),H=()=>A({title:u(`tasks.retry`,null,`重试`),content:u(`tasks.rerunQueueConfirm`,null,`确定要重跑一轮吗?所有子任务将被重置为待执行状态并重新开始执行。`),okText:u(`common.confirm`,null,`确认`),onOk:async()=>{try{await v.post(`/batch-tasks/${e}/rerun`),k(u(`tasks.statusRunning`,null,`执行中`)),I()}catch(e){S(z(e,u(`tasks.rerunQueueFailed`,null,`重跑批量任务失败`)))}}}),U=()=>A({title:u(`tasks.deleteQueue`,null,`删除队列`),content:u(`tasks.deleteQueueConfirm`,null,`确定要删除这个批量任务队列吗?此操作不可恢复。`),okText:u(`common.delete`,null,`删除`),onOk:async()=>{try{await v.del(`/batch-tasks/${e}`),k(u(`tasks.deleteQueue`,null,`删除队列`)),l?.(),o?.()}catch(e){S(z(e,u(`tasks.deleteQueueFailed`,null,`删除批量任务队列失败`)))}}}),ue=e=>b({visible:!0,taskId:e?.id||``,message:e?.message||``}),de=async()=>{let t=_.message.trim();if(!t)S(u(`tasks.taskMessageRequired`,null,`任务消息不能为空`));else try{_.taskId?await v.put(`/batch-tasks/${e}/tasks/${_.taskId}`,{message:t}):await v.post(`/batch-tasks/${e}/tasks`,{message:t}),k(u(`common.save`,null,`保存`)),b({visible:!1,taskId:``,message:``}),I()}catch(e){S(z(e,_.taskId?u(`tasks.saveTaskFailed`,null,`保存任务失败`):u(`tasks.addTaskFailed`,null,`添加任务失败`)))}},K=t=>A({title:u(`tasks.runSingleTask`,null,`单条执行`),content:u(`tasks.confirmRunSingleTask`,null,`确定执行该任务?仅运行这一条,完成后队列会自动暂停,不会继续执行其他待执行项。`),okText:u(`common.confirm`,null,`确认`),danger:!1,onOk:async()=>{try{await v.post(`/batch-tasks/${e}/tasks/${t.id}/run`),k(u(`tasks.runSingleTask`,null,`单条执行`)),I()}catch(e){S(z(e,u(`tasks.runSingleTaskFailed`,null,`单条执行失败`)))}}}),fe=t=>A({title:u(`common.delete`,null,`删除`),content:u(`tasks.confirmDeleteTask`,null,`确定要删除这个任务吗?`),okText:u(`common.delete`,null,`删除`),onOk:async()=>{try{await v.del(`/batch-tasks/${e}/tasks/${t.id}`),k(u(`common.delete`,null,`删除`)),I()}catch(e){S(z(e,u(`tasks.deleteTaskFailed`,null,`删除任务失败`)))}}}),pe=e=>!!(r&&M&&e.status!==`running`&&M.status!==`running`&&[`pending`,`paused`,`completed`,`cancelled`].includes(M.status)),q=[{title:`#`,dataIndex:`id`,width:58,render:(e,t)=>{let n=(M?.tasks||[]).findIndex(e=>e.id===t.id);return(0,B.jsx)(W,{type:`tertiary`,size:`small`,children:n+1})}},{title:u(`tasks.title`,null,`任务`),dataIndex:`message`,render:(e,t)=>(0,B.jsx)(`span`,{className:`task-cell-message`,title:e,children:e||u(`tasks.taskIncomplete`,null,`任务信息不完整`)})},{title:u(`projects.status`,null,`状态`),dataIndex:`status`,width:96,render:e=>(0,B.jsx)(G,{status:e})},{title:u(`tasks.duration`,null,`执行时长`),dataIndex:`startedAt`,width:110,render:(e,t)=>(0,B.jsx)(W,{size:`small`,children:e?R(e,t.completedAt):`—`})},{title:u(`common.actions`,null,`操作`),dataIndex:`id`,width:210,render:(e,t)=>(0,B.jsxs)(a,{spacing:2,wrap:!0,children:[(0,B.jsx)(s,{size:`small`,theme:`borderless`,onClick:()=>D({visible:!0,task:t}),children:`结果`}),(0,B.jsx)(s,{size:`small`,theme:`borderless`,disabled:!r,onClick:()=>ue(t),children:u(`common.edit`,null,`编辑`)}),(0,B.jsx)(s,{size:`small`,theme:`borderless`,disabled:!pe(t),title:u(`tasks.runSingleTaskUnavailable`,null,`队列或任务执行中,暂无法单条执行`),onClick:()=>K(t),children:u(`tasks.runSingleTask`,null,`单条执行`)}),(0,B.jsx)(s,{size:`small`,theme:`borderless`,type:`danger`,disabled:!i,onClick:()=>fe(t),children:u(`common.delete`,null,`删除`)})]})}],J=ce(M),Y=M?.scheduleMode===`cron`&&M?.scheduleEnabled!==!1;return(0,B.jsxs)(f,{visible:t,width:900,title:M?M.title||M.id:u(`tasks.batchQueueTitle`,null,`批量任务队列`),onCancel:o,children:[(0,B.jsx)(re,{error:le(O.error),onRetry:()=>O.reload()}),M?(0,B.jsxs)(`div`,{className:`task-detail-stack`,children:[(0,B.jsxs)(`div`,{className:`task-detail-actions`,children:[(0,B.jsxs)(a,{wrap:!0,children:[(0,B.jsx)(s,{type:`primary`,disabled:!r||M.status===`running`,onClick:se,children:`开始执行`}),(0,B.jsx)(s,{disabled:!r||M.status!==`running`,onClick:V,children:`暂停`}),(0,B.jsx)(s,{disabled:!r||![`completed`,`cancelled`].includes(M.status),onClick:H,children:u(`tasks.retry`,null,`重试`)}),(0,B.jsx)(s,{icon:(0,B.jsx)(ne,{}),theme:`borderless`,onClick:()=>O.reload()})]}),(0,B.jsxs)(a,{children:[(0,B.jsx)(s,{icon:(0,B.jsx)(te,{}),disabled:!r,onClick:()=>ue(null),children:`添加任务`}),(0,B.jsx)(s,{type:`danger`,disabled:!i,onClick:U,children:u(`tasks.deleteQueue`,null,`删除队列`)})]})]}),(0,B.jsxs)(`div`,{className:`task-progress-block`,children:[(0,B.jsxs)(`div`,{className:`task-progress-head`,children:[(0,B.jsx)(c,{size:`small`,color:J.color,children:J.label}),J.sublabel?(0,B.jsx)(W,{type:`tertiary`,size:`small`,children:J.sublabel}):null]}),(0,B.jsx)(p,{percent:N.percent,showInfo:!0,stroke:`var(--semi-color-primary)`}),(0,B.jsxs)(`div`,{className:`task-progress-legend`,children:[(0,B.jsxs)(`span`,{children:[u(`tasks.totalLabel`,null,`总计`),` `,N.total]}),(0,B.jsxs)(`span`,{children:[u(`tasks.pendingLabel`,null,`待执行`),` `,N.pending]}),(0,B.jsxs)(`span`,{children:[u(`tasks.runningLabel`,null,`执行中`),` `,N.running]}),(0,B.jsxs)(`span`,{children:[u(`tasks.completedLabel`,null,`已完成`),` `,N.completed]}),(0,B.jsxs)(`span`,{children:[u(`tasks.failedLabel`,null,`失败`),` `,N.failed]}),(0,B.jsxs)(`span`,{children:[u(`tasks.cancelledLabel`,null,`已取消`),` `,N.cancelled]})]}),(0,B.jsx)(W,{type:`tertiary`,size:`small`,children:Y?u(`tasks.cronRunningProgressHint`,null,`本轮执行中;下一整轮仍按 Cron 与「下次执行时间」排程`):u(`tasks.finishedProgressHint`,null,`进度表示已结束的任务比例,包含失败和取消,不表示成功率。`)})]}),(0,B.jsx)(w,{columns:3,items:[{label:u(`tasks.queueIdLabel`,null,`队列ID`),value:(0,B.jsx)(`code`,{children:M.id})},{label:u(`tasks.createdTimeLabel`,null,`创建时间`),value:g(M.createdAt)},{label:`Agent 模式`,value:(P.find(e=>e.value===M.agentMode)||P[0]).label},{label:`角色`,value:M.role||u(`batchImportModal.defaultRole`,null,`默认`)},{label:`项目`,value:M.projectId||`—`},{label:u(`batchImportModal.hitlPolicy`,null,`工具审批`),value:(F.find(e=>e.value===(M.hitlPolicy||``))||F[0]).label},{label:u(`batchImportModal.concurrency`,null,`并发数`),value:M.concurrency||1},{label:u(`batchImportModal.scheduleMode`,null,`调度方式`),value:M.scheduleMode===`cron`?`Cron ${M.cronExpr||``}${Y?``:`(已关闭)`}`:u(`batchImportModal.scheduleModeManual`,null,`手工执行`)},{label:`下一次执行`,value:M.nextRunAt?g(M.nextRunAt):`—`},M.lastRunError?{label:`最近错误`,value:(0,B.jsx)(W,{type:`danger`,size:`small`,children:M.lastRunError})}:null]}),(0,B.jsx)(ae,{columns:q,dataSource:M.tasks||[],rowKey:`id`,size:`small`,pagination:{pageSize:10},emptyText:u(`tasks.noValidTask`,null,`没有有效的任务`)})]}):null,(0,B.jsx)(C,{visible:_.visible,title:_.taskId?u(`common.edit`,null,`编辑`):`添加任务`,onCancel:()=>b({visible:!1,taskId:``,message:``}),onOk:de,okText:u(`common.save`,null,`保存`),cancelText:u(`common.cancel`,null,`取消`),width:620,children:(0,B.jsx)(h,{value:_.message,rows:5,placeholder:u(`batchImportModal.tasksListPlaceholder`,null,`请输入任务列表,每行一个任务`),onChange:e=>b(t=>({...t,message:e}))})}),(0,B.jsx)(C,{visible:E.visible,title:E.task?E.task.message:`结果`,onCancel:()=>D({visible:!1,task:null}),footer:(0,B.jsxs)(a,{children:[E.task?.conversationId?(0,B.jsx)(s,{onClick:()=>{let e=E.task.conversationId;D({visible:!1,task:null}),o?.(),ee(`/chat?conversation=${encodeURIComponent(e)}`)},children:u(`tasks.viewConversation`,null,`查看对话`)}):null,(0,B.jsx)(s,{onClick:()=>D({visible:!1,task:null}),children:u(`common.close`,null,`关闭`)})]}),width:720,children:(0,B.jsxs)(`div`,{className:`task-detail-stack`,children:[(0,B.jsx)(w,{columns:2,items:[{label:u(`projects.status`,null,`状态`),value:(0,B.jsx)(G,{status:E.task?.status})},{label:u(`tasks.startedAt`,null,`开始时间`),value:g(E.task?.startedAt)},{label:u(`tasks.completedAt`,null,`完成时间`),value:g(E.task?.completedAt)},{label:u(`tasks.duration`,null,`执行时长`),value:R(E.task?.startedAt,E.task?.completedAt)},E.task?.conversationId?{label:u(`tasks.conversationIdLabel`,null,`对话ID`),value:(0,B.jsx)(`code`,{children:E.task.conversationId})}:null]}),E.task?.error?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(W,{strong:!0,type:`danger`,children:u(`tasks.statusFailed`,null,`执行失败`)}),(0,B.jsx)(`pre`,{className:`task-result-pre`,children:E.task.error})]}):null,E.task?.result?(0,B.jsx)(T,{content:E.task.result}):(0,B.jsx)(W,{type:`tertiary`,children:`暂无结果`})]})})]})}var{Text:K}=u,fe={running:{label:`执行中`,color:`blue`},cancelling:{label:`取消中`,color:`amber`},cleaning:{label:`清理中`,color:`amber`}};function pe(){let e=y(),t=n(),r=x(()=>v.get(`/agent-loop/tasks`),[]);ie(()=>r.reload({silent:!0}),6e3);let i=Array.isArray(r.data?.tasks)?r.data.tasks:[],o=[{title:e(`tasks.title`,null,`任务`),dataIndex:`title`,render:(t,n)=>(0,B.jsxs)(`div`,{className:`task-live-title`,children:[(0,B.jsx)(`span`,{className:`task-cell-message`,title:t||n.message,children:t||n.message||e(`tasks.unnamedTask`,null,`未命名任务`)}),(0,B.jsx)(K,{type:`tertiary`,size:`small`,children:(0,B.jsx)(`code`,{children:n.runId||`—`})})]})},{title:e(`projects.status`,null,`状态`),dataIndex:`status`,width:110,render:e=>{let t=fe[String(e||``)]||{label:e||`—`,color:`blue`};return(0,B.jsx)(c,{size:`small`,color:t.color,children:t.label})}},{title:e(`tasks.conversationIdLabel`,null,`对话ID`),dataIndex:`conversationId`,width:230,render:e=>(0,B.jsx)(K,{type:`tertiary`,size:`small`,children:(0,B.jsx)(`code`,{children:e||`—`})})},{title:e(`tasks.startedAt`,null,`开始时间`),dataIndex:`startedAt`,width:165,render:e=>(0,B.jsx)(K,{size:`small`,children:g(e)})},{title:e(`tasks.duration`,null,`执行时长`),dataIndex:`startedAt`,width:110,render:e=>(0,B.jsx)(K,{size:`small`,children:R(e)})},{title:e(`common.actions`,null,`操作`),dataIndex:`conversationId`,width:110,render:n=>(0,B.jsx)(a,{children:(0,B.jsx)(s,{size:`small`,theme:`borderless`,disabled:!n,onClick:()=>t(`/chat?conversation=${encodeURIComponent(n)}`),children:e(`tasks.viewConversation`,null,`查看对话`)})})}];return(0,B.jsxs)(E,{title:`${e(`tasks.runningLabel`,null,`执行中`)}任务(Agent Loop)`,description:`当前进程中正在执行的 Agent 任务;每 6 秒自动刷新。`,extra:(0,B.jsx)(s,{icon:(0,B.jsx)(ne,{}),theme:`borderless`,loading:r.loading,onClick:()=>r.reload(),children:e(`common.refresh`,null,`刷新`)}),children:[(0,B.jsx)(re,{error:le(r.error),onRetry:()=>r.reload()}),(0,B.jsx)(ae,{columns:o,dataSource:i,rowKey:e=>e.runId||e.conversationId||`unknown-task`,loading:r.loading,pagination:{pageSize:10},emptyText:e(`tasks.noMatchingTasks`,null,`当前没有符合条件的任务`)})]})}var{Text:q}=u;function J(){let e=y(),{hasPermission:t}=_(),n=t(`tasks:write`),r=t(`tasks:delete`),[l,u]=i(),f=l.get(`id`)||``,h=l.get(`tab`)||`queues`,[C,w]=(0,j.useState)(1),[T,M]=(0,j.useState)(10),[N,P]=(0,j.useState)(`all`),[F,I]=(0,j.useState)(``),R=D(F,300),[V,H]=(0,j.useState)(!1),[U,W]=(0,j.useState)(0),G=x(()=>v.get(`/batch-tasks`,{limit:100,page:1}),[U]),K=x(()=>v.get(`/batch-tasks`,{limit:T,page:C,status:N===`all`?void 0:N,keyword:R.trim()||void 0}),[C,T,N,R,U]),fe=Array.isArray(K.data?.queues)?K.data.queues:[],J=K.data?.total??0,Y=(0,j.useMemo)(()=>(G.data?.queues||[]).some(e=>e.status===`running`),[G.data]);ie(()=>{Y&&(G.reload({silent:!0}),K.reload({silent:!0}))},Y?5e3:0);let X=(0,j.useCallback)((e,t)=>{let n=new URLSearchParams(l);e?n.set(`id`,e):n.delete(`id`),t?n.set(`tab`,t):n.delete(`tab`),u(n,{replace:!!e})},[l,u]);(0,j.useEffect)(()=>{h!==`queues`&&h!==`live`&&X(void 0,`queues`)},[h,X]);let Z=()=>W(e=>e+1),Q=G.data?.queues||[],$=(0,j.useMemo)(()=>{let e=Q.map(L);return{queues:G.data?.total??Q.length,running:Q.filter(e=>e.status===`running`).length,pendingTasks:e.reduce((e,t)=>e+t.pending,0),failedTasks:e.reduce((e,t)=>e+t.failed,0)}},[Q,G.data]),me=async t=>{try{await v.post(`/batch-tasks/${t.id}/start`),k(`已开始执行`),Z()}catch(t){S(z(t,e(`tasks.startBatchQueueFailed`,null,`启动批量任务失败`)))}},he=t=>A({title:e(`tasks.statusPaused`,null,`已暂停`),content:e(`tasks.pauseQueueConfirm`,null,`确定要暂停这个批量任务队列吗?当前正在执行的任务将被停止,后续任务将保留待执行状态。`),okText:e(`common.confirm`,null,`确认`),onOk:async()=>{try{await v.post(`/batch-tasks/${t.id}/pause`),k(e(`tasks.statusPaused`,null,`已暂停`)),Z()}catch(t){S(z(t,e(`tasks.pauseQueueFailed`,null,`暂停批量任务失败`)))}}}),ge=t=>A({title:e(`tasks.retry`,null,`重试`),content:e(`tasks.rerunQueueConfirm`,null,`确定要重跑一轮吗?所有子任务将被重置为待执行状态并重新开始执行。`),okText:e(`common.confirm`,null,`确认`),onOk:async()=>{try{await v.post(`/batch-tasks/${t.id}/rerun`),k(`已开始重跑`),Z()}catch(t){S(z(t,e(`tasks.rerunQueueFailed`,null,`重跑批量任务失败`)))}}}),_e=t=>A({title:e(`tasks.deleteQueue`,null,`删除队列`),content:e(`tasks.deleteQueueConfirm`,null,`确定要删除这个批量任务队列吗?此操作不可恢复。`),okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{await v.del(`/batch-tasks/${t.id}`),k(e(`tasks.deleteQueue`,null,`删除队列`)),f===t.id&&X(void 0,h),Z()}catch(t){S(z(t,e(`tasks.deleteQueueFailed`,null,`删除批量任务队列失败`)))}}}),ve=[{id:`queues`,label:e(`tasks.batchQueueTitle`,null,`批量任务队列`),value:$.queues,loading:G.loading},{id:`running`,label:e(`tasks.runningLabel`,null,`执行中`),value:$.running,tone:$.running?`success`:void 0,loading:G.loading},{id:`pending`,label:e(`tasks.pendingLabel`,null,`待执行`),value:$.pendingTasks,loading:G.loading},{id:`failed`,label:e(`tasks.failedLabel`,null,`失败`),value:$.failedTasks,tone:$.failedTasks?`danger`:void 0,loading:G.loading}],ye=[{title:e(`batchImportModal.queueTitle`,null,`任务标题`),dataIndex:`title`,render:(t,n)=>{let r=ce(n);return(0,B.jsxs)(`button`,{type:`button`,className:`task-queue-name`,onClick:()=>X(n.id,`queues`),title:n.id,children:[(0,B.jsx)(`span`,{className:`task-queue-title`,children:t||e(`tasks.batchQueueUntitled`,null,`未命名队列`)}),r.sublabel?(0,B.jsx)(`span`,{className:`task-queue-sub`,children:r.sublabel}):null]})}},{title:e(`projects.status`,null,`状态`),dataIndex:`status`,width:170,render:(e,t)=>{let n=ce(t);return(0,B.jsx)(c,{size:`small`,color:n.color,children:n.label})}},{title:`进度`,dataIndex:`progress`,width:190,render:(e,t)=>{let n=L(t);return(0,B.jsxs)(`div`,{className:`task-queue-progress`,children:[(0,B.jsx)(p,{percent:n.percent,showInfo:!1,size:`small`}),(0,B.jsxs)(q,{type:`tertiary`,size:`small`,children:[n.percent,`%(`,n.done,`/`,n.total,`)`]})]})}},{title:e(`batchImportModal.agentMode`,null,`代理模式`),dataIndex:`agentMode`,width:150,render:e=>(0,B.jsx)(q,{size:`small`,children:se(e)})},{title:e(`batchImportModal.scheduleMode`,null,`调度方式`),dataIndex:`scheduleMode`,width:128,render:(t,n)=>(0,B.jsx)(q,{size:`small`,children:t===`cron`?`Cron · ${n.cronExpr||``}`:e(`batchImportModal.scheduleModeManual`,null,`手工执行`)})},{title:e(`tasks.createdTimeLabel`,null,`创建时间`),dataIndex:`createdAt`,width:160,render:e=>(0,B.jsx)(q,{type:`tertiary`,size:`small`,children:g(e)})},{title:e(`common.actions`,null,`操作`),dataIndex:`id`,width:250,render:(t,i)=>(0,B.jsxs)(a,{spacing:2,wrap:!0,children:[(0,B.jsx)(s,{size:`small`,theme:`borderless`,onClick:()=>X(i.id,`queues`),children:e(`projects.details`,null,`详情`)}),i.status===`running`?(0,B.jsx)(s,{size:`small`,theme:`borderless`,disabled:!n,onClick:()=>he(i),children:e(`tasks.statusPaused`,null,`已暂停`)}):(0,B.jsx)(s,{size:`small`,theme:`borderless`,disabled:!n,onClick:()=>me(i),children:`开始执行`}),(0,B.jsx)(s,{size:`small`,theme:`borderless`,disabled:!n||![`completed`,`cancelled`].includes(i.status),onClick:()=>ge(i),children:e(`tasks.retry`,null,`重试`)}),(0,B.jsx)(s,{size:`small`,theme:`borderless`,type:`danger`,disabled:!r,onClick:()=>_e(i),children:e(`common.delete`,null,`删除`)})]})}];return(0,B.jsxs)(`div`,{className:`task-page`,children:[(0,B.jsx)(O,{title:e(`tasks.title`,null,`任务管理`),description:e(`tasks.pageDesc`,null,`批量任务队列按并发池执行子任务;队列详情可查看进度、单条执行与结果。`),extra:(0,B.jsxs)(a,{children:[(0,B.jsx)(s,{icon:(0,B.jsx)(ne,{}),theme:`borderless`,loading:K.loading,onClick:Z,children:e(`common.refresh`,null,`刷新`)}),(0,B.jsx)(s,{type:`primary`,icon:(0,B.jsx)(te,{}),disabled:!n,onClick:()=>H(!0),children:e(`batchImportModal.title`,null,`新建任务`)})]})}),(0,B.jsx)(re,{error:le(G.error||K.error),onRetry:Z}),(0,B.jsx)(b,{metrics:ve,columns:4}),(0,B.jsx)(d,{type:`line`,activeKey:h,onChange:e=>X(void 0,e),tabList:[{itemKey:`queues`,tab:e(`tasks.batchQueueTitle`,null,`批量任务队列`)},{itemKey:`live`,tab:`${e(`tasks.runningLabel`,null,`执行中`)}任务`}],className:`task-tabs`}),h===`live`?(0,B.jsx)(pe,{}):(0,B.jsxs)(E,{title:e(`tasks.batchQueueTitle`,null,`批量任务队列`),description:e(`tasks.finishedProgressHint`,null,`进度表示已结束的任务比例,包含失败和取消,不表示成功率。`),extra:(0,B.jsx)(q,{type:`tertiary`,size:`small`,children:e(`tasks.taskCount`,{count:J},`共 ${J} 个任务`)}),children:[(0,B.jsxs)(`div`,{className:`task-toolbar`,children:[(0,B.jsx)(o,{prefix:(0,B.jsx)(ee,{}),value:F,showClear:!0,placeholder:e(`batchImportModal.queueTitlePlaceholder`,null,`请输入任务标题(可选,用于标识和筛选)`),onChange:e=>{I(e),w(1)},style:{width:280}}),(0,B.jsx)(m,{value:N,onChange:e=>{P(e),w(1)},style:{width:150},optionList:oe})]}),(0,B.jsx)(ae,{columns:ye,dataSource:fe,rowKey:`id`,loading:K.loading,emptyText:N!==`all`||F?e(`tasks.noMatchingTasks`,null,`当前没有符合条件的任务`):e(`tasks.noBatchQueues`,null,`当前没有批量任务队列`),pagination:{currentPage:C,pageSize:T,total:J,onPageChange:e=>w(e),onPageSizeChange:e=>{M(e),w(1)}}})]}),(0,B.jsx)(ue,{visible:V,onCancel:()=>H(!1),onCreated:e=>{H(!1),Z(),e?.queueId&&X(e.queueId,`queues`)}}),(0,B.jsx)(de,{queueId:f,visible:!!f,canWrite:n,canDelete:r,onClose:()=>X(void 0,h),onChanged:Z})]})}export{J as default};
\ No newline at end of file
diff --git a/web/static/app/assets/tasks-DivgO43N.js b/web/static/app/assets/tasks-DivgO43N.js
deleted file mode 100644
index cbab2b14..00000000
--- a/web/static/app/assets/tasks-DivgO43N.js
+++ /dev/null
@@ -1,2 +0,0 @@
-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,at as ee,c as d,ct as te,f,h as p,ot as ne,v as m,x as h}from"./semi-CXF9U6uC.js";import{E as g,F as _,I as v,P as y,_ as b,a as x,b as S,c as C,d as w,f as T,l as re,m as E,n as D,p as O,r as ie,s as ae,x as k,y as A}from"./index-CrDogtQS.js";var j=e(t(),1),M={pending:{label:`待执行`,color:`amber`},running:{label:`执行中`,color:`blue`},paused:{label:`已暂停`,color:`grey`},completed:{label:`已完成`,color:`green`},cancelled:{label:`已取消`,color:`grey`}},N={pending:{label:`待执行`,color:`amber`},running:{label:`执行中`,color:`blue`},completed:{label:`已完成`,color:`green`},failed:{label:`失败`,color:`red`},cancelled:{label:`已取消`,color:`grey`}},P=[{value:`single`,label:`单代理(Pi SDK)`},{value:`deep`,label:`Deep(DeepAgent)`},{value:`plan_execute`,label:`Plan-Execute`},{value:`supervisor`,label:`Supervisor(专家路由)`}],F=[{value:``,label:`沿用全局设置`},{value:`off`,label:`关闭审批`},{value:`human`,label:`人工审批`},{value:`audit_agent`,label:`Agent 审批`},{value:`review_edit`,label:`Agent 审查编辑`}],I=[{value:`manual`,label:`手工执行`},{value:`cron`,label:`Cron 调度`}],oe=[{value:`all`,label:`全部状态`},{value:`pending`,label:`待执行`},{value:`running`,label:`执行中`},{value:`paused`,label:`已暂停`},{value:`completed`,label:`已完成`},{value:`cancelled`,label:`已取消`}];function L(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===`running`).length,s=t.filter(e=>e.status===`pending`).length,c=r+i+a;return{total:n,completed:r,failed:i,cancelled:a,running:o,pending:s,done:c,percent:n?Math.round(c/n*100):0}}function se(e){return(P.find(t=>t.value===String(e||`single`))||P[0]).label}function ce(e){let t=M[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=L(e);return n&&e?.status===`completed`?{...t,label:`本轮已完成 · 定时循环中`,sublabel:i?`下次执行:${i}`:``,note:`定时队列:子任务已跑完,到点将自动下一轮`}:n&&e?.status===`pending`&&i?{...t,sublabel:`Cron 已排程 · 下次 ${i}`}:e?.status===`completed`&&a.failed>0?{...t,label:`已结束(${a.failed} 项失败)`,color:`red`}:{...t,sublabel:``}}function R(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{if(!e)return;s(H),f(!1);let t=!1;return i(`roles:read`)&&v.get(`/roles`).then(e=>{t||u(Array.isArray(e?.roles)?e.roles:[])}).catch(()=>{t||u([])}),i(`project:read`)&&v.get(`/projects`,{limit:500}).then(e=>{t||d(Array.isArray(e?.projects)?e.projects:[])}).catch(()=>{t||d([])}),()=>{t=!0}},[e,i]);let p=e=>s(t=>({...t,...e}));return(0,B.jsxs)(C,{visible:e,title:r(`batchImportModal.title`,null,`新建任务`),onCancel:t,onOk:async()=>{let e=a.tasksText.split(`
-`).map(e=>e.trim()).filter(Boolean);if(!e.length){S(r(`tasks.noValidTask`,null,`没有有效的任务`));return}if(a.scheduleMode===`cron`){if(!a.cronExpr.trim()){S(r(`batchImportModal.cronExprRequired`,null,`请选择 Cron 调度后填写 Cron 表达式`));return}if(!U.test(a.cronExpr.trim())){S(r(`batchImportModal.cronExprInvalid`,null,`Cron 表达式格式错误,需要 5 段(分 时 日 月 周)`));return}}let t=Number(a.concurrency);(!Number.isFinite(t)||t<1)&&(t=1),t>8&&(t=8),f(!0);try{let i=await v.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});k(r(`tasks.batchQueueTitle`,null,`批量任务队列`)),n?.(i)}catch(e){S(z(e,r(`tasks.createBatchQueueFailed`,null,`创建批量任务队列失败`)))}finally{f(!1)}},okText:r(`batchImportModal.createQueue`,null,`创建队列`),cancelText:r(`common.cancel`,null,`取消`),confirmLoading:te,width:760,maskClosable:!1,children:[(0,B.jsxs)(`div`,{className:`task-form-grid`,children:[(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.queueTitle`,null,`任务标题`)}),(0,B.jsx)(o,{value:a.title,maxLength:200,placeholder:r(`batchImportModal.queueTitlePlaceholder`,null,`请输入任务标题(可选,用于标识和筛选)`),onChange:e=>p({title:e})})]}),(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.role`,null,`角色`)}),(0,B.jsx)(m,{value:a.role,style:{width:`100%`},optionList:[{value:``,label:r(`batchImportModal.defaultRole`,null,`默认`)},...c.map(e=>({value:e.name,label:e.name}))],onChange:e=>p({role:e})}),(0,B.jsx)(V,{type:`tertiary`,size:`small`,children:r(`batchImportModal.roleHint`,null,`选择一个角色,所有任务将使用该角色的配置(提示词和工具)执行。`)})]})]}),(0,B.jsxs)(`div`,{className:`task-form-grid`,children:[(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.project`,null,`所属项目`)}),(0,B.jsx)(m,{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=>p({projectId:e})})]}),(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.agentMode`,null,`代理模式`)}),(0,B.jsx)(m,{value:a.agentMode,style:{width:`100%`},optionList:P,onChange:e=>p({agentMode:e})}),(0,B.jsx)(V,{type:`tertiary`,size:`small`,children:r(`batchImportModal.agentModeHint`,null,`与对话页一致:Pi 单代理,或 Deep / Plan-Execute / Supervisor(后三种需已启用多代理)。`)})]})]}),(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.tasksList`,null,`任务列表(每行一个任务)`)}),(0,B.jsx)(h,{value:a.tasksText,rows:7,placeholder:r(`batchImportModal.tasksListPlaceholderExample`,null,`请输入任务列表,每行一个任务`),onChange:e=>p({tasksText:e})}),(0,B.jsx)(V,{type:`tertiary`,size:`small`,children:r(`batchImportModal.tasksListHint`,null,`每行输入一个任务指令,系统将按并发池执行这些任务。空行会被自动忽略。`)})]}),(0,B.jsxs)(`div`,{className:`task-form-grid`,children:[(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.hitlPolicy`,null,`工具审批`)}),(0,B.jsx)(m,{value:a.hitlPolicy,style:{width:`100%`},optionList:F,onChange:e=>p({hitlPolicy:e})})]}),(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.concurrency`,null,`并发数`)}),(0,B.jsx)(o,{type:`number`,min:1,max:8,value:String(a.concurrency),onChange:e=>p({concurrency:e})}),(0,B.jsx)(V,{type:`tertiary`,size:`small`,children:r(`batchImportModal.concurrencyHint`,null,`同时执行的子任务数量(1-8)。默认 1 为串行;含扫描类工具时建议 1-2。`)})]})]}),(0,B.jsxs)(`div`,{className:`task-form-grid`,children:[(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.scheduleMode`,null,`调度方式`)}),(0,B.jsx)(m,{value:a.scheduleMode,style:{width:`100%`},optionList:I,onChange:e=>p({scheduleMode:e})})]}),(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(V,{strong:!0,size:`small`,children:r(`batchImportModal.cronExpr`,null,`Cron 表达式`)}),(0,B.jsx)(o,{value:a.cronExpr,disabled:a.scheduleMode!==`cron`,placeholder:r(`batchImportModal.cronExprPlaceholder`,null,`例如:0 */2 * * *(每2小时执行一次)`),onChange:e=>p({cronExpr:e})}),(0,B.jsx)(V,{type:`tertiary`,size:`small`,children:r(`batchImportModal.cronExprHint`,null,`采用标准 5 段 Cron:分 时 日 月 周。`)})]})]}),(0,B.jsxs)(`div`,{className:`task-form-field`,children:[(0,B.jsx)(l,{checked:a.executeNow,onChange:e=>p({executeNow:e.target.checked}),children:r(`batchImportModal.executeNow`,null,`创建后立即执行`)}),(0,B.jsx)(V,{type:`tertiary`,size:`small`,children:r(`batchImportModal.executeNowHint`,null,`默认不立即执行;关闭后队列保持待执行,可在需要时手动开始。`)})]})]})}var{Text:W}=u;function G({status:e}){let t=N[String(e||``)]||{label:e||`—`,color:`grey`};return(0,B.jsx)(c,{size:`small`,color:t.color,children:t.label})}function de({queueId:e,visible:t,canWrite:r,canDelete:i,onClose:o,onChanged:l}){let u=y(),ee=n(),[d,m]=(0,j.useState)(0),[_,b]=(0,j.useState)({visible:!1,taskId:``,message:``}),[E,D]=(0,j.useState)({visible:!1,task:null}),O=x(()=>e?v.get(`/batch-tasks/${e}`):Promise.resolve(null),[e,d]),M=O.data?.queue||null,N=(0,j.useMemo)(()=>L(M),[M]);ie(()=>{t&&M?.status===`running`&&O.reload({silent:!0})},t&&M?.status===`running`?4e3:0),(0,j.useEffect)(()=>{t&&e&&O.reload({silent:!0})},[t,e]),(0,j.useEffect)(()=>{t||(b({visible:!1,taskId:``,message:``}),D({visible:!1,task:null}))},[t]);let I=()=>{m(e=>e+1),l?.()},oe=async(t,n)=>{try{await v.post(`/batch-tasks/${e}/${t}`),k(n),I()}catch(e){S(z(e,n+`失败`))}},se=()=>oe(`start`,`已开始执行`),V=()=>A({title:u(`tasks.statusPaused`,null,`已暂停`),content:u(`tasks.pauseQueueConfirm`,null,`确定要暂停这个批量任务队列吗?当前正在执行的任务将被停止,后续任务将保留待执行状态。`),okText:u(`common.confirm`,null,`确认`),onOk:async()=>{try{await v.post(`/batch-tasks/${e}/pause`),k(u(`tasks.statusPaused`,null,`已暂停`)),I()}catch(e){S(z(e,u(`tasks.pauseQueueFailed`,null,`暂停批量任务失败`)))}}}),H=()=>A({title:u(`tasks.retry`,null,`重试`),content:u(`tasks.rerunQueueConfirm`,null,`确定要重跑一轮吗?所有子任务将被重置为待执行状态并重新开始执行。`),okText:u(`common.confirm`,null,`确认`),onOk:async()=>{try{await v.post(`/batch-tasks/${e}/rerun`),k(u(`tasks.statusRunning`,null,`执行中`)),I()}catch(e){S(z(e,u(`tasks.rerunQueueFailed`,null,`重跑批量任务失败`)))}}}),U=()=>A({title:u(`tasks.deleteQueue`,null,`删除队列`),content:u(`tasks.deleteQueueConfirm`,null,`确定要删除这个批量任务队列吗?此操作不可恢复。`),okText:u(`common.delete`,null,`删除`),onOk:async()=>{try{await v.del(`/batch-tasks/${e}`),k(u(`tasks.deleteQueue`,null,`删除队列`)),l?.(),o?.()}catch(e){S(z(e,u(`tasks.deleteQueueFailed`,null,`删除批量任务队列失败`)))}}}),ue=e=>b({visible:!0,taskId:e?.id||``,message:e?.message||``}),de=async()=>{let t=_.message.trim();if(!t)S(u(`tasks.taskMessageRequired`,null,`任务消息不能为空`));else try{_.taskId?await v.put(`/batch-tasks/${e}/tasks/${_.taskId}`,{message:t}):await v.post(`/batch-tasks/${e}/tasks`,{message:t}),k(u(`common.save`,null,`保存`)),b({visible:!1,taskId:``,message:``}),I()}catch(e){S(z(e,_.taskId?u(`tasks.saveTaskFailed`,null,`保存任务失败`):u(`tasks.addTaskFailed`,null,`添加任务失败`)))}},K=t=>A({title:u(`tasks.runSingleTask`,null,`单条执行`),content:u(`tasks.confirmRunSingleTask`,null,`确定执行该任务?仅运行这一条,完成后队列会自动暂停,不会继续执行其他待执行项。`),okText:u(`common.confirm`,null,`确认`),danger:!1,onOk:async()=>{try{await v.post(`/batch-tasks/${e}/tasks/${t.id}/run`),k(u(`tasks.runSingleTask`,null,`单条执行`)),I()}catch(e){S(z(e,u(`tasks.runSingleTaskFailed`,null,`单条执行失败`)))}}}),fe=t=>A({title:u(`common.delete`,null,`删除`),content:u(`tasks.confirmDeleteTask`,null,`确定要删除这个任务吗?`),okText:u(`common.delete`,null,`删除`),onOk:async()=>{try{await v.del(`/batch-tasks/${e}/tasks/${t.id}`),k(u(`common.delete`,null,`删除`)),I()}catch(e){S(z(e,u(`tasks.deleteTaskFailed`,null,`删除任务失败`)))}}}),pe=e=>!!(r&&M&&e.status!==`running`&&M.status!==`running`&&[`pending`,`paused`,`completed`,`cancelled`].includes(M.status)),q=[{title:`#`,dataIndex:`id`,width:58,render:(e,t)=>{let n=(M?.tasks||[]).findIndex(e=>e.id===t.id);return(0,B.jsx)(W,{type:`tertiary`,size:`small`,children:n+1})}},{title:u(`tasks.title`,null,`任务`),dataIndex:`message`,render:(e,t)=>(0,B.jsx)(`span`,{className:`task-cell-message`,title:e,children:e||u(`tasks.taskIncomplete`,null,`任务信息不完整`)})},{title:u(`projects.status`,null,`状态`),dataIndex:`status`,width:96,render:e=>(0,B.jsx)(G,{status:e})},{title:u(`tasks.duration`,null,`执行时长`),dataIndex:`startedAt`,width:110,render:(e,t)=>(0,B.jsx)(W,{size:`small`,children:e?R(e,t.completedAt):`—`})},{title:u(`common.actions`,null,`操作`),dataIndex:`id`,width:210,render:(e,t)=>(0,B.jsxs)(a,{spacing:2,wrap:!0,children:[(0,B.jsx)(s,{size:`small`,theme:`borderless`,onClick:()=>D({visible:!0,task:t}),children:`结果`}),(0,B.jsx)(s,{size:`small`,theme:`borderless`,disabled:!r,onClick:()=>ue(t),children:u(`common.edit`,null,`编辑`)}),(0,B.jsx)(s,{size:`small`,theme:`borderless`,disabled:!pe(t),title:u(`tasks.runSingleTaskUnavailable`,null,`队列或任务执行中,暂无法单条执行`),onClick:()=>K(t),children:u(`tasks.runSingleTask`,null,`单条执行`)}),(0,B.jsx)(s,{size:`small`,theme:`borderless`,type:`danger`,disabled:!i,onClick:()=>fe(t),children:u(`common.delete`,null,`删除`)})]})}],J=ce(M),Y=M?.scheduleMode===`cron`&&M?.scheduleEnabled!==!1;return(0,B.jsxs)(f,{visible:t,width:900,title:M?M.title||M.id:u(`tasks.batchQueueTitle`,null,`批量任务队列`),onCancel:o,children:[(0,B.jsx)(re,{error:le(O.error),onRetry:()=>O.reload()}),M?(0,B.jsxs)(`div`,{className:`task-detail-stack`,children:[(0,B.jsxs)(`div`,{className:`task-detail-actions`,children:[(0,B.jsxs)(a,{wrap:!0,children:[(0,B.jsx)(s,{type:`primary`,disabled:!r||M.status===`running`,onClick:se,children:`开始执行`}),(0,B.jsx)(s,{disabled:!r||M.status!==`running`,onClick:V,children:`暂停`}),(0,B.jsx)(s,{disabled:!r||![`completed`,`cancelled`].includes(M.status),onClick:H,children:u(`tasks.retry`,null,`重试`)}),(0,B.jsx)(s,{icon:(0,B.jsx)(ne,{}),theme:`borderless`,onClick:()=>O.reload()})]}),(0,B.jsxs)(a,{children:[(0,B.jsx)(s,{icon:(0,B.jsx)(te,{}),disabled:!r,onClick:()=>ue(null),children:`添加任务`}),(0,B.jsx)(s,{type:`danger`,disabled:!i,onClick:U,children:u(`tasks.deleteQueue`,null,`删除队列`)})]})]}),(0,B.jsxs)(`div`,{className:`task-progress-block`,children:[(0,B.jsxs)(`div`,{className:`task-progress-head`,children:[(0,B.jsx)(c,{size:`small`,color:J.color,children:J.label}),J.sublabel?(0,B.jsx)(W,{type:`tertiary`,size:`small`,children:J.sublabel}):null]}),(0,B.jsx)(p,{percent:N.percent,showInfo:!0,stroke:`var(--semi-color-primary)`}),(0,B.jsxs)(`div`,{className:`task-progress-legend`,children:[(0,B.jsxs)(`span`,{children:[u(`tasks.totalLabel`,null,`总计`),` `,N.total]}),(0,B.jsxs)(`span`,{children:[u(`tasks.pendingLabel`,null,`待执行`),` `,N.pending]}),(0,B.jsxs)(`span`,{children:[u(`tasks.runningLabel`,null,`执行中`),` `,N.running]}),(0,B.jsxs)(`span`,{children:[u(`tasks.completedLabel`,null,`已完成`),` `,N.completed]}),(0,B.jsxs)(`span`,{children:[u(`tasks.failedLabel`,null,`失败`),` `,N.failed]}),(0,B.jsxs)(`span`,{children:[u(`tasks.cancelledLabel`,null,`已取消`),` `,N.cancelled]})]}),(0,B.jsx)(W,{type:`tertiary`,size:`small`,children:Y?u(`tasks.cronRunningProgressHint`,null,`本轮执行中;下一整轮仍按 Cron 与「下次执行时间」排程`):u(`tasks.finishedProgressHint`,null,`进度表示已结束的任务比例,包含失败和取消,不表示成功率。`)})]}),(0,B.jsx)(w,{columns:3,items:[{label:u(`tasks.queueIdLabel`,null,`队列ID`),value:(0,B.jsx)(`code`,{children:M.id})},{label:u(`tasks.createdTimeLabel`,null,`创建时间`),value:g(M.createdAt)},{label:`Agent 模式`,value:(P.find(e=>e.value===M.agentMode)||P[0]).label},{label:`角色`,value:M.role||u(`batchImportModal.defaultRole`,null,`默认`)},{label:`项目`,value:M.projectId||`—`},{label:u(`batchImportModal.hitlPolicy`,null,`工具审批`),value:(F.find(e=>e.value===(M.hitlPolicy||``))||F[0]).label},{label:u(`batchImportModal.concurrency`,null,`并发数`),value:M.concurrency||1},{label:u(`batchImportModal.scheduleMode`,null,`调度方式`),value:M.scheduleMode===`cron`?`Cron ${M.cronExpr||``}${Y?``:`(已关闭)`}`:u(`batchImportModal.scheduleModeManual`,null,`手工执行`)},{label:`下一次执行`,value:M.nextRunAt?g(M.nextRunAt):`—`},M.lastRunError?{label:`最近错误`,value:(0,B.jsx)(W,{type:`danger`,size:`small`,children:M.lastRunError})}:null]}),(0,B.jsx)(ae,{columns:q,dataSource:M.tasks||[],rowKey:`id`,size:`small`,pagination:{pageSize:10},emptyText:u(`tasks.noValidTask`,null,`没有有效的任务`)})]}):null,(0,B.jsx)(C,{visible:_.visible,title:_.taskId?u(`common.edit`,null,`编辑`):`添加任务`,onCancel:()=>b({visible:!1,taskId:``,message:``}),onOk:de,okText:u(`common.save`,null,`保存`),cancelText:u(`common.cancel`,null,`取消`),width:620,children:(0,B.jsx)(h,{value:_.message,rows:5,placeholder:u(`batchImportModal.tasksListPlaceholder`,null,`请输入任务列表,每行一个任务`),onChange:e=>b(t=>({...t,message:e}))})}),(0,B.jsx)(C,{visible:E.visible,title:E.task?E.task.message:`结果`,onCancel:()=>D({visible:!1,task:null}),footer:(0,B.jsxs)(a,{children:[E.task?.conversationId?(0,B.jsx)(s,{onClick:()=>{let e=E.task.conversationId;D({visible:!1,task:null}),o?.(),ee(`/chat?conversation=${encodeURIComponent(e)}`)},children:u(`tasks.viewConversation`,null,`查看对话`)}):null,(0,B.jsx)(s,{onClick:()=>D({visible:!1,task:null}),children:u(`common.close`,null,`关闭`)})]}),width:720,children:(0,B.jsxs)(`div`,{className:`task-detail-stack`,children:[(0,B.jsx)(w,{columns:2,items:[{label:u(`projects.status`,null,`状态`),value:(0,B.jsx)(G,{status:E.task?.status})},{label:u(`tasks.startedAt`,null,`开始时间`),value:g(E.task?.startedAt)},{label:u(`tasks.completedAt`,null,`完成时间`),value:g(E.task?.completedAt)},{label:u(`tasks.duration`,null,`执行时长`),value:R(E.task?.startedAt,E.task?.completedAt)},E.task?.conversationId?{label:u(`tasks.conversationIdLabel`,null,`对话ID`),value:(0,B.jsx)(`code`,{children:E.task.conversationId})}:null]}),E.task?.error?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(W,{strong:!0,type:`danger`,children:u(`tasks.statusFailed`,null,`执行失败`)}),(0,B.jsx)(`pre`,{className:`task-result-pre`,children:E.task.error})]}):null,E.task?.result?(0,B.jsx)(T,{content:E.task.result}):(0,B.jsx)(W,{type:`tertiary`,children:`暂无结果`})]})})]})}var{Text:K}=u,fe={running:{label:`执行中`,color:`blue`},cancelling:{label:`取消中`,color:`amber`},cleaning:{label:`清理中`,color:`amber`}};function pe(){let e=y(),t=n(),r=x(()=>v.get(`/agent-loop/tasks`),[]);ie(()=>r.reload({silent:!0}),6e3);let i=Array.isArray(r.data?.tasks)?r.data.tasks:[],o=[{title:e(`tasks.title`,null,`任务`),dataIndex:`title`,render:(t,n)=>(0,B.jsxs)(`div`,{className:`task-live-title`,children:[(0,B.jsx)(`span`,{className:`task-cell-message`,title:t||n.message,children:t||n.message||e(`tasks.unnamedTask`,null,`未命名任务`)}),(0,B.jsx)(K,{type:`tertiary`,size:`small`,children:(0,B.jsx)(`code`,{children:n.runId||`—`})})]})},{title:e(`projects.status`,null,`状态`),dataIndex:`status`,width:110,render:e=>{let t=fe[String(e||``)]||{label:e||`—`,color:`blue`};return(0,B.jsx)(c,{size:`small`,color:t.color,children:t.label})}},{title:e(`tasks.conversationIdLabel`,null,`对话ID`),dataIndex:`conversationId`,width:230,render:e=>(0,B.jsx)(K,{type:`tertiary`,size:`small`,children:(0,B.jsx)(`code`,{children:e||`—`})})},{title:e(`tasks.startedAt`,null,`开始时间`),dataIndex:`startedAt`,width:165,render:e=>(0,B.jsx)(K,{size:`small`,children:g(e)})},{title:e(`tasks.duration`,null,`执行时长`),dataIndex:`startedAt`,width:110,render:e=>(0,B.jsx)(K,{size:`small`,children:R(e)})},{title:e(`common.actions`,null,`操作`),dataIndex:`conversationId`,width:110,render:n=>(0,B.jsx)(a,{children:(0,B.jsx)(s,{size:`small`,theme:`borderless`,disabled:!n,onClick:()=>t(`/chat?conversation=${encodeURIComponent(n)}`),children:e(`tasks.viewConversation`,null,`查看对话`)})})}];return(0,B.jsxs)(E,{title:`${e(`tasks.runningLabel`,null,`执行中`)}任务(Agent Loop)`,description:`当前进程中正在执行的 Agent 任务;每 6 秒自动刷新。`,extra:(0,B.jsx)(s,{icon:(0,B.jsx)(ne,{}),theme:`borderless`,loading:r.loading,onClick:()=>r.reload(),children:e(`common.refresh`,null,`刷新`)}),children:[(0,B.jsx)(re,{error:le(r.error),onRetry:()=>r.reload()}),(0,B.jsx)(ae,{columns:o,dataSource:i,rowKey:e=>e.runId||e.conversationId||`unknown-task`,loading:r.loading,pagination:{pageSize:10},emptyText:e(`tasks.noMatchingTasks`,null,`当前没有符合条件的任务`)})]})}var{Text:q}=u;function J(){let e=y(),{hasPermission:t}=_(),n=t(`tasks:write`),r=t(`tasks:delete`),[l,u]=i(),f=l.get(`id`)||``,h=l.get(`tab`)||`queues`,[C,w]=(0,j.useState)(1),[T,M]=(0,j.useState)(10),[N,P]=(0,j.useState)(`all`),[F,I]=(0,j.useState)(``),R=D(F,300),[V,H]=(0,j.useState)(!1),[U,W]=(0,j.useState)(0),G=x(()=>v.get(`/batch-tasks`,{limit:100,page:1}),[U]),K=x(()=>v.get(`/batch-tasks`,{limit:T,page:C,status:N===`all`?void 0:N,keyword:R.trim()||void 0}),[C,T,N,R,U]),fe=Array.isArray(K.data?.queues)?K.data.queues:[],J=K.data?.total??0,Y=(0,j.useMemo)(()=>(G.data?.queues||[]).some(e=>e.status===`running`),[G.data]);ie(()=>{Y&&(G.reload({silent:!0}),K.reload({silent:!0}))},Y?5e3:0);let X=(0,j.useCallback)((e,t)=>{let n=new URLSearchParams(l);e?n.set(`id`,e):n.delete(`id`),t?n.set(`tab`,t):n.delete(`tab`),u(n,{replace:!!e})},[l,u]);(0,j.useEffect)(()=>{h!==`queues`&&h!==`live`&&X(void 0,`queues`)},[h,X]);let Z=()=>W(e=>e+1),Q=G.data?.queues||[],$=(0,j.useMemo)(()=>{let e=Q.map(L);return{queues:G.data?.total??Q.length,running:Q.filter(e=>e.status===`running`).length,pendingTasks:e.reduce((e,t)=>e+t.pending,0),failedTasks:e.reduce((e,t)=>e+t.failed,0)}},[Q,G.data]),me=async t=>{try{await v.post(`/batch-tasks/${t.id}/start`),k(`已开始执行`),Z()}catch(t){S(z(t,e(`tasks.startBatchQueueFailed`,null,`启动批量任务失败`)))}},he=t=>A({title:e(`tasks.statusPaused`,null,`已暂停`),content:e(`tasks.pauseQueueConfirm`,null,`确定要暂停这个批量任务队列吗?当前正在执行的任务将被停止,后续任务将保留待执行状态。`),okText:e(`common.confirm`,null,`确认`),onOk:async()=>{try{await v.post(`/batch-tasks/${t.id}/pause`),k(e(`tasks.statusPaused`,null,`已暂停`)),Z()}catch(t){S(z(t,e(`tasks.pauseQueueFailed`,null,`暂停批量任务失败`)))}}}),ge=t=>A({title:e(`tasks.retry`,null,`重试`),content:e(`tasks.rerunQueueConfirm`,null,`确定要重跑一轮吗?所有子任务将被重置为待执行状态并重新开始执行。`),okText:e(`common.confirm`,null,`确认`),onOk:async()=>{try{await v.post(`/batch-tasks/${t.id}/rerun`),k(`已开始重跑`),Z()}catch(t){S(z(t,e(`tasks.rerunQueueFailed`,null,`重跑批量任务失败`)))}}}),_e=t=>A({title:e(`tasks.deleteQueue`,null,`删除队列`),content:e(`tasks.deleteQueueConfirm`,null,`确定要删除这个批量任务队列吗?此操作不可恢复。`),okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{await v.del(`/batch-tasks/${t.id}`),k(e(`tasks.deleteQueue`,null,`删除队列`)),f===t.id&&X(void 0,h),Z()}catch(t){S(z(t,e(`tasks.deleteQueueFailed`,null,`删除批量任务队列失败`)))}}}),ve=[{id:`queues`,label:e(`tasks.batchQueueTitle`,null,`批量任务队列`),value:$.queues,loading:G.loading},{id:`running`,label:e(`tasks.runningLabel`,null,`执行中`),value:$.running,tone:$.running?`success`:void 0,loading:G.loading},{id:`pending`,label:e(`tasks.pendingLabel`,null,`待执行`),value:$.pendingTasks,loading:G.loading},{id:`failed`,label:e(`tasks.failedLabel`,null,`失败`),value:$.failedTasks,tone:$.failedTasks?`danger`:void 0,loading:G.loading}],ye=[{title:e(`batchImportModal.queueTitle`,null,`任务标题`),dataIndex:`title`,render:(t,n)=>{let r=ce(n);return(0,B.jsxs)(`button`,{type:`button`,className:`task-queue-name`,onClick:()=>X(n.id,`queues`),title:n.id,children:[(0,B.jsx)(`span`,{className:`task-queue-title`,children:t||e(`tasks.batchQueueUntitled`,null,`未命名队列`)}),r.sublabel?(0,B.jsx)(`span`,{className:`task-queue-sub`,children:r.sublabel}):null]})}},{title:e(`projects.status`,null,`状态`),dataIndex:`status`,width:170,render:(e,t)=>{let n=ce(t);return(0,B.jsx)(c,{size:`small`,color:n.color,children:n.label})}},{title:`进度`,dataIndex:`progress`,width:190,render:(e,t)=>{let n=L(t);return(0,B.jsxs)(`div`,{className:`task-queue-progress`,children:[(0,B.jsx)(p,{percent:n.percent,showInfo:!1,size:`small`}),(0,B.jsxs)(q,{type:`tertiary`,size:`small`,children:[n.percent,`%(`,n.done,`/`,n.total,`)`]})]})}},{title:e(`batchImportModal.agentMode`,null,`代理模式`),dataIndex:`agentMode`,width:150,render:e=>(0,B.jsx)(q,{size:`small`,children:se(e)})},{title:e(`batchImportModal.scheduleMode`,null,`调度方式`),dataIndex:`scheduleMode`,width:128,render:(t,n)=>(0,B.jsx)(q,{size:`small`,children:t===`cron`?`Cron · ${n.cronExpr||``}`:e(`batchImportModal.scheduleModeManual`,null,`手工执行`)})},{title:e(`tasks.createdTimeLabel`,null,`创建时间`),dataIndex:`createdAt`,width:160,render:e=>(0,B.jsx)(q,{type:`tertiary`,size:`small`,children:g(e)})},{title:e(`common.actions`,null,`操作`),dataIndex:`id`,width:250,render:(t,i)=>(0,B.jsxs)(a,{spacing:2,wrap:!0,children:[(0,B.jsx)(s,{size:`small`,theme:`borderless`,onClick:()=>X(i.id,`queues`),children:e(`projects.details`,null,`详情`)}),i.status===`running`?(0,B.jsx)(s,{size:`small`,theme:`borderless`,disabled:!n,onClick:()=>he(i),children:e(`tasks.statusPaused`,null,`已暂停`)}):(0,B.jsx)(s,{size:`small`,theme:`borderless`,disabled:!n,onClick:()=>me(i),children:`开始执行`}),(0,B.jsx)(s,{size:`small`,theme:`borderless`,disabled:!n||![`completed`,`cancelled`].includes(i.status),onClick:()=>ge(i),children:e(`tasks.retry`,null,`重试`)}),(0,B.jsx)(s,{size:`small`,theme:`borderless`,type:`danger`,disabled:!r,onClick:()=>_e(i),children:e(`common.delete`,null,`删除`)})]})}];return(0,B.jsxs)(`div`,{className:`task-page`,children:[(0,B.jsx)(O,{title:e(`tasks.title`,null,`任务管理`),description:e(`tasks.pageDesc`,null,`批量任务队列按并发池执行子任务;队列详情可查看进度、单条执行与结果。`),extra:(0,B.jsxs)(a,{children:[(0,B.jsx)(s,{icon:(0,B.jsx)(ne,{}),theme:`borderless`,loading:K.loading,onClick:Z,children:e(`common.refresh`,null,`刷新`)}),(0,B.jsx)(s,{type:`primary`,icon:(0,B.jsx)(te,{}),disabled:!n,onClick:()=>H(!0),children:e(`batchImportModal.title`,null,`新建任务`)})]})}),(0,B.jsx)(re,{error:le(G.error||K.error),onRetry:Z}),(0,B.jsx)(b,{metrics:ve,columns:4}),(0,B.jsx)(d,{type:`line`,activeKey:h,onChange:e=>X(void 0,e),tabList:[{itemKey:`queues`,tab:e(`tasks.batchQueueTitle`,null,`批量任务队列`)},{itemKey:`live`,tab:`${e(`tasks.runningLabel`,null,`执行中`)}任务`}],className:`task-tabs`}),h===`live`?(0,B.jsx)(pe,{}):(0,B.jsxs)(E,{title:e(`tasks.batchQueueTitle`,null,`批量任务队列`),description:e(`tasks.finishedProgressHint`,null,`进度表示已结束的任务比例,包含失败和取消,不表示成功率。`),extra:(0,B.jsx)(q,{type:`tertiary`,size:`small`,children:e(`tasks.taskCount`,{count:J},`共 ${J} 个任务`)}),children:[(0,B.jsxs)(`div`,{className:`task-toolbar`,children:[(0,B.jsx)(o,{prefix:(0,B.jsx)(ee,{}),value:F,showClear:!0,placeholder:e(`batchImportModal.queueTitlePlaceholder`,null,`请输入任务标题(可选,用于标识和筛选)`),onChange:e=>{I(e),w(1)},style:{width:280}}),(0,B.jsx)(m,{value:N,onChange:e=>{P(e),w(1)},style:{width:150},optionList:oe})]}),(0,B.jsx)(ae,{columns:ye,dataSource:fe,rowKey:`id`,loading:K.loading,emptyText:N!==`all`||F?e(`tasks.noMatchingTasks`,null,`当前没有符合条件的任务`):e(`tasks.noBatchQueues`,null,`当前没有批量任务队列`),pagination:{currentPage:C,pageSize:T,total:J,onPageChange:e=>w(e),onPageSizeChange:e=>{M(e),w(1)}}})]}),(0,B.jsx)(ue,{visible:V,onCancel:()=>H(!1),onCreated:e=>{H(!1),Z(),e?.queueId&&X(e.queueId,`queues`)}}),(0,B.jsx)(de,{queueId:f,visible:!!f,canWrite:n,canDelete:r,onClose:()=>X(void 0,h),onChanged:Z})]})}export{J as default};
\ No newline at end of file
diff --git a/web/static/app/assets/tool-guard-7EL5mNBc.js b/web/static/app/assets/tool-guard-C1gYGedw.js
similarity index 99%
rename from web/static/app/assets/tool-guard-7EL5mNBc.js
rename to web/static/app/assets/tool-guard-C1gYGedw.js
index 69242739..185cabc6 100644
--- a/web/static/app/assets/tool-guard-7EL5mNBc.js
+++ b/web/static/app/assets/tool-guard-C1gYGedw.js
@@ -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,Ht as o,L as s,M as c,Tt as l,W as u,Wt as d,X as f,ct as p,ot as m,u as h,x as g,z as _}from"./semi-CXF9U6uC.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-CrDogtQS.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;tO)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}=u,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(`toolGuard.blocked`,null,`已命中规则:将阻止调用`):k?o(`toolGuard.disabledResult`,null,`调用拦截已关闭:此配置不会阻止调用`):o(`toolGuard.notBlocked`,null,`未命中已启用的规则`)})]}),l&&(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:o(`toolGuard.singleResultHint`,null,`这是单条规则验证结果,实际拦截还取决于总开关、规则启停和匹配顺序。`)}),E&&O&&(0,R.jsxs)(`div`,{className:`tool-guard-match`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:o(`toolGuard.matchedRule`,null,`命中规则`)}),(0,R.jsx)(`div`,{children:O.ruleName||O.ruleId||`—`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:o(`toolGuard.matchedText`,null,`匹配文本`)}),(0,R.jsx)(`pre`,{children:O.matchedText||`—`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:o(`toolGuard.matchedMessage`,null,`返回的拦截提醒`)}),(0,R.jsx)(`div`,{children:O.message||`—`})]})]})]}),!v&&!C&&(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:o(`toolGuard.testReadyHint`,null,`点击「测试匹配」,在这里查看验证结果。`)}),l===!1&&!v&&!C&&k&&(0,R.jsx)(_,{type:`info`,bordered:!0,closeIcon:null,description:o(`toolGuard.disabledResult`,null,`调用拦截已关闭:此配置不会阻止调用`)})]})}var{Text:U}=u;function W({rule:e,index:t,total:n,canWrite:r,canTest:c,onChange:u,onDelete:f,onMove:p}){let m=b();return(0,R.jsxs)(`div`,{className:`tool-guard-rule-body`,children:[(0,R.jsxs)(`div`,{className:`tool-guard-rule-toolbar`,children:[(0,R.jsxs)(i,{spacing:8,children:[(0,R.jsx)(h,{size:`small`,checked:e.enabled,disabled:!r,onChange:e=>u({enabled:e}),"aria-label":m(`toolGuard.ruleEnabled`,null,`启用`)}),(0,R.jsx)(U,{size:`small`,type:`tertiary`,children:e.enabled?m(`toolGuard.ruleOn`,null,`已启用`):m(`toolGuard.ruleOff`,null,`已停用`)})]}),(0,R.jsxs)(i,{spacing:6,children:[(0,R.jsx)(s,{size:`small`,theme:`borderless`,icon:(0,R.jsx)(o,{}),disabled:!r||t===0,onClick:()=>p(-1),children:m(`toolGuard.moveUp`,null,`上移`)}),(0,R.jsx)(s,{size:`small`,theme:`borderless`,icon:(0,R.jsx)(d,{}),disabled:!r||t===n-1,onClick:()=>p(1),children:m(`toolGuard.moveDown`,null,`下移`)}),(0,R.jsx)(s,{size:`small`,type:`danger`,theme:`borderless`,icon:(0,R.jsx)(l,{}),disabled:!r,onClick:f,children:m(`toolGuard.deleteRule`,null,`删除`)})]})]}),(0,R.jsxs)(`div`,{className:`tool-guard-editor-grid`,children:[(0,R.jsxs)(`label`,{className:`tool-guard-field`,children:[(0,R.jsx)(U,{type:`tertiary`,size:`small`,children:m(`toolGuard.ruleName`,null,`规则名称`)}),(0,R.jsx)(a,{value:e.name,maxLength:200,disabled:!r,onChange:e=>u({name:e}),placeholder:m(`toolGuard.ruleName`,null,`规则名称`)})]}),(0,R.jsxs)(`label`,{className:`tool-guard-field tool-guard-field-wide`,children:[(0,R.jsx)(U,{type:`tertiary`,size:`small`,children:m(`toolGuard.pattern`,null,`匹配正则(RE2)`)}),(0,R.jsx)(g,{value:e.pattern,rows:3,spellCheck:!1,disabled:!r,onChange:e=>u({pattern:e}),className:`tool-guard-mono`,placeholder:`(?i)(169\\\\.254\\\\.169\\\\.254|metadata\\\\.google\\\\.internal)`})]}),(0,R.jsxs)(`label`,{className:`tool-guard-field tool-guard-field-wide`,children:[(0,R.jsx)(U,{type:`tertiary`,size:`small`,children:m(`toolGuard.message`,null,`拦截提醒`)}),(0,R.jsx)(g,{value:e.message,rows:2,disabled:!r,onChange:e=>u({message:e}),placeholder:m(`toolGuard.defaultPreview`,null,`命中后使用默认拦截提醒`)}),(0,R.jsx)(U,{type:`tertiary`,size:`small`,children:m(`toolGuard.messageHint`,null,`拦截提醒可使用 {match}(匹配文本)、{tool}(工具名称)、{rule}(规则名称)。`)})]})]}),(0,R.jsx)(H,{config:null,rule:e,compact:!0,disabled:!c})]})}var{Text:G}=u;function K(){let e=b(),{hasPermission:t}=v(),n=t(`config:read`),a=t(`config:write`),[o,l]=(0,D.useState)(null),[u,d]=(0,D.useState)(null),[g,_]=(0,D.useState)(``),[O,k]=(0,D.useState)(n),[N,L]=(0,D.useState)(null),[z,B]=(0,D.useState)(null),[V,U]=(0,D.useState)(!1),[K,q]=(0,D.useState)(!1),[ee,J]=(0,D.useState)([]),Y=(0,D.useCallback)(async()=>{if(n){k(!0),L(null),q(!1);try{let e=await y.raw(`/tool-guard`),t=e.headers.get(`ETag`)||``,n=j(await e.json());l(n),d(A(n)),_(t)}catch(e){L(e)}finally{k(!1)}}},[n]);(0,D.useEffect)(()=>{Y()},[Y]);let X=(0,D.useMemo)(()=>F(o,u),[o,u]),Z=o?.rules?.length||0,Q=o?.rules?.filter(e=>e.enabled).length||0,$=()=>{X?E({title:e(`toolGuard.reloadTitle`,null,`重新加载拦截配置`),content:e(`toolGuard.reloadConfirm`,null,`当前有未保存修改,重新加载会丢弃这些修改。确认继续?`),okText:e(`common.confirm`,null,`确定`),onOk:Y}):Y()},te=(e,t)=>{a&&(l(n=>({...n,rules:n.rules.map((n,r)=>r===e?{...n,...t}:n)})),B(null))},ne=()=>{if(!a||!o)return;if(o.rules.length>=100){x(e(`toolGuard.tooManyRules`,null,`最多可配置 100 条拦截规则`));return}let t=M();l(n=>({...n,rules:[...n.rules,{id:t,name:``,enabled:!0,pattern:``,message:e(`toolGuard.defaultMessage`,null,`识别到 {match},调用被规则「{rule}」拦截。请检查目标与操作后重试。`)}]})),J(e=>[...e,t]),B(null)},re=e=>{a&&o&&(l(t=>({...t,rules:t.rules.filter((t,n)=>n!==e)})),B(null))},ie=(e,t)=>{if(!a||!o)return;let n=e+t;n<0||n>=o.rules.length||(l(t=>{let r=[...t.rules],[i]=r.splice(e,1);return r.splice(n,0,i),{...t,rules:r}}),B(null))};return n?(0,R.jsxs)(`div`,{className:`tool-guard-page`,children:[(0,R.jsx)(w,{title:e(`toolGuard.title`,null,`调用拦截`),description:e(`toolGuard.description`,null,`在 MCP 工具执行前检查工具名称和参数,命中规则立即阻止调用。人机协同审批和工具白名单不会跳过此检查。`),extra:(0,R.jsxs)(i,{children:[(0,R.jsx)(c,{size:`small`,color:X?`amber`:`green`,children:V?e(`toolGuard.loading`,null,`处理中…`):X?e(`toolGuard.unsaved`,null,`有未保存修改`):e(`toolGuard.savedState`,null,`已与服务端同步`)}),(0,R.jsx)(s,{onClick:()=>{a&&u&&(l(A(u)),B(null),q(!1))},disabled:!a||!X||V,children:e(`toolGuard.reset`,null,`撤销修改`)}),(0,R.jsx)(s,{icon:(0,R.jsx)(m,{}),onClick:$,loading:O,disabled:V,children:e(`common.refresh`,null,`刷新`)}),(0,R.jsx)(s,{theme:`solid`,type:`primary`,icon:(0,R.jsx)(f,{}),loading:V,disabled:!a||!X,onClick:async()=>{if(!a||!o||!X)return;let t=P(o);if(t){if(B(Error(t.message)),t.index>=0){let e=o.rules[t.index];e&&J(t=>t.includes(e.id)?t:[...t,e.id])}}else if(!g)B(Error(e(`toolGuard.versionRequired`,null,`缺少调用拦截配置版本,请刷新页面后重试。`)));else{U(!0),B(null),q(!1);try{let t=await y.raw(`/tool-guard`,{method:`PUT`,body:I(o),headers:{"If-Match":g}}),n=t.headers.get(`ETag`)||g,r=j(await t.json());l(r),d(A(r)),_(n),T(e(`toolGuard.saveSuccess`,null,`调用拦截配置已保存,后续工具调用将使用新配置。`))}catch(t){let n=t?.payload?.code;n===`tool_guard_conflict`||n===`tool_guard_version_required`?(q(!0),B(Error(t.message))):B(t),x(t,e(`toolGuard.saveFailed`,null,`保存失败`))}finally{U(!1)}}},children:e(`toolGuard.save`,null,`保存并生效`)})]})}),O&&!o&&(0,R.jsx)(C,{title:e(`toolGuard.loading`,null,`处理中…`),children:(0,R.jsx)(G,{type:`tertiary`,children:`…`})}),(0,R.jsx)(S,{error:N,onRetry:Y}),(0,R.jsx)(S,{error:z,onRetry:K?$:void 0}),o&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(C,{title:e(`toolGuard.policyTitle`,null,`拦截策略`),description:e(`toolGuard.enableHint`,null,`在工具执行前检查风险,修改后保存生效。`),children:(0,R.jsxs)(`div`,{className:`tool-guard-policy`,children:[(0,R.jsxs)(i,{spacing:10,align:`center`,children:[(0,R.jsx)(h,{checked:o.enabled,disabled:!a||V,onChange:e=>{l(t=>({...t,enabled:e})),B(null)},"aria-label":e(`toolGuard.enabled`,null,`启用调用拦截`)}),(0,R.jsx)(G,{strong:!0,children:e(`toolGuard.enabled`,null,`启用调用拦截`)}),(0,R.jsx)(c,{size:`small`,color:o.enabled?`green`:`grey`,children:o.enabled?e(`toolGuard.protectionOn`,null,`调用拦截已开启`):e(`toolGuard.protectionOff`,null,`调用拦截已关闭`)}),(0,R.jsx)(c,{size:`small`,color:`blue`,children:e(`toolGuard.ruleCount`,{enabled:Q,total:Z},`${Q} / ${Z} 条规则已启用`)})]}),(0,R.jsx)(G,{type:`tertiary`,size:`small`,children:e(`toolGuard.scopeHint`,null,`正则仅检查调用中可见的文本;不会解析 IP 归属、重定向目标或工具读取的文件内容。`)})]})}),(0,R.jsxs)(C,{title:e(`toolGuard.rulesTitle`,null,`拦截规则`),description:e(`toolGuard.rulesHint`,null,`按顺序匹配已启用的规则,使用首条命中规则的提醒。正则采用 RE2 语法,保存和试运行时由服务端校验。`),extra:(0,R.jsx)(s,{icon:(0,R.jsx)(p,{}),disabled:!a||V||Z>=100,onClick:ne,children:e(`toolGuard.addRule`,null,`添加规则`)}),children:[Z===0&&(0,R.jsx)(G,{type:`tertiary`,children:e(`toolGuard.emptyRules`,null,`暂无规则。添加规则后保存,即可启用对应的拦截措施。`)}),Z>0&&(0,R.jsx)(r,{activeKey:ee,onChange:e=>J([].concat(e)),keepDOM:!1,children:o.rules.map((t,n)=>(0,R.jsx)(r.Panel,{itemKey:t.id,header:(0,R.jsxs)(i,{spacing:8,align:`center`,children:[(0,R.jsx)(`span`,{className:`tool-guard-rule-number`,children:String(n+1).padStart(2,`0`)}),(0,R.jsx)(G,{strong:!0,children:t.name.trim()||e(`toolGuard.unnamedRule`,null,`未命名规则`)}),(0,R.jsx)(c,{size:`small`,color:t.enabled?`green`:`grey`,children:t.enabled?e(`toolGuard.ruleOn`,null,`已启用`):e(`toolGuard.ruleOff`,null,`已停用`)}),(()=>{let n=u?.rules?.find(e=>e.id===t.id);return n?JSON.stringify(n)===JSON.stringify(t)?null:(0,R.jsx)(c,{size:`small`,color:`amber`,children:e(`toolGuard.ruleModified`,null,`已修改`)}):(0,R.jsx)(c,{size:`small`,color:`blue`,children:e(`toolGuard.ruleNew`,null,`新增`)})})()]}),children:(0,R.jsx)(W,{rule:t,index:n,total:Z,canWrite:a&&!V,canTest:!V,onChange:e=>te(n,e),onDelete:()=>re(n),onMove:e=>ie(n,e)})},t.id))}),(0,R.jsx)(G,{type:`tertiary`,size:`small`,children:e(`toolGuard.listHint`,null,`点击规则查看和编辑,按列表顺序匹配。`)})]}),(0,R.jsx)(C,{title:e(`toolGuard.testTitle`,null,`全部规则验证`),description:e(`toolGuard.testHint`,null,`使用页面上的当前配置(包括未保存修改),仅检查匹配结果,不执行任何工具。`),children:(0,R.jsx)(H,{config:o,disabled:V})})]})]}):(0,R.jsxs)(`div`,{className:`tool-guard-page`,children:[(0,R.jsx)(w,{title:e(`toolGuard.title`,null,`调用拦截`)}),(0,R.jsx)(S,{error:Error(e(`toolGuard.noPermission`,null,`当前账号缺少 config:read 权限,无法读取拦截配置。`))})]})}export{K as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{A as r,F as i,H as a,Ht as o,L as s,M as c,Tt as l,W as u,Wt as d,X as f,ct as p,ot as m,u as h,x as g,z as _}from"./semi-CXF9U6uC.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-LQJrYSgy.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;tO)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}=u,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(`toolGuard.blocked`,null,`已命中规则:将阻止调用`):k?o(`toolGuard.disabledResult`,null,`调用拦截已关闭:此配置不会阻止调用`):o(`toolGuard.notBlocked`,null,`未命中已启用的规则`)})]}),l&&(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:o(`toolGuard.singleResultHint`,null,`这是单条规则验证结果,实际拦截还取决于总开关、规则启停和匹配顺序。`)}),E&&O&&(0,R.jsxs)(`div`,{className:`tool-guard-match`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:o(`toolGuard.matchedRule`,null,`命中规则`)}),(0,R.jsx)(`div`,{children:O.ruleName||O.ruleId||`—`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:o(`toolGuard.matchedText`,null,`匹配文本`)}),(0,R.jsx)(`pre`,{children:O.matchedText||`—`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:o(`toolGuard.matchedMessage`,null,`返回的拦截提醒`)}),(0,R.jsx)(`div`,{children:O.message||`—`})]})]})]}),!v&&!C&&(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:o(`toolGuard.testReadyHint`,null,`点击「测试匹配」,在这里查看验证结果。`)}),l===!1&&!v&&!C&&k&&(0,R.jsx)(_,{type:`info`,bordered:!0,closeIcon:null,description:o(`toolGuard.disabledResult`,null,`调用拦截已关闭:此配置不会阻止调用`)})]})}var{Text:U}=u;function W({rule:e,index:t,total:n,canWrite:r,canTest:c,onChange:u,onDelete:f,onMove:p}){let m=b();return(0,R.jsxs)(`div`,{className:`tool-guard-rule-body`,children:[(0,R.jsxs)(`div`,{className:`tool-guard-rule-toolbar`,children:[(0,R.jsxs)(i,{spacing:8,children:[(0,R.jsx)(h,{size:`small`,checked:e.enabled,disabled:!r,onChange:e=>u({enabled:e}),"aria-label":m(`toolGuard.ruleEnabled`,null,`启用`)}),(0,R.jsx)(U,{size:`small`,type:`tertiary`,children:e.enabled?m(`toolGuard.ruleOn`,null,`已启用`):m(`toolGuard.ruleOff`,null,`已停用`)})]}),(0,R.jsxs)(i,{spacing:6,children:[(0,R.jsx)(s,{size:`small`,theme:`borderless`,icon:(0,R.jsx)(o,{}),disabled:!r||t===0,onClick:()=>p(-1),children:m(`toolGuard.moveUp`,null,`上移`)}),(0,R.jsx)(s,{size:`small`,theme:`borderless`,icon:(0,R.jsx)(d,{}),disabled:!r||t===n-1,onClick:()=>p(1),children:m(`toolGuard.moveDown`,null,`下移`)}),(0,R.jsx)(s,{size:`small`,type:`danger`,theme:`borderless`,icon:(0,R.jsx)(l,{}),disabled:!r,onClick:f,children:m(`toolGuard.deleteRule`,null,`删除`)})]})]}),(0,R.jsxs)(`div`,{className:`tool-guard-editor-grid`,children:[(0,R.jsxs)(`label`,{className:`tool-guard-field`,children:[(0,R.jsx)(U,{type:`tertiary`,size:`small`,children:m(`toolGuard.ruleName`,null,`规则名称`)}),(0,R.jsx)(a,{value:e.name,maxLength:200,disabled:!r,onChange:e=>u({name:e}),placeholder:m(`toolGuard.ruleName`,null,`规则名称`)})]}),(0,R.jsxs)(`label`,{className:`tool-guard-field tool-guard-field-wide`,children:[(0,R.jsx)(U,{type:`tertiary`,size:`small`,children:m(`toolGuard.pattern`,null,`匹配正则(RE2)`)}),(0,R.jsx)(g,{value:e.pattern,rows:3,spellCheck:!1,disabled:!r,onChange:e=>u({pattern:e}),className:`tool-guard-mono`,placeholder:`(?i)(169\\\\.254\\\\.169\\\\.254|metadata\\\\.google\\\\.internal)`})]}),(0,R.jsxs)(`label`,{className:`tool-guard-field tool-guard-field-wide`,children:[(0,R.jsx)(U,{type:`tertiary`,size:`small`,children:m(`toolGuard.message`,null,`拦截提醒`)}),(0,R.jsx)(g,{value:e.message,rows:2,disabled:!r,onChange:e=>u({message:e}),placeholder:m(`toolGuard.defaultPreview`,null,`命中后使用默认拦截提醒`)}),(0,R.jsx)(U,{type:`tertiary`,size:`small`,children:m(`toolGuard.messageHint`,null,`拦截提醒可使用 {match}(匹配文本)、{tool}(工具名称)、{rule}(规则名称)。`)})]})]}),(0,R.jsx)(H,{config:null,rule:e,compact:!0,disabled:!c})]})}var{Text:G}=u;function K(){let e=b(),{hasPermission:t}=v(),n=t(`config:read`),a=t(`config:write`),[o,l]=(0,D.useState)(null),[u,d]=(0,D.useState)(null),[g,_]=(0,D.useState)(``),[O,k]=(0,D.useState)(n),[N,L]=(0,D.useState)(null),[z,B]=(0,D.useState)(null),[V,U]=(0,D.useState)(!1),[K,q]=(0,D.useState)(!1),[ee,J]=(0,D.useState)([]),Y=(0,D.useCallback)(async()=>{if(n){k(!0),L(null),q(!1);try{let e=await y.raw(`/tool-guard`),t=e.headers.get(`ETag`)||``,n=j(await e.json());l(n),d(A(n)),_(t)}catch(e){L(e)}finally{k(!1)}}},[n]);(0,D.useEffect)(()=>{Y()},[Y]);let X=(0,D.useMemo)(()=>F(o,u),[o,u]),Z=o?.rules?.length||0,Q=o?.rules?.filter(e=>e.enabled).length||0,$=()=>{X?E({title:e(`toolGuard.reloadTitle`,null,`重新加载拦截配置`),content:e(`toolGuard.reloadConfirm`,null,`当前有未保存修改,重新加载会丢弃这些修改。确认继续?`),okText:e(`common.confirm`,null,`确定`),onOk:Y}):Y()},te=(e,t)=>{a&&(l(n=>({...n,rules:n.rules.map((n,r)=>r===e?{...n,...t}:n)})),B(null))},ne=()=>{if(!a||!o)return;if(o.rules.length>=100){x(e(`toolGuard.tooManyRules`,null,`最多可配置 100 条拦截规则`));return}let t=M();l(n=>({...n,rules:[...n.rules,{id:t,name:``,enabled:!0,pattern:``,message:e(`toolGuard.defaultMessage`,null,`识别到 {match},调用被规则「{rule}」拦截。请检查目标与操作后重试。`)}]})),J(e=>[...e,t]),B(null)},re=e=>{a&&o&&(l(t=>({...t,rules:t.rules.filter((t,n)=>n!==e)})),B(null))},ie=(e,t)=>{if(!a||!o)return;let n=e+t;n<0||n>=o.rules.length||(l(t=>{let r=[...t.rules],[i]=r.splice(e,1);return r.splice(n,0,i),{...t,rules:r}}),B(null))};return n?(0,R.jsxs)(`div`,{className:`tool-guard-page`,children:[(0,R.jsx)(w,{title:e(`toolGuard.title`,null,`调用拦截`),description:e(`toolGuard.description`,null,`在 MCP 工具执行前检查工具名称和参数,命中规则立即阻止调用。人机协同审批和工具白名单不会跳过此检查。`),extra:(0,R.jsxs)(i,{children:[(0,R.jsx)(c,{size:`small`,color:X?`amber`:`green`,children:V?e(`toolGuard.loading`,null,`处理中…`):X?e(`toolGuard.unsaved`,null,`有未保存修改`):e(`toolGuard.savedState`,null,`已与服务端同步`)}),(0,R.jsx)(s,{onClick:()=>{a&&u&&(l(A(u)),B(null),q(!1))},disabled:!a||!X||V,children:e(`toolGuard.reset`,null,`撤销修改`)}),(0,R.jsx)(s,{icon:(0,R.jsx)(m,{}),onClick:$,loading:O,disabled:V,children:e(`common.refresh`,null,`刷新`)}),(0,R.jsx)(s,{theme:`solid`,type:`primary`,icon:(0,R.jsx)(f,{}),loading:V,disabled:!a||!X,onClick:async()=>{if(!a||!o||!X)return;let t=P(o);if(t){if(B(Error(t.message)),t.index>=0){let e=o.rules[t.index];e&&J(t=>t.includes(e.id)?t:[...t,e.id])}}else if(!g)B(Error(e(`toolGuard.versionRequired`,null,`缺少调用拦截配置版本,请刷新页面后重试。`)));else{U(!0),B(null),q(!1);try{let t=await y.raw(`/tool-guard`,{method:`PUT`,body:I(o),headers:{"If-Match":g}}),n=t.headers.get(`ETag`)||g,r=j(await t.json());l(r),d(A(r)),_(n),T(e(`toolGuard.saveSuccess`,null,`调用拦截配置已保存,后续工具调用将使用新配置。`))}catch(t){let n=t?.payload?.code;n===`tool_guard_conflict`||n===`tool_guard_version_required`?(q(!0),B(Error(t.message))):B(t),x(t,e(`toolGuard.saveFailed`,null,`保存失败`))}finally{U(!1)}}},children:e(`toolGuard.save`,null,`保存并生效`)})]})}),O&&!o&&(0,R.jsx)(C,{title:e(`toolGuard.loading`,null,`处理中…`),children:(0,R.jsx)(G,{type:`tertiary`,children:`…`})}),(0,R.jsx)(S,{error:N,onRetry:Y}),(0,R.jsx)(S,{error:z,onRetry:K?$:void 0}),o&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(C,{title:e(`toolGuard.policyTitle`,null,`拦截策略`),description:e(`toolGuard.enableHint`,null,`在工具执行前检查风险,修改后保存生效。`),children:(0,R.jsxs)(`div`,{className:`tool-guard-policy`,children:[(0,R.jsxs)(i,{spacing:10,align:`center`,children:[(0,R.jsx)(h,{checked:o.enabled,disabled:!a||V,onChange:e=>{l(t=>({...t,enabled:e})),B(null)},"aria-label":e(`toolGuard.enabled`,null,`启用调用拦截`)}),(0,R.jsx)(G,{strong:!0,children:e(`toolGuard.enabled`,null,`启用调用拦截`)}),(0,R.jsx)(c,{size:`small`,color:o.enabled?`green`:`grey`,children:o.enabled?e(`toolGuard.protectionOn`,null,`调用拦截已开启`):e(`toolGuard.protectionOff`,null,`调用拦截已关闭`)}),(0,R.jsx)(c,{size:`small`,color:`blue`,children:e(`toolGuard.ruleCount`,{enabled:Q,total:Z},`${Q} / ${Z} 条规则已启用`)})]}),(0,R.jsx)(G,{type:`tertiary`,size:`small`,children:e(`toolGuard.scopeHint`,null,`正则仅检查调用中可见的文本;不会解析 IP 归属、重定向目标或工具读取的文件内容。`)})]})}),(0,R.jsxs)(C,{title:e(`toolGuard.rulesTitle`,null,`拦截规则`),description:e(`toolGuard.rulesHint`,null,`按顺序匹配已启用的规则,使用首条命中规则的提醒。正则采用 RE2 语法,保存和试运行时由服务端校验。`),extra:(0,R.jsx)(s,{icon:(0,R.jsx)(p,{}),disabled:!a||V||Z>=100,onClick:ne,children:e(`toolGuard.addRule`,null,`添加规则`)}),children:[Z===0&&(0,R.jsx)(G,{type:`tertiary`,children:e(`toolGuard.emptyRules`,null,`暂无规则。添加规则后保存,即可启用对应的拦截措施。`)}),Z>0&&(0,R.jsx)(r,{activeKey:ee,onChange:e=>J([].concat(e)),keepDOM:!1,children:o.rules.map((t,n)=>(0,R.jsx)(r.Panel,{itemKey:t.id,header:(0,R.jsxs)(i,{spacing:8,align:`center`,children:[(0,R.jsx)(`span`,{className:`tool-guard-rule-number`,children:String(n+1).padStart(2,`0`)}),(0,R.jsx)(G,{strong:!0,children:t.name.trim()||e(`toolGuard.unnamedRule`,null,`未命名规则`)}),(0,R.jsx)(c,{size:`small`,color:t.enabled?`green`:`grey`,children:t.enabled?e(`toolGuard.ruleOn`,null,`已启用`):e(`toolGuard.ruleOff`,null,`已停用`)}),(()=>{let n=u?.rules?.find(e=>e.id===t.id);return n?JSON.stringify(n)===JSON.stringify(t)?null:(0,R.jsx)(c,{size:`small`,color:`amber`,children:e(`toolGuard.ruleModified`,null,`已修改`)}):(0,R.jsx)(c,{size:`small`,color:`blue`,children:e(`toolGuard.ruleNew`,null,`新增`)})})()]}),children:(0,R.jsx)(W,{rule:t,index:n,total:Z,canWrite:a&&!V,canTest:!V,onChange:e=>te(n,e),onDelete:()=>re(n),onMove:e=>ie(n,e)})},t.id))}),(0,R.jsx)(G,{type:`tertiary`,size:`small`,children:e(`toolGuard.listHint`,null,`点击规则查看和编辑,按列表顺序匹配。`)})]}),(0,R.jsx)(C,{title:e(`toolGuard.testTitle`,null,`全部规则验证`),description:e(`toolGuard.testHint`,null,`使用页面上的当前配置(包括未保存修改),仅检查匹配结果,不执行任何工具。`),children:(0,R.jsx)(H,{config:o,disabled:V})})]})]}):(0,R.jsxs)(`div`,{className:`tool-guard-page`,children:[(0,R.jsx)(w,{title:e(`toolGuard.title`,null,`调用拦截`)}),(0,R.jsx)(S,{error:Error(e(`toolGuard.noPermission`,null,`当前账号缺少 config:read 权限,无法读取拦截配置。`))})]})}export{K as default};
\ No newline at end of file
diff --git a/web/static/app/assets/vulnerabilities-Bkcss_JH.js b/web/static/app/assets/vulnerabilities-C-hePmba.js
similarity index 61%
rename from web/static/app/assets/vulnerabilities-Bkcss_JH.js
rename to web/static/app/assets/vulnerabilities-C-hePmba.js
index ffb1833d..32673c41 100644
--- a/web/static/app/assets/vulnerabilities-Bkcss_JH.js
+++ b/web/static/app/assets/vulnerabilities-C-hePmba.js
@@ -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,F as o,H as s,L as c,M as l,St as u,Tt as d,U as f,W as p,a as m,at as h,c as g,ct as _,f as v,i as y,m as ee,ot as b,p as x,s as te,v as S}from"./semi-CXF9U6uC.js";import{C as ne,E as re,F as ie,I as C,L as ae,P as oe,R as se,S as w,_ as ce,a as T,b as E,c as D,d as le,f as O,h as k,l as ue,m as A,n as j,o as de,p as fe,s as pe,v as M,x as N,y as me}from"./index-CrDogtQS.js";var P=e(t(),1),he=[`critical`,`high`,`medium`,`low`,`info`],ge=[`open`,`confirmed`,`fixed`,`ignored`,`false_positive`],F=[`q`,`severity`,`status`,`project_id`,`conversation_tag`,`task_tag`,`assessment_id`],_e=[10,20,50,100],I={critical:`dashboard.severityCritical`,high:`dashboard.severityHigh`,medium:`dashboard.severityMedium`,low:`dashboard.severityLow`,info:`dashboard.severityInfo`},ve={open:`vulnerabilityPage.statusOpen`,confirmed:`vulnerabilityPage.statusConfirmed`,fixed:`vulnerabilityPage.statusFixed`,ignored:`vulnerabilityPage.statusIgnored`,false_positive:`vulnerabilityPage.statusFalsePositive`},L={open:`待处理`,confirmed:`已确认`,fixed:`已修复`,ignored:`已忽略`,false_positive:`误报`},R={retest:`复测结果`,retest_started:`复测分支已创建`,merge:`归并上报`,split:`拆分归并组`,detach:`解除关联`},z=[{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=I[t];return n?e(n,null,ne[t]||t):String(t)}function B(e,t){if(!t)return`—`;let n=ve[t];return n?e(n,null,L[t]||t):String(t)}function be(e,t){return t?e(`vulnerabilityPage.history_${t}`,null,R[t]||t):`—`}function xe(e){return he.map(t=>({value:t,label:ye(e,t)}))}function V(e){return ge.map(t=>({value:t,label:B(e,t)}))}function Se(e){return z.map(t=>({value:t.value,label:e(t.key,null,t.fallback)}))}function Ce(e){let t={};return F.forEach(n=>{let r=String(e?.[n]??``).trim();r&&(t[n]=r)}),t}function we(e){let t=Ce(e);return delete t.severity,t}function Te(e){return F.some(t=>String(e?.[t]??``).trim()!==``)}function Ee(e,t){let n=Number(e)||0,r=Number(t)||0;return r>0?Math.round(n/r*100):0}function De(e){return String(e?.target||``).trim()}function H(e){return(Array.isArray(e?.targets)?e.targets:[]).map(e=>e?.host).find(Boolean)||e?.target_host||e?.target_domain||``}function Oe(e){if(!e)return`—`;let t=e.host||e.id||`—`;return e.port?`${t}:${e.port}`:t}function U(e,t=8){let n=String(e||``);return n.length>t?`${n.slice(0,t)}…`:n}function ke(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 W=e(r(),1);function G(e,t){return[{value:``,label:e},...t]}function Ae({t:e,filters:t,options:n,projectOptions:r,hasGroupFilters:i,onChange:a,onReset:o}){let[l,u]=(0,P.useState)(t.q),d=j(l,380),f=(0,P.useRef)(t.q);(0,P.useEffect)(()=>{d!==f.current&&(f.current=d,a(`q`,d))},[d,a]),(0,P.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:[],g=Array.isArray(n?.assessment_ids)?n.assessment_ids:[];return(0,W.jsxs)(`div`,{className:`vulnerability-filter-bar`,children:[(0,W.jsx)(s,{className:`vulnerability-filter-search`,prefix:(0,W.jsx)(h,{}),value:l,showClear:!0,placeholder:e(`vulnerabilityPage.searchKeyword`,null,`搜索标题、描述、类型、目标…`),"aria-label":e(`vulnerabilityPage.searchKeyword`,null,`搜索标题、描述、类型、目标…`),onChange:e=>u(e)}),(0,W.jsx)(S,{className:`vulnerability-filter-select`,value:t.severity,placeholder:e(`vulnerabilityPage.severity`,null,`严重程度`),optionList:G(e(`vulnerabilityPage.allSeverities`,null,`全部级别`),xe(e)),onChange:e=>a(`severity`,e||``)}),(0,W.jsx)(S,{className:`vulnerability-filter-select`,value:t.status,placeholder:e(`vulnerabilityPage.status`,null,`状态`),optionList:G(e(`dashboard.allStatuses`,null,`全部状态`),V(e)),onChange:e=>a(`status`,e||``)}),(0,W.jsx)(S,{className:`vulnerability-filter-select vulnerability-filter-select--wide`,value:t.project_id,placeholder:e(`vulnerabilityPage.detailProject`,null,`所属项目`),filter:!0,optionList:G(e(`vulnerabilityPage.allProjects`,null,`全部项目`),r),onChange:e=>a(`project_id`,e||``)}),(0,W.jsx)(S,{className:`vulnerability-filter-select`,value:t.conversation_tag,placeholder:e(`vulnerabilityPage.conversationTag`,null,`来源(对话标签)`),filter:!0,optionList:G(e(`vulnerabilityPage.allSources`,null,`全部来源`),p.map(e=>({value:e,label:e}))),onChange:e=>a(`conversation_tag`,e||``)}),(0,W.jsx)(S,{className:`vulnerability-filter-select`,value:t.task_tag,placeholder:e(`vulnerabilityPage.taskTag`,null,`任务标签`),filter:!0,optionList:G(e(`vulnerabilityPage.allTaskTags`,null,`全部任务标签`),m.map(e=>({value:e,label:e}))),onChange:e=>a(`task_tag`,e||``)}),(0,W.jsx)(S,{className:`vulnerability-filter-select`,value:t.assessment_id,placeholder:e(`vulnerabilityPage.assessmentTask`,null,`深度测评`),filter:!0,optionList:G(e(`vulnerabilityPage.allAssessments`,null,`全部测评`),g.map(e=>({value:e,label:U(e,12)}))),onChange:e=>a(`assessment_id`,e||``)}),(0,W.jsx)(`div`,{className:`vulnerability-filter-actions`,children:(0,W.jsx)(c,{icon:(0,W.jsx)(b,{}),theme:`borderless`,disabled:!Te(t)&&!t.sort&&!i,onClick:o,children:e(`vulnerabilityPage.clearAll`,null,`重置全部`)})})]})}var{Text:je}=p,K={critical:`red`,high:`orange`,medium:`amber`,low:`blue`,info:`grey`};function q(e,t){return t.key.startsWith(`task:`)?e(`vulnerabilityPage.viewTaskGroup`,{id:t.label||t.key.slice(5)}):t.label?t.label:t.key.startsWith(`host:`)?e(`vulnerabilityPage.unknownHost`):t.key.startsWith(`queue:`)?e(`vulnerabilityPage.taskQueueGroup`,{id:t.key.slice(6)}):t.key.startsWith(`assessment:`)?t.key.slice(11):e(`vulnerabilityPage.viewNoTask`)}function Me(e,t){let n=q(e,t);return{key:t.key,value:t.key,label:(0,W.jsxs)(`span`,{className:`vulnerability-group-node`,children:[(0,W.jsx)(`span`,{className:`vulnerability-group-name`,title:n,children:n}),(0,W.jsx)(l,{size:`small`,color:`grey`,children:t.count})]}),children:t.children?.map(t=>Me(e,t))}}function Ne({t:e,mode:t,groups:n,selection:r,loading:i,search:a,onSearch:o,onSelect:c}){let[l,u]=(0,P.useState)(a),d=t===`task`,p=e(d?`vulnerabilityPage.viewTask`:`vulnerabilityPage.viewHost`),g=e(d?`vulnerabilityPage.taskSearch`:`vulnerabilityPage.hostSearch`),{treeData:_,expandedKeys:v}=(0,P.useMemo)(()=>({treeData:[{key:`all`,value:`all`,label:e(d?`vulnerabilityPage.allTasks`:`vulnerabilityPage.allHosts`)},...n.map(t=>Me(e,t))],expandedKeys:n.filter(e=>e.children?.length).map(e=>e.key)}),[e,n,d]);return(0,P.useEffect)(()=>u(a),[a]),(0,P.useEffect)(()=>{if(l.trim()===a)return;let e=setTimeout(()=>o(l.trim()),350);return()=>clearTimeout(e)},[l,a,o]),(0,W.jsxs)(`aside`,{className:`vulnerability-group-sidebar`,"aria-label":p,children:[(0,W.jsx)(je,{strong:!0,children:p}),(0,W.jsx)(s,{prefix:(0,W.jsx)(h,{}),"aria-label":g,placeholder:g,value:l,showClear:!0,onChange:u}),(0,W.jsxs)(f,{spinning:i,wrapperClassName:`vulnerability-group-scroll`,children:[(0,W.jsx)(m,{"aria-label":p,treeData:_,value:r||`all`,onSelect:e=>c(e===`all`?``:e),expandedKeys:v,expandIcon:()=>(0,W.jsx)(`span`,{className:`semi-tree-empty-icon`,"aria-hidden":`true`}),expandAction:!1,blockNode:!0}),!n.length&&!i&&(0,W.jsx)(je,{className:`vulnerability-group-empty`,type:`tertiary`,size:`small`,children:e(`vulnerabilityPage.noMatchingGroups`)})]})]})}function Pe({t:e,group:t}){return(0,W.jsxs)(`div`,{className:`vulnerability-group-overview`,children:[(0,W.jsx)(je,{strong:!0,className:`vulnerability-group-name`,children:q(e,t)}),(0,W.jsxs)(`div`,{className:`vulnerability-group-badges`,children:[he.filter(e=>t.severities?.[e]).map(n=>(0,W.jsxs)(l,{color:K[n],children:[ye(e,n),` `,t.severities[n]]},n)),(0,W.jsx)(l,{color:`grey`,children:e(`vulnerabilityPage.groupPending`,{count:t.pending})})]})]})}var{Text:Fe}=p;function Ie({record:e}){let t=[e.conversation_tag,e.task_tag].filter(Boolean);return t.length?(0,W.jsx)(`span`,{className:`vulnerability-source-tags`,children:t.map(e=>(0,W.jsx)(l,{size:`small`,color:`blue`,type:`light`,children:e},e))}):e.conversation_id?(0,W.jsx)(Fe,{type:`tertiary`,className:`vulnerability-inline-code`,title:e.conversation_id,children:U(e.conversation_id,10)}):(0,W.jsx)(Fe,{type:`tertiary`,children:`—`})}function Le({t:e,data:t,loading:n,page:r,pageSize:i,total:a,selection:o,onSelectionChange:s,onOpen:l,onEdit:u,onDelete:d,onDownload:f,sort:p,onSort:m,canWrite:h,canDelete:g,onPageChange:_,onPageSizeChange:v,toolbar:y,onRefresh:ee}){let b=[{title:e(`vulnerabilityPage.tableTitle`,null,`漏洞名称`),dataIndex:`title`,render:(t,n)=>(0,W.jsxs)(`div`,{className:`vulnerability-title-cell`,children:[(0,W.jsx)(`span`,{className:`vulnerability-title-text`,title:n.title,children:n.title||`—`}),(0,W.jsxs)(`span`,{className:`vulnerability-title-meta`,children:[n.type||`—`,n.case_id?` · ${e(`vulnerabilityPage.mergedRecord`,null,`已归并`)}`:``,n.assessment_id?` · ${e(`vulnerabilityPage.assessmentTask`,null,`深度测评`)}`:``]})]})},{title:e(`vulnerabilityPage.tableSeverity`,null,`严重度`),dataIndex:`severity`,width:92,render:e=>(0,W.jsx)(k,{severity:e})},{title:e(`vulnerabilityPage.tableStatus`,null,`状态`),dataIndex:`status`,width:100,render:t=>(0,W.jsx)(M,{status:t,label:B(e,t)})},{title:e(`vulnerabilityPage.detailTarget`,null,`目标 / 宿主`),dataIndex:`target`,width:220,render:(e,t)=>{let n=De(t),r=Array.isArray(t.targets)&&t.targets.length?t.targets.map(e=>e?.host).filter(Boolean).join(`, `):``;return(0,W.jsxs)(`div`,{className:`vulnerability-target-cell`,children:[(0,W.jsx)(`span`,{className:`vulnerability-target-text`,title:n||r,children:n||r||`—`}),n&&r&&r!==n?(0,W.jsx)(`span`,{className:`vulnerability-target-host`,title:r,children:r}):null]})}},{title:e(`vulnerabilityPage.tableSource`,null,`来源`),dataIndex:`conversation_tag`,width:170,render:(e,t)=>(0,W.jsx)(Ie,{record:t})},{title:e(`vulnerabilityPage.tableDate`,null,`创建时间`),dataIndex:`created_at`,width:180,render:e=>(0,W.jsx)(`span`,{className:`vulnerability-time`,children:re(e)})},{title:e(`vulnerabilityPage.tableActions`,null,`操作`),dataIndex:`id`,width:200,render:(t,n)=>(0,W.jsxs)(`div`,{className:`vulnerability-row-actions`,children:[(0,W.jsx)(c,{size:`small`,theme:`borderless`,onClick:e=>{e.stopPropagation(),l(n.id)},children:e(`vulnerabilityPage.rowView`,null,`详情`)}),(0,W.jsx)(c,{size:`small`,theme:`borderless`,onClick:e=>{e.stopPropagation(),f(n)},children:e(`vulnerabilityPage.tableDownload`,null,`下载`)}),h&&(0,W.jsx)(c,{size:`small`,theme:`borderless`,onClick:e=>{e.stopPropagation(),u(n)},children:e(`common.edit`,null,`编辑`)}),g&&(0,W.jsx)(c,{size:`small`,theme:`borderless`,type:`danger`,onClick:e=>{e.stopPropagation(),d(n)},children:e(`common.delete`,null,`删除`)})]})}],x=y?(0,W.jsxs)(`div`,{className:`vulnerability-table-toolbar`,children:[y,(0,W.jsx)(S,{className:`vulnerability-sort-select`,size:`small`,value:p,optionList:Se(e),onChange:e=>m(e||``)})]}):null;return(0,W.jsx)(pe,{columns:b,dataSource:Array.isArray(t)?t:[],loading:n,rowKey:`id`,toolbar:x,onRefresh:ee,emptyText:e(`vulnerabilityPage.noRecords`,null,`暂无漏洞记录`),scroll:{x:1200},rowSelection:g?{selectedRowKeys:o,onChange:e=>s(Array.isArray(e)?e:[])}:void 0,onRow:e=>({onClick:t=>{t.target?.closest?.(`button, a, input, label, .semi-checkbox`)||l(e.id)}}),pagination:{currentPage:r,pageSize:i,total:Number(a)||0,showSizeChanger:!0,pageSizeOpts:_e,onPageChange:e=>_(Number(e)),onPageSizeChange:e=>v(Number(e))}})}var{Text:J,Paragraph:Y}=p;function X({title:e,extra:t,children:n}){return(0,W.jsxs)(`section`,{className:`vulnerability-section`,children:[(0,W.jsxs)(`div`,{className:`vulnerability-section-head`,children:[(0,W.jsx)(`span`,{className:`vulnerability-section-title`,children:e}),t]}),(0,W.jsx)(`div`,{className:`vulnerability-section-body`,children:n})]})}function Z({title:e,content:t,code:n}){let r=String(t??``).trim();return r?n?(0,W.jsx)(X,{title:e,extra:(0,W.jsx)(de,{text:r,size:`small`}),children:(0,W.jsx)(`pre`,{className:`vulnerability-code`,children:r})}):(0,W.jsx)(X,{title:e,children:(0,W.jsx)(O,{content:r})}):null}function Re({visible:e,vulnId:t,refreshKey:r,onClose:i,onEdit:s,onDelete:l,onOpenVuln:p,canWrite:m,canDelete:h,t:_,projectNames:y}){let S=n(),[ne,ie]=(0,P.useState)(`overview`),[oe,se]=(0,P.useState)(`docx`),[w,ce]=(0,P.useState)(!1),D=T(()=>C.get(`/vulnerabilities/${encodeURIComponent(t)}/context`),[t,r,e],{skip:!e||!t});(0,P.useEffect)(()=>{ie(`overview`),se(`docx`)},[t]);let O=D.data?.vulnerability?.id===t?D.data:null,A=O?.vulnerability||null,j=Array.isArray(O?.history)?O.history:[],de=Array.isArray(O?.members)?O.members:[],fe=Array.isArray(O?.assets)?O.assets:[],pe=A?.project_id?y?.[A.project_id]||A.project_id:``,me=e=>{e&&S(`/chat?conversation=${encodeURIComponent(e)}`)},he=async()=>{if(A&&!w){ce(!0);try{let e=await ae(`/vulnerabilities/${encodeURIComponent(A.id)}/download`,{query:{format:oe}});N(`${_(`vulnerabilityPage.downloadOkTitle`,null,`下载成功`)}${e?` · ${e}`:``}`)}catch(e){E(e,_(`vulnerabilityPage.downloadFailed`,null,`下载失败`))}finally{ce(!1)}}},ge=A?[{label:_(`vulnerabilityPage.detailVulnId`,null,`漏洞ID`),value:(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:A.id})},{label:_(`vulnerabilityPage.tableSeverity`,null,`严重度`),value:(0,W.jsx)(k,{severity:A.severity})},{label:_(`vulnerabilityPage.status`,null,`状态`),value:(0,W.jsx)(M,{status:A.status,label:B(_,A.status)})},A.type?{label:_(`vulnerabilityPage.detailType`,null,`类型`),value:A.type}:null,A.target?{label:_(`vulnerabilityPage.detailTarget`,null,`目标`),value:(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:A.target})}:null,H(A)&&H(A)!==A.target?{label:_(`vulnerabilityPage.detailHost`,null,`宿主`),value:(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:H(A)})}:null,{label:_(`vulnerabilityPage.detailProject`,null,`所属项目`),value:pe||_(`vulnerabilityPage.projectUnbound`,null,`未绑定项目`)},A.conversation_tag?{label:_(`vulnerabilityPage.detailConversationTag`,null,`对话标签`),value:A.conversation_tag}:null,A.conversation_id?{label:_(`vulnerabilityPage.detailConversationId`,null,`会话ID`),value:(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:A.conversation_id})}:null,A.task_tag?{label:_(`vulnerabilityPage.detailTaskTag`,null,`任务标签`),value:A.task_tag}:null,A.task_id?{label:_(`vulnerabilityPage.detailTaskId`,null,`任务ID`),value:(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:A.task_id})}:null,A.task_queue_id?{label:_(`vulnerabilityPage.detailTaskQueueId`,null,`任务队列ID`),value:(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:A.task_queue_id})}:null,A.case_id?{label:_(`vulnerabilityPage.mergedRecord`,null,`已归并`),value:A.case_title||U(A.case_id,12)}:null,A.assessment_id?{label:_(`vulnerabilityPage.assessmentTask`,null,`深度测评`),value:A.assessment_name||U(A.assessment_id,12)}:null,{label:_(`vulnerabilityMd.labelCreated`,null,`创建时间`),value:re(A.created_at)},{label:_(`vulnerabilityMd.labelUpdated`,null,`更新时间`),value:re(A.updated_at)}].filter(Boolean):[],F=Array.isArray(A?.targets)?A.targets:[];return(0,W.jsxs)(v,{className:`vulnerability-detail-drawer`,visible:e,onCancel:i,width:720,title:(0,W.jsxs)(`div`,{className:`vulnerability-drawer-title`,children:[(0,W.jsx)(`span`,{className:`vulnerability-drawer-title-text`,title:A?.title,children:A?.title||_(`vulnerabilityPage.inspectorTitle`,null,`漏洞工作台`)}),A&&(0,W.jsxs)(`span`,{className:`vulnerability-drawer-meta`,children:[(0,W.jsx)(k,{severity:A.severity}),(0,W.jsx)(M,{status:A.status,label:B(_,A.status)}),A.type?(0,W.jsx)(J,{type:`tertiary`,children:A.type}):null]})]}),footer:(0,W.jsxs)(o,{children:[(0,W.jsx)(c,{onClick:i,children:_(`common.close`,null,`关闭`)}),(0,W.jsx)(c,{icon:(0,W.jsx)(b,{}),onClick:()=>D.reload(),loading:D.loading,children:_(`common.refresh`,null,`刷新`)}),m&&(0,W.jsx)(c,{icon:(0,W.jsx)(u,{}),disabled:!A,onClick:()=>s(A),children:_(`common.edit`,null,`编辑`)}),h&&(0,W.jsx)(c,{type:`danger`,icon:(0,W.jsx)(d,{}),disabled:!A,onClick:()=>l(A),children:_(`common.delete`,null,`删除`)})]}),children:[(0,W.jsx)(ue,{error:D.error,onRetry:D.reload}),!D.error&&!A&&(0,W.jsx)(`div`,{className:`vulnerability-drawer-loading`,children:(0,W.jsx)(f,{size:`large`})}),A&&(0,W.jsxs)(g,{type:`line`,activeKey:ne,onChange:e=>ie(e),children:[(0,W.jsxs)(g.TabPane,{tab:_(`vulnerabilityPage.inspector_overview`,null,`概览`),itemKey:`overview`,children:[(0,W.jsx)(le,{items:ge,columns:2}),(0,W.jsx)(Z,{title:_(`vulnerabilityMd.headingDescription`,null,`描述`),content:A.description}),(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailImpact`,null,`影响`),content:A.impact}),(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailRecommendation`,null,`修复建议`),content:A.recommendation})]}),(0,W.jsxs)(g.TabPane,{tab:_(`vulnerabilityPage.inspector_evidence`,null,`复现与证据`),itemKey:`evidence`,children:[(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailPreconditions`,null,`前置条件`),content:A.preconditions}),(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailReproductionSteps`,null,`复现步骤`),content:A.reproduction_steps}),(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailEvidence`,null,`证据 / POC`),content:A.evidence,code:!0}),(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailRetestNotes`,null,`复测方式`),content:A.retest_notes}),(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailRetestLog`,null,`复测记录`),content:A.retest_log,code:!0}),(0,W.jsx)(X,{title:_(`vulnerabilityPage.inspector_history`,null,`处置历史`),children:j.length?(0,W.jsx)(te,{children:j.map((e,t)=>(0,W.jsx)(te.Item,{time:re(e.created_at),type:e.kind===`retest`?`success`:`default`,children:(0,W.jsxs)(`div`,{className:`vulnerability-history-item`,children:[(0,W.jsxs)(`div`,{className:`vulnerability-history-head`,children:[(0,W.jsx)(J,{strong:!0,children:be(_,e.kind)}),e.status?(0,W.jsx)(M,{status:e.status,label:B(_,e.status)}):null,e.actor?(0,W.jsx)(J,{type:`tertiary`,children:e.actor}):null]}),e.evidence?(0,W.jsx)(`pre`,{className:`vulnerability-code`,children:e.evidence}):null,e.snapshot?(0,W.jsx)(a,{className:`vulnerability-snapshot`,children:(0,W.jsxs)(a.Panel,{header:_(`vulnerabilityPage.retestSnapshot`,null,`复测时的证据快照`),itemKey:`snapshot`,children:[(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailReproductionSteps`,null,`复现步骤`),content:e.snapshot.reproduction_steps}),(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailEvidence`,null,`证据 / POC`),content:e.snapshot.evidence,code:!0})]})}):null,e.conversation_id?(0,W.jsx)(c,{size:`small`,theme:`borderless`,onClick:()=>me(e.conversation_id),children:_(`vulnerabilityPage.openRetestChat`,null,`打开复测对话`)}):null]})},`${e.kind}-${e.created_at}-${t}`))}):(0,W.jsx)(Y,{type:`tertiary`,children:_(`vulnerabilityPage.noHistory`,null,`暂无结构化处置记录`)})})]}),(0,W.jsxs)(g.TabPane,{tab:_(`vulnerabilityPage.detailRelations`,null,`关联`),itemKey:`relations`,children:[(0,W.jsx)(X,{title:_(`vulnerabilityPage.detailProject`,null,`所属项目`),children:A.project_id?(0,W.jsxs)(`div`,{className:`vulnerability-related-row`,children:[(0,W.jsx)(J,{children:pe}),(0,W.jsx)(J,{type:`tertiary`,className:`vulnerability-inline-code`,children:A.project_id})]}):(0,W.jsx)(Y,{type:`tertiary`,children:_(`vulnerabilityPage.projectUnbound`,null,`未绑定项目`)})}),(0,W.jsx)(X,{title:_(`vulnerabilityPage.affectedTargets`,null,`受影响目标`),children:F.length?(0,W.jsx)(`ul`,{className:`vulnerability-related-list`,children:F.map(e=>(0,W.jsxs)(`li`,{className:`vulnerability-related-item`,children:[(0,W.jsx)(J,{strong:!0,children:e.host||e.domain||e.raw}),e.raw&&e.raw!==e.host?(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:e.raw}):null]},`${e.raw}-${e.host}`))}):(0,W.jsx)(Y,{type:`tertiary`,children:A.target||`—`})}),(0,W.jsx)(X,{title:_(`vulnerabilityPage.linkedAssets`,null,`资产库匹配`),children:fe.length?(0,W.jsx)(`ul`,{className:`vulnerability-related-list`,children:fe.map(e=>(0,W.jsxs)(`li`,{className:`vulnerability-related-item`,children:[(0,W.jsx)(J,{strong:!0,children:Oe(e)}),(0,W.jsx)(J,{type:`tertiary`,className:`vulnerability-inline-code`,children:U(e.id,12)})]},e.id||`${e.host}-${e.port}`))}):(0,W.jsx)(Y,{type:`tertiary`,children:_(`vulnerabilityPage.noLinkedAssets`,null,`未匹配到资产库记录`)})}),(0,W.jsxs)(X,{title:_(`vulnerabilityPage.detailConversationId`,null,`会话`),children:[A.conversation_id?(0,W.jsxs)(`div`,{className:`vulnerability-related-row`,children:[(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:A.conversation_id}),(0,W.jsx)(c,{size:`small`,theme:`borderless`,onClick:()=>me(A.conversation_id),children:_(`vulnerabilityPage.openConversation`,null,`查看对话`)})]}):(0,W.jsx)(Y,{type:`tertiary`,children:_(`vulnerabilityPage.standaloneRecord`,null,`独立记录(无关联会话)`)}),A.task_id||A.task_queue_id?(0,W.jsxs)(`div`,{className:`vulnerability-related-row`,children:[(0,W.jsx)(J,{type:`tertiary`,children:_(`vulnerabilityPage.detailTaskId`,null,`任务ID`)}),(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:A.task_id||A.task_queue_id})]}):null]}),A.assessment_id?(0,W.jsx)(X,{title:_(`vulnerabilityPage.assessmentTask`,null,`深度测评`),children:(0,W.jsxs)(`div`,{className:`vulnerability-related-row`,children:[(0,W.jsx)(J,{children:A.assessment_name||U(A.assessment_id,12)}),A.assessment_step_title?(0,W.jsx)(J,{type:`tertiary`,children:A.assessment_step_title}):null]})}):null,de.length?(0,W.jsx)(X,{title:A.case_title||_(`vulnerabilityPage.mergedRecord`,null,`已归并`),children:(0,W.jsx)(`div`,{className:`vulnerability-member-list`,children:de.map(e=>(0,W.jsxs)(c,{size:`small`,theme:`borderless`,disabled:e.id===A.id,onClick:()=>p(e.id),children:[e.title,` · `,B(_,e.status)]},e.id))})}):null]}),(0,W.jsx)(g.TabPane,{tab:_(`vulnerabilityDownload.title`,null,`下载报告`),itemKey:`download`,children:(0,W.jsxs)(`div`,{className:`vulnerability-download-panel`,children:[(0,W.jsx)(Y,{type:`tertiary`,children:_(`vulnerabilityDownload.hint`,null,`请选择下载格式`)}),(0,W.jsxs)(ee,{value:oe,onChange:e=>se(e.target.value),children:[(0,W.jsx)(x,{value:`docx`,children:_(`vulnerabilityDownload.word`,null,`Word(.docx)`)}),(0,W.jsx)(x,{value:`md`,children:_(`vulnerabilityDownload.markdown`,null,`Markdown(.md)`)})]}),(0,W.jsx)(c,{theme:`solid`,type:`primary`,loading:w,onClick:he,children:_(`vulnerabilityDownload.download`,null,`下载漏洞报告`)}),(0,W.jsx)(J,{type:`tertiary`,children:_(`vulnerabilityPage.downloadHint`,null,`报告由服务端按当前记录生成,包含描述、证据与修复建议。`)})]})})]})]})}var{Text:ze}=p,Be={title:``,severity:``,status:`open`,type:``,target:``,project_id:``,conversation_id:``,conversation_tag:``,task_tag:``,description:``,preconditions:``,reproduction_steps:``,evidence:``,impact:``,recommendation:``,retest_notes:``};function Ve(e){return e?{title:e.title||``,severity:e.severity||``,status:e.status||`open`,type:e.type||``,target:e.target||``,project_id:e.project_id||``,conversation_id:e.conversation_id||``,conversation_tag:e.conversation_tag||``,task_tag:e.task_tag||``,description:e.description||``,preconditions:e.preconditions||``,reproduction_steps:e.reproduction_steps||``,evidence:e.evidence||``,impact:e.impact||``,recommendation:e.recommendation||``,retest_notes:e.retest_notes||``}:{...Be}}function Q(e){return String(e??``).trim()}function He({visible:e,vulnId:t,t:n,projectOptions:r,onClose:i,onSaved:a}){let o=!!t,[s,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(!1),[d,p]=(0,P.useState)(null),[m,h]=(0,P.useState)({...Be}),[g,_]=(0,P.useState)(``);(0,P.useEffect)(()=>{if(!e)return;if(p(null),!t){_(``);return}let n=!1;return C.get(`/vulnerabilities/${encodeURIComponent(t)}`).then(e=>{n||(h(Ve(e)),_(t))}).catch(e=>{n||p(e)}),()=>{n=!0}},[e,t]);let v=!o||g===t,ee=o?m:{...Be},b=async()=>{if(!s||l)return;let e;try{e=await s.validate()}catch{return}let r={title:Q(e.title),severity:e.severity,status:e.status||`open`,type:Q(e.type),target:Q(e.target),description:e.description||``,preconditions:e.preconditions||``,reproduction_steps:e.reproduction_steps||``,evidence:e.evidence||``,impact:e.impact||``,recommendation:e.recommendation||``,retest_notes:e.retest_notes||``,project_id:Q(e.project_id),conversation_tag:Q(e.conversation_tag),task_tag:Q(e.task_tag)};o||(r.conversation_id=Q(e.conversation_id)),u(!0);try{let e=o?await C.put(`/vulnerabilities/${encodeURIComponent(t)}`,r):await C.post(`/vulnerabilities`,r);a?.(e)}catch(e){E(e,n(`vulnerabilityPage.saveFailed`,null,`保存失败`))}finally{u(!1)}};return(0,W.jsx)(D,{title:o?n(`vulnerability.editVuln`,null,`编辑漏洞`):n(`vulnerability.addVuln`,null,`添加漏洞`),visible:e,onCancel:i,onOk:b,confirmLoading:l,okText:n(`common.save`,null,`保存`),cancelText:n(`common.cancel`,null,`取消`),width:780,maskClosable:!1,children:e?d?(0,W.jsx)(ze,{type:`danger`,children:se(d,n(`vulnerabilityPage.fetchFailed`,null,`获取漏洞失败`))}):v?(0,W.jsx)(y,{initValues:ee,getFormApi:c,labelPosition:`top`,onSubmit:b,children:(0,W.jsxs)(`div`,{className:`vulnerability-form-grid`,children:[(0,W.jsx)(`div`,{className:`vulnerability-field vulnerability-field--full`,children:(0,W.jsx)(y.Input,{field:`title`,label:n(`vulnerabilityModal.title`,null,`标题`),placeholder:n(`vulnerabilityModal.titlePlaceholder`,null,`/api/login 存在 SQL 注入`),rules:[{required:!0,message:n(`vulnerabilityModal.titleRequired`,null,`请填写漏洞标题`)}],maxLength:500})}),(0,W.jsx)(`div`,{className:`vulnerability-field`,children:(0,W.jsx)(y.Select,{field:`severity`,label:n(`vulnerabilityModal.severity`,null,`严重程度`),placeholder:n(`vulnerabilityModal.pleaseSelect`,null,`请选择`),style:{width:`100%`},optionList:xe(n),rules:[{required:!0,message:n(`vulnerabilityModal.severityRequired`,null,`请选择严重程度`)}]})}),(0,W.jsx)(`div`,{className:`vulnerability-field`,children:(0,W.jsx)(y.Select,{field:`status`,label:n(`vulnerabilityModal.status`,null,`状态`),style:{width:`100%`},optionList:V(n)})}),(0,W.jsx)(`div`,{className:`vulnerability-field`,children:(0,W.jsx)(y.Input,{field:`target`,label:n(`vulnerabilityModal.target`,null,`目标`),placeholder:n(`vulnerabilityModal.targetPlaceholder`,null,`精确到 URL/IP:端口/接口路径/参数名`)})}),(0,W.jsx)(`div`,{className:`vulnerability-field`,children:(0,W.jsx)(y.Input,{field:`type`,label:n(`vulnerabilityModal.type`,null,`漏洞类型`),placeholder:n(`vulnerabilityModal.typePlaceholder`,null,`如:SQL注入、XSS、CSRF等`)})}),(0,W.jsx)(`div`,{className:`vulnerability-field`,children:(0,W.jsx)(y.Select,{field:`project_id`,label:n(`vulnerabilityModal.project`,null,`所属项目`),placeholder:n(`vulnerabilityModal.projectNone`,null,`(未绑定)`),style:{width:`100%`},filter:!0,optionList:[{value:``,label:n(`vulnerabilityModal.projectNone`,null,`(未绑定)`)},...r]})}),(0,W.jsx)(`div`,{className:`vulnerability-field`,children:(0,W.jsx)(y.Input,{field:`conversation_id`,label:n(`vulnerabilityModal.conversationId`,null,`会话ID`),placeholder:n(`vulnerabilityModal.conversationIdPlaceholder`,null,`可选:输入已有会话ID,留空可独立添加漏洞`),disabled:o})}),(0,W.jsx)(`div`,{className:`vulnerability-field`,children:(0,W.jsx)(y.Input,{field:`conversation_tag`,label:n(`vulnerabilityModal.conversationTag`,null,`对话标签`),placeholder:n(`vulnerabilityModal.conversationTagPlaceholder`,null,`如:红队演练A、客户A周报`)})}),(0,W.jsx)(`div`,{className:`vulnerability-field`,children:(0,W.jsx)(y.Input,{field:`task_tag`,label:n(`vulnerabilityModal.taskTag`,null,`任务标签`),placeholder:n(`vulnerabilityModal.taskTagPlaceholder`,null,`如:批量扫描Q2、专项复测`)})}),(0,W.jsx)(`div`,{className:`vulnerability-field vulnerability-field--full`,children:(0,W.jsx)(y.TextArea,{field:`description`,label:n(`vulnerabilityModal.description`,null,`描述`),placeholder:n(`vulnerabilityModal.descriptionPlaceholder`,null,`说明漏洞摘要、触发点、异常现象和为什么可被利用。`),autosize:{minRows:3,maxRows:8}})}),(0,W.jsx)(`div`,{className:`vulnerability-field vulnerability-field--full`,children:(0,W.jsx)(y.TextArea,{field:`preconditions`,label:n(`vulnerabilityModal.preconditions`,null,`前置条件`),placeholder:n(`vulnerabilityModal.preconditionsPlaceholder`,null,`登录状态、权限、账号、Header/Cookie、特定数据、环境/版本;无则写无。`),autosize:{minRows:2,maxRows:6}})}),(0,W.jsx)(`div`,{className:`vulnerability-field vulnerability-field--full`,children:(0,W.jsx)(y.TextArea,{field:`reproduction_steps`,label:n(`vulnerabilityModal.reproductionSteps`,null,`复现步骤`),placeholder:n(`vulnerabilityModal.reproductionStepsPlaceholder`,null,`按 1/2/3 编号,写清入口、参数、payload、执行命令、观察点。`),autosize:{minRows:3,maxRows:10}})}),(0,W.jsx)(`div`,{className:`vulnerability-field vulnerability-field--full`,children:(0,W.jsx)(y.TextArea,{field:`evidence`,label:n(`vulnerabilityModal.evidence`,null,`证据 / POC`),placeholder:n(`vulnerabilityModal.evidencePlaceholder`,null,`原始请求/响应、curl/工具命令、截图说明、日志、回连记录等。`),autosize:{minRows:3,maxRows:10}})}),(0,W.jsx)(`div`,{className:`vulnerability-field vulnerability-field--full`,children:(0,W.jsx)(y.TextArea,{field:`impact`,label:n(`vulnerabilityModal.impact`,null,`影响`),placeholder:n(`vulnerabilityModal.impactPlaceholder`,null,`结合已验证事实说明实际影响,例如越权读取哪些数据。`),autosize:{minRows:2,maxRows:6}})}),(0,W.jsx)(`div`,{className:`vulnerability-field vulnerability-field--full`,children:(0,W.jsx)(y.TextArea,{field:`recommendation`,label:n(`vulnerabilityModal.recommendation`,null,`修复建议`),placeholder:n(`vulnerabilityModal.recommendationPlaceholder`,null,`写具体修复点和复测标准。`),autosize:{minRows:2,maxRows:8}})}),(0,W.jsx)(`div`,{className:`vulnerability-field vulnerability-field--full`,children:(0,W.jsx)(y.TextArea,{field:`retest_notes`,label:n(`vulnerabilityModal.retestNotes`,null,`复测方式`),placeholder:n(`vulnerabilityModal.retestNotesPlaceholder`,null,`修复后如何验证漏洞已关闭,包括应返回的状态码、错误信息或访问控制结果。`),autosize:{minRows:2,maxRows:6}})})]})},o?`${t}-${g}`:`new`):(0,W.jsx)(`div`,{className:`vulnerability-modal-loading`,children:(0,W.jsx)(f,{size:`large`})}):null})}var{Text:Ue}=p,We={none:`viewList`,host:`viewHost`,task:`viewTask`},Ge=[];function Ke(){let e=oe(),{hasPermission:t}=ie(),[n,r]=i(),a=(0,P.useMemo)(()=>({q:n.get(`q`)||``,severity:n.get(`severity`)||``,status:n.get(`status`)||``,project_id:n.get(`project_id`)||``,conversation_tag:n.get(`conversation_tag`)||``,task_tag:n.get(`task_tag`)||``,assessment_id:n.get(`assessment_id`)||``,sort:[`severity`,`latest`,`oldest`].includes(n.get(`sort`))?n.get(`sort`):``}),[n]),o=Math.max(1,Number.parseInt(n.get(`page`)||`1`,10)||1),s=_e.includes(Number(n.get(`page_size`)))?Number(n.get(`page_size`)):20,l=(n.get(`id`)||``).trim(),u=n.get(`group_by`),d=u===`host`||u===`task`?u:``,f=d&&n.get(`selection`)||``,p=d===`task`?`task_q`:`host_q`,m=d&&n.get(p)||``,h=m?{[p]:m}:{},g=t(`vulnerability:write`),v=t(`vulnerability:delete`)||g,y=(0,P.useCallback)((e,t={})=>{r(n=>{let r=new URLSearchParams(n);return Object.entries(e).forEach(([e,t])=>{t==null||t===``?r.delete(e):r.set(e,String(t))}),t.resetPage&&r.delete(`page`),r.toString()===n.toString()?n:r},{replace:!0})},[r]),x=(0,P.useCallback)((e,t)=>{y({[e]:t},{resetPage:!0})},[y]),te=(0,P.useCallback)(()=>{let e={sort:void 0,selection:void 0,host_q:void 0,task_q:void 0};F.forEach(t=>{e[t]=void 0}),y(e,{resetPage:!0})},[y]),S=(0,P.useCallback)(e=>{y({group_by:e===`none`?void 0:e,selection:void 0,host_q:void 0,task_q:void 0},{resetPage:!0})},[y]),ne=(0,P.useCallback)(e=>{y({selection:e},{resetPage:!0})},[y]),re=(0,P.useCallback)(e=>{y({[p]:e,selection:void 0},{resetPage:!0})},[p,y]),se=(0,P.useCallback)(e=>y({id:e}),[y]),D=(0,P.useCallback)(()=>y({id:void 0}),[y]),le={...Ce(a),...h,...d?{group_by:d,pagination:`records`,selection:f}:{},...a.sort?{sort:a.sort}:{},summary:`true`,page:o,limit:s},O=JSON.stringify(le),k=T(async()=>({...await C.get(`/vulnerabilities`,le)||{},__requestKey:O,__groupView:d}),[O]),j=k.data?.__requestKey===O?k.data:null,de=k.data?.__groupView===d&&k.data?.navigation||Ge,pe=j?.selection?de.flatMap(e=>[e,...e.children||[]]).find(e=>e.key===j.selection):null,M=(0,P.useMemo)(()=>we(a),[a]),ge=JSON.stringify(M),I=T(()=>C.get(`/vulnerabilities/stats`,M),[ge]),[ve,L]=(0,P.useState)(0),R=T(()=>C.get(`/vulnerabilities/filter-options`),[ve]),z=T(async()=>{try{let e=await C.get(`/projects`,{limit:500});return Array.isArray(e?.projects)?e.projects:[]}catch{return[]}},[]),B=(0,P.useMemo)(()=>{let e={};return(z.data||[]).forEach(t=>{t?.id&&(e[t.id]=t.name||t.id)}),e},[z.data]),be=(0,P.useMemo)(()=>{let e=new Map;return(R.data?.project_ids||[]).forEach(t=>{t&&e.set(t,B[t]||t)}),a.project_id&&!e.has(a.project_id)&&e.set(a.project_id,B[a.project_id]||a.project_id),[...e.entries()].map(([e,t])=>({value:e,label:t}))},[R.data,B,a.project_id]),xe=(0,P.useMemo)(()=>{let e=new Map;return(z.data||[]).forEach(t=>{t?.id&&e.set(t.id,t.name||t.id)}),[...e.entries()].map(([e,t])=>({value:e,label:t}))},[z.data]),[V,Se]=(0,P.useState)([]),[De,H]=(0,P.useState)({visible:!1,id:``}),[Oe,U]=(0,P.useState)(0),[G,je]=(0,P.useState)(!1);(0,P.useEffect)(()=>{Se([])},[O]),(0,P.useEffect)(()=>{if(!j)return;let e={},t=Number(j.page);t&&t!==o&&(e.page=t),f&&!j.selection&&(e.selection=void 0),Object.keys(e).length&&y(e)},[j,f,o,y]);let K=k.reload,q=I.reload,Me=R.reload,Fe=(0,P.useCallback)(()=>{K(),q(),Me({silent:!0})},[K,q,Me]),Ie=(0,P.useCallback)(e=>{H({visible:!0,id:e?.id||``})},[]),J=(0,P.useCallback)(()=>{H({visible:!1,id:``}),N(e(`vulnerabilityPage.saveSuccess`,null,`已保存`)),U(e=>e+1),L(e=>e+1),K({silent:!0}),q({silent:!0})},[K,q,e]),Y=(0,P.useCallback)(t=>{t?.id&&me({title:e(`vulnerabilityPage.deleteTitle`,null,`删除漏洞`),content:`${e(`vulnerability.deleteConfirm`,null,`确定要删除此漏洞吗?`)}${t.title?` ${t.title}`:``}`,okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{await C.del(`/vulnerabilities/${encodeURIComponent(t.id)}`),N(e(`vulnerabilityPage.deleteSuccess`,null,`已删除`)),l===t.id&&D(),U(e=>e+1),L(e=>e+1),await Promise.all([K({silent:!0}),q({silent:!0})])}catch(t){E(t,e(`vulnerabilityPage.deleteFailed`,null,`删除失败`))}}})},[l,D,K,q,e]),X=(0,P.useCallback)(()=>{if(!V.length)return;let t=[...V];me({title:e(`vulnerabilityPage.batchDelete`,null,`批量删除`),content:e(`vulnerabilityPage.batchDeleteConfirm`,{count:t.length},`确定要删除选中的 ${t.length} 条漏洞吗?此操作不可恢复。`),okText:e(`common.delete`,null,`删除`),onOk:async()=>{let n=0,r=0;for(let e of t)try{await C.del(`/vulnerabilities/${encodeURIComponent(e)}`),n+=1}catch{r+=1}r?w(e(`vulnerabilityPage.batchDeletePartial`,{deleted:n,failed:r},`已删除 ${n} 条,${r} 条失败`)):N(e(`vulnerabilityPage.batchDeleteSuccess`,{count:n},`成功删除 ${n} 条漏洞`)),Se([]),t.includes(l)&&D(),U(e=>e+1),L(e=>e+1),await Promise.all([K({silent:!0}),q({silent:!0})])}})},[V,l,D,K,q,e]),Z=(0,P.useCallback)(async()=>{let t=Ce(a);try{let n=await C.get(`/vulnerabilities`,{...t,page:1,limit:1}),r=Number(n?.total)||0;if(!r){w(e(`vulnerabilityPage.batchDeleteNoResults`,null,`当前筛选条件下没有可删除的漏洞`));return}me({title:e(`vulnerabilityPage.deleteFilteredTitle`,null,`删除当前筛选结果`),content:e(`vulnerabilityPage.batchDeleteConfirm`,{count:r},`确定要删除当前筛选条件下的 ${r} 条漏洞吗?此操作不可恢复。`),okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{let n=await C.del(`/vulnerabilities/batch`,{query:t}),i=Number(n?.deleted)||r;N(e(`vulnerabilityPage.batchDeleteSuccess`,{count:i},`成功删除 ${i} 条漏洞`)),Se([]),U(e=>e+1),L(e=>e+1),await Promise.all([K({silent:!0}),q({silent:!0})])}catch(t){E(t,e(`vulnerabilityPage.batchDeleteFailed`,null,`批量删除失败`))}}})}catch(t){E(t,e(`vulnerabilityPage.fetchFailed`,null,`获取漏洞失败`))}},[a,K,q,e]),ze=(0,P.useCallback)(async()=>{if(!G){je(!0);try{let t=await C.get(`/vulnerabilities/export`,{...Ce(a),...h,mode:`summary`,group_by:`conversation`}),n=Array.isArray(t?.files)?t.files:[];if(!n.length){w(e(`vulnerabilityPage.exportNoResults`,null,`当前筛选条件下无可导出漏洞`));return}n.forEach((e,t)=>{setTimeout(()=>ke(e.filename||`vulnerability-export-${t+1}.md`,e.content||``),t*120)}),N(n.length>1?e(`vulnerabilityPage.exportStarted`,{count:n.length},`已开始下载 ${n.length} 份报告`):e(`vulnerabilityPage.exportSuccess`,null,`报告已开始下载`))}catch(t){E(t,e(`vulnerabilityPage.exportFailed`,null,`导出失败`))}finally{je(!1)}}},[G,a,h,e]),Be=(0,P.useCallback)(async t=>{try{let n=await ae(`/vulnerabilities/${encodeURIComponent(t.id)}/download`,{query:{format:`docx`}});N(`${e(`vulnerabilityPage.downloadOkTitle`,null,`下载成功`)}${n?` · ${n}`:``}`)}catch(t){E(t,e(`vulnerabilityPage.downloadFailed`,null,`下载失败`))}},[e]),Ve=(0,P.useCallback)(e=>{y({page:String(e)})},[y]),Q=(0,P.useCallback)(e=>{if(!e||e===s)return;let t=Math.max(1,Math.floor((o-1)*s/e)+1);y({page_size:String(e),page:String(t)})},[o,s,y]),Ke=I.data||{},qe=Ke.by_severity||{},Je=Number(Ke.total)||0,Ye=Number(Ke.distinct)||0,Xe=(0,P.useMemo)(()=>[{id:`total`,label:e(`vulnerabilityPage.statTotal`,null,`总漏洞数`),value:Je,detail:Ye&&Ye!==Je?e(`vulnerabilityPage.distinctCount`,{count:Ye},`${Ye} 个独立漏洞`):void 0,loading:I.loading,onClick:()=>x(`severity`,``)},...he.map(t=>{let n=Number(qe[t])||0,r=Ee(n,Je),i=a.severity===t;return{id:t,label:ye(e,t),value:n,severity:t,pressed:i,detail:i?`${e(`vulnerabilityPage.filterActive`,null,`已筛选`)} · ${r}%`:`${r}%`,loading:I.loading,onClick:()=>x(`severity`,i?``:t)}})],[e,Je,Ye,qe,I.loading,a.severity,x]),$=Number(j?.total)||0,Ze=$?(o-1)*s+1:0,Qe=$?Math.min(o*s,$):0,$e=$?e(`vulnerabilityPage.recordPagination`,{start:Ze,end:Qe,total:$},`显示 ${Ze}–${Qe} / 共 ${$} 条漏洞`):e(`vulnerabilityPage.noRecords`,null,`暂无漏洞记录`),et=k.error||I.error||R.error,tt=(0,W.jsxs)(`div`,{className:`vulnerability-toolbar-left`,children:[(0,W.jsx)(Ue,{type:`tertiary`,children:j&&V.length?e(`vulnerabilityPage.selectedCount`,{count:V.length},`已选 ${V.length} 项`):$e}),v&&(0,W.jsx)(c,{size:`small`,type:`danger`,theme:`light`,disabled:!j||!V.length,onClick:X,children:e(`vulnerabilityPage.batchDelete`,null,`批量删除`)}),v&&!f&&!m&&Te(a)&&(0,W.jsx)(c,{size:`small`,type:`danger`,theme:`borderless`,onClick:Z,children:e(`vulnerabilityPage.deleteFiltered`,null,`删除筛选结果`)})]});return(0,W.jsxs)(`div`,{className:`vulnerability-page`,children:[(0,W.jsx)(fe,{title:e(`vulnerability.title`,null,`漏洞管理`),description:e(`vulnerabilityPage.workspaceSubtitle`,null,`资产、上报与处置进展`),extra:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(c,{icon:(0,W.jsx)(b,{}),onClick:Fe,loading:k.loading,children:e(`common.refresh`,null,`刷新`)}),(0,W.jsx)(c,{onClick:ze,loading:G,children:e(f?`vulnerabilityPage.exportAllGroups`:`vulnerabilityPage.batchExport`)}),g&&(0,W.jsx)(c,{theme:`solid`,type:`primary`,icon:(0,W.jsx)(_,{}),onClick:()=>Ie(null),children:e(`vulnerability.addVuln`,null,`添加漏洞`)})]})}),(0,W.jsx)(ce,{metrics:Xe,columns:6}),(0,W.jsx)(ue,{error:et,onRetry:Fe}),(0,W.jsxs)(A,{className:`vulnerability-list-card`,title:e(`vulnerabilityPage.listTitle`,null,`漏洞记录`),extra:(0,W.jsx)(ee,{"aria-label":e(`vulnerabilityPage.viewLabel`),type:`button`,value:d||`none`,options:Object.entries(We).map(([t,n])=>({value:t,label:e(`vulnerabilityPage.${n}`)})),onChange:e=>S(e.target.value)}),children:[(0,W.jsx)(Ae,{t:e,filters:a,options:R.data,projectOptions:be,hasGroupFilters:!!(f||m),onChange:x,onReset:te}),(0,W.jsxs)(`div`,{className:d?`vulnerability-group-layout`:void 0,children:[d&&(0,W.jsx)(Ne,{t:e,mode:d,groups:de,selection:f,search:m,loading:k.loading,onSearch:re,onSelect:ne},d),(0,W.jsxs)(`div`,{className:`vulnerability-group-results`,children:[pe&&(0,W.jsx)(Pe,{t:e,group:pe}),(0,W.jsx)(Le,{t:e,data:j?.vulnerabilities,loading:k.loading,page:o,pageSize:s,total:$,selection:j?V:[],onSelectionChange:Se,onOpen:se,onEdit:Ie,onDelete:Y,onDownload:Be,sort:a.sort,onSort:e=>x(`sort`,e),canWrite:g,canDelete:v,onPageChange:Ve,onPageSizeChange:Q,toolbar:tt,onRefresh:Fe})]})]})]}),(0,W.jsx)(Re,{visible:!!l,vulnId:l,refreshKey:Oe,onClose:D,onOpenVuln:se,onEdit:Ie,onDelete:Y,canWrite:g,canDelete:v,t:e,projectNames:B}),(0,W.jsx)(He,{visible:De.visible,vulnId:De.id,t:e,projectOptions:xe,onClose:()=>H({visible:!1,id:``}),onSaved:J})]})}export{Ke as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,y as i}from"./react-QV7DAAIx.js";import{A as a,F as o,H as s,L as c,M as l,St as u,Tt as d,U as f,W as p,a as m,at as h,c as g,ct as _,f as v,i as y,m as ee,ot as b,p as x,s as te,v as S}from"./semi-CXF9U6uC.js";import{C as ne,E as re,F as ie,I as C,L as ae,P as oe,R as se,S as w,_ as ce,a as T,b as E,c as D,d as le,f as O,h as k,l as ue,m as A,n as j,o as de,p as fe,s as pe,v as M,x as N,y as me}from"./index-LQJrYSgy.js";var P=e(t(),1),he=[`critical`,`high`,`medium`,`low`,`info`],ge=[`open`,`confirmed`,`fixed`,`ignored`,`false_positive`],F=[`q`,`severity`,`status`,`project_id`,`conversation_tag`,`task_tag`,`assessment_id`],_e=[10,20,50,100],I={critical:`dashboard.severityCritical`,high:`dashboard.severityHigh`,medium:`dashboard.severityMedium`,low:`dashboard.severityLow`,info:`dashboard.severityInfo`},ve={open:`vulnerabilityPage.statusOpen`,confirmed:`vulnerabilityPage.statusConfirmed`,fixed:`vulnerabilityPage.statusFixed`,ignored:`vulnerabilityPage.statusIgnored`,false_positive:`vulnerabilityPage.statusFalsePositive`},L={open:`待处理`,confirmed:`已确认`,fixed:`已修复`,ignored:`已忽略`,false_positive:`误报`},R={retest:`复测结果`,retest_started:`复测分支已创建`,merge:`归并上报`,split:`拆分归并组`,detach:`解除关联`},z=[{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=I[t];return n?e(n,null,ne[t]||t):String(t)}function B(e,t){if(!t)return`—`;let n=ve[t];return n?e(n,null,L[t]||t):String(t)}function be(e,t){return t?e(`vulnerabilityPage.history_${t}`,null,R[t]||t):`—`}function xe(e){return he.map(t=>({value:t,label:ye(e,t)}))}function V(e){return ge.map(t=>({value:t,label:B(e,t)}))}function Se(e){return z.map(t=>({value:t.value,label:e(t.key,null,t.fallback)}))}function Ce(e){let t={};return F.forEach(n=>{let r=String(e?.[n]??``).trim();r&&(t[n]=r)}),t}function we(e){let t=Ce(e);return delete t.severity,t}function Te(e){return F.some(t=>String(e?.[t]??``).trim()!==``)}function Ee(e,t){let n=Number(e)||0,r=Number(t)||0;return r>0?Math.round(n/r*100):0}function De(e){return String(e?.target||``).trim()}function H(e){return(Array.isArray(e?.targets)?e.targets:[]).map(e=>e?.host).find(Boolean)||e?.target_host||e?.target_domain||``}function Oe(e){if(!e)return`—`;let t=e.host||e.id||`—`;return e.port?`${t}:${e.port}`:t}function U(e,t=8){let n=String(e||``);return n.length>t?`${n.slice(0,t)}…`:n}function ke(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 W=e(r(),1);function G(e,t){return[{value:``,label:e},...t]}function Ae({t:e,filters:t,options:n,projectOptions:r,hasGroupFilters:i,onChange:a,onReset:o}){let[l,u]=(0,P.useState)(t.q),d=j(l,380),f=(0,P.useRef)(t.q);(0,P.useEffect)(()=>{d!==f.current&&(f.current=d,a(`q`,d))},[d,a]),(0,P.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:[],g=Array.isArray(n?.assessment_ids)?n.assessment_ids:[];return(0,W.jsxs)(`div`,{className:`vulnerability-filter-bar`,children:[(0,W.jsx)(s,{className:`vulnerability-filter-search`,prefix:(0,W.jsx)(h,{}),value:l,showClear:!0,placeholder:e(`vulnerabilityPage.searchKeyword`,null,`搜索标题、描述、类型、目标…`),"aria-label":e(`vulnerabilityPage.searchKeyword`,null,`搜索标题、描述、类型、目标…`),onChange:e=>u(e)}),(0,W.jsx)(S,{className:`vulnerability-filter-select`,value:t.severity,placeholder:e(`vulnerabilityPage.severity`,null,`严重程度`),optionList:G(e(`vulnerabilityPage.allSeverities`,null,`全部级别`),xe(e)),onChange:e=>a(`severity`,e||``)}),(0,W.jsx)(S,{className:`vulnerability-filter-select`,value:t.status,placeholder:e(`vulnerabilityPage.status`,null,`状态`),optionList:G(e(`dashboard.allStatuses`,null,`全部状态`),V(e)),onChange:e=>a(`status`,e||``)}),(0,W.jsx)(S,{className:`vulnerability-filter-select vulnerability-filter-select--wide`,value:t.project_id,placeholder:e(`vulnerabilityPage.detailProject`,null,`所属项目`),filter:!0,optionList:G(e(`vulnerabilityPage.allProjects`,null,`全部项目`),r),onChange:e=>a(`project_id`,e||``)}),(0,W.jsx)(S,{className:`vulnerability-filter-select`,value:t.conversation_tag,placeholder:e(`vulnerabilityPage.conversationTag`,null,`来源(对话标签)`),filter:!0,optionList:G(e(`vulnerabilityPage.allSources`,null,`全部来源`),p.map(e=>({value:e,label:e}))),onChange:e=>a(`conversation_tag`,e||``)}),(0,W.jsx)(S,{className:`vulnerability-filter-select`,value:t.task_tag,placeholder:e(`vulnerabilityPage.taskTag`,null,`任务标签`),filter:!0,optionList:G(e(`vulnerabilityPage.allTaskTags`,null,`全部任务标签`),m.map(e=>({value:e,label:e}))),onChange:e=>a(`task_tag`,e||``)}),(0,W.jsx)(S,{className:`vulnerability-filter-select`,value:t.assessment_id,placeholder:e(`vulnerabilityPage.assessmentTask`,null,`深度测评`),filter:!0,optionList:G(e(`vulnerabilityPage.allAssessments`,null,`全部测评`),g.map(e=>({value:e,label:U(e,12)}))),onChange:e=>a(`assessment_id`,e||``)}),(0,W.jsx)(`div`,{className:`vulnerability-filter-actions`,children:(0,W.jsx)(c,{icon:(0,W.jsx)(b,{}),theme:`borderless`,disabled:!Te(t)&&!t.sort&&!i,onClick:o,children:e(`vulnerabilityPage.clearAll`,null,`重置全部`)})})]})}var{Text:je}=p,K={critical:`red`,high:`orange`,medium:`amber`,low:`blue`,info:`grey`};function q(e,t){return t.key.startsWith(`task:`)?e(`vulnerabilityPage.viewTaskGroup`,{id:t.label||t.key.slice(5)}):t.label?t.label:t.key.startsWith(`host:`)?e(`vulnerabilityPage.unknownHost`):t.key.startsWith(`queue:`)?e(`vulnerabilityPage.taskQueueGroup`,{id:t.key.slice(6)}):t.key.startsWith(`assessment:`)?t.key.slice(11):e(`vulnerabilityPage.viewNoTask`)}function Me(e,t){let n=q(e,t);return{key:t.key,value:t.key,label:(0,W.jsxs)(`span`,{className:`vulnerability-group-node`,children:[(0,W.jsx)(`span`,{className:`vulnerability-group-name`,title:n,children:n}),(0,W.jsx)(l,{size:`small`,color:`grey`,children:t.count})]}),children:t.children?.map(t=>Me(e,t))}}function Ne({t:e,mode:t,groups:n,selection:r,loading:i,search:a,onSearch:o,onSelect:c}){let[l,u]=(0,P.useState)(a),d=t===`task`,p=e(d?`vulnerabilityPage.viewTask`:`vulnerabilityPage.viewHost`),g=e(d?`vulnerabilityPage.taskSearch`:`vulnerabilityPage.hostSearch`),{treeData:_,expandedKeys:v}=(0,P.useMemo)(()=>({treeData:[{key:`all`,value:`all`,label:e(d?`vulnerabilityPage.allTasks`:`vulnerabilityPage.allHosts`)},...n.map(t=>Me(e,t))],expandedKeys:n.filter(e=>e.children?.length).map(e=>e.key)}),[e,n,d]);return(0,P.useEffect)(()=>u(a),[a]),(0,P.useEffect)(()=>{if(l.trim()===a)return;let e=setTimeout(()=>o(l.trim()),350);return()=>clearTimeout(e)},[l,a,o]),(0,W.jsxs)(`aside`,{className:`vulnerability-group-sidebar`,"aria-label":p,children:[(0,W.jsx)(je,{strong:!0,children:p}),(0,W.jsx)(s,{prefix:(0,W.jsx)(h,{}),"aria-label":g,placeholder:g,value:l,showClear:!0,onChange:u}),(0,W.jsxs)(f,{spinning:i,wrapperClassName:`vulnerability-group-scroll`,children:[(0,W.jsx)(m,{"aria-label":p,treeData:_,value:r||`all`,onSelect:e=>c(e===`all`?``:e),expandedKeys:v,expandIcon:()=>(0,W.jsx)(`span`,{className:`semi-tree-empty-icon`,"aria-hidden":`true`}),expandAction:!1,blockNode:!0}),!n.length&&!i&&(0,W.jsx)(je,{className:`vulnerability-group-empty`,type:`tertiary`,size:`small`,children:e(`vulnerabilityPage.noMatchingGroups`)})]})]})}function Pe({t:e,group:t}){return(0,W.jsxs)(`div`,{className:`vulnerability-group-overview`,children:[(0,W.jsx)(je,{strong:!0,className:`vulnerability-group-name`,children:q(e,t)}),(0,W.jsxs)(`div`,{className:`vulnerability-group-badges`,children:[he.filter(e=>t.severities?.[e]).map(n=>(0,W.jsxs)(l,{color:K[n],children:[ye(e,n),` `,t.severities[n]]},n)),(0,W.jsx)(l,{color:`grey`,children:e(`vulnerabilityPage.groupPending`,{count:t.pending})})]})]})}var{Text:Fe}=p;function Ie({record:e}){let t=[e.conversation_tag,e.task_tag].filter(Boolean);return t.length?(0,W.jsx)(`span`,{className:`vulnerability-source-tags`,children:t.map(e=>(0,W.jsx)(l,{size:`small`,color:`blue`,type:`light`,children:e},e))}):e.conversation_id?(0,W.jsx)(Fe,{type:`tertiary`,className:`vulnerability-inline-code`,title:e.conversation_id,children:U(e.conversation_id,10)}):(0,W.jsx)(Fe,{type:`tertiary`,children:`—`})}function Le({t:e,data:t,loading:n,page:r,pageSize:i,total:a,selection:o,onSelectionChange:s,onOpen:l,onEdit:u,onDelete:d,onDownload:f,sort:p,onSort:m,canWrite:h,canDelete:g,onPageChange:_,onPageSizeChange:v,toolbar:y,onRefresh:ee}){let b=[{title:e(`vulnerabilityPage.tableTitle`,null,`漏洞名称`),dataIndex:`title`,render:(t,n)=>(0,W.jsxs)(`div`,{className:`vulnerability-title-cell`,children:[(0,W.jsx)(`span`,{className:`vulnerability-title-text`,title:n.title,children:n.title||`—`}),(0,W.jsxs)(`span`,{className:`vulnerability-title-meta`,children:[n.type||`—`,n.case_id?` · ${e(`vulnerabilityPage.mergedRecord`,null,`已归并`)}`:``,n.assessment_id?` · ${e(`vulnerabilityPage.assessmentTask`,null,`深度测评`)}`:``]})]})},{title:e(`vulnerabilityPage.tableSeverity`,null,`严重度`),dataIndex:`severity`,width:92,render:e=>(0,W.jsx)(k,{severity:e})},{title:e(`vulnerabilityPage.tableStatus`,null,`状态`),dataIndex:`status`,width:100,render:t=>(0,W.jsx)(M,{status:t,label:B(e,t)})},{title:e(`vulnerabilityPage.detailTarget`,null,`目标 / 宿主`),dataIndex:`target`,width:220,render:(e,t)=>{let n=De(t),r=Array.isArray(t.targets)&&t.targets.length?t.targets.map(e=>e?.host).filter(Boolean).join(`, `):``;return(0,W.jsxs)(`div`,{className:`vulnerability-target-cell`,children:[(0,W.jsx)(`span`,{className:`vulnerability-target-text`,title:n||r,children:n||r||`—`}),n&&r&&r!==n?(0,W.jsx)(`span`,{className:`vulnerability-target-host`,title:r,children:r}):null]})}},{title:e(`vulnerabilityPage.tableSource`,null,`来源`),dataIndex:`conversation_tag`,width:170,render:(e,t)=>(0,W.jsx)(Ie,{record:t})},{title:e(`vulnerabilityPage.tableDate`,null,`创建时间`),dataIndex:`created_at`,width:180,render:e=>(0,W.jsx)(`span`,{className:`vulnerability-time`,children:re(e)})},{title:e(`vulnerabilityPage.tableActions`,null,`操作`),dataIndex:`id`,width:200,render:(t,n)=>(0,W.jsxs)(`div`,{className:`vulnerability-row-actions`,children:[(0,W.jsx)(c,{size:`small`,theme:`borderless`,onClick:e=>{e.stopPropagation(),l(n.id)},children:e(`vulnerabilityPage.rowView`,null,`详情`)}),(0,W.jsx)(c,{size:`small`,theme:`borderless`,onClick:e=>{e.stopPropagation(),f(n)},children:e(`vulnerabilityPage.tableDownload`,null,`下载`)}),h&&(0,W.jsx)(c,{size:`small`,theme:`borderless`,onClick:e=>{e.stopPropagation(),u(n)},children:e(`common.edit`,null,`编辑`)}),g&&(0,W.jsx)(c,{size:`small`,theme:`borderless`,type:`danger`,onClick:e=>{e.stopPropagation(),d(n)},children:e(`common.delete`,null,`删除`)})]})}],x=y?(0,W.jsxs)(`div`,{className:`vulnerability-table-toolbar`,children:[y,(0,W.jsx)(S,{className:`vulnerability-sort-select`,size:`small`,value:p,optionList:Se(e),onChange:e=>m(e||``)})]}):null;return(0,W.jsx)(pe,{columns:b,dataSource:Array.isArray(t)?t:[],loading:n,rowKey:`id`,toolbar:x,onRefresh:ee,emptyText:e(`vulnerabilityPage.noRecords`,null,`暂无漏洞记录`),scroll:{x:1200},rowSelection:g?{selectedRowKeys:o,onChange:e=>s(Array.isArray(e)?e:[])}:void 0,onRow:e=>({onClick:t=>{t.target?.closest?.(`button, a, input, label, .semi-checkbox`)||l(e.id)}}),pagination:{currentPage:r,pageSize:i,total:Number(a)||0,showSizeChanger:!0,pageSizeOpts:_e,onPageChange:e=>_(Number(e)),onPageSizeChange:e=>v(Number(e))}})}var{Text:J,Paragraph:Y}=p;function X({title:e,extra:t,children:n}){return(0,W.jsxs)(`section`,{className:`vulnerability-section`,children:[(0,W.jsxs)(`div`,{className:`vulnerability-section-head`,children:[(0,W.jsx)(`span`,{className:`vulnerability-section-title`,children:e}),t]}),(0,W.jsx)(`div`,{className:`vulnerability-section-body`,children:n})]})}function Z({title:e,content:t,code:n}){let r=String(t??``).trim();return r?n?(0,W.jsx)(X,{title:e,extra:(0,W.jsx)(de,{text:r,size:`small`}),children:(0,W.jsx)(`pre`,{className:`vulnerability-code`,children:r})}):(0,W.jsx)(X,{title:e,children:(0,W.jsx)(O,{content:r})}):null}function Re({visible:e,vulnId:t,refreshKey:r,onClose:i,onEdit:s,onDelete:l,onOpenVuln:p,canWrite:m,canDelete:h,t:_,projectNames:y}){let S=n(),[ne,ie]=(0,P.useState)(`overview`),[oe,se]=(0,P.useState)(`docx`),[w,ce]=(0,P.useState)(!1),D=T(()=>C.get(`/vulnerabilities/${encodeURIComponent(t)}/context`),[t,r,e],{skip:!e||!t});(0,P.useEffect)(()=>{ie(`overview`),se(`docx`)},[t]);let O=D.data?.vulnerability?.id===t?D.data:null,A=O?.vulnerability||null,j=Array.isArray(O?.history)?O.history:[],de=Array.isArray(O?.members)?O.members:[],fe=Array.isArray(O?.assets)?O.assets:[],pe=A?.project_id?y?.[A.project_id]||A.project_id:``,me=e=>{e&&S(`/chat?conversation=${encodeURIComponent(e)}`)},he=async()=>{if(A&&!w){ce(!0);try{let e=await ae(`/vulnerabilities/${encodeURIComponent(A.id)}/download`,{query:{format:oe}});N(`${_(`vulnerabilityPage.downloadOkTitle`,null,`下载成功`)}${e?` · ${e}`:``}`)}catch(e){E(e,_(`vulnerabilityPage.downloadFailed`,null,`下载失败`))}finally{ce(!1)}}},ge=A?[{label:_(`vulnerabilityPage.detailVulnId`,null,`漏洞ID`),value:(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:A.id})},{label:_(`vulnerabilityPage.tableSeverity`,null,`严重度`),value:(0,W.jsx)(k,{severity:A.severity})},{label:_(`vulnerabilityPage.status`,null,`状态`),value:(0,W.jsx)(M,{status:A.status,label:B(_,A.status)})},A.type?{label:_(`vulnerabilityPage.detailType`,null,`类型`),value:A.type}:null,A.target?{label:_(`vulnerabilityPage.detailTarget`,null,`目标`),value:(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:A.target})}:null,H(A)&&H(A)!==A.target?{label:_(`vulnerabilityPage.detailHost`,null,`宿主`),value:(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:H(A)})}:null,{label:_(`vulnerabilityPage.detailProject`,null,`所属项目`),value:pe||_(`vulnerabilityPage.projectUnbound`,null,`未绑定项目`)},A.conversation_tag?{label:_(`vulnerabilityPage.detailConversationTag`,null,`对话标签`),value:A.conversation_tag}:null,A.conversation_id?{label:_(`vulnerabilityPage.detailConversationId`,null,`会话ID`),value:(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:A.conversation_id})}:null,A.task_tag?{label:_(`vulnerabilityPage.detailTaskTag`,null,`任务标签`),value:A.task_tag}:null,A.task_id?{label:_(`vulnerabilityPage.detailTaskId`,null,`任务ID`),value:(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:A.task_id})}:null,A.task_queue_id?{label:_(`vulnerabilityPage.detailTaskQueueId`,null,`任务队列ID`),value:(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:A.task_queue_id})}:null,A.case_id?{label:_(`vulnerabilityPage.mergedRecord`,null,`已归并`),value:A.case_title||U(A.case_id,12)}:null,A.assessment_id?{label:_(`vulnerabilityPage.assessmentTask`,null,`深度测评`),value:A.assessment_name||U(A.assessment_id,12)}:null,{label:_(`vulnerabilityMd.labelCreated`,null,`创建时间`),value:re(A.created_at)},{label:_(`vulnerabilityMd.labelUpdated`,null,`更新时间`),value:re(A.updated_at)}].filter(Boolean):[],F=Array.isArray(A?.targets)?A.targets:[];return(0,W.jsxs)(v,{className:`vulnerability-detail-drawer`,visible:e,onCancel:i,width:720,title:(0,W.jsxs)(`div`,{className:`vulnerability-drawer-title`,children:[(0,W.jsx)(`span`,{className:`vulnerability-drawer-title-text`,title:A?.title,children:A?.title||_(`vulnerabilityPage.inspectorTitle`,null,`漏洞工作台`)}),A&&(0,W.jsxs)(`span`,{className:`vulnerability-drawer-meta`,children:[(0,W.jsx)(k,{severity:A.severity}),(0,W.jsx)(M,{status:A.status,label:B(_,A.status)}),A.type?(0,W.jsx)(J,{type:`tertiary`,children:A.type}):null]})]}),footer:(0,W.jsxs)(o,{children:[(0,W.jsx)(c,{onClick:i,children:_(`common.close`,null,`关闭`)}),(0,W.jsx)(c,{icon:(0,W.jsx)(b,{}),onClick:()=>D.reload(),loading:D.loading,children:_(`common.refresh`,null,`刷新`)}),m&&(0,W.jsx)(c,{icon:(0,W.jsx)(u,{}),disabled:!A,onClick:()=>s(A),children:_(`common.edit`,null,`编辑`)}),h&&(0,W.jsx)(c,{type:`danger`,icon:(0,W.jsx)(d,{}),disabled:!A,onClick:()=>l(A),children:_(`common.delete`,null,`删除`)})]}),children:[(0,W.jsx)(ue,{error:D.error,onRetry:D.reload}),!D.error&&!A&&(0,W.jsx)(`div`,{className:`vulnerability-drawer-loading`,children:(0,W.jsx)(f,{size:`large`})}),A&&(0,W.jsxs)(g,{type:`line`,activeKey:ne,onChange:e=>ie(e),children:[(0,W.jsxs)(g.TabPane,{tab:_(`vulnerabilityPage.inspector_overview`,null,`概览`),itemKey:`overview`,children:[(0,W.jsx)(le,{items:ge,columns:2}),(0,W.jsx)(Z,{title:_(`vulnerabilityMd.headingDescription`,null,`描述`),content:A.description}),(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailImpact`,null,`影响`),content:A.impact}),(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailRecommendation`,null,`修复建议`),content:A.recommendation})]}),(0,W.jsxs)(g.TabPane,{tab:_(`vulnerabilityPage.inspector_evidence`,null,`复现与证据`),itemKey:`evidence`,children:[(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailPreconditions`,null,`前置条件`),content:A.preconditions}),(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailReproductionSteps`,null,`复现步骤`),content:A.reproduction_steps}),(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailEvidence`,null,`证据 / POC`),content:A.evidence,code:!0}),(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailRetestNotes`,null,`复测方式`),content:A.retest_notes}),(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailRetestLog`,null,`复测记录`),content:A.retest_log,code:!0}),(0,W.jsx)(X,{title:_(`vulnerabilityPage.inspector_history`,null,`处置历史`),children:j.length?(0,W.jsx)(te,{children:j.map((e,t)=>(0,W.jsx)(te.Item,{time:re(e.created_at),type:e.kind===`retest`?`success`:`default`,children:(0,W.jsxs)(`div`,{className:`vulnerability-history-item`,children:[(0,W.jsxs)(`div`,{className:`vulnerability-history-head`,children:[(0,W.jsx)(J,{strong:!0,children:be(_,e.kind)}),e.status?(0,W.jsx)(M,{status:e.status,label:B(_,e.status)}):null,e.actor?(0,W.jsx)(J,{type:`tertiary`,children:e.actor}):null]}),e.evidence?(0,W.jsx)(`pre`,{className:`vulnerability-code`,children:e.evidence}):null,e.snapshot?(0,W.jsx)(a,{className:`vulnerability-snapshot`,children:(0,W.jsxs)(a.Panel,{header:_(`vulnerabilityPage.retestSnapshot`,null,`复测时的证据快照`),itemKey:`snapshot`,children:[(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailReproductionSteps`,null,`复现步骤`),content:e.snapshot.reproduction_steps}),(0,W.jsx)(Z,{title:_(`vulnerabilityPage.detailEvidence`,null,`证据 / POC`),content:e.snapshot.evidence,code:!0})]})}):null,e.conversation_id?(0,W.jsx)(c,{size:`small`,theme:`borderless`,onClick:()=>me(e.conversation_id),children:_(`vulnerabilityPage.openRetestChat`,null,`打开复测对话`)}):null]})},`${e.kind}-${e.created_at}-${t}`))}):(0,W.jsx)(Y,{type:`tertiary`,children:_(`vulnerabilityPage.noHistory`,null,`暂无结构化处置记录`)})})]}),(0,W.jsxs)(g.TabPane,{tab:_(`vulnerabilityPage.detailRelations`,null,`关联`),itemKey:`relations`,children:[(0,W.jsx)(X,{title:_(`vulnerabilityPage.detailProject`,null,`所属项目`),children:A.project_id?(0,W.jsxs)(`div`,{className:`vulnerability-related-row`,children:[(0,W.jsx)(J,{children:pe}),(0,W.jsx)(J,{type:`tertiary`,className:`vulnerability-inline-code`,children:A.project_id})]}):(0,W.jsx)(Y,{type:`tertiary`,children:_(`vulnerabilityPage.projectUnbound`,null,`未绑定项目`)})}),(0,W.jsx)(X,{title:_(`vulnerabilityPage.affectedTargets`,null,`受影响目标`),children:F.length?(0,W.jsx)(`ul`,{className:`vulnerability-related-list`,children:F.map(e=>(0,W.jsxs)(`li`,{className:`vulnerability-related-item`,children:[(0,W.jsx)(J,{strong:!0,children:e.host||e.domain||e.raw}),e.raw&&e.raw!==e.host?(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:e.raw}):null]},`${e.raw}-${e.host}`))}):(0,W.jsx)(Y,{type:`tertiary`,children:A.target||`—`})}),(0,W.jsx)(X,{title:_(`vulnerabilityPage.linkedAssets`,null,`资产库匹配`),children:fe.length?(0,W.jsx)(`ul`,{className:`vulnerability-related-list`,children:fe.map(e=>(0,W.jsxs)(`li`,{className:`vulnerability-related-item`,children:[(0,W.jsx)(J,{strong:!0,children:Oe(e)}),(0,W.jsx)(J,{type:`tertiary`,className:`vulnerability-inline-code`,children:U(e.id,12)})]},e.id||`${e.host}-${e.port}`))}):(0,W.jsx)(Y,{type:`tertiary`,children:_(`vulnerabilityPage.noLinkedAssets`,null,`未匹配到资产库记录`)})}),(0,W.jsxs)(X,{title:_(`vulnerabilityPage.detailConversationId`,null,`会话`),children:[A.conversation_id?(0,W.jsxs)(`div`,{className:`vulnerability-related-row`,children:[(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:A.conversation_id}),(0,W.jsx)(c,{size:`small`,theme:`borderless`,onClick:()=>me(A.conversation_id),children:_(`vulnerabilityPage.openConversation`,null,`查看对话`)})]}):(0,W.jsx)(Y,{type:`tertiary`,children:_(`vulnerabilityPage.standaloneRecord`,null,`独立记录(无关联会话)`)}),A.task_id||A.task_queue_id?(0,W.jsxs)(`div`,{className:`vulnerability-related-row`,children:[(0,W.jsx)(J,{type:`tertiary`,children:_(`vulnerabilityPage.detailTaskId`,null,`任务ID`)}),(0,W.jsx)(`span`,{className:`vulnerability-inline-code`,children:A.task_id||A.task_queue_id})]}):null]}),A.assessment_id?(0,W.jsx)(X,{title:_(`vulnerabilityPage.assessmentTask`,null,`深度测评`),children:(0,W.jsxs)(`div`,{className:`vulnerability-related-row`,children:[(0,W.jsx)(J,{children:A.assessment_name||U(A.assessment_id,12)}),A.assessment_step_title?(0,W.jsx)(J,{type:`tertiary`,children:A.assessment_step_title}):null]})}):null,de.length?(0,W.jsx)(X,{title:A.case_title||_(`vulnerabilityPage.mergedRecord`,null,`已归并`),children:(0,W.jsx)(`div`,{className:`vulnerability-member-list`,children:de.map(e=>(0,W.jsxs)(c,{size:`small`,theme:`borderless`,disabled:e.id===A.id,onClick:()=>p(e.id),children:[e.title,` · `,B(_,e.status)]},e.id))})}):null]}),(0,W.jsx)(g.TabPane,{tab:_(`vulnerabilityDownload.title`,null,`下载报告`),itemKey:`download`,children:(0,W.jsxs)(`div`,{className:`vulnerability-download-panel`,children:[(0,W.jsx)(Y,{type:`tertiary`,children:_(`vulnerabilityDownload.hint`,null,`请选择下载格式`)}),(0,W.jsxs)(ee,{value:oe,onChange:e=>se(e.target.value),children:[(0,W.jsx)(x,{value:`docx`,children:_(`vulnerabilityDownload.word`,null,`Word(.docx)`)}),(0,W.jsx)(x,{value:`md`,children:_(`vulnerabilityDownload.markdown`,null,`Markdown(.md)`)})]}),(0,W.jsx)(c,{theme:`solid`,type:`primary`,loading:w,onClick:he,children:_(`vulnerabilityDownload.download`,null,`下载漏洞报告`)}),(0,W.jsx)(J,{type:`tertiary`,children:_(`vulnerabilityPage.downloadHint`,null,`报告由服务端按当前记录生成,包含描述、证据与修复建议。`)})]})})]})]})}var{Text:ze}=p,Be={title:``,severity:``,status:`open`,type:``,target:``,project_id:``,conversation_id:``,conversation_tag:``,task_tag:``,description:``,preconditions:``,reproduction_steps:``,evidence:``,impact:``,recommendation:``,retest_notes:``};function Ve(e){return e?{title:e.title||``,severity:e.severity||``,status:e.status||`open`,type:e.type||``,target:e.target||``,project_id:e.project_id||``,conversation_id:e.conversation_id||``,conversation_tag:e.conversation_tag||``,task_tag:e.task_tag||``,description:e.description||``,preconditions:e.preconditions||``,reproduction_steps:e.reproduction_steps||``,evidence:e.evidence||``,impact:e.impact||``,recommendation:e.recommendation||``,retest_notes:e.retest_notes||``}:{...Be}}function Q(e){return String(e??``).trim()}function He({visible:e,vulnId:t,t:n,projectOptions:r,onClose:i,onSaved:a}){let o=!!t,[s,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(!1),[d,p]=(0,P.useState)(null),[m,h]=(0,P.useState)({...Be}),[g,_]=(0,P.useState)(``);(0,P.useEffect)(()=>{if(!e)return;if(p(null),!t){_(``);return}let n=!1;return C.get(`/vulnerabilities/${encodeURIComponent(t)}`).then(e=>{n||(h(Ve(e)),_(t))}).catch(e=>{n||p(e)}),()=>{n=!0}},[e,t]);let v=!o||g===t,ee=o?m:{...Be},b=async()=>{if(!s||l)return;let e;try{e=await s.validate()}catch{return}let r={title:Q(e.title),severity:e.severity,status:e.status||`open`,type:Q(e.type),target:Q(e.target),description:e.description||``,preconditions:e.preconditions||``,reproduction_steps:e.reproduction_steps||``,evidence:e.evidence||``,impact:e.impact||``,recommendation:e.recommendation||``,retest_notes:e.retest_notes||``,project_id:Q(e.project_id),conversation_tag:Q(e.conversation_tag),task_tag:Q(e.task_tag)};o||(r.conversation_id=Q(e.conversation_id)),u(!0);try{let e=o?await C.put(`/vulnerabilities/${encodeURIComponent(t)}`,r):await C.post(`/vulnerabilities`,r);a?.(e)}catch(e){E(e,n(`vulnerabilityPage.saveFailed`,null,`保存失败`))}finally{u(!1)}};return(0,W.jsx)(D,{title:o?n(`vulnerability.editVuln`,null,`编辑漏洞`):n(`vulnerability.addVuln`,null,`添加漏洞`),visible:e,onCancel:i,onOk:b,confirmLoading:l,okText:n(`common.save`,null,`保存`),cancelText:n(`common.cancel`,null,`取消`),width:780,children:e?d?(0,W.jsx)(ze,{type:`danger`,children:se(d,n(`vulnerabilityPage.fetchFailed`,null,`获取漏洞失败`))}):v?(0,W.jsx)(y,{initValues:ee,getFormApi:c,labelPosition:`top`,onSubmit:b,children:(0,W.jsxs)(`div`,{className:`vulnerability-form-grid`,children:[(0,W.jsx)(`div`,{className:`vulnerability-field vulnerability-field--full`,children:(0,W.jsx)(y.Input,{field:`title`,label:n(`vulnerabilityModal.title`,null,`标题`),placeholder:n(`vulnerabilityModal.titlePlaceholder`,null,`/api/login 存在 SQL 注入`),rules:[{required:!0,message:n(`vulnerabilityModal.titleRequired`,null,`请填写漏洞标题`)}],maxLength:500})}),(0,W.jsx)(`div`,{className:`vulnerability-field`,children:(0,W.jsx)(y.Select,{field:`severity`,label:n(`vulnerabilityModal.severity`,null,`严重程度`),placeholder:n(`vulnerabilityModal.pleaseSelect`,null,`请选择`),style:{width:`100%`},optionList:xe(n),rules:[{required:!0,message:n(`vulnerabilityModal.severityRequired`,null,`请选择严重程度`)}]})}),(0,W.jsx)(`div`,{className:`vulnerability-field`,children:(0,W.jsx)(y.Select,{field:`status`,label:n(`vulnerabilityModal.status`,null,`状态`),style:{width:`100%`},optionList:V(n)})}),(0,W.jsx)(`div`,{className:`vulnerability-field`,children:(0,W.jsx)(y.Input,{field:`target`,label:n(`vulnerabilityModal.target`,null,`目标`),placeholder:n(`vulnerabilityModal.targetPlaceholder`,null,`精确到 URL/IP:端口/接口路径/参数名`)})}),(0,W.jsx)(`div`,{className:`vulnerability-field`,children:(0,W.jsx)(y.Input,{field:`type`,label:n(`vulnerabilityModal.type`,null,`漏洞类型`),placeholder:n(`vulnerabilityModal.typePlaceholder`,null,`如:SQL注入、XSS、CSRF等`)})}),(0,W.jsx)(`div`,{className:`vulnerability-field`,children:(0,W.jsx)(y.Select,{field:`project_id`,label:n(`vulnerabilityModal.project`,null,`所属项目`),placeholder:n(`vulnerabilityModal.projectNone`,null,`(未绑定)`),style:{width:`100%`},filter:!0,optionList:[{value:``,label:n(`vulnerabilityModal.projectNone`,null,`(未绑定)`)},...r]})}),(0,W.jsx)(`div`,{className:`vulnerability-field`,children:(0,W.jsx)(y.Input,{field:`conversation_id`,label:n(`vulnerabilityModal.conversationId`,null,`会话ID`),placeholder:n(`vulnerabilityModal.conversationIdPlaceholder`,null,`可选:输入已有会话ID,留空可独立添加漏洞`),disabled:o})}),(0,W.jsx)(`div`,{className:`vulnerability-field`,children:(0,W.jsx)(y.Input,{field:`conversation_tag`,label:n(`vulnerabilityModal.conversationTag`,null,`对话标签`),placeholder:n(`vulnerabilityModal.conversationTagPlaceholder`,null,`如:红队演练A、客户A周报`)})}),(0,W.jsx)(`div`,{className:`vulnerability-field`,children:(0,W.jsx)(y.Input,{field:`task_tag`,label:n(`vulnerabilityModal.taskTag`,null,`任务标签`),placeholder:n(`vulnerabilityModal.taskTagPlaceholder`,null,`如:批量扫描Q2、专项复测`)})}),(0,W.jsx)(`div`,{className:`vulnerability-field vulnerability-field--full`,children:(0,W.jsx)(y.TextArea,{field:`description`,label:n(`vulnerabilityModal.description`,null,`描述`),placeholder:n(`vulnerabilityModal.descriptionPlaceholder`,null,`说明漏洞摘要、触发点、异常现象和为什么可被利用。`),autosize:{minRows:3,maxRows:8}})}),(0,W.jsx)(`div`,{className:`vulnerability-field vulnerability-field--full`,children:(0,W.jsx)(y.TextArea,{field:`preconditions`,label:n(`vulnerabilityModal.preconditions`,null,`前置条件`),placeholder:n(`vulnerabilityModal.preconditionsPlaceholder`,null,`登录状态、权限、账号、Header/Cookie、特定数据、环境/版本;无则写无。`),autosize:{minRows:2,maxRows:6}})}),(0,W.jsx)(`div`,{className:`vulnerability-field vulnerability-field--full`,children:(0,W.jsx)(y.TextArea,{field:`reproduction_steps`,label:n(`vulnerabilityModal.reproductionSteps`,null,`复现步骤`),placeholder:n(`vulnerabilityModal.reproductionStepsPlaceholder`,null,`按 1/2/3 编号,写清入口、参数、payload、执行命令、观察点。`),autosize:{minRows:3,maxRows:10}})}),(0,W.jsx)(`div`,{className:`vulnerability-field vulnerability-field--full`,children:(0,W.jsx)(y.TextArea,{field:`evidence`,label:n(`vulnerabilityModal.evidence`,null,`证据 / POC`),placeholder:n(`vulnerabilityModal.evidencePlaceholder`,null,`原始请求/响应、curl/工具命令、截图说明、日志、回连记录等。`),autosize:{minRows:3,maxRows:10}})}),(0,W.jsx)(`div`,{className:`vulnerability-field vulnerability-field--full`,children:(0,W.jsx)(y.TextArea,{field:`impact`,label:n(`vulnerabilityModal.impact`,null,`影响`),placeholder:n(`vulnerabilityModal.impactPlaceholder`,null,`结合已验证事实说明实际影响,例如越权读取哪些数据。`),autosize:{minRows:2,maxRows:6}})}),(0,W.jsx)(`div`,{className:`vulnerability-field vulnerability-field--full`,children:(0,W.jsx)(y.TextArea,{field:`recommendation`,label:n(`vulnerabilityModal.recommendation`,null,`修复建议`),placeholder:n(`vulnerabilityModal.recommendationPlaceholder`,null,`写具体修复点和复测标准。`),autosize:{minRows:2,maxRows:8}})}),(0,W.jsx)(`div`,{className:`vulnerability-field vulnerability-field--full`,children:(0,W.jsx)(y.TextArea,{field:`retest_notes`,label:n(`vulnerabilityModal.retestNotes`,null,`复测方式`),placeholder:n(`vulnerabilityModal.retestNotesPlaceholder`,null,`修复后如何验证漏洞已关闭,包括应返回的状态码、错误信息或访问控制结果。`),autosize:{minRows:2,maxRows:6}})})]})},o?`${t}-${g}`:`new`):(0,W.jsx)(`div`,{className:`vulnerability-modal-loading`,children:(0,W.jsx)(f,{size:`large`})}):null})}var{Text:Ue}=p,We={none:`viewList`,host:`viewHost`,task:`viewTask`},Ge=[];function Ke(){let e=oe(),{hasPermission:t}=ie(),[n,r]=i(),a=(0,P.useMemo)(()=>({q:n.get(`q`)||``,severity:n.get(`severity`)||``,status:n.get(`status`)||``,project_id:n.get(`project_id`)||``,conversation_tag:n.get(`conversation_tag`)||``,task_tag:n.get(`task_tag`)||``,assessment_id:n.get(`assessment_id`)||``,sort:[`severity`,`latest`,`oldest`].includes(n.get(`sort`))?n.get(`sort`):``}),[n]),o=Math.max(1,Number.parseInt(n.get(`page`)||`1`,10)||1),s=_e.includes(Number(n.get(`page_size`)))?Number(n.get(`page_size`)):20,l=(n.get(`id`)||``).trim(),u=n.get(`group_by`),d=u===`host`||u===`task`?u:``,f=d&&n.get(`selection`)||``,p=d===`task`?`task_q`:`host_q`,m=d&&n.get(p)||``,h=m?{[p]:m}:{},g=t(`vulnerability:write`),v=t(`vulnerability:delete`)||g,y=(0,P.useCallback)((e,t={})=>{r(n=>{let r=new URLSearchParams(n);return Object.entries(e).forEach(([e,t])=>{t==null||t===``?r.delete(e):r.set(e,String(t))}),t.resetPage&&r.delete(`page`),r.toString()===n.toString()?n:r},{replace:!0})},[r]),x=(0,P.useCallback)((e,t)=>{y({[e]:t},{resetPage:!0})},[y]),te=(0,P.useCallback)(()=>{let e={sort:void 0,selection:void 0,host_q:void 0,task_q:void 0};F.forEach(t=>{e[t]=void 0}),y(e,{resetPage:!0})},[y]),S=(0,P.useCallback)(e=>{y({group_by:e===`none`?void 0:e,selection:void 0,host_q:void 0,task_q:void 0},{resetPage:!0})},[y]),ne=(0,P.useCallback)(e=>{y({selection:e},{resetPage:!0})},[y]),re=(0,P.useCallback)(e=>{y({[p]:e,selection:void 0},{resetPage:!0})},[p,y]),se=(0,P.useCallback)(e=>y({id:e}),[y]),D=(0,P.useCallback)(()=>y({id:void 0}),[y]),le={...Ce(a),...h,...d?{group_by:d,pagination:`records`,selection:f}:{},...a.sort?{sort:a.sort}:{},summary:`true`,page:o,limit:s},O=JSON.stringify(le),k=T(async()=>({...await C.get(`/vulnerabilities`,le)||{},__requestKey:O,__groupView:d}),[O]),j=k.data?.__requestKey===O?k.data:null,de=k.data?.__groupView===d&&k.data?.navigation||Ge,pe=j?.selection?de.flatMap(e=>[e,...e.children||[]]).find(e=>e.key===j.selection):null,M=(0,P.useMemo)(()=>we(a),[a]),ge=JSON.stringify(M),I=T(()=>C.get(`/vulnerabilities/stats`,M),[ge]),[ve,L]=(0,P.useState)(0),R=T(()=>C.get(`/vulnerabilities/filter-options`),[ve]),z=T(async()=>{try{let e=await C.get(`/projects`,{limit:500});return Array.isArray(e?.projects)?e.projects:[]}catch{return[]}},[]),B=(0,P.useMemo)(()=>{let e={};return(z.data||[]).forEach(t=>{t?.id&&(e[t.id]=t.name||t.id)}),e},[z.data]),be=(0,P.useMemo)(()=>{let e=new Map;return(R.data?.project_ids||[]).forEach(t=>{t&&e.set(t,B[t]||t)}),a.project_id&&!e.has(a.project_id)&&e.set(a.project_id,B[a.project_id]||a.project_id),[...e.entries()].map(([e,t])=>({value:e,label:t}))},[R.data,B,a.project_id]),xe=(0,P.useMemo)(()=>{let e=new Map;return(z.data||[]).forEach(t=>{t?.id&&e.set(t.id,t.name||t.id)}),[...e.entries()].map(([e,t])=>({value:e,label:t}))},[z.data]),[V,Se]=(0,P.useState)([]),[De,H]=(0,P.useState)({visible:!1,id:``}),[Oe,U]=(0,P.useState)(0),[G,je]=(0,P.useState)(!1);(0,P.useEffect)(()=>{Se([])},[O]),(0,P.useEffect)(()=>{if(!j)return;let e={},t=Number(j.page);t&&t!==o&&(e.page=t),f&&!j.selection&&(e.selection=void 0),Object.keys(e).length&&y(e)},[j,f,o,y]);let K=k.reload,q=I.reload,Me=R.reload,Fe=(0,P.useCallback)(()=>{K(),q(),Me({silent:!0})},[K,q,Me]),Ie=(0,P.useCallback)(e=>{H({visible:!0,id:e?.id||``})},[]),J=(0,P.useCallback)(()=>{H({visible:!1,id:``}),N(e(`vulnerabilityPage.saveSuccess`,null,`已保存`)),U(e=>e+1),L(e=>e+1),K({silent:!0}),q({silent:!0})},[K,q,e]),Y=(0,P.useCallback)(t=>{t?.id&&me({title:e(`vulnerabilityPage.deleteTitle`,null,`删除漏洞`),content:`${e(`vulnerability.deleteConfirm`,null,`确定要删除此漏洞吗?`)}${t.title?` ${t.title}`:``}`,okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{await C.del(`/vulnerabilities/${encodeURIComponent(t.id)}`),N(e(`vulnerabilityPage.deleteSuccess`,null,`已删除`)),l===t.id&&D(),U(e=>e+1),L(e=>e+1),await Promise.all([K({silent:!0}),q({silent:!0})])}catch(t){E(t,e(`vulnerabilityPage.deleteFailed`,null,`删除失败`))}}})},[l,D,K,q,e]),X=(0,P.useCallback)(()=>{if(!V.length)return;let t=[...V];me({title:e(`vulnerabilityPage.batchDelete`,null,`批量删除`),content:e(`vulnerabilityPage.batchDeleteConfirm`,{count:t.length},`确定要删除选中的 ${t.length} 条漏洞吗?此操作不可恢复。`),okText:e(`common.delete`,null,`删除`),onOk:async()=>{let n=0,r=0;for(let e of t)try{await C.del(`/vulnerabilities/${encodeURIComponent(e)}`),n+=1}catch{r+=1}r?w(e(`vulnerabilityPage.batchDeletePartial`,{deleted:n,failed:r},`已删除 ${n} 条,${r} 条失败`)):N(e(`vulnerabilityPage.batchDeleteSuccess`,{count:n},`成功删除 ${n} 条漏洞`)),Se([]),t.includes(l)&&D(),U(e=>e+1),L(e=>e+1),await Promise.all([K({silent:!0}),q({silent:!0})])}})},[V,l,D,K,q,e]),Z=(0,P.useCallback)(async()=>{let t=Ce(a);try{let n=await C.get(`/vulnerabilities`,{...t,page:1,limit:1}),r=Number(n?.total)||0;if(!r){w(e(`vulnerabilityPage.batchDeleteNoResults`,null,`当前筛选条件下没有可删除的漏洞`));return}me({title:e(`vulnerabilityPage.deleteFilteredTitle`,null,`删除当前筛选结果`),content:e(`vulnerabilityPage.batchDeleteConfirm`,{count:r},`确定要删除当前筛选条件下的 ${r} 条漏洞吗?此操作不可恢复。`),okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{let n=await C.del(`/vulnerabilities/batch`,{query:t}),i=Number(n?.deleted)||r;N(e(`vulnerabilityPage.batchDeleteSuccess`,{count:i},`成功删除 ${i} 条漏洞`)),Se([]),U(e=>e+1),L(e=>e+1),await Promise.all([K({silent:!0}),q({silent:!0})])}catch(t){E(t,e(`vulnerabilityPage.batchDeleteFailed`,null,`批量删除失败`))}}})}catch(t){E(t,e(`vulnerabilityPage.fetchFailed`,null,`获取漏洞失败`))}},[a,K,q,e]),ze=(0,P.useCallback)(async()=>{if(!G){je(!0);try{let t=await C.get(`/vulnerabilities/export`,{...Ce(a),...h,mode:`summary`,group_by:`conversation`}),n=Array.isArray(t?.files)?t.files:[];if(!n.length){w(e(`vulnerabilityPage.exportNoResults`,null,`当前筛选条件下无可导出漏洞`));return}n.forEach((e,t)=>{setTimeout(()=>ke(e.filename||`vulnerability-export-${t+1}.md`,e.content||``),t*120)}),N(n.length>1?e(`vulnerabilityPage.exportStarted`,{count:n.length},`已开始下载 ${n.length} 份报告`):e(`vulnerabilityPage.exportSuccess`,null,`报告已开始下载`))}catch(t){E(t,e(`vulnerabilityPage.exportFailed`,null,`导出失败`))}finally{je(!1)}}},[G,a,h,e]),Be=(0,P.useCallback)(async t=>{try{let n=await ae(`/vulnerabilities/${encodeURIComponent(t.id)}/download`,{query:{format:`docx`}});N(`${e(`vulnerabilityPage.downloadOkTitle`,null,`下载成功`)}${n?` · ${n}`:``}`)}catch(t){E(t,e(`vulnerabilityPage.downloadFailed`,null,`下载失败`))}},[e]),Ve=(0,P.useCallback)(e=>{y({page:String(e)})},[y]),Q=(0,P.useCallback)(e=>{if(!e||e===s)return;let t=Math.max(1,Math.floor((o-1)*s/e)+1);y({page_size:String(e),page:String(t)})},[o,s,y]),Ke=I.data||{},qe=Ke.by_severity||{},Je=Number(Ke.total)||0,Ye=Number(Ke.distinct)||0,Xe=(0,P.useMemo)(()=>[{id:`total`,label:e(`vulnerabilityPage.statTotal`,null,`总漏洞数`),value:Je,detail:Ye&&Ye!==Je?e(`vulnerabilityPage.distinctCount`,{count:Ye},`${Ye} 个独立漏洞`):void 0,loading:I.loading,onClick:()=>x(`severity`,``)},...he.map(t=>{let n=Number(qe[t])||0,r=Ee(n,Je),i=a.severity===t;return{id:t,label:ye(e,t),value:n,severity:t,pressed:i,detail:i?`${e(`vulnerabilityPage.filterActive`,null,`已筛选`)} · ${r}%`:`${r}%`,loading:I.loading,onClick:()=>x(`severity`,i?``:t)}})],[e,Je,Ye,qe,I.loading,a.severity,x]),$=Number(j?.total)||0,Ze=$?(o-1)*s+1:0,Qe=$?Math.min(o*s,$):0,$e=$?e(`vulnerabilityPage.recordPagination`,{start:Ze,end:Qe,total:$},`显示 ${Ze}–${Qe} / 共 ${$} 条漏洞`):e(`vulnerabilityPage.noRecords`,null,`暂无漏洞记录`),et=k.error||I.error||R.error,tt=(0,W.jsxs)(`div`,{className:`vulnerability-toolbar-left`,children:[(0,W.jsx)(Ue,{type:`tertiary`,children:j&&V.length?e(`vulnerabilityPage.selectedCount`,{count:V.length},`已选 ${V.length} 项`):$e}),v&&(0,W.jsx)(c,{size:`small`,type:`danger`,theme:`light`,disabled:!j||!V.length,onClick:X,children:e(`vulnerabilityPage.batchDelete`,null,`批量删除`)}),v&&!f&&!m&&Te(a)&&(0,W.jsx)(c,{size:`small`,type:`danger`,theme:`borderless`,onClick:Z,children:e(`vulnerabilityPage.deleteFiltered`,null,`删除筛选结果`)})]});return(0,W.jsxs)(`div`,{className:`vulnerability-page`,children:[(0,W.jsx)(fe,{title:e(`vulnerability.title`,null,`漏洞管理`),description:e(`vulnerabilityPage.workspaceSubtitle`,null,`资产、上报与处置进展`),extra:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(c,{icon:(0,W.jsx)(b,{}),onClick:Fe,loading:k.loading,children:e(`common.refresh`,null,`刷新`)}),(0,W.jsx)(c,{onClick:ze,loading:G,children:e(f?`vulnerabilityPage.exportAllGroups`:`vulnerabilityPage.batchExport`)}),g&&(0,W.jsx)(c,{theme:`solid`,type:`primary`,icon:(0,W.jsx)(_,{}),onClick:()=>Ie(null),children:e(`vulnerability.addVuln`,null,`添加漏洞`)})]})}),(0,W.jsx)(ce,{metrics:Xe,columns:6}),(0,W.jsx)(ue,{error:et,onRetry:Fe}),(0,W.jsxs)(A,{className:`vulnerability-list-card`,title:e(`vulnerabilityPage.listTitle`,null,`漏洞记录`),extra:(0,W.jsx)(ee,{"aria-label":e(`vulnerabilityPage.viewLabel`),type:`button`,value:d||`none`,options:Object.entries(We).map(([t,n])=>({value:t,label:e(`vulnerabilityPage.${n}`)})),onChange:e=>S(e.target.value)}),children:[(0,W.jsx)(Ae,{t:e,filters:a,options:R.data,projectOptions:be,hasGroupFilters:!!(f||m),onChange:x,onReset:te}),(0,W.jsxs)(`div`,{className:d?`vulnerability-group-layout`:void 0,children:[d&&(0,W.jsx)(Ne,{t:e,mode:d,groups:de,selection:f,search:m,loading:k.loading,onSearch:re,onSelect:ne},d),(0,W.jsxs)(`div`,{className:`vulnerability-group-results`,children:[pe&&(0,W.jsx)(Pe,{t:e,group:pe}),(0,W.jsx)(Le,{t:e,data:j?.vulnerabilities,loading:k.loading,page:o,pageSize:s,total:$,selection:j?V:[],onSelectionChange:Se,onOpen:se,onEdit:Ie,onDelete:Y,onDownload:Be,sort:a.sort,onSort:e=>x(`sort`,e),canWrite:g,canDelete:v,onPageChange:Ve,onPageSizeChange:Q,toolbar:tt,onRefresh:Fe})]})]})]}),(0,W.jsx)(Re,{visible:!!l,vulnId:l,refreshKey:Oe,onClose:D,onOpenVuln:se,onEdit:Ie,onDelete:Y,canWrite:g,canDelete:v,t:e,projectNames:B}),(0,W.jsx)(He,{visible:De.visible,vulnId:De.id,t:e,projectOptions:xe,onClose:()=>H({visible:!1,id:``}),onSaved:J})]})}export{Ke as default};
\ No newline at end of file
diff --git a/web/static/app/assets/webshell-CIbXTeR9.js b/web/static/app/assets/webshell-ByRhMULc.js
similarity index 99%
rename from web/static/app/assets/webshell-CIbXTeR9.js
rename to web/static/app/assets/webshell-ByRhMULc.js
index bc99988d..f8f3d1c5 100644
--- a/web/static/app/assets/webshell-CIbXTeR9.js
+++ b/web/static/app/assets/webshell-ByRhMULc.js
@@ -1,2 +1,2 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{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,ct as p,i as m,it as h,ot as g,x as _}from"./semi-CXF9U6uC.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-CrDogtQS.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)(m,{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)(m.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)(m.Input,{field:`password`,label:c(`webshell.password`,null,`连接密码/密钥`),placeholder:c(`webshell.passwordPlaceholder`,null,`如冰蝎/蚁剑的连接密码`)}),(0,V.jsxs)(`div`,{className:`webshell-form-row`,children:[(0,V.jsx)(m.Select,{field:`type`,label:c(`webshell.type`,null,`Shell 类型`),optionList:H,style:{width:`100%`}}),(0,V.jsx)(m.Select,{field:`method`,label:c(`webshell.method`,null,`请求方式`),optionList:U,style:{width:`100%`}})]}),(0,V.jsxs)(`div`,{className:`webshell-form-row`,children:[(0,V.jsx)(m.Input,{field:`cmd_param`,label:c(`webshell.cmdParam`,null,`命令参数名`),placeholder:`cmd`}),(0,V.jsx)(m.Select,{field:`encoding`,label:c(`webshell.encoding`,null,`响应编码`),optionList:W,style:{width:`100%`}})]}),(0,V.jsxs)(`div`,{className:`webshell-form-row`,children:[(0,V.jsx)(m.Select,{field:`os`,label:c(`webshell.os`,null,`目标系统`),optionList:G,style:{width:`100%`}}),(0,V.jsx)(m.Select,{field:`project_id`,label:c(`webshell.project`,null,`所属项目`),optionList:n.map(e=>({value:e.id,label:e.name||e.id})),showClear:!0,style:{width:`100%`},placeholder:`可选`})]}),(0,V.jsx)(m.Input,{field:`remark`,label:c(`webshell.remark`,null,`备注`),placeholder:c(`webshell.remarkPlaceholder`,null,`便于识别的备注名`)}),(0,V.jsx)(le,{type:`tertiary`,size:`small`,children:c(`webshell.encodingHint`,null,`中文 Windows 目标若出现乱码,请切换为 GBK 或 GB18030`)})]},t?.id||`new`)})}var q={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11};function J(e,t,n){if(!e||!t||!n)return``;let r=String(n).trim();if(/^\d{4}$/.test(r))return`${r} ${e} ${t}`;let i=new Date,a=i.getFullYear();if(/^\d{1,2}:\d{2}$/.test(r)){let n=q[e],o=parseInt(t,10);return n!=null&&!Number.isNaN(o)&&new Date(a,n,o).getTime()>i.getTime()&&--a,`${a} ${e} ${t} ${r}`}return`${e} ${t} ${r}`}function de(e){if(!e)return``;let t=e.charAt(0);return{d:`dir`,"-":`file`,l:`link`,c:`char`,b:`block`,s:`socket`,p:`pipe`}[t]||t}function Y(e){let t=String(e||``).match(/^(\d{4}[/-]\d{1,2}[/-]\d{1,2})\s+(\d{1,2}:\d{2})(?:\s*(AM|PM))?\s+(<[^>]+>|[\d,]+)\s+(.+?)\s*$/i);if(!t)return null;let n=(t[4]||``).trim(),r=(t[5]||``).trim();if(!r||r===`.`||r===`..`)return null;let i=/^<(dir|junction|symlinkd)>$/i.test(n);return{name:r,isDir:i,size:i?``:n.replace(/,/g,``),mtime:`${t[1]} ${t[2]}${t[3]?` ${t[3].toUpperCase()}`:``}`.trim(),mode:i?`d`:`-`,owner:``,group:``,type:i?`dir`:`file`}}var X=[/^(total|总计)\s+\d+$/i,/^(驱动器|卷的序列号是|volume in drive|volume serial number is|directory of)/i,/^[A-Za-z]:\\.*\s+的目录$/i,/^\d+\s+(个文件|file\(s\))\s+[\d,]+\s+(字节|bytes?)$/i,/^\d+\s+(个目录|dir\(s\))\s+[\d,]+\s+(可用字节|bytes free)$/i,/^[^>\n]*>\s*dir(?:\s|$)/i];function Z(e){let t=String(e||``).split(/\n/).filter(e=>e.trim()),n=[];for(let e of t){let t=e.trim();if(X.some(e=>e.test(t)))continue;let r=e.match(/^(\S+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(\d+)\s+([A-Za-z]{3})\s+(\d{1,2})\s+(\S+)\s+(.+)$/);if(r){let t=(r[9]||``).trim();if(t===`.`||t===`..`)continue;n.push({name:t,isDir:r[1].startsWith(`d`),size:r[5],mode:r[1],mtime:J(r[6],r[7],r[8]),owner:r[3],group:r[4],type:de(r[1]),line:e});continue}let i=Y(e);if(i){n.push({...i,line:e});continue}if(!/^[bcdlps-][rwxStTs-]{9}[+.@]?\s/.test(e))continue;let a=t.split(/\s+/),o=(a.length>=9?a.slice(8).join(` `):a[a.length-1]||``).trim();o&&o!==`.`&&o!==`..`&&n.push({name:o,isDir:e.startsWith(`d`),size:a[4]||``,mode:a[0]||``,owner:a[2]||``,group:a[3]||``,mtime:a[5]&&/^[A-Za-z]{3}$/.test(a[5])?J(a[5],a[6],a[7]):``,type:de(a[0]),line:e})}return n}function Q(e){let t=String(e??``).trim();return t?(t=t.replace(/\\/g,`/`).replace(/\/{2,}/g,`/`),t.length>1&&(t=t.replace(/\/+$/,``)),/^[A-Za-z]:$/.test(t)?`${t}/`:t||`.`):`.`}function $(e,t){let n=Q(e);return t?t.startsWith(`/`)||/^[A-Za-z]:/.test(t)||n===`.`?Q(t):Q(n===`/`?`/${t}`:`${n}/${t}`):n}function fe(e){let t=Q(e);if(t===`.`||t===`/`||/^[A-Za-z]:\/$/.test(t))return t;let n=t.lastIndexOf(`/`);if(n<0)return`.`;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?`${r}/`:r}function pe(e){let t=Q(e),n=/^[A-Za-z]:/.test(t),r=!n&&t.startsWith(`/`),i=n?t.replace(/^[A-Za-z]:\/?/,``):t.replace(/^\//,``),a=t===`.`||t===`/`||!i?[]:i.split(`/`),o=[{label:n?t.slice(0,2)+`/`:r?`/`:`.`,path:n?`${t.slice(0,2)}/`:r?`/`:`.`}];return a.forEach((e,i)=>{let s=a.slice(0,i+1).join(`/`);o.push({label:e,path:n?`${t.slice(0,2)}/${s}`:r?`/${s}`:s})}),o}var{Text:me}=u;function he(e,t){let n=new Blob([t],{type:`application/octet-stream`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e||`download.bin`,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function ge({connection:e,canWrite:t}){let n=x(),[r,c]=(0,M.useState)(`.`),[l,u]=(0,M.useState)(`.`),[f,p]=(0,M.useState)(``),[m,h]=(0,M.useState)([]),[v,y]=(0,M.useState)(!1),[b,C]=(0,M.useState)(null),[E,te]=(0,M.useState)(``),[D,O]=(0,M.useState)({visible:!1,mode:`read`,path:``,content:``,loading:!1}),[N,P]=(0,M.useState)({visible:!1,mode:`mkdir`,title:``,value:``,target:``}),F=(0,M.useCallback)(async t=>{if(!e?.id)return;let n=Q(t??r);y(!0),C(null);try{let t=await R({connection:e,action:`list`,path:n});if(!t?.ok&&t?.error){C(t.error),h([]),p(t.output||``);return}p(t?.output||``),h(Z(t?.output||``)),c(n),u(n)}catch(e){C(e),h([])}finally{y(!1)}},[e,r]);(0,M.useEffect)(()=>{c(`.`),u(`.`),h([]),p(``),F(`.`)},[e?.id]);let re=async t=>{try{let n=await R({connection:e,action:`read`,path:t});return n?.error&&!n?.ok?(w(n.error),null):n?.output??``}catch(e){return w(e),null}},I=async(e,t)=>{O({visible:!0,mode:t,path:e,content:``,loading:!0});let n=await re(e);O(e=>({...e,content:n??``,loading:!1}))},ie=async()=>{try{let t=await R({connection:e,action:`write`,path:D.path,content:D.content});if(t?.error&&!t?.ok){w(t.error);return}A(n(`webshell.saveFile`,null,`已保存`)),O(e=>({...e,visible:!1})),F(r)}catch(e){w(e)}},L=async(e,t)=>{let n=await re(e);n!==null&&he(t,n)},z=t=>{j({title:n(`webshell.deleteFile`,null,`删除文件`),content:t,onOk:async()=>{try{let i=await R({connection:e,action:`delete`,path:t});if(i?.error&&!i?.ok){w(i.error);return}A(n(`webshell.deleteFile`,null,`已删除`)),F(r)}catch(e){w(e)}}})},ae=async()=>{let t=String(N.value||``).trim();if(!t)S(n(`webshell.filePath`,null,`请填写路径`));else try{if(N.mode===`mkdir`){let i=await R({connection:e,action:`mkdir`,path:$(r,t)});if(i?.error&&!i?.ok){w(i.error);return}A(n(`webshell.newDir`,null,`目录已创建`))}else if(N.mode===`create`){let i=await R({connection:e,action:`write`,path:$(r,t),content:``});if(i?.error&&!i?.ok){w(i.error);return}A(n(`webshell.newFile`,null,`文件已创建`))}else if(N.mode===`rename`){let r=await R({connection:e,action:`rename`,path:N.target,targetPath:$(fe(N.target),t)});if(r?.error&&!r?.ok){w(r.error);return}A(n(`webshell.rename`,null,`已重命名`))}P(e=>({...e,visible:!1})),F(r)}catch(e){w(e)}},B=(0,M.useMemo)(()=>{let e=E.trim().toLowerCase();return e?m.filter(t=>t.name.toLowerCase().includes(e)):m},[m,E]),oe=(0,M.useMemo)(()=>pe(r),[r]),se=[{title:n(`webshell.colName`,null,`名称`),dataIndex:`name`,render:(e,t)=>(0,V.jsxs)(`button`,{type:`button`,className:`webshell-file-name ${t.isDir?`is-dir`:`is-file`}`,onClick:()=>t.isDir?F($(r,e)):I($(r,e),`read`),title:e,children:[e,t.isDir?`/`:``]})},{title:n(`webshell.colType`,null,`类型`),dataIndex:`type`,width:90},{title:n(`webshell.colSize`,null,`大小`),dataIndex:`size`,width:110},{title:n(`webshell.colModifiedAt`,null,`修改时间`),dataIndex:`mtime`,width:170},{title:n(`webshell.colOwner`,null,`所有者`),dataIndex:`owner`,width:120},{title:n(`webshell.colPerms`,null,`权限`),dataIndex:`mode`,width:130},{title:n(`webshell.moreActions`,null,`操作`),dataIndex:`ops`,width:240,render:(e,a)=>{let s=$(r,a.name);return(0,V.jsxs)(i,{spacing:4,wrap:!0,children:[a.isDir?(0,V.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>F(s),children:n(`webshell.listDir`,null,`打开`)}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>I(s,`read`),children:n(`webshell.readFile`,null,`读取`)}),(0,V.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>I(s,`write`),children:n(`webshell.editFile`,null,`编辑`)}),(0,V.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>L(s,a.name),children:n(`webshell.downloadFile`,null,`下载`)})]}),(0,V.jsx)(o,{size:`small`,theme:`borderless`,disabled:!t,onClick:()=>P({visible:!0,mode:`rename`,title:n(`webshell.rename`,null,`重命名`),value:a.name,target:s}),children:n(`webshell.rename`,null,`重命名`)}),!a.isDir&&(0,V.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!t,onClick:()=>z(s),children:n(`webshell.deleteFile`,null,`删除`)})]})}}];return(0,V.jsxs)(`div`,{className:`webshell-files`,children:[(0,V.jsx)(`div`,{className:`webshell-file-toolbar`,children:(0,V.jsxs)(i,{spacing:8,wrap:!0,children:[(0,V.jsx)(o,{size:`small`,onClick:()=>F(fe(r)),children:n(`webshell.parentDir`,null,`上级目录`)}),(0,V.jsx)(o,{size:`small`,icon:(0,V.jsx)(g,{}),onClick:()=>F(r),loading:v,children:n(`webshell.refresh`,null,`刷新`)}),(0,V.jsx)(o,{size:`small`,disabled:!t,onClick:()=>P({visible:!0,mode:`mkdir`,title:n(`webshell.newDir`,null,`新建目录`),value:``,target:``}),children:n(`webshell.newDir`,null,`新建目录`)}),(0,V.jsx)(o,{size:`small`,disabled:!t,onClick:()=>P({visible:!0,mode:`create`,title:n(`webshell.newFile`,null,`新建文件`),value:``,target:``}),children:n(`webshell.newFile`,null,`新建文件`)})]})}),(0,V.jsxs)(`div`,{className:`webshell-file-pathbar`,children:[(0,V.jsx)(me,{type:`tertiary`,children:n(`webshell.filePath`,null,`当前路径`)}),(0,V.jsx)(a,{value:l,onChange:u,onEnterPress:()=>F(l),size:`small`,className:`webshell-file-path-input`}),(0,V.jsx)(o,{size:`small`,icon:(0,V.jsx)(d,{}),onClick:()=>F(l),children:n(`webshell.listDir`,null,`列出目录`)}),(0,V.jsx)(a,{value:E,onChange:te,placeholder:n(`webshell.filterPlaceholder`,null,`过滤文件名`),size:`small`,className:`webshell-file-filter`})]}),(0,V.jsx)(`nav`,{className:`webshell-breadcrumb`,"aria-label":`breadcrumb`,children:oe.map((e,t)=>(0,V.jsxs)(`span`,{className:`webshell-breadcrumb-item`,children:[t>0&&(0,V.jsx)(`span`,{className:`webshell-breadcrumb-sep`,children:`/`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>F(e.path),title:e.path,children:t===0?n(`webshell.breadcrumbHome`,null,`根`):e.label})]},e.path))}),(0,V.jsx)(ee,{error:b,onRetry:()=>F(r)}),m.length===0&&f.trim()&&!v?(0,V.jsx)(ne,{title:n(`webshell.filePath`,null,`原始输出`),value:f}):(0,V.jsx)(k,{columns:se,dataSource:B,rowKey:`name`,loading:v,pagination:{pageSize:20},emptyText:n(`webshell.emptyDir`,null,`目录为空`)}),(0,V.jsxs)(T,{visible:D.visible,title:D.mode===`write`?n(`webshell.editFile`,null,`编辑文件`):n(`webshell.readFile`,null,`读取文件`),width:760,onCancel:()=>O(e=>({...e,visible:!1})),footer:(0,V.jsxs)(i,{children:[(0,V.jsx)(o,{onClick:()=>O(e=>({...e,visible:!1})),children:n(`webshell.cancelEdit`,null,`关闭`)}),D.mode===`write`&&(0,V.jsx)(o,{theme:`solid`,type:`primary`,disabled:!t,onClick:ie,children:n(`webshell.saveFile`,null,`保存`)})]}),children:[(0,V.jsx)(`div`,{className:`webshell-editor-path`,children:(0,V.jsx)(s,{size:`small`,children:D.path})}),(0,V.jsx)(_,{value:D.content,onChange:e=>O(t=>({...t,content:e})),autosize:{minRows:12,maxRows:24},disabled:D.mode!==`write`,className:`webshell-editor-area`})]}),(0,V.jsx)(T,{visible:N.visible,title:N.title,width:420,onCancel:()=>P(e=>({...e,visible:!1})),onOk:ae,children:(0,V.jsx)(a,{value:N.value,onChange:e=>P(t=>({...t,value:e})),placeholder:N.mode===`rename`?n(`webshell.rename`,null,`新名称`):n(`webshell.filePath`,null,`名称或路径`)})})]})}var _e=0,ve=()=>(_e+=1,_e);function ye({connection:e,canWrite:t,onRecordCommand:n}){let r=x(),[c,l]=(0,M.useState)([]),[u,d]=(0,M.useState)(``),[f,p]=(0,M.useState)(!1),m=(0,M.useRef)(null),g=(0,M.useCallback)(e=>{l(t=>[...t,{id:ve(),...e}])},[]);(0,M.useEffect)(()=>{l([]),d(``)},[e?.id]),(0,M.useEffect)(()=>{let e=m.current;e&&(e.scrollTop=e.scrollHeight)},[c]);let _=async i=>{let a=String(i??u).trim();if(a){if(!t)S(r(`webshell.webshellWriteRequired`,null,`当前账号没有执行权限`));else{d(``),g({kind:`cmd`,text:a}),n?.(a),p(!0);try{let t=await L({connection:e,command:a});t?.output&&g({kind:`out`,text:t.output}),t?.error&&g({kind:`err`,text:t.error}),!t?.ok&&!t?.error&&g({kind:`err`,text:r(`webshell.execError`,null,`执行失败`)})}catch(e){g({kind:`err`,text:e?.message||r(`webshell.execError`,null,`执行失败`)}),w(e)}finally{p(!1)}}}};return(0,V.jsxs)(`div`,{className:`webshell-terminal`,children:[(0,V.jsx)(`div`,{className:`webshell-terminal-bar`,children:(0,V.jsxs)(i,{spacing:8,children:[(0,V.jsx)(s,{size:`small`,color:f?`amber`:`green`,children:f?r(`webshell.terminalRunning`,null,`执行中`):r(`webshell.terminalIdle`,null,`空闲`)}),(0,V.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>l([]),children:r(`webshell.clearScreen`,null,`清屏`)}),(0,V.jsx)(o,{size:`small`,theme:`borderless`,onClick:async()=>{let e=c.map(e=>e.kind===`cmd`?`$ ${e.text}`:e.text).join(`
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{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,ct as p,i as m,it as h,ot as g,x as _}from"./semi-CXF9U6uC.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-LQJrYSgy.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)(m,{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)(m.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)(m.Input,{field:`password`,label:c(`webshell.password`,null,`连接密码/密钥`),placeholder:c(`webshell.passwordPlaceholder`,null,`如冰蝎/蚁剑的连接密码`)}),(0,V.jsxs)(`div`,{className:`webshell-form-row`,children:[(0,V.jsx)(m.Select,{field:`type`,label:c(`webshell.type`,null,`Shell 类型`),optionList:H,style:{width:`100%`}}),(0,V.jsx)(m.Select,{field:`method`,label:c(`webshell.method`,null,`请求方式`),optionList:U,style:{width:`100%`}})]}),(0,V.jsxs)(`div`,{className:`webshell-form-row`,children:[(0,V.jsx)(m.Input,{field:`cmd_param`,label:c(`webshell.cmdParam`,null,`命令参数名`),placeholder:`cmd`}),(0,V.jsx)(m.Select,{field:`encoding`,label:c(`webshell.encoding`,null,`响应编码`),optionList:W,style:{width:`100%`}})]}),(0,V.jsxs)(`div`,{className:`webshell-form-row`,children:[(0,V.jsx)(m.Select,{field:`os`,label:c(`webshell.os`,null,`目标系统`),optionList:G,style:{width:`100%`}}),(0,V.jsx)(m.Select,{field:`project_id`,label:c(`webshell.project`,null,`所属项目`),optionList:n.map(e=>({value:e.id,label:e.name||e.id})),showClear:!0,style:{width:`100%`},placeholder:`可选`})]}),(0,V.jsx)(m.Input,{field:`remark`,label:c(`webshell.remark`,null,`备注`),placeholder:c(`webshell.remarkPlaceholder`,null,`便于识别的备注名`)}),(0,V.jsx)(le,{type:`tertiary`,size:`small`,children:c(`webshell.encodingHint`,null,`中文 Windows 目标若出现乱码,请切换为 GBK 或 GB18030`)})]},t?.id||`new`)})}var q={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11};function J(e,t,n){if(!e||!t||!n)return``;let r=String(n).trim();if(/^\d{4}$/.test(r))return`${r} ${e} ${t}`;let i=new Date,a=i.getFullYear();if(/^\d{1,2}:\d{2}$/.test(r)){let n=q[e],o=parseInt(t,10);return n!=null&&!Number.isNaN(o)&&new Date(a,n,o).getTime()>i.getTime()&&--a,`${a} ${e} ${t} ${r}`}return`${e} ${t} ${r}`}function de(e){if(!e)return``;let t=e.charAt(0);return{d:`dir`,"-":`file`,l:`link`,c:`char`,b:`block`,s:`socket`,p:`pipe`}[t]||t}function Y(e){let t=String(e||``).match(/^(\d{4}[/-]\d{1,2}[/-]\d{1,2})\s+(\d{1,2}:\d{2})(?:\s*(AM|PM))?\s+(<[^>]+>|[\d,]+)\s+(.+?)\s*$/i);if(!t)return null;let n=(t[4]||``).trim(),r=(t[5]||``).trim();if(!r||r===`.`||r===`..`)return null;let i=/^<(dir|junction|symlinkd)>$/i.test(n);return{name:r,isDir:i,size:i?``:n.replace(/,/g,``),mtime:`${t[1]} ${t[2]}${t[3]?` ${t[3].toUpperCase()}`:``}`.trim(),mode:i?`d`:`-`,owner:``,group:``,type:i?`dir`:`file`}}var X=[/^(total|总计)\s+\d+$/i,/^(驱动器|卷的序列号是|volume in drive|volume serial number is|directory of)/i,/^[A-Za-z]:\\.*\s+的目录$/i,/^\d+\s+(个文件|file\(s\))\s+[\d,]+\s+(字节|bytes?)$/i,/^\d+\s+(个目录|dir\(s\))\s+[\d,]+\s+(可用字节|bytes free)$/i,/^[^>\n]*>\s*dir(?:\s|$)/i];function Z(e){let t=String(e||``).split(/\n/).filter(e=>e.trim()),n=[];for(let e of t){let t=e.trim();if(X.some(e=>e.test(t)))continue;let r=e.match(/^(\S+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(\d+)\s+([A-Za-z]{3})\s+(\d{1,2})\s+(\S+)\s+(.+)$/);if(r){let t=(r[9]||``).trim();if(t===`.`||t===`..`)continue;n.push({name:t,isDir:r[1].startsWith(`d`),size:r[5],mode:r[1],mtime:J(r[6],r[7],r[8]),owner:r[3],group:r[4],type:de(r[1]),line:e});continue}let i=Y(e);if(i){n.push({...i,line:e});continue}if(!/^[bcdlps-][rwxStTs-]{9}[+.@]?\s/.test(e))continue;let a=t.split(/\s+/),o=(a.length>=9?a.slice(8).join(` `):a[a.length-1]||``).trim();o&&o!==`.`&&o!==`..`&&n.push({name:o,isDir:e.startsWith(`d`),size:a[4]||``,mode:a[0]||``,owner:a[2]||``,group:a[3]||``,mtime:a[5]&&/^[A-Za-z]{3}$/.test(a[5])?J(a[5],a[6],a[7]):``,type:de(a[0]),line:e})}return n}function Q(e){let t=String(e??``).trim();return t?(t=t.replace(/\\/g,`/`).replace(/\/{2,}/g,`/`),t.length>1&&(t=t.replace(/\/+$/,``)),/^[A-Za-z]:$/.test(t)?`${t}/`:t||`.`):`.`}function $(e,t){let n=Q(e);return t?t.startsWith(`/`)||/^[A-Za-z]:/.test(t)||n===`.`?Q(t):Q(n===`/`?`/${t}`:`${n}/${t}`):n}function fe(e){let t=Q(e);if(t===`.`||t===`/`||/^[A-Za-z]:\/$/.test(t))return t;let n=t.lastIndexOf(`/`);if(n<0)return`.`;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?`${r}/`:r}function pe(e){let t=Q(e),n=/^[A-Za-z]:/.test(t),r=!n&&t.startsWith(`/`),i=n?t.replace(/^[A-Za-z]:\/?/,``):t.replace(/^\//,``),a=t===`.`||t===`/`||!i?[]:i.split(`/`),o=[{label:n?t.slice(0,2)+`/`:r?`/`:`.`,path:n?`${t.slice(0,2)}/`:r?`/`:`.`}];return a.forEach((e,i)=>{let s=a.slice(0,i+1).join(`/`);o.push({label:e,path:n?`${t.slice(0,2)}/${s}`:r?`/${s}`:s})}),o}var{Text:me}=u;function he(e,t){let n=new Blob([t],{type:`application/octet-stream`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e||`download.bin`,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function ge({connection:e,canWrite:t}){let n=x(),[r,c]=(0,M.useState)(`.`),[l,u]=(0,M.useState)(`.`),[f,p]=(0,M.useState)(``),[m,h]=(0,M.useState)([]),[v,y]=(0,M.useState)(!1),[b,C]=(0,M.useState)(null),[E,te]=(0,M.useState)(``),[D,O]=(0,M.useState)({visible:!1,mode:`read`,path:``,content:``,loading:!1}),[N,P]=(0,M.useState)({visible:!1,mode:`mkdir`,title:``,value:``,target:``}),F=(0,M.useCallback)(async t=>{if(!e?.id)return;let n=Q(t??r);y(!0),C(null);try{let t=await R({connection:e,action:`list`,path:n});if(!t?.ok&&t?.error){C(t.error),h([]),p(t.output||``);return}p(t?.output||``),h(Z(t?.output||``)),c(n),u(n)}catch(e){C(e),h([])}finally{y(!1)}},[e,r]);(0,M.useEffect)(()=>{c(`.`),u(`.`),h([]),p(``),F(`.`)},[e?.id]);let re=async t=>{try{let n=await R({connection:e,action:`read`,path:t});return n?.error&&!n?.ok?(w(n.error),null):n?.output??``}catch(e){return w(e),null}},I=async(e,t)=>{O({visible:!0,mode:t,path:e,content:``,loading:!0});let n=await re(e);O(e=>({...e,content:n??``,loading:!1}))},ie=async()=>{try{let t=await R({connection:e,action:`write`,path:D.path,content:D.content});if(t?.error&&!t?.ok){w(t.error);return}A(n(`webshell.saveFile`,null,`已保存`)),O(e=>({...e,visible:!1})),F(r)}catch(e){w(e)}},L=async(e,t)=>{let n=await re(e);n!==null&&he(t,n)},z=t=>{j({title:n(`webshell.deleteFile`,null,`删除文件`),content:t,onOk:async()=>{try{let i=await R({connection:e,action:`delete`,path:t});if(i?.error&&!i?.ok){w(i.error);return}A(n(`webshell.deleteFile`,null,`已删除`)),F(r)}catch(e){w(e)}}})},ae=async()=>{let t=String(N.value||``).trim();if(!t)S(n(`webshell.filePath`,null,`请填写路径`));else try{if(N.mode===`mkdir`){let i=await R({connection:e,action:`mkdir`,path:$(r,t)});if(i?.error&&!i?.ok){w(i.error);return}A(n(`webshell.newDir`,null,`目录已创建`))}else if(N.mode===`create`){let i=await R({connection:e,action:`write`,path:$(r,t),content:``});if(i?.error&&!i?.ok){w(i.error);return}A(n(`webshell.newFile`,null,`文件已创建`))}else if(N.mode===`rename`){let r=await R({connection:e,action:`rename`,path:N.target,targetPath:$(fe(N.target),t)});if(r?.error&&!r?.ok){w(r.error);return}A(n(`webshell.rename`,null,`已重命名`))}P(e=>({...e,visible:!1})),F(r)}catch(e){w(e)}},B=(0,M.useMemo)(()=>{let e=E.trim().toLowerCase();return e?m.filter(t=>t.name.toLowerCase().includes(e)):m},[m,E]),oe=(0,M.useMemo)(()=>pe(r),[r]),se=[{title:n(`webshell.colName`,null,`名称`),dataIndex:`name`,render:(e,t)=>(0,V.jsxs)(`button`,{type:`button`,className:`webshell-file-name ${t.isDir?`is-dir`:`is-file`}`,onClick:()=>t.isDir?F($(r,e)):I($(r,e),`read`),title:e,children:[e,t.isDir?`/`:``]})},{title:n(`webshell.colType`,null,`类型`),dataIndex:`type`,width:90},{title:n(`webshell.colSize`,null,`大小`),dataIndex:`size`,width:110},{title:n(`webshell.colModifiedAt`,null,`修改时间`),dataIndex:`mtime`,width:170},{title:n(`webshell.colOwner`,null,`所有者`),dataIndex:`owner`,width:120},{title:n(`webshell.colPerms`,null,`权限`),dataIndex:`mode`,width:130},{title:n(`webshell.moreActions`,null,`操作`),dataIndex:`ops`,width:240,render:(e,a)=>{let s=$(r,a.name);return(0,V.jsxs)(i,{spacing:4,wrap:!0,children:[a.isDir?(0,V.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>F(s),children:n(`webshell.listDir`,null,`打开`)}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>I(s,`read`),children:n(`webshell.readFile`,null,`读取`)}),(0,V.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>I(s,`write`),children:n(`webshell.editFile`,null,`编辑`)}),(0,V.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>L(s,a.name),children:n(`webshell.downloadFile`,null,`下载`)})]}),(0,V.jsx)(o,{size:`small`,theme:`borderless`,disabled:!t,onClick:()=>P({visible:!0,mode:`rename`,title:n(`webshell.rename`,null,`重命名`),value:a.name,target:s}),children:n(`webshell.rename`,null,`重命名`)}),!a.isDir&&(0,V.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!t,onClick:()=>z(s),children:n(`webshell.deleteFile`,null,`删除`)})]})}}];return(0,V.jsxs)(`div`,{className:`webshell-files`,children:[(0,V.jsx)(`div`,{className:`webshell-file-toolbar`,children:(0,V.jsxs)(i,{spacing:8,wrap:!0,children:[(0,V.jsx)(o,{size:`small`,onClick:()=>F(fe(r)),children:n(`webshell.parentDir`,null,`上级目录`)}),(0,V.jsx)(o,{size:`small`,icon:(0,V.jsx)(g,{}),onClick:()=>F(r),loading:v,children:n(`webshell.refresh`,null,`刷新`)}),(0,V.jsx)(o,{size:`small`,disabled:!t,onClick:()=>P({visible:!0,mode:`mkdir`,title:n(`webshell.newDir`,null,`新建目录`),value:``,target:``}),children:n(`webshell.newDir`,null,`新建目录`)}),(0,V.jsx)(o,{size:`small`,disabled:!t,onClick:()=>P({visible:!0,mode:`create`,title:n(`webshell.newFile`,null,`新建文件`),value:``,target:``}),children:n(`webshell.newFile`,null,`新建文件`)})]})}),(0,V.jsxs)(`div`,{className:`webshell-file-pathbar`,children:[(0,V.jsx)(me,{type:`tertiary`,children:n(`webshell.filePath`,null,`当前路径`)}),(0,V.jsx)(a,{value:l,onChange:u,onEnterPress:()=>F(l),size:`small`,className:`webshell-file-path-input`}),(0,V.jsx)(o,{size:`small`,icon:(0,V.jsx)(d,{}),onClick:()=>F(l),children:n(`webshell.listDir`,null,`列出目录`)}),(0,V.jsx)(a,{value:E,onChange:te,placeholder:n(`webshell.filterPlaceholder`,null,`过滤文件名`),size:`small`,className:`webshell-file-filter`})]}),(0,V.jsx)(`nav`,{className:`webshell-breadcrumb`,"aria-label":`breadcrumb`,children:oe.map((e,t)=>(0,V.jsxs)(`span`,{className:`webshell-breadcrumb-item`,children:[t>0&&(0,V.jsx)(`span`,{className:`webshell-breadcrumb-sep`,children:`/`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>F(e.path),title:e.path,children:t===0?n(`webshell.breadcrumbHome`,null,`根`):e.label})]},e.path))}),(0,V.jsx)(ee,{error:b,onRetry:()=>F(r)}),m.length===0&&f.trim()&&!v?(0,V.jsx)(ne,{title:n(`webshell.filePath`,null,`原始输出`),value:f}):(0,V.jsx)(k,{columns:se,dataSource:B,rowKey:`name`,loading:v,pagination:{pageSize:20},emptyText:n(`webshell.emptyDir`,null,`目录为空`)}),(0,V.jsxs)(T,{visible:D.visible,title:D.mode===`write`?n(`webshell.editFile`,null,`编辑文件`):n(`webshell.readFile`,null,`读取文件`),width:760,onCancel:()=>O(e=>({...e,visible:!1})),footer:(0,V.jsxs)(i,{children:[(0,V.jsx)(o,{onClick:()=>O(e=>({...e,visible:!1})),children:n(`webshell.cancelEdit`,null,`关闭`)}),D.mode===`write`&&(0,V.jsx)(o,{theme:`solid`,type:`primary`,disabled:!t,onClick:ie,children:n(`webshell.saveFile`,null,`保存`)})]}),children:[(0,V.jsx)(`div`,{className:`webshell-editor-path`,children:(0,V.jsx)(s,{size:`small`,children:D.path})}),(0,V.jsx)(_,{value:D.content,onChange:e=>O(t=>({...t,content:e})),autosize:{minRows:12,maxRows:24},disabled:D.mode!==`write`,className:`webshell-editor-area`})]}),(0,V.jsx)(T,{visible:N.visible,title:N.title,width:420,onCancel:()=>P(e=>({...e,visible:!1})),onOk:ae,children:(0,V.jsx)(a,{value:N.value,onChange:e=>P(t=>({...t,value:e})),placeholder:N.mode===`rename`?n(`webshell.rename`,null,`新名称`):n(`webshell.filePath`,null,`名称或路径`)})})]})}var _e=0,ve=()=>(_e+=1,_e);function ye({connection:e,canWrite:t,onRecordCommand:n}){let r=x(),[c,l]=(0,M.useState)([]),[u,d]=(0,M.useState)(``),[f,p]=(0,M.useState)(!1),m=(0,M.useRef)(null),g=(0,M.useCallback)(e=>{l(t=>[...t,{id:ve(),...e}])},[]);(0,M.useEffect)(()=>{l([]),d(``)},[e?.id]),(0,M.useEffect)(()=>{let e=m.current;e&&(e.scrollTop=e.scrollHeight)},[c]);let _=async i=>{let a=String(i??u).trim();if(a){if(!t)S(r(`webshell.webshellWriteRequired`,null,`当前账号没有执行权限`));else{d(``),g({kind:`cmd`,text:a}),n?.(a),p(!0);try{let t=await L({connection:e,command:a});t?.output&&g({kind:`out`,text:t.output}),t?.error&&g({kind:`err`,text:t.error}),!t?.ok&&!t?.error&&g({kind:`err`,text:r(`webshell.execError`,null,`执行失败`)})}catch(e){g({kind:`err`,text:e?.message||r(`webshell.execError`,null,`执行失败`)}),w(e)}finally{p(!1)}}}};return(0,V.jsxs)(`div`,{className:`webshell-terminal`,children:[(0,V.jsx)(`div`,{className:`webshell-terminal-bar`,children:(0,V.jsxs)(i,{spacing:8,children:[(0,V.jsx)(s,{size:`small`,color:f?`amber`:`green`,children:f?r(`webshell.terminalRunning`,null,`执行中`):r(`webshell.terminalIdle`,null,`空闲`)}),(0,V.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>l([]),children:r(`webshell.clearScreen`,null,`清屏`)}),(0,V.jsx)(o,{size:`small`,theme:`borderless`,onClick:async()=>{let e=c.map(e=>e.kind===`cmd`?`$ ${e.text}`:e.text).join(`
`);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:m,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)),f&&(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:d,onEnterPress:()=>f?S(r(`webshell.waitFinish`,null,`请等待当前命令执行完成`)):_(),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`l`&&(e.preventDefault(),l([]))},placeholder:r(`webshell.commandPlaceholder`,null,`输入命令后回车执行`),disabled:f||!t,prefix:`$`}),(0,V.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,V.jsx)(h,{}),loading:f,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.createdAt)})]}),(0,V.jsx)(E,{content:e.content||``})]},e.id||`${e.role}-${e.createdAt}`))]})]})}var{Text:Te}=u,Ee={auto:`自动`,"utf-8":`UTF-8`,gbk:`GBK`,gb18030:`GB18030`};function De(e){return e===`online`?`green`:e===`probing`?`amber`:e===`offline`?`red`:`grey`}function Oe(){let e=x(),{hasPermission:t}=y(),n=t(`webshell:write`),u=t(`webshell:delete`)||n,[m,h]=r(),v=m.get(`id`)||``,[b,T]=(0,M.useState)(``),E=te(b,250),[D,k]=(0,M.useState)({}),[ne,L]=(0,M.useState)(!1),[R,z]=(0,M.useState)({visible:!1,record:null}),[ae,B]=(0,M.useState)(!1),[se,le]=(0,M.useState)([]),[H,U]=(0,M.useState)(``),[W,G]=(0,M.useState)([]),K=(0,M.useRef)(null),{data:q,loading:J,error:de,reload:Y}=C(()=>N(),[]),X=(0,M.useMemo)(()=>Array.isArray(q)?q:[],[q]);(0,M.useEffect)(()=>{oe().then(le)},[]);let Z=(0,M.useMemo)(()=>X.find(e=>e.id===v)||null,[X,v]),Q=e=>{let t=new URLSearchParams(m);e?t.set(`id`,e):t.delete(`id`),h(t,{replace:!0})},$=(0,M.useCallback)(e=>{n&&v&&(K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{ie(v,e).catch(()=>{})},700))},[n,v]);(0,M.useEffect)(()=>{let e=!1;return U(``),G([]),v&&I(v).then(t=>{if(e)return;let n=t?.state||{};U(typeof n.memo==`string`?n.memo:``),G(Array.isArray(n.commands)?n.commands:[])}).catch(()=>{}),()=>{e=!0}},[v]);let fe=e=>{U(e),$({memo:e,commands:W})},pe=e=>{let t=[...W,{command:e,at:new Date().toISOString()}].slice(-200);G(t),$({memo:H,commands:t})},me=e=>{let t=W.filter((t,n)=>`${n}-${t.at}`!==e);G(t),$({memo:H,commands:t})},he=()=>{j({title:e(`webshell.clearHistory`,null,`清空历史`),content:e(`webshell.clearHistoryConfirm`,null,`确定清空该连接的命令历史?`),onOk:()=>{G([]),$({memo:H,commands:[]})}})},_e=async e=>{k(t=>({...t,[e.id]:`probing`}));try{let t=await ce(e);return k(n=>({...n,[e.id]:t.ok?`online`:`offline`})),t.ok}catch{return k(t=>({...t,[e.id]:`offline`})),!1}},ve=async()=>{if(!X.length)S(e(`webshell.probeNoConnections`,null,`暂无可探活连接`));else{L(!0);for(let e of X)await _e(e);L(!1)}},be=async t=>{B(!0);try{if(R.record?.id)await F(R.record.id,t),A(e(`webshell.toastUpdated`,null,`连接已更新`));else{let n=await P(t);A(e(`webshell.toastCreated`,null,`连接已创建`)),n?.id&&Q(n.id)}z({visible:!1,record:null}),Y()}catch(t){w(t,e(`webshell.saveFailed`,null,`保存失败`))}finally{B(!1)}},Se=t=>{j({title:e(`webshell.deleteConfirm`,null,`确定要删除该连接吗?`),content:t.url,onOk:async()=>{try{await re(t.id),A(e(`webshell.toastDeleted`,null,`连接已删除`)),t.id===v&&Q(``),Y()}catch(e){w(e)}}})},Ce=(0,M.useMemo)(()=>{let e=E.trim().toLowerCase();return e?X.filter(t=>[t.url,t.remark,t.type,t.id].filter(Boolean).some(t=>String(t).toLowerCase().includes(e))):X},[X,E]),Oe=[{tab:e(`webshell.tabTerminal`,null,`虚拟终端`),itemKey:`terminal`,children:Z?(0,V.jsx)(ye,{connection:Z,canWrite:n,onRecordCommand:pe}):null},{tab:e(`webshell.tabFileManager`,null,`文件管理`),itemKey:`files`,children:Z?(0,V.jsx)(ge,{connection:Z,canWrite:n}):null},{tab:e(`webshell.tabHistory`,null,`命令历史`),itemKey:`history`,children:(0,V.jsx)(xe,{history:W,onRemove:me,onClear:n?he:null,onRun:e=>Z?pe(e):null})},{tab:e(`webshell.tabAiSessions`,null,`AI 会话`),itemKey:`ai`,children:Z?(0,V.jsx)(we,{connection:Z}):null},{tab:e(`webshell.tabMemo`,null,`备忘录`),itemKey:`memo`,children:(0,V.jsx)(_,{value:H,onChange:fe,autosize:{minRows:10,maxRows:20},placeholder:e(`webshell.aiMemoPlaceholder`,null,`记录关键命令、测试思路、复现步骤...`),disabled:!n})}];return(0,V.jsxs)(`div`,{className:`webshell-page`,id:`page-webshell`,children:[(0,V.jsx)(O,{title:e(`webshell.title`,null,`WebShell 管理`),description:e(`webshell.pageDesc`,null,`统一管理 WebShell 连接,代理执行命令并浏览目标文件`),extra:[(0,V.jsx)(o,{icon:(0,V.jsx)(g,{}),onClick:Y,loading:J,children:e(`webshell.refresh`,null,`刷新`)},`refresh`),(0,V.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,V.jsx)(p,{}),disabled:!n,onClick:()=>z({visible:!0,record:null}),children:e(`webshell.addConnection`,null,`添加连接`)},`add`)]}),(0,V.jsx)(ee,{error:de,onRetry:Y}),(0,V.jsxs)(`div`,{className:`webshell-layout`,children:[(0,V.jsxs)(`aside`,{className:`webshell-sidebar`,children:[(0,V.jsxs)(`div`,{className:`webshell-sidebar-head`,children:[(0,V.jsx)(Te,{strong:!0,children:e(`webshell.connections`,null,`连接列表`)}),(0,V.jsx)(s,{size:`small`,children:X.length})]}),(0,V.jsx)(a,{value:b,onChange:T,prefix:(0,V.jsx)(d,{}),placeholder:e(`webshell.searchPlaceholder`,null,`搜索连接...`),size:`small`}),(0,V.jsx)(o,{size:`small`,theme:`borderless`,loading:ne,onClick:ve,disabled:!X.length,children:e(`webshell.batchProbe`,null,`一键批量探活`)}),(0,V.jsxs)(`div`,{className:`webshell-conn-list`,children:[J&&!X.length&&(0,V.jsx)(`div`,{className:`webshell-conn-loading`,children:(0,V.jsx)(l,{})}),!J&&Ce.length===0&&(0,V.jsx)(Te,{type:`tertiary`,className:`webshell-conn-empty`,children:X.length?e(`webshell.noMatchConnections`,null,`暂无匹配连接`):e(`webshell.noConnections`,null,`暂无连接,请点击「添加连接」`)}),Ce.map(t=>(0,V.jsxs)(`button`,{type:`button`,className:`webshell-conn-item ${t.id===v?`is-active`:``}`,onClick:()=>Q(t.id),children:[(0,V.jsx)(`span`,{className:`webshell-conn-url`,title:t.url,children:t.remark||t.url}),(0,V.jsxs)(`span`,{className:`webshell-conn-meta`,children:[(0,V.jsx)(s,{size:`small`,color:`blue`,children:String(t.type||`php`).toUpperCase()}),D[t.id]&&(0,V.jsx)(s,{size:`small`,color:De(D[t.id]),children:D[t.id]===`online`?e(`webshell.probeOnline`,null,`在线`):D[t.id]===`probing`?e(`webshell.probeRunning`,null,`探活中`):e(`webshell.probeOffline`,null,`离线`)})]})]},t.id))]})]}),(0,V.jsx)(`section`,{className:`webshell-main`,children:Z?(0,V.jsxs)(`div`,{className:`webshell-workspace`,children:[(0,V.jsxs)(`div`,{className:`webshell-workspace-head`,children:[(0,V.jsxs)(`div`,{className:`webshell-workspace-title`,children:[(0,V.jsx)(Te,{strong:!0,ellipsis:{showTooltip:!0},className:`webshell-workspace-url`,children:Z.url}),(0,V.jsxs)(i,{spacing:6,wrap:!0,children:[(0,V.jsx)(s,{size:`small`,color:`blue`,children:String(Z.type||`php`).toUpperCase()}),(0,V.jsx)(s,{size:`small`,children:String(Z.method||`post`).toUpperCase()}),(0,V.jsx)(s,{size:`small`,children:Ee[Z.encoding]||`自动`}),(0,V.jsx)(s,{size:`small`,children:Z.os===`windows`?`Windows`:Z.os===`linux`?`Linux`:`OS 自动`}),Z.remark&&(0,V.jsx)(Te,{type:`tertiary`,size:`small`,children:Z.remark})]})]}),(0,V.jsxs)(i,{spacing:8,children:[(0,V.jsx)(o,{size:`small`,loading:D[Z.id]===`probing`,onClick:()=>_e(Z),children:e(`webshell.testConnectivity`,null,`测试连通性`)}),(0,V.jsx)(o,{size:`small`,disabled:!n,onClick:()=>z({visible:!0,record:Z}),children:e(`webshell.editConnection`,null,`编辑`)}),(0,V.jsx)(o,{size:`small`,type:`danger`,disabled:!u,onClick:()=>Se(Z),children:e(`webshell.deleteFile`,null,`删除`)})]})]}),(0,V.jsx)(f,{type:`line`,defaultActiveKey:`terminal`,className:`webshell-tabs`,items:Oe},Z.id)]}):(0,V.jsx)(c,{title:e(`webshell.selectOrAdd`,null,`请从左侧选择连接,或添加新的 WebShell 连接`),description:null,style:{padding:64}})})]}),(0,V.jsx)(ue,{visible:R.visible,record:R.record,projects:se,submitting:ae,onCancel:()=>z({visible:!1,record:null}),onSubmit:be})]})}export{Oe as default};
\ No newline at end of file
diff --git a/web/static/app/assets/workflows-BD0hFUmU.js b/web/static/app/assets/workflows-BD0hFUmU.js
new file mode 100644
index 00000000..c0cf0f4e
--- /dev/null
+++ b/web/static/app/assets/workflows-BD0hFUmU.js
@@ -0,0 +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,at as u,b as d,c as f,ct as p,f as m,l as h,m as g,ot as _,p as v,s as y,u as b,x,z as S}from"./semi-CXF9U6uC.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-LQJrYSgy.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(),u=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){let e=t.graph_json||``;try{e=JSON.stringify(JSON.parse(e),null,2)}catch{}p({id:t.id||``,name:t.name||``,description:t.description||``,version:t.version||1,enabled:t.enabled!==!1,graph:e})}else p({...de,graph:JSON.stringify(V,null,2)})}},[e,t]);let C=e=>p(t=>({...t,...e})),E=(0,R.useMemo)(()=>ae(f.graph),[f.graph]);return(0,Y.jsxs)(te,{visible:e,title:b?s(`workflows.metaModalTitle`,null,`工作流信息`):s(`workflows.newGraph`,null,`新建工作流`),onCancel:n,onOk:async()=>{let e=(b?t.id:f.id).trim(),n=f.name.trim();if(!e||!n)k(s(`workflows.idNameRequired`,null,`工作流 ID 和名称不能为空`));else if(!b&&!ue.test(e))k(`工作流 ID 必须以字母或数字开头,仅含字母、数字、下划线、连字符`);else{if(f.graph.trim())try{JSON.parse(f.graph)}catch(e){k(`graph 必须是合法 JSON:${J(e,``)}`);return}h(!0);try{let t={id:e,name:n,description:f.description,version:Number(f.version)||0,enabled:!!f.enabled,graph:f.graph.trim()?JSON.parse(f.graph):void 0},i=b?await T.put(`/workflows/${encodeURIComponent(e)}`,t):await T.post(`/workflows`,t);I(s(`workflows.saved`,null,`工作流已保存`)),r?.(i?.workflow||null)}catch(e){k(J(e,s(`workflows.saveFailed`,null,`保存工作流失败`)))}finally{h(!1)}}},okText:s(`common.save`,null,`保存`),cancelText:s(`common.cancel`,null,`取消`),confirmLoading:m,width:860,children:[(0,Y.jsxs)(`div`,{className:`workflow-form-grid`,children:[(0,Y.jsxs)(`div`,{className:`workflow-form-field`,children:[(0,Y.jsx)(X,{strong:!0,size:`small`,children:s(`workflows.metaId`,null,`ID`)}),(0,Y.jsx)(a,{value:f.id,disabled:b,placeholder:`web-scan-basic`,onChange:e=>C({id:e})}),(0,Y.jsx)(X,{type:`tertiary`,size:`small`,children:s(`workflows.metaIdHint`,null,`创建后不可修改,用于 API 与角色绑定`)})]}),(0,Y.jsxs)(`div`,{className:`workflow-form-field`,children:[(0,Y.jsx)(X,{strong:!0,size:`small`,children:s(`workflows.metaName`,null,`名称`)}),(0,Y.jsx)(a,{value:f.name,placeholder:s(`workflows.namePlaceholder`,null,`基础 Web 扫描`),onChange:e=>C({name:e})})]})]}),(0,Y.jsxs)(`div`,{className:`workflow-form-grid`,children:[(0,Y.jsxs)(`div`,{className:`workflow-form-field`,children:[(0,Y.jsx)(X,{strong:!0,size:`small`,children:s(`workflows.metaDescription`,null,`描述`)}),(0,Y.jsx)(a,{value:f.description,placeholder:s(`workflows.descriptionPlaceholder`,null,`可选`),onChange:e=>C({description:e})})]}),(0,Y.jsxs)(`div`,{className:`workflow-form-grid workflow-form-grid--tight`,children:[(0,Y.jsxs)(`div`,{className:`workflow-form-field`,children:[(0,Y.jsx)(X,{strong:!0,size:`small`,children:`版本`}),(0,Y.jsx)(d,{value:f.version,min:0,style:{width:`100%`},onChange:e=>C({version:e||0})})]}),(0,Y.jsxs)(`div`,{className:`workflow-form-field`,children:[(0,Y.jsx)(X,{strong:!0,size:`small`,children:s(`workflows.metaEnabled`,null,`启用`)}),(0,Y.jsx)(c,{checked:f.enabled,onChange:e=>C({enabled:e.target.checked}),children:s(`workflows.metaEnabledHint`,null,`禁用后无法被角色自动触发`)})]})]})]}),(0,Y.jsxs)(`div`,{className:`workflow-form-field`,children:[(0,Y.jsxs)(i,{children:[(0,Y.jsx)(X,{strong:!0,size:`small`,children:`graph JSON`}),(0,Y.jsx)(X,{type:`tertiary`,size:`small`,children:E.error?`解析失败:${E.error}`:`${E.nodes.length} 个节点 · ${E.edges.length} 条连线`})]}),(0,Y.jsx)(x,{value:f.graph,rows:16,spellCheck:!1,className:`workflow-graph-input`,placeholder:`{"nodes":[],"edges":[],"config":{}}`,onChange:e=>{C({graph:e}),y(null)}}),(0,Y.jsxs)(i,{wrap:!0,children:[(0,Y.jsx)(o,{size:`small`,onClick:()=>{try{C({graph:JSON.stringify(JSON.parse(f.graph),null,2)}),y(null)}catch(e){k(`${s(`projects.invalidJson`,null,`JSON 格式无效`)}:${J(e,``)}`)}},children:s(`projects.formatJson`,null,`格式化`)}),(0,Y.jsx)(o,{size:`small`,onClick:()=>{C({graph:JSON.stringify(V,null,2)}),y(null)},children:`插入最小模板`}),(0,Y.jsx)(o,{size:`small`,loading:g,disabled:!u,title:u?``:`需要 workflow:execute 权限`,onClick:async()=>{if(!f.graph.trim()){y({type:`danger`,text:s(`workflows.validation.serverFailed`,null,`图定义不能为空`)});return}let e;try{e=JSON.parse(f.graph)}catch(e){y({type:`danger`,text:`JSON 解析失败:${J(e,``)}`});return}_(!0),y(null);try{await T.post(`/workflows/validate`,{graph:e}),y({type:`success`,text:`结构校验通过`})}catch(e){y({type:`danger`,text:J(e,s(`workflows.validation.serverFailed`,null,`后端图校验失败`))})}finally{_(!1)}},children:s(`workflows.validate`,null,`校验图定义`)}),(0,Y.jsxs)(X,{type:`tertiary`,size:`small`,children:[`节点类型:`,z.map(e=>e.label).join(` / `)]})]})]}),v?(0,Y.jsx)(S,{type:v.type,bordered:!0,closeIcon:null,description:v.text,style:{marginTop:12}}):null]})}var{Text:Z}=l;function pe({raw:e}){let t=(0,R.useMemo)(()=>ae(e),[e]);if(t.error)return(0,Y.jsxs)(Z,{type:`danger`,size:`small`,children:[`graph 解析失败:`,t.error]});let n=t.nodes.map(e=>({id:e.id,type:e.type||`tool`,label:e.label||``,config:e.config||{}}));return(0,Y.jsxs)(`div`,{className:`workflow-detail-stack`,children:[(0,Y.jsx)(h,{columns:[{title:`节点`,dataIndex:`id`,width:160,render:e=>(0,Y.jsx)(`code`,{children:e})},{title:`类型`,dataIndex:`type`,width:90,render:e=>(0,Y.jsx)(s,{size:`small`,color:`blue`,type:`light`,children:ie[e]||e})},{title:`名称`,dataIndex:`label`,render:(e,t)=>(0,Y.jsx)(`span`,{className:`workflow-cell-ellipsis`,title:e||t.id,children:e||`—`})}],dataSource:n,rowKey:`id`,size:`small`,pagination:!1,empty:(0,Y.jsx)(Z,{type:`tertiary`,size:`small`,children:`图内没有节点`})}),(0,Y.jsxs)(`div`,{className:`workflow-edge-list`,children:[(0,Y.jsxs)(Z,{strong:!0,size:`small`,children:[`连线(`,t.edges.length,`)`]}),t.edges.length?(0,Y.jsx)(`ul`,{className:`workflow-link-list`,children:t.edges.map((e,t)=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{children:e.source}),` → `,(0,Y.jsx)(`code`,{children:e.target}),e.label?(0,Y.jsx)(`span`,{className:`workflow-edge-label`,children:e.label}):null]},e.id||`${e.source}-${e.target}-${t}`))}):(0,Y.jsx)(Z,{type:`tertiary`,size:`small`,children:`暂无连线`})]})]})}function me({workflowId:e,visible:t,canWrite:n,canDelete:r,onClose:a,onEdit:c,onDeleted:l}){let u=D(),[d,f]=(0,R.useState)(!1),p=O(()=>e?T.get(`/workflows/${encodeURIComponent(e)}`):Promise.resolve(null),[e]),h=p.data?.workflow||null;return(0,R.useEffect)(()=>{t&&e&&p.reload({silent:!0})},[t,e]),(0,Y.jsxs)(m,{visible:t,width:760,title:h?h.name||h.id:u(`workflows.metaModalTitle`,null,`工作流信息`),onCancel:a,footer:(0,Y.jsxs)(i,{children:[(0,Y.jsx)(o,{disabled:!n||!h,onClick:()=>c?.(h),children:u(`common.edit`,null,`编辑`)}),(0,Y.jsx)(o,{loading:d,disabled:!h,onClick:async()=>{if(h){f(!0);try{await E(`/workflows/${encodeURIComponent(h.id)}/package`,{filename:`${h.id}.csapkg.zip`}),I(u(`workflows.package.export`,null,`导出`))}catch(e){k(J(e,u(`workflows.package.errors.exportFailed`,null,`导出失败,请稍后重试。`)))}finally{f(!1)}}},children:u(`workflows.package.export`,null,`导出`)}),(0,Y.jsx)(o,{type:`danger`,disabled:!r||!h,onClick:()=>L({title:u(`workflows.deleteWorkflow`,null,`删除工作流`),content:u(`workflows.confirmDelete`,{id:h?.id},`确定删除工作流 ${h?.id}?`),okText:u(`common.delete`,null,`删除`),onOk:async()=>{try{await T.del(`/workflows/${encodeURIComponent(h.id)}`),I(u(`workflows.deleted`,null,`工作流已删除`)),l?.(h.id)}catch(e){k(J(e,u(`workflows.deleteFailed`,null,`删除工作流失败`)))}}}),children:u(`workflows.deleteWorkflow`,null,`删除工作流`)}),(0,Y.jsx)(o,{onClick:a,children:u(`common.close`,null,`关闭`)})]}),children:[(0,Y.jsx)(j,{error:oe(p.error),onRetry:()=>p.reload()}),h?(0,Y.jsxs)(`div`,{className:`workflow-detail-stack`,children:[(0,Y.jsxs)(`div`,{className:`workflow-detail-tags`,children:[(0,Y.jsx)(s,{size:`small`,color:h.enabled?`green`:`grey`,children:h.enabled?u(`workflows.statusEnabled`,null,`启用`):u(`workflows.statusDisabled`,null,`禁用`)}),h.validation_error?(0,Y.jsx)(s,{size:`small`,color:`red`,children:u(`workflows.statusInvalid`,null,`校验未通过`)}):(0,Y.jsx)(s,{size:`small`,color:`green`,type:`light`,children:`结构有效`}),(0,Y.jsxs)(Z,{type:`tertiary`,size:`small`,children:[`版本 `,h.version||0]})]}),h.validation_error?(0,Y.jsx)(j,{error:{message:h.validation_error}}):null,(0,Y.jsx)(A,{columns:2,items:[{label:u(`workflows.metaId`,null,`ID`),value:(0,Y.jsx)(`code`,{children:h.id})},{label:u(`workflows.metaName`,null,`名称`),value:h.name||`—`},{label:u(`workflows.updated`,null,`更新`),value:C(h.updated_at)},{label:`创建`,value:C(h.created_at)},{label:u(`workflows.metaDescription`,null,`描述`),value:h.description||`—`}]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(Z,{strong:!0,children:u(`workflows.nodeProperties`,null,`节点属性`)}),(0,Y.jsx)(pe,{raw:h.graph_json})]}),(0,Y.jsx)(F,{value:h.graph_json?he(h.graph_json):{},title:`graph JSON`,collapsed:!0})]}):null]})}function he(e){try{return JSON.parse(e)}catch{return{raw:e}}}var{Text:Q}=l;function ge(e){let t=B[String(e||``)]||{label:e||`—`,color:`grey`};return(0,Y.jsx)(s,{size:`small`,color:t.color,children:t.label})}function _e({runId:e,visible:t,canExecute:n,onClose:r,onChanged:a}){let s=D(),[c,l]=(0,R.useState)(``),[u,d]=(0,R.useState)(!1),f=O(()=>e?T.get(`/workflows/runs/${encodeURIComponent(e)}`):Promise.resolve(null),[e]),p=O(()=>e?T.get(`/workflows/runs/${encodeURIComponent(e)}/replay`):Promise.resolve(null),[e]),h=f.data?.run||null;(0,R.useEffect)(()=>{t&&e&&(f.reload({silent:!0}),p.reload({silent:!0}))},[t,e]);let g=f.data?.nodeRuns||[],_=p.data?.steps||[],v=t=>L({title:t?`通过审批`:`拒绝审批`,content:t?`确认通过该工作流的审批节点并继续执行?`:`确认拒绝该工作流的审批节点?运行将以失败结束。`,okText:s(`common.confirm`,null,`确认`),danger:!t,onOk:async()=>{d(!0);try{await T.post(`/workflows/runs/${encodeURIComponent(e)}/resume`,{approved:t,comment:c}),I(t?`已通过审批`:`已拒绝审批`),l(``),f.reload({silent:!0}),p.reload({silent:!0}),a?.()}catch(e){k(J(e,`审批提交失败`))}finally{d(!1)}}});return(0,Y.jsxs)(m,{visible:t,width:820,title:s(`workflows.dryRunTrace`,null,`运行轨迹`),onCancel:r,footer:(0,Y.jsxs)(i,{children:[h?.status===`awaiting_hitl`&&n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{value:c,rows:1,placeholder:`审批备注(可选)`,onChange:e=>l(e),style:{width:240}}),(0,Y.jsx)(o,{type:`primary`,loading:u,onClick:()=>v(!0),children:`通过`}),(0,Y.jsx)(o,{type:`danger`,loading:u,onClick:()=>v(!1),children:`拒绝`})]}):null,(0,Y.jsx)(o,{onClick:r,children:s(`common.close`,null,`关闭`)})]}),children:[(0,Y.jsx)(j,{error:oe(f.error),onRetry:()=>f.reload()}),h?(0,Y.jsxs)(`div`,{className:`workflow-detail-stack`,children:[(0,Y.jsxs)(`div`,{className:`workflow-detail-tags`,children:[ge(h.status),(0,Y.jsxs)(Q,{type:`tertiary`,size:`small`,children:[`运行 `,(0,Y.jsx)(`code`,{children:q(h.id,16)})]})]}),(0,Y.jsx)(A,{columns:2,items:[{label:`工作流`,value:(0,Y.jsx)(`code`,{children:h.workflow_id})},{label:`版本`,value:h.workflow_version??`—`},{label:`会话`,value:h.conversation_id||`—`},{label:`项目`,value:h.project_id||`—`},{label:`开始时间`,value:C(h.started_at)},{label:`结束时间`,value:C(h.finished_at)},h.pending_hitl_node_id?{label:`待审批节点`,value:(0,Y.jsx)(`code`,{children:h.pending_hitl_node_id})}:null,h.error?{label:`错误`,value:(0,Y.jsx)(Q,{type:`danger`,size:`small`,children:h.error})}:null]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(Q,{strong:!0,children:[`节点执行记录(`,g.length,`)`]}),(0,Y.jsx)(y,{className:`workflow-timeline`,children:g.length?g.map(e=>(0,Y.jsx)(y.Item,{time:C(e.started_at),type:e.status===`failed`?`error`:e.status===`completed`?`success`:`ongoing`,children:(0,Y.jsxs)(`div`,{className:`workflow-timeline-item`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`code`,{children:e.node_id}),` `,ge(e.status)]}),e.error?(0,Y.jsx)(Q,{type:`danger`,size:`small`,children:e.error}):null,e.output_json?(0,Y.jsx)(F,{value:ve(e.output_json),title:`output`,collapsed:!0}):null]})},e.id)):(0,Y.jsx)(Q,{type:`tertiary`,size:`small`,children:`暂无节点执行记录`})})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(Q,{strong:!0,children:[s(`workflows.dryRunTrace`,null,`回放轨迹`),`(`,_.length,` 步)`]}),(0,Y.jsx)(y,{className:`workflow-timeline`,children:_.length?_.map(e=>(0,Y.jsx)(y.Item,{time:C(e.startedAt),type:e.status===`failed`?`error`:e.status===`completed`?`success`:`ongoing`,children:(0,Y.jsxs)(`div`,{className:`workflow-timeline-item`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(Q,{strong:!0,size:`small`,children:[`#`,e.step]}),` `,(0,Y.jsx)(`code`,{children:e.nodeId}),` `,ge(e.status)]}),e.error?(0,Y.jsx)(Q,{type:`danger`,size:`small`,children:e.error}):null,(0,Y.jsx)(F,{value:{input:e.input,output:e.output},title:`step`,collapsed:!0})]})},e.nodeRunId||`${e.step}-${e.nodeId}`)):(0,Y.jsx)(Q,{type:`tertiary`,size:`small`,children:s(`workflows.dryRunNoTrace`,null,`暂无轨迹`)})})]}),(0,Y.jsx)(F,{value:h,title:`run`,collapsed:!0})]}):null]})}function ve(e){try{return JSON.parse(e)}catch{return{raw:e}}}var{Text:ye}=l;function be({canExecute:e}){let t=D(),[n,a]=r(),c=n.get(`run`)||``,l=O(()=>T.get(`/workflows/runs/pending`),[]);N(()=>l.reload({silent:!0}),15e3);let u=Array.isArray(l.data?.runs)?l.data.runs:[],d=e=>{let t=new URLSearchParams(n);e?t.set(`run`,e):t.delete(`run`),a(t,{replace:!0})},f=[{title:`运行`,dataIndex:`id`,width:190,render:e=>(0,Y.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>d(e),children:(0,Y.jsx)(`code`,{children:q(e,14)})})},{title:`工作流`,dataIndex:`workflow_id`,width:200,render:e=>(0,Y.jsx)(ye,{size:`small`,children:(0,Y.jsx)(`code`,{children:e})})},{title:`会话`,dataIndex:`conversation_id`,width:220,render:e=>(0,Y.jsx)(ye,{type:`tertiary`,size:`small`,children:(0,Y.jsx)(`code`,{children:e||`—`})})},{title:t(`projects.status`,null,`状态`),dataIndex:`status`,width:110,render:e=>{let t=B[String(e||``)]||{label:e||`—`,color:`grey`};return(0,Y.jsx)(s,{size:`small`,color:t.color,children:t.label})}},{title:`待审批节点`,dataIndex:`pending_hitl_node_id`,width:160,render:e=>e?(0,Y.jsx)(`code`,{children:e}):(0,Y.jsx)(ye,{type:`tertiary`,children:`—`})},{title:`开始时间`,dataIndex:`started_at`,width:165,render:e=>(0,Y.jsx)(ye,{size:`small`,children:C(e)})},{title:t(`common.actions`,null,`操作`),dataIndex:`id`,width:120,render:e=>(0,Y.jsx)(i,{children:(0,Y.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>d(e),children:t(`projects.details`,null,`详情`)})})}];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(M,{title:t(`workflows.runsPending`,null,`待审批运行`),description:`等待审批(awaiting_hitl)的工作流运行,每 15 秒自动刷新。${e?` 可直接在此通过或拒绝。`:``}`,extra:(0,Y.jsx)(o,{icon:(0,Y.jsx)(_,{}),theme:`borderless`,loading:l.loading,onClick:()=>l.reload(),children:t(`common.refresh`,null,`刷新`)}),children:[(0,Y.jsx)(j,{error:oe(l.error),onRetry:()=>l.reload()}),(0,Y.jsx)(P,{columns:f,dataSource:u,rowKey:`id`,loading:l.loading,pagination:{pageSize:10},emptyText:`当前没有等待审批的工作流运行`})]}),(0,Y.jsx)(_e,{runId:c,visible:!!c,canExecute:e,onClose:()=>d(``),onChanged:()=>l.reload({silent:!0})})]})}var{Text:$,Paragraph:xe}=l,Se=10485760;function Ce(e){let t=String(e||``).replace(/^data:[^;]+;base64,/,``).replace(/\s+/g,``);if(!t)throw Error(`粘贴内容为空`);let n=atob(t),r=new Uint8Array(n.length);for(let e=0;e{e||(u(null),f(``),m(``),_(null),b(``),E(``),O(!1),N(``),F(null),j(!1),ne(!1))},[e]);let L=h?.conflict?.state||``,z=(0,R.useMemo)(()=>G(L),[L]),ie=()=>{m(``);try{let e=Ce(d);if(e.size>Se){m(r(`workflows.package.errors.fileTooLarge`,null,`文件超过 10 MiB 限制,请选择更小的本地包。`));return}u(e),_(null),F(null)}catch(e){m(`Base64 解码失败:${J(e,``)}`)}},B=e=>{let t=e.target.files&&e.target.files[0];m(``),N(``),F(null),_(null),t?t.size>Se?(m(r(`workflows.package.errors.fileTooLarge`,null,`文件超过 10 MiB 限制,请选择更小的本地包。`)),u(null)):u(t):u(null)},V=async()=>{if(!l)m(r(`workflows.package.errors.fileRequired`,null,`请选择本地工作流包后再预检。`));else{j(!0),N(``),F(null);try{let e=new FormData;e.append(`file`,l,l.name||`workflow.csapkg.zip`);let t=(await T.post(`/workflow-package-inspections`,e))?.inspection||null;_(t);let n=G(t?.conflict?.state||``);b(n[0]||``),E(``),O(!1)}catch(e){N(ce(e,r))}finally{j(!1)}}},H=async()=>{if(!h?.id){N(r(`workflows.package.resolution.needInspection`,null,`请先选择本地包并完成预检。`));return}if(!y){N(r(`workflows.package.errors.invalidAction`,null,`导入处理方式无效,请重新选择。`));return}if(y===`rename`&&!w.trim()){N(r(`workflows.package.errors.invalidRenameId`,null,`请输入可用的新工作流 ID。`));return}if(y===`overwrite`&&!ee){N(r(`workflows.package.errors.overwriteConfirmationRequired`,null,`请勾选确认后再覆盖本地工作流。`));return}let e=le();if(!e)N(r(`workflows.package.errors.idempotencyKeyRequired`,null,`浏览器无法生成导入请求标识,请刷新页面后重试。`));else{ne(!0),N(``);try{let t=await T.post(`/workflow-package-imports`,{inspection_id:h.id,resolution:{action:y,new_workflow_id:y===`rename`?w.trim():``},confirm_overwrite:y===`overwrite`},{headers:{"Idempotency-Key":e}});F(t?.import||null),I(r(`workflows.package.result.complete`,null,`导入已完成。`)),n?.(t?.import||null)}catch(e){N(ce(e,r))}finally{ne(!1)}}},W=L===`identical`?r(`workflows.package.conflict.identical`,null,`检测到同 ID 且内容相同的本地工作流;本次将跳过导入。`):L===`id_conflict`?r(`workflows.package.conflict.idConflict`,null,`检测到同 ID 但内容不同的本地工作流。默认保留本地版本。`):L===`none`?r(`workflows.package.conflict.none`,null,`未发现同 ID 的本地工作流,可创建导入。`):``,K=h?.workflow;return(0,Y.jsxs)(te,{visible:e,title:r(`workflows.package.title`,null,`导入本地包`),onCancel:t,width:760,maskClosable:!k&&!M,footer:(0,Y.jsxs)(i,{children:[(0,Y.jsx)(o,{onClick:t,children:r(`common.close`,null,`关闭`)}),(0,Y.jsx)(o,{type:`primary`,loading:k,disabled:!!P,onClick:V,children:k?r(`workflows.package.inspecting`,null,`正在安全预检…`):r(`workflows.package.inspect`,null,`上传并预检`)}),(0,Y.jsx)(o,{type:`primary`,loading:M,disabled:!h||!!P||!y,onClick:H,children:r(`workflows.package.confirmImport`,null,`确认导入`)})]}),children:[(0,Y.jsxs)(xe,{type:`tertiary`,size:`small`,children:[r(`workflows.package.preflightHint`,null,`先检查包内容与冲突,再由你确认是否导入`),` · `,r(`workflows.package.fileHint`,null,`仅支持单个 .csapkg.zip,文件不得超过 10 MiB。`)]}),(0,Y.jsxs)(`div`,{className:`workflow-package-block`,children:[(0,Y.jsx)($,{strong:!0,size:`small`,children:r(`workflows.package.stepInspection`,null,`上传与预检`)}),(0,Y.jsxs)(`div`,{className:`workflow-package-file-row`,children:[(0,Y.jsx)(`input`,{type:`file`,accept:`.zip,application/zip`,className:`workflow-file-input`,onChange:B,"aria-label":r(`workflows.package.selectFile`,null,`选择本地包`)}),(0,Y.jsx)($,{type:`tertiary`,size:`small`,children:l?`${l.name} · ${(l.size/1024).toFixed(1)} KiB`:r(`workflows.package.noFile`,null,`未选择文件`)}),l?(0,Y.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>{u(null),_(null),F(null)},children:r(`workflows.package.removeFile`,null,`移除文件`)}):null]}),(0,Y.jsx)(x,{value:d,rows:3,placeholder:`或粘贴工作流包 base64(.csapkg.zip)`,onChange:e=>f(e)}),(0,Y.jsxs)(i,{children:[(0,Y.jsx)(o,{size:`small`,onClick:ie,disabled:!d.trim(),children:`使用粘贴内容`}),p?(0,Y.jsx)($,{type:`danger`,size:`small`,children:p}):null]})]}),re?(0,Y.jsx)(S,{type:`danger`,bordered:!0,closeIcon:null,description:re,className:`workflow-package-banner`}):null,h?(0,Y.jsxs)(`div`,{className:`workflow-package-block`,children:[(0,Y.jsxs)(`div`,{className:`workflow-package-summary-head`,children:[(0,Y.jsx)($,{strong:!0,size:`small`,children:r(`workflows.package.summary.title`,null,`预检结果`)}),(0,Y.jsx)(s,{size:`small`,color:`green`,children:r(`workflows.package.summary.passed`,null,`校验通过`)})]}),(0,Y.jsx)(S,{type:L===`id_conflict`?`warning`:`success`,bordered:!0,closeIcon:null,description:W,className:`workflow-package-banner`}),(0,Y.jsx)(A,{columns:2,items:[{label:r(`workflows.package.summary.workflowName`,null,`工作流名称`),value:K?.name||`—`},{label:r(`workflows.package.summary.sourceId`,null,`源工作流 ID`),value:(0,Y.jsx)(`code`,{children:K?.source_id||`—`})},{label:r(`workflows.package.summary.sourceRevision`,null,`源版本`),value:K?.source_revision??`—`},{label:r(`workflows.package.summary.graphSize`,null,`图规模`),value:`${K?.node_count||0} 节点 · ${K?.edge_count||0} 连线`},{label:r(`workflows.package.summary.contentHash`,null,`内容摘要`),value:q(K?.content_hash)},{label:r(`workflows.package.summary.expiresAt`,null,`预检有效期`),value:C(h.expires_at)}]}),(0,Y.jsx)($,{strong:!0,size:`small`,children:r(`workflows.package.resolutionTitle`,null,`处理方式`)}),(0,Y.jsx)(g,{value:y,onChange:e=>{b(e.target.value),O(!1)},direction:`vertical`,children:z.map(e=>(0,Y.jsx)(v,{value:e,children:(0,Y.jsxs)(`span`,{className:`workflow-package-action`,children:[(0,Y.jsx)($,{strong:!0,size:`small`,children:U[e]?.label||e}),(0,Y.jsx)($,{type:`tertiary`,size:`small`,children:U[e]?.hint||``})]})},e))}),y===`rename`?(0,Y.jsx)(a,{value:w,placeholder:r(`workflows.package.resolution.newWorkflowIdPlaceholder`,null,`例如:web-scan-basic-copy`),onChange:e=>E(e)}):null,y===`overwrite`?(0,Y.jsxs)(`div`,{className:`workflow-package-overwrite`,children:[(0,Y.jsx)(S,{type:`warning`,bordered:!0,closeIcon:null,description:r(`workflows.package.overwriteWarning`,null,`覆盖将替换名称、描述、图定义和启用状态。本期不提供回滚。`)}),(0,Y.jsx)(c,{checked:ee,onChange:e=>O(e.target.checked),children:r(`workflows.package.overwriteCheck`,null,`我已确认覆盖当前本地工作流`)})]}):null]}):null,P?(0,Y.jsx)(S,{type:`success`,bordered:!0,closeIcon:null,className:`workflow-package-banner`,description:r(we[P.result]||`workflows.package.result.complete`,null,`导入已完成。`)}):null]})}var{Text:Ee}=l;async function De(){let[e,t]=await Promise.all([T.get(`/workflows`,{includeDisabled:`true`}),T.get(`/workflows/runs/pending`).catch(()=>null)]);return{workflows:Array.isArray(e?.workflows)?e.workflows:[],pendingRuns:Array.isArray(t?.runs)?t.runs:[]}}function Oe(){let e=D(),{hasPermission:t}=w(),n=t(`workflow:write`),c=t(`workflow:delete`),l=t(`workflow:execute`),[d,m]=r(),h=d.get(`id`)||``,g=d.get(`tab`)||`list`,[v,y]=(0,R.useState)(``),x=ne(v,250),[S,te]=(0,R.useState)(!0),[A,N]=(0,R.useState)({visible:!1,workflow:null}),[F,z]=(0,R.useState)(!1),[ie,B]=(0,R.useState)(0),V=O(De,[ie]),H=V.data?.workflows||[],U=V.data?.pendingRuns||[],W=(0,R.useCallback)((e,t)=>{let n=new URLSearchParams(d);e?n.set(`id`,e):n.delete(`id`),t?n.set(`tab`,t):n.delete(`tab`),t&&t!==`runs`&&n.delete(`run`),m(n,{replace:!!e})},[d,m]),G=()=>B(e=>e+1),K=(0,R.useMemo)(()=>{let e=x.trim().toLowerCase();return H.filter(t=>!S&&t.enabled===!1?!1:!e||[t.id,t.name,t.description].join(` `).toLowerCase().includes(e))},[H,x,S]),q=H.filter(e=>!!e.validation_error).length,se=H.filter(e=>e.enabled).length,ce=[{id:`total`,label:e(`workflows.processLibrary`,null,`工作流列表`),value:H.length,loading:V.loading},{id:`enabled`,label:e(`workflows.statusEnabled`,null,`启用`),value:se,tone:`success`,loading:V.loading},{id:`invalid`,label:e(`workflows.statusInvalid`,null,`校验未通过`),value:q,tone:q?`danger`:void 0,loading:V.loading},{id:`pending`,label:e(`workflows.runsPending`,null,`待审批运行`),value:U.length,tone:U.length?`warning`:void 0,loading:V.loading}],le=async t=>{try{await E(`/workflows/${encodeURIComponent(t.id)}/package`,{filename:`${t.id}.csapkg.zip`}),I(e(`workflows.package.export`,null,`导出`))}catch(t){k(J(t,e(`workflows.package.errors.exportFailed`,null,`导出失败,请稍后重试。`)))}},X=t=>L({title:e(`workflows.deleteWorkflow`,null,`删除工作流`),content:e(`workflows.confirmDelete`,{id:t.id},`确定删除工作流 ${t.id}?`),okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{await T.del(`/workflows/${encodeURIComponent(t.id)}`),I(e(`workflows.deleted`,null,`工作流已删除`)),h===t.id&&W(void 0,g),G()}catch(t){k(J(t,e(`workflows.deleteFailed`,null,`删除工作流失败`)))}}}),ue=[{title:e(`workflows.metaName`,null,`名称`),dataIndex:`name`,render:(t,n)=>{let r=ae(n.graph_json);return(0,Y.jsxs)(`button`,{type:`button`,className:`workflow-name-button`,onClick:()=>W(n.id,`list`),title:n.id,children:[(0,Y.jsx)(`span`,{className:`workflow-name-text`,children:t||e(`workflows.untitled`,null,`未命名工作流`)}),(0,Y.jsxs)(`span`,{className:`workflow-name-sub`,children:[(0,Y.jsx)(`code`,{children:n.id}),` · `,r.error?`图解析失败`:`${r.nodes.length} 节点 / ${r.edges.length} 连线`]})]})}},{title:e(`projects.status`,null,`状态`),dataIndex:`enabled`,width:150,render:(t,n)=>(0,Y.jsxs)(i,{spacing:4,wrap:!0,children:[(0,Y.jsx)(s,{size:`small`,color:t?`green`:`grey`,children:t?e(`workflows.statusEnabled`,null,`启用`):e(`workflows.statusDisabled`,null,`禁用`)}),n.validation_error?(0,Y.jsx)(s,{size:`small`,color:`red`,children:e(`workflows.statusInvalid`,null,`校验未通过`)}):null]})},{title:`版本`,dataIndex:`version`,width:80,render:e=>(0,Y.jsxs)(Ee,{size:`small`,children:[`v`,e??0]})},{title:e(`projects.updated`,null,`更新`),dataIndex:`updated_at`,width:165,render:e=>(0,Y.jsx)(Ee,{type:`tertiary`,size:`small`,children:C(e)})},{title:e(`common.actions`,null,`操作`),dataIndex:`id`,width:260,render:(t,r)=>(0,Y.jsxs)(i,{spacing:2,wrap:!0,children:[(0,Y.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>W(r.id,`list`),children:e(`projects.details`,null,`详情`)}),(0,Y.jsx)(o,{size:`small`,theme:`borderless`,disabled:!n,onClick:()=>N({visible:!0,workflow:r}),children:e(`common.edit`,null,`编辑`)}),(0,Y.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>le(r),children:e(`workflows.package.export`,null,`导出`)}),(0,Y.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!c,onClick:()=>X(r),children:e(`common.delete`,null,`删除`)})]})}];return(0,Y.jsxs)(`div`,{className:`workflow-page`,children:[(0,Y.jsx)(re,{title:e(`workflows.title`,null,`工作流`),description:e(`workflows.processLibraryHint`,null,`工作流定义由节点与连线组成,可被角色或对话按需触发。`),extra:(0,Y.jsxs)(i,{children:[(0,Y.jsx)(o,{icon:(0,Y.jsx)(_,{}),theme:`borderless`,loading:V.loading,onClick:G,children:e(`common.refresh`,null,`刷新`)}),(0,Y.jsx)(o,{disabled:!n,onClick:()=>z(!0),children:e(`workflows.package.importLocal`,null,`导入本地包`)}),(0,Y.jsx)(o,{type:`primary`,icon:(0,Y.jsx)(p,{}),disabled:!n,onClick:()=>N({visible:!0,workflow:null}),children:e(`workflows.newGraph`,null,`新建工作流`)})]})}),(0,Y.jsx)(j,{error:oe(V.error),onRetry:G}),(0,Y.jsx)(ee,{metrics:ce,columns:4}),(0,Y.jsx)(f,{type:`line`,activeKey:g,onChange:e=>W(void 0,e),tabList:[{itemKey:`list`,tab:e(`workflows.processLibrary`,null,`工作流列表`)},{itemKey:`runs`,tab:e(`workflows.runsPending`,null,`运行历史`)}],className:`workflow-tabs`}),g===`runs`?(0,Y.jsx)(be,{canExecute:l}):(0,Y.jsxs)(M,{title:e(`workflows.processLibrary`,null,`工作流列表`),description:e(`workflows.metaIdHint`,null,`创建后不可修改,用于 API 与角色绑定`),extra:(0,Y.jsxs)(Ee,{type:`tertiary`,size:`small`,children:[K.length,` / `,H.length]}),children:[(0,Y.jsxs)(`div`,{className:`workflow-toolbar`,children:[(0,Y.jsx)(a,{prefix:(0,Y.jsx)(u,{}),value:v,showClear:!0,placeholder:e(`workflows.searchPlaceholder`,null,`搜索工作流…`),onChange:e=>y(e),style:{width:260}}),(0,Y.jsxs)(i,{spacing:6,children:[(0,Y.jsx)(b,{checked:S,onChange:te,size:`small`}),(0,Y.jsx)(Ee,{size:`small`,children:`显示已禁用`})]})]}),(0,Y.jsx)(P,{columns:ue,dataSource:K,rowKey:`id`,loading:V.loading,pagination:{pageSize:10},emptyText:e(`workflows.emptyList`,null,`暂无工作流`)})]}),(0,Y.jsx)(fe,{visible:A.visible,workflow:A.workflow,onCancel:()=>N({visible:!1,workflow:null}),onSaved:e=>{N({visible:!1,workflow:null}),G(),e?.id&&W(e.id,`list`)}}),(0,Y.jsx)(me,{workflowId:h,visible:!!h,canWrite:n,canDelete:c,onClose:()=>W(void 0,g),onEdit:e=>{e&&(W(void 0,g),N({visible:!0,workflow:e}))},onDeleted:()=>{W(void 0,g),G()}}),(0,Y.jsx)(Te,{visible:F,onCancel:()=>z(!1),onImported:()=>G()})]})}export{Oe as default};
\ No newline at end of file
diff --git a/web/static/app/assets/workflows-DehfjrnW.js b/web/static/app/assets/workflows-DehfjrnW.js
deleted file mode 100644
index f7d53c5a..00000000
--- a/web/static/app/assets/workflows-DehfjrnW.js
+++ /dev/null
@@ -1 +0,0 @@
-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,at as u,b as d,c as f,ct as p,f as m,l as h,m as g,ot as _,p as v,s as y,u as b,x,z as S}from"./semi-CXF9U6uC.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 ne,n as M,p as re,r as N,s as P,u as F,x as I,y as L}from"./index-CrDogtQS.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(),u=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){let e=t.graph_json||``;try{e=JSON.stringify(JSON.parse(e),null,2)}catch{}p({id:t.id||``,name:t.name||``,description:t.description||``,version:t.version||1,enabled:t.enabled!==!1,graph:e})}else p({...de,graph:JSON.stringify(V,null,2)})}},[e,t]);let C=e=>p(t=>({...t,...e})),E=(0,R.useMemo)(()=>ae(f.graph),[f.graph]);return(0,Y.jsxs)(te,{visible:e,title:b?s(`workflows.metaModalTitle`,null,`工作流信息`):s(`workflows.newGraph`,null,`新建工作流`),onCancel:n,onOk:async()=>{let e=(b?t.id:f.id).trim(),n=f.name.trim();if(!e||!n)k(s(`workflows.idNameRequired`,null,`工作流 ID 和名称不能为空`));else if(!b&&!ue.test(e))k(`工作流 ID 必须以字母或数字开头,仅含字母、数字、下划线、连字符`);else{if(f.graph.trim())try{JSON.parse(f.graph)}catch(e){k(`graph 必须是合法 JSON:${J(e,``)}`);return}h(!0);try{let t={id:e,name:n,description:f.description,version:Number(f.version)||0,enabled:!!f.enabled,graph:f.graph.trim()?JSON.parse(f.graph):void 0},i=b?await T.put(`/workflows/${encodeURIComponent(e)}`,t):await T.post(`/workflows`,t);I(s(`workflows.saved`,null,`工作流已保存`)),r?.(i?.workflow||null)}catch(e){k(J(e,s(`workflows.saveFailed`,null,`保存工作流失败`)))}finally{h(!1)}}},okText:s(`common.save`,null,`保存`),cancelText:s(`common.cancel`,null,`取消`),confirmLoading:m,width:860,maskClosable:!1,children:[(0,Y.jsxs)(`div`,{className:`workflow-form-grid`,children:[(0,Y.jsxs)(`div`,{className:`workflow-form-field`,children:[(0,Y.jsx)(X,{strong:!0,size:`small`,children:s(`workflows.metaId`,null,`ID`)}),(0,Y.jsx)(a,{value:f.id,disabled:b,placeholder:`web-scan-basic`,onChange:e=>C({id:e})}),(0,Y.jsx)(X,{type:`tertiary`,size:`small`,children:s(`workflows.metaIdHint`,null,`创建后不可修改,用于 API 与角色绑定`)})]}),(0,Y.jsxs)(`div`,{className:`workflow-form-field`,children:[(0,Y.jsx)(X,{strong:!0,size:`small`,children:s(`workflows.metaName`,null,`名称`)}),(0,Y.jsx)(a,{value:f.name,placeholder:s(`workflows.namePlaceholder`,null,`基础 Web 扫描`),onChange:e=>C({name:e})})]})]}),(0,Y.jsxs)(`div`,{className:`workflow-form-grid`,children:[(0,Y.jsxs)(`div`,{className:`workflow-form-field`,children:[(0,Y.jsx)(X,{strong:!0,size:`small`,children:s(`workflows.metaDescription`,null,`描述`)}),(0,Y.jsx)(a,{value:f.description,placeholder:s(`workflows.descriptionPlaceholder`,null,`可选`),onChange:e=>C({description:e})})]}),(0,Y.jsxs)(`div`,{className:`workflow-form-grid workflow-form-grid--tight`,children:[(0,Y.jsxs)(`div`,{className:`workflow-form-field`,children:[(0,Y.jsx)(X,{strong:!0,size:`small`,children:`版本`}),(0,Y.jsx)(d,{value:f.version,min:0,style:{width:`100%`},onChange:e=>C({version:e||0})})]}),(0,Y.jsxs)(`div`,{className:`workflow-form-field`,children:[(0,Y.jsx)(X,{strong:!0,size:`small`,children:s(`workflows.metaEnabled`,null,`启用`)}),(0,Y.jsx)(c,{checked:f.enabled,onChange:e=>C({enabled:e.target.checked}),children:s(`workflows.metaEnabledHint`,null,`禁用后无法被角色自动触发`)})]})]})]}),(0,Y.jsxs)(`div`,{className:`workflow-form-field`,children:[(0,Y.jsxs)(i,{children:[(0,Y.jsx)(X,{strong:!0,size:`small`,children:`graph JSON`}),(0,Y.jsx)(X,{type:`tertiary`,size:`small`,children:E.error?`解析失败:${E.error}`:`${E.nodes.length} 个节点 · ${E.edges.length} 条连线`})]}),(0,Y.jsx)(x,{value:f.graph,rows:16,spellCheck:!1,className:`workflow-graph-input`,placeholder:`{"nodes":[],"edges":[],"config":{}}`,onChange:e=>{C({graph:e}),y(null)}}),(0,Y.jsxs)(i,{wrap:!0,children:[(0,Y.jsx)(o,{size:`small`,onClick:()=>{try{C({graph:JSON.stringify(JSON.parse(f.graph),null,2)}),y(null)}catch(e){k(`${s(`projects.invalidJson`,null,`JSON 格式无效`)}:${J(e,``)}`)}},children:s(`projects.formatJson`,null,`格式化`)}),(0,Y.jsx)(o,{size:`small`,onClick:()=>{C({graph:JSON.stringify(V,null,2)}),y(null)},children:`插入最小模板`}),(0,Y.jsx)(o,{size:`small`,loading:g,disabled:!u,title:u?``:`需要 workflow:execute 权限`,onClick:async()=>{if(!f.graph.trim()){y({type:`danger`,text:s(`workflows.validation.serverFailed`,null,`图定义不能为空`)});return}let e;try{e=JSON.parse(f.graph)}catch(e){y({type:`danger`,text:`JSON 解析失败:${J(e,``)}`});return}_(!0),y(null);try{await T.post(`/workflows/validate`,{graph:e}),y({type:`success`,text:`结构校验通过`})}catch(e){y({type:`danger`,text:J(e,s(`workflows.validation.serverFailed`,null,`后端图校验失败`))})}finally{_(!1)}},children:s(`workflows.validate`,null,`校验图定义`)}),(0,Y.jsxs)(X,{type:`tertiary`,size:`small`,children:[`节点类型:`,z.map(e=>e.label).join(` / `)]})]})]}),v?(0,Y.jsx)(S,{type:v.type,bordered:!0,closeIcon:null,description:v.text,style:{marginTop:12}}):null]})}var{Text:Z}=l;function pe({raw:e}){let t=(0,R.useMemo)(()=>ae(e),[e]);if(t.error)return(0,Y.jsxs)(Z,{type:`danger`,size:`small`,children:[`graph 解析失败:`,t.error]});let n=t.nodes.map(e=>({id:e.id,type:e.type||`tool`,label:e.label||``,config:e.config||{}}));return(0,Y.jsxs)(`div`,{className:`workflow-detail-stack`,children:[(0,Y.jsx)(h,{columns:[{title:`节点`,dataIndex:`id`,width:160,render:e=>(0,Y.jsx)(`code`,{children:e})},{title:`类型`,dataIndex:`type`,width:90,render:e=>(0,Y.jsx)(s,{size:`small`,color:`blue`,type:`light`,children:ie[e]||e})},{title:`名称`,dataIndex:`label`,render:(e,t)=>(0,Y.jsx)(`span`,{className:`workflow-cell-ellipsis`,title:e||t.id,children:e||`—`})}],dataSource:n,rowKey:`id`,size:`small`,pagination:!1,empty:(0,Y.jsx)(Z,{type:`tertiary`,size:`small`,children:`图内没有节点`})}),(0,Y.jsxs)(`div`,{className:`workflow-edge-list`,children:[(0,Y.jsxs)(Z,{strong:!0,size:`small`,children:[`连线(`,t.edges.length,`)`]}),t.edges.length?(0,Y.jsx)(`ul`,{className:`workflow-link-list`,children:t.edges.map((e,t)=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{children:e.source}),` → `,(0,Y.jsx)(`code`,{children:e.target}),e.label?(0,Y.jsx)(`span`,{className:`workflow-edge-label`,children:e.label}):null]},e.id||`${e.source}-${e.target}-${t}`))}):(0,Y.jsx)(Z,{type:`tertiary`,size:`small`,children:`暂无连线`})]})]})}function me({workflowId:e,visible:t,canWrite:n,canDelete:r,onClose:a,onEdit:c,onDeleted:l}){let u=D(),[d,f]=(0,R.useState)(!1),p=O(()=>e?T.get(`/workflows/${encodeURIComponent(e)}`):Promise.resolve(null),[e]),h=p.data?.workflow||null;return(0,R.useEffect)(()=>{t&&e&&p.reload({silent:!0})},[t,e]),(0,Y.jsxs)(m,{visible:t,width:760,title:h?h.name||h.id:u(`workflows.metaModalTitle`,null,`工作流信息`),onCancel:a,footer:(0,Y.jsxs)(i,{children:[(0,Y.jsx)(o,{disabled:!n||!h,onClick:()=>c?.(h),children:u(`common.edit`,null,`编辑`)}),(0,Y.jsx)(o,{loading:d,disabled:!h,onClick:async()=>{if(h){f(!0);try{await E(`/workflows/${encodeURIComponent(h.id)}/package`,{filename:`${h.id}.csapkg.zip`}),I(u(`workflows.package.export`,null,`导出`))}catch(e){k(J(e,u(`workflows.package.errors.exportFailed`,null,`导出失败,请稍后重试。`)))}finally{f(!1)}}},children:u(`workflows.package.export`,null,`导出`)}),(0,Y.jsx)(o,{type:`danger`,disabled:!r||!h,onClick:()=>L({title:u(`workflows.deleteWorkflow`,null,`删除工作流`),content:u(`workflows.confirmDelete`,{id:h?.id},`确定删除工作流 ${h?.id}?`),okText:u(`common.delete`,null,`删除`),onOk:async()=>{try{await T.del(`/workflows/${encodeURIComponent(h.id)}`),I(u(`workflows.deleted`,null,`工作流已删除`)),l?.(h.id)}catch(e){k(J(e,u(`workflows.deleteFailed`,null,`删除工作流失败`)))}}}),children:u(`workflows.deleteWorkflow`,null,`删除工作流`)}),(0,Y.jsx)(o,{onClick:a,children:u(`common.close`,null,`关闭`)})]}),children:[(0,Y.jsx)(j,{error:oe(p.error),onRetry:()=>p.reload()}),h?(0,Y.jsxs)(`div`,{className:`workflow-detail-stack`,children:[(0,Y.jsxs)(`div`,{className:`workflow-detail-tags`,children:[(0,Y.jsx)(s,{size:`small`,color:h.enabled?`green`:`grey`,children:h.enabled?u(`workflows.statusEnabled`,null,`启用`):u(`workflows.statusDisabled`,null,`禁用`)}),h.validation_error?(0,Y.jsx)(s,{size:`small`,color:`red`,children:u(`workflows.statusInvalid`,null,`校验未通过`)}):(0,Y.jsx)(s,{size:`small`,color:`green`,type:`light`,children:`结构有效`}),(0,Y.jsxs)(Z,{type:`tertiary`,size:`small`,children:[`版本 `,h.version||0]})]}),h.validation_error?(0,Y.jsx)(j,{error:{message:h.validation_error}}):null,(0,Y.jsx)(A,{columns:2,items:[{label:u(`workflows.metaId`,null,`ID`),value:(0,Y.jsx)(`code`,{children:h.id})},{label:u(`workflows.metaName`,null,`名称`),value:h.name||`—`},{label:u(`workflows.updated`,null,`更新`),value:C(h.updated_at)},{label:`创建`,value:C(h.created_at)},{label:u(`workflows.metaDescription`,null,`描述`),value:h.description||`—`}]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(Z,{strong:!0,children:u(`workflows.nodeProperties`,null,`节点属性`)}),(0,Y.jsx)(pe,{raw:h.graph_json})]}),(0,Y.jsx)(F,{value:h.graph_json?he(h.graph_json):{},title:`graph JSON`,collapsed:!0})]}):null]})}function he(e){try{return JSON.parse(e)}catch{return{raw:e}}}var{Text:Q}=l;function ge(e){let t=B[String(e||``)]||{label:e||`—`,color:`grey`};return(0,Y.jsx)(s,{size:`small`,color:t.color,children:t.label})}function _e({runId:e,visible:t,canExecute:n,onClose:r,onChanged:a}){let s=D(),[c,l]=(0,R.useState)(``),[u,d]=(0,R.useState)(!1),f=O(()=>e?T.get(`/workflows/runs/${encodeURIComponent(e)}`):Promise.resolve(null),[e]),p=O(()=>e?T.get(`/workflows/runs/${encodeURIComponent(e)}/replay`):Promise.resolve(null),[e]),h=f.data?.run||null;(0,R.useEffect)(()=>{t&&e&&(f.reload({silent:!0}),p.reload({silent:!0}))},[t,e]);let g=f.data?.nodeRuns||[],_=p.data?.steps||[],v=t=>L({title:t?`通过审批`:`拒绝审批`,content:t?`确认通过该工作流的审批节点并继续执行?`:`确认拒绝该工作流的审批节点?运行将以失败结束。`,okText:s(`common.confirm`,null,`确认`),danger:!t,onOk:async()=>{d(!0);try{await T.post(`/workflows/runs/${encodeURIComponent(e)}/resume`,{approved:t,comment:c}),I(t?`已通过审批`:`已拒绝审批`),l(``),f.reload({silent:!0}),p.reload({silent:!0}),a?.()}catch(e){k(J(e,`审批提交失败`))}finally{d(!1)}}});return(0,Y.jsxs)(m,{visible:t,width:820,title:s(`workflows.dryRunTrace`,null,`运行轨迹`),onCancel:r,footer:(0,Y.jsxs)(i,{children:[h?.status===`awaiting_hitl`&&n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{value:c,rows:1,placeholder:`审批备注(可选)`,onChange:e=>l(e),style:{width:240}}),(0,Y.jsx)(o,{type:`primary`,loading:u,onClick:()=>v(!0),children:`通过`}),(0,Y.jsx)(o,{type:`danger`,loading:u,onClick:()=>v(!1),children:`拒绝`})]}):null,(0,Y.jsx)(o,{onClick:r,children:s(`common.close`,null,`关闭`)})]}),children:[(0,Y.jsx)(j,{error:oe(f.error),onRetry:()=>f.reload()}),h?(0,Y.jsxs)(`div`,{className:`workflow-detail-stack`,children:[(0,Y.jsxs)(`div`,{className:`workflow-detail-tags`,children:[ge(h.status),(0,Y.jsxs)(Q,{type:`tertiary`,size:`small`,children:[`运行 `,(0,Y.jsx)(`code`,{children:q(h.id,16)})]})]}),(0,Y.jsx)(A,{columns:2,items:[{label:`工作流`,value:(0,Y.jsx)(`code`,{children:h.workflow_id})},{label:`版本`,value:h.workflow_version??`—`},{label:`会话`,value:h.conversation_id||`—`},{label:`项目`,value:h.project_id||`—`},{label:`开始时间`,value:C(h.started_at)},{label:`结束时间`,value:C(h.finished_at)},h.pending_hitl_node_id?{label:`待审批节点`,value:(0,Y.jsx)(`code`,{children:h.pending_hitl_node_id})}:null,h.error?{label:`错误`,value:(0,Y.jsx)(Q,{type:`danger`,size:`small`,children:h.error})}:null]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(Q,{strong:!0,children:[`节点执行记录(`,g.length,`)`]}),(0,Y.jsx)(y,{className:`workflow-timeline`,children:g.length?g.map(e=>(0,Y.jsx)(y.Item,{time:C(e.started_at),type:e.status===`failed`?`error`:e.status===`completed`?`success`:`ongoing`,children:(0,Y.jsxs)(`div`,{className:`workflow-timeline-item`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`code`,{children:e.node_id}),` `,ge(e.status)]}),e.error?(0,Y.jsx)(Q,{type:`danger`,size:`small`,children:e.error}):null,e.output_json?(0,Y.jsx)(F,{value:ve(e.output_json),title:`output`,collapsed:!0}):null]})},e.id)):(0,Y.jsx)(Q,{type:`tertiary`,size:`small`,children:`暂无节点执行记录`})})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(Q,{strong:!0,children:[s(`workflows.dryRunTrace`,null,`回放轨迹`),`(`,_.length,` 步)`]}),(0,Y.jsx)(y,{className:`workflow-timeline`,children:_.length?_.map(e=>(0,Y.jsx)(y.Item,{time:C(e.startedAt),type:e.status===`failed`?`error`:e.status===`completed`?`success`:`ongoing`,children:(0,Y.jsxs)(`div`,{className:`workflow-timeline-item`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(Q,{strong:!0,size:`small`,children:[`#`,e.step]}),` `,(0,Y.jsx)(`code`,{children:e.nodeId}),` `,ge(e.status)]}),e.error?(0,Y.jsx)(Q,{type:`danger`,size:`small`,children:e.error}):null,(0,Y.jsx)(F,{value:{input:e.input,output:e.output},title:`step`,collapsed:!0})]})},e.nodeRunId||`${e.step}-${e.nodeId}`)):(0,Y.jsx)(Q,{type:`tertiary`,size:`small`,children:s(`workflows.dryRunNoTrace`,null,`暂无轨迹`)})})]}),(0,Y.jsx)(F,{value:h,title:`run`,collapsed:!0})]}):null]})}function ve(e){try{return JSON.parse(e)}catch{return{raw:e}}}var{Text:ye}=l;function be({canExecute:e}){let t=D(),[n,a]=r(),c=n.get(`run`)||``,l=O(()=>T.get(`/workflows/runs/pending`),[]);N(()=>l.reload({silent:!0}),15e3);let u=Array.isArray(l.data?.runs)?l.data.runs:[],d=e=>{let t=new URLSearchParams(n);e?t.set(`run`,e):t.delete(`run`),a(t,{replace:!0})},f=[{title:`运行`,dataIndex:`id`,width:190,render:e=>(0,Y.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>d(e),children:(0,Y.jsx)(`code`,{children:q(e,14)})})},{title:`工作流`,dataIndex:`workflow_id`,width:200,render:e=>(0,Y.jsx)(ye,{size:`small`,children:(0,Y.jsx)(`code`,{children:e})})},{title:`会话`,dataIndex:`conversation_id`,width:220,render:e=>(0,Y.jsx)(ye,{type:`tertiary`,size:`small`,children:(0,Y.jsx)(`code`,{children:e||`—`})})},{title:t(`projects.status`,null,`状态`),dataIndex:`status`,width:110,render:e=>{let t=B[String(e||``)]||{label:e||`—`,color:`grey`};return(0,Y.jsx)(s,{size:`small`,color:t.color,children:t.label})}},{title:`待审批节点`,dataIndex:`pending_hitl_node_id`,width:160,render:e=>e?(0,Y.jsx)(`code`,{children:e}):(0,Y.jsx)(ye,{type:`tertiary`,children:`—`})},{title:`开始时间`,dataIndex:`started_at`,width:165,render:e=>(0,Y.jsx)(ye,{size:`small`,children:C(e)})},{title:t(`common.actions`,null,`操作`),dataIndex:`id`,width:120,render:e=>(0,Y.jsx)(i,{children:(0,Y.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>d(e),children:t(`projects.details`,null,`详情`)})})}];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(ne,{title:t(`workflows.runsPending`,null,`待审批运行`),description:`等待审批(awaiting_hitl)的工作流运行,每 15 秒自动刷新。${e?` 可直接在此通过或拒绝。`:``}`,extra:(0,Y.jsx)(o,{icon:(0,Y.jsx)(_,{}),theme:`borderless`,loading:l.loading,onClick:()=>l.reload(),children:t(`common.refresh`,null,`刷新`)}),children:[(0,Y.jsx)(j,{error:oe(l.error),onRetry:()=>l.reload()}),(0,Y.jsx)(P,{columns:f,dataSource:u,rowKey:`id`,loading:l.loading,pagination:{pageSize:10},emptyText:`当前没有等待审批的工作流运行`})]}),(0,Y.jsx)(_e,{runId:c,visible:!!c,canExecute:e,onClose:()=>d(``),onChanged:()=>l.reload({silent:!0})})]})}var{Text:$,Paragraph:xe}=l,Se=10485760;function Ce(e){let t=String(e||``).replace(/^data:[^;]+;base64,/,``).replace(/\s+/g,``);if(!t)throw Error(`粘贴内容为空`);let n=atob(t),r=new Uint8Array(n.length);for(let e=0;e{e||(u(null),f(``),m(``),_(null),b(``),E(``),O(!1),N(``),F(null),j(!1),M(!1))},[e]);let L=h?.conflict?.state||``,z=(0,R.useMemo)(()=>G(L),[L]),ie=()=>{m(``);try{let e=Ce(d);if(e.size>Se){m(r(`workflows.package.errors.fileTooLarge`,null,`文件超过 10 MiB 限制,请选择更小的本地包。`));return}u(e),_(null),F(null)}catch(e){m(`Base64 解码失败:${J(e,``)}`)}},B=e=>{let t=e.target.files&&e.target.files[0];m(``),N(``),F(null),_(null),t?t.size>Se?(m(r(`workflows.package.errors.fileTooLarge`,null,`文件超过 10 MiB 限制,请选择更小的本地包。`)),u(null)):u(t):u(null)},V=async()=>{if(!l)m(r(`workflows.package.errors.fileRequired`,null,`请选择本地工作流包后再预检。`));else{j(!0),N(``),F(null);try{let e=new FormData;e.append(`file`,l,l.name||`workflow.csapkg.zip`);let t=(await T.post(`/workflow-package-inspections`,e))?.inspection||null;_(t);let n=G(t?.conflict?.state||``);b(n[0]||``),E(``),O(!1)}catch(e){N(ce(e,r))}finally{j(!1)}}},H=async()=>{if(!h?.id){N(r(`workflows.package.resolution.needInspection`,null,`请先选择本地包并完成预检。`));return}if(!y){N(r(`workflows.package.errors.invalidAction`,null,`导入处理方式无效,请重新选择。`));return}if(y===`rename`&&!w.trim()){N(r(`workflows.package.errors.invalidRenameId`,null,`请输入可用的新工作流 ID。`));return}if(y===`overwrite`&&!ee){N(r(`workflows.package.errors.overwriteConfirmationRequired`,null,`请勾选确认后再覆盖本地工作流。`));return}let e=le();if(!e)N(r(`workflows.package.errors.idempotencyKeyRequired`,null,`浏览器无法生成导入请求标识,请刷新页面后重试。`));else{M(!0),N(``);try{let t=await T.post(`/workflow-package-imports`,{inspection_id:h.id,resolution:{action:y,new_workflow_id:y===`rename`?w.trim():``},confirm_overwrite:y===`overwrite`},{headers:{"Idempotency-Key":e}});F(t?.import||null),I(r(`workflows.package.result.complete`,null,`导入已完成。`)),n?.(t?.import||null)}catch(e){N(ce(e,r))}finally{M(!1)}}},W=L===`identical`?r(`workflows.package.conflict.identical`,null,`检测到同 ID 且内容相同的本地工作流;本次将跳过导入。`):L===`id_conflict`?r(`workflows.package.conflict.idConflict`,null,`检测到同 ID 但内容不同的本地工作流。默认保留本地版本。`):L===`none`?r(`workflows.package.conflict.none`,null,`未发现同 ID 的本地工作流,可创建导入。`):``,K=h?.workflow;return(0,Y.jsxs)(te,{visible:e,title:r(`workflows.package.title`,null,`导入本地包`),onCancel:t,width:760,maskClosable:!1,footer:(0,Y.jsxs)(i,{children:[(0,Y.jsx)(o,{onClick:t,children:r(`common.close`,null,`关闭`)}),(0,Y.jsx)(o,{type:`primary`,loading:k,disabled:!!P,onClick:V,children:k?r(`workflows.package.inspecting`,null,`正在安全预检…`):r(`workflows.package.inspect`,null,`上传并预检`)}),(0,Y.jsx)(o,{type:`primary`,loading:ne,disabled:!h||!!P||!y,onClick:H,children:r(`workflows.package.confirmImport`,null,`确认导入`)})]}),children:[(0,Y.jsxs)(xe,{type:`tertiary`,size:`small`,children:[r(`workflows.package.preflightHint`,null,`先检查包内容与冲突,再由你确认是否导入`),` · `,r(`workflows.package.fileHint`,null,`仅支持单个 .csapkg.zip,文件不得超过 10 MiB。`)]}),(0,Y.jsxs)(`div`,{className:`workflow-package-block`,children:[(0,Y.jsx)($,{strong:!0,size:`small`,children:r(`workflows.package.stepInspection`,null,`上传与预检`)}),(0,Y.jsxs)(`div`,{className:`workflow-package-file-row`,children:[(0,Y.jsx)(`input`,{type:`file`,accept:`.zip,application/zip`,className:`workflow-file-input`,onChange:B,"aria-label":r(`workflows.package.selectFile`,null,`选择本地包`)}),(0,Y.jsx)($,{type:`tertiary`,size:`small`,children:l?`${l.name} · ${(l.size/1024).toFixed(1)} KiB`:r(`workflows.package.noFile`,null,`未选择文件`)}),l?(0,Y.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>{u(null),_(null),F(null)},children:r(`workflows.package.removeFile`,null,`移除文件`)}):null]}),(0,Y.jsx)(x,{value:d,rows:3,placeholder:`或粘贴工作流包 base64(.csapkg.zip)`,onChange:e=>f(e)}),(0,Y.jsxs)(i,{children:[(0,Y.jsx)(o,{size:`small`,onClick:ie,disabled:!d.trim(),children:`使用粘贴内容`}),p?(0,Y.jsx)($,{type:`danger`,size:`small`,children:p}):null]})]}),re?(0,Y.jsx)(S,{type:`danger`,bordered:!0,closeIcon:null,description:re,className:`workflow-package-banner`}):null,h?(0,Y.jsxs)(`div`,{className:`workflow-package-block`,children:[(0,Y.jsxs)(`div`,{className:`workflow-package-summary-head`,children:[(0,Y.jsx)($,{strong:!0,size:`small`,children:r(`workflows.package.summary.title`,null,`预检结果`)}),(0,Y.jsx)(s,{size:`small`,color:`green`,children:r(`workflows.package.summary.passed`,null,`校验通过`)})]}),(0,Y.jsx)(S,{type:L===`id_conflict`?`warning`:`success`,bordered:!0,closeIcon:null,description:W,className:`workflow-package-banner`}),(0,Y.jsx)(A,{columns:2,items:[{label:r(`workflows.package.summary.workflowName`,null,`工作流名称`),value:K?.name||`—`},{label:r(`workflows.package.summary.sourceId`,null,`源工作流 ID`),value:(0,Y.jsx)(`code`,{children:K?.source_id||`—`})},{label:r(`workflows.package.summary.sourceRevision`,null,`源版本`),value:K?.source_revision??`—`},{label:r(`workflows.package.summary.graphSize`,null,`图规模`),value:`${K?.node_count||0} 节点 · ${K?.edge_count||0} 连线`},{label:r(`workflows.package.summary.contentHash`,null,`内容摘要`),value:q(K?.content_hash)},{label:r(`workflows.package.summary.expiresAt`,null,`预检有效期`),value:C(h.expires_at)}]}),(0,Y.jsx)($,{strong:!0,size:`small`,children:r(`workflows.package.resolutionTitle`,null,`处理方式`)}),(0,Y.jsx)(g,{value:y,onChange:e=>{b(e.target.value),O(!1)},direction:`vertical`,children:z.map(e=>(0,Y.jsx)(v,{value:e,children:(0,Y.jsxs)(`span`,{className:`workflow-package-action`,children:[(0,Y.jsx)($,{strong:!0,size:`small`,children:U[e]?.label||e}),(0,Y.jsx)($,{type:`tertiary`,size:`small`,children:U[e]?.hint||``})]})},e))}),y===`rename`?(0,Y.jsx)(a,{value:w,placeholder:r(`workflows.package.resolution.newWorkflowIdPlaceholder`,null,`例如:web-scan-basic-copy`),onChange:e=>E(e)}):null,y===`overwrite`?(0,Y.jsxs)(`div`,{className:`workflow-package-overwrite`,children:[(0,Y.jsx)(S,{type:`warning`,bordered:!0,closeIcon:null,description:r(`workflows.package.overwriteWarning`,null,`覆盖将替换名称、描述、图定义和启用状态。本期不提供回滚。`)}),(0,Y.jsx)(c,{checked:ee,onChange:e=>O(e.target.checked),children:r(`workflows.package.overwriteCheck`,null,`我已确认覆盖当前本地工作流`)})]}):null]}):null,P?(0,Y.jsx)(S,{type:`success`,bordered:!0,closeIcon:null,className:`workflow-package-banner`,description:r(we[P.result]||`workflows.package.result.complete`,null,`导入已完成。`)}):null]})}var{Text:Ee}=l;async function De(){let[e,t]=await Promise.all([T.get(`/workflows`,{includeDisabled:`true`}),T.get(`/workflows/runs/pending`).catch(()=>null)]);return{workflows:Array.isArray(e?.workflows)?e.workflows:[],pendingRuns:Array.isArray(t?.runs)?t.runs:[]}}function Oe(){let e=D(),{hasPermission:t}=w(),n=t(`workflow:write`),c=t(`workflow:delete`),l=t(`workflow:execute`),[d,m]=r(),h=d.get(`id`)||``,g=d.get(`tab`)||`list`,[v,y]=(0,R.useState)(``),x=M(v,250),[S,te]=(0,R.useState)(!0),[A,N]=(0,R.useState)({visible:!1,workflow:null}),[F,z]=(0,R.useState)(!1),[ie,B]=(0,R.useState)(0),V=O(De,[ie]),H=V.data?.workflows||[],U=V.data?.pendingRuns||[],W=(0,R.useCallback)((e,t)=>{let n=new URLSearchParams(d);e?n.set(`id`,e):n.delete(`id`),t?n.set(`tab`,t):n.delete(`tab`),t&&t!==`runs`&&n.delete(`run`),m(n,{replace:!!e})},[d,m]),G=()=>B(e=>e+1),K=(0,R.useMemo)(()=>{let e=x.trim().toLowerCase();return H.filter(t=>!S&&t.enabled===!1?!1:!e||[t.id,t.name,t.description].join(` `).toLowerCase().includes(e))},[H,x,S]),q=H.filter(e=>!!e.validation_error).length,se=H.filter(e=>e.enabled).length,ce=[{id:`total`,label:e(`workflows.processLibrary`,null,`工作流列表`),value:H.length,loading:V.loading},{id:`enabled`,label:e(`workflows.statusEnabled`,null,`启用`),value:se,tone:`success`,loading:V.loading},{id:`invalid`,label:e(`workflows.statusInvalid`,null,`校验未通过`),value:q,tone:q?`danger`:void 0,loading:V.loading},{id:`pending`,label:e(`workflows.runsPending`,null,`待审批运行`),value:U.length,tone:U.length?`warning`:void 0,loading:V.loading}],le=async t=>{try{await E(`/workflows/${encodeURIComponent(t.id)}/package`,{filename:`${t.id}.csapkg.zip`}),I(e(`workflows.package.export`,null,`导出`))}catch(t){k(J(t,e(`workflows.package.errors.exportFailed`,null,`导出失败,请稍后重试。`)))}},X=t=>L({title:e(`workflows.deleteWorkflow`,null,`删除工作流`),content:e(`workflows.confirmDelete`,{id:t.id},`确定删除工作流 ${t.id}?`),okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{await T.del(`/workflows/${encodeURIComponent(t.id)}`),I(e(`workflows.deleted`,null,`工作流已删除`)),h===t.id&&W(void 0,g),G()}catch(t){k(J(t,e(`workflows.deleteFailed`,null,`删除工作流失败`)))}}}),ue=[{title:e(`workflows.metaName`,null,`名称`),dataIndex:`name`,render:(t,n)=>{let r=ae(n.graph_json);return(0,Y.jsxs)(`button`,{type:`button`,className:`workflow-name-button`,onClick:()=>W(n.id,`list`),title:n.id,children:[(0,Y.jsx)(`span`,{className:`workflow-name-text`,children:t||e(`workflows.untitled`,null,`未命名工作流`)}),(0,Y.jsxs)(`span`,{className:`workflow-name-sub`,children:[(0,Y.jsx)(`code`,{children:n.id}),` · `,r.error?`图解析失败`:`${r.nodes.length} 节点 / ${r.edges.length} 连线`]})]})}},{title:e(`projects.status`,null,`状态`),dataIndex:`enabled`,width:150,render:(t,n)=>(0,Y.jsxs)(i,{spacing:4,wrap:!0,children:[(0,Y.jsx)(s,{size:`small`,color:t?`green`:`grey`,children:t?e(`workflows.statusEnabled`,null,`启用`):e(`workflows.statusDisabled`,null,`禁用`)}),n.validation_error?(0,Y.jsx)(s,{size:`small`,color:`red`,children:e(`workflows.statusInvalid`,null,`校验未通过`)}):null]})},{title:`版本`,dataIndex:`version`,width:80,render:e=>(0,Y.jsxs)(Ee,{size:`small`,children:[`v`,e??0]})},{title:e(`projects.updated`,null,`更新`),dataIndex:`updated_at`,width:165,render:e=>(0,Y.jsx)(Ee,{type:`tertiary`,size:`small`,children:C(e)})},{title:e(`common.actions`,null,`操作`),dataIndex:`id`,width:260,render:(t,r)=>(0,Y.jsxs)(i,{spacing:2,wrap:!0,children:[(0,Y.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>W(r.id,`list`),children:e(`projects.details`,null,`详情`)}),(0,Y.jsx)(o,{size:`small`,theme:`borderless`,disabled:!n,onClick:()=>N({visible:!0,workflow:r}),children:e(`common.edit`,null,`编辑`)}),(0,Y.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>le(r),children:e(`workflows.package.export`,null,`导出`)}),(0,Y.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!c,onClick:()=>X(r),children:e(`common.delete`,null,`删除`)})]})}];return(0,Y.jsxs)(`div`,{className:`workflow-page`,children:[(0,Y.jsx)(re,{title:e(`workflows.title`,null,`工作流`),description:e(`workflows.processLibraryHint`,null,`工作流定义由节点与连线组成,可被角色或对话按需触发。`),extra:(0,Y.jsxs)(i,{children:[(0,Y.jsx)(o,{icon:(0,Y.jsx)(_,{}),theme:`borderless`,loading:V.loading,onClick:G,children:e(`common.refresh`,null,`刷新`)}),(0,Y.jsx)(o,{disabled:!n,onClick:()=>z(!0),children:e(`workflows.package.importLocal`,null,`导入本地包`)}),(0,Y.jsx)(o,{type:`primary`,icon:(0,Y.jsx)(p,{}),disabled:!n,onClick:()=>N({visible:!0,workflow:null}),children:e(`workflows.newGraph`,null,`新建工作流`)})]})}),(0,Y.jsx)(j,{error:oe(V.error),onRetry:G}),(0,Y.jsx)(ee,{metrics:ce,columns:4}),(0,Y.jsx)(f,{type:`line`,activeKey:g,onChange:e=>W(void 0,e),tabList:[{itemKey:`list`,tab:e(`workflows.processLibrary`,null,`工作流列表`)},{itemKey:`runs`,tab:e(`workflows.runsPending`,null,`运行历史`)}],className:`workflow-tabs`}),g===`runs`?(0,Y.jsx)(be,{canExecute:l}):(0,Y.jsxs)(ne,{title:e(`workflows.processLibrary`,null,`工作流列表`),description:e(`workflows.metaIdHint`,null,`创建后不可修改,用于 API 与角色绑定`),extra:(0,Y.jsxs)(Ee,{type:`tertiary`,size:`small`,children:[K.length,` / `,H.length]}),children:[(0,Y.jsxs)(`div`,{className:`workflow-toolbar`,children:[(0,Y.jsx)(a,{prefix:(0,Y.jsx)(u,{}),value:v,showClear:!0,placeholder:e(`workflows.searchPlaceholder`,null,`搜索工作流…`),onChange:e=>y(e),style:{width:260}}),(0,Y.jsxs)(i,{spacing:6,children:[(0,Y.jsx)(b,{checked:S,onChange:te,size:`small`}),(0,Y.jsx)(Ee,{size:`small`,children:`显示已禁用`})]})]}),(0,Y.jsx)(P,{columns:ue,dataSource:K,rowKey:`id`,loading:V.loading,pagination:{pageSize:10},emptyText:e(`workflows.emptyList`,null,`暂无工作流`)})]}),(0,Y.jsx)(fe,{visible:A.visible,workflow:A.workflow,onCancel:()=>N({visible:!1,workflow:null}),onSaved:e=>{N({visible:!1,workflow:null}),G(),e?.id&&W(e.id,`list`)}}),(0,Y.jsx)(me,{workflowId:h,visible:!!h,canWrite:n,canDelete:c,onClose:()=>W(void 0,g),onEdit:e=>{e&&(W(void 0,g),N({visible:!0,workflow:e}))},onDeleted:()=>{W(void 0,g),G()}}),(0,Y.jsx)(Te,{visible:F,onCancel:()=>z(!1),onImported:()=>G()})]})}export{Oe as default};
\ No newline at end of file
diff --git a/web/static/app/index.html b/web/static/app/index.html
index b752b72a..7d9c2bc1 100644
--- a/web/static/app/index.html
+++ b/web/static/app/index.html
@@ -18,7 +18,7 @@
} catch (error) { /* first paint fallback */ }
})();
-
+