comfy-ts 2.18.0 → 2.18.1

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.
package/dist/index.d.cts CHANGED
@@ -16519,6 +16519,8 @@ declare const ComfyManagerAPIPluginList_ark: import("arktype/internal/variants/o
16519
16519
  /** the part of the registry the views read */
16520
16520
  type ManagerMirror = {
16521
16521
  plugins_byTitle: ReadonlyMap<KnownComfyPluginTitle, ComfyManagerPluginInfo>;
16522
+ plugins_byFile: ReadonlyMap<string, ComfyManagerPluginInfo>;
16523
+ plugins_byNodeKey: ReadonlyMap<string, readonly ComfyManagerPluginInfo[]>;
16522
16524
  /** every model row: upstream ships a few names twice, with different files */
16523
16525
  modelRows: readonly ComfyManagerModelInfo[];
16524
16526
  };
@@ -16584,11 +16586,14 @@ type ManagerApi = {
16584
16586
  generation: ManagerGeneration;
16585
16587
  version: string;
16586
16588
  };
16587
- /** install waits poll the queue; tests pass milliseconds */
16589
+ /** install waits poll the queue; `pollGraceMs`: how long the poll survives a host that does not answer */
16588
16590
  type ManagerTiming = {
16589
16591
  pollMs: number;
16590
16592
  installTimeoutMs: number;
16593
+ pollGraceMs: number;
16591
16594
  };
16595
+ /** `unknown`: we lost sight of the task, the Manager may still be installing (agent/architecture.md) */
16596
+ type InstallOutcome = 'installed' | 'failed' | 'unknown';
16592
16597
  declare class ComfyManager {
16593
16598
  host: {
16594
16599
  getServerHostHTTP: () => string;
@@ -16638,26 +16643,39 @@ declare class ComfyManager {
16638
16643
  /** what the host has of our model mirror; a model absent from the list reads `unknown` */
16639
16644
  fetchModels: () => Promise<ComfyManagerAPIModelList>;
16640
16645
  fetchLogs: () => Promise<any>;
16646
+ /** true only for a KNOWN install: false is "not known to be installed" (missing OR undecided), see `getModelStatus` */
16641
16647
  isModelInstalled: (name: KnownModel_Name) => boolean;
16642
16648
  modelsBeeingInstalled: Set<KnownModel_Name>;
16643
- /** queue the install, wait until the Manager ran it; true only once the model is verified installed */
16649
+ /** queue the install, wait until the Manager ran it; true only once the model is verified installed (`installModelOutcome` tells failed from unknown) */
16644
16650
  installModel: (model: ComfyManagerModelInfo) => Promise<boolean>;
16651
+ installModelOutcome: (model: ComfyManagerModelInfo) => Promise<InstallOutcome>;
16645
16652
  getModelStatus: (modelName: KnownModel_Name) => PluginInstallStatus;
16646
16653
  /**
16647
16654
  * you need to call `fetchPluginList()` to populate this field
16648
16655
  */
16649
16656
  pluginList: Maybe<ComfyManagerAPIPluginList>;
16650
16657
  get titlesOfAllInstalledPlugins(): KnownComfyPluginTitle[];
16658
+ /** true only for a KNOWN install: false is "not known to be installed" (missing OR undecided), see `getPluginStatus` */
16651
16659
  isPluginInstalled: (title: KnownComfyPluginTitle) => boolean;
16652
16660
  getPluginStatus: (title: KnownComfyPluginTitle) => PluginInstallStatus;
16661
+ /** one requirement against the fetched lists; `unknown` when they cannot say, null when the mirror does not know it */
16662
+ requirementStatus: (req: Requirements) => PluginInstallStatus | null;
16663
+ /** `missing`: known not installed, the only requirements an install flow may queue; `undecided`: the lists cannot say */
16664
+ checkRequirements: (requirements: Requirements[]) => {
16665
+ missing: Requirements[];
16666
+ undecided: Requirements[];
16667
+ };
16668
+ /** false only when a requirement is known missing; an undecided one passes with a warning */
16669
+ matchRequirements: (requirements: Requirements[]) => boolean;
16653
16670
  /** the host's plugin list in the public `custom_nodes` shape, titled like our mirror; absent = `unknown` */
16654
16671
  fetchPlugins: (
16655
16672
  /** @default: 'cache' */
16656
16673
  mode?: ComfyManagerAPIFetchPolicy,
16657
16674
  /** @default: true */
16658
16675
  skipUpdate?: boolean) => Promise<ComfyManagerAPIPluginList>;
16659
- /** queue the install, wait until the Manager ran it; true only once the pack is verified installed */
16676
+ /** queue the install, wait until the Manager ran it; true only once the pack is verified installed (`installPluginOutcome` tells failed from unknown) */
16660
16677
  installPlugin: (plugin: ComfyManagerPluginInfo) => Promise<boolean>;
16678
+ installPluginOutcome: (plugin: ComfyManagerPluginInfo) => Promise<InstallOutcome>;
16661
16679
  /** the Manager's own getlist (v3, v4 legacy ui), normalized */
16662
16680
  private listedPlugins;
16663
16681
  private fetchPluginWire;
@@ -16670,9 +16688,9 @@ declare class ComfyManager {
16670
16688
  private installedModelView;
16671
16689
  /** v3 and v4 legacy ui: the Manager's own list row for the pack, sent like its own ui does */
16672
16690
  private enqueueListedPlugin;
16673
- /** v4: no list to take a row from, so the pack goes by repo name at nightly */
16691
+ /** v4: no list to take a row from, so the pack goes by repo name at nightly; resolves with that id */
16674
16692
  private enqueuePluginTask;
16675
- /** v4: the task's own history entry says how it ended */
16693
+ /** v4: the task's own history entry says how it ended; the end state confirms a success */
16676
16694
  private settleByHistory;
16677
16695
  /**
16678
16696
  * a worker lingers a few seconds after a drain, then exits; a start in that window answers 201
@@ -16682,8 +16700,14 @@ declare class ComfyManager {
16682
16700
  private restartIdleQueue;
16683
16701
  /** v3, v4 legacy ui: no per item result over http, so wait for the drain and look at the end state */
16684
16702
  private settleByDrain;
16703
+ /** the end state after the task ran: a host that does not answer here leaves the outcome unknown */
16704
+ private endState;
16685
16705
  private runInstall;
16686
- /** poll until `check` gives a value, never past `timing.installTimeoutMs` */
16706
+ /**
16707
+ * poll until `check` gives a value. A failed request is a blip: logged, and the poll goes on until
16708
+ * `timing.pollGraceMs` passes without one good answer. Giving up, or the deadline, is an UNKNOWN
16709
+ * outcome (the task may still run); only an `InstallFailed` from `check` ends the wait as a failure.
16710
+ */
16687
16711
  private waitFor;
16688
16712
  /** json POST (the Manager's csrf guard refuses simple form types); the reply json, or null when empty */
16689
16713
  private post;
@@ -17679,8 +17703,13 @@ declare class ComfyHost<ID extends string = string> {
17679
17703
  constructor(data: ComfyHostData & {
17680
17704
  id: ID;
17681
17705
  });
17682
- /** helper to check if your host have whatever it needs to run your workflow */
17706
+ /** false only when a requirement is known missing; an undecided one passes with a warning (manager.matchRequirements) */
17683
17707
  matchRequirements: (requirements: Requirements[]) => boolean;
17708
+ /** `missing` (known not installed, the only ones to queue for install) and `undecided` (the lists cannot say) */
17709
+ checkRequirements: (requirements: Requirements[]) => {
17710
+ missing: Requirements[];
17711
+ undecided: Requirements[];
17712
+ };
17684
17713
  /** server sent by the comfy-manager plugin */
17685
17714
  readonly serverLogs: ServerLog[];
17686
17715
  /** if true, request ComfyUI to forward logs */
@@ -18624,7 +18653,7 @@ type CanonicalGroup = {
18624
18653
  };
18625
18654
  //#endregion
18626
18655
  //#region src/litegraph/normalizeWorkflow.d.ts
18627
- type WorkflowNormalizeErrorCode = 'schema-reject' | 'subgraph-cycle' | 'subgraph-io-mismatch' | 'bad-document';
18656
+ type WorkflowNormalizeErrorCode = 'schema-reject' | 'subgraph-cycle' | 'subgraph-too-large' | 'subgraph-io-mismatch' | 'bad-document';
18628
18657
  /** a workflow JSON we cannot turn into a CanonicalWorkflow — loud, typed, never a cast */
18629
18658
  declare class WorkflowNormalizeError extends Error {
18630
18659
  code: WorkflowNormalizeErrorCode;
package/dist/index.d.ts CHANGED
@@ -16519,6 +16519,8 @@ declare const ComfyManagerAPIPluginList_ark: import("arktype/internal/variants/o
16519
16519
  /** the part of the registry the views read */
16520
16520
  type ManagerMirror = {
16521
16521
  plugins_byTitle: ReadonlyMap<KnownComfyPluginTitle, ComfyManagerPluginInfo>;
16522
+ plugins_byFile: ReadonlyMap<string, ComfyManagerPluginInfo>;
16523
+ plugins_byNodeKey: ReadonlyMap<string, readonly ComfyManagerPluginInfo[]>;
16522
16524
  /** every model row: upstream ships a few names twice, with different files */
16523
16525
  modelRows: readonly ComfyManagerModelInfo[];
16524
16526
  };
@@ -16584,11 +16586,14 @@ type ManagerApi = {
16584
16586
  generation: ManagerGeneration;
16585
16587
  version: string;
16586
16588
  };
16587
- /** install waits poll the queue; tests pass milliseconds */
16589
+ /** install waits poll the queue; `pollGraceMs`: how long the poll survives a host that does not answer */
16588
16590
  type ManagerTiming = {
16589
16591
  pollMs: number;
16590
16592
  installTimeoutMs: number;
16593
+ pollGraceMs: number;
16591
16594
  };
16595
+ /** `unknown`: we lost sight of the task, the Manager may still be installing (agent/architecture.md) */
16596
+ type InstallOutcome = 'installed' | 'failed' | 'unknown';
16592
16597
  declare class ComfyManager {
16593
16598
  host: {
16594
16599
  getServerHostHTTP: () => string;
@@ -16638,26 +16643,39 @@ declare class ComfyManager {
16638
16643
  /** what the host has of our model mirror; a model absent from the list reads `unknown` */
16639
16644
  fetchModels: () => Promise<ComfyManagerAPIModelList>;
16640
16645
  fetchLogs: () => Promise<any>;
16646
+ /** true only for a KNOWN install: false is "not known to be installed" (missing OR undecided), see `getModelStatus` */
16641
16647
  isModelInstalled: (name: KnownModel_Name) => boolean;
16642
16648
  modelsBeeingInstalled: Set<KnownModel_Name>;
16643
- /** queue the install, wait until the Manager ran it; true only once the model is verified installed */
16649
+ /** queue the install, wait until the Manager ran it; true only once the model is verified installed (`installModelOutcome` tells failed from unknown) */
16644
16650
  installModel: (model: ComfyManagerModelInfo) => Promise<boolean>;
16651
+ installModelOutcome: (model: ComfyManagerModelInfo) => Promise<InstallOutcome>;
16645
16652
  getModelStatus: (modelName: KnownModel_Name) => PluginInstallStatus;
16646
16653
  /**
16647
16654
  * you need to call `fetchPluginList()` to populate this field
16648
16655
  */
16649
16656
  pluginList: Maybe<ComfyManagerAPIPluginList>;
16650
16657
  get titlesOfAllInstalledPlugins(): KnownComfyPluginTitle[];
16658
+ /** true only for a KNOWN install: false is "not known to be installed" (missing OR undecided), see `getPluginStatus` */
16651
16659
  isPluginInstalled: (title: KnownComfyPluginTitle) => boolean;
16652
16660
  getPluginStatus: (title: KnownComfyPluginTitle) => PluginInstallStatus;
16661
+ /** one requirement against the fetched lists; `unknown` when they cannot say, null when the mirror does not know it */
16662
+ requirementStatus: (req: Requirements) => PluginInstallStatus | null;
16663
+ /** `missing`: known not installed, the only requirements an install flow may queue; `undecided`: the lists cannot say */
16664
+ checkRequirements: (requirements: Requirements[]) => {
16665
+ missing: Requirements[];
16666
+ undecided: Requirements[];
16667
+ };
16668
+ /** false only when a requirement is known missing; an undecided one passes with a warning */
16669
+ matchRequirements: (requirements: Requirements[]) => boolean;
16653
16670
  /** the host's plugin list in the public `custom_nodes` shape, titled like our mirror; absent = `unknown` */
16654
16671
  fetchPlugins: (
16655
16672
  /** @default: 'cache' */
16656
16673
  mode?: ComfyManagerAPIFetchPolicy,
16657
16674
  /** @default: true */
16658
16675
  skipUpdate?: boolean) => Promise<ComfyManagerAPIPluginList>;
16659
- /** queue the install, wait until the Manager ran it; true only once the pack is verified installed */
16676
+ /** queue the install, wait until the Manager ran it; true only once the pack is verified installed (`installPluginOutcome` tells failed from unknown) */
16660
16677
  installPlugin: (plugin: ComfyManagerPluginInfo) => Promise<boolean>;
16678
+ installPluginOutcome: (plugin: ComfyManagerPluginInfo) => Promise<InstallOutcome>;
16661
16679
  /** the Manager's own getlist (v3, v4 legacy ui), normalized */
16662
16680
  private listedPlugins;
16663
16681
  private fetchPluginWire;
@@ -16670,9 +16688,9 @@ declare class ComfyManager {
16670
16688
  private installedModelView;
16671
16689
  /** v3 and v4 legacy ui: the Manager's own list row for the pack, sent like its own ui does */
16672
16690
  private enqueueListedPlugin;
16673
- /** v4: no list to take a row from, so the pack goes by repo name at nightly */
16691
+ /** v4: no list to take a row from, so the pack goes by repo name at nightly; resolves with that id */
16674
16692
  private enqueuePluginTask;
16675
- /** v4: the task's own history entry says how it ended */
16693
+ /** v4: the task's own history entry says how it ended; the end state confirms a success */
16676
16694
  private settleByHistory;
16677
16695
  /**
16678
16696
  * a worker lingers a few seconds after a drain, then exits; a start in that window answers 201
@@ -16682,8 +16700,14 @@ declare class ComfyManager {
16682
16700
  private restartIdleQueue;
16683
16701
  /** v3, v4 legacy ui: no per item result over http, so wait for the drain and look at the end state */
16684
16702
  private settleByDrain;
16703
+ /** the end state after the task ran: a host that does not answer here leaves the outcome unknown */
16704
+ private endState;
16685
16705
  private runInstall;
16686
- /** poll until `check` gives a value, never past `timing.installTimeoutMs` */
16706
+ /**
16707
+ * poll until `check` gives a value. A failed request is a blip: logged, and the poll goes on until
16708
+ * `timing.pollGraceMs` passes without one good answer. Giving up, or the deadline, is an UNKNOWN
16709
+ * outcome (the task may still run); only an `InstallFailed` from `check` ends the wait as a failure.
16710
+ */
16687
16711
  private waitFor;
16688
16712
  /** json POST (the Manager's csrf guard refuses simple form types); the reply json, or null when empty */
16689
16713
  private post;
@@ -17679,8 +17703,13 @@ declare class ComfyHost<ID extends string = string> {
17679
17703
  constructor(data: ComfyHostData & {
17680
17704
  id: ID;
17681
17705
  });
17682
- /** helper to check if your host have whatever it needs to run your workflow */
17706
+ /** false only when a requirement is known missing; an undecided one passes with a warning (manager.matchRequirements) */
17683
17707
  matchRequirements: (requirements: Requirements[]) => boolean;
17708
+ /** `missing` (known not installed, the only ones to queue for install) and `undecided` (the lists cannot say) */
17709
+ checkRequirements: (requirements: Requirements[]) => {
17710
+ missing: Requirements[];
17711
+ undecided: Requirements[];
17712
+ };
17684
17713
  /** server sent by the comfy-manager plugin */
17685
17714
  readonly serverLogs: ServerLog[];
17686
17715
  /** if true, request ComfyUI to forward logs */
@@ -18624,7 +18653,7 @@ type CanonicalGroup = {
18624
18653
  };
18625
18654
  //#endregion
18626
18655
  //#region src/litegraph/normalizeWorkflow.d.ts
18627
- type WorkflowNormalizeErrorCode = 'schema-reject' | 'subgraph-cycle' | 'subgraph-io-mismatch' | 'bad-document';
18656
+ type WorkflowNormalizeErrorCode = 'schema-reject' | 'subgraph-cycle' | 'subgraph-too-large' | 'subgraph-io-mismatch' | 'bad-document';
18628
18657
  /** a workflow JSON we cannot turn into a CanonicalWorkflow — loud, typed, never a cast */
18629
18658
  declare class WorkflowNormalizeError extends Error {
18630
18659
  code: WorkflowNormalizeErrorCode;
package/dist/index.js CHANGED
@@ -110,7 +110,7 @@ function createNodeStorage() {
110
110
  }
111
111
  //#endregion
112
112
  //#region package.json
113
- var version = "2.18.0";
113
+ var version = "2.18.1";
114
114
  //#endregion
115
115
  //#region src/litegraph/LiteGraphLinkID.ts
116
116
  const asLiteGraphLinkID = (id) => id;
@@ -130,8 +130,55 @@ const bang = (x, msg = "") => {
130
130
  /** boundary sentinel ids inside definition link tables */
131
131
  const SUBGRAPH_INPUT_NODE_ID = -10;
132
132
  const SUBGRAPH_OUTPUT_NODE_ID = -20;
133
- /** 48 corpus files nest defs inside defs; a self-referencing def would loop forever */
134
- const MAX_EXPANSION_PASSES = 32;
133
+ /** expanded node count above which a file is refused before expanding: the largest official
134
+ * template expands to 575 nodes, and fan-out nesting grows geometrically without any cycle */
135
+ const MAX_EXPANDED_NODES = 1e5;
136
+ /**
137
+ * before any expansion: the definitions as a graph (def → the defs its NORMAL-mode instances name,
138
+ * the only ones expansion follows). A cycle reachable from the root is refused with the defs it
139
+ * runs through, and the expanded size is counted, not built, and refused above
140
+ * MAX_EXPANDED_NODES. One explicit stack, no recursion: the file decides the depth
141
+ */
142
+ const checkExpansion = (wf, defs) => {
143
+ const children = (nodes) => nodes.filter((n) => n.mode === "normal" && defs.has(n.type)).map((n) => n.type);
144
+ const own = (nodes) => nodes.filter((n) => !(n.mode === "normal" && defs.has(n.type))).length;
145
+ const name = (id) => JSON.stringify(defs.get(id)?.name ?? id);
146
+ const cap = (n) => Math.min(n, 100001);
147
+ const size = /* @__PURE__ */ new Map();
148
+ const onPath = /* @__PURE__ */ new Set();
149
+ for (const root of new Set(children(wf.nodes))) {
150
+ if (size.has(root)) continue;
151
+ const stack = [{
152
+ id: root,
153
+ kids: children(bang(defs.get(root)).nodes),
154
+ next: 0
155
+ }];
156
+ onPath.add(root);
157
+ while (stack.length > 0) {
158
+ const top = bang(stack[stack.length - 1]);
159
+ const kid = top.kids[top.next++];
160
+ if (kid == null) {
161
+ const total = top.kids.reduce((acc, k) => cap(acc + (size.get(k) ?? 0)), own(bang(defs.get(top.id)).nodes));
162
+ size.set(top.id, total);
163
+ onPath.delete(top.id);
164
+ stack.pop();
165
+ continue;
166
+ }
167
+ if (size.has(kid)) continue;
168
+ if (onPath.has(kid)) {
169
+ const from = stack.findIndex((frame) => frame.id === kid);
170
+ throw new WorkflowNormalizeError("subgraph-cycle", `subgraph definitions contain themselves: ${[...stack.slice(from).map((frame) => frame.id), kid].map(name).join(" → ")}`, { cycle: stack.slice(from).map((frame) => frame.id) });
171
+ }
172
+ onPath.add(kid);
173
+ stack.push({
174
+ id: kid,
175
+ kids: children(bang(defs.get(kid)).nodes),
176
+ next: 0
177
+ });
178
+ }
179
+ }
180
+ if (children(wf.nodes).reduce((acc, k) => cap(acc + (size.get(k) ?? 0)), own(wf.nodes)) > 1e5) throw new WorkflowNormalizeError("subgraph-too-large", `subgraph expansion would produce more than ${MAX_EXPANDED_NODES} nodes (the largest official template has 575)`);
181
+ };
135
182
  /**
136
183
  * widget-kind fallback when a def input slot has no boundary target carrying a
137
184
  * widget marker: these litegraph slot types carry widget values. LOCAL copy on
@@ -154,11 +201,12 @@ const PRIMITIVE_WIDGET_TYPES = /* @__PURE__ */ new Set([
154
201
  * passthrough walk, which needs no interior.
155
202
  */
156
203
  const expandSubgraphs = (wf, defs) => {
204
+ checkExpansion(wf, defs);
157
205
  let passes = 0;
158
206
  while (true) {
159
207
  const expandable = wf.nodes.filter((n) => defs.has(n.type) && n.mode !== "bypassed");
160
208
  if (expandable.length === 0) return wf;
161
- if (++passes > MAX_EXPANSION_PASSES) throw new WorkflowNormalizeError("subgraph-cycle", `subgraph expansion did not terminate after ${MAX_EXPANSION_PASSES} passes — self-referencing definitions?`);
209
+ if (++passes > defs.size + 1) throw new WorkflowNormalizeError("subgraph-cycle", `subgraph expansion still had instances after ${passes - 1} passes over ${defs.size} definitions`);
162
210
  for (const instance of expandable) if (instance.mode === "muted") dropMutedInstance(wf, instance);
163
211
  else expandOneInstance(wf, instance, bang(defs.get(instance.type)));
164
212
  }
@@ -1053,6 +1101,8 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
1053
1101
  if (node.widgets.positional.length > 0) PRIMITIVE_VALUES[node.id] = node.widgets.positional[0];
1054
1102
  else if (Object.hasOwn(node.widgets.named, "value")) PRIMITIVE_VALUES[node.id] = node.widgets.named["value"];
1055
1103
  }
1104
+ const linksById = new Map(workflow.links.map((l) => [l.id, l]));
1105
+ const nodesById = new Map(workflow.nodes.map((n) => [n.id, n]));
1056
1106
  for (const node of workflow.nodes) {
1057
1107
  if (isNeverExecuted(node)) continue;
1058
1108
  if (node.mode !== "normal") continue;
@@ -1231,9 +1281,9 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
1231
1281
  }
1232
1282
  }
1233
1283
  const getParentNode = (linkId) => {
1234
- const link = workflow.links.find((link) => link.id === linkId);
1284
+ const link = linksById.get(linkId);
1235
1285
  if (link == null) throw new WorkflowConvertError("dangling-link", `node ${node.id}(${node.type}) references a non-existing link (id=${linkId})`, node);
1236
- const parentNode = workflow.nodes.find((n) => n.id === link.originId);
1286
+ const parentNode = nodesById.get(link.originId);
1237
1287
  if (parentNode == null) throw new WorkflowConvertError("dangling-link", `link ${linkId} references a non-existent parent node ${link.originId}`, node);
1238
1288
  return {
1239
1289
  node: parentNode,
@@ -1359,15 +1409,20 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
1359
1409
  }
1360
1410
  }
1361
1411
  if (missing.size > 0) {
1362
- const complete = (id, seen) => {
1363
- if (seen.has(id)) return true;
1364
- seen.add(id);
1365
- if (missing.has(id)) return false;
1366
- for (const value of Object.values(prompt[id]?.inputs ?? {})) if (Array.isArray(value) && typeof value[0] === "string" && !complete(value[0], seen)) return false;
1367
- return true;
1368
- };
1412
+ const consumers = /* @__PURE__ */ new Map();
1413
+ for (const [id, n] of Object.entries(prompt)) for (const value of Object.values(n.inputs)) if (Array.isArray(value) && typeof value[0] === "string") {
1414
+ const list = consumers.get(value[0]) ?? [];
1415
+ list.push(id);
1416
+ consumers.set(value[0], list);
1417
+ }
1418
+ const blocked = new Set(missing.keys());
1419
+ const queue = [...blocked];
1420
+ for (let head = 0; head < queue.length; head++) for (const next of consumers.get(queue[head] ?? "") ?? []) if (!blocked.has(next)) {
1421
+ blocked.add(next);
1422
+ queue.push(next);
1423
+ }
1369
1424
  const outputs = Object.keys(prompt).filter((id) => schema.data.spec[prompt[id]?.class_type ?? ""]?.output_node === true);
1370
- const dropped = outputs.filter((id) => !complete(id, /* @__PURE__ */ new Set()));
1425
+ const dropped = outputs.filter((id) => blocked.has(id));
1371
1426
  const first = missing.values().next().value;
1372
1427
  if (first != null && outputs.length > 0 && dropped.length === outputs.length) throw new WorkflowConvertError("missing-required-input", first.message, first.node);
1373
1428
  if (dropped.length > 0 || outputs.length === 0) console.warn(`🟡 [workflow] ComfyUI will skip output node(s) ${dropped.join(", ") || "(none in this graph)"}: ${[...missing.values()].map((m) => m.message).join("; ")}`);
@@ -4423,8 +4478,13 @@ const ComfyManagerAPIPackList_ark = type({
4423
4478
  /** 🔶 NAMING DISCLAIMER: I call a "custom node package" => "PLUGIN" */
4424
4479
  const MANAGER_TIMING = {
4425
4480
  pollMs: 1e3,
4426
- installTimeoutMs: 60 * 6e4
4481
+ installTimeoutMs: 60 * 6e4,
4482
+ pollGraceMs: 12e4
4427
4483
  };
4484
+ /** an install the host refused or reported failed: ends the wait at once */
4485
+ var InstallFailed = class extends Error {};
4486
+ /** we lost sight of the task: the outcome is not known */
4487
+ var OutcomeUnknown = class extends Error {};
4428
4488
  /** what each generation does NOT serve (history means the `?ui_id=` form) */
4429
4489
  const NOT_SERVED = {
4430
4490
  v3: [
@@ -4530,7 +4590,7 @@ var ComfyManager = class {
4530
4590
  fetchPlugins: () => this.installedPluginView(api),
4531
4591
  fetchModels: () => this.installedModelView(),
4532
4592
  enqueuePlugin: (plugin, uiId) => this.enqueuePluginTask(api, plugin, uiId),
4533
- settle: (what, uiId) => this.settleByHistory(api, what, uiId)
4593
+ settle: (what, uiId, landed, sentId) => this.settleByHistory(api, what, uiId, landed, sentId)
4534
4594
  };
4535
4595
  }
4536
4596
  };
@@ -4579,7 +4639,8 @@ var ComfyManager = class {
4579
4639
  return this.modelList?.models.some((x) => x.name === name && x.installed === "True") ?? false;
4580
4640
  };
4581
4641
  this.modelsBeeingInstalled = /* @__PURE__ */ new Set();
4582
- this.installModel = async (model) => {
4642
+ this.installModel = async (model) => await this.installModelOutcome(model) === "installed";
4643
+ this.installModelOutcome = async (model) => {
4583
4644
  this.modelsBeeingInstalled.add(model.name);
4584
4645
  try {
4585
4646
  return await this.runInstall(`model "${model.name}"`, {
@@ -4592,7 +4653,8 @@ var ComfyManager = class {
4592
4653
  await this.post(this.route(api, "/manager/queue/install_model"), body);
4593
4654
  },
4594
4655
  landed: async (s) => {
4595
- return (await s.fetchModels()).models.find((x) => x.filename === model.filename && x.save_path === model.save_path && x.base === model.base)?.installed === "True";
4656
+ const row = (await s.fetchModels()).models.find((x) => x.filename === model.filename && x.save_path === model.save_path && x.base === model.base);
4657
+ return row == null ? null : row.installed === "True";
4596
4658
  }
4597
4659
  });
4598
4660
  } finally {
@@ -4626,10 +4688,43 @@ var ComfyManager = class {
4626
4688
  return "error";
4627
4689
  })();
4628
4690
  };
4691
+ this.requirementStatus = (req) => {
4692
+ const mirror = this.mirror();
4693
+ const packs = (() => {
4694
+ if (req.type === "customNodesByNodeKey") return mirror.plugins_byNodeKey.get(req.nodeName) ?? [];
4695
+ if (req.type === "customNodesByTitle") return [mirror.plugins_byTitle.get(req.title)].filter((x) => x != null);
4696
+ if (req.type === "customNodesByURI") return [mirror.plugins_byFile.get(req.uri)].filter((x) => x != null);
4697
+ return null;
4698
+ })();
4699
+ if (packs == null) return req.type === "modelInManager" ? this.getModelStatus(req.modelName) : null;
4700
+ if (packs.length === 0) return req.type === "customNodesByNodeKey" ? "unknown" : null;
4701
+ const statuses = packs.map((x) => this.getPluginStatus(x.title));
4702
+ if (statuses.some((x) => x === "installed" || x === "update-available")) return "installed";
4703
+ return statuses.every((x) => x === "not-installed") ? "not-installed" : "unknown";
4704
+ };
4705
+ this.checkRequirements = (requirements) => {
4706
+ const out = {
4707
+ missing: [],
4708
+ undecided: []
4709
+ };
4710
+ for (const req of requirements) {
4711
+ if (req.optional) continue;
4712
+ const status = this.requirementStatus(req);
4713
+ if (status === "not-installed") out.missing.push(req);
4714
+ else if (status === "unknown" || status === "error") out.undecided.push(req);
4715
+ }
4716
+ return out;
4717
+ };
4718
+ this.matchRequirements = (requirements) => {
4719
+ const check = this.checkRequirements(requirements);
4720
+ if (check.undecided.length > 0) logError(`requirements the host lists cannot decide, read as present: ${check.undecided.map((r) => JSON.stringify(r)).join(", ")}` + (this.pluginList == null || this.modelList == null ? " (the lists are not fetched: call fetchPluginsAndModels)" : ""));
4721
+ return check.missing.length === 0;
4722
+ };
4629
4723
  this.fetchPlugins = async (mode = "cache", skipUpdate = true) => {
4630
4724
  return this.strategy(await this.api()).fetchPlugins(mode, skipUpdate);
4631
4725
  };
4632
- this.installPlugin = async (plugin) => {
4726
+ this.installPlugin = async (plugin) => await this.installPluginOutcome(plugin) === "installed";
4727
+ this.installPluginOutcome = async (plugin) => {
4633
4728
  return this.runInstall(`plugin "${plugin.title}"`, {
4634
4729
  enqueue: (api, uiId) => this.strategy(api).enqueuePlugin(plugin, uiId),
4635
4730
  landed: async (_s, api) => {
@@ -4706,8 +4801,9 @@ var ComfyManager = class {
4706
4801
  };
4707
4802
  this.enqueuePluginTask = async (api, plugin, uiId) => {
4708
4803
  const url = plugin.files[0] ?? plugin.reference;
4804
+ const id = repoPath(url).split("/").pop() ?? url;
4709
4805
  const params = {
4710
- id: repoPath(url).split("/").pop() ?? url,
4806
+ id,
4711
4807
  version: "nightly",
4712
4808
  selected_version: "nightly",
4713
4809
  repository: url,
@@ -4720,18 +4816,26 @@ var ComfyManager = class {
4720
4816
  kind: "install",
4721
4817
  params
4722
4818
  });
4819
+ return id;
4723
4820
  };
4724
- this.settleByHistory = async (api, what, uiId) => {
4821
+ this.settleByHistory = async (api, what, uiId, landed, sentId) => {
4725
4822
  const route = this.route(api, "/manager/queue/history", `?ui_id=${encodeURIComponent(uiId)}`);
4823
+ const readEntry = async () => (await this.getValid(route, TaskHistory_ark)).history.status ?? null;
4726
4824
  const entry = await this.waitFor(what, async () => {
4727
- const status = (await this.getValid(route, TaskHistory_ark)).history.status;
4728
- if (status == null) await this.restartIdleQueue(api);
4729
- return status ?? null;
4825
+ const status = await readEntry();
4826
+ if (status != null) return status;
4827
+ if (await this.restartIdleQueue(api) !== "drained") return null;
4828
+ const late = await readEntry();
4829
+ if (late != null) return late;
4830
+ throw new InstallFailed("the task left the queue with no result (a queue/reset from the Manager UI or another client removes it)");
4730
4831
  });
4731
- if (entry.status_str === "success" || entry.status_str === "skip") return;
4832
+ if (entry.status_str === "success" || entry.status_str === "skip") {
4833
+ if (await this.endState(landed) !== false) return;
4834
+ throw new InstallFailed(sentId != null ? `the Manager reported success, but this pack does not read installed: another pack holds the id "${sentId}" it installs by` : "the Manager reported success, but it does not read installed afterwards");
4835
+ }
4732
4836
  const messages = entry.messages ?? [];
4733
4837
  const gate = messages.length === 1 && messages[0] === "failed" ? ": refused by its security policy, which allows installs only with security_level normal or below AND either ComfyUI listening on localhost or network_mode personal_cloud (the ComfyUI console names the rule)" : "";
4734
- throw new Error(`the Manager reports ${entry.status_str}: ${messages.join(" | ")}${gate}`);
4838
+ throw new InstallFailed(`the Manager reports ${entry.status_str}: ${messages.join(" | ")}${gate}`);
4735
4839
  };
4736
4840
  this.restartIdleQueue = async (api) => {
4737
4841
  const status = await this.getValid(this.route(api, "/manager/queue/status"), QueueStatus_ark);
@@ -4742,29 +4846,52 @@ var ComfyManager = class {
4742
4846
  };
4743
4847
  this.settleByDrain = async (api, what, landed) => {
4744
4848
  await this.waitFor(what, async () => await this.restartIdleQueue(api) === "drained" ? true : null);
4745
- if (!await landed()) throw new Error(`the Manager queue drained but it is not installed; ComfyUI-Manager ${api.version} reports why only over its websocket (cm-queue-status) and in the ComfyUI console`);
4849
+ const state = await this.endState(landed);
4850
+ if (state === true) return;
4851
+ if (state === null) throw new OutcomeUnknown("the queue drained, but the lists cannot say whether it is installed");
4852
+ throw new InstallFailed(`the Manager queue drained but it is not installed; ComfyUI-Manager ${api.version} reports why only over its websocket (cm-queue-status) and in the ComfyUI console`);
4853
+ };
4854
+ this.endState = async (landed) => {
4855
+ try {
4856
+ return await landed();
4857
+ } catch (exception) {
4858
+ throw new OutcomeUnknown(`the task ran, but its end state could not be read: ${errorText(exception)}`);
4859
+ }
4746
4860
  };
4747
4861
  this.runInstall = async (what, p) => {
4862
+ const host = this.host.getServerHostHTTP();
4748
4863
  try {
4749
4864
  const api = await this.api();
4750
4865
  const s = this.strategy(api);
4751
4866
  const uiId = nanoid();
4752
- await p.enqueue(api, uiId);
4867
+ const sentId = await p.enqueue(api, uiId);
4753
4868
  await this.post(this.route(api, "/manager/queue/start"));
4754
- await s.settle(what, uiId, () => p.landed(s, api));
4869
+ await s.settle(what, uiId, () => p.landed(s, api), sentId);
4755
4870
  logSuccess(`${what} installed`);
4756
- return true;
4871
+ return "installed";
4757
4872
  } catch (exception) {
4758
- logError(`${what}: install failed on ${this.host.getServerHostHTTP()}: ${errorText(exception)}`);
4759
- return false;
4873
+ if (exception instanceof OutcomeUnknown) {
4874
+ logError(`${what}: OUTCOME UNKNOWN on ${host}: ${exception.message}. The Manager may still be installing it: refetch the list (fetchModels / fetchPlugins) and read its status before installing again, a blind retry queues a second download`);
4875
+ return "unknown";
4876
+ }
4877
+ logError(`${what}: install failed on ${host}: ${errorText(exception)}`);
4878
+ return "failed";
4760
4879
  }
4761
4880
  };
4762
4881
  this.waitFor = async (what, check) => {
4763
4882
  const deadline = Date.now() + this.timing.installTimeoutMs;
4883
+ let lastAnswer = Date.now();
4764
4884
  for (;;) {
4765
- const value = await check();
4766
- if (value != null) return value;
4767
- if (Date.now() >= deadline) throw new Error(`${what} still running after ${this.timing.installTimeoutMs} ms (manager.timing.installTimeoutMs)`);
4885
+ try {
4886
+ const value = await check();
4887
+ lastAnswer = Date.now();
4888
+ if (value != null) return value;
4889
+ } catch (exception) {
4890
+ if (exception instanceof InstallFailed) throw exception;
4891
+ if (Date.now() - lastAnswer >= this.timing.pollGraceMs) throw new OutcomeUnknown(`the host gave no answer for ${this.timing.pollGraceMs} ms (manager.timing.pollGraceMs), last: ${errorText(exception)}`);
4892
+ logError(`${what}: poll failed, still waiting: ${errorText(exception)}`);
4893
+ }
4894
+ if (Date.now() >= deadline) throw new OutcomeUnknown(`still running after ${this.timing.installTimeoutMs} ms (manager.timing.installTimeoutMs)`);
4768
4895
  await new Promise((resolve) => setTimeout(resolve, this.timing.pollMs));
4769
4896
  }
4770
4897
  };
@@ -6657,26 +6784,8 @@ var ComfyHost = class {
6657
6784
  constructor(data) {
6658
6785
  this.data = data;
6659
6786
  this.uploader = new ComfyUploader(this);
6660
- this.matchRequirements = (requirements) => {
6661
- const repo = comfyts.registry;
6662
- for (const req of requirements) {
6663
- if (req.optional) continue;
6664
- if (req.type === "customNodesByNodeKey") {
6665
- if (!(repo.plugins_byNodeKey.get(req.nodeName) ?? []).find((i) => this.manager.isPluginInstalled(i.title))) return false;
6666
- } else if (req.type === "customNodesByTitle") {
6667
- const plugin = repo.plugins_byTitle.get(req.title);
6668
- if (plugin == null) continue;
6669
- if (!this.manager.isPluginInstalled(plugin.title)) return false;
6670
- } else if (req.type === "customNodesByURI") {
6671
- const plugin = repo.plugins_byFile.get(req.uri);
6672
- if (plugin == null) continue;
6673
- if (!this.manager.isPluginInstalled(plugin.title)) return false;
6674
- } else if (req.type === "modelInManager") {
6675
- if (!this.manager.isModelInstalled(req.modelName)) return false;
6676
- }
6677
- }
6678
- return true;
6679
- };
6787
+ this.matchRequirements = (requirements) => this.manager.matchRequirements(requirements);
6788
+ this.checkRequirements = (requirements) => this.manager.checkRequirements(requirements);
6680
6789
  this.serverLogs = [];
6681
6790
  this.wantLog = true;
6682
6791
  this.maxLogs = 200;