comfy-ts 2.9.0 → 2.11.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 (55) hide show
  1. package/README.md +6 -4
  2. package/dist/{LogsSt-DFxzQfDc.js → LogsSt-qtFzOKpu.js} +2 -2
  3. package/dist/{LogsSt-DFxzQfDc.js.map → LogsSt-qtFzOKpu.js.map} +1 -1
  4. package/dist/cli.js +4 -4
  5. package/dist/index.cjs +102 -3
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +19 -0
  8. package/dist/index.d.ts +19 -0
  9. package/dist/index.js +102 -3
  10. package/dist/index.js.map +1 -1
  11. package/dist/{run-serve-_nrvJYyt.js → run-serve-BK7BA2dn.js} +91 -3
  12. package/dist/run-serve-BK7BA2dn.js.map +1 -0
  13. package/dist/{run-tui-BLEdTsOX.js → run-tui-CQyvMf0N.js} +36 -4
  14. package/dist/run-tui-CQyvMf0N.js.map +1 -0
  15. package/dist/{DefinedWorkflow-BatWaZO1.js → schemaDrift-DjjEtwfx.js} +176 -2
  16. package/dist/schemaDrift-DjjEtwfx.js.map +1 -0
  17. package/dist/serve-web.js +32 -16
  18. package/dist/{state-BbgJeCe6.js → state--wrz0BQc.js} +23 -5
  19. package/dist/state--wrz0BQc.js.map +1 -0
  20. package/dist/web.d.ts +19 -0
  21. package/dist/web.js +102 -3
  22. package/dist/web.js.map +1 -1
  23. package/examples/README.md +1 -0
  24. package/examples/comfy-cloud/capybara-i2v.cflow.ts +2 -0
  25. package/examples/comfy-cloud/ltx25-i2v.cflow.ts +152 -0
  26. package/examples/comfy-cloud/ltx25-t2v.cflow.ts +126 -0
  27. package/examples/comfy-cloud/minimax-music3-t2a.cflow.ts +95 -0
  28. package/examples/comfy-cloud/sdk.d.ts +30724 -24404
  29. package/examples/comfy-cloud/wan22-5b-t2v.cflow.ts +2 -0
  30. package/examples/comfy-cloud/wan22-i2v.cflow.ts +2 -0
  31. package/examples/comfy-cloud/wan22-t2v.cflow.ts +2 -0
  32. package/examples/rvion/07-local-llm-text-gen.cflow.ts +2 -2
  33. package/examples/rvion/08-qwen-image-21-t2i.cflow.ts +64 -0
  34. package/examples/rvion/09-qwen-image-21-edit.cflow.ts +83 -0
  35. package/package.json +4 -2
  36. package/src/cli/serve/ServeApp.ts +94 -0
  37. package/src/cli/serve/describeVar.ts +7 -0
  38. package/src/cli/serve/favicon.ts +3 -0
  39. package/src/cli/serve/web/api.ts +12 -0
  40. package/src/cli/serve/web/components/VarsForm.tsx +18 -7
  41. package/src/cli/serve/web/components/controls/LorasControl.tsx +102 -6
  42. package/src/cli/serve/web/state/WebSt.ts +79 -0
  43. package/src/cli/serve/web/state/loraSort.ts +39 -0
  44. package/src/cli/serve/web/styles.ts +15 -0
  45. package/src/cli/tui/components/Header.tsx +2 -0
  46. package/src/cli/tui/state/HostSt.ts +34 -0
  47. package/src/graph/ComfyNode.ts +19 -3
  48. package/src/host/ComfyHost.ts +15 -0
  49. package/src/host/loraInfoCache.ts +64 -0
  50. package/src/host/loraManagerApi.ts +27 -0
  51. package/src/host/schemaDrift.ts +87 -0
  52. package/dist/DefinedWorkflow-BatWaZO1.js.map +0 -1
  53. package/dist/run-serve-_nrvJYyt.js.map +0 -1
  54. package/dist/run-tui-BLEdTsOX.js.map +0 -1
  55. package/dist/state-BbgJeCe6.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -16430,6 +16430,19 @@ declare class DefinedWorkflow<ID extends string = string, V extends VarsSpec = V
16430
16430
  }): Promise<ComfyExecution>;
16431
16431
  }
16432
16432
  //#endregion
16433
+ //#region src/host/schemaDrift.d.ts
16434
+ type Delta = {
16435
+ added: string[];
16436
+ removed: string[];
16437
+ };
16438
+ type SchemaDrift = {
16439
+ /** null on a light check: node types are only compared by a full one */
16440
+ nodes: Delta | null;
16441
+ models: ({
16442
+ noun: string;
16443
+ } & Delta)[];
16444
+ };
16445
+ //#endregion
16433
16446
  //#region src/host/ComfyHost.d.ts
