@fieldwangai/agentflow 0.1.159 → 0.1.162

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.
Files changed (118) hide show
  1. package/bin/lib/auth.mjs +231 -14
  2. package/bin/lib/catalog-flows.mjs +12 -1
  3. package/bin/lib/cli-auth-page.mjs +103 -0
  4. package/bin/lib/control-while.mjs +336 -0
  5. package/bin/lib/flow-dsl/codegen.mjs +74 -11
  6. package/bin/lib/flow-dsl/ir.mjs +33 -2
  7. package/bin/lib/flow-dsl/lint.mjs +128 -3
  8. package/bin/lib/flow-dsl/parser.mjs +168 -4
  9. package/bin/lib/marketplace.mjs +10 -2
  10. package/bin/lib/node-package-manifest.mjs +7 -2
  11. package/bin/lib/node-ui-kit.mjs +156 -0
  12. package/bin/lib/paths.mjs +2 -0
  13. package/bin/lib/skill-runtime.mjs +6 -0
  14. package/bin/lib/table.mjs +2 -3
  15. package/bin/lib/ui-server.mjs +220 -17
  16. package/bin/lib/workspace-draft.mjs +74 -0
  17. package/bin/lib/workspace-flow-store.mjs +11 -2
  18. package/bin/lib/workspace-graph-merge.mjs +3 -0
  19. package/bin/lib/workspace-routes.mjs +307 -5
  20. package/bin/lib/workspace-server.mjs +598 -11
  21. package/bin/pipeline/validate-flow.mjs +3 -3
  22. package/builtin/nodes/control_parse_json.md +25 -0
  23. package/builtin/nodes/control_subflow_call.md +27 -0
  24. package/builtin/nodes/control_while.md +124 -0
  25. package/builtin/nodes/provide_json.md +14 -0
  26. package/builtin/nodes/workspace_subflow_input.md +14 -0
  27. package/builtin/pipelines/new/workspace.flow.js +1 -1
  28. package/builtin/pipelines/subflow-preview/workspace.flow.js +29 -0
  29. package/builtin/pipelines/subflow-preview/workspace.layout.json +38 -0
  30. package/builtin/pipelines/subflow-preview/workspace.nodes.json +19 -0
  31. package/builtin/pipelines/subflow-preview/workspace.state.json +93 -0
  32. package/builtin/pipelines/while-subflow-preview/workspace.flow.js +55 -0
  33. package/builtin/pipelines/while-subflow-preview/workspace.layout.json +66 -0
  34. package/builtin/pipelines/while-subflow-preview/workspace.nodes.json +49 -0
  35. package/builtin/pipelines/while-subflow-preview/workspace.state.json +194 -0
  36. package/builtin/web-ui/dist/assets/{WorkflowAssistantThread-CY19DsYq.js → WorkflowAssistantThread-CTrXOZ00.js} +1 -1
  37. package/builtin/web-ui/dist/assets/index-5uJFccdX.css +1 -0
  38. package/builtin/web-ui/dist/assets/index-BeUfNQRL.js +873 -0
  39. package/builtin/web-ui/dist/index.html +2 -2
  40. package/package.json +6 -1
  41. package/reference/flow-control-capabilities.md +41 -16
  42. package/shared/slot-types.js +58 -0
  43. package/skills/agentflow-author-flow/SKILL.md +81 -8
  44. package/skills/agentflow-author-flow/agents/openai.yaml +3 -3
  45. package/skills/agentflow-cli/SKILL.md +130 -25
  46. package/skills/agentflow-cli/agents/openai.yaml +2 -2
  47. package/skills/agentflow-cli/runtime/bin/lib/skill-runtime.mjs +14765 -0
  48. package/skills/agentflow-cli/runtime/builtin/nodes/agent_subAgent.md +34 -0
  49. package/skills/agentflow-cli/runtime/builtin/nodes/control_agent_toBool.md +26 -0
  50. package/skills/agentflow-cli/runtime/builtin/nodes/control_anyOne.md +19 -0
  51. package/skills/agentflow-cli/runtime/builtin/nodes/control_cancelled.md +26 -0
  52. package/skills/agentflow-cli/runtime/builtin/nodes/control_cd_workspace.md +50 -0
  53. package/skills/agentflow-cli/runtime/builtin/nodes/control_delay.md +31 -0
  54. package/skills/agentflow-cli/runtime/builtin/nodes/control_end.md +13 -0
  55. package/skills/agentflow-cli/runtime/builtin/nodes/control_if.md +21 -0
  56. package/skills/agentflow-cli/runtime/builtin/nodes/control_interval_loop.md +55 -0
  57. package/skills/agentflow-cli/runtime/builtin/nodes/control_load_mcp.md +24 -0
  58. package/skills/agentflow-cli/runtime/builtin/nodes/control_load_skills.md +35 -0
  59. package/skills/agentflow-cli/runtime/builtin/nodes/control_parse_json.md +25 -0
  60. package/skills/agentflow-cli/runtime/builtin/nodes/control_start.md +13 -0
  61. package/skills/agentflow-cli/runtime/builtin/nodes/control_subflow_call.md +27 -0
  62. package/skills/agentflow-cli/runtime/builtin/nodes/control_toBool.md +27 -0
  63. package/skills/agentflow-cli/runtime/builtin/nodes/control_user_workspace.md +24 -0
  64. package/skills/agentflow-cli/runtime/builtin/nodes/control_wait_until.md +34 -0
  65. package/skills/agentflow-cli/runtime/builtin/nodes/control_while.md +124 -0
  66. package/skills/agentflow-cli/runtime/builtin/nodes/display_ascii.md +24 -0
  67. package/skills/agentflow-cli/runtime/builtin/nodes/display_chart.md +32 -0
  68. package/skills/agentflow-cli/runtime/builtin/nodes/display_code.md +39 -0
  69. package/skills/agentflow-cli/runtime/builtin/nodes/display_html.md +32 -0
  70. package/skills/agentflow-cli/runtime/builtin/nodes/display_image.md +36 -0
  71. package/skills/agentflow-cli/runtime/builtin/nodes/display_markdown.md +24 -0
  72. package/skills/agentflow-cli/runtime/builtin/nodes/display_mermaid.md +24 -0
  73. package/skills/agentflow-cli/runtime/builtin/nodes/display_react_app.md +53 -0
  74. package/skills/agentflow-cli/runtime/builtin/nodes/display_table.md +32 -0
  75. package/skills/agentflow-cli/runtime/builtin/nodes/provide_bool.md +14 -0
  76. package/skills/agentflow-cli/runtime/builtin/nodes/provide_file.md +14 -0
  77. package/skills/agentflow-cli/runtime/builtin/nodes/provide_json.md +14 -0
  78. package/skills/agentflow-cli/runtime/builtin/nodes/provide_password.md +14 -0
  79. package/skills/agentflow-cli/runtime/builtin/nodes/provide_str.md +14 -0
  80. package/skills/agentflow-cli/runtime/builtin/nodes/tool_display_share_link.md +47 -0
  81. package/skills/agentflow-cli/runtime/builtin/nodes/tool_get_env.md +20 -0
  82. package/skills/agentflow-cli/runtime/builtin/nodes/tool_git_checkout.md +70 -0
  83. package/skills/agentflow-cli/runtime/builtin/nodes/tool_git_worktree_load.md +73 -0
  84. package/skills/agentflow-cli/runtime/builtin/nodes/tool_git_worktree_unload.md +52 -0
  85. package/skills/agentflow-cli/runtime/builtin/nodes/tool_gitlab_create_mr.md +114 -0
  86. package/skills/agentflow-cli/runtime/builtin/nodes/tool_jenkins_build.md +67 -0
  87. package/skills/agentflow-cli/runtime/builtin/nodes/tool_load_key.md +26 -0
  88. package/skills/agentflow-cli/runtime/builtin/nodes/tool_nodejs.md +52 -0
  89. package/skills/agentflow-cli/runtime/builtin/nodes/tool_print.md +21 -0
  90. package/skills/agentflow-cli/runtime/builtin/nodes/tool_save_key.md +26 -0
  91. package/skills/agentflow-cli/runtime/builtin/nodes/tool_set_run_env.md +38 -0
  92. package/skills/agentflow-cli/runtime/builtin/nodes/tool_user_ask.md +27 -0
  93. package/skills/agentflow-cli/runtime/builtin/nodes/tool_user_check.md +26 -0
  94. package/skills/agentflow-cli/runtime/builtin/nodes/tool_wecom_send_app_markdown.md +57 -0
  95. package/skills/agentflow-cli/runtime/builtin/nodes/tool_wecom_send_group_markdown.md +45 -0
  96. package/skills/agentflow-cli/runtime/builtin/nodes/workspace_one_click_task.md +44 -0
  97. package/skills/agentflow-cli/runtime/builtin/nodes/workspace_run.md +16 -0
  98. package/skills/agentflow-cli/runtime/builtin/nodes/workspace_scheduled_run.md +16 -0
  99. package/skills/agentflow-cli/runtime/builtin/nodes/workspace_subflow_input.md +14 -0
  100. package/skills/agentflow-cli/runtime/package.json +6 -0
  101. package/skills/agentflow-cli/scripts/agentflow-auth-store.mjs +113 -0
  102. package/skills/agentflow-cli/scripts/agentflow-cli.mjs +393 -28
  103. package/skills/agentflow-cli/scripts/agentflow-runtime.mjs +11 -4
  104. package/skills/agentflow-flow-add-instances/SKILL.md +2 -2
  105. package/skills/agentflow-flow-dsl/SKILL.md +83 -10
  106. package/skills/agentflow-flow-dsl/agents/openai.yaml +2 -2
  107. package/skills/agentflow-flow-dsl/references/node-calls.md +3 -0
  108. package/skills/agentflow-flow-dsl/references/subflow-authoring.md +230 -0
  109. package/skills/agentflow-flow-edit-node-fields/SKILL.md +3 -3
  110. package/skills/agentflow-flow-recipes/SKILL.md +1 -1
  111. package/skills/agentflow-flow-recipes/references/recipes.md +1 -2
  112. package/skills/agentflow-flow-sync-ui/SKILL.md +1 -1
  113. package/skills/agentflow-node-dsl/SKILL.md +44 -13
  114. package/skills/agentflow-node-reference/references/builtin-nodes.md +25 -0
  115. package/skills/agentflow-workspace-markdown/SKILL.md +1 -1
  116. package/builtin/web-ui/dist/assets/index-B9ppXv7e.css +0 -1
  117. package/builtin/web-ui/dist/assets/index-CdEQWRrp.js +0 -872
  118. package/skills/agentflow-workspace-graph/SKILL.md +0 -85
