@ai-setting/roy-agent-core 1.5.42 → 1.5.44

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 (31) hide show
  1. package/dist/env/agent/index.js +2 -2
  2. package/dist/env/index.js +11 -10
  3. package/dist/env/task/delegate/index.js +3 -2
  4. package/dist/env/task/index.js +3 -3
  5. package/dist/env/tool/built-in/index.js +1 -1
  6. package/dist/env/tool/index.js +2 -2
  7. package/dist/env/workflow/decorators/index.js +1 -1
  8. package/dist/env/workflow/engine/index.js +4 -3
  9. package/dist/env/workflow/index.js +34 -19
  10. package/dist/env/workflow/nodes/index.js +5 -1
  11. package/dist/env/workflow/types/index.js +16 -2
  12. package/dist/env/workflow/utils/index.js +15 -196
  13. package/dist/index.js +13 -12
  14. package/dist/shared/@ai-setting/{roy-agent-core-9q6sa7m3.js → roy-agent-core-1zq3p19q.js} +1 -1
  15. package/dist/shared/@ai-setting/{roy-agent-core-ffb9fq4v.js → roy-agent-core-23gw9c4s.js} +2 -2
  16. package/dist/shared/@ai-setting/{roy-agent-core-bmr6bdfb.js → roy-agent-core-2ms7296b.js} +4 -4
  17. package/dist/shared/@ai-setting/{roy-agent-core-2jnzv9at.js → roy-agent-core-38dkek2y.js} +319 -189
  18. package/dist/shared/@ai-setting/roy-agent-core-6vxg2gmr.js +321 -0
  19. package/dist/shared/@ai-setting/{roy-agent-core-0rtxwr28.js → roy-agent-core-9bmtxmp6.js} +77 -120
  20. package/dist/shared/@ai-setting/{roy-agent-core-xz22rmak.js → roy-agent-core-9p43ap7h.js} +21 -7
  21. package/dist/shared/@ai-setting/{roy-agent-core-7t05apnp.js → roy-agent-core-fg3j215p.js} +26 -0
  22. package/dist/shared/@ai-setting/{roy-agent-core-7fgf85wc.js → roy-agent-core-h0x19xgn.js} +6 -7
  23. package/dist/shared/@ai-setting/roy-agent-core-qnrf2aw6.js +441 -0
  24. package/dist/shared/@ai-setting/{roy-agent-core-ek6gk3wk.js → roy-agent-core-r6rwsr54.js} +42 -3
  25. package/dist/shared/@ai-setting/roy-agent-core-v002ynpa.js +435 -0
  26. package/dist/shared/@ai-setting/{roy-agent-core-rsybkb38.js → roy-agent-core-ysvh8er9.js} +36 -39
  27. package/dist/shared/@ai-setting/{roy-agent-core-9yxb3ty9.js → roy-agent-core-z5sxe4p7.js} +5 -1
  28. package/package.json +1 -1
  29. package/dist/shared/@ai-setting/roy-agent-core-5x94xmt6.js +0 -350
  30. package/dist/shared/@ai-setting/roy-agent-core-jvatggbb.js +0 -603
  31. /package/dist/shared/@ai-setting/{roy-agent-core-e130w7mv.js → roy-agent-core-ryw3ckfy.js} +0 -0
@@ -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 };
@@ -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
- class ConditionNode {
12
- definition;
13
- type = "condition";
14
- id;
15
- constructor(definition) {
16
- this.definition = definition;
17
- this.id = definition.id;
18
- }
19
- async execute(context) {
20
- const startTime = Date.now();
21
- try {
22
- const conditionConfig = this.definition.config?.condition;
23
- if (conditionConfig === undefined) {
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: true, condition: true },
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
- return condition;
59
- }
60
- resolveTemplate(path, context) {
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 (nodeOutput2 === undefined)
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
- return value2;
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 (nodeOutput === undefined && normalizedHyphen !== nodeId) {
103
- nodeOutput = context.previousOutputs.get(normalizedHyphen);
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
- return value;
117
- }
118
- evaluateCondition(value) {
119
- if (typeof value === "boolean") {
120
- return value;
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 Object.keys(obj).length > 0;
92
+ return Boolean(value);
137
93
  }
138
- return Boolean(value);
139
- }
140
- }
141
- var init_condition_node = () => {};
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 {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_SUBAGENT_PROMPT
3
- } from "./roy-agent-core-7t05apnp.js";
3
+ } from "./roy-agent-core-fg3j215p.js";
4
4
  import {
5
5
  TaskHookPoints
6
6
  } from "./roy-agent-core-92z6t4he.js";
@@ -53,13 +53,23 @@ async function resolveFromRegistry(subagentType, agentDef, builtIn, registry) {
53
53
  fromRegistry: true
54
54
  };
55
55
  }
