@ai-setting/roy-agent-core 1.4.12 → 1.4.14

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 (127) hide show
  1. package/dist/packages/core/src/config/index.js +32 -0
  2. package/dist/packages/core/src/env/agent/index.js +24 -0
  3. package/dist/packages/core/src/env/commands/index.js +14 -0
  4. package/dist/packages/core/src/env/debug/formatters/index.js +11 -0
  5. package/dist/packages/core/src/env/debug/index.js +26 -0
  6. package/dist/packages/core/src/env/hook/index.js +29 -0
  7. package/dist/packages/core/src/env/index.js +81 -0
  8. package/dist/packages/core/src/env/llm/index.js +40 -0
  9. package/dist/packages/core/src/env/log-trace/index.js +83 -0
  10. package/dist/packages/core/src/env/mcp/index.js +39 -0
  11. package/dist/packages/core/src/env/mcp/tool/index.js +14 -0
  12. package/dist/packages/core/src/env/memory/built-in/index.js +11 -0
  13. package/dist/packages/core/src/env/memory/index.js +56 -0
  14. package/dist/packages/core/src/env/memory/plugin/index.js +36 -0
  15. package/dist/packages/core/src/env/prompt/index.js +20 -0
  16. package/dist/packages/core/src/env/session/index.js +25 -0
  17. package/dist/packages/core/src/env/session/storage/index.js +18 -0
  18. package/dist/packages/core/src/env/skill/index.js +34 -0
  19. package/dist/packages/core/src/env/skill/tool/index.js +9 -0
  20. package/dist/packages/core/src/env/task/delegate/index.js +18 -0
  21. package/dist/packages/core/src/env/task/hooks/index.js +7 -0
  22. package/dist/packages/core/src/env/task/index.js +30 -0
  23. package/dist/packages/core/src/env/task/plugins/index.js +23 -0
  24. package/dist/packages/core/src/env/task/storage/index.js +14 -0
  25. package/dist/packages/core/src/env/task/tools/index.js +17 -0
  26. package/dist/packages/core/src/env/task/tools/operation/index.js +15 -0
  27. package/dist/packages/core/src/env/tool/built-in/index.js +25 -0
  28. package/dist/packages/core/src/env/tool/index.js +39 -0
  29. package/dist/packages/core/src/env/workflow/decorators/index.js +27 -0
  30. package/dist/packages/core/src/env/workflow/engine/index.js +28 -0
  31. package/dist/packages/core/src/env/workflow/index.js +132 -0
  32. package/dist/packages/core/src/env/workflow/nodes/index.js +19 -0
  33. package/dist/packages/core/src/env/workflow/service/index.js +13 -0
  34. package/dist/packages/core/src/env/workflow/storage/index.js +27 -0
  35. package/dist/packages/core/src/env/workflow/tools/index.js +159 -0
  36. package/dist/packages/core/src/env/workflow/types/index.js +94 -0
  37. package/dist/packages/core/src/env/workflow/utils/index.js +637 -0
  38. package/dist/packages/core/src/index.js +398 -0
  39. package/dist/shared/@ai-setting/roy-agent-core-04fm8177.js +393 -0
  40. package/dist/shared/@ai-setting/roy-agent-core-04qgbjbe.js +172 -0
  41. package/dist/shared/@ai-setting/roy-agent-core-084qqd7t.js +11 -0
  42. package/dist/shared/@ai-setting/roy-agent-core-0gekht4e.js +1130 -0
  43. package/dist/shared/@ai-setting/roy-agent-core-0hdry23r.js +419 -0
  44. package/dist/shared/@ai-setting/roy-agent-core-0sgn3de4.js +102 -0
  45. package/dist/{env/task/tools/index.js → shared/@ai-setting/roy-agent-core-12x57kf1.js} +1 -59
  46. package/dist/shared/@ai-setting/roy-agent-core-1f3xrrm6.js +393 -0
  47. package/dist/shared/@ai-setting/roy-agent-core-1k28kg7h.js +368 -0
  48. package/dist/shared/@ai-setting/roy-agent-core-1z1zv5g8.js +258 -0
  49. package/dist/shared/@ai-setting/roy-agent-core-2hqxnaf3.js +851 -0
  50. package/dist/shared/@ai-setting/roy-agent-core-3dfq8awb.js +587 -0
  51. package/dist/shared/@ai-setting/roy-agent-core-3takar0s.js +93 -0
  52. package/dist/shared/@ai-setting/roy-agent-core-3tnb2005.js +117 -0
  53. package/dist/shared/@ai-setting/roy-agent-core-4vmcvkav.js +14 -0
  54. package/dist/shared/@ai-setting/roy-agent-core-4ws8atva.js +107 -0
  55. package/dist/{env/workflow/nodes/index.js → shared/@ai-setting/roy-agent-core-5fbp24se.js} +8 -55
  56. package/dist/shared/@ai-setting/roy-agent-core-5my94ywp.js +66 -0
  57. package/dist/shared/@ai-setting/roy-agent-core-6j0zcmwk.js +2146 -0
  58. package/dist/shared/@ai-setting/roy-agent-core-6w4pmxc7.js +266 -0
  59. package/dist/shared/@ai-setting/roy-agent-core-7vrk3add.js +10 -0
  60. package/dist/shared/@ai-setting/roy-agent-core-8dvbn7tw.js +64 -0
  61. package/dist/{env/memory/built-in/index.js → shared/@ai-setting/roy-agent-core-8mbmrwzs.js} +22 -76
  62. package/dist/shared/@ai-setting/roy-agent-core-8wzz66qe.js +620 -0
  63. package/dist/shared/@ai-setting/roy-agent-core-9ykq91jc.js +762 -0
  64. package/dist/shared/@ai-setting/roy-agent-core-dde19zke.js +1305 -0
  65. package/dist/shared/@ai-setting/roy-agent-core-f7g67gce.js +913 -0
  66. package/dist/{env/workflow/types/index.js → shared/@ai-setting/roy-agent-core-fq5mtxsy.js} +16 -154
  67. package/dist/{env/task/hooks/index.js → shared/@ai-setting/roy-agent-core-fs0mn2jk.js} +3 -18
  68. package/dist/{config/index.js → shared/@ai-setting/roy-agent-core-fvd9g6k8.js} +140 -605
  69. package/dist/shared/@ai-setting/roy-agent-core-gv1hrn3x.js +378 -0
  70. package/dist/{env/task/tools/operation/index.js → shared/@ai-setting/roy-agent-core-gy0wp5h7.js} +1 -58
  71. package/dist/shared/@ai-setting/roy-agent-core-hyza1gm7.js +15 -0
  72. package/dist/shared/@ai-setting/roy-agent-core-j8zx62zr.js +154 -0
  73. package/dist/shared/@ai-setting/roy-agent-core-jb2exr0d.js +442 -0
  74. package/dist/shared/@ai-setting/roy-agent-core-jv3b7v9w.js +57 -0
  75. package/dist/shared/@ai-setting/roy-agent-core-k1rxf9ya.js +513 -0
  76. package/dist/shared/@ai-setting/roy-agent-core-kydc9nwb.js +60 -0
  77. package/dist/shared/@ai-setting/roy-agent-core-m2x48hw6.js +97 -0
  78. package/dist/shared/@ai-setting/roy-agent-core-m6y668cc.js +377 -0
  79. package/dist/shared/@ai-setting/roy-agent-core-nczzf0ms.js +15 -0
  80. package/dist/shared/@ai-setting/roy-agent-core-nfj6knp5.js +36 -0
  81. package/dist/shared/@ai-setting/roy-agent-core-ntrp979d.js +204 -0
  82. package/dist/shared/@ai-setting/roy-agent-core-pd7g8z5v.js +1387 -0
  83. package/dist/shared/@ai-setting/roy-agent-core-pzk1syce.js +14 -0
  84. package/dist/shared/@ai-setting/roy-agent-core-q50tg9m2.js +862 -0
  85. package/dist/shared/@ai-setting/roy-agent-core-qg9tcaph.js +11 -0
  86. package/dist/shared/@ai-setting/roy-agent-core-qhyerewk.js +20 -0
  87. package/dist/shared/@ai-setting/roy-agent-core-qxybm159.js +82 -0
  88. package/dist/shared/@ai-setting/roy-agent-core-rh9dpkpw.js +549 -0
  89. package/dist/shared/@ai-setting/roy-agent-core-rr9p1g43.js +205 -0
  90. package/dist/{env/workflow/decorators/index.js → shared/@ai-setting/roy-agent-core-sbzvpfn7.js} +8 -173
  91. package/dist/shared/@ai-setting/roy-agent-core-t22nqt4d.js +788 -0
  92. package/dist/shared/@ai-setting/roy-agent-core-tkr5ynkh.js +200 -0
  93. package/dist/shared/@ai-setting/roy-agent-core-v4aabsf0.js +303 -0
  94. package/dist/{env/hook/index.js → shared/@ai-setting/roy-agent-core-w75rafhy.js} +3 -74
  95. package/dist/{env/debug/formatters/index.js → shared/@ai-setting/roy-agent-core-w76hqkmg.js} +11 -66
  96. package/dist/shared/@ai-setting/roy-agent-core-yfbgwes2.js +408 -0
  97. package/dist/shared/@ai-setting/roy-agent-core-yn761yve.js +299 -0
  98. package/dist/shared/@ai-setting/roy-agent-core-yrzmn4m1.js +492 -0
  99. package/dist/{env/workflow/service/index.js → shared/@ai-setting/roy-agent-core-yt8wdh2w.js} +1 -57
  100. package/package.json +3 -2
  101. package/dist/env/agent/index.js +0 -3035
  102. package/dist/env/commands/index.js +0 -1685
  103. package/dist/env/debug/index.js +0 -2300
  104. package/dist/env/index.js +0 -12591
  105. package/dist/env/llm/index.js +0 -2736
  106. package/dist/env/log-trace/index.js +0 -1779
  107. package/dist/env/mcp/index.js +0 -2173
  108. package/dist/env/mcp/tool/index.js +0 -1149
  109. package/dist/env/memory/index.js +0 -2171
  110. package/dist/env/memory/plugin/index.js +0 -1263
  111. package/dist/env/prompt/index.js +0 -2107
  112. package/dist/env/session/index.js +0 -3594
  113. package/dist/env/session/storage/index.js +0 -2049
  114. package/dist/env/skill/index.js +0 -1635
  115. package/dist/env/skill/tool/index.js +0 -114
  116. package/dist/env/task/delegate/index.js +0 -1844
  117. package/dist/env/task/index.js +0 -3578
  118. package/dist/env/task/plugins/index.js +0 -1626
  119. package/dist/env/task/storage/index.js +0 -1464
  120. package/dist/env/tool/built-in/index.js +0 -1151
  121. package/dist/env/tool/index.js +0 -2284
  122. package/dist/env/workflow/engine/index.js +0 -4391
  123. package/dist/env/workflow/index.js +0 -6214
  124. package/dist/env/workflow/storage/index.js +0 -1236
  125. package/dist/env/workflow/tools/index.js +0 -1081
  126. package/dist/env/workflow/utils/index.js +0 -1631
  127. package/dist/index.js +0 -22778
