comfy-ts 2.1.0 → 2.3.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 (42) hide show
  1. package/README.md +65 -225
  2. package/dist/{DefinedWorkflow-CqNE_kgR.js → DefinedWorkflow-CwHInZgn.js} +4 -3
  3. package/dist/DefinedWorkflow-CwHInZgn.js.map +1 -0
  4. package/dist/{DraftsSt-C-gBk9v7.js → DraftsSt-omWuBSej.js} +2 -2
  5. package/dist/{DraftsSt-C-gBk9v7.js.map → DraftsSt-omWuBSej.js.map} +1 -1
  6. package/dist/cli.js +3 -3
  7. package/dist/index.cjs +54 -6
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +28 -3
  10. package/dist/index.d.ts +28 -3
  11. package/dist/index.js +54 -7
  12. package/dist/index.js.map +1 -1
  13. package/dist/{run-serve-CnlN_RFH.js → run-serve-CfzOH-AR.js} +174 -126
  14. package/dist/run-serve-CfzOH-AR.js.map +1 -0
  15. package/dist/{run-tui-DXI_Jufu.js → run-tui-_LD0DoGe.js} +49 -50
  16. package/dist/run-tui-_LD0DoGe.js.map +1 -0
  17. package/dist/{state-DC5BcG6d.js → state-C-OOEcp3.js} +54 -8
  18. package/dist/state-C-OOEcp3.js.map +1 -0
  19. package/dist/web.d.ts +28 -3
  20. package/dist/web.js +54 -7
  21. package/dist/web.js.map +1 -1
  22. package/examples/README.md +6 -18
  23. package/examples/images/README.md +2 -6
  24. package/guide-for-agents.md +25 -84
  25. package/package.json +1 -1
  26. package/src/cli/serve/ServeApp.ts +21 -11
  27. package/src/cli/serve/applyVarPayload.ts +91 -71
  28. package/src/cli/serve/describeVar.ts +57 -28
  29. package/src/cli/tui/components/StatusBar.tsx +1 -0
  30. package/src/cli/tui/components/TextOverlay.tsx +7 -3
  31. package/src/cli/tui/components/VarsPanel.tsx +2 -2
  32. package/src/cli/tui/state/ExecSt.ts +47 -52
  33. package/src/cli/tui/state/TuiSt.ts +11 -6
  34. package/src/coreExports.ts +1 -0
  35. package/src/host/ComfyHost.ts +55 -3
  36. package/src/runner/ComfyExecution.ts +15 -7
  37. package/src/runner/outputPath.ts +11 -0
  38. package/src/vars/ComfyVars.ts +12 -2
  39. package/dist/DefinedWorkflow-CqNE_kgR.js.map +0 -1
  40. package/dist/run-serve-CnlN_RFH.js.map +0 -1
  41. package/dist/run-tui-DXI_Jufu.js.map +0 -1
  42. package/dist/state-DC5BcG6d.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { i as stripAnsi, n as settingsPathFor, o as sha1HexOfString } from "./state-DC5BcG6d.js";
2
- import { c as PromptVar, g as getComfyStorage, h as extractErrorMessage, m as setLoraKeyword, p as getLoraKeyword, s as LorasVar, y as logError } from "./DefinedWorkflow-CqNE_kgR.js";
3
- import { a as assignFamilyColors, c as findDefinedWorkflow, i as listDraftsForFile, l as mergeWorkflowSources, n as draftKeyForFile, o as buildFileRows, s as familyOf, t as DraftsSt, u as scanCflowFiles } from "./DraftsSt-C-gBk9v7.js";
1
+ import { a as importSharp, i as stripAnsi, n as settingsPathFor, s as sha1HexOfString } from "./state-C-OOEcp3.js";
2
+ import { a as setLoraKeyword, i as getLoraKeyword, n as LorasVar, o as extractErrorMessage, r as PromptVar, s as getComfyStorage, u as logError } from "./DefinedWorkflow-CwHInZgn.js";
3
+ import { a as assignFamilyColors, c as findDefinedWorkflow, i as listDraftsForFile, l as mergeWorkflowSources, n as draftKeyForFile, o as buildFileRows, s as familyOf, t as DraftsSt, u as scanCflowFiles } from "./DraftsSt-omWuBSej.js";
4
4
  import { spawn } from "node:child_process";
5
5
  import { fileURLToPath, pathToFileURL } from "node:url";
6
6
  import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, writeFileSync } from "node:fs";
@@ -477,6 +477,7 @@ const ProgressLine = observer((p) => {
477
477
  });
