n8n-nodes-comfyui-all 2.3.15 → 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/ComfyUi/ComfyUi.node.d.ts +78 -69
- package/dist/nodes/ComfyUi/ComfyUi.node.d.ts.map +1 -1
- package/dist/nodes/ComfyUi/ComfyUi.node.js +116 -252
- package/dist/nodes/ComfyUi/ComfyUi.node.js.map +1 -1
- package/dist/nodes/ComfyUiTool/ComfyUiTool.node.d.ts +66 -80
- package/dist/nodes/ComfyUiTool/ComfyUiTool.node.d.ts.map +1 -1
- package/dist/nodes/ComfyUiTool/ComfyUiTool.node.js +125 -286
- package/dist/nodes/ComfyUiTool/ComfyUiTool.node.js.map +1 -1
- package/dist/nodes/agentToolHelpers.d.ts +24 -60
- package/dist/nodes/agentToolHelpers.d.ts.map +1 -1
- package/dist/nodes/agentToolHelpers.js +42 -263
- package/dist/nodes/agentToolHelpers.js.map +1 -1
- package/dist/nodes/parameterProcessor.d.ts.map +1 -1
- package/dist/nodes/parameterProcessor.js +23 -56
- package/dist/nodes/parameterProcessor.js.map +1 -1
- package/dist/nodes/types.d.ts +0 -40
- package/dist/nodes/types.d.ts.map +1 -1
- package/dist/nodes/validation.d.ts +0 -10
- package/dist/nodes/validation.d.ts.map +1 -1
- package/dist/nodes/validation.js +0 -81
- package/dist/nodes/validation.js.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,59 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent Tool Helpers - Utility functions for AI Agent-friendly ComfyUI nodes
|
|
3
3
|
*
|
|
4
|
-
* This file contains helper functions for
|
|
5
|
-
*
|
|
4
|
+
* This file contains helper functions for handling binary data and
|
|
5
|
+
* generic workflow parameter updates, without making assumptions about
|
|
6
|
+
* specific ComfyUI node types.
|
|
6
7
|
*/
|
|
7
8
|
import type { INodeExecutionData } from 'n8n-workflow';
|
|
8
|
-
import { Workflow,
|
|
9
|
-
export declare const DEFAULT_NEGATIVE_PROMPT = "ugly, blurry, low quality, distorted";
|
|
10
|
-
export declare const DEFAULT_WIDTH = 512;
|
|
11
|
-
export declare const DEFAULT_HEIGHT = 512;
|
|
12
|
-
export declare const DEFAULT_STEPS = 20;
|
|
13
|
-
export declare const DEFAULT_CFG = 8;
|
|
14
|
-
export declare const MAX_SEED_VALUE = 2147483647;
|
|
15
|
-
export declare const PARAM_PATTERNS: Record<string, ParameterPattern>;
|
|
16
|
-
/**
|
|
17
|
-
* Extract parameter from query
|
|
18
|
-
* @param query - User query text
|
|
19
|
-
* @param pattern - Parameter pattern configuration
|
|
20
|
-
* @returns Extracted parameter and cleaned query
|
|
21
|
-
*/
|
|
22
|
-
export declare function extractParameter(query: string, pattern: ParameterPattern): ParameterExtractionResult;
|
|
23
|
-
/**
|
|
24
|
-
* Parse user input to extract image generation parameters
|
|
25
|
-
* @param query - User query text
|
|
26
|
-
* @param defaults - Default parameter values
|
|
27
|
-
* @returns Parsed parameters object
|
|
28
|
-
*/
|
|
29
|
-
export declare function parseInput(query: string, defaults?: {
|
|
30
|
-
negativePrompt?: string;
|
|
31
|
-
width?: number;
|
|
32
|
-
height?: number;
|
|
33
|
-
steps?: number;
|
|
34
|
-
cfg?: number;
|
|
35
|
-
}): ParsedParameters;
|
|
36
|
-
/**
|
|
37
|
-
* Find node ID by node type
|
|
38
|
-
* @param workflow - Workflow object
|
|
39
|
-
* @param classType - Node type
|
|
40
|
-
* @returns Node ID or null
|
|
41
|
-
*/
|
|
42
|
-
export declare function findNodeByClassType(workflow: Workflow, classType: string): string | null;
|
|
43
|
-
/**
|
|
44
|
-
* Update workflow parameters
|
|
45
|
-
* @param workflow - ComfyUI workflow object
|
|
46
|
-
* @param params - Parameters object
|
|
47
|
-
* @returns Updated workflow
|
|
48
|
-
*/
|
|
49
|
-
export declare function updateWorkflow(workflow: Workflow, params: ParsedParameters): Workflow;
|
|
50
|
-
/**
|
|
51
|
-
* Update workflow with uploaded image filename
|
|
52
|
-
* @param workflow - ComfyUI workflow object
|
|
53
|
-
* @param imageFilename - Uploaded image filename
|
|
54
|
-
* @returns Updated workflow
|
|
55
|
-
*/
|
|
56
|
-
export declare function updateWorkflowWithImage(workflow: Workflow, imageFilename: string): Workflow;
|
|
9
|
+
import type { Workflow, BinaryData } from './types';
|
|
57
10
|
/**
|
|
58
11
|
* Extract binary data from input data
|
|
59
12
|
* @param inputData - Input data from n8n
|
|
@@ -74,20 +27,31 @@ export declare function hasBinaryData(inputData: INodeExecutionData[]): boolean;
|
|
|
74
27
|
*/
|
|
75
28
|
export declare function getFirstBinaryKey(inputData: INodeExecutionData[]): string | null;
|
|
76
29
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
30
|
+
* Update a specific node's parameter in a workflow
|
|
31
|
+
* @param workflow - ComfyUI workflow object
|
|
32
|
+
* @param nodeId - The ID of the node to update
|
|
33
|
+
* @param paramPath - The path to the parameter (e.g., 'inputs.text', 'inputs.seed')
|
|
34
|
+
* @param value - The new value
|
|
35
|
+
* @returns Updated workflow (new object, original is not mutated)
|
|
36
|
+
*/
|
|
37
|
+
export declare function updateNodeParameter(workflow: Workflow, nodeId: string, paramPath: string, value: unknown): Workflow;
|
|
38
|
+
/**
|
|
39
|
+
* Update multiple node parameters at once
|
|
79
40
|
* @param workflow - ComfyUI workflow object
|
|
80
|
-
* @param
|
|
41
|
+
* @param updates - Array of updates to apply
|
|
81
42
|
* @returns Updated workflow
|
|
82
43
|
*/
|
|
83
|
-
export declare function
|
|
44
|
+
export declare function updateMultipleParameters(workflow: Workflow, updates: Array<{
|
|
45
|
+
nodeId: string;
|
|
46
|
+
paramPath: string;
|
|
47
|
+
value: unknown;
|
|
48
|
+
}>): Workflow;
|
|
84
49
|
/**
|
|
85
|
-
*
|
|
86
|
-
* Used by ComfyUiTool when user has configured which node/parameters AI can modify
|
|
50
|
+
* Set input image in a LoadImage node
|
|
87
51
|
* @param workflow - ComfyUI workflow object
|
|
88
|
-
* @param nodeId -
|
|
89
|
-
* @param
|
|
52
|
+
* @param nodeId - The ID of the LoadImage node
|
|
53
|
+
* @param imageFilename - The uploaded image filename
|
|
90
54
|
* @returns Updated workflow
|
|
91
55
|
*/
|
|
92
|
-
export declare function
|
|
56
|
+
export declare function setLoadImageNode(workflow: Workflow, nodeId: string, imageFilename: string): Workflow;
|
|
93
57
|
//# sourceMappingURL=agentToolHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentToolHelpers.d.ts","sourceRoot":"","sources":["../../nodes/agentToolHelpers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"agentToolHelpers.d.ts","sourceRoot":"","sources":["../../nodes/agentToolHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,EAAE,EAAE,SAAS,GAAE,MAAe,GAAG,UAAU,GAAG,IAAI,CAWhH;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAatE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,EAAE,GAAG,MAAM,GAAG,IAAI,CAYhF;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,OAAO,GACb,QAAQ,CAwBV;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,KAAK,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,GACpE,QAAQ,CAaV;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,GACpB,QAAQ,CAEV"}
|
|
@@ -2,200 +2,17 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Agent Tool Helpers - Utility functions for AI Agent-friendly ComfyUI nodes
|
|
4
4
|
*
|
|
5
|
-
* This file contains helper functions for
|
|
6
|
-
*
|
|
5
|
+
* This file contains helper functions for handling binary data and
|
|
6
|
+
* generic workflow parameter updates, without making assumptions about
|
|
7
|
+
* specific ComfyUI node types.
|
|
7
8
|
*/
|
|
8
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.PARAM_PATTERNS = exports.MAX_SEED_VALUE = exports.DEFAULT_CFG = exports.DEFAULT_STEPS = exports.DEFAULT_HEIGHT = exports.DEFAULT_WIDTH = exports.DEFAULT_NEGATIVE_PROMPT = void 0;
|
|
10
|
-
exports.extractParameter = extractParameter;
|
|
11
|
-
exports.parseInput = parseInput;
|
|
12
|
-
exports.findNodeByClassType = findNodeByClassType;
|
|
13
|
-
exports.updateWorkflow = updateWorkflow;
|
|
14
|
-
exports.updateWorkflowWithImage = updateWorkflowWithImage;
|
|
15
10
|
exports.extractBinaryData = extractBinaryData;
|
|
16
11
|
exports.hasBinaryData = hasBinaryData;
|
|
17
12
|
exports.getFirstBinaryKey = getFirstBinaryKey;
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
20
|
-
|
|
21
|
-
// Parameter default values
|
|
22
|
-
exports.DEFAULT_NEGATIVE_PROMPT = 'ugly, blurry, low quality, distorted';
|
|
23
|
-
exports.DEFAULT_WIDTH = 512;
|
|
24
|
-
exports.DEFAULT_HEIGHT = 512;
|
|
25
|
-
exports.DEFAULT_STEPS = 20;
|
|
26
|
-
exports.DEFAULT_CFG = 8;
|
|
27
|
-
// Maximum random seed value (32-bit signed integer max value)
|
|
28
|
-
exports.MAX_SEED_VALUE = 2147483647;
|
|
29
|
-
// Parameter extraction rules configuration
|
|
30
|
-
exports.PARAM_PATTERNS = {
|
|
31
|
-
negative: {
|
|
32
|
-
regex: /(?<=\s|,|,|^)negative:\s*([^\n]+)/i,
|
|
33
|
-
paramKey: 'negative_prompt',
|
|
34
|
-
parser: (match) => match[1].trim()
|
|
35
|
-
},
|
|
36
|
-
size: {
|
|
37
|
-
regex: /(?<=\s|,|,|^)size:\s*(\d+)x(\d+)/i,
|
|
38
|
-
paramKeys: ['width', 'height'],
|
|
39
|
-
parser: (match) => ({
|
|
40
|
-
width: parseInt(match[1]),
|
|
41
|
-
height: parseInt(match[2])
|
|
42
|
-
})
|
|
43
|
-
},
|
|
44
|
-
steps: {
|
|
45
|
-
regex: /(?<=\s|,|,|^)steps:\s*(\d+)/i,
|
|
46
|
-
paramKey: 'steps',
|
|
47
|
-
parser: (match) => parseInt(match[1])
|
|
48
|
-
},
|
|
49
|
-
cfg: {
|
|
50
|
-
regex: /(?<=\s|,|,|^)cfg:\s*([\d.]+)/i,
|
|
51
|
-
paramKey: 'cfg',
|
|
52
|
-
parser: (match) => parseFloat(match[1])
|
|
53
|
-
},
|
|
54
|
-
seed: {
|
|
55
|
-
regex: /(?<=\s|,|,|^)seed:\s*(\d+)/i,
|
|
56
|
-
paramKey: 'seed',
|
|
57
|
-
parser: (match) => parseInt(match[1])
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Extract parameter from query
|
|
62
|
-
* @param query - User query text
|
|
63
|
-
* @param pattern - Parameter pattern configuration
|
|
64
|
-
* @returns Extracted parameter and cleaned query
|
|
65
|
-
*/
|
|
66
|
-
function extractParameter(query, pattern) {
|
|
67
|
-
const match = query.match(pattern.regex);
|
|
68
|
-
if (!match) {
|
|
69
|
-
return { value: null, cleanedQuery: query };
|
|
70
|
-
}
|
|
71
|
-
const value = pattern.parser(match);
|
|
72
|
-
const cleanedQuery = query.replace(pattern.regex, '').trim();
|
|
73
|
-
return { value, cleanedQuery };
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Parse user input to extract image generation parameters
|
|
77
|
-
* @param query - User query text
|
|
78
|
-
* @param defaults - Default parameter values
|
|
79
|
-
* @returns Parsed parameters object
|
|
80
|
-
*/
|
|
81
|
-
function parseInput(query, defaults = {}) {
|
|
82
|
-
const params = {
|
|
83
|
-
prompt: '',
|
|
84
|
-
negative_prompt: defaults.negativePrompt || exports.DEFAULT_NEGATIVE_PROMPT,
|
|
85
|
-
width: defaults.width || exports.DEFAULT_WIDTH,
|
|
86
|
-
height: defaults.height || exports.DEFAULT_HEIGHT,
|
|
87
|
-
steps: defaults.steps || exports.DEFAULT_STEPS,
|
|
88
|
-
cfg: defaults.cfg || exports.DEFAULT_CFG,
|
|
89
|
-
seed: (0, crypto_1.randomInt)(0, exports.MAX_SEED_VALUE)
|
|
90
|
-
};
|
|
91
|
-
let currentQuery = query.trim();
|
|
92
|
-
// Handle empty query case
|
|
93
|
-
if (!currentQuery) {
|
|
94
|
-
currentQuery = 'A beautiful image'; // Default fallback prompt
|
|
95
|
-
}
|
|
96
|
-
// Extract parameters using patterns
|
|
97
|
-
for (const [, pattern] of Object.entries(exports.PARAM_PATTERNS)) {
|
|
98
|
-
const { value, cleanedQuery } = extractParameter(currentQuery, pattern);
|
|
99
|
-
if (value !== null) {
|
|
100
|
-
if (pattern.paramKeys) {
|
|
101
|
-
// Type guard: check if value is an object with keys
|
|
102
|
-
if (typeof value === 'object' && value !== null) {
|
|
103
|
-
const valueRecord = value;
|
|
104
|
-
const valueKeys = Object.keys(valueRecord);
|
|
105
|
-
pattern.paramKeys.forEach((key, index) => {
|
|
106
|
-
params[key] = valueRecord[valueKeys[index]];
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else if (pattern.paramKey) {
|
|
111
|
-
params[pattern.paramKey] = value;
|
|
112
|
-
}
|
|
113
|
-
currentQuery = cleanedQuery;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
// Clean up remaining parameter markers and extra punctuation
|
|
117
|
-
currentQuery = currentQuery
|
|
118
|
-
.replace(/,\s*,/g, ',') // Remove consecutive Chinese commas
|
|
119
|
-
.replace(/,\s*,/g, ',') // Remove consecutive English commas
|
|
120
|
-
.replace(/[,,]\s*[,,]/g, ' ') // Remove extra spaces between commas
|
|
121
|
-
.replace(/^\s*[,,]+/g, '') // Remove all leading commas
|
|
122
|
-
.replace(/[,,]+\s*$/g, '') // Remove all trailing commas
|
|
123
|
-
.trim();
|
|
124
|
-
params.prompt = currentQuery;
|
|
125
|
-
return params;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Find node ID by node type
|
|
129
|
-
* @param workflow - Workflow object
|
|
130
|
-
* @param classType - Node type
|
|
131
|
-
* @returns Node ID or null
|
|
132
|
-
*/
|
|
133
|
-
function findNodeByClassType(workflow, classType) {
|
|
134
|
-
for (const nodeId in workflow) {
|
|
135
|
-
if (workflow[nodeId] && workflow[nodeId].class_type === classType) {
|
|
136
|
-
return nodeId;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Update workflow parameters
|
|
143
|
-
* @param workflow - ComfyUI workflow object
|
|
144
|
-
* @param params - Parameters object
|
|
145
|
-
* @returns Updated workflow
|
|
146
|
-
*/
|
|
147
|
-
function updateWorkflow(workflow, params) {
|
|
148
|
-
const updatedWorkflow = JSON.parse(JSON.stringify(workflow));
|
|
149
|
-
// Find and update positive and negative prompt nodes
|
|
150
|
-
const clipTextEncodeNodes = [];
|
|
151
|
-
for (const nodeId in updatedWorkflow) {
|
|
152
|
-
if (updatedWorkflow[nodeId] && updatedWorkflow[nodeId].class_type === 'CLIPTextEncode') {
|
|
153
|
-
clipTextEncodeNodes.push(nodeId);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
if (clipTextEncodeNodes.length >= 1) {
|
|
157
|
-
updatedWorkflow[clipTextEncodeNodes[0]].inputs.text = params.prompt;
|
|
158
|
-
}
|
|
159
|
-
if (clipTextEncodeNodes.length >= 2) {
|
|
160
|
-
updatedWorkflow[clipTextEncodeNodes[1]].inputs.text = params.negative_prompt;
|
|
161
|
-
}
|
|
162
|
-
// Find and update image size node (for text-to-image)
|
|
163
|
-
const latentNodeId = findNodeByClassType(updatedWorkflow, 'EmptyLatentImage') ||
|
|
164
|
-
findNodeByClassType(updatedWorkflow, 'EmptySD3LatentImage');
|
|
165
|
-
if (latentNodeId && updatedWorkflow[latentNodeId].inputs) {
|
|
166
|
-
updatedWorkflow[latentNodeId].inputs.width = params.width;
|
|
167
|
-
updatedWorkflow[latentNodeId].inputs.height = params.height;
|
|
168
|
-
}
|
|
169
|
-
// Find and update sampling parameters node
|
|
170
|
-
const samplerNodeId = findNodeByClassType(updatedWorkflow, 'KSampler');
|
|
171
|
-
if (samplerNodeId && updatedWorkflow[samplerNodeId].inputs) {
|
|
172
|
-
updatedWorkflow[samplerNodeId].inputs.steps = params.steps;
|
|
173
|
-
updatedWorkflow[samplerNodeId].inputs.cfg = params.cfg;
|
|
174
|
-
updatedWorkflow[samplerNodeId].inputs.seed = params.seed;
|
|
175
|
-
}
|
|
176
|
-
// Find and update edit instruction node (for image editing workflows)
|
|
177
|
-
const primitiveNodeId = findNodeByClassType(updatedWorkflow, 'PrimitiveStringMultiline');
|
|
178
|
-
if (primitiveNodeId && updatedWorkflow[primitiveNodeId].inputs) {
|
|
179
|
-
updatedWorkflow[primitiveNodeId].inputs.value = params.prompt;
|
|
180
|
-
}
|
|
181
|
-
return updatedWorkflow;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Update workflow with uploaded image filename
|
|
185
|
-
* @param workflow - ComfyUI workflow object
|
|
186
|
-
* @param imageFilename - Uploaded image filename
|
|
187
|
-
* @returns Updated workflow
|
|
188
|
-
*/
|
|
189
|
-
function updateWorkflowWithImage(workflow, imageFilename) {
|
|
190
|
-
const updatedWorkflow = JSON.parse(JSON.stringify(workflow));
|
|
191
|
-
// Find LoadImage node and update the image filename
|
|
192
|
-
const loadImageNodeId = findNodeByClassType(updatedWorkflow, 'LoadImage');
|
|
193
|
-
if (loadImageNodeId && updatedWorkflow[loadImageNodeId].inputs) {
|
|
194
|
-
updatedWorkflow[loadImageNodeId].inputs.image = imageFilename;
|
|
195
|
-
updatedWorkflow[loadImageNodeId].inputs.upload = 'image';
|
|
196
|
-
}
|
|
197
|
-
return updatedWorkflow;
|
|
198
|
-
}
|
|
13
|
+
exports.updateNodeParameter = updateNodeParameter;
|
|
14
|
+
exports.updateMultipleParameters = updateMultipleParameters;
|
|
15
|
+
exports.setLoadImageNode = setLoadImageNode;
|
|
199
16
|
/**
|
|
200
17
|
* Extract binary data from input data
|
|
201
18
|
* @param inputData - Input data from n8n
|
|
@@ -246,92 +63,54 @@ function getFirstBinaryKey(inputData) {
|
|
|
246
63
|
return binaryKeys.length > 0 ? binaryKeys[0] : null;
|
|
247
64
|
}
|
|
248
65
|
/**
|
|
249
|
-
*
|
|
250
|
-
* Intelligently maps parameters to the correct nodes in the workflow
|
|
66
|
+
* Update a specific node's parameter in a workflow
|
|
251
67
|
* @param workflow - ComfyUI workflow object
|
|
252
|
-
* @param
|
|
253
|
-
* @
|
|
68
|
+
* @param nodeId - The ID of the node to update
|
|
69
|
+
* @param paramPath - The path to the parameter (e.g., 'inputs.text', 'inputs.seed')
|
|
70
|
+
* @param value - The new value
|
|
71
|
+
* @returns Updated workflow (new object, original is not mutated)
|
|
254
72
|
*/
|
|
255
|
-
function
|
|
73
|
+
function updateNodeParameter(workflow, nodeId, paramPath, value) {
|
|
74
|
+
// Deep clone to avoid mutating original
|
|
256
75
|
const updatedWorkflow = JSON.parse(JSON.stringify(workflow));
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
// EmptyLatentImage parameters
|
|
268
|
-
'width': ['EmptyLatentImage', 'EmptySD3LatentImage'],
|
|
269
|
-
'height': ['EmptyLatentImage', 'EmptySD3LatentImage'],
|
|
270
|
-
'batch_size': ['EmptyLatentImage', 'EmptySD3LatentImage'],
|
|
271
|
-
// CLIPTextEncode parameters (text)
|
|
272
|
-
'text': ['CLIPTextEncode'],
|
|
273
|
-
'prompt': ['CLIPTextEncode'],
|
|
274
|
-
// CheckpointLoader parameters
|
|
275
|
-
'ckpt_name': ['CheckpointLoaderSimple', 'CheckpointLoader'],
|
|
276
|
-
'model': ['CheckpointLoaderSimple', 'CheckpointLoader'],
|
|
277
|
-
// SaveImage parameters
|
|
278
|
-
'filename_prefix': ['SaveImage', 'SaveVideo', 'SaveAnimatedWEBP'],
|
|
279
|
-
};
|
|
280
|
-
// Apply each parameter to the appropriate node
|
|
281
|
-
for (const [paramName, paramValue] of Object.entries(params)) {
|
|
282
|
-
// Skip special parameters that are handled separately
|
|
283
|
-
if (['negative_prompt', 'negative', 'prompt'].includes(paramName)) {
|
|
284
|
-
continue;
|
|
285
|
-
}
|
|
286
|
-
// Find target node type for this parameter
|
|
287
|
-
const targetNodeTypes = parameterMapping[paramName.toLowerCase()];
|
|
288
|
-
if (targetNodeTypes) {
|
|
289
|
-
// Find the first node of the target type
|
|
290
|
-
for (const nodeId in updatedWorkflow) {
|
|
291
|
-
const node = updatedWorkflow[nodeId];
|
|
292
|
-
if (node && targetNodeTypes.includes(node.class_type)) {
|
|
293
|
-
// Apply the parameter
|
|
294
|
-
if (updatedWorkflow[nodeId].inputs) {
|
|
295
|
-
updatedWorkflow[nodeId].inputs[paramName] = paramValue;
|
|
296
|
-
break; // Only apply to the first matching node
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
else {
|
|
302
|
-
// Parameter not in mapping, try to find it by name in any node
|
|
303
|
-
for (const nodeId in updatedWorkflow) {
|
|
304
|
-
const node = updatedWorkflow[nodeId];
|
|
305
|
-
if (node && node.inputs && paramName in node.inputs) {
|
|
306
|
-
// Direct parameter match
|
|
307
|
-
updatedWorkflow[nodeId].inputs[paramName] = paramValue;
|
|
308
|
-
break; // Only apply to the first matching node
|
|
309
|
-
}
|
|
310
|
-
}
|
|
76
|
+
if (!updatedWorkflow[nodeId]) {
|
|
77
|
+
throw new Error(`Node "${nodeId}" not found in workflow`);
|
|
78
|
+
}
|
|
79
|
+
// Navigate the path and set the value
|
|
80
|
+
const pathParts = paramPath.split('.');
|
|
81
|
+
let current = updatedWorkflow[nodeId];
|
|
82
|
+
for (let i = 0; i < pathParts.length - 1; i++) {
|
|
83
|
+
const part = pathParts[i];
|
|
84
|
+
if (!(part in current)) {
|
|
85
|
+
throw new Error(`Path "${paramPath}" does not exist in node "${nodeId}"`);
|
|
311
86
|
}
|
|
87
|
+
current = current[part];
|
|
312
88
|
}
|
|
89
|
+
const lastPart = pathParts[pathParts.length - 1];
|
|
90
|
+
current[lastPart] = value;
|
|
313
91
|
return updatedWorkflow;
|
|
314
92
|
}
|
|
315
93
|
/**
|
|
316
|
-
*
|
|
317
|
-
* Used by ComfyUiTool when user has configured which node/parameters AI can modify
|
|
94
|
+
* Update multiple node parameters at once
|
|
318
95
|
* @param workflow - ComfyUI workflow object
|
|
319
|
-
* @param
|
|
320
|
-
* @param params - Parameters to apply
|
|
96
|
+
* @param updates - Array of updates to apply
|
|
321
97
|
* @returns Updated workflow
|
|
322
98
|
*/
|
|
323
|
-
function
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
}
|
|
328
|
-
if (!updatedWorkflow[nodeId].inputs) {
|
|
329
|
-
updatedWorkflow[nodeId].inputs = {};
|
|
330
|
-
}
|
|
331
|
-
// Apply each parameter directly to the specified node
|
|
332
|
-
for (const [paramName, paramValue] of Object.entries(params)) {
|
|
333
|
-
updatedWorkflow[nodeId].inputs[paramName] = paramValue;
|
|
99
|
+
function updateMultipleParameters(workflow, updates) {
|
|
100
|
+
let updatedWorkflow = workflow;
|
|
101
|
+
for (const update of updates) {
|
|
102
|
+
updatedWorkflow = updateNodeParameter(updatedWorkflow, update.nodeId, update.paramPath, update.value);
|
|
334
103
|
}
|
|
335
104
|
return updatedWorkflow;
|
|
336
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Set input image in a LoadImage node
|
|
108
|
+
* @param workflow - ComfyUI workflow object
|
|
109
|
+
* @param nodeId - The ID of the LoadImage node
|
|
110
|
+
* @param imageFilename - The uploaded image filename
|
|
111
|
+
* @returns Updated workflow
|
|
112
|
+
*/
|
|
113
|
+
function setLoadImageNode(workflow, nodeId, imageFilename) {
|
|
114
|
+
return updateNodeParameter(workflow, nodeId, 'inputs.image', imageFilename);
|
|
115
|
+
}
|
|
337
116
|
//# sourceMappingURL=agentToolHelpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentToolHelpers.js","sourceRoot":"","sources":["../../nodes/agentToolHelpers.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"agentToolHelpers.js","sourceRoot":"","sources":["../../nodes/agentToolHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAWH,8CAWC;AAOD,sCAaC;AAOD,8CAYC;AAUD,kDA6BC;AAQD,4DAgBC;AASD,4CAMC;AAtID;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,SAA+B,EAAE,YAAoB,MAAM;IAC3F,IAAI,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,M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AAO,CAAC,IAAI,CAAC;CAoGjB"}
|
|
@@ -234,16 +234,25 @@ TIP: Check the previous nodes' "Output Binary Key" parameters. One of them shoul
|
|
|
234
234
|
}
|
|
235
235
|
this.logger.debug(`Processing ${nodeParametersInput.nodeParameter.length} node parameter overrides`);
|
|
236
236
|
for (const [i, nodeParamConfig] of nodeParametersInput.nodeParameter.entries()) {
|
|
237
|
-
const nodeId = nodeParamConfig.nodeId
|
|
237
|
+
const nodeId = nodeParamConfig.nodeId;
|
|
238
238
|
const parameterMode = nodeParamConfig.parameterMode || 'single';
|
|
239
239
|
const parametersJson = nodeParamConfig.parametersJson;
|
|
240
240
|
const paramName = nodeParamConfig.paramName;
|
|
241
|
-
const
|
|
241
|
+
const type = nodeParamConfig.type || 'text';
|
|
242
|
+
const imageSource = nodeParamConfig.imageSource || 'binary';
|
|
242
243
|
const value = nodeParamConfig.value || '';
|
|
243
|
-
const binaryProperty = nodeParamConfig.binaryProperty || 'data';
|
|
244
244
|
const numberValue = nodeParamConfig.numberValue ?? 0;
|
|
245
245
|
const booleanValue = nodeParamConfig.booleanValue ?? 'false';
|
|
246
246
|
const imageUrl = nodeParamConfig.imageUrl || '';
|
|
247
|
+
if (!nodeId) {
|
|
248
|
+
throw new n8n_workflow_1.NodeOperationError(this.executeFunctions.getNode(), `Node Parameters ${i + 1} is missing Node ID.`);
|
|
249
|
+
}
|
|
250
|
+
if (!workflow[nodeId]) {
|
|
251
|
+
throw new n8n_workflow_1.NodeOperationError(this.executeFunctions.getNode(), `Node ID "${nodeId}" not found in workflow. Please check your workflow JSON.`);
|
|
252
|
+
}
|
|
253
|
+
if (!workflow[nodeId].inputs) {
|
|
254
|
+
workflow[nodeId].inputs = {};
|
|
255
|
+
}
|
|
247
256
|
if (parameterMode === 'multiple' && parametersJson) {
|
|
248
257
|
let parameters;
|
|
249
258
|
try {
|
|
@@ -256,79 +265,37 @@ TIP: Check the previous nodes' "Output Binary Key" parameters. One of them shoul
|
|
|
256
265
|
if (typeof parameters !== 'object' || parameters === null) {
|
|
257
266
|
throw new n8n_workflow_1.NodeOperationError(this.executeFunctions.getNode(), `Node Parameters ${i + 1}: Parameters must be a JSON object`);
|
|
258
267
|
}
|
|
259
|
-
// Validate nodeId for multiple parameters mode
|
|
260
|
-
if (!nodeId) {
|
|
261
|
-
throw new n8n_workflow_1.NodeOperationError(this.executeFunctions.getNode(), `Node Parameters ${i + 1}: Node ID is required for Multiple Parameters mode. Please select a node in "Node Name or ID" field.`);
|
|
262
|
-
}
|
|
263
|
-
if (!workflow[nodeId]) {
|
|
264
|
-
throw new n8n_workflow_1.NodeOperationError(this.executeFunctions.getNode(), `Node Parameters ${i + 1}: Node ID "${nodeId}" not found in workflow. Please check your workflow JSON.`);
|
|
265
|
-
}
|
|
266
|
-
if (!workflow[nodeId].inputs) {
|
|
267
|
-
workflow[nodeId].inputs = {};
|
|
268
|
-
}
|
|
269
268
|
this.logger.debug(`Applying multiple parameters to node ${nodeId}`, { parameters });
|
|
270
269
|
for (const [key, val] of Object.entries(parameters)) {
|
|
271
270
|
workflow[nodeId].inputs[key] = val;
|
|
272
271
|
}
|
|
273
272
|
}
|
|
274
273
|
else if (parameterMode === 'single' && paramName) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
// Old format (backward compatibility): paramName|type (e.g., "seed|number")
|
|
278
|
-
let actualParamName = paramName;
|
|
279
|
-
let detectedType;
|
|
280
|
-
let actualNodeId = nodeId; // Default to user-provided nodeId
|
|
281
|
-
if (paramName.includes('|')) {
|
|
282
|
-
const parts = paramName.split('|');
|
|
283
|
-
if (parts.length >= 3) {
|
|
284
|
-
// New format: nodeId|paramName|type
|
|
285
|
-
actualNodeId = parts[0];
|
|
286
|
-
actualParamName = parts[1];
|
|
287
|
-
detectedType = parts[2];
|
|
288
|
-
}
|
|
289
|
-
else if (parts.length >= 2) {
|
|
290
|
-
// Old format: paramName|type (backward compatibility)
|
|
291
|
-
actualParamName = parts[0];
|
|
292
|
-
detectedType = parts[1];
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
// Validate that the extracted nodeId exists in workflow
|
|
296
|
-
if (!workflow[actualNodeId]) {
|
|
297
|
-
throw new n8n_workflow_1.NodeOperationError(this.executeFunctions.getNode(), `Node Parameters ${i + 1}: Node ID "${actualNodeId}" not found in workflow. Please check your workflow JSON.`);
|
|
274
|
+
if (!type) {
|
|
275
|
+
throw new n8n_workflow_1.NodeOperationError(this.executeFunctions.getNode(), `Node Parameters ${i + 1}: Type is required for single parameter mode.`);
|
|
298
276
|
}
|
|
299
|
-
// Initialize inputs object if it doesn't exist
|
|
300
|
-
if (!workflow[actualNodeId].inputs) {
|
|
301
|
-
workflow[actualNodeId].inputs = {};
|
|
302
|
-
}
|
|
303
|
-
// Use detected type from paramName if available, otherwise use valueType default
|
|
304
|
-
const actualValueType = detectedType || valueType;
|
|
305
277
|
let parsedValue;
|
|
306
|
-
|
|
307
|
-
switch (actualValueType) {
|
|
278
|
+
switch (type) {
|
|
308
279
|
case 'text':
|
|
309
280
|
parsedValue = this.processTextParameter(value);
|
|
310
|
-
workflow[
|
|
281
|
+
workflow[nodeId].inputs[paramName] = parsedValue;
|
|
311
282
|
break;
|
|
312
283
|
case 'number':
|
|
313
284
|
parsedValue = this.processNumberParameter(numberValue);
|
|
314
|
-
workflow[
|
|
285
|
+
workflow[nodeId].inputs[paramName] = parsedValue;
|
|
315
286
|
break;
|
|
316
287
|
case 'boolean':
|
|
317
288
|
parsedValue = this.processBooleanParameter(booleanValue);
|
|
318
|
-
workflow[
|
|
319
|
-
break;
|
|
320
|
-
case 'imageUrl':
|
|
321
|
-
parsedValue = await this.processImageParameter(actualNodeId, actualParamName, 'url', imageUrl, '', i, uploadImage, timeout);
|
|
322
|
-
workflow[actualNodeId].inputs[actualParamName] = parsedValue;
|
|
289
|
+
workflow[nodeId].inputs[paramName] = parsedValue;
|
|
323
290
|
break;
|
|
324
|
-
case '
|
|
325
|
-
parsedValue = await this.processImageParameter(
|
|
326
|
-
workflow[
|
|
291
|
+
case 'image':
|
|
292
|
+
parsedValue = await this.processImageParameter(nodeId, paramName, imageSource, imageUrl, value, i, uploadImage, timeout);
|
|
293
|
+
workflow[nodeId].inputs[paramName] = parsedValue;
|
|
327
294
|
break;
|
|
328
295
|
default:
|
|
329
|
-
throw new n8n_workflow_1.NodeOperationError(this.executeFunctions.getNode(), `Node Parameters ${i + 1}: Unknown
|
|
296
|
+
throw new n8n_workflow_1.NodeOperationError(this.executeFunctions.getNode(), `Node Parameters ${i + 1}: Unknown type "${type}"`);
|
|
330
297
|
}
|
|
331
|
-
this.logger.debug(`Applying single parameter to node ${
|
|
298
|
+
this.logger.debug(`Applying single parameter to node ${nodeId}`, { paramName, value: parsedValue });
|
|
332
299
|
}
|
|
333
300
|
else {
|
|
334
301
|
throw new n8n_workflow_1.NodeOperationError(this.executeFunctions.getNode(), `Node Parameters ${i + 1}: For Multiple Parameters mode, provide Parameters JSON. For Single Parameter mode, provide Parameter Name and Value.`);
|