comfy-ts 1.0.0 → 1.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 (147) hide show
  1. package/README.md +60 -11
  2. package/dist/cli.js +4 -4439
  3. package/dist/cli.js.map +1 -1
  4. package/dist/index.cjs +445 -172
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +7439 -340
  7. package/dist/index.d.ts +7457 -358
  8. package/dist/index.js +444 -172
  9. package/dist/index.js.map +1 -1
  10. package/dist/{run-tui-BFhba_oG.js → run-tui-BAdizWsO.js} +1244 -201
  11. package/dist/run-tui-BAdizWsO.js.map +1 -0
  12. package/dist/state-BYbxDgfr.js +5258 -0
  13. package/dist/state-BYbxDgfr.js.map +1 -0
  14. package/examples/README.md +32 -0
  15. package/examples/comfy-cloud/ace-step-t2a.cflow.ts +79 -0
  16. package/examples/comfy-cloud/anima-t2i.cflow.ts +57 -0
  17. package/examples/comfy-cloud/boogu-i2i.cflow.ts +76 -0
  18. package/examples/comfy-cloud/capybara-i2i.cflow.ts +85 -0
  19. package/examples/comfy-cloud/capybara-i2v.cflow.ts +90 -0
  20. package/examples/comfy-cloud/capybara-t2i.cflow.ts +67 -0
  21. package/examples/comfy-cloud/chatterbox-t2a.cflow.ts +79 -0
  22. package/examples/comfy-cloud/chroma-t2i.cflow.ts +62 -0
  23. package/examples/comfy-cloud/cloudHost.ts +41 -0
  24. package/examples/comfy-cloud/ernie-t2i.cflow.ts +59 -0
  25. package/examples/comfy-cloud/firered-i2i.cflow.ts +74 -0
  26. package/examples/comfy-cloud/flux1-i2i.cflow.ts +76 -0
  27. package/examples/comfy-cloud/flux1-t2i.cflow.ts +63 -0
  28. package/examples/comfy-cloud/flux2-i2i.cflow.ts +80 -0
  29. package/examples/comfy-cloud/flux2-t2i.cflow.ts +57 -0
  30. package/examples/comfy-cloud/hidream-i2i.cflow.ts +89 -0
  31. package/examples/comfy-cloud/hidream-t2i.cflow.ts +65 -0
  32. package/examples/comfy-cloud/hunyuan-video-i2v.cflow.ts +93 -0
  33. package/examples/comfy-cloud/hunyuan-video-t2v.cflow.ts +74 -0
  34. package/examples/comfy-cloud/ideogram4-t2i.cflow.ts +80 -0
  35. package/examples/comfy-cloud/kandinsky5-i2v.cflow.ts +95 -0
  36. package/examples/comfy-cloud/kandinsky5-t2i.cflow.ts +60 -0
  37. package/examples/comfy-cloud/kandinsky5-t2v.cflow.ts +78 -0
  38. package/examples/comfy-cloud/krea2-t2i.cflow.ts +59 -0
  39. package/examples/comfy-cloud/lens-t2i.cflow.ts +62 -0
  40. package/examples/comfy-cloud/longcat-i2i.cflow.ts +74 -0
  41. package/examples/comfy-cloud/longcat-t2i.cflow.ts +65 -0
  42. package/examples/comfy-cloud/ltxv-i2v.cflow.ts +92 -0
  43. package/examples/comfy-cloud/ltxv-t2v.cflow.ts +78 -0
  44. package/examples/comfy-cloud/newbie-t2i.cflow.ts +67 -0
  45. package/examples/comfy-cloud/omnigen2-i2i.cflow.ts +86 -0
  46. package/examples/comfy-cloud/omnigen2-t2i.cflow.ts +62 -0
  47. package/examples/comfy-cloud/ovis-t2i.cflow.ts +56 -0
  48. package/examples/comfy-cloud/pixeldit-t2i.cflow.ts +63 -0
  49. package/examples/comfy-cloud/qwen-image-i2i.cflow.ts +69 -0
  50. package/examples/comfy-cloud/qwen-image-t2i.cflow.ts +55 -0
  51. package/examples/comfy-cloud/sd35-t2i.cflow.ts +48 -0
  52. package/examples/comfy-cloud/sdk.d.ts +445 -57
  53. package/examples/comfy-cloud/sdxl-t2i.cflow.ts +69 -0
  54. package/examples/comfy-cloud/stable-audio-t2a.cflow.ts +53 -0
  55. package/examples/comfy-cloud/svd-i2v.cflow.ts +75 -0
  56. package/examples/comfy-cloud/wan21-i2v.cflow.ts +83 -0
  57. package/examples/comfy-cloud/wan21-t2v.cflow.ts +64 -0
  58. package/examples/comfy-cloud/wan22-5b-t2v.cflow.ts +69 -0
  59. package/examples/comfy-cloud/wan22-i2v.cflow.ts +107 -0
  60. package/examples/comfy-cloud/wan22-t2v.cflow.ts +98 -0
  61. package/examples/comfy-cloud/z-image-t2i.cflow.ts +62 -0
  62. package/examples/images/README.md +18 -0
  63. package/examples/images/bear_1024x1024.jpg +0 -0
  64. package/examples/images/deer_768x1344.jpg +0 -0
  65. package/examples/images/dog_512x512.jpg +0 -0
  66. package/examples/images/lioness_768x768.jpg +0 -0
  67. package/examples/images/pug_200x300.jpg +0 -0
  68. package/examples/images/walrus_1344x768.jpg +0 -0
  69. package/examples/{01-txt2img.cflow.ts → rvion/01-txt2img.cflow.ts} +1 -1
  70. package/examples/{02-img2img-upload.cflow.ts → rvion/02-img2img-upload.cflow.ts} +7 -18
  71. package/examples/{03-export-workflow-json.cflow.ts → rvion/03-export-workflow-json.cflow.ts} +1 -1
  72. package/examples/{04-krea2-turbo-t2i.cflow.ts → rvion/04-krea2-turbo-t2i.cflow.ts} +2 -2
  73. package/examples/rvion/05-comfy-cloud.cflow.ts +51 -0
  74. package/examples/rvion/06-qwen-image-edit.cflow.ts +89 -0
  75. package/guide-for-agents.md +7 -1
  76. package/package.json +18 -4
  77. package/src/cli/tui/components/CopyOverlay.tsx +25 -0
  78. package/src/cli/tui/components/Header.tsx +9 -4
  79. package/src/cli/tui/components/HostPanel.tsx +3 -2
  80. package/src/cli/tui/components/HostsOverlay.tsx +33 -0
  81. package/src/cli/tui/components/PreviewPanel.tsx +9 -8
  82. package/src/cli/tui/components/StatusBar.tsx +39 -9
  83. package/src/cli/tui/components/TreePanel.tsx +17 -7
  84. package/src/cli/tui/components/TuiApp.tsx +65 -5
  85. package/src/cli/tui/discoverWorkflows.ts +7 -41
  86. package/src/cli/tui/imagePicker/ImagePickerOverlay.tsx +72 -0
  87. package/src/cli/tui/imagePicker/ImagePickerSt.ts +288 -0
  88. package/src/cli/tui/imagePicker/fsListing.ts +48 -0
  89. package/src/cli/tui/imagePicker/pickerPrefs.ts +78 -0
  90. package/src/cli/tui/run-tui.tsx +49 -8
  91. package/src/cli/tui/state/DraftsSt.ts +3 -2
  92. package/src/cli/tui/state/ExecSt.ts +108 -12
  93. package/src/cli/tui/state/HostSt.ts +94 -10
  94. package/src/cli/tui/state/LorasSt.ts +14 -36
  95. package/src/cli/tui/state/PickerSt.ts +8 -2
  96. package/src/cli/tui/state/PreviewSt.ts +28 -2
  97. package/src/cli/tui/state/QueueSt.ts +2 -2
  98. package/src/cli/tui/state/SettingsSt.ts +25 -7
  99. package/src/cli/tui/state/TreeSt.ts +139 -36
  100. package/src/cli/tui/state/TuiSt.ts +53 -6
  101. package/src/cli/tui/state/WorkflowsSt.ts +14 -2
  102. package/src/cli/tui/treeRows.ts +165 -0
  103. package/src/exampleAssets.ts +56 -0
  104. package/src/graph/ComfyNode.ts +4 -1
  105. package/src/host/ComfyHost.ts +7 -0
  106. package/src/index.ts +7 -0
  107. package/src/manager/ComfyRegistry.ts +37 -9
  108. package/src/manager/generated/KnownComfyCustomNodeName.ts +23852 -1926
  109. package/src/manager/generated/KnownComfyPluginTitle.ts +6854 -236
  110. package/src/manager/generated/KnownComfyPluginURL.ts +3425 -111
  111. package/src/manager/generated/KnownModel_Base.ts +23 -7
  112. package/src/manager/generated/KnownModel_FileName.ts +421 -0
  113. package/src/manager/generated/KnownModel_Name.ts +421 -0
  114. package/src/manager/generated/KnownModel_SavePath.ts +34 -8
  115. package/src/manager/generated/KnownModel_Type.ts +18 -14
  116. package/src/manager/json/alter-list.json +221 -221
  117. package/src/manager/json/custom-node-list.json +61020 -21946
  118. package/src/manager/json/extension-node-map.json +81077 -31176
  119. package/src/manager/json/github-stats.json +29321 -12601
  120. package/src/manager/json/model-list.json +5935 -4997
  121. package/src/manager/loaders/parseReport.ts +55 -0
  122. package/src/manager/loaders/step1_downloadComfyManagerJSONs.ts +15 -49
  123. package/src/manager/loaders/step2_custom-node-list-loader.ts +38 -83
  124. package/src/manager/loaders/step3_extension-node-map-loader.ts +36 -142
  125. package/src/manager/loaders/step4_model-list-loader.ts +25 -36
  126. package/src/manager/loaders/step5_alter-list-loader.ts +29 -0
  127. package/src/manager/loaders/step6_github-stats-loader.ts +23 -0
  128. package/src/manager/script-update-manager.bun.ts +9 -1
  129. package/src/manager/types/ComfyManagerAlterInfo.ts +13 -0
  130. package/src/manager/types/ComfyManagerFileModelInfo.ts +7 -3
  131. package/src/manager/types/ComfyManagerFilePluginContent.ts +6 -9
  132. package/src/manager/types/ComfyManagerFilePluginList.ts +3 -3
  133. package/src/manager/types/ComfyManagerGithubStats.ts +9 -0
  134. package/src/manager/types/ComfyManagerPluginContentMetadata.ts +2 -3
  135. package/src/manager/types/ComfyManagerPluginInfo.ts +48 -34
  136. package/src/runner/ComfyWorkflowLayout.ts +6 -4
  137. package/src/sdk-generator/ComfySchema.ts +14 -1
  138. package/src/sdk-generator/comfyui-sdk-codegen.ts +15 -0
  139. package/src/sdk-generator/inputWidgetKind.ts +17 -0
  140. package/src/state.ts +7 -1
  141. package/src/vars/ComfyVars.ts +106 -5
  142. package/src/vars/DefinedWorkflow.ts +28 -10
  143. package/dist/DefinedWorkflow-O3ynII3Y.js +0 -598
  144. package/dist/DefinedWorkflow-O3ynII3Y.js.map +0 -1
  145. package/dist/run-tui-BFhba_oG.js.map +0 -1
  146. package/examples/05-comfy-cloud.cflow.ts +0 -67
  147. package/src/utils/tryExtracting.ts +0 -41
