comfy-ts 2.0.0 → 2.2.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.
Files changed (47) hide show
  1. package/README.md +65 -225
  2. package/dist/{DefinedWorkflow-CqNE_kgR.js → DefinedWorkflow-CwHInZgn.js} +4 -3
  3. package/dist/DefinedWorkflow-CwHInZgn.js.map +1 -0
  4. package/dist/{DraftsSt-Da4DZUP7.js → DraftsSt-omWuBSej.js} +3 -4
  5. package/dist/DraftsSt-omWuBSej.js.map +1 -0
  6. package/dist/cli.js +3 -3
  7. package/dist/index.cjs +22 -5
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +12 -2
  10. package/dist/index.d.ts +12 -2
  11. package/dist/index.js +22 -5
  12. package/dist/index.js.map +1 -1
  13. package/dist/{run-serve-BqeXtf8P.js → run-serve-C1oo5ilG.js} +170 -126
  14. package/dist/run-serve-C1oo5ilG.js.map +1 -0
  15. package/dist/{run-tui-CiB7TbYv.js → run-tui-CuVst-nc.js} +298 -103
  16. package/dist/run-tui-CuVst-nc.js.map +1 -0
  17. package/dist/{state-C1g_B8zR.js → state-CvMt0W1-.js} +23 -7
  18. package/dist/state-CvMt0W1-.js.map +1 -0
  19. package/dist/web.d.ts +12 -2
  20. package/dist/web.js +22 -5
  21. package/dist/web.js.map +1 -1
  22. package/examples/README.md +6 -18
  23. package/examples/images/README.md +2 -6
  24. package/guide-for-agents.md +25 -84
  25. package/package.json +1 -1
  26. package/src/cli/serve/ServeApp.ts +17 -11
  27. package/src/cli/serve/applyVarPayload.ts +91 -71
  28. package/src/cli/serve/describeVar.ts +57 -28
  29. package/src/cli/tui/components/StatusBar.tsx +1 -0
  30. package/src/cli/tui/components/TextOverlay.tsx +7 -3
  31. package/src/cli/tui/components/TuiApp.tsx +4 -5
  32. package/src/cli/tui/components/VarsPanel.tsx +42 -4
  33. package/src/cli/tui/imageClipboard.ts +40 -0
  34. package/src/cli/tui/state/DraftsSt.ts +1 -2
  35. package/src/cli/tui/state/ExecSt.ts +146 -98
  36. package/src/cli/tui/state/PreviewSt.ts +12 -11
  37. package/src/cli/tui/state/SettingsSt.ts +13 -0
  38. package/src/cli/tui/state/TuiSt.ts +65 -11
  39. package/src/host/ComfyHost.ts +5 -1
  40. package/src/runner/ComfyExecution.ts +15 -7
  41. package/src/runner/outputPath.ts +11 -0
  42. package/src/vars/ComfyVars.ts +12 -2
  43. package/dist/DefinedWorkflow-CqNE_kgR.js.map +0 -1
  44. package/dist/DraftsSt-Da4DZUP7.js.map +0 -1
  45. package/dist/run-serve-BqeXtf8P.js.map +0 -1
  46. package/dist/run-tui-CiB7TbYv.js.map +0 -1
  47. package/dist/state-C1g_B8zR.js.map +0 -1
package/README.md CHANGED
@@ -2,34 +2,11 @@
2
2
 
3
3
  _the ultimate ComfyUI toolkit for TypeScript: `SDK` + `CLI` + `TUI` + agent guide_
4
4
 
