comfy-ts 0.2.0 → 0.4.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/LICENSE +21 -0
- package/README.md +363 -0
- package/dist/cli.js +764 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +4171 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +9910 -0
- package/dist/index.d.ts +9894 -58
- package/dist/index.js +4092 -2
- package/dist/index.js.map +1 -1
- package/dist/log-CdfgILde.js +10 -0
- package/dist/log-CdfgILde.js.map +1 -0
- package/dist/run-tui-SDSJo1Qf.js +3896 -0
- package/dist/run-tui-SDSJo1Qf.js.map +1 -0
- package/package.json +103 -75
- package/src/cli/comfy-ts-cli.ts +36 -0
- package/src/cli/gen.ts +47 -0
- package/src/cli/outline.ts +82 -0
- package/src/cli/tui/components/DraftsOverlay.tsx +44 -0
- package/src/cli/tui/components/EditField.tsx +27 -0
- package/src/cli/tui/components/Header.tsx +56 -0
- package/src/cli/tui/components/HostPanel.tsx +37 -0
- package/src/cli/tui/components/LogsPanel.tsx +23 -0
- package/src/cli/tui/components/LorasOverlay.tsx +49 -0
- package/src/cli/tui/components/OverlayList.tsx +25 -0
- package/src/cli/tui/components/PickerOverlays.tsx +66 -0
- package/src/cli/tui/components/PreviewPanel.tsx +78 -0
- package/src/cli/tui/components/PromptOverlay.tsx +16 -0
- package/src/cli/tui/components/StatusBar.tsx +171 -0
- package/src/cli/tui/components/TextOverlay.tsx +72 -0
- package/src/cli/tui/components/TreePanel.tsx +51 -0
- package/src/cli/tui/components/TuiApp.tsx +246 -0
- package/src/cli/tui/components/VarsPanel.tsx +86 -0
- package/src/cli/tui/findDefinedWorkflow.ts +16 -0
- package/src/cli/tui/keys.ts +20 -0
- package/src/cli/tui/protocolImagePainter.ts +95 -0
- package/src/cli/tui/run-tui.tsx +76 -0
- package/src/cli/tui/state/DraftsSt.ts +273 -0
- package/src/cli/tui/state/EditorSt.ts +289 -0
- package/src/cli/tui/state/ExecSt.ts +173 -0
- package/src/cli/tui/state/HostSt.ts +230 -0
- package/src/cli/tui/state/LogsSt.ts +107 -0
- package/src/cli/tui/state/LorasSt.ts +185 -0
- package/src/cli/tui/state/PickerSt.ts +112 -0
- package/src/cli/tui/state/PreviewSt.ts +288 -0
- package/src/cli/tui/state/QueueSt.ts +59 -0
- package/src/cli/tui/state/SettingsSt.ts +100 -0
- package/src/cli/tui/state/TreeSt.ts +122 -0
- package/src/cli/tui/state/TuiSt.ts +175 -0
- package/src/cli/tui/state/WorkflowsSt.ts +93 -0
- package/src/cli/tui-env.ts +8 -0
- package/src/errors/InvalidPromptError.ts +12 -0
- package/src/graph/ComfyNode.ts +403 -0
- package/src/graph/ComfyNodeID.ts +28 -0
- package/src/graph/ComfyNodeOutput.ts +16 -0
- package/src/graph/NodeSlotSize.ts +4 -0
- package/src/graph/autoValue.ts +17 -0
- package/src/host/ComfyHost.ts +690 -0
- package/src/host/ComfyInstallType.ts +15 -0
- package/src/host/ComfyManager.ts +232 -0
- package/src/host/ComfyUploader.ts +110 -0
- package/src/host/ComfyWorkflowBuilder.ts +60 -0
- package/src/host/Requirements.ts +55 -0
- package/src/host/ResilientWebsocket.ts +147 -0
- package/src/host/loraManagerApi.ts +98 -0
- package/src/image-utils/_getPngMetadata.ts +53 -0
- package/src/image-utils/_getWebpMetadata.ts +38 -0
- package/src/image-utils/_parseExifData.ts +53 -0
- package/src/index.ts +89 -0
- package/src/litegraph/LiteGraphGroup.ts +22 -0
- package/src/litegraph/LiteGraphJSON.ts +46 -0
- package/src/litegraph/LiteGraphLink.ts +23 -0
- package/src/litegraph/LiteGraphLinkID.ts +6 -0
- package/src/litegraph/LiteGraphNode.ts +69 -0
- package/src/litegraph/LiteGraphNodeInput.ts +27 -0
- package/src/litegraph/LiteGraphNodeOutput.ts +23 -0
- package/src/litegraph/LiteGraphSlotIndex.ts +6 -0
- package/src/litegraph/convertFlowToLiteGraphJSON.ts +114 -0
- package/src/manager/ComfyRegistry.ts +124 -0
- package/src/manager/generated/KnownComfyCustomNodeName.ts +19280 -0
- package/src/manager/generated/KnownComfyPluginTitle.ts +5130 -0
- package/src/manager/generated/KnownComfyPluginURL.ts +2589 -0
- package/src/manager/generated/KnownModel_Base.ts +126 -0
- package/src/manager/generated/KnownModel_FileName.ts +2287 -0
- package/src/manager/generated/KnownModel_Name.ts +2287 -0
- package/src/manager/generated/KnownModel_SavePath.ts +263 -0
- package/src/manager/generated/KnownModel_Type.ts +97 -0
- package/src/manager/json/alter-list.json +224 -0
- package/src/manager/json/custom-node-list.extra.ts +13 -0
- package/src/manager/json/custom-node-list.json +21948 -0
- package/src/manager/json/extension-node-map.json +31282 -0
- package/src/manager/json/github-stats.json +12602 -0
- package/src/manager/json/model-list.extra.ts +26 -0
- package/src/manager/json/model-list.json +5052 -0
- package/src/manager/loaders/step1_downloadComfyManagerJSONs.ts +56 -0
- package/src/manager/loaders/step2_custom-node-list-loader.ts +149 -0
- package/src/manager/loaders/step3_extension-node-map-loader.ts +189 -0
- package/src/manager/loaders/step4_model-list-loader.ts +159 -0
- package/src/manager/script-update-manager.bun.ts +18 -0
- package/src/manager/types/ComfyManagerAPIFetchPolicy.ts +9 -0
- package/src/manager/types/ComfyManagerAPIModelList.ts +10 -0
- package/src/manager/types/ComfyManagerAPIPluginList.ts +11 -0
- package/src/manager/types/ComfyManagerFileModelInfo.ts +5 -0
- package/src/manager/types/ComfyManagerFilePluginContent.ts +13 -0
- package/src/manager/types/ComfyManagerFilePluginList.ts +5 -0
- package/src/manager/types/ComfyManagerModelInfo.ts +18 -0
- package/src/manager/types/ComfyManagerPluginContentMetadata.ts +16 -0
- package/src/manager/types/ComfyManagerPluginEnums.ts +8 -0
- package/src/manager/types/ComfyManagerPluginInfo.ts +50 -0
- package/src/runner/ComfyExecution.ts +301 -0
- package/src/runner/ComfyExecutionStatus.ts +2 -0
- package/src/runner/ComfyWorkflow.ts +395 -0
- package/src/runner/ComfyWorkflowLayout.ts +96 -0
- package/src/runner/ComfyWsApi.ts +170 -0
- package/src/runner/MediaImage.ts +262 -0
- package/src/sdk-generator/ComfyNodeSchema.ts +79 -0
- package/src/sdk-generator/ComfySchema.ts +369 -0
- package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +95 -0
- package/src/sdk-generator/Primitives.ts +76 -0
- package/src/sdk-generator/_getUnionNameBasedOnFirstFoundEnumName.ts +39 -0
- package/src/sdk-generator/_pythonModuleToNamespace.ts +27 -0
- package/src/sdk-generator/_toQualifiedNodeKey.ts +5 -0
- package/src/sdk-generator/comfy-api-json.ts +16 -0
- package/src/sdk-generator/comfyui-sdk-codegen.ts +287 -0
- package/src/sdk-generator/comfyui-types.ts +56 -0
- package/src/sdk-generator/litegraphToApiRequestPayload.ts +157 -0
- package/src/ssh-host-manager/ssh-config-manager.ts +89 -0
- package/src/ssh-host-manager/ssh-config.windows.md +32 -0
- package/src/ssh-host-manager/ssh-manager.ts +114 -0
- package/src/state.ts +136 -0
- package/src/types/comfy-sdk.ts +106 -0
- package/src/types/index.ts +55 -0
- package/src/utils/CodeBuffer.ts +61 -0
- package/src/utils/ComfyColors.ts +38 -0
- package/src/utils/ansi.ts +33 -0
- package/src/utils/ansiImage.ts +36 -0
- package/src/utils/bang.ts +39 -0
- package/src/utils/deepCopyNaive.ts +1 -0
- package/src/utils/downloadFile.ts +77 -0
- package/src/utils/escapeJSKey.ts +32 -0
- package/src/utils/exhaust.ts +4 -0
- package/src/utils/extractErrorMessage.ts +11 -0
- package/src/utils/fuzzyMatch.ts +8 -0
- package/src/utils/githubRegexes.ts +2 -0
- package/src/utils/hashArrayBuffer.ts +6 -0
- package/src/utils/log.ts +9 -0
- package/src/utils/loraTag.ts +10 -0
- package/src/utils/mojibake.ts +60 -0
- package/src/utils/printArkResultInConsole.ts +16 -0
- package/src/utils/softValidate.ts +8 -0
- package/src/utils/stringifyReadable.ts +32 -0
- package/src/utils/toposort.ts +59 -0
- package/src/utils/tryExtracting.ts +41 -0
- package/src/utils/writeFile.ts +16 -0
- package/src/vars/ComfyVars.ts +531 -0
- package/src/vars/DefinedWorkflow.ts +112 -0
- package/src/vars/loraKeywords.ts +56 -0
- package/dist/index.d.mts +0 -74
- package/dist/index.mjs +0 -3
- package/dist/index.mjs.map +0 -1
- package/readme.md +0 -40
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { ansi as chalk } from 'src/utils/ansi.ts'
|
|
2
|
+
import type { NodeNameInComfy, QualifiedNodeKey } from 'src/sdk-generator/comfyui-types.ts'
|
|
3
|
+
import type { KnownComfyCustomNodeName } from 'src/manager/generated/KnownComfyCustomNodeName.ts'
|
|
4
|
+
import type { KnownComfyPluginTitle } from 'src/manager/generated/KnownComfyPluginTitle.ts'
|
|
5
|
+
import type { KnownComfyPluginURL } from 'src/manager/generated/KnownComfyPluginURL.ts'
|
|
6
|
+
import type { KnownModel_Name } from 'src/manager/generated/KnownModel_Name.ts'
|
|
7
|
+
import { DownloadComfyManagerJSONs } from 'src/manager/loaders/step1_downloadComfyManagerJSONs.ts'
|
|
8
|
+
import { _getKnownPlugins } from 'src/manager/loaders/step2_custom-node-list-loader.ts'
|
|
9
|
+
import { _getCustomNodeRegistry } from 'src/manager/loaders/step3_extension-node-map-loader.ts'
|
|
10
|
+
import { _getKnownModels } from 'src/manager/loaders/step4_model-list-loader.ts'
|
|
11
|
+
import type { ComfyManagerModelInfo } from 'src/manager/types/ComfyManagerModelInfo.ts'
|
|
12
|
+
import type { ComfyManagerPluginInfo } from 'src/manager/types/ComfyManagerPluginInfo.ts'
|
|
13
|
+
|
|
14
|
+
const log = (...args: unknown[]) => console.log(`[📘 registry]`, ...args)
|
|
15
|
+
|
|
16
|
+
export class ComfyRegistry {
|
|
17
|
+
// plugins, indexed
|
|
18
|
+
plugins_byTitle = new Map<KnownComfyPluginTitle, ComfyManagerPluginInfo>()
|
|
19
|
+
plugins_byFile = new Map<KnownComfyPluginURL, ComfyManagerPluginInfo>()
|
|
20
|
+
plugins_byNodeNameInComfy = new Map<NodeNameInComfy, ComfyManagerPluginInfo[]>()
|
|
21
|
+
plugins_byNodeKey = new Map<QualifiedNodeKey, ComfyManagerPluginInfo[]>()
|
|
22
|
+
|
|
23
|
+
// custom nodes
|
|
24
|
+
customNodes_byPluginName = new Map<KnownComfyPluginTitle, KnownComfyCustomNodeName[]>()
|
|
25
|
+
|
|
26
|
+
// Models
|
|
27
|
+
knownModels = new Map<KnownModel_Name, ComfyManagerModelInfo>()
|
|
28
|
+
|
|
29
|
+
static async DownloadAndUpdate(download: boolean): Promise<ComfyRegistry> {
|
|
30
|
+
if (download) {
|
|
31
|
+
log(chalk.bold(`1. Downloading comfy-manager JSONs...`))
|
|
32
|
+
await DownloadComfyManagerJSONs()
|
|
33
|
+
} else {
|
|
34
|
+
log(`1. Downloading comfy-manager JSONs... ${chalk.bold('[SKIPPED]')}`)
|
|
35
|
+
}
|
|
36
|
+
// should take care of the code generation
|
|
37
|
+
return new ComfyRegistry({
|
|
38
|
+
check: true,
|
|
39
|
+
genTypes: true,
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
constructor(
|
|
44
|
+
public opts: {
|
|
45
|
+
check?: boolean
|
|
46
|
+
genTypes?: boolean
|
|
47
|
+
} = {},
|
|
48
|
+
) {
|
|
49
|
+
this.plugins_byFile.set('https://github.com/comfyanonymous/ComfyUI' as any, {
|
|
50
|
+
id: 'nodes',
|
|
51
|
+
author: 'comfyanonymous',
|
|
52
|
+
description: 'built-in',
|
|
53
|
+
title: 'built-in' as any,
|
|
54
|
+
files: [],
|
|
55
|
+
reference: 'https://github.com/comfyanonymous/ComfyUI',
|
|
56
|
+
install_type: '',
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
log(`loading src/manager/json/${chalk.yellow('custom-node-list.json')}...`)
|
|
60
|
+
_getKnownPlugins(this)
|
|
61
|
+
|
|
62
|
+
log(`loading src/manager/json/${chalk.yellow('extension-node-map.json')}...`)
|
|
63
|
+
_getCustomNodeRegistry(this)
|
|
64
|
+
|
|
65
|
+
log(`loading src/manager/json/${chalk.yellow('model-list.json')}...`)
|
|
66
|
+
_getKnownModels(this)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
getKnownCheckpoints = (): ComfyManagerModelInfo[] => {
|
|
70
|
+
const allKnownModels = [...this.knownModels.values()]
|
|
71
|
+
const allKnownCheckpoints = allKnownModels.filter((i) => i.type === 'checkpoint')
|
|
72
|
+
// console.log(`[🤠] allKnownCheckpoints`, allKnownCheckpoints)
|
|
73
|
+
// for (const mi of knownModels.values()) {
|
|
74
|
+
// console.log(`[🧐] `, mi.type === 'checkpoint' ? '✅' : '❌', mi.name)
|
|
75
|
+
// }
|
|
76
|
+
return allKnownCheckpoints
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* try to replicate the logic of ComfyUIManager to extract the final
|
|
81
|
+
* file path of a downloaded managed model
|
|
82
|
+
*/
|
|
83
|
+
getModelInfoFinalFilePath = (mi: ComfyManagerModelInfo): string => {
|
|
84
|
+
/**
|
|
85
|
+
* the wide data-lt once told:
|
|
86
|
+
*
|
|
87
|
+
* | if save_path is 'default'
|
|
88
|
+
* | models/type'/filename
|
|
89
|
+
*
|
|
90
|
+
* | if type is "checkpoint"
|
|
91
|
+
* | models/checkpoints/filename
|
|
92
|
+
*
|
|
93
|
+
* | if save_path not starting with custom node
|
|
94
|
+
* | base path is models
|
|
95
|
+
* | e.g. save_path is "checkpoints/SD1.5"
|
|
96
|
+
* | models/checkpoints/SD1.5/filename
|
|
97
|
+
* | save_path is "custom_nodes/AAA/models"
|
|
98
|
+
* | custom_nodes/AAA/models/filename
|
|
99
|
+
*
|
|
100
|
+
*/
|
|
101
|
+
if (mi.save_path === 'default') return `models/${mi.type}/${mi.filename}`
|
|
102
|
+
if (mi.type === 'checkpoint') return `models/checkpoints/${mi.filename}`
|
|
103
|
+
if (mi.save_path.startsWith('custom_nodes')) return `${mi.save_path}/${mi.filename}`
|
|
104
|
+
else return `models/${mi.save_path}/${mi.filename}`
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
getModelInfoEnumName = (mi: ComfyManagerModelInfo, prefix: string = ''): { win: string; nix: string } => {
|
|
108
|
+
const relPath = this.getModelInfoFinalFilePath(mi)
|
|
109
|
+
|
|
110
|
+
const winPath = relPath.replace(/\//g, '\\')
|
|
111
|
+
const winPrefix = prefix?.replace(/\//g, '\\')
|
|
112
|
+
const isUnderPrefixWin = winPath.startsWith(winPrefix)
|
|
113
|
+
|
|
114
|
+
const nixPath = relPath.replace(/\\/g, '/')
|
|
115
|
+
const nixPrefix = prefix?.replace(/\//g, '\\')
|
|
116
|
+
const isUnderPrefixNix = nixPath.startsWith(nixPrefix)
|
|
117
|
+
|
|
118
|
+
const isUnderPrefix = isUnderPrefixNix || isUnderPrefixWin
|
|
119
|
+
return {
|
|
120
|
+
win: isUnderPrefix ? winPath.slice(winPrefix.length) : mi.filename /* winRel */,
|
|
121
|
+
nix: isUnderPrefix ? nixPath.slice(nixPrefix.length) : mi.filename /* nixRel */,
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|