comfy-ts 2.18.0 → 2.19.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.
- package/README.md +140 -95
- package/claude-code/.claude-plugin/plugin.json +9 -0
- package/claude-code/skills/convert/SKILL.md +25 -0
- package/claude-code/skills/guide/SKILL.md +21 -0
- package/claude-code/skills/run/SKILL.md +12 -0
- package/claude-code/skills/setup/SKILL.md +15 -0
- package/claude-code/skills/workflow/SKILL.md +19 -0
- package/dist/cli.js +219 -6
- package/dist/cli.js.map +1 -1
- package/dist/{state-DgwWhZWb.js → exampleAssets-CE4PUy3n.js} +206 -58
- package/dist/exampleAssets-CE4PUy3n.js.map +1 -0
- package/dist/index.cjs +173 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -8
- package/dist/index.d.ts +37 -8
- package/dist/index.js +173 -59
- package/dist/index.js.map +1 -1
- package/dist/{run-run-Wn7H72Zg.js → run-run-C_yXY0vl.js} +2 -3
- package/dist/{run-run-Wn7H72Zg.js.map → run-run-C_yXY0vl.js.map} +1 -1
- package/dist/{run-tui-VWSj1D_j.js → run-tui-B3dsftdB.js} +2 -3
- package/dist/{run-tui-VWSj1D_j.js.map → run-tui-B3dsftdB.js.map} +1 -1
- package/dist/web.d.ts +55 -26
- package/dist/web.js +164 -55
- package/dist/web.js.map +1 -1
- package/examples/README.md +17 -11
- package/guide-for-agents.md +4 -1
- package/package.json +3 -2
- package/src/cli/comfy-ts-cli.ts +8 -0
- package/src/cli/skill.ts +207 -0
- package/src/exampleAssets.ts +10 -4
- package/src/host/ComfyHost.ts +6 -36
- package/src/host/ComfyManager.ts +168 -42
- package/src/litegraph/expandSubgraphs.ts +58 -4
- package/src/litegraph/normalizeWorkflow.ts +6 -1
- package/src/manager/installedView.ts +2 -0
- package/src/sdk-generator/litegraphToApiRequestPayload.ts +25 -11
- package/dist/exampleAssets-BfWzygoM.js +0 -38
- package/dist/exampleAssets-BfWzygoM.js.map +0 -1
- package/dist/state-DgwWhZWb.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -134,7 +134,7 @@ function createNodeStorage() {
|
|
|
134
134
|
}
|
|
135
135
|
//#endregion
|
|
136
136
|
//#region package.json
|
|
137
|
-
var version = "2.
|
|
137
|
+
var version = "2.19.0";
|
|
138
138
|
//#endregion
|
|
139
139
|
//#region src/litegraph/LiteGraphLinkID.ts
|
|
140
140
|
const asLiteGraphLinkID = (id) => id;
|
|
@@ -154,8 +154,55 @@ const bang = (x, msg = "") => {
|
|
|
154
154
|
/** boundary sentinel ids inside definition link tables */
|
|
155
155
|
const SUBGRAPH_INPUT_NODE_ID = -10;
|
|
156
156
|
const SUBGRAPH_OUTPUT_NODE_ID = -20;
|
|
157
|
-
/**
|
|
158
|
-
|
|
157
|
+
/** expanded node count above which a file is refused before expanding: the largest official
|
|
158
|
+
* template expands to 575 nodes, and fan-out nesting grows geometrically without any cycle */
|
|
159
|
+
const MAX_EXPANDED_NODES = 1e5;
|
|
160
|
+
/**
|
|
161
|
+
* before any expansion: the definitions as a graph (def → the defs its NORMAL-mode instances name,
|
|
162
|
+
* the only ones expansion follows). A cycle reachable from the root is refused with the defs it
|
|
163
|
+
* runs through, and the expanded size is counted, not built, and refused above
|
|
164
|
+
* MAX_EXPANDED_NODES. One explicit stack, no recursion: the file decides the depth
|
|
165
|
+
*/
|
|
166
|
+
const checkExpansion = (wf, defs) => {
|
|
167
|
+
const children = (nodes) => nodes.filter((n) => n.mode === "normal" && defs.has(n.type)).map((n) => n.type);
|
|
168
|
+
const own = (nodes) => nodes.filter((n) => !(n.mode === "normal" && defs.has(n.type))).length;
|
|
169
|
+
const name = (id) => JSON.stringify(defs.get(id)?.name ?? id);
|
|
170
|
+
const cap = (n) => Math.min(n, 100001);
|
|
171
|
+
const size = /* @__PURE__ */ new Map();
|
|
172
|
+
const onPath = /* @__PURE__ */ new Set();
|
|
173
|
+
for (const root of new Set(children(wf.nodes))) {
|
|
174
|
+
if (size.has(root)) continue;
|
|
175
|
+
const stack = [{
|
|
176
|
+
id: root,
|
|
177
|
+
kids: children(bang(defs.get(root)).nodes),
|
|
178
|
+
next: 0
|
|
179
|
+
}];
|
|
180
|
+
onPath.add(root);
|
|
181
|
+
while (stack.length > 0) {
|
|
182
|
+
const top = bang(stack[stack.length - 1]);
|
|
183
|
+
const kid = top.kids[top.next++];
|
|
184
|
+
if (kid == null) {
|
|
185
|
+
const total = top.kids.reduce((acc, k) => cap(acc + (size.get(k) ?? 0)), own(bang(defs.get(top.id)).nodes));
|
|
186
|
+
size.set(top.id, total);
|
|
187
|
+
onPath.delete(top.id);
|
|
188
|
+
stack.pop();
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (size.has(kid)) continue;
|
|
192
|
+
if (onPath.has(kid)) {
|
|
193
|
+
const from = stack.findIndex((frame) => frame.id === kid);
|
|
194
|
+
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) });
|
|
195
|
+
}
|
|
196
|
+
onPath.add(kid);
|
|
197
|
+
stack.push({
|
|
198
|
+
id: kid,
|
|
199
|
+
kids: children(bang(defs.get(kid)).nodes),
|
|
200
|
+
next: 0
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
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)`);
|
|
205
|
+
};
|
|
159
206
|
/**
|
|
160
207
|
* widget-kind fallback when a def input slot has no boundary target carrying a
|
|
161
208
|
* widget marker: these litegraph slot types carry widget values. LOCAL copy on
|
|
@@ -178,11 +225,12 @@ const PRIMITIVE_WIDGET_TYPES = /* @__PURE__ */ new Set([
|
|
|
178
225
|
* passthrough walk, which needs no interior.
|
|
179
226
|
*/
|
|
180
227
|
const expandSubgraphs = (wf, defs) => {
|
|
228
|
+
checkExpansion(wf, defs);
|
|
181
229
|
let passes = 0;
|
|
182
230
|
while (true) {
|
|
183
231
|
const expandable = wf.nodes.filter((n) => defs.has(n.type) && n.mode !== "bypassed");
|
|
184
232
|
if (expandable.length === 0) return wf;
|
|
185
|
-
if (++passes >
|
|
233
|
+
if (++passes > defs.size + 1) throw new WorkflowNormalizeError("subgraph-cycle", `subgraph expansion still had instances after ${passes - 1} passes over ${defs.size} definitions`);
|
|
186
234
|
for (const instance of expandable) if (instance.mode === "muted") dropMutedInstance(wf, instance);
|
|
187
235
|
else expandOneInstance(wf, instance, bang(defs.get(instance.type)));
|
|
188
236
|
}
|
|
@@ -1077,6 +1125,8 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
|
|
|
1077
1125
|
if (node.widgets.positional.length > 0) PRIMITIVE_VALUES[node.id] = node.widgets.positional[0];
|
|
1078
1126
|
else if (Object.hasOwn(node.widgets.named, "value")) PRIMITIVE_VALUES[node.id] = node.widgets.named["value"];
|
|
1079
1127
|
}
|
|
1128
|
+
const linksById = new Map(workflow.links.map((l) => [l.id, l]));
|
|
1129
|
+
const nodesById = new Map(workflow.nodes.map((n) => [n.id, n]));
|
|
1080
1130
|
for (const node of workflow.nodes) {
|
|
1081
1131
|
if (isNeverExecuted(node)) continue;
|
|
1082
1132
|
if (node.mode !== "normal") continue;
|
|
@@ -1255,9 +1305,9 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
|
|
|
1255
1305
|
}
|
|
1256
1306
|
}
|
|
1257
1307
|
const getParentNode = (linkId) => {
|
|
1258
|
-
const link =
|
|
1308
|
+
const link = linksById.get(linkId);
|
|
1259
1309
|
if (link == null) throw new WorkflowConvertError("dangling-link", `node ${node.id}(${node.type}) references a non-existing link (id=${linkId})`, node);
|
|
1260
|
-
const parentNode =
|
|
1310
|
+
const parentNode = nodesById.get(link.originId);
|
|
1261
1311
|
if (parentNode == null) throw new WorkflowConvertError("dangling-link", `link ${linkId} references a non-existent parent node ${link.originId}`, node);
|
|
1262
1312
|
return {
|
|
1263
1313
|
node: parentNode,
|
|
@@ -1383,15 +1433,20 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
|
|
|
1383
1433
|
}
|
|
1384
1434
|
}
|
|
1385
1435
|
if (missing.size > 0) {
|
|
1386
|
-
const
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1436
|
+
const consumers = /* @__PURE__ */ new Map();
|
|
1437
|
+
for (const [id, n] of Object.entries(prompt)) for (const value of Object.values(n.inputs)) if (Array.isArray(value) && typeof value[0] === "string") {
|
|
1438
|
+
const list = consumers.get(value[0]) ?? [];
|
|
1439
|
+
list.push(id);
|
|
1440
|
+
consumers.set(value[0], list);
|
|
1441
|
+
}
|
|
1442
|
+
const blocked = new Set(missing.keys());
|
|
1443
|
+
const queue = [...blocked];
|
|
1444
|
+
for (let head = 0; head < queue.length; head++) for (const next of consumers.get(queue[head] ?? "") ?? []) if (!blocked.has(next)) {
|
|
1445
|
+
blocked.add(next);
|
|
1446
|
+
queue.push(next);
|
|
1447
|
+
}
|
|
1393
1448
|
const outputs = Object.keys(prompt).filter((id) => schema.data.spec[prompt[id]?.class_type ?? ""]?.output_node === true);
|
|
1394
|
-
const dropped = outputs.filter((id) =>
|
|
1449
|
+
const dropped = outputs.filter((id) => blocked.has(id));
|
|
1395
1450
|
const first = missing.values().next().value;
|
|
1396
1451
|
if (first != null && outputs.length > 0 && dropped.length === outputs.length) throw new WorkflowConvertError("missing-required-input", first.message, first.node);
|
|
1397
1452
|
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("; ")}`);
|
|
@@ -4450,8 +4505,13 @@ const ComfyManagerAPIPackList_ark = (0, arktype.type)({
|
|
|
4450
4505
|
/** 🔶 NAMING DISCLAIMER: I call a "custom node package" => "PLUGIN" */
|
|
4451
4506
|
const MANAGER_TIMING = {
|
|
4452
4507
|
pollMs: 1e3,
|
|
4453
|
-
installTimeoutMs: 60 * 6e4
|
|
4508
|
+
installTimeoutMs: 60 * 6e4,
|
|
4509
|
+
pollGraceMs: 12e4
|
|
4454
4510
|
};
|
|
4511
|
+
/** an install the host refused or reported failed: ends the wait at once */
|
|
4512
|
+
var InstallFailed = class extends Error {};
|
|
4513
|
+
/** we lost sight of the task: the outcome is not known */
|
|
4514
|
+
var OutcomeUnknown = class extends Error {};
|
|
4455
4515
|
/** what each generation does NOT serve (history means the `?ui_id=` form) */
|
|
4456
4516
|
const NOT_SERVED = {
|
|
4457
4517
|
v3: [
|
|
@@ -4557,7 +4617,7 @@ var ComfyManager = class {
|
|
|
4557
4617
|
fetchPlugins: () => this.installedPluginView(api),
|
|
4558
4618
|
fetchModels: () => this.installedModelView(),
|
|
4559
4619
|
enqueuePlugin: (plugin, uiId) => this.enqueuePluginTask(api, plugin, uiId),
|
|
4560
|
-
settle: (what, uiId) => this.settleByHistory(api, what, uiId)
|
|
4620
|
+
settle: (what, uiId, landed, sentId) => this.settleByHistory(api, what, uiId, landed, sentId)
|
|
4561
4621
|
};
|
|
4562
4622
|
}
|
|
4563
4623
|
};
|
|
@@ -4606,7 +4666,8 @@ var ComfyManager = class {
|
|
|
4606
4666
|
return this.modelList?.models.some((x) => x.name === name && x.installed === "True") ?? false;
|
|
4607
4667
|
};
|
|
4608
4668
|
this.modelsBeeingInstalled = /* @__PURE__ */ new Set();
|
|
4609
|
-
this.installModel = async (model) =>
|
|
4669
|
+
this.installModel = async (model) => await this.installModelOutcome(model) === "installed";
|
|
4670
|
+
this.installModelOutcome = async (model) => {
|
|
4610
4671
|
this.modelsBeeingInstalled.add(model.name);
|
|
4611
4672
|
try {
|
|
4612
4673
|
return await this.runInstall(`model "${model.name}"`, {
|
|
@@ -4619,7 +4680,8 @@ var ComfyManager = class {
|
|
|
4619
4680
|
await this.post(this.route(api, "/manager/queue/install_model"), body);
|
|
4620
4681
|
},
|
|
4621
4682
|
landed: async (s) => {
|
|
4622
|
-
|
|
4683
|
+
const row = (await s.fetchModels()).models.find((x) => x.filename === model.filename && x.save_path === model.save_path && x.base === model.base);
|
|
4684
|
+
return row == null ? null : row.installed === "True";
|
|
4623
4685
|
}
|
|
4624
4686
|
});
|
|
4625
4687
|
} finally {
|
|
@@ -4653,10 +4715,43 @@ var ComfyManager = class {
|
|
|
4653
4715
|
return "error";
|
|
4654
4716
|
})();
|
|
4655
4717
|
};
|
|
4718
|
+
this.requirementStatus = (req) => {
|
|
4719
|
+
const mirror = this.mirror();
|
|
4720
|
+
const packs = (() => {
|
|
4721
|
+
if (req.type === "customNodesByNodeKey") return mirror.plugins_byNodeKey.get(req.nodeName) ?? [];
|
|
4722
|
+
if (req.type === "customNodesByTitle") return [mirror.plugins_byTitle.get(req.title)].filter((x) => x != null);
|
|
4723
|
+
if (req.type === "customNodesByURI") return [mirror.plugins_byFile.get(req.uri)].filter((x) => x != null);
|
|
4724
|
+
return null;
|
|
4725
|
+
})();
|
|
4726
|
+
if (packs == null) return req.type === "modelInManager" ? this.getModelStatus(req.modelName) : null;
|
|
4727
|
+
if (packs.length === 0) return req.type === "customNodesByNodeKey" ? "unknown" : null;
|
|
4728
|
+
const statuses = packs.map((x) => this.getPluginStatus(x.title));
|
|
4729
|
+
if (statuses.some((x) => x === "installed" || x === "update-available")) return "installed";
|
|
4730
|
+
return statuses.every((x) => x === "not-installed") ? "not-installed" : "unknown";
|
|
4731
|
+
};
|
|
4732
|
+
this.checkRequirements = (requirements) => {
|
|
4733
|
+
const out = {
|
|
4734
|
+
missing: [],
|
|
4735
|
+
undecided: []
|
|
4736
|
+
};
|
|
4737
|
+
for (const req of requirements) {
|
|
4738
|
+
if (req.optional) continue;
|
|
4739
|
+
const status = this.requirementStatus(req);
|
|
4740
|
+
if (status === "not-installed") out.missing.push(req);
|
|
4741
|
+
else if (status === "unknown" || status === "error") out.undecided.push(req);
|
|
4742
|
+
}
|
|
4743
|
+
return out;
|
|
4744
|
+
};
|
|
4745
|
+
this.matchRequirements = (requirements) => {
|
|
4746
|
+
const check = this.checkRequirements(requirements);
|
|
4747
|
+
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)" : ""));
|
|
4748
|
+
return check.missing.length === 0;
|
|
4749
|
+
};
|
|
4656
4750
|
this.fetchPlugins = async (mode = "cache", skipUpdate = true) => {
|
|
4657
4751
|
return this.strategy(await this.api()).fetchPlugins(mode, skipUpdate);
|
|
4658
4752
|
};
|
|
4659
|
-
this.installPlugin = async (plugin) =>
|
|
4753
|
+
this.installPlugin = async (plugin) => await this.installPluginOutcome(plugin) === "installed";
|
|
4754
|
+
this.installPluginOutcome = async (plugin) => {
|
|
4660
4755
|
return this.runInstall(`plugin "${plugin.title}"`, {
|
|
4661
4756
|
enqueue: (api, uiId) => this.strategy(api).enqueuePlugin(plugin, uiId),
|
|
4662
4757
|
landed: async (_s, api) => {
|
|
@@ -4733,8 +4828,9 @@ var ComfyManager = class {
|
|
|
4733
4828
|
};
|
|
4734
4829
|
this.enqueuePluginTask = async (api, plugin, uiId) => {
|
|
4735
4830
|
const url = plugin.files[0] ?? plugin.reference;
|
|
4831
|
+
const id = repoPath(url).split("/").pop() ?? url;
|
|
4736
4832
|
const params = {
|
|
4737
|
-
id
|
|
4833
|
+
id,
|
|
4738
4834
|
version: "nightly",
|
|
4739
4835
|
selected_version: "nightly",
|
|
4740
4836
|
repository: url,
|
|
@@ -4747,18 +4843,26 @@ var ComfyManager = class {
|
|
|
4747
4843
|
kind: "install",
|
|
4748
4844
|
params
|
|
4749
4845
|
});
|
|
4846
|
+
return id;
|
|
4750
4847
|
};
|
|
4751
|
-
this.settleByHistory = async (api, what, uiId) => {
|
|
4848
|
+
this.settleByHistory = async (api, what, uiId, landed, sentId) => {
|
|
4752
4849
|
const route = this.route(api, "/manager/queue/history", `?ui_id=${encodeURIComponent(uiId)}`);
|
|
4850
|
+
const readEntry = async () => (await this.getValid(route, TaskHistory_ark)).history.status ?? null;
|
|
4753
4851
|
const entry = await this.waitFor(what, async () => {
|
|
4754
|
-
const status =
|
|
4755
|
-
if (status
|
|
4756
|
-
|
|
4852
|
+
const status = await readEntry();
|
|
4853
|
+
if (status != null) return status;
|
|
4854
|
+
if (await this.restartIdleQueue(api) !== "drained") return null;
|
|
4855
|
+
const late = await readEntry();
|
|
4856
|
+
if (late != null) return late;
|
|
4857
|
+
throw new InstallFailed("the task left the queue with no result (a queue/reset from the Manager UI or another client removes it)");
|
|
4757
4858
|
});
|
|
4758
|
-
if (entry.status_str === "success" || entry.status_str === "skip")
|
|
4859
|
+
if (entry.status_str === "success" || entry.status_str === "skip") {
|
|
4860
|
+
if (await this.endState(landed) !== false) return;
|
|
4861
|
+
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");
|
|
4862
|
+
}
|
|
4759
4863
|
const messages = entry.messages ?? [];
|
|
4760
4864
|
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)" : "";
|
|
4761
|
-
throw new
|
|
4865
|
+
throw new InstallFailed(`the Manager reports ${entry.status_str}: ${messages.join(" | ")}${gate}`);
|
|
4762
4866
|
};
|
|
4763
4867
|
this.restartIdleQueue = async (api) => {
|
|
4764
4868
|
const status = await this.getValid(this.route(api, "/manager/queue/status"), QueueStatus_ark);
|
|
@@ -4769,29 +4873,52 @@ var ComfyManager = class {
|
|
|
4769
4873
|
};
|
|
4770
4874
|
this.settleByDrain = async (api, what, landed) => {
|
|
4771
4875
|
await this.waitFor(what, async () => await this.restartIdleQueue(api) === "drained" ? true : null);
|
|
4772
|
-
|
|
4876
|
+
const state = await this.endState(landed);
|
|
4877
|
+
if (state === true) return;
|
|
4878
|
+
if (state === null) throw new OutcomeUnknown("the queue drained, but the lists cannot say whether it is installed");
|
|
4879
|
+
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`);
|
|
4880
|
+
};
|
|
4881
|
+
this.endState = async (landed) => {
|
|
4882
|
+
try {
|
|
4883
|
+
return await landed();
|
|
4884
|
+
} catch (exception) {
|
|
4885
|
+
throw new OutcomeUnknown(`the task ran, but its end state could not be read: ${errorText(exception)}`);
|
|
4886
|
+
}
|
|
4773
4887
|
};
|
|
4774
4888
|
this.runInstall = async (what, p) => {
|
|
4889
|
+
const host = this.host.getServerHostHTTP();
|
|
4775
4890
|
try {
|
|
4776
4891
|
const api = await this.api();
|
|
4777
4892
|
const s = this.strategy(api);
|
|
4778
4893
|
const uiId = (0, nanoid.nanoid)();
|
|
4779
|
-
await p.enqueue(api, uiId);
|
|
4894
|
+
const sentId = await p.enqueue(api, uiId);
|
|
4780
4895
|
await this.post(this.route(api, "/manager/queue/start"));
|
|
4781
|
-
await s.settle(what, uiId, () => p.landed(s, api));
|
|
4896
|
+
await s.settle(what, uiId, () => p.landed(s, api), sentId);
|
|
4782
4897
|
logSuccess(`${what} installed`);
|
|
4783
|
-
return
|
|
4898
|
+
return "installed";
|
|
4784
4899
|
} catch (exception) {
|
|
4785
|
-
|
|
4786
|
-
|
|
4900
|
+
if (exception instanceof OutcomeUnknown) {
|
|
4901
|
+
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`);
|
|
4902
|
+
return "unknown";
|
|
4903
|
+
}
|
|
4904
|
+
logError(`${what}: install failed on ${host}: ${errorText(exception)}`);
|
|
4905
|
+
return "failed";
|
|
4787
4906
|
}
|
|
4788
4907
|
};
|
|
4789
4908
|
this.waitFor = async (what, check) => {
|
|
4790
4909
|
const deadline = Date.now() + this.timing.installTimeoutMs;
|
|
4910
|
+
let lastAnswer = Date.now();
|
|
4791
4911
|
for (;;) {
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4912
|
+
try {
|
|
4913
|
+
const value = await check();
|
|
4914
|
+
lastAnswer = Date.now();
|
|
4915
|
+
if (value != null) return value;
|
|
4916
|
+
} catch (exception) {
|
|
4917
|
+
if (exception instanceof InstallFailed) throw exception;
|
|
4918
|
+
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)}`);
|
|
4919
|
+
logError(`${what}: poll failed, still waiting: ${errorText(exception)}`);
|
|
4920
|
+
}
|
|
4921
|
+
if (Date.now() >= deadline) throw new OutcomeUnknown(`still running after ${this.timing.installTimeoutMs} ms (manager.timing.installTimeoutMs)`);
|
|
4795
4922
|
await new Promise((resolve) => setTimeout(resolve, this.timing.pollMs));
|
|
4796
4923
|
}
|
|
4797
4924
|
};
|
|
@@ -6684,26 +6811,8 @@ var ComfyHost = class {
|
|
|
6684
6811
|
constructor(data) {
|
|
6685
6812
|
this.data = data;
|
|
6686
6813
|
this.uploader = new ComfyUploader(this);
|
|
6687
|
-
this.matchRequirements = (requirements) =>
|
|
6688
|
-
|
|
6689
|
-
for (const req of requirements) {
|
|
6690
|
-
if (req.optional) continue;
|
|
6691
|
-
if (req.type === "customNodesByNodeKey") {
|
|
6692
|
-
if (!(repo.plugins_byNodeKey.get(req.nodeName) ?? []).find((i) => this.manager.isPluginInstalled(i.title))) return false;
|
|
6693
|
-
} else if (req.type === "customNodesByTitle") {
|
|
6694
|
-
const plugin = repo.plugins_byTitle.get(req.title);
|
|
6695
|
-
if (plugin == null) continue;
|
|
6696
|
-
if (!this.manager.isPluginInstalled(plugin.title)) return false;
|
|
6697
|
-
} else if (req.type === "customNodesByURI") {
|
|
6698
|
-
const plugin = repo.plugins_byFile.get(req.uri);
|
|
6699
|
-
if (plugin == null) continue;
|
|
6700
|
-
if (!this.manager.isPluginInstalled(plugin.title)) return false;
|
|
6701
|
-
} else if (req.type === "modelInManager") {
|
|
6702
|
-
if (!this.manager.isModelInstalled(req.modelName)) return false;
|
|
6703
|
-
}
|
|
6704
|
-
}
|
|
6705
|
-
return true;
|
|
6706
|
-
};
|
|
6814
|
+
this.matchRequirements = (requirements) => this.manager.matchRequirements(requirements);
|
|
6815
|
+
this.checkRequirements = (requirements) => this.manager.checkRequirements(requirements);
|
|
6707
6816
|
this.serverLogs = [];
|
|
6708
6817
|
this.wantLog = true;
|
|
6709
6818
|
this.maxLogs = 200;
|
|
@@ -7951,6 +8060,14 @@ function loraTag(name, strength = 1, clipStrength) {
|
|
|
7951
8060
|
* package.json all the way up is a broken install and throws.
|
|
7952
8061
|
*/
|
|
7953
8062
|
function bundledExamplesDir(moduleUrl = require("url").pathToFileURL(__filename).href) {
|
|
8063
|
+
const pkgDir = comfyTsPackageDir(moduleUrl);
|
|
8064
|
+
if (pkgDir == null) return null;
|
|
8065
|
+
const examples = (0, pathe.join)(pkgDir, "examples");
|
|
8066
|
+
return (0, node_fs.existsSync)(examples) ? examples : null;
|
|
8067
|
+
}
|
|
8068
|
+
/** the comfy-ts package root (the folder of its package.json), by the same walk: null when the
|
|
8069
|
+
* nearest named package is another one, a throw when no package.json is found at all */
|
|
8070
|
+
function comfyTsPackageDir(moduleUrl = require("url").pathToFileURL(__filename).href) {
|
|
7954
8071
|
let dir = (0, pathe.dirname)((0, node_url.fileURLToPath)(moduleUrl));
|
|
7955
8072
|
let prev = "";
|
|
7956
8073
|
while (dir !== prev) {
|
|
@@ -7960,10 +8077,7 @@ function bundledExamplesDir(moduleUrl = require("url").pathToFileURL(__filename)
|
|
|
7960
8077
|
try {
|
|
7961
8078
|
pkg = JSON.parse((0, node_fs.readFileSync)(pkgPath, "utf8"));
|
|
7962
8079
|
} catch {}
|
|
7963
|
-
if (pkg.name === "comfy-ts")
|
|
7964
|
-
const examples = (0, pathe.join)(dir, "examples");
|
|
7965
|
-
return (0, node_fs.existsSync)(examples) ? examples : null;
|
|
7966
|
-
}
|
|
8080
|
+
if (pkg.name === "comfy-ts") return dir;
|
|
7967
8081
|
if (pkg.name != null) return null;
|
|
7968
8082
|
}
|
|
7969
8083
|
prev = dir;
|