tuna-agent 0.1.48 → 0.1.50
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.
- package/dist/mcp/setup.js +24 -8
- package/package.json +1 -1
package/dist/mcp/setup.js
CHANGED
|
@@ -237,7 +237,7 @@ export async function callMem0Patterns(agentName, minCluster = 3) {
|
|
|
237
237
|
* Returns a concise lesson learned, or empty string on failure.
|
|
238
238
|
*/
|
|
239
239
|
export async function callMem0Reflect(taskDesc, resultSummary, status) {
|
|
240
|
-
const {
|
|
240
|
+
const { execSync } = await import('child_process');
|
|
241
241
|
// Resolve claude binary path (same search logic as claude-cli.ts)
|
|
242
242
|
let claudeBin = 'claude';
|
|
243
243
|
try {
|
|
@@ -273,10 +273,23 @@ export async function callMem0Reflect(taskDesc, resultSummary, status) {
|
|
|
273
273
|
'',
|
|
274
274
|
'Lessons learned:',
|
|
275
275
|
].join('\n');
|
|
276
|
+
// Use spawn with stdin='ignore' — execFile keeps stdin pipe open which causes claude to hang/SIGTERM
|
|
277
|
+
const { spawn } = await import('child_process');
|
|
276
278
|
return new Promise((resolve) => {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
279
|
+
const child = spawn(claudeBin, ['-p', prompt, '--output-format', 'text'], { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
280
|
+
let stdout = '';
|
|
281
|
+
let stderr = '';
|
|
282
|
+
child.stdout.on('data', (d) => { stdout += d.toString(); });
|
|
283
|
+
child.stderr.on('data', (d) => { stderr += d.toString(); });
|
|
284
|
+
const timer = setTimeout(() => {
|
|
285
|
+
child.kill();
|
|
286
|
+
console.warn('[Mem0 Reflect] Claude CLI timed out after 60s');
|
|
287
|
+
resolve('');
|
|
288
|
+
}, 60000);
|
|
289
|
+
child.on('close', (code) => {
|
|
290
|
+
clearTimeout(timer);
|
|
291
|
+
if (code !== 0) {
|
|
292
|
+
console.warn(`[Mem0 Reflect] Claude CLI exited ${code}: ${stderr.substring(0, 200)}`);
|
|
280
293
|
resolve('');
|
|
281
294
|
return;
|
|
282
295
|
}
|
|
@@ -288,6 +301,11 @@ export async function callMem0Reflect(taskDesc, resultSummary, status) {
|
|
|
288
301
|
console.log(`[Mem0 Reflect] Generated: "${reflection.substring(0, 100)}..."`);
|
|
289
302
|
resolve(reflection);
|
|
290
303
|
});
|
|
304
|
+
child.on('error', (err) => {
|
|
305
|
+
clearTimeout(timer);
|
|
306
|
+
console.warn(`[Mem0 Reflect] Spawn error: ${err.message}`);
|
|
307
|
+
resolve('');
|
|
308
|
+
});
|
|
291
309
|
});
|
|
292
310
|
}
|
|
293
311
|
/**
|
|
@@ -339,10 +357,8 @@ export function setupMcpConfig(config) {
|
|
|
339
357
|
args: [browserServerPath, '--user-data-dir', path.join(process.env.HOME || '', '.config', 'tuna-browser', 'chrome-profile')],
|
|
340
358
|
},
|
|
341
359
|
};
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
mcpServers['mem0'] = mem0Config;
|
|
345
|
-
}
|
|
360
|
+
// mem0 is NOT added here — it's added per-agent in writeAgentFolderMcpJson with the correct user_id.
|
|
361
|
+
// Adding it here (with machine name as user_id) would override the per-agent .mcp.json.
|
|
346
362
|
const mcpConfig = { mcpServers };
|
|
347
363
|
if (!fs.existsSync(MCP_CONFIG_DIR)) {
|
|
348
364
|
fs.mkdirSync(MCP_CONFIG_DIR, { recursive: true });
|