comfy-ts 1.0.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 (147) hide show
  1. package/README.md +60 -11
  2. package/dist/cli.js +4 -4439
  3. package/dist/cli.js.map +1 -1
  4. package/dist/index.cjs +445 -172
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +7439 -340
  7. package/dist/index.d.ts +7457 -358
  8. package/dist/index.js +444 -172
  9. package/dist/index.js.map +1 -1
  10. package/dist/{run-tui-BFhba_oG.js → run-tui-BAdizWsO.js} +1244 -201
  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 +32 -0
  15. package/examples/comfy-cloud/ace-step-t2a.cflow.ts +79 -0
  16. package/examples/comfy-cloud/anima-t2i.cflow.ts +57 -0
  17. package/examples/comfy-cloud/boogu-i2i.cflow.ts +76 -0
  18. package/examples/comfy-cloud/capybara-i2i.cflow.ts +85 -0
  19. package/examples/comfy-cloud/capybara-i2v.cflow.ts +90 -0
  20. package/examples/comfy-cloud/capybara-t2i.cflow.ts +67 -0
  21. package/examples/comfy-cloud/chatterbox-t2a.cflow.ts +79 -0
  22. package/examples/comfy-cloud/chroma-t2i.cflow.ts +62 -0
  23. package/examples/comfy-cloud/cloudHost.ts +41 -0
  24. package/examples/comfy-cloud/ernie-t2i.cflow.ts +59 -0
  25. package/examples/comfy-cloud/firered-i2i.cflow.ts +74 -0
  26. package/examples/comfy-cloud/flux1-i2i.cflow.ts +76 -0
  27. package/examples/comfy-cloud/flux1-t2i.cflow.ts +63 -0
  28. package/examples/comfy-cloud/flux2-i2i.cflow.ts +80 -0
  29. package/examples/comfy-cloud/flux2-t2i.cflow.ts +57 -0
  30. package/examples/comfy-cloud/hidream-i2i.cflow.ts +89 -0
  31. package/examples/comfy-cloud/hidream-t2i.cflow.ts +65 -0
  32. package/examples/comfy-cloud/hunyuan-video-i2v.cflow.ts +93 -0
  33. package/examples/comfy-cloud/hunyuan-video-t2v.cflow.ts +74 -0
  34. package/examples/comfy-cloud/ideogram4-t2i.cflow.ts +80 -0
  35. package/examples/comfy-cloud/kandinsky5-i2v.cflow.ts +95 -0
  36. package/examples/comfy-cloud/kandinsky5-t2i.cflow.ts +60 -0
  37. package/examples/comfy-cloud/kandinsky5-t2v.cflow.ts +78 -0
  38. package/examples/comfy-cloud/krea2-t2i.cflow.ts +59 -0
  39. package/examples/comfy-cloud/lens-t2i.cflow.ts +62 -0
  40. package/examples/comfy-cloud/longcat-i2i.cflow.ts +74 -0
  41. package/examples/comfy-cloud/longcat-t2i.cflow.ts +65 -0
  42. package/examples/comfy-cloud/ltxv-i2v.cflow.ts +92 -0
  43. package/examples/comfy-cloud/ltxv-t2v.cflow.ts +78 -0
  44. package/examples/comfy-cloud/newbie-t2i.cflow.ts +67 -0
  45. package/examples/comfy-cloud/omnigen2-i2i.cflow.ts +86 -0
  46. package/examples/comfy-cloud/omnigen2-t2i.cflow.ts +62 -0
  47. package/examples/comfy-cloud/ovis-t2i.cflow.ts +56 -0
  48. package/examples/comfy-cloud/pixeldit-t2i.cflow.ts +63 -0
  49. package/examples/comfy-cloud/qwen-image-i2i.cflow.ts +69 -0
  50. package/examples/comfy-cloud/qwen-image-t2i.cflow.ts +55 -0
  51. package/examples/comfy-cloud/sd35-t2i.cflow.ts +48 -0
  52. package/examples/comfy-cloud/sdk.d.ts +445 -57
  53. package/examples/comfy-cloud/sdxl-t2i.cflow.ts +69 -0
  54. package/examples/comfy-cloud/stable-audio-t2a.cflow.ts +53 -0
  55. package/examples/comfy-cloud/svd-i2v.cflow.ts +75 -0
  56. package/examples/comfy-cloud/wan21-i2v.cflow.ts +83 -0
  57. package/examples/comfy-cloud/wan21-t2v.cflow.ts +64 -0
  58. package/examples/comfy-cloud/wan22-5b-t2v.cflow.ts +69 -0
  59. package/examples/comfy-cloud/wan22-i2v.cflow.ts +107 -0
  60. package/examples/comfy-cloud/wan22-t2v.cflow.ts +98 -0
  61. package/examples/comfy-cloud/z-image-t2i.cflow.ts +62 -0
  62. package/examples/images/README.md +18 -0
  63. package/examples/images/bear_1024x1024.jpg +0 -0
  64. package/examples/images/deer_768x1344.jpg +0 -0
  65. package/examples/images/dog_512x512.jpg +0 -0
  66. package/examples/images/lioness_768x768.jpg +0 -0
  67. package/examples/images/pug_200x300.jpg +0 -0
  68. package/examples/images/walrus_1344x768.jpg +0 -0
  69. package/examples/{01-txt2img.cflow.ts → rvion/01-txt2img.cflow.ts} +1 -1
  70. package/examples/{02-img2img-upload.cflow.ts → rvion/02-img2img-upload.cflow.ts} +7 -18
  71. package/examples/{03-export-workflow-json.cflow.ts → rvion/03-export-workflow-json.cflow.ts} +1 -1
  72. package/examples/{04-krea2-turbo-t2i.cflow.ts → rvion/04-krea2-turbo-t2i.cflow.ts} +2 -2
  73. package/examples/rvion/05-comfy-cloud.cflow.ts +51 -0
  74. package/examples/rvion/06-qwen-image-edit.cflow.ts +89 -0
  75. package/guide-for-agents.md +7 -1
  76. package/package.json +18 -4
  77. package/src/cli/tui/components/CopyOverlay.tsx +25 -0
  78. package/src/cli/tui/components/Header.tsx +9 -4
  79. package/src/cli/tui/components/HostPanel.tsx +3 -2
  80. package/src/cli/tui/components/HostsOverlay.tsx +33 -0
  81. package/src/cli/tui/components/PreviewPanel.tsx +9 -8
  82. package/src/cli/tui/components/StatusBar.tsx +39 -9
  83. package/src/cli/tui/components/TreePanel.tsx +17 -7
  84. package/src/cli/tui/components/TuiApp.tsx +65 -5
  85. package/src/cli/tui/discoverWorkflows.ts +7 -41
  86. package/src/cli/tui/imagePicker/ImagePickerOverlay.tsx +72 -0
  87. package/src/cli/tui/imagePicker/ImagePickerSt.ts +288 -0
  88. package/src/cli/tui/imagePicker/fsListing.ts +48 -0
  89. package/src/cli/tui/imagePicker/pickerPrefs.ts +78 -0
  90. package/src/cli/tui/run-tui.tsx +49 -8
  91. package/src/cli/tui/state/DraftsSt.ts +3 -2
  92. package/src/cli/tui/state/ExecSt.ts +108 -12
  93. package/src/cli/tui/state/HostSt.ts +94 -10
  94. package/src/cli/tui/state/LorasSt.ts +14 -36
  95. package/src/cli/tui/state/PickerSt.ts +8 -2
  96. package/src/cli/tui/state/PreviewSt.ts +28 -2
  97. package/src/cli/tui/state/QueueSt.ts +2 -2
  98. package/src/cli/tui/state/SettingsSt.ts +25 -7
  99. package/src/cli/tui/state/TreeSt.ts +139 -36
  100. package/src/cli/tui/state/TuiSt.ts +53 -6
  101. package/src/cli/tui/state/WorkflowsSt.ts +14 -2
  102. package/src/cli/tui/treeRows.ts +165 -0
  103. package/src/exampleAssets.ts +56 -0
  104. package/src/graph/ComfyNode.ts +4 -1
  105. package/src/host/ComfyHost.ts +7 -0
  106. package/src/index.ts +7 -0
  107. package/src/manager/ComfyRegistry.ts +37 -9
  108. package/src/manager/generated/KnownComfyCustomNodeName.ts +23852 -1926
  109. package/src/manager/generated/KnownComfyPluginTitle.ts +6854 -236
  110. package/src/manager/generated/KnownComfyPluginURL.ts +3425 -111
  111. package/src/manager/generated/KnownModel_Base.ts +23 -7
  112. package/src/manager/generated/KnownModel_FileName.ts +421 -0
  113. package/src/manager/generated/KnownModel_Name.ts +421 -0
  114. package/src/manager/generated/KnownModel_SavePath.ts +34 -8
  115. package/src/manager/generated/KnownModel_Type.ts +18 -14
  116. package/src/manager/json/alter-list.json +221 -221
  117. package/src/manager/json/custom-node-list.json +61020 -21946
  118. package/src/manager/json/extension-node-map.json +81077 -31176
  119. package/src/manager/json/github-stats.json +29321 -12601
  120. package/src/manager/json/model-list.json +5935 -4997
  121. package/src/manager/loaders/parseReport.ts +55 -0
  122. package/src/manager/loaders/step1_downloadComfyManagerJSONs.ts +15 -49
  123. package/src/manager/loaders/step2_custom-node-list-loader.ts +38 -83
  124. package/src/manager/loaders/step3_extension-node-map-loader.ts +36 -142
  125. package/src/manager/loaders/step4_model-list-loader.ts +25 -36
  126. package/src/manager/loaders/step5_alter-list-loader.ts +29 -0
  127. package/src/manager/loaders/step6_github-stats-loader.ts +23 -0
  128. package/src/manager/script-update-manager.bun.ts +9 -1
  129. package/src/manager/types/ComfyManagerAlterInfo.ts +13 -0
  130. package/src/manager/types/ComfyManagerFileModelInfo.ts +7 -3
  131. package/src/manager/types/ComfyManagerFilePluginContent.ts +6 -9
  132. package/src/manager/types/ComfyManagerFilePluginList.ts +3 -3
  133. package/src/manager/types/ComfyManagerGithubStats.ts +9 -0
  134. package/src/manager/types/ComfyManagerPluginContentMetadata.ts +2 -3
  135. package/src/manager/types/ComfyManagerPluginInfo.ts +48 -34
  136. package/src/runner/ComfyWorkflowLayout.ts +6 -4
  137. package/src/sdk-generator/ComfySchema.ts +14 -1
  138. package/src/sdk-generator/comfyui-sdk-codegen.ts +15 -0
  139. package/src/sdk-generator/inputWidgetKind.ts +17 -0
  140. package/src/state.ts +7 -1
  141. package/src/vars/ComfyVars.ts +106 -5
  142. package/src/vars/DefinedWorkflow.ts +28 -10
  143. package/dist/DefinedWorkflow-O3ynII3Y.js +0 -598
  144. package/dist/DefinedWorkflow-O3ynII3Y.js.map +0 -1
  145. package/dist/run-tui-BFhba_oG.js.map +0 -1
  146. package/examples/05-comfy-cloud.cflow.ts +0 -67
  147. package/src/utils/tryExtracting.ts +0 -41
