[PR #44] [CLOSED] feat: add embedWorkflow to embed the graph in output metadata #54

Closed
opened 2026-10-31 22:04:10 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/comfy-typescript-sdk/pull/44
Author: @wei-hai
Created: 8/12/2026
Status: ❌ Closed

Base: main ← Head: wei/be-7128-embed-workflow-metadata


📝 Commits (1)

  • 998d6ea feat: add embedWorkflow option to embed the API-format graph in output metadata

📊 Changes

5 files changed (+169 additions, -8 deletions)

View changed files

📝 README.md (+25 -1)
📝 src/sdk/client.test.ts (+64 -0)
📝 src/sdk/client.ts (+23 -6)
📝 src/sdk/core.test.ts (+27 -0)
📝 src/sdk/core.ts (+30 -1)

📄 Description

Recovering the workflow from an image it produced isn't possible today, which makes debugging harder. Adds an opt-in flag.

flowchart LR
  W["workflow"] --> M["materialize<br/>(assets → core/ASSET)"]
  M --> G["graph"]
  G -- "workflow" --> R["POST /jobs"]
  G -- "extra_data.extra_pnginfo.workflow<br/>(only if embedWorkflow)" --> R
  R --> P["PNG: workflow chunk"]

submit() and run() take embedWorkflow?: boolean, threaded from run() through to submit(). When set, the SDK sends the materialized graph as extra_data.extra_pnginfo.workflow, the key local ComfyUI's SaveImage writes into output PNG metadata.

Behavior

  • Off by default. With no apiKey and the flag off, the wire format is byte-identical to today: no extra_data at all, never {}. Existing tests pinning this are untouched.
  • Merges with the partner-node key when both are given.
  • Embeds the materialized graph — the same object sent as workflow — not the caller's input. A test asserts the core/ASSET substitution actually happened, so it can't pass by embedding the wrong object.

Reviewer notes

  • Needs the matching server-side contract change, landing separately — don't merge this first, or the flag is a no-op.
  • spec/openapi.yaml is untouched by design (synced one-way). Because of that, core.ts carries a local ExtraData type extending the generated one. It is temporary — delete it once the spec re-syncs.
  • The Python SDK ships the same feature as embed_workflow, producing identical bytes.

oxlint, oxfmt, tsc, vitest (161 passed), spec-drift, hygiene, and build all clean.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/comfy-typescript-sdk/pull/44 **Author:** [@wei-hai](https://github.com/wei-hai) **Created:** 8/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `wei/be-7128-embed-workflow-metadata` --- ### 📝 Commits (1) - [`998d6ea`](https://github.com/Comfy-Org/comfy-typescript-sdk/commit/998d6eaec8c7aad0af2c17e0c0c53d70aed1e770) feat: add embedWorkflow option to embed the API-format graph in output metadata ### 📊 Changes **5 files changed** (+169 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+25 -1) 📝 `src/sdk/client.test.ts` (+64 -0) 📝 `src/sdk/client.ts` (+23 -6) 📝 `src/sdk/core.test.ts` (+27 -0) 📝 `src/sdk/core.ts` (+30 -1) </details> ### 📄 Description Recovering the workflow from an image it produced isn't possible today, which makes debugging harder. Adds an opt-in flag. ```mermaid flowchart LR W["workflow"] --> M["materialize<br/>(assets → core/ASSET)"] M --> G["graph"] G -- "workflow" --> R["POST /jobs"] G -- "extra_data.extra_pnginfo.workflow<br/>(only if embedWorkflow)" --> R R --> P["PNG: workflow chunk"] ``` `submit()` and `run()` take `embedWorkflow?: boolean`, threaded from `run()` through to `submit()`. When set, the SDK sends the materialized graph as `extra_data.extra_pnginfo.workflow`, the key local ComfyUI's `SaveImage` writes into output PNG metadata. ## Behavior - Off by default. With no `apiKey` and the flag off, the wire format is byte-identical to today: no `extra_data` at all, never `{}`. Existing tests pinning this are untouched. - Merges with the partner-node key when both are given. - Embeds the **materialized** graph — the same object sent as `workflow` — not the caller's input. A test asserts the `core/ASSET` substitution actually happened, so it can't pass by embedding the wrong object. ## Reviewer notes - Needs the matching server-side contract change, landing separately — **don't merge this first**, or the flag is a no-op. - `spec/openapi.yaml` is untouched by design (synced one-way). Because of that, `core.ts` carries a local `ExtraData` type extending the generated one. **It is temporary — delete it once the spec re-syncs.** - The Python SDK ships the same feature as `embed_workflow`, producing identical bytes. `oxlint`, `oxfmt`, `tsc`, `vitest` (161 passed), spec-drift, hygiene, and build all clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 22:04:10 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/comfy-typescript-sdk#54
No description provided.