comfy-ts 2.11.0 → 2.13.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 +1 -0
- package/dist/{LogsSt-qtFzOKpu.js → LogsSt-CUeo843w.js} +51 -7
- package/dist/LogsSt-CUeo843w.js.map +1 -0
- package/dist/cli.js +4 -4
- package/dist/index.cjs +595 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +286 -46
- package/dist/index.d.ts +286 -46
- package/dist/index.js +591 -74
- package/dist/index.js.map +1 -1
- package/dist/{run-serve-BK7BA2dn.js → run-serve-DlRBv_Nk.js} +738 -58
- package/dist/run-serve-DlRBv_Nk.js.map +1 -0
- package/dist/{run-tui-CQyvMf0N.js → run-tui-B5uxm2_l.js} +43 -18
- package/dist/run-tui-B5uxm2_l.js.map +1 -0
- package/dist/{schemaDrift-DjjEtwfx.js → schemaDrift-E95iTF7E.js} +473 -60
- package/dist/schemaDrift-E95iTF7E.js.map +1 -0
- package/dist/serve-web.js +710 -174
- package/dist/{state--wrz0BQc.js → state-CUp2J1Zy.js} +126 -14
- package/dist/state-CUp2J1Zy.js.map +1 -0
- package/dist/web.d.ts +286 -46
- package/dist/web.js +591 -74
- package/dist/web.js.map +1 -1
- package/examples/comfy-cloud/sdk.d.ts +163 -163
- package/examples/rvion/06-qwen-image-edit.cflow.ts +3 -2
- package/examples/rvion/10-anima-t2i.cflow.ts +252 -0
- package/examples/rvion/11-yue2-t2a.cflow.ts +105 -0
- package/examples/rvion/12-stable-audio-3-t2a.cflow.ts +78 -0
- package/examples/rvion/13-ace-step-15-xl-t2a.cflow.ts +153 -0
- package/examples/rvion/stableAudio3Prompts.ts +19 -0
- package/extra/README.md +4 -0
- package/extra/comfyui-fresh-model-lists/README.md +25 -0
- package/extra/comfyui-fresh-model-lists/__init__.py +36 -0
- package/extra/comfyui-fresh-model-lists/test_fresh_model_lists.py +97 -0
- package/package.json +15 -7
- package/src/cli/draftMeta.ts +39 -0
- package/src/cli/serve/ServeApp.ts +305 -30
- package/src/cli/serve/applyVarPayload.ts +50 -22
- package/src/cli/serve/byteRange.ts +48 -0
- package/src/cli/serve/describeVar.ts +42 -6
- package/src/cli/serve/llmConfigShape.ts +51 -0
- package/src/cli/serve/llmConfigs.ts +52 -0
- package/src/cli/serve/run-serve.ts +12 -3
- package/src/cli/serve/tagList.ts +92 -0
- package/src/cli/serve/tagSource.ts +69 -0
- package/src/cli/serve/web/api.ts +72 -0
- package/src/cli/serve/web/components/App.tsx +485 -44
- package/src/cli/serve/web/components/DraftTabs.tsx +167 -0
- package/src/cli/serve/web/components/Gallery.tsx +133 -31
- package/src/cli/serve/web/components/HistoryPicker.tsx +149 -0
- package/src/cli/serve/web/components/Icon.tsx +58 -2
- package/src/cli/serve/web/components/MenuButton.tsx +53 -0
- package/src/cli/serve/web/components/Omnibox.tsx +135 -0
- package/src/cli/serve/web/components/PromptEnhancer.tsx +476 -180
- package/src/cli/serve/web/components/SideMenu.tsx +414 -0
- package/src/cli/serve/web/components/TooltipLayer.tsx +46 -0
- package/src/cli/serve/web/components/VarIcon.tsx +24 -0
- package/src/cli/serve/web/components/VarsForm.tsx +223 -351
- package/src/cli/serve/web/components/controls/BasicControls.tsx +57 -32
- package/src/cli/serve/web/components/controls/LorasControl.tsx +646 -317
- package/src/cli/serve/web/components/controls/PresetPicker.tsx +1 -1
- package/src/cli/serve/web/components/controls/PromptControl.tsx +279 -0
- package/src/cli/serve/web/components/controls/PromptEditor.tsx +113 -0
- package/src/cli/serve/web/components/controls/SeedControl.tsx +17 -10
- package/src/cli/serve/web/components/controls/SizeControl.tsx +111 -18
- package/src/cli/serve/web/components/modKey.ts +2 -0
- package/src/cli/serve/web/llm.ts +23 -12
- package/src/cli/serve/web/promptEditor/promptExtensions.ts +284 -0
- package/src/cli/serve/web/state/EnhancerSt.ts +431 -101
- package/src/cli/serve/web/state/FormSt.ts +214 -30
- package/src/cli/serve/web/state/OmniboxSt.ts +59 -0
- package/src/cli/serve/web/state/WebSt.ts +364 -80
- package/src/cli/serve/web/state/choiceButtons.ts +61 -0
- package/src/cli/serve/web/state/draftNames.ts +16 -0
- package/src/cli/serve/web/state/draftTabs.ts +75 -0
- package/src/cli/serve/web/state/generateButton.ts +16 -0
- package/src/cli/serve/web/state/history.ts +54 -0
- package/src/cli/serve/web/state/host.ts +5 -2
- package/src/cli/serve/web/state/keptLines.ts +53 -0
- package/src/cli/serve/web/state/latentMode.ts +20 -0
- package/src/cli/serve/web/state/loraSort.ts +18 -0
- package/src/cli/serve/web/state/moduleTree.ts +2 -2
- package/src/cli/serve/web/state/omnibox.ts +133 -0
- package/src/cli/serve/web/state/payload.ts +38 -58
- package/src/cli/serve/web/state/shortcuts.ts +103 -0
- package/src/cli/serve/web/state/sizeStars.ts +31 -0
- package/src/cli/serve/web/state/stableSlots.ts +21 -0
- package/src/cli/serve/web/state/varGroups.ts +24 -0
- package/src/cli/serve/web/styles.ts +653 -154
- package/src/cli/serve/webBundle.ts +54 -10
- package/src/cli/serve/workflowTags.ts +42 -0
- package/src/cli/serve/workspaceLabels.ts +23 -0
- package/src/cli/tui/components/PickerOverlays.tsx +9 -2
- package/src/cli/tui/imagePicker/ImagePickerSt.ts +1 -1
- package/src/cli/tui/state/DraftsSt.ts +28 -8
- package/src/cli/tui/state/EditorSt.ts +1 -1
- package/src/cli/tui/state/LorasSt.ts +1 -1
- package/src/cli/tui/state/PickerSt.ts +25 -7
- package/src/cli/tui/state/SettingsSt.ts +1 -1
- package/src/cli/tui/state/TuiSt.ts +10 -0
- package/src/coreExports.ts +21 -0
- package/src/host/ComfyHost.ts +17 -2
- package/src/host/ResilientWebsocket.ts +54 -4
- package/src/host/loraInfoCache.ts +6 -0
- package/src/runner/ComfyExecution.ts +60 -0
- package/src/runner/ComfyWorkflow.ts +4 -0
- package/src/runner/ComfyWsApi.ts +2 -0
- package/src/runner/MediaImage.ts +2 -2
- package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +5 -5
- package/src/sdk-generator/comfyui-sdk-codegen.ts +1 -1
- package/src/state.ts +5 -0
- package/src/utils/copyName.ts +12 -0
- package/src/vars/ComfyVars.ts +337 -67
- package/src/vars/DefinedWorkflow.ts +47 -20
- package/src/vars/lanes.ts +238 -0
- package/src/vars/loraEntry.ts +101 -0
- package/src/vars/promptSyntax.ts +382 -0
- package/dist/LogsSt-qtFzOKpu.js.map +0 -1
- package/dist/run-serve-BK7BA2dn.js.map +0 -1
- package/dist/run-tui-CQyvMf0N.js.map +0 -1
- package/dist/schemaDrift-DjjEtwfx.js.map +0 -1
- package/dist/state--wrz0BQc.js.map +0 -1
- package/src/cli/serve/web/components/Sidebar.tsx +0 -66
|
@@ -36,6 +36,30 @@ export type ComfyExecutionData = {
|
|
|
36
36
|
status?: ComfyExecutionStatus | null
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/** one audio file an output node published, downloaded as the server wrote it.
|
|
40
|
+
* `absPath` is null when saving is off: `bytes` is then the only copy */
|
|
41
|
+
export type ComfyAudioOutput = {
|
|
42
|
+
nodeId: ComfyNodeId
|
|
43
|
+
filename: string
|
|
44
|
+
mime: string
|
|
45
|
+
bytes: Uint8Array
|
|
46
|
+
absPath: AbsolutePath | null
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const AUDIO_MIMES: Record<string, string> = {
|
|
50
|
+
flac: 'audio/flac',
|
|
51
|
+
mp3: 'audio/mpeg',
|
|
52
|
+
opus: 'audio/ogg',
|
|
53
|
+
ogg: 'audio/ogg',
|
|
54
|
+
wav: 'audio/wav',
|
|
55
|
+
m4a: 'audio/mp4',
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function audioMime(filename: string): string {
|
|
59
|
+
const ext = filename.split('.').pop()?.toLowerCase() ?? ''
|
|
60
|
+
return AUDIO_MIMES[ext] ?? 'application/octet-stream'
|
|
61
|
+
}
|
|
62
|
+
|
|
39
63
|
/** one text output as an output node published it (`nodeKey` is null when the node left the snapshot) */
|
|
40
64
|
export type ComfyTextOutput = {
|
|
41
65
|
nodeId: ComfyNodeId
|
|
@@ -142,6 +166,7 @@ export class ComfyExecution {
|
|
|
142
166
|
if (!this.logProgress) return
|
|
143
167
|
const p = this.progress
|
|
144
168
|
const outputs = [`${this.images.length} image(s)`]
|
|
169
|
+
if (this.audios.length > 0) outputs.push(`${this.audios.length} audio(s)`)
|
|
145
170
|
if (this.texts.length > 0) outputs.push(`${this.texts.length} text(s)`)
|
|
146
171
|
const line = `${this.status === 'Failure' ? '🔴' : '🟢'} ${this.status.toLowerCase()} in ${(p.elapsedMs / 1000).toFixed(1)}s · ${outputs.join(' · ')}`
|
|
147
172
|
if (globalThis.process?.stdout?.isTTY) process.stdout.write(`\r\x1b[2K${line}\n`)
|
|
@@ -239,9 +264,44 @@ export class ComfyExecution {
|
|
|
239
264
|
)
|
|
240
265
|
}
|
|
241
266
|
}
|
|
267
|
+
for (const audio of msg.data.output?.audio ?? []) {
|
|
268
|
+
this.pendingPromises.push(
|
|
269
|
+
this.retrieveAudio(audio, promptNodeID).catch((e: unknown) => {
|
|
270
|
+
console.error(`🔴 failed to retrieve ${audio.filename}:`, e)
|
|
271
|
+
this.audioErrors.push({ audio, error: e })
|
|
272
|
+
}),
|
|
273
|
+
)
|
|
274
|
+
}
|
|
242
275
|
}
|
|
243
276
|
private pendingPromises: Promise<void>[] = []
|
|
244
277
|
|
|
278
|
+
/** audio retrievals that failed (their files are missing from `audios`) */
|
|
279
|
+
audioErrors: { audio: ComfyImageInfo; error: unknown }[] = []
|
|
280
|
+
|
|
281
|
+
/** audio files retrieved for this execution, in arrival order (final once `done` resolves) */
|
|
282
|
+
audios: ComfyAudioOutput[] = []
|
|
283
|
+
|
|
284
|
+
private retrieveAudio = async (info: ComfyImageInfo, promptNodeID: ComfyNodeId): Promise<void> => {
|
|
285
|
+
const response = await this.host.fetchFile('/view?' + new URLSearchParams(info).toString())
|
|
286
|
+
const bytes = new Uint8Array(await response.arrayBuffer())
|
|
287
|
+
const mime = audioMime(info.filename)
|
|
288
|
+
const sf = this.save
|
|
289
|
+
if (sf == null) {
|
|
290
|
+
this.audios.push({ nodeId: promptNodeID, filename: info.filename, mime, bytes, absPath: null })
|
|
291
|
+
return
|
|
292
|
+
}
|
|
293
|
+
const promptPrefix = this.workflow.data.apiJson?.[promptNodeID]?.inputs['filename_prefix']
|
|
294
|
+
const written = await this.encodeAndWrite({
|
|
295
|
+
bytes,
|
|
296
|
+
// never re-encoded: `save.format` is an image setting
|
|
297
|
+
sf: { ...sf, format: 'raw' },
|
|
298
|
+
filenamePrefix: typeof promptPrefix === 'string' ? promptPrefix : undefined,
|
|
299
|
+
subfolder: info.subfolder,
|
|
300
|
+
filename: info.filename,
|
|
301
|
+
})
|
|
302
|
+
this.audios.push({ nodeId: promptNodeID, filename: info.filename, mime, bytes, absPath: written.path })
|
|
303
|
+
}
|
|
304
|
+
|
|
245
305
|
/** image retrievals that failed (their images are missing from `images`);
|
|
246
306
|
* `image` is null for SaveImageWebsocket frames (no server-side file info exists) */
|
|
247
307
|
imageErrors: { image: Maybe<ComfyImageInfo>; error: unknown }[] = []
|
|
@@ -96,6 +96,10 @@ export class ComfyWorkflow<ID extends string = string> {
|
|
|
96
96
|
this.outputFolder = join(comfyts.outputPath, `workflow-${this.id}`)
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
/** a dry build: media loads name the local file by its hash and upload nothing, so a graph
|
|
100
|
+
* can be built only to be read (serve derives workflow tags this way) */
|
|
101
|
+
dry = false
|
|
102
|
+
|
|
99
103
|
/** nodes, in creation order */
|
|
100
104
|
nodes: ComfyNode[] = []
|
|
101
105
|
|
package/src/runner/ComfyWsApi.ts
CHANGED
|
@@ -64,6 +64,8 @@ const tempScope = scope({
|
|
|
64
64
|
output: {
|
|
65
65
|
'previews?': [{ filepath: 'string' }, '[]'],
|
|
66
66
|
'images?': 'ComfyImageInfo[]',
|
|
67
|
+
// SaveAudio*, PreviewAudio: same file triple as an image
|
|
68
|
+
'audio?': 'ComfyImageInfo[]',
|
|
67
69
|
// ui payload of a text output node (PreviewAny, and how TextGenerate
|
|
68
70
|
// results reach the client); entries are soft, non-strings are dropped
|
|
69
71
|
'text?': 'unknown[]',
|
package/src/runner/MediaImage.ts
CHANGED
|
@@ -118,7 +118,7 @@ export class MediaImage {
|
|
|
118
118
|
loadInWorkflow_viaLoadImageNode = async <WID extends string>(
|
|
119
119
|
workflow: ComfyWorkflow<WID>,
|
|
120
120
|
): Promise<NodeOf<WID, 'LoadImage'>> => {
|
|
121
|
-
const enumName = await this.uploadAndReturnEnumName(workflow.host)
|
|
121
|
+
const enumName = workflow.dry ? this.enumName : await this.uploadAndReturnEnumName(workflow.host)
|
|
122
122
|
const img = bang(workflow.builderBase.LoadImage, 'host has no LoadImage node')({ image: enumName })
|
|
123
123
|
// sanctioned cast: uploaded names are runtime-known; the node itself is the host's LoadImage
|
|
124
124
|
return img as NodeOf<WID, 'LoadImage'>
|
|
@@ -131,7 +131,7 @@ export class MediaImage {
|
|
|
131
131
|
/** workflow to load image as mask into */
|
|
132
132
|
workflow: ComfyWorkflow<WID>,
|
|
133
133
|
): Promise<NodeOf<WID, 'LoadImageMask'>> => {
|
|
134
|
-
const enumName = await this.uploadAndReturnEnumName(workflow.host)
|
|
134
|
+
const enumName = workflow.dry ? this.enumName : await this.uploadAndReturnEnumName(workflow.host)
|
|
135
135
|
const mask = bang(
|
|
136
136
|
workflow.builderBase.LoadImageMask,
|
|
137
137
|
'host has no LoadImageMask node',
|
|
@@ -14,16 +14,16 @@ export const ComfyUIObjectInfoScope = scope({
|
|
|
14
14
|
'hidden?': 'string[]',
|
|
15
15
|
},
|
|
16
16
|
output: 'ComfyInputType[]',
|
|
17
|
-
output_is_list: 'boolean[]',
|
|
17
|
+
output_is_list: '(boolean | null)[]',
|
|
18
18
|
output_name: 'string[]',
|
|
19
19
|
name: 'string',
|
|
20
|
-
display_name: 'string',
|
|
20
|
+
display_name: 'string | null',
|
|
21
21
|
description: 'string',
|
|
22
22
|
/** */
|
|
23
23
|
python_module: 'string',
|
|
24
24
|
category: 'string',
|
|
25
25
|
output_node: 'boolean',
|
|
26
|
-
'output_tooltips?': 'string[]',
|
|
26
|
+
'output_tooltips?': '(string | null)[]',
|
|
27
27
|
// Stability Flags
|
|
28
28
|
'deprecated?': 'boolean',
|
|
29
29
|
'experimental?': 'boolean',
|
|
@@ -47,8 +47,8 @@ export const ComfyUIObjectInfoScope = scope({
|
|
|
47
47
|
'tooltip?': 'string | null | ComfyInputOpts_advanced',
|
|
48
48
|
'multiline?': 'boolean | null',
|
|
49
49
|
|
|
50
|
-
//
|
|
51
|
-
'default?': 'boolean | number | string | null | number[]',
|
|
50
|
+
// number[] and object: widget defaults like a size pair, a curve, a trim window
|
|
51
|
+
'default?': 'boolean | number | string | null | number[] | object',
|
|
52
52
|
|
|
53
53
|
'forceInput?': 'boolean | null',
|
|
54
54
|
'min?': 'number | null',
|
|
@@ -211,7 +211,7 @@ export function codegenSDK(this: ComfySchema, opts: CodegenOptions): string {
|
|
|
211
211
|
// #region Builder ----------------------------------------------------------------------------
|
|
212
212
|
p(`interface Builder {`)
|
|
213
213
|
for (const n of nodes) {
|
|
214
|
-
const baseDescription = `displayName="${n.raw.display_name}" category="${n.category}" name="${n.nameInComfy}" output=[${n.outputs.map((o) => o.outKey).join(', ')}]`
|
|
214
|
+
const baseDescription = `displayName="${n.raw.display_name ?? n.nameInComfy}" category="${n.category}" name="${n.nameInComfy}" output=[${n.outputs.map((o) => o.outKey).join(', ')}]`
|
|
215
215
|
if (n.raw.description) {
|
|
216
216
|
p(` /**`)
|
|
217
217
|
p(
|
package/src/state.ts
CHANGED
|
@@ -110,6 +110,11 @@ export class ComfyTS {
|
|
|
110
110
|
return asAbsolutePath(join(this.baseFolder, 'prompt-enhancers', relativePath))
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
/** the serve web ui's LLM configs (prompt enhancer), one json per config */
|
|
114
|
+
resolveFromLlmConfigs(relativePath: string): AbsolutePath {
|
|
115
|
+
return asAbsolutePath(join(this.baseFolder, 'llm-configs', relativePath))
|
|
116
|
+
}
|
|
117
|
+
|
|
113
118
|
resolveFromCache(relativePath: string): AbsolutePath {
|
|
114
119
|
return asAbsolutePath(join(this.baseFolder, 'cache', relativePath))
|
|
115
120
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** the default name of a duplicate: a trailing number is incremented (`shot 007` → `shot 008`,
|
|
2
|
+
* zero padding kept), anything else gets `-2`. Never returns a name in `taken` */
|
|
3
|
+
export function copyName(name: string, taken: readonly string[]): string {
|
|
4
|
+
const m = /^(.*?)(\d+)$/.exec(name)
|
|
5
|
+
if (m == null) return copyName(`${name}-1`, taken)
|
|
6
|
+
const prefix = m[1] ?? ''
|
|
7
|
+
const digits = m[2] ?? ''
|
|
8
|
+
for (let n = Number(digits) + 1; ; n++) {
|
|
9
|
+
const candidate = `${prefix}${String(n).padStart(digits.length, '0')}`
|
|
10
|
+
if (!taken.includes(candidate)) return candidate
|
|
11
|
+
}
|
|
12
|
+
}
|