comfyui-mcp 0.52.72 → 0.52.73

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.
@@ -3289,20 +3289,62 @@ function annotateQueueStatusWithManifestPartial(res) {
3289
3289
  };
3290
3290
  }
3291
3291
  /** Parse a ctx.call ToolResult's text payload as JSON, or null if not parseable. */
3292
- function parseToolResultJson(res) {
3292
+ function parseToolResultValue(res) {
3293
3293
  if (!res || res.isError)
3294
3294
  return null;
3295
3295
  const text = res?.content?.find((c) => c.type === "text")?.text;
3296
3296
  if (typeof text !== "string")
3297
3297
  return null;
3298
3298
  try {
3299
- const parsed = JSON.parse(text);
3300
- return parsed && typeof parsed === "object" ? parsed : null;
3299
+ return JSON.parse(text);
3301
3300
  }
3302
3301
  catch {
3303
3302
  return null;
3304
3303
  }
3305
3304
  }
3305
+ function parseToolResultJson(res) {
3306
+ const parsed = parseToolResultValue(res);
3307
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed)
3308
+ ? parsed
3309
+ : null;
3310
+ }
3311
+ /**
3312
+ * Normalize the panel's graph_query detail reply for graph consumers. Newer
3313
+ * panel executors return matching detail rows as JSON Lines in `text` inside a
3314
+ * wrapper object, while older/current executors may return `{ nodes: [...] }`.
3315
+ * A malformed row is only one bad observation; it must not discard the valid
3316
+ * rows that follow it or make panel_kitchen report a transport failure.
3317
+ */
3318
+ function normalizeGraphQueryResult(res) {
3319
+ const parsed = parseToolResultValue(res);
3320
+ if (!parsed)
3321
+ return { nodes: [] };
3322
+ if (Array.isArray(parsed))
3323
+ return { nodes: parsed };
3324
+ if (typeof parsed !== "object")
3325
+ return { nodes: [] };
3326
+ const record = parsed;
3327
+ if (Array.isArray(record.nodes))
3328
+ return record;
3329
+ if (typeof record.text !== "string")
3330
+ return { nodes: [] };
3331
+ const nodes = [];
3332
+ for (const line of record.text.split(/\r?\n/)) {
3333
+ const trimmed = line.trim();
3334
+ if (!trimmed)
3335
+ continue;
3336
+ try {
3337
+ const row = JSON.parse(trimmed);
3338
+ if (row && typeof row === "object" && !Array.isArray(row)) {
3339
+ nodes.push(row);
3340
+ }
3341
+ }
3342
+ catch {
3343
+ // Ignore one malformed JSON row; other graph_query rows remain usable.
3344
+ }
3345
+ }
3346
+ return { ...record, nodes };
3347
+ }
3306
3348
  function toolResultText(res) {
3307
3349
  return res?.content?.find((c) => c.type === "text")?.text ?? "workflow_open failed";
3308
3350
  }
@@ -16917,8 +16959,21 @@ CHECKED FOR YOU: the graph read this message prescribes was just run, and it ` +
16917
16959
  types: ["UNETLoader"],
16918
16960
  fields: "detail",
16919
16961
  limit: 200,
16962
+ max_chars: 60000,
16920
16963
  });
16921
- const graph = parseToolResultJson(query) ?? { nodes: [] };
16964
+ if (query.isError)
16965
+ return query;
16966
+ const graph = normalizeGraphQueryResult(query);
16967
+ if (graph.truncated === true) {
16968
+ const truncationCause = graph.truncated_by === "limit"
16969
+ ? "the graph_query row limit"
16970
+ : graph.truncated_by === "max_chars"
16971
+ ? "the panel's max_chars ceiling"
16972
+ : "a panel response cap";
16973
+ return fail(`panel_kitchen could not assess the complete live graph: graph_query truncated its ` +
16974
+ `detail rows at ${truncationCause}. Narrow the live graph with a ` +
16975
+ `more specific workflow or retry after reducing the number of UNETLoaders.`);
16976
+ }
16922
16977
  const recs = await assessKitchenGraph(status, graph);
16923
16978
  if (args.action === "assess") {
16924
16979
  const hint = kitchenProactiveHint(status, recs);