tuna-agent 0.1.34 → 0.1.35
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/agents/claude-code-adapter.js +11 -3
- package/dist/mcp/setup.d.ts +6 -0
- package/dist/mcp/setup.js +23 -0
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import { planTask, chatWithPM } from '../pm/planner.js';
|
|
|
7
7
|
import { savePMState, clearPMState } from '../daemon/pm-state.js';
|
|
8
8
|
import { simplifyMarkdown, waitForInput, sessionToPayload, executePlanAndReport, } from '../utils/execution-helpers.js';
|
|
9
9
|
import { downloadAttachments, cleanupAttachments } from '../utils/image-download.js';
|
|
10
|
-
import { writeAgentFolderMcpConfig } from '../mcp/setup.js';
|
|
10
|
+
import { writeAgentFolderMcpConfig, fetchMem0Count } from '../mcp/setup.js';
|
|
11
11
|
export class ClaudeCodeAdapter {
|
|
12
12
|
type = 'claude-code';
|
|
13
13
|
displayName = 'Claude Code';
|
|
@@ -119,10 +119,18 @@ export class ClaudeCodeAdapter {
|
|
|
119
119
|
const cwd = task.repoPath || defaultWorkspace;
|
|
120
120
|
if (!fs.existsSync(cwd))
|
|
121
121
|
fs.mkdirSync(cwd, { recursive: true });
|
|
122
|
-
// Write MCP config to agent folder .
|
|
123
|
-
// Claude Code reads
|
|
122
|
+
// Write MCP config to agent folder .mcp.json on first round
|
|
123
|
+
// Claude Code reads .mcp.json automatically for project-level MCPs
|
|
124
124
|
if (round === 0) {
|
|
125
125
|
writeAgentFolderMcpConfig(cwd, this.agentConfig);
|
|
126
|
+
// Seed memoryCount from Mem0 so it survives daemon restarts (non-blocking)
|
|
127
|
+
const agentFolderName = path.basename(cwd);
|
|
128
|
+
fetchMem0Count(agentFolderName).then(count => {
|
|
129
|
+
if (count > this.metrics.memoryCount) {
|
|
130
|
+
this.metrics.memoryCount = count;
|
|
131
|
+
console.log(`[Metrics] Seeded memoryCount=${count} from Mem0 for "${agentFolderName}"`);
|
|
132
|
+
}
|
|
133
|
+
}).catch(() => { });
|
|
126
134
|
}
|
|
127
135
|
// Skills/scheduled tasks use MCP tools (knowledge sync) → disable agentTeam
|
|
128
136
|
// Manual chat tasks may spawn sub-agents → keep agentTeam enabled
|
package/dist/mcp/setup.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { AgentConfig } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Fetch Mem0 memory count for an agent via HTTP API.
|
|
4
|
+
* Used to initialize memoryCount on daemon startup.
|
|
5
|
+
* Returns 0 if MEM0_HTTP_BASE is not set or request fails.
|
|
6
|
+
*/
|
|
7
|
+
export declare function fetchMem0Count(agentName: string): Promise<number>;
|
|
2
8
|
/**
|
|
3
9
|
* Call Mem0 add_memory via mem0-add script (bypasses OpenMemory API).
|
|
4
10
|
* Calls `mem0-add <text>` directly or via SSH — simple, reliable.
|
package/dist/mcp/setup.js
CHANGED
|
@@ -7,9 +7,11 @@ const MCP_CONFIG_DIR = path.join(process.env.HOME || '', '.tuna-agent');
|
|
|
7
7
|
const MCP_CONFIG_PATH = path.join(MCP_CONFIG_DIR, 'mcp-config.json');
|
|
8
8
|
// Mem0 config from environment variables
|
|
9
9
|
// MEM0_SSH_HOST: "local" = run mem0-mcp directly, "user@host" = run via SSH, unset = disabled
|
|
10
|
+
// MEM0_HTTP_BASE: HTTP base URL of OpenMemory API (e.g. http://redrop.ddns.net:8765)
|
|
10
11
|
const MEM0_SSH_HOST = process.env.MEM0_SSH_HOST;
|
|
11
12
|
const MEM0_SSH_PORT = process.env.MEM0_SSH_PORT || '22';
|
|
12
13
|
const MEM0_SSH_KEY = process.env.MEM0_SSH_KEY;
|
|
14
|
+
const MEM0_HTTP_BASE = process.env.MEM0_HTTP_BASE || '';
|
|
13
15
|
const MEM0_ENV_VARS = {
|
|
14
16
|
MEM0_API_BASE: 'http://127.0.0.1:8765',
|
|
15
17
|
MEM0_QDRANT_URL: 'http://127.0.0.1:6333',
|
|
@@ -20,6 +22,27 @@ const MEM0_ENV_VARS = {
|
|
|
20
22
|
MEM0_NEO4J_USER: 'neo4j',
|
|
21
23
|
MEM0_NEO4J_PASSWORD: 'mem0graph',
|
|
22
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Fetch Mem0 memory count for an agent via HTTP API.
|
|
27
|
+
* Used to initialize memoryCount on daemon startup.
|
|
28
|
+
* Returns 0 if MEM0_HTTP_BASE is not set or request fails.
|
|
29
|
+
*/
|
|
30
|
+
export async function fetchMem0Count(agentName) {
|
|
31
|
+
if (!MEM0_HTTP_BASE)
|
|
32
|
+
return 0;
|
|
33
|
+
try {
|
|
34
|
+
const safeName = agentName.replace(/[^a-zA-Z0-9_-]/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '') || 'agent';
|
|
35
|
+
const url = `${MEM0_HTTP_BASE}/api/v1/memories/?user_id=${encodeURIComponent(safeName)}&page=1&page_size=1`;
|
|
36
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(5000) });
|
|
37
|
+
if (!res.ok)
|
|
38
|
+
return 0;
|
|
39
|
+
const data = await res.json();
|
|
40
|
+
return data.total || 0;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
23
46
|
/**
|
|
24
47
|
* Call Mem0 add_memory via mem0-add script (bypasses OpenMemory API).
|
|
25
48
|
* Calls `mem0-add <text>` directly or via SSH — simple, reliable.
|