comfy-ts 2.12.0 → 2.14.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 (81) hide show
  1. package/dist/{LogsSt-U1H0mP1m.js → LogsSt-CUeo843w.js} +18 -4
  2. package/dist/LogsSt-CUeo843w.js.map +1 -0
  3. package/dist/cli.js +4 -4
  4. package/dist/index.cjs +123 -12
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +96 -16
  7. package/dist/index.d.ts +96 -16
  8. package/dist/index.js +123 -12
  9. package/dist/index.js.map +1 -1
  10. package/dist/{run-serve-BeAznay5.js → run-serve-DUqcn0h3.js} +477 -63
  11. package/dist/run-serve-DUqcn0h3.js.map +1 -0
  12. package/dist/{run-tui-BTGjvnKk.js → run-tui-D-LaSqgB.js} +4 -4
  13. package/dist/{run-tui-BTGjvnKk.js.map → run-tui-D-LaSqgB.js.map} +1 -1
  14. package/dist/{schemaDrift-Cg39vs53.js → schemaDrift-E95iTF7E.js} +4 -1
  15. package/dist/{schemaDrift-Cg39vs53.js.map → schemaDrift-E95iTF7E.js.map} +1 -1
  16. package/dist/serve-web.js +378 -141
  17. package/dist/{state-C7REnHan.js → state-BytbdZ8s.js} +122 -14
  18. package/dist/state-BytbdZ8s.js.map +1 -0
  19. package/dist/web.d.ts +96 -16
  20. package/dist/web.js +123 -12
  21. package/dist/web.js.map +1 -1
  22. package/examples/comfy-cloud/sdk.d.ts +163 -163
  23. package/examples/rvion/10-anima-t2i.cflow.ts +48 -25
  24. package/examples/rvion/11-yue2-t2a.cflow.ts +105 -0
  25. package/examples/rvion/12-stable-audio-3-t2a.cflow.ts +78 -0
  26. package/examples/rvion/13-ace-step-15-xl-t2a.cflow.ts +153 -0
  27. package/examples/rvion/stableAudio3Prompts.ts +19 -0
  28. package/package.json +2 -2
  29. package/src/cli/serve/ServeApp.ts +224 -77
  30. package/src/cli/serve/byteRange.ts +48 -0
  31. package/src/cli/serve/resultHistory.ts +125 -0
  32. package/src/cli/serve/run-serve.ts +12 -3
  33. package/src/cli/serve/runError.ts +23 -0
  34. package/src/cli/serve/serveSettings.ts +17 -1
  35. package/src/cli/serve/web/api.ts +53 -2
  36. package/src/cli/serve/web/components/App.tsx +311 -160
  37. package/src/cli/serve/web/components/DraftTabs.tsx +167 -0
  38. package/src/cli/serve/web/components/Gallery.tsx +75 -25
  39. package/src/cli/serve/web/components/Icon.tsx +44 -0
  40. package/src/cli/serve/web/components/MemoryBudget.tsx +98 -0
  41. package/src/cli/serve/web/components/Omnibox.tsx +70 -20
  42. package/src/cli/serve/web/components/RunError.tsx +19 -0
  43. package/src/cli/serve/web/components/ShortcutsModal.tsx +54 -0
  44. package/src/cli/serve/web/components/SideMenu.tsx +428 -0
  45. package/src/cli/serve/web/components/TooltipLayer.tsx +3 -2
  46. package/src/cli/serve/web/components/VarsForm.tsx +141 -404
  47. package/src/cli/serve/web/components/controls/BasicControls.tsx +8 -1
  48. package/src/cli/serve/web/components/controls/LorasControl.tsx +30 -25
  49. package/src/cli/serve/web/promptEditor/promptExtensions.ts +9 -4
  50. package/src/cli/serve/web/state/EnhancerSt.ts +17 -2
  51. package/src/cli/serve/web/state/FormSt.ts +22 -2
  52. package/src/cli/serve/web/state/OmniboxSt.ts +3 -1
  53. package/src/cli/serve/web/state/RunSt.ts +61 -3
  54. package/src/cli/serve/web/state/WebSt.ts +198 -35
  55. package/src/cli/serve/web/state/draftNames.ts +16 -0
  56. package/src/cli/serve/web/state/draftTabs.ts +75 -0
  57. package/src/cli/serve/web/state/formRows.ts +9 -0
  58. package/src/cli/serve/web/state/generateButton.ts +1 -1
  59. package/src/cli/serve/web/state/keptResults.ts +26 -0
  60. package/src/cli/serve/web/state/lightbox.ts +17 -0
  61. package/src/cli/serve/web/state/omnibox.ts +82 -18
  62. package/src/cli/serve/web/state/shortcutCatalog.ts +100 -0
  63. package/src/cli/serve/web/state/shortcuts.ts +66 -7
  64. package/src/cli/serve/web/styles.ts +327 -93
  65. package/src/cli/serve/workflowTags.ts +42 -0
  66. package/src/cli/serve/workspaceLabels.ts +23 -0
  67. package/src/cli/tui/state/DraftsSt.ts +10 -6
  68. package/src/coreExports.ts +1 -0
  69. package/src/host/ComfyHost.ts +17 -2
  70. package/src/host/ResilientWebsocket.ts +54 -4
  71. package/src/runner/ComfyExecution.ts +60 -0
  72. package/src/runner/ComfyWorkflow.ts +4 -0
  73. package/src/runner/ComfyWsApi.ts +2 -0
  74. package/src/runner/MediaImage.ts +2 -2
  75. package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +5 -5
  76. package/src/sdk-generator/comfyui-sdk-codegen.ts +1 -1
  77. package/src/utils/copyName.ts +12 -0
  78. package/src/vars/DefinedWorkflow.ts +7 -1
  79. package/dist/LogsSt-U1H0mP1m.js.map +0 -1
  80. package/dist/run-serve-BeAznay5.js.map +0 -1
  81. package/dist/state-C7REnHan.js.map +0 -1
