comfy-ts 1.0.0 → 1.1.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 (124) hide show
  1. package/README.md +42 -6
  2. package/dist/{DefinedWorkflow-O3ynII3Y.js → DefinedWorkflow-BYyu5dK9.js} +76 -5
  3. package/dist/DefinedWorkflow-BYyu5dK9.js.map +1 -0
  4. package/dist/cli.js +421 -308
  5. package/dist/cli.js.map +1 -1
  6. package/dist/index.cjs +394 -162
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +7426 -353
  9. package/dist/index.d.ts +7408 -335
  10. package/dist/index.js +393 -162
  11. package/dist/index.js.map +1 -1
  12. package/dist/{run-tui-BFhba_oG.js → run-tui-DZ22HDHI.js} +529 -78
  13. package/dist/run-tui-DZ22HDHI.js.map +1 -0
  14. package/examples/02-img2img-upload.cflow.ts +6 -17
  15. package/examples/05-comfy-cloud.cflow.ts +19 -35
  16. package/examples/README.md +30 -0
  17. package/examples/comfy-cloud/ace-step-t2a.cflow.ts +79 -0
  18. package/examples/comfy-cloud/anima-t2i.cflow.ts +57 -0
  19. package/examples/comfy-cloud/boogu-i2i.cflow.ts +76 -0
  20. package/examples/comfy-cloud/capybara-i2i.cflow.ts +85 -0
  21. package/examples/comfy-cloud/capybara-i2v.cflow.ts +90 -0
  22. package/examples/comfy-cloud/capybara-t2i.cflow.ts +67 -0
  23. package/examples/comfy-cloud/chatterbox-t2a.cflow.ts +79 -0
  24. package/examples/comfy-cloud/chroma-t2i.cflow.ts +62 -0
  25. package/examples/comfy-cloud/cloudHost.ts +41 -0
  26. package/examples/comfy-cloud/ernie-t2i.cflow.ts +59 -0
  27. package/examples/comfy-cloud/firered-i2i.cflow.ts +74 -0
  28. package/examples/comfy-cloud/flux1-i2i.cflow.ts +76 -0
  29. package/examples/comfy-cloud/flux1-t2i.cflow.ts +63 -0
  30. package/examples/comfy-cloud/flux2-i2i.cflow.ts +80 -0
  31. package/examples/comfy-cloud/flux2-t2i.cflow.ts +57 -0
  32. package/examples/comfy-cloud/hidream-i2i.cflow.ts +89 -0
  33. package/examples/comfy-cloud/hidream-t2i.cflow.ts +65 -0
  34. package/examples/comfy-cloud/hunyuan-video-i2v.cflow.ts +93 -0
  35. package/examples/comfy-cloud/hunyuan-video-t2v.cflow.ts +74 -0
  36. package/examples/comfy-cloud/ideogram4-t2i.cflow.ts +80 -0
  37. package/examples/comfy-cloud/kandinsky5-i2v.cflow.ts +95 -0
  38. package/examples/comfy-cloud/kandinsky5-t2i.cflow.ts +60 -0
  39. package/examples/comfy-cloud/kandinsky5-t2v.cflow.ts +78 -0
  40. package/examples/comfy-cloud/krea2-t2i.cflow.ts +59 -0
  41. package/examples/comfy-cloud/lens-t2i.cflow.ts +62 -0
  42. package/examples/comfy-cloud/longcat-i2i.cflow.ts +74 -0
  43. package/examples/comfy-cloud/longcat-t2i.cflow.ts +65 -0
  44. package/examples/comfy-cloud/ltxv-i2v.cflow.ts +92 -0
  45. package/examples/comfy-cloud/ltxv-t2v.cflow.ts +78 -0
  46. package/examples/comfy-cloud/newbie-t2i.cflow.ts +67 -0
  47. package/examples/comfy-cloud/omnigen2-i2i.cflow.ts +86 -0
  48. package/examples/comfy-cloud/omnigen2-t2i.cflow.ts +62 -0
  49. package/examples/comfy-cloud/ovis-t2i.cflow.ts +56 -0
  50. package/examples/comfy-cloud/pixeldit-t2i.cflow.ts +63 -0
  51. package/examples/comfy-cloud/qwen-image-i2i.cflow.ts +69 -0
  52. package/examples/comfy-cloud/qwen-image-t2i.cflow.ts +55 -0
  53. package/examples/comfy-cloud/sd35-t2i.cflow.ts +48 -0
  54. package/examples/comfy-cloud/sdk.d.ts +445 -57
  55. package/examples/comfy-cloud/sdxl-t2i.cflow.ts +69 -0
  56. package/examples/comfy-cloud/stable-audio-t2a.cflow.ts +53 -0
  57. package/examples/comfy-cloud/svd-i2v.cflow.ts +75 -0
  58. package/examples/comfy-cloud/wan21-i2v.cflow.ts +83 -0
  59. package/examples/comfy-cloud/wan21-t2v.cflow.ts +64 -0
  60. package/examples/comfy-cloud/wan22-5b-t2v.cflow.ts +69 -0
  61. package/examples/comfy-cloud/wan22-i2v.cflow.ts +107 -0
  62. package/examples/comfy-cloud/wan22-t2v.cflow.ts +98 -0
  63. package/examples/comfy-cloud/z-image-t2i.cflow.ts +62 -0
  64. package/examples/images/README.md +18 -0
  65. package/examples/images/bear_1024x1024.jpg +0 -0
  66. package/examples/images/deer_768x1344.jpg +0 -0
  67. package/examples/images/dog_512x512.jpg +0 -0
  68. package/examples/images/lioness_768x768.jpg +0 -0
  69. package/examples/images/pug_200x300.jpg +0 -0
  70. package/examples/images/walrus_1344x768.jpg +0 -0
  71. package/guide-for-agents.md +7 -1
  72. package/package.json +15 -4
  73. package/src/cli/tui/components/PreviewPanel.tsx +9 -8
  74. package/src/cli/tui/components/StatusBar.tsx +11 -0
  75. package/src/cli/tui/components/TuiApp.tsx +18 -0
  76. package/src/cli/tui/discoverWorkflows.ts +7 -41
  77. package/src/cli/tui/imagePicker/ImagePickerOverlay.tsx +72 -0
  78. package/src/cli/tui/imagePicker/ImagePickerSt.ts +288 -0
  79. package/src/cli/tui/imagePicker/fsListing.ts +46 -0
  80. package/src/cli/tui/imagePicker/pickerPrefs.ts +78 -0
  81. package/src/cli/tui/run-tui.tsx +2 -1
  82. package/src/cli/tui/state/LorasSt.ts +14 -36
  83. package/src/cli/tui/state/PreviewSt.ts +28 -2
  84. package/src/cli/tui/state/TuiSt.ts +6 -0
  85. package/src/exampleAssets.ts +56 -0
  86. package/src/graph/ComfyNode.ts +4 -1
  87. package/src/index.ts +7 -0
  88. package/src/manager/ComfyRegistry.ts +37 -9
  89. package/src/manager/generated/KnownComfyCustomNodeName.ts +23852 -1926
  90. package/src/manager/generated/KnownComfyPluginTitle.ts +6854 -236
  91. package/src/manager/generated/KnownComfyPluginURL.ts +3425 -111
  92. package/src/manager/generated/KnownModel_Base.ts +23 -7
  93. package/src/manager/generated/KnownModel_FileName.ts +421 -0
  94. package/src/manager/generated/KnownModel_Name.ts +421 -0
  95. package/src/manager/generated/KnownModel_SavePath.ts +34 -8
  96. package/src/manager/generated/KnownModel_Type.ts +18 -14
  97. package/src/manager/json/alter-list.json +221 -221
  98. package/src/manager/json/custom-node-list.json +61020 -21946
  99. package/src/manager/json/extension-node-map.json +81077 -31176
  100. package/src/manager/json/github-stats.json +29321 -12601
  101. package/src/manager/json/model-list.json +5935 -4997
  102. package/src/manager/loaders/parseReport.ts +55 -0
  103. package/src/manager/loaders/step1_downloadComfyManagerJSONs.ts +15 -49
  104. package/src/manager/loaders/step2_custom-node-list-loader.ts +38 -83
  105. package/src/manager/loaders/step3_extension-node-map-loader.ts +36 -142
  106. package/src/manager/loaders/step4_model-list-loader.ts +25 -36
  107. package/src/manager/loaders/step5_alter-list-loader.ts +29 -0
  108. package/src/manager/loaders/step6_github-stats-loader.ts +23 -0
  109. package/src/manager/script-update-manager.bun.ts +9 -1
  110. package/src/manager/types/ComfyManagerAlterInfo.ts +13 -0
  111. package/src/manager/types/ComfyManagerFileModelInfo.ts +7 -3
  112. package/src/manager/types/ComfyManagerFilePluginContent.ts +6 -9
  113. package/src/manager/types/ComfyManagerFilePluginList.ts +3 -3
  114. package/src/manager/types/ComfyManagerGithubStats.ts +9 -0
  115. package/src/manager/types/ComfyManagerPluginContentMetadata.ts +2 -3
  116. package/src/manager/types/ComfyManagerPluginInfo.ts +48 -34
  117. package/src/sdk-generator/ComfySchema.ts +14 -1
  118. package/src/sdk-generator/comfyui-sdk-codegen.ts +15 -0
  119. package/src/sdk-generator/inputWidgetKind.ts +17 -0
  120. package/src/vars/ComfyVars.ts +82 -2
  121. package/src/vars/DefinedWorkflow.ts +7 -2
  122. package/dist/DefinedWorkflow-O3ynII3Y.js.map +0 -1
  123. package/dist/run-tui-BFhba_oG.js.map +0 -1
  124. package/src/utils/tryExtracting.ts +0 -41
