mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-12-03 20:21:51 +08:00
feat(proxy,chat): add per-task/schedule/chat proxy pool routing and @task mentions
- Support pool auto-rotation mode alongside inherit/direct/node/custom proxy routes across gateway and MITM proxy
- Add GET /api/proxy/routes/{scope}/{owner_id}, task create/DTO proxy_route, and schedule proxy persistence + propagation
- Add list_proxy_pool and set_task_proxy chat agent tools and @task mention search/context injection
- Wire shared proxy/pool selectors into tasks, schedules, chat sandbox popover, and container routes UI
This commit is contained in:
1 parent
b18cf89b77
commit
778e49317d
28 files changed
+1683
-124
No files matched your search
@@ -14,6 +14,7 @@ import {
|
||||
Trash2Icon,
|
||||
} from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { ContainerProxyControlSection } from "@/components/proxy-route-selector";
|
||||
|
||||
import {
|
||||
AlertDialog,
|
||||
@@ -250,7 +251,7 @@ export function SessionSandboxControl({
|
||||
<span className="hidden sm:inline">{stateLabel}</span>
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="end" className="w-80 space-y-3 text-xs">
|
||||
<PopoverContent align="end" className="w-96 space-y-3 text-xs">
|
||||
<PopoverHeader>
|
||||
<PopoverTitle className="flex items-center justify-between text-sm">
|
||||
<span className="flex items-center gap-1.5">
|
||||
@@ -325,6 +326,8 @@ export function SessionSandboxControl({
|
||||
{info.error ? <p className="break-all text-destructive">{info.error}</p> : null}
|
||||
</div>
|
||||
|
||||
<ContainerProxyControlSection scope={scope} ownerId={ownerID} open={open} />
|
||||
|
||||
<div className="flex flex-wrap items-center gap-1.5">
|
||||
{!running ? (
|
||||
<Button
|
||||
|
||||
@@ -18,6 +18,11 @@ import { toast } from "sonner";
|
||||
|
||||
import { DateSelect } from "@/components/date-select";
|
||||
import { RemarkEditor, ScheduleNameEditor } from "@/components/remark-editor";
|
||||
import {
|
||||
formatProxyRouteSummary,
|
||||
normalizeProxyMode,
|
||||
ProxyRouteFields,
|
||||
} from "@/components/proxy-route-selector";
|
||||
import { TimeSelect } from "@/components/time-select";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -31,7 +36,7 @@ import { localizedError } from "@/i18n/errors";
|
||||
import { useLiveTranslation } from "@/i18n/use-live-translation";
|
||||
import { api, type ScheduleInput } from "@/lib/api";
|
||||
import { scheduleDisplay } from "@/lib/schedule-display";
|
||||
import type { Task, TaskSchedule } from "@/lib/types";
|
||||
import type { ProxyPoolEntry, Task, TaskSchedule } from "@/lib/types";
|
||||
|
||||
const blank: ScheduleInput = {
|
||||
name: "",
|
||||
@@ -42,6 +47,9 @@ const blank: ScheduleInput = {
|
||||
task_ids: [],
|
||||
timezone_mode: "beijing",
|
||||
start_immediately: false,
|
||||
proxy_mode: "inherit",
|
||||
proxy_pool_id: "",
|
||||
proxy_url: "",
|
||||
};
|
||||
|
||||
type ScheduleHistoryEntry = NonNullable<TaskSchedule["history"]>[number];
|
||||
@@ -145,17 +153,19 @@ function statusClass(status: TaskSchedule["status"]) {
|
||||
function ScheduleForm({
|
||||
value,
|
||||
tasks,
|
||||
proxyPool,
|
||||
onSave,
|
||||
onCancel,
|
||||
saving,
|
||||
}: {
|
||||
value: ScheduleInput;
|
||||
tasks: Task[];
|
||||
proxyPool: ProxyPoolEntry[];
|
||||
onSave: (v: ScheduleInput) => void;
|
||||
onCancel?: () => void;
|
||||
saving: boolean;
|
||||
}) {
|
||||
const { t: translate, i18n } = useLiveTranslation();
|
||||
const { t: translate, i18n, isEn } = useLiveTranslation();
|
||||
const { weekdays } = scheduleDisplay(translate, i18n.resolvedLanguage ?? "zh-CN");
|
||||
const [draft, setDraft] = React.useState(value);
|
||||
const [taskQuery, setTaskQuery] = React.useState("");
|
||||
@@ -304,6 +314,27 @@ function ScheduleForm({
|
||||
/>
|
||||
<Label htmlFor="schedule-start-immediately">{translate("schedule.startImmediately")}</Label>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label>{translate("schedule.proxy")}</Label>
|
||||
<ProxyRouteFields
|
||||
value={{
|
||||
mode: normalizeProxyMode(draft.proxy_mode),
|
||||
proxy_pool_id: draft.proxy_pool_id ?? "",
|
||||
proxy_url: draft.proxy_url ?? "",
|
||||
}}
|
||||
onChange={(next) =>
|
||||
set({
|
||||
proxy_mode: next.mode,
|
||||
proxy_pool_id: next.proxy_pool_id,
|
||||
proxy_url: next.proxy_url,
|
||||
})
|
||||
}
|
||||
proxyPool={proxyPool}
|
||||
inheritLabel={translate("schedule.proxyInherit")}
|
||||
idPrefix="schedule-proxy"
|
||||
/>
|
||||
<p className="text-muted-foreground text-xs">{translate("schedule.proxyHelp")}</p>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<Label>{translate("schedule.boundTasks")}</Label>
|
||||
@@ -336,7 +367,7 @@ function ScheduleForm({
|
||||
}
|
||||
|
||||
export default function SchedulesPage() {
|
||||
const { t: translate, liveT, i18n } = useLiveTranslation();
|
||||
const { t: translate, liveT, i18n, isEn } = useLiveTranslation();
|
||||
const {
|
||||
periodLabel,
|
||||
startLabel,
|
||||
@@ -349,6 +380,7 @@ export default function SchedulesPage() {
|
||||
} = scheduleDisplay(translate, i18n.resolvedLanguage ?? "zh-CN");
|
||||
const [items, setItems] = React.useState<TaskSchedule[]>([]);
|
||||
const [tasks, setTasks] = React.useState<Task[]>([]);
|
||||
const [proxyPool, setProxyPool] = React.useState<ProxyPoolEntry[]>([]);
|
||||
const [loading, setLoading] = React.useState(true);
|
||||
const [editing, setEditing] = React.useState<{ id?: number; value: ScheduleInput } | null>(null);
|
||||
const [saving, setSaving] = React.useState(false);
|
||||
@@ -362,9 +394,14 @@ export default function SchedulesPage() {
|
||||
const load = React.useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const [s, t] = await Promise.all([api.schedules(), api.tasks()]);
|
||||
const [s, t, pool] = await Promise.all([
|
||||
api.schedules(),
|
||||
api.tasks(),
|
||||
api.proxyPool().catch(() => ({ entries: [] as ProxyPoolEntry[], active_id: "", switch_log: [] })),
|
||||
]);
|
||||
setItems(s);
|
||||
setTasks(t.tasks);
|
||||
setProxyPool(pool.entries ?? []);
|
||||
} catch (e) {
|
||||
toast.error(localizedError(e, liveT));
|
||||
} finally {
|
||||
@@ -741,6 +778,35 @@ export default function SchedulesPage() {
|
||||
{item.task_ids.length
|
||||
? item.task_ids.map((id) => `#${id}`).join(", ")
|
||||
: translate("schedule.none")}
|
||||
{item.proxy_mode && item.proxy_mode !== "inherit" ? (
|
||||
<div className="mt-1">
|
||||
<Badge
|
||||
variant="secondary"
|
||||
className="max-w-48 truncate font-mono text-[10px]"
|
||||
title={formatProxyRouteSummary(
|
||||
{
|
||||
mode: item.proxy_mode,
|
||||
proxy_pool_id: item.proxy_pool_id,
|
||||
proxy_url: item.proxy_url,
|
||||
effective_proxy: item.effective_proxy,
|
||||
},
|
||||
isEn,
|
||||
proxyPool,
|
||||
)}
|
||||
>
|
||||
{formatProxyRouteSummary(
|
||||
{
|
||||
mode: item.proxy_mode,
|
||||
proxy_pool_id: item.proxy_pool_id,
|
||||
proxy_url: item.proxy_url,
|
||||
effective_proxy: item.effective_proxy,
|
||||
},
|
||||
isEn,
|
||||
proxyPool,
|
||||
)}
|
||||
</Badge>
|
||||
</div>
|
||||
) : null}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Badge variant="outline" className={statusClass(item.status)}>
|
||||
@@ -778,6 +844,9 @@ export default function SchedulesPage() {
|
||||
start_time: item.start_time.slice(0, 5),
|
||||
end_time: item.end_time?.slice(0, 5),
|
||||
start_immediately: item.start_immediately,
|
||||
proxy_mode: item.proxy_mode ?? "inherit",
|
||||
proxy_pool_id: item.proxy_pool_id ?? "",
|
||||
proxy_url: item.proxy_url ?? "",
|
||||
task_ids: item.task_ids,
|
||||
},
|
||||
})
|
||||
@@ -864,6 +933,7 @@ export default function SchedulesPage() {
|
||||
<ScheduleForm
|
||||
value={editing.value}
|
||||
tasks={tasks}
|
||||
proxyPool={proxyPool}
|
||||
saving={saving}
|
||||
onCancel={() => setEditing(null)}
|
||||
onSave={save}
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
Trash2Icon,
|
||||
} from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { ContainerProxyControlSection } from "@/components/proxy-route-selector";
|
||||
|
||||
import {
|
||||
AlertDialog,
|
||||
@@ -255,7 +256,7 @@ export function TaskSandboxControl({ task, onTaskUpdated }: { task: Task; onTask
|
||||
<span className="hidden sm:inline">{stateLabel}</span>
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="end" className="w-80 space-y-3 text-xs">
|
||||
<PopoverContent align="end" className="w-96 space-y-3 text-xs">
|
||||
<PopoverHeader>
|
||||
<PopoverTitle className="flex items-center justify-between text-sm">
|
||||
<span className="flex items-center gap-1.5">
|
||||
@@ -325,6 +326,8 @@ export function TaskSandboxControl({ task, onTaskUpdated }: { task: Task; onTask
|
||||
{info.error ? <p className="text-destructive break-all">{info.error}</p> : null}
|
||||
</div>
|
||||
|
||||
<ContainerProxyControlSection scope="task" ownerId={task.id} open={open} onSaved={onTaskUpdated} />
|
||||
|
||||
<div className="flex flex-wrap items-center gap-1.5">
|
||||
{!running ? (
|
||||
<Button
|
||||
|
||||
@@ -56,6 +56,7 @@ import { ReportTab } from "./_tabs/report-tab";
|
||||
import { RetestsTab } from "./_tabs/retests-tab";
|
||||
import { SessionsTab } from "./_tabs/sessions-tab";
|
||||
import { TaskSandboxControl } from "./_components/task-sandbox-control";
|
||||
import { TaskProxyPopoverControl } from "@/components/proxy-route-selector";
|
||||
|
||||
const TABS = (ui: UITranslate) => [
|
||||
{ value: "sessions", label: ui("screen.a63280253f17d4") },
|
||||
@@ -499,6 +500,7 @@ function TaskDetailInner() {
|
||||
</code>
|
||||
<Separator orientation="vertical" className="mx-1 hidden h-4 sm:block" />
|
||||
<TaskLLMControl task={task} profiles={profiles} onUpdated={load} />
|
||||
<TaskProxyPopoverControl taskId={task.id} proxyRoute={task.proxy_route} onUpdated={load} />
|
||||
<TaskSandboxControl task={task} onTaskUpdated={load} />
|
||||
<StatusBadge
|
||||
stopReason={task.stop_reason}
|
||||
|
||||
@@ -50,6 +50,12 @@ import { toast } from "sonner";
|
||||
|
||||
import { AssetInterceptRulesEditor } from "@/components/asset-intercept-rules-editor";
|
||||
import { DateSelect } from "@/components/date-select";
|
||||
import {
|
||||
EMPTY_PROXY_ROUTE_DRAFT,
|
||||
type ProxyRouteDraft,
|
||||
ProxyRouteFields,
|
||||
TaskProxyPopoverControl,
|
||||
} from "@/components/proxy-route-selector";
|
||||
import { RemarkEditor } from "@/components/remark-editor";
|
||||
import { StatusBadge } from "@/components/status-badge";
|
||||
import { TablePagination } from "@/components/table-pagination";
|
||||
@@ -137,6 +143,7 @@ import type {
|
||||
DeleteTaskOptions,
|
||||
DeleteTaskResult,
|
||||
LLMProfile,
|
||||
ProxyPoolEntry,
|
||||
Task,
|
||||
TaskArchive,
|
||||
TaskArchiveState,
|
||||
@@ -1186,6 +1193,7 @@ export default function TasksPage() {
|
||||
onTogglePinned={toggleTaskPinned}
|
||||
onToggleGlobalAssets={toggleTaskGlobalAssets}
|
||||
onArchive={queueTaskArchive}
|
||||
onProxyUpdated={refreshCategoriesAndTasks}
|
||||
selected={selectedIds.has(task.id)}
|
||||
onSelectedChange={toggleSelected}
|
||||
visibleColumns={visibleColumns}
|
||||
@@ -1430,6 +1438,7 @@ const TaskRow = React.memo(function TaskRow({
|
||||
onTogglePinned,
|
||||
onToggleGlobalAssets,
|
||||
onArchive,
|
||||
onProxyUpdated,
|
||||
selected,
|
||||
onSelectedChange,
|
||||
visibleColumns,
|
||||
@@ -1443,6 +1452,7 @@ const TaskRow = React.memo(function TaskRow({
|
||||
onTogglePinned: (task: Task) => Promise<void>;
|
||||
onToggleGlobalAssets: (task: Task) => Promise<void>;
|
||||
onArchive: (task: Task) => Promise<void>;
|
||||
onProxyUpdated: () => void;
|
||||
selected: boolean;
|
||||
onSelectedChange: (id: string, checked: boolean) => void;
|
||||
visibleColumns: Record<TaskColumnKey, boolean>;
|
||||
@@ -1595,6 +1605,7 @@ const TaskRow = React.memo(function TaskRow({
|
||||
<TableCell className="sticky right-0 z-10 bg-card text-right shadow-[-1px_0_0_0_hsl(var(--border))] group-hover:bg-muted/50">
|
||||
<div className="flex items-center justify-end gap-0.5">
|
||||
<TaskGlobalAssetsAction task={task} onToggle={onToggleGlobalAssets} />
|
||||
<TaskProxyPopoverControl taskId={task.id} proxyRoute={task.proxy_route} iconOnly onUpdated={onProxyUpdated} />
|
||||
<TaskActionTooltip label={translate("taskUI.viewTask")} description={translate("taskUI.viewTaskHelp")}>
|
||||
<Button size="icon" variant="ghost" asChild aria-label={translate("taskUI.viewTask")}>
|
||||
<Link href={`/function/tasks/detail?id=${encodeURIComponent(task.id)}`}>
|
||||
@@ -3592,6 +3603,8 @@ function CreateTaskSheet({
|
||||
const [selectedTemplateID, setSelectedTemplateID] = React.useState<number | null>(null);
|
||||
const [profiles, setProfiles] = React.useState<LLMProfile[]>([]);
|
||||
const [companies, setCompanies] = React.useState<Company[]>([]);
|
||||
const [proxyPool, setProxyPool] = React.useState<ProxyPoolEntry[]>([]);
|
||||
const [proxyRoute, setProxyRoute] = React.useState<ProxyRouteDraft>(EMPTY_PROXY_ROUTE_DRAFT);
|
||||
const [sourceTaskIDs, setSourceTaskIDs] = React.useState<string[]>([]);
|
||||
const [companyIDs, setCompanyIDs] = React.useState<number[]>([]);
|
||||
const [llmProfileIDs, setLLMProfileIDs] = React.useState<string[]>([]);
|
||||
@@ -3635,6 +3648,10 @@ function CreateTaskSheet({
|
||||
.companies()
|
||||
.then(setCompanies)
|
||||
.catch(() => setCompanies([]));
|
||||
api
|
||||
.proxyPool()
|
||||
.then((res) => setProxyPool(res.entries ?? []))
|
||||
.catch(() => setProxyPool([]));
|
||||
}, []);
|
||||
|
||||
// pickFiles uploads the chosen files into this draft's staging dir and appends their
|
||||
@@ -3673,6 +3690,10 @@ function CreateTaskSheet({
|
||||
toast.error(translate("taskUI.invalidWorkers", { max: MAX_TASK_WORKER_COUNT }));
|
||||
return;
|
||||
}
|
||||
if (proxyRoute.mode === "proxy" && !proxyRoute.proxy_pool_id && !proxyRoute.proxy_url.trim()) {
|
||||
toast.error(translate("taskUI.proxyRequired"));
|
||||
return;
|
||||
}
|
||||
setCreating(true);
|
||||
try {
|
||||
const timeoutSec = Math.max(0, Math.floor(Number(timeoutMin) || 0)) * 60;
|
||||
@@ -3701,6 +3722,14 @@ function CreateTaskSheet({
|
||||
interceptRules: interceptRules
|
||||
.map((r) => ({ ...r, pattern: r.pattern.trim() }))
|
||||
.filter((r) => r.pattern !== ""),
|
||||
proxyRoute:
|
||||
proxyRoute.mode !== "inherit"
|
||||
? {
|
||||
mode: proxyRoute.mode,
|
||||
proxy_pool_id: proxyRoute.mode === "proxy" ? proxyRoute.proxy_pool_id || undefined : undefined,
|
||||
proxy_url: proxyRoute.mode === "proxy" && !proxyRoute.proxy_pool_id ? proxyRoute.proxy_url.trim() : undefined,
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
toast.success(translate("taskUI.taskCreated"));
|
||||
setName("");
|
||||
@@ -3722,6 +3751,7 @@ function CreateTaskSheet({
|
||||
setShareGlobalAssets(false);
|
||||
setWorkerCount("");
|
||||
setInterceptRules([]);
|
||||
setProxyRoute(EMPTY_PROXY_ROUTE_DRAFT);
|
||||
setScheduleEnabled(false);
|
||||
setSchedule({
|
||||
name: translate("taskUI.defaultSchedule"),
|
||||
@@ -4040,6 +4070,16 @@ function CreateTaskSheet({
|
||||
/>
|
||||
<FieldDescription>{translate("taskUI.llmChainHelp")}</FieldDescription>
|
||||
</Field>
|
||||
<Field>
|
||||
<FieldLabel htmlFor="task-create-proxy-mode">{translate("taskUI.proxy")}</FieldLabel>
|
||||
<ProxyRouteFields
|
||||
value={proxyRoute}
|
||||
onChange={setProxyRoute}
|
||||
proxyPool={proxyPool}
|
||||
idPrefix="task-create-proxy"
|
||||
/>
|
||||
<FieldDescription>{translate("taskUI.proxyHelp")}</FieldDescription>
|
||||
</Field>
|
||||
|
||||
{/* 高级参数默认折叠:超时/心跳/首个意图,展开才占空间,常用路径保持清爽。 */}
|
||||
<Collapsible>
|
||||
|
||||
@@ -66,7 +66,7 @@ export function ContainerRoutesTab({
|
||||
|
||||
const [newScope, setNewScope] = React.useState<"task" | "session">("task");
|
||||
const [newOwnerID, setNewOwnerID] = React.useState("");
|
||||
const [newMode, setNewMode] = React.useState<"direct" | "proxy">("proxy");
|
||||
const [newMode, setNewMode] = React.useState<"direct" | "pool" | "proxy">("proxy");
|
||||
const [newPoolID, setNewPoolID] = React.useState("__custom__");
|
||||
const [newProxyURL, setNewProxyURL] = React.useState("");
|
||||
const [newNote, setNewNote] = React.useState("");
|
||||
@@ -153,6 +153,8 @@ export function ContainerRoutesTab({
|
||||
await api.deleteProxyRoute(item.scope, item.owner_id);
|
||||
} else if (selection === "__direct__") {
|
||||
await api.putProxyRoute(item.scope, item.owner_id, { mode: "direct", note: item.note });
|
||||
} else if (selection === "__pool__") {
|
||||
await api.putProxyRoute(item.scope, item.owner_id, { mode: "pool", note: item.note });
|
||||
} else if (selection.startsWith("pool:")) {
|
||||
await api.putProxyRoute(item.scope, item.owner_id, {
|
||||
mode: "proxy",
|
||||
@@ -331,12 +333,13 @@ export function ContainerRoutesTab({
|
||||
/>
|
||||
</div>
|
||||
<div className="md:col-span-2">
|
||||
<Select value={newMode} onValueChange={(v) => setNewMode(v as "direct" | "proxy")}>
|
||||
<Select value={newMode} onValueChange={(v) => setNewMode(v as "direct" | "pool" | "proxy")}>
|
||||
<SelectTrigger className="h-8 text-xs">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="proxy">{L("指定代理", "Use proxy")}</SelectItem>
|
||||
<SelectItem value="pool">{L("代理池(自动轮换)", "Proxy pool (auto-rotate)")}</SelectItem>
|
||||
<SelectItem value="direct">{L("强制直连", "Force direct")}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
@@ -416,6 +419,8 @@ export function ContainerRoutesTab({
|
||||
currentVal = "__inherit__";
|
||||
} else if (c.mode === "direct") {
|
||||
currentVal = "__direct__";
|
||||
} else if (c.mode === "pool") {
|
||||
currentVal = "__pool__";
|
||||
} else if (c.proxy_pool_id) {
|
||||
currentVal = `pool:${c.proxy_pool_id}`;
|
||||
}
|
||||
@@ -455,6 +460,7 @@ export function ContainerRoutesTab({
|
||||
<SelectContent>
|
||||
<SelectItem value="__inherit__">{L("继承全局代理", "Inherit global")}</SelectItem>
|
||||
<SelectItem value="__direct__">{L("强制直连", "Force direct")}</SelectItem>
|
||||
<SelectItem value="__pool__">{L("代理池(自动轮换)", "Proxy pool (auto-rotate)")}</SelectItem>
|
||||
{currentVal === "__custom__" ? (
|
||||
<SelectItem value="__custom__">{L("自定义代理 URL", "Custom proxy URL")}</SelectItem>
|
||||
) : null}
|
||||
|
||||
@@ -0,0 +1,402 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
import Link from "next/link";
|
||||
|
||||
import { ExternalLinkIcon, Loader2Icon, RouteIcon } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger } from "@/components/ui/popover";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { useLiveTranslation } from "@/i18n/use-live-translation";
|
||||
import { api } from "@/lib/api";
|
||||
import type { ProxyPoolEntry, TaskProxyRoute } from "@/lib/types";
|
||||
|
||||
export type ProxyRouteMode = "inherit" | "direct" | "pool" | "proxy";
|
||||
|
||||
export interface ProxyRouteDraft {
|
||||
mode: ProxyRouteMode;
|
||||
proxy_pool_id: string;
|
||||
proxy_url: string;
|
||||
}
|
||||
|
||||
export const EMPTY_PROXY_ROUTE_DRAFT: ProxyRouteDraft = {
|
||||
mode: "inherit",
|
||||
proxy_pool_id: "",
|
||||
proxy_url: "",
|
||||
};
|
||||
|
||||
export function normalizeProxyMode(mode?: string): ProxyRouteMode {
|
||||
switch ((mode ?? "").trim().toLowerCase()) {
|
||||
case "direct":
|
||||
return "direct";
|
||||
case "pool":
|
||||
return "pool";
|
||||
case "proxy":
|
||||
return "proxy";
|
||||
default:
|
||||
return "inherit";
|
||||
}
|
||||
}
|
||||
|
||||
export function formatProxyRouteSummary(
|
||||
route: Pick<TaskProxyRoute, "mode" | "proxy_pool_id" | "proxy_url" | "effective_proxy"> | undefined,
|
||||
isEn: boolean,
|
||||
proxyPool?: ProxyPoolEntry[],
|
||||
): string {
|
||||
const L = (zh: string, en: string) => (isEn ? en : zh);
|
||||
const mode = normalizeProxyMode(route?.mode);
|
||||
const eff = (route?.effective_proxy ?? "").trim();
|
||||
const effLabel = !eff || eff === "direct" ? L("直连", "Direct") : eff;
|
||||
if (mode === "inherit") {
|
||||
return `${L("继承全局", "Global")} (${effLabel})`;
|
||||
}
|
||||
if (mode === "direct") {
|
||||
return L("直连", "Direct");
|
||||
}
|
||||
if (mode === "pool") {
|
||||
return eff && eff !== "direct" ? `${L("代理池", "Pool")} · ${eff}` : L("代理池", "Proxy Pool");
|
||||
}
|
||||
if (route?.proxy_pool_id) {
|
||||
const entry = proxyPool?.find((p) => p.id === route.proxy_pool_id);
|
||||
if (entry) {
|
||||
return `${L("节点", "Node")}: ${entry.name || entry.url}`;
|
||||
}
|
||||
}
|
||||
return effLabel;
|
||||
}
|
||||
|
||||
export function ProxyRouteFields({
|
||||
value,
|
||||
onChange,
|
||||
proxyPool,
|
||||
inheritLabel,
|
||||
compact = false,
|
||||
disabled = false,
|
||||
idPrefix = "proxy-route",
|
||||
}: {
|
||||
value: ProxyRouteDraft;
|
||||
onChange: (next: ProxyRouteDraft) => void;
|
||||
proxyPool: ProxyPoolEntry[];
|
||||
inheritLabel?: string;
|
||||
compact?: boolean;
|
||||
disabled?: boolean;
|
||||
idPrefix?: string;
|
||||
}) {
|
||||
const { isEn } = useLiveTranslation();
|
||||
const L = (zh: string, en: string) => (isEn ? en : zh);
|
||||
|
||||
const enabledPoolEntries = React.useMemo(() => proxyPool.filter((p) => p.enabled), [proxyPool]);
|
||||
const poolSelection = value.proxy_pool_id ? value.proxy_pool_id : "__custom__";
|
||||
const triggerClass = compact ? "h-8 text-xs" : "h-9 text-sm";
|
||||
|
||||
return (
|
||||
<div className={compact ? "space-y-2" : "space-y-2.5"}>
|
||||
<Select
|
||||
value={value.mode}
|
||||
disabled={disabled}
|
||||
onValueChange={(nextMode) => {
|
||||
const mode = normalizeProxyMode(nextMode);
|
||||
if (mode === "proxy") {
|
||||
const defaultPoolID = value.proxy_pool_id || (enabledPoolEntries[0]?.id ?? "");
|
||||
onChange({
|
||||
mode,
|
||||
proxy_pool_id: value.proxy_url ? "" : defaultPoolID,
|
||||
proxy_url: value.proxy_url,
|
||||
});
|
||||
} else {
|
||||
onChange({ mode, proxy_pool_id: "", proxy_url: "" });
|
||||
}
|
||||
}}
|
||||
>
|
||||
<SelectTrigger id={`${idPrefix}-mode`} className={triggerClass}>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="inherit">
|
||||
{inheritLabel ?? L("继承全局代理设置", "Inherit global proxy")}
|
||||
</SelectItem>
|
||||
<SelectItem value="direct">{L("强制直连(绕过全局代理)", "Force direct (bypass global)")}</SelectItem>
|
||||
<SelectItem value="pool">
|
||||
{L(
|
||||
`代理池(自动轮换 · ${enabledPoolEntries.length} 个可用节点)`,
|
||||
`Proxy pool (auto-rotate · ${enabledPoolEntries.length} enabled)`,
|
||||
)}
|
||||
</SelectItem>
|
||||
<SelectItem value="proxy">{L("指定代理(代理池节点 / 自定义 URL)", "Specific proxy (pool node / custom URL)")}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
{value.mode === "pool" && enabledPoolEntries.length === 0 ? (
|
||||
<p className="text-amber-600 text-[11px] dark:text-amber-400">
|
||||
{L(
|
||||
"代理池当前无可用节点,请先前往「代理与出口」添加并启用节点。",
|
||||
"No enabled proxy pool entries yet. Add and enable nodes in Proxy & Egress first.",
|
||||
)}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
{value.mode === "proxy" ? (
|
||||
<div className={compact ? "space-y-1.5" : "space-y-2"}>
|
||||
<Select
|
||||
value={poolSelection}
|
||||
disabled={disabled}
|
||||
onValueChange={(sel) => {
|
||||
if (sel === "__custom__") {
|
||||
onChange({ mode: "proxy", proxy_pool_id: "", proxy_url: value.proxy_url });
|
||||
} else {
|
||||
onChange({ mode: "proxy", proxy_pool_id: sel, proxy_url: "" });
|
||||
}
|
||||
}}
|
||||
>
|
||||
<SelectTrigger id={`${idPrefix}-node`} className={triggerClass}>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="__custom__">{L("手动输入代理 URL", "Custom proxy URL")}</SelectItem>
|
||||
{proxyPool.map((p) => (
|
||||
<SelectItem key={p.id} value={p.id}>
|
||||
<span className="truncate">
|
||||
{p.name ? `${p.name} (${p.url})` : p.url}
|
||||
{!p.enabled ? L(" [已停用]", " [disabled]") : ""}
|
||||
{p.egress_ip ? ` · ${p.egress_ip}` : ""}
|
||||
</span>
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
{poolSelection === "__custom__" ? (
|
||||
<Input
|
||||
id={`${idPrefix}-url`}
|
||||
value={value.proxy_url}
|
||||
disabled={disabled}
|
||||
onChange={(e) => onChange({ mode: "proxy", proxy_pool_id: "", proxy_url: e.target.value })}
|
||||
placeholder="socks5://127.0.0.1:1080 或 http://user:pass@host:8080"
|
||||
className={compact ? "h-8 font-mono text-xs" : "h-9 font-mono text-xs"}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function ContainerProxyControlSection({
|
||||
scope,
|
||||
ownerId,
|
||||
open,
|
||||
onSaved,
|
||||
}: {
|
||||
scope: "task" | "session";
|
||||
ownerId: string;
|
||||
open: boolean;
|
||||
onSaved?: () => void;
|
||||
}) {
|
||||
const { isEn } = useLiveTranslation();
|
||||
const L = (zh: string, en: string) => (isEn ? en : zh);
|
||||
|
||||
const [loading, setLoading] = React.useState(false);
|
||||
const [saving, setSaving] = React.useState(false);
|
||||
const [proxyPool, setProxyPool] = React.useState<ProxyPoolEntry[]>([]);
|
||||
const [draft, setDraft] = React.useState<ProxyRouteDraft>(EMPTY_PROXY_ROUTE_DRAFT);
|
||||
const [savedDraft, setSavedDraft] = React.useState<ProxyRouteDraft>(EMPTY_PROXY_ROUTE_DRAFT);
|
||||
const [effectiveProxy, setEffectiveProxy] = React.useState<string>("");
|
||||
const [globalProxy, setGlobalProxy] = React.useState<string>("");
|
||||
|
||||
const load = React.useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const [routeRes, poolRes] = await Promise.all([
|
||||
api.proxyRoute(scope, ownerId),
|
||||
api.proxyPool().catch(() => ({ entries: [] as ProxyPoolEntry[], active_id: "", switch_log: [] })),
|
||||
]);
|
||||
const next: ProxyRouteDraft = {
|
||||
mode: normalizeProxyMode(routeRes.mode),
|
||||
proxy_pool_id: routeRes.proxy_pool_id ?? "",
|
||||
proxy_url: routeRes.proxy_url ?? "",
|
||||
};
|
||||
setProxyPool(poolRes.entries ?? []);
|
||||
setDraft(next);
|
||||
setSavedDraft(next);
|
||||
setEffectiveProxy(routeRes.effective_proxy || "direct");
|
||||
setGlobalProxy(routeRes.global_proxy || "direct");
|
||||
} catch {
|
||||
// Non-fatal; user can retry or inspect on /system/proxy.
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [scope, ownerId]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!open) return;
|
||||
void load();
|
||||
}, [open, load]);
|
||||
|
||||
const dirty =
|
||||
draft.mode !== savedDraft.mode ||
|
||||
draft.proxy_pool_id !== savedDraft.proxy_pool_id ||
|
||||
draft.proxy_url.trim() !== savedDraft.proxy_url.trim();
|
||||
|
||||
const handleSave = async () => {
|
||||
if (draft.mode === "proxy" && !draft.proxy_pool_id && !draft.proxy_url.trim()) {
|
||||
toast.error(L("请选择代理池节点或输入自定义代理 URL", "Select a pool node or enter a custom proxy URL"));
|
||||
return;
|
||||
}
|
||||
setSaving(true);
|
||||
try {
|
||||
if (draft.mode === "inherit") {
|
||||
await api.deleteProxyRoute(scope, ownerId);
|
||||
} else {
|
||||
await api.putProxyRoute(scope, ownerId, {
|
||||
mode: draft.mode,
|
||||
proxy_pool_id: draft.mode === "proxy" ? draft.proxy_pool_id || undefined : undefined,
|
||||
proxy_url: draft.mode === "proxy" && !draft.proxy_pool_id ? draft.proxy_url.trim() : undefined,
|
||||
});
|
||||
}
|
||||
await load();
|
||||
toast.success(L("容器代理路由已更新并实时生效", "Container proxy route updated"));
|
||||
onSaved?.();
|
||||
} catch (e) {
|
||||
toast.error(e instanceof Error ? e.message : String(e));
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
const effDisplay =
|
||||
!effectiveProxy || effectiveProxy === "direct" ? L("直连", "Direct") : effectiveProxy;
|
||||
const globalDisplay =
|
||||
!globalProxy || globalProxy === "direct" ? L("直连", "Direct") : globalProxy;
|
||||
|
||||
return (
|
||||
<div className="space-y-2 rounded-md border bg-muted/20 p-2.5">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<Label className="flex items-center gap-1.5 text-xs font-medium">
|
||||
<RouteIcon className="size-3.5" />
|
||||
{L("出口代理 / 代理池", "Egress Proxy / Pool")}
|
||||
</Label>
|
||||
<Link
|
||||
href="/system/proxy"
|
||||
className="inline-flex items-center gap-0.5 text-[11px] text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
{L("代理管理", "Manage")}
|
||||
<ExternalLinkIcon className="size-2.5" />
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between gap-2 text-[11px] text-muted-foreground">
|
||||
<span>{L("当前生效", "Effective")}</span>
|
||||
<span className="max-w-[200px] truncate font-mono text-foreground" title={effDisplay}>
|
||||
{loading ? L("读取中…", "Loading…") : effDisplay}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<ProxyRouteFields
|
||||
value={draft}
|
||||
onChange={setDraft}
|
||||
proxyPool={proxyPool}
|
||||
compact
|
||||
disabled={loading || saving}
|
||||
inheritLabel={L(`继承全局 (${globalDisplay})`, `Inherit global (${globalDisplay})`)}
|
||||
idPrefix={`container-proxy-${scope}-${ownerId}`}
|
||||
/>
|
||||
|
||||
<div className="flex justify-end">
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
className="h-7 px-2.5 text-xs"
|
||||
disabled={loading || saving || !dirty}
|
||||
onClick={() => void handleSave()}
|
||||
>
|
||||
{saving ? <Loader2Icon className="mr-1 size-3 animate-spin" /> : null}
|
||||
{saving ? L("应用中…", "Applying…") : L("应用代理", "Apply Proxy")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function TaskProxyPopoverControl({
|
||||
taskId,
|
||||
proxyRoute,
|
||||
iconOnly = false,
|
||||
onUpdated,
|
||||
}: {
|
||||
taskId: string;
|
||||
proxyRoute?: TaskProxyRoute;
|
||||
iconOnly?: boolean;
|
||||
onUpdated?: () => void;
|
||||
}) {
|
||||
const { isEn } = useLiveTranslation();
|
||||
const L = (zh: string, en: string) => (isEn ? en : zh);
|
||||
const [open, setOpen] = React.useState(false);
|
||||
|
||||
const mode = normalizeProxyMode(proxyRoute?.mode);
|
||||
const isCustom = mode !== "inherit";
|
||||
const badgeText =
|
||||
mode === "direct"
|
||||
? L("直连", "Direct")
|
||||
: mode === "pool"
|
||||
? L("代理池", "Pool")
|
||||
: mode === "proxy"
|
||||
? L("指定代理", "Proxy")
|
||||
: L("代理: 全局", "Proxy: Global");
|
||||
|
||||
return (
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
{iconOnly ? (
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className={isCustom ? "text-primary" : "text-muted-foreground"}
|
||||
title={`${L("出口代理", "Egress Proxy")}: ${formatProxyRouteSummary(proxyRoute, isEn)}`}
|
||||
aria-label={L("设置任务代理", "Configure task proxy")}
|
||||
>
|
||||
<RouteIcon className="size-4" />
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
size="sm"
|
||||
variant={isCustom ? "secondary" : "outline"}
|
||||
className="h-7 gap-1.5 px-2 text-xs"
|
||||
title={formatProxyRouteSummary(proxyRoute, isEn)}
|
||||
>
|
||||
<RouteIcon className="size-3.5" />
|
||||
<span className="hidden sm:inline">{badgeText}</span>
|
||||
{isCustom ? <Badge variant="outline" className="h-4 px-1 font-mono text-[10px]">{mode}</Badge> : null}
|
||||
</Button>
|
||||
)}
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="end" className="w-96 space-y-3 text-xs">
|
||||
<PopoverHeader>
|
||||
<PopoverTitle className="flex items-center gap-1.5 text-sm">
|
||||
<RouteIcon className="size-4" />
|
||||
{L(`任务 #${taskId} 出口代理`, `Task #${taskId} Egress Proxy`)}
|
||||
</PopoverTitle>
|
||||
<PopoverDescription className="text-xs">
|
||||
{L(
|
||||
"为该任务容器单独指定出口代理或代理池,保存后立即对透明网关与抓包代理生效。",
|
||||
"Override egress proxy or proxy pool for this task container. Applies immediately to gateway and capture proxy.",
|
||||
)}
|
||||
</PopoverDescription>
|
||||
</PopoverHeader>
|
||||
<ContainerProxyControlSection
|
||||
scope="task"
|
||||
ownerId={taskId}
|
||||
open={open}
|
||||
onSaved={() => {
|
||||
onUpdated?.();
|
||||
}}
|
||||
/>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
@@ -117,6 +117,7 @@ export const messages = {
|
||||
"auth.reenterPassword": ["再次输入密码", "Enter your password again"],
|
||||
"auth.saving": ["保存中...", "Saving…"],
|
||||
"auth.setupAndLogin": ["设置密码并登录", "Set password and sign in"],
|
||||
"mention.task": ["任务", "Task"],
|
||||
"mention.finding": ["漏洞", "Finding"],
|
||||
"mention.asset": ["资产", "Asset"],
|
||||
"mention.company": ["企业", "Company"],
|
||||
|
||||
@@ -202,4 +202,13 @@ export const scheduleMessages = {
|
||||
"演示模式不会执行计划任务,请在实际部署中运行",
|
||||
"Demo mode does not execute schedules. Run this schedule in a deployed instance.",
|
||||
],
|
||||
"schedule.proxy": ["出口代理 / 代理池", "Egress Proxy / Proxy Pool"],
|
||||
"schedule.proxyInherit": [
|
||||
"保持任务自身 / 全局代理设置(不覆盖)",
|
||||
"Keep task / global proxy (do not override)",
|
||||
],
|
||||
"schedule.proxyHelp": [
|
||||
"设为直连、代理池或指定代理后,保存与计划触发时会自动应用到所有关联任务的容器。",
|
||||
"When set to direct, proxy pool, or specific proxy, bound tasks automatically apply this route on save and when the schedule runs.",
|
||||
],
|
||||
} as const;
|
||||
@@ -934,4 +934,13 @@ export const taskMessages = {
|
||||
"taskUI.phase.delete_metadata": ["删除归档元数据", "Deleting archive metadata"],
|
||||
"taskUI.phase.ready": ["可还原", "Ready to restore"],
|
||||
"taskUI.phase.failed": ["失败", "Failed"],
|
||||
"taskUI.proxy": ["出口代理 / 代理池", "Egress Proxy / Proxy Pool"],
|
||||
"taskUI.proxyHelp": [
|
||||
"为本任务沙箱容器单独设置出口代理(继承全局、强制直连、代理池自动轮换、指定节点或自定义 URL)。",
|
||||
"Override the sandbox container egress proxy for this task (direct, auto-rotating proxy pool, specific pool node, or custom URL).",
|
||||
],
|
||||
"taskUI.proxyRequired": [
|
||||
"请选择代理池节点或输入自定义代理 URL",
|
||||
"Select a proxy pool node or enter a custom proxy URL",
|
||||
],
|
||||
} as const;
|
||||
@@ -25,6 +25,7 @@ import type {
|
||||
CompanyScopeMutation,
|
||||
CompanyScopeRule,
|
||||
ContainerProxyRoute,
|
||||
ContainerRouteStatusItem,
|
||||
Conversation,
|
||||
ConvTokenSummary,
|
||||
CoverageAssetRefs,
|
||||
@@ -416,6 +417,9 @@ export type ScheduleInput = {
|
||||
start_time: string;
|
||||
end_time?: string;
|
||||
start_immediately?: boolean;
|
||||
proxy_mode?: "inherit" | "direct" | "pool" | "proxy" | string;
|
||||
proxy_pool_id?: string;
|
||||
proxy_url?: string;
|
||||
task_ids: number[];
|
||||
};
|
||||
|
||||
@@ -431,6 +435,9 @@ function schedulePayload(input: ScheduleInput) {
|
||||
start_time: input.start_time,
|
||||
end_time: input.end_time ?? "",
|
||||
start_immediately: input.start_immediately ?? false,
|
||||
proxy_mode: input.proxy_mode ?? "inherit",
|
||||
proxy_pool_id: input.proxy_pool_id ?? "",
|
||||
proxy_url: input.proxy_url ?? "",
|
||||
task_ids: input.task_ids,
|
||||
};
|
||||
}
|
||||
@@ -499,6 +506,7 @@ export const api = {
|
||||
workerCount?: number;
|
||||
interceptRules?: AssetInterceptRuleInput[];
|
||||
schedule?: ScheduleInput;
|
||||
proxyRoute?: { mode: "inherit" | "direct" | "pool" | "proxy"; proxy_pool_id?: string; proxy_url?: string; note?: string };
|
||||
}) =>
|
||||
post<Task>("/tasks", {
|
||||
name: input.name ?? "",
|
||||
@@ -520,6 +528,7 @@ export const api = {
|
||||
worker_count: input.workerCount ?? 0, // 0 = 用全局默认 workers
|
||||
intercept_rules: input.interceptRules ?? [], // 任务级资产拦截规则
|
||||
schedule: input.schedule ? schedulePayload(input.schedule) : undefined,
|
||||
proxy_route: input.proxyRoute && input.proxyRoute.mode !== "inherit" ? input.proxyRoute : undefined,
|
||||
}),
|
||||
schedules: () => get<{ schedules: TaskSchedule[] }>("/schedules").then((r) => arr(r.schedules)),
|
||||
renameSchedule: (id: number, name: string) => patch<TaskSchedule>(`/schedules/${id}/metadata`, { name }),
|
||||
@@ -1940,6 +1949,10 @@ export const api = {
|
||||
|
||||
// ---- Per-Container Proxy Routes & Transparent Gateway (#218 Phase 3/4) ----
|
||||
proxyRoutes: () => get<ProxyRoutesState>("/proxy/routes"),
|
||||
proxyRoute: (scope: string, ownerId: string) =>
|
||||
get<ContainerRouteStatusItem & { global_proxy?: string }>(
|
||||
`/proxy/routes/${encodeURIComponent(scope)}/${encodeURIComponent(ownerId)}`,
|
||||
),
|
||||
putProxyRoute: (
|
||||
scope: string,
|
||||
ownerId: string,
|
||||
|
||||
@@ -10,7 +10,11 @@ test("mention trigger supports Chinese and cursor placement without hijacking em
|
||||
});
|
||||
|
||||
test("categories, Chinese aliases, IP and keyword search", () => {
|
||||
assert.equal(mentionSearch("").categories.length, 9);
|
||||
assert.equal(mentionSearch("").categories.length, 10);
|
||||
assert.equal(mentionSearch("任").categories[0].kind, "task");
|
||||
assert.equal(mentionSearch("任务").kind, "task");
|
||||
assert.equal(mentionSearch("任务 5").query, "5");
|
||||
assert.equal(mentionSearch("task 5").kind, "task");
|
||||
assert.equal(mentionSearch("漏").categories[0].kind, "finding");
|
||||
assert.equal(mentionSearch("漏洞").kind, "finding");
|
||||
assert.equal(mentionSearch("漏洞SQL注入").query, "SQL注入");
|
||||
@@ -31,8 +35,8 @@ test("tokens roundtrip labels and removing one reference preserves its neighbors
|
||||
});
|
||||
|
||||
test("all mention kinds use stable tokens and recognize their legacy Chinese form", () => {
|
||||
const kinds = ["finding", "asset", "company", "endpoint", "ip", "app", "root_domain", "subdomain", "service"];
|
||||
const legacy = ["漏洞", "资产", "企业", "接口", "IP", "应用", "域名", "子域名", "服务"];
|
||||
const kinds = ["task", "finding", "asset", "company", "endpoint", "ip", "app", "root_domain", "subdomain", "service"];
|
||||
const legacy = ["任务", "漏洞", "资产", "企业", "接口", "IP", "应用", "域名", "子域名", "服务"];
|
||||
for (const [i, kind] of kinds.entries()) {
|
||||
const token = mentionToken({kind, id:i + 1, label:"Keep 用户名称"});
|
||||
assert.ok(token.startsWith("@[" + kind + "#"));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export const mentionKinds = [
|
||||
{ kind: "task", label: "任务", alias: "task", english: "Task" },
|
||||
{ kind: "finding", label: "漏洞", alias: "finding", english: "Finding" },
|
||||
{ kind: "asset", label: "资产", alias: "asset", english: "Asset" },
|
||||
{ kind: "company", label: "企业", alias: "company", english: "Company" },
|
||||
@@ -63,7 +64,7 @@ export function selectedMentions(value: string, translate?: (key: string) => str
|
||||
// Keep recognizing Chinese tokens in saved drafts and conversation history.
|
||||
return [
|
||||
...value.matchAll(
|
||||
/@\[(finding|asset|company|endpoint|ip|app|root_domain|subdomain|service|漏洞|资产|企业|接口|IP|应用|域名|子域名|服务)#([0-9]+)(?: ([^\]\r\n]*))?\]/g,
|
||||
/@\[(task|finding|asset|company|endpoint|ip|app|root_domain|subdomain|service|任务|漏洞|资产|企业|接口|IP|应用|域名|子域名|服务)#([0-9]+)(?: ([^\]\r\n]*))?\]/g,
|
||||
),
|
||||
].map((match) => {
|
||||
const entry = mentionKinds.find((item) => item.kind === match[1] || item.label === match[1]);
|
||||
|
||||
+13
-1
@@ -72,6 +72,14 @@ export interface Task {
|
||||
company_ids?: number[]; // associated company scopes; current company assets join the task at creation
|
||||
share_global_assets?: boolean; // opt-in global asset visibility; default false
|
||||
coverage_enabled?: boolean; // 资产覆盖度功能开关(创建时定,默认开);false=不计算/不展示覆盖度
|
||||
proxy_route?: TaskProxyRoute;
|
||||
}
|
||||
|
||||
export interface TaskProxyRoute {
|
||||
mode: "inherit" | "direct" | "pool" | "proxy" | string;
|
||||
proxy_pool_id?: string;
|
||||
proxy_url?: string;
|
||||
effective_proxy?: string;
|
||||
}
|
||||
|
||||
export interface TaskCategory {
|
||||
@@ -771,6 +779,10 @@ export interface TaskSchedule {
|
||||
start_time: string;
|
||||
end_time?: string;
|
||||
start_immediately: boolean;
|
||||
proxy_mode?: "inherit" | "direct" | "pool" | "proxy" | string;
|
||||
proxy_pool_id?: string;
|
||||
proxy_url?: string;
|
||||
effective_proxy?: string;
|
||||
status: "waiting" | "running" | "outside" | "completed" | "error" | "paused";
|
||||
last_window_key?: string;
|
||||
last_transition_at?: string;
|
||||
@@ -2182,7 +2194,7 @@ export interface TrafficDNSResp {
|
||||
export interface ContainerProxyRoute {
|
||||
scope: "task" | "session" | string;
|
||||
owner_id: string;
|
||||
mode: "inherit" | "direct" | "proxy" | string;
|
||||
mode: "inherit" | "direct" | "pool" | "proxy" | string;
|
||||
proxy_pool_id?: string;
|
||||
proxy_url?: string;
|
||||
note?: string;
|
||||
|
||||
Reference in new issue
Block a user