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
"use server";
import { NextResponse } from "next/server";
import { getInstalledVersion, getLatestVersion } from "@/lib/services/installers/cliproxy";
import { requireManagementAuth } from "@/lib/api/requireManagementAuth";
import { sanitizeErrorMessage } from "@omniroute/open-sse/utils/error";
export async function GET(request: Request) {
const authError = await requireManagementAuth(request);
if (authError) return authError;
try {
// Accept legacy "cliproxyapi" alias as well as the canonical "cliproxy" tool name.
// Both refer to the same binary; normalizing here avoids a DB lookup mismatch.
const { searchParams } = new URL(request.url);
const toolParam = searchParams.get("tool") ?? "cliproxy";
if (toolParam !== "cliproxy" && toolParam !== "cliproxyapi") {
return NextResponse.json({ error: `Unknown tool: ${toolParam}` }, { status: 400 });
}
const [installedVersion, latestVersion] = await Promise.all([
getInstalledVersion(),
getLatestVersion(),
]);
const latest = latestVersion ?? null;
return NextResponse.json({
current: installedVersion,
latest,
updateAvailable: !!installedVersion && !!latest && installedVersion !== latest,
});
} catch (error) {
const message = sanitizeErrorMessage(
error instanceof Error ? error.message : "Failed to check for updates"
);
console.error("[version-manager] check-update error:", message);
return NextResponse.json({ error: message }, { status: 500 });
}
}