comfy-ts 2.18.1 → 2.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +147 -97
- package/claude-code/.claude-plugin/plugin.json +9 -0
- package/claude-code/skills/convert/SKILL.md +25 -0
- package/claude-code/skills/guide/SKILL.md +21 -0
- package/claude-code/skills/run/SKILL.md +12 -0
- package/claude-code/skills/setup/SKILL.md +15 -0
- package/claude-code/skills/workflow/SKILL.md +19 -0
- package/dist/{ServeApp-qXcQfdgT.js → ServeApp-B469W26E.js} +5 -5
- package/dist/{ServeApp-qXcQfdgT.js.map → ServeApp-B469W26E.js.map} +1 -1
- package/dist/cli.js +228 -11
- package/dist/cli.js.map +1 -1
- package/dist/{state-C067Kbew.js → exampleAssets-j1f26nGc.js} +177 -56
- package/dist/{state-C067Kbew.js.map → exampleAssets-j1f26nGc.js.map} +1 -1
- package/dist/{findDefinedWorkflow-0lG-VTEd.js → findDefinedWorkflow-B90-xFxX.js} +2 -2
- package/dist/{findDefinedWorkflow-0lG-VTEd.js.map → findDefinedWorkflow-B90-xFxX.js.map} +1 -1
- package/dist/index.cjs +92 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +92 -10
- package/dist/index.js.map +1 -1
- package/dist/{run-run-Zr699h2S.js → run-run-QEoh7Wbh.js} +5 -6
- package/dist/{run-run-Zr699h2S.js.map → run-run-QEoh7Wbh.js.map} +1 -1
- package/dist/{run-serve-DaXzoVTS.js → run-serve-CsEYPGm9.js} +4 -4
- package/dist/{run-serve-DaXzoVTS.js.map → run-serve-CsEYPGm9.js.map} +1 -1
- package/dist/{run-tui-CeM1GOJP.js → run-tui-YxiSoNvK.js} +9 -15
- package/dist/run-tui-YxiSoNvK.js.map +1 -0
- package/dist/{schemaDrift-CbsABBuk.js → schemaDrift-DaWsE-mt.js} +15 -15
- package/dist/{schemaDrift-CbsABBuk.js.map → schemaDrift-DaWsE-mt.js.map} +1 -1
- package/dist/web.d.ts +30 -20
- package/dist/web.js +83 -6
- package/dist/web.js.map +1 -1
- package/examples/README.md +17 -11
- package/examples/rvion/01-txt2img.cflow.ts +1 -1
- package/examples/rvion/02-img2img-upload.cflow.ts +1 -1
- package/examples/rvion/03-export-workflow-json.cflow.ts +1 -1
- package/examples/rvion/04-krea2-turbo-t2i.cflow.ts +1 -1
- package/examples/rvion/06-qwen-image-edit.cflow.ts +1 -1
- package/examples/rvion/07-local-llm-text-gen.cflow.ts +1 -1
- package/examples/rvion/08-qwen-image-21-t2i.cflow.ts +1 -1
- package/examples/rvion/09-qwen-image-21-edit.cflow.ts +1 -1
- package/examples/rvion/10-anima-t2i.cflow.ts +1 -1
- package/examples/rvion/11-yue2-t2a.cflow.ts +1 -1
- package/examples/rvion/12-stable-audio-3-t2a.cflow.ts +1 -1
- package/examples/rvion/13-ace-step-15-xl-t2a.cflow.ts +1 -1
- package/examples/rvion/14-video-soundtrack.cflow.ts +1 -1
- package/examples/rvion/15-tts-voice-clone.cflow.ts +1 -1
- package/examples/rvion/16-tts-voice-design.cflow.ts +1 -1
- package/guide-for-agents.md +8 -5
- package/package.json +8 -7
- package/src/cli/comfy-ts-cli.ts +12 -2
- package/src/cli/gen.ts +6 -1
- package/src/cli/serve/ServeApp.ts +4 -4
- package/src/cli/serve/web/api.ts +1 -1
- package/src/cli/skill.ts +207 -0
- package/src/cli/tui/components/Header.tsx +1 -4
- package/src/cli/tui/components/HostPanel.tsx +1 -4
- package/src/cli/tui/state/HostSt.ts +2 -2
- package/src/exampleAssets.ts +10 -4
- package/src/host/ComfyHost.ts +35 -5
- package/src/host/hostFile.ts +57 -0
- package/src/state.ts +15 -9
- package/dist/exampleAssets-BfWzygoM.js +0 -38
- package/dist/exampleAssets-BfWzygoM.js.map +0 -1
- package/dist/run-tui-CeM1GOJP.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
# comfy-ts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Write ComfyUI workflows in TypeScript, then run them from code, one command, a terminal, a browser or an agent.**
|
|
4
4
|
|
|
5
5
|
[](https://github.com/rvion/comfy-ts/actions/workflows/ci.yml) [](https://www.npmjs.com/package/comfy-ts) [](https://www.npmjs.com/package/comfy-ts) [](https://github.com/rvion/comfy-ts/releases) [](https://www.npmjs.com/package/comfy-ts) [](https://github.com/rvion/comfy-ts/blob/main/LICENSE) [](https://github.com/sponsors/rvion)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Types come from your own ComfyUI: every node and model it has autocompletes, and a wrong graph is a compile error. Run on your GPU, another machine or Comfy Cloud, and get the images, audio and video back in your code or as files. 73 ready workflows cover 43 model families, from SDXL to Wan video and ACE-Step songs.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
| 🔁 **JSON, both ways** | import and export `api.json` and `workflow.json`, drag your code onto the Comfy canvas |
|
|
9
|
+
| you want to | start here |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| build and run workflows in code, typed down to the model names of your exact machine | [the SDK](#-the-sdk-workflows-as-code), [the codegen](#-the-codegen-an-sdk-for-your-own-install) |
|
|
12
|
+
| tune a workflow with knobs, drafts, a queue and live latent previews in the terminal | [the TUI](#%EF%B8%8F-the-tui) |
|
|
13
|
+
| get the same workflows as a form in a browser, a phone included, with an LLM prompt refiner | [the web panel](#-the-web-panel) |
|
|
14
|
+
| generate from the command line, or let an AI agent generate for you | [the CLI](#%EF%B8%8F-the-cli), [for AI agents](#-for-ai-agents) |
|
|
15
|
+
| call your workflows over HTTP from a frontend, curl or n8n | [serve](#-serve-drafts-as-an-http-api) |
|
|
16
|
+
| run on Comfy Cloud or a rented GPU, with ready workflows for 43 model families | [hosts](#-hosts-local-lan-comfy-cloud-any-provider), [the model zoo](#the-model-zoo-73-cloud-workflows-43-model-families) |
|
|
17
|
+
| find and install the custom nodes and models a workflow needs, with typed names | [ComfyUI-Manager](#-custom-nodes-and-models-comfyui-manager) |
|
|
18
|
+
| keep client images off the server disk | [ephemeral outputs](#%EF%B8%8F-ephemeral-outputs-leave-no-traces) |
|
|
19
|
+
| move a graph between your code and the ComfyUI canvas, `api.json` and `workflow.json` | [JSON both ways](#-json-both-ways) |
|
|
21
20
|
|
|
22
21
|
## ⚡ 60 second start
|
|
23
22
|
|
|
@@ -47,7 +46,7 @@ const txt2img = host.defineWorkflow({
|
|
|
47
46
|
seed: 42, steps: 20, cfg: 7,
|
|
48
47
|
sampler_name: 'euler', scheduler: 'normal', denoise: 1,
|
|
49
48
|
})
|
|
50
|
-
// streams the image back over the websocket
|
|
49
|
+
// streams the image back over the websocket: nothing saved on the server
|
|
51
50
|
b.SaveImageWebsocket({ images: b.VAEDecode({ samples, vae: ckpt }) })
|
|
52
51
|
},
|
|
53
52
|
})
|
|
@@ -63,7 +62,7 @@ $ bun myFirstWorkflow.ts
|
|
|
63
62
|
.comfy-ts/outputs/txt2img_20260731-142012.png
|
|
64
63
|
```
|
|
65
64
|
|
|
66
|
-
Drop `save: true` and the outputs never touch a disk at all
|
|
65
|
+
Drop `save: true` and the outputs never touch a disk at all: `img.buffer` holds the bytes in memory ([ephemeral outputs](#%EF%B8%8F-ephemeral-outputs-leave-no-traces)).
|
|
67
66
|
|
|
68
67
|
One tsconfig line activates the generated types:
|
|
69
68
|
|
|
@@ -71,11 +70,11 @@ One tsconfig line activates the generated types:
|
|
|
71
70
|
{ "include": ["src", ".comfy-ts/hosts/**/sdk.d.ts"] }
|
|
72
71
|
```
|
|
73
72
|
|
|
74
|
-
No codegen yet? Everything still compiles on permissive base types,
|
|
73
|
+
No codegen yet? Everything still runs, and compiles on permissive base types (with `noUncheckedIndexedAccess` off), then sharpens the moment the generated sdk lands. Runs under Bun and node ≥ 20, dual ESM/CJS.
|
|
75
74
|
|
|
76
75
|
## 🧩 The SDK: workflows as code
|
|
77
76
|
|
|
78
|
-
|
|
77
|
+
A wrong workflow is a compile error, before ComfyUI ever sees the graph. The builder keeps type inference fast and asks for no ceremony, so a graph in code is quick to write and quick to change. The tricks:
|
|
79
78
|
|
|
80
79
|
- [Pass the node, skip the slot](#pass-the-node-skip-the-slot)
|
|
81
80
|
- [Nested or flat, your call](#nested-or-flat-your-call)
|
|
@@ -84,7 +83,7 @@ The best embedded DSL we know how to build, distilled from years of writing type
|
|
|
84
83
|
- [Content-addressed uploads](#content-addressed-uploads)
|
|
85
84
|
- [Problems, not crashes](#problems-not-crashes)
|
|
86
85
|
|
|
87
|
-
|
|
86
|
+
All of it rests on [the codegen](#-the-codegen-an-sdk-for-your-own-install) below.
|
|
88
87
|
|
|
89
88
|
### Pass the node, skip the slot
|
|
90
89
|
|
|
@@ -100,7 +99,7 @@ b.VAEDecode({ samples, vae: ckpt }) // same ckpt node, VAE outpu
|
|
|
100
99
|
|
|
101
100
|
### Nested or flat, your call
|
|
102
101
|
|
|
103
|
-
The same graph writes flat (a const per node) or nested (the code shaped like the graph). Mix freely
|
|
102
|
+
The same graph writes flat (a const per node) or nested (the code shaped like the graph). Mix them freely. Nested is often the practical form for small branches:
|
|
104
103
|
|
|
105
104
|
```ts
|
|
106
105
|
// flat
|
|
@@ -142,7 +141,7 @@ import { auto } from 'comfy-ts'
|
|
|
142
141
|
const samples = b.KSampler({ latent_image: auto() /* picks the latest LATENT producer */ })
|
|
143
142
|
```
|
|
144
143
|
|
|
145
|
-
Handy in quick scripts
|
|
144
|
+
Handy in quick scripts. Prefer explicit wiring in code meant to be read.
|
|
146
145
|
|
|
147
146
|
### Content-addressed uploads
|
|
148
147
|
|
|
@@ -160,15 +159,17 @@ build: async (b, vars, wf) => {
|
|
|
160
159
|
|
|
161
160
|
Invalid graphs accumulate precise messages in `workflow.problems` before ComfyUI ever sees them: missing required inputs, type mismatches, each named with the node and field.
|
|
162
161
|
|
|
163
|
-
## 🧬 The codegen:
|
|
162
|
+
## 🧬 The codegen: an SDK for your own install
|
|
164
163
|
|
|
165
|
-
|
|
164
|
+
This is not a ComfyUI type package that someone published once. One command reads YOUR host and writes a full SDK for it:
|
|
166
165
|
|
|
167
166
|
```bash
|
|
168
167
|
bunx comfy-ts gen --id my-gpu --host http://127.0.0.1:8188
|
|
169
|
-
# → .comfy-ts/hosts/my-gpu/{object_info.json, embeddings.json, sdk.d.ts}
|
|
168
|
+
# → .comfy-ts/hosts/my-gpu/{object_info.json, embeddings.json, sdk.d.ts, host.json}
|
|
170
169
|
```
|
|
171
170
|
|
|
171
|
+
`host.json` keeps the address, so your code names the host by its id alone and never writes a machine name: `comfy.host({ id: 'my-gpu' })`.
|
|
172
|
+
|
|
172
173
|
```ts
|
|
173
174
|
declare global {
|
|
174
175
|
namespace Comfy {
|
|
@@ -180,16 +181,17 @@ declare global {
|
|
|
180
181
|
}
|
|
181
182
|
```
|
|
182
183
|
|
|
183
|
-
- **Literal types from the actual install.** `ckpt_name` only accepts checkpoints that machine really has
|
|
184
|
+
- **Literal types from the actual install.** `ckpt_name` only accepts checkpoints that machine really has. Samplers, schedulers, loras and embeddings are unions of the real values.
|
|
184
185
|
- **Custom nodes are first-class.** Every installed pack lands in the builder: `b['rmbg.RMBG']` autocompletes like any core node.
|
|
186
|
+
- **New input kinds are typed.** A dynamic group input (ComfyUI 0.45, for example `LoadLoraModel.loras`) is a list of at least one row: `b.LoadLoraModel({ model, loras: [{ lora_name, strength }] })`.
|
|
185
187
|
- **One namespace per host, many hosts per codebase.** A workflow written against `my-gpu` cannot silently reference a model that only exists on `my-laptop`.
|
|
186
|
-
- **Never blocking.** Before the first codegen everything compiles on permissive base types,
|
|
187
|
-
- **Browsable.** The generated file is real TypeScript
|
|
188
|
-
- **See it for real: the Comfy Cloud catalog.** [`examples/comfy-cloud/sdk.d.ts`](examples/comfy-cloud/sdk.d.ts) is a full generated SDK for [Comfy Cloud](https://cloud.comfy.org) (
|
|
188
|
+
- **Never blocking.** Before the first codegen everything runs, and compiles on permissive base types (with `noUncheckedIndexedAccess` off), then sharpens the moment the generated sdk lands.
|
|
189
|
+
- **Browsable.** The generated file is real TypeScript. `bunx comfy-ts outline` shows it section by section.
|
|
190
|
+
- **See it for real: the Comfy Cloud catalog.** [`examples/comfy-cloud/sdk.d.ts`](examples/comfy-cloud/sdk.d.ts) is a full generated SDK for [Comfy Cloud](https://cloud.comfy.org) (7.4 MB, 3893 node types), committed so you can browse it and typecheck graphs against it without any host. [`examples/rvion/05-comfy-cloud.cflow.ts`](examples/rvion/05-comfy-cloud.cflow.ts) runs against it live: `url` + `apiKey` host config, one env var, images back in seconds.
|
|
189
191
|
|
|
190
192
|
## 🎛️ App mode & vars: knobs on everything
|
|
191
193
|
|
|
192
|
-
Vars turn a workflow module into a small APP
|
|
194
|
+
Vars turn a workflow module into a small APP. Declare the tweakable parts once (`import { v } from 'comfy-ts'`), and `build` runs again with the current values on every `run()`. The TUI and the web panel render vars as their UI, scripts set them in code, drafts snapshot them. One module gives many setups, and you can run it again at any time, where a script runs once.
|
|
193
195
|
|
|
194
196
|
```ts
|
|
195
197
|
export const txt2img = host.defineWorkflow({
|
|
@@ -208,17 +210,18 @@ txt2img.vars.seed.randomize()
|
|
|
208
210
|
await txt2img.run({ log: true }) // fresh graph, fresh image
|
|
209
211
|
```
|
|
210
212
|
|
|
211
|
-
| var kind |
|
|
213
|
+
| var kind | what it does |
|
|
212
214
|
| ----------------------- | --------------------------------------------------------------------------------- |
|
|
213
215
|
| `v.seed` | mode + number (`+ N` `- N` `= N` `? N`), advances itself: queued runs differ. `v.seed(42, { mode: '+' })` declares the mode |
|
|
214
216
|
| `v.prompt` | structured text: `//` comments stripped, `- ` lines become the negative prompt |
|
|
215
217
|
| `v.loras` | RegExp resolved against the host's REAL lora list, fully typed, multi-select |
|
|
216
|
-
| `v.
|
|
217
|
-
| `v.
|
|
218
|
+
| `v.model` | `v.model('UNETLoader.unet_name', { default, filter })`: a choice over the host's own file list for that loader input, typed as that slot's union |
|
|
219
|
+
| `v.image` | local image path, TUI picker attached. `exampleImagePath('bear_1024x1024.jpg')` defaults to a bundled sample |
|
|
220
|
+
| `v.audio` `v.video` | local audio or video path, same picker. `await myVar.loadInWorkflow(wf)` uploads it and returns the `LoadAudio` / `LoadVideo` node |
|
|
218
221
|
| `v.text` `v.int` `v.float` `v.toggle` `v.choice` `v.size` | the everyday knobs, ranges included |
|
|
219
222
|
| `presets` on `v.text` / `v.prompt` | named starting texts (`{ 'terse tags': '…' }`): a presets button in the web panel, `P` in the TUI. Picking one replaces the field. `promptEnhancerPresets()` offers your `.comfy-ts/prompt-enhancers/*.md` library as presets too |
|
|
220
223
|
|
|
221
|
-
`vars` can be a lambda
|
|
224
|
+
`vars` can be a lambda that receives `v`, so vars can reference each other: `v.prompt('a cozy house', { loraKeywordsFrom: loras })` prefixes the active loras' trigger keywords. `v.model` is available only in that lambda form. Name the file `*.cflow.ts` and the TUI finds it.
|
|
222
225
|
|
|
223
226
|
## 👀 Live previews: watch the image form
|
|
224
227
|
|
|
@@ -243,15 +246,15 @@ await host.fetchPreviewMethod() // 'auto' · 'none' = relaunch with --preview-me
|
|
|
243
246
|
|
|
244
247
|
## 🕶️ Ephemeral outputs: leave no traces
|
|
245
248
|
|
|
246
|
-
Some images
|
|
249
|
+
Some images must not outlive the run: client work, private subjects, anything you would not leave in a shared server's `output/` folder. ComfyUI has three image savers, and they differ exactly there:
|
|
247
250
|
|
|
248
251
|
| saver | where the image lands server-side | how long it stays |
|
|
249
252
|
| -------------------- | -------------------------------------------------- | ------------------------------ |
|
|
250
253
|
| `SaveImage` | `output/` dir, workflow JSON embedded in the PNG | forever (no delete API) |
|
|
251
254
|
| `PreviewImage` | `temp/` dir | until the server restarts |
|
|
252
|
-
| `SaveImageWebsocket` | nowhere
|
|
255
|
+
| `SaveImageWebsocket` | nowhere: streamed back as binary ws frames | never touches the server disk |
|
|
253
256
|
|
|
254
|
-
comfy-ts treats `SaveImageWebsocket` as a first-class output: its frames land in `execution.images` like any other output, and **local saving is opt-in
|
|
257
|
+
comfy-ts treats `SaveImageWebsocket` as a first-class output: its frames land in `execution.images` like any other output, and **local saving is opt-in**. Without `save`, the images exist only in memory (`img.buffer`, `img.getAsBlob()`, `img.getBase64Url()`; `img.absPath` is null):
|
|
255
258
|
|
|
256
259
|
```ts
|
|
257
260
|
// zero disk, end to end: nothing on the server, nothing locally
|
|
@@ -262,7 +265,7 @@ const bytes = execution.images[0]?.buffer
|
|
|
262
265
|
await txt2img.run({ log: true, save: { prefix: 'my-project' } })
|
|
263
266
|
```
|
|
264
267
|
|
|
265
|
-
Every combination is a valid choice
|
|
268
|
+
Every combination is a valid choice: you pick where the image lives. `execution.images` works in all four (the bytes always stream to memory):
|
|
266
269
|
|
|
267
270
|
| graph saver | `save` option | server disk | local disk |
|
|
268
271
|
| -------------------- | ------------- | ----------- | ---------- |
|
|
@@ -271,9 +274,9 @@ Every combination is a valid choice — you pick where the image lives. `executi
|
|
|
271
274
|
| `SaveImageWebsocket` | none | no | no |
|
|
272
275
|
| `SaveImageWebsocket` | `save: …` | no | yes |
|
|
273
276
|
|
|
274
|
-
Running comfy-ts on the same machine as ComfyUI? Then row one is the best of both worlds: `SaveImage` with no `save:` writes the file exactly once, by the server, and it is already local
|
|
277
|
+
Running comfy-ts on the same machine as ComfyUI? Then row one is the best of both worlds: `SaveImage` with no `save:` writes the file exactly once, by the server, and it is already local. Read it straight from ComfyUI's own `output/` folder.
|
|
275
278
|
|
|
276
|
-
Running an imported workflow or template that uses `SaveImage`? `ephemeral: true` rewrites its save nodes to `SaveImageWebsocket` in the sent prompt (the graph you authored stays untouched) and deletes the run's server history entry afterwards
|
|
279
|
+
Running an imported workflow or template that uses `SaveImage`? `ephemeral: true` rewrites its save nodes to `SaveImageWebsocket` in the sent prompt (the graph you authored stays untouched) and deletes the run's server history entry afterwards, because the history holds your full workflow, prompts included:
|
|
277
280
|
|
|
278
281
|
```ts
|
|
279
282
|
await workflow.run({ ephemeral: true }) // implies scrubHistory: true
|
|
@@ -282,9 +285,9 @@ await host.clearHistory() // or wipe the server's whole history
|
|
|
282
285
|
|
|
283
286
|
Honest limits, so you can decide what to trust:
|
|
284
287
|
|
|
285
|
-
- **uploaded inputs persist**: `/upload/image` files stay in the server's `input/` dir (ComfyUI has no delete API). If the host has a base64 loader node installed (`ETN_LoadImageBase64` from comfyui-tooling-nodes, or ComfyUI-Easy-Use's `easy loadImageBase64`), `mediaImage.loadInWorkflow_viaBase64Node(wf)`
|
|
286
|
-
- **video
|
|
287
|
-
- **out of our reach**: server logs, RAM, crash dumps, reverse proxies, and a cloud provider's own retention policy. Ephemeral mode controls what the ComfyUI API persists
|
|
288
|
+
- **uploaded inputs persist**: `/upload/image` files stay in the server's `input/` dir (ComfyUI has no delete API). If the host has a base64 loader node installed (`ETN_LoadImageBase64` from comfyui-tooling-nodes, or ComfyUI-Easy-Use's `easy loadImageBase64`), `mediaImage.loadInWorkflow_viaBase64Node(wf)` puts the image inside the prompt instead: no server file, and `scrubHistory` erases the prompt after. Comfy Cloud ships neither, so cloud inputs currently must ride uploads.
|
|
289
|
+
- **video and audio have no websocket saver** upstream: `SaveVideo` / `SaveAudio*` outputs persist on the host.
|
|
290
|
+
- **out of our reach**: server logs, RAM, crash dumps, reverse proxies, and a cloud provider's own retention policy. Ephemeral mode controls what the ComfyUI API persists, nothing more, and we will not pretend otherwise.
|
|
288
291
|
|
|
289
292
|
Every image example in `examples/` uses `SaveImageWebsocket`.
|
|
290
293
|
|
|
@@ -296,7 +299,7 @@ Every image example in `examples/` uses `SaveImageWebsocket`.
|
|
|
296
299
|
bunx comfy-ts tui
|
|
297
300
|
```
|
|
298
301
|
|
|
299
|
-
No argument needed: it finds every `*.cflow.ts` under your project AND the examples bundled with the package, so the first launch is never empty. Pass a folder or a module to scan just that. Keyboard-first, a persistent keybar
|
|
302
|
+
No argument needed: it finds every `*.cflow.ts` under your project AND the examples bundled with the package, so the first launch is never empty. Pass a folder or a module to scan just that. Keyboard-first, with a persistent keybar that shows every available key.
|
|
300
303
|
|
|
301
304
|
| panel | what it does |
|
|
302
305
|
| ------------ | -------------------------------------------------------------------------------- |
|
|
@@ -311,18 +314,20 @@ No argument needed: it finds every `*.cflow.ts` under your project AND the examp
|
|
|
311
314
|
|
|
312
315
|
```bash
|
|
313
316
|
bunx comfy-ts gen --id my-gpu --host http://127.0.0.1:8188
|
|
314
|
-
# → .comfy-ts/hosts/my-gpu/{object_info.json, embeddings.json, sdk.d.ts}
|
|
317
|
+
# → .comfy-ts/hosts/my-gpu/{object_info.json, embeddings.json, sdk.d.ts, host.json}
|
|
315
318
|
|
|
316
|
-
bunx comfy-ts outline # what
|
|
319
|
+
bunx comfy-ts outline # what is inside that 2MB sdk.d.ts?
|
|
317
320
|
bunx comfy-ts loras # mirror your loras' names + trigger words (below)
|
|
318
321
|
bunx comfy-ts tui # your *.cflow.ts + bundled examples
|
|
319
322
|
bunx comfy-ts tui [dir | module] # scan just that
|
|
320
323
|
bunx comfy-ts serve [dir | module] # drafts as a local HTTP API (below)
|
|
321
|
-
bunx comfy-ts run anima-t2i --prompt "a knight in the rain" --out knight.png
|
|
324
|
+
bunx comfy-ts run 10-anima-t2i --prompt "a knight in the rain" --out knight.png
|
|
322
325
|
# one generation, headless: every var a flag
|
|
323
326
|
```
|
|
324
327
|
|
|
325
|
-
Any reachable host: the box under your desk or a GPU machine across the network, same command, same output.
|
|
328
|
+
Any reachable host works the same: the box under your desk or a GPU machine across the network, same command, same output.
|
|
329
|
+
|
|
330
|
+
`comfy-ts run` finds the module in your folder, then in the bundled examples, by its key or a unique part of it (`rvion/anima` narrows by folder). `--<var>-file` reads a text var from a file, `--draft <name>` starts from a saved draft, `--json` prints one line with every output path, and `comfy-ts run <name> --help` lists the vars.
|
|
326
331
|
|
|
327
332
|
### Loras with names, not file names
|
|
328
333
|
|
|
@@ -334,11 +339,11 @@ bunx comfy-ts loras --id my-gpu --host http://127.0.0.1:8188
|
|
|
334
339
|
bunx comfy-ts loras # refresh later: id and url are remembered
|
|
335
340
|
```
|
|
336
341
|
|
|
337
|
-
After that, in the TUI's loras overlay you can type `aurora ink` to find `styles\aurora-ink-v3.safetensors`, and a lora's civitai trigger words are prefixed onto your `v.prompt` automatically when it is active (⌃K still overrides any lora's keyword by hand). No extension, or no sync yet? Everything behaves as before
|
|
342
|
+
After that, in the TUI's loras overlay you can type `aurora ink` to find `styles\aurora-ink-v3.safetensors`, and a lora's civitai trigger words are prefixed onto your `v.prompt` automatically when it is active (⌃K still overrides any lora's keyword by hand). No extension, or no sync yet? Everything behaves as before: file names and hand-typed keywords.
|
|
338
343
|
|
|
339
|
-
##
|
|
344
|
+
## 🔗 Serve: drafts as an HTTP API
|
|
340
345
|
|
|
341
|
-
|
|
346
|
+
Tune a draft in the TUI, then make it callable by anything that speaks HTTP: a web frontend, curl, n8n, another service:
|
|
342
347
|
|
|
343
348
|
```bash
|
|
344
349
|
bunx comfy-ts serve # every *.cflow.ts under cwd, port 8288
|
|
@@ -347,9 +352,9 @@ bunx comfy-ts serve txt2img.cflow.ts # one workflow (routes shorten to /gener
|
|
|
347
352
|
bunx comfy-ts serve --port 9000 --host 0.0.0.0 # pick port / reach it from your phone or tailnet
|
|
348
353
|
```
|
|
349
354
|
|
|
350
|
-
Bound beyond localhost, the startup print lists every URL the box answers on (LAN and tailnet), so the web UI is one tap away on another device. There is no auth:
|
|
355
|
+
Bound beyond localhost, the startup print lists every URL the box answers on (LAN and tailnet), so the web UI is one tap away on another device. There is no auth: do this only on a network you trust. A browser page on any origin can call it, which is what lets `comfy-ts/web` use serve as its bridge. With no auth, that also means a page you visit can reach the API on your own machine. The launch screen says so every time.
|
|
351
356
|
|
|
352
|
-
Discover what
|
|
357
|
+
Discover what is served, the same info the startup print shows, as JSON:
|
|
353
358
|
|
|
354
359
|
```bash
|
|
355
360
|
curl http://127.0.0.1:8288/drafts # all workflows, their drafts, every var described
|
|
@@ -368,24 +373,24 @@ curl -X POST http://127.0.0.1:8288/generate/txt2img/moody \
|
|
|
368
373
|
-H 'accept: image/*' -d '{"seed": 42}' -o out.png # raw image bytes
|
|
369
374
|
```
|
|
370
375
|
|
|
371
|
-
Draft values are the defaults, the JSON body overrides per request, and every value is validated before anything is queued (wrong choice? the 400 lists the allowed ones). `GET /drafts`
|
|
376
|
+
Draft values are the defaults, the JSON body overrides them per request, and every value is validated before anything is queued (wrong choice? the 400 lists the allowed ones). `GET /drafts` describes every workflow, draft and var, enough for a frontend to render a form. `Accept: image/*` returns the image bytes directly. Drafts are read again on every request: keep the TUI open, tweak, and the next call uses the new values. Serve binds to localhost only unless you say otherwise (`--host`, `--port`).
|
|
372
377
|
|
|
373
378
|
## 🌐 The web panel
|
|
374
379
|
|
|
375
|
-
Open that same url in a **browser** and you get a full control panel
|
|
380
|
+
Open that same url in a **browser** and you get a full control panel: no frontend to write, nothing to build, no extra dependency.
|
|
376
381
|
|
|
377
|
-
- every var as its real control: prompt textarea (`//` comments, `- ` negative lines), sliders, seed mode buttons (`=` `+` `?`) with 🎲, size presets, image upload with preview, and a lora palette
|
|
378
|
-
- edits **autosave into the selected draft**, exactly like the TUI (the two stay in sync live)
|
|
379
|
-
- every click on generate **queues** another prompt
|
|
380
|
-
- live progress bar and latent preview while it runs, results in a gallery
|
|
381
|
-
- **works on a phone**: collapsible menu, everything touch-sized. `--host 0.0.0.0
|
|
382
|
-
- ✨ **prompt refiner** on every prompt var: rewrite the prompt with a thinking model,
|
|
382
|
+
- every var as its real control: prompt textarea (`//` comments, `- ` negative lines), sliders, seed mode buttons (`=` `+` `?`) with 🎲, size presets, image upload with preview, and a lora palette. A switch on each lora card pauses or resumes that lora in place, a click on the card opens what it is with per-lora model and clip strengths, and the rest of your loras show as a gallery of preview cards with human model names and trigger words from the [lora mirror](#loras-with-names-not-file-names)
|
|
383
|
+
- edits **autosave into the selected draft**, exactly like the TUI (the two stay in sync live). Duplicate or delete a draft from the header
|
|
384
|
+
- every click on generate **queues** another prompt. The queue lists them and drops any pending one
|
|
385
|
+
- live progress bar and latent preview while it runs, results in a gallery. Click any image for the lightbox (copy to clipboard, open, delete)
|
|
386
|
+
- **works on a phone**: collapsible menu, everything touch-sized. With `--host 0.0.0.0`, the startup print gives you the LAN and tailnet urls
|
|
387
|
+
- ✨ **prompt refiner** on every prompt var: rewrite the prompt with a thinking model, with the answer and the model's reasoning streamed, then apply it or not. Nothing touches your prompt until you say so. Cloud through **OpenRouter**, or a local model through **Open WebUI** (a local model's `<think>` block goes to the reasoning pane, never into your prompt). Your key stays in the browser and never reaches the serve process. The master prompts are markdown files in `.comfy-ts/prompt-enhancers/`, one per image model, editable from the panel or from your editor
|
|
383
388
|
|
|
384
|
-
The JSON api above is unchanged
|
|
389
|
+
The JSON api above is unchanged: the panel is one more client of it.
|
|
385
390
|
|
|
386
391
|
## 🕸️ In the browser: `comfy-ts/web`
|
|
387
392
|
|
|
388
|
-
The same library runs in a browser bundle
|
|
393
|
+
The same library runs in a browser bundle: define workflows, connect to a host, run, get bytes back, no server in between:
|
|
389
394
|
|
|
390
395
|
```ts
|
|
391
396
|
import { ComfyTS } from 'comfy-ts/web'
|
|
@@ -397,15 +402,18 @@ const wf = host.workflow()
|
|
|
397
402
|
// …build with wf.builder, run, then execution.images[0].getAsBlob()
|
|
398
403
|
```
|
|
399
404
|
|
|
400
|
-
Nothing touches disk: schema caches and outputs live in an in-memory store (pass `ComfyTS.create({ storage })` for your own backend). Types work the same as everywhere else
|
|
405
|
+
Nothing touches disk: schema caches and outputs live in an in-memory store (pass `ComfyTS.create({ storage })` for your own backend). Types work the same as everywhere else: include a generated `sdk.d.ts` in your tsconfig and every node autocompletes.
|
|
401
406
|
|
|
402
|
-
The honest support matrix: **local
|
|
407
|
+
The honest support matrix: **local and LAN hosts connect directly** when ComfyUI is started with `--enable-cors-header '*'` (browser websocket auth rides `?token=<api-key>`, because browsers cannot set upgrade headers). **Comfy Cloud sends no CORS headers today**, so cloud from a browser goes through `comfy-ts serve` as the bridge. Runnable page: `bun examples/web/serve.ts`.
|
|
403
408
|
|
|
404
409
|
## 🌍 Hosts: local, LAN, Comfy Cloud, any provider
|
|
405
410
|
|
|
406
|
-
Every Comfy
|
|
411
|
+
Every Comfy works through one identical API: same mechanism, same codegen, same typed SDK, same TUI, whatever answers the protocol:
|
|
407
412
|
|
|
408
413
|
```ts
|
|
414
|
+
// the address `comfy-ts gen --id my-gpu --host …` saved: code that names no machine
|
|
415
|
+
comfy.host({ id: 'my-gpu' })
|
|
416
|
+
|
|
409
417
|
// the box you are on
|
|
410
418
|
comfy.host({ id: 'local', host: '127.0.0.1', port: 8188 })
|
|
411
419
|
|
|
@@ -420,48 +428,83 @@ comfy.host({ id: 'runpod', url: 'https://xxxx-8188.proxy.runpod.net' })
|
|
|
420
428
|
comfy.host({ id: 'modal', url: 'https://you--comfy.modal.run', headers: { 'Modal-Key': '…', 'Modal-Secret': '…' } })
|
|
421
429
|
```
|
|
422
430
|
|
|
423
|
-
[Comfy Cloud](https://cloud.comfy.org) is first-class: the key rides `X-API-Key` on every request and the websocket, outputs download through the signed-url redirect, live latent previews stream into the TUI, and the whole cloud catalog ships as a committed, browsable SDK ([`examples/comfy-cloud/sdk.d.ts`](examples/comfy-cloud/sdk.d.ts)) with a
|
|
431
|
+
[Comfy Cloud](https://cloud.comfy.org) is first-class: the key rides `X-API-Key` on every request and on the websocket, outputs download through the signed-url redirect, live latent previews stream into the TUI, and the whole cloud catalog ships as a committed, browsable SDK ([`examples/comfy-cloud/sdk.d.ts`](examples/comfy-cloud/sdk.d.ts)) with a [model zoo of 73 ready workflows](#the-model-zoo-73-cloud-workflows-43-model-families) built against it. Cloud runs bill your own Comfy Cloud account.
|
|
424
432
|
|
|
425
|
-
Reaching a Comfy
|
|
433
|
+
Reaching a Comfy that runs on another one of your machines:
|
|
426
434
|
|
|
427
|
-
- **ssh tunnel**: `ssh -N -L 8188:127.0.0.1:8188 you@gpu-box`, then `host: '127.0.0.1', port: 8188` as if it were local (`ssh -R` does the reverse:
|
|
428
|
-
- **tailscale**: `tailscale serve 8188` on the box gives a stable https url for `url
|
|
429
|
-
- **cloudflared**: `cloudflared tunnel --url http://127.0.0.1:8188` prints a temporary public https url
|
|
435
|
+
- **ssh tunnel**: `ssh -N -L 8188:127.0.0.1:8188 you@gpu-box`, then `host: '127.0.0.1', port: 8188` as if it were local (`ssh -R` does the reverse: it exposes YOUR Comfy to the remote box).
|
|
436
|
+
- **tailscale**: `tailscale serve 8188` on the box gives a stable https url for `url:`. Plain tailnet hostnames work with `host:` too.
|
|
437
|
+
- **cloudflared**: `cloudflared tunnel --url http://127.0.0.1:8188` prints a temporary public https url. Paste it into `url:`.
|
|
430
438
|
|
|
431
|
-
## 🔌
|
|
439
|
+
## 🔌 Custom nodes and models: ComfyUI-Manager
|
|
432
440
|
|
|
433
|
-
The whole ComfyUI-Manager registry
|
|
441
|
+
The whole ComfyUI-Manager registry is mirrored into generated types: every known custom node pack, plugin title and model is a typed union. The generated files are committed, browsable TypeScript:
|
|
434
442
|
|
|
435
443
|
- [`KnownComfyCustomNodeName`](src/manager/generated/KnownComfyCustomNodeName.ts): every node name of every known pack
|
|
436
444
|
- [`KnownComfyPluginTitle`](src/manager/generated/KnownComfyPluginTitle.ts) / [`KnownComfyPluginURL`](src/manager/generated/KnownComfyPluginURL.ts): the whole custom-node ecosystem as literal types
|
|
437
445
|
- [`KnownModel_Name`](src/manager/generated/KnownModel_Name.ts) and its [`Base` / `Type` / `FileName` / `SavePath`](src/manager/generated/) siblings: every model the registry knows, down to where it installs
|
|
438
446
|
|
|
447
|
+
A script (or an agent) can read what a workflow needs, see what the host is missing, and install it by name, with the compiler checking the spelling:
|
|
448
|
+
|
|
439
449
|
```ts
|
|
440
|
-
|
|
441
|
-
|
|
450
|
+
import type { Requirements } from 'comfy-ts'
|
|
451
|
+
|
|
452
|
+
const needs: Requirements[] = [
|
|
453
|
+
{ type: 'customNodesByTitle', title: 'ComfyUI Impact Pack' }, // autocompletes across the ecosystem
|
|
454
|
+
{ type: 'modelInManager', modelName: 'TAEF1 Decoder' },
|
|
455
|
+
]
|
|
456
|
+
await host.manager.fetchPluginsAndModels() // what the host has installed
|
|
457
|
+
const { missing, undecided } = host.checkRequirements(needs)
|
|
458
|
+
|
|
459
|
+
await host.installCustomNodeByTitle('ComfyUI Impact Pack') // true only for a verified install
|
|
460
|
+
const model = host.manager.registry.knownModels.get('TAEF1 Decoder')
|
|
461
|
+
if (model) await host.manager.installModelOutcome(model) // 'installed' | 'failed' | 'unknown'
|
|
442
462
|
```
|
|
443
463
|
|
|
444
|
-
|
|
464
|
+
- **Every Manager generation.** Installs go through the Manager's install queue on the legacy custom node Manager (V3.x) and on the pip Manager 4.x, with its default UI or its legacy UI. `await host.manager.api()` says which one the host runs: `{ generation: 'v3' | 'v4-legacy-ui' | 'v4', version }`.
|
|
465
|
+
- **An install returns when it is done.** It resolves after the Manager ran the install and the result is checked, so a large model can take minutes. `timing.installTimeoutMs` (default 1 hour) bounds the wait. A failed status request does not end it: the wait goes on until the host has not answered for `timing.pollGraceMs` (default 2 minutes).
|
|
466
|
+
- **Three outcomes.** `installModel` and `installPlugin` return `true` only for a verified install. `installModelOutcome` and `installPluginOutcome` also say `unknown` when the client lost sight of the task while the Manager can still be installing: fetch the lists again and read the status before you install again.
|
|
467
|
+
- **Missing or undecided.** `checkRequirements` returns `{ missing, undecided }`: queue installs for `missing` only. A pack or a model the host cannot decide has the status `unknown` in `getPluginStatus` and `getModelStatus`, and `isPluginInstalled` / `isModelInstalled` are `true` only for a known install. `host.matchRequirements` is `false` only when a requirement is known to be missing.
|
|
468
|
+
- **The Manager 4.x default UI serves no lists.** There the plugin and model view is built from what the host has installed and the bundled registry, and `update-available` is never reported.
|
|
469
|
+
- **A refusal says why.** A refused install logs the route and what the host said. A refusal by the Manager 4.x security policy names the settings it wants.
|
|
445
470
|
|
|
446
471
|
## 🤖 For AI agents
|
|
447
472
|
|
|
448
|
-
comfy-ts is built to be driven by agents as much as by people. After
|
|
473
|
+
comfy-ts is built to be driven by agents as much as by people. After you install it, one line in your `CLAUDE.md` teaches your agent the whole library:
|
|
449
474
|
|
|
450
475
|
```
|
|
451
476
|
@./node_modules/comfy-ts/guide-for-agents.md
|
|
452
477
|
```
|
|
453
478
|
|
|
479
|
+
An agent then generates with one command and reads the output paths from one line of JSON: `bunx comfy-ts run <module> --<var> <value> --out <path> --json` ([the CLI](#%EF%B8%8F-the-cli)).
|
|
480
|
+
|
|
481
|
+
For Claude Code, comfy-ts also ships slash commands: set up a host, write a workflow, convert a ComfyUI JSON, run a generation. Install them into your project from the package:
|
|
482
|
+
|
|
483
|
+
```bash
|
|
484
|
+
bunx comfy-ts skill install # /comfy-ts-setup, /comfy-ts-workflow, /comfy-ts-convert, /comfy-ts-run, /comfy-ts-guide
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
Or, with no npm install, as a Claude Code plugin (in a Claude Code session):
|
|
488
|
+
|
|
489
|
+
```
|
|
490
|
+
/plugin marketplace add rvion/comfy-ts
|
|
491
|
+
/plugin install comfy-ts@comfy-ts
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
Both carry the same skills, which read the guide above from the installed package. A rerun of `skill install` after an upgrade updates them and never overwrites a skill file you edited (`--force` does).
|
|
495
|
+
|
|
454
496
|
## 🔁 JSON, both ways
|
|
455
497
|
|
|
456
498
|
- `workflow.toApiJson()`: the executable prompt format.
|
|
457
|
-
- `await workflow.toWorkflowJson()`: an AUTOLAYOUTED litegraph file. Drop it on the ComfyUI canvas and see the graph you wrote in code, readably laid out.
|
|
458
|
-
- `host.importApiJson` / `host.importWorkflowJson`: both directions, covered by round-trip tests.
|
|
499
|
+
- `await workflow.toWorkflowJson()`: an AUTOLAYOUTED litegraph file. Drop it on the ComfyUI canvas and see the graph you wrote in code, readably laid out. Dynamic combos, dynamic group inputs, autogrow inputs and widgets fed by a link export the way the editor saves them.
|
|
500
|
+
- `host.importApiJson` / `host.importWorkflowJson`: both directions, covered by round-trip tests. Subgraphs are expanded into plain nodes on import, so a re-export is flat. A subgraph that contains itself fails with a `subgraph-cycle` error, and nested subgraphs that expand past 100,000 nodes fail with `subgraph-too-large`.
|
|
501
|
+
- Newer editor features are the compat frontier: every official Comfy-Org template and blueprint (about 1,000 files) is swept against our schemas to find the gaps.
|
|
459
502
|
|
|
460
503
|
## 📚 Examples
|
|
461
504
|
|
|
462
|
-
Every example is a runnable `*.cflow.ts` module: run it with bun,
|
|
505
|
+
Every example is a runnable `*.cflow.ts` module: run it with bun, with `bunx comfy-ts run <name>`, or browse them all with `bunx comfy-ts tui`.
|
|
463
506
|
|
|
464
|
-
Start with the didactic sequence in [`examples/rvion/`](examples/rvion/):
|
|
507
|
+
Start with the didactic sequence in [`examples/rvion/`](examples/rvion/). These name their host by id only, `comfy.host({ id: 'windows-1' })`: run `bunx comfy-ts gen --id windows-1 --host http://<your-comfy>:8188` once and they find yours. The models each one names must be on that host.
|
|
465
508
|
|
|
466
509
|
| example | shows |
|
|
467
510
|
| ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
|
|
@@ -471,28 +514,34 @@ Start with the didactic sequence in [`examples/rvion/`](examples/rvion/):
|
|
|
471
514
|
| [`04-krea2-turbo-t2i`](examples/rvion/04-krea2-turbo-t2i.cflow.ts) | a real pipeline: krea2 turbo, lora stack, RMBG cutout → transparent png |
|
|
472
515
|
| [`05-comfy-cloud`](examples/rvion/05-comfy-cloud.cflow.ts) | the same code on Comfy Cloud: `url` + `apiKey` host, typechecked against the committed catalog SDK |
|
|
473
516
|
| [`06-qwen-image-edit`](examples/rvion/06-qwen-image-edit.cflow.ts) | Qwen Image Edit 2511, lightning 4-step lora toggle |
|
|
474
|
-
| [`07-local-llm-text-gen`](examples/rvion/07-local-llm-text-gen.cflow.ts) | a local LLM through core `TextGenerate`, text back in `execution.text
|
|
517
|
+
| [`07-local-llm-text-gen`](examples/rvion/07-local-llm-text-gen.cflow.ts) | a local LLM through core `TextGenerate`, text back in `execution.text`. `--sweep` probes every text encoder on the host |
|
|
475
518
|
| [`08-qwen-image-21-t2i`](examples/rvion/08-qwen-image-21-t2i.cflow.ts) | Qwen Image 2.1 text to image: int8 model, Qwen3-VL 8b encoder |
|
|
476
519
|
| [`09-qwen-image-21-edit`](examples/rvion/09-qwen-image-21-edit.cflow.ts) | Qwen Image 2.1 edit: the reference image feeds an autogrow slot, output keeps its size; a remove-background preset |
|
|
477
520
|
| [`10-anima-t2i`](examples/rvion/10-anima-t2i.cflow.ts) | Anima text to image: turbo, aesthetic, base or base + turbo lora as one click, anima lora stack, optional RMBG cutout |
|
|
521
|
+
| [`11-yue2-t2a`](examples/rvion/11-yue2-t2a.cflow.ts) | YuE2 text to music: the first prompt line is the style, the rest the lyrics; ABC planning shows as a text result |
|
|
522
|
+
| [`12-stable-audio-3-t2a`](examples/rvion/12-stable-audio-3-t2a.cflow.ts) | Stable Audio 3 Medium: music, instruments, sound effects or one-shots from one description, an optional local LLM rewrite |
|
|
523
|
+
| [`13-ace-step-15-xl-t2a`](examples/rvion/13-ace-step-15-xl-t2a.cflow.ts) | ACE-Step 1.5 XL: a song with vocals from a caption and lyrics, turbo, sft or base model |
|
|
524
|
+
| [`14-video-soundtrack`](examples/rvion/14-video-soundtrack.cflow.ts) | a new soundtrack on a video: the frames of one file, the audio of another, core nodes only |
|
|
525
|
+
| [`15-tts-voice-clone`](examples/rvion/15-tts-voice-clone.cflow.ts) | text to speech in a cloned voice (TTS-Audio-Suite pack): five engines, a language, `execution.audios` |
|
|
526
|
+
| [`16-tts-voice-design`](examples/rvion/16-tts-voice-design.cflow.ts) | a new voice from a written description: the clip and its line are what example 15 takes |
|
|
478
527
|
|
|
479
|
-
### The model zoo:
|
|
528
|
+
### The model zoo: 73 cloud workflows, 43 model families
|
|
480
529
|
|
|
481
|
-
[`examples/comfy-cloud/`](examples/comfy-cloud/) holds one runnable example per family × mode (`<family>-<mode>.cflow.ts`), each transcribed from the official ComfyUI template of that model, typechecked against the committed cloud catalog, and runnable on [Comfy Cloud](https://cloud.comfy.org) with one env var (`COMFY_CLOUD_API_KEY`). Image, video and audio:
|
|
530
|
+
[`examples/comfy-cloud/`](examples/comfy-cloud/) holds one runnable example per family × mode (`<family>-<mode>.cflow.ts`), each transcribed from the official ComfyUI template of that model, typechecked against the committed cloud catalog, and runnable on [Comfy Cloud](https://cloud.comfy.org) with one env var (`COMFY_CLOUD_API_KEY`). Image, video and audio. `(+ name)` marks a variant file of the same family (`flux2-t2i-dev.cflow.ts`):
|
|
482
531
|
|
|
483
532
|
| mode | families |
|
|
484
533
|
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
485
|
-
| **t2i** text→image | sd15 (= example 05), sdxl, sd35, flux1, flux2, qwen-image, z-image, chroma, hidream, omnigen2, kandinsky5, capybara, krea2, lens, ernie, longcat, ovis, pixeldit, anima, newbie, ideogram4 |
|
|
486
|
-
| **i2i** image edit | flux1, flux2, qwen-image, hidream, omnigen2, capybara, longcat, boogu, firered
|
|
487
|
-
| **t2v** text→video | wan21, wan22, wan22-5b, ltxv, ltx25 (with sound), hunyuan-video, kandinsky5
|
|
488
|
-
| **i2v** image→video | wan21, wan22, ltxv, ltx25 (with sound), hunyuan-video, kandinsky5, capybara, svd
|
|
489
|
-
| **t2a** text→audio | ace-step (song), minimax-music3 (song), stable-audio (sfx/music), chatterbox (tts)
|
|
534
|
+
| **t2i** text→image | sd15 (= example 05), sdxl, sd35, flux1 (+ krea), flux2 (+ dev), qwen-image (+ 2512), z-image (+ base), chroma, hidream, hidream-o1, omnigen2, kandinsky5, capybara, krea2, lens, ernie (+ base), longcat, ovis, pixeldit, anima (+ base), newbie, ideogram4, boogu, mage-flow (+ turbo), minimax-h3, netayume |
|
|
535
|
+
| **i2i** image edit | flux1, flux2 (+ dev), qwen-image (+ 2509), hidream, hidream-o1, omnigen2, capybara, longcat, boogu, firered, chronoedit, krea2 (style reference), mage-flow (+ turbo) |
|
|
536
|
+
| **t2v** text→video | wan21, wan22, wan22-5b, ltxv, ltx2, ltx23, ltx25 (with sound), hunyuan-video, kandinsky5 |
|
|
537
|
+
| **i2v** image→video | wan21, wan22, ltxv, ltx2, ltx23, ltx25 (with sound), hunyuan-video, kandinsky5, capybara, svd |
|
|
538
|
+
| **t2a** text→audio | ace-step (song), ace-step15 (song), minimax-music3 (song), stable-audio (sfx/music), stable-audio3 (sfx/music), chatterbox (tts) |
|
|
490
539
|
|
|
491
|
-
Every zoo file imports offline and headless (no key, no cache needed
|
|
540
|
+
Every zoo file imports offline and headless (no key, no cache needed: CI proves it), builds a validated graph, and doubles as a TUI app with typed knobs: prompt, seed, steps, size, input image, …
|
|
492
541
|
|
|
493
542
|
## 🗂️ The `.comfy-ts/` folder
|
|
494
543
|
|
|
495
|
-
One folder of local state per consumer repo: `hosts/` (schema dumps
|
|
544
|
+
One folder of local state per consumer repo: `hosts/` (schema dumps, the generated sdk and the saved address per host), `outputs/`, `drafts/`, TUI settings, lora keywords. Gitignore all of it. `hosts/` is a full dump of that machine's models and paths (~10MB), so a commit of it publishes your setup. In a PRIVATE repo, a commit of it is what buys you typed CI.
|
|
496
545
|
|
|
497
546
|
## ✅ Feature status
|
|
498
547
|
|
|
@@ -510,25 +559,26 @@ One folder of local state per consumer repo: `hosts/` (schema dumps + the genera
|
|
|
510
559
|
| export api.json + autolayouted workflow.json | ✅ |
|
|
511
560
|
| import api.json into a live workflow | ✅ |
|
|
512
561
|
| import workflow.json (litegraph → api conversion) | ✅ |
|
|
513
|
-
| sidekick CLI (`gen`, `outline`, `tui`, `serve`)
|
|
562
|
+
| sidekick CLI (`gen`, `outline`, `loras`, `tui`, `serve`) | ✅ |
|
|
563
|
+
| `comfy-ts run`: one headless generation, every var a flag | 🔶 |
|
|
514
564
|
| serve web panel: every var as a control, queue, gallery, phone | ✅ |
|
|
515
565
|
| prompt refiner in the panel (OpenRouter or local Open WebUI) | ✅ |
|
|
516
566
|
| cloud hosts: `url` + `X-API-Key` auth, Comfy Cloud ran live | ✅ |
|
|
517
567
|
| ComfyUI-Manager registry mirror + Known\* ecosystem unions | ✅ |
|
|
518
|
-
| install custom nodes / models
|
|
568
|
+
| install custom nodes / models through the ComfyUI-Manager queue (V3.x, 4.x) | 🔶 |
|
|
519
569
|
| content-addressed local asset cache | 🔶 |
|
|
520
570
|
|
|
521
571
|
✅ working and exercised · 🔶 partial / in progress
|
|
522
572
|
|
|
523
|
-
## 🧱 A
|
|
573
|
+
## 🧱 A library you can trust, made to last
|
|
524
574
|
|
|
525
|
-
The
|
|
575
|
+
The features above sit on boring foundations:
|
|
526
576
|
|
|
527
577
|
- **Strict TypeScript everywhere.** `strict` + `noUncheckedIndexedAccess`, no `any`, every remaining cast individually justified in a reviewed whitelist.
|
|
528
578
|
- **A hard CI gate on every commit.** Typecheck, zero-warning lint (a warning is fixed or the rule is disabled on purpose, never ignored), format check, import hygiene, the full headless test suite.
|
|
529
579
|
- **Runtime validation with arktype.** Wire messages and JSON formats are schema-validated. When ComfyUI drifts faster than the schemas, failures are logged loud, never swallowed.
|
|
530
580
|
- **Codegen you can regenerate, never hand-edit.** The SDK, the manager unions and the snapshot tests around them all rebuild from source data with one command each.
|
|
531
|
-
- **A compat grind loop, not compat hope.** The full official
|
|
581
|
+
- **A compat grind loop, not compat hope.** The full official corpus from Comfy-Org (about 1,000 templates and blueprints) is mirrored locally and swept against our schemas on demand, so an upstream format change surfaces as a failing report line, not as your broken pipeline.
|
|
532
582
|
- **Boring packaging.** Dual ESM/CJS, Bun and node ≥ 20, `src/` shipped in the tarball for go-to-definition.
|
|
533
583
|
|
|
534
584
|
## Related projects
|
|
@@ -539,8 +589,8 @@ The glitter above sits on boring foundations:
|
|
|
539
589
|
|
|
540
590
|
## Support
|
|
541
591
|
|
|
542
|
-
comfy-ts is free, MIT, and maintained for the long run. If it saves you time or powers something you sell, consider [sponsoring](https://github.com/sponsors/rvion)
|
|
592
|
+
comfy-ts is free, MIT, and maintained for the long run. If it saves you time or powers something you sell, consider [sponsoring](https://github.com/sponsors/rvion): it keeps the grind loops grinding.
|
|
543
593
|
|
|
544
594
|
## License
|
|
545
595
|
|
|
546
|
-
MIT © [
|
|
596
|
+
MIT © [rvion](https://github.com/rvion)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "comfy-ts",
|
|
3
|
+
"description": "Claude Code skills for comfy-ts, the typed TypeScript SDK for ComfyUI: set up a host, write a workflow, convert a ComfyUI JSON, run a generation",
|
|
4
|
+
"author": { "name": "rvion", "url": "https://github.com/rvion" },
|
|
5
|
+
"homepage": "https://github.com/rvion/comfy-ts",
|
|
6
|
+
"repository": "https://github.com/rvion/comfy-ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"keywords": ["comfyui", "typescript", "sdk", "workflow", "generative-ai"]
|
|
9
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Convert a ComfyUI workflow JSON (a saved workflow.json, an exported api.json, an official template) into a typed comfy-ts workflow module (*.cflow.ts). Use when the user has a ComfyUI JSON and wants it as TypeScript.
|
|
3
|
+
argument-hint: "[workflow.json] [module-name]"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Convert this ComfyUI JSON into a comfy-ts module: $ARGUMENTS
|
|
7
|
+
|
|
8
|
+
1. Read `node_modules/comfy-ts/guide-for-agents.md`: the module pattern, the var kinds, import and export. The conversion needs a host whose `.comfy-ts/hosts/<id>/sdk.d.ts` exists and whose nodes cover the JSON; without one, set the project up first.
|
|
9
|
+
2. Let comfy-ts read the JSON offline and print it in the prompt format. A JSON with a `nodes` array is a workflow.json; an object of `{ class_type, inputs }` entries is an api.json. Save this as a scratch `.ts` file in the project and run it with `bun`:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { ComfyTS } from 'comfy-ts'
|
|
13
|
+
const host = ComfyTS.create().host({ id: '<host-id>', url: '<host-url>' })
|
|
14
|
+
await host.loadSchemaFromCache()
|
|
15
|
+
const json = JSON.parse(await Bun.file('<input.json>').text())
|
|
16
|
+
const wf = 'nodes' in json ? host.importWorkflowJson(json) : host.importApiJson(json)
|
|
17
|
+
console.log(JSON.stringify(wf.toApiJson(), null, 1))
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
An error that names a node or a model the host lacks is the answer: report it, never guess around it.
|
|
21
|
+
3. Write `<module-name>.cflow.ts` from that prompt: one `b.<class_type>({ … })` call per node, producers first. A link `["<id>", <slot>]` becomes the producing node's output, `node.outputs.<name>` with the output name from the `OUT` block of `sdk.d.ts`. A literal input stays a value. Make vars of what a user tunes: prompt text, seed, size, steps, input media, the model files.
|
|
22
|
+
4. Check it as a new workflow is checked: the project typechecks, `bunx comfy-ts run ./<module-name>.cflow.ts --help` lists the vars, a dry build has empty `problems`. Then compare `(await m.default.build({ dry: true })).toApiJson()` with the converted prompt: every loader, encoder, sampler and saver node of the prompt is there.
|
|
23
|
+
5. Delete the scratch file.
|
|
24
|
+
|
|
25
|
+
Report the module path, its vars, and every node the conversion dropped, with the reason.
|