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
package/src/vars/ComfyVars.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
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 { homedir } from 'node:os'
|
|
4
5
|
import { action, makeObservable, observable } from 'mobx'
|
|
6
|
+
import { isAbsolute, join, resolve } from 'pathe'
|
|
5
7
|
import { getLoraKeyword } from 'src/vars/loraKeywords.ts'
|
|
6
8
|
|
|
7
|
-
export type VarKind = 'text' | 'int' | 'float' | 'seed' | 'toggle' | 'choice' | 'loras' | 'size'
|
|
9
|
+
export type VarKind = 'text' | 'int' | 'float' | 'seed' | 'toggle' | 'choice' | 'loras' | 'size' | 'image'
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* full base: T is what's STORED/edited, Out what the GRAPH consumes at build
|
|
@@ -14,6 +16,8 @@ export type VarKind = 'text' | 'int' | 'float' | 'seed' | 'toggle' | 'choice' |
|
|
|
14
16
|
*/
|
|
15
17
|
export abstract class ComfyVarBase<T, Out> {
|
|
16
18
|
abstract readonly kind: VarKind
|
|
19
|
+
/** the vars-spec key, stamped by DefinedWorkflow at define time — error messages name the var with it */
|
|
20
|
+
name?: string
|
|
17
21
|
value: T
|
|
18
22
|
constructor(
|
|
19
23
|
public readonly defaultValue: T,
|
|
@@ -474,7 +478,80 @@ export class SizeVar extends ComfyVar<SizeValue> {
|
|
|
474
478
|
}
|
|
475
479
|
}
|
|
476
480
|
|
|
477
|
-
|
|
481
|
+
export type ImageVarOpts = {
|
|
482
|
+
/** where the TUI picker starts browsing AND what relative values resolve against (absPath) */
|
|
483
|
+
folder?: string
|
|
484
|
+
/** picker listing filter, lowercase without dots; never affects the value */
|
|
485
|
+
extensions?: readonly string[]
|
|
486
|
+
label?: string
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
export const DEFAULT_IMAGE_EXTENSIONS: readonly string[] = ['png', 'jpg', 'jpeg', 'webp', 'gif']
|
|
490
|
+
|
|
491
|
+
/** empty image var consumed at build time — typed so drivers surface it apart from real crashes */
|
|
492
|
+
export class ImageVarEmptyError extends Error {
|
|
493
|
+
constructor(public readonly varName: string) {
|
|
494
|
+
super(`image var '${varName}' is empty — pick a file (TUI: activate the var; script: .set('/path/to/image.png'))`)
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/** trim + expand a leading `~/` — every ImageVar write funnels through this */
|
|
499
|
+
function expandUserPath(raw: string): string {
|
|
500
|
+
const trimmed = raw.trim()
|
|
501
|
+
return trimmed.startsWith('~/') ? join(homedir(), trimmed.slice(2)) : trimmed
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* a local image path. The VALUE is a PLAIN PATH STRING — text-encodable,
|
|
506
|
+
* drafts persist it verbatim (toJSON = the string), hand-editable in the
|
|
507
|
+
* draft json. Empty = unset: outValue()/absPath() throw ImageVarEmptyError,
|
|
508
|
+
* so a build never runs on a silent placeholder. The TUI opens the image
|
|
509
|
+
* picker overlay for kind 'image'.
|
|
510
|
+
*/
|
|
511
|
+
export class ImageVar extends ComfyVar<string> {
|
|
512
|
+
readonly kind = 'image' as const
|
|
513
|
+
constructor(
|
|
514
|
+
defaultValue: string,
|
|
515
|
+
public opts: ImageVarOpts = {},
|
|
516
|
+
) {
|
|
517
|
+
super(expandUserPath(defaultValue), opts.label)
|
|
518
|
+
}
|
|
519
|
+
/** what the picker lists (lowercase, no dots) */
|
|
520
|
+
get extensions(): readonly string[] {
|
|
521
|
+
return this.opts.extensions ?? DEFAULT_IMAGE_EXTENSIONS
|
|
522
|
+
}
|
|
523
|
+
override set(value: string): this {
|
|
524
|
+
return super.set(expandUserPath(value))
|
|
525
|
+
}
|
|
526
|
+
parse(raw: string): boolean {
|
|
527
|
+
this.set(raw)
|
|
528
|
+
return true
|
|
529
|
+
}
|
|
530
|
+
isSet(): boolean {
|
|
531
|
+
return this.value !== ''
|
|
532
|
+
}
|
|
533
|
+
private emptyError(): ImageVarEmptyError {
|
|
534
|
+
return new ImageVarEmptyError(this.name ?? this.label ?? 'image')
|
|
535
|
+
}
|
|
536
|
+
/** the ONE resolution helper: absolute kept as-is, relative resolved against opts.folder, else cwd */
|
|
537
|
+
absPath(): string {
|
|
538
|
+
if (!this.isSet()) throw this.emptyError()
|
|
539
|
+
if (isAbsolute(this.value)) return this.value
|
|
540
|
+
return resolve(this.opts.folder ?? process.cwd(), this.value)
|
|
541
|
+
}
|
|
542
|
+
/** empty = unset: the build fails LOUD here (varValues calls outValue) */
|
|
543
|
+
override outValue(): string {
|
|
544
|
+
if (!this.isSet()) throw this.emptyError()
|
|
545
|
+
return this.value
|
|
546
|
+
}
|
|
547
|
+
override display(): string {
|
|
548
|
+
if (!this.isSet()) return '(unset) pick a file'
|
|
549
|
+
const home = homedir()
|
|
550
|
+
return this.value.startsWith(`${home}/`) ? `~${this.value.slice(home.length)}` : this.value
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/** the var constructors: v.text / v.prompt / v.int / v.float / v.seed / v.toggle / v.choice / v.loras / v.size / v.image */
|
|
478
555
|
export const v = {
|
|
479
556
|
text: (defaultValue: string, label?: string): TextVar => new TextVar(defaultValue, label),
|
|
480
557
|
prompt: (defaultValue: string, opts: { label?: string; loraKeywordsFrom?: ActiveLoraSource } = {}): PromptVar =>
|
|
@@ -494,6 +571,7 @@ export const v = {
|
|
|
494
571
|
): LorasVar<T> => new LorasVar(options, initial, label),
|
|
495
572
|
size: (defaultValue?: SizeValue, opts: { presets?: SizePreset[]; label?: string } = {}): SizeVar =>
|
|
496
573
|
new SizeVar(defaultValue, opts.presets, opts.label),
|
|
574
|
+
image: (defaultValue: string, opts: ImageVarOpts = {}): ImageVar => new ImageVar(defaultValue, opts),
|
|
497
575
|
}
|
|
498
576
|
|
|
499
577
|
/**
|
|
@@ -505,6 +583,8 @@ export type AnyVar = {
|
|
|
505
583
|
readonly kind: VarKind
|
|
506
584
|
readonly value: unknown
|
|
507
585
|
readonly label?: string
|
|
586
|
+
/** the vars-spec key — DefinedWorkflow writes it at define time */
|
|
587
|
+
name?: string
|
|
508
588
|
parse(raw: string): boolean
|
|
509
589
|
loadJSON(value: unknown): unknown
|
|
510
590
|
toJSON(): unknown
|
|
@@ -70,8 +70,13 @@ export class DefinedWorkflow<ID extends string = string, V extends VarsSpec = Va
|
|
|
70
70
|
// factory BoundVars describes; the regex-loras typing claim it adds is
|
|
71
71
|
// resolved from the same object_info enum via bindHost below
|
|
72
72
|
this.vars = isVarsThunk(spec.vars) ? spec.vars(v as BoundVars<ID>) : spec.vars
|
|
73
|
-
//
|
|
74
|
-
|
|
73
|
+
// define-time var wiring: the spec key becomes the var's name (error
|
|
74
|
+
// messages name the var with it), host-dependent vars (v.loras(regex))
|
|
75
|
+
// resolve their options
|
|
76
|
+
for (const [key, varDef] of this.entries()) {
|
|
77
|
+
varDef.name = key
|
|
78
|
+
varDef.bindHost?.(this.host)
|
|
79
|
+
}
|
|
75
80
|
}
|
|
76
81
|
|
|
77
82
|
/** [name, var] pairs, for drivers that enumerate the knobs */
|
package/dist/log-CdfgILde.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
//#region src/utils/log.ts
|
|
2
|
-
const isQuiet = () => process.env.COMFY_TS_QUIET === "1";
|
|
3
|
-
const logInfo = (msg) => {
|
|
4
|
-
if (!isQuiet()) console.log(msg);
|
|
5
|
-
};
|
|
6
|
-
const logError = (msg) => console.error(`[comfy-ts] 🔴 ${msg}`);
|
|
7
|
-
//#endregion
|
|
8
|
-
export { logInfo as n, logError as t };
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=log-CdfgILde.js.map
|
package/dist/log-CdfgILde.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"log-CdfgILde.js","names":[],"sources":["../src/utils/log.ts"],"sourcesContent":["// loud console logging; errors must be observable to human AND LLM.\n// COMFY_TS_QUIET=1 (set by drivers like the TUI) silences INFO chatter only —\n// errors always print.\nexport const isQuiet = (): boolean => process.env.COMFY_TS_QUIET === '1'\nexport const logInfo = (msg: string): void => {\n if (!isQuiet()) console.log(msg)\n}\nexport const logError = (msg: string): void => console.error(`[comfy-ts] 🔴 ${msg}`)\nexport const logSuccess = (msg: string): void => console.log(`[comfy-ts] 🟢 ${msg}`)\n"],"mappings":";AAGA,MAAa,gBAAyB,QAAQ,IAAI,mBAAmB;AACrE,MAAa,WAAW,QAAsB;CAC3C,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,GAAG;AAClC;AACA,MAAa,YAAY,QAAsB,QAAQ,MAAM,iBAAiB,KAAK"}
|