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
fix: resolve runtime metadata and migration directory lookup
diegosouzapw01092fa34979
diff --git a/open-sse/config/providerHeaderProfiles.ts b/open-sse/config/providerHeaderProfiles.tsindex 69c591652d..abeba69013 100644--- a/open-sse/config/providerHeaderProfiles.ts+++ b/open-sse/config/providerHeaderProfiles.ts@@ -46,25 +46,25 @@ export function getGitHubCopilotChatHeaders(};}-function getRuntimePlatform(): string {+export function getRuntimePlatform(): string {return typeof process !== "undefined" && typeof process.platform === "string"? process.platform: "unknown";}-function getRuntimeArch(): string {+export function getRuntimeArch(): string {return typeof process !== "undefined" && typeof process.arch === "string"? process.arch: "unknown";}-function getRuntimeVersion(): string {+export function getRuntimeVersion(): string {return typeof process !== "undefined" && typeof process.version === "string"? process.version: "unknown";}-function normalizeStainlessPlatform(platform: string = getRuntimePlatform()): string {+export function normalizeStainlessPlatform(platform: string = getRuntimePlatform()): string {const normalized = platform.toLowerCase();if (normalized.includes("ios")) return "iOS";if (normalized === "android") return "Android";@@ -76,7 +76,7 @@ function normalizeStainlessPlatform(platform: string = getRuntimePlatform()): streturn normalized ? `Other:${normalized}` : "Unknown";}-function normalizeStainlessArch(arch: string = getRuntimeArch()): string {+export function normalizeStainlessArch(arch: string = getRuntimeArch()): string {if (arch === "x32") return "x32";if (arch === "x86_64" || arch === "x64") return "x64";if (arch === "arm") return "arm";diff --git a/open-sse/config/providerRegistry.ts b/open-sse/config/providerRegistry.tsindex c65d7f8f64..8265f3376f 100644--- a/open-sse/config/providerRegistry.ts+++ b/open-sse/config/providerRegistry.ts@@ -6,7 +6,6 @@* is auto-generated from this registry.*/-import { platform, arch } from "os";import { ANTIGRAVITY_BASE_URLS } from "./antigravityUpstream.ts";import { ANTIGRAVITY_PUBLIC_MODELS } from "./antigravityModelAliases.ts";import {@@ -33,6 +32,8 @@ import {getKiroServiceHeaders,getQoderDefaultHeaders,getQwenOauthHeaders,+ getRuntimePlatform,+ getRuntimeArch,} from "./providerHeaderProfiles.ts";import type { ProviderRequestDefaults } from "../services/providerRequestDefaults.ts";@@ -245,7 +246,7 @@ const CHAT_OPENAI_COMPAT_MODELS: Record<string, RegistryModel[]> = {};function mapStainlessOs() {- switch (platform()) {+ switch (getRuntimePlatform()) {case "darwin":return "MacOS";case "win32":@@ -253,12 +254,12 @@ function mapStainlessOs() {case "linux":return "Linux";default:- return `Other::${platform()}`;+ return `Other::${getRuntimePlatform()}`;}}function mapStainlessArch() {- switch (arch()) {+ switch (getRuntimeArch()) {case "x64":return "x64";case "arm64":@@ -266,7 +267,7 @@ function mapStainlessArch() {case "ia32":return "x86";default:- return `other::${arch()}`;+ return `other::${getRuntimeArch()}`;}}diff --git a/src/app/(dashboard)/dashboard/providers/[id]/page.tsx b/src/app/(dashboard)/dashboard/providers/[id]/page.tsxindex 5e118a8764..d9095ee893 100644--- a/src/app/(dashboard)/dashboard/providers/[id]/page.tsx+++ b/src/app/(dashboard)/dashboard/providers/[id]/page.tsx@@ -503,6 +503,7 @@ interface ConnectionRowConnection {providerSpecificData?: Record<string, unknown>;expiresAt?: string;tokenExpiresAt?: string;+ maxConcurrent?: number | null;}interface ConnectionRowProps {diff --git a/src/app/api/providers/[id]/route.ts b/src/app/api/providers/[id]/route.tsindex 37f1f8ec90..f4fe213a9b 100644--- a/src/app/api/providers/[id]/route.ts+++ b/src/app/api/providers/[id]/route.ts@@ -129,7 +129,7 @@ export async function PUT(request: Request, { params }: { params: Promise<{ id:providerSpecificData: incomingPsd,} = body;- const existing = await getProviderConnectionById(id);+ const existing = (await getProviderConnectionById(id)) as Record<string, any> | null;if (!existing) {return NextResponse.json({ error: "Connection not found" }, { status: 404 });}@@ -244,7 +244,7 @@ export async function DELETE(request: Request, { params }: { params: Promise<{ iconst { id } = await params;// Fetch connection before deleting to check provider type- const connection = await getProviderConnectionById(id);+ const connection = (await getProviderConnectionById(id)) as Record<string, any> | null;if (!connection) {return NextResponse.json({ error: "Connection not found" }, { status: 404 });}diff --git a/src/lib/db/migrationRunner.ts b/src/lib/db/migrationRunner.tsindex f3484dc214..ad2123c902 100644--- a/src/lib/db/migrationRunner.ts+++ b/src/lib/db/migrationRunner.ts@@ -30,8 +30,25 @@ function resolveMigrationsDir(): string {return path.resolve(configuredDir);}+ const checkLocations = (basePath: string) => {+ const locations = [+ path.join(basePath, "migrations"),+ path.join(basePath, "src", "lib", "db", "migrations"),+ path.join(basePath, "app", "src", "lib", "db", "migrations"),+ ];+ for (const loc of locations) {+ if (fs.existsSync(loc)) return loc;+ }+ return null;+ };+try {- return path.join(path.dirname(fileURLToPath(import.meta.url)), "migrations");+ let currentDir = path.dirname(fileURLToPath(import.meta.url));+ while (currentDir !== path.dirname(currentDir)) {+ const found = checkLocations(currentDir);+ if (found) return found;+ currentDir = path.dirname(currentDir);+ }} catch {// Fall through to more defensive URL parsing below.}@@ -46,21 +63,20 @@ function resolveMigrationsDir(): string {const rawPath = decodeURIComponent(metaUrl.replace(/^file:\/\/\//, "/").replace(/^file:\/\//, ""));- return path.join(path.dirname(path.resolve(rawPath)), "migrations");+ let currentDir = path.dirname(path.resolve(rawPath));+ while (currentDir !== path.dirname(currentDir)) {+ const found = checkLocations(currentDir);+ if (found) return found;+ currentDir = path.dirname(currentDir);+ }} catch {// Fall through to process.cwd fallback}}// Last resort: use process.cwd to find migrations relative to the app root- const cwdFallback = path.join(process.cwd(), "src", "lib", "db", "migrations");- if (fs.existsSync(cwdFallback)) {- return cwdFallback;- }- const appFallback = path.join(process.cwd(), "app", "src", "lib", "db", "migrations");- if (fs.existsSync(appFallback)) {- return appFallback;- }+ const fromCwd = checkLocations(process.cwd());+ if (fromCwd) return fromCwd;throw new Error("[Migration] Could not resolve migrations directory. Set OMNIROUTE_MIGRATIONS_DIR."