videogen/scripts/workflows/local-comfyui-backend.js
caelum0x d56639a594
Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

100 lines
8.9 KiB
JavaScript

export const meta = {
name: 'local-comfyui-wan-backend',
description: 'Make external/ComfyUI + Wan2.2-Fun + VideoX-Fun ACTUALLY USED: wire a local-ComfyUI render backend so wan_camera (and broll) can target a local/LAN ComfyUI server ($0-wallet path), not only remote comfyui-deploy. Build + fake-test here; GPU-run later.',
phases: [
{ title: 'Recon' },
{ title: 'Design' },
{ title: 'Build' },
{ title: 'Integrate' },
{ title: 'Review' },
],
}
const ROOT = '/Users/arhansubasi/videogen'
const API = `${ROOT}/apps/api/app`
const NOTE = `GOAL: the external/ model checkouts (ComfyUI, Wan2.2-Fun-A14B Control-Camera, VideoX-Fun) are currently reference-only — runtime hits REMOTE comfyui-deploy/RunPod. Make them USABLE LOCALLY: a render backend that submits the Wan camera workflow to a LOCAL/LAN ComfyUI server (native /prompt + /history + /view API). This is the $0-wallet local generation path. Build + fake-test here (inject HTTP, canned ComfyUI responses — NO GPU / no live server in this env); it runs for real on a GPU host. Additive; do not break the existing remote path.`
// ---------------------------------------------------------------- Recon
phase('Recon')
const RECON_SCHEMA = {
type: 'object', required: ['summary', 'key_symbols', 'integration_notes'],
properties: {
summary: { type: 'string' },
key_symbols: { type: 'array', items: { type: 'string' } },
integration_notes: { type: 'array', items: { type: 'string' } },
gotchas: { type: 'array', items: { type: 'string' } },
},
}
const recon = await parallel([
() => agent(
`Recon the render-backend contract (read-only): ${API}/services/render/backends/base.py + envelope.py (the async backend abstraction — submit/poll/output, IN_QUEUE/IN_PROGRESS/COMPLETED), and ${API}/domains/routing/providers/wan_camera.py (how it builds a comfyui-deploy run body + the CameraControlSpec it sends). Report the EXACT backend interface a new "local-comfyui" backend must implement and how wan_camera would target it. Read-only.`,
{ label: 'recon:backend', phase: 'Recon', schema: RECON_SCHEMA }),
() => agent(
`Recon the LOCAL ComfyUI API + the Wan camera workflow (read-only). Read ${ROOT}/external/ComfyUI (the server API: POST /prompt with a workflow graph, GET /history/{id}, GET /view for outputs, websocket progress) and ${ROOT}/external/VideoX-Fun (the Wan2.2-Fun Control-Camera pipeline/graph + camera_utils) and ${ROOT}/external/comfyui-deploy (the run-route shape wan_camera already mimics). Produce a spec for submitting a Wan camera-control workflow to a LOCAL ComfyUI server: the workflow JSON template, where the input image + CameraControlSpec (camera_pose, num_frames) inject, and how to poll history for the output video. ${NOTE} Read-only.`,
{ label: 'recon:comfy', phase: 'Recon', schema: RECON_SCHEMA }),
])
// ---------------------------------------------------------------- Design
phase('Design')
const DESIGN_SCHEMA = {
type: 'object', required: ['backend_files', 'workflow_template', 'config', 'test_plan'],
properties: {
backend_files: { type: 'array', items: { type: 'object', required: ['path', 'purpose'], properties: { path: { type: 'string' }, purpose: { type: 'string' } } } },
workflow_template: { type: 'string', description: 'where the pinned Wan camera ComfyUI workflow JSON lives + how inputs inject' },
config: { type: 'string', description: 'env/config to point at a local ComfyUI URL + enable the local backend' },
test_plan: { type: 'array', items: { type: 'string' } },
},
}
const design = await agent(
`Architect a local-ComfyUI render backend (additive). Recon:\nBACKEND: ${JSON.stringify(recon[0])}\nCOMFY: ${JSON.stringify(recon[1])}\n\n` +
`Design: (1) a new backend at apps/api/app/services/render/backends/local_comfyui.py implementing the async backend contract by POSTing a pinned Wan camera workflow to a local ComfyUI /prompt, polling /history, resolving the output video via /view. (2) A pinned Wan camera workflow JSON template (under apps/api/assets/workflows/) with injection points for input image + CameraControlSpec. (3) Config to select the local backend + set COMFYUI_LOCAL_URL, without breaking the remote comfyui-deploy path (both selectable). (4) How wan_camera routes to local when configured. Injectable HTTP transport for tests (fake ComfyUI /prompt + /history + /view). ${NOTE} Give file list + TDD plan.`,
{ label: 'design:local-comfy', phase: 'Design', effort: 'high', schema: DESIGN_SCHEMA })
log(`Design: ${design.backend_files.length} backend files`)
// ---------------------------------------------------------------- Build
phase('Build')
const built = await agent(
`Build the local-ComfyUI backend, TDD, in ${ROOT}. Files: ${JSON.stringify(design.backend_files)}. ${design.workflow_template}\n${NOTE}\n` +
`Implement the backend (submit workflow → poll history → resolve output) with an INJECTED HTTP transport (tests pass a fake emitting canned ComfyUI /prompt {prompt_id}, /history {outputs}, /view bytes — NEVER a live server/GPU). Add the pinned Wan camera workflow JSON + input injection. Wire config so wan_camera can select local vs remote. Tests first (RED→GREEN): workflow builds with injected image+CameraControlSpec; submit→poll→complete happy path; ComfyUI error/timeout handled; remote path still works when local disabled. Run: cd ${ROOT} && python -m pytest apps/api tests -k 'comfy or local_backend or wan_camera' -q. Report files + public symbols + honest note that live GPU execution was NOT run here.`,
{ label: 'build:local-comfy', phase: 'Build', effort: 'high', schema: {
type: 'object', required: ['files_written', 'tests_written', 'tests_pass', 'notes'],
properties: { files_written: { type: 'array', items: { type: 'string' } }, tests_written: { type: 'array', items: { type: 'string' } }, tests_pass: { type: 'boolean' }, notes: { type: 'string' } } } })
// ---------------------------------------------------------------- Integrate
phase('Integrate')
const integrated = await agent(
`Integrate the local-ComfyUI backend in ${ROOT}. Built: ${JSON.stringify(built.files_written)}. Register the backend in the render backend registry (mirror how remote backends register), ensure wan_camera can target it via config, and confirm the remote path is unaffected. Run: cd ${ROOT} && python -m pytest apps/api tests -k 'comfy or local_backend or wan_camera or render' -q. Fix wiring minimally; don't weaken tests. Note pre-existing unrelated failures separately. Report tests_pass + remaining issues.`,
{ label: 'integrate', phase: 'Integrate', effort: 'high', schema: {
type: 'object', required: ['registered', 'tests_pass', 'output_tail', 'remaining_issues'],
properties: { registered: { type: 'boolean' }, tests_pass: { type: 'boolean' }, output_tail: { type: 'string' }, remaining_issues: { type: 'array', items: { type: 'string' } } } } })
log(`Integrate: registered=${integrated.registered} tests_pass=${integrated.tests_pass}`)
// ---------------------------------------------------------------- Review
phase('Review')
const FINDINGS_SCHEMA = {
type: 'object', required: ['findings'],
properties: { findings: { type: 'array', items: {
type: 'object', required: ['severity', 'file', 'summary', 'fix'],
properties: { severity: { type: 'string', enum: ['critical', 'high', 'medium', 'low'] }, file: { type: 'string' }, line: { type: 'integer' }, summary: { type: 'string' }, fix: { type: 'string' } } } } },
}
const review = await agent(
`Adversarial review of the local-ComfyUI backend in ${ROOT} (${built.files_written.join(', ')}). Does it correctly implement the async envelope (no busy-wait, handles ComfyUI queue/exec errors, missing output, websocket-vs-poll)? Is the workflow JSON injection safe (no template breakage on odd CameraControlSpec)? Is the remote path truly preserved (both selectable)? Any network call not behind the injectable transport? Report real defects + failing scenario + minimal fix.`,
{ label: 'review', phase: 'Review', effort: 'high', schema: FINDINGS_SCHEMA })
const mustFix = (review.findings || []).filter(f => f.severity === 'critical' || f.severity === 'high')
let fixResult = { applied: [], note: 'none' }
if (mustFix.length > 0) {
fixResult = await agent(`Fix these CONFIRMED critical/high findings in ${ROOT}, minimal edits, don't weaken tests. Re-run the comfy/render tests. Report.\n${JSON.stringify(mustFix, null, 2)}`,
{ label: 'fix', phase: 'Review', effort: 'high', schema: { type: 'object', required: ['applied', 'note'], properties: { applied: { type: 'array', items: { type: 'string' } }, note: { type: 'string' } } } })
}
return {
task: 'Local ComfyUI/Wan render backend (external checkouts now wired)',
files_written: built.files_written,
registered: integrated.registered,
tests_pass: integrated.tests_pass,
critical_high_fixed: fixResult.applied,
remaining_issues: integrated.remaining_issues,
note: 'Fake-tested here; live Wan generation requires a GPU host running local ComfyUI.',
}