comfy-ts 2.3.0 → 2.4.1

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 (54) hide show
  1. package/README.md +13 -0
  2. package/dist/{DefinedWorkflow-CwHInZgn.js → DefinedWorkflow-QrhT6V66.js} +441 -9
  3. package/dist/DefinedWorkflow-QrhT6V66.js.map +1 -0
  4. package/dist/{DraftsSt-omWuBSej.js → DraftsSt-D9Fhk4qR.js} +2 -2
  5. package/dist/{DraftsSt-omWuBSej.js.map → DraftsSt-D9Fhk4qR.js.map} +1 -1
  6. package/dist/cli.js +116 -8
  7. package/dist/cli.js.map +1 -1
  8. package/dist/index.cjs +268 -23
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +150 -9
  11. package/dist/index.d.ts +150 -9
  12. package/dist/index.js +257 -24
  13. package/dist/index.js.map +1 -1
  14. package/dist/{run-serve-CfzOH-AR.js → run-serve-C9E8dyLP.js} +3 -3
  15. package/dist/run-serve-C9E8dyLP.js.map +1 -0
  16. package/dist/{run-tui-_LD0DoGe.js → run-tui-8si-rVW0.js} +60 -121
  17. package/dist/run-tui-8si-rVW0.js.map +1 -0
  18. package/dist/{state-C-OOEcp3.js → state-C0ARiFFM.js} +15 -76
  19. package/dist/state-C0ARiFFM.js.map +1 -0
  20. package/dist/web.d.ts +150 -9
  21. package/dist/web.js +257 -24
  22. package/dist/web.js.map +1 -1
  23. package/guide-for-agents.md +3 -0
  24. package/package.json +2 -1
  25. package/src/cli/comfy-ts-cli.ts +16 -1
  26. package/src/cli/flags.ts +14 -0
  27. package/src/cli/gen.ts +2 -4
  28. package/src/cli/loras.ts +113 -0
  29. package/src/cli/serve/applyVarPayload.ts +1 -1
  30. package/src/cli/tui/components/LorasOverlay.tsx +18 -5
  31. package/src/cli/tui/components/StatusBar.tsx +1 -0
  32. package/src/cli/tui/components/TuiApp.tsx +1 -0
  33. package/src/cli/tui/imageClipboard.ts +3 -3
  34. package/src/cli/tui/protocolImagePainter.ts +1 -1
  35. package/src/cli/tui/run-tui.tsx +2 -2
  36. package/src/cli/tui/state/ExecSt.ts +2 -2
  37. package/src/cli/tui/state/HostSt.ts +1 -1
  38. package/src/cli/tui/state/LorasSt.ts +60 -15
  39. package/src/cli/tui/state/PreviewSt.ts +1 -1
  40. package/src/cli/tui/state/SettingsSt.ts +1 -1
  41. package/src/coreExports.ts +20 -1
  42. package/src/host/ComfyHost.ts +10 -1
  43. package/src/host/ResilientWebsocket.ts +20 -0
  44. package/src/host/loraInfoCache.ts +216 -0
  45. package/src/host/loraManagerApi.ts +131 -27
  46. package/src/runner/ComfyExecution.ts +1 -1
  47. package/src/runner/outputPath.ts +3 -3
  48. package/src/utils/isRecord.ts +4 -0
  49. package/src/vars/ComfyVars.ts +13 -7
  50. package/src/vars/loraKeywords.ts +48 -5
  51. package/dist/DefinedWorkflow-CwHInZgn.js.map +0 -1
  52. package/dist/run-serve-CfzOH-AR.js.map +0 -1
  53. package/dist/run-tui-_LD0DoGe.js.map +0 -1
  54. package/dist/state-C-OOEcp3.js.map +0 -1
@@ -1,77 +1,8 @@
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";
1
+ import { A as sha1HexOfString, C as getComfyStorage, D as logInfo, E as logError, O as logSuccess, S as extractErrorMessage, T as isQuiet, k as sha1Hex, t as DefinedWorkflow, w as resolveComfyStorage } from "./DefinedWorkflow-QrhT6V66.js";
2
2
  import { basename, join } from "pathe";
