comfy-ts 2.11.0 → 2.12.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 +1 -0
- package/dist/{LogsSt-qtFzOKpu.js → LogsSt-U1H0mP1m.js} +35 -5
- package/dist/LogsSt-U1H0mP1m.js.map +1 -0
- package/dist/cli.js +4 -4
- package/dist/index.cjs +473 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +191 -31
- package/dist/index.d.ts +191 -31
- package/dist/index.js +469 -63
- package/dist/index.js.map +1 -1
- package/dist/{run-serve-BK7BA2dn.js → run-serve-BeAznay5.js} +461 -43
- package/dist/run-serve-BeAznay5.js.map +1 -0
- package/dist/{run-tui-CQyvMf0N.js → run-tui-BTGjvnKk.js} +43 -18
- package/dist/run-tui-BTGjvnKk.js.map +1 -0
- package/dist/{schemaDrift-DjjEtwfx.js → schemaDrift-Cg39vs53.js} +470 -60
- package/dist/schemaDrift-Cg39vs53.js.map +1 -0
- package/dist/serve-web.js +508 -134
- package/dist/{state--wrz0BQc.js → state-C7REnHan.js} +7 -3
- package/dist/{state--wrz0BQc.js.map → state-C7REnHan.js.map} +1 -1
- package/dist/web.d.ts +191 -31
- package/dist/web.js +469 -63
- package/dist/web.js.map +1 -1
- package/examples/rvion/06-qwen-image-edit.cflow.ts +3 -2
- package/examples/rvion/10-anima-t2i.cflow.ts +229 -0
- package/extra/README.md +4 -0
- package/extra/comfyui-fresh-model-lists/README.md +25 -0
- package/extra/comfyui-fresh-model-lists/__init__.py +36 -0
- package/extra/comfyui-fresh-model-lists/test_fresh_model_lists.py +97 -0
- package/package.json +15 -7
- package/src/cli/draftMeta.ts +39 -0
- package/src/cli/serve/ServeApp.ts +148 -12
- package/src/cli/serve/applyVarPayload.ts +50 -22
- package/src/cli/serve/describeVar.ts +42 -6
- package/src/cli/serve/llmConfigShape.ts +51 -0
- package/src/cli/serve/llmConfigs.ts +52 -0
- package/src/cli/serve/tagList.ts +92 -0
- package/src/cli/serve/tagSource.ts +69 -0
- package/src/cli/serve/web/api.ts +48 -0
- package/src/cli/serve/web/components/App.tsx +336 -44
- package/src/cli/serve/web/components/Gallery.tsx +105 -28
- package/src/cli/serve/web/components/HistoryPicker.tsx +149 -0
- package/src/cli/serve/web/components/Icon.tsx +18 -2
- package/src/cli/serve/web/components/MenuButton.tsx +53 -0
- package/src/cli/serve/web/components/Omnibox.tsx +85 -0
- package/src/cli/serve/web/components/PromptEnhancer.tsx +476 -180
- package/src/cli/serve/web/components/TooltipLayer.tsx +45 -0
- package/src/cli/serve/web/components/VarIcon.tsx +24 -0
- package/src/cli/serve/web/components/VarsForm.tsx +341 -188
- package/src/cli/serve/web/components/controls/BasicControls.tsx +57 -32
- package/src/cli/serve/web/components/controls/LorasControl.tsx +644 -317
- package/src/cli/serve/web/components/controls/PresetPicker.tsx +1 -1
- package/src/cli/serve/web/components/controls/PromptControl.tsx +279 -0
- package/src/cli/serve/web/components/controls/PromptEditor.tsx +113 -0
- package/src/cli/serve/web/components/controls/SeedControl.tsx +17 -10
- package/src/cli/serve/web/components/controls/SizeControl.tsx +111 -18
- package/src/cli/serve/web/components/modKey.ts +2 -0
- package/src/cli/serve/web/llm.ts +23 -12
- package/src/cli/serve/web/promptEditor/promptExtensions.ts +281 -0
- package/src/cli/serve/web/state/EnhancerSt.ts +415 -100
- package/src/cli/serve/web/state/FormSt.ts +193 -29
- package/src/cli/serve/web/state/OmniboxSt.ts +57 -0
- package/src/cli/serve/web/state/WebSt.ts +219 -74
- package/src/cli/serve/web/state/choiceButtons.ts +61 -0
- package/src/cli/serve/web/state/generateButton.ts +16 -0
- package/src/cli/serve/web/state/history.ts +54 -0
- package/src/cli/serve/web/state/host.ts +5 -2
- package/src/cli/serve/web/state/keptLines.ts +53 -0
- package/src/cli/serve/web/state/latentMode.ts +20 -0
- package/src/cli/serve/web/state/loraSort.ts +18 -0
- package/src/cli/serve/web/state/moduleTree.ts +2 -2
- package/src/cli/serve/web/state/omnibox.ts +69 -0
- package/src/cli/serve/web/state/payload.ts +38 -58
- package/src/cli/serve/web/state/shortcuts.ts +54 -0
- package/src/cli/serve/web/state/sizeStars.ts +31 -0
- package/src/cli/serve/web/state/stableSlots.ts +21 -0
- package/src/cli/serve/web/state/varGroups.ts +24 -0
- package/src/cli/serve/web/styles.ts +457 -118
- package/src/cli/serve/webBundle.ts +54 -10
- package/src/cli/tui/components/PickerOverlays.tsx +9 -2
- package/src/cli/tui/imagePicker/ImagePickerSt.ts +1 -1
- package/src/cli/tui/state/DraftsSt.ts +18 -2
- package/src/cli/tui/state/EditorSt.ts +1 -1
- package/src/cli/tui/state/LorasSt.ts +1 -1
- package/src/cli/tui/state/PickerSt.ts +25 -7
- package/src/cli/tui/state/SettingsSt.ts +1 -1
- package/src/cli/tui/state/TuiSt.ts +10 -0
- package/src/coreExports.ts +20 -0
- package/src/host/loraInfoCache.ts +6 -0
- package/src/state.ts +5 -0
- package/src/vars/ComfyVars.ts +337 -67
- package/src/vars/DefinedWorkflow.ts +40 -19
- package/src/vars/lanes.ts +238 -0
- package/src/vars/loraEntry.ts +101 -0
- package/src/vars/promptSyntax.ts +382 -0
- package/dist/LogsSt-qtFzOKpu.js.map +0 -1
- package/dist/run-serve-BK7BA2dn.js.map +0 -1
- package/dist/run-tui-CQyvMf0N.js.map +0 -1
- package/dist/schemaDrift-DjjEtwfx.js.map +0 -1
- package/src/cli/serve/web/components/Sidebar.tsx +0 -66
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// mirrors the official image_qwen_image_edit_2511 template, single reference
|
|
3
3
|
// image; the lightning toggle switches the 4-step Lightning lora (cfg 1) vs
|
|
4
4
|
// full sampling (cfg 4 — raise steps to ~40 yourself when you flip it off)
|
|
5
|
+
// box inventory: qwen-image-edit-2511-Q2_K.gguf (ComfyUI-GGUF), Qwen-Image-Edit-2511-Lightning-4steps-V1.0-fp32 lora
|
|
5
6
|
// run directly: bun examples/rvion/06-qwen-image-edit.cflow.ts [path/to/image.png] ["edit instruction"]
|
|
6
7
|
import { asAbsolutePath, ComfyTS, exampleImagePath, MediaImage, v } from 'comfy-ts'
|
|
7
8
|
|
|
@@ -28,7 +29,7 @@ export const qwenImageEdit = host.defineWorkflow({
|
|
|
28
29
|
const loaded = await img.loadInWorkflow_viaLoadImageNode(wf)
|
|
29
30
|
const scaled = b.FluxKontextImageScale({ image: loaded })
|
|
30
31
|
|
|
31
|
-
const unet = b.
|
|
32
|
+
const unet = b['GGUF.UnetLoaderGGUF']({ unet_name: 'qwen-image-edit-2511-Q2_K.gguf' })
|
|
32
33
|
const clip = b.CLIPLoader({
|
|
33
34
|
clip_name: 'qwen_2.5_vl_7b_fp8_scaled.safetensors',
|
|
34
35
|
type: 'qwen_image',
|
|
@@ -44,7 +45,7 @@ export const qwenImageEdit = host.defineWorkflow({
|
|
|
44
45
|
if (vars.lightning) {
|
|
45
46
|
model = b.LoraLoaderModelOnly({
|
|
46
47
|
model,
|
|
47
|
-
lora_name: 'Qwen-Image-Edit-2511-Lightning-4steps-V1.0-
|
|
48
|
+
lora_name: 'Qwen-Image-Edit-2511-Lightning-4steps-V1.0-fp32.safetensors',
|
|
48
49
|
strength_model: 1,
|
|
49
50
|
})._MODEL
|
|
50
51
|
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// anima text-to-image on the local box: anime UNET, qwen3 0.6b text encoder, qwen image vae.
|
|
2
|
+
// four models behind one choice, each with the settings its model card gives
|
|
3
|
+
// (huggingface.co/circlestone-labs/Anima): the distilled ones run 8 steps at cfg 1, the
|
|
4
|
+
// others 30-50 steps at cfg 4-5. er_sde is the author's default sampler, euler suits turbo.
|
|
5
|
+
//
|
|
6
|
+
// run directly: bun examples/rvion/10-anima-t2i.cflow.ts ["prompt"] [seed]
|
|
7
|
+
import { activeLoras, ComfyTS } from 'comfy-ts'
|
|
8
|
+
|
|
9
|
+
const comfy = ComfyTS.create()
|
|
10
|
+
const host = comfy.host({ id: 'windows-1', host: 'desktop-im18794', port: 8085 })
|
|
11
|
+
await host.loadSchemaFromCache()
|
|
12
|
+
|
|
13
|
+
const TURBO_LORA = 'anima\\anima-turbo-lora-v0.2.safetensors'
|
|
14
|
+
// the a1111 tagcomplete list: fetched by serve on first use, never part of this repo
|
|
15
|
+
const DANBOORU_TAGS = 'https://raw.githubusercontent.com/DominikDoom/a1111-sd-webui-tagcomplete/main/tags/danbooru.csv'
|
|
16
|
+
|
|
17
|
+
const MODELS = {
|
|
18
|
+
// distilled: fast, stable, a strong default style. What the author suggests starting with
|
|
19
|
+
turbo: { unet: 'anima-turbo-v1.1.safetensors', turboLora: false, distilled: true, scores: true },
|
|
20
|
+
// base fine-tuned on high quality images only. Its card: no score_* tags, they push it into slop
|
|
21
|
+
aesthetic: { unet: 'anima-aesthetic-v1.1.safetensors', turboLora: false, distilled: false, scores: false },
|
|
22
|
+
// the raw pretrained model: plain neutral style, what loras are trained on
|
|
23
|
+
base: { unet: 'anima-base-v1.0.safetensors', turboLora: false, distilled: false, scores: true },
|
|
24
|
+
// base with the official turbo lora, the template's fast path
|
|
25
|
+
'base+turbo': { unet: 'anima-base-v1.0.safetensors', turboLora: true, distilled: true, scores: true },
|
|
26
|
+
} as const
|
|
27
|
+
|
|
28
|
+
/** the tags in front of the prompt and the negative, from the top choices. Joined to the text
|
|
29
|
+
* with ', ', and an empty side adds nothing, so a bare prompt reads exactly as typed */
|
|
30
|
+
const QUALITY_TAGS: Record<string, string[]> = {
|
|
31
|
+
good: ['good quality'],
|
|
32
|
+
best: ['best quality'],
|
|
33
|
+
masterpiece: ['masterpiece', 'best quality'],
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function animaTags(p: {
|
|
37
|
+
/** null = no quality tags (the lit button clicked off) */
|
|
38
|
+
quality: string | null
|
|
39
|
+
/** every score picked becomes its own tag; none picked = no score tag */
|
|
40
|
+
score: readonly string[]
|
|
41
|
+
/** null = no rating tag */
|
|
42
|
+
safety: string | null
|
|
43
|
+
/** false on aesthetic: its card says score tags push it into slop */
|
|
44
|
+
scores: boolean
|
|
45
|
+
}): { positive: string[]; negative: string[] } {
|
|
46
|
+
const score = p.scores ? p.score.map((n) => `score_${n}`) : []
|
|
47
|
+
const quality = p.quality == null ? [] : (QUALITY_TAGS[p.quality] ?? [])
|
|
48
|
+
return {
|
|
49
|
+
positive: [...quality, ...score, ...(p.safety == null ? [] : [p.safety])],
|
|
50
|
+
negative: [
|
|
51
|
+
...(quality.length > 0 ? ['worst quality', 'low quality'] : []),
|
|
52
|
+
...(score.length > 0 ? ['score_1', 'score_2', 'score_3'] : []),
|
|
53
|
+
],
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const joinTags = (tags: string[], text: string): string => [...tags, text].filter((t) => t.trim() !== '').join(', ')
|
|
58
|
+
|
|
59
|
+
/** the texts the two CLIPTextEncode nodes receive. ONE function for the build and the live
|
|
60
|
+
* preview, so the preview is exactly what runs */
|
|
61
|
+
function animaPrompts(p: {
|
|
62
|
+
model: keyof typeof MODELS
|
|
63
|
+
quality: string | null
|
|
64
|
+
score: readonly string[]
|
|
65
|
+
safety: string | null
|
|
66
|
+
prompt: { positive: string; negative: string }
|
|
67
|
+
}): { positive: string; negative: string } {
|
|
68
|
+
const tags = animaTags({ quality: p.quality, score: p.score, safety: p.safety, scores: MODELS[p.model].scores })
|
|
69
|
+
return { positive: joinTags(tags.positive, p.prompt.positive), negative: joinTags(tags.negative, p.prompt.negative) }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const animaT2i = host.defineWorkflow({
|
|
73
|
+
id: 'anima-t2i',
|
|
74
|
+
vars: (v) => {
|
|
75
|
+
// every lora inside an `anima/` folder (never WanAnimate and friends), except the turbo one: the model choice owns it
|
|
76
|
+
const loras = v.loras(/^(?!.*anima-turbo-lora)(?:.*[\\/])?anima[\\/]/i)
|
|
77
|
+
return {
|
|
78
|
+
// the tags every anima prompt starts with, as buttons: the model card's order is
|
|
79
|
+
// quality, score, safety, then the rest, and the build writes them in that order
|
|
80
|
+
safety: v
|
|
81
|
+
.choice(['safe', 'sensitive', 'nsfw', 'explicit'], 'safe', { label: 'safety', select: 'zero-or-one' })
|
|
82
|
+
.ui({
|
|
83
|
+
group: 'tags',
|
|
84
|
+
groupColor: 'rgba(158, 206, 106, 0.07)',
|
|
85
|
+
description: 'the rating tag anima was trained with, written after quality and score',
|
|
86
|
+
// one color per rating, green to red, so the lit one says how far it goes
|
|
87
|
+
options: {
|
|
88
|
+
safe: { color: '#9ece6a' },
|
|
89
|
+
sensitive: { color: '#e0af68' },
|
|
90
|
+
nsfw: { color: '#ff9e64' },
|
|
91
|
+
explicit: { color: '#f7768e' },
|
|
92
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
// any number of scores, each its own score_N tag in front, score_1..3 in the negative
|
|
95
|
+
// once one is picked. Left out on aesthetic, as its card says
|
|
96
|
+
score: v.choice(['6', '7', '8', '9'], ['7'], { label: 'score', select: 'many' }).ui({
|
|
97
|
+
group: 'tags',
|
|
98
|
+
description:
|
|
99
|
+
'click to toggle: every score picked adds its score_N tag, and score_1 to 3 go to the negative. None picked, no score. Left out on aesthetic: its card says score tags push it into slop',
|
|
100
|
+
}),
|
|
101
|
+
// the card's human quality scale: masterpiece, best quality, good quality, … worst quality
|
|
102
|
+
quality: v
|
|
103
|
+
.choice(['good', 'best', 'masterpiece'], 'masterpiece', { label: 'quality', select: 'zero-or-one' })
|
|
104
|
+
.ui({
|
|
105
|
+
group: 'tags',
|
|
106
|
+
description:
|
|
107
|
+
'good: good quality. best: best quality. masterpiece: masterpiece, best quality. Any of them puts worst quality, low quality in the negative',
|
|
108
|
+
}),
|
|
109
|
+
// anima reads booru tags and short phrases. `- ` lines are the negative prompt
|
|
110
|
+
prompt: v.prompt(
|
|
111
|
+
'1girl, silver hair, long coat, standing on a rooftop at dusk, city lights, wind, looking at viewer\n- blurry, jpeg artifacts, sepia',
|
|
112
|
+
{
|
|
113
|
+
loraKeywordsFrom: loras,
|
|
114
|
+
// danbooru tag completion. The card: lowercase, spaces for underscores, artists as `@name`
|
|
115
|
+
tags: { url: DANBOORU_TAGS, artistPrefix: '@' },
|
|
116
|
+
// named starting texts: picking one REPLACES the box, the draft reverts it
|
|
117
|
+
presets: {
|
|
118
|
+
'rooftop portrait':
|
|
119
|
+
'1girl, silver hair, long coat, standing on a rooftop at dusk, city lights, wind, looking at viewer\n- blurry, jpeg artifacts, sepia',
|
|
120
|
+
'chibi sprite':
|
|
121
|
+
'chibi, full body, simple background, white background, round sheep mascot, big eyes, flat colors\n- blurry, text, watermark',
|
|
122
|
+
landscape:
|
|
123
|
+
'no humans, scenery, floating islands, waterfalls, soft clouds, golden hour, detailed background\n- blurry, jpeg artifacts',
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
),
|
|
127
|
+
// right under the prompt: the loras and the words they add are read together
|
|
128
|
+
loras,
|
|
129
|
+
seed: v.seed(1, { mode: '+' }),
|
|
130
|
+
model: v.choice(['turbo', 'aesthetic', 'base', 'base+turbo'], 'turbo', 'model').ui({
|
|
131
|
+
group: 'sampling',
|
|
132
|
+
groupColor: 'rgba(122, 162, 247, 0.08)',
|
|
133
|
+
description: 'turbo and base+turbo: 8 steps at cfg 1. aesthetic and base: the steps and cfg below',
|
|
134
|
+
}),
|
|
135
|
+
// auto = er_sde on aesthetic and base, euler on the distilled ones
|
|
136
|
+
sampler: v.choice(['auto', 'er_sde', 'euler', 'euler_ancestral'], 'auto', 'sampler').ui({ group: 'sampling' }),
|
|
137
|
+
// the distilled models ignore these: 8 steps at cfg 1 is what they were distilled for
|
|
138
|
+
steps: v.int(30, { min: 1, max: 60 }).ui({
|
|
139
|
+
group: 'sampling',
|
|
140
|
+
description: 'only aesthetic and base read it: the distilled models run 8',
|
|
141
|
+
activeWhen: { model: ['aesthetic', 'base'] },
|
|
142
|
+
}),
|
|
143
|
+
cfg: v.float(4, { min: 0, max: 15 }).ui({
|
|
144
|
+
group: 'sampling',
|
|
145
|
+
description: 'only aesthetic and base read it: the distilled models run at 1. The card suggests 4 to 5',
|
|
146
|
+
activeWhen: { model: ['aesthetic', 'base'] },
|
|
147
|
+
}),
|
|
148
|
+
size: v.size({ width: 1024, height: 1024 }),
|
|
149
|
+
removeBg: v.toggle(false, 'remove bg'),
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
// the final prompt, live under generate while you edit: the tags, the lora keywords, your text
|
|
153
|
+
previews: {
|
|
154
|
+
prompt: (vars) => {
|
|
155
|
+
const p = animaPrompts(vars)
|
|
156
|
+
// written like the prompt box: the negative is a `- ` line, never part of the positive
|
|
157
|
+
return p.negative === '' ? p.positive : `${p.positive}\n- ${p.negative}`
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
build: (b, vars) => {
|
|
161
|
+
const clipLoader = b.CLIPLoader({
|
|
162
|
+
clip_name: 'qwen_3_06b_base.safetensors',
|
|
163
|
+
type: 'stable_diffusion',
|
|
164
|
+
device: 'default',
|
|
165
|
+
})
|
|
166
|
+
const spec = MODELS[vars.model]
|
|
167
|
+
let model = b.UNETLoader({ unet_name: spec.unet, weight_dtype: 'default' })._MODEL
|
|
168
|
+
let clip = clipLoader._CLIP
|
|
169
|
+
if (spec.turboLora) model = b.LoraLoaderModelOnly({ model, lora_name: TURBO_LORA, strength_model: 1 })._MODEL
|
|
170
|
+
for (const l of activeLoras(vars.loras)) {
|
|
171
|
+
const loaded = b.LoraLoader({
|
|
172
|
+
model,
|
|
173
|
+
clip,
|
|
174
|
+
lora_name: l.lora_name,
|
|
175
|
+
strength_model: l.strength_model,
|
|
176
|
+
strength_clip: l.strength_clip,
|
|
177
|
+
})
|
|
178
|
+
model = loaded._MODEL
|
|
179
|
+
clip = loaded._CLIP
|
|
180
|
+
}
|
|
181
|
+
const prompts = animaPrompts(vars)
|
|
182
|
+
const samples = b.KSampler({
|
|
183
|
+
model,
|
|
184
|
+
positive: b.CLIPTextEncode({ clip, text: prompts.positive }),
|
|
185
|
+
negative: b.CLIPTextEncode({ clip, text: prompts.negative }),
|
|
186
|
+
latent_image: b.EmptyLatentImage({ width: vars.size.width, height: vars.size.height, batch_size: 1 }),
|
|
187
|
+
seed: vars.seed,
|
|
188
|
+
steps: spec.distilled ? 8 : vars.steps,
|
|
189
|
+
cfg: spec.distilled ? 1 : vars.cfg,
|
|
190
|
+
sampler_name: vars.sampler === 'auto' ? (spec.distilled ? 'euler' : 'er_sde') : vars.sampler,
|
|
191
|
+
scheduler: 'simple',
|
|
192
|
+
denoise: 1,
|
|
193
|
+
})
|
|
194
|
+
const image = b.VAEDecode({ samples, vae: b.VAELoader({ vae_name: 'qwen_image_vae.safetensors' }) })
|
|
195
|
+
if (vars.removeBg) {
|
|
196
|
+
// same cutout as 04: the savers drop RMBG's alpha unless the mask is rejoined, and
|
|
197
|
+
// JoinImageWithAlpha inverts the mask it gets, hence the InvertMask in front
|
|
198
|
+
const cutout = b['rmbg.RMBG']({
|
|
199
|
+
image,
|
|
200
|
+
model: 'BEN2',
|
|
201
|
+
sensitivity: 1,
|
|
202
|
+
process_res: 1024,
|
|
203
|
+
mask_blur: 0,
|
|
204
|
+
mask_offset: 0,
|
|
205
|
+
invert_output: false,
|
|
206
|
+
refine_foreground: false,
|
|
207
|
+
background: 'Alpha',
|
|
208
|
+
})
|
|
209
|
+
const rgba = b.JoinImageWithAlpha({
|
|
210
|
+
image: cutout.outputs.IMAGE,
|
|
211
|
+
alpha: b.InvertMask({ mask: cutout.outputs.MASK }),
|
|
212
|
+
})
|
|
213
|
+
b.SaveImageWebsocket({ images: rgba })
|
|
214
|
+
} else {
|
|
215
|
+
b.SaveImageWebsocket({ images: image })
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
export default animaT2i
|
|
221
|
+
|
|
222
|
+
// standalone run (skipped when another driver, the TUI or serve, imports this module)
|
|
223
|
+
if (import.meta.main) {
|
|
224
|
+
if (process.argv[2]) animaT2i.vars.prompt.set(process.argv[2])
|
|
225
|
+
if (process.argv[3]) animaT2i.vars.seed.set(Number(process.argv[3]))
|
|
226
|
+
const execution = await animaT2i.run({ log: true, save: { prefix: 'comfy-ts-example/anima-t2i' } })
|
|
227
|
+
for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
|
|
228
|
+
host.disconnect()
|
|
229
|
+
}
|
package/extra/README.md
CHANGED
|
@@ -6,6 +6,10 @@ Things that live outside the TypeScript library but make it more useful. Nothing
|
|
|
6
6
|
|
|
7
7
|
`Generate Text (streaming)`: core `TextGenerate`, except it publishes the answer as it is produced instead of once at the end. Copy the folder into `ComfyUI/custom_nodes/` and restart. The live text arrives as `execution.progressText`, which `comfy-ts serve` renders while the run is in flight.
|
|
8
8
|
|
|
9
|
+
## [`comfyui-fresh-model-lists/`](comfyui-fresh-model-lists/), a ComfyUI extension
|
|
10
|
+
|
|
11
|
+
A lora you just downloaded shows up without restarting ComfyUI. On an exFAT drive, a folder's modification time does not change when a file is added, so ComfyUI's file list cache never expires and only a restart refreshes it. This adds a 2 second age limit to that cache. Copy the folder into `ComfyUI/custom_nodes/` and restart once.
|
|
12
|
+
|
|
9
13
|
## [`scripts/fetch_text_encoder.py`](scripts/fetch_text_encoder.py), a Hugging Face model, ready for `CLIPLoader`
|
|
10
14
|
|
|
11
15
|
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# comfyui-fresh-model-lists
|
|
2
|
+
|
|
3
|
+
A ComfyUI extension with no nodes: model lists (loras, checkpoints, every `models/` folder) that follow the disk, so a lora you just downloaded shows up without restarting ComfyUI.
|
|
4
|
+
|
|
5
|
+
## Why it exists
|
|
6
|
+
|
|
7
|
+
ComfyUI caches each folder's file list and keeps it while every scanned directory keeps its modification time. That works on NTFS and ext4, where adding a file updates the directory's mtime.
|
|
8
|
+
|
|
9
|
+
On **exFAT** it does not. Windows leaves an exFAT directory's modification time unchanged when a file is created inside it (measured: a new file in `models/loras/krea2/styles`, directory mtime still from six weeks earlier, `os.path.getmtime` agreeing). The cache never invalidates, `/object_info` keeps serving the old enum, and the only way to see a new lora is a restart. A models drive formatted exFAT, common for large external or shared SSDs, has this on every download.
|
|
10
|
+
|
|
11
|
+
## How it works
|
|
12
|
+
|
|
13
|
+
It wraps `folder_paths.cached_filename_list_` and adds an age limit: a list scanned more than `TTL_SECONDS` (2 s) ago counts as stale, so the next read rescans. ComfyUI's own mtime check still runs first. A rescan is cheap: a full `models/` walk of about 1000 files took 18 ms on an exFAT SSD, and during one `/object_info` request ComfyUI scans each folder only once.
|
|
14
|
+
|
|
15
|
+
After a download, refresh the node definitions (the `R` key in the ComfyUI frontend, the refetch button in the `comfy-ts serve` panel) and the new file is in the list.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
Copy this folder into `ComfyUI/custom_nodes/` and restart ComfyUI once. The startup log says `[fresh-model-lists] model lists rescan after 2.0s`.
|
|
20
|
+
|
|
21
|
+
Uninstall by deleting the folder. It touches no file, only one function in memory.
|
|
22
|
+
|
|
23
|
+
## Tests
|
|
24
|
+
|
|
25
|
+
`python3 -m unittest test_fresh_model_lists` runs without ComfyUI, against a stub `folder_paths` whose directory mtimes never move. The control case shows the new file staying invisible without the extension.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# model lists (loras, checkpoints, …) that follow the disk on exFAT and other filesystems
|
|
2
|
+
# whose directory mtime does not move when a file is added. ComfyUI's filename cache is
|
|
3
|
+
# valid while every scanned directory keeps its mtime, so there a new file stays invisible
|
|
4
|
+
# until a restart. This adds an age limit: an entry older than TTL_SECONDS is rescanned.
|
|
5
|
+
# a full models/ rescan measured 18 ms on an exFAT ssd, and object_info scans each folder once.
|
|
6
|
+
import logging
|
|
7
|
+
|
|
8
|
+
import folder_paths
|
|
9
|
+
|
|
10
|
+
TTL_SECONDS = 2.0
|
|
11
|
+
|
|
12
|
+
_MARK = "_fresh_model_lists_original"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _install() -> None:
|
|
16
|
+
import time
|
|
17
|
+
|
|
18
|
+
current = folder_paths.cached_filename_list_
|
|
19
|
+
original = getattr(current, _MARK, current)
|
|
20
|
+
|
|
21
|
+
def cached_filename_list_(folder_name):
|
|
22
|
+
out = original(folder_name)
|
|
23
|
+
# out[2] is the perf_counter taken when the list was scanned
|
|
24
|
+
if out is not None and time.perf_counter() - out[2] > TTL_SECONDS:
|
|
25
|
+
return None
|
|
26
|
+
return out
|
|
27
|
+
|
|
28
|
+
setattr(cached_filename_list_, _MARK, original)
|
|
29
|
+
folder_paths.cached_filename_list_ = cached_filename_list_
|
|
30
|
+
logging.info(f"[fresh-model-lists] model lists rescan after {TTL_SECONDS}s")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
_install()
|
|
34
|
+
|
|
35
|
+
NODE_CLASS_MAPPINGS = {}
|
|
36
|
+
NODE_DISPLAY_NAME_MAPPINGS = {}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# runs without ComfyUI: a stub `folder_paths` carries the real cache logic, and the
|
|
2
|
+
# filesystem is a dict whose directory mtimes never move, which is what exFAT does.
|
|
3
|
+
import importlib.util
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
import time
|
|
7
|
+
import types
|
|
8
|
+
import unittest
|
|
9
|
+
|
|
10
|
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
11
|
+
|
|
12
|
+
DISK = {"loras": ["a.safetensors"]}
|
|
13
|
+
DIR_MTIME = 1000.0
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def make_folder_paths():
|
|
17
|
+
fp = types.ModuleType("folder_paths")
|
|
18
|
+
fp.filename_list_cache = {}
|
|
19
|
+
fp.cache_helper = types.SimpleNamespace(get=lambda k, d=None: d, set=lambda k, v: None)
|
|
20
|
+
fp.folder_names_and_paths = {"loras": (["/models/loras"], {".safetensors"})}
|
|
21
|
+
fp.map_legacy = lambda name: name
|
|
22
|
+
fp.os_getmtime = lambda path: DIR_MTIME
|
|
23
|
+
|
|
24
|
+
def get_filename_list_(name):
|
|
25
|
+
return sorted(DISK[name]), {"/models/loras": DIR_MTIME}, time.perf_counter()
|
|
26
|
+
|
|
27
|
+
# same shape as ComfyUI's: valid while every scanned directory keeps its mtime
|
|
28
|
+
def cached_filename_list_(name):
|
|
29
|
+
if name not in fp.filename_list_cache:
|
|
30
|
+
return None
|
|
31
|
+
out = fp.filename_list_cache[name]
|
|
32
|
+
for folder, mtime in out[1].items():
|
|
33
|
+
if fp.os_getmtime(folder) != mtime:
|
|
34
|
+
return None
|
|
35
|
+
return out
|
|
36
|
+
|
|
37
|
+
def get_filename_list(name):
|
|
38
|
+
out = fp.cached_filename_list_(name)
|
|
39
|
+
if out is None:
|
|
40
|
+
out = get_filename_list_(name)
|
|
41
|
+
fp.filename_list_cache[name] = out
|
|
42
|
+
return list(out[0])
|
|
43
|
+
|
|
44
|
+
fp.get_filename_list_ = get_filename_list_
|
|
45
|
+
fp.cached_filename_list_ = cached_filename_list_
|
|
46
|
+
fp.get_filename_list = get_filename_list
|
|
47
|
+
return fp
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def load_node(fp):
|
|
51
|
+
sys.modules["folder_paths"] = fp
|
|
52
|
+
spec = importlib.util.spec_from_file_location("fresh_model_lists", os.path.join(HERE, "__init__.py"))
|
|
53
|
+
mod = importlib.util.module_from_spec(spec)
|
|
54
|
+
spec.loader.exec_module(mod)
|
|
55
|
+
return mod
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class FreshModelListsTest(unittest.TestCase):
|
|
59
|
+
def setUp(self):
|
|
60
|
+
DISK["loras"] = ["a.safetensors"]
|
|
61
|
+
|
|
62
|
+
def test_control_without_the_node_a_new_file_stays_invisible(self):
|
|
63
|
+
fp = make_folder_paths()
|
|
64
|
+
self.assertEqual(fp.get_filename_list("loras"), ["a.safetensors"])
|
|
65
|
+
DISK["loras"].append("b.safetensors")
|
|
66
|
+
self.assertEqual(fp.get_filename_list("loras"), ["a.safetensors"])
|
|
67
|
+
|
|
68
|
+
def test_with_the_node_a_new_file_appears_once_the_ttl_passed(self):
|
|
69
|
+
# why we think it is actually a bug, and not just meaning spec should change: ComfyUI's
|
|
70
|
+
# cache promises a file list that follows the disk, and on exFAT a new lora never shows
|
|
71
|
+
# until a restart (measured on a real exFAT drive: dir mtime unchanged after a create)
|
|
72
|
+
fp = make_folder_paths()
|
|
73
|
+
node = load_node(fp)
|
|
74
|
+
node.TTL_SECONDS = 0.05
|
|
75
|
+
self.assertEqual(fp.get_filename_list("loras"), ["a.safetensors"])
|
|
76
|
+
DISK["loras"].append("b.safetensors")
|
|
77
|
+
time.sleep(0.06)
|
|
78
|
+
self.assertEqual(fp.get_filename_list("loras"), ["a.safetensors", "b.safetensors"])
|
|
79
|
+
|
|
80
|
+
def test_within_the_ttl_the_cache_still_answers(self):
|
|
81
|
+
fp = make_folder_paths()
|
|
82
|
+
node = load_node(fp)
|
|
83
|
+
node.TTL_SECONDS = 60
|
|
84
|
+
fp.get_filename_list("loras")
|
|
85
|
+
DISK["loras"].append("b.safetensors")
|
|
86
|
+
self.assertEqual(fp.get_filename_list("loras"), ["a.safetensors"])
|
|
87
|
+
|
|
88
|
+
def test_loading_twice_does_not_stack_wrappers(self):
|
|
89
|
+
fp = make_folder_paths()
|
|
90
|
+
base = fp.cached_filename_list_
|
|
91
|
+
load_node(fp)
|
|
92
|
+
load_node(fp)
|
|
93
|
+
self.assertIs(fp.cached_filename_list_._fresh_model_lists_original, base)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
if __name__ == "__main__":
|
|
97
|
+
unittest.main()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comfy-ts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.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",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"cli",
|
|
20
20
|
"tui"
|
|
21
21
|
],
|
|
22
|
-
"author": "
|
|
22
|
+
"author": "Rémi Vion <vion.remi@gmail.com>",
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"funding": "https://github.com/sponsors/rvion",
|
|
25
25
|
"repository": {
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"scripts": {
|
|
69
69
|
"build": "tsdown && bun scripts/build-serve-web.ts",
|
|
70
70
|
"build:watch": "tsdown --watch",
|
|
71
|
-
"test": "bun test",
|
|
71
|
+
"test": "bun test --parallel --no-isolate",
|
|
72
72
|
"test:watch": "bun test --watch",
|
|
73
|
-
"typecheck": "tsc --noEmit && tsc -p examples/web/tsconfig.json",
|
|
73
|
+
"typecheck": "tsc --noEmit --tsBuildInfoFile node_modules/.cache/tsbuildinfo-typecheck.json && tsc -p examples/web/tsconfig.json && tsc -p src/cli/serve/web/tsconfig.json",
|
|
74
74
|
"typecheck:lib": "tsc -p tsconfig.lib.json && tsc -p src/cli/serve/web/tsconfig.json",
|
|
75
75
|
"lint": "oxlint src examples scripts tests",
|
|
76
76
|
"format": "oxfmt src examples scripts tests",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"imports:fix": "rvt imports --fix",
|
|
80
80
|
"cycles": "rvt cycles 1",
|
|
81
81
|
"rename": "rvt rename",
|
|
82
|
-
"ci": "bun run typecheck:lib && bun run lint && bun run format:check && bun run imports:check && bun test",
|
|
82
|
+
"ci": "bun run typecheck:lib && bun run lint && bun run format:check && bun run imports:check && bun run test",
|
|
83
83
|
"ci:local": "bun run ci && bun run typecheck",
|
|
84
84
|
"gen:manager": "bun src/manager/script-update-manager.bun.ts",
|
|
85
85
|
"gen:sdk": "bun scripts/gen-sdk-from-cache.ts",
|
|
@@ -99,11 +99,12 @@
|
|
|
99
99
|
"serve:watch": "bun --watch src/cli/comfy-ts-cli.ts serve",
|
|
100
100
|
"serve:0000": "bun src/cli/comfy-ts-cli.ts serve --host 0.0.0.0",
|
|
101
101
|
"serve:0000:rvion": "bun src/cli/comfy-ts-cli.ts serve --host 0.0.0.0 examples/rvion",
|
|
102
|
-
"serve:rvion": "bun --watch src/cli/comfy-ts-cli.ts serve examples/rvion"
|
|
102
|
+
"serve:rvion": "bun --watch src/cli/comfy-ts-cli.ts serve examples/rvion",
|
|
103
|
+
"check:panel-scroll": "bun scripts/check-panel-scroll.ts"
|
|
103
104
|
},
|
|
104
105
|
"rvt": {
|
|
105
106
|
"skip": [
|
|
106
|
-
".
|
|
107
|
+
".shipkit/private",
|
|
107
108
|
"tmp",
|
|
108
109
|
".comfy-ts"
|
|
109
110
|
]
|
|
@@ -113,6 +114,11 @@
|
|
|
113
114
|
"node": ">=20.0.0"
|
|
114
115
|
},
|
|
115
116
|
"dependencies": {
|
|
117
|
+
"@codemirror/autocomplete": "^6.20.3",
|
|
118
|
+
"@codemirror/commands": "^6.11.1",
|
|
119
|
+
"@codemirror/state": "^6.7.6",
|
|
120
|
+
"@codemirror/view": "^6.43.13",
|
|
121
|
+
"@floating-ui/react": "^0.27.20",
|
|
116
122
|
"arktype": "^2.2.3",
|
|
117
123
|
"image-meta": "^0.2.2",
|
|
118
124
|
"ink": "^7.1.1",
|
|
@@ -122,6 +128,7 @@
|
|
|
122
128
|
"pathe": "^2.0.3",
|
|
123
129
|
"react": "^19.2.8",
|
|
124
130
|
"react-dom": "^19.2.8",
|
|
131
|
+
"react-resizable-panels": "^4.13.3",
|
|
125
132
|
"sharp": "^0.35.3",
|
|
126
133
|
"ws": "^8.21.1"
|
|
127
134
|
},
|
|
@@ -133,6 +140,7 @@
|
|
|
133
140
|
"oxfmt": "^0.60.0",
|
|
134
141
|
"oxlint": "^1.75.0",
|
|
135
142
|
"oxlint-tsgolint": "^7.0.2001",
|
|
143
|
+
"rvlib-shipkit": "^1.2.0",
|
|
136
144
|
"rvlib-ts-tools": "^0.3.3",
|
|
137
145
|
"tsdown": "^0.22.14",
|
|
138
146
|
"typescript": "^7.0.2"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// what a draft file carries BESIDE its var values: keys starting with `$`, never a var name (a var
|
|
2
|
+
// is an identifier). Today one: `$enhance`, the enhancer's input per prompt (per lane in lanes
|
|
3
|
+
// mode), so each draft keeps its own intent next to the prompt it refines. Every reader walks
|
|
4
|
+
// the workflow's vars and ignores these keys; every writer keeps them (preserveDraftMeta). PURE,
|
|
5
|
+
// the browser bundle and the TUI both import it
|
|
6
|
+
export const ENHANCE_KEY = '$enhance'
|
|
7
|
+
|
|
8
|
+
/** where one intent lives in `$enhance`: the var, or `var#lane` for one lane */
|
|
9
|
+
export function intentKey(varName: string, lane: number | null): string {
|
|
10
|
+
return lane == null ? varName : `${varName}#${lane}`
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** `$enhance` as a clean string map: a hand-broken entry drops, the rest stays */
|
|
14
|
+
export function readIntents(raw: unknown): Record<string, string> {
|
|
15
|
+
if (raw == null || typeof raw !== 'object' || Array.isArray(raw)) return {}
|
|
16
|
+
const out: Record<string, string> = {}
|
|
17
|
+
for (const [k, v] of Object.entries(raw)) if (typeof v === 'string' && v !== '') out[k] = v
|
|
18
|
+
return out
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** a parsed draft file: a json object, never an array or a scalar */
|
|
22
|
+
export function isDraftRecord(raw: unknown): raw is Record<string, unknown> {
|
|
23
|
+
return raw != null && typeof raw === 'object' && !Array.isArray(raw)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function isDraftMetaKey(key: string): boolean {
|
|
27
|
+
return key === ENHANCE_KEY
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** a writer that knows only the var values keeps what the file already carried beside them */
|
|
31
|
+
export function preserveDraftMeta(
|
|
32
|
+
previous: Record<string, unknown> | null,
|
|
33
|
+
next: Record<string, unknown>,
|
|
34
|
+
): Record<string, unknown> {
|
|
35
|
+
if (previous == null) return next
|
|
36
|
+
const out = { ...next }
|
|
37
|
+
for (const [k, v] of Object.entries(previous)) if (isDraftMetaKey(k) && !(k in out)) out[k] = v
|
|
38
|
+
return out
|
|
39
|
+
}
|