comfy-ts 2.4.0 → 2.4.2

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 (34) hide show
  1. package/dist/{DefinedWorkflow-QrhT6V66.js → DefinedWorkflow-CnzmQrBh.js} +45 -13
  2. package/dist/DefinedWorkflow-CnzmQrBh.js.map +1 -0
  3. package/dist/{DraftsSt-D9Fhk4qR.js → DraftsSt-C1MbWnEp.js} +2 -2
  4. package/dist/{DraftsSt-D9Fhk4qR.js.map → DraftsSt-C1MbWnEp.js.map} +1 -1
  5. package/dist/cli.js +18 -11
  6. package/dist/cli.js.map +1 -1
  7. package/dist/index.cjs +38 -14
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +27 -5
  10. package/dist/index.d.ts +27 -5
  11. package/dist/index.js +38 -15
  12. package/dist/index.js.map +1 -1
  13. package/dist/{run-serve-C9E8dyLP.js → run-serve-D47Zas-a.js} +3 -3
  14. package/dist/{run-serve-C9E8dyLP.js.map → run-serve-D47Zas-a.js.map} +1 -1
  15. package/dist/{run-tui-cawSJuuh.js → run-tui-BqNO9Ck0.js} +21 -12
  16. package/dist/run-tui-BqNO9Ck0.js.map +1 -0
  17. package/dist/{state-BbKuSDCV.js → state-D9w1aJow.js} +11 -3
  18. package/dist/{state-BbKuSDCV.js.map → state-D9w1aJow.js.map} +1 -1
  19. package/dist/web.d.ts +27 -5
  20. package/dist/web.js +38 -15
  21. package/dist/web.js.map +1 -1
  22. package/package.json +1 -1
  23. package/src/cli/loras.ts +20 -9
  24. package/src/cli/tui/components/TuiApp.tsx +1 -1
  25. package/src/cli/tui/protocolImagePainter.ts +1 -1
  26. package/src/cli/tui/state/ExecSt.ts +3 -3
  27. package/src/cli/tui/state/LorasSt.ts +19 -5
  28. package/src/coreExports.ts +1 -0
  29. package/src/host/ComfyHost.ts +9 -0
  30. package/src/host/ResilientWebsocket.ts +20 -0
  31. package/src/host/loraInfoCache.ts +34 -13
  32. package/src/host/loraManagerApi.ts +25 -4
  33. package/dist/DefinedWorkflow-QrhT6V66.js.map +0 -1
  34. package/dist/run-tui-cawSJuuh.js.map +0 -1
package/dist/web.d.ts CHANGED
@@ -15873,6 +15873,14 @@ declare class ResilientWebSocketClient {
15873
15873
  /** transport unrecoverable (no ws package AND no global WebSocket, or ctor threw):
15874
15874
  * reported here ONCE, the client goes permanently closed — never a retry storm */
15875
15875
  onTransportDead?: (error: unknown) => void;
15876
+ /**
15877
+ * the socket closed WITHOUT ever opening: nothing is listening there.
15878
+ * That is a definitive answer, not a blip, so it is reported instead of
15879
+ * retried and the caller decides. The 2s retry loop exists to heal an
15880
+ * ESTABLISHED session; spending it on a refused connect only makes every
15881
+ * waiter sit for the full connect deadline. No callback = retry as before.
15882
+ */
15883
+ onFirstConnectFailed?: (error: unknown) => void;
15876
15884
  };
15877
15885
  private url;
15878
15886
  private currentWS?;
@@ -15893,7 +15901,17 @@ declare class ResilientWebSocketClient {
15893
15901
  /** transport unrecoverable (no ws package AND no global WebSocket, or ctor threw):
15894
15902
  * reported here ONCE, the client goes permanently closed — never a retry storm */
15895
15903
  onTransportDead?: (error: unknown) => void;
15904
+ /**
15905
+ * the socket closed WITHOUT ever opening: nothing is listening there.
15906
+ * That is a definitive answer, not a blip, so it is reported instead of
15907
+ * retried and the caller decides. The 2s retry loop exists to heal an
15908
+ * ESTABLISHED session; spending it on a refused connect only makes every
15909
+ * waiter sit for the full connect deadline. No callback = retry as before.
15910
+ */
15911
+ onFirstConnectFailed?: (error: unknown) => void;
15896
15912
  });
15913
+ /** an established session heals by retrying; a first connect that never opened does not */
15914
+ private hasEverOpened;
15897
15915
  private reconnectTimeout?;
15898
15916
  private permanentlyClosed;
15899
15917
  /** close and stop reconnecting (lets a script exit cleanly) */
@@ -17435,10 +17453,14 @@ type LoraMirror = {
17435
17453
  loras: Record<string, LmLoraItem>;
17436
17454
  };