package/dist/index.js CHANGED
@@ -1,17 +1,18 @@
1
1
  import fs, { existsSync, mkdirSync, readFileSync, statSync, writeFile, writeFileSync } from "node:fs";
2
- import { basename, dirname, join } from "pathe";
2
+ import { basename, dirname, isAbsolute, join, resolve } from "pathe";
3
3
  import { scope, type } from "arktype";
4
4
  import { nanoid } from "nanoid";
5
5
  import sharp from "sharp";
6
6
  import { imageMeta } from "image-meta";
7
7
  import crypto from "node:crypto";
8
8
  import WebSocket from "ws";
9
+ import { homedir } from "node:os";
9
10
  import { action, makeObservable, observable, runInAction } from "mobx";
10
11
  import https from "node:https";
11
12
  import { stdout } from "node:process";
12
- import { readFileSync as readFileSync$1, writeFileSync as writeFileSync$1 } from "fs";
13
+ import { fileURLToPath } from "node:url";
13
14
  //#region package.json
14
- var version = "1.0.0";
15
+ var version = "1.2.0";
15
16
  //#endregion
16
17
  //#region src/litegraph/LiteGraphLinkID.ts
17
18
  const asLiteGraphLinkID = (id) => id;
@@ -710,6 +711,21 @@ const parseContainer = (template) => {
710
711
  requiredCount: isRecord(input) && isRecord(input["required"]) && Object.keys(input["required"]).length > 0 ? Math.min(min, names.length) : 0
711
712
  };
712
713
  };
