comfy-ts 2.17.0 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/{ServeApp-BSA5yzxZ.js → ServeApp-qXcQfdgT.js} +3 -3
  2. package/dist/ServeApp-qXcQfdgT.js.map +1 -0
  3. package/dist/cli.js +58 -8
  4. package/dist/cli.js.map +1 -1
  5. package/dist/index.cjs +956 -151
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +1154 -408
  8. package/dist/index.d.ts +1154 -408
  9. package/dist/index.js +956 -151
  10. package/dist/index.js.map +1 -1
  11. package/dist/{run-run-DnaMLCFn.js → run-run-Wn7H72Zg.js} +3 -3
  12. package/dist/{run-run-DnaMLCFn.js.map → run-run-Wn7H72Zg.js.map} +1 -1
  13. package/dist/{run-serve-CbKxIu6i.js → run-serve-DaXzoVTS.js} +58 -12
  14. package/dist/run-serve-DaXzoVTS.js.map +1 -0
  15. package/dist/{run-tui-B0AQWbad.js → run-tui-VWSj1D_j.js} +3 -3
  16. package/dist/{run-tui-B0AQWbad.js.map → run-tui-VWSj1D_j.js.map} +1 -1
  17. package/dist/serve-web.js +56 -48
  18. package/dist/{state-C2oDiQ26.js → state-DgwWhZWb.js} +957 -152
  19. package/dist/state-DgwWhZWb.js.map +1 -0
  20. package/dist/web.d.ts +1172 -426
  21. package/dist/web.js +956 -151
  22. package/dist/web.js.map +1 -1
  23. package/examples/comfy-cloud/ace-step15-t2a.cflow.ts +163 -0
  24. package/examples/comfy-cloud/anima-t2i-base.cflow.ts +57 -0
  25. package/examples/comfy-cloud/boogu-t2i.cflow.ts +55 -0
  26. package/examples/comfy-cloud/chronoedit-i2i.cflow.ts +95 -0
  27. package/examples/comfy-cloud/ernie-t2i-base.cflow.ts +81 -0
  28. package/examples/comfy-cloud/flux1-t2i-krea.cflow.ts +63 -0
  29. package/examples/comfy-cloud/flux2-i2i-dev.cflow.ts +83 -0
  30. package/examples/comfy-cloud/flux2-t2i-dev.cflow.ts +60 -0
  31. package/examples/comfy-cloud/hidream-o1-i2i.cflow.ts +71 -0
  32. package/examples/comfy-cloud/hidream-o1-t2i.cflow.ts +62 -0
  33. package/examples/comfy-cloud/krea2-i2i.cflow.ts +78 -0
  34. package/examples/comfy-cloud/ltx2-i2v.cflow.ts +175 -0
  35. package/examples/comfy-cloud/ltx2-t2v.cflow.ts +143 -0
  36. package/examples/comfy-cloud/ltx23-i2v.cflow.ts +189 -0
  37. package/examples/comfy-cloud/ltx23-t2v.cflow.ts +151 -0
  38. package/examples/comfy-cloud/mage-flow-i2i-turbo.cflow.ts +72 -0
  39. package/examples/comfy-cloud/mage-flow-i2i.cflow.ts +74 -0
  40. package/examples/comfy-cloud/mage-flow-t2i-turbo.cflow.ts +60 -0
  41. package/examples/comfy-cloud/mage-flow-t2i.cflow.ts +60 -0
  42. package/examples/comfy-cloud/minimax-h3-t2i.cflow.ts +64 -0
  43. package/examples/comfy-cloud/netayume-t2i.cflow.ts +60 -0
  44. package/examples/comfy-cloud/qwen-image-i2i-2509.cflow.ts +75 -0
  45. package/examples/comfy-cloud/qwen-image-t2i-2512.cflow.ts +63 -0
  46. package/examples/comfy-cloud/sdk.d.ts +21683 -13737
  47. package/examples/comfy-cloud/stable-audio3-t2a.cflow.ts +96 -0
  48. package/examples/comfy-cloud/z-image-t2i-base.cflow.ts +54 -0
  49. package/examples/rvion/04-krea2-turbo-t2i.cflow.ts +1 -1
  50. package/package.json +2 -2
  51. package/src/cli/bunHop.ts +49 -0
  52. package/src/cli/comfy-ts-cli.ts +4 -4
  53. package/src/cli/serve/run-serve.ts +51 -13
  54. package/src/cli/serve/web/components/App.tsx +2 -0
  55. package/src/cli/serve/web/components/DialogLayer.tsx +55 -0
  56. package/src/cli/serve/web/components/DraftTabs.tsx +8 -3
  57. package/src/cli/serve/web/components/PromptEnhancer.tsx +15 -9
  58. package/src/cli/serve/web/components/SideMenu.tsx +16 -8
  59. package/src/cli/serve/web/state/WebSt.ts +10 -1
  60. package/src/cli/serve/web/state/dialog.ts +59 -0
  61. package/src/cli/serve/web/state/keptLines.ts +1 -1
  62. package/src/cli/serve/web/styles.ts +8 -0
  63. package/src/graph/ComfyNode.ts +93 -12
  64. package/src/host/ComfyHost.ts +31 -10
  65. package/src/host/ComfyManager.ts +448 -62
  66. package/src/litegraph/CanonicalWorkflow.ts +3 -0
  67. package/src/litegraph/LiteGraphJSON.ts +2 -2
  68. package/src/litegraph/LiteGraphNodeInput.ts +2 -2
  69. package/src/litegraph/LiteGraphNodeOutput.ts +2 -2
  70. package/src/litegraph/convertFlowToLiteGraphJSON.ts +127 -34
  71. package/src/litegraph/expandSubgraphs.ts +14 -0
  72. package/src/litegraph/normalizeWorkflow.ts +1 -0
  73. package/src/manager/ComfyRegistry.ts +2 -0
  74. package/src/manager/generated/KnownComfyCustomNodeName.ts +6354 -1680
  75. package/src/manager/generated/KnownComfyPluginTitle.ts +718 -356
  76. package/src/manager/generated/KnownComfyPluginURL.ts +357 -181
  77. package/src/manager/generated/KnownModel_Base.ts +9 -5
  78. package/src/manager/generated/KnownModel_FileName.ts +135 -0
  79. package/src/manager/generated/KnownModel_Name.ts +135 -0
  80. package/src/manager/generated/KnownModel_SavePath.ts +16 -14
  81. package/src/manager/generated/KnownModel_Type.ts +15 -13
  82. package/src/manager/installedView.ts +176 -0
  83. package/src/manager/json/custom-node-list.json +4018 -2248
  84. package/src/manager/json/extension-node-map.json +8903 -2964
  85. package/src/manager/json/github-stats.json +10796 -10036
  86. package/src/manager/json/model-list.json +298 -1
  87. package/src/manager/loaders/step4_model-list-loader.ts +1 -0
  88. package/src/manager/types/ComfyManagerAPIModelList.ts +3 -0
  89. package/src/manager/types/ComfyManagerAPIPluginList.ts +19 -0
  90. package/src/promptEnhancers.ts +1 -1
  91. package/src/runner/ComfyExecution.ts +4 -1
  92. package/src/runner/ComfyWsApi.ts +82 -15
  93. package/src/sdk-generator/ComfySchema.ts +10 -1
  94. package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +4 -1
  95. package/src/sdk-generator/comfyui-sdk-codegen.ts +61 -20
  96. package/src/sdk-generator/inputWidgetKind.ts +19 -4
  97. package/src/sdk-generator/litegraphToApiRequestPayload.ts +141 -33
  98. package/dist/ServeApp-BSA5yzxZ.js.map +0 -1
  99. package/dist/run-serve-CbKxIu6i.js.map +0 -1
  100. package/dist/state-C2oDiQ26.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,
