comfy-ts 1.1.0 → 1.2.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 (48) hide show
  1. package/README.md +21 -8
  2. package/dist/cli.js +4 -4552
  3. package/dist/cli.js.map +1 -1
  4. package/dist/index.cjs +53 -12
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +49 -23
  7. package/dist/index.d.ts +49 -23
  8. package/dist/index.js +53 -12
  9. package/dist/index.js.map +1 -1
  10. package/dist/{run-tui-DZ22HDHI.js → run-tui-BAdizWsO.js} +722 -130
  11. package/dist/run-tui-BAdizWsO.js.map +1 -0
  12. package/dist/state-BYbxDgfr.js +5258 -0
  13. package/dist/state-BYbxDgfr.js.map +1 -0
  14. package/examples/README.md +6 -4
  15. package/examples/{01-txt2img.cflow.ts → rvion/01-txt2img.cflow.ts} +1 -1
  16. package/examples/{02-img2img-upload.cflow.ts → rvion/02-img2img-upload.cflow.ts} +1 -1
  17. package/examples/{03-export-workflow-json.cflow.ts → rvion/03-export-workflow-json.cflow.ts} +1 -1
  18. package/examples/{04-krea2-turbo-t2i.cflow.ts → rvion/04-krea2-turbo-t2i.cflow.ts} +2 -2
  19. package/examples/{05-comfy-cloud.cflow.ts → rvion/05-comfy-cloud.cflow.ts} +2 -2
  20. package/examples/rvion/06-qwen-image-edit.cflow.ts +89 -0
  21. package/package.json +4 -1
  22. package/src/cli/tui/components/CopyOverlay.tsx +25 -0
  23. package/src/cli/tui/components/Header.tsx +9 -4
  24. package/src/cli/tui/components/HostPanel.tsx +3 -2
  25. package/src/cli/tui/components/HostsOverlay.tsx +33 -0
  26. package/src/cli/tui/components/StatusBar.tsx +28 -9
  27. package/src/cli/tui/components/TreePanel.tsx +17 -7
  28. package/src/cli/tui/components/TuiApp.tsx +47 -5
  29. package/src/cli/tui/imagePicker/fsListing.ts +6 -4
  30. package/src/cli/tui/run-tui.tsx +47 -7
  31. package/src/cli/tui/state/DraftsSt.ts +3 -2
  32. package/src/cli/tui/state/ExecSt.ts +108 -12
  33. package/src/cli/tui/state/HostSt.ts +94 -10
  34. package/src/cli/tui/state/PickerSt.ts +8 -2
  35. package/src/cli/tui/state/QueueSt.ts +2 -2
  36. package/src/cli/tui/state/SettingsSt.ts +25 -7
  37. package/src/cli/tui/state/TreeSt.ts +139 -36
  38. package/src/cli/tui/state/TuiSt.ts +47 -6
  39. package/src/cli/tui/state/WorkflowsSt.ts +14 -2
  40. package/src/cli/tui/treeRows.ts +165 -0
  41. package/src/host/ComfyHost.ts +7 -0
  42. package/src/runner/ComfyWorkflowLayout.ts +6 -4
  43. package/src/state.ts +7 -1
  44. package/src/vars/ComfyVars.ts +25 -4
  45. package/src/vars/DefinedWorkflow.ts +21 -8
  46. package/dist/DefinedWorkflow-BYyu5dK9.js +0 -669
  47. package/dist/DefinedWorkflow-BYyu5dK9.js.map +0 -1
  48. package/dist/run-tui-DZ22HDHI.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -40,7 +40,7 @@ node_https = __toESM(node_https, 1);
40
40
  let node_process = require("node:process");
41
41
  let node_url = require("node:url");
42
42
  //#region package.json
43
- var version = "1.1.0";
43
+ var version = "1.2.0";
44
44
  //#endregion
45
45
  //#region src/litegraph/LiteGraphLinkID.ts
