@nodetool-ai/integration-nodes 0.8.10 → 0.8.14

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.
Files changed (42) hide show
  1. package/README.md +17 -6
  2. package/dist/.nodetool-build-stamp +1 -1
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +5 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/nodes/comfy-graph-cloud.d.ts +113 -0
  8. package/dist/nodes/comfy-graph-cloud.d.ts.map +1 -0
  9. package/dist/nodes/comfy-graph-cloud.js +578 -0
  10. package/dist/nodes/comfy-graph-cloud.js.map +1 -0
  11. package/dist/nodes/comfy-sdk.d.ts +30 -1
  12. package/dist/nodes/comfy-sdk.d.ts.map +1 -1
  13. package/dist/nodes/comfy-sdk.js +143 -32
  14. package/dist/nodes/comfy-sdk.js.map +1 -1
  15. package/dist/nodes/comfy-server-status.d.ts +31 -0
  16. package/dist/nodes/comfy-server-status.d.ts.map +1 -0
  17. package/dist/nodes/comfy-server-status.js +65 -0
  18. package/dist/nodes/comfy-server-status.js.map +1 -0
  19. package/dist/nodes/comfy-server-transport.d.ts +32 -0
  20. package/dist/nodes/comfy-server-transport.d.ts.map +1 -0
  21. package/dist/nodes/comfy-server-transport.js +177 -0
  22. package/dist/nodes/comfy-server-transport.js.map +1 -0
  23. package/dist/nodes/comfy-target.d.ts +26 -0
  24. package/dist/nodes/comfy-target.d.ts.map +1 -0
  25. package/dist/nodes/comfy-target.js +61 -0
  26. package/dist/nodes/comfy-target.js.map +1 -0
  27. package/dist/nodes/comfy-worker-transport.d.ts +16 -0
  28. package/dist/nodes/comfy-worker-transport.d.ts.map +1 -0
  29. package/dist/nodes/comfy-worker-transport.js +153 -0
  30. package/dist/nodes/comfy-worker-transport.js.map +1 -0
  31. package/dist/nodes/comfy.d.ts +3 -8
  32. package/dist/nodes/comfy.d.ts.map +1 -1
  33. package/dist/nodes/comfy.js +5 -72
  34. package/dist/nodes/comfy.js.map +1 -1
  35. package/dist/nodes/kie-dynamic.d.ts.map +1 -1
  36. package/dist/nodes/kie-dynamic.js +13 -10
  37. package/dist/nodes/kie-dynamic.js.map +1 -1
  38. package/dist/nodes/wan2gp.d.ts +141 -0
  39. package/dist/nodes/wan2gp.d.ts.map +1 -0
  40. package/dist/nodes/wan2gp.js +505 -0
  41. package/dist/nodes/wan2gp.js.map +1 -0
  42. package/package.json +6 -6