16434
16447
  type ComfyHostID = Tagged<string, {
16435
16448
  HostID: true;
@@ -16643,6 +16656,12 @@ declare class ComfyHost<ID extends string = string> {
16643
16656
  enabled: boolean;
16644
16657
  clientId: string;
16645
16658
  }) => Promise<void>;
16659
+ /** what changed on the host since this schema was loaded (src/host/schemaDrift.ts). `full: false`
16660
+ * asks only the loaders the schema has, a few KB, so it can run on a timer. Throws when the host
16661
+ * cannot be reached, which is itself the signal a caller watches for a restart */
16662
+ checkSchemaDrift: (p: {
16663
+ full: boolean;
16664
+ }) => Promise<SchemaDrift>;
16646
16665
  /** GET a JSON route through host.fetch (/api preferred, bare fallback) */
16647
16666
  private fetchJSON_;
16648
16667
  /** retrieve the comfy spec from the schema*/
package/dist/index.d.ts CHANGED
@@ -16430,6 +16430,19 @@ declare class DefinedWorkflow<ID extends string = string, V extends VarsSpec = V
16430
16430
  }): Promise<ComfyExecution>;
16431
16431
  }
16432
16432
  //#endregion
16433
+ //#region src/host/schemaDrift.d.ts
16434
+ type Delta = {
16435
+ added: string[];
16436
+ removed: string[];
16437
+ };
16438
+ type SchemaDrift = {
16439
+ /** null on a light check: node types are only compared by a full one */
16440
+ nodes: Delta | null;
16441
+ models: ({
16442
+ noun: string;
16443
+ } & Delta)[];
16444
+ };
16445
+ //#endregion
16433
16446
  //#region src/host/ComfyHost.d.ts
16434
16447
  type ComfyHostID = Tagged<string, {
16435
16448
  HostID: true;
@@ -16643,6 +16656,12 @@ declare class ComfyHost<ID extends string = string> {
16643
16656
  enabled: boolean;
16644
16657
  clientId: string;
16645
16658
  }) => Promise<void>;
16659
+ /** what changed on the host since this schema was loaded (src/host/schemaDrift.ts). `full: false`
16660
+ * asks only the loaders the schema has, a few KB, so it can run on a timer. Throws when the host
16661
+ * cannot be reached, which is itself the signal a caller watches for a restart */
16662
+ checkSchemaDrift: (p: {
16663
+ full: boolean;
16664
+ }) => Promise<SchemaDrift>;
16646
16665
  /** GET a JSON route through host.fetch (/api preferred, bare fallback) */
16647
16666
  private fetchJSON_;
16648
16667
  /** retrieve the comfy spec from the schema*/
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.9.0";
113
+ var version = "2.11.0";
114
114
  //#endregion
115
115
  //#region src/litegraph/LiteGraphLinkID.ts
116
116
  const asLiteGraphLinkID = (id) => id;
@@ -1587,8 +1587,15 @@ var ComfyNode = class ComfyNode {
1587
1587
  }
1588
1588
  _getExpectedTypeForField(name) {
1589
1589
  const input = this.$schema.inputs.find((i) => i.nameInComfy === name);
1590
- if (input == null) throw new Error("🔴 input not found asdf");
1591
- return input.typeName;
1590
+ if (input != null) return input.typeName;
1591
+ const dot = name.indexOf(".");
1592
+ const decl = dot > 0 ? this.$schema.inputs.find((i) => i.nameInComfy === name.slice(0, dot)) : void 0;
1593
+ if (decl != null) {
1594
+ const kind = classifySchemaInput(decl);
1595
+ const slotType = containerInstanceSlotType(decl.opts);
1596
+ if (kind.kind === "dynamic-container" && kind.instanceNames.includes(name.slice(dot + 1)) && slotType != null) return slotType;
1597
+ }
1598
+ throw new Error(`🔴 no input "${name}" on ${this.$schema.nodeKey}: cannot tell which output of the linked node to use`);
1592
1599
  }
1593
1600
  _getOutputForTypeOrCrash(type) {
1594
1601
  const i = this.$schema.outputs.find((i) => i.typeName === type);
@@ -5002,6 +5009,87 @@ var DefinedWorkflow = class {
5002
5009
  }
5003
5010
  };
5004
5011
  //#endregion
