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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): HF download works music-only + gate custom models per engine
[._.]/ Adam Eivy21e6d1b322a9
diff --git a/client/src/components/music/MusicGenPanel.jsx b/client/src/components/music/MusicGenPanel.jsxindex 787308b7ba..5bd115853b 100644--- a/client/src/components/music/MusicGenPanel.jsx+++ b/client/src/components/music/MusicGenPanel.jsx@@ -198,7 +198,10 @@ export default function MusicGenPanel({ track, prompt, lyrics, onGenerated }) {) : null}</div>- {/* Install an additional model from HuggingFace. */}+ {/* Install an additional model from HuggingFace — only for engines that+ can render an arbitrary checkpoint (musicgen/audioldm2). ACE-Step uses+ a fixed foundation checkpoint, so the install affordance is hidden. */}+ {engine?.customModels ? (<div className="pt-2 border-t border-port-border/60"><span className="block text-[11px] uppercase tracking-wider text-gray-500 mb-1">Install a model from HuggingFace</span><div className="flex items-center gap-2">@@ -221,6 +224,7 @@ export default function MusicGenPanel({ track, prompt, lyrics, onGenerated }) {</div>{installProgress ? <p className="text-[11px] text-gray-500 mt-1 truncate">{installProgress.message}</p> : null}</div>+ ) : null}</div>);}diff --git a/server/lib/hfDownload.js b/server/lib/hfDownload.jsindex bf30c8ff13..6cd7c727e7 100644--- a/server/lib/hfDownload.js+++ b/server/lib/hfDownload.js@@ -20,7 +20,10 @@import { spawn } from 'node:child_process';import { join } from 'node:path';-import { resolveFlux2Python, isFlux2VenvHealthy } from './pythonSetup.js';+import {+ resolveFlux2Python, isFlux2VenvHealthy,+ resolveAcestepPython, resolveAudioldm2Python, resolveMusicgenPython,+} from './pythonSetup.js';import { PATHS } from './fileUtils.js';import { getHfTokenInfo } from './hfToken.js';import { safeChildProcessEnv } from './processEnv.js';@@ -30,19 +33,23 @@ const HELPER_SCRIPT = join(PATHS.root, 'scripts', 'hf_download_repo.py');// Resolve a Python interpreter with huggingface_hub installed. Order: FLUX.2// venv (the modern path; always has hf_hub via diffusers), then the-// settings.imageGen.local.pythonPath (mflux installs). Returns null if-// neither is available — the caller surfaces a user-facing error rather-// than silently failing the download.+// settings.imageGen.local.pythonPath (mflux installs), then any provisioned+// MUSIC venv (acestep/audioldm2/musicgen all install huggingface_hub) so the+// Track editor's "Install model" button works in a MUSIC-ONLY setup with no+// image-gen configured. Returns null if none is available — the caller+// surfaces a user-facing error rather than silently failing the download.//// Health-gate the FLUX.2 venv: an interrupted install leaves the binary in// place but no packages, and resolveFlux2Python() alone would still return// that broken interpreter. Every download would then fail on the broken-// venv before reaching the working mflux pythonPath.+// venv before reaching the working fallback.export async function resolveHfDownloadPython() {const flux2 = resolveFlux2Python();if (flux2 && await isFlux2VenvHealthy()) return flux2;const settings = await getSettings();- return settings?.imageGen?.local?.pythonPath || null;+ if (settings?.imageGen?.local?.pythonPath) return settings.imageGen.local.pythonPath;+ // Music venvs are a valid hf_hub host — used when only music gen is set up.+ return resolveAcestepPython() || resolveAudioldm2Python() || resolveMusicgenPython() || null;}// Returns `{ promise, kill }`. The promise resolves with `{ ok, sizeBytes,diff --git a/server/routes/music.js b/server/routes/music.jsindex a350c4db0e..af32b0ccc0 100644--- a/server/routes/music.js+++ b/server/routes/music.js@@ -42,6 +42,10 @@ router.get('/engines', asyncHandler(async (_req, res) => {maxDurationSec: engine.maxDurationSec,defaultDurationSec: engine.defaultDurationSec,lyrics: engine.lyrics === true,+ // Whether this engine can render an arbitrary HuggingFace checkpoint (gates+ // the "install/select model" UI). ACE-Step resolves a single foundation+ // checkpoint via checkpoint_dir, so custom repos don't apply to it.+ customModels: engine.customModels === true,ready: isEngineReady(engine.id),installEnv: engine.installEnv,venvDefault: engine.venvDefault,@@ -77,6 +81,12 @@ router.get('/models/:engine', asyncHandler(async (req, res) => {router.post('/models', asyncHandler(async (req, res) => {const body = validateRequest(installSchema, req.body ?? {});if (!ENGINES[body.engine]) throw new ServerError('Unknown audio engine', { status: 400, code: 'AUDIO_MODEL_UNKNOWN_ENGINE' });+ // Reject install for engines that can't render a custom HF checkpoint (e.g.+ // ACE-Step, which uses a fixed checkpoint_dir) — otherwise a downloaded repo+ // would register as selectable but the sidecar would ignore it.+ if (!ENGINES[body.engine].customModels) {+ throw new ServerError(`${ENGINES[body.engine].name} does not support custom HuggingFace models`, { status: 400, code: 'AUDIO_MODEL_ENGINE_FIXED' });+ }if (!isValidRepoId(body.repo)) throw new ServerError('Invalid HuggingFace repo id', { status: 400, code: 'AUDIO_MODEL_INVALID_REPO' });await addAudioModel({ engine: body.engine, repo: body.repo, name: body.name });// Hand the response to the shared SSE driver — it owns writeHead/end + thediff --git a/server/routes/music.test.js b/server/routes/music.test.jsindex cc4b3a6f29..7eb77d5286 100644--- a/server/routes/music.test.js+++ b/server/routes/music.test.js@@ -9,8 +9,8 @@ import { ServerError } from '../lib/errorHandler.js';const gen = vi.hoisted(() => ({ generateMusic: vi.fn(), ready: true }));vi.mock('../services/pipeline/musicGen.js', () => {const ENGINES = {- musicgen: { id: 'musicgen', name: 'MusicGen', models: [{ id: 'm', name: 'M' }], defaultModelId: 'm', minDurationSec: 1, maxDurationSec: 30, defaultDurationSec: 12, installEnv: 'INSTALL_MUSICGEN', venvDefault: '/v/mg' },- acestep: { id: 'acestep', name: 'ACE-Step', models: [{ id: 'a', name: 'A' }], defaultModelId: 'a', minDurationSec: 1, maxDurationSec: 240, defaultDurationSec: 60, installEnv: 'INSTALL_ACESTEP', venvDefault: '/v/ace', lyrics: true },+ musicgen: { id: 'musicgen', name: 'MusicGen', models: [{ id: 'm', name: 'M' }], defaultModelId: 'm', minDurationSec: 1, maxDurationSec: 30, defaultDurationSec: 12, installEnv: 'INSTALL_MUSICGEN', venvDefault: '/v/mg', customModels: true },+ acestep: { id: 'acestep', name: 'ACE-Step', models: [{ id: 'a', name: 'A' }], defaultModelId: 'a', minDurationSec: 1, maxDurationSec: 240, defaultDurationSec: 60, installEnv: 'INSTALL_ACESTEP', venvDefault: '/v/ace', lyrics: true, customModels: false },};return {ENGINES,@@ -86,8 +86,19 @@ describe('music routes', () => {const ace = r.body.engines.find((e) => e.id === 'acestep');expect(ace.lyrics).toBe(true);expect(ace.ready).toBe(true);+ expect(ace.customModels).toBe(false); // fixed checkpoint — no custom installexpect(ace.models).toEqual([{ id: 'm', name: 'M', userAdded: false }]);- expect(r.body.engines.find((e) => e.id === 'musicgen').lyrics).toBe(false);+ const mg = r.body.engines.find((e) => e.id === 'musicgen');+ expect(mg.lyrics).toBe(false);+ expect(mg.customModels).toBe(true);+ });++ it('POST /models rejects an engine that does not support custom models (acestep)', async () => {+ const r = await request(app).post('/api/music/models').send({ engine: 'acestep', repo: 'someorg/ace-variant' });+ expect(r.status).toBe(400);+ expect(r.body.code).toBe('AUDIO_MODEL_ENGINE_FIXED');+ expect(models.add).not.toHaveBeenCalled();+ expect(sse.run).not.toHaveBeenCalled();});it('GET /models/:engine returns the merged model list; 404s for an unknown engine', async () => {diff --git a/server/services/pipeline/musicGen.js b/server/services/pipeline/musicGen.jsindex 36bccde3ac..dc72b4d30b 100644--- a/server/services/pipeline/musicGen.js+++ b/server/services/pipeline/musicGen.js@@ -114,6 +114,9 @@ export const ENGINES = Object.freeze({resolvePython: resolveMusicgenPython,venvDefault: MUSICGEN_VENV_DEFAULT,installEnv: 'INSTALL_MUSICGEN',+ // The sidecar passes `--model <repo>` straight to from_pretrained, so any+ // HuggingFace MusicGen checkpoint works — user-installed models are usable.+ customModels: true,},audioldm2: {id: 'audioldm2',@@ -128,6 +131,9 @@ export const ENGINES = Object.freeze({resolvePython: resolveAudioldm2Python,venvDefault: AUDIOLDM2_VENV_DEFAULT,installEnv: 'INSTALL_AUDIOLDM2',+ // `--model <repo>` → AudioLDM2Pipeline.from_pretrained: any HF AudioLDM2+ // checkpoint works, so user-installed models are usable.+ customModels: true,},acestep: {id: 'acestep',@@ -145,6 +151,12 @@ export const ENGINES = Object.freeze({// ACE-Step is lyric-aware: the route/UI may send `lyrics`, threaded into the// sidecar as --lyrics. The other engines ignore lyrics (the flag gates UI).lyrics: true,+ // ACE-Step resolves a single foundation checkpoint via its own checkpoint_dir+ // (NOT a from_pretrained repo id), so an arbitrary HF repo can't be swapped+ // in like the diffusers/MLX engines. Custom-model install/selection is+ // therefore disabled for it (customModels falsy) — the sidecar ignores+ // --model by design.+ customModels: false,},});diff --git a/server/services/pipeline/musicGen.test.js b/server/services/pipeline/musicGen.test.jsindex a1cab55f84..bb736b7825 100644--- a/server/services/pipeline/musicGen.test.js+++ b/server/services/pipeline/musicGen.test.js@@ -193,15 +193,18 @@ describe('buildSidecarArgs', () => {});describe('acestep engine entry', () => {- it('is lyric-aware and uses the acestep sidecar', () => {+ it('is lyric-aware, fixed-checkpoint, and uses the acestep sidecar', () => {expect(ENGINES.acestep.lyrics).toBe(true);+ expect(ENGINES.acestep.customModels).toBe(false); // single foundation checkpointexpect(ENGINES.acestep.scriptPath).toMatch(/generate_acestep\.py$/);expect(ENGINES.acestep.installEnv).toBe('INSTALL_ACESTEP');});- it('the other engines are NOT lyric-aware', () => {+ it('the other engines are NOT lyric-aware but DO accept custom HF checkpoints', () => {expect(ENGINES.musicgen.lyrics).toBeUndefined();expect(ENGINES.audioldm2.lyrics).toBeUndefined();+ expect(ENGINES.musicgen.customModels).toBe(true);+ expect(ENGINES.audioldm2.customModels).toBe(true);});});