comfy-ts 1.1.0 → 1.3.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 +61 -8
- package/dist/{DefinedWorkflow-BYyu5dK9.js → DefinedWorkflow-gpknV-5f.js} +52 -35
- package/dist/DefinedWorkflow-gpknV-5f.js.map +1 -0
- package/dist/DraftsSt-DmA0jWGl.js +434 -0
- package/dist/DraftsSt-DmA0jWGl.js.map +1 -0
- package/dist/cli.js +17 -4555
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +184 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -23
- package/dist/index.d.ts +36 -5
- package/dist/index.js +184 -32
- package/dist/index.js.map +1 -1
- package/dist/run-serve-Bn6yIJB0.js +638 -0
- package/dist/run-serve-Bn6yIJB0.js.map +1 -0
- package/dist/{run-tui-DZ22HDHI.js → run-tui-BtjaOXRh.js} +791 -395
- package/dist/run-tui-BtjaOXRh.js.map +1 -0
- package/dist/state-DKCPy105.js +4690 -0
- package/dist/state-DKCPy105.js.map +1 -0
- package/examples/README.md +6 -4
- 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} +1 -1
- 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/{05-comfy-cloud.cflow.ts → rvion/05-comfy-cloud.cflow.ts} +2 -2
- package/examples/rvion/06-qwen-image-edit.cflow.ts +89 -0
- package/package.json +6 -2
- package/src/cli/comfy-ts-cli.ts +15 -5
- package/src/cli/serve/ServeApp.ts +378 -0
- package/src/cli/serve/applyVarPayload.ts +119 -0
- package/src/cli/serve/describeVar.ts +74 -0
- package/src/cli/serve/run-serve.ts +169 -0
- 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/StatusBar.tsx +29 -9
- package/src/cli/tui/components/TreePanel.tsx +33 -9
- package/src/cli/tui/components/TuiApp.tsx +54 -7
- package/src/cli/tui/components/VarsPanel.tsx +67 -34
- package/src/cli/tui/imageClipboard.ts +39 -0
- package/src/cli/tui/imagePicker/fsListing.ts +6 -4
- package/src/cli/tui/listWindow.ts +36 -0
- package/src/cli/tui/run-tui.tsx +47 -7
- package/src/cli/tui/state/DraftsSt.ts +3 -2
- package/src/cli/tui/state/ExecSt.ts +156 -12
- package/src/cli/tui/state/HostSt.ts +94 -10
- package/src/cli/tui/state/PickerSt.ts +8 -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 +164 -36
- package/src/cli/tui/state/TuiSt.ts +81 -6
- package/src/cli/tui/state/WorkflowsSt.ts +14 -2
- package/src/cli/tui/treeRows.ts +165 -0
- package/src/host/ComfyHost.ts +7 -0
- package/src/litegraph/convertFlowToLiteGraphJSON.ts +11 -7
- package/src/runner/ComfyExecution.ts +21 -4
- package/src/runner/ComfyWorkflowLayout.ts +6 -4
- package/src/runner/outputPath.ts +75 -0
- package/src/sdk-generator/inputWidgetKind.ts +50 -11
- package/src/sdk-generator/litegraphToApiRequestPayload.ts +14 -7
- package/src/state.ts +7 -1
- package/src/vars/ComfyVars.ts +33 -4
- package/src/vars/DefinedWorkflow.ts +21 -8
- package/dist/DefinedWorkflow-BYyu5dK9.js.map +0 -1
- package/dist/run-tui-DZ22HDHI.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@ node_https = __toESM(node_https, 1);
|
|
|
40
40
|
let node_process = require("node:process");
|
|
41
41
|
let node_url = require("node:url");
|
|
42
42
|
//#region package.json
|
|
43
|
-
var version = "1.
|
|
43
|
+
var version = "1.3.0";
|
|
44
44
|
//#endregion
|
|
45
45
|
//#region src/litegraph/LiteGraphLinkID.ts
|
|
46
46
|
const asLiteGraphLinkID = (id) => id;
|
|
@@ -754,6 +754,25 @@ const containerInstanceSlotType = (opts) => {
|
|
|
754
754
|
if (subs.length !== 1 || first == null || typeof first.type !== "string") return null;
|
|
755
755
|
return first.type;
|
|
756
756
|
};
|
|
757
|
+
/**
|
|
758
|
+
* frontend-registered widgets whose object_info opts carry NO config signal —
|
|
759
|
+
* the one exception to config-only classification (architecture.md rule 8).
|
|
760
|
+
* Every entry must quote the frontend widget-creation source.
|
|
761
|
+
*
|
|
762
|
+
* LOAD_3D (ComfyUI_frontend src/extensions/core/load3d.ts, verified
|
|
763
|
+
* 2026-07-31): the LOAD_3D custom widget handler runs
|
|
764
|
+
* node.addWidget('button', 'upload 3d model', 'upload3dmodel', …)
|
|
765
|
+
* node.addWidget('button', 'upload extra resources', 'uploadExtraResources', …)
|
|
766
|
+
* node.addWidget('button', 'clear', 'clear', …)
|
|
767
|
+
* THEN creates the scene widget, so the serialized run is
|
|
768
|
+
* [btn, btn, btn, value] with the real value LAST. Lax domain: '' in saved
|
|
769
|
+
* files, an {image, mask, normal, camera_info, …} dict at queue time.
|
|
770
|
+
*/
|
|
771
|
+
const EMPTY_CONFIG_FRONTEND_WIDGETS = { LOAD_3D: { prefixValues: [
|
|
772
|
+
"upload3dmodel",
|
|
773
|
+
"uploadExtraResources",
|
|
774
|
+
"clear"
|
|
775
|
+
] } };
|
|
757
776
|
const classifyWidgetInput = (p) => {
|
|
758
777
|
const o = isRecord(p.opts) ? p.opts : null;
|
|
759
778
|
if (o?.["forceInput"] === true) return { kind: "slot" };
|
|
@@ -762,7 +781,8 @@ const classifyWidgetInput = (p) => {
|
|
|
762
781
|
return {
|
|
763
782
|
kind: "widget",
|
|
764
783
|
consumes: controlConsumes(o, tn, p.name),
|
|
765
|
-
strictValues: true
|
|
784
|
+
strictValues: true,
|
|
785
|
+
prefixValues: []
|
|
766
786
|
};
|
|
767
787
|
}
|
|
768
788
|
if (typeof p.type !== "string") return { kind: "slot" };
|
|
@@ -770,7 +790,8 @@ const classifyWidgetInput = (p) => {
|
|
|
770
790
|
if (ComfyPrimitiveMapping[widgetTypeName] != null) return {
|
|
771
791
|
kind: "widget",
|
|
772
792
|
consumes: controlConsumes(o, widgetTypeName, p.name),
|
|
773
|
-
strictValues: true
|
|
793
|
+
strictValues: true,
|
|
794
|
+
prefixValues: []
|
|
774
795
|
};
|
|
775
796
|
const options = o?.["options"];
|
|
776
797
|
if (Array.isArray(options)) {
|
|
@@ -787,7 +808,8 @@ const classifyWidgetInput = (p) => {
|
|
|
787
808
|
return {
|
|
788
809
|
kind: "widget",
|
|
789
810
|
consumes: controlConsumes(o, p.type, p.name),
|
|
790
|
-
strictValues: true
|
|
811
|
+
strictValues: true,
|
|
812
|
+
prefixValues: []
|
|
791
813
|
};
|
|
792
814
|
}
|
|
793
815
|
const template = o?.["template"];
|
|
@@ -798,7 +820,15 @@ const classifyWidgetInput = (p) => {
|
|
|
798
820
|
if (o?.["socketless"] === true) return {
|
|
799
821
|
kind: "widget",
|
|
800
822
|
consumes: 1,
|
|
801
|
-
strictValues: false
|
|
823
|
+
strictValues: false,
|
|
824
|
+
prefixValues: []
|
|
825
|
+
};
|
|
826
|
+
const emptyConfigEntry = EMPTY_CONFIG_FRONTEND_WIDGETS[widgetTypeName];
|
|
827
|
+
if (emptyConfigEntry != null) return {
|
|
828
|
+
kind: "widget",
|
|
829
|
+
consumes: emptyConfigEntry.prefixValues.length + 1,
|
|
830
|
+
strictValues: false,
|
|
831
|
+
prefixValues: emptyConfigEntry.prefixValues
|
|
802
832
|
};
|
|
803
833
|
return { kind: "slot" };
|
|
804
834
|
};
|
|
@@ -808,11 +838,6 @@ const classifySchemaInput = (input) => classifyWidgetInput({
|
|
|
808
838
|
opts: input.opts,
|
|
809
839
|
isEnumUnion: input.isEnum
|
|
810
840
|
});
|
|
811
|
-
/** how many widgets_values entries this schema input consumes (export path + positional walks) */
|
|
812
|
-
const howManyWidgetValuesForThisSchemaType = (input) => {
|
|
813
|
-
const kind = classifySchemaInput(input);
|
|
814
|
-
return kind.kind === "widget" ? kind.consumes : 0;
|
|
815
|
-
};
|
|
816
841
|
/**
|
|
817
842
|
* what ComfyUI's frontend gives a widget created with no serialized value
|
|
818
843
|
* (`getWidgetDefaultValue` semantics), used when a positional array is
|
|
@@ -914,15 +939,15 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
|
|
|
914
939
|
if (!p.strict && isRecord(value)) return value;
|
|
915
940
|
throw new WorkflowConvertError("invalid-widget-value", `node ${node.id}(${node.type}) has an invalid widget value for "${p.promptName}": ${JSON.stringify(value)}`, node);
|
|
916
941
|
};
|
|
917
|
-
/** named wins, then positional cursor; filled=true when both miss (caller falls back to the schema default) */
|
|
942
|
+
/** named wins, then positional cursor (+prefixLen skips leading button values, LOAD_3D); filled=true when both miss (caller falls back to the schema default) */
|
|
918
943
|
const resolveWidgetValue = (p) => {
|
|
919
944
|
let value;
|
|
920
945
|
let has = false;
|
|
921
946
|
if (Object.hasOwn(named, p.promptName)) {
|
|
922
947
|
value = named[p.promptName];
|
|
923
948
|
has = true;
|
|
924
|
-
} else if (offset < positional.length) {
|
|
925
|
-
value = positional[offset];
|
|
949
|
+
} else if (offset + p.prefixLen < positional.length) {
|
|
950
|
+
value = positional[offset + p.prefixLen];
|
|
926
951
|
has = true;
|
|
927
952
|
}
|
|
928
953
|
if (positional.length > 0) offset += p.consumes;
|
|
@@ -934,7 +959,8 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
|
|
|
934
959
|
const consumePlainWidget = (p) => {
|
|
935
960
|
const r = resolveWidgetValue({
|
|
936
961
|
promptName: p.promptName,
|
|
937
|
-
consumes: p.consumes
|
|
962
|
+
consumes: p.consumes,
|
|
963
|
+
prefixLen: p.prefixLen
|
|
938
964
|
});
|
|
939
965
|
const raw = r.filled ? defaultValueForWidget({
|
|
940
966
|
type: p.typeName,
|
|
@@ -953,7 +979,8 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
|
|
|
953
979
|
const consumeDynamicCombo = (p) => {
|
|
954
980
|
const r = resolveWidgetValue({
|
|
955
981
|
promptName: p.path,
|
|
956
|
-
consumes: 1
|
|
982
|
+
consumes: 1,
|
|
983
|
+
prefixLen: 0
|
|
957
984
|
});
|
|
958
985
|
const key = r.filled ? p.defaultKey : r.value;
|
|
959
986
|
if (typeof key !== "string") throw new WorkflowConvertError("invalid-widget-value", `node ${node.id}(${node.type}): dynamic combo "${p.path}" key is not a string: ${JSON.stringify(key)}`, node);
|
|
@@ -981,6 +1008,7 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
|
|
|
981
1008
|
typeName: typeof sub.type === "string" ? sub.type : "COMBO",
|
|
982
1009
|
opts: sub.opts,
|
|
983
1010
|
consumes: kind.consumes,
|
|
1011
|
+
prefixLen: kind.prefixValues.length,
|
|
984
1012
|
strict: kind.strictValues,
|
|
985
1013
|
enumValues: inlineEnum,
|
|
986
1014
|
linkedInput: inputsInNodeJSON.find((i) => i.name === subPath)
|
|
@@ -992,13 +1020,15 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
|
|
|
992
1020
|
if (kind.kind === "slot" && input?.widgetName != null) kind = {
|
|
993
1021
|
kind: "widget",
|
|
994
1022
|
consumes: howManyWidgetValuesForThisInputType(input.type, field.nameInComfy) === 2 ? 2 : 1,
|
|
995
|
-
strictValues: true
|
|
1023
|
+
strictValues: true,
|
|
1024
|
+
prefixValues: []
|
|
996
1025
|
};
|
|
997
1026
|
if (kind.kind === "widget") consumePlainWidget({
|
|
998
1027
|
promptName: field.nameInComfy,
|
|
999
1028
|
typeName: field.typeName,
|
|
1000
1029
|
opts: field.opts,
|
|
1001
1030
|
consumes: kind.consumes,
|
|
1031
|
+
prefixLen: kind.prefixValues.length,
|
|
1002
1032
|
strict: kind.strictValues,
|
|
1003
1033
|
linkedInput: input
|
|
1004
1034
|
});
|
|
@@ -1498,7 +1528,7 @@ const convertNodeToLiteGraphNode = (ctx, node) => {
|
|
|
1498
1528
|
const widgets_values = [];
|
|
1499
1529
|
for (const ipt of node.$schema.inputs) {
|
|
1500
1530
|
const raw = node.serializeValue(ipt.nameInComfy, node.json.inputs[ipt.nameInComfy]);
|
|
1501
|
-
const
|
|
1531
|
+
const kind = classifySchemaInput(ipt);
|
|
1502
1532
|
if (_isLink(raw)) {
|
|
1503
1533
|
const nodeUidNumber = bang(ctx.graph.nodes.find((n) => n.uid === raw[0])?.uidNumber, `link target node "${raw[0]}" not found in graph`);
|
|
1504
1534
|
inputs.push({
|
|
@@ -1506,9 +1536,10 @@ const convertNodeToLiteGraphNode = (ctx, node) => {
|
|
|
1506
1536
|
type: ipt.typeName,
|
|
1507
1537
|
link: ctx.allocateLink(nodeUidNumber, raw[1], node.uidNumber, asLiteGraphSlotIndex(inputs.length), ipt.typeName)
|
|
1508
1538
|
});
|
|
1509
|
-
} else if (
|
|
1510
|
-
widgets_values.push(raw);
|
|
1511
|
-
|
|
1539
|
+
} else if (kind.kind === "widget") {
|
|
1540
|
+
widgets_values.push(...kind.prefixValues, raw);
|
|
1541
|
+
const phantoms = kind.consumes - 1 - kind.prefixValues.length;
|
|
1542
|
+
for (let i = 0; i < phantoms; i++) widgets_values.push(false);
|
|
1512
1543
|
} else inputs.push({
|
|
1513
1544
|
name: ipt.nameInComfy,
|
|
1514
1545
|
type: ipt.typeName,
|
|
@@ -1554,6 +1585,65 @@ var LiteGraphCtx = class {
|
|
|
1554
1585
|
}
|
|
1555
1586
|
};
|
|
1556
1587
|
//#endregion
|
|
1588
|
+
//#region src/runner/outputPath.ts
|
|
1589
|
+
/**
|
|
1590
|
+
* local output naming, relative to `.comfy-ts/outputs/` (his repro
|
|
1591
|
+
* 2026-07-31): the server filename is NOT unique — cloud hosts reset the
|
|
1592
|
+
* `_00001_` counter every run, so trusting it overwrote the same file — and
|
|
1593
|
+
* a `foo/krea/` prefix means the DIRECTORY foo/krea/, not a `krea_` name
|
|
1594
|
+
* prefix. Local names are ours: dir from the prompt's own filename_prefix
|
|
1595
|
+
* (or an explicit saveFormat.prefix override), then
|
|
1596
|
+
* `<stem>_<timestamp>_<counter><ext>` so every run sorts chronologically
|
|
1597
|
+
* per stem and nothing ever collides.
|
|
1598
|
+
*/
|
|
1599
|
+
const localOutputPath = (p) => {
|
|
1600
|
+
const dot = p.filename.lastIndexOf(".");
|
|
1601
|
+
const ext = dot === -1 ? "" : p.filename.slice(dot);
|
|
1602
|
+
const base = dot === -1 ? p.filename : p.filename.slice(0, dot);
|
|
1603
|
+
const counterMatch = /_(\d+)_$/.exec(base);
|
|
1604
|
+
const counter = counterMatch?.[1];
|
|
1605
|
+
const serverStem = counterMatch != null ? base.slice(0, base.length - counterMatch[0].length) : base;
|
|
1606
|
+
let dir;
|
|
1607
|
+
let stem;
|
|
1608
|
+
if (p.filenamePrefix != null && p.filenamePrefix !== "") {
|
|
1609
|
+
const slash = p.filenamePrefix.lastIndexOf("/");
|
|
1610
|
+
dir = slash === -1 ? "" : p.filenamePrefix.slice(0, slash);
|
|
1611
|
+
stem = slash === -1 ? p.filenamePrefix : p.filenamePrefix.slice(slash + 1);
|
|
1612
|
+
} else {
|
|
1613
|
+
dir = p.subfolder;
|
|
1614
|
+
stem = serverStem;
|
|
1615
|
+
}
|
|
1616
|
+
if (p.localDir != null) dir = p.localDir;
|
|
1617
|
+
const name = [
|
|
1618
|
+
stem === "" ? null : stem,
|
|
1619
|
+
p.timestamp,
|
|
1620
|
+
counter
|
|
1621
|
+
].filter((x) => x != null).join("_") + ext;
|
|
1622
|
+
return dir === "" ? name : `${dir}/${name}`;
|
|
1623
|
+
};
|
|
1624
|
+
/**
|
|
1625
|
+
* never-overwrite guard: bump `-2`, `-3`, … while the path exists on disk OR
|
|
1626
|
+
* was already CLAIMED by a still-downloading retrieval (two same-second runs
|
|
1627
|
+
* on a counter-resetting cloud host compute the same name — reviewer catch).
|
|
1628
|
+
* The chosen path is claimed before returning.
|
|
1629
|
+
*/
|
|
1630
|
+
const uniquifyOutputPath = (p) => {
|
|
1631
|
+
let out = p.path;
|
|
1632
|
+
if (p.exists(out) || p.claimed.has(out)) {
|
|
1633
|
+
const dot = out.lastIndexOf(".");
|
|
1634
|
+
const stem = dot === -1 ? out : out.slice(0, dot);
|
|
1635
|
+
const ext = dot === -1 ? "" : out.slice(dot);
|
|
1636
|
+
for (let n = 2; p.exists(out) || p.claimed.has(out); n++) out = `${stem}-${n}${ext}`;
|
|
1637
|
+
}
|
|
1638
|
+
p.claimed.add(out);
|
|
1639
|
+
return out;
|
|
1640
|
+
};
|
|
1641
|
+
/** YYYYMMDD-HHmmss, local time — sortable, text-encodable, no colons for filesystems */
|
|
1642
|
+
const runTimestamp = (d) => {
|
|
1643
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
1644
|
+
return `${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}-${pad(d.getHours())}${pad(d.getMinutes())}${pad(d.getSeconds())}`;
|
|
1645
|
+
};
|
|
1646
|
+
//#endregion
|
|
1557
1647
|
//#region src/types/index.ts
|
|
1558
1648
|
const asAbsolutePath = (path) => path;
|
|
1559
1649
|
const asRelativePath = (path) => path;
|
|
@@ -1902,6 +1992,9 @@ var MediaImage = class MediaImage {
|
|
|
1902
1992
|
};
|
|
1903
1993
|
//#endregion
|
|
1904
1994
|
//#region src/runner/ComfyExecution.ts
|
|
1995
|
+
/** paths claimed by in-flight retrievals: two same-second runs on a
|
|
1996
|
+
* counter-resetting cloud host compute the same name before either writes */
|
|
1997
|
+
const CLAIMED_OUTPUT_PATHS = /* @__PURE__ */ new Set();
|
|
1905
1998
|
var ComfyExecution = class {
|
|
1906
1999
|
get host() {
|
|
1907
2000
|
return this.workflow.host;
|
|
@@ -1967,11 +2060,23 @@ var ComfyExecution = class {
|
|
|
1967
2060
|
if (promptNode == null) throw new Error(`❌ invariant violation: promptNode is null`);
|
|
1968
2061
|
const imgRoute = "/view?" + new URLSearchParams(comfyImageInfo).toString();
|
|
1969
2062
|
const sf = this.saveFormat;
|
|
1970
|
-
|
|
2063
|
+
const promptPrefix = promptNode.inputs["filename_prefix"];
|
|
2064
|
+
let absPath = comfyts.resolveFromOutput(localOutputPath({
|
|
2065
|
+
localDir: sf?.prefix,
|
|
2066
|
+
filenamePrefix: typeof promptPrefix === "string" ? promptPrefix : void 0,
|
|
2067
|
+
subfolder: comfyImageInfo.subfolder,
|
|
2068
|
+
filename: comfyImageInfo.filename,
|
|
2069
|
+
timestamp: runTimestamp(new Date(this.startedAt))
|
|
2070
|
+
}));
|
|
1971
2071
|
if (sf?.format && sf.format !== "raw") {
|
|
1972
2072
|
const extension = sf.format.split("/")[1];
|
|
1973
2073
|
absPath += "." + extension;
|
|
1974
2074
|
}
|
|
2075
|
+
absPath = uniquifyOutputPath({
|
|
2076
|
+
path: absPath,
|
|
2077
|
+
exists: node_fs.existsSync,
|
|
2078
|
+
claimed: CLAIMED_OUTPUT_PATHS
|
|
2079
|
+
});
|
|
1975
2080
|
(0, node_fs.mkdirSync)((0, pathe.dirname)(absPath), { recursive: true });
|
|
1976
2081
|
let img;
|
|
1977
2082
|
if (sf && sf.format !== "raw") {
|
|
@@ -2214,8 +2319,8 @@ function comfyWorkflowAutoLayout(p) {
|
|
|
2214
2319
|
if (cols[at]) cols[at].push(node);
|
|
2215
2320
|
else cols[at] = [node];
|
|
2216
2321
|
}
|
|
2217
|
-
const HSEP = p?.node_hsep ??
|
|
2218
|
-
const VSEP = p?.node_vsep ??
|
|
2322
|
+
const HSEP = p?.node_hsep ?? 100;
|
|
2323
|
+
const VSEP = p?.node_vsep ?? 40;
|
|
2219
2324
|
let colX = 0;
|
|
2220
2325
|
let maxY = 0;
|
|
2221
2326
|
for (const col of cols) {
|
|
@@ -3725,6 +3830,12 @@ var SeedVar = class extends ComfyVar {
|
|
|
3725
3830
|
afterRun() {
|
|
3726
3831
|
this.advance();
|
|
3727
3832
|
}
|
|
3833
|
+
/** mode is part of the seed's state: a reset must not keep a caller's `?`/`+` alive
|
|
3834
|
+
* ('=' is the construction default; drafts restore their own mode via loadJSON) */
|
|
3835
|
+
reset() {
|
|
3836
|
+
this.setMode("=");
|
|
3837
|
+
return super.reset();
|
|
3838
|
+
}
|
|
3728
3839
|
/** parse `+` `- 12` `= 5` `?` or a bare number (=> fixed). Keeps the current number when none given */
|
|
3729
3840
|
parse(raw) {
|
|
3730
3841
|
const m = raw.trim().match(/^([+\-=?])?\s*(\d+)?$/);
|
|
@@ -3946,16 +4057,38 @@ const DEFAULT_SIZE_PRESETS = [
|
|
|
3946
4057
|
height: 1344
|
|
3947
4058
|
}
|
|
3948
4059
|
];
|
|
3949
|
-
/** width/height picker: presets + free `WxH` entry
|
|
4060
|
+
/** width/height picker: presets + free `WxH` entry + optionally the LIVE
|
|
4061
|
+
* size of a linked image var (his ask 2026-07-30: the widget shows
|
|
4062
|
+
* `WxH size of image '<name>'` as a pickable row) */
|
|
3950
4063
|
var SizeVar = class extends ComfyVar {
|
|
3951
4064
|
constructor(defaultValue = {
|
|
3952
4065
|
width: 1024,
|
|
3953
4066
|
height: 1024
|
|
3954
|
-
}, presets = DEFAULT_SIZE_PRESETS, label) {
|
|
4067
|
+
}, presets = DEFAULT_SIZE_PRESETS, label, imageVar) {
|
|
3955
4068
|
super(defaultValue, label);
|
|
3956
4069
|
this.presets = presets;
|
|
4070
|
+
this.imageVar = imageVar;
|
|
3957
4071
|
this.kind = "size";
|
|
3958
4072
|
}
|
|
4073
|
+
/** current dimensions of the linked image var — null when no link, unset
|
|
4074
|
+
* path, or an unreadable/undecodable file (those errors belong to the
|
|
4075
|
+
* image var itself, the size row simply disappears) */
|
|
4076
|
+
imageSize() {
|
|
4077
|
+
const iv = this.imageVar;
|
|
4078
|
+
if (iv == null || iv.value === "") return null;
|
|
4079
|
+
try {
|
|
4080
|
+
const abs = iv.absPath();
|
|
4081
|
+
const meta = (0, image_meta.imageMeta)(new Uint8Array((0, node_fs.readFileSync)(abs)));
|
|
4082
|
+
if (meta.width == null || meta.height == null) return null;
|
|
4083
|
+
return {
|
|
4084
|
+
width: meta.width,
|
|
4085
|
+
height: meta.height,
|
|
4086
|
+
name: (0, pathe.basename)(abs)
|
|
4087
|
+
};
|
|
4088
|
+
} catch {
|
|
4089
|
+
return null;
|
|
4090
|
+
}
|
|
4091
|
+
}
|
|
3959
4092
|
/** accepts '1024x768' / '1024×768' / a preset label */
|
|
3960
4093
|
parse(raw) {
|
|
3961
4094
|
const m = raw.trim().match(/^(\d+)\s*[x×]\s*(\d+)$/);
|
|
@@ -4058,7 +4191,7 @@ const v = {
|
|
|
4058
4191
|
toggle: (defaultValue, label) => new ToggleVar(defaultValue, label),
|
|
4059
4192
|
choice: (choices, defaultValue, label) => new ChoiceVar(choices, defaultValue, label),
|
|
4060
4193
|
loras: (options, initial = {}, label) => new LorasVar(options, initial, label),
|
|
4061
|
-
size: (defaultValue, opts = {}) => new SizeVar(defaultValue, opts.presets, opts.label),
|
|
4194
|
+
size: (defaultValue, opts = {}) => new SizeVar(defaultValue, opts.presets, opts.label, opts.image),
|
|
4062
4195
|
image: (defaultValue, opts = {}) => new ImageVar(defaultValue, opts)
|
|
4063
4196
|
};
|
|
4064
4197
|
function varValues(vars) {
|
|
@@ -4097,10 +4230,12 @@ var DefinedWorkflow = class {
|
|
|
4097
4230
|
* (set by run()) fires each var's afterRun() right after snapshotting the
|
|
4098
4231
|
* values — atomically, before any await — so the graph uses this run's seed
|
|
4099
4232
|
* while the var moves to the next (queued runs get distinct seeds; a bare
|
|
4100
|
-
* build() for copy/export never advances).
|
|
4233
|
+
* build() for copy/export never advances). `p.host` substitutes the host
|
|
4234
|
+
* the graph is built against (TUI host override): node/model availability
|
|
4235
|
+
* there surfaces as workflow.problems / server validation, by design.
|
|
4101
4236
|
*/
|
|
4102
4237
|
async build(p = {}) {
|
|
4103
|
-
const wf = this.host.workflow({ id: this.spec.id });
|
|
4238
|
+
const wf = (p.host ?? this.host).workflow({ id: this.spec.id });
|
|
4104
4239
|
const values = varValues(this.vars);
|
|
4105
4240
|
if (p.advance) for (const varDef of Object.values(this.vars)) varDef.afterRun();
|
|
4106
4241
|
await this.spec.build(wf.builder, values, wf);
|
|
@@ -4108,10 +4243,20 @@ var DefinedWorkflow = class {
|
|
|
4108
4243
|
return wf;
|
|
4109
4244
|
}
|
|
4110
4245
|
/** build a fresh graph from the current var values, send it, wait for outputs.
|
|
4111
|
-
* connects first (idempotent) — modules can import offline from the schema cache
|
|
4246
|
+
* connects first (idempotent) — modules can import offline from the schema cache.
|
|
4247
|
+
* `settings.host` runs against THAT host instead of the defining one. */
|
|
4112
4248
|
async run(settings = {}) {
|
|
4113
|
-
|
|
4114
|
-
|
|
4249
|
+
const host = settings.host ?? this.host;
|
|
4250
|
+
await host.connect();
|
|
4251
|
+
const execution = await (await this.build({
|
|
4252
|
+
advance: true,
|
|
4253
|
+
host
|
|
4254
|
+
})).run({
|
|
4255
|
+
saveFormat: settings.saveFormat,
|
|
4256
|
+
idMode: settings.idMode,
|
|
4257
|
+
log: settings.log,
|
|
4258
|
+
onProgress: settings.onProgress
|
|
4259
|
+
});
|
|
4115
4260
|
this.lastExecution = execution;
|
|
4116
4261
|
return execution;
|
|
4117
4262
|
}
|
|
@@ -4368,6 +4513,7 @@ var ComfyHost = class {
|
|
|
4368
4513
|
this.comfySessionId = "temp";
|
|
4369
4514
|
this._unknownBinaryFrameTypes = /* @__PURE__ */ new Set();
|
|
4370
4515
|
this.status = null;
|
|
4516
|
+
this.lastWsMessageAt = null;
|
|
4371
4517
|
this.base = parseHostBase(this.data);
|
|
4372
4518
|
/** folder where file related to the host config will be cached */
|
|
4373
4519
|
this.cacheFolder = comfyts.resolveFromHosts(this.data.id);
|
|
@@ -4521,6 +4667,7 @@ var ComfyHost = class {
|
|
|
4521
4667
|
prompt.onPromptRelatedMessage(msg);
|
|
4522
4668
|
}
|
|
4523
4669
|
onMessage(e) {
|
|
4670
|
+
this.lastWsMessageAt = Date.now();
|
|
4524
4671
|
if (this.data.onWsMessageAny) this.data.onWsMessageAny(e);
|
|
4525
4672
|
if (e.data instanceof ArrayBuffer) {
|
|
4526
4673
|
const frame = parseBinaryWsFrame(e.data);
|
|
@@ -5185,6 +5332,11 @@ var ComfyRegistry = class ComfyRegistry {
|
|
|
5185
5332
|
};
|
|
5186
5333
|
//#endregion
|
|
5187
5334
|
//#region src/state.ts
|
|
5335
|
+
/** the ONE settings-file location rule — run-tui reads it BEFORE any module
|
|
5336
|
+
* import creates the comfyts global, so the path logic cannot live on the instance only */
|
|
5337
|
+
function settingsPathFor(root) {
|
|
5338
|
+
return asAbsolutePath((0, pathe.join)(root, ".comfy-ts", "settings.json"));
|
|
5339
|
+
}
|
|
5188
5340
|
/** singleton */
|
|
5189
5341
|
var ComfyTS = class ComfyTS {
|
|
5190
5342
|
constructor(p = {}) {
|
|
@@ -5253,7 +5405,7 @@ var ComfyTS = class ComfyTS {
|
|
|
5253
5405
|
}
|
|
5254
5406
|
/** local TUI settings (preview mode, last draft per workflow) — gitignored */
|
|
5255
5407
|
get settingsPath() {
|
|
5256
|
-
return
|
|
5408
|
+
return settingsPathFor(this.rootPath);
|
|
5257
5409
|
}
|
|
5258
5410
|
resolveFromHosts(relativePath) {
|
|
5259
5411
|
return asAbsolutePath((0, pathe.join)(this.hostsFolder, relativePath));
|