comfy-ts 2.17.1 → 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 (80) hide show
  1. package/dist/cli.js +3 -3
  2. package/dist/index.cjs +944 -165
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +1154 -408
  5. package/dist/index.d.ts +1154 -408
  6. package/dist/index.js +944 -165
  7. package/dist/index.js.map +1 -1
  8. package/dist/{run-run-tg82jUIk.js → run-run-Wn7H72Zg.js} +2 -2
  9. package/dist/{run-run-tg82jUIk.js.map → run-run-Wn7H72Zg.js.map} +1 -1
  10. package/dist/{run-tui-Bw7BA75d.js → run-tui-VWSj1D_j.js} +2 -2
  11. package/dist/{run-tui-Bw7BA75d.js.map → run-tui-VWSj1D_j.js.map} +1 -1
  12. package/dist/serve-web.js +47 -47
  13. package/dist/{state-zTow5ucI.js → state-DgwWhZWb.js} +945 -166
  14. package/dist/state-DgwWhZWb.js.map +1 -0
  15. package/dist/web.d.ts +1172 -426
  16. package/dist/web.js +944 -165
  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 +31 -10
  48. package/src/host/ComfyManager.ts +448 -62
  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 +14 -0
  55. package/src/litegraph/normalizeWorkflow.ts +1 -0
  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 +176 -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 +141 -33
  80. package/dist/state-zTow5ucI.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, containerInstanceSlotType } 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'
@@ -42,51 +50,118 @@ const convertNodeToLiteGraphNode = (ctx: LiteGraphCtx, node: ComfyNode<any>): Li
42
50
  const widgets_values: unknown[] = []
43
51
  // target_slot = index within THIS node's litegraph inputs array,
44
52
  // not the schema input index (widget inputs are not litegraph slots)
45
- const pushLinked = (name: string, type: string, link: [string, number], shape?: number): void => {
53
+ const pushLinked = (
54
+ name: string,
55
+ type: string,
56
+ link: [string, number],
57
+ extra: { shape?: number; widget?: boolean } = {},
58
+ ): void => {
46
59
  const nodeUidNumber = bang(
47
60
  ctx.graph.nodes.find((n) => n.uid === link[0])?.uidNumber,
48
61
  `link target node "${link[0]}" not found in graph`,
49
62
  )
50
63
  const linkId = ctx.allocateLink(nodeUidNumber, link[1], node.uidNumber, asLiteGraphSlotIndex(inputs.length), type)
51
- inputs.push(shape == null ? { name, type, link: linkId } : { name, type, shape, link: linkId })
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)
52
68
  }
53
- for (const ipt of node.$schema.inputs) {
54
- const kind = classifySchemaInput(ipt)
55
- if (kind.kind === 'dynamic-container') {
56
- // the declaration is never a slot: each grown instance is its own
57
- // optional slot `decl.<instance>` (shape 7), as the editor stores it
58
- const type = containerInstanceSlotType(ipt.opts) ?? '*'
59
- for (const instance of kind.instanceNames) {
60
- const name = `${ipt.nameInComfy}.${instance}`
61
- const value = node.json.inputs[name]
62
- if (value == null) continue
63
- const raw = node.serializeValue(name, value)
64
- if (!_isLink(raw))
65
- throw new Error(
66
- `🔴 [toWorkflowJson] ${node.$schema.nameInComfy}#${node.uid} "${name}" holds a literal; an autogrow instance is a link slot in the editor`,
67
- )
68
- pushLinked(name, type, raw, 7)
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
69
109
  }
70
- continue
71
- }
72
- const raw = node.serializeValue(ipt.nameInComfy, node.json.inputs[ipt.nameInComfy])
73
- if (_isLink(raw)) {
74
- pushLinked(ipt.nameInComfy, ipt.typeName, raw)
75
- } else if (kind.kind === 'widget') {
76
- // frontend button-widget values ride BEFORE the real value (LOAD_3D)
77
- widgets_values.push(...kind.prefixValues, raw)
78
- // control_after_generate phantom AFTER the value: the classifier's
79
- // consumes covers prefix + value + control, config-driven (the 2024
80
- // INT-named-seed heuristic lives inside controlConsumes), so export
81
- // and import can never disagree on the run length
82
- const phantoms = kind.consumes - 1 - kind.prefixValues.length
83
- for (let i = 0; i < phantoms; i++) widgets_values.push(controlMode(ipt.opts))
84
- } else {
85
- // unconnected link-kind input: a litegraph slot with no link —
86
- // NEVER a widget value (that would misalign the round-trip import)
87
- inputs.push({ name: ipt.nameInComfy, type: ipt.typeName, link: null })
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)
88
143
  }
89
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
+ }
158
+ for (const ipt of node.$schema.inputs) {
159
+ const kind = classifySchemaInput(ipt)
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 })
164
+ }
90
165
  const outputs = node.$schema.outputs.map(
91
166
  (i, ix): LiteGraphNodeOutput => ({
92
167
  // ❌9 name: i.nameInComfy,
@@ -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[] = []