fix(frontend): restore chat composer settings
This commit is contained in:
parent
b345b708ca
commit
daa1c57556
|
|
@ -0,0 +1,145 @@
|
|||
import { useId, useState } from 'react';
|
||||
import { Button, Select, SideSheet, Spin, Tag, Typography } from '@douyinfe/semi-ui';
|
||||
import { useResource } from '../../components/hooks';
|
||||
import { ErrorBanner, toastError } from '../../components/ui';
|
||||
import { api } from '../../lib/http';
|
||||
import { useT } from '../../lib/i18n';
|
||||
import { REASONING_EFFORTS, REASONING_MODES } from './useModelPreferences';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
function SettingSelect({ label, ...props }) {
|
||||
const id = useId();
|
||||
return (
|
||||
<div className="chat-setting-field">
|
||||
<Text id={id} strong>{label}</Text>
|
||||
<Select aria-labelledby={id} {...props} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function ChatSettings({
|
||||
onClose, narrow, busy, canReadConfig, canReadHitl, canEnableHitl,
|
||||
model, conversationId, draftApproval, onEnableDraftApproval
|
||||
}) {
|
||||
const t = useT();
|
||||
const [saving, setSaving] = useState(false);
|
||||
const approvals = useResource(
|
||||
() => api.get(conversationId ? `/hitl/config/${encodeURIComponent(conversationId)}` : '/hitl/default-config'),
|
||||
[conversationId, canReadHitl],
|
||||
{ skip: !canReadHitl }
|
||||
);
|
||||
const approvalMode = conversationId
|
||||
? (approvals.data?.hitl?.enabled ? approvals.data.hitl.mode : 'off')
|
||||
: approvals.data?.defaultMode;
|
||||
const approvalActive = approvalMode === 'approval' || approvalMode === 'review_edit';
|
||||
const approvalLabel = approvalMode === 'review_edit'
|
||||
? t('chat.hitlModeReviewEdit', null, '审查编辑')
|
||||
: t('chat.hitlModeApproval', null, '审批模式');
|
||||
const defaultChannel = model.config.data?.default_channel;
|
||||
const defaultModel = model.channels.find(([id]) => id === defaultChannel)?.[1]?.model;
|
||||
const defaultLabel = t('chat.aiChannelDefault', null, '跟随默认通道');
|
||||
const channelOptions = [
|
||||
{ value: '', label: defaultModel ? `${defaultLabel} · ${defaultModel}` : defaultLabel },
|
||||
...model.channels.map(([id, config]) => ({
|
||||
value: id,
|
||||
label: [config?.name || id, config?.model].filter(Boolean).join(' · ')
|
||||
}))
|
||||
];
|
||||
const reasoningLabels = {
|
||||
default: t('chat.reasoningModeDefault', null, '跟随系统'),
|
||||
off: t('chat.reasoningModeOff', null, '关闭'),
|
||||
on: t('chat.reasoningModeOn', null, '开启'),
|
||||
auto: t('chat.reasoningModeAuto', null, '自动')
|
||||
};
|
||||
|
||||
const enableApproval = async () => {
|
||||
const hitl = {
|
||||
enabled: true,
|
||||
mode: 'approval',
|
||||
reviewer: 'human',
|
||||
timeoutSeconds: approvals.data.defaultTimeoutSeconds ?? 300
|
||||
};
|
||||
if (!conversationId) {
|
||||
onEnableDraftApproval(hitl);
|
||||
return;
|
||||
}
|
||||
setSaving(true);
|
||||
try {
|
||||
await api.put('/hitl/config', { conversationId, ...hitl });
|
||||
approvals.setData(current => ({ ...current, hitl }));
|
||||
} catch (error) {
|
||||
toastError(error, t('chat.hitlApplyFail', null, '同步到服务器失败'));
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<SideSheet
|
||||
visible
|
||||
title={t('chat.sessionSettingsTitle', null, '会话设置')}
|
||||
width={narrow ? '100%' : 420}
|
||||
closable={!saving}
|
||||
maskClosable={!saving}
|
||||
closeOnEsc={!saving}
|
||||
onCancel={onClose}
|
||||
>
|
||||
<div className="chat-settings-fields">
|
||||
{canReadConfig && (
|
||||
<>
|
||||
<SettingSelect
|
||||
label={t('chat.aiChannelLabel', null, 'AI 通道')}
|
||||
value={model.channel}
|
||||
optionList={channelOptions}
|
||||
onSelect={model.setChannel}
|
||||
loading={model.config.loading}
|
||||
disabled={busy || model.config.loading || Boolean(model.config.error)}
|
||||
/>
|
||||
<ErrorBanner error={model.config.error} onRetry={() => model.config.reload()} />
|
||||
</>
|
||||
)}
|
||||
<SettingSelect
|
||||
label={t('chat.reasoningModeLabel', null, '模型推理')}
|
||||
value={model.mode}
|
||||
optionList={REASONING_MODES.map(value => ({ value, label: reasoningLabels[value] }))}
|
||||
onSelect={model.setMode}
|
||||
disabled={busy}
|
||||
/>
|
||||
<SettingSelect
|
||||
label={t('chat.reasoningEffortLabel', null, '推理强度')}
|
||||
value={model.mode === 'off' ? '' : model.effort}
|
||||
optionList={[
|
||||
{ value: '', label: t('chat.reasoningEffortUnset', null, '不指定') },
|
||||
...REASONING_EFFORTS.map(value => ({ value, label: value }))
|
||||
]}
|
||||
onSelect={model.setEffort}
|
||||
disabled={busy || model.mode === 'off'}
|
||||
/>
|
||||
{canReadHitl && (
|
||||
<section className="chat-setting-field">
|
||||
<Text strong>{t('chat.hitlTitle', null, '人机协同')}</Text>
|
||||
<ErrorBanner error={approvals.error} onRetry={() => approvals.reload()} />
|
||||
{approvals.loading && <Spin />}
|
||||
{approvals.data && !approvals.error && (
|
||||
<div className="chat-setting-approval">
|
||||
<Tag color={approvalActive || draftApproval ? 'green' : 'grey'}>
|
||||
{draftApproval && !conversationId
|
||||
? t('chat.hitlFirstMessageEnabled', null, '首条消息将使用人工审批')
|
||||
: approvalActive ? approvalLabel : t('chat.hitlModeOff', null, '关闭')}
|
||||
</Tag>
|
||||
{canEnableHitl && !approvalActive && !draftApproval && (
|
||||
<Button disabled={busy || saving} loading={saving} onClick={enableApproval}>
|
||||
{conversationId
|
||||
? t('chat.hitlEnableHuman', null, '开启人工审批')
|
||||
: t('chat.hitlEnableFirstMessage', null, '为首条消息开启人工审批')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
)}
|
||||
</div>
|
||||
</SideSheet>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/** 发送区:文本、附件、代理模式、项目选择、发送/停止。 */
|
||||
import { useRef } from 'react';
|
||||
import { Banner, Button, Select, Space, Tag, TextArea, Tooltip, Typography } from '@douyinfe/semi-ui';
|
||||
import { IconPaperclip, IconSend, IconStop } from '@douyinfe/semi-icons';
|
||||
import { IconPaperclip, IconSend, IconSetting, IconStop } from '@douyinfe/semi-icons';
|
||||
import { useT } from '../../lib/i18n';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
|
@ -20,6 +20,7 @@ export default function Composer({
|
|||
canExecute,
|
||||
mode,
|
||||
onModeChange,
|
||||
onOpenSettings,
|
||||
projectId,
|
||||
onProjectChange,
|
||||
projects,
|
||||
|
|
@ -139,6 +140,11 @@ export default function Composer({
|
|||
disabled={sending}
|
||||
/>
|
||||
)}
|
||||
{onOpenSettings && (
|
||||
<Button icon={<IconSetting aria-hidden="true" />} theme="borderless" onClick={onOpenSettings}>
|
||||
{t('chat.sessionSettingsTitle', null, '会话设置')}
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
<Space spacing={8} wrap className="chat-composer-submit">
|
||||
<Text type="tertiary" size="small" className="chat-composer-hint">
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { useT } from '../../lib/i18n';
|
|||
import { useDebounced, useInterval, useLocalStorage, useResource } from '../../components/hooks';
|
||||
import { toastError, toastSuccess, toastWarning } from '../../components/ui';
|
||||
import ChatHeader from './ChatHeader';
|
||||
import ChatSettings from './ChatSettings';
|
||||
import ConversationList from './ConversationList';
|
||||
import MessageList from './MessageList';
|
||||
import Composer, { AGENT_MODES } from './Composer';
|
||||
|
|
@ -16,6 +17,7 @@ import HitlDock from './HitlDock';
|
|||
import { PlanTasksSheet, TokenUsageSheet } from './Sheets';
|
||||
import { useAgentRun } from './useAgentRun';
|
||||
import { useConversationActions } from './useConversationActions';
|
||||
import { useModelPreferences } from './useModelPreferences';
|
||||
import './page.css';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
|
@ -52,6 +54,7 @@ export default function Page() {
|
|||
const canStop = hasPermission('tasks:write');
|
||||
const canReadHitl = hasPermission('hitl:read');
|
||||
const canDecideHitl = hasPermission('hitl:write');
|
||||
const canReadConfig = hasPermission('config:read');
|
||||
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const conversationId = searchParams.get('conversation') || '';
|
||||
|
|
@ -66,6 +69,9 @@ export default function Page() {
|
|||
const [newProjectId, setNewProjectId] = useState('');
|
||||
const [storedMode, setStoredMode] = useLocalStorage(MODE_STORAGE_KEY, 'single');
|
||||
const mode = AGENT_MODES.includes(storedMode) ? storedMode : 'single';
|
||||
const model = useModelPreferences(canReadConfig);
|
||||
const [settingsOpen, setSettingsOpen] = useState(false);
|
||||
const [draftApproval, setDraftApproval] = useState(null);
|
||||
|
||||
const [detail, setDetail] = useState(EMPTY_DETAIL);
|
||||
const [composers, setComposers] = useState(() => new Map());
|
||||
|
|
@ -179,6 +185,7 @@ export default function Page() {
|
|||
}, []);
|
||||
|
||||
const bindConversation = useCallback(id => {
|
||||
setDraftApproval(null);
|
||||
boundByRun.current = id;
|
||||
conversationRef.current = id;
|
||||
setSearchParams({ conversation: id }, { replace: true });
|
||||
|
|
@ -361,7 +368,7 @@ export default function Page() {
|
|||
}, [conversationId, updateComposer]);
|
||||
|
||||
const submit = useCallback(() => {
|
||||
if (!canWrite || !canExecute || sending || backgroundRunning || checkingRun) return;
|
||||
if (!canWrite || !canExecute || sending || backgroundRunning || checkingRun || model.waitingForChannel) return;
|
||||
const text = draft.trim();
|
||||
if (!text && !attachments.length) {
|
||||
toastWarning(t('chat.emptyMessage', null, '请输入内容或添加附件'));
|
||||
|
|
@ -390,8 +397,15 @@ export default function Page() {
|
|||
}));
|
||||
resetRun();
|
||||
updateComposer(conversationId, () => ({ draft: '', attachments: [] }));
|
||||
run.send({ message, attachments: ready, mode, projectId: newProjectId });
|
||||
}, [attachments, backgroundRunning, canWrite, canExecute, checkingRun, conversationId, draft, mode, newProjectId, resetRun, run, sending, t, updateComposer]);
|
||||
run.send({
|
||||
message,
|
||||
attachments: ready,
|
||||
mode,
|
||||
projectId: newProjectId,
|
||||
...model.request,
|
||||
hitl: !conversationId && canDecideHitl ? draftApproval || undefined : undefined
|
||||
});
|
||||
}, [attachments, backgroundRunning, canWrite, canExecute, canDecideHitl, checkingRun, conversationId, draft, draftApproval, mode, model, newProjectId, resetRun, run, sending, t, updateComposer]);
|
||||
|
||||
const conversation = detail.conversation;
|
||||
|
||||
|
|
@ -506,11 +520,13 @@ export default function Page() {
|
|||
onStop={stop}
|
||||
canStop={canStop}
|
||||
sending={sending || backgroundRunning}
|
||||
checkingRun={checkingRun}
|
||||
checkingRun={checkingRun || model.waitingForChannel}
|
||||
canWrite={canWrite}
|
||||
canExecute={canExecute}
|
||||
mode={mode}
|
||||
onModeChange={value => setStoredMode(AGENT_MODES.includes(value) ? value : 'single')}
|
||||
onOpenSettings={canReadConfig || canReadHitl || (canWrite && canExecute)
|
||||
? () => setSettingsOpen(true) : undefined}
|
||||
projectId={newProjectId}
|
||||
onProjectChange={value => setNewProjectId(value || '')}
|
||||
projects={projects}
|
||||
|
|
@ -522,6 +538,21 @@ export default function Page() {
|
|||
/>
|
||||
</div>
|
||||
</section>
|
||||
{settingsOpen && (
|
||||
<ChatSettings
|
||||
key={conversationId}
|
||||
onClose={() => setSettingsOpen(false)}
|
||||
narrow={narrow}
|
||||
busy={sending || backgroundRunning || checkingRun || !(canWrite && canExecute)}
|
||||
canReadConfig={canReadConfig}
|
||||
canReadHitl={canReadHitl}
|
||||
canEnableHitl={canDecideHitl}
|
||||
model={model}
|
||||
conversationId={conversationId}
|
||||
draftApproval={!conversationId ? draftApproval : null}
|
||||
onEnableDraftApproval={setDraftApproval}
|
||||
/>
|
||||
)}
|
||||
<SideSheet
|
||||
visible={narrow && sidebarOpen}
|
||||
placement="left"
|
||||
|
|
|
|||
|
|
@ -300,6 +300,9 @@
|
|||
.chat-composer-submit { min-width: 0; max-width: 100%; margin-inline-start: auto; justify-content: flex-end; }
|
||||
.chat-composer-submit > * { min-width: 0; max-width: 100%; }
|
||||
.chat-composer-hint { font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
|
||||
.chat-settings-fields { display: grid; gap: 16px; }
|
||||
.chat-setting-field { display: grid; gap: 8px; min-width: 0; }
|
||||
.chat-setting-approval { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
|
||||
|
||||
/* ---------- 侧滑面板 ---------- */
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ export function useAgentRun({
|
|||
});
|
||||
}, [conversationRef, flushLive, onSettled, requestDetailReload]);
|
||||
|
||||
const send = useCallback(({ message, attachments, mode, projectId }) => {
|
||||
const send = useCallback(({ message, attachments, mode, projectId, aiChannelId, reasoning, hitl }) => {
|
||||
const run = { live: createLiveState({ conversationId: conversationRef.current }), markedFinished: false, abort: null };
|
||||
runRef.current = run;
|
||||
liveRef.current = run.live;
|
||||
|
|
@ -80,7 +80,10 @@ export function useAgentRun({
|
|||
const streaming = mode !== 'single';
|
||||
const body = {
|
||||
message,
|
||||
conversationId: conversationRef.current || ''
|
||||
conversationId: conversationRef.current || '',
|
||||
aiChannelId,
|
||||
reasoning,
|
||||
hitl
|
||||
};
|
||||
if (!conversationRef.current && projectId) body.projectId = projectId;
|
||||
if (streaming) body.orchestration = mode;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
import { useState } from 'react';
|
||||
import { useResource } from '../../components/hooks';
|
||||
import { api } from '../../lib/http';
|
||||
|
||||
export const REASONING_MODES = ['default', 'off', 'on', 'auto'];
|
||||
export const REASONING_EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max'];
|
||||
|
||||
// The legacy composer stored plain strings under these keys.
|
||||
function useChatPreference(key, fallback) {
|
||||
const [value, setValue] = useState(() => {
|
||||
try { return localStorage.getItem(key) ?? fallback; } catch { return fallback; }
|
||||
});
|
||||
|
||||
return [value, next => {
|
||||
setValue(next);
|
||||
try { localStorage.setItem(key, next); } catch { /* storage unavailable */ }
|
||||
}];
|
||||
}
|
||||
|
||||
export function useModelPreferences(canReadConfig) {
|
||||
const [storedChannel, setChannel] = useChatPreference('cyberstrike-chat-ai-channel', '');
|
||||
const [storedMode, setMode] = useChatPreference('cyberstrike-chat-reasoning-mode', 'default');
|
||||
const [storedEffort, setEffort] = useChatPreference('cyberstrike-chat-reasoning-effort', '');
|
||||
const config = useResource(async () => (await api.get('/config'))?.ai, [canReadConfig], { skip: !canReadConfig });
|
||||
const channels = Object.entries(config.data?.channels || {}).sort(([a], [b]) => a.localeCompare(b));
|
||||
const normalizedChannel = storedChannel.trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
|
||||
const channel = channels.find(([id]) => id === storedChannel)?.[0]
|
||||
|| channels.find(([id]) => id === normalizedChannel)?.[0] || '';
|
||||
const mode = REASONING_MODES.includes(storedMode) ? storedMode : 'default';
|
||||
const effort = REASONING_EFFORTS.includes(storedEffort) ? storedEffort : '';
|
||||
const reasoning = {
|
||||
mode: mode === 'default' ? undefined : mode,
|
||||
effort: mode === 'off' ? undefined : effort || undefined
|
||||
};
|
||||
|
||||
return {
|
||||
channel, channels, setChannel, config, mode, setMode, effort, setEffort,
|
||||
waitingForChannel: Boolean(canReadConfig && storedChannel && config.loading),
|
||||
request: {
|
||||
aiChannelId: canReadConfig ? channel || undefined : undefined,
|
||||
reasoning: reasoning.mode || reasoning.effort ? reasoning : undefined
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -33,6 +33,99 @@ test('refreshing a conversation detects an active backend run and disables dupli
|
|||
expect(mockApi.writes()).toEqual([]);
|
||||
});
|
||||
|
||||
test.describe('chat composer settings', () => {
|
||||
test.use({ appPermissions: [...UI_PERMISSIONS, 'hitl:write'] });
|
||||
|
||||
test('restores legacy model preferences, saves changes, and sends them with a new message', async ({ page, mockApi }) => {
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
mockApi.respond('GET', '/api/config', { json: { ai: {
|
||||
default_channel: 'demo-primary',
|
||||
channels: {
|
||||
'demo-primary': { name: '示例通道 A', model: 'fixture-a' },
|
||||
'demo-backup': { name: '示例通道 B', model: 'fixture-b' }
|
||||
}
|
||||
} } });
|
||||
mockApi.respond('GET', '/api/hitl/default-config', { json: { defaultMode: 'off', defaultTimeoutSeconds: 120 } });
|
||||
const message = 'FAKE:请翻译这句示例文本。';
|
||||
const id = mockApi.enableChatStream(message);
|
||||
const main = await visit(page, 'chat');
|
||||
await page.evaluate(() => {
|
||||
localStorage.setItem('cyberstrike-chat-ai-channel', 'DEMO_BACKUP');
|
||||
localStorage.setItem('cyberstrike-chat-reasoning-mode', 'on');
|
||||
localStorage.setItem('cyberstrike-chat-reasoning-effort', 'low');
|
||||
});
|
||||
await page.reload();
|
||||
await ready(page);
|
||||
const openSettings = main.getByRole('button', { name: label('chat.sessionSettingsTitle'), exact: true });
|
||||
await openSettings.click();
|
||||
const settings = page.getByRole('dialog').filter({ hasText: label('chat.sessionSettingsTitle') });
|
||||
const channel = settings.getByRole('combobox', { name: label('chat.aiChannelLabel') });
|
||||
const mode = settings.getByRole('combobox', { name: label('chat.reasoningModeLabel') });
|
||||
const effort = settings.getByRole('combobox', { name: label('chat.reasoningEffortLabel') });
|
||||
await expect(channel).toContainText('示例通道 B · fixture-b');
|
||||
await expect(effort).toContainText('low');
|
||||
await channel.click();
|
||||
await expect(page.getByRole('option', { name: `${label('chat.aiChannelDefault')} · fixture-a` })).toBeVisible();
|
||||
await page.getByRole('option', { name: '示例通道 A · fixture-a' }).click();
|
||||
await mode.click();
|
||||
await page.getByRole('listbox').getByText(label('chat.reasoningModeOff'), { exact: true }).click();
|
||||
await expect(effort).toBeDisabled();
|
||||
await mode.click();
|
||||
await page.getByRole('listbox').getByText(label('chat.reasoningModeOn'), { exact: true }).click();
|
||||
await effort.click();
|
||||
await page.getByRole('listbox').getByText('medium', { exact: true }).click();
|
||||
await expect(effort).toContainText('medium');
|
||||
await expect.poll(async () => (await settings.boundingBox())?.width).toBeLessThanOrEqual(390);
|
||||
await page.reload();
|
||||
await ready(page);
|
||||
await openSettings.click();
|
||||
await expect(channel).toContainText('示例通道 A · fixture-a');
|
||||
await expect(effort).toContainText('medium');
|
||||
await settings.getByRole('button', { name: label('chat.hitlEnableFirstMessage') }).click();
|
||||
await expect(settings.getByText(label('chat.hitlFirstMessageEnabled'))).toBeVisible();
|
||||
await settings.locator('button.semi-sidesheet-close').click();
|
||||
const input = main.getByRole('textbox', { name: label('chat.composerLabel', '对话内容') });
|
||||
await input.fill(message);
|
||||
await input.press('Enter');
|
||||
await expect(page).toHaveURL(new RegExp(`#/chat\\?conversation=${id}$`));
|
||||
expect(mockApi.writes().map(({ path, body }) => ({ path, body }))).toEqual([{
|
||||
path: '/api/agent/stream',
|
||||
body: {
|
||||
message, conversationId: '', aiChannelId: 'demo-primary',
|
||||
reasoning: { mode: 'on', effort: 'medium' },
|
||||
hitl: { enabled: true, mode: 'approval', reviewer: 'human', timeoutSeconds: 120 }
|
||||
}
|
||||
}]);
|
||||
});
|
||||
|
||||
test('loads an existing conversation approval status and persists human approval on demand', async ({ page, mockApi }) => {
|
||||
const path = `/api/hitl/config/${CONVERSATION.id}`;
|
||||
const expected = { enabled: true, mode: 'approval', reviewer: 'human', timeoutSeconds: 90 };
|
||||
let hitl = { enabled: false, mode: 'off', sensitiveTools: ['fixture-existing-tool'] };
|
||||
mockApi.respond('GET', '/api/agent-loop/tasks', { json: { tasks: [] } });
|
||||
mockApi.respond('GET', path, () => ({ json: { hitl, defaultTimeoutSeconds: 90 } }));
|
||||
mockApi.respond('PUT', '/api/hitl/config', request => {
|
||||
hitl = request.body;
|
||||
return { json: { ok: true } };
|
||||
});
|
||||
await page.goto('/static/app/#/chat?conversation=' + CONVERSATION.id);
|
||||
const main = await ready(page);
|
||||
const openSettings = main.getByRole('button', { name: label('chat.sessionSettingsTitle'), exact: true });
|
||||
const settings = page.getByRole('dialog');
|
||||
await openSettings.click();
|
||||
const enable = settings.getByRole('button', { name: label('chat.hitlEnableHuman') });
|
||||
await expect(enable).toBeEnabled();
|
||||
expect(mockApi.writes()).toEqual([]);
|
||||
await enable.click();
|
||||
await expect(settings.getByText(label('chat.hitlModeApproval'), { exact: true })).toBeVisible();
|
||||
expect(mockApi.calls('PUT', '/api/hitl/config')[0]?.body).toEqual({ conversationId: CONVERSATION.id, ...expected });
|
||||
await settings.locator('button.semi-sidesheet-close').click();
|
||||
await openSettings.click();
|
||||
await expect(settings.getByText(label('chat.hitlModeApproval'), { exact: true })).toBeVisible();
|
||||
expect(mockApi.writes()).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('running-status stop permission', () => {
|
||||
test.use({ appPermissions: [...UI_PERMISSIONS, 'tasks:write'] });
|
||||
test('an authorized user can stop the displayed background run', async ({ page, mockApi }) => {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{C as r,I as i,P as a,U as o,V as s,i as c,it as l,j as u,ot as d,rt as f,xt as p,yt as m}from"./semi-DNxeCrHm.js";import{F as h,I as g,P as _,a as v,b as y,c as b,d as x,f as S,l as C,m as w,p as T,s as E,u as D,x as O,y as k}from"./index-DJ5x9hL_.js";var A=e(t(),1),j=e(n(),1),{Text:M}=o;function N(){let e=_(),{hasPermission:t}=h(),n=t(`agents:write`),o=t(`agents:delete`),[N,P]=(0,A.useState)(``),[F,I]=(0,A.useState)(null),[L,R]=(0,A.useState)(null),[z,B]=(0,A.useState)(!1),V=v(()=>g.get(`/multi-agent/markdown-agents`),[]),H=(Array.isArray(V.data?.agents)?V.data.agents:[]).filter(e=>{if(!N)return!0;let t=N.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),U=async e=>{try{I(await g.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){y(e,`读取智能体失败`)}},W=async()=>{let e=await L.form.validate();B(!0);try{await g.post(`/multi-agent/markdown-agents`,{filename:e.filename?.trim()||``,name:e.name.trim(),description:e.description?.trim()||``,instruction:e.instruction,kind:e.kind||`sub`,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean)}),O(`智能体已保存`),R(null),V.reload()}catch(e){y(e,`保存智能体失败`)}finally{B(!1)}},G=e=>k({title:`删除智能体「${e.name||e.filename}」?`,onOk:async()=>{await g.del(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`),O(`已删除`),V.reload()}});return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(T,{title:e(`agents.title`,null,`智能体管理`),description:V.data?.dir?`目录:${V.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,j.jsxs)(a,{children:[(0,j.jsx)(i,{icon:(0,j.jsx)(l,{}),onClick:()=>V.reload(),loading:V.loading,children:`刷新`}),n&&(0,j.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,j.jsx)(d,{}),onClick:()=>R({record:null,form:{}}),children:`新建智能体`})]})}),V.data?.error&&(0,j.jsx)(C,{error:V.data.error}),(0,j.jsxs)(w,{title:`智能体(${H.length})`,children:[(0,j.jsx)(C,{error:V.error,onRetry:()=>V.reload()}),(0,j.jsx)(E,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,j.jsxs)(a,{vertical:!0,spacing:0,align:`start`,children:[(0,j.jsxs)(a,{children:[(0,j.jsx)(M,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,j.jsx)(u,{size:`small`,color:`purple`,children:`编排器`})]}),(0,j.jsx)(M,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,j.jsx)(u,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,j.jsx)(M,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,j.jsxs)(a,{children:[(0,j.jsx)(i,{size:`small`,theme:`borderless`,onClick:()=>U(t),children:`详情`}),n&&(0,j.jsx)(i,{size:`small`,theme:`borderless`,icon:(0,j.jsx)(m,{}),onClick:()=>R({record:t,form:{}})}),o&&(0,j.jsx)(i,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,j.jsx)(p,{}),onClick:()=>G(t)})]})}],dataSource:H,rowKey:`filename`,loading:V.loading,pagination:{pageSize:20},toolbar:(0,j.jsx)(s,{prefix:(0,j.jsx)(f,{}),value:N,onChange:P,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,j.jsx)(r,{title:L?.record?`编辑智能体`:`新建智能体`,visible:!!L,onCancel:()=>R(null),onOk:W,confirmLoading:z,width:760,children:(0,j.jsxs)(c,{getFormApi:e=>R(t=>t&&{...t,form:e}),initValues:L?.record?{filename:L.record.filename,name:L.record.name,description:L.record.description,kind:L.record.kind||`sub`}:{kind:`sub`},children:[(0,j.jsx)(c.Input,{field:`filename`,label:`文件名(留空自动生成)`,placeholder:`例如 recon.md`}),(0,j.jsx)(c.Input,{field:`name`,label:`名称`,rules:[{required:!0,message:`请输入名称`}]}),(0,j.jsx)(c.Input,{field:`description`,label:`描述`}),(0,j.jsx)(c.Select,{field:`kind`,label:`类型`,optionList:[{value:`sub`,label:`子智能体`},{value:`orchestrator`,label:`编排器`},{value:`plan_execute`,label:`计划执行`}]}),(0,j.jsx)(c.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::tool`}),(0,j.jsx)(c.TextArea,{field:`instruction`,label:`指令(Markdown)`,autosize:{minRows:8,maxRows:20}})]})},L?.record?.filename||`new-agent`),(0,j.jsx)(b,{title:F?.name||`智能体详情`,visible:!!F,onCancel:()=>I(null),width:720,children:F&&(0,j.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,j.jsx)(x,{items:[{label:`文件名`,value:F.filename},{label:`ID`,value:F.id},{label:`类型`,value:F.kind},{label:`绑定角色`,value:F.bind_role||`—`},{label:`最大迭代`,value:F.max_iterations??`—`},{label:`工具`,value:Array.isArray(F.tools)&&F.tools.length?F.tools.join(`、`):`—`}]}),(0,j.jsx)(S,{content:F.instruction||F.raw||``}),(0,j.jsx)(D,{value:F.raw||F,title:`原始 Markdown`,collapsed:!0})]})})]})}export{N as default};
|
||||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{C as r,I as i,P as a,U as o,V as s,i as c,it as l,j as u,ot as d,rt as f,xt as p,yt as m}from"./semi-DNxeCrHm.js";import{F as h,I as g,P as _,a as v,b as y,c as b,d as x,f as S,l as C,m as w,p as T,s as E,u as D,x as O,y as k}from"./index-DBJjrr5j.js";var A=e(t(),1),j=e(n(),1),{Text:M}=o;function N(){let e=_(),{hasPermission:t}=h(),n=t(`agents:write`),o=t(`agents:delete`),[N,P]=(0,A.useState)(``),[F,I]=(0,A.useState)(null),[L,R]=(0,A.useState)(null),[z,B]=(0,A.useState)(!1),V=v(()=>g.get(`/multi-agent/markdown-agents`),[]),H=(Array.isArray(V.data?.agents)?V.data.agents:[]).filter(e=>{if(!N)return!0;let t=N.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),U=async e=>{try{I(await g.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){y(e,`读取智能体失败`)}},W=async()=>{let e=await L.form.validate();B(!0);try{await g.post(`/multi-agent/markdown-agents`,{filename:e.filename?.trim()||``,name:e.name.trim(),description:e.description?.trim()||``,instruction:e.instruction,kind:e.kind||`sub`,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean)}),O(`智能体已保存`),R(null),V.reload()}catch(e){y(e,`保存智能体失败`)}finally{B(!1)}},G=e=>k({title:`删除智能体「${e.name||e.filename}」?`,onOk:async()=>{await g.del(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`),O(`已删除`),V.reload()}});return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(T,{title:e(`agents.title`,null,`智能体管理`),description:V.data?.dir?`目录:${V.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,j.jsxs)(a,{children:[(0,j.jsx)(i,{icon:(0,j.jsx)(l,{}),onClick:()=>V.reload(),loading:V.loading,children:`刷新`}),n&&(0,j.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,j.jsx)(d,{}),onClick:()=>R({record:null,form:{}}),children:`新建智能体`})]})}),V.data?.error&&(0,j.jsx)(C,{error:V.data.error}),(0,j.jsxs)(w,{title:`智能体(${H.length})`,children:[(0,j.jsx)(C,{error:V.error,onRetry:()=>V.reload()}),(0,j.jsx)(E,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,j.jsxs)(a,{vertical:!0,spacing:0,align:`start`,children:[(0,j.jsxs)(a,{children:[(0,j.jsx)(M,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,j.jsx)(u,{size:`small`,color:`purple`,children:`编排器`})]}),(0,j.jsx)(M,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,j.jsx)(u,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,j.jsx)(M,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,j.jsxs)(a,{children:[(0,j.jsx)(i,{size:`small`,theme:`borderless`,onClick:()=>U(t),children:`详情`}),n&&(0,j.jsx)(i,{size:`small`,theme:`borderless`,icon:(0,j.jsx)(m,{}),onClick:()=>R({record:t,form:{}})}),o&&(0,j.jsx)(i,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,j.jsx)(p,{}),onClick:()=>G(t)})]})}],dataSource:H,rowKey:`filename`,loading:V.loading,pagination:{pageSize:20},toolbar:(0,j.jsx)(s,{prefix:(0,j.jsx)(f,{}),value:N,onChange:P,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,j.jsx)(r,{title:L?.record?`编辑智能体`:`新建智能体`,visible:!!L,onCancel:()=>R(null),onOk:W,confirmLoading:z,width:760,children:(0,j.jsxs)(c,{getFormApi:e=>R(t=>t&&{...t,form:e}),initValues:L?.record?{filename:L.record.filename,name:L.record.name,description:L.record.description,kind:L.record.kind||`sub`}:{kind:`sub`},children:[(0,j.jsx)(c.Input,{field:`filename`,label:`文件名(留空自动生成)`,placeholder:`例如 recon.md`}),(0,j.jsx)(c.Input,{field:`name`,label:`名称`,rules:[{required:!0,message:`请输入名称`}]}),(0,j.jsx)(c.Input,{field:`description`,label:`描述`}),(0,j.jsx)(c.Select,{field:`kind`,label:`类型`,optionList:[{value:`sub`,label:`子智能体`},{value:`orchestrator`,label:`编排器`},{value:`plan_execute`,label:`计划执行`}]}),(0,j.jsx)(c.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::tool`}),(0,j.jsx)(c.TextArea,{field:`instruction`,label:`指令(Markdown)`,autosize:{minRows:8,maxRows:20}})]})},L?.record?.filename||`new-agent`),(0,j.jsx)(b,{title:F?.name||`智能体详情`,visible:!!F,onCancel:()=>I(null),width:720,children:F&&(0,j.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,j.jsx)(x,{items:[{label:`文件名`,value:F.filename},{label:`ID`,value:F.id},{label:`类型`,value:F.kind},{label:`绑定角色`,value:F.bind_role||`—`},{label:`最大迭代`,value:F.max_iterations??`—`},{label:`工具`,value:Array.isArray(F.tools)&&F.tools.length?F.tools.join(`、`):`—`}]}),(0,j.jsx)(S,{content:F.instruction||F.raw||``}),(0,j.jsx)(D,{value:F.raw||F,title:`原始 Markdown`,collapsed:!0})]})})]})}export{N as default};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
import{I as e,L as t}from"./index-DJ5x9hL_.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-DBJjrr5j.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{I as t,P as n,U as r}from"./semi-DNxeCrHm.js";import{E as i,P as a,k as o}from"./index-DJ5x9hL_.js";import"./c2-shared-BMlZ1XNv.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)(n,{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(n=>(0,c.jsx)(t,{size:`small`,theme:n.value===e?`solid`:`borderless`,type:n.value===e?`primary`:`tertiary`,onClick:()=>r(n.value),children:o(`c2.${i}.preset${n.value===`all`?`All`:n.value}`,null,n.label)},n.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{I as t,P as n,U as r}from"./semi-DNxeCrHm.js";import{E as i,P as a,k as o}from"./index-DBJjrr5j.js";import"./c2-shared-B4xiNGUk.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)(n,{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(n=>(0,c.jsx)(t,{size:`small`,theme:n.value===e?`solid`:`borderless`,type:n.value===e?`primary`:`tertiary`,onClick:()=>r(n.value),children:o(`c2.${i}.preset${n.value===`all`?`All`:n.value}`,null,n.label)},n.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};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{I as r,P as i,U as a,V as o,it as s,j as c,rt as l,xt as u}from"./semi-DNxeCrHm.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-DJ5x9hL_.js";var T=e(t(),1),E=e(n(),1),{Text:D}=a;function O(){let e=m(),{hasPermission:t}=f(),n=t(`knowledge:delete`),[a,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(50),[j,M]=(0,T.useState)(null),N=h(()=>p.get(`/knowledge/retrieval-logs`,{conversationId:a||void 0,limit:k}),[a,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)(r,{icon:(0,E.jsx)(s,{}),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)(c,{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)(r,{size:`small`,theme:`borderless`,onClick:()=>M(t),children:`详情`}),n&&(0,E.jsx)(r,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,E.jsx)(u,{}),onClick:()=>F(t)})]})}],dataSource:P,rowKey:`id`,loading:N.loading,pagination:!1,toolbar:(0,E.jsxs)(i,{children:[(0,E.jsx)(o,{prefix:(0,E.jsx)(l,{}),placeholder:`按会话 ID 过滤`,value:a,onChange:O,style:{width:260}}),(0,E.jsx)(o,{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{I as r,P as i,U as a,V as o,it as s,j as c,rt as l,xt as u}from"./semi-DNxeCrHm.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-DBJjrr5j.js";var T=e(t(),1),E=e(n(),1),{Text:D}=a;function O(){let e=m(),{hasPermission:t}=f(),n=t(`knowledge:delete`),[a,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(50),[j,M]=(0,T.useState)(null),N=h(()=>p.get(`/knowledge/retrieval-logs`,{conversationId:a||void 0,limit:k}),[a,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)(r,{icon:(0,E.jsx)(s,{}),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)(c,{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)(r,{size:`small`,theme:`borderless`,onClick:()=>M(t),children:`详情`}),n&&(0,E.jsx)(r,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,E.jsx)(u,{}),onClick:()=>F(t)})]})}],dataSource:P,rowKey:`id`,loading:N.loading,pagination:!1,toolbar:(0,E.jsxs)(i,{children:[(0,E.jsx)(o,{prefix:(0,E.jsx)(l,{}),placeholder:`按会话 ID 过滤`,value:a,onChange:O,style:{width:260}}),(0,E.jsx)(o,{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};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{C as r,I as i,P as a,U as o,V as s,i as c,it as l,j as u,ot as d,rt as f,xt as p,yt as m}from"./semi-DNxeCrHm.js";import{F as h,I as g,P as _,a as v,b as y,l as b,m as x,p as S,s as C,x as w,y as T}from"./index-DJ5x9hL_.js";var E=e(t(),1),D=e(n(),1),{Text:O}=o;function k(){let e=_(),{hasPermission:t}=h(),n=t(`roles:write`),o=t(`roles:delete`),[k,A]=(0,E.useState)(``),[j,M]=(0,E.useState)(null),[N,P]=(0,E.useState)(!1),F=v(()=>g.get(`/roles`),[]),I=(Array.isArray(F.data?.roles)?F.data.roles:[]).filter(e=>{if(!k)return!0;let t=k.toLowerCase();return[e.name,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),L=async()=>{let e=await j.form.validate();P(!0);try{let t={name:e.name.trim(),description:e.description?.trim()||``,user_prompt:e.user_prompt||``,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean),enabled:e.enabled!==!1},n=j.role?.name;n&&n!==t.name?(await g.post(`/roles`,t),await g.del(`/roles/${encodeURIComponent(n)}`)):n?await g.put(`/roles/${encodeURIComponent(n)}`,t):await g.post(`/roles`,t),w(`角色已保存`),M(null),F.reload()}catch(e){y(e,`保存角色失败`)}finally{P(!1)}},R=e=>T({title:`删除角色「${e.name}」?`,content:`已绑定该角色的对话将失去对应提示词与工具配置。`,onOk:async()=>{await g.del(`/roles/${encodeURIComponent(e.name)}`),w(`已删除`),F.reload()}});return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(S,{title:e(`roles.title`,null,`角色管理`),description:`角色定义对话的系统提示词、可用工具与绑定工作流。`,extra:(0,D.jsxs)(a,{children:[(0,D.jsx)(i,{icon:(0,D.jsx)(l,{}),onClick:()=>F.reload(),loading:F.loading,children:`刷新`}),n&&(0,D.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,D.jsx)(d,{}),onClick:()=>M({role:null,form:{}}),children:`新建角色`})]})}),(0,D.jsxs)(x,{title:`角色(${I.length})`,children:[(0,D.jsx)(b,{error:F.error,onRetry:()=>F.reload()}),(0,D.jsx)(C,{columns:[{title:`角色`,dataIndex:`name`,render:(e,t)=>(0,D.jsxs)(a,{vertical:!0,spacing:0,align:`start`,children:[(0,D.jsxs)(a,{children:[(0,D.jsx)(O,{strong:!0,children:e}),t.enabled===!1&&(0,D.jsx)(u,{size:`small`,color:`grey`,children:`已停用`})]}),(0,D.jsx)(O,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:t.description||`—`})]})},{title:`工具`,dataIndex:`tools`,width:260,render:e=>Array.isArray(e)&&e.length?(0,D.jsxs)(a,{wrap:!0,spacing:4,children:[e.slice(0,4).map(e=>(0,D.jsx)(u,{size:`small`,children:e},e)),e.length>4&&(0,D.jsxs)(O,{type:`tertiary`,children:[`+`,e.length-4]})]}):(0,D.jsx)(O,{type:`tertiary`,children:`未绑定`})},{title:`工作流`,dataIndex:`workflow_id`,width:160,render:e=>e||`—`},{title:`操作`,width:150,render:(e,t)=>(0,D.jsxs)(a,{children:[n&&(0,D.jsx)(i,{size:`small`,theme:`borderless`,icon:(0,D.jsx)(m,{}),onClick:()=>M({role:t,form:{}}),children:`编辑`}),o&&(0,D.jsx)(i,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,D.jsx)(p,{}),onClick:()=>R(t)})]})}],dataSource:I,rowKey:`name`,loading:F.loading,pagination:{pageSize:20},toolbar:(0,D.jsx)(s,{prefix:(0,D.jsx)(f,{}),value:k,onChange:A,placeholder:`搜索角色名称`,style:{width:260}})})]}),(0,D.jsx)(r,{title:j?.role?`编辑角色`:`新建角色`,visible:!!j,onCancel:()=>M(null),onOk:L,confirmLoading:N,width:760,children:(0,D.jsxs)(c,{getFormApi:e=>M(t=>t&&{...t,form:e}),initValues:j?.role?{name:j.role.name,description:j.role.description,user_prompt:j.role.user_prompt,tools:Array.isArray(j.role.tools)?j.role.tools.join(`, `):``,enabled:j.role.enabled!==!1}:{enabled:!0},children:[(0,D.jsx)(c.Input,{field:`name`,label:`角色名称`,rules:[{required:!0,message:`请输入角色名称`}]}),(0,D.jsx)(c.Input,{field:`description`,label:`描述`}),(0,D.jsx)(c.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::toolName`}),(0,D.jsx)(c.TextArea,{field:`user_prompt`,label:`用户提示词(追加到用户消息前)`,autosize:{minRows:6,maxRows:18}}),(0,D.jsx)(c.Slot,{label:`启用`,children:(0,D.jsx)(c.Switch,{field:`enabled`})})]})},j?.role?.name||`new-role`)]})}export{k as default};
|
||||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{C as r,I as i,P as a,U as o,V as s,i as c,it as l,j as u,ot as d,rt as f,xt as p,yt as m}from"./semi-DNxeCrHm.js";import{F as h,I as g,P as _,a as v,b as y,l as b,m as x,p as S,s as C,x as w,y as T}from"./index-DBJjrr5j.js";var E=e(t(),1),D=e(n(),1),{Text:O}=o;function k(){let e=_(),{hasPermission:t}=h(),n=t(`roles:write`),o=t(`roles:delete`),[k,A]=(0,E.useState)(``),[j,M]=(0,E.useState)(null),[N,P]=(0,E.useState)(!1),F=v(()=>g.get(`/roles`),[]),I=(Array.isArray(F.data?.roles)?F.data.roles:[]).filter(e=>{if(!k)return!0;let t=k.toLowerCase();return[e.name,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),L=async()=>{let e=await j.form.validate();P(!0);try{let t={name:e.name.trim(),description:e.description?.trim()||``,user_prompt:e.user_prompt||``,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean),enabled:e.enabled!==!1},n=j.role?.name;n&&n!==t.name?(await g.post(`/roles`,t),await g.del(`/roles/${encodeURIComponent(n)}`)):n?await g.put(`/roles/${encodeURIComponent(n)}`,t):await g.post(`/roles`,t),w(`角色已保存`),M(null),F.reload()}catch(e){y(e,`保存角色失败`)}finally{P(!1)}},R=e=>T({title:`删除角色「${e.name}」?`,content:`已绑定该角色的对话将失去对应提示词与工具配置。`,onOk:async()=>{await g.del(`/roles/${encodeURIComponent(e.name)}`),w(`已删除`),F.reload()}});return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(S,{title:e(`roles.title`,null,`角色管理`),description:`角色定义对话的系统提示词、可用工具与绑定工作流。`,extra:(0,D.jsxs)(a,{children:[(0,D.jsx)(i,{icon:(0,D.jsx)(l,{}),onClick:()=>F.reload(),loading:F.loading,children:`刷新`}),n&&(0,D.jsx)(i,{theme:`solid`,type:`primary`,icon:(0,D.jsx)(d,{}),onClick:()=>M({role:null,form:{}}),children:`新建角色`})]})}),(0,D.jsxs)(x,{title:`角色(${I.length})`,children:[(0,D.jsx)(b,{error:F.error,onRetry:()=>F.reload()}),(0,D.jsx)(C,{columns:[{title:`角色`,dataIndex:`name`,render:(e,t)=>(0,D.jsxs)(a,{vertical:!0,spacing:0,align:`start`,children:[(0,D.jsxs)(a,{children:[(0,D.jsx)(O,{strong:!0,children:e}),t.enabled===!1&&(0,D.jsx)(u,{size:`small`,color:`grey`,children:`已停用`})]}),(0,D.jsx)(O,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:t.description||`—`})]})},{title:`工具`,dataIndex:`tools`,width:260,render:e=>Array.isArray(e)&&e.length?(0,D.jsxs)(a,{wrap:!0,spacing:4,children:[e.slice(0,4).map(e=>(0,D.jsx)(u,{size:`small`,children:e},e)),e.length>4&&(0,D.jsxs)(O,{type:`tertiary`,children:[`+`,e.length-4]})]}):(0,D.jsx)(O,{type:`tertiary`,children:`未绑定`})},{title:`工作流`,dataIndex:`workflow_id`,width:160,render:e=>e||`—`},{title:`操作`,width:150,render:(e,t)=>(0,D.jsxs)(a,{children:[n&&(0,D.jsx)(i,{size:`small`,theme:`borderless`,icon:(0,D.jsx)(m,{}),onClick:()=>M({role:t,form:{}}),children:`编辑`}),o&&(0,D.jsx)(i,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,D.jsx)(p,{}),onClick:()=>R(t)})]})}],dataSource:I,rowKey:`name`,loading:F.loading,pagination:{pageSize:20},toolbar:(0,D.jsx)(s,{prefix:(0,D.jsx)(f,{}),value:k,onChange:A,placeholder:`搜索角色名称`,style:{width:260}})})]}),(0,D.jsx)(r,{title:j?.role?`编辑角色`:`新建角色`,visible:!!j,onCancel:()=>M(null),onOk:L,confirmLoading:N,width:760,children:(0,D.jsxs)(c,{getFormApi:e=>M(t=>t&&{...t,form:e}),initValues:j?.role?{name:j.role.name,description:j.role.description,user_prompt:j.role.user_prompt,tools:Array.isArray(j.role.tools)?j.role.tools.join(`, `):``,enabled:j.role.enabled!==!1}:{enabled:!0},children:[(0,D.jsx)(c.Input,{field:`name`,label:`角色名称`,rules:[{required:!0,message:`请输入角色名称`}]}),(0,D.jsx)(c.Input,{field:`description`,label:`描述`}),(0,D.jsx)(c.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::toolName`}),(0,D.jsx)(c.TextArea,{field:`user_prompt`,label:`用户提示词(追加到用户消息前)`,autosize:{minRows:6,maxRows:18}}),(0,D.jsx)(c.Slot,{label:`启用`,children:(0,D.jsx)(c.Switch,{field:`enabled`})})]})},j?.role?.name||`new-role`)]})}export{k as default};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,_ as n,t as r,y as i}from"./react-QV7DAAIx.js";import{D as a,F as o,Ht as s,I as c,J as l,P as u,R as d,U as f,V as p,_ as m,b as h,bt as g,c as _,d as v,f as y,it as b,j as x,k as S,m as C,p as w,rt as T,s as E,u as D}from"./semi-DNxeCrHm.js";import{A as O,D as k,E as A,F as j,I as M,L as N,M as P,N as F,P as I,R as L,S as R,T as z,_ as ee,a as B,b as te,d as V,j as ne,l as H,m as U,n as re,o as ie,p as ae,s as oe,u as W,x as G,y as se}from"./index-DJ5x9hL_.js";var K=e(t(),1),q=class extends Error{constructor(e,t){super(t?`第 ${t} 行:${e}`:e),this.name=`YamlError`,this.line=t||0}},ce=/^(?:[-?:,\[\]{}#&*!|>'"%@`]|.*[:\s]$|.*\s#|.*[\n\r\t])/,le=/^(?:true|false|null|~|yes|no|on|off|[-+]?(?:\d+|\d*\.\d+)(?:[eE][-+]?\d+)?)$/i;function J(e){let t=String(e);return!(t===``||le.test(t)||/^[-+]?(?:\d+\.\d*|\.\d+|\d+)(?:[eE][-+]?\d+)?$/.test(t)||ce.test(t)||/^(?:\s)|:(?:\s|$)|[\r\n\t]/.test(t)||/[,[\]{}]/.test(t)||/^[!&*|>@`]/.test(t))}function ue(e){return JSON.stringify(String(e))}function de(e){let t=String(e);return J(t)?t:ue(t)}function fe(e){if(e==null)return`null`;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return Number.isFinite(e)?String(e):ue(String(e));let t=String(e);return J(t)?t:ue(t)}function pe(e){return e==null||[`string`,`number`,`boolean`].includes(typeof e)}function me(e,t,n,r){let i=` `.repeat(n),a=de(e);if(pe(t))r.push(`${i}${a}: ${fe(t)}`);else if(Array.isArray(t)){if(!t.length){r.push(`${i}${a}: []`);return}r.push(`${i}${a}:`),_e(t,n+2,r)}else Object.entries(t).length?(r.push(`${i}${a}:`),he(t,n+2,r)):r.push(`${i}${a}: {}`)}function he(e,t,n){for(let[r,i]of Object.entries(e))me(r,i,t,n)}function ge(e,t,n){let r=` `.repeat(t);if(pe(e)){n.push(`${r}- ${fe(e)}`);return}if(Array.isArray(e)){if(!e.length){n.push(`${r}- []`);return}n.push(`${r}-`),_e(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);pe(o)?n.push(`${r}- ${de(a)}: ${fe(o)}`):(n.push(`${r}-`),me(a,o,t+2,n));for(let[e,r]of s)me(e,r,t+2,n)}function _e(e,t,n){for(let r of e)ge(r,t,n)}function ve(e,{header:t}={}){let n=[];if(t){for(let e of String(t).replace(/\r\n?/g,`
|
||||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,_ as n,t as r,y as i}from"./react-QV7DAAIx.js";import{D as a,F as o,Ht as s,I as c,J as l,P as u,R as d,U as f,V as p,_ as m,b as h,bt as g,c as _,d as v,f as y,it as b,j as x,k as S,m as C,p as w,rt as T,s as E,u as D}from"./semi-DNxeCrHm.js";import{A as O,D as k,E as A,F as j,I as M,L as N,M as P,N as F,P as I,R as L,S as R,T as z,_ as ee,a as B,b as te,d as V,j as ne,l as H,m as U,n as re,o as ie,p as ae,s as oe,u as W,x as G,y as se}from"./index-DBJjrr5j.js";var K=e(t(),1),q=class extends Error{constructor(e,t){super(t?`第 ${t} 行:${e}`:e),this.name=`YamlError`,this.line=t||0}},ce=/^(?:[-?:,\[\]{}#&*!|>'"%@`]|.*[:\s]$|.*\s#|.*[\n\r\t])/,le=/^(?:true|false|null|~|yes|no|on|off|[-+]?(?:\d+|\d*\.\d+)(?:[eE][-+]?\d+)?)$/i;function J(e){let t=String(e);return!(t===``||le.test(t)||/^[-+]?(?:\d+\.\d*|\.\d+|\d+)(?:[eE][-+]?\d+)?$/.test(t)||ce.test(t)||/^(?:\s)|:(?:\s|$)|[\r\n\t]/.test(t)||/[,[\]{}]/.test(t)||/^[!&*|>@`]/.test(t))}function ue(e){return JSON.stringify(String(e))}function de(e){let t=String(e);return J(t)?t:ue(t)}function fe(e){if(e==null)return`null`;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return Number.isFinite(e)?String(e):ue(String(e));let t=String(e);return J(t)?t:ue(t)}function pe(e){return e==null||[`string`,`number`,`boolean`].includes(typeof e)}function me(e,t,n,r){let i=` `.repeat(n),a=de(e);if(pe(t))r.push(`${i}${a}: ${fe(t)}`);else if(Array.isArray(t)){if(!t.length){r.push(`${i}${a}: []`);return}r.push(`${i}${a}:`),_e(t,n+2,r)}else Object.entries(t).length?(r.push(`${i}${a}:`),he(t,n+2,r)):r.push(`${i}${a}: {}`)}function he(e,t,n){for(let[r,i]of Object.entries(e))me(r,i,t,n)}function ge(e,t,n){let r=` `.repeat(t);if(pe(e)){n.push(`${r}- ${fe(e)}`);return}if(Array.isArray(e)){if(!e.length){n.push(`${r}- []`);return}n.push(`${r}-`),_e(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);pe(o)?n.push(`${r}- ${de(a)}: ${fe(o)}`):(n.push(`${r}-`),me(a,o,t+2,n));for(let[e,r]of s)me(e,r,t+2,n)}function _e(e,t,n){for(let r of e)ge(r,t,n)}function ve(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 pe(e)?(n.push(fe(e)),`${n.join(`
|
||||
`)}\n`):Array.isArray(e)?(e.length?_e(e,0,n):n.push(`[]`),`${n.join(`
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{I as t,P as n,U as r,it as i,xt as a}from"./semi-DNxeCrHm.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-DJ5x9hL_.js";import{t as y}from"./react-QV7DAAIx.js";var b=e(y(),1),{Text:x}=r;function S(){let e=u(),{hasPermission:r}=s(),y=r(`skills:delete`),S=f(()=>c.get(`/skills/stats`),[]),C=Array.isArray(S.data?.stats)?S.data.stats:[],w=Number(S.data?.total_calls||0),T=Number(S.data?.total_success||0),E=w>0?T/w:null,D=()=>v({title:`清空所有技能调用统计?`,content:`只影响统计计数,不删除技能文件。`,onOk:async()=>{await c.del(`/skills/stats`),_(`统计已清空`),S.reload()}}),O=e=>v({title:`清空「${e}」的统计?`,onOk:async()=>{await c.del(`/skills/${encodeURIComponent(e)}/stats`),_(`已清空`),S.reload()}});return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(h,{title:e(`skills.monitorTitle`,null,`技能状态`),description:S.data?.skills_dir?`技能目录:${S.data.skills_dir}`:`统计技能被调用的次数、成功率与最近使用时间。`,extra:(0,b.jsxs)(n,{children:[(0,b.jsx)(t,{icon:(0,b.jsx)(i,{}),onClick:()=>S.reload(),loading:S.loading,children:`刷新`}),y&&(0,b.jsx)(t,{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)(t,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,b.jsx)(a,{}),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{I as t,P as n,U as r,it as i,xt as a}from"./semi-DNxeCrHm.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-DBJjrr5j.js";import{t as y}from"./react-QV7DAAIx.js";var b=e(y(),1),{Text:x}=r;function S(){let e=u(),{hasPermission:r}=s(),y=r(`skills:delete`),S=f(()=>c.get(`/skills/stats`),[]),C=Array.isArray(S.data?.stats)?S.data.stats:[],w=Number(S.data?.total_calls||0),T=Number(S.data?.total_success||0),E=w>0?T/w:null,D=()=>v({title:`清空所有技能调用统计?`,content:`只影响统计计数,不删除技能文件。`,onOk:async()=>{await c.del(`/skills/stats`),_(`统计已清空`),S.reload()}}),O=e=>v({title:`清空「${e}」的统计?`,onOk:async()=>{await c.del(`/skills/${encodeURIComponent(e)}/stats`),_(`已清空`),S.reload()}});return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(h,{title:e(`skills.monitorTitle`,null,`技能状态`),description:S.data?.skills_dir?`技能目录:${S.data.skills_dir}`:`统计技能被调用的次数、成功率与最近使用时间。`,extra:(0,b.jsxs)(n,{children:[(0,b.jsx)(t,{icon:(0,b.jsx)(i,{}),onClick:()=>S.reload(),loading:S.loading,children:`刷新`}),y&&(0,b.jsx)(t,{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)(t,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,b.jsx)(a,{}),onClick:()=>O(n.skill_name),children:`清空`}):null}],dataSource:C,rowKey:`skill_name`,loading:S.loading,pagination:{pageSize:20}})]})]})}export{S as default};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -18,7 +18,7 @@
|
|||
} catch (error) { /* first paint fallback */ }
|
||||
})();
|
||||
</script>
|
||||
<script type="module" crossorigin src="/static/app/assets/index-DJ5x9hL_.js"></script>
|
||||
<script type="module" crossorigin src="/static/app/assets/index-DBJjrr5j.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-DNxeCrHm.js">
|
||||
|
|
|
|||
|
|
@ -1001,6 +1001,9 @@
|
|||
"hitlModeLabel": "الوضع",
|
||||
"hitlModeOff": "إيقاف",
|
||||
"hitlModeApproval": "الموافقة",
|
||||
"hitlEnableHuman": "تفعيل الموافقة البشرية",
|
||||
"hitlEnableFirstMessage": "تفعيل الموافقة البشرية للرسالة الأولى",
|
||||
"hitlFirstMessageEnabled": "تم تفعيل الموافقة البشرية للرسالة الأولى",
|
||||
"hitlModeReviewEdit": "المراجعة والتعديل",
|
||||
"hitlSensitiveTools": "الأدوات الحسّاسة (مفصولة بفواصل)",
|
||||
"hitlWhitelistTools": "الأدوات المدرجة في قائمة السماح (تتخطّى الموافقة، مفصولة بفواصل)",
|
||||
|
|
|
|||
|
|
@ -1002,6 +1002,9 @@
|
|||
"hitlModeLabel": "Mode",
|
||||
"hitlModeOff": "Off",
|
||||
"hitlModeApproval": "Approval",
|
||||
"hitlEnableHuman": "Enable human approval",
|
||||
"hitlEnableFirstMessage": "Enable human approval for the first message",
|
||||
"hitlFirstMessageEnabled": "Human approval enabled for the first message",
|
||||
"hitlModeReviewEdit": "Review & Edit",
|
||||
"hitlSensitiveTools": "Sensitive tools (comma-separated)",
|
||||
"hitlWhitelistTools": "Whitelisted tools (skip approval, comma-separated)",
|
||||
|
|
|
|||
|
|
@ -1014,6 +1014,9 @@
|
|||
"hitlModeLabel": "Режим",
|
||||
"hitlModeOff": "Выкл.",
|
||||
"hitlModeApproval": "Одобрение",
|
||||
"hitlEnableHuman": "Включить одобрение человеком",
|
||||
"hitlEnableFirstMessage": "Включить одобрение человеком для первого сообщения",
|
||||
"hitlFirstMessageEnabled": "Для первого сообщения включено одобрение человеком",
|
||||
"hitlModeReviewEdit": "Проверка и правка",
|
||||
"hitlSensitiveTools": "Чувствительные инструменты (через запятую)",
|
||||
"hitlWhitelistTools": "Белый список инструментов (без одобрения, через запятую)",
|
||||
|
|
|
|||
|
|
@ -990,6 +990,9 @@
|
|||
"hitlModeLabel": "模式",
|
||||
"hitlModeOff": "关闭",
|
||||
"hitlModeApproval": "审批模式",
|
||||
"hitlEnableHuman": "开启人工审批",
|
||||
"hitlEnableFirstMessage": "为首条消息开启人工审批",
|
||||
"hitlFirstMessageEnabled": "首条消息将使用人工审批",
|
||||
"hitlModeReviewEdit": "审查编辑",
|
||||
"hitlSensitiveTools": "敏感工具(逗号分隔)",
|
||||
"hitlWhitelistTools": "白名单工具(免审批,逗号分隔)",
|
||||
|
|
|
|||
Loading…
Reference in New Issue