@@ -0,0 +1,578 @@
1
+ /**
2
+ * Runner for Comfy workflows (`run_mode: "comfy"`).
3
+ *
4
+ * A Comfy workflow is a NodeTool graph of `comfy.<ClassName>` nodes. The
5
+ * kernel never executes those nodes one by one: `collapseComfyGraph` in
6
+ * `@nodetool-ai/protocol` swaps the whole graph for one
7
+ * {@link ComfyCloudGraphNode}, which compiles it to ComfyUI's API format,
8
+ * submits it to Comfy Cloud through the Comfy API v2 as a single job, and
9
+ * relays the job's live events back to the editor as `node_update` and
10
+ * `node_progress` messages addressed to the original node ids. Those travel
11
+ * over the editor's existing WebSocket, so a Comfy workflow lights up node by
12
+ * node like any other run.
13
+ *
14
+ * The v2 SSE stream carries job status and outputs, but Comfy Cloud leaves its
15
+ * `current_node` empty. Per-node state comes from the Cloud WebSocket, which
16
+ * reports every job of the account, so its frames are filtered by prompt id.
17
+ * That socket only adds detail: a run without it still finishes and saves.
18
+ *
19
+ * `resolveComfyTarget` selects Comfy Cloud, a self-hosted ComfyUI or a NodeTool
20
+ * ComfyUI worker. The target only changes the transport and the node catalog.
21
+ */
22
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
23
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
24
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
25
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
26
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
27
+ };
28
+ import { Buffer } from "node:buffer";
29
+ import { randomUUID } from "node:crypto";
30
+ import { BaseNode, prop } from "@nodetool-ai/node-sdk";
31
+ import { COMFY_CLOUD_GRAPH_NODE_TYPE, buildComfyPrompt, comfyClassType, comfyOutputNames, isComfyNodeType } from "@nodetool-ai/protocol";
32
+ import { applyComfyInputs, cloudTransport, describeComfyError, jobFailure, extFromUri, outputFrame } from "./comfy-sdk.js";
33
+ import { serverTransport } from "./comfy-server-transport.js";
34
+ import { describeComfyTarget, normalizeComfyServerUrl, resolveComfyTarget } from "./comfy-target.js";
35
+ import { fetchComfyWorkerObjectInfo, workerTransport } from "./comfy-worker-transport.js";
36
+ export { describeComfyTarget, normalizeComfyServerUrl, resolveComfyTarget } from "./comfy-target.js";
37
+ /** Comfy Cloud origin. The v2 job API and the v1 node catalog share it. */
38
+ export const COMFY_CLOUD_ORIGIN = "https://cloud.comfy.org";
39
+ const OBJECT_INFO_TTL_MS = 30 * 60 * 1000;
40
+ const SERVER_OBJECT_INFO_TTL_MS = 30 * 1000;
41
+ const objectInfoCache = new Map();
42
+ /**
43
+ * Comfy Cloud's node catalog (`GET /api/object_info`), cached per API key for
44
+ * half an hour. The catalog is about 10 MB and changes when Comfy deploys.
45
+ */
46
+ export function fetchComfyObjectInfo(apiKey, options = {}) {
47
+ // In-memory only, so the key itself is the cache key; nothing is persisted.
48
+ const doFetch = options.fetchImpl ?? fetch;
49
+ return cachedObjectInfo(apiKey, OBJECT_INFO_TTL_MS, async () => {
50
+ const res = await doFetch(`${COMFY_CLOUD_ORIGIN}/api/object_info`, {
51
+ headers: { "X-API-Key": apiKey, Accept: "application/json" },
52
+ signal: options.signal
53
+ });
54
+ if (!res.ok) {
55
+ throw new Error(`Comfy Cloud node catalog request failed: HTTP ${res.status}`);
56
+ }
57
+ return (await res.json());
58
+ });
59
+ }
60
+ function cachedObjectInfo(key, ttlMs, load) {
61
+ const cached = objectInfoCache.get(key);
62
+ if (cached && Date.now() - cached.at < ttlMs) {
63
+ return cached.info;
64
+ }
65
+ const info = load();
66
+ objectInfoCache.set(key, { at: Date.now(), info });
67
+ info.catch(() => {
68
+ if (objectInfoCache.get(key)?.info === info)
69
+ objectInfoCache.delete(key);
70
+ });
71
+ return info;
72
+ }
73
+ /**
74
+ * A self-hosted ComfyUI's node catalog. It is cached briefly, because a restart
75
+ * of the server can add custom nodes and models.
76
+ */
77
+ export function fetchComfyServerObjectInfo(serverUrl, options = {}) {
78
+ const url = normalizeComfyServerUrl(serverUrl);
79
+ const doFetch = options.fetchImpl ?? fetch;
80
+ return cachedObjectInfo(url, SERVER_OBJECT_INFO_TTL_MS, async () => {
81
+ let res;
82
+ try {
83
+ res = await doFetch(`${url}/object_info`, {
84
+ headers: { Accept: "application/json" },
85
+ signal: options.signal
86
+ });
87
+ }
88
+ catch (err) {
89
+ throw new Error(`Could not reach the ComfyUI server at ${url}. Start it or correct COMFY_SERVER_URL in Settings. (${err instanceof Error ? err.message : String(err)})`);
90
+ }
91
+ if (!res.ok) {
92
+ const hint = res.status === 404
93
+ ? " ComfyUI may still be starting, or this URL may not be a ComfyUI server."
94
+ : "";
95
+ throw new Error(`The ComfyUI server at ${url} returned HTTP ${res.status} for its node catalog.${hint}`);
96
+ }
97
+ return (await res.json());
98
+ });
99
+ }
100
+ /** A ComfyUI worker's node catalog, cached briefly like a server's. */
101
+ export function fetchComfyWorkerCatalog(url, token) {
102
+ return cachedObjectInfo(`worker:${url}`, SERVER_OBJECT_INFO_TTL_MS, async () => (await fetchComfyWorkerObjectInfo(url, token)));
103
+ }
104
+ /** The node catalog of the selected target. */
105
+ export function fetchComfyTargetCatalog(target, options = {}) {
106
+ switch (target.kind) {
107
+ case "cloud":
108
+ return fetchComfyObjectInfo(target.apiKey, options);
109
+ case "server":
110
+ return fetchComfyServerObjectInfo(target.url, options);
111
+ case "worker":
112
+ return fetchComfyWorkerCatalog(target.url, target.token);
113
+ }
114
+ }
115
+ /** Test hook: forget cached catalogs. */
116
+ export function clearComfyObjectInfoCache() {
117
+ objectInfoCache.clear();
118
+ }
119
+ const TERMINAL = new Set(["succeeded", "canceled", "failed", "expired"]);
120
+ function abortError(message) {
121
+ const error = new Error(message);
122
+ error.name = "AbortError";
123
+ return error;
124
+ }
125
+ export class ComfyCloudGraphNode extends BaseNode {
126
+ static nodeType = COMFY_CLOUD_GRAPH_NODE_TYPE;
127
+ static title = "Run Comfy Workflow";
128
+ static description = "Runs a whole Comfy workflow as one job on the target in COMFY_TARGET: Comfy Cloud, a ComfyUI server or a ComfyUI worker.\n comfy, comfyui, cloud, workflow";
129
+ static hidden = true;
130
+ static inlineFields = [];
131
+ static inputFields = [];
132
+ static supportsDynamicInputs = true;
133
+ static supportsDynamicOutputs = true;
134
+ static autoSaveAsset = true;
135
+ static metadataOutputTypes = {
136
+ output: "dict[str, any]"
137
+ };
138
+ /** Split out so tests run without a Comfy Cloud account. */
139
+ createTransport(apiKey) {
140
+ return cloudTransport(apiKey);
141
+ }
142
+ /** Split out so tests run without a Comfy Cloud account. */
143
+ loadObjectInfo(apiKey, signal) {
144
+ return fetchComfyObjectInfo(apiKey, { signal });
145
+ }
146
+ /** Split out so tests can reach a local server through a real executor. */
147
+ createServerTransport(url, timeoutMs) {
148
+ return serverTransport(url, timeoutMs);
149
+ }
150
+ /** Split out so tests run without a ComfyUI server. */
151
+ loadServerObjectInfo(url, signal) {
152
+ return fetchComfyServerObjectInfo(url, { signal });
153
+ }
154
+ /** Split out so tests run without a worker. */
155
+ openWorkerTransport(url, token, timeoutSeconds) {
156
+ return workerTransport(url, token, timeoutSeconds);
157
+ }
158
+ /** Split out so tests run without a worker. */
159
+ loadWorkerObjectInfo(url, token) {
160
+ return fetchComfyWorkerCatalog(url, token);
161
+ }
162
+ /**
163
+ * Open the account WebSocket and hand each JSON frame to `onFrame`. Returns
164
+ * the function that closes it. Split out so tests run without a socket. The
165
+ * URL holds the API key, so it never goes into a log line.
166
+ */
167
+ openLiveFrames(apiKey, onFrame, onUnavailable) {
168
+ const url = new URL("/ws", COMFY_CLOUD_ORIGIN);
169
+ url.protocol = "wss:";
170
+ url.searchParams.set("clientId", randomUUID());
171
+ url.searchParams.set("token", apiKey);
172
+ const socket = new WebSocket(url);
173
+ socket.addEventListener("message", (event) => {
174
+ // Binary frames are preview bitmaps, which the SSE stream also carries.
175
+ if (typeof event.data !== "string")
176
+ return;
177
+ try {
178
+ onFrame(JSON.parse(event.data));
179
+ }
180
+ catch {
181
+ // A malformed status frame costs one update, not the run.
182
+ }
183
+ });
184
+ socket.addEventListener("error", onUnavailable);
185
+ return () => socket.close();
186
+ }
187
+ /**
188
+ * Save one output file as an asset of the Comfy node that produced it, so it
189
+ * appears in the assets panel and in that node's history. A failed save keeps
190
+ * the bytes on the frame: the job has already been paid for.
191
+ */
192
+ async saveOutput(output, frame, context, warn) {
193
+ const [slot, value] = Object.entries(frame)[0] ?? [];
194
+ const ref = value;
195
+ if (!slot || !ref?.data || !context?.hasModelInterface?.("createAsset")) {
196
+ return frame;
197
+ }
198
+ try {
199
+ const created = (await context.createAsset({
200
+ name: output.name,
201
+ contentType: output.contentType,
202
+ content: Buffer.from(ref.data, "base64"),
203
+ nodeId: output.nodeId,
204
+ metadata: { output_name: "output" }
205
+ }));
206
+ if (typeof created?.id !== "string")
207
+ return frame;
208
+ const ext = extFromUri(output.name);
209
+ return {
210
+ [slot]: {
211
+ type: ref.type,
212
+ uri: `asset://${created.id}${ext ? `.${ext}` : ""}`,
213
+ asset_id: created.id,
214
+ mimeType: ref.mimeType
215
+ }
216
+ };
217
+ }
218
+ catch (err) {
219
+ warn(`Could not save ${output.name} as an asset: ${err instanceof Error ? err.message : String(err)}`);
220
+ return frame;
221
+ }
222
+ }
223
+ async process(context) {
224
+ const merged = {};
225
+ for await (const frame of this.genProcess(context)) {
226
+ Object.assign(merged, frame);
227
+ }
228
+ return merged;
229
+ }
230
+ async *genProcess(context) {
231
+ const live = { close: () => { } };
232
+ try {
233
+ yield* this.runJob(context, live);
234
+ }
235
+ finally {
236
+ live.close();
237
+ }
238
+ }
239
+ async *runJob(context, live) {
240
+ const target = await resolveComfyTarget(async (key) => key === "COMFY_API_KEY"
241
+ ? this._secrets.COMFY_API_KEY?.trim() || context?.getSecret(key)
242
+ : context?.getSecret(key));
243
+ const where = describeComfyTarget(target);
244
+ const apiKey = target.kind === "cloud" ? target.apiKey : undefined;
245
+ const graph = {
246
+ nodes: (Array.isArray(this.nodes) ? this.nodes : []).filter((n) => isComfyNodeType(n?.type)),
247
+ edges: Array.isArray(this.edges) ? this.edges : []
248
+ };
249
+ if (graph.nodes.length === 0) {
250
+ throw new Error("The Comfy workflow has no ComfyUI nodes to run.");
251
+ }
252
+ const timeoutSeconds = Math.max(1, this.timeout);
253
+ const timeoutSignal = AbortSignal.timeout(timeoutSeconds * 1000);
254
+ const signal = context?.signal
255
+ ? AbortSignal.any([context.signal, timeoutSignal])
256
+ : timeoutSignal;
257
+ const runnerId = this.__node_id;
258
+ const runnerName = this.__node_name || ComfyCloudGraphNode.title;
259
+ const log = (content, severity = "info") => {
260
+ context?.postMessage({
261
+ type: "log_update",
262
+ node_id: runnerId,
263
+ node_name: runnerName,
264
+ content,
265
+ severity
266
+ });
267
+ };
268
+ const nodesById = new Map(graph.nodes.map((n) => [n.id, n]));
269
+ const lastStatus = new Map();
270
+ const nameOf = (node) => {
271
+ const title = node.ui_properties?.title;
272
+ return typeof title === "string" && title ? title : comfyClassType(node.type);
273
+ };
274
+ const nodeUpdate = (nodeId, status, extra = {}) => {
275
+ const node = nodesById.get(nodeId);
276
+ if (!node)
277
+ return;
278
+ // A repeat of the same status carries nothing new for the editor.
279
+ if (lastStatus.get(nodeId) === status && Object.keys(extra).length === 0)
280
+ return;
281
+ lastStatus.set(nodeId, status);
282
+ context?.postMessage({
283
+ type: "node_update",
284
+ node_id: nodeId,
285
+ node_name: nameOf(node),
286
+ node_type: node.type,
287
+ status,
288
+ ...extra
289
+ });
290
+ };
291
+ let info;
292
+ try {
293
+ info =
294
+ target.kind === "server"
295
+ ? await this.loadServerObjectInfo(target.url, signal)
296
+ : target.kind === "worker"
297
+ ? await this.loadWorkerObjectInfo(target.url, target.token)
298
+ : await this.loadObjectInfo(target.apiKey, signal);
299
+ }
300
+ catch (err) {
301
+ throw describeComfyError(err);
302
+ }
303
+ const unknown = graph.nodes
304
+ .map((n) => comfyClassType(n.type))
305
+ .filter((cls) => !(cls in info));
306
+ if (unknown.length > 0) {
307
+ throw new Error(`${where} does not have these node classes: ${[...new Set(unknown)].join(", ")}`);
308
+ }
309
+ // A Comfy job returns files only for its output nodes, so a socket wired to
310
+ // an Output would stay empty for the whole run.
311
+ for (const slot of Array.isArray(this.output_slots) ? this.output_slots : []) {
312
+ const sep = slot.indexOf(":");
313
+ const source = nodesById.get(slot.slice(0, sep));
314
+ const entry = source ? info[comfyClassType(source.type)] : undefined;
315
+ if (slot.slice(sep + 1) !== "output" || entry?.output_node !== true) {
316
+ throw new Error(`A workflow Output reads ${slot}, which Comfy does not return. Connect the Output to a Save node.`);
317
+ }
318
+ }
319
+ const prompt = buildComfyPrompt(graph, (cls) => info[cls] ? comfyOutputNames(info[cls]) : undefined);
320
+ const transport = target.kind === "server"
321
+ ? this.createServerTransport(target.url, timeoutSeconds * 1000)
322
+ : target.kind === "worker"
323
+ ? await this.openWorkerTransport(target.url, target.token, timeoutSeconds)
324
+ : this.createTransport(target.apiKey);
325
+ await applyComfyInputs(prompt, this.dynamicProps, transport, context);
326
+ for (const node of graph.nodes)
327
+ nodeUpdate(node.id, "queued");
328
+ log(`Submitting Comfy workflow to ${where} (${graph.nodes.length} nodes)`);
329
+ const done = new Set();
330
+ const finish = (nodeId) => {
331
+ if (!nodeId || done.has(nodeId))
332
+ return;
333
+ done.add(nodeId);
334
+ nodeUpdate(nodeId, "completed");
335
+ };
336
+ // Frames can beat the submit response, so they wait for the job id.
337
+ let liveJobId = null;
338
+ let liveSeen = false;
339
+ const earlyFrames = [];
340
+ const lastNodeProgress = new Map();
341
+ const applyLiveFrame = (frame) => {
342
+ const nodes = frame.data?.nodes;
343
+ if (frame.type === "execution_cached" && Array.isArray(nodes)) {
344
+ liveSeen = true;
345
+ for (const id of nodes)
346
+ finish(String(id));
347
+ }
348
+ if (frame.type !== "progress_state" || !nodes || Array.isArray(nodes))
349
+ return;
350
+ liveSeen = true;
351
+ for (const [key, state] of Object.entries(nodes)) {
352
+ const id = state.display_node_id ?? state.node_id ?? key;
353
+ if (state.state === "finished") {
354
+ finish(id);
355
+ }
356
+ else if (state.state === "running" && !done.has(id)) {
357
+ nodeUpdate(id, "running");
358
+ const { value, max } = state;
359
+ if (typeof value === "number" &&
360
+ typeof max === "number" &&
361
+ max > 1 &&
362
+ lastNodeProgress.get(id) !== value) {
363
+ lastNodeProgress.set(id, value);
364
+ context?.postMessage({
365
+ type: "node_progress",
366
+ node_id: id,
367
+ progress: value,
368
+ total: max
369
+ });
370
+ }
371
+ }
372
+ }
373
+ };
374
+ // A self-hosted or worker job reports its nodes through its own events.
375
+ if (apiKey)
376
+ try {
377
+ live.close = this.openLiveFrames(apiKey, (frame) => {
378
+ const promptId = frame.data?.prompt_id;
379
+ if (!promptId)
380
+ return;
381
+ if (liveJobId === null)
382
+ earlyFrames.push(frame);
383
+ else if (promptId === liveJobId)
384
+ applyLiveFrame(frame);
385
+ }, () => log("Live node status is unavailable for this run", "warning"));
386
+ }
387
+ catch {
388
+ log("Live node status is unavailable for this run", "warning");
389
+ }
390
+ let job;
391
+ try {
392
+ job = await transport.submit(prompt, { signal, apiKey });
393
+ }
394
+ catch (err) {
395
+ const error = describeComfyError(err);
396
+ for (const node of graph.nodes)
397
+ nodeUpdate(node.id, "error", { error: error.message });
398
+ throw error;
399
+ }
400
+ log(`Comfy job ${job.id} submitted`);
401
+ liveJobId = job.id;
402
+ for (const frame of earlyFrames.splice(0)) {
403
+ if (frame.data?.prompt_id === liveJobId)
404
+ applyLiveFrame(frame);
405
+ }
406
+ const onAbort = () => {
407
+ void job.cancel().catch(() => {
408
+ // A finished job stays terminal; nothing to undo.
409
+ });
410
+ };
411
+ if (signal.aborted)
412
+ onAbort();
413
+ else
414
+ signal.addEventListener("abort", onAbort, { once: true });
415
+ let active = null;
416
+ const emitted = new Set();
417
+ let fileCount = 0;
418
+ let terminal = null;
419
+ let runningMarked = false;
420
+ const emitOutput = async (output) => {
421
+ const frame = await this.saveOutput(output, await outputFrame(output, signal), context, (content) => log(content, "warning"));
422
+ const value = Object.values(frame)[0];
423
+ // The editor shows the file inline on the Comfy node that saved it.
424
+ const shown = value && typeof value === "object" && value.data
425
+ ? { type: value.type, uri: `data:${value.mimeType ?? "application/octet-stream"};base64,${value.data}` }
426
+ : value;
427
+ done.add(output.nodeId);
428
+ nodeUpdate(output.nodeId, "completed", { result: { output: shown } });
429
+ // A workflow Output reads the node's `output` handle.
430
+ return { ...frame, [`${output.nodeId}:output`]: Object.values(frame)[0] };
431
+ };
432
+ try {
433
+ for await (const event of job.events(signal)) {
434
+ switch (event.kind) {
435
+ case "statusChange":
436
+ log(event.queuePosition === null
437
+ ? `Status: ${event.status}`
438
+ : `Status: ${event.status} (queue position ${event.queuePosition})`);
439
+ if (TERMINAL.has(event.status))
440
+ terminal = event.status;
441
+ // Without the live socket nothing names the executing node, so once
442
+ // the job leaves the queue every pending node shows running until
443
+ // progress names one or the job finishes.
444
+ if (event.status === "running" && !runningMarked && !liveSeen) {
445
+ runningMarked = true;
446
+ for (const node of graph.nodes) {
447
+ if (!done.has(node.id))
448
+ nodeUpdate(node.id, "running");
449
+ }
450
+ }
451
+ break;
452
+ case "progress": {
453
+ const current = event.currentNode;
454
+ if (current && current !== active) {
455
+ finish(active);
456
+ active = current;
457
+ nodeUpdate(current, "running");
458
+ }
459
+ if (active && event.step !== null && event.steps !== null && event.steps > 0) {
460
+ context?.postMessage({
461
+ type: "node_progress",
462
+ node_id: active,
463
+ progress: event.step,
464
+ total: event.steps
465
+ });
466
+ }
467
+ context?.postMessage({
468
+ type: "node_progress",
469
+ node_id: runnerId,
470
+ progress: Math.round(event.value * 100),
471
+ total: 100
472
+ });
473
+ break;
474
+ }
475
+ case "preview": {
476
+ const uri = `data:${event.contentType};base64,${Buffer.from(event.data).toString("base64")}`;
477
+ nodeUpdate(event.nodeId, "running", {
478
+ result: { output: { type: "image", uri } }
479
+ });
480
+ break;
481
+ }
482
+ case "outputReady": {
483
+ fileCount += 1;
484
+ emitted.add(event.output.id);
485
+ log(`Output from #${event.output.nodeId} (${event.output.name})`);
486
+ yield await emitOutput(event.output);
487
+ break;
488
+ }
489
+ case "log":
490
+ log(event.message, event.level === "error" ? "error" : "info");
491
+ break;
492
+ }
493
+ }
494
+ }
495
+ catch (err) {
496
+ signal.removeEventListener("abort", onAbort);
497
+ if (signal.aborted) {
498
+ if (timeoutSignal.aborted && !context?.signal?.aborted) {
499
+ throw new Error(`Comfy job did not finish within ${timeoutSeconds}s`);
500
+ }
501
+ throw abortError(`Comfy job ${job.id} was canceled`);
502
+ }
503
+ throw describeComfyError(err);
504
+ }
505
+ signal.removeEventListener("abort", onAbort);
506
+ await job.refresh(signal);
507
+ const status = TERMINAL.has(job.status) ? job.status : (terminal ?? job.status);
508
+ if (status === "canceled" || status === "canceling") {
509
+ throw abortError(`Comfy job ${job.id} was canceled`);
510
+ }
511
+ if (status !== "succeeded") {
512
+ const error = status === "failed" ? jobFailure(job) : new Error(`Comfy job ${job.id} ended ${status}`);
513
+ const failedNode = job.error?.node_id ?? active;
514
+ if (failedNode)
515
+ nodeUpdate(String(failedNode), "error", { error: error.message });
516
+ log(error.message, "error");
517
+ throw error;
518
+ }
519
+ for (const output of job.outputs) {
520
+ if (emitted.has(output.id))
521
+ continue;
522
+ fileCount += 1;
523
+ yield await emitOutput(output);
524
+ }
525
+ // Nodes Comfy served from cache never report progress; the job finished,
526
+ // so every node did too.
527
+ for (const node of graph.nodes)
528
+ finish(node.id);
529
+ log(`Comfy job ${job.id} completed (${fileCount} file${fileCount === 1 ? "" : "s"})`);
530
+ yield {
531
+ output: {
532
+ job_id: job.id,
533
+ status,
534
+ outputs: job.outputs.map((o) => ({
535
+ node_id: o.nodeId,
536
+ name: o.name,
537
+ type: o.type,
538
+ content_type: o.contentType,
539
+ asset_id: o.id
540
+ }))
541
+ }
542
+ };
543
+ }
544
+ }
545
+ __decorate([
546
+ prop({
547
+ type: "list[dict[str, any]]",
548
+ default: [],
549
+ title: "Nodes",
550
+ description: "The Comfy workflow's `comfy.*` nodes."
551
+ })
552
+ ], ComfyCloudGraphNode.prototype, "nodes", void 0);
553
+ __decorate([
554
+ prop({
555
+ type: "list[dict[str, any]]",
556
+ default: [],
557
+ title: "Edges",
558
+ description: "The Comfy workflow's edges."
559
+ })
560
+ ], ComfyCloudGraphNode.prototype, "edges", void 0);
561
+ __decorate([
562
+ prop({
563
+ type: "list[str]",
564
+ default: [],
565
+ title: "Output Slots",
566
+ description: "The `<comfyNodeId>:<handle>` slots that workflow Output nodes read."
567
+ })
568
+ ], ComfyCloudGraphNode.prototype, "output_slots", void 0);
569
+ __decorate([
570
+ prop({
571
+ type: "int",
572
+ default: 1800,
573
+ title: "Timeout",
574
+ description: "Maximum seconds to wait for the job to finish.",
575
+ min: 1
576
+ })
577
+ ], ComfyCloudGraphNode.prototype, "timeout", void 0);
578
+ //# sourceMappingURL=comfy-graph-cloud.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comfy-graph-cloud.js","sourceRoot":"","sources":["../../src/nodes/comfy-graph-cloud.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EACL,2BAA2B,EAC3B,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,eAAe,EAKhB,MAAM,uBAAuB,CAAC;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,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,qEAAqE;KACnF,CAAC;yDAC6B;AASvB;IAPP,IAAI,CAAC;QACJ,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,gDAAgD;QAC7D,GAAG,EAAE,CAAC;KACP,CAAC;oDACsB"}
@@ -106,7 +106,11 @@ export interface ComfyTransport {
106
106
  }): Promise<ComfyJob>;