46
46
  const asLiteGraphLinkID = (id) => id;
@@ -2214,8 +2214,8 @@ function comfyWorkflowAutoLayout(p) {
2214
2214
  if (cols[at]) cols[at].push(node);
2215
2215
  else cols[at] = [node];
2216
2216
  }
2217
- const HSEP = p?.node_hsep ?? 20;
2218
- const VSEP = p?.node_vsep ?? 20;
2217
+ const HSEP = p?.node_hsep ?? 100;
2218
+ const VSEP = p?.node_vsep ?? 40;
2219
2219
  let colX = 0;
2220
2220
  let maxY = 0;
2221
2221
  for (const col of cols) {
@@ -3946,16 +3946,38 @@ const DEFAULT_SIZE_PRESETS = [
3946
3946
  height: 1344
3947
3947
  }
3948
3948
  ];
3949
- /** width/height picker: presets + free `WxH` entry */
3949
+ /** width/height picker: presets + free `WxH` entry + optionally the LIVE
3950
+ * size of a linked image var (his ask 2026-07-30: the widget shows
3951
+ * `WxH size of image '<name>'` as a pickable row) */
3950
3952
  var SizeVar = class extends ComfyVar {
3951
3953
  constructor(defaultValue = {
3952
3954
  width: 1024,
3953
3955
  height: 1024
3954
- }, presets = DEFAULT_SIZE_PRESETS, label) {
3956
+ }, presets = DEFAULT_SIZE_PRESETS, label, imageVar) {
3955
3957
  super(defaultValue, label);
3956
3958
  this.presets = presets;
3959
+ this.imageVar = imageVar;
3957
3960
  this.kind = "size";
3958
3961
  }
3962
+ /** current dimensions of the linked image var — null when no link, unset
3963
+ * path, or an unreadable/undecodable file (those errors belong to the
3964
+ * image var itself, the size row simply disappears) */
3965
+ imageSize() {
3966
+ const iv = this.imageVar;
3967
+ if (iv == null || iv.value === "") return null;
3968
+ try {
3969
+ const abs = iv.absPath();
3970
+ const meta = (0, image_meta.imageMeta)(new Uint8Array((0, node_fs.readFileSync)(abs)));
3971
+ if (meta.width == null || meta.height == null) return null;
3972
+ return {
3973
+ width: meta.width,
3974
+ height: meta.height,
3975
+ name: (0, pathe.basename)(abs)
3976
+ };
3977
+ } catch {
3978
+ return null;
3979
+ }
3980
+ }
3959
3981
  /** accepts '1024x768' / '1024×768' / a preset label */
