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

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.
@@ -10,7 +10,7 @@ import {
10
10
  parseJSONCWithProtocols,
11
11
  substituteEnvVars,
12
12
  substituteProtocolRefs
13
- } from "../shared/@ai-setting/roy-agent-core-frx4p6d1.js";
13
+ } from "../shared/@ai-setting/roy-agent-core-nj8yerg9.js";
14
14
  import"../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
15
15
  import"../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
16
16
  import"../shared/@ai-setting/roy-agent-core-4jqq077c.js";
@@ -1,8 +1,10 @@
1
1
  import {
2
2
  AgentComponent,
3
3
  AgentComponentConfigSchema
4
- } from "../../shared/@ai-setting/roy-agent-core-c8f2hync.js";
4
+ } from "../../shared/@ai-setting/roy-agent-core-ek6gk3wk.js";
5
5
  import"../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
6
+ import"../../shared/@ai-setting/roy-agent-core-7t05apnp.js";
7
+ import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
6
8
  import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
7
9
  import {
8
10
  SummaryAgent
@@ -4,7 +4,7 @@ import {
4
4
  builtInHandlers,
5
5
  getBuiltInHandler,
6
6
  larkCliHandler
7
- } from "../../shared/@ai-setting/roy-agent-core-728h32vx.js";
7
+ } from "../../shared/@ai-setting/roy-agent-core-psvwzdhj.js";
8
8
  import {
9
9
  BUILT_IN_EVENT_SOURCE_TYPES,
10
10
  BUILT_IN_EVENT_SOURCE_TYPE_LIST,
@@ -15,7 +15,7 @@ import {
15
15
  validateEventSourceConfig
16
16
  } from "../../shared/@ai-setting/roy-agent-core-xb4hvk1m.js";
17
17
  import"../../shared/@ai-setting/roy-agent-core-dxbsc1zy.js";
18
- import"../../shared/@ai-setting/roy-agent-core-2x07feb7.js";
18
+ import"../../shared/@ai-setting/roy-agent-core-e9fdm13a.js";
19
19
  import"../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
20
20
  import"../../shared/@ai-setting/roy-agent-core-92z6t4he.js";
21
21
  import"../../shared/@ai-setting/roy-agent-core-q5qj0fes.js";
package/dist/env/index.js CHANGED
@@ -1,16 +1,11 @@
1
1
  import {
2
2
  BaseEnvironment
3
3
  } from "../shared/@ai-setting/roy-agent-core-ee6nnnqw.js";
4
- import {
5
- XDG_PATHS,
6
- getXDGPath,
7
- getXDGPaths
8
- } from "../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
9
4
  import {
10
5
  EventSourceComponent,
11
6
  builtInHandlers,
12
7
  larkCliHandler
13
- } from "../shared/@ai-setting/roy-agent-core-728h32vx.js";
8
+ } from "../shared/@ai-setting/roy-agent-core-psvwzdhj.js";
14
9
  import {
15
10
  EventSourceInitHooks,
16
11
  getDefaultConfigForType,
@@ -22,11 +17,11 @@ import"../shared/@ai-setting/roy-agent-core-dxbsc1zy.js";
22
17
  import {
23
18
  PluginComponent
24
19
  } from "../shared/@ai-setting/roy-agent-core-cevpwnq7.js";
25
- import"../shared/@ai-setting/roy-agent-core-2x07feb7.js";
20
+ import"../shared/@ai-setting/roy-agent-core-e9fdm13a.js";
26
21
  import"../shared/@ai-setting/roy-agent-core-az13yzmc.js";
27
22
  import {
28
23
  WorkflowComponent
29
- } from "../shared/@ai-setting/roy-agent-core-yc543gnq.js";
24
+ } from "../shared/@ai-setting/roy-agent-core-bmr6bdfb.js";
30
25
  import"../shared/@ai-setting/roy-agent-core-0rtxwr28.js";
31
26
  import"../shared/@ai-setting/roy-agent-core-2jnzv9at.js";
32
27
  import"../shared/@ai-setting/roy-agent-core-69jskqjg.js";
