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.
- package/dist/cli.js +3 -3
- package/dist/index.cjs +1078 -190
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1185 -410
- package/dist/index.d.ts +1185 -410
- package/dist/index.js +1078 -190
- package/dist/index.js.map +1 -1
- package/dist/{run-run-tg82jUIk.js → run-run-Zr699h2S.js} +2 -2
- package/dist/{run-run-tg82jUIk.js.map → run-run-Zr699h2S.js.map} +1 -1
- package/dist/{run-tui-Bw7BA75d.js → run-tui-CeM1GOJP.js} +2 -2
- package/dist/{run-tui-Bw7BA75d.js.map → run-tui-CeM1GOJP.js.map} +1 -1
- package/dist/serve-web.js +47 -47
- package/dist/{state-zTow5ucI.js → state-C067Kbew.js} +1079 -191
- package/dist/state-C067Kbew.js.map +1 -0
- package/dist/web.d.ts +1203 -428
- package/dist/web.js +1078 -190
- package/dist/web.js.map +1 -1
- package/examples/comfy-cloud/ace-step15-t2a.cflow.ts +163 -0
- package/examples/comfy-cloud/anima-t2i-base.cflow.ts +57 -0
- package/examples/comfy-cloud/boogu-t2i.cflow.ts +55 -0
- package/examples/comfy-cloud/chronoedit-i2i.cflow.ts +95 -0
- package/examples/comfy-cloud/ernie-t2i-base.cflow.ts +81 -0
- package/examples/comfy-cloud/flux1-t2i-krea.cflow.ts +63 -0
- package/examples/comfy-cloud/flux2-i2i-dev.cflow.ts +83 -0
- package/examples/comfy-cloud/flux2-t2i-dev.cflow.ts +60 -0
- package/examples/comfy-cloud/hidream-o1-i2i.cflow.ts +71 -0
- package/examples/comfy-cloud/hidream-o1-t2i.cflow.ts +62 -0
- package/examples/comfy-cloud/krea2-i2i.cflow.ts +78 -0
- package/examples/comfy-cloud/ltx2-i2v.cflow.ts +175 -0
- package/examples/comfy-cloud/ltx2-t2v.cflow.ts +143 -0
- package/examples/comfy-cloud/ltx23-i2v.cflow.ts +189 -0
- package/examples/comfy-cloud/ltx23-t2v.cflow.ts +151 -0
- package/examples/comfy-cloud/mage-flow-i2i-turbo.cflow.ts +72 -0
- package/examples/comfy-cloud/mage-flow-i2i.cflow.ts +74 -0
- package/examples/comfy-cloud/mage-flow-t2i-turbo.cflow.ts +60 -0
- package/examples/comfy-cloud/mage-flow-t2i.cflow.ts +60 -0
- package/examples/comfy-cloud/minimax-h3-t2i.cflow.ts +64 -0
- package/examples/comfy-cloud/netayume-t2i.cflow.ts +60 -0
- package/examples/comfy-cloud/qwen-image-i2i-2509.cflow.ts +75 -0
- package/examples/comfy-cloud/qwen-image-t2i-2512.cflow.ts +63 -0
- package/examples/comfy-cloud/sdk.d.ts +21683 -13737
- package/examples/comfy-cloud/stable-audio3-t2a.cflow.ts +96 -0
- package/examples/comfy-cloud/z-image-t2i-base.cflow.ts +54 -0
- package/examples/rvion/04-krea2-turbo-t2i.cflow.ts +1 -1
- package/package.json +2 -2
- package/src/graph/ComfyNode.ts +93 -12
- package/src/host/ComfyHost.ts +37 -46
- package/src/host/ComfyManager.ts +576 -64
- package/src/litegraph/CanonicalWorkflow.ts +3 -0
- package/src/litegraph/LiteGraphJSON.ts +2 -2
- package/src/litegraph/LiteGraphNodeInput.ts +2 -2
- package/src/litegraph/LiteGraphNodeOutput.ts +2 -2
- package/src/litegraph/convertFlowToLiteGraphJSON.ts +112 -37
- package/src/litegraph/expandSubgraphs.ts +72 -4
- package/src/litegraph/normalizeWorkflow.ts +7 -1
- package/src/manager/ComfyRegistry.ts +2 -0
- package/src/manager/generated/KnownComfyCustomNodeName.ts +6354 -1680
- package/src/manager/generated/KnownComfyPluginTitle.ts +718 -356
- package/src/manager/generated/KnownComfyPluginURL.ts +357 -181
- package/src/manager/generated/KnownModel_Base.ts +9 -5
- package/src/manager/generated/KnownModel_FileName.ts +135 -0
- package/src/manager/generated/KnownModel_Name.ts +135 -0
- package/src/manager/generated/KnownModel_SavePath.ts +16 -14
- package/src/manager/generated/KnownModel_Type.ts +15 -13
- package/src/manager/installedView.ts +178 -0
- package/src/manager/json/custom-node-list.json +4018 -2248
- package/src/manager/json/extension-node-map.json +8903 -2964
- package/src/manager/json/github-stats.json +10796 -10036
- package/src/manager/json/model-list.json +298 -1
- package/src/manager/loaders/step4_model-list-loader.ts +1 -0
- package/src/manager/types/ComfyManagerAPIModelList.ts +3 -0
- package/src/manager/types/ComfyManagerAPIPluginList.ts +19 -0
- package/src/runner/ComfyExecution.ts +4 -1
- package/src/runner/ComfyWsApi.ts +82 -15
- package/src/sdk-generator/ComfySchema.ts +10 -1
- package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +4 -1
- package/src/sdk-generator/comfyui-sdk-codegen.ts +61 -20
- package/src/sdk-generator/inputWidgetKind.ts +19 -4
- package/src/sdk-generator/litegraphToApiRequestPayload.ts +157 -35
- package/dist/state-zTow5ucI.js.map +0 -1
|
@@ -51,6 +51,9 @@ export type CanonicalInput = {
|
|
|
51
51
|
type: string
|
|
52
52
|
link: LiteGraphLinkID | null // null = unconnected (incl. omitted key)
|
|
53
53
|
widgetName: string | null // widget.name when widget-backed
|
|
54
|
+
/** an unlinked slot a subgraph input fed while that input had no outer link: it takes the
|
|
55
|
+
* value of the promoted widget, read from this sibling widget input (architecture.md) */
|
|
56
|
+
widgetSource: { nodeId: number; inputName: string } | null
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
export type CanonicalOutput = {
|
|
@@ -18,7 +18,7 @@ export type ComfyWorkflowJSON = LiteGraphJSON
|
|
|
18
18
|
export type LiteGraphJSON = {
|
|
19
19
|
id?: string // uuid (newer serializers)
|
|
20
20
|
revision?: number
|
|
21
|
-
last_node_id?: number // v0.4 (recomputable, absent in v1)
|
|
21
|
+
last_node_id?: number | string // v0.4 (recomputable, absent in v1), a NodeId: the official blueprints write a string
|
|
22
22
|
last_link_id?: number // v0.4
|
|
23
23
|
state?: Record<string, unknown> // v1: {lastNodeId, lastLinkId, …}
|
|
24
24
|
nodes: LiteGraphNode[]
|
|
@@ -41,7 +41,7 @@ export type LiteGraphJSON = {
|
|
|
41
41
|
export const LiteGraphJSON_ark = type({
|
|
42
42
|
'id?': 'string',
|
|
43
43
|
'revision?': 'number',
|
|
44
|
-
'last_node_id?': 'number',
|
|
44
|
+
'last_node_id?': 'number | string',
|
|
45
45
|
'last_link_id?': 'number',
|
|
46
46
|
'state?': type.Record('string', 'unknown'),
|
|
47
47
|
nodes: LiteGraphNode_ark.array(),
|
|
@@ -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 //
|
|
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?':
|
|
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 {
|
|
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 = (
|
|
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
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
|
69
109
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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,
|
|
@@ -23,8 +23,60 @@ export type CanonicalSubgraphDef = {
|
|
|
23
23
|
const SUBGRAPH_INPUT_NODE_ID = -10
|
|
24
24
|
const SUBGRAPH_OUTPUT_NODE_ID = -20
|
|
25
25
|
|
|
26
|
-
/**
|
|
27
|
-
|
|
26
|
+
/** expanded node count above which a file is refused before expanding: the largest official
|
|
27
|
+
* template expands to 575 nodes, and fan-out nesting grows geometrically without any cycle */
|
|
28
|
+
export const MAX_EXPANDED_NODES = 100_000
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* before any expansion: the definitions as a graph (def → the defs its NORMAL-mode instances name,
|
|
32
|
+
* the only ones expansion follows). A cycle reachable from the root is refused with the defs it
|
|
33
|
+
* runs through, and the expanded size is counted, not built, and refused above
|
|
34
|
+
* MAX_EXPANDED_NODES. One explicit stack, no recursion: the file decides the depth
|
|
35
|
+
*/
|
|
36
|
+
const checkExpansion = (wf: CanonicalWorkflow, defs: Map<string, CanonicalSubgraphDef>): void => {
|
|
37
|
+
const children = (nodes: CanonicalNode[]): string[] =>
|
|
38
|
+
nodes.filter((n) => n.mode === 'normal' && defs.has(n.type)).map((n) => n.type)
|
|
39
|
+
const own = (nodes: CanonicalNode[]): number =>
|
|
40
|
+
nodes.filter((n) => !(n.mode === 'normal' && defs.has(n.type))).length
|
|
41
|
+
const name = (id: string): string => JSON.stringify(defs.get(id)?.name ?? id)
|
|
42
|
+
const cap = (n: number): number => Math.min(n, MAX_EXPANDED_NODES + 1)
|
|
43
|
+
const size = new Map<string, number>() // done (black): expanded node count of one instance
|
|
44
|
+
const onPath = new Set<string>() // gray
|
|
45
|
+
for (const root of new Set(children(wf.nodes))) {
|
|
46
|
+
if (size.has(root)) continue
|
|
47
|
+
const stack: { id: string; kids: string[]; next: number }[] = [
|
|
48
|
+
{ id: root, kids: children(bang(defs.get(root)).nodes), next: 0 },
|
|
49
|
+
]
|
|
50
|
+
onPath.add(root)
|
|
51
|
+
while (stack.length > 0) {
|
|
52
|
+
const top = bang(stack[stack.length - 1])
|
|
53
|
+
const kid = top.kids[top.next++]
|
|
54
|
+
if (kid == null) {
|
|
55
|
+
const total = top.kids.reduce((acc, k) => cap(acc + (size.get(k) ?? 0)), own(bang(defs.get(top.id)).nodes))
|
|
56
|
+
size.set(top.id, total)
|
|
57
|
+
onPath.delete(top.id)
|
|
58
|
+
stack.pop()
|
|
59
|
+
continue
|
|
60
|
+
}
|
|
61
|
+
if (size.has(kid)) continue
|
|
62
|
+
if (onPath.has(kid)) {
|
|
63
|
+
const from = stack.findIndex((frame) => frame.id === kid)
|
|
64
|
+
const cycle = [...stack.slice(from).map((frame) => frame.id), kid].map(name).join(' → ')
|
|
65
|
+
throw new WorkflowNormalizeError('subgraph-cycle', `subgraph definitions contain themselves: ${cycle}`, {
|
|
66
|
+
cycle: stack.slice(from).map((frame) => frame.id),
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
onPath.add(kid)
|
|
70
|
+
stack.push({ id: kid, kids: children(bang(defs.get(kid)).nodes), next: 0 })
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const total = children(wf.nodes).reduce((acc, k) => cap(acc + (size.get(k) ?? 0)), own(wf.nodes))
|
|
74
|
+
if (total > MAX_EXPANDED_NODES)
|
|
75
|
+
throw new WorkflowNormalizeError(
|
|
76
|
+
'subgraph-too-large',
|
|
77
|
+
`subgraph expansion would produce more than ${MAX_EXPANDED_NODES} nodes (the largest official template has 575)`,
|
|
78
|
+
)
|
|
79
|
+
}
|
|
28
80
|
|
|
29
81
|
/**
|
|
30
82
|
* widget-kind fallback when a def input slot has no boundary target carrying a
|
|
@@ -43,14 +95,16 @@ const PRIMITIVE_WIDGET_TYPES: ReadonlySet<string> = new Set(['INT', 'FLOAT', 'ST
|
|
|
43
95
|
* passthrough walk, which needs no interior.
|
|
44
96
|
*/
|
|
45
97
|
export const expandSubgraphs = (wf: CanonicalWorkflow, defs: Map<string, CanonicalSubgraphDef>): CanonicalWorkflow => {
|
|
98
|
+
checkExpansion(wf, defs)
|
|
99
|
+
// acyclic now: each pass goes one definition deeper, so defs.size passes always suffice
|
|
46
100
|
let passes = 0
|
|
47
101
|
while (true) {
|
|
48
102
|
const expandable = wf.nodes.filter((n) => defs.has(n.type) && n.mode !== 'bypassed')
|
|
49
103
|
if (expandable.length === 0) return wf
|
|
50
|
-
if (++passes >
|
|
104
|
+
if (++passes > defs.size + 1)
|
|
51
105
|
throw new WorkflowNormalizeError(
|
|
52
106
|
'subgraph-cycle',
|
|
53
|
-
`subgraph expansion
|
|
107
|
+
`subgraph expansion still had instances after ${passes - 1} passes over ${defs.size} definitions`,
|
|
54
108
|
)
|
|
55
109
|
for (const instance of expandable) {
|
|
56
110
|
if (instance.mode === 'muted') dropMutedInstance(wf, instance)
|
|
@@ -196,6 +250,7 @@ const expandOneInstance = (wf: CanonicalWorkflow, instance: CanonicalNode, def:
|
|
|
196
250
|
type: i.type,
|
|
197
251
|
link: i.link != null ? (newLinkIds.get(i.link) ?? null) : null,
|
|
198
252
|
widgetName: i.widgetName,
|
|
253
|
+
widgetSource: i.widgetSource,
|
|
199
254
|
})),
|
|
200
255
|
outputs: inner.outputs.map((o) => ({
|
|
201
256
|
name: o.name,
|
|
@@ -239,6 +294,19 @@ const expandOneInstance = (wf: CanonicalWorkflow, instance: CanonicalNode, def:
|
|
|
239
294
|
|
|
240
295
|
// 7. widget promotion (both serialization eras), then splice
|
|
241
296
|
promoteInstanceWidgets(instance, def, splicedNodes, newNodeIds, boundaryTargetsByInSlot)
|
|
297
|
+
// 8. a subgraph input with no outer link resolves to its promoted widget (frontend
|
|
298
|
+
// ExecutableNodeDTO.resolveInput): its slot targets read that widget's value
|
|
299
|
+
for (const [slot, targets] of boundaryTargetsByInSlot) {
|
|
300
|
+
if (outerLinkIntoDefSlot.has(slot)) continue
|
|
301
|
+
const source = targets.find((t) => innerInputAt(splicedNodes, t)?.widgetName != null)
|
|
302
|
+
const sourceInput = source != null ? innerInputAt(splicedNodes, source) : null
|
|
303
|
+
if (source == null || sourceInput == null) continue
|
|
304
|
+
for (const t of targets) {
|
|
305
|
+
const input = splicedNodes.find((n) => n.id === t.nodeId)?.inputs[t.slot]
|
|
306
|
+
if (input == null || input.widgetName != null || input.link != null) continue
|
|
307
|
+
input.widgetSource = { nodeId: source.nodeId, inputName: sourceInput.name }
|
|
308
|
+
}
|
|
309
|
+
}
|
|
242
310
|
wf.nodes = wf.nodes.filter((n) => n.id !== instance.id)
|
|
243
311
|
wf.nodes.push(...splicedNodes)
|
|
244
312
|
wf.links.push(...splicedLinks)
|
|
@@ -18,7 +18,12 @@ import type { LiteGraphNodeInput } from 'src/litegraph/LiteGraphNodeInput.ts'
|
|
|
18
18
|
import type { LiteGraphNodeOutput } from 'src/litegraph/LiteGraphNodeOutput.ts'
|
|
19
19
|
import type { LiteGraphSubgraphDef } from 'src/litegraph/LiteGraphSubgraphDef.ts'
|
|
20
20
|
|
|
21
|
-
export type WorkflowNormalizeErrorCode =
|
|
21
|
+
export type WorkflowNormalizeErrorCode =
|
|
22
|
+
| 'schema-reject'
|
|
23
|
+
| 'subgraph-cycle'
|
|
24
|
+
| 'subgraph-too-large'
|
|
25
|
+
| 'subgraph-io-mismatch'
|
|
26
|
+
| 'bad-document'
|
|
22
27
|
|
|
23
28
|
/** a workflow JSON we cannot turn into a CanonicalWorkflow — loud, typed, never a cast */
|
|
24
29
|
export class WorkflowNormalizeError extends Error {
|
|
@@ -100,6 +105,7 @@ const normalizeInput = (i: LiteGraphNodeInput): CanonicalInput => {
|
|
|
100
105
|
type: i.type,
|
|
101
106
|
link: i.link ?? null,
|
|
102
107
|
widgetName: i.widget?.name ?? null,
|
|
108
|
+
widgetSource: null,
|
|
103
109
|
}
|
|
104
110
|
}
|
|
105
111
|
|
|
@@ -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[] = []
|