@@ -30,8 +30,8 @@
30
30
  @keyframes af-app-loading-slide { from { transform: translateX(-115%); } to { transform: translateX(250%); } }
31
31
  @media (prefers-reduced-motion: reduce) { .af-app-loading__track span { width: 100%; animation: none; } }
32
32
  </style>
33
- <script type="module" crossorigin src="/assets/index-CdEQWRrp.js"></script>
34
- <link rel="stylesheet" crossorigin href="/assets/index-B9ppXv7e.css">
33
+ <script type="module" crossorigin src="/assets/index-BeUfNQRL.js"></script>
34
+ <link rel="stylesheet" crossorigin href="/assets/index-5uJFccdX.css">
35
35
  </head>
36
36
  <body>
37
37
  <div id="root">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fieldwangai/agentflow",
3
- "version": "0.1.159",
3
+ "version": "0.1.162",
4
4
  "description": "Orchestration system for long-running complex agent tasks using Cursor, OpenCode, Claude Code, or Codex as execution backends",
5
5
  "type": "module",
6
6
  "main": "bin/agentflow.mjs",
@@ -40,6 +40,7 @@
40
40
  "bin",
41
41
  "agents",
42
42
  "skills",
43
+ "shared",
43
44
  "builtin/nodes",
44
45
  "builtin/pipelines",
