@ai-setting/roy-agent-core 1.6.11 → 1.6.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/env/agent/index.js +2 -2
- package/dist/env/event-source/index.js +3 -3
- package/dist/env/index.js +10 -10
- package/dist/env/prompt/index.js +2 -2
- package/dist/env/task/delegate/index.js +3 -3
- package/dist/env/task/index.js +6 -6
- package/dist/env/task/plugins/index.js +2 -2
- package/dist/env/task/storage/index.js +2 -1
- package/dist/env/task/tools/operation/index.js +1 -1
- package/dist/index.js +11 -11
- package/dist/shared/@ai-setting/{roy-agent-core-m38q2azm.js → roy-agent-core-1bvv6s75.js} +3 -1
- package/dist/shared/@ai-setting/{roy-agent-core-wqe84f84.js → roy-agent-core-3bdpnmtg.js} +29 -0
- package/dist/shared/@ai-setting/{roy-agent-core-5w9a1eqa.js → roy-agent-core-7a3gf3tw.js} +2 -2
- package/dist/shared/@ai-setting/roy-agent-core-9abv4ewh.js +1122 -0
- package/dist/shared/@ai-setting/{roy-agent-core-0cftbg62.js → roy-agent-core-asp5p3zx.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-38kbfarg.js → roy-agent-core-cxdnzn17.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-3rs38pf7.js → roy-agent-core-dntkpwqq.js} +8 -8
- package/dist/shared/@ai-setting/{roy-agent-core-trdpar9f.js → roy-agent-core-ms5dp89r.js} +338 -20
- package/dist/shared/@ai-setting/{roy-agent-core-2ek596yd.js → roy-agent-core-q2bw3cwd.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-y5ymc4f8.js → roy-agent-core-q7rt3x8d.js} +45 -13
- package/dist/shared/@ai-setting/roy-agent-core-rn57psp0.js +396 -0
- package/package.json +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-9xby523m.js +0 -961
- package/dist/shared/@ai-setting/roy-agent-core-t94ktchq.js +0 -213
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
BackgroundTaskManager,
|
|
9
9
|
createDelegateTool,
|
|
10
10
|
createStopTool
|
|
11
|
-
} from "./roy-agent-core-
|
|
11
|
+
} from "./roy-agent-core-7a3gf3tw.js";
|
|
12
12
|
import {
|
|
13
13
|
SQLiteTaskStore,
|
|
14
14
|
getDefaultTaskDbPath
|
|
15
|
-
} from "./roy-agent-core-
|
|
15
|
+
} from "./roy-agent-core-9abv4ewh.js";
|
|
16
16
|
import {
|
|
17
17
|
batchArchiveTaskTool,
|
|
18
18
|
batchDeleteTaskTool,
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
getOperationTool,
|
|
32
32
|
listOperationsTool,
|
|
33
33
|
updateOperationTool
|
|
34
|
-
} from "./roy-agent-core-
|
|
34
|
+
} from "./roy-agent-core-rn57psp0.js";
|
|
35
35
|
import {
|
|
36
36
|
TaskHookPoints
|
|
37
37
|
} from "./roy-agent-core-1pg0fepg.js";
|
|
@@ -406,9 +406,9 @@ class TaskComponent extends BaseComponent {
|
|
|
406
406
|
await this.store.createOperation({
|
|
407
407
|
taskId: task.id,
|
|
408
408
|
sessionId,
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
409
|
+
milestoneType: "create",
|
|
410
|
+
milestoneTitle: `Task created: ${task.title}`,
|
|
411
|
+
milestoneDescription: task.description || ""
|
|
412
412
|
});
|
|
413
413
|
const resultCtx = {
|
|
414
414
|
task,
|
|
@@ -499,8 +499,8 @@ class TaskComponent extends BaseComponent {
|
|
|
499
499
|
await this.createOperation({
|
|
500
500
|
taskId: id,
|
|
501
501
|
sessionId,
|
|
502
|
-
|
|
503
|
-
|
|
502
|
+
milestoneType: "completed",
|
|
503
|
+
milestoneTitle: "Task completed"
|
|
504
504
|
});
|
|
505
505
|
this.publishEvent(TaskEntityEventTypes.COMPLETED, { task, sessionId }, sessionId);
|
|
506
506
|
logger2.info(`[TaskComponent] Task completed: ${id}`);
|
|
@@ -66,8 +66,8 @@ var builtInPrompts = {
|
|
|
66
66
|
- **文件浏览 / 读取**:\`ls -la\`、\`cat file.txt\`、\`head -n 20 file.txt\`、\`tail -n 50 log.txt\`、\`grep "pattern" file.txt\`、\`find . -name "*.ts"\`
|
|
67
67
|
- **状态查询**:\`pwd\`、\`date\`、\`whoami\`、\`which node\`、\`git status\`、\`git log -5\`、\`git diff\`
|
|
68
68
|
- **简单测试 / 工具调用**:\`echo "hello"\`、\`node --version\`、\`bun --version\`
|
|
69
|
-
- **调用一行 \`roy-agent\`
|
|
70
|
-
-
|
|
69
|
+
- **调用一行 \`roy-agent\` 查询命令**(如 \`bun packages/cli/dist/bin/roy-agent.js tasks list\`、\`roy-agent workflow list\`、\`roy-agent workflow tag list\`、\`roy-agent workflow search --keyword xxx\`)
|
|
70
|
+
- **例外:创建/注册 workflow 禁止用 bash 手撸**,必须委托给 \`workflow-creator\`(见下文"Workflow 创建委托指南")
|
|
71
71
|
|
|
72
72
|
**\`bash\` 适合 vs 需要委托的边界:**
|
|
73
73
|
- ✅ \`ls -la\`、\`cat file.txt\`、\`grep "TODO" src/*.ts\`、\`git status\`、\`find . -name "*.ts"\` — **直接用 \`bash\` 执行**
|
|
@@ -151,28 +151,67 @@ delegate_task(
|
|
|
151
151
|
)
|
|
152
152
|
\`\`\`
|
|
153
153
|
|
|
154
|
+
### \uD83E\uDD49 Workflow creator:\`workflow-creator\`(用户主动构建 workflow 时使用)
|
|
155
|
+
|
|
156
|
+
专用 sub-agent:与用户**多轮交互式**协作设计 workflow,根据用户的任务/日志/trace/session 信息一步步澄清需求、学习现有模式、生成 YAML 草稿、迭代 validate 直到通过、最后由用户确认后 add。
|
|
157
|
+
|
|
158
|
+
使用场景:
|
|
159
|
+
- 用户说"帮我建一个 workflow 做 XXX"
|
|
160
|
+
- 用户给了 task/trace/log/session 失败信息,想把它抽象成可复用 workflow
|
|
161
|
+
- 用户想根据现有 workflow 改造出一个新变体
|
|
162
|
+
|
|
163
|
+
与 workflow-extract 的区别:
|
|
164
|
+
- workflow-extract:从已完成 task 对话历史**自动**提取(one-shot)
|
|
165
|
+
- workflow-creator:与用户**多轮对话式**协作(interactive)
|
|
166
|
+
|
|
167
|
+
示例:
|
|
168
|
+
\`\`\`
|
|
169
|
+
delegate_task(
|
|
170
|
+
description="构建定制 workflow",
|
|
171
|
+
prompt="用户想要一个 code-review workflow,要求支持自动 node 校验。需要:先学习现有 code-review 工作流,与用户多轮澄清需求,生成 YAML 后 validate 直到通过,最后由用户确认再 add。",
|
|
172
|
+
subagent_type="workflow-creator",
|
|
173
|
+
similar_task_ids=[]
|
|
174
|
+
)
|
|
175
|
+
\`\`\`
|
|
176
|
+
|
|
154
177
|
## 如何处理用户请求
|
|
155
178
|
|
|
156
179
|
1. **理解** — 用户到底想要什么?
|
|
157
180
|
2. **分类** — 如果需要任何超出简单对话的操作 → 委托。如果是问候/一次性回答 → 直接回复。
|
|
158
|
-
3. **选择智能体** — \`roy
|
|
181
|
+
3. **选择智能体** — \`roy\`(默认)、\`workflow-runner\`(调用 workflow)、\`workflow-creator\`(用户主动构建 workflow)
|
|
159
182
|
4. **搜索相似任务并委托** — 在委托前,先使用 \`task_search\` 搜索与当前请求相关的历史任务,将找到的相似任务 ID 填入 \`similar_task_ids\` 参数。在给子智能体的提示词中,始终包含简要指令,要求将工作视为任务一等公民:创建任务(\`task_create\`)、跟踪进度并完成。
|
|
160
183
|
5. **汇报结果** — 向用户总结结果
|
|
161
184
|
|
|
162
|
-
## Workflow
|
|
185
|
+
## Workflow 创建委托指南(重要)
|
|
186
|
+
|
|
187
|
+
⚠️ **当用户要"创建/封装/设计/构建/重做/复刻"一个 workflow 时,default agent 自己不要撸 CLI**。
|
|
163
188
|
|
|
164
|
-
|
|
189
|
+
✅ **必须 \`delegate_task(subagent_type="workflow-creator", ...)\`** — 让专用 sub-agent 处理全过程。
|
|
165
190
|
|
|
166
|
-
###
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
4. **核实结果** — 用 \`roy-agent workflow get <name>\` 或 \`roy-agent workflow list --tag <tag>\` 确认注册成功
|
|
191
|
+
### 为什么必须委托?
|
|
192
|
+
- default agent 用 bash \`workflow add/validate/tag list\` 手写 YAML 容易出错、命名不规范、tag 容易膨胀、节点类型不熟悉
|
|
193
|
+
- workflow-creator 专做这事,6 个工具白名单 + 8 次 validate 迭代 + 学会复用已有 tag
|
|
194
|
+
- 它会先用 \`workflow_list\`/\`workflow_get\` 学习现有命名约定,再 \`workflow_validate\` 直到通过,最后由用户确认后 add
|
|
171
195
|
|
|
172
|
-
###
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
196
|
+
### 快速判断矩阵(在选择 agent 前先看)
|
|
197
|
+
|
|
198
|
+
| 用户意图 | 关键词 | 委托对象 |
|
|
199
|
+
|---|---|---|
|
|
200
|
+
| **运行**已有 workflow | "执行/跑/test/run/workflow X" | \`workflow-runner\` |
|
|
201
|
+
| **从已完成 task 历史里自动提取** | "把这个 task 抽成 workflow"(one-shot) | \`workflow-extract\`(自动触发,无需手动) |
|
|
202
|
+
| **主动设计/封装/改造**新 workflow | "帮建/封装/设计/再造个变体/想基于 XXX 改造" | **\`workflow-creator\`** ⭐ |
|
|
203
|
+
| 其他任务(编码/调研/分析) | "实现/调研/修 bug" | \`roy\`(默认) |
|
|
204
|
+
|
|
205
|
+
### 委托模板
|
|
206
|
+
|
|
207
|
+
\`\`\`bash
|
|
208
|
+
delegate_task(
|
|
209
|
+
description="构建定制 workflow",
|
|
210
|
+
prompt="详细说明用户想要的 workflow 需求 + 任何上下文(task/trace/log/session 摘要)。让 workflow-creator 多轮澄清、validate 直到通过、用户确认后 add。",
|
|
211
|
+
subagent_type="workflow-creator",
|
|
212
|
+
similar_task_ids=[]
|
|
213
|
+
)
|
|
214
|
+
\`\`\`
|
|
176
215
|
|
|
177
216
|
## 行为规则
|
|
178
217
|
|
|
@@ -181,6 +220,7 @@ delegate_task(
|
|
|
181
220
|
3. **保持简洁** — 简短分析,然后立即委托。不要冗长。
|
|
182
221
|
4. **首选 roy** — 首次委托默认使用 \`roy\`
|
|
183
222
|
5. **workflow-runner** — 凡是走 workflow 解决的任务(包括兼容旧名 \`strict-task-agent\` / \`code-review\` / \`bench-agent-host\` / \`workspace-analyzer\` / \`test-workflow-agent\`,自动重写),都委托给它
|
|
223
|
+
5a. ⚠️ **workflow-creator** — 用户说"帮建 workflow" / "封装成 workflow" / "再造个变体" / "想基于 XXX workflow 改造",**必须委托**,default agent 自己**禁止**用 bash \`workflow add/validate/tag list\` 手撸。手撸已废弃,统一走 workflow-creator(与 workflow-extract one-shot 不同,workflow-creator 是多轮对话式协作)
|
|
184
224
|
6. **始终包含任务生命周期** — 每次委托时,指示子智能体使用 \`task_create\` → \`task_update\` → \`task_operation_create\` → \`task_complete\`
|
|
185
225
|
7. **简单回复** — 对于问候、简单问答或结果总结,可以直接回复
|
|
186
226
|
8. **⚠️ 不要 sleep 等待后台任务结果** — \`delegate_task\` 总是后台模式(参见下方"子代理通知自主处理规则"),委托后**立即返回**。**禁止**调用 \`sleep\`、\`wait\`、\`sleep N\` 等任何同步等待命令试图"等子智能体跑完"。原因:
|
|
@@ -703,7 +743,7 @@ roy-agent <command> <subcmd> --help
|
|
|
703
743
|
| \`task_list\` | List tasks with optional filters for status/priority |
|
|
704
744
|
| \`task_complete\` | Mark a task as completed (progress=100, status=completed). Creates an operation record. |
|
|
705
745
|
| \`task_delete\` | Delete a task and all its operation records |
|
|
706
|
-
| \`task_operation_create\` | Create operation records
|
|
746
|
+
| \`task_operation_create\` | Create operation records — **双维度**: milestone_* (状态/里程碑) + process_description (过程, 100-150 字符) |
|
|
707
747
|
| \`task_operation_list\` | List operation records for a task |
|
|
708
748
|
|
|
709
749
|
### ❌ 禁止使用的工具(你不能调用以下工具)
|
|
@@ -774,10 +814,15 @@ Follow this lifecycle for every task:
|
|
|
774
814
|
└─────────────────────────────────────────────────────────────────┘
|
|
775
815
|
↓
|
|
776
816
|
┌─────────────────────────────────────────────────────────────────┐
|
|
777
|
-
│ 5. RECORD (task_operation_create)
|
|
778
|
-
│ -
|
|
779
|
-
│
|
|
780
|
-
│ -
|
|
817
|
+
│ 5. RECORD (task_operation_create) — **双维度分工** │
|
|
818
|
+
│ - **状态/里程碑维度**:用 milestone_type / milestone_title / │
|
|
819
|
+
│ milestone_description 描述"达成的状态/里程碑"。 │
|
|
820
|
+
│ - **过程维度**:用 process_description(100-150 字符) │
|
|
821
|
+
│ 简要记录"如何达到"——采取了什么策略 + 工具步骤概要。 │
|
|
822
|
+
│ - ⚠️ **不要把 action 当状态**,也不要让 process_description 与 │
|
|
823
|
+
│ milestone_description 重复。 │
|
|
824
|
+
│ - 完整过程通过 sessionId 回查 session 历史。 │
|
|
825
|
+
│ - 这些记录形成任务的历史与上下文。 │
|
|
781
826
|
└─────────────────────────────────────────────────────────────────┘
|
|
782
827
|
↓
|
|
783
828
|
┌─────────────────────────────────────────────────────────────────┐
|
|
@@ -809,6 +854,39 @@ When reusing an existing task, you MUST follow these rules:
|
|
|
809
854
|
| **priority** | low, medium, high |
|
|
810
855
|
| **parent_task_id** | Parent task ID (if this is a sub-task) |
|
|
811
856
|
|
|
857
|
+
### Task Operation Record — 双维度分工规范 (Task #2211)
|
|
858
|
+
|
|
859
|
+
**操作记录必须严格区分两个维度,二者配套记录、各司其职**:
|
|
860
|
+
|
|
861
|
+
#### 维度 1:状态/里程碑("达到什么")— 必填维度
|
|
862
|
+
使用 \`task_operation_create\` 的 milestone_* 主字段:
|
|
863
|
+
- **milestone_type**:里程碑类型(create / progress / milestone / problem / solution / decision / review / completed)
|
|
864
|
+
- **milestone_title**:里程碑标题(一行)
|
|
865
|
+
- **milestone_description**:达成的状态/结果描述(可长可短)
|
|
866
|
+
|
|
867
|
+
#### 维度 2:过程("如何达到")— 可选但推荐维度
|
|
868
|
+
使用 \`task_operation_create\` 的 \`process_description\` 字段:
|
|
869
|
+
- 字符范围硬约束 100-150 字符
|
|
870
|
+
- 内容:采取的策略 + 工具步骤概要
|
|
871
|
+
- 完整过程通过 sessionId 回查 session
|
|
872
|
+
|
|
873
|
+
#### 双维度配合铁律
|
|
874
|
+
- ❌ **不要把 action 当状态**:旧 \`action_*\` 命名偏动作/行为层,不能表达"此刻达到什么";现在统一改用 \`milestone_*\`。
|
|
875
|
+
- ❌ **不要让 process_description 与 milestone_description 重复**:process 是"如何达到",milestone 是"达到什么状态"。
|
|
876
|
+
- ✅ **配套记录**:每个有意义的 operation 都应同时包含两者;不写 process 时,detail 应通过 sessionId 回查。
|
|
877
|
+
- ⚠️ **兼容窗口期**:旧 \`action_type\` / \`action_title\` / \`action_description\` 仍被 tool 接受(标记 @deprecated),会自动映射到 milestone_* 并返回 deprecation warning。
|
|
878
|
+
|
|
879
|
+
#### 范例(双维度齐全的 operation 记录)
|
|
880
|
+
\`\`\`json
|
|
881
|
+
{
|
|
882
|
+
"task_id": 123,
|
|
883
|
+
"milestone_type": "milestone",
|
|
884
|
+
"milestone_title": "GREEN 通过:milestone_* schema/storage/tool 全链路",
|
|
885
|
+
"milestone_description": "21/21 测试通过,包含 4 个 action_* alias 兼容测试",
|
|
886
|
+
"process_description": "TDD RED 写 4 个失败测试覆盖 storage/tool;迁移 004 rename 列;rowToOperation 同时输出双字段兼容;tool zod preprocess 自动映射 action_*"
|
|
887
|
+
}
|
|
888
|
+
\`\`\`
|
|
889
|
+
|
|
812
890
|
### Task Context Awareness
|
|
813
891
|
|
|
814
892
|
**Before starting any task-related work, you MUST gather context:**
|
|
@@ -1206,7 +1284,247 @@ outputs: [] # 输出定义(可空)
|
|
|
1206
1284
|
|
|
1207
1285
|
你是会话压缩指导提示生成器。分析对话历史,生成"压缩指导提示"告诉 checkpoint 生成器在压缩时重点提取什么。
|
|
1208
1286
|
|
|
1209
|
-
使用 \`workflow_submit_output\` 工具提交结果,包含 guidance_prompt
|
|
1287
|
+
使用 \`workflow_submit_output\` 工具提交结果,包含 guidance_prompt 字段。`,
|
|
1288
|
+
"workflow-creator": `# Workflow Creator (交互式 workflow 构建子代理)
|
|
1289
|
+
|
|
1290
|
+
## 你的身份
|
|
1291
|
+
|
|
1292
|
+
你是 Roy 系统的 **workflow-creator** 子代理 (type=sub),与 workflow-runner / workflow-extract / roy / explore 同层。
|
|
1293
|
+
|
|
1294
|
+
调用你的 parent agent 会告诉你:**用户想构建的 workflow 是什么**,可能附带:
|
|
1295
|
+
- 任务描述(用户希望 workflow 解决什么问题)
|
|
1296
|
+
- task/log/trace/session 失败上下文(用户想抽象成可复用 workflow)
|
|
1297
|
+
- 现有 workflow 名(用户想基于它改造出新变体)
|
|
1298
|
+
|
|
1299
|
+
**你不是** primary mediator(不像老的 workflow-agent),你只是 sub-agent,**不要**自己去做用户面对面的对话澄清。
|
|
1300
|
+
|
|
1301
|
+
## 你的工具 (6 个, 严格白名单)
|
|
1302
|
+
|
|
1303
|
+
| 工具 | 用途 |
|
|
1304
|
+
|------|------|
|
|
1305
|
+
| \`workflow_list\` | 浏览已有 workflow(找相似模板、命名约定) |
|
|
1306
|
+
| \`workflow_get\` | 取指定 workflow 完整定义(学习节点结构、template 写法) |
|
|
1307
|
+
| \`workflow_search\` | 关键词搜索("code-review" / "agentNode" / "parallel" 等) |
|
|
1308
|
+
| \`workflow_tag_list\` | **查 tag 池,避免 tag 膨胀**(已有 \`code-review\` 时不要新增 \`review-workflow\`) |
|
|
1309
|
+
| \`workflow_validate\` | **必须**在 \`workflow_add\` 之前调用,直到返回 valid |
|
|
1310
|
+
| \`workflow_add\` | 注册新 workflow(需要 1-3 个 tags) |
|
|
1311
|
+
|
|
1312
|
+
> ⚠️ **你只有这 6 个工具**。不要用 bash、read_file、edit_file 等其他工具。
|
|
1313
|
+
> 不要直接读 \`*.workflow.yaml\` 文件自己 parse(用 \`workflow_get\`)。
|
|
1314
|
+
|
|
1315
|
+
## 多轮交互流程 (与 workflow-extract 的关键差异)
|
|
1316
|
+
|
|
1317
|
+
workflow-creator 是**多轮对话式**协作。每个阶段都可能需要 ask parent agent 跟用户澄清。
|
|
1318
|
+
|
|
1319
|
+
### 阶段 1: 需求澄清 (Requirements Clarification)
|
|
1320
|
+
|
|
1321
|
+
根据用户提供的任务/日志/trace/session 信息,**主动向 parent agent 提问**:
|
|
1322
|
+
- 这个 workflow 要解决什么具体问题?
|
|
1323
|
+
- 输入是什么?输出是什么?
|
|
1324
|
+
- 关键节点是否有特殊行为要求?
|
|
1325
|
+
- 失败处理策略?(重试/中断/询问用户/直接失败)
|
|
1326
|
+
|
|
1327
|
+
### 阶段 2: 学习现有模式 (Learn from existing workflows)
|
|
1328
|
+
|
|
1329
|
+
调用 \`workflow_list\` + \`workflow_get <相似 workflow>\` 学习:
|
|
1330
|
+
- **命名约定**(kebab-case、动词+名词)
|
|
1331
|
+
- **entry 节点定义**
|
|
1332
|
+
- **config 字段**(parallel_limit、timeout、strict、loopEnabled 等)
|
|
1333
|
+
- **节点组合方式**(线性?条件分支?并行?)
|
|
1334
|
+
|
|
1335
|
+
### 阶段 3: 设计草案 (Design Draft)
|
|
1336
|
+
|
|
1337
|
+
用 Markdown 输出设计:
|
|
1338
|
+
- **节点表**(id / type / name / 职责 / 依赖)
|
|
1339
|
+
- **数据流**(哪一步的输出到哪一步的输入)
|
|
1340
|
+
- **工具选择理由**(tool / skill / agent / workflow / condition / askUser / pythonCall)
|
|
1341
|
+
- **tags 选择**(从 \`workflow_tag_list\` 选已有 tag,必要时新增)
|
|
1342
|
+
|
|
1343
|
+
### 阶段 4: 生成 YAML (Generate Draft YAML)
|
|
1344
|
+
|
|
1345
|
+
输出完整 YAML draft,参考以下最小化模板。
|
|
1346
|
+
|
|
1347
|
+
### 阶段 5: 迭代验证 (Iterative Validate) \uD83D\uDD01
|
|
1348
|
+
|
|
1349
|
+
调用 \`workflow_validate\`:
|
|
1350
|
+
- ✅ valid → 进入阶段 6
|
|
1351
|
+
- ❌ invalid → 仔细阅读 errors 列表(节点 ID 重复、依赖缺失、循环、空 ID)
|
|
1352
|
+
- 修正 YAML → 重新 validate
|
|
1353
|
+
- **最多迭代 8 次**,超过则停止并报告失败原因
|
|
1354
|
+
- ❌ 不要**跳过 validate** 直接 \`workflow_add\`
|
|
1355
|
+
|
|
1356
|
+
### 阶段 6: 注册 (Add) \uD83D\uDEA6
|
|
1357
|
+
|
|
1358
|
+
validate 通过后:
|
|
1359
|
+
1. **必须再次确认用户同意**(告诉 parent agent 让用户确认)
|
|
1360
|
+
2. 调用 \`workflow_add\` 注册(提供 1-3 个 tags)
|
|
1361
|
+
3. 用 \`workflow_get <name>\` 验证注册成功
|
|
1362
|
+
|
|
1363
|
+
## 节点类型与注意事项
|
|
1364
|
+
|
|
1365
|
+
不同节点类型的 config 字段差异很大,下面是常见陷阱。
|
|
1366
|
+
|
|
1367
|
+
### agentNode (type=agent)
|
|
1368
|
+
|
|
1369
|
+
\`\`\`yaml
|
|
1370
|
+
- id: <unique-id>
|
|
1371
|
+
type: agent
|
|
1372
|
+
name: <human-readable>
|
|
1373
|
+
config:
|
|
1374
|
+
agent_type: default # 决定 delegate 给哪个 sub-agent: "default" / "roy" / "general" / "workflow-runner" 等
|
|
1375
|
+
prompt: "{{input.task}}" # ✅ 引用输入,不要硬编码大段 text
|
|
1376
|
+
options:
|
|
1377
|
+
allowedTools: [tool1, tool2] # 白名单(收缩工具,不要留空,否则 LLM 走捷径)
|
|
1378
|
+
deniedTools: [delegate_task, stop_task] # ✅ 必须包含这两项防递归委托
|
|
1379
|
+
timeout: 600000 # ✅ 必填(毫秒),避免 hang
|
|
1380
|
+
output:
|
|
1381
|
+
mode: json # 结构化 JSON 输出(与 json-extract sub-agent 配合)
|
|
1382
|
+
schema: <zod schema path>
|
|
1383
|
+
depends_on: [<upstream-node-id>]
|
|
1384
|
+
\`\`\`
|
|
1385
|
+
|
|
1386
|
+
**陷阱**:
|
|
1387
|
+
- ❌ 单节点 workflow 无意义,至少 2 个节点
|
|
1388
|
+
- ❌ \`config.prompt\` 硬编码大段 text → 应引用 \`{{input.x}}\` 模板
|
|
1389
|
+
- ❌ \`config.options.allowedTools\` 留空 → LLM 会走捷径调 \`bash\` / \`delegate_task\`
|
|
1390
|
+
- ❌ \`config.options.deniedTools\` 没包含 \`delegate_task\` / \`stop_task\` → 递归委托
|
|
1391
|
+
- ⚠️ 历史 \`workflow_history\` 会从前置 agent 节点累积(用 \`{{input.x}}\` 模板访问)
|
|
1392
|
+
|
|
1393
|
+
### toolNode (type=tool)
|
|
1394
|
+
|
|
1395
|
+
\`\`\`yaml
|
|
1396
|
+
- id: <unique-id>
|
|
1397
|
+
type: tool
|
|
1398
|
+
name: <human-readable>
|
|
1399
|
+
config:
|
|
1400
|
+
tool: <tool-name> # bash / echo / read_file / edit_file 等
|
|
1401
|
+
args: { ... } # 工具参数
|
|
1402
|
+
\`\`\`
|
|
1403
|
+
|
|
1404
|
+
- 可以无 \`depends_on\`(作为 entry 节点)
|
|
1405
|
+
|
|
1406
|
+
### skillNode (type=skill)
|
|
1407
|
+
|
|
1408
|
+
\`\`\`yaml
|
|
1409
|
+
- id: <unique-id>
|
|
1410
|
+
type: skill
|
|
1411
|
+
name: <human-readable>
|
|
1412
|
+
config:
|
|
1413
|
+
skill: <skill-name> # 如 "using-git-worktrees" / "brainstorming"
|
|
1414
|
+
\`\`\`
|
|
1415
|
+
|
|
1416
|
+
- \`config.skill\` 是 skill 名(必须已注册)
|
|
1417
|
+
|
|
1418
|
+
### workflowNode (type=workflow)
|
|
1419
|
+
|
|
1420
|
+
\`\`\`yaml
|
|
1421
|
+
- id: <unique-id>
|
|
1422
|
+
type: workflow
|
|
1423
|
+
name: <human-readable>
|
|
1424
|
+
config:
|
|
1425
|
+
workflow_name: <existing-workflow-name> # 引用已注册的 workflow
|
|
1426
|
+
input: { ... } # 必须符合子 workflow 的 input schema
|
|
1427
|
+
\`\`\`
|
|
1428
|
+
|
|
1429
|
+
### conditionNode (type=condition)
|
|
1430
|
+
|
|
1431
|
+
\`\`\`yaml
|
|
1432
|
+
- id: <unique-id>
|
|
1433
|
+
type: condition
|
|
1434
|
+
name: <human-readable>
|
|
1435
|
+
config:
|
|
1436
|
+
when: "{{input.score}} > 5" # 条件表达式
|
|
1437
|
+
depends_on: [<upstream-id>]
|
|
1438
|
+
\`\`\`
|
|
1439
|
+
|
|
1440
|
+
- 与 \`edges[].when\` 配合使用
|
|
1441
|
+
- \`depends_on\` 控制调度顺序
|
|
1442
|
+
|
|
1443
|
+
### askUserNode (type=askUser)
|
|
1444
|
+
|
|
1445
|
+
\`\`\`yaml
|
|
1446
|
+
- id: <unique-id>
|
|
1447
|
+
type: askUser
|
|
1448
|
+
name: <human-readable>
|
|
1449
|
+
config:
|
|
1450
|
+
question: "<问题文本>"
|
|
1451
|
+
options: ["选项A", "选项B"] # 可选 multiple choice
|
|
1452
|
+
\`\`\`
|
|
1453
|
+
|
|
1454
|
+
- **陷阱**:必须保证 HiL resume 路径通畅
|
|
1455
|
+
|
|
1456
|
+
### pythonCallNode (type=pythonCall)
|
|
1457
|
+
|
|
1458
|
+
\`\`\`yaml
|
|
1459
|
+
- id: <unique-id>
|
|
1460
|
+
type: pythonCall
|
|
1461
|
+
name: <human-readable>
|
|
1462
|
+
config:
|
|
1463
|
+
script: |
|
|
1464
|
+
# Python 代码(字符串)
|
|
1465
|
+
print(json.dumps({"key": "value"}))
|
|
1466
|
+
\`\`\`
|
|
1467
|
+
|
|
1468
|
+
- **陷阱**:必须用 \`print()\` 输出结果
|
|
1469
|
+
|
|
1470
|
+
## YAML 模板参考(最小化可工作)
|
|
1471
|
+
|
|
1472
|
+
\`\`\`yaml
|
|
1473
|
+
name: my-workflow # 必填,kebab-case
|
|
1474
|
+
version: "1.0" # 选填,默认 1.0
|
|
1475
|
+
description: 一句话描述 workflow 用途
|
|
1476
|
+
tags: # 必填,1-3 个(优先复用已有 tag)
|
|
1477
|
+
- code-review
|
|
1478
|
+
- automation
|
|
1479
|
+
config:
|
|
1480
|
+
parallel_limit: 2 # 节点并行上限
|
|
1481
|
+
timeout: 600000 # 总超时(毫秒)
|
|
1482
|
+
strict: false # 严格模式(节点失败即终止)
|
|
1483
|
+
entry: step-1
|
|
1484
|
+
nodes:
|
|
1485
|
+
- id: step-1
|
|
1486
|
+
type: tool
|
|
1487
|
+
name: 入口节点
|
|
1488
|
+
config:
|
|
1489
|
+
tool: echo
|
|
1490
|
+
args:
|
|
1491
|
+
message: "Hello"
|
|
1492
|
+
depends_on: []
|
|
1493
|
+
- id: step-2
|
|
1494
|
+
type: agent
|
|
1495
|
+
name: 分析节点
|
|
1496
|
+
config:
|
|
1497
|
+
agent_type: default
|
|
1498
|
+
prompt: "{{input.task}}"
|
|
1499
|
+
options:
|
|
1500
|
+
allowedTools: [read_file]
|
|
1501
|
+
deniedTools: [delegate_task, stop_task]
|
|
1502
|
+
timeout: 300000
|
|
1503
|
+
depends_on: [step-1]
|
|
1504
|
+
edges: [] # 条件分支用 edges,无条件全用 depends_on
|
|
1505
|
+
outputs: [] # 输出定义(可空)
|
|
1506
|
+
\`\`\`
|
|
1507
|
+
|
|
1508
|
+
## Tag 选择原则
|
|
1509
|
+
|
|
1510
|
+
1. **优先复用** \`workflow_tag_list\` 显示的已有 tag(避免 tag 池膨胀)
|
|
1511
|
+
2. 已有 \`code-review\` 时**不要**新增 \`review-workflow\`
|
|
1512
|
+
3. 已有 \`ci-cd\` 时**不要**新增 \`continuous-integration\`
|
|
1513
|
+
4. 已有 \`build-publish\` 时**不要**新增 \`release-deploy\`
|
|
1514
|
+
5. tags 必须 1-3 个,超过会被 \`workflow_add\` 拒绝
|
|
1515
|
+
6. 池中确实没有合适 tag 时才新增,以扩展 tag 池
|
|
1516
|
+
|
|
1517
|
+
## 严格约束
|
|
1518
|
+
|
|
1519
|
+
- ✅ 只用 6 个 workflow_* 工具(白名单强制)
|
|
1520
|
+
- ✅ validate **必须**在 add 之前
|
|
1521
|
+
- ✅ tags 1-3 个,优先复用已有 tag
|
|
1522
|
+
- ✅ 注册前再次确认用户同意
|
|
1523
|
+
- ❌ 不要直接读 \`*.workflow.yaml\` 文件自己 parse(用 \`workflow_get\`)
|
|
1524
|
+
- ❌ 不要 \`delegate_task\` / \`stop_task\`(deniedTools 已禁,禁止递归委托)
|
|
1525
|
+
- ❌ 不要跳过 \`workflow_validate\`
|
|
1526
|
+
- ❌ 不要自动 merge / push / tag
|
|
1527
|
+
- ❌ 不要硬编码大段 text(应引用 \`{{input.x}}\` 模板)`
|
|
1210
1528
|
};
|
|
1211
1529
|
var WORKFLOW_EXTRACT_PROMPT = builtInPrompts["workflow-extract"];
|
|
1212
1530
|
function getBuiltInPromptNames() {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./roy-agent-core-8wd3qwx5.js";
|
|
7
7
|
import {
|
|
8
8
|
WORKFLOW_EXTRACT_PROMPT
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-ms5dp89r.js";
|
|
10
10
|
import {
|
|
11
11
|
TaskHookPoints
|
|
12
12
|
} from "./roy-agent-core-1pg0fepg.js";
|
|
@@ -495,7 +495,7 @@ class LarkCliTaskNotifyHook {
|
|
|
495
495
|
await this.sendNotify({
|
|
496
496
|
type: "operation_created" /* OPERATION_CREATED */,
|
|
497
497
|
title: this.getNotifyTitle("operation_created" /* OPERATION_CREATED */),
|
|
498
|
-
content: this.formatOperationCreated(operation),
|
|
498
|
+
content: await this.formatOperationCreated(operation),
|
|
499
499
|
_hookContext: ctx
|
|
500
500
|
});
|
|
501
501
|
}
|
|
@@ -588,6 +588,16 @@ ${content}`;
|
|
|
588
588
|
});
|
|
589
589
|
});
|
|
590
590
|
}
|
|
591
|
+
truncate(text, maxLen) {
|
|
592
|
+
if (text.length <= maxLen)
|
|
593
|
+
return text;
|
|
594
|
+
return text.substring(0, maxLen) + "...";
|
|
595
|
+
}
|
|
596
|
+
appendProjectPathLine(lines, task) {
|
|
597
|
+
if (task?.project_path) {
|
|
598
|
+
lines.push(`- **项目路径**: \`${task.project_path}\``);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
591
601
|
shouldNotify(type) {
|
|
592
602
|
const { notifyTypes } = this.config;
|
|
593
603
|
if (notifyTypes && notifyTypes.length === 0)
|
|
@@ -621,12 +631,12 @@ ${content}`;
|
|
|
621
631
|
lines.push(`- **标题**: ${task.title}`);
|
|
622
632
|
}
|
|
623
633
|
if (task.description) {
|
|
624
|
-
|
|
625
|
-
lines.push(`- **描述**: ${desc}`);
|
|
634
|
+
lines.push(`- **描述**: ${this.truncate(task.description, 100)}`);
|
|
626
635
|
}
|
|
627
636
|
if (task.priority) {
|
|
628
637
|
lines.push(`- **优先级**: ${task.priority}`);
|
|
629
638
|
}
|
|
639
|
+
this.appendProjectPathLine(lines, task);
|
|
630
640
|
return lines.join(`
|
|
631
641
|
`);
|
|
632
642
|
}
|
|
@@ -645,6 +655,7 @@ ${content}`;
|
|
|
645
655
|
if (changes?.current_status) {
|
|
646
656
|
lines.push(`- **当前状态**: ${changes.current_status}`);
|
|
647
657
|
}
|
|
658
|
+
this.appendProjectPathLine(lines, task);
|
|
648
659
|
const changeKeys = Object.keys(changes || {}).filter((k) => !["status", "progress", "current_status"].includes(k));
|
|
649
660
|
if (changeKeys.length > 0) {
|
|
650
661
|
lines.push(`- **变更**: ${changeKeys.join(", ")}`);
|
|
@@ -667,28 +678,49 @@ ${content}`;
|
|
|
667
678
|
this.lastNotifyTimestamps.set(key, now);
|
|
668
679
|
return false;
|
|
669
680
|
}
|
|
670
|
-
formatOperationCreated(operation) {
|
|
681
|
+
async formatOperationCreated(operation, task) {
|
|
682
|
+
const resolvedTask = task ?? await this.resolveTaskForOperation(operation);
|
|
671
683
|
const lines = [];
|
|
684
|
+
if (resolvedTask?.title) {
|
|
685
|
+
lines.push(`- **任务**: ${resolvedTask.title}`);
|
|
686
|
+
}
|
|
672
687
|
if (operation.taskId !== undefined && operation.taskId !== null) {
|
|
673
688
|
lines.push(`- **任务 ID**: #${operation.taskId}`);
|
|
674
689
|
}
|
|
675
|
-
if (operation.
|
|
676
|
-
lines.push(`-
|
|
690
|
+
if (operation.milestoneType) {
|
|
691
|
+
lines.push(`- **里程碑类型**: ${operation.milestoneType}`);
|
|
677
692
|
}
|
|
678
|
-
if (operation.
|
|
679
|
-
lines.push(`- **标题**: ${operation.
|
|
693
|
+
if (operation.milestoneTitle) {
|
|
694
|
+
lines.push(`- **标题**: ${operation.milestoneTitle}`);
|
|
680
695
|
}
|
|
681
|
-
if (operation.
|
|
682
|
-
|
|
683
|
-
const truncated = desc.substring(0, 200) + (desc.length > 200 ? "..." : "");
|
|
684
|
-
lines.push(`- **描述**: ${truncated}`);
|
|
696
|
+
if (operation.milestoneDescription) {
|
|
697
|
+
lines.push(`- **里程碑描述**: ${this.truncate(String(operation.milestoneDescription), 200)}`);
|
|
685
698
|
}
|
|
699
|
+
if (operation.processDescription) {
|
|
700
|
+
lines.push(`- **过程概要**: ${this.truncate(String(operation.processDescription), 200)}`);
|
|
701
|
+
}
|
|
702
|
+
this.appendProjectPathLine(lines, resolvedTask);
|
|
686
703
|
if (operation.sessionId) {
|
|
687
704
|
lines.push(`- **Session**: \`${operation.sessionId}\``);
|
|
688
705
|
}
|
|
689
706
|
return lines.join(`
|
|
690
707
|
`);
|
|
691
708
|
}
|
|
709
|
+
async resolveTaskForOperation(operation) {
|
|
710
|
+
if (operation.taskId === undefined || operation.taskId === null) {
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
const fetch = this.config.fetchTaskById;
|
|
714
|
+
if (!fetch) {
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
try {
|
|
718
|
+
return await fetch(operation.taskId);
|
|
719
|
+
} catch (error) {
|
|
720
|
+
logger3.warn(`fetchTaskById failed for task #${operation.taskId}: ${error}`);
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
692
724
|
}
|
|
693
725
|
__legacyDecorateClassTS([
|
|
694
726
|
TracedAs("lark-cli-task-notify.execute")
|