Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
feat(compliance): support level=high filter in audit-log API (B/F4)
diegosouzapw6a198826460a
diff --git a/src/app/api/compliance/audit-log/route.ts b/src/app/api/compliance/audit-log/route.tsindex 974974564c..9873f2d80c 100644--- a/src/app/api/compliance/audit-log/route.ts+++ b/src/app/api/compliance/audit-log/route.ts@@ -1,6 +1,8 @@import { NextResponse } from "next/server";import { countAuditLog, getAuditLog } from "@/lib/compliance/index";import { requireManagementAuth } from "@/lib/api/requireManagementAuth";+import { AuditLogQuerySchema } from "@/shared/schemas/quota";+import { buildErrorBody } from "@omniroute/open-sse/utils/error";export const dynamic = "force-dynamic";@@ -10,12 +12,20 @@ function parsePagination(value: string | null, fallback: number, min: number, mareturn Math.min(max, Math.max(min, parsed));}-export async function GET(request) {+export async function GET(request: Request) {const authError = await requireManagementAuth(request);if (authError) return authError;try {const { searchParams } = new URL(request.url);++ // Parse the level param via AuditLogQuerySchema (Zod, B7)+ const rawLevel = searchParams.get("level") ?? undefined;+ const parsed = AuditLogQuerySchema.safeParse({ level: rawLevel });+ const level = parsed.success ? parsed.data.level : "all";++ const levelFilter: "high" | undefined = level === "high" ? "high" : undefined;+const filters = {action: searchParams.get("action") || undefined,actor: searchParams.get("actor") || undefined,@@ -28,6 +38,7 @@ export async function GET(request) {to: searchParams.get("to") || searchParams.get("until") || undefined,limit: parsePagination(searchParams.get("limit"), 50, 1, 500),offset: parsePagination(searchParams.get("offset"), 0, 0, 10_000),+ levelFilter,};const logs = getAuditLog(filters);@@ -40,9 +51,7 @@ export async function GET(request) {},});} catch (error) {- return NextResponse.json(- { error: error instanceof Error ? error.message : "Failed to fetch audit log" },- { status: 500 }- );+ const message = error instanceof Error ? error.message : "Failed to fetch audit log";+ return NextResponse.json(buildErrorBody(500, message), { status: 500 });}}diff --git a/src/lib/compliance/index.ts b/src/lib/compliance/index.tsindex 8e11f2bc3b..769e3c7574 100644--- a/src/lib/compliance/index.ts+++ b/src/lib/compliance/index.ts@@ -19,6 +19,7 @@ import {getProxyLogsTableMaxRows,} from "../logEnv";import { generateRequestId, getRequestId } from "@/shared/utils/requestId";+import { HIGH_LEVEL_ACTIONS } from "@/lib/audit/highLevelActions";/** @returns {SqliteAdapter | null} */function getDb() {@@ -53,6 +54,8 @@ type AuditLogFilter = {to?: string;limit?: number;offset?: number;+ /** When "high", restricts results to HIGH_LEVEL_ACTIONS only (B7). */+ levelFilter?: "high";};type AuditLogRow = Record<string, unknown> & {@@ -252,6 +255,14 @@ function buildAuditLogQuery(filter: AuditLogFilter = {}): AuditLogQuery {params.push(filter.to);}+ // B7: level=high filter — restrict to HIGH_LEVEL_ACTIONS via parameterized IN clause+ if (filter.levelFilter === "high" && HIGH_LEVEL_ACTIONS.length > 0) {+ const placeholders = HIGH_LEVEL_ACTIONS.map(() => "?").join(", ");+ conditions.push(`action IN (${placeholders})`);+ // HIGH_LEVEL_ACTIONS is readonly — create a mutable copy for spread+ params.push(...Array.from(HIGH_LEVEL_ACTIONS));+ }+return {where: conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "",params,