45
46
  "builtin/web-ui/dist",
@@ -49,6 +50,7 @@
49
50
  "test": "node --test test/*.test.mjs",
50
51
  "postinstall": "node bin/ensure-workspace-reference.mjs",
51
52
  "build:web-ui": "cd builtin/web-ui && npm install && npm run build",
53
+ "build:agentflow-cli-skill-runtime": "node scripts/build-agentflow-cli-skill-runtime.mjs",
52
54
  "build:website": "cd website && npm install && npm run build",
53
55
  "dev": "AGENTFLOW_DEV=1 node bin/agentflow.mjs ui",
54
56
  "dev:web": "cd builtin/web-ui && npm run dev",
@@ -68,5 +70,8 @@
68
70
  "ora": "^9.3.0",
69
71
  "sharp": "^0.34.5",
70
72
  "update-notifier": "^7.0.0"
73
+ },
74
+ "devDependencies": {
75
+ "esbuild": "^0.28.2"
71
76
  }
72
77
  }
@@ -33,21 +33,45 @@
33
33
 
34
34
  ---
35
35
 
36
- ## 3. 图必须是 DAG(无环)
36
+ ## 3. 图必须是 DAG(无环),重复执行用 control_while
37
37
 
38
38
  Workspace 运行计划做拓扑排序,**遇到环直接抛 `Workspace run graph contains a cycle`**,整次运行失败。
39
39
 
40
40
  因此:
41
41
 
42
42
  - **禁止**从下游节点连边回到上游节点。
43
- - 「检查 → 修复 → 复检」要**向前展开**成多个节点,而不是回流成环。
44
- - 需要「反复重试直到达标」时,把循环放进**单个节点内部**——`agent_subAgent` 的 body 里让 agent 自己迭代,或 `tool_nodejs` 的脚本里自己 while 循环。
43
+ - 「检查 → 修复 → 复检」涉及不同角色时要**向前展开**成多个节点,而不是回流成环。
44
+ - 同一个确定性动作需要反复推进时,用 `control_while`。它在单节点状态机里重复 step 命令,
45
+ 父图仍是 DAG;`continue` 继续、`wait` 暂停且不跑下游、`done` 放行下游、`fail` 失败。
46
+
47
+ step 的 stdout 必须严格是一个 JSON 对象:
48
+
49
+ ```json
50
+ {"decision":"continue|wait|done|fail","state":{},"summary":"本轮摘要"}
51
+ ```
52
+
53
+ 循环上下文通过 `AGENTFLOW_WHILE_STATE`、绝对轮次 `AGENTFLOW_WHILE_ITERATION`、
54
+ `AGENTFLOW_WHILE_MAX_ITERATIONS`、`AGENTFLOW_WHILE_TIMEOUT_MS` 和稳定的逐轮
55
+ `AGENTFLOW_WHILE_IDEMPOTENCY_KEY` 注入。外部写操作应尽量把该幂等键传给目标 API。stdout
56
+ 留给决策对象,普通进度写 stderr。`maxIterations` 默认 20,`timeout` 默认 30m,二者在
57
+ `wait` 后恢复时继续累计;checkpoint 同时保留 state、history、已用执行时间和下一轮编号。
58
+ 输入变化会重置 checkpoint,指纹匹配但 checkpoint 损坏时会拒绝恢复,避免静默重放副作用。
45
59
 
46
60
  旧版用于成环的 `control_anyOne` / `control_toBool` / `control_agent_toBool` / `control_interval_loop` 均已下线。
47
61
 
48
62
  ---
49
63
 
50
- ## 4. 展示结果(Display
64
+ ## 4. 子流程(Subflow
65
+
66
+ 可复用的一段节点拓扑用 `flow.input`、`flow.subflow` 和 `flow.call` 表达。子流程内部继续使用
67
+ 标准 AgentFlow 节点与边,父流程只连接调用节点的契约引脚;禁止跨边界直接连内部节点。
68
+
69
+ 每次调用拥有独立 `callFrameId`,内部事件同时带 `parentNodeId` 和 `subflowId`。禁止递归调用。
70
+ 当前第一版不支持子流程内部 `wait/deferred`,遇到会明确失败;可恢复调用栈补齐后再开放。
71
+
72
+ ---
73
+
74
+ ## 5. 展示结果(Display)
51
75
 
52
76
  把产出槽连到 `display_*` 节点的 `content` 输入即可在画布上渲染:
53
77
 
@@ -66,7 +90,7 @@ Workspace 运行计划做拓扑排序,**遇到环直接抛 `Workspace run grap
66
90
 
67
91
  ---
68
92
 
69
- ## 5. 工具节点与 Agent 节点选型
93
+ ## 6. 工具节点与 Agent 节点选型
70
94
 
71
95
  **核心原则:能用工具节点确定性执行的,不要用 agent_subAgent。**
72
96
 
@@ -76,7 +100,7 @@ Workspace 运行计划做拓扑排序,**遇到环直接抛 `Workspace run grap
76
100
  | 向用户展示结果 | **display_\*** | 专用展示节点 |
77
101
  | 需要 AI 理解上下文、做判断、生成内容 | **agent_subAgent** | 需要 LLM 推理能力 |
78
102
 
79
- ### 5.1 tool_nodejs 直接执行模式(推荐)
103
+ ### 6.1 tool_nodejs 直接执行模式(推荐)
80
104
 
81
105
  在 instance 中设置 `script` 字段,运行时**跳过 AI 直接 spawn 命令**:
82
106
 
@@ -99,7 +123,7 @@ write_summary:
99
123
  - **成败判定**:以脚本进程 **exit code** 为准(0 = success,非 0 = failed)。
100
124
  - **stdout → result**:脚本 stdout 直接作为 result 槽位内容,纯文本即可。**不要用 JSON 封装 stdout。**
