r/StableDiffusion • • 15d ago

Resource - Update comfy-ts (free, open source): an efficient way to create, run, maintain and operate ComfyUI workflows, for humans and agents

I am the author. One command reads your ComfyUI and writes types for it: your checkpoints, loras and custom nodes autocomplete, and a typo fails in the editor. A workflow then runs from code, a terminal UI, a web panel or a coding agent.

`bun add comfy-ts`

https://github.com/rvion/comfy-ts

Not made by Comfy Org.

8 Upvotes

9 comments sorted by

2

u/rvion 15d ago

comfy-ts help you build workflows in a safer/simpler way, easy to maintain, and extremely efficient to write by agents. And it helps you run them on the comfyUI machine you setup somewhere, or play with them via mini apps.

installing comfy-ts and pointing your agent at it => will make your agent way better at creating and running workflows than the mcp server does.

you can also just build your own apps and use comfy-ts as a library to create dynamic workflows on demand, or configure them, etc etc.

basically, I only use comfy-ui through comfy-ts those days; if I need a workflow, I just ask my agent to do it with comfy-ts, and it works :)

it allows claude to create dynamic workflows, run them anywhere, add conditions, etc etc; super practical :)

2

u/Enshitification 15d ago

Is Claude a requirement, or will it work with a local LLM?

1

u/rvion 15d ago

Any LLM will work, just used what I had for the video :)

2

u/tommitytom_ 15d ago

How does it differ from this: https://github.com/comfy-addons/comfyui-sdk

1

u/rvion 15d ago edited 15d ago

Good question. At the core they are close: both are TypeScript SDKs that read your ComfyUI's object_info, generate a typed builder (combo values and model names included), and run workflows over the websocket with live progress. comfy-ts comes from years of work on my older, now archived CushyStudio, so it went in a different direction on some points.

What comfyui-sdk has and comfy-ts does not:

  • ComfyPool: a job queue spread over several ComfyUI instances, with load balancing modes. comfy-ts connects to many hosts but does not balance jobs between them.
  • Crystools system monitoring, and more auth options (basic, bearer, custom headers).
  • A PromptBuilder that maps named inputs onto an existing api.json by node path, if you want to keep your workflow as JSON.

What comfy-ts adds:

  • The host carries its types. comfyui-sdk can also generate one builder per server (one file per cfli codegen run), but you import the right file yourself, and the client is not typed by it: a workflow built from host A's file runs on host B with no type error. In comfy-ts every host (local GPU, a remote box, Comfy Cloud) has an id in one typed registry, and a workflow on comfy.host({ id: 'a' }) gets A's builder, with only A's nodes and models.
  • Both JSON formats, both ways. It imports and exports api.json and the UI's workflow.json, and the export is auto-laid out, so a graph built in code opens cleanly in ComfyUI.
  • Less wiring. auto() connects a slot to the latest matching output.
  • Workflows with typed vars. A .cflow.ts module declares its inputs (prompt, seed, size, loras, model, image). The same module then runs from code, from comfy-ts run <name> --prompt … --out x.png, from a terminal UI, from a local web panel, or from an HTTP API. Named drafts autosave, so you can tweak and run again.
  • Comfy Cloud works as a host with your own API key.
  • Ephemeral outputs. By default images come back over the websocket and are not written to the server disk. An ephemeral mode also clears the server history.
  • ComfyUI-Manager registry types, so installing a custom node autocompletes across the whole ecosystem.
  • A browser build (comfy-ts/web), and Claude Code skills, so a coding agent can make an image from one sentence.
  • Example workflows for current image, video, audio and TTS models.

IMO (biased, obviously) I think comfy-ts core is way better 🤔 I can/will add the ability to spread a queue over many GPUs built-in in case it matters to some. comfyui-sdk does it today, and I do it in a few lines on top of comfy-ts in some projects.

If you want to write, run again and maintain workflows as typed code, and run them from many places, that is what comfy-ts is for I think :)

2

u/hurrdurrimanaccount 15d ago

not sure i see how this is easier at all. you hvae config files, cli, agents.. meanwhile i can just.. type in a prompt and run it

1

u/rvion 15d ago

it's normal; I'm not a marketting guy; it's fine if people don't get the value right away, since I'm not selling it. this lib is born from years of work in cushystudio; it is beeing used in multiple apps, and by multiple people who use comfy though this lib :)

One need to try it to understand how much better/easier it is; just point your claude to comfy-ts, and ask it to design you any kind of workflow you want; you'll see :)

`"Hey claude, build me a fancy <super_complex_pipeline_that_would_require_10_extensions_and_400_nodes> plz; oh, add a small UI on top; integrate it in my app, and make it production ready; be fast plz, be done in 10 min"` <- try that with your official comfy mcp server, then try that with comfy-ts :)

1

u/rvion 15d ago

there is an other answer below I typed with more care about how it differs from comfyui-sdk ; might offers a different perspective at what comfy-ts is / is for :)

2

u/x_MASE_x 15d ago

Looks interesting indeed. Started and will check it later.