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.
Files changed (80) hide show
  1. package/dist/cli.js +3 -3
  2. package/dist/index.cjs +1078 -190
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +1185 -410
  5. package/dist/index.d.ts +1185 -410
  6. package/dist/index.js +1078 -190
  7. package/dist/index.js.map +1 -1
  8. package/dist/{run-run-tg82jUIk.js → run-run-Zr699h2S.js} +2 -2
  9. package/dist/{run-run-tg82jUIk.js.map → run-run-Zr699h2S.js.map} +1 -1
  10. package/dist/{run-tui-Bw7BA75d.js → run-tui-CeM1GOJP.js} +2 -2
  11. package/dist/{run-tui-Bw7BA75d.js.map → run-tui-CeM1GOJP.js.map} +1 -1
  12. package/dist/serve-web.js +47 -47
  13. package/dist/{state-zTow5ucI.js → state-C067Kbew.js} +1079 -191
  14. package/dist/state-C067Kbew.js.map +1 -0
  15. package/dist/web.d.ts +1203 -428
  16. package/dist/web.js +1078 -190
  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 +37 -46
  48. package/src/host/ComfyManager.ts +576 -64
  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 +72 -4
  55. package/src/litegraph/normalizeWorkflow.ts +7 -1
  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 +178 -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 +157 -35
  80. package/dist/state-zTow5ucI.js.map +0 -1
@@ -1,4 +1,5 @@
1
1
  import type { Maybe } from 'src/types/index.ts'
2
+ import { exhaust } from 'src/utils/exhaust.ts'
2
3
  import { CodeBuffer } from 'src/utils/CodeBuffer.ts'
3
4
  import { escapeJSKey } from 'src/utils/escapeJSKey.ts'
4
5
  import type { ComfySchema } from 'src/sdk-generator/ComfySchema.ts'