101
125
 
102
- ### 5.2 判断标准
126
+ ### 6.2 判断标准
103
127
 
104
128
  问自己:**"这个步骤的行为是否完全由输入决定,不需要 AI 推理?"**
105
129
 
@@ -108,7 +132,7 @@ write_summary:
108
132
  - **否** → 用 `agent_subAgent`
109
133
  - 例:根据需求撰写文档、分析代码并提出修改方案、理解上下文后做决策
110
134
 
111
- ### 5.3 `script` 与 `body` 的职责(必须遵守)
135
+ ### 6.3 `script` 与 `body` 的职责(必须遵守)
112
136
 
113
137
  | 字段 | 职责 | 有 `script` 时 | 无 `script` 时 |
114
138
  |------|------|---------------|---------------|
@@ -137,7 +161,7 @@ bad_example:
137
161
  调用 API 获取数据,解析 JSON,提取关键字段保存到文件
138
162
  ```
139
163
 
140
- ### 5.4 常见误用
164
+ ### 6.4 常见误用
141
165
 
142
166
  | 用户需求 | 错误做法 | 正确做法 |
143
167
  |----------|----------|----------|
@@ -146,7 +170,7 @@ bad_example:
146
170
  | 注入密钥 | 写死在 flow 里 | `tool_set_run_env` 或运行时环境变量 |
147
171
  | 复杂 AI 推理/生成 | tool_nodejs + body 写自然语言 | agent_subAgent(需 LLM 能力时必须用 agent) |
148
172
 
149
- ### 5.5 节点单一职责(必须遵守)
173
+ ### 6.5 节点单一职责(必须遵守)
150
174
 
151
175
  **每个节点只做一件事,工作内容保持专注和专一。**
152
176
 
@@ -167,17 +191,18 @@ bad_example:
167
191
 
168
192
  ---
169
193
 
170
- ## 6. 常见流程模式
194
+ ## 7. 常见流程模式
171
195
 
172
196
  1. **线性链**:Run → A → B → … → display
173
197
  2. **条件分支**:… → provide_bool → **control_if** → next1 连分支A、next2 连分支B(true 走 output-0,false 走 output-1)
174
- 3. **并行**:同一个 output 扇出到多个下游节点,无依赖的分支会并行执行,各自往下走
175
- 4. **检查修复 复检**:向前排成 检查节点 → 修复节点 → 复检节点 → control_if(通过走后续,不通过走汇报节点)。**不要连回上游**
176
- 5. **批量任务**:拆解节点产出 `- [ ]` 清单 执行节点在内部逐项推进control_if 按完成情况分支
198
+ 3. **控制扇出**:同一个 output 扇出到多个下游节点;当前 Workspace 运行时按拓扑序串行执行
199
+ 4. **单步收敛**:Runcontrol_while(重复同一 step)→ 下游;wait 时停在 While
200
+ 5. **检查修复复检**:不同角色向前排成多个节点。**不要连回上游**
201
+ 6. **批量任务**:拆解节点产出清单 → control_while 每轮推进一项 → done 后汇总
177
202
 
178
203
  ---
179
204
 
180
- ## 7. Edge 与 Handle 注意点
205
+ ## 8. Edge 与 Handle 注意点
181
206
 
182
207
  - **Fan-out 允许,Fan-in 禁止**:一个 output handle 可连多个 input(扇出),但**一个 input handle 只允许一条入边**(禁止扇入)。同一 `target + targetHandle` 不得出现在多条 edge 中——运行时仅取首条匹配,其余静默丢失。若需替换连线,先删旧边再加新边。
183
208
  - **禁止回流边**:任何从下游连回上游的边都会让运行计划判定成环,整次运行失败。
@@ -188,6 +213,6 @@ bad_example:
188
213
 
189
214
  ---
190
215
 
191
- ## 8. 图与 USER_PROMPT 的读写一致性
216
+ ## 9. 图与 USER_PROMPT 的读写一致性
192
217
 
193
218
  ${USER_PROMPT} 中描述的「读取」「写入」应与图中的 **handler 节点**(input/output 通过 edge 连接的节点)对应:描述的每项「读」应有节点的 input 入边,每项「写」应有节点的 output 出边。详见 [flow-prompt-handler-check.md](./flow-prompt-handler-check.md)。
@@ -0,0 +1,58 @@
1
+ const SLOT_TYPE_ALIASES = new Map([
2
+ ["文本", "text"],
3
+ ["str", "text"],
4
+ ["string", "text"],
5
+ ["文件", "file"],
6
+ ["path", "file"],
7
+ ["节点", "node"],
8
+ ["flow", "node"],
9
+ ["control", "node"],
10
+ ["boolean", "bool"],
11
+ ["布尔", "bool"],
12
+ ["object", "json"],
13
+ ]);
14
+
15
+ /**
16
+ * Lossless assignments that do not need an adapter node.
17
+ * JSON can always be serialized as text; text cannot safely become JSON
18
+ * without parsing and validation, so the reverse direction is deliberately
19
+ * absent.
20
+ */
21
+ const LOSSLESS_ASSIGNMENTS = new Set([
22
+ "json>text",
23
+ ]);
24
+
25
+ export const SLOT_TYPE_COLORS = Object.freeze({
26
+ text: "#2196f3",
27
+ file: "#4caf50",
28
+ node: "#ff9800",
29
+ bool: "#9c27b0",
30
+ json: "#00bcd4",
31
+ image: "#ec407a",
32
+ any: "#9e9e9e",
33
+ });
34
+
35
+ export function normalizeSlotType(type) {
36
+ const raw = String(type ?? "").trim().toLowerCase();
37
+ return SLOT_TYPE_ALIASES.get(raw) || raw || "node";
38
+ }
39
+
40
+ export function slotTypeCompatibility(sourceType, targetType) {
41
+ const source = normalizeSlotType(sourceType);
42
+ const target = normalizeSlotType(targetType);
43
+ if (!source || !target) return { compatible: false, kind: "incompatible", source, target };
44
+ if (source === "any" || target === "any") return { compatible: true, kind: "any", source, target };
45
+ if (source === target) return { compatible: true, kind: "exact", source, target };
46
+ if (LOSSLESS_ASSIGNMENTS.has(`${source}>${target}`)) {
47
+ return { compatible: true, kind: "lossless", source, target };
48
+ }
49
+ return { compatible: false, kind: "incompatible", source, target };
50
+ }
51
+
52
+ export function areSlotTypesCompatible(sourceType, targetType) {
53
+ return slotTypeCompatibility(sourceType, targetType).compatible;
54
+ }
55
+
56
+ export function getSlotTypeColor(type) {
57
+ return SLOT_TYPE_COLORS[normalizeSlotType(type)] || "#9e9e9e";
58
+ }
@@ -1,16 +1,89 @@
1
1
  ---
2
2
  name: agentflow-author-flow
3
- description: Legacy Pipeline authoring is retired. Redirect new AgentFlow creation and editing requests to the Workspace Graph skill and server-side Workspace preview.
3
+ description: Create an AgentFlow from a user's idea, iterate in a private runnable Draft Workspace, show the preview URL, test and inspect outputs, then publish the approved graph and explicitly configure Scheduled Run activation. Use for end-to-end requests such as “创建一个流程”, “给我 Preview”, “试运行并动态修改”, “发布这个 Flow”, “配置定时运行”, “make a temporary flow”, or “run it on a schedule”.
4
4
  ---
5
5
 
6
- # Legacy Pipeline Authoring(已下线)
6
+ # AgentFlow Flow Lifecycle
7
7
 
8
- 旧的 Flow/Pipeline (`flow.yaml` + `control_start/control_end`) 执行功能已经下线。此 skill 不再创建、发布或执行新的 Pipeline。
8
+ Orchestrate the complete authoring lifecycle. Use `agentflow-flow-dsl` for graph structure,
9
+ `agentflow-node-dsl` when deterministic custom code is needed, and `agentflow-cli` for Draft,
10
+ execution, publication, and schedule operations. Read those selected Skills completely before acting.
9
11
 
10
- 新任务统一使用:
12
+ ## Required lifecycle
11
13
 
12
- - `agentflow-workspace-graph`:创建或修改 `workspace.flow.js`
13
- - `agentflow-cli workspace-preview`:上传到服务器临时 Workspace,打开所见即所得画布
14
- - Workspace 页面中的 `Run` / `Scheduled Run`:执行 Workspace
14
+ 1. Check `agentflow-cli config`. Require authorization and `localRuntime.available: true`. If
15
+ authorization is missing, run `agentflow-cli auth start`, return the URL to the user, and run
16
+ `auth complete` after approval; never ask the user to paste a personal Token. The Runtime is
17
+ bundled with the Skill; if unavailable, update/reinstall the SkillHub package instead of
18
+ installing an npm CLI.
19
+ 2. Translate the user's idea into a local `workspace.flow.js`. Search the remote node catalog before
20
+ creating a custom node package.
21
+ 3. Run DSL lint, then layout. Do not upload an invalid or unreadable graph.
22
+ 4. Create a private runnable Draft:
15
23
 
16
- 历史 `flow.yaml` 仅用于读取、迁移和审计,不得作为新功能的实现目标。不要调用 `agentflow apply`、`/api/flow/run` 或创建 `control_start/control_end`。
24
+ ```bash
25
+ node <agentflow-cli-skill-dir>/scripts/agentflow-cli.mjs draft-create \
26
+ --file <flowDir> --ttl-seconds 7200
27
+ ```
28
+
29
+ Add `--with-dependencies` when `<flowDir>/nodes/` exists. Return the Draft URL to the user. A Draft
30
+ is hidden from the formal Flow list, writable in the Workspace UI, and runnable. Its Scheduled Run
31
+ nodes are always suppressed and cannot trigger real Cron jobs.
32
+
33
+ 5. Test the intended Run or Scheduled Run entry manually with `draft-run`. Inspect returned display
34
+ outputs; use run status and logs for failures or long-running work. Obtain confirmation before a
35
+ test that calls an external service or has business side effects.
36
+ 6. Keep the revision returned by every Draft mutation. Apply feedback to the same Draft. If the user
37
+ edited in the UI, pull the Draft before changing a stale local DSL:
38
+
39
+ ```bash
40
+ node <agentflow-cli-skill-dir>/scripts/agentflow-cli.mjs draft-pull \
41
+ --draft-id <draft-id> --output <flowDir> --replace
42
+ ```
43
+
44
+ Then edit locally, lint/layout again, and update against that exact revision:
45
+
46
+ ```bash
47
+ node <agentflow-cli-skill-dir>/scripts/agentflow-cli.mjs draft-update \
48
+ --draft-id <draft-id> \
49
+ --base-revision <last-revision> \
50
+ --file <flowDir>
51
+ ```
52
+
53
+ On a revision conflict, stop and pull before reapplying the intended change; never overwrite UI
54
+ edits with a stale local graph. Repeat preview and execution until the user accepts the actual
55
+ output. Do not treat lint, Mock data, or a visual-only preview as production-equivalent acceptance.
56
+ 7. Before publication, state the exact Draft ID, target Flow ID, destination, and schedule mode. Wait
57
+ for explicit confirmation. Publication defaults to personal space and scheduling disabled.
58
+ 8. Promote the exact tested Draft:
59
+
60
+ ```bash
61
+ node <agentflow-cli-skill-dir>/scripts/agentflow-cli.mjs draft-publish \
62
+ --draft-id <draft-id> \
63
+ --flow-id <flow-id> \
64
+ --target-space personal \
65
+ --schedule disabled
66
+ ```
67
+
68
+ Use `--schedule enabled` only when the user explicitly wants automatic execution. Promotion is
69
+ create-only; do not replace an existing Flow without a separate explicit decision.
70
+ 9. When scheduling is enabled, verify the returned schedule and run `schedule-list --flow-id
71
+ <flow-id>`. Report it as armed only when `enabled: true`, status is not invalid/error, and
72
+ `nextRunAt` is present. Include Cron, timezone, overlap policy, and next run time in the handoff.
73
+
74
+ ## Schedule changes after publication
75
+
76
+ Use `schedule-enable`, `schedule-disable`, or `schedule-set`; do not republish the whole graph merely
77
+ to flip an operational switch. Use `schedule-run-now` for a manual verification of the scheduled
78
+ entry. Re-read `schedule-list` after every mutation.
79
+
80
+ ## Safety gates
81
+
82
+ - Keep read-only `workspace-preview` for sharing only. It cannot run or save; use a Draft for review
83
+ plus execution.
84
+ - Never activate Draft schedules. Draft configuration is design data only.
85
+ - Do not embed tokens, passwords, cookies, or local absolute paths in DSL or node packages.
86
+ - Do not claim external integrations are ready from Mock execution. Require the user's real account,
87
+ network, credentials, and downstream evidence.
88
+ - If the user requests publication but has not reviewed the Draft output, stop at the Draft and ask
89
+ for confirmation.
@@ -1,4 +1,4 @@
1
1
  interface:
2
- display_name: "AgentFlow Flow Authoring"
3
- short_description: "Generate, preview, confirm, and publish AgentFlow flows"
4
- default_prompt: "Use $agentflow-author-flow to generate a local AgentFlow, open its platform-style preview, and publish it after I confirm."
2
+ display_name: "AgentFlow 流程创作"
3
+ short_description: "创建、预览、试运行、修改、发布并配置定时 Flow"
4
+ default_prompt: "使用 $agentflow-author-flow 把我的想法做成可运行 Draft,和我一起修改;确认后再发布,并按我的选择配置定时运行。"
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: agentflow-cli
3
- description: Direct AgentFlow operation through a bundled token-backed CLI, without MCP. Use when Codex needs to search, publish, install, or synchronize versioned node packages; pull or publish portable Workspace DSL flows; upload previews; run or inspect Workspace graphs; or read logs and display outputs through AgentFlow HTTP APIs using AGENTFLOW_TOKEN from env or .env.
3
+ description: Direct AgentFlow operation through a bundled browser-authorized CLI, without MCP or npm. Use when Codex needs to authorize AgentFlow access, create, update, run, or publish temporary Workspace drafts; search, publish, install, or synchronize versioned node packages; pull or publish portable Workspace DSL flows; manage scheduled runs; upload read-only previews; run or inspect Workspace graphs; or read logs and display outputs through AgentFlow HTTP APIs.
4
4
  ---
5
5
 
6
6
  # AgentFlow CLI
@@ -52,21 +52,44 @@ For other SkillHub-supported agents, change the agent name:
52
52
  skillhub install agentflow-cli --global --agent claude-code
53
53
  ```
