comfy-ts 2.17.1 → 2.18.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 (80) hide show
  1. package/dist/cli.js +3 -3
  2. package/dist/index.cjs +944 -165
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +1154 -408
  5. package/dist/index.d.ts +1154 -408
  6. package/dist/index.js +944 -165
  7. package/dist/index.js.map +1 -1
  8. package/dist/{run-run-tg82jUIk.js → run-run-Wn7H72Zg.js} +2 -2
  9. package/dist/{run-run-tg82jUIk.js.map → run-run-Wn7H72Zg.js.map} +1 -1
  10. package/dist/{run-tui-Bw7BA75d.js → run-tui-VWSj1D_j.js} +2 -2
  11. package/dist/{run-tui-Bw7BA75d.js.map → run-tui-VWSj1D_j.js.map} +1 -1
  12. package/dist/serve-web.js +47 -47
  13. package/dist/{state-zTow5ucI.js → state-DgwWhZWb.js} +945 -166
  14. package/dist/state-DgwWhZWb.js.map +1 -0
  15. package/dist/web.d.ts +1172 -426
  16. package/dist/web.js +944 -165
  17. package/dist/web.js.map +1 -1
  18. package/examples/comfy-cloud/ace-step15-t2a.cflow.ts +163 -0
  19. package/examples/comfy-cloud/anima-t2i-base.cflow.ts +57 -0
  20. package/examples/comfy-cloud/boogu-t2i.cflow.ts +55 -0
  21. package/examples/comfy-cloud/chronoedit-i2i.cflow.ts +95 -0
  22. package/examples/comfy-cloud/ernie-t2i-base.cflow.ts +81 -0
  23. package/examples/comfy-cloud/flux1-t2i-krea.cflow.ts +63 -0
  24. package/examples/comfy-cloud/flux2-i2i-dev.cflow.ts +83 -0
  25. package/examples/comfy-cloud/flux2-t2i-dev.cflow.ts +60 -0
  26. package/examples/comfy-cloud/hidream-o1-i2i.cflow.ts +71 -0
  27. package/examples/comfy-cloud/hidream-o1-t2i.cflow.ts +62 -0
  28. package/examples/comfy-cloud/krea2-i2i.cflow.ts +78 -0
  29. package/examples/comfy-cloud/ltx2-i2v.cflow.ts +175 -0
  30. package/examples/comfy-cloud/ltx2-t2v.cflow.ts +143 -0
  31. package/examples/comfy-cloud/ltx23-i2v.cflow.ts +189 -0
  32. package/examples/comfy-cloud/ltx23-t2v.cflow.ts +151 -0
  33. package/examples/comfy-cloud/mage-flow-i2i-turbo.cflow.ts +72 -0
  34. package/examples/comfy-cloud/mage-flow-i2i.cflow.ts +74 -0
  35. package/examples/comfy-cloud/mage-flow-t2i-turbo.cflow.ts +60 -0
  36. package/examples/comfy-cloud/mage-flow-t2i.cflow.ts +60 -0
  37. package/examples/comfy-cloud/minimax-h3-t2i.cflow.ts +64 -0
  38. package/examples/comfy-cloud/netayume-t2i.cflow.ts +60 -0
  39. package/examples/comfy-cloud/qwen-image-i2i-2509.cflow.ts +75 -0
  40. package/examples/comfy-cloud/qwen-image-t2i-2512.cflow.ts +63 -0
  41. package/examples/comfy-cloud/sdk.d.ts +21683 -13737
  42. package/examples/comfy-cloud/stable-audio3-t2a.cflow.ts +96 -0
  43. package/examples/comfy-cloud/z-image-t2i-base.cflow.ts +54 -0
  44. package/examples/rvion/04-krea2-turbo-t2i.cflow.ts +1 -1
  45. package/package.json +2 -2
  46. package/src/graph/ComfyNode.ts +93 -12
  47. package/src/host/ComfyHost.ts +31 -10
  48. package/src/host/ComfyManager.ts +448 -62
  49. package/src/litegraph/CanonicalWorkflow.ts +3 -0
  50. package/src/litegraph/LiteGraphJSON.ts +2 -2
  51. package/src/litegraph/LiteGraphNodeInput.ts +2 -2
  52. package/src/litegraph/LiteGraphNodeOutput.ts +2 -2
  53. package/src/litegraph/convertFlowToLiteGraphJSON.ts +112 -37
  54. package/src/litegraph/expandSubgraphs.ts +14 -0
  55. package/src/litegraph/normalizeWorkflow.ts +1 -0
  56. package/src/manager/ComfyRegistry.ts +2 -0
  57. package/src/manager/generated/KnownComfyCustomNodeName.ts +6354 -1680
  58. package/src/manager/generated/KnownComfyPluginTitle.ts +718 -356
  59. package/src/manager/generated/KnownComfyPluginURL.ts +357 -181
  60. package/src/manager/generated/KnownModel_Base.ts +9 -5
  61. package/src/manager/generated/KnownModel_FileName.ts +135 -0
  62. package/src/manager/generated/KnownModel_Name.ts +135 -0
  63. package/src/manager/generated/KnownModel_SavePath.ts +16 -14
  64. package/src/manager/generated/KnownModel_Type.ts +15 -13
  65. package/src/manager/installedView.ts +176 -0
  66. package/src/manager/json/custom-node-list.json +4018 -2248
  67. package/src/manager/json/extension-node-map.json +8903 -2964
  68. package/src/manager/json/github-stats.json +10796 -10036
  69. package/src/manager/json/model-list.json +298 -1
  70. package/src/manager/loaders/step4_model-list-loader.ts +1 -0
  71. package/src/manager/types/ComfyManagerAPIModelList.ts +3 -0
  72. package/src/manager/types/ComfyManagerAPIPluginList.ts +19 -0
  73. package/src/runner/ComfyExecution.ts +4 -1
  74. package/src/runner/ComfyWsApi.ts +82 -15
  75. package/src/sdk-generator/ComfySchema.ts +10 -1
  76. package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +4 -1
  77. package/src/sdk-generator/comfyui-sdk-codegen.ts +61 -20
  78. package/src/sdk-generator/inputWidgetKind.ts +19 -4
  79. package/src/sdk-generator/litegraphToApiRequestPayload.ts +141 -33
  80. package/dist/state-zTow5ucI.js.map +0 -1
