comfy-ts 2.13.0 → 2.15.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 (75) hide show
  1. package/README.md +1 -0
  2. package/dist/{LogsSt-CUeo843w.js → LogsSt-C3UIWR-o.js} +2 -2
  3. package/dist/{LogsSt-CUeo843w.js.map → LogsSt-C3UIWR-o.js.map} +1 -1
  4. package/dist/cli.js +4 -4
  5. package/dist/index.cjs +213 -53
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +123 -21
  8. package/dist/index.d.ts +123 -21
  9. package/dist/index.js +207 -54
  10. package/dist/index.js.map +1 -1
  11. package/dist/{run-serve-DlRBv_Nk.js → run-serve-B5PfIuhK.js} +310 -88
  12. package/dist/run-serve-B5PfIuhK.js.map +1 -0
  13. package/dist/{run-tui-B5uxm2_l.js → run-tui-D-N4_yyX.js} +15 -9
  14. package/dist/run-tui-D-N4_yyX.js.map +1 -0
  15. package/dist/{schemaDrift-E95iTF7E.js → schemaDrift-BkN8rLiZ.js} +163 -25
  16. package/dist/schemaDrift-BkN8rLiZ.js.map +1 -0
  17. package/dist/serve-web.js +160 -71
  18. package/dist/{state-CUp2J1Zy.js → state-CZsYJqB6.js} +45 -35
  19. package/dist/state-CZsYJqB6.js.map +1 -0
  20. package/dist/web.d.ts +120 -21
  21. package/dist/web.js +196 -51
  22. package/dist/web.js.map +1 -1
  23. package/examples/media/README.md +8 -0
  24. package/examples/media/sine_440hz_3s.flac +0 -0
  25. package/examples/media/testsrc_256x256_3s.mp4 +0 -0
  26. package/examples/rvion/14-video-soundtrack.cflow.ts +47 -0
  27. package/guide-for-agents.md +2 -1
  28. package/package.json +2 -2
  29. package/src/cli/serve/ServeApp.ts +189 -110
  30. package/src/cli/serve/applyVarPayload.ts +5 -3
  31. package/src/cli/serve/describeVar.ts +5 -3
  32. package/src/cli/serve/resultHistory.ts +141 -0
  33. package/src/cli/serve/run-serve.ts +4 -1
  34. package/src/cli/serve/runError.ts +23 -0
  35. package/src/cli/serve/serveSettings.ts +17 -1
  36. package/src/cli/serve/web/api.ts +33 -2
  37. package/src/cli/serve/web/components/App.tsx +6 -4
  38. package/src/cli/serve/web/components/Gallery.tsx +116 -11
  39. package/src/cli/serve/web/components/Icon.tsx +4 -0
  40. package/src/cli/serve/web/components/MemoryBudget.tsx +98 -0
  41. package/src/cli/serve/web/components/RunError.tsx +19 -0
  42. package/src/cli/serve/web/components/ShortcutsModal.tsx +54 -0
  43. package/src/cli/serve/web/components/SideMenu.tsx +14 -0
  44. package/src/cli/serve/web/components/VarsForm.tsx +75 -55
  45. package/src/cli/serve/web/components/controls/BasicControls.tsx +8 -1
  46. package/src/cli/serve/web/components/controls/LorasControl.tsx +6 -3
  47. package/src/cli/serve/web/components/controls/MediaControl.tsx +111 -0
  48. package/src/cli/serve/web/promptEditor/promptExtensions.ts +3 -1
  49. package/src/cli/serve/web/state/FormSt.ts +70 -2
  50. package/src/cli/serve/web/state/RunSt.ts +61 -3
  51. package/src/cli/serve/web/state/WebSt.ts +26 -2
  52. package/src/cli/serve/web/state/formRows.ts +9 -0
  53. package/src/cli/serve/web/state/host.ts +2 -0
  54. package/src/cli/serve/web/state/keptResults.ts +26 -0
  55. package/src/cli/serve/web/state/lightbox.ts +17 -0
  56. package/src/cli/serve/web/state/mediaDrop.ts +76 -0
  57. package/src/cli/serve/web/state/shortcutCatalog.ts +100 -0
  58. package/src/cli/serve/web/state/shortcuts.ts +10 -0
  59. package/src/cli/serve/web/styles.ts +112 -24
  60. package/src/cli/tui/imagePicker/ImagePickerOverlay.tsx +4 -1
  61. package/src/cli/tui/imagePicker/ImagePickerSt.ts +15 -6
  62. package/src/cli/tui/state/TuiSt.ts +1 -1
  63. package/src/coreExports.ts +10 -0
  64. package/src/exampleAssets.ts +13 -3
  65. package/src/host/ComfyUploader.ts +34 -27
  66. package/src/index.ts +1 -1
  67. package/src/runner/ComfyExecution.ts +38 -20
  68. package/src/runner/ComfyWsApi.ts +3 -0
  69. package/src/runner/mediaKinds.ts +51 -0
  70. package/src/vars/ComfyVars.ts +96 -22
  71. package/dist/run-serve-DlRBv_Nk.js.map +0 -1
  72. package/dist/run-tui-B5uxm2_l.js.map +0 -1
  73. package/dist/schemaDrift-E95iTF7E.js.map +0 -1
  74. package/dist/state-CUp2J1Zy.js.map +0 -1
  75. package/src/cli/serve/web/components/controls/ImageControl.tsx +0 -72