@@ -45,6 +46,17 @@ const dynamicComboUnion = (p: {
45
46
  return ` & (${members.join(' | ')})`
46
47
  }
47
48
 
49
+ /** one dynamic-group row as an object type: a field is optional when it has a default or sits in
50
+ * the template's optional section (ComfyNode fills it, agent/sdk-codegen.md) */
51
+ const dynamicGroupRow = (fields: RawInputSpecEntry[]): string => {
52
+ const members = fields.map((e) => {
53
+ const opts = isRecord(e.opts) ? e.opts : null
54
+ const optional = !e.required || opts?.['default'] !== undefined
55
+ return `${escapeJSKey(e.name)}${optional ? '?' : ''}: ${branchInputType(e)}`
56
+ })
57
+ return `{ ${members.join('; ')} }`
58
+ }
59
+
48
60
  /**
49
61
  * convert a host id to the namespace name it gets inside the global `Comfy` namespace
50
62
  * e.g. 'windows-1' -> 'Windows1', 'my_cloud.instance' -> 'MyCloudInstance'
@@ -111,6 +123,8 @@ export function codegenSDK(this: ComfySchema, opts: CodegenOptions): string {
111
123
 
112
124
  // #region IN ---------------------------------------------------------------------------------
113
125
  const nodes = this.nodes.toSorted((a, b) => a.nodeKey.localeCompare(b.nodeKey))
126
+ /** one row type per dynamic group, named once so a long COMBO union is not printed twice */
127
+ const groupRows: [key: string, row: string][] = []
114
128
  p(`interface IN {`)
115
129
  b.indent()
116
130
  for (const n of nodes) {
@@ -123,27 +137,45 @@ export function codegenSDK(this: ComfySchema, opts: CodegenOptions): string {
123
137
  // decl itself — the backend prompt input is `<name>.<inst>`, the
124
138
  // first template.min instances required (agent/sdk-codegen.md)
125
139
  const kind = classifySchemaInput(i)
126
- if (kind.kind === 'dynamic-container') {
127
- const instType = containerInstanceSlotType(i.opts)
128
- if (instType != null) {
129
- kind.instanceNames.forEach((instName, ix) => {
130
- const opt = ix >= kind.requiredCount ? '?' : ''
131
- p(` ${escapeJSKey(`${i.nameInComfy}.${instName}`)}${opt}: Accepts[${JSON.stringify(instType)}]`)
132
- })
140
+ switch (kind.kind) {
141
+ case 'dynamic-container': {
142
+ const instType = containerInstanceSlotType(i.opts)
143
+ if (instType != null) {
144
+ kind.instanceNames.forEach((instName, ix) => {
145
+ const opt = ix >= kind.requiredCount ? '?' : ''
146
+ p(` ${escapeJSKey(`${i.nameInComfy}.${instName}`)}${opt}: Accepts[${JSON.stringify(instType)}]`)
147
+ })
148
+ }
149
+ continue
133
150
  }
134
- continue
135
- }
136
- if (kind.kind === 'dynamic-combo') {
137
- const optsDyn = typeof i.opts === 'string' ? null : i.opts
138
- comboSuffixes.push(
139
- dynamicComboUnion({
140
- name: i.nameInComfy,
141
- nameEscaped: i.nameInComfyEscaped,
142
- options: kind.options,
143
- keyOptional: optsDyn?.default !== undefined || !i.required,
144
- }),
145
- )
146
- continue
151
+ case 'dynamic-combo': {
152
+ const optsDyn = typeof i.opts === 'string' ? null : i.opts
153
+ comboSuffixes.push(
154
+ dynamicComboUnion({
155
+ name: i.nameInComfy,
156
+ nameEscaped: i.nameInComfyEscaped,
157
+ options: kind.options,
158
+ keyOptional: optsDyn?.default !== undefined || !i.required,
159
+ }),
160
+ )
161
+ continue
162
+ }
163
+ case 'dynamic-group': {
164
+ // an array of row objects, the backend's own list[dict] value; ComfyNode
165
+ // expands it to the dotted `<decl>.<row>.<field>` prompt keys
166
+ const rowKey = `${n.nodeKey}.${i.nameInComfy}`
167
+ groupRows.push([rowKey, dynamicGroupRow(kind.fields)])
168
+ const row = `GroupRow[${JSON.stringify(rowKey)}]`
169
+ p(` /** min=${kind.min} max=${kind.max} rows */`)
170
+ if (kind.min > 0) p(` ${i.nameInComfyEscaped}: [${row}, ...${row}[]]`)
171
+ else p(` ${i.nameInComfyEscaped}?: ${row}[]`)
172
+ continue
173
+ }
174
+ case 'widget':
175
+ case 'slot':
176
+ break
177
+ default:
178
+ exhaust(kind)
147
179
  }
148
180
  const opts_ = typeof i.opts === 'string' ? null : i.opts
149
181
  let type = `Accepts[${JSON.stringify(i.typeName)}]`
@@ -181,6 +213,15 @@ export function codegenSDK(this: ComfySchema, opts: CodegenOptions): string {
181
213
  b.deindent()
182
214
  p('}')
183
215
  p('')
216
+ if (groupRows.length > 0) {
217
+ p(`/** one row of each dynamic group input, keyed \`<node>.<input>\` */`)
218
+ p(`interface GroupRow {`)
219
+ b.indent()
220
+ for (const [key, row] of groupRows) p(`${JSON.stringify(key)}: ${row}`)
221
+ b.deindent()
222
+ p('}')
223
+ p('')
224
+ }
184
225
 
185
226
  // #region OUT --------------------------------------------------------------------------------
186
227
  p(`interface OUT {`)
@@ -27,6 +27,8 @@ export type InputWidgetKind =
27
27
  }
28
28
  | { kind: 'dynamic-combo'; options: DynamicComboOption[]; defaultKey: string }
29
29
  | { kind: 'dynamic-container'; instanceNames: string[]; requiredCount: number }
30
+ /** widget rows: prompt keys `<decl>.<row>.<field>`, saved run `[count, …row field runs]` (architecture.md, dynamic group) */
31
+ | { kind: 'dynamic-group'; fields: RawInputSpecEntry[]; min: number; max: number }
30
32
 
31
33
  /** one raw `[type, opts]` input entry as spelled in object_info (dynamic-combo branches arrive in this raw form) */
32
34
  export type RawInputSpecEntry = {
@@ -106,6 +108,15 @@ const parseContainer = (template: Record<string, unknown>): InputWidgetKind => {
106
108
  }
107
109
  }
108
110
 
111
+ /** dynamic group (`template` holding `required`/`optional` sections itself): fields in the
112
+ * frontend's creation order, required then optional; `_io.py _DynamicGroup` defaults min 0, max 20 */
113
+ const parseGroup = (o: Record<string, unknown>, template: Record<string, unknown>): InputWidgetKind => ({
114
+ kind: 'dynamic-group',
115
+ fields: flattenInputSections(template),
116
+ min: typeof o['min'] === 'number' ? o['min'] : 0,
117
+ max: typeof o['max'] === 'number' ? o['max'] : 20,
118
+ })
119
+
109
120
  /**
110
121
  * the single template sub-input's slot type of an autogrow container
111
122
  * (`'IMAGE'` for TextEncodeBooguEdit.images). null when opts are not an
@@ -179,14 +190,18 @@ export const classifyWidgetInput = (p: {
179
190
  }
180
191
  return { kind: 'widget', consumes: controlConsumes(o, p.type, p.name), strictValues: true, prefixValues: [] }
181
192
  }
182
- // 6. template WITH nested input = autogrow container; WITHOUT = matchtype slot typing
193
+ // 6. template WITH nested input = autogrow container; WITH its own required/optional
194
+ // sections = dynamic group; with neither = matchtype slot typing
183
195
  const template = o?.['template']
184
- if (isRecord(template)) {
196
+ if (o != null && isRecord(template)) {
185
197
  if (isRecord(template['input'])) return parseContainer(template)
198
+ if (isRecord(template['required']) || isRecord(template['optional'])) return parseGroup(o, template)
186
199
  return { kind: 'slot' }
187
200
  }
188
- // 7. socketless: a widget that never has a socket (IMAGECOMPARE, COLOR); value domain unknown
189
- if (o?.['socketless'] === true) return { kind: 'widget', consumes: 1, strictValues: false, prefixValues: [] }
201
+ // 7. a socketless KEY, true or false: only a backend WidgetInput emits it (true = no socket,
202
+ // IMAGECOMPARE, COLOR; false = a socket too, BOUNDING_BOXES, COLORS); value domain unknown
203
+ if (typeof o?.['socketless'] === 'boolean')
204
+ return { kind: 'widget', consumes: 1, strictValues: false, prefixValues: [] }
190
205
  // 8. known empty-config frontend widgets (LOAD_3D), the one non-config exception
191
206
  const emptyConfigEntry = EMPTY_CONFIG_FRONTEND_WIDGETS[widgetTypeName]
192
207
  if (emptyConfigEntry != null)
@@ -10,6 +10,7 @@ import type { ComfyNodeSchema } from 'src/sdk-generator/ComfyNodeSchema.ts'
10
10
  import type { ComfyApiJson, ComfyApiNodeJson } from 'src/sdk-generator/comfy-api-json.ts'
11
11
  import type { NodeInputExt } from 'src/sdk-generator/comfyui-types.ts'
12
12
  import { howManyWidgetValuesForThisInputType } from 'src/sdk-generator/Primitives.ts'
13
+ import { exhaust } from 'src/utils/exhaust.ts'
13
14
  import {
14
15
  classifySchemaInput,
15
16
  classifyWidgetInput,
@@ -101,6 +102,10 @@ export const convertLiteGraphToPrompt = (
101
102
  else if (Object.hasOwn(node.widgets.named, 'value')) PRIMITIVE_VALUES[node.id] = node.widgets.named['value']
102
103
  }
103
104
 
105
+ // indexes: a lookup per link must not scan the document (a large file stays linear)
106
+ const linksById = new Map(workflow.links.map((l) => [l.id, l]))
107
+ const nodesById = new Map(workflow.nodes.map((n) => [n.id, n]))
108
+
104
109
  // 2. every executable node
105
110
  for (const node of workflow.nodes) {
106
111
  if (isNeverExecuted(node)) continue // frontend-only nodes (reroutes/primitives unwrapped below)
@@ -212,12 +217,47 @@ export const convertLiteGraphToPrompt = (
212
217
  for (const sub of opt.inputs) consumeBranchInput(`${p.path}.${sub.name}`, sub)
213
218
  }
214
219
 
220
+ /** the row count first (named, else positional, else `min`), then every row's fields in
221
+ * template order: the frontend's saved run (architecture.md, dynamic group) */
222
+ const consumeDynamicGroup = (p: {
223
+ path: string
224
+ fields: RawInputSpecEntry[]
225
+ min: number
226
+ max: number
227
+ }): void => {
228
+ const r = resolveWidgetValue({ promptName: p.path, consumes: 1, prefixLen: 0 })
229
+ const saved = r.filled ? p.min : r.value
230
+ if (typeof saved !== 'number' || !Number.isInteger(saved) || saved < 0 || saved > p.max)
231
+ throw new WorkflowConvertError(
232
+ 'invalid-widget-value',
233
+ `node ${node.id}(${node.type}): dynamic group "${p.path}" row count is not an integer in [0, ${p.max}]: ${JSON.stringify(saved)}`,
234
+ node,
235
+ )
236
+ // the frontend clamps a short count UP to min (dynamicGroupWidget: Math.max(min, requested))
237
+ const rows = Math.max(p.min, saved)
238
+ if (r.filled || rows !== saved) LOG(`${node.type}#${node.id}.${p.path} = ${rows} rows (min ${p.min})`)
239
+ for (let row = 0; row < rows; row++)
240
+ for (const field of p.fields) consumeBranchInput(`${p.path}.${row}.${field.name}`, field)
241
+ }
242
+
215
243
  const consumeBranchInput = (subPath: string, sub: RawInputSpecEntry): void => {
216
- const kind = classifyWidgetInput({ name: sub.name, type: sub.type, opts: sub.opts })
217
- // slots and containers materialize as dotted serialized inputs, resolved as links in 2.b
218
- if (kind.kind === 'slot' || kind.kind === 'dynamic-container') return
219
- if (kind.kind === 'dynamic-combo')
220
- return consumeDynamicCombo({ path: subPath, options: kind.options, defaultKey: kind.defaultKey })
244
+ // the frontend names a branch or row widget by its full dotted path, and the seed
245
+ // heuristic of the control phantom reads that name (architecture.md, rule 9)
246
+ const kind = classifyWidgetInput({ name: subPath, type: sub.type, opts: sub.opts })
247
+ switch (kind.kind) {
248
+ // slots and containers materialize as dotted serialized inputs, resolved as links in 2.b
249
+ case 'slot':
250
+ case 'dynamic-container':
251
+ return
252
+ case 'dynamic-combo':
253
+ return consumeDynamicCombo({ path: subPath, options: kind.options, defaultKey: kind.defaultKey })
254
+ case 'dynamic-group':
255
+ return consumeDynamicGroup({ path: subPath, fields: kind.fields, min: kind.min, max: kind.max })
256
+ case 'widget':
257
+ break
258
+ default:
259
+ return exhaust(kind)
260
+ }
221
261
  const inlineEnum = Array.isArray(sub.type)
222
262
  ? sub.type.filter(
223
263
  (v): v is string | number | boolean =>
@@ -247,52 +287,70 @@ export const convertLiteGraphToPrompt = (
247
287
  kind = { kind: 'widget', consumes: legacyConsumes === 2 ? 2 : 1, strictValues: true, prefixValues: [] }
248
288
  }
249
289
 
250
- if (kind.kind === 'widget') {
251
- consumePlainWidget({
252
- promptName: field.nameInComfy,
253
- typeName: field.typeName,
254
- opts: field.opts,
255
- consumes: kind.consumes,
256
- prefixLen: kind.prefixValues.length,
257
- strict: kind.strictValues,
258
- linkedInput: input,
259
- })
260
- } else if (kind.kind === 'dynamic-combo') {
261
- consumeDynamicCombo({ path: field.nameInComfy, options: kind.options, defaultKey: kind.defaultKey })
262
- } else if (kind.kind === 'dynamic-container') {
263
- // the declaration itself never appears; the first template.min
264
- // instances must be connected (backend requires them by name)
265
- for (const instName of kind.instanceNames.slice(0, kind.requiredCount)) {
266
- const iname = `${field.nameInComfy}.${instName}`
267
- const inst = inputsInNodeJSON.find((i) => i.name === iname)
268
- if (inst?.link == null)
290
+ switch (kind.kind) {
291
+ case 'widget':
292
+ consumePlainWidget({
293
+ promptName: field.nameInComfy,
294
+ typeName: field.typeName,
295
+ opts: field.opts,
296
+ consumes: kind.consumes,
297
+ prefixLen: kind.prefixValues.length,
298
+ strict: kind.strictValues,
299
+ linkedInput: input,
300
+ })
301
+ break
302
+ case 'dynamic-combo':
303
+ consumeDynamicCombo({ path: field.nameInComfy, options: kind.options, defaultKey: kind.defaultKey })
304
+ break
305
+ case 'dynamic-group':
306
+ consumeDynamicGroup({ path: field.nameInComfy, fields: kind.fields, min: kind.min, max: kind.max })
307
+ break
308
+ case 'dynamic-container':
309
+ // the declaration itself never appears; the first template.min
310
+ // instances must be connected (backend requires them by name)
311
+ for (const instName of kind.instanceNames.slice(0, kind.requiredCount)) {
312
+ const iname = `${field.nameInComfy}.${instName}`
313
+ const inst = inputsInNodeJSON.find((i) => i.name === iname)
314
+ if (inst?.link == null)
315
+ throw new WorkflowConvertError(
316
+ 'missing-required-input',
317
+ `node ${node.id}(${node.type}): autogrow "${field.nameInComfy}" requires instance "${iname}" connected (template.min = ${kind.requiredCount})`,
318
+ node,
319
+ )
320
+ }
321
+ break
322
+ case 'slot':
323
+ // a value promoted onto a slot (io-widget era subgraph): the frontend sends the literal
324
+ if (input?.link == null && Object.hasOwn(named, field.nameInComfy)) {
325
+ inputs[field.nameInComfy] = toPromptValue(named[field.nameInComfy], {
326
+ promptName: field.nameInComfy,
327
+ strict: false,
328
+ })
329
+ break
330
+ }
331
+ if (!fieldNamesPresent.has(field.nameInComfy) && field.required)
269
332
  throw new WorkflowConvertError(
270
333
  'missing-required-input',
271
- `node ${node.id}(${node.type}): autogrow "${field.nameInComfy}" requires instance "${iname}" connected (template.min = ${kind.requiredCount})`,
334
+ `node ${node.id}(${node.type}): required input "${field.nameInComfy}" (${field.typeName}) has neither widget value nor link`,
272
335
  node,
273
336
  )
274
- }
275
- } else if (!fieldNamesPresent.has(field.nameInComfy)) {
276
- if (field.required)
277
- throw new WorkflowConvertError(
278
- 'missing-required-input',
279
- `node ${node.id}(${node.type}): required input "${field.nameInComfy}" (${field.typeName}) has neither widget value nor link`,
280
- node,
281
- )
337
+ break
338
+ default:
339
+ exhaust(kind)
282
340
  }
283
341
  }
284
342
 
285
343
  // 2.b links
286
344
  type ParentInfo = { node: CanonicalNode; link: CanonicalLink }
287
345
  const getParentNode = (linkId: LiteGraphLinkID): ParentInfo => {
288
- const link = workflow.links.find((link) => link.id === linkId)
346
+ const link = linksById.get(linkId)
289
347
  if (link == null)
290
348
  throw new WorkflowConvertError(
291
349
  'dangling-link',
292
350
  `node ${node.id}(${node.type}) references a non-existing link (id=${linkId})`,
293
351
  node,
294
352
  )
295
- const parentNode = workflow.nodes.find((n) => n.id === link.originId)
353
+ const parentNode = nodesById.get(link.originId)
296
354
  if (parentNode == null)
297
355
  throw new WorkflowConvertError(
298
356
  'dangling-link',
@@ -433,6 +491,70 @@ export const convertLiteGraphToPrompt = (
433
491
  prompt[String(node.id)] = { inputs, class_type: node.type }
434
492
  }
435
493
 
494
+ // 3. unlinked slots a subgraph input fed with no outer link take that input's promoted widget
495
+ // value, read from the sibling widget it also fed, once every node is converted
496
+ for (const node of workflow.nodes) {
497
+ const own = prompt[String(node.id)]
498
+ if (own == null) continue
499
+ for (const ipt of node.inputs) {
500
+ if (ipt.link != null || ipt.widgetSource == null || Object.hasOwn(own.inputs, ipt.name)) continue
501
+ const value = prompt[String(ipt.widgetSource.nodeId)]?.inputs[ipt.widgetSource.inputName]
502
+ if (value !== undefined) own.inputs[ipt.name] = value
503
+ }
504
+ }
505
+
506
+ // 4. a required plain input absent from the prompt. ComfyUI validates per OUTPUT node
507
+ // (execution.py validate_prompt): it runs the outputs whose upstream nodes are complete and
508
+ // rejects the prompt only when none is. Same here: a typed error when no output survives, a
509
+ // loud warning naming what ComfyUI will drop otherwise; never silent
510
+ const missing = new Map<string, { node: CanonicalNode; message: string }>()
511
+ for (const node of workflow.nodes) {
512
+ const own = prompt[String(node.id)]
513
+ const nodeSchema = schema.nodesByNameInComfy[node.type]
514
+ if (own == null || nodeSchema == null) continue
515
+ for (const field of nodeSchema.inputs) {
516
+ if (!field.required || Object.hasOwn(own.inputs, field.nameInComfy)) continue
517
+ const kind = classifySchemaInput(field).kind
518
+ if (kind !== 'slot' && kind !== 'widget') continue
519
+ missing.set(String(node.id), {
520
+ node,
521
+ message: `node ${node.id}(${node.type}): required input "${field.nameInComfy}" (${field.typeName}) is unlinked and no value covers it`,
522
+ })
523
+ break
524
+ }
525
+ }
526
+ if (missing.size > 0) {
527
+ // blocked = every node downstream of a missing input, one queue walk over the consumer
528
+ // edges: a file decides the graph depth, so no recursion here
529
+ const consumers = new Map<string, string[]>()
530
+ for (const [id, n] of Object.entries(prompt))
531
+ for (const value of Object.values(n.inputs))
532
+ if (Array.isArray(value) && typeof value[0] === 'string') {
533
+ const list = consumers.get(value[0]) ?? []
534
+ list.push(id)
535
+ consumers.set(value[0], list)
536
+ }
537
+ const blocked = new Set(missing.keys())
538
+ const queue = [...blocked]
539
+ for (let head = 0; head < queue.length; head++)
540
+ for (const next of consumers.get(queue[head] ?? '') ?? [])
541
+ if (!blocked.has(next)) {
542
+ blocked.add(next)
543
+ queue.push(next)
544
+ }
545
+ const outputs = Object.keys(prompt).filter(
546
+ (id) => schema.data.spec[prompt[id]?.class_type ?? '']?.output_node === true,
547
+ )
548
+ const dropped = outputs.filter((id) => blocked.has(id))
549
+ const first = missing.values().next().value
550
+ if (first != null && outputs.length > 0 && dropped.length === outputs.length)
551
+ throw new WorkflowConvertError('missing-required-input', first.message, first.node)
552
+ if (dropped.length > 0 || outputs.length === 0)
553
+ console.warn(
554
+ `🟡 [workflow] ComfyUI will skip output node(s) ${dropped.join(', ') || '(none in this graph)'}: ${[...missing.values()].map((m) => m.message).join('; ')}`,
555
+ )
556
+ }
557
+
436
558
  return prompt
437
559
  }
438
560