17437
17455
  /**
17438
- * forget everything loaded, so the next read picks up a fresh `comfy-ts loras`.
17439
- * A long-lived process (the TUI, `comfy-ts serve`) has no other way to see a
17440
- * re-sync that happened in another terminal.
17441
- */
17456
+ * re-read any mirror whose file changed (or appeared) since we loaded it.
17457
+ * `comfy-ts loras` in another terminal is the normal case, and without this a
17458
+ * TUI session kept the stale data — or kept knowing NOTHING, for a host whose
17459
+ * first sync happened while it was open. One stat per registered host, so this
17460
+ * belongs at user-initiated moments (opening the loras overlay), never in a render.
17461
+ */
17462
+ declare function refreshLoraInfoCacheIfChanged(): void;
17463
+ /** forget everything loaded, so the next read re-reads from disk (tests, and a hard refresh) */
17442
17464
  declare function reloadLoraInfoCache(): void;
17443
17465
  /**
17444
17466
  * the lm item for a raw lora name (`styles\x.safetensors`).
@@ -17479,5 +17501,5 @@ declare function loraMatchesFilter(name: string, filter: string, hostId?: string
17479
17501
  */
17480
17502
  declare function loraTag<N extends string = string>(name: N, strength?: number, clipStrength?: number): string;
17481
17503
  //#endregion
17482
- export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyVar, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, ComfyHostAuthError, type ComfyHostData, type ComfyHostID, ComfyHostUnreachableError, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, type ComfyStorage, ComfyTS, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LmLoraItem, type LoraMirror, type LoraNameOf, type LoraStrength, type LoraSweep, type LorasHost, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, type NodeMode, NodeOf, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptID, type PromptRelated_WsMsg, type PromptValue, PromptVar, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, Tagged, TextVar, ToggleVar, type VarKind, type VarValues, type VarsSpec, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
17504
+ export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyVar, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, ComfyExecution, type ComfyExecutionData, type ComfyExecutionStatus, ComfyHost, ComfyHostAuthError, type ComfyHostData, type ComfyHostID, ComfyHostUnreachableError, type ComfyImageName, ComfyManager, ComfyNode, type ComfyNodeId, type ComfyNodeIdMode, type ComfyNodeMetadata, ComfyNodeOutput, type ComfyNodeSchemaJSON, ComfySchema, type ComfySchemaJSON, ComfySdkBase, ComfySdkShape, type ComfyStorage, ComfyTS, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LmLoraItem, type LoraMirror, type LoraNameOf, type LoraStrength, type LoraSweep, type LorasHost, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, type NodeMode, NodeOf, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptID, type PromptRelated_WsMsg, type PromptValue, PromptVar, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, Tagged, TextVar, ToggleVar, type VarKind, type VarValues, type VarsSpec, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
17483
17505
  //# sourceMappingURL=web.d.ts.map
package/dist/web.js CHANGED
@@ -101,7 +101,7 @@ function getComfyStorage() {
101
101
  }
102
102
  //#endregion
103
103
  //#region package.json
104
- var version = "2.4.0";
104
+ var version = "2.4.2";
105
105
  //#endregion
106
106
  //#region src/litegraph/LiteGraphLinkID.ts
107
107
  const asLiteGraphLinkID = (id) => id;
