@ai-setting/roy-agent-core 1.5.13-test → 1.5.15-test

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.
Files changed (141) hide show
  1. package/package.json +1 -1
  2. package/dist/config/index.d.ts +0 -1250
  3. package/dist/config/index.js +0 -32
  4. package/dist/env/agent/index.d.ts +0 -2279
  5. package/dist/env/agent/index.js +0 -24
  6. package/dist/env/commands/index.d.ts +0 -1131
  7. package/dist/env/commands/index.js +0 -14
  8. package/dist/env/debug/formatters/index.d.ts +0 -236
  9. package/dist/env/debug/formatters/index.js +0 -11
  10. package/dist/env/debug/index.d.ts +0 -1652
  11. package/dist/env/debug/index.js +0 -26
  12. package/dist/env/hook/index.d.ts +0 -279
  13. package/dist/env/hook/index.js +0 -29
  14. package/dist/env/index.d.ts +0 -3481
  15. package/dist/env/index.js +0 -82
  16. package/dist/env/llm/index.d.ts +0 -1760
  17. package/dist/env/llm/index.js +0 -40
  18. package/dist/env/log-trace/index.d.ts +0 -1574
  19. package/dist/env/log-trace/index.js +0 -83
  20. package/dist/env/mcp/index.d.ts +0 -1331
  21. package/dist/env/mcp/index.js +0 -39
  22. package/dist/env/mcp/tool/index.d.ts +0 -183
  23. package/dist/env/mcp/tool/index.js +0 -14
  24. package/dist/env/memory/built-in/index.d.ts +0 -232
  25. package/dist/env/memory/built-in/index.js +0 -11
  26. package/dist/env/memory/index.d.ts +0 -1799
  27. package/dist/env/memory/index.js +0 -56
  28. package/dist/env/memory/plugin/index.d.ts +0 -747
  29. package/dist/env/memory/plugin/index.js +0 -36
  30. package/dist/env/prompt/index.d.ts +0 -1164
  31. package/dist/env/prompt/index.js +0 -20
  32. package/dist/env/session/index.d.ts +0 -1908
  33. package/dist/env/session/index.js +0 -25
  34. package/dist/env/session/storage/index.d.ts +0 -564
  35. package/dist/env/session/storage/index.js +0 -18
  36. package/dist/env/skill/index.d.ts +0 -1266
  37. package/dist/env/skill/index.js +0 -34
  38. package/dist/env/skill/tool/index.d.ts +0 -193
  39. package/dist/env/skill/tool/index.js +0 -9
  40. package/dist/env/task/delegate/index.d.ts +0 -1612
  41. package/dist/env/task/delegate/index.js +0 -18
  42. package/dist/env/task/events/index.d.ts +0 -171
  43. package/dist/env/task/events/index.js +0 -7
  44. package/dist/env/task/hooks/index.d.ts +0 -624
  45. package/dist/env/task/hooks/index.js +0 -7
  46. package/dist/env/task/index.d.ts +0 -1553
  47. package/dist/env/task/index.js +0 -34
  48. package/dist/env/task/plugins/index.d.ts +0 -466
  49. package/dist/env/task/plugins/index.js +0 -23
  50. package/dist/env/task/storage/index.d.ts +0 -241
  51. package/dist/env/task/storage/index.js +0 -14
  52. package/dist/env/task/tools/index.d.ts +0 -1485
  53. package/dist/env/task/tools/index.js +0 -17
  54. package/dist/env/task/tools/operation/index.d.ts +0 -1484
  55. package/dist/env/task/tools/operation/index.js +0 -15
  56. package/dist/env/tool/built-in/index.d.ts +0 -218
  57. package/dist/env/tool/built-in/index.js +0 -25
  58. package/dist/env/tool/index.d.ts +0 -1396
  59. package/dist/env/tool/index.js +0 -39
  60. package/dist/env/workflow/decorators/index.d.ts +0 -2161
  61. package/dist/env/workflow/decorators/index.js +0 -27
  62. package/dist/env/workflow/engine/index.d.ts +0 -3453
  63. package/dist/env/workflow/engine/index.js +0 -28
  64. package/dist/env/workflow/index.d.ts +0 -3546
  65. package/dist/env/workflow/index.js +0 -136
  66. package/dist/env/workflow/nodes/index.d.ts +0 -2092
  67. package/dist/env/workflow/nodes/index.js +0 -19
  68. package/dist/env/workflow/service/index.d.ts +0 -227
  69. package/dist/env/workflow/service/index.js +0 -13
  70. package/dist/env/workflow/storage/index.d.ts +0 -165
  71. package/dist/env/workflow/storage/index.js +0 -27
  72. package/dist/env/workflow/tools/index.d.ts +0 -416
  73. package/dist/env/workflow/tools/index.js +0 -159
  74. package/dist/env/workflow/types/index.d.ts +0 -2255
  75. package/dist/env/workflow/types/index.js +0 -98
  76. package/dist/env/workflow/utils/index.d.ts +0 -2031
  77. package/dist/env/workflow/utils/index.js +0 -637
  78. package/dist/index.d.ts +0 -7858
  79. package/dist/index.js +0 -399
  80. package/dist/shared/@ai-setting/roy-agent-core-0rtxwr28.js +0 -258
  81. package/dist/shared/@ai-setting/roy-agent-core-0vbdz0x7.js +0 -36
  82. package/dist/shared/@ai-setting/roy-agent-core-1akcqxj9.js +0 -349
  83. package/dist/shared/@ai-setting/roy-agent-core-1ce3fqrk.js +0 -117
  84. package/dist/shared/@ai-setting/roy-agent-core-2dhd60aw.js +0 -11
  85. package/dist/shared/@ai-setting/roy-agent-core-3jywqmdd.js +0 -393
  86. package/dist/shared/@ai-setting/roy-agent-core-3rr5k71j.js +0 -200
  87. package/dist/shared/@ai-setting/roy-agent-core-44hnfb02.js +0 -299
  88. package/dist/shared/@ai-setting/roy-agent-core-4t40mkpv.js +0 -206
  89. package/dist/shared/@ai-setting/roy-agent-core-4txzpsbt.js +0 -393
  90. package/dist/shared/@ai-setting/roy-agent-core-5x94xmt6.js +0 -350
  91. package/dist/shared/@ai-setting/roy-agent-core-69jskqjg.js +0 -180
  92. package/dist/shared/@ai-setting/roy-agent-core-6kvtahqv.js +0 -408
  93. package/dist/shared/@ai-setting/roy-agent-core-7fgf85wc.js +0 -284
  94. package/dist/shared/@ai-setting/roy-agent-core-81w1963m.js +0 -762
  95. package/dist/shared/@ai-setting/roy-agent-core-8gxth0eh.js +0 -10
  96. package/dist/shared/@ai-setting/roy-agent-core-92z6t4he.js +0 -14
  97. package/dist/shared/@ai-setting/roy-agent-core-93zfb3r1.js +0 -922
  98. package/dist/shared/@ai-setting/roy-agent-core-9yxb3ty9.js +0 -15
  99. package/dist/shared/@ai-setting/roy-agent-core-b0x5dda6.js +0 -1130
  100. package/dist/shared/@ai-setting/roy-agent-core-bcbqy27c.js +0 -14
  101. package/dist/shared/@ai-setting/roy-agent-core-bvr1761x.js +0 -653
  102. package/dist/shared/@ai-setting/roy-agent-core-ctdhjv68.js +0 -93
  103. package/dist/shared/@ai-setting/roy-agent-core-d7cyjkf7.js +0 -872
  104. package/dist/shared/@ai-setting/roy-agent-core-dh9d7a3m.js +0 -11
  105. package/dist/shared/@ai-setting/roy-agent-core-e25xkv53.js +0 -64
  106. package/dist/shared/@ai-setting/roy-agent-core-eajcvp4e.js +0 -378
  107. package/dist/shared/@ai-setting/roy-agent-core-f7q2x5z6.js +0 -492
  108. package/dist/shared/@ai-setting/roy-agent-core-fs0mn2jk.js +0 -52
  109. package/dist/shared/@ai-setting/roy-agent-core-g1s2h0e5.js +0 -171
  110. package/dist/shared/@ai-setting/roy-agent-core-g99pxzn5.js +0 -862
  111. package/dist/shared/@ai-setting/roy-agent-core-gbqcyegm.js +0 -1387
  112. package/dist/shared/@ai-setting/roy-agent-core-gjq1yk68.js +0 -208
  113. package/dist/shared/@ai-setting/roy-agent-core-gq20wsgv.js +0 -139
  114. package/dist/shared/@ai-setting/roy-agent-core-gwc4h96n.js +0 -534
  115. package/dist/shared/@ai-setting/roy-agent-core-jfh9q2qh.js +0 -204
  116. package/dist/shared/@ai-setting/roy-agent-core-jvatggbb.js +0 -603
  117. package/dist/shared/@ai-setting/roy-agent-core-kkbwepqb.js +0 -97
  118. package/dist/shared/@ai-setting/roy-agent-core-pjr12nnd.js +0 -587
  119. package/dist/shared/@ai-setting/roy-agent-core-psv4v63c.js +0 -176
  120. package/dist/shared/@ai-setting/roy-agent-core-psvxt4c9.js +0 -60
  121. package/dist/shared/@ai-setting/roy-agent-core-qqceba6k.js +0 -442
  122. package/dist/shared/@ai-setting/roy-agent-core-qxhq8ven.js +0 -57
  123. package/dist/shared/@ai-setting/roy-agent-core-qxnbvgwe.js +0 -66
  124. package/dist/shared/@ai-setting/roy-agent-core-r9ezzemr.js +0 -10
  125. package/dist/shared/@ai-setting/roy-agent-core-rhmtwnw1.js +0 -267
  126. package/dist/shared/@ai-setting/roy-agent-core-rvv6ydff.js +0 -584
  127. package/dist/shared/@ai-setting/roy-agent-core-rvxg1wps.js +0 -102
  128. package/dist/shared/@ai-setting/roy-agent-core-satmq6sh.js +0 -549
  129. package/dist/shared/@ai-setting/roy-agent-core-sx7wsvnn.js +0 -15
  130. package/dist/shared/@ai-setting/roy-agent-core-t94ktchq.js +0 -213
  131. package/dist/shared/@ai-setting/roy-agent-core-vf215qfv.js +0 -812
  132. package/dist/shared/@ai-setting/roy-agent-core-vkz81f7v.js +0 -1316
  133. package/dist/shared/@ai-setting/roy-agent-core-vn2bc59q.js +0 -1205
  134. package/dist/shared/@ai-setting/roy-agent-core-wa1kzqky.js +0 -328
  135. package/dist/shared/@ai-setting/roy-agent-core-wft9ra24.js +0 -20
  136. package/dist/shared/@ai-setting/roy-agent-core-wrcy0h6z.js +0 -2098
  137. package/dist/shared/@ai-setting/roy-agent-core-xq8hhqb8.js +0 -419
  138. package/dist/shared/@ai-setting/roy-agent-core-xs5rsgat.js +0 -368
  139. package/dist/shared/@ai-setting/roy-agent-core-zbkpc41z.js +0 -377
  140. package/dist/shared/@ai-setting/roy-agent-core-zgypchmt.js +0 -172
  141. package/dist/shared/@ai-setting/roy-agent-core-zpn0bqa8.js +0 -103
