comfy-ts 2.16.0 → 2.17.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 (71) hide show
  1. package/README.md +23 -0
  2. package/dist/{run-serve-C78hD7t9.js → ServeApp-qXcQfdgT.js} +18 -445
  3. package/dist/ServeApp-qXcQfdgT.js.map +1 -0
  4. package/dist/cli.js +72 -9
  5. package/dist/cli.js.map +1 -1
  6. package/dist/exampleAssets-BfWzygoM.js +38 -0
  7. package/dist/exampleAssets-BfWzygoM.js.map +1 -0
  8. package/dist/{LogsSt-Ct7Le0S_.js → findDefinedWorkflow-0lG-VTEd.js} +201 -201
  9. package/dist/findDefinedWorkflow-0lG-VTEd.js.map +1 -0
  10. package/dist/index.cjs +182 -69
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +61 -8
  13. package/dist/index.d.ts +61 -8
  14. package/dist/index.js +182 -69
  15. package/dist/index.js.map +1 -1
  16. package/dist/run-run-tg82jUIk.js +450 -0
  17. package/dist/run-run-tg82jUIk.js.map +1 -0
  18. package/dist/run-serve-DaXzoVTS.js +464 -0
  19. package/dist/run-serve-DaXzoVTS.js.map +1 -0
  20. package/dist/{run-tui-nPETFRmk.js → run-tui-Bw7BA75d.js} +7 -38
  21. package/dist/run-tui-Bw7BA75d.js.map +1 -0
  22. package/dist/{schemaDrift-wb5XkrHV.js → schemaDrift-CbsABBuk.js} +3 -2
  23. package/dist/{schemaDrift-wb5XkrHV.js.map → schemaDrift-CbsABBuk.js.map} +1 -1
  24. package/dist/serve-web.js +56 -48
  25. package/dist/{state-BMW57_M0.js → state-zTow5ucI.js} +182 -70
  26. package/dist/state-zTow5ucI.js.map +1 -0
  27. package/dist/web.d.ts +61 -8
  28. package/dist/web.js +182 -69
  29. package/dist/web.js.map +1 -1
  30. package/examples/README.md +1 -0
  31. package/examples/rvion/15-tts-voice-clone.cflow.ts +8 -8
  32. package/examples/rvion/16-tts-voice-design.cflow.ts +71 -0
  33. package/guide-for-agents.md +3 -0
  34. package/package.json +2 -2
  35. package/src/cli/bunHop.ts +49 -0
  36. package/src/cli/comfy-ts-cli.ts +18 -5
  37. package/src/cli/run/findModules.ts +36 -0
  38. package/src/cli/run/flagValue.ts +61 -0
  39. package/src/cli/run/outputPaths.ts +41 -0
  40. package/src/cli/run/pickModule.ts +41 -0
  41. package/src/cli/run/run-run.ts +250 -0
  42. package/src/cli/run/runArgs.ts +61 -0
  43. package/src/cli/run/sidecar.ts +27 -0
  44. package/src/cli/serve/ServeApp.ts +13 -39
  45. package/src/cli/serve/run-serve.ts +51 -13
  46. package/src/cli/serve/web/components/App.tsx +2 -0
  47. package/src/cli/serve/web/components/DialogLayer.tsx +55 -0
  48. package/src/cli/serve/web/components/DraftTabs.tsx +16 -5
  49. package/src/cli/serve/web/components/PromptEnhancer.tsx +15 -9
  50. package/src/cli/serve/web/components/SideMenu.tsx +16 -8
  51. package/src/cli/serve/web/state/WebSt.ts +10 -1
  52. package/src/cli/serve/web/state/dialog.ts +59 -0
  53. package/src/cli/serve/web/state/draftTabs.ts +12 -0
  54. package/src/cli/serve/web/state/keptLines.ts +1 -1
  55. package/src/cli/serve/web/state/shortcutCatalog.ts +1 -0
  56. package/src/cli/serve/web/styles.ts +8 -0
  57. package/src/coreExports.ts +2 -0
  58. package/src/host/ComfyHost.ts +73 -40
  59. package/src/host/previewMethod.ts +29 -0
  60. package/src/litegraph/convertFlowToLiteGraphJSON.ts +38 -20
  61. package/src/promptEnhancers.ts +1 -1
  62. package/src/runner/ComfyExecution.ts +45 -1
  63. package/src/runner/ComfyWorkflow.ts +6 -1
  64. package/src/runner/ComfyWsApi.ts +1 -1
  65. package/src/runner/wsBinaryFrame.ts +48 -25
  66. package/src/vars/ComfyVars.ts +3 -0
  67. package/src/vars/DefinedWorkflow.ts +1 -0
  68. package/dist/LogsSt-Ct7Le0S_.js.map +0 -1
  69. package/dist/run-serve-C78hD7t9.js.map +0 -1
  70. package/dist/run-tui-nPETFRmk.js.map +0 -1
  71. package/dist/state-BMW57_M0.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -12283,6 +12283,7 @@ type PendingBinaryFrame = {
12283
12283
  type: 'binary_preview_frame';
12284
12284
  bytes: Uint8Array;
12285
12285
  mime: string;
12286
+ metadata: unknown;
12286
12287
  };