54
54
 
55
- After installation, configure only the direct API token. Do not add an MCP server for this skill.
55
+ After installation, authorize the CLI through the AgentFlow browser page. Do not add an MCP server for this skill.
56
+ The Skill already includes the version-matched local Runtime used for Workspace DSL parsing,
57
+ lint/layout, and node-package operations. Do not install an npm package or put `agentflow` on
58
+ `PATH`. `AGENTFLOW_PACKAGE_ROOT` and `--agentflow-package-root` are development overrides only.
56
59
 
57
- Install or update the `@fieldwangai/agentflow` CLI as the local runtime and keep `agentflow` on
58
- `PATH`. The bundled skill intentionally does not copy AgentFlow's parser/runtime modules. It locates
59
- the runtime from an explicit `--agentflow-package-root`, `AGENTFLOW_PACKAGE_ROOT`, the current
60
- project's `node_modules`, or the `agentflow` executable on `PATH`.
61
-
62
- Verify both token and runtime discovery before local DSL or node-package work:
60
+ Verify both authorization and runtime discovery before local DSL or node-package work:
63
61
 
64
62
  ```bash
65
63
  node <skill-dir>/scripts/agentflow-cli.mjs config
66
64
  ```
67
65
 
68
- Require `localRuntime.available: true`. Pure remote reporting commands can still run without a local
69
- runtime, but package creation, installation, Flow pull/publish, and Workspace graph parsing cannot.
66
+ Require `localRuntime.available: true`. A normal SkillHub installation resolves
67
+ `<skill-dir>/runtime`; if it does not, reinstall or update `agentflow-cli` from SkillHub rather than
68
+ installing a separate CLI package. Pure remote reporting commands can still run without a local
69
+ Runtime, but package creation, installation, Flow pull/publish, and Workspace graph parsing cannot.
70
+
71
+ ## Browser authorization
72
+
73
+ When `config` reports `hasToken: false`, do not ask the user to paste a token. Start a non-blocking
74
+ authorization and return its `verificationUrl`:
75
+
76
+ ```bash
77
+ node <skill-dir>/scripts/agentflow-cli.mjs auth start
78
+ ```
79
+
80
+ The user opens the URL, logs in to AgentFlow if necessary, reviews the requested access, and clicks
81
+ Allow. After the user says authorization is complete, exchange the pending one-time request:
82
+
83
+ ```bash
84
+ node <skill-dir>/scripts/agentflow-cli.mjs auth complete
85
+ node <skill-dir>/scripts/agentflow-cli.mjs auth status
86
+ ```
87
+
88
+ `auth start` never prints the secret device code. `auth complete` saves a separate CLI credential in
89
+ `~/.agentflow/auth.json` with owner-only permissions; it never copies the browser cookie. Use
90
+ `AGENTFLOW_AUTH_FILE` only for isolated automation or tests. Revoke the CLI Session and clear its
91
+ local profile with `auth logout`. Do not send the authorization URL to anyone except the requesting
92
+ user; although it contains no access token, it represents an active approval request.
70
93
 