@@ -1,603 +0,0 @@
1
- import {
2
- __esm
3
- } from "./roy-agent-core-fs0mn2jk.js";
4
-
5
- // src/env/workflow/nodes/tool-node.ts
6
- class ToolNode {
7
- definition;
8
- toolRegistry;
9
- type = "tool";
10
- id;
11
- constructor(definition, toolRegistry) {
12
- this.definition = definition;
13
- this.toolRegistry = toolRegistry;
14
- this.id = definition.id;
15
- }
16
- async execute(context) {
17
- const startTime = Date.now();
18
- try {
19
- const toolName = this.definition.config?.tool ?? this.definition.config?.toolName;
20
- if (!toolName) {
21
- throw new Error("Tool name is required. Please specify config.tool or config.toolName in the node definition.");
22
- }
23
- let tool;
24
- if (this.toolRegistry.getTool) {
25
- const result = this.toolRegistry.getTool(toolName);
26
- if (!result) {
27
- throw new Error(`Tool not found: ${toolName}`);
28
- }
29
- if ("tool" in result) {
30
- tool = result.tool;
31
- } else {
32
- tool = result;
33
- }
34
- } else if (this.toolRegistry.getToolByName) {
35
- tool = this.toolRegistry.getToolByName(toolName);
36
- }
37
- if (!tool) {
38
- throw new Error(`Tool not found: ${toolName}`);
39
- }
40
- let input;
41
- if (this.definition.config?.command !== undefined) {
42
- const commandTemplate = this.definition.config.command;
43
- const resolvedCommand = this.resolveTemplateReferences(commandTemplate, context.previousOutputs, context.input);
44
- input = { command: resolvedCommand };
45
- console.log(`[ToolNode] command input: ${resolvedCommand}`);
46
- } else if (this.definition.config?.message !== undefined && Object.keys(this.definition.config).length === 1) {
47
- const messageTemplate = this.definition.config.message;
48
- const resolvedMessage = this.resolveTemplateReferences(messageTemplate, context.previousOutputs, context.input);
49
- input = { message: resolvedMessage };
50
- console.log(`[ToolNode] message input: ${resolvedMessage}`);
51
- } else {
52
- input = this.definition.config?.input ?? this.definition.config?.inputs ?? this.definition.config?.args ?? {};
53
- input = this.resolveTemplateReferences(input, context.previousOutputs, context.input);
54
- }
55
- let output;
56
- try {
57
- const toolContext = {
58
- session_id: context.sessionId || `workflow_${context.runId}`,
59
- message_id: context.nodeId,
60
- metadata: {
61
- workflowRunId: context.runId,
62
- workflowName: context.workflowName,
63
- nodeId: context.nodeId
64
- }
65
- };
66
- const executePromise = tool.execute(input, toolContext);
67
- const timeoutPromise = new Promise((_, reject) => {
68
- setTimeout(() => reject(new Error(`Tool ${toolName} execution timeout after 30s`)), 30000);
69
- });
70
- output = await Promise.race([executePromise, timeoutPromise]);
71
- } catch (err) {
72
- console.log(`[ToolNode] Tool ${toolName} doesn't support context, retrying without context...`);
73
- output = await tool.execute(input);
74
- }
75
- return {
76
- output,
77
- error: undefined,
78
- durationMs: Date.now() - startTime
79
- };
80
- } catch (error) {
81
- return {
82
- output: undefined,
83
- error: error instanceof Error ? error : new Error(String(error)),
84
- durationMs: Date.now() - startTime
85
- };
86
- }
87
- }
88
- resolveTemplateReferences(input, previousOutputs, workflowInput) {
89
- if (typeof input === "string") {
90
- const pureTemplate = this.extractPureTemplate(input) || this.extractDollarTemplate(input);
91
- if (pureTemplate) {
92
- return this.resolvePureTemplate(pureTemplate, previousOutputs, workflowInput);
93
- }
94
- return this.resolveStringTemplate(input, previousOutputs, workflowInput);
95
- }
96
- if (Array.isArray(input)) {
97
- return input.map((item) => this.resolveTemplateReferences(item, previousOutputs, workflowInput));
98
- }
99
- if (input !== null && typeof input === "object") {
100
- const resolved = {};
101
- for (const [key, value] of Object.entries(input)) {
102
- resolved[key] = this.resolveTemplateReferences(value, previousOutputs, workflowInput);
103
- }
104
- return resolved;
105
- }
106
- return input;
107
- }
108
- extractPureTemplate(str) {
109
- const trimmed = str.trim();
110
- if (trimmed.startsWith("{{") && trimmed.endsWith("}}") && trimmed.length > 4) {
111
- const content = trimmed.slice(2, -2).trim();
112
- if (!content.includes("{{") && !content.includes("}}")) {
113
- return content;
114
- }
115
- }
116
- return null;
117
- }
118
- extractDollarTemplate(str) {
119
- const trimmed = str.trim();
120
- if (trimmed.startsWith("${") && trimmed.endsWith("}") && trimmed.length > 3) {
121
- const content = trimmed.slice(2, -1).trim();
122
- if (!content.includes("${") && !content.includes("}")) {
123
- return content;
124
- }
125
- }
126
- return null;
127
- }
128
- resolvePureTemplate(templateContent, previousOutputs, workflowInput) {
129
- const trimmed = templateContent.trim();
130
- const originalTemplate = `{{${templateContent}}}`;
131
- if (trimmed.startsWith("input.")) {
132
- const value = this.getNestedValue(workflowInput, trimmed.slice(6));
133
- return value !== undefined ? value : originalTemplate;
134
- }
135
- if (trimmed.startsWith("nodes.")) {
136
- const path = trimmed.slice(6);
137
- const segments = path.split(".");
138
- const nodeId = segments[0];
139
- const restPath = segments.slice(1).join(".") || undefined;
140
- const value = this.resolvePath(nodeId, restPath, previousOutputs);
141
- return value !== undefined ? value : originalTemplate;
142
- }
143
- if (trimmed !== "input" && trimmed !== "nodes") {
144
- const segments = trimmed.split(".");
145
- const nodeId = segments[0];
146
- const restPath = segments.slice(1).join(".") || undefined;
147
- const value = this.resolvePath(nodeId, restPath, previousOutputs);
148
- return value !== undefined ? value : originalTemplate;
149
- }
150
- return originalTemplate;
151
- }
152
- resolveStringTemplate(template, previousOutputs, workflowInput) {
153
- let resolved = template;
154
- resolved = resolved.replace(/\{\{input\.([^}]+)\}\}/g, (match, path) => {
155
- const value = this.getNestedValue(workflowInput, path.trim());
156
- return this.stringifyValue(value, match);
157
- });
158
- resolved = resolved.replace(/\$\{input\.([^}]+)\}/g, (match, path) => {
159
- const value = this.getNestedValue(workflowInput, path.trim());
160
- return this.stringifyValue(value, match);
161
- });
162
- resolved = resolved.replace(/\{\{([^:.{}][^}]*?)\}\}/g, (match, path) => {
163
- if (path.trim().startsWith("nodes.") || path.trim().startsWith("input.")) {
164
- return match;
165
- }
166
- const segments = path.trim().split(".");
167
- const nodeId = segments[0];
168
- const restPath = segments.slice(1).join(".") || undefined;
169
- const value = this.resolvePath(nodeId, restPath, previousOutputs);
170
- return this.stringifyValue(value, match);
171
- });
172
- resolved = resolved.replace(/\$\{([^}]+)\}/g, (match, path) => {
173
- if (path.trim().startsWith("nodes.") || path.trim().startsWith("input.")) {
174
- return match;
175
- }
176
- const segments = path.trim().split(".");
177
- const nodeId = segments[0];
178
- const restPath = segments.slice(1).join(".") || undefined;
179
- const value = this.resolvePath(nodeId, restPath, previousOutputs);
180
- return this.stringifyValue(value, match);
181
- });
182
- resolved = resolved.replace(/\{\{nodes\.([^}]+)\}\}/g, (match, path) => {
183
- const segments = path.trim().split(".");
184
- const nodeId = segments[0];
185
- const restPath = segments.slice(1).join(".") || undefined;
186
- const nodeOutput = this.resolvePath(nodeId, undefined, previousOutputs);
187
- let extractedValue = this.extractFromWrapper(nodeOutput);
188
- if (typeof extractedValue === "string" && restPath === "output") {
189
- return this.stringifyValue(extractedValue, match);
190
- }
191
- if (restPath) {
192
- const value = this.getNestedValue(extractedValue, restPath);
193
- return this.stringifyValue(value, match);
194
- } else {
195
- return this.stringifyValue(extractedValue, match);
196
- }
197
- });
198
- return resolved;
199
- }
200
- resolvePath(nodeId, path, previousOutputs) {
201
- let nodeOutput = previousOutputs.get(nodeId);
202
- if (nodeOutput === undefined) {
203
- const normalizedUnderscore = nodeId.replace(/-/g, "_");
204
- const normalizedHyphen = nodeId.replace(/_/g, "-");
205
- if (normalizedUnderscore !== nodeId) {
206
- nodeOutput = previousOutputs.get(normalizedUnderscore);
207
- }
208
- if (nodeOutput === undefined && normalizedHyphen !== nodeId) {
209
- nodeOutput = previousOutputs.get(normalizedHyphen);
210
- }
211
- }
212
- if (nodeOutput === undefined) {
213
- return;
214
- }
215
- if (path === undefined || path === "") {
216
- return nodeOutput;
217
- }
218
- return this.getNestedValue(nodeOutput, path);
219
- }
220
- getNestedValue(obj, path) {
221
- if (obj === null || obj === undefined) {
222
- return;
223
- }
224
- const segments = path.split(".");
225
- let current = obj;
226
- for (const segment of segments) {
227
- if (current === null || current === undefined) {
228
- return;
229
- }
230
- current = current[segment];
231
- }
232
- return current;
233
- }
234
- extractFromWrapper(value) {
235
- if (value === null || value === undefined) {
236
- return value;
237
- }
238
- if (typeof value !== "object") {
239
- return value;
240
- }
241
- let result;
242
- if ("output" in value) {
243
- result = value.output;
244
- } else if ("result" in value && !("output" in value)) {
245
- result = value.result;
246
- } else {
247
- return value;
248
- }
249
- if (typeof result === "string") {
250
- return result.trimEnd();
251
- }
252
- return result;
253
- }
254
- stringifyValue(value, fallback) {
255
- if (value === undefined || value === null) {
256
- return fallback;
257
- }
258
- let str;
259
- if (typeof value === "object") {
260
- str = JSON.stringify(value);
261
- } else {
262
- str = String(value);
263
- }
264
- return str.replace(/\\/g, "\\\\").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t").replace(/"/g, "\\\"").replace(/`/g, "\\`").replace(/\$/g, "\\$");
265
- }
266
- }
267
- var init_tool_node = () => {};
268
-
269
- // src/env/workflow/nodes/skill-node.ts
270
- class SkillNode {
271
- definition;
272
- skillRegistry;
273
- type = "skill";
274
- id;
275
- constructor(definition, skillRegistry) {
276
- this.definition = definition;
277
- this.skillRegistry = skillRegistry;
278
- this.id = definition.id;
279
- }
280
- async execute(context) {
281
- const startTime = Date.now();
282
- try {
283
- const skillName = this.definition.config?.skill;
284
- if (!skillName) {
285
- throw new Error("Skill name is required. Please specify config.skill in the node definition.");
286
- }
287
- const skill = this.skillRegistry.getSkill(skillName);
288
- if (!skill) {
289
- throw new Error(`Skill not found: ${skillName}`);
290
- }
291
- const input = this.definition.config?.input ?? {};
292
- const resolvedInput = this.resolveTemplateReferences(input, context.previousOutputs, context.input);
293
- const skillContext = {
294
- runId: context.runId,
295
- workflowName: context.workflowName,
296
- nodeId: context.nodeId,
297
- debug: context.debug
298
- };
299
- const output = await skill.invoke(resolvedInput, skillContext);
300
- return {
301
- output,
302
- error: undefined,
303
- durationMs: Date.now() - startTime
304
- };
305
- } catch (error) {
306
- return {
307
- output: undefined,
308
- error: error instanceof Error ? error : new Error(String(error)),
309
- durationMs: Date.now() - startTime
310
- };
311
- }
312
- }
313
- resolveTemplateReferences(input, previousOutputs, workflowInput) {
314
- if (typeof input === "string") {
315
- const pureTemplate = this.extractPureTemplate(input);
316
- if (pureTemplate) {
317
- return this.resolvePureTemplate(pureTemplate, previousOutputs, workflowInput);
318
- }
319
- return this.resolveStringTemplate(input, previousOutputs, workflowInput);
320
- }
321
- if (Array.isArray(input)) {
322
- return input.map((item) => this.resolveTemplateReferences(item, previousOutputs, workflowInput));
323
- }
324
- if (input !== null && typeof input === "object") {
325
- const resolved = {};
326
- for (const [key, value] of Object.entries(input)) {
327
- resolved[key] = this.resolveTemplateReferences(value, previousOutputs, workflowInput);
328
- }
329
- return resolved;
330
- }
331
- return input;
332
- }
333
- extractPureTemplate(str) {
334
- const trimmed = str.trim();
335
- if (trimmed.startsWith("{{") && trimmed.endsWith("}}") && trimmed.length > 4) {
336
- const content = trimmed.slice(2, -2).trim();
337
- if (!content.includes("{{") && !content.includes("}}")) {
338
- return content;
339
- }
340
- }
341
- return null;
342
- }
343
- resolvePureTemplate(templateContent, previousOutputs, workflowInput) {
344
- const trimmed = templateContent.trim();
345
- const originalTemplate = `{{${templateContent}}}`;
346
- if (trimmed.startsWith("input.")) {
347
- const value = this.getNestedValue(workflowInput, trimmed.slice(6));
348
- return value !== undefined ? value : originalTemplate;
349
- }
350
- if (trimmed.startsWith("nodes.")) {
351
- const path = trimmed.slice(6);
352
- const segments = path.split(".");
353
- const nodeId = segments[0];
354
- const restPath = segments.slice(1).join(".") || undefined;
355
- const value = this.resolvePath(nodeId, restPath, previousOutputs);
356
- return value !== undefined ? value : originalTemplate;
357
- }
358
- if (trimmed !== "input" && trimmed !== "nodes") {
359
- const segments = trimmed.split(".");
360
- const nodeId = segments[0];
361
- const restPath = segments.slice(1).join(".") || undefined;
362
- const value = this.resolvePath(nodeId, restPath, previousOutputs);
363
- return value !== undefined ? value : originalTemplate;
364
- }
365
- return originalTemplate;
366
- }
367
- resolveStringTemplate(template, previousOutputs, workflowInput) {
368
- let resolved = template;
369
- resolved = resolved.replace(/\{\{input\.([^}]+)\}\}/g, (match, path) => {
370
- const value = this.getNestedValue(workflowInput, path.trim());
371
- return this.stringifyValue(value, match);
372
- });
373
- resolved = resolved.replace(/\{\{([^:.{}][^}]*?)\}\}/g, (match, path) => {
374
- if (path.trim().startsWith("nodes.") || path.trim().startsWith("input.")) {
375
- return match;
376
- }
377
- const segments = path.trim().split(".");
378
- const nodeId = segments[0];
379
- const restPath = segments.slice(1).join(".") || undefined;
380
- const value = this.resolvePath(nodeId, restPath, previousOutputs);
381
- return this.stringifyValue(value, match);
382
- });
383
- resolved = resolved.replace(/\{\{nodes\.([^}]+)\}\}/g, (match, path) => {
384
- const segments = path.trim().split(".");
385
- const nodeId = segments[0];
386
- const restPath = segments.slice(1).join(".") || undefined;
387
- const value = this.resolvePath(nodeId, restPath, previousOutputs);
388
- return this.stringifyValue(value, match);
389
- });
390
- return resolved;
391
- }
392
- resolvePath(nodeId, path, previousOutputs) {
393
- let nodeOutput = previousOutputs.get(nodeId);
394
- if (nodeOutput === undefined) {
395
- const normalizedUnderscore = nodeId.replace(/-/g, "_");
396
- const normalizedHyphen = nodeId.replace(/_/g, "-");
397
- if (normalizedUnderscore !== nodeId) {
398
- nodeOutput = previousOutputs.get(normalizedUnderscore);
399
- }
400
- if (nodeOutput === undefined && normalizedHyphen !== nodeId) {
401
- nodeOutput = previousOutputs.get(normalizedHyphen);
402
- }
403
- }
404
- if (nodeOutput === undefined) {
405
- return;
406
- }
407
- let value = this.extractFromWrapper(nodeOutput);
408
- if (!path) {
409
- return value;
410
- }
411
- let segments = path.split(".");
412
- if (segments.length > 1 && (segments[0] === "output" || segments[0] === "result" || segments[0] === "metadata")) {
413
- segments = segments.slice(1);
414
- }
415
- let current = value;
416
- for (const segment of segments) {
417
- if (current === null || current === undefined) {
418
- return;
419
- }
420
- current = current[segment];
421
- }
422
- return current;
423
- }
424
- extractFromWrapper(value) {
425
- if (value === null || value === undefined) {
426
- return value;
427
- }
428
- if (typeof value !== "object") {
429
- return value;
430
- }
431
- if ("result" in value && "metadata" in value) {
432
- return value.result;
433
- }
434
- if ("output" in value) {
435
- return value.output;
436
- }
437
- return value;
438
- }
439
- getNestedValue(obj, path) {
440
- if (!obj) {
441
- return;
442
- }
443
- if ("input" in obj && path in obj["input"]) {
444
- return obj["input"][path];
445
- }
446
- return path.split(".").reduce((current, key) => {
447
- if (current && typeof current === "object") {
448
- return current[key];
449
- }
450
- return;
451
- }, obj);
452
- }
453
- stringifyValue(value, originalTemplate) {
454
- if (value === undefined) {
455
- return originalTemplate;
456
- }
457
- if (value === null) {
458
- return "null";
459
- }
460
- if (typeof value === "string") {
461
- return value;
462
- }
463
- return JSON.stringify(value);
464
- }
465
- }
466
- var init_skill_node = () => {};
467
-
468
- // src/env/workflow/nodes/workflow-node.ts
469
- class WorkflowNode {
470
- workflowRunner;
471
- type = "workflow";
472
- id;
473
- config;
474
- constructor(definition, workflowRunner) {
475
- this.workflowRunner = workflowRunner;
476
- this.id = definition.id;
477
- this.config = definition.config ?? {};
478
- }
479
- async execute(context) {
480
- const startTime = Date.now();
481
- try {
482
- const workflowName = this.config.workflow_name;
483
- if (!workflowName) {
484
- throw new Error("workflow_name is required in config. Please specify config.workflow_name in the node definition.");
485
- }
486
- const previousOutputs = context.previousOutputs ?? this.convertToMap(context.nodeOutputs ?? {});
487
- const resolvedInput = this.resolveInput(this.config.input ?? {}, previousOutputs);
488
- const result = await this.workflowRunner.run(workflowName, resolvedInput);
489
- const success = result.status === "completed";
490
- return {
491
- success,
492
- output: result.output,
493
- error: success ? undefined : result.error,
494
- duration: Date.now() - startTime
495
- };
496
- } catch (error) {
497
- return {
498
- success: false,
499
- output: undefined,
500
- error: error instanceof Error ? error : new Error(String(error)),
501
- duration: Date.now() - startTime
502
- };
503
- }
504
- }
505
- convertToMap(nodeOutputs) {
506
- const map = new Map;
507
- for (const [nodeId, result] of Object.entries(nodeOutputs)) {
508
- map.set(nodeId, result.output);
509
- }
510
- return map;
511
- }
512
- resolveInput(input, previousOutputs) {
513
- const resolved = {};
514
- for (const [key, value] of Object.entries(input)) {
515
- resolved[key] = this.resolveValue(value, previousOutputs);
516
- }
517
- return resolved;
518
- }
519
- resolveValue(value, previousOutputs) {
520
- if (typeof value === "string") {
521
- return this.resolveStringTemplate(value, previousOutputs);
522
- }
523
- if (Array.isArray(value)) {
524
- return value.map((item) => this.resolveValue(item, previousOutputs));
525
- }
526
- if (value !== null && typeof value === "object") {
527
- const resolved = {};
528
- for (const [k, v] of Object.entries(value)) {
529
- resolved[k] = this.resolveValue(v, previousOutputs);
530
- }
531
- return resolved;
532
- }
533
- return value;
534
- }
535
- resolveStringTemplate(template, previousOutputs) {
536
- const templatePattern = /\{\{([^}]+)\}\}/g;
537
- return template.replace(templatePattern, (match, path) => {
538
- const trimmedPath = path.trim();
539
- const value = this.resolvePath(trimmedPath, previousOutputs);
540
- if (value !== undefined) {
541
- return this.stringifyValue(value, match);
542
- }
543
- return match;
544
- });
545
- }
546
- resolvePath(path, previousOutputs) {
547
- const segments = path.split(".");
548
- if (segments.length === 0) {
549
- return;
550
- }
551
- const nodeId = segments[0];
552
- let nodeOutput = previousOutputs.get(nodeId);
553
- if (nodeOutput === undefined) {
554
- return;
555
- }
556
- nodeOutput = this.extractFromWrapper(nodeOutput);
557
- if (segments.length === 1) {
558
- return nodeOutput;
559
- }
560
- let current = nodeOutput;
561
- let startIndex = 1;
562
- if (segments.length > 1 && (segments[1] === "output" || segments[1] === "result" || segments[1] === "metadata")) {
563
- startIndex = 2;
564
- }
565
- for (let i = startIndex;i < segments.length; i++) {
566
- if (current === null || current === undefined) {
567
- return;
568
- }
569
- current = current[segments[i]];
570
- }
571
- return current;
572
- }
573
- extractFromWrapper(value) {
574
- if (value === null || value === undefined) {
575
- return value;
576
- }
577
- if (typeof value !== "object") {
578
- return value;
579
- }
580
- if ("result" in value && "metadata" in value) {
581
- return value.result;
582
- }
583
- if ("output" in value) {
584
- return value.output;
585
- }
586
- return value;
587
- }
588
- stringifyValue(value, originalTemplate) {
589
- if (value === undefined) {
590
- return originalTemplate;
591
- }
592
- if (value === null) {
593
- return "null";
594
- }
595
- if (typeof value === "string") {
596
- return value;
597
- }
598
- return JSON.stringify(value);
599
- }
600
- }
601
- var init_workflow_node = () => {};
602
-
603
- export { ToolNode, init_tool_node, SkillNode, init_skill_node, WorkflowNode, init_workflow_node };
@@ -1,97 +0,0 @@
1
- import {
2
- createHook
3
- } from "./roy-agent-core-2dhd60aw.js";
4
- import {
5
- HookManager
6
- } from "./roy-agent-core-gjq1yk68.js";
7
-
8
- // src/env/component.ts
9
- class BaseComponent {
10
- _status = "created";
11
- _enabled = true;
12
- env;
13
- hookManager;
14
- constructor() {
15
- this.hookManager = new HookManager;
16
- }
17
- getStatus() {
18
- return this._status;
19
- }
20
- getConfig() {
21
- return {
22
- name: this.name,
23
- version: this.version,
24
- enabled: this._enabled,
25
- env: this.env
26
- };
27
- }
28
- isEnvInitialized() {
29
- return this._status !== "created";
30
- }
31
- setStatus(status) {
32
- this._status = status;
33
- }
34
- getEnv() {
35
- return this.env;
36
- }
37
- async init(config) {
38
- if (config?.env) {
39
- this.env = config.env;
40
- }
41
- this.setStatus("initializing");
42
- try {
43
- if (config?.name)
44
- Object.defineProperty(this, "name", { value: config.name, writable: false });
45
- if (config?.version)
46
- Object.defineProperty(this, "version", { value: config.version, writable: false });
47
- } catch {}
48
- if (config?.enabled !== undefined)
49
- this._enabled = config.enabled;
50
- this.hookManager.setComponentInfo(this.name, this.version);
51
- await this.onInit();
52
- this.setStatus("running");
53
- }
54
- async start() {
55
- if (this._started)
56
- return;
57
- this._started = true;
58
- await this.onStart();
59
- this.setStatus("running");
60
- }
61
- async stop() {
62
- this.setStatus("stopping");
63
- this.hookManager.clear();
64
- await this.onStop();
65
- this.setStatus("stopped");
66
- }
67
- async onInit() {}
68
- async onStart() {}
69
- async onStop() {}
70
- registerHook(hookPoint, hook) {
71
- this.hookManager.register(hookPoint, hook);
72
- }
73
- addHook(hookPoint, name, fn, priority) {
74
- this.hookManager.register(hookPoint, createHook({ name, priority }, fn));
75
- }
76
- removeHook(hookPoint, name) {
77
- return this.hookManager.unregister(hookPoint, name);
78
- }
79
- async executeHooks(hookPoint, data, metadata) {
80
- await this.hookManager.execute(hookPoint, data, metadata);
81
- }
82
- getConfigComponent() {
83
- return this.env?.getComponent("config");
84
- }
85
- getRuntimeConfig(key, defaultValue) {
86
- const configComponent = this.getConfigComponent();
87
- if (configComponent) {
88
- const value = configComponent.get(key);
89
- if (value !== undefined) {
90
- return value;
91
- }
92
- }
93
- return defaultValue;
94
- }
95
- }
96
-
97
- export { BaseComponent };