@@ -1,4 +1,4 @@
1
- import { Z as ansi, a as DefinedWorkflow, at as isQuiet, ct as logSuccess, dt as sha1HexOfString, et as extractErrorMessage, it as resolveComfyStorage, lt as statelessRegex, n as diffSchemas, nt as bang, ot as logError, rt as getComfyStorage, st as logInfo, t as MODEL_LISTS, tt as isRecord$1, ut as sha1Hex } from "./schemaDrift-E95iTF7E.js";
1
+ import { X as ansi, a as DefinedWorkflow, at as extractErrorMessage, ct as getComfyStorage, dt as logError, ft as logInfo, ht as sha1HexOfString, it as hashArrayBuffer, lt as resolveComfyStorage, mt as statelessRegex, n as diffSchemas, nt as isVideoFilename, ot as isRecord$1, pt as logSuccess, rt as mediaMime, st as bang, t as MODEL_LISTS, ut as isQuiet } from "./schemaDrift-BkN8rLiZ.js";
2
2
  import { basename, join } from "pathe";
3
3
  import { scope, type } from "arktype";
4
4
  import { nanoid } from "nanoid";
@@ -850,7 +850,7 @@ var ComfySchema = class {
850
850
  };
851
851
  //#endregion
852
852
  //#region package.json
853
- var version = "2.13.0";
853
+ var version = "2.15.0";
854
854
  //#endregion
855
855
  //#region src/litegraph/LiteGraphLinkID.ts
856
856
  const asLiteGraphLinkID = (id) => id;
@@ -2344,11 +2344,6 @@ function exhaust(x) {
2344
2344
  return x;
2345
2345
  }
2346
2346
  //#endregion
2347
- //#region src/utils/hashArrayBuffer.ts
2348
- const hashArrayBuffer = (buffer) => {
2349
- return sha1Hex(buffer);
2350
- };
2351
- //#endregion
2352
2347
  //#region src/graph/ComfyNodeID.ts
2353
2348
  const ComfyNodeId_ark = type.string.as();
