import {readFileSync} from 'node:fs'; import {getLoraAliases,getLoraTriggers} from '../library'; import {loraIdentityKey} from '~/utils/loras'; import {join} from 'node:path'; import {studio2Root} from './store'; /** Optional metadata-only production export; no production media/catalog mount. */ export function studio2LoraCatalog(owner: string) { const local={aliases:getLoraAliases(owner),triggers:getLoraTriggers(owner)}; try { const source=JSON.parse(readFileSync(process.env.STUDIO2_LORA_CATALOG_PATH || join(studio2Root(),'shared-lora-catalog.cache'),'utf8')); const normalize=(map: any)=>Object.fromEntries(Object.entries(map || {}).filter(([,value])=>typeof value==='string').map(([key,value])=>[loraIdentityKey(key),value])); return {aliases:{...local.aliases,...normalize(source.loraAliases)},triggers:{...local.triggers,...normalize(source.loraTriggers)}}; } catch { return local; } }