71
94
  ## Configuration
72
95
 
@@ -75,10 +98,12 @@ The CLI reads configuration in this order:
75
98
  1. CLI flags: `--base-url`, `--token`
76
99
  2. Environment variables: `AGENTFLOW_BASE_URL`, `AGENTFLOW_TOKEN`, `AGENTFLOW_SESSION_TOKEN`
77
100
  3. Env files: `AGENTFLOW_ENV_FILE`, then `.env`, `.agentflow.env`, then `~/.agentflow.env`
101
+ 4. Browser-authorized profile: `~/.agentflow/auth.json`
78
102
 
79
103
  Default base URL: `http://ai.mengma.bigo.inner/`.
80
104
 
81
- Required token: `AGENTFLOW_TOKEN` or `AGENTFLOW_SESSION_TOKEN`. Never print the token in the final answer or logs.
105
+ For CI or service accounts, `AGENTFLOW_TOKEN` or `AGENTFLOW_SESSION_TOKEN` overrides the saved
106
+ profile. Never print any token in the final answer or logs.
82
107
 
83
108
  Example `.env`:
84
109
 
@@ -104,16 +129,14 @@ List flows:
104
129
  node <skill-dir>/scripts/agentflow-cli.mjs list-flows
105
130
  ```
106
131
 
107
- For a package used only in the current local checkout, use the packaged AgentFlow CLI (the
108
- Node DSL workflow is documented in `agentflow-node-dsl`):
132
+ Validate and lay out Workspace DSL with the same bundled CLI:
109
133
 
110
134
  ```bash
