@ai-setting/roy-agent-core 1.5.43 → 1.5.45
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 +5 -5
- package/dist/env/agent/index.js +5 -5
- package/dist/env/commands/index.js +5 -5
- package/dist/env/context/index.js +4 -1
- package/dist/env/debug/index.js +5 -5
- package/dist/env/event-source/index.js +7 -7
- package/dist/env/hook/index.js +3 -3
- package/dist/env/index.js +24 -20
- package/dist/env/llm/index.js +5 -5
- package/dist/env/log-trace/index.js +5 -5
- package/dist/env/mcp/index.js +20 -6
- package/dist/env/memory/index.js +5 -5
- package/dist/env/plugin/index.js +5 -5
- package/dist/env/prompt/index.js +5 -5
- package/dist/env/session/index.js +6 -6
- package/dist/env/session/storage/index.js +1 -1
- package/dist/env/skill/index.js +5 -5
- package/dist/env/task/delegate/index.js +3 -3
- package/dist/env/task/index.js +6 -6
- package/dist/env/task/plugins/index.js +2 -2
- package/dist/env/tool/built-in/index.js +1 -1
- package/dist/env/tool/index.js +6 -6
- package/dist/env/workflow/decorators/index.js +1 -1
- package/dist/env/workflow/engine/index.js +10 -4
- package/dist/env/workflow/index.js +42 -24
- package/dist/env/workflow/nodes/index.js +5 -1
- package/dist/env/workflow/tools/index.js +14 -0
- package/dist/env/workflow/types/index.js +16 -2
- package/dist/env/workflow/utils/index.js +15 -196
- package/dist/index.js +35 -31
- package/dist/shared/@ai-setting/{roy-agent-core-kajktp3d.js → roy-agent-core-20fm423j.js} +47 -26
- package/dist/shared/@ai-setting/{roy-agent-core-ffb9fq4v.js → roy-agent-core-2vhsccvz.js} +54 -12
- package/dist/shared/@ai-setting/{roy-agent-core-69jskqjg.js → roy-agent-core-44g4dhzg.js} +75 -7
- package/dist/shared/@ai-setting/{roy-agent-core-e9fdm13a.js → roy-agent-core-4gmxjdhn.js} +4 -2
- package/dist/shared/@ai-setting/{roy-agent-core-b4wd9tn6.js → roy-agent-core-4k9a823d.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-68qy97r3.js +31 -0
- package/dist/shared/@ai-setting/roy-agent-core-6atd905e.js +42 -0
- package/dist/shared/@ai-setting/{roy-agent-core-4jqq077c.js → roy-agent-core-6e3wz81d.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-pwkk12p4.js → roy-agent-core-6mcb7nqa.js} +60 -0
- package/dist/shared/@ai-setting/roy-agent-core-6vxg2gmr.js +321 -0
- package/dist/shared/@ai-setting/{roy-agent-core-9p43ap7h.js → roy-agent-core-8y804aat.js} +4 -2
- package/dist/shared/@ai-setting/{roy-agent-core-0rtxwr28.js → roy-agent-core-9bmtxmp6.js} +77 -120
- package/dist/shared/@ai-setting/{roy-agent-core-r6rwsr54.js → roy-agent-core-9p604xjf.js} +29 -9
- package/dist/shared/@ai-setting/{roy-agent-core-z1xf2fdk.js → roy-agent-core-a67e90d1.js} +6 -4
- package/dist/shared/@ai-setting/{roy-agent-core-xkb264a8.js → roy-agent-core-bp3xggmb.js} +192 -26
- package/dist/shared/@ai-setting/{roy-agent-core-zrja5v78.js → roy-agent-core-ce9w0j8n.js} +10 -2
- package/dist/shared/@ai-setting/{roy-agent-core-bmr6bdfb.js → roy-agent-core-cr8xer31.js} +15 -8
- package/dist/shared/@ai-setting/roy-agent-core-dbxm76wf.js +190 -0
- package/dist/shared/@ai-setting/{roy-agent-core-nj8yerg9.js → roy-agent-core-eftqdsy5.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-7fgf85wc.js → roy-agent-core-h0x19xgn.js} +6 -7
- package/dist/shared/@ai-setting/{roy-agent-core-psvwzdhj.js → roy-agent-core-hdszq729.js} +9 -5
- package/dist/shared/@ai-setting/{roy-agent-core-dxbsc1zy.js → roy-agent-core-ja9qhg6d.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-cevpwnq7.js → roy-agent-core-mjbfgqen.js} +5 -3
- package/dist/shared/@ai-setting/roy-agent-core-nhfy3p8q.js +132 -0
- package/dist/shared/@ai-setting/{roy-agent-core-2jnzv9at.js → roy-agent-core-nn9dmffw.js} +629 -288
- package/dist/shared/@ai-setting/roy-agent-core-qnrf2aw6.js +441 -0
- package/dist/shared/@ai-setting/{roy-agent-core-ee6nnnqw.js → roy-agent-core-r9hq4cjx.js} +8 -1
- package/dist/shared/@ai-setting/{roy-agent-core-jqy2mdyq.js → roy-agent-core-rgj6hq15.js} +52 -41
- package/dist/shared/@ai-setting/{roy-agent-core-z33en0cz.js → roy-agent-core-rm3hay00.js} +15 -2
- package/dist/shared/@ai-setting/{roy-agent-core-e130w7mv.js → roy-agent-core-rx74rye7.js} +5 -3
- package/dist/shared/@ai-setting/{roy-agent-core-pxcrzyv9.js → roy-agent-core-sk535ft2.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-v002ynpa.js +435 -0
- package/dist/shared/@ai-setting/{roy-agent-core-2dhd60aw.js → roy-agent-core-vdwvamre.js} +10 -0
- package/dist/shared/@ai-setting/{roy-agent-core-1zq3p19q.js → roy-agent-core-w64zachx.js} +8 -4
- package/dist/shared/@ai-setting/roy-agent-core-ye0z728h.js +18 -0
- package/dist/shared/@ai-setting/{roy-agent-core-rsybkb38.js → roy-agent-core-ysvh8er9.js} +36 -39
- package/dist/shared/@ai-setting/{roy-agent-core-9yxb3ty9.js → roy-agent-core-z5sxe4p7.js} +5 -1
- package/dist/shared/@ai-setting/{roy-agent-core-eg6nv09z.js → roy-agent-core-ztx5eh72.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-nqgrjja0.js → roy-agent-core-zwq6vhpj.js} +1 -1
- package/package.json +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-5x94xmt6.js +0 -350
- package/dist/shared/@ai-setting/roy-agent-core-dh9d7a3m.js +0 -11
- package/dist/shared/@ai-setting/roy-agent-core-jvatggbb.js +0 -603
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__esm
|
|
3
|
+
} from "./roy-agent-core-fs0mn2jk.js";
|
|
4
|
+
|
|
5
|
+
// src/env/workflow/utils/workflow-message-metadata.ts
|
|
6
|
+
function getWorkflowNodeIdFromMetadata(metadata) {
|
|
7
|
+
if (!metadata) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const nodeId = metadata.nodeId;
|
|
11
|
+
const workflowNodeId = metadata.workflowNodeId;
|
|
12
|
+
return nodeId ?? workflowNodeId;
|
|
13
|
+
}
|
|
14
|
+
function buildWorkflowNodeMetadata(type, nodeId, nodeType, extra) {
|
|
15
|
+
return {
|
|
16
|
+
_workflowNodeMetadata: true,
|
|
17
|
+
type,
|
|
18
|
+
nodeId,
|
|
19
|
+
workflowNodeId: nodeId,
|
|
20
|
+
workflowNodeType: nodeType,
|
|
21
|
+
...extra
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function patchAgentSessionIdOnMessage(metadata, parts, agentSessionId) {
|
|
25
|
+
const nextMetadata = {
|
|
26
|
+
...metadata ?? {},
|
|
27
|
+
agentSessionId
|
|
28
|
+
};
|
|
29
|
+
if (!parts?.length) {
|
|
30
|
+
return { metadata: nextMetadata, parts };
|
|
31
|
+
}
|
|
32
|
+
const nextParts = parts.map((part) => {
|
|
33
|
+
if (part && typeof part === "object" && "nodeId" in part) {
|
|
34
|
+
return { ...part, agentSessionId };
|
|
35
|
+
}
|
|
36
|
+
return part;
|
|
37
|
+
});
|
|
38
|
+
return { metadata: nextMetadata, parts: nextParts };
|
|
39
|
+
}
|
|
40
|
+
var init_workflow_message_metadata = () => {};
|
|
41
|
+
|
|
42
|
+
export { getWorkflowNodeIdFromMetadata, buildWorkflowNodeMetadata, patchAgentSessionIdOnMessage, init_workflow_message_metadata };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createHook
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-vdwvamre.js";
|
|
4
4
|
import {
|
|
5
5
|
HookManager
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-rgj6hq15.js";
|
|
7
7
|
|
|
8
8
|
// src/env/component.ts
|
|
9
9
|
class BaseComponent {
|
|
@@ -138,6 +138,28 @@ class MemorySessionStore {
|
|
|
138
138
|
session.updatedAt = Date.now();
|
|
139
139
|
return msg.id;
|
|
140
140
|
}
|
|
141
|
+
async updateMessage(sessionId, messageId, updates) {
|
|
142
|
+
const sessionMessages = this.messages.get(sessionId);
|
|
143
|
+
if (!sessionMessages) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
const index = sessionMessages.findIndex((m) => m.id === messageId);
|
|
147
|
+
if (index < 0) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
const current = sessionMessages[index];
|
|
151
|
+
sessionMessages[index] = {
|
|
152
|
+
...current,
|
|
153
|
+
...updates.content !== undefined ? { content: updates.content } : {},
|
|
154
|
+
...updates.metadata !== undefined ? { metadata: updates.metadata } : {},
|
|
155
|
+
...updates.parts !== undefined ? { parts: updates.parts } : {}
|
|
156
|
+
};
|
|
157
|
+
const session = this.sessions.get(sessionId);
|
|
158
|
+
if (session) {
|
|
159
|
+
session.updatedAt = Date.now();
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
141
163
|
async getMessages(sessionId, offset = 0, limit = 50, options) {
|
|
142
164
|
let messages = this.messages.get(sessionId) ?? [];
|
|
143
165
|
if (!options?.includeArchived) {
|
|
@@ -589,6 +611,44 @@ class SQLiteSessionStore {
|
|
|
589
611
|
this.sessionsCache.set(sessionId, session);
|
|
590
612
|
return msg.id;
|
|
591
613
|
}
|
|
614
|
+
async updateMessage(sessionId, messageId, updates) {
|
|
615
|
+
await this.initialize();
|
|
616
|
+
const row = this.db.prepare("SELECT id FROM message WHERE id = ? AND session_id = ?").get(messageId, sessionId);
|
|
617
|
+
if (!row) {
|
|
618
|
+
return false;
|
|
619
|
+
}
|
|
620
|
+
const sets = [];
|
|
621
|
+
const values = [];
|
|
622
|
+
if (updates.content !== undefined) {
|
|
623
|
+
sets.push("content = ?");
|
|
624
|
+
values.push(updates.content);
|
|
625
|
+
}
|
|
626
|
+
if (updates.parts !== undefined) {
|
|
627
|
+
sets.push("parts = ?");
|
|
628
|
+
values.push(JSON.stringify(updates.parts));
|
|
629
|
+
}
|
|
630
|
+
if (updates.metadata !== undefined) {
|
|
631
|
+
sets.push("metadata = ?");
|
|
632
|
+
values.push(JSON.stringify(updates.metadata));
|
|
633
|
+
}
|
|
634
|
+
if (sets.length === 0) {
|
|
635
|
+
return true;
|
|
636
|
+
}
|
|
637
|
+
values.push(messageId, sessionId);
|
|
638
|
+
this.db.prepare(`UPDATE message SET ${sets.join(", ")} WHERE id = ? AND session_id = ?`).run(...values);
|
|
639
|
+
const messages = this.messagesCache.get(sessionId) ?? [];
|
|
640
|
+
const index = messages.findIndex((m) => m.id === messageId);
|
|
641
|
+
if (index >= 0) {
|
|
642
|
+
messages[index] = {
|
|
643
|
+
...messages[index],
|
|
644
|
+
...updates.content !== undefined ? { content: updates.content } : {},
|
|
645
|
+
...updates.metadata !== undefined ? { metadata: updates.metadata } : {},
|
|
646
|
+
...updates.parts !== undefined ? { parts: updates.parts } : {}
|
|
647
|
+
};
|
|
648
|
+
this.messagesCache.set(sessionId, messages);
|
|
649
|
+
}
|
|
650
|
+
return true;
|
|
651
|
+
}
|
|
592
652
|
async getMessages(sessionId, offset = 0, limit = 50, options) {
|
|
593
653
|
await this.initialize();
|
|
594
654
|
let sql = "SELECT * FROM message WHERE session_id = ?";
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TracedAs,
|
|
3
|
+
init_decorator
|
|
4
|
+
} from "./roy-agent-core-q5qj0fes.js";
|
|
5
|
+
import {
|
|
6
|
+
__esm,
|
|
7
|
+
__legacyDecorateClassTS
|
|
8
|
+
} from "./roy-agent-core-fs0mn2jk.js";
|
|
9
|
+
|
|
10
|
+
// src/env/workflow/nodes/tool-node.ts
|
|
11
|
+
var ToolNode;
|
|
12
|
+
var init_tool_node = __esm(() => {
|
|
13
|
+
init_decorator();
|
|
14
|
+
ToolNode = class ToolNode {
|
|
15
|
+
definition;
|
|
16
|
+
toolRegistry;
|
|
17
|
+
type = "tool";
|
|
18
|
+
id;
|
|
19
|
+
constructor(definition, toolRegistry) {
|
|
20
|
+
this.definition = definition;
|
|
21
|
+
this.toolRegistry = toolRegistry;
|
|
22
|
+
this.id = definition.id;
|
|
23
|
+
}
|
|
24
|
+
async execute(context) {
|
|
25
|
+
const startTime = Date.now();
|
|
26
|
+
try {
|
|
27
|
+
const toolName = this.definition.config?.tool ?? this.definition.config?.toolName;
|
|
28
|
+
if (!toolName) {
|
|
29
|
+
throw new Error("Tool name is required. Please specify config.tool or config.toolName in the node definition.");
|
|
30
|
+
}
|
|
31
|
+
let tool;
|
|
32
|
+
if (this.toolRegistry.getTool) {
|
|
33
|
+
const result = this.toolRegistry.getTool(toolName);
|
|
34
|
+
if (!result) {
|
|
35
|
+
throw new Error(`Tool not found: ${toolName}`);
|
|
36
|
+
}
|
|
37
|
+
if ("tool" in result) {
|
|
38
|
+
tool = result.tool;
|
|
39
|
+
} else {
|
|
40
|
+
tool = result;
|
|
41
|
+
}
|
|
42
|
+
} else if (this.toolRegistry.getToolByName) {
|
|
43
|
+
tool = this.toolRegistry.getToolByName(toolName);
|
|
44
|
+
}
|
|
45
|
+
if (!tool) {
|
|
46
|
+
throw new Error(`Tool not found: ${toolName}`);
|
|
47
|
+
}
|
|
48
|
+
const config = context.resolvedConfig ?? (this.definition.config || {});
|
|
49
|
+
const rawInput = config.input ?? config.inputs ?? config.args;
|
|
50
|
+
const rawCommand = config.command;
|
|
51
|
+
const rawMessage = config.message;
|
|
52
|
+
const hasResolvedConfig = context.resolvedConfig !== undefined;
|
|
53
|
+
let input;
|
|
54
|
+
if (rawCommand !== undefined) {
|
|
55
|
+
input = {
|
|
56
|
+
command: hasResolvedConfig ? rawCommand : context.templateResolver ? context.templateResolver.resolveValue(rawCommand) : rawCommand
|
|
57
|
+
};
|
|
58
|
+
} else if (rawMessage !== undefined) {
|
|
59
|
+
input = {
|
|
60
|
+
message: hasResolvedConfig ? rawMessage : context.templateResolver ? context.templateResolver.resolveValue(rawMessage) : rawMessage
|
|
61
|
+
};
|
|
62
|
+
} else if (rawInput !== undefined) {
|
|
63
|
+
input = hasResolvedConfig ? rawInput : context.templateResolver ? context.templateResolver.resolveValue(rawInput) : rawInput;
|
|
64
|
+
} else {
|
|
65
|
+
input = {};
|
|
66
|
+
}
|
|
67
|
+
let output;
|
|
68
|
+
try {
|
|
69
|
+
const toolContext = {
|
|
70
|
+
session_id: context.sessionId || `workflow_${context.runId}`,
|
|
71
|
+
message_id: context.nodeId,
|
|
72
|
+
metadata: {
|
|
73
|
+
workflowRunId: context.runId,
|
|
74
|
+
workflowName: context.workflowName,
|
|
75
|
+
nodeId: context.nodeId
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const executePromise = tool.execute(input, toolContext);
|
|
79
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
80
|
+
setTimeout(() => reject(new Error(`Tool '${toolName}' execution timeout after 60 seconds`)), 60000);
|
|
81
|
+
});
|
|
82
|
+
output = await Promise.race([executePromise, timeoutPromise]);
|
|
83
|
+
} catch (toolError) {
|
|
84
|
+
if (toolError instanceof TypeError && toolError.message.includes("context") && toolError.message.includes("not a function")) {
|
|
85
|
+
output = await tool.execute(input);
|
|
86
|
+
} else {
|
|
87
|
+
throw toolError;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const extractedOutput = this.extractFromWrapper(output);
|
|
91
|
+
return {
|
|
92
|
+
output: extractedOutput,
|
|
93
|
+
error: undefined,
|
|
94
|
+
durationMs: Date.now() - startTime
|
|
95
|
+
};
|
|
96
|
+
} catch (error) {
|
|
97
|
+
return {
|
|
98
|
+
output: undefined,
|
|
99
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
100
|
+
durationMs: Date.now() - startTime
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
extractFromWrapper(value) {
|
|
105
|
+
if (value === null || value === undefined) {
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
if (typeof value !== "object") {
|
|
109
|
+
return value;
|
|
110
|
+
}
|
|
111
|
+
let result;
|
|
112
|
+
if ("output" in value) {
|
|
113
|
+
result = value.output;
|
|
114
|
+
} else if ("result" in value && !("output" in value)) {
|
|
115
|
+
result = value.result;
|
|
116
|
+
} else {
|
|
117
|
+
return value;
|
|
118
|
+
}
|
|
119
|
+
if (typeof result === "string") {
|
|
120
|
+
return result.trimEnd();
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
__legacyDecorateClassTS([
|
|
126
|
+
TracedAs("workflow.tool.execute", { log: true })
|
|
127
|
+
], ToolNode.prototype, "execute", null);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// src/env/workflow/nodes/skill-node.ts
|
|
131
|
+
var SkillNode;
|
|
132
|
+
var init_skill_node = __esm(() => {
|
|
133
|
+
init_decorator();
|
|
134
|
+
SkillNode = class SkillNode {
|
|
135
|
+
definition;
|
|
136
|
+
skillRegistry;
|
|
137
|
+
type = "skill";
|
|
138
|
+
id;
|
|
139
|
+
constructor(definition, skillRegistry) {
|
|
140
|
+
this.definition = definition;
|
|
141
|
+
this.skillRegistry = skillRegistry;
|
|
142
|
+
this.id = definition.id;
|
|
143
|
+
}
|
|
144
|
+
async execute(context) {
|
|
145
|
+
const startTime = Date.now();
|
|
146
|
+
try {
|
|
147
|
+
const skillName = this.definition.config?.skill;
|
|
148
|
+
if (!skillName) {
|
|
149
|
+
throw new Error("Skill name is required. Please specify config.skill in the node definition.");
|
|
150
|
+
}
|
|
151
|
+
const skill = this.skillRegistry.getSkill(skillName);
|
|
152
|
+
if (!skill) {
|
|
153
|
+
throw new Error(`Skill not found: ${skillName}`);
|
|
154
|
+
}
|
|
155
|
+
const config = context.resolvedConfig ?? this.definition.config ?? {};
|
|
156
|
+
const input = config.input ?? {};
|
|
157
|
+
const resolvedInput = context.templateResolver ? context.templateResolver.resolveValue(input) : input;
|
|
158
|
+
const skillContext = {
|
|
159
|
+
runId: context.runId,
|
|
160
|
+
workflowName: context.workflowName,
|
|
161
|
+
nodeId: context.nodeId,
|
|
162
|
+
debug: context.debug,
|
|
163
|
+
sessionId: context.sessionId
|
|
164
|
+
};
|
|
165
|
+
const output = await skill.invoke(resolvedInput, skillContext);
|
|
166
|
+
return {
|
|
167
|
+
output,
|
|
168
|
+
error: undefined,
|
|
169
|
+
durationMs: Date.now() - startTime
|
|
170
|
+
};
|
|
171
|
+
} catch (error) {
|
|
172
|
+
return {
|
|
173
|
+
output: undefined,
|
|
174
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
175
|
+
durationMs: Date.now() - startTime
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
__legacyDecorateClassTS([
|
|
181
|
+
TracedAs("workflow.skill.execute", { log: true })
|
|
182
|
+
], SkillNode.prototype, "execute", null);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// src/env/workflow/nodes/workflow-node.ts
|
|
186
|
+
class WorkflowNode {
|
|
187
|
+
definition;
|
|
188
|
+
workflowRunner;
|
|
189
|
+
type = "workflow";
|
|
190
|
+
id;
|
|
191
|
+
constructor(definition, workflowRunner) {
|
|
192
|
+
this.definition = definition;
|
|
193
|
+
this.workflowRunner = workflowRunner;
|
|
194
|
+
this.id = definition.id;
|
|
195
|
+
}
|
|
196
|
+
async execute(context) {
|
|
197
|
+
const startTime = Date.now();
|
|
198
|
+
try {
|
|
199
|
+
const config = context.resolvedConfig ?? this.definition.config ?? {};
|
|
200
|
+
const workflowName = config.workflow_name;
|
|
201
|
+
if (!workflowName) {
|
|
202
|
+
throw new Error("workflow_name is required in config. Please specify config.workflow_name in the node definition.");
|
|
203
|
+
}
|
|
204
|
+
const previousOutputs = context.previousOutputs ?? this.convertToMap(context.nodeOutputs ?? {});
|
|
205
|
+
const resolvedInput = this.resolveInput(config.input ?? {}, previousOutputs);
|
|
206
|
+
const result = await this.workflowRunner.run(workflowName, resolvedInput);
|
|
207
|
+
const success = result.status === "completed";
|
|
208
|
+
return {
|
|
209
|
+
success,
|
|
210
|
+
output: result.output,
|
|
211
|
+
error: success ? undefined : result.error,
|
|
212
|
+
duration: Date.now() - startTime
|
|
213
|
+
};
|
|
214
|
+
} catch (error) {
|
|
215
|
+
return {
|
|
216
|
+
success: false,
|
|
217
|
+
output: undefined,
|
|
218
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
219
|
+
duration: Date.now() - startTime
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
convertToMap(nodeOutputs) {
|
|
224
|
+
const map = new Map;
|
|
225
|
+
for (const [nodeId, result] of Object.entries(nodeOutputs)) {
|
|
226
|
+
map.set(nodeId, result.output);
|
|
227
|
+
}
|
|
228
|
+
return map;
|
|
229
|
+
}
|
|
230
|
+
resolveInput(input, previousOutputs) {
|
|
231
|
+
const resolved = {};
|
|
232
|
+
for (const [key, value] of Object.entries(input)) {
|
|
233
|
+
resolved[key] = this.resolveValue(value, previousOutputs);
|
|
234
|
+
}
|
|
235
|
+
return resolved;
|
|
236
|
+
}
|
|
237
|
+
resolveValue(value, previousOutputs) {
|
|
238
|
+
if (typeof value === "string") {
|
|
239
|
+
return this.resolveStringTemplate(value, previousOutputs);
|
|
240
|
+
}
|
|
241
|
+
if (Array.isArray(value)) {
|
|
242
|
+
return value.map((item) => this.resolveValue(item, previousOutputs));
|
|
243
|
+
}
|
|
244
|
+
if (value !== null && typeof value === "object") {
|
|
245
|
+
const resolved = {};
|
|
246
|
+
for (const [k, v] of Object.entries(value)) {
|
|
247
|
+
resolved[k] = this.resolveValue(v, previousOutputs);
|
|
248
|
+
}
|
|
249
|
+
return resolved;
|
|
250
|
+
}
|
|
251
|
+
return value;
|
|
252
|
+
}
|
|
253
|
+
resolveStringTemplate(template, previousOutputs) {
|
|
254
|
+
const templatePattern = /\{\{([^}]+)\}\}/g;
|
|
255
|
+
return template.replace(templatePattern, (match, path) => {
|
|
256
|
+
const trimmedPath = path.trim();
|
|
257
|
+
const value = this.resolvePath(trimmedPath, previousOutputs);
|
|
258
|
+
if (value !== undefined) {
|
|
259
|
+
return this.stringifyValue(value, match);
|
|
260
|
+
}
|
|
261
|
+
return match;
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
resolvePath(path, previousOutputs) {
|
|
265
|
+
const segments = path.split(".");
|
|
266
|
+
if (segments.length === 0) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const nodeId = segments[0];
|
|
270
|
+
let nodeOutput = previousOutputs.get(nodeId);
|
|
271
|
+
if (nodeOutput === undefined) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
nodeOutput = this.extractFromWrapper(nodeOutput);
|
|
275
|
+
if (segments.length === 1) {
|
|
276
|
+
return nodeOutput;
|
|
277
|
+
}
|
|
278
|
+
let current = nodeOutput;
|
|
279
|
+
let startIndex = 1;
|
|
280
|
+
if (segments.length > 1 && (segments[1] === "output" || segments[1] === "result" || segments[1] === "metadata")) {
|
|
281
|
+
startIndex = 2;
|
|
282
|
+
}
|
|
283
|
+
for (let i = startIndex;i < segments.length; i++) {
|
|
284
|
+
if (current === null || current === undefined) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
current = current[segments[i]];
|
|
288
|
+
}
|
|
289
|
+
return current;
|
|
290
|
+
}
|
|
291
|
+
extractFromWrapper(value) {
|
|
292
|
+
if (value === null || value === undefined) {
|
|
293
|
+
return value;
|
|
294
|
+
}
|
|
295
|
+
if (typeof value !== "object") {
|
|
296
|
+
return value;
|
|
297
|
+
}
|
|
298
|
+
if ("result" in value && "metadata" in value) {
|
|
299
|
+
return value.result;
|
|
300
|
+
}
|
|
301
|
+
if ("output" in value) {
|
|
302
|
+
return value.output;
|
|
303
|
+
}
|
|
304
|
+
return value;
|
|
305
|
+
}
|
|
306
|
+
stringifyValue(value, originalTemplate) {
|
|
307
|
+
if (value === undefined) {
|
|
308
|
+
return originalTemplate;
|
|
309
|
+
}
|
|
310
|
+
if (value === null) {
|
|
311
|
+
return "null";
|
|
312
|
+
}
|
|
313
|
+
if (typeof value === "string") {
|
|
314
|
+
return value;
|
|
315
|
+
}
|
|
316
|
+
return JSON.stringify(value);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
var init_workflow_node = () => {};
|
|
320
|
+
|
|
321
|
+
export { ToolNode, init_tool_node, SkillNode, init_skill_node, WorkflowNode, init_workflow_node };
|
|
@@ -5,8 +5,9 @@ import {
|
|
|
5
5
|
TaskHookPoints
|
|
6
6
|
} from "./roy-agent-core-92z6t4he.js";
|
|
7
7
|
import {
|
|
8
|
-
globalHookManager
|
|
9
|
-
|
|
8
|
+
globalHookManager,
|
|
9
|
+
init_global_hook_manager
|
|
10
|
+
} from "./roy-agent-core-rgj6hq15.js";
|
|
10
11
|
import {
|
|
11
12
|
createLogger,
|
|
12
13
|
init_logger
|
|
@@ -73,6 +74,7 @@ function listKnownSubagentDescriptions(registry) {
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
// src/env/task/delegate/delegate-tool.ts
|
|
77
|
+
init_global_hook_manager();
|
|
76
78
|
var logger = createLogger("task:delegate");
|
|
77
79
|
var BackgroundTaskEventTypes = {
|
|
78
80
|
STARTED: "task.background.started",
|
|
@@ -2,143 +2,100 @@ import {
|
|
|
2
2
|
DecoratorNode,
|
|
3
3
|
init_decorator_node
|
|
4
4
|
} from "./roy-agent-core-1ce3fqrk.js";
|
|
5
|
+
import {
|
|
6
|
+
TracedAs,
|
|
7
|
+
init_decorator
|
|
8
|
+
} from "./roy-agent-core-q5qj0fes.js";
|
|
9
|
+
import {
|
|
10
|
+
createLogger,
|
|
11
|
+
init_logger
|
|
12
|
+
} from "./roy-agent-core-10n2jh7p.js";
|
|
5
13
|
import {
|
|
6
14
|
__esm,
|
|
7
|
-
__export
|
|
15
|
+
__export,
|
|
16
|
+
__legacyDecorateClassTS
|
|
8
17
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
9
18
|
|
|
10
19
|
// src/env/workflow/nodes/condition-node.ts
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
var logger, ConditionNode;
|
|
21
|
+
var init_condition_node = __esm(() => {
|
|
22
|
+
init_decorator();
|
|
23
|
+
init_logger();
|
|
24
|
+
logger = createLogger("workflow.condition");
|
|
25
|
+
ConditionNode = class ConditionNode {
|
|
26
|
+
definition;
|
|
27
|
+
type = "condition";
|
|
28
|
+
id;
|
|
29
|
+
constructor(definition) {
|
|
30
|
+
this.definition = definition;
|
|
31
|
+
this.id = definition.id;
|
|
32
|
+
}
|
|
33
|
+
async execute(context) {
|
|
34
|
+
const startTime = Date.now();
|
|
35
|
+
try {
|
|
36
|
+
const rawCondition = this.definition.config?.condition;
|
|
37
|
+
if (rawCondition === undefined) {
|
|
38
|
+
return {
|
|
39
|
+
output: { success: true, condition: true },
|
|
40
|
+
error: undefined,
|
|
41
|
+
durationMs: Date.now() - startTime
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
let conditionConfig;
|
|
45
|
+
if (context.resolvedConfig !== undefined) {
|
|
46
|
+
conditionConfig = context.resolvedConfig.condition;
|
|
47
|
+
} else {
|
|
48
|
+
const containsTemplate = typeof rawCondition === "string" && /\{\{.*\}\}/.test(rawCondition);
|
|
49
|
+
if (containsTemplate && !context.templateResolver) {
|
|
50
|
+
logger.warn(`[ConditionNode:${this.id}] Condition contains template references "{{...}}" but ` + `templateResolver is not available. The condition will be evaluated as-is. ` + `To resolve templates, ensure the workflow engine provides a templateResolver.`);
|
|
51
|
+
conditionConfig = rawCondition;
|
|
52
|
+
} else if (context.templateResolver) {
|
|
53
|
+
conditionConfig = context.templateResolver.resolveValue(rawCondition);
|
|
54
|
+
} else {
|
|
55
|
+
conditionConfig = rawCondition;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const result = this.evaluateCondition(conditionConfig);
|
|
24
59
|
return {
|
|
25
|
-
output: { success:
|
|
60
|
+
output: { success: result, condition: conditionConfig },
|
|
26
61
|
error: undefined,
|
|
27
62
|
durationMs: Date.now() - startTime
|
|
28
63
|
};
|
|
64
|
+
} catch (error) {
|
|
65
|
+
return {
|
|
66
|
+
output: undefined,
|
|
67
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
68
|
+
durationMs: Date.now() - startTime
|
|
69
|
+
};
|
|
29
70
|
}
|
|
30
|
-
const resolvedCondition = this.resolveCondition(conditionConfig, context);
|
|
31
|
-
const result = this.evaluateCondition(resolvedCondition);
|
|
32
|
-
return {
|
|
33
|
-
output: { success: result, condition: resolvedCondition },
|
|
34
|
-
error: undefined,
|
|
35
|
-
durationMs: Date.now() - startTime
|
|
36
|
-
};
|
|
37
|
-
} catch (error) {
|
|
38
|
-
return {
|
|
39
|
-
output: undefined,
|
|
40
|
-
error: error instanceof Error ? error : new Error(String(error)),
|
|
41
|
-
durationMs: Date.now() - startTime
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
resolveCondition(condition, context) {
|
|
46
|
-
if (typeof condition === "string") {
|
|
47
|
-
const templateMatch = condition.match(/^\{\{([^}]+)\}\}$/);
|
|
48
|
-
if (templateMatch) {
|
|
49
|
-
const path = templateMatch[1].trim();
|
|
50
|
-
return this.resolveTemplate(path, context);
|
|
51
|
-
}
|
|
52
|
-
if (condition === "true")
|
|
53
|
-
return true;
|
|
54
|
-
if (condition === "false")
|
|
55
|
-
return false;
|
|
56
|
-
return condition;
|
|
57
71
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const trimmed = path.trim();
|
|
62
|
-
if (trimmed.startsWith("input.")) {
|
|
63
|
-
const key = trimmed.slice(6);
|
|
64
|
-
return context.input?.[key];
|
|
65
|
-
}
|
|
66
|
-
if (trimmed.startsWith("nodes.")) {
|
|
67
|
-
const rest = trimmed.slice(6);
|
|
68
|
-
const segments2 = rest.split(".");
|
|
69
|
-
const nodeId2 = segments2[0];
|
|
70
|
-
let nodeOutput2 = context.previousOutputs.get(nodeId2);
|
|
71
|
-
if (nodeOutput2 === undefined) {
|
|
72
|
-
const normalizedUnderscore = nodeId2.replace(/-/g, "_");
|
|
73
|
-
const normalizedHyphen = nodeId2.replace(/_/g, "-");
|
|
74
|
-
if (normalizedUnderscore !== nodeId2) {
|
|
75
|
-
nodeOutput2 = context.previousOutputs.get(normalizedUnderscore);
|
|
76
|
-
}
|
|
77
|
-
if (nodeOutput2 === undefined && normalizedHyphen !== nodeId2) {
|
|
78
|
-
nodeOutput2 = context.previousOutputs.get(normalizedHyphen);
|
|
79
|
-
}
|
|
72
|
+
evaluateCondition(value) {
|
|
73
|
+
if (typeof value === "boolean") {
|
|
74
|
+
return value;
|
|
80
75
|
}
|
|
81
|
-
if (
|
|
82
|
-
return;
|
|
83
|
-
let value2 = nodeOutput2;
|
|
84
|
-
for (const segment of segments2.slice(1)) {
|
|
85
|
-
if (value2 && typeof value2 === "object") {
|
|
86
|
-
value2 = value2[segment];
|
|
87
|
-
} else {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
76
|
+
if (typeof value === "string") {
|
|
77
|
+
return value.toLowerCase() === "true" || value === "1";
|
|
90
78
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const segments = trimmed.split(".");
|
|
94
|
-
const nodeId = segments[0];
|
|
95
|
-
let nodeOutput = context.previousOutputs.get(nodeId);
|
|
96
|
-
if (nodeOutput === undefined) {
|
|
97
|
-
const normalizedUnderscore = nodeId.replace(/-/g, "_");
|
|
98
|
-
const normalizedHyphen = nodeId.replace(/_/g, "-");
|
|
99
|
-
if (normalizedUnderscore !== nodeId) {
|
|
100
|
-
nodeOutput = context.previousOutputs.get(normalizedUnderscore);
|
|
79
|
+
if (typeof value === "number") {
|
|
80
|
+
return value !== 0;
|
|
101
81
|
}
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (nodeOutput === undefined)
|
|
107
|
-
return;
|
|
108
|
-
let value = nodeOutput;
|
|
109
|
-
for (const segment of segments.slice(1)) {
|
|
110
|
-
if (value && typeof value === "object") {
|
|
111
|
-
value = value[segment];
|
|
112
|
-
} else {
|
|
113
|
-
return;
|
|
82
|
+
if (value === null || value === undefined) {
|
|
83
|
+
return false;
|
|
114
84
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
if (typeof value === "string") {
|
|
123
|
-
return value.toLowerCase() === "true" || value === "1";
|
|
124
|
-
}
|
|
125
|
-
if (typeof value === "number") {
|
|
126
|
-
return value !== 0;
|
|
127
|
-
}
|
|
128
|
-
if (value === null || value === undefined) {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
if (typeof value === "object") {
|
|
132
|
-
const obj = value;
|
|
133
|
-
if ("success" in obj) {
|
|
134
|
-
return Boolean(obj.success);
|
|
85
|
+
if (typeof value === "object") {
|
|
86
|
+
const obj = value;
|
|
87
|
+
if ("success" in obj) {
|
|
88
|
+
return Boolean(obj.success);
|
|
89
|
+
}
|
|
90
|
+
return Object.keys(obj).length > 0;
|
|
135
91
|
}
|
|
136
|
-
return
|
|
92
|
+
return Boolean(value);
|
|
137
93
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
94
|
+
};
|
|
95
|
+
__legacyDecorateClassTS([
|
|
96
|
+
TracedAs("workflow.condition.execute", { log: true })
|
|
97
|
+
], ConditionNode.prototype, "execute", null);
|
|
98
|
+
});
|
|
142
99
|
|
|
143
100
|
// src/env/workflow/nodes/merge-node.ts
|
|
144
101
|
class MergeNode {
|