comfyui-node 1.3.1 → 1.4.0
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.
- package/README.md +39 -33
- package/dist/.tsbuildinfo +1 -1
- package/dist/call-wrapper.d.ts +1 -0
- package/dist/call-wrapper.d.ts.map +1 -1
- package/dist/call-wrapper.js +136 -41
- package/dist/call-wrapper.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/pool/WorkflowPool.d.ts +37 -0
- package/dist/pool/WorkflowPool.d.ts.map +1 -0
- package/dist/pool/WorkflowPool.js +435 -0
- package/dist/pool/WorkflowPool.js.map +1 -0
- package/dist/pool/client/ClientManager.d.ts +36 -0
- package/dist/pool/client/ClientManager.d.ts.map +1 -0
- package/dist/pool/client/ClientManager.js +104 -0
- package/dist/pool/client/ClientManager.js.map +1 -0
- package/dist/pool/failover/SmartFailoverStrategy.d.ts +18 -0
- package/dist/pool/failover/SmartFailoverStrategy.d.ts.map +1 -0
- package/dist/pool/failover/SmartFailoverStrategy.js +65 -0
- package/dist/pool/failover/SmartFailoverStrategy.js.map +1 -0
- package/dist/pool/failover/Strategy.d.ts +10 -0
- package/dist/pool/failover/Strategy.d.ts.map +1 -0
- package/dist/pool/failover/Strategy.js +2 -0
- package/dist/pool/failover/Strategy.js.map +1 -0
- package/dist/pool/index.d.ts +8 -0
- package/dist/pool/index.d.ts.map +1 -0
- package/dist/pool/index.js +4 -0
- package/dist/pool/index.js.map +1 -0
- package/dist/pool/queue/QueueAdapter.d.ts +31 -0
- package/dist/pool/queue/QueueAdapter.d.ts.map +1 -0
- package/dist/pool/queue/QueueAdapter.js +2 -0
- package/dist/pool/queue/QueueAdapter.js.map +1 -0
- package/dist/pool/queue/adapters/memory.d.ts +21 -0
- package/dist/pool/queue/adapters/memory.d.ts.map +1 -0
- package/dist/pool/queue/adapters/memory.js +96 -0
- package/dist/pool/queue/adapters/memory.js.map +1 -0
- package/dist/pool/types/events.d.ts +75 -0
- package/dist/pool/types/events.d.ts.map +1 -0
- package/dist/pool/types/events.js +2 -0
- package/dist/pool/types/events.js.map +1 -0
- package/dist/pool/types/job.d.ts +56 -0
- package/dist/pool/types/job.d.ts.map +1 -0
- package/dist/pool/types/job.js +2 -0
- package/dist/pool/types/job.js.map +1 -0
- package/dist/pool/utils/clone.d.ts +2 -0
- package/dist/pool/utils/clone.d.ts.map +1 -0
- package/dist/pool/utils/clone.js +7 -0
- package/dist/pool/utils/clone.js.map +1 -0
- package/dist/pool/utils/hash.d.ts +5 -0
- package/dist/pool/utils/hash.d.ts.map +1 -0
- package/dist/pool/utils/hash.js +19 -0
- package/dist/pool/utils/hash.js.map +1 -0
- package/dist/types/event.d.ts +3 -2
- package/dist/types/event.d.ts.map +1 -1
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.js +2 -1
- package/dist/workflow.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -452,50 +452,56 @@ Changing outputs later? Re‑generate the type after adding the new `.output()`
|
|
|
452
452
|
|
|
453
453
|
## Multi-Instance Pool
|
|
454
454
|
|
|
455
|
-
|
|
455
|
+
The SDK ships two pooling layers:
|
|
456
456
|
|
|
457
|
-
|
|
457
|
+
- **`WorkflowPool` (new, recommended)** – Manages its own queue (pluggable adapters), emits per-job events with consistent job ids, and handles smart failover / retry without depending on the ComfyUI server queue depth. Ideal for multi-tenant services or when integrating with Redis/BullMQ/RabbitMQ backends.
|
|
458
|
+
- **`ComfyPool` (legacy)** – Weighted, in-memory scheduler that delegates most coordination to the ComfyUI queue. Useful for lightweight scripts or when you need backwards compatibility with earlier SDK versions.
|
|
458
459
|
|
|
459
|
-
|
|
460
|
-
| ---- | ---- | -------- | ----------- |
|
|
461
|
-
| Pick zero queue | `EQueueMode.PICK_ZERO` (default) | Choose any online client whose reported `queue_remaining` is 0 (prefers idle machines). Locks a client until it emits an execution event. | Co‑existence with the ComfyUI web UI where queue spikes are common. |
|
|
462
|
-
| Lowest queue | `EQueueMode.PICK_LOWEST` | Choose the online client with the smallest `queue_remaining` (may still be busy). | High throughput batch ingestion; keeps all nodes saturated. |
|
|
463
|
-
| Round‑robin | `EQueueMode.PICK_ROUTINE` | Simple rotation through available online clients irrespective of queue depth. | Latency balancing; predictable distribution. |
|
|
464
|
-
|
|
465
|
-
### Basic Example
|
|
460
|
+
### WorkflowPool Snapshot
|
|
466
461
|
|
|
467
462
|
```ts
|
|
468
|
-
import { ComfyApi,
|
|
469
|
-
import
|
|
470
|
-
// ... pool basic example content (see earlier dedicated Workflow section for high-level abstraction)
|
|
471
|
-
```
|
|
463
|
+
import { ComfyApi, WorkflowPool, MemoryQueueAdapter } from "comfyui-node";
|
|
464
|
+
import WorkflowJson from "./example-txt2img-workflow.json";
|
|
472
465
|
|
|
473
|
-
|
|
466
|
+
const clients = [
|
|
467
|
+
new ComfyApi("http://localhost:8188"),
|
|
468
|
+
new ComfyApi("http://localhost:8189")
|
|
469
|
+
];
|
|
474
470
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
471
|
+
const pool = new WorkflowPool(clients, {
|
|
472
|
+
queueAdapter: new MemoryQueueAdapter()
|
|
473
|
+
});
|
|
478
474
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
]);
|
|
475
|
+
pool.on("job:progress", (ev) => {
|
|
476
|
+
console.log(`job ${ev.detail.jobId} -> ${ev.detail.progress.value}/${ev.detail.progress.max}`);
|
|
477
|
+
});
|
|
483
478
|
|
|
484
|
-
|
|
485
|
-
.
|
|
486
|
-
|
|
479
|
+
pool.on("client:blocked_workflow", (ev) => {
|
|
480
|
+
console.warn(`client ${ev.detail.clientId} cooling off for workflow ${ev.detail.workflowHash.slice(0, 8)}`);
|
|
481
|
+
});
|
|
487
482
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
483
|
+
const jobId = await pool.enqueue(WorkflowJson, {
|
|
484
|
+
metadata: { tenant: "alpha" },
|
|
485
|
+
includeOutputs: ["9"],
|
|
486
|
+
priority: 10
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
console.log("queued", jobId);
|
|
492
490
|
```
|
|
493
491
|
|
|
494
|
-
|
|
492
|
+
See `docs/workflow-pool.md` for full API and event reference.
|
|
495
493
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
494
|
+
### Legacy Pool (`ComfyPool`)
|
|
495
|
+
|
|
496
|
+
The legacy `ComfyPool` is a simpler, in-memory scheduler that relies on the server's queue depth for load balancing.
|
|
497
|
+
|
|
498
|
+
#### ComfyPool Modes
|
|
499
|
+
|
|
500
|
+
| Mode | Enum | Behavior | When to use |
|
|
501
|
+
| ---- | ---- | -------- | ----------- |
|
|
502
|
+
| Pick zero queue | `EQueueMode.PICK_ZERO` (default) | Choose any online client whose reported `queue_remaining` is 0 (prefers idle machines). Locks a client until it emits an execution event. | Co-existence with the ComfyUI web UI where queue spikes are common. |
|
|
503
|
+
| Lowest queue | `EQueueMode.PICK_LOWEST` | Choose the online client with the smallest `queue_remaining` (may still be busy). | High throughput batch ingestion; keeps all nodes saturated. |
|
|
504
|
+
| Round-robin | `EQueueMode.PICK_ROUTINE` | Simple rotation through available online clients irrespective of queue depth. | Latency balancing; predictable distribution. |
|
|
499
505
|
|
|
500
506
|
---
|
|
501
507
|
|
|
@@ -1102,7 +1108,7 @@ If you only need generation progress & previews you do NOT need the Crystools ex
|
|
|
1102
1108
|
|
|
1103
1109
|
## Examples
|
|
1104
1110
|
|
|
1105
|
-
See the `examples` directory for text
|
|
1111
|
+
See the `examples` directory for text-to-image, image-to-image, upscaling and pool orchestration patterns. For an end-to-end WorkflowPool + WebSocket demo, open `demos/recursive-edit/` and run the recursive image editing server + web client.
|
|
1106
1112
|
|
|
1107
1113
|
## Errors & Diagnostics
|
|
1108
1114
|
|