56
+ function buildAgentSelectionGuide(options) {
57
+ const customAgentNote = options.hasCustomAgents ? "- Custom agents from AgentRegistry are listed above." : "- Custom agents from AgentRegistry appear above when registered.";
58
+ return `
59
+ ## Agent Selection Guide
60
+
61
+ - Choose \`subagent_type\` from the list above; use \`general\` when no specialized agent fits (default).
62
+ ${customAgentNote}
63
+ - For full metadata: \`roy-agent agents list\`, \`roy-agent agents get <name>\`, \`roy-agent prompt list\`.`;
64
+ }
56
65
  function listKnownSubagentDescriptions(registry) {
57
66
  const builtInLines = builtInSubAgents.map((agent) => `- ${agent.id}: ${agent.description}`);
58
67
  const registryAgents = registry?.listAgentsByType("sub") ?? [];
59
68
  const customLines = registryAgents.filter((agent) => !builtInSubAgents.some((builtIn) => builtIn.id === agent.name)).map((agent) => `- ${agent.name}: ${agent.description || "Custom agent"}`);
60
69
  const lines = [...builtInLines, ...customLines];
70
+ const guidance = buildAgentSelectionGuide({ hasCustomAgents: customLines.length > 0 });
61
71
  return lines.join(`
62
- `);
72
+ `) + guidance;
63
73
  }
64
74
 
65
75
  // src/env/task/delegate/delegate-tool.ts
@@ -497,16 +507,21 @@ ${prompt}
497
507
  logger.info(`[BackgroundTaskManager] Disposed`);
498
508
  }
499
509
  }
510
+ function getAgentRegistry(taskComponent) {
511
+ const agentComponent = taskComponent.env?.getComponent?.("agent");
512
+ return agentComponent?.getRegistry?.();
513
+ }
500
514
  function createDelegateTool(taskComponent) {
501
515
  const env = taskComponent.env;
502
516
  const backgroundTaskManager = new BackgroundTaskManager(env);
517
+ const registry = getAgentRegistry(taskComponent);
503
518
  taskComponent._backgroundTaskManager = backgroundTaskManager;
504
519
  const tool = {
505
520
  name: "delegate_task",
506
521
  description: `Launch a new sub-agent to handle complex, multistep tasks autonomously.
507
522
 
508
523
  Available agent types:
509
- ${listKnownSubagentDescriptions()}
524
+ ${listKnownSubagentDescriptions(registry)}
510
525
 
511
526
  When using the delegate_task tool, you must specify a subagent_type parameter to select which agent type to use.
512
527
 
@@ -533,9 +548,8 @@ When using the delegate_task tool, you must specify a subagent_type parameter to
533
548
  const { description, prompt, subagent_type = "general", background = false, timeout, cleanup, task_id, reason } = params;
534
549
  const parentSessionId = ctx.session_id || "default";
535
550
  logger.info(`[delegate_task] Called: description=${description}, subagent_type=${subagent_type}, background=${background}, task_id=${task_id}`);
536
- const agentComponent = taskComponent.env?.getComponent?.("agent");
537
- const registry = agentComponent?.getRegistry?.();
538
- if (!isKnownSubagentType(subagent_type, registry)) {
551
+ const registry2 = getAgentRegistry(taskComponent);
552
+ if (!isKnownSubagentType(subagent_type, registry2)) {
539
553
  return {
540
554
  success: false,
541
555
  output: "",
@@ -616,7 +630,7 @@ async function handleSyncTask(taskComponent, parentSessionId, description, promp
616
630
  };
617
631
  }
618
632
  const agentComponent = taskComponent.env?.getComponent?.("agent");
619
- const registry = agentComponent?.getRegistry?.();
633
+ const registry = getAgentRegistry(taskComponent);
620
634
  const resolved = await resolveSubAgentConfig(subagentType, { registry });
621
635
  const subAgent = getSubAgentSpec(subagentType);
622
636
  let basePrompt = resolved?.basePrompt || subAgent?.promptOverride || `You are a subagent. Complete this task: {task_description}`;
@@ -1,10 +1,17 @@
1
1
  import {
2
2
  getXDGPath
3
3
  } from "./roy-agent-core-qxnbvgwe.js";
4
+ import {
5
+ TracedAs,
6
+ init_decorator
7
+ } from "./roy-agent-core-q5qj0fes.js";
4
8
  import {
5
9
  createLogger,
6
10
  init_logger
7
11
  } from "./roy-agent-core-10n2jh7p.js";
12
+ import {
13
+ __legacyDecorateClassTS
14
+ } from "./roy-agent-core-fs0mn2jk.js";
8
15
 
9
16
  // src/env/agent/agent-registry.ts
10
17
  import { readdir, readFile, writeFile, mkdir, unlink } from "fs/promises";
@@ -13,6 +20,7 @@ import { join } from "path";
13
20
  import { z } from "zod";
14
21
  import yaml from "yaml";
15
22
  init_logger();
23
+ init_decorator();
16
24
  var logger = createLogger("agent:registry");
17
25
  var AgentConfigSchema = z.object({
18
26
  name: z.string(),
@@ -262,6 +270,24 @@ class AgentRegistry {
262
270
  return join(this.configDir, `${name}.yaml`);
263
271
  }
264
272
  }
273
+ __legacyDecorateClassTS([
274
+ TracedAs("agent.registry.register", { recordParams: true, recordResult: true, log: true })
275
+ ], AgentRegistry.prototype, "register", null);
276
+ __legacyDecorateClassTS([
277
+ TracedAs("agent.registry.unregister", { recordParams: true, recordResult: true, log: true })
278
+ ], AgentRegistry.prototype, "unregister", null);
279
+ __legacyDecorateClassTS([
280
+ TracedAs("agent.registry.clear", { recordParams: false, recordResult: true, log: true })
281
+ ], AgentRegistry.prototype, "clear", null);
282
+ __legacyDecorateClassTS([
283
+ TracedAs("agent.registry.getSystemPrompt", { recordParams: true, recordResult: true, log: true })
284
+ ], AgentRegistry.prototype, "getSystemPrompt", null);
285
+ __legacyDecorateClassTS([
286
+ TracedAs("agent.registry.load", { recordParams: false, recordResult: true, log: true })
287
+ ], AgentRegistry.prototype, "load", null);
288
+ __legacyDecorateClassTS([
289
+ TracedAs("agent.registry.loadFromDirectory", { recordParams: true, recordResult: true, log: true })
290
+ ], AgentRegistry.prototype, "loadFromDirectory", null);
265
291
  function isAgentConfigFile(fileName) {
266
292
  return fileName.endsWith(".yaml") || fileName.endsWith(".yml");
267
293
  }