feat(chat): simplify reasoning controls with a compact slider
Make reasoning strength easier to adjust with localized levels and reset controls while preserving channel preferences and permission boundaries.
This commit is contained in:
parent
1acb1597ea
commit
a3e4310e81
|
|
@ -1,11 +1,12 @@
|
|||
import { useEffect, useId, useRef, useState } from 'react';
|
||||
import { RadioGroup, Select, SideSheet, Spin, TextArea, Typography } from '@douyinfe/semi-ui';
|
||||
import { Button, Dropdown, RadioGroup, Select, SideSheet, Slider, Spin, TextArea, Typography } from '@douyinfe/semi-ui';
|
||||
import { IconBolt, IconChevronRight, IconUndo } from '@douyinfe/semi-icons';
|
||||
import { useResource } from '../../components/hooks';
|
||||
import { ErrorBanner, toastError } from '../../components/ui';
|
||||
import { api } from '../../lib/http';
|
||||
import { useT } from '../../lib/i18n';
|
||||
import { modelChannelName, modelChannelOptions, selectedModelChannelName } from '../../lib/model-channel';
|
||||
import { REASONING_EFFORTS, REASONING_MODES } from './useModelPreferences';
|
||||
import { REASONING_EFFORTS, REASONING_MODES, reasoningSummary } from './useModelPreferences';
|
||||
|
||||
const { Text } = Typography;
|
||||
const HITL_MODES = ['off', 'approval', 'review_edit'];
|
||||
|
|
@ -82,8 +83,10 @@ function SettingSelect({ label, ...props }) {
|
|||
);
|
||||
}
|
||||
|
||||
export function ModelSettings({ model, busy, canReadConfig }) {
|
||||
export function ModelSettings({ model, busy, canReadConfig, compact = false }) {
|
||||
const t = useT();
|
||||
const channelLabelId = useId();
|
||||
const pickerRef = useRef(null);
|
||||
const defaultId = model.config.data?.default_channel;
|
||||
const defaultName = defaultId ? modelChannelName(defaultId, model.config.data?.channels?.[defaultId]) : '';
|
||||
const defaultLabel = t('chat.aiChannelDefault', null, '跟随默认通道');
|
||||
|
|
@ -91,12 +94,98 @@ export function ModelSettings({ model, busy, canReadConfig }) {
|
|||
{ value: '', label: defaultName ? `${defaultLabel} · ${defaultName}` : defaultLabel },
|
||||
...modelChannelOptions(model.channels)
|
||||
];
|
||||
const reasoningLabels = {
|
||||
default: t('chat.reasoningModeDefault', null, '跟随系统'),
|
||||
off: t('chat.reasoningModeOff', null, '关闭'),
|
||||
on: t('chat.reasoningModeOn', null, '开启'),
|
||||
auto: t('chat.reasoningModeAuto', null, '自动')
|
||||
};
|
||||
const reasoningLabels = Object.fromEntries(REASONING_MODES.map(mode => [mode, reasoningSummary(t, mode, '')]));
|
||||
if (compact) {
|
||||
const levels = ['', ...REASONING_EFFORTS];
|
||||
const marks = Object.fromEntries(levels.map((effort, index) => [
|
||||
index, reasoningSummary(t, effort ? 'on' : 'default', effort)
|
||||
]));
|
||||
const resetReasoning = () => {
|
||||
model.setMode('default');
|
||||
model.setEffort('');
|
||||
};
|
||||
return (
|
||||
<div className="chat-reasoning-picker" ref={pickerRef}>
|
||||
<div className="chat-reasoning-heading">
|
||||
<Dropdown
|
||||
trigger="click"
|
||||
position="bottomLeft"
|
||||
className="chat-reasoning-mode-menu"
|
||||
getPopupContainer={() => pickerRef.current}
|
||||
showTick
|
||||
menu={REASONING_MODES.map(mode => ({
|
||||
node: 'item',
|
||||
name: reasoningLabels[mode],
|
||||
active: model.mode === mode,
|
||||
disabled: busy,
|
||||
onClick: () => mode === 'default' ? resetReasoning() : model.setMode(mode)
|
||||
}))}
|
||||
>
|
||||
<Button
|
||||
theme="borderless"
|
||||
type="tertiary"
|
||||
icon={<IconBolt />}
|
||||
className="chat-reasoning-mode"
|
||||
aria-label={t('chat.reasoningModeLabel', null, '模型推理')}
|
||||
title={`${t('chat.reasoningModeLabel', null, '模型推理')} · ${reasoningLabels[model.mode]}`}
|
||||
disabled={busy}
|
||||
/>
|
||||
</Dropdown>
|
||||
<Text strong className="chat-reasoning-value" role="status">
|
||||
{reasoningSummary(t, model.mode, model.effort)}
|
||||
</Text>
|
||||
<Button
|
||||
theme="borderless"
|
||||
type="tertiary"
|
||||
icon={<IconUndo />}
|
||||
aria-label={t('chat.reasoningReset', null, '重置推理设置')}
|
||||
title={t('chat.reasoningReset', null, '重置推理设置')}
|
||||
disabled={busy}
|
||||
onClick={resetReasoning}
|
||||
/>
|
||||
</div>
|
||||
{canReadConfig ? (
|
||||
<>
|
||||
<span id={channelLabelId} hidden>{t('chat.aiChannelLabel', null, 'AI 通道')}</span>
|
||||
<Select
|
||||
className="chat-reasoning-channel"
|
||||
aria-labelledby={channelLabelId}
|
||||
value={model.channel}
|
||||
optionList={channelOptions}
|
||||
renderSelectedItem={option => option.value === ''
|
||||
? defaultName || t('chat.aiChannelDefaultShort', null, '默认通道')
|
||||
: selectedModelChannelName(option)}
|
||||
arrowIcon={<IconChevronRight size="small" />}
|
||||
borderless
|
||||
onSelect={model.setChannel}
|
||||
dropdownMatchSelectWidth={false}
|
||||
dropdownStyle={{ maxWidth: 'calc(100vw - 32px)' }}
|
||||
loading={model.config.loading}
|
||||
disabled={busy || model.config.loading || Boolean(model.config.error)}
|
||||
/>
|
||||
<ErrorBanner error={model.config.error} onRetry={() => model.config.reload()} />
|
||||
</>
|
||||
) : <Text type="tertiary" className="chat-reasoning-channel-label">{defaultLabel}</Text>}
|
||||
<Slider
|
||||
className="chat-reasoning-slider"
|
||||
aria-label={t('chat.reasoningEffortLabel', null, '推理强度')}
|
||||
min={0}
|
||||
max={levels.length - 1}
|
||||
step={1}
|
||||
marks={marks}
|
||||
showMarkLabel={false}
|
||||
tipFormatter={value => marks[value]}
|
||||
getAriaValueText={value => model.mode === 'off' ? reasoningLabels.off : marks[value]}
|
||||
value={levels.indexOf(model.effort)}
|
||||
disabled={busy || model.mode === 'off'}
|
||||
onChange={value => {
|
||||
model.setEffort(levels[value]);
|
||||
model.setMode(value === 0 ? 'default' : model.mode === 'auto' ? 'auto' : 'on');
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<>
|
||||
{canReadConfig && (
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { IconArrowUp, IconChevronDown, IconDesktop, IconFolder, IconPaperclip, I
|
|||
import { useT } from '../../lib/i18n';
|
||||
import { modelChannelName } from '../../lib/model-channel';
|
||||
import { ModelSettings } from './ChatSettings';
|
||||
import { reasoningSummary } from './useModelPreferences';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
|
|
@ -63,9 +64,7 @@ export default function Composer({
|
|||
const channelName = channelId
|
||||
? modelChannelName(channelId, model.config.data?.channels?.[channelId])
|
||||
: t('chat.aiChannelDefaultShort', null, '默认通道');
|
||||
const reasoningSummary = model.mode === 'off'
|
||||
? t('chat.reasoningModeOff', null, '关闭')
|
||||
: model.effort || t('chat.reasoningSummaryFollow', null, '系统');
|
||||
const reasoningLabel = reasoningSummary(t, model.mode, model.effort);
|
||||
|
||||
const handleKeyDown = event => {
|
||||
if (event.key !== 'Enter' || event.shiftKey) return;
|
||||
|
|
@ -186,22 +185,18 @@ export default function Composer({
|
|||
position="topRight"
|
||||
className="chat-model-popover"
|
||||
condition={!busy}
|
||||
content={(
|
||||
<div className="chat-settings-fields chat-model-settings">
|
||||
<ModelSettings model={model} busy={busy || blocked} canReadConfig={canReadConfig} />
|
||||
</div>
|
||||
)}
|
||||
content={<ModelSettings compact model={model} busy={busy || blocked} canReadConfig={canReadConfig} />}
|
||||
>
|
||||
<Button
|
||||
theme="borderless"
|
||||
type="tertiary"
|
||||
className="chat-composer-model"
|
||||
aria-label={t('chat.modelSettingsAria', null, '选择 AI 通道、模型与推理设置')}
|
||||
title={`${channelName} · ${reasoningSummary}`}
|
||||
title={`${channelName} · ${reasoningLabel}`}
|
||||
disabled={busy}
|
||||
>
|
||||
<span className="chat-composer-model-name">{channelName}</span>
|
||||
<span className="chat-composer-effort">{reasoningSummary}</span>
|
||||
<span className="chat-composer-effort">{reasoningLabel}</span>
|
||||
<IconChevronDown size="small" />
|
||||
</Button>
|
||||
</Popover>
|
||||
|
|
|
|||
|
|
@ -344,8 +344,35 @@
|
|||
.chat-composer-model-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.chat-composer-effort { flex: 0 0 auto; font-size: 12px; color: var(--semi-color-text-2); }
|
||||
.chat-composer-send.semi-button { flex: 0 0 32px; width: 32px; height: 32px; padding: 0; border-radius: 50%; }
|
||||
.chat-model-settings { width: 320px; max-width: calc(100vw - 32px); padding: 16px; }
|
||||
.chat-model-settings .semi-select { width: 100%; min-width: 0; }
|
||||
.chat-model-popover.semi-popover-wrapper { border-radius: 20px; }
|
||||
.chat-reasoning-picker { position: relative; width: 280px; max-width: calc(100vw - 32px); padding: 12px 16px 16px; }
|
||||
.chat-reasoning-heading { display: grid; grid-template-columns: 28px minmax(0, 1fr) 28px; align-items: center; gap: 6px; }
|
||||
.chat-reasoning-heading .semi-button { width: 28px; height: 28px; padding: 0; color: var(--semi-color-text-2); }
|
||||
.chat-reasoning-value.semi-typography { text-align: center; font-size: 16px; color: rgba(var(--semi-orange-6), 1); }
|
||||
.chat-reasoning-channel.semi-select {
|
||||
display: flex;
|
||||
width: fit-content;
|
||||
max-width: calc(100% - 48px);
|
||||
height: 28px;
|
||||
margin: 0 auto;
|
||||
background: transparent;
|
||||
color: var(--semi-color-text-2);
|
||||
}
|
||||
.chat-reasoning-channel .semi-select-selection { min-width: 0; margin-inline: 6px; }
|
||||
.chat-reasoning-channel .semi-select-selection-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.chat-reasoning-channel .semi-select-arrow { padding-inline: 0 4px; }
|
||||
.chat-reasoning-channel.semi-select-borderless:not(:focus-within):not(:hover) .semi-select-arrow { opacity: 1; }
|
||||
.chat-reasoning-channel-label { display: block; text-align: center; line-height: 28px; }
|
||||
.chat-reasoning-slider.semi-slider { padding: 0; margin: 14px 10px 0; }
|
||||
.chat-reasoning-slider .semi-slider-wrapper { height: 36px; }
|
||||
.chat-reasoning-slider .semi-slider-rail,
|
||||
.chat-reasoning-slider .semi-slider-track { top: 4px; height: 28px; border-radius: 16px; }
|
||||
.chat-reasoning-slider .semi-slider-rail { background: var(--semi-color-fill-1); }
|
||||
.chat-reasoning-slider .semi-slider-track { background: rgba(var(--semi-orange-5), 1); }
|
||||
.chat-reasoning-slider .semi-slider-handle { width: 36px; height: 36px; margin-top: 0; background: var(--semi-color-bg-2); border: 1px solid var(--semi-color-border); }
|
||||
.chat-reasoning-slider .semi-slider-dot { top: 16px; width: 4px; height: 4px; background: var(--semi-color-text-3); transform: translateX(-50%); }
|
||||
.chat-reasoning-slider .semi-slider-dot-active { background: var(--semi-color-white); }
|
||||
.chat-reasoning-slider.semi-slider-disabled { opacity: .5; }
|
||||
.chat-settings-fields { display: grid; gap: 16px; }
|
||||
.chat-setting-field { display: grid; gap: 8px; min-width: 0; }
|
||||
.chat-setting-hitl { padding-top: 16px; border-top: 1px solid var(--semi-color-border); }
|
||||
|
|
|
|||
|
|
@ -5,6 +5,15 @@ import { api } from '../../lib/http';
|
|||
export const REASONING_MODES = ['default', 'off', 'on', 'auto'];
|
||||
export const REASONING_EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max'];
|
||||
|
||||
export function reasoningSummary(t, mode, effort) {
|
||||
if (mode !== 'off' && effort) {
|
||||
const labels = { low: '低', medium: '中', high: '高', xhigh: '超高', max: '最高' };
|
||||
return t(`chat.reasoningEffortLabels.${effort}`, null, labels[effort]);
|
||||
}
|
||||
const labels = { default: '跟随系统', off: '关闭', on: '开启', auto: '自动' };
|
||||
return t(`chat.reasoningMode${mode[0].toUpperCase()}${mode.slice(1)}`, null, labels[mode]);
|
||||
}
|
||||
|
||||
// The legacy composer stored plain strings under these keys.
|
||||
function useChatPreference(key, fallback) {
|
||||
const [value, setValue] = useState(() => {
|
||||
|
|
|
|||
|
|
@ -438,25 +438,32 @@ test.describe('chat session settings', () => {
|
|||
await openModel.click();
|
||||
const popover = page.locator('.chat-model-popover');
|
||||
const channel = popover.getByRole('combobox', { name: label('chat.aiChannelLabel'), exact: true });
|
||||
const mode = popover.getByRole('combobox', { name: label('chat.reasoningModeLabel'), exact: true });
|
||||
const effort = popover.getByRole('combobox', { name: label('chat.reasoningEffortLabel'), exact: true });
|
||||
const mode = popover.getByRole('button', { name: label('chat.reasoningModeLabel'), exact: true });
|
||||
const slider = popover.getByRole('slider', { name: label('chat.reasoningEffortLabel'), exact: true });
|
||||
const value = popover.locator('.chat-reasoning-value[role="status"]');
|
||||
const menu = page.locator('.chat-reasoning-mode-menu');
|
||||
await expect(popover).toBeVisible();
|
||||
await expect(popover.getByRole('combobox')).toHaveCount(3);
|
||||
await expect(popover.getByRole('combobox')).toHaveCount(1);
|
||||
await expect(channel).toHaveAttribute('aria-labelledby', /\S+/);
|
||||
await expect(popover.getByRole('combobox', { name: label('chat.hitlModeLabel'), exact: true })).toHaveCount(0);
|
||||
await channel.click();
|
||||
await page.getByRole('listbox').getByText('示例通道 B', { exact: true }).click();
|
||||
await mode.click();
|
||||
await page.getByRole('listbox').getByText(label('chat.reasoningModeOn'), { exact: true }).click();
|
||||
await effort.click();
|
||||
await page.getByRole('listbox').getByText('high', { exact: true }).click();
|
||||
await menu.getByRole('menuitem', { name: label('chat.reasoningModeOn') }).click();
|
||||
await slider.press('Home');
|
||||
for (let step = 0; step < 3; step++) await slider.press('ArrowRight');
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '3');
|
||||
await expect(value).toHaveText(label('chat.reasoningEffortLabels.high', '高'));
|
||||
await mode.click();
|
||||
await page.getByRole('listbox').getByText(label('chat.reasoningModeOff'), { exact: true }).click();
|
||||
await expect(effort).toBeDisabled();
|
||||
await menu.getByRole('menuitem', { name: label('chat.reasoningModeOff') }).click();
|
||||
await expect(slider).toHaveAttribute('aria-disabled', 'true');
|
||||
await expect(value).toHaveText(label('chat.reasoningModeOff'));
|
||||
if (reasoningMode === 'on') {
|
||||
await mode.click();
|
||||
await page.getByRole('listbox').getByText(label('chat.reasoningModeOn'), { exact: true }).click();
|
||||
await expect(effort).toBeEnabled();
|
||||
await expect(effort).toHaveText('high');
|
||||
await menu.getByRole('menuitem', { name: label('chat.reasoningModeOn') }).click();
|
||||
await expect(slider).toHaveAttribute('aria-disabled', 'false');
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '3');
|
||||
await expect(value).toHaveText(label('chat.reasoningEffortLabels.high', '高'));
|
||||
}
|
||||
await expect.poll(() => page.evaluate(() => ({
|
||||
channel: localStorage.getItem('cyberstrike-chat-ai-channel'),
|
||||
|
|
@ -471,9 +478,11 @@ test.describe('chat session settings', () => {
|
|||
await ready(page);
|
||||
await openModel.click();
|
||||
await expect(channel).toHaveText('示例通道 B');
|
||||
await expect(mode).toHaveText(label(reasoningMode === 'off' ? 'chat.reasoningModeOff' : 'chat.reasoningModeOn'));
|
||||
if (reasoningMode === 'off') await expect(effort).toBeDisabled();
|
||||
else await expect(effort).toHaveText('high');
|
||||
await expect(mode).toHaveAttribute('title', new RegExp(label(reasoningMode === 'off' ? 'chat.reasoningModeOff' : 'chat.reasoningModeOn')));
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '3');
|
||||
await expect(slider).toHaveAttribute('aria-disabled', String(reasoningMode === 'off'));
|
||||
await expect(value).toHaveText(reasoningMode === 'off'
|
||||
? label('chat.reasoningModeOff') : label('chat.reasoningEffortLabels.high', '高'));
|
||||
await main.locator('.chat-header-title').click();
|
||||
const input = main.getByRole('textbox', { name: label('chat.composerLabel', '对话内容') });
|
||||
await input.fill(message);
|
||||
|
|
@ -489,6 +498,241 @@ test.describe('chat session settings', () => {
|
|||
});
|
||||
}
|
||||
|
||||
test('composer reasoning slider covers all six levels and clamps keyboard boundaries', async ({ page, mockApi }) => {
|
||||
mockApi.respond('GET', '/api/agent-loop/tasks', { json: { tasks: [] } });
|
||||
mockApi.respond('GET', '/api/config', { json: { ai: {
|
||||
default_channel: 'demo-primary',
|
||||
channels: { 'demo-primary': { name: '示例通道 A', model: 'fixture-a' } }
|
||||
} } });
|
||||
const main = await visit(page, 'chat');
|
||||
await main.getByRole('button', { name: label('chat.modelSettingsAria'), exact: true }).click();
|
||||
const popover = page.locator('.chat-model-popover');
|
||||
const mode = popover.getByRole('button', { name: label('chat.reasoningModeLabel'), exact: true });
|
||||
const slider = popover.getByRole('slider', { name: label('chat.reasoningEffortLabel'), exact: true });
|
||||
const value = popover.locator('.chat-reasoning-value[role="status"]');
|
||||
await expect(popover.getByRole('combobox')).toHaveCount(1);
|
||||
await expect(popover.getByRole('slider')).toHaveCount(1);
|
||||
await expect(slider).toHaveAttribute('aria-valuemin', '0');
|
||||
await expect(slider).toHaveAttribute('aria-valuemax', '5');
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '0');
|
||||
await expect(value).toHaveText(label('chat.reasoningModeDefault'));
|
||||
|
||||
await slider.press('End');
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '5');
|
||||
await slider.press('Home');
|
||||
const levels = [
|
||||
['', label('chat.reasoningModeDefault')],
|
||||
['low', '低'], ['medium', '中'], ['high', '高'], ['xhigh', '超高'], ['max', '最高']
|
||||
];
|
||||
for (const [index, [effort, text]] of levels.entries()) {
|
||||
if (index > 0) await slider.press('ArrowRight');
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', String(index));
|
||||
await expect(slider).toHaveAttribute('aria-disabled', 'false');
|
||||
await expect(value).toHaveText(text);
|
||||
await expect(mode).toHaveAttribute('title', new RegExp(label(index === 0 ? 'chat.reasoningModeDefault' : 'chat.reasoningModeOn')));
|
||||
await expect.poll(() => page.evaluate(() => ({
|
||||
mode: localStorage.getItem('cyberstrike-chat-reasoning-mode'),
|
||||
effort: localStorage.getItem('cyberstrike-chat-reasoning-effort')
|
||||
}))).toEqual({ mode: index === 0 ? 'default' : 'on', effort });
|
||||
}
|
||||
await slider.press('ArrowRight');
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '5');
|
||||
await expect(value).toHaveText('最高');
|
||||
await expect.poll(() => page.evaluate(() => ({
|
||||
mode: localStorage.getItem('cyberstrike-chat-reasoning-mode'),
|
||||
effort: localStorage.getItem('cyberstrike-chat-reasoning-effort')
|
||||
}))).toEqual({ mode: 'on', effort: 'max' });
|
||||
await slider.press('Home');
|
||||
await slider.press('ArrowLeft');
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '0');
|
||||
await expect(value).toHaveText(label('chat.reasoningModeDefault'));
|
||||
await slider.press('ArrowRight');
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '1');
|
||||
await slider.press('ArrowLeft');
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '0');
|
||||
await expect(value).toHaveText(label('chat.reasoningModeDefault'));
|
||||
await expect(mode).toHaveAttribute('title', new RegExp(label('chat.reasoningModeDefault')));
|
||||
await expect.poll(() => page.evaluate(() => ({
|
||||
mode: localStorage.getItem('cyberstrike-chat-reasoning-mode'),
|
||||
effort: localStorage.getItem('cyberstrike-chat-reasoning-effort')
|
||||
}))).toEqual({ mode: 'default', effort: '' });
|
||||
expect(mockApi.writes()).toEqual([]);
|
||||
});
|
||||
|
||||
test('composer reasoning slider selects high with a mouse click and enables reasoning', async ({ page, mockApi }) => {
|
||||
mockApi.respond('GET', '/api/agent-loop/tasks', { json: { tasks: [] } });
|
||||
mockApi.respond('GET', '/api/config', { json: { ai: {
|
||||
default_channel: 'demo-primary',
|
||||
channels: { 'demo-primary': { name: '示例通道 A', model: 'fixture-a' } }
|
||||
} } });
|
||||
const main = await visit(page, 'chat');
|
||||
await main.getByRole('button', { name: label('chat.modelSettingsAria'), exact: true }).click();
|
||||
const popover = page.locator('.chat-model-popover');
|
||||
const slider = popover.getByRole('slider', { name: label('chat.reasoningEffortLabel'), exact: true });
|
||||
const mode = popover.getByRole('button', { name: label('chat.reasoningModeLabel'), exact: true });
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '0');
|
||||
const rail = popover.locator('.semi-slider-rail');
|
||||
await rail.hover();
|
||||
const box = await rail.boundingBox();
|
||||
expect(box).not.toBeNull();
|
||||
// Click between marks on the unfilled rail; do not bypass the pointer handlers.
|
||||
await rail.click({ position: { x: box.width * 0.64, y: box.height / 2 } });
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '3');
|
||||
await expect(popover.locator('.chat-reasoning-value[role="status"]')).toHaveText('高');
|
||||
await expect(mode).toHaveAttribute('title', new RegExp(label('chat.reasoningModeOn')));
|
||||
await expect.poll(() => page.evaluate(() => ({
|
||||
mode: localStorage.getItem('cyberstrike-chat-reasoning-mode'),
|
||||
effort: localStorage.getItem('cyberstrike-chat-reasoning-effort')
|
||||
}))).toEqual({ mode: 'on', effort: 'high' });
|
||||
expect(mockApi.writes()).toEqual([]);
|
||||
});
|
||||
|
||||
test('composer reasoning reset preserves the selected channel and sends without reasoning', async ({ page, mockApi }) => {
|
||||
mockApi.respond('GET', '/api/agent-loop/tasks', { json: { tasks: [] } });
|
||||
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' }
|
||||
}
|
||||
} } });
|
||||
const message = 'FAKE:重置推理后仍使用所选示例通道。';
|
||||
const id = mockApi.enableChatStream(message);
|
||||
const main = await visit(page, 'chat');
|
||||
const openModel = main.getByRole('button', { name: label('chat.modelSettingsAria'), exact: true });
|
||||
await openModel.click();
|
||||
const popover = page.locator('.chat-model-popover');
|
||||
const channel = popover.getByRole('combobox', { name: label('chat.aiChannelLabel'), exact: true });
|
||||
const mode = popover.getByRole('button', { name: label('chat.reasoningModeLabel'), exact: true });
|
||||
const slider = popover.getByRole('slider', { name: label('chat.reasoningEffortLabel'), exact: true });
|
||||
const value = popover.locator('.chat-reasoning-value[role="status"]');
|
||||
const reset = popover.getByRole('button', { name: label('chat.reasoningReset', '重置推理设置'), exact: true });
|
||||
await channel.click();
|
||||
await page.getByRole('listbox').getByText('示例通道 B', { exact: true }).click();
|
||||
await slider.press('End');
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '5');
|
||||
await mode.click();
|
||||
await page.locator('.chat-reasoning-mode-menu').getByRole('menuitem', { name: label('chat.reasoningModeOff') }).click();
|
||||
await expect(slider).toHaveAttribute('aria-disabled', 'true');
|
||||
await expect.poll(() => page.evaluate(() => ({
|
||||
channel: localStorage.getItem('cyberstrike-chat-ai-channel'),
|
||||
mode: localStorage.getItem('cyberstrike-chat-reasoning-mode'),
|
||||
effort: localStorage.getItem('cyberstrike-chat-reasoning-effort')
|
||||
}))).toEqual({ channel: 'demo-backup', mode: 'off', effort: 'max' });
|
||||
|
||||
await expect(reset).toBeEnabled();
|
||||
await reset.click();
|
||||
await expect(channel).toHaveText('示例通道 B');
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '0');
|
||||
await expect(slider).toHaveAttribute('aria-disabled', 'false');
|
||||
await expect(value).toHaveText(label('chat.reasoningModeDefault'));
|
||||
await expect(mode).toHaveAttribute('title', new RegExp(label('chat.reasoningModeDefault')));
|
||||
await expect.poll(() => page.evaluate(() => ({
|
||||
channel: localStorage.getItem('cyberstrike-chat-ai-channel'),
|
||||
mode: localStorage.getItem('cyberstrike-chat-reasoning-mode'),
|
||||
effort: localStorage.getItem('cyberstrike-chat-reasoning-effort')
|
||||
}))).toEqual({ channel: 'demo-backup', mode: 'default', effort: '' });
|
||||
expect(mockApi.writes()).toEqual([]);
|
||||
await page.reload();
|
||||
await ready(page);
|
||||
await openModel.click();
|
||||
await expect(channel).toHaveText('示例通道 B');
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '0');
|
||||
await expect(slider).toHaveAttribute('aria-disabled', 'false');
|
||||
await expect(value).toHaveText(label('chat.reasoningModeDefault'));
|
||||
await expect(mode).toHaveAttribute('title', new RegExp(label('chat.reasoningModeDefault')));
|
||||
await main.locator('.chat-header-title').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(({ method, path, body }) => ({ method, path, body }))).toEqual([{
|
||||
method: 'POST', path: '/api/agent/stream',
|
||||
body: { message, conversationId: '', aiChannelId: 'demo-backup' }
|
||||
}]);
|
||||
expect(mockApi.calls('POST', '/api/agent/stream')[0].body).not.toHaveProperty('reasoning');
|
||||
});
|
||||
|
||||
test('composer reasoning modes round-trip auto, default and off without losing retained effort', async ({ page, mockApi }) => {
|
||||
mockApi.respond('GET', '/api/agent-loop/tasks', { json: { tasks: [] } });
|
||||
mockApi.respond('GET', '/api/config', { json: { ai: {
|
||||
default_channel: 'demo-primary',
|
||||
channels: { 'demo-primary': { name: '示例通道 A', model: 'fixture-a' } }
|
||||
} } });
|
||||
const message = 'FAKE:保留自动推理模式与示例强度。';
|
||||
const id = mockApi.enableChatStream(message);
|
||||
const main = await visit(page, 'chat');
|
||||
const openModel = main.getByRole('button', { name: label('chat.modelSettingsAria'), exact: true });
|
||||
await openModel.click();
|
||||
const popover = page.locator('.chat-model-popover');
|
||||
const mode = popover.getByRole('button', { name: label('chat.reasoningModeLabel'), exact: true });
|
||||
const slider = popover.getByRole('slider', { name: label('chat.reasoningEffortLabel'), exact: true });
|
||||
const value = popover.locator('.chat-reasoning-value[role="status"]');
|
||||
const menu = page.locator('.chat-reasoning-mode-menu');
|
||||
const modes = {
|
||||
default: label('chat.reasoningModeDefault'), off: label('chat.reasoningModeOff'),
|
||||
on: label('chat.reasoningModeOn'), auto: label('chat.reasoningModeAuto')
|
||||
};
|
||||
await expect(value).toHaveText(modes.default);
|
||||
await mode.click();
|
||||
await expect(menu.getByRole('menuitem')).toHaveCount(4);
|
||||
for (const name of Object.values(modes)) await expect(menu.getByRole('menuitem', { name })).toBeVisible();
|
||||
await menu.getByRole('menuitem', { name: modes.default }).click();
|
||||
// Mode menu actions and genuine keyboard input share the same persisted preferences.
|
||||
const transitions = [
|
||||
['auto', 'auto', '', 0, modes.auto],
|
||||
['End', 'auto', 'max', 5, '最高'],
|
||||
['off', 'off', 'max', 5, modes.off],
|
||||
['Home', 'off', 'max', 5, modes.off],
|
||||
['auto', 'auto', 'max', 5, '最高'],
|
||||
['Home', 'default', '', 0, modes.default],
|
||||
['auto', 'auto', '', 0, modes.auto],
|
||||
['End', 'auto', 'max', 5, '最高'],
|
||||
['default', 'default', '', 0, modes.default],
|
||||
['on', 'on', '', 0, modes.on],
|
||||
['ArrowRight', 'on', 'low', 1, '低'],
|
||||
['auto', 'auto', 'low', 1, '低'],
|
||||
['ArrowRight', 'auto', 'medium', 2, '中'],
|
||||
['off', 'off', 'medium', 2, modes.off],
|
||||
['on', 'on', 'medium', 2, '中'],
|
||||
['auto', 'auto', 'medium', 2, '中']
|
||||
];
|
||||
for (const [action, expectedMode, effort, level, text] of transitions) {
|
||||
await test.step(`${action}: ${expectedMode}/${effort || 'unset'}`, async () => {
|
||||
if (modes[action]) {
|
||||
await mode.click();
|
||||
await menu.getByRole('menuitem', { name: modes[action] }).click();
|
||||
} else {
|
||||
await slider.press(action);
|
||||
}
|
||||
await expect(mode).toHaveAttribute('title', new RegExp(modes[expectedMode]));
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', String(level));
|
||||
await expect(slider).toHaveAttribute('aria-disabled', String(expectedMode === 'off'));
|
||||
await expect(value).toHaveText(text);
|
||||
await expect.poll(() => page.evaluate(() => ({
|
||||
mode: localStorage.getItem('cyberstrike-chat-reasoning-mode'),
|
||||
effort: localStorage.getItem('cyberstrike-chat-reasoning-effort')
|
||||
}))).toEqual({ mode: expectedMode, effort });
|
||||
});
|
||||
}
|
||||
expect(mockApi.writes()).toEqual([]);
|
||||
await page.reload();
|
||||
await ready(page);
|
||||
await openModel.click();
|
||||
await expect(mode).toHaveAttribute('title', new RegExp(modes.auto));
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '2');
|
||||
await expect(value).toHaveText('中');
|
||||
await main.locator('.chat-header-title').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(({ method, path, body }) => ({ method, path, body }))).toEqual([{
|
||||
method: 'POST', path: '/api/agent/stream',
|
||||
body: { message, conversationId: '', reasoning: { mode: 'auto', effort: 'medium' } }
|
||||
}]);
|
||||
});
|
||||
|
||||
test('composer HITL entry edits a local draft in a HITL-only sheet and includes it in the first send', async ({ page, mockApi }) => {
|
||||
mockApi.respond('GET', '/api/agent-loop/tasks', { json: { tasks: [] } });
|
||||
mockApi.respond('GET', '/api/hitl/default-config', { json: {
|
||||
|
|
@ -593,6 +837,55 @@ test.describe('chat session settings', () => {
|
|||
test.describe('chat composer read-only permissions', () => {
|
||||
test.use({ appPermissions: UI_PERMISSIONS.filter(permission => permission !== 'chat:write') });
|
||||
|
||||
test('disables the composer reasoning slider, mode and reset without chat:write', async ({ page, mockApi }) => {
|
||||
const conversation = mockEmptyConversation(mockApi);
|
||||
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' }
|
||||
}
|
||||
} } });
|
||||
const main = await visit(page, `chat?conversation=${conversation.id}`);
|
||||
await page.evaluate(() => {
|
||||
localStorage.setItem('cyberstrike-chat-ai-channel', 'demo-backup');
|
||||
localStorage.setItem('cyberstrike-chat-reasoning-mode', 'auto');
|
||||
localStorage.setItem('cyberstrike-chat-reasoning-effort', 'high');
|
||||
});
|
||||
await page.reload();
|
||||
await ready(page);
|
||||
await main.getByRole('button', { name: label('chat.modelSettingsAria'), exact: true }).click();
|
||||
const popover = page.locator('.chat-model-popover');
|
||||
const channel = popover.getByRole('combobox', { name: label('chat.aiChannelLabel'), exact: true });
|
||||
const mode = popover.getByRole('button', { name: label('chat.reasoningModeLabel'), exact: true });
|
||||
const slider = popover.getByRole('slider', { name: label('chat.reasoningEffortLabel'), exact: true });
|
||||
const reset = popover.getByRole('button', { name: label('chat.reasoningReset', '重置推理设置'), exact: true });
|
||||
const value = popover.locator('.chat-reasoning-value[role="status"]');
|
||||
await expect(popover.getByRole('combobox')).toHaveCount(1);
|
||||
await expect(channel).toHaveText('示例通道 B');
|
||||
await expect(channel).toBeDisabled();
|
||||
await expect(mode).toHaveAttribute('title', new RegExp(label('chat.reasoningModeAuto')));
|
||||
await expect(mode).toBeDisabled();
|
||||
await expect(reset).toBeDisabled();
|
||||
await expect(slider).toHaveAttribute('aria-disabled', 'true');
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '3');
|
||||
await expect(value).toHaveText('高');
|
||||
for (const key of ['Home', 'ArrowRight', 'End']) {
|
||||
await slider.press(key);
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '3');
|
||||
}
|
||||
await expect(value).toHaveText('高');
|
||||
await expect.poll(() => page.evaluate(() => ({
|
||||
channel: localStorage.getItem('cyberstrike-chat-ai-channel'),
|
||||
mode: localStorage.getItem('cyberstrike-chat-reasoning-mode'),
|
||||
effort: localStorage.getItem('cyberstrike-chat-reasoning-effort')
|
||||
}))).toEqual({ channel: 'demo-backup', mode: 'auto', effort: 'high' });
|
||||
await main.locator('.chat-header-title').click();
|
||||
await expect(main.getByRole('textbox', { name: label('chat.composerLabel', '对话内容') })).toBeDisabled();
|
||||
await expect(main.getByRole('button', { name: /发送$/ })).toBeDisabled();
|
||||
expect(mockApi.writes()).toEqual([]);
|
||||
});
|
||||
|
||||
test('disables stored project changes and HITL editing without their respective write permissions', async ({ page, mockApi }) => {
|
||||
const conversation = mockEmptyConversation(mockApi, PROJECT.id);
|
||||
mockApi.respond('GET', `/api/hitl/config/${conversation.id}`, { json: {
|
||||
|
|
|
|||
|
|
@ -436,7 +436,7 @@ for (const width of [1440, 1024, 390]) {
|
|||
await screenshot(page, testInfo, `chat-header-${stored ? 'long-title' : 'new'}-${width}`);
|
||||
await model.click();
|
||||
const modelPopover = page.locator('.chat-model-popover');
|
||||
await expect(modelPopover.getByRole('combobox', { name: label('chat.reasoningEffortLabel') })).toBeVisible();
|
||||
await expect(modelPopover.getByRole('slider', { name: label('chat.reasoningEffortLabel') })).toBeVisible();
|
||||
await expect(modelPopover).toBeInViewport({ ratio: 1 });
|
||||
const popoverBox = await modelPopover.boundingBox();
|
||||
expect(popoverBox.x).toBeGreaterThanOrEqual(0);
|
||||
|
|
@ -456,6 +456,52 @@ for (const width of [1440, 1024, 390]) {
|
|||
});
|
||||
}
|
||||
|
||||
for (const width of [1440, 390]) {
|
||||
for (const colorScheme of ['light', 'dark']) {
|
||||
test(`chat: compact reasoning picker at ${width}px in ${colorScheme} mode`, async ({ page, mockApi }, testInfo) => {
|
||||
await page.setViewportSize({ width, height: 900 });
|
||||
await page.emulateMedia({ colorScheme });
|
||||
mockApi.respond('GET', '/api/config', { json: { ai: {
|
||||
default_channel: 'fixture-model',
|
||||
channels: { 'fixture-model': { name: '示例模型', model: 'fixture-model' } }
|
||||
} } });
|
||||
const main = await visit(page, 'chat');
|
||||
const composer = main.locator('.chat-composer');
|
||||
const openModel = button(composer, label('chat.modelSettingsAria'));
|
||||
await expect(openModel).toContainText('示例模型');
|
||||
await openModel.click();
|
||||
const popover = page.locator('.chat-model-popover');
|
||||
const slider = popover.getByRole('slider', { name: label('chat.reasoningEffortLabel') });
|
||||
await expect(slider).toBeVisible();
|
||||
await expect(popover.getByRole('combobox')).toHaveCount(1);
|
||||
await slider.focus();
|
||||
await slider.press('Home');
|
||||
for (let index = 0; index < 3; index++) await slider.press('ArrowRight');
|
||||
await expect(slider).toHaveAttribute('aria-valuenow', '3');
|
||||
await expect(slider).toHaveAttribute('aria-valuetext', label('chat.reasoningEffortLabels.high'));
|
||||
await expect(popover.getByRole('status')).toHaveText(label('chat.reasoningEffortLabels.high'));
|
||||
await expect(composer.locator('.chat-composer-effort')).toHaveText(label('chat.reasoningEffortLabels.high'));
|
||||
await expect(popover).toBeInViewport({ ratio: 1 });
|
||||
const bounds = await popover.boundingBox();
|
||||
expect(bounds.height).toBeLessThanOrEqual(180);
|
||||
expect(bounds.width).toBeLessThanOrEqual(300);
|
||||
expect(bounds.x).toBeGreaterThanOrEqual(0);
|
||||
expect(bounds.x + bounds.width).toBeLessThanOrEqual(width);
|
||||
const overflow = await popover.evaluate(element => element.scrollWidth - element.clientWidth);
|
||||
expect(overflow).toBeLessThanOrEqual(1);
|
||||
await expect(button(popover, label('chat.reasoningReset'))).toBeInViewport({ ratio: 1 });
|
||||
await expect(popover.getByRole('combobox')).toBeInViewport({ ratio: 1 });
|
||||
await expect(popover.locator('.chat-reasoning-channel .semi-select-arrow')).toHaveCSS('opacity', '1');
|
||||
await screenshot(page, testInfo, `chat-reasoning-${width}-${colorScheme}`);
|
||||
await popover.screenshot({ path: testInfo.outputPath(`reasoning-panel-${width}-${colorScheme}.png`) });
|
||||
await slider.press('Escape');
|
||||
await expect(popover).not.toBeVisible();
|
||||
await expect(openModel).toBeFocused();
|
||||
expect(mockApi.writes()).toEqual([]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
test.describe('chat: session settings permission boundary', () => {
|
||||
test.use({ appPermissions: READ_PERMISSIONS.filter(permission => !['config:read', 'hitl:read'].includes(permission)) });
|
||||
test('hides session settings without configuration, approval or execution access', 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{I as r,P as i,St as a,U as o,V as s,i as c,it as l,j as u,ot as d,rt as f,yt as p}from"./semi-BX8ib3Fq.js";import{F as m,I as h,P as g,a as _,b as v,c as y,d as b,f as x,l as S,m as C,p as w,s as T,u as E,x as D,y as O}from"./index-CiI19B2v.js";var k=e(t(),1),A=e(n(),1),{Text:j}=o;function M(){let e=g(),{hasPermission:t}=m(),n=t(`agents:write`),o=t(`agents:delete`),[M,N]=(0,k.useState)(``),[P,F]=(0,k.useState)(null),[I,L]=(0,k.useState)(null),[R,z]=(0,k.useState)(!1),B=_(()=>h.get(`/multi-agent/markdown-agents`),[]),V=(Array.isArray(B.data?.agents)?B.data.agents:[]).filter(e=>{if(!M)return!0;let t=M.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),H=async e=>{try{F(await h.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){v(e,`读取智能体失败`)}},U=async()=>{let e=await I.form.validate();z(!0);try{await h.post(`/multi-agent/markdown-agents`,{filename:e.filename?.trim()||``,name:e.name.trim(),description:e.description?.trim()||``,instruction:e.instruction,kind:e.kind||`sub`,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean)}),D(`智能体已保存`),L(null),B.reload()}catch(e){v(e,`保存智能体失败`)}finally{z(!1)}},W=e=>O({title:`删除智能体「${e.name||e.filename}」?`,onOk:async()=>{await h.del(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`),D(`已删除`),B.reload()}});return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(w,{title:e(`agents.title`,null,`智能体管理`),description:B.data?.dir?`目录:${B.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,A.jsxs)(i,{children:[(0,A.jsx)(r,{icon:(0,A.jsx)(l,{}),onClick:()=>B.reload(),loading:B.loading,children:`刷新`}),n&&(0,A.jsx)(r,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(d,{}),onClick:()=>L({record:null,form:{}}),children:`新建智能体`})]})}),B.data?.error&&(0,A.jsx)(S,{error:B.data.error}),(0,A.jsxs)(C,{title:`智能体(${V.length})`,children:[(0,A.jsx)(S,{error:B.error,onRetry:()=>B.reload()}),(0,A.jsx)(T,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,A.jsxs)(i,{vertical:!0,spacing:0,align:`start`,children:[(0,A.jsxs)(i,{children:[(0,A.jsx)(j,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,A.jsx)(u,{size:`small`,color:`purple`,children:`编排器`})]}),(0,A.jsx)(j,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,A.jsx)(u,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,A.jsx)(j,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,A.jsxs)(i,{children:[(0,A.jsx)(r,{size:`small`,theme:`borderless`,onClick:()=>H(t),children:`详情`}),n&&(0,A.jsx)(r,{size:`small`,theme:`borderless`,icon:(0,A.jsx)(p,{}),onClick:()=>L({record:t,form:{}})}),o&&(0,A.jsx)(r,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,A.jsx)(a,{}),onClick:()=>W(t)})]})}],dataSource:V,rowKey:`filename`,loading:B.loading,pagination:{pageSize:20},toolbar:(0,A.jsx)(s,{prefix:(0,A.jsx)(f,{}),value:M,onChange:N,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,A.jsx)(y,{title:I?.record?`编辑智能体`:`新建智能体`,visible:!!I,onCancel:()=>L(null),onOk:U,confirmLoading:R,width:760,children:(0,A.jsxs)(c,{getFormApi:e=>L(t=>t&&{...t,form:e}),initValues:I?.record?{filename:I.record.filename,name:I.record.name,description:I.record.description,kind:I.record.kind||`sub`}:{kind:`sub`},children:[(0,A.jsx)(c.Input,{field:`filename`,label:`文件名(留空自动生成)`,placeholder:`例如 recon.md`}),(0,A.jsx)(c.Input,{field:`name`,label:`名称`,rules:[{required:!0,message:`请输入名称`}]}),(0,A.jsx)(c.Input,{field:`description`,label:`描述`}),(0,A.jsx)(c.Select,{field:`kind`,label:`类型`,optionList:[{value:`sub`,label:`子智能体`},{value:`orchestrator`,label:`编排器`},{value:`plan_execute`,label:`计划执行`}]}),(0,A.jsx)(c.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::tool`}),(0,A.jsx)(c.TextArea,{field:`instruction`,label:`指令(Markdown)`,autosize:{minRows:8,maxRows:20}})]})},I?.record?.filename||`new-agent`),(0,A.jsx)(y,{title:P?.name||`智能体详情`,visible:!!P,onCancel:()=>F(null),width:720,children:P&&(0,A.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,A.jsx)(b,{items:[{label:`文件名`,value:P.filename},{label:`ID`,value:P.id},{label:`类型`,value:P.kind},{label:`绑定角色`,value:P.bind_role||`—`},{label:`最大迭代`,value:P.max_iterations??`—`},{label:`工具`,value:Array.isArray(P.tools)&&P.tools.length?P.tools.join(`、`):`—`}]}),(0,A.jsx)(x,{content:P.instruction||P.raw||``}),(0,A.jsx)(E,{value:P.raw||P,title:`原始 Markdown`,collapsed:!0})]})})]})}export{M as default};
|
||||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,at as c,ct as l,i as u,ot as d,wt as f,xt as p}from"./semi-DCiGoqD2.js";import{F as m,I as h,P as g,a as _,b as v,c as y,d as b,f as x,l as S,m as C,p as w,s as T,u as E,x as D,y as O}from"./index-Dsnqqq1H.js";var k=e(t(),1),A=e(n(),1),{Text:j}=s;function M(){let e=g(),{hasPermission:t}=m(),n=t(`agents:write`),s=t(`agents:delete`),[M,N]=(0,k.useState)(``),[P,F]=(0,k.useState)(null),[I,L]=(0,k.useState)(null),[R,z]=(0,k.useState)(!1),B=_(()=>h.get(`/multi-agent/markdown-agents`),[]),V=(Array.isArray(B.data?.agents)?B.data.agents:[]).filter(e=>{if(!M)return!0;let t=M.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),H=async e=>{try{F(await h.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){v(e,`读取智能体失败`)}},U=async()=>{let e=await I.form.validate();z(!0);try{await h.post(`/multi-agent/markdown-agents`,{filename:e.filename?.trim()||``,name:e.name.trim(),description:e.description?.trim()||``,instruction:e.instruction,kind:e.kind||`sub`,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean)}),D(`智能体已保存`),L(null),B.reload()}catch(e){v(e,`保存智能体失败`)}finally{z(!1)}},W=e=>O({title:`删除智能体「${e.name||e.filename}」?`,onOk:async()=>{await h.del(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`),D(`已删除`),B.reload()}});return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(w,{title:e(`agents.title`,null,`智能体管理`),description:B.data?.dir?`目录:${B.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,A.jsxs)(r,{children:[(0,A.jsx)(a,{icon:(0,A.jsx)(d,{}),onClick:()=>B.reload(),loading:B.loading,children:`刷新`}),n&&(0,A.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(l,{}),onClick:()=>L({record:null,form:{}}),children:`新建智能体`})]})}),B.data?.error&&(0,A.jsx)(S,{error:B.data.error}),(0,A.jsxs)(C,{title:`智能体(${V.length})`,children:[(0,A.jsx)(S,{error:B.error,onRetry:()=>B.reload()}),(0,A.jsx)(T,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,A.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,A.jsxs)(r,{children:[(0,A.jsx)(j,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,A.jsx)(o,{size:`small`,color:`purple`,children:`编排器`})]}),(0,A.jsx)(j,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,A.jsx)(o,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,A.jsx)(j,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,A.jsxs)(r,{children:[(0,A.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>H(t),children:`详情`}),n&&(0,A.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,A.jsx)(p,{}),onClick:()=>L({record:t,form:{}})}),s&&(0,A.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,A.jsx)(f,{}),onClick:()=>W(t)})]})}],dataSource:V,rowKey:`filename`,loading:B.loading,pagination:{pageSize:20},toolbar:(0,A.jsx)(i,{prefix:(0,A.jsx)(c,{}),value:M,onChange:N,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,A.jsx)(y,{title:I?.record?`编辑智能体`:`新建智能体`,visible:!!I,onCancel:()=>L(null),onOk:U,confirmLoading:R,width:760,children:(0,A.jsxs)(u,{getFormApi:e=>L(t=>t&&{...t,form:e}),initValues:I?.record?{filename:I.record.filename,name:I.record.name,description:I.record.description,kind:I.record.kind||`sub`}:{kind:`sub`},children:[(0,A.jsx)(u.Input,{field:`filename`,label:`文件名(留空自动生成)`,placeholder:`例如 recon.md`}),(0,A.jsx)(u.Input,{field:`name`,label:`名称`,rules:[{required:!0,message:`请输入名称`}]}),(0,A.jsx)(u.Input,{field:`description`,label:`描述`}),(0,A.jsx)(u.Select,{field:`kind`,label:`类型`,optionList:[{value:`sub`,label:`子智能体`},{value:`orchestrator`,label:`编排器`},{value:`plan_execute`,label:`计划执行`}]}),(0,A.jsx)(u.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::tool`}),(0,A.jsx)(u.TextArea,{field:`instruction`,label:`指令(Markdown)`,autosize:{minRows:8,maxRows:20}})]})},I?.record?.filename||`new-agent`),(0,A.jsx)(y,{title:P?.name||`智能体详情`,visible:!!P,onCancel:()=>F(null),width:720,children:P&&(0,A.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,A.jsx)(b,{items:[{label:`文件名`,value:P.filename},{label:`ID`,value:P.id},{label:`类型`,value:P.kind},{label:`绑定角色`,value:P.bind_role||`—`},{label:`最大迭代`,value:P.max_iterations??`—`},{label:`工具`,value:Array.isArray(P.tools)&&P.tools.length?P.tools.join(`、`):`—`}]}),(0,A.jsx)(x,{content:P.instruction||P.raw||``}),(0,A.jsx)(E,{value:P.raw||P,title:`原始 Markdown`,collapsed:!0})]})})]})}export{M as default};
|
||||
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
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}from"./semi-BX8ib3Fq.js";import{E as i,P as a,k as o}from"./index-CiI19B2v.js";import"./c2-shared-CU1DgJgC.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{F as t,L as n,W as r}from"./semi-DCiGoqD2.js";import{E as i,P as a,k as o}from"./index-Dsnqqq1H.js";import"./c2-shared-CZN40x-m.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-CiI19B2v.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-Dsnqqq1H.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};
|
||||
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
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,St as a,U as o,V as s,it as c,j as l,rt as u}from"./semi-BX8ib3Fq.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-CiI19B2v.js";var T=e(t(),1),E=e(n(),1),{Text:D}=o;function O(){let e=m(),{hasPermission:t}=f(),n=t(`knowledge:delete`),[o,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(50),[j,M]=(0,T.useState)(null),N=h(()=>p.get(`/knowledge/retrieval-logs`,{conversationId:o||void 0,limit:k}),[o,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)(c,{}),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)(l,{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)(a,{}),onClick:()=>F(t)})]})}],dataSource:P,rowKey:`id`,loading:N.loading,pagination:!1,toolbar:(0,E.jsxs)(i,{children:[(0,E.jsx)(s,{prefix:(0,E.jsx)(u,{}),placeholder:`按会话 ID 过滤`,value:o,onChange:O,style:{width:260}}),(0,E.jsx)(s,{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{F as r,H as i,L as a,M as o,W as s,at as c,ot as l,wt as u}from"./semi-DCiGoqD2.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-Dsnqqq1H.js";var T=e(t(),1),E=e(n(),1),{Text:D}=s;function O(){let e=m(),{hasPermission:t}=f(),n=t(`knowledge:delete`),[s,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(50),[j,M]=(0,T.useState)(null),N=h(()=>p.get(`/knowledge/retrieval-logs`,{conversationId:s||void 0,limit:k}),[s,k]),P=Array.isArray(N.data?.logs)?N.data.logs:[],F=e=>w({title:`删除该检索日志?`,content:e.query||e.id,onOk:async()=>{await p.del(`/knowledge/retrieval-logs/${encodeURIComponent(e.id)}`),C(`已删除`),N.reload()}});return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(b,{title:e(`knowledge.retrievalLogsTitle`,null,`检索历史`),description:`记录智能体每次知识库检索的语句、命中项与会话,用于回溯回答依据。`,extra:(0,E.jsx)(a,{icon:(0,E.jsx)(l,{}),onClick:()=>N.reload(),loading:N.loading,children:`刷新`})}),(0,E.jsxs)(y,{title:`检索记录(${P.length})`,children:[(0,E.jsx)(v,{error:N.error,onRetry:()=>N.reload()}),(0,E.jsx)(x,{columns:[{title:`检索语句`,dataIndex:`query`,render:(e,t)=>(0,E.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>M(t),style:{background:`none`,border:`none`,padding:0,cursor:`pointer`,textAlign:`left`,color:`var(--semi-color-primary)`},children:e||`—`})},{title:`风险类型`,dataIndex:`riskType`,width:140,render:e=>e?(0,E.jsx)(o,{size:`small`,children:e}):`—`},{title:`命中知识项`,dataIndex:`retrievedItems`,width:120,render:e=>(0,E.jsxs)(D,{type:`tertiary`,children:[Array.isArray(e)?e.length:0,` 条`]})},{title:`会话`,dataIndex:`conversationId`,width:200,render:e=>(0,E.jsx)(D,{type:`tertiary`,ellipsis:{showTooltip:!0},children:e||`—`})},{title:`时间`,dataIndex:`createdAt`,width:180,render:e=>d(e)},{title:`操作`,width:110,render:(e,t)=>(0,E.jsxs)(r,{children:[(0,E.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>M(t),children:`详情`}),n&&(0,E.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,E.jsx)(u,{}),onClick:()=>F(t)})]})}],dataSource:P,rowKey:`id`,loading:N.loading,pagination:!1,toolbar:(0,E.jsxs)(r,{children:[(0,E.jsx)(i,{prefix:(0,E.jsx)(c,{}),placeholder:`按会话 ID 过滤`,value:s,onChange:O,style:{width:260}}),(0,E.jsx)(i,{placeholder:`条数`,value:String(k),onChange:e=>A(Math.min(Math.max(Number(e)||50,1),500)),style:{width:100},suffix:(0,E.jsx)(D,{type:`tertiary`,children:`条`})})]})})]}),(0,E.jsx)(g,{title:`检索日志详情`,visible:!!j,onCancel:()=>M(null),width:560,children:j&&(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,E.jsx)(_,{items:[{label:`日志 ID`,value:j.id},{label:`检索语句`,value:j.query},{label:`风险类型`,value:j.riskType||`—`},{label:`会话 ID`,value:j.conversationId||`—`},{label:`消息 ID`,value:j.messageId||`—`},{label:`时间`,value:d(j.createdAt)}]}),(0,E.jsx)(S,{value:j.retrievedItems||[],title:`命中知识项`})]})})]})}export{O as default};
|
||||
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{U as r,i}from"./semi-BX8ib3Fq.js";import{I as a,P as o,c as s,l as c,x as l}from"./index-CiI19B2v.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,maskClosable:!1,onCancel:n,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=>{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,{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,{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-DCiGoqD2.js";import{I as a,P as o,c as s,l as c,x as l}from"./index-Dsnqqq1H.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,maskClosable:!1,onCancel:n,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=>{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,{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,{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};
|
||||
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,St as a,U as o,V as s,i as c,it as l,j as u,ot as d,rt as f,yt as p}from"./semi-BX8ib3Fq.js";import{F as m,I as h,P as g,a as _,b as v,c as y,l as b,m as x,p as S,s as C,x as w,y as T}from"./index-CiI19B2v.js";var E=e(t(),1),D=e(n(),1),{Text:O}=o;function k(){let e=g(),{hasPermission:t}=m(),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=_(()=>h.get(`/roles`),[]),I=(Array.isArray(F.data?.roles)?F.data.roles:[]).filter(e=>{if(!k)return!0;let t=k.toLowerCase();return[e.name,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),L=async()=>{let e=await j.form.validate();P(!0);try{let t={name:e.name.trim(),description:e.description?.trim()||``,user_prompt:e.user_prompt||``,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean),enabled:e.enabled!==!1},n=j.role?.name;n&&n!==t.name?(await h.post(`/roles`,t),await h.del(`/roles/${encodeURIComponent(n)}`)):n?await h.put(`/roles/${encodeURIComponent(n)}`,t):await h.post(`/roles`,t),w(`角色已保存`),M(null),F.reload()}catch(e){v(e,`保存角色失败`)}finally{P(!1)}},R=e=>T({title:`删除角色「${e.name}」?`,content:`已绑定该角色的对话将失去对应提示词与工具配置。`,onOk:async()=>{await h.del(`/roles/${encodeURIComponent(e.name)}`),w(`已删除`),F.reload()}});return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(S,{title:e(`roles.title`,null,`角色管理`),description:`角色定义对话的系统提示词、可用工具与绑定工作流。`,extra:(0,D.jsxs)(i,{children:[(0,D.jsx)(r,{icon:(0,D.jsx)(l,{}),onClick:()=>F.reload(),loading:F.loading,children:`刷新`}),n&&(0,D.jsx)(r,{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)(i,{vertical:!0,spacing:0,align:`start`,children:[(0,D.jsxs)(i,{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)(i,{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)(i,{children:[n&&(0,D.jsx)(r,{size:`small`,theme:`borderless`,icon:(0,D.jsx)(p,{}),onClick:()=>M({role:t,form:{}}),children:`编辑`}),o&&(0,D.jsx)(r,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,D.jsx)(a,{}),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)(y,{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{F as r,H as i,L as a,M as o,W as s,at as c,ct as l,i as u,ot as d,wt as f,xt as p}from"./semi-DCiGoqD2.js";import{F as m,I as h,P as g,a as _,b as v,c as y,l as b,m as x,p as S,s as C,x as w,y as T}from"./index-Dsnqqq1H.js";var E=e(t(),1),D=e(n(),1),{Text:O}=s;function k(){let e=g(),{hasPermission:t}=m(),n=t(`roles:write`),s=t(`roles:delete`),[k,A]=(0,E.useState)(``),[j,M]=(0,E.useState)(null),[N,P]=(0,E.useState)(!1),F=_(()=>h.get(`/roles`),[]),I=(Array.isArray(F.data?.roles)?F.data.roles:[]).filter(e=>{if(!k)return!0;let t=k.toLowerCase();return[e.name,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),L=async()=>{let e=await j.form.validate();P(!0);try{let t={name:e.name.trim(),description:e.description?.trim()||``,user_prompt:e.user_prompt||``,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean),enabled:e.enabled!==!1},n=j.role?.name;n&&n!==t.name?(await h.post(`/roles`,t),await h.del(`/roles/${encodeURIComponent(n)}`)):n?await h.put(`/roles/${encodeURIComponent(n)}`,t):await h.post(`/roles`,t),w(`角色已保存`),M(null),F.reload()}catch(e){v(e,`保存角色失败`)}finally{P(!1)}},R=e=>T({title:`删除角色「${e.name}」?`,content:`已绑定该角色的对话将失去对应提示词与工具配置。`,onOk:async()=>{await h.del(`/roles/${encodeURIComponent(e.name)}`),w(`已删除`),F.reload()}});return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(S,{title:e(`roles.title`,null,`角色管理`),description:`角色定义对话的系统提示词、可用工具与绑定工作流。`,extra:(0,D.jsxs)(r,{children:[(0,D.jsx)(a,{icon:(0,D.jsx)(d,{}),onClick:()=>F.reload(),loading:F.loading,children:`刷新`}),n&&(0,D.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,D.jsx)(l,{}),onClick:()=>M({role:null,form:{}}),children:`新建角色`})]})}),(0,D.jsxs)(x,{title:`角色(${I.length})`,children:[(0,D.jsx)(b,{error:F.error,onRetry:()=>F.reload()}),(0,D.jsx)(C,{columns:[{title:`角色`,dataIndex:`name`,render:(e,t)=>(0,D.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,D.jsxs)(r,{children:[(0,D.jsx)(O,{strong:!0,children:e}),t.enabled===!1&&(0,D.jsx)(o,{size:`small`,color:`grey`,children:`已停用`})]}),(0,D.jsx)(O,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:t.description||`—`})]})},{title:`工具`,dataIndex:`tools`,width:260,render:e=>Array.isArray(e)&&e.length?(0,D.jsxs)(r,{wrap:!0,spacing:4,children:[e.slice(0,4).map(e=>(0,D.jsx)(o,{size:`small`,children:e},e)),e.length>4&&(0,D.jsxs)(O,{type:`tertiary`,children:[`+`,e.length-4]})]}):(0,D.jsx)(O,{type:`tertiary`,children:`未绑定`})},{title:`工作流`,dataIndex:`workflow_id`,width:160,render:e=>e||`—`},{title:`操作`,width:150,render:(e,t)=>(0,D.jsxs)(r,{children:[n&&(0,D.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,D.jsx)(p,{}),onClick:()=>M({role:t,form:{}}),children:`编辑`}),s&&(0,D.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,D.jsx)(f,{}),onClick:()=>R(t)})]})}],dataSource:I,rowKey:`name`,loading:F.loading,pagination:{pageSize:20},toolbar:(0,D.jsx)(i,{prefix:(0,D.jsx)(c,{}),value:k,onChange:A,placeholder:`搜索角色名称`,style:{width:260}})})]}),(0,D.jsx)(y,{title:j?.role?`编辑角色`:`新建角色`,visible:!!j,onCancel:()=>M(null),onOk:L,confirmLoading:N,width:760,children:(0,D.jsxs)(u,{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)(u.Input,{field:`name`,label:`角色名称`,rules:[{required:!0,message:`请输入角色名称`}]}),(0,D.jsx)(u.Input,{field:`description`,label:`描述`}),(0,D.jsx)(u.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::toolName`}),(0,D.jsx)(u.TextArea,{field:`user_prompt`,label:`用户提示词(追加到用户消息前)`,autosize:{minRows:6,maxRows:18}}),(0,D.jsx)(u.Slot,{label:`启用`,children:(0,D.jsx)(u.Switch,{field:`enabled`})})]})},j?.role?.name||`new-role`)]})}export{k 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{I as t,P as n,St as r,U as i,it as a}from"./semi-BX8ib3Fq.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-CiI19B2v.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)(t,{icon:(0,b.jsx)(a,{}),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)(r,{}),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{F as t,L as n,W as r,ot as i,wt as a}from"./semi-DCiGoqD2.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-Dsnqqq1H.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)(t,{children:[(0,b.jsx)(n,{icon:(0,b.jsx)(i,{}),onClick:()=>S.reload(),loading:S.loading,children:`刷新`}),y&&(0,b.jsx)(n,{type:`danger`,theme:`light`,onClick:D,children:`清空全部统计`})]})}),(0,b.jsx)(d,{columns:4,metrics:[{id:`skills`,label:`技能总数`,value:o(S.data?.total_skills||0),loading:S.loading},{id:`calls`,label:`调用总数`,value:o(w),loading:S.loading},{id:`success`,label:`成功次数`,value:o(T),loading:S.loading},{id:`rate`,label:`成功率`,value:E===null?`—`:l(E),tone:E!==null&&E<.8?`warning`:`success`,loading:S.loading}]}),(0,b.jsxs)(m,{title:`按技能统计`,children:[(0,b.jsx)(p,{error:S.error,onRetry:()=>S.reload()}),(0,b.jsx)(g,{columns:[{title:`技能`,dataIndex:`skill_name`,render:e=>(0,b.jsx)(x,{strong:!0,children:e})},{title:`调用次数`,dataIndex:`total_calls`,width:120,render:e=>o(e||0)},{title:`成功`,dataIndex:`success_calls`,width:100,render:e=>o(e||0)},{title:`失败`,dataIndex:`failed_calls`,width:100,render:e=>Number(e)>0?(0,b.jsx)(x,{type:`danger`,children:o(e)}):`0`},{title:`最后调用`,dataIndex:`last_call_time`,width:180,render:e=>e||`—`},{title:`操作`,width:110,render:(e,t)=>y&&Number(t.total_calls)>0?(0,b.jsx)(n,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,b.jsx)(a,{}),onClick:()=>O(t.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
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,10 +18,10 @@
|
|||
} catch (error) { /* first paint fallback */ }
|
||||
})();
|
||||
</script>
|
||||
<script type="module" crossorigin src="/static/app/assets/index-CiI19B2v.js"></script>
|
||||
<script type="module" crossorigin src="/static/app/assets/index-Dsnqqq1H.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-BX8ib3Fq.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/app/assets/semi-DCiGoqD2.js">
|
||||
<link rel="stylesheet" crossorigin href="/static/app/assets/semi-BUXPdXzR.css">
|
||||
<link rel="stylesheet" crossorigin href="/static/app/assets/index-bMuhvPYI.css">
|
||||
</head>
|
||||
|
|
|
|||
|
|
@ -963,6 +963,14 @@
|
|||
"reasoningModeOn": "تشغيل",
|
||||
"reasoningModeAuto": "تلقائي",
|
||||
"reasoningEffortUnset": "غير محدَّد",
|
||||
"reasoningReset": "إعادة ضبط إعدادات الاستدلال",
|
||||
"reasoningEffortLabels": {
|
||||
"low": "منخفض",
|
||||
"medium": "متوسط",
|
||||
"high": "عالٍ",
|
||||
"xhigh": "عالٍ جدًا",
|
||||
"max": "أقصى"
|
||||
},
|
||||
"reasoningCompactLabel": "الاستدلال",
|
||||
"reasoningCompactAria": "فتح خيارات استدلال النموذج",
|
||||
"reasoningPanelTitle": "استدلال النموذج",
|
||||
|
|
|
|||
|
|
@ -964,6 +964,14 @@
|
|||
"reasoningModeOn": "On",
|
||||
"reasoningModeAuto": "Auto",
|
||||
"reasoningEffortUnset": "Unspecified",
|
||||
"reasoningReset": "Reset reasoning settings",
|
||||
"reasoningEffortLabels": {
|
||||
"low": "Low",
|
||||
"medium": "Medium",
|
||||
"high": "High",
|
||||
"xhigh": "Extra high",
|
||||
"max": "Maximum"
|
||||
},
|
||||
"reasoningCompactLabel": "Reasoning",
|
||||
"reasoningCompactAria": "Open model reasoning options",
|
||||
"reasoningPanelTitle": "Model reasoning",
|
||||
|
|
|
|||
|
|
@ -976,6 +976,14 @@
|
|||
"reasoningModeOn": "Вкл.",
|
||||
"reasoningModeAuto": "Авто",
|
||||
"reasoningEffortUnset": "Не задано",
|
||||
"reasoningReset": "Сбросить настройки рассуждения",
|
||||
"reasoningEffortLabels": {
|
||||
"low": "Низкая",
|
||||
"medium": "Средняя",
|
||||
"high": "Высокая",
|
||||
"xhigh": "Очень высокая",
|
||||
"max": "Максимальная"
|
||||
},
|
||||
"reasoningCompactLabel": "Рассуждение",
|
||||
"reasoningCompactAria": "Открыть параметры рассуждения модели",
|
||||
"reasoningPanelTitle": "Рассуждение модели",
|
||||
|
|
|
|||
|
|
@ -952,6 +952,14 @@
|
|||
"reasoningModeOn": "开启",
|
||||
"reasoningModeAuto": "自动",
|
||||
"reasoningEffortUnset": "不指定",
|
||||
"reasoningReset": "重置推理设置",
|
||||
"reasoningEffortLabels": {
|
||||
"low": "低",
|
||||
"medium": "中",
|
||||
"high": "高",
|
||||
"xhigh": "超高",
|
||||
"max": "最高"
|
||||
},
|
||||
"reasoningCompactLabel": "推理",
|
||||
"reasoningCompactAria": "打开模型推理选项",
|
||||
"reasoningPanelTitle": "模型推理",
|
||||
|
|
|
|||
Loading…
Reference in New Issue