export const NIANCODE_USER_MODEL_ACCOUNT_ID = 'niancode-user-models'; export const NIANCODE_USER_MODEL_ACCOUNT_LABEL = 'Makelore Models'; const WORKS_SQUARE_MODEL_ROUTING_PREFIXES_TO_STRIP = new Set([ 'deepseek', ]); export interface NianCodeUserModelAccountLike { id: string; } export function normalizeImportedUserModelId(rawModel: string): string { const trimmed = rawModel.trim(); const slashIndex = trimmed.indexOf('/'); if (slashIndex <= 0 || slashIndex >= trimmed.length - 1) { return trimmed; } const prefix = trimmed.slice(0, slashIndex).toLowerCase(); const modelId = trimmed.slice(slashIndex + 1).trim(); return WORKS_SQUARE_MODEL_ROUTING_PREFIXES_TO_STRIP.has(prefix) && modelId ? modelId : trimmed; } export function selectUserModelRuntimeAccounts( accounts: T[], ): T[] { const importedUserModelAccount = accounts.find((account) => ( account.id === NIANCODE_USER_MODEL_ACCOUNT_ID )); return importedUserModelAccount ? [importedUserModelAccount] : accounts; }