@ai-setting/roy-agent-core 1.6.12 → 1.6.13
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 +3 -3
- package/dist/env/event-source/index.js +5 -5
- package/dist/env/index.js +17 -17
- package/dist/env/prompt/index.js +2 -2
- package/dist/env/task/delegate/index.js +4 -4
- package/dist/env/task/index.js +5 -5
- package/dist/env/task/plugins/index.js +4 -4
- package/dist/env/tool/built-in/index.js +2 -2
- package/dist/env/tool/index.js +3 -3
- package/dist/env/workflow/engine/index.js +3 -3
- package/dist/env/workflow/index.js +7 -7
- package/dist/env/workflow/service/index.js +1 -1
- package/dist/env/workflow/tools/index.js +4 -4
- package/dist/env/workflow/utils/index.js +2 -2
- package/dist/index.js +130 -19
- package/dist/shared/@ai-setting/{roy-agent-core-0n2a8cbn.js → roy-agent-core-0crh2g0m.js} +594 -237
- package/dist/shared/@ai-setting/{roy-agent-core-asp5p3zx.js → roy-agent-core-0pbmweh4.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-jenchn33.js → roy-agent-core-24rmf17n.js} +8 -0
- package/dist/shared/@ai-setting/{roy-agent-core-q2bw3cwd.js → roy-agent-core-2b4078kz.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-z7f8hyv7.js → roy-agent-core-6jqpdjr4.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-cxdnzn17.js → roy-agent-core-6qbyfzsw.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-mb7b62sm.js → roy-agent-core-8cbsjkkx.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-ms5dp89r.js → roy-agent-core-apz6v22z.js} +81 -40
- package/dist/shared/@ai-setting/{roy-agent-core-q7rt3x8d.js → roy-agent-core-deqpzcg7.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-1bvv6s75.js → roy-agent-core-fvkyv5j6.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-dntkpwqq.js → roy-agent-core-fwxqevpf.js} +4 -1
- package/dist/shared/@ai-setting/{roy-agent-core-pzeexnhf.js → roy-agent-core-nv4yfy3m.js} +4 -3
- package/dist/shared/@ai-setting/{roy-agent-core-3bdpnmtg.js → roy-agent-core-v5nknfh0.js} +1 -8
- package/dist/shared/@ai-setting/{roy-agent-core-06574wqa.js → roy-agent-core-v77pp20w.js} +4 -4
- package/dist/shared/@ai-setting/roy-agent-core-vcjq65nz.js +436 -0
- package/dist/shared/@ai-setting/{roy-agent-core-8wd3qwx5.js → roy-agent-core-wjve1qr5.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-7a3gf3tw.js → roy-agent-core-wpw37qqf.js} +88 -3
- package/dist/shared/@ai-setting/{roy-agent-core-p6x6n3k4.js → roy-agent-core-x7fgze6s.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-p2vpsd1d.js → roy-agent-core-ywtmc0bh.js} +166 -6
- package/package.json +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-4yq23m5g.js +0 -421
- /package/dist/shared/@ai-setting/{roy-agent-core-zs31w092.js → roy-agent-core-9nhwdq9r.js} +0 -0
|
@@ -343,6 +343,14 @@ var init_agent_component_adapter = __esm(() => {
|
|
|
343
343
|
} catch {}
|
|
344
344
|
}
|
|
345
345
|
context.additionInfo = additionInfo;
|
|
346
|
+
const ctxScope = config.cancellationScope;
|
|
347
|
+
if (ctxScope && typeof ctxScope.onForce === "function") {
|
|
348
|
+
ctxScope.onForce("agent-component-adapter-force", () => {
|
|
349
|
+
if (deadlineController && !deadlineController.signal.aborted) {
|
|
350
|
+
deadlineController.abort("force");
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}
|
|
346
354
|
const result = await this.agentComponent.run(config.type || "general", userInput, context);
|
|
347
355
|
if (result.error?.startsWith("__ASK_USER_ERROR__:")) {
|
|
348
356
|
const jsonStr = result.error.substring("__ASK_USER_ERROR__:".length);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentComponentAdapter,
|
|
3
3
|
init_agent_component_adapter
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-24rmf17n.js";
|
|
5
5
|
import"./roy-agent-core-1db4vpc6.js";
|
|
6
6
|
import"./roy-agent-core-e25xkv53.js";
|
|
7
7
|
import"./roy-agent-core-dbkkjmqz.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TAG_MAX_COUNT,
|
|
3
3
|
TAG_MIN_COUNT
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-ywtmc0bh.js";
|
|
5
5
|
import {
|
|
6
6
|
validateWorkflowDefinition
|
|
7
|
-
} from "./roy-agent-core-
|
|
7
|
+
} from "./roy-agent-core-wjve1qr5.js";
|
|
8
8
|
import {
|
|
9
9
|
AskUserError,
|
|
10
10
|
init_workflow_hil
|
|
@@ -1073,68 +1073,109 @@ When reusing an existing task, you MUST follow these rules:
|
|
|
1073
1073
|
# 输出要求
|
|
1074
1074
|
直接调用 write_memory 工具,写入新的全局记忆。
|
|
1075
1075
|
输出格式为 Markdown,保持结构清晰。`,
|
|
1076
|
-
"workflow-runner": `# Workflow Runner
|
|
1076
|
+
"workflow-runner": `# Workflow Runner(workflow 执行 + prompt-driven 失败接管)
|
|
1077
1077
|
|
|
1078
|
-
##
|
|
1079
|
-
|
|
1080
|
-
你是 Roy 系统的 **workflow-runner** 子代理 (type=sub).
|
|
1081
|
-
调用你的 parent agent 会告诉你: 要运行哪个 workflow + 任务上下文.
|
|
1078
|
+
## 身份与输入
|
|
1082
1079
|
|
|
1083
|
-
|
|
1080
|
+
你是 Roy 的 **workflow-runner** 子代理(type=sub)。parent agent 会提供:
|
|
1084
1081
|
|
|
1085
1082
|
\`\`\`
|
|
1086
1083
|
<workflow_name>{WORKFLOW_NAME}</workflow_name>
|
|
1087
1084
|
<task_description>{TASK_DESCRIPTION}</task_description>
|
|
1088
1085
|
<original_prompt>{ORIGINAL_PROMPT}</original_prompt>
|
|
1086
|
+
<existing_sub_session_id?>{EXISTING_SUB_SESSION_ID}</existing_sub_session_id>
|
|
1089
1087
|
\`\`\`
|
|
1090
1088
|
|
|
1091
|
-
|
|
1092
|
-
|
|
1089
|
+
workflow 名必须从 \`<workflow_name>\` 标签读取,不得根据上下文猜测。
|
|
1090
|
+
|
|
1091
|
+
## 可用工具
|
|
1093
1092
|
|
|
1094
|
-
|
|
1093
|
+
### Workflow 工具
|
|
1095
1094
|
|
|
1096
1095
|
| 工具 | 用途 |
|
|
1097
|
-
|
|
1098
|
-
| workflow_get |
|
|
1099
|
-
| workflow_list |
|
|
1100
|
-
| workflow_run |
|
|
1101
|
-
| workflow_run_status |
|
|
1102
|
-
| workflow_run_stop |
|
|
1096
|
+
|---|---|
|
|
1097
|
+
| workflow_get | 读取真实 workflow 定义、输入 schema、节点与依赖 |
|
|
1098
|
+
| workflow_list | 列出已注册 workflow |
|
|
1099
|
+
| workflow_run | 启动或恢复 workflow |
|
|
1100
|
+
| workflow_run_status | 查询原 run_id 的真实状态与节点进度 |
|
|
1101
|
+
| workflow_run_stop | 按要求停止 run |
|
|
1103
1102
|
|
|
1104
|
-
|
|
1103
|
+
### 通用 ReAct 工具
|
|
1105
1104
|
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
4. \`workflow_run(<workflow_name>, input)\` 启动 (同步阻塞)
|
|
1110
|
-
5. 把 output 原样回给 parent agent
|
|
1105
|
+
接管时可用 \`bash\`、\`read_file\`、\`write_file\`、\`edit_file\`、\`grep\`、\`glob\`,
|
|
1106
|
+
以及 \`task_create\`、\`task_update\`、\`task_operation_create\`、\`task_complete\`、
|
|
1107
|
+
\`recall_memory\`、\`record_memory\`。优先用内置工具获取证据并完成节点要求。
|
|
1111
1108
|
|
|
1112
|
-
|
|
1109
|
+
### 禁止工具
|
|
1113
1110
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1111
|
+
- \`delegate_task\`:禁止递归委托,避免代理栈失控。
|
|
1112
|
+
- \`stop_task\`:禁止误杀 parent session。
|
|
1116
1113
|
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1114
|
+
## 默认 workflow-run 模式
|
|
1115
|
+
|
|
1116
|
+
1. 调 \`workflow_get(name)\`,确认 input schema、节点描述和 DAG 依赖。
|
|
1117
|
+
2. 从 original_prompt 提取合法 input。
|
|
1118
|
+
3. 没有 existing_sub_session_id 时调用 fresh \`workflow_run\`;有该 ID 时先调
|
|
1119
|
+
\`workflow_run_status(run_id)\`,再以同一 ID 作为 session 恢复。runId == sessionId。
|
|
1120
|
+
|
|
1121
|
+
Copy-paste CLI 示例:
|
|
1122
|
+
\`roy-agent workflow run roy-rd-with-trace -s workflow_run_1783407282099_1_ah8pho\`
|
|
1123
|
+
4. 对 \`completed\` / \`paused\` 返回真实 output;对 \`running\` / \`stopped\` 按真实状态报告。
|
|
1124
|
+
5. 对每次 \`failed\` / \`timeout\`,扫描你自己最近的 workflow_run tool results,推理连续失败次数。
|
|
1125
|
+
|
|
1126
|
+
## 连续 2 次失败阈值(由 LLM 自行推理)
|
|
1127
|
+
|
|
1128
|
+
接管不依赖 runtime Map、counter 或 execution hook。你必须检查自己最近两次
|
|
1129
|
+
\`workflow_run\` tool result:只有两次连续为 \`status: "failed"\` 或 \`status: "timeout"\`
|
|
1130
|
+
时才接管。未达到连续 2 次时,可以针对同一 run_id 恢复一次;成功结果会中断连续失败序列。
|
|
1121
1131
|
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
workflow_run
|
|
1132
|
+
## 接管流程(严格顺序)
|
|
1133
|
+
|
|
1134
|
+
达到阈值后,**接管后不再调 workflow_run**,并依次执行:
|
|
1135
|
+
|
|
1136
|
+
1. 调 \`workflow_run_status(original_run_id)\`,读取真实 run 状态、失败节点和已完成节点。
|
|
1137
|
+
2. 调 \`workflow_get(name)\`,读取真实 workflow 定义、节点 description 与 DAG 依赖。
|
|
1138
|
+
3. 将每个**节点描述视为 skill spec**:严格遵守其目标、输入输出契约、依赖和验证要求。
|
|
1139
|
+
4. 已成功 phase 不重复;失败节点必须从该节点自身要求重新执行,而不是从首节点重跑。
|
|
1140
|
+
5. 后续节点必须按 DAG/phase 依赖顺序推进,不得在失败节点修复及验证前执行后继节点。
|
|
1141
|
+
6. 使用通用 ReAct 工具完成节点,并收集命令、文件、测试、构建、trace 等验证证据。
|
|
1142
|
+
7. 无法完成的事项不得隐藏,必须列入 unfinished_items。
|
|
1143
|
+
|
|
1144
|
+
## 禁止伪造 workflow engine 成功
|
|
1145
|
+
|
|
1146
|
+
- 禁止把人工 ReAct 接管描述成 workflow engine 的 \`completed\` 或正常 workflow_run success。
|
|
1147
|
+
- 禁止改写、伪造或猜测 engine 状态;状态只能来自 \`workflow_run_status\`。
|
|
1148
|
+
- fallback 证据块不是 workflow output,必须与 engine 原始状态明确区分。
|
|
1149
|
+
|
|
1150
|
+
## 最终 fallback 证据输出契约
|
|
1151
|
+
|
|
1152
|
+
接管后的最终回答必须包含完整证据块:
|
|
1153
|
+
|
|
1154
|
+
\`\`\`
|
|
1155
|
+
===FALLBACK_TAKEOVER===
|
|
1156
|
+
takeover: true
|
|
1157
|
+
original_run_id: <原始 workflow run_id>
|
|
1158
|
+
workflow_name: <workflow 名>
|
|
1159
|
+
failed_node: <失败节点 id 或 phase>
|
|
1160
|
+
react_completed_nodes: [<人工 ReAct 完成的节点>]
|
|
1161
|
+
verification_evidence: |
|
|
1162
|
+
<逐项测试、构建、CLI、trace 或文件证据>
|
|
1163
|
+
unfinished_items: [<仍未完成的事项;无则 []>]
|
|
1164
|
+
===END_FALLBACK_TAKEOVER===
|
|
1125
1165
|
\`\`\`
|
|
1126
1166
|
|
|
1127
|
-
|
|
1128
|
-
> 也用于 \`-s\` resume. 不要混淆.
|
|
1167
|
+
## 终止与防递归规则
|
|
1129
1168
|
|
|
1130
|
-
|
|
1169
|
+
接管不可再触发接管。进入接管模式后保持该模式,输出证据块后立即退出;
|
|
1170
|
+
不得再次调用 workflow_run,也不得再次以“连续失败 2 次”为由嵌套接管。
|
|
1171
|
+
|
|
1172
|
+
## 最终检查
|
|
1131
1173
|
|
|
1132
|
-
-
|
|
1133
|
-
-
|
|
1134
|
-
-
|
|
1135
|
-
-
|
|
1136
|
-
-
|
|
1137
|
-
`,
|
|
1174
|
+
- workflow_run_status 与 workflow_get 均已调用,并以真实返回为依据。
|
|
1175
|
+
- 节点目标、输入输出、依赖和验证要求均已遵守。
|
|
1176
|
+
- 已成功 phase 未重复,失败节点和后续 DAG 顺序正确。
|
|
1177
|
+
- 未伪造 workflow engine 成功,证据块字段完整。
|
|
1178
|
+
- deniedTools 中的 delegate_task / stop_task 从未调用。`,
|
|
1138
1179
|
"json-extract": `# JSON Extract Agent
|
|
1139
1180
|
|
|
1140
1181
|
你是一个 JSON 提取子智能体。**唯一职责**:从父 session 的对话历史中提取最终答案,通过 \`workflow_submit_output\` 工具调用提交结构化 JSON(最多 5 次)。
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./roy-agent-core-az13yzmc.js";
|
|
4
4
|
import {
|
|
5
5
|
validateWorkflowDefinition
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-wjve1qr5.js";
|
|
7
7
|
import {
|
|
8
8
|
WORKFLOW_EXTRACT_PROMPT
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-apz6v22z.js";
|
|
10
10
|
import {
|
|
11
11
|
TaskHookPoints
|
|
12
12
|
} from "./roy-agent-core-1pg0fepg.js";
|
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
} from "./roy-agent-core-dcd1s7ct.js";
|
|
4
4
|
import {
|
|
5
5
|
truncateOutputInline
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-9nhwdq9r.js";
|
|
7
7
|
import {
|
|
8
8
|
AskUserError,
|
|
9
9
|
init_workflow_hil
|
|
10
10
|
} from "./roy-agent-core-e25xkv53.js";
|
|
11
11
|
import {
|
|
12
12
|
AgentRegistry
|
|
13
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-v5nknfh0.js";
|
|
14
14
|
import {
|
|
15
15
|
ContextError
|
|
16
16
|
} from "./roy-agent-core-ctdhjv68.js";
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
BackgroundTaskManager,
|
|
9
9
|
createDelegateTool,
|
|
10
10
|
createStopTool
|
|
11
|
-
} from "./roy-agent-core-
|
|
11
|
+
} from "./roy-agent-core-wpw37qqf.js";
|
|
12
12
|
import {
|
|
13
13
|
SQLiteTaskStore,
|
|
14
14
|
getDefaultTaskDbPath
|
|
@@ -193,6 +193,9 @@ class TaskComponent extends BaseComponent {
|
|
|
193
193
|
configComponent;
|
|
194
194
|
tagService;
|
|
195
195
|
plugins = new Map;
|
|
196
|
+
getBackgroundTaskManager() {
|
|
197
|
+
return this.backgroundTaskManager;
|
|
198
|
+
}
|
|
196
199
|
publishEvent(type, payload, sessionId) {
|
|
197
200
|
if (this.env?.pushEnvEvent) {
|
|
198
201
|
this.env.pushEnvEvent({
|
|
@@ -173,12 +173,13 @@ class ProcessRegistry {
|
|
|
173
173
|
try {
|
|
174
174
|
const result = await killProcessTree(pid, { retry: 3, retryDelayMs: 500 });
|
|
175
175
|
if (result.stillAlive) {
|
|
176
|
-
logger2.error(`进程 PID ${pid} 经过 ${result.attempts}
|
|
176
|
+
logger2.error(`进程 PID ${pid} 经过 ${result.attempts} 次重试后仍未杀死!保留 PID 供后续 forceStopAll 重试。`);
|
|
177
|
+
} else {
|
|
178
|
+
this.pids.delete(pid);
|
|
177
179
|
}
|
|
178
180
|
} catch {}
|
|
179
181
|
}
|
|
180
|
-
this.pids.
|
|
181
|
-
logger2.info(`[bg-process:killAll-done]`);
|
|
182
|
+
logger2.info(`[bg-process:killAll-done] remaining=${this.pids.size}`);
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
185
|
var processRegistryStorage = new AsyncLocalStorage;
|
|
@@ -165,15 +165,8 @@ class AgentRegistry {
|
|
|
165
165
|
const agent = {
|
|
166
166
|
name,
|
|
167
167
|
type: "sub",
|
|
168
|
-
description: "Workflow runner — 负责调用 workflow_run 启动 workflow,支持 session resume 和 stop",
|
|
168
|
+
description: "Workflow runner — 负责调用 workflow_run 启动 workflow,支持 session resume 和 stop;失败接管由 prompt 推理触发 (Task #2251 简化版)。",
|
|
169
169
|
systemPromptRef: "workflow-runner",
|
|
170
|
-
allowedTools: [
|
|
171
|
-
"workflow_get",
|
|
172
|
-
"workflow_list",
|
|
173
|
-
"workflow_run",
|
|
174
|
-
"workflow_run_status",
|
|
175
|
-
"workflow_run_stop"
|
|
176
|
-
],
|
|
177
170
|
deniedTools: ["delegate_task", "stop_task"],
|
|
178
171
|
maxIterations: 30
|
|
179
172
|
};
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
WorkflowEngine,
|
|
7
7
|
exports_engine,
|
|
8
8
|
init_engine
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-0crh2g0m.js";
|
|
10
10
|
import {
|
|
11
11
|
askUserTool,
|
|
12
12
|
createRunWorkflowTool,
|
|
@@ -18,10 +18,10 @@ import {
|
|
|
18
18
|
createWorkflowSearchTool,
|
|
19
19
|
createWorkflowTagListTool,
|
|
20
20
|
createWorkflowValidateTool
|
|
21
|
-
} from "./roy-agent-core-
|
|
21
|
+
} from "./roy-agent-core-8cbsjkkx.js";
|
|
22
22
|
import {
|
|
23
23
|
WorkflowService
|
|
24
|
-
} from "./roy-agent-core-
|
|
24
|
+
} from "./roy-agent-core-ywtmc0bh.js";
|
|
25
25
|
import {
|
|
26
26
|
BaseComponent
|
|
27
27
|
} from "./roy-agent-core-j62bjagf.js";
|
|
@@ -141,7 +141,7 @@ class WorkflowComponent extends BaseComponent {
|
|
|
141
141
|
if (!agentRunner && this._workflowEnv) {
|
|
142
142
|
const agentComponent = this._workflowEnv.getComponent("agent");
|
|
143
143
|
if (agentComponent) {
|
|
144
|
-
const { AgentComponentAdapter } = await import("./roy-agent-core-
|
|
144
|
+
const { AgentComponentAdapter } = await import("./roy-agent-core-6jqpdjr4.js");
|
|
145
145
|
agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent);
|
|
146
146
|
}
|
|
147
147
|
}
|