n8n-nodes-comfyui-all 2.4.1 → 2.4.2
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/dist/nodes/ComfyUiTool/ComfyUiTool.node.d.ts +59 -34
- package/dist/nodes/ComfyUiTool/ComfyUiTool.node.d.ts.map +1 -1
- package/dist/nodes/ComfyUiTool/ComfyUiTool.node.js +122 -146
- package/dist/nodes/ComfyUiTool/ComfyUiTool.node.js.map +1 -1
- package/dist/nodes/agentToolHelpers.d.ts +32 -51
- package/dist/nodes/agentToolHelpers.d.ts.map +1 -1
- package/dist/nodes/agentToolHelpers.js +57 -183
- package/dist/nodes/agentToolHelpers.js.map +1 -1
- package/dist/nodes/types.d.ts +0 -38
- package/dist/nodes/types.d.ts.map +1 -1
- package/dist/nodes/workflowConfig.d.ts +27 -13
- package/dist/nodes/workflowConfig.d.ts.map +1 -1
- package/dist/nodes/workflowConfig.js +57 -148
- package/dist/nodes/workflowConfig.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ComfyUI Tool -
|
|
2
|
+
* ComfyUI Tool - Simplified workflow execution node for AI Agents
|
|
3
3
|
*
|
|
4
|
-
* This
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* This is a simplified node designed for AI Agent usage. It executes
|
|
5
|
+
* ComfyUI workflows provided by the user without making assumptions
|
|
6
|
+
* about workflow structure or node types.
|
|
7
7
|
*/
|
|
8
8
|
import { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
9
9
|
export declare class ComfyUiTool {
|
|
@@ -28,22 +28,13 @@ export declare class ComfyUiTool {
|
|
|
28
28
|
subtitle: string;
|
|
29
29
|
notes: string[];
|
|
30
30
|
inputSample: {
|
|
31
|
-
|
|
31
|
+
workflowJson: string;
|
|
32
32
|
};
|
|
33
33
|
outputSample: {
|
|
34
34
|
json: {
|
|
35
35
|
success: boolean;
|
|
36
36
|
imageCount: number;
|
|
37
37
|
imageUrls: string[];
|
|
38
|
-
prompt: string;
|
|
39
|
-
mode: string;
|
|
40
|
-
parameters: {
|
|
41
|
-
width: number;
|
|
42
|
-
height: number;
|
|
43
|
-
steps: number;
|
|
44
|
-
cfg: number;
|
|
45
|
-
seed: number;
|
|
46
|
-
};
|
|
47
38
|
};
|
|
48
39
|
};
|
|
49
40
|
properties: ({
|
|
@@ -53,9 +44,26 @@ export declare class ComfyUiTool {
|
|
|
53
44
|
required: boolean;
|
|
54
45
|
default: string;
|
|
55
46
|
description: string;
|
|
47
|
+
typeOptions?: undefined;
|
|
48
|
+
placeholder?: undefined;
|
|
49
|
+
hint?: undefined;
|
|
50
|
+
minValue?: undefined;
|
|
51
|
+
maxValue?: undefined;
|
|
52
|
+
options?: undefined;
|
|
53
|
+
} | {
|
|
54
|
+
displayName: string;
|
|
55
|
+
name: string;
|
|
56
|
+
type: string;
|
|
57
|
+
typeOptions: {
|
|
58
|
+
rows: number;
|
|
59
|
+
};
|
|
60
|
+
required: boolean;
|
|
61
|
+
default: string;
|
|
62
|
+
description: string;
|
|
63
|
+
placeholder: string;
|
|
64
|
+
hint: string;
|
|
56
65
|
minValue?: undefined;
|
|
57
66
|
maxValue?: undefined;
|
|
58
|
-
placeholder?: undefined;
|
|
59
67
|
options?: undefined;
|
|
60
68
|
} | {
|
|
61
69
|
displayName: string;
|
|
@@ -66,7 +74,9 @@ export declare class ComfyUiTool {
|
|
|
66
74
|
minValue: number;
|
|
67
75
|
maxValue: number;
|
|
68
76
|
required?: undefined;
|
|
77
|
+
typeOptions?: undefined;
|
|
69
78
|
placeholder?: undefined;
|
|
79
|
+
hint?: undefined;
|
|
70
80
|
options?: undefined;
|
|
71
81
|
} | {
|
|
72
82
|
displayName: string;
|
|
@@ -76,6 +86,8 @@ export declare class ComfyUiTool {
|
|
|
76
86
|
description: string;
|
|
77
87
|
placeholder: string;
|
|
78
88
|
required?: undefined;
|
|
89
|
+
typeOptions?: undefined;
|
|
90
|
+
hint?: undefined;
|
|
79
91
|
minValue?: undefined;
|
|
80
92
|
maxValue?: undefined;
|
|
81
93
|
options?: undefined;
|
|
@@ -85,29 +97,42 @@ export declare class ComfyUiTool {
|
|
|
85
97
|
type: string;
|
|
86
98
|
placeholder: string;
|
|
87
99
|
default: {};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
name: string;
|
|
91
|
-
type: string;
|
|
92
|
-
typeOptions: {
|
|
93
|
-
rows: number;
|
|
94
|
-
};
|
|
95
|
-
default: string;
|
|
96
|
-
description: string;
|
|
97
|
-
minValue?: undefined;
|
|
98
|
-
maxValue?: undefined;
|
|
99
|
-
} | {
|
|
100
|
+
description: string;
|
|
101
|
+
options: {
|
|
100
102
|
displayName: string;
|
|
101
103
|
name: string;
|
|
102
104
|
type: string;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
placeholder: string;
|
|
106
|
+
default: {};
|
|
107
|
+
options: ({
|
|
108
|
+
displayName: string;
|
|
109
|
+
name: string;
|
|
110
|
+
type: string;
|
|
111
|
+
default: string;
|
|
112
|
+
description: string;
|
|
113
|
+
placeholder: string;
|
|
114
|
+
required?: undefined;
|
|
115
|
+
} | {
|
|
116
|
+
displayName: string;
|
|
117
|
+
name: string;
|
|
118
|
+
type: string;
|
|
119
|
+
required: boolean;
|
|
120
|
+
default: string;
|
|
121
|
+
description: string;
|
|
122
|
+
placeholder: string;
|
|
123
|
+
} | {
|
|
124
|
+
displayName: string;
|
|
125
|
+
name: string;
|
|
126
|
+
type: string;
|
|
127
|
+
default: string;
|
|
128
|
+
description: string;
|
|
129
|
+
placeholder?: undefined;
|
|
130
|
+
required?: undefined;
|
|
131
|
+
})[];
|
|
132
|
+
}[];
|
|
109
133
|
required?: undefined;
|
|
110
|
-
|
|
134
|
+
typeOptions?: undefined;
|
|
135
|
+
hint?: undefined;
|
|
111
136
|
minValue?: undefined;
|
|
112
137
|
maxValue?: undefined;
|
|
113
138
|
})[];
|
|
@@ -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;AActB,qBAAa,WAAW;IACtB;;OAEG;IACH,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAmHT;IAEF;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;CAsJxE"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* ComfyUI Tool -
|
|
3
|
+
* ComfyUI Tool - Simplified workflow execution node for AI Agents
|
|
4
4
|
*
|
|
5
|
-
* This
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* This is a simplified node designed for AI Agent usage. It executes
|
|
6
|
+
* ComfyUI workflows provided by the user without making assumptions
|
|
7
|
+
* about workflow structure or node types.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.ComfyUiTool = void 0;
|
|
@@ -27,38 +27,28 @@ class ComfyUiTool {
|
|
|
27
27
|
group: ['transform'],
|
|
28
28
|
version: [1],
|
|
29
29
|
defaultVersion: 1,
|
|
30
|
-
description: '
|
|
30
|
+
description: 'Execute ComfyUI workflows. Requires a workflow JSON exported from ComfyUI.',
|
|
31
31
|
defaults: {
|
|
32
32
|
name: 'ComfyUI Tool',
|
|
33
33
|
},
|
|
34
34
|
usableAsTool: true,
|
|
35
35
|
inputs: ['main'],
|
|
36
36
|
outputs: ['main'],
|
|
37
|
-
subtitle: '
|
|
37
|
+
subtitle: 'ComfyUI Workflow Executor',
|
|
38
38
|
notes: [
|
|
39
|
-
'
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'
|
|
43
|
-
'Examples: "A beautiful sunset, size:1024x768, steps:30"',
|
|
39
|
+
'You must provide a ComfyUI workflow JSON (API Format)',
|
|
40
|
+
'In ComfyUI: Design your workflow → Click "Save (API Format)" → Copy JSON → Paste here',
|
|
41
|
+
'Works with ANY ComfyUI workflow: text-to-image, image-to-image, video generation, etc.',
|
|
42
|
+
'Configure parameters directly in your workflow JSON or use parameter overrides',
|
|
44
43
|
],
|
|
45
44
|
inputSample: {
|
|
46
|
-
|
|
45
|
+
workflowJson: '{ "3": { "inputs": {}, "class_type": "KSampler" } }',
|
|
47
46
|
},
|
|
48
47
|
outputSample: {
|
|
49
48
|
json: {
|
|
50
49
|
success: true,
|
|
51
50
|
imageCount: 1,
|
|
52
51
|
imageUrls: ['http://127.0.0.1:8188/view?filename=ComfyUI_00001.png'],
|
|
53
|
-
prompt: 'A beautiful landscape painting',
|
|
54
|
-
mode: 'text-to-image',
|
|
55
|
-
parameters: {
|
|
56
|
-
width: 512,
|
|
57
|
-
height: 512,
|
|
58
|
-
steps: 20,
|
|
59
|
-
cfg: 8,
|
|
60
|
-
seed: 123456789,
|
|
61
|
-
},
|
|
62
52
|
},
|
|
63
53
|
},
|
|
64
54
|
properties: [
|
|
@@ -70,75 +60,76 @@ class ComfyUiTool {
|
|
|
70
60
|
default: 'http://127.0.0.1:8188',
|
|
71
61
|
description: 'URL of ComfyUI server',
|
|
72
62
|
},
|
|
63
|
+
{
|
|
64
|
+
displayName: 'Workflow JSON',
|
|
65
|
+
name: 'workflowJson',
|
|
66
|
+
type: 'string',
|
|
67
|
+
typeOptions: {
|
|
68
|
+
rows: 20,
|
|
69
|
+
},
|
|
70
|
+
required: true,
|
|
71
|
+
default: '',
|
|
72
|
+
description: 'Paste your ComfyUI workflow JSON (API Format). Required field - no built-in templates.',
|
|
73
|
+
placeholder: 'Paste your ComfyUI workflow JSON (API Format) here...\n\n{\n "3": {\n "inputs": {\n "seed": 123456789,\n ...\n },\n "class_type": "KSampler"\n }\n}',
|
|
74
|
+
hint: 'Required: Export your workflow from ComfyUI in API format and paste it here.',
|
|
75
|
+
},
|
|
73
76
|
{
|
|
74
77
|
displayName: 'Timeout (Seconds)',
|
|
75
78
|
name: 'timeout',
|
|
76
79
|
type: 'number',
|
|
77
|
-
default:
|
|
78
|
-
description: 'Maximum time to wait for
|
|
80
|
+
default: 300,
|
|
81
|
+
description: 'Maximum time to wait for workflow execution (in seconds). Default: 300 (5 minutes).',
|
|
79
82
|
minValue: 10,
|
|
80
|
-
maxValue:
|
|
83
|
+
maxValue: 3600,
|
|
81
84
|
},
|
|
82
85
|
{
|
|
83
|
-
displayName: '
|
|
84
|
-
name: '
|
|
86
|
+
displayName: 'Load Image Node ID',
|
|
87
|
+
name: 'loadImageNodeId',
|
|
85
88
|
type: 'string',
|
|
86
|
-
default: '
|
|
87
|
-
description: '
|
|
88
|
-
placeholder: '
|
|
89
|
+
default: '',
|
|
90
|
+
description: 'Optional: Node ID of LoadImage node if your workflow uses input images. Leave empty if not using image input.',
|
|
91
|
+
placeholder: 'e.g., 5, 12, load_image_1',
|
|
89
92
|
},
|
|
90
93
|
{
|
|
91
|
-
displayName: '
|
|
92
|
-
name: '
|
|
93
|
-
type: '
|
|
94
|
-
placeholder: 'Add
|
|
94
|
+
displayName: 'Parameter Overrides',
|
|
95
|
+
name: 'parameterOverrides',
|
|
96
|
+
type: 'fixedCollection',
|
|
97
|
+
placeholder: 'Add Parameter Override',
|
|
95
98
|
default: {},
|
|
99
|
+
description: 'Override specific node parameters at runtime. Useful for dynamic values from input data.',
|
|
96
100
|
options: [
|
|
97
101
|
{
|
|
98
|
-
displayName: '
|
|
99
|
-
name: '
|
|
100
|
-
type: '
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
default: 20,
|
|
130
|
-
description: 'Default sampling steps when not specified in query',
|
|
131
|
-
minValue: 1,
|
|
132
|
-
maxValue: 150,
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
displayName: 'Default Width',
|
|
136
|
-
name: 'defaultWidth',
|
|
137
|
-
type: 'number',
|
|
138
|
-
default: 512,
|
|
139
|
-
description: 'Default image width when not specified in query',
|
|
140
|
-
minValue: 64,
|
|
141
|
-
maxValue: 4096,
|
|
102
|
+
displayName: 'Parameter Override',
|
|
103
|
+
name: 'parameterOverride',
|
|
104
|
+
type: 'collection',
|
|
105
|
+
placeholder: 'Add Override',
|
|
106
|
+
default: {},
|
|
107
|
+
options: [
|
|
108
|
+
{
|
|
109
|
+
displayName: 'Node ID',
|
|
110
|
+
name: 'nodeId',
|
|
111
|
+
type: 'string',
|
|
112
|
+
default: '',
|
|
113
|
+
description: 'The node ID to update (e.g., "3", "6", "15")',
|
|
114
|
+
placeholder: 'Node ID from workflow JSON',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
displayName: 'Parameter Path',
|
|
118
|
+
name: 'paramPath',
|
|
119
|
+
type: 'string',
|
|
120
|
+
required: true,
|
|
121
|
+
default: '',
|
|
122
|
+
description: 'Path to the parameter (e.g., "inputs.text", "inputs.seed", "inputs.steps")',
|
|
123
|
+
placeholder: 'inputs.parameter_name',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
displayName: 'Value',
|
|
127
|
+
name: 'value',
|
|
128
|
+
type: 'string',
|
|
129
|
+
default: '',
|
|
130
|
+
description: 'The new value. Can be a static value or an expression (e.g., "{{ $JSON.prompt }}").',
|
|
131
|
+
},
|
|
132
|
+
],
|
|
142
133
|
},
|
|
143
134
|
],
|
|
144
135
|
},
|
|
@@ -152,58 +143,34 @@ class ComfyUiTool {
|
|
|
152
143
|
const logger = (0, logger_1.createLogger)(this.logger);
|
|
153
144
|
// Get node parameters
|
|
154
145
|
const comfyUiUrl = this.getNodeParameter('comfyUiUrl', 0);
|
|
146
|
+
const workflowJson = this.getNodeParameter('workflowJson', 0);
|
|
155
147
|
const timeout = this.getNodeParameter('timeout', 0);
|
|
156
|
-
const
|
|
157
|
-
const
|
|
158
|
-
const { customWorkflow = '', defaultWidth = 512, defaultHeight = 512, defaultSteps = 20, defaultCfg = 8, } = advancedOptions || {};
|
|
148
|
+
const loadImageNodeId = this.getNodeParameter('loadImageNodeId', 0);
|
|
149
|
+
const parameterOverrides = this.getNodeParameter('parameterOverrides', 0);
|
|
159
150
|
// Validate URL
|
|
160
151
|
if (!(0, validation_1.validateUrl)(comfyUiUrl)) {
|
|
161
152
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid ComfyUI URL. Must be a valid HTTP/HTTPS URL.');
|
|
162
153
|
}
|
|
154
|
+
// Parse and validate workflow
|
|
155
|
+
let workflow;
|
|
156
|
+
try {
|
|
157
|
+
workflow = (0, workflowConfig_1.parseWorkflow)(workflowJson);
|
|
158
|
+
const validation = (0, validation_1.validateComfyUIWorkflow)(workflowJson);
|
|
159
|
+
if (!validation.valid && validation.error) {
|
|
160
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid workflow: ${validation.error}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
if (error instanceof n8n_workflow_1.NodeOperationError) {
|
|
165
|
+
throw error;
|
|
166
|
+
}
|
|
167
|
+
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)}`);
|
|
168
|
+
}
|
|
169
|
+
logger.info('Processing ComfyUI workflow execution request', { comfyUiUrl, timeout });
|
|
163
170
|
// Get input data
|
|
164
171
|
const inputData = this.getInputData();
|
|
165
|
-
if (!inputData || inputData.length === 0) {
|
|
166
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No input data provided. Please provide a query text.');
|
|
167
|
-
}
|
|
168
|
-
// Check if input contains binary image data
|
|
169
172
|
const hasInputImage = (0, agentToolHelpers_1.hasBinaryData)(inputData);
|
|
170
173
|
let uploadedImageFilename = null;
|
|
171
|
-
// Get query from input
|
|
172
|
-
const firstItem = inputData[0];
|
|
173
|
-
const query = firstItem.json.query ||
|
|
174
|
-
firstItem.json.text ||
|
|
175
|
-
firstItem.json.prompt ||
|
|
176
|
-
'';
|
|
177
|
-
if (!query || query.trim().length === 0) {
|
|
178
|
-
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.');
|
|
179
|
-
}
|
|
180
|
-
// Determine mode based on input
|
|
181
|
-
const mode = hasInputImage ? 'image-to-image' : 'text-to-image';
|
|
182
|
-
logger.info('Processing image generation request', { query, comfyUiUrl, timeout, mode });
|
|
183
|
-
// Parse the query to extract parameters
|
|
184
|
-
const params = (0, agentToolHelpers_1.parseInput)(query, {
|
|
185
|
-
negativePrompt: defaultNegativePrompt,
|
|
186
|
-
width: defaultWidth,
|
|
187
|
-
height: defaultHeight,
|
|
188
|
-
steps: defaultSteps,
|
|
189
|
-
cfg: defaultCfg,
|
|
190
|
-
});
|
|
191
|
-
logger.debug('Parsed parameters', {
|
|
192
|
-
prompt: params.prompt,
|
|
193
|
-
width: params.width,
|
|
194
|
-
height: params.height,
|
|
195
|
-
steps: params.steps,
|
|
196
|
-
cfg: params.cfg,
|
|
197
|
-
seed: params.seed,
|
|
198
|
-
});
|
|
199
|
-
// Get workflow template
|
|
200
|
-
let workflowTemplate;
|
|
201
|
-
if (customWorkflow && customWorkflow.trim().length > 0) {
|
|
202
|
-
workflowTemplate = (0, validation_1.safeJsonParse)(customWorkflow, 'Custom workflow JSON');
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
workflowTemplate = (0, workflowConfig_1.getWorkflowTemplate)({ mode });
|
|
206
|
-
}
|
|
207
174
|
// Create ComfyUI client
|
|
208
175
|
const client = new ComfyUiClient_1.ComfyUIClient({
|
|
209
176
|
baseUrl: comfyUiUrl,
|
|
@@ -212,9 +179,8 @@ class ComfyUiTool {
|
|
|
212
179
|
logger,
|
|
213
180
|
});
|
|
214
181
|
try {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
if (hasInputImage) {
|
|
182
|
+
// If input contains image and LoadImage node ID is specified, upload it
|
|
183
|
+
if (hasInputImage && loadImageNodeId) {
|
|
218
184
|
const binaryKey = (0, agentToolHelpers_1.getFirstBinaryKey)(inputData);
|
|
219
185
|
if (!binaryKey) {
|
|
220
186
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Binary data found but no binary key detected.');
|
|
@@ -226,51 +192,61 @@ class ComfyUiTool {
|
|
|
226
192
|
logger.info('Uploading input image to ComfyUI', {
|
|
227
193
|
fileName: binaryData.fileName,
|
|
228
194
|
mimeType: binaryData.mimeType,
|
|
195
|
+
nodeId: loadImageNodeId,
|
|
229
196
|
});
|
|
230
197
|
// Convert base64 to buffer
|
|
231
198
|
const buffer = Buffer.from(binaryData.data, 'base64');
|
|
232
199
|
// Upload image to ComfyUI
|
|
233
200
|
uploadedImageFilename = await client.uploadImage(buffer, binaryData.fileName || 'input_image.png');
|
|
234
201
|
logger.info('Successfully uploaded input image', { filename: uploadedImageFilename });
|
|
202
|
+
// Update workflow with uploaded image filename
|
|
203
|
+
workflow = (0, agentToolHelpers_1.updateNodeParameter)(workflow, loadImageNodeId, 'inputs.image', uploadedImageFilename);
|
|
235
204
|
}
|
|
236
|
-
//
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
205
|
+
// Apply parameter overrides if provided
|
|
206
|
+
if (parameterOverrides?.parameterOverride && parameterOverrides.parameterOverride.length > 0) {
|
|
207
|
+
logger.info('Applying parameter overrides', {
|
|
208
|
+
count: parameterOverrides.parameterOverride.length,
|
|
209
|
+
});
|
|
210
|
+
for (const override of parameterOverrides.parameterOverride) {
|
|
211
|
+
const { nodeId, paramPath, value } = override;
|
|
212
|
+
// Evaluate expressions if needed
|
|
213
|
+
let evaluatedValue = value;
|
|
214
|
+
if (value && value.includes('{{') && value.includes('}}')) {
|
|
215
|
+
try {
|
|
216
|
+
evaluatedValue = this.evaluateExpression(value, 0);
|
|
217
|
+
logger.debug('Evaluated expression', { nodeId, paramPath, result: evaluatedValue });
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
logger.warn(`Failed to evaluate expression for ${nodeId}.${paramPath}, using raw value`, { error });
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
workflow = (0, agentToolHelpers_1.updateNodeParameter)(workflow, nodeId, paramPath, evaluatedValue);
|
|
224
|
+
logger.debug('Applied parameter override', { nodeId, paramPath, value: evaluatedValue });
|
|
225
|
+
}
|
|
241
226
|
}
|
|
227
|
+
logger.info('Starting ComfyUI workflow execution');
|
|
242
228
|
// Execute workflow
|
|
243
229
|
const result = await client.executeWorkflow(workflow);
|
|
244
230
|
if (!result.success) {
|
|
245
231
|
logger.error('Workflow execution failed', result.error);
|
|
246
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to
|
|
232
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to execute workflow: ${result.error}`);
|
|
247
233
|
}
|
|
248
|
-
//
|
|
234
|
+
// Build URLs
|
|
249
235
|
const imageUrls = result.images ? result.images.map(img => `${comfyUiUrl}${img}`) : [];
|
|
250
236
|
const videoUrls = result.videos ? result.videos.map(vid => `${comfyUiUrl}${vid}`) : [];
|
|
251
|
-
const
|
|
237
|
+
const outputJson = {
|
|
252
238
|
success: true,
|
|
253
239
|
imageUrls,
|
|
254
240
|
videoUrls,
|
|
255
241
|
imageCount: result.images?.length || 0,
|
|
256
242
|
videoCount: result.videos?.length || 0,
|
|
257
|
-
prompt: params.prompt,
|
|
258
|
-
mode: mode,
|
|
259
|
-
parameters: {
|
|
260
|
-
width: params.width,
|
|
261
|
-
height: params.height,
|
|
262
|
-
steps: params.steps,
|
|
263
|
-
cfg: params.cfg,
|
|
264
|
-
seed: params.seed,
|
|
265
|
-
negative_prompt: params.negative_prompt,
|
|
266
|
-
},
|
|
267
243
|
};
|
|
268
|
-
logger.info('
|
|
269
|
-
imageCount:
|
|
270
|
-
|
|
244
|
+
logger.info('Workflow execution completed successfully', {
|
|
245
|
+
imageCount: outputJson.imageCount,
|
|
246
|
+
videoCount: outputJson.videoCount,
|
|
271
247
|
});
|
|
272
|
-
// Return result (no binary data for AI Agent)
|
|
273
|
-
return [this.helpers.constructExecutionMetaData([{ json:
|
|
248
|
+
// Return result (no binary data for AI Agent - URLs only)
|
|
249
|
+
return [this.helpers.constructExecutionMetaData([{ json: outputJson }], { itemData: { item: 0 } })];
|
|
274
250
|
}
|
|
275
251
|
catch (error) {
|
|
276
252
|
logger.error('Error during workflow execution', error);
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"ComfyUiTool.node.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