type RequestTranslator = ( model: string, body: Record, stream?: boolean, credentials?: Record | null ) => unknown; type ResponseTranslator = ( chunk: Record, state: Record ) => unknown; const requestRegistry = new Map(); const responseRegistry = new Map(); function makeKey(from: string, to: string) { return `${from}:${to}`; } export function register( from: string, to: string, requestFn?: RequestTranslator, responseFn?: ResponseTranslator ) { const key = makeKey(from, to); if (requestFn) { requestRegistry.set(key, requestFn); } if (responseFn) { responseRegistry.set(key, responseFn); } } export function getRequestTranslator(from: string, to: string) { return requestRegistry.get(makeKey(from, to)); } export function getResponseTranslator(from: string, to: string) { return responseRegistry.get(makeKey(from, to)); }