3
3
  import { scope, type } from "arktype";
4
4
  import { nanoid } from "nanoid";
5
5
  import { imageMeta } from "image-meta";
6
- //#region src/utils/sha1.ts
7
- function sha1Hex(data) {
8
- const ml = data.length;
9
- const total = Math.ceil((ml + 1 + 8) / 64) * 64;
10
- const bytes = new Uint8Array(total);
11
- bytes.set(data);
12
- bytes[ml] = 128;
13
- const dv = new DataView(bytes.buffer);
14
- const bitLen = ml * 8;
15
- dv.setUint32(total - 8, Math.floor(bitLen / 2 ** 32));
16
- dv.setUint32(total - 4, bitLen >>> 0);
17
- let h0 = 1732584193;
18
- let h1 = 4023233417;
19
- let h2 = 2562383102;
20
- let h3 = 271733878;
21
- let h4 = 3285377520;
22
- const w = /* @__PURE__ */ new Uint32Array(80);
23
- for (let i = 0; i < total; i += 64) {
24
- for (let j = 0; j < 16; j++) w[j] = dv.getUint32(i + j * 4);
25
- for (let j = 16; j < 80; j++) {
26
- const n = (w[j - 3] ?? 0) ^ (w[j - 8] ?? 0) ^ (w[j - 14] ?? 0) ^ (w[j - 16] ?? 0);
27
- w[j] = n << 1 | n >>> 31;
28
- }
29
- let a = h0;
30
- let b = h1;
31
- let c = h2;
32
- let d = h3;
33
- let e = h4;
34
- for (let j = 0; j < 80; j++) {
35
- let f;
36
- let k;
37
- if (j < 20) {
38
- f = b & c | ~b & d;
39
- k = 1518500249;
40
- } else if (j < 40) {
41
- f = b ^ c ^ d;
42
- k = 1859775393;
43
- } else if (j < 60) {
44
- f = b & c | b & d | c & d;
45
- k = 2400959708;
46
- } else {
47
- f = b ^ c ^ d;
48
- k = 3395469782;
49
- }
50
- const temp = (a << 5 | a >>> 27) + f + e + k + (w[j] ?? 0) >>> 0;
51
- e = d;
52
- d = c;
53
- c = b << 30 | b >>> 2;
54
- b = a;
55
- a = temp;
56
- }
57
- h0 = h0 + a >>> 0;
58
- h1 = h1 + b >>> 0;
59
- h2 = h2 + c >>> 0;
60
- h3 = h3 + d >>> 0;
61
- h4 = h4 + e >>> 0;
62
- }
63
- return [
64
- h0,
65
- h1,
66
- h2,
67
- h3,
68
- h4
69
- ].map((x) => x.toString(16).padStart(8, "0")).join("");
70
- }
71
- function sha1HexOfString(s) {
72
- return sha1Hex(new TextEncoder().encode(s));
73
- }
74
- //#endregion
75
6
  //#region src/sdk-generator/_getUnionNameBasedOnFirstFoundEnumName.ts
76
7
  /** having a bunch of sensible default will help slightly */