111
- agentflow marketplace list --json
112
- agentflow marketplace publish-node ./my-node --json
113
- agentflow validate MyFlow --json
135
+ node <skill-dir>/scripts/agentflow-cli.mjs dsl-lint --file <flowDir>
136
+ node <skill-dir>/scripts/agentflow-cli.mjs dsl-layout --file <flowDir>
114
137
  ```
115
138
 
116
- These commands copy a package only into the current workspace marketplace.
139
+ Add `--all` to `dsl-layout` only for a new graph or an explicitly requested full rearrangement.
117
140
 
118
141
  To distribute a complete package directory (including `scripts/`, `templates/`, or assets) through
119
142
  an AgentFlow server, use the token-backed commands. The CLI packs the directory as ZIP; `index.mjs`
@@ -158,8 +181,8 @@ import myNode from "marketplace:my_node@1.0.0";
158
181
  const result = myNode("My node", { input: "value" });
159
182
  ```
160
183
 
161
- Run `agentflow flow dsl lint <flowDir>` with that workspace as the current project before publishing
162
- the flow. `publish-flow` also checks that the server contains every exact imported version before it
184
+ Run the bundled `dsl-lint` command with that workspace as `--workspace-root` before publishing the
185
+ flow. `publish-flow` also checks that the server contains every exact imported version before it
163
186
  writes the Flow. Do not unpack ZIPs by hand or copy only `index.mjs`; relative package files are part
164
187
  of the node's versioned content.
165
188
 
@@ -169,7 +192,8 @@ Publish a new local Flow after the user has reviewed it:
169
192
  node <skill-dir>/scripts/agentflow-cli.mjs publish-flow \
170
193
  --flow-id release-check \
171
194
  --file .workspace/agentflow/pipelines/release-check/flow.yaml \
172
- --target-space personal
195
+ --target-space personal \
196
+ --schedule disabled
173
197
  ```
174
198
 
175
199
  When the reviewed code Flow contains `nodes/`, publish the Flow and all complete package directories
@@ -180,6 +204,7 @@ node <skill-dir>/scripts/agentflow-cli.mjs publish-flow \
180
204
  --flow-id release-check \
181
205
  --file .workspace/agentflow/pipelines/release-check \
182
206
  --target-space personal \
207
+ --schedule disabled \
183
208
  --with-dependencies
184
209
  ```
185
210
 
@@ -188,7 +213,7 @@ and rewrites relative node imports only in the upload payload. It never edits lo
188
213
  `workspace.flow.js`. Without `--with-dependencies`, `publish-flow` continues to reject Flow directories
189
214
  that contain `nodes/` or `workspace.nodes.json` rather than silently dropping them.
190
215
 
191
- Destinations are `personal`, `workspace`, and `team`. `team` creates a workspace Flow and shares it as editor with the current account's active team. Publishing is create-only by default. If the exact Flow already exists, stop and ask whether to update it; only after explicit confirmation rerun with `--replace`. Replacement first reads the server revision and submits it with the update.
216
+ Destinations are `personal`, `workspace`, and `team`. `team` creates a workspace Flow and shares it as editor with the current account's active team. `publish-flow` defaults to `--schedule disabled`; use `enabled` only after explicit confirmation, and reserve `preserve` for migrations. Publishing is create-only by default. If the exact Flow already exists, stop and ask whether to update it; only after explicit confirmation rerun with `--replace`. Replacement first reads the server revision and submits it with the update.
192
217
 
193
218
  Read one flow graph:
194
219
 
@@ -249,6 +274,82 @@ This is for visual review only. It does not publish a formal Flow/Pipeline or
249
274
  create schedules. The returned temporary project is hidden from the normal
250
275
  Flow list and must not be treated as a durable source of truth.
251
276
 
