comfy-ts 1.2.0 → 1.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.
Files changed (72) hide show
  1. package/README.md +66 -0
  2. package/dist/DefinedWorkflow-C_QAxKr3.js +737 -0
  3. package/dist/DefinedWorkflow-C_QAxKr3.js.map +1 -0
  4. package/dist/DraftsSt-DcOTn0QR.js +434 -0
  5. package/dist/DraftsSt-DcOTn0QR.js.map +1 -0
  6. package/dist/cli.js +15 -5
  7. package/dist/cli.js.map +1 -1
  8. package/dist/index.cjs +476 -202
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +98 -40
  11. package/dist/index.d.ts +117 -59
  12. package/dist/index.js +468 -193
  13. package/dist/index.js.map +1 -1
  14. package/dist/run-serve-CN0DhrsA.js +638 -0
  15. package/dist/run-serve-CN0DhrsA.js.map +1 -0
  16. package/dist/{run-tui-BAdizWsO.js → run-tui-bN2hSD5i.js} +250 -447
  17. package/dist/run-tui-bN2hSD5i.js.map +1 -0
  18. package/dist/state-COlKYipO.js +4743 -0
  19. package/dist/state-COlKYipO.js.map +1 -0
  20. package/dist/web.d.ts +17340 -0
  21. package/dist/{state-BYbxDgfr.js → web.js} +1903 -1592
  22. package/dist/web.js.map +1 -0
  23. package/examples/web/example.ts +71 -0
  24. package/examples/web/index.html +77 -0
  25. package/examples/web/serve.ts +42 -0
  26. package/examples/web/tsconfig.json +15 -0
  27. package/package.json +10 -3
  28. package/src/cli/comfy-ts-cli.ts +15 -5
  29. package/src/cli/serve/ServeApp.ts +378 -0
  30. package/src/cli/serve/applyVarPayload.ts +119 -0
  31. package/src/cli/serve/describeVar.ts +74 -0
  32. package/src/cli/serve/run-serve.ts +169 -0
  33. package/src/cli/tui/components/StatusBar.tsx +1 -0
  34. package/src/cli/tui/components/TreePanel.tsx +17 -3
  35. package/src/cli/tui/components/TuiApp.tsx +7 -2
  36. package/src/cli/tui/components/VarsPanel.tsx +67 -34
  37. package/src/cli/tui/imageClipboard.ts +39 -0
  38. package/src/cli/tui/listWindow.ts +36 -0
  39. package/src/cli/tui/state/ExecSt.ts +48 -0
  40. package/src/cli/tui/state/TreeSt.ts +25 -0
  41. package/src/cli/tui/state/TuiSt.ts +34 -0
  42. package/src/coreExports.ts +118 -0
  43. package/src/host/ComfyHost.ts +23 -23
  44. package/src/host/ResilientWebsocket.ts +93 -47
  45. package/src/host/hostUrl.ts +2 -1
  46. package/src/host/loraManagerApi.ts +6 -7
  47. package/src/index.ts +8 -107
  48. package/src/litegraph/convertFlowToLiteGraphJSON.ts +11 -7
  49. package/src/manager/loaders/step2_custom-node-list-loader.ts +4 -4
  50. package/src/manager/loaders/step3_extension-node-map-loader.ts +3 -3
  51. package/src/manager/loaders/step4_model-list-loader.ts +7 -7
  52. package/src/manager/loaders/step5_alter-list-loader.ts +2 -2
  53. package/src/manager/loaders/step6_github-stats-loader.ts +2 -2
  54. package/src/runner/ComfyExecution.ts +32 -12
  55. package/src/runner/MediaImage.ts +18 -30
  56. package/src/runner/outputPath.ts +75 -0
  57. package/src/sdk-generator/ComfySchema.ts +2 -2
  58. package/src/sdk-generator/inputWidgetKind.ts +50 -11
  59. package/src/sdk-generator/litegraphToApiRequestPayload.ts +14 -7
  60. package/src/state.ts +13 -9
  61. package/src/storage/ComfyStorage.ts +144 -0
  62. package/src/storage/nodeStorage.ts +9 -0
  63. package/src/utils/downloadFile.ts +11 -69
  64. package/src/utils/hashArrayBuffer.ts +3 -4
  65. package/src/utils/lazySharp.ts +25 -0
  66. package/src/utils/sha1.ts +69 -0
  67. package/src/vars/ComfyVars.ts +13 -6
  68. package/src/vars/loraKeywords.ts +6 -6
  69. package/src/web.ts +13 -0
  70. package/dist/run-tui-BAdizWsO.js.map +0 -1
  71. package/dist/state-BYbxDgfr.js.map +0 -1
  72. package/src/utils/writeFile.ts +0 -16
package/dist/index.cjs CHANGED
@@ -23,24 +23,118 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  //#endregion
24
24
  let node_fs = require("node:fs");
25
25
  node_fs = __toESM(node_fs, 1);
26
+ let node_os = require("node:os");
27
+ node_os = __toESM(node_os, 1);
26
28
  let pathe = require("pathe");
27
29
  let arktype = require("arktype");
28
30
  let nanoid = require("nanoid");
29
- let sharp = require("sharp");
30
- sharp = __toESM(sharp, 1);
31
31
  let image_meta = require("image-meta");
32
- let node_crypto = require("node:crypto");
33
- node_crypto = __toESM(node_crypto, 1);
34
- let ws = require("ws");
35
- ws = __toESM(ws, 1);
36
- let node_os = require("node:os");
37
32
  let mobx = require("mobx");
38
- let node_https = require("node:https");
39
- node_https = __toESM(node_https, 1);
40
- let node_process = require("node:process");
41
33
  let node_url = require("node:url");
34
+ //#region src/storage/ComfyStorage.ts
35
+ function dirnameOf(path) {
36
+ const ix = path.lastIndexOf("/");
37
+ return ix <= 0 ? "/" : path.slice(0, ix);
38
+ }
39
+ /** node backend built from INJECTED modules: nodeStorage.ts passes its static
40
+ * imports, the autodetect below passes process.getBuiltinModule results */
41
+ function createNodeStorageFrom(fs, os) {
42
+ return {
43
+ kind: "node",
44
+ readText: (p) => fs.readFileSync(p, "utf8"),
45
+ readTextIfExists: (p) => fs.existsSync(p) ? fs.readFileSync(p, "utf8") : null,
46
+ readBytes: (p) => new Uint8Array(fs.readFileSync(p)),
47
+ writeText: (p, text) => {
48
+ fs.mkdirSync(dirnameOf(p), { recursive: true });
49
+ fs.writeFileSync(p, text);
50
+ },
51
+ writeBytes: (p, bytes) => {
52
+ fs.mkdirSync(dirnameOf(p), { recursive: true });
53
+ fs.writeFileSync(p, bytes);
54
+ },
55
+ exists: (p) => fs.existsSync(p),
56
+ mkdirp: (p) => void fs.mkdirSync(p, { recursive: true }),
57
+ mtimeMs: (p) => fs.existsSync(p) ? fs.statSync(p).mtimeMs : null,
58
+ homedir: () => os.homedir(),
59
+ cwd: () => process.cwd()
60
+ };
61
+ }
62
+ /** in-memory backend: the web default, also handy for hermetic tests.
63
+ * Paths are LITERAL keys (no normalization — core callers resolve through
64
+ * pathe/comfyts already). exists() knows written files and EXPLICIT mkdirp
65
+ * dirs only, never implicit parents. Bytes are copied in AND out so neither
66
+ * side can mutate the store. */
67
+ function createMemoryStorage(p = {}) {
68
+ const files = /* @__PURE__ */ new Map();
69
+ const mtimes = /* @__PURE__ */ new Map();
70
+ const dirs = /* @__PURE__ */ new Set();
71
+ const td = new TextDecoder();
72
+ const te = new TextEncoder();
73
+ const write = (path, bytes) => {
74
+ files.set(path, bytes.slice());
75
+ mtimes.set(path, Date.now());
76
+ };
77
+ return {
78
+ kind: "memory",
79
+ readText: (path) => {
80
+ const hit = files.get(path);
81
+ if (hit == null) throw new Error(`[memory storage] no such file: ${path}`);
82
+ return td.decode(hit);
83
+ },
84
+ readTextIfExists: (path) => {
85
+ const hit = files.get(path);
86
+ return hit == null ? null : td.decode(hit);
87
+ },
88
+ readBytes: (path) => {
89
+ const hit = files.get(path);
90
+ if (hit == null) throw new Error(`[memory storage] no such file: ${path}`);
91
+ return hit.slice();
92
+ },
93
+ writeText: (path, text) => write(path, te.encode(text)),
94
+ writeBytes: write,
95
+ exists: (path) => files.has(path) || dirs.has(path),
96
+ mkdirp: (path) => void dirs.add(path),
97
+ mtimeMs: (path) => mtimes.get(path) ?? null,
98
+ homedir: () => p.homedir ?? "/home/web",
99
+ cwd: () => p.cwd ?? "/"
100
+ };
101
+ }
102
+ let installedDefault = null;
103
+ /** entries call this at import time: index.ts installs node, web.ts memory */
104
+ function setDefaultComfyStorage(storage) {
105
+ installedDefault = storage;
106
+ }
107
+ function autodetectNodeStorage() {
108
+ const get = globalThis.process?.getBuiltinModule;
109
+ if (typeof get !== "function") return null;
110
+ const fs = get("node:fs");
111
+ const os = get("node:os");
112
+ if (fs == null || os == null) return null;
113
+ return createNodeStorageFrom(fs, os);
114
+ }
115
+ function resolveComfyStorage(explicit) {
116
+ if (explicit != null) return explicit;
117
+ if (installedDefault != null) return installedDefault;
118
+ const detected = autodetectNodeStorage();
119
+ if (detected != null) {
120
+ installedDefault = detected;
121
+ return detected;
122
+ }
123
+ throw new Error(`no ComfyStorage available — import 'comfy-ts' (node) or 'comfy-ts/web' (browser) before creating ComfyTS, or pass ComfyTS.create({ storage })`);
124
+ }
125
+ /** the ONE accessor call sites use: the instance's storage when the global
126
+ * exists, the resolved default otherwise (vars constructed before create()) */
127
+ function getComfyStorage() {
128
+ return globalThis.comfyts?.storage ?? resolveComfyStorage();
129
+ }
130
+ //#endregion
131
+ //#region src/storage/nodeStorage.ts
132
+ function createNodeStorage() {
133
+ return createNodeStorageFrom(node_fs, node_os);
134
+ }
135
+ //#endregion
42
136
  //#region package.json
