comfy-ts 0.4.0 → 1.1.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.
- package/README.md +385 -255
- package/dist/DefinedWorkflow-BYyu5dK9.js +669 -0
- package/dist/DefinedWorkflow-BYyu5dK9.js.map +1 -0
- package/dist/cli.js +4106 -152
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1560 -333
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7826 -467
- package/dist/index.d.ts +7808 -449
- package/dist/index.js +1550 -333
- package/dist/index.js.map +1 -1
- package/dist/{run-tui-SDSJo1Qf.js → run-tui-DZ22HDHI.js} +631 -657
- package/dist/run-tui-DZ22HDHI.js.map +1 -0
- package/examples/01-txt2img.cflow.ts +50 -0
- package/examples/02-img2img-upload.cflow.ts +55 -0
- package/examples/03-export-workflow-json.cflow.ts +56 -0
- package/examples/04-krea2-turbo-t2i.cflow.ts +125 -0
- package/examples/05-comfy-cloud.cflow.ts +51 -0
- package/examples/README.md +30 -0
- package/examples/comfy-cloud/ace-step-t2a.cflow.ts +79 -0
- package/examples/comfy-cloud/anima-t2i.cflow.ts +57 -0
- package/examples/comfy-cloud/boogu-i2i.cflow.ts +76 -0
- package/examples/comfy-cloud/capybara-i2i.cflow.ts +85 -0
- package/examples/comfy-cloud/capybara-i2v.cflow.ts +90 -0
- package/examples/comfy-cloud/capybara-t2i.cflow.ts +67 -0
- package/examples/comfy-cloud/chatterbox-t2a.cflow.ts +79 -0
- package/examples/comfy-cloud/chroma-t2i.cflow.ts +62 -0
- package/examples/comfy-cloud/cloudHost.ts +41 -0
- package/examples/comfy-cloud/ernie-t2i.cflow.ts +59 -0
- package/examples/comfy-cloud/firered-i2i.cflow.ts +74 -0
- package/examples/comfy-cloud/flux1-i2i.cflow.ts +76 -0
- package/examples/comfy-cloud/flux1-t2i.cflow.ts +63 -0
- package/examples/comfy-cloud/flux2-i2i.cflow.ts +80 -0
- package/examples/comfy-cloud/flux2-t2i.cflow.ts +57 -0
- package/examples/comfy-cloud/hidream-i2i.cflow.ts +89 -0
- package/examples/comfy-cloud/hidream-t2i.cflow.ts +65 -0
- package/examples/comfy-cloud/hunyuan-video-i2v.cflow.ts +93 -0
- package/examples/comfy-cloud/hunyuan-video-t2v.cflow.ts +74 -0
- package/examples/comfy-cloud/ideogram4-t2i.cflow.ts +80 -0
- package/examples/comfy-cloud/kandinsky5-i2v.cflow.ts +95 -0
- package/examples/comfy-cloud/kandinsky5-t2i.cflow.ts +60 -0
- package/examples/comfy-cloud/kandinsky5-t2v.cflow.ts +78 -0
- package/examples/comfy-cloud/krea2-t2i.cflow.ts +59 -0
- package/examples/comfy-cloud/lens-t2i.cflow.ts +62 -0
- package/examples/comfy-cloud/longcat-i2i.cflow.ts +74 -0
- package/examples/comfy-cloud/longcat-t2i.cflow.ts +65 -0
- package/examples/comfy-cloud/ltxv-i2v.cflow.ts +92 -0
- package/examples/comfy-cloud/ltxv-t2v.cflow.ts +78 -0
- package/examples/comfy-cloud/newbie-t2i.cflow.ts +67 -0
- package/examples/comfy-cloud/omnigen2-i2i.cflow.ts +86 -0
- package/examples/comfy-cloud/omnigen2-t2i.cflow.ts +62 -0
- package/examples/comfy-cloud/ovis-t2i.cflow.ts +56 -0
- package/examples/comfy-cloud/pixeldit-t2i.cflow.ts +63 -0
- package/examples/comfy-cloud/qwen-image-i2i.cflow.ts +69 -0
- package/examples/comfy-cloud/qwen-image-t2i.cflow.ts +55 -0
- package/examples/comfy-cloud/sd35-t2i.cflow.ts +48 -0
- package/examples/comfy-cloud/sdk.d.ts +123062 -0
- package/examples/comfy-cloud/sdxl-t2i.cflow.ts +69 -0
- package/examples/comfy-cloud/stable-audio-t2a.cflow.ts +53 -0
- package/examples/comfy-cloud/svd-i2v.cflow.ts +75 -0
- package/examples/comfy-cloud/wan21-i2v.cflow.ts +83 -0
- package/examples/comfy-cloud/wan21-t2v.cflow.ts +64 -0
- package/examples/comfy-cloud/wan22-5b-t2v.cflow.ts +69 -0
- package/examples/comfy-cloud/wan22-i2v.cflow.ts +107 -0
- package/examples/comfy-cloud/wan22-t2v.cflow.ts +98 -0
- package/examples/comfy-cloud/z-image-t2i.cflow.ts +62 -0
- package/examples/images/README.md +18 -0
- package/examples/images/bear_1024x1024.jpg +0 -0
- package/examples/images/deer_768x1344.jpg +0 -0
- package/examples/images/dog_512x512.jpg +0 -0
- package/examples/images/lioness_768x768.jpg +0 -0
- package/examples/images/pug_200x300.jpg +0 -0
- package/examples/images/walrus_1344x768.jpg +0 -0
- package/guide-for-agents.md +172 -0
- package/package.json +20 -4
- package/src/cli/comfy-ts-cli.ts +19 -2
- package/src/cli/gen.ts +21 -12
- package/src/cli/tui/components/PreviewPanel.tsx +9 -8
- package/src/cli/tui/components/StatusBar.tsx +11 -0
- package/src/cli/tui/components/TreePanel.tsx +15 -2
- package/src/cli/tui/components/TuiApp.tsx +18 -0
- package/src/cli/tui/discoverWorkflows.ts +45 -0
- package/src/cli/tui/imagePicker/ImagePickerOverlay.tsx +72 -0
- package/src/cli/tui/imagePicker/ImagePickerSt.ts +288 -0
- package/src/cli/tui/imagePicker/fsListing.ts +46 -0
- package/src/cli/tui/imagePicker/pickerPrefs.ts +78 -0
- package/src/cli/tui/run-tui.tsx +52 -23
- package/src/cli/tui/state/HostSt.ts +2 -3
- package/src/cli/tui/state/LorasSt.ts +14 -36
- package/src/cli/tui/state/PreviewSt.ts +28 -2
- package/src/cli/tui/state/TreeSt.ts +30 -6
- package/src/cli/tui/state/TuiSt.ts +27 -3
- package/src/cli/tui/state/WorkflowsSt.ts +15 -1
- package/src/exampleAssets.ts +56 -0
- package/src/graph/ComfyNode.ts +4 -1
- package/src/host/ComfyHost.ts +203 -77
- package/src/host/ComfyManager.ts +10 -9
- package/src/host/ComfyUploader.ts +1 -2
- package/src/host/ResilientWebsocket.ts +3 -1
- package/src/host/hostUrl.ts +59 -0
- package/src/host/loraManagerApi.ts +5 -4
- package/src/index.ts +27 -1
- package/src/litegraph/CanonicalWorkflow.ts +77 -0
- package/src/litegraph/LiteGraphGroup.ts +9 -7
- package/src/litegraph/LiteGraphJSON.ts +34 -13
- package/src/litegraph/LiteGraphLink.ts +32 -2
- package/src/litegraph/LiteGraphNode.ts +18 -33
- package/src/litegraph/LiteGraphNodeInput.ts +10 -8
- package/src/litegraph/LiteGraphNodeOutput.ts +2 -3
- package/src/litegraph/LiteGraphSubgraphDef.ts +74 -0
- package/src/litegraph/convertFlowToLiteGraphJSON.ts +4 -4
- package/src/litegraph/expandSubgraphs.ts +352 -0
- package/src/litegraph/normalizeWorkflow.ts +141 -0
- package/src/manager/ComfyRegistry.ts +37 -9
- package/src/manager/generated/KnownComfyCustomNodeName.ts +23852 -1926
- package/src/manager/generated/KnownComfyPluginTitle.ts +6854 -236
- package/src/manager/generated/KnownComfyPluginURL.ts +3425 -111
- package/src/manager/generated/KnownModel_Base.ts +23 -7
- package/src/manager/generated/KnownModel_FileName.ts +421 -0
- package/src/manager/generated/KnownModel_Name.ts +421 -0
- package/src/manager/generated/KnownModel_SavePath.ts +34 -8
- package/src/manager/generated/KnownModel_Type.ts +18 -14
- package/src/manager/json/alter-list.json +221 -221
- package/src/manager/json/custom-node-list.json +61020 -21946
- package/src/manager/json/extension-node-map.json +81077 -31176
- package/src/manager/json/github-stats.json +29321 -12601
- package/src/manager/json/model-list.json +5935 -4997
- package/src/manager/loaders/parseReport.ts +55 -0
- package/src/manager/loaders/step1_downloadComfyManagerJSONs.ts +15 -49
- package/src/manager/loaders/step2_custom-node-list-loader.ts +38 -83
- package/src/manager/loaders/step3_extension-node-map-loader.ts +36 -142
- package/src/manager/loaders/step4_model-list-loader.ts +25 -36
- package/src/manager/loaders/step5_alter-list-loader.ts +29 -0
- package/src/manager/loaders/step6_github-stats-loader.ts +23 -0
- package/src/manager/script-update-manager.bun.ts +9 -1
- package/src/manager/types/ComfyManagerAlterInfo.ts +13 -0
- package/src/manager/types/ComfyManagerFileModelInfo.ts +7 -3
- package/src/manager/types/ComfyManagerFilePluginContent.ts +6 -9
- package/src/manager/types/ComfyManagerFilePluginList.ts +3 -3
- package/src/manager/types/ComfyManagerGithubStats.ts +9 -0
- package/src/manager/types/ComfyManagerPluginContentMetadata.ts +2 -3
- package/src/manager/types/ComfyManagerPluginInfo.ts +48 -34
- package/src/runner/ComfyExecution.ts +4 -5
- package/src/runner/ComfyWorkflow.ts +2 -2
- package/src/runner/wsBinaryFrame.ts +48 -0
- package/src/sdk-generator/ComfySchema.ts +14 -1
- package/src/sdk-generator/Primitives.ts +6 -24
- package/src/sdk-generator/comfy-api-json.ts +3 -1
- package/src/sdk-generator/comfyui-sdk-codegen.ts +15 -0
- package/src/sdk-generator/inputWidgetKind.ts +196 -0
- package/src/sdk-generator/litegraphToApiRequestPayload.ts +372 -96
- package/src/state.ts +13 -2
- package/src/vars/ComfyVars.ts +82 -2
- package/src/vars/DefinedWorkflow.ts +7 -2
- package/dist/log-CdfgILde.js +0 -10
- package/dist/log-CdfgILde.js.map +0 -1
- package/dist/run-tui-SDSJo1Qf.js.map +0 -1
- package/src/utils/tryExtracting.ts +0 -41
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { LiteGraphLinkID } from 'src/litegraph/LiteGraphLinkID.ts'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* the ONE strict internal shape for imported workflows. ZERO optional fields:
|
|
5
|
+
* semantic absence is `null`, serializer noise gets a default at normalization.
|
|
6
|
+
* Every consumer of an imported workflow JSON (converter, sweeps, TUI) reads
|
|
7
|
+
* this type only — optionality never crosses `normalizeWorkflow`. A new
|
|
8
|
+
* consumer needing a wire field ADDS it here (with a default), it does not
|
|
9
|
+
* reach around the pipeline to the raw document.
|
|
10
|
+
*/
|
|
11
|
+
export type CanonicalWorkflow = {
|
|
12
|
+
/** subgraph instances with a definition are expanded away by normalization (expandSubgraphs.ts) */
|
|
13
|
+
nodes: CanonicalNode[]
|
|
14
|
+
/** object form only, both wire eras unified */
|
|
15
|
+
links: CanonicalLink[]
|
|
16
|
+
/** [] when the document had none */
|
|
17
|
+
groups: CanonicalGroup[]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type CanonicalLink = {
|
|
21
|
+
id: LiteGraphLinkID
|
|
22
|
+
originId: number
|
|
23
|
+
originSlot: number
|
|
24
|
+
targetId: number
|
|
25
|
+
targetSlot: number
|
|
26
|
+
type: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* raw 0/1/3 (always / on-event / on-trigger) → 'normal'; 2 → 'muted'; 4 → 'bypassed'.
|
|
31
|
+
* Literal union on purpose: converter switches are total, no magic ints downstream.
|
|
32
|
+
*/
|
|
33
|
+
export type NodeMode = 'normal' | 'muted' | 'bypassed'
|
|
34
|
+
|
|
35
|
+
export type CanonicalNode = {
|
|
36
|
+
id: number
|
|
37
|
+
type: string
|
|
38
|
+
title: string | null
|
|
39
|
+
mode: NodeMode
|
|
40
|
+
isVirtualNode: boolean // false when absent
|
|
41
|
+
inputs: CanonicalInput[] // [] when absent
|
|
42
|
+
outputs: CanonicalOutput[] // [] when absent
|
|
43
|
+
widgets: CanonicalWidgetValues
|
|
44
|
+
pos: [number, number] // real tuples (wire has {0,1} objects AND arrays)
|
|
45
|
+
size: [number, number]
|
|
46
|
+
properties: Record<string, unknown> // raw passthrough (proxyWidgets, cnr_id/ver)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type CanonicalInput = {
|
|
50
|
+
name: string
|
|
51
|
+
type: string
|
|
52
|
+
link: LiteGraphLinkID | null // null = unconnected (incl. omitted key)
|
|
53
|
+
widgetName: string | null // widget.name when widget-backed
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type CanonicalOutput = {
|
|
57
|
+
name: string
|
|
58
|
+
type: string
|
|
59
|
+
links: LiteGraphLinkID[] // [] for null/absent
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* ONE shape for all three widget-value realities: array form (positional),
|
|
64
|
+
* object form (named, e.g. VHS_*), and subgraph promotion overrides (named).
|
|
65
|
+
* Both fields ALWAYS present.
|
|
66
|
+
*/
|
|
67
|
+
export type CanonicalWidgetValues = {
|
|
68
|
+
positional: unknown[]
|
|
69
|
+
named: Record<string, unknown>
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type CanonicalGroup = {
|
|
73
|
+
title: string
|
|
74
|
+
bounding: [number, number, number, number]
|
|
75
|
+
color: string // default '#3f789e' (litegraph default)
|
|
76
|
+
fontSize: number // default 24
|
|
77
|
+
}
|
|
@@ -3,20 +3,22 @@ import type { EmptyRecord, IsEqual } from 'src/types/index.ts'
|
|
|
3
3
|
|
|
4
4
|
// prettier-ignore
|
|
5
5
|
export type LiteGraphGroup = {
|
|
6
|
-
|
|
6
|
+
id?: number // 1 (newer serializers only)
|
|
7
|
+
title: string // 'Create Mask'
|
|
7
8
|
bounding: [number, number, number, number] // [1078, -579, 1589, 614]
|
|
8
|
-
color
|
|
9
|
-
font_size
|
|
10
|
-
flags
|
|
9
|
+
color?: string // '#3f789e' (omitted = litegraph default)
|
|
10
|
+
font_size?: number // 24 (omitted = litegraph default)
|
|
11
|
+
flags?: EmptyRecord // {}
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export const LiteGraphGroup_ark = type({
|
|
15
|
+
'id?': 'number',
|
|
14
16
|
title: 'string',
|
|
15
17
|
bounding: type(['number', 'number', 'number', 'number']),
|
|
16
|
-
color: 'string',
|
|
17
|
-
font_size: 'number',
|
|
18
|
+
'color?': 'string',
|
|
19
|
+
'font_size?': 'number',
|
|
18
20
|
// EmptyRecord: an object we don't read any key from
|
|
19
|
-
flags: type.Record('string', 'unknown').as<EmptyRecord>(),
|
|
21
|
+
'flags?': type.Record('string', 'unknown').as<EmptyRecord>(),
|
|
20
22
|
})
|
|
21
23
|
|
|
22
24
|
true satisfies IsEqual<LiteGraphGroup, typeof LiteGraphGroup_ark.infer>
|
|
@@ -3,35 +3,52 @@ import type { EmptyRecord, IsEqual } from 'src/types/index.ts'
|
|
|
3
3
|
import { type LiteGraphGroup, LiteGraphGroup_ark } from 'src/litegraph/LiteGraphGroup.ts'
|
|
4
4
|
import { type LiteGraphLink, LiteGraphLink_ark } from 'src/litegraph/LiteGraphLink.ts'
|
|
5
5
|
import { type LiteGraphNode, LiteGraphNode_ark } from 'src/litegraph/LiteGraphNode.ts'
|
|
6
|
+
import { type LiteGraphSubgraphDef, LiteGraphSubgraphDef_ark } from 'src/litegraph/LiteGraphSubgraphDef.ts'
|
|
6
7
|
|
|
7
8
|
/** comfy workflows are simply LiteGraphs workflows */
|
|
8
9
|
export type ComfyWorkflowJSON = LiteGraphJSON
|
|
9
10
|
|
|
10
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* litegraph workflow root, TOLERANT: models what upstream actually serializes
|
|
13
|
+
* across eras — v0.4 (tuple links, last_*_id) and v1 (object links, `state`),
|
|
14
|
+
* including hybrid files (v0.4 root + v1-shaped subgraph definitions).
|
|
15
|
+
* Downstream code never reads this shape: `normalizeWorkflow` turns it into
|
|
16
|
+
* the strict `CanonicalWorkflow`.
|
|
17
|
+
*/
|
|
11
18
|
export type LiteGraphJSON = {
|
|
12
|
-
|
|
13
|
-
|
|
19
|
+
id?: string // uuid (newer serializers)
|
|
20
|
+
revision?: number
|
|
21
|
+
last_node_id?: number // v0.4 (recomputable, absent in v1)
|
|
22
|
+
last_link_id?: number // v0.4
|
|
23
|
+
state?: Record<string, unknown> // v1: {lastNodeId, lastLinkId, …}
|
|
14
24
|
nodes: LiteGraphNode[]
|
|
15
25
|
links: LiteGraphLink[]
|
|
16
|
-
groups
|
|
17
|
-
config
|
|
18
|
-
extra
|
|
26
|
+
groups?: LiteGraphGroup[]
|
|
27
|
+
config?: EmptyRecord
|
|
28
|
+
extra?: {
|
|
19
29
|
ds?: {
|
|
20
30
|
scale: number
|
|
21
31
|
offset: { 0: number; 1: number }
|
|
22
32
|
}
|
|
23
33
|
}
|
|
24
|
-
|
|
34
|
+
models?: unknown[] // model download manifest — never read
|
|
35
|
+
definitions?: { subgraphs: LiteGraphSubgraphDef[] }
|
|
36
|
+
reroutes?: unknown[] // v1 cosmetic link routing — dropped at normalization
|
|
37
|
+
floatingLinks?: unknown[] // v1 cosmetic — dropped at normalization
|
|
38
|
+
version: 0.4 | 1
|
|
25
39
|
}
|
|
26
40
|
|
|
27
41
|
export const LiteGraphJSON_ark = type({
|
|
28
|
-
|
|
29
|
-
|
|
42
|
+
'id?': 'string',
|
|
43
|
+
'revision?': 'number',
|
|
44
|
+
'last_node_id?': 'number',
|
|
45
|
+
'last_link_id?': 'number',
|
|
46
|
+
'state?': type.Record('string', 'unknown'),
|
|
30
47
|
nodes: LiteGraphNode_ark.array(),
|
|
31
48
|
links: LiteGraphLink_ark.array(),
|
|
32
|
-
groups: LiteGraphGroup_ark.array(),
|
|
33
|
-
config: type.Record('never', 'never'),
|
|
34
|
-
extra: {
|
|
49
|
+
'groups?': LiteGraphGroup_ark.array(),
|
|
50
|
+
'config?': type.Record('never', 'never'),
|
|
51
|
+
'extra?': {
|
|
35
52
|
'ds?': {
|
|
36
53
|
scale: 'number',
|
|
37
54
|
offset: {
|
|
@@ -40,7 +57,11 @@ export const LiteGraphJSON_ark = type({
|
|
|
40
57
|
},
|
|
41
58
|
},
|
|
42
59
|
},
|
|
43
|
-
|
|
60
|
+
'models?': 'unknown[]',
|
|
61
|
+
'definitions?': { subgraphs: LiteGraphSubgraphDef_ark.array() },
|
|
62
|
+
'reroutes?': 'unknown[]',
|
|
63
|
+
'floatingLinks?': 'unknown[]',
|
|
64
|
+
version: '0.4 | 1',
|
|
44
65
|
})
|
|
45
66
|
|
|
46
67
|
true satisfies IsEqual<LiteGraphJSON, typeof LiteGraphJSON_ark.infer>
|
|
@@ -2,7 +2,8 @@ import { type } from 'arktype'
|
|
|
2
2
|
import type { IsEqual } from 'src/types/index.ts'
|
|
3
3
|
import { type LiteGraphLinkID, LiteGraphLinkID_ } from 'src/litegraph/LiteGraphLinkID.ts'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/** v0.4 serialization: links are 6-tuples (our EXPORT path emits this form) */
|
|
6
|
+
export type LiteGraphLinkTuple = [
|
|
6
7
|
linkId: LiteGraphLinkID, // 9, - linkId
|
|
7
8
|
fromNodeId: number, // 8, - fromNodeId
|
|
8
9
|
fromNodeOutputIx: number, // 0, - fromNodeOutputIx
|
|
@@ -11,7 +12,7 @@ export type LiteGraphLink = [
|
|
|
11
12
|
linkType: string, // "IMAGE" - type
|
|
12
13
|
]
|
|
13
14
|
|
|
14
|
-
export const
|
|
15
|
+
export const LiteGraphLinkTuple_ark = type([
|
|
15
16
|
LiteGraphLinkID_, // 9, - linkId
|
|
16
17
|
'number', // 8, - fromNodeId
|
|
17
18
|
'number', // 0, - fromNodeOutputIx
|
|
@@ -20,4 +21,33 @@ export const LiteGraphLink_ark = type([
|
|
|
20
21
|
'string', // "IMAGE" - linkType
|
|
21
22
|
])
|
|
22
23
|
|
|
24
|
+
true satisfies IsEqual<typeof LiteGraphLinkTuple_ark.infer, LiteGraphLinkTuple>
|
|
25
|
+
|
|
26
|
+
/** v1 serialization: links are objects (subgraph definition interiors use this) */
|
|
27
|
+
export type LiteGraphLinkObject = {
|
|
28
|
+
id: LiteGraphLinkID
|
|
29
|
+
origin_id: number // -10 = the subgraph's inputNode boundary
|
|
30
|
+
origin_slot: number
|
|
31
|
+
target_id: number // -20 = the subgraph's outputNode boundary
|
|
32
|
+
target_slot: number
|
|
33
|
+
type: string
|
|
34
|
+
parentId?: number // reroute chain parent (cosmetic)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const LiteGraphLinkObject_ark = type({
|
|
38
|
+
id: LiteGraphLinkID_,
|
|
39
|
+
origin_id: 'number',
|
|
40
|
+
origin_slot: 'number',
|
|
41
|
+
target_id: 'number',
|
|
42
|
+
target_slot: 'number',
|
|
43
|
+
type: 'string',
|
|
44
|
+
'parentId?': 'number',
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
true satisfies IsEqual<typeof LiteGraphLinkObject_ark.infer, LiteGraphLinkObject>
|
|
48
|
+
|
|
49
|
+
export type LiteGraphLink = LiteGraphLinkTuple | LiteGraphLinkObject
|
|
50
|
+
|
|
51
|
+
export const LiteGraphLink_ark = LiteGraphLinkTuple_ark.or(LiteGraphLinkObject_ark)
|
|
52
|
+
|
|
23
53
|
true satisfies IsEqual<typeof LiteGraphLink_ark.infer, LiteGraphLink>
|
|
@@ -1,69 +1,54 @@
|
|
|
1
1
|
import { type } from 'arktype'
|
|
2
|
-
import type {
|
|
2
|
+
import type { IsEqual } from 'src/types/index.ts'
|
|
3
3
|
import { type LiteGraphNodeInput, LiteGraphNodeInput_ark } from 'src/litegraph/LiteGraphNodeInput.ts'
|
|
4
4
|
import { type LiteGraphNodeOutput, LiteGraphNodeOutput_ark } from 'src/litegraph/LiteGraphNodeOutput.ts'
|
|
5
5
|
|
|
6
6
|
// prettier-ignore
|
|
7
7
|
export type LiteGraphNode = {
|
|
8
8
|
id: number // 5
|
|
9
|
-
type: string // 'CLIPTextEncode'
|
|
9
|
+
type: string // 'CLIPTextEncode', or a definitions.subgraphs uuid (instance)
|
|
10
10
|
|
|
11
11
|
// cosmetics
|
|
12
12
|
title?: string // "Inpaint (Positive)",
|
|
13
13
|
color?: string // "#222", or "#3f789e"
|
|
14
|
-
|
|
15
|
-
pos: { '0': number; '1': number } //
|
|
14
|
+
bgcolor?: string // "#3f789e" (lowercase, like upstream)
|
|
15
|
+
pos: { '0': number; '1': number } // serialized as [number, number] OR {0,1}
|
|
16
16
|
size: { '0': number; '1': number }
|
|
17
|
-
flags?:
|
|
17
|
+
flags?: Record<string, unknown> // collapsed?, pinned?, … — never read
|
|
18
18
|
order?: number
|
|
19
19
|
/**
|
|
20
|
-
* 0 = normal
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
* */
|
|
20
|
+
* 0 = always (normal), 1 = on-event, 2 = muted (never),
|
|
21
|
+
* 3 = on-trigger, 4 = bypassed
|
|
22
|
+
*/
|
|
24
23
|
mode?: number
|
|
25
24
|
inputs?: LiteGraphNodeInput[]
|
|
26
|
-
outputs
|
|
25
|
+
outputs?: LiteGraphNodeOutput[]
|
|
27
26
|
|
|
28
27
|
isVirtualNode?: boolean // frontend only
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*/
|
|
34
|
-
'Node name for S&R'?: string
|
|
35
|
-
|
|
36
|
-
/** when set to true, it.... */
|
|
37
|
-
showOutputText?: boolean
|
|
38
|
-
|
|
39
|
-
/** no clue what it does */
|
|
40
|
-
horizontal?: boolean
|
|
41
|
-
}
|
|
42
|
-
widgets_values?: unknown[]
|
|
28
|
+
/** open record: proxyWidgets (subgraph widget promotion), cnr_id/ver (pack provenance), … */
|
|
29
|
+
properties?: Record<string, unknown>
|
|
30
|
+
/** array form (positional) OR object form (named, e.g. VHS_VideoCombine) */
|
|
31
|
+
widgets_values?: unknown[] | Record<string, unknown>
|
|
43
32
|
}
|
|
44
33
|
|
|
45
34
|
export const LiteGraphNode_ark = type({
|
|
46
35
|
id: 'number',
|
|
47
36
|
type: 'string',
|
|
48
37
|
|
|
49
|
-
//
|
|
38
|
+
// cosmetics
|
|
50
39
|
'title?': 'string',
|
|
51
40
|
'color?': 'string',
|
|
52
41
|
'bgcolor?': 'string',
|
|
53
42
|
pos: { '0': 'number', '1': 'number' },
|
|
54
43
|
size: { '0': 'number', '1': 'number' },
|
|
55
|
-
'flags?':
|
|
44
|
+
'flags?': type.Record('string', 'unknown'),
|
|
56
45
|
'order?': 'number',
|
|
57
46
|
'mode?': 'number',
|
|
58
47
|
'inputs?': LiteGraphNodeInput_ark.array(),
|
|
59
|
-
outputs: LiteGraphNodeOutput_ark.array(),
|
|
48
|
+
'outputs?': LiteGraphNodeOutput_ark.array(),
|
|
60
49
|
'isVirtualNode?': 'boolean',
|
|
61
|
-
'properties?':
|
|
62
|
-
|
|
63
|
-
'showOutputText?': 'boolean',
|
|
64
|
-
'horizontal?': 'boolean',
|
|
65
|
-
},
|
|
66
|
-
'widgets_values?': `unknown[]`,
|
|
50
|
+
'properties?': type.Record('string', 'unknown'),
|
|
51
|
+
'widgets_values?': type('unknown[]').or(type.Record('string', 'unknown')),
|
|
67
52
|
})
|
|
68
53
|
|
|
69
54
|
true satisfies IsEqual<LiteGraphNode, typeof LiteGraphNode_ark.infer>
|
|
@@ -3,24 +3,26 @@ import type { IsEqual } from 'src/types/index.ts'
|
|
|
3
3
|
import { type LiteGraphLinkID, LiteGraphLinkID_ } from 'src/litegraph/LiteGraphLinkID.ts'
|
|
4
4
|
|
|
5
5
|
export type LiteGraphNodeInput = {
|
|
6
|
-
name: string //
|
|
7
|
-
type: string //
|
|
8
|
-
link
|
|
9
|
-
shape?: number //
|
|
6
|
+
name: string // | 'clip'
|
|
7
|
+
type: string // | 'CLIP'
|
|
8
|
+
link?: LiteGraphLinkID | null // | 5 (widget-backed inputs omit the key)
|
|
9
|
+
shape?: number // | 7
|
|
10
|
+
label?: string // | 'select'
|
|
10
11
|
widget?: {
|
|
11
|
-
name: string //
|
|
12
|
-
config
|
|
12
|
+
name: string // | 'select'
|
|
13
|
+
config?: unknown // | 2022-era serializer only, gone since
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export const LiteGraphNodeInput_ark = type({
|
|
17
18
|
name: 'string',
|
|
18
19
|
type: 'string',
|
|
19
|
-
link: LiteGraphLinkID_.or(type.null),
|
|
20
|
+
'link?': LiteGraphLinkID_.or(type.null),
|
|
20
21
|
'shape?': 'number',
|
|
22
|
+
'label?': 'string',
|
|
21
23
|
'widget?': type({
|
|
22
24
|
name: 'string',
|
|
23
|
-
config:
|
|
25
|
+
'config?': 'unknown',
|
|
24
26
|
}),
|
|
25
27
|
})
|
|
26
28
|
|
|
@@ -4,10 +4,9 @@ import { type LiteGraphLinkID, LiteGraphLinkID_ } from 'src/litegraph/LiteGraphL
|
|
|
4
4
|
import { type LiteGraphSlotIndex, LiteGraphSlotIndex_ } from 'src/litegraph/LiteGraphSlotIndex.ts'
|
|
5
5
|
|
|
6
6
|
export type LiteGraphNodeOutput = {
|
|
7
|
-
// ❌9 name: string // 'CONDITIONING'
|
|
8
7
|
name: string
|
|
9
8
|
type: string // 'CONDITIONING'
|
|
10
|
-
links
|
|
9
|
+
links?: LiteGraphLinkID[] | null // unconnected outputs may omit the key
|
|
11
10
|
shape?: number // '2D'
|
|
12
11
|
slot_index?: LiteGraphSlotIndex
|
|
13
12
|
}
|
|
@@ -15,7 +14,7 @@ export type LiteGraphNodeOutput = {
|
|
|
15
14
|
export const LiteGraphNodeOutput_ark = type({
|
|
16
15
|
name: 'string',
|
|
17
16
|
type: 'string',
|
|
18
|
-
links: LiteGraphLinkID_.array().or(type.null),
|
|
17
|
+
'links?': LiteGraphLinkID_.array().or(type.null),
|
|
19
18
|
'shape?': 'number',
|
|
20
19
|
'slot_index?': LiteGraphSlotIndex_,
|
|
21
20
|
})
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type } from 'arktype'
|
|
2
|
+
import type { EmptyRecord, IsEqual } from 'src/types/index.ts'
|
|
3
|
+
import { type LiteGraphGroup, LiteGraphGroup_ark } from 'src/litegraph/LiteGraphGroup.ts'
|
|
4
|
+
import { type LiteGraphLinkID, LiteGraphLinkID_ } from 'src/litegraph/LiteGraphLinkID.ts'
|
|
5
|
+
import { type LiteGraphLinkObject, LiteGraphLinkObject_ark } from 'src/litegraph/LiteGraphLink.ts'
|
|
6
|
+
import { type LiteGraphNode, LiteGraphNode_ark } from 'src/litegraph/LiteGraphNode.ts'
|
|
7
|
+
|
|
8
|
+
/** one exposed input/output slot of a subgraph definition */
|
|
9
|
+
export type LiteGraphSubgraphIO = {
|
|
10
|
+
id: string // uuid
|
|
11
|
+
name: string // 'image'
|
|
12
|
+
type: string // 'IMAGE'
|
|
13
|
+
linkIds?: LiteGraphLinkID[]
|
|
14
|
+
label?: string
|
|
15
|
+
localized_name?: string
|
|
16
|
+
pos?: { '0': number; '1': number }
|
|
17
|
+
shape?: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const LiteGraphSubgraphIO_ark = type({
|
|
21
|
+
id: 'string',
|
|
22
|
+
name: 'string',
|
|
23
|
+
type: 'string',
|
|
24
|
+
'linkIds?': LiteGraphLinkID_.array(),
|
|
25
|
+
'label?': 'string',
|
|
26
|
+
'localized_name?': 'string',
|
|
27
|
+
'pos?': { '0': 'number', '1': 'number' },
|
|
28
|
+
'shape?': 'number',
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
true satisfies IsEqual<LiteGraphSubgraphIO, typeof LiteGraphSubgraphIO_ark.infer>
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* a subgraph definition body (definitions.subgraphs[] entry). Corpus fact:
|
|
35
|
+
* every one is a v1-shaped interior (object links, `state`) even when the
|
|
36
|
+
* root document is v0.4 — instances reference it via node.type = this uuid.
|
|
37
|
+
*/
|
|
38
|
+
export type LiteGraphSubgraphDef = {
|
|
39
|
+
id: string // uuid, referenced by instance nodes' `type`
|
|
40
|
+
name: string
|
|
41
|
+
version: number // 1 in the whole corpus
|
|
42
|
+
state?: Record<string, unknown> // {lastNodeId, lastLinkId, …} — recomputable
|
|
43
|
+
revision?: number
|
|
44
|
+
config?: EmptyRecord
|
|
45
|
+
extra?: unknown
|
|
46
|
+
nodes: LiteGraphNode[]
|
|
47
|
+
links: LiteGraphLinkObject[]
|
|
48
|
+
groups?: LiteGraphGroup[]
|
|
49
|
+
inputNode: { id: number; bounding: number[] } // id is -10 in boundary links
|
|
50
|
+
outputNode: { id: number; bounding: number[] } // id is -20 in boundary links
|
|
51
|
+
inputs: LiteGraphSubgraphIO[]
|
|
52
|
+
outputs: LiteGraphSubgraphIO[]
|
|
53
|
+
widgets: unknown[] // empty in the whole corpus
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const LiteGraphSubgraphDef_ark = type({
|
|
57
|
+
id: 'string',
|
|
58
|
+
name: 'string',
|
|
59
|
+
version: 'number',
|
|
60
|
+
'state?': type.Record('string', 'unknown'),
|
|
61
|
+
'revision?': 'number',
|
|
62
|
+
'config?': type.Record('string', 'unknown').as<EmptyRecord>(),
|
|
63
|
+
'extra?': 'unknown',
|
|
64
|
+
nodes: LiteGraphNode_ark.array(),
|
|
65
|
+
links: LiteGraphLinkObject_ark.array(),
|
|
66
|
+
'groups?': LiteGraphGroup_ark.array(),
|
|
67
|
+
inputNode: { id: 'number', bounding: 'number[]' },
|
|
68
|
+
outputNode: { id: 'number', bounding: 'number[]' },
|
|
69
|
+
inputs: LiteGraphSubgraphIO_ark.array(),
|
|
70
|
+
outputs: LiteGraphSubgraphIO_ark.array(),
|
|
71
|
+
widgets: 'unknown[]',
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
true satisfies IsEqual<LiteGraphSubgraphDef, typeof LiteGraphSubgraphDef_ark.infer>
|
|
@@ -1,9 +1,9 @@
|
|
|
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 { howManyWidgetValuesForThisSchemaType } from 'src/sdk-generator/
|
|
4
|
+
import { howManyWidgetValuesForThisSchemaType } from 'src/sdk-generator/inputWidgetKind.ts'
|
|
5
5
|
import type { LiteGraphJSON } from 'src/litegraph/LiteGraphJSON.ts'
|
|
6
|
-
import type {
|
|
6
|
+
import type { LiteGraphLinkTuple } from 'src/litegraph/LiteGraphLink.ts'
|
|
7
7
|
import { asLiteGraphLinkID, type LiteGraphLinkID } from 'src/litegraph/LiteGraphLinkID.ts'
|
|
8
8
|
import type { LiteGraphNode } from 'src/litegraph/LiteGraphNode.ts'
|
|
9
9
|
import type { LiteGraphNodeInput } from 'src/litegraph/LiteGraphNodeInput.ts'
|
|
@@ -21,7 +21,7 @@ export const convertFlowToLiteGraphJSON = (graph: ComfyWorkflow): LiteGraphJSON
|
|
|
21
21
|
const n = xx.liteGraphNode
|
|
22
22
|
n.pos[0] = bang(xx.comfyNode.x)
|
|
23
23
|
n.pos[1] = bang(xx.comfyNode.y)
|
|
24
|
-
for (const o of n.outputs) {
|
|
24
|
+
for (const o of n.outputs ?? []) {
|
|
25
25
|
o.links = ctx.links.filter((l) => l[3] === n.id && l[4] === o.slot_index).map((l) => l[0])
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -99,7 +99,7 @@ const _isLink = (v: unknown): v is [string, number] => {
|
|
|
99
99
|
export class LiteGraphCtx {
|
|
100
100
|
constructor(public graph: ComfyWorkflow) {}
|
|
101
101
|
nextLinkId: number = 0
|
|
102
|
-
links:
|
|
102
|
+
links: LiteGraphLinkTuple[] = []
|
|
103
103
|
allocateLink = (
|
|
104
104
|
fromNodeId: number,
|
|
105
105
|
fromNodeOutputIx: number,
|