comfy-ts 1.0.0 → 1.1.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 (124) hide show
  1. package/README.md +42 -6
  2. package/dist/{DefinedWorkflow-O3ynII3Y.js → DefinedWorkflow-BYyu5dK9.js} +76 -5
  3. package/dist/DefinedWorkflow-BYyu5dK9.js.map +1 -0
  4. package/dist/cli.js +421 -308
  5. package/dist/cli.js.map +1 -1
  6. package/dist/index.cjs +394 -162
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +7426 -353
  9. package/dist/index.d.ts +7408 -335
  10. package/dist/index.js +393 -162
  11. package/dist/index.js.map +1 -1
  12. package/dist/{run-tui-BFhba_oG.js → run-tui-DZ22HDHI.js} +529 -78
  13. package/dist/run-tui-DZ22HDHI.js.map +1 -0
  14. package/examples/02-img2img-upload.cflow.ts +6 -17
  15. package/examples/05-comfy-cloud.cflow.ts +19 -35
  16. package/examples/README.md +30 -0
  17. package/examples/comfy-cloud/ace-step-t2a.cflow.ts +79 -0
  18. package/examples/comfy-cloud/anima-t2i.cflow.ts +57 -0
  19. package/examples/comfy-cloud/boogu-i2i.cflow.ts +76 -0
  20. package/examples/comfy-cloud/capybara-i2i.cflow.ts +85 -0
  21. package/examples/comfy-cloud/capybara-i2v.cflow.ts +90 -0
  22. package/examples/comfy-cloud/capybara-t2i.cflow.ts +67 -0
  23. package/examples/comfy-cloud/chatterbox-t2a.cflow.ts +79 -0
  24. package/examples/comfy-cloud/chroma-t2i.cflow.ts +62 -0
  25. package/examples/comfy-cloud/cloudHost.ts +41 -0
  26. package/examples/comfy-cloud/ernie-t2i.cflow.ts +59 -0
  27. package/examples/comfy-cloud/firered-i2i.cflow.ts +74 -0
  28. package/examples/comfy-cloud/flux1-i2i.cflow.ts +76 -0
  29. package/examples/comfy-cloud/flux1-t2i.cflow.ts +63 -0
  30. package/examples/comfy-cloud/flux2-i2i.cflow.ts +80 -0
  31. package/examples/comfy-cloud/flux2-t2i.cflow.ts +57 -0
  32. package/examples/comfy-cloud/hidream-i2i.cflow.ts +89 -0
  33. package/examples/comfy-cloud/hidream-t2i.cflow.ts +65 -0
  34. package/examples/comfy-cloud/hunyuan-video-i2v.cflow.ts +93 -0
  35. package/examples/comfy-cloud/hunyuan-video-t2v.cflow.ts +74 -0
  36. package/examples/comfy-cloud/ideogram4-t2i.cflow.ts +80 -0
  37. package/examples/comfy-cloud/kandinsky5-i2v.cflow.ts +95 -0
  38. package/examples/comfy-cloud/kandinsky5-t2i.cflow.ts +60 -0
  39. package/examples/comfy-cloud/kandinsky5-t2v.cflow.ts +78 -0
  40. package/examples/comfy-cloud/krea2-t2i.cflow.ts +59 -0
  41. package/examples/comfy-cloud/lens-t2i.cflow.ts +62 -0
  42. package/examples/comfy-cloud/longcat-i2i.cflow.ts +74 -0
  43. package/examples/comfy-cloud/longcat-t2i.cflow.ts +65 -0
  44. package/examples/comfy-cloud/ltxv-i2v.cflow.ts +92 -0
  45. package/examples/comfy-cloud/ltxv-t2v.cflow.ts +78 -0
  46. package/examples/comfy-cloud/newbie-t2i.cflow.ts +67 -0
  47. package/examples/comfy-cloud/omnigen2-i2i.cflow.ts +86 -0
  48. package/examples/comfy-cloud/omnigen2-t2i.cflow.ts +62 -0
  49. package/examples/comfy-cloud/ovis-t2i.cflow.ts +56 -0
  50. package/examples/comfy-cloud/pixeldit-t2i.cflow.ts +63 -0
  51. package/examples/comfy-cloud/qwen-image-i2i.cflow.ts +69 -0
  52. package/examples/comfy-cloud/qwen-image-t2i.cflow.ts +55 -0
  53. package/examples/comfy-cloud/sd35-t2i.cflow.ts +48 -0
  54. package/examples/comfy-cloud/sdk.d.ts +445 -57
  55. package/examples/comfy-cloud/sdxl-t2i.cflow.ts +69 -0
  56. package/examples/comfy-cloud/stable-audio-t2a.cflow.ts +53 -0
  57. package/examples/comfy-cloud/svd-i2v.cflow.ts +75 -0
  58. package/examples/comfy-cloud/wan21-i2v.cflow.ts +83 -0
  59. package/examples/comfy-cloud/wan21-t2v.cflow.ts +64 -0
  60. package/examples/comfy-cloud/wan22-5b-t2v.cflow.ts +69 -0
  61. package/examples/comfy-cloud/wan22-i2v.cflow.ts +107 -0
  62. package/examples/comfy-cloud/wan22-t2v.cflow.ts +98 -0
  63. package/examples/comfy-cloud/z-image-t2i.cflow.ts +62 -0
  64. package/examples/images/README.md +18 -0
  65. package/examples/images/bear_1024x1024.jpg +0 -0
  66. package/examples/images/deer_768x1344.jpg +0 -0
  67. package/examples/images/dog_512x512.jpg +0 -0
  68. package/examples/images/lioness_768x768.jpg +0 -0
  69. package/examples/images/pug_200x300.jpg +0 -0
  70. package/examples/images/walrus_1344x768.jpg +0 -0
  71. package/guide-for-agents.md +7 -1
  72. package/package.json +15 -4
  73. package/src/cli/tui/components/PreviewPanel.tsx +9 -8
  74. package/src/cli/tui/components/StatusBar.tsx +11 -0
  75. package/src/cli/tui/components/TuiApp.tsx +18 -0
  76. package/src/cli/tui/discoverWorkflows.ts +7 -41
  77. package/src/cli/tui/imagePicker/ImagePickerOverlay.tsx +72 -0
  78. package/src/cli/tui/imagePicker/ImagePickerSt.ts +288 -0
  79. package/src/cli/tui/imagePicker/fsListing.ts +46 -0
  80. package/src/cli/tui/imagePicker/pickerPrefs.ts +78 -0
  81. package/src/cli/tui/run-tui.tsx +2 -1
  82. package/src/cli/tui/state/LorasSt.ts +14 -36
  83. package/src/cli/tui/state/PreviewSt.ts +28 -2
  84. package/src/cli/tui/state/TuiSt.ts +6 -0
  85. package/src/exampleAssets.ts +56 -0
  86. package/src/graph/ComfyNode.ts +4 -1
  87. package/src/index.ts +7 -0
  88. package/src/manager/ComfyRegistry.ts +37 -9
  89. package/src/manager/generated/KnownComfyCustomNodeName.ts +23852 -1926
  90. package/src/manager/generated/KnownComfyPluginTitle.ts +6854 -236
  91. package/src/manager/generated/KnownComfyPluginURL.ts +3425 -111
  92. package/src/manager/generated/KnownModel_Base.ts +23 -7
  93. package/src/manager/generated/KnownModel_FileName.ts +421 -0
  94. package/src/manager/generated/KnownModel_Name.ts +421 -0
  95. package/src/manager/generated/KnownModel_SavePath.ts +34 -8
  96. package/src/manager/generated/KnownModel_Type.ts +18 -14
  97. package/src/manager/json/alter-list.json +221 -221
  98. package/src/manager/json/custom-node-list.json +61020 -21946
  99. package/src/manager/json/extension-node-map.json +81077 -31176
  100. package/src/manager/json/github-stats.json +29321 -12601
  101. package/src/manager/json/model-list.json +5935 -4997
  102. package/src/manager/loaders/parseReport.ts +55 -0
  103. package/src/manager/loaders/step1_downloadComfyManagerJSONs.ts +15 -49
  104. package/src/manager/loaders/step2_custom-node-list-loader.ts +38 -83
  105. package/src/manager/loaders/step3_extension-node-map-loader.ts +36 -142
  106. package/src/manager/loaders/step4_model-list-loader.ts +25 -36
  107. package/src/manager/loaders/step5_alter-list-loader.ts +29 -0
  108. package/src/manager/loaders/step6_github-stats-loader.ts +23 -0
  109. package/src/manager/script-update-manager.bun.ts +9 -1
  110. package/src/manager/types/ComfyManagerAlterInfo.ts +13 -0
  111. package/src/manager/types/ComfyManagerFileModelInfo.ts +7 -3
  112. package/src/manager/types/ComfyManagerFilePluginContent.ts +6 -9
  113. package/src/manager/types/ComfyManagerFilePluginList.ts +3 -3
  114. package/src/manager/types/ComfyManagerGithubStats.ts +9 -0
  115. package/src/manager/types/ComfyManagerPluginContentMetadata.ts +2 -3
  116. package/src/manager/types/ComfyManagerPluginInfo.ts +48 -34
  117. package/src/sdk-generator/ComfySchema.ts +14 -1
  118. package/src/sdk-generator/comfyui-sdk-codegen.ts +15 -0
  119. package/src/sdk-generator/inputWidgetKind.ts +17 -0
  120. package/src/vars/ComfyVars.ts +82 -2
  121. package/src/vars/DefinedWorkflow.ts +7 -2
  122. package/dist/DefinedWorkflow-O3ynII3Y.js.map +0 -1
  123. package/dist/run-tui-BFhba_oG.js.map +0 -1
  124. package/src/utils/tryExtracting.ts +0 -41
