comfy-ts 2.18.1 → 2.20.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 (65) hide show
  1. package/README.md +147 -97
  2. package/claude-code/.claude-plugin/plugin.json +9 -0
  3. package/claude-code/skills/convert/SKILL.md +25 -0
  4. package/claude-code/skills/guide/SKILL.md +21 -0
  5. package/claude-code/skills/run/SKILL.md +12 -0
  6. package/claude-code/skills/setup/SKILL.md +15 -0
  7. package/claude-code/skills/workflow/SKILL.md +19 -0
  8. package/dist/{ServeApp-qXcQfdgT.js → ServeApp-B469W26E.js} +5 -5
  9. package/dist/{ServeApp-qXcQfdgT.js.map → ServeApp-B469W26E.js.map} +1 -1
  10. package/dist/cli.js +228 -11
  11. package/dist/cli.js.map +1 -1
  12. package/dist/{state-C067Kbew.js → exampleAssets-j1f26nGc.js} +177 -56
  13. package/dist/{state-C067Kbew.js.map → exampleAssets-j1f26nGc.js.map} +1 -1
  14. package/dist/{findDefinedWorkflow-0lG-VTEd.js → findDefinedWorkflow-B90-xFxX.js} +2 -2
  15. package/dist/{findDefinedWorkflow-0lG-VTEd.js.map → findDefinedWorkflow-B90-xFxX.js.map} +1 -1
  16. package/dist/index.cjs +92 -10
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +12 -2
  19. package/dist/index.d.ts +12 -2
  20. package/dist/index.js +92 -10
  21. package/dist/index.js.map +1 -1
  22. package/dist/{run-run-Zr699h2S.js → run-run-QEoh7Wbh.js} +5 -6
  23. package/dist/{run-run-Zr699h2S.js.map → run-run-QEoh7Wbh.js.map} +1 -1
  24. package/dist/{run-serve-DaXzoVTS.js → run-serve-CsEYPGm9.js} +4 -4
  25. package/dist/{run-serve-DaXzoVTS.js.map → run-serve-CsEYPGm9.js.map} +1 -1
  26. package/dist/{run-tui-CeM1GOJP.js → run-tui-YxiSoNvK.js} +9 -15
  27. package/dist/run-tui-YxiSoNvK.js.map +1 -0
  28. package/dist/{schemaDrift-CbsABBuk.js → schemaDrift-DaWsE-mt.js} +15 -15
  29. package/dist/{schemaDrift-CbsABBuk.js.map → schemaDrift-DaWsE-mt.js.map} +1 -1
  30. package/dist/web.d.ts +30 -20
  31. package/dist/web.js +83 -6
  32. package/dist/web.js.map +1 -1
  33. package/examples/README.md +17 -11
  34. package/examples/rvion/01-txt2img.cflow.ts +1 -1
  35. package/examples/rvion/02-img2img-upload.cflow.ts +1 -1
  36. package/examples/rvion/03-export-workflow-json.cflow.ts +1 -1
  37. package/examples/rvion/04-krea2-turbo-t2i.cflow.ts +1 -1
  38. package/examples/rvion/06-qwen-image-edit.cflow.ts +1 -1
  39. package/examples/rvion/07-local-llm-text-gen.cflow.ts +1 -1
  40. package/examples/rvion/08-qwen-image-21-t2i.cflow.ts +1 -1
  41. package/examples/rvion/09-qwen-image-21-edit.cflow.ts +1 -1
  42. package/examples/rvion/10-anima-t2i.cflow.ts +1 -1
  43. package/examples/rvion/11-yue2-t2a.cflow.ts +1 -1
  44. package/examples/rvion/12-stable-audio-3-t2a.cflow.ts +1 -1
  45. package/examples/rvion/13-ace-step-15-xl-t2a.cflow.ts +1 -1
  46. package/examples/rvion/14-video-soundtrack.cflow.ts +1 -1
  47. package/examples/rvion/15-tts-voice-clone.cflow.ts +1 -1
  48. package/examples/rvion/16-tts-voice-design.cflow.ts +1 -1
  49. package/guide-for-agents.md +8 -5
  50. package/package.json +8 -7
  51. package/src/cli/comfy-ts-cli.ts +12 -2
  52. package/src/cli/gen.ts +6 -1
  53. package/src/cli/serve/ServeApp.ts +4 -4
  54. package/src/cli/serve/web/api.ts +1 -1
  55. package/src/cli/skill.ts +207 -0
  56. package/src/cli/tui/components/Header.tsx +1 -4
  57. package/src/cli/tui/components/HostPanel.tsx +1 -4
  58. package/src/cli/tui/state/HostSt.ts +2 -2
  59. package/src/exampleAssets.ts +10 -4
  60. package/src/host/ComfyHost.ts +35 -5
  61. package/src/host/hostFile.ts +57 -0
  62. package/src/state.ts +15 -9
  63. package/dist/exampleAssets-BfWzygoM.js +0 -38
  64. package/dist/exampleAssets-BfWzygoM.js.map +0 -1
  65. package/dist/run-tui-CeM1GOJP.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -17698,8 +17698,18 @@ declare class ComfyHost<ID extends string = string> {
17698
17698
  /** the schema instance with all methods to interract with the host schema */
17699
17699
  schema: ComfySchema;
17700
17700
  uploader: ComfyUploader;
17701
- /** parsed ONCE from data (url-first or legacy host/port/https) — the url ground truth */
17702
- readonly base: ParsedHostBase;
17701
+ /** parsed ONCE from data (url-first, legacy host/port/https, or the address `gen` saved for
17702
+ * the id alone): the url ground truth. Throws the noAddress text when there is none */
17703
+ get base(): ParsedHostBase;
17704
+ private _base;
17705
+ /** why the id alone found no saved address; null when the host has one. An import stays safe
17706
+ * (like a missing schema cache): the error is logged once, then thrown at first use */
17707
+ noAddress: string | null;
17708
+ /** `host:port` for labels, or a short note when there is no address; never throws */
17709
+ get addressLabel(): string;
17710
+ /** read again at each use until found: a `comfy-ts gen` run after the import (a TUI or a
17711
+ * serve that stays up) makes the host usable without a restart */
17712
+ private readSavedAddress;
17703
17713
  constructor(data: ComfyHostData & {
17704
17714
  id: ID;
17705
17715
  });
package/dist/index.d.ts CHANGED
@@ -17698,8 +17698,18 @@ declare class ComfyHost<ID extends string = string> {
17698
17698
  /** the schema instance with all methods to interract with the host schema */
17699
17699
  schema: ComfySchema;
17700
17700
  uploader: ComfyUploader;
17701
- /** parsed ONCE from data (url-first or legacy host/port/https) — the url ground truth */
17702
- readonly base: ParsedHostBase;
17701
+ /** parsed ONCE from data (url-first, legacy host/port/https, or the address `gen` saved for
17702
+ * the id alone): the url ground truth. Throws the noAddress text when there is none */
17703
+ get base(): ParsedHostBase;
17704
+ private _base;
17705
+ /** why the id alone found no saved address; null when the host has one. An import stays safe
17706
+ * (like a missing schema cache): the error is logged once, then thrown at first use */
17707
+ noAddress: string | null;
17708
+ /** `host:port` for labels, or a short note when there is no address; never throws */
17709
+ get addressLabel(): string;
17710
+ /** read again at each use until found: a `comfy-ts gen` run after the import (a TUI or a
17711
+ * serve that stays up) makes the host usable without a restart */
17712
+ private readSavedAddress;
17703
17713
  constructor(data: ComfyHostData & {
17704
17714
  id: ID;
17705
17715
  });
package/dist/index.js CHANGED
@@ -110,7 +110,7 @@ function createNodeStorage() {
110
110
  }
111
111
  //#endregion
112
112
  //#region package.json
113
- var version = "2.18.1";
113
+ var version = "2.20.0";
114
114
  //#endregion
115
115
  //#region src/litegraph/LiteGraphLinkID.ts
116
116
  const asLiteGraphLinkID = (id) => id;
@@ -5049,6 +5049,54 @@ function renderPort(p) {
5049
5049
  return p.port === schemeDefault ? "" : `:${p.port}`;
5050
5050
  }
5051
5051
  //#endregion
5052
+ //#region src/host/hostFile.ts
5053
+ const HOST_FILE_NAME = "host.json";
5054
+ /** true when the caller gave no address at all: the id alone asks for the saved one */
5055
+ function namesNoAddress(p) {
5056
+ return p.url == null && p.host == null && p.port == null && p.https == null;
5057
+ }
5058
+ function hostFilePath(hostFolder) {
5059
+ return join(hostFolder, HOST_FILE_NAME);
5060
+ }
5061
+ /** the saved address of `id`, parsed; when there is none, the error text names the command that writes it */
5062
+ function readHostFile(storage, hostFolder, id) {
5063
+ const path = hostFilePath(hostFolder);
5064
+ const gen = `\`comfy-ts gen --host <url> --id ${id}\``;
5065
+ const text = storage.readTextIfExists(path);
5066
+ if (text == null) return {
5067
+ base: null,
5068
+ error: `host '${id}': no address given and no ${path}. ${storage.kind === "node" ? `run ${gen} once from this project (it saves the address), or pass the address: host({ id: '${id}', url: '<url>' })` : `this runtime has no saved hosts (${storage.kind} storage): pass the address, host({ id: '${id}', url: '<url>' })`}`
5069
+ };
5070
+ let json;
5071
+ try {
5072
+ json = JSON.parse(text);
5073
+ } catch {
5074
+ return {
5075
+ base: null,
5076
+ error: `host '${id}': ${path} is not valid json. Write it again with ${gen}`
5077
+ };
5078
+ }
5079
+ const url = json != null && typeof json === "object" && "url" in json ? json.url : null;
5080
+ if (typeof url !== "string" || url === "") return {
5081
+ base: null,
5082
+ error: `host '${id}': ${path} has no "url" string. Write it again with ${gen}`
5083
+ };
5084
+ try {
5085
+ return {
5086
+ base: parseHostBase({
5087
+ id,
5088
+ url
5089
+ }),
5090
+ error: null
5091
+ };
5092
+ } catch (e) {
5093
+ return {
5094
+ base: null,
5095
+ error: `${extractErrorMessage(e)} (read from ${path})`
5096
+ };
5097
+ }
5098
+ }
5099
+ //#endregion
5052
5100
  //#region src/host/ResilientWebsocket.ts
5053
5101
  let transportPromise = null;
5054
5102
  /** node: the ws package (headers on the upgrade). browser: native WebSocket. */
@@ -6781,9 +6829,30 @@ var ComfyHostAuthError = class extends Error {
6781
6829
  }
6782
6830
  };
6783
6831
  var ComfyHost = class {
6832
+ /** parsed ONCE from data (url-first, legacy host/port/https, or the address `gen` saved for
6833
+ * the id alone): the url ground truth. Throws the noAddress text when there is none */
6834
+ get base() {
6835
+ this.readSavedAddress();
6836
+ if (this._base == null) throw new Error(this.noAddress ?? `host '${this.data.id}': no address`);
6837
+ return this._base;
6838
+ }
6839
+ /** `host:port` for labels, or a short note when there is no address; never throws */
6840
+ get addressLabel() {
6841
+ return this._base == null ? "no saved address" : `${this._base.host}:${this._base.port}`;
6842
+ }
6843
+ /** read again at each use until found: a `comfy-ts gen` run after the import (a TUI or a
6844
+ * serve that stays up) makes the host usable without a restart */
6845
+ readSavedAddress() {
6846
+ if (this._base != null || !namesNoAddress(this.data)) return;
6847
+ const saved = readHostFile(getComfyStorage(), this.cacheFolder, this.data.id);
6848
+ this._base = saved.base;
6849
+ this.noAddress = saved.error;
6850
+ }
6784
6851
  constructor(data) {
6785
6852
  this.data = data;
6786
6853
  this.uploader = new ComfyUploader(this);
6854
+ this._base = null;
6855
+ this.noAddress = null;
6787
6856
  this.matchRequirements = (requirements) => this.manager.matchRequirements(requirements);
6788
6857
  this.checkRequirements = (requirements) => this.manager.checkRequirements(requirements);
6789
6858
  this.serverLogs = [];
@@ -6893,6 +6962,8 @@ var ComfyHost = class {
6893
6962
  this._schemaStrategy = "auto";
6894
6963
  this._schemaMaxAgeMs = 24 * 36e5;
6895
6964
  this.connect = (p = {}) => {
6965
+ this.readSavedAddress();
6966
+ if (this.noAddress != null) return Promise.reject(new Error(this.noAddress));
6896
6967
  if (this._ready == null) {
6897
6968
  this._schemaStrategy = p.schema ?? "auto";
6898
6969
  this._schemaMaxAgeMs = p.maxAgeMs ?? 24 * 36e5;
@@ -7052,10 +7123,13 @@ var ComfyHost = class {
7052
7123
  this._unknownWsEventTypes = /* @__PURE__ */ new Set();
7053
7124
  this.status = null;
7054
7125
  this.lastWsMessageAt = null;
7055
- this.base = parseHostBase(this.data);
7056
7126
  /** folder where file related to the host config will be cached */
7057
7127
  this.cacheFolder = comfyts.resolveFromHosts(this.data.id);
7058
7128
  const storage = getComfyStorage();
7129
+ if (namesNoAddress(this.data)) {
7130
+ this.readSavedAddress();
7131
+ if (this.noAddress != null) logError(this.noAddress);
7132
+ } else this._base = parseHostBase(this.data);
7059
7133
  if (!storage.exists(this.cacheFolder)) {
7060
7134
  console.log("🟢 creating folder", this.cacheFolder);
7061
7135
  storage.mkdirp(this.cacheFolder);
@@ -7957,11 +8031,14 @@ var ComfyTS = class ComfyTS {
7957
8031
  host(data) {
7958
8032
  const existing = this.hosts.get(data.id);
7959
8033
  if (existing != null) {
7960
- const incoming = parseHostBase(data);
7961
- const cur = existing.base;
7962
- const sameBase = cur.scheme === incoming.scheme && cur.host === incoming.host && cur.port === incoming.port && cur.basePath === incoming.basePath;
8034
+ const incoming = namesNoAddress(data) ? null : parseHostBase(data);
8035
+ const cur = existing.noAddress == null ? existing.base : null;
8036
+ const sameBase = incoming == null || cur != null && cur.scheme === incoming.scheme && cur.host === incoming.host && cur.port === incoming.port && cur.basePath === incoming.basePath;
7963
8037
  const sameAuth = existing.data.apiKey == null === (data.apiKey == null);
7964
- if (!sameBase || !sameAuth) throw new Error(`host id '${data.id}' already registered at ${renderHttpBase(cur)}${existing.data.apiKey != null ? " (authed)" : ""} — refusing ${renderHttpBase(incoming)}${data.apiKey != null ? " (authed)" : ""}`);
8038
+ if (!sameBase || !sameAuth) {
8039
+ const authed = (p) => p.apiKey != null ? " (authed)" : "";
8040
+ throw new Error(`host id '${data.id}' already registered ${cur == null ? "with no address" : `at ${renderHttpBase(cur)}`}${authed(existing.data)} — refusing ${incoming == null ? "the id alone" : renderHttpBase(incoming)}${authed(data)}`);
8041
+ }
7965
8042
  return existing;
7966
8043
  }
7967
8044
  const created = new ComfyHost(data);
@@ -8033,6 +8110,14 @@ function loraTag(name, strength = 1, clipStrength) {
8033
8110
  * package.json all the way up is a broken install and throws.
8034
8111
  */
8035
8112
  function bundledExamplesDir(moduleUrl = import.meta.url) {
8113
+ const pkgDir = comfyTsPackageDir(moduleUrl);
8114
+ if (pkgDir == null) return null;
8115
+ const examples = join(pkgDir, "examples");
8116
+ return existsSync(examples) ? examples : null;
8117
+ }
8118
+ /** the comfy-ts package root (the folder of its package.json), by the same walk: null when the
8119
+ * nearest named package is another one, a throw when no package.json is found at all */
8120
+ function comfyTsPackageDir(moduleUrl = import.meta.url) {
8036
8121
  let dir = dirname(fileURLToPath(moduleUrl));
8037
8122
  let prev = "";
8038
8123
  while (dir !== prev) {
@@ -8042,10 +8127,7 @@ function bundledExamplesDir(moduleUrl = import.meta.url) {
8042
8127
  try {
8043
8128
  pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
8044
8129
  } catch {}
8045
- if (pkg.name === "comfy-ts") {
8046
- const examples = join(dir, "examples");
8047
- return existsSync(examples) ? examples : null;
8048
- }
8130
+ if (pkg.name === "comfy-ts") return dir;
8049
8131
  if (pkg.name != null) return null;
8050
8132
  }
8051
8133
  prev = dir;