@causyne/agent 1.20.26 → 1.20.29

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 (41) hide show
  1. package/package.json +1 -1
  2. package/src/agentLoop.js +52 -4
  3. package/src/agentLoop.ts +48 -4
  4. package/src/browser/causyneBrowser.js +1 -1
  5. package/src/browser/causyneBrowser.ts +1 -1
  6. package/src/browser/searchProviders.js +1 -1
  7. package/src/browser/searchProviders.ts +1 -1
  8. package/src/decideTools.js +9 -1
  9. package/src/decideTools.ts +7 -1
  10. package/src/dynamicCatalogue.js +3 -1
  11. package/src/dynamicCatalogue.ts +3 -1
  12. package/src/launchIntent.js +1 -1
  13. package/src/launchIntent.ts +1 -1
  14. package/src/mcp/mcpRegistry.js +6 -2
  15. package/src/mcp/mcpRegistry.ts +5 -2
  16. package/src/memory/actrRanker.js +78 -0
  17. package/src/memory/actrRanker.ts +111 -0
  18. package/src/memory/contextBudget.js +131 -0
  19. package/src/memory/contextBudget.ts +155 -0
  20. package/src/memory/episodicStore.js +652 -0
  21. package/src/memory/episodicStore.ts +788 -0
  22. package/src/memory/episodicTypes.js +8 -0
  23. package/src/memory/episodicTypes.ts +124 -0
  24. package/src/memory/nearDuplicate.js +179 -0
  25. package/src/memory/nearDuplicate.ts +232 -0
  26. package/src/memory/symbolFolder.js +301 -0
  27. package/src/memory/symbolFolder.ts +327 -0
  28. package/src/toolPacks.js +1 -0
  29. package/src/toolPacks.ts +1 -0
  30. package/src/tools/desktopOpen.js +9 -2
  31. package/src/tools/desktopOpen.ts +8 -2
  32. package/src/tools/memoryRecall.js +211 -0
  33. package/src/tools/memoryRecall.ts +251 -0
  34. package/src/tools/nativeEngine.js +16 -2
  35. package/src/tools/nativeEngine.ts +16 -2
  36. package/src/tools/registry.js +2 -1
  37. package/src/tools/subagentOrchestrator.js +3 -2
  38. package/src/tools/toolSelfRepair.js +4 -1
  39. package/src/tools/toolSelfRepair.ts +4 -1
  40. package/src/toolsList.js +1 -0
  41. package/src/toolsList.ts +1 -0
