comfy-ts 2.9.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/cli.js +2 -2
- package/dist/index.cjs +10 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/{run-tui-BLEdTsOX.js → run-tui-Atvf9vb3.js} +2 -2
- package/dist/{run-tui-BLEdTsOX.js.map → run-tui-Atvf9vb3.js.map} +1 -1
- package/dist/{state-BbgJeCe6.js → state-6RFDIQwJ.js} +11 -4
- package/dist/state-6RFDIQwJ.js.map +1 -0
- package/dist/web.js +10 -3
- package/dist/web.js.map +1 -1
- package/examples/README.md +1 -0
- package/examples/comfy-cloud/ltx25-i2v.cflow.ts +152 -0
- package/examples/comfy-cloud/ltx25-t2v.cflow.ts +126 -0
- package/examples/comfy-cloud/minimax-music3-t2a.cflow.ts +95 -0
- package/examples/comfy-cloud/sdk.d.ts +30724 -24404
- package/examples/rvion/08-qwen-image-21-t2i.cflow.ts +64 -0
- package/examples/rvion/09-qwen-image-21-edit.cflow.ts +83 -0
- package/package.json +1 -1
- package/src/graph/ComfyNode.ts +19 -3
- package/dist/state-BbgJeCe6.js.map +0 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// qwen image 2.1 text-to-image on windows-1 — mirrors the official image_qwen_image_2_1_t2i template
|
|
2
|
+
// int8 diffusion model + qwen3-vl 8b text encoder, 25 steps at cfg 1 (the negative only bites once cfg > 1)
|
|
3
|
+
// box inventory: qwen_image_2.1_int8_convrot, qwen3vl_8b_int8_convrot, qwen_image_2.1_vae_bf16 (Comfy-Org/Qwen-Image-2.1), ComfyUI ≥ 0.37
|
|
4
|
+
// run directly: bun examples/rvion/08-qwen-image-21-t2i.cflow.ts ["prompt"] [seed]
|
|
5
|
+
import { ComfyTS, v } from 'comfy-ts'
|
|
6
|
+
|
|
7
|
+
const comfy = ComfyTS.create()
|
|
8
|
+
const host = comfy.host({ id: 'windows-1', host: 'desktop-im18794', port: 8085 })
|
|
9
|
+
await host.loadSchemaFromCache() // offline import; run() connects lazily
|
|
10
|
+
|
|
11
|
+
export const qwenImage21T2i = host.defineWorkflow({
|
|
12
|
+
id: 'qwen-image-21-t2i',
|
|
13
|
+
vars: {
|
|
14
|
+
// `- ` lines are the negative prompt, `//` lines are comments
|
|
15
|
+
prompt: v.prompt(
|
|
16
|
+
'Greyscale fashion editorial portrait of an avant-garde woman tilted upwards in profile, striking high-contrast chiaroscuro lighting, oversized thick-rimmed circular black sunglasses, a high-necked structural dress in a disrupted optical camouflage pattern of oversized polka dots and pixelated stippling. The background is a vivid mixed-media graphic collage: flat lime green planes, black and white overlapping circles, bold zebra-striped semi-circles, micro-halftone dot matrices. Sharp silhouettes, paper cut-out edges, clean graphic novel textures. No text, no letters, no logos, no watermark.',
|
|
17
|
+
),
|
|
18
|
+
seed: v.seed(42, { mode: '+' }),
|
|
19
|
+
steps: v.int(25, { min: 1, max: 60 }),
|
|
20
|
+
cfg: v.float(1, { min: 1, max: 10 }),
|
|
21
|
+
size: v.size({ width: 1024, height: 1024 }),
|
|
22
|
+
},
|
|
23
|
+
build: (b, vars) => {
|
|
24
|
+
const unet = b.UNETLoader({ unet_name: 'qwen_image_2.1_int8_convrot.safetensors', weight_dtype: 'default' })
|
|
25
|
+
const clip = b.CLIPLoader({
|
|
26
|
+
clip_name: 'qwen3vl_8b_int8_convrot.safetensors',
|
|
27
|
+
type: 'qwen_image',
|
|
28
|
+
device: 'default',
|
|
29
|
+
})
|
|
30
|
+
const vae = b.VAELoader({ vae_name: 'qwen_image_2.1_vae_bf16.safetensors' })
|
|
31
|
+
|
|
32
|
+
const cond = b.TextEncodeQwenImage21({
|
|
33
|
+
clip,
|
|
34
|
+
prompt: vars.prompt.positive,
|
|
35
|
+
negative_prompt: vars.prompt.negative,
|
|
36
|
+
resolution: 1024,
|
|
37
|
+
})
|
|
38
|
+
const samples = b.KSampler({
|
|
39
|
+
model: unet,
|
|
40
|
+
positive: cond.outputs.positive,
|
|
41
|
+
negative: cond.outputs.negative,
|
|
42
|
+
latent_image: b.EmptyLatentImage({ width: vars.size.width, height: vars.size.height, batch_size: 1 }),
|
|
43
|
+
seed: vars.seed,
|
|
44
|
+
steps: vars.steps,
|
|
45
|
+
cfg: vars.cfg,
|
|
46
|
+
sampler_name: 'euler',
|
|
47
|
+
scheduler: 'simple',
|
|
48
|
+
denoise: 1,
|
|
49
|
+
})
|
|
50
|
+
b.SaveImageWebsocket({ images: b.VAEDecode({ samples, vae }) })
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
export default qwenImage21T2i
|
|
55
|
+
|
|
56
|
+
// standalone run (skipped when another driver — e.g. the TUI — imports this module)
|
|
57
|
+
if (import.meta.main) {
|
|
58
|
+
if (process.argv[2]) qwenImage21T2i.vars.prompt.set(process.argv[2])
|
|
59
|
+
if (process.argv[3]) qwenImage21T2i.vars.seed.set(Number(process.argv[3]))
|
|
60
|
+
|
|
61
|
+
const execution = await qwenImage21T2i.run({ log: true, save: { prefix: 'comfy-ts-example/qwen-image-21-t2i' } })
|
|
62
|
+
for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
|
|
63
|
+
host.disconnect()
|
|
64
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// qwen image 2.1 edit on windows-1 — mirrors the official image_qwen_image_2_1_image_edit template, single reference image
|
|
2
|
+
// the reference is seen by the text encoder AND spliced in as a vae latent; the output keeps the reference's own size
|
|
3
|
+
// the "remove background" preset is the official image_qwen_image_2_1_background_removal template: same graph, that instruction
|
|
4
|
+
// box inventory: qwen_image_2.1_int8_convrot, qwen3vl_8b_int8_convrot, qwen_image_2.1_vae_bf16 (Comfy-Org/Qwen-Image-2.1), ComfyUI ≥ 0.37
|
|
5
|
+
// run directly: bun examples/rvion/09-qwen-image-21-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 qwenImage21Edit = host.defineWorkflow({
|
|
16
|
+
id: 'qwen-image-21-edit',
|
|
17
|
+
vars: {
|
|
18
|
+
image,
|
|
19
|
+
// the reference is <image1> in the instruction. `- ` lines are the negative prompt
|
|
20
|
+
prompt: v.prompt(
|
|
21
|
+
'Keep the bear and its pose in <image1> unchanged, wrap a hand-knitted red wool scarf around its neck, realistic wool texture, natural folds, keep the original background and lighting, sharp details',
|
|
22
|
+
{
|
|
23
|
+
presets: {
|
|
24
|
+
'knitted scarf':
|
|
25
|
+
'Keep the bear and its pose in <image1> unchanged, wrap a hand-knitted red wool scarf around its neck, realistic wool texture, natural folds, keep the original background and lighting, sharp details',
|
|
26
|
+
'remove background': 'Remove the background, and output a PNG image',
|
|
27
|
+
watercolor: 'Turn <image1> into a detailed watercolor painting, keep the composition unchanged',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
),
|
|
31
|
+
seed: v.seed(42, { mode: '+' }),
|
|
32
|
+
steps: v.int(25, { min: 1, max: 60 }),
|
|
33
|
+
},
|
|
34
|
+
// async build: the reference 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 unet = b.UNETLoader({ unet_name: 'qwen_image_2.1_int8_convrot.safetensors', weight_dtype: 'default' })
|
|
40
|
+
const clip = b.CLIPLoader({
|
|
41
|
+
clip_name: 'qwen3vl_8b_int8_convrot.safetensors',
|
|
42
|
+
type: 'qwen_image',
|
|
43
|
+
device: 'default',
|
|
44
|
+
})
|
|
45
|
+
const vae = b.VAELoader({ vae_name: 'qwen_image_2.1_vae_bf16.safetensors' })
|
|
46
|
+
|
|
47
|
+
// resolution 0: the reference keeps its own size (rounded to a multiple of 32)
|
|
48
|
+
const cond = b.TextEncodeQwenImage21({
|
|
49
|
+
clip,
|
|
50
|
+
prompt: vars.prompt.positive,
|
|
51
|
+
negative_prompt: vars.prompt.negative,
|
|
52
|
+
resolution: 0,
|
|
53
|
+
'images.image_1': loaded,
|
|
54
|
+
vae,
|
|
55
|
+
})
|
|
56
|
+
const samples = b.KSampler({
|
|
57
|
+
// kv cache of the reference prefix, reused across steps instead of recomputed
|
|
58
|
+
model: b.QwenImage21Cache({ model: unet, device: 'auto', dtype: 'default' }),
|
|
59
|
+
positive: cond.outputs.positive,
|
|
60
|
+
negative: cond.outputs.negative,
|
|
61
|
+
latent_image: cond.outputs.latent,
|
|
62
|
+
seed: vars.seed,
|
|
63
|
+
steps: vars.steps,
|
|
64
|
+
cfg: 1,
|
|
65
|
+
sampler_name: 'euler',
|
|
66
|
+
scheduler: 'simple',
|
|
67
|
+
denoise: 1,
|
|
68
|
+
})
|
|
69
|
+
b.SaveImageWebsocket({ images: b.VAEDecode({ samples, vae }) })
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
export default qwenImage21Edit
|
|
74
|
+
|
|
75
|
+
// standalone run (skipped when another driver — e.g. the TUI — imports this module)
|
|
76
|
+
if (import.meta.main) {
|
|
77
|
+
if (process.argv[2]) qwenImage21Edit.vars.image.set(process.argv[2])
|
|
78
|
+
if (process.argv[3]) qwenImage21Edit.vars.prompt.set(process.argv[3])
|
|
79
|
+
|
|
80
|
+
const execution = await qwenImage21Edit.run({ log: true, save: { prefix: 'comfy-ts-example/qwen-image-21-edit' } })
|
|
81
|
+
for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
|
|
82
|
+
host.disconnect()
|
|
83
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comfy-ts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
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",
|
package/src/graph/ComfyNode.ts
CHANGED
|
@@ -4,7 +4,11 @@ import type { ComfyNodeSchema } from 'src/sdk-generator/ComfyNodeSchema.ts'
|
|
|
4
4
|
import type { ComfyApiNodeJson } from 'src/sdk-generator/comfy-api-json.ts'
|
|
5
5
|
import type { NodeInputExt, NodeOutputExt } from 'src/sdk-generator/comfyui-types.ts'
|
|
6
6
|
import { ComfyDefaultNodeWhenUnknown_Name } from 'src/sdk-generator/Primitives.ts'
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
classifySchemaInput,
|
|
9
|
+
containerInstanceSlotType,
|
|
10
|
+
defaultValueForWidget,
|
|
11
|
+
} from 'src/sdk-generator/inputWidgetKind.ts'
|
|
8
12
|
import type { DynamicComboOption } from 'src/sdk-generator/inputWidgetKind.ts'
|
|
9
13
|
import type { Maybe } from 'src/types/index.ts'
|
|
10
14
|
import { comfyColors } from 'src/utils/ComfyColors.ts'
|
|
@@ -440,8 +444,20 @@ export class ComfyNode<
|
|
|
440
444
|
|
|
441
445
|
private _getExpectedTypeForField(name: string): string {
|
|
442
446
|
const input = this.$schema.inputs.find((i: NodeInputExt) => i.nameInComfy === name)
|
|
443
|
-
if (input
|
|
444
|
-
|
|
447
|
+
if (input != null) return input.typeName
|
|
448
|
+
// autogrow instance key `decl.<instance>`: the container template carries the slot type
|
|
449
|
+
const dot = name.indexOf('.')
|
|
450
|
+
const decl =
|
|
451
|
+
dot > 0 ? this.$schema.inputs.find((i: NodeInputExt) => i.nameInComfy === name.slice(0, dot)) : undefined
|
|
452
|
+
if (decl != null) {
|
|
453
|
+
const kind = classifySchemaInput(decl)
|
|
454
|
+
const slotType = containerInstanceSlotType(decl.opts)
|
|
455
|
+
if (kind.kind === 'dynamic-container' && kind.instanceNames.includes(name.slice(dot + 1)) && slotType != null)
|
|
456
|
+
return slotType
|
|
457
|
+
}
|
|
458
|
+
throw new Error(
|
|
459
|
+
`🔴 no input "${name}" on ${this.$schema.nodeKey}: cannot tell which output of the linked node to use`,
|
|
460
|
+
)
|
|
445
461
|
}
|
|
446
462
|
|
|
447
463
|
private _getOutputForTypeOrCrash(type: string): ComfyNodeOutput<any> {
|