comfyui-mcp 0.51.54 → 0.51.55

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.
@@ -7710,7 +7710,10 @@ export function buildPanelToolDefs() {
7710
7710
  "plus a node-type summary for INSPECTION / EXECUTION / REBUILD — it does NOT and CANNOT load the " +
7711
7711
  "result back onto the canvas (the canvas only loads UI-format graphs). Use it to understand an " +
7712
7712
  "expert workflow's real wiring, run the resolved graph headless, or rebuild connections with the " +
7713
- "graph edit tools. The resolved graph is much smaller than the raw UI JSON.", {
7713
+ "graph edit tools. The resolved graph is much smaller than the raw UI JSON. The reply is TWO " +
7714
+ "blocks — the summary and any conversion notes first, then the graph alone as a whole JSON " +
7715
+ "document — and the same graph is returned as structuredContent.graph, so nothing has to be " +
7716
+ "sliced out of prose to parse it.", {
7714
7717
  pack: z
7715
7718
  .string()
7716
7719
  .optional()
@@ -7803,7 +7806,25 @@ export function buildPanelToolDefs() {
7803
7806
  .sort((a, b) => b[1] - a[1])
7804
7807
  .map(([t, c]) => `${c}× ${t}`)
7805
7808
  .join(", ");
7806
- return ok(`Stripped to ${Object.keys(workflow).length} nodes` +
7809
+ // #1589 — THE GRAPH IS NOW ITS OWN CONTENT BLOCK, and its own
7810
+ // `structuredContent.graph`.
7811
+ //
7812
+ // It used to be string-concatenated onto the end of the summary, so the
7813
+ // single text block began "Stripped to N nodes" and `JSON.parse` of it
7814
+ // failed on the first character. Every programmatic caller had to find the
7815
+ // first `{` and slice — a heuristic that is wrong the moment a conversion
7816
+ // note quotes a brace, which the warning lines can and do (they name
7817
+ // widget values).
7818
+ //
7819
+ // The PROSE ORDER IS UNCHANGED on purpose. #361 put the conversion notes
7820
+ // ahead of the graph so a model reads "this differs from the source"
7821
+ // before the thing it differs from; moving the JSON first to make
7822
+ // `content[0]` parse would have traded a script's convenience for the
7823
+ // reader's warning. Splitting instead keeps both: block 0 is the same
7824
+ // sentence it always was, block 1 is a whole JSON document with nothing
7825
+ // before or after it, and `structuredContent` is the parsed form for
7826
+ // callers that read it.
7827
+ const proseSummary = `Stripped to ${Object.keys(workflow).length} nodes` +
7807
7828
  (warnings.length ? ` · ⚠ ${warnings.length} conversion note(s)` : "") +
7808
7829
  `\nNode types: ${summary}` +
7809
7830
  // #361: a strip that quietly loses a Set/Get link or substitutes a
@@ -7814,8 +7835,26 @@ export function buildPanelToolDefs() {
7814
7835
  ? `\nThe stripped graph DIFFERS from the source workflow where listed below — read these before running or rebuilding from it:\n${warnings
7815
7836
  .map((w) => `- ${w}`)
7816
7837
  .join("\n")}`
7817
- : "") +
7818
- `\n\n${JSON.stringify(workflow, null, 2)}`);
7838
+ : "");
7839
+ // Annotated, not inferred. `def()`'s handler type is enough for TS to accept
7840
+ // this object but NOT to reject a key ToolResult does not declare — excess-
7841
+ // property checking does not survive the inferred return type (measured: with
7842
+ // `structuredContent` deleted from ToolResult, `tsc --noEmit` still exited 0).
7843
+ // A typed local restores it, so the field is a contract the compiler enforces
7844
+ // rather than a comment.
7845
+ const reply = {
7846
+ content: [
7847
+ { type: "text", text: proseSummary },
7848
+ { type: "text", text: JSON.stringify(workflow, null, 2) },
7849
+ ],
7850
+ structuredContent: {
7851
+ graph: workflow,
7852
+ node_count: Object.keys(workflow).length,
7853
+ node_types: hist,
7854
+ warnings,
7855
+ },
7856
+ };
7857
+ return reply;
7819
7858
  }),
7820
7859
  def("panel_flatten_workflow", "Flatten the user's workflow IN PLACE, preserving their layout: every Get/Set bus, Reroute, and " +
7821
7860
  "cg-use-everywhere (UE) broadcast is resolved into a direct real link, and the virtual nodes are " +