@@ -0,0 +1,211 @@
1
+ /**
2
+ * @file src/tools/memoryRecall.ts
3
+ * `memory_recall` — 3-Layer Progressive Episodic Memory Disclosure & Structural Symbol Folding Tool.
4
+ *
5
+ * Implements the token-efficient 3-layer retrieval workflow:
6
+ * 1. `search` — Layer 1 compact index (~50 tokens/row) ranked by query match + ACT-R activation.
7
+ * 2. `timeline` — Layer 2 chronological window (`depthBefore`, `depthAfter`) around an `anchorId`.
8
+ * 3. `get` — Layer 3 full observation details (`narrative`, `facts`, `filesModified`) for `ids`, capped at 64 KB.
9
+ * 4. `outline` — Folded structural symbol outline (`[lineStart-lineEnd]`) of a source file before targeted `fs_read`.
10
+ * 5. `stats` — Episodic memory store telemetry and archive bridge status.
11
+ *
12
+ * Authorship: Strict TypeScript (Causyne Agent).
13
+ */
14
+ import os from 'node:os';
15
+ import path from 'node:path';
16
+ import { episodicStore } from '../memory/episodicStore.js';
17
+ import { foldSourceFileOutline } from '../memory/symbolFolder.js';
18
+ export const memoryRecall = {
19
+ schema: {
20
+ name: 'memory_recall',
21
+ description: 'Progressive 3-layer episodic memory recall and structural file symbol folding. ' +
22
+ 'Follow the 3-layer workflow to save tokens: (1) action="search" to get compact index IDs (#1, #2), ' +
23
+ '(2) action="timeline" with anchorId to see chronological context around an ID, ' +
24
+ '(3) action="get" with ids=[...] to fetch full narratives only for relevant observations, ' +
25
+ 'or (4) action="outline" with filePath to get a folded symbol signature outline with [lineStart-lineEnd] ranges.',
26
+ parameters: {
27
+ type: 'object',
28
+ properties: {
29
+ action: {
30
+ type: 'string',
31
+ enum: ['search', 'timeline', 'get', 'outline', 'stats'],
32
+ description: 'Progressive recall layer: search (index), timeline (window), get (full details), outline (symbol folding), or stats.'
33
+ },
34
+ query: {
35
+ type: 'string',
36
+ description: 'Search keywords for action="search", or symbol filter for action="outline".'
37
+ },
38
+ type: {
39
+ type: 'string',
40
+ enum: ['decision', 'bugfix', 'feature', 'refactor', 'discovery', 'verification', 'summary'],
41
+ description: 'Optional observation category filter for action="search".'
42
+ },
43
+ limit: {
44
+ type: 'number',
45
+ description: 'Maximum index rows to return for action="search" (default: 15, max: 50).'
46
+ },
47
+ workspaceOnly: {
48
+ type: 'boolean',
49
+ description: 'Restrict search to the current workspace project (default: false).'
50
+ },
51
+ anchorId: {
52
+ type: 'string',
53
+ description: 'Target observation ID (e.g. "#12" or "12") for action="timeline".'
54
+ },
55
+ depthBefore: {
56
+ type: 'number',
57
+ description: 'Observations before anchorId in action="timeline" (default: 5).'
58
+ },
59
+ depthAfter: {
60
+ type: 'number',
61
+ description: 'Observations after anchorId in action="timeline" (default: 5).'
62
+ },
63
+ ids: {
64
+ type: 'array',
65
+ items: { type: 'string' },
66
+ description: 'Observation IDs to fetch in full for action="get" (e.g. ["#12", "#15"]).'
67
+ },
68
+ filePath: {
69
+ type: 'string',
70
+ description: 'Source file path to fold into symbol signatures and [lineStart-lineEnd] ranges for action="outline".'
71
+ }
72
+ },
73
+ required: ['action']
74
+ }
75
+ },
76
+ async execute(rawArgs, context = {}) {
77
+ const args = (rawArgs && typeof rawArgs === 'object' && !Array.isArray(rawArgs)
78
+ ? rawArgs
79
+ : {});
80
+ const rawFileCandidate = String(args.filePath ?? args.path ?? args.file_path ?? args.filepath ?? args.target ?? '').trim();
81
+ const inferredAction = args.action
82
+ ?? (rawFileCandidate ? 'outline' : undefined)
83
+ ?? (args.anchorId !== undefined ? 'timeline' : undefined)
84
+ ?? (Array.isArray(args.ids) && args.ids.length > 0 ? 'get' : undefined)
85
+ ?? 'search';
86
+ const action = inferredAction;
87
+ const workspace = context.parentLoop?.workspaceRoot ?? context.workspaceRoot ?? process.cwd();
88
+ try {
89
+ if (action === 'search') {
90
+ const res = episodicStore.searchIndex({
91
+ query: args.query,
92
+ workspace,
93
+ type: args.type,
94
+ limit: args.limit,
95
+ workspaceOnly: args.workspaceOnly
96
+ });
97
+ const formatted = res.results.length === 0
98
+ ? 'No matching episodic observations found.'
99
+ : [
100
+ `Found ${res.totalMatches} match(es) (showing ${res.results.length}):`,
101
+ ...res.results.map((r) => `${r.id} [${r.type}] (${r.project}) ${r.title}${r.reinforcementCount > 0 ? ` [x${r.reinforcementCount + 1}]` : ''} — score ${r.score}`),
102
+ 'Next step: call memory_recall with action="timeline" (anchorId) or action="get" (ids) for full details.'
103
+ ].join('\n');
104
+ return {
105
+ success: true,
106
+ action: 'search',
107
+ totalMatches: res.totalMatches,
108
+ results: res.results,
109
+ output: formatted
110
+ };
111
+ }
112
+ if (action === 'timeline') {
113
+ if (args.anchorId === undefined || String(args.anchorId).trim() === '') {
114
+ return { success: false, error: 'Missing required parameter "anchorId" for action="timeline".' };
115
+ }
116
+ const windowResult = episodicStore.getTimelineWindow({
117
+ anchorId: args.anchorId,
118
+ workspace,
119
+ depthBefore: args.depthBefore,
120
+ depthAfter: args.depthAfter
121
+ });
122
+ if (!windowResult.anchor) {
123
+ return {
124
+ success: false,
125
+ error: `Observation ${String(args.anchorId)} was not found in episodic memory.`
126
+ };
127
+ }
128
+ const allItems = [
129
+ ...windowResult.before,
130
+ windowResult.anchor,
131
+ ...windowResult.after
132
+ ];
133
+ const lines = allItems.map((item) => {
134
+ const marker = item.isAnchor ? '>>> ' : ' ';
135
+ const files = item.filesModified.length > 0 ? ` (${item.filesModified.join(', ')})` : '';
136
+ return `${marker}${item.id} [${item.type}] ${item.title}${files}`;
137
+ });
138
+ return {
139
+ success: true,
140
+ action: 'timeline',
141
+ window: windowResult,
142
+ output: [`Timeline around ${windowResult.anchorId} (${windowResult.project}):`, ...lines].join('\n')
143
+ };
144
+ }
145
+ if (action === 'get') {
146
+ const ids = Array.isArray(args.ids) ? args.ids : [];
147
+ if (ids.length === 0) {
148
+ return { success: false, error: 'Missing required non-empty "ids" array for action="get".' };
149
+ }
150
+ const batch = episodicStore.getObservationsByIds(ids);
151
+ const lines = batch.observations.map((obs) => [
152
+ `### #${obs.id} [${obs.type}] ${obs.title} (${obs.project})`,
153
+ `Tool: ${obs.toolName} | Reinforcements: ${obs.reinforcementCount}`,
154
+ obs.filesModified.length > 0 ? `Files Modified: ${obs.filesModified.join(', ')}` : '',
155
+ obs.filesRead.length > 0 ? `Files Read: ${obs.filesRead.join(', ')}` : '',
156
+ `Narrative: ${obs.narrative}`,
157
+ obs.facts.length > 0 ? `Facts: ${obs.facts.join(' | ')}` : ''
158
+ ].filter(Boolean).join('\n'));
159
+ if (batch.truncatedByByteLimit) {
160
+ lines.push(`[Truncated at 64 KB ceiling; omitted IDs: ${batch.omittedIds.join(', ')}]`);
161
+ }
162
+ return {
163
+ success: true,
164
+ action: 'get',
165
+ observations: batch.observations,
166
+ truncatedByByteLimit: batch.truncatedByByteLimit,
167
+ omittedIds: batch.omittedIds,
168
+ totalBytes: batch.totalBytes,
169
+ output: lines.join('\n\n') || 'No matching observations found for the requested IDs.'
170
+ };
171
+ }
172
+ if (action === 'outline') {
173
+ if (!rawFileCandidate) {
174
+ return { success: false, error: 'Missing required parameter "filePath" for action="outline".' };
175
+ }
176
+ const expanded = rawFileCandidate.startsWith('~/')
177
+ ? path.join(os.homedir(), rawFileCandidate.slice(2))
178
+ : rawFileCandidate;
179
+ const targetPath = path.isAbsolute(expanded)
180
+ ? expanded
181
+ : path.resolve(workspace, expanded);
182
+ const outline = foldSourceFileOutline(targetPath, args.query);
183
+ return {
184
+ success: true,
185
+ action: 'outline',
186
+ filePath: outline.filePath,
187
+ language: outline.language,
188
+ totalLines: outline.totalLines,
189
+ symbolCount: outline.symbols.length,
190
+ output: outline.renderedOutline
191
+ };
192
+ }
193
+ if (action === 'stats') {
194
+ const stats = episodicStore.getStats(workspace);
195
+ return {
196
+ success: true,
197
+ action: 'stats',
198
+ stats,
199
+ output: `Causyne Episodic Store: ${stats.totalObservations} total observations (${stats.projectObservations} in current project), ${stats.totalSummaries} session summaries. Archive bridge: ${stats.externalStoreAvailable ? 'active' : 'standby'}.`
200
+ };
201
+ }
202
+ return { success: false, error: `Unsupported action "${String(action)}".` };
203
+ }
204
+ catch (error) {
205
+ return {
206
+ success: false,
207
+ error: error instanceof Error ? error.message : String(error)
208
+ };
209
+ }
210
+ }
211
+ };
@@ -0,0 +1,251 @@
1
+ /**
2
+ * @file src/tools/memoryRecall.ts
3
+ * `memory_recall` — 3-Layer Progressive Episodic Memory Disclosure & Structural Symbol Folding Tool.
4
+ *
5
+ * Implements the token-efficient 3-layer retrieval workflow:
6
+ * 1. `search` — Layer 1 compact index (~50 tokens/row) ranked by query match + ACT-R activation.
7
+ * 2. `timeline` — Layer 2 chronological window (`depthBefore`, `depthAfter`) around an `anchorId`.
8
+ * 3. `get` — Layer 3 full observation details (`narrative`, `facts`, `filesModified`) for `ids`, capped at 64 KB.
9
+ * 4. `outline` — Folded structural symbol outline (`[lineStart-lineEnd]`) of a source file before targeted `fs_read`.
10
+ * 5. `stats` — Episodic memory store telemetry and archive bridge status.
11
+ *
12
+ * Authorship: Strict TypeScript (Causyne Agent).
13
+ */
14
+
15
+ import os from 'node:os';
16
+ import path from 'node:path';
17
+ import { episodicStore } from '../memory/episodicStore.js';
18
+ import { foldSourceFileOutline } from '../memory/symbolFolder.js';
19
+ import type { ObservationType } from '../memory/episodicTypes.js';
20
+
21
+ interface MemoryRecallContext {
22
+ workspaceRoot?: string | undefined;
23
+ parentLoop?: {
24
+ workspaceRoot?: string | undefined;
25
+ } | undefined;
26
+ }
27
+
28
+ interface MemoryRecallArgs {
29
+ action?: 'search' | 'timeline' | 'get' | 'outline' | 'stats' | undefined;
30
+ query?: string | undefined;
31
+ type?: ObservationType | 'summary' | undefined;
32
+ limit?: number | undefined;
33
+ workspaceOnly?: boolean | undefined;
34
+ anchorId?: string | number | undefined;
35
+ depthBefore?: number | undefined;
36
+ depthAfter?: number | undefined;
37
+ ids?: readonly (string | number)[] | undefined;
38
+ filePath?: string | undefined;
39
+ path?: string | undefined;
40
+ file_path?: string | undefined;
41
+ filepath?: string | undefined;
42
+ target?: string | undefined;
43
+ }
44
+
45
+ export const memoryRecall = {
46
+ schema: {
47
+ name: 'memory_recall',
48
+ description:
49
+ 'Progressive 3-layer episodic memory recall and structural file symbol folding. ' +
50
+ 'Follow the 3-layer workflow to save tokens: (1) action="search" to get compact index IDs (#1, #2), ' +
51
+ '(2) action="timeline" with anchorId to see chronological context around an ID, ' +
52
+ '(3) action="get" with ids=[...] to fetch full narratives only for relevant observations, ' +
53
+ 'or (4) action="outline" with filePath to get a folded symbol signature outline with [lineStart-lineEnd] ranges.',
54
+ parameters: {
55
+ type: 'object',
56
+ properties: {
57
+ action: {
58
+ type: 'string',
59
+ enum: ['search', 'timeline', 'get', 'outline', 'stats'],
60
+ description: 'Progressive recall layer: search (index), timeline (window), get (full details), outline (symbol folding), or stats.'
61
+ },
62
+ query: {
63
+ type: 'string',
64
+ description: 'Search keywords for action="search", or symbol filter for action="outline".'
65
+ },
66
+ type: {
67
+ type: 'string',
68
+ enum: ['decision', 'bugfix', 'feature', 'refactor', 'discovery', 'verification', 'summary'],
69
+ description: 'Optional observation category filter for action="search".'
70
+ },
71
+ limit: {
72
+ type: 'number',
73
+ description: 'Maximum index rows to return for action="search" (default: 15, max: 50).'
74
+ },
75
+ workspaceOnly: {
76
+ type: 'boolean',
77
+ description: 'Restrict search to the current workspace project (default: false).'
78
+ },
79
+ anchorId: {
80
+ type: 'string',
81
+ description: 'Target observation ID (e.g. "#12" or "12") for action="timeline".'
82
+ },
83
+ depthBefore: {
84
+ type: 'number',
85
+ description: 'Observations before anchorId in action="timeline" (default: 5).'
86
+ },
87
+ depthAfter: {
88
+ type: 'number',
89
+ description: 'Observations after anchorId in action="timeline" (default: 5).'
90
+ },
91
+ ids: {
92
+ type: 'array',
93
+ items: { type: 'string' },
94
+ description: 'Observation IDs to fetch in full for action="get" (e.g. ["#12", "#15"]).'
95
+ },
96
+ filePath: {
97
+ type: 'string',
98
+ description: 'Source file path to fold into symbol signatures and [lineStart-lineEnd] ranges for action="outline".'
99
+ }
100
+ },
101
+ required: ['action']
102
+ }
103
+ },
104
+
105
+ async execute(rawArgs: unknown, context: MemoryRecallContext = {}) {
106
+ const args = (rawArgs && typeof rawArgs === 'object' && !Array.isArray(rawArgs)
107
+ ? rawArgs
108
+ : {}) as MemoryRecallArgs;
109
+ const rawFileCandidate = String(
110
+ args.filePath ?? args.path ?? args.file_path ?? args.filepath ?? args.target ?? ''
111
+ ).trim();
112
+ const inferredAction = args.action
113
+ ?? (rawFileCandidate ? 'outline' : undefined)
114
+ ?? (args.anchorId !== undefined ? 'timeline' : undefined)
115
+ ?? (Array.isArray(args.ids) && args.ids.length > 0 ? 'get' : undefined)
116
+ ?? 'search';
117
+ const action = inferredAction;
118
+ const workspace = context.parentLoop?.workspaceRoot ?? context.workspaceRoot ?? process.cwd();
119
+
120
+ try {
121
+ if (action === 'search') {
122
+ const res = episodicStore.searchIndex({
123
+ query: args.query,
124
+ workspace,
125
+ type: args.type,
126
+ limit: args.limit,
127
+ workspaceOnly: args.workspaceOnly
128
+ });
129
+ const formatted = res.results.length === 0
130
+ ? 'No matching episodic observations found.'
131
+ : [
132
+ `Found ${res.totalMatches} match(es) (showing ${res.results.length}):`,
133
+ ...res.results.map(
134
+ (r) => `${r.id} [${r.type}] (${r.project}) ${r.title}${r.reinforcementCount > 0 ? ` [x${r.reinforcementCount + 1}]` : ''} — score ${r.score}`
135
+ ),
136
+ 'Next step: call memory_recall with action="timeline" (anchorId) or action="get" (ids) for full details.'
137
+ ].join('\n');
138
+ return {
139
+ success: true,
140
+ action: 'search',
141
+ totalMatches: res.totalMatches,
142
+ results: res.results,
143
+ output: formatted
144
+ };
145
+ }
146
+
147
+ if (action === 'timeline') {
148
+ if (args.anchorId === undefined || String(args.anchorId).trim() === '') {
149
+ return { success: false, error: 'Missing required parameter "anchorId" for action="timeline".' };
150
+ }
151
+ const windowResult = episodicStore.getTimelineWindow({
152
+ anchorId: args.anchorId,
153
+ workspace,
154
+ depthBefore: args.depthBefore,
155
+ depthAfter: args.depthAfter
156
+ });
157
+ if (!windowResult.anchor) {
158
+ return {
159
+ success: false,
160
+ error: `Observation ${String(args.anchorId)} was not found in episodic memory.`
161
+ };
162
+ }
163
+ const allItems = [
164
+ ...windowResult.before,
165
+ windowResult.anchor,
166
+ ...windowResult.after
167
+ ];
168
+ const lines = allItems.map((item) => {
169
+ const marker = item.isAnchor ? '>>> ' : ' ';
170
+ const files = item.filesModified.length > 0 ? ` (${item.filesModified.join(', ')})` : '';
171
+ return `${marker}${item.id} [${item.type}] ${item.title}${files}`;
172
+ });
173
+ return {
174
+ success: true,
175
+ action: 'timeline',
176
+ window: windowResult,
177
+ output: [`Timeline around ${windowResult.anchorId} (${windowResult.project}):`, ...lines].join('\n')
178
+ };
179
+ }
180
+
181
+ if (action === 'get') {
182
+ const ids = Array.isArray(args.ids) ? args.ids : [];
183
+ if (ids.length === 0) {
184
+ return { success: false, error: 'Missing required non-empty "ids" array for action="get".' };
185
+ }
186
+ const batch = episodicStore.getObservationsByIds(ids);
187
+ const lines = batch.observations.map((obs) => [
188
+ `### #${obs.id} [${obs.type}] ${obs.title} (${obs.project})`,
189
+ `Tool: ${obs.toolName} | Reinforcements: ${obs.reinforcementCount}`,
190
+ obs.filesModified.length > 0 ? `Files Modified: ${obs.filesModified.join(', ')}` : '',
191
+ obs.filesRead.length > 0 ? `Files Read: ${obs.filesRead.join(', ')}` : '',
192
+ `Narrative: ${obs.narrative}`,
193
+ obs.facts.length > 0 ? `Facts: ${obs.facts.join(' | ')}` : ''
194
+ ].filter(Boolean).join('\n'));
195
+
196
+ if (batch.truncatedByByteLimit) {
197
+ lines.push(`[Truncated at 64 KB ceiling; omitted IDs: ${batch.omittedIds.join(', ')}]`);
198
+ }
199
+
200
+ return {
201
+ success: true,
202
+ action: 'get',
203
+ observations: batch.observations,
204
+ truncatedByByteLimit: batch.truncatedByByteLimit,
205
+ omittedIds: batch.omittedIds,
206
+ totalBytes: batch.totalBytes,
207
+ output: lines.join('\n\n') || 'No matching observations found for the requested IDs.'
208
+ };
209
+ }
210
+
211
+ if (action === 'outline') {
212
+ if (!rawFileCandidate) {
213
+ return { success: false, error: 'Missing required parameter "filePath" for action="outline".' };
214
+ }
215
+ const expanded = rawFileCandidate.startsWith('~/')
216
+ ? path.join(os.homedir(), rawFileCandidate.slice(2))
217
+ : rawFileCandidate;
218
+ const targetPath = path.isAbsolute(expanded)
219
+ ? expanded
220
+ : path.resolve(workspace, expanded);
221
+ const outline = foldSourceFileOutline(targetPath, args.query);
222
+ return {
223
+ success: true,
224
+ action: 'outline',
225
+ filePath: outline.filePath,
226
+ language: outline.language,
227
+ totalLines: outline.totalLines,
228
+ symbolCount: outline.symbols.length,
229
+ output: outline.renderedOutline
230
+ };
231
+ }
232
+
233
+ if (action === 'stats') {
234
+ const stats = episodicStore.getStats(workspace);
235
+ return {
236
+ success: true,
237
+ action: 'stats',
238
+ stats,
239
+ output: `Causyne Episodic Store: ${stats.totalObservations} total observations (${stats.projectObservations} in current project), ${stats.totalSummaries} session summaries. Archive bridge: ${stats.externalStoreAvailable ? 'active' : 'standby'}.`
240
+ };
241
+ }
242
+
243
+ return { success: false, error: `Unsupported action "${String(action)}".` };
244
+ } catch (error) {
245
+ return {
246
+ success: false,
247
+ error: error instanceof Error ? error.message : String(error)
248
+ };
249
+ }
250
+ }
251
+ };
@@ -294,8 +294,22 @@ function parseOutput(action, stdout) {
294
294
  }