package/dist/web.d.ts CHANGED
@@ -11941,6 +11941,11 @@ declare const types$1: import("arktype").Module<{
11941
11941
  subfolder: string;
11942
11942
  type: string;
11943
11943
  }[] | undefined;
11944
+ audio?: {
11945
+ filename: string;
11946
+ subfolder: string;
11947
+ type: string;
11948
+ }[] | undefined;
11944
11949
  text?: unknown[] | undefined;
11945
11950
  };
11946
11951
  prompt_id: PromptID;
@@ -12017,6 +12022,11 @@ declare const types$1: import("arktype").Module<{
12017
12022
  subfolder: string;
12018
12023
  type: string;
12019
12024
  }[] | undefined;
12025
+ audio?: {
12026
+ filename: string;
12027
+ subfolder: string;
12028
+ type: string;
12029
+ }[] | undefined;
12020
12030
  text?: unknown[] | undefined;
12021
12031
  };
12022
12032
  prompt_id: PromptID;
@@ -12079,6 +12089,11 @@ declare const types$1: import("arktype").Module<{
12079
12089
  subfolder: string;
12080
12090
  type: string;
12081
12091
  }[] | undefined;
12092
+ audio?: {
12093
+ filename: string;
12094
+ subfolder: string;
12095
+ type: string;
12096
+ }[] | undefined;
12082
12097
  text?: unknown[] | undefined;
12083
12098
  };
12084
12099
  prompt_id: PromptID;
@@ -12180,6 +12195,11 @@ declare const types$1: import("arktype").Module<{
12180
12195
  subfolder: string;
12181
12196
  type: string;
12182
12197
  }[] | undefined;
12198
+ audio?: {
12199
+ filename: string;
12200
+ subfolder: string;
12201
+ type: string;
12202
+ }[] | undefined;
12183
12203
  text?: unknown[] | undefined;
12184
12204
  };
12185
12205
  prompt_id: PromptID;