@@ -39,20 +34,26 @@ import"../shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
39
34
  import {
40
35
  AgentComponent,
41
36
  AgentComponentConfigSchema
42
- } from "../shared/@ai-setting/roy-agent-core-c8f2hync.js";
37
+ } from "../shared/@ai-setting/roy-agent-core-ek6gk3wk.js";
43
38
  import"../shared/@ai-setting/roy-agent-core-e25xkv53.js";
44
39
  import {
45
40
  TaskComponent
46
- } from "../shared/@ai-setting/roy-agent-core-15x8fe5h.js";
47
- import"../shared/@ai-setting/roy-agent-core-v53rfk99.js";
41
+ } from "../shared/@ai-setting/roy-agent-core-9q6sa7m3.js";
42
+ import"../shared/@ai-setting/roy-agent-core-xz22rmak.js";
48
43
  import"../shared/@ai-setting/roy-agent-core-hsxn8m1j.js";
44
+ import"../shared/@ai-setting/roy-agent-core-7t05apnp.js";
45
+ import {
46
+ XDG_PATHS,
47
+ getXDGPath,
48
+ getXDGPaths
49
+ } from "../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
49
50
  import"../shared/@ai-setting/roy-agent-core-wa1kzqky.js";
50
51
  import"../shared/@ai-setting/roy-agent-core-t94ktchq.js";
51
52
  import"../shared/@ai-setting/roy-agent-core-92z6t4he.js";
52
53
  import"../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
53
54
  import {
54
55
  McpComponent
55
- } from "../shared/@ai-setting/roy-agent-core-ycg9rk6z.js";
56
+ } from "../shared/@ai-setting/roy-agent-core-xkb264a8.js";
56
57
  import"../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
57
58
  import"../shared/@ai-setting/roy-agent-core-1bfmxx89.js";
58
59
  import"../shared/@ai-setting/roy-agent-core-kwhv9dcd.js";
@@ -8,7 +8,7 @@ import {
8
8
  McpServerLocalConfigSchema,
9
9
  McpServerRemoteConfigSchema,
10
10
  getMcpPathPriority
11
- } from "../../shared/@ai-setting/roy-agent-core-ycg9rk6z.js";
11
+ } from "../../shared/@ai-setting/roy-agent-core-xkb264a8.js";
12
12
  import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
13
13
  import {
14
14
  adaptMcpTool,
@@ -3,7 +3,8 @@ import {
3
3
  PromptConfigSchema,
4
4
  PromptPathSchema,
5
5
  PromptRenderer
6
- } from "../../shared/@ai-setting/roy-agent-core-wb43x8hd.js";
6
+ } from "../../shared/@ai-setting/roy-agent-core-z1xf2fdk.js";
7
+ import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
7
8
  import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
8
9
  import"../../shared/@ai-setting/roy-agent-core-4jqq077c.js";
9
10
  import"../../shared/@ai-setting/roy-agent-core-2dhd60aw.js";
@@ -3,7 +3,9 @@ import {
3
3
  BackgroundTaskManager,
4
4
  createDelegateTool,
5
5
  createStopTool
6
- } from "../../../shared/@ai-setting/roy-agent-core-v53rfk99.js";
6
+ } from "../../../shared/@ai-setting/roy-agent-core-xz22rmak.js";
7
+ import"../../../shared/@ai-setting/roy-agent-core-7t05apnp.js";
8
+ import"../../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
7
9
  import"../../../shared/@ai-setting/roy-agent-core-92z6t4he.js";
8
10
  import"../../../shared/@ai-setting/roy-agent-core-jqy2mdyq.js";
9
11
  import"../../../shared/@ai-setting/roy-agent-core-z33en0cz.js";
@@ -4,11 +4,13 @@ import {
4
4
  TaskConfigSchema,
5
5
  TaskPriorityEnum,
6
6
  TaskStatusEnum
7
- } from "../../shared/@ai-setting/roy-agent-core-15x8fe5h.js";
8
- import"../../shared/@ai-setting/roy-agent-core-v53rfk99.js";
7
+ } from "../../shared/@ai-setting/roy-agent-core-9q6sa7m3.js";
8
+ import"../../shared/@ai-setting/roy-agent-core-xz22rmak.js";
9
9
  import {
10
10
  SQLiteTaskStore
11
11
  } from "../../shared/@ai-setting/roy-agent-core-hsxn8m1j.js";
