mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-11-26 10:21:50 +08:00
feat: add optional credential processing with dependent switches and traffic evidence
This commit is contained in:
1 parent
7c2efbc1ca
commit
851e3f99ed
16 files changed
+1881
-38
No files matched your search
@@ -20,6 +20,9 @@ import { BasicAuthCard } from "./_components/basic-auth-card";
|
||||
import { UpdateCard } from "./_components/update-card";
|
||||
|
||||
export default function SystemSettingsPage() {
|
||||
const [credentialAgent, setCredentialAgent] = React.useState(false);
|
||||
const [credentialBinding, setCredentialBinding] = React.useState(false);
|
||||
const [savingCredentials, setSavingCredentials] = React.useState(false);
|
||||
const [intelligenceEnabled, setIntelligenceEnabled] = React.useState(false);
|
||||
const [savingIntelligence, setSavingIntelligence] = React.useState(false);
|
||||
const [trafficCapture, setTrafficCapture] = React.useState(false);
|
||||
@@ -51,6 +54,8 @@ export default function SystemSettingsPage() {
|
||||
const sendMode = useChatSendMode();
|
||||
|
||||
const apply = React.useCallback((s: Settings) => {
|
||||
setCredentialAgent(!!s.credential_agent_enabled);
|
||||
setCredentialBinding(!!s.credential_traffic_binding);
|
||||
setIntelligenceEnabled(!!s.task_intelligence_enabled);
|
||||
setTrafficCapture(!!s.traffic_capture);
|
||||
setAgentTrafficBinding(!!s.agent_traffic_binding);
|
||||
@@ -259,6 +264,20 @@ export default function SystemSettingsPage() {
|
||||
// brave-free selected but no key stored and none being entered → tool stays off.
|
||||
const braveNeedsKey = webSearch && backend === "brave-free" && !braveKeySet;
|
||||
|
||||
const saveCredentialOptions = async (patch: Partial<Settings>) => {
|
||||
setSavingCredentials(true);
|
||||
try {
|
||||
const s = await api.setSettings(patch);
|
||||
setCredentialAgent(!!s.credential_agent_enabled);
|
||||
setCredentialBinding(!!s.credential_traffic_binding);
|
||||
setIntelligenceEnabled(!!s.task_intelligence_enabled);
|
||||
toast.success("凭据处理设置已保存");
|
||||
} catch (e) {
|
||||
toast.error("保存失败:" + (e as Error).message);
|
||||
} finally {
|
||||
setSavingCredentials(false);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div className="flex flex-1 flex-col gap-4 md:gap-6">
|
||||
<div>
|
||||
@@ -448,19 +467,21 @@ export default function SystemSettingsPage() {
|
||||
<FieldContent>
|
||||
<FieldLabel htmlFor="task-intelligence">Agent 自动记录</FieldLabel>
|
||||
<FieldDescription>
|
||||
默认关闭。开启会增加提示和上报的 Token 消耗,不启动额外总结 Agent。 对后续 Agent
|
||||
执行生效;关闭后停止新增记录,已有情报仍可查看。
|
||||
默认关闭。任务执行时上报凭据、重要线索和敏感数据,会增加任务 Agent 的提示与上报
|
||||
Token。仅负责记录,不启动凭据整理。关闭后同时停用下方 Agent 与流量绑定,已有情报和整理结果仍可查看。
|
||||
</FieldDescription>
|
||||
</FieldContent>
|
||||
<Switch
|
||||
id="task-intelligence"
|
||||
checked={intelligenceEnabled}
|
||||
disabled={!loaded || savingIntelligence}
|
||||
disabled={!loaded || savingIntelligence || savingCredentials}
|
||||
onCheckedChange={async (value) => {
|
||||
setSavingIntelligence(true);
|
||||
try {
|
||||
const settings = await api.setSettings({ task_intelligence_enabled: value });
|
||||
setIntelligenceEnabled(!!settings.task_intelligence_enabled);
|
||||
setCredentialAgent(!!settings.credential_agent_enabled);
|
||||
setCredentialBinding(!!settings.credential_traffic_binding);
|
||||
toast.success(value ? "任务情报自动记录已开启" : "任务情报自动记录已关闭");
|
||||
} catch (error) {
|
||||
toast.error("保存失败:" + (error as Error).message);
|
||||
@@ -470,6 +491,40 @@ export default function SystemSettingsPage() {
|
||||
}}
|
||||
/>
|
||||
</Field>
|
||||
<Field orientation="horizontal" className="mt-5">
|
||||
<FieldContent>
|
||||
<FieldLabel htmlFor="credential-agent">Agent 开关</FieldLabel>
|
||||
<FieldDescription>
|
||||
默认关闭。独立整理已有和新增凭据,拆分并高亮账号、密码、Token 和
|
||||
Cookie,不改变原始上报或验证状态。复杂文本会使用额外模型 Token;可解析的 JSON
|
||||
无需模型。需先开启上方自动记录。模型可在「Agent → 凭据整理」中配置。
|
||||
</FieldDescription>
|
||||
</FieldContent>
|
||||
<Switch
|
||||
id="credential-agent"
|
||||
checked={credentialAgent}
|
||||
disabled={!loaded || savingCredentials || savingIntelligence || !intelligenceEnabled}
|
||||
onCheckedChange={(value) => void saveCredentialOptions({ credential_agent_enabled: value })}
|
||||
/>
|
||||
</Field>
|
||||
{credentialAgent ? (
|
||||
<Field orientation="horizontal" className="mt-5">
|
||||
<FieldContent>
|
||||
<FieldLabel htmlFor="credential-traffic">绑定流量</FieldLabel>
|
||||
<FieldDescription>
|
||||
默认关闭,仅在 Agent
|
||||
开关开启时可用。核对已抓取流量中的资产与凭据,关联真实请求或响应并保存匹配片段;不主动登录,也不把匹配流量视为验证成功。关闭
|
||||
Agent 时同时停用,已有绑定保留。
|
||||
</FieldDescription>
|
||||
</FieldContent>
|
||||
<Switch
|
||||
id="credential-traffic"
|
||||
checked={credentialBinding}
|
||||
disabled={!loaded || savingCredentials}
|
||||
onCheckedChange={(value) => void saveCredentialOptions({ credential_traffic_binding: value })}
|
||||
/>
|
||||
</Field>
|
||||
) : null}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
|
||||
@@ -0,0 +1,303 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
import { CopyIcon } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import { HttpCodeBlock } from "@/components/http-code-block";
|
||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { api } from "@/lib/api";
|
||||
import { toneClasses } from "@/lib/status";
|
||||
import type { CredentialAccount, CredentialTrafficDetail, TaskIntelligence } from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function intelligencePreview(text: string, limit = 260) {
|
||||
const chars = Array.from(text);
|
||||
return chars.length > limit ? `${chars.slice(0, limit).join("")}…` : text;
|
||||
}
|
||||
const FIELDS = [
|
||||
["username", "账号", "blue"],
|
||||
["password", "密码", "violet"],
|
||||
["token", "Token / API Key", "violet"],
|
||||
["cookie", "Cookie", "amber"],
|
||||
] as const;
|
||||
function HighlightedOriginal({ text, accounts }: { text: string; accounts: CredentialAccount[] }) {
|
||||
const parts = React.useMemo(() => {
|
||||
const values = [
|
||||
...new Set(accounts.flatMap((a) => [a.username, a.password, a.token, a.cookie]).filter((v): v is string => !!v)),
|
||||
]
|
||||
.sort((a, b) => b.length - a.length)
|
||||
.slice(0, 200);
|
||||
if (!values.length) return [text];
|
||||
const re = new RegExp(`(${values.map((v) => v.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|")})`, "g");
|
||||
return text.split(re);
|
||||
}, [text, accounts]);
|
||||
return (
|
||||
<pre className="whitespace-pre-wrap break-all font-mono text-xs">
|
||||
{parts.map((part, i) =>
|
||||
i % 2 ? (
|
||||
<mark key={`${i}-${part}`} className="rounded bg-primary/15 px-0.5 text-primary">
|
||||
{part}
|
||||
</mark>
|
||||
) : (
|
||||
part
|
||||
),
|
||||
)}
|
||||
</pre>
|
||||
);
|
||||
}
|
||||
export function CredentialContent({
|
||||
item,
|
||||
detail = false,
|
||||
enabled = false,
|
||||
onTraffic,
|
||||
onDetails,
|
||||
}: {
|
||||
item: TaskIntelligence;
|
||||
detail?: boolean;
|
||||
enabled?: boolean;
|
||||
onTraffic?: (id: string) => void;
|
||||
onDetails?: () => void;
|
||||
}) {
|
||||
const analysis = item.kind === "credential" ? item.credentials : undefined;
|
||||
const accounts = analysis?.accounts ?? [];
|
||||
const ready = accounts.length > 0;
|
||||
const visibleAccounts = detail ? accounts : accounts.slice(0, 2);
|
||||
const fieldsTruncated =
|
||||
!detail &&
|
||||
visibleAccounts.some((a) =>
|
||||
[a.username, a.password, a.token, a.cookie, a.endpoint, a.label, a.protocol].some(
|
||||
(v) => v && Array.from(v).length > 80,
|
||||
),
|
||||
);
|
||||
let pretty = item.content;
|
||||
try {
|
||||
pretty = JSON.stringify(JSON.parse(item.content), null, 2);
|
||||
} catch {
|
||||
// Plain-text reports keep their original representation.
|
||||
}
|
||||
return (
|
||||
<div className="flex min-w-0 flex-col gap-2">
|
||||
{analysis ? (
|
||||
<div className="flex flex-wrap items-center gap-1 text-xs text-muted-foreground">
|
||||
<Badge variant="outline">
|
||||
{analysis.state === "processing"
|
||||
? "正在整理"
|
||||
: analysis.state === "queued"
|
||||
? "等待整理"
|
||||
: analysis.state === "error"
|
||||
? "整理失败"
|
||||
: analysis.method === "rules"
|
||||
? "规则整理"
|
||||
: "Agent 整理"}
|
||||
</Badge>
|
||||
{analysis.method === "rules" ? <span>未调用模型</span> : null}
|
||||
{detail && analysis.model ? (
|
||||
<span>
|
||||
{analysis.model} ·{" "}
|
||||
{analysis.input_tokens + analysis.output_tokens > 0
|
||||
? `输入 ${analysis.input_tokens} / 输出 ${analysis.output_tokens} Token`
|
||||
: "模型未返回 Token 用量"}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
) : enabled && item.kind === "credential" ? (
|
||||
<span className="text-xs text-muted-foreground">等待凭据整理</span>
|
||||
) : null}
|
||||
{ready ? (
|
||||
<section
|
||||
className={cn("flex min-w-0 flex-col gap-2 overflow-y-auto", detail ? "max-h-96" : "max-h-80")}
|
||||
aria-label="结构化凭据"
|
||||
>
|
||||
{visibleAccounts.map((account, index) => (
|
||||
<div
|
||||
key={`${index}-${account.username ?? account.token ?? account.cookie}`}
|
||||
className="flex min-w-0 flex-col gap-2 rounded-lg border p-2"
|
||||
>
|
||||
<div className="flex flex-wrap gap-1 text-xs text-muted-foreground">
|
||||
<span>凭据 {index + 1}</span>
|
||||
{account.label ? (
|
||||
<span>· {detail ? account.label : intelligencePreview(account.label, 80)}</span>
|
||||
) : null}
|
||||
{account.protocol ? (
|
||||
<Badge variant="outline" className="max-w-full whitespace-normal break-all">
|
||||
{detail ? account.protocol : intelligencePreview(account.protocol, 80)}
|
||||
</Badge>
|
||||
) : null}
|
||||
</div>
|
||||
{account.endpoint ? (
|
||||
<span className="break-all text-xs text-muted-foreground">
|
||||
{detail ? account.endpoint : intelligencePreview(account.endpoint, 80)}
|
||||
</span>
|
||||
) : null}
|
||||
<dl className="flex min-w-0 flex-col gap-1.5">
|
||||
{FIELDS.map(([field, label, tone]) =>
|
||||
account[field] ? (
|
||||
<div key={field} className="flex min-w-0 items-start gap-2">
|
||||
<dt className="min-w-10 shrink-0 pt-1 text-xs text-muted-foreground">{label}</dt>
|
||||
<dd className="flex min-w-0 flex-1 items-start gap-1">
|
||||
<code
|
||||
data-credential-field={field}
|
||||
className={cn(
|
||||
"min-w-0 flex-1 whitespace-pre-wrap break-all rounded border px-1.5 py-1 font-mono text-xs",
|
||||
toneClasses[tone],
|
||||
)}
|
||||
>
|
||||
{detail ? account[field] : intelligencePreview(account[field] ?? "", 80)}
|
||||
</code>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
aria-label={`复制${label} ${index + 1}`}
|
||||
onClick={() =>
|
||||
void navigator.clipboard
|
||||
.writeText(account[field] ?? "")
|
||||
.then(() => toast.success(`${label}已复制`))
|
||||
.catch(() => toast.error("复制失败"))
|
||||
}
|
||||
>
|
||||
<CopyIcon />
|
||||
</Button>
|
||||
</dd>
|
||||
</div>
|
||||
) : null,
|
||||
)}
|
||||
</dl>
|
||||
</div>
|
||||
))}
|
||||
</section>
|
||||
) : null}
|
||||
{!detail && ready && (accounts.length > 2 || fieldsTruncated) ? (
|
||||
<Button variant="link" size="sm" className="h-auto justify-start p-0 text-xs" onClick={onDetails}>
|
||||
{accounts.length > 2 ? `还有 ${accounts.length - 2} 组凭据,查看详情` : "查看完整凭据"}
|
||||
</Button>
|
||||
) : null}
|
||||
{analysis?.error ? (
|
||||
<p role="status" className="break-all text-xs text-destructive">
|
||||
{analysis.error}
|
||||
</p>
|
||||
) : null}
|
||||
{analysis?.note ? <p className="text-xs text-muted-foreground">{analysis.note}</p> : null}
|
||||
{analysis?.traffic?.length ? (
|
||||
<div className="flex flex-col gap-1 text-xs">
|
||||
<span className="text-muted-foreground">关联流量 · {analysis.traffic.length} 条</span>
|
||||
{analysis.traffic.map((ref) => (
|
||||
<button
|
||||
type="button"
|
||||
key={ref.id}
|
||||
className="text-left underline underline-offset-2 [overflow-wrap:anywhere]"
|
||||
onClick={() => onTraffic?.(ref.id)}
|
||||
>
|
||||
{ref.method} {ref.url} · {ref.side === "request" ? "请求中使用" : "响应中发现"}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
{detail && analysis?.traffic_note ? (
|
||||
<p className="text-xs text-muted-foreground">{analysis.traffic_note}</p>
|
||||
) : null}
|
||||
{!ready || detail ? (
|
||||
<div className={cn(detail ? "max-h-72 overflow-auto rounded-lg bg-muted p-3" : "")}>
|
||||
{ready ? <p className="mb-2 text-xs text-muted-foreground">原始上报内容</p> : null}
|
||||
<HighlightedOriginal text={detail ? pretty : intelligencePreview(pretty)} accounts={accounts} />
|
||||
{!detail && Array.from(pretty).length > 260 ? (
|
||||
<Button variant="link" size="sm" className="h-auto justify-start p-0 text-xs" onClick={onDetails}>
|
||||
查看完整内容
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function CredentialTrafficViewer({
|
||||
scope,
|
||||
scopeId,
|
||||
item,
|
||||
trafficId,
|
||||
onClose,
|
||||
}: {
|
||||
scope: "tasks" | "assets";
|
||||
scopeId: string;
|
||||
item: TaskIntelligence | null;
|
||||
trafficId: string | null;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const [data, setData] = React.useState<CredentialTrafficDetail | null>(null);
|
||||
const [error, setError] = React.useState("");
|
||||
React.useEffect(() => {
|
||||
if (!item || !trafficId) return;
|
||||
let alive = true;
|
||||
setData(null);
|
||||
setError("");
|
||||
api
|
||||
.credentialTraffic(scope, scopeId, item.id, trafficId)
|
||||
.then((d) => {
|
||||
if (alive) setData(d);
|
||||
})
|
||||
.catch((e: Error) => {
|
||||
if (alive) setError(e.message);
|
||||
});
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [scope, scopeId, item, trafficId]);
|
||||
return (
|
||||
<Dialog
|
||||
open={!!trafficId}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) onClose();
|
||||
}}
|
||||
>
|
||||
<DialogContent className="max-h-[90vh] overflow-y-auto sm:max-w-4xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle>凭据关联流量</DialogTitle>
|
||||
<DialogDescription className="break-all">{data?.reference.url ?? "读取已绑定的真实流量"}</DialogDescription>
|
||||
</DialogHeader>
|
||||
{error ? (
|
||||
<Alert variant="destructive">
|
||||
<AlertDescription>{error}</AlertDescription>
|
||||
</Alert>
|
||||
) : data ? (
|
||||
<div className="flex flex-col gap-3">
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{data.reference.method} · HTTP {data.reference.status} ·{" "}
|
||||
{data.reference.side === "request" ? "请求包含匹配凭据" : "响应包含匹配凭据"},不代表认证验证成功。
|
||||
</p>
|
||||
<p className="text-sm">绑定时保存的匹配片段</p>
|
||||
<pre className="max-h-52 overflow-auto whitespace-pre-wrap break-all rounded bg-muted p-3 text-xs">
|
||||
{data.reference.excerpt}
|
||||
</pre>
|
||||
{data.unavailable ? (
|
||||
<Alert>
|
||||
<AlertDescription>原始流量已删除或不可用,仍可查看上方保存的匹配片段。</AlertDescription>
|
||||
</Alert>
|
||||
) : (
|
||||
<Tabs defaultValue={data.reference.side}>
|
||||
<TabsList>
|
||||
<TabsTrigger value="request">请求</TabsTrigger>
|
||||
<TabsTrigger value="response">响应</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent value="request">
|
||||
<HttpCodeBlock raw={data.req ?? ""} />
|
||||
</TabsContent>
|
||||
<TabsContent value="response">
|
||||
<HttpCodeBlock raw={data.resp ?? ""} />
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<Skeleton className="h-40" />
|
||||
)}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import Link from "next/link";
|
||||
import { CopyIcon, RefreshCwIcon } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import { CredentialContent, CredentialTrafficViewer, intelligencePreview } from "@/components/credential-content";
|
||||
import { StatusBadge, ToneDot } from "@/components/status-badge";
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
@@ -33,13 +34,6 @@ const STATUS: Record<IntelligenceKind, Record<string, string>> = {
|
||||
lead: { pending: "待跟进", in_progress: "跟进中", dismissed: "已排除", converted: "已转漏洞" },
|
||||
sensitive_data: { suspected: "疑似", confirmed: "已确认", dismissed: "已排除" },
|
||||
};
|
||||
function prettyContent(value: string) {
|
||||
try {
|
||||
return JSON.stringify(JSON.parse(value), null, 2);
|
||||
} catch {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
function time(value: string) {
|
||||
return new Date(value).toLocaleString("zh-CN");
|
||||
}
|
||||
@@ -87,6 +81,12 @@ export function IntelligencePanel({
|
||||
const [refresh, setRefresh] = React.useState(0);
|
||||
const [selected, setSelected] = React.useState<TaskIntelligence | null>(null);
|
||||
const [saving, setSaving] = React.useState(false);
|
||||
const [retrying, setRetrying] = React.useState(false);
|
||||
const [trafficTarget, setTrafficTarget] = React.useState<{ item: TaskIntelligence; id: string } | null>(null);
|
||||
React.useEffect(() => {
|
||||
if (data)
|
||||
setSelected((current) => (current ? (data.items.find((item) => item.id === current.id) ?? current) : null));
|
||||
}, [data]);
|
||||
React.useEffect(() => {
|
||||
const timer = setTimeout(() => {
|
||||
setQuery(search.trim());
|
||||
@@ -268,12 +268,20 @@ export function IntelligencePanel({
|
||||
</TableCell>
|
||||
<TableCell className="align-top whitespace-normal">
|
||||
<div className="flex min-w-0 flex-col gap-2">
|
||||
<pre className="whitespace-pre-wrap break-all font-mono text-xs">
|
||||
{prettyContent(item.content)}
|
||||
</pre>
|
||||
<CredentialContent
|
||||
item={item}
|
||||
enabled={data.credential_agent_enabled}
|
||||
onDetails={() => open(item)}
|
||||
onTraffic={(id) => setTrafficTarget({ item, id })}
|
||||
/>
|
||||
<div className="flex flex-col gap-1 text-xs text-muted-foreground">
|
||||
<span>来源证据</span>
|
||||
<p className="whitespace-pre-wrap break-all">{item.evidence}</p>
|
||||
<p className="whitespace-pre-wrap break-all">{intelligencePreview(item.evidence, 220)}</p>
|
||||
{Array.from(item.evidence).length > 220 ? (
|
||||
<button type="button" className="text-left underline" onClick={() => open(item)}>
|
||||
详情查看完整证据
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</TableCell>
|
||||
@@ -401,9 +409,35 @@ export function IntelligencePanel({
|
||||
复制
|
||||
</Button>
|
||||
</div>
|
||||
<pre className="max-h-72 overflow-auto whitespace-pre-wrap break-all rounded-lg bg-muted p-3 text-xs">
|
||||
{prettyContent(selected.content)}
|
||||
</pre>
|
||||
<CredentialContent
|
||||
item={selected}
|
||||
detail
|
||||
enabled={data?.credential_agent_enabled}
|
||||
onTraffic={(id) => setTrafficTarget({ item: selected, id })}
|
||||
/>
|
||||
{selected.kind === "credential" && !selected.inherited && data?.credential_agent_enabled ? (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
disabled={
|
||||
retrying || selected.credentials?.state === "processing" || selected.credentials?.state === "queued"
|
||||
}
|
||||
onClick={async () => {
|
||||
setRetrying(true);
|
||||
try {
|
||||
await api.retryCredentials(selected.task_id, selected.id);
|
||||
setRefresh((n) => n + 1);
|
||||
toast.success("已加入凭据处理队列");
|
||||
} catch (e) {
|
||||
toast.error((e as Error).message);
|
||||
} finally {
|
||||
setRetrying(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
重新处理凭据
|
||||
</Button>
|
||||
) : null}
|
||||
<p className="text-sm">来源证据</p>
|
||||
<pre className="max-h-48 overflow-auto whitespace-pre-wrap break-all rounded-lg bg-muted p-3 text-xs">
|
||||
{selected.evidence}
|
||||
@@ -422,6 +456,13 @@ export function IntelligencePanel({
|
||||
) : null}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
<CredentialTrafficViewer
|
||||
scope={scope}
|
||||
scopeId={scopeId}
|
||||
item={trafficTarget?.item ?? null}
|
||||
trafficId={trafficTarget?.id ?? null}
|
||||
onClose={() => setTrafficTarget(null)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import type {
|
||||
ConvTokenSummary,
|
||||
CoverageAssetRefs,
|
||||
CoverageGraphData,
|
||||
CredentialTrafficDetail,
|
||||
DailyTokenBucket,
|
||||
DeleteTaskOptions,
|
||||
DeleteTaskResult,
|
||||
@@ -922,6 +923,12 @@ export const api = {
|
||||
get<TaskIntelligence>(`/${scope}/${id}/intelligence/${intelligenceId}`),
|
||||
updateIntelligence: (taskId: number, intelligenceId: number, status: string) =>
|
||||
patch<{ updated: boolean }>(`/tasks/${taskId}/intelligence/${intelligenceId}`, { status }),
|
||||
retryCredentials: (taskId: number, intelligenceId: number) =>
|
||||
post<{ queued: boolean }>(`/tasks/${taskId}/intelligence/${intelligenceId}/credentials/retry`),
|
||||
credentialTraffic: (scope: "tasks" | "assets", scopeId: string, intelligenceId: number, trafficId: string) =>
|
||||
get<CredentialTrafficDetail>(
|
||||
`/${scope}/${scopeId}/intelligence/${intelligenceId}/traffic/${encodeURIComponent(trafficId)}`,
|
||||
),
|
||||
settings: () => get<Settings>(`/settings`),
|
||||
basicAuthSettings: () => get<{ enabled: boolean; username: string; password_set: boolean }>("/settings/basic-auth"),
|
||||
setBasicAuthSettings: (settings: { enabled: boolean; username: string; password: string }) =>
|
||||
|
||||
@@ -3325,6 +3325,8 @@ export const tools: Tool[] = [
|
||||
// ── Settings ─────────────────────────────────────────────────────────────────
|
||||
export const settings: Settings = {
|
||||
task_intelligence_enabled: false,
|
||||
credential_agent_enabled: false,
|
||||
credential_traffic_binding: false,
|
||||
traffic_capture: true,
|
||||
agent_traffic_binding: false,
|
||||
llm_record: false,
|
||||
|
||||
@@ -947,6 +947,8 @@ export interface TrafficHost {
|
||||
// ---- App settings (runtime toggles) ----
|
||||
export interface Settings {
|
||||
traffic_capture: boolean;
|
||||
credential_agent_enabled: boolean;
|
||||
credential_traffic_binding: boolean;
|
||||
task_intelligence_enabled: boolean; // 默认关闭;关闭不注入情报工具或提示
|
||||
agent_traffic_binding: boolean; // Agent 自动绑定流量证据,默认关闭;不影响人工绑定
|
||||
llm_record: boolean; // LLM 录制开关(默认关);关闭时不记录任何 LLM 调用
|
||||
@@ -1744,7 +1746,46 @@ export interface FindingCaseReviewRun {
|
||||
}
|
||||
|
||||
export type IntelligenceKind = "credential" | "lead" | "sensitive_data";
|
||||
export interface CredentialAccount {
|
||||
label?: string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
token?: string;
|
||||
cookie?: string;
|
||||
endpoint?: string;
|
||||
protocol?: string;
|
||||
}
|
||||
export interface CredentialTraffic {
|
||||
id: string;
|
||||
url: string;
|
||||
method: string;
|
||||
status: number;
|
||||
side: string;
|
||||
excerpt: string;
|
||||
accounts: number[];
|
||||
}
|
||||
export interface CredentialAnalysis {
|
||||
state: "queued" | "processing" | "ready" | "error";
|
||||
method?: "rules" | "agent";
|
||||
accounts: CredentialAccount[] | null;
|
||||
traffic: CredentialTraffic[] | null;
|
||||
traffic_state: string;
|
||||
traffic_note?: string;
|
||||
note?: string;
|
||||
error?: string;
|
||||
model?: string;
|
||||
input_tokens: number;
|
||||
output_tokens: number;
|
||||
processed_at?: string;
|
||||
}
|
||||
export interface CredentialTrafficDetail {
|
||||
reference: CredentialTraffic;
|
||||
req?: string;
|
||||
resp?: string;
|
||||
unavailable: boolean;
|
||||
}
|
||||
export interface TaskIntelligence {
|
||||
credentials?: CredentialAnalysis;
|
||||
source_session?: string;
|
||||
id: number;
|
||||
task_id: number;
|
||||
@@ -1762,6 +1803,8 @@ export interface TaskIntelligence {
|
||||
inherited: boolean;
|
||||
}
|
||||
export interface IntelligencePage {
|
||||
credential_agent_enabled: boolean;
|
||||
credential_traffic_binding: boolean;
|
||||
items: TaskIntelligence[];
|
||||
total: number;
|
||||
counts: Record<IntelligenceKind, number>;
|
||||
|
||||
Reference in new issue
Block a user