277
+ ## Runnable Workspace drafts
278
+
279
+ For the review-and-test loop, use a Draft instead of the read-only Preview. A Draft is private to
280
+ the token owner, hidden from the formal Flow list, writable in the Workspace UI, runnable, and
281
+ automatically removed after its TTL. Scheduled Run nodes may be present, but Draft saves never arm
282
+ real schedules.
283
+
284
+ Create one after DSL lint and layout:
285
+
286
+ ```bash
287
+ node <skill-dir>/scripts/agentflow-cli.mjs draft-create \
288
+ --file .workspace/agentflow/pipelines/<flow-id> \
289
+ --ttl-seconds 7200
290
+ ```
291
+
292
+ If the Flow contains local `nodes/`, add `--with-dependencies`; this uploads the complete immutable
293
+ packages before creating the Draft. Reuse the returned Draft and URL while iterating:
294
+
295
+ ```bash
296
+ node <skill-dir>/scripts/agentflow-cli.mjs draft-pull \
297
+ --draft-id <draft-id> \
298
+ --output .workspace/agentflow/pipelines/<flow-id> \
299
+ --replace
300
+
301
+ node <skill-dir>/scripts/agentflow-cli.mjs draft-update \
302
+ --draft-id <draft-id> \
303
+ --base-revision <revision-from-create-update-or-pull> \
304
+ --file .workspace/agentflow/pipelines/<flow-id>
305
+
306
+ node <skill-dir>/scripts/agentflow-cli.mjs draft-run \
307
+ --draft-id <draft-id> \
308
+ --run-node-id <run-node-id> \
309
+ --input topic=hello
310
+ ```
311
+
312
+ `draft-update` resets previous runtime output unless `--keep-runtime` is passed. It requires the
313
+ revision returned by the preceding create, update, or pull and rejects stale updates. If the user
314
+ edited the Draft in the UI, run `draft-pull` before changing the local DSL; do not retry a 409 with
315
+ an invented or freshly fetched revision against an unrefreshed local file.
316
+
317
+ After the user explicitly approves the tested Draft, promote that exact graph. Scheduling defaults
318
+ to disabled; choose `enabled` only after the user asked to activate it:
319
+
320
+ ```bash
321
+ node <skill-dir>/scripts/agentflow-cli.mjs draft-publish \
322
+ --draft-id <draft-id> \
323
+ --flow-id <flow-id> \
324
+ --target-space personal \
325
+ --schedule disabled
326
+ ```
327
+
328
+ Promotion is create-only and keeps the Draft until TTL expiry for recovery. `--schedule enabled`
329
+ enables every Scheduled Run entry and fails when the Draft has none. `--schedule preserve` retains
330
+ the graph values and is for advanced migrations, not the normal confirmation flow.
331
+
332
+ ## Scheduled Run operations
333
+
334
+ Manage published Workspace schedules explicitly:
335
+
336
+ ```bash
337
+ node <skill-dir>/scripts/agentflow-cli.mjs schedule-list --flow-id <flow-id>
338
+ node <skill-dir>/scripts/agentflow-cli.mjs schedule-enable \
339
+ --flow-id <flow-id> --schedule-node-id <node-id>
340
+ node <skill-dir>/scripts/agentflow-cli.mjs schedule-disable \
341
+ --flow-id <flow-id> --schedule-node-id <node-id>
342
+ node <skill-dir>/scripts/agentflow-cli.mjs schedule-set \
343
+ --flow-id <flow-id> --schedule-node-id <node-id> \
344
+ --enabled true --cron "0 8 * * *" --timezone Asia/Shanghai --overlap-policy skip
345
+ node <skill-dir>/scripts/agentflow-cli.mjs schedule-run-now \
346
+ --flow-id <flow-id> --schedule-node-id <node-id>
347
+ ```
348
+
349
+ After publishing or changing a schedule, require `enabled`, `lastStatus`, and `nextRunAt` in the
350
+ returned schedule state before reporting it as armed. Draft schedule configuration is visible and
351
+ editable but returns `suppressed: true` and never gets a `nextRunAt` registration.
352
+
252
353
  Run a Workspace graph:
253
354
 
254
355
  ```bash
@@ -306,14 +407,18 @@ The only admin write exception is audited version-membership repair. Read its st
306
407
 
307
408
  ## Workflow
308
409
 
309
- 1. Check token availability with `config`.
410
+ 1. Check authorization with `config`. If missing, use `auth start`, give the URL to the user, then
411
+ run `auth complete` only after the user approves it.
310
412
  2. Use `list-workspace` or `list-flows` to discover Flow/Pipeline targets only. Use `node-package-search` before creating a new code node. Use `publish-flow` only after a local Flow has passed validation and the user has confirmed the preview.
311
- 3. Use `run` to start the flow. If the task needs the generated page/text, inspect returned `displayOutputs` or call `display-outputs`.
312
- 4. Use `status`, `list-run-by-workspace`, and `logs` when a run is active, failed, or needs debugging.
413
+ 3. For a new user-authored Flow, prefer `draft-create` `draft-run`/`draft-update` explicit user confirmation `draft-publish`. Keep `workspace-preview` for read-only sharing.
414
+ 4. Use `run` to start a published flow. If the task needs the generated page/text, inspect returned `displayOutputs` or call `display-outputs`.
415
+ 5. Use `status`, `list-run-by-workspace`, and `logs` when a run is active, failed, or needs debugging. Use `schedule-list` after every schedule mutation or scheduled publish.
313
416
 
314
417
  ## Failure Handling
315
418
 
316
- - If the CLI says the token is missing, ask the user to set `AGENTFLOW_TOKEN` in env or `.env`.
419
+ - If authorization is missing, use `auth start` and return the URL. Do not ask the user to paste a
420
+ personal Token into the conversation. Use environment Tokens only for non-interactive CI or
421
+ service accounts.
317
422
  - If `publish-flow` returns 409, do not add `--replace` automatically. Ask the user to confirm updating the existing Flow.
318
423
  - If team publishing says no active team is assigned, keep the local draft and ask the user to choose personal/workspace or have an admin assign the account to a team.
319
424
  - If the API returns 401/403, do not retry with a printed token. Ask the user to refresh the token.
@@ -1,4 +1,4 @@
1
1
  interface:
2
2
  display_name: "AgentFlow CLI"
3
- short_description: "Search packages and operate portable AgentFlow workspaces"
4
- default_prompt: "Use $agentflow-cli to search node packages and operate a portable AgentFlow workspace."
3
+ short_description: "Draft, test, publish, and schedule AgentFlow workspaces"
4
+ default_prompt: "Use $agentflow-cli to create a runnable Draft, test it, publish it after confirmation, and manage its schedule."