12
+ import"../../shared/@ai-setting/roy-agent-core-7t05apnp.js";
13
+ import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
12
14
  import"../../shared/@ai-setting/roy-agent-core-wa1kzqky.js";
13
15
  import"../../shared/@ai-setting/roy-agent-core-t94ktchq.js";
14
16
  import"../../shared/@ai-setting/roy-agent-core-92z6t4he.js";
@@ -8,7 +8,7 @@ import {
8
8
  formatExtractorInput,
9
9
  formatExtractorInputFromDescription,
10
10
  parseExtractorOutput
11
- } from "../../../shared/@ai-setting/roy-agent-core-2x07feb7.js";
11
+ } from "../../../shared/@ai-setting/roy-agent-core-e9fdm13a.js";
12
12
  import"../../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
13
13
  import"../../../shared/@ai-setting/roy-agent-core-92z6t4he.js";
14
14
  import"../../../shared/@ai-setting/roy-agent-core-q5qj0fes.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  WorkflowComponent
3
- } from "../../shared/@ai-setting/roy-agent-core-yc543gnq.js";
3
+ } from "../../shared/@ai-setting/roy-agent-core-bmr6bdfb.js";
4
4
  import"../../shared/@ai-setting/roy-agent-core-0rtxwr28.js";
5
5
  import"../../shared/@ai-setting/roy-agent-core-2jnzv9at.js";
6
6
  import"../../shared/@ai-setting/roy-agent-core-69jskqjg.js";
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  } from "./shared/@ai-setting/roy-agent-core-kajktp3d.js";
13
13
  import {
14
14
  ConfigComponent
15
- } from "./shared/@ai-setting/roy-agent-core-frx4p6d1.js";
15
+ } from "./shared/@ai-setting/roy-agent-core-nj8yerg9.js";
16
16
  import {
17
17
  CommandsComponent
18
18
  } from "./shared/@ai-setting/roy-agent-core-b4wd9tn6.js";
@@ -33,9 +33,13 @@ import {
33
33
  } from "./shared/@ai-setting/roy-agent-core-rsybkb38.js";
34
34
  import {
35
35
  PromptComponent,
36
+ PromptStore,
36
37
  getBuiltInPrompt,
37
38
  getBuiltInPromptNames
38
- } from "./shared/@ai-setting/roy-agent-core-wb43x8hd.js";
39
+ } from "./shared/@ai-setting/roy-agent-core-z1xf2fdk.js";
40
+ import {
41
+ closeDatabase
42
+ } from "./shared/@ai-setting/roy-agent-core-9ffsvvcf.js";
39
43
  import"./shared/@ai-setting/roy-agent-core-2grcjaad.js";
40
44
  import {
41
45
  MemoryComponent
@@ -58,17 +62,12 @@ import {
58
62
  generateDescendingId,
59
63
  generateId
60
64
  } from "./shared/@ai-setting/roy-agent-core-ee6nnnqw.js";
61
- import {
62
- XDG_PATHS,
63
- getXDGPath,
64
- getXDGPaths
65
- } from "./shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
66
65
  import {
67
66
  EventSourceComponent,
68
67
  builtInHandlers,
69
68
  getBuiltInHandler,
70
69
  larkCliHandler
71
- } from "./shared/@ai-setting/roy-agent-core-728h32vx.js";
70
+ } from "./shared/@ai-setting/roy-agent-core-psvwzdhj.js";
72
71
  import {
73
72
  BUILT_IN_EVENT_SOURCE_TYPES,
74
73
  BUILT_IN_EVENT_SOURCE_TYPE_LIST,
@@ -87,13 +86,13 @@ import {
87
86
  } from "./shared/@ai-setting/roy-agent-core-cevpwnq7.js";
88
87
  import {
89
88
  TaskTagPlugin
90
- } from "./shared/@ai-setting/roy-agent-core-2x07feb7.js";
89
+ } from "./shared/@ai-setting/roy-agent-core-e9fdm13a.js";
91
90
  import {
92
91
  BasePlugin
93
92
  } from "./shared/@ai-setting/roy-agent-core-az13yzmc.js";