@@ -0,0 +1,71 @@
1
+ // hidream-o1 i2i on Comfy Cloud — HiDream-O1 Image dev fp8, instruction edit from a reference image (28 LCM steps, cfg 1)
2
+ // source template: image_hidream_o1_dev.json (official workflow-templates)
3
+ // needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
4
+ // run directly: bun examples/comfy-cloud/hidream-o1-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('walrus_1344x768.jpg'))
12
+
13
+ export const hidreamO1I2i = host.defineWorkflow({
14
+ id: 'hidream-o1-i2i',
15
+ vars: {
16
+ image,
17
+ // ONE prompt var: the edit instruction; `- ` lines are the NEGATIVE prompt
18
+ prompt: v.prompt(
19
+ 'Transform the background into a rainy neon city street at night, with wet asphalt reflections and blurred neon signs',
20
+ ),
21
+ seed: v.seed(42),
22
+ steps: v.int(28, { min: 1, max: 100 }),
23
+ },
24
+ // async build: the input image is uploaded (hash-named, deduped) per run
25
+ build: async (b, vars, wf) => {
26
+ const img = new MediaImage({ path: asAbsolutePath(image.absPath()) })
27
+ const loaded = await img.loadInWorkflow_viaLoadImageNode(wf)
28
+
29
+ const ckpt = b.CheckpointLoaderSimple({ ckpt_name: 'hidream_o1_image_dev_fp8_scaled.safetensors' })
30
+ // the dev model was trained at noise scale 7.6
31
+ const model = b.ModelNoiseScale({ model: ckpt.outputs.MODEL, noise_scale: 7.6 })
32
+ const clip = ckpt.outputs.CLIP
33
+ // the reference rides on both conditionings (up to 10 references: images.image_2, …)
34
+ const cond = b.HiDreamO1ReferenceImages({
35
+ positive: b.CLIPTextEncode({ clip, text: vars.prompt.positive }),
36
+ negative: b.CLIPTextEncode({ clip, text: vars.prompt.negative }),
37
+ 'images.image_1': loaded,
38
+ })
39
+ const samples = b.SamplerCustom({
40
+ model,
41
+ add_noise: true,
42
+ noise_seed: vars.seed,
43
+ // distilled: cfg 1, an LCM sampler with clipped noise
44
+ cfg: 1,
45
+ positive: cond.outputs.positive,
46
+ negative: cond.outputs.negative,
47
+ sampler: b.SamplerLCM({ s_noise: 1, s_noise_end: 1, noise_clip_std: 2.5 }),
48
+ sigmas: b.BasicScheduler({ model, scheduler: 'normal', steps: vars.steps, denoise: 1 }),
49
+ // the output keeps the reference's size, floored to the 32 px grid
50
+ latent_image: b.EmptyHiDreamO1LatentImage({
51
+ width: Math.floor(img.width_orCrash / 32) * 32,
52
+ height: Math.floor(img.height_orCrash / 32) * 32,
53
+ batch_size: 1,
54
+ }),
55
+ })
56
+ b.SaveImageWebsocket({ images: b.VAEDecode({ samples: samples.outputs.output, vae: ckpt.outputs.VAE }) })
57
+ },
58
+ })
59
+
60
+ export default hidreamO1I2i
61
+
62
+ // standalone run (skipped when another driver — e.g. the TUI — imports this module)
63
+ if (import.meta.main) {
64
+ requireCloudKey()
65
+ if (process.argv[2]) hidreamO1I2i.vars.image.set(process.argv[2])
66
+ if (process.argv[3]) hidreamO1I2i.vars.prompt.set(process.argv[3])
67
+ if (process.argv[4]) hidreamO1I2i.vars.seed.set(Number(process.argv[4]))
68
+ const execution = await hidreamO1I2i.run({ log: true, save: { prefix: 'comfy-ts-zoo/hidream-o1-i2i' } })
69
+ for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
70
+ host.disconnect()
71
+ }
@@ -0,0 +1,62 @@
1
+ // hidream-o1 t2i on Comfy Cloud — HiDream-O1 Image base bf16, native 2K text to image (40 steps, cfg 5, seam smoothing on the last 20%)
2
+ // source template: image_hidream_o1.json (official workflow-templates)
3
+ // needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
4
+ // run directly: bun examples/comfy-cloud/hidream-o1-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 hidreamO1T2i = host.defineWorkflow({
11
+ id: 'hidream-o1-t2i',
12
+ vars: {
13
+ // ONE prompt var: `- ` lines are the NEGATIVE prompt, `//` lines are comments
14
+ prompt: v.prompt(
15
+ 'Graceful female skincare shot, light natural makeup, holding an essence bottle, warm ivory backdrop, soft diffused light',
16
+ ),
17
+ seed: v.seed(42),
18
+ steps: v.int(40, { min: 1, max: 100 }),
19
+ cfg: v.float(5, { min: 1, max: 15 }),
20
+ // trained sizes: 2048x2048, 2304x1728, 2304x1792, 2496x1664, 2560x1440, 3104x1312 and their portrait twins
21
+ size: v.size({ width: 2048, height: 2048 }),
22
+ },
23
+ build: (b, vars) => {
24
+ const ckpt = b.CheckpointLoaderSimple({ ckpt_name: 'hidream_o1_image_bf16.safetensors' })
25
+ // the base model was trained at noise scale 8
26
+ const scaled = b.ModelNoiseScale({ model: ckpt.outputs.MODEL, noise_scale: 8 })
27
+ const clip = ckpt.outputs.CLIP
28
+ const samples = b.SamplerCustom({
29
+ // the patch-grid seam blend runs over the last 20% of the steps only
30
+ model: b.HiDreamO1PatchSeamSmoothing({
31
+ model: scaled,
32
+ start_percent: 0.8,
33
+ end_percent: 1,
34
+ pattern: 'single_shift',
35
+ passes: 'ramp_2_4',
36
+ blend: 'median',
37
+ strength: 1,
38
+ }),
39
+ add_noise: true,
40
+ noise_seed: vars.seed,
41
+ cfg: vars.cfg,
42
+ positive: b.CLIPTextEncode({ clip, text: vars.prompt.positive }),
43
+ negative: b.CLIPTextEncode({ clip, text: vars.prompt.negative }),
44
+ sampler: b.KSamplerSelect({ sampler_name: 'dpmpp_2m_sde_gpu' }),
45
+ sigmas: b.BasicScheduler({ model: scaled, scheduler: 'normal', steps: vars.steps, denoise: 1 }),
46
+ latent_image: b.EmptyHiDreamO1LatentImage({ width: vars.size.width, height: vars.size.height, batch_size: 1 }),
47
+ })
48
+ b.SaveImageWebsocket({ images: b.VAEDecode({ samples: samples.outputs.output, vae: ckpt.outputs.VAE }) })
49
+ },
50
+ })
51
+
52
+ export default hidreamO1T2i
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]) hidreamO1T2i.vars.prompt.set(process.argv[2])
58
+ if (process.argv[3]) hidreamO1T2i.vars.seed.set(Number(process.argv[3]))
59
+ const execution = await hidreamO1T2i.run({ log: true, save: { prefix: 'comfy-ts-zoo/hidream-o1-t2i' } })
60
+ for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
61
+ host.disconnect()
62
+ }
@@ -0,0 +1,78 @@
1
+ // krea2 i2i on Comfy Cloud — Krea 2 Turbo int8 + the style-reference lora: a new picture from the prompt, in the style of the input image (8 steps, cfg 1)
2
+ // source template: image_krea2_turbo_int8_image_style_reference.json (official workflow-templates)
3
+ // needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
4
+ // run directly: bun examples/comfy-cloud/krea2-i2i.cflow.ts [path/to/style.png] ["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('bear_1024x1024.jpg'))
12
+
13
+ export const krea2I2i = host.defineWorkflow({
14
+ id: 'krea2-i2i',
15
+ vars: {
16
+ // the STYLE reference: its look carries over, its content does not
17
+ image,
18
+ // ONE prompt var: what to draw, positive only (the negative is the zeroed-out positive)
19
+ prompt: v.prompt('a white yeti with horns reading a book in a snowy forest'),
20
+ seed: v.seed(42),
21
+ steps: v.int(8, { min: 1, max: 40 }),
22
+ size: v.size({ width: 1024, height: 1024 }),
23
+ },
24
+ // async build: the input image is uploaded (hash-named, deduped) per run
25
+ build: async (b, vars, wf) => {
26
+ const img = new MediaImage({ path: asAbsolutePath(image.absPath()) })
27
+ const loaded = await img.loadInWorkflow_viaLoadImageNode(wf)
28
+
29
+ const vae = b.VAELoader({ vae_name: 'qwen_image_vae.safetensors' })
30
+ const model = b.ModelSamplingFlux({
31
+ model: b.LoraLoaderModelOnly({
32
+ model: b.UNETLoader({ unet_name: 'krea2_turbo_int8_convrot.safetensors', weight_dtype: 'default' }),
33
+ lora_name: 'krea2_style_reference.safetensors',
34
+ strength_model: 1,
35
+ }),
36
+ max_shift: 1.15,
37
+ base_shift: 0.5,
38
+ width: vars.size.width,
39
+ height: vars.size.height,
40
+ })
41
+ // the reference enters as an edit-style image latent, indexed at timestep zero
42
+ const positive = b.FluxKontextMultiReferenceLatentMethod({
43
+ conditioning: b.TextEncodeQwenImageEditPlus({
44
+ clip: b.CLIPLoader({ clip_name: 'qwen3vl_4b_fp8_scaled.safetensors', type: 'krea2', device: 'default' }),
45
+ vae,
46
+ image1: loaded,
47
+ prompt: vars.prompt.positive,
48
+ }),
49
+ reference_latents_method: 'index_timestep_zero',
50
+ })
51
+ const samples = b.SamplerCustomAdvanced({
52
+ noise: b.RandomNoise({ noise_seed: vars.seed }),
53
+ guider: b.CFGGuider({
54
+ model,
55
+ positive,
56
+ negative: b.ConditioningZeroOut({ conditioning: positive }),
57
+ cfg: 1,
58
+ }),
59
+ sampler: b.KSamplerSelect({ sampler_name: 'euler' }),
60
+ sigmas: b.BasicScheduler({ model, scheduler: 'simple', steps: vars.steps, denoise: 1 }),
61
+ latent_image: b.EmptyLatentImage({ width: vars.size.width, height: vars.size.height, batch_size: 1 }),
62
+ })
63
+ b.SaveImageWebsocket({ images: b.VAEDecode({ samples: samples.outputs.output, vae }) })
64
+ },
65
+ })
66
+
67
+ export default krea2I2i
68
+
69
+ // standalone run (skipped when another driver — e.g. the TUI — imports this module)
70
+ if (import.meta.main) {
71
+ requireCloudKey()
72
+ if (process.argv[2]) krea2I2i.vars.image.set(process.argv[2])
73
+ if (process.argv[3]) krea2I2i.vars.prompt.set(process.argv[3])
74
+ if (process.argv[4]) krea2I2i.vars.seed.set(Number(process.argv[4]))
75
+ const execution = await krea2I2i.run({ log: true, save: { prefix: 'comfy-ts-zoo/krea2-i2i' } })
76
+ for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
77
+ host.disconnect()
78
+ }
@@ -0,0 +1,175 @@
1
+ // ltx2 i2v on Comfy Cloud — LTX-2 19b dev fp8, image to video WITH a generated soundtrack: a cfg pass, then a distilled-lora refine at x2
2
+ // source template: video_ltx2_i2v.json (official workflow-templates)
3
+ // needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
4
+ // note: video outputs PERSIST on the host (upstream ships no websocket saver for video — image examples stream ephemerally)
5
+ // run directly: bun examples/comfy-cloud/ltx2-i2v.cflow.ts [path/to/image.png] ["prompt"]
6
+ import { asAbsolutePath, exampleImagePath, MediaImage, v } from 'comfy-ts'
7
+ import { cloudHost, requireCloudKey } from './cloudHost.ts'
8
+
9
+ const host = await cloudHost()
10
+
11
+ // bundled default input (examples/images/, ships in the tarball) — the TUI picker or argv[2] swap it
12
+ const image = v.image(exampleImagePath('walrus_1344x768.jpg'))
13
+
14
+ const CKPT = 'ltx-2-19b-dev-fp8.safetensors'
15
+
16
+ export const ltx2I2v = host.defineWorkflow({
17
+ id: 'ltx2-i2v',
18
+ vars: {
19
+ image,
20
+ // ONE prompt var: describe actions over time, visuals AND sounds; `- ` lines are the NEGATIVE prompt
21
+ prompt: v.prompt(
22
+ 'The walrus slowly raises its head and looks around, whiskers twitching, its breath fogging in the cold air. Waves roll in and break on the rocks behind it, gulls call overhead, and it lets out a deep, rumbling bellow.\n- blurry, low quality, still frame, frames, watermark, overlay, titles, has blurbox, has subtitles',
23
+ ),
24
+ seed: v.seed(42),
25
+ // pass 1 only: the refine pass runs a fixed distilled schedule
26
+ steps: v.int(20, { min: 1, max: 60 }),
27
+ cfg: v.float(4, { min: 1, max: 10 }),
28
+ // the OUTPUT size: the start image is cropped to it, the first pass samples at half of it
29
+ size: v.size({ width: 1280, height: 720 }),
30
+ // 8n + 1 frames; another count snaps to the closest valid one
31
+ length: v.int(121, { min: 9, max: 481 }),
32
+ fps: v.int(25, { min: 1, max: 60 }),
33
+ },
34
+ // async build: the input image is uploaded (hash-named, deduped) per run
35
+ build: async (b, vars, wf) => {
36
+ const img = new MediaImage({ path: asAbsolutePath(image.absPath()) })
37
+ const loaded = await img.loadInWorkflow_viaLoadImageNode(wf)
38
+
39
+ const ckpt = b.CheckpointLoaderSimple({ ckpt_name: CKPT })
40
+ const clip = b.LTXAVTextEncoderLoader({
41
+ text_encoder: 'gemma_3_12B_it_fp4_mixed.safetensors',
42
+ ckpt_name: CKPT,
43
+ device: 'default',
44
+ })
45
+ const audioVae = b.LTXVAudioVAELoader({ ckpt_name: CKPT })
46
+
47
+ // the start image: center-cropped to the output size, longest side to 1536, then re-compressed the way ltx was trained on video frames
48
+ const start = b.LTXVPreprocess({
49
+ image: b.ImageScaleToMaxDimension({
50
+ image: b.ImageScale({
51
+ image: loaded,
52
+ upscale_method: 'lanczos',
53
+ width: vars.size.width,
54
+ height: vars.size.height,
55
+ crop: 'center',
56
+ }),
57
+ upscale_method: 'area',
58
+ largest_size: 1536,
59
+ }),
60
+ img_compression: 33,
61
+ }).outputs.output_image
62
+
63
+ const cond = b.LTXVConditioning({
64
+ positive: b.CLIPTextEncode({ clip, text: vars.prompt.positive }),
65
+ negative: b.CLIPTextEncode({ clip, text: vars.prompt.negative }),
66
+ frame_rate: vars.fps,
67
+ })
68
+ const noise = b.RandomNoise({ noise_seed: vars.seed })
69
+
70
+ // pass 1: the dev model with real cfg at half resolution, the start image written into the first frame
71
+ const avLatent = b.LTXVConcatAVLatent({
72
+ video_latent: b.LTXVImgToVideoInplace({
73
+ vae: ckpt.outputs.VAE,
74
+ image: start,
75
+ latent: b.EmptyLTXVLatentVideo({
76
+ width: Math.round(vars.size.width / 2),
77
+ height: Math.round(vars.size.height / 2),
78
+ length: vars.length,
79
+ batch_size: 1,
80
+ }),
81
+ strength: 1,
82
+ bypass: false,
83
+ }),
84
+ audio_latent: b.LTXVEmptyLatentAudio({
85
+ frames_number: vars.length,
86
+ frame_rate: vars.fps,
87
+ batch_size: 1,
88
+ audio_vae: audioVae,
89
+ }),
90
+ })
91
+ const base = b.SamplerCustomAdvanced({
92
+ noise,
93
+ guider: b.CFGGuider({
94
+ model: ckpt.outputs.MODEL,
95
+ positive: cond.outputs.positive,
96
+ negative: cond.outputs.negative,
97
+ cfg: vars.cfg,
98
+ }),
99
+ sampler: b.KSamplerSelect({ sampler_name: 'euler' }),
100
+ sigmas: b.LTXVScheduler({
101
+ steps: vars.steps,
102
+ max_shift: 2.05,
103
+ base_shift: 0.95,
104
+ stretch: true,
105
+ terminal: 0.1,
106
+ latent: avLatent,
107
+ }),
108
+ latent_image: avLatent,
109
+ })
110
+ const baseAv = b.LTXVSeparateAVLatent({ av_latent: base.outputs.output })
111
+ const cropped = b.LTXVCropGuides({
112
+ positive: cond.outputs.positive,
113
+ negative: cond.outputs.negative,
114
+ latent: baseAv.outputs.video_latent,
115
+ })
116
+
117
+ // pass 2: x2 latent upscale, the start image pinned again, then a short refine with the distilled lora at cfg 1
118
+ const refined = b.SamplerCustomAdvanced({
119
+ noise,
120
+ guider: b.CFGGuider({
121
+ model: b.LoraLoaderModelOnly({
122
+ model: ckpt.outputs.MODEL,
123
+ lora_name: 'ltx-2-19b-distilled-lora-384.safetensors',
124
+ strength_model: 1,
125
+ }),
126
+ positive: cropped.outputs.positive,
127
+ negative: cropped.outputs.negative,
128
+ cfg: 1,
129
+ }),
130
+ sampler: b.KSamplerSelect({ sampler_name: 'gradient_estimation' }),
131
+ sigmas: b.ManualSigmas({ sigmas: '0.909375, 0.725, 0.421875, 0.0' }),
132
+ latent_image: b.LTXVConcatAVLatent({
133
+ video_latent: b.LTXVImgToVideoInplace({
134
+ vae: ckpt.outputs.VAE,
135
+ image: start,
136
+ latent: b.LTXVLatentUpsampler({
137
+ samples: cropped.outputs.latent,
138
+ upscale_model: b.LatentUpscaleModelLoader({
139
+ model_name: 'ltx-2-spatial-upscaler-x2-1.0.safetensors',
140
+ }),
141
+ vae: ckpt.outputs.VAE,
142
+ }),
143
+ strength: 1,
144
+ bypass: false,
145
+ }),
146
+ audio_latent: baseAv.outputs.audio_latent,
147
+ }),
148
+ })
149
+ const av = b.LTXVSeparateAVLatent({ av_latent: refined.outputs.denoised_output })
150
+
151
+ b.SaveVideo({
152
+ video: b.CreateVideo({
153
+ images: b.VAEDecode({ samples: av.outputs.video_latent, vae: ckpt.outputs.VAE }),
154
+ audio: b.LTXVAudioVAEDecode({ samples: av.outputs.audio_latent, audio_vae: audioVae }),
155
+ fps: vars.fps,
156
+ }),
157
+ filename_prefix: 'comfy-ts-zoo/ltx2-i2v',
158
+ format: 'auto',
159
+ codec: 'auto',
160
+ })
161
+ },
162
+ })
163
+
164
+ export default ltx2I2v
165
+
166
+ // standalone run (skipped when another driver — e.g. the TUI — imports this module)
167
+ if (import.meta.main) {
168
+ requireCloudKey()
169
+ if (process.argv[2]) ltx2I2v.vars.image.set(process.argv[2])
170
+ if (process.argv[3]) ltx2I2v.vars.prompt.set(process.argv[3])
171
+ const execution = await ltx2I2v.run({ log: true })
172
+ // SaveVideo outputs land host side (no auto-download for video yet)
173
+ console.log(`🟢 ${execution.status}: video saved on the host under comfy-ts-zoo/ltx2-i2v`)
174
+ host.disconnect()
175
+ }
@@ -0,0 +1,143 @@
1
+ // ltx2 t2v on Comfy Cloud — LTX-2 19b dev fp8, text to video WITH a generated soundtrack: a cfg pass, then a distilled-lora refine at x2
2
+ // source template: video_ltx2_t2v.json (official workflow-templates)
3
+ // needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
4
+ // note: video outputs PERSIST on the host (upstream ships no websocket saver for video — image examples stream ephemerally)
5
+ // run directly: bun examples/comfy-cloud/ltx2-t2v.cflow.ts ["prompt"] [seed]
6
+ import { v } from 'comfy-ts'
7
+ import { cloudHost, requireCloudKey } from './cloudHost.ts'
8
+
9
+ const host = await cloudHost()
10
+
11
+ export const ltx2T2v = host.defineWorkflow({
12
+ id: 'ltx2-t2v',
13
+ vars: {
14
+ // ONE prompt var: describe actions over time, visuals AND sounds; `- ` lines are the NEGATIVE prompt
15
+ prompt: v.prompt(
16
+ 'A close-up of a cheerful girl puppet with curly auburn yarn hair and wide button eyes, holding a small red umbrella above her head. Rain falls gently around her. She looks upward and begins to sing with joy in English: "It\'s raining, it\'s raining, I love it when its raining." Her fabric mouth opens and closes to a melodic tune, she sways slightly from side to side in rhythm. The camera holds steady as the rain sparkles against the soft lighting.\n- blurry, low quality, still frame, frames, watermark, overlay, titles, has blurbox, has subtitles',
17
+ ),
18
+ seed: v.seed(42),
19
+ // pass 1 only: the refine pass runs a fixed distilled schedule
20
+ steps: v.int(20, { min: 1, max: 60 }),
21
+ cfg: v.float(4, { min: 1, max: 10 }),
22
+ // the OUTPUT size: the first pass samples at half of it, the latent upscaler doubles it
23
+ size: v.size({ width: 1280, height: 720 }),
24
+ // 8n + 1 frames; another count snaps to the closest valid one
25
+ length: v.int(121, { min: 9, max: 481 }),
26
+ fps: v.int(24, { min: 1, max: 60 }),
27
+ },
28
+ build: (b, vars) => {
29
+ const ckpt = b.CheckpointLoaderSimple({ ckpt_name: 'ltx-2-19b-dev-fp8.safetensors' })
30
+ const clip = b.LTXAVTextEncoderLoader({
31
+ text_encoder: 'gemma_3_12B_it_fp4_mixed.safetensors',
32
+ ckpt_name: 'ltx-2-19b-dev-fp8.safetensors',
33
+ device: 'default',
34
+ })
35
+ const audioVae = b.LTXVAudioVAELoader({ ckpt_name: 'ltx-2-19b-dev-fp8.safetensors' })
36
+
37
+ const cond = b.LTXVConditioning({
38
+ positive: b.CLIPTextEncode({ clip, text: vars.prompt.positive }),
39
+ negative: b.CLIPTextEncode({ clip, text: vars.prompt.negative }),
40
+ frame_rate: vars.fps,
41
+ })
42
+ const sampler = b.KSamplerSelect({ sampler_name: 'euler_ancestral' })
43
+ const noise = b.RandomNoise({ noise_seed: vars.seed })
44
+
45
+ // pass 1: the dev model with real cfg, video + audio latents sampled together at half resolution
46
+ const avLatent = b.LTXVConcatAVLatent({
47
+ video_latent: b.EmptyLTXVLatentVideo({
48
+ width: Math.round(vars.size.width / 2),
49
+ height: Math.round(vars.size.height / 2),
50
+ length: vars.length,
51
+ batch_size: 1,
52
+ }),
53
+ audio_latent: b.LTXVEmptyLatentAudio({
54
+ frames_number: vars.length,
55
+ frame_rate: vars.fps,
56
+ batch_size: 1,
57
+ audio_vae: audioVae,
58
+ }),
59
+ })
60
+ const base = b.SamplerCustomAdvanced({
61
+ noise,
62
+ guider: b.CFGGuider({
63
+ model: ckpt.outputs.MODEL,
64
+ positive: cond.outputs.positive,
65
+ negative: cond.outputs.negative,
66
+ cfg: vars.cfg,
67
+ }),
68
+ sampler,
69
+ sigmas: b.LTXVScheduler({
70
+ steps: vars.steps,
71
+ max_shift: 2.05,
72
+ base_shift: 0.95,
73
+ stretch: true,
74
+ terminal: 0.1,
75
+ latent: avLatent,
76
+ }),
77
+ latent_image: avLatent,
78
+ })
79
+ const baseAv = b.LTXVSeparateAVLatent({ av_latent: base.outputs.output })
80
+ const cropped = b.LTXVCropGuides({
81
+ positive: cond.outputs.positive,
82
+ negative: cond.outputs.negative,
83
+ latent: baseAv.outputs.video_latent,
84
+ })
85
+
86
+ // pass 2: x2 latent upscale, then a short refine with the distilled lora at cfg 1
87
+ const refined = b.SamplerCustomAdvanced({
88
+ noise,
89
+ guider: b.CFGGuider({
90
+ model: b.LoraLoaderModelOnly({
91
+ model: ckpt.outputs.MODEL,
92
+ lora_name: 'ltx-2-19b-distilled-lora-384.safetensors',
93
+ strength_model: 1,
94
+ }),
95
+ positive: cropped.outputs.positive,
96
+ negative: cropped.outputs.negative,
97
+ cfg: 1,
98
+ }),
99
+ sampler,
100
+ sigmas: b.ManualSigmas({ sigmas: '0.909375, 0.725, 0.421875, 0.0' }),
101
+ latent_image: b.LTXVConcatAVLatent({
102
+ video_latent: b.LTXVLatentUpsampler({
103
+ samples: cropped.outputs.latent,
104
+ upscale_model: b.LatentUpscaleModelLoader({ model_name: 'ltx-2-spatial-upscaler-x2-1.0.safetensors' }),
105
+ vae: ckpt.outputs.VAE,
106
+ }),
107
+ audio_latent: baseAv.outputs.audio_latent,
108
+ }),
109
+ })
110
+ const av = b.LTXVSeparateAVLatent({ av_latent: refined.outputs.denoised_output })
111
+
112
+ b.SaveVideo({
113
+ video: b.CreateVideo({
114
+ images: b.VAEDecodeTiled({
115
+ samples: av.outputs.video_latent,
116
+ vae: ckpt.outputs.VAE,
117
+ tile_size: 512,
118
+ overlap: 64,
119
+ temporal_size: 4096,
120
+ temporal_overlap: 8,
121
+ }),
122
+ audio: b.LTXVAudioVAEDecode({ samples: av.outputs.audio_latent, audio_vae: audioVae }),
123
+ fps: vars.fps,
124
+ }),
125
+ filename_prefix: 'comfy-ts-zoo/ltx2-t2v',
126
+ format: 'auto',
127
+ codec: 'auto',
128
+ })
129
+ },
130
+ })
131
+
132
+ export default ltx2T2v
133
+
134
+ // standalone run (skipped when another driver — e.g. the TUI — imports this module)
135
+ if (import.meta.main) {
136
+ requireCloudKey()
137
+ if (process.argv[2]) ltx2T2v.vars.prompt.set(process.argv[2])
138
+ if (process.argv[3]) ltx2T2v.vars.seed.set(Number(process.argv[3]))
139
+ const execution = await ltx2T2v.run({ log: true })
140
+ // SaveVideo outputs land host side (no auto-download for video yet)
141
+ console.log(`🟢 ${execution.status}: video saved on the host under comfy-ts-zoo/ltx2-t2v`)
142
+ host.disconnect()
143
+ }