import { getSelectableModelIds } from "./inference/config"; import { runSql } from "./supabase"; export const PILOT_FAST_MODEL_ID = "gemini-3.1-flash-lite-high"; export const PILOT_PRO_MODEL_ID = "gemini-3.1-pro-high"; const PILOT_MODEL_IDS = new Set([PILOT_FAST_MODEL_ID, PILOT_PRO_MODEL_ID]); export async function isOperatorUser(userId: string): Promise { const result = await runSql( "select is_operator from auth.users where id = $1 limit 1", [userId], ); return result.rows[0]?.is_operator === true; } export function normalizeModelForAccess( modelId: string | null | undefined, isOperator: boolean, ): string { if (isOperator) { const selectable = new Set(getSelectableModelIds()); if (modelId && selectable.has(modelId)) return modelId; return PILOT_FAST_MODEL_ID; } if (modelId && PILOT_MODEL_IDS.has(modelId)) return modelId; return PILOT_FAST_MODEL_ID; }