@@ -12272,7 +12292,7 @@ declare const types: import("arktype").Module<{
12272
12292
  ComfyInputOpts: string | {
12273
12293
  tooltip?: string | /*elided*/ any | null | undefined;
12274
12294
  multiline?: boolean | null | undefined;
12275
- default?: string | number | boolean | number[] | null | undefined;
12295
+ default?: string | number | boolean | object | number[] | null | undefined;
12276
12296
  forceInput?: boolean | null | undefined;
12277
12297
  min?: number | null | undefined;
12278
12298
  round?: number | boolean | null | undefined;
@@ -12287,7 +12307,7 @@ declare const types: import("arktype").Module<{
12287
12307
  ComfyInputOpts_advanced: {
12288
12308
  tooltip?: string | any | null | undefined;
12289
12309
  multiline?: boolean | null | undefined;
12290
- default?: string | number | boolean | number[] | null | undefined;
12310
+ default?: string | number | boolean | object | number[] | null | undefined;
12291
12311
  forceInput?: boolean | null | undefined;
12292
12312
  min?: number | null | undefined;
12293
12313
  round?: number | boolean | null | undefined;
@@ -12309,7 +12329,7 @@ declare const types: import("arktype").Module<{
12309
12329
  })[], string | {
12310
12330
  tooltip?: string | any | null | undefined;
12311
12331
  multiline?: boolean | null | undefined;
12312
- default?: string | number | boolean | number[] | null | undefined;
12332
+ default?: string | number | boolean | object | number[] | null | undefined;
12313
12333
  forceInput?: boolean | null | undefined;
12314
12334
  min?: number | null | undefined;
12315
12335
  round?: number | boolean | null | undefined;
@@ -12327,7 +12347,7 @@ declare const types: import("arktype").Module<{
12327
12347
  })[], string | {
12328
12348
  tooltip?: string | any | null | undefined;
12329
12349
  multiline?: boolean | null | undefined;
12330
- default?: string | number | boolean | number[] | null | undefined;
12350
+ default?: string | number | boolean | object | number[] | null | undefined;
12331
12351
  forceInput?: boolean | null | undefined;
12332
12352
  min?: number | null | undefined;
12333
12353
  round?: number | boolean | null | undefined;
@@ -12360,7 +12380,7 @@ declare const types: import("arktype").Module<{
12360
12380
  })[], string | {
12361
12381
  tooltip?: string | any | null | undefined;
12362
12382
  multiline?: boolean | null | undefined;
12363
- default?: string | number | boolean | number[] | null | undefined;
12383
+ default?: string | number | boolean | object | number[] | null | undefined;
12364
12384
  forceInput?: boolean | null | undefined;
12365
12385
  min?: number | null | undefined;
12366
12386
  round?: number | boolean | null | undefined;
@@ -12383,7 +12403,7 @@ declare const types: import("arktype").Module<{
12383
12403
  })[], string | {
12384
12404
  tooltip?: string | any | null | undefined;
12385
12405
  multiline?: boolean | null | undefined;
12386
- default?: string | number | boolean | number[] | null | undefined;
12406
+ default?: string | number | boolean | object | number[] | null | undefined;
12387
12407
  forceInput?: boolean | null | undefined;
12388
12408
  min?: number | null | undefined;
12389
12409
  round?: number | boolean | null | undefined;
@@ -12409,15 +12429,15 @@ declare const types: import("arktype").Module<{
12409
12429
  content: string;
12410
12430
  image?: string | null | undefined;
12411
12431
  })[])[];
12412
- output_is_list: boolean[];
12432
+ output_is_list: (boolean | null)[];
12413
12433
  output_name: string[];
12414
12434
  name: string;
12415
- display_name: string;
12435
+ display_name: string | null;
12416
12436
  description: string;
12417
12437
  python_module: string;
12418
12438
  category: string;
12419
12439
  output_node: boolean;
12420
- output_tooltips?: string[] | undefined;
12440
+ output_tooltips?: (string | null)[] | undefined;
12421
12441
  deprecated?: boolean | undefined;
12422
12442
  experimental?: boolean | undefined;
12423
12443
  };
@@ -12434,7 +12454,7 @@ declare const types: import("arktype").Module<{
12434
12454
  })[], string | {
12435
12455
  tooltip?: string | any | null | undefined;
12436
12456
  multiline?: boolean | null | undefined;
12437
- default?: string | number | boolean | number[] | null | undefined;
12457
+ default?: string | number | boolean | object | number[] | null | undefined;
12438
12458
  forceInput?: boolean | null | undefined;
12439
12459
  min?: number | null | undefined;
12440
12460
  round?: number | boolean | null | undefined;
@@ -12457,7 +12477,7 @@ declare const types: import("arktype").Module<{
12457
12477
  })[], string | {
12458
12478
  tooltip?: string | any | null | undefined;
12459
12479
  multiline?: boolean | null | undefined;
12460
- default?: string | number | boolean | number[] | null | undefined;
12480
+ default?: string | number | boolean | object | number[] | null | undefined;
12461
12481
  forceInput?: boolean | null | undefined;
12462
12482
  min?: number | null | undefined;
12463
12483
  round?: number | boolean | null | undefined;
@@ -12483,15 +12503,15 @@ declare const types: import("arktype").Module<{
12483
12503
  content: string;
12484
12504
  image?: string | null | undefined;
12485
12505
  })[])[];
12486
- output_is_list: boolean[];
12506
+ output_is_list: (boolean | null)[];
12487
12507
  output_name: string[];
12488
12508
  name: string;
12489
- display_name: string;
12509
+ display_name: string | null;
12490
12510
  description: string;
12491
12511
  python_module: string;
12492
12512
  category: string;
12493
12513
  output_node: boolean;
12494
- output_tooltips?: string[] | undefined;
12514
+ output_tooltips?: (string | null)[] | undefined;
12495
12515
  deprecated?: boolean | undefined;
12496
12516
  experimental?: boolean | undefined;
12497
12517
  };
@@ -12666,6 +12686,15 @@ type ComfyExecutionData = {
12666
12686
  error?: WsMsgExecutionError | null;
12667
12687
  status?: ComfyExecutionStatus | null;
12668
12688
  };
12689
+ /** one audio file an output node published, downloaded as the server wrote it.
12690
+ * `absPath` is null when saving is off: `bytes` is then the only copy */
12691
+ type ComfyAudioOutput = {
12692
+ nodeId: ComfyNodeId;
12693
+ filename: string;
12694
+ mime: string;
12695
+ bytes: Uint8Array;
12696
+ absPath: AbsolutePath | null;
12697
+ };
12669
12698
  /** one text output as an output node published it (`nodeKey` is null when the node left the snapshot) */