@@ -0,0 +1,62 @@
1
+ // z-image t2i on Comfy Cloud — Z-Image Turbo bf16, 8-step distilled text to image (cfg 1)
2
+ // source template: image_z_image_turbo.json (official workflow-templates)
3
+ // needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
4
+ // run directly: bun examples/comfy-cloud/z-image-t2i.cflow.ts ["prompt"] [seed]
5
+ import { v } from 'comfy-ts'
6
+ import { cloudHost, requireCloudKey } from './cloudHost.ts'
7
+
8
+ const host = await cloudHost()
9
+
10
+ export const zImageT2i = host.defineWorkflow({
11
+ id: 'z-image-t2i',
12
+ vars: {
13
+ // ONE prompt var: `- ` lines are the NEGATIVE prompt, `//` lines are comments
14
+ prompt: v.prompt(
15
+ 'Latina female with thick wavy hair, harbor boats and pastel houses behind. Breezy seaside light, warm tones, cinematic close-up.',
16
+ ),
17
+ seed: v.seed(42),
18
+ steps: v.int(8, { min: 1, max: 40 }),
19
+ size: v.size({ width: 1024, height: 1024 }),
20
+ },
21
+ build: (b, vars) => {
22
+ const model = b.ModelSamplingAuraFlow({
23
+ model: b.UNETLoader({ unet_name: 'z_image_turbo_bf16.safetensors', weight_dtype: 'default' }),
24
+ shift: 3,
25
+ })
26
+ const clip = b.CLIPLoader({ clip_name: 'qwen_3_4b.safetensors', type: 'lumina2', device: 'default' })
27
+ const positive = b.CLIPTextEncode({ clip, text: vars.prompt.positive })
28
+ // turbo distill: no negative lines → zeroed-out conditioning (the template's own default)
29
+ const negative =
30
+ vars.prompt.negative === ''
31
+ ? b.ConditioningZeroOut({ conditioning: positive })
32
+ : b.CLIPTextEncode({ clip, text: vars.prompt.negative })
33
+ const samples = b.KSampler({
34
+ model,
35
+ positive,
36
+ negative,
37
+ latent_image: b.EmptySD3LatentImage({ width: vars.size.width, height: vars.size.height, batch_size: 1 }),
38
+ seed: vars.seed,
39
+ steps: vars.steps,
40
+ cfg: 1,
41
+ sampler_name: 'res_multistep',
42
+ scheduler: 'simple',
43
+ denoise: 1,
44
+ })
45
+ b.SaveImage({
46
+ images: b.VAEDecode({ samples, vae: b.VAELoader({ vae_name: 'ae.safetensors' }) }),
47
+ filename_prefix: 'comfy-ts-zoo/z-image-t2i',
48
+ })
49
+ },
50
+ })
51
+
52
+ export default zImageT2i
53
+
54
+ // standalone run (skipped when another driver — e.g. the TUI — imports this module)
55
+ if (import.meta.main) {
56
+ requireCloudKey()
57
+ if (process.argv[2]) zImageT2i.vars.prompt.set(process.argv[2])
58
+ if (process.argv[3]) zImageT2i.vars.seed.set(Number(process.argv[3]))
59
+ const execution = await zImageT2i.run({ log: true })
60
+ for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
61
+ host.disconnect()
62
+ }
@@ -0,0 +1,18 @@
1
+ # Bundled example input images
2
+
3
+ Default inputs for the i2i/i2v examples — they ship in the npm tarball so
4
+ every example runs out of the box. The exact pixel size is in each filename.
5
+
6
+ Source: [picsum.photos](https://picsum.photos), which serves Unsplash-sourced
7
+ photos, free to use. Fetched and re-encoded (jpeg q80, metadata stripped) by
8
+ `scripts/fetch-example-images.ts` — the manifest in that script is the source
9
+ of truth; regeneration is deliberate (`bun run examples:images`).
10
+
11
+ | file | size | picsum id | author |
12
+ | --------------------- | --------- | ------------------------------------------ | ------------------------------------------------------------ |
13
+ | `dog_512x512.jpg` | 512×512 | [237](https://picsum.photos/id/237/info) | [André Spieker](https://unsplash.com/photos/8wTPqxlnKM4) |
14
+ | `lioness_768x768.jpg` | 768×768 | [1074](https://picsum.photos/id/1074/info) | [Samuel Scrimshaw](https://unsplash.com/photos/sseiVD2XsOk) |
15
+ | `bear_1024x1024.jpg` | 1024×1024 | [433](https://picsum.photos/id/433/info) | [Thomas Lefebvre](https://unsplash.com/photos/aRXPJnXQ9lU) |
16
+ | `walrus_1344x768.jpg` | 1344×768 | [1084](https://picsum.photos/id/1084/info) | [Jay Ruzesky](https://unsplash.com/photos/h13Y8vyIXNU) |
17
+ | `deer_768x1344.jpg` | 768×1344 | [1003](https://picsum.photos/id/1003/info) | [E+N Photographies](https://unsplash.com/photos/GYumuBnTqKc) |
18
+ | `pug_200x300.jpg` | 200×300 | [1025](https://picsum.photos/id/1025/info) | [Matthew Wiebe](https://unsplash.com/photos/U5rMrSI7Pn4) |
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  // generate an image from text, fully typed against the 'windows-1' host sdk
2
- // run directly: bun examples/01-txt2img.cflow.ts ["prompt"] [seed]
2
+ // run directly: bun examples/rvion/01-txt2img.cflow.ts ["prompt"] [seed]
3
3
  // in the TUI: bun run tui (scans **/*.cflow.ts, tweak vars, r to run)
4
4
  import { ComfyTS, v } from 'comfy-ts'
5
5
 
@@ -1,30 +1,19 @@
1
1
  // upload a local image (hash-named, deduped) and run img2img on it
2
- // run directly: bun examples/02-img2img-upload.cflow.ts [path/to/image.png]
3
- // in the TUI: bun run tui — the `image` var is a path; empty = generated placeholder
4
- import { mkdirSync } from 'node:fs'
5
- import { asAbsolutePath, ComfyTS, MediaImage, v } from 'comfy-ts'
6
- import { dirname, resolve } from 'pathe'
7
- import sharp from 'sharp'
2
+ // run directly: bun examples/rvion/02-img2img-upload.cflow.ts [path/to/image.png]
3
+ // in the TUI: bun run tui — activate the `image` var to open the picker (browse, favorites, preview)
4
+ import { asAbsolutePath, ComfyTS, exampleImagePath, MediaImage, v } from 'comfy-ts'
8
5
 
9
6
  const comfy = ComfyTS.create()
10
7
  const host = comfy.host({ id: 'windows-1', host: 'desktop-im18794', port: 8085 })
11
8
  await host.loadSchemaFromCache() // offline import; run() connects lazily
12
9
 
13
- /** empty path → a generated flat-color placeholder (keeps the example self-contained) */
14
- async function resolveInputImage(path: string): Promise<string> {
15
- if (path.trim() !== '') return resolve(path)
16
- const placeholder = comfy.resolveFromOutput('example-input.png')
17
- mkdirSync(dirname(placeholder), { recursive: true })
18
- await sharp({ create: { width: 512, height: 512, channels: 3, background: { r: 210, g: 140, b: 80 } } })
19
- .png()
20
- .toFile(placeholder)
21
- return placeholder
22
- }
10
+ // bundled default input (examples/images/, ships in the tarball) — the TUI picker or argv[2] swap it
11
+ const image = v.image(exampleImagePath('dog_512x512.jpg'))
23
12
 
24
13
  export const img2img = host.defineWorkflow({
25
14
  id: 'img2img-upload',
26
15
  vars: {
27
- image: v.text('', 'image path'),
16
+ image,
28
17
  prompt: v.text('oil painting of a sunset over the sea'),
29
18
  negative: v.text('text, watermark'),
30
19
  seed: v.seed(7),
@@ -34,7 +23,7 @@ export const img2img = host.defineWorkflow({
34
23
  },
35
24
  // async build: the input image is uploaded (hash-named, deduped) per run
36
25
  build: async (b, vars, wf) => {
37
- const img = new MediaImage({ path: asAbsolutePath(await resolveInputImage(vars.image)) })
26
+ const img = new MediaImage({ path: asAbsolutePath(image.absPath()) })
38
27
  const loaded = await img.loadInWorkflow_viaLoadImageNode(wf)
39
28
 
40
29
  const ckpt = b.CheckpointLoaderSimple({ ckpt_name: 'SD1.5\\v1-5-pruned-emaonly.ckpt' })
@@ -1,6 +1,6 @@
1
1
  // build a graph OFFLINE (schema from .comfy-ts/ cache) and export both ComfyUI
2
2
  // JSON formats: api.json (prompt) + workflow.json (readable litegraph, autolayouted)
3
- // run directly: bun examples/03-export-workflow-json.cflow.ts (no server needed)
3
+ // run directly: bun examples/rvion/03-export-workflow-json.cflow.ts (no server needed)
4
4
  // in the TUI: bun run tui — r runs it live (PreviewImage), c/C copy the JSONs
5
5
  import { mkdirSync, writeFileSync } from 'node:fs'
6
6
  import { ComfyTS, v } from 'comfy-ts'
@@ -2,8 +2,8 @@
2
2
  // (rabbits-vs-sheeps "unified"). krea2 turbo UNET + standard LoraLoader chain
3
3
  // → KSampler(8 steps, cfg 1) → RMBG cutout → transparent png game sprite.
4
4
  //
5
- // run directly: bun examples/04-krea2-turbo-t2i.cflow.ts ["prompt"] [seed]
6
- // in the TUI: bun src/cli/comfy-ts-cli.ts tui examples/04-krea2-turbo-t2i.cflow.ts
5
+ // run directly: bun examples/rvion/04-krea2-turbo-t2i.cflow.ts ["prompt"] [seed]
6
+ // in the TUI: bun src/cli/comfy-ts-cli.ts tui examples/rvion/04-krea2-turbo-t2i.cflow.ts
7
7
  // tui browser: bun src/cli/comfy-ts-cli.ts tui examples/ (scans **/*.cflow.ts)
8
8
  import { activeLoras, ComfyTS } from 'comfy-ts'
9
9
 
@@ -0,0 +1,51 @@
1
+ // sd15 t2i on Comfy Cloud — the reference zoo example (agent/examples.md)
2
+ // source template: default.json (official workflow-templates)
3
+ // needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers) — loads fine without, run() needs it
4
+ // run directly: bun examples/rvion/05-comfy-cloud.cflow.ts ["prompt"] [seed]
5
+ import { v } from 'comfy-ts'
6
+ import { cloudHost, requireCloudKey } from '../comfy-cloud/cloudHost.ts'
7
+
8
+ const host = await cloudHost()
9
+
10
+ export const sd15T2i = host.defineWorkflow({
11
+ id: 'sd15-t2i',
12
+ vars: {
13
+ // ONE prompt var: `- ` lines are the NEGATIVE prompt, `//` lines are comments
14
+ prompt: v.prompt('a lighthouse on a cliff at dusk, dramatic clouds\n- blurry, low quality'),
15
+ seed: v.seed(42),
16
+ steps: v.int(12, { min: 1, max: 60 }),
17
+ cfg: v.float(7, { min: 0, max: 30 }),
18
+ size: v.size({ width: 512, height: 512 }),
19
+ },
20
+ build: (b, vars) => {
21
+ const ckpt = b.CheckpointLoaderSimple({ ckpt_name: 'v1-5-pruned-emaonly-fp16.safetensors' })
22
+ const samples = b.KSampler({
23
+ model: ckpt,
24
+ positive: b.CLIPTextEncode({ clip: ckpt, text: vars.prompt.positive }),
25
+ negative: b.CLIPTextEncode({ clip: ckpt, text: vars.prompt.negative }),
26
+ latent_image: b.EmptyLatentImage({ width: vars.size.width, height: vars.size.height, batch_size: 1 }),
27
+ seed: vars.seed,
28
+ steps: vars.steps,
29
+ cfg: vars.cfg,
30
+ sampler_name: 'euler',
31
+ scheduler: 'normal',
32
+ denoise: 1,
33
+ })
34
+ b.SaveImage({ images: b.VAEDecode({ samples, vae: ckpt }), filename_prefix: 'comfy-ts-zoo/sd15-t2i' })
35
+ },
36
+ })
37
+
38
+ export default sd15T2i
39
+
40
+ // standalone run (skipped when another driver — e.g. the TUI — imports this module)
41
+ if (import.meta.main) {
42
+ requireCloudKey()
43
+ if (process.argv[2]) sd15T2i.vars.prompt.set(process.argv[2])
44
+ if (process.argv[3]) sd15T2i.vars.seed.set(Number(process.argv[3]))
45
+
46
+ const t0 = Date.now()
47
+ const execution = await sd15T2i.run({ log: true })
48
+ console.log(`🟢 done in ${((Date.now() - t0) / 1000).toFixed(1)}s — ${execution.images.length} image(s):`)
49
+ for (const img of execution.images) console.log(` ${img.absPath} (${img.width}x${img.height})`)
50
+ host.disconnect()
51
+ }
@@ -0,0 +1,89 @@
1
+ // qwen image edit 2511 on windows-1 — instruction-driven image editing
2
+ // mirrors the official image_qwen_image_edit_2511 template, single reference
3
+ // image; the lightning toggle switches the 4-step Lightning lora (cfg 1) vs
4
+ // full sampling (cfg 4 — raise steps to ~40 yourself when you flip it off)
5
+ // run directly: bun examples/rvion/06-qwen-image-edit.cflow.ts [path/to/image.png] ["edit instruction"]
6
+ import { asAbsolutePath, ComfyTS, exampleImagePath, MediaImage, v } from 'comfy-ts'
7
+
8
+ const comfy = ComfyTS.create()
9
+ const host = comfy.host({ id: 'windows-1', host: 'desktop-im18794', port: 8085 })
10
+ await host.loadSchemaFromCache() // offline import; run() connects lazily
11
+
12
+ // bundled default input (examples/images/, ships in the tarball) — the TUI picker or argv[2] swap it
13
+ const image = v.image(exampleImagePath('bear_1024x1024.jpg'))
14
+
15
+ export const qwenImageEdit = host.defineWorkflow({
16
+ id: 'qwen-image-edit',
17
+ vars: {
18
+ image,
19
+ // `- ` lines are the negative prompt (template default: empty negative encode)
20
+ prompt: v.prompt('turn this photo into a detailed watercolor painting'),
21
+ seed: v.seed(42),
22
+ steps: v.int(4, { min: 1, max: 60 }),
23
+ lightning: v.toggle(true, '4-step lightning lora'),
24
+ prefix: v.text('qwen-image-edit'),
25
+ },
26
+ // async build: the reference image is uploaded (hash-named, deduped) per run
27
+ build: async (b, vars, wf) => {
28
+ const img = new MediaImage({ path: asAbsolutePath(image.absPath()) })
29
+ const loaded = await img.loadInWorkflow_viaLoadImageNode(wf)
30
+ const scaled = b.FluxKontextImageScale({ image: loaded })
31
+
32
+ const unet = b.UNETLoader({ unet_name: 'qwen_image_edit_2511_bf16.safetensors', weight_dtype: 'default' })
33
+ const clip = b.CLIPLoader({
34
+ clip_name: 'qwen_2.5_vl_7b_fp8_scaled.safetensors',
35
+ type: 'qwen_image',
36
+ device: 'default',
37
+ })
38
+ const vae = b.VAELoader({ vae_name: 'qwen_image_vae.safetensors' })
39
+
40
+ let model = b.CFGNorm({
41
+ model: b.ModelSamplingAuraFlow({ model: unet, shift: 3.1 }),
42
+ strength: 1,
43
+ pre_cfg: false,
44
+ })._MODEL
45
+ if (vars.lightning) {
46
+ model = b.LoraLoaderModelOnly({
47
+ model,
48
+ lora_name: 'Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors',
49
+ strength_model: 1,
50
+ })._MODEL
51
+ }
52
+
53
+ // both branches carry the reference through the kontext latent method (template shape)
54
+ const positive = b.FluxKontextMultiReferenceLatentMethod({
55
+ reference_latents_method: 'index_timestep_zero',
56
+ conditioning: b.TextEncodeQwenImageEditPlus({ clip, prompt: vars.prompt.positive, vae, image1: scaled }),
57
+ })
58
+ const negative = b.FluxKontextMultiReferenceLatentMethod({
59
+ reference_latents_method: 'index_timestep_zero',
60
+ conditioning: b.TextEncodeQwenImageEditPlus({ clip, prompt: vars.prompt.negative, vae, image1: scaled }),
61
+ })
62
+
63
+ const samples = b.KSampler({
64
+ model,
65
+ positive,
66
+ negative,
67
+ latent_image: b.VAEEncode({ pixels: scaled, vae }),
68
+ seed: vars.seed,
69
+ steps: vars.steps,
70
+ cfg: vars.lightning ? 1 : 4,
71
+ sampler_name: 'euler',
72
+ scheduler: 'simple',
73
+ denoise: 1,
74
+ })
75
+ b.SaveImage({ images: b.VAEDecode({ samples, vae }), filename_prefix: vars.prefix })
76
+ },
77
+ })
78
+
79
+ export default qwenImageEdit
80
+
81
+ // standalone run (skipped when another driver — e.g. the TUI — imports this module)
82
+ if (import.meta.main) {
83
+ if (process.argv[2]) qwenImageEdit.vars.image.set(process.argv[2])
84
+ if (process.argv[3]) qwenImageEdit.vars.prompt.set(process.argv[3])
85
+
86
+ const execution = await qwenImageEdit.run({ log: true })
87
+ for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
88
+ host.disconnect()
89
+ }
@@ -83,7 +83,7 @@ if (import.meta.main) {
83
83
  ```
84
84
 
85
85
  Var kinds: `v.text`, `v.int`, `v.float`, `v.seed`, `v.toggle`, `v.choice`,
86
- `v.size`, `v.loras`, `v.prompt`. Notes:
86
+ `v.size`, `v.loras`, `v.prompt`, `v.image`. Notes:
87
87
 
88
88
  - `v.loras(/regex/)` resolves against the host's real lora list;
89
89
  `activeLoras(vars.loras)` returns `{ lora_name, strength_model, strength_clip }[]`
@@ -91,6 +91,12 @@ Var kinds: `v.text`, `v.int`, `v.float`, `v.seed`, `v.toggle`, `v.choice`,
91
91
  - `v.prompt` is structured: `//` lines are comments (stripped), `- ` lines go
92
92
  to the negative prompt, `{ loraKeywordsFrom: lorasVar }` prefixes lora
93
93
  trigger keywords. The value is `{ positive, negative }`.
94
+ - `v.image` holds a local image path as a plain string; an empty value throws
95
+ at build time instead of running a silent placeholder. Capture the var in a
96
+ const and call `image.absPath()` in `build`. Default it to a bundled sample
97
+ with `exampleImagePath('bear_1024x1024.jpg')` (ships in the package). In
98
+ the TUI it opens an image picker (browse, favorite folders, recents,
99
+ preview).
94
100
  - `vars` may be a lambda `(v) => ({ ... })` so vars can reference each other.
95
101
  - `build` may be async, for uploads: the third param `wf` feeds `MediaImage`
96
102
  helpers (`new MediaImage({ path }).loadInWorkflow_viaLoadImageNode(wf)`).
package/package.json CHANGED
@@ -1,16 +1,27 @@
1
1
  {
2
2
  "name": "comfy-ts",
3
- "version": "1.0.0",
4
- "description": "Type-safe generative AI pipeline creation and execution using ComfyUI",
3
+ "version": "1.2.0",
4
+ "description": "The complete TypeScript toolkit for ComfyUI and generative AI. Fully type-safe SDK with autocomplete on every node, companion CLI, TUI, agentic docs, and 50+ examples. Design, run and deploy creative pipelines for image, video, audio, 3d and text on any ComfyUI, local, cloud or hosted.",
5
5
  "keywords": [
6
6
  "comfyui",
7
- "AI",
7
+ "generative-ai",
8
8
  "typescript",
9
+ "type-safe",
10
+ "sdk",
9
11
  "codegen",
10
- "stable-diffusion"
12
+ "image-generation",
13
+ "video-generation",
14
+ "audio-generation",
15
+ "3d",
16
+ "stable-diffusion",
17
+ "flux",
18
+ "workflow",
19
+ "cli",
20
+ "tui"
11
21
  ],
12
22
  "author": "Rémi Vion <vion.remi@gmail.com>",
13
23
  "license": "MIT",
24
+ "funding": "https://github.com/sponsors/rvion",
14
25
  "repository": {
15
26
  "type": "git",
16
27
  "url": "https://github.com/rvion/comfy-ts.git"
@@ -67,9 +78,12 @@
67
78
  "gen:sdk": "bun scripts/gen-sdk-from-cache.ts",
68
79
  "gen:sdk:cloud": "bun src/cli/comfy-ts-cli.ts gen --id comfy-cloud --host https://cloud.comfy.org --out examples/comfy-cloud/sdk.d.ts && oxfmt examples/comfy-cloud/sdk.d.ts",
69
80
  "sdk:outline": "bun scripts/sdk-outline.ts",
81
+ "examples:images": "bun scripts/fetch-example-images.ts",
70
82
  "templates:fetch": "bun scripts/fetch-templates.ts",
71
83
  "templates:check": "bun scripts/check-templates.ts",
72
84
  "hooks:install": "git config core.hooksPath .githooks",
85
+ "release": "bun scripts/release.ts",
86
+ "release:dry": "bun scripts/release.ts --dry-run",
73
87
  "prepublishOnly": "bun run ci && bun run build",
74
88
  "tui": "bun src/cli/comfy-ts-cli.ts tui"
75
89
  },
@@ -0,0 +1,25 @@
1
+ import { Box, Text } from 'ink'
2
+ import { observer } from 'mobx-react-lite'
3
+ import { KeyHints } from 'src/cli/tui/components/StatusBar.tsx'
4
+ import type { TuiSt } from 'src/cli/tui/state/TuiSt.ts'
5
+
6
+ /** `c`/`C` confirmation popup: WHAT landed in the clipboard (or the loud
7
+ * failure) — a copy is never silent again. ⏎/esc closes. */
8
+ export const CopyOverlay = observer((p: { st: TuiSt }) => {
9
+ const popup = p.st.exec.copyPopup
10
+ if (popup == null) return null
11
+ return (
12
+ <Box borderStyle="double" borderColor={popup.ok ? 'green' : 'red'} paddingX={1} flexDirection="column">
13
+ <Text bold color={popup.ok ? 'green' : 'red'}>
14
+ {popup.ok ? '✓ ' : '✗ '}
15
+ {popup.title}
16
+ </Text>
17
+ {popup.lines.slice(0, p.st.overlayLines).map((line, ix) => (
18
+ <Text key={`${ix}·${line.slice(0, 12)}`} color={popup.ok ? undefined : 'red'} wrap="truncate">
19
+ {line}
20
+ </Text>
21
+ ))}
22
+ <KeyHints hints={[['⏎/esc', 'close']]} />
23
+ </Box>
24
+ )
25
+ })
@@ -15,9 +15,10 @@ const HeaderBox = (p: { title?: string; children: ReactNode }): ReactNode => (
15
15
  </Box>
16
16
  )
17
17
 
18
- /** labeled header boxes: brand · (w)orkflow · (d)raft · (h)ost — the keys open each surface */
18
+ /** labeled header boxes: brand · (w)orkflow · (d)raft · (h)ost·(a)ctions — the keys open each surface */
19
19
  export const Header = observer((p: { st: TuiSt }) => {
20
20
  const s = p.st
21
+ const runHost = s.runHost
21
22
  return (
22
23
  <Box flexDirection="row">
23
24
  <HeaderBox>
@@ -35,16 +36,20 @@ export const Header = observer((p: { st: TuiSt }) => {
35
36
  {s.drafts.active ?? 'default'}
36
37
  </Text>
37
38
  </HeaderBox>
38
- <HeaderBox title="(h)ost">
39
+ <HeaderBox title="(h)ost · (a)ctions">
39
40
  <Text>
40
41
  <Text color={s.host.status === 'up' ? 'green' : s.host.status === 'down' ? 'red' : 'gray'}>● </Text>
41
42
  <Text bold color="green">
42
- {s.wf.host.data.id}
43
+ {runHost.data.id}
43
44
  </Text>
44
45
  <Text color="gray">
45
46
  {' '}
46
- ({s.wf.host.data.host}:{s.wf.host.data.port})
47
+ ({runHost.base.host}:{runHost.base.port})
47
48
  </Text>
49
+ {/* the override must stay loud: every run bypasses the workflow's own host */}
50
+ {s.hostOverride != null && s.hostOverride !== s.wf.host && (
51
+ <Text color="yellow"> ⇄ overrides {s.wf.host.data.id}</Text>
52
+ )}
48
53
  {/* while down, show the probe loop living: spinner in flight, countdown between tries */}
49
54
  {s.host.status === 'down' && (
50
55
  <Text color="red"> {s.host.probing ? s.host.spinner : `↻ ${s.host.retryInS}s`}</Text>
@@ -9,10 +9,11 @@ export const HostPanel = observer((p: { st: TuiSt }) => {
9
9
  return (
10
10
  <Box borderStyle="double" paddingX={1} flexDirection="column">
11
11
  <Text bold>
12
- host · <Text color="green">{h.host.data.id}</Text>{' '}
12
+ host actions · <Text color="green">{h.host.data.id}</Text>{' '}
13
13
  <Text color="gray">
14
- ({h.host.data.host}:{h.host.data.port})
14
+ ({h.host.base.host}:{h.host.base.port})
15
15
  </Text>
16
+ {s.hostOverride != null && <Text color="yellow"> ⇄ override</Text>}
16
17
  </Text>
17
18
  {h.stats.map((row) => (
18
19
  <Text key={row.label}>
@@ -0,0 +1,33 @@
1
+ import { Text } from 'ink'
2
+ import { observer } from 'mobx-react-lite'
3
+ import { OverlayList } from 'src/cli/tui/components/OverlayList.tsx'
4
+ import type { TuiSt } from 'src/cli/tui/state/TuiSt.ts'
5
+
6
+ /** modal host picker (`h`): row 0 restores the workflow's own host, the rest
7
+ * override where runs are built and sent (every registered host is listed) */
8
+ export const HostsOverlay = observer((p: { st: TuiSt }) => {
9
+ const s = p.st
10
+ const h = s.host
11
+ const rows = h.pickerRows.map((row, ix) => ({
12
+ key: row.host?.data.id ?? '·default·',
13
+ node: (
14
+ <Text key={row.host?.data.id ?? '·default·'} inverse={ix === h.pickerIx}>
15
+ {ix === h.pickerIx ? '▸ ' : ' '}
16
+ {row.active ? '● ' : ' '}
17
+ {row.label}
18
+ </Text>
19
+ ),
20
+ }))
21
+ return (
22
+ <OverlayList
23
+ title={
24
+ <>
25
+ run host <Text color="gray">· overrides the workflow's configured host</Text>
26
+ </>
27
+ }
28
+ selectedIx={h.pickerIx}
29
+ lines={s.overlayLines}
30
+ rows={rows}
31
+ />
32
+ )
33
+ })
@@ -33,26 +33,27 @@ export const PreviewPanel = observer((p: { st: TuiSt }) => {
33
33
  )
34
34
  }
35
35
 
36
- const loraMode = s.mode === 'overlay-loras'
36
+ // an overlay owns the vars area (loras / image picker): its slot owns the panel too
37
+ const overlayMode = pv.overlayActive
37
38
  const running = s.exec.running
38
39
  const wantLatent = running && pv.duringRun !== 'last-output'
39
- const showLatent = !loraMode && wantLatent && (pv.latentAnsi != null || pv.latentBytes != null)
40
- const label = loraMode
41
- ? `lora ${s.loras.previewName ?? 'lora'}`
40
+ const showLatent = !overlayMode && wantLatent && (pv.latentAnsi != null || pv.latentBytes != null)
41
+ const label = overlayMode
42
+ ? (pv.overlay?.name ?? (s.mode === 'overlay-loras' ? 'lora' : 'image'))
42
43
  : showLatent
43
44
  ? pv.duringRun === 'latent-small'
44
45
  ? 'latent small'
45
46
  : 'latent'
46
47
  : 'output'
47
- const placeholder = loraMode
48
- ? (s.loras.previewNote ?? '(pick a lora)')
48
+ const placeholder = overlayMode
49
+ ? (pv.overlay?.note ?? (s.mode === 'overlay-loras' ? '(pick a lora)' : '(pick an image)'))
49
50
  : pv.latentsMissing
50
51
  ? '(no latents from the server — launch comfy with --preview-method auto)'
51
52
  : '(no image yet)'
52
53
  const content = pv.useNative
53
54
  ? null
54
- : loraMode
55
- ? s.loras.previewAnsi
55
+ : overlayMode
56
+ ? (pv.overlay?.ansi ?? null)
56
57
  : showLatent
57
58
  ? (pv.latentAnsi ?? pv.outputAnsi)
58
59
  : pv.outputAnsi
@@ -65,6 +65,7 @@ const KIND_KEYS: Record<string, Hint[]> = {
65
65
  choice: [['⏎/→', 'pick']],
66
66
  size: [['⏎/→', 'pick']],
67
67
  loras: [['⏎/→', 'select']],
68
+ image: [['⏎/→', 'browse']],
68
69
  }
69
70
 
70
71
  /** shown INSIDE the text editor box (TextOverlay footer), not in the keybar */
@@ -118,12 +119,37 @@ const MODE_KEYS: Partial<Record<string, Hint[]>> = {
118
119
  ['⌃N', 'none'],
119
120
  ['esc', 'done'],
120
121
  ],
122
+ 'overlay-image': [
123
+ ['⏎', 'pick / enter dir'],
124
+ ['←', 'parent'],
125
+ ['→', 'enter dir'],
126
+ ['tab', 'pane'],
127
+ ['↑↓', 'move'],
128
+ ['type', 'filter'],
129
+ ['⌃F', 'fav folder'],
130
+ ['esc', 'cancel'],
131
+ ],
121
132
  'overlay-drafts': [['⏎', 'load / new'], ...DRAFT_OP_HINTS, ['↑↓', 'move'], ['esc', 'cancel']],
122
- tree: [['⏎', 'load'], ['↑↓', 'move'], ['←', 'fold'], ['→', 'unfold / vars'], ...DRAFT_OP_HINTS, ['t/esc', 'back']],
133
+ 'overlay-hosts': [
134
+ ['⏎', 'pick run host'],
135
+ ['↑↓', 'move'],
136
+ ['esc', 'cancel'],
137
+ ],
138
+ 'overlay-copy': [['⏎/esc', 'close']],
139
+ tree: [
140
+ ['⏎', 'load'],
141
+ ['↑↓', 'move'],
142
+ ['←', 'fold'],
143
+ ['→', 'unfold / vars'],
144
+ ['/', 'filter'],
145
+ ...DRAFT_OP_HINTS,
146
+ ['t/esc', 'back'],
147
+ ],
123
148
  host: [
124
149
  ['⏎', 'run action'],
125
150
  ['↑↓', 'move'],
126
- ['h/esc', 'back'],
151
+ ['h', 'change host'],
152
+ ['a/esc', 'back'],
127
153
  ],
128
154
  preview: [
129
155
  ['←→', 'change'],
@@ -136,15 +162,19 @@ const MODE_KEYS: Partial<Record<string, Hint[]>> = {
136
162
  export const KeyBar = observer((p: { st: TuiSt }) => {
137
163
  const s = p.st
138
164
  const kind = s.selected?.[1].kind
139
- const modeHints: Hint[] = MODE_KEYS[s.mode] ?? [
140
- ['↑↓', 'select'],
141
- ['←', 'tree'],
142
- ...(kind ? (KIND_KEYS[kind] ?? []) : []),
143
- ]
144
- // keys already advertised by a panel title (t/v/p) or a header box (w/d/h)
165
+ const treeFiltering = s.mode === 'tree' && s.tree.filtering
166
+ const modeHints: Hint[] = treeFiltering
167
+ ? [
168
+ ['type', 'filter'],
169
+ ['⏎', 'load'],
170
+ ['↑↓', 'move'],
171
+ ['esc', 'clear'],
172
+ ]
173
+ : (MODE_KEYS[s.mode] ?? [['↑↓', 'select'], ['←', 'tree'], ...(kind ? (KIND_KEYS[kind] ?? []) : [])])
174
+ // keys already advertised by a panel title (t/v/p) or a header box (w/d/h/a)
145
175
  // are NOT repeated here — one letter, one place
146
176
  const globalHints: Hint[] =
147
- s.mode === 'nav' || s.mode === 'tree' || s.mode === 'host' || s.mode === 'preview'
177
+ !treeFiltering && (s.mode === 'nav' || s.mode === 'tree' || s.mode === 'host' || s.mode === 'preview')
148
178
  ? [
149
179
  ['r', 'run'],
150
180
  ['s', 'reroll+run'],