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
package/dist/index.d.cts CHANGED
@@ -12719,7 +12719,7 @@ declare class ComfyExecution {
12719
12719
  retrieveImage: (comfyImageInfo: ComfyImageInfo, promptNodeID: ComfyNodeId) => Promise<void>;
12720
12720
  /** re-encode when asked, then write under OUR local naming — never the raw
12721
12721
  * server filename: a cloud host resets its _00001_ counter per run, so the
12722
- * server name overwrote the same local file on every run (his repro 2026-07-31) */
12722
+ * server name overwrote the same local file on every run */
12723
12723
  private encodeAndWrite;
12724
12724
  /** accumulate an output on the prompt; tags from node metadata ride along */
12725
12725
  private pushImage;
@@ -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) */
@@ -15910,8 +15928,8 @@ declare class ResilientWebSocketClient {
15910
15928
  * the var's CLASS, and the only safe way to discriminate one: `instanceof` compares class
15911
15929
  * OBJECTS, and the published package hands the same class out twice — a consumer's
15912
15930
  * `.cflow.ts` imports `comfy-ts` (dist/index.js) while `comfy-ts serve`/`tui` run from the
15913
- * cli bundle, so every `instanceof XVar` across that boundary is false (his repro
15914
- * 2026-07-31: "var 'prompt' has unsupported kind 'text'" for EVERY kind). A string tag
15931
+ * cli bundle, so every `instanceof XVar` across that boundary is false (observed
15932
+ * in a consumer app: "var 'prompt' has unsupported kind 'text'", for EVERY kind). A string tag
15915
15933
  * crosses bundles; a class identity does not.
15916
15934
  */
15917
15935
  type VarKind = 'text' | 'prompt' | 'int' | 'float' | 'seed' | 'toggle' | 'choice' | 'loras' | 'size' | 'image';
@@ -15957,9 +15975,13 @@ declare class TextVar extends ComfyVar<string> {
15957
15975
  readonly kind: 'text';
15958
15976
  parse(raw: string): boolean;
15959
15977
  }
15960
- /** what PromptVar needs from a loras var: covariant face, so LorasVar<'a'|'b'> fits */
15978
+ /** what PromptVar needs from a loras var: covariant face, so LorasVar<'a'|'b'> fits.
15979
+ * `hostId` scopes the keyword lookup: the same file name on two hosts is often a
15980
+ * different model, and injecting the other host's trigger words is a silently
15981
+ * wrong generation. */
15961
15982
  type ActiveLoraSource = {
15962
15983
  activeNames(): string[];
15984
+ hostId?: string;
15963
15985
  };
15964
15986
  /** what a prompt CONTRIBUTES to build: `vars.prompt.positive` / `.negative` */
15965
15987
  type PromptValue = {
@@ -16078,6 +16100,9 @@ type ActiveLora<T extends string> = {
16078
16100
  declare function activeLoras<T extends string>(loras: Partial<Record<T, LoraStrength>>): ActiveLora<T>[];
16079
16101
  /** what LorasVar.bindHost needs — structural, so ComfyVars never imports ComfyHost */
16080
16102
  type LorasHost = {
16103
+ data?: {
16104
+ id?: string;
16105
+ };
16081
16106
  schema: {
16082
16107
  getLoras(filter?: RegExp): string[];
16083
16108
  };
@@ -16095,6 +16120,8 @@ declare class LorasVar<T extends string> extends ComfyVar<Partial<Record<T, Lora
16095
16120
  private prev;
16096
16121
  /** a RegExp source resolves lazily (bindHost) — null until then */
16097
16122
  private resolvedOptions;
16123
+ /** which host these loras live on, so their metadata is read from ITS mirror */
16124
+ hostId: string | undefined;
16098
16125
  constructor(optionsSource: readonly T[] | RegExp, initial?: Partial<Record<T, LoraStrength>>, label?: string);
16099
16126
  get options(): readonly T[];
16100
16127
  /** DefinedWorkflow binds the host at define time: a RegExp source resolves here.
@@ -16129,7 +16156,7 @@ type SizePreset = {
16129
16156
  /** SDXL-style ~1MP buckets, multiples of 64 — safe for most latent models */
16130
16157
  declare const DEFAULT_SIZE_PRESETS: SizePreset[];
16131
16158
  /** width/height picker: presets + free `WxH` entry + optionally the LIVE
16132
- * size of a linked image var (his ask 2026-07-30: the widget shows
16159
+ * size of a linked image var (the widget shows
16133
16160
  * `WxH size of image '<name>'` as a pickable row) */
16134
16161
  declare class SizeVar extends ComfyVar<SizeValue> {
16135
16162
  readonly presets: SizePreset[];
@@ -17342,9 +17369,123 @@ workflow: CanonicalWorkflow, opts?: {
17342
17369
  }) => ComfyApiJson;
17343
17370
  //#endregion
17344
17371
  //#region src/vars/loraKeywords.d.ts
17345
- declare function getLoraKeyword(name: string): string;
17346
- /** empty keyword deletes the entry; every set writes the file (tiny, rare) */
17347
- declare function setLoraKeyword(name: string, keyword: string): void;
17372
+ /** the hand keyword when this lora HAS an entry (`''` included), else the mirror's trigger words */
17373
+ declare function getLoraKeyword(name: string, hostId?: string): string;
17374
+ /** true when the keyword shown comes from the lora-manager mirror, not from ⌃K */
17375
+ declare function isLoraKeywordFromMirror(name: string, hostId?: string): boolean;
17376
+ /** what `clearLoraKeywordOverride` would restore this lora to, `''` when nothing */
17377
+ declare function loraKeywordFromMirror(name: string, hostId?: string): string;
17378
+ /**
17379
+ * drop the hand entry entirely, so the mirror's trigger words apply again.
17380
+ * The way BACK from an empty-string tombstone: without it, clearing a keyword on
17381
+ * a lora that has trigger words was a one-way door only a text editor could undo.
17382
+ */
17383
+ declare function clearLoraKeywordOverride(name: string): void;
17384
+ /**
17385
+ * empty keyword deletes the entry — EXCEPT when the mirror has trigger words for
17386
+ * this lora: there `''` is stored as an explicit tombstone, the only way to say
17387
+ * "inject nothing" about a lora civitai gave words to. Every set writes the file
17388
+ * (tiny, rare).
17389
+ */
17390
+ declare function setLoraKeyword(name: string, keyword: string, hostId?: string): void;
17391
+ //#endregion
17392
+ //#region src/host/loraManagerApi.d.ts
17393
+ /**
17394
+ * client for the OPTIONAL ComfyUI-Lora-Manager extension.
17395
+ * absent extension = normal condition: callers get null/empty and degrade.
17396
+ */
17397
+ /**
17398
+ * one lora exactly as lora-manager sent it. RAW on purpose (agent/architecture
17399
+ * item 8): the mirror on disk keeps every field, including the ones we do not
17400
+ * read yet, so adding `sha256` or `civitai.modelId` to a surface later is an
17401
+ * accessor, not a re-sync. Reading goes through the checked lm* helpers below.
17402
+ */
17403
+ type LmLoraItem = Record<string, unknown>;
17404
+ /**
17405
+ * the ONE key space where a host's object_info spelling of a lora meets
17406
+ * lora-manager's: lowercase, forward slashes, no model extension.
17407
+ * `styles\Aurora.safetensors` and lm's folder `styles` + file_name `aurora`
17408
+ * both become `styles/aurora`.
17409
+ */
17410
+ declare function loraKey(name: string): string;
17411
+ /**
17412
+ * the outcome of a sweep, DISCRIMINATED. A bare `null` for "no loras" conflated
17413
+ * three very different situations, and callers then told the user the wrong one:
17414
+ * a host that is merely DOWN was reported as "extension not detected", and a
17415
+ * sweep cut short mid-collection was indistinguishable from a complete one, so
17416
+ * a partial mirror could overwrite a good one and report success.
17417
+ */
17418
+ type LoraSweep = {
17419
+ status: 'ok';
17420
+ items: LmLoraItem[];
17421
+ } |
17422
+ /** the extension answered, then stopped answering: `items` is INCOMPLETE, never write it over a good mirror */
17423
+ {
17424
+ status: 'partial';
17425
+ items: LmLoraItem[];
17426
+ reason: string;
17427
+ } |
17428
+ /** no ComfyUI-Lora-Manager on this host (404 on the first page) */
17429
+ {
17430
+ status: 'absent';
17431
+ } |
17432
+ /** the host itself could not be reached (down, refused, auth) */
17433
+ {
17434
+ status: 'unreachable';
17435
+ reason: string;
17436
+ };
17437
+ //#endregion
17438
+ //#region src/host/loraInfoCache.d.ts
17439
+ /**
17440
+ * the LOCAL MIRROR of what ComfyUI-Lora-Manager knows about a host's loras
17441
+ * (agent/architecture.md item 8). A ComfyUI host only ever tells us a lora's
17442
+ * file name; the model's real name, its trigger words and its tags live in the
17443
+ * extension. We sweep them once (`comfy-ts loras`) into
17444
+ * `.comfy-ts/hosts/<id>/loras.json` and every surface reads the mirror after.
17445
+ */
17446
+ type LoraMirror = {
17447
+ hostId: string;
17448
+ /** remembered so a later `comfy-ts loras` re-syncs with no flags. NEVER an api key. */
17449
+ hostUrl: string;
17450
+ fetchedAt: string;
17451
+ count: number;
17452
+ /** `loraKey` → the RAW lm item */
17453
+ loras: Record<string, LmLoraItem>;
17454
+ };
17455
+ /**
17456
+ * forget everything loaded, so the next read picks up a fresh `comfy-ts loras`.
17457
+ * A long-lived process (the TUI, `comfy-ts serve`) has no other way to see a
17458
+ * re-sync that happened in another terminal.
17459
+ */
17460
+ declare function reloadLoraInfoCache(): void;
17461
+ /**
17462
+ * the lm item for a raw lora name (`styles\x.safetensors`).
17463
+ * `hostId` picks the mirror that actually describes this host's file; without
17464
+ * it, any host that knows the name answers. null when unsynced/unknown.
17465
+ */
17466
+ declare function getLoraInfo(name: string, hostId?: string): LmLoraItem | null;
17467
+ /** civitai trigger words for this lora, in civitai's order */
17468
+ declare function getLoraTriggerWords(name: string, hostId?: string): string[];
17469
+ /** the human name (`Aurora Ink Wash`), falling back to the file's own name */
17470
+ declare function getLoraDisplayName(name: string, hostId?: string): string;
17471
+ /** server-relative preview url from the mirror, null when unsynced/unknown */
17472
+ declare function getLoraPreviewUrl(name: string, hostId?: string): string | null;
17473
+ /** the lora's NAMES: the file, and the model name a human would call it by */
17474
+ declare function loraSearchNames(name: string, hostId?: string): string[];
17475
+ /** the lora's FREE TEXT: tags, base model, trigger words */
17476
+ declare function loraSearchText(name: string, hostId?: string): string[];
17477
+ /**
17478
+ * the loras overlay filter: find a lora by its human name, not only by the file
17479
+ * name. EVERY whitespace-separated token must be a SUBSTRING of some field — order
17480
+ * free, so `aurora ink`, `ink aurora` and `styles wash` all land on the same
17481
+ * lora. NOT fuzzyMatch: a subsequence match over phrases this long matches
17482
+ * nearly everything. Measured on a real collection, filtering by each lora's
17483
+ * own file name: this rule peaks at 8 hits where fuzzyMatch matched a third of
17484
+ * every lora present.
17485
+ * Fields are matched one by one, never as a concatenated haystack, for the same
17486
+ * reason. `tests/lora-corpus.private.test.ts` keeps that measurement runnable.
17487
+ */
17488
+ declare function loraMatchesFilter(name: string, filter: string, hostId?: string): boolean;
17348
17489
  //#endregion
17349
17490
  //#region src/utils/loraTag.d.ts
17350
17491
  /**
@@ -17369,5 +17510,5 @@ declare function exampleImagePath(name: string): string;
17369
17510
  //#region src/cli/tui-env.d.ts
17370
17511
  declare function isTuiActive(): boolean;
17371
17512
  //#endregion
17372
- 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 LoraNameOf, type LoraStrength, 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_, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, getComfyStorage, getLoraKeyword, hostIdToNamespace, isTuiActive, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
17513
+ 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, exampleImagePath, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, isTuiActive, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
17373
17514
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -12719,7 +12719,7 @@ declare class ComfyExecution {
12719
12719
  retrieveImage: (comfyImageInfo: ComfyImageInfo, promptNodeID: ComfyNodeId) => Promise<void>;
12720
12720
  /** re-encode when asked, then write under OUR local naming — never the raw
12721
12721
  * server filename: a cloud host resets its _00001_ counter per run, so the
12722
- * server name overwrote the same local file on every run (his repro 2026-07-31) */
12722
+ * server name overwrote the same local file on every run */
12723
12723
  private encodeAndWrite;
12724
12724
  /** accumulate an output on the prompt; tags from node metadata ride along */
12725
12725
  private pushImage;
@@ -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) */
@@ -15910,8 +15928,8 @@ declare class ResilientWebSocketClient {
15910
15928
  * the var's CLASS, and the only safe way to discriminate one: `instanceof` compares class
15911
15929
  * OBJECTS, and the published package hands the same class out twice — a consumer's
15912
15930
  * `.cflow.ts` imports `comfy-ts` (dist/index.js) while `comfy-ts serve`/`tui` run from the
15913
- * cli bundle, so every `instanceof XVar` across that boundary is false (his repro
15914
- * 2026-07-31: "var 'prompt' has unsupported kind 'text'" for EVERY kind). A string tag
15931
+ * cli bundle, so every `instanceof XVar` across that boundary is false (observed
15932
+ * in a consumer app: "var 'prompt' has unsupported kind 'text'", for EVERY kind). A string tag
15915
15933
  * crosses bundles; a class identity does not.
15916
15934
  */
15917
15935
  type VarKind = 'text' | 'prompt' | 'int' | 'float' | 'seed' | 'toggle' | 'choice' | 'loras' | 'size' | 'image';
@@ -15957,9 +15975,13 @@ declare class TextVar extends ComfyVar<string> {
15957
15975
  readonly kind: 'text';
15958
15976
  parse(raw: string): boolean;
15959
15977
  }
15960
- /** what PromptVar needs from a loras var: covariant face, so LorasVar<'a'|'b'> fits */
15978
+ /** what PromptVar needs from a loras var: covariant face, so LorasVar<'a'|'b'> fits.
15979
+ * `hostId` scopes the keyword lookup: the same file name on two hosts is often a
15980
+ * different model, and injecting the other host's trigger words is a silently
15981
+ * wrong generation. */
15961
15982
  type ActiveLoraSource = {
15962
15983
  activeNames(): string[];
15984
+ hostId?: string;
15963
15985
  };
15964
15986
  /** what a prompt CONTRIBUTES to build: `vars.prompt.positive` / `.negative` */
15965
15987
  type PromptValue = {
@@ -16078,6 +16100,9 @@ type ActiveLora<T extends string> = {
16078
16100
  declare function activeLoras<T extends string>(loras: Partial<Record<T, LoraStrength>>): ActiveLora<T>[];
16079
16101
  /** what LorasVar.bindHost needs — structural, so ComfyVars never imports ComfyHost */
16080
16102
  type LorasHost = {
16103
+ data?: {
16104
+ id?: string;
16105
+ };
16081
16106
  schema: {
16082
16107
  getLoras(filter?: RegExp): string[];
16083
16108
  };
@@ -16095,6 +16120,8 @@ declare class LorasVar<T extends string> extends ComfyVar<Partial<Record<T, Lora
16095
16120
  private prev;
16096
16121
  /** a RegExp source resolves lazily (bindHost) — null until then */
16097
16122
  private resolvedOptions;
16123
+ /** which host these loras live on, so their metadata is read from ITS mirror */
16124
+ hostId: string | undefined;
16098
16125
  constructor(optionsSource: readonly T[] | RegExp, initial?: Partial<Record<T, LoraStrength>>, label?: string);
16099
16126
  get options(): readonly T[];
16100
16127
  /** DefinedWorkflow binds the host at define time: a RegExp source resolves here.
@@ -16129,7 +16156,7 @@ type SizePreset = {
16129
16156
  /** SDXL-style ~1MP buckets, multiples of 64 — safe for most latent models */
16130
16157
  declare const DEFAULT_SIZE_PRESETS: SizePreset[];
16131
16158
  /** width/height picker: presets + free `WxH` entry + optionally the LIVE
16132
- * size of a linked image var (his ask 2026-07-30: the widget shows
16159
+ * size of a linked image var (the widget shows
16133
16160
  * `WxH size of image '<name>'` as a pickable row) */
16134
16161
  declare class SizeVar extends ComfyVar<SizeValue> {
16135
16162
  readonly presets: SizePreset[];
@@ -17342,9 +17369,123 @@ workflow: CanonicalWorkflow, opts?: {
17342
17369
  }) => ComfyApiJson;
17343
17370
  //#endregion
17344
17371
  //#region src/vars/loraKeywords.d.ts
17345
- declare function getLoraKeyword(name: string): string;
17346
- /** empty keyword deletes the entry; every set writes the file (tiny, rare) */
17347
- declare function setLoraKeyword(name: string, keyword: string): void;
17372
+ /** the hand keyword when this lora HAS an entry (`''` included), else the mirror's trigger words */
17373
+ declare function getLoraKeyword(name: string, hostId?: string): string;
17374
+ /** true when the keyword shown comes from the lora-manager mirror, not from ⌃K */
17375
+ declare function isLoraKeywordFromMirror(name: string, hostId?: string): boolean;
17376
+ /** what `clearLoraKeywordOverride` would restore this lora to, `''` when nothing */
17377
+ declare function loraKeywordFromMirror(name: string, hostId?: string): string;
17378
+ /**
17379
+ * drop the hand entry entirely, so the mirror's trigger words apply again.
17380
+ * The way BACK from an empty-string tombstone: without it, clearing a keyword on
17381
+ * a lora that has trigger words was a one-way door only a text editor could undo.
17382
+ */
17383
+ declare function clearLoraKeywordOverride(name: string): void;
17384
+ /**
17385
+ * empty keyword deletes the entry — EXCEPT when the mirror has trigger words for
17386
+ * this lora: there `''` is stored as an explicit tombstone, the only way to say
17387
+ * "inject nothing" about a lora civitai gave words to. Every set writes the file
17388
+ * (tiny, rare).
17389
+ */
17390
+ declare function setLoraKeyword(name: string, keyword: string, hostId?: string): void;
17391
+ //#endregion
17392
+ //#region src/host/loraManagerApi.d.ts
17393
+ /**
17394
+ * client for the OPTIONAL ComfyUI-Lora-Manager extension.
17395
+ * absent extension = normal condition: callers get null/empty and degrade.
17396
+ */
17397
+ /**
17398
+ * one lora exactly as lora-manager sent it. RAW on purpose (agent/architecture
17399
+ * item 8): the mirror on disk keeps every field, including the ones we do not
17400
+ * read yet, so adding `sha256` or `civitai.modelId` to a surface later is an
17401
+ * accessor, not a re-sync. Reading goes through the checked lm* helpers below.
17402
+ */
17403
+ type LmLoraItem = Record<string, unknown>;
17404
+ /**
17405
+ * the ONE key space where a host's object_info spelling of a lora meets
17406
+ * lora-manager's: lowercase, forward slashes, no model extension.
17407
+ * `styles\Aurora.safetensors` and lm's folder `styles` + file_name `aurora`
17408
+ * both become `styles/aurora`.
17409
+ */
17410
+ declare function loraKey(name: string): string;
17411
+ /**
17412
+ * the outcome of a sweep, DISCRIMINATED. A bare `null` for "no loras" conflated
17413
+ * three very different situations, and callers then told the user the wrong one:
17414
+ * a host that is merely DOWN was reported as "extension not detected", and a
17415
+ * sweep cut short mid-collection was indistinguishable from a complete one, so
17416
+ * a partial mirror could overwrite a good one and report success.
17417
+ */
17418
+ type LoraSweep = {
17419
+ status: 'ok';
17420
+ items: LmLoraItem[];
17421
+ } |
17422
+ /** the extension answered, then stopped answering: `items` is INCOMPLETE, never write it over a good mirror */
17423
+ {
17424
+ status: 'partial';
17425
+ items: LmLoraItem[];
17426
+ reason: string;
17427
+ } |
17428
+ /** no ComfyUI-Lora-Manager on this host (404 on the first page) */
17429
+ {
17430
+ status: 'absent';
17431
+ } |
17432
+ /** the host itself could not be reached (down, refused, auth) */
17433
+ {
17434
+ status: 'unreachable';
17435
+ reason: string;
17436
+ };
17437
+ //#endregion
17438
+ //#region src/host/loraInfoCache.d.ts
17439
+ /**
17440
+ * the LOCAL MIRROR of what ComfyUI-Lora-Manager knows about a host's loras
17441
+ * (agent/architecture.md item 8). A ComfyUI host only ever tells us a lora's
17442
+ * file name; the model's real name, its trigger words and its tags live in the
17443
+ * extension. We sweep them once (`comfy-ts loras`) into
17444
+ * `.comfy-ts/hosts/<id>/loras.json` and every surface reads the mirror after.
17445
+ */
17446
+ type LoraMirror = {
17447
+ hostId: string;
17448
+ /** remembered so a later `comfy-ts loras` re-syncs with no flags. NEVER an api key. */
17449
+ hostUrl: string;
17450
+ fetchedAt: string;
17451
+ count: number;
17452
+ /** `loraKey` → the RAW lm item */
17453
+ loras: Record<string, LmLoraItem>;
17454
+ };
17455
+ /**
17456
+ * forget everything loaded, so the next read picks up a fresh `comfy-ts loras`.
17457
+ * A long-lived process (the TUI, `comfy-ts serve`) has no other way to see a
17458
+ * re-sync that happened in another terminal.
17459
+ */
17460
+ declare function reloadLoraInfoCache(): void;
17461
+ /**
17462
+ * the lm item for a raw lora name (`styles\x.safetensors`).
17463
+ * `hostId` picks the mirror that actually describes this host's file; without
17464
+ * it, any host that knows the name answers. null when unsynced/unknown.
17465
+ */
17466
+ declare function getLoraInfo(name: string, hostId?: string): LmLoraItem | null;
17467
+ /** civitai trigger words for this lora, in civitai's order */
17468
+ declare function getLoraTriggerWords(name: string, hostId?: string): string[];
17469
+ /** the human name (`Aurora Ink Wash`), falling back to the file's own name */
17470
+ declare function getLoraDisplayName(name: string, hostId?: string): string;
17471
+ /** server-relative preview url from the mirror, null when unsynced/unknown */
17472
+ declare function getLoraPreviewUrl(name: string, hostId?: string): string | null;
17473
+ /** the lora's NAMES: the file, and the model name a human would call it by */
17474
+ declare function loraSearchNames(name: string, hostId?: string): string[];
17475
+ /** the lora's FREE TEXT: tags, base model, trigger words */
17476
+ declare function loraSearchText(name: string, hostId?: string): string[];
17477
+ /**
17478
+ * the loras overlay filter: find a lora by its human name, not only by the file
17479
+ * name. EVERY whitespace-separated token must be a SUBSTRING of some field — order
17480
+ * free, so `aurora ink`, `ink aurora` and `styles wash` all land on the same
17481
+ * lora. NOT fuzzyMatch: a subsequence match over phrases this long matches
17482
+ * nearly everything. Measured on a real collection, filtering by each lora's
17483
+ * own file name: this rule peaks at 8 hits where fuzzyMatch matched a third of
17484
+ * every lora present.
17485
+ * Fields are matched one by one, never as a concatenated haystack, for the same
17486
+ * reason. `tests/lora-corpus.private.test.ts` keeps that measurement runnable.
17487
+ */
17488
+ declare function loraMatchesFilter(name: string, filter: string, hostId?: string): boolean;
17348
17489
  //#endregion
17349
17490
  //#region src/utils/loraTag.d.ts
17350
17491
  /**
@@ -17369,5 +17510,5 @@ declare function exampleImagePath(name: string): string;
17369
17510
  //#region src/cli/tui-env.d.ts
17370
17511
  declare function isTuiActive(): boolean;
17371
17512
  //#endregion
17372
- 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 LoraNameOf, type LoraStrength, 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_, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, getComfyStorage, getLoraKeyword, hostIdToNamespace, isTuiActive, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
17513
+ 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, exampleImagePath, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, isTuiActive, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
17373
17514
  //# sourceMappingURL=index.d.ts.map