"use strict"; /** * @typedef {Object} EngineContext * @property {import('../../config').loadConfig} config * @property {import('../../logger').Logger} logger * @property {import('../history/history-service').HistoryService} history * @property {import('../comfy/comfy-client').ComfyClient} comfyClient * @property {import('../comfy/comfy-runtime').ComfyRuntime} comfyRuntime * @property {import('../codex/cli').CodexCli} codexCli * * @typedef {Object} EngineResult * @property {boolean} ok * @property {import('../history/history-store').Version} [version] * @property {object} [extra] * @property {string} [error] * @property {any} [details] */ class EngineRegistry { constructor() { this._factories = new Map(); } /** * Регистрирует фабрику движка для типа задания. * @param {string} type - 'edit' | 'upscale' | 'suggest' * @param {(ctx: EngineContext) => { run: (job: any) => Promise }} factory */ register(type, factory) { this._factories.set(type, factory); } /** * Создаёт экземпляр движка для указанного типа задания. * @param {string} type * @param {EngineContext} ctx */ create(type, ctx) { const factory = this._factories.get(type); if (!factory) { throw new Error(`Не найден движок для типа задания: ${type}`); } return factory(ctx); } has(type) { return this._factories.has(type); } } module.exports = { EngineRegistry, };