digitalsee-ai-flow-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +631 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +87 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/flow.d.ts.map +1 -0
- package/dist/api/flow.js +61 -0
- package/dist/api/flow.js.map +1 -0
- package/dist/api/knowledge.d.ts.map +1 -0
- package/dist/api/knowledge.js +32 -0
- package/dist/api/knowledge.js.map +1 -0
- package/dist/api/node.d.ts.map +1 -0
- package/dist/api/node.js +65 -0
- package/dist/api/node.js.map +1 -0
- package/dist/api/variables.d.ts.map +1 -0
- package/dist/api/variables.js +24 -0
- package/dist/api/variables.js.map +1 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +73 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/flow/account.d.ts.map +1 -0
- package/dist/commands/flow/account.js +41 -0
- package/dist/commands/flow/account.js.map +1 -0
- package/dist/commands/flow/analyze.d.ts.map +1 -0
- package/dist/commands/flow/analyze.js +109 -0
- package/dist/commands/flow/analyze.js.map +1 -0
- package/dist/commands/flow/edge.d.ts.map +1 -0
- package/dist/commands/flow/edge.js +167 -0
- package/dist/commands/flow/edge.js.map +1 -0
- package/dist/commands/flow/helpers.d.ts.map +1 -0
- package/dist/commands/flow/helpers.js +213 -0
- package/dist/commands/flow/helpers.js.map +1 -0
- package/dist/commands/flow/list.d.ts.map +1 -0
- package/dist/commands/flow/list.js +40 -0
- package/dist/commands/flow/list.js.map +1 -0
- package/dist/commands/flow/node.d.ts.map +1 -0
- package/dist/commands/flow/node.js +425 -0
- package/dist/commands/flow/node.js.map +1 -0
- package/dist/commands/flow/test.d.ts.map +1 -0
- package/dist/commands/flow/test.js +55 -0
- package/dist/commands/flow/test.js.map +1 -0
- package/dist/commands/flow/variables.d.ts.map +1 -0
- package/dist/commands/flow/variables.js +177 -0
- package/dist/commands/flow/variables.js.map +1 -0
- package/dist/commands/flow.d.ts.map +1 -0
- package/dist/commands/flow.js +23 -0
- package/dist/commands/flow.js.map +1 -0
- package/dist/commands/knowledge.d.ts.map +1 -0
- package/dist/commands/knowledge.js +196 -0
- package/dist/commands/knowledge.js.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +74 -0
- package/dist/index.js.map +1 -0
- package/dist/services/flowAnalyzer.d.ts.map +1 -0
- package/dist/services/flowAnalyzer.js +366 -0
- package/dist/services/flowAnalyzer.js.map +1 -0
- package/dist/services/skillGenerator.d.ts.map +1 -0
- package/dist/services/skillGenerator.js +241 -0
- package/dist/services/skillGenerator.js.map +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +114 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/encoding.d.ts.map +1 -0
- package/dist/utils/encoding.js +21 -0
- package/dist/utils/encoding.js.map +1 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +375 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +115 -0
- package/dist/utils/output.js.map +1 -0
- package/package.json +27 -0
- package/tsconfig.json +22 -0
package/README.md
ADDED
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
# AI Flow CLI
|
|
2
|
+
|
|
3
|
+
AI Flow 连接流命令行管理工具,通过 AI Flow v2 API 管理连接流和节点配置。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
cd AI-Flow-Cli
|
|
9
|
+
npm install
|
|
10
|
+
npm run build
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 快速开始
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# 1. 配置 API 连接
|
|
17
|
+
ai-flow config set --base-url https://localhost:9900 --token <your-token> --insecure
|
|
18
|
+
|
|
19
|
+
# 2. 查看配置
|
|
20
|
+
ai-flow config show
|
|
21
|
+
|
|
22
|
+
# 3. 列出所有连接流
|
|
23
|
+
ai-flow flow list
|
|
24
|
+
|
|
25
|
+
# 4. 分析连接流
|
|
26
|
+
ai-flow flow analyze <flowId>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 配置
|
|
30
|
+
|
|
31
|
+
配置分为两级,优先级:项目级 (`.ai-flowrc`) > 全局 (`~/.ai-flow-cli/config.json`)。
|
|
32
|
+
|
|
33
|
+
默认值:
|
|
34
|
+
- `baseUrl`: `https://localhost:9900`
|
|
35
|
+
- `insecure`: `true`(跳过 SSL 证书验证)
|
|
36
|
+
|
|
37
|
+
### config set
|
|
38
|
+
|
|
39
|
+
设置 API 配置项。
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
ai-flow config set --base-url <url> --token <token>
|
|
43
|
+
ai-flow config set --base-url https://localhost:9900 --token abc123 --insecure
|
|
44
|
+
ai-flow config set --token abc123 --project # 保存到项目级 .ai-flowrc
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### config show
|
|
48
|
+
|
|
49
|
+
显示当前生效的配置。
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
ai-flow config show
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
输出示例:
|
|
56
|
+
```
|
|
57
|
+
配置来源: ~/.ai-flow-cli/config.json
|
|
58
|
+
baseUrl: https://localhost:9900
|
|
59
|
+
token: abcd****1234
|
|
60
|
+
insecure: true
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### config reset
|
|
64
|
+
|
|
65
|
+
重置配置。
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
ai-flow config reset # 重置全局配置
|
|
69
|
+
ai-flow config reset --project # 重置项目级配置
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 连接流操作
|
|
75
|
+
|
|
76
|
+
### flow list
|
|
77
|
+
|
|
78
|
+
列出所有连接流。
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
ai-flow flow list
|
|
82
|
+
ai-flow flow list --page 1 --size 20
|
|
83
|
+
ai-flow flow list --filter "测试"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### flow analyze
|
|
87
|
+
|
|
88
|
+
分析指定连接流的所有节点及执行顺序,输出包括:
|
|
89
|
+
- 流概览(ID、名称、状态、节点/边数量)
|
|
90
|
+
- 节点清单表格
|
|
91
|
+
- 拓扑排序后的执行顺序
|
|
92
|
+
- ASCII 依赖关系图
|
|
93
|
+
- 节点分组统计(触发器/动作/条件/循环/AI/其他)
|
|
94
|
+
- 每节点配置详情(config_schema 字段及当前值)
|
|
95
|
+
- Edges 连接表
|
|
96
|
+
|
|
97
|
+
支持四种输出格式:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
ai-flow flow analyze <flowId> # table(默认,全量输出)
|
|
101
|
+
ai-flow flow analyze <flowId> --format brief # 简要模式:流概览 + 节点清单 + 执行顺序
|
|
102
|
+
ai-flow flow analyze <flowId> --format graph # ASCII 流程图模式:流概览 + 增强型流程图
|
|
103
|
+
ai-flow flow analyze <flowId> --format json # 纯 JSON 格式
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`--format graph` 输出示例:
|
|
107
|
+
```
|
|
108
|
+
=================== 连接流分析: 测试流 ===================
|
|
109
|
+
ID 2056988777387053057
|
|
110
|
+
名称 测试流
|
|
111
|
+
...
|
|
112
|
+
|
|
113
|
+
--- 流程图 ---
|
|
114
|
+
┌──────────────────────────┐
|
|
115
|
+
│ Webhook · 接收数据v2 │
|
|
116
|
+
│ N2056988936204374018 │
|
|
117
|
+
│ 触发器 │
|
|
118
|
+
└────────────┬─────────────┘
|
|
119
|
+
│
|
|
120
|
+
▼
|
|
121
|
+
┌──────────────────────────┐
|
|
122
|
+
│ 流程变量 · 创建变量 │
|
|
123
|
+
│ N2056989510396203009 │
|
|
124
|
+
│ 动作 │
|
|
125
|
+
└────────────┬─────────────┘
|
|
126
|
+
│
|
|
127
|
+
▼
|
|
128
|
+
┌──────────────────────────┐
|
|
129
|
+
│ 延迟 · 延迟 │
|
|
130
|
+
│ N2057287474235510785 │
|
|
131
|
+
│ 动作 │
|
|
132
|
+
└──────────────────────────┘
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### flow test
|
|
136
|
+
|
|
137
|
+
测试运行指定节点。可先通过 `--data`/`--data-file` 更新节点配置再测试。
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
ai-flow flow test <nodeId>
|
|
141
|
+
ai-flow flow test <nodeId> --flow-id <flowId>
|
|
142
|
+
ai-flow flow test <nodeId> --data-file ./config.json
|
|
143
|
+
ai-flow flow test <nodeId> --data '{"millisecond": "2000"}'
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
`config.json` 示例(扁平键值,键名为配置字段的 `name`):
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"millisecond": "2000"
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### flow node create
|
|
154
|
+
|
|
155
|
+
在连接流中创建新节点。
|
|
156
|
+
|
|
157
|
+
目前可视化编辑中节点的大小为 300 * 78 , 为了不显示拥挤 建议 至少以 500 * 200 为基准进行坐标设置
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# 创建普通节点
|
|
161
|
+
ai-flow flow node create \
|
|
162
|
+
--flow-id <flowId> \
|
|
163
|
+
--connector-id <connectorId> \
|
|
164
|
+
--action-id <actionId> \
|
|
165
|
+
--data-file ./node-config.json \
|
|
166
|
+
--position-x 400 --position-y 200
|
|
167
|
+
|
|
168
|
+
# 使用内联 JSON 数据
|
|
169
|
+
ai-flow flow node create \
|
|
170
|
+
--flow-id <flowId> \
|
|
171
|
+
--connector-id <connectorId> \
|
|
172
|
+
--action-id <actionId> \
|
|
173
|
+
--data '{"url": "https://api.example.com", "method": "POST"}'
|
|
174
|
+
|
|
175
|
+
# 指定节点类型
|
|
176
|
+
ai-flow flow node create \
|
|
177
|
+
--flow-id <flowId> \
|
|
178
|
+
--connector-id <connectorId> \
|
|
179
|
+
--action-id <actionId> \
|
|
180
|
+
--node-type LoopNode
|
|
181
|
+
|
|
182
|
+
# 创建触发器节点(流中第一个节点)
|
|
183
|
+
ai-flow flow node create \
|
|
184
|
+
--flow-id <flowId> \
|
|
185
|
+
--connector-id <connectorId> \
|
|
186
|
+
--action-id <actionId> \
|
|
187
|
+
--trigger
|
|
188
|
+
|
|
189
|
+
# 创建节点并配置错误处理
|
|
190
|
+
ai-flow flow node create \
|
|
191
|
+
--flow-id <flowId> \
|
|
192
|
+
--connector-id <connectorId> \
|
|
193
|
+
--action-id <actionId> \
|
|
194
|
+
--error-handler-file ./error-handler.json
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
| 选项 | 必填 | 默认值 | 说明 |
|
|
198
|
+
|------|------|--------|------|
|
|
199
|
+
| `--flow-id` | 是 | — | 连接流 ID |
|
|
200
|
+
| `--connector-id` | 是 | — | 连接器 ID |
|
|
201
|
+
| `--action-id` | 是 | — | 动作 ID |
|
|
202
|
+
| `--trigger` | 否 | `false` | 作为触发器节点,流无节点时会提示启用 |
|
|
203
|
+
| `--node-type` | 否 | 首个节点 `StartEventNode`,否则 `ActionNode` | 节点类型或动作类型 |
|
|
204
|
+
| `--account-id` | 否 | — | 账号实例 ID(需要账号鉴权时指定) |
|
|
205
|
+
| `--error-handler-file` | 否 | — | 错误处理配置 JSON 文件 |
|
|
206
|
+
| `--data-file` | 否 | — | JSON 文件,覆盖配置字段值 |
|
|
207
|
+
| `--data` | 否 | — | JSON 字符串,覆盖配置字段值(与 `--data-file` 互斥) |
|
|
208
|
+
| `--position-x` | 否 | `250` | 节点 X 坐标 |
|
|
209
|
+
| `--position-y` | 否 | `150` | 节点 Y 坐标 |
|
|
210
|
+
|
|
211
|
+
流程:
|
|
212
|
+
1. 调 `GET /acm/actions/v2` 获取 action 的 config_schema 作为模板
|
|
213
|
+
2. 自动填充字段默认值(或通过 `--data`/`--data-file` 覆盖)
|
|
214
|
+
3. POST 创建节点
|
|
215
|
+
|
|
216
|
+
> 不传 `--data`/`--data-file` 时使用默认值填充。`--data`/`--data-file` 内容为 `{"fieldName": "value"}` 格式的扁平 JSON,键名对应配置字段的 `name`,会合并到节点 `properties` 中。对于 ActionNode 会遍历 `sub_params` 按名称匹配;对于特殊节点类型(ConditionNode/LoopNode/SwitchNode)直接合并到 `properties` 顶层。详见 [特殊节点类型配置指南](docs/special-node-types.md)。`--trigger` 标志会筛选触发器类型的动作。
|
|
217
|
+
|
|
218
|
+
> **账号配置**:当动作的 `config_schema` 包含 `account_schema_id` 时,必须通过 `--account-id` 指定账号实例 ID。若未指定,CLI 会自动列出可用的账号实例供选择。
|
|
219
|
+
|
|
220
|
+
> **错误处理配置**:通过 `--error-handler-file` 指定 JSON 文件配置节点的错误处理策略,格式如下。`process_type`: `1`=中断流程, `2`=忽略错误;`warn_type`: `1`=启用告警, `0`=禁用。
|
|
221
|
+
> ```json
|
|
222
|
+
> {
|
|
223
|
+
> "retry": true,
|
|
224
|
+
> "retry_times": 3,
|
|
225
|
+
> "retry_interval": 5,
|
|
226
|
+
> "step_factor": 1.5,
|
|
227
|
+
> "max_retry_interval": 60,
|
|
228
|
+
> "warn_type": 0,
|
|
229
|
+
> "notify_url": "",
|
|
230
|
+
> "process_type": 1,
|
|
231
|
+
> "apply_all": false
|
|
232
|
+
> }
|
|
233
|
+
> ```
|
|
234
|
+
|
|
235
|
+
### flow node show
|
|
236
|
+
|
|
237
|
+
获取节点详细信息,包括配置参数、可选值、当前属性值等。
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
ai-flow flow node show <nodeId>
|
|
241
|
+
ai-flow flow node show <nodeId> --format json
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
输出示例:
|
|
245
|
+
```
|
|
246
|
+
==================== 节点详情: N2056988936204374018 ====================
|
|
247
|
+
节点 ID N2056988936204374018
|
|
248
|
+
节点类型 触发器
|
|
249
|
+
连接器 Webhook
|
|
250
|
+
动作 接收数据v2
|
|
251
|
+
状态 正常
|
|
252
|
+
位置 (250, 150)
|
|
253
|
+
备注 (无)
|
|
254
|
+
描述 (无)
|
|
255
|
+
账号 ID (无)
|
|
256
|
+
账号 Schema ID (无)
|
|
257
|
+
|
|
258
|
+
--- 配置参数 (3) ---
|
|
259
|
+
字段名 显示名 类型 必填 当前值 可选值
|
|
260
|
+
method HTTP Method SELECT 是 POST 获取(GET), 提交(POST), 更新(PUT), 删除(DELETE)
|
|
261
|
+
content_type Content Type SELECT 否 application/json -
|
|
262
|
+
timeout 超时时间(ms) NUMBER 否 5000 -
|
|
263
|
+
|
|
264
|
+
--- 当前属性值 ---
|
|
265
|
+
{ "method": "POST", "content_type": "application/json", "timeout": 5000 }
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### flow node update
|
|
269
|
+
|
|
270
|
+
更新连接流中的节点配置。
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
# 通过 JSON 文件更新配置
|
|
274
|
+
ai-flow flow node update <nodeId> \
|
|
275
|
+
--flow-id <flowId> \
|
|
276
|
+
--data-file ./node-config.json
|
|
277
|
+
|
|
278
|
+
# 通过内联 JSON 更新配置(扁平键值,深度合并到现有 properties)
|
|
279
|
+
ai-flow flow node update <nodeId> \
|
|
280
|
+
--flow-id <flowId> \
|
|
281
|
+
--data '{"properties": {"name":"value"}}'
|
|
282
|
+
|
|
283
|
+
# 更新条件分支节点的 or_list
|
|
284
|
+
ai-flow flow node update <nodeId> \
|
|
285
|
+
--flow-id <flowId> \
|
|
286
|
+
--data '{"or_list":[{"and_list":[{"query":"{{N123.value}}","operator":"gt","value":"100"}]}]}'
|
|
287
|
+
ai-flow flow node update <nodeId> \
|
|
288
|
+
--flow-id <flowId> \
|
|
289
|
+
--position-x 400 --position-y 200
|
|
290
|
+
|
|
291
|
+
# 更新节点备注
|
|
292
|
+
ai-flow flow node update <nodeId> \
|
|
293
|
+
--flow-id <flowId> \
|
|
294
|
+
--note "处理用户登录请求"
|
|
295
|
+
|
|
296
|
+
# 替换连接器/动作
|
|
297
|
+
ai-flow flow node update <nodeId> \
|
|
298
|
+
--flow-id <flowId> \
|
|
299
|
+
--connector-id <newConnectorId> \
|
|
300
|
+
--action-id <newActionId>
|
|
301
|
+
|
|
302
|
+
# 更换账号
|
|
303
|
+
ai-flow flow node update <nodeId> \
|
|
304
|
+
--flow-id <flowId> \
|
|
305
|
+
--account-id <accountId>
|
|
306
|
+
|
|
307
|
+
# 配置错误处理
|
|
308
|
+
ai-flow flow node update <nodeId> \
|
|
309
|
+
--flow-id <flowId> \
|
|
310
|
+
--error-handler-file ./error-handler.json
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
| 选项 | 必填 | 说明 |
|
|
314
|
+
|------|------|------|
|
|
315
|
+
| `--flow-id` | 是 | 连接流 ID |
|
|
316
|
+
| `--data-file` | 否 | JSON 文件,更新节点配置值 |
|
|
317
|
+
| `--data` | 否 | JSON 字符串,更新节点配置值(与 `--data-file` 互斥) |
|
|
318
|
+
| `--position-x` | 否 | 节点 X 坐标 |
|
|
319
|
+
| `--position-y` | 否 | 节点 Y 坐标 |
|
|
320
|
+
| `--note` | 否 | 节点备注 |
|
|
321
|
+
| `--connector-id` | 否 | 更换连接器 ID |
|
|
322
|
+
| `--action-id` | 否 | 更换动作 ID |
|
|
323
|
+
| `--account-id` | 否 | 更换账号实例 ID |
|
|
324
|
+
| `--error-handler-file` | 否 | 错误处理配置 JSON 文件 |
|
|
325
|
+
|
|
326
|
+
> `--data` 更新时会以节点当前 `properties` 为基准进行深度合并(`deepMergePlain`),仅更新指定的字段,未指定字段保持不变。特殊节点类型(ConditionNode 的 `or_list`、LoopNode 的 `type`/`start`/`end` 等)同样通过 `--data` 写入 `properties`。详见 [特殊节点类型配置指南](docs/special-node-types.md)。
|
|
327
|
+
|
|
328
|
+
### flow node delete
|
|
329
|
+
|
|
330
|
+
删除连接流中的节点。
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
# 交互确认后删除
|
|
334
|
+
ai-flow flow node delete <nodeId> --flow-id <flowId>
|
|
335
|
+
|
|
336
|
+
# 跳过确认直接删除
|
|
337
|
+
ai-flow flow node delete <nodeId> --flow-id <flowId> --force
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
| 选项 | 必填 | 说明 |
|
|
341
|
+
|------|------|------|
|
|
342
|
+
| `--flow-id` | 是 | 连接流 ID |
|
|
343
|
+
| `--force` | 否 | 跳过确认提示,直接删除 |
|
|
344
|
+
|
|
345
|
+
### flow account list
|
|
346
|
+
|
|
347
|
+
列出连接器下的可用账号实例。
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
ai-flow flow account list <connectorId>
|
|
351
|
+
ai-flow flow account list <connectorId> --account-schema-id <id>
|
|
352
|
+
ai-flow flow account list <connectorId> --format json
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
| 选项 | 必填 | 说明 |
|
|
356
|
+
|------|------|------|
|
|
357
|
+
| `--account-schema-id` | 否 | 按账号模型过滤 |
|
|
358
|
+
| `--format` | 否 | 输出格式: `table` 或 `json` |
|
|
359
|
+
|
|
360
|
+
## flow edge connect
|
|
361
|
+
|
|
362
|
+
连接节点(支持单条和批量)。通过 `--source-handle` / `--target-handle` 连接到多端点节点的特定出口/入口。
|
|
363
|
+
|
|
364
|
+
**handle 说明**:部分节点有多个输出端点(多出口),连接时必须指定 `--source-handle` 选择正确的分支。常见 handle:
|
|
365
|
+
|
|
366
|
+
| Handle ID | 出现节点 | 含义 |
|
|
367
|
+
|-----------|---------|------|
|
|
368
|
+
| `output` / `input` | 大部分节点 | 默认出口/入口,不指定时使用 |
|
|
369
|
+
| `done` | LoopNode, SelfLoopNode | 循环完成后的出口(右侧上方) |
|
|
370
|
+
| `loop` | LoopNode, SelfLoopNode | 继续循环的出口(右侧下方) |
|
|
371
|
+
| `true` | ConditionNode | 条件为真时的出口(右侧上方) |
|
|
372
|
+
| `false` | ConditionNode | 条件为假时的出口(右侧下方) |
|
|
373
|
+
| `chat_model` | AgentNode, BrowserNode | 连接 AI 语言模型 |
|
|
374
|
+
| `memory` | AgentNode | 连接 AI 记忆 |
|
|
375
|
+
| `tools` | AgentNode | 连接 AI 工具/MCP 服务 |
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
# 单条连接(默认 handle:source=output, target=input)
|
|
379
|
+
ai-flow flow edge connect \
|
|
380
|
+
--flow-id <flowId> \
|
|
381
|
+
--source <sourceNodeId> \
|
|
382
|
+
--target <targetNodeId>
|
|
383
|
+
|
|
384
|
+
# 指定句柄 — 从条件节点的 true 分支连接到目标
|
|
385
|
+
ai-flow flow edge connect \
|
|
386
|
+
--flow-id <flowId> \
|
|
387
|
+
--source <conditionNodeId> \
|
|
388
|
+
--target <targetNodeId> \
|
|
389
|
+
--source-handle true \
|
|
390
|
+
--target-handle input
|
|
391
|
+
|
|
392
|
+
# 指定句柄 — 从循环节点的 done 出口连接
|
|
393
|
+
ai-flow flow edge connect \
|
|
394
|
+
--flow-id <flowId> \
|
|
395
|
+
--source <loopNodeId> \
|
|
396
|
+
--target <nextNodeId> \
|
|
397
|
+
--source-handle done
|
|
398
|
+
|
|
399
|
+
# 指定句柄 — 从循环节点的 loop 出口回连
|
|
400
|
+
ai-flow flow edge connect \
|
|
401
|
+
--flow-id <flowId> \
|
|
402
|
+
--source <loopNodeId> \
|
|
403
|
+
--target <prevNodeId> \
|
|
404
|
+
--source-handle loop
|
|
405
|
+
|
|
406
|
+
# 批量连接
|
|
407
|
+
ai-flow flow edge connect \
|
|
408
|
+
--flow-id <flowId> \
|
|
409
|
+
--edges-file ./edges.json
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
`edges.json` 格式:
|
|
413
|
+
```json
|
|
414
|
+
[
|
|
415
|
+
{"source": "N1", "target": "N2"},
|
|
416
|
+
{"source": "N2", "target": "N3", "sourceHandle": "done", "targetHandle": "input"},
|
|
417
|
+
{"source": "N3", "target": "N4"}
|
|
418
|
+
]
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
| 选项 | 必填 | 默认值 | 说明 |
|
|
422
|
+
|------|------|--------|------|
|
|
423
|
+
| `--flow-id` | 是 | — | 连接流 ID |
|
|
424
|
+
| `--source` | 单条模式必填 | — | 源节点 ID |
|
|
425
|
+
| `--target` | 单条模式必填 | — | 目标节点 ID |
|
|
426
|
+
| `--source-handle` | 否 | `output` | 源节点输出句柄 |
|
|
427
|
+
| `--target-handle` | 否 | `input` | 目标节点输入句柄 |
|
|
428
|
+
| `--edges-file` | 批量模式必填 | — | JSON 文件,含边数组 |
|
|
429
|
+
|
|
430
|
+
### flow edge disconnect
|
|
431
|
+
|
|
432
|
+
删除边(断开节点连接)。
|
|
433
|
+
|
|
434
|
+
```bash
|
|
435
|
+
# 删除单条边
|
|
436
|
+
ai-flow flow edge disconnect --flow-id <flowId> --edge-ids <edgeId>
|
|
437
|
+
|
|
438
|
+
# 删除多条边
|
|
439
|
+
ai-flow flow edge disconnect --flow-id <flowId> --edge-ids <id1> <id2> <id3>
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
### flow variables show
|
|
443
|
+
|
|
444
|
+
获取连接流中目标节点可用的上游变量。
|
|
445
|
+
|
|
446
|
+
```bash
|
|
447
|
+
ai-flow flow variables show <flowId>
|
|
448
|
+
ai-flow flow variables show <flowId> --node-id <targetNodeId>
|
|
449
|
+
ai-flow flow variables show <flowId> --global # 同时显示全局变量
|
|
450
|
+
ai-flow flow variables show <flowId> --format json # JSON 格式输出
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
| 选项 | 必填 | 默认值 | 说明 |
|
|
454
|
+
|------|------|--------|------|
|
|
455
|
+
| `--node-id` | 否 | 流中第一个节点 | 目标节点 ID |
|
|
456
|
+
| `--global` | 否 | `false` | 同时显示全局变量 |
|
|
457
|
+
| `--format` | 否 | `table` | 输出格式: `table` 或 `json` |
|
|
458
|
+
|
|
459
|
+
输出展示每个上游节点的输出字段树,以及可用的变量引用格式:
|
|
460
|
+
```
|
|
461
|
+
延迟时间 [NUMBER] = 1000 {{N2056988936204374018.millisecond}}
|
|
462
|
+
hook_url [STRING] = https://... {{N2056988936204374018.hook_url}}
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
变量引用语法:`{{N<node_id>.<field_path>}}`
|
|
466
|
+
|
|
467
|
+
### flow variables inject
|
|
468
|
+
|
|
469
|
+
在节点配置中注入变量引用。通过 `--data` 或 `--data-file` 传入包含 `{{Nxxx.field}}` 占位符的 JSON,验证引用的合法性后提交更新。
|
|
470
|
+
|
|
471
|
+
```bash
|
|
472
|
+
# 通过文件
|
|
473
|
+
ai-flow flow variables inject <flowId> <nodeId> \
|
|
474
|
+
--data-file ./config-with-vars.json
|
|
475
|
+
|
|
476
|
+
# 通过内联 JSON
|
|
477
|
+
ai-flow flow variables inject <flowId> <nodeId> \
|
|
478
|
+
--data '{"properties": {"millisecond": "{{N2056988936204374018.value}}"}}' \
|
|
479
|
+
--dry-run
|
|
480
|
+
|
|
481
|
+
# 预览模式(不实际更新)
|
|
482
|
+
ai-flow flow variables inject <flowId> <nodeId> \
|
|
483
|
+
--data-file ./config-with-vars.json \
|
|
484
|
+
--dry-run
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
`config-with-vars.json` 示例(扁平键值,值中使用 `{{N<nodeId>.<fieldPath>}}` 引用上游变量):
|
|
488
|
+
```json
|
|
489
|
+
{
|
|
490
|
+
"millisecond": "{{N2056988936204374018.value}}"
|
|
491
|
+
}
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
---
|
|
495
|
+
|
|
496
|
+
## 知识库
|
|
497
|
+
|
|
498
|
+
### knowledge categories
|
|
499
|
+
|
|
500
|
+
列出所有节点分类(支持分类树展开)。
|
|
501
|
+
|
|
502
|
+
```bash
|
|
503
|
+
ai-flow knowledge categories
|
|
504
|
+
ai-flow knowledge categories --type action
|
|
505
|
+
ai-flow knowledge categories --type trigger
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
### knowledge nodes
|
|
509
|
+
|
|
510
|
+
搜索节点,展示匹配的 connector 及 actions(含 nodeType、connectorId)。通过 `--name` 指定关键字时,会进一步调用 actions 接口获取每个 connector 下的完整匹配动作列表。
|
|
511
|
+
|
|
512
|
+
```bash
|
|
513
|
+
ai-flow knowledge nodes
|
|
514
|
+
ai-flow knowledge nodes <category>
|
|
515
|
+
ai-flow knowledge nodes --name "sql" --flow-id <flowId>
|
|
516
|
+
ai-flow knowledge nodes --name "HTTP" --trigger --page 1 --size 20
|
|
517
|
+
ai-flow knowledge nodes --json
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
| 选项 | 必填 | 默认值 | 说明 |
|
|
521
|
+
|------|------|--------|------|
|
|
522
|
+
| `[category]` | 否 | — | 按分类过滤(如 `action`、`trigger`) |
|
|
523
|
+
| `--name` | 否 | — | 按名称搜索关键字 |
|
|
524
|
+
| `--trigger` | 否 | `false` | 是否搜索触发器节点 |
|
|
525
|
+
| `--flow-id` | 否 | — | 连接流 ID |
|
|
526
|
+
| `--page` | 否 | `1` | 页码 |
|
|
527
|
+
| `--size` | 否 | `50` | 每页数量 |
|
|
528
|
+
| `--json` | 否 | — | 以 JSON 格式输出原始数据 |
|
|
529
|
+
|
|
530
|
+
输出示例:
|
|
531
|
+
```
|
|
532
|
+
=============== 节点列表 (共 2 个) ===============
|
|
533
|
+
|
|
534
|
+
▸ MySQL_连接器 (link-123)
|
|
535
|
+
描述 MySQL 数据库连接器
|
|
536
|
+
类型 builtin
|
|
537
|
+
匹配方式 action_name
|
|
538
|
+
匹配动作 (3):
|
|
539
|
+
sql_query 执行SQL查询 nodeType: ActionNode nodeId: act-001 connectorId: link-123
|
|
540
|
+
sql_insert 插入数据 nodeType: ActionNode nodeId: act-002 connectorId: link-123
|
|
541
|
+
sql_update 更新数据 nodeType: ActionNode nodeId: act-003 connectorId: link-123
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
### knowledge actions
|
|
545
|
+
|
|
546
|
+
列出连接器的所有动作及配置 schema 详情。
|
|
547
|
+
|
|
548
|
+
```bash
|
|
549
|
+
ai-flow knowledge actions <linkId>
|
|
550
|
+
ai-flow knowledge actions <linkId> --trigger # 仅触发器
|
|
551
|
+
ai-flow knowledge actions <linkId> --json # JSON 格式输出
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
### knowledge generate-skills
|
|
555
|
+
|
|
556
|
+
遍历所有分类(action / trigger / tool / mcp / model / memory)下的所有节点和动作,为每个动作生成 Markdown 文档和 JSON 结构化数据文件,按分类类型存储。
|
|
557
|
+
|
|
558
|
+
```bash
|
|
559
|
+
ai-flow knowledge generate-skills ./docs
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
输出:
|
|
563
|
+
```
|
|
564
|
+
docs/
|
|
565
|
+
├── action/
|
|
566
|
+
│ ├── markdown/
|
|
567
|
+
│ │ ├── HTTP_发送请求.md
|
|
568
|
+
│ │ └── ...
|
|
569
|
+
│ └── json/
|
|
570
|
+
│ ├── HTTP_发送请求.json
|
|
571
|
+
│ └── ...
|
|
572
|
+
├── trigger/
|
|
573
|
+
│ ├── markdown/
|
|
574
|
+
│ │ ├── Webhook_接收数据v2.md
|
|
575
|
+
│ │ └── ...
|
|
576
|
+
│ └── json/
|
|
577
|
+
│ └── ...
|
|
578
|
+
├── tool/
|
|
579
|
+
│ └── ...
|
|
580
|
+
├── mcp/
|
|
581
|
+
│ └── ...
|
|
582
|
+
├── model/
|
|
583
|
+
│ └── ...
|
|
584
|
+
└── memory/
|
|
585
|
+
└── ...
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
---
|
|
589
|
+
|
|
590
|
+
## 开发
|
|
591
|
+
|
|
592
|
+
```bash
|
|
593
|
+
npm install
|
|
594
|
+
npm run build # 编译 TypeScript
|
|
595
|
+
npm run dev # watch 模式编译
|
|
596
|
+
node dist/index.js --help
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
## 技术栈
|
|
600
|
+
|
|
601
|
+
- **语言**: TypeScript
|
|
602
|
+
- **CLI 框架**: Commander.js
|
|
603
|
+
- **HTTP 客户端**: axios
|
|
604
|
+
- **终端输出**: chalk
|
|
605
|
+
|
|
606
|
+
## 项目结构
|
|
607
|
+
|
|
608
|
+
```
|
|
609
|
+
src/
|
|
610
|
+
├── index.ts # CLI 入口
|
|
611
|
+
├── commands/
|
|
612
|
+
│ ├── config.ts # ai-flow config
|
|
613
|
+
│ ├── flow.ts # ai-flow flow
|
|
614
|
+
│ └── knowledge.ts # ai-flow knowledge
|
|
615
|
+
├── api/
|
|
616
|
+
│ ├── client.ts # axios 实例(SSL、Token)
|
|
617
|
+
│ ├── flow.ts # 流 CRUD
|
|
618
|
+
│ ├── node.ts # 节点 CRUD + 测试运行
|
|
619
|
+
│ ├── edge.ts # 边管理
|
|
620
|
+
│ ├── knowledge.ts # 分类/节点搜索
|
|
621
|
+
│ └── variables.ts # 全局变量 + 输出树
|
|
622
|
+
├── services/
|
|
623
|
+
│ ├── flowAnalyzer.ts # DAG 拓扑分析
|
|
624
|
+
│ └── skillGenerator.ts # Skills 批量生成
|
|
625
|
+
├── utils/
|
|
626
|
+
│ ├── config.ts # 配置持久化(全局 + 项目级)
|
|
627
|
+
│ ├── output.ts # 终端彩色输出
|
|
628
|
+
│ └── format.ts # 数据转换
|
|
629
|
+
└── types/
|
|
630
|
+
└── index.ts # TypeScript 类型定义
|
|
631
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AACA,OAAc,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAgEjE,wBAAgB,SAAS,IAAI,aAAa,CAKzC;AAED,wBAAgB,WAAW,IAAI,IAAI,CAElC;AAED,wBAAsB,MAAM,CAAC,CAAC,GAAG,GAAG,EAClC,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC3B,OAAO,CAAC,CAAC,CAAC,CAIZ;AAED,wBAAsB,OAAO,CAAC,CAAC,GAAG,GAAG,EACnC,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,GAAG,EACV,MAAM,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,CAAC,CAAC,CAIZ;AAED,wBAAsB,QAAQ,CAAC,CAAC,GAAG,GAAG,EACpC,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,GAAG,EACV,MAAM,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,CAAC,CAAC,CAIZ;AAED,wBAAsB,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAIhE"}
|