295
295
  function reveal(file) {
296
296
  return new Promise(resolve => {
297
- const command = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd.exe' : 'xdg-open';
298
- const args = process.platform === 'win32' ? ['/c', 'start', '', file] : [file];
297
+ const resolvedPath = path.resolve(file);
298
+ let command;
299
+ let args;
300
+ if (process.platform === 'darwin') {
301
+ command = '/usr/bin/open';
302
+ args = [resolvedPath];
303
+ }
304
+ else if (process.platform === 'win32') {
305
+ const sysRoot = process.env.SYSTEMROOT || process.env.windir || 'C:\\Windows';
306
+ command = path.join(sysRoot, 'explorer.exe');
307
+ args = [resolvedPath];
308
+ }
309
+ else {
310
+ command = 'xdg-open';
311
+ args = [resolvedPath];
312
+ }
299
313
  const child = spawn(command, args, { detached: true, stdio: 'ignore', windowsHide: true });
300
314
  child.once('error', () => resolve(false));
301
315
  child.once('spawn', () => {
@@ -273,8 +273,22 @@ function parseOutput(action: NativeEngineAction, stdout: string): { data?: unkno
273
273
 
274
274
  function reveal(file: string): Promise<boolean> {
275
275
  return new Promise(resolve => {
276
- const command = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd.exe' : 'xdg-open';
277
- const args = process.platform === 'win32' ? ['/c', 'start', '', file] : [file];
276
+ const resolvedPath = path.resolve(file);
277
+ let command: string;
278
+ let args: string[];
279
+
280
+ if (process.platform === 'darwin') {
281
+ command = '/usr/bin/open';
282
+ args = [resolvedPath];
283
+ } else if (process.platform === 'win32') {
284
+ const sysRoot = process.env.SYSTEMROOT || process.env.windir || 'C:\\Windows';
285
+ command = path.join(sysRoot, 'explorer.exe');
286
+ args = [resolvedPath];
287
+ } else {
288
+ command = 'xdg-open';
289
+ args = [resolvedPath];
290
+ }
291
+
278
292
  const child = spawn(command, args, { detached: true, stdio: 'ignore', windowsHide: true });
279
293
  child.once('error', () => resolve(false));
280
294
  child.once('spawn', () => {
@@ -40,6 +40,7 @@ import { executeProceduralMedia } from './executeProceduralMedia.js';
40
40
  import { manageLocalAiDependencies } from './manageLocalAiDependencies.js';
41
41
  import { generateMediaViaApi } from './generateMediaViaApi.js';
42
42
  import { memoryWrite } from './memoryWrite.js';
43
+ import { memoryRecall } from './memoryRecall.js';
43
44
  import { printerPrint, printerList, printerStatus } from './printer.js';
44
45
  import { toolForgeTool } from './toolForge.js';
45
46
  import { pluginManagerTool } from './pluginManager.js';
@@ -119,7 +120,7 @@ const TOOL_MODULES = [
119
120
  codebaseSearch, browserAct, viewImage, webSearch,
120
121
  updatePlan, requestDecision, clipboard, screenshot, axSnapshot, desktopAct, archive,
121
122
  checkSystemSpecs, executeProceduralMedia, manageLocalAiDependencies,
122
- generateMediaViaApi, memoryWrite, printerPrint, printerList, printerStatus, toolForgeTool, pluginManagerTool,
123
+ generateMediaViaApi, memoryWrite, memoryRecall, printerPrint, printerList, printerStatus, toolForgeTool, pluginManagerTool,
123
124
  astryxOracle, pdfRead, codeVerifySyntax, codeListSymbols, blenderAct, resolveAutomator, palmierAutomator,
124
125
  codeSearchAst, codeSearcher, persistentShell, subagentOrchestrator, deferredMcpSearch, visionInspector,
125
126
  godotAutomator, gameBuilder, gameAssetFetcher,
@@ -1,3 +1,4 @@
1
+ import crypto from 'node:crypto';
1
2
  import { TokenTracker } from '../tokenTracker.js';
2
3
  import { listAgentProfiles, loadAgentProfile } from '../agentProfiles.js';
3
4
  import {
@@ -241,8 +242,8 @@ export const subagentOrchestrator = {
241
242
  };
242
243
  }
243
244
 
244
- const name = args.name || profile?.name || `Worker_${Math.random().toString(36).slice(2, 7)}`;
245
- const subagentId = `sub_${Date.now()}_${Math.random().toString(36).slice(2, 6)}`;
245
+ const name = args.name || profile?.name || `Worker_${crypto.randomBytes(3).toString('hex')}`;
246
+ const subagentId = `sub_${Date.now()}_${crypto.randomBytes(3).toString('hex')}`;
246
247
  let requestedScope = Array.isArray(args.toolScope) && args.toolScope.length > 0
247
248
  ? args.toolScope
248
249
  : profile?.toolScope || DEFAULT_TOOL_SCOPE;
@@ -382,7 +382,10 @@ function sanitizeUnescapedStringLiterals(input) {
382
382
  */
383
383
  function convertSingleQuotesToJson(input) {
384
384
  return input.replace(/'([^'\\]*(?:\\.[^'\\]*)*)'/g, (_match, inner) => {
385
- const escaped = inner.replace(/"/g, '\\"');
385
+ const escaped = inner
386
+ .replace(/\\'/g, "'")
387
+ .replace(/\\/g, '\\\\')
388
+ .replace(/"/g, '\\"');
386
389
  return `"${escaped}"`;
387
390
  });
388
391
  }
@@ -436,7 +436,10 @@ function sanitizeUnescapedStringLiterals(input: string): string {
436
436
  */
437
437
  function convertSingleQuotesToJson(input: string): string {
438
438
  return input.replace(/'([^'\\]*(?:\\.[^'\\]*)*)'/g, (_match, inner) => {
439
- const escaped = (inner as string).replace(/"/g, '\\"');
439
+ const escaped = (inner as string)
440
+ .replace(/\\'/g, "'")
441
+ .replace(/\\/g, '\\\\')
442
+ .replace(/"/g, '\\"');
440
443
  return `"${escaped}"`;
441
444
  });
442
445
  }
package/src/toolsList.js CHANGED
@@ -42,6 +42,7 @@ const CATALOGUE = {
42
42
  update_plan: 'visible checklist, one active step',
43
43
  request_decision: 'ask the user to pick a direction',
44
44
  memory_write: 'save durable user fact or design pattern',
45
+ memory_recall: 'progressive 3-layer memory search, timeline, and file symbol outline',
45
46
  fs_read_skill: 'read a bundled skill by id',
46
47
  skill_create: 'save a reusable skill',
47
48
  tool_search: 'find and load any tool on this list'
package/src/toolsList.ts CHANGED
@@ -56,6 +56,7 @@ const CATALOGUE: Readonly<Record<Exclude<ToolGroup, 'custom'>, Readonly<Record<s
56
56
  update_plan: 'visible checklist, one active step',
57
57
  request_decision: 'ask the user to pick a direction',
58
58
  memory_write: 'save durable user fact or design pattern',
59
+ memory_recall: 'progressive 3-layer memory search, timeline, and file symbol outline',
59
60
  fs_read_skill: 'read a bundled skill by id',
60
61
  skill_create: 'save a reusable skill',
61
62
  tool_search: 'find and load any tool on this list'