12287
12288
  type PendingWsItem = PromptRelated_WsMsg | PendingBinaryFrame;
12288
12289
  type WsMsg = typeof types$1.WsMsg.infer;
@@ -12759,6 +12760,25 @@ type ExecutionProgress = ProgressReport & {
12759
12760
  * puts its partial answer here every few tokens */
12760
12761
  progressText: string | null;
12761
12762
  };
12763
+ /** one live preview frame of a run: the image a sampler is forming, once per step */
12764
+ type ExecutionPreview = {
12765
+ promptId: PromptID;
12766
+ /** the image as ComfyUI encoded it, jpeg or png */
12767
+ bytes: Uint8Array;
12768
+ mime: string;
12769
+ /** the node that sent the frame: the frame's own metadata when it names one (type 4 frames),
12770
+ * else the node executing when it arrived. Null when neither is known */
12771
+ nodeId: ComfyNodeId | null;
12772
+ /** that node's class name in the sent prompt (`KSampler`), null when unknown */
12773
+ nodeName: string | null;
12774
+ /** that node's own counter when the frame arrived (sampler step of total), null when unknown */
12775
+ step: {
12776
+ value: number;
12777
+ max: number;
12778
+ } | null;
12779
+ /** the raw metadata json of a type 4 frame (`node_id`, `prompt_id`, …), null on a type 1 frame */
12780
+ metadata: unknown;
12781
+ };
12762
12782
  declare class ComfyExecution {
12763
12783
  workflow: ComfyWorkflow;
12764
12784
  data: ComfyExecutionData;
@@ -12769,6 +12789,7 @@ declare class ComfyExecution {
12769
12789
  scrubHistory?: boolean;
12770
12790
  ephemeral?: boolean;
12771
12791
  onProgress?: Maybe<(p: ExecutionProgress) => void>;
12792
+ onPreview?: Maybe<(p: ExecutionPreview) => void>;
12772
12793
  logProgress?: boolean;
12773
12794
  });
12774
12795
  /** local disk saving, OPT-IN (architecture.md item 14); null = outputs stay in memory */
