n8n-nodes-comfyui-all 2.4.3 → 2.4.5
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 +4 -2
- package/dist/nodes/ComfyUiTool/ComfyUiTool.node.d.ts.map +1 -1
- package/dist/nodes/ComfyUiTool/ComfyUiTool.node.js +52 -64
- package/dist/nodes/ComfyUiTool/ComfyUiTool.node.js.map +1 -1
- package/package.json +1 -1
- package/dist/nodes/ComfyUiTool.node.d.ts +0 -125
- package/dist/nodes/ComfyUiTool.node.d.ts.map +0 -1
- package/dist/nodes/ComfyUiTool.node.js +0 -265
- package/dist/nodes/ComfyUiTool.node.js.map +0 -1
package/README.md
CHANGED
|
@@ -9,9 +9,11 @@
|
|
|
9
9
|
- 🎨 **Universal Workflow Support** - Works with any ComfyUI workflow in API format
|
|
10
10
|
- 🔄 **Dynamic Parameters** - Override workflow parameters dynamically
|
|
11
11
|
- 🎬 **Multi-Modal Support** - Supports images and videos for both input and output
|
|
12
|
-
- 🤖 **AI Agent Ready** -
|
|
12
|
+
- 🤖 **AI Agent Ready** - Two specialized nodes for different use cases:
|
|
13
|
+
- **ComfyUI Tool** - Optimized for AI Agent workflows (URL-based image input)
|
|
14
|
+
- **ComfyUI** - Full-featured node for standard workflows (binary & URL support)
|
|
13
15
|
- 📊 **Flexible Configuration** - JSON mode or single parameter mode
|
|
14
|
-
- 🔗 **
|
|
16
|
+
- 🔗 **Multiple Image Input Methods** - URL, binary data
|
|
15
17
|
- 🏷️ **Customizable Output** - Customize binary output property names
|
|
16
18
|
|
|
17
19
|
## 📦 Installation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComfyUiTool.node.d.ts","sourceRoot":"","sources":["../../../nodes/ComfyUiTool/ComfyUiTool.node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAEnB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"ComfyUiTool.node.d.ts","sourceRoot":"","sources":["../../../nodes/ComfyUiTool/ComfyUiTool.node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAEnB,MAAM,cAAc,CAAC;AAWtB,qBAAa,WAAW;IACtB;;OAEG;IACH,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2HT;IAEF;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;CA6MxE"}
|
|
@@ -124,12 +124,12 @@ class ComfyUiTool {
|
|
|
124
124
|
placeholder: 'e.g., 5, 12, load_image_1',
|
|
125
125
|
},
|
|
126
126
|
{
|
|
127
|
-
displayName: 'Image
|
|
128
|
-
name: '
|
|
127
|
+
displayName: 'Image URL',
|
|
128
|
+
name: 'imageUrl',
|
|
129
129
|
type: 'string',
|
|
130
130
|
default: '',
|
|
131
|
-
description: 'Optional:
|
|
132
|
-
placeholder: '
|
|
131
|
+
description: 'Optional: URL of the image to process. Use this when passing images from AI Agents. The node will download and upload the image to ComfyUI.',
|
|
132
|
+
placeholder: 'https://example.com/image.png',
|
|
133
133
|
},
|
|
134
134
|
{
|
|
135
135
|
displayName: 'Parameter Overrides',
|
|
@@ -187,7 +187,7 @@ class ComfyUiTool {
|
|
|
187
187
|
const workflowJson = this.getNodeParameter('workflowJson', 0);
|
|
188
188
|
const timeout = this.getNodeParameter('timeout', 0);
|
|
189
189
|
const loadImageNodeId = this.getNodeParameter('loadImageNodeId', 0);
|
|
190
|
-
const
|
|
190
|
+
const imageUrl = this.getNodeParameter('imageUrl', 0);
|
|
191
191
|
const parameterOverrides = this.getNodeParameter('parameterOverrides', 0);
|
|
192
192
|
// Validate URL
|
|
193
193
|
if (!(0, validation_1.validateUrl)(comfyUiUrl)) {
|
|
@@ -209,9 +209,6 @@ class ComfyUiTool {
|
|
|
209
209
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to parse workflow JSON. Please ensure it is valid ComfyUI API format.\nError: ${error instanceof Error ? error.message : String(error)}`);
|
|
210
210
|
}
|
|
211
211
|
logger.info('Processing ComfyUI workflow execution request', { comfyUiUrl, timeout });
|
|
212
|
-
// Get input data
|
|
213
|
-
const inputData = this.getInputData();
|
|
214
|
-
const hasInputImage = (0, agentToolHelpers_1.hasBinaryData)(inputData);
|
|
215
212
|
let uploadedImageFilename = null;
|
|
216
213
|
// Create ComfyUI client
|
|
217
214
|
const client = new ComfyUiClient_1.ComfyUIClient({
|
|
@@ -221,75 +218,66 @@ class ComfyUiTool {
|
|
|
221
218
|
logger,
|
|
222
219
|
});
|
|
223
220
|
try {
|
|
224
|
-
//
|
|
225
|
-
if (
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
221
|
+
// Handle image URL (for AI Agents)
|
|
222
|
+
if (imageUrl && loadImageNodeId) {
|
|
223
|
+
logger.info('Downloading image from URL', { url: imageUrl, nodeId: loadImageNodeId });
|
|
224
|
+
// Validate URL
|
|
225
|
+
const { validateUrl } = await Promise.resolve().then(() => __importStar(require('../validation')));
|
|
226
|
+
if (!validateUrl(imageUrl)) {
|
|
227
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid image URL "${imageUrl}". Must be a valid HTTP/HTTPS URL.`);
|
|
229
228
|
}
|
|
230
|
-
const binaryData = (0, agentToolHelpers_1.extractBinaryData)(inputData, binaryKey);
|
|
231
|
-
if (!binaryData) {
|
|
232
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to extract binary data from key "${binaryKey}".`);
|
|
233
|
-
}
|
|
234
|
-
logger.info('Uploading input image to ComfyUI', {
|
|
235
|
-
fileName: binaryData.fileName,
|
|
236
|
-
mimeType: binaryData.mimeType,
|
|
237
|
-
nodeId: loadImageNodeId,
|
|
238
|
-
});
|
|
239
|
-
// Convert base64 to buffer
|
|
240
|
-
const buffer = Buffer.from(binaryData.data, 'base64');
|
|
241
|
-
// Upload image to ComfyUI
|
|
242
|
-
uploadedImageFilename = await client.uploadImage(buffer, binaryData.fileName || 'input_image.png');
|
|
243
|
-
logger.info('Successfully uploaded input image', { filename: uploadedImageFilename });
|
|
244
|
-
// Update workflow with uploaded image filename
|
|
245
|
-
workflow = (0, agentToolHelpers_1.updateNodeParameter)(workflow, loadImageNodeId, 'inputs.image', uploadedImageFilename);
|
|
246
|
-
}
|
|
247
|
-
else if (imageData && loadImageNodeId) {
|
|
248
|
-
// Handle image data passed as base64 string or file path (for AI Agents)
|
|
249
|
-
logger.info('Processing image data from parameter', { dataLength: imageData.length, nodeId: loadImageNodeId });
|
|
250
229
|
let buffer;
|
|
251
230
|
let filename;
|
|
252
|
-
|
|
253
|
-
//
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
231
|
+
try {
|
|
232
|
+
// Download image using n8n's httpRequest
|
|
233
|
+
const imageResponse = await this.helpers.httpRequest({
|
|
234
|
+
method: 'GET',
|
|
235
|
+
url: imageUrl,
|
|
236
|
+
encoding: 'arraybuffer',
|
|
237
|
+
timeout: timeout * 1000,
|
|
238
|
+
});
|
|
239
|
+
if (!imageResponse || !Buffer.isBuffer(imageResponse)) {
|
|
240
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to download image from URL "${imageUrl}". The server did not return valid image data.`);
|
|
257
241
|
}
|
|
258
|
-
buffer = Buffer.from(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
else if (imageData.startsWith('/') || imageData.startsWith('./') || imageData.startsWith('../')) {
|
|
264
|
-
// File path
|
|
265
|
-
const fs = await Promise.resolve().then(() => __importStar(require('fs/promises')));
|
|
242
|
+
buffer = Buffer.from(imageResponse);
|
|
243
|
+
if (buffer.length === 0) {
|
|
244
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Downloaded image from URL "${imageUrl}" is empty.`);
|
|
245
|
+
}
|
|
246
|
+
// Extract filename from URL
|
|
266
247
|
try {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
248
|
+
const urlObj = new URL(imageUrl);
|
|
249
|
+
const pathname = urlObj.pathname;
|
|
250
|
+
filename = pathname.split('/').pop() || 'agent_image.png';
|
|
251
|
+
// Ensure filename has extension
|
|
252
|
+
if (!filename.includes('.')) {
|
|
253
|
+
filename = 'agent_image.png';
|
|
254
|
+
}
|
|
270
255
|
}
|
|
271
|
-
catch
|
|
272
|
-
|
|
256
|
+
catch {
|
|
257
|
+
filename = 'agent_image.png';
|
|
273
258
|
}
|
|
259
|
+
logger.info('Successfully downloaded image', {
|
|
260
|
+
url: imageUrl,
|
|
261
|
+
size: buffer.length,
|
|
262
|
+
filename
|
|
263
|
+
});
|
|
274
264
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
buffer = Buffer.from(imageData, 'base64');
|
|
279
|
-
filename = 'agent_image.png';
|
|
280
|
-
logger.info('Decoded image from base64 string', { size: buffer.length });
|
|
265
|
+
catch (error) {
|
|
266
|
+
if (error instanceof n8n_workflow_1.NodeOperationError) {
|
|
267
|
+
throw error;
|
|
281
268
|
}
|
|
282
|
-
|
|
283
|
-
|
|
269
|
+
const httpError = error;
|
|
270
|
+
const statusCode = httpError.response?.statusCode;
|
|
271
|
+
const statusMessage = httpError.response?.statusMessage;
|
|
272
|
+
let errorMessage = `Failed to download image from URL "${imageUrl}"`;
|
|
273
|
+
if (statusCode) {
|
|
274
|
+
errorMessage += ` (HTTP ${statusCode} ${statusMessage || ''})`;
|
|
284
275
|
}
|
|
285
|
-
|
|
286
|
-
// Validate buffer
|
|
287
|
-
if (!buffer || buffer.length === 0) {
|
|
288
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Decoded image data is empty. Please check the image data.');
|
|
276
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|
|
289
277
|
}
|
|
290
278
|
// Upload image to ComfyUI
|
|
291
279
|
uploadedImageFilename = await client.uploadImage(buffer, filename);
|
|
292
|
-
logger.info('Successfully uploaded image
|
|
280
|
+
logger.info('Successfully uploaded image to ComfyUI', { filename: uploadedImageFilename });
|
|
293
281
|
// Update workflow with uploaded image filename
|
|
294
282
|
workflow = (0, agentToolHelpers_1.updateNodeParameter)(workflow, loadImageNodeId, 'inputs.image', uploadedImageFilename);
|
|
295
283
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComfyUiTool.node.js","sourceRoot":"","sources":["../../../nodes/ComfyUiTool/ComfyUiTool.node.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+CAIsB;AAEtB,oDAAiD;AACjD,8CAAqE;AAErE,sCAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"ComfyUiTool.node.js","sourceRoot":"","sources":["../../../nodes/ComfyUiTool/ComfyUiTool.node.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+CAIsB;AAEtB,oDAAiD;AACjD,8CAAqE;AAErE,sCAAyC;AACzC,0DAE6B;AAC7B,sDAAkD;AAElD,MAAa,WAAW;IAAxB;QACE;;WAEG;QACH,gBAAW,GAAG;YACZ,WAAW,EAAE,cAAc;YAC3B,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE,kBAAkB;YACxB,SAAS,EAAE,SAAS;YACpB,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC,CAAC,CAAC;YACZ,cAAc,EAAE,CAAC;YACjB,WAAW,EAAE,4EAA4E;YACzF,QAAQ,EAAE;gBACR,IAAI,EAAE,cAAc;aACrB;YACD,YAAY,EAAE,IAAI;YAClB,MAAM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O,EAAE,IAAI;gBACb,SAAS;gBACT,SAAS;gBACT,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;gBACtC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;aACvC,CAAC;YAEF,MAAM,CAAC,IAAI,CAAC,2CAA2C,EAAE;gBACvD,UAAU,EAAE,UAAU,CAAC,UAAU;gBACjC,UAAU,EAAE,UAAU,CAAC,UAAU;aAClC,CAAC,CAAC;YAEH,0DAA0D;YAC1D,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,0BAA0B,CAC7C,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,EACtB,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAC1B,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;YACvD,MAAM,KAAK,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;CACF;AAjVD,kCAiVC"}
|
package/package.json
CHANGED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ComfyUI Tool - AI Agent-friendly image generation node
|
|
3
|
-
*
|
|
4
|
-
* This node is designed to be used as an AI Agent tool with minimal configuration.
|
|
5
|
-
* It accepts a simple text query and automatically generates images using ComfyUI.
|
|
6
|
-
*/
|
|
7
|
-
import { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
8
|
-
export declare class ComfyUiTool {
|
|
9
|
-
/**
|
|
10
|
-
* Node description for n8n
|
|
11
|
-
*/
|
|
12
|
-
description: {
|
|
13
|
-
displayName: string;
|
|
14
|
-
name: string;
|
|
15
|
-
icon: string;
|
|
16
|
-
iconColor: string;
|
|
17
|
-
group: string[];
|
|
18
|
-
version: number[];
|
|
19
|
-
defaultVersion: number;
|
|
20
|
-
description: string;
|
|
21
|
-
defaults: {
|
|
22
|
-
name: string;
|
|
23
|
-
};
|
|
24
|
-
usableAsTool: boolean;
|
|
25
|
-
inputs: string[];
|
|
26
|
-
outputs: string[];
|
|
27
|
-
subtitle: string;
|
|
28
|
-
notes: string[];
|
|
29
|
-
inputSample: {
|
|
30
|
-
query: string;
|
|
31
|
-
};
|
|
32
|
-
outputSample: {
|
|
33
|
-
json: {
|
|
34
|
-
success: boolean;
|
|
35
|
-
imageCount: number;
|
|
36
|
-
imageUrls: string[];
|
|
37
|
-
prompt: string;
|
|
38
|
-
parameters: {
|
|
39
|
-
width: number;
|
|
40
|
-
height: number;
|
|
41
|
-
steps: number;
|
|
42
|
-
cfg: number;
|
|
43
|
-
seed: number;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
binary: {
|
|
47
|
-
data: {
|
|
48
|
-
data: string;
|
|
49
|
-
mimeType: string;
|
|
50
|
-
fileName: string;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
properties: ({
|
|
55
|
-
displayName: string;
|
|
56
|
-
name: string;
|
|
57
|
-
type: string;
|
|
58
|
-
required: boolean;
|
|
59
|
-
default: string;
|
|
60
|
-
description: string;
|
|
61
|
-
minValue?: undefined;
|
|
62
|
-
maxValue?: undefined;
|
|
63
|
-
placeholder?: undefined;
|
|
64
|
-
options?: undefined;
|
|
65
|
-
} | {
|
|
66
|
-
displayName: string;
|
|
67
|
-
name: string;
|
|
68
|
-
type: string;
|
|
69
|
-
default: number;
|
|
70
|
-
description: string;
|
|
71
|
-
minValue: number;
|
|
72
|
-
maxValue: number;
|
|
73
|
-
required?: undefined;
|
|
74
|
-
placeholder?: undefined;
|
|
75
|
-
options?: undefined;
|
|
76
|
-
} | {
|
|
77
|
-
displayName: string;
|
|
78
|
-
name: string;
|
|
79
|
-
type: string;
|
|
80
|
-
default: string;
|
|
81
|
-
description: string;
|
|
82
|
-
placeholder: string;
|
|
83
|
-
required?: undefined;
|
|
84
|
-
minValue?: undefined;
|
|
85
|
-
maxValue?: undefined;
|
|
86
|
-
options?: undefined;
|
|
87
|
-
} | {
|
|
88
|
-
displayName: string;
|
|
89
|
-
name: string;
|
|
90
|
-
type: string;
|
|
91
|
-
placeholder: string;
|
|
92
|
-
default: {};
|
|
93
|
-
options: ({
|
|
94
|
-
displayName: string;
|
|
95
|
-
name: string;
|
|
96
|
-
type: string;
|
|
97
|
-
typeOptions: {
|
|
98
|
-
rows: number;
|
|
99
|
-
};
|
|
100
|
-
default: string;
|
|
101
|
-
description: string;
|
|
102
|
-
minValue?: undefined;
|
|
103
|
-
maxValue?: undefined;
|
|
104
|
-
} | {
|
|
105
|
-
displayName: string;
|
|
106
|
-
name: string;
|
|
107
|
-
type: string;
|
|
108
|
-
default: number;
|
|
109
|
-
description: string;
|
|
110
|
-
minValue: number;
|
|
111
|
-
maxValue: number;
|
|
112
|
-
typeOptions?: undefined;
|
|
113
|
-
})[];
|
|
114
|
-
required?: undefined;
|
|
115
|
-
description?: undefined;
|
|
116
|
-
minValue?: undefined;
|
|
117
|
-
maxValue?: undefined;
|
|
118
|
-
})[];
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Execute function - called when the node runs
|
|
122
|
-
*/
|
|
123
|
-
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
124
|
-
}
|
|
125
|
-
//# sourceMappingURL=ComfyUiTool.node.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ComfyUiTool.node.d.ts","sourceRoot":"","sources":["../../nodes/ComfyUiTool.node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAEnB,MAAM,cAAc,CAAC;AAStB,qBAAa,WAAW;IACtB;;OAEG;IACH,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAyIT;IAEF;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;CAyIxE"}
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ComfyUI Tool - AI Agent-friendly image generation node
|
|
4
|
-
*
|
|
5
|
-
* This node is designed to be used as an AI Agent tool with minimal configuration.
|
|
6
|
-
* It accepts a simple text query and automatically generates images using ComfyUI.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.ComfyUiTool = void 0;
|
|
10
|
-
const n8n_workflow_1 = require("n8n-workflow");
|
|
11
|
-
const ComfyUiClient_1 = require("./ComfyUiClient");
|
|
12
|
-
const validation_1 = require("./validation");
|
|
13
|
-
const logger_1 = require("./logger");
|
|
14
|
-
const agentToolHelpers_1 = require("./agentToolHelpers");
|
|
15
|
-
const workflowConfig_1 = require("./workflowConfig");
|
|
16
|
-
class ComfyUiTool {
|
|
17
|
-
constructor() {
|
|
18
|
-
/**
|
|
19
|
-
* Node description for n8n
|
|
20
|
-
*/
|
|
21
|
-
this.description = {
|
|
22
|
-
displayName: 'ComfyUI Tool',
|
|
23
|
-
name: 'comfyUiTool',
|
|
24
|
-
icon: 'file:comfyui.svg',
|
|
25
|
-
iconColor: '#77C157',
|
|
26
|
-
group: ['transform'],
|
|
27
|
-
version: [1],
|
|
28
|
-
defaultVersion: 1,
|
|
29
|
-
description: 'AI-friendly image generation tool. Simply describe what you want to create.',
|
|
30
|
-
defaults: {
|
|
31
|
-
name: 'ComfyUI Tool',
|
|
32
|
-
},
|
|
33
|
-
usableAsTool: true,
|
|
34
|
-
inputs: ['main'],
|
|
35
|
-
outputs: ['main'],
|
|
36
|
-
subtitle: 'AI Image Generator',
|
|
37
|
-
notes: [
|
|
38
|
-
'Optimized for AI Agent usage',
|
|
39
|
-
'Automatically parses natural language queries',
|
|
40
|
-
'Supports size, steps, cfg, seed, and negative prompt parameters',
|
|
41
|
-
'Example: "A beautiful sunset, size:1024x768, steps:30"',
|
|
42
|
-
],
|
|
43
|
-
inputSample: {
|
|
44
|
-
query: 'A beautiful landscape painting',
|
|
45
|
-
},
|
|
46
|
-
outputSample: {
|
|
47
|
-
json: {
|
|
48
|
-
success: true,
|
|
49
|
-
imageCount: 1,
|
|
50
|
-
imageUrls: ['http://127.0.0.1:8188/view?filename=ComfyUI_00001.png'],
|
|
51
|
-
prompt: 'A beautiful landscape painting',
|
|
52
|
-
parameters: {
|
|
53
|
-
width: 512,
|
|
54
|
-
height: 512,
|
|
55
|
-
steps: 20,
|
|
56
|
-
cfg: 8,
|
|
57
|
-
seed: 123456789,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
binary: {
|
|
61
|
-
data: {
|
|
62
|
-
data: 'base64_encoded_image_data',
|
|
63
|
-
mimeType: 'image/png',
|
|
64
|
-
fileName: 'ComfyUI_00001.png',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
properties: [
|
|
69
|
-
{
|
|
70
|
-
displayName: 'ComfyUI URL',
|
|
71
|
-
name: 'comfyUiUrl',
|
|
72
|
-
type: 'string',
|
|
73
|
-
required: true,
|
|
74
|
-
default: 'http://127.0.0.1:8188',
|
|
75
|
-
description: 'URL of ComfyUI server',
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
displayName: 'Timeout (Seconds)',
|
|
79
|
-
name: 'timeout',
|
|
80
|
-
type: 'number',
|
|
81
|
-
default: 120,
|
|
82
|
-
description: 'Maximum time to wait for image generation (in seconds). Default: 120 (2 minutes).',
|
|
83
|
-
minValue: 10,
|
|
84
|
-
maxValue: 600,
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
displayName: 'Output Binary Key',
|
|
88
|
-
name: 'outputBinaryKey',
|
|
89
|
-
type: 'string',
|
|
90
|
-
default: 'data',
|
|
91
|
-
description: 'Property name for the output binary data (e.g., "data", "image", "output")',
|
|
92
|
-
placeholder: 'data',
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
displayName: 'Default Negative Prompt',
|
|
96
|
-
name: 'defaultNegativePrompt',
|
|
97
|
-
type: 'string',
|
|
98
|
-
default: 'ugly, blurry, low quality, distorted',
|
|
99
|
-
description: 'Default negative prompt to use when not specified in query',
|
|
100
|
-
placeholder: 'ugly, blurry, low quality',
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
displayName: 'Advanced Options',
|
|
104
|
-
name: 'advancedOptions',
|
|
105
|
-
type: 'collection',
|
|
106
|
-
placeholder: 'Add Option',
|
|
107
|
-
default: {},
|
|
108
|
-
options: [
|
|
109
|
-
{
|
|
110
|
-
displayName: 'Custom Workflow JSON',
|
|
111
|
-
name: 'customWorkflow',
|
|
112
|
-
type: 'string',
|
|
113
|
-
typeOptions: {
|
|
114
|
-
rows: 20,
|
|
115
|
-
},
|
|
116
|
-
default: '',
|
|
117
|
-
description: 'Optional: Custom ComfyUI workflow JSON (API Format). If empty, uses default workflow. Only use this if you want to override the default template.',
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
displayName: 'Default Width',
|
|
121
|
-
name: 'defaultWidth',
|
|
122
|
-
type: 'number',
|
|
123
|
-
default: 512,
|
|
124
|
-
description: 'Default image width when not specified in query',
|
|
125
|
-
minValue: 64,
|
|
126
|
-
maxValue: 4096,
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
displayName: 'Default Height',
|
|
130
|
-
name: 'defaultHeight',
|
|
131
|
-
type: 'number',
|
|
132
|
-
default: 512,
|
|
133
|
-
description: 'Default image height when not specified in query',
|
|
134
|
-
minValue: 64,
|
|
135
|
-
maxValue: 4096,
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
displayName: 'Default Steps',
|
|
139
|
-
name: 'defaultSteps',
|
|
140
|
-
type: 'number',
|
|
141
|
-
default: 20,
|
|
142
|
-
description: 'Default sampling steps when not specified in query',
|
|
143
|
-
minValue: 1,
|
|
144
|
-
maxValue: 150,
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
displayName: 'Default CFG',
|
|
148
|
-
name: 'defaultCfg',
|
|
149
|
-
type: 'number',
|
|
150
|
-
default: 8,
|
|
151
|
-
description: 'Default CFG scale when not specified in query',
|
|
152
|
-
minValue: 1,
|
|
153
|
-
maxValue: 30,
|
|
154
|
-
},
|
|
155
|
-
],
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Execute function - called when the node runs
|
|
162
|
-
*/
|
|
163
|
-
async execute() {
|
|
164
|
-
const logger = (0, logger_1.createLogger)(this.logger);
|
|
165
|
-
// Get node parameters
|
|
166
|
-
const comfyUiUrl = this.getNodeParameter('comfyUiUrl', 0);
|
|
167
|
-
const timeout = this.getNodeParameter('timeout', 0);
|
|
168
|
-
const outputBinaryKey = this.getNodeParameter('outputBinaryKey', 0);
|
|
169
|
-
const defaultNegativePrompt = this.getNodeParameter('defaultNegativePrompt', 0);
|
|
170
|
-
const advancedOptions = this.getNodeParameter('advancedOptions', 0);
|
|
171
|
-
const { customWorkflow = '', defaultWidth = 512, defaultHeight = 512, defaultSteps = 20, defaultCfg = 8, } = advancedOptions || {};
|
|
172
|
-
// Validate URL
|
|
173
|
-
if (!(0, validation_1.validateUrl)(comfyUiUrl)) {
|
|
174
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid ComfyUI URL. Must be a valid HTTP/HTTPS URL.');
|
|
175
|
-
}
|
|
176
|
-
// Validate output binary key
|
|
177
|
-
(0, validation_1.validateOutputBinaryKey)(outputBinaryKey);
|
|
178
|
-
// Get input data
|
|
179
|
-
const inputData = this.getInputData();
|
|
180
|
-
if (!inputData || inputData.length === 0) {
|
|
181
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No input data provided. Please provide a query text.');
|
|
182
|
-
}
|
|
183
|
-
// Get query from input
|
|
184
|
-
const firstItem = inputData[0];
|
|
185
|
-
const query = firstItem.json.query ||
|
|
186
|
-
firstItem.json.text ||
|
|
187
|
-
firstItem.json.prompt ||
|
|
188
|
-
'';
|
|
189
|
-
if (!query || query.trim().length === 0) {
|
|
190
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No query found in input. Please provide a "query", "text", or "prompt" field with a description of the image you want to generate.');
|
|
191
|
-
}
|
|
192
|
-
logger.info('Processing image generation request', { query, comfyUiUrl, timeout });
|
|
193
|
-
// Parse the query to extract parameters
|
|
194
|
-
const params = (0, agentToolHelpers_1.parseInput)(query, {
|
|
195
|
-
negativePrompt: defaultNegativePrompt,
|
|
196
|
-
width: defaultWidth,
|
|
197
|
-
height: defaultHeight,
|
|
198
|
-
steps: defaultSteps,
|
|
199
|
-
cfg: defaultCfg,
|
|
200
|
-
});
|
|
201
|
-
logger.debug('Parsed parameters', {
|
|
202
|
-
prompt: params.prompt,
|
|
203
|
-
width: params.width,
|
|
204
|
-
height: params.height,
|
|
205
|
-
steps: params.steps,
|
|
206
|
-
cfg: params.cfg,
|
|
207
|
-
seed: params.seed,
|
|
208
|
-
});
|
|
209
|
-
// Get workflow template
|
|
210
|
-
let workflowTemplate;
|
|
211
|
-
if (customWorkflow && customWorkflow.trim().length > 0) {
|
|
212
|
-
workflowTemplate = (0, validation_1.safeJsonParse)(customWorkflow, 'Custom workflow JSON');
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
workflowTemplate = (0, workflowConfig_1.getWorkflowTemplate)();
|
|
216
|
-
}
|
|
217
|
-
// Update workflow with parsed parameters
|
|
218
|
-
const workflow = (0, agentToolHelpers_1.updateWorkflow)(workflowTemplate, params);
|
|
219
|
-
// Create ComfyUI client
|
|
220
|
-
const client = new ComfyUiClient_1.ComfyUIClient({
|
|
221
|
-
baseUrl: comfyUiUrl,
|
|
222
|
-
timeout: timeout * 1000,
|
|
223
|
-
helpers: this.helpers,
|
|
224
|
-
logger,
|
|
225
|
-
});
|
|
226
|
-
try {
|
|
227
|
-
logger.info('Starting ComfyUI workflow execution');
|
|
228
|
-
// Execute workflow
|
|
229
|
-
const result = await client.executeWorkflow(workflow);
|
|
230
|
-
if (!result.success) {
|
|
231
|
-
logger.error('Workflow execution failed', result.error);
|
|
232
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to generate image: ${result.error}`);
|
|
233
|
-
}
|
|
234
|
-
// Process results
|
|
235
|
-
const { json, binary } = await client.processResults(result, outputBinaryKey);
|
|
236
|
-
// Add metadata to JSON output
|
|
237
|
-
const enhancedJson = {
|
|
238
|
-
...json,
|
|
239
|
-
prompt: params.prompt,
|
|
240
|
-
parameters: {
|
|
241
|
-
width: params.width,
|
|
242
|
-
height: params.height,
|
|
243
|
-
steps: params.steps,
|
|
244
|
-
cfg: params.cfg,
|
|
245
|
-
seed: params.seed,
|
|
246
|
-
negative_prompt: params.negative_prompt,
|
|
247
|
-
},
|
|
248
|
-
};
|
|
249
|
-
logger.info('Image generation completed successfully', {
|
|
250
|
-
imageCount: json.imageCount,
|
|
251
|
-
});
|
|
252
|
-
return [this.helpers.constructExecutionMetaData([{ json: enhancedJson, binary }], { itemData: { item: 0 } })];
|
|
253
|
-
}
|
|
254
|
-
catch (error) {
|
|
255
|
-
logger.error('Error during workflow execution', error);
|
|
256
|
-
throw error;
|
|
257
|
-
}
|
|
258
|
-
finally {
|
|
259
|
-
client.destroy();
|
|
260
|
-
logger.debug('Client destroyed');
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
exports.ComfyUiTool = ComfyUiTool;
|
|
265
|
-
//# sourceMappingURL=ComfyUiTool.node.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ComfyUiTool.node.js","sourceRo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