- {body && (streaming
- ?
{body}
- :
)}
- {!body && streaming &&
正在生成…
}
{list.map(block => {
if (block.kind === 'reasoning') {
return
;
@@ -161,6 +159,17 @@ export default function TurnBody({
return null;
})}
+ {body.trim() && (isAssistant && !streaming ? (
+
+
+ {t('chat.taskSummary')}
+
+
+
+ ) : streaming ? (
+
{body}
+ ) :
)}
+ {!body.trim() && streaming &&
正在生成…
}
);
}
diff --git a/web/frontend/src/pages/chat/page.css b/web/frontend/src/pages/chat/page.css
index 5e64f238..22c62f90 100644
--- a/web/frontend/src/pages/chat/page.css
+++ b/web/frontend/src/pages/chat/page.css
@@ -198,6 +198,10 @@
.chat-turn-body .cs-markdown table { display: block; max-width: 100%; overflow-x: auto; }
.chat-turn-body .cs-markdown img { height: auto; }
.chat-stream-placeholder { font-size: 13px; color: var(--semi-color-text-2); }
+.chat-task-summary { margin-top: 14px; min-width: 0; border: 1px solid var(--semi-color-primary-light-active); border-radius: 12px; background: var(--semi-color-bg-2); }
+.chat-task-summary-title { padding: 14px 16px; color: var(--semi-color-text-0); font-size: 15px; font-weight: 600; cursor: pointer; overflow-wrap: anywhere; }
+.chat-task-summary-title:focus-visible { outline: 2px solid var(--semi-color-primary); outline-offset: -2px; border-radius: 12px; }
+.chat-task-summary-content { min-width: 0; padding: 0 16px 16px; }
.chat-pre {
margin: 0;
diff --git a/web/frontend/tests/chat-task-summary.spec.mjs b/web/frontend/tests/chat-task-summary.spec.mjs
new file mode 100644
index 00000000..79a31178
--- /dev/null
+++ b/web/frontend/tests/chat-task-summary.spec.mjs
@@ -0,0 +1,116 @@
+import { test, expect, ready, CONVERSATION, label } from './fixtures.mjs';
+
+const summaryStart = '已完成本轮检查,发现两项需要复核的问题。';
+const summary = `## 检查结果\n\n${summaryStart}\n\n` + Array.from({ length: 35 }, (_, i) => `### 证据 ${i + 1}\n\n这是本地模拟记录的证据说明,保留测试范围、验证结果和待确认事项。`).join('\n\n');
+
+function processDetails(text) {
+ const details = [];
+ for (let i = 1; i <= 24; i++) {
+ details.push({ eventType: 'iteration', message: `第 ${i} 轮`, data: { iteration: i, piScope: 'main' } });
+ details.push({ eventType: 'tool_call', data: { toolCallId: `call-${i}`, agentName: 'main', toolName: 'read_file', argumentsObj: { path: 'fixture.txt' } } });
+ details.push({ eventType: 'tool_result', message: 'fixture evidence', data: { toolCallId: `call-${i}`, result: 'fixture evidence', success: true } });
+ }
+ details.push({ eventType: 'tool_call', data: { toolCallId: 'exit', toolName: 'exit', agentName: 'main', argumentsObj: { final_result: text } } });
+ details.push({ eventType: 'tool_result', message: text, data: { toolCallId: 'exit', result: text, success: true } });
+ details.push({ eventType: 'agent_usage_summary', data: { agentName: 'main', modelCalls: 24, promptTokens: 1000, completionTokens: 200, totalTokens: 1200 } });
+ details.push({ eventType: 'finalization_check', message: '已交付本轮回复。', data: { finalizable: true, finalized: true, finalText: text } });
+ return details;
+}
+
+function completedConversation(text = summary) {
+ return { ...CONVERSATION, messages: [CONVERSATION.messages[0], { ...CONVERSATION.messages[1], content: text, processDetails: processDetails(text) }] };
+}
+
+for (const [width, colorScheme] of [[1440, 'light'], [390, 'dark']]) {
+ test(`history opens at the expanded summary after 24 iterations at ${width}px`, async ({ page, mockApi }) => {
+ await page.setViewportSize({ width, height: 900 });
+ await page.emulateMedia({ colorScheme });
+ mockApi.respond('GET', `/api/conversations/${CONVERSATION.id}`, { json: completedConversation() });
+ await page.goto(`/static/app/#/chat?conversation=${CONVERSATION.id}`);
+ const main = await ready(page);
+ const result = main.getByRole('region', { name: '任务总结', exact: true });
+ await expect(result.locator('details')).toHaveAttribute('open', '');
+ await expect(result.locator('summary')).toBeInViewport({ ratio: 1 });
+ await expect(result.getByText(summaryStart, { exact: true })).toBeInViewport();
+ await expect(main.locator('.chat-msg-user [data-chat-summary]')).toHaveCount(0);
+ const order = await main.locator('.chat-msg-assistant .chat-turn-body').evaluate(el => {
+ const children = [...el.children];
+ return children[children.length - 1].matches('[data-chat-summary]');
+ });
+ expect(order).toBe(true);
+ expect(await result.evaluate(el => el.scrollWidth <= el.clientWidth)).toBe(true);
+
+ // The report is readable without opening exit, and the original tool evidence remains available.
+ await result.locator('summary').click();
+ await expect(result.locator('details')).not.toHaveAttribute('open', '');
+ await result.locator('summary').click();
+ await expect(result.getByText(summaryStart, { exact: true })).toBeVisible();
+ await main.locator('.chat-messages').evaluate(el => { el.scrollTop = 0; });
+ await main.locator('.chat-tool').first().locator('.semi-collapse-header').click();
+ await expect(main.locator('.chat-tool').first()).toContainText('fixture evidence');
+ await page.reload();
+ await ready(page);
+ await expect(result.locator('summary')).toBeInViewport({ ratio: 1 });
+ expect(mockApi.writes()).toEqual([]);
+ });
+}
+
+test('Plan-Execute completion focuses the summary while reading earlier steps and survives history reconciliation', async ({ page, mockApi }) => {
+ const path = `/api/conversations/${CONVERSATION.id}`;
+ const previous = completedConversation('上一轮的总结');
+ mockApi.respond('GET', '/api/agent-loop/tasks', { json: { tasks: [] } });
+ mockApi.respond('GET', path, { json: previous });
+ await page.goto(`/static/app/#/chat?conversation=${CONVERSATION.id}`);
+ const main = await ready(page);
+ await main.getByRole('combobox', { name: label('chat.agentModeSelectAria', '选择对话执行模式') }).click();
+ await page.getByRole('option').filter({ hasText: 'Plan-Execute' }).click();
+ await expect(main.locator('.chat-composer-mode')).toHaveText('Plan-Execute');
+
+ let finishStream;
+ const streamGate = new Promise(resolve => { finishStream = resolve; });
+ let restoreHistory;
+ const historyGate = new Promise(resolve => { restoreHistory = resolve; });
+ mockApi.respond('POST', '/api/multi-agent/stream', async () => {
+ await streamGate;
+ mockApi.respond('GET', path, async () => {
+ await historyGate;
+ return { json: { ...previous, messages: [...previous.messages, { id: 'new-user', role: 'user', content: '继续整理证据' }, { id: 'new-assistant', role: 'assistant', content: summary, processDetails: processDetails(summary) }] } };
+ });
+ const events = [
+ ...processDetails(summary).map(detail => ({ type: detail.eventType, message: detail.message || '', data: detail.data })),
+ { type: 'response', message: summary, data: { conversationId: CONVERSATION.id, messageId: 'new-assistant', finalizable: true } },
+ { type: 'done', data: {} }
+ ];
+ return { contentType: 'text/event-stream; charset=utf-8', body: events.map(event => `data: ${JSON.stringify(event)}\n\n`).join('') };
+ });
+ const input = main.getByRole('textbox', { name: label('chat.composerLabel', '对话内容'), exact: true });
+ try {
+ await input.fill('继续整理证据');
+ await main.getByRole('button', { name: label('chat.send', '发送'), exact: true }).click();
+ await expect(main.locator('.chat-msg-live')).toBeVisible();
+ await main.locator('.chat-messages').evaluate(el => { el.scrollTop = 0; el.dispatchEvent(new Event('scroll')); });
+ finishStream();
+ const liveSummary = main.locator('.chat-msg-live [data-chat-summary]');
+ await expect(liveSummary.locator('summary')).toBeInViewport({ ratio: 1 });
+ await expect(liveSummary.getByText(summaryStart, { exact: true })).toBeInViewport();
+ restoreHistory();
+ await expect(main.locator('.chat-msg-live')).toHaveCount(0);
+ const stored = main.locator('.chat-msg-assistant').last().locator('[data-chat-summary]');
+ await expect(stored.locator('summary')).toBeInViewport({ ratio: 1 });
+ await expect(stored.getByText(summaryStart, { exact: true })).toBeInViewport();
+ expect(mockApi.writes()).toHaveLength(1);
+ } finally {
+ finishStream();
+ restoreHistory();
+ }
+});
+
+test('a run without final text retains its diagnostic and has no fabricated summary', async ({ page, mockApi }) => {
+ const conversation = completedConversation('');
+ conversation.messages[1].processDetails = [{ eventType: 'error', message: '模型调用失败,尚未生成最终正文' }];
+ mockApi.respond('GET', `/api/conversations/${CONVERSATION.id}`, { json: conversation });
+ await page.goto(`/static/app/#/chat?conversation=${CONVERSATION.id}`);
+ const main = await ready(page);
+ await expect(main.locator('[data-chat-summary]')).toHaveCount(0);
+ await expect(main.getByText('模型调用失败,尚未生成最终正文', { exact: true })).toBeInViewport();
+});
diff --git a/web/static/app/assets/agents-management-CHNYsdON.js b/web/static/app/assets/agents-management-DttFswit.js
similarity index 97%
rename from web/static/app/assets/agents-management-CHNYsdON.js
rename to web/static/app/assets/agents-management-DttFswit.js
index 2ab4f9b2..a2803568 100644
--- a/web/static/app/assets/agents-management-CHNYsdON.js
+++ b/web/static/app/assets/agents-management-DttFswit.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,at as c,ct as l,i as u,ot as d,wt as f,xt as p}from"./semi-DCiGoqD2.js";import{F as m,I as h,P as g,a as _,b as v,c as y,d as b,f as x,l as S,m as C,p as w,s as T,u as E,x as D,y as O}from"./index-DCqi6LfY.js";var k=e(t(),1),A=e(n(),1),{Text:j}=s;function M(){let e=g(),{hasPermission:t}=m(),n=t(`agents:write`),s=t(`agents:delete`),[M,N]=(0,k.useState)(``),[P,F]=(0,k.useState)(null),[I,L]=(0,k.useState)(null),[R,z]=(0,k.useState)(!1),B=_(()=>h.get(`/multi-agent/markdown-agents`),[]),V=(Array.isArray(B.data?.agents)?B.data.agents:[]).filter(e=>{if(!M)return!0;let t=M.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),H=async e=>{try{F(await h.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){v(e,`读取智能体失败`)}},U=async()=>{let e=await I.form.validate();z(!0);try{await h.post(`/multi-agent/markdown-agents`,{filename:e.filename?.trim()||``,name:e.name.trim(),description:e.description?.trim()||``,instruction:e.instruction,kind:e.kind||`sub`,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean)}),D(`智能体已保存`),L(null),B.reload()}catch(e){v(e,`保存智能体失败`)}finally{z(!1)}},W=e=>O({title:`删除智能体「${e.name||e.filename}」?`,onOk:async()=>{await h.del(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`),D(`已删除`),B.reload()}});return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(w,{title:e(`agents.title`,null,`智能体管理`),description:B.data?.dir?`目录:${B.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,A.jsxs)(r,{children:[(0,A.jsx)(a,{icon:(0,A.jsx)(d,{}),onClick:()=>B.reload(),loading:B.loading,children:`刷新`}),n&&(0,A.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(l,{}),onClick:()=>L({record:null,form:{}}),children:`新建智能体`})]})}),B.data?.error&&(0,A.jsx)(S,{error:B.data.error}),(0,A.jsxs)(C,{title:`智能体(${V.length})`,children:[(0,A.jsx)(S,{error:B.error,onRetry:()=>B.reload()}),(0,A.jsx)(T,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,A.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,A.jsxs)(r,{children:[(0,A.jsx)(j,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,A.jsx)(o,{size:`small`,color:`purple`,children:`编排器`})]}),(0,A.jsx)(j,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,A.jsx)(o,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,A.jsx)(j,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,A.jsxs)(r,{children:[(0,A.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>H(t),children:`详情`}),n&&(0,A.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,A.jsx)(p,{}),onClick:()=>L({record:t,form:{}})}),s&&(0,A.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,A.jsx)(f,{}),onClick:()=>W(t)})]})}],dataSource:V,rowKey:`filename`,loading:B.loading,pagination:{pageSize:20},toolbar:(0,A.jsx)(i,{prefix:(0,A.jsx)(c,{}),value:M,onChange:N,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,A.jsx)(y,{title:I?.record?`编辑智能体`:`新建智能体`,visible:!!I,onCancel:()=>L(null),onOk:U,confirmLoading:R,width:760,children:(0,A.jsxs)(u,{getFormApi:e=>L(t=>t&&{...t,form:e}),initValues:I?.record?{filename:I.record.filename,name:I.record.name,description:I.record.description,kind:I.record.kind||`sub`}:{kind:`sub`},children:[(0,A.jsx)(u.Input,{field:`filename`,label:`文件名(留空自动生成)`,placeholder:`例如 recon.md`}),(0,A.jsx)(u.Input,{field:`name`,label:`名称`,rules:[{required:!0,message:`请输入名称`}]}),(0,A.jsx)(u.Input,{field:`description`,label:`描述`}),(0,A.jsx)(u.Select,{field:`kind`,label:`类型`,optionList:[{value:`sub`,label:`子智能体`},{value:`orchestrator`,label:`编排器`},{value:`plan_execute`,label:`计划执行`}]}),(0,A.jsx)(u.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::tool`}),(0,A.jsx)(u.TextArea,{field:`instruction`,label:`指令(Markdown)`,autosize:{minRows:8,maxRows:20}})]})},I?.record?.filename||`new-agent`),(0,A.jsx)(y,{title:P?.name||`智能体详情`,visible:!!P,onCancel:()=>F(null),width:720,children:P&&(0,A.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,A.jsx)(b,{items:[{label:`文件名`,value:P.filename},{label:`ID`,value:P.id},{label:`类型`,value:P.kind},{label:`绑定角色`,value:P.bind_role||`—`},{label:`最大迭代`,value:P.max_iterations??`—`},{label:`工具`,value:Array.isArray(P.tools)&&P.tools.length?P.tools.join(`、`):`—`}]}),(0,A.jsx)(x,{content:P.instruction||P.raw||``}),(0,A.jsx)(E,{value:P.raw||P,title:`原始 Markdown`,collapsed:!0})]})})]})}export{M as default};
\ No newline at end of file
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,at as c,ct as l,i as u,ot as d,wt as f,xt as p}from"./semi-DCiGoqD2.js";import{F as m,I as h,P as g,a as _,b as v,c as y,d as b,f as x,l as S,m as C,p as w,s as T,u as E,x as D,y as O}from"./index-DhiAuEy4.js";var k=e(t(),1),A=e(n(),1),{Text:j}=s;function M(){let e=g(),{hasPermission:t}=m(),n=t(`agents:write`),s=t(`agents:delete`),[M,N]=(0,k.useState)(``),[P,F]=(0,k.useState)(null),[I,L]=(0,k.useState)(null),[R,z]=(0,k.useState)(!1),B=_(()=>h.get(`/multi-agent/markdown-agents`),[]),V=(Array.isArray(B.data?.agents)?B.data.agents:[]).filter(e=>{if(!M)return!0;let t=M.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),H=async e=>{try{F(await h.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){v(e,`读取智能体失败`)}},U=async()=>{let e=await I.form.validate();z(!0);try{await h.post(`/multi-agent/markdown-agents`,{filename:e.filename?.trim()||``,name:e.name.trim(),description:e.description?.trim()||``,instruction:e.instruction,kind:e.kind||`sub`,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean)}),D(`智能体已保存`),L(null),B.reload()}catch(e){v(e,`保存智能体失败`)}finally{z(!1)}},W=e=>O({title:`删除智能体「${e.name||e.filename}」?`,onOk:async()=>{await h.del(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`),D(`已删除`),B.reload()}});return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(w,{title:e(`agents.title`,null,`智能体管理`),description:B.data?.dir?`目录:${B.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,A.jsxs)(r,{children:[(0,A.jsx)(a,{icon:(0,A.jsx)(d,{}),onClick:()=>B.reload(),loading:B.loading,children:`刷新`}),n&&(0,A.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(l,{}),onClick:()=>L({record:null,form:{}}),children:`新建智能体`})]})}),B.data?.error&&(0,A.jsx)(S,{error:B.data.error}),(0,A.jsxs)(C,{title:`智能体(${V.length})`,children:[(0,A.jsx)(S,{error:B.error,onRetry:()=>B.reload()}),(0,A.jsx)(T,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,A.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,A.jsxs)(r,{children:[(0,A.jsx)(j,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,A.jsx)(o,{size:`small`,color:`purple`,children:`编排器`})]}),(0,A.jsx)(j,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,A.jsx)(o,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,A.jsx)(j,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,A.jsxs)(r,{children:[(0,A.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>H(t),children:`详情`}),n&&(0,A.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,A.jsx)(p,{}),onClick:()=>L({record:t,form:{}})}),s&&(0,A.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,A.jsx)(f,{}),onClick:()=>W(t)})]})}],dataSource:V,rowKey:`filename`,loading:B.loading,pagination:{pageSize:20},toolbar:(0,A.jsx)(i,{prefix:(0,A.jsx)(c,{}),value:M,onChange:N,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,A.jsx)(y,{title:I?.record?`编辑智能体`:`新建智能体`,visible:!!I,onCancel:()=>L(null),onOk:U,confirmLoading:R,width:760,children:(0,A.jsxs)(u,{getFormApi:e=>L(t=>t&&{...t,form:e}),initValues:I?.record?{filename:I.record.filename,name:I.record.name,description:I.record.description,kind:I.record.kind||`sub`}:{kind:`sub`},children:[(0,A.jsx)(u.Input,{field:`filename`,label:`文件名(留空自动生成)`,placeholder:`例如 recon.md`}),(0,A.jsx)(u.Input,{field:`name`,label:`名称`,rules:[{required:!0,message:`请输入名称`}]}),(0,A.jsx)(u.Input,{field:`description`,label:`描述`}),(0,A.jsx)(u.Select,{field:`kind`,label:`类型`,optionList:[{value:`sub`,label:`子智能体`},{value:`orchestrator`,label:`编排器`},{value:`plan_execute`,label:`计划执行`}]}),(0,A.jsx)(u.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::tool`}),(0,A.jsx)(u.TextArea,{field:`instruction`,label:`指令(Markdown)`,autosize:{minRows:8,maxRows:20}})]})},I?.record?.filename||`new-agent`),(0,A.jsx)(y,{title:P?.name||`智能体详情`,visible:!!P,onCancel:()=>F(null),width:720,children:P&&(0,A.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,A.jsx)(b,{items:[{label:`文件名`,value:P.filename},{label:`ID`,value:P.id},{label:`类型`,value:P.kind},{label:`绑定角色`,value:P.bind_role||`—`},{label:`最大迭代`,value:P.max_iterations??`—`},{label:`工具`,value:Array.isArray(P.tools)&&P.tools.length?P.tools.join(`、`):`—`}]}),(0,A.jsx)(x,{content:P.instruction||P.raw||``}),(0,A.jsx)(E,{value:P.raw||P,title:`原始 Markdown`,collapsed:!0})]})})]})}export{M as default};
\ No newline at end of file
diff --git a/web/static/app/assets/api-docs-BS1HpMGZ.js b/web/static/app/assets/api-docs-DrZBFtJn.js
similarity index 98%
rename from web/static/app/assets/api-docs-BS1HpMGZ.js
rename to web/static/app/assets/api-docs-DrZBFtJn.js
index 87350b4a..5855c9d8 100644
--- a/web/static/app/assets/api-docs-BS1HpMGZ.js
+++ b/web/static/app/assets/api-docs-DrZBFtJn.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{E as r,F as i,H as a,L as o,M as s,P as c,W as l,at as u,c as d,it as f,ot as p,v as m,x as h}from"./semi-DCiGoqD2.js";import{B as g,I as _,P as v,R as y,b,p as x,u as S}from"./index-DCqi6LfY.js";var C=e(t(),1),w=e(n(),1),{Text:T,Paragraph:E}=l,D={get:`blue`,post:`green`,put:`orange`,delete:`red`,patch:`violet`,head:`grey`,options:`grey`};function O(e){let t=e?.paths||{},n=[];return Object.entries(t).forEach(([e,t])=>{Object.entries(t||{}).forEach(([t,r])=>{r&&typeof r==`object`&&n.push({id:`${t.toUpperCase()} ${e}`,method:t.toUpperCase(),path:e,summary:r.summary||r.description||``,tag:r.tags&&r.tags[0]||`default`,operation:r})})}),n.sort((e,t)=>e.path.localeCompare(t.path)||e.method.localeCompare(t.method))}function k(e){return Array.from(e.matchAll(/\{([^}]+)\}/g)).map(e=>e[1])}function A({operation:e,spec:t}){let n=e.operation||{},c=n.parameters||[],l=k(e.path),[u,d]=(0,C.useState)({}),[p,m]=(0,C.useState)(``),[_,v]=(0,C.useState)(null),[x,E]=(0,C.useState)(!1);return(0,C.useEffect)(()=>{let e={};l.forEach(t=>{let n=c.find(e=>e.name===t&&e.in===`path`);e[t]=n?.schema?.default??n?.example??``}),c.filter(e=>e.in===`query`).forEach(t=>{t.schema?.default!==void 0&&(e[`query:${t.name}`]=String(t.schema.default))}),d(e),m(n.requestBody?`{
+import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{E as r,F as i,H as a,L as o,M as s,P as c,W as l,at as u,c as d,it as f,ot as p,v as m,x as h}from"./semi-DCiGoqD2.js";import{B as g,I as _,P as v,R as y,b,p as x,u as S}from"./index-DhiAuEy4.js";var C=e(t(),1),w=e(n(),1),{Text:T,Paragraph:E}=l,D={get:`blue`,post:`green`,put:`orange`,delete:`red`,patch:`violet`,head:`grey`,options:`grey`};function O(e){let t=e?.paths||{},n=[];return Object.entries(t).forEach(([e,t])=>{Object.entries(t||{}).forEach(([t,r])=>{r&&typeof r==`object`&&n.push({id:`${t.toUpperCase()} ${e}`,method:t.toUpperCase(),path:e,summary:r.summary||r.description||``,tag:r.tags&&r.tags[0]||`default`,operation:r})})}),n.sort((e,t)=>e.path.localeCompare(t.path)||e.method.localeCompare(t.method))}function k(e){return Array.from(e.matchAll(/\{([^}]+)\}/g)).map(e=>e[1])}function A({operation:e,spec:t}){let n=e.operation||{},c=n.parameters||[],l=k(e.path),[u,d]=(0,C.useState)({}),[p,m]=(0,C.useState)(``),[_,v]=(0,C.useState)(null),[x,E]=(0,C.useState)(!1);return(0,C.useEffect)(()=>{let e={};l.forEach(t=>{let n=c.find(e=>e.name===t&&e.in===`path`);e[t]=n?.schema?.default??n?.example??``}),c.filter(e=>e.in===`query`).forEach(t=>{t.schema?.default!==void 0&&(e[`query:${t.name}`]=String(t.schema.default))}),d(e),m(n.requestBody?`{
}`:``),v(null)},[e.id]),(0,w.jsxs)(`div`,{className:`api-docs-try`,children:[(0,w.jsx)(r,{margin:`12px 0`}),(0,w.jsx)(T,{strong:!0,children:`在线调试`}),l.length>0&&(0,w.jsx)(`div`,{className:`api-docs-try-fields`,children:l.map(e=>(0,w.jsxs)(`label`,{className:`api-docs-try-field`,children:[(0,w.jsxs)(`span`,{children:[`路径参数 `,e]}),(0,w.jsx)(a,{size:`small`,value:u[e]??``,onChange:t=>d(n=>({...n,[e]:t}))})]},e))}),c.filter(e=>e.in===`query`).length>0&&(0,w.jsx)(`div`,{className:`api-docs-try-fields`,children:c.filter(e=>e.in===`query`).map(e=>(0,w.jsxs)(`label`,{className:`api-docs-try-field`,children:[(0,w.jsxs)(`span`,{children:[`查询参数 `,e.name,e.required?` *`:``]}),(0,w.jsx)(a,{size:`small`,value:u[`query:${e.name}`]??``,onChange:t=>d(n=>({...n,[`query:${e.name}`]:t})),placeholder:e.description||``})]},e.name))}),n.requestBody&&(0,w.jsxs)(`div`,{className:`api-docs-try-body`,children:[(0,w.jsx)(`span`,{children:`请求体(JSON)`}),(0,w.jsx)(h,{value:p,onChange:m,autosize:{minRows:5,maxRows:14}})]}),(0,w.jsxs)(i,{children:[(0,w.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,w.jsx)(f,{}),loading:x,onClick:async()=>{E(!0),v(null);try{if(l.some(e=>String(u[e]??``).trim()===``)){b(`请填写路径参数`);return}let t=e.path;l.forEach(e=>{t=t.replace(`{${e}}`,encodeURIComponent(u[e]??``))});let r={};c.filter(e=>e.in===`query`).forEach(e=>{let t=u[`query:${e.name}`];t!==void 0&&t!==``&&(r[e.name]=t)});let i={method:e.method,query:r,raw:!0,timeout:12e4};if(n.requestBody&&p.trim())try{i.body=JSON.parse(p)}catch{b(`请求体不是合法 JSON`),E(!1);return}if(!t.startsWith(`/`)||t.startsWith(`//`))throw Error(`接口地址必须为站内 API 路径`);let a=await g(t.startsWith(`/api/`)?t.slice(4):t,i),o=a.headers.get(`content-type`)||``,s;s=o.includes(`application/json`)?await a.json():await a.text(),v({ok:!0,status:a.status,payload:s})}catch(e){v({ok:!1,status:e.status||0,payload:y(e)})}finally{E(!1)}},children:`发送请求`}),(0,w.jsx)(o,{onClick:()=>v(null),children:`清空结果`})]}),_&&(0,w.jsxs)(`div`,{className:`api-docs-try-result`,children:[(0,w.jsx)(s,{color:_.ok?`green`:`red`,children:_.ok?`HTTP ${_.status}`:`失败 ${_.status||``}`}),(0,w.jsx)(S,{value:_.payload,title:`响应`})]})]})}function j(){let e=v(),[t,n]=(0,C.useState)(null),[r,l]=(0,C.useState)(!0),[f,h]=(0,C.useState)(null),[g,b]=(0,C.useState)(``),[k,j]=(0,C.useState)(`all`),[M,N]=(0,C.useState)(null),P=async()=>{l(!0),h(null);try{let e=await _.get(`/openapi/spec`);n(e)}catch(e){h(e)}finally{l(!1)}};(0,C.useEffect)(()=>{P()},[]);let F=(0,C.useMemo)(()=>O(t),[t]),I=(0,C.useMemo)(()=>F.filter(e=>{if(k!==`all`&&e.method!==k)return!1;if(!g)return!0;let t=g.toLowerCase();return e.path.toLowerCase().includes(t)||e.summary.toLowerCase().includes(t)||e.method.toLowerCase().includes(t)}),[F,g,k]),L=I.find(e=>e.id===M)||I[0]||null,R=(0,C.useMemo)(()=>{let e=new Map;return I.forEach(t=>{e.has(t.tag)||e.set(t.tag,[]),e.get(t.tag).push(t)}),[...e.entries()]},[I]);return(0,w.jsxs)(`div`,{className:`api-docs-page`,children:[(0,w.jsx)(x,{title:e(`apiDocs.title`,null,`API 文档`),description:t?.info?.description||`CyberStrikeAI 开放接口`,extra:(0,w.jsx)(o,{icon:(0,w.jsx)(p,{}),onClick:P,loading:r,children:`重新加载`})}),(0,w.jsxs)(`div`,{className:`api-docs-layout`,children:[(0,w.jsxs)(c,{className:`api-docs-sidebar`,bordered:!1,children:[(0,w.jsxs)(i,{vertical:!0,style:{width:`100%`},spacing:8,children:[(0,w.jsx)(a,{prefix:(0,w.jsx)(u,{}),value:g,onChange:b,placeholder:`搜索路径或说明`}),(0,w.jsx)(m,{value:k,onChange:j,style:{width:`100%`},optionList:[{value:`all`,label:`全部方法`},...[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`].map(e=>({value:e,label:e}))]})]}),(0,w.jsxs)(`div`,{className:`api-docs-list`,children:[R.map(([e,t])=>(0,w.jsxs)(`div`,{className:`api-docs-group`,children:[(0,w.jsx)(T,{type:`tertiary`,className:`api-docs-group-title`,children:e}),t.map(e=>(0,w.jsxs)(`button`,{type:`button`,className:`api-docs-item ${L?.id===e.id?`is-active`:``}`,onClick:()=>N(e.id),children:[(0,w.jsx)(s,{size:`small`,color:D[e.method.toLowerCase()],children:e.method}),(0,w.jsx)(`span`,{className:`api-docs-item-path`,children:e.path})]},e.id))]},e)),!r&&R.length===0&&(0,w.jsx)(T,{type:`tertiary`,children:`没有匹配的接口`})]})]}),(0,w.jsxs)(`div`,{className:`api-docs-detail`,children:[f&&(0,w.jsx)(c,{bordered:!1,children:(0,w.jsx)(T,{type:`danger`,children:y(f)})}),L?(0,w.jsxs)(c,{bordered:!1,children:[(0,w.jsxs)(`div`,{className:`api-docs-detail-head`,children:[(0,w.jsx)(s,{color:D[L.method.toLowerCase()],children:L.method}),(0,w.jsx)(`code`,{className:`api-docs-detail-path`,children:L.path})]}),(0,w.jsx)(E,{children:L.summary||`无说明`}),(0,w.jsxs)(d,{type:`line`,children:[(0,w.jsx)(d.TabPane,{itemKey:`params`,tab:`参数`,children:(0,w.jsx)(S,{value:L.operation.parameters||[],title:`Request Parameters`,collapsed:!0})}),(0,w.jsx)(d.TabPane,{itemKey:`body`,tab:`请求体`,children:(0,w.jsx)(S,{value:L.operation.requestBody||{},title:`Request Body`,collapsed:!0})}),(0,w.jsx)(d.TabPane,{itemKey:`responses`,tab:`响应`,children:(0,w.jsx)(S,{value:L.operation.responses||{},title:`Responses`,collapsed:!0})})]}),(0,w.jsx)(A,{operation:L,spec:t})]}):(0,w.jsx)(c,{bordered:!1,children:(0,w.jsx)(T,{type:`tertiary`,children:r?`加载中…`:`选择左侧接口查看详情`})})]})]})]})}export{j as default};
\ No newline at end of file
diff --git a/web/static/app/assets/asset-library-D6VZ8DMo.js b/web/static/app/assets/asset-library-BAx49DmG.js
similarity index 99%
rename from web/static/app/assets/asset-library-D6VZ8DMo.js
rename to web/static/app/assets/asset-library-BAx49DmG.js
index 11beb451..d469ccc3 100644
--- a/web/static/app/assets/asset-library-D6VZ8DMo.js
+++ b/web/static/app/assets/asset-library-BAx49DmG.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,Dt as s,E as c,F as l,H as u,L as d,W as f,at as p,ct as m,f as h,i as g,l as _,m as v,ot as y,p as b,u as x,v as S,x as ee,z as C}from"./semi-DCiGoqD2.js";import{E as w,F as te,I as T,P as E,R as D,S as ne,a as re,b as O,c as k,d as A,l as ie,m as ae,n as oe,o as j,p as se,s as ce,x as M,y as le}from"./index-DCqi6LfY.js";import{A as ue,C as de,D as fe,E as pe,M as me,N as he,O as ge,P as _e,S as ve,T as ye,_ as N,a as P,b as F,c as I,d as L,f as R,g as be,h as z,i as B,j as V,k as H,l as U,m as W,n as G,o as xe,p as Se,r as K,s as q,t as Ce,u as we,v as Te,w as J,x as Ee,y as De}from"./assetTarget-BZG-CCGP.js";var Y=e(t(),1),X=e(i(),1),Oe={q:``,protocol:``,source:``,project_id:``,tag:``,status:``,risk_level:``,environment:``,criticality:``,ip:``,domain:``,port:``,scan:``,sort:`last_seen_at:desc`};function ke(){return{...Oe}}function Ae({filters:e,projects:t,onChange:n,onReset:r,disabled:i}){let a=E(),[s,c]=(0,Y.useState)(e.q||``);(0,Y.useEffect)(()=>{c(e.q||``)},[e.q]);let f=(0,Y.useMemo)(()=>(t||[]).map(e=>({value:e.id,label:e.name||e.id})),[t]),m=[`status`,`risk_level`,`environment`,`criticality`,`ip`,`domain`,`port`,`scan`].filter(t=>e[t]).length;return(0,X.jsxs)(`div`,{className:`asset-library-filters`,children:[(0,X.jsxs)(`div`,{className:`asset-library-filter-grid`,children:[(0,X.jsx)(u,{prefix:(0,X.jsx)(p,{}),value:s,disabled:i,placeholder:a(`assets.searchPlaceholder`,null,`搜索主机、IP、域名、标题、服务或标签`),onChange:e=>{c(e),n({q:e})},showClear:!0}),(0,X.jsx)(S,{value:e.protocol||void 0,placeholder:a(`assets.assetType`,null,`类型 / 协议`),optionList:J,filter:!0,allowCreate:!0,showClear:!0,disabled:i,onChange:e=>n({protocol:e||``})}),(0,X.jsx)(u,{value:e.source,placeholder:a(`assets.source`,null,`来源`),disabled:i,onChange:e=>n({source:e}),showClear:!0}),(0,X.jsx)(S,{value:e.project_id||void 0,placeholder:a(`assets.project`,null,`所属项目`),optionList:f,filter:!0,showClear:!0,disabled:i,onChange:e=>n({project_id:e||``})}),(0,X.jsx)(u,{value:e.tag,placeholder:a(`assets.tagsLabel`,null,`标签`),disabled:i,onChange:e=>n({tag:e}),showClear:!0}),(0,X.jsx)(l,{spacing:8,className:`asset-library-filter-actions`,children:(0,X.jsx)(d,{onClick:r,disabled:i,children:a(`assets.resetFilters`,null,`重置`)})})]}),(0,X.jsx)(o,{className:`asset-library-filter-advanced`,keepDOM:!1,children:(0,X.jsx)(o.Panel,{itemKey:`advanced`,header:`${a(`assets.advancedFilters`,null,`高级筛选`)}${m?`(${m})`:``}`,children:(0,X.jsxs)(`div`,{className:`asset-library-filter-grid asset-library-filter-grid--advanced`,children:[(0,X.jsx)(S,{value:e.status||void 0,placeholder:a(`assets.allStatuses`,null,`全部状态`),optionList:H,showClear:!0,disabled:i,onChange:e=>n({status:e||``})}),(0,X.jsx)(S,{value:e.risk_level||void 0,placeholder:a(`assets.allRisks`,null,`全部风险`),optionList:ye,showClear:!0,disabled:i,onChange:e=>n({risk_level:e||``})}),(0,X.jsx)(S,{value:e.environment||void 0,placeholder:a(`assets.allEnvironments`,null,`全部环境`),optionList:De,showClear:!0,disabled:i,onChange:e=>n({environment:e||``})}),(0,X.jsx)(S,{value:e.criticality||void 0,placeholder:a(`assets.allCriticalities`,null,`全部级别`),optionList:N,showClear:!0,disabled:i,onChange:e=>n({criticality:e||``})}),(0,X.jsx)(u,{value:e.ip,placeholder:`IP`,disabled:i,onChange:e=>n({ip:e}),showClear:!0}),(0,X.jsx)(u,{value:e.domain,placeholder:a(`assets.domain`,null,`域名`),disabled:i,onChange:e=>n({domain:e}),showClear:!0}),(0,X.jsx)(u,{value:e.port,placeholder:a(`assets.port`,null,`端口`),disabled:i,onChange:e=>n({port:String(e||``).replace(/[^\d]/g,``)}),showClear:!0}),(0,X.jsx)(S,{value:e.scan||``,placeholder:a(`assets.scanState`,null,`扫描状态`),optionList:pe,disabled:i,onChange:e=>n({scan:e||``})}),(0,X.jsx)(S,{value:e.sort||`last_seen_at:desc`,optionList:fe,disabled:i,onChange:e=>n({sort:e||`last_seen_at:desc`})})]})})})]})}var{Text:je}=f;function Me({assets:e,loading:t,total:n,page:r,pageSize:i,onPageChange:a,onPageSizeChange:o,selectedRowKeys:s,onSelectionChange:c,onView:u,onEdit:f,onDelete:p,onRefresh:m,canWrite:h,canDelete:g}){let _=E(),v=e=>{le({title:_(`assets.deleteConfirm`,null,`确定删除该资产吗?`),content:K(e),okText:_(`common.delete`,null,`删除`),onOk:()=>{Promise.resolve(p(e)).catch(e=>O(e,_(`assets.deleteFailed`,null,`删除资产失败`)))}})},y=[{title:_(`assets.target`,null,`目标`),dataIndex:`host`,width:260,render:(e,t)=>(0,X.jsxs)(`div`,{className:`asset-library-target`,children:[(0,X.jsx)(z,{text:K(t),max:38}),(0,X.jsx)(je,{type:`tertiary`,size:`small`,children:[t.ip,t.domain].filter(Boolean).join(` · `)||`—`})]})},{title:_(`assets.service`,null,`服务`),dataIndex:`protocol`,width:150,render:(e,t)=>(0,X.jsx)(R,{protocol:t.protocol,port:t.port})},{title:_(`assets.project`,null,`所属项目`),dataIndex:`project_name`,width:160,render:e=>(0,X.jsx)(z,{text:e,max:18})},{title:_(`assets.source`,null,`来源`),dataIndex:`source`,width:120,render:e=>(0,X.jsx)(z,{text:e,max:14})},{title:_(`assets.riskLevel`,null,`风险等级`),dataIndex:`risk_level`,width:150,render:(e,t)=>(0,X.jsxs)(l,{spacing:6,children:[(0,X.jsx)(Se,{asset:t}),(0,X.jsx)(je,{type:`tertiary`,size:`small`,children:Number(t.vulnerability_count||0)})]})},{title:_(`assets.lastSeen`,null,`最近发现`),dataIndex:`last_seen_at`,width:170,render:e=>(0,X.jsx)(je,{size:`small`,children:w(e)})},{title:_(`common.actions`,null,`操作`),dataIndex:`id`,width:190,render:(e,t)=>(0,X.jsxs)(l,{spacing:4,children:[(0,X.jsx)(d,{theme:`borderless`,size:`small`,onClick:()=>u(t),children:_(`common.view`,null,`查看`)}),h&&(0,X.jsx)(d,{theme:`borderless`,size:`small`,onClick:()=>f(t),children:_(`common.edit`,null,`编辑`)}),g&&(0,X.jsx)(d,{theme:`borderless`,type:`danger`,size:`small`,onClick:()=>v(t),children:_(`common.delete`,null,`删除`)})]})}];return(0,X.jsx)(ce,{columns:y,dataSource:e,loading:t,rowKey:`id`,onRefresh:m,rowSelection:{selectedRowKeys:s,onChange:(e,t)=>c(e,t)},pagination:{currentPage:r,pageSize:i,total:n||0,showSizeChanger:!0,pageSizeOpts:[10,20,50,100],onPageChange:a,onPageSizeChange:o},emptyText:_(`common.noData`,null,`暂无数据`)})}var{Text:Z}=f;function Ne({asset:e,visible:t,onClose:r,onEdit:i,onDelete:a,canWrite:o,canDelete:s}){let u=E(),f=n();if(!e)return null;let p=()=>{if(e.last_scan_task_id){f(`/vulnerabilities?task_id=${encodeURIComponent(e.last_scan_task_id)}`);return}if(e.last_scan_conversation_id){f(`/vulnerabilities?conversation_id=${encodeURIComponent(e.last_scan_conversation_id)}`);return}let t=e.host||e.domain||e.ip||``;f(t?`/vulnerabilities?host_q=${encodeURIComponent(t)}`:`/vulnerabilities`)},m=[{label:`Host`,value:e.host||`—`},{label:`IP`,value:e.ip||`—`},{label:u(`assets.domain`,null,`域名`),value:e.domain||`—`},{label:u(`assets.service`,null,`服务`),value:(0,X.jsx)(R,{protocol:e.protocol,port:e.port})},{label:u(`assets.project`,null,`所属项目`),value:e.project_name||e.project_id||`—`},{label:u(`assets.status`,null,`状态`),value:(0,X.jsx)(L,{status:e.status})},{label:u(`assets.riskLevel`,null,`风险等级`),value:(0,X.jsx)(Se,{asset:e})},{label:u(`assets.environment`,null,`环境`),value:me(e.environment)||`—`},{label:u(`assets.criticality`,null,`重要性`),value:V(e.criticality)||`—`},{label:u(`assets.location`,null,`地区`),value:[e.country,e.province,e.city].filter(Boolean).join(` / `)||`—`},{label:u(`assets.responsiblePerson`,null,`负责人`),value:e.responsible_person||`—`},{label:u(`assets.department`,null,`部门`),value:e.department||`—`},{label:u(`assets.businessSystem`,null,`业务系统`),value:e.business_system||`—`},{label:u(`assets.title`,null,`标题/指纹`),value:e.title||`—`},{label:u(`assets.server`,null,`服务指纹`),value:e.server||`—`},{label:u(`assets.source`,null,`来源`),value:e.source||`—`},{label:u(`assets.sourceQuery`,null,`来源查询`),value:e.source_query?(0,X.jsx)(Z,{code:!0,size:`small`,children:e.source_query}):`—`},{label:u(`assets.tagsLabel`,null,`标签`),value:(0,X.jsx)(W,{tags:e.tags,max:6})},{label:u(`assets.firstSeen`,null,`首次发现`),value:w(e.first_seen_at)},{label:u(`assets.lastSeen`,null,`最近发现`),value:w(e.last_seen_at)},{label:u(`assets.lastScan`,null,`上次扫描`),value:w(e.last_scan_at)},{label:`创建时间`,value:w(e.created_at)},{label:`更新时间`,value:w(e.updated_at)},{label:`资产 ID`,value:(0,X.jsx)(Z,{copyable:{content:e.id},size:`small`,children:e.id})}];return(0,X.jsxs)(h,{visible:t,onCancel:r,title:u(`assets.detailTitle`,null,`资产详情`),width:620,placement:`right`,footer:(0,X.jsxs)(l,{children:[o&&(0,X.jsx)(d,{onClick:()=>i(e),children:u(`common.edit`,null,`编辑`)}),s&&(0,X.jsx)(d,{type:`danger`,onClick:()=>a(e),children:u(`common.delete`,null,`删除`)}),(0,X.jsx)(d,{theme:`borderless`,onClick:r,children:u(`common.close`,null,`关闭`)})]}),children:[(0,X.jsxs)(`div`,{className:`asset-library-detail-target`,children:[(0,X.jsxs)(`div`,{className:`asset-library-detail-target-main`,children:[(0,X.jsx)(Z,{strong:!0,size:`large`,children:K(e)}),(0,X.jsx)(j,{text:K(e)})]}),(0,X.jsx)(Z,{type:`tertiary`,children:[e.ip,e.domain,G(e)].filter(Boolean).join(` · `)||`—`}),(0,X.jsxs)(l,{spacing:6,wrap:!0,className:`asset-library-detail-badges`,children:[(0,X.jsx)(L,{status:e.status}),(0,X.jsx)(Se,{asset:e}),(0,X.jsxs)(Z,{type:`tertiary`,size:`small`,children:[u(`assets.relatedVulnerabilities`,null,`相关漏洞`),`:`,Number(e.vulnerability_count||0),e.risk_level?`(${he(e.risk_level)})`:``]})]})]}),(0,X.jsx)(c,{margin:`12px`}),(0,X.jsx)(A,{items:m,columns:2}),(0,X.jsx)(c,{margin:`12px`}),(0,X.jsxs)(l,{children:[(0,X.jsx)(d,{theme:`light`,onClick:p,children:u(`assets.viewRelatedVulnerabilities`,null,`查看关联漏洞`)}),e.project_id&&(0,X.jsx)(d,{theme:`borderless`,onClick:()=>f(`/projects?id=${encodeURIComponent(e.project_id)}`),children:u(`assets.viewProject`,null,`查看项目`)})]})]})}var Pe=`asset-library-editor`;function Q(e){return{target:U(e),host:e?.host||``,ip:e?.ip||``,domain:e?.domain||``,port:e?.port??void 0,protocol:e?.protocol||``,title:e?.title||``,server:e?.server||``,project_id:e?.project_id||``,status:e?.status||`active`,environment:e?.environment||``,criticality:e?.criticality||``,country:e?.country||``,province:e?.province||``,city:e?.city||``,responsible_person:e?.responsible_person||``,department:e?.department||``,business_system:e?.business_system||``,tags:Array.isArray(e?.tags)?e.tags:[]}}function Fe({visible:e,asset:t,projects:n,onClose:r,onSaved:i}){let a=E(),[o,s]=(0,Y.useState)(null),[c,u]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(``),m=(0,Y.useRef)(U(t)),h=(0,Y.useMemo)(()=>Q(t),[t,e]),_=!!t?.id;(0,Y.useEffect)(()=>{e&&(m.current=U(t),p(``),u(!1))},[e,t]);let v=(0,Y.useMemo)(()=>(n||[]).map(e=>({value:e.id,label:e.name||e.id})),[n]),y=e=>{if(!o)return null;let t=String(o.getValue(`target`)||``).trim();try{let e=q(t);return o.setValues({host:e.host,ip:e.ip,domain:e.domain,port:e.port||void 0,protocol:e.protocol}),m.current=t,e}catch(t){return e&&p(t.message),null}},b=()=>{let e=o.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!==m.current)try{let e=q(n);r={...r,host:r.host||e.host,ip:e.ip||r.ip,domain:e.domain||r.domain,port:e.port||r.port,protocol:e.protocol||r.protocol}}catch(e){throw Error(e.message)}return r},x=async()=>{if(c||!o)return;p(``);try{await o.validate()}catch{return}let e;try{e=b()}catch(e){p(e.message);return}u(!0);try{if(_)await T.put(`/assets/${encodeURIComponent(t.id)}`,e),M(a(`assets.updatedSuccessfully`,null,`资产已更新`));else{let t=await T.post(`/assets/import`,{assets:[e],source:`manual`}),n=Number(t?.created||0),r=Number(t?.updated||0),i=Number(t?.skipped||0);if(!n&&!r&&i)throw Error(a(`assets.assetSkipped`,null,`资产未保存,可能已存在且你没有更新权限`));M(n?a(`assets.createdSuccessfully`,null,`资产已添加`):a(`assets.duplicateMerged`,null,`资产已存在,信息已安全合并`))}i?.(),r?.()}catch(e){p(D(e,a(`assets.saveFailed`,null,`保存资产失败`)))}finally{u(!1)}};return(0,X.jsxs)(k,{visible:e,title:_?a(`assets.editAssetTitle`,null,`编辑资产`):a(`assets.addAssetTitle`,null,`新增资产`),width:760,onCancel:r,onOk:x,okText:_?a(`common.save`,null,`保存`):a(`assets.addAssetAction`,null,`添加资产`),confirmLoading:c,closeOnEsc:!0,maskClosable:!1,children:[f&&(0,X.jsx)(C,{type:`danger`,bordered:!0,closeIcon:null,description:f,className:`asset-library-form-error`}),(0,X.jsxs)(g,{className:Pe,initValues:h,getFormApi:s,labelPosition:`top`,onSubmit:x,children:[(0,X.jsx)(`div`,{className:`asset-library-form-grid asset-library-form-grid--full`,children:(0,X.jsx)(g.Input,{field:`target`,label:a(`assets.assetAddress`,null,`资产地址`),placeholder:`https://example.com:443 / example.com / 1.1.1.1:22`,helpText:a(`assets.assetAddressHint`,null,`可识别的 URL、域名、IP 和端口会自动解析`),onBlur:()=>y(!0),rules:[{required:!0,message:a(`assets.targetRequired`,null,`请输入资产地址`)},{validator:(e,t,n)=>{try{q(t),n()}catch(e){n(Error(e.message))}}}]})}),(0,X.jsxs)(`div`,{className:`asset-library-form-grid`,children:[(0,X.jsx)(g.Input,{field:`host`,label:a(`assets.hostUrl`,null,`完整 URL / Host`)}),(0,X.jsx)(g.Input,{field:`ip`,label:`IP`,rules:[{validator:(e,t,n)=>{!t||B(t)||P(t)?n():n(Error(a(`assets.ipInvalid`,null,`IP 地址格式无效`)))}}]}),(0,X.jsx)(g.Input,{field:`domain`,label:a(`assets.domain`,null,`域名`),rules:[{validator:(e,t,n)=>{!t||xe(t)&&!B(t)&&!P(t)?n():n(Error(a(`assets.domainInvalid`,null,`域名格式无效`)))}}]}),(0,X.jsx)(g.InputNumber,{field:`port`,label:a(`assets.port`,null,`端口`),min:0,max:65535,style:{width:`100%`}}),(0,X.jsx)(g.Input,{field:`protocol`,label:a(`assets.protocol`,null,`协议`),rules:[{validator:(e,t,n)=>{!t||/^[a-z][a-z0-9+.-]{0,31}$/.test(String(t).toLowerCase())?n():n(Error(a(`assets.protocolInvalid`,null,`协议格式无效`)))}}]}),(0,X.jsx)(g.Input,{field:`title`,label:a(`assets.pageTitle`,null,`页面标题`)}),(0,X.jsx)(g.Input,{field:`server`,label:a(`assets.serverProduct`,null,`服务 / 产品`)}),(0,X.jsx)(g.Select,{field:`project_id`,label:a(`assets.project`,null,`所属项目`),optionList:v,filter:!0,showClear:!0,placeholder:a(`assets.unboundProject`,null,`暂不绑定`)}),(0,X.jsx)(g.Select,{field:`status`,label:a(`assets.status`,null,`状态`),optionList:H}),(0,X.jsx)(g.Select,{field:`environment`,label:a(`assets.environment`,null,`环境`),optionList:De,showClear:!0,placeholder:`—`}),(0,X.jsx)(g.Select,{field:`criticality`,label:a(`assets.criticality`,null,`重要性`),optionList:N,showClear:!0,placeholder:`—`}),(0,X.jsx)(g.Input,{field:`country`,label:a(`assets.country`,null,`国家/地区`)}),(0,X.jsx)(g.Input,{field:`province`,label:a(`assets.province`,null,`省份/州`)}),(0,X.jsx)(g.Input,{field:`city`,label:a(`assets.city`,null,`城市`)}),(0,X.jsx)(g.Input,{field:`responsible_person`,label:a(`assets.responsiblePerson`,null,`负责人`)}),(0,X.jsx)(g.Input,{field:`department`,label:a(`assets.department`,null,`部门`)}),(0,X.jsx)(g.Input,{field:`business_system`,label:a(`assets.businessSystem`,null,`业务系统`)})]}),(0,X.jsx)(g.TagInput,{field:`tags`,label:a(`assets.tagsLabel`,null,`标签`),placeholder:a(`assets.tagsPlaceholder`,null,`输入后按回车或逗号`),max:30,maxLength:64,addOnBlur:!0,separator:`,,`,style:{width:`100%`}}),(0,X.jsx)(l,{className:`asset-library-editor-actions`,children:(0,X.jsx)(d,{theme:`borderless`,onClick:()=>y(!0),children:a(`assets.parseTarget`,null,`解析资产地址`)})})]},`${t?.id||`new-asset`}-${e?`open`:`closed`}`)]})}var Ie={host:500,title:500,domain:253,protocol:32,server:255,country:255,province:255,city:255,responsible_person:255,department:255,business_system:255};function Le(e){return String(e??``).replace(/^\uFEFF/,``).trim().toLowerCase().replace(/[\s_\-/.()()]+/g,``)}function Re(e){let t=Le(e);return t&&Ee.find(e=>(ve[e]||[]).some(e=>Le(e)===t))||``}function ze(e){let t=String(e??``).replace(/^\uFEFF/,``),n=[],r=[],i=``,a=!1;for(let e=0;e