714
+ /**
715
+ * the single template sub-input's slot type of an autogrow container
716
+ * (`'IMAGE'` for TextEncodeBooguEdit.images). null when opts are not an
717
+ * autogrow template or the template has several sub-inputs (corpus-absent
718
+ * 2026-07-30, 27/27 single on the cloud catalog) — then codegen emits no
719
+ * typed instance keys and the container stays builderBase territory.
720
+ */
721
+ const containerInstanceSlotType = (opts) => {
722
+ const template = (isRecord(opts) ? opts : null)?.["template"];
723
+ if (!isRecord(template) || !isRecord(template["input"])) return null;
724
+ const subs = flattenInputSections(template["input"]);
725
+ const first = subs[0];
726
+ if (subs.length !== 1 || first == null || typeof first.type !== "string") return null;
727
+ return first.type;
728
+ };
713
729
  const classifyWidgetInput = (p) => {
714
730
  const o = isRecord(p.opts) ? p.opts : null;
715
731
  if (o?.["forceInput"] === true) return { kind: "slot" };
@@ -1222,7 +1238,7 @@ var ComfyNode = class ComfyNode {
1222
1238
  for (const i of this.$schema.inputs) {
1223
1239
  _done.add(i.nameInComfy);
1224
1240
  const value = this.serializeValue(i.nameInComfy, promptExt.inputs[i.nameInComfy]);
1225
- inputs[i.nameInComfy] = value;
1241
+ if (value !== void 0) inputs[i.nameInComfy] = value;
1226
1242
  }
1227
1243
  for (const [nameInComfy, rawVal] of Object.entries(promptExt.inputs)) {
1228
1244
  if (_done.has(nameInComfy)) continue;
@@ -2167,8 +2183,8 @@ function comfyWorkflowAutoLayout(p) {
2167
2183
  if (cols[at]) cols[at].push(node);
2168
2184
  else cols[at] = [node];
2169
2185
  }
2170
- const HSEP = p?.node_hsep ?? 20;
2171
- const VSEP = p?.node_vsep ?? 20;
2186
+ const HSEP = p?.node_hsep ?? 100;
2187
+ const VSEP = p?.node_vsep ?? 40;
2172
2188
  let colX = 0;
2173
2189
  let maxY = 0;
2174
2190
  for (const col of cols) {
@@ -2596,6 +2612,15 @@ function codegenSDK(opts) {
2596
2612
  for (const n of nodes) {
2597
2613
  p(`${escapeJSKey(n.nodeKey)}: {`);
2598
2614
  for (const i of n.inputs) {
2615
+ const kind = classifySchemaInput(i);
2616
+ if (kind.kind === "dynamic-container") {
2617
+ const instType = containerInstanceSlotType(i.opts);
2618
+ if (instType != null) kind.instanceNames.forEach((instName, ix) => {
2619
+ const opt = ix >= kind.requiredCount ? "?" : "";
2620
+ p(` ${escapeJSKey(`${i.nameInComfy}.${instName}`)}${opt}: Accepts[${JSON.stringify(instType)}]`);
2621
+ });
2622
+ continue;
2623
+ }
2599
2624
  const opts_ = typeof i.opts === "string" ? null : i.opts;
2600
2625
  let type = `Accepts[${JSON.stringify(i.typeName)}]`;
2601
2626
  const comboOptions = i.typeName === "COMBO" && Array.isArray(opts_?.options) ? opts_.options.filter((o) => typeof o === "string" || typeof o === "number" || typeof o === "boolean") : [];
@@ -2915,9 +2940,18 @@ var ComfySchema = class {
2915
2940
  comfyUnionDef: slotType
2916
2941
  }).unionName);
2917
2942
  else throw new Error(`invalid schema (${JSON.stringify(slotType)}) for input "${ipt.name}" in node "${nodeNameInComfy}" (type: ${typeof slotType}; expected: Array | string)`);
2943
+ const isAutogrowContainer = typeof slotType === "string" && classifyWidgetInput({
2944
+ name: ipt.name,
2945
+ type: slotType,
2946
+ opts: slotOpts
2947
+ }).kind === "dynamic-container";
2948
+ if (isAutogrowContainer) {
2949
+ const instType = containerInstanceSlotType(slotOpts);
2950
+ if (instType != null) this.knownSlotTypes.add(asComfyNodeSlotTypeName(instType));
2951
+ }
2918
2952
  node.inputs.push({
2919
2953
  slotName: inputSlotName,
2920
- required: ipt.required,
2954
+ required: ipt.required && !isAutogrowContainer,
2921
2955
  nameInComfy: inputNameInComfy,
2922
2956
  nameInComfyEscaped: escapeJSKey(inputNameInComfy),
2923
2957
  typeName: inputTypeName,
@@ -3881,16 +3915,38 @@ const DEFAULT_SIZE_PRESETS = [
3881
3915
  height: 1344
3882
3916
  }
3883
3917
  ];
3884
- /** width/height picker: presets + free `WxH` entry */
3918
+ /** width/height picker: presets + free `WxH` entry + optionally the LIVE
3919
+ * size of a linked image var (his ask 2026-07-30: the widget shows
3920
+ * `WxH size of image '<name>'` as a pickable row) */
3885
3921
  var SizeVar = class extends ComfyVar {
3886
3922
  constructor(defaultValue = {
3887
3923
  width: 1024,
3888
3924
  height: 1024
3889
- }, presets = DEFAULT_SIZE_PRESETS, label) {
3925
+ }, presets = DEFAULT_SIZE_PRESETS, label, imageVar) {
3890
3926
  super(defaultValue, label);
3891
3927
  this.presets = presets;
3928
+ this.imageVar = imageVar;
3892
3929
  this.kind = "size";
3893
3930
  }
3931
+ /** current dimensions of the linked image var — null when no link, unset
3932
+ * path, or an unreadable/undecodable file (those errors belong to the
3933
+ * image var itself, the size row simply disappears) */
3934
+ imageSize() {
3935
+ const iv = this.imageVar;
3936
+ if (iv == null || iv.value === "") return null;
3937
+ try {
3938
+ const abs = iv.absPath();
3939
+ const meta = imageMeta(new Uint8Array(readFileSync(abs)));
3940
+ if (meta.width == null || meta.height == null) return null;
3941
+ return {
3942
+ width: meta.width,
3943
+ height: meta.height,
3944
+ name: basename(abs)
3945
+ };
3946
+ } catch {
3947
+ return null;
3948
+ }
3949
+ }
3894
3950
  /** accepts '1024x768' / '1024×768' / a preset label */
3895
3951
  parse(raw) {
3896
3952
  const m = raw.trim().match(/^(\d+)\s*[x×]\s*(\d+)$/);
@@ -3917,7 +3973,73 @@ var SizeVar = class extends ComfyVar {
3917
3973
  return `${width}×${height}${hit ? ` (${hit.label})` : ""}`;
3918
3974
  }
3919
3975
  };
3920
- /** the var constructors: v.text / v.prompt / v.int / v.float / v.seed / v.toggle / v.choice / v.loras / v.size */
3976
+ const DEFAULT_IMAGE_EXTENSIONS = [
3977
+ "png",
3978
+ "jpg",
3979
+ "jpeg",
3980
+ "webp",
3981
+ "gif"
3982
+ ];
3983
+ /** empty image var consumed at build time — typed so drivers surface it apart from real crashes */
3984
+ var ImageVarEmptyError = class extends Error {
3985
+ constructor(varName) {
3986
+ super(`image var '${varName}' is empty — pick a file (TUI: activate the var; script: .set('/path/to/image.png'))`);
3987
+ this.varName = varName;
3988
+ }
3989
+ };
3990
+ /** trim + expand a leading `~/` — every ImageVar write funnels through this */
3991
+ function expandUserPath(raw) {
3992
+ const trimmed = raw.trim();
3993
+ return trimmed.startsWith("~/") ? join(homedir(), trimmed.slice(2)) : trimmed;
3994
+ }
3995
+ /**
3996
+ * a local image path. The VALUE is a PLAIN PATH STRING — text-encodable,
3997
+ * drafts persist it verbatim (toJSON = the string), hand-editable in the
3998
+ * draft json. Empty = unset: outValue()/absPath() throw ImageVarEmptyError,
3999
+ * so a build never runs on a silent placeholder. The TUI opens the image
4000
+ * picker overlay for kind 'image'.
4001
+ */
4002
+ var ImageVar = class extends ComfyVar {
4003
+ constructor(defaultValue, opts = {}) {
4004
+ super(expandUserPath(defaultValue), opts.label);
4005
+ this.opts = opts;
4006
+ this.kind = "image";
4007
+ }
4008
+ /** what the picker lists (lowercase, no dots) */
4009
+ get extensions() {
4010
+ return this.opts.extensions ?? DEFAULT_IMAGE_EXTENSIONS;
4011
+ }
4012
+ set(value) {
4013
+ return super.set(expandUserPath(value));
4014
+ }
4015
+ parse(raw) {
4016
+ this.set(raw);
4017
+ return true;
4018
+ }
4019
+ isSet() {
4020
+ return this.value !== "";
4021
+ }
4022
+ emptyError() {
4023
+ return new ImageVarEmptyError(this.name ?? this.label ?? "image");
4024
+ }
4025
+ /** the ONE resolution helper: absolute kept as-is, relative resolved against opts.folder, else cwd */
4026
+ absPath() {
4027
+ if (!this.isSet()) throw this.emptyError();
4028
+ if (isAbsolute(this.value)) return this.value;
4029
+ return resolve(this.opts.folder ?? process.cwd(), this.value);
4030
+ }
4031
+ /** empty = unset: the build fails LOUD here (varValues calls outValue) */
4032
+ outValue() {
4033
+ if (!this.isSet()) throw this.emptyError();
4034
+ return this.value;
4035
+ }
4036
+ display() {
4037
+ if (!this.isSet()) return "(unset) pick a file";
4038
+ const home = homedir();
4039
+ return this.value.startsWith(`${home}/`) ? `~${this.value.slice(home.length)}` : this.value;
4040
+ }
4041
+ };
4042
+ /** the var constructors: v.text / v.prompt / v.int / v.float / v.seed / v.toggle / v.choice / v.loras / v.size / v.image */
3921
4043
  const v = {
3922
4044
  text: (defaultValue, label) => new TextVar(defaultValue, label),
3923
4045
  prompt: (defaultValue, opts = {}) => new PromptVar(defaultValue, opts),
@@ -3927,7 +4049,8 @@ const v = {
3927
4049
  toggle: (defaultValue, label) => new ToggleVar(defaultValue, label),
3928
4050
  choice: (choices, defaultValue, label) => new ChoiceVar(choices, defaultValue, label),
3929
4051
  loras: (options, initial = {}, label) => new LorasVar(options, initial, label),
3930
- size: (defaultValue, opts = {}) => new SizeVar(defaultValue, opts.presets, opts.label)
4052
+ size: (defaultValue, opts = {}) => new SizeVar(defaultValue, opts.presets, opts.label, opts.image),
4053
+ image: (defaultValue, opts = {}) => new ImageVar(defaultValue, opts)
3931
4054
  };
3932
4055
  function varValues(vars) {
3933
4056
  const out = {};
@@ -3951,7 +4074,10 @@ var DefinedWorkflow = class {
3951
4074
  this.lastWorkflow = null;
3952
4075
  this.lastExecution = null;
3953
4076
  this.vars = isVarsThunk(spec.vars) ? spec.vars(v) : spec.vars;
3954
- for (const [, varDef] of this.entries()) varDef.bindHost?.(this.host);
4077
+ for (const [key, varDef] of this.entries()) {
4078
+ varDef.name = key;
4079
+ varDef.bindHost?.(this.host);
4080
+ }
3955
4081
  }
3956
4082
  /** [name, var] pairs, for drivers that enumerate the knobs */
3957
4083
  entries() {
@@ -3962,10 +4088,12 @@ var DefinedWorkflow = class {
3962
4088
  * (set by run()) fires each var's afterRun() right after snapshotting the
3963
4089
  * values — atomically, before any await — so the graph uses this run's seed
3964
4090
  * while the var moves to the next (queued runs get distinct seeds; a bare
3965
- * build() for copy/export never advances).
4091
+ * build() for copy/export never advances). `p.host` substitutes the host
4092
+ * the graph is built against (TUI host override): node/model availability
4093
+ * there surfaces as workflow.problems / server validation, by design.
3966
4094
  */
3967
4095
  async build(p = {}) {
3968
- const wf = this.host.workflow({ id: this.spec.id });
4096
+ const wf = (p.host ?? this.host).workflow({ id: this.spec.id });
3969
4097
  const values = varValues(this.vars);
3970
4098
  if (p.advance) for (const varDef of Object.values(this.vars)) varDef.afterRun();
3971
4099
  await this.spec.build(wf.builder, values, wf);
@@ -3973,10 +4101,20 @@ var DefinedWorkflow = class {
3973
4101
  return wf;
3974
4102
  }
3975
4103
  /** build a fresh graph from the current var values, send it, wait for outputs.
3976
- * connects first (idempotent) — modules can import offline from the schema cache */
4104
+ * connects first (idempotent) — modules can import offline from the schema cache.
4105
+ * `settings.host` runs against THAT host instead of the defining one. */
3977
4106
  async run(settings = {}) {
3978
- await this.host.connect();
3979
- const execution = await (await this.build({ advance: true })).run(settings);
4107
+ const host = settings.host ?? this.host;
4108
+ await host.connect();
4109
+ const execution = await (await this.build({
4110
+ advance: true,
4111
+ host
4112
+ })).run({
4113
+ saveFormat: settings.saveFormat,
4114
+ idMode: settings.idMode,
4115
+ log: settings.log,
4116
+ onProgress: settings.onProgress
4117
+ });
3980
4118
  this.lastExecution = execution;
3981
4119
  return execution;
3982
4120
  }
@@ -4233,6 +4371,7 @@ var ComfyHost = class {
4233
4371
  this.comfySessionId = "temp";
4234
4372
  this._unknownBinaryFrameTypes = /* @__PURE__ */ new Set();
4235
4373
  this.status = null;
4374
+ this.lastWsMessageAt = null;
4236
4375
  this.base = parseHostBase(this.data);
4237
4376
  /** folder where file related to the host config will be cached */
4238
4377
  this.cacheFolder = comfyts.resolveFromHosts(this.data.id);
@@ -4386,6 +4525,7 @@ var ComfyHost = class {
4386
4525
  prompt.onPromptRelatedMessage(msg);
4387
4526
  }
4388
4527
  onMessage(e) {
4528
+ this.lastWsMessageAt = Date.now();
4389
4529
  if (this.data.onWsMessageAny) this.data.onWsMessageAny(e);
4390
4530
  if (e.data instanceof ArrayBuffer) {
4391
4531
  const frame = parseBinaryWsFrame(e.data);
@@ -4509,31 +4649,19 @@ function downloadFile(url, outputPath, logPrefix = " - ") {
4509
4649
  }
4510
4650
  //#endregion
4511
4651
  //#region src/manager/loaders/step1_downloadComfyManagerJSONs.ts
4652
+ const MANAGER_RAW_BASE = "https://raw.githubusercontent.com/Comfy-Org/ComfyUI-Manager/main";
4653
+ const MANAGER_MIRROR_FILES = [
4654
+ "custom-node-list.json",
4655
+ "model-list.json",
4656
+ "extension-node-map.json",
4657
+ "alter-list.json",
4658
+ "github-stats.json"
4659
+ ];
4512
4660
  async function DownloadComfyManagerJSONs() {
4513
- await SYNC_modelList();
4514
- await SYNC_customNodeList();
4515
- await SYNC_extensionNodeMap();
4516
- await SYNC_alterList();
4517
- await SYNC_githubStats();
4518
- async function SYNC_modelList() {
4519
- await downloadFile("https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/model-list.json", "src/manager/json/model-list.json", `- downloading ynchronizing model-list.json...`);
4520
- console.log(` saved at ${ansi.blue("src/manager/json/model-list.json")}`);
4521
- }
4522
- async function SYNC_customNodeList() {
4523
- 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...`);
4524
- console.log(` saved at ${ansi.blue("src/manager/json/custom-node-list.json")}`);
4525
- }
4526
- async function SYNC_extensionNodeMap() {
4527
- 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...`);
4528
- console.log(` saved at ${ansi.blue("src/manager/json/extension-node-map.json")}`);
4529
- }
4530
- async function SYNC_alterList() {
4531
- await downloadFile("https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/alter-list.json", "src/manager/json/alter-list.json", `- downloading synchronizing alter-list.json...`);
4532
- console.log(` saved at ${ansi.blue("src/manager/json/alter-list.json")}`);
4533
- }
4534
- async function SYNC_githubStats() {
4535
- 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...`);
4536
- console.log(` saved at ${ansi.blue("src/manager/json/github-stats.json")}`);
4661
+ for (const file of MANAGER_MIRROR_FILES) {
4662
+ const dest = `src/manager/json/${file}`;
4663
+ await downloadFile(`${MANAGER_RAW_BASE}/${file}`, dest, `- downloading ${file}...`);
4664
+ console.log(` saved at ${ansi.blue(dest)}`);
4537
4665
  }
4538
4666
  }
4539
4667
  //#endregion
@@ -4541,24 +4669,6 @@ async function DownloadComfyManagerJSONs() {
4541
4669
  const githubRegexpV1 = /https:\/\/github.com\/(.+?)\/(.+?)\/?/;
4542
4670
  const githubRegexpV2 = /https:\/\/github.com\/(.+?)\/([a-zA-Z0-9-_]+)?/;
4543
4671
  //#endregion
4544
- //#region src/utils/tryExtracting.ts
4545
- function tryRecovering({ verbose = 0, property, hacks, onFail, onSuccess }) {
4546
- if (verbose >= 2) console.log(`[🔶] trying to find a suitable value for ${property}...`);
4547
- for (const hack of hacks) {
4548
- if (verbose >= 2) console.log(` > trying to use ${hack.attempt}...`);
4549
- const value = hack.fn();
4550
- if (value != null) {
4551
- if (verbose >= (hack.level ?? 1)) {
4552
- if (verbose) console.log(` 🔶 recovered ${property} using ${hack.attempt}.`);
4553
- }
4554
- onSuccess?.(property, value);
4555
- return value;
4556
- }
4557
- }
4558
- onFail?.(property);
4559
- throw new Error(`[🔶] ${property} could not be recovered`);
4560
- }
4561
- //#endregion
4562
4672
  //#region src/manager/json/custom-node-list.extra.ts
4563
4673
  const ComfyPluginExtra = [{
4564
4674
  id: "TEMP_ComfyUI-BRIA_AI-RMBG",
@@ -4570,43 +4680,111 @@ const ComfyPluginExtra = [{
4570
4680
  description: "better rembg ?"
4571
4681
  }];
4572
4682
  //#endregion
4683
+ //#region src/manager/loaders/parseReport.ts
4684
+ /** root shape of a manager mirror file is broken: nothing to salvage, fail loud */
4685
+ var ManagerParseError = class extends Error {
4686
+ constructor(file, detail) {
4687
+ super(`🔴 [manager] ${file} root shape invalid: ${detail}`);
4688
+ this.file = file;
4689
+ this.detail = detail;
4690
+ this.name = "ManagerParseError";
4691
+ }
4692
+ };
4693
+ var FileParseCounter = class {
4694
+ constructor(file) {
4695
+ this.file = file;
4696
+ this.total = 0;
4697
+ this.accepted = 0;
4698
+ this.skipped = /* @__PURE__ */ new Map();
4699
+ }
4700
+ ok() {
4701
+ this.total++;
4702
+ this.accepted++;
4703
+ }
4704
+ skip(reason, firstError) {
4705
+ this.total++;
4706
+ const prev = this.skipped.get(reason);
4707
+ if (prev == null) this.skipped.set(reason, {
4708
+ count: 1,
4709
+ firstError
4710
+ });
4711
+ else prev.count++;
4712
+ }
4713
+ };
4714
+ /** per-file row accounting for the manager mirror parse; printed on every registry build so upstream drift stays visible */
4715
+ var ManagerParseReport = class {
4716
+ constructor() {
4717
+ this.counters = [];
4718
+ }
4719
+ file(name) {
4720
+ const counter = new FileParseCounter(name);
4721
+ this.counters.push(counter);
4722
+ return counter;
4723
+ }
4724
+ print() {
4725
+ console.log(ansi.bold(`[📘 registry] parse report:`));
4726
+ for (const c of this.counters) {
4727
+ const skippedTotal = [...c.skipped.values()].reduce((acc, cur) => acc + cur.count, 0);
4728
+ const headline = ` ${c.file}: ${c.total} rows, ${c.accepted} accepted, ${skippedTotal} skipped`;
4729
+ console.log(skippedTotal === 0 ? headline : ansi.red(headline));
4730
+ for (const [reason, info] of c.skipped) console.log(ansi.red(` - ${reason} x${info.count}, first: ${info.firstError}`));
4731
+ }
4732
+ }
4733
+ };
4734
+ //#endregion
4573
4735
  //#region src/manager/types/ComfyManagerFilePluginList.ts
4574
- const ComfyManagerFilePluginList_ark = type({ custom_nodes: type({
4736
+ const ComfyManagerFilePluginListRoot_ark = type({ custom_nodes: "unknown[]" });
4737
+ //#endregion
4738
+ //#region src/manager/types/ComfyManagerPluginInfo.ts
4739
+ const ComfyManagerRawPluginInfo_ark = type({
4575
4740
  author: "string",
4576
4741
  title: type.string.as(),
4577
4742
  reference: "string",
4578
4743
  files: type.string.as().array(),
4579
4744
  install_type: "string",
4580
4745
  description: "string",
4581
- id: type.string.as(),
4746
+ "id?": type.string.as(),
4582
4747
  "preemptions?": "string[]",
4583
4748
  "pip?": "string[]",
4584
4749
  "nodename_pattern?": "string",
4585
4750
  "apt_dependency?": "string[]",
4586
4751
  "js_path?": "string",
4587
4752
  "version?": "string",
4588
- "tags?": "string[]"
4589
- }).array() });
4753
+ "tags?": "string[]",
4754
+ "reference2?": "string",
4755
+ "category?": "string",
4756
+ "name?": "string",
4757
+ "license?": "string",
4758
+ "nickname?": "string",
4759
+ "stars?": "number",
4760
+ "last_update?": "string",
4761
+ "badges?": "string[]",
4762
+ "dependencies?": "string[]"
4763
+ });
4590
4764
  //#endregion
4591
4765
  //#region src/manager/loaders/step2_custom-node-list-loader.ts
4592
4766
  const _getKnownPlugins = (DB) => {
4767
+ const counter = DB.report.file("custom-node-list.json");
4593
4768
  let totalFileSeen = 0;
4594
- let totalPluginSeen = 0;
4595
- const knownPluginFile = JSON.parse(readFileSync$1("src/manager/json/custom-node-list.json", "utf8"));
4596
- const knownPluginList = knownPluginFile.custom_nodes.concat(ComfyPluginExtra);
4597
- for (const plugin of knownPluginList) {
4598
- plugin.id ??= tryRecoveringPluginId(plugin, 1);
4599
- plugin.title ??= tryRecoveringPluginTitle(plugin, 1);
4600
- }
4601
- const res = ComfyManagerFilePluginList_ark(knownPluginFile);
4602
- if (DB.opts.check) {
4769
+ const root = ComfyManagerFilePluginListRoot_ark(JSON.parse(readFileSync("src/manager/json/custom-node-list.json", "utf8")));
4770
+ if (root instanceof type.errors) throw new ManagerParseError("custom-node-list.json", root.summary);
4771
+ const canonical = [];
4772
+ for (const row of root.custom_nodes) {
4773
+ const res = ComfyManagerRawPluginInfo_ark(row);
4603
4774
  if (res instanceof type.errors) {
4604
- printArkResultInConsole(res);
4605
- process.exit(1);
4775
+ counter.skip("schema", res.summary);
4776
+ continue;
4606
4777
  }
4778
+ const plugin = normalizePluginInfo(res);
4779
+ if (plugin == null) {
4780
+ counter.skip("id-unrecoverable", res.reference);
4781
+ continue;
4782
+ }
4783
+ canonical.push(plugin);
4784
+ counter.ok();
4607
4785
  }
4786
+ const knownPluginList = canonical.concat(ComfyPluginExtra);
4608
4787
  for (const plugin of knownPluginList) {
4609
- totalPluginSeen++;
4610
4788
  if (DB.opts.check && DB.plugins_byTitle.has(plugin.title)) console.log(` ❌ plugin.title: "${plugin.title}" is duplicated`);
4611
4789
  DB.plugins_byTitle.set(plugin.title, plugin);
4612
4790
  for (const pluginURI of plugin.files) {
@@ -4617,7 +4795,7 @@ const _getKnownPlugins = (DB) => {
4617
4795
  }
4618
4796
  if (DB.opts.genTypes) {
4619
4797
  let out1 = "";
4620
- const allPluginsSortedByTitles = [...DB.plugins_byTitle.values()].sort((a, b) => (a.title ?? "❌missing-title").toLowerCase().localeCompare((b.title ?? "❌missing-title").toLowerCase()));
4798
+ const allPluginsSortedByTitles = [...DB.plugins_byTitle.values()].sort((a, b) => a.title.toLowerCase().localeCompare(b.title.toLowerCase()));
4621
4799
  out1 += "// prettier-ignore\n";
4622
4800
  out1 += "export type KnownComfyPluginTitle =\n";
4623
4801
  for (const plugin of allPluginsSortedByTitles) {
@@ -4626,7 +4804,7 @@ const _getKnownPlugins = (DB) => {
4626
4804
  }
4627
4805
  out1 += "\n";
4628
4806
  const out1Path = "src/manager/generated/KnownComfyPluginTitle.ts";
4629
- writeFileSync$1(out1Path, out1 + "\n", "utf-8");
4807
+ writeFileSync(out1Path, out1 + "\n", "utf-8");
4630
4808
  console.log(` > generated: ${ansi.blue.underline(out1Path)}`);
4631
4809
  let out2 = "";
4632
4810
  const sortedFileNames = [...DB.plugins_byFile.keys()].sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
@@ -4634,47 +4812,33 @@ const _getKnownPlugins = (DB) => {
4634
4812
  out2 += "export type KnownComfyPluginURL =\n";
4635
4813
  for (const fileName of sortedFileNames) out2 += ` | ${JSON.stringify(fileName)}\n`;
4636
4814
  const out2Path = "src/manager/generated/KnownComfyPluginURL.ts";
4637
- writeFileSync$1(out2Path, out2, "utf-8");
4815
+ writeFileSync(out2Path, out2, "utf-8");
4638
4816
  console.log(` > generated: ${ansi.blue.underline(out2Path)}`);
4639
4817
  }
4640
4818
  if (DB.opts.check) {
4641
- console.log(` - ${totalPluginSeen} CustomNodes in file`);
4819
+ console.log(` - ${knownPluginList.length} CustomNodes in file`);
4642
4820
  console.log(` - ${DB.plugins_byTitle.size} CustomNodes registered in map`);
4643
4821
  console.log(` - ${totalFileSeen} CustomNodes-File Seen`);
4644
4822
  console.log(` - ${DB.plugins_byFile.size} CustomNodes-File registered in map`);
4645
4823
  }
4646
4824
  };
4647
- function tryRecoveringPluginTitle(plugin, verbose = 0) {
4648
- return tryRecovering({
4649
- property: "plugin.title",
4650
- verbose,
4651
- hacks: [{
4652
- attempt: "id",
4653
- fn: () => plugin.id
4654
- }, {
4655
- attempt: "github repo name",
4656
- fn: () => plugin.reference
4657
- }]
4658
- });
4659
- }
4660
- function tryRecoveringPluginId(plugin, verbose = 0) {
4661
- return tryRecovering({
4662
- property: "plugin.id",
4663
- verbose,
4664
- hacks: [{
4665
- level: 2,
4666
- attempt: "title",
4667
- fn: () => plugin.title
4668
- }, {
4669
- attempt: "github repo name",
4670
- fn: () => plugin.reference.match(githubRegexpV1)?.[2]
4671
- }]
4672
- });
4825
+ /**
4826
+ * raw → canonical: recover the missing `id` (absent on ~76% of upstream rows)
4827
+ * from the title, else the github repo name. null = unrecoverable, caller
4828
+ * reports and skips the row.
4829
+ */
4830
+ function normalizePluginInfo(p) {
4831
+ const id = p.id ?? p.title ?? p.reference.match(githubRegexpV1)?.[2];
4832
+ if (id == null) return null;
4833
+ return {
4834
+ ...p,
4835
+ id
4836
+ };
4673
4837
  }
4674
4838
  //#endregion
4675
4839
  //#region src/manager/types/ComfyManagerPluginContentMetadata.ts
4676
4840
  const ComfyManagerPluginContentMetadata_ark = type({
4677
- title_aux: type.string.or(type.null),
4841
+ "title_aux?": type.string.or(type.null),
4678
4842
  "author?": "string",
4679
4843
  "nickname?": "string",
4680
4844
  "description?": "string",
@@ -4688,42 +4852,37 @@ const ComfyManagerPluginContentNodeName_ark = type.string.as();
4688
4852
  type("string");
4689
4853
  //#endregion
4690
4854
  //#region src/manager/types/ComfyManagerFilePluginContent.ts
4691
- const ComfyManagerFilePluginContent_ark = type.Record("string", type([ComfyManagerPluginContentNodeName_ark.array(), ComfyManagerPluginContentMetadata_ark]));
4855
+ const ComfyManagerExtensionNodeMapEntry_ark = type([ComfyManagerPluginContentNodeName_ark.array(), ComfyManagerPluginContentMetadata_ark]);
4692
4856
  //#endregion
4693
4857
  //#region src/manager/loaders/step3_extension-node-map-loader.ts
4694
4858
  const _getCustomNodeRegistry = (DB) => {
4859
+ const counter = DB.report.file("extension-node-map.json");
4695
4860
  let totalCustomNodeSeen = 0;
4696
- const extensionNodeMapFile = JSON.parse(readFileSync("src/manager/json/extension-node-map.json", "utf8"));
4697
- const res = ComfyManagerFilePluginContent_ark(extensionNodeMapFile);
4698
- if (DB.opts.check) {
4861
+ const raw = JSON.parse(readFileSync("src/manager/json/extension-node-map.json", "utf8"));
4862
+ const root = type("Record<string, unknown>")(raw);
4863
+ if (root instanceof type.errors) throw new ManagerParseError("extension-node-map.json", root.summary);
4864
+ for (const [url, value] of Object.entries(root)) {
4865
+ const res = ComfyManagerExtensionNodeMapEntry_ark(value);
4699
4866
  if (res instanceof type.errors) {
4700
- printArkResultInConsole(res);
4701
- process.exit(1);
4867
+ counter.skip("schema", `${url}: ${res.summary}`);
4868
+ continue;
4702
4869
  }
4703
- }
4704
- const enmEntries = Object.entries(extensionNodeMapFile).map((x) => {
4705
- const url = x[0];
4706
- const [comfyNodeNames, meta] = x[1];
4707
- const confyPlugin = DB.plugins_byFile.get(url);
4708
- if (confyPlugin == null) throw new Error(`[❌] plugin not found for ${url}`);
4709
- return {
4710
- url,
4711
- comfyNodeNames,
4712
- meta,
4713
- plugin: confyPlugin,
4714
- pythonModule: reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(confyPlugin, url, meta)
4715
- };
4716
- });
4717
- for (const enmEntry of enmEntries) {
4718
- totalCustomNodeSeen += enmEntry.comfyNodeNames.length;
4719
- const plugin = enmEntry.plugin;
4870
+ const plugin = DB.plugins_byFile.get(url);
4871
+ if (plugin == null) {
4872
+ counter.skip("unknown-plugin-url", url);
4873
+ continue;
4874
+ }
4875
+ counter.ok();
4876
+ const comfyNodeNames = res[0];
4877
+ totalCustomNodeSeen += comfyNodeNames.length;
4878
+ const pythonModule = reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(plugin);
4720
4879
  const nodesInPlugin = DB.customNodes_byPluginName.get(plugin.title) ?? [];
4721
4880
  DB.customNodes_byPluginName.set(plugin.title, nodesInPlugin);
4722
- for (const nodeNameInComfy of enmEntry.comfyNodeNames) {
4723
- const nodeKey = toQualifiedNodeKey(enmEntry.pythonModule, nodeNameInComfy);
4724
- const prevEntry2 = DB.plugins_byNodeKey.get(nodeKey);
4725
- if (prevEntry2 == null) DB.plugins_byNodeKey.set(nodeKey, [plugin]);
4726
- else prevEntry2.push(plugin);
4881
+ for (const nodeNameInComfy of comfyNodeNames) {
4882
+ const nodeKey = toQualifiedNodeKey(pythonModule, nodeNameInComfy);
4883
+ const prevEntry = DB.plugins_byNodeKey.get(nodeKey);
4884
+ if (prevEntry == null) DB.plugins_byNodeKey.set(nodeKey, [plugin]);
4885
+ else prevEntry.push(plugin);
4727
4886
  nodesInPlugin.push(nodeKey);
4728
4887
  }
4729
4888
  }
@@ -4732,23 +4891,22 @@ const _getCustomNodeRegistry = (DB) => {
4732
4891
  const sortedNodeKeys = [...DB.plugins_byNodeKey.keys()].sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
4733
4892
  out += "// prettier-ignore\n";
4734
4893
  out += "export type KnownComfyCustomNodeName =\n";
4735
- for (const nodeName of sortedNodeKeys) {
4736
- if (nodeName === "sd_perturbed_attention.PerturbedAttention") console.log(`[🤠] 🔴`, DB.plugins_byNodeKey.get(nodeName));
4737
- out += ` | ${JSON.stringify(nodeName)}\n`;
4738
- }
4894
+ for (const nodeName of sortedNodeKeys) out += ` | ${JSON.stringify(nodeName)}\n`;
4739
4895
  out += "\n";
4740
4896
  const outPath = "src/manager/generated/KnownComfyCustomNodeName.ts";
4741
4897
  writeFileSync(outPath, out + "\n", "utf-8");
4742
4898
  console.log(` > generated: ${ansi.blue.underline(outPath)}`);
4743
4899
  }
4744
- if (DB.opts.check) console.log(` - ${totalCustomNodeSeen} CustomNodes unique names processed`);
4900
+ if (DB.opts.check) {
4901
+ console.log(` - ${totalCustomNodeSeen} CustomNodes names processed`);
4902
+ console.log(` - ${DB.plugins_byNodeKey.size} unique node keys registered in map`);
4903
+ }
4745
4904
  };
4746
- function reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(plugin, _url, _meta) {
4905
+ function reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(plugin) {
4747
4906
  if (plugin.id === "nodes" && plugin.reference === "https://github.com/comfyanonymous/ComfyUI") return "nodes";
4748
4907
  const repoName = plugin.reference.match(githubRegexpV2)?.[2];
4749
4908
  if (repoName) return `custom_nodes.${repoName}`;
4750
- if (plugin.id) return `custom_nodes.${plugin.id}`;
4751
- return "🔴";
4909
+ return `custom_nodes.${plugin.id}`;
4752
4910
  }
4753
4911
  //#endregion
4754
4912
  //#region src/manager/json/model-list.extra.ts
@@ -4772,6 +4930,9 @@ const extraModels = { models: [{
4772
4930
  url: "https://huggingface.co/gemasai/4x_NMKD-Siax_200k/resolve/main/4xRealWebPhoto_v4_dat2.pth"
4773
4931
  }] };
4774
4932
  //#endregion
4933
+ //#region src/manager/types/ComfyManagerFileModelInfo.ts
4934
+ const ComfyManagerFileModelInfoRoot_ark = type({ models: "unknown[]" });
4935
+ //#endregion
4775
4936
  //#region src/manager/types/ComfyManagerModelInfo.ts
4776
4937
  const ComfyManagerModelInfo_ark = type({
4777
4938
  name: type.string.as(),
@@ -4787,20 +4948,21 @@ const ComfyManagerModelInfo_ark = type({
4787
4948
  //#endregion
4788
4949
  //#region src/manager/loaders/step4_model-list-loader.ts
4789
4950
  const _getKnownModels = (DB) => {
4790
- const knownModelList = JSON.parse(readFileSync$1("src/manager/json/model-list.json", "utf8")).models.concat(extraModels.models);
4791
- let hasErrors = false;
4792
- for (const modelInfo of knownModelList) {
4793
- DB.knownModels.set(modelInfo.name, modelInfo);
4794
- if (!hasErrors && DB.opts.check) {
4795
- const res = ComfyManagerModelInfo_ark(modelInfo);
4796
- if (res instanceof type.errors) {
4797
- const errors = res;
4798
- console.error(`❌ model doesn't match schema:`, modelInfo);
4799
- printArkResultInConsole(errors);
4800
- hasErrors = true;
4801
- }
4951
+ const counter = DB.report.file("model-list.json");
4952
+ const root = ComfyManagerFileModelInfoRoot_ark(JSON.parse(readFileSync("src/manager/json/model-list.json", "utf8")));
4953
+ if (root instanceof type.errors) throw new ManagerParseError("model-list.json", root.summary);
4954
+ const canonical = [];
4955
+ for (const row of root.models) {
4956
+ const res = ComfyManagerModelInfo_ark(row);
4957
+ if (res instanceof type.errors) {
4958
+ counter.skip("schema", res.summary);
4959
+ continue;
4802
4960
  }
4961
+ canonical.push(res);
4962
+ counter.ok();
4803
4963
  }
4964
+ const knownModelList = canonical.concat(extraModels.models);
4965
+ for (const modelInfo of knownModelList) DB.knownModels.set(modelInfo.name, modelInfo);
4804
4966
  if (DB.opts.genTypes) {
4805
4967
  let out1 = "";
4806
4968
  const uniqCategories = knownModelList.reduce((acc, cur) => {
@@ -4816,7 +4978,7 @@ const _getKnownModels = (DB) => {
4816
4978
  for (const [cat, count] of Object.entries(uniqCategories)) out1 += ` ${JSON.stringify(cat).padEnd(20)}, // x ${count.toString().padStart(3)}\n`;
4817
4979
  out1 += "]\n";
4818
4980
  const out1Path = "src/manager/generated/KnownModel_Type.ts";
4819
- writeFileSync$1(out1Path, out1 + "\n", "utf-8");
4981
+ writeFileSync(out1Path, out1 + "\n", "utf-8");
4820
4982
  console.log(` > generated: ${ansi.blue.underline(out1Path)}`);
4821
4983
  let out4 = "";
4822
4984
  const uniqSavePath = knownModelList.reduce((acc, cur) => {
@@ -4832,7 +4994,7 @@ const _getKnownModels = (DB) => {
4832
4994
  for (const [cat, count] of Object.entries(uniqSavePath)) out4 += ` ${JSON.stringify(cat).padEnd(50)}, // x ${count.toString().padStart(3)}\n`;
4833
4995
  out4 += "]\n";
4834
4996
  const out4Path = "src/manager/generated/KnownModel_SavePath.ts";
4835
- writeFileSync$1(out4Path, out4 + "\n", "utf-8");
4997
+ writeFileSync(out4Path, out4 + "\n", "utf-8");
4836
4998
  console.log(` > generated: ${ansi.blue.underline(out4Path)}`);
4837
4999
  let out2 = "";
4838
5000
  const uniqBases = knownModelList.reduce((acc, cur) => {
@@ -4849,7 +5011,7 @@ const _getKnownModels = (DB) => {
4849
5011
  for (const [cat, count] of Object.entries(uniqBases)) out2 += ` ${JSON.stringify(cat).padEnd(20)}, // x ${count.toString().padStart(3)}\n`;
4850
5012
  out2 += "]\n";
4851
5013
  const out2Path = "src/manager/generated/KnownModel_Base.ts";
4852
- writeFileSync$1(out2Path, out2 + "\n", "utf-8");
5014
+ writeFileSync(out2Path, out2 + "\n", "utf-8");
4853
5015
  console.log(` > generated: ${ansi.blue.underline(out2Path)}`);
4854
5016
  let out3 = "";
4855
5017
  const sortedModels = knownModelList.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()));
@@ -4864,7 +5026,7 @@ const _getKnownModels = (DB) => {
4864
5026
  }
4865
5027
  out3 += "\n";
4866
5028
  const out3Path = "src/manager/generated/KnownModel_Name.ts";
4867
- writeFileSync$1(out3Path, out3 + "\n", "utf-8");
5029
+ writeFileSync(out3Path, out3 + "\n", "utf-8");
4868
5030
  console.log(` > generated: ${ansi.blue.underline(out3Path)}`);
4869
5031
  let out99 = "";
4870
5032
  out99 += `// prettier-ignore\n`;
@@ -4878,20 +5040,78 @@ const _getKnownModels = (DB) => {
4878
5040
  }
4879
5041
  out99 += "\n";
4880
5042
  const out99Path = "src/manager/generated/KnownModel_FileName.ts";
4881
- writeFileSync$1(out99Path, out99 + "\n", "utf-8");
5043
+ writeFileSync(out99Path, out99 + "\n", "utf-8");
4882
5044
  console.log(` > generated: ${ansi.blue.underline(out99Path)}`);
4883
5045
  }
4884
5046
  if (DB.opts.check) {
4885
5047
  console.log(`${knownModelList.length} models found`);
4886
5048
  console.log(`${DB.knownModels.size} models registered map`);
4887
5049
  if (knownModelList.length !== DB.knownModels.size) console.log(`❌ some models are either duplicated or have overlapping indexing keys`);
4888
- if (hasErrors) console.log(`❌ some models don't match schema`);
4889
- else console.log(`✅ all models match schema`);
5050
+ }
5051
+ };
5052
+ //#endregion
5053
+ //#region src/manager/types/ComfyManagerAlterInfo.ts
5054
+ const ComfyManagerAlterInfo_ark = type({
5055
+ id: "string",
5056
+ tags: "string",
5057
+ description: "string"
5058
+ });
5059
+ const ComfyManagerFileAlterListRoot_ark = type({ items: "unknown[]" });
5060
+ //#endregion
5061
+ //#region src/manager/loaders/step5_alter-list-loader.ts
5062
+ const _getAlterList = (DB) => {
5063
+ const counter = DB.report.file("alter-list.json");
5064
+ const root = ComfyManagerFileAlterListRoot_ark(JSON.parse(readFileSync("src/manager/json/alter-list.json", "utf8")));
5065
+ if (root instanceof type.errors) throw new ManagerParseError("alter-list.json", root.summary);
5066
+ const canonical = [];
5067
+ for (const row of root.items) {
5068
+ const res = ComfyManagerAlterInfo_ark(row);
5069
+ if (res instanceof type.errors) {
5070
+ counter.skip("schema", res.summary);
5071
+ continue;
5072
+ }
5073
+ canonical.push(res);
5074
+ counter.ok();
5075
+ }
5076
+ DB.alterations = canonical;
5077
+ };
5078
+ //#endregion
5079
+ //#region src/manager/types/ComfyManagerGithubStats.ts
5080
+ const ComfyManagerGithubStatEntry_ark = type({
5081
+ stars: "number",
5082
+ last_update: "string",
5083
+ author_account_age_days: "number"
5084
+ });
5085
+ //#endregion
5086
+ //#region src/manager/loaders/step6_github-stats-loader.ts
5087
+ const _getGithubStats = (DB) => {
5088
+ const counter = DB.report.file("github-stats.json");
5089
+ const raw = JSON.parse(readFileSync("src/manager/json/github-stats.json", "utf8"));
5090
+ const root = type("Record<string, unknown>")(raw);
5091
+ if (root instanceof type.errors) throw new ManagerParseError("github-stats.json", root.summary);
5092
+ for (const [url, value] of Object.entries(root)) {
5093
+ const res = ComfyManagerGithubStatEntry_ark(value);
5094
+ if (res instanceof type.errors) {
5095
+ counter.skip("schema", `${url}: ${res.summary}`);
5096
+ continue;
5097
+ }
5098
+ DB.githubStats.set(url, res);
5099
+ counter.ok();
4890
5100
  }
4891
5101
  };
4892
5102
  //#endregion
4893
5103
  //#region src/manager/ComfyRegistry.ts
4894
5104
  const log = (...args) => console.log(`[📘 registry]`, ...args);
5105
+ const BUILTIN_URL = "https://github.com/comfyanonymous/ComfyUI";
5106
+ const BUILTIN_PLUGIN = {
5107
+ id: "nodes",
5108
+ author: "comfyanonymous",
5109
+ description: "built-in",
5110
+ title: "built-in",
5111
+ files: [BUILTIN_URL],
5112
+ reference: "https://github.com/comfyanonymous/ComfyUI",
5113
+ install_type: ""
5114
+ };
4895
5115
  var ComfyRegistry = class ComfyRegistry {
4896
5116
  static async DownloadAndUpdate(download) {
4897
5117
  if (download) {
@@ -4911,6 +5131,9 @@ var ComfyRegistry = class ComfyRegistry {
4911
5131
  this.plugins_byNodeKey = /* @__PURE__ */ new Map();
4912
5132
  this.customNodes_byPluginName = /* @__PURE__ */ new Map();
4913
5133
  this.knownModels = /* @__PURE__ */ new Map();
5134
+ this.alterations = [];
5135
+ this.githubStats = /* @__PURE__ */ new Map();
5136
+ this.report = new ManagerParseReport();
4914
5137
  this.getKnownCheckpoints = () => {
4915
5138
  return [...this.knownModels.values()].filter((i) => i.type === "checkpoint");
4916
5139
  };
@@ -4950,25 +5173,28 @@ var ComfyRegistry = class ComfyRegistry {
4950
5173
  nix: isUnderPrefix ? nixPath.slice(nixPrefix.length) : mi.filename
4951
5174
  };
4952
5175
  };
4953
- this.plugins_byFile.set("https://github.com/comfyanonymous/ComfyUI", {
4954
- id: "nodes",
4955
- author: "comfyanonymous",
4956
- description: "built-in",
4957
- title: "built-in",
4958
- files: [],
4959
- reference: "https://github.com/comfyanonymous/ComfyUI",
4960
- install_type: ""
4961
- });
5176
+ this.plugins_byTitle.set(BUILTIN_PLUGIN.title, BUILTIN_PLUGIN);
5177
+ this.plugins_byFile.set(BUILTIN_URL, BUILTIN_PLUGIN);
4962
5178
  log(`loading src/manager/json/${ansi.yellow("custom-node-list.json")}...`);
4963
5179
  _getKnownPlugins(this);
4964
5180
  log(`loading src/manager/json/${ansi.yellow("extension-node-map.json")}...`);
4965
5181
  _getCustomNodeRegistry(this);
4966
5182
  log(`loading src/manager/json/${ansi.yellow("model-list.json")}...`);
4967
5183
  _getKnownModels(this);
5184
+ log(`loading src/manager/json/${ansi.yellow("alter-list.json")}...`);
5185
+ _getAlterList(this);
5186
+ log(`loading src/manager/json/${ansi.yellow("github-stats.json")}...`);
5187
+ _getGithubStats(this);
5188
+ this.report.print();
4968
5189
  }
4969
5190
  };
4970
5191
  //#endregion
4971
5192
  //#region src/state.ts
5193
+ /** the ONE settings-file location rule — run-tui reads it BEFORE any module
5194
+ * import creates the comfyts global, so the path logic cannot live on the instance only */
5195
+ function settingsPathFor(root) {
5196
+ return asAbsolutePath(join(root, ".comfy-ts", "settings.json"));
5197
+ }
4972
5198
  /** singleton */
4973
5199
  var ComfyTS = class ComfyTS {
4974
5200
  constructor(p = {}) {
@@ -5037,7 +5263,7 @@ var ComfyTS = class ComfyTS {
5037
5263
  }
5038
5264
  /** local TUI settings (preview mode, last draft per workflow) — gitignored */
5039
5265
  get settingsPath() {
5040
- return asAbsolutePath(join(this.baseFolder, "settings.json"));
5266
+ return settingsPathFor(this.rootPath);
5041
5267
  }
5042
5268
  resolveFromHosts(relativePath) {
5043
5269
  return asAbsolutePath(join(this.hostsFolder, relativePath));
@@ -5056,6 +5282,52 @@ var ComfyTS = class ComfyTS {
5056
5282
  }
5057
5283
  };
5058
5284
  //#endregion
5285
+ //#region src/exampleAssets.ts
5286
+ /**
5287
+ * the examples/ folder shipped in the npm tarball, resolved from THIS module's
5288
+ * own location (NEVER cwd): walking up to the nearest NAMED package.json finds
5289
+ * <pkg>/examples both from a consumer's node_modules/comfy-ts/dist/ and from
5290
+ * this repo's src/. Returns null when the examples are absent (a consumer may
5291
+ * prune the folder) or when the nearest named package is not comfy-ts (the lib
5292
+ * was inlined into someone else's bundle — its examples are not on disk); no
5293
+ * package.json all the way up is a broken install and throws.
5294
+ */
5295
+ function bundledExamplesDir(moduleUrl = import.meta.url) {
5296
+ let dir = dirname(fileURLToPath(moduleUrl));
5297
+ let prev = "";
5298
+ while (dir !== prev) {
5299
+ const pkgPath = join(dir, "package.json");
5300
+ if (existsSync(pkgPath)) {
5301
+ let pkg = {};
5302
+ try {
5303
+ pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
5304
+ } catch {}
5305
+ if (pkg.name === "comfy-ts") {
5306
+ const examples = join(dir, "examples");
5307
+ return existsSync(examples) ? examples : null;
5308
+ }
5309
+ if (pkg.name != null) return null;
5310
+ }
5311
+ prev = dir;
5312
+ dir = dirname(dir);
5313
+ }
5314
+ throw new Error(`[comfy-ts] no package.json found walking up from ${fileURLToPath(moduleUrl)}`);
5315
+ }
5316
+ /**
5317
+ * absolute path of a bundled `examples/images/` input image, e.g.
5318
+ * `exampleImagePath('bear_1024x1024.jpg')` — the out-of-the-box default for
5319
+ * i2i/i2v example image vars, valid from this repo AND from a consumer's
5320
+ * node_modules/comfy-ts/. Loud throw naming the path when the file is missing
5321
+ * or the package's examples/ folder was pruned.
5322
+ */
5323
+ function exampleImagePath(name) {
5324
+ const examples = bundledExamplesDir();
5325
+ if (examples == null) throw new Error(`[comfy-ts] cannot resolve bundled example image '${name}': the package's examples/ folder is not on disk`);
5326
+ const abs = join(examples, "images", name);
5327
+ if (!existsSync(abs)) throw new Error(`[comfy-ts] bundled example image not found: ${abs}`);
5328
+ return abs;
5329
+ }
5330
+ //#endregion
5059
5331
  //#region src/cli/tui-env.ts
5060
5332
  const COMFY_TS_TUI_ENV = "COMFY_TS_TUI";
5061
5333
  function isTuiActive() {
@@ -5074,6 +5346,6 @@ function loraTag(name, strength = 1, clipStrength) {
5074
5346
  return clipStrength == null ? `<lora:${name}:${strength}>` : `<lora:${name}:${strength}:${clipStrength}>`;
5075
5347
  }
5076
5348
  //#endregion
5077
- export { ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyManager, ComfyNode, ComfyNodeOutput, ComfySchema, ComfyTS, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, DEFAULT_SIZE_PRESETS, DefinedWorkflow, FloatVar, IntVar, InvalidPromptError, LorasVar, MediaImage, PromptVar, ResilientWebSocketClient, SeedVar, SizeVar, TextVar, ToggleVar, WorkflowConvertError, WorkflowNormalizeError, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, getLoraKeyword, hostIdToNamespace, isTuiActive, loraTag, normalizeWorkflow, parseHostBase, parseWorkflowJson, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setLoraKeyword, v };
5349
+ export { ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyManager, ComfyNode, ComfyNodeOutput, ComfySchema, ComfyTS, ComfyUploader, ComfyVar, ComfyVarBase, ComfyWorkflow, ComfyWorkflowBuilder, DEFAULT_IMAGE_EXTENSIONS, DEFAULT_SIZE_PRESETS, DefinedWorkflow, FloatVar, ImageVar, ImageVarEmptyError, IntVar, InvalidPromptError, LorasVar, MediaImage, PromptVar, ResilientWebSocketClient, SeedVar, SizeVar, TextVar, ToggleVar, WorkflowConvertError, WorkflowNormalizeError, __FAIL, __OK, activeLoras, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, exampleImagePath, getLoraKeyword, hostIdToNamespace, isTuiActive, loraTag, normalizeWorkflow, parseHostBase, parseWorkflowJson, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setLoraKeyword, v };
5078
5350
 
5079
5351
  //# sourceMappingURL=index.js.map