comfy-ts 1.0.0 → 1.2.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 +60 -11
- package/dist/cli.js +4 -4439
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +445 -172
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7439 -340
- package/dist/index.d.ts +7457 -358
- package/dist/index.js +444 -172
- package/dist/index.js.map +1 -1
- package/dist/{run-tui-BFhba_oG.js → run-tui-BAdizWsO.js} +1244 -201
- package/dist/run-tui-BAdizWsO.js.map +1 -0
- package/dist/state-BYbxDgfr.js +5258 -0
- package/dist/state-BYbxDgfr.js.map +1 -0
- package/examples/README.md +32 -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 +445 -57
- 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/examples/{01-txt2img.cflow.ts → rvion/01-txt2img.cflow.ts} +1 -1
- package/examples/{02-img2img-upload.cflow.ts → rvion/02-img2img-upload.cflow.ts} +7 -18
- package/examples/{03-export-workflow-json.cflow.ts → rvion/03-export-workflow-json.cflow.ts} +1 -1
- package/examples/{04-krea2-turbo-t2i.cflow.ts → rvion/04-krea2-turbo-t2i.cflow.ts} +2 -2
- package/examples/rvion/05-comfy-cloud.cflow.ts +51 -0
- package/examples/rvion/06-qwen-image-edit.cflow.ts +89 -0
- package/guide-for-agents.md +7 -1
- package/package.json +18 -4
- package/src/cli/tui/components/CopyOverlay.tsx +25 -0
- package/src/cli/tui/components/Header.tsx +9 -4
- package/src/cli/tui/components/HostPanel.tsx +3 -2
- package/src/cli/tui/components/HostsOverlay.tsx +33 -0
- package/src/cli/tui/components/PreviewPanel.tsx +9 -8
- package/src/cli/tui/components/StatusBar.tsx +39 -9
- package/src/cli/tui/components/TreePanel.tsx +17 -7
- package/src/cli/tui/components/TuiApp.tsx +65 -5
- package/src/cli/tui/discoverWorkflows.ts +7 -41
- 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 +48 -0
- package/src/cli/tui/imagePicker/pickerPrefs.ts +78 -0
- package/src/cli/tui/run-tui.tsx +49 -8
- package/src/cli/tui/state/DraftsSt.ts +3 -2
- package/src/cli/tui/state/ExecSt.ts +108 -12
- package/src/cli/tui/state/HostSt.ts +94 -10
- package/src/cli/tui/state/LorasSt.ts +14 -36
- package/src/cli/tui/state/PickerSt.ts +8 -2
- package/src/cli/tui/state/PreviewSt.ts +28 -2
- package/src/cli/tui/state/QueueSt.ts +2 -2
- package/src/cli/tui/state/SettingsSt.ts +25 -7
- package/src/cli/tui/state/TreeSt.ts +139 -36
- package/src/cli/tui/state/TuiSt.ts +53 -6
- package/src/cli/tui/state/WorkflowsSt.ts +14 -2
- package/src/cli/tui/treeRows.ts +165 -0
- package/src/exampleAssets.ts +56 -0
- package/src/graph/ComfyNode.ts +4 -1
- package/src/host/ComfyHost.ts +7 -0
- package/src/index.ts +7 -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/ComfyWorkflowLayout.ts +6 -4
- package/src/sdk-generator/ComfySchema.ts +14 -1
- package/src/sdk-generator/comfyui-sdk-codegen.ts +15 -0
- package/src/sdk-generator/inputWidgetKind.ts +17 -0
- package/src/state.ts +7 -1
- package/src/vars/ComfyVars.ts +106 -5
- package/src/vars/DefinedWorkflow.ts +28 -10
- package/dist/DefinedWorkflow-O3ynII3Y.js +0 -598
- package/dist/DefinedWorkflow-O3ynII3Y.js.map +0 -1
- package/dist/run-tui-BFhba_oG.js.map +0 -1
- package/examples/05-comfy-cloud.cflow.ts +0 -67
- package/src/utils/tryExtracting.ts +0 -41
|
@@ -8,7 +8,15 @@ console.clear()
|
|
|
8
8
|
console.log(chalk.bold.greenBright('UPDADING COMFY MANAGER JSONS'))
|
|
9
9
|
|
|
10
10
|
// should take care of the code generation
|
|
11
|
-
await ComfyRegistry.DownloadAndUpdate(!skipDL)
|
|
11
|
+
const registry = await ComfyRegistry.DownloadAndUpdate(!skipDL)
|
|
12
|
+
|
|
13
|
+
console.log(chalk.bold.greenBright('REGISTRY TOTALS'))
|
|
14
|
+
console.log(` plugins (by title): ${registry.plugins_byTitle.size}`)
|
|
15
|
+
console.log(` plugin repo urls: ${registry.plugins_byFile.size}`)
|
|
16
|
+
console.log(` custom node keys: ${registry.plugins_byNodeKey.size}`)
|
|
17
|
+
console.log(` models: ${registry.knownModels.size}`)
|
|
18
|
+
console.log(` alterations: ${registry.alterations.length}`)
|
|
19
|
+
console.log(` github stats: ${registry.githubStats.size}`)
|
|
12
20
|
|
|
13
21
|
// the generator aligns its own `// x N` comments and emits trailing blank
|
|
14
22
|
// lines; oxfmt disagrees on both, so WITHOUT this the ci gate goes red right
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type } from 'arktype'
|
|
2
|
+
|
|
3
|
+
/** ONE alter-list.json row (a1111 extension → comfy alternative); `tags` is a comma-separated STRING upstream */
|
|
4
|
+
export type ComfyManagerAlterInfo = typeof ComfyManagerAlterInfo_ark.infer
|
|
5
|
+
export const ComfyManagerAlterInfo_ark = type({
|
|
6
|
+
id: 'string', // "https://github.com/comfyanonymous/ComfyUI"
|
|
7
|
+
tags: 'string', // "SD1.x,SD2.x,SDXL"
|
|
8
|
+
description: 'string',
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
/** root shape only: rows are validated ONE BY ONE */
|
|
12
|
+
export type ComfyManagerFileAlterListRoot = typeof ComfyManagerFileAlterListRoot_ark.infer
|
|
13
|
+
export const ComfyManagerFileAlterListRoot_ark = type({ items: 'unknown[]' })
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { type } from 'arktype'
|
|
2
|
-
import {
|
|
2
|
+
import type { ComfyManagerModelInfo } from 'src/manager/types/ComfyManagerModelInfo.ts'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
export
|
|
4
|
+
/** root shape only: rows are validated ONE BY ONE against ComfyManagerModelInfo_ark */
|
|
5
|
+
export type ComfyManagerFileModelInfoRoot = typeof ComfyManagerFileModelInfoRoot_ark.infer
|
|
6
|
+
export const ComfyManagerFileModelInfoRoot_ark = type({ models: 'unknown[]' })
|
|
7
|
+
|
|
8
|
+
/** hand-maintained extras (model-list.extra.ts) still declare the full canonical shape */
|
|
9
|
+
export type ComfyManagerFileModelInfo = { models: ComfyManagerModelInfo[] }
|
|
@@ -2,12 +2,9 @@ import { type } from 'arktype'
|
|
|
2
2
|
import { ComfyManagerPluginContentMetadata_ark } from 'src/manager/types/ComfyManagerPluginContentMetadata.ts'
|
|
3
3
|
import { ComfyManagerPluginContentNodeName_ark } from 'src/manager/types/ComfyManagerPluginEnums.ts'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
ComfyManagerPluginContentMetadata_ark,
|
|
12
|
-
]),
|
|
13
|
-
)
|
|
5
|
+
/** ONE extension-node-map entry value: [nodeNames, meta]; the file root is a Record of these, validated row by row */
|
|
6
|
+
export type ComfyManagerExtensionNodeMapEntry = typeof ComfyManagerExtensionNodeMapEntry_ark.infer
|
|
7
|
+
export const ComfyManagerExtensionNodeMapEntry_ark = type([
|
|
8
|
+
ComfyManagerPluginContentNodeName_ark.array(),
|
|
9
|
+
ComfyManagerPluginContentMetadata_ark,
|
|
10
|
+
])
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type } from 'arktype'
|
|
2
|
-
import { ComfyManagerPluginInfo_ark } from 'src/manager/types/ComfyManagerPluginInfo.ts'
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
export
|
|
3
|
+
/** root shape only: rows are validated ONE BY ONE against ComfyManagerRawPluginInfo_ark */
|
|
4
|
+
export type ComfyManagerFilePluginListRoot = typeof ComfyManagerFilePluginListRoot_ark.infer
|
|
5
|
+
export const ComfyManagerFilePluginListRoot_ark = type({ custom_nodes: 'unknown[]' })
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type } from 'arktype'
|
|
2
|
+
|
|
3
|
+
/** ONE github-stats.json entry, keyed by repo url in the file root (a Record, validated row by row) */
|
|
4
|
+
export type ComfyManagerGithubStatEntry = typeof ComfyManagerGithubStatEntry_ark.infer
|
|
5
|
+
export const ComfyManagerGithubStatEntry_ark = type({
|
|
6
|
+
stars: 'number',
|
|
7
|
+
last_update: 'string', // "2026-07-28 03:14:59"
|
|
8
|
+
author_account_age_days: 'number',
|
|
9
|
+
})
|
|
@@ -2,9 +2,8 @@ import { type } from 'arktype'
|
|
|
2
2
|
|
|
3
3
|
export type ComfyManagerPluginContentMetadata = typeof ComfyManagerPluginContentMetadata_ark.infer
|
|
4
4
|
export const ComfyManagerPluginContentMetadata_ark = type({
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
title_aux: type.string.or(type.null), // "Jovimetrix Composition Nodes",
|
|
5
|
+
// absent on 10/5573 upstream rows (2026-07-30), null on others
|
|
6
|
+
'title_aux?': type.string.or(type.null), // "Jovimetrix Composition Nodes",
|
|
8
7
|
|
|
9
8
|
// optional
|
|
10
9
|
'author?': 'string', // "amorano",
|
|
@@ -3,48 +3,62 @@ import type { KnownComfyPluginTitle } from 'src/manager/generated/KnownComfyPlug
|
|
|
3
3
|
import type { KnownComfyPluginURL } from 'src/manager/generated/KnownComfyPluginURL.ts'
|
|
4
4
|
import type { ComfyManagerPluginID } from 'src/manager/types/ComfyManagerPluginEnums.ts'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
/**
|
|
7
|
+
* loose INPUT schema: what Comfy-Org/ComfyUI-Manager custom-node-list.json
|
|
8
|
+
* actually ships (surveyed 2026-07-30, 5882 rows)
|
|
9
|
+
*/
|
|
10
|
+
export type ComfyManagerRawPluginInfo = typeof ComfyManagerRawPluginInfo_ark.infer
|
|
11
|
+
export const ComfyManagerRawPluginInfo_ark = type({
|
|
12
|
+
// always present upstream
|
|
13
|
+
author: 'string',
|
|
14
|
+
title: type.string.as<KnownComfyPluginTitle>(),
|
|
15
|
+
reference: 'string',
|
|
16
|
+
files: type.string.as<KnownComfyPluginURL>().array(),
|
|
17
|
+
install_type: 'string', // 'git-clone' | 'copy' | 'unzip' | stray casings
|
|
18
|
+
description: 'string',
|
|
15
19
|
|
|
16
|
-
//
|
|
17
|
-
id: type.string.as<ComfyManagerPluginID>(),
|
|
20
|
+
// absent on 4471/5882 rows (2026-07-30): recovered at normalization
|
|
21
|
+
'id?': type.string.as<ComfyManagerPluginID>(),
|
|
18
22
|
|
|
19
|
-
// optional
|
|
23
|
+
// sparse optional tail
|
|
20
24
|
'preemptions?': 'string[]',
|
|
21
25
|
'pip?': 'string[]',
|
|
22
26
|
'nodename_pattern?': 'string',
|
|
23
27
|
'apt_dependency?': 'string[]',
|
|
24
28
|
'js_path?': 'string',
|
|
25
29
|
'version?': 'string',
|
|
30
|
+
'tags?': 'string[]',
|
|
26
31
|
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
'
|
|
32
|
+
// 2025/2026 additions, unconsumed but declared so drift stays visible
|
|
33
|
+
'reference2?': 'string',
|
|
34
|
+
'category?': 'string',
|
|
35
|
+
'name?': 'string',
|
|
36
|
+
'license?': 'string',
|
|
37
|
+
'nickname?': 'string',
|
|
38
|
+
'stars?': 'number',
|
|
39
|
+
'last_update?': 'string',
|
|
40
|
+
'badges?': 'string[]',
|
|
41
|
+
'dependencies?': 'string[]',
|
|
30
42
|
})
|
|
31
43
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
/**
|
|
45
|
+
* canonical plugin row: `id` ALWAYS present (normalization recovers it).
|
|
46
|
+
* The optional tail stays optional ON PURPOSE: this object is also the
|
|
47
|
+
* Manager v2 install POST body, where absent and null differ python-side.
|
|
48
|
+
*/
|
|
49
|
+
export type ComfyManagerPluginInfo = {
|
|
50
|
+
id: ComfyManagerPluginID
|
|
51
|
+
author: string
|
|
52
|
+
title: KnownComfyPluginTitle
|
|
53
|
+
reference: string
|
|
54
|
+
files: KnownComfyPluginURL[]
|
|
55
|
+
install_type: string
|
|
56
|
+
description: string
|
|
57
|
+
preemptions?: string[]
|
|
58
|
+
pip?: string[]
|
|
59
|
+
nodename_pattern?: string
|
|
60
|
+
apt_dependency?: string[]
|
|
61
|
+
js_path?: string
|
|
62
|
+
version?: string
|
|
63
|
+
tags?: string[]
|
|
64
|
+
}
|
|
@@ -15,9 +15,9 @@ import type { ComfyWorkflow } from 'src/runner/ComfyWorkflow.ts'
|
|
|
15
15
|
export function comfyWorkflowAutoLayout(
|
|
16
16
|
this: ComfyWorkflow,
|
|
17
17
|
p?: {
|
|
18
|
-
/** @default:
|
|
18
|
+
/** @default: 40 */
|
|
19
19
|
node_vsep?: number
|
|
20
|
-
/** @default:
|
|
20
|
+
/** @default: 100 */
|
|
21
21
|
node_hsep?: number
|
|
22
22
|
/** @default false */
|
|
23
23
|
forceLeft?: boolean
|
|
@@ -70,8 +70,10 @@ export function comfyWorkflowAutoLayout(
|
|
|
70
70
|
else cols[at] = [node]
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
// real ComfyUI nodes render wider than the 200px layout estimate, so the
|
|
74
|
+
// horizontal gap is generous to keep pasted graphs readable
|
|
75
|
+
const HSEP = p?.node_hsep ?? 100
|
|
76
|
+
const VSEP = p?.node_vsep ?? 40
|
|
75
77
|
// cols.reverse()
|
|
76
78
|
let colX = 0
|
|
77
79
|
let maxY = 0
|
|
@@ -4,6 +4,7 @@ import { toQualifiedNodeKey } from 'src/sdk-generator/_toQualifiedNodeKey.ts'
|
|
|
4
4
|
import { ComfyNodeSchema } from 'src/sdk-generator/ComfyNodeSchema.ts'
|
|
5
5
|
import type { ComfyEnumDef, ComfyNodeSchemaJSON, ComfySchemaJSON } from 'src/sdk-generator/ComfyUIObjectInfoTypes.ts'
|
|
6
6
|
import { codegenSDK } from 'src/sdk-generator/comfyui-sdk-codegen.ts'
|
|
7
|
+
import { classifyWidgetInput, containerInstanceSlotType } from 'src/sdk-generator/inputWidgetKind.ts'
|
|
7
8
|
import {
|
|
8
9
|
asComfyNodeSlotName,
|
|
9
10
|
asComfyNodeSlotTypeName,
|
|
@@ -233,9 +234,21 @@ export class ComfySchema {
|
|
|
233
234
|
)
|
|
234
235
|
}
|
|
235
236
|
|
|
237
|
+
// autogrow container: the declaration is never a prompt input
|
|
238
|
+
// (instances are `<name>.<inst>` link slots) — never required, and
|
|
239
|
+
// its template sub-input slot type registers like any slot so
|
|
240
|
+
// codegen can type the dotted instance keys (agent/sdk-codegen.md)
|
|
241
|
+
const isAutogrowContainer =
|
|
242
|
+
typeof slotType === 'string' &&
|
|
243
|
+
classifyWidgetInput({ name: ipt.name, type: slotType, opts: slotOpts }).kind === 'dynamic-container'
|
|
244
|
+
if (isAutogrowContainer) {
|
|
245
|
+
const instType = containerInstanceSlotType(slotOpts)
|
|
246
|
+
if (instType != null) this.knownSlotTypes.add(asComfyNodeSlotTypeName(instType))
|
|
247
|
+
}
|
|
248
|
+
|
|
236
249
|
node.inputs.push({
|
|
237
250
|
slotName: inputSlotName,
|
|
238
|
-
required: ipt.required,
|
|
251
|
+
required: ipt.required && !isAutogrowContainer,
|
|
239
252
|
nameInComfy: inputNameInComfy,
|
|
240
253
|
nameInComfyEscaped: escapeJSKey(inputNameInComfy),
|
|
241
254
|
typeName: inputTypeName,
|
|
@@ -4,6 +4,7 @@ import { escapeJSKey } from 'src/utils/escapeJSKey.ts'
|
|
|
4
4
|
import type { ComfySchema } from 'src/sdk-generator/ComfySchema.ts'
|
|
5
5
|
|
|
6
6
|
import { type ComfyNodeSchema, wrapQuote } from 'src/sdk-generator/ComfyNodeSchema.ts'
|
|
7
|
+
import { classifySchemaInput, containerInstanceSlotType } from 'src/sdk-generator/inputWidgetKind.ts'
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* convert a host id to the namespace name it gets inside the global `Comfy` namespace
|
|
@@ -76,6 +77,20 @@ export function codegenSDK(this: ComfySchema, opts: CodegenOptions): string {
|
|
|
76
77
|
for (const n of nodes) {
|
|
77
78
|
p(`${escapeJSKey(n.nodeKey)}: {`)
|
|
78
79
|
for (const i of n.inputs) {
|
|
80
|
+
// autogrow container: emit dotted instance keys, never the container
|
|
81
|
+
// decl itself — the backend prompt input is `<name>.<inst>`, the
|
|
82
|
+
// first template.min instances required (agent/sdk-codegen.md)
|
|
83
|
+
const kind = classifySchemaInput(i)
|
|
84
|
+
if (kind.kind === 'dynamic-container') {
|
|
85
|
+
const instType = containerInstanceSlotType(i.opts)
|
|
86
|
+
if (instType != null) {
|
|
87
|
+
kind.instanceNames.forEach((instName, ix) => {
|
|
88
|
+
const opt = ix >= kind.requiredCount ? '?' : ''
|
|
89
|
+
p(` ${escapeJSKey(`${i.nameInComfy}.${instName}`)}${opt}: Accepts[${JSON.stringify(instType)}]`)
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
continue
|
|
93
|
+
}
|
|
79
94
|
const opts_ = typeof i.opts === 'string' ? null : i.opts
|
|
80
95
|
let type = `Accepts[${JSON.stringify(i.typeName)}]`
|
|
81
96
|
// COMBO inputs (ComfyUI ≥ 0.3.x) carry literal choices in opts.options
|
|
@@ -93,6 +93,23 @@ const parseContainer = (template: Record<string, unknown>): InputWidgetKind => {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* the single template sub-input's slot type of an autogrow container
|
|
98
|
+
* (`'IMAGE'` for TextEncodeBooguEdit.images). null when opts are not an
|
|
99
|
+
* autogrow template or the template has several sub-inputs (corpus-absent
|
|
100
|
+
* 2026-07-30, 27/27 single on the cloud catalog) — then codegen emits no
|
|
101
|
+
* typed instance keys and the container stays builderBase territory.
|
|
102
|
+
*/
|
|
103
|
+
export const containerInstanceSlotType = (opts: unknown): string | null => {
|
|
104
|
+
const o = isRecord(opts) ? opts : null
|
|
105
|
+
const template = o?.['template']
|
|
106
|
+
if (!isRecord(template) || !isRecord(template['input'])) return null
|
|
107
|
+
const subs = flattenInputSections(template['input'])
|
|
108
|
+
const first = subs[0]
|
|
109
|
+
if (subs.length !== 1 || first == null || typeof first.type !== 'string') return null
|
|
110
|
+
return first.type
|
|
111
|
+
}
|
|
112
|
+
|
|
96
113
|
export const classifyWidgetInput = (p: {
|
|
97
114
|
name: string
|
|
98
115
|
type: string | readonly unknown[]
|
package/src/state.ts
CHANGED
|
@@ -6,6 +6,12 @@ import { parseHostBase, renderHttpBase } from 'src/host/hostUrl.ts'
|
|
|
6
6
|
import { ComfyRegistry } from 'src/manager/ComfyRegistry.ts'
|
|
7
7
|
import { type AbsolutePath, asAbsolutePath, type RelativePath } from 'src/types/index.ts'
|
|
8
8
|
|
|
9
|
+
/** the ONE settings-file location rule — run-tui reads it BEFORE any module
|
|
10
|
+
* import creates the comfyts global, so the path logic cannot live on the instance only */
|
|
11
|
+
export function settingsPathFor(root: string): AbsolutePath {
|
|
12
|
+
return asAbsolutePath(join(root, '.comfy-ts', 'settings.json'))
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
/** singleton */
|
|
10
16
|
export class ComfyTS {
|
|
11
17
|
version = pkgJson.version
|
|
@@ -99,7 +105,7 @@ export class ComfyTS {
|
|
|
99
105
|
|
|
100
106
|
/** local TUI settings (preview mode, last draft per workflow) — gitignored */
|
|
101
107
|
get settingsPath(): AbsolutePath {
|
|
102
|
-
return
|
|
108
|
+
return settingsPathFor(this.rootPath)
|
|
103
109
|
}
|
|
104
110
|
|
|
105
111
|
resolveFromHosts(relativePath: string): AbsolutePath {
|
package/src/vars/ComfyVars.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
// Vars: the standard "tweak & re-run" contract. A workflow defined via
|
|
2
2
|
// host.defineWorkflow({ vars, build }) rebuilds its graph from current var
|
|
3
3
|
// values on every run — drivers (scripts, the TUI) edit vars between runs.
|
|
4
|
+
import { readFileSync } from 'node:fs'
|
|
5
|
+
import { homedir } from 'node:os'
|
|
6
|
+
import { imageMeta } from 'image-meta'
|
|
4
7
|
import { action, makeObservable, observable } from 'mobx'
|
|
8
|
+
import { basename, isAbsolute, join, resolve } from 'pathe'
|
|
5
9
|
import { getLoraKeyword } from 'src/vars/loraKeywords.ts'
|
|
6
10
|
|
|
7
|
-
export type VarKind = 'text' | 'int' | 'float' | 'seed' | 'toggle' | 'choice' | 'loras' | 'size'
|
|
11
|
+
export type VarKind = 'text' | 'int' | 'float' | 'seed' | 'toggle' | 'choice' | 'loras' | 'size' | 'image'
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
14
|
* full base: T is what's STORED/edited, Out what the GRAPH consumes at build
|
|
@@ -14,6 +18,8 @@ export type VarKind = 'text' | 'int' | 'float' | 'seed' | 'toggle' | 'choice' |
|
|
|
14
18
|
*/
|
|
15
19
|
export abstract class ComfyVarBase<T, Out> {
|
|
16
20
|
abstract readonly kind: VarKind
|
|
21
|
+
/** the vars-spec key, stamped by DefinedWorkflow at define time — error messages name the var with it */
|
|
22
|
+
name?: string
|
|
17
23
|
value: T
|
|
18
24
|
constructor(
|
|
19
25
|
public readonly defaultValue: T,
|
|
@@ -441,17 +447,36 @@ export const DEFAULT_SIZE_PRESETS: SizePreset[] = [
|
|
|
441
447
|
{ label: '9:16 tall', width: 768, height: 1344 },
|
|
442
448
|
]
|
|
443
449
|
|
|
444
|
-
/** width/height picker: presets + free `WxH` entry
|
|
450
|
+
/** width/height picker: presets + free `WxH` entry + optionally the LIVE
|
|
451
|
+
* size of a linked image var (his ask 2026-07-30: the widget shows
|
|
452
|
+
* `WxH size of image '<name>'` as a pickable row) */
|
|
445
453
|
export class SizeVar extends ComfyVar<SizeValue> {
|
|
446
454
|
readonly kind = 'size' as const
|
|
447
455
|
constructor(
|
|
448
456
|
defaultValue: SizeValue = { width: 1024, height: 1024 },
|
|
449
457
|
public readonly presets: SizePreset[] = DEFAULT_SIZE_PRESETS,
|
|
450
458
|
label?: string,
|
|
459
|
+
public readonly imageVar?: ImageVar,
|
|
451
460
|
) {
|
|
452
461
|
super(defaultValue, label)
|
|
453
462
|
}
|
|
454
463
|
|
|
464
|
+
/** current dimensions of the linked image var — null when no link, unset
|
|
465
|
+
* path, or an unreadable/undecodable file (those errors belong to the
|
|
466
|
+
* image var itself, the size row simply disappears) */
|
|
467
|
+
imageSize(): { width: number; height: number; name: string } | null {
|
|
468
|
+
const iv = this.imageVar
|
|
469
|
+
if (iv == null || iv.value === '') return null
|
|
470
|
+
try {
|
|
471
|
+
const abs = iv.absPath()
|
|
472
|
+
const meta = imageMeta(new Uint8Array(readFileSync(abs)))
|
|
473
|
+
if (meta.width == null || meta.height == null) return null
|
|
474
|
+
return { width: meta.width, height: meta.height, name: basename(abs) }
|
|
475
|
+
} catch {
|
|
476
|
+
return null
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
455
480
|
/** accepts '1024x768' / '1024×768' / a preset label */
|
|
456
481
|
parse(raw: string): boolean {
|
|
457
482
|
const m = raw.trim().match(/^(\d+)\s*[x×]\s*(\d+)$/)
|
|
@@ -474,7 +499,80 @@ export class SizeVar extends ComfyVar<SizeValue> {
|
|
|
474
499
|
}
|
|
475
500
|
}
|
|
476
501
|
|
|
477
|
-
|
|
502
|
+
export type ImageVarOpts = {
|
|
503
|
+
/** where the TUI picker starts browsing AND what relative values resolve against (absPath) */
|
|
504
|
+
folder?: string
|
|
505
|
+
/** picker listing filter, lowercase without dots; never affects the value */
|
|
506
|
+
extensions?: readonly string[]
|
|
507
|
+
label?: string
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
export const DEFAULT_IMAGE_EXTENSIONS: readonly string[] = ['png', 'jpg', 'jpeg', 'webp', 'gif']
|
|
511
|
+
|
|
512
|
+
/** empty image var consumed at build time — typed so drivers surface it apart from real crashes */
|
|
513
|
+
export class ImageVarEmptyError extends Error {
|
|
514
|
+
constructor(public readonly varName: string) {
|
|
515
|
+
super(`image var '${varName}' is empty — pick a file (TUI: activate the var; script: .set('/path/to/image.png'))`)
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/** trim + expand a leading `~/` — every ImageVar write funnels through this */
|
|
520
|
+
function expandUserPath(raw: string): string {
|
|
521
|
+
const trimmed = raw.trim()
|
|
522
|
+
return trimmed.startsWith('~/') ? join(homedir(), trimmed.slice(2)) : trimmed
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* a local image path. The VALUE is a PLAIN PATH STRING — text-encodable,
|
|
527
|
+
* drafts persist it verbatim (toJSON = the string), hand-editable in the
|
|
528
|
+
* draft json. Empty = unset: outValue()/absPath() throw ImageVarEmptyError,
|
|
529
|
+
* so a build never runs on a silent placeholder. The TUI opens the image
|
|
530
|
+
* picker overlay for kind 'image'.
|
|
531
|
+
*/
|
|
532
|
+
export class ImageVar extends ComfyVar<string> {
|
|
533
|
+
readonly kind = 'image' as const
|
|
534
|
+
constructor(
|
|
535
|
+
defaultValue: string,
|
|
536
|
+
public opts: ImageVarOpts = {},
|
|
537
|
+
) {
|
|
538
|
+
super(expandUserPath(defaultValue), opts.label)
|
|
539
|
+
}
|
|
540
|
+
/** what the picker lists (lowercase, no dots) */
|
|
541
|
+
get extensions(): readonly string[] {
|
|
542
|
+
return this.opts.extensions ?? DEFAULT_IMAGE_EXTENSIONS
|
|
543
|
+
}
|
|
544
|
+
override set(value: string): this {
|
|
545
|
+
return super.set(expandUserPath(value))
|
|
546
|
+
}
|
|
547
|
+
parse(raw: string): boolean {
|
|
548
|
+
this.set(raw)
|
|
549
|
+
return true
|
|
550
|
+
}
|
|
551
|
+
isSet(): boolean {
|
|
552
|
+
return this.value !== ''
|
|
553
|
+
}
|
|
554
|
+
private emptyError(): ImageVarEmptyError {
|
|
555
|
+
return new ImageVarEmptyError(this.name ?? this.label ?? 'image')
|
|
556
|
+
}
|
|
557
|
+
/** the ONE resolution helper: absolute kept as-is, relative resolved against opts.folder, else cwd */
|
|
558
|
+
absPath(): string {
|
|
559
|
+
if (!this.isSet()) throw this.emptyError()
|
|
560
|
+
if (isAbsolute(this.value)) return this.value
|
|
561
|
+
return resolve(this.opts.folder ?? process.cwd(), this.value)
|
|
562
|
+
}
|
|
563
|
+
/** empty = unset: the build fails LOUD here (varValues calls outValue) */
|
|
564
|
+
override outValue(): string {
|
|
565
|
+
if (!this.isSet()) throw this.emptyError()
|
|
566
|
+
return this.value
|
|
567
|
+
}
|
|
568
|
+
override display(): string {
|
|
569
|
+
if (!this.isSet()) return '(unset) pick a file'
|
|
570
|
+
const home = homedir()
|
|
571
|
+
return this.value.startsWith(`${home}/`) ? `~${this.value.slice(home.length)}` : this.value
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/** the var constructors: v.text / v.prompt / v.int / v.float / v.seed / v.toggle / v.choice / v.loras / v.size / v.image */
|
|
478
576
|
export const v = {
|
|
479
577
|
text: (defaultValue: string, label?: string): TextVar => new TextVar(defaultValue, label),
|
|
480
578
|
prompt: (defaultValue: string, opts: { label?: string; loraKeywordsFrom?: ActiveLoraSource } = {}): PromptVar =>
|
|
@@ -492,8 +590,9 @@ export const v = {
|
|
|
492
590
|
initial: Partial<Record<T, LoraStrength>> = {},
|
|
493
591
|
label?: string,
|
|
494
592
|
): LorasVar<T> => new LorasVar(options, initial, label),
|
|
495
|
-
size: (defaultValue?: SizeValue, opts: { presets?: SizePreset[]; label?: string } = {}): SizeVar =>
|
|
496
|
-
new SizeVar(defaultValue, opts.presets, opts.label),
|
|
593
|
+
size: (defaultValue?: SizeValue, opts: { presets?: SizePreset[]; label?: string; image?: ImageVar } = {}): SizeVar =>
|
|
594
|
+
new SizeVar(defaultValue, opts.presets, opts.label, opts.image),
|
|
595
|
+
image: (defaultValue: string, opts: ImageVarOpts = {}): ImageVar => new ImageVar(defaultValue, opts),
|
|
497
596
|
}
|
|
498
597
|
|
|
499
598
|
/**
|
|
@@ -505,6 +604,8 @@ export type AnyVar = {
|
|
|
505
604
|
readonly kind: VarKind
|
|
506
605
|
readonly value: unknown
|
|
507
606
|
readonly label?: string
|
|
607
|
+
/** the vars-spec key — DefinedWorkflow writes it at define time */
|
|
608
|
+
name?: string
|
|
508
609
|
parse(raw: string): boolean
|
|
509
610
|
loadJSON(value: unknown): unknown
|
|
510
611
|
toJSON(): unknown
|
|
@@ -37,6 +37,9 @@ export type BoundVars<ID extends string> = Omit<typeof v, 'loras'> & {
|
|
|
37
37
|
export type DefineWorkflowSpec<ID extends string, V extends VarsSpec> = {
|
|
38
38
|
/** short id; also names the workflow instances */
|
|
39
39
|
id?: string
|
|
40
|
+
/** optional TUI tree color (ink color name or hex); unset = the tree's
|
|
41
|
+
* per-family palette (first `-` word of the module basename) */
|
|
42
|
+
color?: string
|
|
40
43
|
/** the tweakable knobs; drivers (scripts, TUI) edit these between runs.
|
|
41
44
|
* A LAMBDA gives cross-referencing vars a scope (loras + prompt with
|
|
42
45
|
* loraKeywordsFrom created inline) — resolved ONCE at define time, and it
|
|
@@ -70,8 +73,13 @@ export class DefinedWorkflow<ID extends string = string, V extends VarsSpec = Va
|
|
|
70
73
|
// factory BoundVars describes; the regex-loras typing claim it adds is
|
|
71
74
|
// resolved from the same object_info enum via bindHost below
|
|
72
75
|
this.vars = isVarsThunk(spec.vars) ? spec.vars(v as BoundVars<ID>) : spec.vars
|
|
73
|
-
//
|
|
74
|
-
|
|
76
|
+
// define-time var wiring: the spec key becomes the var's name (error
|
|
77
|
+
// messages name the var with it), host-dependent vars (v.loras(regex))
|
|
78
|
+
// resolve their options
|
|
79
|
+
for (const [key, varDef] of this.entries()) {
|
|
80
|
+
varDef.name = key
|
|
81
|
+
varDef.bindHost?.(this.host)
|
|
82
|
+
}
|
|
75
83
|
}
|
|
76
84
|
|
|
77
85
|
/** [name, var] pairs, for drivers that enumerate the knobs */
|
|
@@ -89,10 +97,13 @@ export class DefinedWorkflow<ID extends string = string, V extends VarsSpec = Va
|
|
|
89
97
|
* (set by run()) fires each var's afterRun() right after snapshotting the
|
|
90
98
|
* values — atomically, before any await — so the graph uses this run's seed
|
|
91
99
|
* while the var moves to the next (queued runs get distinct seeds; a bare
|
|
92
|
-
* build() for copy/export never advances).
|
|
100
|
+
* build() for copy/export never advances). `p.host` substitutes the host
|
|
101
|
+
* the graph is built against (TUI host override): node/model availability
|
|
102
|
+
* there surfaces as workflow.problems / server validation, by design.
|
|
93
103
|
*/
|
|
94
|
-
async build(p: { advance?: boolean } = {}): Promise<ComfyWorkflow<ID>> {
|
|
95
|
-
const
|
|
104
|
+
async build(p: { advance?: boolean; host?: ComfyHost<ID> } = {}): Promise<ComfyWorkflow<ID>> {
|
|
105
|
+
const host = p.host ?? this.host
|
|
106
|
+
const wf = host.workflow({ id: this.spec.id })
|
|
96
107
|
const values = varValues(this.vars)
|
|
97
108
|
if (p.advance) for (const varDef of Object.values(this.vars)) varDef.afterRun()
|
|
98
109
|
await this.spec.build(wf.builder, values, wf)
|
|
@@ -101,11 +112,18 @@ export class DefinedWorkflow<ID extends string = string, V extends VarsSpec = Va
|
|
|
101
112
|
}
|
|
102
113
|
|
|
103
114
|
/** build a fresh graph from the current var values, send it, wait for outputs.
|
|
104
|
-
* connects first (idempotent) — modules can import offline from the schema cache
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
115
|
+
* connects first (idempotent) — modules can import offline from the schema cache.
|
|
116
|
+
* `settings.host` runs against THAT host instead of the defining one. */
|
|
117
|
+
async run(settings: RunSettings & { host?: ComfyHost<ID> } = {}): Promise<ComfyExecution> {
|
|
118
|
+
const host = settings.host ?? this.host
|
|
119
|
+
await host.connect()
|
|
120
|
+
const wf = await this.build({ advance: true, host })
|
|
121
|
+
const execution = await wf.run({
|
|
122
|
+
saveFormat: settings.saveFormat,
|
|
123
|
+
idMode: settings.idMode,
|
|
124
|
+
log: settings.log,
|
|
125
|
+
onProgress: settings.onProgress,
|
|
126
|
+
})
|
|
109
127
|
this.lastExecution = execution
|
|
110
128
|
return execution
|
|
111
129
|
}
|