@@ -0,0 +1,393 @@
1
+ import {
2
+ envKeyToConfigKey
3
+ } from "./roy-agent-core-jv3b7v9w.js";
4
+ import {
5
+ BaseComponent
6
+ } from "./roy-agent-core-m2x48hw6.js";
7
+ import {
8
+ createMemoryTools
9
+ } from "./roy-agent-core-8mbmrwzs.js";
10
+ import {
11
+ createLogger,
12
+ init_logger
13
+ } from "./roy-agent-core-yn761yve.js";
14
+
15
+ // packages/core/src/env/memory/types.ts
16
+ import { z } from "zod";
17
+ var RecordMemorySchema = z.object({
18
+ scope: z.enum(["project", "global"]).describe("作用域: project/global"),
19
+ mode: z.enum(["append", "prepend", "overwrite", "delete"]).describe("模式: append(追加)/prepend(插入)/overwrite(覆盖)/delete(删除)"),
20
+ content: z.string().optional().describe("记忆内容"),
21
+ title: z.string().optional().describe("章节标题")
22
+ });
23
+ var RecallMemorySchema = z.object({
24
+ scope: z.enum(["project", "global"]).optional().describe("作用域(可选,不传则读取所有)")
25
+ });
26
+ // packages/core/src/env/memory/memory-config.ts
27
+ import path from "path";
28
+ import os from "os";
29
+ var DEFAULT_MEMORY_CONFIG = {
30
+ memoryPaths: [
31
+ {
32
+ type: "global",
33
+ path: path.join(os.homedir(), ".config", "roy-agent", "memory")
34
+ },
35
+ {
36
+ type: "project",
37
+ path: ".roy/memory"
38
+ }
39
+ ],
40
+ recursive: true,
41
+ cacheEnabled: true,
42
+ cacheTTL: 5 * 60 * 1000
43
+ };
44
+ var SOURCE_PRIORITY = {
45
+ global: 0,
46
+ project: 1
47
+ };
48
+ function getSourcePriority(source) {
49
+ return SOURCE_PRIORITY[source] ?? 0;
50
+ }
51
+ // packages/core/src/env/memory/memory-component.ts
52
+ init_logger();
53
+
54
+ // packages/core/src/env/memory/memory-config-registration.ts
55
+ import path2 from "path";
56
+ import os2 from "os";
57
+ var MEMORY_DEFAULTS = {
58
+ "memory.recursive": true,
59
+ "memory.cacheEnabled": true,
60
+ "memory.cacheTTL": 300000,
61
+ "memory.memoryFile": "memory.md",
62
+ "memory.memoryPaths": [
63
+ { type: "global", path: path2.join(os2.homedir(), ".config", "roy-agent", "memory") },
64
+ { type: "project", path: ".roy/memory" }
65
+ ]
66
+ };
67
+ var MEMORY_CONFIG_REGISTRATION = {
68
+ name: "memory",
69
+ sources: [
70
+ { type: "env", envPrefix: "MEMORY", priority: 20, watch: false }
71
+ ],
72
+ keys: [
73
+ { key: "memory.recursive", sources: ["env", "file"] },
74
+ { key: "memory.cacheEnabled", sources: ["env", "file"] },
75
+ { key: "memory.cacheTTL", sources: ["env", "file"] },
76
+ { key: "memory.memoryPaths", sources: ["env", "file"] },
77
+ { key: "memory.memoryFile", sources: ["env", "file"] }
78
+ ]
79
+ };
80
+
81
+ // packages/core/src/env/memory/memory-component.ts
82
+ import path3 from "path";
83
+ import fs from "fs/promises";
84
+ var logger = createLogger("memory");
85
+
86
+ class MemoryComponent extends BaseComponent {
87
+ name = "memory";
88
+ version = "2.0.0";
89
+ config;
90
+ toolComponent;
91
+ configComponent;
92
+ cache = new Map;
93
+ configWatcher;
94
+ async init(config) {
95
+ await super.init(config);
96
+ const options = config?.options;
97
+ if (!options?.configComponent) {
98
+ throw new Error("ConfigComponent is required for MemoryComponent initialization");
99
+ }
100
+ this.configComponent = options.configComponent;
101
+ await this.registerConfig(options);
102
+ logger.info("[MemoryComponent] Initialized (simplified)");
103
+ }
104
+ async registerConfig(options) {
105
+ const configComponent = this.configComponent;
106
+ if (!configComponent)
107
+ return;
108
+ const { configPath, envPrefix, config } = options;
109
+ const prefix = envPrefix ?? "MEMORY";
110
+ configComponent.registerComponent(MEMORY_CONFIG_REGISTRATION);
111
+ if (configPath) {
112
+ configComponent.registerSource({
113
+ type: "file",
114
+ relativePath: configPath,
115
+ optional: true,
116
+ watch: false
117
+ });
118
+ }
119
+ configComponent.registerSource({
120
+ type: "env",
121
+ envPrefix: prefix,
122
+ priority: 20,
123
+ watch: false
124
+ });
125
+ await configComponent.load("memory");
126
+ for (const envKey of Object.keys(process.env)) {
127
+ const configKey = envKeyToConfigKey(envKey, prefix, "memory");
128
+ if (!configKey)
129
+ continue;
130
+ const value = process.env[envKey];
131
+ if (value !== undefined) {
132
+ await configComponent.set(configKey, value);
133
+ }
134
+ }
135
+ for (const [key, value] of Object.entries(MEMORY_DEFAULTS)) {
136
+ if (configComponent.get(key) === undefined) {
137
+ await configComponent.set(key, value);
138
+ }
139
+ }
140
+ if (config) {
141
+ const flatConfig = this.flattenConfig(config);
142
+ for (const [key, value] of Object.entries(flatConfig)) {
143
+ await configComponent.set(key, value);
144
+ }
145
+ }
146
+ this.registerConfigWatcher(configComponent);
147
+ this.buildConfig(configComponent);
148
+ }
149
+ buildConfig(configComponent) {
150
+ const recursive = configComponent.get("memory.recursive") ?? true;
151
+ const cacheEnabled = configComponent.get("memory.cacheEnabled") ?? true;
152
+ const cacheTTL = configComponent.get("memory.cacheTTL") ?? 300000;
153
+ const memoryFile = configComponent.get("memory.memoryFile") ?? "memory.md";
154
+ const memoryPathsConfig = configComponent.get("memory.memoryPaths");
155
+ let memoryPaths = [];
156
+ if (Array.isArray(memoryPathsConfig)) {
157
+ memoryPaths = memoryPathsConfig;
158
+ } else if (typeof memoryPathsConfig === "string") {
159
+ try {
160
+ memoryPaths = JSON.parse(memoryPathsConfig);
161
+ } catch {
162
+ memoryPaths = DEFAULT_MEMORY_CONFIG.memoryPaths;
163
+ }
164
+ }
165
+ if (memoryPaths.length === 0) {
166
+ memoryPaths = DEFAULT_MEMORY_CONFIG.memoryPaths;
167
+ }
168
+ this.config = {
169
+ memoryPaths,
170
+ recursive,
171
+ cacheEnabled,
172
+ cacheTTL,
173
+ memoryFile
174
+ };
175
+ }
176
+ flattenConfig(obj, prefix = "memory") {
177
+ const result = {};
178
+ for (const [key, value] of Object.entries(obj)) {
179
+ const fullKey = `${prefix}.${key}`;
180
+ if (value && typeof value === "object" && !Array.isArray(value)) {
181
+ Object.assign(result, this.flattenConfig(value, fullKey));
182
+ } else {
183
+ result[fullKey] = value;
184
+ }
185
+ }
186
+ return result;
187
+ }
188
+ registerConfigWatcher(configComponent) {
189
+ if (typeof configComponent.watch !== "function") {
190
+ return;
191
+ }
192
+ this.configWatcher = configComponent.watch("memory.*", (event) => {
193
+ this.onConfigChange(event);
194
+ });
195
+ }
196
+ onConfigChange(event) {
197
+ logger.info(`[MemoryComponent] Config changed: ${event.key}`, {
198
+ oldValue: event.oldValue,
199
+ newValue: event.newValue
200
+ });
201
+ if (this.configComponent) {
202
+ this.buildConfig(this.configComponent);
203
+ }
204
+ this.cache.clear();
205
+ }
206
+ async start() {
207
+ await super.start();
208
+ this.toolComponent = this.env?.getComponent("tool");
209
+ if (!this.toolComponent) {
210
+ logger.warn("[MemoryComponent] ToolComponent not found, skipping tool registration");
211
+ return;
212
+ }
213
+ await this.registerTools();
214
+ this.setStatus("running");
215
+ logger.info(`[MemoryComponent] Started with ${this.toolComponent.getToolCount()} tools`);
216
+ }
217
+ async stop() {
218
+ if (this.configWatcher) {
219
+ this.configWatcher();
220
+ this.configWatcher = undefined;
221
+ }
222
+ if (this.toolComponent) {
223
+ this.toolComponent.unregister("record_memory");
224
+ this.toolComponent.unregister("recall_memory");
225
+ }
226
+ this.cache.clear();
227
+ await super.stop();
228
+ logger.info("[MemoryComponent] Stopped");
229
+ }
230
+ async registerTools() {
231
+ if (!this.toolComponent)
232
+ return;
233
+ const tools = createMemoryTools((args) => this.recordMemory(args), (scope) => this.recallMemory(scope), {
234
+ getMemoryPaths: () => this.getMemoryPaths(),
235
+ getMemoryFile: () => this.getMemoryFile()
236
+ });
237
+ for (const tool of tools) {
238
+ this.toolComponent.register(tool);
239
+ }
240
+ logger.info("[MemoryComponent] Registered memory tools");
241
+ }
242
+ getMemoryPaths() {
243
+ return this.config.memoryPaths;
244
+ }
245
+ updateMemoryPaths(paths) {
246
+ this.config.memoryPaths = paths;
247
+ this.clearCache();
248
+ }
249
+ getMemoryFile() {
250
+ return this.config.memoryFile ?? "memory.md";
251
+ }
252
+ async recordMemory(args) {
253
+ const { mode, content, title, filename, scope } = args;
254
+ const memoryFile = filename ?? this.getMemoryFile();
255
+ const paths = this.config.memoryPaths;
256
+ if (paths.length === 0) {
257
+ return null;
258
+ }
259
+ let basePath;
260
+ if (scope) {
261
+ const targetPath = paths.find((p) => p.type === scope);
262
+ if (!targetPath) {
263
+ logger.warn(`[recordMemory] No ${scope} path configured, using first available path`);
264
+ basePath = paths[0].path;
265
+ } else {
266
+ basePath = targetPath.path;
267
+ }
268
+ } else {
269
+ basePath = paths[0].path;
270
+ }
271
+ const filePath = path3.join(basePath, memoryFile);
272
+ try {
273
+ let existingContent = "";
274
+ let fileExists = false;
275
+ try {
276
+ existingContent = await fs.readFile(filePath, "utf-8");
277
+ fileExists = true;
278
+ } catch {}
279
+ let newContent;
280
+ let action;
281
+ switch (mode) {
282
+ case "delete":
283
+ if (fileExists) {
284
+ await fs.unlink(filePath);
285
+ this.clearCache();
286
+ return { path: filePath, action: "delete" };
287
+ }
288
+ return null;
289
+ case "overwrite":
290
+ if (title && content) {
291
+ newContent = `## ${title}
292
+
293
+ ${content}
294
+ `;
295
+ } else {
296
+ newContent = content ?? "";
297
+ }
298
+ action = fileExists ? "overwrite" : "created";
299
+ break;
300
+ case "append":
301
+ if (!content) {
302
+ throw new Error("content is required for append mode");
303
+ }
304
+ if (title) {
305
+ newContent = existingContent + `
306
+ ## ${title}
307
+
308
+ ${content}
309
+ `;
310
+ } else {
311
+ newContent = existingContent + `
312
+ ${content}
313
+ `;
314
+ }
315
+ action = fileExists ? "append" : "created";
316
+ break;
317
+ case "prepend":
318
+ if (!content) {
319
+ throw new Error("content is required for prepend mode");
320
+ }
321
+ if (title) {
322
+ newContent = `## ${title}
323
+
324
+ ${content}
325
+
326
+ ---
327
+
328
+ ${existingContent}`;
329
+ } else {
330
+ newContent = `${content}
331
+
332
+ ---
333
+
334
+ ${existingContent}`;
335
+ }
336
+ action = fileExists ? "prepend" : "created";
337
+ break;
338
+ default:
339
+ throw new Error(`Unknown mode: ${mode}`);
340
+ }
341
+ await fs.mkdir(basePath, { recursive: true });
342
+ await fs.writeFile(filePath, newContent, "utf-8");
343
+ this.clearCache();
344
+ return { path: filePath, action };
345
+ } catch (error) {
346
+ logger.error(`[recordMemory] Failed: ${error}`);
347
+ throw error;
348
+ }
349
+ }
350
+ async recallMemory(scope) {
351
+ const memoryFile = this.getMemoryFile();
352
+ const paths = this.config.memoryPaths;
353
+ const results = [];
354
+ for (const memoryPath of paths) {
355
+ if (scope && memoryPath.type !== scope) {
356
+ continue;
357
+ }
358
+ const filePath = path3.join(memoryPath.path, memoryFile);
359
+ try {
360
+ const content = await fs.readFile(filePath, "utf-8");
361
+ if (content.trim()) {
362
+ results.push(`## [${memoryPath.type}] ${memoryFile}
363
+ ${content}`);
364
+ }
365
+ } catch {}
366
+ }
367
+ return results.join(`
368
+
369
+ `);
370
+ }
371
+ clearCache() {
372
+ this.cache.clear();
373
+ }
374
+ getCache(key) {
375
+ if (!this.config.cacheEnabled)
376
+ return;
377
+ const entry = this.cache.get(key);
378
+ if (!entry)
379
+ return;
380
+ const age = Date.now() - entry.timestamp;
381
+ if (age > (this.config.cacheTTL ?? 300000)) {
382
+ this.cache.delete(key);
383
+ return;
384
+ }
385
+ return entry.data;
386
+ }
387
+ setCache(key, data) {
388
+ if (!this.config.cacheEnabled)
389
+ return;
390
+ this.cache.set(key, { data, timestamp: Date.now() });
391
+ }
392
+ }
393
+ export { DEFAULT_MEMORY_CONFIG, SOURCE_PRIORITY, getSourcePriority, MemoryComponent };