@claude-flow/cli 3.0.0-alpha.2 → 3.0.0-alpha.7
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/.agentic-flow/intelligence.json +4 -3
- package/.claude-flow/agents/store.json +16 -0
- package/.claude-flow/daemon-state.json +123 -0
- package/.claude-flow/hive-mind/state.json +51 -0
- package/.claude-flow/metrics/codebase-map.json +11 -0
- package/.claude-flow/metrics/consolidation.json +6 -0
- package/.claude-flow/metrics/performance.json +3 -3
- package/.claude-flow/metrics/security-audit.json +10 -0
- package/.claude-flow/metrics/task-metrics.json +3 -3
- package/.claude-flow/metrics/test-gaps.json +6 -0
- package/agents/architect.yaml +11 -0
- package/agents/coder.yaml +11 -0
- package/agents/reviewer.yaml +10 -0
- package/agents/security-architect.yaml +10 -0
- package/agents/tester.yaml +10 -0
- package/bin/cli.js +0 -0
- package/dist/src/commands/agent.d.ts.map +1 -1
- package/dist/src/commands/agent.js +43 -27
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/config.js +2 -2
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/daemon.d.ts +8 -0
- package/dist/src/commands/daemon.d.ts.map +1 -0
- package/dist/src/commands/daemon.js +351 -0
- package/dist/src/commands/daemon.js.map +1 -0
- package/dist/src/commands/hive-mind.d.ts.map +1 -1
- package/dist/src/commands/hive-mind.js +252 -35
- package/dist/src/commands/hive-mind.js.map +1 -1
- package/dist/src/commands/hooks.js +1 -1
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts +1 -0
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +4 -1
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/mcp.js +1 -1
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory.d.ts.map +1 -1
- package/dist/src/commands/memory.js +234 -168
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/migrate.js +1 -1
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/process.d.ts.map +1 -1
- package/dist/src/commands/process.js +95 -20
- package/dist/src/commands/process.js.map +1 -1
- package/dist/src/commands/start.js +2 -2
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.d.ts.map +1 -1
- package/dist/src/commands/status.js +26 -2
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/swarm.js +6 -6
- package/dist/src/commands/swarm.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +23 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/init/executor.d.ts.map +1 -1
- package/dist/src/init/executor.js +5 -0
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +22 -12
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/mcp-client.d.ts.map +1 -1
- package/dist/src/mcp-client.js +15 -1
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.d.ts.map +1 -1
- package/dist/src/mcp-server.js +5 -0
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.d.ts +1 -1
- package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +350 -14
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/config-tools.d.ts +1 -1
- package/dist/src/mcp-tools/config-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/config-tools.js +262 -15
- package/dist/src/mcp-tools/config-tools.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.d.ts +8 -0
- package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/hive-mind-tools.js +447 -0
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -0
- package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +80 -15
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/index.d.ts +4 -0
- package/dist/src/mcp-tools/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/index.js +4 -0
- package/dist/src/mcp-tools/index.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +157 -9
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/session-tools.d.ts +8 -0
- package/dist/src/mcp-tools/session-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/session-tools.js +315 -0
- package/dist/src/mcp-tools/session-tools.js.map +1 -0
- package/dist/src/mcp-tools/swarm-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.js +37 -2
- package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
- package/dist/src/mcp-tools/task-tools.d.ts +8 -0
- package/dist/src/mcp-tools/task-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/task-tools.js +302 -0
- package/dist/src/mcp-tools/task-tools.js.map +1 -0
- package/dist/src/mcp-tools/workflow-tools.d.ts +8 -0
- package/dist/src/mcp-tools/workflow-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/workflow-tools.js +481 -0
- package/dist/src/mcp-tools/workflow-tools.js.map +1 -0
- package/dist/src/services/index.d.ts +7 -0
- package/dist/src/services/index.d.ts.map +1 -0
- package/dist/src/services/index.js +6 -0
- package/dist/src/services/index.js.map +1 -0
- package/dist/src/services/worker-daemon.d.ts +126 -0
- package/dist/src/services/worker-daemon.d.ts.map +1 -0
- package/dist/src/services/worker-daemon.js +464 -0
- package/dist/src/services/worker-daemon.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/commands/agent.ts +43 -29
- package/src/commands/config.ts +2 -2
- package/src/commands/daemon.ts +395 -0
- package/src/commands/hive-mind.ts +229 -63
- package/src/commands/hooks.ts +1 -1
- package/src/commands/index.ts +4 -1
- package/src/commands/mcp.ts +1 -1
- package/src/commands/memory.ts +279 -181
- package/src/commands/migrate.ts +1 -1
- package/src/commands/process.ts +98 -20
- package/src/commands/start.ts +2 -2
- package/src/commands/status.ts +33 -2
- package/src/commands/swarm.ts +6 -6
- package/src/index.ts +23 -3
- package/src/init/executor.ts +6 -0
- package/src/init/settings-generator.ts +22 -12
- package/src/mcp-client.ts +15 -1
- package/src/mcp-server.ts +6 -0
- package/src/mcp-tools/agent-tools.ts +388 -14
- package/src/mcp-tools/config-tools.ts +297 -15
- package/src/mcp-tools/hive-mind-tools.ts +521 -0
- package/src/mcp-tools/hooks-tools.ts +84 -15
- package/src/mcp-tools/index.ts +4 -0
- package/src/mcp-tools/memory-tools.ts +190 -9
- package/src/mcp-tools/session-tools.ts +359 -0
- package/src/mcp-tools/swarm-tools.ts +38 -2
- package/src/mcp-tools/task-tools.ts +347 -0
- package/src/mcp-tools/workflow-tools.ts +573 -0
- package/src/services/index.ts +15 -0
- package/src/services/worker-daemon.ts +594 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session MCP Tools for CLI
|
|
3
|
+
*
|
|
4
|
+
* Tool definitions for session management with file persistence.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync, readdirSync, unlinkSync, statSync } from 'node:fs';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import type { MCPTool } from './types.js';
|
|
10
|
+
|
|
11
|
+
// Storage paths
|
|
12
|
+
const STORAGE_DIR = '.claude-flow';
|
|
13
|
+
const SESSION_DIR = 'sessions';
|
|
14
|
+
|
|
15
|
+
interface SessionRecord {
|
|
16
|
+
sessionId: string;
|
|
17
|
+
name: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
savedAt: string;
|
|
20
|
+
stats: {
|
|
21
|
+
tasks: number;
|
|
22
|
+
agents: number;
|
|
23
|
+
memoryEntries: number;
|
|
24
|
+
totalSize: number;
|
|
25
|
+
};
|
|
26
|
+
data?: {
|
|
27
|
+
memory?: Record<string, unknown>;
|
|
28
|
+
tasks?: Record<string, unknown>;
|
|
29
|
+
agents?: Record<string, unknown>;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getSessionDir(): string {
|
|
34
|
+
return join(process.cwd(), STORAGE_DIR, SESSION_DIR);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getSessionPath(sessionId: string): string {
|
|
38
|
+
// Sanitize sessionId to prevent path traversal
|
|
39
|
+
const safeId = sessionId.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
40
|
+
return join(getSessionDir(), `${safeId}.json`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function ensureSessionDir(): void {
|
|
44
|
+
const dir = getSessionDir();
|
|
45
|
+
if (!existsSync(dir)) {
|
|
46
|
+
mkdirSync(dir, { recursive: true });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function loadSession(sessionId: string): SessionRecord | null {
|
|
51
|
+
try {
|
|
52
|
+
const path = getSessionPath(sessionId);
|
|
53
|
+
if (existsSync(path)) {
|
|
54
|
+
const data = readFileSync(path, 'utf-8');
|
|
55
|
+
return JSON.parse(data);
|
|
56
|
+
}
|
|
57
|
+
} catch {
|
|
58
|
+
// Return null on error
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function saveSession(session: SessionRecord): void {
|
|
64
|
+
ensureSessionDir();
|
|
65
|
+
writeFileSync(getSessionPath(session.sessionId), JSON.stringify(session, null, 2), 'utf-8');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function listSessions(): SessionRecord[] {
|
|
69
|
+
ensureSessionDir();
|
|
70
|
+
const dir = getSessionDir();
|
|
71
|
+
const files = readdirSync(dir).filter(f => f.endsWith('.json'));
|
|
72
|
+
|
|
73
|
+
const sessions: SessionRecord[] = [];
|
|
74
|
+
for (const file of files) {
|
|
75
|
+
try {
|
|
76
|
+
const data = readFileSync(join(dir, file), 'utf-8');
|
|
77
|
+
sessions.push(JSON.parse(data));
|
|
78
|
+
} catch {
|
|
79
|
+
// Skip invalid files
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return sessions;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Load related stores for session data
|
|
87
|
+
function loadRelatedStores(options: { includeMemory?: boolean; includeTasks?: boolean; includeAgents?: boolean }) {
|
|
88
|
+
const data: SessionRecord['data'] = {};
|
|
89
|
+
|
|
90
|
+
if (options.includeMemory) {
|
|
91
|
+
try {
|
|
92
|
+
const memoryPath = join(process.cwd(), STORAGE_DIR, 'memory', 'store.json');
|
|
93
|
+
if (existsSync(memoryPath)) {
|
|
94
|
+
data.memory = JSON.parse(readFileSync(memoryPath, 'utf-8'));
|
|
95
|
+
}
|
|
96
|
+
} catch { /* ignore */ }
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (options.includeTasks) {
|
|
100
|
+
try {
|
|
101
|
+
const taskPath = join(process.cwd(), STORAGE_DIR, 'tasks', 'store.json');
|
|
102
|
+
if (existsSync(taskPath)) {
|
|
103
|
+
data.tasks = JSON.parse(readFileSync(taskPath, 'utf-8'));
|
|
104
|
+
}
|
|
105
|
+
} catch { /* ignore */ }
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (options.includeAgents) {
|
|
109
|
+
try {
|
|
110
|
+
const agentPath = join(process.cwd(), STORAGE_DIR, 'agents', 'store.json');
|
|
111
|
+
if (existsSync(agentPath)) {
|
|
112
|
+
data.agents = JSON.parse(readFileSync(agentPath, 'utf-8'));
|
|
113
|
+
}
|
|
114
|
+
} catch { /* ignore */ }
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return data;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export const sessionTools: MCPTool[] = [
|
|
121
|
+
{
|
|
122
|
+
name: 'session/save',
|
|
123
|
+
description: 'Save current session state',
|
|
124
|
+
category: 'session',
|
|
125
|
+
inputSchema: {
|
|
126
|
+
type: 'object',
|
|
127
|
+
properties: {
|
|
128
|
+
name: { type: 'string', description: 'Session name' },
|
|
129
|
+
description: { type: 'string', description: 'Session description' },
|
|
130
|
+
includeMemory: { type: 'boolean', description: 'Include memory in session' },
|
|
131
|
+
includeTasks: { type: 'boolean', description: 'Include tasks in session' },
|
|
132
|
+
includeAgents: { type: 'boolean', description: 'Include agents in session' },
|
|
133
|
+
},
|
|
134
|
+
required: ['name'],
|
|
135
|
+
},
|
|
136
|
+
handler: async (input) => {
|
|
137
|
+
const sessionId = `session-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
138
|
+
|
|
139
|
+
// Load related data based on options
|
|
140
|
+
const data = loadRelatedStores({
|
|
141
|
+
includeMemory: input.includeMemory as boolean,
|
|
142
|
+
includeTasks: input.includeTasks as boolean,
|
|
143
|
+
includeAgents: input.includeAgents as boolean,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Calculate stats
|
|
147
|
+
const stats = {
|
|
148
|
+
tasks: data.tasks ? Object.keys((data.tasks as { tasks?: object }).tasks || {}).length : 0,
|
|
149
|
+
agents: data.agents ? Object.keys((data.agents as { agents?: object }).agents || {}).length : 0,
|
|
150
|
+
memoryEntries: data.memory ? Object.keys((data.memory as { entries?: object }).entries || {}).length : 0,
|
|
151
|
+
totalSize: 0,
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const session: SessionRecord = {
|
|
155
|
+
sessionId,
|
|
156
|
+
name: input.name as string,
|
|
157
|
+
description: input.description as string,
|
|
158
|
+
savedAt: new Date().toISOString(),
|
|
159
|
+
stats,
|
|
160
|
+
data: Object.keys(data).length > 0 ? data : undefined,
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// Calculate size
|
|
164
|
+
const sessionJson = JSON.stringify(session);
|
|
165
|
+
session.stats.totalSize = Buffer.byteLength(sessionJson, 'utf-8');
|
|
166
|
+
|
|
167
|
+
saveSession(session);
|
|
168
|
+
|
|
169
|
+
return {
|
|
170
|
+
sessionId,
|
|
171
|
+
name: session.name,
|
|
172
|
+
savedAt: session.savedAt,
|
|
173
|
+
stats: session.stats,
|
|
174
|
+
path: getSessionPath(sessionId),
|
|
175
|
+
};
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: 'session/restore',
|
|
180
|
+
description: 'Restore a saved session',
|
|
181
|
+
category: 'session',
|
|
182
|
+
inputSchema: {
|
|
183
|
+
type: 'object',
|
|
184
|
+
properties: {
|
|
185
|
+
sessionId: { type: 'string', description: 'Session ID to restore' },
|
|
186
|
+
name: { type: 'string', description: 'Session name to restore' },
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
handler: async (input) => {
|
|
190
|
+
let session: SessionRecord | null = null;
|
|
191
|
+
|
|
192
|
+
// Try to find by sessionId first
|
|
193
|
+
if (input.sessionId) {
|
|
194
|
+
session = loadSession(input.sessionId as string);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Try to find by name if sessionId not found
|
|
198
|
+
if (!session && input.name) {
|
|
199
|
+
const sessions = listSessions();
|
|
200
|
+
session = sessions.find(s => s.name === input.name) || null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Try to find latest if no params
|
|
204
|
+
if (!session && !input.sessionId && !input.name) {
|
|
205
|
+
const sessions = listSessions();
|
|
206
|
+
if (sessions.length > 0) {
|
|
207
|
+
sessions.sort((a, b) => new Date(b.savedAt).getTime() - new Date(a.savedAt).getTime());
|
|
208
|
+
session = sessions[0];
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (session) {
|
|
213
|
+
// Restore data to respective stores
|
|
214
|
+
if (session.data?.memory) {
|
|
215
|
+
const memoryDir = join(process.cwd(), STORAGE_DIR, 'memory');
|
|
216
|
+
if (!existsSync(memoryDir)) mkdirSync(memoryDir, { recursive: true });
|
|
217
|
+
writeFileSync(join(memoryDir, 'store.json'), JSON.stringify(session.data.memory, null, 2), 'utf-8');
|
|
218
|
+
}
|
|
219
|
+
if (session.data?.tasks) {
|
|
220
|
+
const taskDir = join(process.cwd(), STORAGE_DIR, 'tasks');
|
|
221
|
+
if (!existsSync(taskDir)) mkdirSync(taskDir, { recursive: true });
|
|
222
|
+
writeFileSync(join(taskDir, 'store.json'), JSON.stringify(session.data.tasks, null, 2), 'utf-8');
|
|
223
|
+
}
|
|
224
|
+
if (session.data?.agents) {
|
|
225
|
+
const agentDir = join(process.cwd(), STORAGE_DIR, 'agents');
|
|
226
|
+
if (!existsSync(agentDir)) mkdirSync(agentDir, { recursive: true });
|
|
227
|
+
writeFileSync(join(agentDir, 'store.json'), JSON.stringify(session.data.agents, null, 2), 'utf-8');
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return {
|
|
231
|
+
sessionId: session.sessionId,
|
|
232
|
+
name: session.name,
|
|
233
|
+
restored: true,
|
|
234
|
+
restoredAt: new Date().toISOString(),
|
|
235
|
+
stats: session.stats,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return {
|
|
240
|
+
sessionId: input.sessionId || input.name || 'latest',
|
|
241
|
+
restored: false,
|
|
242
|
+
error: 'Session not found',
|
|
243
|
+
};
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: 'session/list',
|
|
248
|
+
description: 'List saved sessions',
|
|
249
|
+
category: 'session',
|
|
250
|
+
inputSchema: {
|
|
251
|
+
type: 'object',
|
|
252
|
+
properties: {
|
|
253
|
+
limit: { type: 'number', description: 'Maximum sessions to return' },
|
|
254
|
+
sortBy: { type: 'string', description: 'Sort field (date, name, size)' },
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
handler: async (input) => {
|
|
258
|
+
let sessions = listSessions();
|
|
259
|
+
|
|
260
|
+
// Sort
|
|
261
|
+
const sortBy = (input.sortBy as string) || 'date';
|
|
262
|
+
if (sortBy === 'date') {
|
|
263
|
+
sessions.sort((a, b) => new Date(b.savedAt).getTime() - new Date(a.savedAt).getTime());
|
|
264
|
+
} else if (sortBy === 'name') {
|
|
265
|
+
sessions.sort((a, b) => a.name.localeCompare(b.name));
|
|
266
|
+
} else if (sortBy === 'size') {
|
|
267
|
+
sessions.sort((a, b) => b.stats.totalSize - a.stats.totalSize);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Apply limit
|
|
271
|
+
const limit = (input.limit as number) || 10;
|
|
272
|
+
sessions = sessions.slice(0, limit);
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
sessions: sessions.map(s => ({
|
|
276
|
+
sessionId: s.sessionId,
|
|
277
|
+
name: s.name,
|
|
278
|
+
description: s.description,
|
|
279
|
+
savedAt: s.savedAt,
|
|
280
|
+
stats: s.stats,
|
|
281
|
+
})),
|
|
282
|
+
total: sessions.length,
|
|
283
|
+
limit,
|
|
284
|
+
};
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
name: 'session/delete',
|
|
289
|
+
description: 'Delete a saved session',
|
|
290
|
+
category: 'session',
|
|
291
|
+
inputSchema: {
|
|
292
|
+
type: 'object',
|
|
293
|
+
properties: {
|
|
294
|
+
sessionId: { type: 'string', description: 'Session ID to delete' },
|
|
295
|
+
},
|
|
296
|
+
required: ['sessionId'],
|
|
297
|
+
},
|
|
298
|
+
handler: async (input) => {
|
|
299
|
+
const sessionId = input.sessionId as string;
|
|
300
|
+
const path = getSessionPath(sessionId);
|
|
301
|
+
|
|
302
|
+
if (existsSync(path)) {
|
|
303
|
+
unlinkSync(path);
|
|
304
|
+
return {
|
|
305
|
+
sessionId,
|
|
306
|
+
deleted: true,
|
|
307
|
+
deletedAt: new Date().toISOString(),
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return {
|
|
312
|
+
sessionId,
|
|
313
|
+
deleted: false,
|
|
314
|
+
error: 'Session not found',
|
|
315
|
+
};
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
name: 'session/info',
|
|
320
|
+
description: 'Get detailed session information',
|
|
321
|
+
category: 'session',
|
|
322
|
+
inputSchema: {
|
|
323
|
+
type: 'object',
|
|
324
|
+
properties: {
|
|
325
|
+
sessionId: { type: 'string', description: 'Session ID' },
|
|
326
|
+
},
|
|
327
|
+
required: ['sessionId'],
|
|
328
|
+
},
|
|
329
|
+
handler: async (input) => {
|
|
330
|
+
const sessionId = input.sessionId as string;
|
|
331
|
+
const session = loadSession(sessionId);
|
|
332
|
+
|
|
333
|
+
if (session) {
|
|
334
|
+
const path = getSessionPath(sessionId);
|
|
335
|
+
const stat = statSync(path);
|
|
336
|
+
|
|
337
|
+
return {
|
|
338
|
+
sessionId: session.sessionId,
|
|
339
|
+
name: session.name,
|
|
340
|
+
description: session.description,
|
|
341
|
+
savedAt: session.savedAt,
|
|
342
|
+
stats: session.stats,
|
|
343
|
+
fileSize: stat.size,
|
|
344
|
+
path,
|
|
345
|
+
hasData: {
|
|
346
|
+
memory: !!session.data?.memory,
|
|
347
|
+
tasks: !!session.data?.tasks,
|
|
348
|
+
agents: !!session.data?.agents,
|
|
349
|
+
},
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return {
|
|
354
|
+
sessionId,
|
|
355
|
+
error: 'Session not found',
|
|
356
|
+
};
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
];
|
|
@@ -20,11 +20,23 @@ export const swarmTools: MCPTool[] = [
|
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
22
|
handler: async (input) => {
|
|
23
|
+
const topology = input.topology || 'hierarchical-mesh';
|
|
24
|
+
const maxAgents = input.maxAgents || 15;
|
|
25
|
+
const config = (input.config || {}) as Record<string, unknown>;
|
|
26
|
+
|
|
23
27
|
return {
|
|
24
28
|
success: true,
|
|
25
29
|
swarmId: `swarm-${Date.now()}`,
|
|
26
|
-
topology
|
|
27
|
-
|
|
30
|
+
topology,
|
|
31
|
+
initializedAt: new Date().toISOString(),
|
|
32
|
+
config: {
|
|
33
|
+
topology,
|
|
34
|
+
maxAgents,
|
|
35
|
+
currentAgents: 0,
|
|
36
|
+
communicationProtocol: (config.communicationProtocol as string) || 'message-bus',
|
|
37
|
+
autoScaling: (config.autoScaling as boolean) ?? true,
|
|
38
|
+
consensusMechanism: (config.consensusMechanism as string) || 'majority',
|
|
39
|
+
},
|
|
28
40
|
};
|
|
29
41
|
},
|
|
30
42
|
},
|
|
@@ -66,4 +78,28 @@ export const swarmTools: MCPTool[] = [
|
|
|
66
78
|
};
|
|
67
79
|
},
|
|
68
80
|
},
|
|
81
|
+
{
|
|
82
|
+
name: 'swarm/health',
|
|
83
|
+
description: 'Check swarm health status',
|
|
84
|
+
category: 'swarm',
|
|
85
|
+
inputSchema: {
|
|
86
|
+
type: 'object',
|
|
87
|
+
properties: {
|
|
88
|
+
swarmId: { type: 'string', description: 'Swarm ID to check' },
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
handler: async (input) => {
|
|
92
|
+
return {
|
|
93
|
+
status: 'healthy' as const,
|
|
94
|
+
swarmId: input.swarmId || 'default',
|
|
95
|
+
checks: [
|
|
96
|
+
{ name: 'coordinator', status: 'ok', message: 'Coordinator responding' },
|
|
97
|
+
{ name: 'agents', status: 'ok', message: 'Agent pool healthy' },
|
|
98
|
+
{ name: 'memory', status: 'ok', message: 'Memory backend connected' },
|
|
99
|
+
{ name: 'messaging', status: 'ok', message: 'Message bus active' },
|
|
100
|
+
],
|
|
101
|
+
checkedAt: new Date().toISOString(),
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
},
|
|
69
105
|
];
|