@@ -0,0 +1,79 @@
1
+ // chatterbox t2a on Comfy Cloud — Chatterbox Multilingual TTS: text to speech in 23 languages, mp3 out
2
+ // source template: audio-chatterbox_tts_multilingual.json (official workflow-templates)
3
+ // needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
4
+ // run directly: bun examples/comfy-cloud/chatterbox-t2a.cflow.ts ["text"] [seed]
5
+ import { v } from 'comfy-ts'
6
+ import { cloudHost, requireCloudKey } from './cloudHost.ts'
7
+
8
+ const host = await cloudHost()
9
+
10
+ export const chatterboxT2a = host.defineWorkflow({
11
+ id: 'chatterbox-t2a',
12
+ vars: {
13
+ // ONE prompt var: the text to speak (`//` lines are comments)
14
+ prompt: v.prompt(
15
+ 'Hola amigos, bienvenidos de nuevo a ComfyUI.\nHoy vamos a explorar Chatterbox, síntesis de voz multilingüe en Comfy Cloud.',
16
+ ),
17
+ seed: v.seed(42),
18
+ language: v.choice(
19
+ [
20
+ 'Arabic (ar)',
21
+ 'Chinese (zh)',
22
+ 'Danish (da)',
23
+ 'Dutch (nl)',
24
+ 'English (en)',
25
+ 'Finnish (fi)',
26
+ 'French (fr)',
27
+ 'German (de)',
28
+ 'Greek (el)',
29
+ 'Hebrew (he)',
30
+ 'Hindi (hi)',
31
+ 'Italian (it)',
32
+ 'Japanese (ja)',
33
+ 'Korean (ko)',
34
+ 'Malay (ms)',
35
+ 'Norwegian (no)',
36
+ 'Polish (pl)',
37
+ 'Portuguese (pt)',
38
+ 'Russian (ru)',
39
+ 'Spanish (es)',
40
+ 'Swahili (sw)',
41
+ 'Swedish (sv)',
42
+ 'Turkish (tr)',
43
+ ],
44
+ 'Spanish (es)',
45
+ ),
46
+ exaggeration: v.float(0.5, { min: 0, max: 2 }),
47
+ cfgWeight: v.float(0.5, { min: 0, max: 1 }),
48
+ temperature: v.float(0.8, { min: 0.05, max: 2 }),
49
+ },
50
+ build: (b, vars) => {
51
+ const speech = b['Fill-ChatterBox.FL_ChatterboxMultilingualTTS']({
52
+ text: vars.prompt.positive,
53
+ language: vars.language,
54
+ exaggeration: vars.exaggeration,
55
+ cfg_weight: vars.cfgWeight,
56
+ temperature: vars.temperature,
57
+ repetition_penalty: 2,
58
+ min_p: 0.05,
59
+ top_p: 1,
60
+ seed: vars.seed,
61
+ use_cpu: false,
62
+ keep_model_loaded: false,
63
+ })
64
+ b.SaveAudioMP3({ audio: speech, filename_prefix: 'comfy-ts-zoo/chatterbox-t2a', quality: 'V0' })
65
+ },
66
+ })
67
+
68
+ export default chatterboxT2a
69
+
70
+ // standalone run (skipped when another driver — e.g. the TUI — imports this module)
71
+ if (import.meta.main) {
72
+ requireCloudKey()
73
+ if (process.argv[2]) chatterboxT2a.vars.prompt.set(process.argv[2])
74
+ if (process.argv[3]) chatterboxT2a.vars.seed.set(Number(process.argv[3]))
75
+ const execution = await chatterboxT2a.run({ log: true })
76
+ // SaveAudio outputs land host side (no auto-download for audio yet)
77
+ console.log(`🟢 ${execution.status}: audio saved on the host under comfy-ts-zoo/chatterbox-t2a`)
78
+ host.disconnect()
79
+ }
@@ -0,0 +1,62 @@
1
+ // chroma t2i on Comfy Cloud — Chroma1-HD (fp8, T5-XXL text encoder), real cfg with a negative prompt
2
+ // source template: image_chroma_text_to_image.json (official workflow-templates)
3
+ // needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
4
+ // run directly: bun examples/comfy-cloud/chroma-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 chromaT2i = host.defineWorkflow({
11
+ id: 'chroma-t2i',
12
+ vars: {
13
+ // ONE prompt var: `- ` lines are the NEGATIVE prompt, `//` lines are comments
14
+ prompt: v.prompt(
15
+ 'nature documentary close-up photograph of a tiger face, highly detailed speckled eye, intricate fur, natural light, subtle shadows, unfiltered amateur photography\n- low quality blurred sketch, chromatic aberrations, oversaturated, toony flat colors',
16
+ ),
17
+ seed: v.seed(42),
18
+ steps: v.int(26, { min: 1, max: 50 }),
19
+ cfg: v.float(3.5, { min: 0, max: 30 }),
20
+ size: v.size({ width: 1024, height: 1024 }),
21
+ },
22
+ build: (b, vars) => {
23
+ const model = b.ModelSamplingAuraFlow({
24
+ model: b.UNETLoader({ unet_name: 'Chroma1-HD-fp8mixed.safetensors', weight_dtype: 'default' }),
25
+ shift: 1,
26
+ })
27
+ // chroma rides a padding-free T5 tokenizer, per the template
28
+ const clip = b.T5TokenizerOptions({
29
+ clip: b.CLIPLoader({ clip_name: 't5xxl_fp8_e4m3fn_scaled.safetensors', type: 'chroma', device: 'default' }),
30
+ min_padding: 0,
31
+ min_length: 0,
32
+ })
33
+ const samples = b.KSampler({
34
+ model,
35
+ positive: b.CLIPTextEncode({ clip, text: vars.prompt.positive }),
36
+ negative: b.CLIPTextEncode({ clip, text: vars.prompt.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: vars.cfg,
41
+ sampler_name: 'euler',
42
+ scheduler: 'beta',
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/chroma-t2i',
48
+ })
49
+ },
50
+ })
51
+
52
+ export default chromaT2i
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]) chromaT2i.vars.prompt.set(process.argv[2])
58
+ if (process.argv[3]) chromaT2i.vars.seed.set(Number(process.argv[3]))
59
+ const execution = await chromaT2i.run({ log: true })
60
+ for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
61
+ host.disconnect()
62
+ }
@@ -0,0 +1,41 @@
1
+ // shared Comfy Cloud host for every cloud example (agent/examples.md owns the
2
+ // pattern). NOT a .cflow file, so the TUI never lists it as a workflow.
3
+ // import-safe on a keyless machine: nothing here throws — standalone blocks
4
+ // call requireCloudKey() first, TUI runs fail with ONE typed 401 per attempt.
5
+ import { type ComfyHost, ComfyTS } from 'comfy-ts'
6
+
7
+ export const CLOUD_KEY_ENV = 'COMFY_CLOUD_API_KEY'
8
+
9
+ export function cloudApiKey(): string | undefined {
10
+ const key = process.env[CLOUD_KEY_ENV]
11
+ return key == null || key === '' ? undefined : key
12
+ }
13
+
14
+ /** standalone runs call this FIRST: fail fast, name the fix */
15
+ export function requireCloudKey(): string {
16
+ const key = cloudApiKey()
17
+ if (key == null)
18
+ throw new Error(
19
+ `[comfy-cloud examples] ${CLOUD_KEY_ENV} is not set — export your Comfy Cloud API key (https://cloud.comfy.org, paid tiers) before running`,
20
+ )
21
+ return key
22
+ }
23
+
24
+ /**
25
+ * THE comfy-cloud host: the registry dedupes by id, so every example importing
26
+ * this helper shares one instance and one ws. Schema comes from the cache
27
+ * (offline import); run() connects lazily. sdkAutoWrite stays false — the
28
+ * catalog home is the COMMITTED examples/comfy-cloud/sdk.d.ts (gen:sdk:cloud),
29
+ * a live connect must never shadow it.
30
+ */
31
+ export async function cloudHost(): Promise<ComfyHost<'comfy-cloud'>> {
32
+ const comfy = ComfyTS.create()
33
+ const host = comfy.host({
34
+ id: 'comfy-cloud',
35
+ url: 'https://cloud.comfy.org',
36
+ apiKey: cloudApiKey(),
37
+ sdkAutoWrite: false,
38
+ })
39
+ await host.loadSchemaFromCache()
40
+ return host
41
+ }
@@ -0,0 +1,59 @@
1
+ // ernie t2i on Comfy Cloud — ERNIE Image Turbo (Baidu), 8-step distilled text to image (cfg 1, flux2 vae)
2
+ // source template: image_ernie_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/ernie-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 ernieT2i = host.defineWorkflow({
11
+ id: 'ernie-t2i',
12
+ vars: {
13
+ // ONE prompt var: `- ` lines are the NEGATIVE prompt, `//` lines are comments
14
+ prompt: v.prompt(
15
+ 'side-profile portrait of a young woman with sleek dark hair in a low bun, white ruffled-collar shirt, deep indigo twilight sky, neon pink-orange rim light tracing her profile, cinematic color blocking',
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.UNETLoader({ unet_name: 'ernie-image-turbo.safetensors', weight_dtype: 'default' })
23
+ const clip = b.CLIPLoader({ clip_name: 'ministral-3-3b.safetensors', type: 'flux2', device: 'default' })
24
+ const positive = b.CLIPTextEncode({ clip, text: vars.prompt.positive })
25
+ // turbo distill: no negative lines → zeroed-out conditioning (the template's own default)
26
+ const negative =
27
+ vars.prompt.negative === ''
28
+ ? b.ConditioningZeroOut({ conditioning: positive })
29
+ : b.CLIPTextEncode({ clip, text: vars.prompt.negative })
30
+ const samples = b.KSampler({
31
+ model,
32
+ positive,
33
+ negative,
34
+ latent_image: b.EmptyFlux2LatentImage({ width: vars.size.width, height: vars.size.height, batch_size: 1 }),
35
+ seed: vars.seed,
36
+ steps: vars.steps,
37
+ cfg: 1,
38
+ sampler_name: 'euler',
39
+ scheduler: 'simple',
40
+ denoise: 1,
41
+ })
42
+ b.SaveImage({
43
+ images: b.VAEDecode({ samples, vae: b.VAELoader({ vae_name: 'flux2-vae.safetensors' }) }),
44
+ filename_prefix: 'comfy-ts-zoo/ernie-t2i',
45
+ })
46
+ },
47
+ })
48
+
49
+ export default ernieT2i
50
+
51
+ // standalone run (skipped when another driver — e.g. the TUI — imports this module)
52
+ if (import.meta.main) {
53
+ requireCloudKey()
54
+ if (process.argv[2]) ernieT2i.vars.prompt.set(process.argv[2])
55
+ if (process.argv[3]) ernieT2i.vars.seed.set(Number(process.argv[3]))
56
+ const execution = await ernieT2i.run({ log: true })
57
+ for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
58
+ host.disconnect()
59
+ }
@@ -0,0 +1,74 @@
1
+ // firered i2i on Comfy Cloud — FireRed Image Edit 1.1, instruction-driven image editing (qwen-image-edit lineage)
2
+ // source template: image_firered_image_edit1_1.json (official workflow-templates)
3
+ // needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
4
+ // run directly: bun examples/comfy-cloud/firered-i2i.cflow.ts [path/to/image.png] ["edit instruction"]
5
+ import { asAbsolutePath, exampleImagePath, MediaImage, v } from 'comfy-ts'
6
+ import { cloudHost, requireCloudKey } from './cloudHost.ts'
7
+
8
+ const host = await cloudHost()
9
+
10
+ // bundled default input (examples/images/, ships in the tarball) — the TUI picker or argv[2] swap it
11
+ const image = v.image(exampleImagePath('bear_1024x1024.jpg'))
12
+
13
+ export const fireredI2i = host.defineWorkflow({
14
+ id: 'firered-i2i',
15
+ vars: {
16
+ image,
17
+ prompt: v.prompt(
18
+ 'restyle the outfit into sheer frosted white fabric with glowing fiber-optic threads, photorealistic',
19
+ ),
20
+ seed: v.seed(43),
21
+ // template defaults: 40 steps / cfg 4 (its optional 8-step Lightning lora branch ships off, dropped here)
22
+ steps: v.int(40, { min: 1, max: 60 }),
23
+ cfg: v.float(4, { min: 0, max: 30 }),
24
+ },
25
+ // async build: the input image is uploaded (hash-named, deduped) per run
26
+ build: async (b, vars, wf) => {
27
+ const img = new MediaImage({ path: asAbsolutePath(image.absPath()) })
28
+ const scaled = b.ImageScaleToTotalPixels({
29
+ image: await img.loadInWorkflow_viaLoadImageNode(wf),
30
+ upscale_method: 'lanczos',
31
+ megapixels: 1,
32
+ })
33
+ const clip = b.CLIPLoader({ clip_name: 'qwen_2.5_vl_7b_fp8_scaled.safetensors', type: 'qwen_image' })
34
+ const vae = b.VAELoader({ vae_name: 'qwen_image_vae.safetensors' })
35
+ // edit conditioning reads the input image itself: both branches reference it
36
+ const encode = (text: string) => b.TextEncodeQwenImageEditPlus({ prompt: text, clip, vae, image1: scaled })
37
+ const model = b.CFGNorm({
38
+ model: b.ModelSamplingAuraFlow({
39
+ model: b.UNETLoader({
40
+ unet_name: 'FireRed-Image-Edit-1.1-transformer.safetensors',
41
+ weight_dtype: 'default',
42
+ }),
43
+ shift: 3.1,
44
+ }),
45
+ strength: 1,
46
+ pre_cfg: false,
47
+ })
48
+ const samples = b.KSampler({
49
+ model,
50
+ positive: encode(vars.prompt.positive),
51
+ negative: encode(vars.prompt.negative),
52
+ latent_image: b.VAEEncode({ pixels: scaled, vae }),
53
+ seed: vars.seed,
54
+ steps: vars.steps,
55
+ cfg: vars.cfg,
56
+ sampler_name: 'euler',
57
+ scheduler: 'simple',
58
+ denoise: 1,
59
+ })
60
+ b.SaveImage({ images: b.VAEDecode({ samples, vae }), filename_prefix: 'comfy-ts-zoo/firered-i2i' })
61
+ },
62
+ })
63
+
64
+ export default fireredI2i
65
+
66
+ // standalone run (skipped when another driver — e.g. the TUI — imports this module)
67
+ if (import.meta.main) {
68
+ requireCloudKey()
69
+ if (process.argv[2]) fireredI2i.vars.image.set(process.argv[2])
70
+ if (process.argv[3]) fireredI2i.vars.prompt.set(process.argv[3])
71
+ const execution = await fireredI2i.run({ log: true })
72
+ for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
73
+ host.disconnect()
74
+ }
@@ -0,0 +1,76 @@
1
+ // flux1 i2i on Comfy Cloud — Flux.1 Kontext Dev image editing: reference latent steers the edit
2
+ // source template: flux_kontext_dev_basic.json (official workflow-templates)
3
+ // needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
4
+ // run directly: bun examples/comfy-cloud/flux1-i2i.cflow.ts [path/to/image.png] ["prompt"]
5
+ import { asAbsolutePath, exampleImagePath, MediaImage, v } from 'comfy-ts'
6
+ import { cloudHost, requireCloudKey } from './cloudHost.ts'
7
+
8
+ const host = await cloudHost()
9
+
10
+ // bundled default input (examples/images/, ships in the tarball) — the TUI picker or argv[2] swap it
11
+ const image = v.image(exampleImagePath('bear_1024x1024.jpg'))
12
+
13
+ export const flux1I2i = host.defineWorkflow({
14
+ id: 'flux1-i2i',
15
+ vars: {
16
+ image,
17
+ prompt: v.prompt('turn this into a watercolor painting, keep the composition'),
18
+ seed: v.seed(42),
19
+ steps: v.int(20, { min: 1, max: 50 }),
20
+ guidance: v.float(2.5, { min: 0, max: 10 }),
21
+ },
22
+ // async build: the input image is uploaded (hash-named, deduped) per run
23
+ build: async (b, vars, wf) => {
24
+ const img = new MediaImage({ path: asAbsolutePath(image.absPath()) })
25
+ const loaded = await img.loadInWorkflow_viaLoadImageNode(wf)
26
+
27
+ const model = b.UNETLoader({ unet_name: 'flux1-dev-kontext_fp8_scaled.safetensors', weight_dtype: 'default' })
28
+ const clip = b.DualCLIPLoader({
29
+ clip_name1: 'clip_l.safetensors',
30
+ clip_name2: 't5xxl_fp8_e4m3fn_scaled.safetensors',
31
+ type: 'flux',
32
+ device: 'default',
33
+ })
34
+ const vae = b.VAELoader({ vae_name: 'ae.safetensors' })
35
+
36
+ // kontext wants its reference at a supported resolution; the edit denoises
37
+ // fully (denoise 1) — the input steers through the reference latent
38
+ const latent = b.VAEEncode({ pixels: b.FluxKontextImageScale({ image: loaded }), vae })
39
+
40
+ const encoded = b.CLIPTextEncode({ clip, text: vars.prompt.positive })
41
+ const positive = b.FluxGuidance({
42
+ conditioning: b.ReferenceLatent({ conditioning: encoded, latent }),
43
+ guidance: vars.guidance,
44
+ })
45
+ const negative =
46
+ vars.prompt.negative === ''
47
+ ? b.ConditioningZeroOut({ conditioning: encoded })
48
+ : b.CLIPTextEncode({ clip, text: vars.prompt.negative })
49
+
50
+ const samples = b.KSampler({
51
+ model,
52
+ positive,
53
+ negative,
54
+ latent_image: latent,
55
+ seed: vars.seed,
56
+ steps: vars.steps,
57
+ cfg: 1,
58
+ sampler_name: 'euler',
59
+ scheduler: 'simple',
60
+ denoise: 1,
61
+ })
62
+ b.SaveImage({ images: b.VAEDecode({ samples, vae }), filename_prefix: 'comfy-ts-zoo/flux1-i2i' })
63
+ },
64
+ })
65
+
66
+ export default flux1I2i
67
+
68
+ // standalone run (skipped when another driver — e.g. the TUI — imports this module)
69
+ if (import.meta.main) {
70
+ requireCloudKey()
71
+ if (process.argv[2]) flux1I2i.vars.image.set(process.argv[2])
72
+ if (process.argv[3]) flux1I2i.vars.prompt.set(process.argv[3])
73
+ const execution = await flux1I2i.run({ log: true })
74
+ for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
75
+ host.disconnect()
76
+ }
@@ -0,0 +1,63 @@
1
+ // flux1 t2i on Comfy Cloud — Flux.1 Dev (UNET + dual CLIP), guidance-distilled: cfg 1, zeroed negative
2
+ // source template: flux_dev_checkpoint_example.json (official workflow-templates)
3
+ // needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
4
+ // run directly: bun examples/comfy-cloud/flux1-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 flux1T2i = host.defineWorkflow({
11
+ id: 'flux1-t2i',
12
+ vars: {
13
+ prompt: v.prompt(
14
+ 'photography portrait of an artist, messy casual bun, smiling at the camera, cinematic soft daylight, shallow depth of field, film grain, high detail',
15
+ ),
16
+ seed: v.seed(42),
17
+ steps: v.int(20, { min: 1, max: 50 }),
18
+ size: v.size({ width: 1024, height: 1024 }),
19
+ },
20
+ build: (b, vars) => {
21
+ const model = b.UNETLoader({ unet_name: 'flux1-dev.safetensors', weight_dtype: 'default' })
22
+ const clip = b.DualCLIPLoader({
23
+ clip_name1: 'clip_l.safetensors',
24
+ clip_name2: 't5xxl_fp16.safetensors',
25
+ type: 'flux',
26
+ device: 'default',
27
+ })
28
+ const vae = b.VAELoader({ vae_name: 'ae.safetensors' })
29
+
30
+ const positive = b.CLIPTextEncode({ clip, text: vars.prompt.positive })
31
+ // distilled model ignores cfg: empty negative stays zeroed out, like the template
32
+ const negative =
33
+ vars.prompt.negative === ''
34
+ ? b.ConditioningZeroOut({ conditioning: positive })
35
+ : b.CLIPTextEncode({ clip, text: vars.prompt.negative })
36
+
37
+ const samples = b.KSampler({
38
+ model,
39
+ positive,
40
+ negative,
41
+ latent_image: b.EmptySD3LatentImage({ width: vars.size.width, height: vars.size.height, batch_size: 1 }),
42
+ seed: vars.seed,
43
+ steps: vars.steps,
44
+ cfg: 1,
45
+ sampler_name: 'euler',
46
+ scheduler: 'simple',
47
+ denoise: 1,
48
+ })
49
+ b.SaveImage({ images: b.VAEDecode({ samples, vae }), filename_prefix: 'comfy-ts-zoo/flux1-t2i' })
50
+ },
51
+ })
52
+
53
+ export default flux1T2i
54
+
55
+ // standalone run (skipped when another driver — e.g. the TUI — imports this module)
56
+ if (import.meta.main) {
57
+ requireCloudKey()
58
+ if (process.argv[2]) flux1T2i.vars.prompt.set(process.argv[2])
59
+ if (process.argv[3]) flux1T2i.vars.seed.set(Number(process.argv[3]))
60
+ const execution = await flux1T2i.run({ log: true })
61
+ for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
62
+ host.disconnect()
63
+ }
@@ -0,0 +1,80 @@
1
+ // flux2 i2i on Comfy Cloud — FLUX.2 Klein 4B distilled image edit (prompt-driven, 4 steps, cfg 1)
2
+ // source template: image_flux2_klein_image_edit_4b_distilled.json (official workflow-templates)
3
+ // needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
4
+ // run directly: bun examples/comfy-cloud/flux2-i2i.cflow.ts [path/to/image.png] ["edit prompt"] [seed]
5
+ import { asAbsolutePath, exampleImagePath, MediaImage, v } from 'comfy-ts'
6
+ import { cloudHost, requireCloudKey } from './cloudHost.ts'
7
+
8
+ const host = await cloudHost()
9
+
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'))
12
+
13
+ export const flux2I2i = host.defineWorkflow({
14
+ id: 'flux2-i2i',
15
+ vars: {
16
+ image,
17
+ prompt: v.prompt('Change the color to blue.'),
18
+ seed: v.seed(7),
19
+ steps: v.int(4, { min: 1, max: 60 }),
20
+ },
21
+ // async build: the input image is uploaded (hash-named, deduped) per run
22
+ build: async (b, vars, wf) => {
23
+ const img = new MediaImage({ path: asAbsolutePath(image.absPath()) })
24
+ const loaded = await img.loadInWorkflow_viaLoadImageNode(wf)
25
+
26
+ const model = b.UNETLoader({ unet_name: 'flux-2-klein-4b-fp8.safetensors', weight_dtype: 'default' })
27
+ const clip = b.CLIPLoader({ clip_name: 'qwen_3_4b.safetensors', type: 'flux2', device: 'default' })
28
+ const vae = b.VAELoader({ vae_name: 'flux2-vae.safetensors' })
29
+
30
+ // reference image → ~1MP; its size drives both the latent and the scheduler
31
+ const scaled = b.ImageScaleToTotalPixels({
32
+ image: loaded,
33
+ upscale_method: 'nearest-exact',
34
+ megapixels: 1,
35
+ resolution_steps: 1,
36
+ })
37
+ const size = b.GetImageSize({ image: scaled })
38
+ const reference = b.VAEEncode({ pixels: scaled, vae })
39
+
40
+ // distilled: prompt only, the negative branch is the zeroed-out positive
41
+ const positive = b.CLIPTextEncode({ clip, text: vars.prompt.positive })
42
+ const samples = b.SamplerCustomAdvanced({
43
+ noise: b.RandomNoise({ noise_seed: vars.seed }),
44
+ guider: b.CFGGuider({
45
+ model,
46
+ positive: b.ReferenceLatent({ conditioning: positive, latent: reference }),
47
+ negative: b.ReferenceLatent({
48
+ conditioning: b.ConditioningZeroOut({ conditioning: positive }),
49
+ latent: reference,
50
+ }),
51
+ cfg: 1,
52
+ }),
53
+ sampler: b.KSamplerSelect({ sampler_name: 'euler' }),
54
+ sigmas: b.Flux2Scheduler({ steps: vars.steps, width: size.outputs.width, height: size.outputs.height }),
55
+ latent_image: b.EmptyFlux2LatentImage({
56
+ width: size.outputs.width,
57
+ height: size.outputs.height,
58
+ batch_size: 1,
59
+ }),
60
+ })
61
+ b.SaveImage({
62
+ images: b.VAEDecode({ samples: samples.outputs.output, vae }),
63
+ filename_prefix: 'comfy-ts-zoo/flux2-i2i',
64
+ })
65
+ },
66
+ })
67
+
68
+ export default flux2I2i
69
+
70
+ // standalone run (skipped when another driver — e.g. the TUI — imports this module)
71
+ if (import.meta.main) {
72
+ requireCloudKey()
73
+ if (process.argv[2]) flux2I2i.vars.image.set(process.argv[2])
74
+ if (process.argv[3]) flux2I2i.vars.prompt.set(process.argv[3])
75
+ if (process.argv[4]) flux2I2i.vars.seed.set(Number(process.argv[4]))
76
+
77
+ const execution = await flux2I2i.run({ log: true })
78
+ for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
79
+ host.disconnect()
80
+ }
@@ -0,0 +1,57 @@
1
+ // flux2 t2i on Comfy Cloud — FLUX.2 Klein base 4B, CFG-guided text to image
2
+ // source template: image_flux2_klein_text_to_image.json (official workflow-templates)
3
+ // needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
4
+ // run directly: bun examples/comfy-cloud/flux2-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 flux2T2i = host.defineWorkflow({
11
+ id: 'flux2-t2i',
12
+ vars: {
13
+ // ONE prompt var: `- ` lines are the NEGATIVE prompt, `//` lines are comments
14
+ prompt: v.prompt(
15
+ 'A hedgehog wearing a tiny party hat surrounded by confetti, early digital camera style, slight noise, flash photography, candid moment, 2000s digicam aesthetic, festive birthday celebration atmosphere',
16
+ ),
17
+ seed: v.seed(0),
18
+ steps: v.int(20, { min: 1, max: 60 }),
19
+ cfg: v.float(5, { min: 0, max: 30 }),
20
+ size: v.size({ width: 1024, height: 1024 }),
21
+ },
22
+ build: (b, vars) => {
23
+ const model = b.UNETLoader({ unet_name: 'flux-2-klein-base-4b.safetensors', weight_dtype: 'default' })
24
+ const clip = b.CLIPLoader({ clip_name: 'qwen_3_4b.safetensors', type: 'flux2', device: 'default' })
25
+ const vae = b.VAELoader({ vae_name: 'flux2-vae.safetensors' })
26
+
27
+ const samples = b.SamplerCustomAdvanced({
28
+ noise: b.RandomNoise({ noise_seed: vars.seed }),
29
+ guider: b.CFGGuider({
30
+ model,
31
+ positive: b.CLIPTextEncode({ clip, text: vars.prompt.positive }),
32
+ negative: b.CLIPTextEncode({ clip, text: vars.prompt.negative }),
33
+ cfg: vars.cfg,
34
+ }),
35
+ sampler: b.KSamplerSelect({ sampler_name: 'euler' }),
36
+ sigmas: b.Flux2Scheduler({ steps: vars.steps, width: vars.size.width, height: vars.size.height }),
37
+ latent_image: b.EmptyFlux2LatentImage({ width: vars.size.width, height: vars.size.height, batch_size: 1 }),
38
+ })
39
+ b.SaveImage({
40
+ images: b.VAEDecode({ samples: samples.outputs.output, vae }),
41
+ filename_prefix: 'comfy-ts-zoo/flux2-t2i',
42
+ })
43
+ },
44
+ })
45
+
46
+ export default flux2T2i
47
+
48
+ // standalone run (skipped when another driver — e.g. the TUI — imports this module)
49
+ if (import.meta.main) {
50
+ requireCloudKey()
51
+ if (process.argv[2]) flux2T2i.vars.prompt.set(process.argv[2])
52
+ if (process.argv[3]) flux2T2i.vars.seed.set(Number(process.argv[3]))
53
+
54
+ const execution = await flux2T2i.run({ log: true })
55
+ for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
56
+ host.disconnect()
57
+ }