Merge remote-tracking branch 'origin/main' into pr398-wire

# Conflicts:
#	web/package.json
This commit is contained in:
BaaRai
2026-11-20 22:12:54 +01:00
85 changed files with 11333 additions and 415 deletions
+1 -1
View File
@@ -16,7 +16,7 @@
"test:polling": "node --test scripts/polling.test.mjs",
"test:replay": "node --test scripts/replay.test.mjs",
"test:upload": "node --test scripts/upload.test.mjs",
"test:i18n": "node scripts/check-i18n.mjs",
"test:i18n": "node scripts/check-i18n.mjs && node --test scripts/i18n.test.mjs",
"test:bash": "node --test src/lib/bash-exit-status.test.mjs"
},
"lint-staged": {
+27 -30
View File
@@ -2,11 +2,14 @@ import { readFileSync, readdirSync, statSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
// Every literal t("...") / t('...') key must exist in the locale dictionary
// with the same {placeholders}. Dynamic keys (variables, template literals
// with ${}) are skipped: there is nothing to compare them against.
// English source text is the key. Check every shipped dictionary, including
// dynamic entries, while retaining the existing literal-call coverage check.
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
const dict = JSON.parse(readFileSync(join(root, "src/i18n/locales/tr.json"), "utf8"));
const localeDir = join(root, "src/i18n/locales");
const dictionaries = readdirSync(localeDir)
.filter((name) => name.endsWith(".json"))
.sort()
.map((name) => [name, JSON.parse(readFileSync(join(localeDir, name), "utf8"))]);
const files = [];
function walk(dir) {
@@ -19,7 +22,7 @@ function walk(dir) {
}
walk(join(root, "src"));
const calls = new Map(); // key -> first file that uses it
const calls = new Map();
const literalCall = /(?:^|[^\w$.])t\(\s*(?:"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)')/gm;
for (const file of files) {
const src = readFileSync(file, "utf8");
@@ -31,34 +34,28 @@ for (const file of files) {
}
function placeholders(s) {
return [...s.matchAll(/\{(\w+)\}/g)]
.map((m) => m[1])
.sort()
.join(",");
return [...s.matchAll(/\{(\w+)\}/g)].map((m) => m[1]).sort().join(",");
}
const missing = [];
const mismatch = [];
for (const [key, file] of calls) {
if (!Object.prototype.hasOwnProperty.call(dict, key)) {
missing.push(`${file}: ${JSON.stringify(key)}`);
continue;
}
if (placeholders(dict[key]) !== placeholders(key)) {
mismatch.push(`${JSON.stringify(key)}: source {${placeholders(key)}} dict {${placeholders(dict[key])}}`);
const allKeys = new Set(dictionaries.flatMap(([, dict]) => Object.keys(dict)));
const errors = [];
if (!dictionaries.length) errors.push("No locale dictionaries found");
for (const [name, dict] of dictionaries) {
for (const key of new Set([...allKeys, ...calls.keys()])) {
if (!Object.prototype.hasOwnProperty.call(dict, key)) {
errors.push(`${name}: missing ${JSON.stringify(key)} (${calls.get(key) ?? "dictionary parity"})`);
continue;
}
const value = dict[key];
if (typeof value !== "string" || !value.trim()) {
errors.push(`${name}: empty or non-string value for ${JSON.stringify(key)}`);
} else if (placeholders(value) !== placeholders(key)) {
errors.push(`${name}: placeholder mismatch for ${JSON.stringify(key)}`);
}
}
console.log(`i18n: ${calls.size} literal keys checked against ${Object.keys(dict).length} ${name} entries`);
}
if (missing.length || mismatch.length) {
if (missing.length) {
console.error(`Missing tr.json entries (${missing.length}):\n${missing.join("\n")}`);
}
if (mismatch.length) {
console.error(`Placeholder mismatches (${mismatch.length}):\n${mismatch.join("\n")}`);
}
if (errors.length) {
console.error(errors.join("\n"));
process.exit(1);
}
console.log(
`i18n: ${calls.size} literal keys checked against ${Object.keys(dict).length} tr.json entries`,
);
+93
View File
@@ -0,0 +1,93 @@
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { createRequire } from "node:module";
import test from "node:test";
import vm from "node:vm";
import ts from "typescript";
const sourceURL = new URL("../src/i18n/index.ts", import.meta.url);
const require = createRequire(sourceURL);
const code = ts.transpileModule(readFileSync(sourceURL, "utf8"), {
compilerOptions: { module: ts.ModuleKind.CommonJS, esModuleInterop: true },
}).outputText;
function load({ saved = null, languages = ["en-US"], language = "en-US", blocked = false, server = false } = {}) {
const writes = [];
let reloads = 0;
const context = { exports: {}, require };
if (!server) {
context.document = { documentElement: { lang: "en" } };
context.window = {
localStorage: {
getItem(key) {
assert.equal(key, "artex.locale");
if (blocked) throw new Error("Storage blocked");
return saved;
},
setItem(key, value) {
if (blocked) throw new Error("Storage blocked");
writes.push([key, value]);
},
},
navigator: { languages, language },
location: { reload: () => { reloads++; } },
};
}
vm.runInNewContext(code, context, { filename: "i18n/index.js" });
return { api: context.exports, document: context.document, writes, reloads: () => reloads };
}
test("static export remains English and unknown keys fall back safely", () => {
const { api } = load({ server: true });
assert.equal(api.locale, "en");
assert.equal(api.intlLocale, "en-US");
assert.equal(api.t("Unknown {value}", { value: 3 }), "Unknown 3");
});
test("saved Chinese preference wins and sets the document and Intl locale", () => {
const { api, document } = load({ saved: "zh-CN", languages: ["tr-TR"] });
assert.equal(api.locale, "zh-CN");
assert.equal(api.intlLocale, "zh-CN");
assert.equal(document.documentElement.lang, "zh-CN");
assert.equal(api.t("Language"), "语言");
assert.equal(api.t("{count} tasks", { count: 3 }), "3 个任务");
assert.equal(api.t("Task #{id}"), "任务 #{id}");
assert.equal(api.t("constructor"), "constructor");
assert.equal(api.t("toString"), "toString");
assert.equal(api.t("__proto__"), "__proto__");
assert.equal(api.t("{count} tasks", Object.create({ count: 3 })), "{count} 个任务");
});
test("Chinese browser tags, fallback languages, invalid preferences and blocked storage", () => {
for (const tag of ["zh", "zh-CN", "zh-SG", "zh-Hans-CN", "ZH-cn"]) {
assert.equal(load({ languages: [tag] }).api.locale, "zh-CN");
}
assert.equal(load({ saved: "invalid", languages: ["fr-FR", "zh-CN"] }).api.locale, "zh-CN");
assert.equal(load({ blocked: true, languages: ["zh-CN"] }).api.locale, "zh-CN");
assert.equal(load({ languages: null, language: "zh-CN" }).api.locale, "zh-CN");
assert.equal(load({ languages: [], language: "zh-CN" }).api.locale, "en");
assert.equal(load({ languages: ["fr-FR"] }).api.locale, "en");
});
test("existing English and Turkish preferences and formatting are preserved", () => {
const english = load({ saved: "en", languages: ["zh-CN"] }).api;
const turkish = load({ saved: "tr", languages: ["zh-CN"] }).api;
assert.equal(english.locale, "en");
assert.equal(english.t("Language"), "Language");
assert.equal(turkish.locale, "tr");
assert.equal(turkish.intlLocale, "tr-TR");
assert.equal(turkish.t("Language"), "Dil");
assert.equal(load({ languages: ["tr-TR"] }).api.locale, "tr");
});
test("switching persists the existing storage key and reloads once", () => {
const state = load();
state.api.setLocale("en");
assert.equal(state.reloads(), 0);
state.api.setLocale("zh-CN");
assert.deepEqual(state.writes, [["artex.locale", "zh-CN"]]);
assert.equal(state.reloads(), 1);
const blocked = load({ blocked: true });
assert.doesNotThrow(() => blocked.api.setLocale("zh-CN"));
assert.equal(blocked.reloads(), 1);
});
+199 -5
View File
@@ -7,6 +7,7 @@ import {
ArrowUpNarrowWideIcon,
ChevronLeftIcon,
ChevronRightIcon,
DownloadIcon,
EraserIcon,
FilterXIcon,
ListChecksIcon,
@@ -14,11 +15,14 @@ import {
RadioTowerIcon,
SearchIcon,
Trash2Icon,
UploadIcon,
XIcon,
} from "lucide-react";
import { toast } from "sonner";
import { HttpCodeBlock } from "@/components/http-code-block";
import { LinkTrafficDialog } from "@/components/link-traffic-dialog";
import { Alert, AlertDescription } from "@/components/ui/alert";
import {
AlertDialog,
AlertDialogAction,
@@ -44,7 +48,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip
import { api } from "@/lib/api";
import { setVisibleInterval } from "@/lib/polling";
import { useStoredSortPreference } from "@/lib/sort-preference";
import type { TrafficDetail, TrafficExchange, TrafficHost, TrafficResp } from "@/lib/types";
import type { TrafficDetail, TrafficExchange, TrafficHARImportResult, TrafficHost, TrafficResp } from "@/lib/types";
import { cn } from "@/lib/utils";
import { intlLocale, t } from "@/i18n";
@@ -135,6 +139,7 @@ export default function TrafficPage() {
const [path, setPath] = React.useState("");
const [pathQ, setPathQ] = React.useState("");
const [statusFilter, setStatusFilter] = React.useState("all");
const [rewrittenFilter, setRewrittenFilter] = React.useState("all");
const [respMin, setRespMin] = React.useState("");
const [respMinQ, setRespMinQ] = React.useState("");
const [respMax, setRespMax] = React.useState("");
@@ -158,6 +163,13 @@ export default function TrafficPage() {
const [deleting, setDeleting] = React.useState(false);
const [reloadTick, setReloadTick] = React.useState(0); // manual refetch trigger
// HAR 1.2 import/export state
const harInputRef = React.useRef<HTMLInputElement | null>(null);
const [harImporting, setHarImporting] = React.useState(false);
const [harExporting, setHarExporting] = React.useState(false);
const [harSummary, setHarSummary] = React.useState<TrafficHARImportResult | null>(null);
const [harError, setHarError] = React.useState<string | null>(null);
// Debounce both filters so we don't refetch on every keystroke.
React.useEffect(() => {
const t = setTimeout(() => setHostQ(host.trim()), 300);
@@ -184,13 +196,15 @@ export default function TrafficPage() {
return () => clearTimeout(t);
}, [respMax]);
const hasAdvancedFilter = Boolean(bodyQ || pathQ || respMinQ || respMaxQ) || statusFilter !== "all";
const hasAdvancedFilter =
Boolean(bodyQ || pathQ || respMinQ || respMaxQ) || statusFilter !== "all" || rewrittenFilter !== "all";
const resetAdvancedFilters = () => {
setBody("");
setBodyQ("");
setPath("");
setPathQ("");
setStatusFilter("all");
setRewrittenFilter("all");
setRespMin("");
setRespMinQ("");
setRespMax("");
@@ -201,7 +215,7 @@ export default function TrafficPage() {
// biome-ignore lint/correctness/useExhaustiveDependencies: these values intentionally trigger a page reset.
React.useEffect(() => {
setPage(0);
}, [hostQ, queryQ, method, size, bodyQ, pathQ, statusFilter, respMinQ, respMaxQ, sort]);
}, [hostQ, queryQ, method, size, bodyQ, pathQ, statusFilter, rewrittenFilter, respMinQ, respMaxQ, sort]);
// Load the current page. Auto-refresh only on page 0 (newest) so paging back
// through history isn't yanked out from under the user.
@@ -214,6 +228,7 @@ export default function TrafficPage() {
body: bodyQ,
path: pathQ,
status: statusFilter,
rewritten: rewrittenFilter,
respMin: respMinQ,
respMax: respMaxQ,
sort: sort.field,
@@ -243,7 +258,21 @@ export default function TrafficPage() {
alive = false;
stopPolling();
};
}, [page, size, hostQ, method, queryQ, bodyQ, pathQ, statusFilter, respMinQ, respMaxQ, sort, reloadTick]);
}, [
page,
size,
hostQ,
method,
queryQ,
bodyQ,
pathQ,
statusFilter,
rewrittenFilter,
respMinQ,
respMaxQ,
sort,
reloadTick,
]);
// Delete traffic for the current host filter (substring) or the checked
// hosts (exact batch), then refetch.
@@ -349,6 +378,76 @@ export default function TrafficPage() {
: { field, direction: "desc" },
);
const handleHarFileChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
const file = event.target.files?.[0];
event.target.value = "";
if (!file) return;
setHarError(null);
setHarSummary(null);
if (file.size > 32 * 1024 * 1024) {
const msg = t("HAR file exceeds the 32 MiB limit");
setHarError(msg);
toast.error(msg);
return;
}
setHarImporting(true);
try {
const raw = await file.text();
const res = await api.trafficImportHAR(raw);
setHarSummary(res);
const summary = t("HAR import complete: {imported} imported, {skipped} skipped, {failed} failed", {
imported: res.imported,
skipped: res.skipped,
failed: res.failed,
});
if (res.failed > 0 || res.truncated) {
toast.warning(summary);
} else {
toast.success(summary);
}
setPage(0);
setReloadTick((n) => n + 1);
} catch (e) {
const msg = t("HAR import failed: {error}", { error: (e as Error).message });
setHarError(msg);
toast.error(msg);
} finally {
setHarImporting(false);
}
};
const handleHarExport = async () => {
setHarExporting(true);
try {
const meta = await api.trafficExportHAR({
host: hostQ,
method,
q: queryQ,
body: bodyQ,
path: pathQ,
status: statusFilter,
rewritten: rewrittenFilter,
respMin: respMinQ,
respMax: respMaxQ,
});
if (meta.truncated) {
toast.warning(
t("Exported {exported} of {matched} matching exchanges (truncated: {reason})", {
exported: meta.exported,
matched: meta.matched,
reason: meta.truncatedReason ?? "limit",
}),
);
} else {
toast.success(t("Exported {count} exchanges to HAR", { count: meta.exported }));
}
} catch (e) {
toast.error((e as Error).message);
} finally {
setHarExporting(false);
}
};
const exchanges = React.useMemo(() => traffic?.exchanges ?? [], [traffic]);
const total = traffic?.total ?? exchanges.length;
const pageCount = Math.max(1, Math.ceil(total / size));
@@ -378,9 +477,76 @@ export default function TrafficPage() {
<span className="text-xs text-muted-foreground tabular-nums">
{t("{count} records", { count: traffic?.count ?? 0 })}
</span>
<input
ref={harInputRef}
type="file"
accept=".har,application/json"
className="hidden"
onChange={(e) => void handleHarFileChange(e)}
/>
<Button
variant="outline"
size="sm"
className="h-8"
disabled={harImporting}
onClick={() => harInputRef.current?.click()}
>
{harImporting ? <Loader2Icon className="size-3.5 animate-spin" /> : <UploadIcon className="size-3.5" />}
{harImporting ? t("Importing HAR…") : t("Import HAR")}
</Button>
<Button
variant="outline"
size="sm"
className="h-8"
disabled={harExporting || !traffic?.count}
onClick={() => void handleHarExport()}
>
{harExporting ? <Loader2Icon className="size-3.5 animate-spin" /> : <DownloadIcon className="size-3.5" />}
{harExporting ? t("Exporting HAR…") : t("Export HAR")}
</Button>
</div>
</div>
{harError ? (
<Alert variant="destructive" className="flex items-center justify-between gap-2 py-2">
<AlertDescription className="text-xs">{harError}</AlertDescription>
<Button variant="ghost" size="icon-xs" aria-label={t("Dismiss")} onClick={() => setHarError(null)}>
<XIcon className="size-3.5" />
</Button>
</Alert>
) : null}
{harSummary ? (
<Alert className="flex items-start justify-between gap-2 py-2">
<AlertDescription className="space-y-1 text-xs">
<p>
{t("HAR import complete: {imported} imported, {skipped} skipped, {failed} failed", {
imported: harSummary.imported,
skipped: harSummary.skipped,
failed: harSummary.failed,
})}
</p>
{harSummary.truncated ? (
<p className="text-amber-600 dark:text-amber-400">
{t("HAR import stopped early at the 32 MiB decoded body cap.")}
</p>
) : null}
{harSummary.errors && harSummary.errors.length > 0 ? (
<ul className="list-disc pl-4 text-muted-foreground">
{harSummary.errors.slice(0, 5).map((item) => (
<li key={`${item.index}-${item.reason}`} className="font-mono">
#{item.index}: {item.reason}
</li>
))}
</ul>
) : null}
</AlertDescription>
<Button variant="ghost" size="icon-xs" aria-label={t("Dismiss")} onClick={() => setHarSummary(null)}>
<XIcon className="size-3.5" />
</Button>
</Alert>
) : null}
{/* Toolbar */}
<div className="flex flex-wrap items-center gap-2">
<Popover open={pickerOpen} onOpenChange={setPickerOpen}>
@@ -598,6 +764,16 @@ export default function TrafficPage() {
))}
</SelectContent>
</Select>
<Select value={rewrittenFilter} onValueChange={setRewrittenFilter}>
<SelectTrigger size="sm" className="w-32">
<SelectValue placeholder={t("Rewritten")} />
</SelectTrigger>
<SelectContent>
<SelectItem value="all">{t("All traffic")}</SelectItem>
<SelectItem value="rewritten">{t("Rewritten")}</SelectItem>
<SelectItem value="original">{t("Original")}</SelectItem>
</SelectContent>
</Select>
<div className="flex items-center gap-1 text-xs text-muted-foreground">
<span>{t("Response size")}</span>
<Input
@@ -721,7 +897,17 @@ export default function TrafficPage() {
<MethodBadge method={e.method} />
</TableCell>
<TableCell className="max-w-0">
<span className="block truncate font-mono text-xs">{e.url}</span>
<div className="flex items-center gap-1.5">
<span className="min-w-0 truncate font-mono text-xs">{e.url}</span>
{e.rewritten ? (
<Badge
variant="outline"
className="shrink-0 border-amber-500/30 bg-amber-500/10 px-1.5 py-0 text-[10px] font-medium text-amber-600 dark:text-amber-400"
>
{t("Rewritten")}
</Badge>
) : null}
</div>
</TableCell>
<TableCell>
<span className={cn("font-mono text-xs font-semibold tabular-nums", statusTone(e.status))}>
@@ -762,6 +948,14 @@ export default function TrafficPage() {
<Badge variant="secondary" className={cn("font-mono tabular-nums", statusTone(selected.status))}>
{selected.status}
</Badge>
{selected.rewritten ? (
<Badge
variant="outline"
className="border-amber-500/30 bg-amber-500/10 text-amber-600 dark:text-amber-400"
>
{t("Rewritten")}
</Badge>
) : null}
<span className="ml-auto text-xs text-muted-foreground tabular-nums">{fmtTime(selected.ts)}</span>
</div>
<SheetTitle className="break-all font-mono">{selected.host}</SheetTitle>
+1
View File
@@ -4,6 +4,7 @@
/* Theme preset styles: these override CSS variables based on the selected data-theme-preset */
@import "../styles/presets/brutalist.css";
@import "../styles/presets/neon.css";
@import "../styles/presets/soft-pop.css";
@import "../styles/presets/tangerine.css";
+29
View File
@@ -0,0 +1,29 @@
# UI localization
English source text is the translation key. `t(key, vars)` is shared by React
components, module constants, toasts and non-React helpers; missing keys fall back
to English. Keep keys, `{name}` placeholders, HTML formatting tags, Go template
actions and literal command/API examples intact when adding translations.
The registered locales are English (`en`), Turkish (`tr`) and Simplified Chinese
(`zh-CN`). The Preferences language control renders `LOCALES` directly. A saved
`artex.locale` browser preference takes priority over browser language detection;
otherwise an exact language tag, then its base language, is matched. Chinese
browser variants use the available Simplified Chinese dictionary. Static export
and unsupported languages retain the English default. Switching language saves
the preference and reloads the page, following the existing module-level design.
To add a locale, add `locales/<code>.json` and register it in `Locale`, `LOCALES`,
`DICTIONARIES` and `INTL_LOCALES` in `index.ts`. Date/number formatting uses
`intlLocale`, and the HTML `lang` attribute follows the selected locale.
Run `npm run test:i18n` and `npm run build:static` from `web/`. The dictionary
checker covers every locale, checks literal call sites, requires matching keys
including dynamic entries, and validates placeholders. Runtime tests exercise
language detection, persistence, English fallback and prototype-safe lookups.
The initial Simplified Chinese dictionary reuses Chinese wording from this
repository's parent of commit `e233c02` (the English translation migration), with
additional translations for current functionality and normalized UI terminology.
This only localizes interface text; backend data, user content, model responses,
protocol identifiers and tool output are not rewritten.
+21 -7
View File
@@ -8,11 +8,12 @@
// setLocale() stores the choice and reloads. That keeps t() usable anywhere (components,
// module constants, toasts, non-React helpers) without hooks or re-render plumbing.
//
// To translate the UI into another language, add locales/<code>.json and list it in LOCALES.
// To translate the UI into another language, add locales/<code>.json and register it below.
import tr from "./locales/tr.json";
import zhCN from "./locales/zh-CN.json";
export type Locale = "tr" | "en";
export type Locale = "tr" | "en" | "zh-CN";
// Used when nothing is saved and the browser language is not one of LOCALES,
// and for the static prerender, which has no browser.
@@ -21,6 +22,7 @@ export const DEFAULT_LOCALE: Locale = "en";
export const LOCALES: { code: Locale; label: string }[] = [
{ code: "tr", label: "Türkçe" },
{ code: "en", label: "English" },
{ code: "zh-CN", label: "简体中文" },
];
const STORAGE_KEY = "artex.locale";
@@ -28,6 +30,13 @@ const STORAGE_KEY = "artex.locale";
const DICTIONARIES: Record<Locale, Record<string, string>> = {
tr: tr as Record<string, string>,
en: {},
"zh-CN": zhCN as Record<string, string>,
};
const INTL_LOCALES: Record<Locale, string> = {
tr: "tr-TR",
en: "en-US",
"zh-CN": "zh-CN",
};
function detectLocale(): Locale {
@@ -35,13 +44,18 @@ function detectLocale(): Locale {
if (typeof window === "undefined") return DEFAULT_LOCALE;
try {
const saved = window.localStorage.getItem(STORAGE_KEY);
if (saved === "tr" || saved === "en") return saved;
const match = LOCALES.find((l) => l.code === saved);
if (match) return match.code;
} catch {
/* storage blocked: fall through to the browser language */
}
for (const lang of window.navigator.languages ?? [window.navigator.language]) {
const base = lang?.toLowerCase().split("-")[0];
const match = LOCALES.find((l) => l.code === base);
const tag = lang?.toLowerCase();
const base = tag?.split("-")[0];
// Prefer a full BCP 47 match, then the available locale for that language.
const match =
LOCALES.find((l) => l.code.toLowerCase() === tag) ??
LOCALES.find((l) => l.code.toLowerCase().split("-")[0] === base);
if (match) return match.code;
}
return DEFAULT_LOCALE;
@@ -52,7 +66,7 @@ export const locale: Locale = detectLocale();
if (typeof document !== "undefined") document.documentElement.lang = locale;
/** BCP 47 tag for Intl / toLocaleString calls, e.g. date.toLocaleString(intlLocale). */
export const intlLocale = locale === "tr" ? "tr-TR" : "en-US";
export const intlLocale = INTL_LOCALES[locale];
const dict = DICTIONARIES[locale];
@@ -71,7 +85,7 @@ export function setLocale(next: Locale) {
try {
window.localStorage.setItem(STORAGE_KEY, next);
} catch {
/* storage blocked: the switch lasts only until the next load */
/* storage blocked: fall back to browser-language detection on reload */
}
window.location.reload();
}
+17
View File
@@ -245,6 +245,7 @@
"All statuses": "Tüm durumlar",
"All tasks": "Tüm görevler",
"All tool execution records": "Tüm araç çalıştırma kayıtları",
"All traffic": "Tüm trafik",
"All types": "Tüm türler",
"all used": "tümü kullanıldı",
"All verification states": "Tüm doğrulama durumları",
@@ -767,6 +768,7 @@
"Discovery time": "Keşif zamanı",
"Discovery time currently ascending, click to toggle sort direction": "Keşif zamanı şu anda artan sırada, sıralama yönünü değiştirmek için tıklayın",
"Discovery time currently descending, click to toggle sort direction": "Keşif zamanı şu anda azalan sırada, sıralama yönünü değiştirmek için tıklayın",
"Dismiss": "Kapat",
"Dismiss update notice": "Güncelleme bildirimini kapat",
"dismissed": "yok sayıldı",
"Dismissed": "Yok sayıldı",
@@ -925,9 +927,13 @@
"Export failed: {error}": "Dışa aktarma başarısız: {error}",
"Export findings": "Bulguları dışa aktar",
"Export format": "Dışa aktarma biçimi",
"Export HAR": "HAR dışa aktar",
"Export scope": "Dışa aktarma kapsamı",
"Export the {count} selected items": "Seçili {count} öğeyi dışa aktar",
"Export the current filter results ({count} items)": "Mevcut süzgeç sonuçlarını dışa aktar ({count} öğe)",
"Exported {count} exchanges to HAR": "{count} değişim HAR olarak dışa aktarıldı",
"Exported {exported} of {matched} matching exchanges (truncated: {reason})": "Eşleşen {matched} değişimin {exported} tanesi dışa aktarıldı (kısaltıldı: {reason})",
"Exporting HAR…": "HAR dışa aktarılıyor…",
"Exporting…": "Dışa aktarılıyor…",
"External MCP tool servers · visibility granted per agent": "Harici MCP araç sunucuları · görünürlük ajan bazında verilir",
"Fact": "Olgu",
@@ -1070,6 +1076,13 @@
"greater than": "büyüktür",
"greater than or equal": "büyük veya eşittir",
"Handle automatically after the timeout instead of waiting": "Beklemek yerine zaman aşımından sonra otomatik olarak işle",
"HAR export failed: {error}": "HAR dışa aktarma başarısız: {error}",
"HAR export is not available in mock mode": "HAR dışa aktarma sahte modda kullanılamaz",
"HAR file exceeds the 32 MiB limit": "HAR dosyası 32 MiB sınırını aşıyor",
"HAR import complete: {imported} imported, {skipped} skipped, {failed} failed": "HAR içe aktarma tamamlandı: {imported} içe aktarıldı, {skipped} atlandı, {failed} başarısız",
"HAR import failed: {error}": "HAR içe aktarma başarısız: {error}",
"HAR import is not available in mock mode": "HAR içe aktarma sahte modda kullanılamaz",
"HAR import stopped early at the 32 MiB decoded body cap.": "HAR içe aktarma 32 MiB çözülmüş gövde sınırında erken durdu.",
"Hard delete": "Kalıcı silme",
"Header": "Başlık",
"Header name": "Başlık adı",
@@ -1112,6 +1125,8 @@
"Idle": "Boşta",
"Ignored": "Yok sayıldı",
"Implicit TLS": "Örtük TLS",
"Import HAR": "HAR içe aktar",
"Importing HAR…": "HAR içe aktarılıyor…",
"In": "Girdi",
"In {input} (incl. cache {cache}) · Out {output}": "Girdi {input} (önbellek {cache} dahil) · Çıktı {output}",
"In flight": "Devam eden",
@@ -1600,6 +1615,7 @@
"OR (either one matches)": "OR (herhangi biri eşleşir)",
"Ordered failover: workers share the current profile and switch after quota exhaustion or repeated provider failures.": "Sıralı yedeğe geçiş: çalışanlar geçerli profili paylaşır ve kota tükendiğinde veya sağlayıcı tekrar tekrar başarısız olduğunda geçiş yapar.",
"origin": "başlangıç",
"Original": "Orijinal",
"Original status": "Önceki durum",
"Other": "Diğer",
"Out": "Çıktı",
@@ -1906,6 +1922,7 @@
"Revoked Skill \"{name}\" visibility": "\"{name}\" becerisinin görünürlüğü kaldırıldı",
"Revoked visibility from \"{agent}\"": "\"{agent}\" için görünürlük kaldırıldı",
"Revoked visibility to \"{name}\"": "\"{name}\" için görünürlük kaldırıldı",
"Rewritten": "Yeniden yazılmış",
"Rewritten by capture rules": "Yakalama kuralları tarafından yeniden yazıldı",
"Rewritten by capture rules: {ids}": "Yakalama kuralları tarafından yeniden yazıldı: {ids}",
"Risk": "Risk",
File diff suppressed because it is too large Load Diff
+75
View File
@@ -102,6 +102,8 @@ import type {
TrafficDetail,
TrafficEvidenceRef,
TrafficEvidenceRole,
TrafficHARExportMeta,
TrafficHARImportResult,
TrafficHost,
TrafficReplayRequest,
TrafficReplayResult,
@@ -840,6 +842,7 @@ export const api = {
body?: string;
path?: string;
status?: string;
rewritten?: string;
respMin?: string;
respMax?: string;
sort?: string;
@@ -854,6 +857,7 @@ export const api = {
(opts.body ? `&body=${encodeURIComponent(opts.body)}` : "") +
(opts.path ? `&path=${encodeURIComponent(opts.path)}` : "") +
(opts.status && opts.status !== "all" ? `&status=${encodeURIComponent(opts.status)}` : "") +
(opts.rewritten && opts.rewritten !== "all" ? `&rewritten=${encodeURIComponent(opts.rewritten)}` : "") +
(opts.respMin ? `&resp_min=${encodeURIComponent(opts.respMin)}` : "") +
(opts.respMax ? `&resp_max=${encodeURIComponent(opts.respMax)}` : "") +
(opts.sort ? `&sort=${encodeURIComponent(opts.sort)}` : "") +
@@ -884,6 +888,77 @@ export const api = {
apply_rules: Boolean(req.apply_rules),
});
},
// Imports a raw HAR 1.2 JSON document into the traffic store.
trafficImportHAR: async (rawJSON: string): Promise<TrafficHARImportResult> => {
if (MOCK) throw new Error(t("HAR import is not available in mock mode"));
return http<TrafficHARImportResult>(`/traffic/import/har`, {
method: "POST",
body: rawJSON,
});
},
// Exports filtered traffic as a HAR 1.2 file download and returns truncation metadata.
trafficExportHAR: async (
opts: {
host?: string;
method?: string;
q?: string;
body?: string;
path?: string;
status?: string;
rewritten?: string;
respMin?: string;
respMax?: string;
} = {},
): Promise<TrafficHARExportMeta> => {
if (MOCK) throw new Error(t("HAR export is not available in mock mode"));
const qs = new URLSearchParams();
if (opts.host) qs.set("host", opts.host);
if (opts.method && opts.method !== "all") qs.set("method", opts.method);
if (opts.q) qs.set("q", opts.q);
if (opts.body) qs.set("body", opts.body);
if (opts.path) qs.set("path", opts.path);
if (opts.status && opts.status !== "all") qs.set("status", opts.status);
if (opts.rewritten && opts.rewritten !== "all") qs.set("rewritten", opts.rewritten);
if (opts.respMin) qs.set("resp_min", opts.respMin);
if (opts.respMax) qs.set("resp_max", opts.respMax);
const suffix = qs.toString();
const token = getToken();
const r = await fetch(`/api/traffic/export/har${suffix ? `?${suffix}` : ""}`, {
headers: { ...(token ? { Authorization: `Bearer ${token}` } : {}) },
});
if (r.status === 401) {
if (typeof window !== "undefined") {
localStorage.removeItem("artex_token");
document.cookie = "artex_token=; path=/; max-age=0";
window.location.href = "/login";
}
throw new Error(t("Unauthorized"));
}
if (!r.ok) {
let msg = String(r.status);
try {
const payload = (await r.json()) as { error?: unknown };
if (typeof payload.error === "string" && payload.error.trim()) msg = payload.error.trim();
} catch {
// Keep status fallback.
}
throw new ApiError(t("HAR export failed: {error}", { error: msg }), r.status);
}
const blob = await r.blob();
const exported = Number(r.headers.get("X-ARTEX-HAR-Exported") ?? "0") || 0;
const matched = Number(r.headers.get("X-ARTEX-HAR-Matched") ?? "0") || 0;
const truncated = r.headers.get("X-ARTEX-HAR-Truncated") === "true";
const truncatedReason = r.headers.get("X-ARTEX-HAR-Truncated-Reason") ?? undefined;
const objectUrl = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = objectUrl;
a.download = "artex-traffic.har";
document.body.appendChild(a);
a.click();
a.remove();
URL.revokeObjectURL(objectUrl);
return { exported, matched, truncated, truncatedReason };
},
trafficHosts: () => get<{ hosts: TrafficHost[] }>(`/traffic/hosts`),
trafficDeleteHost: (host: string) => del<{ deleted: number }>(`/traffic?host=${encodeURIComponent(host)}`),
trafficDeleteHosts: (hosts: string[]) => del<{ deleted: number }>(`/traffic/hosts`, { hosts }),
+8
View File
@@ -29,6 +29,14 @@ export const THEME_PRESET_OPTIONS = [
dark: "oklch(0.7044 0.1872 23.1858)",
},
},
{
label: "Neon",
value: "neon",
primary: {
light: "#00685f",
dark: "#54eccd",
},
},
{
label: "Soft Pop",
value: "soft-pop",
+22
View File
@@ -903,6 +903,7 @@ export interface TrafficExchange {
status: number;
content_type: string;
resp_len: number;
rewritten?: boolean;
}
export interface TrafficRewriteStats {
@@ -913,6 +914,27 @@ export interface TrafficRewriteStats {
sweeps: number;
}
export interface TrafficHARImportError {
index: number;
url?: string;
reason: string;
}
export interface TrafficHARImportResult {
imported: number;
skipped: number;
failed: number;
truncated?: boolean;
errors?: TrafficHARImportError[];
}
export interface TrafficHARExportMeta {
exported: number;
matched: number;
truncated: boolean;
truncatedReason?: string;
}
export interface TrafficResp {
enabled: boolean;
proxy?: string;
+72
View File
@@ -0,0 +1,72 @@
/*
label: Neon
value: neon
*/
:root[data-theme-preset="neon"] {
--background: #f3f8f9;
--foreground: #14252d;
--card: #ffffff;
--card-foreground: var(--foreground);
--popover: #ffffff;
--popover-foreground: var(--foreground);
--primary: #00685f;
--primary-foreground: #ffffff;
--secondary: #dcebed;
--secondary-foreground: #19363b;
--muted: #e6eff1;
--muted-foreground: #456169;
--accent: #ccefe8;
--accent-foreground: #08483f;
--destructive: #aa2647;
--border: #b6cdd1;
--input: #728d91;
--ring: #00766d;
--chart-1: #00776e;
--chart-2: #385eb2;
--chart-3: #9b3e7b;
--chart-4: #916008;
--chart-5: #527927;
--sidebar: #e8f2f3;
--sidebar-foreground: var(--foreground);
--sidebar-primary: var(--primary);
--sidebar-primary-foreground: var(--primary-foreground);
--sidebar-accent: var(--accent);
--sidebar-accent-foreground: var(--accent-foreground);
--sidebar-border: var(--border);
--sidebar-ring: var(--ring);
}
.dark:root[data-theme-preset="neon"] {
--background: #0e181f;
--foreground: #e8f6f3;
--card: #16252d;
--card-foreground: var(--foreground);
--popover: #192a34;
--popover-foreground: var(--foreground);
--primary: #54eccd;
--primary-foreground: #082820;
--secondary: #243743;
--secondary-foreground: #e8f6f3;
--muted: #1e303a;
--muted-foreground: #adc5ca;
--accent: #203f43;
--accent-foreground: #a7f5e4;
--destructive: #ffa6b6;
--border: #3f5861;
--input: #66848e;
--ring: #54eccd;
--chart-1: #54eccd;
--chart-2: #8fb2ff;
--chart-3: #f7a5db;
--chart-4: #fbc477;
--chart-5: #b3db7d;
--sidebar: #111f27;
--sidebar-foreground: var(--foreground);
--sidebar-primary: var(--primary);
--sidebar-primary-foreground: var(--primary-foreground);
--sidebar-accent: var(--accent);
--sidebar-accent-foreground: var(--accent-foreground);
--sidebar-border: var(--border);
--sidebar-ring: var(--ring);
}