comfy-ts 2.1.0 → 2.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 +65 -225
- package/dist/{DefinedWorkflow-CqNE_kgR.js → DefinedWorkflow-CwHInZgn.js} +4 -3
- package/dist/DefinedWorkflow-CwHInZgn.js.map +1 -0
- package/dist/{DraftsSt-C-gBk9v7.js → DraftsSt-omWuBSej.js} +2 -2
- package/dist/{DraftsSt-C-gBk9v7.js.map → DraftsSt-omWuBSej.js.map} +1 -1
- package/dist/cli.js +3 -3
- package/dist/index.cjs +54 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -3
- package/dist/index.d.ts +28 -3
- package/dist/index.js +54 -7
- package/dist/index.js.map +1 -1
- package/dist/{run-serve-CnlN_RFH.js → run-serve-CfzOH-AR.js} +174 -126
- package/dist/run-serve-CfzOH-AR.js.map +1 -0
- package/dist/{run-tui-DXI_Jufu.js → run-tui-_LD0DoGe.js} +49 -50
- package/dist/run-tui-_LD0DoGe.js.map +1 -0
- package/dist/{state-DC5BcG6d.js → state-C-OOEcp3.js} +54 -8
- package/dist/state-C-OOEcp3.js.map +1 -0
- package/dist/web.d.ts +28 -3
- package/dist/web.js +54 -7
- package/dist/web.js.map +1 -1
- package/examples/README.md +6 -18
- package/examples/images/README.md +2 -6
- package/guide-for-agents.md +25 -84
- package/package.json +1 -1
- package/src/cli/serve/ServeApp.ts +21 -11
- package/src/cli/serve/applyVarPayload.ts +91 -71
- package/src/cli/serve/describeVar.ts +57 -28
- package/src/cli/tui/components/StatusBar.tsx +1 -0
- package/src/cli/tui/components/TextOverlay.tsx +7 -3
- package/src/cli/tui/components/VarsPanel.tsx +2 -2
- package/src/cli/tui/state/ExecSt.ts +47 -52
- package/src/cli/tui/state/TuiSt.ts +11 -6
- package/src/coreExports.ts +1 -0
- package/src/host/ComfyHost.ts +55 -3
- package/src/runner/ComfyExecution.ts +15 -7
- package/src/runner/outputPath.ts +11 -0
- package/src/vars/ComfyVars.ts +12 -2
- package/dist/DefinedWorkflow-CqNE_kgR.js.map +0 -1
- package/dist/run-serve-CnlN_RFH.js.map +0 -1
- package/dist/run-tui-DXI_Jufu.js.map +0 -1
- package/dist/state-DC5BcG6d.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as resolveComfyStorage, d as logInfo, f as logSuccess, l as isQuiet, o as extractErrorMessage, s as getComfyStorage, t as DefinedWorkflow, u as logError } from "./DefinedWorkflow-CwHInZgn.js";
|
|
2
2
|
import { basename, join } from "pathe";
|
|
3
3
|
import { scope, type } from "arktype";
|
|
4
4
|
import { nanoid } from "nanoid";
|
|
@@ -884,7 +884,7 @@ var ComfySchema = class {
|
|
|
884
884
|
};
|
|
885
885
|
//#endregion
|
|
886
886
|
//#region package.json
|
|
887
|
-
var version = "2.
|
|
887
|
+
var version = "2.3.0";
|
|
888
888
|
//#endregion
|
|
889
889
|
//#region src/litegraph/LiteGraphLinkID.ts
|
|
890
890
|
const asLiteGraphLinkID = (id) => id;
|
|
@@ -2232,6 +2232,15 @@ const localOutputPath = (p) => {
|
|
|
2232
2232
|
].filter((x) => x != null).join("_") + ext;
|
|
2233
2233
|
return dir === "" ? name : `${dir}/${name}`;
|
|
2234
2234
|
};
|
|
2235
|
+
/** REPLACE the extension (never append one): a re-encoded save owns its whole
|
|
2236
|
+
* name now that local naming is ours, so `save: {format:'image/webp'}` writes
|
|
2237
|
+
* `shot_20260731-154210_00001.webp`, not `…_00001.png.webp` — appending
|
|
2238
|
+
* described the bytes twice and the first description was a lie */
|
|
2239
|
+
const withExtension = (path, ext) => {
|
|
2240
|
+
const slash = path.lastIndexOf("/");
|
|
2241
|
+
const dot = path.lastIndexOf(".");
|
|
2242
|
+
return `${dot > slash ? path.slice(0, dot) : path}.${ext}`;
|
|
2243
|
+
};
|
|
2235
2244
|
/**
|
|
2236
2245
|
* never-overwrite guard: bump `-2`, `-3`, … while the path exists on disk OR
|
|
2237
2246
|
* was already CLAIMED by a still-downloading retrieval (two same-second runs
|
|
@@ -2619,7 +2628,9 @@ var MediaImage = class MediaImage {
|
|
|
2619
2628
|
//#endregion
|
|
2620
2629
|
//#region src/runner/ComfyExecution.ts
|
|
2621
2630
|
/** paths claimed by in-flight retrievals: two same-second runs on a
|
|
2622
|
-
* counter-resetting cloud host compute the same name before either writes
|
|
2631
|
+
* counter-resetting cloud host compute the same name before either writes.
|
|
2632
|
+
* A claim is released as soon as the write lands (the file itself then holds
|
|
2633
|
+
* the name) or fails (the name is free again) — the set never accumulates */
|
|
2623
2634
|
const CLAIMED_OUTPUT_PATHS = /* @__PURE__ */ new Set();
|
|
2624
2635
|
var ComfyExecution = class {
|
|
2625
2636
|
get host() {
|
|
@@ -2746,14 +2757,18 @@ var ComfyExecution = class {
|
|
|
2746
2757
|
filename: p.filename,
|
|
2747
2758
|
timestamp: runTimestamp(new Date(this.startedAt))
|
|
2748
2759
|
}));
|
|
2749
|
-
if (reencode) absPath
|
|
2760
|
+
if (reencode) absPath = withExtension(absPath, bang(bang(p.sf.format).split("/")[1]));
|
|
2750
2761
|
const storage = getComfyStorage();
|
|
2751
2762
|
absPath = uniquifyOutputPath({
|
|
2752
2763
|
path: absPath,
|
|
2753
2764
|
exists: (x) => storage.exists(x),
|
|
2754
2765
|
claimed: CLAIMED_OUTPUT_PATHS
|
|
2755
2766
|
});
|
|
2756
|
-
|
|
2767
|
+
try {
|
|
2768
|
+
storage.writeBytes(asAbsolutePath(absPath), bytes);
|
|
2769
|
+
} finally {
|
|
2770
|
+
CLAIMED_OUTPUT_PATHS.delete(absPath);
|
|
2771
|
+
}
|
|
2757
2772
|
return {
|
|
2758
2773
|
path: asAbsolutePath(absPath),
|
|
2759
2774
|
bytes
|
|
@@ -3738,6 +3753,14 @@ var ResilientWebSocketClient = class {
|
|
|
3738
3753
|
};
|
|
3739
3754
|
//#endregion
|
|
3740
3755
|
//#region src/host/ComfyHost.ts
|
|
3756
|
+
/** the host never came up within ConnectOptions.timeoutMs */
|
|
3757
|
+
var ComfyHostUnreachableError = class extends Error {
|
|
3758
|
+
constructor(..._args) {
|
|
3759
|
+
super(..._args);
|
|
3760
|
+
this.name = "ComfyHostUnreachableError";
|
|
3761
|
+
}
|
|
3762
|
+
};
|
|
3763
|
+
const DEFAULT_CONNECT_TIMEOUT_MS = 3e4;
|
|
3741
3764
|
/** auth failure with a SPECIFIC meaning (per the Comfy Cloud error table):
|
|
3742
3765
|
* 401 invalid/missing key · 402 insufficient credits · 429 subscription inactive
|
|
3743
3766
|
* (or plain rate limiting on non-cloud hosts). The key value never appears here. */
|
|
@@ -3887,14 +3910,25 @@ var ComfyHost = class {
|
|
|
3887
3910
|
this._readyResolve = res;
|
|
3888
3911
|
this._readyReject = rej;
|
|
3889
3912
|
});
|
|
3913
|
+
const timeoutMs = p.timeoutMs ?? DEFAULT_CONNECT_TIMEOUT_MS;
|
|
3914
|
+
if (timeoutMs > 0 && Number.isFinite(timeoutMs)) {
|
|
3915
|
+
this._connectTimer = setTimeout(() => {
|
|
3916
|
+
this.markFailed(new ComfyHostUnreachableError(`host '${this.data.id}' did not come up within ${timeoutMs}ms at ${this.getWSUrl()} — is ComfyUI running there ?`));
|
|
3917
|
+
}, timeoutMs);
|
|
3918
|
+
this._connectTimer.unref?.();
|
|
3919
|
+
}
|
|
3890
3920
|
this.initWebsocket();
|
|
3891
3921
|
}
|
|
3892
3922
|
return this._ready;
|
|
3893
3923
|
};
|
|
3924
|
+
this._connectTimer = null;
|
|
3894
3925
|
this.disconnect = () => {
|
|
3926
|
+
this.clearConnectTimer();
|
|
3895
3927
|
this.ws?.disconnectPermanently();
|
|
3896
3928
|
this.ws = null;
|
|
3897
3929
|
this._ready = null;
|
|
3930
|
+
this._readyResolve = null;
|
|
3931
|
+
this._readyReject = null;
|
|
3898
3932
|
};
|
|
3899
3933
|
this.ws = null;
|
|
3900
3934
|
this._sessionResolve = null;
|
|
@@ -4039,15 +4073,26 @@ var ComfyHost = class {
|
|
|
4039
4073
|
get isConnected() {
|
|
4040
4074
|
return this.ws?.isOpen ?? false;
|
|
4041
4075
|
}
|
|
4076
|
+
clearConnectTimer() {
|
|
4077
|
+
if (this._connectTimer != null) clearTimeout(this._connectTimer);
|
|
4078
|
+
this._connectTimer = null;
|
|
4079
|
+
}
|
|
4042
4080
|
markReady() {
|
|
4081
|
+
this.clearConnectTimer();
|
|
4043
4082
|
this._readyResolve?.();
|
|
4044
4083
|
this._readyResolve = null;
|
|
4045
4084
|
this._readyReject = null;
|
|
4046
4085
|
}
|
|
4047
4086
|
markFailed(error) {
|
|
4048
|
-
this.
|
|
4087
|
+
this.clearConnectTimer();
|
|
4088
|
+
const reject = this._readyReject;
|
|
4089
|
+
if (reject == null) return;
|
|
4049
4090
|
this._readyResolve = null;
|
|
4050
4091
|
this._readyReject = null;
|
|
4092
|
+
this._ready = null;
|
|
4093
|
+
this.ws?.disconnectPermanently();
|
|
4094
|
+
this.ws = null;
|
|
4095
|
+
reject(error);
|
|
4051
4096
|
}
|
|
4052
4097
|
async writeSDKToDisk() {
|
|
4053
4098
|
if (this.data.sdkAutoWrite === false) return;
|
|
@@ -4172,6 +4217,7 @@ var ComfyHost = class {
|
|
|
4172
4217
|
mime: frame.mime
|
|
4173
4218
|
});
|
|
4174
4219
|
}
|
|
4220
|
+
if (this.latentPreview != null) URL.revokeObjectURL(this.latentPreview.url);
|
|
4175
4221
|
const imageBlob = new Blob([frame.bytes], { type: frame.mime });
|
|
4176
4222
|
this.latentPreview = {
|
|
4177
4223
|
blob: imageBlob,
|
|
@@ -4882,6 +4928,6 @@ var ComfyTS = class ComfyTS {
|
|
|
4882
4928
|
}
|
|
4883
4929
|
};
|
|
4884
4930
|
//#endregion
|
|
4885
|
-
export {
|
|
4931
|
+
export { importSharp as a, stripAnsi as i, settingsPathFor as n, ComfySchema as o, readableStringify as r, sha1HexOfString as s, ComfyTS as t };
|
|
4886
4932
|
|
|
4887
|
-
//# sourceMappingURL=state-
|
|
4933
|
+
//# sourceMappingURL=state-C-OOEcp3.js.map
|