94
93
  import {
95
94
  WorkflowComponent
96
- } from "./shared/@ai-setting/roy-agent-core-yc543gnq.js";
95
+ } from "./shared/@ai-setting/roy-agent-core-bmr6bdfb.js";
97
96
  import {
98
97
  init_node_registry_helper,
99
98
  registerDecoratorNodeType
@@ -115,16 +114,24 @@ import"./shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
115
114
  import {
116
115
  AgentComponent,
117
116
  AgentComponentConfigSchema
118
- } from "./shared/@ai-setting/roy-agent-core-c8f2hync.js";
117
+ } from "./shared/@ai-setting/roy-agent-core-ek6gk3wk.js";
119
118
  import {
120
119
  AskUserError,
121
120
  init_workflow_hil
122
121
  } from "./shared/@ai-setting/roy-agent-core-e25xkv53.js";
123
122
  import {
124
123
  TaskComponent
125
- } from "./shared/@ai-setting/roy-agent-core-15x8fe5h.js";
126
- import"./shared/@ai-setting/roy-agent-core-v53rfk99.js";
124
+ } from "./shared/@ai-setting/roy-agent-core-9q6sa7m3.js";
125
+ import"./shared/@ai-setting/roy-agent-core-xz22rmak.js";
127
126
  import"./shared/@ai-setting/roy-agent-core-hsxn8m1j.js";
127
+ import {
128
+ AgentRegistry
129
+ } from "./shared/@ai-setting/roy-agent-core-7t05apnp.js";
130
+ import {
131
+ XDG_PATHS,
132
+ getXDGPath,
133
+ getXDGPaths
134
+ } from "./shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
128
135
  import"./shared/@ai-setting/roy-agent-core-wa1kzqky.js";
129
136
  import"./shared/@ai-setting/roy-agent-core-t94ktchq.js";