3960
3982
  parse(raw) {
3961
3983
  const m = raw.trim().match(/^(\d+)\s*[x×]\s*(\d+)$/);
@@ -4058,7 +4080,7 @@ const v = {
4058
4080
  toggle: (defaultValue, label) => new ToggleVar(defaultValue, label),
4059
4081
  choice: (choices, defaultValue, label) => new ChoiceVar(choices, defaultValue, label),
4060
4082
  loras: (options, initial = {}, label) => new LorasVar(options, initial, label),
4061
- size: (defaultValue, opts = {}) => new SizeVar(defaultValue, opts.presets, opts.label),
4083
+ size: (defaultValue, opts = {}) => new SizeVar(defaultValue, opts.presets, opts.label, opts.image),
4062
4084
  image: (defaultValue, opts = {}) => new ImageVar(defaultValue, opts)
4063
4085
  };
4064
4086
  function varValues(vars) {
@@ -4097,10 +4119,12 @@ var DefinedWorkflow = class {
4097
4119
  * (set by run()) fires each var's afterRun() right after snapshotting the
4098
4120
  * values — atomically, before any await — so the graph uses this run's seed
4099
4121
  * while the var moves to the next (queued runs get distinct seeds; a bare
4100
- * build() for copy/export never advances).
4122
+ * build() for copy/export never advances). `p.host` substitutes the host
4123
+ * the graph is built against (TUI host override): node/model availability
4124
+ * there surfaces as workflow.problems / server validation, by design.
4101
4125
  */
4102
4126
  async build(p = {}) {
4103
- const wf = this.host.workflow({ id: this.spec.id });
4127
+ const wf = (p.host ?? this.host).workflow({ id: this.spec.id });
4104
4128
  const values = varValues(this.vars);
4105
4129
  if (p.advance) for (const varDef of Object.values(this.vars)) varDef.afterRun();
4106
4130
  await this.spec.build(wf.builder, values, wf);
@@ -4108,10 +4132,20 @@ var DefinedWorkflow = class {
4108
4132
  return wf;
4109
4133
  }
4110
4134
  /** build a fresh graph from the current var values, send it, wait for outputs.
4111
- * connects first (idempotent) — modules can import offline from the schema cache */
4135
+ * connects first (idempotent) — modules can import offline from the schema cache.
4136
+ * `settings.host` runs against THAT host instead of the defining one. */
4112
4137
  async run(settings = {}) {
4113
- await this.host.connect();
4114
- const execution = await (await this.build({ advance: true })).run(settings);
4138
+ const host = settings.host ?? this.host;
4139
+ await host.connect();
4140
+ const execution = await (await this.build({
4141
+ advance: true,
4142
+ host
4143
+ })).run({
4144
+ saveFormat: settings.saveFormat,
4145
+ idMode: settings.idMode,
4146
+ log: settings.log,
4147
+ onProgress: settings.onProgress
4148
+ });
4115
4149
  this.lastExecution = execution;
4116
4150
  return execution;
4117
4151
  }
@@ -4368,6 +4402,7 @@ var ComfyHost = class {
4368
4402
  this.comfySessionId = "temp";
4369
4403
  this._unknownBinaryFrameTypes = /* @__PURE__ */ new Set();
4370
4404
  this.status = null;
4405
+ this.lastWsMessageAt = null;
4371
4406
  this.base = parseHostBase(this.data);
4372
4407
  /** folder where file related to the host config will be cached */
4373
4408
  this.cacheFolder = comfyts.resolveFromHosts(this.data.id);
@@ -4521,6 +4556,7 @@ var ComfyHost = class {
4521
4556
  prompt.onPromptRelatedMessage(msg);
4522
4557
  }
4523
4558
  onMessage(e) {
4559
+ this.lastWsMessageAt = Date.now();
4524
4560
  if (this.data.onWsMessageAny) this.data.onWsMessageAny(e);
4525
4561
  if (e.data instanceof ArrayBuffer) {
4526
4562
  const frame = parseBinaryWsFrame(e.data);
@@ -5185,6 +5221,11 @@ var ComfyRegistry = class ComfyRegistry {
5185
5221
  };
5186
5222
  //#endregion
5187
5223
  //#region src/state.ts
5224
+ /** the ONE settings-file location rule — run-tui reads it BEFORE any module
5225
+ * import creates the comfyts global, so the path logic cannot live on the instance only */
5226
+ function settingsPathFor(root) {
5227
+ return asAbsolutePath((0, pathe.join)(root, ".comfy-ts", "settings.json"));
5228
+ }
5188
5229
  /** singleton */
5189
5230
  var ComfyTS = class ComfyTS {
5190
5231
  constructor(p = {}) {
@@ -5253,7 +5294,7 @@ var ComfyTS = class ComfyTS {
5253
5294
  }
5254
5295
  /** local TUI settings (preview mode, last draft per workflow) — gitignored */
5255
5296
  get settingsPath() {
5256
- return asAbsolutePath((0, pathe.join)(this.baseFolder, "settings.json"));
5297
+ return settingsPathFor(this.rootPath);
5257
5298
  }
5258
5299
  resolveFromHosts(relativePath) {
5259
5300
  return asAbsolutePath((0, pathe.join)(this.hostsFolder, relativePath));