comfyui-mcp
Version:
Local-first, agent-native control plane for ComfyUI — MCP server + autonomous sidebar agent that drives your live graph in natural language on ANY LLM: Claude/ChatGPT/Gemini on your subscription (no API key), free local models via Ollama (fully offline),
41 lines • 2.07 kB
JavaScript
import { createWorkflow } from "./workflow-composer.js";
import { DefaultsManager } from "./defaults-manager.js";
import { ValidationError } from "../utils/errors.js";
import { assertSafeInputFilename } from "../utils/input-paths.js";
/**
* Build + enqueue an ESRGAN upscale workflow (UpscaleModelLoader →
* ImageUpscaleWithModel, with an optional downsample for scale=2). Resolves the
* upscale model from the arg, then defaults, then the first local upscale model,
* and throws an actionable error if none can be found.
*/
export async function upscaleImage(args, deps) {
if (!args.image || !args.image.trim()) {
throw new ValidationError("image is required — the filename of an image already in ComfyUI's input dir " +
"(upload it first with upload_image (action:\"image\"), or stage an output with upload_image (action:\"stage\")).");
}
assertSafeInputFilename(args.image, "image");
const scale = args.scale ?? 4;
if (scale !== 2 && scale !== 4) {
throw new ValidationError("scale must be 2 or 4.");
}
const resolved = DefaultsManager.apply(args.model !== undefined ? { upscale_model: args.model } : {});
let model = resolved.upscale_model ?? args.model;
if (!model) {
model = await deps.resolveUpscaleModel();
}
if (!model) {
throw new ValidationError("No upscale model specified or found in models/upscale_models/. Pass `model`, " +
"or download one, e.g. download_model url=" +
"https://huggingface.co/Aitrepreneur/FLX/resolve/main/4x-ClearRealityV1.pth " +
"target_subfolder=upscale_models. The anima/ernie packs also provide upscale " +
"models via apply_manifest.");
}
const workflow = createWorkflow("upscale", {
image_path: args.image,
upscale_model: model,
scale,
});
const { prompt_id, queue_remaining, rejectedOutputs } = await deps.enqueue(workflow);
return { prompt_id, queue_remaining, rejectedOutputs, model, scale };
}
//# sourceMappingURL=upscale-image.js.map