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/web.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/web.js CHANGED
@@ -101,7 +101,7 @@ function getComfyStorage() {
101
101
  }
102
102
  //#endregion
103
103
  //#region package.json
104
- var version = "2.9.0";
104
+ var version = "2.11.0";
105
105
  //#endregion
106
106
  //#region src/litegraph/LiteGraphLinkID.ts
107
107
  const asLiteGraphLinkID = (id) => id;
@@ -1578,8 +1578,15 @@ var ComfyNode = class ComfyNode {
1578
1578
  }
1579
1579
  _getExpectedTypeForField(name) {
1580
1580
  const input = this.$schema.inputs.find((i) => i.nameInComfy === name);
1581
- if (input == null) throw new Error("🔴 input not found asdf");
1582
- return input.typeName;
1581
+ if (input != null) return input.typeName;
1582
+ const dot = name.indexOf(".");
1583
+ const decl = dot > 0 ? this.$schema.inputs.find((i) => i.nameInComfy === name.slice(0, dot)) : void 0;
1584
+ if (decl != null) {
1585
+ const kind = classifySchemaInput(decl);
1586
+ const slotType = containerInstanceSlotType(decl.opts);
1587
+ if (kind.kind === "dynamic-container" && kind.instanceNames.includes(name.slice(dot + 1)) && slotType != null) return slotType;
1588
+ }
1589
+ throw new Error(`🔴 no input "${name}" on ${this.$schema.nodeKey}: cannot tell which output of the linked node to use`);
1583
1590
  }
1584
1591
  _getOutputForTypeOrCrash(type) {
1585
1592
  const i = this.$schema.outputs.find((i) => i.typeName === type);
@@ -4993,6 +5000,87 @@ var DefinedWorkflow = class {
4993
5000
  }
4994
5001
  };
4995
5002
  //#endregion
5003
+ //#region src/host/schemaDrift.ts
5004
+ /**
5005
+ * what changed on a host since a schema was loaded: node types, and the model files each loader
5006
+ * lists. ComfyUI exposes no boot time, so staleness is decided by CONTENT: a restart that changed
5007
+ * nothing stays quiet, a new lora shows even when nobody knows when the box rebooted.
5008
+ * A light check asks only the loaders (`/object_info/<node>`, a few KB); a full one compares every
5009
+ * node type (`/object_info`, megabytes).
5010
+ */
5011
+ /** the loader inputs whose combo IS a model folder listing */
5012
+ const MODEL_LISTS = [
5013
+ {
5014
+ noun: "lora",
5015
+ node: "LoraLoader",
5016
+ input: "lora_name"
5017
+ },
5018
+ {
5019
+ noun: "checkpoint",
5020
+ node: "CheckpointLoaderSimple",
5021
+ input: "ckpt_name"
5022
+ },
5023
+ {
5024
+ noun: "unet",
5025
+ node: "UNETLoader",
5026
+ input: "unet_name"
5027
+ },
5028
+ {
5029
+ noun: "text encoder",
5030
+ node: "CLIPLoader",
5031
+ input: "clip_name"
5032
+ },
5033
+ {
5034
+ noun: "vae",
5035
+ node: "VAELoader",
5036
+ input: "vae_name"
5037
+ }
5038
+ ];
5039
+ /** a combo's options in both object_info spellings: `[[...options]]` and `['COMBO', { options }]` */
5040
+ function comboOptions(spec, node, input) {
5041
+ const def = spec[node];
5042
+ if (!isRecord(def) || !isRecord(def["input"])) return null;
5043
+ const sections = def["input"];
5044
+ for (const section of ["required", "optional"]) {
5045
+ const sec = sections[section];
5046
+ if (!isRecord(sec)) continue;
5047
+ const slot = sec[input];
5048
+ if (!Array.isArray(slot)) continue;
5049
+ const first = slot[0];
5050
+ if (Array.isArray(first)) return first.filter((x) => typeof x === "string");
5051
+ const opts = slot[1];
5052
+ if (first === "COMBO" && isRecord(opts) && Array.isArray(opts["options"])) return opts["options"].filter((x) => typeof x === "string");
5053
+ }
5054
+ return null;
5055
+ }
5056
+ function delta(before, after) {
5057
+ const was = new Set(before);
5058
+ const now = new Set(after);
5059
+ return {
5060
+ added: after.filter((x) => !was.has(x)),
5061
+ removed: before.filter((x) => !now.has(x))
5062
+ };
5063
+ }
5064
+ /** `live` may be PARTIAL (a light check holds only the loaders): a list is compared only where both
5065
+ * sides have the loader, and node types only when `full` */
5066
+ function diffSchemas(p) {
5067
+ const models = [];
5068
+ for (const m of MODEL_LISTS) {
5069
+ const before = comboOptions(p.loaded, m.node, m.input);
5070
+ const after = comboOptions(p.live, m.node, m.input);
5071
+ if (before == null || after == null) continue;
5072
+ const d = delta(before, after);
5073
+ if (d.added.length > 0 || d.removed.length > 0) models.push({
5074
+ noun: m.noun,
5075
+ ...d
5076
+ });
5077
+ }
5078
+ return {
5079
+ nodes: p.full ? delta(Object.keys(p.loaded), Object.keys(p.live)) : null,
5080
+ models
5081
+ };
5082
+ }
5083
+ //#endregion
4996
5084
  //#region src/host/ComfyHost.ts
4997
5085
  /** the host never came up within ConnectOptions.timeoutMs */
4998
5086
  var ComfyHostUnreachableError = class extends Error {
@@ -5218,6 +5306,17 @@ var ComfyHost = class {
5218
5306
  }, { apiPrefix: false });
5219
5307
  if (!res.ok) throw new Error(`PATCH /internal/logs/subscribe failed: ${res.status}`);
5220
5308
  };
5309
+ this.checkSchemaDrift = async (p) => {
5310
+ const loaded = this.schema.data.spec;
5311
+ const live = {};
5312
+ if (p.full) Object.assign(live, await this.fetchJSON_("/object_info"));
5313
+ else for (const m of MODEL_LISTS) if (loaded[m.node] != null) Object.assign(live, await this.fetchJSON_(`/object_info/${m.node}`));
5314
+ return diffSchemas({
5315
+ loaded,
5316
+ live,
5317
+ full: p.full
5318
+ });
5319
+ };
5221
5320
  this.fetchJSON_ = async (route) => {
5222
5321
  const base = this.getServerHostHTTP();
5223
5322
  const res = await this.fetch(route);