comfy-ts 2.17.0 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/{ServeApp-BSA5yzxZ.js → ServeApp-qXcQfdgT.js} +3 -3
  2. package/dist/ServeApp-qXcQfdgT.js.map +1 -0
  3. package/dist/cli.js +58 -8
  4. package/dist/cli.js.map +1 -1
  5. package/dist/index.cjs +956 -151
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +1154 -408
  8. package/dist/index.d.ts +1154 -408
  9. package/dist/index.js +956 -151
  10. package/dist/index.js.map +1 -1
  11. package/dist/{run-run-DnaMLCFn.js → run-run-Wn7H72Zg.js} +3 -3
  12. package/dist/{run-run-DnaMLCFn.js.map → run-run-Wn7H72Zg.js.map} +1 -1
  13. package/dist/{run-serve-CbKxIu6i.js → run-serve-DaXzoVTS.js} +58 -12
  14. package/dist/run-serve-DaXzoVTS.js.map +1 -0
  15. package/dist/{run-tui-B0AQWbad.js → run-tui-VWSj1D_j.js} +3 -3
  16. package/dist/{run-tui-B0AQWbad.js.map → run-tui-VWSj1D_j.js.map} +1 -1
  17. package/dist/serve-web.js +56 -48
  18. package/dist/{state-C2oDiQ26.js → state-DgwWhZWb.js} +957 -152
  19. package/dist/state-DgwWhZWb.js.map +1 -0
  20. package/dist/web.d.ts +1172 -426
  21. package/dist/web.js +956 -151
  22. package/dist/web.js.map +1 -1
  23. package/examples/comfy-cloud/ace-step15-t2a.cflow.ts +163 -0
  24. package/examples/comfy-cloud/anima-t2i-base.cflow.ts +57 -0
  25. package/examples/comfy-cloud/boogu-t2i.cflow.ts +55 -0
  26. package/examples/comfy-cloud/chronoedit-i2i.cflow.ts +95 -0
  27. package/examples/comfy-cloud/ernie-t2i-base.cflow.ts +81 -0
  28. package/examples/comfy-cloud/flux1-t2i-krea.cflow.ts +63 -0
  29. package/examples/comfy-cloud/flux2-i2i-dev.cflow.ts +83 -0
  30. package/examples/comfy-cloud/flux2-t2i-dev.cflow.ts +60 -0
  31. package/examples/comfy-cloud/hidream-o1-i2i.cflow.ts +71 -0
  32. package/examples/comfy-cloud/hidream-o1-t2i.cflow.ts +62 -0
  33. package/examples/comfy-cloud/krea2-i2i.cflow.ts +78 -0
  34. package/examples/comfy-cloud/ltx2-i2v.cflow.ts +175 -0
  35. package/examples/comfy-cloud/ltx2-t2v.cflow.ts +143 -0
  36. package/examples/comfy-cloud/ltx23-i2v.cflow.ts +189 -0
  37. package/examples/comfy-cloud/ltx23-t2v.cflow.ts +151 -0
  38. package/examples/comfy-cloud/mage-flow-i2i-turbo.cflow.ts +72 -0
  39. package/examples/comfy-cloud/mage-flow-i2i.cflow.ts +74 -0
  40. package/examples/comfy-cloud/mage-flow-t2i-turbo.cflow.ts +60 -0
  41. package/examples/comfy-cloud/mage-flow-t2i.cflow.ts +60 -0
  42. package/examples/comfy-cloud/minimax-h3-t2i.cflow.ts +64 -0
  43. package/examples/comfy-cloud/netayume-t2i.cflow.ts +60 -0
  44. package/examples/comfy-cloud/qwen-image-i2i-2509.cflow.ts +75 -0
  45. package/examples/comfy-cloud/qwen-image-t2i-2512.cflow.ts +63 -0
  46. package/examples/comfy-cloud/sdk.d.ts +21683 -13737
  47. package/examples/comfy-cloud/stable-audio3-t2a.cflow.ts +96 -0
  48. package/examples/comfy-cloud/z-image-t2i-base.cflow.ts +54 -0
  49. package/examples/rvion/04-krea2-turbo-t2i.cflow.ts +1 -1
  50. package/package.json +2 -2
  51. package/src/cli/bunHop.ts +49 -0
  52. package/src/cli/comfy-ts-cli.ts +4 -4
  53. package/src/cli/serve/run-serve.ts +51 -13
  54. package/src/cli/serve/web/components/App.tsx +2 -0
  55. package/src/cli/serve/web/components/DialogLayer.tsx +55 -0
  56. package/src/cli/serve/web/components/DraftTabs.tsx +8 -3
  57. package/src/cli/serve/web/components/PromptEnhancer.tsx +15 -9
  58. package/src/cli/serve/web/components/SideMenu.tsx +16 -8
  59. package/src/cli/serve/web/state/WebSt.ts +10 -1
  60. package/src/cli/serve/web/state/dialog.ts +59 -0
  61. package/src/cli/serve/web/state/keptLines.ts +1 -1
  62. package/src/cli/serve/web/styles.ts +8 -0
  63. package/src/graph/ComfyNode.ts +93 -12
  64. package/src/host/ComfyHost.ts +31 -10
  65. package/src/host/ComfyManager.ts +448 -62
  66. package/src/litegraph/CanonicalWorkflow.ts +3 -0
  67. package/src/litegraph/LiteGraphJSON.ts +2 -2
  68. package/src/litegraph/LiteGraphNodeInput.ts +2 -2
  69. package/src/litegraph/LiteGraphNodeOutput.ts +2 -2
  70. package/src/litegraph/convertFlowToLiteGraphJSON.ts +127 -34
  71. package/src/litegraph/expandSubgraphs.ts +14 -0
  72. package/src/litegraph/normalizeWorkflow.ts +1 -0
  73. package/src/manager/ComfyRegistry.ts +2 -0
  74. package/src/manager/generated/KnownComfyCustomNodeName.ts +6354 -1680
  75. package/src/manager/generated/KnownComfyPluginTitle.ts +718 -356
  76. package/src/manager/generated/KnownComfyPluginURL.ts +357 -181
  77. package/src/manager/generated/KnownModel_Base.ts +9 -5
  78. package/src/manager/generated/KnownModel_FileName.ts +135 -0
  79. package/src/manager/generated/KnownModel_Name.ts +135 -0
  80. package/src/manager/generated/KnownModel_SavePath.ts +16 -14
  81. package/src/manager/generated/KnownModel_Type.ts +15 -13
  82. package/src/manager/installedView.ts +176 -0
  83. package/src/manager/json/custom-node-list.json +4018 -2248
  84. package/src/manager/json/extension-node-map.json +8903 -2964
  85. package/src/manager/json/github-stats.json +10796 -10036
  86. package/src/manager/json/model-list.json +298 -1
  87. package/src/manager/loaders/step4_model-list-loader.ts +1 -0
  88. package/src/manager/types/ComfyManagerAPIModelList.ts +3 -0
  89. package/src/manager/types/ComfyManagerAPIPluginList.ts +19 -0
  90. package/src/promptEnhancers.ts +1 -1
  91. package/src/runner/ComfyExecution.ts +4 -1
  92. package/src/runner/ComfyWsApi.ts +82 -15
  93. package/src/sdk-generator/ComfySchema.ts +10 -1
  94. package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +4 -1
  95. package/src/sdk-generator/comfyui-sdk-codegen.ts +61 -20
  96. package/src/sdk-generator/inputWidgetKind.ts +19 -4
  97. package/src/sdk-generator/litegraphToApiRequestPayload.ts +141 -33
  98. package/dist/ServeApp-BSA5yzxZ.js.map +0 -1
  99. package/dist/run-serve-CbKxIu6i.js.map +0 -1
  100. package/dist/state-C2oDiQ26.js.map +0 -1
