);
}
@@ -196,20 +208,25 @@ export default function ProbePanel({ config, canWrite, reloadConfig }) {
const [drafts, setDrafts] = useState({});
const draft = drafts[channelId] || {};
const form = { ...baseline, ...draft };
+ const [listedDefaults, setListedDefaults] = useState(null);
+ const listedModel = listedDefaults && Object.hasOwn(listedDefaults, form.model) ? listedDefaults[form.model] : undefined;
const sameModelEndpoint = ['model', 'base_url', 'provider'].every(field => form[field] === baseline[field]);
const imageMode = draft.image_input ?? (sameModelEndpoint ? baseline.image_input : '');
- const imageDefault = sameModelEndpoint ? config.image_input_defaults?.[legacy ? '' : channelId] : undefined;
+ const imageDefault = sameModelEndpoint ? config.image_input_defaults?.[legacy ? '' : channelId] : listedModel?.image_input;
const imageEnabled = imageMode === 'enabled' || (imageMode !== 'disabled' && imageDefault === true);
- const defaultWindow = config.context_window_defaults?.[legacy ? '' : channelId];
- const useDefaultWindow = defaultWindow > 0 && !form.context_window && !Object.hasOwn(draft, 'context_window')
- && ['base_url', 'model', 'context_profile'].every(field => form[field] === baseline[field]);
+ const defaultWindow = sameModelEndpoint && form.context_profile === baseline.context_profile
+ ? config.context_window_defaults?.[legacy ? '' : channelId]
+ : listedModel?.context_window;
+ const needsDefaultWindow = Boolean(form.model.trim()) && !form.context_window;
+ const useDefaultWindow = needsDefaultWindow && !Object.hasOwn(draft, 'context_window');
+ const matchesServerDefault = defaultWindow === DEFAULT_FORM_CONTEXT_WINDOW;
const dirty = Object.keys(draft).length > 0;
const [busy, setBusy] = useState('');
const [state, setState] = useState(EMPTY_PROBE);
const [saving, setSaving] = useState(false);
const [saveError, setSaveError] = useState(null);
const [applyPending, setApplyPending] = useState(false);
- const locked = !canWrite || saving || busy === 'image';
+ const locked = !canWrite || saving || busy === 'image' || busy === 'list';
const channelOptions = legacy
? [{ value: MAIN_CHANNEL, label: t('settingsProbe.mainChannel', null, '主模型通道') }]
: modelChannelOptions(Object.entries(channels));
@@ -226,7 +243,11 @@ export default function ProbePanel({ config, canWrite, reloadConfig }) {
});
};
const update = (key, value) => {
- setState(EMPTY_PROBE);
+ const listChanged = ['provider', 'base_url', 'api_key', 'context_profile'].includes(key);
+ if (listChanged) setListedDefaults(null);
+ if (state.key !== 'list' || !state.payload?.success || listChanged) {
+ setState(EMPTY_PROBE);
+ }
setDrafts(current => {
const next = { ...current[channelId] };
const modelFields = ['model', 'base_url', 'provider'];
@@ -238,12 +259,14 @@ export default function ProbePanel({ config, canWrite, reloadConfig }) {
});
};
const selectChannel = id => {
+ setListedDefaults(null);
setSelectedId(id);
setState(EMPTY_PROBE);
if (!applyPending) setSaveError(null);
};
const discardDraft = () => {
+ setListedDefaults(null);
clearDraft();
setState(EMPTY_PROBE);
if (!applyPending) setSaveError(null);
@@ -275,6 +298,10 @@ export default function ProbePanel({ config, canWrite, reloadConfig }) {
if (Object.hasOwn(changes, key)) changes[key] = numberValue(form[key]);
}
+ if (dirty && needsDefaultWindow && !matchesServerDefault) {
+ changes.context_window = DEFAULT_FORM_CONTEXT_WINDOW;
+ }
+
setSaving(true);
try {
await api.put('/config', { ai_channel: { channel_id: legacy ? '' : channelId, make_default: makeDefault, ...changes } });
@@ -304,13 +331,15 @@ export default function ProbePanel({ config, canWrite, reloadConfig }) {
const run = async (key, path, body) => {
if (locked || busy) return;
setBusy(key);
+ if (key === 'list') setListedDefaults(null);
setState(EMPTY_PROBE);
try {
const payload = await api.post(path, body);
+ if (key === 'list' && payload.success) setListedDefaults(payload.model_defaults || null);
const detectedWindow = payload.context_window;
const fillWindow = key === 'context' || (key === 'test' && ['', '0'].includes(form.context_window.trim()));
if (fillWindow && payload.success && Number.isSafeInteger(detectedWindow) && detectedWindow > 0
- && !payload.context_runtime_unknown && !(useDefaultWindow && detectedWindow === defaultWindow)) {
+ && !payload.context_runtime_unknown && !(useDefaultWindow && matchesServerDefault && detectedWindow === defaultWindow)) {
const value = String(detectedWindow);
setDrafts(current => {
const next = { ...current[channelId] };
@@ -473,7 +502,7 @@ export default function ProbePanel({ config, canWrite, reloadConfig }) {
{t(key, null, fallback)}
update(field, value)}
inputMode="numeric"
readOnly={locked}
@@ -533,6 +562,7 @@ export default function ProbePanel({ config, canWrite, reloadConfig }) {
loading={busy === 'list'}
disabled={locked || !!busy}
onClick={() => run('list', '/config/list-models', {
+ context_profile: form.context_profile,
provider: form.provider,
channel_id: legacy ? undefined : channelId,
credential_scope: legacy ? 'openai' : undefined,
@@ -543,7 +573,13 @@ export default function ProbePanel({ config, canWrite, reloadConfig }) {
{t('settingsBasic.modelsList', null, '获取模型列表')}
-
+ update('model', value)}
+ disabled={locked}
+ />
{
test.use({ appPermissions: [...UI_PERMISSIONS, 'config:write'] });
+ test('selects a fetched model beyond the first 120 and saves it on the active channel', async ({ page, mockApi }) => {
+ const config = modelConfig();
+ config.ai.default_channel = 'qwen-max';
+ const models = Array.from({ length: 125 }, (_, index) => `fixture-model-${index}`);
+ mockApi.respond('GET', '/api/config', () => ({ json: config }));
+ mockApi.respond('POST', '/api/config/list-models', { json: { success: true, models } });
+ mockApi.respond('PUT', '/api/config', ({ body }) => {
+ const { channel_id, model, context_window } = body.ai_channel;
+ Object.assign(config.ai.channels[channel_id], { model, context_window });
+ return { json: {} };
+ });
+ mockApi.respond('POST', '/api/config/apply', { json: {} });
+ await page.goto('/static/app/#/settings?section=models');
+ const panel = (await ready(page)).locator('.settings-channel-panel');
+ const model = panel.locator('.settings-probe-form').getByLabel('模型', { exact: true });
+ const picker = panel.getByRole('combobox', { name: '请选择模型' });
+ await panel.getByRole('button', { name: '获取模型列表' }).click();
+ await expect(model).toHaveValue('deepseek-flash');
+ await picker.click();
+ await picker.getByRole('textbox').fill('124');
+ await page.getByRole('option').filter({ hasText: 'fixture-model-124' }).click();
+ await expect(model).toHaveValue('fixture-model-124');
+ await expect(panel.getByLabel('模型上下文窗口(Token)', { exact: true })).toHaveValue('1048576');
+ expect(mockApi.calls('PUT', '/api/config')).toEqual([]);
+ await panel.getByRole('button', { name: '保存通道' }).click();
+ await expect(panel.getByRole('button', { name: '保存通道' })).toBeDisabled();
+ await expect.poll(() => mockApi.calls('POST', '/api/config/apply').length).toBe(1);
+ await page.reload();
+ await expect(model).toHaveValue('fixture-model-124');
+ expect(config.ai.channels['qwen-max'].context_window).toBe(1048576);
+ expect(config.ai.channels.primary.model).toBe('primary-model');
+ });
+
+ test('switching from Flash to Pro previews its context window and image capability', async ({ page, mockApi }) => {
+ const config = modelConfig();
+ config.ai.channels.primary.model = 'deepseek-flash';
+ config.context_window_defaults = { primary: 1048576 };
+ config.image_input_defaults = { primary: true };
+ mockApi.respond('GET', '/api/config', { json: config });
+ mockApi.respond('POST', '/api/config/list-models', { json: {
+ success: true, models: ['deepseek-flash', 'deepseek-v4-pro'],
+ model_defaults: {
+ 'deepseek-flash': { context_window: 1048576, image_input: true },
+ 'deepseek-v4-pro': { context_window: 1048576, image_input: false }
+ }
+ } });
+ await page.goto('/static/app/#/settings?section=models');
+ const panel = (await ready(page)).locator('.settings-channel-panel');
+ const window = panel.getByLabel('模型上下文窗口(Token)', { exact: true });
+ const image = panel.getByText('支持图片', { exact: true });
+ const picker = panel.getByRole('combobox', { name: '请选择模型' });
+ await panel.getByRole('button', { name: '获取模型列表' }).click();
+ await expect(image).toBeVisible();
+ await picker.click();
+ await page.getByRole('option').filter({ hasText: 'deepseek-v4-pro' }).click();
+ await expect(window).toHaveValue('1048576');
+ await expect(image).toHaveCount(0);
+ await window.fill('65536');
+ await picker.click();
+ await page.getByRole('option').filter({ hasText: 'deepseek-flash' }).click();
+ await expect(image).toBeVisible();
+ await expect(window).toHaveValue('65536');
+ expect(mockApi.calls('PUT', '/api/config')).toEqual([]);
+ });
+
test('uses the server default until a manual context window is saved', async ({ page, mockApi }) => {
const config = modelConfig();
config.ai.default_channel = 'qwen-max';
@@ -51,13 +116,13 @@ test.describe('model channel editing', () => {
expect(mockApi.calls('PUT', '/api/config').map(({ body }) => body.ai_channel.context_window)).toEqual([65536, 0]);
});
- test('shows an example, fills a detected context window, and saves it explicitly', async ({ page, mockApi }) => {
+ test('starts at 1M, fills a detected context window, and saves it explicitly', async ({ page, mockApi }) => {
const config = modelConfig();
const model = config.ai.channels['qwen-max'];
config.ai.default_channel = 'qwen-max';
mockApi.respond('GET', '/api/config', () => ({ json: config }));
const result = {
- success: true, model: 'deepseek-flash', context_window: 1048576,
+ success: true, model: 'deepseek-flash', context_window: 131072,
context_source: 'openai_models_context_window'
};
mockApi.respond('POST', '/api/config/test-openai', { json: result });
@@ -73,12 +138,11 @@ test.describe('model channel editing', () => {
const detect = panel.getByRole('button', { name: '自动检测', exact: true });
const connection = panel.getByRole('button', { name: '测试连接', exact: true });
const save = panel.getByRole('button', { name: '保存通道', exact: true });
- await expect(window).toHaveValue('');
- await expect(window).toHaveAttribute('placeholder', '例如 131072');
+ await expect(window).toHaveValue('1048576');
await expect(save).toBeDisabled();
await connection.click();
- await expect(window).toHaveValue('1048576');
+ await expect(window).toHaveValue('131072');
await expect(panel.getByText('模型接口返回的上下文窗口', { exact: true })).toBeVisible();
await window.fill('65536');
await connection.click();
@@ -90,15 +154,15 @@ test.describe('model channel editing', () => {
mockApi.respond('POST', '/api/config/detect-context', { json: result });
await detect.click();
- await expect(window).toHaveValue('1048576');
+ await expect(window).toHaveValue('131072');
expect(mockApi.calls('PUT', '/api/config')).toEqual([]);
await save.click();
await expect(save).toBeDisabled();
expect(mockApi.calls('PUT', '/api/config')[0].body).toMatchObject({
- ai_channel: { channel_id: 'qwen-max', context_window: 1048576 }
+ ai_channel: { channel_id: 'qwen-max', context_window: 131072 }
});
await page.reload();
- await expect(window).toHaveValue('1048576');
+ await expect(window).toHaveValue('131072');
});
test('manual edits are saved on the selected channel and the default changes explicitly', async ({ page, mockApi }) => {
diff --git a/web/static/app/assets/AssetEditorModal-DNgfDOqO.js b/web/static/app/assets/AssetEditorModal-BbwbZZn2.js
similarity index 99%
rename from web/static/app/assets/AssetEditorModal-DNgfDOqO.js
rename to web/static/app/assets/AssetEditorModal-BbwbZZn2.js
index aafdb706..0b8702e9 100644
--- a/web/static/app/assets/AssetEditorModal-DNgfDOqO.js
+++ b/web/static/app/assets/AssetEditorModal-BbwbZZn2.js
@@ -1,3 +1,3 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,L as i,i as a,z as o}from"./semi-Dpcldp_F.js";import{I as s,P as c,R as l,c as u,x as d}from"./index-gBcdNgHq.js";import{E as f,a as p,c as m,h,i as g,o as _,p as v,s as y,u as b}from"./assetTarget-D2PEjBAg.js";var x=e(t(),1),S=e(n(),1),C=`asset-library-editor`;function w(e,t){return{target:b(e),host:e?.host||``,ip:e?.ip||``,domain:e?.domain||``,port:e?.port??void 0,protocol:e?.protocol||``,title:e?.title||``,server:e?.server||``,project_id:e?e.project_id||``:t,status:e?.status||`active`,environment:e?.environment||``,criticality:e?.criticality||``,country:e?.country||``,province:e?.province||``,city:e?.city||``,responsible_person:e?.responsible_person||``,department:e?.department||``,business_system:e?.business_system||``,tags:Array.isArray(e?.tags)?e.tags:[]}}function T({visible:e,asset:t,defaultProjectId:n=``,fixedProject:T=!1,projects:E,onClose:D,onSaved:O}){let k=c(),[A,j]=(0,x.useState)(null),[M,N]=(0,x.useState)(!1),[P,F]=(0,x.useState)(``),I=(0,x.useRef)(b(t)),L=(0,x.useMemo)(()=>w(t,n),[t,n,e]),R=!!t?.id;(0,x.useEffect)(()=>{e&&(I.current=b(t),F(``),N(!1))},[e,t]);let z=(0,x.useMemo)(()=>(E||[]).map(e=>({value:e.id,label:e.name||e.id})),[E]),B=e=>{if(!A)return null;let t=String(A.getValue(`target`)||``).trim();try{let e=y(t);return A.setValues({host:e.host,ip:e.ip,domain:e.domain,port:e.port||void 0,protocol:e.protocol}),I.current=t,e}catch(t){return e&&F(t.message),null}},V=()=>{let e=A.getValue(),n=String(e.target||``).trim(),r={host:String(e.host||``).trim(),ip:String(e.ip||``).trim().toLowerCase(),domain:String(e.domain||``).trim(),port:Number(e.port||0),protocol:String(e.protocol||``).trim().toLowerCase(),title:String(e.title||``).trim(),server:String(e.server||``).trim(),status:e.status||`active`,source:t?.source||`manual`,source_query:t?.source_query||``,country:String(e.country||``).trim(),province:String(e.province||``).trim(),city:String(e.city||``).trim(),responsible_person:String(e.responsible_person||``).trim(),department:String(e.department||``).trim(),business_system:String(e.business_system||``).trim(),environment:e.environment||``,criticality:e.criticality||``,project_id:e.project_id||``,tags:Array.isArray(e.tags)?e.tags.map(e=>String(e).trim()).filter(Boolean):[]};if(n&&n!==I.current)try{let e=y(n);r={...r,host:r.host||e.host,ip:e.ip||r.ip,domain:e.domain||r.domain,port:e.port||r.port,protocol:e.protocol||r.protocol}}catch(e){throw Error(e.message)}return r},H=()=>{let e=m(A.getValue(`targets`));if(!e.length)throw Error(k(`assets.targetRequired`,null,`请输入资产地址`));if(e.length>200)throw Error(`一次最多添加 200 个地址`);let t=T?n:A.getValue(`project_id`)||``;return e.map(e=>{let n=y(e);return{host:n.host||n.domain||n.ip,ip:n.ip,domain:n.domain,port:n.port,protocol:n.protocol,status:`active`,source:`manual`,project_id:t,tags:[]}})},U=async()=>{if(M||!A)return;F(``);try{await A.validate()}catch{return}let e,n;try{R?e=V():n=H()}catch(e){F(e.message);return}N(!0);try{if(R)await s.put(`/assets/${encodeURIComponent(t.id)}`,e),d(k(`assets.updatedSuccessfully`,null,`资产已更新`));else{let e=await s.post(`/assets/import`,{assets:n,source:`manual`}),t=Number(e?.created||0),r=Number(e?.updated||0),i=Number(e?.skipped||0);if(!t&&!r&&i)throw Error(k(`assets.assetSkipped`,null,`资产未保存,可能已存在且你没有更新权限`));let a=[];t&&a.push(`新增 ${t}`),r&&a.push(`合并 ${r}`),i&&a.push(`跳过 ${i}`),d(a.length?`已写入资产库:${a.join(`,`)}`:k(`assets.createdSuccessfully`,null,`资产已添加`))}O?.(),D?.()}catch(e){F(l(e,k(`assets.saveFailed`,null,`保存资产失败`)))}finally{N(!1)}};return(0,S.jsxs)(u,{visible:e,title:R?k(`assets.editAssetTitle`,null,`编辑资产`):k(`assets.addAssetTitle`,null,`新增资产`),width:R?760:520,onCancel:D,onOk:U,okText:R?k(`common.save`,null,`保存`):k(`assets.addAssetAction`,null,`添加资产`),confirmLoading:M,closeOnEsc:!0,children:[P&&(0,S.jsx)(o,{type:`danger`,bordered:!0,closeIcon:null,description:P,className:`asset-library-form-error`}),(0,S.jsx)(a,{className:C,initValues:L,getFormApi:j,labelPosition:`top`,onSubmit:U,children:R?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`asset-library-form-grid asset-library-form-grid--full`,children:(0,S.jsx)(a.Input,{field:`target`,label:k(`assets.assetAddress`,null,`资产地址`),placeholder:`https://example.com:443 / example.com / 1.1.1.1:22`,helpText:k(`assets.assetAddressHint`,null,`可识别的 URL、域名、IP 和端口会自动解析`),onBlur:()=>B(!0),rules:[{required:!0,message:k(`assets.targetRequired`,null,`请输入资产地址`)},{validator:(e,t,n)=>{try{y(t),n()}catch(e){n(Error(e.message))}}}]})}),(0,S.jsxs)(`div`,{className:`asset-library-form-grid`,children:[(0,S.jsx)(a.Input,{field:`host`,label:k(`assets.hostUrl`,null,`完整 URL / Host`)}),(0,S.jsx)(a.Input,{field:`ip`,label:`IP`,rules:[{validator:(e,t,n)=>{!t||g(t)||p(t)?n():n(Error(k(`assets.ipInvalid`,null,`IP 地址格式无效`)))}}]}),(0,S.jsx)(a.Input,{field:`domain`,label:k(`assets.domain`,null,`域名`),rules:[{validator:(e,t,n)=>{!t||_(t)&&!g(t)&&!p(t)?n():n(Error(k(`assets.domainInvalid`,null,`域名格式无效`)))}}]}),(0,S.jsx)(a.InputNumber,{field:`port`,label:k(`assets.port`,null,`端口`),min:0,max:65535,style:{width:`100%`}}),(0,S.jsx)(a.Input,{field:`protocol`,label:k(`assets.protocol`,null,`协议`),rules:[{validator:(e,t,n)=>{!t||/^[a-z][a-z0-9+.-]{0,31}$/.test(String(t).toLowerCase())?n():n(Error(k(`assets.protocolInvalid`,null,`协议格式无效`)))}}]}),(0,S.jsx)(a.Input,{field:`title`,label:k(`assets.pageTitle`,null,`页面标题`)}),(0,S.jsx)(a.Input,{field:`server`,label:k(`assets.serverProduct`,null,`服务 / 产品`)}),(0,S.jsx)(a.Select,{field:`project_id`,label:k(`assets.project`,null,`所属项目`),optionList:z,filter:!0,showClear:!0,placeholder:k(`assets.unboundProject`,null,`暂不绑定`)}),(0,S.jsx)(a.Select,{field:`status`,label:k(`assets.status`,null,`状态`),optionList:f}),(0,S.jsx)(a.Select,{field:`environment`,label:k(`assets.environment`,null,`环境`),optionList:h,showClear:!0,placeholder:`—`}),(0,S.jsx)(a.Select,{field:`criticality`,label:k(`assets.criticality`,null,`重要性`),optionList:v,showClear:!0,placeholder:`—`}),(0,S.jsx)(a.Input,{field:`country`,label:k(`assets.country`,null,`国家/地区`)}),(0,S.jsx)(a.Input,{field:`province`,label:k(`assets.province`,null,`省份/州`)}),(0,S.jsx)(a.Input,{field:`city`,label:k(`assets.city`,null,`城市`)}),(0,S.jsx)(a.Input,{field:`responsible_person`,label:k(`assets.responsiblePerson`,null,`负责人`)}),(0,S.jsx)(a.Input,{field:`department`,label:k(`assets.department`,null,`部门`)}),(0,S.jsx)(a.Input,{field:`business_system`,label:k(`assets.businessSystem`,null,`业务系统`)})]}),(0,S.jsx)(a.TagInput,{field:`tags`,label:k(`assets.tagsLabel`,null,`标签`),placeholder:k(`assets.tagsPlaceholder`,null,`输入后按回车或逗号`),max:30,maxLength:64,addOnBlur:!0,separator:`,,`,style:{width:`100%`}}),(0,S.jsx)(r,{className:`asset-library-editor-actions`,children:(0,S.jsx)(i,{theme:`borderless`,onClick:()=>B(!0),children:k(`assets.parseTarget`,null,`解析资产地址`)})})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(a.TextArea,{field:`targets`,label:k(`assets.assetAddress`,null,`资产地址`),rows:8,placeholder:`https://example.com/login
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,L as i,i as a,z as o}from"./semi-Dpcldp_F.js";import{I as s,P as c,R as l,c as u,x as d}from"./index-BMTtTYg1.js";import{E as f,a as p,c as m,h,i as g,o as _,p as v,s as y,u as b}from"./assetTarget-D2PEjBAg.js";var x=e(t(),1),S=e(n(),1),C=`asset-library-editor`;function w(e,t){return{target:b(e),host:e?.host||``,ip:e?.ip||``,domain:e?.domain||``,port:e?.port??void 0,protocol:e?.protocol||``,title:e?.title||``,server:e?.server||``,project_id:e?e.project_id||``:t,status:e?.status||`active`,environment:e?.environment||``,criticality:e?.criticality||``,country:e?.country||``,province:e?.province||``,city:e?.city||``,responsible_person:e?.responsible_person||``,department:e?.department||``,business_system:e?.business_system||``,tags:Array.isArray(e?.tags)?e.tags:[]}}function T({visible:e,asset:t,defaultProjectId:n=``,fixedProject:T=!1,projects:E,onClose:D,onSaved:O}){let k=c(),[A,j]=(0,x.useState)(null),[M,N]=(0,x.useState)(!1),[P,F]=(0,x.useState)(``),I=(0,x.useRef)(b(t)),L=(0,x.useMemo)(()=>w(t,n),[t,n,e]),R=!!t?.id;(0,x.useEffect)(()=>{e&&(I.current=b(t),F(``),N(!1))},[e,t]);let z=(0,x.useMemo)(()=>(E||[]).map(e=>({value:e.id,label:e.name||e.id})),[E]),B=e=>{if(!A)return null;let t=String(A.getValue(`target`)||``).trim();try{let e=y(t);return A.setValues({host:e.host,ip:e.ip,domain:e.domain,port:e.port||void 0,protocol:e.protocol}),I.current=t,e}catch(t){return e&&F(t.message),null}},V=()=>{let e=A.getValue(),n=String(e.target||``).trim(),r={host:String(e.host||``).trim(),ip:String(e.ip||``).trim().toLowerCase(),domain:String(e.domain||``).trim(),port:Number(e.port||0),protocol:String(e.protocol||``).trim().toLowerCase(),title:String(e.title||``).trim(),server:String(e.server||``).trim(),status:e.status||`active`,source:t?.source||`manual`,source_query:t?.source_query||``,country:String(e.country||``).trim(),province:String(e.province||``).trim(),city:String(e.city||``).trim(),responsible_person:String(e.responsible_person||``).trim(),department:String(e.department||``).trim(),business_system:String(e.business_system||``).trim(),environment:e.environment||``,criticality:e.criticality||``,project_id:e.project_id||``,tags:Array.isArray(e.tags)?e.tags.map(e=>String(e).trim()).filter(Boolean):[]};if(n&&n!==I.current)try{let e=y(n);r={...r,host:r.host||e.host,ip:e.ip||r.ip,domain:e.domain||r.domain,port:e.port||r.port,protocol:e.protocol||r.protocol}}catch(e){throw Error(e.message)}return r},H=()=>{let e=m(A.getValue(`targets`));if(!e.length)throw Error(k(`assets.targetRequired`,null,`请输入资产地址`));if(e.length>200)throw Error(`一次最多添加 200 个地址`);let t=T?n:A.getValue(`project_id`)||``;return e.map(e=>{let n=y(e);return{host:n.host||n.domain||n.ip,ip:n.ip,domain:n.domain,port:n.port,protocol:n.protocol,status:`active`,source:`manual`,project_id:t,tags:[]}})},U=async()=>{if(M||!A)return;F(``);try{await A.validate()}catch{return}let e,n;try{R?e=V():n=H()}catch(e){F(e.message);return}N(!0);try{if(R)await s.put(`/assets/${encodeURIComponent(t.id)}`,e),d(k(`assets.updatedSuccessfully`,null,`资产已更新`));else{let e=await s.post(`/assets/import`,{assets:n,source:`manual`}),t=Number(e?.created||0),r=Number(e?.updated||0),i=Number(e?.skipped||0);if(!t&&!r&&i)throw Error(k(`assets.assetSkipped`,null,`资产未保存,可能已存在且你没有更新权限`));let a=[];t&&a.push(`新增 ${t}`),r&&a.push(`合并 ${r}`),i&&a.push(`跳过 ${i}`),d(a.length?`已写入资产库:${a.join(`,`)}`:k(`assets.createdSuccessfully`,null,`资产已添加`))}O?.(),D?.()}catch(e){F(l(e,k(`assets.saveFailed`,null,`保存资产失败`)))}finally{N(!1)}};return(0,S.jsxs)(u,{visible:e,title:R?k(`assets.editAssetTitle`,null,`编辑资产`):k(`assets.addAssetTitle`,null,`新增资产`),width:R?760:520,onCancel:D,onOk:U,okText:R?k(`common.save`,null,`保存`):k(`assets.addAssetAction`,null,`添加资产`),confirmLoading:M,closeOnEsc:!0,children:[P&&(0,S.jsx)(o,{type:`danger`,bordered:!0,closeIcon:null,description:P,className:`asset-library-form-error`}),(0,S.jsx)(a,{className:C,initValues:L,getFormApi:j,labelPosition:`top`,onSubmit:U,children:R?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`asset-library-form-grid asset-library-form-grid--full`,children:(0,S.jsx)(a.Input,{field:`target`,label:k(`assets.assetAddress`,null,`资产地址`),placeholder:`https://example.com:443 / example.com / 1.1.1.1:22`,helpText:k(`assets.assetAddressHint`,null,`可识别的 URL、域名、IP 和端口会自动解析`),onBlur:()=>B(!0),rules:[{required:!0,message:k(`assets.targetRequired`,null,`请输入资产地址`)},{validator:(e,t,n)=>{try{y(t),n()}catch(e){n(Error(e.message))}}}]})}),(0,S.jsxs)(`div`,{className:`asset-library-form-grid`,children:[(0,S.jsx)(a.Input,{field:`host`,label:k(`assets.hostUrl`,null,`完整 URL / Host`)}),(0,S.jsx)(a.Input,{field:`ip`,label:`IP`,rules:[{validator:(e,t,n)=>{!t||g(t)||p(t)?n():n(Error(k(`assets.ipInvalid`,null,`IP 地址格式无效`)))}}]}),(0,S.jsx)(a.Input,{field:`domain`,label:k(`assets.domain`,null,`域名`),rules:[{validator:(e,t,n)=>{!t||_(t)&&!g(t)&&!p(t)?n():n(Error(k(`assets.domainInvalid`,null,`域名格式无效`)))}}]}),(0,S.jsx)(a.InputNumber,{field:`port`,label:k(`assets.port`,null,`端口`),min:0,max:65535,style:{width:`100%`}}),(0,S.jsx)(a.Input,{field:`protocol`,label:k(`assets.protocol`,null,`协议`),rules:[{validator:(e,t,n)=>{!t||/^[a-z][a-z0-9+.-]{0,31}$/.test(String(t).toLowerCase())?n():n(Error(k(`assets.protocolInvalid`,null,`协议格式无效`)))}}]}),(0,S.jsx)(a.Input,{field:`title`,label:k(`assets.pageTitle`,null,`页面标题`)}),(0,S.jsx)(a.Input,{field:`server`,label:k(`assets.serverProduct`,null,`服务 / 产品`)}),(0,S.jsx)(a.Select,{field:`project_id`,label:k(`assets.project`,null,`所属项目`),optionList:z,filter:!0,showClear:!0,placeholder:k(`assets.unboundProject`,null,`暂不绑定`)}),(0,S.jsx)(a.Select,{field:`status`,label:k(`assets.status`,null,`状态`),optionList:f}),(0,S.jsx)(a.Select,{field:`environment`,label:k(`assets.environment`,null,`环境`),optionList:h,showClear:!0,placeholder:`—`}),(0,S.jsx)(a.Select,{field:`criticality`,label:k(`assets.criticality`,null,`重要性`),optionList:v,showClear:!0,placeholder:`—`}),(0,S.jsx)(a.Input,{field:`country`,label:k(`assets.country`,null,`国家/地区`)}),(0,S.jsx)(a.Input,{field:`province`,label:k(`assets.province`,null,`省份/州`)}),(0,S.jsx)(a.Input,{field:`city`,label:k(`assets.city`,null,`城市`)}),(0,S.jsx)(a.Input,{field:`responsible_person`,label:k(`assets.responsiblePerson`,null,`负责人`)}),(0,S.jsx)(a.Input,{field:`department`,label:k(`assets.department`,null,`部门`)}),(0,S.jsx)(a.Input,{field:`business_system`,label:k(`assets.businessSystem`,null,`业务系统`)})]}),(0,S.jsx)(a.TagInput,{field:`tags`,label:k(`assets.tagsLabel`,null,`标签`),placeholder:k(`assets.tagsPlaceholder`,null,`输入后按回车或逗号`),max:30,maxLength:64,addOnBlur:!0,separator:`,,`,style:{width:`100%`}}),(0,S.jsx)(r,{className:`asset-library-editor-actions`,children:(0,S.jsx)(i,{theme:`borderless`,onClick:()=>B(!0),children:k(`assets.parseTarget`,null,`解析资产地址`)})})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(a.TextArea,{field:`targets`,label:k(`assets.assetAddress`,null,`资产地址`),rows:8,placeholder:`https://example.com/login
example.com:443
1.1.1.1:22`,helpText:`每行一个,或用空格、逗号隔开。直接粘贴 URL、域名或 IP:端口。`,rules:[{required:!0,validator:(e,t,n)=>{let r=m(t);if(!r.length)n(Error(k(`assets.targetRequired`,null,`请输入资产地址`)));else{for(let e of r)try{y(e)}catch(t){n(Error(`${e}:${t.message}`));return}n()}}}]}),(0,S.jsx)(a.Select,{field:`project_id`,label:k(`assets.project`,null,`所属项目`),optionList:z,disabled:T,filter:!0,showClear:!T,placeholder:k(`assets.unboundProject`,null,`暂不绑定`),style:{width:`100%`}})]})},`${t?.id||`new-asset`}-${e?`open`:`closed`}`)]})}export{T as t};
\ No newline at end of file
diff --git a/web/static/app/assets/agents-management-BtTb6SoA.js b/web/static/app/assets/agents-management-XOSUN0Hb.js
similarity index 97%
rename from web/static/app/assets/agents-management-BtTb6SoA.js
rename to web/static/app/assets/agents-management-XOSUN0Hb.js
index 0af458c9..a70e4f97 100644
--- a/web/static/app/assets/agents-management-BtTb6SoA.js
+++ b/web/static/app/assets/agents-management-XOSUN0Hb.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,W as s,ot as c,st as l}from"./semi-Dpcldp_F.js";import{F as u,I as d,P as f,a as p,b as m,c as h,d as g,f as _,l as v,m as y,p as b,s as x,u as S}from"./index-gBcdNgHq.js";var C=e(t(),1),w=e(n(),1),{Text:T}=s;function E(){let e=f(),{hasPermission:t}=u(),n=t(`agents:write`),[s,E]=(0,C.useState)(``),[D,O]=(0,C.useState)(null),k=p(()=>d.get(`/multi-agent/markdown-agents`),[]),A=(Array.isArray(k.data?.agents)?k.data.agents:[]).filter(e=>{if(!s)return!0;let t=s.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),j=async e=>{try{O(await d.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){m(e,`读取智能体失败`)}};return(0,w.jsxs)(`div`,{children:[(0,w.jsx)(b,{title:e(`agents.title`,null,`智能体管理`),description:k.data?.dir?`目录:${k.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,w.jsxs)(r,{children:[(0,w.jsx)(a,{icon:(0,w.jsx)(l,{}),onClick:()=>k.reload(),loading:k.loading,children:`刷新`}),n&&(0,w.jsx)(a,{href:`/classic#agents-management`,children:`管理智能体配置`})]})}),k.data?.error&&(0,w.jsx)(v,{error:k.data.error}),(0,w.jsxs)(y,{title:`智能体(${A.length})`,children:[(0,w.jsx)(v,{error:k.error,onRetry:()=>k.reload()}),(0,w.jsx)(x,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,w.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,w.jsxs)(r,{children:[(0,w.jsx)(T,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,w.jsx)(o,{size:`small`,color:`purple`,children:`编排器`})]}),(0,w.jsx)(T,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,w.jsx)(o,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,w.jsx)(T,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,w.jsx)(r,{children:(0,w.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>j(t),children:`详情`})})}],dataSource:A,rowKey:`filename`,loading:k.loading,pagination:{pageSize:20},toolbar:(0,w.jsx)(i,{prefix:(0,w.jsx)(c,{}),value:s,onChange:E,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,w.jsx)(h,{title:D?.name||`智能体详情`,visible:!!D,onCancel:()=>O(null),width:720,children:D&&(0,w.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,w.jsx)(g,{items:[{label:`文件名`,value:D.filename},{label:`ID`,value:D.id},{label:`类型`,value:D.kind},{label:`绑定角色`,value:D.bind_role||`—`},{label:`最大迭代`,value:D.max_iterations??`—`},{label:`工具`,value:Array.isArray(D.tools)&&D.tools.length?D.tools.join(`、`):`—`}]}),(0,w.jsx)(_,{content:D.instruction||D.raw||``}),(0,w.jsx)(S,{value:D.raw||D,title:`原始 Markdown`,collapsed:!0})]})})]})}export{E 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,W as s,ot as c,st as l}from"./semi-Dpcldp_F.js";import{F as u,I as d,P as f,a as p,b as m,c as h,d as g,f as _,l as v,m as y,p as b,s as x,u as S}from"./index-BMTtTYg1.js";var C=e(t(),1),w=e(n(),1),{Text:T}=s;function E(){let e=f(),{hasPermission:t}=u(),n=t(`agents:write`),[s,E]=(0,C.useState)(``),[D,O]=(0,C.useState)(null),k=p(()=>d.get(`/multi-agent/markdown-agents`),[]),A=(Array.isArray(k.data?.agents)?k.data.agents:[]).filter(e=>{if(!s)return!0;let t=s.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),j=async e=>{try{O(await d.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){m(e,`读取智能体失败`)}};return(0,w.jsxs)(`div`,{children:[(0,w.jsx)(b,{title:e(`agents.title`,null,`智能体管理`),description:k.data?.dir?`目录:${k.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,w.jsxs)(r,{children:[(0,w.jsx)(a,{icon:(0,w.jsx)(l,{}),onClick:()=>k.reload(),loading:k.loading,children:`刷新`}),n&&(0,w.jsx)(a,{href:`/classic#agents-management`,children:`管理智能体配置`})]})}),k.data?.error&&(0,w.jsx)(v,{error:k.data.error}),(0,w.jsxs)(y,{title:`智能体(${A.length})`,children:[(0,w.jsx)(v,{error:k.error,onRetry:()=>k.reload()}),(0,w.jsx)(x,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,w.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,w.jsxs)(r,{children:[(0,w.jsx)(T,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,w.jsx)(o,{size:`small`,color:`purple`,children:`编排器`})]}),(0,w.jsx)(T,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,w.jsx)(o,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,w.jsx)(T,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,w.jsx)(r,{children:(0,w.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>j(t),children:`详情`})})}],dataSource:A,rowKey:`filename`,loading:k.loading,pagination:{pageSize:20},toolbar:(0,w.jsx)(i,{prefix:(0,w.jsx)(c,{}),value:s,onChange:E,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,w.jsx)(h,{title:D?.name||`智能体详情`,visible:!!D,onCancel:()=>O(null),width:720,children:D&&(0,w.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,w.jsx)(g,{items:[{label:`文件名`,value:D.filename},{label:`ID`,value:D.id},{label:`类型`,value:D.kind},{label:`绑定角色`,value:D.bind_role||`—`},{label:`最大迭代`,value:D.max_iterations??`—`},{label:`工具`,value:Array.isArray(D.tools)&&D.tools.length?D.tools.join(`、`):`—`}]}),(0,w.jsx)(_,{content:D.instruction||D.raw||``}),(0,w.jsx)(S,{value:D.raw||D,title:`原始 Markdown`,collapsed:!0})]})})]})}export{E as default};
\ No newline at end of file
diff --git a/web/static/app/assets/api-docs-hlf8fxq5.js b/web/static/app/assets/api-docs-CmsQDaBX.js
similarity index 98%
rename from web/static/app/assets/api-docs-hlf8fxq5.js
rename to web/static/app/assets/api-docs-CmsQDaBX.js
index d735f23b..b08ac298 100644
--- a/web/static/app/assets/api-docs-hlf8fxq5.js
+++ b/web/static/app/assets/api-docs-CmsQDaBX.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,P as s,W as c,c as l,ot as u,st as d,v as f}from"./semi-Dpcldp_F.js";import{I as p,P as m,R as h,p as g,u as _}from"./index-gBcdNgHq.js";var v=e(t(),1),y=e(n(),1),{Text:b,Paragraph:x}=c,S={get:`blue`,post:`green`,put:`orange`,delete:`red`,patch:`violet`,head:`grey`,options:`grey`};function C(e){let t=e?.paths||{},n=[];return Object.entries(t).forEach(([e,t])=>{Object.entries(t||{}).forEach(([t,r])=>{Object.hasOwn(S,t)&&r&&n.push({id:`${t.toUpperCase()} ${e}`,method:t.toUpperCase(),path:e,summary:r.summary||r.description||``,tag:r.tags&&r.tags[0]||`default`,operation:r})})}),n.sort((e,t)=>e.path.localeCompare(t.path)||e.method.localeCompare(t.method))}function w(){let e=m(),[t,n]=(0,v.useState)(null),[c,w]=(0,v.useState)(!0),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(`all`),[j,M]=(0,v.useState)(null),N=async()=>{w(!0),E(null);try{let e=await p.get(`/openapi/spec`);n(e)}catch(e){E(e)}finally{w(!1)}};(0,v.useEffect)(()=>{N()},[]);let P=(0,v.useMemo)(()=>C(t),[t]),F=(0,v.useMemo)(()=>P.filter(e=>{if(k!==`all`&&e.method!==k)return!1;if(!D)return!0;let t=D.toLowerCase();return e.path.toLowerCase().includes(t)||e.summary.toLowerCase().includes(t)||e.method.toLowerCase().includes(t)}),[P,D,k]),I=F.find(e=>e.id===j)||F[0]||null,L=(0,v.useMemo)(()=>{let e=new Map;return F.forEach(t=>{e.has(t.tag)||e.set(t.tag,[]),e.get(t.tag).push(t)}),[...e.entries()]},[F]);return(0,y.jsxs)(`div`,{className:`api-docs-page`,children:[(0,y.jsx)(g,{title:e(`apiDocs.title`,null,`API 文档`),description:t?.info?.description||`CyberStrikeAI 开放接口`,extra:(0,y.jsxs)(r,{wrap:!0,children:[(0,y.jsx)(a,{icon:(0,y.jsx)(d,{}),onClick:N,loading:c,children:e(`common.refresh`,null,`刷新`)}),(0,y.jsx)(b,{link:{href:`/api-docs`},children:e(`apiDocs.openConsole`,null,`打开 API 控制台`)})]})}),(0,y.jsxs)(`div`,{className:`api-docs-layout`,children:[(0,y.jsxs)(s,{className:`api-docs-sidebar`,bordered:!1,children:[(0,y.jsxs)(r,{vertical:!0,style:{width:`100%`},spacing:8,children:[(0,y.jsx)(i,{prefix:(0,y.jsx)(u,{}),value:D,onChange:O,placeholder:`搜索路径或说明`}),(0,y.jsx)(f,{value:k,onChange:A,style:{width:`100%`},optionList:[{value:`all`,label:`全部方法`},...[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`].map(e=>({value:e,label:e}))]})]}),(0,y.jsxs)(`div`,{className:`api-docs-list`,children:[L.map(([e,t])=>(0,y.jsxs)(`div`,{className:`api-docs-group`,children:[(0,y.jsx)(b,{type:`tertiary`,className:`api-docs-group-title`,children:e}),t.map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`api-docs-item ${I?.id===e.id?`is-active`:``}`,onClick:()=>M(e.id),children:[(0,y.jsx)(o,{size:`small`,color:S[e.method.toLowerCase()],children:e.method}),(0,y.jsx)(`span`,{className:`api-docs-item-path`,children:e.path})]},e.id))]},e)),!c&&L.length===0&&(0,y.jsx)(b,{type:`tertiary`,children:`没有匹配的接口`})]})]}),(0,y.jsxs)(`div`,{className:`api-docs-detail`,children:[T&&(0,y.jsx)(s,{bordered:!1,children:(0,y.jsx)(b,{type:`danger`,children:h(T)})}),I?(0,y.jsxs)(s,{bordered:!1,children:[(0,y.jsxs)(`div`,{className:`api-docs-detail-head`,children:[(0,y.jsx)(o,{color:S[I.method.toLowerCase()],children:I.method}),(0,y.jsx)(`code`,{className:`api-docs-detail-path`,children:I.path})]}),(0,y.jsx)(x,{children:I.summary||`无说明`}),(0,y.jsxs)(l,{type:`line`,children:[(0,y.jsx)(l.TabPane,{itemKey:`params`,tab:`参数`,children:(0,y.jsx)(_,{value:I.operation.parameters||[],title:`Request Parameters`,collapsed:!0})}),(0,y.jsx)(l.TabPane,{itemKey:`body`,tab:`请求体`,children:(0,y.jsx)(_,{value:I.operation.requestBody||{},title:`Request Body`,collapsed:!0})}),(0,y.jsx)(l.TabPane,{itemKey:`responses`,tab:`响应`,children:(0,y.jsx)(_,{value:I.operation.responses||{},title:`Responses`,collapsed:!0})})]})]}):(0,y.jsx)(s,{bordered:!1,children:(0,y.jsx)(b,{type:`tertiary`,children:c?`加载中…`:`选择左侧接口查看详情`})})]})]})]})}export{w as default};
\ 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,P as s,W as c,c as l,ot as u,st as d,v as f}from"./semi-Dpcldp_F.js";import{I as p,P as m,R as h,p as g,u as _}from"./index-BMTtTYg1.js";var v=e(t(),1),y=e(n(),1),{Text:b,Paragraph:x}=c,S={get:`blue`,post:`green`,put:`orange`,delete:`red`,patch:`violet`,head:`grey`,options:`grey`};function C(e){let t=e?.paths||{},n=[];return Object.entries(t).forEach(([e,t])=>{Object.entries(t||{}).forEach(([t,r])=>{Object.hasOwn(S,t)&&r&&n.push({id:`${t.toUpperCase()} ${e}`,method:t.toUpperCase(),path:e,summary:r.summary||r.description||``,tag:r.tags&&r.tags[0]||`default`,operation:r})})}),n.sort((e,t)=>e.path.localeCompare(t.path)||e.method.localeCompare(t.method))}function w(){let e=m(),[t,n]=(0,v.useState)(null),[c,w]=(0,v.useState)(!0),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(`all`),[j,M]=(0,v.useState)(null),N=async()=>{w(!0),E(null);try{let e=await p.get(`/openapi/spec`);n(e)}catch(e){E(e)}finally{w(!1)}};(0,v.useEffect)(()=>{N()},[]);let P=(0,v.useMemo)(()=>C(t),[t]),F=(0,v.useMemo)(()=>P.filter(e=>{if(k!==`all`&&e.method!==k)return!1;if(!D)return!0;let t=D.toLowerCase();return e.path.toLowerCase().includes(t)||e.summary.toLowerCase().includes(t)||e.method.toLowerCase().includes(t)}),[P,D,k]),I=F.find(e=>e.id===j)||F[0]||null,L=(0,v.useMemo)(()=>{let e=new Map;return F.forEach(t=>{e.has(t.tag)||e.set(t.tag,[]),e.get(t.tag).push(t)}),[...e.entries()]},[F]);return(0,y.jsxs)(`div`,{className:`api-docs-page`,children:[(0,y.jsx)(g,{title:e(`apiDocs.title`,null,`API 文档`),description:t?.info?.description||`CyberStrikeAI 开放接口`,extra:(0,y.jsxs)(r,{wrap:!0,children:[(0,y.jsx)(a,{icon:(0,y.jsx)(d,{}),onClick:N,loading:c,children:e(`common.refresh`,null,`刷新`)}),(0,y.jsx)(b,{link:{href:`/api-docs`},children:e(`apiDocs.openConsole`,null,`打开 API 控制台`)})]})}),(0,y.jsxs)(`div`,{className:`api-docs-layout`,children:[(0,y.jsxs)(s,{className:`api-docs-sidebar`,bordered:!1,children:[(0,y.jsxs)(r,{vertical:!0,style:{width:`100%`},spacing:8,children:[(0,y.jsx)(i,{prefix:(0,y.jsx)(u,{}),value:D,onChange:O,placeholder:`搜索路径或说明`}),(0,y.jsx)(f,{value:k,onChange:A,style:{width:`100%`},optionList:[{value:`all`,label:`全部方法`},...[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`].map(e=>({value:e,label:e}))]})]}),(0,y.jsxs)(`div`,{className:`api-docs-list`,children:[L.map(([e,t])=>(0,y.jsxs)(`div`,{className:`api-docs-group`,children:[(0,y.jsx)(b,{type:`tertiary`,className:`api-docs-group-title`,children:e}),t.map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`api-docs-item ${I?.id===e.id?`is-active`:``}`,onClick:()=>M(e.id),children:[(0,y.jsx)(o,{size:`small`,color:S[e.method.toLowerCase()],children:e.method}),(0,y.jsx)(`span`,{className:`api-docs-item-path`,children:e.path})]},e.id))]},e)),!c&&L.length===0&&(0,y.jsx)(b,{type:`tertiary`,children:`没有匹配的接口`})]})]}),(0,y.jsxs)(`div`,{className:`api-docs-detail`,children:[T&&(0,y.jsx)(s,{bordered:!1,children:(0,y.jsx)(b,{type:`danger`,children:h(T)})}),I?(0,y.jsxs)(s,{bordered:!1,children:[(0,y.jsxs)(`div`,{className:`api-docs-detail-head`,children:[(0,y.jsx)(o,{color:S[I.method.toLowerCase()],children:I.method}),(0,y.jsx)(`code`,{className:`api-docs-detail-path`,children:I.path})]}),(0,y.jsx)(x,{children:I.summary||`无说明`}),(0,y.jsxs)(l,{type:`line`,children:[(0,y.jsx)(l.TabPane,{itemKey:`params`,tab:`参数`,children:(0,y.jsx)(_,{value:I.operation.parameters||[],title:`Request Parameters`,collapsed:!0})}),(0,y.jsx)(l.TabPane,{itemKey:`body`,tab:`请求体`,children:(0,y.jsx)(_,{value:I.operation.requestBody||{},title:`Request Body`,collapsed:!0})}),(0,y.jsx)(l.TabPane,{itemKey:`responses`,tab:`响应`,children:(0,y.jsx)(_,{value:I.operation.responses||{},title:`Responses`,collapsed:!0})})]})]}):(0,y.jsx)(s,{bordered:!1,children:(0,y.jsx)(b,{type:`tertiary`,children:c?`加载中…`:`选择左侧接口查看详情`})})]})]})]})}export{w as default};
\ No newline at end of file
diff --git a/web/static/app/assets/asset-library-1Ly1ptCD.js b/web/static/app/assets/asset-library-XMBnFkCS.js
similarity index 99%
rename from web/static/app/assets/asset-library-1Ly1ptCD.js
rename to web/static/app/assets/asset-library-XMBnFkCS.js
index 6a6c4a7f..9516500a 100644
--- a/web/static/app/assets/asset-library-1Ly1ptCD.js
+++ b/web/static/app/assets/asset-library-XMBnFkCS.js
@@ -1,3 +1,3 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,h as r,t as i,y as a}from"./react-QV7DAAIx.js";import{A as o,E as s,F as c,H as l,L as u,Nt as d,W as f,f as p,l as m,lt as h,m as g,ot as _,p as v,st as y,u as b,v as x,x as ee,z as S}from"./semi-Dpcldp_F.js";import{E as C,F as w,I as T,P as E,R as D,S as O,a as te,b as k,c as A,d as j,l as ne,m as re,n as ie,o as ae,p as oe,s as M,x as N,y as se}from"./index-gBcdNgHq.js";import{A as ce,C as le,D as ue,E as de,M as fe,O as pe,S as me,T as he,_ as ge,a as _e,b as ve,d as ye,f as be,g as xe,h as P,i as F,k as I,l as L,m as Se,n as Ce,o as R,p as we,r as z,s as Te,t as B,v as V,w as H,y as U}from"./assetTarget-D2PEjBAg.js";import{a as Ee,i as W,n as De,r as G,t as Oe}from"./AssetBits-BYTpudK4.js";import{t as ke}from"./AssetEditorModal-DNgfDOqO.js";var K=e(t(),1),q=e(i(),1),Ae={q:``,protocol:``,source:``,tag:``,status:``,risk_level:``,environment:``,criticality:``,ip:``,domain:``,port:``,scan:``,sort:`last_seen_at:desc`};function je(){return{...Ae}}function Me({scope:e,filters:t,onChange:n,onReset:r,disabled:i}){let a=E(),s=(0,K.useId)(),[c,d]=(0,K.useState)(t.q||``);(0,K.useEffect)(()=>{d(t.q||``)},[t.q]);let f=[`status`,`risk_level`,`environment`,`criticality`,`ip`,`domain`,`port`,`scan`].filter(e=>t[e]).length;return(0,q.jsxs)(`div`,{className:`asset-library-filters`,children:[(0,q.jsxs)(`div`,{className:`asset-library-filter-row`,children:[(0,q.jsx)(`span`,{id:s,hidden:!0,children:a(`assets.scopeLabel`,null,`资产范围`)}),(0,q.jsx)(x,{"aria-labelledby":s,value:e.value,optionList:e.options,loading:e.loading,disabled:i,onChange:e.onChange,filter:!0}),(0,q.jsx)(l,{className:`asset-library-filter-search`,prefix:(0,q.jsx)(_,{}),value:c,disabled:i,placeholder:a(`assets.searchPlaceholder`,null,`搜索主机、IP、域名、标题、服务或标签`),onChange:e=>{d(e),n({q:e})},showClear:!0}),(0,q.jsx)(x,{value:t.protocol||void 0,placeholder:a(`assets.assetType`,null,`类型 / 协议`),optionList:ve,filter:!0,allowCreate:!0,showClear:!0,disabled:i,onChange:e=>n({protocol:e||``})}),(0,q.jsx)(l,{value:t.source,placeholder:a(`assets.source`,null,`来源`),disabled:i,onChange:e=>n({source:e}),showClear:!0}),(0,q.jsx)(l,{value:t.tag,placeholder:a(`assets.tagsLabel`,null,`标签`),disabled:i,onChange:e=>n({tag:e}),showClear:!0}),(0,q.jsx)(u,{onClick:r,disabled:i,children:a(`assets.resetFilters`,null,`重置`)})]}),(0,q.jsx)(o,{className:`asset-library-filter-advanced`,keepDOM:!1,children:(0,q.jsx)(o.Panel,{itemKey:`advanced`,header:`${a(`assets.advancedFilters`,null,`高级筛选`)}${f?`(${f})`:``}`,children:(0,q.jsxs)(`div`,{className:`asset-library-filter-grid`,children:[(0,q.jsx)(x,{value:t.status||void 0,placeholder:a(`assets.allStatuses`,null,`全部状态`),optionList:de,showClear:!0,disabled:i,onChange:e=>n({status:e||``})}),(0,q.jsx)(x,{value:t.risk_level||void 0,placeholder:a(`assets.allRisks`,null,`全部风险`),optionList:me,showClear:!0,disabled:i,onChange:e=>n({risk_level:e||``})}),(0,q.jsx)(x,{value:t.environment||void 0,placeholder:a(`assets.allEnvironments`,null,`全部环境`),optionList:P,showClear:!0,disabled:i,onChange:e=>n({environment:e||``})}),(0,q.jsx)(x,{value:t.criticality||void 0,placeholder:a(`assets.allCriticalities`,null,`全部级别`),optionList:we,showClear:!0,disabled:i,onChange:e=>n({criticality:e||``})}),(0,q.jsx)(l,{value:t.ip,placeholder:`IP`,disabled:i,onChange:e=>n({ip:e}),showClear:!0}),(0,q.jsx)(l,{value:t.domain,placeholder:a(`assets.domain`,null,`域名`),disabled:i,onChange:e=>n({domain:e}),showClear:!0}),(0,q.jsx)(l,{value:t.port,placeholder:a(`assets.port`,null,`端口`),disabled:i,onChange:e=>n({port:String(e||``).replace(/[^\d]/g,``)}),showClear:!0}),(0,q.jsx)(x,{value:t.scan||``,placeholder:a(`assets.scanState`,null,`扫描状态`),optionList:le,disabled:i,onChange:e=>n({scan:e||``})}),(0,q.jsx)(x,{value:t.sort||`last_seen_at:desc`,optionList:H,disabled:i,onChange:e=>n({sort:e||`last_seen_at:desc`})})]})})})]})}var{Text:J}=f;function Ne({assets:e,loading:t,total:n,page:r,pageSize:i,onPageChange:a,onPageSizeChange:o,selectedRowKeys:s,onSelectionChange:l,onView:d,onEdit:f,onDelete:p,onRefresh:m,canWrite:h,canDelete:g}){let _=E(),v=e=>{se({title:_(`assets.deleteConfirm`,null,`确定删除该资产吗?`),content:z(e),okText:_(`common.delete`,null,`删除`),onOk:()=>{Promise.resolve(p(e)).catch(e=>k(e,_(`assets.deleteFailed`,null,`删除资产失败`)))}})},y=[{title:_(`assets.target`,null,`目标`),dataIndex:`host`,width:260,render:(e,t)=>(0,q.jsxs)(`div`,{className:`asset-library-target`,children:[(0,q.jsx)(Ee,{text:z(t),max:38}),(0,q.jsx)(J,{type:`tertiary`,size:`small`,children:[t.ip,t.domain].filter(Boolean).join(` · `)||`—`})]})},{title:_(`assets.service`,null,`服务`),dataIndex:`protocol`,width:150,render:(e,t)=>(0,q.jsx)(De,{protocol:t.protocol,port:t.port})},{title:_(`assets.project`,null,`所属项目`),dataIndex:`project_name`,width:160,render:(e,t)=>(0,q.jsx)(Ee,{text:e||t.project_id||_(`assets.scopeUnassigned`,null,`未归属项目`),max:18})},{title:_(`assets.source`,null,`来源`),dataIndex:`source`,width:120,render:e=>(0,q.jsx)(Ee,{text:e,max:14})},{title:_(`assets.riskLevel`,null,`风险等级`),dataIndex:`risk_level`,width:150,render:(e,t)=>(0,q.jsxs)(c,{spacing:6,children:[(0,q.jsx)(G,{asset:t}),(0,q.jsx)(J,{type:`tertiary`,size:`small`,children:Number(t.vulnerability_count||0)})]})},{title:_(`assets.lastSeen`,null,`最近发现`),dataIndex:`last_seen_at`,width:170,render:e=>(0,q.jsx)(J,{size:`small`,children:C(e)})},{title:_(`common.actions`,null,`操作`),dataIndex:`id`,width:190,render:(e,t)=>(0,q.jsxs)(c,{spacing:4,children:[(0,q.jsx)(u,{theme:`borderless`,size:`small`,onClick:()=>d(t),children:_(`common.view`,null,`查看`)}),h&&(0,q.jsx)(u,{theme:`borderless`,size:`small`,onClick:()=>f(t),children:_(`common.edit`,null,`编辑`)}),g&&(0,q.jsx)(u,{theme:`borderless`,type:`danger`,size:`small`,onClick:()=>v(t),children:_(`common.delete`,null,`删除`)})]})}];return(0,q.jsx)(M,{columns:y,dataSource:e,loading:t,rowKey:`id`,onRefresh:m,rowSelection:{selectedRowKeys:s,onChange:(e,t)=>l(e,t)},pagination:{currentPage:r,pageSize:i,total:n||0,showSizeChanger:!0,pageSizeOpts:[10,20,50,100],onPageChange:a,onPageSizeChange:o},emptyText:_(`common.noData`,null,`暂无数据`)})}var{Text:Y}=f;function Pe({asset:e,visible:t,onClose:r,onEdit:i,onDelete:a,canWrite:o,canDelete:l}){let d=E(),f=n();if(!e)return null;let m=()=>{if(e.last_scan_task_id){f(`/vulnerabilities?task_id=${encodeURIComponent(e.last_scan_task_id)}`);return}if(e.last_scan_conversation_id){f(`/vulnerabilities?conversation_id=${encodeURIComponent(e.last_scan_conversation_id)}`);return}let t=e.host||e.domain||e.ip||``;f(t?`/vulnerabilities?host_q=${encodeURIComponent(t)}`:`/vulnerabilities`)},h=[{label:`Host`,value:e.host||`—`},{label:`IP`,value:e.ip||`—`},{label:d(`assets.domain`,null,`域名`),value:e.domain||`—`},{label:d(`assets.service`,null,`服务`),value:(0,q.jsx)(De,{protocol:e.protocol,port:e.port})},{label:d(`assets.project`,null,`所属项目`),value:e.project_name||e.project_id||`—`},{label:d(`assets.status`,null,`状态`),value:(0,q.jsx)(Oe,{status:e.status})},{label:d(`assets.riskLevel`,null,`风险等级`),value:(0,q.jsx)(G,{asset:e})},{label:d(`assets.environment`,null,`环境`),value:I(e.environment)||`—`},{label:d(`assets.criticality`,null,`重要性`),value:pe(e.criticality)||`—`},{label:d(`assets.location`,null,`地区`),value:[e.country,e.province,e.city].filter(Boolean).join(` / `)||`—`},{label:d(`assets.responsiblePerson`,null,`负责人`),value:e.responsible_person||`—`},{label:d(`assets.department`,null,`部门`),value:e.department||`—`},{label:d(`assets.businessSystem`,null,`业务系统`),value:e.business_system||`—`},{label:d(`assets.title`,null,`标题/指纹`),value:e.title||`—`},{label:d(`assets.server`,null,`服务指纹`),value:e.server||`—`},{label:d(`assets.source`,null,`来源`),value:e.source||`—`},{label:d(`assets.sourceQuery`,null,`来源查询`),value:e.source_query?(0,q.jsx)(Y,{code:!0,size:`small`,children:e.source_query}):`—`},{label:d(`assets.tagsLabel`,null,`标签`),value:(0,q.jsx)(W,{tags:e.tags,max:6})},{label:d(`assets.firstSeen`,null,`首次发现`),value:C(e.first_seen_at)},{label:d(`assets.lastSeen`,null,`最近发现`),value:C(e.last_seen_at)},{label:d(`assets.lastScan`,null,`上次扫描`),value:C(e.last_scan_at)},{label:`创建时间`,value:C(e.created_at)},{label:`更新时间`,value:C(e.updated_at)},{label:`资产 ID`,value:(0,q.jsx)(Y,{copyable:{content:e.id},size:`small`,children:e.id})}];return(0,q.jsxs)(p,{visible:t,onCancel:r,title:d(`assets.detailTitle`,null,`资产详情`),width:620,placement:`right`,footer:(0,q.jsxs)(c,{children:[o&&(0,q.jsx)(u,{onClick:()=>i(e),children:d(`common.edit`,null,`编辑`)}),l&&(0,q.jsx)(u,{type:`danger`,onClick:()=>a(e),children:d(`common.delete`,null,`删除`)}),(0,q.jsx)(u,{theme:`borderless`,onClick:r,children:d(`common.close`,null,`关闭`)})]}),children:[(0,q.jsxs)(`div`,{className:`asset-library-detail-target`,children:[(0,q.jsxs)(`div`,{className:`asset-library-detail-target-main`,children:[(0,q.jsx)(Y,{strong:!0,size:`large`,children:z(e)}),(0,q.jsx)(ae,{text:z(e)})]}),(0,q.jsx)(Y,{type:`tertiary`,children:[e.ip,e.domain,Ce(e)].filter(Boolean).join(` · `)||`—`}),(0,q.jsxs)(c,{spacing:6,wrap:!0,className:`asset-library-detail-badges`,children:[(0,q.jsx)(Oe,{status:e.status}),(0,q.jsx)(G,{asset:e}),(0,q.jsxs)(Y,{type:`tertiary`,size:`small`,children:[d(`assets.relatedVulnerabilities`,null,`相关漏洞`),`:`,Number(e.vulnerability_count||0),e.risk_level?`(${ce(e.risk_level)})`:``]})]})]}),(0,q.jsx)(s,{margin:`12px`}),(0,q.jsx)(j,{items:h,columns:2}),(0,q.jsx)(s,{margin:`12px`}),(0,q.jsxs)(c,{children:[(0,q.jsx)(u,{theme:`light`,onClick:m,children:d(`assets.viewRelatedVulnerabilities`,null,`查看关联漏洞`)}),e.project_id&&(0,q.jsx)(u,{theme:`borderless`,onClick:()=>f(`/projects?id=${encodeURIComponent(e.project_id)}`),children:d(`assets.viewProject`,null,`查看项目`)})]})]})}var Fe={host:500,title:500,domain:253,protocol:32,server:255,country:255,province:255,city:255,responsible_person:255,department:255,business_system:255};function X(e){return String(e??``).replace(/^\uFEFF/,``).trim().toLowerCase().replace(/[\s_\-/.()()]+/g,``)}function Ie(e){let t=X(e);return t&&ge.find(e=>(V[e]||[]).some(e=>X(e)===t))||``}function Z(e){let t=String(e??``).replace(/^\uFEFF/,``),n=[],r=[],i=``,a=!1;for(let e=0;e{d(t.q||``)},[t.q]);let f=[`status`,`risk_level`,`environment`,`criticality`,`ip`,`domain`,`port`,`scan`].filter(e=>t[e]).length;return(0,q.jsxs)(`div`,{className:`asset-library-filters`,children:[(0,q.jsxs)(`div`,{className:`asset-library-filter-row`,children:[(0,q.jsx)(`span`,{id:s,hidden:!0,children:a(`assets.scopeLabel`,null,`资产范围`)}),(0,q.jsx)(x,{"aria-labelledby":s,value:e.value,optionList:e.options,loading:e.loading,disabled:i,onChange:e.onChange,filter:!0}),(0,q.jsx)(l,{className:`asset-library-filter-search`,prefix:(0,q.jsx)(_,{}),value:c,disabled:i,placeholder:a(`assets.searchPlaceholder`,null,`搜索主机、IP、域名、标题、服务或标签`),onChange:e=>{d(e),n({q:e})},showClear:!0}),(0,q.jsx)(x,{value:t.protocol||void 0,placeholder:a(`assets.assetType`,null,`类型 / 协议`),optionList:ve,filter:!0,allowCreate:!0,showClear:!0,disabled:i,onChange:e=>n({protocol:e||``})}),(0,q.jsx)(l,{value:t.source,placeholder:a(`assets.source`,null,`来源`),disabled:i,onChange:e=>n({source:e}),showClear:!0}),(0,q.jsx)(l,{value:t.tag,placeholder:a(`assets.tagsLabel`,null,`标签`),disabled:i,onChange:e=>n({tag:e}),showClear:!0}),(0,q.jsx)(u,{onClick:r,disabled:i,children:a(`assets.resetFilters`,null,`重置`)})]}),(0,q.jsx)(o,{className:`asset-library-filter-advanced`,keepDOM:!1,children:(0,q.jsx)(o.Panel,{itemKey:`advanced`,header:`${a(`assets.advancedFilters`,null,`高级筛选`)}${f?`(${f})`:``}`,children:(0,q.jsxs)(`div`,{className:`asset-library-filter-grid`,children:[(0,q.jsx)(x,{value:t.status||void 0,placeholder:a(`assets.allStatuses`,null,`全部状态`),optionList:de,showClear:!0,disabled:i,onChange:e=>n({status:e||``})}),(0,q.jsx)(x,{value:t.risk_level||void 0,placeholder:a(`assets.allRisks`,null,`全部风险`),optionList:me,showClear:!0,disabled:i,onChange:e=>n({risk_level:e||``})}),(0,q.jsx)(x,{value:t.environment||void 0,placeholder:a(`assets.allEnvironments`,null,`全部环境`),optionList:P,showClear:!0,disabled:i,onChange:e=>n({environment:e||``})}),(0,q.jsx)(x,{value:t.criticality||void 0,placeholder:a(`assets.allCriticalities`,null,`全部级别`),optionList:we,showClear:!0,disabled:i,onChange:e=>n({criticality:e||``})}),(0,q.jsx)(l,{value:t.ip,placeholder:`IP`,disabled:i,onChange:e=>n({ip:e}),showClear:!0}),(0,q.jsx)(l,{value:t.domain,placeholder:a(`assets.domain`,null,`域名`),disabled:i,onChange:e=>n({domain:e}),showClear:!0}),(0,q.jsx)(l,{value:t.port,placeholder:a(`assets.port`,null,`端口`),disabled:i,onChange:e=>n({port:String(e||``).replace(/[^\d]/g,``)}),showClear:!0}),(0,q.jsx)(x,{value:t.scan||``,placeholder:a(`assets.scanState`,null,`扫描状态`),optionList:le,disabled:i,onChange:e=>n({scan:e||``})}),(0,q.jsx)(x,{value:t.sort||`last_seen_at:desc`,optionList:H,disabled:i,onChange:e=>n({sort:e||`last_seen_at:desc`})})]})})})]})}var{Text:J}=f;function Ne({assets:e,loading:t,total:n,page:r,pageSize:i,onPageChange:a,onPageSizeChange:o,selectedRowKeys:s,onSelectionChange:l,onView:d,onEdit:f,onDelete:p,onRefresh:m,canWrite:h,canDelete:g}){let _=E(),v=e=>{se({title:_(`assets.deleteConfirm`,null,`确定删除该资产吗?`),content:z(e),okText:_(`common.delete`,null,`删除`),onOk:()=>{Promise.resolve(p(e)).catch(e=>k(e,_(`assets.deleteFailed`,null,`删除资产失败`)))}})},y=[{title:_(`assets.target`,null,`目标`),dataIndex:`host`,width:260,render:(e,t)=>(0,q.jsxs)(`div`,{className:`asset-library-target`,children:[(0,q.jsx)(Ee,{text:z(t),max:38}),(0,q.jsx)(J,{type:`tertiary`,size:`small`,children:[t.ip,t.domain].filter(Boolean).join(` · `)||`—`})]})},{title:_(`assets.service`,null,`服务`),dataIndex:`protocol`,width:150,render:(e,t)=>(0,q.jsx)(De,{protocol:t.protocol,port:t.port})},{title:_(`assets.project`,null,`所属项目`),dataIndex:`project_name`,width:160,render:(e,t)=>(0,q.jsx)(Ee,{text:e||t.project_id||_(`assets.scopeUnassigned`,null,`未归属项目`),max:18})},{title:_(`assets.source`,null,`来源`),dataIndex:`source`,width:120,render:e=>(0,q.jsx)(Ee,{text:e,max:14})},{title:_(`assets.riskLevel`,null,`风险等级`),dataIndex:`risk_level`,width:150,render:(e,t)=>(0,q.jsxs)(c,{spacing:6,children:[(0,q.jsx)(G,{asset:t}),(0,q.jsx)(J,{type:`tertiary`,size:`small`,children:Number(t.vulnerability_count||0)})]})},{title:_(`assets.lastSeen`,null,`最近发现`),dataIndex:`last_seen_at`,width:170,render:e=>(0,q.jsx)(J,{size:`small`,children:C(e)})},{title:_(`common.actions`,null,`操作`),dataIndex:`id`,width:190,render:(e,t)=>(0,q.jsxs)(c,{spacing:4,children:[(0,q.jsx)(u,{theme:`borderless`,size:`small`,onClick:()=>d(t),children:_(`common.view`,null,`查看`)}),h&&(0,q.jsx)(u,{theme:`borderless`,size:`small`,onClick:()=>f(t),children:_(`common.edit`,null,`编辑`)}),g&&(0,q.jsx)(u,{theme:`borderless`,type:`danger`,size:`small`,onClick:()=>v(t),children:_(`common.delete`,null,`删除`)})]})}];return(0,q.jsx)(M,{columns:y,dataSource:e,loading:t,rowKey:`id`,onRefresh:m,rowSelection:{selectedRowKeys:s,onChange:(e,t)=>l(e,t)},pagination:{currentPage:r,pageSize:i,total:n||0,showSizeChanger:!0,pageSizeOpts:[10,20,50,100],onPageChange:a,onPageSizeChange:o},emptyText:_(`common.noData`,null,`暂无数据`)})}var{Text:Y}=f;function Pe({asset:e,visible:t,onClose:r,onEdit:i,onDelete:a,canWrite:o,canDelete:l}){let d=E(),f=n();if(!e)return null;let m=()=>{if(e.last_scan_task_id){f(`/vulnerabilities?task_id=${encodeURIComponent(e.last_scan_task_id)}`);return}if(e.last_scan_conversation_id){f(`/vulnerabilities?conversation_id=${encodeURIComponent(e.last_scan_conversation_id)}`);return}let t=e.host||e.domain||e.ip||``;f(t?`/vulnerabilities?host_q=${encodeURIComponent(t)}`:`/vulnerabilities`)},h=[{label:`Host`,value:e.host||`—`},{label:`IP`,value:e.ip||`—`},{label:d(`assets.domain`,null,`域名`),value:e.domain||`—`},{label:d(`assets.service`,null,`服务`),value:(0,q.jsx)(De,{protocol:e.protocol,port:e.port})},{label:d(`assets.project`,null,`所属项目`),value:e.project_name||e.project_id||`—`},{label:d(`assets.status`,null,`状态`),value:(0,q.jsx)(Oe,{status:e.status})},{label:d(`assets.riskLevel`,null,`风险等级`),value:(0,q.jsx)(G,{asset:e})},{label:d(`assets.environment`,null,`环境`),value:I(e.environment)||`—`},{label:d(`assets.criticality`,null,`重要性`),value:pe(e.criticality)||`—`},{label:d(`assets.location`,null,`地区`),value:[e.country,e.province,e.city].filter(Boolean).join(` / `)||`—`},{label:d(`assets.responsiblePerson`,null,`负责人`),value:e.responsible_person||`—`},{label:d(`assets.department`,null,`部门`),value:e.department||`—`},{label:d(`assets.businessSystem`,null,`业务系统`),value:e.business_system||`—`},{label:d(`assets.title`,null,`标题/指纹`),value:e.title||`—`},{label:d(`assets.server`,null,`服务指纹`),value:e.server||`—`},{label:d(`assets.source`,null,`来源`),value:e.source||`—`},{label:d(`assets.sourceQuery`,null,`来源查询`),value:e.source_query?(0,q.jsx)(Y,{code:!0,size:`small`,children:e.source_query}):`—`},{label:d(`assets.tagsLabel`,null,`标签`),value:(0,q.jsx)(W,{tags:e.tags,max:6})},{label:d(`assets.firstSeen`,null,`首次发现`),value:C(e.first_seen_at)},{label:d(`assets.lastSeen`,null,`最近发现`),value:C(e.last_seen_at)},{label:d(`assets.lastScan`,null,`上次扫描`),value:C(e.last_scan_at)},{label:`创建时间`,value:C(e.created_at)},{label:`更新时间`,value:C(e.updated_at)},{label:`资产 ID`,value:(0,q.jsx)(Y,{copyable:{content:e.id},size:`small`,children:e.id})}];return(0,q.jsxs)(p,{visible:t,onCancel:r,title:d(`assets.detailTitle`,null,`资产详情`),width:620,placement:`right`,footer:(0,q.jsxs)(c,{children:[o&&(0,q.jsx)(u,{onClick:()=>i(e),children:d(`common.edit`,null,`编辑`)}),l&&(0,q.jsx)(u,{type:`danger`,onClick:()=>a(e),children:d(`common.delete`,null,`删除`)}),(0,q.jsx)(u,{theme:`borderless`,onClick:r,children:d(`common.close`,null,`关闭`)})]}),children:[(0,q.jsxs)(`div`,{className:`asset-library-detail-target`,children:[(0,q.jsxs)(`div`,{className:`asset-library-detail-target-main`,children:[(0,q.jsx)(Y,{strong:!0,size:`large`,children:z(e)}),(0,q.jsx)(ae,{text:z(e)})]}),(0,q.jsx)(Y,{type:`tertiary`,children:[e.ip,e.domain,Ce(e)].filter(Boolean).join(` · `)||`—`}),(0,q.jsxs)(c,{spacing:6,wrap:!0,className:`asset-library-detail-badges`,children:[(0,q.jsx)(Oe,{status:e.status}),(0,q.jsx)(G,{asset:e}),(0,q.jsxs)(Y,{type:`tertiary`,size:`small`,children:[d(`assets.relatedVulnerabilities`,null,`相关漏洞`),`:`,Number(e.vulnerability_count||0),e.risk_level?`(${ce(e.risk_level)})`:``]})]})]}),(0,q.jsx)(s,{margin:`12px`}),(0,q.jsx)(j,{items:h,columns:2}),(0,q.jsx)(s,{margin:`12px`}),(0,q.jsxs)(c,{children:[(0,q.jsx)(u,{theme:`light`,onClick:m,children:d(`assets.viewRelatedVulnerabilities`,null,`查看关联漏洞`)}),e.project_id&&(0,q.jsx)(u,{theme:`borderless`,onClick:()=>f(`/projects?id=${encodeURIComponent(e.project_id)}`),children:d(`assets.viewProject`,null,`查看项目`)})]})]})}var Fe={host:500,title:500,domain:253,protocol:32,server:255,country:255,province:255,city:255,responsible_person:255,department:255,business_system:255};function X(e){return String(e??``).replace(/^\uFEFF/,``).trim().toLowerCase().replace(/[\s_\-/.()()]+/g,``)}function Ie(e){let t=X(e);return t&&ge.find(e=>(V[e]||[]).some(e=>X(e)===t))||``}function Z(e){let t=String(e??``).replace(/^\uFEFF/,``),n=[],r=[],i=``,a=!1;for(let e=0;ee.some(e=>String(e??``).trim()!==``))}function Le(e,t,n=``){let r=String(e??``).trim();if(!r)return n;let i=r.toLowerCase();if(t[i])return i;let a=Object.entries(t).find(([,e])=>e===r);return a?a[0]:null}function Re(e,t){let n=String(e??``).trim();if(!n)return{projectId:``,projectName:``,error:``};let r=n.toLowerCase(),i=(t||[]).find(e=>String(e.id).toLowerCase()===r||String(e.name||``).trim().toLowerCase()===r);return i?{projectId:i.id,projectName:i.name,error:``}:{projectId:``,projectName:``,error:`项目不存在或无权访问:${n}`}}function ze(e,t,{projects:n,projectId:r,source:i}){let a=n=>({rowNumber:t,values:e,asset:null,error:n}),o=e.target||e.host||e.domain||e.ip||``;if(!o)return a(`缺少目标地址`);let s;try{s=Te(o)}catch(e){return a(e.message)}let c=String(e.port??``).trim(),l=Number(c===``?s.port||0:c);if(!Number.isInteger(l)||l<0||l>65535)return a(`端口必须在 0–65535 之间`);let u=String(e.ip||s.ip||``).trim().toLowerCase();if(u&&!F(u)&&!_e(u))return a(`IP 地址格式无效`);let d=String(e.domain||s.domain||``).trim(),f=d?R(d):``;if(d&&!f)return a(`域名格式无效`);let p=String(e.protocol||s.protocol||``).trim().toLowerCase();if(p&&!/^[a-z][a-z0-9+.-]{0,31}$/.test(p))return a(`协议格式无效`);let m=Le(e.status,he,`active`);if(!m)return a(`状态仅支持 active 或 inactive`);let h=Le(e.environment,Se,``);if(h===null)return a(`环境值无效`);let g=Le(e.criticality,be,``);if(g===null)return a(`重要性值无效`);let _=Re(e.project||r,n);if(_.error)return a(_.error);if(r!==void 0&&_.projectId!==r)return a(`该行的项目与当前资产范围不一致`);let v=L(e.tags);if(v.length>30)return a(`标签最多 30 个`);if(v.some(e=>Array.from(e).length>64))return a(`单个标签最多 64 个字符`);let y={host:String(e.host||s.host||``).trim(),ip:u,domain:f,port:l,protocol:p,title:String(e.title||``).trim(),server:String(e.server||``).trim(),country:String(e.country||``).trim(),province:String(e.province||``).trim(),city:String(e.city||``).trim(),responsible_person:String(e.responsible_person||``).trim(),department:String(e.department||``).trim(),business_system:String(e.business_system||``).trim(),environment:h,criticality:g,status:m,tags:v,project_id:_.projectId,source:i||`manual-import`},b=Object.keys(Fe).find(e=>Array.from(String(y[e]||``)).length>Fe[e]);if(b)return a(`字段 ${b} 内容过长`);let x=ye(y);return x?a(x):{rowNumber:t,values:e,asset:y,projectName:_.projectName,error:``}}function Be(e){let t=new Map;return e.map(e=>{if(e.error||!e.asset)return e;let n=B(e.asset);return t.has(n)?{...e,error:`与第 ${t.get(n)} 行重复`}:(t.set(n,e.rowNumber),e)})}function Ve(e,t={}){let n=Z(e);if(n.length<2)throw Error(`文件中没有可导入的数据`);let r=n[0].map(Ie);if(!r.some(Boolean))throw Error(`未识别到模板字段,请检查表头`);let i=n.slice(1);if(i.length>1e5)throw Error(`数据不能超过 ${U} 行`);return Be(i.map((e,n)=>{let i={};return r.forEach((t,n)=>{t&&i[t]==null&&(i[t]=String(e[n]??``).trim())}),ze(i,n+2,t)}))}function He(e,t={}){let n;try{n=JSON.parse(String(e??``))}catch(e){throw Error(`JSON 解析失败:`+e.message)}let r=(Array.isArray(n)?n:Array.isArray(n?.assets)?n.assets:[n]).filter(e=>e&&typeof e==`object`);if(!r.length)throw Error(`文件中没有可导入的数据`);if(r.length>1e5)throw Error(`数据不能超过 ${U} 行`);return Be(r.map((e,n)=>ze({target:e.target||e.host||e.domain||e.ip||``,host:e.host,ip:e.ip,domain:e.domain,port:e.port,protocol:e.protocol,title:e.title,server:e.server,country:e.country,province:e.province,city:e.city,responsible_person:e.responsible_person,department:e.department,business_system:e.business_system,environment:e.environment,criticality:e.criticality,status:e.status,tags:Array.isArray(e.tags)?e.tags.join(`,`):e.tags,project:e.project_id||e.project||e.project_name},n+1,t)))}function Q(){return`${ge.join(`,`)}\r\n`}function Ue(e){let t=String(e??``);return/[",\r\n]/.test(t)?`"${t.replaceAll(`"`,`""`)}"`:t}function We(e,t){return t===`target`?z(e):t===`project`?e.project_name||e.project_id||``:t===`tags`?(e.tags||[]).join(`,`):t===`status`?fe(e.status):t===`environment`?I(e.environment):t===`criticality`?pe(e.criticality):t===`risk_level`?ce(e.risk_level):t===`vulnerability_count`?Number(e.vulnerability_count||0):e[t]??``}function Ge(e){let t=[xe.map(([,e])=>Ue(e)).join(`,`)];return(e||[]).forEach(e=>{t.push(xe.map(([t])=>Ue(We(e,t))).join(`,`))}),`\uFEFF${t.join(`\r
`)}`}function Ke(e,t,n=`text/csv;charset=utf-8`){let r=new Blob([t],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}var{Text:$}=f,qe=e=>[{title:e(`assets.rowNumber`,null,`行号`),dataIndex:`rowNumber`,width:70},{title:e(`assets.target`,null,`目标`),dataIndex:`target`,render:(e,t)=>z(t.asset||{target:t.values?.target})},{title:e(`assets.project`,null,`所属项目`),dataIndex:`project`,render:(e,t)=>t.projectName||t.values?.project||`—`},{title:e(`assets.status`,null,`状态`),dataIndex:`status`,render:(e,t)=>t.asset?.status||t.values?.status||`—`},{title:e(`assets.validationResult`,null,`校验结果`),dataIndex:`error`,render:t=>t?(0,q.jsx)($,{type:`danger`,size:`small`,children:t}):(0,q.jsx)($,{type:`success`,size:`small`,children:e(`assets.validationPassed`,null,`通过`)})}];function Je({visible:e,projects:t,defaultProjectId:n,onClose:r,onDone:i}){let a=E(),[o,s]=(0,K.useState)(`csv`),[l,f]=(0,K.useState)(``),[p,h]=(0,K.useState)(``),[_,v]=(0,K.useState)(``),[y,b]=(0,K.useState)(!1),x=(0,K.useRef)(null),C=(0,K.useMemo)(()=>{if(!String(l||``).trim())return{records:[],error:``};try{let e={projects:t,projectId:n,source:`manual-import`};return{records:o===`csv`?Ve(l,e):He(l,e),error:``}}catch(e){return{records:[],error:e.message}}},[l,o,t,n]),w=C.records,O=w.filter(e=>!e.error),te=w.length-O.length,k=_||C.error,j=()=>{f(``),h(``),s(`csv`),v(``),b(!1)},ne=()=>{y||(j(),r?.())},re=async e=>{if(!e)return;v(``);let t=String(e.name||``),n=t.split(`.`).pop().toLowerCase();if(![`csv`,`json`,`txt`].includes(n))v(`仅支持 .csv / .json / .txt 文件`);else if(e.size>104857600)v(a(`assets.fileTooLarge`,null,`文件不能超过 100 MB`));else try{let r=await e.text();s(n===`json`?`json`:`csv`),f(r),h(t)}catch(e){v(D(e,a(`assets.fileParseFailed`,null,`无法解析文件,请确认文件格式正确`)))}};return(0,q.jsxs)(A,{visible:e,title:a(`assets.bulkImportTitle`,null,`批量导入资产`),width:880,onCancel:ne,onOk:async()=>{if(!y&&O.length){v(``),b(!0);try{let e=await T.post(`/assets/import`,{assets:O.map(e=>e.asset),source:`manual-import`,source_query:p||`paste`}),t=Number(e?.skipped||0)+te;N(a(`assets.bulkImportDone`,{created:Number(e?.created||0),updated:Number(e?.updated||0),skipped:t},`导入完成:新增 ${Number(e?.created||0)} 条,更新 ${Number(e?.updated||0)} 条,跳过 ${t} 条`)),j(),i?.(),r?.()}catch(e){v(D(e,a(`assets.importFailed`,null,`资产入库失败`)))}finally{b(!1)}}},okText:a(`assets.importValidRowsCount`,{count:O.length},`导入 ${O.length} 条有效数据`),okButtonProps:{disabled:!O.length},confirmLoading:y,children:[(0,q.jsx)($,{type:`tertiary`,children:a(`assets.bulkImportSubtitle`,null,`支持 CSV / JSON 文本粘贴或文件上传,提交前会先校验并预览数据`)}),k&&(0,q.jsx)(S,{type:`danger`,bordered:!0,closeIcon:null,description:k,className:`asset-library-form-error`}),(0,q.jsxs)(c,{vertical:!0,align:`start`,spacing:10,className:`asset-library-import-body`,children:[(0,q.jsxs)(c,{children:[(0,q.jsx)(g,{type:`button`,value:o,options:[{value:`csv`,label:`CSV`},{value:`json`,label:`JSON`}],onChange:e=>{s(e.target.value),v(``)}}),(0,q.jsx)(u,{icon:(0,q.jsx)(d,{}),onClick:()=>x.current?.click(),children:a(`assets.chooseOrDropFile`,null,`选择文件`)}),(0,q.jsx)(`input`,{ref:x,type:`file`,accept:`.csv,.json,.txt`,className:`asset-library-file-input`,onChange:e=>{re(e.target.files?.[0]),e.target.value=``}}),(0,q.jsx)(u,{theme:`borderless`,onClick:()=>Ke(`asset-import-template.csv`,Q()),children:a(`assets.downloadCsv`,null,`下载 CSV 模板`)}),p&&(0,q.jsx)($,{type:`tertiary`,size:`small`,children:p})]}),(0,q.jsx)(ee,{value:l,rows:8,className:`asset-library-import-textarea`,placeholder:o===`csv`?`target,project,tags,host,ip,domain,port,protocol,title,server,country,province,city,responsible_person,department,business_system,environment,criticality,status`:`[{"host":"https://example.com","ip":"1.1.1.1","port":443,"protocol":"https","tags":["prod"]}]`,onChange:e=>{f(e),v(``)}}),w.length>0&&(0,q.jsxs)(`div`,{className:`asset-library-import-preview`,children:[(0,q.jsx)($,{strong:!0,children:a(`assets.importPreviewSummary`,{total:w.length,valid:O.length,invalid:te},`共 ${w.length} 行,${O.length} 行有效,${te} 行需修正`)}),(0,q.jsx)(m,{columns:qe(a),dataSource:w.slice(0,10).map((e,t)=>({...e,id:t})),rowKey:`id`,size:`small`,pagination:!1}),w.length>10&&(0,q.jsx)($,{type:`tertiary`,size:`small`,children:a(`assets.previewLimitedShort`,{count:w.length},`仅展示前 10 行;提交时将处理全部 ${w.length} 行`)})]})]})]})}var{Text:Ye}=f;function Xe({visible:e,assets:t,onClose:n,onDone:r}){let i=E(),a=(0,K.useMemo)(()=>Array.isArray(t)?t:[],[t]),[o,s]=(0,K.useState)(``),[l,u]=(0,K.useState)(``),[d,f]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{e&&(s(a[0]?.id||``),u(``),f(!1))},[e,a]),(0,q.jsxs)(A,{visible:e,title:i(`assets.mergeDuplicates`,null,`合并重复资产`),width:560,onCancel:n,onOk:async()=>{if(!(d||a.length<2)){f(!0),u(``);try{let e=await T.post(`/assets/merge`,{asset_ids:a.map(e=>e.id),primary_id:o||a[0].id});N(`已合并 ${Number(e?.merged||a.length)} 个资产`),r?.(),n?.()}catch(e){u(D(e,`合并资产失败`))}finally{f(!1)}}},okText:i(`assets.merge`,null,`合并`),okButtonProps:{disabled:a.length<2},confirmLoading:d,children:[a.length<2?(0,q.jsx)(S,{type:`warning`,bordered:!0,closeIcon:null,description:i(`assets.mergeRequiresMultiple`,null,`请至少选择两个重复资产`)}):(0,q.jsxs)(c,{vertical:!0,align:`start`,spacing:8,style:{width:`100%`},children:[(0,q.jsx)(Ye,{type:`tertiary`,children:i(`assets.mergeHint`,null,`将保留一个主资产,其余资产的空字段与标签会合并进来,然后删除被合并记录。所选资产必须共享域名、IP 或 Host。`)}),(0,q.jsx)(g,{value:o,onChange:e=>s(e.target.value),children:(0,q.jsx)(c,{vertical:!0,align:`start`,spacing:4,children:a.map(e=>(0,q.jsxs)(v,{value:e.id,children:[z(e),e.project_name?` · ${e.project_name}`:``]},e.id))})})]}),l&&(0,q.jsx)(S,{type:`danger`,bordered:!0,closeIcon:null,description:l,className:`asset-library-form-error`})]})}var{Text:Ze}=f;function Qe({visible:e,projects:t,assetIds:n,onClose:r,onDone:i}){let a=E(),[o,s]=(0,K.useState)(``),[l,u]=(0,K.useState)(!1),[d,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(!1),h=(0,K.useMemo)(()=>Array.isArray(n)?n:[],[n]),g=(0,K.useMemo)(()=>(t||[]).map(e=>({value:e.id,label:e.name||e.id})),[t]);return(0,K.useEffect)(()=>{e&&(s(``),u(!1),f(``),m(!1))},[e]),(0,q.jsxs)(A,{visible:e,title:a(`assets.bindProjectTitle`,null,`绑定项目`),width:520,onCancel:r,onOk:async()=>{if(!p&&h.length){if(!l&&!o)f(a(`assets.selectProjectRequired`,null,`请选择要绑定的项目`));else{m(!0),f(``);try{await T.put(`/assets/project-binding`,{asset_ids:h,project_id:l?``:o}),N(a(`assets.bindProjectDone`,{count:h.length},`已更新 ${h.length} 个资产`)),i?.(),r?.()}catch(e){f(D(e,a(`assets.bindProjectFailed`,null,`绑定项目失败`)))}finally{m(!1)}}}},okText:l?a(`assets.unbindProject`,null,`解除绑定`):a(`assets.confirmBinding`,null,`确认绑定`),confirmLoading:p,children:[(0,q.jsxs)(c,{vertical:!0,align:`start`,spacing:10,style:{width:`100%`},children:[(0,q.jsx)(Ze,{type:`tertiary`,children:a(`assets.bindProjectCount`,{count:h.length},`将更新 ${h.length} 个资产`)}),(0,q.jsx)(x,{value:o||void 0,optionList:g,filter:!0,showClear:!0,disabled:l,placeholder:a(`assets.chooseProject`,null,`请选择项目`),onChange:e=>s(e||``),style:{width:`100%`}}),(0,q.jsxs)(c,{children:[(0,q.jsx)(b,{checked:l,onChange:u,size:`small`}),(0,q.jsx)(Ze,{size:`small`,children:a(`assets.unbindProject`,null,`解除项目绑定`)})]}),(0,q.jsx)(Ze,{type:`tertiary`,size:`small`,children:a(`assets.bindProjectHint`,null,`所选资产将统一更新为该项目归属。`)})]}),d&&(0,q.jsx)(S,{type:`danger`,bordered:!0,closeIcon:null,description:d,className:`asset-library-form-error`})]})}var{Text:$e}=f,et={status:``,environment:``,criticality:``,responsible_person:``,department:``,business_system:``,add_tags:``,remove_tags:``};function tt({visible:e,assetIds:t,onClose:n,onDone:r}){let i=E(),[a,o]=(0,K.useState)(et),[s,c]=(0,K.useState)(``),[u,d]=(0,K.useState)(!1),f=(0,K.useMemo)(()=>Array.isArray(t)?t:[],[t]);(0,K.useEffect)(()=>{e&&(o(et),c(``),d(!1))},[e]);let p=e=>o(t=>({...t,...e}));return(0,q.jsxs)(A,{visible:e,title:i(`assets.bulkEdit`,null,`批量编辑`),width:620,onCancel:n,onOk:async()=>{if(u||!f.length)return;let e={asset_ids:f};[`status`,`environment`,`criticality`,`responsible_person`,`department`,`business_system`].forEach(t=>{let n=String(a[t]||``).trim();n&&(e[t]=n)});let t=L(a.add_tags),i=L(a.remove_tags);if(t.length&&(e.add_tags=t),i.length&&(e.remove_tags=i),Object.keys(e).length===1)c(`请至少填写一项需要修改的内容`);else{d(!0),c(``);try{let t=await T.put(`/assets/bulk`,e);N(`已更新 ${Number(t?.updated||f.length)} 个资产`),r?.(),n?.()}catch(e){c(D(e,`批量编辑失败`))}finally{d(!1)}}},confirmLoading:u,children:[(0,q.jsxs)($e,{type:`tertiary`,children:[`将修改 `,f.length,` 个资产;空白字段保持原值。`]}),(0,q.jsxs)(`div`,{className:`asset-library-form-grid asset-library-form-grid--bulk`,children:[(0,q.jsx)(x,{value:a.status||void 0,placeholder:i(`assets.status`,null,`状态`),optionList:de,showClear:!0,onChange:e=>p({status:e||``})}),(0,q.jsx)(x,{value:a.environment||void 0,placeholder:i(`assets.environment`,null,`环境`),optionList:P,showClear:!0,onChange:e=>p({environment:e||``})}),(0,q.jsx)(x,{value:a.criticality||void 0,placeholder:i(`assets.criticality`,null,`重要性`),optionList:we,showClear:!0,onChange:e=>p({criticality:e||``})}),(0,q.jsx)(l,{value:a.responsible_person,placeholder:i(`assets.responsiblePerson`,null,`负责人`),onChange:e=>p({responsible_person:e})}),(0,q.jsx)(l,{value:a.department,placeholder:i(`assets.department`,null,`部门`),onChange:e=>p({department:e})}),(0,q.jsx)(l,{value:a.business_system,placeholder:i(`assets.businessSystem`,null,`业务系统`),onChange:e=>p({business_system:e})}),(0,q.jsx)(l,{value:a.add_tags,placeholder:`追加标签(逗号分隔)`,onChange:e=>p({add_tags:e})}),(0,q.jsx)(l,{value:a.remove_tags,placeholder:`移除标签(逗号分隔)`,onChange:e=>p({remove_tags:e})})]}),s&&(0,q.jsx)(S,{type:`danger`,bordered:!0,closeIcon:null,description:s,className:`asset-library-form-error`})]})}function nt(){let{data:e,loading:t,error:n,reload:r}=te(rt,[]);return{projects:e||[],loading:t,error:n,reload:r}}async function rt(){let e=[],t;do{let n=await T.get(`/projects`,{limit:500,offset:e.length}),r=n?.projects||[];if(e.push(...r),r.length<500)break;t=Number(n?.total||e.length)}while(e.length({project_id:e||void 0}),[e]),[_,v]=(0,K.useState)(()=>({...je(),q:i.get(`q`)||``})),[b,x]=(0,K.useState)(1),[ee,C]=(0,K.useState)(20),[D,A]=(0,K.useState)({keys:[],rows:[]}),j=(0,K.useRef)(0),[ae,M]=(0,K.useState)(null),[ce,le]=(0,K.useState)(!1),[ue,de]=(0,K.useState)(null),[fe,pe]=(0,K.useState)(!1),[me,he]=(0,K.useState)(!1),[ge,_e]=(0,K.useState)(!1),[ve,ye]=(0,K.useState)(!1),[be,xe]=(0,K.useState)(!1),P=ie(_,300),F=(0,K.useMemo)(()=>({...at(P,b,ee),...g}),[P,b,ee,g]),{data:I,loading:L,error:Se,reload:Ce}=te(()=>T.get(`/assets`,F),[F,l],{skip:!l}),{projects:R,loading:we,error:z,reload:Te}=n,B=(0,K.useMemo)(()=>Array.isArray(I?.assets)?I.assets:[],[I]),V=Se?0:Number(I?.total||0),H=L||P!==_,U=[{value:`all`,label:o(`assets.scopeAll`,null,`全部资产`)},...R.map(e=>({value:`project:${e.id}`,label:e.name||e.id}))];e&&!U.some(e=>e.value===t)&&U.push({value:t,label:e});let Ee=U.find(e=>e.value===t)?.label,W=(0,K.useRef)(``);(0,K.useEffect)(()=>()=>{j.current+=1},[]),(0,K.useEffect)(()=>{if(!m){W.current=``,M(null);return}if(!l||m===W.current)return;let e=B.find(e=>e.id===m);if(e||r?.id===m){W.current=m,M(e||r);return}let t=!1;return(async()=>{for(let e=1;e<=5&&!t;e+=1){let n=await T.get(`/assets`,{...g,page:e,page_size:100});if(t)return;let r=n?.assets?.find(e=>e.id===m);if(r){M(r);break}if(e>=Number(n?.total_pages||1))break}t||(W.current=m)})().catch(e=>{t||k(e,o(`assets.loadFailed`,null,`加载资产失败`))}),()=>{t=!0}},[B,l,m,r,g,o]);let De=e=>{if(e===t)return;let n=new URLSearchParams;e?.startsWith(`project:`)&&n.set(`project_id`,e.slice(8)),a(n)},G=()=>{j.current+=1,A({keys:[],rows:[]})},Oe=e=>{v(t=>({...t,...e})),x(1),G()},Ae=()=>{v(je()),x(1),G()},J=()=>{G(),Ce(),Te()},Y=e=>{let t=new URLSearchParams(i);e?t.set(`id`,e):t.delete(`id`),a(t,{replace:!0})},Fe=e=>{W.current=e.id,M(e),e?.id&&Y(e.id)},X=()=>{M(null),m&&(W.current=``,Y(``))},Ie=e=>{de(e||null),le(!0),f&&Te()},Z=async()=>{G(),await Ce()},Le=async e=>{await T.del(`/assets/${encodeURIComponent(e.id)}`),N(o(`assets.deleted`,null,`资产已删除`)),ae?.id===e.id&&X(),await Z()},Re=()=>{let e=D.keys;e.length&&se({title:o(`assets.deleteConfirm`,null,`确定删除所选资产吗?`),content:o(`assets.scopedDeleteConfirm`,{count:e.length,project:D.rows[0]?.project_name||D.rows[0]?.project_id||o(`assets.scopeUnassigned`,null,`未归属项目`)},`将永久删除所选的 ${e.length} 个资产。`),okText:o(`common.delete`,null,`删除`),onOk:async()=>{try{let t=await T.post(`/assets/batch-delete`,{asset_ids:e});N(`已删除 ${Number(t?.deleted||e.length)} 个资产`),await Z()}catch(e){k(e,`批量删除失败`)}}})},ze=(0,K.useMemo)(()=>{let{page:e,page_size:t,...n}=F;return n},[F]),Be=async()=>{let e=++j.current;try{let t=await T.get(`/assets/selection`,ze);if(e!==j.current)return;let n=Array.isArray(t?.assets)?t.assets:[];A({keys:n.map(e=>e.id),rows:n}),N(o(`assets.allResultsSelected`,{count:n.length},`已选择 ${n.length} 项`))}catch(t){e===j.current&&k(t,`选择全部结果失败`)}},Ve=async e=>{if(!be){xe(!0);try{let t=D.rows;if(e){let e=await T.get(`/assets/selection`,ze);t=Array.isArray(e?.assets)?e.assets:[]}else t.length||(t=B);if(!t.length){O(`没有可导出的资产`);return}Ke(`assets-${new Date().toISOString().slice(0,10)}.csv`,Ge(t)),N(`已导出 ${t.length} 个资产`)}catch(e){k(e,`导出失败`)}finally{xe(!1)}}},He=(e,t)=>{j.current+=1,A({keys:e||[],rows:t||[]})},Q=D.keys.length,Ue=new Set(D.rows.map(e=>e.project_id||``)).size>1,We=Q>0&&!H&&!Ue;return l?(0,q.jsxs)(`div`,{className:`asset-library-page`,children:[(0,q.jsx)(oe,{title:o(`assets.libraryTitle`,null,`资产库`),extra:(0,q.jsxs)(c,{children:[(0,q.jsx)(u,{icon:(0,q.jsx)(y,{}),onClick:J,loading:L,children:o(`common.refresh`,null,`刷新`)}),f&&(0,q.jsx)(u,{icon:(0,q.jsx)(d,{}),onClick:()=>pe(!0),children:o(`assets.bulkImport`,null,`批量导入`)}),f&&(0,q.jsx)(u,{theme:`solid`,type:`primary`,icon:(0,q.jsx)(h,{}),onClick:()=>Ie(null),children:o(`assets.addAsset`,null,`新增资产`)})]})}),(0,q.jsxs)(re,{title:o(`assets.filterTitle`,null,`筛选条件`),children:[(0,q.jsx)(Me,{scope:{value:t,options:U,loading:we,onChange:De},filters:_,onChange:Oe,onReset:Ae}),(0,q.jsx)(ne,{error:z,onRetry:Te})]}),(0,q.jsx)(ne,{error:Se,onRetry:J}),(0,q.jsxs)(re,{title:`${Ee}(${V})`,extra:(0,q.jsxs)(c,{children:[(0,q.jsx)(u,{theme:`borderless`,disabled:!Q,onClick:G,children:o(`assets.clearSelection`,null,`清除选择`)}),(0,q.jsx)(u,{theme:`borderless`,disabled:H||!V,onClick:()=>Ve(!1),loading:be,children:o(`assets.exportCsv`,null,`导出 CSV`)}),(0,q.jsx)(u,{theme:`borderless`,disabled:H||!V,onClick:()=>Ve(!0),loading:be,children:o(`assets.exportAll`,null,`导出全部筛选结果`)})]}),children:[(0,q.jsxs)(`div`,{className:`asset-library-toolbar`,children:[(0,q.jsxs)(c,{children:[(0,q.jsx)(it,{type:`tertiary`,children:Q?o(`assets.selectedCount`,{count:Q},`已选择 ${Q} 项`):o(`assets.selectedCount`,{count:0},`已选择 0 项`)}),(0,q.jsx)(u,{theme:`borderless`,size:`small`,disabled:H||!V,onClick:Be,children:o(`assets.selectAllResults`,{count:V},`选择全部 ${V} 项`)})]}),(0,q.jsxs)(c,{children:[f&&(0,q.jsx)(u,{size:`small`,disabled:!We||Q<2||!p,onClick:()=>he(!0),children:o(`assets.mergeDuplicates`,null,`合并重复资产`)}),f&&(0,q.jsx)(u,{size:`small`,disabled:!We,onClick:()=>_e(!0),children:o(`assets.bindProject`,null,`绑定项目`)}),f&&(0,q.jsx)(u,{size:`small`,disabled:!We,onClick:()=>ye(!0),children:o(`assets.bulkEdit`,null,`批量编辑`)}),p&&(0,q.jsx)(u,{size:`small`,type:`danger`,disabled:!We,onClick:Re,children:o(`assets.batchDelete`,null,`批量删除…`)})]})]}),Ue&&(f||p)&&(0,q.jsx)(it,{type:`tertiary`,size:`small`,children:o(`assets.mixedProjectSelection`,null,`批量修改前,请将选择缩小到同一项目或仅选择未归属资产。`)}),(0,q.jsx)(Ne,{assets:H||Se?[]:B,loading:H,total:V,page:b,pageSize:ee,onPageChange:e=>{x(e),G()},onPageSizeChange:e=>{C(e),x(1),G()},selectedRowKeys:D.keys,onSelectionChange:He,onView:Fe,onEdit:Ie,onDelete:Le,onRefresh:J,canWrite:f,canDelete:p})]}),(0,q.jsx)(Pe,{asset:ae,visible:!!ae,onClose:X,onEdit:e=>{X(),Ie(e)},onDelete:e=>{se({title:o(`assets.deleteConfirm`,null,`确定删除该资产吗?`),content:e.host||e.domain||e.ip,okText:o(`common.delete`,null,`删除`),onOk:()=>Le(e).catch(e=>k(e,o(`assets.deleteFailed`,null,`删除资产失败`)))})},canWrite:f,canDelete:p}),(0,q.jsx)(ke,{visible:ce,asset:ue,defaultProjectId:e,projects:R,onClose:()=>le(!1),onSaved:Z}),(0,q.jsx)(Je,{visible:fe,defaultProjectId:t===`all`?void 0:e,projects:R,onClose:()=>pe(!1),onDone:Z}),(0,q.jsx)(Xe,{visible:me,assets:D.rows,onClose:()=>he(!1),onDone:Z}),(0,q.jsx)(Qe,{visible:ge,projects:R,assetIds:D.keys,onClose:()=>_e(!1),onDone:Z}),(0,q.jsx)(tt,{visible:ve,assetIds:D.keys,onClose:()=>ye(!1),onDone:Z})]}):(0,q.jsxs)(`div`,{className:`asset-library-page`,children:[(0,q.jsx)(oe,{title:o(`assets.libraryTitle`,null,`资产库`),description:`资产列表、批量操作与导入需要资产读取权限。`}),(0,q.jsx)(S,{type:`warning`,bordered:!0,closeIcon:null,description:o(`assets.readDenied`,null,`当前账号没有 asset:read 权限,无法读取资产库;请联系管理员授权。`)})]})}export{at as buildAssetQuery,ot as default};
\ No newline at end of file
diff --git a/web/static/app/assets/asset-overview-CuQShgUB.js b/web/static/app/assets/asset-overview-o_QJu_8H.js
similarity index 99%
rename from web/static/app/assets/asset-overview-CuQShgUB.js
rename to web/static/app/assets/asset-overview-o_QJu_8H.js
index 69c57e63..4a11f445 100644
--- a/web/static/app/assets/asset-overview-CuQShgUB.js
+++ b/web/static/app/assets/asset-overview-o_QJu_8H.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r}from"./react-QV7DAAIx.js";import{F as i,Jt as a,L as o,T as s,W as c,h as l,m as u,ot as d,st as f,z as p}from"./semi-Dpcldp_F.js";import{D as m,F as h,I as g,P as _,_ as v,a as y,k as b,l as x,m as S,p as C,s as w}from"./index-gBcdNgHq.js";import{a as T,n as E,r as D}from"./AssetBits-BYTpudK4.js";import{r as O}from"./assetTarget-D2PEjBAg.js";var k=e(t(),1),A=e(r(),1),{Text:j}=c,M=[{value:7,label:`7 天`},{value:30,label:`30 天`},{value:90,label:`90 天`}];function N(e,t){let n=Number(e||0),r=Number(t||0);return r?Math.round(n/r*1e3)/10:0}function P(){let e=_(),t=n(),{hasPermission:r,hasAnyPermission:c}=h(),P=r(`asset:read`),F=c([`asset:read`,`fofa:execute`]),[I,L]=(0,k.useState)(30),R=y(()=>g.get(`/assets/stats`,{days:I}),[I],{skip:!P}),z=y(()=>g.get(`/assets`,{page:1,page_size:10,sort_by:`last_seen_at`,sort_order:`desc`}),[],{skip:!P}),B=R.data||{},V=B.coverage||{},H=Array.isArray(B.protocols)?B.protocols:[],U=(0,k.useMemo)(()=>H.reduce((e,t)=>e+Number(t.count||0),0),[H]),W=Array.isArray(z.data?.assets)?z.data.assets:[],G=[{id:`total`,label:e(`assets.totalAssets`,null,`资产总数`),value:m(B.total||0),detail:e(`assets.totalAssetsHint`,null,`当前纳入持续监测的资产`),loading:R.loading},{id:`ips`,label:e(`assets.ipCount`,null,`IP 数量`),value:m(B.ips||0),loading:R.loading},{id:`domains`,label:e(`assets.domainCount`,null,`域名数量`),value:m(B.domains||0),loading:R.loading},{id:`ports`,label:e(`assets.portCount`,null,`端口数量`),value:m(B.ports||0),loading:R.loading},{id:`protocols`,label:e(`assets.serviceTypes`,null,`服务类型`),value:m(H.length),detail:H[0]?`${e(`assets.topProtocol`,null,`主要协议`)}:${H[0].name}`:void 0,loading:R.loading},{id:`recent`,label:e(`assets.recentCount`,null,`近 7 天发现`),value:m(B.recent||0),detail:e(`assets.recentShare`,{percent:N(B.recent,B.total)},`占当前资产总量的 ${N(B.recent,B.total)}%`),loading:R.loading}],K=e=>{let n=e?.id?`?id=${encodeURIComponent(e.id)}`:``;t(`/asset-library${n}`,e?{state:{asset:e}}:void 0)},q=[{title:e(`assets.target`,null,`目标`),dataIndex:`host`,render:(e,t)=>(0,A.jsxs)(`div`,{className:`asset-overview-target`,children:[(0,A.jsx)(T,{text:O(t),max:34}),(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:[t.ip,t.domain].filter(Boolean).join(` · `)||`—`})]})},{title:e(`assets.service`,null,`服务`),dataIndex:`protocol`,width:150,render:(e,t)=>(0,A.jsx)(E,{protocol:t.protocol,port:t.port})},{title:e(`assets.source`,null,`来源`),dataIndex:`source`,width:120,render:e=>(0,A.jsx)(T,{text:e,max:14})},{title:e(`assets.riskLevel`,null,`风险等级`),dataIndex:`risk_level`,width:120,render:(e,t)=>(0,A.jsx)(D,{asset:t})},{title:e(`assets.lastSeen`,null,`最近发现`),dataIndex:`last_seen_at`,width:130,render:t=>(0,A.jsx)(j,{size:`small`,children:b(t,e)})},{title:e(`common.actions`,null,`操作`),dataIndex:`id`,width:100,render:(t,n)=>(0,A.jsx)(o,{theme:`borderless`,size:`small`,onClick:()=>K(n),children:e(`common.view`,null,`查看`)})}],J=[{label:e(`assets.scannedAssets`,null,`已扫描资产`),value:m(V.scanned||0)},{label:e(`assets.recentlyScanned`,null,`近 30 天覆盖`),value:m(V.scanned_30d||0)},{label:e(`assets.neverScanned`,null,`从未扫描`),value:m(V.never_scanned||0)},{label:e(`assets.staleScans`,null,`超过 30 天未扫描`),value:m(V.stale||0)}];return(0,A.jsxs)(`div`,{className:`asset-overview-page`,children:[(0,A.jsx)(C,{title:e(`assets.overviewTitle`,null,`资产概览`),description:`汇总资产规模、服务类型、扫描覆盖与最近发现情况。`,extra:(0,A.jsxs)(i,{wrap:!0,children:[(0,A.jsx)(u,{type:`button`,value:I,options:M,onChange:e=>L(Number(e.target.value)||30)}),(0,A.jsx)(o,{icon:(0,A.jsx)(f,{}),onClick:()=>{R.reload(),z.reload()},children:e(`common.refresh`,null,`刷新`)}),(0,A.jsx)(o,{icon:(0,A.jsx)(a,{}),onClick:()=>t(`/asset-library`),children:e(`assets.viewLibrary`,null,`查看资产库`)}),F&&(0,A.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(d,{}),onClick:()=>t(`/info-collect`),children:e(`nav.infoCollect`,null,`信息收集`)})]})}),!P&&(0,A.jsx)(p,{type:`warning`,bordered:!0,closeIcon:null,description:e(`assets.readDenied`,null,`当前账号没有 asset:read 权限,无法读取资产统计;请联系管理员授权。`)}),P&&(0,A.jsx)(x,{error:R.error,onRetry:()=>R.reload()}),P&&(0,A.jsx)(v,{metrics:G,columns:6}),P&&(0,A.jsxs)(`div`,{className:`asset-overview-columns`,children:[(0,A.jsx)(S,{className:`asset-overview-card`,title:e(`assets.protocolDistribution`,null,`协议分布`),description:e(`assets.protocolDistributionHint`,null,`按已识别服务查看资产暴露构成`),extra:(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e(`assets.protocolKinds`,{count:H.length},`${H.length} 种协议`)}),children:H.length===0?(0,A.jsx)(s,{title:e(`common.noData`,null,`暂无数据`),description:null,style:{padding:24}}):(0,A.jsx)(`div`,{className:`asset-overview-bars`,children:H.map(e=>{let t=N(e.count,B.total||U);return(0,A.jsxs)(`div`,{className:`asset-overview-bar-row`,children:[(0,A.jsx)(j,{size:`small`,className:`asset-overview-bar-label`,children:e.name||`unknown`}),(0,A.jsx)(l,{percent:t,showInfo:!1,stroke:`var(--semi-color-primary)`}),(0,A.jsxs)(j,{type:`tertiary`,size:`small`,className:`asset-overview-bar-value`,children:[m(e.count||0),` · `,t,`%`]})]},e.name)})})}),(0,A.jsx)(S,{className:`asset-overview-card`,title:e(`assets.scanCoverage`,null,`扫描覆盖`),description:e(`assets.scanCoverageHint`,null,`识别未扫描与长期未复查的资产缺口`),extra:(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e(`assets.coverageMeta`,{scanned:V.scanned||0,total:B.total||0},`${V.scanned||0} / ${B.total||0} 已覆盖`)}),children:(0,A.jsxs)(`div`,{className:`asset-overview-coverage`,children:[(0,A.jsxs)(`div`,{className:`asset-overview-coverage-main`,children:[(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e(`assets.overallCoverage`,null,`总体覆盖率`)}),(0,A.jsx)(l,{percent:Number(V.rate||0),stroke:Number(V.rate||0)>=80?`var(--semi-color-success)`:void 0,format:e=>`${e}%`})]}),(0,A.jsx)(`div`,{className:`asset-overview-coverage-grid`,children:J.map(e=>(0,A.jsxs)(`div`,{className:`asset-overview-coverage-item`,children:[(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e.label}),(0,A.jsx)(j,{strong:!0,children:e.value})]},e.label))})]})})]}),P&&(0,A.jsxs)(S,{title:e(`assets.recentAssets`,null,`最近资产`),description:`按最近发现时间排列的前 10 条资产。`,extra:(0,A.jsx)(o,{theme:`borderless`,onClick:()=>t(`/asset-library`),children:e(`assets.viewLibrary`,null,`查看资产库`)}),children:[(0,A.jsx)(x,{error:z.error,onRetry:()=>z.reload()}),(0,A.jsx)(w,{columns:q,dataSource:W,loading:z.loading,rowKey:`id`,pagination:!1,onRefresh:()=>z.reload(),emptyText:e(`common.noData`,null,`暂无数据`)})]})]})}export{P as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r}from"./react-QV7DAAIx.js";import{F as i,Jt as a,L as o,T as s,W as c,h as l,m as u,ot as d,st as f,z as p}from"./semi-Dpcldp_F.js";import{D as m,F as h,I as g,P as _,_ as v,a as y,k as b,l as x,m as S,p as C,s as w}from"./index-BMTtTYg1.js";import{a as T,n as E,r as D}from"./AssetBits-BYTpudK4.js";import{r as O}from"./assetTarget-D2PEjBAg.js";var k=e(t(),1),A=e(r(),1),{Text:j}=c,M=[{value:7,label:`7 天`},{value:30,label:`30 天`},{value:90,label:`90 天`}];function N(e,t){let n=Number(e||0),r=Number(t||0);return r?Math.round(n/r*1e3)/10:0}function P(){let e=_(),t=n(),{hasPermission:r,hasAnyPermission:c}=h(),P=r(`asset:read`),F=c([`asset:read`,`fofa:execute`]),[I,L]=(0,k.useState)(30),R=y(()=>g.get(`/assets/stats`,{days:I}),[I],{skip:!P}),z=y(()=>g.get(`/assets`,{page:1,page_size:10,sort_by:`last_seen_at`,sort_order:`desc`}),[],{skip:!P}),B=R.data||{},V=B.coverage||{},H=Array.isArray(B.protocols)?B.protocols:[],U=(0,k.useMemo)(()=>H.reduce((e,t)=>e+Number(t.count||0),0),[H]),W=Array.isArray(z.data?.assets)?z.data.assets:[],G=[{id:`total`,label:e(`assets.totalAssets`,null,`资产总数`),value:m(B.total||0),detail:e(`assets.totalAssetsHint`,null,`当前纳入持续监测的资产`),loading:R.loading},{id:`ips`,label:e(`assets.ipCount`,null,`IP 数量`),value:m(B.ips||0),loading:R.loading},{id:`domains`,label:e(`assets.domainCount`,null,`域名数量`),value:m(B.domains||0),loading:R.loading},{id:`ports`,label:e(`assets.portCount`,null,`端口数量`),value:m(B.ports||0),loading:R.loading},{id:`protocols`,label:e(`assets.serviceTypes`,null,`服务类型`),value:m(H.length),detail:H[0]?`${e(`assets.topProtocol`,null,`主要协议`)}:${H[0].name}`:void 0,loading:R.loading},{id:`recent`,label:e(`assets.recentCount`,null,`近 7 天发现`),value:m(B.recent||0),detail:e(`assets.recentShare`,{percent:N(B.recent,B.total)},`占当前资产总量的 ${N(B.recent,B.total)}%`),loading:R.loading}],K=e=>{let n=e?.id?`?id=${encodeURIComponent(e.id)}`:``;t(`/asset-library${n}`,e?{state:{asset:e}}:void 0)},q=[{title:e(`assets.target`,null,`目标`),dataIndex:`host`,render:(e,t)=>(0,A.jsxs)(`div`,{className:`asset-overview-target`,children:[(0,A.jsx)(T,{text:O(t),max:34}),(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:[t.ip,t.domain].filter(Boolean).join(` · `)||`—`})]})},{title:e(`assets.service`,null,`服务`),dataIndex:`protocol`,width:150,render:(e,t)=>(0,A.jsx)(E,{protocol:t.protocol,port:t.port})},{title:e(`assets.source`,null,`来源`),dataIndex:`source`,width:120,render:e=>(0,A.jsx)(T,{text:e,max:14})},{title:e(`assets.riskLevel`,null,`风险等级`),dataIndex:`risk_level`,width:120,render:(e,t)=>(0,A.jsx)(D,{asset:t})},{title:e(`assets.lastSeen`,null,`最近发现`),dataIndex:`last_seen_at`,width:130,render:t=>(0,A.jsx)(j,{size:`small`,children:b(t,e)})},{title:e(`common.actions`,null,`操作`),dataIndex:`id`,width:100,render:(t,n)=>(0,A.jsx)(o,{theme:`borderless`,size:`small`,onClick:()=>K(n),children:e(`common.view`,null,`查看`)})}],J=[{label:e(`assets.scannedAssets`,null,`已扫描资产`),value:m(V.scanned||0)},{label:e(`assets.recentlyScanned`,null,`近 30 天覆盖`),value:m(V.scanned_30d||0)},{label:e(`assets.neverScanned`,null,`从未扫描`),value:m(V.never_scanned||0)},{label:e(`assets.staleScans`,null,`超过 30 天未扫描`),value:m(V.stale||0)}];return(0,A.jsxs)(`div`,{className:`asset-overview-page`,children:[(0,A.jsx)(C,{title:e(`assets.overviewTitle`,null,`资产概览`),description:`汇总资产规模、服务类型、扫描覆盖与最近发现情况。`,extra:(0,A.jsxs)(i,{wrap:!0,children:[(0,A.jsx)(u,{type:`button`,value:I,options:M,onChange:e=>L(Number(e.target.value)||30)}),(0,A.jsx)(o,{icon:(0,A.jsx)(f,{}),onClick:()=>{R.reload(),z.reload()},children:e(`common.refresh`,null,`刷新`)}),(0,A.jsx)(o,{icon:(0,A.jsx)(a,{}),onClick:()=>t(`/asset-library`),children:e(`assets.viewLibrary`,null,`查看资产库`)}),F&&(0,A.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(d,{}),onClick:()=>t(`/info-collect`),children:e(`nav.infoCollect`,null,`信息收集`)})]})}),!P&&(0,A.jsx)(p,{type:`warning`,bordered:!0,closeIcon:null,description:e(`assets.readDenied`,null,`当前账号没有 asset:read 权限,无法读取资产统计;请联系管理员授权。`)}),P&&(0,A.jsx)(x,{error:R.error,onRetry:()=>R.reload()}),P&&(0,A.jsx)(v,{metrics:G,columns:6}),P&&(0,A.jsxs)(`div`,{className:`asset-overview-columns`,children:[(0,A.jsx)(S,{className:`asset-overview-card`,title:e(`assets.protocolDistribution`,null,`协议分布`),description:e(`assets.protocolDistributionHint`,null,`按已识别服务查看资产暴露构成`),extra:(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e(`assets.protocolKinds`,{count:H.length},`${H.length} 种协议`)}),children:H.length===0?(0,A.jsx)(s,{title:e(`common.noData`,null,`暂无数据`),description:null,style:{padding:24}}):(0,A.jsx)(`div`,{className:`asset-overview-bars`,children:H.map(e=>{let t=N(e.count,B.total||U);return(0,A.jsxs)(`div`,{className:`asset-overview-bar-row`,children:[(0,A.jsx)(j,{size:`small`,className:`asset-overview-bar-label`,children:e.name||`unknown`}),(0,A.jsx)(l,{percent:t,showInfo:!1,stroke:`var(--semi-color-primary)`}),(0,A.jsxs)(j,{type:`tertiary`,size:`small`,className:`asset-overview-bar-value`,children:[m(e.count||0),` · `,t,`%`]})]},e.name)})})}),(0,A.jsx)(S,{className:`asset-overview-card`,title:e(`assets.scanCoverage`,null,`扫描覆盖`),description:e(`assets.scanCoverageHint`,null,`识别未扫描与长期未复查的资产缺口`),extra:(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e(`assets.coverageMeta`,{scanned:V.scanned||0,total:B.total||0},`${V.scanned||0} / ${B.total||0} 已覆盖`)}),children:(0,A.jsxs)(`div`,{className:`asset-overview-coverage`,children:[(0,A.jsxs)(`div`,{className:`asset-overview-coverage-main`,children:[(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e(`assets.overallCoverage`,null,`总体覆盖率`)}),(0,A.jsx)(l,{percent:Number(V.rate||0),stroke:Number(V.rate||0)>=80?`var(--semi-color-success)`:void 0,format:e=>`${e}%`})]}),(0,A.jsx)(`div`,{className:`asset-overview-coverage-grid`,children:J.map(e=>(0,A.jsxs)(`div`,{className:`asset-overview-coverage-item`,children:[(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e.label}),(0,A.jsx)(j,{strong:!0,children:e.value})]},e.label))})]})})]}),P&&(0,A.jsxs)(S,{title:e(`assets.recentAssets`,null,`最近资产`),description:`按最近发现时间排列的前 10 条资产。`,extra:(0,A.jsx)(o,{theme:`borderless`,onClick:()=>t(`/asset-library`),children:e(`assets.viewLibrary`,null,`查看资产库`)}),children:[(0,A.jsx)(x,{error:z.error,onRetry:()=>z.reload()}),(0,A.jsx)(w,{columns:q,dataSource:W,loading:z.loading,rowKey:`id`,pagination:!1,onRefresh:()=>z.reload(),emptyText:e(`common.noData`,null,`暂无数据`)})]})]})}export{P as default};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-events-CYxXfc-x.js b/web/static/app/assets/c2-events-D6HmGisy.js
similarity index 97%
rename from web/static/app/assets/c2-events-CYxXfc-x.js
rename to web/static/app/assets/c2-events-D6HmGisy.js
index 93036dea..cc0d4352 100644
--- a/web/static/app/assets/c2-events-CYxXfc-x.js
+++ b/web/static/app/assets/c2-events-D6HmGisy.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,W as s,f as ee,st as te,v as c}from"./semi-Dpcldp_F.js";import{E as l,F as ne,P as re,_ as ie,a as u,b as d,l as f,m as p,p as m,r as ae,s as oe,u as se,x as h,y as g}from"./index-gBcdNgHq.js";import{c as _,v}from"./c2-shared-BxfKXbIb.js";import{g as y,m as b,n as x,p as S,r as C,t as w}from"./c2-shared-C42gWRB4.js";var T=e(t(),1),E=e(n(),1),{Text:D}=s;function O(){let e=re(),{hasPermission:t}=ne(),n=t(`c2:delete`)||t(`c2:write`),[s,O]=(0,T.useState)(1),[k,A]=(0,T.useState)(20),[j,M]=(0,T.useState)(``),[N,P]=(0,T.useState)(``),[F,I]=(0,T.useState)(`24h`),[L,R]=(0,T.useState)(``),[z,B]=(0,T.useState)(``),[V,H]=(0,T.useState)([]),[U,W]=(0,T.useState)(null),G=(0,T.useMemo)(()=>({page:s,page_size:k,level:j||void 0,category:N||void 0,session_id:z||void 0,since:y(F)||void 0}),[s,k,j,N,z,F]),{data:K,loading:q,error:ce,reload:J}=u(()=>v(G),[G]),Y=Array.isArray(K?.events)?K.events:[],X=Number(K?.total??Y.length),Z=K?.level_counts||{};ae(()=>J({silent:!0}),5e3);let Q=()=>{B(L.trim()),O(1),H([])},le=()=>{M(``),P(``),I(`24h`),R(``),B(``),O(1),H([])},ue=[{id:`total`,label:e(`c2.events.statTotal`,null,`当前筛选`),value:X},{id:`info`,label:e(`c2.events.info`,null,`信息`),value:Z.info||0},{id:`warn`,label:e(`c2.events.warn`,null,`警告`),value:Z.warn||0,tone:`warning`},{id:`critical`,label:e(`c2.events.critical`,null,`严重`),value:Z.critical||0,tone:`danger`}],$=t=>{g({title:e(`c2.events.batchDelete`,null,`删除事件`),content:t.length>1?e(`c2.events.confirmBatchDelete`,null,`确定删除选中的事件吗?此操作不可恢复。`).replace(`{{n}}`,String(t.length)):e(`c2.events.confirmDeleteOne`,null,`确定删除该条事件吗?此操作不可恢复。`),onOk:async()=>{try{let n=await _(t);h(e(`c2.events.toastDeleted`,null,`已删除`).replace(`{{n}}`,String(n?.deleted??t.length))),H(e=>e.filter(e=>!t.includes(e))),J()}catch(e){d(e)}}})},de=[{title:e(`c2.events.level`,null,`级别`),dataIndex:`level`,width:90,render:t=>(0,E.jsx)(o,{size:`small`,color:x[t]||`grey`,children:e(`c2.events.${t||`info`}`,null,t||`—`)})},{title:e(`c2.events.category`,null,`类别`),dataIndex:`category`,width:110},{title:e(`c2.events.message`,null,`消息`),dataIndex:`message`,render:(e,t)=>(0,E.jsx)(`button`,{type:`button`,className:`c2-event-message`,onClick:()=>W(t),title:e,children:e||`—`})},{title:e(`c2.events.colSession`,null,`会话`),dataIndex:`sessionId`,width:150,render:e=>(0,E.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.events.colTask`,null,`任务`),dataIndex:`taskId`,width:150,render:e=>(0,E.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.events.time`,null,`时间`),dataIndex:`createdAt`,width:130,render:e=>(0,E.jsx)(b,{value:e})},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:130,render:(t,i)=>(0,E.jsxs)(r,{spacing:4,children:[(0,E.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>W(i),children:e(`c2.events.view`,null,`查看`)}),(0,E.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,disabled:!n,onClick:()=>$([i.id]),children:e(`c2.events.deleteOne`,null,`删除`)})]})}];return(0,E.jsxs)(`div`,{className:`c2-page`,id:`page-c2-events`,children:[(0,E.jsx)(m,{title:e(`c2.events.title`,null,`事件审计`),description:e(`c2.events.pageDesc`,null,`监听器、会话、任务与 OPSEC 事件留痕,5 秒自动刷新`),extra:[(0,E.jsx)(a,{icon:(0,E.jsx)(te,{}),onClick:()=>J(),loading:q,children:e(`c2.events.refresh`,null,`刷新`)},`refresh`),(0,E.jsx)(a,{type:`danger`,disabled:!n||!V.length,onClick:()=>$(V),children:e(`c2.events.batchDelete`,null,`批量删除`)},`delete`)]}),(0,E.jsx)(ie,{metrics:ue,columns:4}),(0,E.jsx)(f,{error:ce,onRetry:()=>J()}),(0,E.jsx)(p,{title:e(`c2.events.filterTitle`,null,`筛选`),extra:(0,E.jsx)(S,{value:F,onChange:e=>{I(e),O(1)},ns:`events`}),children:(0,E.jsxs)(`div`,{className:`c2-toolbar-fields`,children:[(0,E.jsxs)(`div`,{className:`c2-field`,children:[(0,E.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.level`,null,`级别`)}),(0,E.jsx)(c,{value:j,onChange:e=>{M(e||``),O(1)},style:{width:150},optionList:[{value:``,label:e(`c2.events.filterAllLevels`,null,`全部级别`)},...C]})]}),(0,E.jsxs)(`div`,{className:`c2-field`,children:[(0,E.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.category`,null,`类别`)}),(0,E.jsx)(c,{value:N,onChange:e=>{P(e||``),O(1)},style:{width:150},optionList:[{value:``,label:e(`c2.events.filterAllCategories`,null,`全部类别`)},...w]})]}),(0,E.jsxs)(`div`,{className:`c2-field`,children:[(0,E.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.filterSession`,null,`会话 ID`)}),(0,E.jsx)(i,{value:L,onChange:R,onEnterPress:Q,placeholder:e(`c2.events.filterSessionPlaceholder`,null,`s_xxxxxxxx`),style:{width:190}})]}),(0,E.jsxs)(r,{spacing:8,children:[(0,E.jsx)(a,{theme:`solid`,type:`primary`,onClick:Q,children:e(`c2.events.applyFilters`,null,`应用筛选`)}),(0,E.jsx)(a,{onClick:le,children:e(`c2.events.resetFilters`,null,`重置`)})]})]})}),(0,E.jsx)(p,{title:e(`c2.events.listTitle`,null,`事件列表`),children:(0,E.jsx)(oe,{columns:de,dataSource:Y,rowKey:`id`,loading:q,onRefresh:()=>J(),rowSelection:{selectedRowKeys:V,onChange:e=>H(e)},pagination:{currentPage:s,pageSize:k,total:X,onPageChange:e=>O(e),onPageSizeChange:e=>{A(e),O(1)}},emptyText:e(`c2.events.empty`,null,`暂无事件`)})}),(0,E.jsx)(ee,{visible:!!U,title:e(`c2.events.detailTitle`,null,`事件详情`),width:560,onCancel:()=>W(null),children:U&&(0,E.jsxs)(`div`,{className:`c2-event-detail`,children:[(0,E.jsxs)(`div`,{className:`c2-event-detail-head`,children:[(0,E.jsx)(o,{size:`small`,color:x[U.level]||`grey`,children:U.level}),(0,E.jsx)(o,{size:`small`,children:U.category}),(0,E.jsx)(D,{type:`tertiary`,size:`small`,children:l(U.createdAt)})]}),(0,E.jsx)(D,{children:U.message}),(0,E.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.events.colId`,null,`事件 ID`)}),(0,E.jsx)(D,{className:`c2-mono`,copyable:{text:U.id},children:U.id}),U.sessionId&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.events.colSession`,null,`会话`)}),(0,E.jsx)(D,{className:`c2-mono`,children:U.sessionId})]}),U.data&&Object.keys(U.data).length>0&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.events.detailData`,null,`附加数据`)}),(0,E.jsx)(se,{value:U.data})]})]})})]})}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,W as s,f as ee,st as te,v as c}from"./semi-Dpcldp_F.js";import{E as l,F as ne,P as re,_ as ie,a as u,b as d,l as f,m as p,p as m,r as ae,s as oe,u as se,x as h,y as g}from"./index-BMTtTYg1.js";import{c as _,v}from"./c2-shared-CweYFEMs.js";import{g as y,m as b,n as x,p as S,r as C,t as w}from"./c2-shared-CGoxRI15.js";var T=e(t(),1),E=e(n(),1),{Text:D}=s;function O(){let e=re(),{hasPermission:t}=ne(),n=t(`c2:delete`)||t(`c2:write`),[s,O]=(0,T.useState)(1),[k,A]=(0,T.useState)(20),[j,M]=(0,T.useState)(``),[N,P]=(0,T.useState)(``),[F,I]=(0,T.useState)(`24h`),[L,R]=(0,T.useState)(``),[z,B]=(0,T.useState)(``),[V,H]=(0,T.useState)([]),[U,W]=(0,T.useState)(null),G=(0,T.useMemo)(()=>({page:s,page_size:k,level:j||void 0,category:N||void 0,session_id:z||void 0,since:y(F)||void 0}),[s,k,j,N,z,F]),{data:K,loading:q,error:ce,reload:J}=u(()=>v(G),[G]),Y=Array.isArray(K?.events)?K.events:[],X=Number(K?.total??Y.length),Z=K?.level_counts||{};ae(()=>J({silent:!0}),5e3);let Q=()=>{B(L.trim()),O(1),H([])},le=()=>{M(``),P(``),I(`24h`),R(``),B(``),O(1),H([])},ue=[{id:`total`,label:e(`c2.events.statTotal`,null,`当前筛选`),value:X},{id:`info`,label:e(`c2.events.info`,null,`信息`),value:Z.info||0},{id:`warn`,label:e(`c2.events.warn`,null,`警告`),value:Z.warn||0,tone:`warning`},{id:`critical`,label:e(`c2.events.critical`,null,`严重`),value:Z.critical||0,tone:`danger`}],$=t=>{g({title:e(`c2.events.batchDelete`,null,`删除事件`),content:t.length>1?e(`c2.events.confirmBatchDelete`,null,`确定删除选中的事件吗?此操作不可恢复。`).replace(`{{n}}`,String(t.length)):e(`c2.events.confirmDeleteOne`,null,`确定删除该条事件吗?此操作不可恢复。`),onOk:async()=>{try{let n=await _(t);h(e(`c2.events.toastDeleted`,null,`已删除`).replace(`{{n}}`,String(n?.deleted??t.length))),H(e=>e.filter(e=>!t.includes(e))),J()}catch(e){d(e)}}})},de=[{title:e(`c2.events.level`,null,`级别`),dataIndex:`level`,width:90,render:t=>(0,E.jsx)(o,{size:`small`,color:x[t]||`grey`,children:e(`c2.events.${t||`info`}`,null,t||`—`)})},{title:e(`c2.events.category`,null,`类别`),dataIndex:`category`,width:110},{title:e(`c2.events.message`,null,`消息`),dataIndex:`message`,render:(e,t)=>(0,E.jsx)(`button`,{type:`button`,className:`c2-event-message`,onClick:()=>W(t),title:e,children:e||`—`})},{title:e(`c2.events.colSession`,null,`会话`),dataIndex:`sessionId`,width:150,render:e=>(0,E.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.events.colTask`,null,`任务`),dataIndex:`taskId`,width:150,render:e=>(0,E.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.events.time`,null,`时间`),dataIndex:`createdAt`,width:130,render:e=>(0,E.jsx)(b,{value:e})},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:130,render:(t,i)=>(0,E.jsxs)(r,{spacing:4,children:[(0,E.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>W(i),children:e(`c2.events.view`,null,`查看`)}),(0,E.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,disabled:!n,onClick:()=>$([i.id]),children:e(`c2.events.deleteOne`,null,`删除`)})]})}];return(0,E.jsxs)(`div`,{className:`c2-page`,id:`page-c2-events`,children:[(0,E.jsx)(m,{title:e(`c2.events.title`,null,`事件审计`),description:e(`c2.events.pageDesc`,null,`监听器、会话、任务与 OPSEC 事件留痕,5 秒自动刷新`),extra:[(0,E.jsx)(a,{icon:(0,E.jsx)(te,{}),onClick:()=>J(),loading:q,children:e(`c2.events.refresh`,null,`刷新`)},`refresh`),(0,E.jsx)(a,{type:`danger`,disabled:!n||!V.length,onClick:()=>$(V),children:e(`c2.events.batchDelete`,null,`批量删除`)},`delete`)]}),(0,E.jsx)(ie,{metrics:ue,columns:4}),(0,E.jsx)(f,{error:ce,onRetry:()=>J()}),(0,E.jsx)(p,{title:e(`c2.events.filterTitle`,null,`筛选`),extra:(0,E.jsx)(S,{value:F,onChange:e=>{I(e),O(1)},ns:`events`}),children:(0,E.jsxs)(`div`,{className:`c2-toolbar-fields`,children:[(0,E.jsxs)(`div`,{className:`c2-field`,children:[(0,E.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.level`,null,`级别`)}),(0,E.jsx)(c,{value:j,onChange:e=>{M(e||``),O(1)},style:{width:150},optionList:[{value:``,label:e(`c2.events.filterAllLevels`,null,`全部级别`)},...C]})]}),(0,E.jsxs)(`div`,{className:`c2-field`,children:[(0,E.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.category`,null,`类别`)}),(0,E.jsx)(c,{value:N,onChange:e=>{P(e||``),O(1)},style:{width:150},optionList:[{value:``,label:e(`c2.events.filterAllCategories`,null,`全部类别`)},...w]})]}),(0,E.jsxs)(`div`,{className:`c2-field`,children:[(0,E.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.events.filterSession`,null,`会话 ID`)}),(0,E.jsx)(i,{value:L,onChange:R,onEnterPress:Q,placeholder:e(`c2.events.filterSessionPlaceholder`,null,`s_xxxxxxxx`),style:{width:190}})]}),(0,E.jsxs)(r,{spacing:8,children:[(0,E.jsx)(a,{theme:`solid`,type:`primary`,onClick:Q,children:e(`c2.events.applyFilters`,null,`应用筛选`)}),(0,E.jsx)(a,{onClick:le,children:e(`c2.events.resetFilters`,null,`重置`)})]})]})}),(0,E.jsx)(p,{title:e(`c2.events.listTitle`,null,`事件列表`),children:(0,E.jsx)(oe,{columns:de,dataSource:Y,rowKey:`id`,loading:q,onRefresh:()=>J(),rowSelection:{selectedRowKeys:V,onChange:e=>H(e)},pagination:{currentPage:s,pageSize:k,total:X,onPageChange:e=>O(e),onPageSizeChange:e=>{A(e),O(1)}},emptyText:e(`c2.events.empty`,null,`暂无事件`)})}),(0,E.jsx)(ee,{visible:!!U,title:e(`c2.events.detailTitle`,null,`事件详情`),width:560,onCancel:()=>W(null),children:U&&(0,E.jsxs)(`div`,{className:`c2-event-detail`,children:[(0,E.jsxs)(`div`,{className:`c2-event-detail-head`,children:[(0,E.jsx)(o,{size:`small`,color:x[U.level]||`grey`,children:U.level}),(0,E.jsx)(o,{size:`small`,children:U.category}),(0,E.jsx)(D,{type:`tertiary`,size:`small`,children:l(U.createdAt)})]}),(0,E.jsx)(D,{children:U.message}),(0,E.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.events.colId`,null,`事件 ID`)}),(0,E.jsx)(D,{className:`c2-mono`,copyable:{text:U.id},children:U.id}),U.sessionId&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.events.colSession`,null,`会话`)}),(0,E.jsx)(D,{className:`c2-mono`,children:U.sessionId})]}),U.data&&Object.keys(U.data).length>0&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.events.detailData`,null,`附加数据`)}),(0,E.jsx)(se,{value:U.data})]})]})})]})}export{O as default};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-listeners-B04z6s--.js b/web/static/app/assets/c2-listeners-Nc6p1LCr.js
similarity index 98%
rename from web/static/app/assets/c2-listeners-B04z6s--.js
rename to web/static/app/assets/c2-listeners-Nc6p1LCr.js
index 548767db..3a337d61 100644
--- a/web/static/app/assets/c2-listeners-B04z6s--.js
+++ b/web/static/app/assets/c2-listeners-Nc6p1LCr.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,L as i,M as a,W as o,i as s,lt as c,st as l}from"./semi-Dpcldp_F.js";import{E as u,F as d,P as f,_ as p,a as m,b as h,c as g,l as _,m as v,o as y,p as b,s as x,x as S,y as C}from"./index-gBcdNgHq.js";import{D as w,E as T,O as E,b as D,i as O,l as k,x as A,y as j}from"./c2-shared-BxfKXbIb.js";import{a as M,i as N,o as P}from"./c2-shared-C42gWRB4.js";var F=e(t(),1),I=e(n(),1),{Text:L}=o;function R(e){if(!e?.configJson)return{};try{return JSON.parse(e.configJson)||{}}catch{return{}}}function z(e){let t=R(e);return{name:e?.name||``,type:e?.type||`http_beacon`,project_id:e?.project_id||``,bind_host:e?.bindHost||`127.0.0.1`,bind_port:String(e?.bindPort??`4444`),callback_host:t.callback_host||``,profile_id:e?.profileId||``,remark:e?.remark||``,default_sleep:String(t.default_sleep??5),default_jitter:String(t.default_jitter??0),max_concurrent_tasks:String(t.max_concurrent_tasks??0),allow_legacy_shell:!!t.allow_legacy_shell}}function B({visible:e,record:t,projects:n,profiles:a,submitting:o,onCancel:c,onSubmit:l}){let u=f(),[d,p]=(0,F.useState)(null),[m,h]=(0,F.useState)(t?.type||`http_beacon`);return(0,I.jsx)(g,{visible:e,title:t?u(`c2.listeners.editTitle`,null,`编辑监听器`):u(`c2.listeners.modalCreateTitle`,null,`创建监听器`),footer:(0,I.jsxs)(r,{children:[(0,I.jsx)(i,{onClick:c,children:u(`c2.common.cancel`,null,`取消`)}),(0,I.jsx)(i,{theme:`solid`,type:`primary`,loading:o,onClick:()=>d?.submitForm(),children:t?u(`c2.listeners.save`,null,`保存`):u(`c2.listeners.submitCreate`,null,`创建`)})]}),width:620,onCancel:c,children:(0,I.jsxs)(s,{initValues:z(t),onSubmit:e=>{let t=Number(e.bind_port);l({name:String(e.name||``).trim(),type:e.type,project_id:e.project_id||``,bind_host:String(e.bind_host||``).trim()||`127.0.0.1`,bind_port:Number.isFinite(t)?t:0,callback_host:String(e.callback_host||``).trim(),profile_id:e.profile_id||``,remark:String(e.remark||``).trim(),config:{callback_host:String(e.callback_host||``).trim(),default_sleep:Number(e.default_sleep)||5,default_jitter:Number(e.default_jitter)||0,max_concurrent_tasks:Number(e.max_concurrent_tasks)||0,allow_legacy_shell:!!e.allow_legacy_shell}})},getFormApi:p,labelPosition:`top`,onValueChange:e=>{e.type&&h(e.type)},children:[(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`name`,label:u(`c2.listeners.name`,null,`名称`),placeholder:u(`c2.listeners.placeholderNameExample`,null,`例如 http-beacon-01`),rules:[{required:!0,message:u(`c2.listeners.nameRequired`,null,`请输入监听器名称`)}]}),(0,I.jsx)(s.Select,{field:`type`,label:u(`c2.listeners.type`,null,`类型`),optionList:P,disabled:!!t,style:{width:`100%`}})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`bind_host`,label:u(`c2.listeners.bindHost`,null,`绑定地址`),placeholder:`127.0.0.1`}),(0,I.jsx)(s.Input,{field:`bind_port`,label:u(`c2.listeners.bindPort`,null,`绑定端口`),placeholder:u(`c2.listeners.placeholderPort`,null,`输入端口号`),rules:[{required:!0,validator:(e,t)=>{let n=Number(t);return Number.isInteger(n)&&n>0&&n<=65535},message:u(`c2.listeners.portInvalid`,null,`端口必须为 1–65535 的整数`)}]})]}),(0,I.jsx)(L,{type:`tertiary`,size:`small`,children:u(`c2.listeners.bindHintExternal`,null,`使用 0.0.0.0 允许外部访问`)}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`callback_host`,label:u(`c2.listeners.callbackHost`,null,`回连地址(可选)`),placeholder:`公网 IP 或域名`}),(0,I.jsx)(s.Select,{field:`profile_id`,label:u(`c2.listeners.malleableProfile`,null,`Malleable Profile`),optionList:[{value:``,label:u(`c2.listeners.malleableProfileNone`,null,`不使用`)},...a.map(e=>({value:e.id,label:e.name||e.id}))],style:{width:`100%`}})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Select,{field:`project_id`,label:u(`c2.listeners.project`,null,`所属项目`),optionList:[{value:``,label:u(`c2.listeners.projectNone`,null,`不绑定项目`)},...n.map(e=>({value:e.id,label:e.name||e.id}))],style:{width:`100%`}}),(0,I.jsx)(s.Input,{field:`remark`,label:u(`c2.listeners.remark`,null,`备注`),placeholder:u(`c2.listeners.placeholderRemarkLong`,null,`可选的备注说明`)})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`default_sleep`,label:`默认 Sleep(秒)`,placeholder:`5`}),(0,I.jsx)(s.Input,{field:`default_jitter`,label:`默认 Jitter(%)`,placeholder:`0`})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`max_concurrent_tasks`,label:`单会话并发任务上限(0 不限)`,placeholder:`0`}),m===`tcp_reverse`&&(0,I.jsx)(s.Switch,{field:`allow_legacy_shell`,label:u(`c2.listeners.allowLegacyShell`,null,`允许未加密经典反弹 Shell(内网实验)`)})]})]},t?.id||`new`)})}var{Text:V}=o,H=e=>P.find(t=>t.value===e)?.label||e||`—`;function U(){let e=f(),{hasPermission:t}=d(),n=t(`c2:write`),o=t(`c2:delete`)||n,[s,P]=(0,F.useState)({visible:!1,record:null}),[L,R]=(0,F.useState)(!1),[z,U]=(0,F.useState)(``),[W,G]=(0,F.useState)(null),{data:K,loading:q,error:J,reload:Y}=m(()=>Promise.all([j(),D().catch(()=>({profiles:[]})),A()]),[]),X=Array.isArray(K?.[0]?.listeners)?K[0].listeners:[],Z=Array.isArray(K?.[1]?.profiles)?K[1].profiles:[],Q=Array.isArray(K?.[2])?K[2]:[],$=(0,F.useMemo)(()=>{let t=X.filter(e=>e.status===`running`).length,n=X.filter(e=>e.status===`error`).length;return[{id:`total`,label:e(`c2.listeners.statTotal`,null,`监听器总数`),value:X.length},{id:`running`,label:e(`c2.listeners.running`,null,`运行中`),value:t,tone:t?`success`:void 0},{id:`stopped`,label:e(`c2.listeners.stopped`,null,`已停止`),value:X.length-t-n},{id:`error`,label:e(`c2.listeners.statusError`,null,`异常`),value:n,tone:n?`danger`:void 0}]},[X,e]),ee=async(t,n)=>{U(t.id);try{n===`start`?(await T(t.id),S(e(`c2.listeners.toastStarted`,null,`监听器已启动`))):(await w(t.id),S(e(`c2.listeners.toastStopped`,null,`监听器已停止`))),Y()}catch(t){h(t,n===`start`?e(`c2.listeners.start`,null,`启动失败`):e(`c2.listeners.stop`,null,`停止失败`))}finally{U(``)}},te=t=>{C({title:e(`c2.listeners.delete`,null,`删除监听器`),content:e(`c2.listeners.confirmDelete`,null,`确定删除此监听器?相关会话与任务将被清除。`),onOk:async()=>{try{await k(t.id),S(e(`c2.listeners.toastDeleted`,null,`监听器已删除`)),Y()}catch(e){h(e)}}})},ne=async t=>{R(!0);try{if(s.record?.id)await E(s.record.id,t),S(e(`c2.listeners.toastUpdated`,null,`监听器已更新`));else{let n=await O(t);S(e(`c2.listeners.toastCreated`,null,`监听器已创建`)),n?.implant_token&&G({name:n.listener?.name||t.name,token:n.implant_token})}P({visible:!1,record:null}),Y()}catch(t){h(t,e(`c2.listeners.saveFailed`,null,`监听器保存失败`))}finally{R(!1)}},re=[{title:e(`c2.listeners.name`,null,`名称`),dataIndex:`name`,render:(e,t)=>(0,I.jsxs)(`div`,{className:`c2-listener-name`,children:[(0,I.jsx)(V,{strong:!0,children:e||t.id}),t.remark&&(0,I.jsx)(V,{type:`tertiary`,size:`small`,children:t.remark})]})},{title:e(`c2.listeners.type`,null,`类型`),dataIndex:`type`,width:140,render:H},{title:e(`c2.listeners.bindEndpoint`,null,`监听地址`),dataIndex:`bindPort`,width:200,render:(e,t)=>(0,I.jsxs)(`span`,{className:`c2-mono`,children:[t.bindHost,`:`,e]})},{title:e(`c2.listeners.callbackShort`,null,`回连`),dataIndex:`configJson`,width:160,render:e=>{try{let t=JSON.parse(e||`{}`);return t.callback_host?(0,I.jsx)(`span`,{className:`c2-mono`,children:t.callback_host}):(0,I.jsx)(V,{type:`tertiary`,children:`—`})}catch{return(0,I.jsx)(V,{type:`tertiary`,children:`—`})}}},{title:e(`c2.listeners.status`,null,`状态`),dataIndex:`status`,width:120,render:(e,t)=>(0,I.jsxs)(`div`,{className:`c2-listener-status`,children:[(0,I.jsx)(a,{size:`small`,color:N[e]||`grey`,children:M[e]||e||`—`}),t.lastError&&(0,I.jsx)(V,{type:`danger`,size:`small`,children:t.lastError})]})},{title:e(`c2.listeners.startedAtPrefix`,null,`启动于`),dataIndex:`startedAt`,width:180,render:e=>e?u(e):(0,I.jsx)(V,{type:`tertiary`,children:`—`})},{title:e(`c2.listeners.actions`,null,`操作`),dataIndex:`actions`,width:220,render:(t,a)=>{let s=a.status===`running`;return(0,I.jsxs)(r,{spacing:4,wrap:!0,children:[(0,I.jsx)(i,{size:`small`,theme:`borderless`,disabled:!n,loading:z===a.id,onClick:()=>ee(a,s?`stop`:`start`),children:s?e(`c2.listeners.stop`,null,`停止`):e(`c2.listeners.start`,null,`启动`)}),(0,I.jsx)(i,{size:`small`,theme:`borderless`,disabled:!n,onClick:()=>P({visible:!0,record:a}),children:e(`c2.listeners.edit`,null,`编辑`)}),(0,I.jsx)(i,{size:`small`,theme:`borderless`,type:`danger`,disabled:!o,onClick:()=>te(a),children:e(`c2.listeners.delete`,null,`删除`)})]})}}];return(0,I.jsxs)(`div`,{className:`c2-page`,id:`page-c2-listeners`,children:[(0,I.jsx)(b,{title:e(`c2.listeners.title`,null,`监听器管理`),description:e(`c2.listeners.pageDesc`,null,`创建并启停 C2 监听器,启停状态即时同步到后端`),extra:[(0,I.jsx)(i,{icon:(0,I.jsx)(l,{}),onClick:Y,loading:q,children:e(`common.refresh`,null,`刷新`)},`refresh`),(0,I.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,I.jsx)(c,{}),disabled:!n,onClick:()=>P({visible:!0,record:null}),children:e(`c2.listeners.create`,null,`创建监听器`)},`create`)]}),(0,I.jsx)(p,{metrics:$,columns:4}),(0,I.jsx)(_,{error:J,onRetry:Y}),(0,I.jsx)(v,{title:e(`c2.listeners.title`,null,`监听器列表`),children:(0,I.jsx)(x,{columns:re,dataSource:X,rowKey:`id`,loading:q,onRefresh:Y,pagination:{pageSize:10},emptyText:e(`c2.listeners.emptyTitle`,null,`暂无监听器`)})}),(0,I.jsx)(B,{visible:s.visible,record:s.record,projects:Q,profiles:Z,submitting:L,onCancel:()=>P({visible:!1,record:null}),onSubmit:ne}),(0,I.jsxs)(g,{visible:!!W,title:e(`c2.listeners.implantTokenTitle`,null,`植入体 Token`),onCancel:()=>G(null),footer:(0,I.jsx)(i,{onClick:()=>G(null),children:e(`c2.listeners.close`,null,`关闭`)}),children:[(0,I.jsx)(V,{type:`tertiary`,children:e(`c2.listeners.implantTokenHint`,null,`该 Token 仅在此处显示一次,请立即保存;后续可通过重新创建监听器获取。`)}),(0,I.jsxs)(`div`,{className:`c2-listener-token`,children:[(0,I.jsx)(`span`,{className:`c2-mono`,children:W?.token}),(0,I.jsx)(y,{text:W?.token||``})]})]})]})}export{U as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,L as i,M as a,W as o,i as s,lt as c,st as l}from"./semi-Dpcldp_F.js";import{E as u,F as d,P as f,_ as p,a as m,b as h,c as g,l as _,m as v,o as y,p as b,s as x,x as S,y as C}from"./index-BMTtTYg1.js";import{D as w,E as T,O as E,b as D,i as O,l as k,x as A,y as j}from"./c2-shared-CweYFEMs.js";import{a as M,i as N,o as P}from"./c2-shared-CGoxRI15.js";var F=e(t(),1),I=e(n(),1),{Text:L}=o;function R(e){if(!e?.configJson)return{};try{return JSON.parse(e.configJson)||{}}catch{return{}}}function z(e){let t=R(e);return{name:e?.name||``,type:e?.type||`http_beacon`,project_id:e?.project_id||``,bind_host:e?.bindHost||`127.0.0.1`,bind_port:String(e?.bindPort??`4444`),callback_host:t.callback_host||``,profile_id:e?.profileId||``,remark:e?.remark||``,default_sleep:String(t.default_sleep??5),default_jitter:String(t.default_jitter??0),max_concurrent_tasks:String(t.max_concurrent_tasks??0),allow_legacy_shell:!!t.allow_legacy_shell}}function B({visible:e,record:t,projects:n,profiles:a,submitting:o,onCancel:c,onSubmit:l}){let u=f(),[d,p]=(0,F.useState)(null),[m,h]=(0,F.useState)(t?.type||`http_beacon`);return(0,I.jsx)(g,{visible:e,title:t?u(`c2.listeners.editTitle`,null,`编辑监听器`):u(`c2.listeners.modalCreateTitle`,null,`创建监听器`),footer:(0,I.jsxs)(r,{children:[(0,I.jsx)(i,{onClick:c,children:u(`c2.common.cancel`,null,`取消`)}),(0,I.jsx)(i,{theme:`solid`,type:`primary`,loading:o,onClick:()=>d?.submitForm(),children:t?u(`c2.listeners.save`,null,`保存`):u(`c2.listeners.submitCreate`,null,`创建`)})]}),width:620,onCancel:c,children:(0,I.jsxs)(s,{initValues:z(t),onSubmit:e=>{let t=Number(e.bind_port);l({name:String(e.name||``).trim(),type:e.type,project_id:e.project_id||``,bind_host:String(e.bind_host||``).trim()||`127.0.0.1`,bind_port:Number.isFinite(t)?t:0,callback_host:String(e.callback_host||``).trim(),profile_id:e.profile_id||``,remark:String(e.remark||``).trim(),config:{callback_host:String(e.callback_host||``).trim(),default_sleep:Number(e.default_sleep)||5,default_jitter:Number(e.default_jitter)||0,max_concurrent_tasks:Number(e.max_concurrent_tasks)||0,allow_legacy_shell:!!e.allow_legacy_shell}})},getFormApi:p,labelPosition:`top`,onValueChange:e=>{e.type&&h(e.type)},children:[(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`name`,label:u(`c2.listeners.name`,null,`名称`),placeholder:u(`c2.listeners.placeholderNameExample`,null,`例如 http-beacon-01`),rules:[{required:!0,message:u(`c2.listeners.nameRequired`,null,`请输入监听器名称`)}]}),(0,I.jsx)(s.Select,{field:`type`,label:u(`c2.listeners.type`,null,`类型`),optionList:P,disabled:!!t,style:{width:`100%`}})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`bind_host`,label:u(`c2.listeners.bindHost`,null,`绑定地址`),placeholder:`127.0.0.1`}),(0,I.jsx)(s.Input,{field:`bind_port`,label:u(`c2.listeners.bindPort`,null,`绑定端口`),placeholder:u(`c2.listeners.placeholderPort`,null,`输入端口号`),rules:[{required:!0,validator:(e,t)=>{let n=Number(t);return Number.isInteger(n)&&n>0&&n<=65535},message:u(`c2.listeners.portInvalid`,null,`端口必须为 1–65535 的整数`)}]})]}),(0,I.jsx)(L,{type:`tertiary`,size:`small`,children:u(`c2.listeners.bindHintExternal`,null,`使用 0.0.0.0 允许外部访问`)}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`callback_host`,label:u(`c2.listeners.callbackHost`,null,`回连地址(可选)`),placeholder:`公网 IP 或域名`}),(0,I.jsx)(s.Select,{field:`profile_id`,label:u(`c2.listeners.malleableProfile`,null,`Malleable Profile`),optionList:[{value:``,label:u(`c2.listeners.malleableProfileNone`,null,`不使用`)},...a.map(e=>({value:e.id,label:e.name||e.id}))],style:{width:`100%`}})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Select,{field:`project_id`,label:u(`c2.listeners.project`,null,`所属项目`),optionList:[{value:``,label:u(`c2.listeners.projectNone`,null,`不绑定项目`)},...n.map(e=>({value:e.id,label:e.name||e.id}))],style:{width:`100%`}}),(0,I.jsx)(s.Input,{field:`remark`,label:u(`c2.listeners.remark`,null,`备注`),placeholder:u(`c2.listeners.placeholderRemarkLong`,null,`可选的备注说明`)})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`default_sleep`,label:`默认 Sleep(秒)`,placeholder:`5`}),(0,I.jsx)(s.Input,{field:`default_jitter`,label:`默认 Jitter(%)`,placeholder:`0`})]}),(0,I.jsxs)(`div`,{className:`c2-form-row`,children:[(0,I.jsx)(s.Input,{field:`max_concurrent_tasks`,label:`单会话并发任务上限(0 不限)`,placeholder:`0`}),m===`tcp_reverse`&&(0,I.jsx)(s.Switch,{field:`allow_legacy_shell`,label:u(`c2.listeners.allowLegacyShell`,null,`允许未加密经典反弹 Shell(内网实验)`)})]})]},t?.id||`new`)})}var{Text:V}=o,H=e=>P.find(t=>t.value===e)?.label||e||`—`;function U(){let e=f(),{hasPermission:t}=d(),n=t(`c2:write`),o=t(`c2:delete`)||n,[s,P]=(0,F.useState)({visible:!1,record:null}),[L,R]=(0,F.useState)(!1),[z,U]=(0,F.useState)(``),[W,G]=(0,F.useState)(null),{data:K,loading:q,error:J,reload:Y}=m(()=>Promise.all([j(),D().catch(()=>({profiles:[]})),A()]),[]),X=Array.isArray(K?.[0]?.listeners)?K[0].listeners:[],Z=Array.isArray(K?.[1]?.profiles)?K[1].profiles:[],Q=Array.isArray(K?.[2])?K[2]:[],$=(0,F.useMemo)(()=>{let t=X.filter(e=>e.status===`running`).length,n=X.filter(e=>e.status===`error`).length;return[{id:`total`,label:e(`c2.listeners.statTotal`,null,`监听器总数`),value:X.length},{id:`running`,label:e(`c2.listeners.running`,null,`运行中`),value:t,tone:t?`success`:void 0},{id:`stopped`,label:e(`c2.listeners.stopped`,null,`已停止`),value:X.length-t-n},{id:`error`,label:e(`c2.listeners.statusError`,null,`异常`),value:n,tone:n?`danger`:void 0}]},[X,e]),ee=async(t,n)=>{U(t.id);try{n===`start`?(await T(t.id),S(e(`c2.listeners.toastStarted`,null,`监听器已启动`))):(await w(t.id),S(e(`c2.listeners.toastStopped`,null,`监听器已停止`))),Y()}catch(t){h(t,n===`start`?e(`c2.listeners.start`,null,`启动失败`):e(`c2.listeners.stop`,null,`停止失败`))}finally{U(``)}},te=t=>{C({title:e(`c2.listeners.delete`,null,`删除监听器`),content:e(`c2.listeners.confirmDelete`,null,`确定删除此监听器?相关会话与任务将被清除。`),onOk:async()=>{try{await k(t.id),S(e(`c2.listeners.toastDeleted`,null,`监听器已删除`)),Y()}catch(e){h(e)}}})},ne=async t=>{R(!0);try{if(s.record?.id)await E(s.record.id,t),S(e(`c2.listeners.toastUpdated`,null,`监听器已更新`));else{let n=await O(t);S(e(`c2.listeners.toastCreated`,null,`监听器已创建`)),n?.implant_token&&G({name:n.listener?.name||t.name,token:n.implant_token})}P({visible:!1,record:null}),Y()}catch(t){h(t,e(`c2.listeners.saveFailed`,null,`监听器保存失败`))}finally{R(!1)}},re=[{title:e(`c2.listeners.name`,null,`名称`),dataIndex:`name`,render:(e,t)=>(0,I.jsxs)(`div`,{className:`c2-listener-name`,children:[(0,I.jsx)(V,{strong:!0,children:e||t.id}),t.remark&&(0,I.jsx)(V,{type:`tertiary`,size:`small`,children:t.remark})]})},{title:e(`c2.listeners.type`,null,`类型`),dataIndex:`type`,width:140,render:H},{title:e(`c2.listeners.bindEndpoint`,null,`监听地址`),dataIndex:`bindPort`,width:200,render:(e,t)=>(0,I.jsxs)(`span`,{className:`c2-mono`,children:[t.bindHost,`:`,e]})},{title:e(`c2.listeners.callbackShort`,null,`回连`),dataIndex:`configJson`,width:160,render:e=>{try{let t=JSON.parse(e||`{}`);return t.callback_host?(0,I.jsx)(`span`,{className:`c2-mono`,children:t.callback_host}):(0,I.jsx)(V,{type:`tertiary`,children:`—`})}catch{return(0,I.jsx)(V,{type:`tertiary`,children:`—`})}}},{title:e(`c2.listeners.status`,null,`状态`),dataIndex:`status`,width:120,render:(e,t)=>(0,I.jsxs)(`div`,{className:`c2-listener-status`,children:[(0,I.jsx)(a,{size:`small`,color:N[e]||`grey`,children:M[e]||e||`—`}),t.lastError&&(0,I.jsx)(V,{type:`danger`,size:`small`,children:t.lastError})]})},{title:e(`c2.listeners.startedAtPrefix`,null,`启动于`),dataIndex:`startedAt`,width:180,render:e=>e?u(e):(0,I.jsx)(V,{type:`tertiary`,children:`—`})},{title:e(`c2.listeners.actions`,null,`操作`),dataIndex:`actions`,width:220,render:(t,a)=>{let s=a.status===`running`;return(0,I.jsxs)(r,{spacing:4,wrap:!0,children:[(0,I.jsx)(i,{size:`small`,theme:`borderless`,disabled:!n,loading:z===a.id,onClick:()=>ee(a,s?`stop`:`start`),children:s?e(`c2.listeners.stop`,null,`停止`):e(`c2.listeners.start`,null,`启动`)}),(0,I.jsx)(i,{size:`small`,theme:`borderless`,disabled:!n,onClick:()=>P({visible:!0,record:a}),children:e(`c2.listeners.edit`,null,`编辑`)}),(0,I.jsx)(i,{size:`small`,theme:`borderless`,type:`danger`,disabled:!o,onClick:()=>te(a),children:e(`c2.listeners.delete`,null,`删除`)})]})}}];return(0,I.jsxs)(`div`,{className:`c2-page`,id:`page-c2-listeners`,children:[(0,I.jsx)(b,{title:e(`c2.listeners.title`,null,`监听器管理`),description:e(`c2.listeners.pageDesc`,null,`创建并启停 C2 监听器,启停状态即时同步到后端`),extra:[(0,I.jsx)(i,{icon:(0,I.jsx)(l,{}),onClick:Y,loading:q,children:e(`common.refresh`,null,`刷新`)},`refresh`),(0,I.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,I.jsx)(c,{}),disabled:!n,onClick:()=>P({visible:!0,record:null}),children:e(`c2.listeners.create`,null,`创建监听器`)},`create`)]}),(0,I.jsx)(p,{metrics:$,columns:4}),(0,I.jsx)(_,{error:J,onRetry:Y}),(0,I.jsx)(v,{title:e(`c2.listeners.title`,null,`监听器列表`),children:(0,I.jsx)(x,{columns:re,dataSource:X,rowKey:`id`,loading:q,onRefresh:Y,pagination:{pageSize:10},emptyText:e(`c2.listeners.emptyTitle`,null,`暂无监听器`)})}),(0,I.jsx)(B,{visible:s.visible,record:s.record,projects:Q,profiles:Z,submitting:L,onCancel:()=>P({visible:!1,record:null}),onSubmit:ne}),(0,I.jsxs)(g,{visible:!!W,title:e(`c2.listeners.implantTokenTitle`,null,`植入体 Token`),onCancel:()=>G(null),footer:(0,I.jsx)(i,{onClick:()=>G(null),children:e(`c2.listeners.close`,null,`关闭`)}),children:[(0,I.jsx)(V,{type:`tertiary`,children:e(`c2.listeners.implantTokenHint`,null,`该 Token 仅在此处显示一次,请立即保存;后续可通过重新创建监听器获取。`)}),(0,I.jsxs)(`div`,{className:`c2-listener-token`,children:[(0,I.jsx)(`span`,{className:`c2-mono`,children:W?.token}),(0,I.jsx)(y,{text:W?.token||``})]})]})]})}export{U as default};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-payloads-B8kOz9Q8.js b/web/static/app/assets/c2-payloads-C6wD7vjB.js
similarity index 97%
rename from web/static/app/assets/c2-payloads-B8kOz9Q8.js
rename to web/static/app/assets/c2-payloads-C6wD7vjB.js
index 696f6567..15fa82a4 100644
--- a/web/static/app/assets/c2-payloads-B8kOz9Q8.js
+++ b/web/static/app/assets/c2-payloads-C6wD7vjB.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,W as s,v as c}from"./semi-Dpcldp_F.js";import{F as l,P as u,S as d,T as f,a as p,b as m,l as h,m as g,o as _,p as v,s as y,x as b}from"./index-gBcdNgHq.js";import{m as x,n as S,t as C,y as w}from"./c2-shared-BxfKXbIb.js";import{o as T,s as E}from"./c2-shared-C42gWRB4.js";var D=e(t(),1),O=e(n(),1),{Text:k,Title:ee}=s,A=[{value:`linux`,label:`Linux`},{value:`windows`,label:`Windows`},{value:`darwin`,label:`macOS`}],j=[{value:`amd64`,label:`AMD64`},{value:`arm64`,label:`ARM64`},{value:`386`,label:`386`}],M=e=>T.find(t=>t.value===e)?.label||e||`—`;function N(){let e=u(),{hasPermission:t}=l(),n=t(`c2:write`),{data:s,loading:T,error:N,reload:P}=p(()=>w(),[]),F=Array.isArray(s?.listeners)?s.listeners:[],[I,L]=(0,D.useState)({listenerId:``,kind:``,host:``}),[R,z]=(0,D.useState)(null),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)({listenerId:``,host:``,os:`linux`,arch:`amd64`}),[W,G]=(0,D.useState)(null),[K,q]=(0,D.useState)(!1),[J,Y]=(0,D.useState)([]),X=(0,D.useMemo)(()=>F.find(e=>e.id===(I.listenerId||F[0]?.id))||null,[F,I.listenerId]),Z=E[X?.type]||[],Q=F.map(e=>({value:e.id,label:`${e.name||e.id} · ${M(e.type)}`})),te=async()=>{let t=I.listenerId||F[0]?.id;if(!t){d(e(`c2.payloads.toastPickListener`,null,`请先选择一个监听器`));return}let n=I.kind||Z[0]?.value;if(!n)d(e(`c2.payloads.noKindOption`,null,`无可用类型`));else{V(!0);try{let e=await C({listener_id:t,kind:n,host:I.host.trim()});z(e)}catch(t){m(t,e(`c2.payloads.toastOnelinerFail`,null,`生成 Oneliner 失败`))}finally{V(!1)}}},ne=async()=>{let t=H.listenerId||F[0]?.id;if(!t)d(e(`c2.payloads.toastPickListener`,null,`请先选择一个监听器`));else{q(!0);try{let n=(await S({listener_id:t,host:H.host.trim(),os:H.os,arch:H.arch,sleep_seconds:5,jitter_percent:0}))?.payload||null;if(G(n),n){let r=String(n.output_path||``).split(/[\\/]/).pop();Y(e=>[{id:n.payload_id||r,fileName:r,listenerId:t,os:n.os,arch:n.arch,size:n.size_bytes},...e]),b(e(`c2.payloads.toastBuildSuccess`,null,`构建成功`).replace(`{{bytes}}`,String(n.size_bytes||0)))}}catch(t){m(t,e(`c2.payloads.toastBuildFail`,null,`构建 Beacon 失败`))}finally{q(!1)}}},$=async t=>{if(!t.fileName?.startsWith(`beacon_`))d(e(`c2.payloads.invalidArtifact`,null,`该产物不可下载`));else try{await x(t.fileName,t.fileName),b(e(`c2.payloads.toastDownloadQueued`,null,`下载任务已排队`))}catch(t){m(t,e(`c2.payloads.download`,null,`下载失败`))}},re=[{title:e(`c2.payloads.fileName`,null,`文件`),dataIndex:`fileName`,render:e=>(0,O.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.payloads.os`,null,`系统`),dataIndex:`os`,width:100},{title:e(`c2.payloads.arch`,null,`架构`),dataIndex:`arch`,width:100},{title:e(`c2.payloads.size`,null,`大小`),dataIndex:`size`,width:110,render:e=>f(e)},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:120,render:(t,n)=>(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>$(n),children:e(`c2.payloads.download`,null,`下载`)})}];return(0,O.jsxs)(`div`,{className:`c2-page`,id:`page-c2-payloads`,children:[(0,O.jsx)(v,{title:e(`c2.payloads.title`,null,`Payload 生成`),description:e(`c2.payloads.pageDesc`,null,`生成单行反弹命令,或交叉编译完整 Beacon 二进制`),extra:[(0,O.jsx)(a,{onClick:P,loading:T,children:e(`common.refresh`,null,`刷新`)},`refresh`)]}),(0,O.jsx)(h,{error:N,onRetry:P}),(0,O.jsxs)(`div`,{className:`c2-payload-grid`,children:[(0,O.jsxs)(g,{title:e(`c2.payloads.oneliner`,null,`单行 Payload`),description:e(`c2.payloads.onelinerDesc`,null,`生成可在目标机直接执行的反弹命令`),children:[(0,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.listener`,null,`监听器`)}),(0,O.jsx)(c,{value:I.listenerId||F[0]?.id||``,onChange:e=>L(t=>({...t,listenerId:e,kind:``})),optionList:Q,placeholder:e(`c2.payloads.noListenersOption`,null,`暂无可用监听器`),style:{width:`100%`}})]}),(0,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.kind`,null,`类型`)}),(0,O.jsx)(c,{value:I.kind||Z[0]?.value||``,onChange:e=>L(t=>({...t,kind:e})),optionList:Z,placeholder:e(`c2.payloads.noKindOption`,null,`无可用类型`),style:{width:`100%`}})]}),(0,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.hostOptional`,null,`回连地址(可选)`)}),(0,O.jsx)(i,{value:I.host,onChange:e=>L(t=>({...t,host:e})),placeholder:e(`c2.payloads.placeholderListenerHost`,null,`留空则使用监听器回连地址`)})]}),(0,O.jsx)(a,{theme:`solid`,type:`primary`,block:!0,disabled:!n,loading:B,onClick:te,children:e(`c2.payloads.generateOnelinerBtn`,null,`生成 Oneliner`)}),R?.oneliner&&(0,O.jsxs)(`div`,{className:`c2-oneliner-result`,children:[(0,O.jsxs)(`div`,{className:`c2-oneliner-head`,children:[(0,O.jsxs)(r,{spacing:6,children:[(0,O.jsx)(o,{size:`small`,children:R.kind}),(0,O.jsxs)(k,{type:`tertiary`,size:`small`,children:[R.host,`:`,R.port]})]}),(0,O.jsx)(_,{text:R.oneliner,label:e(`c2.payloads.copy`,null,`复制`),size:`small`})]}),(0,O.jsx)(`pre`,{className:`c2-pre`,children:R.oneliner})]})]}),(0,O.jsxs)(g,{title:e(`c2.payloads.build`,null,`编译 Beacon`),description:e(`c2.payloads.buildDesc`,null,`交叉编译多平台完整 Beacon 可执行文件`),children:[(0,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.listener`,null,`监听器`)}),(0,O.jsx)(c,{value:H.listenerId||F[0]?.id||``,onChange:e=>U(t=>({...t,listenerId:e})),optionList:Q,placeholder:e(`c2.payloads.noListenersOption`,null,`暂无可用监听器`),style:{width:`100%`}})]}),(0,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.hostOptional`,null,`回连地址(可选)`)}),(0,O.jsx)(i,{value:H.host,onChange:e=>U(t=>({...t,host:e})),placeholder:e(`c2.payloads.placeholderListenerHost`,null,`留空则使用监听器回连地址`)})]}),(0,O.jsxs)(`div`,{className:`c2-form-row`,children:[(0,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.os`,null,`目标系统`)}),(0,O.jsx)(c,{value:H.os,onChange:e=>U(t=>({...t,os:e})),optionList:A,style:{width:`100%`}})]}),(0,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.arch`,null,`目标架构`)}),(0,O.jsx)(c,{value:H.arch,onChange:e=>U(t=>({...t,arch:e})),optionList:j,style:{width:`100%`}})]})]}),(0,O.jsx)(a,{theme:`solid`,type:`primary`,block:!0,disabled:!n,loading:K,onClick:ne,children:e(`c2.payloads.buildBeaconBtn`,null,`构建 Beacon`)}),W&&(0,O.jsxs)(`div`,{className:`c2-build-result`,children:[(0,O.jsx)(ee,{heading:6,children:e(`c2.payloads.buildSuccessTitle`,null,`构建成功`)}),(0,O.jsx)(k,{type:`tertiary`,size:`small`,children:e(`c2.payloads.buildMetaOsArch`,null,`系统 / 架构`).replace(`{{os}}`,W.os||`—`).replace(`{{arch}}`,W.arch||`—`)}),(0,O.jsx)(k,{type:`tertiary`,size:`small`,children:e(`c2.payloads.buildSize`,null,`大小`).replace(`{{bytes}}`,String(W.size_bytes||0))}),(0,O.jsx)(`pre`,{className:`c2-pre`,children:W.output_path}),(0,O.jsx)(a,{size:`small`,onClick:()=>$({fileName:String(W.output_path||``).split(/[\\/]/).pop(),...W}),children:e(`c2.payloads.download`,null,`下载`)})]})]})]}),(0,O.jsx)(g,{title:e(`c2.payloads.artifacts`,null,`本次会话构建产物`),children:(0,O.jsx)(y,{columns:re,dataSource:J,rowKey:`id`,pagination:{pageSize:10},emptyText:e(`c2.payloads.noArtifacts`,null,`暂无构建产物`)})})]})}export{N as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,v as c}from"./semi-Dpcldp_F.js";import{F as l,P as u,S as d,T as f,a as p,b as m,l as h,m as g,o as _,p as v,s as y,x as b}from"./index-BMTtTYg1.js";import{m as x,n as S,t as C,y as w}from"./c2-shared-CweYFEMs.js";import{o as T,s as E}from"./c2-shared-CGoxRI15.js";var D=e(t(),1),O=e(n(),1),{Text:k,Title:ee}=s,A=[{value:`linux`,label:`Linux`},{value:`windows`,label:`Windows`},{value:`darwin`,label:`macOS`}],j=[{value:`amd64`,label:`AMD64`},{value:`arm64`,label:`ARM64`},{value:`386`,label:`386`}],M=e=>T.find(t=>t.value===e)?.label||e||`—`;function N(){let e=u(),{hasPermission:t}=l(),n=t(`c2:write`),{data:s,loading:T,error:N,reload:P}=p(()=>w(),[]),F=Array.isArray(s?.listeners)?s.listeners:[],[I,L]=(0,D.useState)({listenerId:``,kind:``,host:``}),[R,z]=(0,D.useState)(null),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)({listenerId:``,host:``,os:`linux`,arch:`amd64`}),[W,G]=(0,D.useState)(null),[K,q]=(0,D.useState)(!1),[J,Y]=(0,D.useState)([]),X=(0,D.useMemo)(()=>F.find(e=>e.id===(I.listenerId||F[0]?.id))||null,[F,I.listenerId]),Z=E[X?.type]||[],Q=F.map(e=>({value:e.id,label:`${e.name||e.id} · ${M(e.type)}`})),te=async()=>{let t=I.listenerId||F[0]?.id;if(!t){d(e(`c2.payloads.toastPickListener`,null,`请先选择一个监听器`));return}let n=I.kind||Z[0]?.value;if(!n)d(e(`c2.payloads.noKindOption`,null,`无可用类型`));else{V(!0);try{let e=await C({listener_id:t,kind:n,host:I.host.trim()});z(e)}catch(t){m(t,e(`c2.payloads.toastOnelinerFail`,null,`生成 Oneliner 失败`))}finally{V(!1)}}},ne=async()=>{let t=H.listenerId||F[0]?.id;if(!t)d(e(`c2.payloads.toastPickListener`,null,`请先选择一个监听器`));else{q(!0);try{let n=(await S({listener_id:t,host:H.host.trim(),os:H.os,arch:H.arch,sleep_seconds:5,jitter_percent:0}))?.payload||null;if(G(n),n){let r=String(n.output_path||``).split(/[\\/]/).pop();Y(e=>[{id:n.payload_id||r,fileName:r,listenerId:t,os:n.os,arch:n.arch,size:n.size_bytes},...e]),b(e(`c2.payloads.toastBuildSuccess`,null,`构建成功`).replace(`{{bytes}}`,String(n.size_bytes||0)))}}catch(t){m(t,e(`c2.payloads.toastBuildFail`,null,`构建 Beacon 失败`))}finally{q(!1)}}},$=async t=>{if(!t.fileName?.startsWith(`beacon_`))d(e(`c2.payloads.invalidArtifact`,null,`该产物不可下载`));else try{await x(t.fileName,t.fileName),b(e(`c2.payloads.toastDownloadQueued`,null,`下载任务已排队`))}catch(t){m(t,e(`c2.payloads.download`,null,`下载失败`))}},re=[{title:e(`c2.payloads.fileName`,null,`文件`),dataIndex:`fileName`,render:e=>(0,O.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.payloads.os`,null,`系统`),dataIndex:`os`,width:100},{title:e(`c2.payloads.arch`,null,`架构`),dataIndex:`arch`,width:100},{title:e(`c2.payloads.size`,null,`大小`),dataIndex:`size`,width:110,render:e=>f(e)},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:120,render:(t,n)=>(0,O.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>$(n),children:e(`c2.payloads.download`,null,`下载`)})}];return(0,O.jsxs)(`div`,{className:`c2-page`,id:`page-c2-payloads`,children:[(0,O.jsx)(v,{title:e(`c2.payloads.title`,null,`Payload 生成`),description:e(`c2.payloads.pageDesc`,null,`生成单行反弹命令,或交叉编译完整 Beacon 二进制`),extra:[(0,O.jsx)(a,{onClick:P,loading:T,children:e(`common.refresh`,null,`刷新`)},`refresh`)]}),(0,O.jsx)(h,{error:N,onRetry:P}),(0,O.jsxs)(`div`,{className:`c2-payload-grid`,children:[(0,O.jsxs)(g,{title:e(`c2.payloads.oneliner`,null,`单行 Payload`),description:e(`c2.payloads.onelinerDesc`,null,`生成可在目标机直接执行的反弹命令`),children:[(0,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.listener`,null,`监听器`)}),(0,O.jsx)(c,{value:I.listenerId||F[0]?.id||``,onChange:e=>L(t=>({...t,listenerId:e,kind:``})),optionList:Q,placeholder:e(`c2.payloads.noListenersOption`,null,`暂无可用监听器`),style:{width:`100%`}})]}),(0,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.kind`,null,`类型`)}),(0,O.jsx)(c,{value:I.kind||Z[0]?.value||``,onChange:e=>L(t=>({...t,kind:e})),optionList:Z,placeholder:e(`c2.payloads.noKindOption`,null,`无可用类型`),style:{width:`100%`}})]}),(0,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.hostOptional`,null,`回连地址(可选)`)}),(0,O.jsx)(i,{value:I.host,onChange:e=>L(t=>({...t,host:e})),placeholder:e(`c2.payloads.placeholderListenerHost`,null,`留空则使用监听器回连地址`)})]}),(0,O.jsx)(a,{theme:`solid`,type:`primary`,block:!0,disabled:!n,loading:B,onClick:te,children:e(`c2.payloads.generateOnelinerBtn`,null,`生成 Oneliner`)}),R?.oneliner&&(0,O.jsxs)(`div`,{className:`c2-oneliner-result`,children:[(0,O.jsxs)(`div`,{className:`c2-oneliner-head`,children:[(0,O.jsxs)(r,{spacing:6,children:[(0,O.jsx)(o,{size:`small`,children:R.kind}),(0,O.jsxs)(k,{type:`tertiary`,size:`small`,children:[R.host,`:`,R.port]})]}),(0,O.jsx)(_,{text:R.oneliner,label:e(`c2.payloads.copy`,null,`复制`),size:`small`})]}),(0,O.jsx)(`pre`,{className:`c2-pre`,children:R.oneliner})]})]}),(0,O.jsxs)(g,{title:e(`c2.payloads.build`,null,`编译 Beacon`),description:e(`c2.payloads.buildDesc`,null,`交叉编译多平台完整 Beacon 可执行文件`),children:[(0,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.listener`,null,`监听器`)}),(0,O.jsx)(c,{value:H.listenerId||F[0]?.id||``,onChange:e=>U(t=>({...t,listenerId:e})),optionList:Q,placeholder:e(`c2.payloads.noListenersOption`,null,`暂无可用监听器`),style:{width:`100%`}})]}),(0,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.hostOptional`,null,`回连地址(可选)`)}),(0,O.jsx)(i,{value:H.host,onChange:e=>U(t=>({...t,host:e})),placeholder:e(`c2.payloads.placeholderListenerHost`,null,`留空则使用监听器回连地址`)})]}),(0,O.jsxs)(`div`,{className:`c2-form-row`,children:[(0,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.os`,null,`目标系统`)}),(0,O.jsx)(c,{value:H.os,onChange:e=>U(t=>({...t,os:e})),optionList:A,style:{width:`100%`}})]}),(0,O.jsxs)(`div`,{className:`c2-field`,children:[(0,O.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.payloads.arch`,null,`目标架构`)}),(0,O.jsx)(c,{value:H.arch,onChange:e=>U(t=>({...t,arch:e})),optionList:j,style:{width:`100%`}})]})]}),(0,O.jsx)(a,{theme:`solid`,type:`primary`,block:!0,disabled:!n,loading:K,onClick:ne,children:e(`c2.payloads.buildBeaconBtn`,null,`构建 Beacon`)}),W&&(0,O.jsxs)(`div`,{className:`c2-build-result`,children:[(0,O.jsx)(ee,{heading:6,children:e(`c2.payloads.buildSuccessTitle`,null,`构建成功`)}),(0,O.jsx)(k,{type:`tertiary`,size:`small`,children:e(`c2.payloads.buildMetaOsArch`,null,`系统 / 架构`).replace(`{{os}}`,W.os||`—`).replace(`{{arch}}`,W.arch||`—`)}),(0,O.jsx)(k,{type:`tertiary`,size:`small`,children:e(`c2.payloads.buildSize`,null,`大小`).replace(`{{bytes}}`,String(W.size_bytes||0))}),(0,O.jsx)(`pre`,{className:`c2-pre`,children:W.output_path}),(0,O.jsx)(a,{size:`small`,onClick:()=>$({fileName:String(W.output_path||``).split(/[\\/]/).pop(),...W}),children:e(`c2.payloads.download`,null,`下载`)})]})]})]}),(0,O.jsx)(g,{title:e(`c2.payloads.artifacts`,null,`本次会话构建产物`),children:(0,O.jsx)(y,{columns:re,dataSource:J,rowKey:`id`,pagination:{pageSize:10},emptyText:e(`c2.payloads.noArtifacts`,null,`暂无构建产物`)})})]})}export{N as default};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-profiles-eJI5wP9G.js b/web/static/app/assets/c2-profiles-s9C-E1r_.js
similarity index 98%
rename from web/static/app/assets/c2-profiles-eJI5wP9G.js
rename to web/static/app/assets/c2-profiles-s9C-E1r_.js
index 5470c8a4..d7760d93 100644
--- a/web/static/app/assets/c2-profiles-eJI5wP9G.js
+++ b/web/static/app/assets/c2-profiles-s9C-E1r_.js
@@ -1,2 +1,2 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,L as i,M as a,W as o,i as s,lt as c,st as l}from"./semi-Dpcldp_F.js";import{E as u,F as d,P as f,S as p,_ as m,a as h,b as g,c as _,l as v,m as y,p as b,s as x,u as S,x as C,y as w}from"./index-gBcdNgHq.js";import{a as T,b as E,k as D,u as O}from"./c2-shared-BxfKXbIb.js";var k=e(t(),1),A=e(n(),1),{Text:j}=o;function M(e){return{name:e?.name||``,user_agent:e?.userAgent||``,uris:Array.isArray(e?.uris)?e.uris.join(`
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,L as i,M as a,W as o,i as s,lt as c,st as l}from"./semi-Dpcldp_F.js";import{E as u,F as d,P as f,S as p,_ as m,a as h,b as g,c as _,l as v,m as y,p as b,s as x,u as S,x as C,y as w}from"./index-BMTtTYg1.js";import{a as T,b as E,k as D,u as O}from"./c2-shared-CweYFEMs.js";var k=e(t(),1),A=e(n(),1),{Text:j}=o;function M(e){return{name:e?.name||``,user_agent:e?.userAgent||``,uris:Array.isArray(e?.uris)?e.uris.join(`
`):``,jitter_min:String(e?.jitterMinMs??0),jitter_max:String(e?.jitterMaxMs??0),request_headers:e?.requestHeaders?JSON.stringify(e.requestHeaders,null,2):``,response_headers:e?.responseHeaders?JSON.stringify(e.responseHeaders,null,2):``,body_template:e?.bodyTemplate||``}}function N(e,t){let n=String(e||``).trim();if(!n)return{};try{let e=JSON.parse(n);if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`not an object`);return e}catch{return p(t(`c2.profiles.toastInvalidHeadersJson`,null,`响应头 JSON 无效`)),null}}function P({visible:e,record:t,submitting:n,onCancel:a,onSubmit:o}){let c=f(),[l,u]=(0,k.useState)(null);return(0,A.jsx)(_,{visible:e,title:t?c(`c2.profiles.editTitle`,null,`编辑 Profile`):c(`c2.profiles.modalCreateTitle`,null,`创建 Malleable Profile`),footer:(0,A.jsxs)(r,{children:[(0,A.jsx)(i,{onClick:a,children:c(`c2.common.cancel`,null,`取消`)}),(0,A.jsx)(i,{theme:`solid`,type:`primary`,loading:n,onClick:()=>l?.submitForm(),children:t?c(`c2.profiles.save`,null,`保存`):c(`c2.profiles.submitCreate`,null,`创建`)})]}),width:640,onCancel:a,children:(0,A.jsxs)(s,{initValues:M(t),onSubmit:e=>{let t=Number(e.jitter_min),n=Number(e.jitter_max);if(!Number.isInteger(t)||!Number.isInteger(n)||t<0||ne.trim()).filter(Boolean),jitterMinMs:t,jitterMaxMs:n,requestHeaders:r,responseHeaders:i,bodyTemplate:String(e.body_template||``)})},getFormApi:u,labelPosition:`top`,children:[(0,A.jsx)(s.Input,{field:`name`,label:c(`c2.profiles.profileNameLabel`,null,`Profile 名称`),placeholder:c(`c2.profiles.placeholderProfileName`,null,`例如 cdn-fronting`),rules:[{required:!0,message:c(`c2.profiles.toastNameRequired`,null,`请填写 Profile 名称`)}]}),(0,A.jsx)(s.Input,{field:`user_agent`,label:c(`c2.profiles.userAgent`,null,`User-Agent`),placeholder:`Mozilla/5.0 ...`}),(0,A.jsx)(s.TextArea,{field:`uris`,label:c(`c2.profiles.labelBeaconUris`,null,`Beacon URI(每行一个)`),placeholder:`/api/v1/ping`,autosize:{minRows:2,maxRows:5}}),(0,A.jsxs)(`div`,{className:`c2-form-row`,children:[(0,A.jsx)(s.Input,{field:`jitter_min`,label:c(`c2.profiles.labelJitterMin`,null,`Jitter 最小值 (ms)`),placeholder:`0`}),(0,A.jsx)(s.Input,{field:`jitter_max`,label:c(`c2.profiles.labelJitterMax`,null,`Jitter 最大值 (ms)`),placeholder:`0`})]}),(0,A.jsx)(s.TextArea,{field:`request_headers`,label:c(`c2.profiles.requestHeadersJson`,null,`自定义请求头 (JSON)`),placeholder:`{"X-Forwarded-For":"127.0.0.1"}`,autosize:{minRows:2,maxRows:6}}),(0,A.jsx)(s.TextArea,{field:`response_headers`,label:c(`c2.profiles.labelRespHeaders`,null,`自定义响应头 (JSON)`),placeholder:`{"Server":"nginx"}`,autosize:{minRows:2,maxRows:6}}),(0,A.jsx)(s.TextArea,{field:`body_template`,label:c(`c2.profiles.bodyTemplate`,null,`响应体模板`),placeholder:`{"status":"ok"}`,autosize:{minRows:2,maxRows:6}}),(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:c(`c2.profiles.hintHeaders`,null,`用于伪装为合法服务的 HTTP 响应头`)})]},t?.id||`new`)})}var{Text:F}=o;function I(){let e=f(),{hasPermission:t}=d(),n=t(`c2:write`),o=t(`c2:delete`)||n,[s,p]=(0,k.useState)({visible:!1,record:null}),[_,j]=(0,k.useState)(!1),[M,N]=(0,k.useState)(null),{data:I,loading:L,error:R,reload:z}=h(()=>E(),[]),B=Array.isArray(I?.profiles)?I.profiles:[],V=(0,k.useMemo)(()=>[{id:`total`,label:e(`c2.profiles.total`,null,`Profile 总数`),value:B.length},{id:`jitter`,label:e(`c2.profiles.withJitter`,null,`启用 Jitter`),value:B.filter(e=>Number(e.jitterMaxMs)>0).length},{id:`uris`,label:e(`c2.profiles.withUris`,null,`自定义 URI`),value:B.filter(e=>Array.isArray(e.uris)&&e.uris.length>0).length},{id:`headers`,label:e(`c2.profiles.withHeaders`,null,`自定义响应头`),value:B.filter(e=>e.responseHeaders&&Object.keys(e.responseHeaders).length>0).length}],[B,e]),H=async t=>{j(!0);try{s.record?.id?(await D(s.record.id,t),C(e(`c2.profiles.toastUpdated`,null,`Profile 已更新`))):(await T(t),C(e(`c2.profiles.toastCreated`,null,`Profile 已创建`))),p({visible:!1,record:null}),z()}catch(t){g(t,e(`c2.profiles.saveFailed`,null,`Profile 保存失败`))}finally{j(!1)}},U=t=>{w({title:e(`c2.profiles.delete`,null,`删除 Profile`),content:e(`c2.profiles.confirmDelete`,null,`确定删除此 Profile?`),onOk:async()=>{try{await O(t.id),C(e(`c2.profiles.toastDeleted`,null,`Profile 已删除`)),z()}catch(e){g(e)}}})},W=[{title:e(`c2.profiles.name`,null,`名称`),dataIndex:`name`,render:(e,t)=>(0,A.jsx)(`button`,{type:`button`,className:`c2-profile-name`,onClick:()=>N(t),children:e||t.id})},{title:e(`c2.profiles.userAgent`,null,`User-Agent`),dataIndex:`userAgent`,render:e=>(0,A.jsx)(`span`,{className:`c2-mono c2-profile-ua`,title:e,children:e||`—`})},{title:e(`c2.profiles.uris`,null,`URI 路径`),dataIndex:`uris`,width:220,render:e=>Array.isArray(e)&&e.length?(0,A.jsx)(r,{spacing:4,wrap:!0,children:e.slice(0,3).map(e=>(0,A.jsx)(a,{size:`small`,children:e},e))}):(0,A.jsx)(F,{type:`tertiary`,children:`—`})},{title:e(`c2.profiles.jitter`,null,`Jitter 范围`),dataIndex:`jitterMinMs`,width:140,render:(e,t)=>`${e||0} – ${t.jitterMaxMs||0} ms`},{title:e(`c2.profiles.createdAt`,null,`创建时间`),dataIndex:`createdAt`,width:170,render:e=>u(e)},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:180,render:(t,a)=>(0,A.jsxs)(r,{spacing:4,children:[(0,A.jsx)(i,{size:`small`,theme:`borderless`,onClick:()=>N(a),children:e(`c2.profiles.view`,null,`查看`)}),(0,A.jsx)(i,{size:`small`,theme:`borderless`,disabled:!n,onClick:()=>p({visible:!0,record:a}),children:e(`c2.profiles.edit`,null,`编辑`)}),(0,A.jsx)(i,{size:`small`,theme:`borderless`,type:`danger`,disabled:!o,onClick:()=>U(a),children:e(`c2.profiles.delete`,null,`删除`)})]})}];return(0,A.jsxs)(`div`,{className:`c2-page`,id:`page-c2-profiles`,children:[(0,A.jsx)(b,{title:e(`c2.profiles.title`,null,`流量伪装`),description:e(`c2.profiles.pageDesc`,null,`维护 HTTP/HTTPS Beacon 的 UA、URI 与响应头模板`),extra:[(0,A.jsx)(i,{icon:(0,A.jsx)(l,{}),onClick:z,loading:L,children:e(`common.refresh`,null,`刷新`)},`refresh`),(0,A.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(c,{}),disabled:!n,onClick:()=>p({visible:!0,record:null}),children:e(`c2.profiles.createBtn`,null,`创建 Profile`)},`create`)]}),(0,A.jsx)(m,{metrics:V,columns:4}),(0,A.jsx)(v,{error:R,onRetry:z}),(0,A.jsx)(y,{title:e(`c2.profiles.listTitle`,null,`Profile 列表`),children:(0,A.jsx)(x,{columns:W,dataSource:B,rowKey:`id`,loading:L,onRefresh:z,pagination:{pageSize:10},emptyText:e(`c2.profiles.empty`,null,`暂无 Profile`)})}),M&&(0,A.jsx)(y,{title:`${e(`c2.profiles.detailTitle`,null,`Profile 详情`)} · ${M.name||M.id}`,extra:(0,A.jsx)(i,{size:`small`,onClick:()=>N(null),children:e(`c2.profiles.close`,null,`收起`)}),children:(0,A.jsx)(S,{value:M})}),(0,A.jsx)(P,{visible:s.visible,record:s.record,submitting:_,onCancel:()=>p({visible:!1,record:null}),onSubmit:H})]})}export{I as default};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-sessions-DpFfDxb7.js b/web/static/app/assets/c2-sessions-Bg61Ih8o.js
similarity index 98%
rename from web/static/app/assets/c2-sessions-DpFfDxb7.js
rename to web/static/app/assets/c2-sessions-Bg61Ih8o.js
index dc297d86..4aa5ef64 100644
--- a/web/static/app/assets/c2-sessions-DpFfDxb7.js
+++ b/web/static/app/assets/c2-sessions-Bg61Ih8o.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,N as c,T as l,U as u,W as d,at as f,c as p,ot as m,st as h,v as g,x as _}from"./semi-Dpcldp_F.js";import{E as v,F as y,P as b,S as x,a as S,b as C,c as w,d as T,l as E,m as D,n as O,p as k,r as A,s as j,u as M,x as N,y as P}from"./index-gBcdNgHq.js";import{C as F,S as ee,T as te,_ as I,d as L,f as R,g as z,h as B,o as ne,p as V,r as H,s as U,w as W,y as re}from"./c2-shared-BxfKXbIb.js";import{c as ie,h as G,l as ae,m as oe,u as K}from"./c2-shared-C42gWRB4.js";var q=e(t(),1),J=e(n(),1),se=0,ce=()=>(se+=1,se),le=e=>new Promise(t=>setTimeout(t,e));function ue({session:e,canWrite:t,onTaskCreated:n}){let r=b(),[c,l]=(0,q.useState)([]),[u,d]=(0,q.useState)(``),[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(``),_=(0,q.useRef)(!0),v=(0,q.useRef)(null);(0,q.useEffect)(()=>()=>{_.current=!1},[]),(0,q.useEffect)(()=>{let e=v.current;e&&(e.scrollTop=e.scrollHeight)},[c]);let y=(0,q.useCallback)(e=>{l(t=>[...t,{id:ce(),...e}])},[]),S=async e=>{let t=600;for(let n=0;n<40;n+=1){if(!_.current)return null;let n=(await I(e))?.task;if(!n)return null;if([`success`,`failed`,`cancelled`].includes(n.status))return n;await le(t),t=Math.min(Math.round(t*1.4),4e3)}return null},w=async i=>{let a=String(i??u).trim();if(a){if(!t)x(r(`c2.sessions.writeRequired`,null,`当前账号没有下发任务的权限`));else{d(``),y({kind:`cmd`,text:a}),m(!0);try{let t=(await ne(e.id,{task_type:`shell`,payload:{command:a,timeout_seconds:60}}))?.task?.id;if(!t){y({kind:`err`,text:r(`c2.sessions.termNoSession`,null,`下发失败:未返回任务 ID`)});return}g(t),n?.();let i=await S(t);if(!i){y({kind:`warn`,text:r(`c2.sessions.termWaitTimeout`,null,`[等待结果超时]`)});return}i.resultText&&y({kind:i.status===`success`?`out`:`warn`,text:i.resultText}),i.error&&y({kind:`err`,text:i.error}),i.status===`cancelled`&&y({kind:`warn`,text:r(`c2.tasks.cancelled`,null,`已取消`)})}catch(e){y({kind:`err`,text:e?.message||r(`c2.sessions.termStatusErr`,null,`执行失败`)}),C(e)}finally{_.current&&(m(!1),g(``))}}}};return(0,J.jsxs)(`div`,{className:`c2-terminal`,children:[(0,J.jsx)(`div`,{className:`c2-terminal-bar`,children:(0,J.jsxs)(i,{spacing:8,children:[(0,J.jsx)(s,{size:`small`,color:p?`amber`:`green`,children:p?r(`c2.sessions.termStatusExec`,null,`执行中…`):r(`c2.sessions.termStatusReady`,null,`就绪`)}),(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>l([]),children:r(`c2.sessions.clearTerminal`,null,`清屏`)}),p&&h&&(0,J.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,onClick:async()=>{if(h)try{await H(h),y({kind:`warn`,text:r(`c2.tasks.toastCancelled`,null,`任务已取消`)})}catch(e){C(e)}},children:r(`c2.tasks.cancelBtn`,null,`取消`)})]})}),(0,J.jsxs)(`div`,{className:`c2-terminal-log`,ref:v,children:[(0,J.jsx)(`div`,{className:`c2-terminal-welcome`,children:r(`c2.sessions.terminalWelcome`,null,`C2 终端 — 回车执行;命令以 shell 任务下发并等待结果`)}),c.map(e=>(0,J.jsx)(`pre`,{className:`c2-terminal-line kind-${e.kind}`,children:e.kind===`cmd`?`$ ${e.text}`:e.text},e.id))]}),(0,J.jsxs)(`div`,{className:`c2-terminal-input`,children:[(0,J.jsx)(a,{value:u,onChange:d,onEnterPress:()=>p?x(r(`c2.sessions.termWaitFinish`,null,`请等待当前命令执行完成`)):w(),placeholder:r(`c2.sessions.commandPlaceholder`,null,`输入命令后回车下发`),disabled:p||!t,prefix:`$`}),(0,J.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,J.jsx)(f,{}),loading:p,disabled:!t,onClick:()=>w(),children:r(`c2.sessions.execute`,null,`执行命令`)})]})]})}function de(e){let t=String(e||``).split(/\r?\n/),n=[];for(let e of t){let t=e.trim();if(!t||/^total\s+\d+/i.test(t))continue;let r=t.split(` `);if(r.length>=4){let e=r.slice(3).join(` `).trim();if(!e||e===`.`||e===`..`)continue;let t=r[0].trim(),i=r[1].trim();n.push({name:e,size:r[2].trim(),mode:i||t,isDir:t.startsWith(`d`)||i.startsWith(`d`)});continue}let i=t.match(/^\S{1,10}\s+\d+\s+\S+\s+\S+\s+\d+\s+\S+\s+\S+\s+\S+\s+(.+)$/);if(!i)continue;let a=i[1].trim(),o=a.indexOf(` -> `);if(o>0&&(a=a.slice(0,o).trim()),!a||a===`.`||a===`..`)continue;let s=t.split(/\s+/);n.push({name:a,size:s[4]||``,mode:s[0]||``,isDir:(s[0]||``).startsWith(`d`)})}return n}function Y(e){let t=String(e??``).trim();return t?/^[A-Za-z]:/.test(t)?t.replace(/\\+$/,``)||t:(t=t.replace(/\\/g,`/`).replace(/\/{2,}/g,`/`),t.length>1&&(t=t.replace(/\/+$/,``)),t||`.`):`.`}function X(e,t){let n=Y(e);return t?/^[A-Za-z]:/.test(t)||t.startsWith(`/`)||n===`.`||n===``?Y(t):Y(`${n}${n.includes(`\\`)?`\\`:`/`}${t}`):n}function fe(e){let t=Y(e);if(t===`.`||t===`/`||/^[A-Za-z]:$/.test(t))return t;let n=t.includes(`\\`)?`\\`:`/`,r=t.lastIndexOf(n);if(r<0)return`.`;if(r===0)return`/`;let i=t.slice(0,r);return/^[A-Za-z]:$/.test(i)?`${i}${n}`:i}var{Text:pe}=d,me=e=>new Promise(t=>setTimeout(t,e));async function he(e){let t=600;for(let n=0;n<40;n+=1){let n=(await I(e))?.task;if(!n)return null;if([`success`,`failed`,`cancelled`].includes(n.status))return n;await me(t),t=Math.min(Math.round(t*1.4),4e3)}return null}function ge({session:e,canWrite:t}){let n=b(),[r,s]=(0,q.useState)(`.`),[c,l]=(0,q.useState)(`.`),[u,d]=(0,q.useState)([]),[f,p]=(0,q.useState)(``),[m,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(null),[y,S]=(0,q.useState)(``),w=(0,q.useRef)(!0);(0,q.useEffect)(()=>()=>{w.current=!1},[]);let T=(0,q.useCallback)(async t=>{let i=Y(t??r);g(!0),v(null);try{let t=(await U({session_id:e.id,task_type:`ls`,payload:{path:i}}))?.task?.id;if(!t)throw Error(n(`c2.files.failed`,null,`列目录失败`));let r=await he(t);if(!w.current)return;if(!r){v(n(`c2.files.timeout`,null,`加载文件超时`));return}if(r.status!==`success`){v(r.error||n(`c2.files.failed`,null,`列目录失败`)),d([]),p(r.resultText||``);return}p(r.resultText||``),d(de(r.resultText||``)),s(i),l(i)}catch(e){w.current&&v(e)}finally{w.current&&g(!1)}},[e.id,r,n]);(0,q.useEffect)(()=>{s(`.`),l(`.`),d([]),T(`.`)},[e.id]);let D=async i=>{if(!t){x(n(`c2.files.writeRequired`,null,`当前账号没有下发任务的权限`));return}let a=X(r,i.name);try{let t=(await U({session_id:e.id,task_type:`download`,payload:{path:a}}))?.task?.id;if(!t)throw Error(n(`c2.files.failed`,null,`下载失败`));let r=await he(t);if(!r||r.status!==`success`)throw Error(r?.error||n(`c2.files.failed`,null,`下载失败`));await B(r.id,i.name),N(n(`c2.files.downloadOk`,null,`下载成功`))}catch(e){C(e,n(`c2.files.failed`,null,`下载失败`))}},O=u.filter(e=>{let t=y.trim().toLowerCase();return!t||e.name.toLowerCase().includes(t)}),k=[{title:n(`c2.files.colName`,null,`名称`),dataIndex:`name`,render:(e,t)=>(0,J.jsxs)(`button`,{type:`button`,className:`c2-file-name ${t.isDir?`is-dir`:``}`,onClick:()=>t.isDir?T(X(r,e)):D(t),children:[e,t.isDir?`/`:``]})},{title:n(`c2.files.colSize`,null,`大小`),dataIndex:`size`,width:120},{title:n(`c2.files.colMode`,null,`权限`),dataIndex:`mode`,width:160},{title:n(`c2.files.colActions`,null,`操作`),dataIndex:`actions`,width:160,render:(e,i)=>i.isDir?(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>T(X(r,i.name)),children:n(`c2.files.open`,null,`打开`)}):(0,J.jsx)(o,{size:`small`,theme:`borderless`,disabled:!t,onClick:()=>D(i),children:n(`c2.files.download`,null,`下载`)})}];return(0,J.jsxs)(`div`,{className:`c2-files`,children:[(0,J.jsx)(`div`,{className:`c2-files-toolbar`,children:(0,J.jsxs)(i,{spacing:8,wrap:!0,children:[(0,J.jsx)(o,{size:`small`,onClick:()=>T(fe(r)),children:n(`c2.files.parent`,null,`上级目录`)}),(0,J.jsx)(o,{size:`small`,icon:(0,J.jsx)(h,{}),loading:m,onClick:()=>T(r),children:n(`c2.files.refresh`,null,`刷新`)}),(0,J.jsx)(a,{size:`small`,value:c,onChange:l,onEnterPress:()=>T(c),className:`c2-files-path`}),(0,J.jsx)(o,{size:`small`,onClick:()=>T(c),children:n(`c2.files.go`,null,`跳转`)}),(0,J.jsx)(a,{size:`small`,value:y,onChange:S,placeholder:n(`c2.files.filter`,null,`过滤名称`),className:`c2-files-filter`})]})}),(0,J.jsxs)(pe,{type:`tertiary`,size:`small`,children:[n(`c2.files.currentPath`,null,`当前目录`),`:`,r]}),(0,J.jsx)(E,{error:_,onRetry:()=>T(r)}),u.length===0&&f.trim()&&!m?(0,J.jsx)(`pre`,{className:`c2-pre`,children:f}):(0,J.jsx)(j,{columns:k,dataSource:O,rowKey:`name`,loading:m,pagination:{pageSize:20},emptyText:n(`c2.files.emptyDir`,null,`空目录`)})]})}function _e({session:e,canDelete:t,onChanged:n}){let r=b(),[a,c]=(0,q.useState)(null),{data:l,loading:u,error:d,reload:f}=S(()=>F({session_id:e.id,limit:100}),[e.id]),p=Array.isArray(l?.tasks)?l.tasks:[];A(()=>f({silent:!0}),5e3);let m=async e=>{try{await H(e.id),N(r(`c2.tasks.toastCancelled`,null,`任务已取消`)),f({silent:!0}),n?.()}catch(e){C(e)}},h=e=>{P({title:r(`c2.tasks.deleteOne`,null,`删除任务`),content:r(`c2.tasks.confirmDeleteOne`,null,`确定从服务器删除该任务记录吗?此操作不可恢复。`),onOk:async()=>{try{await V([e.id]),N(r(`c2.tasks.toastDeleted`,null,`已删除 {{n}} 条`).replace(`{{n}}`,`1`)),f({silent:!0}),n?.()}catch(e){C(e)}}})},g=[{title:r(`c2.tasks.colType`,null,`类型`),dataIndex:`taskType`,width:120},{title:r(`c2.tasks.colCommand`,null,`命令`),dataIndex:`payload`,render:e=>{let t=e?.command||e?.path||``;return(0,J.jsx)(`span`,{className:`c2-mono`,children:t||`—`})}},{title:r(`c2.tasks.colStatus`,null,`状态`),dataIndex:`status`,width:110,render:e=>(0,J.jsx)(s,{size:`small`,color:K[e]||`grey`,children:r(`c2.tasks.${e||`queued`}`,null,e||`—`)})},{title:r(`c2.tasks.colDuration`,null,`耗时`),dataIndex:`durationMs`,width:100,render:e=>G(e)},{title:r(`c2.tasks.colCreated`,null,`创建时间`),dataIndex:`createdAt`,width:140,render:e=>(0,J.jsx)(oe,{value:e})},{title:r(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:200,render:(e,n)=>(0,J.jsxs)(i,{spacing:4,wrap:!0,children:[(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>c(n),children:r(`c2.tasks.view`,null,`查看`)}),[`queued`,`sent`,`running`].includes(n.status)&&(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>m(n),children:r(`c2.tasks.cancelBtn`,null,`取消`)}),(0,J.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!t,onClick:()=>h(n),children:r(`c2.tasks.deleteBtn`,null,`删除`)})]})}];return(0,J.jsxs)(`div`,{className:`c2-session-tasks`,children:[(0,J.jsx)(E,{error:d,onRetry:()=>f()}),(0,J.jsx)(j,{columns:g,dataSource:p,rowKey:`id`,loading:u,onRefresh:()=>f(),pagination:{pageSize:10},emptyText:r(`c2.tasks.emptySession`,null,`该会话暂无任务`)}),(0,J.jsx)(w,{visible:!!a,title:r(`c2.tasks.modalTitle`,null,`任务详情`),width:720,onCancel:()=>c(null),footer:(0,J.jsx)(o,{onClick:()=>c(null),children:r(`c2.tasks.close`,null,`关闭`)}),children:a&&(0,J.jsxs)(`div`,{className:`c2-task-detail`,children:[(0,J.jsxs)(`div`,{className:`c2-task-detail-meta`,children:[(0,J.jsx)(`span`,{className:`c2-mono`,children:a.id}),(0,J.jsx)(s,{size:`small`,color:K[a.status]||`grey`,children:a.status}),(0,J.jsx)(`span`,{className:`c2-muted`,children:v(a.createdAt)})]}),a.payload&&(0,J.jsx)(M,{title:r(`c2.tasks.labelPayload`,null,`参数`),value:a.payload,collapsed:!0}),a.resultText&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`c2-field-label`,children:r(`c2.tasks.labelResult`,null,`输出`)}),(0,J.jsx)(`pre`,{className:`c2-pre`,children:a.resultText})]}),a.error&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`c2-field-label`,children:r(`c2.tasks.labelError`,null,`错误`)}),(0,J.jsx)(`pre`,{className:`c2-pre c2-pre-error`,children:a.error})]})]})})]})}var{Text:Z}=d;function ve({session:e,canWrite:t,onEditNote:n}){let r=b(),a=[{label:r(`c2.sessions.infoSessionId`,null,`会话 ID`),value:(0,J.jsx)(Z,{copyable:{text:e.id},className:`c2-mono`,children:e.id})},{label:r(`c2.sessions.infoImplantUuid`,null,`植入体 UUID`),value:(0,J.jsx)(Z,{className:`c2-mono`,children:e.implantUuid||`—`})},{label:r(`c2.sessions.infoHostname`,null,`主机名`),value:e.hostname||`—`},{label:r(`c2.sessions.infoUsername`,null,`用户名`),value:e.username||`—`},{label:r(`c2.sessions.infoProcess`,null,`进程`),value:e.processName||`—`},{label:r(`c2.sessions.infoPid`,null,`PID`),value:e.pid||`—`}],s=[{label:r(`c2.sessions.infoOs`,null,`操作系统`),value:e.os||`—`},{label:r(`c2.sessions.infoArch`,null,`架构`),value:e.arch||`—`},{label:r(`c2.sessions.infoAdmin`,null,`管理员`),value:e.isAdmin?r(`c2.sessions.adminYes`,null,`是`):r(`c2.sessions.adminNo`,null,`否`)},{label:r(`c2.sessions.infoInternalIp`,null,`内网 IP`),value:(0,J.jsx)(`span`,{className:`c2-mono`,children:e.internalIp||`—`})},{label:r(`c2.sessions.ip`,null,`外网 IP`),value:(0,J.jsx)(`span`,{className:`c2-mono`,children:e.externalIp||`—`})},{label:r(`c2.sessions.infoSleep`,null,`Sleep`),value:`${e.sleepSeconds||0}s ± ${e.jitterPercent||0}%`}],c=[{label:r(`c2.sessions.infoFirstSeen`,null,`首次上线`),value:v(e.firstSeenAt)},{label:r(`c2.sessions.infoLastCheckin`,null,`上次心跳`),value:v(e.lastCheckIn)},{label:r(`c2.sessions.status`,null,`状态`),value:e.status||`—`},{label:r(`c2.sessions.listener`,null,`监听器`),value:(0,J.jsx)(`span`,{className:`c2-mono`,children:e.listenerId||`—`})}];return(0,J.jsxs)(`div`,{className:`c2-session-info`,children:[(0,J.jsx)(D,{title:r(`c2.sessions.infoSectionIdentity`,null,`身份信息`),children:(0,J.jsx)(T,{items:a,columns:2})}),(0,J.jsx)(D,{title:r(`c2.sessions.infoSectionSystem`,null,`系统环境`),children:(0,J.jsx)(T,{items:s,columns:2})}),(0,J.jsx)(D,{title:r(`c2.sessions.infoSectionNetwork`,null,`网络与信标`),children:(0,J.jsx)(T,{items:c,columns:2})}),(0,J.jsx)(D,{title:r(`c2.sessions.infoSectionNote`,null,`备注`),extra:(0,J.jsx)(i,{children:(0,J.jsx)(o,{size:`small`,disabled:!t,onClick:n,children:r(`c2.sessions.noteEdit`,null,`编辑`)})}),children:(0,J.jsx)(Z,{type:e.note?void 0:`tertiary`,children:e.note||r(`c2.sessions.infoNoteEmpty`,null,`暂无备注`)})}),e.metadata&&Object.keys(e.metadata).length>0&&(0,J.jsx)(D,{title:r(`c2.sessions.infoMetadata`,null,`原始元数据`),children:(0,J.jsx)(M,{value:e.metadata,collapsed:!0})})]})}var{Text:Q}=d;function ye({session:e,canWrite:t,canDelete:n,onChanged:r,onDeleted:c}){let l=b(),[u,d]=(0,q.useState)(`terminal`),[f,m]=(0,q.useState)(null),[g,v]=(0,q.useState)(null),[y,T]=(0,q.useState)(!1),{data:D,loading:O,error:k,reload:A}=S(()=>z(e.id),[e.id]),j=D?.session||e,M=()=>m({sleepSeconds:String(j.sleepSeconds||5),jitterPercent:String(j.jitterPercent||0)}),F=()=>v({note:j.note||``}),ee=async()=>{let e=Number(f.sleepSeconds),t=Number(f.jitterPercent);if(!Number.isFinite(e)||e<1)x(l(`c2.sessions.toastSleepInvalid`,null,`Sleep 间隔至少为 1 秒`));else if(!Number.isFinite(t)||t<0||t>100)x(l(`c2.sessions.toastSleepInvalid`,null,`抖动百分比需在 0–100 之间`));else{T(!0);try{await te(j.id,{sleepSeconds:e,jitterPercent:t}),N(l(`c2.sessions.toastSleepUpdated`,null,`Sleep 设置已更新`)),m(null),A({silent:!0}),r?.()}catch(e){C(e)}finally{T(!1)}}},I=async()=>{let e=String(g.note||``).trim();if(e.length>2e3)x(l(`c2.sessions.toastNoteTooLong`,null,`备注最多 2000 字`));else{T(!0);try{await W(j.id,e),N(l(`c2.sessions.toastNoteSaved`,null,`备注已保存`)),v(null),A({silent:!0}),r?.()}catch(e){C(e)}finally{T(!1)}}},R=()=>{P({title:l(`c2.sessions.cardDeleteSession`,null,`删除会话`),content:l(`c2.sessions.confirmDeleteSession`,null,`从服务器删除此会话及其关联任务与文件记录?`),onOk:async()=>{try{await L(j.id),N(l(`c2.sessions.toastSessionDeleted`,null,`会话记录已删除`)),c?.()}catch(e){C(e)}}})},B=[{tab:l(`c2.sessions.terminal`,null,`终端`),itemKey:`terminal`,children:(0,J.jsx)(ue,{session:j,canWrite:t,onTaskCreated:A})},{tab:l(`c2.sessions.files`,null,`文件`),itemKey:`files`,children:(0,J.jsx)(ge,{session:j,canWrite:t})},{tab:l(`c2.sessions.tasks`,null,`任务`),itemKey:`tasks`,children:(0,J.jsx)(_e,{session:j,canDelete:n,onChanged:A})},{tab:l(`c2.sessions.info`,null,`信息`),itemKey:`info`,children:(0,J.jsx)(ve,{session:j,canWrite:t,onEditNote:F})}];return(0,J.jsxs)(`div`,{className:`c2-session-detail`,children:[(0,J.jsxs)(`div`,{className:`c2-session-head`,children:[(0,J.jsxs)(`div`,{className:`c2-session-title`,children:[(0,J.jsx)(Q,{strong:!0,className:`c2-session-hostname`,children:j.hostname||l(`c2.sessions.unknownHost`,null,`未知主机`)}),(0,J.jsxs)(i,{spacing:6,wrap:!0,children:[(0,J.jsx)(s,{size:`small`,color:ie[j.status]||`grey`,children:l(`c2.sessions.${j.status||`active`}`,null,j.status||`—`)}),(0,J.jsxs)(s,{size:`small`,children:[j.os||`—`,`/`,j.arch||`—`]}),j.isAdmin&&(0,J.jsx)(s,{size:`small`,color:`red`,children:l(`c2.sessions.rootBadge`,null,`ROOT`)}),(0,J.jsxs)(Q,{type:`tertiary`,size:`small`,children:[j.username||`—`,`@`,j.internalIp||j.externalIp||`—`]}),(0,J.jsxs)(Q,{type:`tertiary`,size:`small`,children:[`sleep `,j.sleepSeconds||0,`s ± `,j.jitterPercent||0,`%`]})]})]}),(0,J.jsxs)(i,{spacing:6,wrap:!0,children:[(0,J.jsx)(o,{size:`small`,icon:(0,J.jsx)(h,{}),loading:O,onClick:()=>A(),children:l(`common.refresh`,null,`刷新`)}),(0,J.jsx)(o,{size:`small`,disabled:!t,onClick:M,children:l(`c2.sessions.btnSleep`,null,`Sleep`)}),(0,J.jsx)(o,{size:`small`,disabled:!t,onClick:F,children:l(`c2.sessions.noteEdit`,null,`备注`)}),(0,J.jsx)(o,{size:`small`,type:`danger`,disabled:!n,onClick:R,children:l(`c2.sessions.cardDeleteSession`,null,`删除会话`)})]})]}),(0,J.jsx)(E,{error:k,onRetry:A}),(0,J.jsx)(p,{type:`button`,activeKey:u,onChange:d,items:B}),(0,J.jsxs)(w,{visible:!!f,title:l(`c2.sessions.sleepModalTitle`,null,`心跳配置`),width:440,onCancel:()=>m(null),onOk:ee,confirmLoading:y,children:[(0,J.jsx)(Q,{type:`tertiary`,size:`small`,children:l(`c2.sessions.sleepModalHint`,null,`保存后将写入服务端并下发 sleep 任务。`)}),(0,J.jsxs)(`div`,{className:`c2-session-modal-field`,children:[(0,J.jsx)(Q,{size:`small`,children:l(`c2.sessions.promptSleepSeconds`,null,`Sleep 间隔(秒)`)}),(0,J.jsx)(a,{value:f?.sleepSeconds||``,onChange:e=>m(t=>({...t,sleepSeconds:e}))})]}),(0,J.jsxs)(`div`,{className:`c2-session-modal-field`,children:[(0,J.jsx)(Q,{size:`small`,children:l(`c2.sessions.promptJitterPercent`,null,`抖动百分比(0–100)`)}),(0,J.jsx)(a,{value:f?.jitterPercent||``,onChange:e=>m(t=>({...t,jitterPercent:e}))})]})]}),(0,J.jsx)(w,{visible:!!g,title:l(`c2.sessions.infoNote`,null,`备注`),width:480,onCancel:()=>v(null),onOk:I,confirmLoading:y,children:(0,J.jsx)(_,{value:g?.note||``,onChange:e=>v(t=>({...t,note:e})),placeholder:l(`c2.sessions.notePlaceholder`,null,`添加备注,便于识别该会话…`),autosize:{minRows:4,maxRows:10}})})]})}var{Text:$}=d;function be(){let e=b(),{hasPermission:t}=y(),n=t(`c2:write`),i=t(`c2:delete`)||n,[d,f]=r(),p=d.get(`id`)||``,[_,v]=(0,q.useState)(``),[x,w]=(0,q.useState)(``),[T,D]=(0,q.useState)(!1),[j,M]=(0,q.useState)(``),[F,te]=(0,q.useState)(!0),I=O(j,300),L=(0,q.useMemo)(()=>({status:_||void 0,listener_id:x||void 0,search:I||void 0,suspicious:T?`1`:void 0,limit:200}),[_,x,I,T]),{data:z,loading:B,error:ne,reload:V}=S(()=>Promise.all([ee(L),re().catch(()=>({listeners:[]}))]),[L]),H=Array.isArray(z?.[0]?.sessions)?z[0].sessions:[],U=Array.isArray(z?.[1]?.listeners)?z[1].listeners:[];A(()=>{F&&V({silent:!0})},F?1e4:0);let W=(0,q.useMemo)(()=>H.find(e=>e.id===p)||null,[H,p]),G=e=>{let t=new URLSearchParams(d);e?t.set(`id`,e):t.delete(`id`),f(t,{replace:!0})};return(0,J.jsxs)(`div`,{className:`c2-page`,id:`page-c2-sessions`,children:[(0,J.jsx)(k,{title:e(`c2.sessions.title`,null,`会话管理`),description:e(`c2.sessions.pageDesc`,null,`查看上线会话,下发命令、浏览文件并管理任务历史`),extra:[(0,J.jsx)(o,{icon:(0,J.jsx)(h,{}),onClick:V,loading:B,children:e(`common.refresh`,null,`刷新`)},`refresh`),(0,J.jsx)(o,{type:`danger`,disabled:!i||!H.length,onClick:()=>{H.length?P({title:e(`c2.sessions.deleteFiltered`,null,`删除筛选结果`),content:e(`c2.sessions.confirmDeleteFiltered`,null,`确定删除当前筛选结果中的全部会话?`).replace(`{{n}}`,String(H.length)),onOk:async()=>{try{let t=await R(H.map(e=>e.id));N(e(`c2.sessions.toastBatchDeleted`,null,`已删除 {{n}} 个会话`).replace(`{{n}}`,String(t?.deleted??H.length))),G(``),V()}catch(e){C(e)}}}):C(e(`c2.sessions.toastSelectFirst`,null,`没有可删除的会话`))},children:e(`c2.sessions.deleteFiltered`,null,`删除筛选结果`)},`delete`)]}),(0,J.jsx)(E,{error:ne,onRetry:V}),(0,J.jsxs)(`div`,{className:`c2-session-layout`,children:[(0,J.jsxs)(`aside`,{className:`c2-session-sidebar`,children:[(0,J.jsxs)(`div`,{className:`c2-session-filters`,children:[(0,J.jsx)(g,{size:`small`,value:_,onChange:e=>v(e||``),style:{width:`100%`},optionList:[{value:``,label:e(`c2.sessions.filterAllStatus`,null,`全部状态`)},...ae]}),(0,J.jsx)(g,{size:`small`,value:x,onChange:e=>w(e||``),style:{width:`100%`},optionList:[{value:``,label:e(`c2.sessions.filterAllListeners`,null,`全部监听器`)},...U.map(e=>({value:e.id,label:e.name||e.id}))]}),(0,J.jsx)(a,{size:`small`,value:j,onChange:M,prefix:(0,J.jsx)(m,{}),placeholder:e(`c2.sessions.filterSearchPlaceholder`,null,`搜索主机名 / 用户 / IP`)}),(0,J.jsxs)(`div`,{className:`c2-session-filter-foot`,children:[(0,J.jsx)(c,{checked:T,onChange:e=>D(!!e.target.checked),children:(0,J.jsx)($,{size:`small`,children:e(`c2.sessions.filterSuspicious`,null,`疑似误报`)})}),(0,J.jsx)(c,{checked:F,onChange:e=>te(!!e.target.checked),children:(0,J.jsx)($,{size:`small`,children:e(`c2.sessions.autoRefresh`,null,`自动刷新`)})})]}),(0,J.jsx)($,{type:`tertiary`,size:`small`,children:e(`c2.sessions.listCount`,null,`共 {{n}} 条`).replace(`{{n}}`,String(H.length))})]}),(0,J.jsxs)(`div`,{className:`c2-session-list`,children:[B&&!H.length&&(0,J.jsx)(`div`,{className:`c2-session-loading`,children:(0,J.jsx)(u,{})}),!B&&H.length===0&&(0,J.jsx)(l,{title:j||_||x?e(`c2.sessions.emptyFilter`,null,`没有符合筛选条件的会话`):e(`c2.sessions.listEmpty`,null,`暂无会话`),description:null,style:{padding:24}}),H.map(t=>(0,J.jsxs)(`button`,{type:`button`,className:`c2-session-item ${t.id===p?`is-active`:``}`,onClick:()=>G(t.id),children:[(0,J.jsxs)(`div`,{className:`c2-session-item-head`,children:[(0,J.jsx)(`span`,{className:`c2-session-host`,children:t.hostname||e(`c2.sessions.unknownHost`,null,`未知`)}),(0,J.jsx)(s,{size:`small`,color:ie[t.status]||`grey`,children:e(`c2.sessions.${t.status||`active`}`,null,t.status||`—`)})]}),(0,J.jsxs)(`div`,{className:`c2-session-item-meta`,children:[(0,J.jsx)(`span`,{children:t.username||`—`}),(0,J.jsxs)(`span`,{children:[t.os||`—`,`/`,t.arch||`—`]}),t.isAdmin&&(0,J.jsx)(s,{size:`small`,color:`red`,children:`ROOT`})]}),(0,J.jsxs)(`div`,{className:`c2-session-item-foot`,children:[(0,J.jsx)(`span`,{className:`c2-mono`,children:t.internalIp||t.externalIp||`—`}),(0,J.jsx)(oe,{value:t.lastCheckIn})]})]},t.id))]})]}),(0,J.jsx)(`section`,{className:`c2-session-main`,children:W?(0,J.jsx)(ye,{session:W,canWrite:n,canDelete:i,onChanged:V,onDeleted:()=>{G(``),V()}},W.id):(0,J.jsx)(l,{title:e(`c2.sessions.selectPromptTitle`,null,`选择会话`),description:e(`c2.sessions.selectPromptHint`,null,`在左侧列表中点击一个会话,查看终端、文件与任务详情。`),style:{padding:64}})})]})]})}export{be as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,N as c,T as l,U as u,W as d,at as f,c as p,ot as m,st as h,v as g,x as _}from"./semi-Dpcldp_F.js";import{E as v,F as y,P as b,S as x,a as S,b as C,c as w,d as T,l as E,m as D,n as O,p as k,r as A,s as j,u as M,x as N,y as P}from"./index-BMTtTYg1.js";import{C as F,S as ee,T as te,_ as I,d as L,f as R,g as z,h as B,o as ne,p as V,r as H,s as U,w as W,y as re}from"./c2-shared-CweYFEMs.js";import{c as ie,h as G,l as ae,m as oe,u as K}from"./c2-shared-CGoxRI15.js";var q=e(t(),1),J=e(n(),1),se=0,ce=()=>(se+=1,se),le=e=>new Promise(t=>setTimeout(t,e));function ue({session:e,canWrite:t,onTaskCreated:n}){let r=b(),[c,l]=(0,q.useState)([]),[u,d]=(0,q.useState)(``),[p,m]=(0,q.useState)(!1),[h,g]=(0,q.useState)(``),_=(0,q.useRef)(!0),v=(0,q.useRef)(null);(0,q.useEffect)(()=>()=>{_.current=!1},[]),(0,q.useEffect)(()=>{let e=v.current;e&&(e.scrollTop=e.scrollHeight)},[c]);let y=(0,q.useCallback)(e=>{l(t=>[...t,{id:ce(),...e}])},[]),S=async e=>{let t=600;for(let n=0;n<40;n+=1){if(!_.current)return null;let n=(await I(e))?.task;if(!n)return null;if([`success`,`failed`,`cancelled`].includes(n.status))return n;await le(t),t=Math.min(Math.round(t*1.4),4e3)}return null},w=async i=>{let a=String(i??u).trim();if(a){if(!t)x(r(`c2.sessions.writeRequired`,null,`当前账号没有下发任务的权限`));else{d(``),y({kind:`cmd`,text:a}),m(!0);try{let t=(await ne(e.id,{task_type:`shell`,payload:{command:a,timeout_seconds:60}}))?.task?.id;if(!t){y({kind:`err`,text:r(`c2.sessions.termNoSession`,null,`下发失败:未返回任务 ID`)});return}g(t),n?.();let i=await S(t);if(!i){y({kind:`warn`,text:r(`c2.sessions.termWaitTimeout`,null,`[等待结果超时]`)});return}i.resultText&&y({kind:i.status===`success`?`out`:`warn`,text:i.resultText}),i.error&&y({kind:`err`,text:i.error}),i.status===`cancelled`&&y({kind:`warn`,text:r(`c2.tasks.cancelled`,null,`已取消`)})}catch(e){y({kind:`err`,text:e?.message||r(`c2.sessions.termStatusErr`,null,`执行失败`)}),C(e)}finally{_.current&&(m(!1),g(``))}}}};return(0,J.jsxs)(`div`,{className:`c2-terminal`,children:[(0,J.jsx)(`div`,{className:`c2-terminal-bar`,children:(0,J.jsxs)(i,{spacing:8,children:[(0,J.jsx)(s,{size:`small`,color:p?`amber`:`green`,children:p?r(`c2.sessions.termStatusExec`,null,`执行中…`):r(`c2.sessions.termStatusReady`,null,`就绪`)}),(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>l([]),children:r(`c2.sessions.clearTerminal`,null,`清屏`)}),p&&h&&(0,J.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,onClick:async()=>{if(h)try{await H(h),y({kind:`warn`,text:r(`c2.tasks.toastCancelled`,null,`任务已取消`)})}catch(e){C(e)}},children:r(`c2.tasks.cancelBtn`,null,`取消`)})]})}),(0,J.jsxs)(`div`,{className:`c2-terminal-log`,ref:v,children:[(0,J.jsx)(`div`,{className:`c2-terminal-welcome`,children:r(`c2.sessions.terminalWelcome`,null,`C2 终端 — 回车执行;命令以 shell 任务下发并等待结果`)}),c.map(e=>(0,J.jsx)(`pre`,{className:`c2-terminal-line kind-${e.kind}`,children:e.kind===`cmd`?`$ ${e.text}`:e.text},e.id))]}),(0,J.jsxs)(`div`,{className:`c2-terminal-input`,children:[(0,J.jsx)(a,{value:u,onChange:d,onEnterPress:()=>p?x(r(`c2.sessions.termWaitFinish`,null,`请等待当前命令执行完成`)):w(),placeholder:r(`c2.sessions.commandPlaceholder`,null,`输入命令后回车下发`),disabled:p||!t,prefix:`$`}),(0,J.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,J.jsx)(f,{}),loading:p,disabled:!t,onClick:()=>w(),children:r(`c2.sessions.execute`,null,`执行命令`)})]})]})}function de(e){let t=String(e||``).split(/\r?\n/),n=[];for(let e of t){let t=e.trim();if(!t||/^total\s+\d+/i.test(t))continue;let r=t.split(` `);if(r.length>=4){let e=r.slice(3).join(` `).trim();if(!e||e===`.`||e===`..`)continue;let t=r[0].trim(),i=r[1].trim();n.push({name:e,size:r[2].trim(),mode:i||t,isDir:t.startsWith(`d`)||i.startsWith(`d`)});continue}let i=t.match(/^\S{1,10}\s+\d+\s+\S+\s+\S+\s+\d+\s+\S+\s+\S+\s+\S+\s+(.+)$/);if(!i)continue;let a=i[1].trim(),o=a.indexOf(` -> `);if(o>0&&(a=a.slice(0,o).trim()),!a||a===`.`||a===`..`)continue;let s=t.split(/\s+/);n.push({name:a,size:s[4]||``,mode:s[0]||``,isDir:(s[0]||``).startsWith(`d`)})}return n}function Y(e){let t=String(e??``).trim();return t?/^[A-Za-z]:/.test(t)?t.replace(/\\+$/,``)||t:(t=t.replace(/\\/g,`/`).replace(/\/{2,}/g,`/`),t.length>1&&(t=t.replace(/\/+$/,``)),t||`.`):`.`}function X(e,t){let n=Y(e);return t?/^[A-Za-z]:/.test(t)||t.startsWith(`/`)||n===`.`||n===``?Y(t):Y(`${n}${n.includes(`\\`)?`\\`:`/`}${t}`):n}function fe(e){let t=Y(e);if(t===`.`||t===`/`||/^[A-Za-z]:$/.test(t))return t;let n=t.includes(`\\`)?`\\`:`/`,r=t.lastIndexOf(n);if(r<0)return`.`;if(r===0)return`/`;let i=t.slice(0,r);return/^[A-Za-z]:$/.test(i)?`${i}${n}`:i}var{Text:pe}=d,me=e=>new Promise(t=>setTimeout(t,e));async function he(e){let t=600;for(let n=0;n<40;n+=1){let n=(await I(e))?.task;if(!n)return null;if([`success`,`failed`,`cancelled`].includes(n.status))return n;await me(t),t=Math.min(Math.round(t*1.4),4e3)}return null}function ge({session:e,canWrite:t}){let n=b(),[r,s]=(0,q.useState)(`.`),[c,l]=(0,q.useState)(`.`),[u,d]=(0,q.useState)([]),[f,p]=(0,q.useState)(``),[m,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(null),[y,S]=(0,q.useState)(``),w=(0,q.useRef)(!0);(0,q.useEffect)(()=>()=>{w.current=!1},[]);let T=(0,q.useCallback)(async t=>{let i=Y(t??r);g(!0),v(null);try{let t=(await U({session_id:e.id,task_type:`ls`,payload:{path:i}}))?.task?.id;if(!t)throw Error(n(`c2.files.failed`,null,`列目录失败`));let r=await he(t);if(!w.current)return;if(!r){v(n(`c2.files.timeout`,null,`加载文件超时`));return}if(r.status!==`success`){v(r.error||n(`c2.files.failed`,null,`列目录失败`)),d([]),p(r.resultText||``);return}p(r.resultText||``),d(de(r.resultText||``)),s(i),l(i)}catch(e){w.current&&v(e)}finally{w.current&&g(!1)}},[e.id,r,n]);(0,q.useEffect)(()=>{s(`.`),l(`.`),d([]),T(`.`)},[e.id]);let D=async i=>{if(!t){x(n(`c2.files.writeRequired`,null,`当前账号没有下发任务的权限`));return}let a=X(r,i.name);try{let t=(await U({session_id:e.id,task_type:`download`,payload:{path:a}}))?.task?.id;if(!t)throw Error(n(`c2.files.failed`,null,`下载失败`));let r=await he(t);if(!r||r.status!==`success`)throw Error(r?.error||n(`c2.files.failed`,null,`下载失败`));await B(r.id,i.name),N(n(`c2.files.downloadOk`,null,`下载成功`))}catch(e){C(e,n(`c2.files.failed`,null,`下载失败`))}},O=u.filter(e=>{let t=y.trim().toLowerCase();return!t||e.name.toLowerCase().includes(t)}),k=[{title:n(`c2.files.colName`,null,`名称`),dataIndex:`name`,render:(e,t)=>(0,J.jsxs)(`button`,{type:`button`,className:`c2-file-name ${t.isDir?`is-dir`:``}`,onClick:()=>t.isDir?T(X(r,e)):D(t),children:[e,t.isDir?`/`:``]})},{title:n(`c2.files.colSize`,null,`大小`),dataIndex:`size`,width:120},{title:n(`c2.files.colMode`,null,`权限`),dataIndex:`mode`,width:160},{title:n(`c2.files.colActions`,null,`操作`),dataIndex:`actions`,width:160,render:(e,i)=>i.isDir?(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>T(X(r,i.name)),children:n(`c2.files.open`,null,`打开`)}):(0,J.jsx)(o,{size:`small`,theme:`borderless`,disabled:!t,onClick:()=>D(i),children:n(`c2.files.download`,null,`下载`)})}];return(0,J.jsxs)(`div`,{className:`c2-files`,children:[(0,J.jsx)(`div`,{className:`c2-files-toolbar`,children:(0,J.jsxs)(i,{spacing:8,wrap:!0,children:[(0,J.jsx)(o,{size:`small`,onClick:()=>T(fe(r)),children:n(`c2.files.parent`,null,`上级目录`)}),(0,J.jsx)(o,{size:`small`,icon:(0,J.jsx)(h,{}),loading:m,onClick:()=>T(r),children:n(`c2.files.refresh`,null,`刷新`)}),(0,J.jsx)(a,{size:`small`,value:c,onChange:l,onEnterPress:()=>T(c),className:`c2-files-path`}),(0,J.jsx)(o,{size:`small`,onClick:()=>T(c),children:n(`c2.files.go`,null,`跳转`)}),(0,J.jsx)(a,{size:`small`,value:y,onChange:S,placeholder:n(`c2.files.filter`,null,`过滤名称`),className:`c2-files-filter`})]})}),(0,J.jsxs)(pe,{type:`tertiary`,size:`small`,children:[n(`c2.files.currentPath`,null,`当前目录`),`:`,r]}),(0,J.jsx)(E,{error:_,onRetry:()=>T(r)}),u.length===0&&f.trim()&&!m?(0,J.jsx)(`pre`,{className:`c2-pre`,children:f}):(0,J.jsx)(j,{columns:k,dataSource:O,rowKey:`name`,loading:m,pagination:{pageSize:20},emptyText:n(`c2.files.emptyDir`,null,`空目录`)})]})}function _e({session:e,canDelete:t,onChanged:n}){let r=b(),[a,c]=(0,q.useState)(null),{data:l,loading:u,error:d,reload:f}=S(()=>F({session_id:e.id,limit:100}),[e.id]),p=Array.isArray(l?.tasks)?l.tasks:[];A(()=>f({silent:!0}),5e3);let m=async e=>{try{await H(e.id),N(r(`c2.tasks.toastCancelled`,null,`任务已取消`)),f({silent:!0}),n?.()}catch(e){C(e)}},h=e=>{P({title:r(`c2.tasks.deleteOne`,null,`删除任务`),content:r(`c2.tasks.confirmDeleteOne`,null,`确定从服务器删除该任务记录吗?此操作不可恢复。`),onOk:async()=>{try{await V([e.id]),N(r(`c2.tasks.toastDeleted`,null,`已删除 {{n}} 条`).replace(`{{n}}`,`1`)),f({silent:!0}),n?.()}catch(e){C(e)}}})},g=[{title:r(`c2.tasks.colType`,null,`类型`),dataIndex:`taskType`,width:120},{title:r(`c2.tasks.colCommand`,null,`命令`),dataIndex:`payload`,render:e=>{let t=e?.command||e?.path||``;return(0,J.jsx)(`span`,{className:`c2-mono`,children:t||`—`})}},{title:r(`c2.tasks.colStatus`,null,`状态`),dataIndex:`status`,width:110,render:e=>(0,J.jsx)(s,{size:`small`,color:K[e]||`grey`,children:r(`c2.tasks.${e||`queued`}`,null,e||`—`)})},{title:r(`c2.tasks.colDuration`,null,`耗时`),dataIndex:`durationMs`,width:100,render:e=>G(e)},{title:r(`c2.tasks.colCreated`,null,`创建时间`),dataIndex:`createdAt`,width:140,render:e=>(0,J.jsx)(oe,{value:e})},{title:r(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:200,render:(e,n)=>(0,J.jsxs)(i,{spacing:4,wrap:!0,children:[(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>c(n),children:r(`c2.tasks.view`,null,`查看`)}),[`queued`,`sent`,`running`].includes(n.status)&&(0,J.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>m(n),children:r(`c2.tasks.cancelBtn`,null,`取消`)}),(0,J.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!t,onClick:()=>h(n),children:r(`c2.tasks.deleteBtn`,null,`删除`)})]})}];return(0,J.jsxs)(`div`,{className:`c2-session-tasks`,children:[(0,J.jsx)(E,{error:d,onRetry:()=>f()}),(0,J.jsx)(j,{columns:g,dataSource:p,rowKey:`id`,loading:u,onRefresh:()=>f(),pagination:{pageSize:10},emptyText:r(`c2.tasks.emptySession`,null,`该会话暂无任务`)}),(0,J.jsx)(w,{visible:!!a,title:r(`c2.tasks.modalTitle`,null,`任务详情`),width:720,onCancel:()=>c(null),footer:(0,J.jsx)(o,{onClick:()=>c(null),children:r(`c2.tasks.close`,null,`关闭`)}),children:a&&(0,J.jsxs)(`div`,{className:`c2-task-detail`,children:[(0,J.jsxs)(`div`,{className:`c2-task-detail-meta`,children:[(0,J.jsx)(`span`,{className:`c2-mono`,children:a.id}),(0,J.jsx)(s,{size:`small`,color:K[a.status]||`grey`,children:a.status}),(0,J.jsx)(`span`,{className:`c2-muted`,children:v(a.createdAt)})]}),a.payload&&(0,J.jsx)(M,{title:r(`c2.tasks.labelPayload`,null,`参数`),value:a.payload,collapsed:!0}),a.resultText&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`c2-field-label`,children:r(`c2.tasks.labelResult`,null,`输出`)}),(0,J.jsx)(`pre`,{className:`c2-pre`,children:a.resultText})]}),a.error&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`c2-field-label`,children:r(`c2.tasks.labelError`,null,`错误`)}),(0,J.jsx)(`pre`,{className:`c2-pre c2-pre-error`,children:a.error})]})]})})]})}var{Text:Z}=d;function ve({session:e,canWrite:t,onEditNote:n}){let r=b(),a=[{label:r(`c2.sessions.infoSessionId`,null,`会话 ID`),value:(0,J.jsx)(Z,{copyable:{text:e.id},className:`c2-mono`,children:e.id})},{label:r(`c2.sessions.infoImplantUuid`,null,`植入体 UUID`),value:(0,J.jsx)(Z,{className:`c2-mono`,children:e.implantUuid||`—`})},{label:r(`c2.sessions.infoHostname`,null,`主机名`),value:e.hostname||`—`},{label:r(`c2.sessions.infoUsername`,null,`用户名`),value:e.username||`—`},{label:r(`c2.sessions.infoProcess`,null,`进程`),value:e.processName||`—`},{label:r(`c2.sessions.infoPid`,null,`PID`),value:e.pid||`—`}],s=[{label:r(`c2.sessions.infoOs`,null,`操作系统`),value:e.os||`—`},{label:r(`c2.sessions.infoArch`,null,`架构`),value:e.arch||`—`},{label:r(`c2.sessions.infoAdmin`,null,`管理员`),value:e.isAdmin?r(`c2.sessions.adminYes`,null,`是`):r(`c2.sessions.adminNo`,null,`否`)},{label:r(`c2.sessions.infoInternalIp`,null,`内网 IP`),value:(0,J.jsx)(`span`,{className:`c2-mono`,children:e.internalIp||`—`})},{label:r(`c2.sessions.ip`,null,`外网 IP`),value:(0,J.jsx)(`span`,{className:`c2-mono`,children:e.externalIp||`—`})},{label:r(`c2.sessions.infoSleep`,null,`Sleep`),value:`${e.sleepSeconds||0}s ± ${e.jitterPercent||0}%`}],c=[{label:r(`c2.sessions.infoFirstSeen`,null,`首次上线`),value:v(e.firstSeenAt)},{label:r(`c2.sessions.infoLastCheckin`,null,`上次心跳`),value:v(e.lastCheckIn)},{label:r(`c2.sessions.status`,null,`状态`),value:e.status||`—`},{label:r(`c2.sessions.listener`,null,`监听器`),value:(0,J.jsx)(`span`,{className:`c2-mono`,children:e.listenerId||`—`})}];return(0,J.jsxs)(`div`,{className:`c2-session-info`,children:[(0,J.jsx)(D,{title:r(`c2.sessions.infoSectionIdentity`,null,`身份信息`),children:(0,J.jsx)(T,{items:a,columns:2})}),(0,J.jsx)(D,{title:r(`c2.sessions.infoSectionSystem`,null,`系统环境`),children:(0,J.jsx)(T,{items:s,columns:2})}),(0,J.jsx)(D,{title:r(`c2.sessions.infoSectionNetwork`,null,`网络与信标`),children:(0,J.jsx)(T,{items:c,columns:2})}),(0,J.jsx)(D,{title:r(`c2.sessions.infoSectionNote`,null,`备注`),extra:(0,J.jsx)(i,{children:(0,J.jsx)(o,{size:`small`,disabled:!t,onClick:n,children:r(`c2.sessions.noteEdit`,null,`编辑`)})}),children:(0,J.jsx)(Z,{type:e.note?void 0:`tertiary`,children:e.note||r(`c2.sessions.infoNoteEmpty`,null,`暂无备注`)})}),e.metadata&&Object.keys(e.metadata).length>0&&(0,J.jsx)(D,{title:r(`c2.sessions.infoMetadata`,null,`原始元数据`),children:(0,J.jsx)(M,{value:e.metadata,collapsed:!0})})]})}var{Text:Q}=d;function ye({session:e,canWrite:t,canDelete:n,onChanged:r,onDeleted:c}){let l=b(),[u,d]=(0,q.useState)(`terminal`),[f,m]=(0,q.useState)(null),[g,v]=(0,q.useState)(null),[y,T]=(0,q.useState)(!1),{data:D,loading:O,error:k,reload:A}=S(()=>z(e.id),[e.id]),j=D?.session||e,M=()=>m({sleepSeconds:String(j.sleepSeconds||5),jitterPercent:String(j.jitterPercent||0)}),F=()=>v({note:j.note||``}),ee=async()=>{let e=Number(f.sleepSeconds),t=Number(f.jitterPercent);if(!Number.isFinite(e)||e<1)x(l(`c2.sessions.toastSleepInvalid`,null,`Sleep 间隔至少为 1 秒`));else if(!Number.isFinite(t)||t<0||t>100)x(l(`c2.sessions.toastSleepInvalid`,null,`抖动百分比需在 0–100 之间`));else{T(!0);try{await te(j.id,{sleepSeconds:e,jitterPercent:t}),N(l(`c2.sessions.toastSleepUpdated`,null,`Sleep 设置已更新`)),m(null),A({silent:!0}),r?.()}catch(e){C(e)}finally{T(!1)}}},I=async()=>{let e=String(g.note||``).trim();if(e.length>2e3)x(l(`c2.sessions.toastNoteTooLong`,null,`备注最多 2000 字`));else{T(!0);try{await W(j.id,e),N(l(`c2.sessions.toastNoteSaved`,null,`备注已保存`)),v(null),A({silent:!0}),r?.()}catch(e){C(e)}finally{T(!1)}}},R=()=>{P({title:l(`c2.sessions.cardDeleteSession`,null,`删除会话`),content:l(`c2.sessions.confirmDeleteSession`,null,`从服务器删除此会话及其关联任务与文件记录?`),onOk:async()=>{try{await L(j.id),N(l(`c2.sessions.toastSessionDeleted`,null,`会话记录已删除`)),c?.()}catch(e){C(e)}}})},B=[{tab:l(`c2.sessions.terminal`,null,`终端`),itemKey:`terminal`,children:(0,J.jsx)(ue,{session:j,canWrite:t,onTaskCreated:A})},{tab:l(`c2.sessions.files`,null,`文件`),itemKey:`files`,children:(0,J.jsx)(ge,{session:j,canWrite:t})},{tab:l(`c2.sessions.tasks`,null,`任务`),itemKey:`tasks`,children:(0,J.jsx)(_e,{session:j,canDelete:n,onChanged:A})},{tab:l(`c2.sessions.info`,null,`信息`),itemKey:`info`,children:(0,J.jsx)(ve,{session:j,canWrite:t,onEditNote:F})}];return(0,J.jsxs)(`div`,{className:`c2-session-detail`,children:[(0,J.jsxs)(`div`,{className:`c2-session-head`,children:[(0,J.jsxs)(`div`,{className:`c2-session-title`,children:[(0,J.jsx)(Q,{strong:!0,className:`c2-session-hostname`,children:j.hostname||l(`c2.sessions.unknownHost`,null,`未知主机`)}),(0,J.jsxs)(i,{spacing:6,wrap:!0,children:[(0,J.jsx)(s,{size:`small`,color:ie[j.status]||`grey`,children:l(`c2.sessions.${j.status||`active`}`,null,j.status||`—`)}),(0,J.jsxs)(s,{size:`small`,children:[j.os||`—`,`/`,j.arch||`—`]}),j.isAdmin&&(0,J.jsx)(s,{size:`small`,color:`red`,children:l(`c2.sessions.rootBadge`,null,`ROOT`)}),(0,J.jsxs)(Q,{type:`tertiary`,size:`small`,children:[j.username||`—`,`@`,j.internalIp||j.externalIp||`—`]}),(0,J.jsxs)(Q,{type:`tertiary`,size:`small`,children:[`sleep `,j.sleepSeconds||0,`s ± `,j.jitterPercent||0,`%`]})]})]}),(0,J.jsxs)(i,{spacing:6,wrap:!0,children:[(0,J.jsx)(o,{size:`small`,icon:(0,J.jsx)(h,{}),loading:O,onClick:()=>A(),children:l(`common.refresh`,null,`刷新`)}),(0,J.jsx)(o,{size:`small`,disabled:!t,onClick:M,children:l(`c2.sessions.btnSleep`,null,`Sleep`)}),(0,J.jsx)(o,{size:`small`,disabled:!t,onClick:F,children:l(`c2.sessions.noteEdit`,null,`备注`)}),(0,J.jsx)(o,{size:`small`,type:`danger`,disabled:!n,onClick:R,children:l(`c2.sessions.cardDeleteSession`,null,`删除会话`)})]})]}),(0,J.jsx)(E,{error:k,onRetry:A}),(0,J.jsx)(p,{type:`button`,activeKey:u,onChange:d,items:B}),(0,J.jsxs)(w,{visible:!!f,title:l(`c2.sessions.sleepModalTitle`,null,`心跳配置`),width:440,onCancel:()=>m(null),onOk:ee,confirmLoading:y,children:[(0,J.jsx)(Q,{type:`tertiary`,size:`small`,children:l(`c2.sessions.sleepModalHint`,null,`保存后将写入服务端并下发 sleep 任务。`)}),(0,J.jsxs)(`div`,{className:`c2-session-modal-field`,children:[(0,J.jsx)(Q,{size:`small`,children:l(`c2.sessions.promptSleepSeconds`,null,`Sleep 间隔(秒)`)}),(0,J.jsx)(a,{value:f?.sleepSeconds||``,onChange:e=>m(t=>({...t,sleepSeconds:e}))})]}),(0,J.jsxs)(`div`,{className:`c2-session-modal-field`,children:[(0,J.jsx)(Q,{size:`small`,children:l(`c2.sessions.promptJitterPercent`,null,`抖动百分比(0–100)`)}),(0,J.jsx)(a,{value:f?.jitterPercent||``,onChange:e=>m(t=>({...t,jitterPercent:e}))})]})]}),(0,J.jsx)(w,{visible:!!g,title:l(`c2.sessions.infoNote`,null,`备注`),width:480,onCancel:()=>v(null),onOk:I,confirmLoading:y,children:(0,J.jsx)(_,{value:g?.note||``,onChange:e=>v(t=>({...t,note:e})),placeholder:l(`c2.sessions.notePlaceholder`,null,`添加备注,便于识别该会话…`),autosize:{minRows:4,maxRows:10}})})]})}var{Text:$}=d;function be(){let e=b(),{hasPermission:t}=y(),n=t(`c2:write`),i=t(`c2:delete`)||n,[d,f]=r(),p=d.get(`id`)||``,[_,v]=(0,q.useState)(``),[x,w]=(0,q.useState)(``),[T,D]=(0,q.useState)(!1),[j,M]=(0,q.useState)(``),[F,te]=(0,q.useState)(!0),I=O(j,300),L=(0,q.useMemo)(()=>({status:_||void 0,listener_id:x||void 0,search:I||void 0,suspicious:T?`1`:void 0,limit:200}),[_,x,I,T]),{data:z,loading:B,error:ne,reload:V}=S(()=>Promise.all([ee(L),re().catch(()=>({listeners:[]}))]),[L]),H=Array.isArray(z?.[0]?.sessions)?z[0].sessions:[],U=Array.isArray(z?.[1]?.listeners)?z[1].listeners:[];A(()=>{F&&V({silent:!0})},F?1e4:0);let W=(0,q.useMemo)(()=>H.find(e=>e.id===p)||null,[H,p]),G=e=>{let t=new URLSearchParams(d);e?t.set(`id`,e):t.delete(`id`),f(t,{replace:!0})};return(0,J.jsxs)(`div`,{className:`c2-page`,id:`page-c2-sessions`,children:[(0,J.jsx)(k,{title:e(`c2.sessions.title`,null,`会话管理`),description:e(`c2.sessions.pageDesc`,null,`查看上线会话,下发命令、浏览文件并管理任务历史`),extra:[(0,J.jsx)(o,{icon:(0,J.jsx)(h,{}),onClick:V,loading:B,children:e(`common.refresh`,null,`刷新`)},`refresh`),(0,J.jsx)(o,{type:`danger`,disabled:!i||!H.length,onClick:()=>{H.length?P({title:e(`c2.sessions.deleteFiltered`,null,`删除筛选结果`),content:e(`c2.sessions.confirmDeleteFiltered`,null,`确定删除当前筛选结果中的全部会话?`).replace(`{{n}}`,String(H.length)),onOk:async()=>{try{let t=await R(H.map(e=>e.id));N(e(`c2.sessions.toastBatchDeleted`,null,`已删除 {{n}} 个会话`).replace(`{{n}}`,String(t?.deleted??H.length))),G(``),V()}catch(e){C(e)}}}):C(e(`c2.sessions.toastSelectFirst`,null,`没有可删除的会话`))},children:e(`c2.sessions.deleteFiltered`,null,`删除筛选结果`)},`delete`)]}),(0,J.jsx)(E,{error:ne,onRetry:V}),(0,J.jsxs)(`div`,{className:`c2-session-layout`,children:[(0,J.jsxs)(`aside`,{className:`c2-session-sidebar`,children:[(0,J.jsxs)(`div`,{className:`c2-session-filters`,children:[(0,J.jsx)(g,{size:`small`,value:_,onChange:e=>v(e||``),style:{width:`100%`},optionList:[{value:``,label:e(`c2.sessions.filterAllStatus`,null,`全部状态`)},...ae]}),(0,J.jsx)(g,{size:`small`,value:x,onChange:e=>w(e||``),style:{width:`100%`},optionList:[{value:``,label:e(`c2.sessions.filterAllListeners`,null,`全部监听器`)},...U.map(e=>({value:e.id,label:e.name||e.id}))]}),(0,J.jsx)(a,{size:`small`,value:j,onChange:M,prefix:(0,J.jsx)(m,{}),placeholder:e(`c2.sessions.filterSearchPlaceholder`,null,`搜索主机名 / 用户 / IP`)}),(0,J.jsxs)(`div`,{className:`c2-session-filter-foot`,children:[(0,J.jsx)(c,{checked:T,onChange:e=>D(!!e.target.checked),children:(0,J.jsx)($,{size:`small`,children:e(`c2.sessions.filterSuspicious`,null,`疑似误报`)})}),(0,J.jsx)(c,{checked:F,onChange:e=>te(!!e.target.checked),children:(0,J.jsx)($,{size:`small`,children:e(`c2.sessions.autoRefresh`,null,`自动刷新`)})})]}),(0,J.jsx)($,{type:`tertiary`,size:`small`,children:e(`c2.sessions.listCount`,null,`共 {{n}} 条`).replace(`{{n}}`,String(H.length))})]}),(0,J.jsxs)(`div`,{className:`c2-session-list`,children:[B&&!H.length&&(0,J.jsx)(`div`,{className:`c2-session-loading`,children:(0,J.jsx)(u,{})}),!B&&H.length===0&&(0,J.jsx)(l,{title:j||_||x?e(`c2.sessions.emptyFilter`,null,`没有符合筛选条件的会话`):e(`c2.sessions.listEmpty`,null,`暂无会话`),description:null,style:{padding:24}}),H.map(t=>(0,J.jsxs)(`button`,{type:`button`,className:`c2-session-item ${t.id===p?`is-active`:``}`,onClick:()=>G(t.id),children:[(0,J.jsxs)(`div`,{className:`c2-session-item-head`,children:[(0,J.jsx)(`span`,{className:`c2-session-host`,children:t.hostname||e(`c2.sessions.unknownHost`,null,`未知`)}),(0,J.jsx)(s,{size:`small`,color:ie[t.status]||`grey`,children:e(`c2.sessions.${t.status||`active`}`,null,t.status||`—`)})]}),(0,J.jsxs)(`div`,{className:`c2-session-item-meta`,children:[(0,J.jsx)(`span`,{children:t.username||`—`}),(0,J.jsxs)(`span`,{children:[t.os||`—`,`/`,t.arch||`—`]}),t.isAdmin&&(0,J.jsx)(s,{size:`small`,color:`red`,children:`ROOT`})]}),(0,J.jsxs)(`div`,{className:`c2-session-item-foot`,children:[(0,J.jsx)(`span`,{className:`c2-mono`,children:t.internalIp||t.externalIp||`—`}),(0,J.jsx)(oe,{value:t.lastCheckIn})]})]},t.id))]})]}),(0,J.jsx)(`section`,{className:`c2-session-main`,children:W?(0,J.jsx)(ye,{session:W,canWrite:n,canDelete:i,onChanged:V,onDeleted:()=>{G(``),V()}},W.id):(0,J.jsx)(l,{title:e(`c2.sessions.selectPromptTitle`,null,`选择会话`),description:e(`c2.sessions.selectPromptHint`,null,`在左侧列表中点击一个会话,查看终端、文件与任务详情。`),style:{padding:64}})})]})]})}export{be as default};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-shared-C42gWRB4.js b/web/static/app/assets/c2-shared-CGoxRI15.js
similarity index 98%
rename from web/static/app/assets/c2-shared-C42gWRB4.js
rename to web/static/app/assets/c2-shared-CGoxRI15.js
index bb77d0c8..d0e5918f 100644
--- a/web/static/app/assets/c2-shared-C42gWRB4.js
+++ b/web/static/app/assets/c2-shared-CGoxRI15.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{F as t,L as n,W as r}from"./semi-Dpcldp_F.js";import{E as i,P as a,k as o}from"./index-gBcdNgHq.js";import"./c2-shared-BxfKXbIb.js";import{t as s}from"./react-QV7DAAIx.js";var c=e(s(),1),{Text:l}=r,u=[{value:`http_beacon`,label:`HTTP Beacon`},{value:`https_beacon`,label:`HTTPS Beacon`},{value:`tcp_reverse`,label:`TCP 反向`},{value:`websocket`,label:`WebSocket`}],d={running:`运行中`,stopped:`已停止`,error:`异常`},f={tcp_reverse:[{value:`bash`,label:`Bash (/dev/tcp)`},{value:`nc`,label:`Netcat (-e)`},{value:`nc_mkfifo`,label:`Netcat (mkfifo)`},{value:`python`,label:`Python`},{value:`perl`,label:`Perl`},{value:`powershell`,label:`PowerShell`}],http_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],https_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],websocket:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}]},p=[{value:`shell`,label:`shell`},{value:`exec`,label:`exec`},{value:`ls`,label:`ls`},{value:`pwd`,label:`pwd`},{value:`cd`,label:`cd`},{value:`ps`,label:`ps`},{value:`kill_proc`,label:`kill_proc`},{value:`download`,label:`download`},{value:`upload`,label:`upload`},{value:`screenshot`,label:`screenshot`},{value:`sleep`,label:`sleep`},{value:`exit`,label:`exit`},{value:`self_delete`,label:`self_delete`},{value:`port_fwd`,label:`port_fwd`},{value:`socks_start`,label:`socks_start`},{value:`socks_stop`,label:`socks_stop`},{value:`load_assembly`,label:`load_assembly`},{value:`persist`,label:`persist`}],m=[{value:`queued`,label:`队列中`},{value:`sent`,label:`已发送`},{value:`running`,label:`执行中`},{value:`success`,label:`成功`},{value:`failed`,label:`失败`},{value:`cancelled`,label:`已取消`}],h=[{value:`info`,label:`信息`},{value:`warn`,label:`警告`},{value:`critical`,label:`严重`}],g=[{value:`listener`,label:`监听器`},{value:`session`,label:`会话`},{value:`task`,label:`任务`},{value:`payload`,label:`Payload`},{value:`opsec`,label:`OPSEC`}],_=[{value:`active`,label:`活跃`},{value:`sleeping`,label:`休眠`},{value:`dead`,label:`离线`},{value:`killed`,label:`已终止`}],v=[{value:`15m`,label:`最近15分钟`,ms:9e5},{value:`1h`,label:`最近1小时`,ms:36e5},{value:`24h`,label:`最近24小时`,ms:864e5},{value:`7d`,label:`最近7天`,ms:6048e5},{value:`all`,label:`全部`,ms:0}];function y(e){let t=v.find(t=>t.value===e);return!t||!t.ms?``:new Date(Date.now()-t.ms).toISOString()}function b({value:e,onChange:r,ns:i=`tasks`}){let o=a();return(0,c.jsxs)(t,{spacing:6,wrap:!0,className:`c2-time-presets`,children:[(0,c.jsx)(l,{type:`tertiary`,size:`small`,children:o(`c2.tasks.timePresets`,null,`快捷`)}),v.map(t=>(0,c.jsx)(n,{size:`small`,theme:t.value===e?`solid`:`borderless`,type:t.value===e?`primary`:`tertiary`,onClick:()=>r(t.value),children:o(`c2.${i}.preset${t.value===`all`?`All`:t.value}`,null,t.label)},t.value))]})}function x(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`—`:t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}秒`:`${Math.round(t/6e4)}分钟`}function S({value:e}){let t=a();return e?(0,c.jsx)(`span`,{className:`c2-time-text`,title:i(e),children:o(e,t)}):(0,c.jsx)(l,{type:`tertiary`,children:`—`})}var C={running:`green`,stopped:`grey`,error:`red`},w={queued:`amber`,sent:`blue`,running:`blue`,success:`green`,failed:`red`,cancelled:`grey`},T={active:`green`,sleeping:`amber`,dead:`grey`,killed:`red`},E={info:`blue`,warn:`amber`,critical:`red`};export{d as a,T as c,m as d,p as f,y as g,x as h,C as i,_ as l,S as m,E as n,u as o,b as p,h as r,f as s,g as t,w as u};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{F as t,L as n,W as r}from"./semi-Dpcldp_F.js";import{E as i,P as a,k as o}from"./index-BMTtTYg1.js";import"./c2-shared-CweYFEMs.js";import{t as s}from"./react-QV7DAAIx.js";var c=e(s(),1),{Text:l}=r,u=[{value:`http_beacon`,label:`HTTP Beacon`},{value:`https_beacon`,label:`HTTPS Beacon`},{value:`tcp_reverse`,label:`TCP 反向`},{value:`websocket`,label:`WebSocket`}],d={running:`运行中`,stopped:`已停止`,error:`异常`},f={tcp_reverse:[{value:`bash`,label:`Bash (/dev/tcp)`},{value:`nc`,label:`Netcat (-e)`},{value:`nc_mkfifo`,label:`Netcat (mkfifo)`},{value:`python`,label:`Python`},{value:`perl`,label:`Perl`},{value:`powershell`,label:`PowerShell`}],http_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],https_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],websocket:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}]},p=[{value:`shell`,label:`shell`},{value:`exec`,label:`exec`},{value:`ls`,label:`ls`},{value:`pwd`,label:`pwd`},{value:`cd`,label:`cd`},{value:`ps`,label:`ps`},{value:`kill_proc`,label:`kill_proc`},{value:`download`,label:`download`},{value:`upload`,label:`upload`},{value:`screenshot`,label:`screenshot`},{value:`sleep`,label:`sleep`},{value:`exit`,label:`exit`},{value:`self_delete`,label:`self_delete`},{value:`port_fwd`,label:`port_fwd`},{value:`socks_start`,label:`socks_start`},{value:`socks_stop`,label:`socks_stop`},{value:`load_assembly`,label:`load_assembly`},{value:`persist`,label:`persist`}],m=[{value:`queued`,label:`队列中`},{value:`sent`,label:`已发送`},{value:`running`,label:`执行中`},{value:`success`,label:`成功`},{value:`failed`,label:`失败`},{value:`cancelled`,label:`已取消`}],h=[{value:`info`,label:`信息`},{value:`warn`,label:`警告`},{value:`critical`,label:`严重`}],g=[{value:`listener`,label:`监听器`},{value:`session`,label:`会话`},{value:`task`,label:`任务`},{value:`payload`,label:`Payload`},{value:`opsec`,label:`OPSEC`}],_=[{value:`active`,label:`活跃`},{value:`sleeping`,label:`休眠`},{value:`dead`,label:`离线`},{value:`killed`,label:`已终止`}],v=[{value:`15m`,label:`最近15分钟`,ms:9e5},{value:`1h`,label:`最近1小时`,ms:36e5},{value:`24h`,label:`最近24小时`,ms:864e5},{value:`7d`,label:`最近7天`,ms:6048e5},{value:`all`,label:`全部`,ms:0}];function y(e){let t=v.find(t=>t.value===e);return!t||!t.ms?``:new Date(Date.now()-t.ms).toISOString()}function b({value:e,onChange:r,ns:i=`tasks`}){let o=a();return(0,c.jsxs)(t,{spacing:6,wrap:!0,className:`c2-time-presets`,children:[(0,c.jsx)(l,{type:`tertiary`,size:`small`,children:o(`c2.tasks.timePresets`,null,`快捷`)}),v.map(t=>(0,c.jsx)(n,{size:`small`,theme:t.value===e?`solid`:`borderless`,type:t.value===e?`primary`:`tertiary`,onClick:()=>r(t.value),children:o(`c2.${i}.preset${t.value===`all`?`All`:t.value}`,null,t.label)},t.value))]})}function x(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`—`:t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}秒`:`${Math.round(t/6e4)}分钟`}function S({value:e}){let t=a();return e?(0,c.jsx)(`span`,{className:`c2-time-text`,title:i(e),children:o(e,t)}):(0,c.jsx)(l,{type:`tertiary`,children:`—`})}var C={running:`green`,stopped:`grey`,error:`red`},w={queued:`amber`,sent:`blue`,running:`blue`,success:`green`,failed:`red`,cancelled:`grey`},T={active:`green`,sleeping:`amber`,dead:`grey`,killed:`red`},E={info:`blue`,warn:`amber`,critical:`red`};export{d as a,T as c,m as d,p as f,y as g,x as h,C as i,_ as l,S as m,E as n,u as o,b as p,h as r,f as s,g as t,w as u};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-shared-BxfKXbIb.js b/web/static/app/assets/c2-shared-CweYFEMs.js
similarity index 96%
rename from web/static/app/assets/c2-shared-BxfKXbIb.js
rename to web/static/app/assets/c2-shared-CweYFEMs.js
index 3feb754c..26e50c81 100644
--- a/web/static/app/assets/c2-shared-BxfKXbIb.js
+++ b/web/static/app/assets/c2-shared-CweYFEMs.js
@@ -1 +1 @@
-import{I as e,L as t}from"./index-gBcdNgHq.js";var n=encodeURIComponent,r=t=>e.get(`/c2/listeners`,t),i=t=>e.post(`/c2/listeners`,t),a=(t,r)=>e.put(`/c2/listeners/${n(t)}`,r),o=t=>e.del(`/c2/listeners/${n(t)}`),s=t=>e.post(`/c2/listeners/${n(t)}/start`,{}),c=t=>e.post(`/c2/listeners/${n(t)}/stop`,{}),l=t=>e.get(`/c2/sessions`,t),u=t=>e.get(`/c2/sessions/${n(t)}`),d=t=>e.del(`/c2/sessions/${n(t)}`),f=t=>e.del(`/c2/sessions`,{body:{ids:t}}),p=(t,{sleepSeconds:r,jitterPercent:i})=>e.put(`/c2/sessions/${n(t)}/sleep`,{sleep_seconds:r,jitter_percent:i}),m=(t,r)=>e.put(`/c2/sessions/${n(t)}/note`,{note:r}),h=t=>e.get(`/c2/tasks`,t),g=t=>e.get(`/c2/tasks/${n(t)}`),_=t=>e.post(`/c2/tasks`,t),v=(t,r)=>e.post(`/c2/sessions/${n(t)}/tasks`,r),y=t=>e.post(`/c2/tasks/${n(t)}/cancel`,{}),b=(t,r=30)=>e.get(`/c2/tasks/${n(t)}/wait`,{timeout:r},{timeout:(r+10)*1e3}),x=t=>e.del(`/c2/tasks`,{body:{ids:t}}),S=(e,r)=>t(`/c2/tasks/${n(e)}/result-file`,{filename:r}),C=t=>e.post(`/c2/payloads/oneliner`,t),w=t=>e.post(`/c2/payloads/build`,t),T=(e,r)=>t(`/c2/payloads/${n(e)}/download`,{filename:r}),E=t=>e.get(`/c2/events`,t),D=t=>e.del(`/c2/events`,{body:{ids:t}}),O=()=>e.get(`/c2/profiles`),k=t=>e.post(`/c2/profiles`,t),A=(t,r)=>e.put(`/c2/profiles/${n(t)}`,r),j=t=>e.del(`/c2/profiles/${n(t)}`);async function M(){try{let t=await e.get(`/projects`,{limit:200});return Array.isArray(t?.projects)?t.projects:[]}catch{return[]}}export{b as A,h as C,c as D,s as E,a as O,l as S,p as T,g as _,k as a,O as b,D as c,d,f,u as g,S as h,i,A as k,o as l,T as m,w as n,v as o,x as p,y as r,_ as s,C as t,j as u,E as v,m as w,M as x,r as y};
\ No newline at end of file
+import{I as e,L as t}from"./index-BMTtTYg1.js";var n=encodeURIComponent,r=t=>e.get(`/c2/listeners`,t),i=t=>e.post(`/c2/listeners`,t),a=(t,r)=>e.put(`/c2/listeners/${n(t)}`,r),o=t=>e.del(`/c2/listeners/${n(t)}`),s=t=>e.post(`/c2/listeners/${n(t)}/start`,{}),c=t=>e.post(`/c2/listeners/${n(t)}/stop`,{}),l=t=>e.get(`/c2/sessions`,t),u=t=>e.get(`/c2/sessions/${n(t)}`),d=t=>e.del(`/c2/sessions/${n(t)}`),f=t=>e.del(`/c2/sessions`,{body:{ids:t}}),p=(t,{sleepSeconds:r,jitterPercent:i})=>e.put(`/c2/sessions/${n(t)}/sleep`,{sleep_seconds:r,jitter_percent:i}),m=(t,r)=>e.put(`/c2/sessions/${n(t)}/note`,{note:r}),h=t=>e.get(`/c2/tasks`,t),g=t=>e.get(`/c2/tasks/${n(t)}`),_=t=>e.post(`/c2/tasks`,t),v=(t,r)=>e.post(`/c2/sessions/${n(t)}/tasks`,r),y=t=>e.post(`/c2/tasks/${n(t)}/cancel`,{}),b=(t,r=30)=>e.get(`/c2/tasks/${n(t)}/wait`,{timeout:r},{timeout:(r+10)*1e3}),x=t=>e.del(`/c2/tasks`,{body:{ids:t}}),S=(e,r)=>t(`/c2/tasks/${n(e)}/result-file`,{filename:r}),C=t=>e.post(`/c2/payloads/oneliner`,t),w=t=>e.post(`/c2/payloads/build`,t),T=(e,r)=>t(`/c2/payloads/${n(e)}/download`,{filename:r}),E=t=>e.get(`/c2/events`,t),D=t=>e.del(`/c2/events`,{body:{ids:t}}),O=()=>e.get(`/c2/profiles`),k=t=>e.post(`/c2/profiles`,t),A=(t,r)=>e.put(`/c2/profiles/${n(t)}`,r),j=t=>e.del(`/c2/profiles/${n(t)}`);async function M(){try{let t=await e.get(`/projects`,{limit:200});return Array.isArray(t?.projects)?t.projects:[]}catch{return[]}}export{b as A,h as C,c as D,s as E,a as O,l as S,p as T,g as _,k as a,O as b,D as c,d,f,u as g,S as h,i,A as k,o as l,T as m,w as n,v as o,x as p,y as r,_ as s,C as t,j as u,E as v,m as w,M as x,r as y};
\ No newline at end of file
diff --git a/web/static/app/assets/c2-tasks-BXG-lzo5.js b/web/static/app/assets/c2-tasks-D50_YjFm.js
similarity index 98%
rename from web/static/app/assets/c2-tasks-BXG-lzo5.js
rename to web/static/app/assets/c2-tasks-D50_YjFm.js
index 3dd4f7d4..e88d137f 100644
--- a/web/static/app/assets/c2-tasks-BXG-lzo5.js
+++ b/web/static/app/assets/c2-tasks-D50_YjFm.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,W as c,i as l,lt as u,st as d,v as f}from"./semi-Dpcldp_F.js";import{E as ee,F as te,P as p,_ as ne,a as re,b as m,c as h,l as ie,m as g,p as ae,r as oe,s as se,x as _,y as ce}from"./index-gBcdNgHq.js";import{A as le,C as ue,h as de,p as fe,r as v,s as y}from"./c2-shared-BxfKXbIb.js";import{d as pe,f as b,g as me,h as x,m as he,p as ge,u as S}from"./c2-shared-C42gWRB4.js";var C=e(t(),1),w=e(n(),1),{Text:T}=c,E=new Set([`shell`,`exec`]),D=new Set([`ls`,`download`,`cd`]);function _e({visible:e,defaultSessionId:t,onCancel:n,onSubmit:r,submitting:a}){let s=p(),[c,u]=(0,C.useState)(null),[d,f]=(0,C.useState)(`shell`);return(0,w.jsx)(h,{visible:e,title:s(`c2.tasks.createTitle`,null,`下发任务`),footer:(0,w.jsxs)(i,{children:[(0,w.jsx)(o,{onClick:n,children:s(`c2.tasks.cancelFilters`,null,`取消`)}),(0,w.jsx)(o,{theme:`solid`,type:`primary`,loading:a,onClick:()=>c?.submitForm(),children:s(`c2.tasks.createSubmit`,null,`下发`)})]}),width:560,onCancel:n,children:(0,w.jsxs)(l,{initValues:{session_id:t||``,task_type:`shell`,command:``,timeout_seconds:`60`,extra:``},onSubmit:e=>{let t={},n=String(e.command||``).trim();if(E.has(e.task_type)){t.command=n;let r=Number(e.timeout_seconds);Number.isFinite(r)&&r>0&&(t.timeout_seconds=r)}else(D.has(e.task_type)||n)&&(t.path=n);let i=String(e.extra||``).trim();if(i)try{Object.assign(t,JSON.parse(i))}catch{t.raw=i}r({session_id:String(e.session_id||``).trim(),task_type:e.task_type||`shell`,payload:t,source:`manual`})},getFormApi:u,labelPosition:`top`,onValueChange:e=>{e.task_type&&f(e.task_type)},children:[(0,w.jsx)(l.Input,{field:`session_id`,label:s(`c2.tasks.labelSession`,null,`会话`),placeholder:`s_xxxxxxxx`,rules:[{required:!0,message:s(`c2.tasks.labelSession`,null,`请填写会话 ID`)}]}),(0,w.jsx)(l.Select,{field:`task_type`,label:s(`c2.tasks.labelType`,null,`类型`),optionList:b,style:{width:`100%`}}),(0,w.jsx)(l.Input,{field:`command`,label:E.has(d)?s(`c2.tasks.labelCommand`,null,`命令`):s(`c2.tasks.labelPath`,null,`路径`),placeholder:E.has(d)?`whoami`:`/etc/passwd`}),E.has(d)&&(0,w.jsx)(l.Input,{field:`timeout_seconds`,label:s(`c2.tasks.labelTimeout`,null,`超时(秒)`),placeholder:`60`}),(0,w.jsx)(l.Input,{field:`extra`,label:s(`c2.tasks.labelExtraPayload`,null,`附加参数(JSON,可选)`),placeholder:`{"key":"value"}`}),(0,w.jsx)(T,{type:`tertiary`,size:`small`,children:s(`c2.tasks.createHint`,null,`任务入队后由植入体在下次心跳拉取;危险类型可能需要人机协同审批。`)})]},e?`open`:`closed`)})}var{Text:O}=c;function k(){let e=p(),{hasPermission:t}=te(),n=t(`c2:write`),c=t(`c2:delete`)||n,[l,T]=r(),[E,D]=(0,C.useState)(1),[k,ve]=(0,C.useState)(20),[A,j]=(0,C.useState)(``),[M,N]=(0,C.useState)(``),[P,F]=(0,C.useState)(`all`),[I,L]=(0,C.useState)(l.get(`session_id`)||``),[R,z]=(0,C.useState)(l.get(`session_id`)||``),[B,V]=(0,C.useState)(null),[ye,H]=(0,C.useState)(!1),[be,U]=(0,C.useState)(!1),W=(0,C.useMemo)(()=>({page:E,page_size:k,status:A||void 0,task_type:M||void 0,session_id:R||void 0,since:me(P)||void 0}),[E,k,A,M,R,P]),{data:G,loading:K,error:xe,reload:q}=re(()=>ue(W),[W]),J=Array.isArray(G?.tasks)?G.tasks:[],Y=Number(G?.total??J.length),X=G?.status_counts||{};oe(()=>q({silent:!0}),5e3);let Z=()=>{z(I.trim()),D(1);let e=new URLSearchParams(l);I.trim()?e.set(`session_id`,I.trim()):e.delete(`session_id`),T(e,{replace:!0})},Se=()=>{j(``),N(``),F(`all`),L(``),z(``),D(1),T(new URLSearchParams,{replace:!0})},Ce=[{id:`total`,label:e(`c2.tasks.statTotal`,null,`当前筛选`),value:Y},{id:`success`,label:e(`c2.tasks.success`,null,`成功`),value:X.success||0,tone:`success`},{id:`failed`,label:e(`c2.tasks.failed`,null,`失败`),value:X.failed||0,tone:`danger`},{id:`pending`,label:e(`c2.tasks.pending`,null,`待处理`),value:(X.queued||0)+(X.sent||0)+(X.running||0),tone:`warning`}],we=async t=>{try{await v(t.id),_(e(`c2.tasks.toastCancelled`,null,`任务已取消`)),q({silent:!0})}catch(e){m(e)}},Te=t=>{ce({title:e(`c2.tasks.deleteOne`,null,`删除任务`),content:e(`c2.tasks.confirmDeleteOne`,null,`确定从服务器删除该任务记录吗?此操作不可恢复。`),onOk:async()=>{try{await fe([t.id]),_(e(`c2.tasks.toastDeleted`,null,`已删除 {{n}} 条`).replace(`{{n}}`,`1`)),q()}catch(e){m(e)}}})},Ee=async t=>{try{let n=await le(t.id,20);n?.task&&V(n.task),_(e(`c2.tasks.toastWaited`,null,`已获取最新任务状态`)),q({silent:!0})}catch(t){m(t,e(`c2.tasks.waitTimeout`,null,`等待任务完成超时`))}},Q=async t=>{try{await de(t.id),_(e(`c2.tasks.downloadOk`,null,`已开始下载`))}catch(t){m(t,e(`c2.tasks.labelResult`,null,`下载结果文件失败`))}},$=async t=>{U(!0);try{await y(t),_(e(`c2.tasks.toastCreated`,null,`任务已下发`)),H(!1),q()}catch(t){m(t,e(`c2.tasks.createFailed`,null,`下发任务失败`))}finally{U(!1)}},De=[{title:e(`c2.tasks.colTask`,null,`任务`),dataIndex:`id`,width:150,render:e=>(0,w.jsx)(`span`,{className:`c2-mono`,children:e})},{title:e(`c2.tasks.colSession`,null,`会话`),dataIndex:`sessionId`,width:150,render:e=>(0,w.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.tasks.colType`,null,`类型`),dataIndex:`taskType`,width:110},{title:e(`c2.tasks.colCommand`,null,`命令`),dataIndex:`payload`,render:e=>{let t=e?.command||e?.path||``;return(0,w.jsx)(`span`,{className:`c2-mono c2-task-command`,title:t,children:t||`—`})}},{title:e(`c2.tasks.colStatus`,null,`状态`),dataIndex:`status`,width:110,render:t=>(0,w.jsx)(s,{size:`small`,color:S[t]||`grey`,children:e(`c2.tasks.${t||`queued`}`,null,t||`—`)})},{title:e(`c2.tasks.colDuration`,null,`耗时`),dataIndex:`durationMs`,width:100,render:e=>x(e)},{title:e(`c2.tasks.colCreated`,null,`创建时间`),dataIndex:`createdAt`,width:130,render:e=>(0,w.jsx)(he,{value:e})},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:210,render:(t,n)=>(0,w.jsxs)(i,{spacing:4,wrap:!0,children:[(0,w.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>V(n),children:e(`c2.tasks.view`,null,`查看`)}),[`queued`,`sent`,`running`].includes(n.status)&&(0,w.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>we(n),children:e(`c2.tasks.cancelBtn`,null,`取消`)}),n.resultBlobPath&&(0,w.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>Q(n),children:e(`c2.tasks.downloadResult`,null,`结果文件`)}),(0,w.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!c,onClick:()=>Te(n),children:e(`c2.tasks.deleteBtn`,null,`删除`)})]})}];return(0,w.jsxs)(`div`,{className:`c2-page`,id:`page-c2-tasks`,children:[(0,w.jsx)(ae,{title:e(`c2.tasks.title`,null,`任务管理`),description:e(`c2.tasks.pageDesc`,null,`按状态、类型、会话与时间窗筛选任务,5 秒自动轮询最新状态`),extra:[(0,w.jsx)(o,{icon:(0,w.jsx)(d,{}),onClick:()=>q(),loading:K,children:e(`c2.tasks.refresh`,null,`刷新任务`)},`refresh`),(0,w.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,w.jsx)(u,{}),disabled:!n,onClick:()=>H(!0),children:e(`c2.tasks.createTitle`,null,`下发任务`)},`create`)]}),(0,w.jsx)(ne,{metrics:Ce,columns:4}),(0,w.jsx)(ie,{error:xe,onRetry:()=>q()}),(0,w.jsx)(g,{title:e(`c2.tasks.filterTitle`,null,`筛选`),extra:(0,w.jsx)(ge,{value:P,onChange:e=>{F(e),D(1)},ns:`tasks`}),children:(0,w.jsxs)(`div`,{className:`c2-toolbar-fields`,children:[(0,w.jsxs)(`div`,{className:`c2-field`,children:[(0,w.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.colStatus`,null,`状态`)}),(0,w.jsx)(f,{value:A,onChange:e=>{j(e||``),D(1)},style:{width:160},optionList:[{value:``,label:e(`c2.tasks.filterAllStatuses`,null,`全部状态`)},...pe]})]}),(0,w.jsxs)(`div`,{className:`c2-field`,children:[(0,w.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.colType`,null,`类型`)}),(0,w.jsx)(f,{value:M,onChange:e=>{N(e||``),D(1)},style:{width:160},optionList:[{value:``,label:e(`c2.tasks.filterAllTypes`,null,`全部类型`)},...b]})]}),(0,w.jsxs)(`div`,{className:`c2-field`,children:[(0,w.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.filterSession`,null,`会话 ID`)}),(0,w.jsx)(a,{value:I,onChange:L,onEnterPress:Z,placeholder:e(`c2.tasks.filterSessionPlaceholder`,null,`s_xxxxxxxx`),style:{width:190}})]}),(0,w.jsxs)(i,{spacing:8,children:[(0,w.jsx)(o,{theme:`solid`,type:`primary`,onClick:Z,children:e(`c2.tasks.applyFilters`,null,`应用筛选`)}),(0,w.jsx)(o,{onClick:Se,children:e(`c2.tasks.resetFilters`,null,`重置`)})]})]})}),(0,w.jsx)(g,{title:e(`c2.tasks.listTitle`,null,`任务列表`),children:(0,w.jsx)(se,{columns:De,dataSource:J,rowKey:`id`,loading:K,onRefresh:()=>q(),pagination:{currentPage:E,pageSize:k,total:Y,onPageChange:e=>D(e),onPageSizeChange:e=>{ve(e),D(1)}},emptyText:e(`c2.tasks.emptyAll`,null,`暂无任务`)})}),(0,w.jsx)(_e,{visible:ye,defaultSessionId:R,submitting:be,onCancel:()=>H(!1),onSubmit:$}),(0,w.jsx)(h,{visible:!!B,title:e(`c2.tasks.modalTitle`,null,`任务详情`),width:760,onCancel:()=>V(null),footer:(0,w.jsxs)(i,{children:[B&&[`queued`,`sent`,`running`].includes(B.status)&&(0,w.jsx)(o,{onClick:()=>Ee(B),children:e(`c2.tasks.waitBtn`,null,`等待完成`)}),B?.resultBlobPath&&(0,w.jsx)(o,{onClick:()=>Q(B),children:e(`c2.tasks.downloadResult`,null,`下载结果文件`)}),(0,w.jsx)(o,{onClick:()=>V(null),children:e(`c2.tasks.close`,null,`关闭`)})]}),children:B&&(0,w.jsxs)(`div`,{className:`c2-task-detail`,children:[(0,w.jsxs)(`div`,{className:`c2-task-detail-meta`,children:[(0,w.jsx)(`span`,{className:`c2-mono`,children:B.id}),(0,w.jsx)(s,{size:`small`,color:S[B.status]||`grey`,children:B.status}),(0,w.jsx)(O,{type:`tertiary`,size:`small`,children:ee(B.createdAt)}),(0,w.jsx)(O,{type:`tertiary`,size:`small`,children:x(B.durationMs)})]}),(0,w.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelPayload`,null,`参数`)}),(0,w.jsx)(`pre`,{className:`c2-pre`,children:JSON.stringify(B.payload||{},null,2)}),B.resultText&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelResult`,null,`输出`)}),(0,w.jsx)(`pre`,{className:`c2-pre`,children:B.resultText})]}),B.error&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelError`,null,`错误`)}),(0,w.jsx)(`pre`,{className:`c2-pre c2-pre-error`,children:B.error})]})]})})]})}export{k as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,W as c,i as l,lt as u,st as d,v as f}from"./semi-Dpcldp_F.js";import{E as ee,F as te,P as p,_ as ne,a as re,b as m,c as h,l as ie,m as g,p as ae,r as oe,s as se,x as _,y as ce}from"./index-BMTtTYg1.js";import{A as le,C as ue,h as de,p as fe,r as v,s as y}from"./c2-shared-CweYFEMs.js";import{d as pe,f as b,g as me,h as x,m as he,p as ge,u as S}from"./c2-shared-CGoxRI15.js";var C=e(t(),1),w=e(n(),1),{Text:T}=c,E=new Set([`shell`,`exec`]),D=new Set([`ls`,`download`,`cd`]);function _e({visible:e,defaultSessionId:t,onCancel:n,onSubmit:r,submitting:a}){let s=p(),[c,u]=(0,C.useState)(null),[d,f]=(0,C.useState)(`shell`);return(0,w.jsx)(h,{visible:e,title:s(`c2.tasks.createTitle`,null,`下发任务`),footer:(0,w.jsxs)(i,{children:[(0,w.jsx)(o,{onClick:n,children:s(`c2.tasks.cancelFilters`,null,`取消`)}),(0,w.jsx)(o,{theme:`solid`,type:`primary`,loading:a,onClick:()=>c?.submitForm(),children:s(`c2.tasks.createSubmit`,null,`下发`)})]}),width:560,onCancel:n,children:(0,w.jsxs)(l,{initValues:{session_id:t||``,task_type:`shell`,command:``,timeout_seconds:`60`,extra:``},onSubmit:e=>{let t={},n=String(e.command||``).trim();if(E.has(e.task_type)){t.command=n;let r=Number(e.timeout_seconds);Number.isFinite(r)&&r>0&&(t.timeout_seconds=r)}else(D.has(e.task_type)||n)&&(t.path=n);let i=String(e.extra||``).trim();if(i)try{Object.assign(t,JSON.parse(i))}catch{t.raw=i}r({session_id:String(e.session_id||``).trim(),task_type:e.task_type||`shell`,payload:t,source:`manual`})},getFormApi:u,labelPosition:`top`,onValueChange:e=>{e.task_type&&f(e.task_type)},children:[(0,w.jsx)(l.Input,{field:`session_id`,label:s(`c2.tasks.labelSession`,null,`会话`),placeholder:`s_xxxxxxxx`,rules:[{required:!0,message:s(`c2.tasks.labelSession`,null,`请填写会话 ID`)}]}),(0,w.jsx)(l.Select,{field:`task_type`,label:s(`c2.tasks.labelType`,null,`类型`),optionList:b,style:{width:`100%`}}),(0,w.jsx)(l.Input,{field:`command`,label:E.has(d)?s(`c2.tasks.labelCommand`,null,`命令`):s(`c2.tasks.labelPath`,null,`路径`),placeholder:E.has(d)?`whoami`:`/etc/passwd`}),E.has(d)&&(0,w.jsx)(l.Input,{field:`timeout_seconds`,label:s(`c2.tasks.labelTimeout`,null,`超时(秒)`),placeholder:`60`}),(0,w.jsx)(l.Input,{field:`extra`,label:s(`c2.tasks.labelExtraPayload`,null,`附加参数(JSON,可选)`),placeholder:`{"key":"value"}`}),(0,w.jsx)(T,{type:`tertiary`,size:`small`,children:s(`c2.tasks.createHint`,null,`任务入队后由植入体在下次心跳拉取;危险类型可能需要人机协同审批。`)})]},e?`open`:`closed`)})}var{Text:O}=c;function k(){let e=p(),{hasPermission:t}=te(),n=t(`c2:write`),c=t(`c2:delete`)||n,[l,T]=r(),[E,D]=(0,C.useState)(1),[k,ve]=(0,C.useState)(20),[A,j]=(0,C.useState)(``),[M,N]=(0,C.useState)(``),[P,F]=(0,C.useState)(`all`),[I,L]=(0,C.useState)(l.get(`session_id`)||``),[R,z]=(0,C.useState)(l.get(`session_id`)||``),[B,V]=(0,C.useState)(null),[ye,H]=(0,C.useState)(!1),[be,U]=(0,C.useState)(!1),W=(0,C.useMemo)(()=>({page:E,page_size:k,status:A||void 0,task_type:M||void 0,session_id:R||void 0,since:me(P)||void 0}),[E,k,A,M,R,P]),{data:G,loading:K,error:xe,reload:q}=re(()=>ue(W),[W]),J=Array.isArray(G?.tasks)?G.tasks:[],Y=Number(G?.total??J.length),X=G?.status_counts||{};oe(()=>q({silent:!0}),5e3);let Z=()=>{z(I.trim()),D(1);let e=new URLSearchParams(l);I.trim()?e.set(`session_id`,I.trim()):e.delete(`session_id`),T(e,{replace:!0})},Se=()=>{j(``),N(``),F(`all`),L(``),z(``),D(1),T(new URLSearchParams,{replace:!0})},Ce=[{id:`total`,label:e(`c2.tasks.statTotal`,null,`当前筛选`),value:Y},{id:`success`,label:e(`c2.tasks.success`,null,`成功`),value:X.success||0,tone:`success`},{id:`failed`,label:e(`c2.tasks.failed`,null,`失败`),value:X.failed||0,tone:`danger`},{id:`pending`,label:e(`c2.tasks.pending`,null,`待处理`),value:(X.queued||0)+(X.sent||0)+(X.running||0),tone:`warning`}],we=async t=>{try{await v(t.id),_(e(`c2.tasks.toastCancelled`,null,`任务已取消`)),q({silent:!0})}catch(e){m(e)}},Te=t=>{ce({title:e(`c2.tasks.deleteOne`,null,`删除任务`),content:e(`c2.tasks.confirmDeleteOne`,null,`确定从服务器删除该任务记录吗?此操作不可恢复。`),onOk:async()=>{try{await fe([t.id]),_(e(`c2.tasks.toastDeleted`,null,`已删除 {{n}} 条`).replace(`{{n}}`,`1`)),q()}catch(e){m(e)}}})},Ee=async t=>{try{let n=await le(t.id,20);n?.task&&V(n.task),_(e(`c2.tasks.toastWaited`,null,`已获取最新任务状态`)),q({silent:!0})}catch(t){m(t,e(`c2.tasks.waitTimeout`,null,`等待任务完成超时`))}},Q=async t=>{try{await de(t.id),_(e(`c2.tasks.downloadOk`,null,`已开始下载`))}catch(t){m(t,e(`c2.tasks.labelResult`,null,`下载结果文件失败`))}},$=async t=>{U(!0);try{await y(t),_(e(`c2.tasks.toastCreated`,null,`任务已下发`)),H(!1),q()}catch(t){m(t,e(`c2.tasks.createFailed`,null,`下发任务失败`))}finally{U(!1)}},De=[{title:e(`c2.tasks.colTask`,null,`任务`),dataIndex:`id`,width:150,render:e=>(0,w.jsx)(`span`,{className:`c2-mono`,children:e})},{title:e(`c2.tasks.colSession`,null,`会话`),dataIndex:`sessionId`,width:150,render:e=>(0,w.jsx)(`span`,{className:`c2-mono`,children:e||`—`})},{title:e(`c2.tasks.colType`,null,`类型`),dataIndex:`taskType`,width:110},{title:e(`c2.tasks.colCommand`,null,`命令`),dataIndex:`payload`,render:e=>{let t=e?.command||e?.path||``;return(0,w.jsx)(`span`,{className:`c2-mono c2-task-command`,title:t,children:t||`—`})}},{title:e(`c2.tasks.colStatus`,null,`状态`),dataIndex:`status`,width:110,render:t=>(0,w.jsx)(s,{size:`small`,color:S[t]||`grey`,children:e(`c2.tasks.${t||`queued`}`,null,t||`—`)})},{title:e(`c2.tasks.colDuration`,null,`耗时`),dataIndex:`durationMs`,width:100,render:e=>x(e)},{title:e(`c2.tasks.colCreated`,null,`创建时间`),dataIndex:`createdAt`,width:130,render:e=>(0,w.jsx)(he,{value:e})},{title:e(`c2.tasks.colActions`,null,`操作`),dataIndex:`actions`,width:210,render:(t,n)=>(0,w.jsxs)(i,{spacing:4,wrap:!0,children:[(0,w.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>V(n),children:e(`c2.tasks.view`,null,`查看`)}),[`queued`,`sent`,`running`].includes(n.status)&&(0,w.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>we(n),children:e(`c2.tasks.cancelBtn`,null,`取消`)}),n.resultBlobPath&&(0,w.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>Q(n),children:e(`c2.tasks.downloadResult`,null,`结果文件`)}),(0,w.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!c,onClick:()=>Te(n),children:e(`c2.tasks.deleteBtn`,null,`删除`)})]})}];return(0,w.jsxs)(`div`,{className:`c2-page`,id:`page-c2-tasks`,children:[(0,w.jsx)(ae,{title:e(`c2.tasks.title`,null,`任务管理`),description:e(`c2.tasks.pageDesc`,null,`按状态、类型、会话与时间窗筛选任务,5 秒自动轮询最新状态`),extra:[(0,w.jsx)(o,{icon:(0,w.jsx)(d,{}),onClick:()=>q(),loading:K,children:e(`c2.tasks.refresh`,null,`刷新任务`)},`refresh`),(0,w.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,w.jsx)(u,{}),disabled:!n,onClick:()=>H(!0),children:e(`c2.tasks.createTitle`,null,`下发任务`)},`create`)]}),(0,w.jsx)(ne,{metrics:Ce,columns:4}),(0,w.jsx)(ie,{error:xe,onRetry:()=>q()}),(0,w.jsx)(g,{title:e(`c2.tasks.filterTitle`,null,`筛选`),extra:(0,w.jsx)(ge,{value:P,onChange:e=>{F(e),D(1)},ns:`tasks`}),children:(0,w.jsxs)(`div`,{className:`c2-toolbar-fields`,children:[(0,w.jsxs)(`div`,{className:`c2-field`,children:[(0,w.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.colStatus`,null,`状态`)}),(0,w.jsx)(f,{value:A,onChange:e=>{j(e||``),D(1)},style:{width:160},optionList:[{value:``,label:e(`c2.tasks.filterAllStatuses`,null,`全部状态`)},...pe]})]}),(0,w.jsxs)(`div`,{className:`c2-field`,children:[(0,w.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.colType`,null,`类型`)}),(0,w.jsx)(f,{value:M,onChange:e=>{N(e||``),D(1)},style:{width:160},optionList:[{value:``,label:e(`c2.tasks.filterAllTypes`,null,`全部类型`)},...b]})]}),(0,w.jsxs)(`div`,{className:`c2-field`,children:[(0,w.jsx)(`span`,{className:`c2-field-label`,children:e(`c2.tasks.filterSession`,null,`会话 ID`)}),(0,w.jsx)(a,{value:I,onChange:L,onEnterPress:Z,placeholder:e(`c2.tasks.filterSessionPlaceholder`,null,`s_xxxxxxxx`),style:{width:190}})]}),(0,w.jsxs)(i,{spacing:8,children:[(0,w.jsx)(o,{theme:`solid`,type:`primary`,onClick:Z,children:e(`c2.tasks.applyFilters`,null,`应用筛选`)}),(0,w.jsx)(o,{onClick:Se,children:e(`c2.tasks.resetFilters`,null,`重置`)})]})]})}),(0,w.jsx)(g,{title:e(`c2.tasks.listTitle`,null,`任务列表`),children:(0,w.jsx)(se,{columns:De,dataSource:J,rowKey:`id`,loading:K,onRefresh:()=>q(),pagination:{currentPage:E,pageSize:k,total:Y,onPageChange:e=>D(e),onPageSizeChange:e=>{ve(e),D(1)}},emptyText:e(`c2.tasks.emptyAll`,null,`暂无任务`)})}),(0,w.jsx)(_e,{visible:ye,defaultSessionId:R,submitting:be,onCancel:()=>H(!1),onSubmit:$}),(0,w.jsx)(h,{visible:!!B,title:e(`c2.tasks.modalTitle`,null,`任务详情`),width:760,onCancel:()=>V(null),footer:(0,w.jsxs)(i,{children:[B&&[`queued`,`sent`,`running`].includes(B.status)&&(0,w.jsx)(o,{onClick:()=>Ee(B),children:e(`c2.tasks.waitBtn`,null,`等待完成`)}),B?.resultBlobPath&&(0,w.jsx)(o,{onClick:()=>Q(B),children:e(`c2.tasks.downloadResult`,null,`下载结果文件`)}),(0,w.jsx)(o,{onClick:()=>V(null),children:e(`c2.tasks.close`,null,`关闭`)})]}),children:B&&(0,w.jsxs)(`div`,{className:`c2-task-detail`,children:[(0,w.jsxs)(`div`,{className:`c2-task-detail-meta`,children:[(0,w.jsx)(`span`,{className:`c2-mono`,children:B.id}),(0,w.jsx)(s,{size:`small`,color:S[B.status]||`grey`,children:B.status}),(0,w.jsx)(O,{type:`tertiary`,size:`small`,children:ee(B.createdAt)}),(0,w.jsx)(O,{type:`tertiary`,size:`small`,children:x(B.durationMs)})]}),(0,w.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelPayload`,null,`参数`)}),(0,w.jsx)(`pre`,{className:`c2-pre`,children:JSON.stringify(B.payload||{},null,2)}),B.resultText&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelResult`,null,`输出`)}),(0,w.jsx)(`pre`,{className:`c2-pre`,children:B.resultText})]}),B.error&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{className:`c2-field-label`,children:e(`c2.tasks.labelError`,null,`错误`)}),(0,w.jsx)(`pre`,{className:`c2-pre c2-pre-error`,children:B.error})]})]})})]})}export{k as default};
\ No newline at end of file
diff --git a/web/static/app/assets/chat-DWxpwXqA.js b/web/static/app/assets/chat-B-dZud0m.js
similarity index 99%
rename from web/static/app/assets/chat-DWxpwXqA.js
rename to web/static/app/assets/chat-B-dZud0m.js
index 6a3c8d88..635bf96e 100644
--- a/web/static/app/assets/chat-DWxpwXqA.js
+++ b/web/static/app/assets/chat-B-dZud0m.js
@@ -1,4 +1,4 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{A as i,At as a,C as o,Ct as s,Dt as c,F as l,G as u,H as d,I as f,It as p,L as m,M as h,Mt as g,N as _,P as v,Pt as y,Qt as b,Rt as x,S,T as C,U as ee,V as w,W as T,Wt as E,Y as te,Yt as D,Z as ne,_ as re,d as ie,et as ae,f as O,g as k,h as oe,kt as se,lt as ce,m as le,nt as ue,ot as de,pt as fe,q as A,qt as pe,st as j,tt as M,ut as N,v as me,x as he,z as ge}from"./semi-Dpcldp_F.js";import{D as _e,E as P,F as ve,I as F,N as I,P as L,R as ye,S as R,a as be,b as z,f as xe,i as Se,l as Ce,n as we,o as B,r as Te,u as Ee,x as De,y as Oe,z as V}from"./index-gBcdNgHq.js";import{t as ke}from"./project-form-D2VoONj8.js";import{n as Ae,r as je,t as Me}from"./model-channel-mQ6lfvSO.js";var H=e(t(),1),U=e(n(),1),{Text:Ne,Title:W}=T,Pe={single:{key:`chat.agentModePiSingle`,label:`单代理`,color:`blue`},deep:{key:`chat.agentModeDeep`,label:`Deep`,color:`purple`},plan_execute:{key:`chat.agentModePlanExecuteLabel`,label:`Plan-Execute`,color:`orange`},supervisor:{key:`chat.agentModeSupervisorLabel`,label:`Supervisor`,color:`green`}};function Fe({conversation:e,mode:t,hitlCount:n,conversationId:r,narrow:i,onToggleSidebar:a,onRefresh:o}){let s=L(),c=Pe[t]||Pe.single,u=e?.title||s(`chat.newChat`,null,`新对话`);return(0,U.jsxs)(`header`,{className:`chat-header`,children:[(0,U.jsxs)(`div`,{className:`chat-header-main`,children:[(0,U.jsxs)(`div`,{className:`chat-header-heading`,children:[(0,U.jsx)(W,{heading:3,className:`chat-header-title`,title:u,children:u}),(0,U.jsxs)(l,{spacing:6,wrap:!0,className:`chat-header-tags`,children:[e?.pinned&&(0,U.jsx)(h,{size:`small`,color:`amber`,children:s(`chat.pinned`,null,`已置顶`)}),(0,U.jsx)(h,{size:`small`,color:c.color,children:s(c.key,null,c.label)}),n>0&&(0,U.jsx)(h,{size:`small`,color:`orange`,children:s(`chat.pendingApprovals`,{count:n},`待审批 ${n}`)})]})]}),(0,U.jsx)(Ne,{type:`tertiary`,size:`small`,className:`chat-header-description`,children:r?s(`chat.conversationHint`,null,`会话历史与工具执行过程会自动落库`):s(`chat.newConversationHint`,null,`输入内容即可创建新对话`)})]}),(0,U.jsxs)(l,{spacing:8,wrap:!0,className:`chat-header-actions`,children:[i&&(0,U.jsx)(m,{icon:(0,U.jsx)(fe,{}),onClick:a,children:s(`chat.conversations`,null,`会话`)}),r&&(0,U.jsx)(m,{theme:`borderless`,type:`tertiary`,icon:(0,U.jsx)(j,{"aria-hidden":`true`}),title:s(`chat.refreshConversationHint`,null,`重新读取会话列表、消息、待审批项和执行计划`),onClick:o,children:s(`chat.refreshConversation`,null,`刷新对话`)})]})]})}var Ie=[`default`,`off`,`on`,`auto`],Le=[`low`,`medium`,`high`,`xhigh`,`max`];function Re(e,t,n){return t!==`off`&&n?e(`chat.reasoningEffortLabels.${n}`,null,{low:`低`,medium:`中`,high:`高`,xhigh:`超高`,max:`ultra`}[n]):e(`chat.reasoningMode${t[0].toUpperCase()}${t.slice(1)}`,null,{default:`跟随系统`,off:`关闭`,on:`开启`,auto:`自动`}[t])}function ze(e,t){let[n,r]=(0,H.useState)(()=>{try{return localStorage.getItem(e)??t}catch{return t}});return[n,t=>{r(t);try{localStorage.setItem(e,t)}catch{}}]}function Be(e){let[t,n]=ze(`cyberstrike-chat-ai-channel`,``),[r,i]=ze(`cyberstrike-chat-reasoning-mode`,`default`),[a,o]=ze(`cyberstrike-chat-reasoning-effort`,``),s=be(async()=>(await F.get(`/config`))?.ai,[e],{skip:!e}),c=Object.entries(s.data?.channels||{}).sort(([e],[t])=>e.localeCompare(t)),l=t.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``),u=c.find(([e])=>e===t)?.[0]||c.find(([e])=>e===l)?.[0]||``,d=(s.data?.channels?.[u||s.data?.default_channel])?.reasoning?.allow_client_reasoning===!1,f=Ie.includes(r)?r:`default`,p=Le.includes(a)?a:``,m={mode:f==="default"?void 0:f,effort:f===`off`?void 0:p||void 0};return{channel:u,channels:c,setChannel:n,config:s,mode:f,setMode:i,effort:p,setEffort:o,overrideBlocked:d,waitingForChannel:!!(e&&t&&s.loading),request:{aiChannelId:e&&u||void 0,reasoning:m.mode||m.effort?m:void 0}}}var{Text:G}=T,Ve=[`off`,`approval`,`review_edit`],He=[60,300,600,0],Ue=`tool_search, skill, task, write_todos, transfer_to_agent, exit, TaskCreate, TaskGet, TaskUpdate, TaskList, upsert_project_fact, get_project_fact`;function We(e,t){return t===!1?`off`:Ve.includes(e)?e:`off`}function Ge(e){return e===`audit_agent`?`audit_agent`:`human`}function Ke(e,t=300){if(e==null||e===``)return t;let n=Number(e);return Number.isFinite(n)?Math.max(0,Math.min(86400,Math.round(n))):t}function K(e){return(Array.isArray(e)?e:String(e||``).split(/[,\n\r]+/)).map(e=>String(e||``).trim()).filter(Boolean)}function qe(e,t){let n=new Set(K(t).map(e=>e.toLowerCase()));return K(e).filter(e=>!n.has(e.toLowerCase())).join(`, `)}function Je(e,t,n){if(n)return{mode:We(n.mode,n.enabled),reviewer:Ge(n.reviewer),timeoutSeconds:Ke(n.timeoutSeconds),sensitiveTools:K(n.sensitiveTools).join(`, `)};let r=t?e?.hitl:null;return{mode:t?We(r?.mode,r?.enabled):We(e?.defaultMode),reviewer:Ge(t?r?.reviewer:e?.defaultReviewer),timeoutSeconds:Ke(t?r?.timeoutSeconds??e?.defaultTimeoutSeconds:e?.defaultTimeoutSeconds),sensitiveTools:t?qe(r?.sensitiveTools,e?.hitlGlobalToolWhitelist):Ue}}function q(e){return{enabled:e.mode!==`off`,mode:e.mode,reviewer:e.reviewer,sensitiveTools:K(e.sensitiveTools),timeoutSeconds:e.timeoutSeconds}}function Ye({label:e,...t}){let n=(0,H.useId)();return(0,U.jsxs)(`div`,{className:`chat-setting-field`,children:[(0,U.jsx)(G,{id:n,strong:!0,children:e}),(0,U.jsx)(me,{"aria-labelledby":n,...t})]})}function Xe({model:e,busy:t,canReadConfig:n}){let r=L(),i=(0,H.useId)(),a=(0,H.useRef)(null),s=e.config.data?.default_channel,c=s?Me(s,e.config.data?.channels?.[s]):``,l=r(`chat.aiChannelDefault`,null,`跟随默认通道`),u=[{value:``,label:c?`${l} · ${c}`:l},...Ae(e.channels)],d=Object.fromEntries(Ie.map(e=>[e,Re(r,e,``)])),f=t||e.overrideBlocked,h=[``,...Le],g=Object.fromEntries(h.map((e,t)=>[t,Re(r,e?`on`:`default`,e)])),_=()=>{e.setMode(`default`),e.setEffort(``)};return(0,U.jsxs)(`div`,{className:`chat-reasoning-picker${!e.overrideBlocked&&e.mode!==`off`&&e.effort===`max`?` is-max`:``}${f?` is-disabled`:``}`,ref:a,children:[(0,U.jsxs)(`div`,{className:`chat-reasoning-heading`,children:[(0,U.jsx)(o,{trigger:`click`,position:`bottomLeft`,className:`chat-reasoning-mode-menu`,getPopupContainer:()=>a.current,showTick:!0,menu:Ie.map(t=>({node:`item`,name:d[t],active:e.mode===t,disabled:f,onClick:()=>t==="default"?_():e.setMode(t)})),children:(0,U.jsx)(m,{theme:`borderless`,type:`tertiary`,icon:(0,U.jsx)(E,{}),className:`chat-reasoning-mode`,"aria-label":r(`chat.reasoningModeLabel`,null,`模型推理`),title:`${r(`chat.reasoningModeLabel`,null,`模型推理`)} · ${d[e.overrideBlocked?`default`:e.mode]}`,disabled:f})}),(0,U.jsx)(G,{strong:!0,className:`chat-reasoning-value`,role:`status`,children:e.overrideBlocked?d.default:Re(r,e.mode,e.effort)}),(0,U.jsx)(m,{theme:`borderless`,type:`tertiary`,icon:(0,U.jsx)(te,{}),"aria-label":r(`chat.reasoningReset`,null,`重置推理设置`),title:r(`chat.reasoningReset`,null,`重置推理设置`),disabled:f,onClick:_})]}),n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{id:i,hidden:!0,children:r(`chat.aiChannelLabel`,null,`AI 通道`)}),(0,U.jsx)(me,{className:`chat-reasoning-channel`,"aria-labelledby":i,value:e.channel,optionList:u,renderSelectedItem:e=>e.value===``?c||r(`chat.aiChannelDefaultShort`,null,`默认通道`):je(e),arrowIcon:(0,U.jsx)(p,{size:`small`}),borderless:!0,onSelect:e.setChannel,dropdownMatchSelectWidth:!1,dropdownStyle:{maxWidth:`calc(100vw - 32px)`},loading:e.config.loading,disabled:t||e.config.loading||!!e.config.error}),(0,U.jsx)(Ce,{error:e.config.error,onRetry:()=>e.config.reload()})]}):(0,U.jsx)(G,{type:`tertiary`,className:`chat-reasoning-channel-label`,children:l}),(0,U.jsx)(ie,{className:`chat-reasoning-slider`,"aria-label":r(`chat.reasoningEffortLabel`,null,`推理强度`),min:0,max:h.length-1,step:1,marks:g,showMarkLabel:!1,tipFormatter:e=>g[e],getAriaValueText:t=>e.mode===`off`&&!e.overrideBlocked?d.off:g[t],value:e.overrideBlocked?0:h.indexOf(e.effort),disabled:f||e.mode===`off`,onChange:t=>{e.setEffort(h[t]),e.setMode(t===0?`default`:e.mode===`auto`?`auto`:`on`)}}),e.overrideBlocked&&(0,U.jsx)(G,{type:`tertiary`,size:`small`,className:`chat-reasoning-hint`,children:r(`chat.reasoningOverrideBlocked`,null,`此通道使用系统设置中的推理强度。`)})]})}function Ze({onClose:e,narrow:t,canEnableHitl:n,conversationId:r,draftHitl:i,onDraftHitlChange:a}){let o=L(),s=o(`chat.hitlTitle`,null,`人机协同`),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(!1),g=(0,H.useRef)(0),_=(0,H.useRef)(i),v=(0,H.useId)(),y=(0,H.useId)();_.current=i;let b=be(()=>F.get(r?`/hitl/config/${encodeURIComponent(r)}`:`/hitl/default-config`),[r]);(0,H.useEffect)(()=>{b.data&&(p(Je(b.data,r,_.current)),h(!1))},[b.data,r]);let x={off:o(`chat.hitlModeOff`,null,`关闭`),approval:o(`chat.hitlModeApproval`,null,`审批模式`),review_edit:o(`chat.hitlModeReviewEdit`,null,`审查编辑`)},S={60:o(`chat.hitlTimeoutOneMinute`,null,`1 分钟`),300:o(`chat.hitlTimeoutFiveMinutes`,null,`5 分钟`),600:o(`chat.hitlTimeoutTenMinutes`,null,`10 分钟`),0:o(`chat.hitlTimeoutUnlimited`,null,`不限制`)},C=He.map(e=>({value:e,label:S[e]}));f&&!He.includes(f.timeoutSeconds)&&C.unshift({value:f.timeoutSeconds,label:`${f.timeoutSeconds}s`});let w=!n||c,T=async e=>{let t=++g.current,n=q(e);l(!0),d(!1);try{if(await F.put(`/hitl/config`,{conversationId:r,...n}),t!==g.current)return;b.setData(e=>({...e,hitl:n})),d(!0)}catch(e){t===g.current&&(z(e,o(`chat.hitlApplyFail`,null,`同步到服务器失败`)),b.reload({silent:!0}))}finally{t===g.current&&l(!1)}},E=e=>{let t={...f,...e};p(t),h(!1),d(!1),r?T(t):a(q(t))};return(0,U.jsx)(O,{visible:!0,title:s,"aria-label":s,width:t?`100%`:420,closable:!c,maskClosable:!c,closeOnEsc:!c,onCancel:e,children:(0,U.jsx)(`div`,{className:`chat-settings-fields`,children:(0,U.jsxs)(`section`,{className:`chat-setting-field chat-setting-hitl`,children:[(0,U.jsx)(G,{type:`tertiary`,size:`small`,children:o(`chat.sessionSettingsHint`,null,`人机协同设置只影响后续消息。`)}),(c||u)&&(0,U.jsx)(G,{type:`tertiary`,size:`small`,role:`status`,children:c?o(`chat.systemModelSaving`,null,`正在保存…`):o(`chat.hitlApplyOkSync`,null,`人机协同配置已保存并同步到服务器。`)}),(0,U.jsx)(Ce,{error:b.error,onRetry:()=>b.reload()}),b.loading&&(0,U.jsx)(ee,{}),f&&b.data&&!b.error&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ye,{label:o(`chat.hitlModeLabel`,null,`模式`),value:f.mode,optionList:Ve.map(e=>({value:e,label:x[e]})),onSelect:e=>E({mode:e}),disabled:w}),(0,U.jsxs)(`div`,{className:`chat-setting-field`,children:[(0,U.jsx)(G,{id:v,strong:!0,children:o(`chat.hitlReviewerLabel`,null,`审批方`)}),(0,U.jsx)(le,{"aria-labelledby":v,type:`button`,className:`chat-setting-reviewer`,value:f.reviewer,options:[{value:`human`,label:o(`chat.hitlReviewerHuman`,null,`人工审批`)},{value:`audit_agent`,label:o(`chat.hitlReviewerAgent`,null,`审计 Agent`)}],onChange:e=>E({reviewer:e.target.value}),disabled:w}),(0,U.jsx)(G,{type:`tertiary`,size:`small`,children:o(`chat.hitlReviewerHint`,null,`可在人工与审计 Agent 之间随时切换;规则与白名单不变。人机协同为「关闭」时也可预先选择。`)})]}),(0,U.jsx)(Ye,{label:o(`chat.hitlTimeoutLabel`,null,`审批等待时限`),value:f.timeoutSeconds,optionList:C,onSelect:e=>E({timeoutSeconds:Number(e)}),disabled:w}),(0,U.jsxs)(`div`,{className:`chat-setting-field`,children:[(0,U.jsx)(G,{id:y,strong:!0,children:o(`chat.hitlWhitelistTools`,null,`白名单工具(免审批,逗号分隔)`)}),(0,U.jsx)(he,{"aria-labelledby":y,value:f.sensitiveTools,placeholder:o(`chat.hitlWhitelistPlaceholder`,null,`例:read_file, grep 或每行一个工具名(与 config 全局白名单合并)`),rows:5,disabled:w,onChange:e=>{let t={...f,sensitiveTools:e};p(t),h(!0),d(!1),r||a(q(t))},onBlur:()=>{m&&r&&!w&&(h(!1),T(f))}}),(0,U.jsx)(G,{type:`tertiary`,size:`small`,children:o(`chat.hitlWhitelistHint`,null,`白名单内工具免审批;每行一个或逗号分隔,与 config 全局白名单合并。`)})]})]})]})})})}var{Text:Qe}=T;function $e({item:e,active:t,editing:n,editingTitle:r,onStartEdit:i,onEditingTitle:o,onCommitEdit:s,onCancelEdit:l,onSelect:u,onPin:f,onDelete:p,canWrite:h,canDelete:g,selected:v,onToggleSelect:y,batchMode:x}){let S=L(),C=String(e.title||S(`chat.untitled`,null,`未命名对话`));return(0,U.jsxs)(`div`,{className:`chat-conv-item ${t?`is-active`:``}`,children:[x&&(0,U.jsx)(_,{className:`chat-conv-check`,"aria-label":`${S(`chat.selectConversation`,null,`选择对话`)}:${C}`,checked:v,onChange:t=>y(e.id,t.target.checked)}),n?(0,U.jsxs)(`div`,{className:`chat-conv-edit`,children:[(0,U.jsx)(d,{size:`small`,"aria-label":S(`chat.renameConversationTitle`,null,`重命名`),value:r,autoFocus:!0,onChange:o,onEnterPress:s,onKeyDown:e=>{e.key===`Escape`&&l()}}),(0,U.jsxs)(`div`,{className:`chat-conv-edit-actions`,children:[(0,U.jsx)(m,{size:`small`,theme:`solid`,onClick:s,children:S(`common.save`,null,`保存`)}),(0,U.jsx)(m,{size:`small`,theme:`borderless`,onClick:l,children:S(`common.cancel`,null,`取消`)})]})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`button`,{type:`button`,className:`chat-conv-main`,"aria-current":t?`true`:void 0,title:C,onClick:()=>u(e.id),children:[(0,U.jsxs)(`span`,{className:`chat-conv-title`,children:[e.pinned&&(0,U.jsx)(M,{size:`small`,className:`chat-conv-pin`}),(0,U.jsx)(`span`,{className:`chat-conv-title-text`,children:C})]}),(0,U.jsx)(`span`,{className:`chat-conv-meta`,children:P(e.updatedAt||e.createdAt)})]}),!x&&(0,U.jsxs)(`div`,{className:`chat-conv-actions`,children:[h&&(0,U.jsx)(b,{content:S(`chat.renameConversationTitle`,null,`重命名`),children:(0,U.jsx)(m,{size:`small`,theme:`borderless`,"aria-label":S(`chat.renameConversationTitle`,null,`重命名`),icon:(0,U.jsx)(c,{}),onClick:()=>i(e)})}),h&&(0,U.jsx)(b,{content:e.pinned?S(`chat.unpin`,null,`取消置顶`):S(`chat.pin`,null,`置顶`),children:(0,U.jsx)(m,{size:`small`,theme:`borderless`,icon:(0,U.jsx)(M,{}),"aria-label":e.pinned?S(`chat.unpin`,null,`取消置顶`):S(`chat.pin`,null,`置顶`),type:e.pinned?`warning`:`tertiary`,onClick:()=>f(e)})}),g&&(0,U.jsx)(k,{title:S(`chat.deleteConversationConfirm`,null,`确认删除该对话?删除后不可恢复。`),onConfirm:()=>p(e),children:(0,U.jsx)(m,{size:`small`,theme:`borderless`,type:`danger`,"aria-label":S(`chat.deleteConversationTitle`,null,`删除对话`),icon:(0,U.jsx)(a,{})})})]})]})]})}function et({items:e,groups:t,expandedGroup:n,groupTotal:r,onToggleGroup:i,loading:a,error:o,onRetry:c,search:l,onSearch:u,projectId:p,onProjectChange:h,projects:g,page:v,pageSize:y,onPageChange:b,selectedId:ee,onSelect:w,onCreate:T,onRename:E,onPin:te,onDelete:D,onBatchDelete:ne,canWrite:ie,canDelete:ae}){let O=L(),k=e,oe=(0,H.useId)(),[se,le]=(0,H.useState)(``),[ue,fe]=(0,H.useState)(``),[A,pe]=(0,H.useState)(!1),[M,N]=(0,H.useState)([]),he=k.length>0&&k.every(e=>M.includes(e.id)),ge=!he&&k.some(e=>M.includes(e.id));(0,H.useEffect)(()=>{N([]),pe(!1)},[v,p,l,n]);let _e=(0,H.useMemo)(()=>[{value:``,label:O(`chat.filterAllProjects`,null,`全部项目`)},...(Array.isArray(g)?g:[]).map(e=>({value:e.id,label:e.name||e.id}))],[g,O]),P=(e,t)=>{N(n=>t?[...new Set([...n,e])]:n.filter(t=>t!==e))},ve=e=>{le(e.id),fe(String(e.title||``))},F=()=>{let e=se,t=ue.trim();le(``),e&&t&&E(e,t)},I=(0,U.jsxs)(U.Fragment,{children:[a&&!k.length&&(0,U.jsx)(f,{placeholder:(0,U.jsx)(f.Paragraph,{rows:6}),loading:!0}),!a&&!o&&!k.length&&(0,U.jsx)(C,{title:O(`chat.noHistoryConversations`,null,`暂无历史对话`),description:null,className:`chat-sidebar-empty`}),(0,U.jsx)(S,{dataSource:k,split:!1,renderItem:e=>(0,U.jsx)($e,{item:e,active:e.id===ee,editing:se===e.id,editingTitle:ue,onStartEdit:ve,onEditingTitle:fe,onCommitEdit:F,onCancelEdit:()=>le(``),onSelect:w,onPin:te,onDelete:D,canWrite:ie,canDelete:ae,batchMode:A,selected:M.includes(e.id),onToggleSelect:P},e.id)})]});return(0,U.jsxs)(`div`,{className:`chat-sidebar-inner`,children:[(0,U.jsxs)(`div`,{className:`chat-sidebar-head`,children:[(0,U.jsx)(Qe,{strong:!0,className:`chat-sidebar-title`,children:O(`chat.conversations`,null,`会话`)}),(0,U.jsx)(m,{icon:(0,U.jsx)(ce,{}),theme:`borderless`,className:`chat-new-chat`,onClick:T,disabled:!ie,children:O(`chat.newChat`,null,`新建对话`)})]}),(0,U.jsxs)(`div`,{className:`chat-sidebar-filters`,children:[(0,U.jsx)(d,{prefix:(0,U.jsx)(de,{}),"aria-label":O(`chat.searchHistory`,null,`搜索历史对话`),placeholder:O(`chat.searchHistory`,null,`搜索历史对话`),value:l,onChange:u,showClear:!0}),(0,U.jsx)(me,{value:p,optionList:_e,onChange:h,className:`chat-sidebar-project`,"aria-label":O(`chat.filterByProject`,null,`按项目过滤`),placeholder:O(`chat.filterByProject`,null,`按项目过滤`)})]}),(0,U.jsxs)(`div`,{className:`chat-sidebar-tools`,children:[(0,U.jsxs)(Qe,{type:`tertiary`,size:`small`,children:[O(`chat.recentConversations`,null,`最近对话`),` · `,t.reduce((e,t)=>e+t.total,0)]}),(0,U.jsxs)(`div`,{className:`chat-sidebar-tools-actions`,children:[ae&&k.length>0&&(0,U.jsx)(m,{size:`small`,theme:A?`solid`:`borderless`,onClick:()=>{pe(!A),N([])},children:A?O(`common.cancel`,null,`取消`):O(`chat.batchManage`,null,`批量管理`)}),(0,U.jsx)(m,{size:`small`,theme:`borderless`,"aria-label":O(`chat.refreshConversationList`,null,`刷新会话列表`),title:O(`chat.refreshConversationList`,null,`刷新会话列表`),icon:(0,U.jsx)(j,{}),onClick:c})]})]}),A&&(0,U.jsxs)(`div`,{className:`chat-batch-bar`,children:[(0,U.jsx)(_,{className:`chat-batch-select-all`,checked:he,indeterminate:ge,disabled:a||!k.length,onChange:e=>N(e.target.checked?k.map(e=>e.id):[]),children:O(`chat.selectPage`,null,`全选本页`)}),(0,U.jsxs)(Qe,{size:`small`,children:[O(`chat.selectedCount`,null,`已选`),` `,M.length]}),(0,U.jsx)(m,{size:`small`,type:`danger`,disabled:!M.length,onClick:async()=>{await ne(M),N([]),pe(!1)},children:O(`chat.batchDelete`,null,`批量删除`)})]}),(0,U.jsxs)(`div`,{className:`chat-conv-list`,children:[(0,U.jsx)(Ce,{error:o,onRetry:c}),!t.length&&!a&&!o&&(0,U.jsx)(C,{title:O(`chat.noHistoryConversations`,null,`暂无历史对话`),description:null,className:`chat-sidebar-empty`}),t.map(e=>{let t=e.id===n,r=oe+`-`+e.id;return(0,U.jsxs)(`div`,{className:`chat-conv-group`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`chat-conv-group-toggle`,"aria-expanded":t,"aria-controls":r,title:e.projectId?e.title+` · `+e.projectId:e.title,onClick:()=>i(e.id),children:[(0,U.jsx)(s,{"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`chat-conv-group-name`,children:e.title}),(0,U.jsx)(`span`,{className:`chat-conv-group-count`,children:e.total}),(0,U.jsx)(x,{"aria-hidden":`true`,className:`chat-conv-group-chevron`})]}),(0,U.jsx)(`div`,{id:r,className:`chat-conv-group-content`,hidden:!t,children:t&&I})]},e.id)})]}),n&&r>y&&(0,U.jsx)(`div`,{className:`chat-sidebar-pager`,children:(0,U.jsx)(re,{size:`small`,total:r,pageSize:y,currentPage:v,onPageChange:b,showSizeChanger:!1})})]})}var tt=new Set([`taskcreate`,`taskupdate`,`tasklist`,`taskget`,`write_todos`]),nt=new Set([`heartbeat`,`response_delta`,`thinking_stream_delta`,`reasoning_chain_stream_delta`,`tool_result_delta`]),rt=200,it=2e4;function J(e){return e==null?``:String(e)}function at(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function Y(e,t=it){let n=J(e);return n.length<=t?n:`${n.slice(0,t)}\n…(已截断,共 ${n.length} 字符)`}function ot(e,t=6e3){if(e==null)return``;try{return Y(typeof e==`string`?e:JSON.stringify(e,null,2),t)}catch{return Y(String(e),t)}}function X({conversationId:e=``,id:t}={}){return{id:t||`live-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,conversationId:e,status:`streaming`,text:``,blocks:[],events:[],error:``,notice:``,statusText:``,messageId:``,userMessageId:``,finalizable:null,startedAt:Date.now(),endedAt:0,seq:0}}function Z(e,t){return e.seq+=1,`${t}-${e.seq}`}function Q(e,t){let n=J(t.type);nt.has(n)||(e.events.push({at:Date.now(),type:n,message:J(t.message),data:t.data===void 0?null:t.data}),e.events.length>rt&&e.events.splice(0,e.events.length-rt))}function $(e,{title:t,message:n,tone:r=`info`,data:i=null}){let a=e.blocks[e.blocks.length-1];if(a&&a.kind===`note`&&a.title===t&&a.message===J(n))return a;let o={kind:`note`,id:Z(e,`note`),title:t,message:Y(n),tone:r,data:i};return e.blocks.push(o),o}function st(e,t,n=`thinking`){let r=J(t)||Z(e,`reasoning`),i=r?e.blocks.find(e=>e.kind===`reasoning`&&e.key===r):null;return i||(i={kind:`reasoning`,id:Z(e,`reason`),key:r,stream:J(t),label:n,text:``},e.blocks.push(i)),i}function ct(e,t){let n=J(t.toolCallId),r=null;return n&&(r=e.blocks.find(e=>e.kind===`tool`&&e.toolCallId===n)),r||(r={kind:`tool`,id:Z(e,`tool`),toolCallId:n,toolName:J(t.toolName)||`未知工具`,args:null,result:``,status:`running`,processDetailId:J(t.processDetailId),agentName:J(t.agentName)},e.blocks.push(r)),t.toolName&&(r.toolName===`未知工具`||!r.toolName)&&(r.toolName=J(t.toolName)),t.agentName&&!r.agentName&&(r.agentName=J(t.agentName)),t.processDetailId&&!r.processDetailId&&(r.processDetailId=J(t.processDetailId)),r}function lt(e){let t=J(e.displayStatus||e.status).toLowerCase();return t===`cancelled`||t===`canceled`?`cancelled`:t===`background_running`?`running`:t===`blocked`?`blocked`:e.isError===!0||e.success===!1?`failed`:`success`}function ut(e,t){if(!e||!t||typeof t!=`object`)return e;let n=J(t.type),r=at(t.data)||{};switch(Q(e,t),n){case`heartbeat`:break;case`conversation`:r.conversationId&&(e.conversationId=J(r.conversationId));break;case`message_saved`:r.userMessageId&&(e.userMessageId=J(r.userMessageId));break;case`progress`:e.statusText=J(t.message)||e.statusText;break;case`iteration`:{let n=Number(r.iteration)||1,i=J(r.piScope).trim(),a=J(r.agentName).trim(),o=i===`main`?a?`主代理 · ${a}`:`主代理`:i===`sub`?`子代理${a?` · ${a}`:``}`:``;e.blocks.push({kind:`iteration`,id:Z(e,`iter`),title:`第 ${n} 轮迭代${o?` · ${o}`:``}`,message:Y(t.message,2e3)});break}case`thinking_stream_start`:case`reasoning_chain_stream_start`:{let t=st(e,r.streamId,n===`reasoning_chain_stream_start`?`reasoning_chain`:`thinking`);t.text=``;break}case`thinking_stream_delta`:case`reasoning_chain_stream_delta`:{let i=st(e,r.streamId,n===`reasoning_chain_stream_delta`?`reasoning_chain`:`thinking`),a=typeof r.accumulated==`string`?r.accumulated:null;i.text=Y(a===null?i.text+J(t.message):a);break}case`thinking`:case`reasoning_chain`:if(r.streamId){let i=st(e,r.streamId,n===`reasoning_chain`?`reasoning_chain`:`thinking`);J(t.message)&&(i.text=Y(t.message));break}e.blocks.push({kind:`reasoning`,id:Z(e,`reason`),key:Z(e,`reasonkey`),stream:``,label:n===`reasoning_chain`?`reasoning_chain`:`thinking`,text:Y(t.message)});break;case`response_start`:r.conversationId&&(e.conversationId=J(r.conversationId)),e.statusText||(e.statusText=`正在生成回复…`);break;case`response_delta`:{let n=typeof r.accumulated==`string`?r.accumulated:null;e.text=Y(n===null?e.text+J(t.message):n,6e4);break}case`response`:{let n=J(t.message);n&&(e.text=Y(n,6e4)),r.messageId&&(e.messageId=J(r.messageId)),r.conversationId&&(e.conversationId=J(r.conversationId)),r.finalizable===!1?e.finalizable=!1:r.finalizable===!0&&(e.finalizable=!0);break}case`tool_call`:{let t=ct(e,r);t.args=r.argumentsObj===void 0?r.arguments===void 0?t.args:r.arguments:r.argumentsObj;break}case`tool_result`:{let n=ct(e,r);n.status=lt(r),n.result=Y((r.resultPreview===void 0?r.result:r.resultPreview)??t.message,8e3);break}case`tool_calls_detected`:$(e,{title:`🔧 检测到工具调用`,message:t.message,data:r});break;case`hitl_interrupt`:$(e,{title:`🧑⚖️ 等待人工审批`,message:`${J(r.toolName)||`工具`} · ${J(t.message)||`命中审批策略`}`,tone:`warning`,data:r});break;case`hitl_resumed`:$(e,{title:`✅ 审批通过`,message:J(t.message),tone:`success`,data:r});break;case`hitl_rejected`:$(e,{title:`⛔ 审批被拒绝`,message:J(t.message),tone:`danger`,data:r});break;case`hitl_audit_agent_started`:$(e,{title:`🛡 审计代理审查中`,message:J(t.message),tone:`info`,data:r});break;case`hitl_audit_agent`:$(e,{title:`🛡 审计代理已裁决`,message:`${J(r.decision)||`-`}${r.comment?` · ${J(r.comment)}`:``}`,tone:`info`,data:r});break;case`warning`:case`iteration_limit_reached`:case`pi_pending_orphaned`:$(e,{title:`⚠️ ${J(t.message)||`提示`}`,message:J(t.message),tone:`warning`,data:r});break;case`finalization_check`:$(e,{title:`🔎 最终化校验未通过`,message:J(t.message),tone:`warning`,data:r}),r.finalizable===!1&&(e.finalizable=!1);break;case`finalization_auto_continue`:case`finalization_pending_tools_cancelled`:case`agent_empty_response_continue`:case`agent_run_retry`:case`pi_model_retry`:case`pi_model_failover`:case`pi_stream_error`:$(e,{title:J(t.message)||`运行提示`,message:J(t.message),tone:`warning`,data:r});break;case`agent_usage_summary`:e.blocks.push({kind:`usage`,id:Z(e,`usage`),data:r});break;case`user_interrupt_continue`:$(e,{title:`⏸️ 用户中断并继续`,message:J(t.message),tone:`info`,data:r});break;case`agent_reply`:$(e,{title:`💬 ${J(r.agentName)||`子代理`}回复`,message:J(t.message),data:r});break;case`workflow_start`:case`workflow_done`:case`workflow_node_start`:case`workflow_node_result`:case`workflow_branch_taken`:case`workflow_branch_skipped`:case`workflow_tool_start`:case`workflow_agent_output`:case`workflow_hitl_checkpoint`:case`workflow_hitl_waiting`:case`workflow_hitl_resumed`:case`workflow_hitl_rejected`:case`workflow_paused`:$(e,{title:`🧭 ${J(t.message)||n}`,message:J(t.message),data:r});break;case`cancelled`:e.status=`cancelled`,e.notice=J(t.message)||`任务已取消`,e.endedAt=Date.now();break;case`error`:e.status=`error`,e.error=J(t.message)||`执行失败`,e.endedAt=Date.now();break;case`done`:e.status===`streaming`&&(e.status=r.status===`blocked`||e.finalizable===!1?`blocked`:`done`),r.workflowStatus===`awaiting_hitl`&&(e.statusText=`工作流等待审批`),e.endedAt=Date.now()}return e}var dt={streaming:{label:`生成中`,color:`blue`},done:{label:`已完成`,color:`green`},blocked:{label:`未完成`,color:`orange`},disconnected:{label:`连接已结束`,color:`grey`},error:{label:`失败`,color:`red`},cancelled:{label:`已取消`,color:`grey`}};function ft(e){let t=[],n=0,r=e=>(n+=1,`h-${e}-${n}`),i=J(e?.reasoningContent).trim();i&&t.push({kind:`reasoning`,id:r(`reason`),key:`reasoningContent`,stream:``,label:`thinking`,text:Y(i)});let a=Array.isArray(e?.processDetails)?e.processDetails:[],o=new Map;return a.forEach(e=>{let n=J(e?.eventType),i=at(e?.data)||{},a=J(e?.message);switch(n){case`iteration`:{let e=Number(i.iteration)||1,n=J(i.piScope).trim(),o=J(i.agentName).trim();t.push({kind:`iteration`,id:r(`iter`),title:`第 ${e} 轮迭代${n===`main`?` · 主代理`:n===`sub`?` · 子代理`:``}${o?` · ${o}`:``}`,message:Y(a,2e3)});break}case`thinking`:case`reasoning_chain`:if(!a.trim())break;t.push({kind:`reasoning`,id:r(`reason`),key:J(i.streamId)||r(`reasonkey`),stream:J(i.streamId),label:n,text:Y(a)});break;case`tool_call`:{let n=J(i.toolCallId),a={kind:`tool`,id:r(`tool`),toolCallId:n,toolName:J(i.toolName)||`未知工具`,args:i.argumentsObj===void 0?i.arguments===void 0?null:i.arguments:i.argumentsObj,result:``,status:`running`,processDetailId:J(e?.id),agentName:J(i.agentName)};n&&o.set(n,a),t.push(a);break}case`tool_result`:{let e=J(i.toolCallId),n=e?o.get(e):null;n||(n={kind:`tool`,id:r(`tool`),toolCallId:e,toolName:J(i.toolName)||`未知工具`,args:null,result:``,status:`running`,processDetailId:``,agentName:J(i.agentName)},e&&o.set(e,n),t.push(n)),n.status=lt(i);let s=i.resultPreview===void 0?i.result:i.resultPreview;n.result=Y(s??a,8e3);break}case`planning`:if(!a.trim())break;t.push({kind:`note`,id:r(`note`),title:`📝 规划`,message:Y(a,4e3),tone:`info`,data:null});break;case`hitl_interrupt`:case`hitl_resumed`:case`hitl_rejected`:case`hitl_audit_agent`:case`hitl_audit_agent_started`:{let e=n===`hitl_rejected`?`danger`:n===`hitl_resumed`?`success`:`info`,o=n===`hitl_interrupt`?`🧑⚖️ 人工审批`:n===`hitl_rejected`?`⛔ 审批被拒绝`:n===`hitl_resumed`?`✅ 审批通过`:`🛡 审计代理`;t.push({kind:`note`,id:r(`note`),title:o,message:`${a}${i.toolName?` · ${J(i.toolName)}`:``}${i.decision?` · ${J(i.decision)}`:``}`,tone:e,data:null});break}case`error`:case`timeout`:case`cancelled`:t.push({kind:`note`,id:r(`note`),title:n===`cancelled`?`⏹ 已取消`:`❌ 执行异常`,message:a,tone:`danger`,data:null});break;case`agent_reply`:t.push({kind:`note`,id:r(`note`),title:`💬 子代理回复`,message:Y(a,6e3),tone:`info`,data:null});break;case`agent_usage_summary`:t.push({kind:`usage`,id:r(`usage`),data:i});break;case`progress`:break;default:(a.trim()||Object.keys(i).length)&&t.push({kind:`note`,id:r(`note`),title:J(n)||`过程事件`,message:Y(a,4e3),tone:`info`,data:Object.keys(i).length?i:null})}}),t}var{Text:pt}=T,mt={running:{color:`blue`,label:`执行中`},success:{color:`green`,label:`完成`},failed:{color:`red`,label:`失败`},cancelled:{color:`grey`,label:`已取消`},blocked:{color:`orange`,label:`已拦截`}};function ht({block:e,defaultOpen:t}){let n=e.text||``;if(!n.trim())return null;let r=e.label===`reasoning_chain`?`🔗 推理过程`:`🤔 思考过程`;return(0,U.jsx)(i,{className:`chat-block-collapse`,defaultActiveKey:t?[`1`]:[],children:(0,U.jsx)(i.Panel,{itemKey:`1`,header:(0,U.jsxs)(`span`,{className:`chat-block-title`,children:[r,` · `,n.length,` 字符`]}),children:(0,U.jsx)(`pre`,{className:`chat-pre`,children:Y(n)})})})}function gt({block:e}){let t=mt[e.status]||mt.running,n=ot(e.args),r=e.result||``,a=!!(n||r),o=(0,U.jsxs)(`span`,{className:`chat-tool-head`,children:[(0,U.jsxs)(`span`,{className:`chat-tool-name`,children:[e.agentName?`${e.agentName} · `:``,e.toolName||`未知工具`]}),(0,U.jsx)(h,{size:`small`,color:t.color,shape:`circle`,children:t.label})]});return a?(0,U.jsx)(`div`,{className:`chat-tool`,children:(0,U.jsx)(i,{className:`chat-block-collapse`,children:(0,U.jsxs)(i.Panel,{itemKey:`1`,header:o,children:[n&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(pt,{type:`tertiary`,size:`small`,children:`参数`}),(0,U.jsx)(`pre`,{className:`chat-pre`,children:n})]}),r&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(pt,{type:`tertiary`,size:`small`,children:`结果`}),(0,U.jsx)(`pre`,{className:`chat-pre`,children:r})]})]})})}):(0,U.jsx)(`div`,{className:`chat-tool`,children:(0,U.jsx)(`div`,{className:`chat-tool-head-row`,children:o})})}function _t({block:e}){let[t,n]=(0,H.useState)(!1),r=e.tone||`info`;return(0,U.jsxs)(`div`,{className:`chat-note chat-note-${r}`,children:[(0,U.jsxs)(`div`,{className:`chat-note-head`,children:[(0,U.jsx)(`span`,{className:`chat-note-title`,children:e.title}),e.data&&(0,U.jsx)(`button`,{type:`button`,className:`chat-link-btn`,onClick:()=>n(!t),children:t?`收起 JSON`:`查看 JSON`})]}),e.message&&(0,U.jsx)(`div`,{className:`chat-note-body`,children:e.message}),t&&e.data&&(0,U.jsx)(Ee,{value:e.data,collapsed:!1,title:`事件数据`})]})}function vt({data:e}){let{t,lang:n}=I(),r=e=>_e(Math.max(0,Math.trunc(Number(e)||0)),n),i=[[`chat.piUsageModelCalls`,e.modelCalls],[`chat.piUsagePromptTokens`,e.promptTokens],[`chat.piUsageCompletionTokens`,e.completionTokens],[`chat.piUsageTotalTokens`,e.totalTokens]],a=[[`chat.piUsageCachedTokens`,e.cachedTokens],[`chat.piUsageCacheWriteTokens`,e.cacheWriteTokens],[`chat.piUsageReasoningTokens`,e.reasoningTokens]],o=[...i,...a.filter(([,e])=>Number(e)>0)].map(([e,n])=>`${t(e)}: ${r(n)}`).join(`
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{A as i,At as a,C as o,Ct as s,Dt as c,F as l,G as u,H as d,I as f,It as p,L as m,M as h,Mt as g,N as _,P as v,Pt as y,Qt as b,Rt as x,S,T as C,U as ee,V as w,W as T,Wt as E,Y as te,Yt as D,Z as ne,_ as re,d as ie,et as ae,f as O,g as k,h as oe,kt as se,lt as ce,m as le,nt as ue,ot as de,pt as fe,q as A,qt as pe,st as j,tt as M,ut as N,v as me,x as he,z as ge}from"./semi-Dpcldp_F.js";import{D as _e,E as P,F as ve,I as F,N as I,P as L,R as ye,S as R,a as be,b as z,f as xe,i as Se,l as Ce,n as we,o as B,r as Te,u as Ee,x as De,y as Oe,z as V}from"./index-BMTtTYg1.js";import{t as ke}from"./project-form-nknm1nA2.js";import{n as Ae,r as je,t as Me}from"./model-channel-mQ6lfvSO.js";var H=e(t(),1),U=e(n(),1),{Text:Ne,Title:W}=T,Pe={single:{key:`chat.agentModePiSingle`,label:`单代理`,color:`blue`},deep:{key:`chat.agentModeDeep`,label:`Deep`,color:`purple`},plan_execute:{key:`chat.agentModePlanExecuteLabel`,label:`Plan-Execute`,color:`orange`},supervisor:{key:`chat.agentModeSupervisorLabel`,label:`Supervisor`,color:`green`}};function Fe({conversation:e,mode:t,hitlCount:n,conversationId:r,narrow:i,onToggleSidebar:a,onRefresh:o}){let s=L(),c=Pe[t]||Pe.single,u=e?.title||s(`chat.newChat`,null,`新对话`);return(0,U.jsxs)(`header`,{className:`chat-header`,children:[(0,U.jsxs)(`div`,{className:`chat-header-main`,children:[(0,U.jsxs)(`div`,{className:`chat-header-heading`,children:[(0,U.jsx)(W,{heading:3,className:`chat-header-title`,title:u,children:u}),(0,U.jsxs)(l,{spacing:6,wrap:!0,className:`chat-header-tags`,children:[e?.pinned&&(0,U.jsx)(h,{size:`small`,color:`amber`,children:s(`chat.pinned`,null,`已置顶`)}),(0,U.jsx)(h,{size:`small`,color:c.color,children:s(c.key,null,c.label)}),n>0&&(0,U.jsx)(h,{size:`small`,color:`orange`,children:s(`chat.pendingApprovals`,{count:n},`待审批 ${n}`)})]})]}),(0,U.jsx)(Ne,{type:`tertiary`,size:`small`,className:`chat-header-description`,children:r?s(`chat.conversationHint`,null,`会话历史与工具执行过程会自动落库`):s(`chat.newConversationHint`,null,`输入内容即可创建新对话`)})]}),(0,U.jsxs)(l,{spacing:8,wrap:!0,className:`chat-header-actions`,children:[i&&(0,U.jsx)(m,{icon:(0,U.jsx)(fe,{}),onClick:a,children:s(`chat.conversations`,null,`会话`)}),r&&(0,U.jsx)(m,{theme:`borderless`,type:`tertiary`,icon:(0,U.jsx)(j,{"aria-hidden":`true`}),title:s(`chat.refreshConversationHint`,null,`重新读取会话列表、消息、待审批项和执行计划`),onClick:o,children:s(`chat.refreshConversation`,null,`刷新对话`)})]})]})}var Ie=[`default`,`off`,`on`,`auto`],Le=[`low`,`medium`,`high`,`xhigh`,`max`];function Re(e,t,n){return t!==`off`&&n?e(`chat.reasoningEffortLabels.${n}`,null,{low:`低`,medium:`中`,high:`高`,xhigh:`超高`,max:`ultra`}[n]):e(`chat.reasoningMode${t[0].toUpperCase()}${t.slice(1)}`,null,{default:`跟随系统`,off:`关闭`,on:`开启`,auto:`自动`}[t])}function ze(e,t){let[n,r]=(0,H.useState)(()=>{try{return localStorage.getItem(e)??t}catch{return t}});return[n,t=>{r(t);try{localStorage.setItem(e,t)}catch{}}]}function Be(e){let[t,n]=ze(`cyberstrike-chat-ai-channel`,``),[r,i]=ze(`cyberstrike-chat-reasoning-mode`,`default`),[a,o]=ze(`cyberstrike-chat-reasoning-effort`,``),s=be(async()=>(await F.get(`/config`))?.ai,[e],{skip:!e}),c=Object.entries(s.data?.channels||{}).sort(([e],[t])=>e.localeCompare(t)),l=t.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``),u=c.find(([e])=>e===t)?.[0]||c.find(([e])=>e===l)?.[0]||``,d=(s.data?.channels?.[u||s.data?.default_channel])?.reasoning?.allow_client_reasoning===!1,f=Ie.includes(r)?r:`default`,p=Le.includes(a)?a:``,m={mode:f==="default"?void 0:f,effort:f===`off`?void 0:p||void 0};return{channel:u,channels:c,setChannel:n,config:s,mode:f,setMode:i,effort:p,setEffort:o,overrideBlocked:d,waitingForChannel:!!(e&&t&&s.loading),request:{aiChannelId:e&&u||void 0,reasoning:m.mode||m.effort?m:void 0}}}var{Text:G}=T,Ve=[`off`,`approval`,`review_edit`],He=[60,300,600,0],Ue=`tool_search, skill, task, write_todos, transfer_to_agent, exit, TaskCreate, TaskGet, TaskUpdate, TaskList, upsert_project_fact, get_project_fact`;function We(e,t){return t===!1?`off`:Ve.includes(e)?e:`off`}function Ge(e){return e===`audit_agent`?`audit_agent`:`human`}function Ke(e,t=300){if(e==null||e===``)return t;let n=Number(e);return Number.isFinite(n)?Math.max(0,Math.min(86400,Math.round(n))):t}function K(e){return(Array.isArray(e)?e:String(e||``).split(/[,\n\r]+/)).map(e=>String(e||``).trim()).filter(Boolean)}function qe(e,t){let n=new Set(K(t).map(e=>e.toLowerCase()));return K(e).filter(e=>!n.has(e.toLowerCase())).join(`, `)}function Je(e,t,n){if(n)return{mode:We(n.mode,n.enabled),reviewer:Ge(n.reviewer),timeoutSeconds:Ke(n.timeoutSeconds),sensitiveTools:K(n.sensitiveTools).join(`, `)};let r=t?e?.hitl:null;return{mode:t?We(r?.mode,r?.enabled):We(e?.defaultMode),reviewer:Ge(t?r?.reviewer:e?.defaultReviewer),timeoutSeconds:Ke(t?r?.timeoutSeconds??e?.defaultTimeoutSeconds:e?.defaultTimeoutSeconds),sensitiveTools:t?qe(r?.sensitiveTools,e?.hitlGlobalToolWhitelist):Ue}}function q(e){return{enabled:e.mode!==`off`,mode:e.mode,reviewer:e.reviewer,sensitiveTools:K(e.sensitiveTools),timeoutSeconds:e.timeoutSeconds}}function Ye({label:e,...t}){let n=(0,H.useId)();return(0,U.jsxs)(`div`,{className:`chat-setting-field`,children:[(0,U.jsx)(G,{id:n,strong:!0,children:e}),(0,U.jsx)(me,{"aria-labelledby":n,...t})]})}function Xe({model:e,busy:t,canReadConfig:n}){let r=L(),i=(0,H.useId)(),a=(0,H.useRef)(null),s=e.config.data?.default_channel,c=s?Me(s,e.config.data?.channels?.[s]):``,l=r(`chat.aiChannelDefault`,null,`跟随默认通道`),u=[{value:``,label:c?`${l} · ${c}`:l},...Ae(e.channels)],d=Object.fromEntries(Ie.map(e=>[e,Re(r,e,``)])),f=t||e.overrideBlocked,h=[``,...Le],g=Object.fromEntries(h.map((e,t)=>[t,Re(r,e?`on`:`default`,e)])),_=()=>{e.setMode(`default`),e.setEffort(``)};return(0,U.jsxs)(`div`,{className:`chat-reasoning-picker${!e.overrideBlocked&&e.mode!==`off`&&e.effort===`max`?` is-max`:``}${f?` is-disabled`:``}`,ref:a,children:[(0,U.jsxs)(`div`,{className:`chat-reasoning-heading`,children:[(0,U.jsx)(o,{trigger:`click`,position:`bottomLeft`,className:`chat-reasoning-mode-menu`,getPopupContainer:()=>a.current,showTick:!0,menu:Ie.map(t=>({node:`item`,name:d[t],active:e.mode===t,disabled:f,onClick:()=>t==="default"?_():e.setMode(t)})),children:(0,U.jsx)(m,{theme:`borderless`,type:`tertiary`,icon:(0,U.jsx)(E,{}),className:`chat-reasoning-mode`,"aria-label":r(`chat.reasoningModeLabel`,null,`模型推理`),title:`${r(`chat.reasoningModeLabel`,null,`模型推理`)} · ${d[e.overrideBlocked?`default`:e.mode]}`,disabled:f})}),(0,U.jsx)(G,{strong:!0,className:`chat-reasoning-value`,role:`status`,children:e.overrideBlocked?d.default:Re(r,e.mode,e.effort)}),(0,U.jsx)(m,{theme:`borderless`,type:`tertiary`,icon:(0,U.jsx)(te,{}),"aria-label":r(`chat.reasoningReset`,null,`重置推理设置`),title:r(`chat.reasoningReset`,null,`重置推理设置`),disabled:f,onClick:_})]}),n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{id:i,hidden:!0,children:r(`chat.aiChannelLabel`,null,`AI 通道`)}),(0,U.jsx)(me,{className:`chat-reasoning-channel`,"aria-labelledby":i,value:e.channel,optionList:u,renderSelectedItem:e=>e.value===``?c||r(`chat.aiChannelDefaultShort`,null,`默认通道`):je(e),arrowIcon:(0,U.jsx)(p,{size:`small`}),borderless:!0,onSelect:e.setChannel,dropdownMatchSelectWidth:!1,dropdownStyle:{maxWidth:`calc(100vw - 32px)`},loading:e.config.loading,disabled:t||e.config.loading||!!e.config.error}),(0,U.jsx)(Ce,{error:e.config.error,onRetry:()=>e.config.reload()})]}):(0,U.jsx)(G,{type:`tertiary`,className:`chat-reasoning-channel-label`,children:l}),(0,U.jsx)(ie,{className:`chat-reasoning-slider`,"aria-label":r(`chat.reasoningEffortLabel`,null,`推理强度`),min:0,max:h.length-1,step:1,marks:g,showMarkLabel:!1,tipFormatter:e=>g[e],getAriaValueText:t=>e.mode===`off`&&!e.overrideBlocked?d.off:g[t],value:e.overrideBlocked?0:h.indexOf(e.effort),disabled:f||e.mode===`off`,onChange:t=>{e.setEffort(h[t]),e.setMode(t===0?`default`:e.mode===`auto`?`auto`:`on`)}}),e.overrideBlocked&&(0,U.jsx)(G,{type:`tertiary`,size:`small`,className:`chat-reasoning-hint`,children:r(`chat.reasoningOverrideBlocked`,null,`此通道使用系统设置中的推理强度。`)})]})}function Ze({onClose:e,narrow:t,canEnableHitl:n,conversationId:r,draftHitl:i,onDraftHitlChange:a}){let o=L(),s=o(`chat.hitlTitle`,null,`人机协同`),[c,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(!1),g=(0,H.useRef)(0),_=(0,H.useRef)(i),v=(0,H.useId)(),y=(0,H.useId)();_.current=i;let b=be(()=>F.get(r?`/hitl/config/${encodeURIComponent(r)}`:`/hitl/default-config`),[r]);(0,H.useEffect)(()=>{b.data&&(p(Je(b.data,r,_.current)),h(!1))},[b.data,r]);let x={off:o(`chat.hitlModeOff`,null,`关闭`),approval:o(`chat.hitlModeApproval`,null,`审批模式`),review_edit:o(`chat.hitlModeReviewEdit`,null,`审查编辑`)},S={60:o(`chat.hitlTimeoutOneMinute`,null,`1 分钟`),300:o(`chat.hitlTimeoutFiveMinutes`,null,`5 分钟`),600:o(`chat.hitlTimeoutTenMinutes`,null,`10 分钟`),0:o(`chat.hitlTimeoutUnlimited`,null,`不限制`)},C=He.map(e=>({value:e,label:S[e]}));f&&!He.includes(f.timeoutSeconds)&&C.unshift({value:f.timeoutSeconds,label:`${f.timeoutSeconds}s`});let w=!n||c,T=async e=>{let t=++g.current,n=q(e);l(!0),d(!1);try{if(await F.put(`/hitl/config`,{conversationId:r,...n}),t!==g.current)return;b.setData(e=>({...e,hitl:n})),d(!0)}catch(e){t===g.current&&(z(e,o(`chat.hitlApplyFail`,null,`同步到服务器失败`)),b.reload({silent:!0}))}finally{t===g.current&&l(!1)}},E=e=>{let t={...f,...e};p(t),h(!1),d(!1),r?T(t):a(q(t))};return(0,U.jsx)(O,{visible:!0,title:s,"aria-label":s,width:t?`100%`:420,closable:!c,maskClosable:!c,closeOnEsc:!c,onCancel:e,children:(0,U.jsx)(`div`,{className:`chat-settings-fields`,children:(0,U.jsxs)(`section`,{className:`chat-setting-field chat-setting-hitl`,children:[(0,U.jsx)(G,{type:`tertiary`,size:`small`,children:o(`chat.sessionSettingsHint`,null,`人机协同设置只影响后续消息。`)}),(c||u)&&(0,U.jsx)(G,{type:`tertiary`,size:`small`,role:`status`,children:c?o(`chat.systemModelSaving`,null,`正在保存…`):o(`chat.hitlApplyOkSync`,null,`人机协同配置已保存并同步到服务器。`)}),(0,U.jsx)(Ce,{error:b.error,onRetry:()=>b.reload()}),b.loading&&(0,U.jsx)(ee,{}),f&&b.data&&!b.error&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ye,{label:o(`chat.hitlModeLabel`,null,`模式`),value:f.mode,optionList:Ve.map(e=>({value:e,label:x[e]})),onSelect:e=>E({mode:e}),disabled:w}),(0,U.jsxs)(`div`,{className:`chat-setting-field`,children:[(0,U.jsx)(G,{id:v,strong:!0,children:o(`chat.hitlReviewerLabel`,null,`审批方`)}),(0,U.jsx)(le,{"aria-labelledby":v,type:`button`,className:`chat-setting-reviewer`,value:f.reviewer,options:[{value:`human`,label:o(`chat.hitlReviewerHuman`,null,`人工审批`)},{value:`audit_agent`,label:o(`chat.hitlReviewerAgent`,null,`审计 Agent`)}],onChange:e=>E({reviewer:e.target.value}),disabled:w}),(0,U.jsx)(G,{type:`tertiary`,size:`small`,children:o(`chat.hitlReviewerHint`,null,`可在人工与审计 Agent 之间随时切换;规则与白名单不变。人机协同为「关闭」时也可预先选择。`)})]}),(0,U.jsx)(Ye,{label:o(`chat.hitlTimeoutLabel`,null,`审批等待时限`),value:f.timeoutSeconds,optionList:C,onSelect:e=>E({timeoutSeconds:Number(e)}),disabled:w}),(0,U.jsxs)(`div`,{className:`chat-setting-field`,children:[(0,U.jsx)(G,{id:y,strong:!0,children:o(`chat.hitlWhitelistTools`,null,`白名单工具(免审批,逗号分隔)`)}),(0,U.jsx)(he,{"aria-labelledby":y,value:f.sensitiveTools,placeholder:o(`chat.hitlWhitelistPlaceholder`,null,`例:read_file, grep 或每行一个工具名(与 config 全局白名单合并)`),rows:5,disabled:w,onChange:e=>{let t={...f,sensitiveTools:e};p(t),h(!0),d(!1),r||a(q(t))},onBlur:()=>{m&&r&&!w&&(h(!1),T(f))}}),(0,U.jsx)(G,{type:`tertiary`,size:`small`,children:o(`chat.hitlWhitelistHint`,null,`白名单内工具免审批;每行一个或逗号分隔,与 config 全局白名单合并。`)})]})]})]})})})}var{Text:Qe}=T;function $e({item:e,active:t,editing:n,editingTitle:r,onStartEdit:i,onEditingTitle:o,onCommitEdit:s,onCancelEdit:l,onSelect:u,onPin:f,onDelete:p,canWrite:h,canDelete:g,selected:v,onToggleSelect:y,batchMode:x}){let S=L(),C=String(e.title||S(`chat.untitled`,null,`未命名对话`));return(0,U.jsxs)(`div`,{className:`chat-conv-item ${t?`is-active`:``}`,children:[x&&(0,U.jsx)(_,{className:`chat-conv-check`,"aria-label":`${S(`chat.selectConversation`,null,`选择对话`)}:${C}`,checked:v,onChange:t=>y(e.id,t.target.checked)}),n?(0,U.jsxs)(`div`,{className:`chat-conv-edit`,children:[(0,U.jsx)(d,{size:`small`,"aria-label":S(`chat.renameConversationTitle`,null,`重命名`),value:r,autoFocus:!0,onChange:o,onEnterPress:s,onKeyDown:e=>{e.key===`Escape`&&l()}}),(0,U.jsxs)(`div`,{className:`chat-conv-edit-actions`,children:[(0,U.jsx)(m,{size:`small`,theme:`solid`,onClick:s,children:S(`common.save`,null,`保存`)}),(0,U.jsx)(m,{size:`small`,theme:`borderless`,onClick:l,children:S(`common.cancel`,null,`取消`)})]})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`button`,{type:`button`,className:`chat-conv-main`,"aria-current":t?`true`:void 0,title:C,onClick:()=>u(e.id),children:[(0,U.jsxs)(`span`,{className:`chat-conv-title`,children:[e.pinned&&(0,U.jsx)(M,{size:`small`,className:`chat-conv-pin`}),(0,U.jsx)(`span`,{className:`chat-conv-title-text`,children:C})]}),(0,U.jsx)(`span`,{className:`chat-conv-meta`,children:P(e.updatedAt||e.createdAt)})]}),!x&&(0,U.jsxs)(`div`,{className:`chat-conv-actions`,children:[h&&(0,U.jsx)(b,{content:S(`chat.renameConversationTitle`,null,`重命名`),children:(0,U.jsx)(m,{size:`small`,theme:`borderless`,"aria-label":S(`chat.renameConversationTitle`,null,`重命名`),icon:(0,U.jsx)(c,{}),onClick:()=>i(e)})}),h&&(0,U.jsx)(b,{content:e.pinned?S(`chat.unpin`,null,`取消置顶`):S(`chat.pin`,null,`置顶`),children:(0,U.jsx)(m,{size:`small`,theme:`borderless`,icon:(0,U.jsx)(M,{}),"aria-label":e.pinned?S(`chat.unpin`,null,`取消置顶`):S(`chat.pin`,null,`置顶`),type:e.pinned?`warning`:`tertiary`,onClick:()=>f(e)})}),g&&(0,U.jsx)(k,{title:S(`chat.deleteConversationConfirm`,null,`确认删除该对话?删除后不可恢复。`),onConfirm:()=>p(e),children:(0,U.jsx)(m,{size:`small`,theme:`borderless`,type:`danger`,"aria-label":S(`chat.deleteConversationTitle`,null,`删除对话`),icon:(0,U.jsx)(a,{})})})]})]})]})}function et({items:e,groups:t,expandedGroup:n,groupTotal:r,onToggleGroup:i,loading:a,error:o,onRetry:c,search:l,onSearch:u,projectId:p,onProjectChange:h,projects:g,page:v,pageSize:y,onPageChange:b,selectedId:ee,onSelect:w,onCreate:T,onRename:E,onPin:te,onDelete:D,onBatchDelete:ne,canWrite:ie,canDelete:ae}){let O=L(),k=e,oe=(0,H.useId)(),[se,le]=(0,H.useState)(``),[ue,fe]=(0,H.useState)(``),[A,pe]=(0,H.useState)(!1),[M,N]=(0,H.useState)([]),he=k.length>0&&k.every(e=>M.includes(e.id)),ge=!he&&k.some(e=>M.includes(e.id));(0,H.useEffect)(()=>{N([]),pe(!1)},[v,p,l,n]);let _e=(0,H.useMemo)(()=>[{value:``,label:O(`chat.filterAllProjects`,null,`全部项目`)},...(Array.isArray(g)?g:[]).map(e=>({value:e.id,label:e.name||e.id}))],[g,O]),P=(e,t)=>{N(n=>t?[...new Set([...n,e])]:n.filter(t=>t!==e))},ve=e=>{le(e.id),fe(String(e.title||``))},F=()=>{let e=se,t=ue.trim();le(``),e&&t&&E(e,t)},I=(0,U.jsxs)(U.Fragment,{children:[a&&!k.length&&(0,U.jsx)(f,{placeholder:(0,U.jsx)(f.Paragraph,{rows:6}),loading:!0}),!a&&!o&&!k.length&&(0,U.jsx)(C,{title:O(`chat.noHistoryConversations`,null,`暂无历史对话`),description:null,className:`chat-sidebar-empty`}),(0,U.jsx)(S,{dataSource:k,split:!1,renderItem:e=>(0,U.jsx)($e,{item:e,active:e.id===ee,editing:se===e.id,editingTitle:ue,onStartEdit:ve,onEditingTitle:fe,onCommitEdit:F,onCancelEdit:()=>le(``),onSelect:w,onPin:te,onDelete:D,canWrite:ie,canDelete:ae,batchMode:A,selected:M.includes(e.id),onToggleSelect:P},e.id)})]});return(0,U.jsxs)(`div`,{className:`chat-sidebar-inner`,children:[(0,U.jsxs)(`div`,{className:`chat-sidebar-head`,children:[(0,U.jsx)(Qe,{strong:!0,className:`chat-sidebar-title`,children:O(`chat.conversations`,null,`会话`)}),(0,U.jsx)(m,{icon:(0,U.jsx)(ce,{}),theme:`borderless`,className:`chat-new-chat`,onClick:T,disabled:!ie,children:O(`chat.newChat`,null,`新建对话`)})]}),(0,U.jsxs)(`div`,{className:`chat-sidebar-filters`,children:[(0,U.jsx)(d,{prefix:(0,U.jsx)(de,{}),"aria-label":O(`chat.searchHistory`,null,`搜索历史对话`),placeholder:O(`chat.searchHistory`,null,`搜索历史对话`),value:l,onChange:u,showClear:!0}),(0,U.jsx)(me,{value:p,optionList:_e,onChange:h,className:`chat-sidebar-project`,"aria-label":O(`chat.filterByProject`,null,`按项目过滤`),placeholder:O(`chat.filterByProject`,null,`按项目过滤`)})]}),(0,U.jsxs)(`div`,{className:`chat-sidebar-tools`,children:[(0,U.jsxs)(Qe,{type:`tertiary`,size:`small`,children:[O(`chat.recentConversations`,null,`最近对话`),` · `,t.reduce((e,t)=>e+t.total,0)]}),(0,U.jsxs)(`div`,{className:`chat-sidebar-tools-actions`,children:[ae&&k.length>0&&(0,U.jsx)(m,{size:`small`,theme:A?`solid`:`borderless`,onClick:()=>{pe(!A),N([])},children:A?O(`common.cancel`,null,`取消`):O(`chat.batchManage`,null,`批量管理`)}),(0,U.jsx)(m,{size:`small`,theme:`borderless`,"aria-label":O(`chat.refreshConversationList`,null,`刷新会话列表`),title:O(`chat.refreshConversationList`,null,`刷新会话列表`),icon:(0,U.jsx)(j,{}),onClick:c})]})]}),A&&(0,U.jsxs)(`div`,{className:`chat-batch-bar`,children:[(0,U.jsx)(_,{className:`chat-batch-select-all`,checked:he,indeterminate:ge,disabled:a||!k.length,onChange:e=>N(e.target.checked?k.map(e=>e.id):[]),children:O(`chat.selectPage`,null,`全选本页`)}),(0,U.jsxs)(Qe,{size:`small`,children:[O(`chat.selectedCount`,null,`已选`),` `,M.length]}),(0,U.jsx)(m,{size:`small`,type:`danger`,disabled:!M.length,onClick:async()=>{await ne(M),N([]),pe(!1)},children:O(`chat.batchDelete`,null,`批量删除`)})]}),(0,U.jsxs)(`div`,{className:`chat-conv-list`,children:[(0,U.jsx)(Ce,{error:o,onRetry:c}),!t.length&&!a&&!o&&(0,U.jsx)(C,{title:O(`chat.noHistoryConversations`,null,`暂无历史对话`),description:null,className:`chat-sidebar-empty`}),t.map(e=>{let t=e.id===n,r=oe+`-`+e.id;return(0,U.jsxs)(`div`,{className:`chat-conv-group`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`chat-conv-group-toggle`,"aria-expanded":t,"aria-controls":r,title:e.projectId?e.title+` · `+e.projectId:e.title,onClick:()=>i(e.id),children:[(0,U.jsx)(s,{"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`chat-conv-group-name`,children:e.title}),(0,U.jsx)(`span`,{className:`chat-conv-group-count`,children:e.total}),(0,U.jsx)(x,{"aria-hidden":`true`,className:`chat-conv-group-chevron`})]}),(0,U.jsx)(`div`,{id:r,className:`chat-conv-group-content`,hidden:!t,children:t&&I})]},e.id)})]}),n&&r>y&&(0,U.jsx)(`div`,{className:`chat-sidebar-pager`,children:(0,U.jsx)(re,{size:`small`,total:r,pageSize:y,currentPage:v,onPageChange:b,showSizeChanger:!1})})]})}var tt=new Set([`taskcreate`,`taskupdate`,`tasklist`,`taskget`,`write_todos`]),nt=new Set([`heartbeat`,`response_delta`,`thinking_stream_delta`,`reasoning_chain_stream_delta`,`tool_result_delta`]),rt=200,it=2e4;function J(e){return e==null?``:String(e)}function at(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function Y(e,t=it){let n=J(e);return n.length<=t?n:`${n.slice(0,t)}\n…(已截断,共 ${n.length} 字符)`}function ot(e,t=6e3){if(e==null)return``;try{return Y(typeof e==`string`?e:JSON.stringify(e,null,2),t)}catch{return Y(String(e),t)}}function X({conversationId:e=``,id:t}={}){return{id:t||`live-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,conversationId:e,status:`streaming`,text:``,blocks:[],events:[],error:``,notice:``,statusText:``,messageId:``,userMessageId:``,finalizable:null,startedAt:Date.now(),endedAt:0,seq:0}}function Z(e,t){return e.seq+=1,`${t}-${e.seq}`}function Q(e,t){let n=J(t.type);nt.has(n)||(e.events.push({at:Date.now(),type:n,message:J(t.message),data:t.data===void 0?null:t.data}),e.events.length>rt&&e.events.splice(0,e.events.length-rt))}function $(e,{title:t,message:n,tone:r=`info`,data:i=null}){let a=e.blocks[e.blocks.length-1];if(a&&a.kind===`note`&&a.title===t&&a.message===J(n))return a;let o={kind:`note`,id:Z(e,`note`),title:t,message:Y(n),tone:r,data:i};return e.blocks.push(o),o}function st(e,t,n=`thinking`){let r=J(t)||Z(e,`reasoning`),i=r?e.blocks.find(e=>e.kind===`reasoning`&&e.key===r):null;return i||(i={kind:`reasoning`,id:Z(e,`reason`),key:r,stream:J(t),label:n,text:``},e.blocks.push(i)),i}function ct(e,t){let n=J(t.toolCallId),r=null;return n&&(r=e.blocks.find(e=>e.kind===`tool`&&e.toolCallId===n)),r||(r={kind:`tool`,id:Z(e,`tool`),toolCallId:n,toolName:J(t.toolName)||`未知工具`,args:null,result:``,status:`running`,processDetailId:J(t.processDetailId),agentName:J(t.agentName)},e.blocks.push(r)),t.toolName&&(r.toolName===`未知工具`||!r.toolName)&&(r.toolName=J(t.toolName)),t.agentName&&!r.agentName&&(r.agentName=J(t.agentName)),t.processDetailId&&!r.processDetailId&&(r.processDetailId=J(t.processDetailId)),r}function lt(e){let t=J(e.displayStatus||e.status).toLowerCase();return t===`cancelled`||t===`canceled`?`cancelled`:t===`background_running`?`running`:t===`blocked`?`blocked`:e.isError===!0||e.success===!1?`failed`:`success`}function ut(e,t){if(!e||!t||typeof t!=`object`)return e;let n=J(t.type),r=at(t.data)||{};switch(Q(e,t),n){case`heartbeat`:break;case`conversation`:r.conversationId&&(e.conversationId=J(r.conversationId));break;case`message_saved`:r.userMessageId&&(e.userMessageId=J(r.userMessageId));break;case`progress`:e.statusText=J(t.message)||e.statusText;break;case`iteration`:{let n=Number(r.iteration)||1,i=J(r.piScope).trim(),a=J(r.agentName).trim(),o=i===`main`?a?`主代理 · ${a}`:`主代理`:i===`sub`?`子代理${a?` · ${a}`:``}`:``;e.blocks.push({kind:`iteration`,id:Z(e,`iter`),title:`第 ${n} 轮迭代${o?` · ${o}`:``}`,message:Y(t.message,2e3)});break}case`thinking_stream_start`:case`reasoning_chain_stream_start`:{let t=st(e,r.streamId,n===`reasoning_chain_stream_start`?`reasoning_chain`:`thinking`);t.text=``;break}case`thinking_stream_delta`:case`reasoning_chain_stream_delta`:{let i=st(e,r.streamId,n===`reasoning_chain_stream_delta`?`reasoning_chain`:`thinking`),a=typeof r.accumulated==`string`?r.accumulated:null;i.text=Y(a===null?i.text+J(t.message):a);break}case`thinking`:case`reasoning_chain`:if(r.streamId){let i=st(e,r.streamId,n===`reasoning_chain`?`reasoning_chain`:`thinking`);J(t.message)&&(i.text=Y(t.message));break}e.blocks.push({kind:`reasoning`,id:Z(e,`reason`),key:Z(e,`reasonkey`),stream:``,label:n===`reasoning_chain`?`reasoning_chain`:`thinking`,text:Y(t.message)});break;case`response_start`:r.conversationId&&(e.conversationId=J(r.conversationId)),e.statusText||(e.statusText=`正在生成回复…`);break;case`response_delta`:{let n=typeof r.accumulated==`string`?r.accumulated:null;e.text=Y(n===null?e.text+J(t.message):n,6e4);break}case`response`:{let n=J(t.message);n&&(e.text=Y(n,6e4)),r.messageId&&(e.messageId=J(r.messageId)),r.conversationId&&(e.conversationId=J(r.conversationId)),r.finalizable===!1?e.finalizable=!1:r.finalizable===!0&&(e.finalizable=!0);break}case`tool_call`:{let t=ct(e,r);t.args=r.argumentsObj===void 0?r.arguments===void 0?t.args:r.arguments:r.argumentsObj;break}case`tool_result`:{let n=ct(e,r);n.status=lt(r),n.result=Y((r.resultPreview===void 0?r.result:r.resultPreview)??t.message,8e3);break}case`tool_calls_detected`:$(e,{title:`🔧 检测到工具调用`,message:t.message,data:r});break;case`hitl_interrupt`:$(e,{title:`🧑⚖️ 等待人工审批`,message:`${J(r.toolName)||`工具`} · ${J(t.message)||`命中审批策略`}`,tone:`warning`,data:r});break;case`hitl_resumed`:$(e,{title:`✅ 审批通过`,message:J(t.message),tone:`success`,data:r});break;case`hitl_rejected`:$(e,{title:`⛔ 审批被拒绝`,message:J(t.message),tone:`danger`,data:r});break;case`hitl_audit_agent_started`:$(e,{title:`🛡 审计代理审查中`,message:J(t.message),tone:`info`,data:r});break;case`hitl_audit_agent`:$(e,{title:`🛡 审计代理已裁决`,message:`${J(r.decision)||`-`}${r.comment?` · ${J(r.comment)}`:``}`,tone:`info`,data:r});break;case`warning`:case`iteration_limit_reached`:case`pi_pending_orphaned`:$(e,{title:`⚠️ ${J(t.message)||`提示`}`,message:J(t.message),tone:`warning`,data:r});break;case`finalization_check`:$(e,{title:`🔎 最终化校验未通过`,message:J(t.message),tone:`warning`,data:r}),r.finalizable===!1&&(e.finalizable=!1);break;case`finalization_auto_continue`:case`finalization_pending_tools_cancelled`:case`agent_empty_response_continue`:case`agent_run_retry`:case`pi_model_retry`:case`pi_model_failover`:case`pi_stream_error`:$(e,{title:J(t.message)||`运行提示`,message:J(t.message),tone:`warning`,data:r});break;case`agent_usage_summary`:e.blocks.push({kind:`usage`,id:Z(e,`usage`),data:r});break;case`user_interrupt_continue`:$(e,{title:`⏸️ 用户中断并继续`,message:J(t.message),tone:`info`,data:r});break;case`agent_reply`:$(e,{title:`💬 ${J(r.agentName)||`子代理`}回复`,message:J(t.message),data:r});break;case`workflow_start`:case`workflow_done`:case`workflow_node_start`:case`workflow_node_result`:case`workflow_branch_taken`:case`workflow_branch_skipped`:case`workflow_tool_start`:case`workflow_agent_output`:case`workflow_hitl_checkpoint`:case`workflow_hitl_waiting`:case`workflow_hitl_resumed`:case`workflow_hitl_rejected`:case`workflow_paused`:$(e,{title:`🧭 ${J(t.message)||n}`,message:J(t.message),data:r});break;case`cancelled`:e.status=`cancelled`,e.notice=J(t.message)||`任务已取消`,e.endedAt=Date.now();break;case`error`:e.status=`error`,e.error=J(t.message)||`执行失败`,e.endedAt=Date.now();break;case`done`:e.status===`streaming`&&(e.status=r.status===`blocked`||e.finalizable===!1?`blocked`:`done`),r.workflowStatus===`awaiting_hitl`&&(e.statusText=`工作流等待审批`),e.endedAt=Date.now()}return e}var dt={streaming:{label:`生成中`,color:`blue`},done:{label:`已完成`,color:`green`},blocked:{label:`未完成`,color:`orange`},disconnected:{label:`连接已结束`,color:`grey`},error:{label:`失败`,color:`red`},cancelled:{label:`已取消`,color:`grey`}};function ft(e){let t=[],n=0,r=e=>(n+=1,`h-${e}-${n}`),i=J(e?.reasoningContent).trim();i&&t.push({kind:`reasoning`,id:r(`reason`),key:`reasoningContent`,stream:``,label:`thinking`,text:Y(i)});let a=Array.isArray(e?.processDetails)?e.processDetails:[],o=new Map;return a.forEach(e=>{let n=J(e?.eventType),i=at(e?.data)||{},a=J(e?.message);switch(n){case`iteration`:{let e=Number(i.iteration)||1,n=J(i.piScope).trim(),o=J(i.agentName).trim();t.push({kind:`iteration`,id:r(`iter`),title:`第 ${e} 轮迭代${n===`main`?` · 主代理`:n===`sub`?` · 子代理`:``}${o?` · ${o}`:``}`,message:Y(a,2e3)});break}case`thinking`:case`reasoning_chain`:if(!a.trim())break;t.push({kind:`reasoning`,id:r(`reason`),key:J(i.streamId)||r(`reasonkey`),stream:J(i.streamId),label:n,text:Y(a)});break;case`tool_call`:{let n=J(i.toolCallId),a={kind:`tool`,id:r(`tool`),toolCallId:n,toolName:J(i.toolName)||`未知工具`,args:i.argumentsObj===void 0?i.arguments===void 0?null:i.arguments:i.argumentsObj,result:``,status:`running`,processDetailId:J(e?.id),agentName:J(i.agentName)};n&&o.set(n,a),t.push(a);break}case`tool_result`:{let e=J(i.toolCallId),n=e?o.get(e):null;n||(n={kind:`tool`,id:r(`tool`),toolCallId:e,toolName:J(i.toolName)||`未知工具`,args:null,result:``,status:`running`,processDetailId:``,agentName:J(i.agentName)},e&&o.set(e,n),t.push(n)),n.status=lt(i);let s=i.resultPreview===void 0?i.result:i.resultPreview;n.result=Y(s??a,8e3);break}case`planning`:if(!a.trim())break;t.push({kind:`note`,id:r(`note`),title:`📝 规划`,message:Y(a,4e3),tone:`info`,data:null});break;case`hitl_interrupt`:case`hitl_resumed`:case`hitl_rejected`:case`hitl_audit_agent`:case`hitl_audit_agent_started`:{let e=n===`hitl_rejected`?`danger`:n===`hitl_resumed`?`success`:`info`,o=n===`hitl_interrupt`?`🧑⚖️ 人工审批`:n===`hitl_rejected`?`⛔ 审批被拒绝`:n===`hitl_resumed`?`✅ 审批通过`:`🛡 审计代理`;t.push({kind:`note`,id:r(`note`),title:o,message:`${a}${i.toolName?` · ${J(i.toolName)}`:``}${i.decision?` · ${J(i.decision)}`:``}`,tone:e,data:null});break}case`error`:case`timeout`:case`cancelled`:t.push({kind:`note`,id:r(`note`),title:n===`cancelled`?`⏹ 已取消`:`❌ 执行异常`,message:a,tone:`danger`,data:null});break;case`agent_reply`:t.push({kind:`note`,id:r(`note`),title:`💬 子代理回复`,message:Y(a,6e3),tone:`info`,data:null});break;case`agent_usage_summary`:t.push({kind:`usage`,id:r(`usage`),data:i});break;case`progress`:break;default:(a.trim()||Object.keys(i).length)&&t.push({kind:`note`,id:r(`note`),title:J(n)||`过程事件`,message:Y(a,4e3),tone:`info`,data:Object.keys(i).length?i:null})}}),t}var{Text:pt}=T,mt={running:{color:`blue`,label:`执行中`},success:{color:`green`,label:`完成`},failed:{color:`red`,label:`失败`},cancelled:{color:`grey`,label:`已取消`},blocked:{color:`orange`,label:`已拦截`}};function ht({block:e,defaultOpen:t}){let n=e.text||``;if(!n.trim())return null;let r=e.label===`reasoning_chain`?`🔗 推理过程`:`🤔 思考过程`;return(0,U.jsx)(i,{className:`chat-block-collapse`,defaultActiveKey:t?[`1`]:[],children:(0,U.jsx)(i.Panel,{itemKey:`1`,header:(0,U.jsxs)(`span`,{className:`chat-block-title`,children:[r,` · `,n.length,` 字符`]}),children:(0,U.jsx)(`pre`,{className:`chat-pre`,children:Y(n)})})})}function gt({block:e}){let t=mt[e.status]||mt.running,n=ot(e.args),r=e.result||``,a=!!(n||r),o=(0,U.jsxs)(`span`,{className:`chat-tool-head`,children:[(0,U.jsxs)(`span`,{className:`chat-tool-name`,children:[e.agentName?`${e.agentName} · `:``,e.toolName||`未知工具`]}),(0,U.jsx)(h,{size:`small`,color:t.color,shape:`circle`,children:t.label})]});return a?(0,U.jsx)(`div`,{className:`chat-tool`,children:(0,U.jsx)(i,{className:`chat-block-collapse`,children:(0,U.jsxs)(i.Panel,{itemKey:`1`,header:o,children:[n&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(pt,{type:`tertiary`,size:`small`,children:`参数`}),(0,U.jsx)(`pre`,{className:`chat-pre`,children:n})]}),r&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(pt,{type:`tertiary`,size:`small`,children:`结果`}),(0,U.jsx)(`pre`,{className:`chat-pre`,children:r})]})]})})}):(0,U.jsx)(`div`,{className:`chat-tool`,children:(0,U.jsx)(`div`,{className:`chat-tool-head-row`,children:o})})}function _t({block:e}){let[t,n]=(0,H.useState)(!1),r=e.tone||`info`;return(0,U.jsxs)(`div`,{className:`chat-note chat-note-${r}`,children:[(0,U.jsxs)(`div`,{className:`chat-note-head`,children:[(0,U.jsx)(`span`,{className:`chat-note-title`,children:e.title}),e.data&&(0,U.jsx)(`button`,{type:`button`,className:`chat-link-btn`,onClick:()=>n(!t),children:t?`收起 JSON`:`查看 JSON`})]}),e.message&&(0,U.jsx)(`div`,{className:`chat-note-body`,children:e.message}),t&&e.data&&(0,U.jsx)(Ee,{value:e.data,collapsed:!1,title:`事件数据`})]})}function vt({data:e}){let{t,lang:n}=I(),r=e=>_e(Math.max(0,Math.trunc(Number(e)||0)),n),i=[[`chat.piUsageModelCalls`,e.modelCalls],[`chat.piUsagePromptTokens`,e.promptTokens],[`chat.piUsageCompletionTokens`,e.completionTokens],[`chat.piUsageTotalTokens`,e.totalTokens]],a=[[`chat.piUsageCachedTokens`,e.cachedTokens],[`chat.piUsageCacheWriteTokens`,e.cacheWriteTokens],[`chat.piUsageReasoningTokens`,e.reasoningTokens]],o=[...i,...a.filter(([,e])=>Number(e)>0)].map(([e,n])=>`${t(e)}: ${r(n)}`).join(`
`),s=Number(e.totalTokens),c=[e.agentName,t(`chat.piUsageSummaryTitle`),Number.isFinite(s)&&s>0?r(s):``].filter(Boolean).join(` · `);return(0,U.jsx)(_t,{block:{title:c,message:o,data:e}})}function yt({events:e}){return!e||!e.length?null:(0,U.jsx)(i,{className:`chat-block-collapse chat-event-log`,children:(0,U.jsx)(i.Panel,{itemKey:`1`,header:(0,U.jsxs)(`span`,{className:`chat-block-title`,children:[`🧾 原始事件 · `,e.length,` 条`]}),children:(0,U.jsx)(`pre`,{className:`chat-pre`,children:e.map((e,t)=>`${t+1}. ${JSON.stringify(e)}`).join(`
`)})})})}function bt({text:e,blocks:t,events:n,streaming:r=!1,openReasoning:i=!1,isAssistant:a=!1}){let{t:o}=I(),s=Array.isArray(t)?t:[],c=e||``;return(0,U.jsxs)(`div`,{className:`chat-turn-body`,children:[s.map(e=>e.kind===`reasoning`?(0,U.jsx)(ht,{block:e,defaultOpen:i},e.id):e.kind===`tool`?(0,U.jsx)(gt,{block:e},e.id):e.kind===`iteration`?(0,U.jsx)(`div`,{className:`chat-iteration`,children:(0,U.jsx)(`span`,{className:`chat-iteration-label`,children:e.title})},e.id):e.kind===`note`?(0,U.jsx)(_t,{block:e},e.id):e.kind===`usage`?(0,U.jsx)(vt,{data:e.data},e.id):null),(0,U.jsx)(yt,{events:n}),c.trim()&&(a&&!r?(0,U.jsx)(`section`,{className:`chat-task-summary`,"aria-label":o(`chat.taskSummary`),"data-chat-summary":!0,children:(0,U.jsxs)(`details`,{open:!0,children:[(0,U.jsx)(`summary`,{className:`chat-task-summary-title`,children:o(`chat.taskSummary`)}),(0,U.jsx)(`div`,{className:`chat-task-summary-content`,children:(0,U.jsx)(xe,{content:c})})]},c)}):r?(0,U.jsx)(`pre`,{className:`chat-pre chat-stream-text`,children:c}):(0,U.jsx)(xe,{content:c})),!c.trim()&&r&&(0,U.jsx)(`div`,{className:`chat-stream-placeholder`,children:`正在生成…`})]})}var{Paragraph:xt,Text:St}=T;function Ct(){let e=L();return(0,U.jsx)(`div`,{className:`chat-welcome`,children:(0,U.jsx)(C,{image:(0,U.jsx)(`span`,{className:`chat-welcome-mark`,"aria-hidden":`true`,children:(0,U.jsx)(g,{size:`extra-large`})}),title:e(`chat.welcomeHeading`,null,`让安全探索,从对话开始`),description:(0,U.jsx)(xt,{type:`tertiary`,className:`chat-welcome-description`,children:e(`chat.welcomeScopeDescription`,null,`描述测试目标与授权范围,或上传相关材料,即可开始对话。`)})})})}function wt(e,t,n){let[r,i]=(0,H.useState)(()=>Date.now());if((0,H.useEffect)(()=>{if(!n)return;let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[n]),!e)return``;let a=Math.max(0,Math.round(((n?r:t||e)-e)/1e3));return a<60?`${a}s`:`${Math.floor(a/60)}m${a%60}s`}function Tt({message:e,canDelete:t,onDeleteTurn:n}){let r=L(),i=e.role===`user`,o=e.role===`system`,s=(0,H.useMemo)(()=>ft(e),[e]),c=e.createdAt?P(e.createdAt):``,l=String(e.content||``);return o?(0,U.jsx)(`div`,{className:`chat-system-row`,children:(0,U.jsx)(St,{type:`tertiary`,children:l})},e.id):(0,U.jsxs)(`div`,{className:`chat-msg ${i?`chat-msg-user`:`chat-msg-assistant`}`,children:[(0,U.jsx)(w,{size:`small`,color:i?`grey`:`blue`,className:`chat-avatar`,"aria-hidden":`true`,children:i?(0,U.jsx)(A,{}):`AI`}),(0,U.jsxs)(`div`,{className:`chat-bubble`,children:[(0,U.jsxs)(`div`,{className:`chat-bubble-head`,children:[(0,U.jsx)(`span`,{className:`chat-bubble-role`,children:i?r(`chat.you`,null,`我`):r(`chat.assistant`,null,`助手`)}),c&&(0,U.jsx)(`span`,{className:`chat-bubble-time`,children:c}),(0,U.jsxs)(`span`,{className:`chat-bubble-actions`,children:[!i&&l&&(0,U.jsx)(B,{text:l,size:`small`}),t&&i&&e.id&&(0,U.jsx)(b,{content:r(`chat.deleteTurnTitle`,null,`删除本轮`),children:(0,U.jsx)(m,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,U.jsx)(a,{}),"aria-label":r(`chat.deleteTurnTitle`,null,`删除本轮`),onClick:()=>n(e)})})]})]}),l||s.length>0?(0,U.jsx)(bt,{text:l,blocks:s,events:null,isAssistant:!i}):(0,U.jsx)(St,{type:`tertiary`,children:`—`})]})]},e.id)}function Et({live:e}){let t=L(),n=dt[e.status]||dt.streaming,r=wt(e.startedAt,e.endedAt,e.status===`streaming`);return(0,U.jsxs)(`div`,{className:`chat-msg chat-msg-assistant chat-msg-live`,children:[(0,U.jsx)(w,{size:`small`,color:`blue`,className:`chat-avatar`,children:`AI`}),(0,U.jsxs)(`div`,{className:`chat-bubble`,children:[(0,U.jsxs)(`div`,{className:`chat-bubble-head`,children:[(0,U.jsx)(`span`,{className:`chat-bubble-role`,children:t(`chat.assistant`,null,`助手`)}),(0,U.jsx)(h,{size:`small`,color:n.color,shape:`circle`,children:n.label}),r&&(0,U.jsx)(`span`,{className:`chat-bubble-time`,children:r}),e.statusText&&(0,U.jsx)(`span`,{className:`chat-live-status`,children:e.statusText})]}),(0,U.jsx)(bt,{isAssistant:!0,text:e.text,blocks:e.blocks,events:e.events,streaming:e.status===`streaming`,openReasoning:e.status===`streaming`}),e.error&&(0,U.jsx)(`div`,{className:`chat-live-error`,children:e.error}),e.notice&&(0,U.jsx)(`div`,{className:`chat-live-notice`,children:e.notice}),e.finalizable===!1&&(0,U.jsx)(`div`,{className:`chat-live-notice`,children:`本轮回复未通过最终化校验,内容可能不完整。`})]})]})}function Dt({conversationId:e,messages:t,live:n,loading:r,error:i,onRetry:a,canDelete:o,onDeleteTurn:s}){let c=L(),l=(0,H.useRef)(null),u=(0,H.useRef)(!0),d=(0,H.useRef)(``),[f,p]=(0,H.useState)(!0),h=Array.isArray(t)?t:[],g=h[h.length-1],_=`${h.length}:${g?.id||``}:${g?.content||``}:${g?.processDetails?.length||0}`,v=n?n.status!==`streaming`&&n.text.trim()?`live:${e}:${n.messageId||n.id}:${n.text}`:``:!r&&g?.role===`assistant`&&String(g.content||``).trim()?`history:${e}:${g.id}:${g.content}`:``,y=(0,H.useMemo)(()=>{if(!n)return _;let e=n.blocks.map(e=>`${e.kind}:${e.id}:${e.text?e.text.length:0}:${e.status||``}`).join(`|`);return`${_}#${n.id}#${n.status}#${n.text.length}#${e}`},[_,n]),b=(0,H.useCallback)((e=!1)=>{let t=l.current;t&&t.scrollTo({top:t.scrollHeight,behavior:e?`smooth`:`auto`})},[]),x=(0,H.useCallback)((e=!1)=>{let t=l.current;if(!t)return;let n=t.querySelectorAll(`.chat-msg`),r=n[n.length-1]?.querySelector(`[data-chat-summary]`);if(!r){b(e);return}let i=r.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop-12;t.scrollTo({top:Math.max(0,i),behavior:e?`smooth`:`auto`})},[b]),S=(0,H.useCallback)(()=>{let e=l.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<120;u.current=t,p(t)},[]);return(0,H.useEffect)(()=>{u.current=!0,d.current=``,p(!0);let e=setTimeout(()=>x(!1),30);return()=>clearTimeout(e)},[e,x]),(0,H.useEffect)(()=>{n?.id&&(u.current=!0)},[n?.id]),(0,H.useEffect)(()=>{if(r)return;let e=v&&d.current!==v;e&&(d.current=v),(e||u.current)&&x(!1)},[y,v,r,x]),e||n||h.length?(0,U.jsxs)(`div`,{className:`chat-message-wrap`,children:[(0,U.jsxs)(`div`,{className:`chat-messages`,ref:l,onScroll:S,children:[(0,U.jsx)(Ce,{error:i,onRetry:a}),r&&(0,U.jsx)(`div`,{className:`chat-loading`,children:(0,U.jsx)(ee,{size:`middle`})}),!r&&!h.length&&!n&&(0,U.jsx)(Ct,{}),h.map(e=>(0,U.jsx)(Tt,{message:e,canDelete:o,onDeleteTurn:s},e.id)),n&&(0,U.jsx)(Et,{live:n}),i&&!r&&(0,U.jsx)(m,{icon:(0,U.jsx)(j,{}),theme:`borderless`,onClick:a,className:`chat-retry-inline`,children:c(`common.refresh`,null,`刷新`)})]}),!f&&(0,U.jsx)(m,{className:`chat-scroll-bottom`,icon:(0,U.jsx)(D,{}),size:`small`,theme:`solid`,onClick:()=>{u.current=!0,p(!0),b(!0)},children:c(`chat.returnToLatest`,null,`回到底部`)})]}):(0,U.jsx)(`div`,{className:`chat-message-wrap`,children:(0,U.jsx)(`div`,{className:`chat-messages`,ref:l,children:(0,U.jsx)(Ct,{})})})}var{Text:Ot}=T,kt=[`single`,`deep`,`plan_execute`,`supervisor`],At=`__create_project__`;function jt({value:e,onChange:t,onSend:n,onStop:r,canStop:i,sending:a,checkingRun:o,canWrite:c,canExecute:l,mode:d,onModeChange:f,projectId:p,onProjectChange:g,onCreateProject:_,projects:v,projectDisabled:y,role:S,onRoleChange:C,roles:ee,roleDisabled:w,model:T,canReadConfig:E,onOpenHitl:te,attachments:D,onPickFiles:ne,onRemoveAttachment:re,uploading:ie}){let O=L(),k=(0,H.useRef)(null),oe=(0,H.useId)(),le=(0,H.useId)(),de=(0,H.useId)(),fe=Array.isArray(D)?D:[],j=(0,H.useMemo)(()=>[{value:`single`,title:O(`chat.agentModePiSingle`,null,`单代理`),description:O(`chat.agentModePiSingleHint`,null,`使用设置中选择的 Pi 或兼容运行时执行单代理任务`)},{value:`deep`,title:O(`chat.agentModeDeep`,null,`Deep(DeepAgent)`),description:O(`chat.agentModeDeepHint`,null,`Pi 多代理,适合复杂安全测试、多阶段 task 子代理委派与汇总`)},{value:`plan_execute`,title:O(`chat.agentModePlanExecuteLabel`,null,`Plan-Execute`),description:O(`chat.agentModePlanExecuteHint`,null,`规划 → 执行 → 重规划(单执行器带工具)`)},{value:`supervisor`,title:O(`chat.agentModeSupervisorLabel`,null,`Supervisor(专家路由)`),description:O(`chat.agentModeSupervisorHint`,null,`专家路由场景:监督者通过 transfer 动态分派多个专业子代理`)}].map(({value:e,title:t,description:n})=>({value:e,title:t,label:(0,U.jsxs)(`span`,{className:`chat-mode-option`,children:[(0,U.jsx)(`span`,{children:t}),(0,U.jsx)(`span`,{className:`chat-mode-option-description`,children:n})]})})),[O]),M=[{value:``,label:O(`chat.defaultWorkspace`,null,`默认工作区`)},...(Array.isArray(v)?v:[]).map(e=>({value:e.id,label:e.name||O(`chat.boundProject`,null,`已绑定项目`)}))];p&&!M.some(e=>e.value===p)&&M.push({value:p,label:O(`chat.boundProject`,null,`已绑定项目`)}),_&&M.push({value:At,label:`+ ${O(`projects.newProject`,null,`新建项目`)}`});let _e=(0,H.useMemo)(()=>{let e=(Array.isArray(ee)?ee:[]).filter(e=>e?.name),t=e.filter(e=>e.enabled!==!1&&e.name!==`默认`).sort((e,t)=>e.name.localeCompare(t.name,`zh-CN`)),n=e.find(e=>e.name===`默认`),r=e=>({value:e.name===`默认`?``:e.name,name:e.name===`默认`?O(`chat.defaultRole`,null,`默认`):e.name,icon:e.icon||``,description:e.description||``,label:(0,U.jsxs)(`span`,{className:`chat-role-option`,children:[(0,U.jsxs)(`span`,{className:`chat-role-option-title`,children:[e.icon?(0,U.jsx)(`span`,{className:`chat-role-icon`,"aria-hidden":`true`,children:e.icon}):null,(0,U.jsx)(`span`,{children:e.name===`默认`?O(`chat.defaultRole`,null,`默认`):e.name})]}),e.description?(0,U.jsx)(`span`,{className:`chat-role-option-description`,children:e.description}):null]})}),i=[r({name:`默认`,icon:n?.icon||``,description:n?.description||``})],a=new Set([``]);for(let e of t)a.has(e.name)||(a.add(e.name),i.push(r(e)));if(S&&!a.has(S)){let t=e.find(e=>e.name===S);i.push(r(t||{name:S,icon:``,description:``}))}return i},[S,ee,O]),P=_e.find(e=>e.value===(S||``))||_e[0],ve=Number(ie)||fe.filter(e=>e.uploading).length,F=!c||!l,I=a||o,ye=T.channel||T.config.data?.default_channel,R=ye?Me(ye,T.config.data?.channels?.[ye]):O(`chat.aiChannelDefaultShort`,null,`默认通道`),be=T.overrideBlocked?Re(O,`default`,``):Re(O,T.mode,T.effort);return(0,U.jsxs)(`div`,{className:`chat-composer`,children:[F&&(0,U.jsx)(ge,{type:`warning`,bordered:!0,closeIcon:null,className:`chat-composer-banner`,description:c?O(`chat.noExecutePermission`,null,`当前账号没有智能体执行权限(agent:execute),发送已禁用。`):O(`chat.noWritePermission`,null,`当前账号没有对话写入权限(chat:write),发送已禁用。`)}),(0,U.jsx)(`div`,{className:`chat-composer-shell`,children:(0,U.jsxs)(`div`,{className:`chat-composer-box`,children:[(0,U.jsxs)(`div`,{className:`chat-composer-context`,children:[(0,U.jsx)(`span`,{id:oe,hidden:!0,children:O(`chat.agentModeSelectAria`,null,`选择对话执行模式`)}),(0,U.jsx)(me,{value:d,optionList:j,renderSelectedItem:e=>(0,U.jsx)(`span`,{title:e.title,children:e.title}),onChange:f,prefix:(0,U.jsx)(se,{"aria-hidden":`true`}),className:`chat-context-select chat-composer-mode`,dropdownClassName:`chat-mode-dropdown`,size:`small`,position:`topLeft`,"aria-labelledby":oe,disabled:I||F}),(0,U.jsx)(`span`,{className:`chat-context-divider`,"aria-hidden":`true`}),(0,U.jsx)(`span`,{id:le,hidden:!0,children:O(`chat.chooseWorkspace`,null,`选择会话工作区`)}),(0,U.jsx)(me,{value:p,optionList:M,onChange:e=>{e===At?_?.():g(e)},prefix:(0,U.jsx)(s,{"aria-hidden":`true`}),className:`chat-context-select chat-composer-project`,dropdownClassName:`chat-project-dropdown`,dropdownMatchSelectWidth:!1,position:`topLeft`,size:`small`,renderSelectedItem:e=>(0,U.jsx)(`span`,{title:e.label,children:e.label}),"aria-labelledby":le,disabled:I||y||!c}),C&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`chat-context-divider`,"aria-hidden":`true`}),(0,U.jsx)(`span`,{id:de,hidden:!0,children:O(`chat.selectRole`,null,`选择角色`)}),(0,U.jsx)(me,{value:S||``,optionList:_e,onChange:C,prefix:P?.icon?(0,U.jsx)(`span`,{className:`chat-role-icon`,"aria-hidden":`true`,children:P.icon}):(0,U.jsx)(A,{"aria-hidden":`true`}),className:`chat-context-select chat-composer-role`,dropdownClassName:`chat-role-dropdown`,dropdownMatchSelectWidth:!1,position:`topLeft`,size:`small`,renderSelectedItem:e=>(0,U.jsx)(`span`,{title:e.description||e.name,children:e.name}),"aria-labelledby":de,disabled:I||w||!c})]})]}),(0,U.jsx)(`input`,{ref:k,type:`file`,multiple:!0,hidden:!0,onChange:e=>{e.target.files?.length&&ne(Array.from(e.target.files)),e.target.value=``}}),fe.length>0&&(0,U.jsx)(`div`,{className:`chat-file-list`,children:fe.map(e=>(0,U.jsxs)(h,{className:`chat-file-chip ${e.error?`is-error`:``} ${e.uploading?`is-uploading`:``}`,size:`large`,color:e.error?`red`:e.uploading?`amber`:`blue`,closable:!0,onClose:()=>re(e.id),children:[(0,U.jsx)(N,{size:`small`}),(0,U.jsx)(`span`,{className:`chat-file-name`,title:e.fileName,children:e.fileName}),(0,U.jsx)(`span`,{className:`chat-file-state`,children:e.uploading?`上传中…`:e.error?`上传失败`:`已上传`})]},e.id))}),(0,U.jsx)(he,{className:`chat-textarea`,borderless:!0,value:e,onChange:t,onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent?.isComposing||(e.preventDefault(),I||F||w||ve>0||n())},disabled:F,autosize:{minRows:2,maxRows:8},"aria-label":O(`chat.composerLabel`,null,`对话内容`),placeholder:O(`chat.composerPlaceholder`,null,`描述目标、授权范围与需求,或附上相关材料…`)}),(0,U.jsxs)(`div`,{className:`chat-composer-toolbar`,children:[(0,U.jsxs)(`div`,{className:`chat-composer-controls`,children:[(0,U.jsx)(b,{content:O(`chat.selectFile`,null,`选择附件`),children:(0,U.jsx)(m,{icon:(0,U.jsx)(ce,{}),theme:`borderless`,type:`tertiary`,"aria-label":O(`chat.attachmentsLabel`,null,`附件`),disabled:F,onClick:()=>k.current?.click()})}),(0,U.jsx)(m,{icon:(0,U.jsx)(ue,{}),theme:`borderless`,type:`tertiary`,className:`chat-composer-hitl`,"aria-label":O(`chat.hitlTitle`,null,`人机协同`),disabled:!te,onClick:te,children:O(`chat.hitlTitle`,null,`人机协同`)})]}),(0,U.jsxs)(`div`,{className:`chat-composer-submit`,children:[(0,U.jsx)(u,{trigger:`click`,position:`topRight`,className:`chat-model-popover`,condition:!I,content:(0,U.jsx)(Xe,{model:T,busy:I||F,canReadConfig:E}),children:(0,U.jsxs)(m,{theme:`borderless`,type:`tertiary`,className:`chat-composer-model`,"aria-label":O(`chat.modelSettingsAria`,null,`选择 AI 通道、模型与推理设置`),title:`${R} · ${be}`,disabled:I,children:[(0,U.jsx)(`span`,{className:`chat-composer-model-name`,children:R}),(0,U.jsx)(`span`,{className:`chat-composer-effort`,children:be}),(0,U.jsx)(x,{size:`small`})]})}),a?(0,U.jsx)(m,{type:`danger`,className:`chat-composer-send`,icon:(0,U.jsx)(ae,{}),"aria-label":O(`chat.stop`,null,`停止`),onClick:r,disabled:!i}):(0,U.jsx)(b,{content:O(`chat.sendHint`,null,`Enter 发送 · Shift+Enter 换行`),children:(0,U.jsx)(m,{theme:`solid`,className:`chat-composer-send`,icon:(0,U.jsx)(pe,{}),"aria-label":O(`chat.send`,null,`发送`),disabled:F||o||w||ve>0,onClick:n})})]})]}),ve>0&&(0,U.jsx)(Ot,{type:`tertiary`,size:`small`,role:`status`,children:O(`chat.waitingAttachmentsUpload`,null,`附件上传中…`)})]})})]})}var{Text:Mt}=T,Nt={approval:`仅审批`,feedback:`审批并反馈`,followup:`审批并追问`,review_edit:`审查编辑`};function Pt(e){if(!e)return null;let t=e.payload;if(typeof t==`string`)try{t=JSON.parse(t)}catch{t=null}t&&typeof t==`object`||(t={});let n=t.argumentsObj&&typeof t.argumentsObj==`object`?t.argumentsObj:t.arguments||null;return{...e,payload:t,interruptId:String(e.id||e.interruptId||``),toolName:String(e.toolName||t.toolName||`未知工具`),mode:String(e.mode||t.mode||`approval`).toLowerCase(),args:n}}function Ft({item:e,busy:t,readOnly:n,onApprove:r,onReject:a,onDismiss:o}){let s=L(),c=(0,H.useMemo)(()=>Pt(e),[e]),[u,f]=(0,H.useState)(``);if(!c)return null;let p=ot(c.args,4e3),g=Nt[c.mode]||c.mode,_=n||t||!c.interruptId;return(0,U.jsxs)(v,{className:`chat-hitl-card`,bordered:!0,title:(0,U.jsxs)(`span`,{className:`chat-hitl-title`,children:[(0,U.jsx)(`span`,{children:s(`chat.hitlTitle`,null,`人工审批`)}),(0,U.jsx)(h,{size:`small`,color:`orange`,shape:`circle`,children:g}),(0,U.jsx)(`span`,{className:`chat-hitl-tool`,children:c.toolName})]}),headerExtraContent:(0,U.jsx)(Mt,{type:`tertiary`,size:`small`,children:c.createdAt?P(c.createdAt):``}),children:[(0,U.jsxs)(`div`,{className:`chat-hitl-meta`,children:[c.reviewer&&(0,U.jsxs)(Mt,{type:`tertiary`,size:`small`,children:[`审批人:`,c.reviewer===`audit_agent`?`审计代理`:`人工`]}),c.expiresAt&&(0,U.jsxs)(Mt,{type:`tertiary`,size:`small`,children:[`到期:`,P(c.expiresAt)]}),c.conversationId&&(0,U.jsxs)(Mt,{type:`tertiary`,size:`small`,children:[`会话:`,String(c.conversationId).slice(0,8)]})]}),p&&(0,U.jsx)(i,{className:`chat-block-collapse`,children:(0,U.jsx)(i.Panel,{itemKey:`1`,header:(0,U.jsx)(`span`,{className:`chat-block-title`,children:`调用参数`}),children:(0,U.jsx)(`pre`,{className:`chat-pre`,children:p})})}),(0,U.jsxs)(`div`,{className:`chat-hitl-actions`,children:[(0,U.jsx)(d,{size:`small`,placeholder:s(`chat.hitlComment`,null,`审批备注(拒绝时建议填写原因)`),disabled:n,value:u,onChange:f,className:`chat-hitl-comment`}),(0,U.jsxs)(l,{children:[(0,U.jsx)(m,{theme:`solid`,size:`small`,icon:(0,U.jsx)(ne,{}),disabled:_,onClick:()=>r(c,u),children:s(`chat.hitlApprove`,null,`批准`)}),(0,U.jsx)(m,{type:`danger`,size:`small`,icon:(0,U.jsx)(y,{}),disabled:_,onClick:()=>a(c,u),children:s(`chat.hitlReject`,null,`拒绝`)}),(0,U.jsx)(m,{size:`small`,theme:`borderless`,disabled:_,onClick:()=>o(c),children:s(`chat.hitlDismiss`,null,`忽略`)})]})]})]})}var{Text:It}=T;function Lt({items:e,busyId:t,readOnly:n,onRefresh:r,onDecide:i,onDismiss:a}){let o=L(),s=Array.isArray(e)?e:[];return s.length?(0,U.jsxs)(`div`,{className:`chat-hitl-dock`,children:[(0,U.jsxs)(`div`,{className:`chat-hitl-dock-head`,children:[(0,U.jsx)(It,{strong:!0,children:o(`chat.pendingApprovals`,{count:s.length},`待审批 ${s.length}`)}),(0,U.jsx)(m,{size:`small`,theme:`borderless`,icon:(0,U.jsx)(j,{}),onClick:r})]}),s.map(e=>(0,U.jsx)(Ft,{item:e,readOnly:n,busy:t===String(e.id||e.interruptId),onApprove:(e,t)=>i(e,`approve`,t),onReject:(e,t)=>i(e,`reject`,t),onDismiss:a},e.id||e.interruptId))]}):null}var{Text:Rt}=T,zt={pending:{color:`grey`,label:`待处理`},in_progress:{color:`blue`,label:`进行中`},completed:{color:`green`,label:`已完成`},blocked:{color:`orange`,label:`阻塞`},deleted:{color:`grey`,label:`已删除`}};function Bt({plan:e,loading:t,onRefresh:n}){let r=L(),i=Array.isArray(e?.tasks)?e.tasks.filter(e=>String(e.status||``).toLowerCase()!==`deleted`):[],a=Number(e?.total)||i.length,o=Number(e?.completed)||i.filter(e=>e.status===`completed`).length,s=a?Math.round(o/a*100):0;return(0,U.jsxs)(`div`,{className:`chat-plan`,children:[(0,U.jsxs)(`div`,{className:`chat-plan-toolbar`,children:[(0,U.jsx)(Rt,{type:`tertiary`,size:`small`,children:e?.running?r(`chat.planRunning`,null,`任务执行中`):r(`chat.planIdle`,null,`当前没有运行中的任务`)}),(0,U.jsx)(m,{size:`small`,icon:(0,U.jsx)(j,{}),onClick:n,loading:t,children:r(`common.refresh`,null,`刷新`)})]}),(0,U.jsx)(oe,{percent:s,showInfo:!0}),(0,U.jsx)(Rt,{type:`tertiary`,size:`small`,children:r(`chat.planSummary`,{total:a,done:o},`共 ${a} 项,已完成 ${o} 项`)}),!i.length&&(0,U.jsx)(C,{title:r(`chat.planEmpty`,null,`暂无执行计划`),description:r(`chat.planEmptyHint`,null,`代理调用任务工具后,这里会显示任务看板。`),style:{padding:24}}),(0,U.jsx)(`div`,{className:`chat-plan-list`,children:i.map((e,t)=>{let n=String(e.status||`pending`).toLowerCase(),r=zt[n]||zt.pending;return(0,U.jsxs)(`div`,{className:`chat-plan-item ${n===`in_progress`?`is-active`:``}`,children:[(0,U.jsxs)(`div`,{className:`chat-plan-item-head`,children:[(0,U.jsx)(`span`,{className:`chat-plan-index`,children:t+1}),(0,U.jsx)(`span`,{className:`chat-plan-subject`,children:e.subject||e.activeForm||`—`}),(0,U.jsx)(h,{size:`small`,color:r.color,shape:`circle`,children:r.label})]}),e.description&&(0,U.jsx)(`div`,{className:`chat-plan-desc`,children:e.description})]},e.id||t)})})]})}function Vt({visible:e,onClose:t,plan:n,loading:r,onRefresh:i}){let a=L()(`chat.planTasks`,null,`执行计划`);return(0,U.jsx)(O,{title:a,"aria-label":a,visible:e,onCancel:t,width:`min(100%, 560px)`,placement:`right`,children:(0,U.jsx)(Bt,{plan:n,loading:r,onRefresh:i})})}function Ht({conversationRef:e,bindConversation:t,requestDetailReload:n,onSettled:r,onHitlEvent:i,onPlanTool:a,t:o}){let[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)([]),p=(0,H.useRef)(null),m=(0,H.useRef)(null),h=(0,H.useRef)(null),g=(0,H.useCallback)((e=!1)=>{let t=()=>{h.current=null,p.current&&c({...p.current})};e?(h.current&&(clearTimeout(h.current),h.current=null),t()):h.current||(h.current=setTimeout(t,80))},[]),_=(0,H.useCallback)(t=>{if(!t||t.markedFinished||m.current!==t)return;t.markedFinished=!0,t.live.status===`streaming`&&(t.live.status=t.live.error?`error`:`done`,t.live.endedAt=Date.now()),g(!0),r?.(),u(!1),f(t.live.events.slice(-80));let i=t.live.conversationId||e.current;i?Promise.resolve(n?.(i,{silent:!0})).then(e=>{m.current===t&&e&&(m.current=null,p.current=null,c(null))}):(m.current=null,p.current=null,c(null))},[e,g,r,n]);return{live:s,sending:l,lastEvents:d,send:(0,H.useCallback)(({message:n,attachments:r,mode:s,projectId:l,role:d,aiChannelId:h,reasoning:v,hitl:y,requireHumanApproval:b})=>{let x={live:X({conversationId:e.current}),markedFinished:!1,stopRequested:!1,abort:null};m.current=x,p.current=x.live,c({...x.live}),u(!0),f([]);let S=s!==`single`,C={message:n,conversationId:e.current||``,aiChannelId:h,reasoning:v,hitl:y,requireHumanApproval:b||void 0};!e.current&&l&&(C.projectId=l),d&&(C.role=d),S&&(C.orchestration=s),Array.isArray(r)&&r.length&&(C.attachments=r.map(e=>({fileName:e.fileName,mimeType:e.mimeType||``,serverPath:e.serverPath}))),x.abort=V(S?`/multi-agent/stream`:`/agent/stream`,C,{onEvent(n){if(x.markedFinished||m.current!==x)return;ut(x.live,n);let r=n?.type;if(r===`conversation`&&n?.data?.conversationId){let r=String(n.data.conversationId);x.live.conversationId=r,e.current!==r&&t?.(r)}(r===`hitl_interrupt`||r===`hitl_resumed`||r===`hitl_rejected`)&&i?.(),(r===`tool_call`||r===`tool_result`)&&tt.has(String(n?.data?.toolName||``).toLowerCase())&&a?.(),r===`done`||r===`error`||r===`cancelled`?_(x):g()},onError(e){x.markedFinished||m.current!==x||(x.live.status=`error`,x.live.error=ye(e,o(`chat.streamFailed`,null,`流式连接失败`)),x.live.endedAt=Date.now(),_(x))},onClose(){x.markedFinished||m.current!==x||(x.live.status=`disconnected`,x.live.endedAt=Date.now(),x.stopRequested||(x.live.notice=o(`chat.streamEndedWithoutDone`,null,`连接提前结束,未收到任务完成信号。任务可能仍在后端执行。`),R(x.live.notice)),_(x))}})},[t,e,_,g,i,a,o]),stop:(0,H.useCallback)(async()=>{let t=m.current,r=e.current||t?.live?.conversationId||``;if(r)try{await F.post(`/agent-loop/cancel`,{conversationId:r}),t&&(t.stopRequested=!0),De(o(`chat.stopRequested`,null,`已请求停止任务`))}catch(e){R(ye(e,o(`chat.stopFailed`,null,`停止请求失败`)))}t?.abort?.(),setTimeout(()=>{r&&e.current===r&&n?.(r,{silent:!0})},900)},[e,n,o]),reset:(0,H.useCallback)(()=>{let e=m.current;e&&!e.markedFinished&&e.abort?.(),m.current=null,p.current=null,h.current&&(clearTimeout(h.current),h.current=null),c(null),u(!1),f([])},[]),isStreaming:(0,H.useCallback)(e=>{let t=m.current;return!!(t&&!t.markedFinished&&e&&t.live.conversationId===e)},[])}}function Ut({t:e,conversationRef:t,newProjectId:n,canWrite:r,reloadList:i,requestDetailReload:a,navigate:o,onSelectionCleared:s}){return{createConversation:(0,H.useCallback)(async()=>{if(r)try{let t=(await F.post(`/conversations`,{title:e(`chat.newChat`,null,`新对话`),projectId:n||void 0}))?.id;i(),t&&o({conversation:t}),De(e(`chat.created`,null,`已创建对话`))}catch(t){z(t,e(`chat.createFailed`,null,`创建对话失败`))}},[r,o,n,i,e]),renameConversation:(0,H.useCallback)(async(n,r)=>{try{await F.put(`/conversations/${encodeURIComponent(n)}`,{title:r}),De(e(`chat.renamed`,null,`已重命名`)),i(),n===t.current&&a(n,{silent:!0})}catch(t){z(t,e(`chat.renameFailed`,null,`重命名失败`))}},[t,i,a,e]),togglePin:(0,H.useCallback)(async t=>{try{await F.put(`/conversations/${encodeURIComponent(t.id)}/pinned`,{pinned:!t.pinned}),i()}catch(t){z(t,e(`chat.pinFailed`,null,`置顶操作失败`))}},[i,e]),deleteConversation:(0,H.useCallback)(async n=>{try{await F.del(`/conversations/${encodeURIComponent(n.id)}`),De(e(`chat.deleted`,null,`已删除对话`)),n.id===t.current&&(s(),o({},{replace:!0})),i()}catch(t){z(t,e(`chat.deleteFailed`,null,`删除对话失败`))}},[t,o,s,i,e]),batchDelete:(0,H.useCallback)(async n=>{let r=(await Promise.allSettled(n.map(e=>F.del(`/conversations/${encodeURIComponent(e)}`)))).filter(e=>e.status===`rejected`).length;r?R(e(`chat.batchDeletePartial`,{failed:r},`有 ${r} 个对话删除失败`)):De(e(`chat.batchDeleted`,{count:n.length},`已删除 ${n.length} 个对话`)),n.includes(t.current)&&(s(),o({},{replace:!0})),i()},[t,o,s,i,e]),deleteTurn:(0,H.useCallback)(n=>{let r=t.current;r&&n?.id&&Oe({title:e(`chat.deleteTurnTitle`,null,`删除本轮`),content:e(`chat.deleteTurnConfirm`,null,`将删除该轮提问与全部回答,删除后不可恢复。`),okText:e(`common.delete`,null,`删除`),onOk:async()=>{try{await F.post(`/conversations/${encodeURIComponent(r)}/delete-turn`,{messageId:n.id}),De(e(`chat.turnDeleted`,null,`已删除该轮`)),await a(r,{silent:!0}),i()}catch(t){z(t,e(`chat.deleteTurnFailed`,null,`删除轮次失败`))}}})},[t,i,a,e])}}var{Text:Wt}=T,Gt=20,Kt=`__none__`,qt=`csai-chat-agent-mode`,Jt=`csai-chat-role`;function Yt(e){let t=typeof e==`string`?e.trim():``;return!t||t===`默认`?``:t}var Xt={tasks:[],total:0,completed:0,activeStep:0,running:!1},Zt={conversation:null,messages:[],loading:!1,error:null};function Qt(e){let[t,n]=(0,H.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(e).matches);return(0,H.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=e=>n(e.matches);return n(t.matches),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}function $t(){let e=L(),{hasPermission:t}=ve(),n=t(`chat:write`),a=t(`project:write`),o=t(`agent:execute`),s=t(`chat:delete`),c=t(`tasks:read`),l=t(`tasks:write`),u=t(`hitl:read`),d=t(`hitl:write`),f=t(`config:read`),p=t(`roles:read`),[h,g]=r(),_=h.get(`conversation`)||``,v=(0,H.useRef)(_),y=(0,H.useRef)(null);(0,H.useLayoutEffect)(()=>{v.current=_},[_]);let[b,x]=(0,H.useState)(``),S=we(b,350),[C,ee]=(0,H.useState)(``),[w,T]=(0,H.useState)(Kt),[E,te]=(0,H.useState)(!0),[D,ne]=(0,H.useState)(1),[re,ie]=(0,H.useState)(``),[ae,k]=(0,H.useState)(!1),[se,ce]=(0,H.useState)(!1),[le,ue]=Se(qt,`single`),de=kt.includes(le)?le:`single`,[fe,A]=Se(Jt,``),[pe,j]=(0,H.useState)(()=>new Map),M=(0,H.useRef)(``),N=Be(f),[me,he]=(0,H.useState)(!1),[ge,_e]=(0,H.useState)(null),[P,I]=(0,H.useState)(Zt),[ye,xe]=(0,H.useState)(()=>new Map),{draft:Ce=``,attachments:B=[]}=ye.get(_)||{},Ee=(0,H.useCallback)((e,t)=>{xe(n=>{let r=new Map(n);return r.set(e,t(n.get(e)||{})),r})},[]),Oe=e=>Ee(_,t=>({...t,draft:e})),[V,Ae]=(0,H.useState)(null),je=u&&V?.id===_?V.items:[],[Me,Ne]=(0,H.useState)(``),[W,Pe]=(0,H.useState)(Xt),[Ie,Le]=(0,H.useState)(!1),[Re,ze]=(0,H.useState)(!1),[G,Ve]=(0,H.useState)(!1),He=Qt(`(max-width: 900px)`),Ue=(0,H.useRef)(0),We=(0,H.useRef)(0),Ge=(0,H.useRef)(0),Ke=be(async()=>{let e=await F.get(`/agent-loop/tasks`);return{id:_,running:Array.isArray(e?.tasks)&&e.tasks.some(e=>e.conversationId===_)}},[_,c],{skip:!_||!c}),K=c&&Ke.data?.id===_&&Ke.data.running,qe=!!(c&&_&&Ke.data?.id!==_&&!Ke.error),Je=(0,H.useRef)(null),q=be(async()=>({...await F.get(`/conversations`,{limit:Gt,offset:(D-1)*Gt,search:S||void 0,project_id:w,group_by_project:1}),projectGroup:w,page:D,search:S}),[D,S,w]),Ye=(0,H.useRef)(q.reload);(0,H.useEffect)(()=>{Ye.current=q.reload},[q.reload]);let Xe=be(()=>F.get(`/projects`,{limit:200}),[]),Qe=be(()=>F.get(`/roles`),[p],{skip:!p}),$e=(0,H.useMemo)(()=>Array.isArray(Xe.data?.projects)?Xe.data.projects:[],[Xe.data]),tt=(0,H.useMemo)(()=>(Array.isArray(Qe.data?.roles)?Qe.data.roles:[]).filter(e=>e&&String(e.name||``).trim()).map(e=>({name:String(e.name).trim(),description:String(e.description||``),icon:String(e.icon||``),enabled:e.enabled!==!1})),[Qe.data]),nt=e=>{ce(!1),e?.id&&(Xe.setData(t=>({...t,projects:[e,...t?.projects||[]]})),ht(e.id))},rt=Array.isArray(q.data?.projectGroups)?q.data.projectGroups:[],it=q.data?.projectGroup===w&&q.data?.search===S,J=it&&q.data?.page===D,at=J&&Array.isArray(q.data.conversations)?q.data.conversations:[],Y=it&&q.data.total||0;(0,H.useEffect)(()=>{if(!J)return;let e=Math.max(1,Math.ceil(Y/Gt));D>e&&ne(e)},[J,Y,D]);let ot=(0,H.useCallback)(e=>{T(e),te(!0),ne(1)},[]),X=(0,H.useCallback)(async(e,{silent:t=!1}={})=>{let n=++Ue.current;if(!e)return I(Zt),null;t||I(e=>({...e,loading:!0,error:null}));try{let t=await F.get(`/conversations/${encodeURIComponent(e)}`,{include_process_details:1});return n!==Ue.current||v.current!==e?null:(I({conversation:t||null,messages:Array.isArray(t?.messages)?t.messages:[],loading:!1,error:null}),t)}catch(t){return n===Ue.current&&v.current===e&&I(e=>({...e,loading:!1,error:t})),null}},[]),Z=(0,H.useCallback)(async()=>{let e=v.current,t=++We.current;if(e&&u)try{let n=await F.get(`/hitl/pending`,{conversationId:e,pageSize:50});if(t!==We.current||v.current!==e)return;let r=(Array.isArray(n?.items)?n.items:[]).filter(t=>!t.conversationId||t.conversationId===e);Ae({id:e,items:r})}catch{}},[u]),Q=(0,H.useCallback)(async()=>{let e=v.current;if(!e){Pe(Xt);return}let t=++Ge.current;Le(!0);try{let n=await F.get(`/conversations/${encodeURIComponent(e)}/plan-tasks`);t===Ge.current&&v.current===e&&Pe(n&&typeof n==`object`?n:Xt)}catch{}finally{t===Ge.current&&v.current===e&&Le(!1)}},[]),$=Ht({conversationRef:v,bindConversation:(0,H.useCallback)(e=>{_e(null),y.current=e,v.current=e,j(t=>{if(t.has(e))return t;let n=new Map(t);return n.set(e,M.current),n}),g({conversation:e},{replace:!0}),Ye.current?.({silent:!0})},[g]),requestDetailReload:X,onSettled:(0,H.useCallback)(()=>{Ye.current?.({silent:!0}),Z(),Q()},[Z,Q]),onHitlEvent:Z,onPlanTool:Q,t:e}),{live:st,sending:ct,lastEvents:lt,reset:ut,isStreaming:dt}=$;(0,H.useEffect)(()=>{let e=_&&y.current===_;y.current=null,e||dt(_)||(ut(),Ue.current++,We.current++,Ge.current++,I(Zt),Ae(null),Ne(``),Pe(Xt),Le(!1),ze(!1),_&&(X(_),Z(),Q()))},[_,dt,ut,X,Z,Q]),Te(()=>{Z(),Q(),K&&(Ke.reload({silent:!0}),!ct&&v.current&&X(v.current,{silent:!0}))},ct||K?4e3:0),(0,H.useEffect)(()=>{Je.current===_&&!K&&(X(_,{silent:!0}),Ye.current?.({silent:!0})),Je.current=K?_:null},[K,_,X]);let ft=async()=>{l&&(await $.stop(),Ke.reload({silent:!0}))},pt=(0,H.useCallback)(e=>{e&&(e!==v.current&&g({conversation:e}),Ve(!1))},[g]),mt=(0,H.useCallback)(()=>{Ye.current?.({silent:!0})},[]),ht=async t=>{if(!n||ct||K||qe||ae)return;let r=t||``,i=v.current;if(!i)ie(r);else if(!(P.conversation?.id!==i||P.loading||P.error)){k(!0);try{await F.put(`/conversations/${encodeURIComponent(i)}/project`,{projectId:r}),I(e=>e.conversation?.id===i?{...e,conversation:{...e.conversation,projectId:r}}:e),C&&C!==r||ot(r||Kt),mt()}catch(t){z(t,e(`chat.projectChangeFailed`,null,`更新对话所属项目失败`))}finally{k(!1)}}},{createConversation:gt,renameConversation:_t,togglePin:vt,deleteConversation:yt,batchDelete:bt,deleteTurn:xt}=Ut({t:e,conversationRef:v,newProjectId:re,canWrite:n,reloadList:mt,requestDetailReload:X,navigate:g,onSelectionCleared:(0,H.useCallback)(()=>I(Zt),[])}),St=(0,H.useCallback)(async(t,n,r)=>{let i=v.current;if(d&&t?.interruptId&&V?.id===i&&V.items.some(e=>String(e.id||e.interruptId)===t.interruptId)){Ne(t.interruptId);try{await F.post(`/hitl/decision`,{interruptId:t.interruptId,decision:n,comment:r||``}),De(n===`approve`?e(`chat.hitlApproved`,null,`已批准本次调用`):e(`chat.hitlRejected`,null,`已拒绝本次调用`)),Ae(e=>e?.id===i?{id:i,items:e.items.filter(e=>String(e.id||e.interruptId)!==t.interruptId)}:e)}catch(t){z(t,e(`chat.hitlDecisionFailed`,null,`提交审批失败`))}finally{v.current===i&&(Ne(``),Z())}}},[V,d,Z,e]),Ct=(0,H.useCallback)(async t=>{let n=v.current;if(d&&t?.interruptId&&V?.id===n&&V.items.some(e=>String(e.id||e.interruptId)===t.interruptId)){Ne(t.interruptId);try{await F.post(`/hitl/dismiss`,{interruptId:t.interruptId}),De(e(`chat.hitlDismissed`,null,`已忽略该审批`)),Ae(e=>e?.id===n?{id:n,items:e.items.filter(e=>String(e.id||e.interruptId)!==t.interruptId)}:e)}catch(t){z(t,e(`chat.hitlDismissFailed`,null,`忽略审批失败`))}finally{v.current===n&&(Ne(``),Z())}}},[V,d,Z,e]),wt=(0,H.useCallback)(async t=>{let n=v.current,r=e=>Ee(n,t=>({...t,attachments:e(t.attachments||[])})),i=t.map((e,t)=>({id:`att-${Date.now()}-${t}`,fileName:e.name,mimeType:e.type||``,serverPath:``,uploading:!0,error:!1}));r(e=>[...e,...i]),await Promise.all(i.map(async(i,a)=>{let o=new FormData;o.append(`file`,t[a]),n&&o.append(`conversationId`,n);try{let e=await F.post(`/chat-uploads`,o),t=String(e?.absolutePath||``).trim();if(!t)throw Error(`服务端未返回文件路径`);r(e=>e.map(e=>e.id===i.id?{...e,serverPath:t,uploading:!1,error:!1}:e))}catch(t){r(e=>e.map(e=>e.id===i.id?{...e,uploading:!1,error:!0}:e)),z(t,e(`chat.attachmentUploadFailed`,{name:i.fileName},`附件 ${i.fileName} 上传失败`))}}))},[Ee,e]),Tt=(0,H.useCallback)(e=>{Ee(_,t=>({...t,attachments:(t.attachments||[]).filter(t=>t.id!==e)}))},[_,Ee]),Et=pe.has(_),Ot=P.conversation?.id===_?P.conversation:null,At=!_||Et||!!Ot,Mt=Et?Yt(pe.get(_)):Ot?Yt(Ot.roleName):_?``:Yt(fe),Nt=(0,H.useCallback)(e=>{let t=Yt(e);A(t),j(e=>{let n=new Map(e);return n.set(_,t),n})},[_,A]),Pt=(0,H.useCallback)(()=>{if(!n||!o||ct||K||qe||ae||N.waitingForChannel||!At)return;let t=Ce.trim();if(!t&&!B.length){R(e(`chat.emptyMessage`,null,`请输入内容或添加附件`));return}if(B.some(e=>e.uploading)){R(e(`chat.waitingAttachmentsUpload`,null,`附件仍在上传,请稍候`));return}let r=B.filter(e=>e.serverPath&&!e.error);if(B.length&&r.length!==B.length){R(e(`chat.attachmentsUploadIncomplete`,null,`存在上传失败的附件,请移除后再发送`));return}let i=t||e(`chat.filePrompt`,null,`请解析我上传的附件。`),a=r.length?`${i}\n${r.map(e=>`📎 ${e.fileName}`).join(`
`)}`:i;I(e=>({...e,messages:[...e.messages||[],{id:`local-${Date.now()}`,role:`user`,content:a,createdAt:new Date().toISOString()}]})),ut(),Ee(_,()=>({draft:``,attachments:[]})),M.current=Mt,$.send({message:i,attachments:r,mode:de,projectId:re,role:Mt,...N.request,hitl:!_&&d&&ge||void 0})},[B,K,n,o,d,qe,_,Ce,ge,de,N,re,ae,ut,Mt,At,$,ct,e,Ee]),Ft=P.conversation,It=(0,H.useRef)(``);(0,H.useEffect)(()=>{if(!_){It.current=``;return}if(Ft?.id!==_||It.current===_)return;It.current=_;let e=Ft.projectId||Kt;C&&C!==e||w===e&&E||ot(e)},[Ft,_,E,ot,C,w]);let Rt=rt.find(e=>!e.projectId)?.total||0,zt=[{id:Kt,title:e(`chat.defaultWorkspace`,null,`默认工作区`),total:Rt},...rt.filter(e=>e.projectId).map(t=>({id:t.projectId,title:$e.find(e=>e.id===t.projectId)?.name||e(`chat.boundProject`,null,`已绑定项目`),total:t.total,projectId:t.projectId}))],Bt=(0,U.jsx)(et,{items:E?at:[],groups:zt.filter(e=>!C||e.id===C),expandedGroup:E?w:``,groupTotal:Y,onToggleGroup:e=>{e===w&&E?te(!1):e===w?te(!0):ot(e)},loading:q.loading||!J&&!q.error,error:q.error,onRetry:()=>q.reload(),search:b,onSearch:e=>{x(e),ne(1)},projectId:C,onProjectChange:e=>{ee(e||``),ot(e||Kt)},projects:$e,page:D,pageSize:Gt,onPageChange:ne,selectedId:_,onSelect:pt,onCreate:gt,onRename:_t,onPin:vt,onDelete:yt,onBatchDelete:bt,canWrite:n,canDelete:s});return(0,U.jsxs)(`div`,{className:`chat-page`,children:[!He&&(0,U.jsx)(`aside`,{className:`chat-sidebar`,children:Bt}),(0,U.jsxs)(`section`,{className:`chat-main`,children:[(0,U.jsx)(Fe,{conversation:Ft,mode:de,hitlCount:je.length,conversationId:_,narrow:He,onToggleSidebar:()=>Ve(!0),onRefresh:()=>{Ye.current?.(),_&&X(_),Z(),Q()}}),(0,U.jsxs)(`div`,{className:`chat-panel`,children:[(0,U.jsx)(Dt,{conversationId:_,messages:P.messages,live:st,loading:P.loading||!(!_||P.conversation||P.error),error:P.error,onRetry:()=>_?X(_):null,canDelete:s,onDeleteTurn:xt}),W.running&&W.total>0&&(0,U.jsxs)(`div`,{className:`chat-plan-strip`,children:[(0,U.jsx)(Wt,{size:`small`,children:e(`chat.planTasks`,null,`执行计划`)}),(0,U.jsx)(oe,{percent:Math.round(Number(W.completed||0)/Math.max(1,Number(W.total))*100),showInfo:!1,size:`small`,className:`chat-plan-strip-bar`}),(0,U.jsxs)(Wt,{size:`small`,type:`tertiary`,children:[W.completed,`/`,W.total,W.activeStep?` · ${e(`chat.planStep`,{step:W.activeStep},`第 ${W.activeStep} 步`)}`:``]}),(0,U.jsx)(m,{size:`small`,theme:`borderless`,onClick:()=>{Q(),ze(!0)},children:e(`chat.planDetails`,null,`详情`)})]}),lt.length>0&&!st&&(0,U.jsx)(i,{className:`chat-events-strip`,children:(0,U.jsx)(i.Panel,{itemKey:`1`,header:`${e(`chat.rawEvents`,null,`本轮原始事件`)} · ${lt.length}`,children:(0,U.jsx)(`pre`,{className:`chat-pre`,children:lt.map((e,t)=>`${t+1}. ${JSON.stringify(e)}`).join(`
diff --git a/web/static/app/assets/chat-files-B0eFLyD7.js b/web/static/app/assets/chat-files-BqcGDJ-j.js
similarity index 99%
rename from web/static/app/assets/chat-files-B0eFLyD7.js
rename to web/static/app/assets/chat-files-BqcGDJ-j.js
index ddec7955..0eaf003f 100644
--- a/web/static/app/assets/chat-files-B0eFLyD7.js
+++ b/web/static/app/assets/chat-files-BqcGDJ-j.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,J as a,L as o,M as s,U as c,W as l,f as u,lt as d,ot as f,st as p,v as m}from"./semi-Dpcldp_F.js";import{E as h,F as ee,I as g,L as _,P as v,S as te,T as y,a as ne,b,c as re,l as x,m as ie,n as ae,o as S,p as oe,s as se,x as C,y as ce}from"./index-gBcdNgHq.js";var w=e(t(),1);function le(e){return g.get(`/chat-uploads`,e)}function ue(e,{relativeDir:t}={}){let n=new FormData;return n.append(`file`,e,e.name),t&&n.append(`relativeDir`,t),g.post(`/chat-uploads`,n)}function de(e,t){return g.post(`/chat-uploads/mkdir`,{parent:e||``,name:t})}function fe(e){return g.del(`/chat-uploads`,{body:{path:e}})}function T(e){return g.get(`/chat-uploads/content`,{path:e})}function pe(e,t=`file`){return g.get(`/chat-uploads/path`,{path:e,kind:t})}function me(e){return _(`/chat-uploads/export`,{query:e,filename:`chat-files-export.zip`})}function E(e,t){return _(`/chat-uploads/download`,{query:{path:e},filename:t})}async function D(e){let t=await(await g.raw(`/chat-uploads/download`,{query:{path:e},timeout:12e4})).blob();return{url:URL.createObjectURL(t),type:t.type,size:t.size}}var O=e(n(),1),{Text:k}=l,he=/\.(png|jpe?g|gif|webp|bmp|svg|ico)$/i,A=/\.(txt|log|md|markdown|json|ya?ml|csv|tsv|xml|html?|css|jsx?|tsx?|py|go|java|c|h|cpp|sh|sql|ini|conf|toml|env|pem)$/i;function j(e){let t=e?.name||``;return he.test(t)?`image`:A.test(t)?`text`:`binary`}function ge({item:e,onClose:t}){let n=v(),[r,i]=(0,w.useState)(!1),[a,s]=(0,w.useState)(null),[l,d]=(0,w.useState)(``),[f,p]=(0,w.useState)(``),[m,h]=(0,w.useState)(`text`);return(0,w.useEffect)(()=>{let t=``,n=!1;if(!e)return d(``),p(``),s(null),()=>{};let r=j(e);return h(r),i(!0),s(null),d(``),p(``),(async()=>{try{if(r===`image`){let r=await D(e.relativePath);if(n){URL.revokeObjectURL(r.url);return}t=r.url,p(r.url)}else if(r===`text`){let t=await T(e.relativePath);if(n)return;d(t?.content??``)}}catch(e){n||(s(e),r===`text`&&h(`binary`))}finally{n||i(!1)}})(),()=>{n=!0,t&&URL.revokeObjectURL(t)}},[e]),(0,O.jsx)(u,{visible:!!e,title:e?.name||n(`chatFilesPage.previewTitle`,null,`文件预览`),width:720,onCancel:t,footer:(0,O.jsx)(o,{onClick:async()=>{if(e)try{await E(e.relativePath,e.name)}catch(e){b(e,n(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},children:n(`chatFilesPage.download`,null,`下载`)}),children:e&&(0,O.jsxs)(`div`,{className:`chat-files-preview`,children:[(0,O.jsxs)(`div`,{className:`chat-files-preview-meta`,children:[(0,O.jsx)(k,{type:`tertiary`,size:`small`,children:y(e.size)}),(0,O.jsx)(k,{type:`tertiary`,size:`small`,className:`chat-files-mono`,children:e.relativePath}),(0,O.jsx)(S,{text:e.relativePath,label:n(`chatFilesPage.copyPath`,null,`复制路径`),size:`small`})]}),(0,O.jsx)(x,{error:m===`binary`?null:a}),r&&(0,O.jsx)(`div`,{className:`chat-files-preview-loading`,children:(0,O.jsx)(c,{})}),!r&&m===`image`&&f&&(0,O.jsx)(`img`,{className:`chat-files-preview-image`,src:f,alt:e.name}),!r&&m===`text`&&(0,O.jsx)(`pre`,{className:`chat-files-preview-text`,children:l}),!r&&m===`binary`&&(0,O.jsx)(k,{type:`tertiary`,children:n(`chatFilesPage.editBinaryHint`,null,`图片、压缩包等二进制文件无法在此以文本方式编辑,请使用「下载」后在本地查看或处理。`)})]})})}var{Text:M}=l,_e=[{value:`all`,label:`全部`},{value:`upload`,label:`对话附件`},{value:`reduction`,label:`工具输出`},{value:`workspace`,label:`工作目录`},{value:`conversation_artifact`,label:`会话产物`}],ve={upload:`对话附件`,reduction:`工具输出`,workspace:`工作目录`,conversation_artifact:`会话产物`};function N(e){let t=String(e||``).split(`/`);return t.pop(),t.join(`/`)}function P(e){let t=String(e||``).split(`/`);return t[t.length-1]||e}function F(){let e=v(),{hasPermission:t}=ee(),n=t(`files:write`),c=t(`files:delete`)||n,l=(0,w.useRef)(null),[u,g]=(0,w.useState)(`list`),[_,S]=(0,w.useState)(``),[T,D]=(0,w.useState)(``),[k,he]=(0,w.useState)(`all`),[A,j]=(0,w.useState)(``),[F,I]=(0,w.useState)(``),[L,R]=(0,w.useState)(1),[z,ye]=(0,w.useState)(20),[be,B]=(0,w.useState)(null),[V,H]=(0,w.useState)(null),[xe,U]=(0,w.useState)(!1),W=ae(A,300),G=(0,w.useMemo)(()=>{let e={conversation:_.trim()||void 0,project:T.trim()||void 0,source:k===`all`?void 0:k,search:W.trim()||void 0};return u===`browse`?{...e,page:1,pageSize:`all`}:{...e,page:L,pageSize:z}},[u,_,T,k,W,L,z]),{data:K,loading:q,error:Se,reload:J}=ne(()=>le(G),[G]),Y=Array.isArray(K?.files)?K.files:[],X=Array.isArray(K?.folders)?K.folders:[],Z=Number(K?.total??Y.length),Q=(0,w.useMemo)(()=>u===`browse`?{folders:X.filter(e=>N(e)===F),files:Y.filter(e=>N(e.relativePath)===F)}:{folders:[],files:Y},[u,X,Y,F]),Ce=(0,w.useMemo)(()=>{let t=F?F.split(`/`):[],n=[{label:e(`chatFilesPage.browseRoot`,null,`文件`),path:``}];return t.forEach((e,r)=>n.push({label:e,path:t.slice(0,r+1).join(`/`)})),n},[F,e]),we=async t=>{try{let n=await pe(t.relativePath,`file`);await navigator.clipboard.writeText(n?.absolutePath||t.relativePath),C(e(`chatFilesPage.pathCopied`,null,`路径已复制,可到对话中粘贴使用`))}catch(t){b(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Te=async t=>{try{await E(t.relativePath,t.name)}catch(t){b(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Ee=t=>{ce({title:e(`chatFilesPage.confirmDelete`,null,`确定删除该文件?`),content:t.relativePath,onOk:async()=>{try{await fe(t.relativePath),C(e(`chatFilesPage.deleted`,null,`已删除`)),J()}catch(e){b(e)}}})},De=()=>l.current?.click(),Oe=async t=>{let n=Array.from(t.target.files||[]);if(t.target.value=``,n.length){U(!0);try{for(let e of n)await ue(e,{relativeDir:u===`browse`?F:``});C(e(`chatFilesPage.uploadOkHint`,null,`上传成功。点击「复制路径」可复制绝对路径到剪贴板。`)),J()}catch(t){b(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}finally{U(!1)}}},ke=async()=>{let t=String(V?.name||``).trim();if(!t||t.includes(`/`)||t.includes(`\\`)||t===`.`||t===`..`)te(e(`chatFilesPage.mkdirInvalidName`,null,`名称无效:不能为空,且不能包含 /、\\ 或 . / ..`));else try{await de(u===`browse`?F:``,t),C(e(`chatFilesPage.mkdirOk`,null,`文件夹已创建`)),H(null),J()}catch(t){b(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Ae=async()=>{try{await me({conversation:_.trim()||void 0,project:T.trim()||void 0,source:k===`all`?void 0:k,search:W.trim()||void 0}),C(e(`chatFilesPage.exportStarted`,null,`已开始导出当前文件`))}catch(t){b(t,e(`chatFilesPage.exportEmpty`,null,`没有可导出的文件`))}},je=[{title:e(`chatFilesPage.colName`,null,`文件名`),dataIndex:`name`,render:(e,t)=>(0,O.jsx)(`button`,{type:`button`,className:`chat-files-name`,onClick:()=>B(t),title:t.relativePath,children:e||P(t.relativePath)})},{title:e(`chatFilesPage.sourceFilter`,null,`来源`),dataIndex:`source`,width:110,render:e=>(0,O.jsx)(s,{size:`small`,children:ve[e]||e||`对话附件`})},{title:e(`chatFilesPage.colConversation`,null,`会话`),dataIndex:`conversationTitle`,width:180,render:(e,t)=>(0,O.jsx)(M,{type:`tertiary`,size:`small`,ellipsis:{showTooltip:!0},children:e||t.conversationId||`—`})},{title:e(`chatFilesPage.colSubPath`,null,`路径`),dataIndex:`relativePath`,width:220,render:e=>(0,O.jsx)(`span`,{className:`chat-files-path`,children:e})},{title:e(`chatFilesPage.colSize`,null,`大小`),dataIndex:`size`,width:100,render:e=>y(e)},{title:e(`chatFilesPage.colModified`,null,`修改时间`),dataIndex:`modifiedUnix`,width:170,render:e=>h(e?e*1e3:null)},{title:e(`chatFilesPage.colActions`,null,`操作`),dataIndex:`actions`,width:260,render:(t,n)=>(0,O.jsxs)(r,{spacing:4,wrap:!0,children:[(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>B(n),children:e(`chatFilesPage.preview`,null,`预览`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>we(n),children:e(`chatFilesPage.copyPath`,null,`复制路径`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>Te(n),children:e(`chatFilesPage.download`,null,`下载`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!c,onClick:()=>Ee(n),children:e(`chatFilesPage.delete`,null,`删除`)})]})}],Me=[{title:e(`chatFilesPage.colName`,null,`文件名`),dataIndex:`name`,render:(e,t)=>t.isDir?(0,O.jsxs)(`button`,{type:`button`,className:`chat-files-name is-dir`,onClick:()=>I(t.path),children:[e,`/`]}):(0,O.jsx)(`button`,{type:`button`,className:`chat-files-name`,onClick:()=>B(t),title:t.relativePath,children:e})},{title:e(`chatFilesPage.colSize`,null,`大小`),dataIndex:`size`,width:110,render:e=>e===void 0?`—`:y(e)},{title:e(`chatFilesPage.colModified`,null,`修改时间`),dataIndex:`modifiedUnix`,width:180,render:e=>e?h(e*1e3):`—`},{title:e(`chatFilesPage.colActions`,null,`操作`),dataIndex:`actions`,width:240,render:(t,n)=>n.isDir?(0,O.jsx)(r,{spacing:4,children:(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>I(n.path),children:e(`chatFilesPage.enterFolder`,null,`进入`)})}):(0,O.jsxs)(r,{spacing:4,wrap:!0,children:[(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>B(n),children:e(`chatFilesPage.preview`,null,`预览`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>we(n),children:e(`chatFilesPage.copyPath`,null,`复制路径`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>Te(n),children:e(`chatFilesPage.download`,null,`下载`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!c,onClick:()=>Ee(n),children:e(`chatFilesPage.delete`,null,`删除`)})]})}],Ne=[...Q.folders.map(e=>({rowKey:`dir:${e}`,isDir:!0,path:e,name:P(e)})),...Q.files.map(e=>({...e,rowKey:e.relativePath}))],$=u===`browse`?Ne:Y;return(0,O.jsxs)(`div`,{className:`chat-files-page`,id:`page-chat-files`,children:[(0,O.jsx)(oe,{title:e(`chatFilesPage.title`,null,`文件管理`),description:e(`chatFilesPage.intro`,null,`管理在对话中上传的文件,可复制路径供 AI 引用`),extra:[(0,O.jsx)(o,{onClick:Ae,children:e(`chatFilesPage.export`,null,`导出当前结果`)},`export`),(0,O.jsx)(o,{icon:(0,O.jsx)(d,{}),disabled:!n,onClick:()=>H({name:``}),children:e(`chatFilesPage.newFolderButton`,null,`新建文件夹`)},`mkdir`),(0,O.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,O.jsx)(a,{}),loading:xe,disabled:!n,onClick:De,children:e(`chatFilesPage.upload`,null,`上传文件`)},`upload`),(0,O.jsx)(o,{icon:(0,O.jsx)(p,{}),onClick:J,loading:q,children:e(`common.refresh`,null,`刷新`)},`refresh`)]}),(0,O.jsx)(`input`,{ref:l,type:`file`,multiple:!0,hidden:!0,onChange:Oe}),(0,O.jsx)(x,{error:Se,onRetry:J}),(0,O.jsx)(ie,{title:e(`chatFilesPage.filterTitle`,null,`筛选`),children:(0,O.jsxs)(`div`,{className:`chat-files-fields`,children:[(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.conversationFilter`,null,`会话 ID`)}),(0,O.jsx)(i,{value:_,onChange:e=>{S(e),R(1)},placeholder:e(`chatFilesPage.conversationPlaceholder`,null,`留空表示全部`),style:{width:200}})]}),(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.projectFilter`,null,`项目 ID`)}),(0,O.jsx)(i,{value:T,onChange:e=>{D(e),R(1)},placeholder:e(`chatFilesPage.projectPlaceholder`,null,`留空表示全部`),style:{width:200}})]}),(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.searchName`,null,`文件名`)}),(0,O.jsx)(i,{value:A,onChange:e=>{j(e),R(1)},prefix:(0,O.jsx)(f,{}),placeholder:e(`chatFilesPage.searchNamePlaceholder`,null,`筛选文件名`),style:{width:200}})]}),(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.sourceFilter`,null,`来源`)}),(0,O.jsx)(m,{value:k,onChange:e=>{he(e||`all`),R(1)},optionList:_e,style:{width:160}})]}),(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.groupBy`,null,`分组方式`)}),(0,O.jsx)(m,{value:u,onChange:e=>{g(e||`list`),R(1),I(``)},optionList:[{value:`list`,label:e(`chatFilesPage.groupNone`,null,`不分组(平铺)`)},{value:`browse`,label:e(`chatFilesPage.groupByFolder`,null,`按文件夹(路径浏览)`)}],style:{width:200}})]})]})}),u===`browse`&&(0,O.jsx)(`nav`,{className:`chat-files-breadcrumb`,"aria-label":`breadcrumb`,children:Ce.map((e,t)=>(0,O.jsxs)(`span`,{className:`chat-files-breadcrumb-item`,children:[t>0&&(0,O.jsx)(`span`,{className:`chat-files-breadcrumb-sep`,children:`/`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>I(e.path),children:e.label})]},e.path||`root`))}),(0,O.jsx)(ie,{title:u===`browse`?e(`chatFilesPage.browseRoot`,null,`文件`):e(`chatFilesPage.listTitle`,null,`附件列表`),extra:(0,O.jsx)(M,{type:`tertiary`,size:`small`,children:e(`chatFilesPage.paginationInfo`,null,`显示 {{start}}-{{end}} / {{total}} 个文件`).replace(`{{start}}`,$.length?`1`:`0`).replace(`{{end}}`,String($.length)).replace(`{{total}}`,String(u===`browse`?$.length:Z))}),children:(0,O.jsx)(se,{columns:u===`browse`?Me:je,dataSource:$,rowKey:e=>e.rowKey||e.relativePath,loading:q,onRefresh:J,pagination:u!==`browse`&&{currentPage:L,pageSize:z,total:Z,onPageChange:e=>R(e),onPageSizeChange:e=>{ye(e),R(1)}},emptyText:u===`browse`?e(`chatFilesPage.folderEmpty`,null,`此文件夹为空`):e(`chatFilesPage.empty`,null,`暂无对话附件`)})}),(0,O.jsx)(ge,{item:be,onClose:()=>B(null)}),(0,O.jsxs)(re,{visible:!!V,title:e(`chatFilesPage.newFolderTitle`,null,`新建文件夹`),width:420,onCancel:()=>H(null),onOk:ke,children:[(0,O.jsxs)(M,{type:`tertiary`,size:`small`,children:[e(`chatFilesPage.newFolderLocation`,null,`位置`),`:`,u===`browse`&&F?F:`/`]}),(0,O.jsx)(i,{value:V?.name||``,onChange:e=>H({name:e}),placeholder:e(`chatFilesPage.newFolderNamePlaceholder`,null,`仅名称,不含 /`),style:{marginTop:8}})]})]})}export{F as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,J as a,L as o,M as s,U as c,W as l,f as u,lt as d,ot as f,st as p,v as m}from"./semi-Dpcldp_F.js";import{E as h,F as ee,I as g,L as _,P as v,S as te,T as y,a as ne,b,c as re,l as x,m as ie,n as ae,o as S,p as oe,s as se,x as C,y as ce}from"./index-BMTtTYg1.js";var w=e(t(),1);function le(e){return g.get(`/chat-uploads`,e)}function ue(e,{relativeDir:t}={}){let n=new FormData;return n.append(`file`,e,e.name),t&&n.append(`relativeDir`,t),g.post(`/chat-uploads`,n)}function de(e,t){return g.post(`/chat-uploads/mkdir`,{parent:e||``,name:t})}function fe(e){return g.del(`/chat-uploads`,{body:{path:e}})}function T(e){return g.get(`/chat-uploads/content`,{path:e})}function pe(e,t=`file`){return g.get(`/chat-uploads/path`,{path:e,kind:t})}function me(e){return _(`/chat-uploads/export`,{query:e,filename:`chat-files-export.zip`})}function E(e,t){return _(`/chat-uploads/download`,{query:{path:e},filename:t})}async function D(e){let t=await(await g.raw(`/chat-uploads/download`,{query:{path:e},timeout:12e4})).blob();return{url:URL.createObjectURL(t),type:t.type,size:t.size}}var O=e(n(),1),{Text:k}=l,he=/\.(png|jpe?g|gif|webp|bmp|svg|ico)$/i,A=/\.(txt|log|md|markdown|json|ya?ml|csv|tsv|xml|html?|css|jsx?|tsx?|py|go|java|c|h|cpp|sh|sql|ini|conf|toml|env|pem)$/i;function j(e){let t=e?.name||``;return he.test(t)?`image`:A.test(t)?`text`:`binary`}function ge({item:e,onClose:t}){let n=v(),[r,i]=(0,w.useState)(!1),[a,s]=(0,w.useState)(null),[l,d]=(0,w.useState)(``),[f,p]=(0,w.useState)(``),[m,h]=(0,w.useState)(`text`);return(0,w.useEffect)(()=>{let t=``,n=!1;if(!e)return d(``),p(``),s(null),()=>{};let r=j(e);return h(r),i(!0),s(null),d(``),p(``),(async()=>{try{if(r===`image`){let r=await D(e.relativePath);if(n){URL.revokeObjectURL(r.url);return}t=r.url,p(r.url)}else if(r===`text`){let t=await T(e.relativePath);if(n)return;d(t?.content??``)}}catch(e){n||(s(e),r===`text`&&h(`binary`))}finally{n||i(!1)}})(),()=>{n=!0,t&&URL.revokeObjectURL(t)}},[e]),(0,O.jsx)(u,{visible:!!e,title:e?.name||n(`chatFilesPage.previewTitle`,null,`文件预览`),width:720,onCancel:t,footer:(0,O.jsx)(o,{onClick:async()=>{if(e)try{await E(e.relativePath,e.name)}catch(e){b(e,n(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},children:n(`chatFilesPage.download`,null,`下载`)}),children:e&&(0,O.jsxs)(`div`,{className:`chat-files-preview`,children:[(0,O.jsxs)(`div`,{className:`chat-files-preview-meta`,children:[(0,O.jsx)(k,{type:`tertiary`,size:`small`,children:y(e.size)}),(0,O.jsx)(k,{type:`tertiary`,size:`small`,className:`chat-files-mono`,children:e.relativePath}),(0,O.jsx)(S,{text:e.relativePath,label:n(`chatFilesPage.copyPath`,null,`复制路径`),size:`small`})]}),(0,O.jsx)(x,{error:m===`binary`?null:a}),r&&(0,O.jsx)(`div`,{className:`chat-files-preview-loading`,children:(0,O.jsx)(c,{})}),!r&&m===`image`&&f&&(0,O.jsx)(`img`,{className:`chat-files-preview-image`,src:f,alt:e.name}),!r&&m===`text`&&(0,O.jsx)(`pre`,{className:`chat-files-preview-text`,children:l}),!r&&m===`binary`&&(0,O.jsx)(k,{type:`tertiary`,children:n(`chatFilesPage.editBinaryHint`,null,`图片、压缩包等二进制文件无法在此以文本方式编辑,请使用「下载」后在本地查看或处理。`)})]})})}var{Text:M}=l,_e=[{value:`all`,label:`全部`},{value:`upload`,label:`对话附件`},{value:`reduction`,label:`工具输出`},{value:`workspace`,label:`工作目录`},{value:`conversation_artifact`,label:`会话产物`}],ve={upload:`对话附件`,reduction:`工具输出`,workspace:`工作目录`,conversation_artifact:`会话产物`};function N(e){let t=String(e||``).split(`/`);return t.pop(),t.join(`/`)}function P(e){let t=String(e||``).split(`/`);return t[t.length-1]||e}function F(){let e=v(),{hasPermission:t}=ee(),n=t(`files:write`),c=t(`files:delete`)||n,l=(0,w.useRef)(null),[u,g]=(0,w.useState)(`list`),[_,S]=(0,w.useState)(``),[T,D]=(0,w.useState)(``),[k,he]=(0,w.useState)(`all`),[A,j]=(0,w.useState)(``),[F,I]=(0,w.useState)(``),[L,R]=(0,w.useState)(1),[z,ye]=(0,w.useState)(20),[be,B]=(0,w.useState)(null),[V,H]=(0,w.useState)(null),[xe,U]=(0,w.useState)(!1),W=ae(A,300),G=(0,w.useMemo)(()=>{let e={conversation:_.trim()||void 0,project:T.trim()||void 0,source:k===`all`?void 0:k,search:W.trim()||void 0};return u===`browse`?{...e,page:1,pageSize:`all`}:{...e,page:L,pageSize:z}},[u,_,T,k,W,L,z]),{data:K,loading:q,error:Se,reload:J}=ne(()=>le(G),[G]),Y=Array.isArray(K?.files)?K.files:[],X=Array.isArray(K?.folders)?K.folders:[],Z=Number(K?.total??Y.length),Q=(0,w.useMemo)(()=>u===`browse`?{folders:X.filter(e=>N(e)===F),files:Y.filter(e=>N(e.relativePath)===F)}:{folders:[],files:Y},[u,X,Y,F]),Ce=(0,w.useMemo)(()=>{let t=F?F.split(`/`):[],n=[{label:e(`chatFilesPage.browseRoot`,null,`文件`),path:``}];return t.forEach((e,r)=>n.push({label:e,path:t.slice(0,r+1).join(`/`)})),n},[F,e]),we=async t=>{try{let n=await pe(t.relativePath,`file`);await navigator.clipboard.writeText(n?.absolutePath||t.relativePath),C(e(`chatFilesPage.pathCopied`,null,`路径已复制,可到对话中粘贴使用`))}catch(t){b(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Te=async t=>{try{await E(t.relativePath,t.name)}catch(t){b(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Ee=t=>{ce({title:e(`chatFilesPage.confirmDelete`,null,`确定删除该文件?`),content:t.relativePath,onOk:async()=>{try{await fe(t.relativePath),C(e(`chatFilesPage.deleted`,null,`已删除`)),J()}catch(e){b(e)}}})},De=()=>l.current?.click(),Oe=async t=>{let n=Array.from(t.target.files||[]);if(t.target.value=``,n.length){U(!0);try{for(let e of n)await ue(e,{relativeDir:u===`browse`?F:``});C(e(`chatFilesPage.uploadOkHint`,null,`上传成功。点击「复制路径」可复制绝对路径到剪贴板。`)),J()}catch(t){b(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}finally{U(!1)}}},ke=async()=>{let t=String(V?.name||``).trim();if(!t||t.includes(`/`)||t.includes(`\\`)||t===`.`||t===`..`)te(e(`chatFilesPage.mkdirInvalidName`,null,`名称无效:不能为空,且不能包含 /、\\ 或 . / ..`));else try{await de(u===`browse`?F:``,t),C(e(`chatFilesPage.mkdirOk`,null,`文件夹已创建`)),H(null),J()}catch(t){b(t,e(`chatFilesPage.errorGeneric`,null,`操作失败,请稍后重试。`))}},Ae=async()=>{try{await me({conversation:_.trim()||void 0,project:T.trim()||void 0,source:k===`all`?void 0:k,search:W.trim()||void 0}),C(e(`chatFilesPage.exportStarted`,null,`已开始导出当前文件`))}catch(t){b(t,e(`chatFilesPage.exportEmpty`,null,`没有可导出的文件`))}},je=[{title:e(`chatFilesPage.colName`,null,`文件名`),dataIndex:`name`,render:(e,t)=>(0,O.jsx)(`button`,{type:`button`,className:`chat-files-name`,onClick:()=>B(t),title:t.relativePath,children:e||P(t.relativePath)})},{title:e(`chatFilesPage.sourceFilter`,null,`来源`),dataIndex:`source`,width:110,render:e=>(0,O.jsx)(s,{size:`small`,children:ve[e]||e||`对话附件`})},{title:e(`chatFilesPage.colConversation`,null,`会话`),dataIndex:`conversationTitle`,width:180,render:(e,t)=>(0,O.jsx)(M,{type:`tertiary`,size:`small`,ellipsis:{showTooltip:!0},children:e||t.conversationId||`—`})},{title:e(`chatFilesPage.colSubPath`,null,`路径`),dataIndex:`relativePath`,width:220,render:e=>(0,O.jsx)(`span`,{className:`chat-files-path`,children:e})},{title:e(`chatFilesPage.colSize`,null,`大小`),dataIndex:`size`,width:100,render:e=>y(e)},{title:e(`chatFilesPage.colModified`,null,`修改时间`),dataIndex:`modifiedUnix`,width:170,render:e=>h(e?e*1e3:null)},{title:e(`chatFilesPage.colActions`,null,`操作`),dataIndex:`actions`,width:260,render:(t,n)=>(0,O.jsxs)(r,{spacing:4,wrap:!0,children:[(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>B(n),children:e(`chatFilesPage.preview`,null,`预览`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>we(n),children:e(`chatFilesPage.copyPath`,null,`复制路径`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>Te(n),children:e(`chatFilesPage.download`,null,`下载`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!c,onClick:()=>Ee(n),children:e(`chatFilesPage.delete`,null,`删除`)})]})}],Me=[{title:e(`chatFilesPage.colName`,null,`文件名`),dataIndex:`name`,render:(e,t)=>t.isDir?(0,O.jsxs)(`button`,{type:`button`,className:`chat-files-name is-dir`,onClick:()=>I(t.path),children:[e,`/`]}):(0,O.jsx)(`button`,{type:`button`,className:`chat-files-name`,onClick:()=>B(t),title:t.relativePath,children:e})},{title:e(`chatFilesPage.colSize`,null,`大小`),dataIndex:`size`,width:110,render:e=>e===void 0?`—`:y(e)},{title:e(`chatFilesPage.colModified`,null,`修改时间`),dataIndex:`modifiedUnix`,width:180,render:e=>e?h(e*1e3):`—`},{title:e(`chatFilesPage.colActions`,null,`操作`),dataIndex:`actions`,width:240,render:(t,n)=>n.isDir?(0,O.jsx)(r,{spacing:4,children:(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>I(n.path),children:e(`chatFilesPage.enterFolder`,null,`进入`)})}):(0,O.jsxs)(r,{spacing:4,wrap:!0,children:[(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>B(n),children:e(`chatFilesPage.preview`,null,`预览`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>we(n),children:e(`chatFilesPage.copyPath`,null,`复制路径`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>Te(n),children:e(`chatFilesPage.download`,null,`下载`)}),(0,O.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,disabled:!c,onClick:()=>Ee(n),children:e(`chatFilesPage.delete`,null,`删除`)})]})}],Ne=[...Q.folders.map(e=>({rowKey:`dir:${e}`,isDir:!0,path:e,name:P(e)})),...Q.files.map(e=>({...e,rowKey:e.relativePath}))],$=u===`browse`?Ne:Y;return(0,O.jsxs)(`div`,{className:`chat-files-page`,id:`page-chat-files`,children:[(0,O.jsx)(oe,{title:e(`chatFilesPage.title`,null,`文件管理`),description:e(`chatFilesPage.intro`,null,`管理在对话中上传的文件,可复制路径供 AI 引用`),extra:[(0,O.jsx)(o,{onClick:Ae,children:e(`chatFilesPage.export`,null,`导出当前结果`)},`export`),(0,O.jsx)(o,{icon:(0,O.jsx)(d,{}),disabled:!n,onClick:()=>H({name:``}),children:e(`chatFilesPage.newFolderButton`,null,`新建文件夹`)},`mkdir`),(0,O.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,O.jsx)(a,{}),loading:xe,disabled:!n,onClick:De,children:e(`chatFilesPage.upload`,null,`上传文件`)},`upload`),(0,O.jsx)(o,{icon:(0,O.jsx)(p,{}),onClick:J,loading:q,children:e(`common.refresh`,null,`刷新`)},`refresh`)]}),(0,O.jsx)(`input`,{ref:l,type:`file`,multiple:!0,hidden:!0,onChange:Oe}),(0,O.jsx)(x,{error:Se,onRetry:J}),(0,O.jsx)(ie,{title:e(`chatFilesPage.filterTitle`,null,`筛选`),children:(0,O.jsxs)(`div`,{className:`chat-files-fields`,children:[(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.conversationFilter`,null,`会话 ID`)}),(0,O.jsx)(i,{value:_,onChange:e=>{S(e),R(1)},placeholder:e(`chatFilesPage.conversationPlaceholder`,null,`留空表示全部`),style:{width:200}})]}),(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.projectFilter`,null,`项目 ID`)}),(0,O.jsx)(i,{value:T,onChange:e=>{D(e),R(1)},placeholder:e(`chatFilesPage.projectPlaceholder`,null,`留空表示全部`),style:{width:200}})]}),(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.searchName`,null,`文件名`)}),(0,O.jsx)(i,{value:A,onChange:e=>{j(e),R(1)},prefix:(0,O.jsx)(f,{}),placeholder:e(`chatFilesPage.searchNamePlaceholder`,null,`筛选文件名`),style:{width:200}})]}),(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.sourceFilter`,null,`来源`)}),(0,O.jsx)(m,{value:k,onChange:e=>{he(e||`all`),R(1)},optionList:_e,style:{width:160}})]}),(0,O.jsxs)(`div`,{className:`chat-files-field`,children:[(0,O.jsx)(`span`,{className:`chat-files-field-label`,children:e(`chatFilesPage.groupBy`,null,`分组方式`)}),(0,O.jsx)(m,{value:u,onChange:e=>{g(e||`list`),R(1),I(``)},optionList:[{value:`list`,label:e(`chatFilesPage.groupNone`,null,`不分组(平铺)`)},{value:`browse`,label:e(`chatFilesPage.groupByFolder`,null,`按文件夹(路径浏览)`)}],style:{width:200}})]})]})}),u===`browse`&&(0,O.jsx)(`nav`,{className:`chat-files-breadcrumb`,"aria-label":`breadcrumb`,children:Ce.map((e,t)=>(0,O.jsxs)(`span`,{className:`chat-files-breadcrumb-item`,children:[t>0&&(0,O.jsx)(`span`,{className:`chat-files-breadcrumb-sep`,children:`/`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>I(e.path),children:e.label})]},e.path||`root`))}),(0,O.jsx)(ie,{title:u===`browse`?e(`chatFilesPage.browseRoot`,null,`文件`):e(`chatFilesPage.listTitle`,null,`附件列表`),extra:(0,O.jsx)(M,{type:`tertiary`,size:`small`,children:e(`chatFilesPage.paginationInfo`,null,`显示 {{start}}-{{end}} / {{total}} 个文件`).replace(`{{start}}`,$.length?`1`:`0`).replace(`{{end}}`,String($.length)).replace(`{{total}}`,String(u===`browse`?$.length:Z))}),children:(0,O.jsx)(se,{columns:u===`browse`?Me:je,dataSource:$,rowKey:e=>e.rowKey||e.relativePath,loading:q,onRefresh:J,pagination:u!==`browse`&&{currentPage:L,pageSize:z,total:Z,onPageChange:e=>R(e),onPageSizeChange:e=>{ye(e),R(1)}},emptyText:u===`browse`?e(`chatFilesPage.folderEmpty`,null,`此文件夹为空`):e(`chatFilesPage.empty`,null,`暂无对话附件`)})}),(0,O.jsx)(ge,{item:be,onClose:()=>B(null)}),(0,O.jsxs)(re,{visible:!!V,title:e(`chatFilesPage.newFolderTitle`,null,`新建文件夹`),width:420,onCancel:()=>H(null),onOk:ke,children:[(0,O.jsxs)(M,{type:`tertiary`,size:`small`,children:[e(`chatFilesPage.newFolderLocation`,null,`位置`),`:`,u===`browse`&&F?F:`/`]}),(0,O.jsx)(i,{value:V?.name||``,onChange:e=>H({name:e}),placeholder:e(`chatFilesPage.newFolderNamePlaceholder`,null,`仅名称,不含 /`),style:{marginTop:8}})]})]})}export{F as default};
\ No newline at end of file
diff --git a/web/static/app/assets/dashboard-BoeA5CBF.js b/web/static/app/assets/dashboard-CNznJVIH.js
similarity index 99%
rename from web/static/app/assets/dashboard-BoeA5CBF.js
rename to web/static/app/assets/dashboard-CNznJVIH.js
index ab088696..c0e77b6b 100644
--- a/web/static/app/assets/dashboard-BoeA5CBF.js
+++ b/web/static/app/assets/dashboard-CNznJVIH.js
@@ -1 +1 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,u as i,y as a}from"./react-QV7DAAIx.js";import{Bt as o,F as s,Jt as c,L as l,M as u,Mt as d,Q as f,S as p,T as m,W as h,Wt as g,h as _,nt as v,st as y,v as b,z as x,zt as S}from"./semi-Dpcldp_F.js";import{D as C,E as w,I as T,O as ee,P as E,_ as D,a as O,h as k,k as A,l as j,m as M,p as te,r as ne,w as N}from"./index-gBcdNgHq.js";var P=e(t(),1),F=e(r(),1),I=[`严重`,`高危`,`中危`,`低危`,`信息`],L=[[0,`safe`,`Safe`,`安全`],[3,`low`,`Low`,`低`],[10,`medium`,`Medium`,`中`],[30,`high`,`High`,`高`],[1/0,`severe`,`Severe`,`极高`]],R=[[`open`,`Open`,`待处理`],[`confirmed`,`Confirmed`,`已确认`],[`fixed`,`Fixed`,`已修复`],[`ignored`,`Ignored`,`已忽略`],[`false_positive`,`FalsePositive`,`误报`]];function z(e){return e[0].toUpperCase()+e.slice(1)}function B(e){if(e==null||e===``||![`number`,`string`].includes(typeof e))return null;let t=Number(e);return Number.isFinite(t)&&t>=0?t:null}function V(e){let t=B(e);return t===null?`—`:C(t)}function H(e,t){let n=e?.by_severity;return!n||typeof n!=`object`||Array.isArray(n)?null:B(n[t]??0)}function U(e,t){let n=new URLSearchParams;e&&n.set(`severity`,e),t&&n.set(`status`,t);let r=n.toString();return`/vulnerabilities`+(r?`?`+r:``)}function W(e,t){let n=(e,t)=>`${(210+e*Math.cos(t)).toFixed(3)} ${(201-e*Math.sin(t)).toFixed(3)}`;return`M ${n(188,e)} A 188 188 0 0 1 ${n(188,t)} L ${n(137,t)} A 137 137 0 0 0 ${n(137,e)} Z`}function G(e,t){if(!t)return[];let n=[],r=Math.PI;for(let i of e){if(!i.count)continue;let e=Math.PI*i.count/t,a=r-e,o=Math.min(.014,e/5);n.push({...i,d:W(r-o,a+o)}),r=a}return n}function K({rows:e,total:t,status:n,loading:r,t:a}){let o=(0,P.useId)(),[s,c]=(0,P.useState)(``),[l,u]=(0,P.useState)(``),d=s||l,f=e.find(e=>e.key===d),p=r?`…`:V(f?f.count:t),m=G(e,t),h=e=>({onPointerEnter:()=>c(e),onPointerLeave:()=>c(``),onFocus:()=>u(e),onBlur:()=>u(``)});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`dashboard-severity-chart`,children:[(0,F.jsxs)(`svg`,{viewBox:`0 0 420 217`,role:`group`,"aria-label":a(`dashboard.severityDistribution`,null,`漏洞严重程度分布`),children:[(0,F.jsx)(`defs`,{children:e.map(e=>(0,F.jsxs)(`linearGradient`,{id:o+e.key,x1:`12%`,y1:`0%`,x2:`84%`,y2:`100%`,"data-severity":e.key,children:[(0,F.jsx)(`stop`,{offset:`0%`,stopColor:`var(--severity-light)`}),(0,F.jsx)(`stop`,{offset:`100%`,stopColor:`var(--severity-color)`})]},e.key))}),(0,F.jsx)(`path`,{className:`dashboard-ring-track`,d:W(Math.PI,0)}),m.map(e=>(0,F.jsxs)(i,{to:U(e.key,n),className:`dashboard-ring-link`,"data-severity":e.key,"aria-label":`${e.label} · ${V(e.count)}`,"data-muted":!!(d&&e.key!==d),...h(e.key),children:[(0,F.jsx)(`title`,{children:`${e.label} · ${V(e.count)} (${e.percent}%)`}),(0,F.jsx)(`path`,{d:e.d,fill:`url(#${o+e.key})`})]},e.key))]}),(0,F.jsxs)(`div`,{className:`dashboard-ring-center`,"data-severity":f?.key,children:[(0,F.jsx)(`strong`,{children:p}),(0,F.jsx)(`span`,{children:f?.label||a(`dashboard.totalVulns`,null,`总漏洞数`)})]})]}),(0,F.jsx)(`div`,{className:`dashboard-severity-legend`,children:e.map(e=>(0,F.jsxs)(i,{className:`dashboard-severity-item`,"data-severity":e.key,"data-active":d===e.key,to:U(e.key,n),...h(e.key),children:[(0,F.jsx)(`span`,{className:`dashboard-severity-dot`,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`dashboard-severity-name`,children:e.label}),(0,F.jsx)(`strong`,{children:r?`…`:V(e.count)}),(0,F.jsx)(`span`,{className:`dashboard-severity-percent`,children:!r&&e.percent!==null?`${e.percent}%`:`—`})]},e.key))})]})}function q({stats:e,latest:t,t:n}){let r=N.map(t=>H(e,t)),a=r.some(e=>e===null)?null:r[0]*10+r[1]*5+r[2]*2+r[3]*.5,[,o,s,c]=a===null?[null,`unknown`,``,``]:L.find(([e])=>a<=e);return(0,F.jsxs)(`aside`,{className:`dashboard-risk-summary`,"aria-label":n(`dashboard.riskLevel`,null,`风险等级`),children:[(0,F.jsxs)(`div`,{className:`dashboard-risk-score`,"data-tone":o,children:[(0,F.jsxs)(`span`,{className:`dashboard-risk-caption`,children:[n(`dashboard.riskLevel`,null,`风险等级`),(0,F.jsx)(u,{size:`small`,className:`dashboard-risk-tag`,children:s?n(`dashboard.risk`+s,null,c):`—`})]}),(0,F.jsx)(_,{percent:Math.min(a??0,100),size:`small`,showInfo:!1,stroke:`var(--risk-accent)`,"aria-label":n(`dashboard.riskScore`,null,`加权风险分`)}),(0,F.jsxs)(`span`,{className:`dashboard-risk-caption`,children:[n(`dashboard.riskScore`,null,`加权风险分`),(0,F.jsx)(`strong`,{children:a===null?`—`:`${C(a)}${a>=100?`+`:``}`})]})]}),(0,F.jsxs)(`div`,{className:`dashboard-risk-pending`,children:[(0,F.jsx)(`span`,{children:n(`dashboard.statusOpen`,null,`待处理`)}),(0,F.jsx)(`div`,{className:`dashboard-risk-pending-links`,children:N.slice(0,2).map((e,t)=>(0,F.jsxs)(i,{to:U(e,`open`),"data-severity":e,children:[(0,F.jsx)(`strong`,{children:V(r[t])}),(0,F.jsx)(`span`,{children:n(`dashboard.severity`+z(e),null,I[t])})]},e))})]}),(0,F.jsxs)(`div`,{className:`dashboard-risk-latest`,children:[(0,F.jsx)(`span`,{children:n(`dashboard.latestFound`,null,`最近发现`)}),(0,F.jsx)(`strong`,{children:t?A(t,n):`—`})]})]})}function J({counts:e,states:t,t:n}){let r=B(e?.fixed??0)??0,a=B(e?.confirmed??0)??0,o=(B(e?.open??0)??0)+a+r,s=o?r/o*100:null;return(0,F.jsxs)(`div`,{className:`dashboard-resolution`,children:[(0,F.jsx)(`div`,{className:`dashboard-resolution-grid`,children:t.map(({value:t,label:n})=>(0,F.jsxs)(i,{to:U(``,t),"data-status":t,className:`dashboard-resolution-item`,children:[(0,F.jsx)(`strong`,{children:V(e?e[t]??0:null)}),(0,F.jsx)(`span`,{children:n})]},t))}),(0,F.jsxs)(`div`,{className:`dashboard-resolution-heading`,children:[(0,F.jsx)(`span`,{children:n(`dashboard.fixRate`,null,`修复率`)}),(0,F.jsxs)(`span`,{children:[(0,F.jsx)(`strong`,{className:`dashboard-risk-value`,children:s===null?`—`:`${s.toFixed(s===100?0:1)}%`}),e&&(0,F.jsxs)(`small`,{children:[`(`,C(r),` / `,C(o),`)`]})]})]}),(0,F.jsxs)(`div`,{className:`dashboard-resolution-track`,"aria-hidden":`true`,children:[(0,F.jsx)(`span`,{style:{width:`${s??0}%`}}),(0,F.jsx)(`span`,{style:{width:`${o?a/o*100:0}%`}})]}),(0,F.jsx)(`div`,{className:`dashboard-resolution-legend`,children:[`fixed`,`confirmed`,`open`].map(e=>(0,F.jsx)(`span`,{"data-status":e,children:t.find(t=>t.value===e).label},e))})]})}function re({stats:e,pendingStats:t,latest:n,loadedAt:r,loading:o}){let s=E(),[l,u]=a(),d=R.map(([e,t,n])=>({value:e,label:s(`dashboard.status`+t,null,n)})),f=l.get(`risk_status`),p=d.some(e=>e.value===f)?f:``,m=!!(p&&p!==`open`),h=O(async()=>{try{return{status:p,stats:await T.get(`/vulnerabilities/stats`,{status:p})}}catch(e){return{status:p,error:e}}},[p,r],{skip:!m}),g=h.data?.status===p,_=p===`open`?t:m?g?h.data.stats:null:e,v=o||m&&(h.loading||!g),y=N.map(e=>H(_,e)),S=y.some(e=>e===null)?null:Math.max(B(_?.total)??0,y.reduce((e,t)=>e+t,0)),C=N.map((e,t)=>({key:e,label:s(`dashboard.severity`+z(e),null,I[t]),count:y[t],percent:S===null?null:S===0?0:Math.round(y[t]/S*100)}));return(0,F.jsxs)(M,{className:`dashboard-vulnerability-card`,bodyClassName:`dashboard-vulnerability-body`,title:s(`dashboard.severityDistribution`,null,`漏洞严重程度分布`),extra:(0,F.jsxs)(`div`,{className:`dashboard-vulnerability-actions`,children:[(0,F.jsx)(b,{"aria-label":s(`dashboard.statusFilter`,null,`状态筛选`),size:`small`,value:p||`all`,optionList:[{value:`all`,label:s(`dashboard.allStatuses`,null,`全部状态`)},...d],onChange:e=>u(t=>{let n=new URLSearchParams(t);return e===`all`?n.delete(`risk_status`):n.set(`risk_status`,e),n},{replace:!0})}),(0,F.jsxs)(i,{className:`dashboard-vulnerability-all`,to:U(``,p),children:[s(`dashboard.viewAll`,null,`查看全部`).replace(/\s*→\s*$/,``),(0,F.jsx)(c,{"aria-hidden":`true`})]})]}),children:[m&&g&&h.data.error&&(0,F.jsx)(x,{type:`warning`,closeIcon:null,description:(0,F.jsxs)(`button`,{type:`button`,className:`dashboard-filter-retry`,onClick:()=>h.reload(),children:[s(`common.loadFailed`,null,`加载失败`),` · `,s(`common.refresh`,null,`刷新`)]})}),(0,F.jsxs)(`div`,{className:`dashboard-vulnerability-grid`,children:[(0,F.jsx)(q,{stats:t,latest:n,t:s}),(0,F.jsx)(K,{rows:C,total:S,status:p,loading:v,t:s},p)]}),(0,F.jsx)(J,{counts:e?.by_status,states:d,t:s})]})}var{Text:Y}=h,ie=new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1});async function X(e,t){try{return await T.get(e,t)}catch(e){return e.status===503&&e.payload?.error===`c2_disabled`?{enabled:!1}:null}}async function ae(){let[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_]=await Promise.all([X(`/agent-loop/tasks`),X(`/vulnerabilities/stats`),X(`/vulnerabilities/stats`,{status:`open`}),X(`/vulnerabilities`,{limit:8,page:1}),X(`/batch-tasks`,{limit:200,page:1}),X(`/monitor/stats`,{top:8}),X(`/usage/tokens`,{days:7,limit:20}),X(`/knowledge/stats`),X(`/skills/stats`),X(`/roles`),X(`/multi-agent/markdown-agents`),X(`/hitl/pending`),X(`/external-mcp/stats`),X(`/webshell/connections`),X(`/c2/listeners`),X(`/c2/sessions`,{limit:200}),X(`/projects/dashboard-summary`,{fact_limit:8}),X(`/config/tools`,{page:1,page_size:1,include_external:!1})]),v={agentTasks:e,vulnStats:t,pendingVulnStats:n,vulnList:r,batchQueues:i,monitorStats:a,tokenUsage:o,knowledgeStats:s,skillsStats:c,roles:l,agents:u,hitlPending:d,externalMcp:f,webshell:p,c2Listeners:m,c2Sessions:h,projectSummary:g,toolsConfig:_};return{...v,unavailableCount:Object.values(v).filter(e=>e==null).length,sourceCount:Object.keys(v).length,loadedAt:new Date().toISOString()}}function Z(e,...t){if(Array.isArray(e))return e;for(let n of t)if(Array.isArray(e?.[n]))return e[n];return null}function Q(e,...t){return Z(e,...t)?.length??null}function $({loading:e,unavailable:t,title:n,description:r}){return(0,F.jsx)(m,{className:`dashboard-empty`,title:e?`正在加载数据`:t?`数据暂不可用`:n,description:e?`正在读取最新记录,请稍候。`:t?`未能取得数据,请稍后刷新重试。`:r})}function oe({data:e,loading:t,onOpen:n}){let r=Z(e,`vulnerabilities`);return(0,F.jsx)(p,{className:`dashboard-list dashboard-feed`,loading:t,dataSource:r||[],emptyContent:(0,F.jsx)($,{loading:t,unavailable:r===null,title:`暂无漏洞记录`,description:`测评发现的漏洞会汇集到这里,便于跟进与复核。`}),renderItem:e=>(0,F.jsx)(p.Item,{main:(0,F.jsxs)(`div`,{className:`dashboard-record`,children:[(0,F.jsx)(l,{theme:`borderless`,className:`dashboard-record-link`,onClick:()=>n(e.id),children:e.title||e.name||`未命名漏洞`}),(0,F.jsxs)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:[e.host||e.target||`—`,` · `,w(e.created_at)]})]}),extra:(0,F.jsx)(k,{severity:e.severity})},e.id)})}function se({summary:e,loading:t,onOpen:n}){let r=Z(e,`recent_facts`,`facts`);return(0,F.jsx)(p,{className:`dashboard-list dashboard-feed dashboard-facts`,split:!1,loading:t,dataSource:r||[],emptyContent:(0,F.jsx)($,{loading:t,unavailable:r===null,title:`暂无近期事实`,description:`项目沉淀的事实与证据将在这里展示。`}),renderItem:(e,t)=>(0,F.jsx)(p.Item,{main:(0,F.jsxs)(`div`,{className:`dashboard-record`,children:[(0,F.jsx)(Y,{strong:!0,className:`dashboard-fact-title`,children:e.title||e.summary||e.key||e.fact_key||e.subject||`事实`}),(0,F.jsx)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:e.project_name||e.projectName||e.value||`—`})]}),extra:(0,F.jsxs)(s,{spacing:8,children:[e.status&&(0,F.jsx)(u,{size:`small`,children:e.status}),e.project_id&&(0,F.jsx)(l,{theme:`borderless`,icon:(0,F.jsx)(c,{}),"aria-label":`查看所属项目`,onClick:()=>n(e.project_id)})]})},e.id||e.key||e.fact_key||t)})}function ce(){let e=E(),t=n(),{data:r,loading:i,error:a,reload:u}=O(ae,[]);ne(()=>u({silent:!0}),6e4);let m=(0,P.useMemo)(()=>{let n=Q(r?.agentTasks,`tasks`),a=B(r?.tokenUsage?.summary?.totalTokens),s=H(r?.vulnStats,`critical`),c=H(r?.pendingVulnStats,`high`),l=r?.monitorStats?.summary,u=B(l?.successCalls),d=B(l?.failedCalls),p=u===null||d===null?null:u+d,m=p>0?u/p:null,h=Z(r?.batchQueues,`queues`)?.filter(e=>String(e.status).toLowerCase()===`running`).length;return[{id:`tasks`,label:e(`dashboard.runningConversations`,null,`运行中任务`),value:V(n),detail:`运行中批量队列 ${V(h)}`,icon:(0,F.jsx)(S,{}),onClick:()=>t(`/tasks`)},{id:`vulnerabilities`,label:e(`dashboard.vulnTotal`,null,`漏洞总数`),value:V(r?.vulnStats?.total),detail:e(`dashboard.openHighCountLabel`,{count:V(c)},`待处理高危 ${V(c)}`),tone:s>0?`danger`:void 0,icon:(0,F.jsx)(v,{}),onClick:()=>t(`/vulnerabilities`)},{id:`calls`,label:e(`dashboard.toolCalls`,null,`工具调用`),value:V(l?.totalCalls),detail:`涉及工具 ${V(l?.toolCount)}`,icon:(0,F.jsx)(f,{}),onClick:()=>t(`/mcp-monitor`)},{id:`rate`,label:e(`dashboard.successRate`,null,`执行成功率`),value:m===null?`—`:ee(m),detail:p===null?`执行结果暂不可用`:p===0?`尚无已完成调用`:`失败 ${V(d)} 次`,tone:m!==null&&m<.8?`warning`:void 0,icon:(0,F.jsx)(o,{}),onClick:()=>t(`/mcp-monitor`)},{id:`tokens`,label:e(`dashboard.tokenUsage`,null,`Token 用量(7 天)`),value:a>=1e6?ie.format(a):V(a),valueTitle:a>=1e6?V(a):void 0,detail:`调用次数 ${V(r?.tokenUsage?.summary?.modelCalls??r?.tokenUsage?.summary?.calls)}`,icon:(0,F.jsx)(g,{}),onClick:()=>t(`/settings?section=token-usage`)}].map(e=>({...e,loading:i,detail:i?`正在刷新数据`:e.detail}))},[r,i,t,e]),h=(0,P.useMemo)(()=>{let e=[],t=H(r?.vulnStats,`critical`);t>0&&e.push({id:`critical`,text:`${V(t)} 条严重漏洞`,page:`/vulnerabilities`});let n=Q(r?.hitlPending,`items`,`pending`);n>0&&e.push({id:`pending`,text:`${V(n)} 项审批待处理`,page:`/hitl`});let i=B(r?.monitorStats?.summary?.failedCalls);i>0&&e.push({id:`failed`,text:`工具调用失败 ${V(i)} 次`,page:`/mcp-monitor`});let a=B(r?.externalMcp?.total),o=B(r?.externalMcp?.connected);return a!==null&&o!==null&&a>o&&e.push({id:`mcp`,text:`${V(a-o)} 个外部 MCP 未连接`,page:`/mcp-management`}),e},[r]),_=(0,P.useMemo)(()=>[{id:`tools`,label:`MCP 工具`,value:r?.toolsConfig?.total,page:`/mcp-management`},{id:`knowledge`,label:`知识条目`,value:r?.knowledgeStats?.total_items,page:`/knowledge-management`},{id:`skills`,label:`技能`,value:r?.skillsStats?.total_skills,page:`/skills-management`},{id:`roles`,label:`角色`,value:Q(r?.roles,`roles`),page:`/roles-management`},{id:`agents`,label:`智能体`,value:Q(r?.agents,`agents`),page:`/agents-management`},{id:`webshell`,label:`WebShell 连接`,value:Q(r?.webshell,`connections`),page:`/webshell`},{id:`listeners`,label:`C2 监听器`,value:Q(r?.c2Listeners,`listeners`),page:`/c2-listeners`},{id:`sessions`,label:`C2 会话`,value:Q(r?.c2Sessions,`sessions`,`items`),page:`/c2-sessions`}].filter(e=>(e.id!==`listeners`||r?.c2Listeners?.enabled!==!1)&&(e.id!==`sessions`||r?.c2Sessions?.enabled!==!1)),[r]),b=r?.loadedAt?w(r.loadedAt):`—`,C=e=>t(`/projects?id=${encodeURIComponent(e)}`);return(0,F.jsxs)(`div`,{className:`dashboard-page`,"aria-busy":i,children:[(0,F.jsx)(te,{title:e(`dashboard.title`,null,`仪表盘`),description:`最近刷新 ${b} · 每 60 秒自动刷新`,extra:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(l,{icon:(0,F.jsx)(y,{}),onClick:()=>u(),loading:i,children:e(`common.refresh`,null,`刷新`)}),(0,F.jsx)(l,{theme:`solid`,icon:(0,F.jsx)(d,{}),onClick:()=>t(`/chat`),children:`进入对话`})]})}),(0,F.jsx)(D,{metrics:m,columns:5}),(0,F.jsx)(j,{error:a,onRetry:()=>u()}),r?.unavailableCount>0&&(0,F.jsx)(x,{className:`dashboard-notice`,type:`info`,fullMode:!1,closeIcon:null,title:r.unavailableCount===r.sourceCount?`数据暂不可用`:`部分数据不可用`,description:r.unavailableCount===r.sourceCount?`本次未能取得仪表盘数据,请检查服务连接后刷新重试。`:`${r.unavailableCount} 项数据源未能加载,相关数值以 — 显示。已返回的数据仍可查看,请稍后刷新重试。`}),h.length>0&&(0,F.jsx)(x,{className:`dashboard-notice`,type:`warning`,fullMode:!1,closeIcon:null,description:(0,F.jsxs)(s,{wrap:!0,spacing:8,children:[(0,F.jsx)(Y,{strong:!0,children:`需要关注`}),h.map(e=>(0,F.jsx)(l,{theme:`borderless`,type:`warning`,icon:(0,F.jsx)(c,{}),iconPosition:`right`,onClick:()=>t(e.page),children:e.text},e.id))]})}),(0,F.jsxs)(`div`,{className:`dashboard-grid`,children:[(0,F.jsxs)(`div`,{className:`dashboard-column`,children:[(0,F.jsx)(re,{stats:r?.vulnStats,pendingStats:r?.pendingVulnStats,latest:r?.vulnList?.vulnerabilities?.[0]?.created_at,loadedAt:r?.loadedAt,loading:i}),(0,F.jsx)(M,{title:e(`dashboard.recentVulns`,null,`最近漏洞`),extra:(0,F.jsx)(l,{theme:`borderless`,size:`small`,icon:(0,F.jsx)(c,{}),iconPosition:`right`,onClick:()=>t(`/vulnerabilities`),children:`查看全部`}),children:(0,F.jsx)(oe,{data:r?.vulnList,loading:i,onOpen:e=>t(`/vulnerabilities?id=${encodeURIComponent(e)}`)})})]}),(0,F.jsxs)(`div`,{className:`dashboard-column`,children:[(0,F.jsx)(M,{title:e(`dashboard.projects`,null,`项目概览`),extra:(0,F.jsx)(l,{theme:`borderless`,size:`small`,icon:(0,F.jsx)(c,{}),iconPosition:`right`,onClick:()=>t(`/projects`),children:`全部项目`}),children:(0,F.jsx)(ue,{summary:r?.projectSummary,loading:i,onOpen:C})}),(0,F.jsx)(M,{title:e(`dashboard.toolsTop`,null,`工具调用 Top`),extra:(0,F.jsx)(l,{theme:`borderless`,size:`small`,onClick:()=>t(`/mcp-monitor`),children:`调用监控`}),children:(0,F.jsx)(le,{data:r?.monitorStats,loading:i})}),(0,F.jsx)(M,{className:`dashboard-capability-card`,bodyClassName:`dashboard-capability-body`,title:e(`dashboard.capability`,null,`能力与运行态`),children:(0,F.jsx)(p,{className:`dashboard-capabilities`,split:!1,dataSource:_,renderItem:e=>(0,F.jsx)(p.Item,{children:(0,F.jsxs)(l,{block:!0,theme:`borderless`,type:`tertiary`,className:`dashboard-capability`,onClick:()=>t(e.page),children:[(0,F.jsx)(`span`,{children:e.label}),(0,F.jsx)(`span`,{className:`dashboard-capability-value`,children:i?`…`:V(e.value)})]})},e.id)})})]})]}),(0,F.jsx)(M,{className:`dashboard-facts-card`,title:e(`dashboard.recentFacts`,null,`近期事实`),children:(0,F.jsx)(se,{summary:r?.projectSummary,loading:i,onOpen:C})})]})}function le({data:e,loading:t}){let n=Z(e,`topTools`),r=n?.slice(0,8).map(e=>({name:e.name||e.toolName||`未命名工具`,count:B(e.count??e.calls??e.totalCalls)}))||[],i=Math.max(...r.map(e=>e.count??0),1);return(0,F.jsx)(p,{className:`dashboard-list`,loading:t,dataSource:r,emptyContent:(0,F.jsx)($,{loading:t,unavailable:n===null,title:`暂无工具调用`,description:`执行任务后,可在这里查看使用最多的工具。`}),renderItem:(e,t)=>(0,F.jsxs)(p.Item,{className:`dashboard-tool-row`,children:[(0,F.jsx)(Y,{type:`tertiary`,size:`small`,className:`dashboard-tool-rank`,children:t+1}),(0,F.jsxs)(`div`,{className:`dashboard-record`,children:[(0,F.jsxs)(`div`,{className:`dashboard-tool-heading`,children:[(0,F.jsx)(Y,{className:`dashboard-tool-name`,title:e.name,children:e.name}),(0,F.jsxs)(Y,{type:`secondary`,size:`small`,className:`dashboard-count`,children:[V(e.count),` 次`]})]}),e.count!==null&&(0,F.jsx)(_,{percent:Math.round(e.count/i*100),showInfo:!1,size:`small`,stroke:`var(--semi-color-primary)`,"aria-label":`${e.name}调用次数`,"aria-valuetext":`${V(e.count)} 次`})]})]},`${e.name}-${t}`)})}function ue({summary:e,loading:t,onOpen:n}){let r=Z(e,`projects`),i=Z(e,`recent_facts`,`facts`),a=e?.totals||e,o=[[`活跃项目`,a?.active_projects??a?.activeProjects],[`事实总数`,a?.total_facts??a?.totalFacts],[`最近事实`,i?.length]];return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dl`,{className:`dashboard-project-totals`,children:o.map(([e,n])=>(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:e}),(0,F.jsx)(`dd`,{children:t?`…`:V(n)})]},e))}),(0,F.jsx)(p,{className:`dashboard-list dashboard-feed`,loading:t,dataSource:r?.slice(0,6)||[],emptyContent:(0,F.jsx)($,{loading:t,unavailable:!e,title:r===null?`在项目中继续工作`:`暂无项目`,description:r===null?`当前摘要提供项目与事实统计,完整列表请查看全部项目。`:`创建项目后,在这里跟进项目进展。`}),renderItem:e=>(0,F.jsx)(p.Item,{main:(0,F.jsxs)(`div`,{className:`dashboard-record`,children:[(0,F.jsx)(l,{theme:`borderless`,className:`dashboard-record-link`,onClick:()=>n(e.id),children:e.name||`未命名项目`}),(0,F.jsxs)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:[e.status||`—`,` · `,w(e.updated_at)]})]})},e.id)})]})}export{ce as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,u as i,y as a}from"./react-QV7DAAIx.js";import{Bt as o,F as s,Jt as c,L as l,M as u,Mt as d,Q as f,S as p,T as m,W as h,Wt as g,h as _,nt as v,st as y,v as b,z as x,zt as S}from"./semi-Dpcldp_F.js";import{D as C,E as w,I as T,O as ee,P as E,_ as D,a as O,h as k,k as A,l as j,m as M,p as te,r as ne,w as N}from"./index-BMTtTYg1.js";var P=e(t(),1),F=e(r(),1),I=[`严重`,`高危`,`中危`,`低危`,`信息`],L=[[0,`safe`,`Safe`,`安全`],[3,`low`,`Low`,`低`],[10,`medium`,`Medium`,`中`],[30,`high`,`High`,`高`],[1/0,`severe`,`Severe`,`极高`]],R=[[`open`,`Open`,`待处理`],[`confirmed`,`Confirmed`,`已确认`],[`fixed`,`Fixed`,`已修复`],[`ignored`,`Ignored`,`已忽略`],[`false_positive`,`FalsePositive`,`误报`]];function z(e){return e[0].toUpperCase()+e.slice(1)}function B(e){if(e==null||e===``||![`number`,`string`].includes(typeof e))return null;let t=Number(e);return Number.isFinite(t)&&t>=0?t:null}function V(e){let t=B(e);return t===null?`—`:C(t)}function H(e,t){let n=e?.by_severity;return!n||typeof n!=`object`||Array.isArray(n)?null:B(n[t]??0)}function U(e,t){let n=new URLSearchParams;e&&n.set(`severity`,e),t&&n.set(`status`,t);let r=n.toString();return`/vulnerabilities`+(r?`?`+r:``)}function W(e,t){let n=(e,t)=>`${(210+e*Math.cos(t)).toFixed(3)} ${(201-e*Math.sin(t)).toFixed(3)}`;return`M ${n(188,e)} A 188 188 0 0 1 ${n(188,t)} L ${n(137,t)} A 137 137 0 0 0 ${n(137,e)} Z`}function G(e,t){if(!t)return[];let n=[],r=Math.PI;for(let i of e){if(!i.count)continue;let e=Math.PI*i.count/t,a=r-e,o=Math.min(.014,e/5);n.push({...i,d:W(r-o,a+o)}),r=a}return n}function K({rows:e,total:t,status:n,loading:r,t:a}){let o=(0,P.useId)(),[s,c]=(0,P.useState)(``),[l,u]=(0,P.useState)(``),d=s||l,f=e.find(e=>e.key===d),p=r?`…`:V(f?f.count:t),m=G(e,t),h=e=>({onPointerEnter:()=>c(e),onPointerLeave:()=>c(``),onFocus:()=>u(e),onBlur:()=>u(``)});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`dashboard-severity-chart`,children:[(0,F.jsxs)(`svg`,{viewBox:`0 0 420 217`,role:`group`,"aria-label":a(`dashboard.severityDistribution`,null,`漏洞严重程度分布`),children:[(0,F.jsx)(`defs`,{children:e.map(e=>(0,F.jsxs)(`linearGradient`,{id:o+e.key,x1:`12%`,y1:`0%`,x2:`84%`,y2:`100%`,"data-severity":e.key,children:[(0,F.jsx)(`stop`,{offset:`0%`,stopColor:`var(--severity-light)`}),(0,F.jsx)(`stop`,{offset:`100%`,stopColor:`var(--severity-color)`})]},e.key))}),(0,F.jsx)(`path`,{className:`dashboard-ring-track`,d:W(Math.PI,0)}),m.map(e=>(0,F.jsxs)(i,{to:U(e.key,n),className:`dashboard-ring-link`,"data-severity":e.key,"aria-label":`${e.label} · ${V(e.count)}`,"data-muted":!!(d&&e.key!==d),...h(e.key),children:[(0,F.jsx)(`title`,{children:`${e.label} · ${V(e.count)} (${e.percent}%)`}),(0,F.jsx)(`path`,{d:e.d,fill:`url(#${o+e.key})`})]},e.key))]}),(0,F.jsxs)(`div`,{className:`dashboard-ring-center`,"data-severity":f?.key,children:[(0,F.jsx)(`strong`,{children:p}),(0,F.jsx)(`span`,{children:f?.label||a(`dashboard.totalVulns`,null,`总漏洞数`)})]})]}),(0,F.jsx)(`div`,{className:`dashboard-severity-legend`,children:e.map(e=>(0,F.jsxs)(i,{className:`dashboard-severity-item`,"data-severity":e.key,"data-active":d===e.key,to:U(e.key,n),...h(e.key),children:[(0,F.jsx)(`span`,{className:`dashboard-severity-dot`,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`dashboard-severity-name`,children:e.label}),(0,F.jsx)(`strong`,{children:r?`…`:V(e.count)}),(0,F.jsx)(`span`,{className:`dashboard-severity-percent`,children:!r&&e.percent!==null?`${e.percent}%`:`—`})]},e.key))})]})}function q({stats:e,latest:t,t:n}){let r=N.map(t=>H(e,t)),a=r.some(e=>e===null)?null:r[0]*10+r[1]*5+r[2]*2+r[3]*.5,[,o,s,c]=a===null?[null,`unknown`,``,``]:L.find(([e])=>a<=e);return(0,F.jsxs)(`aside`,{className:`dashboard-risk-summary`,"aria-label":n(`dashboard.riskLevel`,null,`风险等级`),children:[(0,F.jsxs)(`div`,{className:`dashboard-risk-score`,"data-tone":o,children:[(0,F.jsxs)(`span`,{className:`dashboard-risk-caption`,children:[n(`dashboard.riskLevel`,null,`风险等级`),(0,F.jsx)(u,{size:`small`,className:`dashboard-risk-tag`,children:s?n(`dashboard.risk`+s,null,c):`—`})]}),(0,F.jsx)(_,{percent:Math.min(a??0,100),size:`small`,showInfo:!1,stroke:`var(--risk-accent)`,"aria-label":n(`dashboard.riskScore`,null,`加权风险分`)}),(0,F.jsxs)(`span`,{className:`dashboard-risk-caption`,children:[n(`dashboard.riskScore`,null,`加权风险分`),(0,F.jsx)(`strong`,{children:a===null?`—`:`${C(a)}${a>=100?`+`:``}`})]})]}),(0,F.jsxs)(`div`,{className:`dashboard-risk-pending`,children:[(0,F.jsx)(`span`,{children:n(`dashboard.statusOpen`,null,`待处理`)}),(0,F.jsx)(`div`,{className:`dashboard-risk-pending-links`,children:N.slice(0,2).map((e,t)=>(0,F.jsxs)(i,{to:U(e,`open`),"data-severity":e,children:[(0,F.jsx)(`strong`,{children:V(r[t])}),(0,F.jsx)(`span`,{children:n(`dashboard.severity`+z(e),null,I[t])})]},e))})]}),(0,F.jsxs)(`div`,{className:`dashboard-risk-latest`,children:[(0,F.jsx)(`span`,{children:n(`dashboard.latestFound`,null,`最近发现`)}),(0,F.jsx)(`strong`,{children:t?A(t,n):`—`})]})]})}function J({counts:e,states:t,t:n}){let r=B(e?.fixed??0)??0,a=B(e?.confirmed??0)??0,o=(B(e?.open??0)??0)+a+r,s=o?r/o*100:null;return(0,F.jsxs)(`div`,{className:`dashboard-resolution`,children:[(0,F.jsx)(`div`,{className:`dashboard-resolution-grid`,children:t.map(({value:t,label:n})=>(0,F.jsxs)(i,{to:U(``,t),"data-status":t,className:`dashboard-resolution-item`,children:[(0,F.jsx)(`strong`,{children:V(e?e[t]??0:null)}),(0,F.jsx)(`span`,{children:n})]},t))}),(0,F.jsxs)(`div`,{className:`dashboard-resolution-heading`,children:[(0,F.jsx)(`span`,{children:n(`dashboard.fixRate`,null,`修复率`)}),(0,F.jsxs)(`span`,{children:[(0,F.jsx)(`strong`,{className:`dashboard-risk-value`,children:s===null?`—`:`${s.toFixed(s===100?0:1)}%`}),e&&(0,F.jsxs)(`small`,{children:[`(`,C(r),` / `,C(o),`)`]})]})]}),(0,F.jsxs)(`div`,{className:`dashboard-resolution-track`,"aria-hidden":`true`,children:[(0,F.jsx)(`span`,{style:{width:`${s??0}%`}}),(0,F.jsx)(`span`,{style:{width:`${o?a/o*100:0}%`}})]}),(0,F.jsx)(`div`,{className:`dashboard-resolution-legend`,children:[`fixed`,`confirmed`,`open`].map(e=>(0,F.jsx)(`span`,{"data-status":e,children:t.find(t=>t.value===e).label},e))})]})}function re({stats:e,pendingStats:t,latest:n,loadedAt:r,loading:o}){let s=E(),[l,u]=a(),d=R.map(([e,t,n])=>({value:e,label:s(`dashboard.status`+t,null,n)})),f=l.get(`risk_status`),p=d.some(e=>e.value===f)?f:``,m=!!(p&&p!==`open`),h=O(async()=>{try{return{status:p,stats:await T.get(`/vulnerabilities/stats`,{status:p})}}catch(e){return{status:p,error:e}}},[p,r],{skip:!m}),g=h.data?.status===p,_=p===`open`?t:m?g?h.data.stats:null:e,v=o||m&&(h.loading||!g),y=N.map(e=>H(_,e)),S=y.some(e=>e===null)?null:Math.max(B(_?.total)??0,y.reduce((e,t)=>e+t,0)),C=N.map((e,t)=>({key:e,label:s(`dashboard.severity`+z(e),null,I[t]),count:y[t],percent:S===null?null:S===0?0:Math.round(y[t]/S*100)}));return(0,F.jsxs)(M,{className:`dashboard-vulnerability-card`,bodyClassName:`dashboard-vulnerability-body`,title:s(`dashboard.severityDistribution`,null,`漏洞严重程度分布`),extra:(0,F.jsxs)(`div`,{className:`dashboard-vulnerability-actions`,children:[(0,F.jsx)(b,{"aria-label":s(`dashboard.statusFilter`,null,`状态筛选`),size:`small`,value:p||`all`,optionList:[{value:`all`,label:s(`dashboard.allStatuses`,null,`全部状态`)},...d],onChange:e=>u(t=>{let n=new URLSearchParams(t);return e===`all`?n.delete(`risk_status`):n.set(`risk_status`,e),n},{replace:!0})}),(0,F.jsxs)(i,{className:`dashboard-vulnerability-all`,to:U(``,p),children:[s(`dashboard.viewAll`,null,`查看全部`).replace(/\s*→\s*$/,``),(0,F.jsx)(c,{"aria-hidden":`true`})]})]}),children:[m&&g&&h.data.error&&(0,F.jsx)(x,{type:`warning`,closeIcon:null,description:(0,F.jsxs)(`button`,{type:`button`,className:`dashboard-filter-retry`,onClick:()=>h.reload(),children:[s(`common.loadFailed`,null,`加载失败`),` · `,s(`common.refresh`,null,`刷新`)]})}),(0,F.jsxs)(`div`,{className:`dashboard-vulnerability-grid`,children:[(0,F.jsx)(q,{stats:t,latest:n,t:s}),(0,F.jsx)(K,{rows:C,total:S,status:p,loading:v,t:s},p)]}),(0,F.jsx)(J,{counts:e?.by_status,states:d,t:s})]})}var{Text:Y}=h,ie=new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1});async function X(e,t){try{return await T.get(e,t)}catch(e){return e.status===503&&e.payload?.error===`c2_disabled`?{enabled:!1}:null}}async function ae(){let[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_]=await Promise.all([X(`/agent-loop/tasks`),X(`/vulnerabilities/stats`),X(`/vulnerabilities/stats`,{status:`open`}),X(`/vulnerabilities`,{limit:8,page:1}),X(`/batch-tasks`,{limit:200,page:1}),X(`/monitor/stats`,{top:8}),X(`/usage/tokens`,{days:7,limit:20}),X(`/knowledge/stats`),X(`/skills/stats`),X(`/roles`),X(`/multi-agent/markdown-agents`),X(`/hitl/pending`),X(`/external-mcp/stats`),X(`/webshell/connections`),X(`/c2/listeners`),X(`/c2/sessions`,{limit:200}),X(`/projects/dashboard-summary`,{fact_limit:8}),X(`/config/tools`,{page:1,page_size:1,include_external:!1})]),v={agentTasks:e,vulnStats:t,pendingVulnStats:n,vulnList:r,batchQueues:i,monitorStats:a,tokenUsage:o,knowledgeStats:s,skillsStats:c,roles:l,agents:u,hitlPending:d,externalMcp:f,webshell:p,c2Listeners:m,c2Sessions:h,projectSummary:g,toolsConfig:_};return{...v,unavailableCount:Object.values(v).filter(e=>e==null).length,sourceCount:Object.keys(v).length,loadedAt:new Date().toISOString()}}function Z(e,...t){if(Array.isArray(e))return e;for(let n of t)if(Array.isArray(e?.[n]))return e[n];return null}function Q(e,...t){return Z(e,...t)?.length??null}function $({loading:e,unavailable:t,title:n,description:r}){return(0,F.jsx)(m,{className:`dashboard-empty`,title:e?`正在加载数据`:t?`数据暂不可用`:n,description:e?`正在读取最新记录,请稍候。`:t?`未能取得数据,请稍后刷新重试。`:r})}function oe({data:e,loading:t,onOpen:n}){let r=Z(e,`vulnerabilities`);return(0,F.jsx)(p,{className:`dashboard-list dashboard-feed`,loading:t,dataSource:r||[],emptyContent:(0,F.jsx)($,{loading:t,unavailable:r===null,title:`暂无漏洞记录`,description:`测评发现的漏洞会汇集到这里,便于跟进与复核。`}),renderItem:e=>(0,F.jsx)(p.Item,{main:(0,F.jsxs)(`div`,{className:`dashboard-record`,children:[(0,F.jsx)(l,{theme:`borderless`,className:`dashboard-record-link`,onClick:()=>n(e.id),children:e.title||e.name||`未命名漏洞`}),(0,F.jsxs)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:[e.host||e.target||`—`,` · `,w(e.created_at)]})]}),extra:(0,F.jsx)(k,{severity:e.severity})},e.id)})}function se({summary:e,loading:t,onOpen:n}){let r=Z(e,`recent_facts`,`facts`);return(0,F.jsx)(p,{className:`dashboard-list dashboard-feed dashboard-facts`,split:!1,loading:t,dataSource:r||[],emptyContent:(0,F.jsx)($,{loading:t,unavailable:r===null,title:`暂无近期事实`,description:`项目沉淀的事实与证据将在这里展示。`}),renderItem:(e,t)=>(0,F.jsx)(p.Item,{main:(0,F.jsxs)(`div`,{className:`dashboard-record`,children:[(0,F.jsx)(Y,{strong:!0,className:`dashboard-fact-title`,children:e.title||e.summary||e.key||e.fact_key||e.subject||`事实`}),(0,F.jsx)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:e.project_name||e.projectName||e.value||`—`})]}),extra:(0,F.jsxs)(s,{spacing:8,children:[e.status&&(0,F.jsx)(u,{size:`small`,children:e.status}),e.project_id&&(0,F.jsx)(l,{theme:`borderless`,icon:(0,F.jsx)(c,{}),"aria-label":`查看所属项目`,onClick:()=>n(e.project_id)})]})},e.id||e.key||e.fact_key||t)})}function ce(){let e=E(),t=n(),{data:r,loading:i,error:a,reload:u}=O(ae,[]);ne(()=>u({silent:!0}),6e4);let m=(0,P.useMemo)(()=>{let n=Q(r?.agentTasks,`tasks`),a=B(r?.tokenUsage?.summary?.totalTokens),s=H(r?.vulnStats,`critical`),c=H(r?.pendingVulnStats,`high`),l=r?.monitorStats?.summary,u=B(l?.successCalls),d=B(l?.failedCalls),p=u===null||d===null?null:u+d,m=p>0?u/p:null,h=Z(r?.batchQueues,`queues`)?.filter(e=>String(e.status).toLowerCase()===`running`).length;return[{id:`tasks`,label:e(`dashboard.runningConversations`,null,`运行中任务`),value:V(n),detail:`运行中批量队列 ${V(h)}`,icon:(0,F.jsx)(S,{}),onClick:()=>t(`/tasks`)},{id:`vulnerabilities`,label:e(`dashboard.vulnTotal`,null,`漏洞总数`),value:V(r?.vulnStats?.total),detail:e(`dashboard.openHighCountLabel`,{count:V(c)},`待处理高危 ${V(c)}`),tone:s>0?`danger`:void 0,icon:(0,F.jsx)(v,{}),onClick:()=>t(`/vulnerabilities`)},{id:`calls`,label:e(`dashboard.toolCalls`,null,`工具调用`),value:V(l?.totalCalls),detail:`涉及工具 ${V(l?.toolCount)}`,icon:(0,F.jsx)(f,{}),onClick:()=>t(`/mcp-monitor`)},{id:`rate`,label:e(`dashboard.successRate`,null,`执行成功率`),value:m===null?`—`:ee(m),detail:p===null?`执行结果暂不可用`:p===0?`尚无已完成调用`:`失败 ${V(d)} 次`,tone:m!==null&&m<.8?`warning`:void 0,icon:(0,F.jsx)(o,{}),onClick:()=>t(`/mcp-monitor`)},{id:`tokens`,label:e(`dashboard.tokenUsage`,null,`Token 用量(7 天)`),value:a>=1e6?ie.format(a):V(a),valueTitle:a>=1e6?V(a):void 0,detail:`调用次数 ${V(r?.tokenUsage?.summary?.modelCalls??r?.tokenUsage?.summary?.calls)}`,icon:(0,F.jsx)(g,{}),onClick:()=>t(`/settings?section=token-usage`)}].map(e=>({...e,loading:i,detail:i?`正在刷新数据`:e.detail}))},[r,i,t,e]),h=(0,P.useMemo)(()=>{let e=[],t=H(r?.vulnStats,`critical`);t>0&&e.push({id:`critical`,text:`${V(t)} 条严重漏洞`,page:`/vulnerabilities`});let n=Q(r?.hitlPending,`items`,`pending`);n>0&&e.push({id:`pending`,text:`${V(n)} 项审批待处理`,page:`/hitl`});let i=B(r?.monitorStats?.summary?.failedCalls);i>0&&e.push({id:`failed`,text:`工具调用失败 ${V(i)} 次`,page:`/mcp-monitor`});let a=B(r?.externalMcp?.total),o=B(r?.externalMcp?.connected);return a!==null&&o!==null&&a>o&&e.push({id:`mcp`,text:`${V(a-o)} 个外部 MCP 未连接`,page:`/mcp-management`}),e},[r]),_=(0,P.useMemo)(()=>[{id:`tools`,label:`MCP 工具`,value:r?.toolsConfig?.total,page:`/mcp-management`},{id:`knowledge`,label:`知识条目`,value:r?.knowledgeStats?.total_items,page:`/knowledge-management`},{id:`skills`,label:`技能`,value:r?.skillsStats?.total_skills,page:`/skills-management`},{id:`roles`,label:`角色`,value:Q(r?.roles,`roles`),page:`/roles-management`},{id:`agents`,label:`智能体`,value:Q(r?.agents,`agents`),page:`/agents-management`},{id:`webshell`,label:`WebShell 连接`,value:Q(r?.webshell,`connections`),page:`/webshell`},{id:`listeners`,label:`C2 监听器`,value:Q(r?.c2Listeners,`listeners`),page:`/c2-listeners`},{id:`sessions`,label:`C2 会话`,value:Q(r?.c2Sessions,`sessions`,`items`),page:`/c2-sessions`}].filter(e=>(e.id!==`listeners`||r?.c2Listeners?.enabled!==!1)&&(e.id!==`sessions`||r?.c2Sessions?.enabled!==!1)),[r]),b=r?.loadedAt?w(r.loadedAt):`—`,C=e=>t(`/projects?id=${encodeURIComponent(e)}`);return(0,F.jsxs)(`div`,{className:`dashboard-page`,"aria-busy":i,children:[(0,F.jsx)(te,{title:e(`dashboard.title`,null,`仪表盘`),description:`最近刷新 ${b} · 每 60 秒自动刷新`,extra:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(l,{icon:(0,F.jsx)(y,{}),onClick:()=>u(),loading:i,children:e(`common.refresh`,null,`刷新`)}),(0,F.jsx)(l,{theme:`solid`,icon:(0,F.jsx)(d,{}),onClick:()=>t(`/chat`),children:`进入对话`})]})}),(0,F.jsx)(D,{metrics:m,columns:5}),(0,F.jsx)(j,{error:a,onRetry:()=>u()}),r?.unavailableCount>0&&(0,F.jsx)(x,{className:`dashboard-notice`,type:`info`,fullMode:!1,closeIcon:null,title:r.unavailableCount===r.sourceCount?`数据暂不可用`:`部分数据不可用`,description:r.unavailableCount===r.sourceCount?`本次未能取得仪表盘数据,请检查服务连接后刷新重试。`:`${r.unavailableCount} 项数据源未能加载,相关数值以 — 显示。已返回的数据仍可查看,请稍后刷新重试。`}),h.length>0&&(0,F.jsx)(x,{className:`dashboard-notice`,type:`warning`,fullMode:!1,closeIcon:null,description:(0,F.jsxs)(s,{wrap:!0,spacing:8,children:[(0,F.jsx)(Y,{strong:!0,children:`需要关注`}),h.map(e=>(0,F.jsx)(l,{theme:`borderless`,type:`warning`,icon:(0,F.jsx)(c,{}),iconPosition:`right`,onClick:()=>t(e.page),children:e.text},e.id))]})}),(0,F.jsxs)(`div`,{className:`dashboard-grid`,children:[(0,F.jsxs)(`div`,{className:`dashboard-column`,children:[(0,F.jsx)(re,{stats:r?.vulnStats,pendingStats:r?.pendingVulnStats,latest:r?.vulnList?.vulnerabilities?.[0]?.created_at,loadedAt:r?.loadedAt,loading:i}),(0,F.jsx)(M,{title:e(`dashboard.recentVulns`,null,`最近漏洞`),extra:(0,F.jsx)(l,{theme:`borderless`,size:`small`,icon:(0,F.jsx)(c,{}),iconPosition:`right`,onClick:()=>t(`/vulnerabilities`),children:`查看全部`}),children:(0,F.jsx)(oe,{data:r?.vulnList,loading:i,onOpen:e=>t(`/vulnerabilities?id=${encodeURIComponent(e)}`)})})]}),(0,F.jsxs)(`div`,{className:`dashboard-column`,children:[(0,F.jsx)(M,{title:e(`dashboard.projects`,null,`项目概览`),extra:(0,F.jsx)(l,{theme:`borderless`,size:`small`,icon:(0,F.jsx)(c,{}),iconPosition:`right`,onClick:()=>t(`/projects`),children:`全部项目`}),children:(0,F.jsx)(ue,{summary:r?.projectSummary,loading:i,onOpen:C})}),(0,F.jsx)(M,{title:e(`dashboard.toolsTop`,null,`工具调用 Top`),extra:(0,F.jsx)(l,{theme:`borderless`,size:`small`,onClick:()=>t(`/mcp-monitor`),children:`调用监控`}),children:(0,F.jsx)(le,{data:r?.monitorStats,loading:i})}),(0,F.jsx)(M,{className:`dashboard-capability-card`,bodyClassName:`dashboard-capability-body`,title:e(`dashboard.capability`,null,`能力与运行态`),children:(0,F.jsx)(p,{className:`dashboard-capabilities`,split:!1,dataSource:_,renderItem:e=>(0,F.jsx)(p.Item,{children:(0,F.jsxs)(l,{block:!0,theme:`borderless`,type:`tertiary`,className:`dashboard-capability`,onClick:()=>t(e.page),children:[(0,F.jsx)(`span`,{children:e.label}),(0,F.jsx)(`span`,{className:`dashboard-capability-value`,children:i?`…`:V(e.value)})]})},e.id)})})]})]}),(0,F.jsx)(M,{className:`dashboard-facts-card`,title:e(`dashboard.recentFacts`,null,`近期事实`),children:(0,F.jsx)(se,{summary:r?.projectSummary,loading:i,onOpen:C})})]})}function le({data:e,loading:t}){let n=Z(e,`topTools`),r=n?.slice(0,8).map(e=>({name:e.name||e.toolName||`未命名工具`,count:B(e.count??e.calls??e.totalCalls)}))||[],i=Math.max(...r.map(e=>e.count??0),1);return(0,F.jsx)(p,{className:`dashboard-list`,loading:t,dataSource:r,emptyContent:(0,F.jsx)($,{loading:t,unavailable:n===null,title:`暂无工具调用`,description:`执行任务后,可在这里查看使用最多的工具。`}),renderItem:(e,t)=>(0,F.jsxs)(p.Item,{className:`dashboard-tool-row`,children:[(0,F.jsx)(Y,{type:`tertiary`,size:`small`,className:`dashboard-tool-rank`,children:t+1}),(0,F.jsxs)(`div`,{className:`dashboard-record`,children:[(0,F.jsxs)(`div`,{className:`dashboard-tool-heading`,children:[(0,F.jsx)(Y,{className:`dashboard-tool-name`,title:e.name,children:e.name}),(0,F.jsxs)(Y,{type:`secondary`,size:`small`,className:`dashboard-count`,children:[V(e.count),` 次`]})]}),e.count!==null&&(0,F.jsx)(_,{percent:Math.round(e.count/i*100),showInfo:!1,size:`small`,stroke:`var(--semi-color-primary)`,"aria-label":`${e.name}调用次数`,"aria-valuetext":`${V(e.count)} 次`})]})]},`${e.name}-${t}`)})}function ue({summary:e,loading:t,onOpen:n}){let r=Z(e,`projects`),i=Z(e,`recent_facts`,`facts`),a=e?.totals||e,o=[[`活跃项目`,a?.active_projects??a?.activeProjects],[`事实总数`,a?.total_facts??a?.totalFacts],[`最近事实`,i?.length]];return(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dl`,{className:`dashboard-project-totals`,children:o.map(([e,n])=>(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:e}),(0,F.jsx)(`dd`,{children:t?`…`:V(n)})]},e))}),(0,F.jsx)(p,{className:`dashboard-list dashboard-feed`,loading:t,dataSource:r?.slice(0,6)||[],emptyContent:(0,F.jsx)($,{loading:t,unavailable:!e,title:r===null?`在项目中继续工作`:`暂无项目`,description:r===null?`当前摘要提供项目与事实统计,完整列表请查看全部项目。`:`创建项目后,在这里跟进项目进展。`}),renderItem:e=>(0,F.jsx)(p.Item,{main:(0,F.jsxs)(`div`,{className:`dashboard-record`,children:[(0,F.jsx)(l,{theme:`borderless`,className:`dashboard-record-link`,onClick:()=>n(e.id),children:e.name||`未命名项目`}),(0,F.jsxs)(Y,{type:`tertiary`,size:`small`,className:`dashboard-meta`,children:[e.status||`—`,` · `,w(e.updated_at)]})]})},e.id)})]})}export{ce as default};
\ No newline at end of file
diff --git a/web/static/app/assets/hitl-CJCJcXih.js b/web/static/app/assets/hitl-DiQ6zsxN.js
similarity index 99%
rename from web/static/app/assets/hitl-CJCJcXih.js
rename to web/static/app/assets/hitl-DiQ6zsxN.js
index f1cfa89c..07f39029 100644
--- a/web/static/app/assets/hitl-CJCJcXih.js
+++ b/web/static/app/assets/hitl-DiQ6zsxN.js
@@ -1,4 +1,4 @@
-import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{B as i,F as a,H as o,L as s,M as c,T as l,U as u,W as d,_ as f,c as p,f as m,m as h,ot as g,p as _,st as v,v as y,x as b,z as x}from"./semi-Dpcldp_F.js";import{E as S,F as C,I as w,P as T,S as E,a as D,b as O,d as k,l as A,m as j,n as ee,o as M,p as N,s as P,u as F,x as I,y as L}from"./index-gBcdNgHq.js";var R=e(t(),1),z=[{value:`off`,label:`关闭`,hint:`不拦截工具调用`},{value:`approval`,label:`审批模式`,hint:`只裁决通过/拒绝`},{value:`review_edit`,label:`审查编辑模式`,hint:`可收窄参数后放行`}],te={approve:`通过`,reject:`拒绝`},B={approve:`green`,reject:`red`},V={human:`人工`,audit_agent:`审计 Agent`,system:`系统`,manual:`手动录入`};function H(e){let t=String(e||``).trim().toLowerCase().replace(/-/g,`_`);return t===`feedback`||t===`followup`?`approval`:[`off`,`approval`,`review_edit`].includes(t)?t:`off`}function U(e){let t=H(e),n=z.find(e=>e.value===t);return n?n.label:t}function W(e){let t=String(e||``).trim().toLowerCase();return t===`audit_agent`||t===`agent`||t===`ai`?`audit_agent`:`human`}function G(e){return W(e)===`audit_agent`?`审计 Agent`:`人工审批`}function K(e){let t=String(e||``).trim().toLowerCase();return te[t]||t||`—`}function q(e){return B[String(e||``).toLowerCase()]||`grey`}function ne(e){return V[String(e||``).trim().toLowerCase()]||e||`—`}function re(e){let t=String(e||``).trim().toLowerCase();return t===`pending`?`待审批`:t===`decided`?`已裁决`:t===`timeout`?`超时自动拒绝`:t===`cancelled`?`已取消`:e||`—`}function J(e){if(!e)return{};if(typeof e==`object`)return e;try{let t=JSON.parse(String(e));return t&&typeof t==`object`?t:{}}catch{return{}}}function ie(e){if(!e||typeof e!=`object`)return null;if(e.argumentsObj&&typeof e.argumentsObj==`object`)return e.argumentsObj;if(typeof e.arguments==`string`&&e.arguments.trim())try{let t=JSON.parse(e.arguments);if(t&&typeof t==`object`)return t}catch{return{raw:e.arguments}}return e.arguments&&typeof e.arguments==`object`?e.arguments:null}function ae(e){return!e||typeof e!=`object`?[]:[{key:`userMessage`,label:`用户消息`,value:e.userMessage},{key:`thinking`,label:`思考`,value:e.thinking},{key:`reasoningChain`,label:`推理链`,value:e.reasoningChain},{key:`planning`,label:`计划`,value:e.planning}].filter(e=>String(e.value||``).trim())}function oe(e){let t=e?.executionResult;if(!t||typeof t!=`object`)return null;let n=String(t.result||``).trim();return n?{success:t.success===!0,text:n}:null}function se(e){let t=e?.hitlApproval;if(!t||typeof t!=`object`)return``;let n=Number(t.timeoutSeconds)||0;if(n<=0)return`无超时限制`;let r=t.expiresAt?new Date(t.expiresAt):null;return r&&Number.isFinite(r.getTime())?r.getTime()<=Date.now()?`已于 ${S(r)} 到期`:`${S(r)} 截止`:`${n} 秒内需裁决`}function Y(e){return e?S(e):`—`}function ce(e){return String(e||``).split(/[\n,,;;]/).map(e=>e.trim()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t)}function X(e){let t=[];return e?.userMessage&&t.push(`用户消息`),e?.thinking&&t.push(`思考`),e?.executionResult&&t.push(`执行结果`),t.length?t.join(` · `):`—`}var Z=e(n(),1);function Q({payload:e}){let t=ae(e),n=oe(e);return!t.length&&!n?null:(0,Z.jsxs)(`div`,{className:`hitl-context-blocks`,children:[t.map(e=>(0,Z.jsxs)(`div`,{className:`hitl-context-block`,children:[(0,Z.jsx)(`span`,{className:`hitl-context-label`,children:e.label}),(0,Z.jsx)(`pre`,{className:`hitl-context-text`,children:String(e.value)})]},e.key)),n&&(0,Z.jsxs)(`div`,{className:`hitl-context-block ${n.success?`hitl-state-success`:`hitl-state-failed`}`,children:[(0,Z.jsx)(`span`,{className:`hitl-context-label`,children:`执行结果(${n.success?`成功`:`失败`})`}),(0,Z.jsx)(`pre`,{className:`hitl-context-text`,children:n.text})]})]})}var{Text:le}=d;function ue({item:e,canWrite:t,onDone:n}){let r=(0,R.useMemo)(()=>J(e.payload),[e.payload]),i=(0,R.useMemo)(()=>ie(r),[r]),l=H(e.mode)===`review_edit`,u=W(e.reviewer),[d,f]=(0,R.useState)(``),[p,m]=(0,R.useState)(()=>l&&i?JSON.stringify(i,null,2):``),[h,g]=(0,R.useState)(``),[_,v]=(0,R.useState)(``),y=(0,R.useCallback)(async t=>{if(h)return;let r;if(l&&p.trim()){try{r=JSON.parse(p)}catch(e){v(`修改后的参数不是合法 JSON:${e.message}`);return}if(!r||typeof r!=`object`||Array.isArray(r)){v(`修改后的参数必须是 JSON 对象`);return}}v(``),g(t);try{await w.post(`/hitl/decision`,{interruptId:e.id,decision:t,comment:d.trim(),editedArguments:r}),I(t===`approve`?`已通过,工具将继续执行`:`已拒绝本次工具调用`),n?.()}catch(t){if(t?.status===409){await w.post(`/hitl/dismiss`,{interruptId:e.id}).catch(()=>null),E(`该审批已被处理,列表已刷新`),n?.();return}O(t,`提交审批失败`)}finally{g(``)}},[l,p,h,d,e.id,n]),x=(0,R.useCallback)(()=>{L({title:`忽略该审批`,content:`忽略后该审批记为取消(reject),本次工具调用不会继续执行,记录可在审批日志中查看。`,okText:`忽略`,onOk:async()=>{try{await w.post(`/hitl/dismiss`,{interruptId:e.id}),I(`已忽略该审批`),n?.()}catch(e){O(e,`忽略审批失败`)}}})},[e.id,n]);return(0,Z.jsxs)(`div`,{className:`hitl-pending-card`,children:[(0,Z.jsxs)(`div`,{className:`hitl-pending-head`,children:[(0,Z.jsxs)(a,{spacing:6,wrap:!0,children:[(0,Z.jsx)(c,{size:`small`,color:`blue`,shape:`square`,children:e.toolName||`—`}),(0,Z.jsx)(c,{size:`small`,color:l?`violet`:`grey`,children:U(e.mode)}),(0,Z.jsx)(c,{size:`small`,color:u===`audit_agent`?`green`:`grey`,children:G(e.reviewer)})]}),(0,Z.jsxs)(a,{spacing:6,children:[(0,Z.jsx)(le,{type:`tertiary`,size:`small`,children:Y(e.createdAt)}),(0,Z.jsx)(s,{size:`small`,theme:`borderless`,disabled:!t||!!h,onClick:x,children:`忽略`})]})]}),(0,Z.jsxs)(`div`,{className:`hitl-pending-meta`,children:[(0,Z.jsx)(`span`,{className:`hitl-pending-meta-label`,children:`会话`}),(0,Z.jsx)(`span`,{className:`hitl-mono`,children:e.conversationId||`—`}),e.conversationId&&(0,Z.jsx)(M,{text:e.conversationId,size:`small`}),(0,Z.jsx)(`span`,{className:`hitl-pending-deadline`,children:se(r)})]}),(0,Z.jsx)(Q,{payload:r}),i&&(0,Z.jsx)(F,{title:`请求参数`,value:i,collapsed:!0}),(0,Z.jsxs)(`div`,{className:`hitl-pending-editor`,children:[(0,Z.jsx)(`span`,{className:`hitl-context-label`,children:l?`修改后的参数(可编辑,留空表示沿用原参数)`:`审批模式:仅可通过/拒绝,参数编辑已禁用`}),(0,Z.jsx)(b,{rows:l?6:3,value:l?p:i?JSON.stringify(i,null,2):``,disabled:!l,spellCheck:!1,className:`hitl-args-textarea`,onChange:e=>{m(e),_&&v(``)}})]}),_&&(0,Z.jsx)(`div`,{className:`hitl-inline-error`,children:_}),(0,Z.jsx)(o,{value:d,placeholder:`审批备注(可选),例如:只读命令,允许执行`,onChange:e=>f(e)}),(0,Z.jsxs)(`div`,{className:`hitl-pending-actions`,children:[(0,Z.jsx)(s,{type:`danger`,theme:`light`,disabled:!t||!!h,loading:h===`reject`,onClick:()=>y(`reject`),children:`拒绝`}),(0,Z.jsx)(s,{theme:`solid`,disabled:!t||!!h,loading:h===`approve`,onClick:()=>y(`approve`),children:l&&p.trim()&&p.trim()!==(i?JSON.stringify(i,null,2):``)?`保存修改并放行`:`通过`})]}),(0,Z.jsx)(F,{title:`完整载荷`,value:r,collapsed:!0})]})}function de({canWrite:e,onCountChange:t,refreshKey:n=0}){let r=T(),[i,a]=(0,R.useState)(1),[s,c]=(0,R.useState)(20),[d,p]=(0,R.useState)(``),m=ee(d,350),h=D(()=>w.get(`/hitl/pending`,{page:i,pageSize:s,q:m}),[i,s,m,n]),g=h.data?.items||[],_=Number(h.data?.total)||0;(0,R.useEffect)(()=>{t?.(_)},[t,_]);let v=(0,R.useCallback)(e=>{c(e),a(1)},[]);return(0,Z.jsxs)(`div`,{className:`hitl-pending-panel`,children:[(0,Z.jsxs)(`div`,{className:`hitl-panel-toolbar`,children:[(0,Z.jsx)(o,{showClear:!0,value:d,style:{width:300},placeholder:r(`hitl.searchPlaceholder`,null,`搜索工具、会话或载荷…`),onChange:e=>{p(e),a(1)}}),(0,Z.jsxs)(le,{type:`tertiary`,size:`small`,children:[r(`hitl.pendingTitle`,null,`待审批请求`),` · `,_]})]}),(0,Z.jsx)(A,{error:h.error,onRetry:()=>h.reload()}),h.loading&&!g.length&&(0,Z.jsx)(`div`,{className:`hitl-panel-loading`,children:(0,Z.jsx)(u,{})}),!h.loading&&!g.length&&!h.error&&(0,Z.jsx)(l,{title:r(`hitl.emptyState`,null,`暂无待审批请求`),description:`工具调用命中敏感规则时会在此等待裁决。`,style:{padding:48}}),(0,Z.jsx)(`div`,{className:`hitl-pending-list`,children:g.map(t=>(0,Z.jsx)(ue,{item:t,canWrite:e,onDone:()=>{g.length<=1&&i>1?a(i-1):h.reload()}},t.id))}),_>0&&(0,Z.jsx)(`div`,{className:`hitl-panel-pagination`,children:(0,Z.jsx)(f,{currentPage:i,pageSize:s,total:_,showSizeChanger:!0,pageSizeOpts:[10,20,50],showTotal:!0,onPageChange:e=>a(e),onPageSizeChange:v})})]})}var{Text:fe}=d;function pe({logId:e,onClose:t}){let n=T(),{data:r,loading:i,error:o,reload:l}=D(()=>w.get(`/hitl/logs/${encodeURIComponent(e)}`),[e],{skip:!e}),d=(0,R.useMemo)(()=>J(r?.payload),[r?.payload]),f=[r?.auditBackend,r?.auditModel].filter(Boolean).join(` · `);return(0,Z.jsxs)(m,{visible:!!e,onCancel:t,width:720,title:n(`hitl.logModalView`,null,`审批日志详情`),footer:(0,Z.jsx)(s,{onClick:t,children:n(`common.close`,null,`关闭`)}),children:[(0,Z.jsx)(A,{error:o,onRetry:l}),i&&!r&&(0,Z.jsx)(`div`,{className:`hitl-panel-loading`,children:(0,Z.jsx)(u,{})}),r&&(0,Z.jsxs)(`div`,{className:`hitl-log-detail`,children:[(0,Z.jsx)(k,{columns:2,items:[{label:n(`hitl.colTool`,null,`工具`),value:(0,Z.jsx)(fe,{strong:!0,children:r.toolName||`—`})},{label:n(`hitl.colDecision`,null,`决策`),value:(0,Z.jsx)(c,{size:`small`,color:q(r.decision),children:K(r.decision)})},{label:`状态`,value:re(r.status)},{label:n(`hitl.colDecidedBy`,null,`审批方`),value:ne(r.decidedBy)},{label:`审批方类型`,value:G(r.reviewer)},{label:`审批引擎`,value:f||`—`},{label:n(`hitl.colConversation`,null,`会话`),value:r.conversationId?(0,Z.jsxs)(a,{spacing:4,children:[(0,Z.jsx)(`span`,{className:`hitl-mono`,children:r.conversationId}),(0,Z.jsx)(M,{text:r.conversationId,size:`small`})]}):`—`},{label:`模式`,value:r.mode||`—`},{label:`创建时间`,value:Y(r.createdAt)},{label:`裁决时间`,value:Y(r.decidedAt)},{label:`ID`,value:(0,Z.jsx)(`span`,{className:`hitl-mono`,children:r.id})},{label:n(`hitl.fieldComment`,null,`备注`),value:r.comment||`—`}]}),(0,Z.jsx)(Q,{payload:d}),(0,Z.jsx)(F,{title:n(`hitl.fieldPayload`,null,`载荷`),value:d,collapsed:!0})]})]})}function me({canWrite:e,detailId:t,onOpenDetail:n,onCloseDetail:r,refreshKey:i=0}){let l=T(),[u,d]=(0,R.useState)(1),[f,p]=(0,R.useState)(20),[m,h]=(0,R.useState)(``),g=ee(m,350),[_,b]=(0,R.useState)(`all`),[x,S]=(0,R.useState)(`all`),[C,E]=(0,R.useState)([]),k=(0,R.useMemo)(()=>({q:g,decision:_===`all`?``:_,decidedBy:x===`all`?``:x}),[g,_,x]),j=D(()=>w.get(`/hitl/logs`,{page:u,pageSize:f,...k}),[u,f,k,i]),M=j.data?.items||[],N=Number(j.data?.total)||0,F=Number(j.data?.retentionDays)||0,z=(0,R.useCallback)(()=>j.reload(),[j.reload]),te=(0,R.useCallback)(()=>{C.length&&L({title:`批量删除审批日志`,content:`确定删除选中的 ${C.length} 条审批日志?此操作不可恢复。`,okText:l(`common.delete`,null,`删除`),onOk:async()=>{try{await w.del(`/hitl/logs`,{body:{ids:C}}),I(`已删除 ${C.length} 条审批日志`),E([]),z()}catch(e){O(e,`批量删除审批日志失败`)}}})},[z,C,l]),B=(0,R.useCallback)(()=>{L({title:l(`hitl.clearAll`,null,`清空审计日志`),content:g||_!==`all`||x!==`all`?`将清空当前筛选条件下的全部已裁决日志(不会删除待审批项)。`:`将清空全部已裁决审批日志(不会删除待审批项)。`,okText:l(`hitl.clearAll`,null,`清空`),onOk:async()=>{try{await w.del(`/hitl/logs`,{query:k,body:{all:!0}}),I(`审批日志已清空`),E([]),d(1),z()}catch(e){O(e,`清空审批日志失败`)}}})},[x,_,g,k,z,l]),V=[{title:l(`hitl.colTool`,null,`工具`),dataIndex:`toolName`,render:e=>(0,Z.jsx)(`span`,{className:`hitl-mono`,children:e||`—`})},{title:l(`hitl.colConversation`,null,`会话`),dataIndex:`conversationId`,width:200,render:e=>(0,Z.jsx)(`span`,{className:`hitl-mono hitl-ellipsis`,title:e||``,children:e||`—`})},{title:l(`hitl.colDecision`,null,`决策`),dataIndex:`decision`,width:100,render:e=>(0,Z.jsx)(c,{size:`small`,color:q(e),children:K(e)})},{title:l(`hitl.colDecidedBy`,null,`审批方`),dataIndex:`decidedBy`,width:140,render:(e,t)=>(0,Z.jsxs)(`div`,{className:`hitl-log-by`,children:[(0,Z.jsx)(`span`,{children:ne(e)}),t.auditBackend&&(0,Z.jsx)(`span`,{className:`hitl-log-engine`,children:[t.auditBackend,t.auditModel].filter(Boolean).join(` · `)})]})},{title:`备注`,dataIndex:`comment`,render:(e,t)=>(0,Z.jsx)(`span`,{title:e||``,children:e||X(J(t.payload))})},{title:l(`hitl.colTime`,null,`时间`),dataIndex:`decidedAt`,width:180,render:(e,t)=>Y(e||t.createdAt)},{title:l(`common.actions`,null,`操作`),dataIndex:`id`,width:90,render:e=>(0,Z.jsx)(s,{size:`small`,theme:`borderless`,onClick:()=>n(e),children:l(`common.view`,null,`详情`)})}],H={currentPage:u,pageSize:f,total:N,showSizeChanger:!0,pageSizeOpts:[20,50,100],showTotal:!0,onPageChange:e=>d(e),onPageSizeChange:e=>{p(e),d(1)}};return(0,Z.jsxs)(`div`,{className:`hitl-logs-panel`,children:[F>0&&(0,Z.jsx)(`p`,{className:`hitl-retention-hint`,children:l(`hitl.retentionHint`,{days:F},`审批日志保留 ${F} 天,到期自动清理。`)}),(0,Z.jsx)(A,{error:j.error,onRetry:z}),(0,Z.jsx)(P,{columns:V,dataSource:M,rowKey:`id`,loading:j.loading,pagination:H,size:`small`,emptyText:l(`hitl.logsEmpty`,null,`暂无审批日志`),rowSelection:{selectedRowKeys:C,onChange:e=>E(e||[])},toolbar:(0,Z.jsxs)(a,{spacing:8,wrap:!0,children:[(0,Z.jsx)(o,{showClear:!0,style:{width:220},value:m,placeholder:l(`hitl.searchPlaceholder`,null,`搜索工具、会话或载荷…`),onChange:e=>{h(e),d(1)}}),(0,Z.jsx)(y,{value:_,style:{width:120},optionList:[{value:`all`,label:l(`hitl.filterAll`,null,`全部`)},{value:`approve`,label:l(`hitl.decisionApprove`,null,`通过`)},{value:`reject`,label:l(`hitl.decisionReject`,null,`拒绝`)}],onChange:e=>{b(e),d(1)}}),(0,Z.jsx)(y,{value:x,style:{width:150},optionList:[{value:`all`,label:l(`hitl.filterAll`,null,`全部`)},{value:`human`,label:l(`hitl.reviewerHuman`,null,`人工`)},{value:`audit_agent`,label:l(`hitl.reviewerAgent`,null,`审计 Agent`)},{value:`system`,label:l(`hitl.reviewerSystem`,null,`系统`)},{value:`manual`,label:l(`hitl.reviewerManual`,null,`手动录入`)}],onChange:e=>{S(e),d(1)}}),(0,Z.jsx)(s,{icon:(0,Z.jsx)(v,{}),theme:`borderless`,size:`small`,onClick:z,loading:j.loading,children:l(`common.refresh`,null,`刷新`)}),(0,Z.jsxs)(s,{size:`small`,type:`danger`,theme:`borderless`,disabled:!e||!C.length,onClick:te,children:[`批量删除`,C.length?`(${C.length})`:``]}),(0,Z.jsx)(s,{size:`small`,type:`danger`,theme:`borderless`,disabled:!e||!N,onClick:B,children:l(`hitl.clearAll`,null,`清空`)})]})}),(0,Z.jsx)(pe,{logId:t,onClose:r})]})}var{Text:he}=d;function ge({canWrite:e,refreshKey:t=0}){let n=T(),{data:r,loading:i,error:o,reload:l}=D(()=>w.get(`/hitl/tool-whitelist`),[t]),[u,d]=(0,R.useState)(``),[f,p]=(0,R.useState)(``);(0,R.useEffect)(()=>{r&&d((r.toolWhitelist||[]).join(`
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{B as i,F as a,H as o,L as s,M as c,T as l,U as u,W as d,_ as f,c as p,f as m,m as h,ot as g,p as _,st as v,v as y,x as b,z as x}from"./semi-Dpcldp_F.js";import{E as S,F as C,I as w,P as T,S as E,a as D,b as O,d as k,l as A,m as j,n as ee,o as M,p as N,s as P,u as F,x as I,y as L}from"./index-BMTtTYg1.js";var R=e(t(),1),z=[{value:`off`,label:`关闭`,hint:`不拦截工具调用`},{value:`approval`,label:`审批模式`,hint:`只裁决通过/拒绝`},{value:`review_edit`,label:`审查编辑模式`,hint:`可收窄参数后放行`}],te={approve:`通过`,reject:`拒绝`},B={approve:`green`,reject:`red`},V={human:`人工`,audit_agent:`审计 Agent`,system:`系统`,manual:`手动录入`};function H(e){let t=String(e||``).trim().toLowerCase().replace(/-/g,`_`);return t===`feedback`||t===`followup`?`approval`:[`off`,`approval`,`review_edit`].includes(t)?t:`off`}function U(e){let t=H(e),n=z.find(e=>e.value===t);return n?n.label:t}function W(e){let t=String(e||``).trim().toLowerCase();return t===`audit_agent`||t===`agent`||t===`ai`?`audit_agent`:`human`}function G(e){return W(e)===`audit_agent`?`审计 Agent`:`人工审批`}function K(e){let t=String(e||``).trim().toLowerCase();return te[t]||t||`—`}function q(e){return B[String(e||``).toLowerCase()]||`grey`}function ne(e){return V[String(e||``).trim().toLowerCase()]||e||`—`}function re(e){let t=String(e||``).trim().toLowerCase();return t===`pending`?`待审批`:t===`decided`?`已裁决`:t===`timeout`?`超时自动拒绝`:t===`cancelled`?`已取消`:e||`—`}function J(e){if(!e)return{};if(typeof e==`object`)return e;try{let t=JSON.parse(String(e));return t&&typeof t==`object`?t:{}}catch{return{}}}function ie(e){if(!e||typeof e!=`object`)return null;if(e.argumentsObj&&typeof e.argumentsObj==`object`)return e.argumentsObj;if(typeof e.arguments==`string`&&e.arguments.trim())try{let t=JSON.parse(e.arguments);if(t&&typeof t==`object`)return t}catch{return{raw:e.arguments}}return e.arguments&&typeof e.arguments==`object`?e.arguments:null}function ae(e){return!e||typeof e!=`object`?[]:[{key:`userMessage`,label:`用户消息`,value:e.userMessage},{key:`thinking`,label:`思考`,value:e.thinking},{key:`reasoningChain`,label:`推理链`,value:e.reasoningChain},{key:`planning`,label:`计划`,value:e.planning}].filter(e=>String(e.value||``).trim())}function oe(e){let t=e?.executionResult;if(!t||typeof t!=`object`)return null;let n=String(t.result||``).trim();return n?{success:t.success===!0,text:n}:null}function se(e){let t=e?.hitlApproval;if(!t||typeof t!=`object`)return``;let n=Number(t.timeoutSeconds)||0;if(n<=0)return`无超时限制`;let r=t.expiresAt?new Date(t.expiresAt):null;return r&&Number.isFinite(r.getTime())?r.getTime()<=Date.now()?`已于 ${S(r)} 到期`:`${S(r)} 截止`:`${n} 秒内需裁决`}function Y(e){return e?S(e):`—`}function ce(e){return String(e||``).split(/[\n,,;;]/).map(e=>e.trim()).filter(Boolean).filter((e,t,n)=>n.indexOf(e)===t)}function X(e){let t=[];return e?.userMessage&&t.push(`用户消息`),e?.thinking&&t.push(`思考`),e?.executionResult&&t.push(`执行结果`),t.length?t.join(` · `):`—`}var Z=e(n(),1);function Q({payload:e}){let t=ae(e),n=oe(e);return!t.length&&!n?null:(0,Z.jsxs)(`div`,{className:`hitl-context-blocks`,children:[t.map(e=>(0,Z.jsxs)(`div`,{className:`hitl-context-block`,children:[(0,Z.jsx)(`span`,{className:`hitl-context-label`,children:e.label}),(0,Z.jsx)(`pre`,{className:`hitl-context-text`,children:String(e.value)})]},e.key)),n&&(0,Z.jsxs)(`div`,{className:`hitl-context-block ${n.success?`hitl-state-success`:`hitl-state-failed`}`,children:[(0,Z.jsx)(`span`,{className:`hitl-context-label`,children:`执行结果(${n.success?`成功`:`失败`})`}),(0,Z.jsx)(`pre`,{className:`hitl-context-text`,children:n.text})]})]})}var{Text:le}=d;function ue({item:e,canWrite:t,onDone:n}){let r=(0,R.useMemo)(()=>J(e.payload),[e.payload]),i=(0,R.useMemo)(()=>ie(r),[r]),l=H(e.mode)===`review_edit`,u=W(e.reviewer),[d,f]=(0,R.useState)(``),[p,m]=(0,R.useState)(()=>l&&i?JSON.stringify(i,null,2):``),[h,g]=(0,R.useState)(``),[_,v]=(0,R.useState)(``),y=(0,R.useCallback)(async t=>{if(h)return;let r;if(l&&p.trim()){try{r=JSON.parse(p)}catch(e){v(`修改后的参数不是合法 JSON:${e.message}`);return}if(!r||typeof r!=`object`||Array.isArray(r)){v(`修改后的参数必须是 JSON 对象`);return}}v(``),g(t);try{await w.post(`/hitl/decision`,{interruptId:e.id,decision:t,comment:d.trim(),editedArguments:r}),I(t===`approve`?`已通过,工具将继续执行`:`已拒绝本次工具调用`),n?.()}catch(t){if(t?.status===409){await w.post(`/hitl/dismiss`,{interruptId:e.id}).catch(()=>null),E(`该审批已被处理,列表已刷新`),n?.();return}O(t,`提交审批失败`)}finally{g(``)}},[l,p,h,d,e.id,n]),x=(0,R.useCallback)(()=>{L({title:`忽略该审批`,content:`忽略后该审批记为取消(reject),本次工具调用不会继续执行,记录可在审批日志中查看。`,okText:`忽略`,onOk:async()=>{try{await w.post(`/hitl/dismiss`,{interruptId:e.id}),I(`已忽略该审批`),n?.()}catch(e){O(e,`忽略审批失败`)}}})},[e.id,n]);return(0,Z.jsxs)(`div`,{className:`hitl-pending-card`,children:[(0,Z.jsxs)(`div`,{className:`hitl-pending-head`,children:[(0,Z.jsxs)(a,{spacing:6,wrap:!0,children:[(0,Z.jsx)(c,{size:`small`,color:`blue`,shape:`square`,children:e.toolName||`—`}),(0,Z.jsx)(c,{size:`small`,color:l?`violet`:`grey`,children:U(e.mode)}),(0,Z.jsx)(c,{size:`small`,color:u===`audit_agent`?`green`:`grey`,children:G(e.reviewer)})]}),(0,Z.jsxs)(a,{spacing:6,children:[(0,Z.jsx)(le,{type:`tertiary`,size:`small`,children:Y(e.createdAt)}),(0,Z.jsx)(s,{size:`small`,theme:`borderless`,disabled:!t||!!h,onClick:x,children:`忽略`})]})]}),(0,Z.jsxs)(`div`,{className:`hitl-pending-meta`,children:[(0,Z.jsx)(`span`,{className:`hitl-pending-meta-label`,children:`会话`}),(0,Z.jsx)(`span`,{className:`hitl-mono`,children:e.conversationId||`—`}),e.conversationId&&(0,Z.jsx)(M,{text:e.conversationId,size:`small`}),(0,Z.jsx)(`span`,{className:`hitl-pending-deadline`,children:se(r)})]}),(0,Z.jsx)(Q,{payload:r}),i&&(0,Z.jsx)(F,{title:`请求参数`,value:i,collapsed:!0}),(0,Z.jsxs)(`div`,{className:`hitl-pending-editor`,children:[(0,Z.jsx)(`span`,{className:`hitl-context-label`,children:l?`修改后的参数(可编辑,留空表示沿用原参数)`:`审批模式:仅可通过/拒绝,参数编辑已禁用`}),(0,Z.jsx)(b,{rows:l?6:3,value:l?p:i?JSON.stringify(i,null,2):``,disabled:!l,spellCheck:!1,className:`hitl-args-textarea`,onChange:e=>{m(e),_&&v(``)}})]}),_&&(0,Z.jsx)(`div`,{className:`hitl-inline-error`,children:_}),(0,Z.jsx)(o,{value:d,placeholder:`审批备注(可选),例如:只读命令,允许执行`,onChange:e=>f(e)}),(0,Z.jsxs)(`div`,{className:`hitl-pending-actions`,children:[(0,Z.jsx)(s,{type:`danger`,theme:`light`,disabled:!t||!!h,loading:h===`reject`,onClick:()=>y(`reject`),children:`拒绝`}),(0,Z.jsx)(s,{theme:`solid`,disabled:!t||!!h,loading:h===`approve`,onClick:()=>y(`approve`),children:l&&p.trim()&&p.trim()!==(i?JSON.stringify(i,null,2):``)?`保存修改并放行`:`通过`})]}),(0,Z.jsx)(F,{title:`完整载荷`,value:r,collapsed:!0})]})}function de({canWrite:e,onCountChange:t,refreshKey:n=0}){let r=T(),[i,a]=(0,R.useState)(1),[s,c]=(0,R.useState)(20),[d,p]=(0,R.useState)(``),m=ee(d,350),h=D(()=>w.get(`/hitl/pending`,{page:i,pageSize:s,q:m}),[i,s,m,n]),g=h.data?.items||[],_=Number(h.data?.total)||0;(0,R.useEffect)(()=>{t?.(_)},[t,_]);let v=(0,R.useCallback)(e=>{c(e),a(1)},[]);return(0,Z.jsxs)(`div`,{className:`hitl-pending-panel`,children:[(0,Z.jsxs)(`div`,{className:`hitl-panel-toolbar`,children:[(0,Z.jsx)(o,{showClear:!0,value:d,style:{width:300},placeholder:r(`hitl.searchPlaceholder`,null,`搜索工具、会话或载荷…`),onChange:e=>{p(e),a(1)}}),(0,Z.jsxs)(le,{type:`tertiary`,size:`small`,children:[r(`hitl.pendingTitle`,null,`待审批请求`),` · `,_]})]}),(0,Z.jsx)(A,{error:h.error,onRetry:()=>h.reload()}),h.loading&&!g.length&&(0,Z.jsx)(`div`,{className:`hitl-panel-loading`,children:(0,Z.jsx)(u,{})}),!h.loading&&!g.length&&!h.error&&(0,Z.jsx)(l,{title:r(`hitl.emptyState`,null,`暂无待审批请求`),description:`工具调用命中敏感规则时会在此等待裁决。`,style:{padding:48}}),(0,Z.jsx)(`div`,{className:`hitl-pending-list`,children:g.map(t=>(0,Z.jsx)(ue,{item:t,canWrite:e,onDone:()=>{g.length<=1&&i>1?a(i-1):h.reload()}},t.id))}),_>0&&(0,Z.jsx)(`div`,{className:`hitl-panel-pagination`,children:(0,Z.jsx)(f,{currentPage:i,pageSize:s,total:_,showSizeChanger:!0,pageSizeOpts:[10,20,50],showTotal:!0,onPageChange:e=>a(e),onPageSizeChange:v})})]})}var{Text:fe}=d;function pe({logId:e,onClose:t}){let n=T(),{data:r,loading:i,error:o,reload:l}=D(()=>w.get(`/hitl/logs/${encodeURIComponent(e)}`),[e],{skip:!e}),d=(0,R.useMemo)(()=>J(r?.payload),[r?.payload]),f=[r?.auditBackend,r?.auditModel].filter(Boolean).join(` · `);return(0,Z.jsxs)(m,{visible:!!e,onCancel:t,width:720,title:n(`hitl.logModalView`,null,`审批日志详情`),footer:(0,Z.jsx)(s,{onClick:t,children:n(`common.close`,null,`关闭`)}),children:[(0,Z.jsx)(A,{error:o,onRetry:l}),i&&!r&&(0,Z.jsx)(`div`,{className:`hitl-panel-loading`,children:(0,Z.jsx)(u,{})}),r&&(0,Z.jsxs)(`div`,{className:`hitl-log-detail`,children:[(0,Z.jsx)(k,{columns:2,items:[{label:n(`hitl.colTool`,null,`工具`),value:(0,Z.jsx)(fe,{strong:!0,children:r.toolName||`—`})},{label:n(`hitl.colDecision`,null,`决策`),value:(0,Z.jsx)(c,{size:`small`,color:q(r.decision),children:K(r.decision)})},{label:`状态`,value:re(r.status)},{label:n(`hitl.colDecidedBy`,null,`审批方`),value:ne(r.decidedBy)},{label:`审批方类型`,value:G(r.reviewer)},{label:`审批引擎`,value:f||`—`},{label:n(`hitl.colConversation`,null,`会话`),value:r.conversationId?(0,Z.jsxs)(a,{spacing:4,children:[(0,Z.jsx)(`span`,{className:`hitl-mono`,children:r.conversationId}),(0,Z.jsx)(M,{text:r.conversationId,size:`small`})]}):`—`},{label:`模式`,value:r.mode||`—`},{label:`创建时间`,value:Y(r.createdAt)},{label:`裁决时间`,value:Y(r.decidedAt)},{label:`ID`,value:(0,Z.jsx)(`span`,{className:`hitl-mono`,children:r.id})},{label:n(`hitl.fieldComment`,null,`备注`),value:r.comment||`—`}]}),(0,Z.jsx)(Q,{payload:d}),(0,Z.jsx)(F,{title:n(`hitl.fieldPayload`,null,`载荷`),value:d,collapsed:!0})]})]})}function me({canWrite:e,detailId:t,onOpenDetail:n,onCloseDetail:r,refreshKey:i=0}){let l=T(),[u,d]=(0,R.useState)(1),[f,p]=(0,R.useState)(20),[m,h]=(0,R.useState)(``),g=ee(m,350),[_,b]=(0,R.useState)(`all`),[x,S]=(0,R.useState)(`all`),[C,E]=(0,R.useState)([]),k=(0,R.useMemo)(()=>({q:g,decision:_===`all`?``:_,decidedBy:x===`all`?``:x}),[g,_,x]),j=D(()=>w.get(`/hitl/logs`,{page:u,pageSize:f,...k}),[u,f,k,i]),M=j.data?.items||[],N=Number(j.data?.total)||0,F=Number(j.data?.retentionDays)||0,z=(0,R.useCallback)(()=>j.reload(),[j.reload]),te=(0,R.useCallback)(()=>{C.length&&L({title:`批量删除审批日志`,content:`确定删除选中的 ${C.length} 条审批日志?此操作不可恢复。`,okText:l(`common.delete`,null,`删除`),onOk:async()=>{try{await w.del(`/hitl/logs`,{body:{ids:C}}),I(`已删除 ${C.length} 条审批日志`),E([]),z()}catch(e){O(e,`批量删除审批日志失败`)}}})},[z,C,l]),B=(0,R.useCallback)(()=>{L({title:l(`hitl.clearAll`,null,`清空审计日志`),content:g||_!==`all`||x!==`all`?`将清空当前筛选条件下的全部已裁决日志(不会删除待审批项)。`:`将清空全部已裁决审批日志(不会删除待审批项)。`,okText:l(`hitl.clearAll`,null,`清空`),onOk:async()=>{try{await w.del(`/hitl/logs`,{query:k,body:{all:!0}}),I(`审批日志已清空`),E([]),d(1),z()}catch(e){O(e,`清空审批日志失败`)}}})},[x,_,g,k,z,l]),V=[{title:l(`hitl.colTool`,null,`工具`),dataIndex:`toolName`,render:e=>(0,Z.jsx)(`span`,{className:`hitl-mono`,children:e||`—`})},{title:l(`hitl.colConversation`,null,`会话`),dataIndex:`conversationId`,width:200,render:e=>(0,Z.jsx)(`span`,{className:`hitl-mono hitl-ellipsis`,title:e||``,children:e||`—`})},{title:l(`hitl.colDecision`,null,`决策`),dataIndex:`decision`,width:100,render:e=>(0,Z.jsx)(c,{size:`small`,color:q(e),children:K(e)})},{title:l(`hitl.colDecidedBy`,null,`审批方`),dataIndex:`decidedBy`,width:140,render:(e,t)=>(0,Z.jsxs)(`div`,{className:`hitl-log-by`,children:[(0,Z.jsx)(`span`,{children:ne(e)}),t.auditBackend&&(0,Z.jsx)(`span`,{className:`hitl-log-engine`,children:[t.auditBackend,t.auditModel].filter(Boolean).join(` · `)})]})},{title:`备注`,dataIndex:`comment`,render:(e,t)=>(0,Z.jsx)(`span`,{title:e||``,children:e||X(J(t.payload))})},{title:l(`hitl.colTime`,null,`时间`),dataIndex:`decidedAt`,width:180,render:(e,t)=>Y(e||t.createdAt)},{title:l(`common.actions`,null,`操作`),dataIndex:`id`,width:90,render:e=>(0,Z.jsx)(s,{size:`small`,theme:`borderless`,onClick:()=>n(e),children:l(`common.view`,null,`详情`)})}],H={currentPage:u,pageSize:f,total:N,showSizeChanger:!0,pageSizeOpts:[20,50,100],showTotal:!0,onPageChange:e=>d(e),onPageSizeChange:e=>{p(e),d(1)}};return(0,Z.jsxs)(`div`,{className:`hitl-logs-panel`,children:[F>0&&(0,Z.jsx)(`p`,{className:`hitl-retention-hint`,children:l(`hitl.retentionHint`,{days:F},`审批日志保留 ${F} 天,到期自动清理。`)}),(0,Z.jsx)(A,{error:j.error,onRetry:z}),(0,Z.jsx)(P,{columns:V,dataSource:M,rowKey:`id`,loading:j.loading,pagination:H,size:`small`,emptyText:l(`hitl.logsEmpty`,null,`暂无审批日志`),rowSelection:{selectedRowKeys:C,onChange:e=>E(e||[])},toolbar:(0,Z.jsxs)(a,{spacing:8,wrap:!0,children:[(0,Z.jsx)(o,{showClear:!0,style:{width:220},value:m,placeholder:l(`hitl.searchPlaceholder`,null,`搜索工具、会话或载荷…`),onChange:e=>{h(e),d(1)}}),(0,Z.jsx)(y,{value:_,style:{width:120},optionList:[{value:`all`,label:l(`hitl.filterAll`,null,`全部`)},{value:`approve`,label:l(`hitl.decisionApprove`,null,`通过`)},{value:`reject`,label:l(`hitl.decisionReject`,null,`拒绝`)}],onChange:e=>{b(e),d(1)}}),(0,Z.jsx)(y,{value:x,style:{width:150},optionList:[{value:`all`,label:l(`hitl.filterAll`,null,`全部`)},{value:`human`,label:l(`hitl.reviewerHuman`,null,`人工`)},{value:`audit_agent`,label:l(`hitl.reviewerAgent`,null,`审计 Agent`)},{value:`system`,label:l(`hitl.reviewerSystem`,null,`系统`)},{value:`manual`,label:l(`hitl.reviewerManual`,null,`手动录入`)}],onChange:e=>{S(e),d(1)}}),(0,Z.jsx)(s,{icon:(0,Z.jsx)(v,{}),theme:`borderless`,size:`small`,onClick:z,loading:j.loading,children:l(`common.refresh`,null,`刷新`)}),(0,Z.jsxs)(s,{size:`small`,type:`danger`,theme:`borderless`,disabled:!e||!C.length,onClick:te,children:[`批量删除`,C.length?`(${C.length})`:``]}),(0,Z.jsx)(s,{size:`small`,type:`danger`,theme:`borderless`,disabled:!e||!N,onClick:B,children:l(`hitl.clearAll`,null,`清空`)})]})}),(0,Z.jsx)(pe,{logId:t,onClose:r})]})}var{Text:he}=d;function ge({canWrite:e,refreshKey:t=0}){let n=T(),{data:r,loading:i,error:o,reload:l}=D(()=>w.get(`/hitl/tool-whitelist`),[t]),[u,d]=(0,R.useState)(``),[f,p]=(0,R.useState)(``);(0,R.useEffect)(()=>{r&&d((r.toolWhitelist||[]).join(`
`))},[r]);let m=(0,R.useMemo)(()=>ce(u),[u]),h=(0,R.useMemo)(()=>(r?.toolWhitelist||[]).join(`
`),[r]),g=u.trim()!==h.trim(),_=(0,R.useCallback)(async()=>{p(`put`);try{let e=await w.put(`/hitl/tool-whitelist`,{toolWhitelist:m});I(n(`hitl.whitelistSaved`,null,`白名单已保存`)),d((e?.toolWhitelist||m).join(`
`)),l({silent:!0})}catch(e){O(e,n(`hitl.whitelistSaveFailed`,null,`保存白名单失败`))}finally{p(``)}},[l,n,m]),y=(0,R.useCallback)(async()=>{p(`post`);try{let e=await w.post(`/hitl/tool-whitelist`,{sensitiveTools:m});I(e?.hitlGlobalWhitelistMerged?`已合并到全局白名单`:`没有新增工具,白名单未变化`),d((e?.hitlGlobalToolWhitelist||m).join(`
diff --git a/web/static/app/assets/index-gBcdNgHq.js b/web/static/app/assets/index-BMTtTYg1.js
similarity index 96%
rename from web/static/app/assets/index-gBcdNgHq.js
rename to web/static/app/assets/index-BMTtTYg1.js
index fed40d35..7272c31b 100644
--- a/web/static/app/assets/index-gBcdNgHq.js
+++ b/web/static/app/assets/index-BMTtTYg1.js
@@ -1,4 +1,4 @@
-const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dashboard-BoeA5CBF.js","assets/rolldown-runtime-WkwZ5CU-.js","assets/react-QV7DAAIx.js","assets/semi-Dpcldp_F.js","assets/semi-BUXPdXzR.css","assets/dashboard-Dk6QMmtm.css","assets/chat-DWxpwXqA.js","assets/project-form-D2VoONj8.js","assets/model-channel-mQ6lfvSO.js","assets/chat-C3m4vsYB.css","assets/hitl-CJCJcXih.js","assets/hitl-ChWaPsj1.css","assets/tool-guard-DCElpaG3.js","assets/tool-guard-DKIWLN1V.css","assets/projects-umTb3ZuM.js","assets/AssetEditorModal-DNgfDOqO.js","assets/assetTarget-D2PEjBAg.js","assets/projects-BDwUv98l.css","assets/asset-overview-CuQShgUB.js","assets/AssetBits-BYTpudK4.js","assets/asset-overview-TjcTeyEy.css","assets/asset-library-1Ly1ptCD.js","assets/asset-library-a5Vth3JU.css","assets/info-collect-gcz16K7a.js","assets/info-collect-BrIcieOX.css","assets/vulnerabilities-DqwfXC0x.js","assets/vulnerabilities-BPt2JmiL.css","assets/tasks-P4eiZI8g.js","assets/tasks-BtBBHKoW.css","assets/workflows-CI4iDz7T.js","assets/workflows-EsKm07MV.css","assets/webshell-BtabWzUW.js","assets/webshell-BdcYpY5u.css","assets/c2-listeners-B04z6s--.js","assets/c2-shared-BxfKXbIb.js","assets/c2-shared-B-Nz9eUh.css","assets/c2-shared-C42gWRB4.js","assets/c2-listeners-KjhK45yg.css","assets/c2-sessions-DpFfDxb7.js","assets/c2-sessions-DLf_n8Eq.css","assets/c2-tasks-BXG-lzo5.js","assets/c2-tasks-B5H34xZF.css","assets/c2-payloads-B8kOz9Q8.js","assets/c2-payloads-CnRJmaJm.css","assets/c2-events-CYxXfc-x.js","assets/c2-events-BVd4qqKy.css","assets/c2-profiles-eJI5wP9G.js","assets/c2-profiles-BpNJlhDC.css","assets/chat-files-B0eFLyD7.js","assets/chat-files-wKL7Vwmw.css","assets/mcp-monitor-BViFxp5Y.js","assets/mcp-monitor-8VvqmnVY.css","assets/mcp-management-tut2O1U5.js","assets/mcp-management-CEr7J00D.css","assets/knowledge-retrieval-logs-BrnfC4xz.js","assets/knowledge-management-BcNL6uUW.js","assets/skills-monitor-B81EKy9l.js","assets/skills-management-CQXJu1PY.js","assets/agents-management-BtTb6SoA.js","assets/roles-management-B8OjAejZ.js","assets/platform-rbac-CWuv4xy7.js","assets/settings-BG8cDuOU.js","assets/settings-Duqs1vQx.css","assets/api-docs-hlf8fxq5.js","assets/api-docs-B_T3BEfL.css"])))=>i.map(i=>d[i]);
+const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dashboard-CNznJVIH.js","assets/rolldown-runtime-WkwZ5CU-.js","assets/react-QV7DAAIx.js","assets/semi-Dpcldp_F.js","assets/semi-BUXPdXzR.css","assets/dashboard-Dk6QMmtm.css","assets/chat-B-dZud0m.js","assets/project-form-nknm1nA2.js","assets/model-channel-mQ6lfvSO.js","assets/chat-C3m4vsYB.css","assets/hitl-DiQ6zsxN.js","assets/hitl-ChWaPsj1.css","assets/tool-guard-J1mF9p8U.js","assets/tool-guard-DKIWLN1V.css","assets/projects-BBs5dI8y.js","assets/AssetEditorModal-BbwbZZn2.js","assets/assetTarget-D2PEjBAg.js","assets/projects-BDwUv98l.css","assets/asset-overview-o_QJu_8H.js","assets/AssetBits-BYTpudK4.js","assets/asset-overview-TjcTeyEy.css","assets/asset-library-XMBnFkCS.js","assets/asset-library-a5Vth3JU.css","assets/info-collect-CDAsSm95.js","assets/info-collect-BrIcieOX.css","assets/vulnerabilities-CXnxkP8D.js","assets/vulnerabilities-BPt2JmiL.css","assets/tasks-BSMbtSY6.js","assets/tasks-BtBBHKoW.css","assets/workflows-C1ThtY-S.js","assets/workflows-EsKm07MV.css","assets/webshell-DDQpzC0l.js","assets/webshell-BdcYpY5u.css","assets/c2-listeners-Nc6p1LCr.js","assets/c2-shared-CweYFEMs.js","assets/c2-shared-B-Nz9eUh.css","assets/c2-shared-CGoxRI15.js","assets/c2-listeners-KjhK45yg.css","assets/c2-sessions-Bg61Ih8o.js","assets/c2-sessions-DLf_n8Eq.css","assets/c2-tasks-D50_YjFm.js","assets/c2-tasks-B5H34xZF.css","assets/c2-payloads-C6wD7vjB.js","assets/c2-payloads-CnRJmaJm.css","assets/c2-events-D6HmGisy.js","assets/c2-events-BVd4qqKy.css","assets/c2-profiles-s9C-E1r_.js","assets/c2-profiles-BpNJlhDC.css","assets/chat-files-BqcGDJ-j.js","assets/chat-files-wKL7Vwmw.css","assets/mcp-monitor-KnbRUJd6.js","assets/mcp-monitor-8VvqmnVY.css","assets/mcp-management-Cd1nNl8A.js","assets/mcp-management-CEr7J00D.css","assets/knowledge-retrieval-logs-SXJcUbfc.js","assets/knowledge-management-DFOwf3Pq.js","assets/skills-monitor-ZXiRYusW.js","assets/skills-management-BQ8ZyF58.js","assets/agents-management-XOSUN0Hb.js","assets/roles-management-CHCVTlQM.js","assets/platform-rbac-Bk5W3D2O.js","assets/settings-CMRCu6wT.js","assets/settings-i8zJhYeE.css","assets/api-docs-CmsQDaBX.js","assets/api-docs-B_T3BEfL.css"])))=>i.map(i=>d[i]);
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{$ as t,B as n,C as r,Ct as i,D as a,Et as o,F as s,Ft as c,G as l,Gt as u,Ht as d,I as f,It as p,K as m,Kt as ee,L as h,Lt as g,M as _,Mt as v,P as y,Q as te,R as ne,Rt as b,T as re,U as x,Ut as ie,V as S,Vt as ae,W as oe,Wt as se,Zt as ce,_t as le,ct as ue,dt as de,f as fe,gt as pe,i as C,it as me,j as he,jt as ge,k as _e,l as ve,mt as w,n as ye,nt as be,o as xe,pt as Se,q as Ce,r as we,rt as Te,st as Ee,t as De,vt as T,w as Oe,wt as E,y as ke,yt as D,z as Ae,zt as je}from"./semi-Dpcldp_F.js";import{S as Me,b as Ne,d as Pe,f as Fe,g as Ie,h as O,l as Le,m as Re,p as ze,t as Be,v as Ve}from"./react-QV7DAAIx.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var k=e(Me(),1),He=Ne(),Ue=`cyberstrike-auth`;function We(){try{let e=localStorage.getItem(Ue);if(!e)return null;let t=JSON.parse(e);if(!t?.token||!t?.expiresAt)return null;let n=new Date(t.expiresAt);return!Number.isFinite(n.getTime())||n.getTime()<=Date.now()?null:{token:t.token,expiresAt:n.toISOString(),user:t.user||null,roles:Array.isArray(t.roles)?t.roles:[],permissions:Array.isArray(t.permissions)?t.permissions:[],scope:t.scope||``}}catch(e){return console.warn(`读取会话失败:`,e),null}}function Ge(e){e?localStorage.setItem(Ue,JSON.stringify(e)):localStorage.removeItem(Ue)}var Ke=null;function qe(e){Ke=e||null}var Je=class extends Error{constructor(e,{status:t=0,payload:n=null,path:r=``}={}){super(e),this.name=`ApiError`,this.status=t,this.payload=n,this.path=r}};function Ye(e,t){let n=`/api${e.startsWith(`/`)?e:`/${e}`}`;if(!t)return n;let r=new URLSearchParams;for(let[e,n]of Object.entries(t))n!=null&&n!==``&&(Array.isArray(n)?n.forEach(t=>r.append(e,t)):r.append(e,String(n)));let i=r.toString();return i?`${n}${n.includes(`?`)?`&`:`?`}${i}`:n}async function Xe(e){let t=e.headers.get(`content-type`)||``;try{if(t.includes(`application/json`)){let t=await e.json();return{message:t.error||t.message||`请求失败(HTTP ${e.status})`,payload:t}}let n=await e.text();return{message:n?.slice(0,300)||`请求失败(HTTP ${e.status})`,payload:n}}catch{return{message:`请求失败(HTTP ${e.status})`,payload:null}}}async function A(e,t={}){let{method:n=`GET`,body:r,query:i,headers:a={},signal:o,raw:s=!1,timeout:c=6e4}=t,l={Accept:`application/json`,...a},u=r;r!=null&&!(r instanceof FormData)&&typeof r!=`string`&&!(r instanceof Blob)&&(l[`Content-Type`]=`application/json`,u=JSON.stringify(r)),Ke&&!l.Authorization&&(l.Authorization=`Bearer ${Ke}`);let d=new AbortController,f=c?setTimeout(()=>d.abort(),c):null,p=()=>d.abort();o&&(o.aborted?d.abort():o.addEventListener(`abort`,p,{once:!0}));let m;try{m=await fetch(Ye(e,i),{method:n,headers:l,body:u,signal:d.signal})}catch(t){throw t.name===`AbortError`?new Je(`请求已取消`,{path:e}):new Je(`网络连接失败,请检查服务状态`,{path:e})}finally{f&&clearTimeout(f),o&&o.removeEventListener(`abort`,p)}if(m.status===401&&window.dispatchEvent(new CustomEvent(`csai:unauthorized`)),!m.ok){let{message:t,payload:n}=await Xe(m);throw new Je(t,{status:m.status,payload:n,path:e})}return s?m:m.status===204?null:(m.headers.get(`content-type`)||``).includes(`application/json`)?m.json():m.text()}var j={get:(e,t,n={})=>A(e,{...n,query:t}),post:(e,t,n={})=>A(e,{...n,method:`POST`,body:t}),put:(e,t,n={})=>A(e,{...n,method:`PUT`,body:t}),patch:(e,t,n={})=>A(e,{...n,method:`PATCH`,body:t}),del:(e,t={})=>A(e,{...t,method:`DELETE`}),raw:(e,t={})=>A(e,{...t,raw:!0})};async function Ze(e,{query:t,filename:n,method:r=`GET`,body:i}={}){let a=await A(e,{method:r,body:i,query:t,raw:!0,timeout:12e4}),o=await a.blob(),s=a.headers.get(`content-disposition`)||``,c=s.match(/filename\*=UTF-8''([^;]+)/i),l=s.match(/filename="?([^";]+)"?/i),u=n||(c?decodeURIComponent(c[1]):l?.[1])||`download.bin`,d=URL.createObjectURL(o),f=document.createElement(`a`);return f.href=d,f.download=u,document.body.appendChild(f),f.click(),f.remove(),setTimeout(()=>URL.revokeObjectURL(d),1e3),u}function Qe(e,t,{onEvent:n,onError:r,onClose:i,signal:a}={}){let o=new AbortController;a&&(a.aborted?o.abort():a.addEventListener(`abort`,()=>o.abort(),{once:!0}));let s={"Content-Type":`application/json`,Accept:`text/event-stream`};return Ke&&(s.Authorization=`Bearer ${Ke}`),(async()=>{try{let r=await fetch(Ye(e),{method:`POST`,headers:s,body:JSON.stringify(t||{}),signal:o.signal});if(r.status===401&&window.dispatchEvent(new CustomEvent(`csai:unauthorized`)),!r.ok){let{message:t}=await Xe(r);throw new Je(t,{status:r.status,path:e})}if(!r.body)throw new Je(`服务端未返回流式响应`,{path:e});let a=r.body.getReader(),c=new TextDecoder,l=``,u=!1;for(;!u;){let{done:e,value:t}=await a.read();if(e)break;l+=c.decode(t,{stream:!0});let r;for(;(r=l.indexOf(`
`))>=0;){let e=l.slice(0,r).replace(/\r$/,``);if(l=l.slice(r+1),!e.startsWith(`data:`))continue;let t=e.slice(5).trim();if(!t)continue;if(t===`[DONE]`){u=!0;break}let i;try{i=JSON.parse(t)}catch{continue}n?.(i)}}i?.()}catch(e){if(e.name===`AbortError`){i?.();return}r?.(e)}})(),()=>o.abort()}function $e(e,t=`操作失败`){return e?typeof e==`string`?e:e.message||t:t}var M=e(Be(),1),et=(0,k.createContext)(null);function tt(e,t){return e?{token:t||e.token,expiresAt:e.expires_at||e.expiresAt||``,appVersion:typeof e.app_version==`string`?e.app_version.trim():``,user:e.user||null,roles:Array.isArray(e.roles)?e.roles:[],permissions:Array.isArray(e.permissions)?e.permissions:[],scope:e.scope||``}:null}function nt({children:e}){let t=(0,k.useRef)(We()).current,[n,r]=(0,k.useState)(t),[i,a]=(0,k.useState)(!!t);(0,k.useEffect)(()=>{if(qe(t?.token||null),!t?.token){a(!1);return}let e=!1;return j.get(`/auth/validate`).then(n=>{if(e)return;let i=tt(n,t.token);r(i),Ge(i)}).catch(()=>{e||(r(null),Ge(null),qe(null))}).finally(()=>{e||a(!1)}),()=>{e=!0}},[]);let o=(0,k.useCallback)(()=>{r(null),qe(null),Ge(null)},[]);(0,k.useEffect)(()=>{let e=()=>o();return window.addEventListener(`csai:unauthorized`,e),()=>window.removeEventListener(`csai:unauthorized`,e)},[o]);let s=(0,k.useCallback)(async(e,t)=>{let n=await j.post(`/auth/login`,{username:String(e||``).trim(),password:t}),i=tt(n,n?.token);return qe(i?.token||null),Ge(i),r(i),i},[]),c=(0,k.useCallback)(async()=>{try{await j.post(`/auth/logout`,{})}catch{}o()},[o]),l=(0,k.useMemo)(()=>new Set(n?.permissions||[]),[n]),u=(0,k.useCallback)(e=>!e||String(e).split(/\s+/).some(e=>l.has(e)),[l]),d=(0,k.useCallback)(e=>{let t=Array.isArray(e)?e:String(e||``).split(/\s+/).filter(Boolean);return!t.length||t.some(e=>l.has(e))},[l]),f=(0,k.useCallback)(async()=>{if(!n?.token)return null;let e=tt(await j.get(`/auth/validate`),n.token);return r(e),Ge(e),e},[n?.token]),p=(0,k.useMemo)(()=>({session:n,user:n?.user||null,roles:n?.roles||[],permissions:l,hasPermission:u,hasAnyPermission:d,checking:i,authenticated:!!n?.token,login:s,logout:c,refresh:f}),[n,l,u,d,i,s,c,f]);return(0,M.jsx)(et.Provider,{value:p,children:e})}function N(){let e=(0,k.useContext)(et);if(!e)throw Error(`useAuth 必须在 AuthProvider 内使用`);return e}var rt=[{id:`zh-CN`,label:`简体中文`},{id:`en-US`,label:`English`},{id:`ru-RU`,label:`Русский`},{id:`ar-SA`,label:`العربية`}],it=`csai_lang`,at=`zh-CN`,ot=`/static/i18n`,st=new Map;function ct(){try{let e=localStorage.getItem(it);if(e&&rt.some(t=>t.id===e))return e}catch{}let e=String(navigator.language||``).toLowerCase();return e.startsWith(`zh`)?`zh-CN`:e.startsWith(`ru`)?`ru-RU`:e.startsWith(`ar`)?`ar-SA`:e.startsWith(`en`)?`en-US`:at}function lt(e){return st.has(e)||st.set(e,fetch(`${ot}/${e}.json`,{cache:`no-cache`}).then(e=>e.ok?e.json():{}).catch(()=>({}))),st.get(e)}function ut(e,t){if(!e)return;let n=e;for(let e of String(t).split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return typeof n==`string`?n:void 0}function dt(e,t){return t?e.replace(/\{\{\s*(\w+)\s*\}\}/g,(e,n)=>t[n]===void 0?e:String(t[n])):e}var ft=(0,k.createContext)({lang:at,t:e=>e,ready:!1,setLanguage:()=>{}});function pt({children:e}){let[t,n]=(0,k.useState)(ct),[r,i]=(0,k.useState)({}),[a,o]=(0,k.useState)(!1);(0,k.useEffect)(()=>{let e=!1;Promise.all([lt(t),lt(at),lt(`en-US`)]).then(([t,n,r])=>{e||(i({current:t,fallback:n,english:r}),o(!0))}),document.documentElement.lang=t,document.documentElement.dir=t===`ar-SA`?`rtl`:`ltr`;try{localStorage.setItem(it,t)}catch{}return()=>{e=!0}},[t]);let s=(0,k.useCallback)((e,t,n)=>{if(!e)return n??``;let i=ut(r.current,e)??ut(r.fallback,e)??ut(r.english,e);return i===void 0?n??e:dt(i,t)},[r]),c=(0,k.useCallback)(e=>{e&&e!==t&&(o(!1),n(e),window.dispatchEvent(new CustomEvent(`csai:languagechange`,{detail:{lang:e}})))},[t]),l=(0,k.useMemo)(()=>({lang:t,t:s,ready:a,setLanguage:c}),[t,s,a,c]);return(0,M.jsx)(ft.Provider,{value:l,children:e})}function mt(){return(0,k.useContext)(ft)}function P(){return(0,k.useContext)(ft).t}var ht=`cyberstrike-theme`,gt=[`system`,`light`,`dark`];function _t(){try{let e=localStorage.getItem(ht);return gt.includes(e)?e:`system`}catch{return`system`}}function vt(){return typeof window<`u`&&window.matchMedia?window.matchMedia(`(prefers-color-scheme: dark)`).matches:!1}function yt(e){return e===`dark`||e===`light`?e:vt()?`dark`:`light`}function bt(e){let t=yt(e),n=document.documentElement;return n.setAttribute(`data-theme`,t),n.setAttribute(`data-theme-preference`,e),n.style.colorScheme=t,document.body?.setAttribute(`theme-mode`,t===`dark`?`dark`:`light`),t}var xt=(0,k.createContext)({preference:`system`,theme:`light`,setPreference:()=>{},toggle:()=>{}});function St({children:e}){let[t,n]=(0,k.useState)(_t),[r,i]=(0,k.useState)(()=>yt(_t()));(0,k.useLayoutEffect)(()=>{i(bt(t));try{localStorage.setItem(ht,t)}catch{}if(t!==`system`||!window.matchMedia)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>i(bt(t));return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[t]),(0,k.useEffect)(()=>{document.body?.setAttribute(`theme-mode`,r===`dark`?`dark`:`light`)},[r]);let a=(0,k.useCallback)(e=>{gt.includes(e)&&n(e)},[]),o=(0,k.useCallback)(()=>{n(e=>yt(e)===`dark`?`light`:`dark`)},[]),s=(0,k.useMemo)(()=>({preference:t,theme:r,setPreference:a,toggle:o}),[t,r,a,o]);return(0,M.jsx)(xt.Provider,{value:s,children:e})}function Ct(){return(0,k.useContext)(xt)}var wt=[{id:`dashboard`,i18n:`nav.dashboard`,fallback:`仪表盘`,icon:D},{id:`chat`,i18n:`nav.chat`,fallback:`对话`,icon:v},{id:`security`,i18n:`nav.security`,fallback:`安全防护`,icon:be,anyPermission:[`hitl:read`,`config:read`],children:[{id:`hitl`,i18n:`nav.hitl`,fallback:`人机协同`,permission:`hitl:read`},{id:`tool-guard`,i18n:`nav.toolGuard`,fallback:`调用拦截`,permission:`config:read`}]},{id:`projects`,i18n:`nav.projects`,fallback:`项目管理`,icon:ae},{id:`assets`,i18n:`nav.assets`,fallback:`资产管理`,icon:E,anyPermission:[`asset:read`,`fofa:execute`],children:[{id:`asset-overview`,i18n:`nav.assetOverview`,fallback:`资产概览`},{id:`asset-library`,i18n:`nav.assetLibrary`,fallback:`资产库`},{id:`info-collect`,i18n:`nav.infoCollect`,fallback:`信息收集`}]},{id:`vulnerabilities`,i18n:`nav.vulnerabilities`,fallback:`漏洞管理`,icon:be},{id:`tasks`,i18n:`nav.tasks`,fallback:`任务管理`,icon:je},{id:`workflows`,i18n:`nav.workflows`,fallback:`工作流`,icon:d},{id:`webshell`,i18n:`nav.webshell`,fallback:`WebShell管理`,icon:te},{id:`c2`,i18n:`nav.c2`,fallback:`C2`,icon:se,children:[{id:`c2-listeners`,i18n:`nav.c2Listeners`,fallback:`监听器`},{id:`c2-sessions`,i18n:`nav.c2Sessions`,fallback:`会话`},{id:`c2-tasks`,i18n:`nav.c2Tasks`,fallback:`任务`},{id:`c2-payloads`,i18n:`nav.c2Payloads`,fallback:`载荷`},{id:`c2-events`,i18n:`nav.c2Events`,fallback:`事件`},{id:`c2-profiles`,i18n:`nav.c2Profiles`,fallback:`流量伪装`}]},{id:`chat-files`,i18n:`nav.chatFiles`,fallback:`文件管理`,icon:i},{id:`mcp`,i18n:`nav.mcp`,fallback:`MCP`,icon:me,children:[{id:`mcp-monitor`,i18n:`nav.mcpMonitor`,fallback:`MCP状态监控`},{id:`mcp-management`,i18n:`nav.mcpManagement`,fallback:`MCP管理`}]},{id:`knowledge`,i18n:`nav.knowledge`,fallback:`知识`,icon:ie,children:[{id:`knowledge-retrieval-logs`,i18n:`nav.knowledgeRetrievalLogs`,fallback:`检索历史`},{id:`knowledge-management`,i18n:`nav.knowledgeManagement`,fallback:`知识管理`}]},{id:`skills`,i18n:`nav.skills`,fallback:`技能`,icon:ue,children:[{id:`skills-monitor`,i18n:`nav.skillsMonitor`,fallback:`技能状态`},{id:`skills-management`,i18n:`nav.skillsManagement`,fallback:`技能管理`}]},{id:`agents`,i18n:`nav.agents`,fallback:`智能体`,icon:m,children:[{id:`agents-management`,i18n:`nav.agentsManagement`,fallback:`智能体管理`}]},{id:`roles`,i18n:`nav.roles`,fallback:`角色`,icon:Ce,children:[{id:`roles-management`,i18n:`nav.rolesManagement`,fallback:`角色管理`}]},{id:`platform-rbac`,i18n:`nav.platformRbac`,fallback:`平台权限`,icon:w},{id:`settings`,i18n:`nav.settings`,fallback:`系统设置`,icon:Te},{id:`api-docs`,i18n:`apiDocs.title`,fallback:`API 文档`,icon:ee}],Tt=[{id:`workspace`,i18n:`nav.groupWorkspace`,fallback:`工作台`,pages:[`dashboard`,`chat`,`security`]},{id:`operations`,i18n:`nav.groupOperations`,fallback:`安全作业`,pages:[`projects`,`assets`,`vulnerabilities`,`tasks`,`workflows`,`webshell`,`c2`,`chat-files`]},{id:`capabilities`,i18n:`nav.groupCapabilities`,fallback:`能力中心`,pages:[`mcp`,`knowledge`,`skills`,`agents`,`roles`]},{id:`platform`,i18n:`nav.groupPlatform`,fallback:`平台管理`,pages:[`platform-rbac`,`settings`,`api-docs`]}],Et=wt.flatMap(e=>e.children?e.children.map(t=>({...t,parent:e.id})):[e]);function Dt(e){return Et.find(t=>t.id===e)||wt.find(t=>t.id===e)||null}function F(e){"@babel/helpers - typeof";return F=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},F(e)}function Ot(e,t){if(F(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(F(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function kt(e){var t=Ot(e,`string`);return F(t)==`symbol`?t:t+``}function I(e,t,n){return(t=kt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var At;function jt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Mt=jt();function Nt(e){Mt=e}var Pt={exec:()=>null};function L(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(R.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Ft=(()=>{try{return!0}catch{return!1}})(),R={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`)},It=/^(?:[ \t]*(?:\n|$))+/,Lt=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Rt=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,zt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Bt=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Vt=/(?:[*+-]|\d{1,9}[.)])/,Ht=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ut=L(Ht).replace(/bull/g,Vt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Wt=L(Ht).replace(/bull/g,Vt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),z=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Gt=/^[^\n]+/,Kt=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,qt=L(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Kt).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Jt=L(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Vt).getRegex(),B=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Yt=/|$))/,Xt=L(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Yt).replace(`tag`,B).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Zt=L(z).replace(`hr`,zt).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,B).getRegex(),Qt={blockquote:L(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Zt).getRegex(),code:Lt,def:qt,fences:Rt,heading:Bt,hr:zt,html:Xt,lheading:Ut,list:Jt,newline:It,paragraph:Zt,table:Pt,text:Gt},$t=L(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,zt).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,B).getRegex(),en={...Qt,lheading:Wt,table:$t,paragraph:L(z).replace(`hr`,zt).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,$t).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,B).getRegex()},tn={...Qt,html:L(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?\\1> *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Yt).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Pt,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:L(z).replace(`hr`,zt).replace(`heading`,` *#{1,6} *[^
]`).replace(`lheading`,Ut).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},nn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,rn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,an=/^( {2,}|\\)\n(?!\s*$)/,on=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\`+)[^`]+\k(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Ft?"(?`+)[^`]+\k(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),hn=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,gn=L(hn,`u`).replace(/punct/g,sn).getRegex(),_n=L(hn,`u`).replace(/punct/g,dn).getRegex(),vn=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,yn=L(vn,`gu`).replace(/notPunctSpace/g,ln).replace(/punctSpace/g,cn).replace(/punct/g,sn).getRegex(),bn=L(vn,`gu`).replace(/notPunctSpace/g,pn).replace(/punctSpace/g,fn).replace(/punct/g,dn).getRegex(),xn=L(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,ln).replace(/punctSpace/g,cn).replace(/punct/g,sn).getRegex(),Sn=L(/\\(punct)/,`gu`).replace(/punct/g,sn).getRegex(),Cn=L(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),wn=L(Yt).replace(`(?:-->|$)`,`-->`).getRegex(),Tn=L(`^comment|^[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^`).replace(`comment`,wn).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),En=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Dn=L(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,En).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),On=L(/^!?\[(label)\]\[(ref)\]/).replace(`label`,En).replace(`ref`,Kt).getRegex(),kn=L(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Kt).getRegex(),An=L(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,On).replace(`nolink`,kn).getRegex(),jn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Mn={_backpedal:Pt,anyPunctuation:Sn,autolink:Cn,blockSkip:mn,br:an,code:rn,del:Pt,emStrongLDelim:gn,emStrongRDelimAst:yn,emStrongRDelimUnd:xn,escape:nn,link:Dn,nolink:kn,punctuation:un,reflink:On,reflinkSearch:An,tag:Tn,text:on,url:Pt},Nn={...Mn,link:L(/^!?\[(label)\]\((.*?)\)/).replace(`label`,En).getRegex(),reflink:L(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,En).getRegex()},Pn={...Mn,emStrongRDelimAst:bn,emStrongLDelim:_n,url:L(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,jn).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:L(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\":`>`,'"':`"`,"'":`'`},zn=e=>Rn[e];function V(e,t){if(t){if(R.escapeTest.test(e))return e.replace(R.escapeReplace,zn)}else if(R.escapeTestNoEncode.test(e))return e.replace(R.escapeReplaceNoEncode,zn);return e}function Bn(e){try{e=encodeURI(e).replace(R.percentDecode,`%`)}catch{return null}return e}function Vn(e,t){let n=e.replace(R.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(R.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length0?-2:-1}function Wn(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function Gn(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
@@ -61,4 +61,4 @@ ${e}
`+this.renderer.text(i);n+=t?this.renderer.paragraph({type:`paragraph`,raw:o,text:o,tokens:[{type:`text`,raw:o,text:o,escaped:!0}]}):o;continue}default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}parseInline(e,t=this.renderer){let n=``;for(let r=0;r{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new 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=`