package/dist/index.cjs CHANGED
@@ -33,13 +33,14 @@ let node_crypto = require("node:crypto");
33
33
  node_crypto = __toESM(node_crypto, 1);
34
34
  let ws = require("ws");
35
35
  ws = __toESM(ws, 1);
36
+ let node_os = require("node:os");
36
37
  let mobx = require("mobx");
37
38
  let node_https = require("node:https");
38
39
  node_https = __toESM(node_https, 1);
39
40
  let node_process = require("node:process");
40
- let fs = require("fs");
41
+ let node_url = require("node:url");
41
42
  //#region package.json
42
- var version = "1.0.0";
43
+ var version = "1.1.0";
43
44
  //#endregion
44
45
  //#region src/litegraph/LiteGraphLinkID.ts
45
46
  const asLiteGraphLinkID = (id) => id;
@@ -738,6 +739,21 @@ const parseContainer = (template) => {
738
739
  requiredCount: isRecord(input) && isRecord(input["required"]) && Object.keys(input["required"]).length > 0 ? Math.min(min, names.length) : 0
739
740
  };
740
741
  };
742
+ /**
743
+ * the single template sub-input's slot type of an autogrow container
744
+ * (`'IMAGE'` for TextEncodeBooguEdit.images). null when opts are not an
745
+ * autogrow template or the template has several sub-inputs (corpus-absent
746
+ * 2026-07-30, 27/27 single on the cloud catalog) — then codegen emits no
747
+ * typed instance keys and the container stays builderBase territory.
748
+ */
749
+ const containerInstanceSlotType = (opts) => {
750
+ const template = (isRecord(opts) ? opts : null)?.["template"];
751
+ if (!isRecord(template) || !isRecord(template["input"])) return null;
752
+ const subs = flattenInputSections(template["input"]);
753
+ const first = subs[0];
754
+ if (subs.length !== 1 || first == null || typeof first.type !== "string") return null;
755
+ return first.type;
756
+ };
741
757
  const classifyWidgetInput = (p) => {
742
758
  const o = isRecord(p.opts) ? p.opts : null;
743
759
  if (o?.["forceInput"] === true) return { kind: "slot" };
@@ -1250,7 +1266,7 @@ var ComfyNode = class ComfyNode {
1250
1266
  for (const i of this.$schema.inputs) {
1251
1267
  _done.add(i.nameInComfy);
1252
1268
  const value = this.serializeValue(i.nameInComfy, promptExt.inputs[i.nameInComfy]);
1253
- inputs[i.nameInComfy] = value;
1269
+ if (value !== void 0) inputs[i.nameInComfy] = value;
1254
1270
  }
1255
1271
  for (const [nameInComfy, rawVal] of Object.entries(promptExt.inputs)) {
1256
1272
  if (_done.has(nameInComfy)) continue;
@@ -2627,6 +2643,15 @@ function codegenSDK(opts) {
2627
2643
  for (const n of nodes) {
2628
2644
  p(`${escapeJSKey(n.nodeKey)}: {`);
2629
2645
  for (const i of n.inputs) {
2646
+ const kind = classifySchemaInput(i);
2647
+ if (kind.kind === "dynamic-container") {
2648
+ const instType = containerInstanceSlotType(i.opts);
2649
+ if (instType != null) kind.instanceNames.forEach((instName, ix) => {
2650
+ const opt = ix >= kind.requiredCount ? "?" : "";
2651
+ p(` ${escapeJSKey(`${i.nameInComfy}.${instName}`)}${opt}: Accepts[${JSON.stringify(instType)}]`);
2652
+ });
2653
+ continue;
2654
+ }
2630
2655
  const opts_ = typeof i.opts === "string" ? null : i.opts;
2631
2656
  let type = `Accepts[${JSON.stringify(i.typeName)}]`;
2632
2657
  const comboOptions = i.typeName === "COMBO" && Array.isArray(opts_?.options) ? opts_.options.filter((o) => typeof o === "string" || typeof o === "number" || typeof o === "boolean") : [];
@@ -2946,9 +2971,18 @@ var ComfySchema = class {
2946
2971
  comfyUnionDef: slotType
2947
2972
  }).unionName);
2948
2973
  else throw new Error(`invalid schema (${JSON.stringify(slotType)}) for input "${ipt.name}" in node "${nodeNameInComfy}" (type: ${typeof slotType}; expected: Array | string)`);
2974
+ const isAutogrowContainer = typeof slotType === "string" && classifyWidgetInput({
2975
+ name: ipt.name,
2976
+ type: slotType,
2977
+ opts: slotOpts
2978
+ }).kind === "dynamic-container";
2979
+ if (isAutogrowContainer) {
2980
+ const instType = containerInstanceSlotType(slotOpts);
2981
+ if (instType != null) this.knownSlotTypes.add(asComfyNodeSlotTypeName(instType));
2982
+ }
2949
2983
  node.inputs.push({
2950
2984
  slotName: inputSlotName,
2951
- required: ipt.required,
2985
+ required: ipt.required && !isAutogrowContainer,
2952
2986
  nameInComfy: inputNameInComfy,
2953
2987
  nameInComfyEscaped: escapeJSKey(inputNameInComfy),
2954
2988
  typeName: inputTypeName,
@@ -3948,7 +3982,73 @@ var SizeVar = class extends ComfyVar {
3948
3982
  return `${width}×${height}${hit ? ` (${hit.label})` : ""}`;
3949
3983
  }
3950
3984
  };
3951
- /** the var constructors: v.text / v.prompt / v.int / v.float / v.seed / v.toggle / v.choice / v.loras / v.size */
3985
+ const DEFAULT_IMAGE_EXTENSIONS = [
3986
+ "png",
3987
+ "jpg",
3988
+ "jpeg",
3989
+ "webp",
3990
+ "gif"
3991
+ ];
3992
+ /** empty image var consumed at build time — typed so drivers surface it apart from real crashes */
3993
+ var ImageVarEmptyError = class extends Error {
3994
+ constructor(varName) {
3995
+ super(`image var '${varName}' is empty — pick a file (TUI: activate the var; script: .set('/path/to/image.png'))`);
3996
+ this.varName = varName;
3997
+ }
3998
+ };
3999
+ /** trim + expand a leading `~/` — every ImageVar write funnels through this */
4000
+ function expandUserPath(raw) {
4001
+ const trimmed = raw.trim();
4002
+ return trimmed.startsWith("~/") ? (0, pathe.join)((0, node_os.homedir)(), trimmed.slice(2)) : trimmed;
4003
+ }
4004
+ /**
4005
+ * a local image path. The VALUE is a PLAIN PATH STRING — text-encodable,
4006
+ * drafts persist it verbatim (toJSON = the string), hand-editable in the
4007
+ * draft json. Empty = unset: outValue()/absPath() throw ImageVarEmptyError,
4008
+ * so a build never runs on a silent placeholder. The TUI opens the image
4009
+ * picker overlay for kind 'image'.
4010
+ */
4011
+ var ImageVar = class extends ComfyVar {
4012
+ constructor(defaultValue, opts = {}) {
4013
+ super(expandUserPath(defaultValue), opts.label);
4014
+ this.opts = opts;
4015
+ this.kind = "image";
4016
+ }
4017
+ /** what the picker lists (lowercase, no dots) */
4018
+ get extensions() {
4019
+ return this.opts.extensions ?? DEFAULT_IMAGE_EXTENSIONS;
4020
+ }
4021
+ set(value) {
4022
+ return super.set(expandUserPath(value));
4023
+ }
4024
+ parse(raw) {
4025
+ this.set(raw);
4026
+ return true;
4027
+ }
4028
+ isSet() {
4029
+ return this.value !== "";
4030
+ }
4031
+ emptyError() {
4032
+ return new ImageVarEmptyError(this.name ?? this.label ?? "image");
4033
+ }
4034
+ /** the ONE resolution helper: absolute kept as-is, relative resolved against opts.folder, else cwd */
4035
+ absPath() {
4036
+ if (!this.isSet()) throw this.emptyError();
4037
+ if ((0, pathe.isAbsolute)(this.value)) return this.value;
4038
+ return (0, pathe.resolve)(this.opts.folder ?? process.cwd(), this.value);
4039
+ }
4040
+ /** empty = unset: the build fails LOUD here (varValues calls outValue) */
4041
+ outValue() {
4042
+ if (!this.isSet()) throw this.emptyError();
4043
+ return this.value;
4044
+ }
4045
+ display() {
4046
+ if (!this.isSet()) return "(unset) pick a file";
4047
+ const home = (0, node_os.homedir)();
4048
+ return this.value.startsWith(`${home}/`) ? `~${this.value.slice(home.length)}` : this.value;
4049
+ }
4050
+ };
4051
+ /** the var constructors: v.text / v.prompt / v.int / v.float / v.seed / v.toggle / v.choice / v.loras / v.size / v.image */
3952
4052
  const v = {
3953
4053
  text: (defaultValue, label) => new TextVar(defaultValue, label),
3954
4054
  prompt: (defaultValue, opts = {}) => new PromptVar(defaultValue, opts),
@@ -3958,7 +4058,8 @@ const v = {
3958
4058
  toggle: (defaultValue, label) => new ToggleVar(defaultValue, label),
3959
4059
  choice: (choices, defaultValue, label) => new ChoiceVar(choices, defaultValue, label),
3960
4060
  loras: (options, initial = {}, label) => new LorasVar(options, initial, label),
3961
- size: (defaultValue, opts = {}) => new SizeVar(defaultValue, opts.presets, opts.label)
4061
+ size: (defaultValue, opts = {}) => new SizeVar(defaultValue, opts.presets, opts.label),
4062
+ image: (defaultValue, opts = {}) => new ImageVar(defaultValue, opts)
3962
4063
  };
3963
4064
  function varValues(vars) {
3964
4065
  const out = {};
@@ -3982,7 +4083,10 @@ var DefinedWorkflow = class {
3982
4083
  this.lastWorkflow = null;
3983
4084
  this.lastExecution = null;
3984
4085
  this.vars = isVarsThunk(spec.vars) ? spec.vars(v) : spec.vars;
3985
- for (const [, varDef] of this.entries()) varDef.bindHost?.(this.host);
4086
+ for (const [key, varDef] of this.entries()) {
4087
+ varDef.name = key;
4088
+ varDef.bindHost?.(this.host);
4089
+ }
3986
4090
  }
3987
4091
  /** [name, var] pairs, for drivers that enumerate the knobs */
3988
4092
  entries() {
@@ -4540,31 +4644,19 @@ function downloadFile(url, outputPath, logPrefix = " - ") {
4540
4644
  }
4541
4645
  //#endregion
4542
4646
  //#region src/manager/loaders/step1_downloadComfyManagerJSONs.ts
4647
+ const MANAGER_RAW_BASE = "https://raw.githubusercontent.com/Comfy-Org/ComfyUI-Manager/main";
4648
+ const MANAGER_MIRROR_FILES = [
4649
+ "custom-node-list.json",
4650
+ "model-list.json",
4651
+ "extension-node-map.json",
4652
+ "alter-list.json",
4653
+ "github-stats.json"
4654
+ ];
4543
4655
  async function DownloadComfyManagerJSONs() {
4544
- await SYNC_modelList();
4545
- await SYNC_customNodeList();
4546
- await SYNC_extensionNodeMap();
4547
- await SYNC_alterList();
4548
- await SYNC_githubStats();
4549
- async function SYNC_modelList() {
4550
- await downloadFile("https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/model-list.json", "src/manager/json/model-list.json", `- downloading ynchronizing model-list.json...`);
4551
- console.log(` saved at ${ansi.blue("src/manager/json/model-list.json")}`);
4552
- }
4553
- async function SYNC_customNodeList() {
4554
- await downloadFile("https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json", "src/manager/json/custom-node-list.json", `- downloading synchronizing custom-node-list.json...`);
4555
- console.log(` saved at ${ansi.blue("src/manager/json/custom-node-list.json")}`);
4556
- }
4557
- async function SYNC_extensionNodeMap() {
4558
- await downloadFile("https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/extension-node-map.json", "src/manager/json/extension-node-map.json", `- downloading synchronizing extension-node-map.json...`);
4559
- console.log(` saved at ${ansi.blue("src/manager/json/extension-node-map.json")}`);
4560
- }
4561
- async function SYNC_alterList() {
4562
- await downloadFile("https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/alter-list.json", "src/manager/json/alter-list.json", `- downloading synchronizing alter-list.json...`);
4563
- console.log(` saved at ${ansi.blue("src/manager/json/alter-list.json")}`);
4564
- }
4565
- async function SYNC_githubStats() {
4566
- await downloadFile("https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/refs/heads/main/github-stats.json", "src/manager/json/github-stats.json", `- downloading ynchronizing githubStats.json...`);
4567
- console.log(` saved at ${ansi.blue("src/manager/json/github-stats.json")}`);
4656
+ for (const file of MANAGER_MIRROR_FILES) {
4657
+ const dest = `src/manager/json/${file}`;
4658
+ await downloadFile(`${MANAGER_RAW_BASE}/${file}`, dest, `- downloading ${file}...`);
4659
+ console.log(` saved at ${ansi.blue(dest)}`);
4568
4660
  }
4569
4661
  }
4570
4662
  //#endregion
@@ -4572,24 +4664,6 @@ async function DownloadComfyManagerJSONs() {
4572
4664
  const githubRegexpV1 = /https:\/\/github.com\/(.+?)\/(.+?)\/?/;
4573
4665
  const githubRegexpV2 = /https:\/\/github.com\/(.+?)\/([a-zA-Z0-9-_]+)?/;
4574
4666
  //#endregion
4575
- //#region src/utils/tryExtracting.ts
4576
- function tryRecovering({ verbose = 0, property, hacks, onFail, onSuccess }) {
4577
- if (verbose >= 2) console.log(`[🔶] trying to find a suitable value for ${property}...`);
4578
- for (const hack of hacks) {
4579
- if (verbose >= 2) console.log(` > trying to use ${hack.attempt}...`);
4580
- const value = hack.fn();
4581
- if (value != null) {
4582
- if (verbose >= (hack.level ?? 1)) {
4583
- if (verbose) console.log(` 🔶 recovered ${property} using ${hack.attempt}.`);
4584
- }
4585
- onSuccess?.(property, value);
4586
- return value;
4587
- }
4588
- }
4589
- onFail?.(property);
4590
- throw new Error(`[🔶] ${property} could not be recovered`);
4591
- }
4592
- //#endregion
4593
4667
  //#region src/manager/json/custom-node-list.extra.ts
4594
4668
  const ComfyPluginExtra = [{
4595
4669
  id: "TEMP_ComfyUI-BRIA_AI-RMBG",
@@ -4601,46 +4675,111 @@ const ComfyPluginExtra = [{
4601
4675
  description: "better rembg ?"
4602
4676
  }];
4603
4677
  //#endregion
4678
+ //#region src/manager/loaders/parseReport.ts
4679
+ /** root shape of a manager mirror file is broken: nothing to salvage, fail loud */
4680
+ var ManagerParseError = class extends Error {
4681
+ constructor(file, detail) {
4682
+ super(`🔴 [manager] ${file} root shape invalid: ${detail}`);
4683
+ this.file = file;
4684
+ this.detail = detail;
4685
+ this.name = "ManagerParseError";
4686
+ }
4687
+ };
4688
+ var FileParseCounter = class {
4689
+ constructor(file) {
4690
+ this.file = file;
4691
+ this.total = 0;
4692
+ this.accepted = 0;
4693
+ this.skipped = /* @__PURE__ */ new Map();
4694
+ }
4695
+ ok() {
4696
+ this.total++;
4697
+ this.accepted++;
4698
+ }
4699
+ skip(reason, firstError) {
4700
+ this.total++;
4701
+ const prev = this.skipped.get(reason);
4702
+ if (prev == null) this.skipped.set(reason, {
4703
+ count: 1,
4704
+ firstError
4705
+ });
4706
+ else prev.count++;
4707
+ }
4708
+ };
4709
+ /** per-file row accounting for the manager mirror parse; printed on every registry build so upstream drift stays visible */
4710
+ var ManagerParseReport = class {
4711
+ constructor() {
4712
+ this.counters = [];
4713
+ }
4714
+ file(name) {
4715
+ const counter = new FileParseCounter(name);
4716
+ this.counters.push(counter);
4717
+ return counter;
4718
+ }
4719
+ print() {
4720
+ console.log(ansi.bold(`[📘 registry] parse report:`));
4721
+ for (const c of this.counters) {
4722
+ const skippedTotal = [...c.skipped.values()].reduce((acc, cur) => acc + cur.count, 0);
4723
+ const headline = ` ${c.file}: ${c.total} rows, ${c.accepted} accepted, ${skippedTotal} skipped`;
4724
+ console.log(skippedTotal === 0 ? headline : ansi.red(headline));
4725
+ for (const [reason, info] of c.skipped) console.log(ansi.red(` - ${reason} x${info.count}, first: ${info.firstError}`));
4726
+ }
4727
+ }
4728
+ };
4729
+ //#endregion
4730
+ //#region src/manager/types/ComfyManagerFilePluginList.ts
4731
+ const ComfyManagerFilePluginListRoot_ark = (0, arktype.type)({ custom_nodes: "unknown[]" });
4732
+ //#endregion
4604
4733
  //#region src/manager/types/ComfyManagerPluginInfo.ts
4605
- const ComfyManagerPluginInfo_ark = (0, arktype.type)({
4734
+ const ComfyManagerRawPluginInfo_ark = (0, arktype.type)({
4606
4735
  author: "string",
4607
4736
  title: arktype.type.string.as(),
4608
4737
  reference: "string",
4609
4738
  files: arktype.type.string.as().array(),
4610
4739
  install_type: "string",
4611
4740
  description: "string",
4612
- id: arktype.type.string.as(),
4741
+ "id?": arktype.type.string.as(),
4613
4742
  "preemptions?": "string[]",
4614
4743
  "pip?": "string[]",
4615
4744
  "nodename_pattern?": "string",
4616
4745
  "apt_dependency?": "string[]",
4617
4746
  "js_path?": "string",
4618
4747
  "version?": "string",
4619
- "tags?": "string[]"
4748
+ "tags?": "string[]",
4749
+ "reference2?": "string",
4750
+ "category?": "string",
4751
+ "name?": "string",
4752
+ "license?": "string",
4753
+ "nickname?": "string",
4754
+ "stars?": "number",
4755
+ "last_update?": "string",
4756
+ "badges?": "string[]",
4757
+ "dependencies?": "string[]"
4620
4758
  });
4621
4759
  //#endregion
4622
- //#region src/manager/types/ComfyManagerFilePluginList.ts
4623
- const ComfyManagerFilePluginList_ark = (0, arktype.type)({ custom_nodes: ComfyManagerPluginInfo_ark.array() });
4624
- //#endregion
4625
4760
  //#region src/manager/loaders/step2_custom-node-list-loader.ts
4626
4761
  const _getKnownPlugins = (DB) => {
4762
+ const counter = DB.report.file("custom-node-list.json");
4627
4763
  let totalFileSeen = 0;
4628
- let totalPluginSeen = 0;
4629
- const knownPluginFile = JSON.parse((0, fs.readFileSync)("src/manager/json/custom-node-list.json", "utf8"));
4630
- const knownPluginList = knownPluginFile.custom_nodes.concat(ComfyPluginExtra);
4631
- for (const plugin of knownPluginList) {
4632
- plugin.id ??= tryRecoveringPluginId(plugin, 1);
4633
- plugin.title ??= tryRecoveringPluginTitle(plugin, 1);
4634
- }
4635
- const res = ComfyManagerFilePluginList_ark(knownPluginFile);
4636
- if (DB.opts.check) {
4764
+ const root = ComfyManagerFilePluginListRoot_ark(JSON.parse((0, node_fs.readFileSync)("src/manager/json/custom-node-list.json", "utf8")));
4765
+ if (root instanceof arktype.type.errors) throw new ManagerParseError("custom-node-list.json", root.summary);
4766
+ const canonical = [];
4767
+ for (const row of root.custom_nodes) {
4768
+ const res = ComfyManagerRawPluginInfo_ark(row);
4637
4769
  if (res instanceof arktype.type.errors) {
4638
- printArkResultInConsole(res);
4639
- process.exit(1);
4770
+ counter.skip("schema", res.summary);
4771
+ continue;
4772
+ }
4773
+ const plugin = normalizePluginInfo(res);
4774
+ if (plugin == null) {
4775
+ counter.skip("id-unrecoverable", res.reference);
4776
+ continue;
4640
4777
  }
4778
+ canonical.push(plugin);
4779
+ counter.ok();
4641
4780
  }
4781
+ const knownPluginList = canonical.concat(ComfyPluginExtra);
4642
4782
  for (const plugin of knownPluginList) {
4643
- totalPluginSeen++;
4644
4783
  if (DB.opts.check && DB.plugins_byTitle.has(plugin.title)) console.log(` ❌ plugin.title: "${plugin.title}" is duplicated`);
4645
4784
  DB.plugins_byTitle.set(plugin.title, plugin);
4646
4785
  for (const pluginURI of plugin.files) {
@@ -4651,7 +4790,7 @@ const _getKnownPlugins = (DB) => {
4651
4790
  }
4652
4791
  if (DB.opts.genTypes) {
4653
4792
  let out1 = "";
4654
- const allPluginsSortedByTitles = [...DB.plugins_byTitle.values()].sort((a, b) => (a.title ?? "❌missing-title").toLowerCase().localeCompare((b.title ?? "❌missing-title").toLowerCase()));
4793
+ const allPluginsSortedByTitles = [...DB.plugins_byTitle.values()].sort((a, b) => a.title.toLowerCase().localeCompare(b.title.toLowerCase()));
4655
4794
  out1 += "// prettier-ignore\n";
4656
4795
  out1 += "export type KnownComfyPluginTitle =\n";
4657
4796
  for (const plugin of allPluginsSortedByTitles) {
@@ -4660,7 +4799,7 @@ const _getKnownPlugins = (DB) => {
4660
4799
  }
4661
4800
  out1 += "\n";
4662
4801
  const out1Path = "src/manager/generated/KnownComfyPluginTitle.ts";
4663
- (0, fs.writeFileSync)(out1Path, out1 + "\n", "utf-8");
4802
+ (0, node_fs.writeFileSync)(out1Path, out1 + "\n", "utf-8");
4664
4803
  console.log(` > generated: ${ansi.blue.underline(out1Path)}`);
4665
4804
  let out2 = "";
4666
4805
  const sortedFileNames = [...DB.plugins_byFile.keys()].sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
@@ -4668,47 +4807,33 @@ const _getKnownPlugins = (DB) => {
4668
4807
  out2 += "export type KnownComfyPluginURL =\n";
4669
4808
  for (const fileName of sortedFileNames) out2 += ` | ${JSON.stringify(fileName)}\n`;
4670
4809
  const out2Path = "src/manager/generated/KnownComfyPluginURL.ts";
4671
- (0, fs.writeFileSync)(out2Path, out2, "utf-8");
4810
+ (0, node_fs.writeFileSync)(out2Path, out2, "utf-8");
4672
4811
  console.log(` > generated: ${ansi.blue.underline(out2Path)}`);
4673
4812
  }
4674
4813
  if (DB.opts.check) {
4675
- console.log(` - ${totalPluginSeen} CustomNodes in file`);
4814
+ console.log(` - ${knownPluginList.length} CustomNodes in file`);
4676
4815
  console.log(` - ${DB.plugins_byTitle.size} CustomNodes registered in map`);
4677
4816
  console.log(` - ${totalFileSeen} CustomNodes-File Seen`);
4678
4817
  console.log(` - ${DB.plugins_byFile.size} CustomNodes-File registered in map`);
4679
4818
  }
4680
4819
  };
4681
- function tryRecoveringPluginTitle(plugin, verbose = 0) {
4682
- return tryRecovering({
4683
- property: "plugin.title",
4684
- verbose,
4685
- hacks: [{
4686
- attempt: "id",
4687
- fn: () => plugin.id
4688
- }, {
4689
- attempt: "github repo name",
4690
- fn: () => plugin.reference
4691
- }]
4692
- });
4693
- }
4694
- function tryRecoveringPluginId(plugin, verbose = 0) {
4695
- return tryRecovering({
4696
- property: "plugin.id",
4697
- verbose,
4698
- hacks: [{
4699
- level: 2,
4700
- attempt: "title",
4701
- fn: () => plugin.title
4702
- }, {
4703
- attempt: "github repo name",
4704
- fn: () => plugin.reference.match(githubRegexpV1)?.[2]
4705
- }]
4706
- });
4820
+ /**
4821
+ * raw → canonical: recover the missing `id` (absent on ~76% of upstream rows)
4822
+ * from the title, else the github repo name. null = unrecoverable, caller
4823
+ * reports and skips the row.
4824
+ */
4825
+ function normalizePluginInfo(p) {
4826
+ const id = p.id ?? p.title ?? p.reference.match(githubRegexpV1)?.[2];
4827
+ if (id == null) return null;
4828
+ return {
4829
+ ...p,
4830
+ id
4831
+ };
4707
4832
  }
4708
4833
  //#endregion
4709
4834
  //#region src/manager/types/ComfyManagerPluginContentMetadata.ts
4710
4835
  const ComfyManagerPluginContentMetadata_ark = (0, arktype.type)({
4711
- title_aux: arktype.type.string.or(arktype.type.null),
4836
+ "title_aux?": arktype.type.string.or(arktype.type.null),
4712
4837
  "author?": "string",
4713
4838
  "nickname?": "string",
4714
4839
  "description?": "string",
@@ -4722,42 +4847,37 @@ const ComfyManagerPluginContentNodeName_ark = arktype.type.string.as();
4722
4847
  (0, arktype.type)("string");
4723
4848
  //#endregion
4724
4849
  //#region src/manager/types/ComfyManagerFilePluginContent.ts
4725
- const ComfyManagerFilePluginContent_ark = arktype.type.Record("string", (0, arktype.type)([ComfyManagerPluginContentNodeName_ark.array(), ComfyManagerPluginContentMetadata_ark]));
4850
+ const ComfyManagerExtensionNodeMapEntry_ark = (0, arktype.type)([ComfyManagerPluginContentNodeName_ark.array(), ComfyManagerPluginContentMetadata_ark]);
4726
4851
  //#endregion
4727
4852
  //#region src/manager/loaders/step3_extension-node-map-loader.ts
4728
4853
  const _getCustomNodeRegistry = (DB) => {
4854
+ const counter = DB.report.file("extension-node-map.json");
4729
4855
  let totalCustomNodeSeen = 0;
4730
- const extensionNodeMapFile = JSON.parse((0, node_fs.readFileSync)("src/manager/json/extension-node-map.json", "utf8"));
4731
- const res = ComfyManagerFilePluginContent_ark(extensionNodeMapFile);
4732
- if (DB.opts.check) {
4856
+ const raw = JSON.parse((0, node_fs.readFileSync)("src/manager/json/extension-node-map.json", "utf8"));
4857
+ const root = (0, arktype.type)("Record<string, unknown>")(raw);
4858
+ if (root instanceof arktype.type.errors) throw new ManagerParseError("extension-node-map.json", root.summary);
4859
+ for (const [url, value] of Object.entries(root)) {
4860
+ const res = ComfyManagerExtensionNodeMapEntry_ark(value);
4733
4861
  if (res instanceof arktype.type.errors) {
4734
- printArkResultInConsole(res);
4735
- process.exit(1);
4862
+ counter.skip("schema", `${url}: ${res.summary}`);
4863
+ continue;
4736
4864
  }
4737
- }
4738
- const enmEntries = Object.entries(extensionNodeMapFile).map((x) => {
4739
- const url = x[0];
4740
- const [comfyNodeNames, meta] = x[1];
4741
- const confyPlugin = DB.plugins_byFile.get(url);
4742
- if (confyPlugin == null) throw new Error(`[❌] plugin not found for ${url}`);
4743
- return {
4744
- url,
4745
- comfyNodeNames,
4746
- meta,
4747
- plugin: confyPlugin,
4748
- pythonModule: reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(confyPlugin, url, meta)
4749
- };
4750
- });
4751
- for (const enmEntry of enmEntries) {
4752
- totalCustomNodeSeen += enmEntry.comfyNodeNames.length;
4753
- const plugin = enmEntry.plugin;
4865
+ const plugin = DB.plugins_byFile.get(url);
4866
+ if (plugin == null) {
4867
+ counter.skip("unknown-plugin-url", url);
4868
+ continue;
4869
+ }
4870
+ counter.ok();
4871
+ const comfyNodeNames = res[0];
4872
+ totalCustomNodeSeen += comfyNodeNames.length;
4873
+ const pythonModule = reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(plugin);
4754
4874
  const nodesInPlugin = DB.customNodes_byPluginName.get(plugin.title) ?? [];
4755
4875
  DB.customNodes_byPluginName.set(plugin.title, nodesInPlugin);
4756
- for (const nodeNameInComfy of enmEntry.comfyNodeNames) {
4757
- const nodeKey = toQualifiedNodeKey(enmEntry.pythonModule, nodeNameInComfy);
4758
- const prevEntry2 = DB.plugins_byNodeKey.get(nodeKey);
4759
- if (prevEntry2 == null) DB.plugins_byNodeKey.set(nodeKey, [plugin]);
4760
- else prevEntry2.push(plugin);
4876
+ for (const nodeNameInComfy of comfyNodeNames) {
4877
+ const nodeKey = toQualifiedNodeKey(pythonModule, nodeNameInComfy);
4878
+ const prevEntry = DB.plugins_byNodeKey.get(nodeKey);
4879
+ if (prevEntry == null) DB.plugins_byNodeKey.set(nodeKey, [plugin]);
4880
+ else prevEntry.push(plugin);
4761
4881
  nodesInPlugin.push(nodeKey);
4762
4882
  }
4763
4883
  }
@@ -4766,23 +4886,22 @@ const _getCustomNodeRegistry = (DB) => {
4766
4886
  const sortedNodeKeys = [...DB.plugins_byNodeKey.keys()].sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
4767
4887
  out += "// prettier-ignore\n";
4768
4888
  out += "export type KnownComfyCustomNodeName =\n";
4769
- for (const nodeName of sortedNodeKeys) {
4770
- if (nodeName === "sd_perturbed_attention.PerturbedAttention") console.log(`[🤠] 🔴`, DB.plugins_byNodeKey.get(nodeName));
4771
- out += ` | ${JSON.stringify(nodeName)}\n`;
4772
- }
4889
+ for (const nodeName of sortedNodeKeys) out += ` | ${JSON.stringify(nodeName)}\n`;
4773
4890
  out += "\n";
4774
4891
  const outPath = "src/manager/generated/KnownComfyCustomNodeName.ts";
4775
4892
  (0, node_fs.writeFileSync)(outPath, out + "\n", "utf-8");
4776
4893
  console.log(` > generated: ${ansi.blue.underline(outPath)}`);
4777
4894
  }
4778
- if (DB.opts.check) console.log(` - ${totalCustomNodeSeen} CustomNodes unique names processed`);
4895
+ if (DB.opts.check) {
4896
+ console.log(` - ${totalCustomNodeSeen} CustomNodes names processed`);
4897
+ console.log(` - ${DB.plugins_byNodeKey.size} unique node keys registered in map`);
4898
+ }
4779
4899
  };
4780
- function reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(plugin, _url, _meta) {
4900
+ function reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(plugin) {
4781
4901
  if (plugin.id === "nodes" && plugin.reference === "https://github.com/comfyanonymous/ComfyUI") return "nodes";
4782
4902
  const repoName = plugin.reference.match(githubRegexpV2)?.[2];
4783
4903
  if (repoName) return `custom_nodes.${repoName}`;
4784
- if (plugin.id) return `custom_nodes.${plugin.id}`;
4785
- return "🔴";
4904
+ return `custom_nodes.${plugin.id}`;
4786
4905
  }
4787
4906
  //#endregion
4788
4907
  //#region src/manager/json/model-list.extra.ts
@@ -4806,6 +4925,9 @@ const extraModels = { models: [{
4806
4925
  url: "https://huggingface.co/gemasai/4x_NMKD-Siax_200k/resolve/main/4xRealWebPhoto_v4_dat2.pth"
4807
4926
  }] };
4808
4927
  //#endregion
4928
+ //#region src/manager/types/ComfyManagerFileModelInfo.ts
4929
+ const ComfyManagerFileModelInfoRoot_ark = (0, arktype.type)({ models: "unknown[]" });
4930
+ //#endregion
4809
4931
  //#region src/manager/types/ComfyManagerModelInfo.ts
4810
4932
  const ComfyManagerModelInfo_ark = (0, arktype.type)({
4811
4933
  name: arktype.type.string.as(),
@@ -4821,20 +4943,21 @@ const ComfyManagerModelInfo_ark = (0, arktype.type)({
4821
4943
  //#endregion
4822
4944
  //#region src/manager/loaders/step4_model-list-loader.ts
4823
4945
  const _getKnownModels = (DB) => {
4824
- const knownModelList = JSON.parse((0, fs.readFileSync)("src/manager/json/model-list.json", "utf8")).models.concat(extraModels.models);
4825
- let hasErrors = false;
4826
- for (const modelInfo of knownModelList) {
4827
- DB.knownModels.set(modelInfo.name, modelInfo);
4828
- if (!hasErrors && DB.opts.check) {
4829
- const res = ComfyManagerModelInfo_ark(modelInfo);
4830
- if (res instanceof arktype.type.errors) {
4831
- const errors = res;
4832
- console.error(`❌ model doesn't match schema:`, modelInfo);
4833
- printArkResultInConsole(errors);
4834
- hasErrors = true;
4835
- }
4946
+ const counter = DB.report.file("model-list.json");
4947
+ const root = ComfyManagerFileModelInfoRoot_ark(JSON.parse((0, node_fs.readFileSync)("src/manager/json/model-list.json", "utf8")));
4948
+ if (root instanceof arktype.type.errors) throw new ManagerParseError("model-list.json", root.summary);
4949
+ const canonical = [];
4950
+ for (const row of root.models) {
4951
+ const res = ComfyManagerModelInfo_ark(row);
4952
+ if (res instanceof arktype.type.errors) {
4953
+ counter.skip("schema", res.summary);
4954
+ continue;
4836
4955
  }
4956
+ canonical.push(res);
4957
+ counter.ok();
4837
4958
  }
4959
+ const knownModelList = canonical.concat(extraModels.models);
4960
+ for (const modelInfo of knownModelList) DB.knownModels.set(modelInfo.name, modelInfo);
4838
4961
  if (DB.opts.genTypes) {
4839
4962
  let out1 = "";
4840
4963
  const uniqCategories = knownModelList.reduce((acc, cur) => {
@@ -4850,7 +4973,7 @@ const _getKnownModels = (DB) => {
4850
4973
  for (const [cat, count] of Object.entries(uniqCategories)) out1 += ` ${JSON.stringify(cat).padEnd(20)}, // x ${count.toString().padStart(3)}\n`;
4851
4974
  out1 += "]\n";
4852
4975
  const out1Path = "src/manager/generated/KnownModel_Type.ts";
4853
- (0, fs.writeFileSync)(out1Path, out1 + "\n", "utf-8");
4976
+ (0, node_fs.writeFileSync)(out1Path, out1 + "\n", "utf-8");
4854
4977
  console.log(` > generated: ${ansi.blue.underline(out1Path)}`);
4855
4978
  let out4 = "";
4856
4979
  const uniqSavePath = knownModelList.reduce((acc, cur) => {
@@ -4866,7 +4989,7 @@ const _getKnownModels = (DB) => {
4866
4989
  for (const [cat, count] of Object.entries(uniqSavePath)) out4 += ` ${JSON.stringify(cat).padEnd(50)}, // x ${count.toString().padStart(3)}\n`;
4867
4990
  out4 += "]\n";
4868
4991
  const out4Path = "src/manager/generated/KnownModel_SavePath.ts";
4869
- (0, fs.writeFileSync)(out4Path, out4 + "\n", "utf-8");
4992
+ (0, node_fs.writeFileSync)(out4Path, out4 + "\n", "utf-8");
4870
4993
  console.log(` > generated: ${ansi.blue.underline(out4Path)}`);
4871
4994
  let out2 = "";
4872
4995
  const uniqBases = knownModelList.reduce((acc, cur) => {
@@ -4883,7 +5006,7 @@ const _getKnownModels = (DB) => {
4883
5006
  for (const [cat, count] of Object.entries(uniqBases)) out2 += ` ${JSON.stringify(cat).padEnd(20)}, // x ${count.toString().padStart(3)}\n`;
4884
5007
  out2 += "]\n";
4885
5008
  const out2Path = "src/manager/generated/KnownModel_Base.ts";
4886
- (0, fs.writeFileSync)(out2Path, out2 + "\n", "utf-8");
5009
+ (0, node_fs.writeFileSync)(out2Path, out2 + "\n", "utf-8");
4887
5010
  console.log(` > generated: ${ansi.blue.underline(out2Path)}`);
4888
5011
  let out3 = "";
4889
5012
  const sortedModels = knownModelList.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()));
@@ -4898,7 +5021,7 @@ const _getKnownModels = (DB) => {
4898
5021
  }
4899
5022
  out3 += "\n";
4900
5023
  const out3Path = "src/manager/generated/KnownModel_Name.ts";
4901
- (0, fs.writeFileSync)(out3Path, out3 + "\n", "utf-8");
5024
+ (0, node_fs.writeFileSync)(out3Path, out3 + "\n", "utf-8");
4902
5025
  console.log(` > generated: ${ansi.blue.underline(out3Path)}`);
4903
5026
  let out99 = "";
4904
5027
  out99 += `// prettier-ignore\n`;
@@ -4912,20 +5035,78 @@ const _getKnownModels = (DB) => {
4912
5035
  }
4913
5036
  out99 += "\n";
4914
5037
  const out99Path = "src/manager/generated/KnownModel_FileName.ts";
4915
- (0, fs.writeFileSync)(out99Path, out99 + "\n", "utf-8");
5038
+ (0, node_fs.writeFileSync)(out99Path, out99 + "\n", "utf-8");
4916
5039
  console.log(` > generated: ${ansi.blue.underline(out99Path)}`);
4917
5040
  }
4918
5041
  if (DB.opts.check) {
4919
5042
  console.log(`${knownModelList.length} models found`);
4920
5043
  console.log(`${DB.knownModels.size} models registered map`);
4921
5044
  if (knownModelList.length !== DB.knownModels.size) console.log(`❌ some models are either duplicated or have overlapping indexing keys`);
4922
- if (hasErrors) console.log(`❌ some models don't match schema`);
4923
- else console.log(`✅ all models match schema`);
5045
+ }
5046
+ };
5047
+ //#endregion
5048
+ //#region src/manager/types/ComfyManagerAlterInfo.ts
5049
+ const ComfyManagerAlterInfo_ark = (0, arktype.type)({
5050
+ id: "string",
5051
+ tags: "string",
5052
+ description: "string"
5053
+ });
5054
+ const ComfyManagerFileAlterListRoot_ark = (0, arktype.type)({ items: "unknown[]" });
5055
+ //#endregion
5056
+ //#region src/manager/loaders/step5_alter-list-loader.ts
5057
+ const _getAlterList = (DB) => {
5058
+ const counter = DB.report.file("alter-list.json");
5059
+ const root = ComfyManagerFileAlterListRoot_ark(JSON.parse((0, node_fs.readFileSync)("src/manager/json/alter-list.json", "utf8")));
5060
+ if (root instanceof arktype.type.errors) throw new ManagerParseError("alter-list.json", root.summary);
5061
+ const canonical = [];
5062
+ for (const row of root.items) {
5063
+ const res = ComfyManagerAlterInfo_ark(row);
5064
+ if (res instanceof arktype.type.errors) {
5065
+ counter.skip("schema", res.summary);
5066
+ continue;
5067
+ }
5068
+ canonical.push(res);
5069
+ counter.ok();
5070
+ }
5071
+ DB.alterations = canonical;
5072
+ };
5073
+ //#endregion
5074
+ //#region src/manager/types/ComfyManagerGithubStats.ts
5075
+ const ComfyManagerGithubStatEntry_ark = (0, arktype.type)({
5076
+ stars: "number",
5077
+ last_update: "string",
5078
+ author_account_age_days: "number"
5079
+ });
5080
+ //#endregion
5081
+ //#region src/manager/loaders/step6_github-stats-loader.ts
5082
+ const _getGithubStats = (DB) => {
5083
+ const counter = DB.report.file("github-stats.json");
5084
+ const raw = JSON.parse((0, node_fs.readFileSync)("src/manager/json/github-stats.json", "utf8"));
5085
+ const root = (0, arktype.type)("Record<string, unknown>")(raw);
5086
+ if (root instanceof arktype.type.errors) throw new ManagerParseError("github-stats.json", root.summary);
5087
+ for (const [url, value] of Object.entries(root)) {
5088
+ const res = ComfyManagerGithubStatEntry_ark(value);
5089
+ if (res instanceof arktype.type.errors) {
5090
+ counter.skip("schema", `${url}: ${res.summary}`);
5091
+ continue;
5092
+ }
5093
+ DB.githubStats.set(url, res);
5094
+ counter.ok();
4924
5095
  }
4925
5096
  };
4926
5097
  //#endregion
4927
5098
  //#region src/manager/ComfyRegistry.ts
4928
5099
  const log = (...args) => console.log(`[📘 registry]`, ...args);
5100
+ const BUILTIN_URL = "https://github.com/comfyanonymous/ComfyUI";
5101
+ const BUILTIN_PLUGIN = {
5102
+ id: "nodes",
5103
+ author: "comfyanonymous",
5104
+ description: "built-in",
5105
+ title: "built-in",
5106
+ files: [BUILTIN_URL],
5107
+ reference: "https://github.com/comfyanonymous/ComfyUI",
5108
+ install_type: ""
5109
+ };
4929
5110
  var ComfyRegistry = class ComfyRegistry {
4930
5111
  static async DownloadAndUpdate(download) {
4931
5112
  if (download) {
@@ -4945,6 +5126,9 @@ var ComfyRegistry = class ComfyRegistry {
4945
5126
  this.plugins_byNodeKey = /* @__PURE__ */ new Map();
4946
5127
  this.customNodes_byPluginName = /* @__PURE__ */ new Map();
4947
5128
  this.knownModels = /* @__PURE__ */ new Map();
5129
+ this.alterations = [];
5130
+ this.githubStats = /* @__PURE__ */ new Map();
5131
+ this.report = new ManagerParseReport();
4948
5132
  this.getKnownCheckpoints = () => {
4949
5133
  return [...this.knownModels.values()].filter((i) => i.type === "checkpoint");
4950
5134
  };
@@ -4984,21 +5168,19 @@ var ComfyRegistry = class ComfyRegistry {
4984
5168
  nix: isUnderPrefix ? nixPath.slice(nixPrefix.length) : mi.filename
4985
5169
  };
4986
5170
  };
4987
- this.plugins_byFile.set("https://github.com/comfyanonymous/ComfyUI", {
4988
- id: "nodes",
4989
- author: "comfyanonymous",
4990
- description: "built-in",
4991
- title: "built-in",
4992
- files: [],
4993
- reference: "https://github.com/comfyanonymous/ComfyUI",
4994
- install_type: ""
4995
- });
5171
+ this.plugins_byTitle.set(BUILTIN_PLUGIN.title, BUILTIN_PLUGIN);
5172
+ this.plugins_byFile.set(BUILTIN_URL, BUILTIN_PLUGIN);
4996
5173
  log(`loading src/manager/json/${ansi.yellow("custom-node-list.json")}...`);
4997
5174
  _getKnownPlugins(this);
4998
5175
  log(`loading src/manager/json/${ansi.yellow("extension-node-map.json")}...`);
4999
5176
  _getCustomNodeRegistry(this);
5000
5177
  log(`loading src/manager/json/${ansi.yellow("model-list.json")}...`);
5001
5178
  _getKnownModels(this);
5179
+ log(`loading src/manager/json/${ansi.yellow("alter-list.json")}...`);
5180
+ _getAlterList(this);
5181
+ log(`loading src/manager/json/${ansi.yellow("github-stats.json")}...`);
5182
+ _getGithubStats(this);
5183
+ this.report.print();
5002
5184
  }
5003
5185
  };
5004
5186
  //#endregion
@@ -5090,6 +5272,52 @@ var ComfyTS = class ComfyTS {
5090
5272
  }
5091
5273
  };
5092
5274
  //#endregion
5275
+ //#region src/exampleAssets.ts
5276
+ /**
5277
+ * the examples/ folder shipped in the npm tarball, resolved from THIS module's
5278
+ * own location (NEVER cwd): walking up to the nearest NAMED package.json finds
5279
+ * <pkg>/examples both from a consumer's node_modules/comfy-ts/dist/ and from
5280
+ * this repo's src/. Returns null when the examples are absent (a consumer may
5281
+ * prune the folder) or when the nearest named package is not comfy-ts (the lib
5282
+ * was inlined into someone else's bundle — its examples are not on disk); no
5283
+ * package.json all the way up is a broken install and throws.
5284
+ */
5285
+ function bundledExamplesDir(moduleUrl = require("url").pathToFileURL(__filename).href) {
5286
+ let dir = (0, pathe.dirname)((0, node_url.fileURLToPath)(moduleUrl));
5287
+ let prev = "";
5288
+ while (dir !== prev) {
5289
+ const pkgPath = (0, pathe.join)(dir, "package.json");
5290
+ if ((0, node_fs.existsSync)(pkgPath)) {
5291
+ let pkg = {};
5292
+ try {
5293
+ pkg = JSON.parse((0, node_fs.readFileSync)(pkgPath, "utf8"));
5294
+ } catch {}
5295
+ if (pkg.name === "comfy-ts") {
5296
+ const examples = (0, pathe.join)(dir, "examples");
5297
+ return (0, node_fs.existsSync)(examples) ? examples : null;
5298
+ }
5299
+ if (pkg.name != null) return null;
5300
+ }
5301
+ prev = dir;
5302
+ dir = (0, pathe.dirname)(dir);
5303
+ }
5304
+ throw new Error(`[comfy-ts] no package.json found walking up from ${(0, node_url.fileURLToPath)(moduleUrl)}`);
5305
+ }
5306
+ /**
5307
+ * absolute path of a bundled `examples/images/` input image, e.g.
5308
+ * `exampleImagePath('bear_1024x1024.jpg')` — the out-of-the-box default for
5309
+ * i2i/i2v example image vars, valid from this repo AND from a consumer's
5310
+ * node_modules/comfy-ts/. Loud throw naming the path when the file is missing
5311
+ * or the package's examples/ folder was pruned.
5312
+ */
5313
+ function exampleImagePath(name) {
5314
+ const examples = bundledExamplesDir();
5315
+ if (examples == null) throw new Error(`[comfy-ts] cannot resolve bundled example image '${name}': the package's examples/ folder is not on disk`);
5316
+ const abs = (0, pathe.join)(examples, "images", name);
5317
+ if (!(0, node_fs.existsSync)(abs)) throw new Error(`[comfy-ts] bundled example image not found: ${abs}`);
5318
+ return abs;
5319
+ }
5320
+ //#endregion
5093
5321
  //#region src/cli/tui-env.ts
5094
5322
  const COMFY_TS_TUI_ENV = "COMFY_TS_TUI";
5095
5323
  function isTuiActive() {
@@ -5122,9 +5350,12 @@ exports.ComfyVar = ComfyVar;
5122
5350
  exports.ComfyVarBase = ComfyVarBase;
5123
5351
  exports.ComfyWorkflow = ComfyWorkflow;
5124
5352
  exports.ComfyWorkflowBuilder = ComfyWorkflowBuilder;
5353
+ exports.DEFAULT_IMAGE_EXTENSIONS = DEFAULT_IMAGE_EXTENSIONS;
5125
5354
  exports.DEFAULT_SIZE_PRESETS = DEFAULT_SIZE_PRESETS;
5126
5355
  exports.DefinedWorkflow = DefinedWorkflow;
5127
5356
  exports.FloatVar = FloatVar;
5357
+ exports.ImageVar = ImageVar;
5358
+ exports.ImageVarEmptyError = ImageVarEmptyError;
5128
5359
  exports.IntVar = IntVar;
5129
5360
  exports.InvalidPromptError = InvalidPromptError;
5130
5361
  exports.LorasVar = LorasVar;
@@ -5149,6 +5380,7 @@ exports.auto_ = auto_;
5149
5380
  exports.codegenSDK = codegenSDK;
5150
5381
  exports.convertFlowToLiteGraphJSON = convertFlowToLiteGraphJSON;
5151
5382
  exports.convertLiteGraphToPrompt = convertLiteGraphToPrompt;
5383
+ exports.exampleImagePath = exampleImagePath;
5152
5384
  exports.getLoraKeyword = getLoraKeyword;
5153
5385
  exports.hostIdToNamespace = hostIdToNamespace;
5154
5386
  exports.isTuiActive = isTuiActive;