@@ -12781,6 +12802,8 @@ declare class ComfyExecution {
12781
12802
  snapshot: Maybe<ExecutionSnapshot>;
12782
12803
  /** called on every progress-relevant websocket message */
12783
12804
  onProgress: Maybe<(p: ExecutionProgress) => void>;
12805
+ /** called on every live preview frame of this run. Null = frames are never decoded for it */
12806
+ onPreview: Maybe<(p: ExecutionPreview) => void>;
12784
12807
  /** render a live single-line progress report to the console */
12785
12808
  logProgress: boolean;
12786
12809
  readonly startedAt: number;
@@ -12834,6 +12857,13 @@ declare class ComfyExecution {
12834
12857
  * SENT snapshot (the ephemeral rewrite only touches the snapshot, so the
12835
12858
  * live graph may still say SaveImage) — binary frames are then OUTPUTS */
12836
12859
  get wsOutputNodeExecuting(): boolean;
12860
+ /** @internal a live preview frame of this run; never an output (the host routes ws saver frames
12861
+ * to onWsImageOutput before they get here) */
12862
+ onPreviewFrame(p: {
12863
+ bytes: Uint8Array;
12864
+ mime: string;
12865
+ metadata: unknown;
12866
+ }): void;
12837
12867
  /** one binary ws frame = one output image of the executing SaveImageWebsocket
12838
12868
  * node (architecture.md item 14 — the zero-server-disk path) */
12839
12869
  onWsImageOutput: (p: {
@@ -12863,6 +12893,9 @@ declare class ComfyExecution {
12863
12893
  private _finish;
12864
12894
  }
12865
12895
  //#endregion
12896
+ //#region src/host/previewMethod.d.ts
12897
+ type PreviewMethod = 'none' | 'auto' | 'latent2rgb' | 'taesd';
12898
+ //#endregion
12866
12899
  //#region src/sdk-generator/comfyui-sdk-codegen.d.ts
12867
12900
  /**
12868
12901
  * convert a host id to the namespace name it gets inside the global `Comfy` namespace
@@ -16586,6 +16619,9 @@ type MediaVarOpts = {
16586
16619
  * not what the api accepts) */
16587
16620
  extensions?: readonly string[];
16588
16621
  label?: string;
16622
+ /** the text var a file's `<name>.txt` sidecar fills, when a driver sets this var from a file
16623
+ * and leaves that one unset: a voice clip's transcript (`comfy-ts run`) */
16624
+ sidecarText?: TextVar;
16589
16625
  };
16590
16626
  type ImageVarOpts = MediaVarOpts;
16591
16627
  type AudioVarOpts = MediaVarOpts;
@@ -16887,6 +16923,12 @@ declare class ComfyHostAuthError extends Error {
16887
16923
  hostId: string;
16888
16924
  constructor(code: 401 | 402 | 429, hostId: string, message: string);
16889
16925
  }
16926
+ type LatentPreview = {
16927
+ promptID: Maybe<PromptID>;
16928
+ receivedAt: number_Timestamp;
16929
+ blob: Blob;
16930
+ url: string;
16931
+ };
16890
16932
  declare class ComfyHost<ID extends string = string> {
16891
16933
  data: ComfyHostData & {
16892
16934
  id: ID;
@@ -17028,6 +17070,10 @@ declare class ComfyHost<ID extends string = string> {
17028
17070
  deleteHistory: (promptId: string) => Promise<void>;
17029
17071
  /** wipe the server's WHOLE prompt history (every user of that server) */
17030
17072
  clearHistory: () => Promise<void>;
17073
+ /** the `--preview-method` this host was launched with, read from `GET /system_stats`.
17074
+ * `'none'` (ComfyUI's default) means no live preview frame will ever arrive; null = the host
17075
+ * does not publish its launch flags (a cloud host), so only a run can tell */
17076
+ fetchPreviewMethod: () => Promise<PreviewMethod | null>;
17031
17077
  /** the server's recent console buffer (entries are write CHUNKS, not lines) */
17032
17078
  fetchRawLogs: () => Promise<{
17033
17079
  entries: LogEntry[];
@@ -17056,13 +17102,12 @@ declare class ComfyHost<ID extends string = string> {
17056
17102
  private activePromptID;
17057
17103
  /** method to either execute or buffer the incoming message */
17058
17104
  routeOrBuffer(prompt_id: PromptID, msg: PromptRelated_WsMsg): void;
17059
- /** the latent image beeing generated, in case you want to display it */
17060
- latentPreview: Maybe<{
17061
- promptID: Maybe<PromptID>;
17062
- receivedAt: number_Timestamp;
17063
- blob: Blob;
17064
- url: string;
17065
- }>;
17105
+ /** the last raw preview frame; `latentPreview` decodes it only when read */
17106
+ private _latentFrame;
17107
+ private _latentPreview;
17108
+ /** the latent image beeing generated, in case you want to display it. Built on read: a
17109
+ * session that never reads it never decodes a frame nor holds an object url */
17110
+ get latentPreview(): Maybe<LatentPreview>;
17066
17111
  /** byte-level latent-preview hook (e.g. TUI live preview panel) */
17067
17112
  onLatentPreview: Maybe<(p: {
17068
17113
  bytes: Uint8Array;
@@ -17097,6 +17142,10 @@ declare class ComfyHost<ID extends string = string> {
17097
17142
  * sockets keep streaming (a half-open socket receives nothing, so this
17098
17143
  * never revives one) */
17099
17144
  lastWsMessageAt: number | null;
17145
+ /** a type 1 or 4 frame. Parsed only when someone wants it, in this order (architecture.md,
17146
+ * Live previews): the ws saver's output, the pre-registration buffer, the run's onPreview,
17147
+ * the host hook. Nobody listening = the frame is kept by reference and never copied */
17148
+ private onPreviewFrame;
17100
17149
  onMessage(e: WsMessageEvent): void;
17101
17150
  }
17102
17151
  //#endregion
@@ -17294,6 +17343,10 @@ type RunSettings = {
17294
17343
  log?: boolean;
17295
17344
  /** called on every progress-relevant websocket message */
17296
17345
  onProgress?: (p: ExecutionProgress) => void;
17346
+ /** called on every live preview frame of this run (the image a sampler is forming). Opt in:
17347
+ * without it no frame is decoded for the run. ComfyUI sends frames only when launched with
17348
+ * `--preview-method`, see `host.fetchPreviewMethod()` */
17349
+ onPreview?: (p: ExecutionPreview) => void;
17297
17350
  };
17298
17351
  /** exactly what was sent to the host for one execution, frozen at send time */
17299
17352
  type ExecutionSnapshot = {
@@ -18047,5 +18100,5 @@ declare function promptEnhancerPresets(): VarPresetSpec;
18047
18100
  //#region src/cli/tui-env.d.ts
18048
18101
  declare function isTuiActive(): boolean;
18049
18102
  //#endregion
18050
- export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyChoiceVar, type AnyVar, AudioVar, type AudioVarOpts, 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, type ComfyVideoOutput, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_AUDIO_EXTENSIONS, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DEFAULT_STARRED_SIZES, DEFAULT_VIDEO_EXTENSIONS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, type HostSlotSource, 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, MediaVar, MediaVarEmptyError, type MediaVarOpts, type ModelVarOpts, MultiChoiceVar, type NodeMode, NodeOf, OptionalChoiceVar, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptEnhancer, 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, type SlotNameOf, type SlotValueOf, Tagged, TextVar, type TextVarOpts, ToggleVar, type VarKind, type VarPreset, type VarPresetSpec, type VarUi, type VarValues, type VarsSpec, VideoVar, type VideoVarOpts, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, activePresetLabel, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, exampleMediaPath, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, isTuiActive, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, promptEnhancerPresets, readPromptEnhancers, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, sizePresetsFor, toPresetList, v };
18103
+ export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyChoiceVar, type AnyVar, AudioVar, type AudioVarOpts, 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, type ComfyVideoOutput, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_AUDIO_EXTENSIONS, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DEFAULT_STARRED_SIZES, DEFAULT_VIDEO_EXTENSIONS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionPreview, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, type HostSlotSource, 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, MediaVar, MediaVarEmptyError, type MediaVarOpts, type ModelVarOpts, MultiChoiceVar, type NodeMode, NodeOf, OptionalChoiceVar, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type PreviewMethod, type ProgressReport, type PromptEnhancer, 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, type SlotNameOf, type SlotValueOf, Tagged, TextVar, type TextVarOpts, ToggleVar, type VarKind, type VarPreset, type VarPresetSpec, type VarUi, type VarValues, type VarsSpec, VideoVar, type VideoVarOpts, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, activePresetLabel, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, exampleMediaPath, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, isTuiActive, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, promptEnhancerPresets, readPromptEnhancers, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, sizePresetsFor, toPresetList, v };
18051
18104
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -12283,6 +12283,7 @@ type PendingBinaryFrame = {
12283
12283
  type: 'binary_preview_frame';
12284
12284
  bytes: Uint8Array;
12285
12285
  mime: string;
12286
+ metadata: unknown;
12286
12287
  };
12287
12288
  type PendingWsItem = PromptRelated_WsMsg | PendingBinaryFrame;
12288
12289
  type WsMsg = typeof types$1.WsMsg.infer;
@@ -12759,6 +12760,25 @@ type ExecutionProgress = ProgressReport & {
12759
12760
  * puts its partial answer here every few tokens */
12760
12761
  progressText: string | null;
12761
12762
  };
12763
+ /** one live preview frame of a run: the image a sampler is forming, once per step */
12764
+ type ExecutionPreview = {
12765
+ promptId: PromptID;
12766
+ /** the image as ComfyUI encoded it, jpeg or png */
12767
+ bytes: Uint8Array;
12768
+ mime: string;
12769
+ /** the node that sent the frame: the frame's own metadata when it names one (type 4 frames),
12770
+ * else the node executing when it arrived. Null when neither is known */
12771
+ nodeId: ComfyNodeId | null;
12772
+ /** that node's class name in the sent prompt (`KSampler`), null when unknown */
12773
+ nodeName: string | null;
12774
+ /** that node's own counter when the frame arrived (sampler step of total), null when unknown */
12775
+ step: {
12776
+ value: number;
12777
+ max: number;
12778
+ } | null;
12779
+ /** the raw metadata json of a type 4 frame (`node_id`, `prompt_id`, …), null on a type 1 frame */
12780
+ metadata: unknown;
12781
+ };
12762
12782
  declare class ComfyExecution {
12763
12783
  workflow: ComfyWorkflow;
12764
12784
  data: ComfyExecutionData;
@@ -12769,6 +12789,7 @@ declare class ComfyExecution {
12769
12789
  scrubHistory?: boolean;
12770
12790
  ephemeral?: boolean;
12771
12791
  onProgress?: Maybe<(p: ExecutionProgress) => void>;
12792
+ onPreview?: Maybe<(p: ExecutionPreview) => void>;
12772
12793
  logProgress?: boolean;
12773
12794
  });
12774
12795
  /** local disk saving, OPT-IN (architecture.md item 14); null = outputs stay in memory */
@@ -12781,6 +12802,8 @@ declare class ComfyExecution {
12781
12802
  snapshot: Maybe<ExecutionSnapshot>;
12782
12803
  /** called on every progress-relevant websocket message */
12783
12804
  onProgress: Maybe<(p: ExecutionProgress) => void>;
12805
+ /** called on every live preview frame of this run. Null = frames are never decoded for it */
12806
+ onPreview: Maybe<(p: ExecutionPreview) => void>;
12784
12807
  /** render a live single-line progress report to the console */
12785
12808
  logProgress: boolean;
12786
12809
  readonly startedAt: number;
@@ -12834,6 +12857,13 @@ declare class ComfyExecution {
12834
12857
  * SENT snapshot (the ephemeral rewrite only touches the snapshot, so the
12835
12858
  * live graph may still say SaveImage) — binary frames are then OUTPUTS */
12836
12859
  get wsOutputNodeExecuting(): boolean;
12860
+ /** @internal a live preview frame of this run; never an output (the host routes ws saver frames
12861
+ * to onWsImageOutput before they get here) */
12862
+ onPreviewFrame(p: {
12863
+ bytes: Uint8Array;
12864
+ mime: string;
12865
+ metadata: unknown;
12866
+ }): void;
12837
12867
  /** one binary ws frame = one output image of the executing SaveImageWebsocket
12838
12868
  * node (architecture.md item 14 — the zero-server-disk path) */
12839
12869
  onWsImageOutput: (p: {
@@ -12863,6 +12893,9 @@ declare class ComfyExecution {
12863
12893
  private _finish;
12864
12894
  }
12865
12895
  //#endregion
12896
+ //#region src/host/previewMethod.d.ts
12897
+ type PreviewMethod = 'none' | 'auto' | 'latent2rgb' | 'taesd';
12898
+ //#endregion
12866
12899
  //#region src/sdk-generator/comfyui-sdk-codegen.d.ts
12867
12900
  /**
12868
12901
  * convert a host id to the namespace name it gets inside the global `Comfy` namespace
@@ -16586,6 +16619,9 @@ type MediaVarOpts = {
16586
16619
  * not what the api accepts) */
16587
16620
  extensions?: readonly string[];
16588
16621
  label?: string;
16622
+ /** the text var a file's `<name>.txt` sidecar fills, when a driver sets this var from a file
16623
+ * and leaves that one unset: a voice clip's transcript (`comfy-ts run`) */
16624
+ sidecarText?: TextVar;
16589
16625
  };
16590
16626
  type ImageVarOpts = MediaVarOpts;
16591
16627
  type AudioVarOpts = MediaVarOpts;
@@ -16887,6 +16923,12 @@ declare class ComfyHostAuthError extends Error {
16887
16923
  hostId: string;
16888
16924
  constructor(code: 401 | 402 | 429, hostId: string, message: string);
16889
16925
  }
16926
+ type LatentPreview = {
16927
+ promptID: Maybe<PromptID>;
16928
+ receivedAt: number_Timestamp;
16929
+ blob: Blob;
16930
+ url: string;
16931
+ };
16890
16932
  declare class ComfyHost<ID extends string = string> {
16891
16933
  data: ComfyHostData & {
16892
16934
  id: ID;
@@ -17028,6 +17070,10 @@ declare class ComfyHost<ID extends string = string> {
17028
17070
  deleteHistory: (promptId: string) => Promise<void>;
17029
17071
  /** wipe the server's WHOLE prompt history (every user of that server) */
17030
17072
  clearHistory: () => Promise<void>;
17073
+ /** the `--preview-method` this host was launched with, read from `GET /system_stats`.
17074
+ * `'none'` (ComfyUI's default) means no live preview frame will ever arrive; null = the host
17075
+ * does not publish its launch flags (a cloud host), so only a run can tell */
17076
+ fetchPreviewMethod: () => Promise<PreviewMethod | null>;
17031
17077
  /** the server's recent console buffer (entries are write CHUNKS, not lines) */
17032
17078
  fetchRawLogs: () => Promise<{
17033
17079
  entries: LogEntry[];
@@ -17056,13 +17102,12 @@ declare class ComfyHost<ID extends string = string> {
17056
17102
  private activePromptID;
17057
17103
  /** method to either execute or buffer the incoming message */
17058
17104
  routeOrBuffer(prompt_id: PromptID, msg: PromptRelated_WsMsg): void;
17059
- /** the latent image beeing generated, in case you want to display it */
17060
- latentPreview: Maybe<{
17061
- promptID: Maybe<PromptID>;
17062
- receivedAt: number_Timestamp;
17063
- blob: Blob;
17064
- url: string;
17065
- }>;
17105
+ /** the last raw preview frame; `latentPreview` decodes it only when read */
17106
+ private _latentFrame;
17107
+ private _latentPreview;
17108
+ /** the latent image beeing generated, in case you want to display it. Built on read: a
17109
+ * session that never reads it never decodes a frame nor holds an object url */
17110
+ get latentPreview(): Maybe<LatentPreview>;
17066
17111
  /** byte-level latent-preview hook (e.g. TUI live preview panel) */
17067
17112
  onLatentPreview: Maybe<(p: {
17068
17113
  bytes: Uint8Array;
@@ -17097,6 +17142,10 @@ declare class ComfyHost<ID extends string = string> {
17097
17142
  * sockets keep streaming (a half-open socket receives nothing, so this
17098
17143
  * never revives one) */
17099
17144
  lastWsMessageAt: number | null;
17145
+ /** a type 1 or 4 frame. Parsed only when someone wants it, in this order (architecture.md,
17146
+ * Live previews): the ws saver's output, the pre-registration buffer, the run's onPreview,
17147
+ * the host hook. Nobody listening = the frame is kept by reference and never copied */
17148
+ private onPreviewFrame;
17100
17149
  onMessage(e: WsMessageEvent): void;
17101
17150
  }
17102
17151
  //#endregion
@@ -17294,6 +17343,10 @@ type RunSettings = {
17294
17343
  log?: boolean;
17295
17344
  /** called on every progress-relevant websocket message */
17296
17345
  onProgress?: (p: ExecutionProgress) => void;
17346
+ /** called on every live preview frame of this run (the image a sampler is forming). Opt in:
17347
+ * without it no frame is decoded for the run. ComfyUI sends frames only when launched with
17348
+ * `--preview-method`, see `host.fetchPreviewMethod()` */
17349
+ onPreview?: (p: ExecutionPreview) => void;
17297
17350
  };
17298
17351
  /** exactly what was sent to the host for one execution, frozen at send time */
17299
17352
  type ExecutionSnapshot = {
@@ -18047,5 +18100,5 @@ declare function promptEnhancerPresets(): VarPresetSpec;
18047
18100
  //#region src/cli/tui-env.d.ts
18048
18101
  declare function isTuiActive(): boolean;
18049
18102
  //#endregion
18050
- export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyChoiceVar, type AnyVar, AudioVar, type AudioVarOpts, 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, type ComfyVideoOutput, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_AUDIO_EXTENSIONS, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DEFAULT_STARRED_SIZES, DEFAULT_VIDEO_EXTENSIONS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, type HostSlotSource, 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, MediaVar, MediaVarEmptyError, type MediaVarOpts, type ModelVarOpts, MultiChoiceVar, type NodeMode, NodeOf, OptionalChoiceVar, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type ProgressReport, type PromptEnhancer, 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, type SlotNameOf, type SlotValueOf, Tagged, TextVar, type TextVarOpts, ToggleVar, type VarKind, type VarPreset, type VarPresetSpec, type VarUi, type VarValues, type VarsSpec, VideoVar, type VideoVarOpts, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, activePresetLabel, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, exampleMediaPath, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, isTuiActive, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, promptEnhancerPresets, readPromptEnhancers, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, sizePresetsFor, toPresetList, v };
18103
+ export { AbsolutePath, type ActiveLora, type ActiveLoraSource, type AnyChoiceVar, type AnyVar, AudioVar, type AudioVarOpts, 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, type ComfyVideoOutput, ComfyWorkflow, ComfyWorkflowBuilder, type ComfyWorkflowData, type ComfyWorkflowID, type ConnectOptions, ConvertibleImageFormat, DEFAULT_AUDIO_EXTENSIONS, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DEFAULT_STARRED_SIZES, DEFAULT_VIDEO_EXTENSIONS, type DefineWorkflowSpec, DefinedWorkflow, Either, EmptyRecord, type ExecutionPreview, type ExecutionProgress, type ExecutionSnapshot, Flavor, FloatVar, HTMLContent, type HostSlotSource, 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, MediaVar, MediaVarEmptyError, type MediaVarOpts, type ModelVarOpts, MultiChoiceVar, type NodeMode, NodeOf, OptionalChoiceVar, type ParsedHostBase, PartialOmit, type PluginInstallStatus, type PluginSuggestion, type PreviewMethod, type ProgressReport, type PromptEnhancer, 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, type SlotNameOf, type SlotValueOf, Tagged, TextVar, type TextVarOpts, ToggleVar, type VarKind, type VarPreset, type VarPresetSpec, type VarUi, type VarValues, type VarsSpec, VideoVar, type VideoVarOpts, WorkflowConvertError, WorkflowNormalizeError, type WsLike, type WsMessageEvent, type WsMsg, __FAIL, __OK, activeLoras, activePresetLabel, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, exampleImagePath, exampleMediaPath, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, isTuiActive, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, number_Timestamp, parseHostBase, parseWorkflowJson, promptEnhancerPresets, readPromptEnhancers, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, sizePresetsFor, toPresetList, v };
18051
18104
  //# sourceMappingURL=index.d.ts.map