@ai-setting/roy-agent-core 1.5.78 → 1.5.79
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 +1 -1
- package/dist/env/event-source/index.js +2 -2
- package/dist/env/index.js +9 -9
- package/dist/env/task/plugins/index.js +1 -1
- package/dist/env/workflow/engine/index.js +4 -4
- package/dist/env/workflow/index.js +5 -5
- package/dist/env/workflow/tools/index.js +1 -1
- package/dist/index.js +9 -9
- package/dist/shared/@ai-setting/{roy-agent-core-w6j4zyps.js → roy-agent-core-4ws3w7cx.js} +16 -1
- package/dist/shared/@ai-setting/{roy-agent-core-f9xyqx9s.js → roy-agent-core-7mw366pc.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-fkv7ewz9.js → roy-agent-core-7z8fzxck.js} +111 -44
- package/dist/shared/@ai-setting/{roy-agent-core-gb9rb9ny.js → roy-agent-core-8x1gmqcv.js} +8 -3
- package/dist/shared/@ai-setting/{roy-agent-core-4hh4s0w1.js → roy-agent-core-jazhr292.js} +19 -8
- package/dist/shared/@ai-setting/{roy-agent-core-9adgwts7.js → roy-agent-core-m4qjnhz6.js} +18 -2
- package/dist/shared/@ai-setting/{roy-agent-core-r12a2qfv.js → roy-agent-core-n9tw52zb.js} +146 -12
- package/dist/shared/@ai-setting/{roy-agent-core-assbmxe0.js → roy-agent-core-nc0n0bdc.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-yakvqh1d.js → roy-agent-core-qf9gvx02.js} +4 -2
- package/dist/shared/@ai-setting/{roy-agent-core-vqkzn45t.js → roy-agent-core-s83ararq.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-nhfy3p8q.js → roy-agent-core-whw7jap0.js} +23 -1
- package/package.json +1 -1
package/dist/env/agent/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentComponent,
|
|
3
3
|
AgentComponentConfigSchema
|
|
4
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
4
|
+
} from "../../shared/@ai-setting/roy-agent-core-4ws3w7cx.js";
|
|
5
5
|
import"../../shared/@ai-setting/roy-agent-core-r0m0at3x.js";
|
|
6
6
|
import"../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
7
7
|
import"../../shared/@ai-setting/roy-agent-core-zf62vkc4.js";
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
builtInHandlers,
|
|
5
5
|
getBuiltInHandler,
|
|
6
6
|
larkCliHandler
|
|
7
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
7
|
+
} from "../../shared/@ai-setting/roy-agent-core-7mw366pc.js";
|
|
8
8
|
import {
|
|
9
9
|
BUILT_IN_EVENT_SOURCE_TYPES,
|
|
10
10
|
BUILT_IN_EVENT_SOURCE_TYPE_LIST,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
validateEventSourceConfig
|
|
16
16
|
} from "../../shared/@ai-setting/roy-agent-core-xb4hvk1m.js";
|
|
17
17
|
import"../../shared/@ai-setting/roy-agent-core-v8xa6vs8.js";
|
|
18
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
18
|
+
import"../../shared/@ai-setting/roy-agent-core-n9tw52zb.js";
|
|
19
19
|
import"../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
20
20
|
import"../../shared/@ai-setting/roy-agent-core-92z6t4he.js";
|
|
21
21
|
import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
|
package/dist/env/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseEnvironment
|
|
3
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
3
|
+
} from "../shared/@ai-setting/roy-agent-core-8x1gmqcv.js";
|
|
4
4
|
import {
|
|
5
5
|
EventSourceComponent,
|
|
6
6
|
builtInHandlers,
|
|
7
7
|
larkCliHandler
|
|
8
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
8
|
+
} from "../shared/@ai-setting/roy-agent-core-7mw366pc.js";
|
|
9
9
|
import {
|
|
10
10
|
EventSourceInitHooks,
|
|
11
11
|
getDefaultConfigForType,
|
|
@@ -17,15 +17,15 @@ import"../shared/@ai-setting/roy-agent-core-v8xa6vs8.js";
|
|
|
17
17
|
import {
|
|
18
18
|
PluginComponent
|
|
19
19
|
} from "../shared/@ai-setting/roy-agent-core-t1ef8hf2.js";
|
|
20
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
20
|
+
import"../shared/@ai-setting/roy-agent-core-n9tw52zb.js";
|
|
21
21
|
import"../shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
22
22
|
import {
|
|
23
23
|
WorkflowComponent
|
|
24
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
24
|
+
} from "../shared/@ai-setting/roy-agent-core-s83ararq.js";
|
|
25
25
|
import"../shared/@ai-setting/roy-agent-core-fjexv5nm.js";
|
|
26
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
27
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
28
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
26
|
+
import"../shared/@ai-setting/roy-agent-core-jazhr292.js";
|
|
27
|
+
import"../shared/@ai-setting/roy-agent-core-m4qjnhz6.js";
|
|
28
|
+
import"../shared/@ai-setting/roy-agent-core-7z8fzxck.js";
|
|
29
29
|
import"../shared/@ai-setting/roy-agent-core-6atd905e.js";
|
|
30
30
|
import"../shared/@ai-setting/roy-agent-core-99j4w3fx.js";
|
|
31
31
|
import"../shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
|
|
@@ -33,13 +33,13 @@ import"../shared/@ai-setting/roy-agent-core-4t40mkpv.js";
|
|
|
33
33
|
import"../shared/@ai-setting/roy-agent-core-ajx32wzj.js";
|
|
34
34
|
import"../shared/@ai-setting/roy-agent-core-qnrf2aw6.js";
|
|
35
35
|
import"../shared/@ai-setting/roy-agent-core-0vbdz0x7.js";
|
|
36
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
36
|
+
import"../shared/@ai-setting/roy-agent-core-whw7jap0.js";
|
|
37
37
|
import"../shared/@ai-setting/roy-agent-core-h0x19xgn.js";
|
|
38
38
|
import"../shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
39
39
|
import {
|
|
40
40
|
AgentComponent,
|
|
41
41
|
AgentComponentConfigSchema
|
|
42
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
42
|
+
} from "../shared/@ai-setting/roy-agent-core-4ws3w7cx.js";
|
|
43
43
|
import"../shared/@ai-setting/roy-agent-core-r0m0at3x.js";
|
|
44
44
|
import"../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
45
45
|
import {
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
formatExtractorInput,
|
|
10
10
|
formatExtractorInputFromDescription,
|
|
11
11
|
parseExtractorOutput
|
|
12
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
12
|
+
} from "../../../shared/@ai-setting/roy-agent-core-n9tw52zb.js";
|
|
13
13
|
import"../../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
14
14
|
import"../../../shared/@ai-setting/roy-agent-core-92z6t4he.js";
|
|
15
15
|
import"../../../shared/@ai-setting/roy-agent-core-qg4rma4c.js";
|
|
@@ -6,15 +6,15 @@ import {
|
|
|
6
6
|
Scheduler,
|
|
7
7
|
WorkflowEngine,
|
|
8
8
|
init_engine
|
|
9
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
10
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
11
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
9
|
+
} from "../../../shared/@ai-setting/roy-agent-core-jazhr292.js";
|
|
10
|
+
import"../../../shared/@ai-setting/roy-agent-core-m4qjnhz6.js";
|
|
11
|
+
import"../../../shared/@ai-setting/roy-agent-core-7z8fzxck.js";
|
|
12
12
|
import"../../../shared/@ai-setting/roy-agent-core-6atd905e.js";
|
|
13
13
|
import"../../../shared/@ai-setting/roy-agent-core-99j4w3fx.js";
|
|
14
14
|
import"../../../shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
|
|
15
15
|
import"../../../shared/@ai-setting/roy-agent-core-ajx32wzj.js";
|
|
16
16
|
import"../../../shared/@ai-setting/roy-agent-core-qnrf2aw6.js";
|
|
17
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
17
|
+
import"../../../shared/@ai-setting/roy-agent-core-whw7jap0.js";
|
|
18
18
|
import"../../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
19
19
|
import"../../../shared/@ai-setting/roy-agent-core-7tp56w6n.js";
|
|
20
20
|
import"../../../shared/@ai-setting/roy-agent-core-qg4rma4c.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WorkflowComponent
|
|
3
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
3
|
+
} from "../../shared/@ai-setting/roy-agent-core-s83ararq.js";
|
|
4
4
|
import"../../shared/@ai-setting/roy-agent-core-fjexv5nm.js";
|
|
5
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
6
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
7
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
5
|
+
import"../../shared/@ai-setting/roy-agent-core-jazhr292.js";
|
|
6
|
+
import"../../shared/@ai-setting/roy-agent-core-m4qjnhz6.js";
|
|
7
|
+
import"../../shared/@ai-setting/roy-agent-core-7z8fzxck.js";
|
|
8
8
|
import"../../shared/@ai-setting/roy-agent-core-6atd905e.js";
|
|
9
9
|
import"../../shared/@ai-setting/roy-agent-core-99j4w3fx.js";
|
|
10
10
|
import"../../shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
unresolvedVariable
|
|
63
63
|
} from "../../shared/@ai-setting/roy-agent-core-qnrf2aw6.js";
|
|
64
64
|
import"../../shared/@ai-setting/roy-agent-core-0vbdz0x7.js";
|
|
65
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
65
|
+
import"../../shared/@ai-setting/roy-agent-core-whw7jap0.js";
|
|
66
66
|
import {
|
|
67
67
|
Edge,
|
|
68
68
|
NodeAs,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
createSubmitJsonOutputTool,
|
|
10
10
|
init_submit_json_output_tool,
|
|
11
11
|
parseWorkflowJsonOutput
|
|
12
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
12
|
+
} from "../../../shared/@ai-setting/roy-agent-core-whw7jap0.js";
|
|
13
13
|
import"../../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
14
14
|
import {
|
|
15
15
|
createLogger,
|
package/dist/index.js
CHANGED
|
@@ -57,13 +57,13 @@ import {
|
|
|
57
57
|
BaseEnvironment,
|
|
58
58
|
generateDescendingId,
|
|
59
59
|
generateId
|
|
60
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
60
|
+
} from "./shared/@ai-setting/roy-agent-core-8x1gmqcv.js";
|
|
61
61
|
import {
|
|
62
62
|
EventSourceComponent,
|
|
63
63
|
builtInHandlers,
|
|
64
64
|
getBuiltInHandler,
|
|
65
65
|
larkCliHandler
|
|
66
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
66
|
+
} from "./shared/@ai-setting/roy-agent-core-7mw366pc.js";
|
|
67
67
|
import {
|
|
68
68
|
BUILT_IN_EVENT_SOURCE_TYPES,
|
|
69
69
|
BUILT_IN_EVENT_SOURCE_TYPE_LIST,
|
|
@@ -83,20 +83,20 @@ import {
|
|
|
83
83
|
import {
|
|
84
84
|
TaskTagPlugin,
|
|
85
85
|
createAutoTaskPlugin
|
|
86
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
86
|
+
} from "./shared/@ai-setting/roy-agent-core-n9tw52zb.js";
|
|
87
87
|
import {
|
|
88
88
|
BasePlugin
|
|
89
89
|
} from "./shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
90
90
|
import {
|
|
91
91
|
WorkflowComponent
|
|
92
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
92
|
+
} from "./shared/@ai-setting/roy-agent-core-s83ararq.js";
|
|
93
93
|
import {
|
|
94
94
|
init_node_registry_helper,
|
|
95
95
|
registerDecoratorNodeType
|
|
96
96
|
} from "./shared/@ai-setting/roy-agent-core-fjexv5nm.js";
|
|
97
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
98
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
99
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
97
|
+
import"./shared/@ai-setting/roy-agent-core-jazhr292.js";
|
|
98
|
+
import"./shared/@ai-setting/roy-agent-core-m4qjnhz6.js";
|
|
99
|
+
import"./shared/@ai-setting/roy-agent-core-7z8fzxck.js";
|
|
100
100
|
import"./shared/@ai-setting/roy-agent-core-6atd905e.js";
|
|
101
101
|
import"./shared/@ai-setting/roy-agent-core-99j4w3fx.js";
|
|
102
102
|
import"./shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
|
|
@@ -104,7 +104,7 @@ import"./shared/@ai-setting/roy-agent-core-4t40mkpv.js";
|
|
|
104
104
|
import"./shared/@ai-setting/roy-agent-core-ajx32wzj.js";
|
|
105
105
|
import"./shared/@ai-setting/roy-agent-core-qnrf2aw6.js";
|
|
106
106
|
import"./shared/@ai-setting/roy-agent-core-0vbdz0x7.js";
|
|
107
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
107
|
+
import"./shared/@ai-setting/roy-agent-core-whw7jap0.js";
|
|
108
108
|
import {
|
|
109
109
|
Edge,
|
|
110
110
|
NodeAs,
|
|
@@ -116,7 +116,7 @@ import"./shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
|
116
116
|
import {
|
|
117
117
|
AgentComponent,
|
|
118
118
|
AgentComponentConfigSchema
|
|
119
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
119
|
+
} from "./shared/@ai-setting/roy-agent-core-4ws3w7cx.js";
|
|
120
120
|
import {
|
|
121
121
|
createInvokeConfig,
|
|
122
122
|
invoke,
|
|
@@ -512,6 +512,12 @@ class AgentComponent extends BaseComponent {
|
|
|
512
512
|
toolNames: tools.map((t) => t.name)
|
|
513
513
|
});
|
|
514
514
|
}
|
|
515
|
+
if (context?.extraTools?.length) {
|
|
516
|
+
tools = [...tools, ...context.extraTools];
|
|
517
|
+
logger.debug(`[getAvailableTools] After extraTools: ${tools.length} tools`, {
|
|
518
|
+
extraToolNames: context.extraTools.map((t) => t.name)
|
|
519
|
+
});
|
|
520
|
+
}
|
|
515
521
|
logger.debug(`[getAvailableTools] Final tools: ${tools.length}`, {
|
|
516
522
|
toolNames: tools.map((t) => t.name)
|
|
517
523
|
});
|
|
@@ -1102,7 +1108,16 @@ ${additionInfo}`
|
|
|
1102
1108
|
};
|
|
1103
1109
|
let result;
|
|
1104
1110
|
const isLongRunningTool = toolName === "delegate_task" || toolName === "stop_task" || toolName === "bash";
|
|
1105
|
-
|
|
1111
|
+
const isExtraTool = this.toolComponent?.getTool ? !this.toolComponent.getTool(toolName) : false;
|
|
1112
|
+
if (isExtraTool) {
|
|
1113
|
+
logger.debug(`[executeTool] Tool "${toolName}" is an extraTool, executing directly`);
|
|
1114
|
+
const toolPromise = tool.execute(toolCall.arguments, toolContext);
|
|
1115
|
+
if (isLongRunningTool) {
|
|
1116
|
+
result = await toolPromise;
|
|
1117
|
+
} else {
|
|
1118
|
+
result = await withTimeout(toolPromise, 120000, `Tool '${toolName}' execution timeout after 120s`);
|
|
1119
|
+
}
|
|
1120
|
+
} else if (this.toolComponent?.execute) {
|
|
1106
1121
|
const toolPromise = this.toolComponent.execute(request);
|
|
1107
1122
|
if (isLongRunningTool) {
|
|
1108
1123
|
result = await toolPromise;
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createSubmitJsonOutputTool,
|
|
4
4
|
init_submit_json_output_tool,
|
|
5
5
|
parseWorkflowJsonOutput
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-whw7jap0.js";
|
|
7
7
|
import {
|
|
8
8
|
AskUserError,
|
|
9
9
|
init_workflow_hil
|
|
@@ -45,6 +45,12 @@ function describeOutputSchema(schema) {
|
|
|
45
45
|
var init_output_schema_hint = () => {};
|
|
46
46
|
|
|
47
47
|
// src/env/workflow/plugins/workflow-json-output-plugin.ts
|
|
48
|
+
function getFallbackModel(hookCtx) {
|
|
49
|
+
const fromMetadata = hookCtx.context.metadata?.workflowJsonOutputFallbackModel;
|
|
50
|
+
if (typeof fromMetadata === "string" && fromMetadata.length > 0)
|
|
51
|
+
return fromMetadata;
|
|
52
|
+
return process.env.WORKFLOW_JSON_OUTPUT_FALLBACK_MODEL || DEFAULT_FALLBACK_MODEL;
|
|
53
|
+
}
|
|
48
54
|
function isWorkflowJsonOutputEnabled(pluginEnabled) {
|
|
49
55
|
return pluginEnabled?.[WORKFLOW_JSON_OUTPUT_PLUGIN_KEY] === true;
|
|
50
56
|
}
|
|
@@ -81,14 +87,70 @@ async function runWorkflowJsonOutputExtraction(hookCtx, llmComponent) {
|
|
|
81
87
|
if (hookCtx.structuredOutputExtracted) {
|
|
82
88
|
return;
|
|
83
89
|
}
|
|
84
|
-
const extracted =
|
|
85
|
-
model: hookCtx.context.model ?? hookCtx.agent.config.model,
|
|
86
|
-
sessionId: hookCtx.context.sessionId,
|
|
87
|
-
abortSignal: hookCtx.context.abort
|
|
88
|
-
});
|
|
90
|
+
const extracted = extractStructuredJsonFromMessages(hookCtx.messages, schema);
|
|
89
91
|
if (extracted) {
|
|
90
92
|
hookCtx.structuredOutputExtracted = extracted;
|
|
93
|
+
logger.info("Workflow JSON output extracted from ReAct messages (no second LLM invoke)");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
logger.warn(`Workflow JSON extraction: Phase 1 (ReAct messages) returned no workflow_submit_output. ` + `Attempting Phase 2 fallback with model=${getFallbackModel(hookCtx)}.`);
|
|
97
|
+
try {
|
|
98
|
+
const fallbackExtracted = await extractStructuredJsonViaLlm(llmComponent, hookCtx.messages, schema, {
|
|
99
|
+
model: getFallbackModel(hookCtx),
|
|
100
|
+
sessionId: hookCtx.context.sessionId,
|
|
101
|
+
abortSignal: hookCtx.context.abort
|
|
102
|
+
});
|
|
103
|
+
if (fallbackExtracted) {
|
|
104
|
+
hookCtx.structuredOutputExtracted = fallbackExtracted;
|
|
105
|
+
logger.info(`Workflow JSON output extracted via fallback LLM (${getFallbackModel(hookCtx)})`);
|
|
106
|
+
} else {
|
|
107
|
+
logger.warn(`Workflow JSON extraction: Phase 2 fallback (${getFallbackModel(hookCtx)}) also failed to extract structured output. ` + `Check if the fallback model is available and supports forced toolChoice.`);
|
|
108
|
+
}
|
|
109
|
+
} catch (error) {
|
|
110
|
+
logger.error(`Workflow JSON extraction: Phase 2 fallback (${getFallbackModel(hookCtx)}) threw error`, { error: String(error) });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function tryExtractToolCall(submitTool, tc) {
|
|
114
|
+
const name = tc.function?.name ?? tc.name;
|
|
115
|
+
if (name !== WORKFLOW_SUBMIT_OUTPUT_TOOL_NAME)
|
|
116
|
+
return;
|
|
117
|
+
const argsRaw = tc.function?.arguments ?? tc.arguments;
|
|
118
|
+
const argsStr = typeof argsRaw === "string" ? argsRaw : JSON.stringify(argsRaw ?? {});
|
|
119
|
+
try {
|
|
120
|
+
return submitTool.parameters.parse(JSON.parse(argsStr));
|
|
121
|
+
} catch {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function extractStructuredJsonFromMessages(messages, schema) {
|
|
126
|
+
const submitTool = createSubmitJsonOutputTool(schema);
|
|
127
|
+
for (let i = messages.length - 1;i >= 0; i--) {
|
|
128
|
+
const msg = messages[i];
|
|
129
|
+
if (msg.role !== "assistant")
|
|
130
|
+
continue;
|
|
131
|
+
const toolCalls = msg.tool_calls ?? msg.toolCalls ?? [];
|
|
132
|
+
if (toolCalls.length) {
|
|
133
|
+
for (let j = toolCalls.length - 1;j >= 0; j--) {
|
|
134
|
+
const result = tryExtractToolCall(submitTool, toolCalls[j]);
|
|
135
|
+
if (result)
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (Array.isArray(msg.content)) {
|
|
140
|
+
for (let k = msg.content.length - 1;k >= 0; k--) {
|
|
141
|
+
const part = msg.content[k];
|
|
142
|
+
if (part?.type !== "tool-call")
|
|
143
|
+
continue;
|
|
144
|
+
const result = tryExtractToolCall(submitTool, {
|
|
145
|
+
name: part.toolName,
|
|
146
|
+
arguments: part.args ?? part.arguments
|
|
147
|
+
});
|
|
148
|
+
if (result)
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
91
152
|
}
|
|
153
|
+
return;
|
|
92
154
|
}
|
|
93
155
|
async function extractStructuredJsonViaLlm(llmComponent, historyMessages, schema, options = {}) {
|
|
94
156
|
const submitTool = createSubmitJsonOutputTool(schema);
|
|
@@ -97,43 +159,48 @@ async function extractStructuredJsonViaLlm(llmComponent, historyMessages, schema
|
|
|
97
159
|
content: "Based on the conversation above, call workflow_submit_output exactly once with structured JSON. " + `${describeOutputSchema(schema)}.`
|
|
98
160
|
};
|
|
99
161
|
const messages = [...historyMessages, extractionUserMessage].map(toLLMMessage);
|
|
100
|
-
|
|
101
|
-
messages
|
|
102
|
-
|
|
103
|
-
{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
],
|
|
109
|
-
toolChoice: {
|
|
110
|
-
type: "function",
|
|
111
|
-
function: { name: WORKFLOW_SUBMIT_OUTPUT_TOOL_NAME }
|
|
112
|
-
},
|
|
113
|
-
model: options.model,
|
|
114
|
-
context: {
|
|
115
|
-
sessionId: options.sessionId
|
|
116
|
-
},
|
|
117
|
-
abortSignal: options.abortSignal,
|
|
118
|
-
skipThresholdCheck: true
|
|
119
|
-
});
|
|
120
|
-
const toolCalls = result.output?.toolCalls ?? [];
|
|
121
|
-
for (let i = toolCalls.length - 1;i >= 0; i--) {
|
|
122
|
-
const tc = toolCalls[i];
|
|
123
|
-
const name = tc.function?.name ?? tc.name;
|
|
124
|
-
if (name !== WORKFLOW_SUBMIT_OUTPUT_TOOL_NAME) {
|
|
125
|
-
continue;
|
|
162
|
+
for (let attempt = 0;attempt < 2; attempt++) {
|
|
163
|
+
const msgs = [...messages];
|
|
164
|
+
if (attempt === 1) {
|
|
165
|
+
msgs.push({
|
|
166
|
+
role: "user",
|
|
167
|
+
content: "You MUST call workflow_submit_output now with the structured JSON. Do NOT write text. Only call the tool."
|
|
168
|
+
});
|
|
126
169
|
}
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
170
|
+
const result = await llmComponent.invoke({
|
|
171
|
+
messages: msgs,
|
|
172
|
+
tools: [
|
|
173
|
+
{
|
|
174
|
+
name: submitTool.name,
|
|
175
|
+
description: submitTool.description ?? "",
|
|
176
|
+
parameters: submitTool.parameters
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
model: options.model,
|
|
180
|
+
context: {
|
|
181
|
+
sessionId: options.sessionId
|
|
182
|
+
},
|
|
183
|
+
abortSignal: options.abortSignal,
|
|
184
|
+
skipThresholdCheck: true
|
|
185
|
+
});
|
|
186
|
+
const toolCalls = result.output?.toolCalls ?? [];
|
|
187
|
+
for (let i = toolCalls.length - 1;i >= 0; i--) {
|
|
188
|
+
const tc = toolCalls[i];
|
|
189
|
+
const name = tc.function?.name ?? tc.name;
|
|
190
|
+
if (name !== WORKFLOW_SUBMIT_OUTPUT_TOOL_NAME) {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
const argsRaw = tc.function?.arguments ?? tc.arguments;
|
|
194
|
+
const argsStr = typeof argsRaw === "string" ? argsRaw : JSON.stringify(argsRaw ?? {});
|
|
195
|
+
try {
|
|
196
|
+
const parsed = submitTool.parameters.parse(JSON.parse(argsStr));
|
|
197
|
+
return parsed;
|
|
198
|
+
} catch {
|
|
199
|
+
const fromExecute = await submitTool.execute(JSON.parse(argsStr));
|
|
200
|
+
const fromMarker = parseWorkflowJsonOutput(fromExecute.output);
|
|
201
|
+
if (fromMarker) {
|
|
202
|
+
return fromMarker;
|
|
203
|
+
}
|
|
137
204
|
}
|
|
138
205
|
}
|
|
139
206
|
}
|
|
@@ -180,7 +247,7 @@ function toLLMMessage(msg) {
|
|
|
180
247
|
}
|
|
181
248
|
return { role: msg.role, content: "" };
|
|
182
249
|
}
|
|
183
|
-
var logger, WORKFLOW_JSON_OUTPUT_SOURCE_ID = "workflow", WORKFLOW_JSON_OUTPUT_PLUGIN_NAME = "json-output", WORKFLOW_JSON_OUTPUT_PLUGIN_KEY, HOOK_POINT = "agent:after.react", HOOK_NAME, registered = false, tracedRunWorkflowJsonOutputExtraction, tracedExtractStructuredJsonViaLlm;
|
|
250
|
+
var logger, WORKFLOW_JSON_OUTPUT_SOURCE_ID = "workflow", WORKFLOW_JSON_OUTPUT_PLUGIN_NAME = "json-output", WORKFLOW_JSON_OUTPUT_PLUGIN_KEY, DEFAULT_FALLBACK_MODEL = "minimax/MiniMax-M3", HOOK_POINT = "agent:after.react", HOOK_NAME, registered = false, tracedRunWorkflowJsonOutputExtraction, tracedExtractStructuredJsonViaLlm;
|
|
184
251
|
var init_workflow_json_output_plugin = __esm(() => {
|
|
185
252
|
init_global_hook_manager();
|
|
186
253
|
init_workflow_hil();
|
|
@@ -195,4 +262,4 @@ var init_workflow_json_output_plugin = __esm(() => {
|
|
|
195
262
|
tracedExtractStructuredJsonViaLlm = wrapFunction(extractStructuredJsonViaLlm, "workflow.json_output.extract_via_llm", { recordParams: false, recordResult: true, log: true });
|
|
196
263
|
});
|
|
197
264
|
|
|
198
|
-
export { WORKFLOW_JSON_OUTPUT_SOURCE_ID, WORKFLOW_JSON_OUTPUT_PLUGIN_NAME, WORKFLOW_JSON_OUTPUT_PLUGIN_KEY, isWorkflowJsonOutputEnabled, registerWorkflowJsonOutputPlugin, unregisterWorkflowJsonOutputPlugin, runWorkflowJsonOutputExtraction, extractStructuredJsonViaLlm, tracedRunWorkflowJsonOutputExtraction, tracedExtractStructuredJsonViaLlm, init_workflow_json_output_plugin };
|
|
265
|
+
export { WORKFLOW_JSON_OUTPUT_SOURCE_ID, WORKFLOW_JSON_OUTPUT_PLUGIN_NAME, WORKFLOW_JSON_OUTPUT_PLUGIN_KEY, isWorkflowJsonOutputEnabled, registerWorkflowJsonOutputPlugin, unregisterWorkflowJsonOutputPlugin, runWorkflowJsonOutputExtraction, extractStructuredJsonFromMessages, extractStructuredJsonViaLlm, tracedRunWorkflowJsonOutputExtraction, tracedExtractStructuredJsonViaLlm, init_workflow_json_output_plugin };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAutoTaskPlugin
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-n9tw52zb.js";
|
|
4
4
|
import {
|
|
5
5
|
ContextError,
|
|
6
6
|
ErrorCodes
|
|
@@ -195,9 +195,14 @@ class BaseEnvironment extends BaseComponent {
|
|
|
195
195
|
});
|
|
196
196
|
logger.info(`[handle_query] Created default receptionist agent with deniedTools: ${defaultDeniedTools.length} tools denied`);
|
|
197
197
|
try {
|
|
198
|
-
const
|
|
198
|
+
const llmRef = this.getComponent("llm");
|
|
199
|
+
const toolRef = this.getComponent("tool");
|
|
200
|
+
const autoTaskPlugin = createAutoTaskPlugin({
|
|
201
|
+
llmComponent: llmRef ?? undefined,
|
|
202
|
+
toolComponent: toolRef ?? undefined
|
|
203
|
+
});
|
|
199
204
|
agentComponent.registerPlugin("default", autoTaskPlugin);
|
|
200
|
-
logger.info("[handle_query] AutoTaskPlugin registered on default agent");
|
|
205
|
+
logger.info("[handle_query] AutoTaskPlugin v3 registered on default agent");
|
|
201
206
|
} catch (err) {
|
|
202
207
|
logger.warn(`[handle_query] Failed to register AutoTaskPlugin: ${err}`);
|
|
203
208
|
}
|
|
@@ -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-m4qjnhz6.js";
|
|
5
5
|
import {
|
|
6
6
|
buildWorkflowNodeMetadata,
|
|
7
7
|
getWorkflowNodeIdFromMetadata,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
jsonSchemaToZod,
|
|
35
35
|
parseWorkflowJsonOutput,
|
|
36
36
|
validateJsonOutputSchema
|
|
37
|
-
} from "./roy-agent-core-
|
|
37
|
+
} from "./roy-agent-core-whw7jap0.js";
|
|
38
38
|
import {
|
|
39
39
|
AskUserError,
|
|
40
40
|
createNodeInterruptEvent,
|
|
@@ -1452,7 +1452,8 @@ var init_agent_node = __esm(() => {
|
|
|
1452
1452
|
model: effectiveModel,
|
|
1453
1453
|
allowedTools: effectiveAllowedTools,
|
|
1454
1454
|
deniedTools: effectiveDeniedTools,
|
|
1455
|
-
outputSchema: outputConfig.schema
|
|
1455
|
+
outputSchema: outputConfig.schema,
|
|
1456
|
+
workflowJsonOutputFallbackModel: options.workflowJsonOutputFallbackModel
|
|
1456
1457
|
},
|
|
1457
1458
|
workflowHistory: context.workflowHistory,
|
|
1458
1459
|
nodeId: this.definition.id,
|
|
@@ -2423,9 +2424,19 @@ var init_engine = __esm(() => {
|
|
|
2423
2424
|
const durationMs = Date.now() - sessionState.startedAt.getTime();
|
|
2424
2425
|
const sessionId = sessionState.sessionId;
|
|
2425
2426
|
const runId = this.getRunIdFromSessionId(sessionId);
|
|
2426
|
-
const
|
|
2427
|
+
const dagAnalysis = sessionState.dagManager.analyze();
|
|
2428
|
+
const exitNodes = new Set(dagAnalysis.exitNodes);
|
|
2429
|
+
const exitOutput = {};
|
|
2427
2430
|
for (const [nodeId, nodeOutput] of sessionState.nodeOutputs) {
|
|
2428
|
-
|
|
2431
|
+
if (exitNodes.has(nodeId)) {
|
|
2432
|
+
exitOutput[nodeId] = nodeOutput;
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
const singleExit = exitNodes.size === 1 ? Array.from(exitNodes)[0] : undefined;
|
|
2436
|
+
const finalOutput = singleExit && exitOutput[singleExit] !== undefined ? exitOutput[singleExit] : exitOutput;
|
|
2437
|
+
const allNodeOutputs = {};
|
|
2438
|
+
for (const [nodeId, nodeOutput] of sessionState.nodeOutputs) {
|
|
2439
|
+
allNodeOutputs[nodeId] = nodeOutput;
|
|
2429
2440
|
}
|
|
2430
2441
|
if (this.sessionComponent) {
|
|
2431
2442
|
const metadata = await this.getSessionMetadata(sessionId);
|
|
@@ -2435,7 +2446,7 @@ var init_engine = __esm(() => {
|
|
|
2435
2446
|
status: "completed",
|
|
2436
2447
|
completedAt: Date.now(),
|
|
2437
2448
|
durationMs,
|
|
2438
|
-
output,
|
|
2449
|
+
output: allNodeOutputs,
|
|
2439
2450
|
pendingNodeId: undefined,
|
|
2440
2451
|
pauseReason: undefined,
|
|
2441
2452
|
agentSessions: markAllAgentSessionsCompleted(metadata.agentSessions)
|
|
@@ -2443,13 +2454,13 @@ var init_engine = __esm(() => {
|
|
|
2443
2454
|
});
|
|
2444
2455
|
}
|
|
2445
2456
|
await sessionState.eventBus.publish(createWorkflowEvent("workflow.completed", runId, {
|
|
2446
|
-
result:
|
|
2457
|
+
result: finalOutput,
|
|
2447
2458
|
duration_ms: durationMs
|
|
2448
2459
|
}), true);
|
|
2449
2460
|
sessionState.resolveCompleted({
|
|
2450
2461
|
runId,
|
|
2451
2462
|
status: "completed",
|
|
2452
|
-
output,
|
|
2463
|
+
output: finalOutput,
|
|
2453
2464
|
durationMs
|
|
2454
2465
|
});
|
|
2455
2466
|
this.cleanupSession(sessionState);
|
|
@@ -3,7 +3,11 @@ import {
|
|
|
3
3
|
init_workflow_json_output_plugin,
|
|
4
4
|
registerWorkflowJsonOutputPlugin,
|
|
5
5
|
tracedExtractStructuredJsonViaLlm
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-7z8fzxck.js";
|
|
7
|
+
import {
|
|
8
|
+
createSubmitJsonOutputTool,
|
|
9
|
+
init_submit_json_output_tool
|
|
10
|
+
} from "./roy-agent-core-whw7jap0.js";
|
|
7
11
|
import {
|
|
8
12
|
AskUserError,
|
|
9
13
|
init_workflow_hil
|
|
@@ -23,6 +27,7 @@ var init_agent_component_adapter = __esm(() => {
|
|
|
23
27
|
init_workflow_hil();
|
|
24
28
|
init_workflow_json_output_plugin();
|
|
25
29
|
init_decorator();
|
|
30
|
+
init_submit_json_output_tool();
|
|
26
31
|
AgentComponentAdapter = class AgentComponentAdapter {
|
|
27
32
|
agentComponent;
|
|
28
33
|
options;
|
|
@@ -134,13 +139,24 @@ var init_agent_component_adapter = __esm(() => {
|
|
|
134
139
|
runId,
|
|
135
140
|
nodeId,
|
|
136
141
|
sessionId: agentSessionId,
|
|
137
|
-
outputSchema
|
|
142
|
+
outputSchema,
|
|
143
|
+
workflowJsonOutputFallbackModel: config.options?.workflowJsonOutputFallbackModel
|
|
138
144
|
};
|
|
139
145
|
if (outputSchema) {
|
|
140
146
|
context.pluginEnabled = {
|
|
141
147
|
...context.pluginEnabled ?? {},
|
|
142
148
|
[WORKFLOW_JSON_OUTPUT_PLUGIN_KEY]: true
|
|
143
149
|
};
|
|
150
|
+
const submitTool = createSubmitJsonOutputTool(outputSchema);
|
|
151
|
+
context.extraTools = [
|
|
152
|
+
...context.extraTools ?? [],
|
|
153
|
+
{
|
|
154
|
+
name: submitTool.name,
|
|
155
|
+
description: submitTool.description ?? "",
|
|
156
|
+
parameters: submitTool.parameters,
|
|
157
|
+
execute: submitTool.execute
|
|
158
|
+
}
|
|
159
|
+
];
|
|
144
160
|
}
|
|
145
161
|
if (config.workflowHistory) {
|
|
146
162
|
context.workflowHistory = config.workflowHistory;
|
|
@@ -393,29 +393,163 @@ init_logger();
|
|
|
393
393
|
init_decorator();
|
|
394
394
|
var logger2 = createLogger("AutoTaskPlugin");
|
|
395
395
|
function createAutoTaskPlugin(config) {
|
|
396
|
-
const threshold = config?.threshold ??
|
|
396
|
+
const threshold = config?.threshold ?? 30;
|
|
397
397
|
const agentName = config?.agentName ?? "default";
|
|
398
|
-
const
|
|
398
|
+
const llmRef = config?.llmComponent ?? null;
|
|
399
|
+
const toolRef = config?.toolComponent ?? null;
|
|
400
|
+
const toolChoiceModel = config?.model;
|
|
401
|
+
const subagentType = config?.subagentType ?? "roy";
|
|
402
|
+
let lastProcessedTraceId = "";
|
|
403
|
+
let cachedDelegateToolInfo = undefined;
|
|
404
|
+
function getDelegateToolInfoImpl() {
|
|
405
|
+
if (cachedDelegateToolInfo !== undefined)
|
|
406
|
+
return cachedDelegateToolInfo;
|
|
407
|
+
if (!toolRef || typeof toolRef.getTool !== "function") {
|
|
408
|
+
cachedDelegateToolInfo = null;
|
|
409
|
+
return null;
|
|
410
|
+
}
|
|
411
|
+
const tool = toolRef.getTool("delegate_task");
|
|
412
|
+
if (!tool) {
|
|
413
|
+
cachedDelegateToolInfo = null;
|
|
414
|
+
return null;
|
|
415
|
+
}
|
|
416
|
+
cachedDelegateToolInfo = {
|
|
417
|
+
name: tool.name,
|
|
418
|
+
description: tool.description || "",
|
|
419
|
+
parameters: tool.parameters ?? {}
|
|
420
|
+
};
|
|
421
|
+
return cachedDelegateToolInfo;
|
|
422
|
+
}
|
|
423
|
+
const getDelegateToolInfo = wrapFunction(getDelegateToolInfoImpl, "plugin.auto-task.get-tool-info", { recordParams: false, recordResult: true, log: true });
|
|
424
|
+
async function tryInvokeForDelegateImpl(msgs, delegateToolInfo, model, sid) {
|
|
425
|
+
const result = await llmRef.invoke({
|
|
426
|
+
messages: msgs,
|
|
427
|
+
tools: [delegateToolInfo],
|
|
428
|
+
model,
|
|
429
|
+
context: { sessionId: sid },
|
|
430
|
+
skipThresholdCheck: true
|
|
431
|
+
});
|
|
432
|
+
const toolCalls = result?.output?.toolCalls;
|
|
433
|
+
if (!toolCalls || toolCalls.length === 0) {
|
|
434
|
+
logger2.warn(`[AutoTaskPlugin] LLM returned no toolCalls (session=${sid.slice(0, 12)}...)`);
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
for (const tc of toolCalls) {
|
|
438
|
+
const tcName = tc.function?.name ?? tc.name;
|
|
439
|
+
if (tcName !== "delegate_task")
|
|
440
|
+
continue;
|
|
441
|
+
const rawArgs = tc.function?.arguments ?? tc.arguments;
|
|
442
|
+
try {
|
|
443
|
+
const args = JSON.parse(typeof rawArgs === "string" ? rawArgs : JSON.stringify(rawArgs ?? {}));
|
|
444
|
+
if (args.description && args.prompt) {
|
|
445
|
+
return args;
|
|
446
|
+
}
|
|
447
|
+
logger2.warn(`[AutoTaskPlugin] delegate_task args missing required fields: ${JSON.stringify(args).slice(0, 100)}`);
|
|
448
|
+
} catch {
|
|
449
|
+
logger2.warn(`[AutoTaskPlugin] Failed to parse delegate_task args: ${String(rawArgs).slice(0, 100)}`);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return null;
|
|
453
|
+
}
|
|
454
|
+
const tryInvokeForDelegate = wrapFunction(tryInvokeForDelegateImpl, "plugin.auto-task.invoke-llm", { recordParams: true, recordResult: true, log: true });
|
|
399
455
|
async function executeImpl(ctx) {
|
|
400
456
|
try {
|
|
457
|
+
logger2.debug(`[AutoTaskPlugin] agentName=${ctx.agent.name} (expected=${agentName})`);
|
|
401
458
|
if (ctx.agent.name !== agentName)
|
|
402
459
|
return { continue: true };
|
|
460
|
+
logger2.debug(`[AutoTaskPlugin] iteration=${ctx.iteration} (threshold=${threshold})`);
|
|
403
461
|
if (ctx.iteration !== threshold)
|
|
404
462
|
return { continue: true };
|
|
463
|
+
const traceId = ctx.context?.traceId ?? ctx.context?.sessionId ?? "unknown";
|
|
405
464
|
const sid = ctx.context?.sessionId ?? "unknown";
|
|
406
|
-
if (
|
|
465
|
+
if (traceId === lastProcessedTraceId) {
|
|
466
|
+
logger2.debug(`[AutoTaskPlugin] skip - traceId=${traceId.slice(0, 20)}... already processed`);
|
|
407
467
|
return { continue: true };
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
468
|
+
}
|
|
469
|
+
lastProcessedTraceId = traceId;
|
|
470
|
+
logger2.debug(`[AutoTaskPlugin] new query detected (traceId=${traceId.slice(0, 20)}...)`);
|
|
471
|
+
if (!llmRef || !toolRef) {
|
|
472
|
+
logger2.warn(`[AutoTaskPlugin] llmComponent or toolComponent not provided at creation (session=${sid.slice(0, 12)}...)`);
|
|
473
|
+
return { continue: true };
|
|
474
|
+
}
|
|
475
|
+
const delegateToolInfo = getDelegateToolInfo();
|
|
476
|
+
if (!delegateToolInfo) {
|
|
477
|
+
logger2.warn(`[AutoTaskPlugin] delegate_task tool not found in toolComponent (session=${sid.slice(0, 12)}...)`);
|
|
478
|
+
return { continue: true };
|
|
479
|
+
}
|
|
480
|
+
const msgs = [];
|
|
481
|
+
for (const m of ctx.messages) {
|
|
482
|
+
if (m.role === "user") {
|
|
483
|
+
msgs.push({
|
|
484
|
+
role: "user",
|
|
485
|
+
content: typeof m.content === "string" ? m.content : JSON.stringify(m.content)
|
|
486
|
+
});
|
|
487
|
+
} else if (m.role === "assistant") {
|
|
488
|
+
const text = typeof m.content === "string" ? m.content : "";
|
|
489
|
+
if (text.trim()) {
|
|
490
|
+
msgs.push({ role: "assistant", content: text });
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
msgs.push({
|
|
495
|
+
role: "user",
|
|
496
|
+
content: `Based on the conversation above, please call \`delegate_task\` to hand off the current work to a sub-agent.
|
|
497
|
+
|
|
498
|
+
Parameters for delegate_task:
|
|
499
|
+
- description: A short 3-8 word title describing this work
|
|
500
|
+
- prompt: Detailed instructions for the sub-agent to continue the work
|
|
501
|
+
- subagent_type: Use "${subagentType}"
|
|
502
|
+
- similar_task_ids: []
|
|
503
|
+
|
|
504
|
+
Call delegate_task now.`
|
|
505
|
+
});
|
|
506
|
+
const model = toolChoiceModel ?? ctx.context?.model ?? ctx.agent?.config?.model;
|
|
507
|
+
logger2.info(`[AutoTaskPlugin] Invoking LLM (model=${model}) for delegate_task args at iteration ${ctx.iteration} (session=${sid.slice(0, 12)}...)`);
|
|
508
|
+
let args = await tryInvokeForDelegate(msgs, delegateToolInfo, model, sid);
|
|
509
|
+
if (!args) {
|
|
510
|
+
logger2.info(`[AutoTaskPlugin] Retrying with alternative prompt (session=${sid.slice(0, 12)}...)`);
|
|
511
|
+
msgs.push({
|
|
512
|
+
role: "user",
|
|
513
|
+
content: `Please call \`delegate_task\` now with description (short title), prompt (detailed instructions), subagent_type="${subagentType}", and similar_task_ids=[].`
|
|
514
|
+
});
|
|
515
|
+
args = await tryInvokeForDelegate(msgs, delegateToolInfo, model, sid);
|
|
516
|
+
}
|
|
517
|
+
if (!args) {
|
|
518
|
+
logger2.warn(`[AutoTaskPlugin] Failed to get delegate_task args after retry (session=${sid.slice(0, 12)}...)`);
|
|
519
|
+
return { continue: true };
|
|
520
|
+
}
|
|
521
|
+
logger2.info(`[AutoTaskPlugin] LLM generated delegate_task args: description="${String(args.description).slice(0, 50)}", subagent_type=${args.subagent_type}`);
|
|
522
|
+
const execResult = await toolRef.execute({
|
|
523
|
+
name: "delegate_task",
|
|
524
|
+
args: {
|
|
525
|
+
description: args.description,
|
|
526
|
+
prompt: args.prompt,
|
|
527
|
+
subagent_type: args.subagent_type || subagentType,
|
|
528
|
+
similar_task_ids: args.similar_task_ids || []
|
|
529
|
+
},
|
|
530
|
+
context: {
|
|
531
|
+
session_id: sid,
|
|
532
|
+
agent: ctx.agent.name
|
|
533
|
+
},
|
|
534
|
+
skipHooks: true
|
|
535
|
+
});
|
|
536
|
+
if (execResult.success && ctx.toolResult?.result?.output !== undefined) {
|
|
537
|
+
const bgProcessId = execResult.result?.bgProcessId ?? "unknown";
|
|
538
|
+
const injection = `
|
|
412
539
|
|
|
413
540
|
---
|
|
414
|
-
|
|
541
|
+
\uD83D\uDE80 **Task Delegated**: 已通过 delegate_task 委托给子 agent(${subagentType})在后台运行。
|
|
415
542
|
|
|
416
|
-
|
|
543
|
+
⏳ 请等待后台任务运行结果通知,无需额外操作。
|
|
544
|
+
|
|
545
|
+
\uD83D\uDCCB 后台进程 ID: \`${bgProcessId}\`
|
|
546
|
+
---`;
|
|
547
|
+
ctx.toolResult.result.output += injection;
|
|
548
|
+
logger2.info(`[AutoTaskPlugin] delegate_task called (bgProcessId=${bgProcessId}, session=${sid.slice(0, 12)}...)`);
|
|
549
|
+
} else {
|
|
550
|
+
const errMsg = execResult?.output || execResult?.error || "unknown error";
|
|
551
|
+
logger2.warn(`[AutoTaskPlugin] delegate_task execution failed: success=${execResult?.success}, error=${String(errMsg).slice(0, 200)}`);
|
|
417
552
|
}
|
|
418
|
-
logger2.info(`[AutoTaskPlugin] Prompted delegate_task at iteration ${ctx.iteration} (session=${sid.slice(0, 12)}...)`);
|
|
419
553
|
return { continue: true };
|
|
420
554
|
} catch (err) {
|
|
421
555
|
logger2.error(`[AutoTaskPlugin] hook failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -429,8 +563,8 @@ function createAutoTaskPlugin(config) {
|
|
|
429
563
|
});
|
|
430
564
|
return {
|
|
431
565
|
name: "AutoTaskPlugin",
|
|
432
|
-
version: "
|
|
433
|
-
description: "ReAct iteration
|
|
566
|
+
version: "3.0.0",
|
|
567
|
+
description: "ReAct iteration 达到阈值时通过 LLM 生成 delegate_task 入参并直接调用",
|
|
434
568
|
hooks: [
|
|
435
569
|
{ point: "agent:after.tool", priority: 50 }
|
|
436
570
|
],
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentComponentAdapter,
|
|
3
3
|
init_agent_component_adapter
|
|
4
|
-
} from "./roy-agent-core-
|
|
5
|
-
import"./roy-agent-core-
|
|
6
|
-
import"./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-m4qjnhz6.js";
|
|
5
|
+
import"./roy-agent-core-7z8fzxck.js";
|
|
6
|
+
import"./roy-agent-core-whw7jap0.js";
|
|
7
7
|
import"./roy-agent-core-e25xkv53.js";
|
|
8
8
|
import"./roy-agent-core-7tp56w6n.js";
|
|
9
9
|
import"./roy-agent-core-qg4rma4c.js";
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
WORKFLOW_JSON_OUTPUT_PLUGIN_KEY,
|
|
3
3
|
WORKFLOW_JSON_OUTPUT_PLUGIN_NAME,
|
|
4
4
|
WORKFLOW_JSON_OUTPUT_SOURCE_ID,
|
|
5
|
+
extractStructuredJsonFromMessages,
|
|
5
6
|
extractStructuredJsonViaLlm,
|
|
6
7
|
init_workflow_json_output_plugin,
|
|
7
8
|
isWorkflowJsonOutputEnabled,
|
|
@@ -10,8 +11,8 @@ import {
|
|
|
10
11
|
tracedExtractStructuredJsonViaLlm,
|
|
11
12
|
tracedRunWorkflowJsonOutputExtraction,
|
|
12
13
|
unregisterWorkflowJsonOutputPlugin
|
|
13
|
-
} from "./roy-agent-core-
|
|
14
|
-
import"./roy-agent-core-
|
|
14
|
+
} from "./roy-agent-core-7z8fzxck.js";
|
|
15
|
+
import"./roy-agent-core-whw7jap0.js";
|
|
15
16
|
import"./roy-agent-core-e25xkv53.js";
|
|
16
17
|
import"./roy-agent-core-7tp56w6n.js";
|
|
17
18
|
import"./roy-agent-core-qg4rma4c.js";
|
|
@@ -31,6 +32,7 @@ export {
|
|
|
31
32
|
registerWorkflowJsonOutputPlugin,
|
|
32
33
|
isWorkflowJsonOutputEnabled,
|
|
33
34
|
extractStructuredJsonViaLlm,
|
|
35
|
+
extractStructuredJsonFromMessages,
|
|
34
36
|
WORKFLOW_JSON_OUTPUT_SOURCE_ID,
|
|
35
37
|
WORKFLOW_JSON_OUTPUT_PLUGIN_NAME,
|
|
36
38
|
WORKFLOW_JSON_OUTPUT_PLUGIN_KEY
|
|
@@ -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-jazhr292.js";
|
|
10
10
|
import {
|
|
11
11
|
WorkflowService
|
|
12
12
|
} from "./roy-agent-core-4t40mkpv.js";
|
|
@@ -136,7 +136,7 @@ class WorkflowComponent extends BaseComponent {
|
|
|
136
136
|
const agentComponent = this._workflowEnv.getComponent("agent");
|
|
137
137
|
const llmComponent = this._workflowEnv.getComponent("llm");
|
|
138
138
|
if (agentComponent) {
|
|
139
|
-
const { AgentComponentAdapter } = await import("./roy-agent-core-
|
|
139
|
+
const { AgentComponentAdapter } = await import("./roy-agent-core-nc0n0bdc.js");
|
|
140
140
|
agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent, llmComponent);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -208,7 +208,7 @@ class WorkflowComponent extends BaseComponent {
|
|
|
208
208
|
const sessionComponent = this._workflowEnv?.getComponent("session");
|
|
209
209
|
componentLogger.info(`initSqliteService - toolComponent: ${!!toolComponent}, llmComponent: ${!!llmComponent}, skillRegistry: ${!!skillComponent}, sessionComponent: ${!!sessionComponent}`);
|
|
210
210
|
if (llmComponent) {
|
|
211
|
-
const { registerWorkflowJsonOutputPlugin } = await import("./roy-agent-core-
|
|
211
|
+
const { registerWorkflowJsonOutputPlugin } = await import("./roy-agent-core-qf9gvx02.js");
|
|
212
212
|
registerWorkflowJsonOutputPlugin(llmComponent);
|
|
213
213
|
}
|
|
214
214
|
this.createService({
|
|
@@ -77,13 +77,35 @@ function propertyToZod(prop) {
|
|
|
77
77
|
case "number":
|
|
78
78
|
case "integer":
|
|
79
79
|
return z.number();
|
|
80
|
+
case "array":
|
|
81
|
+
if (prop.items) {
|
|
82
|
+
return z.array(propertyToZod(prop.items));
|
|
83
|
+
}
|
|
84
|
+
return z.array(z.unknown());
|
|
85
|
+
case "object":
|
|
86
|
+
if (prop.properties) {
|
|
87
|
+
const required = new Set(prop.required ?? []);
|
|
88
|
+
const shape = {};
|
|
89
|
+
for (const [key, subProp] of Object.entries(prop.properties)) {
|
|
90
|
+
let field = propertyToZod(subProp);
|
|
91
|
+
if (subProp.description) {
|
|
92
|
+
field = field.describe(subProp.description);
|
|
93
|
+
}
|
|
94
|
+
if (!required.has(key)) {
|
|
95
|
+
field = field.optional();
|
|
96
|
+
}
|
|
97
|
+
shape[key] = field;
|
|
98
|
+
}
|
|
99
|
+
return z.object(shape);
|
|
100
|
+
}
|
|
101
|
+
return z.record(z.unknown());
|
|
80
102
|
default:
|
|
81
103
|
return z.unknown();
|
|
82
104
|
}
|
|
83
105
|
}
|
|
84
106
|
var SUPPORTED_PROPERTY_TYPES;
|
|
85
107
|
var init_json_schema_to_zod = __esm(() => {
|
|
86
|
-
SUPPORTED_PROPERTY_TYPES = new Set(["boolean", "string", "number", "integer"]);
|
|
108
|
+
SUPPORTED_PROPERTY_TYPES = new Set(["boolean", "string", "number", "integer", "array", "object"]);
|
|
87
109
|
});
|
|
88
110
|
|
|
89
111
|
// src/env/workflow/tools/submit-json-output-tool.ts
|