@@ -3802,6 +3802,7 @@ var ResilientWebSocketClient = class {
3802
3802
  this.messageBuffer = [];
3803
3803
  this.isOpen = false;
3804
3804
  this.debugMessages = [];
3805
+ this.hasEverOpened = false;
3805
3806
  this.permanentlyClosed = false;
3806
3807
  this.url = options.url();
3807
3808
  this.connect();
@@ -3853,6 +3854,7 @@ var ResilientWebSocketClient = class {
3853
3854
  ws.onopen = () => {
3854
3855
  if (ws !== this.currentWS) return;
3855
3856
  this.addInfo("✅ WebSocket connected to " + this.url);
3857
+ this.hasEverOpened = true;
3856
3858
  this.isOpen = true;
3857
3859
  this.options.onConnectOrReconnect();
3858
3860
  this.flushMessageBuffer();
@@ -3863,6 +3865,11 @@ var ResilientWebSocketClient = class {
3863
3865
  this.options.onClose();
3864
3866
  if (this.permanentlyClosed) return;
3865
3867
  this.addError(`WebSocket closed (reason=${JSON.stringify(event.reason)}, code=${event.code})`);
3868
+ if (!this.hasEverOpened && this.options.onFirstConnectFailed != null) {
3869
+ this.permanentlyClosed = true;
3870
+ this.options.onFirstConnectFailed(/* @__PURE__ */ new Error(`connection refused (code=${event.code}${event.reason === "" ? "" : `, ${event.reason}`})`));
3871
+ return;
3872
+ }
3866
3873
  this.addInfo("⏱️ reconnecting in 2 seconds...");
3867
3874
  this.reconnectTimeout = setTimeout(() => void this.connect(), 2e3);
3868
3875
  };
@@ -3981,25 +3988,40 @@ function readLoraMirror(hostId) {
3981
3988
  * `comfyts.hosts` — exactly the hosts this process can be asked about.
3982
3989
  */
3983
3990
  const byHost = /* @__PURE__ */ new Map();
3984
- /** hosts already looked for, INCLUDING the ones with no mirror (see reloadLoraInfoCache) */
3985
- const loadedHostIds = /* @__PURE__ */ new Set();
3991
+ /** hosts already looked for, INCLUDING the ones with no mirror on disk → their mtime is null */
3992
+ const loadedMtimes = /* @__PURE__ */ new Map();
3993
+ /** cheap: no stat, no parse — this runs inside the overlay's render for every row */
3986
3994
  function ensureLoaded() {
3987
- for (const hostId of comfyts.hosts.keys()) {
3988
- if (loadedHostIds.has(hostId)) continue;
3989
- loadedHostIds.add(hostId);
3990
- const mirror = readLoraMirror(hostId);
3991
- if (mirror == null) continue;
3992
- byHost.set(hostId, new Map(Object.entries(mirror.loras)));
3993
- }
3995
+ for (const hostId of comfyts.hosts.keys()) if (!loadedMtimes.has(hostId)) loadHost(hostId);
3996
+ }
3997
+ function loadHost(hostId) {
3998
+ const storage = getComfyStorage();
3999
+ const path = loraMirrorPath(hostId);
4000
+ loadedMtimes.set(hostId, storage.mtimeMs(path));
4001
+ const mirror = readLoraMirror(hostId);
4002
+ if (mirror != null) byHost.set(hostId, new Map(Object.entries(mirror.loras)));
4003
+ else if (storage.exists(path)) byHost.set(hostId, /* @__PURE__ */ new Map());
4004
+ else byHost.delete(hostId);
3994
4005
  }
3995
4006
  /**
3996
- * forget everything loaded, so the next read picks up a fresh `comfy-ts loras`.
3997
- * A long-lived process (the TUI, `comfy-ts serve`) has no other way to see a
3998
- * re-sync that happened in another terminal.
4007
+ * re-read any mirror whose file changed (or appeared) since we loaded it.
4008
+ * `comfy-ts loras` in another terminal is the normal case, and without this a
4009
+ * TUI session kept the stale data — or kept knowing NOTHING, for a host whose
4010
+ * first sync happened while it was open. One stat per registered host, so this
4011
+ * belongs at user-initiated moments (opening the loras overlay), never in a render.
3999
4012
  */
4013
+ function refreshLoraInfoCacheIfChanged() {
4014
+ const storage = getComfyStorage();
4015
+ for (const hostId of comfyts.hosts.keys()) {
4016
+ const seen = loadedMtimes.get(hostId);
4017
+ const now = storage.mtimeMs(loraMirrorPath(hostId));
4018
+ if (!loadedMtimes.has(hostId) || seen !== now) loadHost(hostId);
4019
+ }
4020
+ }
4021
+ /** forget everything loaded, so the next read re-reads from disk (tests, and a hard refresh) */
4000
4022
  function reloadLoraInfoCache() {
4001
4023
  byHost.clear();
4002
- loadedHostIds.clear();
4024
+ loadedMtimes.clear();
4003
4025
  }
4004
4026
  /**
4005
4027
  * the lm item for a raw lora name (`styles\x.safetensors`).
@@ -5176,6 +5198,7 @@ var ComfyHost = class {
5176
5198
  url: () => this.getWSUrl(),
5177
5199
  headers: () => this.authHeaders(),
5178
5200
  onTransportDead: (e) => this.markFailed(e),
5201
+ onFirstConnectFailed: (e) => this.markFailed(new ComfyHostUnreachableError(`host '${this.data.id}' is not reachable at ${this.getWSUrl()} — ${extractErrorMessage(e)}. Is ComfyUI running there ?`)),
5179
5202
  onClose: () => {
5180
5203
  logInfo(`[👢] WEBSOCKET: closed connection to ComfyUI host ${this.data.id}`);
5181
5204
  }
@@ -5982,6 +6005,6 @@ function loraTag(name, strength = 1, clipStrength) {
5982
6005
  */
5983
6006
  setDefaultComfyStorage(createMemoryStorage());
5984
6007
  //#endregion
5985
- export { ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyHostUnreachableError, ComfyManager, ComfyNode, ComfyNodeOutput, ComfySchema, ComfyTS, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DefinedWorkflow, FloatVar, ImageVar, ImageVarEmptyError, IntVar, InvalidPromptError, LorasVar, MediaImage, PromptVar, ResilientWebSocketClient, SeedVar, SizeVar, TextVar, ToggleVar, WorkflowConvertError, WorkflowNormalizeError, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, parseHostBase, parseWorkflowJson, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
6008
+ export { ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyHostUnreachableError, ComfyManager, ComfyNode, ComfyNodeOutput, ComfySchema, ComfyTS, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DefinedWorkflow, FloatVar, ImageVar, ImageVarEmptyError, IntVar, InvalidPromptError, LorasVar, MediaImage, PromptVar, ResilientWebSocketClient, SeedVar, SizeVar, TextVar, ToggleVar, WorkflowConvertError, WorkflowNormalizeError, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, parseHostBase, parseWorkflowJson, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
5986
6009
 
5987
6010
  //# sourceMappingURL=web.js.map