feat(deep-assessment): clarify exploration flow and task summary

This commit is contained in:
Sycun 2026-11-20 08:43:27 +08:00
parent 222398fdf7
commit 1d1db56a04
46 changed files with 1053 additions and 338 deletions

View File

@ -0,0 +1,69 @@
import { Button, Tag, Typography } from '@douyinfe/semi-ui';
import { formatDateTime } from '../../lib/format';
import { statusText } from './labels';
const { Text, Paragraph } = Typography;
const PREVIEW_LIMIT = 6;
export default function GraphBrief({ task, t, onIntent, onGoIntents }) {
const steps = task.steps || [];
const titles = new Map(steps.map(step => [step.id, step.title || step.id]));
const completed = steps.filter(step => step.status === 'completed').length;
const summary = task.summary?.trim();
return (
<details className="assessment-graph-brief">
<summary>
<Text strong>目标拆解与阶段总结</Text>
<Text type="tertiary" size="small" className="assessment-graph-brief-counts">
{steps.length ? `${steps.length} 个意图 · ${completed} 个已完成` : '暂无意图'}
</Text>
</summary>
<div className="assessment-graph-brief-grid">
<section className="assessment-graph-brief-content">
<Text strong>{t('deepAssessments.objective', null, '目标')}</Text>
<Paragraph className="assessment-pre">{task.objective || task.name || '—'}</Paragraph>
{steps.length ? (
<>
<ul className="assessment-graph-intents" aria-label="目标拆解">
{steps.slice(0, PREVIEW_LIMIT).map(step => {
const dependencies = (step.depends_on || []).map(id => titles.get(id) || id);
return (
<li key={step.id}>
<div className="assessment-graph-intent-head">
<Button size="small" theme="borderless" onClick={() => onIntent(step.id)} title={titles.get(step.id)}>
{titles.get(step.id)}
</Button>
{step.status ? <Tag size="small">{statusText(t, step.status)}</Tag> : null}
</div>
{dependencies.length ? (
<Text size="small" type="tertiary">
上游依赖 · {dependencies.slice(0, 2).join('、')}
{dependencies.length > 2 ? ` 等 ${dependencies.length} 项` : ''}
</Text>
) : null}
</li>
);
})}
</ul>
{steps.length > PREVIEW_LIMIT ? (
<Button size="small" theme="borderless" onClick={onGoIntents}>查看全部意图</Button>
) : null}
</>
) : (
<Text type="tertiary" size="small">已有计划中的意图会显示在这里。</Text>
)}
</section>
<section className="assessment-graph-brief-content">
<Text strong>阶段总结</Text>
<Paragraph className="assessment-pre assessment-graph-summary">
{summary || '当前还没有保存的阶段总结。'}
</Paragraph>
{summary && task.updated_at ? (
<Text size="small" type="tertiary">测评更新于 {formatDateTime(task.updated_at)}</Text>
) : null}
</section>
</div>
</details>
);
}

View File

@ -0,0 +1,311 @@
import { Fragment, useEffect, useRef, useState } from 'react';
import { toastError } from '../../components/ui';
import { GRAPH_KIND_COLOR } from './labels';
import { GRAPH_COLUMN_GAP, graphPositions } from './graphLayout';
const STYLE = [
{
selector: 'node',
style: {
'background-color': 'data(color)',
width: 23, height: 23,
'border-width': 2, 'border-color': '#ffffff'
}
},
{ selector: 'node[kind = "goal"]', style: { width: 31, height: 31 } },
{ selector: 'node[boundary = 1]', style: { shape: 'round-rectangle', width: 17, height: 17 } },
{ selector: 'node.current', style: { 'border-color': '#0066ff', 'border-width': 4 } },
{
selector: 'edge',
style: {
width: 1.8,
'line-color': 'data(color)',
'target-arrow-color': 'data(color)',
'target-arrow-shape': 'triangle',
'arrow-scale': 0.8,
'curve-style': 'bezier',
opacity: 0.74
}
},
{
selector: 'edge.flow',
style: { 'curve-style': 'round-taxi', 'taxi-direction': 'rightward', 'taxi-radius': 16 }
},
{
selector: 'edge.long-flow',
style: {
'curve-style': 'unbundled-bezier', 'control-point-weights': 0.45,
'control-point-distances': 'data(bend)'
}
},
{ selector: 'edge[projection = "archive"]', style: { 'line-style': 'dashed' } },
{ selector: 'edge[projection = "details"]', style: { 'line-style': 'dotted' } },
{ selector: 'node.dim', style: { opacity: 0.32 } },
{ selector: 'edge.dim', style: { opacity: 0.12 } },
{
selector: 'edge.related',
style: { width: 2.8, opacity: 1, 'z-index': 2 }
},
{ selector: '.hidden', style: { display: 'none' } }
];
const LABEL_WIDTH = 148;
const LABEL_HEIGHT = 22;
const LABEL_PADDING = 7;
const LABEL_PRIORITY = { goal: 0, finding: 1, step: 2, guidance: 3, fact: 4, digest: 5 };
const overlaps = (a, b) => a.x < b.x + b.width && a.x + a.width > b.x
&& a.y < b.y + b.height && a.y + a.height > b.y;
function visibleLabels(cy, model, selected, hovered, measure) {
const width = cy.width();
const height = cy.height();
const zoom = cy.zoom();
const items = cy.nodes(':visible').map(node => {
const item = model.nodes.get(node.id());
const { x, y } = node.renderedPosition();
const radius = node.renderedOuterWidth() / 2 + 2;
const priority = node === selected ? -2 : node === hovered ? -1
: (LABEL_PRIORITY[item.kind] ?? 6) + (item.boundary ? 8 : 0);
return { node, item, x, y, radius, priority };
}).filter(({ x, y, radius }) => x >= -radius && x <= width + radius && y >= -radius && y <= height + radius);
const occupied = items.map(({ x, y, radius }) => ({
x: x - radius, y: y - radius, width: radius * 2, height: radius * 2
}));
const labels = [];
items.sort((a, b) => a.priority - b.priority);
for (const { node, item, x, y, radius, priority } of items) {
if (zoom < 0.64 && priority > 3) continue;
if (node.hasClass('dim') && priority >= 0) continue;
const title = (item.title || item.id).replace(/\s+/g, ' ').trim() || item.id;
const labelWidth = Math.min(LABEL_WIDTH, Math.ceil(measure(title)) + LABEL_PADDING * 2);
const left = Math.max(4, Math.min(x - labelWidth / 2, width - labelWidth - 4));
const top = y + radius + 4;
const candidates = [{ x: left, y: top, width: labelWidth, height: LABEL_HEIGHT }];
if (priority <= 3) {
candidates.push(
{ ...candidates[0], y: y - radius - LABEL_HEIGHT - 4 },
{ ...candidates[0], x: x + radius + 5, y: y - LABEL_HEIGHT / 2 },
{ ...candidates[0], x: x - radius - labelWidth - 5, y: y - LABEL_HEIGHT / 2 }
);
}
if (priority <= 0) {
// A fitted overview can leave only a few pixels between nodes on a phone.
for (const offset of [28, 54, 80, 106, 132]) {
candidates.push(
{ ...candidates[0], y: top + offset, displaced: true },
{ ...candidates[0], y: y - radius - LABEL_HEIGHT - 4 - offset, displaced: true }
);
}
}
const box = candidates.find(rect => rect.x >= 3 && rect.x + rect.width <= width - 3
&& rect.y >= 3 && rect.y + rect.height <= height - 3
&& !occupied.some(other => overlaps(rect, other)));
if (!box) continue;
occupied.push({ x: box.x - 3, y: box.y - 2, width: box.width + 6, height: LABEL_HEIGHT + 4 });
const below = box.y > y;
const leader = box.displaced ? {
left: x,
top: below ? y + radius : box.y + LABEL_HEIGHT,
height: below ? box.y - y - radius : y - radius - box.y - LABEL_HEIGHT
} : null;
labels.push({ id: item.id, title, box, leader, selected: priority === -2 });
}
return labels;
}
export function fitGraph(cy) {
const nodes = cy.nodes(':visible');
if (nodes.empty()) return;
cy.fit(nodes, 45);
if (cy.zoom() > 1) cy.zoom(1).center(nodes);
}
export function zoomGraph(cy, factor) {
cy.zoom({
level: cy.zoom() * factor,
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
});
}
export default function GraphCanvas({ model, graphKey, selectedId, showAll, locate, onSelect, cyRef }) {
const containerRef = useRef(null);
const chartRef = useRef(null);
const viewRef = useRef(null);
const controlsRef = useRef({ selectedId, showAll, locate, onSelect });
const [labels, setLabels] = useState([]);
useEffect(() => {
controlsRef.current = { selectedId, showAll, locate, onSelect };
chartRef.current?.syncSelection();
}, [selectedId, showAll, locate, onSelect]);
useEffect(() => {
const container = containerRef.current;
if (!model.nodes.size) {
setLabels([]);
return undefined;
}
let disposed = false;
let cy;
let frame;
let resize;
let hovered;
let centeredRequest;
let previousSelection;
let previousShowAll = controlsRef.current.showAll;
setLabels([]);
import('cytoscape').then(({ default: cytoscape }) => {
if (disposed) return;
const positions = graphPositions(model);
const elements = [
...[...model.nodes.values()].map(node => ({
data: {
id: node.id, kind: node.kind, boundary: Number(Boolean(node.boundary)),
color: GRAPH_KIND_COLOR[node.kind] || '#86909c'
},
position: positions.get(node.id)
})),
...model.edges.map(edge => {
const source = positions.get(edge.source);
const target = positions.get(edge.target);
const spansColumns = target.x - source.x > GRAPH_COLUMN_GAP * 1.5;
return {
data: {
...edge, projection: edge.projection || '',
bend: target.y < source.y ? -28 : 28
},
classes: model.layoutEdges.has(edge.id) ? (spansColumns ? 'long-flow' : 'flow') : ''
};
})
];
cy = cytoscape({
container, elements, style: STYLE,
layout: { name: 'preset', fit: false },
wheelSensitivity: 0.2, minZoom: 0.005, maxZoom: 3,
boxSelectionEnabled: false,
autounselectify: true
});
cyRef.current = cy;
const measurement = document.createElement('canvas').getContext('2d');
measurement.font = `12px ${getComputedStyle(container).fontFamily}`;
const widths = new Map();
const measure = title => {
if (!widths.has(title)) widths.set(title, measurement.measureText(title).width);
return widths.get(title);
};
const selectedNode = () => cy.$id(controlsRef.current.selectedId)[0];
const updateLabels = () => {
cancelAnimationFrame(frame);
frame = requestAnimationFrame(() => setLabels(visibleLabels(cy, model, selectedNode(), hovered, measure)));
};
const syncSelection = () => {
const { showAll, locate } = controlsRef.current;
const selected = selectedNode();
const related = selected?.connectedEdges() || cy.collection();
const neighbors = related.connectedNodes();
const overview = !showAll && model.dense && model.overview.size > 0;
cy.batch(() => {
// Selection is controlled by the detail panel, including label and search picks.
cy.nodes().forEach(node => {
const nearby = node === selected || neighbors.has(node);
node.toggleClass('current', node === selected);
node.toggleClass('dim', Boolean(selected && !nearby));
node.toggleClass('hidden', overview && !nearby && !model.overview.has(node.id()));
});
cy.edges().forEach(edge => {
const incident = related.has(edge);
edge.toggleClass('related', incident);
edge.toggleClass('dim', Boolean(selected && !incident));
edge.toggleClass('hidden', !showAll && model.dense && !model.backbone.has(edge.id()) && !incident);
});
});
if (locate && locate !== centeredRequest && selected?.id() === locate.id) {
centeredRequest = locate;
const zoom = Math.max(cy.zoom(), 1);
cy.zoom(zoom).center(selected);
} else if (!selected && (showAll !== previousShowAll || (overview && previousSelection?.hidden()))) {
fitGraph(cy);
}
previousSelection = selected;
previousShowAll = showAll;
updateLabels();
};
chartRef.current = { syncSelection };
const saved = viewRef.current;
const restore = saved?.key === graphKey;
if (restore) {
cy.viewport(saved);
centeredRequest = controlsRef.current.locate;
}
syncSelection();
if (!restore && !centeredRequest) fitGraph(cy);
cy.on('pan zoom position', updateLabels);
cy.on('tap', event => {
if (event.target === cy) controlsRef.current.onSelect('');
else if (event.target.isNode()) controlsRef.current.onSelect(event.target.id());
});
cy.on('mouseover', 'node', event => { hovered = event.target; updateLabels(); });
cy.on('mouseout', 'node', () => { hovered = undefined; updateLabels(); });
let width = cy.width();
let height = cy.height();
resize = new ResizeObserver(() => {
const previousWidth = width;
const previousHeight = height;
cy.resize();
const nextWidth = cy.width();
const nextHeight = cy.height();
cy.panBy({ x: (nextWidth - width) / 2, y: (nextHeight - height) / 2 });
width = nextWidth;
height = nextHeight;
const selected = selectedNode();
const point = selected?.renderedPosition();
if (point && (point.x < 30 || point.x > width - 30 || point.y < 30 || point.y > height - 30)) {
cy.center(selected);
} else if (!selected && (nextWidth < previousWidth || nextHeight < previousHeight)) {
fitGraph(cy);
}
updateLabels();
});
resize.observe(container);
}).catch(error => { if (!disposed) toastError(error, '图谱渲染失败'); });
return () => {
disposed = true;
cancelAnimationFrame(frame);
resize?.disconnect();
if (cy) {
viewRef.current = { key: graphKey, zoom: cy.zoom(), pan: cy.pan() };
cy.destroy();
}
chartRef.current = null;
cyRef.current = null;
};
}, [model, graphKey, cyRef]);
return (
<div className="assessment-graph-viewport" role="group" aria-label="探索图">
<div ref={containerRef} className="assessment-graph-canvas" />
<div className="assessment-graph-labels">
{labels.map(({ id, title, box, leader, selected }) => (
<Fragment key={id}>
{leader ? <span aria-hidden="true" className="assessment-graph-label-leader" style={leader} /> : null}
<button
type="button"
className="assessment-graph-label"
aria-pressed={selected}
style={{ left: box.x, top: box.y, width: box.width }}
title={title}
dir="auto"
onClick={() => onSelect(id)}
>
{title}
</button>
</Fragment>
))}
</div>
</div>
);
}