130
137
  import {
@@ -137,7 +144,7 @@ import {
137
144
  import"./shared/@ai-setting/roy-agent-core-psvxt4c9.js";
138
145
  import {
139
146
  McpComponent
140
- } from "./shared/@ai-setting/roy-agent-core-ycg9rk6z.js";
147
+ } from "./shared/@ai-setting/roy-agent-core-xkb264a8.js";
141
148
  import {
142
149
  AgentError,
143
150
  ComponentError,
@@ -365,6 +372,7 @@ export {
365
372
  createLogger,
366
373
  createInvokeConfig,
367
374
  createHook,
375
+ closeDatabase,
368
376
  builtInHandlers,
369
377
  bashTool,
370
378
  XDG_PATHS,
@@ -392,6 +400,7 @@ export {
392
400
  ReplFormatter,
393
401
  ProviderConfigSchema,
394
402
  ProviderCapabilitiesSchema,
403
+ PromptStore,
395
404
  PromptComponent,
396
405
  PluginComponent,
397
406
  OTelTracerProvider,
@@ -423,6 +432,7 @@ export {
423
432
  BUILT_IN_EVENT_SOURCE_TYPE_LIST,
424
433
  BUILT_IN_EVENT_SOURCE_TYPES,
425
434
  AskUserError,
435
+ AgentRegistry,
426
436
  AgentError,
427
437
  AgentComponentConfigSchema,
428
438
  AgentComponent
@@ -0,0 +1,287 @@
1
+ import {
2
+ getXDGPath
3
+ } from "./roy-agent-core-qxnbvgwe.js";
4
+ import {
5
+ createLogger,
6
+ init_logger
7
+ } from "./roy-agent-core-10n2jh7p.js";
8
+
9
+ // src/env/agent/agent-registry.ts
10
+ import { readdir, readFile, writeFile, mkdir, unlink } from "fs/promises";
11
+ import { existsSync } from "fs";
12
+ import { join } from "path";
13
+ import { z } from "zod";
14
+ import yaml from "yaml";
15
+ init_logger();
16
+ var logger = createLogger("agent:registry");
17
+ var AgentConfigSchema = z.object({
18
+ name: z.string(),
19
+ type: z.enum(["primary", "sub"]),
20
+ description: z.string().optional(),
21
+ systemPromptRef: z.string().optional(),
22
+ systemPrompt: z.string().optional(),
23
+ model: z.string().optional(),
24
+ maxIterations: z.number().optional(),
25
+ maxErrorRetries: z.number().optional(),
26
+ allowedTools: z.array(z.string()).optional(),
27
+ deniedTools: z.array(z.string()).optional(),
28
+ toolTimeout: z.number().optional(),
29
+ toolRetries: z.number().optional(),
30
+ doomLoopThreshold: z.number().optional(),
31
+ filterHistory: z.boolean().optional()
32
+ });
33
+
34
+ class AgentRegistry {
35
+ agents = new Map;
36
+ configDir;
37
+ configComponent;
38
+ promptComponent;
39
+ resolvePromptComponent;
40
+ constructor(options) {
41
+ this.configComponent = options.configComponent;
42
+ this.promptComponent = options.promptComponent ?? null;
43
+ this.resolvePromptComponent = options.resolvePromptComponent;
44
+ const customDir = this.configComponent?.get?.("agent.configDir");
45
+ if (customDir && typeof customDir === "string" && customDir.length > 0) {
46
+ this.configDir = customDir;
47
+ } else if (options.baseDir) {
48
+ this.configDir = join(options.baseDir, "agents");
49
+ } else {
50
+ this.configDir = join(getXDGPath("data"), "agents");
51
+ }
52
+ logger.debug(`[AgentRegistry] Config dir: ${this.configDir}`);
53
+ }
54
+ getConfigDir() {
55
+ return this.configDir;
56
+ }
57
+ hasAgent(name) {
58
+ return this.agents.has(name);
59
+ }
60
+ get(name) {
61
+ return this.agents.get(name);
62
+ }
63
+ list() {
64
+ return Array.from(this.agents.values());
65
+ }
66
+ listAgentsByType(type) {
67
+ return this.list().filter((agent) => agent.type === type);
68
+ }
69
+ register(agent) {
70
+ if (!agent.name) {
71
+ throw new Error("Agent name is required");
72
+ }
73
+ this.agents.set(agent.name, { ...agent });
74
+ logger.info(`[AgentRegistry] Registered agent: ${agent.name}`, { type: agent.type });
75
+ }
76
+ unregister(name) {
77
+ const deleted = this.agents.delete(name);
78
+ if (deleted) {
79
+ logger.info(`[AgentRegistry] Unregistered agent: ${name}`);
80
+ }
81
+ return deleted;
82
+ }
83
+ clear() {
84
+ this.agents.clear();
85
+ logger.info("[AgentRegistry] Cleared all agents");
86
+ }
87
+ async getSystemPrompt(name) {
88
+ const agent = this.agents.get(name);
89
+ if (!agent) {
90
+ return;
91
+ }
92
+ const promptComponent = this.getActivePromptComponent();
93
+ if (agent.systemPromptRef) {
94
+ try {
95
+ const prompt = promptComponent?.get?.(agent.systemPromptRef);
96
+ if (prompt) {
97
+ logger.debug(`[AgentRegistry] Resolved systemPromptRef: ${agent.systemPromptRef}`);
98
+ return prompt;
99
+ }
100
+ if (promptComponent?.getPrompt) {
101
+ const rendered = await promptComponent.getPrompt(agent.systemPromptRef);
102
+ if (rendered) {
103
+ return rendered;
104
+ }
105
+ }
106
+ if (agent.systemPrompt) {
107
+ logger.debug(`[AgentRegistry] systemPromptRef not found, falling back to inline`);
108
+ return agent.systemPrompt;
109
+ }
110
+ return;
111
+ } catch (error) {
112
+ logger.warn(`[AgentRegistry] Failed to resolve systemPromptRef: ${agent.systemPromptRef}`, { error });
113
+ return agent.systemPrompt;
114
+ }
115
+ }
116
+ return agent.systemPrompt;
117
+ }
118
+ getActivePromptComponent() {
119
+ return this.resolvePromptComponent?.() ?? this.promptComponent;
120
+ }
121
+ getInlineSystemPrompt(name) {
122
+ const agent = this.agents.get(name);
123
+ if (!agent) {
124
+ return;
125
+ }
126
+ return agent.systemPrompt;
127
+ }
128
+ async load() {
129
+ try {
130
+ return await this.loadFromDirectory(this.configDir);
131
+ } catch (error) {
132
+ logger.warn(`[AgentRegistry] Failed to load agents: ${error}`);
133
+ return 0;
134
+ }
135
+ }
136
+ async loadFromDirectory(directory) {
137
+ let loaded = 0;
138
+ try {
139
+ if (!existsSync(directory)) {
140
+ logger.debug(`[AgentRegistry] Config directory does not exist: ${directory}`);
141
+ return 0;
142
+ }
143
+ const files = await readdir(directory, { withFileTypes: true });
144
+ for (const file of files) {
145
+ const fullPath = join(directory, file.name);
146
+ if (file.isDirectory()) {
147
+ continue;
148
+ }
149
+ if (!isAgentConfigFile(file.name)) {
150
+ continue;
151
+ }
152
+ try {
153
+ const content = await readFile(fullPath, "utf-8");
154
+ const agent = this.parseAgentConfig(content, fullPath);
155
+ if (agent) {
156
+ this.agents.set(agent.name, agent);
157
+ logger.info(`[AgentRegistry] Loaded agent: ${agent.name} from ${file.name}`);
158
+ loaded++;
159
+ }
160
+ } catch (error) {
161
+ logger.warn(`[AgentRegistry] Failed to load agent from ${file.name}: ${error}`);
162
+ }
163
+ }
164
+ logger.info(`[AgentRegistry] Loaded ${loaded} agents from ${directory}`);
165
+ } catch (error) {
166
+ logger.warn(`[AgentRegistry] Error reading config directory: ${error}`);
167
+ }
168
+ return loaded;
169
+ }
170
+ parseAgentConfig(content, source) {
171
+ try {
172
+ const parsed = yaml.parse(content);
173
+ const result = AgentConfigSchema.safeParse(parsed);
174
+ if (!result.success) {
175
+ logger.warn(`[AgentRegistry] Invalid agent config: ${source}`, {
176
+ errors: result.error.errors
177
+ });
178
+ return null;
179
+ }
180
+ return result.data;
181
+ } catch (error) {
182
+ logger.error(`[AgentRegistry] Failed to parse agent config: ${source}`, { error });
183
+ return null;
184
+ }
185
+ }
186
+ async saveAgent(agent) {
187
+ try {
188
+ await this.ensureConfigDir();
189
+ const yamlContent = this.agentToYaml(agent);
190
+ const filePath = join(this.configDir, `${agent.name}.yaml`);
191
+ await writeFile(filePath, yamlContent, "utf-8");
192
+ this.agents.set(agent.name, agent);
193
+ logger.info(`[AgentRegistry] Saved agent: ${agent.name} to ${filePath}`);
194
+ return true;
195
+ } catch (error) {
196
+ logger.error(`[AgentRegistry] Failed to save agent: ${agent.name}`, { error });
197
+ return false;
198
+ }
199
+ }
200
+ async ensureConfigDir() {
201
+ if (!existsSync(this.configDir)) {
202
+ await mkdir(this.configDir, { recursive: true });
203
+ logger.debug(`[AgentRegistry] Created config directory: ${this.configDir}`);
204
+ }
205
+ }
206
+ agentToYaml(agent) {
207
+ const config = {
208
+ name: agent.name,
209
+ type: agent.type,
210
+ ...agent.description !== undefined ? { description: agent.description } : {},
211
+ ...agent.systemPromptRef !== undefined ? { systemPromptRef: agent.systemPromptRef } : {},
212
+ ...agent.systemPrompt !== undefined ? { systemPrompt: agent.systemPrompt } : {},
213
+ ...agent.model !== undefined ? { model: agent.model } : {},
214
+ ...agent.maxIterations !== undefined ? { maxIterations: agent.maxIterations } : {},
215
+ ...agent.maxErrorRetries !== undefined ? { maxErrorRetries: agent.maxErrorRetries } : {},
216
+ ...agent.allowedTools !== undefined ? { allowedTools: agent.allowedTools } : {},
217
+ ...agent.deniedTools !== undefined ? { deniedTools: agent.deniedTools } : {},
218
+ ...agent.toolTimeout !== undefined ? { toolTimeout: agent.toolTimeout } : {},
219
+ ...agent.toolRetries !== undefined ? { toolRetries: agent.toolRetries } : {},
220
+ ...agent.doomLoopThreshold !== undefined ? { doomLoopThreshold: agent.doomLoopThreshold } : {},
221
+ ...agent.filterHistory !== undefined ? { filterHistory: agent.filterHistory } : {}
222
+ };
223
+ return yaml.stringify(config).trimEnd() + `
224
+ `;
225
+ }
226
+ async deleteAgent(name) {
227
+ const agent = this.agents.get(name);
228
+ if (!agent) {
229
+ logger.warn(`[AgentRegistry] Agent not found: ${name}`);
230
+ return false;
231
+ }
232
+ try {
233
+ const filePath = join(this.configDir, `${name}.yaml`);
234
+ if (existsSync(filePath)) {
235
+ await unlink(filePath);
236
+ logger.info(`[AgentRegistry] Deleted agent file: ${filePath}`);
237
+ }
238
+ this.agents.delete(name);
239
+ return true;
240
+ } catch (error) {
241
+ logger.error(`[AgentRegistry] Failed to delete agent: ${name}`, { error });
242
+ return false;
243
+ }
244
+ }
245
+ exportAgents(options = {}) {
246
+ const agents = this.list();
247
+ if (options.format === "json") {
248
+ return agents;
249
+ }
250
+ return agents;
251
+ }
252
+ exportAgentsAsJson() {
253
+ return JSON.stringify(this.list(), null, 2);
254
+ }
255
+ size() {
256
+ return this.agents.size;
257
+ }
258
+ configDirExists() {
259
+ return existsSync(this.configDir);
260
+ }
261
+ getAgentFilePath(name) {
262
+ return join(this.configDir, `${name}.yaml`);
263
+ }
264
+ }
265
+ function isAgentConfigFile(fileName) {
266
+ return fileName.endsWith(".yaml") || fileName.endsWith(".yml");
267
+ }
268
+ var DEFAULT_SUBAGENT_PROMPT = `You are a subagent created by the main agent to handle a specific task.
269
+
270
+ ## Your Role
271
+ - You were created to handle: {task_description}
272
+ - Complete this task. That's your entire purpose.
273
+ - You are NOT the main agent. Don't try to be.
274
+
275
+ ## Rules
276
+ 1. **Stay focused** - Do your assigned task, nothing else
277
+ 2. **Complete the task** - Your final message will be automatically reported to the main agent
278
+ 3. **Don't initiate** - No heartbeats, no proactive actions, no side quests
279
+ 4. **Be ephemeral** - You may be terminated after task completion. That's fine.
280
+ 5. **No nested delegation** - Do NOT use delegate_task or stop_task tools. Complete the task yourself.
281
+
282
+ ## Execution
283
+ - Use the available tools to complete the task
284
+ - If you need more information, ask the main agent through the result
285
+ - Return a clear summary of what you did and the results`;
286
+
287
+ export { AgentRegistry, DEFAULT_SUBAGENT_PROMPT };
@@ -2,7 +2,7 @@ import {
2
2
  BackgroundTaskManager,
3
3
  createDelegateTool,
4
4
  createStopTool
5
- } from "./roy-agent-core-v53rfk99.js";
5
+ } from "./roy-agent-core-xz22rmak.js";
6
6
  import {
7
7
  SQLiteTaskStore,
8
8
  getDefaultTaskDbPath
@@ -259,6 +259,10 @@ class WorkflowComponent extends BaseComponent {
259
259
  this._status = "stopping";
260
260
  this.workflowService = null;
261
261
  this.nodeRegistry = null;
262
+ try {
263
+ const { closeDatabase } = await import("./roy-agent-core-zwp3jp02.js");
264
+ closeDatabase();
265
+ } catch {}
262
266
  this._status = "stopped";
263
267
  componentLogger.info("WorkflowComponent stopped");
264
268
  }