@@ -0,0 +1,176 @@
1
+ /**
2
+ * PURE builders of the public plugin and model lists where the Manager serves none (4.x default ui),
3
+ * from our mirror and what the host reports (agent/architecture.md, Manager HTTP client).
4
+ * A row the data cannot decide is left OUT (reads `unknown`), never given a guessed status.
5
+ */
6
+ import { type } from 'arktype'
7
+ import type { KnownComfyPluginTitle } from 'src/manager/generated/KnownComfyPluginTitle.ts'
8
+ import type { ComfyManagerAPIModelList } from 'src/manager/types/ComfyManagerAPIModelList.ts'
9
+ import type { ComfyManagerAPIPluginList } from 'src/manager/types/ComfyManagerAPIPluginList.ts'
10
+ import type { ComfyManagerModelInfo } from 'src/manager/types/ComfyManagerModelInfo.ts'
11
+ import type { ComfyManagerPluginInfo } from 'src/manager/types/ComfyManagerPluginInfo.ts'
12
+
13
+ /** the part of the registry the views read */
14
+ export type ManagerMirror = {
15
+ plugins_byTitle: ReadonlyMap<KnownComfyPluginTitle, ComfyManagerPluginInfo>
16
+ /** every model row: upstream ships a few names twice, with different files */
17
+ modelRows: readonly ComfyManagerModelInfo[]
18
+ }
19
+
20
+ /** `GET customnode/installed`: a disk scan, keyed by directory */
21
+ export const InstalledPacks_ark = type.Record(
22
+ 'string',
23
+ type({ 'cnr_id?': 'string | null', 'aux_id?': 'string | null', enabled: 'boolean' }),
24
+ )
25
+ export type InstalledPacks = typeof InstalledPacks_ark.infer
26
+
27
+ /** `GET customnode/getmappings`: the extension-node-map, registered repos rekeyed by registry id */
28
+ export const PackMappings_ark = type.Record('string', type(['string[]', { 'title_aux?': 'string' }]))
29
+ export type PackMappings = typeof PackMappings_ark.infer
30
+
31
+ /** `https://github.com/Owner/Repo.git/` → `owner/repo` */
32
+ export const repoPath = (url: string): string =>
33
+ url
34
+ .toLowerCase()
35
+ .replace(/\/+$/, '')
36
+ .replace(/\.git$/, '')
37
+ .split('/')
38
+ .slice(-2)
39
+ .join('/')
40
+
41
+ /** one installed pack, joined to the mirror when the data allows it */
42
+ export type AttributedPack = { enabled: boolean; repo: string | null; title: string | null; id: string }
43
+
44
+ /** git clone → its `owner/repo`; registry install → its registry id's `title_aux` (= the mirror title) */
45
+ export const attributePacks = (installed: InstalledPacks, mappings: PackMappings): AttributedPack[] => {
46
+ // registry ids are case insensitive: the mappings keep the registry's casing, the scan lowercases
47
+ const titleById = new Map(Object.entries(mappings).map(([k, v]) => [k.toLowerCase(), v[1].title_aux]))
48
+ return Object.entries(installed).map(([dir, p]) => {
49
+ const aux = p.aux_id ?? null
50
+ const cnr = p.cnr_id != null && p.cnr_id !== '' ? p.cnr_id : null
51
+ const repo = aux != null && aux.includes('/') ? repoPath(aux) : null
52
+ const title = cnr != null ? (titleById.get(cnr.toLowerCase()) ?? null) : null
53
+ return { enabled: p.enabled, repo, title, id: cnr ?? aux ?? dir }
54
+ })
55
+ }
56
+
57
+ /** is this mirror row among the attributed packs, enabled? */
58
+ export const packIsInstalled = (
59
+ packs: AttributedPack[],
60
+ plugin: { title: string; files: string[]; reference: string },
61
+ ): boolean => {
62
+ const repo = repoPath(plugin.files[0] ?? plugin.reference)
63
+ return packs.some((p) => p.enabled && (p.repo === repo || p.title === plugin.title))
64
+ }
65
+
66
+ export const buildPluginView = (p: {
67
+ mirror: ManagerMirror
68
+ installed: InstalledPacks
69
+ mappings: PackMappings
70
+ }): { list: ComfyManagerAPIPluginList; unattributed: string[] } => {
71
+ const packs = attributePacks(p.installed, p.mappings)
72
+ const plugins = [...p.mirror.plugins_byTitle.values()]
73
+ const mirrorRepos = new Set(plugins.flatMap((x) => x.files.map(repoPath)))
74
+ const mirrorTitles = new Set<string>(plugins.map((x) => x.title))
75
+ const joins = (x: AttributedPack): boolean =>
76
+ (x.repo != null && mirrorRepos.has(x.repo)) || (x.title != null && mirrorTitles.has(x.title))
77
+ // a git clone whose repo the mirror lacks is no mirror row; an enabled pack known by no repo that joins
78
+ // nothing could be one (a disabled one reads `False` whichever row it is, like a missing one)
79
+ const unattributed = packs.filter((x) => x.enabled && x.repo == null && !joins(x))
80
+ const serverTitles = new Set(
81
+ Object.values(p.mappings).flatMap((v) => (v[1].title_aux != null ? [v[1].title_aux] : [])),
82
+ )
83
+ const custom_nodes: ComfyManagerAPIPluginList['custom_nodes'] = []
84
+ for (const plugin of plugins) {
85
+ const repo = repoPath(plugin.files[0] ?? plugin.reference)
86
+ const joined = packs.filter((x) => x.repo === repo || x.title === plugin.title)
87
+ if (joined.some((x) => x.enabled)) custom_nodes.push({ title: plugin.title, installed: 'True' })
88
+ // an unattributed registry install can only be a row the server's mappings do not name
89
+ else if (joined.length === 0 && unattributed.length > 0 && !serverTitles.has(plugin.title)) continue
90
+ else custom_nodes.push({ title: plugin.title, installed: 'False' })
91
+ }
92
+ return { list: { chanel: 'default', custom_nodes }, unattributed: unattributed.map((x) => x.id) }
93
+ }
94
+
95
+ /** the Manager's `type` → folder map for `save_path: default` (model_utils.get_model_dir, 4.4) */
96
+ const DEFAULT_FOLDER_BY_TYPE: Record<string, string> = {
97
+ checkpoints: 'checkpoints',
98
+ checkpoint: 'checkpoints',
99
+ unclip: 'checkpoints',
100
+ text_encoders: 'text_encoders',
101
+ clip: 'text_encoders',
102
+ vae: 'vae',
103
+ lora: 'loras',
104
+ 't2i-adapter': 'controlnet',
105
+ 't2i-style': 'controlnet',
106
+ controlnet: 'controlnet',
107
+ clip_vision: 'clip_vision',
108
+ gligen: 'gligen',
109
+ upscale: 'upscale_models',
110
+ embedding: 'embeddings',
111
+ embeddings: 'embeddings',
112
+ unet: 'diffusion_models',
113
+ diffusion_model: 'diffusion_models',
114
+ }
115
+
116
+ /** what core `get_filename_list` lists in the standard folders */
117
+ const LISTED_EXTENSIONS = ['.ckpt', '.pt', '.pt2', '.bin', '.pth', '.safetensors', '.pkl', '.sft']
118
+
119
+ /**
120
+ * where this model counts as installed, in core's `/models/<folder>` terms; null when not decidable.
121
+ * The Manager's own check accepts the folder root as well as the `save_path` sub folder.
122
+ */
123
+ export const modelLocation = (m: ComfyManagerModelInfo): { folder: string; files: string[] } | null => {
124
+ if (m.filename === '<huggingface>' || /[\\/:]/.test(m.filename)) return null
125
+ if (!LISTED_EXTENSIONS.some((ext) => m.filename.toLowerCase().endsWith(ext))) return null
126
+ if (m.save_path === 'default') {
127
+ const folder = DEFAULT_FOLDER_BY_TYPE[m.type.toLowerCase()]
128
+ return folder == null ? null : { folder, files: [m.filename] }
129
+ }
130
+ const parts = m.save_path
131
+ .replaceAll('\\', '/')
132
+ .split('/')
133
+ .filter((s) => s !== '')
134
+ const folder = parts[0]
135
+ if (folder == null || folder === 'custom_nodes' || parts.includes('..')) return null
136
+ const sub = [...parts.slice(1), m.filename].join('/')
137
+ return { folder, files: sub === m.filename ? [m.filename] : [m.filename, sub] }
138
+ }
139
+
140
+ export const buildModelView = (p: {
141
+ models: readonly ComfyManagerModelInfo[]
142
+ /** registered folder → its relative file paths, for the folders core lists */
143
+ files: ReadonlyMap<string, readonly string[]>
144
+ }): ComfyManagerAPIModelList => {
145
+ const listed = new Map(
146
+ [...p.files].map(([folder, files]) => [folder, new Set(files.map((f) => f.replaceAll('\\', '/')))]),
147
+ )
148
+ const statusOf = (m: ComfyManagerModelInfo): 'True' | 'False' | null => {
149
+ const at = modelLocation(m)
150
+ const files = at == null ? null : listed.get(at.folder)
151
+ if (at == null || files == null) return null
152
+ return at.files.some((f) => files.has(f)) ? 'True' : 'False'
153
+ }
154
+ const byName = new Map<string, ComfyManagerModelInfo[]>()
155
+ for (const m of p.models) byName.set(m.name, [...(byName.get(m.name) ?? []), m])
156
+ const models: ComfyManagerAPIModelList['models'] = []
157
+ for (const rows of byName.values()) {
158
+ // a name shipped twice with different files is decided only when every row agrees
159
+ const statuses = new Set(rows.map(statusOf))
160
+ const first = rows[0]
161
+ const installed = statuses.size === 1 ? [...statuses][0] : null
162
+ if (first == null || installed == null) continue
163
+ models.push({
164
+ name: first.name,
165
+ installed,
166
+ filename: first.filename,
167
+ save_path: first.save_path,
168
+ base: first.base,
169
+ })
170
+ }
171
+ return { models }
172
+ }
173
+
174
+ /** the folders the views need listed */
175
+ export const modelFolders = (models: Iterable<ComfyManagerModelInfo>): Set<string> =>
176
+ new Set([...models].flatMap((m) => modelLocation(m)?.folder ?? []))