5
- [![CI](https://github.com/rvion/comfy-ts/actions/workflows/ci.yml/badge.svg)](https://github.com/rvion/comfy-ts/actions/workflows/ci.yml)
6
- [![npm version](https://img.shields.io/npm/v/comfy-ts.svg)](https://www.npmjs.com/package/comfy-ts)
7
- [![npm downloads](https://img.shields.io/npm/dm/comfy-ts.svg)](https://www.npmjs.com/package/comfy-ts)
8
- [![GitHub release](https://img.shields.io/github/v/release/rvion/comfy-ts)](https://github.com/rvion/comfy-ts/releases)
9
- [![types](https://img.shields.io/npm/types/comfy-ts)](https://www.npmjs.com/package/comfy-ts)
10
- [![license](https://img.shields.io/npm/l/comfy-ts.svg)](https://github.com/rvion/comfy-ts/blob/main/LICENSE)
11
- [![sponsor](https://img.shields.io/github/sponsors/rvion?label=sponsor&logo=githubsponsors)](https://github.com/sponsors/rvion)
12
-
13
- **Everything ComfyUI, from TypeScript.** Build workflows in code with
14
- autocomplete on every node and model of your exact install. Run them on any
15
- host, from the box under your desk to a cloud GPU, and get the images
16
- straight back into your code. Drive them from a terminal UI with live
17
- latent previews. Let scripts and agents discover and install whatever the
18
- ecosystem offers. Import and export both ComfyUI JSON formats. One library,
19
- the whole pipeline.
20
-
21
- **Jump to:**
22
- [⚡ 60 second start](#-60-second-start) ·
23
- [🧩 SDK](#-the-sdk-workflows-as-code) ·
24
- [🧬 Codegen](#-the-codegen-nothing-else-comes-close) ·
25
- [🎛️ App mode & vars](#-app-mode--vars-knobs-on-everything) ·
26
- [🖥️ TUI](#-the-tui) ·
27
- [⌨️ CLI](#-the-cli) ·
28
- [🌍 Comfy Cloud & hosts](#-hosts-local-lan-comfy-cloud-any-provider) ·
29
- [🔌 Ecosystem](#-ecosystem-discovery-and-install) ·
30
- [🤖 Agents](#-for-ai-agents) ·
31
- [📚 Examples](#-examples) ·
32
- [🧱 Trust](#-a-lib-you-can-trust-made-to-last)
5
+ [![CI](https://github.com/rvion/comfy-ts/actions/workflows/ci.yml/badge.svg)](https://github.com/rvion/comfy-ts/actions/workflows/ci.yml) [![npm version](https://img.shields.io/npm/v/comfy-ts.svg)](https://www.npmjs.com/package/comfy-ts) [![npm downloads](https://img.shields.io/npm/dm/comfy-ts.svg)](https://www.npmjs.com/package/comfy-ts) [![GitHub release](https://img.shields.io/github/v/release/rvion/comfy-ts)](https://github.com/rvion/comfy-ts/releases) [![types](https://img.shields.io/npm/types/comfy-ts)](https://www.npmjs.com/package/comfy-ts) [![license](https://img.shields.io/npm/l/comfy-ts.svg)](https://github.com/rvion/comfy-ts/blob/main/LICENSE) [![sponsor](https://img.shields.io/github/sponsors/rvion?label=sponsor&logo=githubsponsors)](https://github.com/sponsors/rvion)
6
+
7
+ **Everything ComfyUI, from TypeScript.** Build workflows in code with autocomplete on every node and model of your exact install. Run them on any host, from the box under your desk to a cloud GPU, and get the images straight back into your code. Drive them from a terminal UI with live latent previews. Let scripts and agents discover and install whatever the ecosystem offers. Import and export both ComfyUI JSON formats. One library, the whole pipeline.
8
+
9
+ **Jump to:** [⚡ 60 second start](#-60-second-start) · [🧩 SDK](#-the-sdk-workflows-as-code) · [🧬 Codegen](#-the-codegen-nothing-else-comes-close) · [🎛️ App mode & vars](#-app-mode--vars-knobs-on-everything) · [🖥️ TUI](#-the-tui) · [⌨️ CLI](#-the-cli) · [🌍 Comfy Cloud & hosts](#-hosts-local-lan-comfy-cloud-any-provider) · [🔌 Ecosystem](#-ecosystem-discovery-and-install) · [🤖 Agents](#-for-ai-agents) · [📚 Examples](#-examples) · [🧱 Trust](#-a-lib-you-can-trust-made-to-last)
33
10
 
34
11
  ## What's inside
35
12
 
@@ -85,8 +62,7 @@ $ bun myFirstWorkflow.ts
85
62
  .comfy-ts/outputs/txt2img_20260731-142012.png
86
63
  ```
87
64
 
88
- Drop `save: true` and the outputs never touch a disk at all — `img.buffer`
89
- holds the bytes in memory ("Ephemeral outputs" below).
65
+ Drop `save: true` and the outputs never touch a disk at all — `img.buffer` holds the bytes in memory ("Ephemeral outputs" below).
90
66
 
91
67
  One tsconfig line activates the generated types:
92
68
 
@@ -94,17 +70,11 @@ One tsconfig line activates the generated types:
94
70
  { "include": ["src", ".comfy-ts/hosts/**/sdk.d.ts"] }
95
71
  ```
96
72
 
97
- No codegen yet? Everything still compiles on permissive base types, and
98
- sharpens the moment the generated sdk lands. Runs under Bun and node ≥ 20,
99
- dual ESM/CJS.
73
+ No codegen yet? Everything still compiles on permissive base types, and sharpens the moment the generated sdk lands. Runs under Bun and node ≥ 20, dual ESM/CJS.
100
74
 
101
75
  ## 🧩 The SDK: workflows as code
102
76
 
103
- The best embedded DSL we know how to build, distilled from years of writing
104
- typed DSLs in TypeScript. Fast inference, clever tricks, zero ceremony.
105
- Wrong workflow? Compile error, before ComfyUI ever sees the graph. Writing
106
- workflows in code gets so comfortable you may catch yourself experimenting
107
- here rather than in the visual editor. The tricks this section showcases:
77
+ The best embedded DSL we know how to build, distilled from years of writing typed DSLs in TypeScript. Fast inference, clever tricks, zero ceremony. Wrong workflow? Compile error, before ComfyUI ever sees the graph. Writing workflows in code gets so comfortable you may catch yourself experimenting here rather than in the visual editor. The tricks this section showcases:
108
78
 
109
79
  - [Pass the node, skip the slot](#pass-the-node-skip-the-slot)
110
80
  - [Nested or flat, your call](#nested-or-flat-your-call)
@@ -113,13 +83,11 @@ here rather than in the visual editor. The tricks this section showcases:
113
83
  - [Content-addressed uploads](#content-addressed-uploads)
114
84
  - [Problems, not crashes](#problems-not-crashes)
115
85
 
116
- Wondering how any of this can exist? It all rests on
117
- [the codegen](#-the-codegen-nothing-else-comes-close) below.
86
+ Wondering how any of this can exist? It all rests on [the codegen](#-the-codegen-nothing-else-comes-close) below.
118
87
 
119
88
  ### Pass the node, skip the slot
120
89
 
121
- When a node has exactly ONE output of the expected type, pass the node
122
- itself:
90
+ When a node has exactly ONE output of the expected type, pass the node itself:
123
91
 
124
92
  ```ts
125
93
  const ckpt = b.CheckpointLoaderSimple({ ckpt_name: 'SD1.5\\v1-5-pruned-emaonly.ckpt' })
@@ -127,14 +95,11 @@ const samples = b.KSampler({ model: ckpt /* … */ }) // instead of model: ckpt.
127
95
  b.VAEDecode({ samples, vae: ckpt }) // same ckpt node, VAE output this time
128
96
  ```
129
97
 
130
- `ckpt` carries one MODEL, one CLIP and one VAE output, so it slots into all
131
- three kinds of inputs directly, and refuses inputs it cannot feed.
98
+ `ckpt` carries one MODEL, one CLIP and one VAE output, so it slots into all three kinds of inputs directly, and refuses inputs it cannot feed.
132
99
 
133
100
  ### Nested or flat, your call
134
101
 
135
- The same graph writes flat (a const per node) or nested (the code shaped
136
- like the graph). Mix freely; nested is often the practical form for small
137
- branches:
102
+ The same graph writes flat (a const per node) or nested (the code shaped like the graph). Mix freely; nested is often the practical form for small branches:
138
103
 
139
104
  ```ts
140
105
  // flat
@@ -156,9 +121,7 @@ b.SaveImage({
156
121
 
157
122
  ### Lambda inputs: autocomplete only what fits
158
123
 
159
- Any input accepts a lambda. Its parameter is the builder NARROWED to the
160
- nodes able to produce the expected type, so autocomplete proposes only what
161
- can actually plug in:
124
+ Any input accepts a lambda. Its parameter is the builder NARROWED to the nodes able to produce the expected type, so autocomplete proposes only what can actually plug in:
162
125
 
163
126
  ```ts
164
127
  b.KSampler({
@@ -170,8 +133,7 @@ b.KSampler({
170
133
 
171
134
  ### auto(): let the graph wire itself
172
135
 
173
- Leave a slot blank and comfy-ts wires the most recent node producing the
174
- right type:
136
+ Leave a slot blank and comfy-ts wires the most recent node producing the right type:
175
137
 
176
138
  ```ts
177
139
  import { auto } from 'comfy-ts'
@@ -183,8 +145,7 @@ Handy in quick scripts; prefer explicit wiring in code meant to be read.
183
145
 
184
146
  ### Content-addressed uploads
185
147
 
186
- Uploads are hash-named and deduped against the host before any byte moves.
187
- Run the same img2img a hundred times, the input image travels once:
148
+ Uploads are hash-named and deduped against the host before any byte moves. Run the same img2img a hundred times, the input image travels once:
188
149
 
189
150
  ```ts
190
151
  build: async (b, vars, wf) => {
@@ -196,14 +157,11 @@ build: async (b, vars, wf) => {
196
157
 
197
158
  ### Problems, not crashes
198
159
 
199
- Invalid graphs accumulate precise messages in `workflow.problems` before
200
- ComfyUI ever sees them: missing required inputs, type mismatches, each named
201
- with the node and field.
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.
202
161
 
203
162
  ## 🧬 The codegen: nothing else comes close
204
163
 
205
- Not "a ComfyUI type package" someone published once. One command reads YOUR
206
- host and writes a full SDK for it:
164
+ Not "a ComfyUI type package" someone published once. One command reads YOUR host and writes a full SDK for it:
207
165
 
208
166
  ```bash
209
167
  bunx comfy-ts gen --id my-gpu --host http://127.0.0.1:8188
@@ -221,34 +179,16 @@ declare global {
221
179
  }
222
180
  ```
223
181
 
224
- - **Literal types from the actual install.** `ckpt_name` only accepts
225
- checkpoints that machine really has; samplers, schedulers, loras and
226
- embeddings are unions of the real values.
227
- - **Custom nodes are first-class.** Every installed pack lands in the
228
- builder: `b['rmbg.RMBG']` autocompletes like any core node.
229
- - **One namespace per host, many hosts per codebase.** A workflow written
230
- against `my-gpu` cannot silently reference a model that only exists on
231
- `my-laptop`.
232
- - **Never blocking.** Before the first codegen everything compiles on
233
- permissive base types, and sharpens the moment the generated sdk lands.
234
- - **Browsable.** The generated file is real TypeScript;
235
- `bunx comfy-ts outline` shows it section by section.
236
- - **See it for real: the Comfy Cloud catalog.**
237
- [`examples/comfy-cloud/sdk.d.ts`](examples/comfy-cloud/sdk.d.ts) is a full
238
- generated SDK for [Comfy Cloud](https://cloud.comfy.org) (5.9MB, 3574
239
- nodes), committed so you can browse it and typecheck graphs against it
240
- without any host.
241
- [`examples/rvion/05-comfy-cloud.cflow.ts`](examples/rvion/05-comfy-cloud.cflow.ts)
242
- runs against it live: `url` + `apiKey` host config, one env var, images
243
- back in seconds.
182
+ - **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.
183
+ - **Custom nodes are first-class.** Every installed pack lands in the builder: `b['rmbg.RMBG']` autocompletes like any core node.
184
+ - **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`.
185
+ - **Never blocking.** Before the first codegen everything compiles on permissive base types, and sharpens the moment the generated sdk lands.
186
+ - **Browsable.** The generated file is real TypeScript; `bunx comfy-ts outline` shows it section by section.
187
+ - **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) (5.9MB, 3574 nodes), 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.
244
188
 
245
189
  ## 🎛️ App mode & vars: knobs on everything
246
190
 
247
- Vars turn a workflow module into a small APP: declare the tweakable parts
248
- once (`import { v } from 'comfy-ts'`) and `build` re-executes with current
249
- values on every `run()`. The TUI renders vars as its UI, scripts set them
250
- programmatically, drafts snapshot them. One module, many setups, re-runnable
251
- forever instead of a one-shot script.
191
+ Vars turn a workflow module into a small APP: declare the tweakable parts once (`import { v } from 'comfy-ts'`) and `build` re-executes with current values on every `run()`. The TUI renders vars as its UI, scripts set them programmatically, drafts snapshot them. One module, many setups, re-runnable forever instead of a one-shot script.
252
192
 
253
193
  ```ts
254
194
  export const txt2img = host.defineWorkflow({
@@ -275,15 +215,11 @@ await txt2img.run({ log: true }) // fresh graph, fresh image
275
215
  | `v.image` | local image path, TUI picker attached; `exampleImagePath('bear_1024x1024.jpg')` defaults to a bundled sample |
276
216
  | `v.text` `v.int` `v.float` `v.toggle` `v.choice` `v.size` | the everyday knobs, ranges included |
277
217
 
278
- `vars` can be a lambda receiving `v` so vars reference each other:
279
- `v.prompt('a cozy house', { loraKeywordsFrom: loras })` prefixes the active
280
- loras' trigger keywords. Name the file `*.cflow.ts` and the TUI finds it.
218
+ `vars` can be a lambda receiving `v` so vars reference each other: `v.prompt('a cozy house', { loraKeywordsFrom: loras })` prefixes the active loras' trigger keywords. Name the file `*.cflow.ts` and the TUI finds it.
281
219
 
282
220
  ## 🕶️ Ephemeral outputs: leave no traces
283
221
 
284
- Some images should not outlive the run — client work, private subjects,
285
- anything you would not leave in a shared server's `output/` folder. ComfyUI
286
- has three image savers, and they differ exactly there:
222
+ Some images should 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:
287
223
 
288
224
  | saver | where the image lands server-side | how long it stays |
289
225
  | -------------------- | -------------------------------------------------- | ------------------------------ |
@@ -291,10 +227,7 @@ has three image savers, and they differ exactly there:
291
227
  | `PreviewImage` | `temp/` dir | until the server restarts |
292
228
  | `SaveImageWebsocket` | nowhere — streamed back as binary ws frames | never touches the server disk |
293
229
 
294
- comfy-ts treats `SaveImageWebsocket` as a first-class output: its frames land
295
- in `execution.images` like any other output, and **local saving is opt-in** —
296
- without `save`, the images exist only in memory (`img.buffer`, `img.getAsBlob()`,
297
- `img.getBase64Url()`; `img.absPath` is null):
230
+ 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):
298
231
 
299
232
  ```ts
300
233
  // zero disk, end to end: nothing on the server, nothing locally
@@ -305,8 +238,7 @@ const bytes = execution.images[0]?.buffer
305
238
  await txt2img.run({ log: true, save: { prefix: 'my-project' } })
306
239
  ```
307
240
 
308
- Every combination is a valid choice — you pick where the image lives.
309
- `execution.images` works in all four (the bytes always stream to memory):
241
+ Every combination is a valid choice — you pick where the image lives. `execution.images` works in all four (the bytes always stream to memory):
310
242
 
311
243
  | graph saver | `save` option | server disk | local disk |
312
244
  | -------------------- | ------------- | ----------- | ---------- |
@@ -315,15 +247,9 @@ Every combination is a valid choice — you pick where the image lives.
315
247
  | `SaveImageWebsocket` | none | no | no |
316
248
  | `SaveImageWebsocket` | `save: …` | no | yes |
317
249
 
318
- Running comfy-ts on the same machine as ComfyUI? Then row one is the best
319
- of both worlds: `SaveImage` with no `save:` writes the file exactly once,
320
- by the server, and it is already local — read it straight from ComfyUI's
321
- own `output/` folder.
250
+ 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.
322
251
 
323
- Running an imported workflow or template that uses `SaveImage`? `ephemeral:
324
- true` rewrites its save nodes to `SaveImageWebsocket` in the sent prompt (the
325
- graph you authored stays untouched) and deletes the run's server history entry
326
- afterwards — the history holds your full workflow, prompts included:
252
+ 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 — the history holds your full workflow, prompts included:
327
253
 
328
254
  ```ts
329
255
  await workflow.run({ ephemeral: true }) // implies scrubHistory: true
@@ -332,18 +258,9 @@ await host.clearHistory() // or wipe the server's whole history
332
258
 
333
259
  Honest limits, so you can decide what to trust:
334
260
 
335
- - **uploaded inputs persist**: `/upload/image` files stay in the server's
336
- `input/` dir (ComfyUI has no delete API). If the host has a base64 loader
337
- node installed (`ETN_LoadImageBase64` from comfyui-tooling-nodes, or
338
- ComfyUI-Easy-Use's `easy loadImageBase64`),
339
- `mediaImage.loadInWorkflow_viaBase64Node(wf)` inlines the image into the
340
- prompt instead — no server file, and `scrubHistory` erases the prompt after.
341
- Comfy Cloud ships neither, so cloud inputs currently must ride uploads.
342
- - **video/audio have no websocket saver** upstream: `SaveVideo` / `SaveAudio*`
343
- outputs persist on the host.
344
- - **out of our reach**: server logs, RAM, crash dumps, reverse proxies, and a
345
- cloud provider's own retention policy. Ephemeral mode controls what the
346
- ComfyUI API persists — nothing more, and we won't pretend otherwise.
261
+ - **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)` inlines the image into the prompt instead — no server file, and `scrubHistory` erases the prompt after. Comfy Cloud ships neither, so cloud inputs currently must ride uploads.
262
+ - **video/audio have no websocket saver** upstream: `SaveVideo` / `SaveAudio*` outputs persist on the host.
263
+ - **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 won't pretend otherwise.
347
264
 
348
265
  Every image example in `examples/` uses `SaveImageWebsocket`.
349
266
 
@@ -355,10 +272,7 @@ Every image example in `examples/` uses `SaveImageWebsocket`.
355
272
  bunx comfy-ts tui
356
273
  ```
357
274
 
358
- No argument needed: it finds every `*.cflow.ts` under your project AND the
359
- examples bundled with the package, so the first launch is never empty. Pass
360
- a folder or a module to scan just that. Keyboard-first, a persistent keybar
361
- showing every available key.
275
+ 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 showing every available key.
362
276
 
363
277
  | panel | what it does |
364
278
  | ------------ | -------------------------------------------------------------------------------- |
@@ -367,11 +281,7 @@ showing every available key.
367
281
  | **(p)review** | LIVE latent previews mid-run, then the final image, painted REAL on iTerm2/WezTerm/VS Code |
368
282
  | **(h)ost** | node/lora/embedding counts, live queue, re-codegen, restart Comfy, interrupt |
369
283
 
370
- `r` runs, `s` rerolls the seed and runs, `o` opens the output, `c`/`C` copy
371
- workflow.json / api.json. Press `r` mid-run and it QUEUES with the values as
372
- they are right now. Drafts autosave: reopening lands you where you left off.
373
- Image vars open a full picker: browse the disk, favorite folders, recent
374
- picks, live preview of the highlighted image in the preview panel.
284
+ `r` runs, `s` rerolls the seed and runs, `o` opens the output, `c`/`C` copy workflow.json / api.json. Press `r` mid-run and it QUEUES with the values as they are right now. Drafts autosave: reopening lands you where you left off. Image vars open a full picker: browse the disk, favorite folders, recent picks, live preview of the highlighted image in the preview panel.
375
285
 
376
286
  ## ⌨️ The CLI
377
287
 
@@ -385,13 +295,11 @@ bunx comfy-ts tui [dir | module] # scan just that
385
295
  bunx comfy-ts serve [dir | module] # drafts as a local HTTP API (below)
386
296
  ```
387
297
 
388
- Any reachable host: the box under your desk or a GPU machine across the
389
- network, same command, same output.
298
+ Any reachable host: the box under your desk or a GPU machine across the network, same command, same output.
390
299
 
391
300
  ## 🌐 Serve: drafts as an HTTP API
392
301
 
393
- Hand-tune a draft in the TUI, then make it callable by anything that speaks
394
- HTTP — a web frontend, curl, n8n, another service:
302
+ Hand-tune a draft in the TUI, then make it callable by anything that speaks HTTP — a web frontend, curl, n8n, another service:
395
303
 
396
304
  ```bash
397
305
  bunx comfy-ts serve # every *.cflow.ts under cwd, port 8288
@@ -419,18 +327,11 @@ curl -X POST http://127.0.0.1:8288/generate/txt2img/moody \
419
327
  -H 'accept: image/*' -d '{"seed": 42}' -o out.png # raw image bytes
420
328
  ```
421
329
 
422
- Draft values are the defaults, the JSON body overrides per request, and every
423
- value is validated before anything is queued (wrong choice? the 400 lists the
424
- allowed ones). `GET /drafts` self-describes every workflow, draft and var —
425
- enough for a frontend to render a form. `Accept: image/*` returns the image
426
- bytes directly (`curl … -H 'accept: image/*' -o out.png`). Drafts are
427
- re-read on every request: keep the TUI open, tweak, next call uses the new
428
- values. Binds to localhost only unless you say otherwise (`--bind`, `--port`).
330
+ 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` self-describes every workflow, draft and var — enough for a frontend to render a form. `Accept: image/*` returns the image bytes directly (`curl … -H 'accept: image/*' -o out.png`). Drafts are re-read on every request: keep the TUI open, tweak, next call uses the new values. Binds to localhost only unless you say otherwise (`--bind`, `--port`).
429
331
 
430
332
  ## 🕸️ In the browser: `comfy-ts/web`
431
333
 
432
- The same library runs in a browser bundle — define workflows, connect to a
433
- host, run, get bytes back, no server in between:
334
+ The same library runs in a browser bundle — define workflows, connect to a host, run, get bytes back, no server in between:
434
335
 
435
336
  ```ts
436
337
  import { ComfyTS } from 'comfy-ts/web'
@@ -442,21 +343,13 @@ const wf = host.workflow()
442
343
  // …build with wf.builder, run, then execution.images[0].getAsBlob()
443
344
  ```
444
345
 
445
- Nothing touches disk: schema caches and outputs live in an in-memory store
446
- (pass `ComfyTS.create({ storage })` for your own backend). Types work the
447
- same as everywhere else — include a generated `sdk.d.ts` in your tsconfig
448
- and every node autocompletes.
346
+ 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.
449
347
 
450
- The honest support matrix: **local/LAN hosts connect directly** when ComfyUI
451
- is started with `--enable-cors-header '*'` (browser websocket auth rides
452
- `?token=<api-key>` since browsers cannot set upgrade headers). **Comfy Cloud
453
- sends no CORS headers today**, so cloud from a browser goes through
454
- `comfy-ts serve` as the bridge. Runnable page: `bun examples/web/serve.ts`.
348
+ The honest support matrix: **local/LAN hosts connect directly** when ComfyUI is started with `--enable-cors-header '*'` (browser websocket auth rides `?token=<api-key>` since 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`.
455
349
 
456
350
  ## 🌍 Hosts: local, LAN, Comfy Cloud, any provider
457
351
 
458
- Every Comfy is supported, through one identical API. Same mechanism, same
459
- codegen, same typed SDK, same TUI, whatever answers the protocol:
352
+ Every Comfy is supported, through one identical API. Same mechanism, same codegen, same typed SDK, same TUI, whatever answers the protocol:
460
353
 
461
354
  ```ts
462
355
  // the box you are on
@@ -473,54 +366,32 @@ comfy.host({ id: 'runpod', url: 'https://xxxx-8188.proxy.runpod.net' })
473
366
  comfy.host({ id: 'modal', url: 'https://you--comfy.modal.run', headers: { 'Modal-Key': '…', 'Modal-Secret': '…' } })
474
367
  ```
475
368
 
476
- [Comfy Cloud](https://cloud.comfy.org) is first-class: the key rides
477
- `X-API-Key` on every request and the websocket, outputs download through the
478
- signed-url redirect, live latent previews stream into the TUI, and the whole
479
- cloud catalog ships as a committed, browsable SDK
480
- ([`examples/comfy-cloud/sdk.d.ts`](examples/comfy-cloud/sdk.d.ts)) with a
481
- whole [model zoo of 46 ready workflows](#the-model-zoo-46-cloud-workflows-32-model-families)
482
- built against it.
369
+ [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 whole [model zoo of 46 ready workflows](#the-model-zoo-46-cloud-workflows-32-model-families) built against it.
483
370
 
484
371
  Reaching a Comfy running on another one of your machines:
485
372
 
486
- - **ssh tunnel**: `ssh -N -L 8188:127.0.0.1:8188 you@gpu-box`, then
487
- `host: '127.0.0.1', port: 8188` as if it were local (`ssh -R` does the
488
- reverse: expose YOUR Comfy to the remote box).
489
- - **tailscale**: `tailscale serve 8188` on the box gives a stable https url
490
- for `url:`; plain tailnet hostnames work with `host:` too.
491
- - **cloudflared**: `cloudflared tunnel --url http://127.0.0.1:8188` prints a
492
- temporary public https url, paste it into `url:`.
373
+ - **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: expose YOUR Comfy to the remote box).
374
+ - **tailscale**: `tailscale serve 8188` on the box gives a stable https url for `url:`; plain tailnet hostnames work with `host:` too.
375
+ - **cloudflared**: `cloudflared tunnel --url http://127.0.0.1:8188` prints a temporary public https url, paste it into `url:`.
493
376
 
494
377
  ## 🔌 Ecosystem discovery and install
495
378
 
496
- The whole ComfyUI-Manager registry, mirrored into generated types: every
497
- known custom node pack, plugin title and model is a typed union. The
498
- generated files are committed, browsable TypeScript:
379
+ The whole ComfyUI-Manager registry, mirrored into generated types: every known custom node pack, plugin title and model is a typed union. The generated files are committed, browsable TypeScript:
499
380
 
500
- - [`KnownComfyCustomNodeName`](src/manager/generated/KnownComfyCustomNodeName.ts):
501
- every node name of every known pack
502
- - [`KnownComfyPluginTitle`](src/manager/generated/KnownComfyPluginTitle.ts) /
503
- [`KnownComfyPluginURL`](src/manager/generated/KnownComfyPluginURL.ts):
504
- the whole custom-node ecosystem as literal types
505
- - [`KnownModel_Name`](src/manager/generated/KnownModel_Name.ts) and its
506
- [`Base` / `Type` / `FileName` / `SavePath`](src/manager/generated/)
507
- siblings: every model the registry knows, down to where it installs
381
+ - [`KnownComfyCustomNodeName`](src/manager/generated/KnownComfyCustomNodeName.ts): every node name of every known pack
382
+ - [`KnownComfyPluginTitle`](src/manager/generated/KnownComfyPluginTitle.ts) / [`KnownComfyPluginURL`](src/manager/generated/KnownComfyPluginURL.ts): the whole custom-node ecosystem as literal types
383
+ - [`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
508
384
 
509
385
  ```ts
510
386
  await host.installCustomNodeByTitle('ComfyUI Impact Pack') // autocompletes across the ecosystem
511
387
  await host.manager.installModel(modelInfo)
512
388
  ```
513
389
 
514
- A script (or an agent) can look at a workflow, see what is missing, and
515
- install it by name with the compiler checking the spelling. Install
516
- endpoints currently target the Manager v2 API; v3 moved them behind a queue
517
- API and support is being ground down (see the feature table).
390
+ A script (or an agent) can look at a workflow, see what is missing, and install it by name with the compiler checking the spelling. Install endpoints currently target the Manager v2 API; v3 moved them behind a queue API and support is being ground down (see the feature table).
518
391
 
519
392
  ## 🤖 For AI agents
520
393
 
521
- comfy-ts is built to be driven by agents as much as by people. After
522
- installing, one line in your `CLAUDE.md` teaches your agent the whole
523
- library:
394
+ comfy-ts is built to be driven by agents as much as by people. After installing, one line in your `CLAUDE.md` teaches your agent the whole library:
524
395
 
525
396
  ```
526
397
  @./node_modules/comfy-ts/guide-for-agents.md
@@ -529,18 +400,12 @@ library:
529
400
  ## 🔁 JSON, both ways
530
401
 
531
402
  - `workflow.toApiJson()`: the executable prompt format.
532
- - `await workflow.toWorkflowJson()`: an AUTOLAYOUTED litegraph file. Drop it
533
- on the ComfyUI canvas and see the graph you wrote in code, readably laid
534
- out.
535
- - `host.importApiJson` / `host.importWorkflowJson`: both directions, covered
536
- by round-trip tests. Newer editor features (subgraphs) are the current
537
- compat frontier: we sweep every official Comfy-Org template against our
538
- schemas to grind that gap down.
403
+ - `await workflow.toWorkflowJson()`: an AUTOLAYOUTED litegraph file. Drop it on the ComfyUI canvas and see the graph you wrote in code, readably laid out.
404
+ - `host.importApiJson` / `host.importWorkflowJson`: both directions, covered by round-trip tests. Newer editor features (subgraphs) are the current compat frontier: we sweep every official Comfy-Org template against our schemas to grind that gap down.
539
405
 
540
406
  ## 📚 Examples
541
407
 
542
- Every example is a runnable `*.cflow.ts` module: run it with bun, or just
543
- `bunx comfy-ts tui` — the TUI finds them all.
408
+ Every example is a runnable `*.cflow.ts` module: run it with bun, or just `bunx comfy-ts tui` — the TUI finds them all.
544
409
 
545
410
  Start with the didactic sequence in [`examples/rvion/`](examples/rvion/):
546
411
 
@@ -555,11 +420,7 @@ Start with the didactic sequence in [`examples/rvion/`](examples/rvion/):
555
420
 
556
421
  ### The model zoo: 46 cloud workflows, 32 model families
557
422
 
558
- [`examples/comfy-cloud/`](examples/comfy-cloud/) holds one runnable example
559
- per family × mode (`<family>-<mode>.cflow.ts`), each transcribed from the
560
- official ComfyUI template of that model, typechecked against the committed
561
- cloud catalog, and runnable on [Comfy Cloud](https://cloud.comfy.org) with
562
- one env var (`COMFY_CLOUD_API_KEY`). Image, video and audio:
423
+ [`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:
563
424
 
564
425
  | mode | families |
565
426
  | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
@@ -569,17 +430,11 @@ one env var (`COMFY_CLOUD_API_KEY`). Image, video and audio:
569
430
  | **i2v** image→video | wan21, wan22, ltxv, hunyuan-video, kandinsky5, capybara, svd |
570
431
  | **t2a** text→audio | ace-step (song), stable-audio (sfx/music), chatterbox (tts) |
571
432
 
572
- Every zoo file imports offline and headless (no key, no cache needed — CI
573
- proves it), builds a validated graph, and doubles as a TUI app with typed
574
- knobs: prompt, seed, steps, size, input image, …
433
+ 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, …
575
434
 
576
435
  ## 🗂️ The `.comfy-ts/` folder
577
436
 
578
- One folder of local state per consumer repo: `hosts/` (schema dumps + the
579
- generated sdk per host), `outputs/`, `drafts/`, TUI settings, lora keywords.
580
- Gitignore all of it. `hosts/` is a full dump of that machine's models and
581
- paths (~10MB), so committing it publishes your setup; in a PRIVATE repo,
582
- committing it is what buys you typed CI.
437
+ One folder of local state per consumer repo: `hosts/` (schema dumps + the generated sdk 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 committing it publishes your setup; in a PRIVATE repo, committing it is what buys you typed CI.
583
438
 
584
439
  ## ✅ Feature status
585
440
 
@@ -609,24 +464,12 @@ committing it is what buys you typed CI.
609
464
 
610
465
  The glitter above sits on boring foundations:
611
466
 
612
- - **Strict TypeScript everywhere.** `strict` + `noUncheckedIndexedAccess`,
613
- no `any`, every remaining cast individually justified in a reviewed
614
- whitelist.
615
- - **A hard CI gate on every commit.** Typecheck, zero-warning lint (a
616
- warning is fixed or the rule is disabled on purpose, never ignored),
617
- format check, import hygiene, the full headless test suite.
618
- - **Runtime validation with arktype.** Wire messages and JSON formats are
619
- schema-validated. When ComfyUI drifts faster than the schemas, failures
620
- are logged loud, never swallowed.
621
- - **Codegen you can regenerate, never hand-edit.** The SDK, the manager
622
- unions and the snapshot tests around them all rebuild from source data
623
- with one command each.
624
- - **A compat grind loop, not compat hope.** The full official template
625
- corpus (~780 workflows from Comfy-Org) is mirrored locally and swept
626
- against our schemas on demand, so upstream format changes surface as a
627
- failing report line, not as your broken pipeline.
628
- - **Boring packaging.** Dual ESM/CJS, Bun and node ≥ 20, `src/` shipped in
629
- the tarball for go-to-definition.
467
+ - **Strict TypeScript everywhere.** `strict` + `noUncheckedIndexedAccess`, no `any`, every remaining cast individually justified in a reviewed whitelist.
468
+ - **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.
469
+ - **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.
470
+ - **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.
471
+ - **A compat grind loop, not compat hope.** The full official template corpus (~780 workflows from Comfy-Org) is mirrored locally and swept against our schemas on demand, so upstream format changes surface as a failing report line, not as your broken pipeline.
472
+ - **Boring packaging.** Dual ESM/CJS, Bun and node ≥ 20, `src/` shipped in the tarball for go-to-definition.
630
473
 
631
474
  ## Related projects
632
475
 
@@ -636,10 +479,7 @@ The glitter above sits on boring foundations:
636
479
 
637
480
  ## Support
638
481
 
639
- comfy-ts is free, MIT, and maintained for the long run. If it saves you
640
- time or powers something you sell, consider
641
- [sponsoring](https://github.com/sponsors/rvion), it keeps the grind loops
642
- grinding.
482
+ 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.
643
483
 
644
484
  ## License
645
485
 
@@ -206,7 +206,7 @@ var PromptVar = class extends ComfyVarBase {
206
206
  constructor(defaultValue, promptOpts = {}) {
207
207
  super(defaultValue, promptOpts.label);
208
208
  this.promptOpts = promptOpts;
209
- this.kind = "text";
209
+ this.kind = "prompt";
210
210
  }
211
211
  parse(raw) {
212
212
  this.set(raw);
@@ -597,6 +597,7 @@ var ImageVarEmptyError = class extends Error {
597
597
  constructor(varName) {
598
598
  super(`image var '${varName}' is empty — pick a file (TUI: activate the var; script: .set('/path/to/image.png'))`);
599
599
  this.varName = varName;
600
+ this.name = "ImageVarEmptyError";
600
601
  }
601
602
  };
602
603
  /** trim + expand a leading `~/` — every ImageVar write funnels through this */
@@ -734,6 +735,6 @@ var DefinedWorkflow = class {
734
735
  }
735
736
  };
736
737
  //#endregion
737
- export { resolveComfyStorage as _, ImageVarEmptyError as a, logInfo as b, PromptVar as c, TextVar as d, ToggleVar as f, getComfyStorage as g, extractErrorMessage as h, ImageVar as i, SeedVar as l, setLoraKeyword as m, ChoiceVar as n, IntVar as o, getLoraKeyword as p, FloatVar as r, LorasVar as s, DefinedWorkflow as t, SizeVar as u, isQuiet as v, logSuccess as x, logError as y };
738
+ export { setLoraKeyword as a, resolveComfyStorage as c, logInfo as d, logSuccess as f, getLoraKeyword as i, isQuiet as l, LorasVar as n, extractErrorMessage as o, PromptVar as r, getComfyStorage as s, DefinedWorkflow as t, logError as u };
738
739
 
739
- //# sourceMappingURL=DefinedWorkflow-CqNE_kgR.js.map
740
+ //# sourceMappingURL=DefinedWorkflow-CwHInZgn.js.map