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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { X as ansi, a as DefinedWorkflow, at as extractErrorMessage, ct as getComfyStorage, dt as logError, ft as logInfo, ht as sha1HexOfString, it as hashArrayBuffer, lt as resolveComfyStorage, mt as statelessRegex, n as diffSchemas, nt as isVideoFilename, ot as isRecord$1, pt as logSuccess, rt as mediaMime, st as bang, t as MODEL_LISTS, ut as isQuiet } from "./schemaDrift-CbsABBuk.js";
|
|
2
|
-
import {
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import { basename, dirname, join } from "pathe";
|
|
3
5
|
import { scope, type } from "arktype";
|
|
4
6
|
import { nanoid } from "nanoid";
|
|
5
7
|
import { imageMeta } from "image-meta";
|
|
@@ -902,7 +904,7 @@ var ComfySchema = class {
|
|
|
902
904
|
};
|
|
903
905
|
//#endregion
|
|
904
906
|
//#region package.json
|
|
905
|
-
var version = "2.
|
|
907
|
+
var version = "2.19.0";
|
|
906
908
|
//#endregion
|
|
907
909
|
//#region src/litegraph/LiteGraphLinkID.ts
|
|
908
910
|
const asLiteGraphLinkID = (id) => id;
|
|
@@ -912,8 +914,55 @@ const LiteGraphLinkID_ = type.number.atLeast(0).as();
|
|
|
912
914
|
/** boundary sentinel ids inside definition link tables */
|
|
913
915
|
const SUBGRAPH_INPUT_NODE_ID = -10;
|
|
914
916
|
const SUBGRAPH_OUTPUT_NODE_ID = -20;
|
|
915
|
-
/**
|
|
916
|
-
|
|
917
|
+
/** expanded node count above which a file is refused before expanding: the largest official
|
|
918
|
+
* template expands to 575 nodes, and fan-out nesting grows geometrically without any cycle */
|
|
919
|
+
const MAX_EXPANDED_NODES = 1e5;
|
|
920
|
+
/**
|
|
921
|
+
* before any expansion: the definitions as a graph (def → the defs its NORMAL-mode instances name,
|
|
922
|
+
* the only ones expansion follows). A cycle reachable from the root is refused with the defs it
|
|
923
|
+
* runs through, and the expanded size is counted, not built, and refused above
|
|
924
|
+
* MAX_EXPANDED_NODES. One explicit stack, no recursion: the file decides the depth
|
|
925
|
+
*/
|
|
926
|
+
const checkExpansion = (wf, defs) => {
|
|
927
|
+
const children = (nodes) => nodes.filter((n) => n.mode === "normal" && defs.has(n.type)).map((n) => n.type);
|
|
928
|
+
const own = (nodes) => nodes.filter((n) => !(n.mode === "normal" && defs.has(n.type))).length;
|
|
929
|
+
const name = (id) => JSON.stringify(defs.get(id)?.name ?? id);
|
|
930
|
+
const cap = (n) => Math.min(n, 100001);
|
|
931
|
+
const size = /* @__PURE__ */ new Map();
|
|
932
|
+
const onPath = /* @__PURE__ */ new Set();
|
|
933
|
+
for (const root of new Set(children(wf.nodes))) {
|
|
934
|
+
if (size.has(root)) continue;
|
|
935
|
+
const stack = [{
|
|
936
|
+
id: root,
|
|
937
|
+
kids: children(bang(defs.get(root)).nodes),
|
|
938
|
+
next: 0
|
|
939
|
+
}];
|
|
940
|
+
onPath.add(root);
|
|
941
|
+
while (stack.length > 0) {
|
|
942
|
+
const top = bang(stack[stack.length - 1]);
|
|
943
|
+
const kid = top.kids[top.next++];
|
|
944
|
+
if (kid == null) {
|
|
945
|
+
const total = top.kids.reduce((acc, k) => cap(acc + (size.get(k) ?? 0)), own(bang(defs.get(top.id)).nodes));
|
|
946
|
+
size.set(top.id, total);
|
|
947
|
+
onPath.delete(top.id);
|
|
948
|
+
stack.pop();
|
|
949
|
+
continue;
|
|
950
|
+
}
|
|
951
|
+
if (size.has(kid)) continue;
|
|
952
|
+
if (onPath.has(kid)) {
|
|
953
|
+
const from = stack.findIndex((frame) => frame.id === kid);
|
|
954
|
+
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) });
|
|
955
|
+
}
|
|
956
|
+
onPath.add(kid);
|
|
957
|
+
stack.push({
|
|
958
|
+
id: kid,
|
|
959
|
+
kids: children(bang(defs.get(kid)).nodes),
|
|
960
|
+
next: 0
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
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)`);
|
|
965
|
+
};
|
|
917
966
|
/**
|
|
918
967
|
* widget-kind fallback when a def input slot has no boundary target carrying a
|
|
919
968
|
* widget marker: these litegraph slot types carry widget values. LOCAL copy on
|
|
@@ -936,11 +985,12 @@ const PRIMITIVE_WIDGET_TYPES = /* @__PURE__ */ new Set([
|
|
|
936
985
|
* passthrough walk, which needs no interior.
|
|
937
986
|
*/
|
|
938
987
|
const expandSubgraphs = (wf, defs) => {
|
|
988
|
+
checkExpansion(wf, defs);
|
|
939
989
|
let passes = 0;
|
|
940
990
|
while (true) {
|
|
941
991
|
const expandable = wf.nodes.filter((n) => defs.has(n.type) && n.mode !== "bypassed");
|
|
942
992
|
if (expandable.length === 0) return wf;
|
|
943
|
-
if (++passes >
|
|
993
|
+
if (++passes > defs.size + 1) throw new WorkflowNormalizeError("subgraph-cycle", `subgraph expansion still had instances after ${passes - 1} passes over ${defs.size} definitions`);
|
|
944
994
|
for (const instance of expandable) if (instance.mode === "muted") dropMutedInstance(wf, instance);
|
|
945
995
|
else expandOneInstance(wf, instance, bang(defs.get(instance.type)));
|
|
946
996
|
}
|
|
@@ -1593,6 +1643,8 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
|
|
|
1593
1643
|
if (node.widgets.positional.length > 0) PRIMITIVE_VALUES[node.id] = node.widgets.positional[0];
|
|
1594
1644
|
else if (Object.hasOwn(node.widgets.named, "value")) PRIMITIVE_VALUES[node.id] = node.widgets.named["value"];
|
|
1595
1645
|
}
|
|
1646
|
+
const linksById = new Map(workflow.links.map((l) => [l.id, l]));
|
|
1647
|
+
const nodesById = new Map(workflow.nodes.map((n) => [n.id, n]));
|
|
1596
1648
|
for (const node of workflow.nodes) {
|
|
1597
1649
|
if (isNeverExecuted(node)) continue;
|
|
1598
1650
|
if (node.mode !== "normal") continue;
|
|
@@ -1771,9 +1823,9 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
|
|
|
1771
1823
|
}
|
|
1772
1824
|
}
|
|
1773
1825
|
const getParentNode = (linkId) => {
|
|
1774
|
-
const link =
|
|
1826
|
+
const link = linksById.get(linkId);
|
|
1775
1827
|
if (link == null) throw new WorkflowConvertError("dangling-link", `node ${node.id}(${node.type}) references a non-existing link (id=${linkId})`, node);
|
|
1776
|
-
const parentNode =
|
|
1828
|
+
const parentNode = nodesById.get(link.originId);
|
|
1777
1829
|
if (parentNode == null) throw new WorkflowConvertError("dangling-link", `link ${linkId} references a non-existent parent node ${link.originId}`, node);
|
|
1778
1830
|
return {
|
|
1779
1831
|
node: parentNode,
|
|
@@ -1899,15 +1951,20 @@ const convertLiteGraphToPrompt = (schema, workflow, opts = {}) => {
|
|
|
1899
1951
|
}
|
|
1900
1952
|
}
|
|
1901
1953
|
if (missing.size > 0) {
|
|
1902
|
-
const
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1954
|
+
const consumers = /* @__PURE__ */ new Map();
|
|
1955
|
+
for (const [id, n] of Object.entries(prompt)) for (const value of Object.values(n.inputs)) if (Array.isArray(value) && typeof value[0] === "string") {
|
|
1956
|
+
const list = consumers.get(value[0]) ?? [];
|
|
1957
|
+
list.push(id);
|
|
1958
|
+
consumers.set(value[0], list);
|
|
1959
|
+
}
|
|
1960
|
+
const blocked = new Set(missing.keys());
|
|
1961
|
+
const queue = [...blocked];
|
|
1962
|
+
for (let head = 0; head < queue.length; head++) for (const next of consumers.get(queue[head] ?? "") ?? []) if (!blocked.has(next)) {
|
|
1963
|
+
blocked.add(next);
|
|
1964
|
+
queue.push(next);
|
|
1965
|
+
}
|
|
1909
1966
|
const outputs = Object.keys(prompt).filter((id) => schema.data.spec[prompt[id]?.class_type ?? ""]?.output_node === true);
|
|
1910
|
-
const dropped = outputs.filter((id) =>
|
|
1967
|
+
const dropped = outputs.filter((id) => blocked.has(id));
|
|
1911
1968
|
const first = missing.values().next().value;
|
|
1912
1969
|
if (first != null && outputs.length > 0 && dropped.length === outputs.length) throw new WorkflowConvertError("missing-required-input", first.message, first.node);
|
|
1913
1970
|
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("; ")}`);
|
|
@@ -4091,8 +4148,13 @@ const ComfyManagerAPIPackList_ark = type({
|
|
|
4091
4148
|
/** 🔶 NAMING DISCLAIMER: I call a "custom node package" => "PLUGIN" */
|
|
4092
4149
|
const MANAGER_TIMING = {
|
|
4093
4150
|
pollMs: 1e3,
|
|
4094
|
-
installTimeoutMs: 60 * 6e4
|
|
4151
|
+
installTimeoutMs: 60 * 6e4,
|
|
4152
|
+
pollGraceMs: 12e4
|
|
4095
4153
|
};
|
|
4154
|
+
/** an install the host refused or reported failed: ends the wait at once */
|
|
4155
|
+
var InstallFailed = class extends Error {};
|
|
4156
|
+
/** we lost sight of the task: the outcome is not known */
|
|
4157
|
+
var OutcomeUnknown = class extends Error {};
|
|
4096
4158
|
/** what each generation does NOT serve (history means the `?ui_id=` form) */
|
|
4097
4159
|
const NOT_SERVED = {
|
|
4098
4160
|
v3: [
|
|
@@ -4198,7 +4260,7 @@ var ComfyManager = class {
|
|
|
4198
4260
|
fetchPlugins: () => this.installedPluginView(api),
|
|
4199
4261
|
fetchModels: () => this.installedModelView(),
|
|
4200
4262
|
enqueuePlugin: (plugin, uiId) => this.enqueuePluginTask(api, plugin, uiId),
|
|
4201
|
-
settle: (what, uiId) => this.settleByHistory(api, what, uiId)
|
|
4263
|
+
settle: (what, uiId, landed, sentId) => this.settleByHistory(api, what, uiId, landed, sentId)
|
|
4202
4264
|
};
|
|
4203
4265
|
}
|
|
4204
4266
|
};
|
|
@@ -4247,7 +4309,8 @@ var ComfyManager = class {
|
|
|
4247
4309
|
return this.modelList?.models.some((x) => x.name === name && x.installed === "True") ?? false;
|
|
4248
4310
|
};
|
|
4249
4311
|
this.modelsBeeingInstalled = /* @__PURE__ */ new Set();
|
|
4250
|
-
this.installModel = async (model) =>
|
|
4312
|
+
this.installModel = async (model) => await this.installModelOutcome(model) === "installed";
|
|
4313
|
+
this.installModelOutcome = async (model) => {
|
|
4251
4314
|
this.modelsBeeingInstalled.add(model.name);
|
|
4252
4315
|
try {
|
|
4253
4316
|
return await this.runInstall(`model "${model.name}"`, {
|
|
@@ -4260,7 +4323,8 @@ var ComfyManager = class {
|
|
|
4260
4323
|
await this.post(this.route(api, "/manager/queue/install_model"), body);
|
|
4261
4324
|
},
|
|
4262
4325
|
landed: async (s) => {
|
|
4263
|
-
|
|
4326
|
+
const row = (await s.fetchModels()).models.find((x) => x.filename === model.filename && x.save_path === model.save_path && x.base === model.base);
|
|
4327
|
+
return row == null ? null : row.installed === "True";
|
|
4264
4328
|
}
|
|
4265
4329
|
});
|
|
4266
4330
|
} finally {
|
|
@@ -4294,10 +4358,43 @@ var ComfyManager = class {
|
|
|
4294
4358
|
return "error";
|
|
4295
4359
|
})();
|
|
4296
4360
|
};
|
|
4361
|
+
this.requirementStatus = (req) => {
|
|
4362
|
+
const mirror = this.mirror();
|
|
4363
|
+
const packs = (() => {
|
|
4364
|
+
if (req.type === "customNodesByNodeKey") return mirror.plugins_byNodeKey.get(req.nodeName) ?? [];
|
|
4365
|
+
if (req.type === "customNodesByTitle") return [mirror.plugins_byTitle.get(req.title)].filter((x) => x != null);
|
|
4366
|
+
if (req.type === "customNodesByURI") return [mirror.plugins_byFile.get(req.uri)].filter((x) => x != null);
|
|
4367
|
+
return null;
|
|
4368
|
+
})();
|
|
4369
|
+
if (packs == null) return req.type === "modelInManager" ? this.getModelStatus(req.modelName) : null;
|
|
4370
|
+
if (packs.length === 0) return req.type === "customNodesByNodeKey" ? "unknown" : null;
|
|
4371
|
+
const statuses = packs.map((x) => this.getPluginStatus(x.title));
|
|
4372
|
+
if (statuses.some((x) => x === "installed" || x === "update-available")) return "installed";
|
|
4373
|
+
return statuses.every((x) => x === "not-installed") ? "not-installed" : "unknown";
|
|
4374
|
+
};
|
|
4375
|
+
this.checkRequirements = (requirements) => {
|
|
4376
|
+
const out = {
|
|
4377
|
+
missing: [],
|
|
4378
|
+
undecided: []
|
|
4379
|
+
};
|
|
4380
|
+
for (const req of requirements) {
|
|
4381
|
+
if (req.optional) continue;
|
|
4382
|
+
const status = this.requirementStatus(req);
|
|
4383
|
+
if (status === "not-installed") out.missing.push(req);
|
|
4384
|
+
else if (status === "unknown" || status === "error") out.undecided.push(req);
|
|
4385
|
+
}
|
|
4386
|
+
return out;
|
|
4387
|
+
};
|
|
4388
|
+
this.matchRequirements = (requirements) => {
|
|
4389
|
+
const check = this.checkRequirements(requirements);
|
|
4390
|
+
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)" : ""));
|
|
4391
|
+
return check.missing.length === 0;
|
|
4392
|
+
};
|
|
4297
4393
|
this.fetchPlugins = async (mode = "cache", skipUpdate = true) => {
|
|
4298
4394
|
return this.strategy(await this.api()).fetchPlugins(mode, skipUpdate);
|
|
4299
4395
|
};
|
|
4300
|
-
this.installPlugin = async (plugin) =>
|
|
4396
|
+
this.installPlugin = async (plugin) => await this.installPluginOutcome(plugin) === "installed";
|
|
4397
|
+
this.installPluginOutcome = async (plugin) => {
|
|
4301
4398
|
return this.runInstall(`plugin "${plugin.title}"`, {
|
|
4302
4399
|
enqueue: (api, uiId) => this.strategy(api).enqueuePlugin(plugin, uiId),
|
|
4303
4400
|
landed: async (_s, api) => {
|
|
@@ -4374,8 +4471,9 @@ var ComfyManager = class {
|
|
|
4374
4471
|
};
|
|
4375
4472
|
this.enqueuePluginTask = async (api, plugin, uiId) => {
|
|
4376
4473
|
const url = plugin.files[0] ?? plugin.reference;
|
|
4474
|
+
const id = repoPath(url).split("/").pop() ?? url;
|
|
4377
4475
|
const params = {
|
|
4378
|
-
id
|
|
4476
|
+
id,
|
|
4379
4477
|
version: "nightly",
|
|
4380
4478
|
selected_version: "nightly",
|
|
4381
4479
|
repository: url,
|
|
@@ -4388,18 +4486,26 @@ var ComfyManager = class {
|
|
|
4388
4486
|
kind: "install",
|
|
4389
4487
|
params
|
|
4390
4488
|
});
|
|
4489
|
+
return id;
|
|
4391
4490
|
};
|
|
4392
|
-
this.settleByHistory = async (api, what, uiId) => {
|
|
4491
|
+
this.settleByHistory = async (api, what, uiId, landed, sentId) => {
|
|
4393
4492
|
const route = this.route(api, "/manager/queue/history", `?ui_id=${encodeURIComponent(uiId)}`);
|
|
4493
|
+
const readEntry = async () => (await this.getValid(route, TaskHistory_ark)).history.status ?? null;
|
|
4394
4494
|
const entry = await this.waitFor(what, async () => {
|
|
4395
|
-
const status =
|
|
4396
|
-
if (status
|
|
4397
|
-
|
|
4495
|
+
const status = await readEntry();
|
|
4496
|
+
if (status != null) return status;
|
|
4497
|
+
if (await this.restartIdleQueue(api) !== "drained") return null;
|
|
4498
|
+
const late = await readEntry();
|
|
4499
|
+
if (late != null) return late;
|
|
4500
|
+
throw new InstallFailed("the task left the queue with no result (a queue/reset from the Manager UI or another client removes it)");
|
|
4398
4501
|
});
|
|
4399
|
-
if (entry.status_str === "success" || entry.status_str === "skip")
|
|
4502
|
+
if (entry.status_str === "success" || entry.status_str === "skip") {
|
|
4503
|
+
if (await this.endState(landed) !== false) return;
|
|
4504
|
+
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");
|
|
4505
|
+
}
|
|
4400
4506
|
const messages = entry.messages ?? [];
|
|
4401
4507
|
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)" : "";
|
|
4402
|
-
throw new
|
|
4508
|
+
throw new InstallFailed(`the Manager reports ${entry.status_str}: ${messages.join(" | ")}${gate}`);
|
|
4403
4509
|
};
|
|
4404
4510
|
this.restartIdleQueue = async (api) => {
|
|
4405
4511
|
const status = await this.getValid(this.route(api, "/manager/queue/status"), QueueStatus_ark);
|
|
@@ -4410,29 +4516,52 @@ var ComfyManager = class {
|
|
|
4410
4516
|
};
|
|
4411
4517
|
this.settleByDrain = async (api, what, landed) => {
|
|
4412
4518
|
await this.waitFor(what, async () => await this.restartIdleQueue(api) === "drained" ? true : null);
|
|
4413
|
-
|
|
4519
|
+
const state = await this.endState(landed);
|
|
4520
|
+
if (state === true) return;
|
|
4521
|
+
if (state === null) throw new OutcomeUnknown("the queue drained, but the lists cannot say whether it is installed");
|
|
4522
|
+
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`);
|
|
4523
|
+
};
|
|
4524
|
+
this.endState = async (landed) => {
|
|
4525
|
+
try {
|
|
4526
|
+
return await landed();
|
|
4527
|
+
} catch (exception) {
|
|
4528
|
+
throw new OutcomeUnknown(`the task ran, but its end state could not be read: ${errorText(exception)}`);
|
|
4529
|
+
}
|
|
4414
4530
|
};
|
|
4415
4531
|
this.runInstall = async (what, p) => {
|
|
4532
|
+
const host = this.host.getServerHostHTTP();
|
|
4416
4533
|
try {
|
|
4417
4534
|
const api = await this.api();
|
|
4418
4535
|
const s = this.strategy(api);
|
|
4419
4536
|
const uiId = nanoid();
|
|
4420
|
-
await p.enqueue(api, uiId);
|
|
4537
|
+
const sentId = await p.enqueue(api, uiId);
|
|
4421
4538
|
await this.post(this.route(api, "/manager/queue/start"));
|
|
4422
|
-
await s.settle(what, uiId, () => p.landed(s, api));
|
|
4539
|
+
await s.settle(what, uiId, () => p.landed(s, api), sentId);
|
|
4423
4540
|
logSuccess(`${what} installed`);
|
|
4424
|
-
return
|
|
4541
|
+
return "installed";
|
|
4425
4542
|
} catch (exception) {
|
|
4426
|
-
|
|
4427
|
-
|
|
4543
|
+
if (exception instanceof OutcomeUnknown) {
|
|
4544
|
+
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`);
|
|
4545
|
+
return "unknown";
|
|
4546
|
+
}
|
|
4547
|
+
logError(`${what}: install failed on ${host}: ${errorText(exception)}`);
|
|
4548
|
+
return "failed";
|
|
4428
4549
|
}
|
|
4429
4550
|
};
|
|
4430
4551
|
this.waitFor = async (what, check) => {
|
|
4431
4552
|
const deadline = Date.now() + this.timing.installTimeoutMs;
|
|
4553
|
+
let lastAnswer = Date.now();
|
|
4432
4554
|
for (;;) {
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4555
|
+
try {
|
|
4556
|
+
const value = await check();
|
|
4557
|
+
lastAnswer = Date.now();
|
|
4558
|
+
if (value != null) return value;
|
|
4559
|
+
} catch (exception) {
|
|
4560
|
+
if (exception instanceof InstallFailed) throw exception;
|
|
4561
|
+
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)}`);
|
|
4562
|
+
logError(`${what}: poll failed, still waiting: ${errorText(exception)}`);
|
|
4563
|
+
}
|
|
4564
|
+
if (Date.now() >= deadline) throw new OutcomeUnknown(`still running after ${this.timing.installTimeoutMs} ms (manager.timing.installTimeoutMs)`);
|
|
4436
4565
|
await new Promise((resolve) => setTimeout(resolve, this.timing.pollMs));
|
|
4437
4566
|
}
|
|
4438
4567
|
};
|
|
@@ -4783,26 +4912,8 @@ var ComfyHost = class {
|
|
|
4783
4912
|
constructor(data) {
|
|
4784
4913
|
this.data = data;
|
|
4785
4914
|
this.uploader = new ComfyUploader(this);
|
|
4786
|
-
this.matchRequirements = (requirements) =>
|
|
4787
|
-
|
|
4788
|
-
for (const req of requirements) {
|
|
4789
|
-
if (req.optional) continue;
|
|
4790
|
-
if (req.type === "customNodesByNodeKey") {
|
|
4791
|
-
if (!(repo.plugins_byNodeKey.get(req.nodeName) ?? []).find((i) => this.manager.isPluginInstalled(i.title))) return false;
|
|
4792
|
-
} else if (req.type === "customNodesByTitle") {
|
|
4793
|
-
const plugin = repo.plugins_byTitle.get(req.title);
|
|
4794
|
-
if (plugin == null) continue;
|
|
4795
|
-
if (!this.manager.isPluginInstalled(plugin.title)) return false;
|
|
4796
|
-
} else if (req.type === "customNodesByURI") {
|
|
4797
|
-
const plugin = repo.plugins_byFile.get(req.uri);
|
|
4798
|
-
if (plugin == null) continue;
|
|
4799
|
-
if (!this.manager.isPluginInstalled(plugin.title)) return false;
|
|
4800
|
-
} else if (req.type === "modelInManager") {
|
|
4801
|
-
if (!this.manager.isModelInstalled(req.modelName)) return false;
|
|
4802
|
-
}
|
|
4803
|
-
}
|
|
4804
|
-
return true;
|
|
4805
|
-
};
|
|
4915
|
+
this.matchRequirements = (requirements) => this.manager.matchRequirements(requirements);
|
|
4916
|
+
this.checkRequirements = (requirements) => this.manager.checkRequirements(requirements);
|
|
4806
4917
|
this.serverLogs = [];
|
|
4807
4918
|
this.wantLog = true;
|
|
4808
4919
|
this.maxLogs = 200;
|
|
@@ -6027,6 +6138,43 @@ var ComfyTS = class ComfyTS {
|
|
|
6027
6138
|
}
|
|
6028
6139
|
};
|
|
6029
6140
|
//#endregion
|
|
6030
|
-
|
|
6141
|
+
//#region src/exampleAssets.ts
|
|
6142
|
+
/**
|
|
6143
|
+
* the examples/ folder shipped in the npm tarball, resolved from THIS module's
|
|
6144
|
+
* own location (NEVER cwd): walking up to the nearest NAMED package.json finds
|
|
6145
|
+
* <pkg>/examples both from a consumer's node_modules/comfy-ts/dist/ and from
|
|
6146
|
+
* this repo's src/. Returns null when the examples are absent (a consumer may
|
|
6147
|
+
* prune the folder) or when the nearest named package is not comfy-ts (the lib
|
|
6148
|
+
* was inlined into someone else's bundle — its examples are not on disk); no
|
|
6149
|
+
* package.json all the way up is a broken install and throws.
|
|
6150
|
+
*/
|
|
6151
|
+
function bundledExamplesDir(moduleUrl = import.meta.url) {
|
|
6152
|
+
const pkgDir = comfyTsPackageDir(moduleUrl);
|
|
6153
|
+
if (pkgDir == null) return null;
|
|
6154
|
+
const examples = join(pkgDir, "examples");
|
|
6155
|
+
return existsSync(examples) ? examples : null;
|
|
6156
|
+
}
|
|
6157
|
+
/** the comfy-ts package root (the folder of its package.json), by the same walk: null when the
|
|
6158
|
+
* nearest named package is another one, a throw when no package.json is found at all */
|
|
6159
|
+
function comfyTsPackageDir(moduleUrl = import.meta.url) {
|
|
6160
|
+
let dir = dirname(fileURLToPath(moduleUrl));
|
|
6161
|
+
let prev = "";
|
|
6162
|
+
while (dir !== prev) {
|
|
6163
|
+
const pkgPath = join(dir, "package.json");
|
|
6164
|
+
if (existsSync(pkgPath)) {
|
|
6165
|
+
let pkg = {};
|
|
6166
|
+
try {
|
|
6167
|
+
pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
6168
|
+
} catch {}
|
|
6169
|
+
if (pkg.name === "comfy-ts") return dir;
|
|
6170
|
+
if (pkg.name != null) return null;
|
|
6171
|
+
}
|
|
6172
|
+
prev = dir;
|
|
6173
|
+
dir = dirname(dir);
|
|
6174
|
+
}
|
|
6175
|
+
throw new Error(`[comfy-ts] no package.json found walking up from ${fileURLToPath(moduleUrl)}`);
|
|
6176
|
+
}
|
|
6177
|
+
//#endregion
|
|
6178
|
+
export { readableStringify as a, settingsPathFor as i, comfyTsPackageDir as n, importSharp as o, ComfyTS as r, ComfySchema as s, bundledExamplesDir as t };
|
|
6031
6179
|
|
|
6032
|
-
//# sourceMappingURL=
|
|
6180
|
+
//# sourceMappingURL=exampleAssets-CE4PUy3n.js.map
|