@ai-setting/roy-agent-core 1.6.8 → 1.6.10
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/config/index.js +11 -9
- package/dist/env/agent/index.js +10 -10
- package/dist/env/commands/index.js +8 -8
- package/dist/env/context/index.js +3 -3
- package/dist/env/debug/index.js +7 -7
- package/dist/env/event-source/index.js +11 -11
- package/dist/env/hook/index.js +5 -5
- package/dist/env/index.js +30 -29
- package/dist/env/llm/index.js +9 -8
- package/dist/env/log-trace/index.js +8 -8
- package/dist/env/mcp/index.js +8 -8
- package/dist/env/memory/index.js +8 -8
- package/dist/env/plugin/index.js +7 -7
- package/dist/env/prompt/index.js +9 -9
- package/dist/env/session/index.js +8 -8
- package/dist/env/skill/index.js +8 -8
- package/dist/env/task/delegate/index.js +8 -7
- package/dist/env/task/index.js +13 -12
- package/dist/env/task/plugins/index.js +5 -5
- package/dist/env/task/tools/index.js +3 -3
- package/dist/env/tool/built-in/index.js +2 -2
- package/dist/env/tool/index.js +9 -9
- package/dist/env/workflow/engine/index.js +8 -8
- package/dist/env/workflow/index.js +17 -16
- package/dist/env/workflow/nodes/index.js +2 -2
- package/dist/env/workflow/service/index.js +2 -2
- package/dist/env/workflow/storage/index.js +3 -3
- package/dist/env/workflow/tools/index.js +11 -10
- package/dist/env/workflow/utils/index.js +2 -2
- package/dist/index.js +41 -39
- package/dist/shared/@ai-setting/{roy-agent-core-12ttd2w1.js → roy-agent-core-0cftbg62.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-2vevsd36.js → roy-agent-core-0n2a8cbn.js} +55 -9
- package/dist/shared/@ai-setting/{roy-agent-core-33rhv946.js → roy-agent-core-1gsnq4p2.js} +5 -197
- package/dist/shared/@ai-setting/{roy-agent-core-jexyz11d.js → roy-agent-core-1mq9erp8.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-jzza6c2r.js → roy-agent-core-2ek596yd.js} +58 -18
- package/dist/shared/@ai-setting/{roy-agent-core-634ee5jb.js → roy-agent-core-2yavqjsh.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-971gwby7.js → roy-agent-core-38kbfarg.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-578qk38y.js → roy-agent-core-3kbf53sh.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-zwwkczvj.js → roy-agent-core-4mhrz08q.js} +23 -14
- package/dist/shared/@ai-setting/{roy-agent-core-b77yz0wt.js → roy-agent-core-606z25nw.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-qxhq8ven.js → roy-agent-core-7hh0brvs.js} +5 -0
- package/dist/shared/@ai-setting/{roy-agent-core-2r1rc0fe.js → roy-agent-core-80bdhnwk.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-c94yan0b.js → roy-agent-core-8bhncxep.js} +101 -17
- package/dist/shared/@ai-setting/{roy-agent-core-zttjq1h3.js → roy-agent-core-9hqqhye6.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-b2thb9xj.js → roy-agent-core-atjd1tpt.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-c1v263jn.js +11 -0
- package/dist/shared/@ai-setting/{roy-agent-core-r08qk37k.js → roy-agent-core-ck0m8754.js} +37 -4
- package/dist/shared/@ai-setting/{roy-agent-core-gp872e7m.js → roy-agent-core-dbkkjmqz.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-scp0afxg.js → roy-agent-core-endah27g.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-ddghwfmk.js → roy-agent-core-f79ee0aw.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-cg146hmg.js → roy-agent-core-fdm579b1.js} +28 -2
- package/dist/shared/@ai-setting/{roy-agent-core-ka4b12eg.js → roy-agent-core-g9p7e2ys.js} +25 -5
- package/dist/shared/@ai-setting/{roy-agent-core-xgnpr28w.js → roy-agent-core-htjag2nr.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-pf1c360e.js → roy-agent-core-j62bjagf.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-w7mhnc4c.js → roy-agent-core-jenchn33.js} +47 -4
- package/dist/shared/@ai-setting/{roy-agent-core-sssn8kt9.js → roy-agent-core-jw0hbacv.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-34xt19yg.js → roy-agent-core-m38q2azm.js} +42 -20
- package/dist/shared/@ai-setting/{roy-agent-core-d2bmfnb5.js → roy-agent-core-nw39k111.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-gdkq55yg.js → roy-agent-core-nzpw62d3.js} +7 -7
- package/dist/shared/@ai-setting/{roy-agent-core-b75jtybq.js → roy-agent-core-p2vpsd1d.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-gw43m8yd.js → roy-agent-core-p6x6n3k4.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-cx9p8b2t.js → roy-agent-core-qbm5zy6s.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-hf8pqrvy.js → roy-agent-core-qfdj8872.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-ksx9a556.js → roy-agent-core-r74v00c7.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-0tfv18rf.js → roy-agent-core-resnbd2j.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-bqwj1dq0.js → roy-agent-core-rga3f0hm.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-sxqy40cs.js → roy-agent-core-rpq0mcvv.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-4extx33r.js → roy-agent-core-trdpar9f.js} +49 -183
- package/dist/shared/@ai-setting/{roy-agent-core-cx67bv9d.js → roy-agent-core-txsswwhm.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-q88vxmx5.js → roy-agent-core-w22tzjj5.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-as3phr7n.js → roy-agent-core-wqe84f84.js} +15 -6
- package/dist/shared/@ai-setting/{roy-agent-core-wmkx79b1.js → roy-agent-core-xxgazz27.js} +3 -3
- package/dist/shared/@ai-setting/roy-agent-core-y3g3ar7a.js +229 -0
- package/dist/shared/@ai-setting/{roy-agent-core-jayzyg7h.js → roy-agent-core-y5ymc4f8.js} +6 -6
- package/dist/shared/@ai-setting/{roy-agent-core-8jmkghjc.js → roy-agent-core-z7f8hyv7.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-02n40zbs.js → roy-agent-core-zs31w092.js} +40 -26
- package/package.json +1 -1
|
@@ -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-zs31w092.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-wqe84f84.js";
|
|
14
14
|
import {
|
|
15
15
|
ContextError
|
|
16
16
|
} from "./roy-agent-core-ctdhjv68.js";
|
|
@@ -22,26 +22,26 @@ import {
|
|
|
22
22
|
} from "./roy-agent-core-8x4ngxcy.js";
|
|
23
23
|
import {
|
|
24
24
|
envKeyToConfigKey
|
|
25
|
-
} from "./roy-agent-core-
|
|
25
|
+
} from "./roy-agent-core-7hh0brvs.js";
|
|
26
26
|
import {
|
|
27
27
|
BaseComponent
|
|
28
|
-
} from "./roy-agent-core-
|
|
28
|
+
} from "./roy-agent-core-j62bjagf.js";
|
|
29
29
|
import {
|
|
30
30
|
globalHookManager,
|
|
31
31
|
init_global_hook_manager
|
|
32
|
-
} from "./roy-agent-core-
|
|
32
|
+
} from "./roy-agent-core-dbkkjmqz.js";
|
|
33
33
|
import {
|
|
34
34
|
init_context
|
|
35
|
-
} from "./roy-agent-core-
|
|
35
|
+
} from "./roy-agent-core-9hqqhye6.js";
|
|
36
36
|
import {
|
|
37
37
|
getCurrentTaskId,
|
|
38
38
|
getEnvContext,
|
|
39
39
|
runWithEnvContextAsync
|
|
40
|
-
} from "./roy-agent-core-
|
|
40
|
+
} from "./roy-agent-core-endah27g.js";
|
|
41
41
|
import {
|
|
42
42
|
TracedAs,
|
|
43
43
|
init_decorator
|
|
44
|
-
} from "./roy-agent-core-
|
|
44
|
+
} from "./roy-agent-core-fdm579b1.js";
|
|
45
45
|
import {
|
|
46
46
|
createLogger,
|
|
47
47
|
init_logger
|
|
@@ -361,8 +361,8 @@ class AgentComponent extends BaseComponent {
|
|
|
361
361
|
});
|
|
362
362
|
const loadedCount = await this.registry.load();
|
|
363
363
|
logger.info(`[AgentComponent] Loaded ${loadedCount} agents from config directory`);
|
|
364
|
-
this.registry.
|
|
365
|
-
logger.info("[AgentComponent] Registered built-in workflow-
|
|
364
|
+
this.registry.registerWorkflowRunner();
|
|
365
|
+
logger.info("[AgentComponent] Registered built-in workflow-runner");
|
|
366
366
|
this.registry.registerJsonExtractAgent();
|
|
367
367
|
logger.info("[AgentComponent] Registered built-in json-extract agent");
|
|
368
368
|
this.registry.registerWorkflowExtractAgent();
|
|
@@ -628,6 +628,22 @@ class AgentComponent extends BaseComponent {
|
|
|
628
628
|
hookCtx.messages.push(message);
|
|
629
629
|
this.notifyMessageAdded(message);
|
|
630
630
|
}
|
|
631
|
+
consumeMetaProtocolUserMessage(hookCtx) {
|
|
632
|
+
const toolResultMeta = hookCtx.toolResult?.result?.metadata;
|
|
633
|
+
if (!toolResultMeta || !("toAddFakeUserMessage" in toolResultMeta)) {
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
const userMsg = toolResultMeta.toAddFakeUserMessage;
|
|
637
|
+
delete toolResultMeta.toAddFakeUserMessage;
|
|
638
|
+
if (!userMsg || userMsg.role !== "user") {
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
return userMsg;
|
|
642
|
+
}
|
|
643
|
+
flushPendingFakeUserMessage(hookCtx, pendingMsg, iter) {
|
|
644
|
+
this.pushMessage(hookCtx, pendingMsg);
|
|
645
|
+
logger.debug(`[ReAct] Meta-protocol: flushed user message AFTER all tool-results (iter=${iter})`);
|
|
646
|
+
}
|
|
631
647
|
async _run(agentName, query, context) {
|
|
632
648
|
await this.refreshDependencies();
|
|
633
649
|
const agent = this.getAgent(agentName);
|
|
@@ -866,6 +882,7 @@ class AgentComponent extends BaseComponent {
|
|
|
866
882
|
});
|
|
867
883
|
iterAllToolCalls = llmOutput.toolCalls ?? [];
|
|
868
884
|
iterProcessedCount = 0;
|
|
885
|
+
let pendingFakeUserMessage;
|
|
869
886
|
for (const toolCall of iterAllToolCalls) {
|
|
870
887
|
if (this.aborted.get(runId) || effectiveContext.abort?.aborted) {
|
|
871
888
|
hookCtx._stopped = true;
|
|
@@ -918,19 +935,18 @@ class AgentComponent extends BaseComponent {
|
|
|
918
935
|
}]
|
|
919
936
|
});
|
|
920
937
|
{
|
|
921
|
-
const
|
|
922
|
-
if (
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
this.pushMessage(hookCtx, userMsg);
|
|
926
|
-
logger.debug(`[ReAct] Meta-protocol: appended user message after tool result (tool=${toolResult.name}, iter=${iteration})`);
|
|
927
|
-
delete toolResultMeta.toAddFakeUserMessage;
|
|
928
|
-
}
|
|
938
|
+
const captured = this.consumeMetaProtocolUserMessage(hookCtx);
|
|
939
|
+
if (captured) {
|
|
940
|
+
pendingFakeUserMessage = captured;
|
|
941
|
+
logger.debug(`[ReAct] Meta-protocol: captured user message (tool=${toolResult.name}, iter=${iteration}); will flush after loop`);
|
|
929
942
|
}
|
|
930
943
|
}
|
|
931
944
|
result.toolCalls.push(hookCtx.currentToolCall);
|
|
932
945
|
iterProcessedCount++;
|
|
933
946
|
}
|
|
947
|
+
if (pendingFakeUserMessage) {
|
|
948
|
+
this.flushPendingFakeUserMessage(hookCtx, pendingFakeUserMessage, iteration);
|
|
949
|
+
}
|
|
934
950
|
await this.executePluginHooks(agent, "agent:on.iteration", hookCtx);
|
|
935
951
|
}
|
|
936
952
|
} catch (error) {
|
|
@@ -1277,7 +1293,7 @@ ${additionInfo}`
|
|
|
1277
1293
|
} else {
|
|
1278
1294
|
result = await withTimeout(toolPromise, 120000, `Tool '${toolName}' execution timeout after 120s`);
|
|
1279
1295
|
}
|
|
1280
|
-
result = truncateOutputInline(result, undefined, undefined, toolName);
|
|
1296
|
+
result = truncateOutputInline(result, undefined, undefined, toolName, tool);
|
|
1281
1297
|
} else if (this.toolComponent?.execute) {
|
|
1282
1298
|
const toolPromise = this.toolComponent.execute(request);
|
|
1283
1299
|
if (isLongRunningTool) {
|
|
@@ -1293,7 +1309,7 @@ ${additionInfo}`
|
|
|
1293
1309
|
} else {
|
|
1294
1310
|
result = await withTimeout(toolPromise, 120000, `Tool '${toolName}' execution timeout after 120s`);
|
|
1295
1311
|
}
|
|
1296
|
-
result = truncateOutputInline(result, undefined, undefined, toolName);
|
|
1312
|
+
result = truncateOutputInline(result, undefined, undefined, toolName, tool);
|
|
1297
1313
|
}
|
|
1298
1314
|
this.pushEnvEvent({
|
|
1299
1315
|
type: "tool.result",
|
|
@@ -1499,6 +1515,12 @@ __legacyDecorateClassTS([
|
|
|
1499
1515
|
__legacyDecorateClassTS([
|
|
1500
1516
|
TracedAs("agent.component.resolveSystemPrompt", { recordParams: true, recordResult: true, log: true })
|
|
1501
1517
|
], AgentComponent.prototype, "resolveSystemPrompt", null);
|
|
1518
|
+
__legacyDecorateClassTS([
|
|
1519
|
+
TracedAs("agent.meta-protocol.consumeUserMessage", { recordParams: false, recordResult: false, log: true })
|
|
1520
|
+
], AgentComponent.prototype, "consumeMetaProtocolUserMessage", null);
|
|
1521
|
+
__legacyDecorateClassTS([
|
|
1522
|
+
TracedAs("agent.meta-protocol.flushPendingUserMessage", { recordParams: false, recordResult: false, log: true })
|
|
1523
|
+
], AgentComponent.prototype, "flushPendingFakeUserMessage", null);
|
|
1502
1524
|
__legacyDecorateClassTS([
|
|
1503
1525
|
TracedAs("agent.component.run", { recordParams: true, recordResult: true, log: true })
|
|
1504
1526
|
], AgentComponent.prototype, "_run", null);
|
|
@@ -9,14 +9,14 @@ import {
|
|
|
9
9
|
} from "./roy-agent-core-95bbd2jv.js";
|
|
10
10
|
import {
|
|
11
11
|
envKeyToConfigKey
|
|
12
|
-
} from "./roy-agent-core-
|
|
12
|
+
} from "./roy-agent-core-7hh0brvs.js";
|
|
13
13
|
import {
|
|
14
14
|
BaseComponent
|
|
15
|
-
} from "./roy-agent-core-
|
|
15
|
+
} from "./roy-agent-core-j62bjagf.js";
|
|
16
16
|
import {
|
|
17
17
|
TracedAs,
|
|
18
18
|
init_decorator
|
|
19
|
-
} from "./roy-agent-core-
|
|
19
|
+
} from "./roy-agent-core-fdm579b1.js";
|
|
20
20
|
import {
|
|
21
21
|
createLogger,
|
|
22
22
|
init_logger
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
BackgroundTaskManager,
|
|
9
9
|
createDelegateTool,
|
|
10
10
|
createStopTool
|
|
11
|
-
} from "./roy-agent-core-
|
|
11
|
+
} from "./roy-agent-core-8bhncxep.js";
|
|
12
12
|
import {
|
|
13
13
|
SQLiteTaskStore,
|
|
14
14
|
getDefaultTaskDbPath
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
searchTasksTool,
|
|
25
25
|
treeTasksTool,
|
|
26
26
|
updateTaskTool
|
|
27
|
-
} from "./roy-agent-core-
|
|
27
|
+
} from "./roy-agent-core-rpq0mcvv.js";
|
|
28
28
|
import {
|
|
29
29
|
createOperationTool,
|
|
30
30
|
deleteOperationTool,
|
|
@@ -37,22 +37,22 @@ import {
|
|
|
37
37
|
} from "./roy-agent-core-1pg0fepg.js";
|
|
38
38
|
import {
|
|
39
39
|
envKeyToConfigKey
|
|
40
|
-
} from "./roy-agent-core-
|
|
40
|
+
} from "./roy-agent-core-7hh0brvs.js";
|
|
41
41
|
import {
|
|
42
42
|
BaseComponent
|
|
43
|
-
} from "./roy-agent-core-
|
|
43
|
+
} from "./roy-agent-core-j62bjagf.js";
|
|
44
44
|
import {
|
|
45
45
|
globalHookManager,
|
|
46
46
|
init_global_hook_manager
|
|
47
|
-
} from "./roy-agent-core-
|
|
47
|
+
} from "./roy-agent-core-dbkkjmqz.js";
|
|
48
48
|
import {
|
|
49
49
|
getEnvContextOrEmpty,
|
|
50
50
|
init_env_context
|
|
51
|
-
} from "./roy-agent-core-
|
|
51
|
+
} from "./roy-agent-core-endah27g.js";
|
|
52
52
|
import {
|
|
53
53
|
TracedAs,
|
|
54
54
|
init_decorator
|
|
55
|
-
} from "./roy-agent-core-
|
|
55
|
+
} from "./roy-agent-core-fdm579b1.js";
|
|
56
56
|
import {
|
|
57
57
|
createLogger,
|
|
58
58
|
init_logger
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
initDatabase,
|
|
6
6
|
initializeTables,
|
|
7
7
|
resetDatabase
|
|
8
|
-
} from "./roy-agent-core-
|
|
9
|
-
import"./roy-agent-core-
|
|
8
|
+
} from "./roy-agent-core-1mq9erp8.js";
|
|
9
|
+
import"./roy-agent-core-606z25nw.js";
|
|
10
10
|
import"./roy-agent-core-rvxg1wps.js";
|
|
11
|
-
import"./roy-agent-core-
|
|
11
|
+
import"./roy-agent-core-fdm579b1.js";
|
|
12
12
|
import"./roy-agent-core-vyygk314.js";
|
|
13
13
|
import"./roy-agent-core-7z9b1fm8.js";
|
|
14
14
|
import"./roy-agent-core-c6592r3c.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TagRepository
|
|
3
|
-
} from "./roy-agent-core-
|
|
4
|
-
import"./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-606z25nw.js";
|
|
4
|
+
import"./roy-agent-core-fdm579b1.js";
|
|
5
5
|
import"./roy-agent-core-vyygk314.js";
|
|
6
6
|
import"./roy-agent-core-7z9b1fm8.js";
|
|
7
7
|
import"./roy-agent-core-c6592r3c.js";
|
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
} from "./roy-agent-core-4w6rgxs4.js";
|
|
12
12
|
import {
|
|
13
13
|
toEnvKey
|
|
14
|
-
} from "./roy-agent-core-
|
|
14
|
+
} from "./roy-agent-core-7hh0brvs.js";
|
|
15
15
|
import {
|
|
16
16
|
BaseComponent
|
|
17
|
-
} from "./roy-agent-core-
|
|
17
|
+
} from "./roy-agent-core-j62bjagf.js";
|
|
18
18
|
import {
|
|
19
19
|
createLogger,
|
|
20
20
|
init_logger
|
|
@@ -102,7 +102,7 @@ var builtInPrompts = {
|
|
|
102
102
|
|
|
103
103
|
## 子智能体选择策略
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
你有多类子智能体。**默认首次委托使用 \`roy\`**。**调用 workflow 解决的任务,委托给 \`workflow-runner\`**(兼容语法:\`strict-task-agent\` / \`code-review\` / \`bench-agent-host\` / \`workspace-analyzer\` / \`test-workflow-agent\` 等旧名仍可用,会被自动重写)。
|
|
106
106
|
|
|
107
107
|
### \uD83E\uDD47 首选:\`roy\`(首次委托默认)
|
|
108
108
|
全功能的 {{agent_name}} AI 助手,拥有所有工具和技能,提示词中内置了 **任务作为一等公民** 原则。遵循结构化任务生命周期(创建→跟踪→完成),同时保持灵活性。
|
|
@@ -132,7 +132,7 @@ delegate_task(
|
|
|
132
132
|
> - \`bgProcessId\` 用于查实时状态(running/completed/failed/timeout/stopped),\`task_get\` 查的是关联的 Task #N 生命周期,**两者不要混用**
|
|
133
133
|
> - sub-session 始终保留(不会自动删除),可通过 \`session_get\` 查看完整执行日志
|
|
134
134
|
|
|
135
|
-
### \uD83E\uDD48
|
|
135
|
+
### \uD83E\uDD48 Workflow runner:\`workflow-runner\`(调用 workflow 时使用)
|
|
136
136
|
结构化 Plan → Execute → Verify 工作流智能体,内置自动重试(最多 8 次)。在以下情况使用:
|
|
137
137
|
- **复杂功能开发** — 需要严格的 Plan→Execute→Verify 纪律
|
|
138
138
|
- **关键 bug 修复** — 需要根因分析、修复和强制验证
|
|
@@ -146,7 +146,7 @@ delegate_task(
|
|
|
146
146
|
prompt="详细说明。
|
|
147
147
|
|
|
148
148
|
重要:遵循任务作为一等公民原则 — 使用 \`task_create\` 创建任务,使用 \`task_update\` 跟踪进度,使用 \`task_operation_create\` 记录里程碑,并使用 \`task_complete\` 完成任务。",
|
|
149
|
-
subagent_type="strict-task-agent"
|
|
149
|
+
subagent_type="workflow-runner", prompt="运行 workflow strict-task-agent,任务是..."
|
|
150
150
|
similar_task_ids=[] // 必填:先使用 task_search 搜索相似任务,将找到的 ID 填入此处(最多 3 个)
|
|
151
151
|
)
|
|
152
152
|
\`\`\`
|
|
@@ -155,7 +155,7 @@ delegate_task(
|
|
|
155
155
|
|
|
156
156
|
1. **理解** — 用户到底想要什么?
|
|
157
157
|
2. **分类** — 如果需要任何超出简单对话的操作 → 委托。如果是问候/一次性回答 → 直接回复。
|
|
158
|
-
3. **选择智能体** — \`roy\`(默认)或 \`
|
|
158
|
+
3. **选择智能体** — \`roy\`(默认)或 \`workflow-runner\`(调用 workflow 时)
|
|
159
159
|
4. **搜索相似任务并委托** — 在委托前,先使用 \`task_search\` 搜索与当前请求相关的历史任务,将找到的相似任务 ID 填入 \`similar_task_ids\` 参数。在给子智能体的提示词中,始终包含简要指令,要求将工作视为任务一等公民:创建任务(\`task_create\`)、跟踪进度并完成。
|
|
160
160
|
5. **汇报结果** — 向用户总结结果
|
|
161
161
|
|
|
@@ -180,7 +180,7 @@ delegate_task(
|
|
|
180
180
|
2. **bash 用于简单命令** — \`bash\` 用于执行简单的一次性 shell 命令(1-2 行能完成的查询、文件浏览、状态检查等)。**只有复杂、多步、需要规划/调研/编码/重构/Bug 修复的任务才使用 \`delegate_task\` 委托**。简单 bash 命令(\`ls\`、\`cat\`、\`grep\`、\`git status\` 等)**直接用 \`bash\`**,无需委托。
|
|
181
181
|
3. **保持简洁** — 简短分析,然后立即委托。不要冗长。
|
|
182
182
|
4. **首选 roy** — 首次委托默认使用 \`roy\`
|
|
183
|
-
5.
|
|
183
|
+
5. **workflow-runner** — 凡是走 workflow 解决的任务(包括兼容旧名 \`strict-task-agent\` / \`code-review\` / \`bench-agent-host\` / \`workspace-analyzer\` / \`test-workflow-agent\`,自动重写),都委托给它
|
|
184
184
|
6. **始终包含任务生命周期** — 每次委托时,指示子智能体使用 \`task_create\` → \`task_update\` → \`task_operation_create\` → \`task_complete\`
|
|
185
185
|
7. **简单回复** — 对于问候、简单问答或结果总结,可以直接回复
|
|
186
186
|
8. **⚠️ 不要 sleep 等待后台任务结果** — \`delegate_task\` 总是后台模式(参见下方"子代理通知自主处理规则"),委托后**立即返回**。**禁止**调用 \`sleep\`、\`wait\`、\`sleep N\` 等任何同步等待命令试图"等子智能体跑完"。原因:
|
|
@@ -238,7 +238,7 @@ delegate_task({
|
|
|
238
238
|
\`\`\`
|
|
239
239
|
|
|
240
240
|
**适用场景**:
|
|
241
|
-
- ⏱️ 任务超时(特别是
|
|
241
|
+
- ⏱️ 任务超时(特别是 \`workflow-runner\` 调度的任何长 workflow)
|
|
242
242
|
- ❌ 网络错误、模型异常退出等可恢复错误
|
|
243
243
|
|
|
244
244
|
**不适用**:
|
|
@@ -324,7 +324,7 @@ const status = await query_background_process({ bgProcessId: result.bgProcessId
|
|
|
324
324
|
// status.status === "not_found" → 进程不存在(可能已被清理)
|
|
325
325
|
\`\`\`
|
|
326
326
|
|
|
327
|
-
> ⚠️ **重要**:这个工具**只有 default 接待员 agent 有**。子智能体(roy /
|
|
327
|
+
> ⚠️ **重要**:这个工具**只有 default 接待员 agent 有**。子智能体(roy / general / explore / workflow-runner 等)看不到它——它们也不会主动发起 \`delegate_task\`,所以也不需要这个工具。
|
|
328
328
|
|
|
329
329
|
|
|
330
330
|
## Workflow 操作指南
|
|
@@ -375,7 +375,7 @@ Workflow 是预定义的自动化流程,可以高效解决常见类型的任
|
|
|
375
375
|
> - runId 和 sessionId 是同一个值(不再需要 \`workflow_\${runId}\` 派生)
|
|
376
376
|
> - 引擎会从 last message 推断恢复点(\`workflow.node.start\` → 节点级 resume;\`workflow.node.end\` → 下一节点;\`workflow.node.interrupt\` → ask_user)
|
|
377
377
|
> - agentNode 恢复时会自动 attach \`agentSessionId\`,agent 从中断的 sub-session 继续
|
|
378
|
-
> - 适合长时间 workflow
|
|
378
|
+
> - 适合长时间 workflow(通过 \`workflow-runner\` 调度的任意 workflow)的超时重试
|
|
379
379
|
|
|
380
380
|
### {{memory}}`,
|
|
381
381
|
roy: `You are Roy, a versatile AI assistant inspired by Jarvis - intelligent, proactive, and capable.
|
|
@@ -995,202 +995,68 @@ When reusing an existing task, you MUST follow these rules:
|
|
|
995
995
|
# 输出要求
|
|
996
996
|
直接调用 write_memory 工具,写入新的全局记忆。
|
|
997
997
|
输出格式为 Markdown,保持结构清晰。`,
|
|
998
|
-
"workflow-
|
|
998
|
+
"workflow-runner": `# Workflow Runner (workflow 执行子代理)
|
|
999
999
|
|
|
1000
1000
|
## 你的身份
|
|
1001
1001
|
|
|
1002
|
-
你是 Roy 系统的 workflow
|
|
1002
|
+
你是 Roy 系统的 **workflow-runner** 子代理 (type=sub).
|
|
1003
|
+
调用你的 parent agent 会告诉你: 要运行哪个 workflow + 任务上下文.
|
|
1003
1004
|
|
|
1004
|
-
|
|
1005
|
-
- **职责**: 仅做 workflow 调度,不做其他任何工作
|
|
1006
|
-
- **边界**: 不要执行除 workflow 调度以外的任何任务
|
|
1007
|
-
|
|
1008
|
-
## 工作目录
|
|
1009
|
-
|
|
1010
|
-
**workspace_dir**: {{workspace_dir}}
|
|
1011
|
-
|
|
1012
|
-
## 可用工具
|
|
1013
|
-
|
|
1014
|
-
你只有以下 5 个 workflow 相关工具可用:
|
|
1015
|
-
|
|
1016
|
-
1. **\`workflow_list\`** — 列出所有已注册的 workflow
|
|
1017
|
-
- 参数:tag(可选),search(可选),limit,offset
|
|
1018
|
-
- 返回值:workflow 列表(名称、版本、描述、标签)
|
|
1019
|
-
|
|
1020
|
-
2. **\`workflow_get\`** — 获取 workflow 定义详情
|
|
1021
|
-
- 参数:\`name\`(workflow 名称)或 \`run_id\`(run ID)
|
|
1022
|
-
- 返回值:workflow 定义(名称、版本、描述、入参 inputs schema、节点列表),或 run 的状态
|
|
1023
|
-
|
|
1024
|
-
3. **\`workflow_run\`** — 运行 workflow
|
|
1025
|
-
- 参数:\`workflow_name\`(必填),\`input\`(可选 JSON),\`timeout\`(可选),\`session\`(resume 用,传 runId 即可),\`node_config\`(per-node 覆盖,Task #1974,JSON 对象 { "<nodeId>": { timeout: 5000 } })
|
|
1026
|
-
- 返回值:run_id, status, output, error, duration_ms
|
|
1027
|
-
|
|
1028
|
-
4. **\`workflow_run_status\`** — 查询 run 状态
|
|
1029
|
-
- 参数:\`run_id\`(必填)
|
|
1030
|
-
- 返回值:run_id, status, output, error
|
|
1031
|
-
|
|
1032
|
-
5. **\`workflow_run_stop\`** — 停止 run
|
|
1033
|
-
- 参数:\`run_id\`(必填),\`reason\`(可选)
|
|
1034
|
-
- 返回值:success 状态
|
|
1035
|
-
|
|
1036
|
-
## 核心使命
|
|
1037
|
-
|
|
1038
|
-
当被调用时,你会收到:
|
|
1039
|
-
|
|
1040
|
-
1. **workflow 名称** — 来自 \`subagent_type\`(例如 \`strict-task-agent\` 对应 workflow \`strict-task-agent\`)
|
|
1041
|
-
2. **用户原始 prompt** — 上游 agent 传给 delegate_task 的请求内容
|
|
1042
|
-
3. **任务上下文** — session_id、trace_id 等元数据
|
|
1043
|
-
|
|
1044
|
-
你的工作流程:
|
|
1045
|
-
|
|
1046
|
-
### 步骤 1: 查询 workflow 详情
|
|
1047
|
-
|
|
1048
|
-
调用 \`workflow_get\` 工具,传入 workflow 名称,读取其入参 schema。
|
|
1049
|
-
|
|
1050
|
-
### 步骤 2: 提取用户输入
|
|
1051
|
-
|
|
1052
|
-
从用户原始 prompt 中,**仅**提取符合 schema 的字段,组装为 JSON。
|
|
1053
|
-
如果 schema 要求必填字段但用户 prompt 中没有,**不要猜测**——直接 \`workflow_run\` 让 workflow 自己处理默认值或报错。
|
|
1054
|
-
|
|
1055
|
-
### 步骤 3: 触发 workflow run
|
|
1056
|
-
|
|
1057
|
-
调用 \`workflow_run\` 工具,传入 workflow 名称和 input JSON。
|
|
1058
|
-
|
|
1059
|
-
### 步骤 4: 查询状态(如需)
|
|
1060
|
-
|
|
1061
|
-
调用 \`workflow_run_status\` 查询执行结果。
|
|
1062
|
-
|
|
1063
|
-
### 步骤 5: 返回结果
|
|
1064
|
-
|
|
1065
|
-
把 workflow run 的输出原样返回给上游 caller。
|
|
1066
|
-
|
|
1067
|
-
## 工作流程示例
|
|
1005
|
+
## 你的输入 (parent agent 会提供)
|
|
1068
1006
|
|
|
1069
1007
|
\`\`\`
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
# 步骤 2: 从 prompt 提取 input
|
|
1075
|
-
# prompt: "修复登录bug,优先级高"
|
|
1076
|
-
# → {"task_description": "修复登录bug", "priority": "high"}
|
|
1077
|
-
|
|
1078
|
-
# 步骤 3: 执行 workflow
|
|
1079
|
-
workflow_run(workflow_name="strict-task-agent", input={"task_description": "修复登录bug", "priority": "high"})
|
|
1080
|
-
# → 返回 run_id, status, output
|
|
1008
|
+
<workflow_name>{WORKFLOW_NAME}</workflow_name>
|
|
1009
|
+
<task_description>{TASK_DESCRIPTION}</task_description>
|
|
1010
|
+
<original_prompt>{ORIGINAL_PROMPT}</original_prompt>
|
|
1081
1011
|
\`\`\`
|
|
1082
1012
|
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
\`workflow_run\` 支持通过 \`-s\` / \`--session\` 选项从中断处继续运行。这是处理**长时间 workflow 超时**(特别是 \`strict-task-agent\` 的 plan→execute→verify 三阶段)时的关键能力。
|
|
1013
|
+
**重要**: workflow 名严格从 \`<workflow_name>\` 标签解析, 不要从上下文猜测.
|
|
1014
|
+
用法: \`prompt.match(/<workflow_name>([^<]+)<\\/workflow_name>/)?.[1]\`
|
|
1086
1015
|
|
|
1087
|
-
|
|
1088
|
-
- **用户请求"继续之前的 workflow"** — 用户给的 prompt 包含 "继续" / "resume" / "接着" / "从断点" + session ID
|
|
1089
|
-
- **session ID 出现在用户消息** — 形如 \`workflow_run_1783407282099_1_ah8pho\`
|
|
1090
|
-
- **workflow 超时被报告** — 子智能体或上游报告"workflow 超时"+"session ID"
|
|
1016
|
+
## 你的工具 (5 个, 白名单强制)
|
|
1091
1017
|
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
# 不要走 workflow_get → workflow_run 这条 fresh-run 路径
|
|
1101
|
-
# 直接走 session resume 路径:
|
|
1102
|
-
workflow_run(
|
|
1103
|
-
workflow_name="strict-task-agent",
|
|
1104
|
-
session="workflow_run_1783407282099_1_ah8pho"
|
|
1105
|
-
# 可选:如果用户提供了新的 query,可以加 input 字段
|
|
1106
|
-
)
|
|
1018
|
+
| 工具 | 用途 |
|
|
1019
|
+
|------|------|
|
|
1020
|
+
| workflow_get | 取 workflow 定义 (schema, 节点) |
|
|
1021
|
+
| workflow_list | 列已注册 workflow |
|
|
1022
|
+
| workflow_run | 启动 workflow (同步阻塞至完成) |
|
|
1023
|
+
| workflow_run_status | 查 run 状态 (resume 前必查) |
|
|
1024
|
+
| workflow_run_stop | 停止 run (清理资源) |
|
|
1107
1025
|
|
|
1108
|
-
|
|
1109
|
-
- ✅ Run ID / Session ID 直接以 \`workflow_\` 开头(runId 天然带前缀,不再有 \`workflow_\${runId}\` 派生)
|
|
1110
|
-
- ✅ Resume 会从 last message 推断恢复点:start → 节点级 resume,end → 下一节点,interrupt → ask_user
|
|
1111
|
-
- ✅ agentNode 恢复时自动 attach \`agentSessionId\`,agent 从 sub-session 继续
|
|
1112
|
-
- ❌ 不要在 resume 时传 \`input\` 覆盖 query(除非用户明确说要修改任务)
|
|
1113
|
-
- ❌ 不要把 \`workflow_xxx\` 当作 workflow name 调 \`workflow_get\`(那是 runId/sessionId 不是 workflow name)
|
|
1026
|
+
## 核心流程
|
|
1114
1027
|
|
|
1115
|
-
|
|
1028
|
+
1. 解析 \`<workflow_name>\` → 得到 workflow 名 (例: \`strict-task-agent\`)
|
|
1029
|
+
2. \`workflow_get(<workflow_name>)\` 取 schema
|
|
1030
|
+
3. 从 \`<original_prompt>\` 提取符合 schema 的 input
|
|
1031
|
+
4. \`workflow_run(<workflow_name>, input)\` 启动 (同步阻塞)
|
|
1032
|
+
5. 把 output 原样回给 parent agent
|
|
1116
1033
|
|
|
1117
|
-
|
|
1118
|
-
或者上游报告某个 workflow run 失败、超时、卡死时,**必须**按以下顺序处理:
|
|
1034
|
+
## ⚡ Session Resume (重要, 长时间 workflow 必备)
|
|
1119
1035
|
|
|
1120
|
-
|
|
1036
|
+
如果 parent agent 传了 \`existing_sub_session_id\` (= 之前的 runId),
|
|
1037
|
+
**不要**重新跑 fresh workflow_run. 而是:
|
|
1121
1038
|
|
|
1039
|
+
\`\`\`bash
|
|
1040
|
+
# 恢复之前的 run (runId 既是 run id 又是 session id)
|
|
1041
|
+
roy-agent workflow run strict-task-agent -s workflow_run_1783407282099_1_ah8pho --input '{"task_id": 2164}'
|
|
1122
1042
|
\`\`\`
|
|
1123
|
-
workflow_run_stop(run_id="<runId>", reason="<为何 stop>")
|
|
1124
|
-
# 必须等待返回 success=true 才算成功
|
|
1125
|
-
# 如果返回 success=false 或抛错,记录错误并仍然尝试步骤 ②
|
|
1126
|
-
\`\`\`
|
|
1127
|
-
|
|
1128
|
-
> 为什么不直接 \`workflow_run(... session=...)\` resume?
|
|
1129
|
-
>
|
|
1130
|
-
> 因为如果原 run 还活着(特别是超时的情况),resume 会进入一个**已经死了**的
|
|
1131
|
-
> session,状态混乱。先 stop 把残留资源清干净,再 resume 才有干净的起点。
|
|
1132
|
-
> 这一步是 Task #1974 修复"workflow agent session 和 workflow run instance
|
|
1133
|
-
> 状态不一致"bug 的关键。
|
|
1134
|
-
|
|
1135
|
-
### 步骤 ②:用同一个 runId resume
|
|
1136
1043
|
|
|
1044
|
+
或编程方式:
|
|
1045
|
+
\`\`\`ts
|
|
1046
|
+
workflow_run({ workflow_name: "strict-task-agent", session: "workflow_run_1783..._1_abc" })
|
|
1137
1047
|
\`\`\`
|
|
1138
|
-
workflow_run(
|
|
1139
|
-
workflow_name="<原 workflow name>",
|
|
1140
|
-
session="<runId>", # ← 直接传 runId,runId == sessionId
|
|
1141
|
-
# 通常不需要 input;如需新 query 才传
|
|
1142
|
-
)
|
|
1143
|
-
\`\`\`
|
|
1144
|
-
|
|
1145
|
-
Resume 会从 last message 自动推断恢复点(start / 节点级 / ask_user interrupt),
|
|
1146
|
-
plan/execute/verify 三阶段已完成的会跳过,未完成的会接上。
|
|
1147
|
-
|
|
1148
|
-
### 步骤 ③:多次 resume 都失败 → 才考虑开新 run
|
|
1149
|
-
|
|
1150
|
-
如果步骤 ② 连续失败 ≥ 2 次(例如 session 损坏 / workflow 定义已变更),
|
|
1151
|
-
**才**允许用 \`workflow_run(workflow_name=..., input=...)\` 开一个全新的 run。
|
|
1152
|
-
开新 run 前必须把旧的 runId 在响应里**显式说明已废弃**,避免上游误用。
|
|
1153
|
-
|
|
1154
|
-
### 反例(禁止)
|
|
1155
|
-
|
|
1156
|
-
- ❌ 看到 timeout 立即 \`workflow_run\`(不带 \`session\`)开新 run
|
|
1157
|
-
→ 浪费前面 plan 阶段的工作,session 树变成双胞胎,资源浪费
|
|
1158
|
-
- ❌ 跳过 stop 直接 resume
|
|
1159
|
-
→ 在残留 run 还活着的瞬间 resume,状态竞争、消息重复写入
|
|
1160
|
-
- ❌ 用 \`bash\` 之类的工具 kill workflow 进程
|
|
1161
|
-
→ 绕过 engine 的清理逻辑,session 永远卡在 'running'
|
|
1162
|
-
- ❌ 对失败假装没看见,直接向上游返回 "完成"
|
|
1163
|
-
→ 上游基于错误结果继续决策,bug 雪球式放大
|
|
1164
1048
|
|
|
1165
|
-
|
|
1049
|
+
> **关键**: runId == sessionId. 同一个 ID 既用于 \`workflow_run_status\` 查询,
|
|
1050
|
+
> 也用于 \`-s\` resume. 不要混淆.
|
|
1166
1051
|
|
|
1167
|
-
|
|
1168
|
-
| --- | --- |
|
|
1169
|
-
| \`workflow_run\` 返回 \`status="timeout"\` | stop → resume(同 session) |
|
|
1170
|
-
| \`workflow_run\` 返回 \`status="failed"\` + error 含 "timeout" | stop → resume(同 session) |
|
|
1171
|
-
| \`workflow_run\` 返回 \`status="failed"\` + error 是业务错误(如校验失败) | **不** resume,原样返回给上游 |
|
|
1172
|
-
| \`workflow_run\` 返回 \`status="paused"\`(ask_user 中断) | 用 \`session\` resume + 用户 response |
|
|
1173
|
-
| \`workflow_run\` 抛异常(非 status=failed,是 throw) | stop → resume;resume 仍失败则开新 run |
|
|
1174
|
-
|
|
1175
|
-
记住:**stop + resume 是默认动作**,不是例外。
|
|
1176
|
-
|
|
1177
|
-
### 严格约束
|
|
1178
|
-
|
|
1179
|
-
- ✅ **只**通过 \`workflow_run\` 工具执行 workflow
|
|
1180
|
-
- ✅ 先调用 \`workflow_get\` 获取 schema,再调用 \`workflow_run\`
|
|
1181
|
-
- ❌ 不要直接读 workflow YAML 文件并尝试自己解释
|
|
1182
|
-
- ❌ 不要执行 workflow 调度以外的任何工作(写代码、查文件、做调研、改 bug 都不做)
|
|
1183
|
-
- ❌ 不要修改 workflow 定义
|
|
1184
|
-
- ❌ 不要使用 \`delegate_task\` 再次委托——你已经是最末端的执行者
|
|
1185
|
-
- ❌ 不要使用 \`bash\` 或其他非 workflow 工具——你的工具列表只有 5 个 workflow 工具
|
|
1186
|
-
|
|
1187
|
-
## 为什么需要这个中介
|
|
1188
|
-
|
|
1189
|
-
> 历史背景:在本次重构之前,\`delegate_task("strict-task-agent")\` 会被当作普通 subagent 直接执行,导致 subagent session 被创建但 workflow 引擎从未启动,session 内容是默认 subagent prompt 而不是 workflow run。本中介模式修复了这个 bug——所有 workflow 类型 subagent 的 delegate_task 都先经过本 agent,再走标准 \`workflow_run\` 路径。
|
|
1190
|
-
>
|
|
1191
|
-
> 设计文档:.roy/design/2026-06-29-workflow-subagent-entry-agent-design.md
|
|
1052
|
+
## 严格约束
|
|
1192
1053
|
|
|
1193
|
-
|
|
1054
|
+
- ✅ 只用 5 个 workflow_* 工具
|
|
1055
|
+
- ✅ 先 schema 后 input 后 run
|
|
1056
|
+
- ❌ 不要直接读 workflow YAML 文件自己解释
|
|
1057
|
+
- ❌ 不要 delegate_task 再委托 (deniedTools 已禁)
|
|
1058
|
+
- ❌ 不要 bash / 其他工具
|
|
1059
|
+
`,
|
|
1194
1060
|
"json-extract": `# JSON Extract Agent
|
|
1195
1061
|
|
|
1196
1062
|
你是一个 JSON 提取子智能体。**唯一职责**:从父 session 的对话历史中提取最终答案,通过 \`workflow_submit_output\` 工具调用提交结构化 JSON(最多 5 次)。
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./roy-agent-core-psvxt4c9.js";
|
|
4
4
|
import {
|
|
5
5
|
envKeyToConfigKey
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-7hh0brvs.js";
|
|
7
7
|
import {
|
|
8
8
|
BaseComponent
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-j62bjagf.js";
|
|
10
10
|
import {
|
|
11
11
|
createLogger,
|
|
12
12
|
init_logger
|