tuna-agent 0.1.13 β†’ 0.1.15

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.
@@ -691,9 +691,13 @@ Instructions:
691
691
  async storeRatingMemory(data) {
692
692
  if (!process.env.MEM0_SSH_HOST)
693
693
  return;
694
- const sentiment = data.score > 0 ? 'approved (thumbs up)' : 'rejected (thumbs down)';
695
- const commentPart = data.comment ? ` User feedback: "${data.comment}"` : '';
696
- const memoryText = `User ${sentiment} task "${data.taskTitle}".${commentPart} Task description: ${data.taskDescription.substring(0, 200)}`;
694
+ const rating = data.score > 0 ? 'GOOD (πŸ‘)' : 'BAD (πŸ‘Ž)';
695
+ const taskContext = (data.taskTitle || data.taskDescription).substring(0, 100);
696
+ const parts = [`[USER RATING: ${rating}] Task: "${taskContext}"`];
697
+ if (data.comment) {
698
+ parts.push(`User comment: "${data.comment}"`);
699
+ }
700
+ const memoryText = parts.join('. ');
697
701
  try {
698
702
  console.log(`[Ratingβ†’Mem0] Storing rating for task "${data.taskTitle}" (${data.score > 0 ? 'πŸ‘' : 'πŸ‘Ž'})`);
699
703
  const { callMem0AddMemory } = await import('../mcp/setup.js');
package/dist/mcp/setup.js CHANGED
@@ -49,32 +49,52 @@ export async function callMem0AddMemory(text, agentName) {
49
49
  return new Promise((resolve, reject) => {
50
50
  const proc = spawn(cmd, args, { stdio: ['pipe', 'pipe', 'pipe'], env: spawnEnv });
51
51
  let stdout = '';
52
- const timeout = setTimeout(() => { proc.kill(); reject(new Error('Mem0 call timed out')); }, 15000);
53
- proc.stdout.on('data', (d) => { stdout += d.toString(); });
52
+ let resolved = false;
53
+ const timer = setTimeout(() => { if (!resolved) {
54
+ resolved = true;
55
+ proc.kill();
56
+ reject(new Error('Mem0 call timed out'));
57
+ } }, 15000);
54
58
  proc.stderr.on('data', () => { }); // ignore stderr
55
- // Send MCP init + add_memory
56
59
  const initMsg = JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'initialize', params: { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'tuna-agent', version: '1.0' } } });
57
60
  const notifyMsg = JSON.stringify({ jsonrpc: '2.0', method: 'notifications/initialized' });
58
61
  const addMsg = JSON.stringify({ jsonrpc: '2.0', id: 2, method: 'tools/call', params: { name: 'add_memory', arguments: { text } } });
59
- proc.stdin.write(initMsg + '\n');
60
- proc.stdin.write(notifyMsg + '\n');
61
- proc.stdin.write(addMsg + '\n');
62
- // Wait for response then close
63
- const checkDone = () => {
64
- if (stdout.includes('"id":2') || stdout.includes('"id": 2')) {
65
- clearTimeout(timeout);
66
- proc.stdin.end();
67
- proc.kill();
68
- if (stdout.includes('"error"')) {
69
- reject(new Error(`Mem0 error: ${stdout.substring(stdout.lastIndexOf('"error"'), stdout.lastIndexOf('"error"') + 200)}`));
70
- }
71
- else {
62
+ let sentAdd = false;
63
+ proc.stdout.on('data', (d) => {
64
+ stdout += d.toString();
65
+ // After init response, send the add_memory call
66
+ if (!sentAdd && stdout.includes('"id":1')) {
67
+ sentAdd = true;
68
+ proc.stdin.write(notifyMsg + '\n');
69
+ proc.stdin.write(addMsg + '\n');
70
+ }
71
+ // After add_memory response, we're done
72
+ if (sentAdd && stdout.includes('"id":2')) {
73
+ if (!resolved) {
74
+ resolved = true;
75
+ clearTimeout(timer);
76
+ proc.stdin.end();
77
+ proc.kill();
72
78
  resolve();
73
79
  }
74
80
  }
75
- };
76
- proc.stdout.on('data', checkDone);
77
- proc.on('close', () => { clearTimeout(timeout); resolve(); });
81
+ });
82
+ // Send init immediately
83
+ proc.stdin.write(initMsg + '\n');
84
+ proc.on('close', () => {
85
+ if (!resolved) {
86
+ resolved = true;
87
+ clearTimeout(timer);
88
+ resolve();
89
+ }
90
+ });
91
+ proc.on('error', (err) => {
92
+ if (!resolved) {
93
+ resolved = true;
94
+ clearTimeout(timer);
95
+ reject(err);
96
+ }
97
+ });
78
98
  });
79
99
  }
80
100
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuna-agent",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Tuna Agent - Run AI coding tasks on your machine",
5
5
  "bin": {
6
6
  "tuna-agent": "dist/cli/index.js"