107
107
  assetFromBytes(bytes: Uint8Array, filename: string, contentType: string): ComfyAssetHandle;
108
108
  }
109
- /** Comfy Cloud, authenticated with a `COMFY_API_KEY`. */
109
+ /**
110
+ * Comfy Cloud, authenticated with a `COMFY_API_KEY`. Comfy Cloud answers a job
111
+ * with `http://` links, which the SDK polls with no key; `comfyCloudFetch`
112
+ * restores https and the key, as the comfy_cloud provider does.
113
+ */
110
114
  export declare function cloudTransport(apiKey: string): ComfyTransport;
111
115
  /** Drop every trailing `/` without a regex that backtracks on long runs. */
112
116
  export declare function stripTrailingSlashes(value: string): string;
@@ -145,6 +149,19 @@ export interface ComfyRunOptions {
145
149
  }
146
150
  /** Turn an SDK error into a message a workflow author can act on. */
147
151
  export declare function describeComfyError(err: unknown): Error;
152
+ export declare function jobFailure(job: ComfyJob): Error;
153
+ /**
154
+ * The media kind of an output. Comfy Cloud reports SaveVideo and SaveAudio
155
+ * files with `type: "image"`, so a video or audio content type wins over it.
156
+ */
157
+ export declare function outputKind(output: Pick<ComfyOutput, "type" | "contentType">): string;
158
+ /** Map one finished output onto its dynamic slot name and frame value. */
159
+ export declare function outputFrame(output: ComfyOutput, signal: AbortSignal): Promise<Record<string, unknown>>;
160
+ /**
161
+ * Write run inputs into `graph`. A key `<comfyNodeId>:<field>` names the field,
162
+ * and a media value is uploaded through `transport`.
163
+ */
164
+ export declare function applyComfyInputs(graph: ComfyPrompt, dynamicProps: Iterable<[string, unknown]>, transport: ComfyTransport, context: ProcessingContext | undefined): Promise<void>;
148
165
  /**
149
166
  * Submit `prompt` through `transport` and stream what it produces.
150
167
  *
@@ -155,4 +172,16 @@ export declare function describeComfyError(err: unknown): Error;
155
172
  * UI-format workflow).
156
173
  */
157
174
  export declare function runComfyWorkflow(transport: ComfyTransport, prompt: ComfyPrompt, dynamicProps: Iterable<[string, unknown]>, options: ComfyRunOptions): AsyncGenerator<Record<string, unknown>>;
175
+ /** Sniff a media kind + mime from the leading bytes of a ComfyUI output blob. */
176
+ export declare function sniffMedia(bytes: Uint8Array): {
177
+ kind: string;
178
+ mime: string;
179
+ };
180
+ /**
181
+ * Turn a worker WebSocket URL into the HTTP origin its API v2 routes live on:
182
+ * `ws:` becomes `http:`, `wss:` becomes `https:`, and path and query are
183
+ * dropped (`wss://abc-7777.proxy.runpod.net/ws` →
184
+ * `https://abc-7777.proxy.runpod.net`).
185
+ */
186
+ export declare function workerHttpOrigin(workerUrl: string): string;
158
187
  //# sourceMappingURL=comfy-sdk.d.ts.map