@@ -212,12 +213,47 @@ export const convertLiteGraphToPrompt = (
212
213
  for (const sub of opt.inputs) consumeBranchInput(`${p.path}.${sub.name}`, sub)
213
214
  }
214
215
 
216
+ /** the row count first (named, else positional, else `min`), then every row's fields in
217
+ * template order: the frontend's saved run (architecture.md, dynamic group) */
218
+ const consumeDynamicGroup = (p: {
219
+ path: string
220
+ fields: RawInputSpecEntry[]
221
+ min: number
222
+ max: number
223
+ }): void => {
224
+ const r = resolveWidgetValue({ promptName: p.path, consumes: 1, prefixLen: 0 })
225
+ const saved = r.filled ? p.min : r.value
226
+ if (typeof saved !== 'number' || !Number.isInteger(saved) || saved < 0 || saved > p.max)
227
+ throw new WorkflowConvertError(
228
+ 'invalid-widget-value',
229
+ `node ${node.id}(${node.type}): dynamic group "${p.path}" row count is not an integer in [0, ${p.max}]: ${JSON.stringify(saved)}`,
230
+ node,
231
+ )
232
+ // the frontend clamps a short count UP to min (dynamicGroupWidget: Math.max(min, requested))
233
+ const rows = Math.max(p.min, saved)
234
+ if (r.filled || rows !== saved) LOG(`${node.type}#${node.id}.${p.path} = ${rows} rows (min ${p.min})`)
235
+ for (let row = 0; row < rows; row++)
236
+ for (const field of p.fields) consumeBranchInput(`${p.path}.${row}.${field.name}`, field)
237
+ }
238
+
215
239
  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 })