43
- var version = "1.2.0";
137
+ var version = "1.4.0";
44
138
  //#endregion
45
139
  //#region src/litegraph/LiteGraphLinkID.ts
46
140
  const asLiteGraphLinkID = (id) => id;
@@ -754,6 +848,25 @@ const containerInstanceSlotType = (opts) => {
754
848
  if (subs.length !== 1 || first == null || typeof first.type !== "string") return null;
755
849
  return first.type;
756
850
  };
851
+ /**
852
+ * frontend-registered widgets whose object_info opts carry NO config signal —
853
+ * the one exception to config-only classification (architecture.md rule 8).
854
+ * Every entry must quote the frontend widget-creation source.
855
+ *
856
+ * LOAD_3D (ComfyUI_frontend src/extensions/core/load3d.ts, verified
857
+ * 2026-07-31): the LOAD_3D custom widget handler runs
858
+ * node.addWidget('button', 'upload 3d model', 'upload3dmodel', …)
859
+ * node.addWidget('button', 'upload extra resources', 'uploadExtraResources', …)
860
+ * node.addWidget('button', 'clear', 'clear', …)
861
+ * THEN creates the scene widget, so the serialized run is
862
+ * [btn, btn, btn, value] with the real value LAST. Lax domain: '' in saved
863
+ * files, an {image, mask, normal, camera_info, …} dict at queue time.
864
+ */
865
+ const EMPTY_CONFIG_FRONTEND_WIDGETS = { LOAD_3D: { prefixValues: [
866
+ "upload3dmodel",
867
+ "uploadExtraResources",
868
+ "clear"
869
+ ] } };
757
870
  const classifyWidgetInput = (p) => {
758
871
  const o = isRecord(p.opts) ? p.opts : null;
759
872
  if (o?.["forceInput"] === true) return { kind: "slot" };
@@ -762,7 +875,8 @@ const classifyWidgetInput = (p) => {
762
875
  return {
763
876
  kind: "widget",
764
877
  consumes: controlConsumes(o, tn, p.name),
765
- strictValues: true
878
+ strictValues: true,
879
+ prefixValues: []
766
880
  };
767
881
  }
768
882
  if (typeof p.type !== "string") return { kind: "slot" };
@@ -770,7 +884,8 @@ const classifyWidgetInput = (p) => {
770
884
  if (ComfyPrimitiveMapping[widgetTypeName] != null) return {
771
885
  kind: "widget",
772
886
  consumes: controlConsumes(o, widgetTypeName, p.name),
773
- strictValues: true
887
+ strictValues: true,
888
+ prefixValues: []
774
889
  };
775
890
  const options = o?.["options"];
776
891
  if (Array.isArray(options)) {
@@ -787,7 +902,8 @@ const classifyWidgetInput = (p) => {
787
902
  return {
788
903
  kind: "widget",
789
904
  consumes: controlConsumes(o, p.type, p.name),
790
- strictValues: true
905
+ strictValues: true,
906
+ prefixValues: []
791
907
  };
792
908
  }
793
909
  const template = o?.["template"];
@@ -798,7 +914,15 @@ const classifyWidgetInput = (p) => {
798
914
  if (o?.["socketless"] === true) return {
799
915
  kind: "widget",
800
916
  consumes: 1,
801
- strictValues: false
917
+ strictValues: false,
918
+ prefixValues: []
919
+ };
920
+ const emptyConfigEntry = EMPTY_CONFIG_FRONTEND_WIDGETS[widgetTypeName];
921
+ if (emptyConfigEntry != null) return {
922
+ kind: "widget",
923
+ consumes: emptyConfigEntry.prefixValues.length + 1,
924
+ strictValues: false,
925
+ prefixValues: emptyConfigEntry.prefixValues
802
926
  };
803
927
  return { kind: "slot" };
804
928
  };
@@ -808,11 +932,6 @@ const classifySchemaInput = (input) => classifyWidgetInput({
808
932
  opts: input.opts,
809
933
  isEnumUnion: input.isEnum
810
934
  });
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
935
  /**
817
936
  * what ComfyUI's frontend gives a widget created with no serialized value
818
937
  * (`getWidgetDefaultValue` semantics), used when a positional array is
@@ -914,15 +1033,15 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
914
1033
  if (!p.strict && isRecord(value)) return value;
915
1034
  throw new WorkflowConvertError("invalid-widget-value", `node ${node.id}(${node.type}) has an invalid widget value for "${p.promptName}": ${JSON.stringify(value)}`, node);
916
1035
  };
917
- /** named wins, then positional cursor; filled=true when both miss (caller falls back to the schema default) */
1036
+ /** 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
1037
  const resolveWidgetValue = (p) => {
919
1038
  let value;
920
1039
  let has = false;
921
1040
  if (Object.hasOwn(named, p.promptName)) {
922
1041
  value = named[p.promptName];
923
1042
  has = true;
924
- } else if (offset < positional.length) {
925
- value = positional[offset];
1043
+ } else if (offset + p.prefixLen < positional.length) {
1044
+ value = positional[offset + p.prefixLen];
926
1045
  has = true;
927
1046
  }
928
1047
  if (positional.length > 0) offset += p.consumes;
@@ -934,7 +1053,8 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
934
1053
  const consumePlainWidget = (p) => {
935
1054
  const r = resolveWidgetValue({
936
1055
  promptName: p.promptName,
937
- consumes: p.consumes
1056
+ consumes: p.consumes,
1057
+ prefixLen: p.prefixLen
938
1058
  });
939
1059
  const raw = r.filled ? defaultValueForWidget({
940
1060
  type: p.typeName,
@@ -953,7 +1073,8 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
953
1073
  const consumeDynamicCombo = (p) => {
954
1074
  const r = resolveWidgetValue({
955
1075
  promptName: p.path,
956
- consumes: 1
1076
+ consumes: 1,
1077
+ prefixLen: 0
957
1078
  });
958
1079
  const key = r.filled ? p.defaultKey : r.value;
959
1080
  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 +1102,7 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
981
1102
  typeName: typeof sub.type === "string" ? sub.type : "COMBO",
982
1103
  opts: sub.opts,
983
1104
  consumes: kind.consumes,
1105
+ prefixLen: kind.prefixValues.length,
984
1106
  strict: kind.strictValues,
985
1107
  enumValues: inlineEnum,
986
1108
  linkedInput: inputsInNodeJSON.find((i) => i.name === subPath)
@@ -992,13 +1114,15 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
992
1114
  if (kind.kind === "slot" && input?.widgetName != null) kind = {
993
1115
  kind: "widget",
994
1116
  consumes: howManyWidgetValuesForThisInputType(input.type, field.nameInComfy) === 2 ? 2 : 1,
995
- strictValues: true
1117
+ strictValues: true,
1118
+ prefixValues: []
996
1119
  };
997
1120
  if (kind.kind === "widget") consumePlainWidget({
998
1121
  promptName: field.nameInComfy,
999
1122
  typeName: field.typeName,
1000
1123
  opts: field.opts,
1001
1124
  consumes: kind.consumes,
1125
+ prefixLen: kind.prefixValues.length,
1002
1126
  strict: kind.strictValues,
1003
1127
  linkedInput: input
1004
1128
  });
@@ -1498,7 +1622,7 @@ const convertNodeToLiteGraphNode = (ctx, node) => {
1498
1622
  const widgets_values = [];
1499
1623
  for (const ipt of node.$schema.inputs) {
1500
1624
  const raw = node.serializeValue(ipt.nameInComfy, node.json.inputs[ipt.nameInComfy]);
1501
- const isWidget = howManyWidgetValuesForThisSchemaType(ipt) > 0;
1625
+ const kind = classifySchemaInput(ipt);
1502
1626
  if (_isLink(raw)) {
1503
1627
  const nodeUidNumber = bang(ctx.graph.nodes.find((n) => n.uid === raw[0])?.uidNumber, `link target node "${raw[0]}" not found in graph`);
1504
1628
  inputs.push({
@@ -1506,9 +1630,10 @@ const convertNodeToLiteGraphNode = (ctx, node) => {
1506
1630
  type: ipt.typeName,
1507
1631
  link: ctx.allocateLink(nodeUidNumber, raw[1], node.uidNumber, asLiteGraphSlotIndex(inputs.length), ipt.typeName)
1508
1632
  });
1509
- } else if (isWidget) {
1510
- widgets_values.push(raw);
1511
- if (ipt.typeName === "INT" && (ipt.nameInComfy === "seed" || ipt.nameInComfy === "noise_seed")) widgets_values.push(false);
1633
+ } else if (kind.kind === "widget") {
1634
+ widgets_values.push(...kind.prefixValues, raw);
1635
+ const phantoms = kind.consumes - 1 - kind.prefixValues.length;
1636
+ for (let i = 0; i < phantoms; i++) widgets_values.push(false);
1512
1637
  } else inputs.push({
1513
1638
  name: ipt.nameInComfy,
1514
1639
  type: ipt.typeName,
@@ -1554,6 +1679,91 @@ var LiteGraphCtx = class {
1554
1679
  }
1555
1680
  };
1556
1681
  //#endregion
1682
+ //#region src/runner/outputPath.ts
1683
+ /**
1684
+ * local output naming, relative to `.comfy-ts/outputs/` (his repro
1685
+ * 2026-07-31): the server filename is NOT unique — cloud hosts reset the
1686
+ * `_00001_` counter every run, so trusting it overwrote the same file — and
1687
+ * a `foo/krea/` prefix means the DIRECTORY foo/krea/, not a `krea_` name
1688
+ * prefix. Local names are ours: dir from the prompt's own filename_prefix
1689
+ * (or an explicit saveFormat.prefix override), then
1690
+ * `<stem>_<timestamp>_<counter><ext>` so every run sorts chronologically
1691
+ * per stem and nothing ever collides.
1692
+ */
1693
+ const localOutputPath = (p) => {
1694
+ const dot = p.filename.lastIndexOf(".");
1695
+ const ext = dot === -1 ? "" : p.filename.slice(dot);
1696
+ const base = dot === -1 ? p.filename : p.filename.slice(0, dot);
1697
+ const counterMatch = /_(\d+)_$/.exec(base);
1698
+ const counter = counterMatch?.[1];
1699
+ const serverStem = counterMatch != null ? base.slice(0, base.length - counterMatch[0].length) : base;
1700
+ let dir;
1701
+ let stem;
1702
+ if (p.filenamePrefix != null && p.filenamePrefix !== "") {
1703
+ const slash = p.filenamePrefix.lastIndexOf("/");
1704
+ dir = slash === -1 ? "" : p.filenamePrefix.slice(0, slash);
1705
+ stem = slash === -1 ? p.filenamePrefix : p.filenamePrefix.slice(slash + 1);
1706
+ } else {
1707
+ dir = p.subfolder;
1708
+ stem = serverStem;
1709
+ }
1710
+ if (p.localDir != null) dir = p.localDir;
1711
+ const name = [
1712
+ stem === "" ? null : stem,
1713
+ p.timestamp,
1714
+ counter
1715
+ ].filter((x) => x != null).join("_") + ext;
1716
+ return dir === "" ? name : `${dir}/${name}`;
1717
+ };
1718
+ /**
1719
+ * never-overwrite guard: bump `-2`, `-3`, … while the path exists on disk OR
1720
+ * was already CLAIMED by a still-downloading retrieval (two same-second runs
1721
+ * on a counter-resetting cloud host compute the same name — reviewer catch).
1722
+ * The chosen path is claimed before returning.
1723
+ */
1724
+ const uniquifyOutputPath = (p) => {
1725
+ let out = p.path;
1726
+ if (p.exists(out) || p.claimed.has(out)) {
1727
+ const dot = out.lastIndexOf(".");
1728
+ const stem = dot === -1 ? out : out.slice(0, dot);
1729
+ const ext = dot === -1 ? "" : out.slice(dot);
1730
+ for (let n = 2; p.exists(out) || p.claimed.has(out); n++) out = `${stem}-${n}${ext}`;
1731
+ }
1732
+ p.claimed.add(out);
1733
+ return out;
1734
+ };
1735
+ /** YYYYMMDD-HHmmss, local time — sortable, text-encodable, no colons for filesystems */
1736
+ const runTimestamp = (d) => {
1737
+ const pad = (n) => String(n).padStart(2, "0");
1738
+ return `${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}-${pad(d.getHours())}${pad(d.getMinutes())}${pad(d.getSeconds())}`;
1739
+ };
1740
+ //#endregion
1741
+ //#region src/utils/extractErrorMessage.ts
1742
+ /** Extracts an error message from an exception stuff. */
1743
+ const extractErrorMessage = (error) => {
1744
+ if (error instanceof Error) return error.message;
1745
+ if (error === null) return "null";
1746
+ if (typeof error === "string") return error;
1747
+ if (typeof error === "object") {
1748
+ if ("message" in error && typeof error.message === "string") return error.message;
1749
+ return JSON.stringify(error);
1750
+ }
1751
+ return String(error);
1752
+ };
1753
+ //#endregion
1754
+ //#region src/utils/lazySharp.ts
1755
+ let cached = null;
1756
+ async function importSharp(reason) {
1757
+ if (cached != null) return cached;
1758
+ const specifier = "sharp";
1759
+ try {
1760
+ cached = (await import(specifier)).default;
1761
+ return cached;
1762
+ } catch (e) {
1763
+ throw new Error(`sharp is unavailable — ${reason} is node-only (browser builds get raw bytes instead): ${extractErrorMessage(e)}`, { cause: e });
1764
+ }
1765
+ }
1766
+ //#endregion
1557
1767
  //#region src/types/index.ts
1558
1768
  const asAbsolutePath = (path) => path;
1559
1769
  const asRelativePath = (path) => path;
@@ -1603,10 +1813,78 @@ function exhaust(x) {
1603
1813
  return x;
1604
1814
  }
1605
1815
  //#endregion
1816
+ //#region src/utils/sha1.ts
1817
+ function sha1Hex(data) {
1818
+ const ml = data.length;
1819
+ const total = Math.ceil((ml + 1 + 8) / 64) * 64;
1820
+ const bytes = new Uint8Array(total);
1821
+ bytes.set(data);
1822
+ bytes[ml] = 128;
1823
+ const dv = new DataView(bytes.buffer);
1824
+ const bitLen = ml * 8;
1825
+ dv.setUint32(total - 8, Math.floor(bitLen / 2 ** 32));
1826
+ dv.setUint32(total - 4, bitLen >>> 0);
1827
+ let h0 = 1732584193;
1828
+ let h1 = 4023233417;
1829
+ let h2 = 2562383102;
1830
+ let h3 = 271733878;
1831
+ let h4 = 3285377520;
1832
+ const w = /* @__PURE__ */ new Uint32Array(80);
1833
+ for (let i = 0; i < total; i += 64) {
1834
+ for (let j = 0; j < 16; j++) w[j] = dv.getUint32(i + j * 4);
1835
+ for (let j = 16; j < 80; j++) {
1836
+ const n = (w[j - 3] ?? 0) ^ (w[j - 8] ?? 0) ^ (w[j - 14] ?? 0) ^ (w[j - 16] ?? 0);
1837
+ w[j] = n << 1 | n >>> 31;
1838
+ }
1839
+ let a = h0;
1840
+ let b = h1;
1841
+ let c = h2;
1842
+ let d = h3;
1843
+ let e = h4;
1844
+ for (let j = 0; j < 80; j++) {
1845
+ let f;
1846
+ let k;
1847
+ if (j < 20) {
1848
+ f = b & c | ~b & d;
1849
+ k = 1518500249;
1850
+ } else if (j < 40) {
1851
+ f = b ^ c ^ d;
1852
+ k = 1859775393;
1853
+ } else if (j < 60) {
1854
+ f = b & c | b & d | c & d;
1855
+ k = 2400959708;
1856
+ } else {
1857
+ f = b ^ c ^ d;
1858
+ k = 3395469782;
1859
+ }
1860
+ const temp = (a << 5 | a >>> 27) + f + e + k + (w[j] ?? 0) >>> 0;
1861
+ e = d;
1862
+ d = c;
1863
+ c = b << 30 | b >>> 2;
1864
+ b = a;
1865
+ a = temp;
1866
+ }
1867
+ h0 = h0 + a >>> 0;
1868
+ h1 = h1 + b >>> 0;
1869
+ h2 = h2 + c >>> 0;
1870
+ h3 = h3 + d >>> 0;
1871
+ h4 = h4 + e >>> 0;
1872
+ }
1873
+ return [
1874
+ h0,
1875
+ h1,
1876
+ h2,
1877
+ h3,
1878
+ h4
1879
+ ].map((x) => x.toString(16).padStart(8, "0")).join("");
1880
+ }
1881
+ function sha1HexOfString(s) {
1882
+ return sha1Hex(new TextEncoder().encode(s));
1883
+ }
1884
+ //#endregion
1606
1885
  //#region src/utils/hashArrayBuffer.ts
1607
1886
  const hashArrayBuffer = (buffer) => {
1608
- const data = Buffer.from(buffer);
1609
- return node_crypto.default.createHash("sha1").update(data).digest("hex");
1887
+ return sha1Hex(buffer);
1610
1888
  };
1611
1889
  //#endregion
1612
1890
  //#region src/graph/ComfyNodeID.ts
@@ -1785,29 +2063,21 @@ var MediaImage = class MediaImage {
1785
2063
  this._metadata = null;
1786
2064
  this._hash = null;
1787
2065
  this.processWithSharp_inplace = async (fn) => {
1788
- const buff = await fn((0, sharp.default)(this.absPath)).toBuffer();
1789
- (0, node_fs.writeFileSync)(this.absPath, buff);
2066
+ const buff = await fn((await importSharp("processWithSharp_inplace"))(this.buffer)).toBuffer();
2067
+ getComfyStorage().writeBytes(this.absPath, new Uint8Array(buff));
1790
2068
  this.updateBuffer(new Uint8Array(buff));
1791
2069
  return this;
1792
2070
  };
1793
2071
  this.processWithSharp = async (fn, path) => {
1794
- const res = fn((0, sharp.default)(this.absPath));
2072
+ const sharp = await importSharp("processWithSharp");
1795
2073
  path ??= this.absPath + `.processed-${Date.now()}` + this.extension;
1796
- await res.toFile(path);
1797
- const buffer = await res.toBuffer();
2074
+ const buffer = new Uint8Array(await fn(sharp(this.buffer)).toBuffer());
2075
+ getComfyStorage().writeBytes(path, buffer);
1798
2076
  return new MediaImage({
1799
2077
  path,
1800
2078
  buffer
1801
2079
  });
1802
2080
  };
1803
- this.generatePreview = async (targetPath) => {
1804
- const img = (0, sharp.default)(this.absPath).rotate().resize(100).jpeg({ mozjpeg: true });
1805
- (0, node_fs.mkdirSync)((0, pathe.dirname)(targetPath), { recursive: true });
1806
- await img.toFile(targetPath);
1807
- };
1808
- this.generateMiniPreview = async () => {
1809
- return (await (0, sharp.default)(this.absPath).resize(32, 32, { fit: "inside" }).webp({ quality: 1 }).toBuffer()).toString("base64");
1810
- };
1811
2081
  this.absPath = data.path;
1812
2082
  this.execution = data.execution;
1813
2083
  this.promptNodeID = data.promptNodeID;
@@ -1877,31 +2147,33 @@ var MediaImage = class MediaImage {
1877
2147
  * does not includes the prefix `data:image/png;base64,`
1878
2148
  */
1879
2149
  getBase64Payload() {
1880
- return Buffer.from(this.buffer).toString("base64");
2150
+ const bytes = this.buffer;
2151
+ let bin = "";
2152
+ const chunk = 32768;
2153
+ for (let i = 0; i < bytes.length; i += chunk) bin += String.fromCharCode(...bytes.subarray(i, i + chunk));
2154
+ return btoa(bin);
1881
2155
  }
1882
2156
  get buffer() {
1883
2157
  if (this._buffer != null) return this._buffer;
1884
- const buff = (0, node_fs.readFileSync)(this.absPath);
1885
- const uint8arr = new Uint8Array(buff);
1886
- this._buffer = uint8arr;
2158
+ this._buffer = getComfyStorage().readBytes(this.absPath);
1887
2159
  return this._buffer;
1888
2160
  }
1889
2161
  get metadata() {
1890
2162
  if (this._metadata != null) return this._metadata;
1891
- const buff = (0, node_fs.readFileSync)(this.absPath);
1892
- const uint8arr = new Uint8Array(buff);
1893
- this._metadata = (0, image_meta.imageMeta)(uint8arr);
2163
+ this._metadata = (0, image_meta.imageMeta)(this.buffer);
1894
2164
  return this._metadata;
1895
2165
  }
1896
2166
  get hash() {
1897
2167
  if (this._hash != null) return this._hash;
1898
- const buff = (0, node_fs.readFileSync)(this.absPath);
1899
- this._hash = hashArrayBuffer(new Uint8Array(buff));
2168
+ this._hash = hashArrayBuffer(this.buffer);
1900
2169
  return this._hash;
1901
2170
  }
1902
2171
  };
1903
2172
  //#endregion
1904
2173
  //#region src/runner/ComfyExecution.ts
2174
+ /** paths claimed by in-flight retrievals: two same-second runs on a
2175
+ * counter-resetting cloud host compute the same name before either writes */
2176
+ const CLAIMED_OUTPUT_PATHS = /* @__PURE__ */ new Set();
1905
2177
  var ComfyExecution = class {
1906
2178
  get host() {
1907
2179
  return this.workflow.host;
@@ -1967,12 +2239,24 @@ var ComfyExecution = class {
1967
2239
  if (promptNode == null) throw new Error(`❌ invariant violation: promptNode is null`);
1968
2240
  const imgRoute = "/view?" + new URLSearchParams(comfyImageInfo).toString();
1969
2241
  const sf = this.saveFormat;
1970
- let absPath = comfyts.resolveFromOutput((0, pathe.join)(sf?.prefix ?? comfyImageInfo.subfolder, comfyImageInfo.filename));
2242
+ const promptPrefix = promptNode.inputs["filename_prefix"];
2243
+ let absPath = comfyts.resolveFromOutput(localOutputPath({
2244
+ localDir: sf?.prefix,
2245
+ filenamePrefix: typeof promptPrefix === "string" ? promptPrefix : void 0,
2246
+ subfolder: comfyImageInfo.subfolder,
2247
+ filename: comfyImageInfo.filename,
2248
+ timestamp: runTimestamp(new Date(this.startedAt))
2249
+ }));
1971
2250
  if (sf?.format && sf.format !== "raw") {
1972
2251
  const extension = sf.format.split("/")[1];
1973
2252
  absPath += "." + extension;
1974
2253
  }
1975
- (0, node_fs.mkdirSync)((0, pathe.dirname)(absPath), { recursive: true });
2254
+ const storage = getComfyStorage();
2255
+ absPath = uniquifyOutputPath({
2256
+ path: absPath,
2257
+ exists: (p) => storage.exists(p),
2258
+ claimed: CLAIMED_OUTPUT_PATHS
2259
+ });
1976
2260
  let img;
1977
2261
  if (sf && sf.format !== "raw") {
1978
2262
  const buff = await (await this.host.fetchFile(imgRoute)).arrayBuffer();
@@ -1987,9 +2271,11 @@ var ComfyExecution = class {
1987
2271
  if (sf.format === "image/webp") return "webp";
1988
2272
  return "png";
1989
2273
  })();
1990
- await (0, sharp.default)(buff).withMetadata().withExif({ IFD0: textChunk }).toFormat(format, sf.quality ? { quality: Math.round(sf.quality * 100) } : void 0).toFile(absPath);
2274
+ const encoded = await (await importSharp(`saveFormat '${sf.format}' re-encoding`))(buff).withMetadata().withExif({ IFD0: textChunk }).toFormat(format, sf.quality ? { quality: Math.round(sf.quality * 100) } : void 0).toBuffer();
2275
+ storage.writeBytes(asAbsolutePath(absPath), new Uint8Array(encoded));
1991
2276
  img = new MediaImage({
1992
2277
  path: asAbsolutePath(absPath),
2278
+ buffer: new Uint8Array(encoded),
1993
2279
  execution: this,
1994
2280
  promptNodeID,
1995
2281
  comfyUIInfos: {
@@ -2000,7 +2286,7 @@ var ComfyExecution = class {
2000
2286
  } else {
2001
2287
  const buff = await (await this.host.fetchFile(imgRoute)).arrayBuffer();
2002
2288
  const uint8arr = new Uint8Array(buff);
2003
- (0, node_fs.writeFileSync)(absPath, uint8arr);
2289
+ storage.writeBytes(asAbsolutePath(absPath), uint8arr);
2004
2290
  img = new MediaImage({
2005
2291
  path: asAbsolutePath(absPath),
2006
2292
  buffer: uint8arr,
@@ -2057,14 +2343,14 @@ var ComfyExecution = class {
2057
2343
  const line = `▶ [${bar}] ${p.percent.toFixed(0).padStart(3)}%${node} · ${(p.elapsedMs / 1e3).toFixed(0)}s`;
2058
2344
  if (line === this._lastLoggedLine) return;
2059
2345
  this._lastLoggedLine = line;
2060
- if (process.stdout.isTTY) process.stdout.write(`\r\x1b[2K${line}`);
2346
+ if (globalThis.process?.stdout?.isTTY) process.stdout.write(`\r\x1b[2K${line}`);
2061
2347
  else console.log(line);
2062
2348
  }
2063
2349
  finishProgressLine() {
2064
2350
  if (!this.logProgress) return;
2065
2351
  const p = this.progress;
2066
2352
  const line = `${this.status === "Failure" ? "🔴" : "🟢"} ${this.status.toLowerCase()} in ${(p.elapsedMs / 1e3).toFixed(1)}s · ${this.images.length} image(s)`;
2067
- if (process.stdout.isTTY) process.stdout.write(`\r\x1b[2K${line}\n`);
2353
+ if (globalThis.process?.stdout?.isTTY) process.stdout.write(`\r\x1b[2K${line}\n`);
2068
2354
  else console.log(line);
2069
2355
  }
2070
2356
  log(...args) {
@@ -2813,7 +3099,7 @@ var ComfySchema = class {
2813
3099
  else if (typeof enumValue === "number") enumValues.push(enumValue);
2814
3100
  else enumValues.push(enumValue.content);
2815
3101
  const hashContent = enumValues.length === 0 ? `[[empty]]` : enumValues.sort().join("|");
2816
- const hash = node_crypto.default.createHash("sha1").update(hashContent).digest("hex").slice(0, 8);
3102
+ const hash = sha1HexOfString(hashContent).slice(0, 8);
2817
3103
  let unionInfo = this.knownUnionByHash.get(hash);
2818
3104
  if (unionInfo == null) {
2819
3105
  const unionName = getUnionNameBasedOnFirstFoundEnumName(p.slotName, hash, hashContent);
@@ -3097,19 +3383,6 @@ types.ComfyInputType;
3097
3383
  types.ComfyEnumDef;
3098
3384
  types.ComfyInputOpts;
3099
3385
  //#endregion
3100
- //#region src/utils/extractErrorMessage.ts
3101
- /** Extracts an error message from an exception stuff. */
3102
- const extractErrorMessage = (error) => {
3103
- if (error instanceof Error) return error.message;
3104
- if (error === null) return "null";
3105
- if (typeof error === "string") return error;
3106
- if (typeof error === "object") {
3107
- if ("message" in error && typeof error.message === "string") return error.message;
3108
- return JSON.stringify(error);
3109
- }
3110
- return String(error);
3111
- };
3112
- //#endregion
3113
3386
  //#region src/utils/stringifyReadable.ts
3114
3387
  const tab = " ";
3115
3388
  function readableStringify(obj, maxLevel = 3, level = 0) {
@@ -3137,17 +3410,6 @@ function readableStringify(obj, maxLevel = 3, level = 0) {
3137
3410
  return result;
3138
3411
  }
3139
3412
  //#endregion
3140
- //#region src/utils/writeFile.ts
3141
- const writeFileAsync = async (path, data, fmt) => {
3142
- return new Promise((resolve, reject) => {
3143
- logInfo(`writing file: ${ansi.blue(path)}`);
3144
- (0, node_fs.writeFile)(path, data, fmt, (err) => {
3145
- if (err) reject(err);
3146
- else resolve();
3147
- });
3148
- });
3149
- };
3150
- //#endregion
3151
3413
  //#region src/manager/types/ComfyManagerAPIModelList.ts
3152
3414
  const ComfyManagerAPIModelList_ark = (0, arktype.type)({ models: (0, arktype.type)({
3153
3415
  name: arktype.type.string.as(),
@@ -3385,7 +3647,8 @@ function parseHostBase(p) {
3385
3647
  function renderHttpBase(p) {
3386
3648
  return `${p.scheme}://${p.host}${renderPort(p)}${p.basePath}`;
3387
3649
  }
3388
- /** ws(s) endpoint; auth NEVER rides the query string (headers own it) */
3650
+ /** ws(s) endpoint; auth rides the upgrade headers — EXCEPT headerless
3651
+ * transports (browser), where the ws client remaps X-API-Key to ?token= */
3389
3652
  function renderWsUrl(p) {
3390
3653
  return `${p.scheme === "https" ? "wss" : "ws"}://${p.host}${renderPort(p)}${p.basePath}/ws`;
3391
3654
  }
@@ -3395,6 +3658,27 @@ function renderPort(p) {
3395
3658
  }
3396
3659
  //#endregion
3397
3660
  //#region src/host/ResilientWebsocket.ts
3661
+ let transportPromise = null;
3662
+ /** node: the ws package (headers on the upgrade). browser: native WebSocket. */
3663
+ function resolveWsTransport() {
3664
+ transportPromise ??= (async () => {
3665
+ const specifier = "ws";
3666
+ try {
3667
+ return {
3668
+ ctor: (await import(specifier)).default,
3669
+ supportsHeaders: true
3670
+ };
3671
+ } catch {
3672
+ const native = globalThis.WebSocket;
3673
+ if (native != null) return {
3674
+ ctor: native,
3675
+ supportsHeaders: false
3676
+ };
3677
+ throw new Error(`no WebSocket transport: neither the 'ws' package nor a global WebSocket is available`);
3678
+ }
3679
+ })();
3680
+ return transportPromise;
3681
+ }
3398
3682
  var ResilientWebSocketClient = class {
3399
3683
  addInfo(msg) {
3400
3684
  this.debugMessages.push({
@@ -3429,7 +3713,17 @@ var ResilientWebSocketClient = class {
3429
3713
  this.currentWS = null;
3430
3714
  this.isOpen = false;
3431
3715
  }
3432
- connect() {
3716
+ /** headerless transports carry the api key as ?token= — everything else is refused loud */
3717
+ headerlessUrl(headers) {
3718
+ const rest = { ...headers };
3719
+ const apiKey = rest["X-API-Key"];
3720
+ delete rest["X-API-Key"];
3721
+ const extra = Object.keys(rest);
3722
+ if (extra.length > 0) throw new Error(`custom ws headers (${extra.join(", ")}) need the 'ws' package — a browser WebSocket cannot set upgrade headers`);
3723
+ if (apiKey == null) return this.url;
3724
+ return this.url + (this.url.includes("?") ? "&" : "?") + "token=" + encodeURIComponent(apiKey);
3725
+ }
3726
+ async connect() {
3433
3727
  this.isOpen = false;
3434
3728
  const prevWS = this.currentWS;
3435
3729
  if (this.reconnectTimeout) clearTimeout(this.reconnectTimeout);
@@ -3438,30 +3732,41 @@ var ResilientWebSocketClient = class {
3438
3732
  this.addInfo("Previous WebSocket discarded");
3439
3733
  prevWS.close();
3440
3734
  }
3441
- const ws$1 = new ws.default(this.url, { headers: this.options.headers?.() });
3442
- ws$1.binaryType = "arraybuffer";
3443
- this.currentWS = ws$1;
3444
- if (this.options.onMessage) ws$1.onmessage = (event) => {
3735
+ let ws;
3736
+ try {
3737
+ const transport = await resolveWsTransport();
3738
+ if (this.permanentlyClosed) return;
3739
+ const headers = this.options.headers?.() ?? {};
3740
+ ws = transport.supportsHeaders ? new transport.ctor(this.url, { headers }) : new transport.ctor(this.headerlessUrl(headers));
3741
+ } catch (e) {
3742
+ this.addError(`cannot open WebSocket: ${extractErrorMessage(e)}`);
3743
+ this.permanentlyClosed = true;
3744
+ this.options.onTransportDead?.(e);
3745
+ return;
3746
+ }
3747
+ ws.binaryType = "arraybuffer";
3748
+ this.currentWS = ws;
3749
+ ws.onmessage = (event) => {
3445
3750
  this.options.onMessage(event);
3446
3751
  };
3447
- ws$1.onopen = (_event) => {
3448
- if (ws$1 !== this.currentWS) return;
3752
+ ws.onopen = () => {
3753
+ if (ws !== this.currentWS) return;
3449
3754
  this.addInfo("✅ WebSocket connected to " + this.url);
3450
3755
  this.isOpen = true;
3451
3756
  this.options.onConnectOrReconnect();
3452
3757
  this.flushMessageBuffer();
3453
3758
  };
3454
- ws$1.onclose = (event) => {
3455
- if (ws$1 !== this.currentWS) return;
3759
+ ws.onclose = (event) => {
3760
+ if (ws !== this.currentWS) return;
3456
3761
  this.isOpen = false;
3457
3762
  this.options.onClose();
3458
3763
  if (this.permanentlyClosed) return;
3459
3764
  this.addError(`WebSocket closed (reason=${JSON.stringify(event.reason)}, code=${event.code})`);
3460
3765
  this.addInfo("⏱️ reconnecting in 2 seconds...");
3461
- this.reconnectTimeout = setTimeout(() => this.connect(), 2e3);
3766
+ this.reconnectTimeout = setTimeout(() => void this.connect(), 2e3);
3462
3767
  };
3463
- ws$1.onerror = (event) => {
3464
- if (ws$1 !== this.currentWS) return;
3768
+ ws.onerror = (event) => {
3769
+ if (ws !== this.currentWS) return;
3465
3770
  this.addError(`WebSocket ERROR` + JSON.stringify(event));
3466
3771
  console.error({ event });
3467
3772
  };
@@ -3476,14 +3781,6 @@ var ResilientWebSocketClient = class {
3476
3781
  this.currentWS?.send(message);
3477
3782
  }
3478
3783
  }
3479
- /** forward WebSocket add event listeners to the current WebSocket instance */
3480
- addEventListener(type, listener, options) {
3481
- this.currentWS?.addEventListener(type, listener, options);
3482
- }
3483
- /** forward WebSocket remove event listeners to the current WebSocket instance */
3484
- removeEventListener(type, listener) {
3485
- this.currentWS?.removeEventListener(type, listener);
3486
- }
3487
3784
  };
3488
3785
  //#endregion
3489
3786
  //#region src/vars/loraKeywords.ts
@@ -3503,9 +3800,10 @@ function loadOnce() {
3503
3800
  if (loaded) return;
3504
3801
  loaded = true;
3505
3802
  const path = filePath();
3506
- if (!(0, node_fs.existsSync)(path)) return;
3803
+ const text = getComfyStorage().readTextIfExists(path);
3804
+ if (text == null) return;
3507
3805
  try {
3508
- const raw = JSON.parse((0, node_fs.readFileSync)(path, "utf8"));
3806
+ const raw = JSON.parse(text);
3509
3807
  if (raw == null || typeof raw !== "object") return;
3510
3808
  (0, mobx.runInAction)(() => {
3511
3809
  for (const [name, kw] of Object.entries(raw)) if (typeof kw === "string") keywords.set(name, kw);
@@ -3528,8 +3826,7 @@ function setLoraKeyword(name, keyword) {
3528
3826
  });
3529
3827
  const path = filePath();
3530
3828
  try {
3531
- (0, node_fs.mkdirSync)((0, pathe.dirname)(path), { recursive: true });
3532
- (0, node_fs.writeFileSync)(path, JSON.stringify(Object.fromEntries([...keywords.entries()].sort()), null, 2));
3829
+ getComfyStorage().writeText(path, JSON.stringify(Object.fromEntries([...keywords.entries()].sort()), null, 2));
3533
3830
  } catch (e) {
3534
3831
  logError(`[loraKeywords] write failed ${path}: ${String(e)}`);
3535
3832
  }
@@ -3725,6 +4022,12 @@ var SeedVar = class extends ComfyVar {
3725
4022
  afterRun() {
3726
4023
  this.advance();
3727
4024
  }
4025
+ /** mode is part of the seed's state: a reset must not keep a caller's `?`/`+` alive
4026
+ * ('=' is the construction default; drafts restore their own mode via loadJSON) */
4027
+ reset() {
4028
+ this.setMode("=");
4029
+ return super.reset();
4030
+ }
3728
4031
  /** parse `+` `- 12` `= 5` `?` or a bare number (=> fixed). Keeps the current number when none given */
3729
4032
  parse(raw) {
3730
4033
  const m = raw.trim().match(/^([+\-=?])?\s*(\d+)?$/);
@@ -3967,7 +4270,7 @@ var SizeVar = class extends ComfyVar {
3967
4270
  if (iv == null || iv.value === "") return null;
3968
4271
  try {
3969
4272
  const abs = iv.absPath();
3970
- const meta = (0, image_meta.imageMeta)(new Uint8Array((0, node_fs.readFileSync)(abs)));
4273
+ const meta = (0, image_meta.imageMeta)(getComfyStorage().readBytes(abs));
3971
4274
  if (meta.width == null || meta.height == null) return null;
3972
4275
  return {
3973
4276
  width: meta.width,
@@ -4021,7 +4324,7 @@ var ImageVarEmptyError = class extends Error {
4021
4324
  /** trim + expand a leading `~/` — every ImageVar write funnels through this */
4022
4325
  function expandUserPath(raw) {
4023
4326
  const trimmed = raw.trim();
4024
- return trimmed.startsWith("~/") ? (0, pathe.join)((0, node_os.homedir)(), trimmed.slice(2)) : trimmed;
4327
+ return trimmed.startsWith("~/") ? (0, pathe.join)(getComfyStorage().homedir(), trimmed.slice(2)) : trimmed;
4025
4328
  }
4026
4329
  /**
4027
4330
  * a local image path. The VALUE is a PLAIN PATH STRING — text-encodable,
@@ -4057,7 +4360,7 @@ var ImageVar = class extends ComfyVar {
4057
4360
  absPath() {
4058
4361
  if (!this.isSet()) throw this.emptyError();
4059
4362
  if ((0, pathe.isAbsolute)(this.value)) return this.value;
4060
- return (0, pathe.resolve)(this.opts.folder ?? process.cwd(), this.value);
4363
+ return (0, pathe.resolve)(this.opts.folder ?? getComfyStorage().cwd(), this.value);
4061
4364
  }
4062
4365
  /** empty = unset: the build fails LOUD here (varValues calls outValue) */
4063
4366
  outValue() {
@@ -4066,7 +4369,7 @@ var ImageVar = class extends ComfyVar {
4066
4369
  }
4067
4370
  display() {
4068
4371
  if (!this.isSet()) return "(unset) pick a file";
4069
- const home = (0, node_os.homedir)();
4372
+ const home = getComfyStorage().homedir();
4070
4373
  return this.value.startsWith(`${home}/`) ? `~${this.value.slice(home.length)}` : this.value;
4071
4374
  }
4072
4375
  };
@@ -4364,11 +4667,11 @@ var ComfyHost = class {
4364
4667
  this.isUpdatingSchema = true;
4365
4668
  const object_info_json = await this.fetchJSON_("/object_info");
4366
4669
  const object_info_str = readableStringify(object_info_json, 4);
4367
- writeFileAsync(this.comfyJSONPath, object_info_str, "utf-8");
4670
+ getComfyStorage().writeText(this.comfyJSONPath, object_info_str);
4368
4671
  const res = ComfySchemaJSON_ark(object_info_json);
4369
4672
  if (res instanceof arktype.type.errors) printArkResultInConsole(res);
4370
4673
  const embeddings_json = await this.fetchJSON_("/embeddings").catch(() => []);
4371
- writeFileAsync(this.embeddingsPath, JSON.stringify(embeddings_json), "utf-8");
4674
+ getComfyStorage().writeText(this.embeddingsPath, JSON.stringify(embeddings_json));
4372
4675
  this.schema.update({
4373
4676
  spec: object_info_json,
4374
4677
  embeddings: embeddings_json
@@ -4385,7 +4688,7 @@ var ComfyHost = class {
4385
4688
  };
4386
4689
  console.error(error);
4387
4690
  console.error("🔴 FAILURE TO GENERATE the typed sdk", extractErrorMessage(error));
4388
- if (!(0, node_fs.existsSync)(this.sdkDTSPath)) await this.writeSDKToDisk();
4691
+ if (!getComfyStorage().exists(this.sdkDTSPath)) await this.writeSDKToDisk();
4389
4692
  this.markFailed(error);
4390
4693
  } finally {
4391
4694
  this.isUpdatingSchema = false;
@@ -4406,9 +4709,10 @@ var ComfyHost = class {
4406
4709
  this.base = parseHostBase(this.data);
4407
4710
  /** folder where file related to the host config will be cached */
4408
4711
  this.cacheFolder = comfyts.resolveFromHosts(this.data.id);
4409
- if (!(0, node_fs.existsSync)(this.cacheFolder)) {
4712
+ const storage = getComfyStorage();
4713
+ if (!storage.exists(this.cacheFolder)) {
4410
4714
  console.log("🟢 creating folder", this.cacheFolder);
4411
- (0, node_fs.mkdirSync)(this.cacheFolder, { recursive: true });
4715
+ storage.mkdirp(this.cacheFolder);
4412
4716
  }
4413
4717
  this.comfyJSONPath = comfyts.resolve(this.cacheFolder, `object_info.json`);
4414
4718
  this.embeddingsPath = comfyts.resolve(this.cacheFolder, `embeddings.json`);
@@ -4458,19 +4762,20 @@ var ComfyHost = class {
4458
4762
  }
4459
4763
  async writeSDKToDisk() {
4460
4764
  if (this.data.sdkAutoWrite === false) return;
4765
+ const storage = getComfyStorage();
4461
4766
  const comfySchemaTs = this.schema.codegenDTS({ hostId: this.data.id });
4462
- if ((0, node_fs.existsSync)(this.sdkDTSPath) && (0, node_fs.readFileSync)(this.sdkDTSPath, "utf-8") === comfySchemaTs) return;
4463
- await writeFileAsync(this.sdkDTSPath, comfySchemaTs, "utf-8");
4767
+ if (storage.readTextIfExists(this.sdkDTSPath) === comfySchemaTs) return;
4768
+ storage.writeText(this.sdkDTSPath, comfySchemaTs);
4464
4769
  }
4465
4770
  shouldUseSchemaCache() {
4466
4771
  if (this._schemaStrategy === "refresh") return false;
4467
- const exists = (0, node_fs.existsSync)(this.comfyJSONPath);
4772
+ const mtimeMs = getComfyStorage().mtimeMs(this.comfyJSONPath);
4468
4773
  if (this._schemaStrategy === "cache") {
4469
- if (!exists) throw new Error(`connect({schema:'cache'}) but no cache at ${this.comfyJSONPath}`);
4774
+ if (mtimeMs == null) throw new Error(`connect({schema:'cache'}) but no cache at ${this.comfyJSONPath}`);
4470
4775
  return true;
4471
4776
  }
4472
- if (!exists) return false;
4473
- return Date.now() - (0, node_fs.statSync)(this.comfyJSONPath).mtimeMs < this._schemaMaxAgeMs;
4777
+ if (mtimeMs == null) return false;
4778
+ return Date.now() - mtimeMs < this._schemaMaxAgeMs;
4474
4779
  }
4475
4780
  waitForSession(timeoutMs = 5e3) {
4476
4781
  if (this.comfySessionId !== "temp") return Promise.resolve();
@@ -4505,6 +4810,7 @@ var ComfyHost = class {
4505
4810
  onMessage: (e) => this.onMessage(e),
4506
4811
  url: () => this.getWSUrl(),
4507
4812
  headers: () => this.authHeaders(),
4813
+ onTransportDead: (e) => this.markFailed(e),
4508
4814
  onClose: () => {
4509
4815
  logInfo(`[👢] WEBSOCKET: closed connection to ComfyUI host ${this.data.id}`);
4510
4816
  }
@@ -4524,7 +4830,7 @@ var ComfyHost = class {
4524
4830
  * examples must still open in the TUI; run() fetches the real schema through
4525
4831
  * connect() anyway). Not memoized in that case, so a later gen/connect retries. */
4526
4832
  loadSchemaFromCache() {
4527
- if (this._schemaFromCache == null && !(0, node_fs.existsSync)(this.comfyJSONPath)) {
4833
+ if (this._schemaFromCache == null && !getComfyStorage().exists(this.comfyJSONPath)) {
4528
4834
  logError(`no schema cache for host '${this.data.id}' at ${this.comfyJSONPath} — continuing with base types (no node/model unions); run \`comfy-ts gen --id ${this.data.id} --host <url>\` or connect() once to create it`);
4529
4835
  return Promise.resolve();
4530
4836
  }
@@ -4536,7 +4842,7 @@ var ComfyHost = class {
4536
4842
  embeddings: embeddings_json
4537
4843
  });
4538
4844
  this.schema.RUN_BASIC_CHECKS();
4539
- if (!(0, node_fs.existsSync)(this.sdkDTSPath)) await this.writeSDKToDisk();
4845
+ if (!getComfyStorage().exists(this.sdkDTSPath)) await this.writeSDKToDisk();
4540
4846
  })().catch((e) => {
4541
4847
  this._schemaFromCache = null;
4542
4848
  throw e;
@@ -4628,55 +4934,13 @@ var ComfyHost = class {
4628
4934
  };
4629
4935
  //#endregion
4630
4936
  //#region src/utils/downloadFile.ts
4631
- /** Usage example
4632
- * | ;(async () => {
4633
- * | try {
4634
- * | await downloadFile('https://example.com/file', 'folder/filename')
4635
- * | console.log('Download completed successfully')
4636
- * | } catch (error) {
4637
- * | console.error('Download failed:', error)
4638
- * | }
4639
- * | })()
4640
- * |
4641
- */
4642
- function downloadFile(url, outputPath, logPrefix = " - ") {
4643
- (0, node_fs.mkdirSync)((0, pathe.dirname)(outputPath), { recursive: true });
4644
- return new Promise((resolve, reject) => {
4645
- node_https.default.get(url, (response) => {
4646
- if (response.statusCode === 302 || response.statusCode === 301) {
4647
- const newUrl = response.headers.location;
4648
- console.log(`Redirected to ${newUrl}`);
4649
- resolve(downloadFile(newUrl, outputPath));
4650
- return;
4651
- }
4652
- if (response.statusCode !== 200) {
4653
- reject(`Failed to download file: Status Code ${response.statusCode}`);
4654
- return;
4655
- }
4656
- const rawLen = response.headers["content-length"];
4657
- if (rawLen == null) console.warn(`download file: progress not available because no content-length header in response.`);
4658
- else {
4659
- const totalSize = parseInt(rawLen, 10);
4660
- let downloaded = 0;
4661
- let lastLoggedPercentage = 0;
4662
- response.on("data", (chunk) => {
4663
- downloaded += chunk.length;
4664
- const percentage = Math.round(downloaded / totalSize * 100);
4665
- if (percentage >= lastLoggedPercentage + 1) {
4666
- node_process.stdout.write(`\r${logPrefix}${percentage}% downloaded`);
4667
- lastLoggedPercentage = percentage;
4668
- }
4669
- });
4670
- }
4671
- const fileStream = node_fs.default.createWriteStream(outputPath);
4672
- response.pipe(fileStream);
4673
- fileStream.on("finish", () => {
4674
- console.log(` (DONE)`);
4675
- fileStream.close();
4676
- resolve(true);
4677
- });
4678
- }).on("error", (err) => reject(err));
4679
- });
4937
+ async function downloadFile(url, outputPath, logPrefix = " - ") {
4938
+ const res = await fetch(url);
4939
+ if (!res.ok) throw new Error(`Failed to download ${url}: HTTP ${res.status}`);
4940
+ const bytes = new Uint8Array(await res.arrayBuffer());
4941
+ getComfyStorage().writeBytes(outputPath, bytes);
4942
+ console.log(`${logPrefix}${(bytes.length / 1024).toFixed(0)}kB (DONE)`);
4943
+ return true;
4680
4944
  }
4681
4945
  //#endregion
4682
4946
  //#region src/manager/loaders/step1_downloadComfyManagerJSONs.ts
@@ -4797,7 +5061,7 @@ const ComfyManagerRawPluginInfo_ark = (0, arktype.type)({
4797
5061
  const _getKnownPlugins = (DB) => {
4798
5062
  const counter = DB.report.file("custom-node-list.json");
4799
5063
  let totalFileSeen = 0;
4800
- const root = ComfyManagerFilePluginListRoot_ark(JSON.parse((0, node_fs.readFileSync)("src/manager/json/custom-node-list.json", "utf8")));
5064
+ const root = ComfyManagerFilePluginListRoot_ark(JSON.parse(getComfyStorage().readText("src/manager/json/custom-node-list.json")));
4801
5065
  if (root instanceof arktype.type.errors) throw new ManagerParseError("custom-node-list.json", root.summary);
4802
5066
  const canonical = [];
4803
5067
  for (const row of root.custom_nodes) {
@@ -4835,7 +5099,7 @@ const _getKnownPlugins = (DB) => {
4835
5099
  }
4836
5100
  out1 += "\n";
4837
5101
  const out1Path = "src/manager/generated/KnownComfyPluginTitle.ts";
4838
- (0, node_fs.writeFileSync)(out1Path, out1 + "\n", "utf-8");
5102
+ getComfyStorage().writeText(out1Path, out1 + "\n");
4839
5103
  console.log(` > generated: ${ansi.blue.underline(out1Path)}`);
4840
5104
  let out2 = "";
4841
5105
  const sortedFileNames = [...DB.plugins_byFile.keys()].sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
@@ -4843,7 +5107,7 @@ const _getKnownPlugins = (DB) => {
4843
5107
  out2 += "export type KnownComfyPluginURL =\n";
4844
5108
  for (const fileName of sortedFileNames) out2 += ` | ${JSON.stringify(fileName)}\n`;
4845
5109
  const out2Path = "src/manager/generated/KnownComfyPluginURL.ts";
4846
- (0, node_fs.writeFileSync)(out2Path, out2, "utf-8");
5110
+ getComfyStorage().writeText(out2Path, out2);
4847
5111
  console.log(` > generated: ${ansi.blue.underline(out2Path)}`);
4848
5112
  }
4849
5113
  if (DB.opts.check) {
@@ -4889,7 +5153,7 @@ const ComfyManagerExtensionNodeMapEntry_ark = (0, arktype.type)([ComfyManagerPlu
4889
5153
  const _getCustomNodeRegistry = (DB) => {
4890
5154
  const counter = DB.report.file("extension-node-map.json");
4891
5155
  let totalCustomNodeSeen = 0;
4892
- const raw = JSON.parse((0, node_fs.readFileSync)("src/manager/json/extension-node-map.json", "utf8"));
5156
+ const raw = JSON.parse(getComfyStorage().readText("src/manager/json/extension-node-map.json"));
4893
5157
  const root = (0, arktype.type)("Record<string, unknown>")(raw);
4894
5158
  if (root instanceof arktype.type.errors) throw new ManagerParseError("extension-node-map.json", root.summary);
4895
5159
  for (const [url, value] of Object.entries(root)) {
@@ -4925,7 +5189,7 @@ const _getCustomNodeRegistry = (DB) => {
4925
5189
  for (const nodeName of sortedNodeKeys) out += ` | ${JSON.stringify(nodeName)}\n`;
4926
5190
  out += "\n";
4927
5191
  const outPath = "src/manager/generated/KnownComfyCustomNodeName.ts";
4928
- (0, node_fs.writeFileSync)(outPath, out + "\n", "utf-8");
5192
+ getComfyStorage().writeText(outPath, out + "\n");
4929
5193
  console.log(` > generated: ${ansi.blue.underline(outPath)}`);
4930
5194
  }
4931
5195
  if (DB.opts.check) {
@@ -4980,7 +5244,7 @@ const ComfyManagerModelInfo_ark = (0, arktype.type)({
4980
5244
  //#region src/manager/loaders/step4_model-list-loader.ts
4981
5245
  const _getKnownModels = (DB) => {
4982
5246
  const counter = DB.report.file("model-list.json");
4983
- const root = ComfyManagerFileModelInfoRoot_ark(JSON.parse((0, node_fs.readFileSync)("src/manager/json/model-list.json", "utf8")));
5247
+ const root = ComfyManagerFileModelInfoRoot_ark(JSON.parse(getComfyStorage().readText("src/manager/json/model-list.json")));
4984
5248
  if (root instanceof arktype.type.errors) throw new ManagerParseError("model-list.json", root.summary);
4985
5249
  const canonical = [];
4986
5250
  for (const row of root.models) {
@@ -5009,7 +5273,7 @@ const _getKnownModels = (DB) => {
5009
5273
  for (const [cat, count] of Object.entries(uniqCategories)) out1 += ` ${JSON.stringify(cat).padEnd(20)}, // x ${count.toString().padStart(3)}\n`;
5010
5274
  out1 += "]\n";
5011
5275
  const out1Path = "src/manager/generated/KnownModel_Type.ts";
5012
- (0, node_fs.writeFileSync)(out1Path, out1 + "\n", "utf-8");
5276
+ getComfyStorage().writeText(out1Path, out1 + "\n");
5013
5277
  console.log(` > generated: ${ansi.blue.underline(out1Path)}`);
5014
5278
  let out4 = "";
5015
5279
  const uniqSavePath = knownModelList.reduce((acc, cur) => {
@@ -5025,7 +5289,7 @@ const _getKnownModels = (DB) => {
5025
5289
  for (const [cat, count] of Object.entries(uniqSavePath)) out4 += ` ${JSON.stringify(cat).padEnd(50)}, // x ${count.toString().padStart(3)}\n`;
5026
5290
  out4 += "]\n";
5027
5291
  const out4Path = "src/manager/generated/KnownModel_SavePath.ts";
5028
- (0, node_fs.writeFileSync)(out4Path, out4 + "\n", "utf-8");
5292
+ getComfyStorage().writeText(out4Path, out4 + "\n");
5029
5293
  console.log(` > generated: ${ansi.blue.underline(out4Path)}`);
5030
5294
  let out2 = "";
5031
5295
  const uniqBases = knownModelList.reduce((acc, cur) => {
@@ -5042,7 +5306,7 @@ const _getKnownModels = (DB) => {
5042
5306
  for (const [cat, count] of Object.entries(uniqBases)) out2 += ` ${JSON.stringify(cat).padEnd(20)}, // x ${count.toString().padStart(3)}\n`;
5043
5307
  out2 += "]\n";
5044
5308
  const out2Path = "src/manager/generated/KnownModel_Base.ts";
5045
- (0, node_fs.writeFileSync)(out2Path, out2 + "\n", "utf-8");
5309
+ getComfyStorage().writeText(out2Path, out2 + "\n");
5046
5310
  console.log(` > generated: ${ansi.blue.underline(out2Path)}`);
5047
5311
  let out3 = "";
5048
5312
  const sortedModels = knownModelList.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()));
@@ -5057,7 +5321,7 @@ const _getKnownModels = (DB) => {
5057
5321
  }
5058
5322
  out3 += "\n";
5059
5323
  const out3Path = "src/manager/generated/KnownModel_Name.ts";
5060
- (0, node_fs.writeFileSync)(out3Path, out3 + "\n", "utf-8");
5324
+ getComfyStorage().writeText(out3Path, out3 + "\n");
5061
5325
  console.log(` > generated: ${ansi.blue.underline(out3Path)}`);
5062
5326
  let out99 = "";
5063
5327
  out99 += `// prettier-ignore\n`;
@@ -5071,7 +5335,7 @@ const _getKnownModels = (DB) => {
5071
5335
  }
5072
5336
  out99 += "\n";
5073
5337
  const out99Path = "src/manager/generated/KnownModel_FileName.ts";
5074
- (0, node_fs.writeFileSync)(out99Path, out99 + "\n", "utf-8");
5338
+ getComfyStorage().writeText(out99Path, out99 + "\n");
5075
5339
  console.log(` > generated: ${ansi.blue.underline(out99Path)}`);
5076
5340
  }
5077
5341
  if (DB.opts.check) {
@@ -5092,7 +5356,7 @@ const ComfyManagerFileAlterListRoot_ark = (0, arktype.type)({ items: "unknown[]"
5092
5356
  //#region src/manager/loaders/step5_alter-list-loader.ts
5093
5357
  const _getAlterList = (DB) => {
5094
5358
  const counter = DB.report.file("alter-list.json");
5095
- const root = ComfyManagerFileAlterListRoot_ark(JSON.parse((0, node_fs.readFileSync)("src/manager/json/alter-list.json", "utf8")));
5359
+ const root = ComfyManagerFileAlterListRoot_ark(JSON.parse(getComfyStorage().readText("src/manager/json/alter-list.json")));
5096
5360
  if (root instanceof arktype.type.errors) throw new ManagerParseError("alter-list.json", root.summary);
5097
5361
  const canonical = [];
5098
5362
  for (const row of root.items) {
@@ -5117,7 +5381,7 @@ const ComfyManagerGithubStatEntry_ark = (0, arktype.type)({
5117
5381
  //#region src/manager/loaders/step6_github-stats-loader.ts
5118
5382
  const _getGithubStats = (DB) => {
5119
5383
  const counter = DB.report.file("github-stats.json");
5120
- const raw = JSON.parse((0, node_fs.readFileSync)("src/manager/json/github-stats.json", "utf8"));
5384
+ const raw = JSON.parse(getComfyStorage().readText("src/manager/json/github-stats.json"));
5121
5385
  const root = (0, arktype.type)("Record<string, unknown>")(raw);
5122
5386
  if (root instanceof arktype.type.errors) throw new ManagerParseError("github-stats.json", root.summary);
5123
5387
  for (const [url, value] of Object.entries(root)) {
@@ -5232,13 +5496,12 @@ var ComfyTS = class ComfyTS {
5232
5496
  this.version = version;
5233
5497
  this.hosts = /* @__PURE__ */ new Map();
5234
5498
  this._registry = null;
5235
- this.rootPath = asAbsolutePath(process.cwd());
5236
5499
  this.readJSON_ = (absPath, def) => {
5237
- if (!(0, node_fs.existsSync)(absPath)) {
5500
+ const str = this.storage.readTextIfExists(absPath);
5501
+ if (str == null) {
5238
5502
  if (def != null) return def;
5239
5503
  throw new Error(`file does not exist ${absPath}`);
5240
5504
  }
5241
- const str = (0, node_fs.readFileSync)(absPath, "utf8");
5242
5505
  return JSON.parse(str);
5243
5506
  };
5244
5507
  this.autolayoutOpts = {
@@ -5249,7 +5512,8 @@ var ComfyTS = class ComfyTS {
5249
5512
  const globalHack = globalThis;
5250
5513
  if (globalHack.comfyts != null) throw new Error("ComfyTS instance already created");
5251
5514
  globalHack.comfyts = this;
5252
- if (p.rootPath) this.rootPath = asAbsolutePath(p.rootPath);
5515
+ this.storage = resolveComfyStorage(p.storage);
5516
+ this.rootPath = asAbsolutePath(p.rootPath ?? this.storage.cwd());
5253
5517
  this.baseFolder = asAbsolutePath((0, pathe.join)(this.rootPath, ".comfy-ts"));
5254
5518
  this.hostsFolder = asAbsolutePath((0, pathe.join)(this.baseFolder, "hosts"));
5255
5519
  this.outputPath = asAbsolutePath((0, pathe.join)(this.baseFolder, "outputs"));
@@ -5313,6 +5577,18 @@ var ComfyTS = class ComfyTS {
5313
5577
  }
5314
5578
  };
5315
5579
  //#endregion
5580
+ //#region src/utils/loraTag.ts
5581
+ /**
5582
+ * build a LoraManager-style lora tag: `<lora:name:strength>` or
5583
+ * `<lora:name:strength:clipStrength>`. Pin the name to a host union for
5584
+ * autocomplete + validation:
5585
+ *
5586
+ * loraTag<Comfy.Windows1.Union['E_LoraName']>('myLora', 0.8)
5587
+ */
5588
+ function loraTag(name, strength = 1, clipStrength) {
5589
+ return clipStrength == null ? `<lora:${name}:${strength}>` : `<lora:${name}:${strength}:${clipStrength}>`;
5590
+ }
5591
+ //#endregion
5316
5592
  //#region src/exampleAssets.ts
5317
5593
  /**
5318
5594
  * the examples/ folder shipped in the npm tarball, resolved from THIS module's
@@ -5365,17 +5641,12 @@ function isTuiActive() {
5365
5641
  return process.env[COMFY_TS_TUI_ENV] === "1";
5366
5642
  }
5367
5643
  //#endregion
5368
- //#region src/utils/loraTag.ts
5644
+ //#region src/index.ts
5369
5645
  /**
5370
- * build a LoraManager-style lora tag: `<lora:name:strength>` or
5371
- * `<lora:name:strength:clipStrength>`. Pin the name to a host union for
5372
- * autocomplete + validation:
5373
- *
5374
- * loraTag<Comfy.Windows1.Union['E_LoraName']>('myLora', 0.8)
5646
+ * comfy-ts — type-safe ComfyUI workflow creation and execution (NODE entry)
5647
+ * @packageDocumentation
5375
5648
  */
5376
- function loraTag(name, strength = 1, clipStrength) {
5377
- return clipStrength == null ? `<lora:${name}:${strength}>` : `<lora:${name}:${strength}:${clipStrength}>`;
5378
- }
5649
+ setDefaultComfyStorage(createNodeStorage());
5379
5650
  //#endregion
5380
5651
  exports.ChoiceVar = ChoiceVar;
5381
5652
  exports.ComfyExecution = ComfyExecution;
@@ -5421,7 +5692,9 @@ exports.auto_ = auto_;
5421
5692
  exports.codegenSDK = codegenSDK;
5422
5693
  exports.convertFlowToLiteGraphJSON = convertFlowToLiteGraphJSON;
5423
5694
  exports.convertLiteGraphToPrompt = convertLiteGraphToPrompt;
5695
+ exports.createMemoryStorage = createMemoryStorage;
5424
5696
  exports.exampleImagePath = exampleImagePath;
5697
+ exports.getComfyStorage = getComfyStorage;
5425
5698
  exports.getLoraKeyword = getLoraKeyword;
5426
5699
  exports.hostIdToNamespace = hostIdToNamespace;
5427
5700
  exports.isTuiActive = isTuiActive;
@@ -5433,6 +5706,7 @@ exports.renderHttpBase = renderHttpBase;
5433
5706
  exports.renderWsUrl = renderWsUrl;
5434
5707
  exports.resultFailure = resultFailure;
5435
5708
  exports.resultSuccess = resultSuccess;
5709
+ exports.setDefaultComfyStorage = setDefaultComfyStorage;
5436
5710
  exports.setLoraKeyword = setLoraKeyword;
5437
5711
  exports.v = v;
5438
5712