Merge pull request #422 from Sycun/codex/restore-settings-model-picker

fix(settings): 恢复模型选择器,上下文窗口默认填入 1M
This commit is contained in:
公明 authored and GitHub committed 2026-11-23 17:36:52 +08:00
commit 16cf8f06a9
47 files changed
+220 -101

No files matched your search

+6 -3
View File
@@ -8,7 +8,7 @@ const (
// DefaultLocalContextWindow 是 local 档位下未提供 context_window 时的保守窗口。
DefaultLocalContextWindow = 32768
// DeepSeek's official /models response reports this total input and output window.
deepSeekFlashContextWindow = 1048576
deepSeekContextWindow = 1048576
// LocalContextBudgetPercent 是 local 档位把原生窗口折算成提示词预算的比例。
LocalContextBudgetPercent = 60
// LocalContextBudgetCap 防止 256K/1M 窗口把预算放大到超出本地模型有效上下文。
@@ -73,8 +73,11 @@ func (c OpenAIConfig) DefaultContextWindow() int {
if c.IsLocalContextProfile() {
return DefaultLocalContextWindow
}
if c.IsDeepSeekOfficialEndpoint() && strings.EqualFold(strings.TrimSpace(c.Model), "deepseek-flash") {
return deepSeekFlashContextWindow
if c.IsDeepSeekOfficialEndpoint() {
switch strings.ToLower(strings.TrimSpace(c.Model)) {
case "deepseek-flash", "deepseek-v4-pro":
return deepSeekContextWindow
}
}
return 0
}
+19 -4
View File
@@ -1656,6 +1656,7 @@ func (h *ConfigHandler) testTypeSafe(c *gin.Context, req TestTypeSafeRequest) {
// ListModelsRequest 获取模型列表请求(OpenAI 兼容 GET /models)。
type ListModelsRequest struct {
ContextProfile string `json:"context_profile,omitempty"`
CredentialScope string `json:"credential_scope,omitempty"`
ChannelID string `json:"channel_id,omitempty"`
Provider string `json:"provider"`
@@ -1728,11 +1729,25 @@ func (h *ConfigHandler) ListModels(c *gin.Context) {
return
}
// Use the same defaults as the saved-channel view for unsaved model selections.
type modelDefaults struct {
ContextWindow int `json:"context_window,omitempty"`
ImageInput *bool `json:"image_input,omitempty"`
}
defaults := make(map[string]modelDefaults)
for _, id := range models {
model := config.OpenAIConfig{BaseURL: baseURL, Provider: provider, Model: id, ContextProfile: req.ContextProfile}
entry := modelDefaults{ContextWindow: model.DefaultContextWindow(), ImageInput: model.ImageInputCapability()}
if entry.ContextWindow > 0 || entry.ImageInput != nil {
defaults[id] = entry
}
}
c.JSON(http.StatusOK, gin.H{
"success": true,
"supported": true,
"models": models,
"count": len(models),
"success": true,
"supported": true,
"models": models,
"model_defaults": defaults,
"count": len(models),
})
}
+2 -1
View File
@@ -18,6 +18,7 @@ import (
func TestGetConfigReportsContextWindowDefaultsSeparately(t *testing.T) {
cfg := &config.Config{AI: config.AIConfig{Channels: map[string]config.AIChannelConfig{
"flash": {BaseURL: "https://api.deepseek.com", Model: "deepseek-flash"},
"pro": {BaseURL: "https://api.deepseek.com", Model: "deepseek-v4-pro"},
"local": {ContextProfile: "local", ContextWindow: 65536},
"gateway": {BaseURL: "https://example.test", Model: "deepseek-flash"},
}}}
@@ -33,7 +34,7 @@ func TestGetConfigReportsContextWindowDefaultsSeparately(t *testing.T) {
if err := json.Unmarshal(res.Body.Bytes(), &result); err != nil {
t.Fatal(err)
}
if defaults := result.ContextWindowDefaults; defaults["flash"] != 1048576 || defaults["local"] != 32768 || len(defaults) != 2 {
if defaults := result.ContextWindowDefaults; defaults["flash"] != 1048576 || defaults["pro"] != 1048576 || defaults["local"] != 32768 || len(defaults) != 3 {
t.Fatalf("unexpected context window defaults: %v", defaults)
}
if result.AI.Channels["flash"].ContextWindow != 0 || result.AI.Channels["local"].ContextWindow != 65536 {
+11 -4
View File
@@ -5123,9 +5123,10 @@ func (h *OpenAPIHandler) GetOpenAPISpec(c *gin.Context) {
"type": "object",
"required": []string{"api_key"},
"properties": map[string]interface{}{
"provider": map[string]interface{}{"type": "string", "description": "LLM提供商(openai/claude)", "example": "openai"},
"base_url": map[string]interface{}{"type": "string", "description": "API基地址(可选)"},
"api_key": map[string]interface{}{"type": "string", "description": "API密钥"},
"provider": map[string]interface{}{"type": "string", "description": "LLM提供商(openai/claude)", "example": "openai"},
"context_profile": map[string]interface{}{"type": "string", "description": "用于预览模型默认窗口的上下文配置"},
"base_url": map[string]interface{}{"type": "string", "description": "API基地址(可选)"},
"api_key": map[string]interface{}{"type": "string", "description": "API密钥"},
},
},
},
@@ -5143,7 +5144,13 @@ func (h *OpenAPIHandler) GetOpenAPISpec(c *gin.Context) {
"supported": map[string]interface{}{"type": "boolean"},
"error": map[string]interface{}{"type": "string"},
"models": map[string]interface{}{"type": "array", "items": map[string]interface{}{"type": "string"}},
"count": map[string]interface{}{"type": "integer"},
"model_defaults": map[string]interface{}{"type": "object", "additionalProperties": map[string]interface{}{
"type": "object", "properties": map[string]interface{}{
"context_window": map[string]interface{}{"type": "integer"},
"image_input": map[string]interface{}{"type": "boolean"},
},
}},
"count": map[string]interface{}{"type": "integer"},
},
},
},
+1 -8
View File
@@ -68,14 +68,7 @@
.settings-channel-panel .semi-card-header-wrapper { align-items: center; gap: 8px; }
.settings-channel-notices { display: grid; gap: 8px; margin-top: 14px; }
.settings-probe-result { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.settings-model-tags {
display: flex;
flex-wrap: wrap;
gap: 6px;
max-height: 190px;
overflow: auto;
padding: 2px;
}
.settings-model-picker { width: min(280px, 60vw); }
.settings-audit-model {
margin-top: 18px;
border-top: 1px solid var(--semi-color-border);
@@ -13,6 +13,7 @@ const { Text } = Typography;
const MAIN_CHANNEL = '__main__';
const NO_CHANNELS = {};
const DEFAULT_FORM_CONTEXT_WINDOW = 1048576;
const PROVIDERS = [
{ value: 'openai_compatible', key: 'settingsProbe.compatible', fallback: '兼容 OpenAI 的接口' },
{ value: 'claude', key: 'settingsBasic.providerClaude', fallback: 'Claude(Anthropic Messages)' }
@@ -101,8 +102,9 @@ function summarizeContext(t, payload, fallbackWindow) {
];
}
function ProbeOutput({ state, defaultWindow }) {
function ProbeOutput({ state, defaultWindow, model, onModelChange, disabled }) {
const t = useT();
const pickerLabelId = useId();
const { key, payload, error } = state;
if (error) return <ErrorBanner error={error} />;
if (!payload) return null;
@@ -119,15 +121,25 @@ function ProbeOutput({ state, defaultWindow }) {
);
}
const models = Array.isArray(payload.models) ? payload.models : [];
const selectLabel = t('settingsBasic.modelsListSelectPlaceholder', null, '请选择模型');
return (
<div className="settings-probe-result">
<Space spacing={8}>
<Space wrap spacing={8}>
<Text>{t('settingsBasic.modelsListSuccess', { count: payload.count ?? models.length }, `已获取 ${payload.count ?? models.length} 个模型`)}</Text>
<span id={pickerLabelId} hidden>{selectLabel}</span>
{models.length > 0 && (
<Select
filter
aria-labelledby={pickerLabelId}
placeholder={selectLabel}
value={models.includes(model) ? model : undefined}
optionList={models.map(id => ({ value: id, label: id }))}
onChange={onModelChange}
disabled={disabled}
className="settings-model-picker"
/>
)}
</Space>
<div className="settings-model-tags">
{models.slice(0, 120).map(model => <Tag key={String(model)} size="small">{String(model)}</Tag>)}
{models.length > 120 && <Tag size="small" color="grey">…</Tag>}
</div>
</div>
);
}
@@ -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 }) {
<Text id={labelId} type="tertiary" size="small">{t(key, null, fallback)}</Text>
<Input
aria-labelledby={labelId}
value={String(showDefault ? defaultWindow : form[field])}
value={String(showDefault ? DEFAULT_FORM_CONTEXT_WINDOW : form[field])}
onChange={value => 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, '获取模型列表')}
</Button>
</Space>
<ProbeOutput state={state} defaultWindow={useDefaultWindow ? defaultWindow : 0} />
<ProbeOutput
state={state}
defaultWindow={useDefaultWindow ? defaultWindow : 0}
model={form.model}
onModelChange={value => update('model', value)}
disabled={locked}
/>
<Collapse className="settings-audit-model">
<Collapse.Panel itemKey="audit-model" header={(
+72 -8
View File
@@ -16,6 +16,71 @@ function modelConfig() {
test.describe('model channel editing', () => {
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 }) => {
@@ -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||Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,L as i,i as a,z as o}from"./semi-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||Line truncated
example.com:443
1.1.1.1:22`,helpText:`每行一个,或用空格、逗号隔开。直接粘贴 URL、域名或 IP:端口。`,rules:[{required:!0,validator:(e,t,n)=>{let r=m(t);if(!r.length)n(Error(k(`assets.targetRequired`,null,`请输入资产地址`)));else{for(let e of r)try{y(e)}catch(t){n(Error(`${e}:${t.message}`));return}n()}}}]}),(0,S.jsx)(a.Select,{field:`project_id`,label:k(`assets.project`,null,`所属项目`),optionList:z,disabled:T,filter:!0,showClear:!T,placeholder:k(`assets.unboundProject`,null,`暂不绑定`),style:{width:`100%`}})]})},`${t?.id||`new-asset`}-${e?`open`:`closed`}`)]})}export{T as t};
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,ot as c,st as l}from"./semi-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};
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};
@@ -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};
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};
@@ -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.projeLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,h as r,t as i,y as a}from"./react-QV7DAAIx.js";import{A as o,E as s,F as c,H as l,L as u,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-BMTtTYg1.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-BbwbZZn2.js";var K=e(t(),1),q=e(i(),1),Ae={q:``,protocol:``,source:``,tag:``,status:``,risk_level:``,environment:``,criticality:``,ip:``,domain:``,port:``,scan:``,sort:`last_seen_at:desc`};function je(){return{...Ae}}function Me({scope:e,filters:t,onChange:n,onReset:r,disabled:i}){let a=E(),s=(0,K.useId)(),[c,d]=(0,K.useState)(t.q||``);(0,K.useEffect)(()=>{d(t.q||``)},[t.q]);let f=[`status`,`risk_level`,`environment`,`criticality`,`ip`,`domain`,`port`,`scan`].filter(e=>t[e]).length;return(0,q.jsxs)(`div`,{className:`asset-library-filters`,children:[(0,q.jsxs)(`div`,{className:`asset-library-filter-row`,children:[(0,q.jsx)(`span`,{id:s,hidden:!0,children:a(`assets.scopeLabel`,null,`资产范围`)}),(0,q.jsx)(x,{"aria-labelledby":s,value:e.value,optionList:e.options,loading:e.loading,disabled:i,onChange:e.onChange,filter:!0}),(0,q.jsx)(l,{className:`asset-library-filter-search`,prefix:(0,q.jsx)(_,{}),value:c,disabled:i,placeholder:a(`assets.searchPlaceholder`,null,`搜索主机、IP、域名、标题、服务或标签`),onChange:e=>{d(e),n({q:e})},showClear:!0}),(0,q.jsx)(x,{value:t.protocol||void 0,placeholder:a(`assets.assetType`,null,`类型 / 协议`),optionList:ve,filter:!0,allowCreate:!0,showClear:!0,disabled:i,onChange:e=>n({protocol:e||``})}),(0,q.jsx)(l,{value:t.source,placeholder:a(`assets.source`,null,`来源`),disabled:i,onChange:e=>n({source:e}),showClear:!0}),(0,q.jsx)(l,{value:t.tag,placeholder:a(`assets.tagsLabel`,null,`标签`),disabled:i,onChange:e=>n({tag:e}),showClear:!0}),(0,q.jsx)(u,{onClick:r,disabled:i,children:a(`assets.resetFilters`,null,`重置`)})]}),(0,q.jsx)(o,{className:`asset-library-filter-advanced`,keepDOM:!1,children:(0,q.jsx)(o.Panel,{itemKey:`advanced`,header:`${a(`assets.advancedFilters`,null,`高级筛选`)}${f?`(${f})`:``}`,children:(0,q.jsxs)(`div`,{className:`asset-library-filter-grid`,children:[(0,q.jsx)(x,{value:t.status||void 0,placeholder:a(`assets.allStatuses`,null,`全部状态`),optionList:de,showClear:!0,disabled:i,onChange:e=>n({status:e||``})}),(0,q.jsx)(x,{value:t.risk_level||void 0,placeholder:a(`assets.allRisks`,null,`全部风险`),optionList:me,showClear:!0,disabled:i,onChange:e=>n({risk_level:e||``})}),(0,q.jsx)(x,{value:t.environment||void 0,placeholder:a(`assets.allEnvironments`,null,`全部环境`),optionList:P,showClear:!0,disabled:i,onChange:e=>n({environment:e||``})}),(0,q.jsx)(x,{value:t.criticality||void 0,placeholder:a(`assets.allCriticalities`,null,`全部级别`),optionList:we,showClear:!0,disabled:i,onChange:e=>n({criticality:e||``})}),(0,q.jsx)(l,{value:t.ip,placeholder:`IP`,disabled:i,onChange:e=>n({ip:e}),showClear:!0}),(0,q.jsx)(l,{value:t.domain,placeholder:a(`assets.domain`,null,`域名`),disabled:i,onChange:e=>n({domain:e}),showClear:!0}),(0,q.jsx)(l,{value:t.port,placeholder:a(`assets.port`,null,`端口`),disabled:i,onChange:e=>n({port:String(e||``).replace(/[^\d]/g,``)}),showClear:!0}),(0,q.jsx)(x,{value:t.scan||``,placeholder:a(`assets.scanState`,null,`扫描状态`),optionList:le,disabled:i,onChange:e=>n({scan:e||``})}),(0,q.jsx)(x,{value:t.sort||`last_seen_at:desc`,optionList:H,disabled:i,onChange:e=>n({sort:e||`last_seen_at:desc`})})]})})})]})}var{Text:J}=f;function Ne({assets:e,loading:t,total:n,page:r,pageSize:i,onPageChange:a,onPageSizeChange:o,selectedRowKeys:s,onSelectionChange:l,onView:d,onEdit:f,onDelete:p,onRefresh:m,canWrite:h,canDelete:g}){let _=E(),v=e=>{se({title:_(`assets.deleteConfirm`,null,`确定删除该资产吗?`),content:z(e),okText:_(`common.delete`,null,`删除`),onOk:()=>{Promise.resolve(p(e)).catch(e=>k(e,_(`assets.deleteFailed`,null,`删除资产失败`)))}})},y=[{title:_(`assets.target`,null,`目标`),dataIndex:`host`,width:260,render:(e,t)=>(0,q.jsxs)(`div`,{className:`asset-library-target`,children:[(0,q.jsx)(Ee,{text:z(t),max:38}),(0,q.jsx)(J,{type:`tertiary`,size:`small`,children:[t.ip,t.domain].filter(Boolean).join(` · `)||`—`})]})},{title:_(`assets.service`,null,`服务`),dataIndex:`protocol`,width:150,render:(e,t)=>(0,q.jsx)(De,{protocol:t.protocol,port:t.port})},{title:_(`assets.project`,null,`所属项目`),dataIndex:`project_name`,width:160,render:(e,t)=>(0,q.jsx)(Ee,{text:e||t.projeLine truncated
`?(r.push(i),n.push(r),r=[],i=``):o!==`\r`&&(i+=o)}return(i!==``||r.length)&&(r.push(i),n.push(r)),n.filter(e=>e.some(e=>String(e??``).trim()!==``))}function Le(e,t,n=``){let r=String(e??``).trim();if(!r)return n;let i=r.toLowerCase();if(t[i])return i;let a=Object.entries(t).find(([,e])=>e===r);return a?a[0]:null}function Re(e,t){let n=String(e??``).trim();if(!n)return{projectId:``,projectName:``,error:``};let r=n.toLowerCase(),i=(t||[]).find(e=>String(e.id).toLowerCase()===r||String(e.name||``).trim().toLowerCase()===r);return i?{projectId:i.id,projectName:i.name,error:``}:{projectId:``,projectName:``,error:`项目不存在或无权访问:${n}`}}function ze(e,t,{projects:n,projectId:r,source:i}){let a=n=>({rowNumber:t,values:e,asset:null,error:n}),o=e.target||e.host||e.domain||e.ip||``;if(!o)return a(`缺少目标地址`);let s;try{s=Te(o)}catch(e){return a(e.message)}let c=String(e.port??``).trim(),l=Number(c===``?s.port||0:c);if(!Number.isInteger(l)||l<0||l>65535)return a(`端口必须在 0–65535 之间`);let u=String(e.ip||s.ip||``).trim().toLowerCase();if(u&&!F(u)&&!_e(u))return a(`IP 地址格式无效`);let d=String(e.domain||s.domain||``).trim(),f=d?R(d):``;if(d&&!f)return a(`域名格式无效`);let p=String(e.protocol||s.protocol||``).trim().toLowerCase();if(p&&!/^[a-z][a-z0-9+.-]{0,31}$/.test(p))return a(`协议格式无效`);let m=Le(e.status,he,`active`);if(!m)return a(`状态仅支持 active 或 inactive`);let h=Le(e.environment,Se,``);if(h===null)return a(`环境值无效`);let g=Le(e.criticality,be,``);if(g===null)return a(`重要性值无效`);let _=Re(e.project||r,n);if(_.error)return a(_.error);if(r!==void 0&&_.projectId!==r)return a(`该行的项目与当前资产范围不一致`);let v=L(e.tags);if(v.length>30)return a(`标签最多 30 个`);if(v.some(e=>Array.from(e).length>64))return a(`单个标签最多 64 个字符`);let y={host:String(e.host||s.host||``).trim(),ip:u,domain:f,port:l,protocol:p,title:String(e.title||``).trim(),server:String(e.server||``).trim(),country:String(e.country||``).trim(),province:String(e.province||``).trim(),city:String(e.city||``).trim(),responsible_person:String(e.responsible_person||``).trim(),department:String(e.department||``).trim(),business_system:String(e.business_system||``).trim(),environment:h,criticality:g,status:m,tags:v,project_id:_.projectId,source:i||`manual-import`},b=Object.keys(Fe).find(e=>Array.from(String(y[e]||``)).length>Fe[e]);if(b)return a(`字段 ${b} 内容过长`);let x=ye(y);return x?a(x):{rowNumber:t,values:e,asset:y,projectName:_.projectName,error:``}}function Be(e){let t=new Map;return e.map(e=>{if(e.error||!e.asset)return e;let n=B(e.asset);return t.has(n)?{...e,error:`与第 ${t.get(n)} 行重复`}:(t.set(n,e.rowNumber),e)})}function Ve(e,t={}){let n=Z(e);if(n.length<2)throw Error(`文件中没有可导入的数据`);let r=n[0].map(Ie);if(!r.some(Boolean))throw Error(`未识别到模板字段,请检查表头`);let i=n.slice(1);if(i.length>1e5)throw Error(`数据不能超过 ${U} 行`);return Be(i.map((e,n)=>{let i={};return r.forEach((t,n)=>{t&&i[t]==null&&(i[t]=String(e[n]??``).trim())}),ze(i,n+2,t)}))}function He(e,t={}){let n;try{n=JSON.parse(String(e??``))}catch(e){throw Error(`JSON 解析失败:`+e.message)}let r=(Array.isArray(n)?n:Array.isArray(n?.assets)?n.assets:[n]).filter(e=>e&&typeof e==`object`);if(!r.length)throw Error(`文件中没有可导入的数据`);if(r.length>1e5)throw Error(`数据不能超过 ${U} 行`);return Be(r.map((e,n)=>ze({target:e.target||e.host||e.domain||e.ip||``,host:e.host,ip:e.ip,domain:e.domain,port:e.port,protocol:e.protocol,title:e.title,server:e.server,country:e.country,province:e.province,city:e.city,responsible_person:e.responsible_person,department:e.department,business_system:e.business_system,environment:e.environment,criticality:e.criticality,status:e.status,tags:Array.isArray(e.tags)?e.tags.join(`,`):e.tags,project:e.project_id||e.project||e.project_name},n+1,t)))}function Q(){return`${ge.join(`,`)}\r\n`}function Ue(e){let t=String(e??``);return/[",\r\n]/.test(t)?`"${t.replaceAll(`"`,`""`)}"`:t}function We(e,t){return t===`target`?z(e):t===`project`?e.project_name||e.project_id||``:t===`tags`?(e.tags||[]).join(`,`):t===`status`?fe(e.status):t===`environment`?I(e.environment):t===`criticality`?pe(e.criticality):t===`risk_level`?ce(e.risk_level):t===`vulnerability_count`?Number(e.vulnerability_count||0):e[t]??``}function Ge(e){let t=[xe.map(([,e])=>Ue(e)).join(`,`)];return(e||[]).forEach(e=>{t.push(xe.map(([t])=>Ue(We(e,t))).join(`,`))}),`\uFEFF${t.join(`\r
`)}`}function Ke(e,t,n=`text/csv;charset=utf-8`){let r=new Blob([t],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}var{Text:$}=f,qe=e=>[{title:e(`assets.rowNumber`,null,`行号`),dataIndex:`rowNumber`,width:70},{title:e(`assets.target`,null,`目标`),dataIndex:`target`,render:(e,t)=>z(t.asset||{target:t.values?.target})},{title:e(`assets.project`,null,`所属项目`),dataIndex:`project`,render:(e,t)=>t.projectName||t.values?.project||`—`},{title:e(`assets.status`,null,`状态`),dataIndex:`status`,render:(e,t)=>t.asset?.status||t.values?.status||`—`},{title:e(`assets.validationResult`,null,`校验结果`),dataIndex:`error`,render:t=>t?(0,q.jsx)($,{type:`danger`,size:`small`,children:t}):(0,q.jsx)($,{type:`success`,size:`small`,children:e(`assets.validationPassed`,null,`通过`)})}];function Je({visible:e,projects:t,defaultProjectId:n,onClose:r,onDone:i}){let a=E(),[o,s]=(0,K.useState)(`csv`),[l,f]=(0,K.useState)(``),[p,h]=(0,K.useState)(``),[_,v]=(0,K.useState)(``),[y,b]=(0,K.useState)(!1),x=(0,K.useRef)(null),C=(0,K.useMemo)(()=>{if(!String(l||``).trim())return{records:[],error:``};try{let e={projects:t,projectId:n,source:`manual-import`};return{records:o===`csv`?Ve(l,e):He(l,e),error:``}}catch(e){return{records:[],error:e.message}}},[l,o,t,n]),w=C.records,O=w.filter(e=>!e.error),te=w.length-O.length,k=_||C.error,j=()=>{f(``),h(``),s(`csv`),v(``),b(!1)},ne=()=>{y||(j(),r?.())},re=async e=>{if(!e)return;v(``);let t=String(e.name||``),n=t.split(`.`).pop().toLowerCase();if(![`csv`,`json`,`txt`].includes(n))v(`仅支持 .csv / .json / .txt 文件`);else if(e.size>104857600)v(a(`assets.fileTooLarge`,null,`文件不能超过 100 MB`));else try{let r=await e.text();s(n===`json`?`json`:`csv`),f(r),h(t)}catch(e){v(D(e,a(`assets.fileParseFailed`,null,`无法解析文件,请确认文件格式正确`)))}};return(0,q.jsxs)(A,{visible:e,title:a(`assets.bulkImportTitle`,null,`批量导入资产`),width:880,onCancel:ne,onOk:async()=>{if(!y&&O.length){v(``),b(!0);try{let e=await T.post(`/assets/import`,{assets:O.map(e=>e.asset),source:`manual-import`,source_query:p||`paste`}),t=Number(e?.skipped||0)+te;N(a(`assets.bulkImportDone`,{created:Number(e?.created||0),updated:Number(e?.updated||0),skipped:t},`导入完成:新增 ${Number(e?.created||0)} 条,更新 ${Number(e?.updated||0)} 条,跳过 ${t} 条`)),j(),i?.(),r?.()}catch(e){v(D(e,a(`assets.importFailed`,null,`资产入库失败`)))}finally{b(!1)}}},okText:a(`assets.importValidRowsCount`,{count:O.length},`导入 ${O.length} 条有效数据`),okButtonProps:{disabled:!O.length},confirmLoading:y,children:[(0,q.jsx)($,{type:`tertiary`,children:a(`assets.bulkImportSubtitle`,null,`支持 CSV / JSON 文本粘贴或文件上传,提交前会先校验并预览数据`)}),k&&(0,q.jsx)(S,{type:`danger`,bordered:!0,closeIcon:null,description:k,className:`asset-library-form-error`}),(0,q.jsxs)(c,{vertical:!0,align:`start`,spacing:10,className:`asset-library-import-body`,children:[(0,q.jsxs)(c,{children:[(0,q.jsx)(g,{type:`button`,value:o,options:[{value:`csv`,label:`CSV`},{value:`json`,label:`JSON`}],onChange:e=>{s(e.target.value),v(``)}}),(0,q.jsx)(u,{icon:(0,q.jsx)(d,{}),onClick:()=>x.current?.click(),children:a(`assets.chooseOrDropFile`,null,`选择文件`)}),(0,q.jsx)(`input`,{ref:x,type:`file`,accept:`.csv,.json,.txt`,className:`asset-library-file-input`,onChange:e=>{re(e.target.files?.[0]),e.target.value=``}}),(0,q.jsx)(u,{theme:`borderless`,onClick:()=>Ke(`asset-import-template.csv`,Q()),children:a(`assets.downloadCsv`,null,`下载 CSV 模板`)}),p&&(0,q.jsx)($,{type:`tertiary`,size:`small`,children:p})]}),(0,q.jsx)(ee,{value:l,rows:8,className:`asset-library-import-textarea`,placeholder:o===`csv`?`target,project,tags,host,ip,domain,port,protocol,title,server,country,province,city,responsible_person,department,business_system,environment,criticality,status`:`[{"host":"https://example.com","ip":"1.1.1.1","port":443,"protocol":"https","tags":["prod"]}]`,onChange:e=>{f(e),v(``)}}),w.length>0&&(0,q.jsxs)(`div`,{className:`asset-library-import-preview`,children:[(0,q.jsx)($,{strong:!0,children:a(`assets.importPreviewSummary`,{total:w.length,valid:O.length,invalid:te},`共 ${w.length} 行,${O.length} 行有效,${te} 行需修正`)}),(0,q.jsx)(m,{columns:qe(a),dataSource:w.slice(0,10).map((e,t)=>({...e,id:t})),rowKey:`id`,size:`small`,pagination:!1}),w.length>10&&(0,q.jsx)($,{type:`tertiary`,size:`small`,children:a(`assets.previewLimitedShort`,{count:w.length},`仅展示前 10 行;提交时将处理全部 ${w.length} 行`)})]})]})]})}var{Text:Ye}=f;function Xe({visible:e,assets:t,onClose:n,onDone:r}){let i=E(),a=(0,K.useMemo)(()=>Array.isArray(t)?t:[],[t]),[o,s]=(0,K.useState)(``),[l,u]=(0,K.useState)(``),[d,f]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{e&&(s(a[0]?.id||``),u(``),f(!1))},[e,a]),(0,q.jsxs)(A,{visible:e,title:i(`asset Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r}from"./react-QV7DAAIx.js";import{F as i,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:Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r}from"./react-QV7DAAIx.js";import{F as i,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:Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,f as ee,st as te,v as c}from"./semi-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 Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,f as ee,st as te,v as c}from"./semi-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 Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,L as i,M as a,W as o,i as s,lt as c,st as l}from"./semi-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()Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,L as i,M as a,W as o,i as s,lt as c,st as l}from"./semi-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()Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,v as c}from"./semi-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:Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,v as c}from"./semi-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:Line truncated
@@ -1,2 +1,2 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,L as i,M as a,W as o,i as s,lt as c,st as l}from"./semi-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||n<t){p(c(`c2.profiles.toastInvalidJitter`,null,`Jitter 必须为整数,且满足 0 <= 最小值 <= 最大值`));return}let r=N(e.request_headers,c);if(r===null)return;let i=N(e.response_headers,c);i!==null&&o({name:String(e.name||``).trim(),userAgent:String(e.user_agent||``).trim(),uris:String(e.uris||``).split(/\r?\n/).map(e=>e.trim()).filter(Boolean),jitterMinMs:t,jitterMaxMs:n,requestHeaders:r,responseHeaders:i,bodyTemplate:String(e.body_template||``)})},getFormApi:u,labelPosition:`top`,children:[(0,A.jsx)(s.Input,{field:`name`,label:c(`c2.profiles.profileNameLabel`,null,`Profile 名称`),placeholder:c(`c2.profiles.placeholderProfileName`,null,`例如 cdn-fronting`),rules:[{required:!0,message:c(`c2.profiles.toastNameRequired`,null,`请填写 Profile 名称`)}]}),(0,A.jsx)(s.Input,{field:`user_agent`,label:c(`c2.profiles.userAgent`,null,`User-Agent`),placeholder:`Mozilla/5.0 ...`}),(0,A.jsx)(s.TextArea,{field:`uris`,label:c(`c2.profiles.labelBeaconUris`,null,`Beacon URI(每行一个)`),placeholder:`/api/v1/ping`,autosize:{minRows:2,maxRows:5}}),(0,A.jsxs)(`div`,{className:`c2-form-row`,children:[(0,A.jsx)(s.Input,{field:`jitter_min`,label:c(`c2.profiles.labelJitterMin`,null,`Jitter 最小值 (ms)`),placeholder:`0`}),(0,A.jsx)(s.Input,{field:`jitter_max`,label:c(`c2.profiles.labelJitterMax`,null,`Jitter 最大值 (ms)`),placeholder:`0`})]}),(0,A.jsx)(s.TextArea,{field:`request_headers`,label:c(`c2.profiles.requestHeadersJson`,null,`自定义请求头 (JSON)`),placeholder:`{"X-Forwarded-For":"127.0.0.1"}`,autosize:{minRows:2,maxRows:6}}),(0,A.jsx)(s.TextArea,{field:`response_headers`,label:c(`c2.profiles.labelRespHeaders`,null,`自定义响应头 (JSON)`),placeholder:`{"Server":"nginx"}`,autosize:{minRows:2,maxRows:6}}),(0,A.jsx)(s.TextArea,{field:`body_template`,label:c(`c2.profiles.bodyTemplate`,null,`响应体模板`),placeholder:`{"status":"ok"}`,autosize:{minRows:2,maxRows:6}}),(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:c(`c2.profiles.hintHeaders`,null,`用于伪装为合法服务的 HTTP 响应头`)})]},t?.id||`new`)})}var{Text:F}=o;function I(){let e=f(),{hasPermission:t}=d(),n=t(`c2:write`),o=t(`c2:delete`)||n,[s,p]=(0,k.useState)({visible:!1,record:null}),[_,j]=(0,k.useState)(!1),[M,N]=(0,k.useState)(null),{data:I,loading:L,error:R,reload:z}=h(()=>E(),[]),B=Array.isArray(I?.profiles)?I.profiles:[],V=(0,k.useMemo)(()=>[{id:`total`,label:e(`c2.profiles.total`,null,`Profile 总数`),value:B.length},{id:`jitter`,label:e(`c2.profiles.withJitter`,null,`启用 Jitter`),value:B.filter(e=>Number(e.jitterMaxMs)>0).length},{id:`uris`,label:e(`c2.profiles.withUris`,null,`自定义 URI`),value:B.filter(e=>Array.isArray(e.uris)&&e.uris.length>0).length},{id:`headers`,label:e(`c2.profiles.withHeaders`,null,`自定义响应头`),value:B.filter(e=>e.responseHeaders&&Object.keys(e.responseHeaders).length>0).length}],[B,e]),H=async t=>{j(!0);try{s.record?.id?(await D(s.record.id,t),C(e(`c2.profiles.toastUpdated`,null,`Profile 已更新`))):(await T(t),C(e(`c2.profiles.toastCreated`,null,`Profile 已创建`))),p({visible:!1,record:null}),z()}catch(t){g(t,e(`c2.profiles.saveFailed`,null,`Profile 保存失败`))}finally{j(!1)}},U=t=>{w({title:e(`c2.profiles.delete`,null,`删除 Profile`),content:e(`c2.profiles.confirmDelete`,null,`确定删除此 Profile?`),onOk:async()=>{try{await O(t.id),C(e(`c2.profiles.toastDeleted`,null,`Profile 已删除`)),z()}catch(e){g(e)}}})},W=[{title:e(`c2.profiles.name`,null,`名称`),dataIndex:`name`,render:(e,t)=>(0,A.jsx)(`button`,{type:`button`,className:`c2-profile-name`,onClick:()=>N(t),children:e||t.id})},{title:e(`c2.profiles.userAgent`,null,`User-Agent`),dataIndex:`userAgent`,render:e=>(0,A.jsx)(`span`,{className:`c2-mono c2-profile-ua`,title:e,childr Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,N as c,T as l,U as u,W as d,at as f,c as p,ot as m,st as h,v as g,x as _}from"./semi-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)retLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,N as c,T as l,U as u,W as d,at as f,c as p,ot as m,st as h,v as g,x as _}from"./semi-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)retLine truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{F as t,L as n,W as r}from"./semi-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};
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};
@@ -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};
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};
@@ -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,`任 Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,W as c,i as l,lt as u,st as d,v as f}from"./semi-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,`任 Line truncated
@@ -1,4 +1,4 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{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?.defaultReviLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{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?.defaultReviLine truncated
`),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}:${Line truncated
`)}`: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(`
@@ -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`);aLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,J as a,L as o,M as s,U as c,W as l,f as u,lt as d,ot as f,st as p,v as m}from"./semi-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`);aLine truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,u as i,y as a}from"./react-QV7DAAIx.js";import{Bt as o,F as s,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- Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,u as i,y as a}from"./react-QV7DAAIx.js";import{Bt as o,F as s,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- Line truncated
@@ -1,4 +1,4 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{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),本次工具调用 Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{B as i,F as a,H as o,L as s,M as c,T as l,U as u,W as d,_ as f,c as p,f as m,m as h,ot as g,p as _,st as v,v as y,x as b,z as x}from"./semi-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),本次工具调用 Line truncated
`))},[r]);let m=(0,R.useMemo)(()=>ce(u),[u]),h=(0,R.useMemo)(()=>(r?.toolWhitelist||[]).join(`
`),[r]),g=u.trim()!==h.trim(),_=(0,R.useCallback)(async()=>{p(`put`);try{let e=await w.put(`/hitl/tool-whitelist`,{toolWhitelist:m});I(n(`hitl.whitelistSaved`,null,`白名单已保存`)),d((e?.toolWhitelist||m).join(`
`)),l({silent:!0})}catch(e){O(e,n(`hitl.whitelistSaveFailed`,null,`保存白名单失败`))}finally{p(``)}},[l,n,m]),y=(0,R.useCallback)(async()=>{p(`post`);try{let e=await w.post(`/hitl/tool-whitelist`,{sensitiveTools:m});I(e?.hitlGlobalWhitelistMerged?`已合并到全局白名单`:`没有新增工具,白名单未变化`),d((e?.hitlGlobalToolWhitelist||m).join(`
@@ -1,4 +1,4 @@
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dashboard-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(Line truncated
`))>=0;){let e=l.slice(0,r).replace(/\r$/,``);if(l=l.slice(r+1),!e.startsWith(`data:`))continue;let t=e.slice(5).trim();if(!t)continue;if(t===`[DONE]`){u=!0;break}let i;try{i=JSON.parse(t)}catch{continue}n?.(i)}}i?.()}catch(e){if(e.name===`AbortError`){i?.();return}r?.(e)}})(),()=>o.abort()}function $e(e,t=`操作失败`){return e?typeof e==`string`?e:e.message||t:t}var M=e(Be(),1),et=(0,k.createContext)(null);function tt(e,t){return e?{token:t||e.token,expiresAt:e.expires_at||e.expiresAt||``,appVersion:typeof e.app_version==`string`?e.app_version.trim():``,user:e.user||null,roles:Array.isArray(e.roles)?e.roles:[],permissions:Array.isArray(e.permissions)?e.permissions:[],scope:e.scope||``}:null}function nt({children:e}){let t=(0,k.useRef)(We()).current,[n,r]=(0,k.useState)(t),[i,a]=(0,k.useState)(!!t);(0,k.useEffect)(()=>{if(qe(t?.token||null),!t?.token){a(!1);return}let e=!1;return j.get(`/auth/validate`).then(n=>{if(e)return;let i=tt(n,t.token);r(i),Ge(i)}).catch(()=>{e||(r(null),Ge(null),qe(null))}).finally(()=>{e||a(!1)}),()=>{e=!0}},[]);let o=(0,k.useCallback)(()=>{r(null),qe(null),Ge(null)},[]);(0,k.useEffect)(()=>{let e=()=>o();return window.addEventListener(`csai:unauthorized`,e),()=>window.removeEventListener(`csai:unauthorized`,e)},[o]);let s=(0,k.useCallback)(async(e,t)=>{let n=await j.post(`/auth/login`,{username:String(e||``).trim(),password:t}),i=tt(n,n?.token);return qe(i?.token||null),Ge(i),r(i),i},[]),c=(0,k.useCallback)(async()=>{try{await j.post(`/auth/logout`,{})}catch{}o()},[o]),l=(0,k.useMemo)(()=>new Set(n?.permissions||[]),[n]),u=(0,k.useCallback)(e=>!e||String(e).split(/\s+/).some(e=>l.has(e)),[l]),d=(0,k.useCallback)(e=>{let t=Array.isArray(e)?e:String(e||``).split(/\s+/).filter(Boolean);return!t.length||t.some(e=>l.has(e))},[l]),f=(0,k.useCallback)(async()=>{if(!n?.token)return null;let e=tt(await j.get(`/auth/validate`),n.token);return r(e),Ge(e),e},[n?.token]),p=(0,k.useMemo)(()=>({session:n,user:n?.user||null,roles:n?.roles||[],permissions:l,hasPermission:u,hasAnyPermission:d,checking:i,authenticated:!!n?.token,login:s,logout:c,refresh:f}),[n,l,u,d,i,s,c,f]);return(0,M.jsx)(et.Provider,{value:p,children:e})}function N(){let e=(0,k.useContext)(et);if(!e)throw Error(`useAuth 必须在 AuthProvider 内使用`);return e}var rt=[{id:`zh-CN`,label:`简体中文`},{id:`en-US`,label:`English`},{id:`ru-RU`,label:`Русский`},{id:`ar-SA`,label:`العربية`}],it=`csai_lang`,at=`zh-CN`,ot=`/static/i18n`,st=new Map;function ct(){try{let e=localStorage.getItem(it);if(e&&rt.some(t=>t.id===e))return e}catch{}let e=String(navigator.language||``).toLowerCase();return e.startsWith(`zh`)?`zh-CN`:e.startsWith(`ru`)?`ru-RU`:e.startsWith(`ar`)?`ar-SA`:e.startsWith(`en`)?`en-US`:at}function lt(e){return st.has(e)||st.set(e,fetch(`${ot}/${e}.json`,{cache:`no-cache`}).then(e=>e.ok?e.json():{}).catch(()=>({}))),st.get(e)}function ut(e,t){if(!e)return;let n=e;for(let e of String(t).split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return typeof n==`string`?n:void 0}function dt(e,t){return t?e.replace(/\{\{\s*(\w+)\s*\}\}/g,(e,n)=>t[n]===void 0?e:String(t[n])):e}var ft=(0,k.createContext)({lang:at,t:e=>e,ready:!1,setLanguage:()=>{}});function pt({children:e}){let[t,n]=(0,k.useState)(ct),[r,i]=(0,k.useState)({}),[a,o]=(0,k.useState)(!1);(0,k.useEffect)(()=>{let e=!1;Promise.all([lt(t),lt(at),lt(`en-US`)]).then(([t,n,r])=>{e||(i({current:t,fallback:n,english:r}),o(!0))}),document.documentElement.lang=t,document.documentElement.dir=t===`ar-SA`?`rtl`:`ltr`;try{localStorage.setItem(it,t)}catch{}return()=>{e=!0}},[t]);let s=(0,k.useCallback)((e,t,n)=>{if(!e)return n??``;let i=ut(r.current,e)??ut(r.fallback,e)??ut(r.english,e);return i===void 0?n??e:dt(i,t)},[r]),c=(0,k.useCallback)(e=>{e&&e!==t&&(o(!1),n(e),window.dispatchEvent(new CustomEvent(`csai:languagechange`,{detail:{lang:e}})))},[t]),l=(0,k.useMemo)(()=>({lang:t,t:s,ready:a,setLanguage:c}),[t,s,a,c]);return(0,M.jsx)(ft.Provider,{value:l,children:e})}function mt(){return(0,k.useContext)(ft)}function P(){return(0,k.useContext)(ft).t}var ht=`cyberstrike-theme`,gt=[`system`,`light`,`dark`];function _t(){try{let e=localStorage.getItem(ht);return gt.includes(e)?e:`system`}catch{return`system`}}function vt(){return typeof window<`u`&&window.matchMedia?window.matchMedia(`(prefers-color-scheme: dark)`).matches:!1}function yt(e){return e===`dark`||e===`light`?e:vt()?`dark`:`light`}function bt(e){let t=yt(e),n=document.documentElement;return n.setAttribute(`data-theme`,t),n.setAttribute(`data-theme-preference`,e),n.style.colorScheme=t,document.body?.setAttribute(`theme-mode`,t===`dark`?`dark`:`light`),t}var xt=(0,k.createContext)({preference:`system`,theme:`light`,setPreference:()=>{},toggle:()=>{}});function St({children:e}){let[t,n]=(0,k.useState)(_t),[r,i]=(0,k.useState)(()=>yt(_t()));(0,k.useLayoutEffect)(()=>{i(bt(t));try{localStorage.setItem(ht,t)}catch{}if(t!==`system`||!window.matchMedia)return;let e=window.matchMedia(`(prefers-color-scheme: darLine truncated
]`).replace(`lheading`,Ut).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},nn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,rn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,an=/^( {2,}|\\)\n(?!\s*$)/,on=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,sn=/[\p{P}\p{S}]/u,cn=/[\s\p{P}\p{S}]/u,ln=/[^\s\p{P}\p{S}]/u,un=L(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,cn).getRegex(),dn=/(?!~)[\p{P}\p{S}]/u,fn=/(?!~)[\s\p{P}\p{S}]/u,pn=/(?:[^\s\p{P}\p{S}]|~)/u,mn=L(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Ft?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),hn=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,gn=L(hn,`u`).replace(/punct/g,sn).getRegex(),_n=L(hn,`u`).replace(/punct/g,dn).getRegex(),vn=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,yn=L(vn,`gu`).replace(/notPunctSpace/g,ln).replace(/punctSpace/g,cn).replace(/punct/g,sn).getRegex(),bn=L(vn,`gu`).replace(/notPunctSpace/g,pn).replace(/punctSpace/g,fn).replace(/punct/g,dn).getRegex(),xn=L(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,ln).replace(/punctSpace/g,cn).replace(/punct/g,sn).getRegex(),Sn=L(/\\(punct)/,`gu`).replace(/punct/g,sn).getRegex(),Cn=L(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),wn=L(Yt).replace(`(?:-->|$)`,`-->`).getRegex(),Tn=L(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,wn).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),En=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Dn=L(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,En).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),On=L(/^!?\[(label)\]\[(ref)\]/).replace(`label`,En).replace(`ref`,Kt).getRegex(),kn=L(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Kt).getRegex(),An=L(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,On).replace(`nolink`,kn).getRegex(),jn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Mn={_backpedal:Pt,anyPunctuation:Sn,autolink:Cn,blockSkip:mn,br:an,code:rn,del:Pt,emStrongLDelim:gn,emStrongRDelimAst:yn,emStrongRDelimUnd:xn,escape:nn,link:Dn,nolink:kn,punctuation:un,reflink:On,reflinkSearch:An,tag:Tn,text:on,url:Pt},Nn={...Mn,link:L(/^!?\[(label)\]\((.*?)\)/).replace(`label`,En).getRegex(),reflink:L(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,En).getRegex()},Pn={...Mn,emStrongRDelimAst:bn,emStrongLDelim:_n,url:L(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,jn).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:L(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,jn).getRegex()},Fn={...Pn,br:L(an).replace(`{2,}`,`*`).getRegex(),text:L(Pn.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},In={normal:Qt,gfm:en,pedantic:tn},Ln={normal:Mn,gfm:Pn,breaks:Fn,pedantic:Nn},Rn={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},zn=e=>Rn[e];function V(e,t){if(t){if(R.escapeTest.test(e))return e.replace(R.escapeReplace,zn)}else if(R.escapeTestNoEncode.test(e))return e.replace(R.escapeReplaceNoEncode,zn);return e}function Bn(e){try{e=encodeURI(e).replace(R.percentDecode,`%`)}catch{return null}return e}function Vn(e,t){let n=e.replace(R.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(R.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(R.slashPipe,`|`);return n}functionLine truncated
@@ -61,4 +61,4 @@ ${e}</tr>
`+this.renderer.text(i);n+=t?this.renderer.paragraph({type:`paragraph`,raw:o,text:o,tokens:[{type:`text`,raw:o,text:o,escaped:!0}]}):o;continue}default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}parseInline(e,t=this.renderer){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Yn=(At=class{constructor(e){I(this,`options`,void 0),I(this,`block`,void 0),this.options=e||Mt}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?H.lex:H.lexInline}provideParser(){return this.block?U.parse:U.parseInline}},I(At,`passThroughHooks`,new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`])),I(At,`passThroughHooksRespectAsync`,new Set([`preprocess`,`postprocess`,`processAllTokens`])),At),Xn=new class{constructor(...e){I(this,`defaults`,jt()),I(this,`options`,this.setOptions),I(this,`parse`,this.parseMarkdown(!0)),I(this,`parseInline`,this.parseMarkdown(!1)),I(this,`Parser`,U),I(this,`Renderer`,qn),I(this,`TextRenderer`,Jn),I(this,`Lexer`,H),I(this,`Tokenizer`,Kn),I(this,`Hooks`,Yn),this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new qn(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Kn(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Yn;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=Yn.passThroughHooks.has(n)?e=>{if(this.defaults.async&&Yn.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return H.lex(e,t??this.defaults)}parser(e,t){return U.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.as Line truncated
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+V(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function W(e,t){return Xn.parse(e,t)}W.options=W.setOptions=function(e){return Xn.setOptions(e),W.defaults=Xn.defaults,Nt(W.defaults),W},W.getDefaults=jt,W.defaults=Mt,W.use=function(...e){return Xn.use(...e),W.defaults=Xn.defaults,Nt(W.defaults),W},W.walkTokens=function(e,t){return Xn.walkTokens(e,t)},W.parseInline=Xn.parseInline,W.Parser=U,W.parser=U.parse,W.Renderer=qn,W.TextRenderer=Jn,W.Lexer=H,W.lexer=H.lex,W.Tokenizer=Kn,W.Hooks=Yn,W.parse=W,W.options,W.setOptions,W.use,W.walkTokens,W.parseInline,U.parse,H.lex;function Zn(e,t){this.v=e,this.k=t}function Qn(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function $n(e){if(Array.isArray(e))return e}function er(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function tr(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nr(e,t){return $n(e)||er(e,t)||rr(e,t)||tr()}function rr(e,t){if(e){if(typeof e==`string`)return Qn(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Qn(e,t):void 0}}function ir(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof Zn;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}ir.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},ir.prototype.next=function(e){return this._invoke(`next`,e)},ir.prototype.throw=function(e){return this._invoke(`throw`,e)},ir.prototype.return=function(e){return this._invoke(`return`,e)};var ar=Object.entries,or=Object.keys,sr=Object.setPrototypeOf,cr=Object.isFrozen,lr=Object.getPrototypeOf,ur=Object.getOwnPropertyDescriptor,G=Object.freeze,K=Object.seal,dr=Object.create,fr=typeof Reflect<`u`&&Reflect,pr=fr.apply,mr=fr.construct;G||(G=function(e){return e}),K||(K=function(e){return e}),pr||(pr=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)}),mr||(mr=function(e){return new e(...[...arguments].slice(1))});var hr=Y(Array.prototype.forEach),gr=Y(Array.prototype.lastIndexOf),_r=Y(Array.prototype.pop),vr=Y(Array.prototype.push),yr=Y(Array.prototype.slice),br=Y(Array.prototype.splice),xr=Array.isArray,Sr=Rr(Set),Cr=Y(Set.prototype.add),wr=Y(Set.prototype.has),Tr=Y(String.prototype.toLowerCase),Er=Y(String.prototype.toString),Dr=Y(String.prototype.match),Or=Y(String.prototype.replace),kr=Y(String.prototype.indexOf),Ar=Y(String.prototype.trim),jr=Y(Number.prototype.toString),Mr=Y(Boolean.prototype.toString),Nr=typeof BigInt>`u`?null:Y(BigInt.prototype.toString),Pr=typeof Symbol>`u`?null:Y(Symbol.prototype.toString),q=Y(Object.prototype.hasOwnProperty),Fr=Y(Object.prototype.toString),Ir=RegExp.prototype.test,J=function(e,t){return e instanceof RegExp&&(e.lastIndex=0),pr(Ir,e,[t])},Lr=Rr(TypeError);function Y(e){return function(t){var n=[...arguments].slice(1);return pr(e,t,n)}}function Rr(e){return function(){return mr(e,[...arguments])}}function X(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Tr;if(sr&&sr(e,null),!xr(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(cr(t)||(t[r]=e),i=e)}e[i]=!0}return e}function zr(e){for(let t=0;t<e.length;t++)q(e,t)||(e[t]=null);return e}function Br(e){let t=dr(null);for(let r of ar(e)){var n=nr(r,2);let i=n[0],a=n[1];q(e,i)&&(t[i]=xr(a)?zr(a):a&&typeof a==`object`&&a.constructor===Object?Br(a):a)}return t}function Vr(e){let t=dr(null),n=or(e),r=n.length;for(;r--;)t[n[r]]=e[n[r]];return t}function Hr(e){switch(typeof e){case`string`:return e;case`number`:return jr(e);case`boolean`:return Mr(e);case`bigint`:return Nr?Nr(e):`0`;case`symbol`:return Pr?Pr(e):`Symbol()`;case`undefined`:return Fr(e);case`function`:case`object`:{if(e===null)return Fr(e);let t=e,n=Z(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Fr(e)}return Fr(e)}default:return Fr(e)}}function Z(e,t){for(;e!==null;){let n=ur(e,t);if(n){if(n.get)return Y(n.get);if(typeof n.value==`function`)return Y(n.value)}e=lr(e)}function n(){return null}return n}function Ur(e,t){for(;e!==null;){let n=ur(e,t);if(n)return n.get?Y(n.get):null;e=lr(e)}return null}function Wr(e){if(!e)return!1;try{return J(e,``),!0}catch{return!1}}var Gr=G(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Kr=G(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.filter.font.g.glyph.glyphref.hkern.image.line.lineargradient.marker.mask.metadata.mpath.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),qr=G([`feBlend`,`feColorMatrix`,`feComponentTransferLine truncated
`+p),de(p)},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};vt(e),ze=!0,Be=T,Ve=E},t.clearConfig=function(){ht=null,ze=!1,Be=null,Ve=null,S=oe,ae=``},t.isValidAttribute=function(e,t,n){ht||vt({});let r=P(e),i=P(t);return typeof n==`string`&&(tn(t,n)||!Ie&&J(gi,n))?!1:Xt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&q(w,e)&&vr(w[e],t)},t.removeHook=function(e,t){if(q(w,e)){if(t!==void 0){let n=gr(w[e],t);return n===-1?void 0:br(w[e],n,1)[0]}return _r(w[e])}},t.removeHooks=function(e){q(w,e)&&(w[e]=[])},t.removeAllHooks=function(){w=Si()},t}var Ei=Ti(),Di=[`critical`,`high`,`medium`,`low`,`info`],Oi={critical:`red`,high:`orange`,medium:`amber`,low:`blue`,info:`grey`},ki={critical:`严重`,high:`高危`,medium:`中危`,low:`低危`,info:`信息`},Ai={running:`blue`,pending:`amber`,queued:`amber`,paused:`grey`,success:`green`,succeeded:`green`,completed:`green`,done:`green`,failed:`red`,error:`red`,cancelled:`grey`,canceled:`grey`,stopped:`grey`,active:`green`,inactive:`grey`,online:`green`,offline:`grey`,open:`red`,closed:`green`,archived:`grey`};function ji(e,t=`zh-CN`){if(!e)return`—`;let n=e instanceof Date?e:new Date(e);return Number.isFinite(n.getTime())?n.toLocaleString(t,{hour12:!1}):`—`}function Mi(e,t=`zh-CN`){if(!e)return`—`;let n=e instanceof Date?e:new Date(e);return Number.isFinite(n.getTime())?n.toLocaleDateString(t):`—`}function Ni(e,t){if(!e)return`—`;let n=new Date(e);if(!Number.isFinite(n.getTime()))return`—`;let r=Date.now()-n.getTime();return r<6e4?t?.(`common.justNow`,null,`刚刚`)||`刚刚`:r<36e5?t?.(`common.minutesAgo`,{n:Math.floor(r/6e4)},`${Math.floor(r/6e4)} 分钟前`):r<864e5?t?.(`common.hoursAgo`,{n:Math.floor(r/36e5)},`${Math.floor(r/36e5)} 小时前`):r<2592e6?t?.(`common.daysAgo`,{n:Math.floor(r/864e5)},`${Math.floor(r/864e5)} 天前`):Mi(e)}function Pi(e){let t=Number(e);if(!Number.isFinite(t)||t<0)return`—`;if(t<1024)return`${t} B`;let n=[`KB`,`MB`,`GB`,`TB`],r=t/1024,i=0;for(;r>=1024&&i<n.length-1;)r/=1024,i+=1;return`${r.toFixed(r>=100?0:1)} ${n[i]}`}function Fi(e,t=`zh-CN`){let n=Number(e);return Number.isFinite(n)?n.toLocaleString(t):`—`}function Ii(e,t=1){let n=Number(e);return Number.isFinite(n)?`${(n*(n<=1?100:1)).toFixed(t)}%`:`—`}function Li(e){return Oi[String(e||``).toLowerCase()]||`grey`}function Ri(e){return Ai[String(e||``).toLowerCase()]||`grey`}function zi(e,t=120){let n=String(e??``);return n.length>t?`${n.slice(0,t)}…`:n}var{Title:Bi,Text:Vi,Paragraph:Hi}=oe;function Ui(e){xe.success({content:e,duration:2})}function Wi(e){xe.warning({content:e,duration:3})}function Gi(e,t=`操作失败`){xe.error({content:$e(e,t),duration:4})}function Ki({title:e,description:t,extra:n,children:r}){return(0,M.jsxs)(`header`,{className:`cs-page-header`,children:[(0,M.jsxs)(`div`,{className:`cs-page-header-main`,children:[(0,M.jsx)(Bi,{heading:3,className:`cs-page-title`,children:e}),t&&(0,M.jsx)(Vi,{type:`tertiary`,className:`cs-page-desc`,children:t}),r]}),n&&(0,M.jsx)(s,{className:`cs-page-header-extra`,wrap:!0,children:n})]})}function qi({title:e,description:t,extra:n,children:r,className:i=``,bodyClassName:a=``}){return(0,M.jsxs)(y,{className:`cs-section-card ${i}`,title:e?(0,M.jsx)(`span`,{className:`cs-section-title`,children:e}):void 0,headerExtraContent:n,bordered:!1,children:[t&&(0,M.jsx)(Hi,{type:`tertiary`,className:`cs-section-desc`,children:t}),(0,M.jsx)(`div`,{className:a,children:r})]})}function Ji({metrics:e,columns:t=4}){return(0,M.jsx)(`div`,{className:`cs-stat-grid`,style:{"--cs-stat-columns":t},children:e.map(e=>(0,M.jsx)(Yi,{...e},e.id||e.label))})}function Yi({label:e,value:t,valueTitle:n,detail:r,tone:i,severity:a,icon:o,onClick:s,pressed:c,loading:l=!1}){let u=(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`span`,{className:`cs-stat-head`,children:[(0,M.jsx)(Vi,{type:`tertiary`,className:`cs-stat-label`,children:e}),o&&(0,M.jsx)(`span`,{className:`cs-stat-icon ${i?`tone-${i}`:``}`,"aria-hidden":`true`,children:o})]}),(0,M.jsx)(f,{loading:l,placeholder:(0,M.jsx)(f.Title,{style:{width:`60%`,height:36,margin:`8px 0`}}),children:(0,M.jsx)(`span`,{className:`cs-stat-value ${i?`tone-${i}`:``}`,title:n,children:t??`—`})}),r&&(0,M.jsx)(`span`,{className:`cs-stat-detail`,children:r})]});return s?(0,M.jsx)(h,{className:`cs-stat-card is-clickable`,theme:`borderless`,onClick:s,"aria-label":String(e),"aria-pressed":c,"data-severity":a,children:u}):(0,M.jsx)(y,{className:`cs-stat-card`,"data-severity":a,bordered:!1,children:u})}function Xi({columns:e,dataSource:t,rowKey:n=`id`,loading:r,pagination:i,emptyText:a,onRefresh:o,toolbar:s,size:c=`default`,className:l=``,...u}){let d=P(),f=i!==!1&&{pageSize:10,showSizeChanger:!0,pageSizeOpts:[10,20,50,100],showTotal:!0,...i||{}};return(0,M.jsxs)(`div`,{className:`cs-table-wrap ${l}`,children:[(s||o)&&(0,M.jsxs)(`div`,{className:`cs-table-toolbar`,children:[(0,M.jsx)(`div`,{className:`cs-table-toolbar-main`,children:s}),o&&(0,M.jsx)(h,{icon:(0,M.jsx)(Ee,{}) Line truncated
`+p),de(p)},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};vt(e),ze=!0,Be=T,Ve=E},t.clearConfig=function(){ht=null,ze=!1,Be=null,Ve=null,S=oe,ae=``},t.isValidAttribute=function(e,t,n){ht||vt({});let r=P(e),i=P(t);return typeof n==`string`&&(tn(t,n)||!Ie&&J(gi,n))?!1:Xt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&q(w,e)&&vr(w[e],t)},t.removeHook=function(e,t){if(q(w,e)){if(t!==void 0){let n=gr(w[e],t);return n===-1?void 0:br(w[e],n,1)[0]}return _r(w[e])}},t.removeHooks=function(e){q(w,e)&&(w[e]=[])},t.removeAllHooks=function(){w=Si()},t}var Ei=Ti(),Di=[`critical`,`high`,`medium`,`low`,`info`],Oi={critical:`red`,high:`orange`,medium:`amber`,low:`blue`,info:`grey`},ki={critical:`严重`,high:`高危`,medium:`中危`,low:`低危`,info:`信息`},Ai={running:`blue`,pending:`amber`,queued:`amber`,paused:`grey`,success:`green`,succeeded:`green`,completed:`green`,done:`green`,failed:`red`,error:`red`,cancelled:`grey`,canceled:`grey`,stopped:`grey`,active:`green`,inactive:`grey`,online:`green`,offline:`grey`,open:`red`,closed:`green`,archived:`grey`};function ji(e,t=`zh-CN`){if(!e)return`—`;let n=e instanceof Date?e:new Date(e);return Number.isFinite(n.getTime())?n.toLocaleString(t,{hour12:!1}):`—`}function Mi(e,t=`zh-CN`){if(!e)return`—`;let n=e instanceof Date?e:new Date(e);return Number.isFinite(n.getTime())?n.toLocaleDateString(t):`—`}function Ni(e,t){if(!e)return`—`;let n=new Date(e);if(!Number.isFinite(n.getTime()))return`—`;let r=Date.now()-n.getTime();return r<6e4?t?.(`common.justNow`,null,`刚刚`)||`刚刚`:r<36e5?t?.(`common.minutesAgo`,{n:Math.floor(r/6e4)},`${Math.floor(r/6e4)} 分钟前`):r<864e5?t?.(`common.hoursAgo`,{n:Math.floor(r/36e5)},`${Math.floor(r/36e5)} 小时前`):r<2592e6?t?.(`common.daysAgo`,{n:Math.floor(r/864e5)},`${Math.floor(r/864e5)} 天前`):Mi(e)}function Pi(e){let t=Number(e);if(!Number.isFinite(t)||t<0)return`—`;if(t<1024)return`${t} B`;let n=[`KB`,`MB`,`GB`,`TB`],r=t/1024,i=0;for(;r>=1024&&i<n.length-1;)r/=1024,i+=1;return`${r.toFixed(r>=100?0:1)} ${n[i]}`}function Fi(e,t=`zh-CN`){let n=Number(e);return Number.isFinite(n)?n.toLocaleString(t):`—`}function Ii(e,t=1){let n=Number(e);return Number.isFinite(n)?`${(n*(n<=1?100:1)).toFixed(t)}%`:`—`}function Li(e){return Oi[String(e||``).toLowerCase()]||`grey`}function Ri(e){return Ai[String(e||``).toLowerCase()]||`grey`}function zi(e,t=120){let n=String(e??``);return n.length>t?`${n.slice(0,t)}…`:n}var{Title:Bi,Text:Vi,Paragraph:Hi}=oe;function Ui(e){xe.success({content:e,duration:2})}function Wi(e){xe.warning({content:e,duration:3})}function Gi(e,t=`操作失败`){xe.error({content:$e(e,t),duration:4})}function Ki({title:e,description:t,extra:n,children:r}){return(0,M.jsxs)(`header`,{className:`cs-page-header`,children:[(0,M.jsxs)(`div`,{className:`cs-page-header-main`,children:[(0,M.jsx)(Bi,{heading:3,className:`cs-page-title`,children:e}),t&&(0,M.jsx)(Vi,{type:`tertiary`,className:`cs-page-desc`,children:t}),r]}),n&&(0,M.jsx)(s,{className:`cs-page-header-extra`,wrap:!0,children:n})]})}function qi({title:e,description:t,extra:n,children:r,className:i=``,bodyClassName:a=``}){return(0,M.jsxs)(y,{className:`cs-section-card ${i}`,title:e?(0,M.jsx)(`span`,{className:`cs-section-title`,children:e}):void 0,headerExtraContent:n,bordered:!1,children:[t&&(0,M.jsx)(Hi,{type:`tertiary`,className:`cs-section-desc`,children:t}),(0,M.jsx)(`div`,{className:a,children:r})]})}function Ji({metrics:e,columns:t=4}){return(0,M.jsx)(`div`,{className:`cs-stat-grid`,style:{"--cs-stat-columns":t},children:e.map(e=>(0,M.jsx)(Yi,{...e},e.id||e.label))})}function Yi({label:e,value:t,valueTitle:n,detail:r,tone:i,severity:a,icon:o,onClick:s,pressed:c,loading:l=!1}){let u=(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`span`,{className:`cs-stat-head`,children:[(0,M.jsx)(Vi,{type:`tertiary`,className:`cs-stat-label`,children:e}),o&&(0,M.jsx)(`span`,{className:`cs-stat-icon ${i?`tone-${i}`:``}`,"aria-hidden":`true`,children:o})]}),(0,M.jsx)(f,{loading:l,placeholder:(0,M.jsx)(f.Title,{style:{width:`60%`,height:36,margin:`8px 0`}}),children:(0,M.jsx)(`span`,{className:`cs-stat-value ${i?`tone-${i}`:``}`,title:n,children:t??`—`})}),r&&(0,M.jsx)(`span`,{className:`cs-stat-detail`,children:r})]});return s?(0,M.jsx)(h,{className:`cs-stat-card is-clickable`,theme:`borderless`,onClick:s,"aria-label":String(e),"aria-pressed":c,"data-severity":a,children:u}):(0,M.jsx)(y,{className:`cs-stat-card`,"data-severity":a,bordered:!1,children:u})}function Xi({columns:e,dataSource:t,rowKey:n=`id`,loading:r,pagination:i,emptyText:a,onRefresh:o,toolbar:s,size:c=`default`,className:l=``,...u}){let d=P(),f=i!==!1&&{pageSize:10,showSizeChanger:!0,pageSizeOpts:[10,20,50,100],showTotal:!0,...i||{}};return(0,M.jsxs)(`div`,{className:`cs-table-wrap ${l}`,children:[(s||o)&&(0,M.jsxs)(`div`,{className:`cs-table-toolbar`,children:[(0,M.jsx)(`div`,{className:`cs-table-toolbar-main`,children:s}),o&&(0,M.jsx)(h,{icon:(0,M.jsx)(Ee,{}) Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,Nt as o,T as s,U as c,W as l,_ as u,b as d,f,ot as p,st as m,u as h,v as g,x as _,z as v}from"./semi-Dpcldp_F.js";import{F as ee,I as y,P as b,S as x,b as S,c as C,d as w,i as te,l as ne,m as re,p as ie,s as T,u as ae,x as oe}from"./index-gBcdNgHq.js";import{a as E}from"./AssetBits-BYTpudK4.js";import{a as D,i as O,o as k}from"./assetTarget-D2PEjBAg.js";var A=e(t(),1),j={fofa:{label:`FOFA`,maxSize:1e4,defaultFields:`host,ip,port,domain,title,protocol,country,region,city,server`,placeholder:`app="Apache" && country="CN"`,fieldPresets:[[`最小字段`,`host,ip,port,domain`],[`Web 常用`,`host,title,ip,port,domain,protocol,server,icp,country,region,city`],[`情报增强`,`host,ip,port,domain,title,protocol,country,region,city,server,asn,org,icp,header,banner`]],queryPresets:[[`Apache + 中国`,`app="Apache" && country="CN"`],[`登录页 + 中国`,`title="登录" && country="CN"`],[`指定域名`,`domain="example.com"`],[`指定 IP`,`ip="1.1.1.1"`]],supportsFull:!0},zoomeye:{label:`ZoomEye`,maxSize:1e4,defaultFields:`ip,port,domain,hostname,title,service,app,country,city`,placeholder:`app="Apache" && country="CN"`,fieldPresets:[[`最小字段`,`ip,port,domain,hostname`],[`Web 常用`,`ip,port,domain,hostname,title,service,app,country,city`],[`情报增强`,`ip,port,domain,hostname,title,service,app,country,city,org,isp,ssl`]],queryPresets:[[`Apache + 中国`,`app="Apache" && country="CN"`],[`SSH 服务`,`service="ssh"`],[`指定域名`,`domain="example.com"`],[`指定 IP`,`ip="1.1.1.1"`]],supportsFull:!1},quake:{label:`Quake`,maxSize:1e4,defaultFields:`ip,port,domain,service.name,service.http.title,location.country_cn,location.province_cn,location.city_cn`,placeholder:`service.name:"http" AND country_cn:"中国"`,fieldPresets:[[`最小字段`,`ip,port,domain`],[`Web 常用`,`ip,port,domain,service.name,service.http.title,location.country_cn,location.city_cn`],[`情报增强`,`ip,port,domain,service.name,service.http.title,service.http.server,location.country_cn,location.province_cn,location.city_cn,asn`]],queryPresets:[[`HTTP + 中国`,`service.name:"http" AND country_cn:"中国"`],[`443 端口`,`port:443`],[`指定域名`,`domain:"example.com"`],[`指定 IP`,`ip:"1.1.1.1"`]],supportsFull:!0},shodan:{label:`Shodan`,maxSize:1e3,defaultFields:`ip_str,port,hostnames,domains,org,isp,location.country_name,location.city,product,transport`,placeholder:`product:nginx country:CN`,fieldPresets:[[`最小字段`,`ip_str,port,hostnames,domains`],[`Web 常用`,`ip_str,port,hostnames,domains,product,org,location.country_name,location.city`],[`情报增强`,`ip_str,port,hostnames,domains,org,isp,asn,location.country_name,location.city,product,transport,ssl.cert.subject.cn`]],queryPresets:[[`Nginx + 中国`,`product:nginx country:CN`],[`SSH 服务`,`port:22`],[`证书域名`,`ssl.cert.subject.cn:example.com`],[`Amazon 443`,`org:"Amazon" port:443`]],supportsFull:!1}},se=Object.entries(j).map(([e,t])=>({value:e,label:t.label}));function ce(e){return j[e]||j.fofa}function le(e,t=5){let n=[`host`,`ip`,`port`,`domain`,`title`,`protocol`,`server`,`country`,`city`].filter(t=>e.includes(t)),r=e.filter(e=>!n.includes(e));return[...n,...r].slice(0,t)}function ue(e,t){if(!e||typeof e!=`object`)return``;let n=t=>{for(let n of t){let t=e[n];if(Array.isArray(t)&&t.length)return String(t[0]);if(t)return String(t)}return``},r=n([`host`,`url`,`hostname`]);if(r)return r;let i=n([`domain`,`domains`,`hostnames`]);if(i)return i;let a=n([`ip`,`ip_str`]),o=e.port;return a?o?`${a}:${o}`:a:``}function de(e,t){let n=new Set(t.map(Number));return(e||[]).filter((e,t)=>n.has(t))}var M=e(n(),1),{Text:N}=l;function P(e){if(e==null||e===``)return(0,M.jsx)(N,{type:`tertiary`,children:`—`});let t=Array.isArray(e)?e.join(`, `):typeof e==`object`?JSON.stringify(e):String(e);return(0,M.jsx)(E,{text:t,max:44})}function F(e,t){let n=ue(e,t);return n?/^https?:\/\//i.test(n)?(0,M.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:`info-collect-target-link`,children:(0,M.jsx)(E,{text:n,max:44})}):(0,M.jsx)(E,{text:n,max:44}):(0,M.jsx)(N,{type:`tertiary`,children:`—`})}function fe({fields:e,results:t,visibleFields:n,selectedKeys:r,onSelectionChange:i,onOpenDetail:o,loading:s}){let c=b(),l=Array.isArray(e)?e:[],u=(Array.isArray(n)?n:[]).filter(e=>l.includes(e)),d=[{title:c(`assets.target`,null,`目标`),dataIndex:`__target`,width:240,render:(e,t)=>F(t,l)},...u.map(e=>({title:e,dataIndex:e,render:(t,n)=>P(n[e])})),{title:c(`common.actions`,null,`操作`),dataIndex:`__actions`,width:90,render:(e,t)=>(0,M.jsx)(a,{theme:`borderless`,size:`small`,onClick:()=>o(t),children:c(`common.view`,null,`详情`)})}],f=(t||[]).map((e,t)=>({...e,__key:String(t),__index:t}));return(0,M.jsx)(T,{columns:d,dataSource:f,rowKey:`__key`,loading:s,pagination:!1,rowSelection:{selectedRowKeys:r,onChange:e=>i(e)},emptyText:c(`infoCollect.noResults`,null,`暂 Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,Nt as o,T as s,U as c,W as l,_ as u,b as d,f,ot as p,st as m,u as h,v as g,x as _,z as v}from"./semi-Dpcldp_F.js";import{F as ee,I as y,P as b,S as x,b as S,c as C,d as w,i as te,l as ne,m as re,p as ie,s as T,u as ae,x as oe}from"./index-BMTtTYg1.js";import{a as E}from"./AssetBits-BYTpudK4.js";import{a as D,i as O,o as k}from"./assetTarget-D2PEjBAg.js";var A=e(t(),1),j={fofa:{label:`FOFA`,maxSize:1e4,defaultFields:`host,ip,port,domain,title,protocol,country,region,city,server`,placeholder:`app="Apache" && country="CN"`,fieldPresets:[[`最小字段`,`host,ip,port,domain`],[`Web 常用`,`host,title,ip,port,domain,protocol,server,icp,country,region,city`],[`情报增强`,`host,ip,port,domain,title,protocol,country,region,city,server,asn,org,icp,header,banner`]],queryPresets:[[`Apache + 中国`,`app="Apache" && country="CN"`],[`登录页 + 中国`,`title="登录" && country="CN"`],[`指定域名`,`domain="example.com"`],[`指定 IP`,`ip="1.1.1.1"`]],supportsFull:!0},zoomeye:{label:`ZoomEye`,maxSize:1e4,defaultFields:`ip,port,domain,hostname,title,service,app,country,city`,placeholder:`app="Apache" && country="CN"`,fieldPresets:[[`最小字段`,`ip,port,domain,hostname`],[`Web 常用`,`ip,port,domain,hostname,title,service,app,country,city`],[`情报增强`,`ip,port,domain,hostname,title,service,app,country,city,org,isp,ssl`]],queryPresets:[[`Apache + 中国`,`app="Apache" && country="CN"`],[`SSH 服务`,`service="ssh"`],[`指定域名`,`domain="example.com"`],[`指定 IP`,`ip="1.1.1.1"`]],supportsFull:!1},quake:{label:`Quake`,maxSize:1e4,defaultFields:`ip,port,domain,service.name,service.http.title,location.country_cn,location.province_cn,location.city_cn`,placeholder:`service.name:"http" AND country_cn:"中国"`,fieldPresets:[[`最小字段`,`ip,port,domain`],[`Web 常用`,`ip,port,domain,service.name,service.http.title,location.country_cn,location.city_cn`],[`情报增强`,`ip,port,domain,service.name,service.http.title,service.http.server,location.country_cn,location.province_cn,location.city_cn,asn`]],queryPresets:[[`HTTP + 中国`,`service.name:"http" AND country_cn:"中国"`],[`443 端口`,`port:443`],[`指定域名`,`domain:"example.com"`],[`指定 IP`,`ip:"1.1.1.1"`]],supportsFull:!0},shodan:{label:`Shodan`,maxSize:1e3,defaultFields:`ip_str,port,hostnames,domains,org,isp,location.country_name,location.city,product,transport`,placeholder:`product:nginx country:CN`,fieldPresets:[[`最小字段`,`ip_str,port,hostnames,domains`],[`Web 常用`,`ip_str,port,hostnames,domains,product,org,location.country_name,location.city`],[`情报增强`,`ip_str,port,hostnames,domains,org,isp,asn,location.country_name,location.city,product,transport,ssl.cert.subject.cn`]],queryPresets:[[`Nginx + 中国`,`product:nginx country:CN`],[`SSH 服务`,`port:22`],[`证书域名`,`ssl.cert.subject.cn:example.com`],[`Amazon 443`,`org:"Amazon" port:443`]],supportsFull:!1}},se=Object.entries(j).map(([e,t])=>({value:e,label:t.label}));function ce(e){return j[e]||j.fofa}function le(e,t=5){let n=[`host`,`ip`,`port`,`domain`,`title`,`protocol`,`server`,`country`,`city`].filter(t=>e.includes(t)),r=e.filter(e=>!n.includes(e));return[...n,...r].slice(0,t)}function ue(e,t){if(!e||typeof e!=`object`)return``;let n=t=>{for(let n of t){let t=e[n];if(Array.isArray(t)&&t.length)return String(t[0]);if(t)return String(t)}return``},r=n([`host`,`url`,`hostname`]);if(r)return r;let i=n([`domain`,`domains`,`hostnames`]);if(i)return i;let a=n([`ip`,`ip_str`]),o=e.port;return a?o?`${a}:${o}`:a:``}function de(e,t){let n=new Set(t.map(Number));return(e||[]).filter((e,t)=>n.has(t))}var M=e(n(),1),{Text:N}=l;function P(e){if(e==null||e===``)return(0,M.jsx)(N,{type:`tertiary`,children:`—`});let t=Array.isArray(e)?e.join(`, `):typeof e==`object`?JSON.stringify(e):String(e);return(0,M.jsx)(E,{text:t,max:44})}function F(e,t){let n=ue(e,t);return n?/^https?:\/\//i.test(n)?(0,M.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:`info-collect-target-link`,children:(0,M.jsx)(E,{text:n,max:44})}):(0,M.jsx)(E,{text:n,max:44}):(0,M.jsx)(N,{type:`tertiary`,children:`—`})}function fe({fields:e,results:t,visibleFields:n,selectedKeys:r,onSelectionChange:i,onOpenDetail:o,loading:s}){let c=b(),l=Array.isArray(e)?e:[],u=(Array.isArray(n)?n:[]).filter(e=>l.includes(e)),d=[{title:c(`assets.target`,null,`目标`),dataIndex:`__target`,width:240,render:(e,t)=>F(t,l)},...u.map(e=>({title:e,dataIndex:e,render:(t,n)=>P(n[e])})),{title:c(`common.actions`,null,`操作`),dataIndex:`__actions`,width:90,render:(e,t)=>(0,M.jsx)(a,{theme:`borderless`,size:`small`,onClick:()=>o(t),children:c(`common.view`,null,`详情`)})}],f=(t||[]).map((e,t)=>({...e,__key:String(t),__index:t}));return(0,M.jsx)(T,{columns:d,dataSource:f,rowKey:`__key`,loading:s,pagination:!1,rowSelection:{selectedRowKeys:r,onChange:e=>i(e)},emptyText:c(`infoCollect.noResults`,null,`暂 Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{At as r,Dt as i,F as a,H as ee,L as o,M as s,W as c,i as l,lt as u,ot as d,st as te,v as ne}from"./semi-Dpcldp_F.js";import{D as f,E as p,F as m,I as h,P as g,_ as re,a as _,b as v,c as y,d as ie,f as b,l as x,m as S,p as C,s as ae,x as w,y as T}from"./index-gBcdNgHq.js";var E=e(t(),1),D=e(n(),1),{Text:O}=c;function k(){let e=g(),{hasPermission:t}=m(),n=t(`knowledge:write`),[k,A]=(0,E.useState)(``),[j,oe]=(0,E.useState)(``),[M,N]=(0,E.useState)(1),[P,F]=(0,E.useState)(20),[I,L]=(0,E.useState)(null),[R,z]=(0,E.useState)(null),[B,V]=(0,E.useState)(!1),[H,U]=(0,E.useState)(!1),[W,G]=(0,E.useState)(null),K=_(()=>h.get(`/knowledge/items`,{category:k||void 0,search:j||void 0,limit:P,offset:(M-1)*P}),[k,j,M,P]),q=_(()=>h.get(`/knowledge/stats`),[]),J=_(()=>h.get(`/knowledge/categories`),[]),Y=_(()=>h.get(`/knowledge/index-status`),[]),X=K.data?.enabled===!1,Z=Array.isArray(K.data?.items)?K.data.items:[],se=Number(K.data?.total||0),ce=(Array.isArray(J.data?.categories)?J.data.categories:[]).map(e=>typeof e==`string`?{value:e,label:e}:{value:e.name||e.category,label:e.name||e.category}),Q=(0,E.useCallback)(()=>{K.reload(),q.reload(),Y.reload()},[K,q,Y]),le=async()=>{if(B||!I?.form)return;let e=await I.form.validate().catch(()=>null);if(e){V(!0);try{let t={category:e.category.trim(),title:e.title.trim(),content:e.content};I.item?.id?await h.put(`/knowledge/items/${encodeURIComponent(I.item.id)}`,t):await h.post(`/knowledge/items`,t),w(I.item?.id?`知识项已更新`:`知识项已创建`),L(null),Q()}catch(e){v(e,`保存失败`)}finally{V(!1)}}},ue=e=>T({title:`删除知识项「${e.title}」?`,content:`删除后需要重新索引,且不可恢复。`,onOk:async()=>{await h.del(`/knowledge/items/${encodeURIComponent(e.id)}`),w(`已删除`),Q()}}),$=async e=>{try{await h.post(`/knowledge/index`,e?{full:!0}:{}),w(`索引任务已提交`),Y.reload()}catch(e){v(e,`构建索引失败`)}},de=async e=>{try{G(await h.post(`/knowledge/search`,{query:e,topK:5}))}catch(e){v(e,`检索失败`)}};return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(C,{title:e(`knowledge.title`,null,`知识管理`),description:`知识条目会参与智能体检索;修改后需要重建索引才能生效。`,extra:(0,D.jsxs)(a,{wrap:!0,children:[(0,D.jsx)(o,{icon:(0,D.jsx)(te,{}),onClick:Q,children:`刷新`}),n&&!X&&(0,D.jsx)(o,{onClick:()=>$(!1),children:`构建索引`}),n&&!X&&(0,D.jsx)(o,{onClick:()=>$(!0),children:`全量重建`}),n&&!X&&(0,D.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,D.jsx)(u,{}),onClick:()=>L({item:null,form:{}}),children:`新增知识`})]})}),X&&(0,D.jsx)(c.Paragraph,{type:`tertiary`,children:K.data.message}),(0,D.jsx)(re,{columns:4,metrics:[{id:`items`,label:`知识条目`,value:f(q.data?.total_items||0),loading:q.loading},{id:`categories`,label:`分类数`,value:f(q.data?.total_categories||0),loading:q.loading},{id:`indexed`,label:`已索引`,value:f(Y.data?.indexed_items??Y.data?.total_indexed??0),loading:Y.loading},{id:`pending`,label:`待索引`,value:f(Y.data?.pending_items??0),loading:Y.loading}]}),(0,D.jsxs)(S,{title:`知识条目`,children:[(0,D.jsx)(x,{error:K.error,onRetry:()=>K.reload()}),(0,D.jsx)(ae,{columns:[{title:`标题`,dataIndex:`title`,render:(e,t)=>(0,D.jsx)(O,{strong:!0,children:e||t.filePath})},{title:`分类`,dataIndex:`category`,width:160,render:e=>e?(0,D.jsx)(s,{size:`small`,children:e}):`—`},{title:`更新时间`,dataIndex:`updatedAt`,width:180,render:e=>p(e)},{title:`操作`,width:150,render:(e,t)=>(0,D.jsxs)(a,{children:[(0,D.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>z(t),children:`查看`}),n&&(0,D.jsx)(o,{size:`small`,theme:`borderless`,icon:(0,D.jsx)(i,{}),onClick:()=>L({item:t,form:{}})}),n&&(0,D.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,D.jsx)(r,{}),onClick:()=>ue(t)})]})}],dataSource:Z,rowKey:`id`,loading:K.loading,pagination:{currentPage:M,pageSize:P,total:se,onPageChange:N,onPageSizeChange:e=>{F(e),N(1)}},toolbar:(0,D.jsxs)(a,{wrap:!0,children:[(0,D.jsx)(ee,{prefix:(0,D.jsx)(d,{}),value:j,onChange:e=>{oe(e),N(1)},placeholder:`搜索标题或内容`,style:{width:220}}),(0,D.jsx)(ne,{value:k,onChange:e=>{A(e||``),N(1)},placeholder:`全部分类`,style:{width:180},showClear:!0,optionList:ce}),(0,D.jsx)(o,{disabled:X,onClick:()=>U(!0),children:`检索测试`})]})})]}),(0,D.jsx)(y,{title:I?.item?`编辑知识项`:`新增知识项`,visible:!!I,onCancel:()=>L(null),onOk:le,confirmLoading:B,width:760,children:(0,D.jsxs)(l,{getFormApi:e=>L(t=>t&&{...t,form:e}),initValues:I?.item?{category:I.item.category,title:I.item.title,content:I.item.content}:{},children:[(0,D.jsx)(l.Input,{field:`category`,label:`分类`,rules:[{required:!0,message:`请输入分类`}]}),(0,D.jsx)(l.Input,{field:`title`,label:`标题`,rules:[{required:!0,message:`请输入标题`}]}),(0,D.jsx)(l.TextArea,{field:`content`,label:`内容(Markdown)`,rules:[{required:!0,message:`请输入内容`Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{At as r,Dt as i,F as a,H as ee,L as o,M as s,W as c,i as l,lt as u,ot as d,st as te,v as ne}from"./semi-Dpcldp_F.js";import{D as f,E as p,F as m,I as h,P as g,_ as re,a as _,b as v,c as y,d as ie,f as b,l as x,m as S,p as C,s as ae,x as w,y as T}from"./index-BMTtTYg1.js";var E=e(t(),1),D=e(n(),1),{Text:O}=c;function k(){let e=g(),{hasPermission:t}=m(),n=t(`knowledge:write`),[k,A]=(0,E.useState)(``),[j,oe]=(0,E.useState)(``),[M,N]=(0,E.useState)(1),[P,F]=(0,E.useState)(20),[I,L]=(0,E.useState)(null),[R,z]=(0,E.useState)(null),[B,V]=(0,E.useState)(!1),[H,U]=(0,E.useState)(!1),[W,G]=(0,E.useState)(null),K=_(()=>h.get(`/knowledge/items`,{category:k||void 0,search:j||void 0,limit:P,offset:(M-1)*P}),[k,j,M,P]),q=_(()=>h.get(`/knowledge/stats`),[]),J=_(()=>h.get(`/knowledge/categories`),[]),Y=_(()=>h.get(`/knowledge/index-status`),[]),X=K.data?.enabled===!1,Z=Array.isArray(K.data?.items)?K.data.items:[],se=Number(K.data?.total||0),ce=(Array.isArray(J.data?.categories)?J.data.categories:[]).map(e=>typeof e==`string`?{value:e,label:e}:{value:e.name||e.category,label:e.name||e.category}),Q=(0,E.useCallback)(()=>{K.reload(),q.reload(),Y.reload()},[K,q,Y]),le=async()=>{if(B||!I?.form)return;let e=await I.form.validate().catch(()=>null);if(e){V(!0);try{let t={category:e.category.trim(),title:e.title.trim(),content:e.content};I.item?.id?await h.put(`/knowledge/items/${encodeURIComponent(I.item.id)}`,t):await h.post(`/knowledge/items`,t),w(I.item?.id?`知识项已更新`:`知识项已创建`),L(null),Q()}catch(e){v(e,`保存失败`)}finally{V(!1)}}},ue=e=>T({title:`删除知识项「${e.title}」?`,content:`删除后需要重新索引,且不可恢复。`,onOk:async()=>{await h.del(`/knowledge/items/${encodeURIComponent(e.id)}`),w(`已删除`),Q()}}),$=async e=>{try{await h.post(`/knowledge/index`,e?{full:!0}:{}),w(`索引任务已提交`),Y.reload()}catch(e){v(e,`构建索引失败`)}},de=async e=>{try{G(await h.post(`/knowledge/search`,{query:e,topK:5}))}catch(e){v(e,`检索失败`)}};return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(C,{title:e(`knowledge.title`,null,`知识管理`),description:`知识条目会参与智能体检索;修改后需要重建索引才能生效。`,extra:(0,D.jsxs)(a,{wrap:!0,children:[(0,D.jsx)(o,{icon:(0,D.jsx)(te,{}),onClick:Q,children:`刷新`}),n&&!X&&(0,D.jsx)(o,{onClick:()=>$(!1),children:`构建索引`}),n&&!X&&(0,D.jsx)(o,{onClick:()=>$(!0),children:`全量重建`}),n&&!X&&(0,D.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,D.jsx)(u,{}),onClick:()=>L({item:null,form:{}}),children:`新增知识`})]})}),X&&(0,D.jsx)(c.Paragraph,{type:`tertiary`,children:K.data.message}),(0,D.jsx)(re,{columns:4,metrics:[{id:`items`,label:`知识条目`,value:f(q.data?.total_items||0),loading:q.loading},{id:`categories`,label:`分类数`,value:f(q.data?.total_categories||0),loading:q.loading},{id:`indexed`,label:`已索引`,value:f(Y.data?.indexed_items??Y.data?.total_indexed??0),loading:Y.loading},{id:`pending`,label:`待索引`,value:f(Y.data?.pending_items??0),loading:Y.loading}]}),(0,D.jsxs)(S,{title:`知识条目`,children:[(0,D.jsx)(x,{error:K.error,onRetry:()=>K.reload()}),(0,D.jsx)(ae,{columns:[{title:`标题`,dataIndex:`title`,render:(e,t)=>(0,D.jsx)(O,{strong:!0,children:e||t.filePath})},{title:`分类`,dataIndex:`category`,width:160,render:e=>e?(0,D.jsx)(s,{size:`small`,children:e}):`—`},{title:`更新时间`,dataIndex:`updatedAt`,width:180,render:e=>p(e)},{title:`操作`,width:150,render:(e,t)=>(0,D.jsxs)(a,{children:[(0,D.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>z(t),children:`查看`}),n&&(0,D.jsx)(o,{size:`small`,theme:`borderless`,icon:(0,D.jsx)(i,{}),onClick:()=>L({item:t,form:{}})}),n&&(0,D.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,D.jsx)(r,{}),onClick:()=>ue(t)})]})}],dataSource:Z,rowKey:`id`,loading:K.loading,pagination:{currentPage:M,pageSize:P,total:se,onPageChange:N,onPageSizeChange:e=>{F(e),N(1)}},toolbar:(0,D.jsxs)(a,{wrap:!0,children:[(0,D.jsx)(ee,{prefix:(0,D.jsx)(d,{}),value:j,onChange:e=>{oe(e),N(1)},placeholder:`搜索标题或内容`,style:{width:220}}),(0,D.jsx)(ne,{value:k,onChange:e=>{A(e||``),N(1)},placeholder:`全部分类`,style:{width:180},showClear:!0,optionList:ce}),(0,D.jsx)(o,{disabled:X,onClick:()=>U(!0),children:`检索测试`})]})})]}),(0,D.jsx)(y,{title:I?.item?`编辑知识项`:`新增知识项`,visible:!!I,onCancel:()=>L(null),onOk:le,confirmLoading:B,width:760,children:(0,D.jsxs)(l,{getFormApi:e=>L(t=>t&&{...t,form:e}),initValues:I?.item?{category:I.item.category,title:I.item.title,content:I.item.content}:{},children:[(0,D.jsx)(l.Input,{field:`category`,label:`分类`,rules:[{required:!0,message:`请输入分类`}]}),(0,D.jsx)(l.Input,{field:`title`,label:`标题`,rules:[{required:!0,message:`请输入标题`}]}),(0,D.jsx)(l.TextArea,{field:`content`,label:`内容(Markdown)`,rules:[{required:!0,message:`请输入内容`Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{At as r,F as i,H as a,L as o,M as s,W as c,ot as l,st as u}from"./semi-Dpcldp_F.js";import{E as d,F as f,I as p,P as m,a as h,c as g,d as _,l as v,m as y,p as b,s as x,u as S,x as C,y as w}from"./index-gBcdNgHq.js";var T=e(t(),1),E=e(n(),1),{Text:D}=c;function O(){let e=m(),{hasPermission:t}=f(),n=t(`knowledge:delete`),[c,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(50),[j,M]=(0,T.useState)(null),N=h(()=>p.get(`/knowledge/retrieval-logs`,{conversationId:c||void 0,limit:k}),[c,k]),P=Array.isArray(N.data?.logs)?N.data.logs:[],F=e=>w({title:`删除该检索日志?`,content:e.query||e.id,onOk:async()=>{await p.del(`/knowledge/retrieval-logs/${encodeURIComponent(e.id)}`),C(`已删除`),N.reload()}});return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(b,{title:e(`knowledge.retrievalLogsTitle`,null,`检索历史`),description:`记录智能体每次知识库检索的语句、命中项与会话,用于回溯回答依据。`,extra:(0,E.jsx)(o,{icon:(0,E.jsx)(u,{}),onClick:()=>N.reload(),loading:N.loading,children:`刷新`})}),(0,E.jsxs)(y,{title:`检索记录(${P.length})`,children:[(0,E.jsx)(v,{error:N.error,onRetry:()=>N.reload()}),(0,E.jsx)(x,{columns:[{title:`检索语句`,dataIndex:`query`,render:(e,t)=>(0,E.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>M(t),style:{background:`none`,border:`none`,padding:0,cursor:`pointer`,textAlign:`left`,color:`var(--semi-color-primary)`},children:e||`—`})},{title:`风险类型`,dataIndex:`riskType`,width:140,render:e=>e?(0,E.jsx)(s,{size:`small`,children:e}):`—`},{title:`命中知识项`,dataIndex:`retrievedItems`,width:120,render:e=>(0,E.jsxs)(D,{type:`tertiary`,children:[Array.isArray(e)?e.length:0,` 条`]})},{title:`会话`,dataIndex:`conversationId`,width:200,render:e=>(0,E.jsx)(D,{type:`tertiary`,ellipsis:{showTooltip:!0},children:e||`—`})},{title:`时间`,dataIndex:`createdAt`,width:180,render:e=>d(e)},{title:`操作`,width:110,render:(e,t)=>(0,E.jsxs)(i,{children:[(0,E.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>M(t),children:`详情`}),n&&(0,E.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,E.jsx)(r,{}),onClick:()=>F(t)})]})}],dataSource:P,rowKey:`id`,loading:N.loading,pagination:!1,toolbar:(0,E.jsxs)(i,{children:[(0,E.jsx)(a,{prefix:(0,E.jsx)(l,{}),placeholder:`按会话 ID 过滤`,value:c,onChange:O,style:{width:260}}),(0,E.jsx)(a,{placeholder:`条数`,value:String(k),onChange:e=>A(Math.min(Math.max(Number(e)||50,1),500)),style:{width:100},suffix:(0,E.jsx)(D,{type:`tertiary`,children:`条`})})]})})]}),(0,E.jsx)(g,{title:`检索日志详情`,visible:!!j,onCancel:()=>M(null),width:560,children:j&&(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,E.jsx)(_,{items:[{label:`日志 ID`,value:j.id},{label:`检索语句`,value:j.query},{label:`风险类型`,value:j.riskType||`—`},{label:`会话 ID`,value:j.conversationId||`—`},{label:`消息 ID`,value:j.messageId||`—`},{label:`时间`,value:d(j.createdAt)}]}),(0,E.jsx)(S,{value:j.retrievedItems||[],title:`命中知识项`})]})})]})}export{O as default};
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{At as r,F as i,H as a,L as o,M as s,W as c,ot as l,st as u}from"./semi-Dpcldp_F.js";import{E as d,F as f,I as p,P as m,a as h,c as g,d as _,l as v,m as y,p as b,s as x,u as S,x as C,y as w}from"./index-BMTtTYg1.js";var T=e(t(),1),E=e(n(),1),{Text:D}=c;function O(){let e=m(),{hasPermission:t}=f(),n=t(`knowledge:delete`),[c,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(50),[j,M]=(0,T.useState)(null),N=h(()=>p.get(`/knowledge/retrieval-logs`,{conversationId:c||void 0,limit:k}),[c,k]),P=Array.isArray(N.data?.logs)?N.data.logs:[],F=e=>w({title:`删除该检索日志?`,content:e.query||e.id,onOk:async()=>{await p.del(`/knowledge/retrieval-logs/${encodeURIComponent(e.id)}`),C(`已删除`),N.reload()}});return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(b,{title:e(`knowledge.retrievalLogsTitle`,null,`检索历史`),description:`记录智能体每次知识库检索的语句、命中项与会话,用于回溯回答依据。`,extra:(0,E.jsx)(o,{icon:(0,E.jsx)(u,{}),onClick:()=>N.reload(),loading:N.loading,children:`刷新`})}),(0,E.jsxs)(y,{title:`检索记录(${P.length})`,children:[(0,E.jsx)(v,{error:N.error,onRetry:()=>N.reload()}),(0,E.jsx)(x,{columns:[{title:`检索语句`,dataIndex:`query`,render:(e,t)=>(0,E.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>M(t),style:{background:`none`,border:`none`,padding:0,cursor:`pointer`,textAlign:`left`,color:`var(--semi-color-primary)`},children:e||`—`})},{title:`风险类型`,dataIndex:`riskType`,width:140,render:e=>e?(0,E.jsx)(s,{size:`small`,children:e}):`—`},{title:`命中知识项`,dataIndex:`retrievedItems`,width:120,render:e=>(0,E.jsxs)(D,{type:`tertiary`,children:[Array.isArray(e)?e.length:0,` 条`]})},{title:`会话`,dataIndex:`conversationId`,width:200,render:e=>(0,E.jsx)(D,{type:`tertiary`,ellipsis:{showTooltip:!0},children:e||`—`})},{title:`时间`,dataIndex:`createdAt`,width:180,render:e=>d(e)},{title:`操作`,width:110,render:(e,t)=>(0,E.jsxs)(i,{children:[(0,E.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>M(t),children:`详情`}),n&&(0,E.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,E.jsx)(r,{}),onClick:()=>F(t)})]})}],dataSource:P,rowKey:`id`,loading:N.loading,pagination:!1,toolbar:(0,E.jsxs)(i,{children:[(0,E.jsx)(a,{prefix:(0,E.jsx)(l,{}),placeholder:`按会话 ID 过滤`,value:c,onChange:O,style:{width:260}}),(0,E.jsx)(a,{placeholder:`条数`,value:String(k),onChange:e=>A(Math.min(Math.max(Number(e)||50,1),500)),style:{width:100},suffix:(0,E.jsx)(D,{type:`tertiary`,children:`条`})})]})})]}),(0,E.jsx)(g,{title:`检索日志详情`,visible:!!j,onCancel:()=>M(null),width:560,children:j&&(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,E.jsx)(_,{items:[{label:`日志 ID`,value:j.id},{label:`检索语句`,value:j.query},{label:`风险类型`,value:j.riskType||`—`},{label:`会话 ID`,value:j.conversationId||`—`},{label:`消息 ID`,value:j.messageId||`—`},{label:`时间`,value:d(j.createdAt)}]}),(0,E.jsx)(S,{value:j.retrievedItems||[],title:`命中知识项`})]})})]})}export{O as default};
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,N as s,W as c,lt as l,ot as u,st as d,u as f,v as p,x as m,z as h}from"./semi-Dpcldp_F.js";import{F as g,I as _,P as v,R as y,_ as b,a as x,b as S,c as C,l as w,m as T,n as E,o as D,p as O,r as k,s as A,x as j,y as M}from"./index-gBcdNgHq.js";var N=e(t(),1),P={connected:{color:`green`,label:`已连接`},connecting:{color:`blue`,label:`连接中`},disconnected:{color:`amber`,label:`未连接`},disabled:{color:`grey`,label:`已停用`},error:{color:`red`,label:`连接失败`}};function F(e){return P[String(e||``).toLowerCase()]||{color:`grey`,label:e||`未知`}}function I(e){return e?String(e.type||e.transport||(e.command?`stdio`:`http`)).toLowerCase():`http`}function L(e){return e?e.is_external&&e.external_mcp?`${e.external_mcp}::${e.name}`:e.name||``:``}function R(e){return e?e.is_external?`外部 · ${e.external_mcp||`未知`}`:`内置`:`—`}var z=e(n(),1),{Text:B}=c,V={"my-stdio-server":{command:`python3`,args:["${HOME}/mcp-servers/main.py",`--port`,"${MCP_PORT:-3000}"],env:{API_KEY:"${API_KEY}",LOG_LEVEL:"${LOG_LEVEL:-INFO}"},timeout:300},"my-http-server":{type:`http`,url:`https://mcp.example.com/mcp`,headers:{Authorization:"Bearer ${MCP_TOKEN}"}},"my-sse-server":{type:`sse`,url:`http://127.0.0.1:8081/mcp/sse`}};function H(e,{editingName:t}){if(typeof e!=`object`||!e||Array.isArray(e))return{error:`配置必须是 JSON 对象`};let n=Object.keys(e);if(!n.length)return{error:`至少需要一个 MCP 配置`};if(t&&!e[t])return{error:`编辑模式下 JSON 必须包含配置名称 "${t}"`};for(let t of n){if(!t.trim())return{error:`配置名称不能为空`};let n=e[t];if(typeof n!=`object`||!n||Array.isArray(n))return{error:`"${t}" 的配置必须是对象`};delete n.external_mcp_enable;let r=n.type||n.transport||(n.command?`stdio`:n.url?`http`:``);if(!r)return{error:`"${t}" 需要指定 command(stdio)或 url + type(http/sse)`};if(r===`stdio`&&!n.command)return{error:`"${t}" 的 stdio 模式需要 command`};if((r===`http`||r===`sse`)&&!n.url)return{error:`"${t}" 的 ${r} 模式需要 url`}}return{error:``,names:n}}function U({canWrite:e,onChanged:t,refreshKey:n=0}){let i=v(),s=x(()=>_.get(`/external-mcp`),[n]),[c,u]=(0,N.useState)(``),[f,p]=(0,N.useState)(!1),[g,b]=(0,N.useState)(null),[E,O]=(0,N.useState)(``),[A,P]=(0,N.useState)(``),[L,R]=(0,N.useState)(!1),U=(0,N.useMemo)(()=>{let e=s.data?.servers||{};return Object.entries(e).sort(([e],[t])=>e.localeCompare(t))},[s.data]),W=(0,N.useCallback)(e=>s.reload(e),[s.reload]);k(()=>{typeof document<`u`&&document.hidden||W({silent:!0})},8e3);let G=(0,N.useCallback)(()=>{b(null),O(``),P(``),p(!0)},[]),K=(0,N.useCallback)(async e=>{b(e),O(``),P(``),p(!0);try{let t={...(await _.get(`/external-mcp/${encodeURIComponent(e)}`))?.config||{}};delete t.tool_count,delete t.external_mcp_enable,O(JSON.stringify({[e]:t},null,2))}catch(e){p(!1),S(e,i(`mcp.getConfigFailed`,null,`获取外部MCP配置失败`))}},[i]),q=(0,N.useCallback)(()=>{p(!1),b(null),P(``)},[]),J=(0,N.useCallback)(async(e,n)=>{let r=n===`connected`?`stop`:`start`;u(e);try{await _.post(`/external-mcp/${encodeURIComponent(e)}/${r}`,{}),j(r===`start`?`已提交启动请求,正在后台连接`:`外部 MCP 已停止`),W({silent:!0}),t?.()}catch(e){S(e,i(`mcp.operationFailed`,null,`操作失败`))}finally{u(``)}},[t,W,i]),Y=(0,N.useCallback)(e=>{M({title:i(`mcp.deleteExternalConfirm`,{name:e},`确定要删除外部MCP "${e}" 吗?`),content:`删除后该 MCP 的工具将从对话中移除。`,okText:i(`common.delete`,null,`删除`),onOk:async()=>{try{await _.del(`/external-mcp/${encodeURIComponent(e)}`),j(i(`mcp.deleteSuccess`,null,`删除成功`)),W(),t?.()}catch(e){S(e,i(`mcp.operationFailed`,null,`删除失败`))}}})},[t,W,i]),X=(0,N.useCallback)(async()=>{let e=E.trim();if(!e){P(i(`mcp.jsonEmpty`,null,`JSON不能为空`));return}let n;try{n=JSON.parse(e)}catch(e){P(`${i(`mcp.jsonError`,null,`JSON格式错误`)}: ${e.message}`);return}let{error:r,names:a}=H(n,{editingName:g});if(r)P(r);else{P(``),R(!0);try{let e=g?[g]:a;for(let t of e)await _.put(`/external-mcp/${encodeURIComponent(t)}`,{config:n[t]});j(i(`mcp.saveSuccess`,null,`保存成功`)),q(),W(),t?.()}catch(e){P(`${i(`mcp.operationFailed`,null,`保存失败`)}: ${y(e)}`)}finally{R(!1)}}},[q,g,E,t,W,i]),Z=(0,z.jsxs)(r,{spacing:8,children:[(0,z.jsx)(a,{size:`small`,icon:(0,z.jsx)(d,{}),theme:`borderless`,onClick:()=>W(),loading:s.loading,children:i(`common.refresh`,null,`刷新`)}),(0,z.jsx)(a,{size:`small`,icon:(0,z.jsx)(l,{}),disabled:!e,onClick:G,children:i(`mcp.addExternalMCP`,null,`添加外部MCP`)})]});return(0,z.jsxs)(T,{title:i(`mcp.externalConfig`,null,`外部 MCP 配置`),description:`stdio 传 command/args/env,http 与 sse 传 url/headers;状态每 8 秒自动刷新。`,extra:Z,children:[(0,z.jsx)(w,{error:s.error,onRetry:()=>W()}),!U.length&&!s.loading&&(0,z.jsxs)(`div`,{className:`mcp-managemen Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,N as s,W as c,lt as l,ot as u,st as d,u as f,v as p,x as m,z as h}from"./semi-Dpcldp_F.js";import{F as g,I as _,P as v,R as y,_ as b,a as x,b as S,c as C,l as w,m as T,n as E,o as D,p as O,r as k,s as A,x as j,y as M}from"./index-BMTtTYg1.js";var N=e(t(),1),P={connected:{color:`green`,label:`已连接`},connecting:{color:`blue`,label:`连接中`},disconnected:{color:`amber`,label:`未连接`},disabled:{color:`grey`,label:`已停用`},error:{color:`red`,label:`连接失败`}};function F(e){return P[String(e||``).toLowerCase()]||{color:`grey`,label:e||`未知`}}function I(e){return e?String(e.type||e.transport||(e.command?`stdio`:`http`)).toLowerCase():`http`}function L(e){return e?e.is_external&&e.external_mcp?`${e.external_mcp}::${e.name}`:e.name||``:``}function R(e){return e?e.is_external?`外部 · ${e.external_mcp||`未知`}`:`内置`:`—`}var z=e(n(),1),{Text:B}=c,V={"my-stdio-server":{command:`python3`,args:["${HOME}/mcp-servers/main.py",`--port`,"${MCP_PORT:-3000}"],env:{API_KEY:"${API_KEY}",LOG_LEVEL:"${LOG_LEVEL:-INFO}"},timeout:300},"my-http-server":{type:`http`,url:`https://mcp.example.com/mcp`,headers:{Authorization:"Bearer ${MCP_TOKEN}"}},"my-sse-server":{type:`sse`,url:`http://127.0.0.1:8081/mcp/sse`}};function H(e,{editingName:t}){if(typeof e!=`object`||!e||Array.isArray(e))return{error:`配置必须是 JSON 对象`};let n=Object.keys(e);if(!n.length)return{error:`至少需要一个 MCP 配置`};if(t&&!e[t])return{error:`编辑模式下 JSON 必须包含配置名称 "${t}"`};for(let t of n){if(!t.trim())return{error:`配置名称不能为空`};let n=e[t];if(typeof n!=`object`||!n||Array.isArray(n))return{error:`"${t}" 的配置必须是对象`};delete n.external_mcp_enable;let r=n.type||n.transport||(n.command?`stdio`:n.url?`http`:``);if(!r)return{error:`"${t}" 需要指定 command(stdio)或 url + type(http/sse)`};if(r===`stdio`&&!n.command)return{error:`"${t}" 的 stdio 模式需要 command`};if((r===`http`||r===`sse`)&&!n.url)return{error:`"${t}" 的 ${r} 模式需要 url`}}return{error:``,names:n}}function U({canWrite:e,onChanged:t,refreshKey:n=0}){let i=v(),s=x(()=>_.get(`/external-mcp`),[n]),[c,u]=(0,N.useState)(``),[f,p]=(0,N.useState)(!1),[g,b]=(0,N.useState)(null),[E,O]=(0,N.useState)(``),[A,P]=(0,N.useState)(``),[L,R]=(0,N.useState)(!1),U=(0,N.useMemo)(()=>{let e=s.data?.servers||{};return Object.entries(e).sort(([e],[t])=>e.localeCompare(t))},[s.data]),W=(0,N.useCallback)(e=>s.reload(e),[s.reload]);k(()=>{typeof document<`u`&&document.hidden||W({silent:!0})},8e3);let G=(0,N.useCallback)(()=>{b(null),O(``),P(``),p(!0)},[]),K=(0,N.useCallback)(async e=>{b(e),O(``),P(``),p(!0);try{let t={...(await _.get(`/external-mcp/${encodeURIComponent(e)}`))?.config||{}};delete t.tool_count,delete t.external_mcp_enable,O(JSON.stringify({[e]:t},null,2))}catch(e){p(!1),S(e,i(`mcp.getConfigFailed`,null,`获取外部MCP配置失败`))}},[i]),q=(0,N.useCallback)(()=>{p(!1),b(null),P(``)},[]),J=(0,N.useCallback)(async(e,n)=>{let r=n===`connected`?`stop`:`start`;u(e);try{await _.post(`/external-mcp/${encodeURIComponent(e)}/${r}`,{}),j(r===`start`?`已提交启动请求,正在后台连接`:`外部 MCP 已停止`),W({silent:!0}),t?.()}catch(e){S(e,i(`mcp.operationFailed`,null,`操作失败`))}finally{u(``)}},[t,W,i]),Y=(0,N.useCallback)(e=>{M({title:i(`mcp.deleteExternalConfirm`,{name:e},`确定要删除外部MCP "${e}" 吗?`),content:`删除后该 MCP 的工具将从对话中移除。`,okText:i(`common.delete`,null,`删除`),onOk:async()=>{try{await _.del(`/external-mcp/${encodeURIComponent(e)}`),j(i(`mcp.deleteSuccess`,null,`删除成功`)),W(),t?.()}catch(e){S(e,i(`mcp.operationFailed`,null,`删除失败`))}}})},[t,W,i]),X=(0,N.useCallback)(async()=>{let e=E.trim();if(!e){P(i(`mcp.jsonEmpty`,null,`JSON不能为空`));return}let n;try{n=JSON.parse(e)}catch(e){P(`${i(`mcp.jsonError`,null,`JSON格式错误`)}: ${e.message}`);return}let{error:r,names:a}=H(n,{editingName:g});if(r)P(r);else{P(``),R(!0);try{let e=g?[g]:a;for(let t of e)await _.put(`/external-mcp/${encodeURIComponent(t)}`,{config:n[t]});j(i(`mcp.saveSuccess`,null,`保存成功`)),q(),W(),t?.()}catch(e){P(`${i(`mcp.operationFailed`,null,`保存失败`)}: ${y(e)}`)}finally{R(!1)}}},[q,g,E,t,W,i]),Z=(0,z.jsxs)(r,{spacing:8,children:[(0,z.jsx)(a,{size:`small`,icon:(0,z.jsx)(d,{}),theme:`borderless`,onClick:()=>W(),loading:s.loading,children:i(`common.refresh`,null,`刷新`)}),(0,z.jsx)(a,{size:`small`,icon:(0,z.jsx)(l,{}),disabled:!e,onClick:G,children:i(`mcp.addExternalMCP`,null,`添加外部MCP`)})]});return(0,z.jsxs)(T,{title:i(`mcp.externalConfig`,null,`外部 MCP 配置`),description:`stdio 传 command/args/env,http 与 sse 传 url/headers;状态每 8 秒自动刷新。`,extra:Z,children:[(0,z.jsx)(w,{error:s.error,onRetry:()=>W()}),!U.length&&!s.loading&&(0,z.jsxs)(`div`,{className:`mcp-managemen Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,U as c,W as l,f as u,ot as d,st as f,v as p,w as m,x as h,z as g}from"./semi-Dpcldp_F.js";import{D as _,E as v,F as y,I as b,O as x,P as S,S as ee,_ as C,a as w,b as T,d as E,g as D,i as te,l as O,m as k,n as ne,o as A,p as re,r as ie,s as j,u as M,x as N,y as P}from"./index-gBcdNgHq.js";var F=e(t(),1),I=[`completed`,`running`,`queued`,`failed`,`blocked`,`hard_timeout`,`cancelled`,`orphaned`],L={pending:`statusPending`,queued:`statusQueued`,running:`statusRunning`,completed:`statusCompleted`,failed:`statusFailed`,blocked:`statusBlocked`,cancelled:`statusCancelled`,hard_timeout:`statusHardTimeout`,orphaned:`statusOrphaned`},R={pending:`等待中`,queued:`排队中`,running:`执行中`,completed:`已完成`,failed:`失败`,blocked:`已拦截`,cancelled:`已终止`,hard_timeout:`执行超时`,orphaned:`孤儿任务`},z={completed:`green`,running:`blue`,queued:`amber`,failed:`red`,blocked:`orange`,hard_timeout:`red`,cancelled:`grey`,orphaned:`grey`};function B(e){return String(e||``).trim().toLowerCase()}function V(e,t){let n=B(t),r=L[n];return r?e(`mcpMonitor.${r}`,null,R[n]||n):t||`—`}function H(e){return z[B(e)]||`grey`}function U(e){return B(e)===`running`}function W(e){let t=String(e||``).trim();return t?t.includes(`::`)?t.replace(/::/g,`__`):t:``}function G(e){if(!e)return null;let t=Number(e.duration);if(Number.isFinite(t)&&t>0)return t/1e6;let n=e.startTime?new Date(e.startTime).getTime():NaN,r=e.endTime?new Date(e.endTime).getTime():NaN;return Number.isFinite(n)&&Number.isFinite(r)&&r>=n?r-n:null}function K(e){let t=Number(e);if(!Number.isFinite(t)||t<0)return`—`;if(t<1e3)return`${Math.round(t)} ms`;if(t<6e4)return`${(t/1e3).toFixed(2)} s`;let n=Math.floor(t/6e4),r=Math.round(t%6e4/1e3);return n<60?`${n} 分 ${r} 秒`:`${Math.floor(n/60)} 小时 ${n%60} 分`}function q(e){if(!e)return null;let t=(Number(e.totalCalls)||0)-(Number(e.blockedCalls)||0);return t<=0?null:(Number(e.successCalls)||0)/t}function J(e,t=1){return e==null||!Number.isFinite(Number(e))?`—`:`${(Number(e)*100).toFixed(t)}%`}function ae(e){let t=(e||[]).map(G).filter(e=>Number.isFinite(e)&&e>=0);return t.length?t.reduce((e,t)=>e+t,0)/t.length:null}function Y(e,t){let n=new Date(e);if(!Number.isFinite(n.getTime()))return``;let r=e=>String(e).padStart(2,`0`),i=`${r(n.getMonth()+1)}-${r(n.getDate())}`;return t===`30d`?i:t===`7d`?`${i} ${r(n.getHours())}h`:`${r(n.getHours())}:00`}function X(e,t){let n=e?.t?new Date(e.t).toLocaleString(`zh-CN`,{hour12:!1}):`—`;return t(`mcpMonitor.timelineTooltip`,{time:n,total:e?.total||0,failed:e?.failed||0,blocked:e?.blocked||0},`${n} 总调用 ${e?.total||0},失败 ${e?.failed||0},拦截 ${e?.blocked||0}`)}var Z=e(n(),1);function oe({summary:e,loading:t,avgMs:n=null,avgSamples:r=0}){let i=S(),a=q(e);return(0,Z.jsx)(C,{columns:4,metrics:[{id:`calls`,label:i(`mcpMonitor.totalCalls`,null,`调用次数`),value:e?e.totalCalls??0:`—`,detail:e?i(`mcpMonitor.statsFromAllTools`,null,`全部工具累计,含已拦截调用`):void 0,loading:t},{id:`rate`,label:i(`mcpMonitor.successRate`,null,`成功率`),value:J(a),detail:e?`${i(`common.ok`,null,`成功`)} ${e.successCalls??0} / ${i(`mcpMonitor.failedColumn`,null,`失败`)} ${e.failedCalls??0}`:void 0,tone:a===null?void 0:a>=.95?`success`:a>=.8?`warning`:`danger`,loading:t},{id:`avg`,label:`平均耗时`,value:n===null?`—`:K(n),detail:r>0?`按当前页 ${r} 条计时记录估算`:`当前页暂无可计时的执行记录`,loading:t},{id:`failed`,label:i(`mcpMonitor.failedMetric`,null,`失败数`),value:e?e.failedCalls??0:`—`,detail:e?`${i(`mcpMonitor.blockedCount`,{n:e.blockedCalls??0},`安全拦截 ${e.blockedCalls??0}`)} · ${i(`mcpMonitor.lastCall`,null,`最近调用`)} ${e.lastCallTime?v(e.lastCallTime):`—`}`:void 0,tone:e&&e.failedCalls>0?`danger`:void 0,loading:t}]})}function se({topTools:e,loading:t,onFilterTool:n,activeTool:r}){let i=S(),a=(0,F.useMemo)(()=>(e||[]).map(e=>{let t=Number(e.totalCalls)||0,n=Number(e.blockedCalls)||0,r=Number(e.successCalls)||0,i=t-n;return{...e,key:e.toolName,displayName:W(e.toolName),rate:i>0?r/i:null}}),[e]),o=[{title:i(`mcpMonitor.columnTool`,null,`工具`),dataIndex:`displayName`,render:(e,t)=>(0,Z.jsx)(`button`,{type:`button`,className:`mcp-monitor-tool-link ${r&&r===t.toolName?`mcp-monitor-link-active`:``}`,onClick:()=>n?.(t.toolName),children:e||i(`mcpMonitor.unknownTool`,null,`未知工具`)})},{title:i(`mcpMonitor.columnCalls`,null,`调用`),dataIndex:`totalCalls`,width:90,render:e=>e??0},{title:i(`mcpMonitor.successColumn`,null,`成功`),dataIndex:`successCalls`,width:90,render:e=>e??0},{title:i(`mcpMonitor.failedColumn`,null,`失败`),dataIndex:`failedCalls`,width:90,render:e=>(0,Z.jsx)(`span`,{className:e>0?`mcp-monitor-danger`:void 0,children:e??0})},{title:i(`mcpMonitor.blockedColumn`,null,`拦截`),dataIndex:`blockedCalls`,width:90,render:e=>e?(0,Z.jsx)Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,U as c,W as l,f as u,ot as d,st as f,v as p,w as m,x as h,z as g}from"./semi-Dpcldp_F.js";import{D as _,E as v,F as y,I as b,O as x,P as S,S as ee,_ as C,a as w,b as T,d as E,g as D,i as te,l as O,m as k,n as ne,o as A,p as re,r as ie,s as j,u as M,x as N,y as P}from"./index-BMTtTYg1.js";var F=e(t(),1),I=[`completed`,`running`,`queued`,`failed`,`blocked`,`hard_timeout`,`cancelled`,`orphaned`],L={pending:`statusPending`,queued:`statusQueued`,running:`statusRunning`,completed:`statusCompleted`,failed:`statusFailed`,blocked:`statusBlocked`,cancelled:`statusCancelled`,hard_timeout:`statusHardTimeout`,orphaned:`statusOrphaned`},R={pending:`等待中`,queued:`排队中`,running:`执行中`,completed:`已完成`,failed:`失败`,blocked:`已拦截`,cancelled:`已终止`,hard_timeout:`执行超时`,orphaned:`孤儿任务`},z={completed:`green`,running:`blue`,queued:`amber`,failed:`red`,blocked:`orange`,hard_timeout:`red`,cancelled:`grey`,orphaned:`grey`};function B(e){return String(e||``).trim().toLowerCase()}function V(e,t){let n=B(t),r=L[n];return r?e(`mcpMonitor.${r}`,null,R[n]||n):t||`—`}function H(e){return z[B(e)]||`grey`}function U(e){return B(e)===`running`}function W(e){let t=String(e||``).trim();return t?t.includes(`::`)?t.replace(/::/g,`__`):t:``}function G(e){if(!e)return null;let t=Number(e.duration);if(Number.isFinite(t)&&t>0)return t/1e6;let n=e.startTime?new Date(e.startTime).getTime():NaN,r=e.endTime?new Date(e.endTime).getTime():NaN;return Number.isFinite(n)&&Number.isFinite(r)&&r>=n?r-n:null}function K(e){let t=Number(e);if(!Number.isFinite(t)||t<0)return`—`;if(t<1e3)return`${Math.round(t)} ms`;if(t<6e4)return`${(t/1e3).toFixed(2)} s`;let n=Math.floor(t/6e4),r=Math.round(t%6e4/1e3);return n<60?`${n} 分 ${r} 秒`:`${Math.floor(n/60)} 小时 ${n%60} 分`}function q(e){if(!e)return null;let t=(Number(e.totalCalls)||0)-(Number(e.blockedCalls)||0);return t<=0?null:(Number(e.successCalls)||0)/t}function J(e,t=1){return e==null||!Number.isFinite(Number(e))?`—`:`${(Number(e)*100).toFixed(t)}%`}function ae(e){let t=(e||[]).map(G).filter(e=>Number.isFinite(e)&&e>=0);return t.length?t.reduce((e,t)=>e+t,0)/t.length:null}function Y(e,t){let n=new Date(e);if(!Number.isFinite(n.getTime()))return``;let r=e=>String(e).padStart(2,`0`),i=`${r(n.getMonth()+1)}-${r(n.getDate())}`;return t===`30d`?i:t===`7d`?`${i} ${r(n.getHours())}h`:`${r(n.getHours())}:00`}function X(e,t){let n=e?.t?new Date(e.t).toLocaleString(`zh-CN`,{hour12:!1}):`—`;return t(`mcpMonitor.timelineTooltip`,{time:n,total:e?.total||0,failed:e?.failed||0,blocked:e?.blocked||0},`${n} 总调用 ${e?.total||0},失败 ${e?.failed||0},拦截 ${e?.blocked||0}`)}var Z=e(n(),1);function oe({summary:e,loading:t,avgMs:n=null,avgSamples:r=0}){let i=S(),a=q(e);return(0,Z.jsx)(C,{columns:4,metrics:[{id:`calls`,label:i(`mcpMonitor.totalCalls`,null,`调用次数`),value:e?e.totalCalls??0:`—`,detail:e?i(`mcpMonitor.statsFromAllTools`,null,`全部工具累计,含已拦截调用`):void 0,loading:t},{id:`rate`,label:i(`mcpMonitor.successRate`,null,`成功率`),value:J(a),detail:e?`${i(`common.ok`,null,`成功`)} ${e.successCalls??0} / ${i(`mcpMonitor.failedColumn`,null,`失败`)} ${e.failedCalls??0}`:void 0,tone:a===null?void 0:a>=.95?`success`:a>=.8?`warning`:`danger`,loading:t},{id:`avg`,label:`平均耗时`,value:n===null?`—`:K(n),detail:r>0?`按当前页 ${r} 条计时记录估算`:`当前页暂无可计时的执行记录`,loading:t},{id:`failed`,label:i(`mcpMonitor.failedMetric`,null,`失败数`),value:e?e.failedCalls??0:`—`,detail:e?`${i(`mcpMonitor.blockedCount`,{n:e.blockedCalls??0},`安全拦截 ${e.blockedCalls??0}`)} · ${i(`mcpMonitor.lastCall`,null,`最近调用`)} ${e.lastCallTime?v(e.lastCallTime):`—`}`:void 0,tone:e&&e.failedCalls>0?`danger`:void 0,loading:t}]})}function se({topTools:e,loading:t,onFilterTool:n,activeTool:r}){let i=S(),a=(0,F.useMemo)(()=>(e||[]).map(e=>{let t=Number(e.totalCalls)||0,n=Number(e.blockedCalls)||0,r=Number(e.successCalls)||0,i=t-n;return{...e,key:e.toolName,displayName:W(e.toolName),rate:i>0?r/i:null}}),[e]),o=[{title:i(`mcpMonitor.columnTool`,null,`工具`),dataIndex:`displayName`,render:(e,t)=>(0,Z.jsx)(`button`,{type:`button`,className:`mcp-monitor-tool-link ${r&&r===t.toolName?`mcp-monitor-link-active`:``}`,onClick:()=>n?.(t.toolName),children:e||i(`mcpMonitor.unknownTool`,null,`未知工具`)})},{title:i(`mcpMonitor.columnCalls`,null,`调用`),dataIndex:`totalCalls`,width:90,render:e=>e??0},{title:i(`mcpMonitor.successColumn`,null,`成功`),dataIndex:`successCalls`,width:90,render:e=>e??0},{title:i(`mcpMonitor.failedColumn`,null,`失败`),dataIndex:`failedCalls`,width:90,render:e=>(0,Z.jsx)(`span`,{className:e>0?`mcp-monitor-danger`:void 0,children:e??0})},{title:i(`mcpMonitor.blockedColumn`,null,`拦截`),dataIndex:`blockedCalls`,width:90,render:e=>e?(0,Z.jsx)Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{At as r,Dt as i,F as a,H as o,L as s,M as c,N as l,W as u,c as d,i as f,lt as p,st as m,v as h}from"./semi-Dpcldp_F.js";import{E as g,F as _,I as v,P as y,a as b,b as x,c as S,l as C,m as w,n as T,p as E,s as D,x as O,y as k}from"./index-gBcdNgHq.js";var A=e(t(),1),j=e(n(),1),M=[[`project`,`项目`],[`conversation`,`会话`],[`asset`,`资产`],[`vulnerability`,`漏洞`],[`batch_task`,`批量任务`]];function N({users:e,onCancel:t,onSaved:n}){let r=(0,A.useId)(),[i,c]=(0,A.useState)(M[0][0]),[l,d]=(0,A.useState)(``),[p,m]=(0,A.useState)(0),[g,_]=(0,A.useState)([]),[y,x]=(0,A.useState)(null),[w,E]=(0,A.useState)(!1),D=T(l,250),k=b(async()=>({type:i,q:D,offset:p,payload:await v.get(`/rbac/resources`,{type:i,q:D,limit:20,offset:p})}),[i,D,p]),N=k.data?.type===i&&k.data.q===D&&k.data.offset===p?k.data.payload:null,P=Array.isArray(N?.resources)?N.resources:[],F=new Map([...g,...P.map(e=>[e.id,e.label||e.id])]);return(0,j.jsx)(S,{visible:!0,title:`新增资源授权`,width:560,closable:!w,maskClosable:!w,closeOnEsc:!w,onCancel:t,formId:r,okText:`保存授权`,confirmLoading:w,cancelButtonProps:{disabled:w},children:(0,j.jsxs)(f,{id:r,onSubmit:async e=>{if(w)return;x(null);let t=String(e.ids||``).split(/[\s,,;;]+/).filter(Boolean),r=[...new Set([...g.map(([e])=>e),...t])];if(!r.length||r.length>100)x(Error(`请选择或输入 1 至 100 个资源 ID`));else{E(!0);try{await v.post(`/rbac/resource-assignments`,{user_id:e.user_id,resource_type:i,resource_ids:r}),O(`资源授权已保存`),n()}catch(e){x(e)}finally{E(!1)}}},initValues:{resource_type:i},children:[(0,j.jsx)(f.Select,{field:`user_id`,label:`用户`,filter:!0,optionList:e.map(e=>({value:e.id,label:e.display_name||e.username})),rules:[{required:!0,message:`请选择用户`}]}),(0,j.jsx)(f.Select,{field:`resource_type`,label:`资源类型`,optionList:M.map(([e,t])=>({value:e,label:t})),onChange:e=>{c(e),_([]),d(``),m(0)}}),(0,j.jsx)(f.Slot,{label:`按名称或 ID 搜索`,children:(0,j.jsx)(o,{"aria-label":`搜索资源`,value:l,onChange:e=>{d(e),m(0)}})}),(0,j.jsxs)(f.Slot,{label:`选择资源`,children:[(0,j.jsxs)(a,{wrap:!0,children:[(0,j.jsx)(s,{size:`small`,disabled:p===0||k.loading,onClick:()=>m(e=>Math.max(0,e-20)),children:`上一页`}),(0,j.jsxs)(u.Text,{type:`tertiary`,children:[p+P.length,` / `,N?.total??`—`]}),(0,j.jsx)(s,{size:`small`,disabled:!N?.has_more||k.loading,onClick:()=>m(e=>e+20),children:`下一页`})]}),(0,j.jsx)(h,{multiple:!0,style:{width:`100%`,marginTop:8},loading:k.loading,value:g.map(([e])=>e),"aria-label":`选择资源`,optionList:[...F].map(([e,t])=>({value:e,label:t})),onChange:e=>_((e||[]).map(e=>[e,F.get(e)||e]))})]}),(0,j.jsx)(f.TextArea,{field:`ids`,label:`手动输入资源 ID`,placeholder:`多个 ID 用空格或换行分隔`,rows:2}),(0,j.jsx)(C,{error:y||k.error})]})})}var{Text:P}=u;function F({value:e=[],options:t,onChange:n}){let r=(0,A.useMemo)(()=>{let e=new Map;return t.forEach(t=>{let[n]=t.split(`:`);e.has(n)||e.set(n,[]),e.get(n).push(t)}),[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[t]);return(0,j.jsx)(`div`,{style:{maxHeight:320,overflow:`auto`,border:`1px solid var(--semi-color-border)`,borderRadius:8,padding:12},children:r.map(([t,r])=>(0,j.jsxs)(`div`,{style:{marginBottom:10},children:[(0,j.jsx)(P,{type:`tertiary`,style:{fontSize:12,textTransform:`uppercase`},children:t}),(0,j.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8,marginTop:4},children:r.map(t=>(0,j.jsx)(l,{checked:e.includes(t),onChange:r=>{let i=new Set(e);r.target.checked?i.add(t):i.delete(t),n([...i])},children:t.split(`:`)[1]},t))})]},t))})}function I(){let e=y(),{hasPermission:t}=_(),n=t(`rbac:write`),[o,l]=(0,A.useState)(`roles`),[u,h]=(0,A.useState)(null),[T,M]=(0,A.useState)(null),[I,L]=(0,A.useState)(!1),[R,z]=(0,A.useState)(!1),B=b(()=>v.get(`/rbac/metadata`),[]),V=b(()=>v.get(`/rbac/roles`),[]),H=b(()=>v.get(`/rbac/users`),[]),U=b(()=>v.get(`/rbac/resource-assignments`),[]),W=B.data?.permissions?Object.keys(B.data.permissions):[],G=Array.isArray(V.data?.roles)?V.data.roles:[],K=Array.isArray(H.data?.users)?H.data.users:[],q=Array.isArray(U.data?.assignments)?U.data.assignments:[],J=G.map(e=>({value:e.id,label:e.name})),Y=new Map(G.map(e=>[e.id,e.name])),X=new Map(K.map(e=>[e.id,e.display_name||e.username])),Z=async()=>{if(R||!u?.form)return;let e=await u.form.validate().catch(()=>null);if(e){z(!0);try{let t={name:e.name.trim(),description:e.description||``,scope:e.scope||``,permissions:u.permissions||[]};u.role?.id?await v.put(`/rbac/roles/${encodeURIComponent(u.role.id)}`,t):await v.post(`/rbac/roles`,t),O(`角色已保存`),h(null),V.reload(),B.reload()}catch(e){x(e,`保存角色失败`)}finally{z(!1)}}},Q=async()=>{if(R||!T?.form)return;let e=await T.form.validate().catch(()=>null);if(e){z(!0);try{let t={display_name:e.display_name||``,enabled:e.enabled!==!1,roles:e.roles||[]};T.user?.id?(e.password&&(tLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{At as r,Dt as i,F as a,H as o,L as s,M as c,N as l,W as u,c as d,i as f,lt as p,st as m,v as h}from"./semi-Dpcldp_F.js";import{E as g,F as _,I as v,P as y,a as b,b as x,c as S,l as C,m as w,n as T,p as E,s as D,x as O,y as k}from"./index-BMTtTYg1.js";var A=e(t(),1),j=e(n(),1),M=[[`project`,`项目`],[`conversation`,`会话`],[`asset`,`资产`],[`vulnerability`,`漏洞`],[`batch_task`,`批量任务`]];function N({users:e,onCancel:t,onSaved:n}){let r=(0,A.useId)(),[i,c]=(0,A.useState)(M[0][0]),[l,d]=(0,A.useState)(``),[p,m]=(0,A.useState)(0),[g,_]=(0,A.useState)([]),[y,x]=(0,A.useState)(null),[w,E]=(0,A.useState)(!1),D=T(l,250),k=b(async()=>({type:i,q:D,offset:p,payload:await v.get(`/rbac/resources`,{type:i,q:D,limit:20,offset:p})}),[i,D,p]),N=k.data?.type===i&&k.data.q===D&&k.data.offset===p?k.data.payload:null,P=Array.isArray(N?.resources)?N.resources:[],F=new Map([...g,...P.map(e=>[e.id,e.label||e.id])]);return(0,j.jsx)(S,{visible:!0,title:`新增资源授权`,width:560,closable:!w,maskClosable:!w,closeOnEsc:!w,onCancel:t,formId:r,okText:`保存授权`,confirmLoading:w,cancelButtonProps:{disabled:w},children:(0,j.jsxs)(f,{id:r,onSubmit:async e=>{if(w)return;x(null);let t=String(e.ids||``).split(/[\s,,;;]+/).filter(Boolean),r=[...new Set([...g.map(([e])=>e),...t])];if(!r.length||r.length>100)x(Error(`请选择或输入 1 至 100 个资源 ID`));else{E(!0);try{await v.post(`/rbac/resource-assignments`,{user_id:e.user_id,resource_type:i,resource_ids:r}),O(`资源授权已保存`),n()}catch(e){x(e)}finally{E(!1)}}},initValues:{resource_type:i},children:[(0,j.jsx)(f.Select,{field:`user_id`,label:`用户`,filter:!0,optionList:e.map(e=>({value:e.id,label:e.display_name||e.username})),rules:[{required:!0,message:`请选择用户`}]}),(0,j.jsx)(f.Select,{field:`resource_type`,label:`资源类型`,optionList:M.map(([e,t])=>({value:e,label:t})),onChange:e=>{c(e),_([]),d(``),m(0)}}),(0,j.jsx)(f.Slot,{label:`按名称或 ID 搜索`,children:(0,j.jsx)(o,{"aria-label":`搜索资源`,value:l,onChange:e=>{d(e),m(0)}})}),(0,j.jsxs)(f.Slot,{label:`选择资源`,children:[(0,j.jsxs)(a,{wrap:!0,children:[(0,j.jsx)(s,{size:`small`,disabled:p===0||k.loading,onClick:()=>m(e=>Math.max(0,e-20)),children:`上一页`}),(0,j.jsxs)(u.Text,{type:`tertiary`,children:[p+P.length,` / `,N?.total??`—`]}),(0,j.jsx)(s,{size:`small`,disabled:!N?.has_more||k.loading,onClick:()=>m(e=>e+20),children:`下一页`})]}),(0,j.jsx)(h,{multiple:!0,style:{width:`100%`,marginTop:8},loading:k.loading,value:g.map(([e])=>e),"aria-label":`选择资源`,optionList:[...F].map(([e,t])=>({value:e,label:t})),onChange:e=>_((e||[]).map(e=>[e,F.get(e)||e]))})]}),(0,j.jsx)(f.TextArea,{field:`ids`,label:`手动输入资源 ID`,placeholder:`多个 ID 用空格或换行分隔`,rows:2}),(0,j.jsx)(C,{error:y||k.error})]})})}var{Text:P}=u;function F({value:e=[],options:t,onChange:n}){let r=(0,A.useMemo)(()=>{let e=new Map;return t.forEach(t=>{let[n]=t.split(`:`);e.has(n)||e.set(n,[]),e.get(n).push(t)}),[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[t]);return(0,j.jsx)(`div`,{style:{maxHeight:320,overflow:`auto`,border:`1px solid var(--semi-color-border)`,borderRadius:8,padding:12},children:r.map(([t,r])=>(0,j.jsxs)(`div`,{style:{marginBottom:10},children:[(0,j.jsx)(P,{type:`tertiary`,style:{fontSize:12,textTransform:`uppercase`},children:t}),(0,j.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8,marginTop:4},children:r.map(t=>(0,j.jsx)(l,{checked:e.includes(t),onChange:r=>{let i=new Set(e);r.target.checked?i.add(t):i.delete(t),n([...i])},children:t.split(`:`)[1]},t))})]},t))})}function I(){let e=y(),{hasPermission:t}=_(),n=t(`rbac:write`),[o,l]=(0,A.useState)(`roles`),[u,h]=(0,A.useState)(null),[T,M]=(0,A.useState)(null),[I,L]=(0,A.useState)(!1),[R,z]=(0,A.useState)(!1),B=b(()=>v.get(`/rbac/metadata`),[]),V=b(()=>v.get(`/rbac/roles`),[]),H=b(()=>v.get(`/rbac/users`),[]),U=b(()=>v.get(`/rbac/resource-assignments`),[]),W=B.data?.permissions?Object.keys(B.data.permissions):[],G=Array.isArray(V.data?.roles)?V.data.roles:[],K=Array.isArray(H.data?.users)?H.data.users:[],q=Array.isArray(U.data?.assignments)?U.data.assignments:[],J=G.map(e=>({value:e.id,label:e.name})),Y=new Map(G.map(e=>[e.id,e.name])),X=new Map(K.map(e=>[e.id,e.display_name||e.username])),Z=async()=>{if(R||!u?.form)return;let e=await u.form.validate().catch(()=>null);if(e){z(!0);try{let t={name:e.name.trim(),description:e.description||``,scope:e.scope||``,permissions:u.permissions||[]};u.role?.id?await v.put(`/rbac/roles/${encodeURIComponent(u.role.id)}`,t):await v.post(`/rbac/roles`,t),O(`角色已保存`),h(null),V.reload(),B.reload()}catch(e){x(e,`保存角色失败`)}finally{z(!1)}}},Q=async()=>{if(R||!T?.form)return;let e=await T.form.validate().catch(()=>null);if(e){z(!0);try{let t={display_name:e.display_name||``,enabled:e.enabled!==!1,roles:e.roles||[]};T.user?.id?(e.password&&(tLine truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{W as r,i}from"./semi-Dpcldp_F.js";import{I as a,P as o,c as s,l as c,x as l}from"./index-gBcdNgHq.js";var u=e(t(),1),d=e(n(),1),{Text:f}=r,p=120,m=4e3;function h({visible:e,project:t,onCancel:n,onSaved:r}){let h=o(),g=(0,u.useId)(),[_,v]=(0,u.useState)(!1),[y,b]=(0,u.useState)(null),x=!!t?.id;return(0,u.useEffect)(()=>{b(null)},[e,t?.id]),(0,d.jsxs)(s,{visible:e,width:560,closable:!_,closeOnEsc:!_,onCancel:n,cancelButtonProps:{disabled:_},title:x?h(`projects.modalEditTitle`,null,`编辑项目`):h(`projects.modalNewTitle`,null,`新建项目`),formId:g,okText:x?h(`projects.saveChanges`,null,`保存修改`):h(`projects.createProject`,null,`创建项目`),confirmLoading:_,children:[(0,d.jsx)(f,{type:`tertiary`,size:`small`,children:x?h(`projects.modalEditSubtitle`,null,`修改项目名称与描述`):h(`projects.modalNewSubtitle`,null,`创建后可绑定对话,跨会话共享事实黑板`)}),(0,d.jsxs)(i,{id:g,onSubmit:async e=>{if(!_){v(!0),b(null);try{let n={name:e.name.trim(),description:(e.description||``).slice(0,m)},i=x?await a.put(`/projects/${t.id}`,n):await a.post(`/projects`,n);l(x?h(`projects.saved`,null,`已保存`):h(`projects.createProject`,null,`创建项目`)),r?.(i)}catch(e){b(e)}finally{v(!1)}}},initValues:{name:t?.name||``,description:t?.description||``},children:[(0,d.jsx)(i.Input,{id:`${g}-name`,field:`name`,maxLength:p,label:h(`projects.projectName`,null,`项目名称`),placeholder:h(`projects.projectNamePlaceholder`,null,`例如:某客户 Web 渗透`),rules:[{required:!0,whitespace:!0,message:h(`projects.enterProjectName`,null,`请输入项目名称`)}]}),(0,d.jsx)(i.TextArea,{id:`${g}-description`,field:`description`,rows:4,maxCount:m,label:h(`projects.projectDescription`,null,`项目描述`),placeholder:h(`projects.projectDescriptionPlaceholder`,null,`客户/任务备注、协作说明…`),extraText:h(`projects.descriptionLengthHint`,null,`仅供团队成员查阅,Agent 不会读取;需让 Agent 知晓的内容请写入事实黑板`)}),(0,d.jsx)(c,{error:y})]},`${e}-${t?.id||`new`}`)]})}export{h as t};
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{W as r,i}from"./semi-Dpcldp_F.js";import{I as a,P as o,c as s,l as c,x as l}from"./index-BMTtTYg1.js";var u=e(t(),1),d=e(n(),1),{Text:f}=r,p=120,m=4e3;function h({visible:e,project:t,onCancel:n,onSaved:r}){let h=o(),g=(0,u.useId)(),[_,v]=(0,u.useState)(!1),[y,b]=(0,u.useState)(null),x=!!t?.id;return(0,u.useEffect)(()=>{b(null)},[e,t?.id]),(0,d.jsxs)(s,{visible:e,width:560,closable:!_,closeOnEsc:!_,onCancel:n,cancelButtonProps:{disabled:_},title:x?h(`projects.modalEditTitle`,null,`编辑项目`):h(`projects.modalNewTitle`,null,`新建项目`),formId:g,okText:x?h(`projects.saveChanges`,null,`保存修改`):h(`projects.createProject`,null,`创建项目`),confirmLoading:_,children:[(0,d.jsx)(f,{type:`tertiary`,size:`small`,children:x?h(`projects.modalEditSubtitle`,null,`修改项目名称与描述`):h(`projects.modalNewSubtitle`,null,`创建后可绑定对话,跨会话共享事实黑板`)}),(0,d.jsxs)(i,{id:g,onSubmit:async e=>{if(!_){v(!0),b(null);try{let n={name:e.name.trim(),description:(e.description||``).slice(0,m)},i=x?await a.put(`/projects/${t.id}`,n):await a.post(`/projects`,n);l(x?h(`projects.saved`,null,`已保存`):h(`projects.createProject`,null,`创建项目`)),r?.(i)}catch(e){b(e)}finally{v(!1)}}},initValues:{name:t?.name||``,description:t?.description||``},children:[(0,d.jsx)(i.Input,{id:`${g}-name`,field:`name`,maxLength:p,label:h(`projects.projectName`,null,`项目名称`),placeholder:h(`projects.projectNamePlaceholder`,null,`例如:某客户 Web 渗透`),rules:[{required:!0,whitespace:!0,message:h(`projects.enterProjectName`,null,`请输入项目名称`)}]}),(0,d.jsx)(i.TextArea,{id:`${g}-description`,field:`description`,rows:4,maxCount:m,label:h(`projects.projectDescription`,null,`项目描述`),placeholder:h(`projects.projectDescriptionPlaceholder`,null,`客户/任务备注、协作说明…`),extraText:h(`projects.descriptionLengthHint`,null,`仅供团队成员查阅,Agent 不会读取;需让 Agent 知晓的内容请写入事实黑板`)}),(0,d.jsx)(c,{error:y})]},`${e}-${t?.id||`new`}`)]})}export{h as t};
@@ -1,4 +1,4 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,y as i}from"./react-QV7DAAIx.js";import{E as a,F as o,H as s,Ht as c,L as l,M as u,N as d,T as f,Tt as p,U as m,W as h,Wt as g,X as _,Xt as v,_ as y,_t as b,bt as x,c as S,f as C,ft as w,g as T,ht as E,it as D,lt as ee,ot as O,st as te,u as k,v as A,wt as j,x as M,xt as N}from"./semi-Dpcldp_F.js";import{E as P,F,I,P as L,_ as R,a as z,b as B,c as ne,d as re,f as ie,l as V,m as H,n as U,p as ae,s as oe,t as se,x as W,y as G}from"./index-gBcdNgHq.js";import{t as ce}from"./project-form-D2VoONj8.js";import{t as le}from"./AssetEditorModal-DNgfDOqO.js";var K=e(t(),1),q=[{value:`target`,label:`target(目标)`},{value:`auth`,label:`auth(认证)`},{value:`infra`,label:`infra(基础设施)`},{value:`business`,label:`business(业务)`},{value:`finding`,label:`finding(发现)`},{value:`chain`,label:`chain(攻击链)`},{value:`exploit`,label:`exploit(利用)`},{value:`poc`,label:`poc(POC)`},{value:`note`,label:`note(备注)`}],ue={target:`目标`,auth:`认证`,infra:`基础设施`,business:`业务`,finding:`发现`,chain:`攻击链`,exploit:`利用`,poc:`POC`,note:`备注`,vuln:`漏洞`,missing:`缺失`},de=[{value:`tentative`,label:`待确认`},{value:`confirmed`,label:`已确认`},{value:`deprecated`,label:`已废弃`}],fe={confirmed:{label:`已确认`,color:`green`},tentative:{label:`待确认`,color:`amber`},deprecated:{label:`已废弃`,color:`grey`}},pe=[{value:`active`,label:`进行中`},{value:`archived`,label:`已归档`}],J={target:`#2563eb`,auth:`#0891b2`,infra:`#0d9488`,finding:`#d97706`,chain:`#db2777`,exploit:`#7c3aed`,poc:`#7c3aed`,vulnerability:`#dc2626`,note:`#64748b`,missing:`#94a3b8`},me={target:`TARGET · 目标`,auth:`AUTH · 认证`,infra:`INFRA · 基础设施`,finding:`FINDING · 发现`,chain:`CHAIN · 攻击链`,exploit:`EXPLOIT · 利用`,poc:`POC · 验证`,vulnerability:`VULN · 漏洞`,note:`NOTE · 备注`,missing:`MISSING · 缺失`},he=[`discovered_on`,`depends_on`,`leads_to`,`enables`,`exploits`];function Y(e,t=`操作失败`){if(!e)return t;if(typeof e==`string`)return e;let n=e.payload;if(n&&typeof n==`object`){let e=n.error;if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=typeof e.message==`string`?e.message:``,n=typeof e.code==`string`?e.code:``;if(t)return n?`${t}(${n})`:t}if(typeof n.message==`string`&&n.message)return n.message}return typeof e.message==`string`&&e.message&&e.message!==`[object Object]`?e.message:t}function ge(e,t=`加载失败`){return e?{message:Y(e,t)}:null}function _e(e){return!Array.isArray(e)||!e.length?``:e.map(e=>`${e.edge_type||e.type||``}: ${e.source_fact_key||e.from||``}`.trim()).join(`
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,y as i}from"./react-QV7DAAIx.js";import{E as a,F as o,H as s,Ht as c,L as l,M as u,N as d,T as f,Tt as p,U as m,W as h,Wt as g,X as _,Xt as v,_ as y,_t as b,bt as x,c as S,f as C,ft as w,g as T,ht as E,it as D,lt as ee,ot as O,st as te,u as k,v as A,wt as j,x as M,xt as N}from"./semi-Dpcldp_F.js";import{E as P,F,I,P as L,_ as R,a as z,b as B,c as ne,d as re,f as ie,l as V,m as H,n as U,p as ae,s as oe,t as se,x as W,y as G}from"./index-BMTtTYg1.js";import{t as ce}from"./project-form-nknm1nA2.js";import{t as le}from"./AssetEditorModal-BbwbZZn2.js";var K=e(t(),1),q=[{value:`target`,label:`target(目标)`},{value:`auth`,label:`auth(认证)`},{value:`infra`,label:`infra(基础设施)`},{value:`business`,label:`business(业务)`},{value:`finding`,label:`finding(发现)`},{value:`chain`,label:`chain(攻击链)`},{value:`exploit`,label:`exploit(利用)`},{value:`poc`,label:`poc(POC)`},{value:`note`,label:`note(备注)`}],ue={target:`目标`,auth:`认证`,infra:`基础设施`,business:`业务`,finding:`发现`,chain:`攻击链`,exploit:`利用`,poc:`POC`,note:`备注`,vuln:`漏洞`,missing:`缺失`},de=[{value:`tentative`,label:`待确认`},{value:`confirmed`,label:`已确认`},{value:`deprecated`,label:`已废弃`}],fe={confirmed:{label:`已确认`,color:`green`},tentative:{label:`待确认`,color:`amber`},deprecated:{label:`已废弃`,color:`grey`}},pe=[{value:`active`,label:`进行中`},{value:`archived`,label:`已归档`}],J={target:`#2563eb`,auth:`#0891b2`,infra:`#0d9488`,finding:`#d97706`,chain:`#db2777`,exploit:`#7c3aed`,poc:`#7c3aed`,vulnerability:`#dc2626`,note:`#64748b`,missing:`#94a3b8`},me={target:`TARGET · 目标`,auth:`AUTH · 认证`,infra:`INFRA · 基础设施`,finding:`FINDING · 发现`,chain:`CHAIN · 攻击链`,exploit:`EXPLOIT · 利用`,poc:`POC · 验证`,vulnerability:`VULN · 漏洞`,note:`NOTE · 备注`,missing:`MISSING · 缺失`},he=[`discovered_on`,`depends_on`,`leads_to`,`enables`,`exploits`];function Y(e,t=`操作失败`){if(!e)return t;if(typeof e==`string`)return e;let n=e.payload;if(n&&typeof n==`object`){let e=n.error;if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=typeof e.message==`string`?e.message:``,n=typeof e.code==`string`?e.code:``;if(t)return n?`${t}(${n})`:t}if(typeof n.message==`string`&&n.message)return n.message}return typeof e.message==`string`&&e.message&&e.message!==`[object Object]`?e.message:t}function ge(e,t=`加载失败`){return e?{message:Y(e,t)}:null}function _e(e){return!Array.isArray(e)||!e.length?``:e.map(e=>`${e.edge_type||e.type||``}: ${e.source_fact_key||e.from||``}`.trim()).join(`
`)}var X=e(r(),1),{Text:ve}=h;function ye({value:e}){let t=fe[String(e||``).toLowerCase()]||{label:e||`—`,color:`grey`};return(0,X.jsx)(u,{size:`small`,color:t.color,children:t.label})}function be({projectId:e,canWrite:t,revision:n=0,onAddFact:r,onEditFact:i,onViewFact:a,onMutated:c}){let f=L(),[p,m]=(0,K.useState)(``),h=U(p,300),[g,_]=(0,K.useState)(`all`),[v,y]=(0,K.useState)(`all`),[b,x]=(0,K.useState)(!0),[S,C]=(0,K.useState)(!1),w=z(()=>I.get(`/projects/${e}/facts`,{limit:200,include_link_counts:`true`,exclude_deprecated:b?`true`:void 0,search:h.trim()||void 0,category:g===`all`?void 0:g,confidence:v===`all`?void 0:v,sparse_only:S?`true`:void 0}),[e,h,g,v,b,S,n]),E=(0,K.useMemo)(()=>Array.isArray(w.data)?w.data:[],[w.data]),D=async t=>{try{await I.post(`/projects/${e}/facts/deprecate`,{fact_key:t.fact_key}),W(f(`projects.saved`,null,`已保存`)),c?c():w.reload({silent:!0})}catch(e){B(Y(e,f(`projects.operationFailed`,null,`操作失败`)))}},k=async t=>{try{await I.post(`/projects/${e}/facts/restore`,{fact_key:t.fact_key,confidence:`tentative`}),W(f(`projects.saved`,null,`已保存`)),c?c():w.reload({silent:!0})}catch(e){B(Y(e,f(`projects.operationFailed`,null,`操作失败`)))}},j=t=>{G({title:f(`projects.deleteForeverTitle`,null,`永久删除`),content:f(`projects.confirmDeleteFact`,null,`删除该事实?`),okText:f(`common.delete`,null,`删除`),onOk:async()=>{try{await I.del(`/projects/${e}/facts/${t.id}`),W(f(`common.delete`,null,`删除`)),c?c():w.reload({silent:!0})}catch(e){B(Y(e,f(`projects.operationFailed`,null,`操作失败`)))}}})},M=[{title:`fact_key`,dataIndex:`fact_key`,width:230,render:(e,t)=>(0,X.jsxs)(`div`,{className:`project-fact-key`,children:[(0,X.jsx)(`code`,{className:`project-fact-key-chip`,title:e,children:e}),(0,X.jsxs)(`div`,{className:`project-fact-key-meta`,children:[t.pinned&&(0,X.jsx)(u,{size:`small`,color:`blue`,type:`light`,children:f(`projects.pinned`,null,`置顶`)}),t.related_vulnerability_id&&(0,X.jsx)(u,{size:`small`,color:`violet`,type:`light`,title:t.related_vulnerability_id,children:f(`projects.relatedVulnIdTitle`,null,`关联漏洞 ID`)})]})]})},{title:f(`projects.category`,null,`分类`),dataIndex:`category`,width:108,render:e=>(0,X.jsx)(u,{size:`small`,color:`cyan`,type:`light`,children:ue[String(e||``).toLowerCase()]||e||`—`})},{title:f(`projects.summary`,null,`摘要`),dataIndex:`summary`,render:(e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`project-cell-ellipsis project-link-button`,title:e,onClick:()=>a?.(t.fact_key),children:e||`—`})},{title:f(`projects.linksColumn`,null,`关系`),dataIndex:`link_counts`,width:92,render:e=>{let t=e?.outgoing||0,n=e?.incoming||0;return!t&&!n?(0,X.jsx)(ve,{type:`tertiary`,children:`—`}):(0,X.jsxs)(`span`,{className:`project-link-counts`,title:f(`projects.linkCountsTitle`,null,`出边数 / 入边数`),children:[`↑`,t,` ↓`,n]})}},{title:f(`projects.confidence`,null,`置信度`),dataIndex:`confidence`,width:92,render:e=>(0,X.jsx)(ye,{value:e})},{title:f(`projects.updated`,null,`更新`),dataIndex:`updated_at`,width:158,render:e=>(0,X.jsx)(ve,{size:`small`,children:P(e)})},{title:f(`common.actions`,null,`操作`),dataIndex:`id`,width:224,render:(e,n)=>{let r=String(n.confidence||``).toLowerCase()===`deprecated`;return(0,X.jsxs)(o,{spacing:2,wrap:!0,children:[(0,X.jsx)(l,{size:`small`,theme:`borderless`,onClick:()=>a?.(n.fact_key),children:f(`projects.details`,null,`详情`)}),(0,X.jsx)(l,{size:`small`,theme:`borderless`,disabled:!t,onClick:()=>i?.(n.fact_key),children:f(`common.edit`,null,`编辑`)}),r?(0,X.jsx)(l,{size:`small`,theme:`borderless`,disabled:!t,onClick:()=>k(n),children:f(`projects.restore`,null,`恢复`)}):(0,X.jsx)(T,{title:f(`projects.confirmDeprecateFact`,{factKey:n.fact_key},`将事实 ${n.fact_key} 标记为已废弃?`),onConfirm:()=>D(n),disabled:!t,children:(0,X.jsx)(l,{size:`small`,theme:`borderless`,disabled:!t,title:f(`projects.deprecateTitle`,null,`标记为已废弃`),children:f(`projects.deprecate`,null,`废弃`)})}),(0,X.jsx)(l,{size:`small`,theme:`borderless`,type:`danger`,disabled:!t,onClick:()=>j(n),children:f(`common.delete`,null,`删除`)})]})}}];return(0,X.jsxs)(H,{title:f(`projects.tabFacts`,null,`事实黑板`),description:f(`projects.factToolbarHint`,null,`索引仅含 key 与摘要;攻击链 / POC 写在 body,Agent 通过 get_project_fact 复现`),extra:(0,X.jsxs)(o,{children:[(0,X.jsx)(l,{icon:(0,X.jsx)(te,{}),theme:`borderless`,loading:w.loading,onClick:()=>{c?c():w.reload()}}),(0,X.jsx)(l,{type:`primary`,icon:(0,X.jsx)(ee,{}),disabled:!t,onClick:r,children:f(`projects.addFact`,null,`添加事实`)})]}),children:[(0,X.jsx)(V,{error:ge(w.error),onRetry:w.reload}),(0,X.jsxs)(`div`,{className:`project-toolbar`,children:[(0,X.jsx)(s,{prefix:(0,X.jsx)(O,{}),value:p,showClear:!0,"aria-label":f(`projects.searchFactsSr`,null,`搜索事实`),placeholder:f(`projects.searchFactsPlaceholder`,null,`搜索 key、摘要、body…`),onChange:e=>m(e),style:{width:260}}),(0,X.j Line truncated
"targets": ["https://example.com"]
}`,onChange:e=>m({scope_json:e})}),(0,X.jsx)(Q,{type:`tertiary`,size:`small`,children:c(`projects.scopeFootnote`,null,`支持 targets、exclude、notes 等字段,留空表示不限制范围。`)})]}),(0,X.jsx)(a,{margin:`12px`}),(0,X.jsxs)(`div`,{className:`project-danger-zone`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(Q,{strong:!0,children:c(`projects.dangerZoneTitle`,null,`危险操作`)}),(0,X.jsx)(`div`,{children:(0,X.jsx)(Q,{type:`tertiary`,size:`small`,children:c(`projects.dangerZoneHint`,null,`归档后需在列表勾选「显示已归档」才能查看;删除将清除全部事实且不可恢复。`)})})]}),(0,X.jsxs)(o,{children:[(0,X.jsx)(l,{disabled:!t,onClick:()=>{G({title:v?c(`projects.restoreProjectActive`,null,`恢复为进行中`):c(`projects.archiveProject`,null,`归档`),content:v?c(`projects.confirmRestoreProjectActive`,null,`恢复为 active?`):c(`projects.confirmArchiveProject`,null,`归档后默认不再出现在活跃列表,是否继续?`),okText:c(`common.confirm`,null,`确认`),danger:!v,onOk:async()=>{try{await I.put(`/projects/${e.id}`,{status:v?`active`:`archived`}),W(c(`projects.saved`,null,`已保存`)),r?.()}catch(e){B(Y(e,c(`projects.operationFailed`,null,`操作失败`)))}}})},children:v?c(`projects.restoreProjectActive`,null,`恢复为进行中`):c(`projects.archiveProject`,null,`归档`)}),(0,X.jsx)(l,{type:`danger`,disabled:!n,onClick:()=>{G({title:c(`projects.deleteProject`,null,`删除项目`),content:c(`projects.confirmDeleteProject`,null,`确定删除该项目?事实将一并删除,对话将解除绑定。`),okText:c(`common.delete`,null,`删除`),onOk:async()=>{try{await I.del(`/projects/${e.id}`),W(c(`projects.deleteProject`,null,`删除项目`)),i?.(e.id)}catch(e){B(Y(e,c(`projects.deleteFailed`,null,`删除失败`)))}}})},children:c(`projects.deleteProject`,null,`删除项目`)})]})]})]}):(0,X.jsx)(H,{title:c(`projects.tabSettings`,null,`设置`),children:(0,X.jsx)(Q,{type:`tertiary`,children:c(`projects.selectOrCreateTitle`,null,`选择或创建项目`)})})}var{Text:$}=h,Ke={fact_key:``,category:`note`,summary:``,body:``,confidence:`tentative`,pinned:!1,related_vulnerability_id:``,links_text:``};function qe({visible:e,projectId:t,factKey:n,onCancel:r,onSaved:i}){let a=L(),[o,c]=(0,K.useState)(Ke),[l,u]=(0,K.useState)(q),[f,p]=(0,K.useState)(!1),[m,h]=(0,K.useState)(!1),[g,_]=(0,K.useState)(``),v=!!n;(0,K.useEffect)(()=>{if(!e||(c(Ke),u(q),_(``),p(!1),h(!1),!n))return;let r=!1;return p(!0),I.get(`/projects/${t}/facts`,{fact_key:n,include_links:`true`}).then(e=>{if(r||!e)return;let t=e.category||`note`;q.some(e=>e.value===t)||u([...q,{value:t,label:`${t}(自定义)`}]),_(e.id||``),c({fact_key:e.fact_key||n,category:t,summary:e.summary||``,body:e.body||``,confidence:(e.confidence||`tentative`).toLowerCase(),pinned:!!e.pinned,related_vulnerability_id:e.related_vulnerability_id||``,links_text:_e(e.incoming_links)})}).catch(e=>{r||B(Y(e,a(`projects.loadFactFailed`,null,`加载事实失败`)))}).finally(()=>{r||p(!1)}),()=>{r=!0}},[e,t,n]);let y=e=>c(t=>({...t,...e})),b=(0,K.useMemo)(()=>he.join(`、`),[]);return(0,X.jsxs)(ne,{visible:e,title:v?a(`projects.editFact`,null,`编辑事实`):a(`projects.addFact`,null,`添加事实`),onCancel:r,onOk:async()=>{let e=o.fact_key.trim(),n=o.summary.trim();if(!e||!n){B(a(`projects.factKeySummaryRequired`,null,`fact_key 与 summary 必填`));return}let r={fact_key:e,category:o.category||`note`,summary:n,body:o.body,confidence:o.confidence||`tentative`,pinned:!!o.pinned,related_vulnerability_id:o.related_vulnerability_id.trim(),links_text:o.links_text};if(v&&!g)B(a(`projects.loadFactFailed`,null,`加载事实失败`));else{h(!0);try{v&&g?await I.put(`/projects/${t}/facts/${g}`,r):await I.post(`/projects/${t}/facts`,r),W(a(`projects.saved`,null,`已保存`)),i?.()}catch(e){B(Y(e,a(`projects.saveFailed`,null,`保存失败`)))}finally{h(!1)}}},okText:v?a(`projects.saveChanges`,null,`保存修改`):a(`projects.saveFact`,null,`保存事实`),cancelText:a(`common.cancel`,null,`取消`),confirmLoading:m,width:720,children:[(0,X.jsx)($,{type:`tertiary`,size:`small`,children:a(`projects.factModalSubtitle`,null,`摘要注入黑板索引;body 沉淀攻击链与 POC,供审计复现(与漏洞记录分工)`)}),(0,X.jsxs)(`div`,{className:`project-form-grid`,children:[(0,X.jsxs)(`div`,{className:`project-form-field`,children:[(0,X.jsx)($,{strong:!0,size:`small`,children:`fact_key`}),(0,X.jsx)(s,{value:o.fact_key,disabled:f,placeholder:`target/primary_domain`,onChange:e=>y({fact_key:e})})]}),(0,X.jsxs)(`div`,{className:`project-form-field`,children:[(0,X.jsx)($,{strong:!0,size:`small`,children:a(`projects.category`,null,`分类`)}),(0,X.jsx)(A,{value:o.category,optionList:l,onChange:e=>y({category:e}),style:{width:`100%`}})]})]}),(0,X.jsxs)(`div`,{className:`project-form-field`,children:[(0,X.jsx)($,{strong:!0,size:`small`,children:a(`projects.summary`,null,`摘要`)}),(0,X.jsx)(s,{value:o.summary,placeholder:a(`projLine truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,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,l as m,m as h,p as g,s as _}from"./index-gBcdNgHq.js";var v=e(t(),1),y=e(n(),1),{Text:b}=s;function x(){let e=f(),{hasPermission:t}=u(),n=t(`roles:write roles:delete`),[s,x]=(0,v.useState)(``),S=p(()=>d.get(`/roles`),[]),C=(Array.isArray(S.data?.roles)?S.data.roles:[]).filter(e=>{if(!s)return!0;let t=s.toLowerCase();return[e.name,e.description].some(e=>String(e||``).toLowerCase().includes(t))});return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(g,{title:e(`roles.title`,null,`角色管理`),description:`角色定义对话的系统提示词、可用工具与绑定工作流。`,extra:(0,y.jsxs)(r,{children:[(0,y.jsx)(a,{icon:(0,y.jsx)(l,{}),onClick:()=>S.reload(),loading:S.loading,children:`刷新`}),n&&(0,y.jsx)(a,{href:`/classic#roles-management`,children:`管理已有角色配置`})]})}),(0,y.jsxs)(h,{title:`角色(${C.length})`,children:[(0,y.jsx)(m,{error:S.error,onRetry:()=>S.reload()}),(0,y.jsx)(_,{columns:[{title:`角色`,dataIndex:`name`,render:(e,t)=>(0,y.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,y.jsxs)(r,{children:[(0,y.jsx)(b,{strong:!0,children:e}),t.enabled===!1&&(0,y.jsx)(o,{size:`small`,color:`grey`,children:`已停用`})]}),(0,y.jsx)(b,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:t.description||`—`})]})},{title:`工具`,dataIndex:`tools`,width:260,render:e=>Array.isArray(e)&&e.length?(0,y.jsxs)(r,{wrap:!0,spacing:4,children:[e.slice(0,4).map(e=>(0,y.jsx)(o,{size:`small`,children:e},e)),e.length>4&&(0,y.jsxs)(b,{type:`tertiary`,children:[`+`,e.length-4]})]}):(0,y.jsx)(b,{type:`tertiary`,children:`未绑定`})},{title:`工作流`,dataIndex:`workflow_id`,width:160,render:e=>e||`—`}],dataSource:C,rowKey:`name`,loading:S.loading,pagination:{pageSize:20},toolbar:(0,y.jsx)(i,{prefix:(0,y.jsx)(c,{}),value:s,onChange:x,placeholder:`搜索角色名称`,style:{width:260}})})]})]})}export{x as default};
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,ot as c,st as l}from"./semi-Dpcldp_F.js";import{F as u,I as d,P as f,a as p,l as m,m as h,p as g,s as _}from"./index-BMTtTYg1.js";var v=e(t(),1),y=e(n(),1),{Text:b}=s;function x(){let e=f(),{hasPermission:t}=u(),n=t(`roles:write roles:delete`),[s,x]=(0,v.useState)(``),S=p(()=>d.get(`/roles`),[]),C=(Array.isArray(S.data?.roles)?S.data.roles:[]).filter(e=>{if(!s)return!0;let t=s.toLowerCase();return[e.name,e.description].some(e=>String(e||``).toLowerCase().includes(t))});return(0,y.jsxs)(`div`,{children:[(0,y.jsx)(g,{title:e(`roles.title`,null,`角色管理`),description:`角色定义对话的系统提示词、可用工具与绑定工作流。`,extra:(0,y.jsxs)(r,{children:[(0,y.jsx)(a,{icon:(0,y.jsx)(l,{}),onClick:()=>S.reload(),loading:S.loading,children:`刷新`}),n&&(0,y.jsx)(a,{href:`/classic#roles-management`,children:`管理已有角色配置`})]})}),(0,y.jsxs)(h,{title:`角色(${C.length})`,children:[(0,y.jsx)(m,{error:S.error,onRetry:()=>S.reload()}),(0,y.jsx)(_,{columns:[{title:`角色`,dataIndex:`name`,render:(e,t)=>(0,y.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,y.jsxs)(r,{children:[(0,y.jsx)(b,{strong:!0,children:e}),t.enabled===!1&&(0,y.jsx)(o,{size:`small`,color:`grey`,children:`已停用`})]}),(0,y.jsx)(b,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:t.description||`—`})]})},{title:`工具`,dataIndex:`tools`,width:260,render:e=>Array.isArray(e)&&e.length?(0,y.jsxs)(r,{wrap:!0,spacing:4,children:[e.slice(0,4).map(e=>(0,y.jsx)(o,{size:`small`,children:e},e)),e.length>4&&(0,y.jsxs)(b,{type:`tertiary`,children:[`+`,e.length-4]})]}):(0,y.jsx)(b,{type:`tertiary`,children:`未绑定`})},{title:`工作流`,dataIndex:`workflow_id`,width:160,render:e=>e||`—`}],dataSource:C,rowKey:`name`,loading:S.loading,pagination:{pageSize:20},toolbar:(0,y.jsx)(i,{prefix:(0,y.jsx)(c,{}),value:s,onChange:x,placeholder:`搜索角色名称`,style:{width:260}})})]})]})}export{x as default};
@@ -1,19 +0,0 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,_ as n,t as r,y as i}from"./react-QV7DAAIx.js";import{A as a,F as o,H as s,I as c,L as l,M as u,O as d,Ot as f,Qt as p,W as m,Z as h,c as g,f as _,h as ee,m as v,ot as y,p as b,s as x,st as te,u as S,v as C,x as w,z as T}from"./semi-Dpcldp_F.js";import{A as E,D,E as O,F as k,I as A,L as j,M,N,P,R as F,S as I,T as L,_ as R,a as z,b as ne,d as B,j as re,l as V,m as H,n as ie,o as U,p as W,s as ae,u as G,x as oe,y as se}from"./index-gBcdNgHq.js";import{n as ce,r as le,t as K}from"./model-channel-mQ6lfvSO.js";var q=e(t(),1),J=class extends Error{constructor(e,t){super(t?`第 ${t} 行:${e}`:e),this.name=`YamlError`,this.line=t||0}},ue=/^(?:[-?:,\[\]{}#&*!|>'"%@`]|.*[:\s]$|.*\s#|.*[\n\r\t])/,de=/^(?:true|false|null|~|yes|no|on|off|[-+]?(?:\d+|\d*\.\d+)(?:[eE][-+]?\d+)?)$/i;function Y(e){let t=String(e);return!(t===``||de.test(t)||/^[-+]?(?:\d+\.\d*|\.\d+|\d+)(?:[eE][-+]?\d+)?$/.test(t)||ue.test(t)||/^(?:\s)|:(?:\s|$)|[\r\n\t]/.test(t)||/[,[\]{}]/.test(t)||/^[!&*|>@`]/.test(t))}function fe(e){return JSON.stringify(String(e))}function pe(e){let t=String(e);return Y(t)?t:fe(t)}function me(e){if(e==null)return`null`;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return Number.isFinite(e)?String(e):fe(String(e));let t=String(e);return Y(t)?t:fe(t)}function he(e){return e==null||[`string`,`number`,`boolean`].includes(typeof e)}function ge(e,t,n,r){let i=` `.repeat(n),a=pe(e);if(he(t))r.push(`${i}${a}: ${me(t)}`);else if(Array.isArray(t)){if(!t.length){r.push(`${i}${a}: []`);return}r.push(`${i}${a}:`),ye(t,n+2,r)}else Object.entries(t).length?(r.push(`${i}${a}:`),_e(t,n+2,r)):r.push(`${i}${a}: {}`)}function _e(e,t,n){for(let[r,i]of Object.entries(e))ge(r,i,t,n)}function ve(e,t,n){let r=` `.repeat(t);if(he(e)){n.push(`${r}- ${me(e)}`);return}if(Array.isArray(e)){if(!e.length){n.push(`${r}- []`);return}n.push(`${r}-`),ye(e,t+2,n);return}let i=Object.entries(e);if(!i.length){n.push(`${r}- {}`);return}let[a,o]=i[0],s=i.slice(1);he(o)?n.push(`${r}- ${pe(a)}: ${me(o)}`):(n.push(`${r}-`),ge(a,o,t+2,n));for(let[e,r]of s)ge(e,r,t+2,n)}function ye(e,t,n){for(let r of e)ve(r,t,n)}function be(e,{header:t}={}){let n=[];if(t){for(let e of String(t).replace(/\r\n?/g,`
`).split(`
`))n.push(`# ${e}`.trimEnd());n.length&&n.push(``)}return he(e)?(n.push(me(e)),`${n.join(`
`)}\n`):Array.isArray(e)?(e.length?ye(e,0,n):n.push(`[]`),`${n.join(`
`)}\n`):!e||!Object.keys(e).length?(n.push(`{}`),`${n.join(`
`)}\n`):(_e(e,0,n),`${n.join(`
`)}\n`)}function xe(e){let t=``;for(let n=0;n<e.length;n+=1){let r=e[n];if(t){if(r===`\\`&&t===`"`){n+=1;continue}r===t&&(t=``)}else if(r===`"`||r===`'`)t=r;else if(r===`#`&&(n===0||/\s/.test(e[n-1])))return e.slice(0,n).trimEnd()}return e.trimEnd()}function Se(e,t,n){let r=e[t],i=``,a=t+1;for(;a<e.length;){let t=e[a];if(r===`'`){if(t===`'`){if(e[a+1]===`'`){i+=`'`,a+=2;continue}return{value:i,end:a+1}}i+=t,a+=1}else if(t===`\\`){let t=e[a+1],n={n:`
`,r:`\r`,t:` `,'"':`"`,"\\":`\\`,"/":`/`,0:`\0`,b:`\b`,f:`\f`};if(t===`u`){i+=String.fromCharCode(parseInt(e.slice(a+2,a+6),16)),a+=6;continue}if(t in n){i+=n[t],a+=2;continue}i+=t||``,a+=2}else{if(t===`"`)return{value:i,end:a+1};i+=t,a+=1}}throw new J(`字符串引号未闭合`,n)}function Ce(e,t){let n=e.trimEnd();if(n.startsWith(`"`)||n.startsWith(`'`)){let e=Se(n,0,t),r=n.slice(e.end).trimStart();if(!r.startsWith(`:`))throw new J(`键名后缺少冒号`,t);return{key:e.value,rest:xe(r.slice(1).trim())}}for(let e=0;e<n.length;e+=1)if(n[e]===`:`&&(e+1>=n.length||/\s/.test(n[e+1]))){let r=n.slice(0,e).trim();if(!r)throw new J(`键名为空`,t);if(/^[&*!|>@`]/.test(r))throw new J(`不支持的键名写法:${r}`,t);return{key:r,rest:xe(n.slice(e+1).trim())}}throw new J(`缺少冒号,无法识别为键值`,t)}function we(e,t){if(e.startsWith(`"`)||e.startsWith(`'`)){let{end:n}=Se(e,0,t);return e.slice(n).trimStart().startsWith(`:`)}if(/^[\[{]/.test(e))return!1;for(let t=0;t<e.length;t+=1)if(e[t]===`:`&&(t+1>=e.length||/\s/.test(e[t+1])))return!0;return!1}function Te(e){let t=e.trim();return t===``||t===`~`||/^null$/i.test(t)?null:/^true$/i.test(t)?!0:/^false$/i.test(t)?!1:/^[-+]?\d+$/.test(t)&&t.length<16||/^[-+]?(?:\d+\.\d*|\.\d+|\d+)(?:[eE][-+]?\d+)?$/.test(t)?Number(t):t}function Ee(e,t,n){let r=t,i=()=>{for(;r<e.length&&/\s/.test(e[r]);)r+=1},a=()=>{i();let t=e[r];if(t===`[`||t===`{`){let o=t,s=o===`[`?`]`:`}`;r+=1;let c=o===`[`,l=c?[]:{};for(;;){if(i(),r>=e.length)throw new J(`行内集合未闭合`,n);if(e[r]===s)return r+=1,l;if(c)l.push(a());else{let t=a();if(i(),e[r]!==`:`)throw new J(`行内对象缺少冒号`,n);r+=1,l[String(t)]=a()}if(i(),e[r]===`,`)r+=1;else{if(e[r]===s)return r+=1,l;throw new J(`行内集合分隔符不正确`,n)}}}if(t===`"`||t===`'`){let t=Se(e,r,n);return r=t.end,t.value}let o=r;for(;o<e.length&&!/[,\]}]/.test(e[o])&&!(e[o]===`:`&&/[\s,\]}]/.test(e[o+1]||``));)o+=1;let s=e.slice(r,o).trim();return r=o,Te(s)},o=a();if(i(),r<e.length)throw new J(`行内值后存在多余内容`,n);return o}function De(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`[`)||n.startsWith(`{`))return Ee(n,0,t);if(n.startsWith(`"`)||n.startsWith(`'`)){let e=Se(n,0,t);if(n.slice(e.end).trim())throw new J(`引号字符串后存在多余内容`,t);return e.value}if(/^[&*]/.test(n))throw new J(`不支持锚点/别名`,t);return Te(n)}function Oe(e){return/^[|>][-+0-9]*$/.test(e.trim())}function ke(e,t,n,r){let i=n.trim()[0],a=n.includes(`-`)?`strip`:n.includes(`+`)?`keep`:`clip`,o=e.rawLines,s=[],c=null,l=r;for(let e=r;e<o.length;e+=1){let n=o[e];if(n.trim()===``){s.push(``),l=e+1;continue}let r=/^[ \t]*/.exec(n)[0].length;if(r<=t)break;c===null&&(c=r),s.push(` `.repeat(Math.max(0,r-c))+n.slice(r)),l=e+1}for(;e.i<e.lines.length&&e.lines[e.i].line<=l;)e.i+=1;if(!s.length)return``;let u=s,d;if(i===`|`)d=u.join(`
`);else{d=u[0]??``;for(let e=1;e<u.length;e+=1)d+=u[e]===``||u[e-1]===``?`\n${u[e]}`:` ${u[e]}`}let f=d.replace(/\n+$/,``);return a===`strip`?f:a===`keep`?d?`${d}\n`:``:f?`${f}\n`:``}function Ae(e,t){let n=e.lines[e.i];return n?n.content===`-`||n.content.startsWith(`- `)?Ne(e,t):je(e,t):null}function je(e,t,n=null){let r=n||{};for(;e.i<e.lines.length;){let n=e.lines[e.i];if(n.indent<t)break;if(n.indent>t)throw new J(`缩进层级不一致`,n.line);if(n.content===`-`||n.content.startsWith(`- `))throw new J(`同一层级不能混用列表与键值`,n.line);let i=Ce(n.content,n.line);e.i+=1,r[i.key]=Me(e,t,i.rest,n.line)}return r}function Me(e,t,n,r){if(n===``){let n=e.lines[e.i];return n&&n.indent>t?Ae(e,n.indent):null}return Oe(n)?ke(e,t,n,r):De(n,r)}function Ne(e,t){let n=[];for(;e.i<e.lines.length;){let r=e.lines[e.i];if(r.indent!==t){if(r.indent>t)throw new J(`缩进层级不一致`,r.line);break}if(!(r.content===`-`||r.content.startsWith(`- `)))break;let i=r.content===`-`?``:r.content.slice(1).trimStart(),a=t+(r.content.length-i.length);if(e.i+=1,i===``){let r=e.lines[e.i];r&&r.indent>t?n.push(Ae(e,r.indent)):n.push(null)}else if(we(i,r.line)&&!/^[\[{]/.test(i)){let t=Ce(i,r.line),o={};o[t.key]=Me(e,a,t.rest,r.line),je(e,a,o),n.push(o)}else Oe(i)?n.push(ke(e,t,i,r.line)):n.push(De(i,r.line))}return n}function Pe(e){let t=String(e??``).replace(/\r\n?/g,`
`).split(`
`),n=[];if(t.forEach((e,t)=>{if(/^\s*$/.test(e)||/^\s*#/.test(e)||/^\s*(---|\.\.\.)\s*(#.*)?$/.test(e))return;let r=/^[ \t]*/.exec(e)[0];if(r.includes(` `))throw new J(`缩进不能使用制表符`,t+1);n.push({indent:r.length,content:e.slice(r.length),line:t+1})}),!n.length)return null;let r={lines:n,rawLines:t,i:0},i=Ae(r,n[0].indent);if(r.i<n.length)throw new J(`存在无法归属的缩进内容`,r.lines[r.i].line);return i}var X=e(r(),1),{Text:Fe}=m;function Ie({permission:e,label:t}){let n=P();return(0,X.jsx)(T,{type:`warning`,bordered:!0,closeIcon:null,description:n(`settings.permissionMissing`,{permission:e},`当前账号缺少 ${e} 权限,无法${t||`访问该分区`}。`)})}function Le({rows:e=4}){return(0,X.jsx)(`div`,{className:`settings-loading-block`,children:(0,X.jsx)(c,{placeholder:(0,X.jsx)(c.Paragraph,{rows:e}),loading:!0,children:(0,X.jsx)(`div`,{style:{height:e*18}})})})}function Z({children:e}){return(0,X.jsx)(Fe,{type:`tertiary`,size:`small`,className:`settings-hint`,children:e})}function Q({children:e}){return(0,X.jsx)(`span`,{className:`settings-mono`,children:e})}var{Paragraph:Re}=m,ze=[`ai`,`openai`,`vision`,`knowledge`,`storage`],Be=`系统设置 · 原始配置(由 GET /config 生成)
· 密钥字段显示为 ********:原样保存会沿用已保存的凭据,填写新值即替换。
· 保存 = PUT /config(写入 config.yaml)+ POST /config/apply(重新加载)。
· 只提交文本里有修改的段落,省略的段落沿用服务端配置。
· storage(清理策略)不在 GET /config 里,请到「存储与更新」分区编辑。
· 此编辑器可保存模型、视觉、知识库和存储配置。其余配置请使用原有设置页面。`;function Ve(){let e=P(),{hasPermission:t}=k(),n=t(`config:read`),r=t(`config:write`),i=(0,q.useCallback)(()=>A.get(`/config`),[]),s=z(i,[n],{skip:!n}),[c,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(``),[m,g]=(0,q.useState)(``),[_,ee]=(0,q.useState)(null),[v,y]=(0,q.useState)(``),[b,x]=(0,q.useState)(`idle`);(0,q.useEffect)(()=>{if(!s.data)return;let{context_window_defaults:e,...t}=s.data,n=be(t,{header:Be});d(n),p(n),g(``)},[s.data]);let S=f!==``&&c!==f,C=b!==`idle`,E=(0,q.useMemo)(()=>{let t=s.data;if(!t)return[];let n=t.ai?.channels||{},r=Object.entries(n).map(([e,t])=>K(e,t)),i=t.ai?.default_channel,a=Array.isArray(t.tools)?t.tools:[],o=a.filter(e=>e.enabled).length;return[{label:e(`settings.defaultChannel`,null,`默认 AI 通道`),value:i?K(i,n[i]):`—`},{label:e(`settingsBasic.aiChannelSavedList`,null,`已保存通道`),value:`${D(r.length)}${r.length?`(${r.slice(0,4).join(`、`)})`:``}`},{label:e(`settings.toolsEnabled`,null,`已启用工具`),value:`${D(o)} / ${D(a.length)}`},{label:e(`settings.visionLabel`,null,`视觉模型`),value:t.vision?.enabled?t.vision.model||`已启用`:`未启用`},{label:e(`settings.knowledge.title`,null,`知识库`),value:t.knowledge?.enabled?`已启用`:`未启用`},{label:`C2`,value:t.c2?.enabled?`已启用`:`未启用`}]},[s.data,e]),O=(0,q.useCallback)(async()=>{ee(null),y(``),await s.reload()},[s.reload]),j=(0,q.useCallback)(()=>{S?se({title:`重新加载配置`,content:`当前有未保存修改,重新加载会丢弃这些修改。确认继续?`,okText:`确定`,onOk:O}):O()},[O,S]);return n?s.loading&&!s.data?(0,X.jsx)(Le,{rows:8}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{error:s.error,onRetry:j}),s.data&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(H,{title:e(`settings.overviewTitle`,null,`当前配置概览`),children:(0,X.jsx)(B,{items:E,columns:3})}),(0,X.jsxs)(H,{title:e(`settings.rawTitle`,null,`原始 YAML 配置`),description:e(`settingsDisplay.rawYamlHelp`,null,`查看或批量修改服务端高级配置。保存会写入支持的改动并尝试应用。`),extra:(0,X.jsxs)(o,{children:[(0,X.jsx)(u,{color:S?`amber`:`green`,size:`small`,children:S?e(`settings.unsaved`,null,`有未保存修改`):e(`settings.savedState`,null,`已与服务端同步`)}),(0,X.jsx)(U,{text:c,label:e(`common.copy`,null,`复制`)})]}),children:[v&&(0,X.jsx)(T,{type:`warning`,bordered:!0,closeIcon:null,className:`settings-yaml-notice`,description:v}),m&&(0,X.jsx)(V,{error:m}),(0,X.jsx)(V,{error:_,onRetry:j}),(0,X.jsxs)(`div`,{className:`settings-yaml-toolbar`,children:[(0,X.jsxs)(o,{children:[(0,X.jsx)(l,{theme:`solid`,type:`primary`,icon:(0,X.jsx)(h,{}),loading:C,disabled:!r||!S,onClick:async()=>{let t;try{t=Pe(c)}catch(e){g(F(e,`YAML 解析失败`));return}if(!t||typeof t!=`object`||Array.isArray(t)){g(`顶层必须是键值映射(key: value),不能是列表或标量。`);return}g(``),ee(null),y(``);let n=Object.keys(t).filter(e=>!ze.includes(e)),r={};for(let e of ze)t[e]!==void 0&&JSON.stringify(t[e])!==JSON.stringify(s.data?.[e])&&(r[e]=t[e]);if(!Object.keys(r).length){y(`没有需要保存的配置修改。`),n.length&&I(`已忽略不支持的字段:${n.join(`、`)}`);return}x(`saving`);try{await A.put(`/config`,r)}catch(t){x(`idle`),ee(t),ne(t,e(`settings.apply.applyFailed`,null,`保存配置失败`));return}let i=null;x(`applying`);try{await A.post(`/config/apply`)}catch(e){i=e}x(`idle`),i?(ee(i),y(e(`settings.apply.appliedWithError`,null,`配置已写入 config.yaml,但应用失败;部分改动需要重启后才能生效。`)),I(e(`settings.apply.appliedWithError`,null,`配置已写入,但应用失败`))):oe(e(`settings.apply.applySuccess`,null,`配置已成功应用`)),n.length&&I(e(`settings.apply.ignoredSections`,{list:n.join(`、`)},`已忽略后端不接收的字段:${n.join(`、`)}`)),await s.reload()},children:b===`applying`?e(`settings.applying`,null,`正在应用…`):e(`settings.saveAndApply`,null,`保存并应用`)}),(0,X.jsx)(l,{onClick:()=>{try{let e=Pe(c);if(!e||typeof e!=`object`||Array.isArray(e)){g(`顶层必须是键值映射(key: value),不能是列表或标量。`);return}d(be(e,{header:Be})),g(``)}catch(e){g(F(e,`YAML 解析失败`))}},disabled:C,children:e(`settings.formatAndValidate`,null,`格式化并校验`)}),(0,X.jsx)(l,{onClick:()=>{d(f),g(``),y(``)},disabled:!S||C,children:e(`toolGuard.reset`,null,`撤销修改`)}),(0,X.jsx)(l,{icon:(0,X.jsx)(te,{}),onClick:j,loading:s.loading,disabled:C,children:e(`common.refresh`,null,`刷新`)})]}),(0,X.jsx)(Z,{children:e(`settings.lineCount`,{count:c.split(`
`).length},`${c.split(`
`).length} 行`)})]}),!r&&(0,X.jsx)(Re,{type:`tertiary`,size:`small`,className:`settings-hint`,children:e(`settings.readOnlyHint`,null,`当前账号没有 config:write 权限,只能查看配置,无法保存。`)}),(0,X.jsx)(w,{className:`settings-yaml-input`,value:c,onChange:e=>{d(e),y(``)},readOnly:!r||C,spellCheck:!1,autosize:!1,rows:24})]}),(0,X.jsx)(H,{title:e(`settings.jsonTitle`,null,`只读参考`),children:(0,X.jsx)(a,{children:(0,X.jsx)(a.Panel,{header:e(`settings.jsonPanel`,null,`GET /config 原始响应(JSON,便于核对字段名)`),itemKey:`json`,children:(0,X.jsx)(G,{value:s.data,collapsed:!0,title:`GET /config`})})})})]})]}):(0,X.jsx)(Ie,{permission:`config:read`,label:e(`settings.nav.basic`,null,`读取基础配置`)})}var{Text:He}=m,Ue=`__main__`,We={},Ge=[{value:`openai_compatible`,key:`settingsProbe.compatible`,fallback:`兼容 OpenAI 的接口`},{value:`claude`,key:`settingsBasic.providerClaude`,fallback:`Claude(Anthropic Messages)`}],Ke=[``,`auto`,`local_auto`,`local`,`economy`,`custom`],qe=[[`context_window`,`settingsBasic.contextWindow`,`模型上下文窗口(Token)`],[`max_total_tokens`,`settingsBasic.maxTotalTokens`,`最大上下文令牌数`],[`max_completion_tokens`,`settingsBasic.maxCompletionTokens`,`最大输出令牌数`]],Je={key:``,payload:null,error:null},Ye={context_window_unknown:`contextWarnUnknown`,context_runtime_unknown:`contextWarnRuntimeUnknown`,local_context_window_unknown:`contextWarnWindowUnknown`,local_context_window_small:`contextWarnWindowSmall`,max_total_tokens_clamped:`contextWarnBudgetClamped`,max_completion_tokens_clamped:`contextWarnCompletionClamped`,configured_budget_exceeds_context_window:`contextWarnBudgetExceedsWindow`,ollama_v1_ignores_num_ctx:`contextWarnOllamaV1`,ollama_runtime_context_unknown:`contextWarnOllamaRuntime`,llamacpp_parallel_slots:`contextWarnLlamaCppSlots`},Xe={ollama:`Ollama`,llamacpp:`llama.cpp`,lmstudio:`LM Studio`,omlx:`oMLX`,vllm:`vLLM`};function Ze(e,t){return e(`settingsProbe.profiles.`+(t||`default`),null,t||`使用默认设置`)}function Qe(e){let t=Number(e);return Number.isSafeInteger(t)&&t>=0?t:0}function $e(e){let t=e.provider||`openai_compatible`;return t===`openai`&&(t=`openai_compatible`),t===`anthropic`&&(t=`claude`),{name:e.name||``,provider:t,base_url:e.base_url||``,api_key:e.api_key||``,model:e.model||``,image_input:e.image_input||``,context_profile:e.context_profile||``,context_window:e.context_window>0?String(e.context_window):``,max_total_tokens:e.max_total_tokens||0,max_completion_tokens:e.max_completion_tokens||0,headers:e.headers||void 0}}function et(e,t){return[{label:e(`settingsProbe.result`,null,`测试结果`),value:(0,X.jsx)(u,{color:`green`,children:e(`settingsBasic.testSuccess`,null,`连接成功`)})},{label:e(`settingsBasic.model`,null,`模型`),value:t.model||`—`},{label:e(`settingsProbe.latency`,null,`响应耗时`),value:t.latency_ms==null?`—`:e(`settingsProbe.milliseconds`,{value:t.latency_ms},`${t.latency_ms} 毫秒`)}]}function tt(e,t,n){let r=t.context_source,i=r?.replace(/^omlx_models_(?=max_model_len|context_length|max_context_length|context_window)/,`openai_models_`),a=t.context_backend;return[...et(e,t),{label:e(`settingsProbe.window`,null,`上下文窗口`),value:t.context_window||n||`—`},{label:e(`settingsProbe.backend`,null,`模型接口类型`),value:a===`openai_compatible`?e(`settingsProbe.compatible`,null,`兼容 OpenAI 的接口`):Xe[a]||a||`—`},{label:e(`settingsProbe.source`,null,`窗口信息来源`),value:n?e(`settingsProbe.windowDefault`,null,`默认值`):r?e(`settingsProbe.sources.`+i,null,r):`—`},{label:e(`settingsProbe.profile`,null,`上下文配置`),value:Ze(e,t.context_profile)},{label:e(`settingsProbe.effectiveBudget`,null,`实际可用上下文令牌数`),value:t.effective_max_total_tokens??`—`}]}function nt({state:e,defaultWindow:t}){let n=P(),{key:r,payload:i,error:a}=e;if(a)return(0,X.jsx)(V,{error:a});if(!i)return null;if(r===`list`){if(!i.success)return(0,X.jsx)(T,{type:i.supported===!1?`info`:`danger`,bordered:!0,closeIcon:null,description:i.error||n(`settingsBasic.modelsListFailed`,null,`获取模型列表失败`)});let e=Array.isArray(i.models)?i.models:[];return(0,X.jsxs)(`div`,{className:`settings-probe-result`,children:[(0,X.jsx)(o,{spacing:8,children:(0,X.jsx)(He,{children:n(`settingsBasic.modelsListSuccess`,{count:i.count??e.length},`已获取 ${i.count??e.length} 个模型`)})}),(0,X.jsxs)(`div`,{className:`settings-model-tags`,children:[e.slice(0,120).map(e=>(0,X.jsx)(u,{size:`small`,children:String(e)},String(e))),e.length>120&&(0,X.jsx)(u,{size:`small`,color:`grey`,children:`…`})]})]})}if(r===`audit`||r===`image`)return(0,X.jsx)(`div`,{className:`settings-probe-result`,children:i.success?(0,X.jsx)(B,{columns:3,items:et(n,i).map((e,t)=>r===`image`&&t===0?{...e,value:(0,X.jsx)(u,{color:`green`,children:n(`settingsProbe.imageReadSuccess`,null,`图片读取成功`)})}:e)}):(0,X.jsx)(T,{type:`danger`,bordered:!0,closeIcon:nullLine truncated
@@ -0,0 +1,19 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,_ as n,t as r,y as i}from"./react-QV7DAAIx.js";import{A as a,F as o,H as s,I as c,L as l,M as u,O as d,Ot as f,Qt as p,W as m,Z as h,c as g,f as _,h as ee,m as v,ot as y,p as b,s as x,st as te,u as S,v as C,x as w,z as T}from"./semi-Dpcldp_F.js";import{A as ne,D as E,E as D,F as re,I as O,L as k,M as A,N as j,P as M,R as N,S as P,T as F,_ as I,a as L,b as R,d as z,j as ie,l as B,m as V,n as H,o as U,p as W,s as G,u as K,x as ae,y as oe}from"./index-BMTtTYg1.js";import{n as se,r as ce,t as q}from"./model-channel-mQ6lfvSO.js";var J=e(t(),1),Y=class extends Error{constructor(e,t){super(t?`第 ${t} 行:${e}`:e),this.name=`YamlError`,this.line=t||0}},le=/^(?:[-?:,\[\]{}#&*!|>'"%@`]|.*[:\s]$|.*\s#|.*[\n\r\t])/,ue=/^(?:true|false|null|~|yes|no|on|off|[-+]?(?:\d+|\d*\.\d+)(?:[eE][-+]?\d+)?)$/i;function de(e){let t=String(e);return!(t===``||ue.test(t)||/^[-+]?(?:\d+\.\d*|\.\d+|\d+)(?:[eE][-+]?\d+)?$/.test(t)||le.test(t)||/^(?:\s)|:(?:\s|$)|[\r\n\t]/.test(t)||/[,[\]{}]/.test(t)||/^[!&*|>@`]/.test(t))}function fe(e){return JSON.stringify(String(e))}function pe(e){let t=String(e);return de(t)?t:fe(t)}function me(e){if(e==null)return`null`;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return Number.isFinite(e)?String(e):fe(String(e));let t=String(e);return de(t)?t:fe(t)}function he(e){return e==null||[`string`,`number`,`boolean`].includes(typeof e)}function ge(e,t,n,r){let i=` `.repeat(n),a=pe(e);if(he(t))r.push(`${i}${a}: ${me(t)}`);else if(Array.isArray(t)){if(!t.length){r.push(`${i}${a}: []`);return}r.push(`${i}${a}:`),ye(t,n+2,r)}else Object.entries(t).length?(r.push(`${i}${a}:`),_e(t,n+2,r)):r.push(`${i}${a}: {}`)}function _e(e,t,n){for(let[r,i]of Object.entries(e))ge(r,i,t,n)}function ve(e,t,n){let r=` `.repeat(t);if(he(e)){n.push(`${r}- ${me(e)}`);return}if(Array.isArray(e)){if(!e.length){n.push(`${r}- []`);return}n.push(`${r}-`),ye(e,t+2,n);return}let i=Object.entries(e);if(!i.length){n.push(`${r}- {}`);return}let[a,o]=i[0],s=i.slice(1);he(o)?n.push(`${r}- ${pe(a)}: ${me(o)}`):(n.push(`${r}-`),ge(a,o,t+2,n));for(let[e,r]of s)ge(e,r,t+2,n)}function ye(e,t,n){for(let r of e)ve(r,t,n)}function be(e,{header:t}={}){let n=[];if(t){for(let e of String(t).replace(/\r\n?/g,`
`).split(`
`))n.push(`# ${e}`.trimEnd());n.length&&n.push(``)}return he(e)?(n.push(me(e)),`${n.join(`
`)}\n`):Array.isArray(e)?(e.length?ye(e,0,n):n.push(`[]`),`${n.join(`
`)}\n`):!e||!Object.keys(e).length?(n.push(`{}`),`${n.join(`
`)}\n`):(_e(e,0,n),`${n.join(`
`)}\n`)}function xe(e){let t=``;for(let n=0;n<e.length;n+=1){let r=e[n];if(t){if(r===`\\`&&t===`"`){n+=1;continue}r===t&&(t=``)}else if(r===`"`||r===`'`)t=r;else if(r===`#`&&(n===0||/\s/.test(e[n-1])))return e.slice(0,n).trimEnd()}return e.trimEnd()}function Se(e,t,n){let r=e[t],i=``,a=t+1;for(;a<e.length;){let t=e[a];if(r===`'`){if(t===`'`){if(e[a+1]===`'`){i+=`'`,a+=2;continue}return{value:i,end:a+1}}i+=t,a+=1}else if(t===`\\`){let t=e[a+1],n={n:`
`,r:`\r`,t:` `,'"':`"`,"\\":`\\`,"/":`/`,0:`\0`,b:`\b`,f:`\f`};if(t===`u`){i+=String.fromCharCode(parseInt(e.slice(a+2,a+6),16)),a+=6;continue}if(t in n){i+=n[t],a+=2;continue}i+=t||``,a+=2}else{if(t===`"`)return{value:i,end:a+1};i+=t,a+=1}}throw new Y(`字符串引号未闭合`,n)}function Ce(e,t){let n=e.trimEnd();if(n.startsWith(`"`)||n.startsWith(`'`)){let e=Se(n,0,t),r=n.slice(e.end).trimStart();if(!r.startsWith(`:`))throw new Y(`键名后缺少冒号`,t);return{key:e.value,rest:xe(r.slice(1).trim())}}for(let e=0;e<n.length;e+=1)if(n[e]===`:`&&(e+1>=n.length||/\s/.test(n[e+1]))){let r=n.slice(0,e).trim();if(!r)throw new Y(`键名为空`,t);if(/^[&*!|>@`]/.test(r))throw new Y(`不支持的键名写法:${r}`,t);return{key:r,rest:xe(n.slice(e+1).trim())}}throw new Y(`缺少冒号,无法识别为键值`,t)}function we(e,t){if(e.startsWith(`"`)||e.startsWith(`'`)){let{end:n}=Se(e,0,t);return e.slice(n).trimStart().startsWith(`:`)}if(/^[\[{]/.test(e))return!1;for(let t=0;t<e.length;t+=1)if(e[t]===`:`&&(t+1>=e.length||/\s/.test(e[t+1])))return!0;return!1}function Te(e){let t=e.trim();return t===``||t===`~`||/^null$/i.test(t)?null:/^true$/i.test(t)?!0:/^false$/i.test(t)?!1:/^[-+]?\d+$/.test(t)&&t.length<16||/^[-+]?(?:\d+\.\d*|\.\d+|\d+)(?:[eE][-+]?\d+)?$/.test(t)?Number(t):t}function Ee(e,t,n){let r=t,i=()=>{for(;r<e.length&&/\s/.test(e[r]);)r+=1},a=()=>{i();let t=e[r];if(t===`[`||t===`{`){let o=t,s=o===`[`?`]`:`}`;r+=1;let c=o===`[`,l=c?[]:{};for(;;){if(i(),r>=e.length)throw new Y(`行内集合未闭合`,n);if(e[r]===s)return r+=1,l;if(c)l.push(a());else{let t=a();if(i(),e[r]!==`:`)throw new Y(`行内对象缺少冒号`,n);r+=1,l[String(t)]=a()}if(i(),e[r]===`,`)r+=1;else{if(e[r]===s)return r+=1,l;throw new Y(`行内集合分隔符不正确`,n)}}}if(t===`"`||t===`'`){let t=Se(e,r,n);return r=t.end,t.value}let o=r;for(;o<e.length&&!/[,\]}]/.test(e[o])&&!(e[o]===`:`&&/[\s,\]}]/.test(e[o+1]||``));)o+=1;let s=e.slice(r,o).trim();return r=o,Te(s)},o=a();if(i(),r<e.length)throw new Y(`行内值后存在多余内容`,n);return o}function De(e,t){let n=e.trim();if(!n)return null;if(n.startsWith(`[`)||n.startsWith(`{`))return Ee(n,0,t);if(n.startsWith(`"`)||n.startsWith(`'`)){let e=Se(n,0,t);if(n.slice(e.end).trim())throw new Y(`引号字符串后存在多余内容`,t);return e.value}if(/^[&*]/.test(n))throw new Y(`不支持锚点/别名`,t);return Te(n)}function Oe(e){return/^[|>][-+0-9]*$/.test(e.trim())}function ke(e,t,n,r){let i=n.trim()[0],a=n.includes(`-`)?`strip`:n.includes(`+`)?`keep`:`clip`,o=e.rawLines,s=[],c=null,l=r;for(let e=r;e<o.length;e+=1){let n=o[e];if(n.trim()===``){s.push(``),l=e+1;continue}let r=/^[ \t]*/.exec(n)[0].length;if(r<=t)break;c===null&&(c=r),s.push(` `.repeat(Math.max(0,r-c))+n.slice(r)),l=e+1}for(;e.i<e.lines.length&&e.lines[e.i].line<=l;)e.i+=1;if(!s.length)return``;let u=s,d;if(i===`|`)d=u.join(`
`);else{d=u[0]??``;for(let e=1;e<u.length;e+=1)d+=u[e]===``||u[e-1]===``?`\n${u[e]}`:` ${u[e]}`}let f=d.replace(/\n+$/,``);return a===`strip`?f:a===`keep`?d?`${d}\n`:``:f?`${f}\n`:``}function Ae(e,t){let n=e.lines[e.i];return n?n.content===`-`||n.content.startsWith(`- `)?Ne(e,t):je(e,t):null}function je(e,t,n=null){let r=n||{};for(;e.i<e.lines.length;){let n=e.lines[e.i];if(n.indent<t)break;if(n.indent>t)throw new Y(`缩进层级不一致`,n.line);if(n.content===`-`||n.content.startsWith(`- `))throw new Y(`同一层级不能混用列表与键值`,n.line);let i=Ce(n.content,n.line);e.i+=1,r[i.key]=Me(e,t,i.rest,n.line)}return r}function Me(e,t,n,r){if(n===``){let n=e.lines[e.i];return n&&n.indent>t?Ae(e,n.indent):null}return Oe(n)?ke(e,t,n,r):De(n,r)}function Ne(e,t){let n=[];for(;e.i<e.lines.length;){let r=e.lines[e.i];if(r.indent!==t){if(r.indent>t)throw new Y(`缩进层级不一致`,r.line);break}if(!(r.content===`-`||r.content.startsWith(`- `)))break;let i=r.content===`-`?``:r.content.slice(1).trimStart(),a=t+(r.content.length-i.length);if(e.i+=1,i===``){let r=e.lines[e.i];r&&r.indent>t?n.push(Ae(e,r.indent)):n.push(null)}else if(we(i,r.line)&&!/^[\[{]/.test(i)){let t=Ce(i,r.line),o={};o[t.key]=Me(e,a,t.rest,r.line),je(e,a,o),n.push(o)}else Oe(i)?n.push(ke(e,t,i,r.line)):n.push(De(i,r.line))}return n}function Pe(e){let t=String(e??``).replace(/\r\n?/g,`
`).split(`
`),n=[];if(t.forEach((e,t)=>{if(/^\s*$/.test(e)||/^\s*#/.test(e)||/^\s*(---|\.\.\.)\s*(#.*)?$/.test(e))return;let r=/^[ \t]*/.exec(e)[0];if(r.includes(` `))throw new Y(`缩进不能使用制表符`,t+1);n.push({indent:r.length,content:e.slice(r.length),line:t+1})}),!n.length)return null;let r={lines:n,rawLines:t,i:0},i=Ae(r,n[0].indent);if(r.i<n.length)throw new Y(`存在无法归属的缩进内容`,r.lines[r.i].line);return i}var X=e(r(),1),{Text:Fe}=m;function Ie({permission:e,label:t}){let n=M();return(0,X.jsx)(T,{type:`warning`,bordered:!0,closeIcon:null,description:n(`settings.permissionMissing`,{permission:e},`当前账号缺少 ${e} 权限,无法${t||`访问该分区`}。`)})}function Le({rows:e=4}){return(0,X.jsx)(`div`,{className:`settings-loading-block`,children:(0,X.jsx)(c,{placeholder:(0,X.jsx)(c.Paragraph,{rows:e}),loading:!0,children:(0,X.jsx)(`div`,{style:{height:e*18}})})})}function Z({children:e}){return(0,X.jsx)(Fe,{type:`tertiary`,size:`small`,className:`settings-hint`,children:e})}function Q({children:e}){return(0,X.jsx)(`span`,{className:`settings-mono`,children:e})}var{Paragraph:Re}=m,ze=[`ai`,`openai`,`vision`,`knowledge`,`storage`],Be=`系统设置 · 原始配置(由 GET /config 生成)
· 密钥字段显示为 ********:原样保存会沿用已保存的凭据,填写新值即替换。
· 保存 = PUT /config(写入 config.yaml)+ POST /config/apply(重新加载)。
· 只提交文本里有修改的段落,省略的段落沿用服务端配置。
· storage(清理策略)不在 GET /config 里,请到「存储与更新」分区编辑。
· 此编辑器可保存模型、视觉、知识库和存储配置。其余配置请使用原有设置页面。`;function Ve(){let e=M(),{hasPermission:t}=re(),n=t(`config:read`),r=t(`config:write`),i=(0,J.useCallback)(()=>O.get(`/config`),[]),s=L(i,[n],{skip:!n}),[c,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(``),[m,g]=(0,J.useState)(``),[_,ee]=(0,J.useState)(null),[v,y]=(0,J.useState)(``),[b,x]=(0,J.useState)(`idle`);(0,J.useEffect)(()=>{if(!s.data)return;let{context_window_defaults:e,...t}=s.data,n=be(t,{header:Be});d(n),p(n),g(``)},[s.data]);let S=f!==``&&c!==f,C=b!==`idle`,ne=(0,J.useMemo)(()=>{let t=s.data;if(!t)return[];let n=t.ai?.channels||{},r=Object.entries(n).map(([e,t])=>q(e,t)),i=t.ai?.default_channel,a=Array.isArray(t.tools)?t.tools:[],o=a.filter(e=>e.enabled).length;return[{label:e(`settings.defaultChannel`,null,`默认 AI 通道`),value:i?q(i,n[i]):`—`},{label:e(`settingsBasic.aiChannelSavedList`,null,`已保存通道`),value:`${E(r.length)}${r.length?`(${r.slice(0,4).join(`、`)})`:``}`},{label:e(`settings.toolsEnabled`,null,`已启用工具`),value:`${E(o)} / ${E(a.length)}`},{label:e(`settings.visionLabel`,null,`视觉模型`),value:t.vision?.enabled?t.vision.model||`已启用`:`未启用`},{label:e(`settings.knowledge.title`,null,`知识库`),value:t.knowledge?.enabled?`已启用`:`未启用`},{label:`C2`,value:t.c2?.enabled?`已启用`:`未启用`}]},[s.data,e]),D=(0,J.useCallback)(async()=>{ee(null),y(``),await s.reload()},[s.reload]),k=(0,J.useCallback)(()=>{S?oe({title:`重新加载配置`,content:`当前有未保存修改,重新加载会丢弃这些修改。确认继续?`,okText:`确定`,onOk:D}):D()},[D,S]);return n?s.loading&&!s.data?(0,X.jsx)(Le,{rows:8}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(B,{error:s.error,onRetry:k}),s.data&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{title:e(`settings.overviewTitle`,null,`当前配置概览`),children:(0,X.jsx)(z,{items:ne,columns:3})}),(0,X.jsxs)(V,{title:e(`settings.rawTitle`,null,`原始 YAML 配置`),description:e(`settingsDisplay.rawYamlHelp`,null,`查看或批量修改服务端高级配置。保存会写入支持的改动并尝试应用。`),extra:(0,X.jsxs)(o,{children:[(0,X.jsx)(u,{color:S?`amber`:`green`,size:`small`,children:S?e(`settings.unsaved`,null,`有未保存修改`):e(`settings.savedState`,null,`已与服务端同步`)}),(0,X.jsx)(U,{text:c,label:e(`common.copy`,null,`复制`)})]}),children:[v&&(0,X.jsx)(T,{type:`warning`,bordered:!0,closeIcon:null,className:`settings-yaml-notice`,description:v}),m&&(0,X.jsx)(B,{error:m}),(0,X.jsx)(B,{error:_,onRetry:k}),(0,X.jsxs)(`div`,{className:`settings-yaml-toolbar`,children:[(0,X.jsxs)(o,{children:[(0,X.jsx)(l,{theme:`solid`,type:`primary`,icon:(0,X.jsx)(h,{}),loading:C,disabled:!r||!S,onClick:async()=>{let t;try{t=Pe(c)}catch(e){g(N(e,`YAML 解析失败`));return}if(!t||typeof t!=`object`||Array.isArray(t)){g(`顶层必须是键值映射(key: value),不能是列表或标量。`);return}g(``),ee(null),y(``);let n=Object.keys(t).filter(e=>!ze.includes(e)),r={};for(let e of ze)t[e]!==void 0&&JSON.stringify(t[e])!==JSON.stringify(s.data?.[e])&&(r[e]=t[e]);if(!Object.keys(r).length){y(`没有需要保存的配置修改。`),n.length&&P(`已忽略不支持的字段:${n.join(`、`)}`);return}x(`saving`);try{await O.put(`/config`,r)}catch(t){x(`idle`),ee(t),R(t,e(`settings.apply.applyFailed`,null,`保存配置失败`));return}let i=null;x(`applying`);try{await O.post(`/config/apply`)}catch(e){i=e}x(`idle`),i?(ee(i),y(e(`settings.apply.appliedWithError`,null,`配置已写入 config.yaml,但应用失败;部分改动需要重启后才能生效。`)),P(e(`settings.apply.appliedWithError`,null,`配置已写入,但应用失败`))):ae(e(`settings.apply.applySuccess`,null,`配置已成功应用`)),n.length&&P(e(`settings.apply.ignoredSections`,{list:n.join(`、`)},`已忽略后端不接收的字段:${n.join(`、`)}`)),await s.reload()},children:b===`applying`?e(`settings.applying`,null,`正在应用…`):e(`settings.saveAndApply`,null,`保存并应用`)}),(0,X.jsx)(l,{onClick:()=>{try{let e=Pe(c);if(!e||typeof e!=`object`||Array.isArray(e)){g(`顶层必须是键值映射(key: value),不能是列表或标量。`);return}d(be(e,{header:Be})),g(``)}catch(e){g(N(e,`YAML 解析失败`))}},disabled:C,children:e(`settings.formatAndValidate`,null,`格式化并校验`)}),(0,X.jsx)(l,{onClick:()=>{d(f),g(``),y(``)},disabled:!S||C,children:e(`toolGuard.reset`,null,`撤销修改`)}),(0,X.jsx)(l,{icon:(0,X.jsx)(te,{}),onClick:k,loading:s.loading,disabled:C,children:e(`common.refresh`,null,`刷新`)})]}),(0,X.jsx)(Z,{children:e(`settings.lineCount`,{count:c.split(`
`).length},`${c.split(`
`).length} 行`)})]}),!r&&(0,X.jsx)(Re,{type:`tertiary`,size:`small`,className:`settings-hint`,children:e(`settings.readOnlyHint`,null,`当前账号没有 config:write 权限,只能查看配置,无法保存。`)}),(0,X.jsx)(w,{className:`settings-yaml-input`,value:c,onChange:e=>{d(e),y(``)},readOnly:!r||C,spellCheck:!1,autosize:!1,rows:24})]}),(0,X.jsx)(V,{title:e(`settings.jsonTitle`,null,`只读参考`),children:(0,X.jsx)(a,{children:(0,X.jsx)(a.Panel,{header:e(`settings.jsonPanel`,null,`GET /config 原始响应(JSON,便于核对字段名)`),itemKey:`json`,children:(0,X.jsx)(K,{value:s.data,collapsed:!0,title:`GET /config`})})})})]})]}):(0,X.jsx)(Ie,{permission:`config:read`,label:e(`settings.nav.basic`,null,`读取基础配置`)})}var{Text:He}=m,Ue=`__main__`,We={},Ge=1048576,Ke=[{value:`openai_compatible`,key:`settingsProbe.compatible`,fallback:`兼容 OpenAI 的接口`},{value:`claude`,key:`settingsBasic.providerClaude`,fallback:`Claude(Anthropic Messages)`}],qe=[``,`auto`,`local_auto`,`local`,`economy`,`custom`],Je=[[`context_window`,`settingsBasic.contextWindow`,`模型上下文窗口(Token)`],[`max_total_tokens`,`settingsBasic.maxTotalTokens`,`最大上下文令牌数`],[`max_completion_tokens`,`settingsBasic.maxCompletionTokens`,`最大输出令牌数`]],Ye={key:``,payload:null,error:null},Xe={context_window_unknown:`contextWarnUnknown`,context_runtime_unknown:`contextWarnRuntimeUnknown`,local_context_window_unknown:`contextWarnWindowUnknown`,local_context_window_small:`contextWarnWindowSmall`,max_total_tokens_clamped:`contextWarnBudgetClamped`,max_completion_tokens_clamped:`contextWarnCompletionClamped`,configured_budget_exceeds_context_window:`contextWarnBudgetExceedsWindow`,ollama_v1_ignores_num_ctx:`contextWarnOllamaV1`,ollama_runtime_context_unknown:`contextWarnOllamaRuntime`,llamacpp_parallel_slots:`contextWarnLlamaCppSlots`},Ze={ollama:`Ollama`,llamacpp:`llama.cpp`,lmstudio:`LM Studio`,omlx:`oMLX`,vllm:`vLLM`};function Qe(e,t){return e(`settingsProbe.profiles.`+(t||`default`),null,t||`使用默认设置`)}function $e(e){let t=Number(e);return Number.isSafeInteger(t)&&t>=0?t:0}function et(e){let t=e.provider||`openai_compatible`;return t===`openai`&&(t=`openai_compatible`),t===`anthropic`&&(t=`claude`),{name:e.name||``,provider:t,base_url:e.base_url||``,api_key:e.api_key||``,model:e.model||``,image_input:e.image_input||``,context_profile:e.context_profile||``,context_window:e.context_window>0?String(e.context_window):``,max_total_tokens:e.max_total_tokens||0,max_completion_tokens:e.max_completion_tokens||0,headers:e.headers||void 0}}function tt(e,t){return[{label:e(`settingsProbe.result`,null,`测试结果`),value:(0,X.jsx)(u,{color:`green`,children:e(`settingsBasic.testSuccess`,null,`连接成功`)})},{label:e(`settingsBasic.model`,null,`模型`),value:t.model||`—`},{label:e(`settingsProbe.latency`,null,`响应耗时`),value:t.latency_ms==null?`—`:e(`settingsProbe.milliseconds`,{value:t.latency_ms},`${t.latency_ms} 毫秒`)}]}function nt(e,t,n){let r=t.context_source,i=r?.replace(/^omlx_models_(?=max_model_len|context_length|max_context_length|context_window)/,`openai_models_`),a=t.context_backend;return[...tt(e,t),{label:e(`settingsProbe.window`,null,`上下文窗口`),value:t.context_window||n||`—`},{label:e(`settingsProbe.backend`,null,`模型接口类型`),value:a===`openai_compatible`?e(`settingsProbe.compatible`,null,`兼容 OpenAI 的接口`):Ze[a]||a||`—`},{label:e(`settingsProbe.source`,null,`窗口信息来源`),value:n?e(`settingsProbe.windowDefault`,null,`默认值`):r?e(`settingsProbe.sources.`+i,null,r):`—`},{label:e(`settingsProbe.profile`,null,`上下文配置`),value:Qe(e,t.context_profile)},{label:e(`settingsProbe.effectiveBudget`,null,`实际可用上下文令牌数`),value:t.effective_max_total_tokens??`—`}]}function rt({state:e,defaultWindow:t,model:n,onModelChange:r,disabled:i}){let a=M(),s=(0,J.useId)(),{key:c,payload:l,error:d}=e;if(d)return(0,X.jsx)(B,{error:d});if(!l)return null;if(c===`list`){if(!l.success)return(0,X.jsx)(T,{type:l.supported===!1?`info`:`danger`,bordered:!0,closeIcon:null,description:l.error||a(`settingsBasic.modelsListFailed`,null,`获取模型列表失败`)});let e=Array.isArray(l.models)?l.models:[],t=a(`settingsBasic.modelsListSelectPlaceholder`,null,`请选择模型`);return(0,X.jsx)(`div`,{className:`settings-probe-result`,children:(0,X.jsxs)(o,{wrap:!0,spacing:8,children:[(0,X.jsx)(He,{children:a(`settingsBasic.modelsListSuccess`,{count:l.count??e.length},`已获取 ${l.count??e.length} 个模型`)}),(0,X.jsx)(`span`,{id:s,hidden:!0,children:t}),e.length>0&&(0,X.jsx)(C,{filter:!0,"aria-labelledby":s,placeholder:t,value:e.includes(n)?n:void 0,optionList:e.map(e=>({value:e,label:e})),onChange:r,disabled:i,className:`settings-model-picker`})]})})}if(c===`audit`||c===`image`)return(0,X.jsx)(`div`,{className:`settings-probe-result`,children:l.success?(0,X.jsx)(z,{columns:3,items:tt(a,l).map((e,t)=>c===`image`&&t===0Line truncated
@@ -1 +1 @@
.settings-page{flex-direction:column;min-width:0;display:flex}.settings-tabs .semi-tabs-content{min-width:0;padding-top:0}.settings-tabs .semi-tabs-pane{min-width:0}.settings-tabs .semi-tabs-bar-left{flex:0 0 156px;margin-inline-end:24px}.settings-tabs .semi-tabs-bar-left .semi-tabs-tab{text-align:start;border-radius:8px;margin-bottom:4px;padding:12px 16px;font-size:13px}.settings-tabs .semi-tabs-bar-left .semi-tabs-tab-active{background:var(--semi-color-primary-light-default)}.settings-tabs .semi-tabs-bar-top{margin-bottom:16px}.settings-tabs .semi-tabs-bar-top .semi-tabs-tab{font-size:13px}.settings-loading-block{padding:18px 4px}.settings-token-filters{flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:14px;display:flex}.settings-token-conversation{width:280px;max-width:100%}.settings-hint{color:var(--semi-color-text-2);font-size:12px;line-height:1.6;display:inline-block}.settings-mono{word-break:break-all;font-family:SFMono-Regular,Consolas,Liberation Mono,monospace;font-size:12px}.settings-yaml-toolbar{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px;margin-bottom:10px;display:flex}.settings-yaml-input .semi-input-textarea{-moz-tab-size:2;tab-size:2;min-height:420px;font-family:SFMono-Regular,Consolas,Liberation Mono,monospace;font-size:12.5px;line-height:1.6}.settings-yaml-notice{margin-bottom:12px}.settings-schema{flex-direction:column;gap:14px;display:flex}.settings-schema-table{border-collapse:collapse;width:100%;font-size:12.5px}.settings-schema-table th,.settings-schema-table td{border-bottom:1px solid var(--semi-color-border);text-align:left;vertical-align:top;padding:8px 10px}.settings-schema-table th{color:var(--semi-color-text-2);font-weight:600}.settings-probe-form{grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:12px 16px;display:grid}.settings-field{flex-direction:column;gap:6px;min-width:0;display:flex}.settings-field-wide{grid-column:span 2}.settings-probe-actions{margin-top:14px}.settings-channel-panel .semi-card-header-wrapper{align-items:center;gap:8px}.settings-channel-notices{gap:8px;margin-top:14px;display:grid}.settings-probe-result{flex-direction:column;gap:10px;margin-top:12px;display:flex}.settings-model-tags{flex-wrap:wrap;gap:6px;max-height:190px;padding:2px;display:flex;overflow:auto}.settings-audit-model{border-top:1px solid var(--semi-color-border);margin-top:18px}.settings-probe-card{flex-direction:column;gap:8px;min-width:0;display:flex}.settings-probe-inline{grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:8px;display:grid}.settings-disk{flex-direction:column;gap:6px;max-width:720px;margin-bottom:16px;display:flex}.settings-policy-grid{grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:12px 16px;margin-bottom:10px;display:grid}.settings-incoming{margin-top:12px}.settings-incoming ul{margin:6px 0 0;padding-left:18px;font-size:12.5px;line-height:1.8}.settings-update-steps{max-height:360px;margin-top:16px;padding-right:4px;overflow:auto}.settings-audit-filters{flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:12px;display:flex}.settings-audit-banner{margin-bottom:12px}.settings-audit-detail{flex-direction:column;gap:16px;display:flex}.settings-audit-message-block{border:1px solid var(--semi-color-border);background:var(--semi-color-fill-0);word-break:break-word;border-radius:8px;flex-direction:column;gap:4px;padding:10px 12px;display:flex}.settings-appearance-status{margin-top:12px}@media (max-width:900px){.settings-field-wide{grid-column:span 1}.settings-yaml-input .semi-input-textarea{min-height:300px}}@media (max-width:480px){.settings-channel-panel .semi-card-header-wrapper{flex-direction:column-reverse;align-items:stretch}.settings-channel-panel .semi-card-header-wrapper-title{margin-inline-start:0;margin-inline-end:0}}.settings-update-source-form{flex-direction:column;gap:8px;max-width:760px;display:flex}
.settings-page{flex-direction:column;min-width:0;display:flex}.settings-tabs .semi-tabs-content{min-width:0;padding-top:0}.settings-tabs .semi-tabs-pane{min-width:0}.settings-tabs .semi-tabs-bar-left{flex:0 0 156px;margin-inline-end:24px}.settings-tabs .semi-tabs-bar-left .semi-tabs-tab{text-align:start;border-radius:8px;margin-bottom:4px;padding:12px 16px;font-size:13px}.settings-tabs .semi-tabs-bar-left .semi-tabs-tab-active{background:var(--semi-color-primary-light-default)}.settings-tabs .semi-tabs-bar-top{margin-bottom:16px}.settings-tabs .semi-tabs-bar-top .semi-tabs-tab{font-size:13px}.settings-loading-block{padding:18px 4px}.settings-token-filters{flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:14px;display:flex}.settings-token-conversation{width:280px;max-width:100%}.settings-hint{color:var(--semi-color-text-2);font-size:12px;line-height:1.6;display:inline-block}.settings-mono{word-break:break-all;font-family:SFMono-Regular,Consolas,Liberation Mono,monospace;font-size:12px}.settings-yaml-toolbar{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px;margin-bottom:10px;display:flex}.settings-yaml-input .semi-input-textarea{-moz-tab-size:2;tab-size:2;min-height:420px;font-family:SFMono-Regular,Consolas,Liberation Mono,monospace;font-size:12.5px;line-height:1.6}.settings-yaml-notice{margin-bottom:12px}.settings-schema{flex-direction:column;gap:14px;display:flex}.settings-schema-table{border-collapse:collapse;width:100%;font-size:12.5px}.settings-schema-table th,.settings-schema-table td{border-bottom:1px solid var(--semi-color-border);text-align:left;vertical-align:top;padding:8px 10px}.settings-schema-table th{color:var(--semi-color-text-2);font-weight:600}.settings-probe-form{grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:12px 16px;display:grid}.settings-field{flex-direction:column;gap:6px;min-width:0;display:flex}.settings-field-wide{grid-column:span 2}.settings-probe-actions{margin-top:14px}.settings-channel-panel .semi-card-header-wrapper{align-items:center;gap:8px}.settings-channel-notices{gap:8px;margin-top:14px;display:grid}.settings-probe-result{flex-direction:column;gap:10px;margin-top:12px;display:flex}.settings-model-picker{width:min(280px,60vw)}.settings-audit-model{border-top:1px solid var(--semi-color-border);margin-top:18px}.settings-probe-card{flex-direction:column;gap:8px;min-width:0;display:flex}.settings-probe-inline{grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:8px;display:grid}.settings-disk{flex-direction:column;gap:6px;max-width:720px;margin-bottom:16px;display:flex}.settings-policy-grid{grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:12px 16px;margin-bottom:10px;display:grid}.settings-incoming{margin-top:12px}.settings-incoming ul{margin:6px 0 0;padding-left:18px;font-size:12.5px;line-height:1.8}.settings-update-steps{max-height:360px;margin-top:16px;padding-right:4px;overflow:auto}.settings-audit-filters{flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:12px;display:flex}.settings-audit-banner{margin-bottom:12px}.settings-audit-detail{flex-direction:column;gap:16px;display:flex}.settings-audit-message-block{border:1px solid var(--semi-color-border);background:var(--semi-color-fill-0);word-break:break-word;border-radius:8px;flex-direction:column;gap:4px;padding:10px 12px;display:flex}.settings-appearance-status{margin-top:12px}@media (max-width:900px){.settings-field-wide{grid-column:span 1}.settings-yaml-input .semi-input-textarea{min-height:300px}}@media (max-width:480px){.settings-channel-panel .semi-card-header-wrapper{flex-direction:column-reverse;align-items:stretch}.settings-channel-panel .semi-card-header-wrapper-title{margin-inline-start:0;margin-inline-end:0}}.settings-update-source-form{flex-direction:column;gap:8px;max-width:760px;display:flex}
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{At as r,F as i,H as a,L as o,S as s,W as c,i as l,lt as u,ot as d,st as f,x as p}from"./semi-Dpcldp_F.js";import{E as m,F as h,I as g,P as _,T as v,a as y,b,c as x,d as S,f as C,l as w,m as T,n as E,p as D,s as O,x as k,y as A}from"./index-gBcdNgHq.js";var j=e(t(),1),M=e(n(),1),{Text:N}=c;function P(){let e=_(),{hasPermission:t}=h(),n=t(`skills:write`),s=t(`skills:delete`),[c,p]=(0,j.useState)(``),S=E(c,300),[C,P]=(0,j.useState)(1),[I,L]=(0,j.useState)(20),[R,z]=(0,j.useState)(null),[B,V]=(0,j.useState)(null),[H,U]=(0,j.useState)(!1),W=y(()=>g.get(`/skills`,{search:S||void 0,limit:I,offset:(C-1)*I}),[S,C,I]),G=Array.isArray(W.data?.skills)?W.data.skills:[],K=Number(W.data?.total||0),q=async()=>{if(H||!B?.form)return;let e=await B.form.validate().catch(()=>null);if(e){U(!0);try{await g.post(`/skills`,{name:e.name.trim(),description:e.description.trim(),content:e.content}),k(`技能已创建`),V(null),W.reload()}catch(e){b(e,`创建技能失败`)}finally{U(!1)}}},J=e=>A({title:`删除技能「${e.name}」?`,content:`该技能目录及其全部文件会被移除。`,onOk:async()=>{await g.del(`/skills/${encodeURIComponent(e.id||e.name)}`),k(`已删除`),W.reload()}});return(0,M.jsxs)(`div`,{children:[(0,M.jsx)(D,{title:e(`skills.managementTitle`,null,`技能管理`),description:`技能以目录形式存放在技能根目录,SKILL.md 描述触发条件与用法。`,extra:(0,M.jsxs)(i,{children:[(0,M.jsx)(o,{icon:(0,M.jsx)(f,{}),onClick:()=>W.reload(),loading:W.loading,children:`刷新`}),n&&(0,M.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,M.jsx)(u,{}),onClick:()=>V({form:{}}),children:`新建技能`})]})}),(0,M.jsxs)(T,{title:`技能(${K})`,children:[(0,M.jsx)(w,{error:W.error,onRetry:()=>W.reload()}),(0,M.jsx)(O,{columns:[{title:`技能`,dataIndex:`name`,render:(e,t)=>(0,M.jsxs)(i,{vertical:!0,spacing:0,align:`start`,children:[(0,M.jsx)(N,{strong:!0,children:e||t.id}),(0,M.jsx)(N,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:420},children:t.description})]})},{title:`版本`,dataIndex:`version`,width:100,render:e=>e||`—`},{title:`文件`,dataIndex:`file_count`,width:80,render:e=>String(e??`—`)},{title:`大小`,dataIndex:`file_size`,width:100,render:e=>v(e)},{title:`更新时间`,dataIndex:`mod_time`,width:170,render:e=>e?m(e):`—`},{title:`操作`,width:140,render:(e,t)=>(0,M.jsxs)(i,{children:[(0,M.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>z(t),children:`详情`}),s&&(0,M.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,M.jsx)(r,{}),onClick:()=>J(t)})]})}],dataSource:G,rowKey:e=>e.id||e.name,loading:W.loading,pagination:{currentPage:C,pageSize:I,total:K,onPageChange:P,onPageSizeChange:e=>{L(e),P(1)}},toolbar:(0,M.jsx)(a,{prefix:(0,M.jsx)(d,{}),value:c,onChange:e=>{p(e),P(1)},placeholder:`搜索技能名称或描述`,style:{width:280}})})]}),(0,M.jsx)(x,{title:`新建技能`,visible:!!B,onCancel:()=>V(null),onOk:q,confirmLoading:H,width:720,children:(0,M.jsxs)(l,{getFormApi:e=>V(t=>t&&{...t,form:e}),children:[(0,M.jsx)(l.Input,{field:`name`,label:`目录名`,placeholder:`小写字母、数字、连字符`,rules:[{required:!0,message:`请输入目录名`},{pattern:/^[a-z0-9-]+$/,message:`只允许小写字母、数字与连字符`}]}),(0,M.jsx)(l.Input,{field:`description`,label:`描述`,rules:[{required:!0,message:`请输入描述`}]}),(0,M.jsx)(l.TextArea,{field:`content`,label:`SKILL.md 正文`,rules:[{required:!0,message:`请输入正文`}],autosize:{minRows:10,maxRows:24}})]})},`new-skill`),(0,M.jsx)(F,{skill:R,onClose:()=>z(null),canWrite:n})]})}function F({skill:e,onClose:t,canWrite:n}){let[r,a]=(0,j.useState)([]),[c,l]=(0,j.useState)(``),[u,d]=(0,j.useState)(``),[f,m]=(0,j.useState)(!1),[h,_]=(0,j.useState)(!1);(0,j.useEffect)(()=>{e&&(a([]),l(``),d(``),g.get(`/skills/${encodeURIComponent(e.id||e.name)}/files`).then(e=>a(Array.isArray(e?.files)?e.files:[])).catch(()=>a([])))},[e]);let v=async t=>{m(!0);try{let n=await g.get(`/skills/${encodeURIComponent(e.id||e.name)}/file`,{path:t});l(t),d(n?.content||``)}catch(e){b(e,`读取文件失败`)}finally{m(!1)}},y=async()=>{_(!0);try{await g.put(`/skills/${encodeURIComponent(e.id||e.name)}/file`,{path:c,content:u}),k(`文件已保存`)}catch(e){b(e,`保存文件失败`)}finally{_(!1)}},w=r.map(e=>typeof e==`string`?e:e.path||e.name);return(0,M.jsx)(x,{title:e?.name||`技能详情`,visible:!!e,onCancel:t,width:860,children:e&&(0,M.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,M.jsx)(S,{items:[{label:`目录名`,value:e.id||e.dir_name},{label:`版本`,value:e.version||`—`},{label:`路径`,value:e.path},{label:`文件数`,value:e.file_count},{label:`触发词`,value:Array.isArray(e.triggers)?e.triggers.join(`、`):`—`},{label:`标签`,value:Array.isArray(e.tags)?e.tags.join(`、`):`—`}]}),(0,M.jsx)(N,{type:`tertiary`,children:e.description}),(0,M.jsxs)(`div`,{style:{displLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{At as r,F as i,H as a,L as o,S as s,W as c,i as l,lt as u,ot as d,st as f,x as p}from"./semi-Dpcldp_F.js";import{E as m,F as h,I as g,P as _,T as v,a as y,b,c as x,d as S,f as C,l as w,m as T,n as E,p as D,s as O,x as k,y as A}from"./index-BMTtTYg1.js";var j=e(t(),1),M=e(n(),1),{Text:N}=c;function P(){let e=_(),{hasPermission:t}=h(),n=t(`skills:write`),s=t(`skills:delete`),[c,p]=(0,j.useState)(``),S=E(c,300),[C,P]=(0,j.useState)(1),[I,L]=(0,j.useState)(20),[R,z]=(0,j.useState)(null),[B,V]=(0,j.useState)(null),[H,U]=(0,j.useState)(!1),W=y(()=>g.get(`/skills`,{search:S||void 0,limit:I,offset:(C-1)*I}),[S,C,I]),G=Array.isArray(W.data?.skills)?W.data.skills:[],K=Number(W.data?.total||0),q=async()=>{if(H||!B?.form)return;let e=await B.form.validate().catch(()=>null);if(e){U(!0);try{await g.post(`/skills`,{name:e.name.trim(),description:e.description.trim(),content:e.content}),k(`技能已创建`),V(null),W.reload()}catch(e){b(e,`创建技能失败`)}finally{U(!1)}}},J=e=>A({title:`删除技能「${e.name}」?`,content:`该技能目录及其全部文件会被移除。`,onOk:async()=>{await g.del(`/skills/${encodeURIComponent(e.id||e.name)}`),k(`已删除`),W.reload()}});return(0,M.jsxs)(`div`,{children:[(0,M.jsx)(D,{title:e(`skills.managementTitle`,null,`技能管理`),description:`技能以目录形式存放在技能根目录,SKILL.md 描述触发条件与用法。`,extra:(0,M.jsxs)(i,{children:[(0,M.jsx)(o,{icon:(0,M.jsx)(f,{}),onClick:()=>W.reload(),loading:W.loading,children:`刷新`}),n&&(0,M.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,M.jsx)(u,{}),onClick:()=>V({form:{}}),children:`新建技能`})]})}),(0,M.jsxs)(T,{title:`技能(${K})`,children:[(0,M.jsx)(w,{error:W.error,onRetry:()=>W.reload()}),(0,M.jsx)(O,{columns:[{title:`技能`,dataIndex:`name`,render:(e,t)=>(0,M.jsxs)(i,{vertical:!0,spacing:0,align:`start`,children:[(0,M.jsx)(N,{strong:!0,children:e||t.id}),(0,M.jsx)(N,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:420},children:t.description})]})},{title:`版本`,dataIndex:`version`,width:100,render:e=>e||`—`},{title:`文件`,dataIndex:`file_count`,width:80,render:e=>String(e??`—`)},{title:`大小`,dataIndex:`file_size`,width:100,render:e=>v(e)},{title:`更新时间`,dataIndex:`mod_time`,width:170,render:e=>e?m(e):`—`},{title:`操作`,width:140,render:(e,t)=>(0,M.jsxs)(i,{children:[(0,M.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>z(t),children:`详情`}),s&&(0,M.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,M.jsx)(r,{}),onClick:()=>J(t)})]})}],dataSource:G,rowKey:e=>e.id||e.name,loading:W.loading,pagination:{currentPage:C,pageSize:I,total:K,onPageChange:P,onPageSizeChange:e=>{L(e),P(1)}},toolbar:(0,M.jsx)(a,{prefix:(0,M.jsx)(d,{}),value:c,onChange:e=>{p(e),P(1)},placeholder:`搜索技能名称或描述`,style:{width:280}})})]}),(0,M.jsx)(x,{title:`新建技能`,visible:!!B,onCancel:()=>V(null),onOk:q,confirmLoading:H,width:720,children:(0,M.jsxs)(l,{getFormApi:e=>V(t=>t&&{...t,form:e}),children:[(0,M.jsx)(l.Input,{field:`name`,label:`目录名`,placeholder:`小写字母、数字、连字符`,rules:[{required:!0,message:`请输入目录名`},{pattern:/^[a-z0-9-]+$/,message:`只允许小写字母、数字与连字符`}]}),(0,M.jsx)(l.Input,{field:`description`,label:`描述`,rules:[{required:!0,message:`请输入描述`}]}),(0,M.jsx)(l.TextArea,{field:`content`,label:`SKILL.md 正文`,rules:[{required:!0,message:`请输入正文`}],autosize:{minRows:10,maxRows:24}})]})},`new-skill`),(0,M.jsx)(F,{skill:R,onClose:()=>z(null),canWrite:n})]})}function F({skill:e,onClose:t,canWrite:n}){let[r,a]=(0,j.useState)([]),[c,l]=(0,j.useState)(``),[u,d]=(0,j.useState)(``),[f,m]=(0,j.useState)(!1),[h,_]=(0,j.useState)(!1);(0,j.useEffect)(()=>{e&&(a([]),l(``),d(``),g.get(`/skills/${encodeURIComponent(e.id||e.name)}/files`).then(e=>a(Array.isArray(e?.files)?e.files:[])).catch(()=>a([])))},[e]);let v=async t=>{m(!0);try{let n=await g.get(`/skills/${encodeURIComponent(e.id||e.name)}/file`,{path:t});l(t),d(n?.content||``)}catch(e){b(e,`读取文件失败`)}finally{m(!1)}},y=async()=>{_(!0);try{await g.put(`/skills/${encodeURIComponent(e.id||e.name)}/file`,{path:c,content:u}),k(`文件已保存`)}catch(e){b(e,`保存文件失败`)}finally{_(!1)}},w=r.map(e=>typeof e==`string`?e:e.path||e.name);return(0,M.jsx)(x,{title:e?.name||`技能详情`,visible:!!e,onCancel:t,width:860,children:e&&(0,M.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,M.jsx)(S,{items:[{label:`目录名`,value:e.id||e.dir_name},{label:`版本`,value:e.version||`—`},{label:`路径`,value:e.path},{label:`文件数`,value:e.file_count},{label:`触发词`,value:Array.isArray(e.triggers)?e.triggers.join(`、`):`—`},{label:`标签`,value:Array.isArray(e.tags)?e.tags.join(`、`):`—`}]}),(0,M.jsx)(N,{type:`tertiary`,children:e.description}),(0,M.jsxs)(`div`,{style:{displLine truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{At as t,F as n,L as r,W as i,st as a}from"./semi-Dpcldp_F.js";import{D as o,F as s,I as c,O as l,P as u,_ as d,a as f,l as p,m,p as h,s as g,x as _,y as v}from"./index-gBcdNgHq.js";import{t as y}from"./react-QV7DAAIx.js";var b=e(y(),1),{Text:x}=i;function S(){let e=u(),{hasPermission:i}=s(),y=i(`skills:delete`),S=f(()=>c.get(`/skills/stats`),[]),C=Array.isArray(S.data?.stats)?S.data.stats:[],w=Number(S.data?.total_calls||0),T=Number(S.data?.total_success||0),E=w>0?T/w:null,D=()=>v({title:`清空所有技能调用统计?`,content:`只影响统计计数,不删除技能文件。`,onOk:async()=>{await c.del(`/skills/stats`),_(`统计已清空`),S.reload()}}),O=e=>v({title:`清空「${e}」的统计?`,onOk:async()=>{await c.del(`/skills/${encodeURIComponent(e)}/stats`),_(`已清空`),S.reload()}});return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(h,{title:e(`skills.monitorTitle`,null,`技能状态`),description:S.data?.skills_dir?`技能目录:${S.data.skills_dir}`:`统计技能被调用的次数、成功率与最近使用时间。`,extra:(0,b.jsxs)(n,{children:[(0,b.jsx)(r,{icon:(0,b.jsx)(a,{}),onClick:()=>S.reload(),loading:S.loading,children:`刷新`}),y&&(0,b.jsx)(r,{type:`danger`,theme:`light`,onClick:D,children:`清空全部统计`})]})}),(0,b.jsx)(d,{columns:4,metrics:[{id:`skills`,label:`技能总数`,value:o(S.data?.total_skills||0),loading:S.loading},{id:`calls`,label:`调用总数`,value:o(w),loading:S.loading},{id:`success`,label:`成功次数`,value:o(T),loading:S.loading},{id:`rate`,label:`成功率`,value:E===null?`—`:l(E),tone:E!==null&&E<.8?`warning`:`success`,loading:S.loading}]}),(0,b.jsxs)(m,{title:`按技能统计`,children:[(0,b.jsx)(p,{error:S.error,onRetry:()=>S.reload()}),(0,b.jsx)(g,{columns:[{title:`技能`,dataIndex:`skill_name`,render:e=>(0,b.jsx)(x,{strong:!0,children:e})},{title:`调用次数`,dataIndex:`total_calls`,width:120,render:e=>o(e||0)},{title:`成功`,dataIndex:`success_calls`,width:100,render:e=>o(e||0)},{title:`失败`,dataIndex:`failed_calls`,width:100,render:e=>Number(e)>0?(0,b.jsx)(x,{type:`danger`,children:o(e)}):`0`},{title:`最后调用`,dataIndex:`last_call_time`,width:180,render:e=>e||`—`},{title:`操作`,width:110,render:(e,n)=>y&&Number(n.total_calls)>0?(0,b.jsx)(r,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,b.jsx)(t,{}),onClick:()=>O(n.skill_name),children:`清空`}):null}],dataSource:C,rowKey:`skill_name`,loading:S.loading,pagination:{pageSize:20}})]})]})}export{S as default};
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{At as t,F as n,L as r,W as i,st as a}from"./semi-Dpcldp_F.js";import{D as o,F as s,I as c,O as l,P as u,_ as d,a as f,l as p,m,p as h,s as g,x as _,y as v}from"./index-BMTtTYg1.js";import{t as y}from"./react-QV7DAAIx.js";var b=e(y(),1),{Text:x}=i;function S(){let e=u(),{hasPermission:i}=s(),y=i(`skills:delete`),S=f(()=>c.get(`/skills/stats`),[]),C=Array.isArray(S.data?.stats)?S.data.stats:[],w=Number(S.data?.total_calls||0),T=Number(S.data?.total_success||0),E=w>0?T/w:null,D=()=>v({title:`清空所有技能调用统计?`,content:`只影响统计计数,不删除技能文件。`,onOk:async()=>{await c.del(`/skills/stats`),_(`统计已清空`),S.reload()}}),O=e=>v({title:`清空「${e}」的统计?`,onOk:async()=>{await c.del(`/skills/${encodeURIComponent(e)}/stats`),_(`已清空`),S.reload()}});return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(h,{title:e(`skills.monitorTitle`,null,`技能状态`),description:S.data?.skills_dir?`技能目录:${S.data.skills_dir}`:`统计技能被调用的次数、成功率与最近使用时间。`,extra:(0,b.jsxs)(n,{children:[(0,b.jsx)(r,{icon:(0,b.jsx)(a,{}),onClick:()=>S.reload(),loading:S.loading,children:`刷新`}),y&&(0,b.jsx)(r,{type:`danger`,theme:`light`,onClick:D,children:`清空全部统计`})]})}),(0,b.jsx)(d,{columns:4,metrics:[{id:`skills`,label:`技能总数`,value:o(S.data?.total_skills||0),loading:S.loading},{id:`calls`,label:`调用总数`,value:o(w),loading:S.loading},{id:`success`,label:`成功次数`,value:o(T),loading:S.loading},{id:`rate`,label:`成功率`,value:E===null?`—`:l(E),tone:E!==null&&E<.8?`warning`:`success`,loading:S.loading}]}),(0,b.jsxs)(m,{title:`按技能统计`,children:[(0,b.jsx)(p,{error:S.error,onRetry:()=>S.reload()}),(0,b.jsx)(g,{columns:[{title:`技能`,dataIndex:`skill_name`,render:e=>(0,b.jsx)(x,{strong:!0,children:e})},{title:`调用次数`,dataIndex:`total_calls`,width:120,render:e=>o(e||0)},{title:`成功`,dataIndex:`success_calls`,width:100,render:e=>o(e||0)},{title:`失败`,dataIndex:`failed_calls`,width:100,render:e=>Number(e)>0?(0,b.jsx)(x,{type:`danger`,children:o(e)}):`0`},{title:`最后调用`,dataIndex:`last_call_time`,width:180,render:e=>e||`—`},{title:`操作`,width:110,render:(e,n)=>y&&Number(n.total_calls)>0?(0,b.jsx)(r,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,b.jsx)(t,{}),onClick:()=>O(n.skill_name),children:`清空`}):null}],dataSource:C,rowKey:`skill_name`,loading:S.loading,pagination:{pageSize:20}})]})]})}export{S as default};
@@ -1,2 +1,2 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,y as i}from"./react-QV7DAAIx.js";import{F as a,H as o,L as s,M as c,N as l,W as u,c as ee,f as d,h as f,lt as p,ot as te,st as m,v as h,x as g}from"./semi-Dpcldp_F.js";import{E as _,F as v,I as y,P as b,_ as x,a as S,b as C,c as w,d as T,f as E,l as ne,m as D,n as O,p as k,r as re,s as ie,x as A,y as j}from"./index-gBcdNgHq.js";var M=e(t(),1),N={pending:{label:`待执行`,color:`amber`},running:{label:`执行中`,color:`blue`},paused:{label:`已暂停`,color:`grey`},completed:{label:`已完成`,color:`green`},cancelled:{label:`已取消`,color:`grey`}},P={pending:{label:`待执行`,color:`amber`},running:{label:`执行中`,color:`blue`},completed:{label:`已完成`,color:`green`},failed:{label:`失败`,color:`red`},cancelled:{label:`已取消`,color:`grey`},blocked:{label:`受阻`,color:`orange`}},F=[{value:`single`,label:`单代理(Pi SDK)`},{value:`deep`,label:`Deep(DeepAgent)`},{value:`plan_execute`,label:`Plan-Execute`},{value:`supervisor`,label:`Supervisor(专家路由)`}],I=[{value:``,label:`沿用全局设置`},{value:`off`,label:`关闭审批`},{value:`human`,label:`人工审批`},{value:`audit_agent`,label:`Agent 审批`},{value:`review_edit`,label:`Agent 审查编辑`}],L=[{value:`manual`,label:`手工执行`},{value:`cron`,label:`Cron 调度`}],ae=[{value:`all`,label:`全部状态`},{value:`pending`,label:`待执行`},{value:`running`,label:`执行中`},{value:`paused`,label:`已暂停`},{value:`completed`,label:`已完成`},{value:`cancelled`,label:`已取消`}];function R(e){let t=Array.isArray(e?.tasks)?e.tasks:[],n=t.length,r=t.filter(e=>e.status===`completed`).length,i=t.filter(e=>e.status===`failed`).length,a=t.filter(e=>e.status===`cancelled`).length,o=t.filter(e=>e.status===`blocked`).length,s=t.filter(e=>e.status===`running`).length,c=t.filter(e=>e.status===`pending`).length,l=r+i+a+o;return{total:n,completed:r,failed:i,cancelled:a,blocked:o,running:s,pending:c,done:l,percent:n?Math.round(l/n*100):0}}function oe(e){return(F.find(t=>t.value===String(e||`single`))||F[0]).label}function se(e){let t=N[String(e?.status||``)]||{label:e?.status||`—`,color:`grey`},n=e?.scheduleMode===`cron`&&e?.scheduleEnabled!==!1,r=e?.nextRunAt?new Date(e.nextRunAt):null,i=r&&Number.isFinite(r.getTime())?r.toLocaleString(`zh-CN`,{hour12:!1}):``,a=R(e),o=a.blocked>0?e?.lastRunError||`${a.blocked} 项受阻`:``;if(a.blocked>0&&a.completed===0&&a.failed===0)return{...t,label:`受阻(${a.blocked} 项)`,color:`orange`,sublabel:o};if(n&&e?.status===`completed`){let e=a.failed>0||a.blocked>0;return{...t,label:e?`本轮已结束 · 定时循环中`:`本轮已完成 · 定时循环中`,color:a.failed>0?`red`:a.blocked>0?`orange`:t.color,sublabel:o||(i?`下次执行:${i}`:``),note:`定时队列:子任务已跑完,到点将自动下一轮`}}if(n&&e?.status===`pending`&&i)return{...t,sublabel:`Cron 已排程 · 下次 ${i}`};if(e?.status===`completed`&&a.failed>0){let e=a.blocked>0?`,${a.blocked} 项受阻`:``;return{...t,label:`已结束(${a.failed} 项失败${e})`,color:`red`,sublabel:o}}return e?.status===`completed`&&a.blocked>0?{...t,label:`已结束(${a.blocked} 项受阻)`,color:`orange`,sublabel:o}:{...t,sublabel:``}}function z(e,t){if(!e)return`—`;let n=new Date(e).getTime(),r=t?new Date(t).getTime():Date.now();if(!Number.isFinite(n)||!Number.isFinite(r)||r<n)return`—`;let i=Math.round((r-n)/1e3);return i<60?`${i} 秒`:i<3600?`${Math.floor(i/60)} 分 ${i%60} 秒`:`${Math.floor(i/3600)} 小时 ${Math.floor(i%3600/60)} 分`}function B(e,t=`操作失败`){if(!e)return t;if(typeof e==`string`)return e;let n=e.payload;if(n&&typeof n==`object`){let e=n.error;if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=typeof e.message==`string`?e.message:``,n=typeof e.code==`string`?e.code:``;if(t)return n?`${t}(${n})`:t}if(typeof n.message==`string`&&n.message)return n.message}return typeof e.message==`string`&&e.message&&e.message!==`[object Object]`?e.message:t}function ce(e,t=`加载失败`){return e?{message:B(e,t)}:null}var V=e(r(),1),{Text:H}=u,U={title:``,tasksText:``,role:``,projectId:``,agentMode:`single`,hitlPolicy:``,scheduleMode:`manual`,cronExpr:``,concurrency:1,executeNow:!1},W=/^\S+\s+\S+\s+\S+\s+\S+\s+\S+$/;function le({visible:e,onCancel:t,onCreated:n}){let r=b(),{hasPermission:i}=v(),[a,s]=(0,M.useState)(U),[c,u]=(0,M.useState)([]),[ee,d]=(0,M.useState)([]),[f,p]=(0,M.useState)(null),[te,m]=(0,M.useState)(!1);(0,M.useEffect)(()=>{if(!e)return;s(U),m(!1);let t=!1;return i(`roles:read`)&&y.get(`/roles`).then(e=>{t||u(Array.isArray(e?.roles)?e.roles:[])}).catch(()=>{t||u([])}),i(`project:read`)&&y.get(`/projects`,{limit:500}).then(e=>{t||d(Array.isArray(e?.projects)?e.projects:[])}).catch(()=>{t||d([])}),()=>{t=!0}},[e,i]),(0,M.useEffect)(()=>{if(!e||!a.projectId||!i(`asset:read`)){p(null);return}let t=!1;return y.get(`/assets`,{project_id:a.projectId,page:1,page_size:1}).then(eLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,y as i}from"./react-QV7DAAIx.js";import{F as a,H as o,L as s,M as c,N as l,W as u,c as ee,f as d,h as f,lt as p,ot as te,st as m,v as h,x as g}from"./semi-Dpcldp_F.js";import{E as _,F as v,I as y,P as b,_ as x,a as S,b as C,c as w,d as T,f as E,l as ne,m as D,n as O,p as k,r as re,s as ie,x as A,y as j}from"./index-BMTtTYg1.js";var M=e(t(),1),N={pending:{label:`待执行`,color:`amber`},running:{label:`执行中`,color:`blue`},paused:{label:`已暂停`,color:`grey`},completed:{label:`已完成`,color:`green`},cancelled:{label:`已取消`,color:`grey`}},P={pending:{label:`待执行`,color:`amber`},running:{label:`执行中`,color:`blue`},completed:{label:`已完成`,color:`green`},failed:{label:`失败`,color:`red`},cancelled:{label:`已取消`,color:`grey`},blocked:{label:`受阻`,color:`orange`}},F=[{value:`single`,label:`单代理(Pi SDK)`},{value:`deep`,label:`Deep(DeepAgent)`},{value:`plan_execute`,label:`Plan-Execute`},{value:`supervisor`,label:`Supervisor(专家路由)`}],I=[{value:``,label:`沿用全局设置`},{value:`off`,label:`关闭审批`},{value:`human`,label:`人工审批`},{value:`audit_agent`,label:`Agent 审批`},{value:`review_edit`,label:`Agent 审查编辑`}],L=[{value:`manual`,label:`手工执行`},{value:`cron`,label:`Cron 调度`}],ae=[{value:`all`,label:`全部状态`},{value:`pending`,label:`待执行`},{value:`running`,label:`执行中`},{value:`paused`,label:`已暂停`},{value:`completed`,label:`已完成`},{value:`cancelled`,label:`已取消`}];function R(e){let t=Array.isArray(e?.tasks)?e.tasks:[],n=t.length,r=t.filter(e=>e.status===`completed`).length,i=t.filter(e=>e.status===`failed`).length,a=t.filter(e=>e.status===`cancelled`).length,o=t.filter(e=>e.status===`blocked`).length,s=t.filter(e=>e.status===`running`).length,c=t.filter(e=>e.status===`pending`).length,l=r+i+a+o;return{total:n,completed:r,failed:i,cancelled:a,blocked:o,running:s,pending:c,done:l,percent:n?Math.round(l/n*100):0}}function oe(e){return(F.find(t=>t.value===String(e||`single`))||F[0]).label}function se(e){let t=N[String(e?.status||``)]||{label:e?.status||`—`,color:`grey`},n=e?.scheduleMode===`cron`&&e?.scheduleEnabled!==!1,r=e?.nextRunAt?new Date(e.nextRunAt):null,i=r&&Number.isFinite(r.getTime())?r.toLocaleString(`zh-CN`,{hour12:!1}):``,a=R(e),o=a.blocked>0?e?.lastRunError||`${a.blocked} 项受阻`:``;if(a.blocked>0&&a.completed===0&&a.failed===0)return{...t,label:`受阻(${a.blocked} 项)`,color:`orange`,sublabel:o};if(n&&e?.status===`completed`){let e=a.failed>0||a.blocked>0;return{...t,label:e?`本轮已结束 · 定时循环中`:`本轮已完成 · 定时循环中`,color:a.failed>0?`red`:a.blocked>0?`orange`:t.color,sublabel:o||(i?`下次执行:${i}`:``),note:`定时队列:子任务已跑完,到点将自动下一轮`}}if(n&&e?.status===`pending`&&i)return{...t,sublabel:`Cron 已排程 · 下次 ${i}`};if(e?.status===`completed`&&a.failed>0){let e=a.blocked>0?`,${a.blocked} 项受阻`:``;return{...t,label:`已结束(${a.failed} 项失败${e})`,color:`red`,sublabel:o}}return e?.status===`completed`&&a.blocked>0?{...t,label:`已结束(${a.blocked} 项受阻)`,color:`orange`,sublabel:o}:{...t,sublabel:``}}function z(e,t){if(!e)return`—`;let n=new Date(e).getTime(),r=t?new Date(t).getTime():Date.now();if(!Number.isFinite(n)||!Number.isFinite(r)||r<n)return`—`;let i=Math.round((r-n)/1e3);return i<60?`${i} 秒`:i<3600?`${Math.floor(i/60)} 分 ${i%60} 秒`:`${Math.floor(i/3600)} 小时 ${Math.floor(i%3600/60)} 分`}function B(e,t=`操作失败`){if(!e)return t;if(typeof e==`string`)return e;let n=e.payload;if(n&&typeof n==`object`){let e=n.error;if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=typeof e.message==`string`?e.message:``,n=typeof e.code==`string`?e.code:``;if(t)return n?`${t}(${n})`:t}if(typeof n.message==`string`&&n.message)return n.message}return typeof e.message==`string`&&e.message&&e.message!==`[object Object]`?e.message:t}function ce(e,t=`加载失败`){return e?{message:B(e,t)}:null}var V=e(r(),1),{Text:H}=u,U={title:``,tasksText:``,role:``,projectId:``,agentMode:`single`,hitlPolicy:``,scheduleMode:`manual`,cronExpr:``,concurrency:1,executeNow:!1},W=/^\S+\s+\S+\s+\S+\s+\S+\s+\S+$/;function le({visible:e,onCancel:t,onCreated:n}){let r=b(),{hasPermission:i}=v(),[a,s]=(0,M.useState)(U),[c,u]=(0,M.useState)([]),[ee,d]=(0,M.useState)([]),[f,p]=(0,M.useState)(null),[te,m]=(0,M.useState)(!1);(0,M.useEffect)(()=>{if(!e)return;s(U),m(!1);let t=!1;return i(`roles:read`)&&y.get(`/roles`).then(e=>{t||u(Array.isArray(e?.roles)?e.roles:[])}).catch(()=>{t||u([])}),i(`project:read`)&&y.get(`/projects`,{limit:500}).then(e=>{t||d(Array.isArray(e?.projects)?e.projects:[])}).catch(()=>{t||d([])}),()=>{t=!0}},[e,i]),(0,M.useEffect)(()=>{if(!e||!a.projectId||!i(`asset:read`)){p(null);return}let t=!1;return y.get(`/assets`,{project_id:a.projectId,page:1,page_size:1}).then(eLine truncated
`).map(e=>e.trim()).filter(Boolean);if(!e.length){C(r(`tasks.noValidTask`,null,`没有有效的任务`));return}if(a.scheduleMode===`cron`){if(!a.cronExpr.trim()){C(r(`batchImportModal.cronExprRequired`,null,`请选择 Cron 调度后填写 Cron 表达式`));return}if(!W.test(a.cronExpr.trim())){C(r(`batchImportModal.cronExprInvalid`,null,`Cron 表达式格式错误,需要 5 段(分 时 日 月 周)`));return}}let t=Number(a.concurrency);(!Number.isFinite(t)||t<1)&&(t=1),t>8&&(t=8),m(!0);try{let i=await y.post(`/batch-tasks`,{title:a.title.trim(),tasks:e,role:a.role||``,projectId:a.projectId||``,agentMode:a.agentMode||`single`,hitlPolicy:a.hitlPolicy||``,scheduleMode:a.scheduleMode===`cron`?`cron`:`manual`,cronExpr:a.scheduleMode===`cron`?a.cronExpr.trim():``,concurrency:t,executeNow:!!a.executeNow});A(r(`tasks.batchQueueTitle`,null,`批量任务队列`)),n?.(i)}catch(e){C(B(e,r(`tasks.createBatchQueueFailed`,null,`创建批量任务队列失败`)))}finally{m(!1)}},okText:r(`batchImportModal.createQueue`,null,`创建队列`),cancelText:r(`common.cancel`,null,`取消`),confirmLoading:te,width:760,maskClosable:!1,children:[(0,V.jsxs)(`div`,{className:`task-form-grid`,children:[(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:r(`batchImportModal.queueTitle`,null,`任务标题`)}),(0,V.jsx)(o,{value:a.title,maxLength:200,placeholder:r(`batchImportModal.queueTitlePlaceholder`,null,`请输入任务标题(可选,用于标识和筛选)`),onChange:e=>_({title:e})})]}),(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:r(`batchImportModal.role`,null,`角色`)}),(0,V.jsx)(h,{value:a.role,style:{width:`100%`},optionList:[{value:``,label:r(`batchImportModal.defaultRole`,null,`默认`)},...c.map(e=>({value:e.name,label:e.name}))],onChange:e=>_({role:e})}),(0,V.jsx)(H,{type:`tertiary`,size:`small`,children:r(`batchImportModal.roleHint`,null,`选择一个角色,所有任务将使用该角色的配置(提示词和工具)执行。`)})]})]}),(0,V.jsxs)(`div`,{className:`task-form-grid`,children:[(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:r(`batchImportModal.project`,null,`所属项目`)}),(0,V.jsx)(h,{value:a.projectId,style:{width:`100%`},optionList:[{value:``,label:r(`batchImportModal.projectNone`,null,`(未绑定)`)},...ee.map(e=>({value:e.id,label:e.name||e.id}))],onChange:e=>_({projectId:e||``})})]}),(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:r(`batchImportModal.agentMode`,null,`代理模式`)}),(0,V.jsx)(h,{value:a.agentMode,style:{width:`100%`},optionList:F,onChange:e=>_({agentMode:e})}),(0,V.jsx)(H,{type:`tertiary`,size:`small`,children:r(`batchImportModal.agentModeHint`,null,`与对话页一致:Pi 单代理,或 Deep / Plan-Execute / Supervisor(后三种需已启用多代理)。`)})]})]}),(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:`资产范围`}),(0,V.jsx)(H,{type:`tertiary`,size:`small`,children:a.projectId?f==null?`资产库中该项目的全部资产`:`资产库中该项目的全部资产(${f})`:`选择项目后,使用资产库里该项目的资产。`})]}),(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:r(`batchImportModal.tasksList`,null,`任务列表(每行一个任务)`)}),(0,V.jsx)(g,{value:a.tasksText,rows:7,placeholder:r(`batchImportModal.tasksListPlaceholderExample`,null,`请输入任务列表,每行一个任务`),onChange:e=>_({tasksText:e})}),(0,V.jsx)(H,{type:`tertiary`,size:`small`,children:r(`batchImportModal.tasksListHint`,null,`每行输入一个任务指令,系统将按并发池执行这些任务。空行会被自动忽略。`)})]}),(0,V.jsxs)(`div`,{className:`task-form-grid`,children:[(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:r(`batchImportModal.hitlPolicy`,null,`工具审批`)}),(0,V.jsx)(h,{value:a.hitlPolicy,style:{width:`100%`},optionList:I,onChange:e=>_({hitlPolicy:e})})]}),(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:r(`batchImportModal.concurrency`,null,`并发数`)}),(0,V.jsx)(o,{type:`number`,min:1,max:8,value:String(a.concurrency),onChange:e=>_({concurrency:e})}),(0,V.jsx)(H,{type:`tertiary`,size:`small`,children:r(`batchImportModal.concurrencyHint`,null,`同时执行的子任务数量(1-8)。默认 1 为串行;含扫描类工具时建议 1-2。`)})]})]}),(0,V.jsxs)(`div`,{className:`task-form-grid`,children:[(0,V.jsxs)(`div`,{className:`task-form-field`,children:[(0,V.jsx)(H,{strong:!0,size:`small`,children:r(`batchImportModal.scheduleMode`,null,`调度方式`)}),(0,V.jsx)(h,{value:a.scheduleMode,style:{width:`100%`},optionList:L,onChange:e=>_({scheduleMode:e})})]}),(0,V.jsxs)(`div`,{className:`task-fLine truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{A as r,At as i,F as a,H as o,L as s,M as c,W as l,Yt as u,Z as d,lt as f,qt as p,st as m,u as h,x as g,z as _}from"./semi-Dpcldp_F.js";import{F as v,I as y,P as b,b as x,l as S,m as C,p as w,x as T,y as E}from"./index-gBcdNgHq.js";var D=e(t(),1),O=200,k=4096;function A(e){return JSON.parse(JSON.stringify(e))}function j(e){if(!e||typeof e.enabled!=`boolean`||e.rules!=null&&!Array.isArray(e.rules))throw Error(`服务端返回的配置格式不正确`);return{enabled:e.enabled,rules:(e.rules||[]).map(e=>({id:String(e.id||``),name:String(e.name||``),enabled:!!e.enabled,pattern:String(e.pattern||``),message:String(e.message||``)}))}}function M(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`rule-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function N(e){return new TextEncoder().encode(String(e||``)).length}function P(e){if(!e)return{index:-1,field:``,message:`请先加载拦截配置`};if(e.rules.length>100)return{index:-1,field:``,message:`最多可配置 100 条拦截规则`};for(let t=0;t<e.rules.length;t+=1){let n=e.rules[t];if(!n.name.trim())return{index:t,field:`name`,message:`第 ${t+1} 条规则缺少名称`};if(!n.pattern.trim())return{index:t,field:`pattern`,message:`第 ${t+1} 条规则缺少匹配正则`};if(N(n.name)>O)return{index:t,field:`name`,message:`第 ${t+1} 条规则名称超过 ${O} 字节`};if(N(n.pattern)>k)return{index:t,field:`pattern`,message:`第 ${t+1} 条规则正则超过 ${k} 字节`};if(N(n.message)>k)return{index:t,field:`message`,message:`第 ${t+1} 条规则提醒超过 ${k} 字节`}}return null}function F(e,t){return!e||!t?!1:JSON.stringify(e)!==JSON.stringify(t)}function I(e){return{enabled:!!e?.enabled,rules:(e?.rules||[]).map(e=>({id:e.id,name:e.name,enabled:!!e.enabled,pattern:e.pattern,message:e.message}))}}function L(e){return{enabled:!0,rules:[{id:e.id,name:e.name,enabled:!0,pattern:e.pattern,message:e.message}]}}var R=e(n(),1),{Text:z}=l,B=`http_request`,V=`{"url": "https://example.gov.cn"}`;function H({config:e,rule:t=null,disabled:n=!1,compact:r=!1}){let i=b(),l=!!t,[u,d]=(0,D.useState)(B),[f,p]=(0,D.useState)(V),[m,h]=(0,D.useState)(!1),[v,x]=(0,D.useState)(null),[C,w]=(0,D.useState)(null),T=async()=>{if(n||m)return;if(w(null),x(null),!l&&!e){w(Error(i(`toolGuard.loadFirst`,null,`请先加载拦截配置`)));return}if(!u.trim()){w(Error(i(`toolGuard.toolRequired`,null,`请填写测试工具名称`)));return}let r;try{if(r=JSON.parse(f),!r||Array.isArray(r)||typeof r!=`object`)throw Error(`not an object`)}catch{w(Error(i(`toolGuard.invalidArguments`,null,`工具参数必须是有效的 JSON 对象`)));return}h(!0);try{let n={config:l?L(t):I(e),toolName:u.trim(),arguments:r},a=await y.post(`/tool-guard/test`,n);if(!a||typeof a.blocked!=`boolean`)throw Error(i(`toolGuard.invalidTestResponse`,null,`服务端返回的测试结果格式不正确`));x(a)}catch(e){w(e)}finally{h(!1)}},E=v?.blocked,O=v?.match,k=!l&&e&&e.enabled===!1;return(0,R.jsxs)(`div`,{className:r?`tool-guard-test tool-guard-test-compact`:`tool-guard-test`,children:[(0,R.jsxs)(a,{vertical:!0,spacing:6,align:`start`,children:[(0,R.jsx)(z,{strong:!0,children:l?i(`toolGuard.testScopeSingle`,{name:t.name||i(`toolGuard.unnamedRule`,null,`未命名规则`)},`单条验证:${t.name||`未命名规则`}`):i(`toolGuard.testScopeAll`,null,`全部规则验证`)}),(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:l?i(`toolGuard.testSingleHint`,null,`仅验证本条规则,忽略总开关和规则启停;不保存、不执行工具。`):i(`toolGuard.testAllHint`,null,`按当前顺序与启停状态验证全部规则,不保存、不执行工具。`)})]}),(0,R.jsxs)(`div`,{className:`tool-guard-test-form`,children:[(0,R.jsxs)(`label`,{className:`tool-guard-field`,children:[(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:i(`toolGuard.testTool`,null,`工具名称`)}),(0,R.jsx)(o,{value:u,onChange:e=>{d(e),x(null)},placeholder:`http_request`})]}),(0,R.jsxs)(`label`,{className:`tool-guard-field tool-guard-field-wide`,children:[(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:i(`toolGuard.testArguments`,null,`工具参数(JSON 对象)`)}),(0,R.jsx)(g,{value:f,onChange:e=>{p(e),x(null)},rows:3,spellCheck:!1,className:`tool-guard-args`})]})]}),(0,R.jsx)(s,{theme:`solid`,type:`primary`,loading:m,disabled:n,onClick:T,className:`tool-guard-test-run`,children:m?i(`toolGuard.testing`,null,`验证中…`):i(`toolGuard.test`,null,`测试匹配`)}),(0,R.jsx)(S,{error:C}),v&&(0,R.jsxs)(`div`,{className:`tool-guard-test-result ${E?`is-blocked`:`is-pass`}`,children:[(0,R.jsxs)(a,{spacing:8,wrap:!0,children:[(0,R.jsx)(c,{color:E?`red`:k?`grey`:`green`,size:`small`,children:E?`blocked`:`passed`}),(0,R.jsx)(z,{strong:!0,children:l?E?i(`toolGuard.singleMatched`,null,`本条规则匹配成功`):i(`toolGuard.singleNotMatched`,null,`本条规则未匹配`):E?i(`t Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{A as r,At as i,F as a,H as o,L as s,M as c,W as l,Yt as u,Z as d,lt as f,qt as p,st as m,u as h,x as g,z as _}from"./semi-Dpcldp_F.js";import{F as v,I as y,P as b,b as x,l as S,m as C,p as w,x as T,y as E}from"./index-BMTtTYg1.js";var D=e(t(),1),O=200,k=4096;function A(e){return JSON.parse(JSON.stringify(e))}function j(e){if(!e||typeof e.enabled!=`boolean`||e.rules!=null&&!Array.isArray(e.rules))throw Error(`服务端返回的配置格式不正确`);return{enabled:e.enabled,rules:(e.rules||[]).map(e=>({id:String(e.id||``),name:String(e.name||``),enabled:!!e.enabled,pattern:String(e.pattern||``),message:String(e.message||``)}))}}function M(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`rule-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function N(e){return new TextEncoder().encode(String(e||``)).length}function P(e){if(!e)return{index:-1,field:``,message:`请先加载拦截配置`};if(e.rules.length>100)return{index:-1,field:``,message:`最多可配置 100 条拦截规则`};for(let t=0;t<e.rules.length;t+=1){let n=e.rules[t];if(!n.name.trim())return{index:t,field:`name`,message:`第 ${t+1} 条规则缺少名称`};if(!n.pattern.trim())return{index:t,field:`pattern`,message:`第 ${t+1} 条规则缺少匹配正则`};if(N(n.name)>O)return{index:t,field:`name`,message:`第 ${t+1} 条规则名称超过 ${O} 字节`};if(N(n.pattern)>k)return{index:t,field:`pattern`,message:`第 ${t+1} 条规则正则超过 ${k} 字节`};if(N(n.message)>k)return{index:t,field:`message`,message:`第 ${t+1} 条规则提醒超过 ${k} 字节`}}return null}function F(e,t){return!e||!t?!1:JSON.stringify(e)!==JSON.stringify(t)}function I(e){return{enabled:!!e?.enabled,rules:(e?.rules||[]).map(e=>({id:e.id,name:e.name,enabled:!!e.enabled,pattern:e.pattern,message:e.message}))}}function L(e){return{enabled:!0,rules:[{id:e.id,name:e.name,enabled:!0,pattern:e.pattern,message:e.message}]}}var R=e(n(),1),{Text:z}=l,B=`http_request`,V=`{"url": "https://example.gov.cn"}`;function H({config:e,rule:t=null,disabled:n=!1,compact:r=!1}){let i=b(),l=!!t,[u,d]=(0,D.useState)(B),[f,p]=(0,D.useState)(V),[m,h]=(0,D.useState)(!1),[v,x]=(0,D.useState)(null),[C,w]=(0,D.useState)(null),T=async()=>{if(n||m)return;if(w(null),x(null),!l&&!e){w(Error(i(`toolGuard.loadFirst`,null,`请先加载拦截配置`)));return}if(!u.trim()){w(Error(i(`toolGuard.toolRequired`,null,`请填写测试工具名称`)));return}let r;try{if(r=JSON.parse(f),!r||Array.isArray(r)||typeof r!=`object`)throw Error(`not an object`)}catch{w(Error(i(`toolGuard.invalidArguments`,null,`工具参数必须是有效的 JSON 对象`)));return}h(!0);try{let n={config:l?L(t):I(e),toolName:u.trim(),arguments:r},a=await y.post(`/tool-guard/test`,n);if(!a||typeof a.blocked!=`boolean`)throw Error(i(`toolGuard.invalidTestResponse`,null,`服务端返回的测试结果格式不正确`));x(a)}catch(e){w(e)}finally{h(!1)}},E=v?.blocked,O=v?.match,k=!l&&e&&e.enabled===!1;return(0,R.jsxs)(`div`,{className:r?`tool-guard-test tool-guard-test-compact`:`tool-guard-test`,children:[(0,R.jsxs)(a,{vertical:!0,spacing:6,align:`start`,children:[(0,R.jsx)(z,{strong:!0,children:l?i(`toolGuard.testScopeSingle`,{name:t.name||i(`toolGuard.unnamedRule`,null,`未命名规则`)},`单条验证:${t.name||`未命名规则`}`):i(`toolGuard.testScopeAll`,null,`全部规则验证`)}),(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:l?i(`toolGuard.testSingleHint`,null,`仅验证本条规则,忽略总开关和规则启停;不保存、不执行工具。`):i(`toolGuard.testAllHint`,null,`按当前顺序与启停状态验证全部规则,不保存、不执行工具。`)})]}),(0,R.jsxs)(`div`,{className:`tool-guard-test-form`,children:[(0,R.jsxs)(`label`,{className:`tool-guard-field`,children:[(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:i(`toolGuard.testTool`,null,`工具名称`)}),(0,R.jsx)(o,{value:u,onChange:e=>{d(e),x(null)},placeholder:`http_request`})]}),(0,R.jsxs)(`label`,{className:`tool-guard-field tool-guard-field-wide`,children:[(0,R.jsx)(z,{type:`tertiary`,size:`small`,children:i(`toolGuard.testArguments`,null,`工具参数(JSON 对象)`)}),(0,R.jsx)(g,{value:f,onChange:e=>{p(e),x(null)},rows:3,spellCheck:!1,className:`tool-guard-args`})]})]}),(0,R.jsx)(s,{theme:`solid`,type:`primary`,loading:m,disabled:n,onClick:T,className:`tool-guard-test-run`,children:m?i(`toolGuard.testing`,null,`验证中…`):i(`toolGuard.test`,null,`测试匹配`)}),(0,R.jsx)(S,{error:C}),v&&(0,R.jsxs)(`div`,{className:`tool-guard-test-result ${E?`is-blocked`:`is-pass`}`,children:[(0,R.jsxs)(a,{spacing:8,wrap:!0,children:[(0,R.jsx)(c,{color:E?`red`:k?`grey`:`green`,size:`small`,children:E?`blocked`:`passed`}),(0,R.jsx)(z,{strong:!0,children:l?E?i(`toolGuard.singleMatched`,null,`本条规则匹配成功`):i(`toolGuard.singleNotMatched`,null,`本条规则未匹配`):E?i(`t Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,y as i}from"./react-QV7DAAIx.js";import{A as a,At as o,Dt as s,F as c,H as l,L as u,M as d,St as f,U as p,W as m,a as h,c as g,f as _,i as v,lt as y,m as ee,ot as b,p as te,s as ne,st as re,v as x}from"./semi-Dpcldp_F.js";import{C as ie,E as S,F as ae,I as C,L as oe,P as se,R as w,S as T,_ as E,a as D,b as O,c as k,d as ce,f as A,h as j,l as le,m as ue,n as de,o as fe,p as pe,s as me,v as he,x as M,y as ge}from"./index-gBcdNgHq.js";var N=e(t(),1),_e=[`critical`,`high`,`medium`,`low`,`info`],P=[`open`,`confirmed`,`fixed`,`ignored`,`false_positive`],ve=[`q`,`severity`,`status`,`project_id`,`conversation_tag`,`task_tag`],ye=[10,20,50,100],be={critical:`dashboard.severityCritical`,high:`dashboard.severityHigh`,medium:`dashboard.severityMedium`,low:`dashboard.severityLow`,info:`dashboard.severityInfo`},F={open:`vulnerabilityPage.statusOpen`,confirmed:`vulnerabilityPage.statusConfirmed`,fixed:`vulnerabilityPage.statusFixed`,ignored:`vulnerabilityPage.statusIgnored`,false_positive:`vulnerabilityPage.statusFalsePositive`},I={open:`待处理`,confirmed:`已确认`,fixed:`已修复`,ignored:`已忽略`,false_positive:`误报`},L={retest:`复测结果`,retest_started:`复测分支已创建`,merge:`归并上报`,split:`拆分归并组`,detach:`解除关联`},R=[{value:``,key:`vulnerabilityPage.sortDefault`,fallback:`默认顺序`},{value:`severity`,key:`vulnerabilityPage.sortSeverity`,fallback:`高危优先`},{value:`latest`,key:`vulnerabilityPage.sortLatest`,fallback:`创建时间:最新优先`},{value:`oldest`,key:`vulnerabilityPage.sortOldest`,fallback:`创建时间:最早优先`}];function xe(e,t){if(!t)return`—`;let n=be[t];return n?e(n,null,ie[t]||t):String(t)}function z(e,t){if(!t)return`—`;let n=F[t];return n?e(n,null,I[t]||t):String(t)}function Se(e,t){return t?e(`vulnerabilityPage.history_${t}`,null,L[t]||t):`—`}function B(e){return _e.map(t=>({value:t,label:xe(e,t)}))}function V(e){return P.map(t=>({value:t,label:z(e,t)}))}function Ce(e){return R.map(t=>({value:t.value,label:e(t.key,null,t.fallback)}))}function we(e){let t={};return ve.forEach(n=>{let r=String(e?.[n]??``).trim();r&&(t[n]=r)}),t}function Te(e){let t=we(e);return delete t.severity,t}function Ee(e){return ve.some(t=>String(e?.[t]??``).trim()!==``)}function De(e,t){let n=Number(e)||0,r=Number(t)||0;return r>0?Math.round(n/r*100):0}function Oe(e){return String(e?.target||``).trim()}function ke(e){return(Array.isArray(e?.targets)?e.targets:[]).map(e=>e?.host).find(Boolean)||e?.target_host||e?.target_domain||``}function H(e){if(!e)return`—`;let t=e.host||e.id||`—`;return e.port?`${t}:${e.port}`:t}function U(e,t=8){let n=String(e||``);return n.length>t?`${n.slice(0,t)}…`:n}function Ae(e,t){let n=new Blob([t],{type:`text/markdown;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);return i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3),e}var W=e(r(),1);function G(e,t){return[{value:``,label:e},...t]}function je({t:e,filters:t,options:n,projectOptions:r,hasGroupFilters:i,onChange:a,onReset:o}){let[s,c]=(0,N.useState)(t.q),d=de(s,380),f=(0,N.useRef)(t.q);(0,N.useEffect)(()=>{d!==f.current&&(f.current=d,a(`q`,d))},[d,a]),(0,N.useEffect)(()=>{t.q!==f.current&&(f.current=t.q,c(t.q))},[t.q]);let p=Array.isArray(n?.conversation_tags)?n.conversation_tags:[],m=Array.isArray(n?.task_tags)?n.task_tags:[];return(0,W.jsxs)(`div`,{className:`vulnerability-filter-bar`,children:[(0,W.jsx)(l,{className:`vulnerability-filter-search`,prefix:(0,W.jsx)(b,{}),value:s,showClear:!0,placeholder:e(`vulnerabilityPage.searchKeyword`,null,`搜索标题、描述、类型、目标…`),"aria-label":e(`vulnerabilityPage.searchKeyword`,null,`搜索标题、描述、类型、目标…`),onChange:e=>c(e)}),(0,W.jsx)(x,{className:`vulnerability-filter-select`,value:t.severity,placeholder:e(`vulnerabilityPage.severity`,null,`严重程度`),optionList:G(e(`vulnerabilityPage.allSeverities`,null,`全部级别`),B(e)),onChange:e=>a(`severity`,e||``)}),(0,W.jsx)(x,{className:`vulnerability-filter-select`,value:t.status,placeholder:e(`vulnerabilityPage.status`,null,`状态`),optionList:G(e(`dashboard.allStatuses`,null,`全部状态`),V(e)),onChange:e=>a(`status`,e||``)}),(0,W.jsx)(x,{className:`vulnerability-filter-select vulnerability-filter-select--wide`,value:t.project_id,placeholder:e(`vulnerabilityPage.detailProject`,null,`所属项目`),filter:!0,optionList:G(e(`vulnerabilityPage.allProjects`,null,`全部项目`),r),onChange:e=>a(`project_id`,e||``)}),(0,W.jsx)(x,{className:`vulnerability-filter-select`,value:t.conversation_tag,placeholder:e(`vulnerabilityPage.conversationTag`,null,`来源(对话标签)`),filter:!0,optionList:G(e(`vulnerabilityPage.allSources`,null,`全部来源`),p.map(e=>({value:e,label:e}))),onChange:e=>a(`conversation_tag`,e||``)}),(0,W.jsx)(x,{className:`vulnerability-filter-select`Line truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r,y as i}from"./react-QV7DAAIx.js";import{A as a,At as o,Dt as s,F as c,H as l,L as u,M as d,St as f,U as p,W as m,a as h,c as g,f as _,i as v,lt as y,m as ee,ot as b,p as te,s as ne,st as re,v as x}from"./semi-Dpcldp_F.js";import{C as ie,E as S,F as ae,I as C,L as oe,P as se,R as w,S as T,_ as E,a as D,b as O,c as k,d as ce,f as A,h as j,l as le,m as ue,n as de,o as fe,p as pe,s as me,v as he,x as M,y as ge}from"./index-BMTtTYg1.js";var N=e(t(),1),_e=[`critical`,`high`,`medium`,`low`,`info`],P=[`open`,`confirmed`,`fixed`,`ignored`,`false_positive`],ve=[`q`,`severity`,`status`,`project_id`,`conversation_tag`,`task_tag`],ye=[10,20,50,100],be={critical:`dashboard.severityCritical`,high:`dashboard.severityHigh`,medium:`dashboard.severityMedium`,low:`dashboard.severityLow`,info:`dashboard.severityInfo`},F={open:`vulnerabilityPage.statusOpen`,confirmed:`vulnerabilityPage.statusConfirmed`,fixed:`vulnerabilityPage.statusFixed`,ignored:`vulnerabilityPage.statusIgnored`,false_positive:`vulnerabilityPage.statusFalsePositive`},I={open:`待处理`,confirmed:`已确认`,fixed:`已修复`,ignored:`已忽略`,false_positive:`误报`},L={retest:`复测结果`,retest_started:`复测分支已创建`,merge:`归并上报`,split:`拆分归并组`,detach:`解除关联`},R=[{value:``,key:`vulnerabilityPage.sortDefault`,fallback:`默认顺序`},{value:`severity`,key:`vulnerabilityPage.sortSeverity`,fallback:`高危优先`},{value:`latest`,key:`vulnerabilityPage.sortLatest`,fallback:`创建时间:最新优先`},{value:`oldest`,key:`vulnerabilityPage.sortOldest`,fallback:`创建时间:最早优先`}];function xe(e,t){if(!t)return`—`;let n=be[t];return n?e(n,null,ie[t]||t):String(t)}function z(e,t){if(!t)return`—`;let n=F[t];return n?e(n,null,I[t]||t):String(t)}function Se(e,t){return t?e(`vulnerabilityPage.history_${t}`,null,L[t]||t):`—`}function B(e){return _e.map(t=>({value:t,label:xe(e,t)}))}function V(e){return P.map(t=>({value:t,label:z(e,t)}))}function Ce(e){return R.map(t=>({value:t.value,label:e(t.key,null,t.fallback)}))}function we(e){let t={};return ve.forEach(n=>{let r=String(e?.[n]??``).trim();r&&(t[n]=r)}),t}function Te(e){let t=we(e);return delete t.severity,t}function Ee(e){return ve.some(t=>String(e?.[t]??``).trim()!==``)}function De(e,t){let n=Number(e)||0,r=Number(t)||0;return r>0?Math.round(n/r*100):0}function Oe(e){return String(e?.target||``).trim()}function ke(e){return(Array.isArray(e?.targets)?e.targets:[]).map(e=>e?.host).find(Boolean)||e?.target_host||e?.target_domain||``}function H(e){if(!e)return`—`;let t=e.host||e.id||`—`;return e.port?`${t}:${e.port}`:t}function U(e,t=8){let n=String(e||``);return n.length>t?`${n.slice(0,t)}…`:n}function Ae(e,t){let n=new Blob([t],{type:`text/markdown;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);return i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3),e}var W=e(r(),1);function G(e,t){return[{value:``,label:e},...t]}function je({t:e,filters:t,options:n,projectOptions:r,hasGroupFilters:i,onChange:a,onReset:o}){let[s,c]=(0,N.useState)(t.q),d=de(s,380),f=(0,N.useRef)(t.q);(0,N.useEffect)(()=>{d!==f.current&&(f.current=d,a(`q`,d))},[d,a]),(0,N.useEffect)(()=>{t.q!==f.current&&(f.current=t.q,c(t.q))},[t.q]);let p=Array.isArray(n?.conversation_tags)?n.conversation_tags:[],m=Array.isArray(n?.task_tags)?n.task_tags:[];return(0,W.jsxs)(`div`,{className:`vulnerability-filter-bar`,children:[(0,W.jsx)(l,{className:`vulnerability-filter-search`,prefix:(0,W.jsx)(b,{}),value:s,showClear:!0,placeholder:e(`vulnerabilityPage.searchKeyword`,null,`搜索标题、描述、类型、目标…`),"aria-label":e(`vulnerabilityPage.searchKeyword`,null,`搜索标题、描述、类型、目标…`),onChange:e=>c(e)}),(0,W.jsx)(x,{className:`vulnerability-filter-select`,value:t.severity,placeholder:e(`vulnerabilityPage.severity`,null,`严重程度`),optionList:G(e(`vulnerabilityPage.allSeverities`,null,`全部级别`),B(e)),onChange:e=>a(`severity`,e||``)}),(0,W.jsx)(x,{className:`vulnerability-filter-select`,value:t.status,placeholder:e(`vulnerabilityPage.status`,null,`状态`),optionList:G(e(`dashboard.allStatuses`,null,`全部状态`),V(e)),onChange:e=>a(`status`,e||``)}),(0,W.jsx)(x,{className:`vulnerability-filter-select vulnerability-filter-select--wide`,value:t.project_id,placeholder:e(`vulnerabilityPage.detailProject`,null,`所属项目`),filter:!0,optionList:G(e(`vulnerabilityPage.allProjects`,null,`全部项目`),r),onChange:e=>a(`project_id`,e||``)}),(0,W.jsx)(x,{className:`vulnerability-filter-select`,value:t.conversation_tag,placeholder:e(`vulnerabilityPage.conversationTag`,null,`来源(对话标签)`),filter:!0,optionList:G(e(`vulnerabilityPage.allSources`,null,`全部来源`),p.map(e=>({value:e,label:e}))),onChange:e=>a(`conversation_tag`,e||``)}),(0,W.jsx)(x,{className:`vulnerability-filter-select`Line truncated
@@ -1,2 +1,2 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,T as c,U as l,W as u,at as d,c as f,i as p,lt as m,ot as h,st as g,x as _}from"./semi-Dpcldp_F.js";import{E as v,F as y,I as b,P as x,S,a as C,b as w,c as T,f as E,l as ee,n as te,o as D,p as O,s as k,u as ne,x as A,y as j}from"./index-gBcdNgHq.js";var M=e(t(),1);function N(e){return b.get(`/webshell/connections`,e)}function P(e){return b.post(`/webshell/connections`,e)}function F(e,t){return b.put(`/webshell/connections/${encodeURIComponent(e)}`,t)}function re(e){return b.del(`/webshell/connections/${encodeURIComponent(e)}`)}function I(e){return b.get(`/webshell/connections/${encodeURIComponent(e)}/state`)}function ie(e,t){return b.put(`/webshell/connections/${encodeURIComponent(e)}/state`,{state:t})}function L({connection:e,command:t}){return b.post(`/webshell/exec`,{connection_id:e.id,url:e.url,type:e.type||`php`,method:(e.method||`post`).toLowerCase(),cmd_param:e.cmdParam||``,encoding:e.encoding||`auto`,os:e.os||`auto`,command:t})}function R({connection:e,action:t,path:n,targetPath:r,content:i,chunkIndex:a}){let o={connection_id:e.id,url:e.url,type:e.type||`php`,method:(e.method||`post`).toLowerCase(),cmd_param:e.cmdParam||``,encoding:e.encoding||`auto`,os:e.os||`auto`,action:t};return n!==void 0&&(o.path=n),r!==void 0&&(o.target_path=r),i!==void 0&&(o.content=i),a!==void 0&&(o.chunk_index=a),b.post(`/webshell/file`,o)}function z(e){return b.get(`/webshell/connections/${encodeURIComponent(e)}/ai-conversations`)}function ae(e){return b.get(`/webshell/connections/${encodeURIComponent(e)}/ai-history`)}function B(e){return b.get(`/conversations/${encodeURIComponent(e)}`,{include_process_details:0})}async function oe(){try{let e=await b.get(`/projects`,{limit:200});return Array.isArray(e?.projects)?e.projects:[]}catch{return[]}}function se(){return`__CSAI_PROBE_${Math.random().toString(36).slice(2,10)}_${Date.now().toString(36)}__`}async function ce(e){let t=se(),n=await L({connection:e,command:`echo ${t}`});return{ok:!!n?.ok&&String(n?.output||``).includes(t),output:n?.output||``,error:n?.error||``}}var V=e(n(),1),{Text:le}=u,H=[{value:`php`,label:`PHP`},{value:`asp`,label:`ASP`},{value:`aspx`,label:`ASPX`},{value:`jsp`,label:`JSP`},{value:`custom`,label:`自定义`}],U=[{value:`post`,label:`POST`},{value:`get`,label:`GET`}],W=[{value:`auto`,label:`自动检测`},{value:`utf-8`,label:`UTF-8`},{value:`gbk`,label:`GBK(中文 Windows)`},{value:`gb18030`,label:`GB18030`}],G=[{value:`auto`,label:`自动(按 Shell 类型推断)`},{value:`linux`,label:`Linux / Unix`},{value:`windows`,label:`Windows`}];function K(e){return e?{url:e.url||``,password:e.password||``,type:e.type||`php`,method:(e.method||`post`).toLowerCase(),cmd_param:e.cmdParam||``,encoding:e.encoding||`auto`,os:e.os||`auto`,remark:e.remark||``,project_id:e.project_id||``}:{url:``,password:``,type:`php`,method:`post`,cmd_param:``,encoding:`auto`,os:`auto`,remark:``,project_id:``}}function ue({visible:e,record:t,projects:n,submitting:r,onCancel:a,onSubmit:s}){let c=x(),[l,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(!1);return(0,V.jsx)(T,{visible:e,title:t?c(`webshell.editConnectionTitle`,null,`编辑连接`):c(`webshell.addConnection`,null,`添加连接`),footer:(0,V.jsxs)(i,{children:[(0,V.jsx)(o,{onClick:async()=>{let e=l?.getValues?.()||{},n=String(e.url||``).trim();if(!n)S(c(`webshell.url`,null,`请填写 Shell 地址`));else if(e.password===`********`)S(c(`webshell.testNoExpectedOutput`,null,`已保存口令不可用于新建测试,请填写口令`));else{f(!0);try{let r=await ce({id:t?.id||``,url:n,password:e.password||``,type:e.type||`php`,method:e.method||`post`,cmdParam:e.cmd_param||``,encoding:e.encoding||`auto`,os:e.os||`auto`});r.ok?A(c(`webshell.testSuccess`,null,`连通性正常,Shell 可访问`)):w(r.error||c(`webshell.testFailed`,null,`连通性测试失败`))}catch(e){w(e,c(`webshell.testFailed`,null,`连通性测试失败`))}finally{f(!1)}}},loading:d,children:c(`webshell.testConnectivity`,null,`测试连通性`)}),(0,V.jsx)(o,{onClick:a,children:c(`webshell.cancelEdit`,null,`取消`)}),(0,V.jsx)(o,{theme:`solid`,type:`primary`,loading:r,onClick:()=>l?.submitForm(),children:t?c(`webshell.saveFile`,null,`保存`):c(`webshell.addConnection`,null,`添加连接`)})]}),width:600,onCancel:a,children:(0,V.jsxs)(p,{initValues:K(t),onSubmit:e=>{s({url:String(e.url||``).trim(),password:e.password||``,type:e.type||`php`,method:e.method||`post`,cmd_param:String(e.cmd_param||``).trim(),encoding:e.encoding||`auto`,os:e.os||`auto`,remark:String(e.remark||``).trim(),project_id:e.project_id||``})},getFormApi:u,labelPosition:`top`,children:[(0,V.jsx)(p.Input,{field:`url`,label:c(`webshell.url`,null,`Shell 地址`),placeholder:`http(s)://target.com/shell.php`,rules:[{required:!0,message:c(`webshell.url`,null,`请填写 Shell 地址`)}]}),(0,V.jsx)(p.Input,{field:`password`,label:c(`webshell.password`,nLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,T as c,U as l,W as u,at as d,c as f,i as p,lt as m,ot as h,st as g,x as _}from"./semi-Dpcldp_F.js";import{E as v,F as y,I as b,P as x,S,a as C,b as w,c as T,f as E,l as ee,n as te,o as D,p as O,s as k,u as ne,x as A,y as j}from"./index-BMTtTYg1.js";var M=e(t(),1);function N(e){return b.get(`/webshell/connections`,e)}function P(e){return b.post(`/webshell/connections`,e)}function F(e,t){return b.put(`/webshell/connections/${encodeURIComponent(e)}`,t)}function re(e){return b.del(`/webshell/connections/${encodeURIComponent(e)}`)}function I(e){return b.get(`/webshell/connections/${encodeURIComponent(e)}/state`)}function ie(e,t){return b.put(`/webshell/connections/${encodeURIComponent(e)}/state`,{state:t})}function L({connection:e,command:t}){return b.post(`/webshell/exec`,{connection_id:e.id,url:e.url,type:e.type||`php`,method:(e.method||`post`).toLowerCase(),cmd_param:e.cmdParam||``,encoding:e.encoding||`auto`,os:e.os||`auto`,command:t})}function R({connection:e,action:t,path:n,targetPath:r,content:i,chunkIndex:a}){let o={connection_id:e.id,url:e.url,type:e.type||`php`,method:(e.method||`post`).toLowerCase(),cmd_param:e.cmdParam||``,encoding:e.encoding||`auto`,os:e.os||`auto`,action:t};return n!==void 0&&(o.path=n),r!==void 0&&(o.target_path=r),i!==void 0&&(o.content=i),a!==void 0&&(o.chunk_index=a),b.post(`/webshell/file`,o)}function z(e){return b.get(`/webshell/connections/${encodeURIComponent(e)}/ai-conversations`)}function ae(e){return b.get(`/webshell/connections/${encodeURIComponent(e)}/ai-history`)}function B(e){return b.get(`/conversations/${encodeURIComponent(e)}`,{include_process_details:0})}async function oe(){try{let e=await b.get(`/projects`,{limit:200});return Array.isArray(e?.projects)?e.projects:[]}catch{return[]}}function se(){return`__CSAI_PROBE_${Math.random().toString(36).slice(2,10)}_${Date.now().toString(36)}__`}async function ce(e){let t=se(),n=await L({connection:e,command:`echo ${t}`});return{ok:!!n?.ok&&String(n?.output||``).includes(t),output:n?.output||``,error:n?.error||``}}var V=e(n(),1),{Text:le}=u,H=[{value:`php`,label:`PHP`},{value:`asp`,label:`ASP`},{value:`aspx`,label:`ASPX`},{value:`jsp`,label:`JSP`},{value:`custom`,label:`自定义`}],U=[{value:`post`,label:`POST`},{value:`get`,label:`GET`}],W=[{value:`auto`,label:`自动检测`},{value:`utf-8`,label:`UTF-8`},{value:`gbk`,label:`GBK(中文 Windows)`},{value:`gb18030`,label:`GB18030`}],G=[{value:`auto`,label:`自动(按 Shell 类型推断)`},{value:`linux`,label:`Linux / Unix`},{value:`windows`,label:`Windows`}];function K(e){return e?{url:e.url||``,password:e.password||``,type:e.type||`php`,method:(e.method||`post`).toLowerCase(),cmd_param:e.cmdParam||``,encoding:e.encoding||`auto`,os:e.os||`auto`,remark:e.remark||``,project_id:e.project_id||``}:{url:``,password:``,type:`php`,method:`post`,cmd_param:``,encoding:`auto`,os:`auto`,remark:``,project_id:``}}function ue({visible:e,record:t,projects:n,submitting:r,onCancel:a,onSubmit:s}){let c=x(),[l,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(!1);return(0,V.jsx)(T,{visible:e,title:t?c(`webshell.editConnectionTitle`,null,`编辑连接`):c(`webshell.addConnection`,null,`添加连接`),footer:(0,V.jsxs)(i,{children:[(0,V.jsx)(o,{onClick:async()=>{let e=l?.getValues?.()||{},n=String(e.url||``).trim();if(!n)S(c(`webshell.url`,null,`请填写 Shell 地址`));else if(e.password===`********`)S(c(`webshell.testNoExpectedOutput`,null,`已保存口令不可用于新建测试,请填写口令`));else{f(!0);try{let r=await ce({id:t?.id||``,url:n,password:e.password||``,type:e.type||`php`,method:e.method||`post`,cmdParam:e.cmd_param||``,encoding:e.encoding||`auto`,os:e.os||`auto`});r.ok?A(c(`webshell.testSuccess`,null,`连通性正常,Shell 可访问`)):w(r.error||c(`webshell.testFailed`,null,`连通性测试失败`))}catch(e){w(e,c(`webshell.testFailed`,null,`连通性测试失败`))}finally{f(!1)}}},loading:d,children:c(`webshell.testConnectivity`,null,`测试连通性`)}),(0,V.jsx)(o,{onClick:a,children:c(`webshell.cancelEdit`,null,`取消`)}),(0,V.jsx)(o,{theme:`solid`,type:`primary`,loading:r,onClick:()=>l?.submitForm(),children:t?c(`webshell.saveFile`,null,`保存`):c(`webshell.addConnection`,null,`添加连接`)})]}),width:600,onCancel:a,children:(0,V.jsxs)(p,{initValues:K(t),onSubmit:e=>{s({url:String(e.url||``).trim(),password:e.password||``,type:e.type||`php`,method:e.method||`post`,cmd_param:String(e.cmd_param||``).trim(),encoding:e.encoding||`auto`,os:e.os||`auto`,remark:String(e.remark||``).trim(),project_id:e.project_id||``})},getFormApi:u,labelPosition:`top`,children:[(0,V.jsx)(p.Input,{field:`url`,label:c(`webshell.url`,null,`Shell 地址`),placeholder:`http(s)://target.com/shell.php`,rules:[{required:!0,message:c(`webshell.url`,null,`请填写 Shell 地址`)}]}),(0,V.jsx)(p.Input,{field:`password`,label:c(`webshell.password`,nLine truncated
`);try{await navigator.clipboard.writeText(e),A(r(`webshell.terminalCopyOk`,null,`日志已复制`))}catch(e){w(e,r(`webshell.terminalCopyFail`,null,`复制失败`))}},children:r(`webshell.copyTerminalLog`,null,`复制日志`)})]})}),(0,V.jsxs)(`div`,{className:`webshell-terminal-log`,ref:h,children:[(0,V.jsx)(`div`,{className:`webshell-terminal-welcome`,children:r(`webshell.terminalWelcome`,null,`WebShell 虚拟终端 — 输入命令后按回车执行(Ctrl+L 清屏)`)}),c.map(e=>(0,V.jsx)(`pre`,{className:`webshell-terminal-line kind-${e.kind}`,children:e.kind===`cmd`?`$ ${e.text}`:e.text},e.id)),p&&(0,V.jsx)(`div`,{className:`webshell-terminal-pending`,children:r(`webshell.running`,null,`执行中…`)})]}),(0,V.jsxs)(`div`,{className:`webshell-terminal-input`,children:[(0,V.jsx)(a,{value:u,onChange:f,onEnterPress:()=>p?S(r(`webshell.waitFinish`,null,`请等待当前命令执行完成`)):_(),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`l`&&(e.preventDefault(),l([]))},placeholder:r(`webshell.commandPlaceholder`,null,`输入命令后回车执行`),disabled:p||!t,prefix:`$`}),(0,V.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,V.jsx)(d,{}),loading:p,disabled:!t,onClick:()=>_(),children:r(`webshell.runCommand`,null,`执行`)})]})]})}var{Text:be}=u;function xe({history:e,onClear:t,onRemove:n,onRun:r}){let a=x(),s=e.map((e,t)=>({...e,rowId:`${t}-${e.at}`})),c=[{title:a(`webshell.colCommand`,null,`命令`),dataIndex:`command`,render:e=>(0,V.jsx)(`code`,{className:`webshell-history-cmd`,children:e})},{title:a(`webshell.colExecutedAt`,null,`执行时间`),dataIndex:`at`,width:200,render:e=>v(e)},{title:a(`webshell.moreActions`,null,`操作`),dataIndex:`ops`,width:220,render:(e,t)=>(0,V.jsxs)(i,{spacing:4,children:[(0,V.jsx)(D,{text:t.command,label:a(`common.copied`,null,`复制`),size:`small`}),r&&(0,V.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>r(t.command),children:a(`webshell.rerun`,null,`再执行`)}),(0,V.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,onClick:()=>j({title:a(`webshell.deleteHistory`,null,`删除该条历史`),content:t.command,onOk:()=>n(t.rowId)}),children:a(`webshell.deleteFile`,null,`删除`)})]})}];return(0,V.jsxs)(`div`,{className:`webshell-history`,children:[(0,V.jsxs)(`div`,{className:`webshell-history-toolbar`,children:[(0,V.jsx)(be,{type:`tertiary`,children:a(`webshell.historyHint`,null,`仅记录本连接在当前浏览器执行过的命令`)}),(0,V.jsx)(i,{spacing:8,children:t&&(0,V.jsx)(o,{size:`small`,disabled:!s.length,onClick:()=>t(),children:a(`webshell.clearHistory`,null,`清空历史`)})})]}),(0,V.jsx)(k,{columns:c,dataSource:s,rowKey:`rowId`,pagination:{pageSize:15},emptyText:a(`webshell.noHistory`,null,`暂无命令历史`)})]})}var{Text:Se}=u,Ce={user:`blue`,assistant:`green`,system:`grey`,tool:`violet`};function we({connection:e}){let t=x(),[n,r]=(0,M.useState)([]),[i,a]=(0,M.useState)(``),[u,d]=(0,M.useState)([]),[f,p]=(0,M.useState)(!1),[m,h]=(0,M.useState)(null),_=(0,M.useCallback)(async()=>{if(e?.id){p(!0),h(null);try{let[t,n]=await Promise.all([z(e.id).catch(()=>[]),ae(e.id).catch(()=>null)]),i=Array.isArray(t)?t:[];r(i);let o=n?.conversationId||i[0]?.id||``;if(a(o),n?.conversationId)d(Array.isArray(n.messages)?n.messages:[]);else if(o){let e=await B(o).catch(()=>null);d(Array.isArray(e?.messages)?e.messages:[])}else d([])}catch(e){h(e)}finally{p(!1)}}},[e?.id]);(0,M.useEffect)(()=>{_()},[_]);let y=async e=>{if(e){a(e),p(!0);try{let t=await B(e);d(Array.isArray(t?.messages)?t.messages:[])}catch(e){h(e),d([])}finally{p(!1)}}};return(0,V.jsxs)(`div`,{className:`webshell-ai`,children:[(0,V.jsxs)(`div`,{className:`webshell-ai-sidebar`,children:[(0,V.jsxs)(`div`,{className:`webshell-ai-sidebar-head`,children:[(0,V.jsx)(Se,{strong:!0,children:t(`webshell.aiPreviousConversation`,null,`之前的对话`)}),(0,V.jsx)(o,{size:`small`,theme:`borderless`,icon:(0,V.jsx)(g,{}),onClick:_,loading:f})]}),n.length===0?(0,V.jsx)(c,{title:t(`webshell.aiNoConversation`,null,`暂无 AI 会话`),description:null,style:{padding:24}}):(0,V.jsx)(`ul`,{className:`webshell-ai-list`,children:n.map(e=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,className:`webshell-ai-item ${e.id===i?`is-active`:``}`,onClick:()=>y(e.id),children:[(0,V.jsx)(`span`,{className:`webshell-ai-title`,children:e.title||e.id}),(0,V.jsx)(`span`,{className:`webshell-ai-time`,children:v(e.updatedAt)})]})},e.id))})]}),(0,V.jsxs)(`div`,{className:`webshell-ai-main`,children:[(0,V.jsx)(ee,{error:m,onRetry:_}),f&&(0,V.jsx)(`div`,{className:`webshell-ai-loading`,children:(0,V.jsx)(l,{})}),!f&&u.length===0&&(0,V.jsx)(c,{title:t(`webshell.aiNoMessage`,null,`暂无对话消息`),description:null,style:{padding:48}}),!f&&u.map(e=>(0,V.jsxs)(`div`,{className:`webshell-ai-message`,children:[(0,V.jsxs)(`div`,{className:`webshell-ai-message-head`,children:[(0,V.jsx)(s,{size:`small`,color:Ce[e.role]||`grey`,children:e.role||`message`}),(0,V.jsx)(Se,{type:`tertiary`,size:`small`,children:v(e Line truncated
@@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,N as c,W as l,b as u,c as d,f,l as p,lt as m,m as h,ot as g,p as _,s as v,st as y,u as b,x,z as S}from"./semi-Dpcldp_F.js";import{E as C,F as w,I as T,L as E,P as D,_ as ee,a as O,b as k,c as te,d as A,l as j,m as M,n as ne,p as re,r as N,s as P,u as F,x as I,y as L}from"./index-gBcdNgHq.js";var R=e(t(),1),z=[{value:`start`,label:`开始`},{value:`tool`,label:`工具`},{value:`agent`,label:`Agent`},{value:`condition`,label:`条件`},{value:`hitl`,label:`审批`},{value:`output`,label:`输出`},{value:`end`,label:`结束`}],ie=Object.fromEntries(z.map(e=>[e.value,e.label])),B={running:{label:`执行中`,color:`blue`},awaiting_hitl:{label:`等待审批`,color:`amber`},completed:{label:`已完成`,color:`green`},failed:{label:`失败`,color:`red`},cancelled:{label:`已取消`,color:`grey`},pending:{label:`待执行`,color:`amber`}},V={nodes:[{id:`start`,type:`start`,label:`开始`,position:{x:80,y:140},config:{}},{id:`out`,type:`output`,label:`输出`,position:{x:380,y:140},config:{output_key:`result`}}],edges:[{id:`e1`,source:`start`,target:`out`,label:``}],config:{}},H={WFPKG_FILE_REQUIRED:`workflows.package.errors.fileRequired`,WFPKG_FILE_TOO_LARGE:`workflows.package.errors.fileTooLarge`,WFPKG_UNSUPPORTED_FORMAT:`workflows.package.errors.unsupportedFormat`,WFPKG_INVALID_ARCHIVE:`workflows.package.errors.invalidArchive`,WFPKG_INVALID_MANIFEST:`workflows.package.errors.invalidManifest`,WFPKG_CHECKSUM_MISMATCH:`workflows.package.errors.checksumMismatch`,WFPKG_MULTIPLE_WORKFLOWS:`workflows.package.errors.multipleWorkflows`,WFPKG_WORKFLOW_INVALID:`workflows.package.errors.workflowInvalid`,WFPKG_INSPECTION_NOT_FOUND:`workflows.package.errors.inspectionNotFound`,WFPKG_INSPECTION_EXPIRED:`workflows.package.errors.inspectionExpired`,WFPKG_INSPECTION_CONSUMED:`workflows.package.errors.inspectionConsumed`,WFPKG_CONFLICT_CHANGED:`workflows.package.errors.conflictChanged`,WFPKG_ID_CONFLICT:`workflows.package.errors.idConflict`,WFPKG_INVALID_ACTION:`workflows.package.errors.invalidAction`,WFPKG_INVALID_RENAME_ID:`workflows.package.errors.invalidRenameId`,WFPKG_OVERWRITE_CONFIRMATION_REQUIRED:`workflows.package.errors.overwriteConfirmationRequired`,WFPKG_IDEMPOTENCY_KEY_REQUIRED:`workflows.package.errors.idempotencyKeyRequired`,WFPKG_IDEMPOTENCY_KEY_REUSED:`workflows.package.errors.idempotencyKeyReused`,WFPKG_IMPORT_FAILED:`workflows.package.errors.importFailed`},U={create:{label:`创建导入`,hint:`导入后会创建一个新的本地工作流。`},keep_existing:{label:`保留本地版本`,hint:`不修改当前本地工作流;导入记录会保留。`},overwrite:{label:`覆盖本地版本`,hint:`替换名称、描述、图定义和启用状态;需要再次确认。`},rename:{label:`另存为新 ID`,hint:`保留当前本地工作流,并以新的 ID 创建副本。`}},W={none:[`create`],identical:[`keep_existing`],id_conflict:[`keep_existing`,`overwrite`,`rename`]};function G(e){return(W[e]||[]).slice()}function K(e){if(!e||!String(e).trim())return{graph:null,error:`图定义不能为空`};try{let t=JSON.parse(e);return!t||typeof t!=`object`?{graph:null,error:`图定义必须是 JSON 对象`}:{graph:{nodes:Array.isArray(t.nodes)?t.nodes:[],edges:Array.isArray(t.edges)?t.edges:[],config:t.config||{}},error:null}}catch(e){return{graph:null,error:e.message||`JSON 解析失败`}}}function ae(e){let{graph:t,error:n}=K(e);return t?{nodes:t.nodes,edges:t.edges,error:null}:{nodes:[],edges:[],error:n}}function q(e,t=12){let n=String(e||``);if(!n)return`—`;let r=n.startsWith(`sha256:`)?n.slice(7):n;return r.length>t?`${r.slice(0,t)}…`:r}function J(e,t=`操作失败`){if(!e)return t;if(typeof e==`string`)return e;let n=e.payload;if(n&&typeof n==`object`){let e=n.error;if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=typeof e.message==`string`?e.message:``,n=typeof e.code==`string`?e.code:``;if(t)return n?`${t}(${n})`:t}if(typeof n.message==`string`&&n.message)return n.message}return typeof e.message==`string`&&e.message&&e.message!==`[object Object]`?e.message:t}function oe(e,t=`加载失败`){return e?{message:J(e,t)}:null}function se(e){let t=e?.payload?.error;return t&&typeof t==`object`&&typeof t.code==`string`?t.code:``}function ce(e,t){let n=se(e);if(n&&H[n]){let e=t?.(H[n],null,``);if(e)return e}return J(e,`操作未完成,请稍后重试。`)}function le(){let e=typeof globalThis<`u`?globalThis.crypto:null;return!e||typeof e.randomUUID!=`function`?``:e.randomUUID()}var Y=e(n(),1),{Text:X}=l,ue=/^[A-Za-z0-9][A-Za-z0-9_-]*$/,de={id:``,name:``,description:``,version:1,enabled:!0,graph:``};function fe({visible:e,workflow:t,onCancel:n,onSaved:r}){let s=D(),{hasPermission:l}=w(),d=l(`workflow:execute`),[f,p]=(0,R.useState)(de),[m,h]=(0,R.useState)(!1),[g,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(null),b=!!t?.id;(0,R.useEffect)(()=>{if(e){if(y(null),h(!1),t){lLine truncated
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n,y as r}from"./react-QV7DAAIx.js";import{F as i,H as a,L as o,M as s,N as c,W as l,b as u,c as d,f,l as p,lt as m,m as h,ot as g,p as _,s as v,st as y,u as b,x,z as S}from"./semi-Dpcldp_F.js";import{E as C,F as w,I as T,L as E,P as D,_ as ee,a as O,b as k,c as te,d as A,l as j,m as M,n as ne,p as re,r as N,s as P,u as F,x as I,y as L}from"./index-BMTtTYg1.js";var R=e(t(),1),z=[{value:`start`,label:`开始`},{value:`tool`,label:`工具`},{value:`agent`,label:`Agent`},{value:`condition`,label:`条件`},{value:`hitl`,label:`审批`},{value:`output`,label:`输出`},{value:`end`,label:`结束`}],ie=Object.fromEntries(z.map(e=>[e.value,e.label])),B={running:{label:`执行中`,color:`blue`},awaiting_hitl:{label:`等待审批`,color:`amber`},completed:{label:`已完成`,color:`green`},failed:{label:`失败`,color:`red`},cancelled:{label:`已取消`,color:`grey`},pending:{label:`待执行`,color:`amber`}},V={nodes:[{id:`start`,type:`start`,label:`开始`,position:{x:80,y:140},config:{}},{id:`out`,type:`output`,label:`输出`,position:{x:380,y:140},config:{output_key:`result`}}],edges:[{id:`e1`,source:`start`,target:`out`,label:``}],config:{}},H={WFPKG_FILE_REQUIRED:`workflows.package.errors.fileRequired`,WFPKG_FILE_TOO_LARGE:`workflows.package.errors.fileTooLarge`,WFPKG_UNSUPPORTED_FORMAT:`workflows.package.errors.unsupportedFormat`,WFPKG_INVALID_ARCHIVE:`workflows.package.errors.invalidArchive`,WFPKG_INVALID_MANIFEST:`workflows.package.errors.invalidManifest`,WFPKG_CHECKSUM_MISMATCH:`workflows.package.errors.checksumMismatch`,WFPKG_MULTIPLE_WORKFLOWS:`workflows.package.errors.multipleWorkflows`,WFPKG_WORKFLOW_INVALID:`workflows.package.errors.workflowInvalid`,WFPKG_INSPECTION_NOT_FOUND:`workflows.package.errors.inspectionNotFound`,WFPKG_INSPECTION_EXPIRED:`workflows.package.errors.inspectionExpired`,WFPKG_INSPECTION_CONSUMED:`workflows.package.errors.inspectionConsumed`,WFPKG_CONFLICT_CHANGED:`workflows.package.errors.conflictChanged`,WFPKG_ID_CONFLICT:`workflows.package.errors.idConflict`,WFPKG_INVALID_ACTION:`workflows.package.errors.invalidAction`,WFPKG_INVALID_RENAME_ID:`workflows.package.errors.invalidRenameId`,WFPKG_OVERWRITE_CONFIRMATION_REQUIRED:`workflows.package.errors.overwriteConfirmationRequired`,WFPKG_IDEMPOTENCY_KEY_REQUIRED:`workflows.package.errors.idempotencyKeyRequired`,WFPKG_IDEMPOTENCY_KEY_REUSED:`workflows.package.errors.idempotencyKeyReused`,WFPKG_IMPORT_FAILED:`workflows.package.errors.importFailed`},U={create:{label:`创建导入`,hint:`导入后会创建一个新的本地工作流。`},keep_existing:{label:`保留本地版本`,hint:`不修改当前本地工作流;导入记录会保留。`},overwrite:{label:`覆盖本地版本`,hint:`替换名称、描述、图定义和启用状态;需要再次确认。`},rename:{label:`另存为新 ID`,hint:`保留当前本地工作流,并以新的 ID 创建副本。`}},W={none:[`create`],identical:[`keep_existing`],id_conflict:[`keep_existing`,`overwrite`,`rename`]};function G(e){return(W[e]||[]).slice()}function K(e){if(!e||!String(e).trim())return{graph:null,error:`图定义不能为空`};try{let t=JSON.parse(e);return!t||typeof t!=`object`?{graph:null,error:`图定义必须是 JSON 对象`}:{graph:{nodes:Array.isArray(t.nodes)?t.nodes:[],edges:Array.isArray(t.edges)?t.edges:[],config:t.config||{}},error:null}}catch(e){return{graph:null,error:e.message||`JSON 解析失败`}}}function ae(e){let{graph:t,error:n}=K(e);return t?{nodes:t.nodes,edges:t.edges,error:null}:{nodes:[],edges:[],error:n}}function q(e,t=12){let n=String(e||``);if(!n)return`—`;let r=n.startsWith(`sha256:`)?n.slice(7):n;return r.length>t?`${r.slice(0,t)}…`:r}function J(e,t=`操作失败`){if(!e)return t;if(typeof e==`string`)return e;let n=e.payload;if(n&&typeof n==`object`){let e=n.error;if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=typeof e.message==`string`?e.message:``,n=typeof e.code==`string`?e.code:``;if(t)return n?`${t}(${n})`:t}if(typeof n.message==`string`&&n.message)return n.message}return typeof e.message==`string`&&e.message&&e.message!==`[object Object]`?e.message:t}function oe(e,t=`加载失败`){return e?{message:J(e,t)}:null}function se(e){let t=e?.payload?.error;return t&&typeof t==`object`&&typeof t.code==`string`?t.code:``}function ce(e,t){let n=se(e);if(n&&H[n]){let e=t?.(H[n],null,``);if(e)return e}return J(e,`操作未完成,请稍后重试。`)}function le(){let e=typeof globalThis<`u`?globalThis.crypto:null;return!e||typeof e.randomUUID!=`function`?``:e.randomUUID()}var Y=e(n(),1),{Text:X}=l,ue=/^[A-Za-z0-9][A-Za-z0-9_-]*$/,de={id:``,name:``,description:``,version:1,enabled:!0,graph:``};function fe({visible:e,workflow:t,onCancel:n,onSaved:r}){let s=D(),{hasPermission:l}=w(),d=l(`workflow:execute`),[f,p]=(0,R.useState)(de),[m,h]=(0,R.useState)(!1),[g,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(null),b=!!t?.id;(0,R.useEffect)(()=>{if(e){if(y(null),h(!1),t){lLine truncated
+1 -1
View File
@@ -18,7 +18,7 @@
} catch (error) { /* first paint fallback */ }
})();
</script>
<script type="module" crossorigin src="/static/app/assets/index-gBcdNgHq.js"></script>
<script type="module" crossorigin src="/static/app/assets/index-BMTtTYg1.js"></script>
<link rel="modulepreload" crossorigin href="/static/app/assets/rolldown-runtime-WkwZ5CU-.js">
<link rel="modulepreload" crossorigin href="/static/app/assets/react-QV7DAAIx.js">
<link rel="modulepreload" crossorigin href="/static/app/assets/semi-Dpcldp_F.js">
+1 -1
View File
@@ -3077,7 +3077,7 @@
"fetchModels": "جلب القائمة",
"modelsListFetching": "جارٍ جلب قائمة النماذج...",
"modelsListSelectPlaceholder": "اختر نموذجًا",
"modelsListSuccess": "تم تحميل {count} نموذج — استخدم القائمة المنسدلة على اليمين، أو اكتب في حقل الإدخال",
"modelsListSuccess": "تم تحميل {{count}} نموذج",
"modelsListFailed": "فشل جلب قائمة النماذج",
"modelsListNeedApiKey": "يُرجى إدخال API Key أولاً",
"modelsListClaudeHint": "لا يدعم Claude جلب قائمة النماذج تلقائيًّا؛ أدخل اسم النموذج يدويًّا",
+1 -1
View File
@@ -3232,7 +3232,7 @@
"fetchModels": "Загрузить список",
"modelsListFetching": "Загрузка списка моделей...",
"modelsListSelectPlaceholder": "Выберите модель",
"modelsListSuccess": "Загружено моделей: {count} — выберите в списке справа или введите в поле",
"modelsListSuccess": "Загружено моделей: {{count}}",
"modelsListFailed": "Не удалось загрузить список моделей",
"modelsListNeedApiKey": "Сначала введите ключ API",
"modelsListClaudeHint": "Claude не поддерживает автозагрузку списка моделей; введите имя модели вручную",