240
+ // the frontend names a branch or row widget by its full dotted path, and the seed
241
+ // heuristic of the control phantom reads that name (architecture.md, rule 9)
242
+ const kind = classifyWidgetInput({ name: subPath, type: sub.type, opts: sub.opts })
243
+ switch (kind.kind) {
244
+ // slots and containers materialize as dotted serialized inputs, resolved as links in 2.b
245
+ case 'slot':
246
+ case 'dynamic-container':
247
+ return
248
+ case 'dynamic-combo':
249
+ return consumeDynamicCombo({ path: subPath, options: kind.options, defaultKey: kind.defaultKey })
250
+ case 'dynamic-group':
251
+ return consumeDynamicGroup({ path: subPath, fields: kind.fields, min: kind.min, max: kind.max })
252
+ case 'widget':
253
+ break
254
+ default:
255
+ return exhaust(kind)
256
+ }
221
257
  const inlineEnum = Array.isArray(sub.type)
222
258
  ? sub.type.filter(
223
259
  (v): v is string | number | boolean =>
@@ -247,38 +283,56 @@ export const convertLiteGraphToPrompt = (
247
283
  kind = { kind: 'widget', consumes: legacyConsumes === 2 ? 2 : 1, strictValues: true, prefixValues: [] }
248
284
  }
249
285
 
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)
286
+ switch (kind.kind) {
287
+ case 'widget':
288
+ consumePlainWidget({
289
+ promptName: field.nameInComfy,
290
+ typeName: field.typeName,
291
+ opts: field.opts,
292
+ consumes: kind.consumes,
293
+ prefixLen: kind.prefixValues.length,
294
+ strict: kind.strictValues,
295
+ linkedInput: input,
296
+ })
297
+ break
298
+ case 'dynamic-combo':
299
+ consumeDynamicCombo({ path: field.nameInComfy, options: kind.options, defaultKey: kind.defaultKey })
300
+ break
301
+ case 'dynamic-group':
302
+ consumeDynamicGroup({ path: field.nameInComfy, fields: kind.fields, min: kind.min, max: kind.max })
303
+ break
304
+ case 'dynamic-container':
305
+ // the declaration itself never appears; the first template.min
306
+ // instances must be connected (backend requires them by name)
307
+ for (const instName of kind.instanceNames.slice(0, kind.requiredCount)) {
308
+ const iname = `${field.nameInComfy}.${instName}`
309
+ const inst = inputsInNodeJSON.find((i) => i.name === iname)
310
+ if (inst?.link == null)
311
+ throw new WorkflowConvertError(
312
+ 'missing-required-input',
313
+ `node ${node.id}(${node.type}): autogrow "${field.nameInComfy}" requires instance "${iname}" connected (template.min = ${kind.requiredCount})`,
314
+ node,
315
+ )
316
+ }
317
+ break
318
+ case 'slot':
319
+ // a value promoted onto a slot (io-widget era subgraph): the frontend sends the literal
320
+ if (input?.link == null && Object.hasOwn(named, field.nameInComfy)) {
321
+ inputs[field.nameInComfy] = toPromptValue(named[field.nameInComfy], {
322
+ promptName: field.nameInComfy,
323
+ strict: false,
324
+ })
325
+ break
326
+ }
327
+ if (!fieldNamesPresent.has(field.nameInComfy) && field.required)
269
328
  throw new WorkflowConvertError(
270
329
  'missing-required-input',
271
- `node ${node.id}(${node.type}): autogrow "${field.nameInComfy}" requires instance "${iname}" connected (template.min = ${kind.requiredCount})`,
330
+ `node ${node.id}(${node.type}): required input "${field.nameInComfy}" (${field.typeName}) has neither widget value nor link`,
272
331
  node,
273
332
  )
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
- )
333
+ break
334
+ default:
335
+ exhaust(kind)
282
336
  }