5012
+ //#region src/host/schemaDrift.ts
5013
+ /**
5014
+ * what changed on a host since a schema was loaded: node types, and the model files each loader
5015
+ * lists. ComfyUI exposes no boot time, so staleness is decided by CONTENT: a restart that changed
5016
+ * nothing stays quiet, a new lora shows even when nobody knows when the box rebooted.
5017
+ * A light check asks only the loaders (`/object_info/<node>`, a few KB); a full one compares every
5018
+ * node type (`/object_info`, megabytes).
5019
+ */
5020
+ /** the loader inputs whose combo IS a model folder listing */
5021
+ const MODEL_LISTS = [
5022
+ {
5023
+ noun: "lora",
5024
+ node: "LoraLoader",
5025
+ input: "lora_name"
5026
+ },
5027
+ {
5028
+ noun: "checkpoint",
5029
+ node: "CheckpointLoaderSimple",
5030
+ input: "ckpt_name"
5031
+ },
5032
+ {
5033
+ noun: "unet",
5034
+ node: "UNETLoader",
5035
+ input: "unet_name"
5036
+ },
5037
+ {
5038
+ noun: "text encoder",
5039
+ node: "CLIPLoader",
5040
+ input: "clip_name"
5041
+ },
5042
+ {
5043
+ noun: "vae",
5044
+ node: "VAELoader",
5045
+ input: "vae_name"
5046
+ }
5047
+ ];
5048
+ /** a combo's options in both object_info spellings: `[[...options]]` and `['COMBO', { options }]` */
5049
+ function comboOptions(spec, node, input) {
5050
+ const def = spec[node];
5051
+ if (!isRecord(def) || !isRecord(def["input"])) return null;
5052
+ const sections = def["input"];
5053
+ for (const section of ["required", "optional"]) {
5054
+ const sec = sections[section];
5055
+ if (!isRecord(sec)) continue;
5056
+ const slot = sec[input];
5057
+ if (!Array.isArray(slot)) continue;
5058
+ const first = slot[0];
5059
+ if (Array.isArray(first)) return first.filter((x) => typeof x === "string");
5060
+ const opts = slot[1];
5061
+ if (first === "COMBO" && isRecord(opts) && Array.isArray(opts["options"])) return opts["options"].filter((x) => typeof x === "string");
5062
+ }
5063
+ return null;
5064
+ }
5065
+ function delta(before, after) {
5066
+ const was = new Set(before);
5067
+ const now = new Set(after);
5068
+ return {
5069
+ added: after.filter((x) => !was.has(x)),
5070
+ removed: before.filter((x) => !now.has(x))
5071
+ };
5072
+ }
5073
+ /** `live` may be PARTIAL (a light check holds only the loaders): a list is compared only where both
5074
+ * sides have the loader, and node types only when `full` */
5075
+ function diffSchemas(p) {
5076
+ const models = [];
5077
+ for (const m of MODEL_LISTS) {
5078
+ const before = comboOptions(p.loaded, m.node, m.input);
5079
+ const after = comboOptions(p.live, m.node, m.input);
5080
+ if (before == null || after == null) continue;
5081
+ const d = delta(before, after);
5082
+ if (d.added.length > 0 || d.removed.length > 0) models.push({
5083
+ noun: m.noun,
5084
+ ...d
5085
+ });
5086
+ }
5087
+ return {
5088
+ nodes: p.full ? delta(Object.keys(p.loaded), Object.keys(p.live)) : null,
5089
+ models
5090
+ };
5091
+ }
5092
+ //#endregion
5005
5093
  //#region src/host/ComfyHost.ts
5006
5094
  /** the host never came up within ConnectOptions.timeoutMs */
5007
5095
  var ComfyHostUnreachableError = class extends Error {
@@ -5227,6 +5315,17 @@ var ComfyHost = class {
5227
5315
  }, { apiPrefix: false });
5228
5316
  if (!res.ok) throw new Error(`PATCH /internal/logs/subscribe failed: ${res.status}`);
5229
5317
  };
5318
+ this.checkSchemaDrift = async (p) => {
5319
+ const loaded = this.schema.data.spec;
5320
+ const live = {};
5321
+ if (p.full) Object.assign(live, await this.fetchJSON_("/object_info"));
5322
+ else for (const m of MODEL_LISTS) if (loaded[m.node] != null) Object.assign(live, await this.fetchJSON_(`/object_info/${m.node}`));
5323
+ return diffSchemas({
5324
+ loaded,
5325
+ live,
5326
+ full: p.full
5327
+ });
5328
+ };
5230
5329
  this.fetchJSON_ = async (route) => {
5231
5330
  const base = this.getServerHostHTTP();
5232
5331
  const res = await this.fetch(route);