478
478
  const KIND_KEYS = {
479
479
  text: [["⏎/→", "edit"]],
480
+ prompt: [["⏎/→", "edit"]],
480
481
  int: [["⏎/→", "edit"]],
481
482
  float: [["⏎/→", "edit"]],
482
483
  seed: [
@@ -1607,9 +1608,10 @@ const TextOverlay = observer((p) => {
1607
1608
  const s = p.st;
1608
1609
  const ed = s.editor;
1609
1610
  const winLines = s.overlayLines;
1610
- const promptVar = s.selected?.[1];
1611
- const isPrompt = promptVar instanceof PromptVar;
1612
- const injected = isPrompt ? promptVar.injectedKeywords() : [];
1611
+ const selectedVar = s.selected?.[1];
1612
+ const promptVar = selectedVar?.kind === "prompt" ? selectedVar : null;
1613
+ const isPrompt = promptVar != null;
1614
+ const injected = promptVar?.injectedKeywords() ?? [];
1613
1615
  const lines = [];
1614
1616
  let start = 0;
1615
1617
  for (const text of ed.buffer.split("\n")) {
@@ -1858,7 +1860,7 @@ const VarRow = observer((p) => {
1858
1860
  color: "cyan",
1859
1861
  wrap: "truncate",
1860
1862
  children: value.replaceAll("\n", " ")
1861
- }) : p.varDef instanceof PromptVar ? /* @__PURE__ */ jsx(PromptCell, {
1863
+ }) : p.varDef.kind === "prompt" ? /* @__PURE__ */ jsx(PromptCell, {
1862
1864
  varDef: p.varDef,
1863
1865
  value
1864
1866
  }) : /* @__PURE__ */ jsx(Text, {
@@ -2789,6 +2791,10 @@ var ExecSt = class {
2789
2791
  this.copyPopup = null;
2790
2792
  this.st.mode = "nav";
2791
2793
  }
2794
+ /** makeAutoObservable already annotates this method as an action, so the
2795
+ * post-await callers below need no runInAction of their own (verified
2796
+ * against mobx: a TS-private prototype method called after an `await`
2797
+ * opens its own action context; only a CONSTRUCTOR body does not) */
2792
2798
  showCopyPopup(title, ok, lines) {
2793
2799
  const m = this.st.mode;
2794
2800
  if (m === "edit" || m.startsWith("overlay-")) {
@@ -2841,16 +2847,14 @@ var ExecSt = class {
2841
2847
  proc.on("error", () => resolve(false));
2842
2848
  proc.on("close", (code) => resolve(code === 0));
2843
2849
  });
2844
- runInAction(() => {
2845
- this.showCopyPopup("image → clipboard", ok, ok ? [
2846
- `${basename(file)} — paste the pixels anywhere`,
2847
- "",
2848
- `via fallback file ${file}`
2849
- ] : [`COPY FAILED for ${lastImg.filename}`, `could not run ${piped.cmd} — is it installed and allowed ?`]);
2850
- });
2850
+ this.showCopyPopup("image → clipboard", ok, ok ? [
2851
+ `${basename(file)} — paste the pixels anywhere`,
2852
+ "",
2853
+ `via fallback file ${file}`
2854
+ ] : [`COPY FAILED for ${lastImg.filename}`, `could not run ${piped.cmd} — is it installed and allowed ?`]);
2851
2855
  }
2852
2856
  async toPngBytes(bytes) {
2853
- const { default: sharp } = await import("sharp");
2857
+ const sharp = await importSharp("the clipboard png normalize");
2854
2858
  return new Uint8Array(await sharp(bytes).png().toBuffer());
2855
2859
  }
2856
2860
  runWithStdin(p) {
@@ -2896,22 +2900,18 @@ var ExecSt = class {
2896
2900
  const json = await (await this.st.wf.build({ host: this.st.hostOverride ?? void 0 })).toWorkflowJson();
2897
2901
  const text = JSON.stringify(json, null, 2);
2898
2902
  const ok = await this.toClipboard(text);
2899
- runInAction(() => {
2900
- this.showCopyPopup("workflow.json → clipboard", ok, ok ? [
2901
- `${json.nodes.length} nodes · ${text.length} chars — paste into the ComfyUI editor`,
2902
- "",
2903
- ...jsonHead(text, 10)
2904
- ] : ["CLIPBOARD COPY FAILED — is a clipboard tool available (pbcopy/clip/xclip) ?"]);
2905
- });
2903
+ this.showCopyPopup("workflow.json → clipboard", ok, ok ? [
2904
+ `${json.nodes.length} nodes · ${text.length} chars — paste into the ComfyUI editor`,
2905
+ "",
2906
+ ...jsonHead(text, 10)
2907
+ ] : ["CLIPBOARD COPY FAILED — is a clipboard tool available (pbcopy/clip/xclip) ?"]);
2906
2908
  } catch (e) {
2907
- runInAction(() => {
2908
- this.showCopyPopup("workflow.json copy FAILED", false, [
2909
- extractErrorMessage(e),
2910
- "",
2911
- "nothing was copied. i2i/i2v builds upload their input image first —",
2912
- "an unreachable host fails the build itself, not just the run."
2913
- ]);
2914
- });
2909
+ this.showCopyPopup("workflow.json copy FAILED", false, [
2910
+ extractErrorMessage(e),
2911
+ "",
2912
+ "nothing was copied. i2i/i2v builds upload their input image first —",
2913
+ "an unreachable host fails the build itself, not just the run."
2914
+ ]);
2915
2915
  } finally {
2916
2916
  runInAction(() => {
2917
2917
  this.copying = false;
@@ -2929,22 +2929,18 @@ var ExecSt = class {
2929
2929
  const json = (await this.st.wf.build({ host: this.st.hostOverride ?? void 0 })).toApiJson("use_stringified_numbers_only");
2930
2930
  const text = JSON.stringify(json, null, 2);
2931
2931
  const ok = await this.toClipboard(text);
2932
- runInAction(() => {
2933
- this.showCopyPopup("api.json → clipboard", ok, ok ? [
2934
- `${Object.keys(json).length} nodes · ${text.length} chars — the POST /prompt payload`,
2935
- "",
2936
- ...jsonHead(text, 10)
2937
- ] : ["CLIPBOARD COPY FAILED — is a clipboard tool available (pbcopy/clip/xclip) ?"]);
2938
- });
2932
+ this.showCopyPopup("api.json → clipboard", ok, ok ? [
2933
+ `${Object.keys(json).length} nodes · ${text.length} chars — the POST /prompt payload`,
2934
+ "",
2935
+ ...jsonHead(text, 10)
2936
+ ] : ["CLIPBOARD COPY FAILED — is a clipboard tool available (pbcopy/clip/xclip) ?"]);
2939
2937
  } catch (e) {
2940
- runInAction(() => {
2941
- this.showCopyPopup("api.json copy FAILED", false, [
2942
- extractErrorMessage(e),
2943
- "",
2944
- "nothing was copied. i2i/i2v builds upload their input image first —",
2945
- "an unreachable host fails the build itself, not just the run."
2946
- ]);
2947
- });
2938
+ this.showCopyPopup("api.json copy FAILED", false, [
2939
+ extractErrorMessage(e),
2940
+ "",
2941
+ "nothing was copied. i2i/i2v builds upload their input image first —",
2942
+ "an unreachable host fails the build itself, not just the run."
2943
+ ]);
2948
2944
  } finally {
2949
2945
  runInAction(() => {
2950
2946
  this.copying = false;
@@ -4249,9 +4245,12 @@ var TuiSt = class {
4249
4245
  this.applyPersistedHostOverride();
4250
4246
  this.drafts.activateRemembered();
4251
4247
  if (opts.currentFile != null) {
4252
- this.tree.expandedFiles.add(opts.currentFile);
4253
- this.workflows.recordSpecColor(opts.currentFile, wf);
4254
- this.settings.lastWorkflow = opts.currentFile;
4248
+ const currentFile = opts.currentFile;
4249
+ runInAction(() => {
4250
+ this.tree.expandedFiles.add(currentFile);
4251
+ this.workflows.recordSpecColor(currentFile, wf);
4252
+ this.settings.lastWorkflow = currentFile;
4253
+ });
4255
4254
  }
4256
4255
  const onResize = () => {
4257
4256
  runInAction(() => {
@@ -4361,7 +4360,7 @@ var TuiSt = class {
4361
4360
  const sel = this.selected?.[1];
4362
4361
  if (sel == null) return;
4363
4362
  if (sel.kind === "toggle") sel.toggle();
4364
- else if (sel.kind === "text") this.editor.beginMultiline();
4363
+ else if (sel.kind === "text" || sel.kind === "prompt") this.editor.beginMultiline();
4365
4364
  else if (sel.kind === "choice") this.picker.beginChoice();
4366
4365
  else if (sel.kind === "size") this.picker.beginSize();
4367
4366
  else if (sel.kind === "loras") this.loras.begin();
@@ -4464,4 +4463,4 @@ async function runTui(args) {
4464
4463
  //#endregion
4465
4464
  export { runTui };
4466
4465
 
4467
- //# sourceMappingURL=run-tui-DXI_Jufu.js.map
4466
+ //# sourceMappingURL=run-tui-_LD0DoGe.js.map