283
337
  }
284
338
 
@@ -433,6 +487,60 @@ export const convertLiteGraphToPrompt = (
433
487
  prompt[String(node.id)] = { inputs, class_type: node.type }
434
488
  }
435
489
 
490
+ // 3. unlinked slots a subgraph input fed with no outer link take that input's promoted widget
491
+ // value, read from the sibling widget it also fed, once every node is converted
492
+ for (const node of workflow.nodes) {
493
+ const own = prompt[String(node.id)]
494
+ if (own == null) continue
495
+ for (const ipt of node.inputs) {
496
+ if (ipt.link != null || ipt.widgetSource == null || Object.hasOwn(own.inputs, ipt.name)) continue
497
+ const value = prompt[String(ipt.widgetSource.nodeId)]?.inputs[ipt.widgetSource.inputName]
498
+ if (value !== undefined) own.inputs[ipt.name] = value
499
+ }
500
+ }
501
+
502
+ // 4. a required plain input absent from the prompt. ComfyUI validates per OUTPUT node
503
+ // (execution.py validate_prompt): it runs the outputs whose upstream nodes are complete and
504
+ // rejects the prompt only when none is. Same here: a typed error when no output survives, a
505
+ // loud warning naming what ComfyUI will drop otherwise; never silent
506
+ const missing = new Map<string, { node: CanonicalNode; message: string }>()
507
+ for (const node of workflow.nodes) {
508
+ const own = prompt[String(node.id)]
509
+ const nodeSchema = schema.nodesByNameInComfy[node.type]
510
+ if (own == null || nodeSchema == null) continue
511
+ for (const field of nodeSchema.inputs) {
512
+ if (!field.required || Object.hasOwn(own.inputs, field.nameInComfy)) continue
513
+ const kind = classifySchemaInput(field).kind
514
+ if (kind !== 'slot' && kind !== 'widget') continue
515
+ missing.set(String(node.id), {
516
+ node,
517
+ message: `node ${node.id}(${node.type}): required input "${field.nameInComfy}" (${field.typeName}) is unlinked and no value covers it`,
518
+ })
519
+ break
520
+ }
521
+ }
522
+ if (missing.size > 0) {
523
+ const complete = (id: string, seen: Set<string>): boolean => {
524
+ if (seen.has(id)) return true
525
+ seen.add(id)
526
+ if (missing.has(id)) return false
527
+ for (const value of Object.values(prompt[id]?.inputs ?? {}))
528
+ if (Array.isArray(value) && typeof value[0] === 'string' && !complete(value[0], seen)) return false
529
+ return true
530
+ }
531
+ const outputs = Object.keys(prompt).filter(
532
+ (id) => schema.data.spec[prompt[id]?.class_type ?? '']?.output_node === true,
533
+ )
534
+ const dropped = outputs.filter((id) => !complete(id, new Set()))
535
+ const first = missing.values().next().value
536
+ if (first != null && outputs.length > 0 && dropped.length === outputs.length)
537
+ throw new WorkflowConvertError('missing-required-input', first.message, first.node)
538
+ if (dropped.length > 0 || outputs.length === 0)
539
+ console.warn(
540
+ `🟡 [workflow] ComfyUI will skip output node(s) ${dropped.join(', ') || '(none in this graph)'}: ${[...missing.values()].map((m) => m.message).join('; ')}`,
541
+ )
542
+ }
543
+
436
544
  return prompt
437
545
  }
438
546