comfy-ts 2.7.0 → 2.9.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 (104) hide show
  1. package/README.md +20 -13
  2. package/dist/{DefinedWorkflow-BJgt5t0x.js → DefinedWorkflow-BatWaZO1.js} +199 -16
  3. package/dist/DefinedWorkflow-BatWaZO1.js.map +1 -0
  4. package/dist/{DraftsSt-dizp3VcC.js → LogsSt-DFxzQfDc.js} +152 -4
  5. package/dist/LogsSt-DFxzQfDc.js.map +1 -0
  6. package/dist/cli.js +7 -5
  7. package/dist/cli.js.map +1 -1
  8. package/dist/index.cjs +284 -35
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +125 -7
  11. package/dist/index.d.ts +125 -7
  12. package/dist/index.js +282 -37
  13. package/dist/index.js.map +1 -1
  14. package/dist/run-serve-_nrvJYyt.js +1948 -0
  15. package/dist/run-serve-_nrvJYyt.js.map +1 -0
  16. package/dist/{run-tui-JxlEbb_f.js → run-tui-BLEdTsOX.js} +106 -157
  17. package/dist/run-tui-BLEdTsOX.js.map +1 -0
  18. package/dist/serve-web.js +441 -72
  19. package/dist/{state-CaHeDL-0.js → state-BbgJeCe6.js} +180 -45
  20. package/dist/state-BbgJeCe6.js.map +1 -0
  21. package/dist/web.d.ts +185 -7
  22. package/dist/web.js +235 -36
  23. package/dist/web.js.map +1 -1
  24. package/examples/README.md +1 -0
  25. package/examples/comfy-cloud/sdk.d.ts +4066 -321
  26. package/examples/rvion/04-krea2-turbo-t2i.cflow.ts +18 -2
  27. package/examples/rvion/07-local-llm-text-gen.cflow.ts +220 -0
  28. package/examples/web/tsconfig.json +3 -0
  29. package/extra/README.md +32 -0
  30. package/extra/comfyui-textgen-stream/README.md +35 -0
  31. package/extra/comfyui-textgen-stream/__init__.py +166 -0
  32. package/extra/scripts/fetch_text_encoder.py +137 -0
  33. package/package.json +6 -3
  34. package/src/cli/comfy-ts-cli.ts +3 -1
  35. package/src/cli/serve/ServeApp.ts +754 -40
  36. package/src/cli/serve/applyVarPayload.ts +10 -3
  37. package/src/cli/serve/describeVar.ts +47 -7
  38. package/src/cli/serve/hostProtocol.ts +68 -0
  39. package/src/cli/serve/managerOnlyLoras.ts +27 -0
  40. package/src/cli/serve/run-serve.ts +35 -38
  41. package/src/cli/serve/serveSettings.ts +86 -0
  42. package/src/cli/serve/startupPrint.ts +111 -0
  43. package/src/cli/serve/web/api.ts +97 -1
  44. package/src/cli/serve/web/components/App.tsx +61 -22
  45. package/src/cli/serve/web/components/Gallery.tsx +306 -41
  46. package/src/cli/serve/web/components/Icon.tsx +160 -0
  47. package/src/cli/serve/web/components/PromptEnhancer.tsx +12 -9
  48. package/src/cli/serve/web/components/Sidebar.tsx +43 -19
  49. package/src/cli/serve/web/components/VarsForm.tsx +440 -91
  50. package/src/cli/serve/web/components/controls/BasicControls.tsx +38 -5
  51. package/src/cli/serve/web/components/controls/ImageControl.tsx +3 -2
  52. package/src/cli/serve/web/components/controls/LorasControl.tsx +498 -81
  53. package/src/cli/serve/web/components/controls/PresetPicker.tsx +60 -0
  54. package/src/cli/serve/web/components/controls/SeedControl.tsx +38 -20
  55. package/src/cli/serve/web/components/controls/SizeControl.tsx +3 -2
  56. package/src/cli/serve/web/llm.ts +1 -1
  57. package/src/cli/serve/web/logWeb.ts +6 -0
  58. package/src/cli/serve/web/state/EnhancerSt.ts +8 -15
  59. package/src/cli/serve/web/state/FormSt.ts +74 -18
  60. package/src/cli/serve/web/state/RunSt.ts +22 -1
  61. package/src/cli/serve/web/state/WebSt.ts +814 -22
  62. package/src/cli/serve/web/state/host.ts +206 -0
  63. package/src/cli/serve/web/state/lightbox.ts +44 -0
  64. package/src/cli/serve/web/state/moduleTree.ts +52 -0
  65. package/src/cli/serve/web/state/payload.ts +44 -2
  66. package/src/cli/serve/web/state/urlSelection.ts +53 -0
  67. package/src/cli/serve/web/styles.ts +422 -57
  68. package/src/cli/serve/web/tsconfig.json +4 -0
  69. package/src/cli/tui/components/PickerOverlays.tsx +37 -0
  70. package/src/cli/tui/components/StatusBar.tsx +14 -1
  71. package/src/cli/tui/components/TuiApp.tsx +5 -2
  72. package/src/cli/tui/state/HostSt.ts +3 -2
  73. package/src/cli/tui/state/PickerSt.ts +48 -2
  74. package/src/cli/tui/state/TreeSt.ts +1 -1
  75. package/src/cli/tui/state/TuiSt.ts +2 -1
  76. package/src/coreExports.ts +8 -1
  77. package/src/graph/ComfyNode.ts +58 -1
  78. package/src/host/ComfyHost.ts +13 -2
  79. package/src/host/ComfyManager.ts +31 -13
  80. package/src/host/loraInfoCache.ts +35 -1
  81. package/src/host/loraManagerApi.ts +94 -0
  82. package/src/index.ts +2 -0
  83. package/src/promptEnhancers.ts +102 -0
  84. package/src/runner/ComfyExecution.ts +61 -6
  85. package/src/runner/ComfyWorkflow.ts +18 -4
  86. package/src/runner/ComfyWsApi.ts +3 -0
  87. package/src/runner/describePromptRejection.ts +34 -0
  88. package/src/sdk-generator/ComfySchema.ts +17 -4
  89. package/src/sdk-generator/comfyui-sdk-codegen.ts +56 -2
  90. package/src/utils/ansi.ts +13 -0
  91. package/src/utils/matchesRegex.ts +13 -0
  92. package/src/utils/safeName.ts +29 -0
  93. package/src/utils/stringMap.ts +9 -0
  94. package/src/vars/ComfyVars.ts +61 -10
  95. package/src/vars/presets.ts +17 -0
  96. package/src/web.ts +12 -0
  97. package/dist/DefinedWorkflow-BJgt5t0x.js.map +0 -1
  98. package/dist/DraftsSt-dizp3VcC.js.map +0 -1
  99. package/dist/run-serve-D1Tsuru9.js +0 -1162
  100. package/dist/run-serve-D1Tsuru9.js.map +0 -1
  101. package/dist/run-tui-JxlEbb_f.js.map +0 -1
  102. package/dist/state-CaHeDL-0.js.map +0 -1
  103. package/src/cli/serve/promptEnhancers.ts +0 -69
  104. package/src/cli/serve/safeName.ts +0 -12