12670
12699
  type ComfyTextOutput = {
12671
12700
  nodeId: ComfyNodeId;
@@ -12730,6 +12759,14 @@ declare class ComfyExecution {
12730
12759
  /** update execution list */
12731
12760
  private onExecuted;
12732
12761
  private pendingPromises;
12762
+ /** audio retrievals that failed (their files are missing from `audios`) */
12763
+ audioErrors: {
12764
+ audio: ComfyImageInfo;
12765
+ error: unknown;
12766
+ }[];
12767
+ /** audio files retrieved for this execution, in arrival order (final once `done` resolves) */
12768
+ audios: ComfyAudioOutput[];
12769
+ private retrieveAudio;
12733
12770
  /** image retrievals that failed (their images are missing from `images`);
12734
12771
  * `image` is null for SaveImageWebsocket frames (no server-side file info exists) */
12735
12772
  imageErrors: {
@@ -15891,6 +15928,10 @@ type WsLike = {
15891
15928
  onerror: ((event: unknown) => void) | null;
15892
15929
  send(data: Message): void;
15893
15930
  close(): void;
15931
+ /** the `ws` package only (a browser answers pings by itself and exposes none of these) */
15932
+ ping?(): void;
15933
+ on?(event: 'pong', cb: () => void): void;
15934
+ terminate?(): void;
15894
15935
  };
15895
15936
  /** what both transports deliver with binaryType 'arraybuffer': string or ArrayBuffer in `data` */
15896
15937
  type WsMessageEvent = {
@@ -15900,6 +15941,13 @@ type WsCloseEvent = {
15900
15941
  code: number;
15901
15942
  reason: string;
15902
15943
  };
15944
+ type WsCtor = new (url: string, opts?: {
15945
+ headers?: Record<string, string>;
15946
+ }) => WsLike;
15947
+ type WsTransport = {
15948
+ ctor: WsCtor;
15949
+ supportsHeaders: boolean;
15950
+ };
15903
15951
  type WsDebugMessage = {
15904
15952
  type: 'info' | 'error';
15905
15953
  timestamp: number;
@@ -15926,6 +15974,14 @@ declare class ResilientWebSocketClient {
15926
15974
  * waiter sit for the full connect deadline. No callback = retry as before.
15927
15975
  */
15928
15976
  onFirstConnectFailed?: (error: unknown) => void;
15977
+ /** tests only: a fake socket instead of the ws package / browser WebSocket */
15978
+ transport?: WsTransport;
15979
+ /** a host that vanishes (power loss, hard reboot) never sends a close frame, so the
15980
+ * socket would look open forever: every `heartbeatMs` it is pinged, and one without a
15981
+ * pong since the last ping is dropped, which starts the reconnect. Default 15s */
15982
+ heartbeatMs?: number;
15983
+ /** pause before a reconnect. Default 2s */
15984
+ reconnectMs?: number;
15929
15985
  };
15930
15986
  private url;
15931
15987
  private currentWS?;
@@ -15954,11 +16010,23 @@ declare class ResilientWebSocketClient {
15954
16010
  * waiter sit for the full connect deadline. No callback = retry as before.
15955
16011
  */
15956
16012
  onFirstConnectFailed?: (error: unknown) => void;
16013
+ /** tests only: a fake socket instead of the ws package / browser WebSocket */
16014
+ transport?: WsTransport;
16015
+ /** a host that vanishes (power loss, hard reboot) never sends a close frame, so the
16016
+ * socket would look open forever: every `heartbeatMs` it is pinged, and one without a
16017
+ * pong since the last ping is dropped, which starts the reconnect. Default 15s */
16018
+ heartbeatMs?: number;
16019
+ /** pause before a reconnect. Default 2s */
16020
+ reconnectMs?: number;
15957
16021
  });
15958
16022
  /** an established session heals by retrying; a first connect that never opened does not */
15959
16023
  private hasEverOpened;
15960
16024
  private reconnectTimeout?;
16025
+ private heartbeat;
15961
16026
  private permanentlyClosed;
16027
+ private stopHeartbeat;
16028
+ /** ping on a timer; no pong since the previous ping = the peer is gone, drop the socket */
16029
+ private startHeartbeat;
15962
16030
  /** close and stop reconnecting (lets a script exit cleanly) */
15963
16031
  disconnectPermanently(): void;
15964
16032
  /** headerless transports carry the api key as ?token= — everything else is refused loud */
@@ -16547,6 +16615,9 @@ type DefineWorkflowSpec<ID extends string, V extends VarsSpec> = {
16547
16615
  * live while the vars are edited (the serve panel: a foldable block under generate). Use the
16548
16616
  * function build uses, so a preview is what the run sends, never a paraphrase of it */
16549
16617
  previews?: Record<string, (vars: VarValues<V>) => string>;
16618
+ /** free search tags for the serve omnibox, added to the ones read from the graph
16619
+ * (`image`, `audio`, `video`, `text`, `llm`, `edit`) */
16620
+ tags?: string[];
16550
16621
  };
16551
16622
  /**
16552
16623
  * a re-runnable workflow definition: `build` re-executes per run with the
@@ -16575,10 +16646,12 @@ declare class DefinedWorkflow<ID extends string = string, V extends VarsSpec = V
16575
16646
  * build() for copy/export never advances). `p.host` substitutes the host
16576
16647
  * the graph is built against (TUI host override): node/model availability
16577
16648
  * there surfaces as workflow.problems / server validation, by design.
16649
+ * `p.dry` builds a graph only to read it: nothing is uploaded, lastWorkflow is left alone.
16578
16650
  */
16579
16651
  build(p?: {
16580
16652
  advance?: boolean;
16581
16653
  host?: ComfyHost<ID>;
16654
+ dry?: boolean;
16582
16655
  }): Promise<ComfyWorkflow<ID>>;
16583
16656
  /** build a fresh graph from the current var values, send it, wait for outputs.
16584
16657
  * connects first (idempotent) — modules can import offline from the schema cache.
@@ -16798,7 +16871,11 @@ declare class ComfyHost<ID extends string = string> {
16798
16871
  private postJSON_;
16799
16872
  /** drop every PENDING prompt from the server queue (the running one keeps going) */
16800
16873
  clearQueue: () => Promise<void>;
16801
- /** interrupt the CURRENTLY RUNNING prompt */
16874
+ /** a repeat interrupt for the same running prompt inside this window reuses the first request */
16875
+ interruptCoalesceMs: number;
16876
+ private _lastInterrupt;
16877
+ /** interrupt the CURRENTLY RUNNING prompt. A burst of /interrupt posts can make the ComfyUI
16878
+ * python process quit, so repeats for the same prompt are coalesced into one request */
16802
16879
  interrupt: () => Promise<void>;
16803
16880
  /** delete ONE prompt's server history entry */
16804
16881
  deleteHistory: (promptId: string) => Promise<void>;
@@ -17100,6 +17177,9 @@ declare class ComfyWorkflow<ID extends string = string> {
17100
17177
  apiJson: ComfyApiJson;
17101
17178
  outputFolder: AbsolutePath;
17102
17179
  constructor(host: ComfyHost<ID>, data: ComfyWorkflowData);
17180
+ /** a dry build: media loads name the local file by its hash and upload nothing, so a graph
17181
+ * can be built only to be read (serve derives workflow tags this way) */
17182
+ dry: boolean;
17103
17183
  /** nodes, in creation order */
17104
17184
  nodes: ComfyNode[];
17105
17185
  /** @internal every node constructor must call this */
@@ -17864,5 +17944,5 @@ type HostToPanel = {
17864
17944
  comfyTs: 'get-state';
17865
17945
  };
17866
17946
  //#endregion
17867
- export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyChoiceVar, type AnyVar, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, type ChoiceSelect, 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 ComfyTextOutput, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DEFAULT_STARRED_SIZES, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, type HostToPanel, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LmLoraItem, type LoraEntry, type LoraLane, type LoraLanes, type LoraMirror, type LoraNameOf, type LoraRecord, type LoraStrength, type LoraSweep, type LorasHost, type LorasInput, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, MultiChoiceVar, type NodeMode, NodeOf, OptionalChoiceVar, type PanelError, type PanelHostAction, type PanelRequest, type PanelResultAction, type PanelState, type PanelToHost, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptID, type PromptInput, type PromptLane, type PromptLanes, type PromptRelated_WsMsg, type PromptTagsOpts, type PromptValue, PromptVar, type PromptVarOpts, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SD15_SIZE_PRESETS, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, Tagged, TextVar, type TextVarOpts, ToggleVar, type VarKind, type VarPreset, type VarPresetSpec, type VarUi, type VarValues, type VarsSpec, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, activePresetLabel, 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, sizePresetsFor, toPresetList, v };
17947
+ export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyChoiceVar, type AnyVar, BaseNode, BaseNodeFactory, BaseNodeInputs, BaseNodeOutputs, type BoundVars, Branded, type CanonicalGroup, type CanonicalInput, type CanonicalLink, type CanonicalNode, type CanonicalOutput, type CanonicalWidgetValues, type CanonicalWorkflow, type ChoiceSelect, ChoiceVar, type CodegenOptions, type ComfyApiJson, type ComfyApiNodeJson, type ComfyAudioOutput, 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 ComfyTextOutput, type ComfyUnionValue, type ComfyUploadImageResult, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DEFAULT_STARRED_SIZES, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, type HostToPanel, ImageVar, ImageVarEmptyError, type ImageVarOpts, IntVar, InvalidPromptError, IsEqual, type LiteGraphJSON, type LmLoraItem, type LoraEntry, type LoraLane, type LoraLanes, type LoraMirror, type LoraNameOf, type LoraRecord, type LoraStrength, type LoraSweep, type LorasHost, type LorasInput, LorasVar, MDContent, Maybe, MediaImage, type MediaImageData, MultiChoiceVar, type NodeMode, NodeOf, OptionalChoiceVar, type PanelError, type PanelHostAction, type PanelRequest, type PanelResultAction, type PanelState, type PanelToHost, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptID, type PromptInput, type PromptLane, type PromptLanes, type PromptRelated_WsMsg, type PromptTagsOpts, type PromptValue, PromptVar, type PromptVarOpts, type QualifiedNodeKey, RelativePath, type Requirements, ResilientWebSocketClient, Result, ResultFailure, type RunSettings, SD15_SIZE_PRESETS, SaveOptions, SdkForHost, SeedVar, type SizePreset, type SizeValue, SizeVar, Tagged, TextVar, type TextVarOpts, ToggleVar, type VarKind, type VarPreset, type VarPresetSpec, type VarUi, type VarValues, type VarsSpec, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, activePresetLabel, 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, sizePresetsFor, toPresetList, v };
17868
17948
  //# 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.12.0";
104
+ var version = "2.14.0";
105
105
  //#endregion
106
106
  //#region src/litegraph/LiteGraphLinkID.ts
107
107
  const asLiteGraphLinkID = (id) => id;
@@ -2007,6 +2007,7 @@ const types$1 = scope({
2007
2007
  output: {
2008
2008
  "previews?": [{ filepath: "string" }, "[]"],
2009
2009
  "images?": "ComfyImageInfo[]",
2010
+ "audio?": "ComfyImageInfo[]",
2010
2011
  "text?": "unknown[]"
2011
2012
  },
2012
2013
  prompt_id: "PromptID"
@@ -2107,11 +2108,11 @@ var MediaImage = class MediaImage {
2107
2108
  });
2108
2109
  };
2109
2110
  this.loadInWorkflow_viaLoadImageNode = async (workflow) => {
2110
- const enumName = await this.uploadAndReturnEnumName(workflow.host);
2111
+ const enumName = workflow.dry ? this.enumName : await this.uploadAndReturnEnumName(workflow.host);
2111
2112
  return bang(workflow.builderBase.LoadImage, "host has no LoadImage node")({ image: enumName });
2112
2113
  };
2113
2114
  this.loadInWorkflowAsMask_viaLoadImageMask = async (channel, workflow) => {
2114
- const enumName = await this.uploadAndReturnEnumName(workflow.host);
2115
+ const enumName = workflow.dry ? this.enumName : await this.uploadAndReturnEnumName(workflow.host);
2115
2116
  return bang(workflow.builderBase.LoadImageMask, "host has no LoadImageMask node")({
2116
2117
  image: enumName,
2117
2118
  channel
@@ -2259,6 +2260,18 @@ var MediaImage = class MediaImage {
2259
2260
  * A claim is released as soon as the write lands (the file itself then holds
2260
2261
  * the name) or fails (the name is free again) — the set never accumulates */
2261
2262
  const CLAIMED_OUTPUT_PATHS = /* @__PURE__ */ new Set();
2263
+ const AUDIO_MIMES = {
2264
+ flac: "audio/flac",
2265
+ mp3: "audio/mpeg",
2266
+ opus: "audio/ogg",
2267
+ ogg: "audio/ogg",
2268
+ wav: "audio/wav",
2269
+ m4a: "audio/mp4"
2270
+ };
2271
+ function audioMime(filename) {
2272
+ const ext = filename.split(".").pop()?.toLowerCase() ?? "";
2273
+ return AUDIO_MIMES[ext] ?? "application/octet-stream";
2274
+ }
2262
2275
  var ComfyExecution = class {
2263
2276
  get host() {
2264
2277
  return this.workflow.host;
@@ -2333,8 +2346,51 @@ var ComfyExecution = class {
2333
2346
  error: e
2334
2347
  });
2335
2348
  }));
2349
+ for (const audio of msg.data.output?.audio ?? []) this.pendingPromises.push(this.retrieveAudio(audio, promptNodeID).catch((e) => {
2350
+ console.error(`🔴 failed to retrieve ${audio.filename}:`, e);
2351
+ this.audioErrors.push({
2352
+ audio,
2353
+ error: e
2354
+ });
2355
+ }));
2336
2356
  };
2337
2357
  this.pendingPromises = [];
2358
+ this.audioErrors = [];
2359
+ this.audios = [];
2360
+ this.retrieveAudio = async (info, promptNodeID) => {
2361
+ const response = await this.host.fetchFile("/view?" + new URLSearchParams(info).toString());
2362
+ const bytes = new Uint8Array(await response.arrayBuffer());
2363
+ const mime = audioMime(info.filename);
2364
+ const sf = this.save;
2365
+ if (sf == null) {
2366
+ this.audios.push({
2367
+ nodeId: promptNodeID,
2368
+ filename: info.filename,
2369
+ mime,
2370
+ bytes,
2371
+ absPath: null
2372
+ });
2373
+ return;
2374
+ }
2375
+ const promptPrefix = this.workflow.data.apiJson?.[promptNodeID]?.inputs["filename_prefix"];
2376
+ const written = await this.encodeAndWrite({
2377
+ bytes,
2378
+ sf: {
2379
+ ...sf,
2380
+ format: "raw"
2381
+ },
2382
+ filenamePrefix: typeof promptPrefix === "string" ? promptPrefix : void 0,
2383
+ subfolder: info.subfolder,
2384
+ filename: info.filename
2385
+ });
2386
+ this.audios.push({
2387
+ nodeId: promptNodeID,
2388
+ filename: info.filename,
2389
+ mime,
2390
+ bytes,
2391
+ absPath: written.path
2392
+ });
2393
+ };
2338
2394
  this.imageErrors = [];
2339
2395
  this.retrieveImage = async (comfyImageInfo, promptNodeID) => {
2340
2396
  const promptNode = this.workflow.data.apiJson?.[promptNodeID];
@@ -2506,6 +2562,7 @@ var ComfyExecution = class {
2506
2562
  if (!this.logProgress) return;
2507
2563
  const p = this.progress;
2508
2564
  const outputs = [`${this.images.length} image(s)`];
2565
+ if (this.audios.length > 0) outputs.push(`${this.audios.length} audio(s)`);
2509
2566
  if (this.texts.length > 0) outputs.push(`${this.texts.length} text(s)`);
2510
2567
  const line = `${this.status === "Failure" ? "🔴" : "🟢"} ${this.status.toLowerCase()} in ${(p.elapsedMs / 1e3).toFixed(1)}s · ${outputs.join(" · ")}`;
2511
2568
  if (globalThis.process?.stdout?.isTTY) process.stdout.write(`\r\x1b[2K${line}\n`);
@@ -2736,6 +2793,7 @@ var ComfyWorkflow = class {
2736
2793
  constructor(host, data) {
2737
2794
  this.host = host;
2738
2795
  this.data = data;
2796
+ this.dry = false;
2739
2797
  this.nodes = [];
2740
2798
  this.registerNode = (node) => {
2741
2799
  if (this.data.apiJson == null) throw new Error("graph not hydrated");
@@ -3233,7 +3291,7 @@ function codegenSDK(opts) {
3233
3291
  p("}");
3234
3292
  p(`interface Builder {`);
3235
3293
  for (const n of nodes) {
3236
- const baseDescription = `displayName="${n.raw.display_name}" category="${n.category}" name="${n.nameInComfy}" output=[${n.outputs.map((o) => o.outKey).join(", ")}]`;
3294
+ const baseDescription = `displayName="${n.raw.display_name ?? n.nameInComfy}" category="${n.category}" name="${n.nameInComfy}" output=[${n.outputs.map((o) => o.outKey).join(", ")}]`;
3237
3295
  if (n.raw.description) {
3238
3296
  p(` /**`);
3239
3297
  p(n.raw.description.split("\n").map((i) => ` * ${i}`).join("\n"));
@@ -3587,16 +3645,16 @@ const types = scope({
3587
3645
  "hidden?": "string[]"
3588
3646
  },
3589
3647
  output: "ComfyInputType[]",
3590
- output_is_list: "boolean[]",
3648
+ output_is_list: "(boolean | null)[]",
3591
3649
  output_name: "string[]",
3592
3650
  name: "string",
3593
- display_name: "string",
3651
+ display_name: "string | null",
3594
3652
  description: "string",
3595
3653
  /** */
3596
3654
  python_module: "string",
3597
3655
  category: "string",
3598
3656
  output_node: "boolean",
3599
- "output_tooltips?": "string[]",
3657
+ "output_tooltips?": "(string | null)[]",
3600
3658
  "deprecated?": "boolean",
3601
3659
  "experimental?": "boolean"
3602
3660
  },
@@ -3612,7 +3670,7 @@ const types = scope({
3612
3670
  ComfyInputOpts_advanced: {
3613
3671
  "tooltip?": "string | null | ComfyInputOpts_advanced",
3614
3672
  "multiline?": "boolean | null",
3615
- "default?": "boolean | number | string | null | number[]",
3673
+ "default?": "boolean | number | string | null | number[] | object",
3616
3674
  "forceInput?": "boolean | null",
3617
3675
  "min?": "number | null",
3618
3676
  "round?": "boolean | number | null",
@@ -3973,14 +4031,46 @@ var ResilientWebSocketClient = class {
3973
4031
  this.isOpen = false;
3974
4032
  this.debugMessages = [];
3975
4033
  this.hasEverOpened = false;
4034
+ this.heartbeat = null;
3976
4035
  this.permanentlyClosed = false;
3977
4036
  this.url = options.url();
3978
4037
  this.connect();
3979
4038
  }
4039
+ stopHeartbeat() {
4040
+ if (this.heartbeat != null) clearInterval(this.heartbeat);
4041
+ this.heartbeat = null;
4042
+ }
4043
+ /** ping on a timer; no pong since the previous ping = the peer is gone, drop the socket */
4044
+ startHeartbeat(ws) {
4045
+ this.stopHeartbeat();
4046
+ if (typeof ws.ping !== "function" || typeof ws.on !== "function") return;
4047
+ let awaitingPong = false;
4048
+ ws.on("pong", () => {
4049
+ awaitingPong = false;
4050
+ });
4051
+ const ms = this.options.heartbeatMs ?? 15e3;
4052
+ this.heartbeat = setInterval(() => {
4053
+ if (ws !== this.currentWS) return this.stopHeartbeat();
4054
+ if (awaitingPong) {
4055
+ this.addError(`no pong within ${ms}ms: the host is gone, dropping the socket to reconnect`);
4056
+ this.stopHeartbeat();
4057
+ if (typeof ws.terminate === "function") ws.terminate();
4058
+ else ws.close();
4059
+ return;
4060
+ }
4061
+ awaitingPong = true;
4062
+ try {
4063
+ ws.ping?.();
4064
+ } catch (e) {
4065
+ this.addError(`ping failed: ${extractErrorMessage(e)}`);
4066
+ }
4067
+ }, ms);
4068
+ }
3980
4069
  /** close and stop reconnecting (lets a script exit cleanly) */
3981
4070
  disconnectPermanently() {
3982
4071
  this.permanentlyClosed = true;
3983
4072
  if (this.reconnectTimeout) clearTimeout(this.reconnectTimeout);
4073
+ this.stopHeartbeat();
3984
4074
  this.currentWS?.close();
3985
4075
  this.currentWS = null;
3986
4076
  this.isOpen = false;
@@ -3999,6 +4089,7 @@ var ResilientWebSocketClient = class {
3999
4089
  this.isOpen = false;
4000
4090
  const prevWS = this.currentWS;
4001
4091
  if (this.reconnectTimeout) clearTimeout(this.reconnectTimeout);
4092
+ this.stopHeartbeat();
4002
4093
  this.currentWS = null;
4003
4094
  if (prevWS) {
4004
4095
  this.addInfo("Previous WebSocket discarded");
@@ -4006,7 +4097,7 @@ var ResilientWebSocketClient = class {
4006
4097
  }
4007
4098
  let ws;
4008
4099
  try {
4009
- const transport = await resolveWsTransport();
4100
+ const transport = this.options.transport ?? await resolveWsTransport();
4010
4101
  if (this.permanentlyClosed) return;
4011
4102
  const headers = this.options.headers?.() ?? {};
4012
4103
  ws = transport.supportsHeaders ? new transport.ctor(this.url, { headers }) : new transport.ctor(this.headerlessUrl(headers));
@@ -4028,10 +4119,12 @@ var ResilientWebSocketClient = class {
4028
4119
  this.isOpen = true;
4029
4120
  this.options.onConnectOrReconnect();
4030
4121
  this.flushMessageBuffer();
4122
+ this.startHeartbeat(ws);
4031
4123
  };
4032
4124
  ws.onclose = (event) => {
4033
4125
  if (ws !== this.currentWS) return;
4034
4126
  this.isOpen = false;
4127
+ this.stopHeartbeat();
4035
4128
  this.options.onClose();
4036
4129
  if (this.permanentlyClosed) return;
4037
4130
  this.addError(`WebSocket closed (reason=${JSON.stringify(event.reason)}, code=${event.code})`);
@@ -4040,8 +4133,9 @@ var ResilientWebSocketClient = class {
4040
4133
  this.options.onFirstConnectFailed(/* @__PURE__ */ new Error(`connection refused (code=${event.code}${event.reason === "" ? "" : `, ${event.reason}`})`));
4041
4134
  return;
4042
4135
  }
4043
- this.addInfo("⏱️ reconnecting in 2 seconds...");
4044
- this.reconnectTimeout = setTimeout(() => void this.connect(), 2e3);
4136
+ const wait = this.options.reconnectMs ?? 2e3;
4137
+ this.addInfo(`⏱️ reconnecting in ${wait / 1e3} seconds...`);
4138
+ this.reconnectTimeout = setTimeout(() => void this.connect(), wait);
4045
4139
  };
4046
4140
  ws.onerror = (event) => {
4047
4141
  if (ws !== this.currentWS) return;
@@ -5371,12 +5465,15 @@ var DefinedWorkflow = class {
5371
5465
  * build() for copy/export never advances). `p.host` substitutes the host
5372
5466
  * the graph is built against (TUI host override): node/model availability
5373
5467
  * there surfaces as workflow.problems / server validation, by design.
5468
+ * `p.dry` builds a graph only to read it: nothing is uploaded, lastWorkflow is left alone.
5374
5469
  */
5375
5470
  async build(p = {}) {
5376
5471
  const wf = (p.host ?? this.host).workflow({ id: this.spec.id });
5472
+ wf.dry = p.dry === true;
5377
5473
  const values = varValues(this.vars);
5378
5474
  if (p.advance) for (const varDef of Object.values(this.vars)) varDef.afterRun();
5379
5475
  await this.spec.build(wf.builder, values, wf);
5476
+ if (wf.dry) return wf;
5380
5477
  this.lastWorkflow = wf;
5381
5478
  return wf;
5382
5479
  }
@@ -5677,8 +5774,22 @@ var ComfyHost = class {
5677
5774
  this.clearQueue = () => {
5678
5775
  return this.postJSON_("/queue", { clear: true });
5679
5776
  };
5777
+ this.interruptCoalesceMs = 3e3;
5778
+ this._lastInterrupt = null;
5680
5779
  this.interrupt = () => {
5681
- return this.postJSON_("/interrupt", {});
5780
+ const now = Date.now();
5781
+ const last = this._lastInterrupt;
5782
+ if (last != null && last.promptID === this.activePromptID && now - last.at < this.interruptCoalesceMs) return last.req;
5783
+ const req = this.postJSON_("/interrupt", {});
5784
+ this._lastInterrupt = {
5785
+ promptID: this.activePromptID,
5786
+ at: now,
5787
+ req
5788
+ };
5789
+ req.catch(() => {
5790
+ if (this._lastInterrupt?.req === req) this._lastInterrupt = null;
5791
+ });
5792
+ return req;
5682
5793
  };
5683
5794
  this.deleteHistory = (promptId) => {
5684
5795
  return this.postJSON_("/history", { delete: [promptId] });