2354
2349
  type({
@@ -2413,6 +2408,8 @@ const types$1 = scope({
2413
2408
  "previews?": [{ filepath: "string" }, "[]"],
2414
2409
  "images?": "ComfyImageInfo[]",
2415
2410
  "audio?": "ComfyImageInfo[]",
2411
+ "video?": "ComfyImageInfo[]",
2412
+ "gifs?": "ComfyImageInfo[]",
2416
2413
  "text?": "unknown[]"
2417
2414
  },
2418
2415
  prompt_id: "PromptID"
@@ -2665,18 +2662,6 @@ var MediaImage = class MediaImage {
2665
2662
  * A claim is released as soon as the write lands (the file itself then holds
2666
2663
  * the name) or fails (the name is free again) — the set never accumulates */
2667
2664
  const CLAIMED_OUTPUT_PATHS = /* @__PURE__ */ new Set();
2668
- const AUDIO_MIMES = {
2669
- flac: "audio/flac",
2670
- mp3: "audio/mpeg",
2671
- opus: "audio/ogg",
2672
- ogg: "audio/ogg",
2673
- wav: "audio/wav",
2674
- m4a: "audio/mp4"
2675
- };
2676
- function audioMime(filename) {
2677
- const ext = filename.split(".").pop()?.toLowerCase() ?? "";
2678
- return AUDIO_MIMES[ext] ?? "application/octet-stream";
2679
- }
2680
2665
  var ComfyExecution = class {
2681
2666
  get host() {
2682
2667
  return this.workflow.host;
@@ -2743,15 +2728,28 @@ var ComfyExecution = class {
2743
2728
  text: entry
2744
2729
  });
2745
2730
  }
2746
- const images = msg.data.output?.images;
2747
- if (images) for (const img of images) this.pendingPromises.push(this.retrieveImage(img, promptNodeID).catch((e) => {
2731
+ const out = msg.data.output;
2732
+ const listed = [
2733
+ ...out?.images ?? [],
2734
+ ...out?.video ?? [],
2735
+ ...out?.gifs ?? []
2736
+ ].filter((f) => f.type !== "input");
2737
+ for (const video of listed.filter((f) => isVideoFilename(f.filename))) this.pendingPromises.push(this.retrieveFile("video", video, promptNodeID).catch((e) => {
2738
+ console.error(`🔴 failed to retrieve ${video.filename}:`, e);
2739
+ this.videoErrors.push({
2740
+ video,
2741
+ error: e
2742
+ });
2743
+ }));
2744
+ const images = listed.filter((f) => !isVideoFilename(f.filename));
2745
+ if (images.length > 0) for (const img of images) this.pendingPromises.push(this.retrieveImage(img, promptNodeID).catch((e) => {
2748
2746
  console.error(`🔴 failed to retrieve ${img.filename}:`, e);
2749
2747
  this.imageErrors.push({
2750
2748
  image: img,
2751
2749
  error: e
2752
2750
  });
2753
2751
  }));
2754
- for (const audio of msg.data.output?.audio ?? []) this.pendingPromises.push(this.retrieveAudio(audio, promptNodeID).catch((e) => {
2752
+ for (const audio of msg.data.output?.audio ?? []) this.pendingPromises.push(this.retrieveFile("audio", audio, promptNodeID).catch((e) => {
2755
2753
  console.error(`🔴 failed to retrieve ${audio.filename}:`, e);
2756
2754
  this.audioErrors.push({
2757
2755
  audio,
@@ -2762,13 +2760,16 @@ var ComfyExecution = class {
2762
2760
  this.pendingPromises = [];
2763
2761
  this.audioErrors = [];
2764
2762
  this.audios = [];
2765
- this.retrieveAudio = async (info, promptNodeID) => {
2763
+ this.videoErrors = [];
2764
+ this.videos = [];
2765
+ this.retrieveFile = async (kind, info, promptNodeID) => {
2766
2766
  const response = await this.host.fetchFile("/view?" + new URLSearchParams(info).toString());
2767
2767
  const bytes = new Uint8Array(await response.arrayBuffer());
2768
- const mime = audioMime(info.filename);
2768
+ const mime = mediaMime(info.filename);
2769
+ const list = kind === "audio" ? this.audios : this.videos;
2769
2770
  const sf = this.save;
2770
2771
  if (sf == null) {
2771
- this.audios.push({
2772
+ list.push({
2772
2773
  nodeId: promptNodeID,
2773
2774
  filename: info.filename,
2774
2775
  mime,
@@ -2788,7 +2789,7 @@ var ComfyExecution = class {
2788
2789
  subfolder: info.subfolder,
2789
2790
  filename: info.filename
2790
2791
  });
2791
- this.audios.push({
2792
+ list.push({
2792
2793
  nodeId: promptNodeID,
2793
2794
  filename: info.filename,
2794
2795
  mime,
@@ -2968,6 +2969,7 @@ var ComfyExecution = class {
2968
2969
  const p = this.progress;
2969
2970
  const outputs = [`${this.images.length} image(s)`];
2970
2971
  if (this.audios.length > 0) outputs.push(`${this.audios.length} audio(s)`);
2972
+ if (this.videos.length > 0) outputs.push(`${this.videos.length} video(s)`);
2971
2973
  if (this.texts.length > 0) outputs.push(`${this.texts.length} text(s)`);
2972
2974
  const line = `${this.status === "Failure" ? "🔴" : "🟢"} ${this.status.toLowerCase()} in ${(p.elapsedMs / 1e3).toFixed(1)}s · ${outputs.join(" · ")}`;
2973
2975
  if (globalThis.process?.stdout?.isTTY) process.stdout.write(`\r\x1b[2K${line}\n`);
@@ -3661,15 +3663,23 @@ const ComfyUploadImageResult_ark = type({
3661
3663
  var ComfyUploader = class {
3662
3664
  constructor(host) {
3663
3665
  this.host = host;
3666
+ this.uploaded = /* @__PURE__ */ new Set();
3664
3667
  this.uploadImage = async (img, p) => {
3665
- const uniqFileName = img.enumName;
3666
- const expectedFinalName = p.subfolder ? `${p.subfolder}/${uniqFileName}` : uniqFileName;
3667
- if (this.host.schema.hasImage(expectedFinalName)) {
3668
- console.log(`[🌁] UPLOAD: 🩶 "${img.absPath}" already exists on current ComfyUI instance`);
3668
+ return await this.uploadInput({
3669
+ blob: img.getAsBlob(),
3670
+ name: img.enumName,
3671
+ ...p,
3672
+ slot: "LoadImage.image"
3673
+ });
3674
+ };
3675
+ this.uploadInput = async (p) => {
3676
+ const expectedFinalName = p.subfolder ? `${p.subfolder}/${p.name}` : p.name;
3677
+ if (this.uploaded.has(expectedFinalName) || this.host.schema.stringValues(p.slot).includes(expectedFinalName)) {
3678
+ console.log(`[🌁] UPLOAD: 🩶 "${expectedFinalName}" already exists on current ComfyUI instance`);
3669
3679
  return expectedFinalName;
3670
3680
  }
3671
3681
  const form = new FormData();
3672
- form.set("image", img.getAsBlob(), uniqFileName);
3682
+ form.set("image", p.blob, p.name);
3673
3683
  if (p.type) form.set("type", p.type);
3674
3684
  if (p.override ?? true) form.set("override", "true");
3675
3685
  if (p.subfolder) form.set("subfolder", p.subfolder);
@@ -3679,11 +3689,11 @@ var ComfyUploader = class {
3679
3689
  });
3680
3690
  const result = softValidate(ComfyUploadImageResult_ark, await resp.json());
3681
3691
  console.log("[🌁] UPLOAD: ✅ got", result);
3682
- if (result.name == null) throw new Error("upload failed");
3692
+ if (result.name == null) throw new Error(`upload of '${p.name}' failed: the host answered no name`);
3683
3693
  const finalName = result.subfolder ? `${result.subfolder}/${result.name}` : result.name;
3684
3694
  if (finalName !== expectedFinalName) console.warn(`[🌁] UPLOAD: ⚠️ expected "${expectedFinalName}" but got "${finalName}"`);
3685
- else console.log(`[🌁] UPLOAD: ✅ finalName is "${finalName}"`);
3686
- this.host.schema.unsafely_addImageInSchemaWithoutReloading(finalName);
3695
+ if (p.slot === "LoadImage.image") this.host.schema.unsafely_addImageInSchemaWithoutReloading(finalName);
3696
+ this.uploaded.add(finalName);
3687
3697
  return finalName;
3688
3698
  };
3689
3699
  }
@@ -5128,4 +5138,4 @@ var ComfyTS = class ComfyTS {
5128
5138
  //#endregion
5129
5139
  export { ComfySchema as a, importSharp as i, settingsPathFor as n, readableStringify as r, ComfyTS as t };
5130
5140
 
5131
- //# sourceMappingURL=state-CUp2J1Zy.js.map
5141
+ //# sourceMappingURL=state-CZsYJqB6.js.map