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

wire Wan 2.2 + HunyuanVideo MLX runtime (experimental) + changelog

[._.]/ Adam Eivye134c7fbf199
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 096236e9a8..ae92d4fcb3 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -9,6 +9,8 @@ TBD
## Added
- **Brain → Links buckets (bookmark groups)**: the Links tab now has a bucket board above the searchable list, so links can be organized into arbitrary groups (e.g. a "Reading list" or "Work tools" bucket of quick-launch buttons). Each bucket is a colored card whose links render as compact favicon + title chips that open in a new tab; buckets have an inline "add a URL" field (auto-titled from the hostname), inline rename/recolor/icon edit, and can be reordered by dragging. Links can be filed into a bucket by dragging a chip between buckets or via a per-row "+ Bucket…" dropdown in the list; an "Ungrouped" filter tab surfaces links not yet in any bucket. Buckets reuse the existing link records (a new `bucketId`/`bucketOrder` on each link) — single source of truth — and are a new federated brain collection (`buckets`) that syncs across peers. Deleting a bucket keeps its links (they fall back to ungrouped).
+- **Big local diffusion + video models for 64+ GB unified-memory hardware.** New entries in the image registry: Flux 2 Klein 9B native bf16 (`flux2-klein-9b-bf16`, ~36 GB) loads the gated `black-forest-labs/FLUX.2-klein-9B` repo directly without SDNQ or Int8; HiDream-I1 Full + Fast (`hidream-i1-full`, `hidream-i1-fast`) — 17B MoE DiT, needs `meta-llama/Meta-Llama-3.1-8B-Instruct` as `text_encoder_4`; Qwen-Image and Qwen-Image-Edit (`qwen-image`, `qwen-image-edit`) — 20B MMDiT, Apache 2.0, strong English + Chinese text rendering. New video entries: LTX-2.3 Unified Beta bf16 un-deprecated (now practical on 128 GB hardware as the quality ceiling for the mlx_video runtime); Wan 2.2 T2V + I2V A14B (~28 GB) via osama-ata/Wan2.2-mlx; HunyuanVideo (~60 GB) via gaurav-nelson/HunyuanVideo_MLX. The HiDream / Qwen / ERNIE / Z-Image dispatch in `server/services/imageGen/local.js` collapsed to a single `usesDiffusersRunner(model)` predicate; all four reuse the FLUX.2 venv with their pipeline-class + (HiDream only) `text_encoder_4` flags passed through to the shared `scripts/z_image_turbo.py` runner. Wan 2.2 and HunyuanVideo land as new `runtime: 'wan22' | 'hunyuan'` paths in `videoGen/local.js`, each backed by a thin subprocess wrapper (`scripts/generate_wan22.py`, `scripts/generate_hunyuan.py`) over upstream's `generate.py` — provisioned via `INSTALL_WAN22=1` / `INSTALL_HUNYUAN=1 bash scripts/setup-image-video.sh`. Upstream CLI surfaces for Wan and Hunyuan aren't pinned across releases — flagged experimental; if upstream renames args, mark the corresponding entries `broken: true` in `data/media-models.json` until the helper script is updated to match.
+- **Memory Management panel (Settings → Local LLMs).** Surfaces what's currently resident in unified memory and lets you evict it before kicking off a big diffusion render: each loaded Ollama model with per-row Unload, Whisper STT (Stop/Start), Kokoro TTS (Unload), plus a "Free everything" fan-out. Ollama eviction uses the documented `keep_alive: 0` trick on `/api/generate` with an empty prompt — no tokens generated, immediate evict — exposed via `POST /api/local-llm/unload`. Voice paths add `GET /api/voice/tts/status`, `POST /api/voice/tts/unload`, and `POST /api/voice/whisper` (action: start|stop). The panel polls every 5s, errors surface via the default `apiCore` toast (single layer per convention), and "Free everything" fans out in parallel via `Promise.allSettled` so individual failures don't block the rest.
- **Brain → Links search**: a keyword search box on the Links tab filters the saved links list in real time across title, URL, description, and tags (case-insensitive). It composes with the existing GitHub/Other category tabs, includes a clear (×) affordance, and shows a distinct "no links match" empty state separate from the "no links saved yet" state. Filtering is client-side over the already-loaded list, so there are no extra round-trips and no server changes.
- **Unified Story Builder** (`/story-builder`): a new guided page that walks a story from idea → universe aesthetic → plot arc → reader map → characters → issues → production as one linear flow. Each step is LLM-assisted with an AI-refinement affordance and ends with an explicit lock before the next unlocks; going back to revise an earlier step soft-flags the downstream locked steps as "stale" (integrity gate) so nothing silently drifts — without destroying their content. The builder is a thin conductor over the existing Universe / Series / Issue records (no data duplication); heavy per-issue production hands off to the existing Pipeline issue page. Reachable from the sidebar (Create → Story Builder), ⌘K, and voice. The intro screen supports two intake modes: **start from a seed idea**, or **import a finished work** (comic script / screenplay / novel / short story) — the importer reverse-engineers it into a universe, arc, characters, and issues, then drops you into the wizard to review and lock each stage. An **AI provider/model picker** at the top of the builder (and the import tab) drives every operation — idea expand, aesthetic, arc, reader map, character refine, and the import analysis — persisted on the session so one selection applies throughout. The **characters step generates a styled preview image per character** (world style fused with the character descriptor, via the same render path as the Universe Builder) and shows it alongside each character so you can eyeball that the world and character styles read correctly together.
- **Brain → Links: optional title & tags on quick-add**: the Links tab quick-add form now has a collapsible "Add title & tags (optional)" section so a link can be saved with a custom title and tags up front, instead of only being editable after the fact. Collapsed by default to keep the paste-and-go flow clean.
diff --git a/scripts/generate_hunyuan.py b/scripts/generate_hunyuan.py
new file mode 100644
index 0000000000..d8ba0f3796
--- /dev/null
+++ b/scripts/generate_hunyuan.py
@@ -0,0 +1,101 @@
+#!/usr/bin/env python3
+"""
+PortOS HunyuanVideo MLX helper.
+
+Subprocesses upstream gaurav-nelson/HunyuanVideo_MLX inference entry point
+from the cloned repo at --repo-dir. Same subprocess-not-import strategy as
+generate_wan22.py — upstream isn't a pip package.
+
+Spawned by server/services/videoGen/local.js when model.runtime === 'hunyuan'.
+
+EXPERIMENTAL: upstream HunyuanVideo_MLX is community-maintained and its CLI
+hasn't been pinned across releases. ~60 GB resident at bf16 → impractical
+without first evicting Ollama / Whisper / Kokoro (see the Memory Management
+panel under Settings → Local LLMs). If a future upstream commit reshapes
+sample_video.py args, set `broken: true` on `hunyuan_video` in
+data/media-models.json and grep here to update the translation.
+"""
+
+import argparse
+import os
+import subprocess
+import sys
+from pathlib import Path
+
+
+def parse_args() -> argparse.Namespace:
+ p = argparse.ArgumentParser(description="PortOS HunyuanVideo MLX helper")
+ p.add_argument("--repo-dir", required=True, help="Cloned HunyuanVideo_MLX repo root")
+ p.add_argument("--model-repo", required=True, help="HF repo of HunyuanVideo weights (tencent/HunyuanVideo)")
+ p.add_argument("--prompt", required=True)
+ p.add_argument("--width", type=int, required=True)
+ p.add_argument("--height", type=int, required=True)
+ p.add_argument("--num-frames", type=int, default=129)
+ p.add_argument("--steps", type=int, default=30)
+ p.add_argument("--guidance", type=float, default=6.0)
+ p.add_argument("--seed", type=int, default=42)
+ p.add_argument("--output", required=True)
+ return p.parse_args()
+
+
+def main() -> int:
+ args = parse_args()
+
+ repo_dir = Path(args.repo_dir).expanduser().resolve()
+ if not repo_dir.is_dir():
+ print(f"❌ HunyuanVideo MLX repo not found at {repo_dir}", file=sys.stderr)
+ return 64
+ # Upstream's entry point is sample_video.py (mirrors the original tencent
+ # script name). Fall back to generate.py if upstream restructures.
+ sample_py = repo_dir / "sample_video.py"
+ if not sample_py.exists():
+ sample_py = repo_dir / "generate.py"
+ if not sample_py.exists():
+ print(f"❌ no sample_video.py or generate.py under {repo_dir} — upstream layout changed?", file=sys.stderr)
+ return 64
+
+ print(f"STAGE:download-weights:{args.model_repo}", file=sys.stderr, flush=True)
+ try:
+ from huggingface_hub import snapshot_download
+ except Exception as err:
+ print(f"❌ huggingface_hub import failed: {err}", file=sys.stderr)
+ return 64
+ ckpt_dir = snapshot_download(args.model_repo)
+ print(f"🔧 hunyuan: weights ← {ckpt_dir}", file=sys.stderr)
+
+ upstream_args = [
+ sys.executable,
+ str(sample_py),
+ "--model-base", ckpt_dir,
+ "--video-size", str(args.height), str(args.width),
+ "--video-length", str(args.num_frames),
+ "--infer-steps", str(args.steps),
+ "--guidance-scale", str(args.guidance),
+ "--prompt", args.prompt,
+ "--seed", str(args.seed),
+ "--save-path", args.output,
+ ]
+
+ print(f"STAGE:inference", file=sys.stderr, flush=True)
+ print(f"🎬 hunyuan generate {args.width}x{args.height} frames={args.num_frames} steps={args.steps}", file=sys.stderr)
+
+ proc = subprocess.run(
+ upstream_args,
+ cwd=str(repo_dir),
+ env={**os.environ, "PYTHONUNBUFFERED": "1"},
+ )
+
+ if proc.returncode != 0:
+ print(f"❌ hunyuan upstream exited {proc.returncode}", file=sys.stderr)
+ return proc.returncode
+
+ if not Path(args.output).exists():
+ print(f"❌ hunyuan finished but {args.output} missing", file=sys.stderr)
+ return 1
+
+ print(f"✅ hunyuan saved {args.output}", file=sys.stderr)
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/scripts/generate_wan22.py b/scripts/generate_wan22.py
new file mode 100644
index 0000000000..5d9ebf36a2
--- /dev/null
+++ b/scripts/generate_wan22.py
@@ -0,0 +1,113 @@
+#!/usr/bin/env python3
+"""
+PortOS Wan 2.2 MLX helper.
+
+Subprocesses upstream osama-ata/Wan2.2-mlx generate.py from the cloned repo
+at --repo-dir. PortOS releases an arg shape it controls (--prompt, --width,
+--output) and this helper translates to upstream's --task / --size / --ckpt_dir
+form. Done this way (subprocess, not import) because upstream isn't packaged
+as a pip module — it's a repo clone whose internal module layout can shift.
+
+Spawned by server/services/videoGen/local.js when model.runtime === 'wan22'.
+The STAGE: / STATUS: SSE protocol matches generate_ltx2.py so the JS side
+needs no per-runtime parser. Progress hints from upstream tqdm bars are
+forwarded as-is — local.js handleLine() already understands the percentage
+regex.
+
+EXPERIMENTAL: upstream Wan2.2-mlx CLI surface isn't pinned. If a future
+upstream commit renames --task or --ckpt_dir, set the broken flag in
+data/media-models.json (`wan22_t2v_a14b`, `wan22_i2v_a14b`) and grep for
+this helper to update the translation.
+"""
+
+import argparse
+import os
+import subprocess
+import sys
+from pathlib import Path
+
+
+def parse_args() -> argparse.Namespace:
+ p = argparse.ArgumentParser(description="PortOS Wan 2.2 MLX helper")
+ p.add_argument("--repo-dir", required=True, help="Cloned osama-ata/Wan2.2-mlx repo root")
+ p.add_argument("--task", required=True, help="t2v-A14B | i2v-A14B")
+ p.add_argument("--model-repo", required=True, help="HF repo of the Wan 2.2 weights (Wan-AI/Wan2.2-T2V-A14B etc.)")
+ p.add_argument("--prompt", required=True)
+ p.add_argument("--width", type=int, required=True)
+ p.add_argument("--height", type=int, required=True)
+ p.add_argument("--num-frames", type=int, default=81)
+ p.add_argument("--steps", type=int, default=25)
+ p.add_argument("--guidance", type=float, default=5.0)
+ p.add_argument("--seed", type=int, default=42)
+ p.add_argument("--output", required=True)
+ p.add_argument("--image", default=None, help="i2v source image path")
+ return p.parse_args()
+
+
+def main() -> int:
+ args = parse_args()
+
+ repo_dir = Path(args.repo_dir).expanduser().resolve()
+ if not repo_dir.is_dir():
+ print(f"❌ Wan 2.2 repo not found at {repo_dir}", file=sys.stderr)
+ return 64
+ generate_py = repo_dir / "generate.py"
+ if not generate_py.exists():
+ print(f"❌ {generate_py} missing — upstream layout changed?", file=sys.stderr)
+ return 64
+
+ # Upstream caches weights under ~/.cache/huggingface/ on the first run.
+ # The --ckpt_dir convention in upstream's README points at a local
+ # snapshot, but `huggingface_hub.snapshot_download(model_repo)` resolves
+ # to the same canonical cache path either way.
+ print(f"STAGE:download-weights:{args.model_repo}", file=sys.stderr, flush=True)
+ try:
+ from huggingface_hub import snapshot_download
+ except Exception as err:
+ print(f"❌ huggingface_hub import failed: {err}", file=sys.stderr)
+ return 64
+ ckpt_dir = snapshot_download(args.model_repo)
+ print(f"🔧 wan22: weights ← {ckpt_dir}", file=sys.stderr)
+
+ upstream_args = [
+ sys.executable,
+ str(generate_py),
+ "--task", args.task,
+ "--size", f"{args.width}*{args.height}",
+ "--ckpt_dir", ckpt_dir,
+ "--prompt", args.prompt,
+ "--num_frames", str(args.num_frames),
+ "--sample_steps", str(args.steps),
+ "--sample_guide_scale", str(args.guidance),
+ "--base_seed", str(args.seed),
+ "--save_file", args.output,
+ ]
+ if args.image:
+ upstream_args.extend(["--image", args.image])
+
+ print(f"STAGE:inference", file=sys.stderr, flush=True)
+ print(f"🎬 wan22 generate task={args.task} {args.width}x{args.height} steps={args.steps} seed={args.seed}", file=sys.stderr)
+
+ # cwd = repo_dir so upstream's relative imports work. Forward stderr
+ # unchanged — upstream emits tqdm progress bars which local.js's
+ # handleLine() already parses for the percentage SSE event.
+ proc = subprocess.run(
+ upstream_args,
+ cwd=str(repo_dir),
+ env={**os.environ, "PYTHONUNBUFFERED": "1"},
+ )
+
+ if proc.returncode != 0:
+ print(f"❌ wan22 upstream exited {proc.returncode}", file=sys.stderr)
+ return proc.returncode
+
+ if not Path(args.output).exists():
+ print(f"❌ wan22 finished but {args.output} missing", file=sys.stderr)
+ return 1
+
+ print(f"✅ wan22 saved {args.output}", file=sys.stderr)
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/scripts/setup-image-video.sh b/scripts/setup-image-video.sh
index 153d2ce4d8..095e4ffdf8 100755
--- a/scripts/setup-image-video.sh
+++ b/scripts/setup-image-video.sh
@@ -145,6 +145,101 @@ if [[ "$INSTALL_LTX2" == "1" ]]; then
echo "✅ ltx-2-mlx venv ready: ${LTX2_PY}"
fi
+INSTALL_WAN22="${INSTALL_WAN22:-0}"
+if [[ "$INSTALL_WAN22" == "1" ]]; then
+ # osama-ata/Wan2.2-mlx — pure-MLX port of Alibaba's Wan 2.2 video model.
+ # MoE-A14B: 14B active params at inference, ~28 GB resident at bf16. The
+ # PortOS helper at scripts/generate_wan22.py subprocesses upstream's
+ # generate.py from the cloned repo, so PortOS releases own the arg
+ # translation layer (PortOS arg stability) while upstream owns the
+ # actual inference (upstream-tracked changes).
+ #
+ # EXPERIMENTAL — upstream CLI hasn't been pinned across releases; if a
+ # commit reshapes --task / --ckpt_dir, set `broken: true` on the
+ # wan22_* entries in data/media-models.json until generate_wan22.py is
+ # updated to match.
+ if ! have uv; then
+ echo "❌ INSTALL_WAN22=1 requires the 'uv' Python installer." >&2
+ echo " curl -LsSf https://astral.sh/uv/install.sh | sh" >&2
+ exit 1
+ fi
+ if ! have git; then
+ echo "❌ INSTALL_WAN22=1 requires git." >&2
+ exit 1
+ fi
+ WAN22_PIN="${WAN22_PIN:-main}"
+ WAN22_DIR="${HOME}/.portos/wan2.2-mlx"
+ WAN22_PY="${WAN22_DIR}/.venv/bin/python3"
+ mkdir -p "${HOME}/.portos"
+ if [[ ! -d "${WAN22_DIR}/.git" ]]; then
+ echo "📦 Cloning osama-ata/Wan2.2-mlx..."
+ git clone https://github.com/osama-ata/Wan2.2-mlx.git "${WAN22_DIR}"
+ else
+ echo "📦 Fetching Wan2.2-mlx updates..."
+ (cd "${WAN22_DIR}" && git fetch origin)
+ fi
+ (cd "${WAN22_DIR}" && git checkout --quiet "${WAN22_PIN}")
+ if [[ ! -x "${WAN22_PY}" ]]; then
+ echo "📦 Creating Wan2.2-mlx venv with Python 3.11..."
+ (cd "${WAN22_DIR}" && uv venv --python 3.11)
+ fi
+ # Upstream uses pyproject + requirements rather than a lockfile. Use
+ # `uv pip install -r requirements.txt` when present; otherwise `uv sync`
+ # falls back to the project config.
+ if [[ -f "${WAN22_DIR}/requirements.txt" ]]; then
+ echo "📦 Installing Wan2.2-mlx requirements..."
+ (cd "${WAN22_DIR}" && uv pip install -r requirements.txt)
+ else
+ echo "📦 Syncing Wan2.2-mlx packages..."
+ (cd "${WAN22_DIR}" && uv sync)
+ fi
+ echo "✅ Wan2.2-mlx venv ready: ${WAN22_PY}"
+fi
+
+INSTALL_HUNYUAN="${INSTALL_HUNYUAN:-0}"
+if [[ "$INSTALL_HUNYUAN" == "1" ]]; then
+ # gaurav-nelson/HunyuanVideo_MLX — community MLX port of Tencent's
+ # HunyuanVideo (13B). ~60 GB resident at bf16. Practical only with the
+ # 4-bit Gemma text encoder + everything else evicted (see the Memory
+ # Management panel under Settings → Local LLMs).
+ #
+ # EXPERIMENTAL — same caveat as Wan 2.2: upstream CLI isn't pinned. If
+ # sample_video.py args drift, flip `hunyuan_video` broken in
+ # data/media-models.json and update scripts/generate_hunyuan.py.
+ if ! have uv; then
+ echo "❌ INSTALL_HUNYUAN=1 requires the 'uv' Python installer." >&2
+ exit 1
+ fi
+ if ! have git; then
+ echo "❌ INSTALL_HUNYUAN=1 requires git." >&2
+ exit 1
+ fi
+ HUNYUAN_PIN="${HUNYUAN_PIN:-main}"
+ HUNYUAN_DIR="${HOME}/.portos/hunyuan-video-mlx"
+ HUNYUAN_PY="${HUNYUAN_DIR}/.venv/bin/python3"
+ mkdir -p "${HOME}/.portos"
+ if [[ ! -d "${HUNYUAN_DIR}/.git" ]]; then
+ echo "📦 Cloning gaurav-nelson/HunyuanVideo_MLX..."
+ git clone https://github.com/gaurav-nelson/HunyuanVideo_MLX.git "${HUNYUAN_DIR}"
+ else
+ echo "📦 Fetching HunyuanVideo_MLX updates..."
+ (cd "${HUNYUAN_DIR}" && git fetch origin)
+ fi
+ (cd "${HUNYUAN_DIR}" && git checkout --quiet "${HUNYUAN_PIN}")
+ if [[ ! -x "${HUNYUAN_PY}" ]]; then
+ echo "📦 Creating HunyuanVideo_MLX venv with Python 3.11..."
+ (cd "${HUNYUAN_DIR}" && uv venv --python 3.11)
+ fi
+ if [[ -f "${HUNYUAN_DIR}/requirements.txt" ]]; then
+ echo "📦 Installing HunyuanVideo_MLX requirements..."
+ (cd "${HUNYUAN_DIR}" && uv pip install -r requirements.txt)
+ else
+ echo "📦 Syncing HunyuanVideo_MLX packages..."
+ (cd "${HUNYUAN_DIR}" && uv sync)
+ fi
+ echo "✅ HunyuanVideo_MLX venv ready: ${HUNYUAN_PY}"
+fi
+
INSTALL_FLUX2="${INSTALL_FLUX2:-$(is_macos && echo 1 || echo 0)}"
if [[ "$INSTALL_FLUX2" == "1" ]]; then
diff --git a/server/services/videoGen/local.js b/server/services/videoGen/local.js
index 0b62d2f6d8..993c2d3a1b 100644
--- a/server/services/videoGen/local.js
+++ b/server/services/videoGen/local.js
@@ -32,6 +32,22 @@ import { findFfmpeg, safeUnder, generateThumbnail, optimizeForStreaming, upscale
const LTX2_VENV_PYTHON = join(homedir(), '.portos', 'ltx-2-mlx', '.venv', 'bin', 'python3');
const LTX2_HELPER_SCRIPT = join(PATHS.root, 'scripts', 'generate_ltx2.py');
+// Wan 2.2 MLX runtime — osama-ata/Wan2.2-mlx cloned at
+// ~/.portos/wan2.2-mlx/. The wrapper at scripts/generate_wan22.py
+// subprocesses upstream generate.py so PortOS releases don't drift from
+// upstream's CLI. Provisioned via `INSTALL_WAN22=1 bash scripts/setup-image-video.sh`.
+const WAN22_VENV_PYTHON = join(homedir(), '.portos', 'wan2.2-mlx', '.venv', 'bin', 'python3');
+const WAN22_HELPER_SCRIPT = join(PATHS.root, 'scripts', 'generate_wan22.py');
+const WAN22_REPO_DIR = join(homedir(), '.portos', 'wan2.2-mlx');
+
+// HunyuanVideo MLX runtime — gaurav-nelson/HunyuanVideo_MLX cloned at
+// ~/.portos/hunyuan-video-mlx/. ~60 GB resident at bf16 so practical only
+// with the 4-bit Gemma text encoder + everything else evicted. Provisioned
+// via `INSTALL_HUNYUAN=1 bash scripts/setup-image-video.sh`.
+const HUNYUAN_VENV_PYTHON = join(homedir(), '.portos', 'hunyuan-video-mlx', '.venv', 'bin', 'python3');
+const HUNYUAN_HELPER_SCRIPT = join(PATHS.root, 'scripts', 'generate_hunyuan.py');
+const HUNYUAN_REPO_DIR = join(homedir(), '.portos', 'hunyuan-video-mlx');
+
const execFileAsync = promisify(execFile);
const IS_WIN = process.platform === 'win32';
@@ -242,6 +258,60 @@ const buildLtx2Args = ({ model, prompt, negativePrompt, width, height, numFrames
return { bin: LTX2_VENV_PYTHON, args };
};
+// Build args for the Wan 2.2 MLX helper. The helper subprocesses upstream
+// `generate.py` from the cloned osama-ata/Wan2.2-mlx repo. The wrapper
+// translates PortOS's stable arg surface (prompt, output, image) into
+// upstream's --task / --size / --ckpt_dir form so PortOS releases don't
+// fight upstream CLI changes.
+const buildWan22Args = ({ model, prompt, width, height, numFrames, steps, guidance, seed, sourceImagePath, mode, outputPath }) => {
+ if (!existsSync(WAN22_VENV_PYTHON)) {
+ throw new ServerError(
+ `wan2.2-mlx venv not found at ${WAN22_VENV_PYTHON}. Run \`INSTALL_WAN22=1 bash scripts/setup-image-video.sh\` to install.`,
+ { status: 500, code: 'WAN22_VENV_MISSING' },
+ );
+ }
+ const args = [
+ WAN22_HELPER_SCRIPT,
+ '--repo-dir', WAN22_REPO_DIR,
+ '--task', model.mode === 'i2v' ? 'i2v-A14B' : 't2v-A14B',
+ '--model-repo', model.repo,
+ '--prompt', prompt,
+ '--width', String(width),
+ '--height', String(height),
+ '--num-frames', String(numFrames),
+ '--steps', String(steps),
+ '--guidance', String(guidance ?? 5.0),
+ '--seed', String(seed),
+ '--output', outputPath,
+ ];
+ if (mode === 'i2v' && sourceImagePath) args.push('--image', sourceImagePath);
+ return { bin: WAN22_VENV_PYTHON, args };
+};
+
+// Build args for the HunyuanVideo MLX helper. Mirror of the Wan 2.2 path.
+const buildHunyuanArgs = ({ model, prompt, width, height, numFrames, steps, guidance, seed, outputPath }) => {
+ if (!existsSync(HUNYUAN_VENV_PYTHON)) {
+ throw new ServerError(
+ `hunyuan-video-mlx venv not found at ${HUNYUAN_VENV_PYTHON}. Run \`INSTALL_HUNYUAN=1 bash scripts/setup-image-video.sh\` to install.`,
+ { status: 500, code: 'HUNYUAN_VENV_MISSING' },
+ );
+ }
+ const args = [
+ HUNYUAN_HELPER_SCRIPT,
+ '--repo-dir', HUNYUAN_REPO_DIR,
+ '--model-repo', model.repo,
+ '--prompt', prompt,
+ '--width', String(width),
+ '--height', String(height),
+ '--num-frames', String(numFrames),
+ '--steps', String(steps),
+ '--guidance', String(guidance ?? 6.0),
+ '--seed', String(seed),
+ '--output', outputPath,
+ ];
+ return { bin: HUNYUAN_VENV_PYTHON, args };
+};
+
const buildArgs = ({ pythonPath, modelId, model, prompt, negativePrompt, width, height, numFrames, fps, steps, guidance, seed, tiling, disableAudio, sourceImagePath, lastImagePath, keyframes, extendFromVideoPath, audioFilePath, mode, imageStrength, textEncoderRepo, outputPath }) => {
// Route to the dgrauet/ltx-2-mlx helper when the model declares the new
// runtime. Existing notapalindrome models default to runtime: 'mlx_video'
@@ -249,6 +319,12 @@ const buildArgs = ({ pythonPath, modelId, model, prompt, negativePrompt, width,
if (model.runtime === 'ltx2') {
return buildLtx2Args({ model, prompt, negativePrompt, width, height, numFrames, fps, steps, guidance, seed, sourceImagePath, lastImagePath, keyframes, extendFromVideoPath, audioFilePath, mode, imageStrength, disableAudio, outputPath, textEncoderRepo });
}
+ if (model.runtime === 'wan22') {
+ return buildWan22Args({ model, prompt, width, height, numFrames, steps, guidance, seed, sourceImagePath, mode, outputPath });
+ }
+ if (model.runtime === 'hunyuan') {
+ return buildHunyuanArgs({ model, prompt, width, height, numFrames, steps, guidance, seed, outputPath });
+ }
if (Array.isArray(keyframes) && keyframes.length >= 2) {
throw new ServerError(
'Multi-keyframe mode (keyframes array) is only supported on the ltx2 runtime. Pick a model with runtime: "ltx2" in data/media-models.json.',