comfy-ts 2.17.1 → 2.18.1
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/dist/cli.js +3 -3
- package/dist/index.cjs +1078 -190
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1185 -410
- package/dist/index.d.ts +1185 -410
- package/dist/index.js +1078 -190
- package/dist/index.js.map +1 -1
- package/dist/{run-run-tg82jUIk.js → run-run-Zr699h2S.js} +2 -2
- package/dist/{run-run-tg82jUIk.js.map → run-run-Zr699h2S.js.map} +1 -1
- package/dist/{run-tui-Bw7BA75d.js → run-tui-CeM1GOJP.js} +2 -2
- package/dist/{run-tui-Bw7BA75d.js.map → run-tui-CeM1GOJP.js.map} +1 -1
- package/dist/serve-web.js +47 -47
- package/dist/{state-zTow5ucI.js → state-C067Kbew.js} +1079 -191
- package/dist/state-C067Kbew.js.map +1 -0
- package/dist/web.d.ts +1203 -428
- package/dist/web.js +1078 -190
- package/dist/web.js.map +1 -1
- package/examples/comfy-cloud/ace-step15-t2a.cflow.ts +163 -0
- package/examples/comfy-cloud/anima-t2i-base.cflow.ts +57 -0
- package/examples/comfy-cloud/boogu-t2i.cflow.ts +55 -0
- package/examples/comfy-cloud/chronoedit-i2i.cflow.ts +95 -0
- package/examples/comfy-cloud/ernie-t2i-base.cflow.ts +81 -0
- package/examples/comfy-cloud/flux1-t2i-krea.cflow.ts +63 -0
- package/examples/comfy-cloud/flux2-i2i-dev.cflow.ts +83 -0
- package/examples/comfy-cloud/flux2-t2i-dev.cflow.ts +60 -0
- package/examples/comfy-cloud/hidream-o1-i2i.cflow.ts +71 -0
- package/examples/comfy-cloud/hidream-o1-t2i.cflow.ts +62 -0
- package/examples/comfy-cloud/krea2-i2i.cflow.ts +78 -0
- package/examples/comfy-cloud/ltx2-i2v.cflow.ts +175 -0
- package/examples/comfy-cloud/ltx2-t2v.cflow.ts +143 -0
- package/examples/comfy-cloud/ltx23-i2v.cflow.ts +189 -0
- package/examples/comfy-cloud/ltx23-t2v.cflow.ts +151 -0
- package/examples/comfy-cloud/mage-flow-i2i-turbo.cflow.ts +72 -0
- package/examples/comfy-cloud/mage-flow-i2i.cflow.ts +74 -0
- package/examples/comfy-cloud/mage-flow-t2i-turbo.cflow.ts +60 -0
- package/examples/comfy-cloud/mage-flow-t2i.cflow.ts +60 -0
- package/examples/comfy-cloud/minimax-h3-t2i.cflow.ts +64 -0
- package/examples/comfy-cloud/netayume-t2i.cflow.ts +60 -0
- package/examples/comfy-cloud/qwen-image-i2i-2509.cflow.ts +75 -0
- package/examples/comfy-cloud/qwen-image-t2i-2512.cflow.ts +63 -0
- package/examples/comfy-cloud/sdk.d.ts +21683 -13737
- package/examples/comfy-cloud/stable-audio3-t2a.cflow.ts +96 -0
- package/examples/comfy-cloud/z-image-t2i-base.cflow.ts +54 -0
- package/examples/rvion/04-krea2-turbo-t2i.cflow.ts +1 -1
- package/package.json +2 -2
- package/src/graph/ComfyNode.ts +93 -12
- package/src/host/ComfyHost.ts +37 -46
- package/src/host/ComfyManager.ts +576 -64
- package/src/litegraph/CanonicalWorkflow.ts +3 -0
- package/src/litegraph/LiteGraphJSON.ts +2 -2
- package/src/litegraph/LiteGraphNodeInput.ts +2 -2
- package/src/litegraph/LiteGraphNodeOutput.ts +2 -2
- package/src/litegraph/convertFlowToLiteGraphJSON.ts +112 -37
- package/src/litegraph/expandSubgraphs.ts +72 -4
- package/src/litegraph/normalizeWorkflow.ts +7 -1
- package/src/manager/ComfyRegistry.ts +2 -0
- package/src/manager/generated/KnownComfyCustomNodeName.ts +6354 -1680
- package/src/manager/generated/KnownComfyPluginTitle.ts +718 -356
- package/src/manager/generated/KnownComfyPluginURL.ts +357 -181
- package/src/manager/generated/KnownModel_Base.ts +9 -5
- package/src/manager/generated/KnownModel_FileName.ts +135 -0
- package/src/manager/generated/KnownModel_Name.ts +135 -0
- package/src/manager/generated/KnownModel_SavePath.ts +16 -14
- package/src/manager/generated/KnownModel_Type.ts +15 -13
- package/src/manager/installedView.ts +178 -0
- package/src/manager/json/custom-node-list.json +4018 -2248
- package/src/manager/json/extension-node-map.json +8903 -2964
- package/src/manager/json/github-stats.json +10796 -10036
- package/src/manager/json/model-list.json +298 -1
- package/src/manager/loaders/step4_model-list-loader.ts +1 -0
- package/src/manager/types/ComfyManagerAPIModelList.ts +3 -0
- package/src/manager/types/ComfyManagerAPIPluginList.ts +19 -0
- package/src/runner/ComfyExecution.ts +4 -1
- package/src/runner/ComfyWsApi.ts +82 -15
- package/src/sdk-generator/ComfySchema.ts +10 -1
- package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +4 -1
- package/src/sdk-generator/comfyui-sdk-codegen.ts +61 -20
- package/src/sdk-generator/inputWidgetKind.ts +19 -4
- package/src/sdk-generator/litegraphToApiRequestPayload.ts +157 -35
- package/dist/state-zTow5ucI.js.map +0 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// stable-audio3 t2a on Comfy Cloud — Stable Audio 3 Medium text to audio: music, instruments, sound effects or one-shots; distilled or base model
|
|
2
|
+
// source template: audio_stable_audio_3_medium.json (official workflow-templates), the base choice follows audio_stable_audio_3_medium_base.json
|
|
3
|
+
// needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
|
|
4
|
+
// note: audio outputs PERSIST on the host (upstream ships no websocket saver for audio — image examples stream ephemerally)
|
|
5
|
+
// run directly: bun examples/comfy-cloud/stable-audio3-t2a.cflow.ts ["prompt"] [seed]
|
|
6
|
+
import { v } from 'comfy-ts'
|
|
7
|
+
// the template's four per-category system prompts, verbatim, shared with rvion 12 (the same model on the local box)
|
|
8
|
+
import { SA3_CATEGORIES, sa3Reprompt } from '../rvion/stableAudio3Prompts.ts'
|
|
9
|
+
import { cloudHost, requireCloudKey } from './cloudHost.ts'
|
|
10
|
+
|
|
11
|
+
const host = await cloudHost()
|
|
12
|
+
|
|
13
|
+
// each checkpoint with its own template's sampling: the distilled one runs 8 steps at cfg 1, the base one 50 at cfg 7
|
|
14
|
+
const MODELS = {
|
|
15
|
+
medium: { ckpt: 'stable_audio_3_medium.safetensors', steps: 8, cfg: 1 },
|
|
16
|
+
'medium base': { ckpt: 'stable_audio_3_medium_base.safetensors', steps: 50, cfg: 7 },
|
|
17
|
+
} as const
|
|
18
|
+
|
|
19
|
+
export const stableAudio3T2a = host.defineWorkflow({
|
|
20
|
+
id: 'stable-audio3-t2a',
|
|
21
|
+
vars: {
|
|
22
|
+
// ONE prompt var: a plain description is enough when `reprompt` is on (`//` lines are comments)
|
|
23
|
+
prompt: v.prompt(
|
|
24
|
+
'Tropical house track with marimba, steel drums, soft synths, smooth bass, layered percussion, and light piano riffs for sunny chill dance vibes',
|
|
25
|
+
),
|
|
26
|
+
seed: v.seed(42),
|
|
27
|
+
model: v.choice(['medium', 'medium base'], 'medium', 'model'),
|
|
28
|
+
category: v.choice(SA3_CATEGORIES, 'Music', 'category'),
|
|
29
|
+
// on: a qwen3.5 2b first rewrites the description with the category's system prompt and the target length
|
|
30
|
+
reprompt: v.toggle(true, 'reprompt'),
|
|
31
|
+
seconds: v.float(150, { min: 1, max: 300 }),
|
|
32
|
+
},
|
|
33
|
+
build: (b, vars) => {
|
|
34
|
+
const m = MODELS[vars.model]
|
|
35
|
+
const ckpt = b.CheckpointLoaderSimple({ ckpt_name: m.ckpt })
|
|
36
|
+
const clip = b.CLIPLoader({ clip_name: 't5gemma_b_b_ul2.safetensors', type: 'stable_audio', device: 'default' })
|
|
37
|
+
|
|
38
|
+
const text = vars.reprompt
|
|
39
|
+
? b.TextGenerate({
|
|
40
|
+
clip: b.CLIPLoader({
|
|
41
|
+
clip_name: 'qwen3.5_2b_bf16.safetensors',
|
|
42
|
+
type: 'stable_diffusion',
|
|
43
|
+
device: 'default',
|
|
44
|
+
}),
|
|
45
|
+
prompt: sa3Reprompt({
|
|
46
|
+
category: vars.category,
|
|
47
|
+
input: vars.prompt.positive,
|
|
48
|
+
seconds: Math.floor(vars.seconds),
|
|
49
|
+
}),
|
|
50
|
+
max_length: 256,
|
|
51
|
+
sampling_mode: 'on',
|
|
52
|
+
'sampling_mode.temperature': 0.7,
|
|
53
|
+
'sampling_mode.top_k': 64,
|
|
54
|
+
'sampling_mode.top_p': 0.95,
|
|
55
|
+
'sampling_mode.min_p': 0.05,
|
|
56
|
+
'sampling_mode.repetition_penalty': 1.05,
|
|
57
|
+
'sampling_mode.seed': 0,
|
|
58
|
+
thinking: false,
|
|
59
|
+
use_default_template: true,
|
|
60
|
+
mtp: 'auto',
|
|
61
|
+
}).outputs.generated_text
|
|
62
|
+
: vars.prompt.positive
|
|
63
|
+
|
|
64
|
+
// lcm sampling against an empty negative
|
|
65
|
+
const samples = b.KSampler({
|
|
66
|
+
model: ckpt.outputs.MODEL,
|
|
67
|
+
positive: b.CLIPTextEncode({ clip, text }),
|
|
68
|
+
negative: b.CLIPTextEncode({ clip, text: '' }),
|
|
69
|
+
latent_image: b.EmptyLatentAudio({ seconds: vars.seconds, batch_size: 1 }),
|
|
70
|
+
seed: vars.seed,
|
|
71
|
+
steps: m.steps,
|
|
72
|
+
cfg: m.cfg,
|
|
73
|
+
sampler_name: 'lcm',
|
|
74
|
+
scheduler: 'simple',
|
|
75
|
+
denoise: 1,
|
|
76
|
+
})
|
|
77
|
+
b.SaveAudioAdvanced({
|
|
78
|
+
audio: b.VAEDecodeAudio({ samples, vae: ckpt.outputs.VAE }),
|
|
79
|
+
filename_prefix: 'comfy-ts-zoo/stable-audio3-t2a',
|
|
80
|
+
format: 'mp3',
|
|
81
|
+
'format.quality': 'V0',
|
|
82
|
+
})
|
|
83
|
+
},
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
export default stableAudio3T2a
|
|
87
|
+
|
|
88
|
+
// standalone run (skipped when another driver — e.g. the TUI — imports this module)
|
|
89
|
+
if (import.meta.main) {
|
|
90
|
+
requireCloudKey()
|
|
91
|
+
if (process.argv[2]) stableAudio3T2a.vars.prompt.set(process.argv[2])
|
|
92
|
+
if (process.argv[3]) stableAudio3T2a.vars.seed.set(Number(process.argv[3]))
|
|
93
|
+
const execution = await stableAudio3T2a.run({ log: true, save: { prefix: 'comfy-ts-zoo/stable-audio3-t2a' } })
|
|
94
|
+
for (const audio of execution.audios) console.log(`🟢 ${audio.absPath}`)
|
|
95
|
+
host.disconnect()
|
|
96
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// z-image t2i base on Comfy Cloud — Z-Image base bf16, the undistilled model: 25 steps with real cfg and a negative prompt
|
|
2
|
+
// source template: image_z_image.json (official workflow-templates)
|
|
3
|
+
// needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
|
|
4
|
+
// run directly: bun examples/comfy-cloud/z-image-t2i-base.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 zImageT2iBase = host.defineWorkflow({
|
|
11
|
+
id: 'z-image-t2i-base',
|
|
12
|
+
vars: {
|
|
13
|
+
// ONE prompt var: `- ` lines are the NEGATIVE prompt, `//` lines are comments
|
|
14
|
+
prompt: v.prompt(
|
|
15
|
+
'A fashion photograph full of surreal romanticism, low-angle shot against a clear light blue sky. The vegetation is rendered in shades of blue, from ice blue to deep cobalt, with delicate realistic leaves; warm brown trunks contrast with the cool foliage like a dreamy forest from another world. A model in a yellow and white vertically striped long dress walks slowly on the sand, the noon sun casting clear shadows. Clean, transparent colors, quiet and poetic high-fashion mood.',
|
|
16
|
+
),
|
|
17
|
+
seed: v.seed(42),
|
|
18
|
+
steps: v.int(25, { min: 1, max: 80 }),
|
|
19
|
+
cfg: v.float(4, { min: 1, max: 10 }),
|
|
20
|
+
size: v.size({ width: 1024, height: 1024 }),
|
|
21
|
+
},
|
|
22
|
+
build: (b, vars) => {
|
|
23
|
+
const model = b.ModelSamplingAuraFlow({
|
|
24
|
+
model: b.UNETLoader({ unet_name: 'z_image_bf16.safetensors', weight_dtype: 'default' }),
|
|
25
|
+
shift: 3,
|
|
26
|
+
})
|
|
27
|
+
const clip = b.CLIPLoader({ clip_name: 'qwen_3_4b.safetensors', type: 'lumina2', device: 'default' })
|
|
28
|
+
const samples = b.KSampler({
|
|
29
|
+
model,
|
|
30
|
+
positive: b.CLIPTextEncode({ clip, text: vars.prompt.positive }),
|
|
31
|
+
negative: b.CLIPTextEncode({ clip, text: vars.prompt.negative }),
|
|
32
|
+
latent_image: b.EmptySD3LatentImage({ width: vars.size.width, height: vars.size.height, batch_size: 1 }),
|
|
33
|
+
seed: vars.seed,
|
|
34
|
+
steps: vars.steps,
|
|
35
|
+
cfg: vars.cfg,
|
|
36
|
+
sampler_name: 'res_multistep',
|
|
37
|
+
scheduler: 'simple',
|
|
38
|
+
denoise: 1,
|
|
39
|
+
})
|
|
40
|
+
b.SaveImageWebsocket({ images: b.VAEDecode({ samples, vae: b.VAELoader({ vae_name: 'ae.safetensors' }) }) })
|
|
41
|
+
},
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
export default zImageT2iBase
|
|
45
|
+
|
|
46
|
+
// standalone run (skipped when another driver — e.g. the TUI — imports this module)
|
|
47
|
+
if (import.meta.main) {
|
|
48
|
+
requireCloudKey()
|
|
49
|
+
if (process.argv[2]) zImageT2iBase.vars.prompt.set(process.argv[2])
|
|
50
|
+
if (process.argv[3]) zImageT2iBase.vars.seed.set(Number(process.argv[3]))
|
|
51
|
+
const execution = await zImageT2iBase.run({ log: true, save: { prefix: 'comfy-ts-zoo/z-image-t2i-base' } })
|
|
52
|
+
for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
|
|
53
|
+
host.disconnect()
|
|
54
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// krea2 turbo text-to-image, ported from a real production pipeline
|
|
2
|
-
// (
|
|
2
|
+
// (a game's "unified" sprite flow). krea2 turbo UNET + standard LoraLoader chain
|
|
3
3
|
// → KSampler(8 steps, cfg 1) → RMBG cutout → transparent png game sprite.
|
|
4
4
|
//
|
|
5
5
|
// run directly: bun examples/rvion/04-krea2-turbo-t2i.cflow.ts ["prompt"] [seed]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comfy-ts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.1",
|
|
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",
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"oxfmt": "^0.60.0",
|
|
141
141
|
"oxlint": "^1.75.0",
|
|
142
142
|
"oxlint-tsgolint": "^7.0.2001",
|
|
143
|
-
"rvlib-shipkit": "^2.
|
|
143
|
+
"rvlib-shipkit": "^2.25.0",
|
|
144
144
|
"rvlib-ts-tools": "^0.3.3",
|
|
145
145
|
"tsdown": "^0.22.14",
|
|
146
146
|
"typescript": "^7.0.2"
|
package/src/graph/ComfyNode.ts
CHANGED
|
@@ -9,13 +9,14 @@ import {
|
|
|
9
9
|
containerInstanceSlotType,
|
|
10
10
|
defaultValueForWidget,
|
|
11
11
|
} from 'src/sdk-generator/inputWidgetKind.ts'
|
|
12
|
-
import type { DynamicComboOption } from 'src/sdk-generator/inputWidgetKind.ts'
|
|
12
|
+
import type { DynamicComboOption, RawInputSpecEntry } from 'src/sdk-generator/inputWidgetKind.ts'
|
|
13
13
|
import type { Maybe } from 'src/types/index.ts'
|
|
14
14
|
import { comfyColors } from 'src/utils/ComfyColors.ts'
|
|
15
15
|
import { auto_ } from 'src/graph/autoValue.ts'
|
|
16
16
|
import type { ComfyNodeId, ComfyNodeMetadata } from 'src/graph/ComfyNodeID.ts'
|
|
17
17
|
import { ComfyNodeOutput } from 'src/graph/ComfyNodeOutput.ts'
|
|
18
18
|
import { NodeSlotSize, NodeTitleHeight, nodeLineHeight } from 'src/graph/NodeSlotSize.ts'
|
|
19
|
+
import { exhaust } from 'src/utils/exhaust.ts'
|
|
19
20
|
|
|
20
21
|
type NodeExecutionStatus = 'executing' | 'done' | 'error' | 'waiting' | 'cached' | null
|
|
21
22
|
|
|
@@ -185,21 +186,39 @@ export class ComfyNode<
|
|
|
185
186
|
_convertPromptExtToPrompt(promptExt: ComfyApiNodeJson): ComfyApiNodeJson {
|
|
186
187
|
const inputs: { [inputName: string]: any } = {}
|
|
187
188
|
const _done = new Set<string>()
|
|
188
|
-
/** every dotted key
|
|
189
|
+
/** every dotted key a dynamic input wrote or dropped on purpose: the rest loop skips them */
|
|
189
190
|
const _comboBranchKeys = new Set<string>()
|
|
190
191
|
for (const i of this.$schema.inputs) {
|
|
191
192
|
_done.add(i.nameInComfy)
|
|
192
193
|
const kind = classifySchemaInput(i)
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
194
|
+
switch (kind.kind) {
|
|
195
|
+
case 'dynamic-combo':
|
|
196
|
+
this._writeDynamicCombo({
|
|
197
|
+
name: i.nameInComfy,
|
|
198
|
+
options: kind.options,
|
|
199
|
+
defaultKey: kind.defaultKey,
|
|
200
|
+
provided: promptExt.inputs,
|
|
201
|
+
out: inputs,
|
|
202
|
+
claimed: _comboBranchKeys,
|
|
203
|
+
})
|
|
204
|
+
continue
|
|
205
|
+
case 'dynamic-group':
|
|
206
|
+
this._writeDynamicGroup({
|
|
207
|
+
name: i.nameInComfy,
|
|
208
|
+
fields: kind.fields,
|
|
209
|
+
min: kind.min,
|
|
210
|
+
max: kind.max,
|
|
211
|
+
provided: promptExt.inputs,
|
|
212
|
+
out: inputs,
|
|
213
|
+
claimed: _comboBranchKeys,
|
|
214
|
+
})
|
|
215
|
+
continue
|
|
216
|
+
case 'widget':
|
|
217
|
+
case 'slot':
|
|
218
|
+
case 'dynamic-container':
|
|
219
|
+
break
|
|
220
|
+
default:
|
|
221
|
+
exhaust(kind)
|
|
203
222
|
}
|
|
204
223
|
const value = this.serializeValue(i.nameInComfy, promptExt.inputs[i.nameInComfy])
|
|
205
224
|
// absent optionals (autogrow containers included) stay OUT of the
|
|
@@ -253,6 +272,61 @@ export class ComfyNode<
|
|
|
253
272
|
}
|
|
254
273
|
}
|
|
255
274
|
|
|
275
|
+
/** dynamic group → the row array becomes `<decl>.<row>.<field>` keys, absent fields filled
|
|
276
|
+
* from the schema (architecture.md, dynamic group). No array = a prompt json whose dotted
|
|
277
|
+
* keys are already the rows: they pass through the rest loop untouched */
|
|
278
|
+
private _writeDynamicGroup(p: {
|
|
279
|
+
name: string
|
|
280
|
+
fields: RawInputSpecEntry[]
|
|
281
|
+
min: number
|
|
282
|
+
max: number
|
|
283
|
+
provided: { [k: string]: unknown }
|
|
284
|
+
out: { [k: string]: any }
|
|
285
|
+
claimed: Set<string>
|
|
286
|
+
}): void {
|
|
287
|
+
const where = `${this.$schema.nodeKey}#${this.uid}`
|
|
288
|
+
const raw = p.provided[p.name]
|
|
289
|
+
const prefix = `${p.name}.`
|
|
290
|
+
if (raw == null) {
|
|
291
|
+
const hasRows = Object.keys(p.provided).some((k) => k.startsWith(prefix))
|
|
292
|
+
if (!hasRows && p.min > 0)
|
|
293
|
+
this.graph.recordProblem(`🔴 "${p.name}" on ${where} needs at least ${p.min} row(s)`)
|
|
294
|
+
return
|
|
295
|
+
}
|
|
296
|
+
// the array wins over stray dotted keys of the same group
|
|
297
|
+
for (const k of Object.keys(p.provided)) if (k.startsWith(prefix)) p.claimed.add(k)
|
|
298
|
+
if (!Array.isArray(raw)) {
|
|
299
|
+
this.graph.recordProblem(`🔴 "${p.name}" on ${where} takes an array of rows, got ${JSON.stringify(raw)}`)
|
|
300
|
+
return
|
|
301
|
+
}
|
|
302
|
+
if (raw.length < p.min || raw.length > p.max)
|
|
303
|
+
this.graph.recordProblem(
|
|
304
|
+
`🔴 "${p.name}" on ${where} has ${raw.length} row(s), the host takes ${p.min} to ${p.max}`,
|
|
305
|
+
)
|
|
306
|
+
raw.forEach((row: unknown, ix) => {
|
|
307
|
+
if (typeof row !== 'object' || row == null || Array.isArray(row)) {
|
|
308
|
+
this.graph.recordProblem(`🔴 "${p.name}" row ${ix} on ${where} is not an object: ${JSON.stringify(row)}`)
|
|
309
|
+
return
|
|
310
|
+
}
|
|
311
|
+
const given = new Map(Object.entries(row))
|
|
312
|
+
for (const field of p.fields) {
|
|
313
|
+
const dotted = `${p.name}.${ix}.${field.name}`
|
|
314
|
+
const value = given.get(field.name)
|
|
315
|
+
p.out[dotted] =
|
|
316
|
+
value == null
|
|
317
|
+
? defaultValueForWidget({
|
|
318
|
+
type: typeof field.type === 'string' ? field.type : 'COMBO',
|
|
319
|
+
opts: field.opts,
|
|
320
|
+
enumValues: Array.isArray(field.type) ? field.type.filter(isScalarValue) : undefined,
|
|
321
|
+
})
|
|
322
|
+
: this.serializeValue(dotted, value)
|
|
323
|
+
given.delete(field.name)
|
|
324
|
+
}
|
|
325
|
+
for (const extra of given.keys())
|
|
326
|
+
this.graph.recordProblem(`🔴 "${p.name}" row ${ix} on ${where} has no field "${extra}"`)
|
|
327
|
+
})
|
|
328
|
+
}
|
|
329
|
+
|
|
256
330
|
/** return the list of nodes piped into this node */
|
|
257
331
|
_incomingNodes(): ComfyNodeId[] {
|
|
258
332
|
const incomingNodes: ComfyNodeId[] = []
|
|
@@ -454,6 +528,13 @@ export class ComfyNode<
|
|
|
454
528
|
const slotType = containerInstanceSlotType(decl.opts)
|
|
455
529
|
if (kind.kind === 'dynamic-container' && kind.instanceNames.includes(name.slice(dot + 1)) && slotType != null)
|
|
456
530
|
return slotType
|
|
531
|
+
// dynamic group row field `decl.<row>.<field>`: the template field carries the type
|
|
532
|
+
if (kind.kind === 'dynamic-group') {
|
|
533
|
+
const rest = name.slice(dot + 1)
|
|
534
|
+
const fieldName = rest.slice(rest.indexOf('.') + 1)
|
|
535
|
+
const field = kind.fields.find((f) => f.name === fieldName)
|
|
536
|
+
if (rest.includes('.') && typeof field?.type === 'string') return field.type
|
|
537
|
+
}
|
|
457
538
|
}
|
|
458
539
|
throw new Error(
|
|
459
540
|
`🔴 no input "${name}" on ${this.$schema.nodeKey}: cannot tell which output of the linked node to use`,
|
package/src/host/ComfyHost.ts
CHANGED
|
@@ -24,6 +24,8 @@ import {
|
|
|
24
24
|
type PromptRelated_WsMsg,
|
|
25
25
|
type WsMsg,
|
|
26
26
|
WsMsg_ark,
|
|
27
|
+
isIgnoredWsEventType,
|
|
28
|
+
isRoutedWsEventType,
|
|
27
29
|
WsMsgLogsData_ark,
|
|
28
30
|
} from 'src/runner/ComfyWsApi.ts'
|
|
29
31
|
import { ComfySchema } from 'src/sdk-generator/ComfySchema.ts'
|
|
@@ -161,42 +163,12 @@ export class ComfyHost<ID extends string = string> {
|
|
|
161
163
|
this.schema = new ComfySchema({ embeddings: [], spec: {} })
|
|
162
164
|
}
|
|
163
165
|
|
|
164
|
-
/**
|
|
165
|
-
matchRequirements = (requirements: Requirements[]): boolean =>
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const plugins: ComfyManagerPluginInfo[] = repo.plugins_byNodeKey.get(req.nodeName) ?? []
|
|
171
|
-
if (!plugins.find((i) => this.manager.isPluginInstalled(i.title))) {
|
|
172
|
-
// console.log(`[❌ A] ${JSON.stringify(req)} NOT MATCHED`)
|
|
173
|
-
return false
|
|
174
|
-
}
|
|
175
|
-
} else if (req.type === 'customNodesByTitle') {
|
|
176
|
-
const plugin: ComfyManagerPluginInfo | undefined = repo.plugins_byTitle.get(req.title)
|
|
177
|
-
if (plugin == null) continue
|
|
178
|
-
if (!this.manager.isPluginInstalled(plugin.title)) {
|
|
179
|
-
// console.log(`[❌ B] ${JSON.stringify(req)} NOT MATCHED`)
|
|
180
|
-
return false
|
|
181
|
-
}
|
|
182
|
-
} else if (req.type === 'customNodesByURI') {
|
|
183
|
-
const plugin: ComfyManagerPluginInfo | undefined = repo.plugins_byFile.get(req.uri)
|
|
184
|
-
if (plugin == null) continue
|
|
185
|
-
if (!this.manager.isPluginInstalled(plugin.title)) {
|
|
186
|
-
// console.log(`[❌ C] ${JSON.stringify(req)} NOT MATCHED`)
|
|
187
|
-
return false
|
|
188
|
-
}
|
|
189
|
-
} else if (req.type === 'modelInManager') {
|
|
190
|
-
if (!this.manager.isModelInstalled(req.modelName)) {
|
|
191
|
-
// console.log(`[❌ D] ${JSON.stringify(req)} NOT MATCHED`)
|
|
192
|
-
return false
|
|
193
|
-
}
|
|
194
|
-
} else {
|
|
195
|
-
// exhaust(req.type)
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
return true
|
|
199
|
-
}
|
|
166
|
+
/** false only when a requirement is known missing; an undecided one passes with a warning (manager.matchRequirements) */
|
|
167
|
+
matchRequirements = (requirements: Requirements[]): boolean => this.manager.matchRequirements(requirements)
|
|
168
|
+
|
|
169
|
+
/** `missing` (known not installed, the only ones to queue for install) and `undecided` (the lists cannot say) */
|
|
170
|
+
checkRequirements = (requirements: Requirements[]): { missing: Requirements[]; undecided: Requirements[] } =>
|
|
171
|
+
this.manager.checkRequirements(requirements)
|
|
200
172
|
|
|
201
173
|
// ----- Rotating srever logs -----
|
|
202
174
|
|
|
@@ -848,8 +820,10 @@ export class ComfyHost<ID extends string = string> {
|
|
|
848
820
|
/** the session assigned to us by the server */
|
|
849
821
|
comfySessionId: string = 'temp' /** send by ComfyUI server */
|
|
850
822
|
|
|
851
|
-
/**
|
|
823
|
+
/** event types we already complained about on this connection (one log per type, no
|
|
824
|
+
* spam); both sets clear when the server assigns a new session id */
|
|
852
825
|
private _unknownBinaryFrameTypes = new Set<number>()
|
|
826
|
+
private _unknownWsEventTypes = new Set<string>()
|
|
853
827
|
|
|
854
828
|
/** handy to keep around */
|
|
855
829
|
status: ComfyStatusData['status'] | null = null
|
|
@@ -919,11 +893,27 @@ export class ComfyHost<ID extends string = string> {
|
|
|
919
893
|
return
|
|
920
894
|
}
|
|
921
895
|
|
|
922
|
-
|
|
896
|
+
let msg_: unknown = JSON.parse(String(e.data))
|
|
897
|
+
|
|
898
|
+
// ----- routed, ignored by name, or unknown (architecture.md, ws events) -----
|
|
899
|
+
const rec = typeof msg_ === 'object' && msg_ != null ? msg_ : null
|
|
900
|
+
const eventType = rec != null && 'type' in rec && typeof rec.type === 'string' ? rec.type : null
|
|
901
|
+
if (eventType != null && isIgnoredWsEventType(eventType)) return
|
|
902
|
+
if (eventType == null || !isRoutedWsEventType(eventType)) {
|
|
903
|
+
const key = eventType ?? '<no type>'
|
|
904
|
+
if (this._unknownWsEventTypes.has(key)) return
|
|
905
|
+
this._unknownWsEventTypes.add(key)
|
|
906
|
+
console.error(
|
|
907
|
+
`🔴 unknown ws event type ${JSON.stringify(key)} from host ${this.data.id}, ignored (reported once per connection)`,
|
|
908
|
+
)
|
|
909
|
+
return
|
|
910
|
+
}
|
|
923
911
|
|
|
924
|
-
//
|
|
925
|
-
if (
|
|
926
|
-
|
|
912
|
+
// the reconnect resend of the running node carries no prompt_id (server.py websocket_handler)
|
|
913
|
+
if (eventType === 'executing' && this.activePromptID != null && rec != null) {
|
|
914
|
+
const data: unknown = Reflect.get(rec, 'data')
|
|
915
|
+
if (typeof data === 'object' && data != null && !('prompt_id' in data))
|
|
916
|
+
msg_ = { type: eventType, data: { ...data, prompt_id: this.activePromptID } }
|
|
927
917
|
}
|
|
928
918
|
|
|
929
919
|
// ----- soft-validate against the schema -----
|
|
@@ -942,7 +932,11 @@ export class ComfyHost<ID extends string = string> {
|
|
|
942
932
|
this.comfySessionId = msg.data.sid
|
|
943
933
|
this._sessionResolve?.()
|
|
944
934
|
this._sessionResolve = null
|
|
945
|
-
if (sidChanged)
|
|
935
|
+
if (sidChanged) {
|
|
936
|
+
this._unknownWsEventTypes.clear()
|
|
937
|
+
this._unknownBinaryFrameTypes.clear()
|
|
938
|
+
this.onSession?.(msg.data.sid)
|
|
939
|
+
}
|
|
946
940
|
}
|
|
947
941
|
this.status = msg.data.status
|
|
948
942
|
this.onStatus?.({ queueRemaining: msg.data.status?.exec_info?.queue_remaining ?? 0 })
|
|
@@ -963,6 +957,7 @@ export class ComfyHost<ID extends string = string> {
|
|
|
963
957
|
msg.type === 'execution_start' ||
|
|
964
958
|
msg.type === 'execution_cached' ||
|
|
965
959
|
msg.type === 'execution_error' ||
|
|
960
|
+
msg.type === 'execution_interrupted' ||
|
|
966
961
|
msg.type === 'execution_success' ||
|
|
967
962
|
msg.type === 'executing' ||
|
|
968
963
|
msg.type === 'executed' ||
|
|
@@ -982,9 +977,5 @@ export class ComfyHost<ID extends string = string> {
|
|
|
982
977
|
return
|
|
983
978
|
}
|
|
984
979
|
exhaust(msg)
|
|
985
|
-
console.log('❌', 'Unknown message:', msg)
|
|
986
|
-
|
|
987
|
-
toastError('Unknown message type: ' + JSON.stringify(msg.type))
|
|
988
|
-
// throw new Error('Unknown message type: ' + JSON.stringify(msg))
|
|
989
980
|
}
|
|
990
981
|
}
|