mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-11-24 09:41:51 +08:00
Merge pull request #26 from RuoJi6/codex/task-intelligence
feat: 新增可选的任务情报自动记录与查看
This commit is contained in:
35 files changed
+3692
-58
No files matched your search
+17
-1
@@ -28,6 +28,7 @@ import type {
|
||||
ConvTokenSummary,
|
||||
CoverageAssetRefs,
|
||||
CoverageGraphData,
|
||||
CredentialTrafficDetail,
|
||||
DailyTokenBucket,
|
||||
DeleteTaskOptions,
|
||||
DeleteTaskResult,
|
||||
@@ -50,6 +51,7 @@ import type {
|
||||
FindingsPage,
|
||||
FindingTraffic,
|
||||
FindingTrafficDetail,
|
||||
IntelligencePage,
|
||||
IntentAsset,
|
||||
InterceptApprovalFilter,
|
||||
InterceptApprovalRow,
|
||||
@@ -91,6 +93,7 @@ import type {
|
||||
TaskCategory,
|
||||
TaskConstraint,
|
||||
TaskGoal,
|
||||
TaskIntelligence,
|
||||
TaskLLMResolutions,
|
||||
TaskNode,
|
||||
TaskSchedule,
|
||||
@@ -337,7 +340,8 @@ export const api = {
|
||||
runScheduleNow: (id: number) =>
|
||||
post<{ ok: boolean; started: number; errors?: string[] }>(`/schedules/${id}/run-now`, {}),
|
||||
taskCategories: () => get<{ categories: TaskCategory[] }>("/task-categories").then((r) => arr(r.categories)),
|
||||
updateTask: (id: string, input: { name?: string; pinned?: boolean; remark?: string }) => patch<Task>(`/tasks/${id}`, input),
|
||||
updateTask: (id: string, input: { name?: string; pinned?: boolean; remark?: string }) =>
|
||||
patch<Task>(`/tasks/${id}`, input),
|
||||
renameTask: (id: string, name: string) => patch<Task>(`/tasks/${id}`, { name }),
|
||||
pinTask: (id: string, pinned: boolean) => patch<Task>(`/tasks/${id}`, { pinned }),
|
||||
createTaskCategory: (name: string) => post<TaskCategory>("/task-categories", { name }),
|
||||
@@ -913,6 +917,18 @@ export const api = {
|
||||
trafficDeleteAll: () => del<{ deleted: number; reclaimed: number }>(`/traffic/all`),
|
||||
|
||||
// ---- app settings (runtime toggles) ----
|
||||
intelligence: (scope: "tasks" | "assets", id: string, query: URLSearchParams) =>
|
||||
get<IntelligencePage>(`/${scope}/${id}/intelligence?${query.toString()}`),
|
||||
intelligenceDetail: (scope: "tasks" | "assets", id: string, intelligenceId: number) =>
|
||||
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 }) =>
|
||||
|
||||
@@ -3324,6 +3324,9 @@ 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,
|
||||
|
||||
@@ -109,7 +109,15 @@ const delivery: Record<string, StatusMeta> = {
|
||||
skipped: { label: "已跳过", tone: "neutral" },
|
||||
};
|
||||
|
||||
// Intelligence category colors are shared by task, asset and detail views.
|
||||
const intelligence: Record<string, StatusMeta> = {
|
||||
credential: { label: "凭据", tone: "violet" },
|
||||
lead: { label: "重要线索", tone: "blue" },
|
||||
sensitive_data: { label: "敏感数据", tone: "amber" },
|
||||
};
|
||||
|
||||
const maps = {
|
||||
intelligence,
|
||||
intent,
|
||||
task,
|
||||
severity,
|
||||
|
||||
@@ -947,6 +947,9 @@ 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 调用
|
||||
// Web search. brave_key_set / tavily_key_set reflect whether a key is stored
|
||||
@@ -1741,3 +1744,69 @@ export interface FindingCaseReviewRun {
|
||||
state: "queued" | "running" | "done" | "failed";
|
||||
error: string;
|
||||
}
|
||||
|
||||
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;
|
||||
node_id?: number;
|
||||
kind: IntelligenceKind;
|
||||
title: string;
|
||||
content: string;
|
||||
evidence: string;
|
||||
confidence: "observed" | "inferred";
|
||||
status: string;
|
||||
asset_ids: number[];
|
||||
worker: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
inherited: boolean;
|
||||
}
|
||||
export interface IntelligencePage {
|
||||
credential_agent_enabled: boolean;
|
||||
credential_traffic_binding: boolean;
|
||||
items: TaskIntelligence[];
|
||||
total: number;
|
||||
counts: Record<IntelligenceKind, number>;
|
||||
enabled: boolean;
|
||||
}
|
||||
+20
-8
@@ -57,20 +57,32 @@ export async function copyText(text: string): Promise<boolean> {
|
||||
// 继续走降级方案
|
||||
}
|
||||
}
|
||||
const active = document.activeElement;
|
||||
const selection = window.getSelection();
|
||||
const ranges = selection ? Array.from({ length: selection.rangeCount }, (_, i) => selection.getRangeAt(i)) : [];
|
||||
const textarea = document.createElement("textarea");
|
||||
try {
|
||||
const textarea = document.createElement("textarea");
|
||||
textarea.value = text;
|
||||
textarea.setAttribute("aria-label", "复制内容");
|
||||
textarea.style.position = "fixed";
|
||||
textarea.style.left = "-9999px";
|
||||
textarea.style.top = "0";
|
||||
document.body.appendChild(textarea);
|
||||
textarea.focus();
|
||||
textarea.style.opacity = "0";
|
||||
textarea.style.pointerEvents = "none";
|
||||
// Stay inside the active modal so its focus trap does not steal the selection.
|
||||
const dialogs = document.querySelectorAll('[role="dialog"][data-state="open"]');
|
||||
const container = active?.closest('[role="dialog"]') ?? dialogs.item(dialogs.length - 1) ?? document.body;
|
||||
container.appendChild(textarea);
|
||||
textarea.focus({ preventScroll: true });
|
||||
textarea.select();
|
||||
const ok = document.execCommand("copy");
|
||||
document.body.removeChild(textarea);
|
||||
return ok;
|
||||
return document.execCommand("copy");
|
||||
} catch {
|
||||
return false;
|
||||
} finally {
|
||||
textarea.remove();
|
||||
if (active instanceof HTMLElement && active.isConnected) active.focus({ preventScroll: true });
|
||||
if (selection && ranges.length) {
|
||||
selection.removeAllRanges();
|
||||
for (const range of ranges) selection.addRange(range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user