Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: defer image model preparation until blank-pin resolution (#9913)

Adam Eivyb02bacd40e7f
diff --git a/server/services/musicVideo/productionPool.js b/server/services/musicVideo/productionPool.js
index 488b32b3cf..a2c496fb3b 100644
--- a/server/services/musicVideo/productionPool.js
+++ b/server/services/musicVideo/productionPool.js
@@ -24,7 +24,6 @@
* routes cost $0.
*/
-import { selectLocalImageModelFromSettings } from '../imageGen/prepareParams.js';
import { ServerError } from '../../lib/errorHandler.js';
import { FAL_IMAGE_FAMILIES, buildFalImageRequest, falImageFamily } from '../../lib/falImageModels.js';
import { resolveFalApiKey } from '../falQueue.js';
@@ -37,9 +36,11 @@ import { isHardwareCompatible } from '../../lib/systemCapabilities.js';
import { RUNNER_FAMILIES } from '../../lib/runners.js';
import { poolHasRoute, routeKey } from './production.js';
-const localImageModel = (route, env) => route.model
- ? (env.imageModels || []).find((model) => model.id === route.model)
- : selectLocalImageModelFromSettings(env.settings, '', env.imageModels || []);
+async function localImageModel(route, env) {
+ if (route.model) return (env.imageModels || []).find((model) => model.id === route.model);
+ const { selectLocalImageModelFromSettings } = await import('../imageGen/prepareParams.js');
+ return selectLocalImageModelFromSettings(env.settings, '', env.imageModels || []);
+}
const describe = (route) => `${route.kind} ${route.mode}${route.model ? ` (${route.model})` : ''}`;
const isMetered = (route) => MUSIC_VIDEO_AUTOMATION_TOOLS.some((t) => t.id === `${route.kind}:${route.mode}` && t.metered);
@@ -139,7 +140,7 @@ async function routeEligibility(route, env) {
}
if (route.mode === 'local') {
if (!settings?.imageGen?.local?.pythonPath) return { ok: false, reason: 'The local image runtime is not configured in Settings' };
- const model = localImageModel(route, env);
+ const model = await localImageModel(route, env);
if (!model) return { ok: false, reason: `Local image model "${route.model || '(none)'}" is not installed` };
if (!isHardwareCompatible(model.hardwareCompatibility)) return { ok: false, reason: `Local image model "${model.id}" cannot run on this hardware` };
return { ok: true, reason: null };
@@ -174,7 +175,7 @@ async function routeEligibility(route, env) {
}
/** Why `route` cannot serve this scene requirement, or null when it can. */
-function routeIncapableReason(route, requirement, env) {
+async function routeIncapableReason(route, requirement, env) {
if (route.kind !== requirement.kind) return `${describe(route)} does not generate ${requirement.kind === 'image' ? 'frames' : 'clips'}`;
if (requirement.kind === 'image' && requirement.conditioning > 0) {
const limit = route.mode === 'local' ? null : maxInputImages(route.mode);
@@ -182,7 +183,7 @@ function routeIncapableReason(route, requirement, env) {
return `${describe(route)} takes at most ${limit} reference image${limit === 1 ? '' : 's'}; the visual spec conditions on ${requirement.conditioning}`;
}
if (route.mode === 'local') {
- const model = localImageModel(route, env);
+ const model = await localImageModel(route, env);
if (model?.runner !== RUNNER_FAMILIES.FLUX2 && model?.pipelineClass !== 'QwenImage21Pipeline') {
return `Local model "${model?.id || route.model || '(none)'}" cannot use reference images (FLUX.2 and Qwen Image 2.1 only)`;
}
@@ -217,7 +218,7 @@ export async function assertRouteAllowed(run, route, requirement, env) {
}
const { ok, reason } = await routeEligibility(route, env);
if (!ok) throw new ServerError(reason, { status: 409, code: 'PRODUCTION_ROUTE_INELIGIBLE' });
- const incapable = routeIncapableReason(route, requirement, env);
+ const incapable = await routeIncapableReason(route, requirement, env);
if (incapable) throw new ServerError(incapable, { status: 409, code: 'PRODUCTION_ROUTE_INCAPABLE' });
}
@@ -233,7 +234,7 @@ export async function chooseProductionRoute(run, requirement, env) {
for (const route of candidates) {
const { ok, reason } = await routeEligibility(route, env);
if (!ok) { reasons.push(reason); continue; }
- const incapable = routeIncapableReason(route, requirement, env);
+ const incapable = await routeIncapableReason(route, requirement, env);
if (incapable) { reasons.push(incapable); continue; }
const skipped = reasons.length ? ` (skipped ${reasons.length} earlier route${reasons.length === 1 ? '' : 's'}: ${reasons.join('; ')})` : '';
const need = requirement.kind === 'image'