package/dist/web.js CHANGED
@@ -101,7 +101,7 @@ function getComfyStorage() {
101
101
  }
102
102
  //#endregion
103
103
  //#region package.json
104
- var version = "2.7.0";
104
+ var version = "2.9.0";
105
105
  //#endregion
106
106
  //#region src/litegraph/LiteGraphLinkID.ts
107
107
  const asLiteGraphLinkID = (id) => id;
@@ -1212,6 +1212,40 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
1212
1212
  return prompt;
1213
1213
  };
1214
1214
  //#endregion
1215
+ //#region src/utils/isRecord.ts
1216
+ /** narrows unknown wire json to an indexable object (arrays and null excluded) */
1217
+ function isRecord(v) {
1218
+ return typeof v === "object" && v !== null && !Array.isArray(v);
1219
+ }
1220
+ //#endregion
1221
+ //#region src/runner/describePromptRejection.ts
1222
+ function str(v) {
1223
+ return typeof v === "string" ? v.trim() : "";
1224
+ }
1225
+ function describePromptRejection(body) {
1226
+ if (!isRecord(body)) return "no reason given";
1227
+ const parts = [];
1228
+ const err = body["error"];
1229
+ if (isRecord(err)) {
1230
+ const head = str(err["message"]);
1231
+ const detail = str(err["details"]);
1232
+ if (head !== "") parts.push(detail === "" ? head : `${head} (${detail})`);
1233
+ }
1234
+ const nodes = body["node_errors"];
1235
+ if (isRecord(nodes)) for (const [nodeId, raw] of Object.entries(nodes)) {
1236
+ if (!isRecord(raw)) continue;
1237
+ const list = raw["errors"];
1238
+ if (!Array.isArray(list)) continue;
1239
+ for (const e of list) {
1240
+ if (!isRecord(e)) continue;
1241
+ const detail = str(e["details"]);
1242
+ const msg = str(e["message"]);
1243
+ parts.push(`node ${nodeId}: ${[msg, detail].filter((x) => x !== "").join(" — ")}`);
1244
+ }
1245
+ }
1246
+ return parts.length === 0 ? "no reason given" : parts.join(" · ");
1247
+ }
1248
+ //#endregion
1215
1249
  //#region src/errors/InvalidPromptError.ts
