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
@@ -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 of every branch: the selected ones are written here, the rest are dropped */
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
- if (kind.kind === 'dynamic-combo') {
194
- this._writeDynamicCombo({
195
- name: i.nameInComfy,
196
- options: kind.options,
197
- defaultKey: kind.defaultKey,
198
- provided: promptExt.inputs,
199
- out: inputs,
200
- claimed: _comboBranchKeys,
201
- })
202
- continue
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`,
@@ -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'
@@ -848,8 +850,10 @@ export class ComfyHost<ID extends string = string> {
848
850
  /** the session assigned to us by the server */
849
851
  comfySessionId: string = 'temp' /** send by ComfyUI server */
850
852
 
851
- /** binary frame types we already complained about (one log per type, no spam) */
853
+ /** event types we already complained about on this connection (one log per type, no
854
+ * spam); both sets clear when the server assigns a new session id */
852
855
  private _unknownBinaryFrameTypes = new Set<number>()
856
+ private _unknownWsEventTypes = new Set<string>()
853
857
 
854
858
  /** handy to keep around */
855
859
  status: ComfyStatusData['status'] | null = null
@@ -919,11 +923,27 @@ export class ComfyHost<ID extends string = string> {
919
923
  return
920
924
  }
921
925
 
922
- const msg_: unknown = JSON.parse(String(e.data))
926
+ let msg_: unknown = JSON.parse(String(e.data))
927
+
928
+ // ----- routed, ignored by name, or unknown (architecture.md, ws events) -----
929
+ const rec = typeof msg_ === 'object' && msg_ != null ? msg_ : null
930
+ const eventType = rec != null && 'type' in rec && typeof rec.type === 'string' ? rec.type : null
931
+ if (eventType != null && isIgnoredWsEventType(eventType)) return
932
+ if (eventType == null || !isRoutedWsEventType(eventType)) {
933
+ const key = eventType ?? '<no type>'
934
+ if (this._unknownWsEventTypes.has(key)) return
935
+ this._unknownWsEventTypes.add(key)
936
+ console.error(
937
+ `🔴 unknown ws event type ${JSON.stringify(key)} from host ${this.data.id}, ignored (reported once per connection)`,
938
+ )
939
+ return
940
+ }
923
941
 
924
- // ----- crystools silent fix -----
925
- if (typeof msg_ === 'object' && msg_ != null && 'type' in msg_) {
926
- if (msg_.type === 'crystools.monitor') return
942
+ // the reconnect resend of the running node carries no prompt_id (server.py websocket_handler)
943
+ if (eventType === 'executing' && this.activePromptID != null && rec != null) {
944
+ const data: unknown = Reflect.get(rec, 'data')
945
+ if (typeof data === 'object' && data != null && !('prompt_id' in data))
946
+ msg_ = { type: eventType, data: { ...data, prompt_id: this.activePromptID } }
927
947
  }
928
948
 
929
949
  // ----- soft-validate against the schema -----
@@ -942,7 +962,11 @@ export class ComfyHost<ID extends string = string> {
942
962
  this.comfySessionId = msg.data.sid
943
963
  this._sessionResolve?.()
944
964
  this._sessionResolve = null
945
- if (sidChanged) this.onSession?.(msg.data.sid)
965
+ if (sidChanged) {
966
+ this._unknownWsEventTypes.clear()
967
+ this._unknownBinaryFrameTypes.clear()
968
+ this.onSession?.(msg.data.sid)
969
+ }
946
970
  }
947
971
  this.status = msg.data.status
948
972
  this.onStatus?.({ queueRemaining: msg.data.status?.exec_info?.queue_remaining ?? 0 })
@@ -963,6 +987,7 @@ export class ComfyHost<ID extends string = string> {
963
987
  msg.type === 'execution_start' ||
964
988
  msg.type === 'execution_cached' ||
965
989
  msg.type === 'execution_error' ||
990
+ msg.type === 'execution_interrupted' ||
966
991
  msg.type === 'execution_success' ||
967
992
  msg.type === 'executing' ||
968
993
  msg.type === 'executed' ||
@@ -982,9 +1007,5 @@ export class ComfyHost<ID extends string = string> {
982
1007
  return
983
1008
  }
984
1009
  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
1010
  }
990
1011
  }