comfy-ts 1.4.0 → 2.1.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 (97) hide show
  1. package/README.md +80 -6
  2. package/dist/{DefinedWorkflow-C_QAxKr3.js → DefinedWorkflow-CqNE_kgR.js} +4 -2
  3. package/dist/{DefinedWorkflow-C_QAxKr3.js.map → DefinedWorkflow-CqNE_kgR.js.map} +1 -1
  4. package/dist/{DraftsSt-DcOTn0QR.js → DraftsSt-C-gBk9v7.js} +3 -4
  5. package/dist/DraftsSt-C-gBk9v7.js.map +1 -0
  6. package/dist/cli.js +3 -3
  7. package/dist/index.cjs +212 -66
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +72 -77
  10. package/dist/index.d.ts +72 -77
  11. package/dist/index.js +212 -66
  12. package/dist/index.js.map +1 -1
  13. package/dist/{run-serve-CN0DhrsA.js → run-serve-CnlN_RFH.js} +9 -7
  14. package/dist/run-serve-CnlN_RFH.js.map +1 -0
  15. package/dist/{run-tui-bN2hSD5i.js → run-tui-DXI_Jufu.js} +258 -56
  16. package/dist/run-tui-DXI_Jufu.js.map +1 -0
  17. package/dist/{state-COlKYipO.js → state-DC5BcG6d.js} +211 -67
  18. package/dist/state-DC5BcG6d.js.map +1 -0
  19. package/dist/web.d.ts +72 -77
  20. package/dist/web.js +212 -66
  21. package/dist/web.js.map +1 -1
  22. package/examples/comfy-cloud/ace-step-t2a.cflow.ts +1 -0
  23. package/examples/comfy-cloud/anima-t2i.cflow.ts +2 -3
  24. package/examples/comfy-cloud/boogu-i2i.cflow.ts +2 -5
  25. package/examples/comfy-cloud/capybara-i2i.cflow.ts +2 -2
  26. package/examples/comfy-cloud/capybara-i2v.cflow.ts +1 -0
  27. package/examples/comfy-cloud/capybara-t2i.cflow.ts +2 -2
  28. package/examples/comfy-cloud/chatterbox-t2a.cflow.ts +1 -0
  29. package/examples/comfy-cloud/chroma-t2i.cflow.ts +2 -5
  30. package/examples/comfy-cloud/ernie-t2i.cflow.ts +2 -3
  31. package/examples/comfy-cloud/firered-i2i.cflow.ts +2 -2
  32. package/examples/comfy-cloud/flux1-i2i.cflow.ts +2 -2
  33. package/examples/comfy-cloud/flux1-t2i.cflow.ts +2 -2
  34. package/examples/comfy-cloud/flux2-i2i.cflow.ts +2 -5
  35. package/examples/comfy-cloud/flux2-t2i.cflow.ts +2 -5
  36. package/examples/comfy-cloud/hidream-i2i.cflow.ts +2 -5
  37. package/examples/comfy-cloud/hidream-t2i.cflow.ts +2 -2
  38. package/examples/comfy-cloud/hunyuan-video-i2v.cflow.ts +1 -0
  39. package/examples/comfy-cloud/hunyuan-video-t2v.cflow.ts +1 -0
  40. package/examples/comfy-cloud/ideogram4-t2i.cflow.ts +2 -3
  41. package/examples/comfy-cloud/kandinsky5-i2v.cflow.ts +1 -0
  42. package/examples/comfy-cloud/kandinsky5-t2i.cflow.ts +2 -2
  43. package/examples/comfy-cloud/kandinsky5-t2v.cflow.ts +1 -0
  44. package/examples/comfy-cloud/krea2-t2i.cflow.ts +2 -3
  45. package/examples/comfy-cloud/lens-t2i.cflow.ts +2 -3
  46. package/examples/comfy-cloud/longcat-i2i.cflow.ts +2 -2
  47. package/examples/comfy-cloud/longcat-t2i.cflow.ts +2 -5
  48. package/examples/comfy-cloud/ltxv-i2v.cflow.ts +1 -0
  49. package/examples/comfy-cloud/ltxv-t2v.cflow.ts +1 -0
  50. package/examples/comfy-cloud/newbie-t2i.cflow.ts +2 -5
  51. package/examples/comfy-cloud/omnigen2-i2i.cflow.ts +2 -5
  52. package/examples/comfy-cloud/omnigen2-t2i.cflow.ts +2 -5
  53. package/examples/comfy-cloud/ovis-t2i.cflow.ts +2 -5
  54. package/examples/comfy-cloud/pixeldit-t2i.cflow.ts +2 -5
  55. package/examples/comfy-cloud/qwen-image-i2i.cflow.ts +2 -2
  56. package/examples/comfy-cloud/qwen-image-t2i.cflow.ts +2 -2
  57. package/examples/comfy-cloud/sd35-t2i.cflow.ts +2 -2
  58. package/examples/comfy-cloud/sdk.d.ts +13251 -11458
  59. package/examples/comfy-cloud/sdxl-t2i.cflow.ts +2 -2
  60. package/examples/comfy-cloud/stable-audio-t2a.cflow.ts +1 -0
  61. package/examples/comfy-cloud/svd-i2v.cflow.ts +1 -0
  62. package/examples/comfy-cloud/wan21-i2v.cflow.ts +1 -0
  63. package/examples/comfy-cloud/wan21-t2v.cflow.ts +1 -0
  64. package/examples/comfy-cloud/wan22-5b-t2v.cflow.ts +1 -0
  65. package/examples/comfy-cloud/wan22-i2v.cflow.ts +1 -0
  66. package/examples/comfy-cloud/wan22-t2v.cflow.ts +1 -0
  67. package/examples/comfy-cloud/z-image-t2i.cflow.ts +2 -5
  68. package/examples/rvion/01-txt2img.cflow.ts +5 -3
  69. package/examples/rvion/02-img2img-upload.cflow.ts +5 -4
  70. package/examples/rvion/04-krea2-turbo-t2i.cflow.ts +6 -7
  71. package/examples/rvion/05-comfy-cloud.cflow.ts +4 -2
  72. package/examples/rvion/06-qwen-image-edit.cflow.ts +2 -3
  73. package/examples/web/example.ts +8 -1
  74. package/package.json +1 -1
  75. package/src/cli/serve/ServeApp.ts +9 -6
  76. package/src/cli/tui/components/TuiApp.tsx +4 -5
  77. package/src/cli/tui/components/VarsPanel.tsx +40 -2
  78. package/src/cli/tui/imageClipboard.ts +40 -0
  79. package/src/cli/tui/state/DraftsSt.ts +1 -2
  80. package/src/cli/tui/state/ExecSt.ts +105 -40
  81. package/src/cli/tui/state/PreviewSt.ts +12 -11
  82. package/src/cli/tui/state/SettingsSt.ts +13 -0
  83. package/src/cli/tui/state/TuiSt.ts +54 -5
  84. package/src/host/ComfyHost.ts +33 -1
  85. package/src/runner/ComfyExecution.ts +162 -74
  86. package/src/runner/ComfyWorkflow.ts +25 -3
  87. package/src/runner/ComfyWsApi.ts +6 -0
  88. package/src/runner/MediaImage.ts +58 -11
  89. package/src/runner/ephemeral.ts +21 -0
  90. package/src/runner/outputPath.ts +2 -2
  91. package/src/sdk-generator/_pythonModuleToNamespace.ts +3 -0
  92. package/src/types/index.ts +6 -2
  93. package/src/vars/DefinedWorkflow.ts +3 -1
  94. package/dist/DraftsSt-DcOTn0QR.js.map +0 -1
  95. package/dist/run-serve-CN0DhrsA.js.map +0 -1
  96. package/dist/run-tui-bN2hSD5i.js.map +0 -1
  97. package/dist/state-COlKYipO.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -11780,9 +11780,13 @@ type RelativePath = Tagged<string, {
11780
11780
  declare const asAbsolutePath: (path: string) => AbsolutePath;
11781
11781
  declare const asRelativePath: (path: string) => RelativePath;
11782
11782
  type ConvertibleImageFormat = 'image/png' | 'image/jpeg' | 'image/webp' | 'raw';
11783
- type ImageSaveFormat = {
11784
- format: ConvertibleImageFormat;
11783
+ /** local disk saving is OPT-IN per run: `save: true` = raw bytes, an object re-encodes/relocates */
11784
+ type SaveOptions = {
11785
+ /** 'raw' (default) writes the bytes untouched; an image/* mime re-encodes through sharp */
11786
+ format?: ConvertibleImageFormat;
11787
+ /** local dir under `.comfy-ts/outputs/` (wins over the prompt's own filename_prefix) */
11785
11788
  prefix?: string;
11789
+ /** 0..1, re-encode only */
11786
11790
  quality?: number;
11787
11791
  };
11788
11792
  type Either<L, R> = {
@@ -12208,6 +12212,15 @@ declare const types$1: import("arktype").Module<{
12208
12212
  }>;
12209
12213
  type NodeProgress = typeof types$1.NodeProgress.infer;
12210
12214
  type PromptRelated_WsMsg = typeof types$1.PromptRelated_WsMsg.infer;
12215
+ /** a binary preview-kind ws frame buffered IN ORDER with the json messages
12216
+ * during the pre-registration window (ComfyHost._pendingMsgs) — replayed by
12217
+ * ComfyExecution.onCreate, which decides output-vs-latent at replay time */
12218
+ type PendingBinaryFrame = {
12219
+ type: 'binary_preview_frame';
12220
+ bytes: Uint8Array;
12221
+ mime: string;
12222
+ };
12223
+ type PendingWsItem = PromptRelated_WsMsg | PendingBinaryFrame;
12211
12224
  type WsMsg = typeof types$1.WsMsg.infer;
12212
12225
  type ComfyStatusData = typeof types$1.ComfyStatusData.infer;
12213
12226
  type WsMsgExecutionCached = typeof types$1.WsMsgExecutionCached.infer;
@@ -12539,7 +12552,8 @@ type ComfyImageName = Branded<string, {
12539
12552
  //#endregion
12540
12553
  //#region src/runner/MediaImage.d.ts
12541
12554
  type MediaImageData = {
12542
- path: AbsolutePath;
12555
+ /** absent = in-memory image (ws output with local saving off) — the buffer is then required */
12556
+ path?: Maybe<AbsolutePath>;
12543
12557
  buffer?: Uint8Array;
12544
12558
  execution?: ComfyExecution;
12545
12559
  promptNodeID?: string | null;
@@ -12550,7 +12564,8 @@ type ImageInfos_ComfyGenerated = {
12550
12564
  comfyImageInfo: ComfyImageInfo;
12551
12565
  };
12552
12566
  declare class MediaImage {
12553
- absPath: AbsolutePath;
12567
+ /** null for in-memory images (local saving is opt-in — architecture.md item 14) */
12568
+ absPath: AbsolutePath | null;
12554
12569
  /** the execution this image came from (null when not generated via comfy-ts) */
12555
12570
  execution: Maybe<ComfyExecution>;
12556
12571
  /** return the workflow from which this image was generated */
@@ -12561,7 +12576,7 @@ declare class MediaImage {
12561
12576
  tags: string[];
12562
12577
  /** the image as a Blob, e.g. to feed FormData uploads */
12563
12578
  getAsBlob(): Blob;
12564
- /** return the image filename */
12579
+ /** return the image filename (in-memory images get a stable hash-derived name) */
12565
12580
  get filename(): string;
12566
12581
  get baseNameWithoutExtension(): string;
12567
12582
  /**
@@ -12580,6 +12595,11 @@ declare class MediaImage {
12580
12595
  channel: 'alpha' | 'blue' | 'green' | 'red',
12581
12596
  /** workflow to load image as mask into */
12582
12597
  workflow: ComfyWorkflow<WID>) => Promise<NodeOf<WID, 'LoadImageMask'>>;
12598
+ /** load this image into the workflow WITHOUT any server-side file: the
12599
+ * image rides base64 inside the prompt JSON (architecture.md item 14 —
12600
+ * the prompt still enters server history; `scrubHistory` covers that).
12601
+ * Feature-detected against the host schema; no supported node = loud throw. */
12602
+ loadInWorkflow_viaBase64Node: <WID extends string>(workflow: ComfyWorkflow<WID>) => NodeOf<WID, 'LoadImage'>;
12583
12603
  /** return the json of the ComfyNode that led to this image */
12584
12604
  get ComfyNode(): Maybe<ComfyApiNodeJson>;
12585
12605
  /**
@@ -12606,6 +12626,7 @@ declare class MediaImage {
12606
12626
  /** lazilly loaded, call recomputeMetadata to expire */
12607
12627
  private _buffer;
12608
12628
  get buffer(): Uint8Array;
12629
+ /** no-op on in-memory images: the buffer is the only copy */
12609
12630
  freeBuffer: () => void;
12610
12631
  updateBuffer: (buff: Uint8Array) => void;
12611
12632
  reloadBuffer: () => Uint8Array;
@@ -12652,11 +12673,18 @@ declare class ComfyExecution {
12652
12673
  get host(): ComfyHost;
12653
12674
  constructor(workflow: ComfyWorkflow, data: ComfyExecutionData, init?: {
12654
12675
  snapshot?: ExecutionSnapshot;
12655
- saveFormat?: Maybe<ImageSaveFormat>;
12676
+ save?: Maybe<boolean | SaveOptions>;
12677
+ scrubHistory?: boolean;
12678
+ ephemeral?: boolean;
12656
12679
  onProgress?: Maybe<(p: ExecutionProgress) => void>;
12657
12680
  logProgress?: boolean;
12658
12681
  });
12659
- saveFormat: Maybe<ImageSaveFormat>;
12682
+ /** local disk saving, OPT-IN (architecture.md item 14); null = outputs stay in memory */
12683
+ save: Maybe<SaveOptions>;
12684
+ /** delete this run's server history entry after `done` */
12685
+ scrubHistory: boolean;
12686
+ /** this run's SaveImage nodes were rewritten to SaveImageWebsocket in the snapshot */
12687
+ ephemeral: boolean;
12660
12688
  /** exactly what was sent to the host, frozen at send time (replayable) */
12661
12689
  snapshot: Maybe<ExecutionSnapshot>;
12662
12690
  /** called on every progress-relevant websocket message */
@@ -12674,7 +12702,7 @@ declare class ComfyExecution {
12674
12702
  onCreate(): void;
12675
12703
  get progressGlobal(): ProgressReport;
12676
12704
  get status(): 'New' | 'Scheduled' | 'Running' | 'Success' | 'Failure';
12677
- onPromptRelatedMessage: (msg: PromptRelated_WsMsg) => void;
12705
+ onPromptRelatedMessage: (msg: PendingWsItem) => void;
12678
12706
  /** update pointer to the currently executing node */
12679
12707
  private onExecuting;
12680
12708
  private onExecutionSuccess;
@@ -12682,12 +12710,30 @@ declare class ComfyExecution {
12682
12710
  /** update execution list */
12683
12711
  private onExecuted;
12684
12712
  private pendingPromises;
12685
- /** image retrievals that failed (their images are missing from `images`) */
12713
+ /** image retrievals that failed (their images are missing from `images`);
12714
+ * `image` is null for SaveImageWebsocket frames (no server-side file info exists) */
12686
12715
  imageErrors: {
12687
- image: ComfyImageInfo;
12716
+ image: Maybe<ComfyImageInfo>;
12688
12717
  error: unknown;
12689
12718
  }[];
12690
12719
  retrieveImage: (comfyImageInfo: ComfyImageInfo, promptNodeID: ComfyNodeId) => Promise<void>;
12720
+ /** re-encode when asked, then write under OUR local naming — never the raw
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) */
12723
+ private encodeAndWrite;
12724
+ /** accumulate an output on the prompt; tags from node metadata ride along */
12725
+ private pushImage;
12726
+ /** true while the currently executing node is a SaveImageWebsocket in the
12727
+ * SENT snapshot (the ephemeral rewrite only touches the snapshot, so the
12728
+ * live graph may still say SaveImage) — binary frames are then OUTPUTS */
12729
+ get wsOutputNodeExecuting(): boolean;
12730
+ /** one binary ws frame = one output image of the executing SaveImageWebsocket
12731
+ * node (architecture.md item 14 — the zero-server-disk path) */
12732
+ onWsImageOutput: (p: {
12733
+ bytes: Uint8Array;
12734
+ mime: string;
12735
+ }) => void;
12736
+ private storeWsImage;
12691
12737
  /** images retrieved for this execution, in arrival order (final once `done` resolves) */
12692
12738
  images: MediaImage[];
12693
12739
  update(data: Partial<ComfyExecutionData>): void;
@@ -16435,6 +16481,10 @@ declare class ComfyHost<ID extends string = string> {
16435
16481
  clearQueue: () => Promise<void>;
16436
16482
  /** interrupt the CURRENTLY RUNNING prompt */
16437
16483
  interrupt: () => Promise<void>;
16484
+ /** delete ONE prompt's server history entry */
16485
+ deleteHistory: (promptId: string) => Promise<void>;
16486
+ /** wipe the server's WHOLE prompt history (every user of that server) */
16487
+ clearHistory: () => Promise<void>;
16438
16488
  /** the server's recent console buffer (entries are write CHUNKS, not lines) */
16439
16489
  fetchRawLogs: () => Promise<{
16440
16490
  entries: LogEntry[];
@@ -16452,71 +16502,7 @@ declare class ComfyHost<ID extends string = string> {
16452
16502
  /** executions we started */
16453
16503
  executions: Map<PromptID, ComfyExecution>;
16454
16504
  /** buffer in case we receive packets out of order */
16455
- _pendingMsgs: Map<PromptID, ({
16456
- type: "execution_start";
16457
- data: {
16458
- prompt_id: PromptID;
16459
- };
16460
- } | {
16461
- type: "execution_cached";
16462
- data: {
16463
- nodes: ComfyNodeId[];
16464
- prompt_id: PromptID;
16465
- };
16466
- } | {
16467
- type: "executing";
16468
- data: {
16469
- prompt_id: PromptID;
16470
- node?: ComfyNodeId | null | undefined;
16471
- };
16472
- } | {
16473
- type: "progress";
16474
- data: {
16475
- value: number;
16476
- max: number;
16477
- };
16478
- } | {
16479
- type: "progress_state";
16480
- data: {
16481
- prompt_id: PromptID;
16482
- nodes: Record<string, unknown>;
16483
- };
16484
- } | {
16485
- type: "executed";
16486
- data: {
16487
- node: ComfyNodeId;
16488
- output: {
16489
- previews?: {
16490
- filepath: string;
16491
- }[] | undefined;
16492
- images?: {
16493
- filename: string;
16494
- subfolder: string;
16495
- type: string;
16496
- }[] | undefined;
16497
- };
16498
- prompt_id: PromptID;
16499
- };
16500
- } | {
16501
- type: "execution_error";
16502
- data: {
16503
- prompt_id: PromptID;
16504
- node_id: ComfyNodeId;
16505
- node_type: string;
16506
- executed: ComfyNodeId[];
16507
- exception_message: string;
16508
- exception_type: string;
16509
- traceback: string[];
16510
- current_inputs: Record<string, unknown>;
16511
- current_outputs: Record<string, unknown>;
16512
- };
16513
- } | {
16514
- type: "execution_success";
16515
- data: {
16516
- prompt_id: PromptID;
16517
- timestamp: number;
16518
- };
16519
- })[]>;
16505
+ _pendingMsgs: Map<PromptID, PendingWsItem[]>;
16520
16506
  /** the active prompt currently running on this host */
16521
16507
  private activePromptID;
16522
16508
  /** method to either execute or buffer the incoming message */
@@ -16738,7 +16724,16 @@ type ProgressReport = {
16738
16724
  };
16739
16725
  type ComfyNodeIdMode = 'use_stringified_numbers_only' | 'use_class_name_and_number';
16740
16726
  type RunSettings = {
16741
- saveFormat?: ImageSaveFormat;
16727
+ /** local disk saving is OPT-IN: unset/false keeps outputs in memory only
16728
+ * (`execution.images` buffers); `true` = raw save, an object re-encodes/relocates */
16729
+ save?: boolean | SaveOptions;
16730
+ /** rewrite every SaveImage node to SaveImageWebsocket in the SENT prompt —
16731
+ * outputs never touch the server disk. Implies `scrubHistory` unless that
16732
+ * is explicitly false. (architecture.md item 14) */
16733
+ ephemeral?: boolean;
16734
+ /** delete this run's server history entry (workflow JSON, prompts, filenames)
16735
+ * after `done` — loud but non-fatal on failure */
16736
+ scrubHistory?: boolean;
16742
16737
  idMode?: ComfyNodeIdMode;
16743
16738
  /** render a live single-line progress report to the console */
16744
16739
  log?: boolean;
@@ -17349,5 +17344,5 @@ declare function exampleImagePath(name: string): string;
17349
17344
  //#region src/cli/tui-env.d.ts
17350
17345
  declare function isTuiActive(): boolean;
17351
17346
  //#endregion
17352
- 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, 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, ImageSaveFormat, 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, 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 };
17347
+ 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, 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 };
17353
17348
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -11780,9 +11780,13 @@ type RelativePath = Tagged<string, {
11780
11780
  declare const asAbsolutePath: (path: string) => AbsolutePath;
11781
11781
  declare const asRelativePath: (path: string) => RelativePath;
11782
11782
  type ConvertibleImageFormat = 'image/png' | 'image/jpeg' | 'image/webp' | 'raw';
11783
- type ImageSaveFormat = {
11784
- format: ConvertibleImageFormat;
11783
+ /** local disk saving is OPT-IN per run: `save: true` = raw bytes, an object re-encodes/relocates */
11784
+ type SaveOptions = {
11785
+ /** 'raw' (default) writes the bytes untouched; an image/* mime re-encodes through sharp */
11786
+ format?: ConvertibleImageFormat;
11787
+ /** local dir under `.comfy-ts/outputs/` (wins over the prompt's own filename_prefix) */
11785
11788
  prefix?: string;
11789
+ /** 0..1, re-encode only */
11786
11790
  quality?: number;
11787
11791
  };
11788
11792
  type Either<L, R> = {
@@ -12208,6 +12212,15 @@ declare const types$1: import("arktype").Module<{
12208
12212
  }>;
12209
12213
  type NodeProgress = typeof types$1.NodeProgress.infer;
12210
12214
  type PromptRelated_WsMsg = typeof types$1.PromptRelated_WsMsg.infer;
12215
+ /** a binary preview-kind ws frame buffered IN ORDER with the json messages
12216
+ * during the pre-registration window (ComfyHost._pendingMsgs) — replayed by
12217
+ * ComfyExecution.onCreate, which decides output-vs-latent at replay time */
12218
+ type PendingBinaryFrame = {
12219
+ type: 'binary_preview_frame';
12220
+ bytes: Uint8Array;
12221
+ mime: string;
12222
+ };
12223
+ type PendingWsItem = PromptRelated_WsMsg | PendingBinaryFrame;
12211
12224
  type WsMsg = typeof types$1.WsMsg.infer;
12212
12225
  type ComfyStatusData = typeof types$1.ComfyStatusData.infer;
12213
12226
  type WsMsgExecutionCached = typeof types$1.WsMsgExecutionCached.infer;
@@ -12539,7 +12552,8 @@ type ComfyImageName = Branded<string, {
12539
12552
  //#endregion
12540
12553
  //#region src/runner/MediaImage.d.ts
12541
12554
  type MediaImageData = {
12542
- path: AbsolutePath;
12555
+ /** absent = in-memory image (ws output with local saving off) — the buffer is then required */
12556
+ path?: Maybe<AbsolutePath>;
12543
12557
  buffer?: Uint8Array;
12544
12558
  execution?: ComfyExecution;
12545
12559
  promptNodeID?: string | null;
@@ -12550,7 +12564,8 @@ type ImageInfos_ComfyGenerated = {
12550
12564
  comfyImageInfo: ComfyImageInfo;
12551
12565
  };
12552
12566
  declare class MediaImage {
12553
- absPath: AbsolutePath;
12567
+ /** null for in-memory images (local saving is opt-in — architecture.md item 14) */
12568
+ absPath: AbsolutePath | null;
12554
12569
  /** the execution this image came from (null when not generated via comfy-ts) */
12555
12570
  execution: Maybe<ComfyExecution>;
12556
12571
  /** return the workflow from which this image was generated */
@@ -12561,7 +12576,7 @@ declare class MediaImage {
12561
12576
  tags: string[];
12562
12577
  /** the image as a Blob, e.g. to feed FormData uploads */
12563
12578
  getAsBlob(): Blob;
12564
- /** return the image filename */
12579
+ /** return the image filename (in-memory images get a stable hash-derived name) */
12565
12580
  get filename(): string;
12566
12581
  get baseNameWithoutExtension(): string;
12567
12582
  /**
@@ -12580,6 +12595,11 @@ declare class MediaImage {
12580
12595
  channel: 'alpha' | 'blue' | 'green' | 'red',
12581
12596
  /** workflow to load image as mask into */
12582
12597
  workflow: ComfyWorkflow<WID>) => Promise<NodeOf<WID, 'LoadImageMask'>>;
12598
+ /** load this image into the workflow WITHOUT any server-side file: the
12599
+ * image rides base64 inside the prompt JSON (architecture.md item 14 —
12600
+ * the prompt still enters server history; `scrubHistory` covers that).
12601
+ * Feature-detected against the host schema; no supported node = loud throw. */
12602
+ loadInWorkflow_viaBase64Node: <WID extends string>(workflow: ComfyWorkflow<WID>) => NodeOf<WID, 'LoadImage'>;
12583
12603
  /** return the json of the ComfyNode that led to this image */
12584
12604
  get ComfyNode(): Maybe<ComfyApiNodeJson>;
12585
12605
  /**
@@ -12606,6 +12626,7 @@ declare class MediaImage {
12606
12626
  /** lazilly loaded, call recomputeMetadata to expire */
12607
12627
  private _buffer;
12608
12628
  get buffer(): Uint8Array;
12629
+ /** no-op on in-memory images: the buffer is the only copy */
12609
12630
  freeBuffer: () => void;
12610
12631
  updateBuffer: (buff: Uint8Array) => void;
12611
12632
  reloadBuffer: () => Uint8Array;
@@ -12652,11 +12673,18 @@ declare class ComfyExecution {
12652
12673
  get host(): ComfyHost;
12653
12674
  constructor(workflow: ComfyWorkflow, data: ComfyExecutionData, init?: {
12654
12675
  snapshot?: ExecutionSnapshot;
12655
- saveFormat?: Maybe<ImageSaveFormat>;
12676
+ save?: Maybe<boolean | SaveOptions>;
12677
+ scrubHistory?: boolean;
12678
+ ephemeral?: boolean;
12656
12679
  onProgress?: Maybe<(p: ExecutionProgress) => void>;
12657
12680
  logProgress?: boolean;
12658
12681
  });
12659
- saveFormat: Maybe<ImageSaveFormat>;
12682
+ /** local disk saving, OPT-IN (architecture.md item 14); null = outputs stay in memory */
12683
+ save: Maybe<SaveOptions>;
12684
+ /** delete this run's server history entry after `done` */
12685
+ scrubHistory: boolean;
12686
+ /** this run's SaveImage nodes were rewritten to SaveImageWebsocket in the snapshot */
12687
+ ephemeral: boolean;
12660
12688
  /** exactly what was sent to the host, frozen at send time (replayable) */
12661
12689
  snapshot: Maybe<ExecutionSnapshot>;
12662
12690
  /** called on every progress-relevant websocket message */
@@ -12674,7 +12702,7 @@ declare class ComfyExecution {
12674
12702
  onCreate(): void;
12675
12703
  get progressGlobal(): ProgressReport;
12676
12704
  get status(): 'New' | 'Scheduled' | 'Running' | 'Success' | 'Failure';
12677
- onPromptRelatedMessage: (msg: PromptRelated_WsMsg) => void;
12705
+ onPromptRelatedMessage: (msg: PendingWsItem) => void;
12678
12706
  /** update pointer to the currently executing node */
12679
12707
  private onExecuting;
12680
12708
  private onExecutionSuccess;
@@ -12682,12 +12710,30 @@ declare class ComfyExecution {
12682
12710
  /** update execution list */
12683
12711
  private onExecuted;
12684
12712
  private pendingPromises;
12685
- /** image retrievals that failed (their images are missing from `images`) */
12713
+ /** image retrievals that failed (their images are missing from `images`);
12714
+ * `image` is null for SaveImageWebsocket frames (no server-side file info exists) */
12686
12715
  imageErrors: {
12687
- image: ComfyImageInfo;
12716
+ image: Maybe<ComfyImageInfo>;
12688
12717
  error: unknown;
12689
12718
  }[];
12690
12719
  retrieveImage: (comfyImageInfo: ComfyImageInfo, promptNodeID: ComfyNodeId) => Promise<void>;
12720
+ /** re-encode when asked, then write under OUR local naming — never the raw
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) */
12723
+ private encodeAndWrite;
12724
+ /** accumulate an output on the prompt; tags from node metadata ride along */
12725
+ private pushImage;
12726
+ /** true while the currently executing node is a SaveImageWebsocket in the
12727
+ * SENT snapshot (the ephemeral rewrite only touches the snapshot, so the
12728
+ * live graph may still say SaveImage) — binary frames are then OUTPUTS */
12729
+ get wsOutputNodeExecuting(): boolean;
12730
+ /** one binary ws frame = one output image of the executing SaveImageWebsocket
12731
+ * node (architecture.md item 14 — the zero-server-disk path) */
12732
+ onWsImageOutput: (p: {
12733
+ bytes: Uint8Array;
12734
+ mime: string;
12735
+ }) => void;
12736
+ private storeWsImage;
12691
12737
  /** images retrieved for this execution, in arrival order (final once `done` resolves) */
12692
12738
  images: MediaImage[];
12693
12739
  update(data: Partial<ComfyExecutionData>): void;
@@ -16435,6 +16481,10 @@ declare class ComfyHost<ID extends string = string> {
16435
16481
  clearQueue: () => Promise<void>;
16436
16482
  /** interrupt the CURRENTLY RUNNING prompt */
16437
16483
  interrupt: () => Promise<void>;
16484
+ /** delete ONE prompt's server history entry */
16485
+ deleteHistory: (promptId: string) => Promise<void>;
16486
+ /** wipe the server's WHOLE prompt history (every user of that server) */
16487
+ clearHistory: () => Promise<void>;
16438
16488
  /** the server's recent console buffer (entries are write CHUNKS, not lines) */
16439
16489
  fetchRawLogs: () => Promise<{
16440
16490
  entries: LogEntry[];
@@ -16452,71 +16502,7 @@ declare class ComfyHost<ID extends string = string> {
16452
16502
  /** executions we started */
16453
16503
  executions: Map<PromptID, ComfyExecution>;
16454
16504
  /** buffer in case we receive packets out of order */
16455
- _pendingMsgs: Map<PromptID, ({
16456
- type: "execution_start";
16457
- data: {
16458
- prompt_id: PromptID;
16459
- };
16460
- } | {
16461
- type: "execution_cached";
16462
- data: {
16463
- nodes: ComfyNodeId[];
16464
- prompt_id: PromptID;
16465
- };
16466
- } | {
16467
- type: "executing";
16468
- data: {
16469
- prompt_id: PromptID;
16470
- node?: ComfyNodeId | null | undefined;
16471
- };
16472
- } | {
16473
- type: "progress";
16474
- data: {
16475
- value: number;
16476
- max: number;
16477
- };
16478
- } | {
16479
- type: "progress_state";
16480
- data: {
16481
- prompt_id: PromptID;
16482
- nodes: Record<string, unknown>;
16483
- };
16484
- } | {
16485
- type: "executed";
16486
- data: {
16487
- node: ComfyNodeId;
16488
- output: {
16489
- previews?: {
16490
- filepath: string;
16491
- }[] | undefined;
16492
- images?: {
16493
- filename: string;
16494
- subfolder: string;
16495
- type: string;
16496
- }[] | undefined;
16497
- };
16498
- prompt_id: PromptID;
16499
- };
16500
- } | {
16501
- type: "execution_error";
16502
- data: {
16503
- prompt_id: PromptID;
16504
- node_id: ComfyNodeId;
16505
- node_type: string;
16506
- executed: ComfyNodeId[];
16507
- exception_message: string;
16508
- exception_type: string;
16509
- traceback: string[];
16510
- current_inputs: Record<string, unknown>;
16511
- current_outputs: Record<string, unknown>;
16512
- };
16513
- } | {
16514
- type: "execution_success";
16515
- data: {
16516
- prompt_id: PromptID;
16517
- timestamp: number;
16518
- };
16519
- })[]>;
16505
+ _pendingMsgs: Map<PromptID, PendingWsItem[]>;
16520
16506
  /** the active prompt currently running on this host */
16521
16507
  private activePromptID;
16522
16508
  /** method to either execute or buffer the incoming message */
@@ -16738,7 +16724,16 @@ type ProgressReport = {
16738
16724
  };
16739
16725
  type ComfyNodeIdMode = 'use_stringified_numbers_only' | 'use_class_name_and_number';
16740
16726
  type RunSettings = {
16741
- saveFormat?: ImageSaveFormat;
16727
+ /** local disk saving is OPT-IN: unset/false keeps outputs in memory only
16728
+ * (`execution.images` buffers); `true` = raw save, an object re-encodes/relocates */
16729
+ save?: boolean | SaveOptions;
16730
+ /** rewrite every SaveImage node to SaveImageWebsocket in the SENT prompt —
16731
+ * outputs never touch the server disk. Implies `scrubHistory` unless that
16732
+ * is explicitly false. (architecture.md item 14) */
16733
+ ephemeral?: boolean;
16734
+ /** delete this run's server history entry (workflow JSON, prompts, filenames)
16735
+ * after `done` — loud but non-fatal on failure */
16736
+ scrubHistory?: boolean;
16742
16737
  idMode?: ComfyNodeIdMode;
16743
16738
  /** render a live single-line progress report to the console */
16744
16739
  log?: boolean;
@@ -17349,5 +17344,5 @@ declare function exampleImagePath(name: string): string;
17349
17344
  //#region src/cli/tui-env.d.ts
17350
17345
  declare function isTuiActive(): boolean;
17351
17346
  //#endregion
17352
- 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, 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, ImageSaveFormat, 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, 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 };
17347
+ 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, 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 };
17353
17348
  //# sourceMappingURL=index.d.ts.map