fix: restore session collaboration and refine workspace UI

This commit is contained in:
Sycun 2026-11-19 13:06:42 +08:00
parent 4351c95000
commit 7320cc608a
66 changed files with 808 additions and 277 deletions

View File

@ -66,7 +66,7 @@ func (db *DB) CreateConversationWithWebshell(webshellConnectionID, title string,
var err error
exec := db.Exec
var tx *sql.Tx
if meta.HumanApprovalTimeoutSeconds != nil {
if meta.HITL != nil {
tx, err = db.Begin()
if err != nil {
return nil, err
@ -101,8 +101,8 @@ func (db *DB) CreateConversationWithWebshell(webshellConnectionID, title string,
return nil, fmt.Errorf("创建对话失败: %w", err)
}
if tx != nil {
if err := requireConversationHumanApproval(tx.Exec, id, *meta.HumanApprovalTimeoutSeconds, now); err != nil {
return nil, fmt.Errorf("保存人工审批失败: %w", err)
if err := saveConversationHITLConfig(tx.Exec, id, *meta.HITL, now); err != nil {
return nil, fmt.Errorf("保存人机协同配置失败: %w", err)
}
if err := tx.Commit(); err != nil {
return nil, err
@ -125,6 +125,38 @@ func (db *DB) CreateConversationWithWebshell(webshellConnectionID, title string,
return conv, nil
}
func saveConversationHITLConfig(exec func(string, ...any) (sql.Result, error), conversationID string, config ConversationHITLConfig, now time.Time) error {
if !config.Enabled {
config.Mode = "off"
}
if config.Reviewer == "" {
config.Reviewer = "human"
}
if config.TimeoutSeconds < 0 {
config.TimeoutSeconds = 0
}
tools := config.SensitiveTools
if tools == nil {
tools = []string{}
}
toolsJSON, err := json.Marshal(tools)
if err != nil {
return err
}
result, err := exec(`INSERT INTO hitl_conversation_configs
(conversation_id, enabled, mode, reviewer, sensitive_tools, timeout_seconds, updated_at)
SELECT id, ?, ?, ?, ?, ?, ? FROM conversations WHERE id=?`,
boolToInt(config.Enabled), config.Mode, config.Reviewer, string(toolsJSON), config.TimeoutSeconds, now, conversationID)
if err != nil {
return err
}
affected, err := result.RowsAffected()
if err == nil && affected == 0 {
return sql.ErrNoRows
}
return err
}
// RequireConversationHumanApproval updates the mode and reviewer while preserving
// any existing session-specific timeout and tool exemptions.
func (db *DB) RequireConversationHumanApproval(conversationID string, defaultTimeout int) error {

View File

@ -1,15 +1,24 @@
package database
// ConversationHITLConfig is the session policy saved atomically with a new conversation.
type ConversationHITLConfig struct {
Enabled bool
Mode string
Reviewer string
SensitiveTools []string
TimeoutSeconds int
}
// ConversationCreateMeta describes how a conversation was created (for audit hooks).
type ConversationCreateMeta struct {
Source string
WebShellConnectionID string
ProjectID string
RoleName string
AgentMode string
ClientIP string
SessionHint string
HumanApprovalTimeoutSeconds *int
Source string
WebShellConnectionID string
ProjectID string
RoleName string
AgentMode string
ClientIP string
SessionHint string
HITL *ConversationHITLConfig
}
// ConversationCreateHook is invoked after a conversation row is inserted.

View File

@ -55,6 +55,28 @@ func TestConversationHumanApproval(t *testing.T) {
}
})
t.Run("new conversation saves the complete session policy", func(t *testing.T) {
ctx, _ := gin.CreateTestContext(httptest.NewRecorder())
ctx.Request = httptest.NewRequest(http.MethodPost, "/api/agent/stream", nil)
ctx.Set(security.ContextSessionKey, session)
req := &ChatRequest{Message: "Review edit policy fixture", Hitl: &HITLRequest{
Enabled: true, Mode: "review_edit", Reviewer: "audit_agent",
SensitiveTools: []string{"fixture_read_only"}, TimeoutSeconds: 120,
}}
prep, err := h.prepareMultiAgentSession(req, ctx, "agent_stream")
if err != nil {
t.Fatal(err)
}
saved, err := h.hitlManager.LoadConversationConfig(prep.ConversationID)
if err != nil {
t.Fatal(err)
}
if !saved.Enabled || saved.Mode != "review_edit" || saved.Reviewer != "audit_agent" ||
saved.TimeoutSeconds != 120 || !slices.Equal(saved.SensitiveTools, req.Hitl.SensitiveTools) {
t.Fatalf("unexpected saved session policy: %+v", saved)
}
})
t.Run("existing conversation saves human approval and retains its settings", func(t *testing.T) {
conv, err := db.CreateConversation("Existing conversation", database.ConversationCreateMeta{})
if err != nil {

View File

@ -45,15 +45,15 @@ func (h *AgentHandler) prepareMultiAgentSession(req *ChatRequest, c *gin.Context
if !hasSession || !session.Permissions["chat:write"] {
return nil, fmt.Errorf("无权写入对话")
}
if req.RequireHumanApproval {
if req.RequireHumanApproval || (conversationID == "" && req.Hitl != nil) {
if !session.Permissions["hitl:write"] {
return nil, fmt.Errorf("无权访问人机协同设置")
}
if conversationID != "" {
if req.RequireHumanApproval && conversationID != "" {
return nil, fmt.Errorf("已有对话请先保存人机协同设置")
}
if h.hitlManager == nil {
return nil, fmt.Errorf("保存人工审批失败: 人机协同不可用")
return nil, fmt.Errorf("保存人机协同配置失败: 人机协同不可用")
}
}
canAccess := func(resourceType, resourceID string) bool {
@ -79,9 +79,23 @@ func (h *AgentHandler) prepareMultiAgentSession(req *ChatRequest, c *gin.Context
meta.AgentMode = chatRequestAgentMode(req, source)
if req.RequireHumanApproval {
timeout := h.hitlEffectiveDefaultTimeoutSeconds()
meta.HumanApprovalTimeoutSeconds = &timeout
req.Hitl = &HITLRequest{Enabled: true, Mode: "approval", Reviewer: "human", TimeoutSeconds: timeout}
}
if req.Hitl != nil {
req.Hitl.Mode = normalizeHitlMode(req.Hitl.Mode)
req.Hitl.Reviewer = normalizeHitlReviewer(req.Hitl.Reviewer)
if !req.Hitl.Enabled || req.Hitl.Mode == "off" {
req.Hitl.Enabled = false
req.Hitl.Mode = "off"
}
if req.Hitl.TimeoutSeconds < 0 {
req.Hitl.TimeoutSeconds = 0
}
meta.HITL = &database.ConversationHITLConfig{
Enabled: req.Hitl.Enabled, Mode: req.Hitl.Mode, Reviewer: req.Hitl.Reviewer,
SensitiveTools: req.Hitl.SensitiveTools, TimeoutSeconds: req.Hitl.TimeoutSeconds,
}
}
if webshellID != "" {
meta.Source = source + "_webshell"
meta.WebShellConnectionID = webshellID

View File

@ -432,14 +432,14 @@ func (h *NotificationHandler) summarizeLongRunningTasks(threshold time.Duration,
}
if now.Sub(t.StartedAt) >= threshold {
items = append(items, NotificationSummaryItem{
ID: "task_long:" + t.ConversationID,
ID: "task_long:" + t.RunID,
Level: "p1",
Type: "long_running_tasks",
Title: i18nText(english, "长时间运行任务", "Long Running Task"),
Desc: i18nText(english, "会话 "+t.ConversationID+" 运行超过 15 分钟", "Conversation "+t.ConversationID+" has been running over 15 minutes"),
Ts: t.StartedAt.UTC().Format(time.RFC3339),
Count: 1,
Actionable: true,
Actionable: false,
Read: false,
ConversationID: t.ConversationID,
})
@ -616,6 +616,7 @@ func normalizeMarkableEventID(id string) (string, bool) {
allowedPrefixes := []string{
"vuln:",
"exec_failed:",
"task_long:",
"task_completed:",
"c2evt:",
}

View File

@ -2,10 +2,12 @@ package handler
import (
"bytes"
"encoding/json"
"net/http"
"net/http/httptest"
"path/filepath"
"testing"
"time"
"cyberstrike-ai/internal/database"
"cyberstrike-ai/internal/security"
@ -43,3 +45,106 @@ func TestNotificationReadStateIsPerUser(t *testing.T) {
t.Fatalf("u2 inherited u1 read state = %#v, err=%v", u2, err)
}
}
func TestLongRunningNotificationCanBeMarkedRead(t *testing.T) {
db, err := database.NewDB(filepath.Join(t.TempDir(), "notifications.db"), zap.NewNop())
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = db.Close() })
const conversationID = "conversation-1"
if _, err := db.Exec(`
INSERT INTO hitl_interrupts (id, conversation_id, mode, tool_name, status, created_at)
VALUES ('approval-1', ?, 'approval', 'fixture', 'pending', CURRENT_TIMESTAMP)
`, conversationID); err != nil {
t.Fatal(err)
}
tasks := NewAgentTaskManager()
t.Cleanup(tasks.Shutdown)
startLongRun := func() *AgentTask {
t.Helper()
task, err := tasks.StartTask(conversationID, "fixture", nil)
if err != nil {
t.Fatal(err)
}
tasks.mu.Lock()
task.StartedAt = time.Now().Add(-16 * time.Minute)
tasks.mu.Unlock()
return task
}
first := startLongRun()
h := NewNotificationHandler(db, &AgentHandler{tasks: tasks}, zap.NewNop())
router := gin.New()
router.Use(func(c *gin.Context) {
c.Set(security.ContextSessionKey, security.Session{
UserID: c.GetHeader("X-Test-User"), Scope: database.RBACScopeAll,
Permissions: map[string]bool{"tasks:read": true, "hitl:read": true},
})
})
router.GET("/notifications/summary", h.GetSummary)
router.POST("/notifications/read", h.MarkRead)
request := func(method, path, userID string, body []byte) []byte {
t.Helper()
req := httptest.NewRequest(method, path, bytes.NewReader(body))
req.Header.Set("X-Test-User", userID)
req.Header.Set("Content-Type", "application/json")
w := httptest.NewRecorder()
router.ServeHTTP(w, req)
if w.Code != http.StatusOK {
t.Fatalf("%s %s status = %d: %s", method, path, w.Code, w.Body.String())
}
return w.Body.Bytes()
}
summary := func(userID string) NotificationSummaryResponse {
t.Helper()
var result NotificationSummaryResponse
if err := json.Unmarshal(request(http.MethodGet, "/notifications/summary", userID, nil), &result); err != nil {
t.Fatal(err)
}
return result
}
longRunningID := func(result NotificationSummaryResponse) string {
for _, item := range result.Items {
if item.Type == "long_running_tasks" && item.ConversationID == conversationID {
return item.ID
}
}
return ""
}
before := summary("u1")
id := longRunningID(before)
if id == "" || before.UnreadCount != 2 {
t.Fatalf("expected a long-running and an approval notification, got %+v", before)
}
body, err := json.Marshal(markReadRequest{EventIDs: []string{id, "hitl:approval-1"}})
if err != nil {
t.Fatal(err)
}
var marked struct {
Marked int `json:"marked"`
}
if err := json.Unmarshal(request(http.MethodPost, "/notifications/read", "u1", body), &marked); err != nil {
t.Fatal(err)
}
if marked.Marked != 1 {
t.Fatalf("marked = %d, want only the long-running notification marked", marked.Marked)
}
after := summary("u1")
if after.UnreadCount != 1 || len(after.Items) != 1 || after.Items[0].Type != "hitl_pending" || after.Counts["longRunningTasks"] != 1 {
t.Fatalf("expected only the approval notification while the task keeps running, got %+v", after)
}
if otherID := longRunningID(summary("u2")); otherID != id {
t.Fatalf("other user saw notification %q, want %q", otherID, id)
}
if err := tasks.FinishTaskRun(conversationID, first.RunID, "completed"); err != nil {
t.Fatal(err)
}
startLongRun()
if nextID := longRunningID(summary("u1")); nextID == "" || nextID == id {
t.Fatalf("new run must have a new notification, got %q after %q", nextID, id)
}
}

View File

@ -16,6 +16,10 @@ import { formatDateTime } from '../lib/format';
import { useInterval } from '../components/hooks';
const { Text } = Typography;
const sidebarSubmenuProps = {
position: 'right',
contentClassName: 'cs-nav-flyout'
};
function useIsMobile() {
const [mobile, setMobile] = useState(() => window.matchMedia('(max-width: 900px)').matches);
@ -303,6 +307,7 @@ export default function AppLayout() {
selectedKeys={selectedKeys}
onSelect={onSelect}
isCollapsed={compact}
subDropdownProps={sidebarSubmenuProps}
openKeys={openKeys}
onOpenChange={({ openKeys: keys }) => setOpenKeys(keys)}
/>

View File

@ -1,5 +1,5 @@
import { useId, useState } from 'react';
import { Button, Select, SideSheet, Spin, Tag, Typography } from '@douyinfe/semi-ui';
import { useEffect, useId, useRef, useState } from 'react';
import { RadioGroup, Select, SideSheet, Spin, TextArea, Typography } from '@douyinfe/semi-ui';
import { useResource } from '../../components/hooks';
import { ErrorBanner, toastError } from '../../components/ui';
import { api } from '../../lib/http';
@ -8,6 +8,69 @@ import { modelChannelName, modelChannelOptions, selectedModelChannelName } from
import { REASONING_EFFORTS, REASONING_MODES } from './useModelPreferences';
const { Text } = Typography;
const HITL_MODES = ['off', 'approval', 'review_edit'];
const HITL_TIMEOUTS = [60, 300, 600, 0];
const DEFAULT_HITL_SESSION_TOOL_WHITELIST = 'tool_search, skill, task, write_todos, transfer_to_agent, exit, TaskCreate, TaskGet, TaskUpdate, TaskList, upsert_project_fact, get_project_fact';
function normalizeMode(mode, enabled) {
if (enabled === false) return 'off';
return HITL_MODES.includes(mode) ? mode : 'off';
}
function normalizeReviewer(reviewer) {
return reviewer === 'audit_agent' ? 'audit_agent' : 'human';
}
function normalizeTimeout(value, fallback = 300) {
if (value === undefined || value === null || value === '') return fallback;
const parsed = Number(value);
if (!Number.isFinite(parsed)) return fallback;
return Math.max(0, Math.min(86400, Math.round(parsed)));
}
function splitTools(value) {
const tools = Array.isArray(value) ? value : String(value || '').split(/[,\n\r]+/);
return tools.map(tool => String(tool || '').trim()).filter(Boolean);
}
function sessionToolsForDisplay(value, globalTools) {
const global = new Set(splitTools(globalTools).map(tool => tool.toLowerCase()));
return splitTools(value).filter(tool => !global.has(tool.toLowerCase())).join(', ');
}
function formFromConfig(data, conversationId, draft) {
if (draft) {
return {
mode: normalizeMode(draft.mode, draft.enabled),
reviewer: normalizeReviewer(draft.reviewer),
timeoutSeconds: normalizeTimeout(draft.timeoutSeconds),
sensitiveTools: splitTools(draft.sensitiveTools).join(', ')
};
}
const stored = conversationId ? data?.hitl : null;
return {
mode: conversationId
? normalizeMode(stored?.mode, stored?.enabled)
: normalizeMode(data?.defaultMode),
reviewer: normalizeReviewer(conversationId ? stored?.reviewer : data?.defaultReviewer),
timeoutSeconds: normalizeTimeout(conversationId
? stored?.timeoutSeconds ?? data?.defaultTimeoutSeconds
: data?.defaultTimeoutSeconds),
sensitiveTools: conversationId
? sessionToolsForDisplay(stored?.sensitiveTools, data?.hitlGlobalToolWhitelist)
: DEFAULT_HITL_SESSION_TOOL_WHITELIST
};
}
function requestFromForm(form) {
return {
enabled: form.mode !== 'off',
mode: form.mode,
reviewer: form.reviewer,
sensitiveTools: splitTools(form.sensitiveTools),
timeoutSeconds: form.timeoutSeconds
};
}
function SettingSelect({ label, ...props }) {
const id = useId();
@ -21,31 +84,31 @@ function SettingSelect({ label, ...props }) {
export default function ChatSettings({
onClose, narrow, busy, canReadConfig, canReadHitl, canEnableHitl,
model, conversationId, draftApproval, onEnableDraftApproval
model, conversationId, draftHitl, onDraftHitlChange
}) {
const t = useT();
const [saving, setSaving] = useState(false);
const [saved, setSaved] = useState(false);
const [form, setForm] = useState(null);
const [toolsDirty, setToolsDirty] = useState(false);
const saveSequence = useRef(0);
const draftRef = useRef(draftHitl);
const reviewerId = useId();
const toolsId = useId();
draftRef.current = draftHitl;
const approvals = useResource(
() => api.get(conversationId ? `/hitl/config/${encodeURIComponent(conversationId)}` : '/hitl/default-config'),
[conversationId, canReadHitl],
{ skip: !canReadHitl }
);
const approvalMode = draftApproval ? 'approval' : (conversationId
? (approvals.data?.hitl?.enabled ? approvals.data.hitl.mode : 'off')
: approvals.data?.defaultMode);
const approvalActive = approvalMode === 'approval' || approvalMode === 'review_edit';
const reviewer = draftApproval ? 'human' : (conversationId
? approvals.data?.hitl?.reviewer
: approvals.data?.defaultReviewer);
const usesAuditAgent = reviewer === 'audit_agent';
const canSelectHuman = canEnableHitl && approvals.data?.conversationHumanApproval && !draftApproval
&& (!conversationId || approvalMode !== 'approval' || reviewer !== 'human');
const approvalLabel = approvalMode === 'review_edit'
? t('chat.hitlModeReviewEdit', null, '审查编辑')
: t('chat.hitlModeApproval', null, '审批模式');
const reviewerLabel = usesAuditAgent
? t('chat.hitlReviewerAgent', null, '审计 Agent')
: t('chat.hitlReviewerHuman', null, '人工审批');
useEffect(() => {
if (!approvals.data) return;
setForm(formFromConfig(approvals.data, conversationId, draftRef.current));
setToolsDirty(false);
}, [approvals.data, conversationId]);
const defaultId = model.config.data?.default_channel;
const defaultName = defaultId ? modelChannelName(defaultId, model.config.data?.channels?.[defaultId]) : '';
const defaultLabel = t('chat.aiChannelDefault', null, '跟随默认通道');
@ -59,23 +122,69 @@ export default function ChatSettings({
on: t('chat.reasoningModeOn', null, '开启'),
auto: t('chat.reasoningModeAuto', null, '自动')
};
const modeLabels = {
off: t('chat.hitlModeOff', null, '关闭'),
approval: t('chat.hitlModeApproval', null, '审批模式'),
review_edit: t('chat.hitlModeReviewEdit', null, '审查编辑')
};
const timeoutLabels = {
60: t('chat.hitlTimeoutOneMinute', null, '1 分钟'),
300: t('chat.hitlTimeoutFiveMinutes', null, '5 分钟'),
600: t('chat.hitlTimeoutTenMinutes', null, '10 分钟'),
0: t('chat.hitlTimeoutUnlimited', null, '不限制')
};
const timeoutOptions = HITL_TIMEOUTS.map(value => ({ value, label: timeoutLabels[value] }));
if (form && !HITL_TIMEOUTS.includes(form.timeoutSeconds)) {
timeoutOptions.unshift({ value: form.timeoutSeconds, label: `${form.timeoutSeconds}s` });
}
const hitlDisabled = !canEnableHitl || saving;
const enableApproval = async () => {
if (!conversationId) {
onEnableDraftApproval();
return;
}
const persist = async next => {
const sequence = ++saveSequence.current;
const hitl = requestFromForm(next);
setSaving(true);
setSaved(false);
try {
const saved = await api.put(`/hitl/config/${encodeURIComponent(conversationId)}/human-approval`);
approvals.setData(current => ({ ...current, hitl: saved.hitl }));
await api.put('/hitl/config', { conversationId, ...hitl });
if (sequence !== saveSequence.current) return;
approvals.setData(current => ({ ...current, hitl }));
setSaved(true);
} catch (error) {
toastError(error, t('chat.hitlApplyFail', null, '同步到服务器失败'));
if (sequence === saveSequence.current) {
toastError(error, t('chat.hitlApplyFail', null, '同步到服务器失败'));
approvals.reload({ silent: true });
}
} finally {
setSaving(false);
if (sequence === saveSequence.current) setSaving(false);
}
};
const updateConfig = patch => {
const next = { ...form, ...patch };
setForm(next);
setToolsDirty(false);
setSaved(false);
if (conversationId) {
void persist(next);
} else {
onDraftHitlChange(requestFromForm(next));
}
};
const updateTools = value => {
const next = { ...form, sensitiveTools: value };
setForm(next);
setToolsDirty(true);
setSaved(false);
if (!conversationId) onDraftHitlChange(requestFromForm(next));
};
const saveTools = () => {
if (!toolsDirty || !conversationId || hitlDisabled) return;
setToolsDirty(false);
void persist(form);
};
return (
<SideSheet
visible
@ -119,32 +228,71 @@ export default function ChatSettings({
disabled={busy || model.mode === 'off'}
/>
{canReadHitl && (
<section className="chat-setting-field">
<section className="chat-setting-field chat-setting-hitl">
<Text strong>{t('chat.hitlTitle', null, '人机协同')}</Text>
<Text type="tertiary" size="small">
{t('chat.sessionSettingsHint', null, '人机协同设置只影响后续消息。')}
</Text>
{(saving || saved) && (
<Text type="tertiary" size="small" role="status">
{saving
? t('chat.systemModelSaving', null, '正在保存…')
: t('chat.hitlApplyOkSync', null, '人机协同配置已保存并同步到服务器。')}
</Text>
)}
<ErrorBanner error={approvals.error} onRetry={() => approvals.reload()} />
{approvals.loading && <Spin />}
{approvals.data && !approvals.error && (
{form && approvals.data && !approvals.error && (
<>
<div className="chat-setting-approval">
<Tag color={approvalActive ? 'green' : 'grey'}>
{approvalActive ? approvalLabel : t('chat.hitlModeOff', null, '关闭')}
</Tag>
{approvalActive && reviewer && (
<Text type="secondary">
{t('chat.hitlCurrentReviewer', { reviewer: reviewerLabel }, '审批方 · {{reviewer}}')}
</Text>
)}
</div>
{draftApproval && (
<SettingSelect
label={t('chat.hitlModeLabel', null, '模式')}
value={form.mode}
optionList={HITL_MODES.map(value => ({ value, label: modeLabels[value] }))}
onSelect={value => updateConfig({ mode: value })}
disabled={hitlDisabled}
/>
<div className="chat-setting-field">
<Text id={reviewerId} strong>{t('chat.hitlReviewerLabel', null, '审批方')}</Text>
<RadioGroup
aria-labelledby={reviewerId}
type="button"
className="chat-setting-reviewer"
value={form.reviewer}
options={[
{ value: 'human', label: t('chat.hitlReviewerHuman', null, '人工审批') },
{ value: 'audit_agent', label: t('chat.hitlReviewerAgent', null, '审计 Agent') }
]}
onChange={event => updateConfig({ reviewer: event.target.value })}
disabled={hitlDisabled}
/>
<Text type="tertiary" size="small">
{t('chat.hitlConversationApprovalPending', null, '发送后将为此会话保存人工审批。')}
{t('chat.hitlReviewerHint', null, '可在人工与审计 Agent 之间随时切换;规则与白名单不变。人机协同为「关闭」时也可预先选择。')}
</Text>
)}
{canSelectHuman && (
<Button disabled={busy || saving} loading={saving} onClick={enableApproval}>
{t('chat.hitlRequireHumanForConversation', null, '此会话使用人工审批')}
</Button>
)}
</div>
<SettingSelect
label={t('chat.hitlTimeoutLabel', null, '审批等待时限')}
value={form.timeoutSeconds}
optionList={timeoutOptions}
onSelect={value => updateConfig({ timeoutSeconds: Number(value) })}
disabled={hitlDisabled}
/>
<div className="chat-setting-field">
<Text id={toolsId} strong>
{t('chat.hitlWhitelistTools', null, '白名单工具(免审批,逗号分隔)')}
</Text>
<TextArea
aria-labelledby={toolsId}
value={form.sensitiveTools}
placeholder={t('chat.hitlWhitelistPlaceholder', null, '例:read_file, grep 或每行一个工具名(与 config 全局白名单合并)')}
rows={5}
disabled={hitlDisabled}
onChange={updateTools}
onBlur={saveTools}
/>
<Text type="tertiary" size="small">
{t('chat.hitlWhitelistHint', null, '白名单内工具免审批;每行一个或逗号分隔,与 config 全局白名单合并。')}
</Text>
</div>
</>
)}
</section>

View File

@ -140,7 +140,7 @@ export default function ConversationList({
<div className="chat-sidebar-inner">
<div className="chat-sidebar-head">
<Text strong className="chat-sidebar-title">{t('chat.conversations', null, '会话')}</Text>
<Button icon={<IconPlus />} theme="solid" onClick={onCreate} disabled={!canWrite}>
<Button icon={<IconPlus />} theme="borderless" className="chat-new-chat" onClick={onCreate} disabled={!canWrite}>
{t('chat.newChat', null, '新建对话')}
</Button>
</div>

View File

@ -1,7 +1,7 @@
/** 消息区:历史消息 + 当前流式输出,自动贴底滚动。 */
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { Avatar, Button, Empty, Space, Spin, Tag, Tooltip, Typography } from '@douyinfe/semi-ui';
import { IconArrowDown, IconComment, IconDelete, IconPaperclip, IconRefresh, IconShield, IconUser } from '@douyinfe/semi-icons';
import { Avatar, Button, Empty, Spin, Tag, Tooltip, Typography } from '@douyinfe/semi-ui';
import { IconArrowDown, IconComment, IconDelete, IconRefresh, IconUser } from '@douyinfe/semi-icons';
import { CopyButton, ErrorBanner } from '../../components/ui';
import { useT } from '../../lib/i18n';
import { formatDateTime } from '../../lib/format';
@ -14,7 +14,6 @@ function ChatWelcome() {
const t = useT();
return (
<div className="chat-welcome">
<Text type="tertiary" className="chat-welcome-brand">CyberStrikeAI</Text>
<Empty
image={<span className="chat-welcome-mark" aria-hidden="true"><IconComment size="extra-large" /></span>}
title={t('chat.welcomeHeading', null, '让安全探索,从对话开始')}
@ -23,16 +22,7 @@ function ChatWelcome() {
{t('chat.welcomeScopeDescription', null, '描述测试目标与授权范围,或上传相关材料,即可开始对话。')}
</Paragraph>
)}
>
<Space spacing={8} wrap className="chat-welcome-tags">
<Tag size="large" type="light" color="blue" prefixIcon={<IconShield />}>
{t('chat.welcomeScopeTag', null, '明确授权范围')}
</Tag>
<Tag size="large" type="light" color="grey" prefixIcon={<IconPaperclip />}>
{t('chat.welcomeMaterialsTag', null, '附上相关材料')}
</Tag>
</Space>
</Empty>
/>
</div>
);
}

View File

@ -71,7 +71,7 @@ export default function Page() {
const mode = AGENT_MODES.includes(storedMode) ? storedMode : 'single';
const model = useModelPreferences(canReadConfig);
const [settingsOpen, setSettingsOpen] = useState(false);
const [draftApproval, setDraftApproval] = useState(false);
const [draftHitl, setDraftHitl] = useState(null);
const [detail, setDetail] = useState(EMPTY_DETAIL);
const [composers, setComposers] = useState(() => new Map());
@ -185,7 +185,7 @@ export default function Page() {
}, []);
const bindConversation = useCallback(id => {
setDraftApproval(false);
setDraftHitl(null);
boundByRun.current = id;
conversationRef.current = id;
setSearchParams({ conversation: id }, { replace: true });
@ -403,9 +403,9 @@ export default function Page() {
mode,
projectId: newProjectId,
...model.request,
requireHumanApproval: !conversationId && draftApproval
hitl: !conversationId && canDecideHitl ? draftHitl || undefined : undefined
});
}, [attachments, backgroundRunning, canWrite, canExecute, checkingRun, conversationId, draft, draftApproval, mode, model, newProjectId, resetRun, run, sending, t, updateComposer]);
}, [attachments, backgroundRunning, canWrite, canExecute, canDecideHitl, checkingRun, conversationId, draft, draftHitl, mode, model, newProjectId, resetRun, run, sending, t, updateComposer]);
const conversation = detail.conversation;
@ -549,8 +549,8 @@ export default function Page() {
canEnableHitl={canDecideHitl}
model={model}
conversationId={conversationId}
draftApproval={!conversationId && draftApproval}
onEnableDraftApproval={() => setDraftApproval(true)}
draftHitl={!conversationId ? draftHitl : null}
onDraftHitlChange={setDraftHitl}
/>
)}
<SideSheet

View File

@ -2,7 +2,7 @@
.chat-page {
display: flex;
gap: 20px;
gap: 0;
height: 100%;
min-width: 0;
min-height: 0;
@ -11,12 +11,11 @@
/* ---------- 会话栏 ---------- */
.chat-sidebar {
flex: 0 0 296px;
width: 296px;
flex: 0 0 272px;
width: 272px;
min-height: 0;
display: flex;
border: 1px solid var(--semi-color-border);
border-radius: 12px;
border-right: 1px solid var(--semi-color-border);
background: var(--semi-color-bg-1);
overflow: hidden;
}
@ -39,11 +38,12 @@
gap: 8px;
flex-wrap: wrap;
}
.chat-sidebar-head { padding: 20px 16px 16px; }
.chat-sidebar-title { font-size: 16px; }
.chat-sidebar-filters { display: flex; flex-direction: column; gap: 10px; padding: 0 16px 20px; }
.chat-sidebar-head { padding: 16px 12px 8px; }
.chat-sidebar-title { font-size: 15px; }
.chat-new-chat { padding-inline: 8px; }
.chat-sidebar-filters { display: flex; flex-direction: column; gap: 8px; padding: 0 12px 12px; }
.chat-sidebar-project { width: 100%; min-width: 0; }
.chat-sidebar-tools { padding: 0 16px 10px; }
.chat-sidebar-tools { padding: 0 12px 8px; }
.chat-sidebar-tools-actions { display: flex; align-items: center; gap: 4px; }
.chat-sidebar-empty { padding: 32px 12px; }
@ -75,8 +75,8 @@
align-items: center;
gap: 4px;
min-width: 0;
border-radius: 12px;
padding: 4px 6px;
border-radius: 8px;
padding: 2px 4px;
transition: background-color .15s ease;
}
.chat-conv-item:hover,
@ -90,8 +90,8 @@
min-width: 0;
display: flex;
flex-direction: column;
gap: 6px;
padding: 10px 6px;
gap: 2px;
padding: 8px 6px;
background: none;
border: none;
border-radius: 8px;
@ -121,19 +121,17 @@
}
.chat-main { container: chat-workspace / inline-size; }
.chat-panel {
--chat-content-width: 960px;
--chat-content-inset: 20px;
border: 1px solid var(--semi-color-border);
border-radius: 12px;
background: var(--semi-color-bg-1);
--chat-content-width: 840px;
--chat-content-inset: 24px;
background: transparent;
overflow: hidden;
}
.chat-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; padding: 0 0 20px; flex: 0 0 auto; }
.chat-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding: 0 4px 12px; flex: 0 0 auto; }
.chat-header-main { flex: 1 1 300px; min-width: 0; }
.chat-header-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.chat-header-title.semi-typography { margin: 0; font-size: 22px; line-height: 1.4; letter-spacing: -.4px; max-width: 100%; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chat-header-description { display: block; margin-top: 8px; line-height: 1.6; overflow-wrap: anywhere; }
.chat-header-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.chat-header-title.semi-typography { margin: 0; font-size: 18px; line-height: 1.4; letter-spacing: -.2px; max-width: 100%; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chat-header-description { display: block; margin-top: 4px; line-height: 1.5; overflow-wrap: anywhere; }
.chat-header-actions,
.chat-header-tags { min-width: 0; max-width: 100%; }
.chat-header-actions > *,
@ -160,15 +158,12 @@
.chat-messages > * { flex-shrink: 0; }
.chat-loading { display: flex; justify-content: center; padding: 24px; }
.chat-welcome { width: 100%; max-width: 600px; margin: auto; padding: 24px 0; text-align: center; }
.chat-welcome-brand { display: block; margin-bottom: 20px; font-size: 12px; font-weight: 600; letter-spacing: 1.6px; }
.chat-welcome-mark { display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 12px; color: var(--semi-color-primary); background: var(--semi-color-primary-light-default); }
.chat-welcome .semi-empty-content { min-width: 0; max-width: 100%; margin-top: 20px; }
.chat-welcome .semi-empty-title { margin: 0; font-size: clamp(22px, 2.2vw, 30px); line-height: 1.45; letter-spacing: -.5px; overflow-wrap: anywhere; }
.chat-welcome { width: 100%; max-width: 560px; margin: auto; padding: 24px 0; text-align: center; }
.chat-welcome-mark { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; color: var(--semi-color-text-2); }
.chat-welcome .semi-empty-content { min-width: 0; max-width: 100%; margin-top: 12px; }
.chat-welcome .semi-empty-title { margin: 0; font-size: clamp(24px, 2.4vw, 32px); font-weight: 500; line-height: 1.45; letter-spacing: -.5px; overflow-wrap: anywhere; }
.chat-welcome .semi-empty-title + .semi-empty-description { margin-top: 12px; }
.chat-welcome-description.semi-typography { max-width: 420px; margin: 0 auto; font-size: 14px; line-height: 1.9; overflow-wrap: anywhere; }
.chat-welcome-tags { justify-content: center; max-width: 100%; }
.chat-welcome-tags .semi-tag { max-width: 100%; }
.chat-welcome-description.semi-typography { max-width: 460px; margin: 0 auto; font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
.chat-msg { display: flex; align-items: flex-start; gap: 12px; width: 100%; max-width: var(--chat-content-width); min-width: 0; align-self: center; }
.chat-msg-user { flex-direction: row-reverse; }
@ -284,21 +279,28 @@
.chat-composer {
flex: 0 0 auto;
min-width: 0;
max-height: 60%;
max-height: 65%;
overflow-y: auto;
scrollbar-gutter: stable;
padding-block: 16px 20px;
padding-block: 12px 24px;
padding-inline: var(--chat-content-inset);
border-top: 1px solid var(--semi-color-border);
display: flex;
flex-direction: column;
gap: 12px;
}
.chat-composer:focus-within {
border-top-color: var(--semi-color-focus-border);
box-shadow: inset 0 1px var(--semi-color-focus-border);
}
.chat-composer > * { flex-shrink: 0; width: 100%; max-width: var(--chat-content-width); margin-inline: auto; }
.chat-composer-box {
padding: 14px 16px 10px;
border: 1px solid var(--semi-color-border);
border-radius: 16px;
background: var(--semi-color-bg-1);
box-shadow: var(--semi-shadow-elevated);
transition: border-color .15s ease, box-shadow .15s ease;
}
.chat-composer-box:focus-within {
border-color: var(--semi-color-focus-border);
box-shadow: 0 0 0 2px var(--semi-color-primary-light-default);
}
.chat-composer-banner { margin-bottom: 2px; }
.chat-file-list { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.chat-file-chip { max-width: 100%; }
@ -311,7 +313,7 @@
.chat-composer-box .semi-input-textarea { overflow-wrap: anywhere; }
.chat-composer-box .semi-input-textarea:focus-visible { outline: none; }
.chat-composer-box .semi-input-textarea-counter { display: none; }
.chat-composer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.chat-composer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.chat-composer-controls { flex: 1 1 360px; min-width: 0; }
.chat-composer-controls > * { min-width: 0; max-width: 100%; }
.chat-composer-select { flex: 1 1 148px; width: 148px; min-width: 0; }
@ -320,7 +322,9 @@
.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; }
.chat-setting-hitl { padding-top: 16px; border-top: 1px solid var(--semi-color-border); }
.chat-setting-reviewer { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
.chat-setting-reviewer .semi-radio-addon-buttonRadio { flex: 1; text-align: center; }
/* ---------- 侧滑面板 ---------- */
@ -393,7 +397,6 @@
.chat-panel { --chat-content-inset: 12px; }
.chat-messages { padding-block: 20px; gap: 24px; }
.chat-welcome { padding: 12px 0; }
.chat-welcome-brand { margin-bottom: 12px; }
.chat-welcome-mark { width: 48px; height: 48px; }
.chat-msg { gap: 8px; }
.chat-bubble,
@ -402,7 +405,8 @@
.chat-bubble-head { gap: 4px 8px; }
.chat-turn-body .cs-markdown,
.chat-stream-text { font-size: 14px; }
.chat-composer { padding-block: 12px; }
.chat-composer { padding-block: 8px 12px; }
.chat-composer-box { padding: 12px 12px 8px; border-radius: 14px; }
.chat-composer-box .semi-input-textarea { font-size: 16px; }
.chat-composer-controls,
.chat-composer-submit { width: 100%; }
@ -425,5 +429,6 @@
@media (prefers-reduced-motion: reduce) {
.chat-conv-item,
.chat-conv-actions,
.chat-bubble-actions { transition: none; }
.chat-bubble-actions,
.chat-composer-box { transition: none; }
}

View File

@ -69,7 +69,7 @@ export function useAgentRun({
});
}, [conversationRef, flushLive, onSettled, requestDetailReload]);
const send = useCallback(({ message, attachments, mode, projectId, aiChannelId, reasoning, requireHumanApproval }) => {
const send = useCallback(({ message, attachments, mode, projectId, aiChannelId, reasoning, hitl, requireHumanApproval }) => {
const run = { live: createLiveState({ conversationId: conversationRef.current }), markedFinished: false, abort: null };
runRef.current = run;
liveRef.current = run.live;
@ -83,6 +83,7 @@ export function useAgentRun({
conversationId: conversationRef.current || '',
aiChannelId,
reasoning,
hitl,
requireHumanApproval: requireHumanApproval || undefined
};
if (!conversationRef.current && projectId) body.projectId = projectId;

View File

@ -1,6 +1,6 @@
/** 深度测评列表:筛选、进度、新建、删除与进入工作台。 */
import { useEffect, useMemo, useState } from 'react';
import { Button, Input, Progress, Select, Space, Switch, Typography } from '@douyinfe/semi-ui';
import { Button, Input, Progress, RadioGroup, Select, Space, Typography } from '@douyinfe/semi-ui';
import { IconDelete, IconPlus, IconRefresh, IconSearch } from '@douyinfe/semi-icons';
import { api } from '../../lib/http';
import { useT } from '../../lib/i18n';
@ -199,13 +199,19 @@ export default function AssessmentList({ onOpen }) {
/>
<ErrorBanner error={resource.error} onRetry={() => resource.reload()} />
<SectionCard
className="assessment-list-card"
title={t('deepAssessments.listTitle', null, '测评列表')}
extra={(
<Switch
checked={archived}
onChange={value => setArchived(Boolean(value))}
checkedText="已归档"
uncheckedText="进行中"
<RadioGroup
className="assessment-archive-filter"
aria-label={t('deepAssessments.archiveFilter', null, '归档状态')}
type="button"
value={archived ? 'archived' : 'unarchived'}
options={[
{ value: 'unarchived', label: t('deepAssessments.unarchivedTasks', null, '未归档') },
{ value: 'archived', label: t('deepAssessments.archivedTasks', null, '已归档') }
]}
onChange={event => setArchived(event.target.value === 'archived')}
/>
)}
>

View File

@ -47,6 +47,15 @@
margin: 8px 0 0;
}
.assessment-list-card .semi-card-header {
flex-wrap: wrap;
gap: 10px;
}
.assessment-archive-filter {
white-space: nowrap;
}
.assessment-toolbar {
display: flex;
flex-wrap: wrap;

View File

@ -80,6 +80,10 @@ body[theme-mode="dark"] .semi-button-primary.semi-button-solid:not(.semi-button-
.cs-nav .semi-navigation-item-icon-info { min-width: 18px; margin-inline-end: 10px; }
.cs-nav .semi-navigation-item-sub { padding: 0; }
.cs-nav.semi-navigation-collapsed { padding-inline: 8px; }
.cs-nav-flyout .semi-dropdown-menu { max-block-size: calc(100dvh - 16px); overflow-y: auto; }
.cs-nav-flyout .semi-navigation-item { min-inline-size: 0; max-inline-size: 280px; padding-inline: 12px; }
.cs-nav-flyout .semi-navigation-item-icon-info:empty { display: none; }
.cs-nav-flyout .semi-navigation-item-text { white-space: normal; overflow-wrap: anywhere; }
.is-compact .cs-nav-section + .cs-nav-section { padding-top: 12px; border-top: 1px solid var(--semi-color-border); margin-top: 12px; }
.cs-nav-footer { padding: 10px 12px; border-top: 1px solid var(--semi-color-border); }
.cs-nav-footer .semi-button { justify-content: flex-start; font-size: 12px; }
@ -166,8 +170,23 @@ body[theme-mode="dark"] .cs-severity-tag[data-severity="critical"] { color: #fff
.cs-json-viewer-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--semi-color-fill-0); }
.cs-json-viewer-body { margin: 0; padding: 16px; max-height: 420px; overflow: auto; font-size: 12px; line-height: 1.65; font-family: "SFMono-Regular", Consolas, monospace; }
.cs-notification-panel { width: min(340px, calc(100vw - 48px)); max-height: 420px; display: flex; flex-direction: column; }
.cs-notification-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 10px; border-bottom: 1px solid var(--semi-color-border); }
.cs-notification-list { overflow: auto; display: flex; flex-direction: column; gap: 4px; padding-top: 12px; }
.cs-notification-head {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 6px 12px;
padding: 10px 16px;
border-bottom: 1px solid var(--semi-color-border);
}
.cs-notification-list {
overflow: auto;
display: flex;
flex-direction: column;
gap: 4px;
padding: 12px 8px;
text-align: center;
}
.cs-notification-item { display: flex; gap: 10px; align-items: flex-start; text-align: start; border: none; background: transparent; padding: 10px 8px; border-radius: 8px; cursor: pointer; color: inherit; }
.cs-notification-item:hover { background: var(--semi-color-fill-0); }
.cs-notification-dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 6px; background: var(--semi-color-primary); flex: 0 0 6px; }

View File

@ -83,8 +83,10 @@ test.describe('chat composer settings', () => {
await openSettings.click();
await expect(channel).toHaveText('示例通道 A');
await expect(effort).toContainText('medium');
await settings.getByRole('button', { name: label('chat.hitlRequireHumanForConversation') }).click();
await expect(settings.getByText(label('chat.hitlConversationApprovalPending'))).toBeVisible();
const collaborationMode = settings.getByRole('combobox', { name: label('chat.hitlModeLabel') });
await collaborationMode.click();
await page.getByRole('listbox').getByText(label('chat.hitlModeApproval'), { exact: true }).click();
await expect(collaborationMode).toHaveText(label('chat.hitlModeApproval'));
await settings.locator('button.semi-sidesheet-close').click();
const input = main.getByRole('textbox', { name: label('chat.composerLabel', '对话内容') });
await input.fill(message);
@ -95,38 +97,90 @@ test.describe('chat composer settings', () => {
body: {
message, conversationId: '', aiChannelId: 'demo-primary',
reasoning: { mode: 'on', effort: 'medium' },
requireHumanApproval: true
hitl: {
enabled: true, mode: 'approval', reviewer: 'human', timeoutSeconds: 120,
sensitiveTools: expect.arrayContaining(['tool_search', 'TaskCreate'])
}
}
}]);
});
test('loads an existing conversation approval status and persists human approval on demand', async ({ page, mockApi }) => {
test('restores editable session HITL controls and persists every change', async ({ page, mockApi }) => {
const path = `/api/hitl/config/${CONVERSATION.id}`;
const expected = { enabled: true, mode: 'approval', reviewer: 'human', timeoutSeconds: 90 };
let hitl = { enabled: true, mode: 'approval', reviewer: 'audit_agent', timeoutSeconds: 90 };
let hitl = {
enabled: false, mode: 'off', reviewer: 'human',
sensitiveTools: ['fixture-existing-tool'], timeoutSeconds: 90
};
mockApi.respond('GET', '/api/agent-loop/tasks', { json: { tasks: [] } });
mockApi.respond('GET', path, () => ({ json: { hitl, defaultTimeoutSeconds: 90, conversationHumanApproval: true } }));
mockApi.respond('PUT', path + '/human-approval', () => {
hitl = expected;
return { json: { hitl } };
mockApi.respond('GET', path, () => ({ json: {
hitl, defaultTimeoutSeconds: 90, hitlGlobalToolWhitelist: []
} }));
mockApi.respond('PUT', '/api/hitl/config', request => {
const { conversationId, ...config } = request.body;
hitl = config;
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.hitlRequireHumanForConversation') });
await expect(enable).toBeEnabled();
const mode = settings.getByRole('combobox', { name: label('chat.hitlModeLabel') });
const timeout = settings.getByRole('combobox', { name: label('chat.hitlTimeoutLabel') });
const human = settings.getByRole('radio', { name: label('chat.hitlReviewerHuman') });
const auditAgent = settings.getByRole('radio', { name: label('chat.hitlReviewerAgent') });
const tools = settings.getByRole('textbox', { name: label('chat.hitlWhitelistTools') });
await expect(mode).toHaveText(label('chat.hitlModeOff'));
await expect(human).toBeChecked();
await expect(timeout).toHaveText('90s');
await expect(tools).toHaveValue('fixture-existing-tool');
expect(mockApi.writes()).toEqual([]);
await enable.click();
await expect(settings.getByText(label('chat.hitlModeApproval'), { exact: true })).toBeVisible();
expect(mockApi.calls('PUT', path + '/human-approval')).toHaveLength(1);
const savedCount = async count => {
await expect.poll(() => mockApi.calls('PUT', '/api/hitl/config').length).toBe(count);
};
await mode.click();
await page.getByRole('listbox').getByText(label('chat.hitlModeApproval'), { exact: true }).click();
await savedCount(1);
await mode.click();
await page.getByRole('listbox').getByText(label('chat.hitlModeReviewEdit'), { exact: true }).click();
await savedCount(2);
await settings.getByText(label('chat.hitlReviewerAgent'), { exact: true }).click();
await savedCount(3);
await expect(auditAgent).toBeChecked();
await timeout.click();
await page.getByRole('listbox').getByText(label('chat.hitlTimeoutOneMinute'), { exact: true }).click();
await savedCount(4);
await tools.fill('fixture-read, fixture-write');
await tools.press('Tab');
await savedCount(5);
await mode.click();
await page.getByRole('listbox').getByText(label('chat.hitlModeOff'), { exact: true }).click();
await savedCount(6);
const expected = {
conversationId: CONVERSATION.id,
reviewer: 'audit_agent',
sensitiveTools: ['fixture-read', 'fixture-write'],
timeoutSeconds: 60
};
expect(mockApi.calls('PUT', '/api/hitl/config').map(call => call.body)).toEqual([
{ conversationId: CONVERSATION.id, enabled: true, mode: 'approval', reviewer: 'human', sensitiveTools: ['fixture-existing-tool'], timeoutSeconds: 90 },
{ conversationId: CONVERSATION.id, enabled: true, mode: 'review_edit', reviewer: 'human', sensitiveTools: ['fixture-existing-tool'], timeoutSeconds: 90 },
{ conversationId: CONVERSATION.id, enabled: true, mode: 'review_edit', reviewer: 'audit_agent', sensitiveTools: ['fixture-existing-tool'], timeoutSeconds: 90 },
{ conversationId: CONVERSATION.id, enabled: true, mode: 'review_edit', reviewer: 'audit_agent', sensitiveTools: ['fixture-existing-tool'], timeoutSeconds: 60 },
{ ...expected, enabled: true, mode: 'review_edit' },
{ ...expected, enabled: false, mode: 'off' }
]);
await expect(settings.getByRole('status')).toHaveText(label('chat.hitlApplyOkSync'));
await settings.locator('button.semi-sidesheet-close').click();
await openSettings.click();
await expect(settings.getByText(label('chat.hitlModeApproval'), { exact: true })).toBeVisible();
const reviewer = label('chat.hitlCurrentReviewer').replace('{{reviewer}}', label('chat.hitlReviewerHuman'));
await expect(settings.getByText(reviewer, { exact: true })).toBeVisible();
expect(mockApi.writes()).toHaveLength(1);
await expect(mode).toHaveText(label('chat.hitlModeOff'));
await expect(auditAgent).toBeChecked();
await expect(timeout).toHaveText(label('chat.hitlTimeoutOneMinute'));
await expect(tools).toHaveValue('fixture-read, fixture-write');
expect(mockApi.writes()).toHaveLength(6);
});
test('sets conversation-level human approval when the default reviewer is inherited', async ({ page, mockApi }) => {
@ -143,11 +197,11 @@ test.describe('chat composer settings', () => {
const settingsButton = main.getByRole('button', { name: label('chat.sessionSettingsTitle'), exact: true });
await settingsButton.click();
const settings = page.getByRole('dialog');
const reviewer = label('chat.hitlCurrentReviewer');
await expect(settings.getByText(reviewer.replace('{{reviewer}}', label('chat.hitlReviewerAgent')), { exact: true })).toBeVisible();
const enable = settings.getByRole('button', { name: label('chat.hitlRequireHumanForConversation') });
await enable.click();
await expect(settings.getByText(reviewer.replace('{{reviewer}}', label('chat.hitlReviewerHuman')), { exact: true })).toBeVisible();
const auditAgent = settings.getByRole('radio', { name: label('chat.hitlReviewerAgent') });
const human = settings.getByRole('radio', { name: label('chat.hitlReviewerHuman') });
await expect(auditAgent).toBeChecked();
await settings.getByText(label('chat.hitlReviewerHuman'), { exact: true }).click();
await expect(human).toBeChecked();
expect(mockApi.writes()).toEqual([]);
await settings.locator('button.semi-sidesheet-close').click();
@ -155,12 +209,36 @@ test.describe('chat composer settings', () => {
await input.fill(message);
await input.press('Enter');
await expect(page).toHaveURL(new RegExp(`#/chat\\?conversation=${id}$`));
expect(mockApi.calls('POST', '/api/agent/stream')[0]?.body.requireHumanApproval).toBe(true);
expect(mockApi.calls('POST', '/api/agent/stream')[0]?.body.hitl).toMatchObject({
enabled: true, mode: 'approval', reviewer: 'human', timeoutSeconds: 180
});
await page.reload();
await ready(page);
await settingsButton.click();
await expect(settings.getByText(reviewer.replace('{{reviewer}}', label('chat.hitlReviewerHuman')), { exact: true })).toBeVisible();
await expect(enable).toHaveCount(0);
await expect(human).toBeChecked();
await expect(settings.getByRole('combobox', { name: label('chat.hitlModeLabel') })).toHaveText(label('chat.hitlModeApproval'));
});
test('restores the server value when a session HITL change fails', async ({ page, mockApi }) => {
const path = `/api/hitl/config/${CONVERSATION.id}`;
mockApi.respond('GET', '/api/agent-loop/tasks', { json: { tasks: [] } });
mockApi.respond('GET', path, { json: {
hitl: { enabled: false, mode: 'off', reviewer: 'human', sensitiveTools: [], timeoutSeconds: 300 },
defaultTimeoutSeconds: 300
} });
mockApi.fail('PUT', '/api/hitl/config', 'fixture 保存失败');
await page.goto('/static/app/#/chat?conversation=' + CONVERSATION.id);
const main = await ready(page);
await main.getByRole('button', { name: label('chat.sessionSettingsTitle'), exact: true }).click();
const settings = page.getByRole('dialog');
const mode = settings.getByRole('combobox', { name: label('chat.hitlModeLabel') });
await expect(mode).toHaveText(label('chat.hitlModeOff'));
await mode.click();
await page.getByRole('listbox').getByText(label('chat.hitlModeApproval'), { exact: true }).click();
await expect(page.getByText('fixture 保存失败', { exact: false })).toBeVisible();
await expect(mode).toHaveText(label('chat.hitlModeOff'));
await expect.poll(() => mockApi.calls('GET', path).length).toBeGreaterThanOrEqual(2);
expect(mockApi.calls('PUT', '/api/hitl/config')).toHaveLength(1);
});
});

View File

@ -241,6 +241,55 @@ test('navigation: four Semi groups, parent expansion, child selection and collap
await expect.poll(() => page.evaluate(() => localStorage.getItem('csai-nav-collapsed'))).toBe('0');
});
test('navigation: collapsed submenus fit their labels and center beside the parent', async ({ page }, testInfo) => {
await visit(page, 'chat');
const sidebar = page.locator('.cs-sider');
await button(sidebar, label('nav.collapse', '收起菜单')).click();
await expect(page.locator('.cs-shell')).toHaveClass(/is-collapsed/);
const mcp = sidebar.getByRole('menuitem', { name: 'MCP', exact: true });
const monitor = page.getByRole('menuitem', { name: label('nav.mcpMonitor', 'MCP状态监控'), exact: true });
const mcpMenu = page.locator('.semi-navigation-popover').filter({ has: monitor });
await mcp.hover();
await expect(monitor).toBeVisible();
const mcpBox = await mcp.boundingBox();
await expect.poll(async () => {
const menu = await mcpMenu.boundingBox();
return Math.abs(menu.y + menu.height / 2 - (mcpBox.y + mcpBox.height / 2));
}).toBeLessThanOrEqual(1);
const menuBox = await mcpMenu.boundingBox();
const monitorText = await monitor.locator('.semi-navigation-item-text').boundingBox();
const leftPadding = monitorText.x - menuBox.x;
const rightPadding = menuBox.x + menuBox.width - monitorText.x - monitorText.width;
expect(Math.abs(leftPadding - rightPadding)).toBeLessThanOrEqual(1);
await screenshot(page, testInfo, 'collapsed-mcp-menu');
const c2 = sidebar.getByRole('menuitem', { name: 'C2', exact: true });
const profiles = page.getByRole('menuitem', { name: label('nav.c2Profiles', '流量伪装'), exact: true });
const c2Menu = page.locator('.semi-navigation-popover').filter({ has: profiles });
await c2.hover();
await expect(c2Menu.getByRole('menuitem')).toHaveCount(6);
const c2Box = await c2.boundingBox();
const c2Center = c2Box.y + c2Box.height / 2;
await expect.poll(async () => {
const menu = await c2Menu.boundingBox();
return Math.abs(menu.y + menu.height / 2 - c2Center);
}).toBeLessThanOrEqual(1);
const tallMenu = await c2Menu.boundingBox();
expect(tallMenu.width).toBeLessThan(menuBox.width);
// Put the trigger near the lower edge so the menu no longer fits at its centered position.
const height = Math.ceil(c2Box.y + c2Box.height + 60);
expect(c2Center + tallMenu.height / 2).toBeGreaterThan(height);
await page.setViewportSize({ width: 1440, height });
await expect.poll(async () => {
const menu = await c2Menu.boundingBox();
return menu.y >= 0 && menu.y + menu.height <= height && menu.y <= c2Center;
}).toBe(true);
await profiles.click();
await expect(page).toHaveURL(/#\/c2-profiles$/);
});
test('theme: menu switches dark/light, actual primary colors, reload preserves preference', async ({ page }, testInfo) => {
await visit(page, 'dashboard');
let current = label('theme.system', '跟随系统');
@ -322,7 +371,7 @@ test('chat: select stored conversation and restore it after reload', async ({ pa
expect(mockApi.writes()).toEqual([]);
});
test('chat: message list and focused composer share one panel', async ({ page, mockApi }, testInfo) => {
test('chat: floating composer stays aligned and shows focus', async ({ page, mockApi }, testInfo) => {
mockApi.respond('GET', '/api/agent-loop/tasks', { json: { tasks: [] } });
await page.goto(`/static/app/#/chat?conversation=${CONVERSATION.id}`);
const main = await ready(page);
@ -330,25 +379,27 @@ test('chat: message list and focused composer share one panel', async ({ page, m
const messages = panel.locator('.chat-messages');
const assistant = messages.locator('.chat-msg-assistant').first();
const composer = panel.locator('.chat-composer');
const composerBox = composer.locator('.chat-composer-box');
const input = composer.getByRole('textbox', { name: label('chat.composerLabel', '对话内容') });
await expect(assistant).toBeVisible();
const [timeline, footer, row, textarea] = await Promise.all(
[messages, composer, assistant, input].map(element => element.boundingBox())
const [timeline, footer, box] = await Promise.all(
[messages, composer, composerBox].map(element => element.boundingBox())
);
expect(footer.x).toBeCloseTo(timeline.x, 0);
expect(footer.width).toBeCloseTo(timeline.width, 0);
expect(footer.y).toBeCloseTo(timeline.y + timeline.height, 0);
expect(textarea.x).toBeCloseTo(row.x, 0);
expect(textarea.width).toBeCloseTo(row.width, 0);
expect(box.x).toBeGreaterThanOrEqual(timeline.x);
expect(box.width).toBeLessThanOrEqual(footer.width);
await expect(composer).toHaveCSS('background-color', 'rgba(0, 0, 0, 0)');
await expect(composer.locator('.chat-composer-box')).toHaveCSS('border-top-width', '0px');
await expect(composerBox).toHaveCSS('border-top-width', '1px');
await expect(composerBox).toHaveCSS('border-radius', '16px');
const dividerColor = await composer.evaluate(node => getComputedStyle(node).borderTopColor);
const borderColor = await composerBox.evaluate(node => getComputedStyle(node).borderTopColor);
await input.click();
await expect(input).toBeFocused();
await expect(input).toHaveCSS('outline-style', 'none');
await expect(composer).not.toHaveCSS('border-top-color', dividerColor);
await expect(composerBox).not.toHaveCSS('border-top-color', borderColor);
expect(mockApi.writes()).toEqual([]);
await panel.screenshot({ path: testInfo.outputPath('focused-chat-panel.png') });
});
@ -399,6 +450,34 @@ for (const [id, path, record] of [
});
}
test('deep assessment: archive filter stays horizontal and switches the list without writes', async ({ page, mockApi }) => {
mockApi.respond('GET', '/api/deep-assessments', (_, url) => ({
json: { tasks: url.searchParams.get('archived') === 'true' ? [] : [ASSESSMENT], has_more: false }
}));
const main = await visit(page, 'deep-assessments');
const filter = main.getByRole('radiogroup', { name: '归档状态' });
const unarchived = filter.getByRole('radio', { name: '未归档' });
const archived = filter.getByRole('radio', { name: '已归档' });
const unarchivedLabel = filter.getByText('未归档', { exact: true });
const archivedLabel = filter.getByText('已归档', { exact: true });
const draft = button(main, ASSESSMENT.name);
await expect(unarchived).toBeChecked();
await expect(draft).toBeVisible();
await expect(filter).toBeInViewport({ ratio: 1 });
await page.setViewportSize({ width: 390, height: 844 });
await expect(filter).toBeInViewport({ ratio: 1 });
expect((await unarchivedLabel.boundingBox()).y).toBe((await archivedLabel.boundingBox()).y);
await archivedLabel.click();
await expect(archived).toBeChecked();
await expect(draft).toHaveCount(0);
await unarchivedLabel.click();
await expect(unarchived).toBeChecked();
await expect(draft).toBeVisible();
expect(mockApi.writes()).toEqual([]);
});
test('deep assessment: options retry, required objective, close new-draft modal without execution', async ({ page, mockApi }, testInfo) => {
mockApi.fail('GET', '/api/deep-assessments/options', '示例选项加载失败');
const main = await visit(page, 'deep-assessments');

View File

@ -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-CnhFixIe.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-rhyktlYQ.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};

View File

@ -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-CnhFixIe.js";import"./c2-shared-BCw9u-Qs.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-rhyktlYQ.js";import"./c2-shared-CvBM-5ub.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};

View File

@ -1 +1 @@
import{I as e,L as t}from"./index-CnhFixIe.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-rhyktlYQ.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

View File

@ -1 +0,0 @@
.assessment-page{flex-direction:column;gap:12px;display:flex}.assessment-page .cs-page-header-extra{flex-wrap:wrap;justify-content:flex-end}.assessment-meta{align-items:center;margin-top:6px}.assessment-banner{margin-bottom:0}.assessment-tabs{background:var(--semi-color-bg-1);border-radius:var(--semi-border-radius-large);padding:4px 16px 16px}.assessment-tab{flex-direction:column;gap:12px;padding-top:4px;display:flex}.assessment-loading{color:var(--semi-color-text-2);justify-content:center;align-items:center;padding:48px;display:flex}.assessment-hint{color:var(--semi-color-text-2);margin:8px 0 0;font-size:12px}.assessment-toolbar{flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:12px;display:flex}.assessment-pager{justify-content:flex-end;padding-top:12px;display:flex}.assessment-list-name{flex-direction:column;gap:2px;min-width:0;display:flex}.assessment-link{text-align:left;justify-content:flex-start;height:auto;padding:0;font-weight:600}.assessment-ellipsis{text-overflow:ellipsis;white-space:nowrap;max-width:420px;overflow:hidden}.assessment-progress{flex-direction:column;gap:4px;display:flex}.assessment-progress .semi-progress-track{min-width:120px}.assessment-pre{white-space:pre-wrap;word-break:break-word;margin:0;font-family:inherit;line-height:1.6}.assessment-facts-row{flex-wrap:wrap;gap:16px;margin-top:12px;display:flex}.assessment-guidance{border-top:1px solid var(--semi-color-border);flex-direction:column;gap:8px;margin-top:16px;padding-top:12px;display:flex}.assessment-guidance-item{grid-template-columns:32px minmax(0,1fr);align-items:start;gap:8px;display:grid}.assessment-section{border-top:1px solid var(--semi-color-border);flex-direction:column;gap:8px;margin-top:4px;padding-top:12px;display:flex}.assessment-timeline{max-height:480px;padding-right:8px;overflow-y:auto}.assessment-event-head{align-items:center;gap:8px;display:flex}.assessment-event-message{white-space:pre-wrap;word-break:break-word;color:var(--semi-color-text-1);margin-top:2px;font-size:12px}.assessment-drawer{flex-direction:column;gap:12px;display:flex}.assessment-form-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:0 16px;display:grid}.assessment-form-note{margin-top:8px}.assessment-form-actions{border-top:1px solid var(--semi-color-border);justify-content:flex-end;gap:8px;margin-top:16px;padding-top:12px;display:flex}.assessment-graph-meta,.assessment-graph-toolbar{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px;margin-bottom:8px;display:flex}.assessment-graph-layout{grid-template-columns:minmax(0,1fr) 340px;align-items:stretch;gap:12px;display:grid}.assessment-graph-canvas{border:1px solid var(--semi-color-border);border-radius:var(--semi-border-radius-medium);background:var(--semi-color-bg-2);width:100%;height:520px;overflow:hidden}.assessment-node-panel{border:1px solid var(--semi-color-border);border-radius:var(--semi-border-radius-medium);background:var(--semi-color-bg-1);height:520px;padding:12px;overflow-y:auto}.assessment-node-body{flex-direction:column;gap:10px;display:flex}.assessment-node-head{flex-direction:column;gap:6px;display:flex}.assessment-node-content{border-radius:var(--semi-border-radius-small);background:var(--semi-color-fill-0);max-height:220px;padding:8px;overflow-y:auto}.assessment-relations{flex-wrap:wrap;gap:4px;display:flex}.assessment-path-list{flex-direction:column;gap:4px;max-height:240px;display:flex;overflow-y:auto}.assessment-path-node{border-radius:var(--semi-border-radius-small);background:var(--semi-color-fill-0);align-items:center;gap:8px;min-width:0;padding:4px 6px;display:flex}.assessment-report{max-width:960px}@media (max-width:1180px){.assessment-graph-layout{grid-template-columns:minmax(0,1fr)}.assessment-node-panel{height:auto;max-height:420px}}@media (max-width:720px){.assessment-form-grid{grid-template-columns:minmax(0,1fr)}.assessment-graph-canvas{height:420px}}.assessment-error-block{flex-direction:column;align-items:flex-start;gap:8px;margin-bottom:12px;display:flex}

View File

@ -0,0 +1 @@
.assessment-page{flex-direction:column;gap:12px;display:flex}.assessment-page .cs-page-header-extra{flex-wrap:wrap;justify-content:flex-end}.assessment-meta{align-items:center;margin-top:6px}.assessment-banner{margin-bottom:0}.assessment-tabs{background:var(--semi-color-bg-1);border-radius:var(--semi-border-radius-large);padding:4px 16px 16px}.assessment-tab{flex-direction:column;gap:12px;padding-top:4px;display:flex}.assessment-loading{color:var(--semi-color-text-2);justify-content:center;align-items:center;padding:48px;display:flex}.assessment-hint{color:var(--semi-color-text-2);margin:8px 0 0;font-size:12px}.assessment-list-card .semi-card-header{flex-wrap:wrap;gap:10px}.assessment-archive-filter{white-space:nowrap}.assessment-toolbar{flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:12px;display:flex}.assessment-pager{justify-content:flex-end;padding-top:12px;display:flex}.assessment-list-name{flex-direction:column;gap:2px;min-width:0;display:flex}.assessment-link{text-align:left;justify-content:flex-start;height:auto;padding:0;font-weight:600}.assessment-ellipsis{text-overflow:ellipsis;white-space:nowrap;max-width:420px;overflow:hidden}.assessment-progress{flex-direction:column;gap:4px;display:flex}.assessment-progress .semi-progress-track{min-width:120px}.assessment-pre{white-space:pre-wrap;word-break:break-word;margin:0;font-family:inherit;line-height:1.6}.assessment-facts-row{flex-wrap:wrap;gap:16px;margin-top:12px;display:flex}.assessment-guidance{border-top:1px solid var(--semi-color-border);flex-direction:column;gap:8px;margin-top:16px;padding-top:12px;display:flex}.assessment-guidance-item{grid-template-columns:32px minmax(0,1fr);align-items:start;gap:8px;display:grid}.assessment-section{border-top:1px solid var(--semi-color-border);flex-direction:column;gap:8px;margin-top:4px;padding-top:12px;display:flex}.assessment-timeline{max-height:480px;padding-right:8px;overflow-y:auto}.assessment-event-head{align-items:center;gap:8px;display:flex}.assessment-event-message{white-space:pre-wrap;word-break:break-word;color:var(--semi-color-text-1);margin-top:2px;font-size:12px}.assessment-drawer{flex-direction:column;gap:12px;display:flex}.assessment-form-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:0 16px;display:grid}.assessment-form-note{margin-top:8px}.assessment-form-actions{border-top:1px solid var(--semi-color-border);justify-content:flex-end;gap:8px;margin-top:16px;padding-top:12px;display:flex}.assessment-graph-meta,.assessment-graph-toolbar{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px;margin-bottom:8px;display:flex}.assessment-graph-layout{grid-template-columns:minmax(0,1fr) 340px;align-items:stretch;gap:12px;display:grid}.assessment-graph-canvas{border:1px solid var(--semi-color-border);border-radius:var(--semi-border-radius-medium);background:var(--semi-color-bg-2);width:100%;height:520px;overflow:hidden}.assessment-node-panel{border:1px solid var(--semi-color-border);border-radius:var(--semi-border-radius-medium);background:var(--semi-color-bg-1);height:520px;padding:12px;overflow-y:auto}.assessment-node-body{flex-direction:column;gap:10px;display:flex}.assessment-node-head{flex-direction:column;gap:6px;display:flex}.assessment-node-content{border-radius:var(--semi-border-radius-small);background:var(--semi-color-fill-0);max-height:220px;padding:8px;overflow-y:auto}.assessment-relations{flex-wrap:wrap;gap:4px;display:flex}.assessment-path-list{flex-direction:column;gap:4px;max-height:240px;display:flex;overflow-y:auto}.assessment-path-node{border-radius:var(--semi-border-radius-small);background:var(--semi-color-fill-0);align-items:center;gap:8px;min-width:0;padding:4px 6px;display:flex}.assessment-report{max-width:960px}@media (max-width:1180px){.assessment-graph-layout{grid-template-columns:minmax(0,1fr)}.assessment-node-panel{height:auto;max-height:420px}}@media (max-width:720px){.assessment-form-grid{grid-template-columns:minmax(0,1fr)}.assessment-graph-canvas{height:420px}}.assessment-error-block{flex-direction:column;align-items:flex-start;gap:8px;margin-bottom:12px;display:flex}

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

View File

@ -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-CnhFixIe.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-rhyktlYQ.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};

View File

@ -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-CnhFixIe.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-rhyktlYQ.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};

View File

@ -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 ee,I as j,L as M,M as N,N as P,P as F,R as I,S as L,T as R,_ as te,a as z,b as B,d as V,j as ne,l as H,m as U,n as re,o as ie,p as ae,s as W,u as G,x as K,y as oe}from"./index-CnhFixIe.js";import{n as se,r as ce,t as le}from"./model-channel-mQ6lfvSO.js";var q=e(t(),1),J=class extends Error{constructor(e,t){super(t?`第 ${t} 行:${e}`:e),this.name=`YamlError`,this.line=t||0}},ue=/^(?:[-?:,\[\]{}#&*!|>'"%@`]|.*[:\s]$|.*\s#|.*[\n\r\t])/,de=/^(?:true|false|null|~|yes|no|on|off|[-+]?(?:\d+|\d*\.\d+)(?:[eE][-+]?\d+)?)$/i;function fe(e){let t=String(e);return!(t===``||de.test(t)||/^[-+]?(?:\d+\.\d*|\.\d+|\d+)(?:[eE][-+]?\d+)?$/.test(t)||ue.test(t)||/^(?:\s)|:(?:\s|$)|[\r\n\t]/.test(t)||/[,[\]{}]/.test(t)||/^[!&*|>@`]/.test(t))}function pe(e){return JSON.stringify(String(e))}function me(e){let t=String(e);return fe(t)?t:pe(t)}function he(e){if(e==null)return`null`;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return Number.isFinite(e)?String(e):pe(String(e));let t=String(e);return fe(t)?t:pe(t)}function ge(e){return e==null||[`string`,`number`,`boolean`].includes(typeof e)}function _e(e,t,n,r){let i=` `.repeat(n),a=me(e);if(ge(t))r.push(`${i}${a}: ${he(t)}`);else if(Array.isArray(t)){if(!t.length){r.push(`${i}${a}: []`);return}r.push(`${i}${a}:`),be(t,n+2,r)}else Object.entries(t).length?(r.push(`${i}${a}:`),ve(t,n+2,r)):r.push(`${i}${a}: {}`)}function ve(e,t,n){for(let[r,i]of Object.entries(e))_e(r,i,t,n)}function ye(e,t,n){let r=` `.repeat(t);if(ge(e)){n.push(`${r}- ${he(e)}`);return}if(Array.isArray(e)){if(!e.length){n.push(`${r}- []`);return}n.push(`${r}-`),be(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);ge(o)?n.push(`${r}- ${me(a)}: ${he(o)}`):(n.push(`${r}-`),_e(a,o,t+2,n));for(let[e,r]of s)_e(e,r,t+2,n)}function be(e,t,n){for(let r of e)ye(r,t,n)}function xe(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 ee,I as j,L as M,M as N,N as P,P as F,R as I,S as L,T as R,_ as te,a as z,b as B,d as V,j as ne,l as H,m as U,n as re,o as ie,p as ae,s as W,u as G,x as K,y as oe}from"./index-rhyktlYQ.js";import{n as se,r as ce,t as le}from"./model-channel-mQ6lfvSO.js";var q=e(t(),1),J=class extends Error{constructor(e,t){super(t?`第 ${t} 行:${e}`:e),this.name=`YamlError`,this.line=t||0}},ue=/^(?:[-?:,\[\]{}#&*!|>'"%@`]|.*[:\s]$|.*\s#|.*[\n\r\t])/,de=/^(?:true|false|null|~|yes|no|on|off|[-+]?(?:\d+|\d*\.\d+)(?:[eE][-+]?\d+)?)$/i;function fe(e){let t=String(e);return!(t===``||de.test(t)||/^[-+]?(?:\d+\.\d*|\.\d+|\d+)(?:[eE][-+]?\d+)?$/.test(t)||ue.test(t)||/^(?:\s)|:(?:\s|$)|[\r\n\t]/.test(t)||/[,[\]{}]/.test(t)||/^[!&*|>@`]/.test(t))}function pe(e){return JSON.stringify(String(e))}function me(e){let t=String(e);return fe(t)?t:pe(t)}function he(e){if(e==null)return`null`;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return Number.isFinite(e)?String(e):pe(String(e));let t=String(e);return fe(t)?t:pe(t)}function ge(e){return e==null||[`string`,`number`,`boolean`].includes(typeof e)}function _e(e,t,n,r){let i=` `.repeat(n),a=me(e);if(ge(t))r.push(`${i}${a}: ${he(t)}`);else if(Array.isArray(t)){if(!t.length){r.push(`${i}${a}: []`);return}r.push(`${i}${a}:`),be(t,n+2,r)}else Object.entries(t).length?(r.push(`${i}${a}:`),ve(t,n+2,r)):r.push(`${i}${a}: {}`)}function ve(e,t,n){for(let[r,i]of Object.entries(e))_e(r,i,t,n)}function ye(e,t,n){let r=` `.repeat(t);if(ge(e)){n.push(`${r}- ${he(e)}`);return}if(Array.isArray(e)){if(!e.length){n.push(`${r}- []`);return}n.push(`${r}-`),be(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);ge(o)?n.push(`${r}- ${me(a)}: ${he(o)}`):(n.push(`${r}-`),_e(a,o,t+2,n));for(let[e,r]of s)_e(e,r,t+2,n)}function be(e,t,n){for(let r of e)ye(r,t,n)}function xe(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 ge(e)?(n.push(he(e)),`${n.join(`
`)}\n`):Array.isArray(e)?(e.length?be(e,0,n):n.push(`[]`),`${n.join(`

View File

@ -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-CnhFixIe.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-rhyktlYQ.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

View File

@ -18,12 +18,12 @@
} catch (error) { /* first paint fallback */ }
})();
</script>
<script type="module" crossorigin src="/static/app/assets/index-CnhFixIe.js"></script>
<script type="module" crossorigin src="/static/app/assets/index-rhyktlYQ.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">
<link rel="stylesheet" crossorigin href="/static/app/assets/semi-BUXPdXzR.css">
<link rel="stylesheet" crossorigin href="/static/app/assets/index-DBcUCOSW.css">
<link rel="stylesheet" crossorigin href="/static/app/assets/index-DgiqFDzv.css">
</head>
<body>
<div id="root"></div>

View File

@ -4646,6 +4646,11 @@
}
}
},
"deepAssessments": {
"unarchivedTasks": "غير مؤرشف",
"archivedTasks": "مؤرشف",
"archiveFilter": "حالة الأرشفة"
},
"vulnerabilityRetest": {
"startFailed": "لم يُرسَل إعادة الاختبار. مُوجّهه محفوظ في الفرع؛ عُد إليه للمتابعة.",
"title": "إعادة اختبار الثغرة",

View File

@ -5653,6 +5653,7 @@
"archive": "Archive",
"restore": "Restore to list",
"currentTasks": "Current tasks",
"unarchivedTasks": "Unarchived",
"archivedTasks": "Archived",
"archiveFilter": "Archive status",
"archiveHint": "Archiving keeps progress and evidence. Pause running work first.",

View File

@ -5549,6 +5549,7 @@
"archive": "В архив",
"restore": "Вернуть в список",
"currentTasks": "Текущие задачи",
"unarchivedTasks": "Не в архиве",
"archivedTasks": "Архив",
"archiveFilter": "Архив",
"archiveHint": "Архив сохраняет прогресс и доказательства. Сначала приостановите выполнение.",

View File

@ -5520,6 +5520,7 @@
"archive": "归档",
"restore": "恢复到列表",
"currentTasks": "当前任务",
"unarchivedTasks": "未归档",
"archivedTasks": "已归档",
"archiveFilter": "归档状态",
"archiveHint": "归档保留进度与证据;执行中的任务请先暂停。",