n8n-nodes-comfyui-all 2.0.0 → 2.1.1
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 +90 -826
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,882 +1,146 @@
|
|
|
1
|
-
# n8n-comfyui-
|
|
1
|
+
# n8n-nodes-comfyui-all
|
|
2
2
|
|
|
3
|
-
n8n
|
|
3
|
+
> n8n community node for integrating ComfyUI workflows into n8n automation platform.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/n8n-nodes-comfyui-all)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- **[快速开始](#快速开始)** - 安装和配置指南
|
|
9
|
-
- **[使用方法](#使用方法)** - 基础节点使用
|
|
10
|
-
- **[工作流示例](#工作流示例)** - 实际应用案例
|
|
11
|
-
- **[故障排除](#故障排除)** - 常见问题解决
|
|
7
|
+
## ✨ Features
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
- 🎨 **Universal Workflow Support** - Works with any ComfyUI workflow in API format
|
|
10
|
+
- 🔄 **Dynamic Parameters** - Override workflow parameters dynamically
|
|
11
|
+
- 🎬 **Multi-Modal Support** - Supports images and videos for both input and output
|
|
12
|
+
- 🤖 **AI Agent Ready** - Can be used as a tool in AI Agent workflows
|
|
13
|
+
- 📊 **Flexible Configuration** - JSON mode or single parameter mode
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
**发布日期**: 2026-01-07
|
|
17
|
-
**节点名称**: ComfyUI Workflow
|
|
15
|
+
## 📦 Installation
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
### n8n Cloud
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
1. Go to **Settings** → **Community Nodes**
|
|
20
|
+
2. Click **Install**
|
|
21
|
+
3. Enter: `n8n-nodes-comfyui-all`
|
|
22
|
+
4. Click **Install**
|
|
22
23
|
|
|
23
|
-
-
|
|
24
|
-
- ✅ **动态参数**:自动识别和配置工作流中的输入参数
|
|
25
|
-
- ✅ **灵活配置**:支持文本生成图像、图像处理、视频生成等所有 ComfyUI 功能
|
|
26
|
-
- ✅ **智能验证**:自动验证工作流格式和参数
|
|
27
|
-
- ✅ **SSRF 防护**:防止内网地址访问
|
|
28
|
-
- ✅ **错误处理**:完善的错误处理和重试机制
|
|
29
|
-
- ✅ **双模式参数配置**:支持 JSON 模式(多个参数)和单参数模式(逐个配置)
|
|
30
|
-
- ✅ **图像输入验证**:imagesToAny action 自动验证图像输入
|
|
31
|
-
- 🆕 **AI Agent 支持**:既可作为普通节点,也可作为 AI Agent Tool 使用
|
|
32
|
-
- 🆕 **双模式工作**:在普通工作流和 AI Agent 对话中都能使用
|
|
33
|
-
|
|
34
|
-
### 重要说明
|
|
35
|
-
|
|
36
|
-
#### 自定义节点 vs 社区节点
|
|
37
|
-
|
|
38
|
-
本项目是一个**自定义节点**(Custom Node),用于本地开发和测试。
|
|
39
|
-
|
|
40
|
-
**自定义节点**:
|
|
41
|
-
- 本地开发,无需发布到 npm
|
|
42
|
-
- 可以快速迭代和调试
|
|
43
|
-
- 实时修改代码,立即生效
|
|
44
|
-
- 适合开发环境
|
|
45
|
-
|
|
46
|
-
**社区节点**(Community Nodes):
|
|
47
|
-
- 通过 n8n 界面安装(Settings → Community Nodes)
|
|
48
|
-
- 从 npm registry 下载已发布的包
|
|
49
|
-
- n8n 自动管理依赖
|
|
50
|
-
- 适合使用第三方开发的成熟节点
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
## 快速开始
|
|
55
|
-
|
|
56
|
-
### 前置要求
|
|
57
|
-
|
|
58
|
-
- Node.js 18.10+
|
|
59
|
-
- npm
|
|
60
|
-
- n8n 2.x
|
|
61
|
-
- ComfyUI 服务器运行中(默认:http://127.0.0.1:8188)
|
|
62
|
-
|
|
63
|
-
### 安装
|
|
64
|
-
|
|
65
|
-
#### 方法 1: 使用本地安装(推荐)
|
|
24
|
+
### Self-Hosted n8n
|
|
66
25
|
|
|
67
26
|
```bash
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
npm install
|
|
71
|
-
npm run build
|
|
72
|
-
|
|
73
|
-
# 步骤 2: 在 n8n 的 custom 目录安装
|
|
74
|
-
cd /home/ZLQyiA/projets/n8n-service/.n8n/custom
|
|
75
|
-
|
|
76
|
-
# 创建 package.json(如果不存在)
|
|
77
|
-
cat > package.json << 'EOF'
|
|
78
|
-
{
|
|
79
|
-
"name": "n8n-custom-nodes",
|
|
80
|
-
"version": "1.0.0",
|
|
81
|
-
"description": "Custom n8n nodes",
|
|
82
|
-
"dependencies": {
|
|
83
|
-
"n8n-nodes-comfyui-all": "file:../../n8n-comfyui-nodes"
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
EOF
|
|
87
|
-
|
|
88
|
-
# 安装本地包
|
|
89
|
-
npm install
|
|
90
|
-
|
|
91
|
-
# 步骤 3: 验证安装
|
|
92
|
-
ls -la node_modules/
|
|
93
|
-
# 应该看到: n8n-nodes-comfyui-all -> ../../../n8n-comfyui-nodes
|
|
94
|
-
|
|
95
|
-
# 步骤 4: 重启 n8n 服务
|
|
96
|
-
cd /home/ZLQyiA/projets/n8n-service
|
|
97
|
-
./stop-n8n.sh
|
|
98
|
-
./start-n8n.sh
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
**重要说明**:
|
|
102
|
-
- n8n 使用 `N8N_USER_DATA_DIR` 环境变量指定的目录
|
|
103
|
-
- 在我们的环境中,custom 目录位于:`/home/ZLQyiA/projets/n8n-service/.n8n/custom/`
|
|
104
|
-
- 请确保安装到正确的 custom 目录,而不是 `~/.n8n/custom/`
|
|
105
|
-
|
|
106
|
-
### 重新部署
|
|
107
|
-
|
|
108
|
-
如果需要重新部署(例如修改代码后):
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
# 1. 清理旧安装
|
|
112
|
-
cd /home/ZLQyiA/projets/n8n-service
|
|
113
|
-
rm -rf .n8n/custom/node_modules .n8n/custom/package-lock.json
|
|
114
|
-
rm -rf n8n-comfyui-nodes/dist
|
|
115
|
-
|
|
116
|
-
# 2. 重新编译
|
|
117
|
-
cd n8n-comfyui-nodes
|
|
118
|
-
npm run build
|
|
119
|
-
|
|
120
|
-
# 3. 重新安装
|
|
121
|
-
cd ../.n8n/custom
|
|
122
|
-
npm install
|
|
123
|
-
|
|
124
|
-
# 4. 重启 n8n
|
|
125
|
-
cd ../..
|
|
126
|
-
./stop-n8n.sh
|
|
127
|
-
./start-n8n.sh
|
|
128
|
-
|
|
129
|
-
# 5. 验证部署
|
|
130
|
-
cd n8n-comfyui-nodes
|
|
131
|
-
./check-deployment.sh
|
|
27
|
+
cd ~/.n8n
|
|
28
|
+
npm install n8n-nodes-comfyui-all
|
|
132
29
|
```
|
|
133
30
|
|
|
134
|
-
|
|
135
|
-
```bash
|
|
136
|
-
cd /home/ZLQyiA/projets/n8n-service/n8n-comfyui-nodes
|
|
137
|
-
./check-deployment.sh # 检查当前部署状态
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
#### 方法 2: 通过 n8n 界面安装
|
|
141
|
-
|
|
142
|
-
1. 访问 n8n 界面
|
|
143
|
-
2. Settings → Community Nodes
|
|
144
|
-
3. 点击 "Install"
|
|
145
|
-
4. 输入包名并安装
|
|
146
|
-
|
|
147
|
-
### 重启 n8n
|
|
31
|
+
Or via n8n interface: **Settings** → **Community Nodes** → **Install** → `n8n-nodes-comfyui-all`
|
|
148
32
|
|
|
149
|
-
|
|
150
|
-
cd /home/ZLQyiA/projets/n8n-service
|
|
151
|
-
./stop-n8n.sh
|
|
152
|
-
./start-n8n.sh
|
|
153
|
-
```
|
|
33
|
+
> Restart n8n after installation.
|
|
154
34
|
|
|
155
|
-
|
|
35
|
+
## 🚀 Quick Start
|
|
156
36
|
|
|
157
|
-
|
|
37
|
+
### 1. Prerequisites
|
|
158
38
|
|
|
159
|
-
|
|
39
|
+
- ComfyUI server running (default: `http://127.0.0.1:8188`)
|
|
40
|
+
- n8n instance (version 2.x or higher)
|
|
160
41
|
|
|
161
|
-
|
|
162
|
-
2. 点击 **Save (API Format)** 导出工作流
|
|
163
|
-
3. 复制生成的 JSON
|
|
42
|
+
### 2. Create Your Workflow in ComfyUI
|
|
164
43
|
|
|
165
|
-
|
|
44
|
+
1. Design your workflow in ComfyUI
|
|
45
|
+
2. Click **Save (API Format)** to export
|
|
46
|
+
3. Copy the generated JSON
|
|
166
47
|
|
|
167
|
-
|
|
168
|
-
2. 配置参数:
|
|
169
|
-
- **ComfyUI URL**: `http://127.0.0.1:8188`
|
|
170
|
-
- **Workflow JSON**: 粘贴工作流 JSON
|
|
171
|
-
- **Node Parameters**: 配置节点参数(支持 JSON 模式和单参数模式)
|
|
48
|
+
### 3. Configure n8n Node
|
|
172
49
|
|
|
173
|
-
|
|
50
|
+
1. Add **ComfyUI** node to your n8n workflow
|
|
51
|
+
2. Set **ComfyUI URL**: `http://127.0.0.1:8188`
|
|
52
|
+
3. Paste your **Workflow JSON**
|
|
53
|
+
4. Optionally configure **Node Parameters**
|
|
174
54
|
|
|
175
|
-
|
|
55
|
+
## 📖 Usage
|
|
176
56
|
|
|
177
|
-
|
|
57
|
+
### Basic Example: Text to Image
|
|
178
58
|
|
|
179
|
-
|
|
59
|
+
**Node Configuration:**
|
|
60
|
+
- **Action**: `TextToAny`
|
|
61
|
+
- **ComfyUI URL**: `http://127.0.0.1:8188`
|
|
62
|
+
- **Workflow JSON**: Your ComfyUI workflow in API format
|
|
180
63
|
|
|
181
|
-
|
|
64
|
+
**Optional Node Parameters (Single Parameter Mode):**
|
|
65
|
+
- Node ID: `6` (your CLIP text node)
|
|
66
|
+
- Parameter Name: `text`
|
|
67
|
+
- Type: `Text`
|
|
68
|
+
- Value: `a beautiful landscape, high quality`
|
|
182
69
|
|
|
183
|
-
|
|
184
|
-
2. 点击 **"Add Node"** 添加一个节点配置
|
|
185
|
-
3. 选择 **Parameter Mode** 为 **JSON Mode**
|
|
186
|
-
4. 填写以下字段:
|
|
187
|
-
- **Node ID**: 工作流中节点的 ID(例如:`13`)
|
|
188
|
-
- **Parameters JSON**: 该节点的所有参数,JSON 格式
|
|
70
|
+
### Parameter Configuration Modes
|
|
189
71
|
|
|
190
|
-
|
|
72
|
+
#### 1. Multiple Parameters Mode (JSON)
|
|
191
73
|
|
|
192
|
-
|
|
74
|
+
Configure multiple parameters at once using JSON:
|
|
193
75
|
|
|
194
76
|
```json
|
|
195
77
|
{
|
|
196
78
|
"width": 1024,
|
|
197
79
|
"height": 1024,
|
|
198
|
-
"batch_size": 1
|
|
199
|
-
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
**多个节点配置**:
|
|
203
|
-
|
|
204
|
-
你可以添加多个 Node 条目来配置不同的节点:
|
|
205
|
-
|
|
206
|
-
- Node 1: ID=13, Mode=JSON, Parameters=`{"width": 1024, "height": 1024, "batch_size": 1}`
|
|
207
|
-
- Node 2: ID=3, Mode=JSON, Parameters=`{"seed": 12345, "steps": 20, "cfg": 7.5}`
|
|
208
|
-
|
|
209
|
-
**优点**:
|
|
210
|
-
- ✅ 配置更简洁,一个节点一个配置项
|
|
211
|
-
- ✅ 支持 JSON 格式,可以复制粘贴
|
|
212
|
-
- ✅ 适合需要配置多个参数的节点
|
|
213
|
-
|
|
214
|
-
#### 模式 2: 单参数模式
|
|
215
|
-
|
|
216
|
-
逐个配置参数,适合不熟悉 JSON 的用户。
|
|
217
|
-
|
|
218
|
-
**使用步骤**:
|
|
219
|
-
|
|
220
|
-
1. 在节点配置中找到 **"Node Parameters"** 部分
|
|
221
|
-
2. 点击 **"Add Node"** 添加一个节点配置
|
|
222
|
-
3. 选择 **Parameter Mode** 为 **Single Parameter**
|
|
223
|
-
4. 填写以下字段:
|
|
224
|
-
- **Node ID**: 工作流中节点的 ID(例如:`13`)
|
|
225
|
-
- **Parameter Name**: 参数名(例如:`width`)
|
|
226
|
-
- **Type**: 数据类型(text/number/boolean/json)
|
|
227
|
-
- **Value**: 参数值
|
|
228
|
-
|
|
229
|
-
**示例**:
|
|
230
|
-
|
|
231
|
-
配置 EmptyLatentImage 节点(ID: 13)的 width 参数:
|
|
232
|
-
|
|
233
|
-
- Node 1: ID=13, Mode=Single, Parameter Name=width, Type=number, Value=1024
|
|
234
|
-
|
|
235
|
-
配置多个参数:
|
|
236
|
-
|
|
237
|
-
- Node 1: ID=13, Mode=Single, Parameter Name=width, Type=number, Value=1024
|
|
238
|
-
- Node 2: ID=13, Mode=Single, Parameter Name=height, Type=number, Value=1024
|
|
239
|
-
- Node 3: ID=13, Mode=Single, Parameter Name=batch_size, Type=number, Value=1
|
|
240
|
-
|
|
241
|
-
**优点**:
|
|
242
|
-
- ✅ 不需要了解 JSON 语法
|
|
243
|
-
- ✅ 有类型验证,避免错误
|
|
244
|
-
- ✅ 适合只需要配置少量参数的情况
|
|
245
|
-
|
|
246
|
-
#### 两种模式的对比
|
|
247
|
-
|
|
248
|
-
| 特性 | JSON 模式 | 单参数模式 |
|
|
249
|
-
|------|-----------|-----------|
|
|
250
|
-
| 配置方式 | JSON 格式,一次多个参数 | 逐个参数配置 |
|
|
251
|
-
| 适用场景 | 节点有多个参数需要配置 | 只需要配置少量参数 |
|
|
252
|
-
| 类型验证 | 无(JSON 格式) | 有(Type 字段) |
|
|
253
|
-
| 推荐度 | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ |
|
|
254
|
-
|
|
255
|
-
**注意**:
|
|
256
|
-
- 图像应该通过工作流连接(imagesToAny)或工作流 JSON 直接配置,不需要通过参数上传
|
|
257
|
-
- 参数值会覆盖工作流 JSON 中的默认值
|
|
258
|
-
- 两种模式可以混合使用
|
|
259
|
-
|
|
260
|
-
---
|
|
261
|
-
|
|
262
|
-
## AI Agent 集成
|
|
263
|
-
|
|
264
|
-
### 🎉 双模式支持
|
|
265
|
-
|
|
266
|
-
ComfyUI Workflow 节点现在支持两种使用方式:
|
|
267
|
-
|
|
268
|
-
#### 模式 1: 作为普通节点使用
|
|
269
|
-
|
|
270
|
-
拖拽到任何工作流中,手动配置参数。
|
|
271
|
-
|
|
272
|
-
#### 模式 2: 作为 AI Agent Tool 使用 🆕
|
|
273
|
-
|
|
274
|
-
在 AI Agent 的 tools 列表中会自动出现 ComfyUI Workflow!
|
|
275
|
-
|
|
276
|
-
### 在 AI Agent 中使用
|
|
277
|
-
|
|
278
|
-
#### 步骤 1: 创建 AI Agent
|
|
279
|
-
|
|
280
|
-
1. 添加 **OpenAI Conversational Agent** 节点
|
|
281
|
-
2. 配置 Chat Model 和 Memory
|
|
282
|
-
|
|
283
|
-
#### 步骤 2: 添加 ComfyUI Tool
|
|
284
|
-
|
|
285
|
-
1. 点击 AI Agent 节点
|
|
286
|
-
2. 在 **Tools** 部分点击 **+ Add Tool**
|
|
287
|
-
3. 搜索 **"ComfyUI"**
|
|
288
|
-
4. 选择 **ComfyUI Workflow** 节点
|
|
289
|
-
5. 配置节点参数(ComfyUI URL、Workflow JSON 等)
|
|
290
|
-
|
|
291
|
-
#### 步骤 3: 开始对话
|
|
292
|
-
|
|
293
|
-
**示例对话**:
|
|
294
|
-
```
|
|
295
|
-
用户: 生成一只可爱的猫咪
|
|
296
|
-
|
|
297
|
-
AI: 好的,我来为您生成一张可爱猫咪的图片。
|
|
298
|
-
[调用 ComfyUI Workflow tool]
|
|
299
|
-
完成!图片已生成。
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
### 技术实现
|
|
303
|
-
|
|
304
|
-
节点通过 `usableAsTool: true` 属性支持 AI Agent。这与 lark/feishu 节点的实现方式相同。
|
|
305
|
-
|
|
306
|
-
### 使用示例
|
|
307
|
-
|
|
308
|
-
#### 基础用法
|
|
309
|
-
|
|
310
|
-
**用户输入**:
|
|
311
|
-
```
|
|
312
|
-
生成一只在森林里的狐狸
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
**AI Agent 行为**:
|
|
316
|
-
1. 识别用户想要生成图像
|
|
317
|
-
2. 调用 ComfyUI 工具
|
|
318
|
-
3. 使用默认参数生成图像(512x512, 20 steps)
|
|
319
|
-
4. 返回生成的图像 URL
|
|
320
|
-
|
|
321
|
-
#### 高级用法(带参数)
|
|
322
|
-
|
|
323
|
-
**用户输入**:
|
|
324
|
-
```
|
|
325
|
-
创建一个赛博朋克城市,size:1024x768, steps:30, cfg:10
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
**支持的参数**:
|
|
329
|
-
- `size:WIDTHxHEIGHT` - 图像尺寸(如:1024x768)
|
|
330
|
-
- `steps:N` - 采样步数(如:30)
|
|
331
|
-
- `cfg:N` - CFG 强度(如:7.5)
|
|
332
|
-
- `seed:N` - 随机种子(如:12345)
|
|
333
|
-
- `negative:TEXT` - 负向提示词(如:ugly, blurry)
|
|
334
|
-
|
|
335
|
-
#### 负向提示词
|
|
336
|
-
|
|
337
|
-
**用户输入**:
|
|
338
|
-
```
|
|
339
|
-
画一个美丽的日落,negative: 模糊, 低质量, 变形
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
### 文件位置
|
|
343
|
-
|
|
344
|
-
- **完整代码**: `agent-tools/ComfyUI-Agent-Tool.js`
|
|
345
|
-
- **详细文档**: `agent-tools/README.md`
|
|
346
|
-
- **工作流示例**: `agent-tools/example-workflow.json`
|
|
347
|
-
|
|
348
|
-
### 定制工作流
|
|
349
|
-
|
|
350
|
-
要使用你自己的 ComfyUI 工作流:
|
|
351
|
-
|
|
352
|
-
1. 在 ComfyUI 中创建工作流
|
|
353
|
-
2. 导出为 **API Format**
|
|
354
|
-
3. 替换 `ComfyUI-Agent-Tool.js` 中的 `WORKFLOW_TEMPLATE`
|
|
355
|
-
4. 根据你的工作流调整 `updateWorkflow()` 函数
|
|
356
|
-
|
|
357
|
-
**详细指南**: 请参考 `agent-tools/README.md`
|
|
358
|
-
|
|
359
|
-
---
|
|
360
|
-
|
|
361
|
-
## 支持的节点类型
|
|
362
|
-
|
|
363
|
-
| 节点类型 | 说明 | 可配置参数 |
|
|
364
|
-
|---------|------|-----------|
|
|
365
|
-
| LoadImage | 图像加载 | image |
|
|
366
|
-
| KSampler | 采样器 | seed, steps, cfg, sampler_name, scheduler, denoise |
|
|
367
|
-
| CheckpointLoaderSimple | 模型加载 | ckpt_name |
|
|
368
|
-
| LoraLoader | LoRA 加载 | lora_name, strength_model, strength_clip |
|
|
369
|
-
| CLIPTextEncode | 文本编码 | text |
|
|
370
|
-
| EmptyLatentImage | 潜像尺寸 | width, height, batch_size |
|
|
371
|
-
| SaveImage | 保存图像 | filename_prefix |
|
|
372
|
-
|
|
373
|
-
---
|
|
374
|
-
|
|
375
|
-
## 常见使用场景
|
|
376
|
-
|
|
377
|
-
### 1. 文本生成图像
|
|
378
|
-
|
|
379
|
-
**工作流**: 标准的 text-to-image
|
|
380
|
-
|
|
381
|
-
**参数**:
|
|
382
|
-
```json
|
|
383
|
-
{
|
|
384
|
-
"6_text": "beautiful landscape, high quality",
|
|
385
|
-
"7_text": "ugly, blurry",
|
|
386
|
-
"3_steps": 25,
|
|
387
|
-
"3_cfg": 7.5,
|
|
388
|
-
"3_sampler_name": "euler"
|
|
389
|
-
}
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
### 2. 图像风格转换
|
|
393
|
-
|
|
394
|
-
**参数**:
|
|
395
|
-
```json
|
|
396
|
-
{
|
|
397
|
-
"6_text": "oil painting style, artistic",
|
|
398
|
-
"10_image": "http://example.com/input.jpg",
|
|
399
|
-
"3_denoise": 0.65
|
|
400
|
-
}
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
### 3. 使用固定种子
|
|
404
|
-
|
|
405
|
-
**参数**:
|
|
406
|
-
```json
|
|
407
|
-
{
|
|
408
|
-
"6_text": "a cyberpunk city",
|
|
409
|
-
"3_seed": 12345
|
|
410
|
-
}
|
|
411
|
-
```
|
|
412
|
-
|
|
413
|
-
---
|
|
414
|
-
|
|
415
|
-
## 参数说明
|
|
416
|
-
|
|
417
|
-
### 文本参数
|
|
418
|
-
|
|
419
|
-
```json
|
|
420
|
-
{
|
|
421
|
-
"6_text": "beautiful landscape",
|
|
422
|
-
"9_filename_prefix": "my_image"
|
|
423
|
-
}
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
### 数字参数
|
|
427
|
-
|
|
428
|
-
```json
|
|
429
|
-
{
|
|
430
|
-
"3_steps": 20,
|
|
431
|
-
"3_cfg": 7.5,
|
|
432
|
-
"5_width": 512,
|
|
433
|
-
"5_height": 512
|
|
434
|
-
}
|
|
435
|
-
```
|
|
436
|
-
|
|
437
|
-
### 选项参数
|
|
438
|
-
|
|
439
|
-
**sampler_name**: `euler`, `euler_ancestral`, `heun`, `dpm_2`, `dpm_2_ancestral`, `lms`, `ddim`, `uni_pc`
|
|
440
|
-
|
|
441
|
-
**scheduler**: `normal`, `karras`, `exponential`, `sgm_uniform`, `simple`, `ddim_uniform`
|
|
442
|
-
|
|
443
|
-
### 图像参数
|
|
444
|
-
|
|
445
|
-
URL 方式:
|
|
446
|
-
```json
|
|
447
|
-
{
|
|
448
|
-
"10_image": "http://example.com/image.png"
|
|
449
|
-
}
|
|
450
|
-
```
|
|
451
|
-
|
|
452
|
-
Base64 方式:
|
|
453
|
-
```json
|
|
454
|
-
{
|
|
455
|
-
"10_image": "data:image/png;base64,iVBORw0KG..."
|
|
456
|
-
}
|
|
457
|
-
```
|
|
458
|
-
|
|
459
|
-
---
|
|
460
|
-
|
|
461
|
-
## 输出格式
|
|
462
|
-
|
|
463
|
-
成功执行后返回:
|
|
464
|
-
|
|
465
|
-
```json
|
|
466
|
-
{
|
|
467
|
-
"success": true,
|
|
468
|
-
"images": [
|
|
469
|
-
{
|
|
470
|
-
"url": "http://127.0.0.1:8188/view?filename=ComfyUI_00001.png...",
|
|
471
|
-
"type": "image"
|
|
472
|
-
}
|
|
473
|
-
],
|
|
474
|
-
"videos": [
|
|
475
|
-
{
|
|
476
|
-
"url": "http://127.0.0.1:8188/view?filename=video.mp4...",
|
|
477
|
-
"type": "video"
|
|
478
|
-
}
|
|
479
|
-
]
|
|
80
|
+
"batch_size": 1,
|
|
81
|
+
"seed": 12345
|
|
480
82
|
}
|
|
481
83
|
```
|
|
482
84
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
## 开发
|
|
486
|
-
|
|
487
|
-
### 编译
|
|
488
|
-
|
|
489
|
-
```bash
|
|
490
|
-
npm run build
|
|
491
|
-
```
|
|
492
|
-
|
|
493
|
-
### 代码检查
|
|
494
|
-
|
|
495
|
-
```bash
|
|
496
|
-
npm run lint
|
|
497
|
-
npm run lintfix
|
|
498
|
-
```
|
|
499
|
-
|
|
500
|
-
### 监听模式
|
|
501
|
-
|
|
502
|
-
```bash
|
|
503
|
-
npm run dev
|
|
504
|
-
```
|
|
505
|
-
|
|
506
|
-
### 测试
|
|
507
|
-
|
|
508
|
-
```bash
|
|
509
|
-
node test-load.js
|
|
510
|
-
```
|
|
511
|
-
|
|
512
|
-
---
|
|
513
|
-
|
|
514
|
-
## 故障排除
|
|
515
|
-
|
|
516
|
-
### 节点未出现在 n8n 中
|
|
517
|
-
|
|
518
|
-
1. 确认安装到正确的 custom 目录:
|
|
519
|
-
```bash
|
|
520
|
-
ls -la /home/ZLQyiA/projets/n8n-service/.n8n/custom/node_modules/
|
|
521
|
-
```
|
|
522
|
-
应该看到:`n8n-nodes-comfyui-all -> ../../../n8n-comfyui-nodes`
|
|
523
|
-
|
|
524
|
-
2. 重启 n8n 服务:
|
|
525
|
-
```bash
|
|
526
|
-
cd /home/ZLQyiA/projets/n8n-service
|
|
527
|
-
./stop-n8n.sh
|
|
528
|
-
./start-n8n.sh
|
|
529
|
-
```
|
|
530
|
-
|
|
531
|
-
3. 检查 package.json 包含正确配置
|
|
532
|
-
|
|
533
|
-
### 连接 ComfyUI 失败
|
|
534
|
-
|
|
535
|
-
1. 确保 ComfyUI 正在运行
|
|
536
|
-
2. 检查 URL 配置
|
|
537
|
-
3. 查看防火墙设置
|
|
538
|
-
|
|
539
|
-
### 工作流验证失败
|
|
540
|
-
|
|
541
|
-
1. 确保使用 "Save (API Format)" 导出
|
|
542
|
-
2. 验证 JSON 格式正确
|
|
543
|
-
3. 检查节点 ID 和参数名
|
|
544
|
-
|
|
545
|
-
### n8n 检测到包缺失警告
|
|
546
|
-
|
|
547
|
-
如果看到 `n8n detected that some packages are missing` 警告,这是正常的:
|
|
548
|
-
- n8n 尝试从 npm registry 获取社区节点信息但超时
|
|
549
|
-
- 不影响本地自定义节点的使用
|
|
550
|
-
- 如果节点能正常工作,可以忽略此警告
|
|
551
|
-
|
|
552
|
-
---
|
|
553
|
-
|
|
554
|
-
## 项目结构
|
|
555
|
-
|
|
556
|
-
```
|
|
557
|
-
n8n-nodes-comfyui-all/
|
|
558
|
-
├── nodes/
|
|
559
|
-
│ ├── ComfyUi/
|
|
560
|
-
│ │ ├── ComfyUi.node.ts # 主节点实现
|
|
561
|
-
│ │ └── comfyui.svg # 节点图标
|
|
562
|
-
│ ├── ComfyUiClient.ts # API 客户端
|
|
563
|
-
│ ├── workflow-parser.ts # 工作流解析器
|
|
564
|
-
│ ├── validation.ts # 验证工具
|
|
565
|
-
│ ├── types.ts # 类型定义
|
|
566
|
-
│ └── constants.ts # 配置常量
|
|
567
|
-
├── agent-tools/ # AI Agent 工具
|
|
568
|
-
│ ├── ComfyUI-Agent-Tool.js # Custom Code Tool 代码
|
|
569
|
-
│ ├── README.md # AI Agent 工具文档
|
|
570
|
-
│ └── example-workflow.json # 工作流示例
|
|
571
|
-
├── dist/ # 编译输出
|
|
572
|
-
├── index.ts # 入口文件
|
|
573
|
-
├── package.json # 包配置
|
|
574
|
-
├── tsconfig.json # TypeScript 配置
|
|
575
|
-
└── README.md # 本文件
|
|
576
|
-
```
|
|
577
|
-
|
|
578
|
-
---
|
|
85
|
+
#### 2. Single Parameter Mode
|
|
579
86
|
|
|
580
|
-
|
|
87
|
+
Configure one parameter at a time with type validation:
|
|
581
88
|
|
|
582
|
-
|
|
89
|
+
- **Parameter Name**: `steps`
|
|
90
|
+
- **Type**: `Number`
|
|
91
|
+
- **Value**: `25`
|
|
583
92
|
|
|
584
|
-
|
|
93
|
+
### Binary File Upload
|
|
585
94
|
|
|
586
|
-
|
|
587
|
-
{
|
|
588
|
-
"3": {
|
|
589
|
-
"inputs": {
|
|
590
|
-
"seed": 123456789,
|
|
591
|
-
"steps": 20,
|
|
592
|
-
"cfg": 8,
|
|
593
|
-
"sampler_name": "euler",
|
|
594
|
-
"scheduler": "normal",
|
|
595
|
-
"denoise": 1,
|
|
596
|
-
"model": ["4", 0],
|
|
597
|
-
"positive": ["6", 0],
|
|
598
|
-
"negative": ["7", 0],
|
|
599
|
-
"latent_image": ["5", 0]
|
|
600
|
-
},
|
|
601
|
-
"class_type": "KSampler"
|
|
602
|
-
},
|
|
603
|
-
"4": {
|
|
604
|
-
"inputs": {
|
|
605
|
-
"ckpt_name": "v1-5-pruned-emaonly.ckpt"
|
|
606
|
-
},
|
|
607
|
-
"class_type": "CheckpointLoaderSimple"
|
|
608
|
-
},
|
|
609
|
-
"5": {
|
|
610
|
-
"inputs": {
|
|
611
|
-
"width": 512,
|
|
612
|
-
"height": 512,
|
|
613
|
-
"batch_size": 1
|
|
614
|
-
},
|
|
615
|
-
"class_type": "EmptyLatentImage"
|
|
616
|
-
},
|
|
617
|
-
"6": {
|
|
618
|
-
"inputs": {
|
|
619
|
-
"text": "beautiful landscape, high quality",
|
|
620
|
-
"clip": ["4", 1]
|
|
621
|
-
},
|
|
622
|
-
"class_type": "CLIPTextEncode"
|
|
623
|
-
},
|
|
624
|
-
"7": {
|
|
625
|
-
"inputs": {
|
|
626
|
-
"text": "ugly, blurry, low quality",
|
|
627
|
-
"clip": ["4", 1]
|
|
628
|
-
},
|
|
629
|
-
"class_type": "CLIPTextEncode"
|
|
630
|
-
},
|
|
631
|
-
"8": {
|
|
632
|
-
"inputs": {
|
|
633
|
-
"samples": ["3", 0],
|
|
634
|
-
"vae": ["4", 2]
|
|
635
|
-
},
|
|
636
|
-
"class_type": "VAEDecode"
|
|
637
|
-
},
|
|
638
|
-
"9": {
|
|
639
|
-
"inputs": {
|
|
640
|
-
"filename_prefix": "ComfyUI",
|
|
641
|
-
"images": ["8", 0]
|
|
642
|
-
},
|
|
643
|
-
"class_type": "SaveImage"
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
```
|
|
95
|
+
To upload input images to ComfyUI:
|
|
647
96
|
|
|
648
|
-
**
|
|
97
|
+
- **Type**: `Binary`
|
|
98
|
+
- **Binary Property**: `data` (default)
|
|
99
|
+
- The node will automatically upload the binary data and use the filename
|
|
649
100
|
|
|
650
|
-
|
|
651
|
-
{
|
|
652
|
-
"6_text": "a serene mountain landscape at sunset",
|
|
653
|
-
"7_text": "ugly, blurry, low quality, distorted",
|
|
654
|
-
"3_steps": 25,
|
|
655
|
-
"3_cfg": 7.5
|
|
656
|
-
}
|
|
657
|
-
```
|
|
658
|
-
|
|
659
|
-
---
|
|
101
|
+
## 🤖 AI Agent Integration
|
|
660
102
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
**工作流 JSON**:
|
|
664
|
-
|
|
665
|
-
```json
|
|
666
|
-
{
|
|
667
|
-
"3": {
|
|
668
|
-
"inputs": {
|
|
669
|
-
"seed": 0,
|
|
670
|
-
"steps": 20,
|
|
671
|
-
"cfg": 8,
|
|
672
|
-
"sampler_name": "euler",
|
|
673
|
-
"scheduler": "normal",
|
|
674
|
-
"denoise": 0.75,
|
|
675
|
-
"model": ["4", 0],
|
|
676
|
-
"positive": ["6", 0],
|
|
677
|
-
"negative": ["7", 0],
|
|
678
|
-
"latent_image": ["5", 0]
|
|
679
|
-
},
|
|
680
|
-
"class_type": "KSampler"
|
|
681
|
-
},
|
|
682
|
-
"4": {
|
|
683
|
-
"inputs": {
|
|
684
|
-
"ckpt_name": "v1-5-pruned-emaonly.ckpt"
|
|
685
|
-
},
|
|
686
|
-
"class_type": "CheckpointLoaderSimple"
|
|
687
|
-
},
|
|
688
|
-
"5": {
|
|
689
|
-
"inputs": {
|
|
690
|
-
"pixels": ["10", 0],
|
|
691
|
-
"vae": ["4", 2]
|
|
692
|
-
},
|
|
693
|
-
"class_type": "VAEEncode"
|
|
694
|
-
},
|
|
695
|
-
"6": {
|
|
696
|
-
"inputs": {
|
|
697
|
-
"text": "oil painting style",
|
|
698
|
-
"clip": ["4", 1]
|
|
699
|
-
},
|
|
700
|
-
"class_type": "CLIPTextEncode"
|
|
701
|
-
},
|
|
702
|
-
"7": {
|
|
703
|
-
"inputs": {
|
|
704
|
-
"text": "ugly, blurry",
|
|
705
|
-
"clip": ["4", 1]
|
|
706
|
-
},
|
|
707
|
-
"class_type": "CLIPTextEncode"
|
|
708
|
-
},
|
|
709
|
-
"8": {
|
|
710
|
-
"inputs": {
|
|
711
|
-
"samples": ["3", 0],
|
|
712
|
-
"vae": ["4", 2]
|
|
713
|
-
},
|
|
714
|
-
"class_type": "VAEDecode"
|
|
715
|
-
},
|
|
716
|
-
"9": {
|
|
717
|
-
"inputs": {
|
|
718
|
-
"filename_prefix": "ComfyUI",
|
|
719
|
-
"images": ["8", 0]
|
|
720
|
-
},
|
|
721
|
-
"class_type": "SaveImage"
|
|
722
|
-
},
|
|
723
|
-
"10": {
|
|
724
|
-
"inputs": {
|
|
725
|
-
"image": "example.png",
|
|
726
|
-
"choose file to upload": "image"
|
|
727
|
-
},
|
|
728
|
-
"class_type": "LoadImage"
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
```
|
|
103
|
+
Use ComfyUI as a tool in AI Agent workflows:
|
|
732
104
|
|
|
733
|
-
**
|
|
105
|
+
1. Add an **AI Agent** node (e.g., OpenAI Conversational Agent)
|
|
106
|
+
2. In the **Tools** section, add **ComfyUI**
|
|
107
|
+
3. Configure the ComfyUI node parameters
|
|
108
|
+
4. Start chatting!
|
|
734
109
|
|
|
735
|
-
|
|
736
|
-
{
|
|
737
|
-
"6_text": "watercolor painting style, artistic",
|
|
738
|
-
"7_text": "",
|
|
739
|
-
"10_image": "http://example.com/input.jpg",
|
|
740
|
-
"3_denoise": 0.6
|
|
741
|
-
}
|
|
110
|
+
**Example:**
|
|
742
111
|
```
|
|
112
|
+
User: Generate a cute cat picture
|
|
743
113
|
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
**工作流**: 使用示例 1 的工作流
|
|
749
|
-
|
|
750
|
-
**参数**:
|
|
751
|
-
```json
|
|
752
|
-
{
|
|
753
|
-
"6_text": "a cyberpunk city",
|
|
754
|
-
"3_seed": 12345
|
|
755
|
-
}
|
|
114
|
+
AI: I'll generate that for you using ComfyUI.
|
|
115
|
+
[Calls ComfyUI tool]
|
|
116
|
+
Done! Here's your cute cat picture.
|
|
756
117
|
```
|
|
757
118
|
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
## 参数说明
|
|
761
|
-
|
|
762
|
-
### 节点说明
|
|
763
|
-
|
|
764
|
-
| 节点 ID | 类型 | 功能 | 可配置参数 |
|
|
765
|
-
|---------|------|------|-----------|
|
|
766
|
-
| 3 | KSampler | 采样器,控制生成参数 | seed, steps, cfg, sampler_name, scheduler, denoise |
|
|
767
|
-
| 4 | CheckpointLoaderSimple | 加载模型 | ckpt_name |
|
|
768
|
-
| 5 | EmptyLatentImage / VAEEncode | 创建空潜像或编码图像 | width, height, batch_size / pixels |
|
|
769
|
-
| 6 | CLIPTextEncode | 正向提示词编码 | text |
|
|
770
|
-
| 7 | CLIPTextEncode | 负向提示词编码 | text |
|
|
771
|
-
| 8 | VAEDecode | 解码潜像为图像 | - |
|
|
772
|
-
| 9 | SaveImage | 保存生成的图像 | filename_prefix |
|
|
773
|
-
| 10 | LoadImage | 加载输入图像 | image |
|
|
774
|
-
|
|
775
|
-
### 常用参数详解
|
|
776
|
-
|
|
777
|
-
**KSampler (节点 3)**:
|
|
778
|
-
- `seed`: 随机种子(留空自动生成,固定可复现结果)
|
|
779
|
-
- `steps`: 采样步数 (20-50,通常 20-30 步足够)
|
|
780
|
-
- `cfg`: CFG 强度 (6-15,常用 7-8)
|
|
781
|
-
- `sampler_name`: 采样器类型(euler, euler_ancestral, ddim 等)
|
|
782
|
-
- `scheduler`: 调度器类型(normal, karras, exponential 等)
|
|
783
|
-
- `denoise`: 去噪强度 (0-1)
|
|
784
|
-
- 文生图: 1.0
|
|
785
|
-
- 图生图: 0.5-0.75
|
|
786
|
-
- 图像编辑: 0.3-0.5
|
|
787
|
-
|
|
788
|
-
**CLIPTextEncode (节点 6/7)**:
|
|
789
|
-
- `text`: 提示词文本
|
|
790
|
-
|
|
791
|
-
**EmptyLatentImage (节点 5)**:
|
|
792
|
-
- `width`: 图像宽度 (512, 768, 1024)
|
|
793
|
-
- `height`: 图像高度 (512, 768, 1024)
|
|
794
|
-
- `batch_size`: 批次大小 (1-4)
|
|
795
|
-
|
|
796
|
-
**LoadImage (节点 10)**:
|
|
797
|
-
- `image`: 图像 URL 或 base64 数据
|
|
798
|
-
|
|
799
|
-
### 使用提示
|
|
800
|
-
|
|
801
|
-
- **首次使用**:建议使用示例 1(文本生成图像)开始
|
|
802
|
-
- **种子控制**:固定 seed 可以复现结果
|
|
803
|
-
- **步数优化**:20-30 步通常足够,更多步数不一定更好
|
|
804
|
-
- **CFG 值**:7-8 是常用范围,太高可能导致过饱和
|
|
805
|
-
- **去噪强度**:根据使用场景调整(见上方 KSampler 参数说明)
|
|
806
|
-
|
|
807
|
-
---
|
|
808
|
-
|
|
809
|
-
## 更多示例
|
|
810
|
-
|
|
811
|
-
---
|
|
812
|
-
|
|
813
|
-
## 技术栈
|
|
814
|
-
|
|
815
|
-
- TypeScript (严格模式)
|
|
816
|
-
- n8n-workflow
|
|
817
|
-
- axios
|
|
818
|
-
- ComfyUI API
|
|
819
|
-
|
|
820
|
-
---
|
|
821
|
-
|
|
822
|
-
## 许可证
|
|
823
|
-
|
|
824
|
-
MIT
|
|
825
|
-
|
|
826
|
-
---
|
|
827
|
-
|
|
828
|
-
## 更新日志
|
|
829
|
-
|
|
830
|
-
### v2.4 (2026-01-07)
|
|
831
|
-
|
|
832
|
-
- ✨ **优雅的模式切换**:添加 Parameter Mode 选择器,动态显示相关字段
|
|
833
|
-
- ✨ **改进用户体验**:JSON 模式和单参数模式清晰分离,不再混淆
|
|
834
|
-
- ✨ **动态显示**:根据选择的模式自动显示/隐藏字段
|
|
835
|
-
- 📝 更新文档,详细说明模式切换的使用方法
|
|
836
|
-
- 🔧 优化代码结构,提升可维护性
|
|
837
|
-
|
|
838
|
-
### v2.3 (2026-01-07)
|
|
839
|
-
|
|
840
|
-
- ✨ **Node Parameters 双模式支持**:支持 JSON 模式和单参数模式
|
|
841
|
-
- ✨ **灵活配置**:JSON 模式适合配置多个参数,单参数模式适合逐个配置
|
|
842
|
-
- ✨ **动态显示**:根据选择的模式动态显示相关字段
|
|
843
|
-
- 📝 更新文档,详细说明两种模式的使用方法和对比
|
|
844
|
-
- 🔧 优化代码结构,提升用户体验
|
|
119
|
+
For detailed AI Agent usage, see [AI-AGENT-USAGE.md](AI-AGENT-USAGE.md).
|
|
845
120
|
|
|
846
|
-
|
|
121
|
+
## 🔧 Configuration Reference
|
|
847
122
|
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
123
|
+
| Field | Description |
|
|
124
|
+
|-------|-------------|
|
|
125
|
+
| **ComfyUI URL** | URL of your ComfyUI server |
|
|
126
|
+
| **Action** | TextToAny or ImagesToAny |
|
|
127
|
+
| **Workflow JSON** | ComfyUI workflow in API format |
|
|
128
|
+
| **Timeout** | Maximum wait time in seconds (default: 300) |
|
|
129
|
+
| **Node Parameters** | Override workflow parameters |
|
|
854
130
|
|
|
855
|
-
|
|
131
|
+
## 💡 Tips
|
|
856
132
|
|
|
857
|
-
-
|
|
858
|
-
-
|
|
859
|
-
-
|
|
860
|
-
-
|
|
861
|
-
-
|
|
862
|
-
- ✅ 完善测试覆盖
|
|
133
|
+
- **First time**: Start with a simple text-to-image workflow
|
|
134
|
+
- **Parameter overrides**: Use Node Parameters instead of modifying workflow JSON
|
|
135
|
+
- **Seed control**: Fixed seeds produce reproducible results
|
|
136
|
+
- **Optimization**: 20-30 sampling steps are usually sufficient
|
|
137
|
+
- **Binary data**: Use Binary type to upload input images
|
|
863
138
|
|
|
864
|
-
|
|
139
|
+
## 📚 Additional Documentation
|
|
865
140
|
|
|
866
|
-
-
|
|
867
|
-
-
|
|
868
|
-
- ✨ 统一节点设计
|
|
869
|
-
- 🆕 **AI Agent 集成**:通过 Custom Code Tool 在 AI Agent 中生成图像
|
|
870
|
-
- 🆕 添加自然语言参数解析(支持 size, steps, cfg, seed, negative 等)
|
|
871
|
-
- 🆕 提供完整的 AI Agent 工具模板和文档
|
|
872
|
-
- 📚 新增 `agent-tools/` 目录,包含 Custom Code Tool 代码和示例
|
|
873
|
-
- 🐛 修复视频输出 bug
|
|
874
|
-
- 🔒 增强 SSRF 防护
|
|
875
|
-
- 📝 改进错误处理和资源管理
|
|
876
|
-
- 🔧 修复自定义节点安装问题(使用正确的 custom 目录)
|
|
877
|
-
- 🔧 修复重复节点安装问题
|
|
141
|
+
- **[AI Agent Usage Guide](AI-AGENT-USAGE.md)** - Detailed AI Agent integration guide
|
|
142
|
+
- **[Development Guide](DEVELOPMENT.md)** - Contributing and development setup
|
|
878
143
|
|
|
879
|
-
|
|
144
|
+
## 🤝 Contributing
|
|
880
145
|
|
|
881
|
-
|
|
882
|
-
- 支持多种预定义操作类型
|
|
146
|
+
Contributions are welcome! Please see [DEVELOPMENT.md](DEVELOPMENT.md) for guidelines.
|