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
@@ -7,7 +7,7 @@ export type LiteGraphNodeInput = {
7
7
  type: string // | 'CLIP'
8
8
  link?: LiteGraphLinkID | null // | 5 (widget-backed inputs omit the key)
9
9
  shape?: number // | 7
10
- label?: string // | 'select'
10
+ label?: string | null // | 'select' (null in the official fibo2 templates)
11
11
  widget?: {
12
12
  name: string // | 'select'
13
13
  config?: unknown // | 2022-era serializer only, gone since
@@ -19,7 +19,7 @@ export const LiteGraphNodeInput_ark = type({
19
19
  type: 'string',
20
20
  'link?': LiteGraphLinkID_.or(type.null),
21
21
  'shape?': 'number',
22
- 'label?': 'string',
22
+ 'label?': type.string.or(type.null),
23
23
  'widget?': type({
24
24
  name: 'string',
25
25
  'config?': 'unknown',
@@ -8,7 +8,7 @@ export type LiteGraphNodeOutput = {
8
8
  type: string // 'CONDITIONING'
9
9
  links?: LiteGraphLinkID[] | null // unconnected outputs may omit the key
10
10
  shape?: number // '2D'
11
- slot_index?: LiteGraphSlotIndex
11
+ slot_index?: LiteGraphSlotIndex | null // the official fibo2 templates write null
12
12
  }
13
13
 
14
14
  export const LiteGraphNodeOutput_ark = type({
@@ -16,7 +16,7 @@ export const LiteGraphNodeOutput_ark = type({
16
16
  type: 'string',
17
17
  'links?': LiteGraphLinkID_.array().or(type.null),
18
18
  'shape?': 'number',
19
- 'slot_index?': LiteGraphSlotIndex_,
19
+ 'slot_index?': LiteGraphSlotIndex_.or(type.null),
20
20
  })
21
21
 
22
22
  true satisfies IsEqual<LiteGraphNodeOutput, typeof LiteGraphNodeOutput_ark.infer>
@@ -1,7 +1,15 @@
1
1
  import type { ComfyNode } from 'src/graph/ComfyNode.ts'
2
2
  import type { ComfyWorkflow } from 'src/runner/ComfyWorkflow.ts'
3
3
  import { bang } from 'src/utils/bang.ts'
4
- import { classifySchemaInput } from 'src/sdk-generator/inputWidgetKind.ts'
4
+ import {
5
+ classifySchemaInput,
6
+ classifyWidgetInput,
7
+ containerInstanceSlotType,
8
+ defaultValueForWidget,
9
+ type InputWidgetKind,
10
+ type RawInputSpecEntry,
11
+ } from 'src/sdk-generator/inputWidgetKind.ts'
12
+ import { exhaust } from 'src/utils/exhaust.ts'
5
13
  import type { LiteGraphJSON } from 'src/litegraph/LiteGraphJSON.ts'
6
14
  import type { LiteGraphLinkTuple } from 'src/litegraph/LiteGraphLink.ts'
7
15
  import { asLiteGraphLinkID, type LiteGraphLinkID } from 'src/litegraph/LiteGraphLinkID.ts'
@@ -40,41 +48,119 @@ export const convertFlowToLiteGraphJSON = (graph: ComfyWorkflow): LiteGraphJSON
40
48
  const convertNodeToLiteGraphNode = (ctx: LiteGraphCtx, node: ComfyNode<any>): LiteGraphNode => {
41
49
  const inputs: LiteGraphNodeInput[] = []
42
50
  const widgets_values: unknown[] = []
51
+ // target_slot = index within THIS node's litegraph inputs array,
52
+ // not the schema input index (widget inputs are not litegraph slots)
53
+ const pushLinked = (
54
+ name: string,
55
+ type: string,
56
+ link: [string, number],
57
+ extra: { shape?: number; widget?: boolean } = {},
58
+ ): void => {
59
+ const nodeUidNumber = bang(
60
+ ctx.graph.nodes.find((n) => n.uid === link[0])?.uidNumber,
61
+ `link target node "${link[0]}" not found in graph`,
62
+ )
63
+ const linkId = ctx.allocateLink(nodeUidNumber, link[1], node.uidNumber, asLiteGraphSlotIndex(inputs.length), type)
64
+ const input: LiteGraphNodeInput = { name, type, link: linkId }
65
+ if (extra.shape != null) input.shape = extra.shape
66
+ if (extra.widget === true) input.widget = { name }
67
+ inputs.push(input)
68
+ }
69
+ /** frontend button-widget values ride BEFORE the real value (LOAD_3D); the control_after_generate
70
+ * phantom AFTER it: the classifier's consumes covers prefix + value + control, config-driven
71
+ * (the 2024 INT-named-seed heuristic lives inside controlConsumes), so export and import can
72
+ * never disagree on the run length */
73
+ const pushWidgetRun = (kind: Extract<InputWidgetKind, { kind: 'widget' }>, raw: unknown, opts: unknown): void => {
74
+ widgets_values.push(...kind.prefixValues, raw)
75
+ const phantoms = kind.consumes - 1 - kind.prefixValues.length
76
+ for (let i = 0; i < phantoms; i++) widgets_values.push(controlMode(opts))
77
+ }
78
+ /** one input, the way the editor saves it: a widget writes its run (a linked one too, with
79
+ * its widget socket, since the editor serializes every widget), a dynamic combo its key then
80
+ * the selected branch inline, a group its row count then the rows, a slot its socket */
81
+ const writeInput = (p: {
82
+ name: string
83
+ kind: InputWidgetKind
84
+ typeName: string
85
+ opts: unknown
86
+ value: unknown
87
+ }): void => {
88
+ const where = `${node.$schema.nameInComfy}#${node.uid} "${p.name}"`
89
+ switch (p.kind.kind) {
90
+ case 'widget':
91
+ if (_isLink(p.value)) {
92
+ pushLinked(p.name, p.typeName, p.value, { widget: true })
93
+ pushWidgetRun(p.kind, defaultValueForWidget({ type: p.typeName, opts: p.opts }), p.opts)
94
+ } else pushWidgetRun(p.kind, p.value, p.opts)
95
+ return
96
+ case 'slot':
97
+ // an unconnected slot is a litegraph socket with no link, NEVER a widget value
98
+ if (_isLink(p.value)) pushLinked(p.name, p.typeName, p.value)
99
+ else inputs.push({ name: p.name, type: p.typeName, link: null })
100
+ return
101
+ case 'dynamic-combo': {
102
+ const kind = p.kind
103
+ const key = typeof p.value === 'string' ? p.value : kind.defaultKey
104
+ const option = kind.options.find((o) => o.key === key)
105
+ if (option == null) throw new Error(`🔴 [toWorkflowJson] ${where}: "${key}" is not one of its options`)
106
+ widgets_values.push(key)
107
+ for (const sub of option.inputs) writeSub(`${p.name}.${sub.name}`, sub)
108
+ return
109
+ }
110
+ case 'dynamic-container': {
111
+ // the declaration is never a slot: each grown instance is its own
112
+ // optional slot `decl.<instance>` (shape 7), as the editor stores it
113
+ const type = containerInstanceSlotType(p.opts) ?? '*'
114
+ for (const instance of p.kind.instanceNames) {
115
+ const name = `${p.name}.${instance}`
116
+ const value = node.json.inputs[name]
117
+ if (value == null) continue
118
+ const raw = node.serializeValue(name, value)
119
+ if (!_isLink(raw))
120
+ throw new Error(
121
+ `🔴 [toWorkflowJson] ${where}.${instance} holds a literal; an autogrow instance is a link slot in the editor`,
122
+ )
123
+ pushLinked(name, type, raw, { shape: 7 })
124
+ }
125
+ return
126
+ }
127
+ case 'dynamic-group': {
128
+ // the editor's run: the row count, then each row's field runs (dynamicGroupWidget.ts)
129
+ const prefix = `${p.name}.`
130
+ let rows = 0
131
+ for (const key of Object.keys(node.json.inputs)) {
132
+ if (!key.startsWith(prefix)) continue
133
+ const row = Number(key.slice(prefix.length).split('.')[0])
134
+ if (Number.isInteger(row) && row >= rows) rows = row + 1
135
+ }
136
+ widgets_values.push(rows)
137
+ for (let row = 0; row < rows; row++)
138
+ for (const field of p.kind.fields) writeSub(`${prefix}${row}.${field.name}`, field)
139
+ return
140
+ }
141
+ default:
142
+ exhaust(p.kind)
143
+ }
144
+ }
145
+ /** a dotted input (dynamic combo branch, group row field): never a schema input, so its absent
146
+ * value is the widget's schema default rather than serializeValue's */
147
+ const writeSub = (name: string, sub: RawInputSpecEntry): void => {
148
+ const typeName = typeof sub.type === 'string' ? sub.type : 'COMBO'
149
+ const raw: unknown = node.json.inputs[name]
150
+ writeInput({
151
+ name,
152
+ kind: classifyWidgetInput({ name, type: sub.type, opts: sub.opts }),
153
+ typeName,
154
+ opts: sub.opts,
155
+ value: raw === undefined ? defaultValueForWidget({ type: typeName, opts: sub.opts }) : raw,
156
+ })
157
+ }
43
158
  for (const ipt of node.$schema.inputs) {
44
- const raw = node.serializeValue(ipt.nameInComfy, node.json.inputs[ipt.nameInComfy])
45
159
  const kind = classifySchemaInput(ipt)
46
- if (_isLink(raw)) {
47
- const nodeUidNumber = bang(
48
- ctx.graph.nodes.find((n) => n.uid === raw[0])?.uidNumber,
49
- `link target node "${raw[0]}" not found in graph`,
50
- )
51
- inputs.push({
52
- name: ipt.nameInComfy,
53
- type: ipt.typeName,
54
- // target_slot = index within THIS node's litegraph inputs array,
55
- // not the schema input index (widget inputs are not litegraph slots)
56
- link: ctx.allocateLink(
57
- nodeUidNumber,
58
- raw[1],
59
- node.uidNumber,
60
- asLiteGraphSlotIndex(inputs.length),
61
- ipt.typeName,
62
- ),
63
- })
64
- } else if (kind.kind === 'widget') {
65
- // frontend button-widget values ride BEFORE the real value (LOAD_3D)
66
- widgets_values.push(...kind.prefixValues, raw)
67
- // control_after_generate phantom AFTER the value: the classifier's
68
- // consumes covers prefix + value + control, config-driven (the 2024
69
- // INT-named-seed heuristic lives inside controlConsumes), so export
70
- // and import can never disagree on the run length
71
- const phantoms = kind.consumes - 1 - kind.prefixValues.length
72
- for (let i = 0; i < phantoms; i++) widgets_values.push(false)
73
- } else {
74
- // unconnected link-kind input: a litegraph slot with no link —
75
- // NEVER a widget value (that would misalign the round-trip import)
76
- inputs.push({ name: ipt.nameInComfy, type: ipt.typeName, link: null })
77
- }
160
+ // a dynamic input's own key is never a schema-default value: read it raw
161
+ const raw = node.json.inputs[ipt.nameInComfy]
162
+ const value = kind.kind === 'widget' || kind.kind === 'slot' ? node.serializeValue(ipt.nameInComfy, raw) : raw
163
+ writeInput({ name: ipt.nameInComfy, kind, typeName: ipt.typeName, opts: ipt.opts, value })
78
164
  }
79
165
  const outputs = node.$schema.outputs.map(
80
166
  (i, ix): LiteGraphNodeOutput => ({
@@ -96,6 +182,13 @@ const convertNodeToLiteGraphNode = (ctx: LiteGraphCtx, node: ComfyNode<any>): Li
96
182
  }
97
183
  }
98
184
 
185
+ /** the editor's control widget is a combo (fixed, increment, decrement, randomize):
186
+ * a config naming a mode keeps it, anything else is `fixed`, the seed the code pinned */
187
+ const controlMode = (opts: unknown): string => {
188
+ const mode = typeof opts === 'object' && opts != null ? Reflect.get(opts, 'control_after_generate') : null
189
+ return typeof mode === 'string' ? mode : 'fixed'
190
+ }
191
+
99
192
  const _isLink = (v: unknown): v is [string, number] => {
100
193
  return Array.isArray(v) && v.length === 2 && typeof v[0] === 'string' && typeof v[1] === 'number'
101
194
  }
@@ -196,6 +196,7 @@ const expandOneInstance = (wf: CanonicalWorkflow, instance: CanonicalNode, def:
196
196
  type: i.type,
197
197
  link: i.link != null ? (newLinkIds.get(i.link) ?? null) : null,
198
198
  widgetName: i.widgetName,
199
+ widgetSource: i.widgetSource,
199
200
  })),
200
201
  outputs: inner.outputs.map((o) => ({
201
202
  name: o.name,
@@ -239,6 +240,19 @@ const expandOneInstance = (wf: CanonicalWorkflow, instance: CanonicalNode, def:
239
240
 
240
241
  // 7. widget promotion (both serialization eras), then splice
241
242
  promoteInstanceWidgets(instance, def, splicedNodes, newNodeIds, boundaryTargetsByInSlot)
243
+ // 8. a subgraph input with no outer link resolves to its promoted widget (frontend
244
+ // ExecutableNodeDTO.resolveInput): its slot targets read that widget's value
245
+ for (const [slot, targets] of boundaryTargetsByInSlot) {
246
+ if (outerLinkIntoDefSlot.has(slot)) continue
247
+ const source = targets.find((t) => innerInputAt(splicedNodes, t)?.widgetName != null)
248
+ const sourceInput = source != null ? innerInputAt(splicedNodes, source) : null
249
+ if (source == null || sourceInput == null) continue
250
+ for (const t of targets) {
251
+ const input = splicedNodes.find((n) => n.id === t.nodeId)?.inputs[t.slot]
252
+ if (input == null || input.widgetName != null || input.link != null) continue
253
+ input.widgetSource = { nodeId: source.nodeId, inputName: sourceInput.name }
254
+ }
255
+ }
242
256
  wf.nodes = wf.nodes.filter((n) => n.id !== instance.id)
243
257
  wf.nodes.push(...splicedNodes)
244
258
  wf.links.push(...splicedLinks)
@@ -100,6 +100,7 @@ const normalizeInput = (i: LiteGraphNodeInput): CanonicalInput => {
100
100
  type: i.type,
101
101
  link: i.link ?? null,
102
102
  widgetName: i.widget?.name ?? null,
103
+ widgetSource: null,
103
104
  }
104
105
  }
105
106
 
@@ -42,6 +42,8 @@ export class ComfyRegistry {
42
42
 
43
43
  // Models
44
44
  knownModels = new Map<KnownModel_Name, ComfyManagerModelInfo>()
45
+ /** every model row, the ones sharing a name included (knownModels keeps the last) */
46
+ modelRows: ComfyManagerModelInfo[] = []
45
47
 
46
48
  // a1111 → comfy alternatives (alter-list.json)
47
49
  alterations: ComfyManagerAlterInfo[] = []