@ai-setting/roy-agent-core 1.5.5 → 1.5.7
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.d.ts +1250 -0
- package/dist/env/agent/index.d.ts +2279 -0
- package/dist/env/agent/index.js +1 -1
- package/dist/env/commands/index.d.ts +1131 -0
- package/dist/env/debug/formatters/index.d.ts +236 -0
- package/dist/env/debug/index.d.ts +1652 -0
- package/dist/env/hook/index.d.ts +279 -0
- package/dist/env/index.d.ts +3460 -0
- package/dist/env/index.js +8 -8
- package/dist/env/llm/index.d.ts +1760 -0
- package/dist/env/log-trace/index.d.ts +1574 -0
- package/dist/env/mcp/index.d.ts +1331 -0
- package/dist/env/mcp/index.js +2 -2
- package/dist/env/mcp/tool/index.d.ts +183 -0
- package/dist/env/mcp/tool/index.js +1 -1
- package/dist/env/memory/built-in/index.d.ts +232 -0
- package/dist/env/memory/index.d.ts +1799 -0
- package/dist/env/memory/plugin/index.d.ts +747 -0
- package/dist/env/prompt/index.d.ts +1164 -0
- package/dist/env/session/index.d.ts +1908 -0
- package/dist/env/session/storage/index.d.ts +564 -0
- package/dist/env/skill/index.d.ts +1266 -0
- package/dist/env/skill/tool/index.d.ts +193 -0
- package/dist/env/task/delegate/index.d.ts +1622 -0
- package/dist/env/task/hooks/index.d.ts +607 -0
- package/dist/env/task/index.d.ts +1415 -0
- package/dist/env/task/plugins/index.d.ts +462 -0
- package/dist/env/task/storage/index.d.ts +224 -0
- package/dist/env/task/tools/index.d.ts +1464 -0
- package/dist/env/task/tools/operation/index.d.ts +1463 -0
- package/dist/env/tool/built-in/index.d.ts +218 -0
- package/dist/env/tool/index.d.ts +1396 -0
- package/dist/env/workflow/decorators/index.d.ts +2161 -0
- package/dist/env/workflow/engine/index.d.ts +3453 -0
- package/dist/env/workflow/engine/index.js +4 -4
- package/dist/env/workflow/index.d.ts +3546 -0
- package/dist/env/workflow/index.js +9 -5
- package/dist/env/workflow/nodes/index.d.ts +2092 -0
- package/dist/env/workflow/nodes/index.js +1 -1
- package/dist/env/workflow/service/index.d.ts +227 -0
- package/dist/env/workflow/storage/index.d.ts +165 -0
- package/dist/env/workflow/tools/index.d.ts +416 -0
- package/dist/env/workflow/types/index.d.ts +2255 -0
- package/dist/env/workflow/types/index.js +5 -1
- package/dist/env/workflow/utils/index.d.ts +2031 -0
- package/dist/index.d.ts +7837 -0
- package/dist/index.js +8 -8
- package/dist/shared/@ai-setting/{roy-agent-core-nhdrvfp8.js → roy-agent-core-1akcqxj9.js} +49 -3
- package/dist/shared/@ai-setting/{roy-agent-core-rzp9kxne.js → roy-agent-core-5x94xmt6.js} +14 -5
- package/dist/shared/@ai-setting/{roy-agent-core-pc9g3962.js → roy-agent-core-69jskqjg.js} +41 -66
- package/dist/shared/@ai-setting/{roy-agent-core-f0cc2ep9.js → roy-agent-core-b0x5dda6.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-ya8krqzt.js → roy-agent-core-dc497hmk.js} +5 -4
- package/dist/shared/@ai-setting/{roy-agent-core-z2t8hse8.js → roy-agent-core-dh9d7a3m.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-qw0ebh1d.js → roy-agent-core-gq20wsgv.js} +49 -17
- package/dist/shared/@ai-setting/{roy-agent-core-3agad0d9.js → roy-agent-core-jvatggbb.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-c0jcxnf4.js → roy-agent-core-pjr12nnd.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-kkp3qmc3.js → roy-agent-core-wrcy0h6z.js} +132 -180
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
} from "./shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
75
75
|
import {
|
|
76
76
|
WorkflowComponent
|
|
77
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
77
|
+
} from "./shared/@ai-setting/roy-agent-core-dc497hmk.js";
|
|
78
78
|
import {
|
|
79
79
|
init_node_registry_helper,
|
|
80
80
|
registerDecoratorNodeType
|
|
@@ -89,14 +89,14 @@ import {
|
|
|
89
89
|
createWorkflowFromClass
|
|
90
90
|
} from "./shared/@ai-setting/roy-agent-core-7fgf85wc.js";
|
|
91
91
|
import"./shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
92
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
93
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
94
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
95
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
92
|
+
import"./shared/@ai-setting/roy-agent-core-wrcy0h6z.js";
|
|
93
|
+
import"./shared/@ai-setting/roy-agent-core-69jskqjg.js";
|
|
94
|
+
import"./shared/@ai-setting/roy-agent-core-jvatggbb.js";
|
|
95
|
+
import"./shared/@ai-setting/roy-agent-core-5x94xmt6.js";
|
|
96
96
|
import {
|
|
97
97
|
AgentComponent,
|
|
98
98
|
AgentComponentConfigSchema
|
|
99
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
99
|
+
} from "./shared/@ai-setting/roy-agent-core-b0x5dda6.js";
|
|
100
100
|
import {
|
|
101
101
|
AskUserError,
|
|
102
102
|
init_workflow_hil
|
|
@@ -117,7 +117,7 @@ import {
|
|
|
117
117
|
import"./shared/@ai-setting/roy-agent-core-psvxt4c9.js";
|
|
118
118
|
import {
|
|
119
119
|
McpComponent
|
|
120
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
120
|
+
} from "./shared/@ai-setting/roy-agent-core-pjr12nnd.js";
|
|
121
121
|
import {
|
|
122
122
|
AgentError,
|
|
123
123
|
ComponentError,
|
|
@@ -129,7 +129,7 @@ import {
|
|
|
129
129
|
getErrorCode,
|
|
130
130
|
isRoyError
|
|
131
131
|
} from "./shared/@ai-setting/roy-agent-core-ctdhjv68.js";
|
|
132
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
132
|
+
import"./shared/@ai-setting/roy-agent-core-1akcqxj9.js";
|
|
133
133
|
import {
|
|
134
134
|
SessionComponent
|
|
135
135
|
} from "./shared/@ai-setting/roy-agent-core-81w1963m.js";
|
|
@@ -7,6 +7,31 @@ import {
|
|
|
7
7
|
init_logger();
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
var logger = createLogger("mcp-adapter");
|
|
10
|
+
function validateRequiredParams(inputSchema, args) {
|
|
11
|
+
if (!inputSchema) {
|
|
12
|
+
return { valid: true, missing: [] };
|
|
13
|
+
}
|
|
14
|
+
const schema = inputSchema;
|
|
15
|
+
const required = schema.required ?? [];
|
|
16
|
+
if (required.length === 0) {
|
|
17
|
+
return { valid: true, missing: [] };
|
|
18
|
+
}
|
|
19
|
+
const missing = [];
|
|
20
|
+
for (const param of required) {
|
|
21
|
+
const value = args[param];
|
|
22
|
+
if (value === undefined || value === null) {
|
|
23
|
+
missing.push(param);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (missing.length > 0) {
|
|
27
|
+
return {
|
|
28
|
+
valid: false,
|
|
29
|
+
missing,
|
|
30
|
+
error: `Missing required parameter${missing.length > 1 ? "s" : ""}: ${missing.join(", ")}`
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return { valid: true, missing: [] };
|
|
34
|
+
}
|
|
10
35
|
function adaptMcpTool(mcpTool, mcpClient, serverName) {
|
|
11
36
|
const toolName = `mcp_${serverName}_${mcpTool.name}`;
|
|
12
37
|
const description = `MCP tool [${serverName}/${mcpTool.name}]: ${mcpTool.description ?? ""}`;
|
|
@@ -16,20 +41,41 @@ function adaptMcpTool(mcpTool, mcpClient, serverName) {
|
|
|
16
41
|
description,
|
|
17
42
|
parameters: paramsSchema,
|
|
18
43
|
execute: async (args, _ctx) => {
|
|
44
|
+
const toolArgs = args ?? {};
|
|
45
|
+
const validation = validateRequiredParams(mcpTool.inputSchema, toolArgs);
|
|
46
|
+
if (!validation.valid) {
|
|
47
|
+
logger.warn(`[McpAdapter] Tool call skipped: ${toolName}`, {
|
|
48
|
+
reason: "missing_required_params",
|
|
49
|
+
missing: validation.missing
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
success: false,
|
|
53
|
+
output: "",
|
|
54
|
+
error: validation.error
|
|
55
|
+
};
|
|
56
|
+
}
|
|
19
57
|
try {
|
|
20
58
|
const result = await mcpClient.callTool({
|
|
21
59
|
name: mcpTool.name,
|
|
22
|
-
arguments:
|
|
60
|
+
arguments: toolArgs
|
|
23
61
|
});
|
|
24
62
|
return convertMcpCallResult(result);
|
|
25
63
|
} catch (error) {
|
|
64
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
65
|
+
const errorCode = error?.code;
|
|
26
66
|
logger.error(`[McpAdapter] Tool call failed: ${toolName}`, {
|
|
27
|
-
error:
|
|
67
|
+
error: errorMessage,
|
|
68
|
+
errorCode,
|
|
69
|
+
receivedArgs: toolArgs
|
|
28
70
|
});
|
|
71
|
+
let userMessage = errorMessage;
|
|
72
|
+
if (errorCode === -32602) {
|
|
73
|
+
userMessage = `Invalid parameters for tool "${mcpTool.name}": ${errorMessage}`;
|
|
74
|
+
}
|
|
29
75
|
return {
|
|
30
76
|
success: false,
|
|
31
77
|
output: "",
|
|
32
|
-
error:
|
|
78
|
+
error: userMessage
|
|
33
79
|
};
|
|
34
80
|
}
|
|
35
81
|
},
|
|
@@ -57,7 +57,7 @@ function parseWorkflowFileSync(content, filename) {
|
|
|
57
57
|
definition
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
var DependsOnSchema, RetryConfigSchema, NodeDefinitionSchema, WorkflowConfigSchema, OutputDefinitionSchema, WorkflowMetadataSchema, WorkflowDefinitionSchema, yamlParser = null;
|
|
60
|
+
var DependsOnSchema, RetryConfigSchema, NodeDefinitionSchema, WorkflowConfigSchema, OutputDefinitionSchema, InputParameterSchema, WorkflowInputsSchema, WorkflowMetadataSchema, WorkflowDefinitionSchema, yamlParser = null;
|
|
61
61
|
var init_workflow = __esm(() => {
|
|
62
62
|
DependsOnSchema = z.array(z.string());
|
|
63
63
|
RetryConfigSchema = z.object({
|
|
@@ -86,6 +86,13 @@ var init_workflow = __esm(() => {
|
|
|
86
86
|
source: z.string(),
|
|
87
87
|
path: z.string()
|
|
88
88
|
});
|
|
89
|
+
InputParameterSchema = z.object({
|
|
90
|
+
type: z.enum(["string", "number", "boolean", "object", "array"]),
|
|
91
|
+
description: z.string().optional(),
|
|
92
|
+
default: z.unknown().optional(),
|
|
93
|
+
required: z.boolean().default(false)
|
|
94
|
+
});
|
|
95
|
+
WorkflowInputsSchema = z.record(z.string(), InputParameterSchema);
|
|
89
96
|
WorkflowMetadataSchema = z.object({
|
|
90
97
|
author: z.string().optional(),
|
|
91
98
|
taskId: z.number().optional(),
|
|
@@ -101,6 +108,7 @@ var init_workflow = __esm(() => {
|
|
|
101
108
|
nodes: z.array(NodeDefinitionSchema).min(1, "At least one node is required"),
|
|
102
109
|
entry: z.union([z.string(), z.array(z.string())]).default("__default_entry__"),
|
|
103
110
|
outputs: z.array(OutputDefinitionSchema).optional().default([]),
|
|
111
|
+
inputs: WorkflowInputsSchema.optional().default({}),
|
|
104
112
|
metadata: WorkflowMetadataSchema.optional().default({})
|
|
105
113
|
});
|
|
106
114
|
});
|
|
@@ -111,9 +119,9 @@ var WorkflowMessageRoleSchema;
|
|
|
111
119
|
var init_workflow_message = __esm(() => {
|
|
112
120
|
init_workflow_hil();
|
|
113
121
|
WorkflowMessageRoleSchema = z2.enum([
|
|
114
|
-
"workflow.node.
|
|
122
|
+
"workflow.node.start",
|
|
115
123
|
"workflow.node.interrupt",
|
|
116
|
-
"workflow.node.
|
|
124
|
+
"workflow.node.end",
|
|
117
125
|
"workflow.node.resume"
|
|
118
126
|
]);
|
|
119
127
|
});
|
|
@@ -203,8 +211,9 @@ var init_event = __esm(() => {
|
|
|
203
211
|
NodeStartedEventSchema = BaseEventSchema.extend({
|
|
204
212
|
type: z3.literal("node.started"),
|
|
205
213
|
node_id: z3.string(),
|
|
206
|
-
input: z3.any(),
|
|
214
|
+
input: z3.any().optional(),
|
|
207
215
|
agentSessionId: z3.string().optional(),
|
|
216
|
+
userQuery: z3.string().optional(),
|
|
208
217
|
userResponse: z3.string().optional()
|
|
209
218
|
});
|
|
210
219
|
NodeProgressEventSchema = BaseEventSchema.extend({
|
|
@@ -338,4 +347,4 @@ var init_types = __esm(() => {
|
|
|
338
347
|
init_run();
|
|
339
348
|
});
|
|
340
349
|
|
|
341
|
-
export { BaseEventSchema, WorkflowStartedEventSchema, WorkflowPausedEventSchema, WorkflowResumedEventSchema, WorkflowStoppedEventSchema, WorkflowCompletedEventSchema, WorkflowFailedEventSchema, WorkflowOutputEventSchema, NodeScheduledEventSchema, NodeStartedEventSchema, NodeProgressEventSchema, NodeCompletedEventSchema, NodeFailedEventSchema, NodeSkippedEventSchema, NodeDataEventSchema, NodeAddedEventSchema, NodeRemovedEventSchema, ControlPauseEventSchema, ControlResumeEventSchema, ControlStopEventSchema, NodeInterruptEventSchema, WorkflowAskUserEventSchema, WorkflowEventSchema, createWorkflowEvent, init_event, DependsOnSchema, RetryConfigSchema, NodeDefinitionSchema, WorkflowConfigSchema, OutputDefinitionSchema, WorkflowMetadataSchema, WorkflowDefinitionSchema, parseWorkflowFile, parseWorkflowFileSync, WorkflowMessageRoleSchema, isWorkflowSessionMetadata, getWorkflowSessionStatus, RunStatusSchema, NodeStatusSchema, createNodeExecutionContext, init_types };
|
|
350
|
+
export { BaseEventSchema, WorkflowStartedEventSchema, WorkflowPausedEventSchema, WorkflowResumedEventSchema, WorkflowStoppedEventSchema, WorkflowCompletedEventSchema, WorkflowFailedEventSchema, WorkflowOutputEventSchema, NodeScheduledEventSchema, NodeStartedEventSchema, NodeProgressEventSchema, NodeCompletedEventSchema, NodeFailedEventSchema, NodeSkippedEventSchema, NodeDataEventSchema, NodeAddedEventSchema, NodeRemovedEventSchema, ControlPauseEventSchema, ControlResumeEventSchema, ControlStopEventSchema, NodeInterruptEventSchema, WorkflowAskUserEventSchema, WorkflowEventSchema, createWorkflowEvent, init_event, DependsOnSchema, RetryConfigSchema, NodeDefinitionSchema, WorkflowConfigSchema, OutputDefinitionSchema, InputParameterSchema, WorkflowInputsSchema, WorkflowMetadataSchema, WorkflowDefinitionSchema, parseWorkflowFile, parseWorkflowFileSync, WorkflowMessageRoleSchema, isWorkflowSessionMetadata, getWorkflowSessionStatus, RunStatusSchema, NodeStatusSchema, createNodeExecutionContext, init_types };
|
|
@@ -46,55 +46,42 @@ class AgentComponentAdapter {
|
|
|
46
46
|
const nodeId = config.nodeId || "unknown";
|
|
47
47
|
const runId = config.runId || "unknown";
|
|
48
48
|
const workflowSessionId = config.workflowSessionId;
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
metadata: {
|
|
61
|
-
type: "user_intent",
|
|
62
|
-
intent: "workflow.resume",
|
|
63
|
-
workflowNodeId: nodeId
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
} catch (error) {
|
|
67
|
-
console.warn(`Failed to add user response to agent session ${agentSessionId}:`, error);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
if (this._sessionComponent) {
|
|
72
|
-
agentSessionId = `${this.agentSessionPrefix}_${runId}_${nodeId}_${Date.now()}`;
|
|
73
|
-
try {
|
|
74
|
-
await this._sessionComponent.create({
|
|
75
|
-
title: `Agent Session: ${config.type} (${agentSessionId})`,
|
|
76
|
-
metadata: {
|
|
77
|
-
type: "agent",
|
|
78
|
-
workflowRunId: runId,
|
|
79
|
-
workflowNodeId: nodeId
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
this._currentAgentSessionId = agentSessionId;
|
|
83
|
-
if (workflowSessionId) {
|
|
84
|
-
const mapping = this.runSessionToAgentSessions.get(workflowSessionId) || [];
|
|
85
|
-
mapping.push(agentSessionId);
|
|
86
|
-
this.runSessionToAgentSessions.set(workflowSessionId, mapping);
|
|
49
|
+
const isResume = !!resumeOptions?.userQuery;
|
|
50
|
+
let agentSessionId = resumeOptions?.agentSessionId || config.agentSessionId || this._currentAgentSessionId;
|
|
51
|
+
if (!agentSessionId && this._sessionComponent) {
|
|
52
|
+
agentSessionId = `${this.agentSessionPrefix}_${runId}_${nodeId}_${Date.now()}`;
|
|
53
|
+
try {
|
|
54
|
+
await this._sessionComponent.create({
|
|
55
|
+
title: `Agent Session: ${config.type} (${agentSessionId})`,
|
|
56
|
+
metadata: {
|
|
57
|
+
type: "agent",
|
|
58
|
+
workflowRunId: runId,
|
|
59
|
+
workflowNodeId: nodeId
|
|
87
60
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
61
|
+
});
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.warn(`Failed to create agent session ${agentSessionId}:`, error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (agentSessionId) {
|
|
67
|
+
this._currentAgentSessionId = agentSessionId;
|
|
68
|
+
if (workflowSessionId && this._sessionComponent) {
|
|
69
|
+
const mapping = this.runSessionToAgentSessions.get(workflowSessionId) || [];
|
|
70
|
+
if (!mapping.includes(agentSessionId)) {
|
|
71
|
+
mapping.push(agentSessionId);
|
|
72
|
+
this.runSessionToAgentSessions.set(workflowSessionId, mapping);
|
|
96
73
|
}
|
|
97
74
|
}
|
|
75
|
+
if (isResume) {
|
|
76
|
+
this.pendingSessions.delete(agentSessionId);
|
|
77
|
+
} else {
|
|
78
|
+
this.pendingSessions.set(agentSessionId, {
|
|
79
|
+
agentSessionId,
|
|
80
|
+
nodeId,
|
|
81
|
+
runId,
|
|
82
|
+
createdAt: Date.now()
|
|
83
|
+
});
|
|
84
|
+
}
|
|
98
85
|
}
|
|
99
86
|
try {
|
|
100
87
|
const context = {};
|
|
@@ -113,7 +100,9 @@ class AgentComponentAdapter {
|
|
|
113
100
|
if (config.workflowHistory) {
|
|
114
101
|
context.workflowHistory = config.workflowHistory;
|
|
115
102
|
}
|
|
116
|
-
|
|
103
|
+
context.additionInfo = config.prompt;
|
|
104
|
+
const userInput = resumeOptions?.userQuery || "";
|
|
105
|
+
const result = await this.agentComponent.run(config.type || "general", userInput, context);
|
|
117
106
|
if (result.error?.startsWith("__ASK_USER_ERROR__:")) {
|
|
118
107
|
const jsonStr = result.error.substring("__ASK_USER_ERROR__:".length);
|
|
119
108
|
const errorInfo = JSON.parse(jsonStr);
|
|
@@ -153,30 +142,16 @@ class AgentComponentAdapter {
|
|
|
153
142
|
}
|
|
154
143
|
};
|
|
155
144
|
} finally {
|
|
156
|
-
if (
|
|
145
|
+
if (isResume) {
|
|
157
146
|
this._currentAgentSessionId = undefined;
|
|
158
147
|
}
|
|
159
148
|
}
|
|
160
149
|
}
|
|
161
|
-
async resumeAgent(agentSessionId,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
await this._sessionComponent.addMessage(agentSessionId, {
|
|
165
|
-
role: "user",
|
|
166
|
-
content: userResponse,
|
|
167
|
-
metadata: {
|
|
168
|
-
type: "user_intent",
|
|
169
|
-
intent: "workflow.resume"
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
this.pendingSessions.delete(agentSessionId);
|
|
173
|
-
this._currentAgentSessionId = agentSessionId;
|
|
174
|
-
} catch (error) {
|
|
175
|
-
console.warn(`Failed to add user response to agent session ${agentSessionId}:`, error);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
150
|
+
async resumeAgent(agentSessionId, userQuery, config) {
|
|
151
|
+
this.pendingSessions.delete(agentSessionId);
|
|
152
|
+
this._currentAgentSessionId = agentSessionId;
|
|
178
153
|
config.agentSessionId = agentSessionId;
|
|
179
|
-
return this.run(config, {
|
|
154
|
+
return this.run(config, { userQuery, agentSessionId });
|
|
180
155
|
}
|
|
181
156
|
getPendingSession(agentSessionId) {
|
|
182
157
|
return this.pendingSessions.get(agentSessionId);
|
|
@@ -834,11 +834,11 @@ class AgentComponent extends BaseComponent {
|
|
|
834
834
|
content: ctx.systemPrompt
|
|
835
835
|
});
|
|
836
836
|
}
|
|
837
|
-
if (ctx.additionInfo) {
|
|
837
|
+
if (ctx.context?.additionInfo) {
|
|
838
838
|
messages.push({
|
|
839
839
|
role: "user",
|
|
840
840
|
content: `额外信息:
|
|
841
|
-
${ctx.additionInfo}`
|
|
841
|
+
${ctx.context.additionInfo}`
|
|
842
842
|
});
|
|
843
843
|
}
|
|
844
844
|
messages.push(...ctx.messages);
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
WorkflowEngine,
|
|
13
13
|
exports_engine,
|
|
14
14
|
init_engine
|
|
15
|
-
} from "./roy-agent-core-
|
|
15
|
+
} from "./roy-agent-core-wrcy0h6z.js";
|
|
16
16
|
import {
|
|
17
17
|
BaseComponent
|
|
18
18
|
} from "./roy-agent-core-kkbwepqb.js";
|
|
@@ -134,14 +134,15 @@ class WorkflowComponent extends BaseComponent {
|
|
|
134
134
|
if (!agentRunner && this._workflowEnv) {
|
|
135
135
|
const agentComponent = this._workflowEnv.getComponent("agent");
|
|
136
136
|
if (agentComponent) {
|
|
137
|
-
const { AgentComponentAdapter } = await import("./roy-agent-core-
|
|
138
|
-
agentRunner = new AgentComponentAdapter(agentComponent);
|
|
137
|
+
const { AgentComponentAdapter } = await import("./roy-agent-core-dh9d7a3m.js");
|
|
138
|
+
agentRunner = new AgentComponentAdapter(agentComponent, {}, this.sessionComponent);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
const registry = new NodeRegistry({
|
|
142
142
|
toolRegistry: toolComponent,
|
|
143
143
|
skillRegistry: skillComponent,
|
|
144
|
-
agentRunner
|
|
144
|
+
agentRunner,
|
|
145
|
+
sessionComponent: this.sessionComponent
|
|
145
146
|
});
|
|
146
147
|
registerDecoratorNodeType2(registry);
|
|
147
148
|
const engine = new WorkflowEngine(registry);
|
|
@@ -10,7 +10,7 @@ function inferNextNode(messages, definition) {
|
|
|
10
10
|
const lastMessage = messages[messages.length - 1];
|
|
11
11
|
const metadata = lastMessage.metadata;
|
|
12
12
|
switch (metadata?.type) {
|
|
13
|
-
case "workflow.node.
|
|
13
|
+
case "workflow.node.start":
|
|
14
14
|
return {
|
|
15
15
|
type: "resume_node",
|
|
16
16
|
nodeId: metadata.workflowNodeId,
|
|
@@ -22,16 +22,16 @@ function inferNextNode(messages, definition) {
|
|
|
22
22
|
nodeId: metadata.workflowNodeId,
|
|
23
23
|
agentSessionId: metadata.agentSessionId
|
|
24
24
|
};
|
|
25
|
-
case "workflow.node.
|
|
25
|
+
case "workflow.node.end":
|
|
26
26
|
return getNextNodes(metadata.workflowNodeId, definition);
|
|
27
27
|
default:
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
const
|
|
28
|
+
const lastStart = findLastStartMessage(messages);
|
|
29
|
+
if (lastStart) {
|
|
30
|
+
const startMetadata = lastStart.metadata;
|
|
31
31
|
return {
|
|
32
32
|
type: "resume_node",
|
|
33
|
-
nodeId:
|
|
34
|
-
agentSessionId:
|
|
33
|
+
nodeId: startMetadata.workflowNodeId,
|
|
34
|
+
agentSessionId: startMetadata.agentSessionId
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
return { type: "entry_node", nodeId: definition.entryNode };
|
|
@@ -53,10 +53,10 @@ function findLastInterruptMessage(messages) {
|
|
|
53
53
|
}
|
|
54
54
|
return null;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function findLastStartMessage(messages) {
|
|
57
57
|
for (let i = messages.length - 1;i >= 0; i--) {
|
|
58
58
|
const msg = messages[i];
|
|
59
|
-
if (msg.metadata?.type === "workflow.node.
|
|
59
|
+
if (msg.metadata?.type === "workflow.node.start") {
|
|
60
60
|
return msg;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -64,18 +64,18 @@ function findLastCallMessage(messages) {
|
|
|
64
64
|
}
|
|
65
65
|
function parseNodeOutputs(messages) {
|
|
66
66
|
const outputs = new Map;
|
|
67
|
-
let
|
|
67
|
+
let lastStartNodeId = null;
|
|
68
68
|
for (const msg of messages) {
|
|
69
69
|
const metadata = msg.metadata;
|
|
70
|
-
if (metadata?.type === "workflow.node.
|
|
71
|
-
|
|
72
|
-
} else if (metadata?.type === "workflow.node.
|
|
70
|
+
if (metadata?.type === "workflow.node.start") {
|
|
71
|
+
lastStartNodeId = metadata.workflowNodeId;
|
|
72
|
+
} else if (metadata?.type === "workflow.node.end" && lastStartNodeId) {
|
|
73
73
|
try {
|
|
74
|
-
outputs.set(
|
|
74
|
+
outputs.set(lastStartNodeId, JSON.parse(msg.content));
|
|
75
75
|
} catch {
|
|
76
|
-
outputs.set(
|
|
76
|
+
outputs.set(lastStartNodeId, msg.content);
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
lastStartNodeId = null;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
return outputs;
|
|
@@ -94,6 +94,37 @@ function getAgentSessionIdFromInterrupt(messages) {
|
|
|
94
94
|
const metadata = lastInterrupt.metadata;
|
|
95
95
|
return metadata?.agentSessionId || null;
|
|
96
96
|
}
|
|
97
|
+
function extractResumeInfo(messages) {
|
|
98
|
+
const nodeOutputs = parseNodeOutputs(messages);
|
|
99
|
+
let pendingNodeId;
|
|
100
|
+
let agentSessionId;
|
|
101
|
+
let hasInterrupt = false;
|
|
102
|
+
let lastInterruptQuery;
|
|
103
|
+
for (const msg of messages) {
|
|
104
|
+
const metadata = msg.metadata;
|
|
105
|
+
if (metadata?.type === "workflow.node.start") {
|
|
106
|
+
pendingNodeId = metadata.workflowNodeId;
|
|
107
|
+
if (metadata?.agentSessionId && !agentSessionId) {
|
|
108
|
+
agentSessionId = metadata.agentSessionId;
|
|
109
|
+
}
|
|
110
|
+
} else if (metadata?.type === "workflow.node.end") {
|
|
111
|
+
pendingNodeId = undefined;
|
|
112
|
+
agentSessionId = undefined;
|
|
113
|
+
} else if (metadata?.type === "workflow.node.interrupt") {
|
|
114
|
+
pendingNodeId = metadata.workflowNodeId;
|
|
115
|
+
agentSessionId = metadata.agentSessionId;
|
|
116
|
+
hasInterrupt = true;
|
|
117
|
+
lastInterruptQuery = msg.content;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
pendingNodeId,
|
|
122
|
+
agentSessionId,
|
|
123
|
+
hasInterrupt,
|
|
124
|
+
nodeOutputs,
|
|
125
|
+
lastInterruptQuery
|
|
126
|
+
};
|
|
127
|
+
}
|
|
97
128
|
var init_session_recovery = () => {};
|
|
98
129
|
init_session_recovery();
|
|
99
130
|
|
|
@@ -102,6 +133,7 @@ export {
|
|
|
102
133
|
inferNextNode,
|
|
103
134
|
hasPendingAskUser,
|
|
104
135
|
getAgentSessionIdFromInterrupt,
|
|
136
|
+
findLastStartMessage,
|
|
105
137
|
findLastInterruptMessage,
|
|
106
|
-
|
|
138
|
+
extractResumeInfo
|
|
107
139
|
};
|
|
@@ -49,7 +49,7 @@ class ToolNode {
|
|
|
49
49
|
input = { message: resolvedMessage };
|
|
50
50
|
console.log(`[ToolNode] message input: ${resolvedMessage}`);
|
|
51
51
|
} else {
|
|
52
|
-
input = this.definition.config?.input ?? this.definition.config?.args ?? {};
|
|
52
|
+
input = this.definition.config?.input ?? this.definition.config?.inputs ?? this.definition.config?.args ?? {};
|
|
53
53
|
input = this.resolveTemplateReferences(input, context.previousOutputs, context.input);
|
|
54
54
|
}
|
|
55
55
|
let output;
|