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(providers): add lm studio and grok 4.3 support
diegosouzapw3834768b720f
diff --git a/open-sse/config/providerRegistry.ts b/open-sse/config/providerRegistry.tsindex ede6e0cdff..a3bce6d173 100644--- a/open-sse/config/providerRegistry.ts+++ b/open-sse/config/providerRegistry.ts@@ -1151,6 +1151,16 @@ export const REGISTRY: Record<string, RegistryEntry> = {{ id: "qwen-3-32b", name: "Qwen3 32B" },],},+ "lm-studio": {+ id: "lm-studio",+ alias: "lmstudio",+ format: "openai",+ executor: "default",+ baseUrl: "http://localhost:1234/v1",+ authType: "apikey", // Some setups may use proxy with api key+ authHeader: "bearer",+ models: [], // Usually dynamic based on local models downloaded+ },"ollama-cloud": {id: "ollama-cloud",diff --git a/open-sse/executors/grok-web.ts b/open-sse/executors/grok-web.tsindex 99996ee976..a87c51dc86 100644--- a/open-sse/executors/grok-web.ts+++ b/open-sse/executors/grok-web.ts@@ -58,6 +58,11 @@ const MODEL_MAP: Record<string, GrokModelInfo> = {modelMode: "MODEL_MODE_GROK_4_THINKING",isThinking: true,},+ "grok-4.3": {+ grokModel: "grok-4-3-thinking-1129",+ modelMode: "MODEL_MODE_GROK_4_3_THINKING",+ isThinking: true,+ },"grok-4-heavy": { grokModel: "grok-4", modelMode: "MODEL_MODE_HEAVY", isThinking: true },"grok-4.1-mini": {grokModel: "grok-4-1-thinking-1129",diff --git a/src/app/api/db-backups/exportAll/route.ts b/src/app/api/db-backups/exportAll/route.tsindex 4cb2e75144..5b6343c541 100644--- a/src/app/api/db-backups/exportAll/route.ts+++ b/src/app/api/db-backups/exportAll/route.ts@@ -4,7 +4,7 @@ import { CALL_LOGS_DIR } from "@/lib/usage/callLogArtifacts";import fs from "fs";import path from "path";import os from "os";-import { execSync } from "node:child_process";+import { execFileSync } from "node:child_process";import { isAuthenticated } from "@/shared/utils/apiAuth";/**@@ -115,7 +115,7 @@ export async function GET(request: NextRequest) {// Create ZIP using tar (available on all Linux/macOS, and the archiver npm package is not installed)// We'll use Node.js built-in zlib to create a simple tar.gz insteadconst tarPath = zipPath.replace(".zip", ".tar.gz");- execSync(`tar -czf "${tarPath}" -C "${path.dirname(tempDir)}" "${path.basename(tempDir)}"`, {+ execFileSync("tar", ["-czf", tarPath, "-C", path.dirname(tempDir), path.basename(tempDir)], {timeout: 30000,});diff --git a/src/app/api/v1/chat/completions/route.ts b/src/app/api/v1/chat/completions/route.tsindex e478e167d1..65bc9cf056 100644--- a/src/app/api/v1/chat/completions/route.ts+++ b/src/app/api/v1/chat/completions/route.ts@@ -1,4 +1,4 @@-import { CORS_ORIGIN, CORS_HEADERS } from "@/shared/utils/cors";+import { CORS_ORIGIN, CORS_HEADERS, handleCorsOptions } from "@/shared/utils/cors";import { callCloudWithMachineId } from "@/shared/utils/cloud";import { handleChat } from "@/sse/handlers/chat";import { initTranslators } from "@omniroute/open-sse/translator/index.ts";@@ -25,13 +25,7 @@ function ensureInitialized() {* Handle CORS preflight*/export async function OPTIONS() {- return new Response(null, {- headers: {- "Access-Control-Allow-Origin": CORS_ORIGIN,- "Access-Control-Allow-Methods": "GET, POST, OPTIONS",- "Access-Control-Allow-Headers": "*",- },- });+ return handleCorsOptions();}export async function POST(request) {diff --git a/src/lib/acp/manager.ts b/src/lib/acp/manager.tsindex fb58ee13eb..055fc1e222 100644--- a/src/lib/acp/manager.ts+++ b/src/lib/acp/manager.ts@@ -47,6 +47,11 @@ export class AcpManager extends EventEmitter {args: string[] = [],env: Record<string, string> = {}): AcpSession {+ const ALLOWED_AGENTS = ["claude", "codex", "gemini", "qwen"];+ if (!ALLOWED_AGENTS.includes(agentId)) {+ throw new Error(`Unknown agent: ${agentId}`);+ }+const sessionId = `acp-${agentId}-${Date.now()}-${crypto.randomUUID().slice(0, 8)}`;const child = spawn(binary, args, {diff --git a/src/lib/db/encryption.ts b/src/lib/db/encryption.tsindex c26cd10624..07ab9db803 100644--- a/src/lib/db/encryption.ts+++ b/src/lib/db/encryption.ts@@ -8,7 +8,7 @@* (stores plaintext for development convenience).*/-import { createCipheriv, createDecipheriv, randomBytes, scryptSync } from "crypto";+import { createCipheriv, createDecipheriv, randomBytes, scryptSync, createHash } from "crypto";const ALGORITHM = "aes-256-gcm";const IV_LENGTH = 16;@@ -16,6 +16,7 @@ const KEY_LENGTH = 32;const PREFIX = "enc:v1:";let _derivedKey: Buffer | null = null;+let _legacyDerivedKey: Buffer | null = null;/** Connection object with potentially encrypted credential fields. */export interface ConnectionFields {@@ -44,8 +45,8 @@ function getKey(): Buffer | null {return null;}- // Fixed salt derived from app name — deterministic so same key always produces same derived key- const salt = "omniroute-field-encryption-v1";+ // Dynamic salt derived from key hash to prevent rainbow table attacks, while remaining deterministic+ const salt = createHash("sha256").update(secret).digest().slice(0, 16);try {_derivedKey = scryptSync(secret, salt, KEY_LENGTH);} catch (err: unknown) {@@ -59,6 +60,25 @@ function getKey(): Buffer | null {return _derivedKey;}+/**+ * Derive legacy 256-bit key from the env secret using the old static salt.+ * Used exclusively for fallback decryption.+ */+function getLegacyKey(): Buffer | null {+ if (_legacyDerivedKey !== null) return _legacyDerivedKey;++ const secret = process.env.STORAGE_ENCRYPTION_KEY;+ if (!secret || typeof secret !== "string" || secret.trim().length === 0) return null;++ const legacySalt = "omniroute-field-encryption-v1";+ try {+ _legacyDerivedKey = scryptSync(secret, legacySalt, KEY_LENGTH);+ } catch {+ return null;+ }+ return _legacyDerivedKey;+}+/** Check if encryption is enabled. */export function isEncryptionEnabled(): boolean {return !!process.env.STORAGE_ENCRYPTION_KEY;@@ -72,7 +92,12 @@ export function encrypt(plaintext: string | null | undefined): string | null | uif (!plaintext || typeof plaintext !== "string") return plaintext;const key = getKey();- if (!key) return plaintext; // passthrough mode+ if (!key) {+ console.warn(+ "[Encryption] STORAGE_ENCRYPTION_KEY not set. Storing plaintext (passthrough mode)."+ );+ return plaintext; // passthrough mode+ }// Already encrypted — don't double-encryptif (plaintext.startsWith(PREFIX)) return plaintext;@@ -132,6 +157,21 @@ export function decrypt(ciphertext: string | null | undefined): string | null |decrypted += decipher.final("utf8");return decrypted;} catch (err: unknown) {+ const legacyKey = getLegacyKey();+ if (legacyKey) {+ try {+ const iv = Buffer.from(ivHex, "hex");+ const authTag = Buffer.from(authTagHex, "hex");+ const legacyDecipher = createDecipheriv(ALGORITHM, legacyKey, iv);+ legacyDecipher.setAuthTag(authTag);++ let legacyDecrypted = legacyDecipher.update(encryptedHex, "hex", "utf8");+ legacyDecrypted += legacyDecipher.final("utf8");+ return legacyDecrypted;+ } catch (legacyErr) {+ // Fallback failed as well+ }+ }const message = err instanceof Error ? err.message : String(err);console.error("[Encryption] Decryption failed:", message);return ciphertext;diff --git a/src/middleware/promptInjectionGuard.ts b/src/middleware/promptInjectionGuard.tsindex 6aaef72e41..74543d9a2e 100644--- a/src/middleware/promptInjectionGuard.ts+++ b/src/middleware/promptInjectionGuard.ts@@ -84,8 +84,12 @@ export function withInjectionGuard(handler: any, options: any = {}) {request.headers.set("X-Injection-Detections", String(result.detections.length));}}- } catch {- // Don't block on guard errors — fail open+ } catch (error) {+ console.error("[SECURITY] Injection guard error:", error);+ return new Response(JSON.stringify({ error: "Security check failed" }), {+ status: 500,+ headers: { "Content-Type": "application/json" },+ });}return handler(request, context);diff --git a/src/shared/constants/providers.ts b/src/shared/constants/providers.tsindex 535477becb..26afcc2ebc 100644--- a/src/shared/constants/providers.ts+++ b/src/shared/constants/providers.ts@@ -364,6 +364,15 @@ export const APIKEY_PROVIDERS = {textIcon: "NB",website: "https://nanobananaapi.ai",},+ "lm-studio": {+ id: "lm-studio",+ alias: "lmstudio",+ name: "LM Studio",+ icon: "server",+ color: "#4A148C",+ textIcon: "LM",+ website: "https://lmstudio.ai",+ },"ollama-cloud": {id: "ollama-cloud",alias: "ollamacloud",diff --git a/src/shared/utils/cors.ts b/src/shared/utils/cors.tsindex 6e045c767d..848e4ae8d5 100644--- a/src/shared/utils/cors.ts+++ b/src/shared/utils/cors.ts@@ -24,7 +24,8 @@ export const CORS_ORIGIN = process.env.CORS_ORIGIN || "*";export const CORS_HEADERS = {"Access-Control-Allow-Origin": CORS_ORIGIN,"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",- "Access-Control-Allow-Headers": "Content-Type, Authorization, x-api-key, anthropic-version",+ "Access-Control-Allow-Headers":+ "Content-Type, Authorization, x-api-key, anthropic-version, x-omniroute-connection, x-internal-test, accept",};/**