comfyui-mcp 0.50.76 → 0.50.77

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.
@@ -6,6 +6,28 @@
6
6
  // clear "install <pkg>" error instead of crashing on import.
7
7
  import { ModelError } from "./errors.js";
8
8
  const cache = new Map();
9
+ export function classifyImportFailure(spec, err) {
10
+ const e = err;
11
+ const message = typeof e?.message === "string" ? e.message : String(err);
12
+ const notFound = e?.code === "ERR_MODULE_NOT_FOUND" || e?.code === "MODULE_NOT_FOUND";
13
+ if (!notFound)
14
+ return { kind: "unloadable", detail: message };
15
+ // "Cannot find package 'x' imported from …" / "Cannot find module 'x'".
16
+ const named = /Cannot find (?:package|module) ['"]([^'"]+)['"]/.exec(message)?.[1];
17
+ if (named === undefined) {
18
+ // A not-found we cannot attribute. Treat it as the requested package rather
19
+ // than inventing a transitive one — this is the pre-existing behaviour and
20
+ // the common case.
21
+ return { kind: "missing" };
22
+ }
23
+ // SUBPATHS RUN BOTH WAYS, and only one direction is obvious. Requesting
24
+ // "pkg/sub" makes Node report `Cannot find package 'pkg'` — it names the bare
25
+ // PACKAGE, not what was asked for — so a `named === spec` test fails and the
26
+ // package gets blamed as its own dependency. Found by a surviving mutant and
27
+ // confirmed against real Node before fixing.
28
+ const isSelf = named === spec || named.startsWith(`${spec}/`) || spec.startsWith(`${named}/`);
29
+ return isSelf ? { kind: "missing" } : { kind: "missing-transitive", detail: named };
30
+ }
9
31
  export async function requireOptionalDep(spec, options) {
10
32
  const cached = cache.get(spec);
11
33
  if (cached !== undefined)
@@ -18,9 +40,21 @@ export async function requireOptionalDep(spec, options) {
18
40
  catch (err) {
19
41
  const feature = options?.feature ?? spec;
20
42
  const installHint = options?.installHint ?? `npm install ${spec}`;
21
- throw new ModelError(`Optional dependency for ${feature} is not installed. ` +
22
- `To enable it, run: ${installHint}`, {
23
- code: "OPTIONAL_DEP_MISSING",
43
+ const why = classifyImportFailure(spec, err);
44
+ throw new ModelError(why.kind === "missing"
45
+ ? `Optional dependency for ${feature} is not installed. To enable it, run: ${installHint}`
46
+ : why.kind === "missing-transitive"
47
+ ? `Optional dependency for ${feature} IS installed, but it could not load because ` +
48
+ `${why.detail} is missing — one of its own dependencies, not this package. ` +
49
+ `Running "${installHint}" will report nothing to do. Reinstall it so its ` +
50
+ `dependency tree is resolved (npm install --force ${spec}), or install ${why.detail} directly.`
51
+ : `Optional dependency for ${feature} IS installed, but it failed to LOAD: ${why.detail}. ` +
52
+ `Running "${installHint}" will report nothing to do — the package is present and ` +
53
+ `broken, which is usually a native binary built for a different Node/ABI or platform. ` +
54
+ `Reinstall it (npm install --force ${spec}), or check that binary's own requirements.`, {
55
+ // The code still distinguishes the two for programmatic callers: only a
56
+ // genuinely absent package is MISSING.
57
+ code: why.kind === "missing" ? "OPTIONAL_DEP_MISSING" : "OPTIONAL_DEP_UNLOADABLE",
24
58
  package: spec,
25
59
  cause: err instanceof Error ? err.message : String(err),
26
60
  });
@@ -1 +1 @@
1
- {"version":3,"file":"optional-dep.js","sourceRoot":"","sources":["../../src/utils/optional-dep.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,EAAE;AACF,6EAA6E;AAC7E,8EAA8E;AAC9E,6EAA6E;AAC7E,6DAA6D;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAmB,CAAC;AAEzC,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,IAAY,EACZ,OAGC;IAED,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAW,CAAC;IAC7C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,CAAM,CAAC;QACtC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACrB,OAAO,GA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I,KAAK,SAAS;YACpB,CAAC,CAAC,2BAA2B,OAAO,yCAAyC,WAAW,EAAE;YAC1F,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,oBAAoB;gBACjC,CAAC,CAAC,2BAA2B,OAAO,+CAA+C;oBACjF,GAAG,GAAG,CAAC,MAAM,+DAA+D;oBAC5E,YAAY,WAAW,mDAAmD;oBAC1E,oDAAoD,IAAI,iBAAiB,GAAG,CAAC,MAAM,YAAY;gBACjG,CAAC,CAAC,2BAA2B,OAAO,yCAAyC,GAAG,CAAC,MAAM,IAAI;oBACzF,YAAY,WAAW,2DAA2D;oBAClF,uFAAuF;oBACvF,qCAAqC,IAAI,6CAA6C,EAC5F;YACE,wEAAwE;YACxE,uCAAuC;YACvC,IAAI,EAAE,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,yBAAyB;YACjF,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;SACxD,CACF,CAAC;IACJ,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comfyui-mcp",
3
- "version": "0.50.76",
3
+ "version": "0.50.77",
4
4
  "mcpName": "io.github.artokun/comfyui-mcp",
5
5
  "description": "Local-first, agent-native control plane for ComfyUI — MCP server + autonomous sidebar agent that drives your live graph in natural language on ANY LLM: Claude/ChatGPT/Gemini on your subscription (no API key), free local models via Ollama (fully offline), or any hosted model via an OpenAI-compatible endpoint (DeepSeek, GLM, MiMo, OpenRouter). Generate images, video & audio, author and run workflows, manage models and custom nodes; a compact tool-router mode keeps even 4B models effective, and a built-in LLM Arena benchmarks them on real ComfyUI tasks. Also a Claude Code plugin with skills, slash commands, and installer packs. Local, LAN, VPS, or Comfy Cloud.",
6
6
  "homepage": "https://comfyui-mcp.artokun.io/docs",