77
8
  function getUnionNameBasedOnFirstFoundEnumName(enumName, hash, hashContent) {
@@ -884,7 +815,7 @@ var ComfySchema = class {
884
815
  };
885
816
  //#endregion
886
817
  //#region package.json
887
- var version = "2.3.0";
818
+ var version = "2.4.1";
888
819
  //#endregion
889
820
  //#region src/litegraph/LiteGraphLinkID.ts
890
821
  const asLiteGraphLinkID = (id) => id;
@@ -2198,8 +2129,8 @@ var LiteGraphCtx = class {
2198
2129
  //#endregion
2199
2130
  //#region src/runner/outputPath.ts
2200
2131
  /**
2201
- * local output naming, relative to `.comfy-ts/outputs/` (his repro
2202
- * 2026-07-31): the server filename is NOT unique — cloud hosts reset the
2132
+ * local output naming, relative to `.comfy-ts/outputs/`:
2133
+ * the server filename is NOT unique — cloud hosts reset the
2203
2134
  * `_00001_` counter every run, so trusting it overwrote the same file — and
2204
2135
  * a `foo/krea/` prefix means the DIRECTORY foo/krea/, not a `krea_` name
2205
2136
  * prefix. Local names are ours: dir from the prompt's own filename_prefix
@@ -2244,7 +2175,7 @@ const withExtension = (path, ext) => {
2244
2175
  /**
2245
2176
  * never-overwrite guard: bump `-2`, `-3`, … while the path exists on disk OR
2246
2177
  * was already CLAIMED by a still-downloading retrieval (two same-second runs
2247
- * on a counter-resetting cloud host compute the same name — reviewer catch).
2178
+ * on a counter-resetting cloud host compute the same name).
2248
2179
  * The chosen path is claimed before returning.
2249
2180
  */
2250
2181
  const uniquifyOutputPath = (p) => {
@@ -3670,6 +3601,7 @@ var ResilientWebSocketClient = class {
3670
3601
  this.messageBuffer = [];
3671
3602
  this.isOpen = false;
3672
3603
  this.debugMessages = [];
3604
+ this.hasEverOpened = false;
3673
3605
  this.permanentlyClosed = false;
3674
3606
  this.url = options.url();
3675
3607
  this.connect();
@@ -3721,6 +3653,7 @@ var ResilientWebSocketClient = class {
3721
3653
  ws.onopen = () => {
3722
3654
  if (ws !== this.currentWS) return;
3723
3655
  this.addInfo("✅ WebSocket connected to " + this.url);
3656
+ this.hasEverOpened = true;
3724
3657
  this.isOpen = true;
3725
3658
  this.options.onConnectOrReconnect();
3726
3659
  this.flushMessageBuffer();
@@ -3731,6 +3664,11 @@ var ResilientWebSocketClient = class {
3731
3664
  this.options.onClose();
3732
3665
  if (this.permanentlyClosed) return;
3733
3666
  this.addError(`WebSocket closed (reason=${JSON.stringify(event.reason)}, code=${event.code})`);
3667
+ if (!this.hasEverOpened && this.options.onFirstConnectFailed != null) {
3668
+ this.permanentlyClosed = true;
3669
+ this.options.onFirstConnectFailed(/* @__PURE__ */ new Error(`connection refused (code=${event.code}${event.reason === "" ? "" : `, ${event.reason}`})`));
3670
+ return;
3671
+ }
3734
3672
  this.addInfo("⏱️ reconnecting in 2 seconds...");
3735
3673
  this.reconnectTimeout = setTimeout(() => void this.connect(), 2e3);
3736
3674
  };
@@ -4145,6 +4083,7 @@ var ComfyHost = class {
4145
4083
  url: () => this.getWSUrl(),
4146
4084
  headers: () => this.authHeaders(),
4147
4085
  onTransportDead: (e) => this.markFailed(e),
4086
+ onFirstConnectFailed: (e) => this.markFailed(new ComfyHostUnreachableError(`host '${this.data.id}' is not reachable at ${this.getWSUrl()} — ${extractErrorMessage(e)}. Is ComfyUI running there ?`)),
4148
4087
  onClose: () => {
4149
4088
  logInfo(`[👢] WEBSOCKET: closed connection to ComfyUI host ${this.data.id}`);
4150
4089
  }
@@ -4928,6 +4867,6 @@ var ComfyTS = class ComfyTS {
4928
4867
  }
4929
4868
  };
4930
4869
  //#endregion
4931
- export { importSharp as a, stripAnsi as i, settingsPathFor as n, ComfySchema as o, readableStringify as r, sha1HexOfString as s, ComfyTS as t };
4870
+ export { importSharp as a, stripAnsi as i, settingsPathFor as n, ComfySchema as o, readableStringify as r, ComfyTS as t };
4932
4871
 
4933
- //# sourceMappingURL=state-C-OOEcp3.js.map
4872
+ //# sourceMappingURL=state-C0ARiFFM.js.map