View File

@ -1,76 +1,26 @@
/** 探索图:cytoscape 渲染、节点下钻与证据路径。 */
import { useCallback, useEffect, useRef, useState } from 'react';
import { useCallback, useMemo, useRef, useState } from 'react';
import { Button, Empty, RadioGroup, Select, Space, Tag, Typography } from '@douyinfe/semi-ui';
import { api } from '../../lib/http';
import { useT } from '../../lib/i18n';
import { useTheme } from '../../lib/theme';
import { useResource } from '../../components/hooks';
import { SectionCard, ErrorBanner, JsonViewer, KeyValueList, toastError } from '../../components/ui';
import { formatDateTime } from '../../lib/format';
import { GRAPH_KIND_COLOR, kindText, stateText, truncateText } from './labels';
import { kindText, stateText, truncateText } from './labels';
import GraphCanvas, { fitGraph, zoomGraph } from './GraphCanvas';
import GraphBrief from './GraphBrief';
import { prepareGraph, graphPositions } from './graphLayout';
const { Text, Paragraph } = Typography;
const CY_STYLE = [
{
selector: 'node',
style: {
'background-color': 'data(color)',
label: 'data(label)',
'font-size': 10,
'text-wrap': 'wrap',
'text-max-width': 120,
'text-valign': 'bottom',
'text-margin-y': 5,
'text-outline-width': 1.5,
width: 26,
height: 26,
'border-width': 2,
'border-color': '#ffffff'
}
},
{
selector: 'node[boundary = 1]',
style: { shape: 'round-rectangle', width: 18, height: 18, opacity: 0.7 }
},
{
selector: 'node:selected',
style: { 'border-color': '#0066ff', 'border-width': 4 }
},
{
selector: 'edge',
style: {
width: 1,
'line-color': '#c9cdd4',
'target-arrow-color': '#c9cdd4',
'target-arrow-shape': 'triangle',
'arrow-scale': 0.7,
'curve-style': 'bezier',
opacity: 0.85
}
},
{
selector: 'edge[projection = "archive"]',
style: { 'line-style': 'dashed', 'line-color': '#d9d9d9' }
},
{
selector: 'edge[projection = "details"]',
style: { 'line-style': 'dotted' }
}
];
function updateLabelColors(cy) {
const { color, backgroundColor } = getComputedStyle(cy.container());
cy.nodes().style({ color, 'text-outline-color': backgroundColor });
}
export default function GraphTab({ id, reloadToken }) {
export default function GraphTab({ id, task, reloadToken, onGoIntents }) {
const t = useT();
const { theme } = useTheme();
const [view, setView] = useState('summary');
const [scope, setScope] = useState('');
const [offset, setOffset] = useState(0);
const [selectedId, setSelectedId] = useState('');
const [showAll, setShowAll] = useState(false);
const [locate, setLocate] = useState(null);
const [node, setNode] = useState(null);
const [relations, setRelations] = useState([]);
const [linksOffset, setLinksOffset] = useState(0);
@ -80,156 +30,85 @@ export default function GraphTab({ id, reloadToken }) {
const [nodeLoading, setNodeLoading] = useState(false);
const [pathView, setPathView] = useState(null);
const [pathLoading, setPathLoading] = useState(false);
const containerRef = useRef(null);
const cyRef = useRef(null);
const selectRef = useRef(() => {});
const nodeRequest = useRef(0);
const graphKey = JSON.stringify([id, view, scope, offset]);
const resource = useResource(
() => api.get(`/deep-assessments/${id}/graph`, { view, scope, offset, limit: 80 }),
async () => ({
key: graphKey,
graph: await api.get(`/deep-assessments/${id}/graph`, { view, scope, offset, limit: 80 })
}),
[id, view, scope, offset, reloadToken]
);
const graph = resource.data;
const nodes = graph?.nodes || [];
const graph = resource.data?.graph;
const model = useMemo(() => prepareGraph(graph), [graph]);
const nodes = [...model.nodes.values()];
const collapsedNodes = model.overview.size ? model.nodes.size - model.overview.size : 0;
const canExpand = model.dense && (collapsedNodes > 0 || model.edges.length > model.backbone.size);
const selectNode = useCallback(async (nodeId, options = {}) => {
const { appendBody = false, appendLinks = false } = options;
if (!nodeId) return;
const { appendBody = false, appendLinks = false, center = false } = options;
const request = ++nodeRequest.current;
setSelectedId(nodeId);
const cy = cyRef.current;
if (cy) {
cy.elements().unselect();
cy.$id(nodeId).select();
if (center) setLocate({ id: nodeId });
if (!appendBody && !appendLinks) {
setNode(null);
setRelations([]);
setPathView(null);
}
setNodeLoading(true);
setPathLoading(false);
setNodeLoading(Boolean(nodeId));
if (!nodeId) return;
try {
const data = await api.get(`/deep-assessments/${id}/graph/node`, {
node_id: nodeId,
offset: appendBody ? bodyOffset : 0,
links_offset: appendLinks ? linksOffset : 0
});
const next = data?.node || null;
setNode(prev => (
appendBody && prev && next && prev.id === next.id
? { ...next, body: `${prev.body || ''}${next.body || ''}` }
: next
));
setBodyOffset(Number(data?.next_offset) || 0);
setBodyMore(Boolean(data?.has_more));
setRelations(prev => (appendLinks ? [...prev, ...(data?.relations || [])] : (data?.relations || [])));
setLinksOffset(Number(data?.relations_next_offset) || 0);
setLinksMore(Boolean(data?.relations_has_more));
setPathView(null);
if (request !== nodeRequest.current) return;
if (!appendLinks) {
const next = data?.node || null;
setNode(prev => (
appendBody && prev && next && prev.id === next.id
? { ...next, body: `${prev.body || ''}${next.body || ''}` }
: next
));
setBodyOffset(Number(data?.next_offset) || 0);
setBodyMore(Boolean(data?.has_more));
}
if (!appendBody) {
setRelations(prev => (appendLinks ? [...prev, ...(data?.relations || [])] : (data?.relations || [])));
setLinksOffset(Number(data?.relations_next_offset) || 0);
setLinksMore(Boolean(data?.relations_has_more));
}
} catch (error) {
toastError(error, '读取节点失败');
if (request === nodeRequest.current) toastError(error, '读取节点失败');
} finally {
setNodeLoading(false);
if (request === nodeRequest.current) setNodeLoading(false);
}
}, [id, bodyOffset, linksOffset]);
useEffect(() => { selectRef.current = selectNode; }, [selectNode]);
// cytoscape 仅在图谱页按需加载,容器高度由页面样式固定。
useEffect(() => {
const source = graph?.nodes || [];
if (!source.length || !containerRef.current) {
if (cyRef.current) {
cyRef.current.destroy();
cyRef.current = null;
}
return undefined;
}
let disposed = false;
let cy = null;
const unique = [];
const seen = new Set();
source.forEach(item => {
if (!seen.has(item.id)) {
seen.add(item.id);
unique.push(item);
}
});
import('cytoscape').then(module => {
const cytoscape = module.default || module;
if (disposed || !containerRef.current) return;
const elements = [
...unique.map(item => ({
data: {
id: item.id,
label: truncateText(item.title || item.id, 32),
kind: item.kind,
state: item.state,
color: GRAPH_KIND_COLOR[item.kind] || '#86909c',
boundary: item.boundary ? 1 : 0
}
})),
...(graph.edges || [])
.filter(edge => seen.has(edge.source) && seen.has(edge.target))
.map((edge, index) => ({
data: {
id: `edge-${index}`,
source: edge.source,
target: edge.target,
relation: edge.relation,
projection: edge.projection || ''
}
}))
];
cy = cytoscape({
container: containerRef.current,
elements,
style: CY_STYLE,
layout: {
name: unique.length > 45 ? 'cose' : 'breadthfirst',
directed: true,
padding: 28,
animate: false,
spacingFactor: 1.2
},
wheelSensitivity: 0.2,
minZoom: 0.15,
maxZoom: 3
});
updateLabelColors(cy);
cy.on('tap', 'node', event => selectRef.current?.(event.target.id()));
cyRef.current = cy;
}).catch(error => {
toastError(error, '图谱渲染失败');
});
return () => {
disposed = true;
if (cy) cy.destroy();
if (cyRef.current === cy) cyRef.current = null;
};
}, [graph]);
useEffect(() => {
if (cyRef.current) updateLabelColors(cyRef.current);
}, [theme]);
const loadPath = async () => {
if (!node) return;
const request = nodeRequest.current;
setPathLoading(true);
try {
const data = await api.get(`/deep-assessments/${id}/evidence-path`, { fact_id: node.id });
setPathView(data);
if (request === nodeRequest.current) setPathView(data);
} catch (error) {
toastError(error, '读取证据路径失败');
if (request === nodeRequest.current) toastError(error, '读取证据路径失败');
} finally {
setPathLoading(false);
if (request === nodeRequest.current) setPathLoading(false);
}
};
const fit = () => cyRef.current?.fit(undefined, 30);
const relayout = () => {
const cy = cyRef.current;
if (!cy) return;
cy.layout({
name: cy.nodes().length > 45 ? 'cose' : 'breadthfirst',
directed: true,
padding: 28,
animate: true,
spacingFactor: 1.2
}).run();
const positions = graphPositions(model);
cy.nodes().positions(node => positions.get(node.id()));
fitGraph(cy);
};
const headExtra = (
@ -246,14 +125,13 @@ export default function GraphTab({ id, reloadToken }) {
onChange={event => { setView(event.target.value); setOffset(0); }}
/>
<Button size="small" onClick={() => { setScope(''); setOffset(0); }} disabled={!scope && offset === 0}>全图概览</Button>
<Button size="small" onClick={fit}>适应画布</Button>
<Button size="small" onClick={relayout}>重新布局</Button>
<Button size="small" onClick={() => resource.reload()} loading={resource.loading}>刷新</Button>
</Space>
);
const nodeOptions = nodes.map(item => ({
value: item.id,
title: item.title || item.id,
label: `${item.boundary ? '引用 · ' : ''}${kindText(t, item.kind)} · ${truncateText(item.title || item.id, 40)}`
}));
@ -261,10 +139,16 @@ export default function GraphTab({ id, reloadToken }) {
<div className="assessment-tab">
<SectionCard
title={t('deepAssessments.graph', null, '探索图')}
description="摘要用于续接;原始观察、执行回执与证据路径可展开查看。点击节点读取原文。"
description="点击节点查看原文与直接关联,放大可查看更多节点名称。"
extra={headExtra}
>
<ErrorBanner error={resource.error} onRetry={() => resource.reload()} />
<GraphBrief
task={task}
t={t}
onIntent={stepId => selectNode(`step:${stepId}`, { center: true })}
onGoIntents={onGoIntents}
/>
<div className="assessment-graph-meta">
<Text type="tertiary">
当前页节点 {graph?.primary_count ?? Math.max(0, nodes.length - 1)} / {graph?.total ?? 0}
@ -282,18 +166,20 @@ export default function GraphTab({ id, reloadToken }) {
{resource.loading && !graph ? <Text type="tertiary">正在读取图谱…</Text> : null}
<div className="assessment-graph-toolbar">
<Select
value={selectedId || ''}
onChange={value => { if (value) selectNode(String(value)); }}
aria-label="搜索图谱节点"
value={model.nodes.has(selectedId) ? selectedId : undefined}
onChange={value => selectNode(value ? String(value) : '', { center: Boolean(value) })}
optionList={nodeOptions}
placeholder="选择节点查看详情"
style={{ width: 320 }}
showClear={false}
placeholder="搜索并定位节点"
className="assessment-graph-search"
filter={(input, option) => `${option.label} ${option.title} ${option.value}`.toLowerCase().includes(input.toLowerCase().trim())}
showClear
/>
<Space>
<Button size="small" disabled={offset === 0} onClick={() => setOffset(value => Math.max(0, value - 80))}>
{t('deepAssessments.previous', null, '上一页')}
</Button>
<Text type="tertiary">偏移 {offset}</Text>
<Text type="tertiary">第 {Math.floor(offset / 80) + 1} 页</Text>
<Button size="small" disabled={!graph?.has_more} onClick={() => setOffset(value => value + 80)}>
{t('deepAssessments.next', null, '下一页')}
</Button>
@ -306,93 +192,120 @@ export default function GraphTab({ id, reloadToken }) {
style={{ padding: 48 }}
/>
) : (
<div className="assessment-graph-layout">
<div ref={containerRef} className="assessment-graph-canvas" role="img" aria-label="探索图" />
<div className="assessment-node-panel" aria-live="polite">
{!selectedId ? (
<Empty title="选择节点" description="点击图中节点或上方下拉框,读取节点原文与证据路径。" style={{ padding: 24 }} />
) : (
<div className="assessment-node-body">
<div className="assessment-node-head">
<Text strong>{node?.title || selectedId}</Text>
<Space spacing={4}>
{node ? <Tag size="small" color="blue">{kindText(t, node.kind)}</Tag> : null}
{node?.state ? <Tag size="small" color="grey">{stateText(t, node.state)}</Tag> : null}
{node?.boundary ? <Tag size="small" color="amber">跨页引用</Tag> : null}
</Space>
</div>
{nodeLoading ? <Text type="tertiary">正在读取节点…</Text> : null}
{node ? (
<>
<Paragraph className="assessment-pre assessment-node-content">{node.body || '—'}</Paragraph>
{bodyMore ? (
<Button size="small" onClick={() => selectNode(node.id, { appendBody: true })} loading={nodeLoading}>
继续读取原文
</Button>
) : null}
<KeyValueList
columns={1}
items={[
{ label: '节点 ID', value: node.id },
{ label: '意图', value: node.step_id || '—' },
{ label: '更新轮次', value: node.updated_round ?? '—' },
{ label: '更新时间', value: formatDateTime(node.updated_at) }
]}
/>
{relations.length ? (
<section className="assessment-section">
<Text strong>关联节点</Text>
<div className="assessment-relations">
{relations.map((relation, index) => (
<Button
key={`${relation.node?.id}-${index}`}
size="small"
theme="borderless"
onClick={() => selectNode(relation.node?.id)}
>
{relation.direction === 'upstream' ? '上游' : '下游'} · {relation.relation} · {truncateText(relation.node?.title, 30)}
</Button>
))}
</div>
{linksMore ? (
<Button size="small" onClick={() => selectNode(node.id, { appendLinks: true })} loading={nodeLoading}>
继续查看关联
</Button>
) : null}
</section>
) : null}
{node.kind === 'fact' ? (
<Button size="small" onClick={loadPath} loading={pathLoading}>查看证据路径</Button>
) : null}
{node.step_id ? (
<Button size="small" theme="borderless" onClick={() => { setScope(node.id); setOffset(0); }}>
展开此节点分支
</Button>
) : null}
{pathView ? (
<section className="assessment-section">
<Text strong>证据路径 · {pathView.title || pathView.root}</Text>
<Text type="tertiary" size="small">
节点 {Array.isArray(pathView.nodes) ? pathView.nodes.length : 0} · 未归属回执 {pathView.unattributed_receipts || 0}
</Text>
<div className="assessment-path-list">
{(pathView.nodes || []).map(item => (
<div key={item.id} className="assessment-path-node">
<Tag size="small">{kindText(t, item.kind)}</Tag>
<Text ellipsis={{ showTooltip: true }}>{item.title || item.id}</Text>
</div>
))}
</div>
<JsonViewer title="证据路径原始数据" value={pathView} collapsed />
</section>
) : null}
<JsonViewer title="节点来源" value={node.source || {}} collapsed />
</>
) : null}
</div>
)}
<>
<div className="assessment-graph-tools">
<Space wrap>
<Button size="small" aria-label="缩小图谱" disabled={!nodes.length} onClick={() => cyRef.current && zoomGraph(cyRef.current, 0.8)}>−</Button>
<Button size="small" aria-label="放大图谱" disabled={!nodes.length} onClick={() => cyRef.current && zoomGraph(cyRef.current, 1.25)}>+</Button>
<Button size="small" disabled={!nodes.length} onClick={() => cyRef.current && fitGraph(cyRef.current)}>适应画布</Button>
<Button size="small" disabled={!nodes.length} onClick={relayout}>重置布局</Button>
</Space>
{canExpand ? (
<Space wrap>
<Text size="small" type="tertiary">
{showAll ? `全部 ${model.edges.length} 条连线` : `主干 ${model.backbone.size} / ${model.edges.length} 条连线`}
{!showAll && collapsedNodes > 0 ? ` · 收起 ${collapsedNodes} 个明细节点` : null}
</Text>
<Button size="small" onClick={() => setShowAll(value => !value)}>{showAll ? '仅看主干' : '显示全部节点与连线'}</Button>
</Space>
) : null}
</div>
</div>
{model.legend.length ? (
<div className="assessment-graph-legend" role="group" aria-label="连线图例">
{model.legend.map(({ label, color }) => (
<span key={label}><i aria-hidden="true" style={{ backgroundColor: color }} />{label}</span>
))}
</div>
) : null}
<div className={`assessment-graph-layout${selectedId ? ' with-details' : ''}`}>
<GraphCanvas model={model} graphKey={resource.data?.key} selectedId={selectedId} showAll={showAll} locate={locate} onSelect={selectNode} cyRef={cyRef} />
{selectedId ? (
<div className="assessment-node-panel" aria-live="polite">
<div className="assessment-node-body">
<div className="assessment-node-head">
<div className="assessment-node-title">
<Text strong>{node?.title || model.nodes.get(selectedId)?.title || selectedId}</Text>
<Button size="small" theme="borderless" onClick={() => selectNode('')}>关闭详情</Button>
</div>
<Space spacing={4}>
{node ? <Tag size="small" color="blue">{kindText(t, node.kind)}</Tag> : null}
{node?.state ? <Tag size="small" color="grey">{stateText(t, node.state)}</Tag> : null}
{node?.boundary ? <Tag size="small" color="amber">跨页引用</Tag> : null}
</Space>
</div>
{nodeLoading ? <Text type="tertiary">正在读取节点…</Text> : null}
{node ? (
<>
<Paragraph className="assessment-pre assessment-node-content">{node.body || '—'}</Paragraph>
{bodyMore ? (
<Button size="small" onClick={() => selectNode(node.id, { appendBody: true })} loading={nodeLoading}>
继续读取原文
</Button>
) : null}
<KeyValueList
columns={1}
items={[
{ label: '节点 ID', value: node.id },
{ label: '意图', value: node.step_id || '—' },
{ label: '更新轮次', value: node.updated_round ?? '—' },
{ label: '更新时间', value: formatDateTime(node.updated_at) }
]}
/>
{relations.length ? (
<section className="assessment-section">
<Text strong>关联节点</Text>
<div className="assessment-relations">
{relations.map((relation, index) => (
<Button
key={`${relation.node?.id}-${index}`}
size="small"
theme="borderless"
onClick={() => relation.node?.id && selectNode(relation.node.id, { center: true })}
>
{relation.direction === 'upstream' ? '上游' : '下游'} · {relation.relation} · {truncateText(relation.node?.title, 30)}
</Button>
))}
</div>
{linksMore ? (
<Button size="small" onClick={() => selectNode(node.id, { appendLinks: true })} loading={nodeLoading}>
继续查看关联
</Button>
) : null}
</section>
) : null}
{node.kind === 'fact' ? (
<Button size="small" onClick={loadPath} loading={pathLoading}>查看证据路径</Button>
) : null}
{node.step_id ? (
<Button size="small" theme="borderless" onClick={() => { setScope(node.id); setOffset(0); }}>
展开此节点分支
</Button>
) : null}
{pathView ? (
<section className="assessment-section">
<Text strong>证据路径 · {pathView.title || pathView.root}</Text>
<Text type="tertiary" size="small">
节点 {Array.isArray(pathView.nodes) ? pathView.nodes.length : 0} · 未归属回执 {pathView.unattributed_receipts || 0}
</Text>
<div className="assessment-path-list">
{(pathView.nodes || []).map(item => (
<div key={item.id} className="assessment-path-node">
<Tag size="small">{kindText(t, item.kind)}</Tag>
<Text ellipsis={{ showTooltip: true }}>{item.title || item.id}</Text>
</div>
))}
</div>
<JsonViewer title="证据路径原始数据" value={pathView} collapsed />
</section>
) : null}
<JsonViewer title="节点来源" value={node.source || {}} collapsed />
</>
) : null}
</div>
</div>
) : null}
</div>
</>
)}
</SectionCard>
</div>

View File

@ -348,7 +348,7 @@ export default function Workbench({ id, tab, criterion, evidencePath, evidenceSt
) : activeTab === 'assets' ? (
<AssetsTab id={id} task={task} observation={observation} reloadToken={reloadToken} />
) : activeTab === 'graph' ? (
<GraphTab id={id} reloadToken={reloadToken} />
<GraphTab id={id} task={task} reloadToken={reloadToken} onGoIntents={() => onTabChange?.('intents')} />
) : activeTab === 'findings' ? (
<FindingsTab id={id} task={task} reloadToken={reloadToken} />
) : activeTab === 'acceptance' ? (

View File

@ -0,0 +1,154 @@
const RELATION_STYLES = [
{ label: '规划与依赖', color: '#548df0', relations: ['plans', 'depends_on'] },
{ label: '产出与证据', color: '#24aa94', relations: ['produces', 'supports', 'derives', 'reviews'] },
{ label: '线索与引用', color: '#aa78e8', relations: ['guides', 'informs'] },
{ label: '执行与记录', color: '#dc913a', relations: ['executes', 'records', 'summarizes'] },
{ label: '归档与其他', color: '#8b9bb3', relations: [] }
];
const isDetail = node => node.boundary || ['receipt', 'observation', 'memory'].includes(node.kind);
function edgePriority(edge, nodes) {
const source = nodes.get(edge.source);
const target = nodes.get(edge.target);
if (edge.projection) return 4;
if (source.kind === 'step' && source.step_id && source.step_id === target.step_id) return 0;
if (['plans', 'depends_on', 'contains', 'archives'].includes(edge.relation)) return 1;
if (['informs', 'supports', 'derives'].includes(edge.relation)) return 3;
return 2;
}
function hasUpstream(upstream, start, target) {
const pending = [start];
const seen = new Set();
while (pending.length) {
const id = pending.pop();
if (id === target) return true;
if (seen.has(id)) continue;
seen.add(id);
pending.push(...upstream.get(id));
}
return false;
}
/** Pick real parent edges for positioning. Keep feedback and extra relations for inspection. */
export function prepareGraph(graph) {
const nodes = new Map((graph?.nodes || []).map(node => [node.id, node]));
const styles = new Set();
const edges = (graph?.edges || [])
.filter(edge => nodes.has(edge.source) && nodes.has(edge.target))
.map((edge, index) => {
const style = RELATION_STYLES.find(item => item.relations.includes(edge.relation)) || RELATION_STYLES.at(-1);
styles.add(style);
return { ...edge, id: `edge-${index}`, color: style.color };
});
const parents = new Map();
const ordered = edges.map(edge => ({ edge, priority: edgePriority(edge, nodes) }));
ordered.sort((a, b) => a.priority - b.priority
|| Number(Boolean(nodes.get(a.edge.source).boundary)) - Number(Boolean(nodes.get(b.edge.source).boundary))
|| a.edge.source.localeCompare(b.edge.source)
|| a.edge.target.localeCompare(b.edge.target)
|| (a.edge.relation || '').localeCompare(b.edge.relation || ''));
const layoutEdges = new Set();
const backbone = new Set();
for (const { edge } of ordered) {
const target = nodes.get(edge.target);
if (target.kind === 'goal' || parents.has(edge.target)) continue;
let ancestor = edge.source;
while (ancestor && ancestor !== edge.target) ancestor = parents.get(ancestor);
if (ancestor === edge.target) continue;
parents.set(edge.target, edge.source);
layoutEdges.add(edge.id);
if (!isDetail(target)) backbone.add(edge.id);
}
const upstream = new Map([...nodes.keys()].map(id => [id, new Set()]));
for (const [target, source] of parents) upstream.get(target).add(source);
for (const { edge } of ordered) {
if (edge.relation !== 'depends_on' || edge.projection || layoutEdges.has(edge.id)) continue;
if (nodes.get(edge.target).kind === 'goal' || hasUpstream(upstream, edge.source, edge.target)) continue;
upstream.get(edge.target).add(edge.source);
layoutEdges.add(edge.id);
if (!isDetail(nodes.get(edge.target))) backbone.add(edge.id);
}
const overview = new Set([...nodes.values()].filter(node => !isDetail(node)).map(node => node.id));
for (const edge of edges) {
if (backbone.has(edge.id)) {
overview.add(edge.source);
overview.add(edge.target);
}
}
return {
nodes,
edges,
upstream,
layoutEdges,
backbone,
overview,
legend: RELATION_STYLES.filter(style => styles.has(style)),
dense: nodes.size > 20 || edges.length > nodes.size * 1.5
};
}
export const GRAPH_COLUMN_GAP = 168;
const GRAPH_LEVEL_GAP = 36;
export function graphPositions({ nodes, upstream }) {
const depths = new Map();
const levels = [];
const hasGoal = [...nodes.values()].some(node => node.kind === 'goal');
const depthOf = id => {
if (!depths.has(id)) {
const parents = upstream.get(id);
const depth = parents.size
? Math.max(...[...parents].map(depthOf)) + 1
: Number(hasGoal && nodes.get(id).kind !== 'goal');
depths.set(id, depth);
}
return depths.get(id);
};
for (const id of nodes.keys()) {
const depth = depthOf(id);
(levels[depth] ??= []).push(id);
}
const positions = new Map();
const rowLimit = Math.min(17, Math.max(3, Math.ceil(Math.sqrt(nodes.size * 1.6))));
let x = 0;
for (const level of levels) {
// Ordering by the mean of incoming positions keeps connected branches together.
const weighted = level.map(id => {
const linked = upstream.get(id);
const center = linked.size
? [...linked].reduce((sum, parent) => sum + positions.get(parent).y, 0) / linked.size
: 0;
return { id, center };
});
weighted.sort((a, b) => a.center - b.center);
const ordered = weighted.map(node => node.id);
// Keep sibling order. Put dense execution records to the right of the decisions
// they accompany so the main paths stay together.
const groups = ordered.length > rowLimit
? [ordered.filter(id => !isDetail(nodes.get(id))), ordered.filter(id => isDetail(nodes.get(id)))]
: [ordered];
let columnIndex = 0;
for (const group of groups) {
if (!group.length) continue;
const columns = Math.ceil(group.length / rowLimit);
const columnSize = Math.ceil(group.length / columns);
for (let start = 0; start < group.length; start += columnSize) {
const column = group.slice(start, start + columnSize);
// Offset wrapped columns to keep long connectors from running through other markers.
const stagger = [0, 23, -23, 35, -35][columnIndex % 5];
column.forEach((id, index) => positions.set(id, {
x,
y: (index - (column.length - 1) / 2) * 76 + stagger
}));
x += GRAPH_COLUMN_GAP;
columnIndex += 1;
}
}
x += GRAPH_LEVEL_GAP;
}
return positions;
}

View File

@ -185,6 +185,73 @@
}
/* 图谱 */
.assessment-graph-brief {
margin-bottom: 12px;
border: 1px solid var(--semi-color-border);
border-radius: var(--semi-border-radius-medium);
background: var(--semi-color-bg-1);
}
.assessment-graph-brief > summary {
padding: 8px 12px;
cursor: pointer;
}
.assessment-graph-brief-counts {
margin-inline-start: 10px;
}
.assessment-graph-brief-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 16px;
padding: 12px;
border-top: 1px solid var(--semi-color-border);
}
.assessment-graph-brief-content {
display: flex;
flex-direction: column;
align-items: flex-start;
min-width: 0;
gap: 6px;
overflow-wrap: anywhere;
}
.assessment-graph-summary {
max-height: 280px;
overflow-y: auto;
}
.assessment-graph-intents {
list-style: none;
width: 100%;
margin: 0;
padding: 0;
}
.assessment-graph-intents li {
padding: 4px 0;
border-top: 1px solid var(--semi-color-border);
}
.assessment-graph-intent-head {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 6px;
}
.assessment-graph-intent-head button {
max-width: 100%;
}
.assessment-graph-intent-head .semi-button-content {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.assessment-graph-meta {
display: flex;
flex-wrap: wrap;
@ -194,7 +261,8 @@
margin-bottom: 8px;
}
.assessment-graph-toolbar {
.assessment-graph-toolbar,
.assessment-graph-tools {
display: flex;
flex-wrap: wrap;
align-items: center;
@ -203,25 +271,100 @@
margin-bottom: 8px;
}
.assessment-graph-layout {
display: grid;
grid-template-columns: minmax(0, 1fr) 340px;
gap: 12px;
align-items: stretch;
.assessment-graph-legend {
display: flex;
flex-wrap: wrap;
gap: 5px 16px;
margin: 2px 0 10px;
color: var(--semi-color-text-1);
font-size: 12px;
}
.assessment-graph-canvas {
height: 520px;
width: 100%;
.assessment-graph-legend span {
display: inline-flex;
align-items: center;
gap: 6px;
}
.assessment-graph-legend i {
width: 15px;
height: 2px;
border-radius: 2px;
}
.assessment-graph-search {
width: min(100%, 340px);
}
.assessment-graph-layout {
--assessment-graph-height: clamp(480px, 66svh, 720px);
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 12px;
align-items: start;
}
.assessment-graph-layout.with-details {
grid-template-columns: minmax(0, 1fr) minmax(300px, 350px);
}
.assessment-graph-viewport {
position: relative;
height: var(--assessment-graph-height);
overflow: hidden;
border: 1px solid var(--semi-color-border);
border-radius: var(--semi-border-radius-medium);
background: var(--semi-color-bg-2);
background-image: radial-gradient(var(--semi-color-border) 1px, transparent 1px);
background-size: 20px 20px;
}
.assessment-graph-canvas,
.assessment-graph-labels {
position: absolute;
inset: 0;
direction: ltr;
}
.assessment-graph-labels {
pointer-events: none;
}
.assessment-graph-label-leader {
position: absolute;
width: 1px;
background: var(--semi-color-text-2);
opacity: 0.55;
}
.assessment-graph-label {
position: absolute;
height: 22px;
padding: 0 6px;
border: 1px solid var(--semi-color-border);
border-radius: var(--semi-border-radius-small);
background: var(--semi-color-bg-1);
color: var(--semi-color-text-0);
font-family: inherit;
font-size: 12px;
line-height: 20px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
pointer-events: auto;
cursor: pointer;
}
.assessment-graph-label:hover,
.assessment-graph-label:focus-visible,
.assessment-graph-label[aria-pressed="true"] {
border-color: var(--semi-color-primary);
color: var(--semi-color-primary);
}
.assessment-node-panel {
height: 520px;
height: var(--assessment-graph-height);
min-width: 0;
overflow-y: auto;
border: 1px solid var(--semi-color-border);
border-radius: var(--semi-border-radius-medium);
@ -229,6 +372,18 @@
padding: 12px;
}
.assessment-node-title {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 8px;
overflow-wrap: anywhere;
}
.assessment-node-title > button {
flex-shrink: 0;
}
.assessment-node-body {
display: flex;
flex-direction: column;
@ -278,7 +433,7 @@
}
@media (max-width: 1180px) {
.assessment-graph-layout {
.assessment-graph-layout.with-details {
grid-template-columns: minmax(0, 1fr);
}
@ -289,12 +444,13 @@
}
@media (max-width: 720px) {
.assessment-form-grid {
.assessment-form-grid,
.assessment-graph-brief-grid {
grid-template-columns: minmax(0, 1fr);
}
.assessment-graph-canvas {
height: 420px;
.assessment-graph-layout {
--assessment-graph-height: clamp(390px, 58svh, 500px);
}
}

View File

@ -1017,32 +1017,144 @@ test('deep assessment: graph label color follows the theme with the graph open',
nodes: [{ id: 'goal', kind: 'goal', title }, { id: 'note', kind: 'observation', title: '示例观察记录' }],
edges: [{ source: 'goal', target: 'note' }]
} });
await page.addInitScript(nodeTitle => {
for (const context of [CanvasRenderingContext2D, globalThis.OffscreenCanvasRenderingContext2D]) {
if (!context) continue;
const fillText = context.prototype.fillText;
context.prototype.fillText = function (text, ...args) {
if (text === nodeTitle) window.graphLabelColor = this.fillStyle;
return fillText.call(this, text, ...args);
};
}
}, title);
await page.goto(`/static/app/#/deep-assessments?id=${ASSESSMENT.id}&tab=graph`);
const main = await ready(page);
const canvas = main.locator('.assessment-graph-canvas canvas').first();
await expect(canvas).toBeAttached();
await expect.poll(() => page.evaluate(() => window.graphLabelColor)).toBe('#192438');
const nodeLabel = main.getByRole('group', { name: '探索图' }).getByRole('button', { name: title });
await expect(nodeLabel).toHaveCSS('color', 'rgb(25, 36, 56)');
const reads = mockApi.calls('GET', `${path}/graph`).length;
await button(page.locator('.cs-header'), label('theme.system', '跟随系统')).click();
await page.getByRole('menuitem', { name: label('theme.dark', '暗色'), exact: true }).click();
await expect(page.locator('html')).toHaveAttribute('data-theme', 'dark');
await expect.poll(() => page.evaluate(() => window.graphLabelColor)).toBe('#e8edf6');
await expect(nodeLabel).toHaveCSS('color', 'rgb(232, 237, 246)');
expect(mockApi.calls('GET', `${path}/graph`)).toHaveLength(reads);
await screenshot(page, testInfo, 'assessment-graph-dark');
expect(mockApi.writes()).toEqual([]);
});
test('deep assessment: dense graph keeps labels readable and locates a cross-page node', async ({ page, mockApi }, testInfo) => {
const path = `/api/deep-assessments/${ASSESSMENT.id}`;
const goal = { id: 'goal', kind: 'goal', title: '示例测评目标' };
const steps = Array.from({ length: 20 }, (_, i) => ({
id: `step:${i}`, step_id: String(i), kind: 'step', title: `探索意图 ${i + 1}`
}));
const facts = Array.from({ length: 60 }, (_, i) => ({
id: `fact:${i}`, step_id: String(i % steps.length), kind: 'fact',
title: `已观察到的第 ${i + 1} 条事实记录及其关联说明`
}));
const receipts = Array.from({ length: 80 }, (_, i) => ({
id: `receipt:${i}`, step_id: String(i % steps.length), kind: 'receipt', boundary: true,
title: `跨页引用中的回执说明和完整执行记录${'示例'.repeat(18)} 唯一编号 ${i + 1}`, body: '合成回执原文'
}));
const edges = [
...steps.map(step => ({ source: goal.id, target: step.id, relation: 'plans' })),
...facts.map(fact => ({ source: `step:${fact.step_id}`, target: fact.id, relation: 'produces' })),
...receipts.map(receipt => ({ source: `step:${receipt.step_id}`, target: receipt.id, relation: 'executes' })),
...facts.map((fact, i) => ({ source: receipts[i].id, target: fact.id, relation: 'supports' })),
...facts.map((fact, i) => ({ source: fact.id, target: steps[(i + 1) % steps.length].id, relation: 'informs' }))
];
mockApi.respond('GET', `${path}/events`, { json: { events: [] } });
mockApi.respond('GET', `${path}/graph`, { json: {
nodes: [goal, ...steps, ...facts, ...receipts], edges,
primary_count: 80, total: 160, boundary_total: 80, has_more: true
} });
const receipt = receipts.at(-1);
mockApi.respond('GET', `${path}/graph/node`, { json: {
node: receipt,
relations: [{ node: steps.at(-1), relation: 'executes', direction: 'upstream' }]
} });
await page.addInitScript(() => localStorage.setItem('cyberstrike-theme', 'dark'));
await page.goto(`/static/app/#/deep-assessments?id=${ASSESSMENT.id}&tab=graph`);
const main = await ready(page);
const graph = main.getByRole('group', { name: '探索图' });
const labels = graph.getByRole('button');
await expect(graph.getByRole('button', { name: goal.title, exact: true })).toBeVisible();
expect(await labels.count()).toBeGreaterThan(5);
expect(await labels.count()).toBeLessThan(25);
const bounds = await labels.evaluateAll(items => items.map(item => {
const { left, top, right, bottom } = item.getBoundingClientRect();
return { left, top, right, bottom, size: getComputedStyle(item).fontSize };
}));
for (const [i, box] of bounds.entries()) {
expect(box.size).toBe('12px');
for (const other of bounds.slice(i + 1)) {
expect(box.left < other.right && box.right > other.left && box.top < other.bottom && box.bottom > other.top).toBe(false);
}
}
await expect(main.locator('.assessment-node-panel')).toHaveCount(0);
await expect(main.getByText('主干 80 / 280 条连线 · 收起 80 个明细节点')).toBeVisible();
const goalLabel = graph.getByRole('button', { name: goal.title, exact: true });
const firstIntent = graph.getByRole('button', { name: /^探索意图/ }).first();
expect((await goalLabel.boundingBox()).x).toBeLessThan((await firstIntent.boundingBox()).x);
const legend = main.getByRole('group', { name: '连线图例' });
await expect(legend.getByText('规划与依赖')).toBeVisible();
await expect(legend.getByText('产出与证据')).toBeVisible();
await graph.screenshot({ path: testInfo.outputPath('assessment-graph-dense-overview.png') });
const reads = mockApi.calls('GET', `${path}/graph`).length;
await button(main, '显示全部节点与连线').click();
await expect(main.getByText('全部 280 条连线')).toBeVisible();
await button(main, '仅看主干').click();
expect(mockApi.calls('GET', `${path}/graph`)).toHaveLength(reads);
await main.getByText('搜索并定位节点', { exact: true }).click();
await main.getByRole('combobox').getByRole('textbox').fill('唯一编号 80');
await page.getByRole('option', { name: /跨页引用/ }).click();
await expect(main.getByText('合成回执原文')).toBeVisible();
const selected = graph.getByRole('button', { name: receipt.title, pressed: true });
await expect(selected).toBeVisible();
await expect(graph.getByRole('button', { name: goal.title, exact: true })).toHaveCount(0);
expect(new URLSearchParams(mockApi.calls('GET', `${path}/graph/node`).at(-1).query).get('node_id')).toBe(receipt.id);
const position = await selected.boundingBox();
await main.locator('.cs-section-card').getByRole('button', { name: '刷新', exact: true }).click();
await expect.poll(() => mockApi.calls('GET', `${path}/graph`).length).toBe(reads + 1);
await expect.poll(async () => {
const restored = await selected.boundingBox();
return restored ? Math.hypot(restored.x - position.x, restored.y - position.y) : Infinity;
}).toBeLessThan(1);
await screenshot(page, testInfo, 'assessment-graph-dense-selection');
await button(main, '关闭详情').click();
await expect(main.locator('.assessment-node-panel')).toHaveCount(0);
await page.setViewportSize({ width: 390, height: 844 });
await button(main, '适应画布').click();
await expect(graph.getByRole('button', { name: goal.title, exact: true })).toBeVisible();
await assertNoOverflow(page);
await graph.screenshot({ path: testInfo.outputPath('assessment-graph-dense-mobile.png') });
expect(mockApi.writes()).toEqual([]);
});
test('deep assessment: graph brief reflects saved intents and the current task summary', async ({ page, mockApi }) => {
await page.setViewportSize({ width: 390, height: 844 });
const path = `/api/deep-assessments/${ASSESSMENT.id}`;
const first = { id: 'notes', title: '整理已有记录', status: 'completed' };
const second = { id: 'summary', title: '归并阶段结果', status: 'pending', depends_on: [first.id] };
const task = { ...ASSESSMENT, steps: [first, second], summary: '已整理首批记录,阶段结果待归并。' };
mockApi.respond('GET', path, { json: { task } });
mockApi.respond('GET', `${path}/events`, { json: { events: [] } });
const node = { id: `step:${second.id}`, kind: 'step', title: second.title, body: '已保存的意图详情' };
mockApi.respond('GET', `${path}/graph`, { json: { nodes: [node], edges: [] } });
mockApi.respond('GET', `${path}/graph/node`, { json: { node } });
await page.goto(`/static/app/#/deep-assessments?id=${ASSESSMENT.id}&tab=graph`);
const main = await ready(page);
const brief = main.locator('.assessment-graph-brief');
await expect(brief.getByText('2 个意图 · 1 个已完成')).toBeVisible();
await brief.locator('summary').click();
await expect(brief.getByText(task.objective)).toBeVisible();
await expect(brief.getByText(`上游依赖 · ${first.title}`)).toBeVisible();
await expect(brief.getByText(task.summary)).toBeVisible();
await button(brief, second.title).click();
await expect(main.getByText(node.body)).toBeVisible();
const updated = { ...task, steps: [first, { ...second, status: 'completed' }], summary: '已归并本阶段结果。' };
mockApi.respond('GET', path, { json: { task: updated } });
await main.getByRole('button', { name: 'refresh 刷新', exact: true }).click();
await expect(brief.getByText('2 个意图 · 2 个已完成')).toBeVisible();
await expect(brief.getByText(updated.summary)).toBeVisible();
await assertNoOverflow(page);
expect(mockApi.writes()).toEqual([]);
});
test('deep assessment: graph switches views and resets pagination on a narrow screen', async ({ page, mockApi }) => {
const apiPath = `/api/deep-assessments/${ASSESSMENT.id}`;
mockApi.respond('GET', `${apiPath}/events`, { json: { events: [] } });

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{F as r,H as i,L as a,M as o,W as s,at as c,ct as l,i as u,ot as d,wt as f,xt as p}from"./semi-DCiGoqD2.js";import{F as m,I as h,P as g,a as _,b as v,c as y,d as b,f as x,l as S,m as C,p as w,s as T,u as E,x as D,y as O}from"./index-DhiAuEy4.js";var k=e(t(),1),A=e(n(),1),{Text:j}=s;function M(){let e=g(),{hasPermission:t}=m(),n=t(`agents:write`),s=t(`agents:delete`),[M,N]=(0,k.useState)(``),[P,F]=(0,k.useState)(null),[I,L]=(0,k.useState)(null),[R,z]=(0,k.useState)(!1),B=_(()=>h.get(`/multi-agent/markdown-agents`),[]),V=(Array.isArray(B.data?.agents)?B.data.agents:[]).filter(e=>{if(!M)return!0;let t=M.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),H=async e=>{try{F(await h.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){v(e,`读取智能体失败`)}},U=async()=>{let e=await I.form.validate();z(!0);try{await h.post(`/multi-agent/markdown-agents`,{filename:e.filename?.trim()||``,name:e.name.trim(),description:e.description?.trim()||``,instruction:e.instruction,kind:e.kind||`sub`,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean)}),D(`智能体已保存`),L(null),B.reload()}catch(e){v(e,`保存智能体失败`)}finally{z(!1)}},W=e=>O({title:`删除智能体「${e.name||e.filename}」?`,onOk:async()=>{await h.del(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`),D(`已删除`),B.reload()}});return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(w,{title:e(`agents.title`,null,`智能体管理`),description:B.data?.dir?`目录:${B.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,A.jsxs)(r,{children:[(0,A.jsx)(a,{icon:(0,A.jsx)(d,{}),onClick:()=>B.reload(),loading:B.loading,children:`刷新`}),n&&(0,A.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(l,{}),onClick:()=>L({record:null,form:{}}),children:`新建智能体`})]})}),B.data?.error&&(0,A.jsx)(S,{error:B.data.error}),(0,A.jsxs)(C,{title:`智能体(${V.length})`,children:[(0,A.jsx)(S,{error:B.error,onRetry:()=>B.reload()}),(0,A.jsx)(T,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,A.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,A.jsxs)(r,{children:[(0,A.jsx)(j,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,A.jsx)(o,{size:`small`,color:`purple`,children:`编排器`})]}),(0,A.jsx)(j,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,A.jsx)(o,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,A.jsx)(j,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,A.jsxs)(r,{children:[(0,A.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>H(t),children:`详情`}),n&&(0,A.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,A.jsx)(p,{}),onClick:()=>L({record:t,form:{}})}),s&&(0,A.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,A.jsx)(f,{}),onClick:()=>W(t)})]})}],dataSource:V,rowKey:`filename`,loading:B.loading,pagination:{pageSize:20},toolbar:(0,A.jsx)(i,{prefix:(0,A.jsx)(c,{}),value:M,onChange:N,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,A.jsx)(y,{title:I?.record?`编辑智能体`:`新建智能体`,visible:!!I,onCancel:()=>L(null),onOk:U,confirmLoading:R,width:760,children:(0,A.jsxs)(u,{getFormApi:e=>L(t=>t&&{...t,form:e}),initValues:I?.record?{filename:I.record.filename,name:I.record.name,description:I.record.description,kind:I.record.kind||`sub`}:{kind:`sub`},children:[(0,A.jsx)(u.Input,{field:`filename`,label:`文件名(留空自动生成)`,placeholder:`例如 recon.md`}),(0,A.jsx)(u.Input,{field:`name`,label:`名称`,rules:[{required:!0,message:`请输入名称`}]}),(0,A.jsx)(u.Input,{field:`description`,label:`描述`}),(0,A.jsx)(u.Select,{field:`kind`,label:`类型`,optionList:[{value:`sub`,label:`子智能体`},{value:`orchestrator`,label:`编排器`},{value:`plan_execute`,label:`计划执行`}]}),(0,A.jsx)(u.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::tool`}),(0,A.jsx)(u.TextArea,{field:`instruction`,label:`指令(Markdown)`,autosize:{minRows:8,maxRows:20}})]})},I?.record?.filename||`new-agent`),(0,A.jsx)(y,{title:P?.name||`智能体详情`,visible:!!P,onCancel:()=>F(null),width:720,children:P&&(0,A.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,A.jsx)(b,{items:[{label:`文件名`,value:P.filename},{label:`ID`,value:P.id},{label:`类型`,value:P.kind},{label:`绑定角色`,value:P.bind_role||`—`},{label:`最大迭代`,value:P.max_iterations??`—`},{label:`工具`,value:Array.isArray(P.tools)&&P.tools.length?P.tools.join(`、`):`—`}]}),(0,A.jsx)(x,{content:P.instruction||P.raw||``}),(0,A.jsx)(E,{value:P.raw||P,title:`原始 Markdown`,collapsed:!0})]})})]})}export{M as default};
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,at as c,ct as l,i as u,ot as d,wt as f,xt as p}from"./semi-DCiGoqD2.js";import{F as m,I as h,P as g,a as _,b as v,c as y,d as b,f as x,l as S,m as C,p as w,s as T,u as E,x as D,y as O}from"./index-CexI4Ljq.js";var k=e(t(),1),A=e(n(),1),{Text:j}=s;function M(){let e=g(),{hasPermission:t}=m(),n=t(`agents:write`),s=t(`agents:delete`),[M,N]=(0,k.useState)(``),[P,F]=(0,k.useState)(null),[I,L]=(0,k.useState)(null),[R,z]=(0,k.useState)(!1),B=_(()=>h.get(`/multi-agent/markdown-agents`),[]),V=(Array.isArray(B.data?.agents)?B.data.agents:[]).filter(e=>{if(!M)return!0;let t=M.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),H=async e=>{try{F(await h.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){v(e,`读取智能体失败`)}},U=async()=>{let e=await I.form.validate();z(!0);try{await h.post(`/multi-agent/markdown-agents`,{filename:e.filename?.trim()||``,name:e.name.trim(),description:e.description?.trim()||``,instruction:e.instruction,kind:e.kind||`sub`,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean)}),D(`智能体已保存`),L(null),B.reload()}catch(e){v(e,`保存智能体失败`)}finally{z(!1)}},W=e=>O({title:`删除智能体「${e.name||e.filename}」?`,onOk:async()=>{await h.del(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`),D(`已删除`),B.reload()}});return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(w,{title:e(`agents.title`,null,`智能体管理`),description:B.data?.dir?`目录:${B.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,A.jsxs)(r,{children:[(0,A.jsx)(a,{icon:(0,A.jsx)(d,{}),onClick:()=>B.reload(),loading:B.loading,children:`刷新`}),n&&(0,A.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(l,{}),onClick:()=>L({record:null,form:{}}),children:`新建智能体`})]})}),B.data?.error&&(0,A.jsx)(S,{error:B.data.error}),(0,A.jsxs)(C,{title:`智能体(${V.length})`,children:[(0,A.jsx)(S,{error:B.error,onRetry:()=>B.reload()}),(0,A.jsx)(T,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,A.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,A.jsxs)(r,{children:[(0,A.jsx)(j,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,A.jsx)(o,{size:`small`,color:`purple`,children:`编排器`})]}),(0,A.jsx)(j,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,A.jsx)(o,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,A.jsx)(j,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,A.jsxs)(r,{children:[(0,A.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>H(t),children:`详情`}),n&&(0,A.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,A.jsx)(p,{}),onClick:()=>L({record:t,form:{}})}),s&&(0,A.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,A.jsx)(f,{}),onClick:()=>W(t)})]})}],dataSource:V,rowKey:`filename`,loading:B.loading,pagination:{pageSize:20},toolbar:(0,A.jsx)(i,{prefix:(0,A.jsx)(c,{}),value:M,onChange:N,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,A.jsx)(y,{title:I?.record?`编辑智能体`:`新建智能体`,visible:!!I,onCancel:()=>L(null),onOk:U,confirmLoading:R,width:760,children:(0,A.jsxs)(u,{getFormApi:e=>L(t=>t&&{...t,form:e}),initValues:I?.record?{filename:I.record.filename,name:I.record.name,description:I.record.description,kind:I.record.kind||`sub`}:{kind:`sub`},children:[(0,A.jsx)(u.Input,{field:`filename`,label:`文件名(留空自动生成)`,placeholder:`例如 recon.md`}),(0,A.jsx)(u.Input,{field:`name`,label:`名称`,rules:[{required:!0,message:`请输入名称`}]}),(0,A.jsx)(u.Input,{field:`description`,label:`描述`}),(0,A.jsx)(u.Select,{field:`kind`,label:`类型`,optionList:[{value:`sub`,label:`子智能体`},{value:`orchestrator`,label:`编排器`},{value:`plan_execute`,label:`计划执行`}]}),(0,A.jsx)(u.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::tool`}),(0,A.jsx)(u.TextArea,{field:`instruction`,label:`指令(Markdown)`,autosize:{minRows:8,maxRows:20}})]})},I?.record?.filename||`new-agent`),(0,A.jsx)(y,{title:P?.name||`智能体详情`,visible:!!P,onCancel:()=>F(null),width:720,children:P&&(0,A.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,A.jsx)(b,{items:[{label:`文件名`,value:P.filename},{label:`ID`,value:P.id},{label:`类型`,value:P.kind},{label:`绑定角色`,value:P.bind_role||`—`},{label:`最大迭代`,value:P.max_iterations??`—`},{label:`工具`,value:Array.isArray(P.tools)&&P.tools.length?P.tools.join(`、`):`—`}]}),(0,A.jsx)(x,{content:P.instruction||P.raw||``}),(0,A.jsx)(E,{value:P.raw||P,title:`原始 Markdown`,collapsed:!0})]})})]})}export{M as default};

View File

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

View File

@ -1 +1 @@
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{F as t,L as n,W as r}from"./semi-DCiGoqD2.js";import{E as i,P as a,k as o}from"./index-DhiAuEy4.js";import"./c2-shared-CbaqmFYG.js";import{t as s}from"./react-QV7DAAIx.js";var c=e(s(),1),{Text:l}=r,u=[{value:`http_beacon`,label:`HTTP Beacon`},{value:`https_beacon`,label:`HTTPS Beacon`},{value:`tcp_reverse`,label:`TCP 反向`},{value:`websocket`,label:`WebSocket`}],d={running:`运行中`,stopped:`已停止`,error:`异常`},f={tcp_reverse:[{value:`bash`,label:`Bash (/dev/tcp)`},{value:`nc`,label:`Netcat (-e)`},{value:`nc_mkfifo`,label:`Netcat (mkfifo)`},{value:`python`,label:`Python`},{value:`perl`,label:`Perl`},{value:`powershell`,label:`PowerShell`}],http_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],https_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],websocket:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}]},p=[{value:`shell`,label:`shell`},{value:`exec`,label:`exec`},{value:`ls`,label:`ls`},{value:`pwd`,label:`pwd`},{value:`cd`,label:`cd`},{value:`ps`,label:`ps`},{value:`kill_proc`,label:`kill_proc`},{value:`download`,label:`download`},{value:`upload`,label:`upload`},{value:`screenshot`,label:`screenshot`},{value:`sleep`,label:`sleep`},{value:`exit`,label:`exit`},{value:`self_delete`,label:`self_delete`},{value:`port_fwd`,label:`port_fwd`},{value:`socks_start`,label:`socks_start`},{value:`socks_stop`,label:`socks_stop`},{value:`load_assembly`,label:`load_assembly`},{value:`persist`,label:`persist`}],m=[{value:`queued`,label:`队列中`},{value:`sent`,label:`已发送`},{value:`running`,label:`执行中`},{value:`success`,label:`成功`},{value:`failed`,label:`失败`},{value:`cancelled`,label:`已取消`}],h=[{value:`info`,label:`信息`},{value:`warn`,label:`警告`},{value:`critical`,label:`严重`}],g=[{value:`listener`,label:`监听器`},{value:`session`,label:`会话`},{value:`task`,label:`任务`},{value:`payload`,label:`Payload`},{value:`opsec`,label:`OPSEC`}],_=[{value:`active`,label:`活跃`},{value:`sleeping`,label:`休眠`},{value:`dead`,label:`离线`},{value:`killed`,label:`已终止`}],v=[{value:`15m`,label:`最近15分钟`,ms:9e5},{value:`1h`,label:`最近1小时`,ms:36e5},{value:`24h`,label:`最近24小时`,ms:864e5},{value:`7d`,label:`最近7天`,ms:6048e5},{value:`all`,label:`全部`,ms:0}];function y(e){let t=v.find(t=>t.value===e);return!t||!t.ms?``:new Date(Date.now()-t.ms).toISOString()}function b({value:e,onChange:r,ns:i=`tasks`}){let o=a();return(0,c.jsxs)(t,{spacing:6,wrap:!0,className:`c2-time-presets`,children:[(0,c.jsx)(l,{type:`tertiary`,size:`small`,children:o(`c2.tasks.timePresets`,null,`快捷`)}),v.map(t=>(0,c.jsx)(n,{size:`small`,theme:t.value===e?`solid`:`borderless`,type:t.value===e?`primary`:`tertiary`,onClick:()=>r(t.value),children:o(`c2.${i}.preset${t.value===`all`?`All`:t.value}`,null,t.label)},t.value))]})}function x(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`—`:t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}秒`:`${Math.round(t/6e4)}分钟`}function S({value:e}){let t=a();return e?(0,c.jsx)(`span`,{className:`c2-time-text`,title:i(e),children:o(e,t)}):(0,c.jsx)(l,{type:`tertiary`,children:`—`})}var C={running:`green`,stopped:`grey`,error:`red`},w={queued:`amber`,sent:`blue`,running:`blue`,success:`green`,failed:`red`,cancelled:`grey`},T={active:`green`,sleeping:`amber`,dead:`grey`,killed:`red`},E={info:`blue`,warn:`amber`,critical:`red`};export{d as a,T as c,m as d,p as f,y as g,x as h,C as i,_ as l,S as m,E as n,u as o,b as p,h as r,f as s,g as t,w as u};
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{F as t,L as n,W as r}from"./semi-DCiGoqD2.js";import{E as i,P as a,k as o}from"./index-CexI4Ljq.js";import"./c2-shared-DdWdvkU_.js";import{t as s}from"./react-QV7DAAIx.js";var c=e(s(),1),{Text:l}=r,u=[{value:`http_beacon`,label:`HTTP Beacon`},{value:`https_beacon`,label:`HTTPS Beacon`},{value:`tcp_reverse`,label:`TCP 反向`},{value:`websocket`,label:`WebSocket`}],d={running:`运行中`,stopped:`已停止`,error:`异常`},f={tcp_reverse:[{value:`bash`,label:`Bash (/dev/tcp)`},{value:`nc`,label:`Netcat (-e)`},{value:`nc_mkfifo`,label:`Netcat (mkfifo)`},{value:`python`,label:`Python`},{value:`perl`,label:`Perl`},{value:`powershell`,label:`PowerShell`}],http_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],https_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],websocket:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}]},p=[{value:`shell`,label:`shell`},{value:`exec`,label:`exec`},{value:`ls`,label:`ls`},{value:`pwd`,label:`pwd`},{value:`cd`,label:`cd`},{value:`ps`,label:`ps`},{value:`kill_proc`,label:`kill_proc`},{value:`download`,label:`download`},{value:`upload`,label:`upload`},{value:`screenshot`,label:`screenshot`},{value:`sleep`,label:`sleep`},{value:`exit`,label:`exit`},{value:`self_delete`,label:`self_delete`},{value:`port_fwd`,label:`port_fwd`},{value:`socks_start`,label:`socks_start`},{value:`socks_stop`,label:`socks_stop`},{value:`load_assembly`,label:`load_assembly`},{value:`persist`,label:`persist`}],m=[{value:`queued`,label:`队列中`},{value:`sent`,label:`已发送`},{value:`running`,label:`执行中`},{value:`success`,label:`成功`},{value:`failed`,label:`失败`},{value:`cancelled`,label:`已取消`}],h=[{value:`info`,label:`信息`},{value:`warn`,label:`警告`},{value:`critical`,label:`严重`}],g=[{value:`listener`,label:`监听器`},{value:`session`,label:`会话`},{value:`task`,label:`任务`},{value:`payload`,label:`Payload`},{value:`opsec`,label:`OPSEC`}],_=[{value:`active`,label:`活跃`},{value:`sleeping`,label:`休眠`},{value:`dead`,label:`离线`},{value:`killed`,label:`已终止`}],v=[{value:`15m`,label:`最近15分钟`,ms:9e5},{value:`1h`,label:`最近1小时`,ms:36e5},{value:`24h`,label:`最近24小时`,ms:864e5},{value:`7d`,label:`最近7天`,ms:6048e5},{value:`all`,label:`全部`,ms:0}];function y(e){let t=v.find(t=>t.value===e);return!t||!t.ms?``:new Date(Date.now()-t.ms).toISOString()}function b({value:e,onChange:r,ns:i=`tasks`}){let o=a();return(0,c.jsxs)(t,{spacing:6,wrap:!0,className:`c2-time-presets`,children:[(0,c.jsx)(l,{type:`tertiary`,size:`small`,children:o(`c2.tasks.timePresets`,null,`快捷`)}),v.map(t=>(0,c.jsx)(n,{size:`small`,theme:t.value===e?`solid`:`borderless`,type:t.value===e?`primary`:`tertiary`,onClick:()=>r(t.value),children:o(`c2.${i}.preset${t.value===`all`?`All`:t.value}`,null,t.label)},t.value))]})}function x(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`—`:t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}秒`:`${Math.round(t/6e4)}分钟`}function S({value:e}){let t=a();return e?(0,c.jsx)(`span`,{className:`c2-time-text`,title:i(e),children:o(e,t)}):(0,c.jsx)(l,{type:`tertiary`,children:`—`})}var C={running:`green`,stopped:`grey`,error:`red`},w={queued:`amber`,sent:`blue`,running:`blue`,success:`green`,failed:`red`,cancelled:`grey`},T={active:`green`,sleeping:`amber`,dead:`grey`,killed:`red`},E={info:`blue`,warn:`amber`,critical:`red`};export{d as a,T as c,m as d,p as f,y as g,x as h,C as i,_ as l,S as m,E as n,u as o,b as p,h as r,f as s,g as t,w as u};

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-list-card .semi-card-header{flex-wrap:wrap;gap:10px}.assessment-view-options{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{justify-content:flex-end;gap:8px;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;color:var(--semi-color-text-0);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

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{F as r,H as i,L as a,M as o,W as s,at as c,ot as l,wt as u}from"./semi-DCiGoqD2.js";import{E as d,F as f,I as p,P as m,a as h,c as g,d as _,l as v,m as y,p as b,s as x,u as S,x as C,y as w}from"./index-DhiAuEy4.js";var T=e(t(),1),E=e(n(),1),{Text:D}=s;function O(){let e=m(),{hasPermission:t}=f(),n=t(`knowledge:delete`),[s,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(50),[j,M]=(0,T.useState)(null),N=h(()=>p.get(`/knowledge/retrieval-logs`,{conversationId:s||void 0,limit:k}),[s,k]),P=Array.isArray(N.data?.logs)?N.data.logs:[],F=e=>w({title:`删除该检索日志?`,content:e.query||e.id,onOk:async()=>{await p.del(`/knowledge/retrieval-logs/${encodeURIComponent(e.id)}`),C(`已删除`),N.reload()}});return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(b,{title:e(`knowledge.retrievalLogsTitle`,null,`检索历史`),description:`记录智能体每次知识库检索的语句、命中项与会话,用于回溯回答依据。`,extra:(0,E.jsx)(a,{icon:(0,E.jsx)(l,{}),onClick:()=>N.reload(),loading:N.loading,children:`刷新`})}),(0,E.jsxs)(y,{title:`检索记录(${P.length})`,children:[(0,E.jsx)(v,{error:N.error,onRetry:()=>N.reload()}),(0,E.jsx)(x,{columns:[{title:`检索语句`,dataIndex:`query`,render:(e,t)=>(0,E.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>M(t),style:{background:`none`,border:`none`,padding:0,cursor:`pointer`,textAlign:`left`,color:`var(--semi-color-primary)`},children:e||`—`})},{title:`风险类型`,dataIndex:`riskType`,width:140,render:e=>e?(0,E.jsx)(o,{size:`small`,children:e}):`—`},{title:`命中知识项`,dataIndex:`retrievedItems`,width:120,render:e=>(0,E.jsxs)(D,{type:`tertiary`,children:[Array.isArray(e)?e.length:0,` 条`]})},{title:`会话`,dataIndex:`conversationId`,width:200,render:e=>(0,E.jsx)(D,{type:`tertiary`,ellipsis:{showTooltip:!0},children:e||`—`})},{title:`时间`,dataIndex:`createdAt`,width:180,render:e=>d(e)},{title:`操作`,width:110,render:(e,t)=>(0,E.jsxs)(r,{children:[(0,E.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>M(t),children:`详情`}),n&&(0,E.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,E.jsx)(u,{}),onClick:()=>F(t)})]})}],dataSource:P,rowKey:`id`,loading:N.loading,pagination:!1,toolbar:(0,E.jsxs)(r,{children:[(0,E.jsx)(i,{prefix:(0,E.jsx)(c,{}),placeholder:`按会话 ID 过滤`,value:s,onChange:O,style:{width:260}}),(0,E.jsx)(i,{placeholder:`条数`,value:String(k),onChange:e=>A(Math.min(Math.max(Number(e)||50,1),500)),style:{width:100},suffix:(0,E.jsx)(D,{type:`tertiary`,children:`条`})})]})})]}),(0,E.jsx)(g,{title:`检索日志详情`,visible:!!j,onCancel:()=>M(null),width:560,children:j&&(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,E.jsx)(_,{items:[{label:`日志 ID`,value:j.id},{label:`检索语句`,value:j.query},{label:`风险类型`,value:j.riskType||`—`},{label:`会话 ID`,value:j.conversationId||`—`},{label:`消息 ID`,value:j.messageId||`—`},{label:`时间`,value:d(j.createdAt)}]}),(0,E.jsx)(S,{value:j.retrievedItems||[],title:`命中知识项`})]})})]})}export{O as default};
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,at as c,ot as l,wt as u}from"./semi-DCiGoqD2.js";import{E as d,F as f,I as p,P as m,a as h,c as g,d as _,l as v,m as y,p as b,s as x,u as S,x as C,y as w}from"./index-CexI4Ljq.js";var T=e(t(),1),E=e(n(),1),{Text:D}=s;function O(){let e=m(),{hasPermission:t}=f(),n=t(`knowledge:delete`),[s,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(50),[j,M]=(0,T.useState)(null),N=h(()=>p.get(`/knowledge/retrieval-logs`,{conversationId:s||void 0,limit:k}),[s,k]),P=Array.isArray(N.data?.logs)?N.data.logs:[],F=e=>w({title:`删除该检索日志?`,content:e.query||e.id,onOk:async()=>{await p.del(`/knowledge/retrieval-logs/${encodeURIComponent(e.id)}`),C(`已删除`),N.reload()}});return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(b,{title:e(`knowledge.retrievalLogsTitle`,null,`检索历史`),description:`记录智能体每次知识库检索的语句、命中项与会话,用于回溯回答依据。`,extra:(0,E.jsx)(a,{icon:(0,E.jsx)(l,{}),onClick:()=>N.reload(),loading:N.loading,children:`刷新`})}),(0,E.jsxs)(y,{title:`检索记录(${P.length})`,children:[(0,E.jsx)(v,{error:N.error,onRetry:()=>N.reload()}),(0,E.jsx)(x,{columns:[{title:`检索语句`,dataIndex:`query`,render:(e,t)=>(0,E.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>M(t),style:{background:`none`,border:`none`,padding:0,cursor:`pointer`,textAlign:`left`,color:`var(--semi-color-primary)`},children:e||`—`})},{title:`风险类型`,dataIndex:`riskType`,width:140,render:e=>e?(0,E.jsx)(o,{size:`small`,children:e}):`—`},{title:`命中知识项`,dataIndex:`retrievedItems`,width:120,render:e=>(0,E.jsxs)(D,{type:`tertiary`,children:[Array.isArray(e)?e.length:0,` 条`]})},{title:`会话`,dataIndex:`conversationId`,width:200,render:e=>(0,E.jsx)(D,{type:`tertiary`,ellipsis:{showTooltip:!0},children:e||`—`})},{title:`时间`,dataIndex:`createdAt`,width:180,render:e=>d(e)},{title:`操作`,width:110,render:(e,t)=>(0,E.jsxs)(r,{children:[(0,E.jsx)(a,{size:`small`,theme:`borderless`,onClick:()=>M(t),children:`详情`}),n&&(0,E.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,E.jsx)(u,{}),onClick:()=>F(t)})]})}],dataSource:P,rowKey:`id`,loading:N.loading,pagination:!1,toolbar:(0,E.jsxs)(r,{children:[(0,E.jsx)(i,{prefix:(0,E.jsx)(c,{}),placeholder:`按会话 ID 过滤`,value:s,onChange:O,style:{width:260}}),(0,E.jsx)(i,{placeholder:`条数`,value:String(k),onChange:e=>A(Math.min(Math.max(Number(e)||50,1),500)),style:{width:100},suffix:(0,E.jsx)(D,{type:`tertiary`,children:`条`})})]})})]}),(0,E.jsx)(g,{title:`检索日志详情`,visible:!!j,onCancel:()=>M(null),width:560,children:j&&(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,E.jsx)(_,{items:[{label:`日志 ID`,value:j.id},{label:`检索语句`,value:j.query},{label:`风险类型`,value:j.riskType||`—`},{label:`会话 ID`,value:j.conversationId||`—`},{label:`消息 ID`,value:j.messageId||`—`},{label:`时间`,value:d(j.createdAt)}]}),(0,E.jsx)(S,{value:j.retrievedItems||[],title:`命中知识项`})]})})]})}export{O as default};

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{W as r,i}from"./semi-DCiGoqD2.js";import{I as a,P as o,c as s,l as c,x as l}from"./index-DhiAuEy4.js";var u=e(t(),1),d=e(n(),1),{Text:f}=r,p=120,m=4e3;function h({visible:e,project:t,onCancel:n,onSaved:r}){let h=o(),g=(0,u.useId)(),[_,v]=(0,u.useState)(!1),[y,b]=(0,u.useState)(null),x=!!t?.id;return(0,u.useEffect)(()=>{b(null)},[e,t?.id]),(0,d.jsxs)(s,{visible:e,width:560,maskClosable:!1,onCancel:n,title:x?h(`projects.modalEditTitle`,null,`编辑项目`):h(`projects.modalNewTitle`,null,`新建项目`),formId:g,okText:x?h(`projects.saveChanges`,null,`保存修改`):h(`projects.createProject`,null,`创建项目`),confirmLoading:_,children:[(0,d.jsx)(f,{type:`tertiary`,size:`small`,children:x?h(`projects.modalEditSubtitle`,null,`修改项目名称与描述`):h(`projects.modalNewSubtitle`,null,`创建后可绑定对话,跨会话共享事实黑板`)}),(0,d.jsxs)(i,{id:g,onSubmit:async e=>{v(!0),b(null);try{let n={name:e.name.trim(),description:(e.description||``).slice(0,m)},i=x?await a.put(`/projects/${t.id}`,n):await a.post(`/projects`,n);l(x?h(`projects.saved`,null,`已保存`):h(`projects.createProject`,null,`创建项目`)),r?.(i)}catch(e){b(e)}finally{v(!1)}},initValues:{name:t?.name||``,description:t?.description||``},children:[(0,d.jsx)(i.Input,{field:`name`,maxLength:p,label:h(`projects.projectName`,null,`项目名称`),placeholder:h(`projects.projectNamePlaceholder`,null,`例如:某客户 Web 渗透`),rules:[{required:!0,whitespace:!0,message:h(`projects.enterProjectName`,null,`请输入项目名称`)}]}),(0,d.jsx)(i.TextArea,{field:`description`,rows:4,maxCount:m,label:h(`projects.projectDescription`,null,`项目描述`),placeholder:h(`projects.projectDescriptionPlaceholder`,null,`客户/任务备注、协作说明…`),extraText:h(`projects.descriptionLengthHint`,null,`仅供团队成员查阅,Agent 不会读取;需让 Agent 知晓的内容请写入事实黑板`)}),(0,d.jsx)(c,{error:y})]},`${e}-${t?.id||`new`}`)]})}export{h as t};
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{W as r,i}from"./semi-DCiGoqD2.js";import{I as a,P as o,c as s,l as c,x as l}from"./index-CexI4Ljq.js";var u=e(t(),1),d=e(n(),1),{Text:f}=r,p=120,m=4e3;function h({visible:e,project:t,onCancel:n,onSaved:r}){let h=o(),g=(0,u.useId)(),[_,v]=(0,u.useState)(!1),[y,b]=(0,u.useState)(null),x=!!t?.id;return(0,u.useEffect)(()=>{b(null)},[e,t?.id]),(0,d.jsxs)(s,{visible:e,width:560,maskClosable:!1,onCancel:n,title:x?h(`projects.modalEditTitle`,null,`编辑项目`):h(`projects.modalNewTitle`,null,`新建项目`),formId:g,okText:x?h(`projects.saveChanges`,null,`保存修改`):h(`projects.createProject`,null,`创建项目`),confirmLoading:_,children:[(0,d.jsx)(f,{type:`tertiary`,size:`small`,children:x?h(`projects.modalEditSubtitle`,null,`修改项目名称与描述`):h(`projects.modalNewSubtitle`,null,`创建后可绑定对话,跨会话共享事实黑板`)}),(0,d.jsxs)(i,{id:g,onSubmit:async e=>{v(!0),b(null);try{let n={name:e.name.trim(),description:(e.description||``).slice(0,m)},i=x?await a.put(`/projects/${t.id}`,n):await a.post(`/projects`,n);l(x?h(`projects.saved`,null,`已保存`):h(`projects.createProject`,null,`创建项目`)),r?.(i)}catch(e){b(e)}finally{v(!1)}},initValues:{name:t?.name||``,description:t?.description||``},children:[(0,d.jsx)(i.Input,{field:`name`,maxLength:p,label:h(`projects.projectName`,null,`项目名称`),placeholder:h(`projects.projectNamePlaceholder`,null,`例如:某客户 Web 渗透`),rules:[{required:!0,whitespace:!0,message:h(`projects.enterProjectName`,null,`请输入项目名称`)}]}),(0,d.jsx)(i.TextArea,{field:`description`,rows:4,maxCount:m,label:h(`projects.projectDescription`,null,`项目描述`),placeholder:h(`projects.projectDescriptionPlaceholder`,null,`客户/任务备注、协作说明…`),extraText:h(`projects.descriptionLengthHint`,null,`仅供团队成员查阅,Agent 不会读取;需让 Agent 知晓的内容请写入事实黑板`)}),(0,d.jsx)(c,{error:y})]},`${e}-${t?.id||`new`}`)]})}export{h as t};

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{F as r,H as i,L as a,M as o,W as s,at as c,ct as l,i as u,ot as d,wt as f,xt as p}from"./semi-DCiGoqD2.js";import{F as m,I as h,P as g,a as _,b as v,c as y,l as b,m as x,p as S,s as C,x as w,y as T}from"./index-DhiAuEy4.js";var E=e(t(),1),D=e(n(),1),{Text:O}=s;function k(){let e=g(),{hasPermission:t}=m(),n=t(`roles:write`),s=t(`roles:delete`),[k,A]=(0,E.useState)(``),[j,M]=(0,E.useState)(null),[N,P]=(0,E.useState)(!1),F=_(()=>h.get(`/roles`),[]),I=(Array.isArray(F.data?.roles)?F.data.roles:[]).filter(e=>{if(!k)return!0;let t=k.toLowerCase();return[e.name,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),L=async()=>{let e=await j.form.validate();P(!0);try{let t={name:e.name.trim(),description:e.description?.trim()||``,user_prompt:e.user_prompt||``,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean),enabled:e.enabled!==!1},n=j.role?.name;n&&n!==t.name?(await h.post(`/roles`,t),await h.del(`/roles/${encodeURIComponent(n)}`)):n?await h.put(`/roles/${encodeURIComponent(n)}`,t):await h.post(`/roles`,t),w(`角色已保存`),M(null),F.reload()}catch(e){v(e,`保存角色失败`)}finally{P(!1)}},R=e=>T({title:`删除角色「${e.name}」?`,content:`已绑定该角色的对话将失去对应提示词与工具配置。`,onOk:async()=>{await h.del(`/roles/${encodeURIComponent(e.name)}`),w(`已删除`),F.reload()}});return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(S,{title:e(`roles.title`,null,`角色管理`),description:`角色定义对话的系统提示词、可用工具与绑定工作流。`,extra:(0,D.jsxs)(r,{children:[(0,D.jsx)(a,{icon:(0,D.jsx)(d,{}),onClick:()=>F.reload(),loading:F.loading,children:`刷新`}),n&&(0,D.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,D.jsx)(l,{}),onClick:()=>M({role:null,form:{}}),children:`新建角色`})]})}),(0,D.jsxs)(x,{title:`角色(${I.length})`,children:[(0,D.jsx)(b,{error:F.error,onRetry:()=>F.reload()}),(0,D.jsx)(C,{columns:[{title:`角色`,dataIndex:`name`,render:(e,t)=>(0,D.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,D.jsxs)(r,{children:[(0,D.jsx)(O,{strong:!0,children:e}),t.enabled===!1&&(0,D.jsx)(o,{size:`small`,color:`grey`,children:`已停用`})]}),(0,D.jsx)(O,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:t.description||`—`})]})},{title:`工具`,dataIndex:`tools`,width:260,render:e=>Array.isArray(e)&&e.length?(0,D.jsxs)(r,{wrap:!0,spacing:4,children:[e.slice(0,4).map(e=>(0,D.jsx)(o,{size:`small`,children:e},e)),e.length>4&&(0,D.jsxs)(O,{type:`tertiary`,children:[`+`,e.length-4]})]}):(0,D.jsx)(O,{type:`tertiary`,children:`未绑定`})},{title:`工作流`,dataIndex:`workflow_id`,width:160,render:e=>e||`—`},{title:`操作`,width:150,render:(e,t)=>(0,D.jsxs)(r,{children:[n&&(0,D.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,D.jsx)(p,{}),onClick:()=>M({role:t,form:{}}),children:`编辑`}),s&&(0,D.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,D.jsx)(f,{}),onClick:()=>R(t)})]})}],dataSource:I,rowKey:`name`,loading:F.loading,pagination:{pageSize:20},toolbar:(0,D.jsx)(i,{prefix:(0,D.jsx)(c,{}),value:k,onChange:A,placeholder:`搜索角色名称`,style:{width:260}})})]}),(0,D.jsx)(y,{title:j?.role?`编辑角色`:`新建角色`,visible:!!j,onCancel:()=>M(null),onOk:L,confirmLoading:N,width:760,children:(0,D.jsxs)(u,{getFormApi:e=>M(t=>t&&{...t,form:e}),initValues:j?.role?{name:j.role.name,description:j.role.description,user_prompt:j.role.user_prompt,tools:Array.isArray(j.role.tools)?j.role.tools.join(`, `):``,enabled:j.role.enabled!==!1}:{enabled:!0},children:[(0,D.jsx)(u.Input,{field:`name`,label:`角色名称`,rules:[{required:!0,message:`请输入角色名称`}]}),(0,D.jsx)(u.Input,{field:`description`,label:`描述`}),(0,D.jsx)(u.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::toolName`}),(0,D.jsx)(u.TextArea,{field:`user_prompt`,label:`用户提示词(追加到用户消息前)`,autosize:{minRows:6,maxRows:18}}),(0,D.jsx)(u.Slot,{label:`启用`,children:(0,D.jsx)(u.Switch,{field:`enabled`})})]})},j?.role?.name||`new-role`)]})}export{k as default};
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,W as s,at as c,ct as l,i as u,ot as d,wt as f,xt as p}from"./semi-DCiGoqD2.js";import{F as m,I as h,P as g,a as _,b as v,c as y,l as b,m as x,p as S,s as C,x as w,y as T}from"./index-CexI4Ljq.js";var E=e(t(),1),D=e(n(),1),{Text:O}=s;function k(){let e=g(),{hasPermission:t}=m(),n=t(`roles:write`),s=t(`roles:delete`),[k,A]=(0,E.useState)(``),[j,M]=(0,E.useState)(null),[N,P]=(0,E.useState)(!1),F=_(()=>h.get(`/roles`),[]),I=(Array.isArray(F.data?.roles)?F.data.roles:[]).filter(e=>{if(!k)return!0;let t=k.toLowerCase();return[e.name,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),L=async()=>{let e=await j.form.validate();P(!0);try{let t={name:e.name.trim(),description:e.description?.trim()||``,user_prompt:e.user_prompt||``,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean),enabled:e.enabled!==!1},n=j.role?.name;n&&n!==t.name?(await h.post(`/roles`,t),await h.del(`/roles/${encodeURIComponent(n)}`)):n?await h.put(`/roles/${encodeURIComponent(n)}`,t):await h.post(`/roles`,t),w(`角色已保存`),M(null),F.reload()}catch(e){v(e,`保存角色失败`)}finally{P(!1)}},R=e=>T({title:`删除角色「${e.name}」?`,content:`已绑定该角色的对话将失去对应提示词与工具配置。`,onOk:async()=>{await h.del(`/roles/${encodeURIComponent(e.name)}`),w(`已删除`),F.reload()}});return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(S,{title:e(`roles.title`,null,`角色管理`),description:`角色定义对话的系统提示词、可用工具与绑定工作流。`,extra:(0,D.jsxs)(r,{children:[(0,D.jsx)(a,{icon:(0,D.jsx)(d,{}),onClick:()=>F.reload(),loading:F.loading,children:`刷新`}),n&&(0,D.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,D.jsx)(l,{}),onClick:()=>M({role:null,form:{}}),children:`新建角色`})]})}),(0,D.jsxs)(x,{title:`角色(${I.length})`,children:[(0,D.jsx)(b,{error:F.error,onRetry:()=>F.reload()}),(0,D.jsx)(C,{columns:[{title:`角色`,dataIndex:`name`,render:(e,t)=>(0,D.jsxs)(r,{vertical:!0,spacing:0,align:`start`,children:[(0,D.jsxs)(r,{children:[(0,D.jsx)(O,{strong:!0,children:e}),t.enabled===!1&&(0,D.jsx)(o,{size:`small`,color:`grey`,children:`已停用`})]}),(0,D.jsx)(O,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:t.description||`—`})]})},{title:`工具`,dataIndex:`tools`,width:260,render:e=>Array.isArray(e)&&e.length?(0,D.jsxs)(r,{wrap:!0,spacing:4,children:[e.slice(0,4).map(e=>(0,D.jsx)(o,{size:`small`,children:e},e)),e.length>4&&(0,D.jsxs)(O,{type:`tertiary`,children:[`+`,e.length-4]})]}):(0,D.jsx)(O,{type:`tertiary`,children:`未绑定`})},{title:`工作流`,dataIndex:`workflow_id`,width:160,render:e=>e||`—`},{title:`操作`,width:150,render:(e,t)=>(0,D.jsxs)(r,{children:[n&&(0,D.jsx)(a,{size:`small`,theme:`borderless`,icon:(0,D.jsx)(p,{}),onClick:()=>M({role:t,form:{}}),children:`编辑`}),s&&(0,D.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,D.jsx)(f,{}),onClick:()=>R(t)})]})}],dataSource:I,rowKey:`name`,loading:F.loading,pagination:{pageSize:20},toolbar:(0,D.jsx)(i,{prefix:(0,D.jsx)(c,{}),value:k,onChange:A,placeholder:`搜索角色名称`,style:{width:260}})})]}),(0,D.jsx)(y,{title:j?.role?`编辑角色`:`新建角色`,visible:!!j,onCancel:()=>M(null),onOk:L,confirmLoading:N,width:760,children:(0,D.jsxs)(u,{getFormApi:e=>M(t=>t&&{...t,form:e}),initValues:j?.role?{name:j.role.name,description:j.role.description,user_prompt:j.role.user_prompt,tools:Array.isArray(j.role.tools)?j.role.tools.join(`, `):``,enabled:j.role.enabled!==!1}:{enabled:!0},children:[(0,D.jsx)(u.Input,{field:`name`,label:`角色名称`,rules:[{required:!0,message:`请输入角色名称`}]}),(0,D.jsx)(u.Input,{field:`description`,label:`描述`}),(0,D.jsx)(u.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::toolName`}),(0,D.jsx)(u.TextArea,{field:`user_prompt`,label:`用户提示词(追加到用户消息前)`,autosize:{minRows:6,maxRows:18}}),(0,D.jsx)(u.Slot,{label:`启用`,children:(0,D.jsx)(u.Switch,{field:`enabled`})})]})},j?.role?.name||`new-role`)]})}export{k as default};

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{A as a,F as o,Gt as s,H as c,I as l,L as u,M as d,O as f,St as p,W as m,X as h,at as g,c as _,f as v,h as y,m as b,ot as ee,p as x,s as S,u as C,v as w,x as T,z as E}from"./semi-DCiGoqD2.js";import{A as D,D as O,E as k,F as A,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-DhiAuEy4.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{A as a,F as o,Gt as s,H as c,I as l,L as u,M as d,O as f,St as p,W as m,X as h,at as g,c as _,f as v,h as y,m as b,ot as ee,p as x,s as S,u as C,v as w,x as T,z as E}from"./semi-DCiGoqD2.js";import{A as D,D as O,E as k,F as A,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-CexI4Ljq.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{F as t,L as n,W as r,ot as i,wt as a}from"./semi-DCiGoqD2.js";import{D as o,F as s,I as c,O as l,P as u,_ as d,a as f,l as p,m,p as h,s as g,x as _,y as v}from"./index-DhiAuEy4.js";import{t as y}from"./react-QV7DAAIx.js";var b=e(y(),1),{Text:x}=r;function S(){let e=u(),{hasPermission:r}=s(),y=r(`skills:delete`),S=f(()=>c.get(`/skills/stats`),[]),C=Array.isArray(S.data?.stats)?S.data.stats:[],w=Number(S.data?.total_calls||0),T=Number(S.data?.total_success||0),E=w>0?T/w:null,D=()=>v({title:`清空所有技能调用统计?`,content:`只影响统计计数,不删除技能文件。`,onOk:async()=>{await c.del(`/skills/stats`),_(`统计已清空`),S.reload()}}),O=e=>v({title:`清空「${e}」的统计?`,onOk:async()=>{await c.del(`/skills/${encodeURIComponent(e)}/stats`),_(`已清空`),S.reload()}});return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(h,{title:e(`skills.monitorTitle`,null,`技能状态`),description:S.data?.skills_dir?`技能目录:${S.data.skills_dir}`:`统计技能被调用的次数、成功率与最近使用时间。`,extra:(0,b.jsxs)(t,{children:[(0,b.jsx)(n,{icon:(0,b.jsx)(i,{}),onClick:()=>S.reload(),loading:S.loading,children:`刷新`}),y&&(0,b.jsx)(n,{type:`danger`,theme:`light`,onClick:D,children:`清空全部统计`})]})}),(0,b.jsx)(d,{columns:4,metrics:[{id:`skills`,label:`技能总数`,value:o(S.data?.total_skills||0),loading:S.loading},{id:`calls`,label:`调用总数`,value:o(w),loading:S.loading},{id:`success`,label:`成功次数`,value:o(T),loading:S.loading},{id:`rate`,label:`成功率`,value:E===null?`—`:l(E),tone:E!==null&&E<.8?`warning`:`success`,loading:S.loading}]}),(0,b.jsxs)(m,{title:`按技能统计`,children:[(0,b.jsx)(p,{error:S.error,onRetry:()=>S.reload()}),(0,b.jsx)(g,{columns:[{title:`技能`,dataIndex:`skill_name`,render:e=>(0,b.jsx)(x,{strong:!0,children:e})},{title:`调用次数`,dataIndex:`total_calls`,width:120,render:e=>o(e||0)},{title:`成功`,dataIndex:`success_calls`,width:100,render:e=>o(e||0)},{title:`失败`,dataIndex:`failed_calls`,width:100,render:e=>Number(e)>0?(0,b.jsx)(x,{type:`danger`,children:o(e)}):`0`},{title:`最后调用`,dataIndex:`last_call_time`,width:180,render:e=>e||`—`},{title:`操作`,width:110,render:(e,t)=>y&&Number(t.total_calls)>0?(0,b.jsx)(n,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,b.jsx)(a,{}),onClick:()=>O(t.skill_name),children:`清空`}):null}],dataSource:C,rowKey:`skill_name`,loading:S.loading,pagination:{pageSize:20}})]})]})}export{S as default};
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{F as t,L as n,W as r,ot as i,wt as a}from"./semi-DCiGoqD2.js";import{D as o,F as s,I as c,O as l,P as u,_ as d,a as f,l as p,m,p as h,s as g,x as _,y as v}from"./index-CexI4Ljq.js";import{t as y}from"./react-QV7DAAIx.js";var b=e(y(),1),{Text:x}=r;function S(){let e=u(),{hasPermission:r}=s(),y=r(`skills:delete`),S=f(()=>c.get(`/skills/stats`),[]),C=Array.isArray(S.data?.stats)?S.data.stats:[],w=Number(S.data?.total_calls||0),T=Number(S.data?.total_success||0),E=w>0?T/w:null,D=()=>v({title:`清空所有技能调用统计?`,content:`只影响统计计数,不删除技能文件。`,onOk:async()=>{await c.del(`/skills/stats`),_(`统计已清空`),S.reload()}}),O=e=>v({title:`清空「${e}」的统计?`,onOk:async()=>{await c.del(`/skills/${encodeURIComponent(e)}/stats`),_(`已清空`),S.reload()}});return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(h,{title:e(`skills.monitorTitle`,null,`技能状态`),description:S.data?.skills_dir?`技能目录:${S.data.skills_dir}`:`统计技能被调用的次数、成功率与最近使用时间。`,extra:(0,b.jsxs)(t,{children:[(0,b.jsx)(n,{icon:(0,b.jsx)(i,{}),onClick:()=>S.reload(),loading:S.loading,children:`刷新`}),y&&(0,b.jsx)(n,{type:`danger`,theme:`light`,onClick:D,children:`清空全部统计`})]})}),(0,b.jsx)(d,{columns:4,metrics:[{id:`skills`,label:`技能总数`,value:o(S.data?.total_skills||0),loading:S.loading},{id:`calls`,label:`调用总数`,value:o(w),loading:S.loading},{id:`success`,label:`成功次数`,value:o(T),loading:S.loading},{id:`rate`,label:`成功率`,value:E===null?`—`:l(E),tone:E!==null&&E<.8?`warning`:`success`,loading:S.loading}]}),(0,b.jsxs)(m,{title:`按技能统计`,children:[(0,b.jsx)(p,{error:S.error,onRetry:()=>S.reload()}),(0,b.jsx)(g,{columns:[{title:`技能`,dataIndex:`skill_name`,render:e=>(0,b.jsx)(x,{strong:!0,children:e})},{title:`调用次数`,dataIndex:`total_calls`,width:120,render:e=>o(e||0)},{title:`成功`,dataIndex:`success_calls`,width:100,render:e=>o(e||0)},{title:`失败`,dataIndex:`failed_calls`,width:100,render:e=>Number(e)>0?(0,b.jsx)(x,{type:`danger`,children:o(e)}):`0`},{title:`最后调用`,dataIndex:`last_call_time`,width:180,render:e=>e||`—`},{title:`操作`,width:110,render:(e,t)=>y&&Number(t.total_calls)>0?(0,b.jsx)(n,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,b.jsx)(a,{}),onClick:()=>O(t.skill_name),children:`清空`}):null}],dataSource:C,rowKey:`skill_name`,loading:S.loading,pagination:{pageSize:20}})]})]})}export{S as default};

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,7 @@
} catch (error) { /* first paint fallback */ }
})();
</script>
<script type="module" crossorigin src="/static/app/assets/index-DhiAuEy4.js"></script>
<script type="module" crossorigin src="/static/app/assets/index-CexI4Ljq.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-DCiGoqD2.js">