1216
1250
  var InvalidPromptError = class extends Error {
1217
1251
  constructor(message, snapshot, details) {
@@ -1262,6 +1296,7 @@ var ComfyNodeOutput = class {
1262
1296
  };
1263
1297
  //#endregion
1264
1298
  //#region src/graph/ComfyNode.ts
1299
+ const isScalarValue = (x) => typeof x === "string" || typeof x === "number" || typeof x === "boolean";
1265
1300
  /** ComfyNode
1266
1301
  * - correspond to a signal in the graph
1267
1302
  * - belongs to a script
@@ -1354,13 +1389,27 @@ var ComfyNode = class ComfyNode {
1354
1389
  _convertPromptExtToPrompt(promptExt) {
1355
1390
  const inputs = {};
1356
1391
  const _done = /* @__PURE__ */ new Set();
1392
+ /** every dotted key of every branch: the selected ones are written here, the rest are dropped */
1393
+ const _comboBranchKeys = /* @__PURE__ */ new Set();
1357
1394
  for (const i of this.$schema.inputs) {
1358
1395
  _done.add(i.nameInComfy);
1396
+ const kind = classifySchemaInput(i);
1397
+ if (kind.kind === "dynamic-combo") {
1398
+ this._writeDynamicCombo({
1399
+ name: i.nameInComfy,
1400
+ options: kind.options,
1401
+ defaultKey: kind.defaultKey,
1402
+ provided: promptExt.inputs,
1403
+ out: inputs,
1404
+ claimed: _comboBranchKeys
1405
+ });
1406
+ continue;
1407
+ }
1359
1408
  const value = this.serializeValue(i.nameInComfy, promptExt.inputs[i.nameInComfy]);
1360
1409
  if (value !== void 0) inputs[i.nameInComfy] = value;
1361
1410
  }
1362
1411
  for (const [nameInComfy, rawVal] of Object.entries(promptExt.inputs)) {
1363
- if (_done.has(nameInComfy)) continue;
1412
+ if (_done.has(nameInComfy) || _comboBranchKeys.has(nameInComfy)) continue;
1364
1413
  inputs[nameInComfy] = this.serializeValue(nameInComfy, rawVal);
1365
1414
  }
1366
1415
  return {
@@ -1368,6 +1417,31 @@ var ComfyNode = class ComfyNode {
1368
1417
  inputs
1369
1418
  };
1370
1419
  }
1420
+ /** dynamic combo → the key plus ONLY the selected branch's dotted inputs, absent ones
1421
+ * filled from the schema (agent/architecture.md, dynamic-combo fill). The host declares
1422
+ * those branch inputs required and default-fills none of them */
1423
+ _writeDynamicCombo(p) {
1424
+ for (const opt of p.options) for (const e of opt.inputs) p.claimed.add(`${p.name}.${e.name}`);
1425
+ const raw = p.provided[p.name];
1426
+ const key = typeof raw === "string" ? raw : p.defaultKey;
1427
+ const branch = p.options.find((o) => o.key === key);
1428
+ if (branch == null) {
1429
+ const known = p.options.map((o) => o.key).join(", ");
1430
+ console.error(`🔴 unknown "${p.name}" option ${JSON.stringify(key)} (known: ${known})`);
1431
+ this.graph.recordProblem(`🔴 unknown "${p.name}" option ${JSON.stringify(key)} on ${this.$schema.nodeKey}#${this.uid} (known: ${known})`);
1432
+ return;
1433
+ }
1434
+ p.out[p.name] = key;
1435
+ for (const e of branch.inputs) {
1436
+ const dotted = `${p.name}.${e.name}`;
1437
+ const given = p.provided[dotted];
1438
+ p.out[dotted] = given === void 0 ? defaultValueForWidget({
1439
+ type: typeof e.type === "string" ? e.type : "COMBO",
1440
+ opts: e.opts,
1441
+ enumValues: Array.isArray(e.type) ? e.type.filter(isScalarValue) : void 0
1442
+ }) : this.serializeValue(dotted, given);
1443
+ }
1444
+ }
1371
1445
  /** return the list of nodes piped into this node */
1372
1446
  _incomingNodes() {
1373
1447
  const incomingNodes = [];
@@ -1925,7 +1999,8 @@ const types$1 = scope({
1925
1999
  node: "ComfyNodeID",
1926
2000
  output: {
1927
2001
  "previews?": [{ filepath: "string" }, "[]"],
1928
- "images?": "ComfyImageInfo[]"
2002
+ "images?": "ComfyImageInfo[]",
2003
+ "text?": "unknown[]"
1929
2004
  },
1930
2005
  prompt_id: "PromptID"
1931
2006
  },
@@ -2234,6 +2309,15 @@ var ComfyExecution = class {
2234
2309
  };
2235
2310
  this.onExecuted = (msg) => {
2236
2311
  const promptNodeID = msg.data.node;
2312
+ for (const entry of msg.data.output?.text ?? []) {
2313
+ if (typeof entry !== "string") continue;
2314
+ const nodeKey = this.workflow.data.apiJson?.[promptNodeID]?.class_type ?? null;
2315
+ this.texts.push({
2316
+ nodeId: promptNodeID,
2317
+ nodeKey,
2318
+ text: entry
2319
+ });
2320
+ }
2237
2321
  const images = msg.data.output?.images;
2238
2322
  if (images) for (const img of images) this.pendingPromises.push(this.retrieveImage(img, promptNodeID).catch((e) => {
2239
2323
  console.error(`🔴 failed to retrieve ${img.filename}:`, e);
@@ -2351,6 +2435,9 @@ var ComfyExecution = class {
2351
2435
  }), promptNodeID);
2352
2436
  };
2353
2437
  this.images = [];
2438
+ this.texts = [];
2439
+ this.progressTexts = /* @__PURE__ */ new Map();
2440
+ this.progressText = null;
2354
2441
  this.alreadyDone = false;
2355
2442
  this._finish = async (p) => {
2356
2443
  if (this.alreadyDone) throw new Error(`❌ invariant violation: already finished`);
@@ -2386,7 +2473,9 @@ var ComfyExecution = class {
2386
2473
  ...this.progressGlobal,
2387
2474
  promptId: this.data.id,
2388
2475
  nodeName: this.workflow.currentExecutingNode?.$schema.nameInComfy ?? null,
2389
- elapsedMs: Date.now() - this.startedAt
2476
+ elapsedMs: Date.now() - this.startedAt,
2477
+ nodeProgress: this.workflow.currentExecutingNode?.progress ?? null,
2478
+ progressText: this.progressText
2390
2479
  };
2391
2480
  }
2392
2481
  emitProgress() {
@@ -2397,16 +2486,21 @@ var ComfyExecution = class {
2397
2486
  const filled = Math.round(p.percent / 100 * width);
2398
2487
  const bar = "█".repeat(filled) + "░".repeat(width - filled);
2399
2488
  const node = p.nodeName ? ` · ${p.nodeName}` : "";
2400
- const line = `▶ [${bar}] ${p.percent.toFixed(0).padStart(3)}%${node} · ${(p.elapsedMs / 1e3).toFixed(0)}s`;
2401
- if (line === this._lastLoggedLine) return;
2402
- this._lastLoggedLine = line;
2403
- if (globalThis.process?.stdout?.isTTY) process.stdout.write(`\r\x1b[2K${line}`);
2404
- else console.log(line);
2489
+ const count = p.nodeProgress ? ` ${p.nodeProgress.value}/${p.nodeProgress.max}` : "";
2490
+ const line = `▶ [${bar}] ${p.percent.toFixed(0).padStart(3)}%${node}${count} · ${(p.elapsedMs / 1e3).toFixed(0)}s`;
2491
+ const tail = p.progressText?.replaceAll("\n", " ").trimEnd().slice(-60);
2492
+ const full = tail == null || tail === "" ? line : `${line} · …${tail}`;
2493
+ if (full === this._lastLoggedLine) return;
2494
+ this._lastLoggedLine = full;
2495
+ if (globalThis.process?.stdout?.isTTY) process.stdout.write(`\r\x1b[2K${full}`);
2496
+ else console.log(full);
2405
2497
  }
2406
2498
  finishProgressLine() {
2407
2499
  if (!this.logProgress) return;
2408
2500
  const p = this.progress;
2409
- const line = `${this.status === "Failure" ? "🔴" : "🟢"} ${this.status.toLowerCase()} in ${(p.elapsedMs / 1e3).toFixed(1)}s · ${this.images.length} image(s)`;
2501
+ const outputs = [`${this.images.length} image(s)`];
2502
+ if (this.texts.length > 0) outputs.push(`${this.texts.length} text(s)`);
2503
+ const line = `${this.status === "Failure" ? "🔴" : "🟢"} ${this.status.toLowerCase()} in ${(p.elapsedMs / 1e3).toFixed(1)}s · ${outputs.join(" · ")}`;
2410
2504
  if (globalThis.process?.stdout?.isTTY) process.stdout.write(`\r\x1b[2K${line}\n`);
2411
2505
  else console.log(line);
2412
2506
  }
@@ -2448,6 +2542,16 @@ var ComfyExecution = class {
2448
2542
  if (uid == null) return false;
2449
2543
  return (this.snapshot?.apiJson ?? this.workflow.apiJson)[uid]?.class_type === "SaveImageWebsocket";
2450
2544
  }
2545
+ /** @internal a live-text frame for one node */
2546
+ onProgressText(p) {
2547
+ this.progressTexts.set(p.nodeId, p.text);
2548
+ this.progressText = p.text;
2549
+ this.emitProgress();
2550
+ }
2551
+ /** the last text output, the one a single-generator workflow means by "the result" */
2552
+ get text() {
2553
+ return this.texts.at(-1)?.text ?? null;
2554
+ }
2451
2555
  update(data) {
2452
2556
  Object.assign(this.data, data);
2453
2557
  }
@@ -2480,11 +2584,14 @@ const deepCopyNaive = (x) => JSON.parse(JSON.stringify(x));
2480
2584
  //#region src/utils/ansi.ts
2481
2585
  const codes = {
2482
2586
  bold: [1, 22],
2587
+ dim: [2, 22],
2483
2588
  underline: [4, 24],
2484
2589
  red: [31, 39],
2485
2590
  green: [32, 39],
2486
2591
  yellow: [33, 39],
2487
2592
  blue: [34, 39],
2593
+ cyan: [36, 39],
2594
+ gray: [90, 39],
2488
2595
  greenBright: [92, 39]
2489
2596
  };
2490
2597
  function styler(open = "", close = "") {
@@ -2735,6 +2842,7 @@ var ComfyWorkflow = class {
2735
2842
  return execution;
2736
2843
  };
2737
2844
  this.start = async (p = {}) => {
2845
+ if (this.host.ws == null) throw new Error(`🔴 host '${this.host.data.id}' was never connected — call \`await host.connect()\` before running a workflow`);
2738
2846
  this.resetRunState();
2739
2847
  const snapshot = {
2740
2848
  apiJson: deepCopyNaive(this.toApiJson(p.idMode ?? "use_stringified_numbers_only")),
@@ -2759,8 +2867,9 @@ var ComfyWorkflow = class {
2759
2867
  headers: { "Content-Type": "application/json" },
2760
2868
  body: JSON.stringify(out)
2761
2869
  });
2762
- const promptInfo = softValidate(PromptInfo_ark, await res.json());
2763
- if (res.status !== 200) throw new InvalidPromptError("ComfyUI /prompt request failed", snapshot, promptInfo);
2870
+ const promptInfoJson = await res.json();
2871
+ if (res.status !== 200) throw new InvalidPromptError(`ComfyUI refused the prompt: ${describePromptRejection(promptInfoJson)}`, snapshot, promptInfoJson);
2872
+ const promptInfo = softValidate(PromptInfo_ark, promptInfoJson);
2764
2873
  return new ComfyExecution(this, {
2765
2874
  id: promptInfo.prompt_id,
2766
2875
  executed: false,
@@ -2833,6 +2942,13 @@ var ComfyWorkflow = class {
2833
2942
  }
2834
2943
  };
2835
2944
  //#endregion
2945
+ //#region src/utils/matchesRegex.ts
2946
+ function statelessRegex(re) {
2947
+ if (!re.global && !re.sticky) return re;
2948
+ const source = re.sticky ? `^(?:${re.source})` : re.source;
2949
+ return new RegExp(source, re.flags.replace(/[gy]/g, ""));
2950
+ }
2951
+ //#endregion
2836
2952
  //#region src/sdk-generator/_getUnionNameBasedOnFirstFoundEnumName.ts
2837
2953
  /** having a bunch of sensible default will help slightly */
2838
2954
  function getUnionNameBasedOnFirstFoundEnumName(enumName, hash, hashContent) {
@@ -2977,6 +3093,25 @@ const wrapQuote = (s) => {
2977
3093
  };
2978
3094
  //#endregion
2979
3095
  //#region src/sdk-generator/comfyui-sdk-codegen.ts
3096
+ const isScalar = (x) => typeof x === "string" || typeof x === "number" || typeof x === "boolean";
3097
+ /** a dynamic-combo branch input, typed the way its dotted prompt key is filled: inline enums
3098
+ * and COMBO option lists become literal unions, everything else stays a named slot */
3099
+ const branchInputType = (entry) => {
3100
+ const opts = isRecord$1(entry.opts) ? entry.opts : null;
3101
+ const scalars = (Array.isArray(entry.type) ? entry.type : Array.isArray(opts?.["options"]) ? opts["options"] : []).filter(isScalar);
3102
+ if (scalars.length > 0) return scalars.map((o) => JSON.stringify(o)).join(" | ");
3103
+ if (typeof entry.type === "string") return `Accepts[${JSON.stringify(entry.type)}]`;
3104
+ return "string | number | boolean";
3105
+ };
3106
+ /** `& ({key:'a'; 'name.x'?: …} | {key:'b'})` — one member per branch, so a key from a branch
3107
+ * you did not select is a type error. Branch fields are optional: ComfyNode fills them
3108
+ * from the schema at serialization (agent/architecture.md, dynamic-combo fill) */
3109
+ const dynamicComboUnion = (p) => {
3110
+ return ` & (${p.options.map((opt) => {
3111
+ const fields = opt.inputs.map((e) => `${escapeJSKey(`${p.name}.${e.name}`)}?: ${branchInputType(e)}`);
3112
+ return `{ ${[`${p.nameEscaped}${p.keyOptional ? "?" : ""}: ${JSON.stringify(opt.key)}`, ...fields].join("; ")} }`;
3113
+ }).join(" | ")})`;
3114
+ };
2980
3115
  /**
2981
3116
  * convert a host id to the namespace name it gets inside the global `Comfy` namespace
2982
3117
  * e.g. 'windows-1' -> 'Windows1', 'my_cloud.instance' -> 'MyCloudInstance'
@@ -3029,6 +3164,7 @@ function codegenSDK(opts) {
3029
3164
  b.indent();
3030
3165
  for (const n of nodes) {
3031
3166
  p(`${escapeJSKey(n.nodeKey)}: {`);
3167
+ const comboSuffixes = [];
3032
3168
  for (const i of n.inputs) {
3033
3169
  const kind = classifySchemaInput(i);
3034
3170
  if (kind.kind === "dynamic-container") {
@@ -3039,6 +3175,16 @@ function codegenSDK(opts) {
3039
3175
  });
3040
3176
  continue;
3041
3177
  }
3178
+ if (kind.kind === "dynamic-combo") {
3179
+ const optsDyn = typeof i.opts === "string" ? null : i.opts;
3180
+ comboSuffixes.push(dynamicComboUnion({
3181
+ name: i.nameInComfy,
3182
+ nameEscaped: i.nameInComfyEscaped,
3183
+ options: kind.options,
3184
+ keyOptional: optsDyn?.default !== void 0 || !i.required
3185
+ }));
3186
+ continue;
3187
+ }
3042
3188
  const opts_ = typeof i.opts === "string" ? null : i.opts;
3043
3189
  let type = `Accepts[${JSON.stringify(i.typeName)}]`;
3044
3190
  const comboOptions = i.typeName === "COMBO" && Array.isArray(opts_?.options) ? opts_.options.filter((o) => typeof o === "string" || typeof o === "number" || typeof o === "boolean") : [];
@@ -3055,7 +3201,7 @@ function codegenSDK(opts) {
3055
3201
  const canBeOmmited = opts_?.default !== void 0 || !i.required;
3056
3202
  p(` ${i.nameInComfyEscaped}${canBeOmmited ? "?" : ""}: ${type}`);
3057
3203
  }
3058
- p(`},`);
3204
+ p(`}${comboSuffixes.join("")},`);
3059
3205
  }
3060
3206
  b.deindent();
3061
3207
  p("}");
@@ -3224,7 +3370,8 @@ var ComfySchema = class {
3224
3370
  };
3225
3371
  this.getLoras = (filter) => {
3226
3372
  const all = this.stringValues("LoraLoader.lora_name");
3227
- return filter == null ? all : all.filter((n) => filter.test(n));
3373
+ const stateless = filter == null ? null : statelessRegex(filter);
3374
+ return stateless == null ? all : all.filter((n) => stateless.test(n));
3228
3375
  };
3229
3376
  this.getImages = () => {
3230
3377
  return this.stringValues("LoadImage.image");
@@ -3358,15 +3505,19 @@ var ComfySchema = class {
3358
3505
  comfyUnionDef: slotType
3359
3506
  }).unionName);
3360
3507
  else throw new Error(`invalid schema (${JSON.stringify(slotType)}) for input "${ipt.name}" in node "${nodeNameInComfy}" (type: ${typeof slotType}; expected: Array | string)`);
3361
- const isAutogrowContainer = typeof slotType === "string" && classifyWidgetInput({
3508
+ const widgetKind = typeof slotType === "string" ? classifyWidgetInput({
3362
3509
  name: ipt.name,
3363
3510
  type: slotType,
3364
3511
  opts: slotOpts
3365
- }).kind === "dynamic-container";
3512
+ }) : null;
3513
+ const isAutogrowContainer = widgetKind?.kind === "dynamic-container";
3366
3514
  if (isAutogrowContainer) {
3367
3515
  const instType = containerInstanceSlotType(slotOpts);
3368
3516
  if (instType != null) this.knownSlotTypes.add(asComfyNodeSlotTypeName(instType));
3369
3517
  }
3518
+ if (widgetKind?.kind === "dynamic-combo") {
3519
+ for (const opt of widgetKind.options) for (const entry of opt.inputs) if (typeof entry.type === "string") this.knownSlotTypes.add(asComfyNodeSlotTypeName(entry.type));
3520
+ }
3370
3521
  node.inputs.push({
3371
3522
  slotName: inputSlotName,
3372
3523
  required: ipt.required && !isAutogrowContainer,
@@ -3542,7 +3693,19 @@ var ComfyManager = class {
3542
3693
  return comfyts.registry.getModelInfoFinalFilePath(mi);
3543
3694
  };
3544
3695
  this.restartComfyUI = async () => {
3545
- return this.fetchGetJSON("/manager/reboot");
3696
+ const refusals = [];
3697
+ for (const method of ["POST", "GET"]) {
3698
+ let response;
3699
+ try {
3700
+ response = await this.host.fetch("/manager/reboot", { method });
3701
+ } catch {
3702
+ return;
3703
+ }
3704
+ if (response.ok) return;
3705
+ refusals.push(`${method} → ${response.status}`);
3706
+ if (response.status !== 404) break;
3707
+ }
3708
+ throw new Error(`🔴 ${this.host.getServerHostHTTP()} refused to reboot (${refusals.join(", ")}) — ComfyUI-Manager is not installed there, or its reboot route moved again`);
3546
3709
  };
3547
3710
  this.modelList = null;
3548
3711
  this.fetchModels = () => {
@@ -3667,7 +3830,7 @@ var ComfyManager = class {
3667
3830
  }
3668
3831
  rebootComfyUIAndUpdateHostPluginsAndModelsAfter10Seconds() {
3669
3832
  setTimeout(() => void this.fetchPluginsAndModels(), 1e4);
3670
- return this.fetchGetJSON("/manager/reboot");
3833
+ return this.restartComfyUI();
3671
3834
  }
3672
3835
  get titlesOfAllInstalledPlugins() {
3673
3836
  return this.pluginList?.custom_nodes.filter((x) => x.installed === "True").map((x) => x.title) ?? [];
@@ -3890,12 +4053,6 @@ var ResilientWebSocketClient = class {
3890
4053
  }
3891
4054
  }
3892
4055
  };
3893
- //#endregion
3894
- //#region src/utils/isRecord.ts
3895
- /** narrows unknown wire json to an indexable object (arrays and null excluded) */
3896
- function isRecord(v) {
3897
- return typeof v === "object" && v !== null && !Array.isArray(v);
3898
- }
3899
4056
  type({
3900
4057
  items: "unknown[]",
3901
4058
  "total?": "number"
@@ -4056,7 +4213,6 @@ function getLoraPreviewUrl(name, hostId) {
4056
4213
  const info = getLoraInfo(name, hostId);
4057
4214
  return info == null ? null : lmPreviewUrl(info);
4058
4215
  }
4059
- /** the lora's NAMES: the file, and the model name a human would call it by */
4060
4216
  function loraSearchNames(name, hostId) {
4061
4217
  const names = [loraBasename(name), name.replaceAll("\\", "/")];
4062
4218
  const info = getLoraInfo(name, hostId);
@@ -4178,6 +4334,20 @@ function writeKeywords() {
4178
4334
  }
4179
4335
  }
4180
4336
  //#endregion
4337
+ //#region src/vars/presets.ts
4338
+ function toPresetList(spec) {
4339
+ if (spec == null) return [];
4340
+ return Object.entries(spec).map(([label, text]) => ({
4341
+ label,
4342
+ text
4343
+ }));
4344
+ }
4345
+ /** which preset the value still IS, or null once it was hand-edited (trailing whitespace ignored) */
4346
+ function activePresetLabel(presets, value) {
4347
+ const v = value.trim();
4348
+ return presets.find((p) => p.text.trim() === v)?.label ?? null;
4349
+ }
4350
+ //#endregion
4181
4351
  //#region src/vars/ComfyVars.ts
4182
4352
  /**
4183
4353
  * full base: T is what's STORED/edited, Out what the GRAPH consumes at build
@@ -4235,9 +4405,14 @@ var ComfyVar = class extends ComfyVarBase {
4235
4405
  }
4236
4406
  };
4237
4407
  var TextVar = class extends ComfyVar {
4238
- constructor(..._args) {
4239
- super(..._args);
4408
+ /** a bare label string was the whole second parameter before opts existed: a published
4409
+ * consumer passing one must keep working, exactly as SeedVar does */
4410
+ constructor(defaultValue, opts = {}) {
4411
+ const o = typeof opts === "string" ? { label: opts } : opts;
4412
+ super(defaultValue, o.label);
4240
4413
  this.kind = "text";
4414
+ this.opts = o;
4415
+ this.presets = toPresetList(o.presets);
4241
4416
  }
4242
4417
  parse(raw) {
4243
4418
  this.set(raw);
@@ -4261,6 +4436,7 @@ var PromptVar = class extends ComfyVarBase {
4261
4436
  super(defaultValue, promptOpts.label);
4262
4437
  this.promptOpts = promptOpts;
4263
4438
  this.kind = "prompt";
4439
+ this.presets = toPresetList(promptOpts.presets);
4264
4440
  }
4265
4441
  parse(raw) {
4266
4442
  this.set(raw);
@@ -4337,11 +4513,14 @@ var FloatVar = class extends ComfyVar {
4337
4513
  * The number shown is always the seed the NEXT run will use.
4338
4514
  */
4339
4515
  var SeedVar = class extends ComfyVar {
4340
- constructor(defaultValue = 0, label) {
4341
- super(defaultValue, label);
4516
+ /** `opts` is the modern shape; a bare label string stays accepted, since that was the
4517
+ * signature before a workflow could declare the mode it wants to run in */
4518
+ constructor(defaultValue = 0, opts = {}) {
4519
+ const o = typeof opts === "string" ? { label: opts } : opts;
4520
+ super(defaultValue, o.label);
4342
4521
  this.kind = "seed";
4343
- this.mode = "=";
4344
- this.defaultMode = "=";
4522
+ this.mode = o.mode ?? "=";
4523
+ this.defaultMode = this.mode;
4345
4524
  makeObservable(this, {
4346
4525
  mode: observable,
4347
4526
  setMode: action,
@@ -4409,8 +4588,8 @@ var SeedVar = class extends ComfyVar {
4409
4588
  }
4410
4589
  };
4411
4590
  var ToggleVar = class extends ComfyVar {
4412
- constructor(..._args2) {
4413
- super(..._args2);
4591
+ constructor(..._args) {
4592
+ super(..._args);
4414
4593
  this.kind = "toggle";
4415
4594
  }
4416
4595
  toggle() {
@@ -4471,6 +4650,12 @@ var LorasVar = class LorasVar extends ComfyVar {
4471
4650
  this.resolvedOptions = null;
4472
4651
  this.hostId = void 0;
4473
4652
  }
4653
+ /** the filter the workflow declared, when it declared one (`v.loras(/krea-?2/i)`). Public so
4654
+ * a UI can SHOW it, and so serve applies the same narrowing to loras only its lora-manager
4655
+ * mirror knows, an unfiltered union would put the whole catalog back in a filtered picker */
4656
+ get optionsFilter() {
4657
+ return this.optionsSource instanceof RegExp ? this.optionsSource : null;
4658
+ }
4474
4659
  get options() {
4475
4660
  if (!(this.optionsSource instanceof RegExp)) return this.optionsSource;
4476
4661
  if (this.resolvedOptions == null) throw new Error(`v.loras(${String(this.optionsSource)}) is host-bound — it only works inside defineWorkflow({ vars }) (pass a name list otherwise)`);
@@ -4725,11 +4910,13 @@ var ImageVar = class extends ComfyVar {
4725
4910
  };
4726
4911
  /** the var constructors: v.text / v.prompt / v.int / v.float / v.seed / v.toggle / v.choice / v.loras / v.size / v.image */
4727
4912
  const v = {
4728
- text: (defaultValue, label) => new TextVar(defaultValue, label),
4913
+ text: (defaultValue, opts = {}) => new TextVar(defaultValue, typeof opts === "string" ? { label: opts } : opts),
4729
4914
  prompt: (defaultValue, opts = {}) => new PromptVar(defaultValue, opts),
4730
4915
  int: (defaultValue, opts = {}) => new IntVar(defaultValue, opts),
4731
4916
  float: (defaultValue, opts = {}) => new FloatVar(defaultValue, opts),
4732
- seed: (defaultValue = 0, label) => new SeedVar(defaultValue, label),
4917
+ /** `mode` is the SPEC default the workflow runs in: `'+'` makes every run step the seed,
4918
+ * which is what a tuning session wants, and reset()/revert come back to it */
4919
+ seed: (defaultValue = 0, opts = {}) => new SeedVar(defaultValue, opts),
4733
4920
  toggle: (defaultValue, label) => new ToggleVar(defaultValue, label),
4734
4921
  choice: (choices, defaultValue, label) => new ChoiceVar(choices, defaultValue, label),
4735
4922
  loras: (options, initial = {}, label) => new LorasVar(options, initial, label),
@@ -5076,6 +5263,7 @@ var ComfyHost = class {
5076
5263
  this.activePromptID = null;
5077
5264
  this.latentPreview = null;
5078
5265
  this.onLatentPreview = null;
5266
+ this.onProgressText = null;
5079
5267
  this.onStatus = null;
5080
5268
  this.onSession = null;
5081
5269
  this.onLogs = null;
@@ -5289,6 +5477,17 @@ var ComfyHost = class {
5289
5477
  this._unknownBinaryFrameTypes.add(frame.eventType);
5290
5478
  console.error(`🔴 unknown binary ws frame type ${frame.eventType} from host ${this.data.id} — ignored`);
5291
5479
  }
5480
+ if (frame.kind === "text") {
5481
+ (this.activePromptID != null ? this.executions.get(this.activePromptID) : null)?.onProgressText({
5482
+ nodeId: frame.nodeId,
5483
+ text: frame.text
5484
+ });
5485
+ this.onProgressText?.({
5486
+ nodeId: frame.nodeId,
5487
+ text: frame.text,
5488
+ promptID: this.activePromptID
5489
+ });
5490
+ }
5292
5491
  return;
5293
5492
  }
5294
5493
  const msg_ = JSON.parse(String(e.data));
@@ -6010,6 +6209,6 @@ function loraTag(name, strength = 1, clipStrength) {
6010
6209
  */
6011
6210
  setDefaultComfyStorage(createMemoryStorage());
6012
6211
  //#endregion
6013
- export { ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyHostUnreachableError, 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_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, parseHostBase, parseWorkflowJson, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, v };
6212
+ export { ChoiceVar, ComfyExecution, ComfyHost, ComfyHostAuthError, ComfyHostUnreachableError, 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, activePresetLabel, asAbsolutePath, asHTMLContent, asMDContent, asRelativePath, auto, auto_, clearLoraKeywordOverride, codegenSDK, convertFlowToLiteGraphJSON, convertLiteGraphToPrompt, createMemoryStorage, getComfyStorage, getLoraDisplayName, getLoraInfo, getLoraKeyword, getLoraPreviewUrl, getLoraTriggerWords, hostIdToNamespace, isLoraKeywordFromMirror, loraKey, loraKeywordFromMirror, loraMatchesFilter, loraSearchNames, loraSearchText, loraTag, normalizeWorkflow, parseHostBase, parseWorkflowJson, refreshLoraInfoCacheIfChanged, reloadLoraInfoCache, renderHttpBase, renderWsUrl, resultFailure, resultSuccess, setDefaultComfyStorage, setLoraKeyword, toPresetList, v };
6014
6213
 
6015
6214
  //# sourceMappingURL=web.js.map