style(projects): render attack path nodes as cards
This commit is contained in:
parent
33db868509
commit
d685a5cd48
|
|
@ -1,11 +1,25 @@
|
|||
import { useEffect, useRef, useState } from 'react';
|
||||
import {
|
||||
IconAlertTriangle, IconBolt, IconBranch, IconFile, IconGlobe,
|
||||
IconHelpCircle, IconKey, IconSearch, IconServer, IconTickCircle
|
||||
} from '@douyinfe/semi-icons';
|
||||
import { NODE_COLORS } from './helpers';
|
||||
|
||||
const STAGE = { target: 0, infra: 1, auth: 1, finding: 2, chain: 3, exploit: 3, poc: 3, vulnerability: 4 };
|
||||
const LABEL_WIDTH = 144;
|
||||
const LABEL_HEIGHT = 23;
|
||||
const overlaps = (a, b) => a.x < b.x + b.width && b.x < a.x + a.width
|
||||
&& a.y < b.y + b.height && b.y < a.y + a.height;
|
||||
const CARD_WIDTH = 216;
|
||||
const CARD_HEIGHT = 84;
|
||||
const COLUMN_GAP = 64;
|
||||
const ROW_GAP = 16;
|
||||
|
||||
const NODE_ICONS = {
|
||||
target: IconGlobe, infra: IconServer, auth: IconKey, finding: IconSearch, chain: IconBranch,
|
||||
exploit: IconBolt, poc: IconTickCircle, vulnerability: IconAlertTriangle, note: IconFile, missing: IconHelpCircle
|
||||
};
|
||||
|
||||
export function GraphNodeIcon({ type }) {
|
||||
const Icon = NODE_ICONS[type] || IconFile;
|
||||
return <span className="project-graph-node-icon" aria-hidden="true"><Icon size="small" /></span>;
|
||||
}
|
||||
|
||||
function graphPositions(nodes, edges, selectedId) {
|
||||
const adjacent = new Map(nodes.map(node => [node.id, new Set()]));
|
||||
|
|
@ -52,11 +66,11 @@ function graphPositions(nodes, edges, selectedId) {
|
|||
for (let start = 0; start < group.length; start += columnSize) {
|
||||
const column = group.slice(start, start + columnSize);
|
||||
column.forEach((id, index) => positions.set(id, {
|
||||
x, y: (index - (column.length - 1) / 2) * 63
|
||||
x, y: (index - (column.length - 1) / 2) * (CARD_HEIGHT + ROW_GAP)
|
||||
}));
|
||||
x += 172;
|
||||
x += CARD_WIDTH + COLUMN_GAP;
|
||||
}
|
||||
x += 34;
|
||||
x += 24;
|
||||
}
|
||||
return positions;
|
||||
}
|
||||
|
|
@ -64,121 +78,170 @@ function graphPositions(nodes, edges, selectedId) {
|
|||
const STYLE = [
|
||||
{
|
||||
selector: 'node',
|
||||
style: { 'background-color': 'data(color)', width: 21, height: 21 }
|
||||
style: {
|
||||
shape: 'round-rectangle', width: CARD_WIDTH, height: CARD_HEIGHT,
|
||||
'background-color': 'data(color)', 'background-opacity': 0.44
|
||||
}
|
||||
},
|
||||
{ selector: 'node[type = "target"]', style: { width: 25, height: 25 } },
|
||||
{
|
||||
selector: 'node[type = "missing"]',
|
||||
style: { 'background-opacity': 0.15, 'border-width': 2, 'border-color': 'data(color)', 'border-style': 'dashed' }
|
||||
},
|
||||
{ selector: 'node.current', style: { width: 30, height: 30, 'underlay-color': 'data(color)', 'underlay-opacity': 0.22, 'underlay-padding': 6 } },
|
||||
{ selector: 'node.current', style: { 'background-opacity': 0.85 } },
|
||||
{
|
||||
selector: 'edge',
|
||||
style: {
|
||||
width: 1.75, 'line-color': '#8191a9', 'target-arrow-color': '#8191a9',
|
||||
'target-arrow-shape': 'triangle', 'arrow-scale': 0.9,
|
||||
'curve-style': 'bezier', opacity: 0.55
|
||||
width: 1.9, 'line-color': '#748fbb', 'target-arrow-color': '#748fbb',
|
||||
'target-arrow-shape': 'triangle', 'arrow-scale': 0.85,
|
||||
'curve-style': 'bezier', opacity: 0.59
|
||||
}
|
||||
},
|
||||
{ selector: 'edge.focused', style: { width: 2, opacity: 0.92 } },
|
||||
{ selector: 'edge[type = "links_vuln"]', style: { 'line-color': '#d45363', 'target-arrow-color': '#d45363' } },
|
||||
{
|
||||
selector: 'edge.forward',
|
||||
style: { 'source-endpoint': '50% 0px', 'target-endpoint': '-50% 0px' }
|
||||
},
|
||||
{
|
||||
selector: 'edge.backward',
|
||||
style: { 'source-endpoint': '-50% 0px', 'target-endpoint': '50% 0px' }
|
||||
},
|
||||
{
|
||||
selector: 'edge.curved',
|
||||
style: {
|
||||
'curve-style': 'unbundled-bezier', 'edge-distances': 'endpoints',
|
||||
'control-point-weights': '0.30 0.70', 'control-point-distances': 'data(bend)'
|
||||
}
|
||||
},
|
||||
{ selector: 'edge.focused', style: { width: 2.3, opacity: 0.96 } },
|
||||
{ selector: 'edge[type = "links_vuln"]', style: { 'line-color': '#c96b81', 'target-arrow-color': '#c96b81' } },
|
||||
{ selector: 'edge[confidence = "tentative"]', style: { 'line-style': 'dashed', 'line-dash-pattern': [5, 4] } }
|
||||
];
|
||||
|
||||
function placeLabels(cy, nodes, selectedId, hoveredId, measure) {
|
||||
const width = cy.width();
|
||||
const height = cy.height();
|
||||
const scale = cy.zoom();
|
||||
const points = cy.nodes().map(element => {
|
||||
const { x, y } = element.renderedPosition();
|
||||
return { id: element.id(), x, y, radius: Math.max(3, element.renderedOuterWidth() / 2) };
|
||||
}).filter(({ x, y }) => x >= 0 && x <= width && y >= 0 && y <= height);
|
||||
const occupied = points.map(({ x, y, radius }) => ({
|
||||
x: x - radius - 1, y: y - radius - 1, width: radius * 2 + 2, height: radius * 2 + 2
|
||||
}));
|
||||
const priority = ({ id }) => {
|
||||
if (id === selectedId) return 0;
|
||||
if (id === hoveredId) return 1;
|
||||
const type = nodes.get(id).type;
|
||||
if (type === 'target') return 2;
|
||||
if (type === 'chain') return 3;
|
||||
return 4;
|
||||
};
|
||||
const labels = [];
|
||||
for (const point of points.sort((a, b) => priority(a) - priority(b))) {
|
||||
const { id, x, y, radius } = point;
|
||||
if (scale < 0.46 && priority(point) > 3) continue;
|
||||
const node = nodes.get(id);
|
||||
const title = ((node.label !== '—' && node.label) || node.fact_key || id).replace(/\s+/g, ' ').trim() || id;
|
||||
const maxWidth = scale < 0.55 && hoveredId !== id && selectedId !== id ? 96 : LABEL_WIDTH;
|
||||
const boxWidth = Math.min(maxWidth, Math.ceil(measure(title)) + 21);
|
||||
const center = Math.max(4, Math.min(x - boxWidth / 2, width - boxWidth - 4));
|
||||
const candidates = [
|
||||
{ x: center, y: y + radius + 4 },
|
||||
{ x: center, y: y - radius - LABEL_HEIGHT - 4 },
|
||||
{ x: x + radius + 5, y: y - LABEL_HEIGHT / 2 },
|
||||
{ x: x - radius - boxWidth - 5, y: y - LABEL_HEIGHT / 2 }
|
||||
];
|
||||
if (!selectedId) candidates.push(...candidates.splice(0, 2));
|
||||
const box = candidates.map(candidate => ({ ...candidate, width: boxWidth, height: LABEL_HEIGHT }))
|
||||
.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: box.height + 4 });
|
||||
labels.push({ id, title, box });
|
||||
function graphElements(nodes, edges, selectedId) {
|
||||
const positions = graphPositions(nodes, edges, selectedId);
|
||||
const ports = new Map(nodes.map(node => [node.id, new Set()]));
|
||||
// Preserve Cytoscape's normal separation for parallel links.
|
||||
const pairKey = edge => JSON.stringify([edge.source, edge.target].sort());
|
||||
const pairCounts = new Map();
|
||||
for (const edge of edges) {
|
||||
const key = pairKey(edge);
|
||||
pairCounts.set(key, (pairCounts.get(key) || 0) + 1);
|
||||
}
|
||||
return labels;
|
||||
const links = edges.map((edge, index) => {
|
||||
const source = positions.get(edge.source);
|
||||
const target = positions.get(edge.target);
|
||||
const dx = target.x - source.x;
|
||||
const dy = target.y - source.y;
|
||||
const classes = [];
|
||||
if (selectedId) classes.push('focused');
|
||||
if (dx !== 0) {
|
||||
const forward = dx > 0;
|
||||
classes.push(forward ? 'forward' : 'backward');
|
||||
ports.get(edge.source).add(forward ? 'right' : 'left');
|
||||
ports.get(edge.target).add(forward ? 'left' : 'right');
|
||||
if (pairCounts.get(pairKey(edge)) === 1) classes.push('curved');
|
||||
}
|
||||
const bend = Math.sign(dy * dx) * Math.min(Math.abs(dy) * 0.3, 60);
|
||||
return {
|
||||
group: 'edges', classes: classes.join(' '),
|
||||
data: { ...edge, id: `edge|${index}|${edge.id || ''}`, bend: [-bend, bend] }
|
||||
};
|
||||
});
|
||||
return {
|
||||
ports,
|
||||
elements: [
|
||||
...nodes.map(node => ({
|
||||
group: 'nodes',
|
||||
data: { id: node.id, color: NODE_COLORS[node.type] || NODE_COLORS.missing },
|
||||
position: positions.get(node.id),
|
||||
classes: node.id === selectedId ? 'current' : ''
|
||||
})),
|
||||
...links
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
export default function FactGraphCanvas({ nodes, edges, selectedId, onSelect, chartRef, label, errorText }) {
|
||||
function visibleCards(cy, byId, ports) {
|
||||
const width = cy.width();
|
||||
const height = cy.height();
|
||||
const cardWidth = CARD_WIDTH * cy.zoom();
|
||||
const cardHeight = CARD_HEIGHT * cy.zoom();
|
||||
// Below this scale Cytoscape's tiles preserve the overall shape of the graph.
|
||||
if (cardWidth < 49) return [];
|
||||
const density = cardHeight >= 62 ? 'detail' : cardHeight >= 33 ? 'standard' : 'compact';
|
||||
return cy.nodes().map(element => {
|
||||
const { x, y } = element.renderedPosition();
|
||||
const id = element.id();
|
||||
return {
|
||||
node: byId.get(id), ports: ports.get(id), density,
|
||||
box: { left: x - cardWidth / 2, top: y - cardHeight / 2, width: cardWidth, height: cardHeight }
|
||||
};
|
||||
}).filter(({ box }) => box.left + box.width > 0 && box.left < width
|
||||
&& box.top + box.height > 0 && box.top < height);
|
||||
}
|
||||
|
||||
function GraphNodeCard({ card, selected, typeLabel, onSelect }) {
|
||||
const { node, ports, density, box } = card;
|
||||
const detail = density === 'detail';
|
||||
const key = node.fact_key || node.id;
|
||||
const title = (node.summary || (node.label !== '—' && node.label) || key).replace(/\s+/g, ' ').trim() || key;
|
||||
const category = typeLabel(node.type || 'note');
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={`project-graph-node project-graph-node--${density}`}
|
||||
title={title}
|
||||
aria-label={title}
|
||||
aria-pressed={selected}
|
||||
style={{ ...box, '--graph-node-color': NODE_COLORS[node.type] || NODE_COLORS.missing }}
|
||||
onClick={() => onSelect(node.id)}
|
||||
>
|
||||
<span className="project-graph-node-content">
|
||||
{density !== 'compact' && (
|
||||
<span className="project-graph-node-kind">
|
||||
<GraphNodeIcon type={node.type} />
|
||||
<span>{category}</span>
|
||||
</span>
|
||||
)}
|
||||
<span className="project-graph-node-title" dir="auto">{title}</span>
|
||||
{detail && box.height >= 76 && title !== key && <span className="project-graph-node-keyline" dir="auto">{key}</span>}
|
||||
</span>
|
||||
{detail && [...ports].map(side => (
|
||||
<span key={side} className={`project-graph-node-port is-${side}`} aria-hidden="true" />
|
||||
))}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
export default function FactGraphCanvas({ nodes, edges, selectedId, onSelect, chartRef, label, errorText, typeLabel }) {
|
||||
const canvas = useRef(null);
|
||||
const [labels, setLabels] = useState([]);
|
||||
const nodeLayer = useRef(null);
|
||||
const [cards, setCards] = useState([]);
|
||||
const [failed, setFailed] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const container = canvas.current;
|
||||
const layer = nodeLayer.current;
|
||||
let disposed = false;
|
||||
let cy;
|
||||
let resize;
|
||||
let frame;
|
||||
let hoveredId;
|
||||
let onCardWheel;
|
||||
let fitted = true;
|
||||
let fitting = false;
|
||||
setLabels([]);
|
||||
setCards([]);
|
||||
setFailed(false);
|
||||
|
||||
import('cytoscape').then(({ default: cytoscape }) => {
|
||||
if (disposed) return;
|
||||
const byId = new Map(nodes.map(node => [node.id, node]));
|
||||
const positions = graphPositions(nodes, edges, selectedId);
|
||||
const { ports, elements } = graphElements(nodes, edges, selectedId);
|
||||
cy = cytoscape({
|
||||
container,
|
||||
elements: [
|
||||
...nodes.map(node => ({
|
||||
group: 'nodes',
|
||||
data: { id: node.id, type: node.type || 'note', color: NODE_COLORS[node.type] || NODE_COLORS.missing },
|
||||
position: positions.get(node.id),
|
||||
classes: node.id === selectedId ? 'current' : ''
|
||||
})),
|
||||
...edges.map((edge, index) => ({
|
||||
group: 'edges',
|
||||
classes: selectedId ? 'focused' : '',
|
||||
data: { ...edge, id: `edge|${index}|${edge.id || ''}` }
|
||||
}))
|
||||
],
|
||||
elements,
|
||||
style: STYLE,
|
||||
layout: { name: 'preset', fit: false },
|
||||
minZoom: 0.006, maxZoom: 3, wheelSensitivity: 0.2,
|
||||
boxSelectionEnabled: false, autounselectify: true, autoungrabify: true
|
||||
});
|
||||
const measure = document.createElement('canvas').getContext('2d');
|
||||
measure.font = `500 12px ${getComputedStyle(container).fontFamily}`;
|
||||
const place = () => {
|
||||
cancelAnimationFrame(frame);
|
||||
frame = requestAnimationFrame(() => setLabels(
|
||||
placeLabels(cy, byId, selectedId, hoveredId, title => measure.measureText(title).width)
|
||||
));
|
||||
frame = requestAnimationFrame(() => setCards(visibleCards(cy, byId, ports)));
|
||||
};
|
||||
const fit = () => {
|
||||
fitting = true;
|
||||
|
|
@ -188,20 +251,25 @@ export default function FactGraphCanvas({ nodes, edges, selectedId, onSelect, ch
|
|||
fitting = false;
|
||||
place();
|
||||
};
|
||||
chartRef.current = {
|
||||
fit,
|
||||
zoom: factor => cy.zoom({
|
||||
level: cy.zoom() * factor,
|
||||
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
|
||||
})
|
||||
const zoom = (factor, renderedPosition = { x: cy.width() / 2, y: cy.height() / 2 }) => {
|
||||
cy.zoom({ level: cy.zoom() * factor, renderedPosition });
|
||||
};
|
||||
chartRef.current = { fit, zoom };
|
||||
// Card buttons sit above the canvas, so mirror its wheel zoom at the pointer.
|
||||
onCardWheel = event => {
|
||||
if (!event.deltaY) return;
|
||||
event.preventDefault();
|
||||
const { left, top, height } = container.getBoundingClientRect();
|
||||
const units = event.deltaMode === 1 ? 33 : event.deltaMode === 2 ? height : 1;
|
||||
zoom(10 ** (-event.deltaY * units / 1250), { x: event.clientX - left, y: event.clientY - top });
|
||||
};
|
||||
layer.addEventListener('wheel', onCardWheel, { passive: false });
|
||||
cy.on('viewport', () => {
|
||||
if (!fitting) fitted = false;
|
||||
place();
|
||||
});
|
||||
cy.on('tap', 'node', event => onSelect(event.target.id()));
|
||||
cy.on('mouseover', 'node', event => { hoveredId = event.target.id(); place(); });
|
||||
cy.on('mouseout', 'node', () => { hoveredId = undefined; place(); });
|
||||
|
||||
let width = cy.width();
|
||||
let height = cy.height();
|
||||
resize = new ResizeObserver(() => {
|
||||
|
|
@ -222,6 +290,7 @@ export default function FactGraphCanvas({ nodes, edges, selectedId, onSelect, ch
|
|||
disposed = true;
|
||||
cancelAnimationFrame(frame);
|
||||
resize?.disconnect();
|
||||
if (onCardWheel) layer.removeEventListener('wheel', onCardWheel);
|
||||
cy?.destroy();
|
||||
chartRef.current = null;
|
||||
};
|
||||
|
|
@ -230,20 +299,15 @@ export default function FactGraphCanvas({ nodes, edges, selectedId, onSelect, ch
|
|||
return (
|
||||
<div className="project-graph-canvas-wrap" role="group" aria-label={label}>
|
||||
<div ref={canvas} className="project-graph-canvas" />
|
||||
<div className="project-graph-labels">
|
||||
{labels.map(({ id, title, box }) => (
|
||||
<button
|
||||
type="button"
|
||||
className="project-graph-label"
|
||||
key={id}
|
||||
title={title}
|
||||
aria-pressed={id === selectedId}
|
||||
style={{ left: box.x, top: box.y, width: box.width }}
|
||||
onClick={() => onSelect(id)}
|
||||
dir="auto"
|
||||
>
|
||||
{title}
|
||||
</button>
|
||||
<div ref={nodeLayer} className="project-graph-nodes">
|
||||
{cards.map(card => (
|
||||
<GraphNodeCard
|
||||
card={card}
|
||||
key={card.node.id}
|
||||
selected={card.node.id === selectedId}
|
||||
typeLabel={typeLabel}
|
||||
onSelect={onSelect}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
{failed && <div className="project-graph-overlay" role="alert">{errorText}</div>}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { useT } from '../../lib/i18n';
|
|||
import { useResource } from '../../components/hooks';
|
||||
import { ErrorBanner, SectionCard, confirmAction, toastError, toastSuccess } from '../../components/ui';
|
||||
import { CONFIDENCE_META, NODE_COLORS, NODE_TYPE_LABEL, errorProp, errText } from './helpers';
|
||||
import FactGraphCanvas from './fact-graph-canvas';
|
||||
import FactGraphCanvas, { GraphNodeIcon } from './fact-graph-canvas';
|
||||
|
||||
const { Text } = Typography;
|
||||
const EMPTY = [];
|
||||
|
|
@ -212,7 +212,7 @@ export default function FactGraphPanel({
|
|||
</>
|
||||
) : (
|
||||
<Text type="tertiary" size="small">
|
||||
{t('projects.graphOverviewHint', null, '点选节点查看直接关系,放大后显示更多标签。')}
|
||||
{t('projects.graphOverviewHint', null, '点选节点查看直接关系,放大可查看卡片摘要。')}
|
||||
</Text>
|
||||
)}
|
||||
</div>
|
||||
|
|
@ -224,14 +224,15 @@ export default function FactGraphPanel({
|
|||
selectedId={selected?.id}
|
||||
onSelect={openNode}
|
||||
chartRef={chartRef}
|
||||
typeLabel={typeLabel}
|
||||
label={t('projects.graphCanvas', null, '攻击路径画布')}
|
||||
errorText={t('projects.graphRenderError', null, '图谱加载失败,请刷新重试。')}
|
||||
/>
|
||||
<div className="project-graph-footer">
|
||||
<div className="project-graph-legend">
|
||||
{types.map(type => (
|
||||
<span key={type}>
|
||||
<i aria-hidden="true" style={{ background: NODE_COLORS[type] }} />
|
||||
<span key={type} style={{ '--graph-node-color': NODE_COLORS[type] }}>
|
||||
<GraphNodeIcon type={type} />
|
||||
{typeLabel(type)}
|
||||
</span>
|
||||
))}
|
||||
|
|
|
|||
|
|
@ -211,39 +211,121 @@
|
|||
height: var(--project-graph-height);
|
||||
border: 1px solid var(--semi-color-border);
|
||||
border-radius: var(--cs-radius, 10px);
|
||||
background: radial-gradient(circle, var(--semi-color-border) 1px, transparent 1px) 0 0 / 18px 18px var(--semi-color-bg-1);
|
||||
background:
|
||||
radial-gradient(circle, color-mix(in srgb, var(--semi-color-text-2) 19%, transparent) .8px, transparent 1px) 0 0 / 20px 20px,
|
||||
color-mix(in srgb, var(--semi-color-bg-1) 96%, #537cba);
|
||||
overflow: hidden;
|
||||
}
|
||||
.project-graph-canvas { width: 100%; height: 100%; }
|
||||
.project-graph-overlay, .project-graph-labels { position: absolute; inset: 0; }
|
||||
.project-graph-overlay, .project-graph-nodes { position: absolute; inset: 0; }
|
||||
.project-graph-overlay, .project-graph-loading { display: grid; place-items: center; }
|
||||
.project-graph-overlay { padding: 16px; color: var(--semi-color-danger); background: var(--semi-color-bg-1); }
|
||||
.project-graph-loading { min-height: 180px; }
|
||||
.project-graph-labels { pointer-events: none; }
|
||||
.project-graph-label {
|
||||
.project-graph-nodes { pointer-events: none; }
|
||||
.project-graph-node {
|
||||
position: absolute;
|
||||
height: 23px;
|
||||
padding: 0 7px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
border: 1px solid var(--semi-color-border);
|
||||
border-radius: 5px;
|
||||
box-sizing: border-box;
|
||||
--graph-node-border: color-mix(in srgb, var(--graph-node-color) 24%, var(--semi-color-border));
|
||||
border: 1px solid var(--graph-node-border);
|
||||
border-inline-start: 3px solid var(--graph-node-color);
|
||||
border-radius: 8px;
|
||||
padding: 0;
|
||||
background: var(--semi-color-bg-1);
|
||||
box-shadow: 0 2px 5px rgba(20, 31, 53, .12);
|
||||
color: var(--semi-color-text-0);
|
||||
font-family: inherit;
|
||||
font-weight: 500;
|
||||
font-size: 12px;
|
||||
line-height: 21px;
|
||||
font-weight: 500;
|
||||
line-height: 1.2;
|
||||
text-align: start;
|
||||
cursor: pointer;
|
||||
pointer-events: auto;
|
||||
}
|
||||
.project-graph-label:hover, .project-graph-label[aria-pressed="true"] {
|
||||
border-color: var(--semi-color-primary);
|
||||
color: var(--semi-color-primary);
|
||||
background: var(--semi-color-primary-light-default);
|
||||
.project-graph-node:hover, .project-graph-node:focus-visible, .project-graph-node[aria-pressed="true"] {
|
||||
border-color: var(--graph-node-color);
|
||||
background: color-mix(in srgb, var(--graph-node-color) 5%, var(--semi-color-bg-1));
|
||||
}
|
||||
.project-graph-node[aria-pressed="true"] {
|
||||
box-shadow: 0 0 0 3px color-mix(in srgb, var(--graph-node-color) 22%, transparent), 0 3px 9px rgba(20, 31, 53, .13);
|
||||
}
|
||||
.project-graph-node-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
min-width: 0;
|
||||
padding-inline: 5px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.project-graph-node--compact { border-radius: 5px; box-shadow: 0 1px 3px rgba(20, 31, 53, .08); }
|
||||
.project-graph-node--compact .project-graph-node-content { padding-inline: 4px; }
|
||||
.project-graph-node--standard .project-graph-node-content {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
gap: 2px;
|
||||
}
|
||||
.project-graph-node--standard .project-graph-node-icon { width: 13px; height: 13px; }
|
||||
.project-graph-node-kind {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
flex-shrink: 0;
|
||||
color: var(--semi-color-text-1);
|
||||
font-size: 10px;
|
||||
font-weight: 650;
|
||||
}
|
||||
.project-graph-node-icon {
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
flex: 0 0 auto;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 5px;
|
||||
color: color-mix(in srgb, var(--graph-node-color) 75%, var(--semi-color-text-0));
|
||||
background: color-mix(in srgb, var(--graph-node-color) 13%, var(--semi-color-bg-1));
|
||||
}
|
||||
.project-graph-node-title, .project-graph-node-keyline {
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.project-graph-node--detail {
|
||||
background: linear-gradient(150deg, color-mix(in srgb, var(--graph-node-color) 5%, var(--semi-color-bg-1)), var(--semi-color-bg-1) 68%);
|
||||
}
|
||||
.project-graph-node--detail .project-graph-node-content {
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
gap: 3px;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
.project-graph-node--detail .project-graph-node-title {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
line-height: 14px;
|
||||
}
|
||||
.project-graph-node-keyline {
|
||||
color: var(--semi-color-text-2);
|
||||
font: 10px/12px "SFMono-Regular", Consolas, monospace;
|
||||
}
|
||||
.project-graph-node-port {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
transform: translateY(-50%);
|
||||
border: 1px solid var(--semi-color-bg-1);
|
||||
border-radius: 50%;
|
||||
background: var(--graph-node-color);
|
||||
}
|
||||
.project-graph-node-port.is-left { left: -4px; }
|
||||
.project-graph-node-port.is-right { right: -4px; }
|
||||
.project-graph-footer {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
|
@ -260,8 +342,7 @@
|
|||
color: var(--semi-color-text-2);
|
||||
font-size: 12px;
|
||||
}
|
||||
.project-graph-legend span { display: inline-flex; align-items: center; gap: 5px; }
|
||||
.project-graph-legend i { width: 8px; height: 8px; border-radius: 50%; }
|
||||
.project-graph-legend > span { display: inline-flex; align-items: center; gap: 5px; }
|
||||
.project-graph-legend .project-graph-legend-dash {
|
||||
width: 16px;
|
||||
height: 0;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ test('project graph: dense overview keeps labels legible and search follows the
|
|||
return { left, top, right, bottom, fontSize: getComputedStyle(item).fontSize };
|
||||
}));
|
||||
expect(boxes.length).toBeGreaterThan(4);
|
||||
expect(boxes.length).toBeLessThan(graph.nodes.length);
|
||||
expect(boxes.length).toBeLessThanOrEqual(graph.nodes.length);
|
||||
await expect(canvas.locator('.project-graph-node--compact').first()).toBeVisible();
|
||||
for (const [index, box] of boxes.entries()) {
|
||||
expect(box.fontSize).toBe('12px');
|
||||
for (const other of boxes.slice(index + 1)) {
|
||||
|
|
@ -70,9 +71,17 @@ test('project graph: dense overview keeps labels legible and search follows the
|
|||
await expect(main.getByText('聚焦直接关系 · 节点: 3 | 边: 2')).toBeVisible();
|
||||
await expect(side.getByText('← 入边', { exact: true })).toBeVisible();
|
||||
await expect(side.getByText('→ 出边', { exact: true })).toBeVisible();
|
||||
await expect(canvas.getByRole('button', { name: selected.label })).toHaveAttribute('aria-pressed', 'true');
|
||||
const selectedCard = canvas.getByRole('button', { name: selected.label });
|
||||
await expect(selectedCard).toHaveAttribute('aria-pressed', 'true');
|
||||
await expect(selectedCard.getByText('发现', { exact: true })).toBeVisible();
|
||||
await expect(selectedCard.getByText(selected.fact_key, { exact: true })).toBeVisible();
|
||||
await main.locator('.project-graph-card').screenshot({ path: testInfo.outputPath('project-graph-focus.png') });
|
||||
|
||||
const beforeZoom = await selectedCard.boundingBox();
|
||||
await selectedCard.hover();
|
||||
await page.mouse.wheel(0, -150);
|
||||
await expect.poll(async () => (await selectedCard.boundingBox()).width).toBeGreaterThan(beforeZoom.width);
|
||||
|
||||
await side.getByRole('button', { name: '详情', exact: true }).click();
|
||||
await expect(page.getByText(detail.body)).toBeVisible();
|
||||
await page.locator('.semi-sidesheet').getByRole('button', { name: '关闭', exact: true }).click();
|
||||
|
|
|
|||
|
|
@ -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,St as s,Tt as c,W as l,at as u,ct as d,i as f,ot as p}from"./semi-CXF9U6uC.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-LQJrYSgy.js";var k=e(t(),1),A=e(n(),1),{Text:j}=l;function M(){let e=g(),{hasPermission:t}=m(),n=t(`agents:write`),l=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)(p,{}),onClick:()=>B.reload(),loading:B.loading,children:`刷新`}),n&&(0,A.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(d,{}),onClick:()=>L({record:null,form:{}}),children:`新建智能体`})]})}),B.data?.error&&(0,A.jsx)(S,{error:B.data.error}),(0,A.jsxs)(C,{title:`智能体(${V.length})`,children:[(0,A.jsx)(S,{error:B.error,onRetry:()=>B.reload()}),(0,A.jsx)(T,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,A.jsxs)(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)(s,{}),onClick:()=>L({record:t,form:{}})}),l&&(0,A.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,A.jsx)(c,{}),onClick:()=>W(t)})]})}],dataSource:V,rowKey:`filename`,loading:B.loading,pagination:{pageSize:20},toolbar:(0,A.jsx)(i,{prefix:(0,A.jsx)(u,{}),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)(f,{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)(f.Input,{field:`filename`,label:`文件名(留空自动生成)`,placeholder:`例如 recon.md`}),(0,A.jsx)(f.Input,{field:`name`,label:`名称`,rules:[{required:!0,message:`请输入名称`}]}),(0,A.jsx)(f.Input,{field:`description`,label:`描述`}),(0,A.jsx)(f.Select,{field:`kind`,label:`类型`,optionList:[{value:`sub`,label:`子智能体`},{value:`orchestrator`,label:`编排器`},{value:`plan_execute`,label:`计划执行`}]}),(0,A.jsx)(f.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::tool`}),(0,A.jsx)(f.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{Et as r,F as i,H as a,L as o,M as s,W as c,i as l,kt as u,lt as d,ot as f,st as p}from"./semi-CDAktpYA.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-BKN3rSq_.js";var k=e(t(),1),A=e(n(),1),{Text:j}=c;function M(){let e=g(),{hasPermission:t}=m(),n=t(`agents:write`),c=t(`agents:delete`),[M,N]=(0,k.useState)(``),[P,F]=(0,k.useState)(null),[I,L]=(0,k.useState)(null),[R,z]=(0,k.useState)(!1),B=_(()=>h.get(`/multi-agent/markdown-agents`),[]),V=(Array.isArray(B.data?.agents)?B.data.agents:[]).filter(e=>{if(!M)return!0;let t=M.toLowerCase();return[e.name,e.id,e.filename,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),H=async e=>{try{F(await h.get(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`))}catch(e){v(e,`读取智能体失败`)}},U=async()=>{let e=await I.form.validate();z(!0);try{await h.post(`/multi-agent/markdown-agents`,{filename:e.filename?.trim()||``,name:e.name.trim(),description:e.description?.trim()||``,instruction:e.instruction,kind:e.kind||`sub`,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean)}),D(`智能体已保存`),L(null),B.reload()}catch(e){v(e,`保存智能体失败`)}finally{z(!1)}},W=e=>O({title:`删除智能体「${e.name||e.filename}」?`,onOk:async()=>{await h.del(`/multi-agent/markdown-agents/${encodeURIComponent(e.filename)}`),D(`已删除`),B.reload()}});return(0,A.jsxs)(`div`,{children:[(0,A.jsx)(w,{title:e(`agents.title`,null,`智能体管理`),description:B.data?.dir?`目录:${B.data.dir}`:`以 Markdown 文件定义的子智能体与编排器。`,extra:(0,A.jsxs)(i,{children:[(0,A.jsx)(o,{icon:(0,A.jsx)(p,{}),onClick:()=>B.reload(),loading:B.loading,children:`刷新`}),n&&(0,A.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(d,{}),onClick:()=>L({record:null,form:{}}),children:`新建智能体`})]})}),B.data?.error&&(0,A.jsx)(S,{error:B.data.error}),(0,A.jsxs)(C,{title:`智能体(${V.length})`,children:[(0,A.jsx)(S,{error:B.error,onRetry:()=>B.reload()}),(0,A.jsx)(T,{columns:[{title:`智能体`,dataIndex:`name`,render:(e,t)=>(0,A.jsxs)(i,{vertical:!0,spacing:0,align:`start`,children:[(0,A.jsxs)(i,{children:[(0,A.jsx)(j,{strong:!0,children:e||t.id}),t.is_orchestrator&&(0,A.jsx)(s,{size:`small`,color:`purple`,children:`编排器`})]}),(0,A.jsx)(j,{type:`tertiary`,children:t.filename})]})},{title:`类型`,dataIndex:`kind`,width:110,render:e=>(0,A.jsx)(s,{size:`small`,children:e||`sub`})},{title:`描述`,dataIndex:`description`,render:e=>(0,A.jsx)(j,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:e||`—`})},{title:`操作`,width:180,render:(e,t)=>(0,A.jsxs)(i,{children:[(0,A.jsx)(o,{size:`small`,theme:`borderless`,onClick:()=>H(t),children:`详情`}),n&&(0,A.jsx)(o,{size:`small`,theme:`borderless`,icon:(0,A.jsx)(r,{}),onClick:()=>L({record:t,form:{}})}),c&&(0,A.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,A.jsx)(u,{}),onClick:()=>W(t)})]})}],dataSource:V,rowKey:`filename`,loading:B.loading,pagination:{pageSize:20},toolbar:(0,A.jsx)(a,{prefix:(0,A.jsx)(f,{}),value:M,onChange:N,placeholder:`搜索名称或文件名`,style:{width:280}})})]}),(0,A.jsx)(y,{title:I?.record?`编辑智能体`:`新建智能体`,visible:!!I,onCancel:()=>L(null),onOk:U,confirmLoading:R,width:760,children:(0,A.jsxs)(l,{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)(l.Input,{field:`filename`,label:`文件名(留空自动生成)`,placeholder:`例如 recon.md`}),(0,A.jsx)(l.Input,{field:`name`,label:`名称`,rules:[{required:!0,message:`请输入名称`}]}),(0,A.jsx)(l.Input,{field:`description`,label:`描述`}),(0,A.jsx)(l.Select,{field:`kind`,label:`类型`,optionList:[{value:`sub`,label:`子智能体`},{value:`orchestrator`,label:`编排器`},{value:`plan_execute`,label:`计划执行`}]}),(0,A.jsx)(l.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::tool`}),(0,A.jsx)(l.TextArea,{field:`instruction`,label:`指令(Markdown)`,autosize:{minRows:8,maxRows:20}})]})},I?.record?.filename||`new-agent`),(0,A.jsx)(y,{title:P?.name||`智能体详情`,visible:!!P,onCancel:()=>F(null),width:720,children:P&&(0,A.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,A.jsx)(b,{items:[{label:`文件名`,value:P.filename},{label:`ID`,value:P.id},{label:`类型`,value:P.kind},{label:`绑定角色`,value:P.bind_role||`—`},{label:`最大迭代`,value:P.max_iterations??`—`},{label:`工具`,value:Array.isArray(P.tools)&&P.tools.length?P.tools.join(`、`):`—`}]}),(0,A.jsx)(x,{content:P.instruction||P.raw||``}),(0,A.jsx)(E,{value:P.raw||P,title:`原始 Markdown`,collapsed:!0})]})})]})}export{M as default};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{F as t,L as n,W as r}from"./semi-CXF9U6uC.js";import{E as i,P as a,k as o}from"./index-LQJrYSgy.js";import"./c2-shared-jjs4Y-hT.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-CDAktpYA.js";import{E as i,P as a,k as o}from"./index-BKN3rSq_.js";import"./c2-shared-VjZmfOYI.js";import{t as s}from"./react-QV7DAAIx.js";var c=e(s(),1),{Text:l}=r,u=[{value:`http_beacon`,label:`HTTP Beacon`},{value:`https_beacon`,label:`HTTPS Beacon`},{value:`tcp_reverse`,label:`TCP 反向`},{value:`websocket`,label:`WebSocket`}],d={running:`运行中`,stopped:`已停止`,error:`异常`},f={tcp_reverse:[{value:`bash`,label:`Bash (/dev/tcp)`},{value:`nc`,label:`Netcat (-e)`},{value:`nc_mkfifo`,label:`Netcat (mkfifo)`},{value:`python`,label:`Python`},{value:`perl`,label:`Perl`},{value:`powershell`,label:`PowerShell`}],http_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],https_beacon:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}],websocket:[{value:`curl_beacon`,label:`Curl Beacon (HTTP)`}]},p=[{value:`shell`,label:`shell`},{value:`exec`,label:`exec`},{value:`ls`,label:`ls`},{value:`pwd`,label:`pwd`},{value:`cd`,label:`cd`},{value:`ps`,label:`ps`},{value:`kill_proc`,label:`kill_proc`},{value:`download`,label:`download`},{value:`upload`,label:`upload`},{value:`screenshot`,label:`screenshot`},{value:`sleep`,label:`sleep`},{value:`exit`,label:`exit`},{value:`self_delete`,label:`self_delete`},{value:`port_fwd`,label:`port_fwd`},{value:`socks_start`,label:`socks_start`},{value:`socks_stop`,label:`socks_stop`},{value:`load_assembly`,label:`load_assembly`},{value:`persist`,label:`persist`}],m=[{value:`queued`,label:`队列中`},{value:`sent`,label:`已发送`},{value:`running`,label:`执行中`},{value:`success`,label:`成功`},{value:`failed`,label:`失败`},{value:`cancelled`,label:`已取消`}],h=[{value:`info`,label:`信息`},{value:`warn`,label:`警告`},{value:`critical`,label:`严重`}],g=[{value:`listener`,label:`监听器`},{value:`session`,label:`会话`},{value:`task`,label:`任务`},{value:`payload`,label:`Payload`},{value:`opsec`,label:`OPSEC`}],_=[{value:`active`,label:`活跃`},{value:`sleeping`,label:`休眠`},{value:`dead`,label:`离线`},{value:`killed`,label:`已终止`}],v=[{value:`15m`,label:`最近15分钟`,ms:9e5},{value:`1h`,label:`最近1小时`,ms:36e5},{value:`24h`,label:`最近24小时`,ms:864e5},{value:`7d`,label:`最近7天`,ms:6048e5},{value:`all`,label:`全部`,ms:0}];function y(e){let t=v.find(t=>t.value===e);return!t||!t.ms?``:new Date(Date.now()-t.ms).toISOString()}function b({value:e,onChange:r,ns:i=`tasks`}){let o=a();return(0,c.jsxs)(t,{spacing:6,wrap:!0,className:`c2-time-presets`,children:[(0,c.jsx)(l,{type:`tertiary`,size:`small`,children:o(`c2.tasks.timePresets`,null,`快捷`)}),v.map(t=>(0,c.jsx)(n,{size:`small`,theme:t.value===e?`solid`:`borderless`,type:t.value===e?`primary`:`tertiary`,onClick:()=>r(t.value),children:o(`c2.${i}.preset${t.value===`all`?`All`:t.value}`,null,t.label)},t.value))]})}function x(e){let t=Number(e);return!Number.isFinite(t)||t<=0?`—`:t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}秒`:`${Math.round(t/6e4)}分钟`}function S({value:e}){let t=a();return e?(0,c.jsx)(`span`,{className:`c2-time-text`,title:i(e),children:o(e,t)}):(0,c.jsx)(l,{type:`tertiary`,children:`—`})}var C={running:`green`,stopped:`grey`,error:`red`},w={queued:`amber`,sent:`blue`,running:`blue`,success:`green`,failed:`red`,cancelled:`grey`},T={active:`green`,sleeping:`amber`,dead:`grey`,killed:`red`},E={info:`blue`,warn:`amber`,critical:`red`};export{d as a,T as c,m as d,p as f,y as g,x as h,C as i,_ as l,S as m,E as n,u as o,b as p,h as r,f as s,g as t,w as u};
|
||||
|
|
@ -1 +1 @@
|
|||
import{I as e,L as t}from"./index-LQJrYSgy.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-BKN3rSq_.js";var n=encodeURIComponent,r=t=>e.get(`/c2/listeners`,t),i=t=>e.post(`/c2/listeners`,t),a=(t,r)=>e.put(`/c2/listeners/${n(t)}`,r),o=t=>e.del(`/c2/listeners/${n(t)}`),s=t=>e.post(`/c2/listeners/${n(t)}/start`,{}),c=t=>e.post(`/c2/listeners/${n(t)}/stop`,{}),l=t=>e.get(`/c2/sessions`,t),u=t=>e.get(`/c2/sessions/${n(t)}`),d=t=>e.del(`/c2/sessions/${n(t)}`),f=t=>e.del(`/c2/sessions`,{body:{ids:t}}),p=(t,{sleepSeconds:r,jitterPercent:i})=>e.put(`/c2/sessions/${n(t)}/sleep`,{sleep_seconds:r,jitter_percent:i}),m=(t,r)=>e.put(`/c2/sessions/${n(t)}/note`,{note:r}),h=t=>e.get(`/c2/tasks`,t),g=t=>e.get(`/c2/tasks/${n(t)}`),_=t=>e.post(`/c2/tasks`,t),v=(t,r)=>e.post(`/c2/sessions/${n(t)}/tasks`,r),y=t=>e.post(`/c2/tasks/${n(t)}/cancel`,{}),b=(t,r=30)=>e.get(`/c2/tasks/${n(t)}/wait`,{timeout:r},{timeout:(r+10)*1e3}),x=t=>e.del(`/c2/tasks`,{body:{ids:t}}),S=(e,r)=>t(`/c2/tasks/${n(e)}/result-file`,{filename:r}),C=t=>e.post(`/c2/payloads/oneliner`,t),w=t=>e.post(`/c2/payloads/build`,t),T=(e,r)=>t(`/c2/payloads/${n(e)}/download`,{filename:r}),E=t=>e.get(`/c2/events`,t),D=t=>e.del(`/c2/events`,{body:{ids:t}}),O=()=>e.get(`/c2/profiles`),k=t=>e.post(`/c2/profiles`,t),A=(t,r)=>e.put(`/c2/profiles/${n(t)}`,r),j=t=>e.del(`/c2/profiles/${n(t)}`);async function M(){try{let t=await e.get(`/projects`,{limit:200});return Array.isArray(t?.projects)?t.projects:[]}catch{return[]}}export{b as A,h as C,c as D,s as E,a as O,l as S,p as T,g as _,k as a,O as b,D as c,d,f,u as g,S as h,i,A as k,o as l,T as m,w as n,v as o,x as p,y as r,_ as s,C as t,j as u,E as v,m as w,M as x,r as y};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -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,Tt as s,W as c,at as l,ot as u}from"./semi-CXF9U6uC.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-LQJrYSgy.js";var T=e(t(),1),E=e(n(),1),{Text:D}=c;function O(){let e=m(),{hasPermission:t}=f(),n=t(`knowledge:delete`),[c,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(50),[j,M]=(0,T.useState)(null),N=h(()=>p.get(`/knowledge/retrieval-logs`,{conversationId:c||void 0,limit:k}),[c,k]),P=Array.isArray(N.data?.logs)?N.data.logs:[],F=e=>w({title:`删除该检索日志?`,content:e.query||e.id,onOk:async()=>{await p.del(`/knowledge/retrieval-logs/${encodeURIComponent(e.id)}`),C(`已删除`),N.reload()}});return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(b,{title:e(`knowledge.retrievalLogsTitle`,null,`检索历史`),description:`记录智能体每次知识库检索的语句、命中项与会话,用于回溯回答依据。`,extra:(0,E.jsx)(a,{icon:(0,E.jsx)(u,{}),onClick:()=>N.reload(),loading:N.loading,children:`刷新`})}),(0,E.jsxs)(y,{title:`检索记录(${P.length})`,children:[(0,E.jsx)(v,{error:N.error,onRetry:()=>N.reload()}),(0,E.jsx)(x,{columns:[{title:`检索语句`,dataIndex:`query`,render:(e,t)=>(0,E.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>M(t),style:{background:`none`,border:`none`,padding:0,cursor:`pointer`,textAlign:`left`,color:`var(--semi-color-primary)`},children:e||`—`})},{title:`风险类型`,dataIndex:`riskType`,width:140,render:e=>e?(0,E.jsx)(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)(s,{}),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)(l,{}),placeholder:`按会话 ID 过滤`,value:c,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,kt as c,ot as l,st as u}from"./semi-CDAktpYA.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-BKN3rSq_.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)(u,{}),onClick:()=>N.reload(),loading:N.loading,children:`刷新`})}),(0,E.jsxs)(y,{title:`检索记录(${P.length})`,children:[(0,E.jsx)(v,{error:N.error,onRetry:()=>N.reload()}),(0,E.jsx)(x,{columns:[{title:`检索语句`,dataIndex:`query`,render:(e,t)=>(0,E.jsx)(`button`,{type:`button`,className:`link-button`,onClick:()=>M(t),style:{background:`none`,border:`none`,padding:0,cursor:`pointer`,textAlign:`left`,color:`var(--semi-color-primary)`},children:e||`—`})},{title:`风险类型`,dataIndex:`riskType`,width:140,render:e=>e?(0,E.jsx)(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)(c,{}),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)(l,{}),placeholder:`按会话 ID 过滤`,value:s,onChange:O,style:{width:260}}),(0,E.jsx)(i,{placeholder:`条数`,value:String(k),onChange:e=>A(Math.min(Math.max(Number(e)||50,1),500)),style:{width:100},suffix:(0,E.jsx)(D,{type:`tertiary`,children:`条`})})]})})]}),(0,E.jsx)(g,{title:`检索日志详情`,visible:!!j,onCancel:()=>M(null),width:560,children:j&&(0,E.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,E.jsx)(_,{items:[{label:`日志 ID`,value:j.id},{label:`检索语句`,value:j.query},{label:`风险类型`,value:j.riskType||`—`},{label:`会话 ID`,value:j.conversationId||`—`},{label:`消息 ID`,value:j.messageId||`—`},{label:`时间`,value:d(j.createdAt)}]}),(0,E.jsx)(S,{value:j.retrievedItems||[],title:`命中知识项`})]})})]})}export{O as default};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -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-CXF9U6uC.js";import{I as a,P as o,c as s,l as c,x as l}from"./index-LQJrYSgy.js";var u=e(t(),1),d=e(n(),1),{Text:f}=r,p=120,m=4e3;function h({visible:e,project:t,onCancel:n,onSaved:r}){let h=o(),g=(0,u.useId)(),[_,v]=(0,u.useState)(!1),[y,b]=(0,u.useState)(null),x=!!t?.id;return(0,u.useEffect)(()=>{b(null)},[e,t?.id]),(0,d.jsxs)(s,{visible:e,width:560,closable:!_,closeOnEsc:!_,onCancel:n,cancelButtonProps:{disabled:_},title:x?h(`projects.modalEditTitle`,null,`编辑项目`):h(`projects.modalNewTitle`,null,`新建项目`),formId:g,okText:x?h(`projects.saveChanges`,null,`保存修改`):h(`projects.createProject`,null,`创建项目`),confirmLoading:_,children:[(0,d.jsx)(f,{type:`tertiary`,size:`small`,children:x?h(`projects.modalEditSubtitle`,null,`修改项目名称与描述`):h(`projects.modalNewSubtitle`,null,`创建后可绑定对话,跨会话共享事实黑板`)}),(0,d.jsxs)(i,{id:g,onSubmit:async e=>{if(!_){v(!0),b(null);try{let n={name:e.name.trim(),description:(e.description||``).slice(0,m)},i=x?await a.put(`/projects/${t.id}`,n):await a.post(`/projects`,n);l(x?h(`projects.saved`,null,`已保存`):h(`projects.createProject`,null,`创建项目`)),r?.(i)}catch(e){b(e)}finally{v(!1)}}},initValues:{name:t?.name||``,description:t?.description||``},children:[(0,d.jsx)(i.Input,{id:`${g}-name`,field:`name`,maxLength:p,label:h(`projects.projectName`,null,`项目名称`),placeholder:h(`projects.projectNamePlaceholder`,null,`例如:某客户 Web 渗透`),rules:[{required:!0,whitespace:!0,message:h(`projects.enterProjectName`,null,`请输入项目名称`)}]}),(0,d.jsx)(i.TextArea,{id:`${g}-description`,field:`description`,rows:4,maxCount:m,label:h(`projects.projectDescription`,null,`项目描述`),placeholder:h(`projects.projectDescriptionPlaceholder`,null,`客户/任务备注、协作说明…`),extraText:h(`projects.descriptionLengthHint`,null,`仅供团队成员查阅,Agent 不会读取;需让 Agent 知晓的内容请写入事实黑板`)}),(0,d.jsx)(c,{error:y})]},`${e}-${t?.id||`new`}`)]})}export{h as t};
|
||||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{W as r,i}from"./semi-CDAktpYA.js";import{I as a,P as o,c as s,l as c,x as l}from"./index-BKN3rSq_.js";var u=e(t(),1),d=e(n(),1),{Text:f}=r,p=120,m=4e3;function h({visible:e,project:t,onCancel:n,onSaved:r}){let h=o(),g=(0,u.useId)(),[_,v]=(0,u.useState)(!1),[y,b]=(0,u.useState)(null),x=!!t?.id;return(0,u.useEffect)(()=>{b(null)},[e,t?.id]),(0,d.jsxs)(s,{visible:e,width:560,closable:!_,closeOnEsc:!_,onCancel:n,cancelButtonProps:{disabled:_},title:x?h(`projects.modalEditTitle`,null,`编辑项目`):h(`projects.modalNewTitle`,null,`新建项目`),formId:g,okText:x?h(`projects.saveChanges`,null,`保存修改`):h(`projects.createProject`,null,`创建项目`),confirmLoading:_,children:[(0,d.jsx)(f,{type:`tertiary`,size:`small`,children:x?h(`projects.modalEditSubtitle`,null,`修改项目名称与描述`):h(`projects.modalNewSubtitle`,null,`创建后可绑定对话,跨会话共享事实黑板`)}),(0,d.jsxs)(i,{id:g,onSubmit:async e=>{if(!_){v(!0),b(null);try{let n={name:e.name.trim(),description:(e.description||``).slice(0,m)},i=x?await a.put(`/projects/${t.id}`,n):await a.post(`/projects`,n);l(x?h(`projects.saved`,null,`已保存`):h(`projects.createProject`,null,`创建项目`)),r?.(i)}catch(e){b(e)}finally{v(!1)}}},initValues:{name:t?.name||``,description:t?.description||``},children:[(0,d.jsx)(i.Input,{id:`${g}-name`,field:`name`,maxLength:p,label:h(`projects.projectName`,null,`项目名称`),placeholder:h(`projects.projectNamePlaceholder`,null,`例如:某客户 Web 渗透`),rules:[{required:!0,whitespace:!0,message:h(`projects.enterProjectName`,null,`请输入项目名称`)}]}),(0,d.jsx)(i.TextArea,{id:`${g}-description`,field:`description`,rows:4,maxCount:m,label:h(`projects.projectDescription`,null,`项目描述`),placeholder:h(`projects.projectDescriptionPlaceholder`,null,`客户/任务备注、协作说明…`),extraText:h(`projects.descriptionLengthHint`,null,`仅供团队成员查阅,Agent 不会读取;需让 Agent 知晓的内容请写入事实黑板`)}),(0,d.jsx)(c,{error:y})]},`${e}-${t?.id||`new`}`)]})}export{h as t};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,t as n}from"./react-QV7DAAIx.js";import{F as r,H as i,L as a,M as o,St as s,Tt as c,W as l,at as u,ct as d,i as f,ot as p}from"./semi-CXF9U6uC.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-LQJrYSgy.js";var E=e(t(),1),D=e(n(),1),{Text:O}=l;function k(){let e=g(),{hasPermission:t}=m(),n=t(`roles:write`),l=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)(p,{}),onClick:()=>F.reload(),loading:F.loading,children:`刷新`}),n&&(0,D.jsx)(a,{theme:`solid`,type:`primary`,icon:(0,D.jsx)(d,{}),onClick:()=>M({role:null,form:{}}),children:`新建角色`})]})}),(0,D.jsxs)(x,{title:`角色(${I.length})`,children:[(0,D.jsx)(b,{error:F.error,onRetry:()=>F.reload()}),(0,D.jsx)(C,{columns:[{title:`角色`,dataIndex:`name`,render:(e,t)=>(0,D.jsxs)(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)(s,{}),onClick:()=>M({role:t,form:{}}),children:`编辑`}),l&&(0,D.jsx)(a,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,D.jsx)(c,{}),onClick:()=>R(t)})]})}],dataSource:I,rowKey:`name`,loading:F.loading,pagination:{pageSize:20},toolbar:(0,D.jsx)(i,{prefix:(0,D.jsx)(u,{}),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)(f,{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)(f.Input,{field:`name`,label:`角色名称`,rules:[{required:!0,message:`请输入角色名称`}]}),(0,D.jsx)(f.Input,{field:`description`,label:`描述`}),(0,D.jsx)(f.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::toolName`}),(0,D.jsx)(f.TextArea,{field:`user_prompt`,label:`用户提示词(追加到用户消息前)`,autosize:{minRows:6,maxRows:18}}),(0,D.jsx)(f.Slot,{label:`启用`,children:(0,D.jsx)(f.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{Et as r,F as i,H as a,L as o,M as s,W as c,i as l,kt as u,lt as d,ot as f,st as p}from"./semi-CDAktpYA.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-BKN3rSq_.js";var E=e(t(),1),D=e(n(),1),{Text:O}=c;function k(){let e=g(),{hasPermission:t}=m(),n=t(`roles:write`),c=t(`roles:delete`),[k,A]=(0,E.useState)(``),[j,M]=(0,E.useState)(null),[N,P]=(0,E.useState)(!1),F=_(()=>h.get(`/roles`),[]),I=(Array.isArray(F.data?.roles)?F.data.roles:[]).filter(e=>{if(!k)return!0;let t=k.toLowerCase();return[e.name,e.description].some(e=>String(e||``).toLowerCase().includes(t))}),L=async()=>{let e=await j.form.validate();P(!0);try{let t={name:e.name.trim(),description:e.description?.trim()||``,user_prompt:e.user_prompt||``,tools:String(e.tools||``).split(`,`).map(e=>e.trim()).filter(Boolean),enabled:e.enabled!==!1},n=j.role?.name;n&&n!==t.name?(await h.post(`/roles`,t),await h.del(`/roles/${encodeURIComponent(n)}`)):n?await h.put(`/roles/${encodeURIComponent(n)}`,t):await h.post(`/roles`,t),w(`角色已保存`),M(null),F.reload()}catch(e){v(e,`保存角色失败`)}finally{P(!1)}},R=e=>T({title:`删除角色「${e.name}」?`,content:`已绑定该角色的对话将失去对应提示词与工具配置。`,onOk:async()=>{await h.del(`/roles/${encodeURIComponent(e.name)}`),w(`已删除`),F.reload()}});return(0,D.jsxs)(`div`,{children:[(0,D.jsx)(S,{title:e(`roles.title`,null,`角色管理`),description:`角色定义对话的系统提示词、可用工具与绑定工作流。`,extra:(0,D.jsxs)(i,{children:[(0,D.jsx)(o,{icon:(0,D.jsx)(p,{}),onClick:()=>F.reload(),loading:F.loading,children:`刷新`}),n&&(0,D.jsx)(o,{theme:`solid`,type:`primary`,icon:(0,D.jsx)(d,{}),onClick:()=>M({role:null,form:{}}),children:`新建角色`})]})}),(0,D.jsxs)(x,{title:`角色(${I.length})`,children:[(0,D.jsx)(b,{error:F.error,onRetry:()=>F.reload()}),(0,D.jsx)(C,{columns:[{title:`角色`,dataIndex:`name`,render:(e,t)=>(0,D.jsxs)(i,{vertical:!0,spacing:0,align:`start`,children:[(0,D.jsxs)(i,{children:[(0,D.jsx)(O,{strong:!0,children:e}),t.enabled===!1&&(0,D.jsx)(s,{size:`small`,color:`grey`,children:`已停用`})]}),(0,D.jsx)(O,{type:`tertiary`,ellipsis:{showTooltip:!0},style:{maxWidth:460},children:t.description||`—`})]})},{title:`工具`,dataIndex:`tools`,width:260,render:e=>Array.isArray(e)&&e.length?(0,D.jsxs)(i,{wrap:!0,spacing:4,children:[e.slice(0,4).map(e=>(0,D.jsx)(s,{size:`small`,children:e},e)),e.length>4&&(0,D.jsxs)(O,{type:`tertiary`,children:[`+`,e.length-4]})]}):(0,D.jsx)(O,{type:`tertiary`,children:`未绑定`})},{title:`工作流`,dataIndex:`workflow_id`,width:160,render:e=>e||`—`},{title:`操作`,width:150,render:(e,t)=>(0,D.jsxs)(i,{children:[n&&(0,D.jsx)(o,{size:`small`,theme:`borderless`,icon:(0,D.jsx)(r,{}),onClick:()=>M({role:t,form:{}}),children:`编辑`}),c&&(0,D.jsx)(o,{size:`small`,theme:`borderless`,type:`danger`,icon:(0,D.jsx)(u,{}),onClick:()=>R(t)})]})}],dataSource:I,rowKey:`name`,loading:F.loading,pagination:{pageSize:20},toolbar:(0,D.jsx)(a,{prefix:(0,D.jsx)(f,{}),value:k,onChange:A,placeholder:`搜索角色名称`,style:{width:260}})})]}),(0,D.jsx)(y,{title:j?.role?`编辑角色`:`新建角色`,visible:!!j,onCancel:()=>M(null),onOk:L,confirmLoading:N,width:760,children:(0,D.jsxs)(l,{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)(l.Input,{field:`name`,label:`角色名称`,rules:[{required:!0,message:`请输入角色名称`}]}),(0,D.jsx)(l.Input,{field:`description`,label:`描述`}),(0,D.jsx)(l.Input,{field:`tools`,label:`工具(逗号分隔)`,placeholder:`toolName, mcp::toolName`}),(0,D.jsx)(l.TextArea,{field:`user_prompt`,label:`用户提示词(追加到用户消息前)`,autosize:{minRows:6,maxRows:18}}),(0,D.jsx)(l.Slot,{label:`启用`,children:(0,D.jsx)(l.Switch,{field:`enabled`})})]})},j?.role?.name||`new-role`)]})}export{k as default};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{F as t,L as n,Tt as r,W as i,ot as a}from"./semi-CXF9U6uC.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-LQJrYSgy.js";import{t as y}from"./react-QV7DAAIx.js";var b=e(y(),1),{Text:x}=i;function S(){let e=u(),{hasPermission:i}=s(),y=i(`skills:delete`),S=f(()=>c.get(`/skills/stats`),[]),C=Array.isArray(S.data?.stats)?S.data.stats:[],w=Number(S.data?.total_calls||0),T=Number(S.data?.total_success||0),E=w>0?T/w:null,D=()=>v({title:`清空所有技能调用统计?`,content:`只影响统计计数,不删除技能文件。`,onOk:async()=>{await c.del(`/skills/stats`),_(`统计已清空`),S.reload()}}),O=e=>v({title:`清空「${e}」的统计?`,onOk:async()=>{await c.del(`/skills/${encodeURIComponent(e)}/stats`),_(`已清空`),S.reload()}});return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(h,{title:e(`skills.monitorTitle`,null,`技能状态`),description:S.data?.skills_dir?`技能目录:${S.data.skills_dir}`:`统计技能被调用的次数、成功率与最近使用时间。`,extra:(0,b.jsxs)(t,{children:[(0,b.jsx)(n,{icon:(0,b.jsx)(a,{}),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)(r,{}),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,kt as i,st as a}from"./semi-CDAktpYA.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-BKN3rSq_.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)(a,{}),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)(i,{}),onClick:()=>O(t.skill_name),children:`清空`}):null}],dataSource:C,rowKey:`skill_name`,loading:S.loading,pagination:{pageSize:20}})]})]})}export{S as default};
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -18,10 +18,10 @@
|
|||
} catch (error) { /* first paint fallback */ }
|
||||
})();
|
||||
</script>
|
||||
<script type="module" crossorigin src="/static/app/assets/index-LQJrYSgy.js"></script>
|
||||
<script type="module" crossorigin src="/static/app/assets/index-BKN3rSq_.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-CXF9U6uC.js">
|
||||
<link rel="modulepreload" crossorigin href="/static/app/assets/semi-CDAktpYA.js">
|
||||
<link rel="stylesheet" crossorigin href="/static/app/assets/semi-BUXPdXzR.css">
|
||||
<link rel="stylesheet" crossorigin href="/static/app/assets/index-BwdEm4YK.css">
|
||||
</head>
|
||||
|
|
|
|||
|
|
@ -510,7 +510,7 @@
|
|||
"graphNoMatches": "لا توجد عُقد مطابقة",
|
||||
"graphBackToOverview": "العودة إلى النظرة العامة",
|
||||
"graphFocus": "العلاقات المباشرة · {{stats}}",
|
||||
"graphOverviewHint": "اختر عقدة لعرض علاقاتها. كبّر الرسم لرؤية مزيد من التسميات.",
|
||||
"graphOverviewHint": "اختر عقدة لعرض علاقاتها. كبّر الرسم لقراءة ملخصات البطاقات.",
|
||||
"graphCanvas": "لوحة مسار الهجوم",
|
||||
"graphRenderError": "تعذّر تحميل الرسم. حدّث الصفحة للمحاولة مجددًا.",
|
||||
"graphTentativeEdge": "علاقة مبدئية",
|
||||
|
|
|
|||
|
|
@ -511,7 +511,7 @@
|
|||
"graphNoMatches": "No matching nodes",
|
||||
"graphBackToOverview": "Back to overview",
|
||||
"graphFocus": "Direct connections · {{stats}}",
|
||||
"graphOverviewHint": "Select a node to see its connections. Zoom in to reveal more labels.",
|
||||
"graphOverviewHint": "Select a node to see its connections. Zoom in to read the card summaries.",
|
||||
"graphCanvas": "Attack path canvas",
|
||||
"graphRenderError": "Could not load the graph. Refresh to retry.",
|
||||
"graphTentativeEdge": "Tentative link",
|
||||
|
|
|
|||
|
|
@ -523,7 +523,7 @@
|
|||
"graphNoMatches": "Подходящие узлы не найдены",
|
||||
"graphBackToOverview": "К общему виду",
|
||||
"graphFocus": "Прямые связи · {{stats}}",
|
||||
"graphOverviewHint": "Выберите узел, чтобы увидеть его связи. Увеличьте масштаб, чтобы увидеть больше подписей.",
|
||||
"graphOverviewHint": "Выберите узел, чтобы увидеть его связи. Увеличьте масштаб, чтобы прочитать описания в карточках.",
|
||||
"graphCanvas": "Граф путей атаки",
|
||||
"graphRenderError": "Не удалось загрузить граф. Обновите страницу.",
|
||||
"graphTentativeEdge": "Предварительная связь",
|
||||
|
|
|
|||
|
|
@ -499,7 +499,7 @@
|
|||
"graphNoMatches": "未找到匹配节点",
|
||||
"graphBackToOverview": "返回全图",
|
||||
"graphFocus": "聚焦直接关系 · {{stats}}",
|
||||
"graphOverviewHint": "点选节点查看直接关系,放大后显示更多标签。",
|
||||
"graphOverviewHint": "点选节点查看直接关系,放大可查看卡片摘要。",
|
||||
"graphCanvas": "攻击路径画布",
|
||||
"graphRenderError": "图谱加载失败,请刷新重试。",
|
||||
"graphTentativeEdge": "待确认关系",
|
||||
|
|
|
|||
Loading…
Reference in New Issue