@agentic-robotics/mcp 0.1.3
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/README.md +300 -0
- package/package.json +51 -0
- package/src/benchmark.ts +434 -0
- package/src/cli.ts +89 -0
- package/src/enhanced-memory.ts +437 -0
- package/src/enhanced-server.ts +523 -0
- package/src/flow-orchestrator.ts +415 -0
- package/src/hybrid-benchmark.ts +291 -0
- package/src/hybrid-memory.ts +401 -0
- package/src/index.ts +10 -0
- package/src/interface.ts +118 -0
- package/src/memory.ts +196 -0
- package/src/optimized-benchmark.ts +302 -0
- package/src/optimized-memory.ts +271 -0
- package/src/server.ts +213 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced ROS3 MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Integrates:
|
|
5
|
+
* - AgentDB (20 MCP tools, 150x faster memory)
|
|
6
|
+
* - agentic-flow (66 agents, 213 MCP tools)
|
|
7
|
+
* - Reflexion memory with self-critique
|
|
8
|
+
* - Skill library with semantic search
|
|
9
|
+
* - Multi-robot swarm coordination
|
|
10
|
+
* - Causal reasoning
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { ROS3Interface } from './interface.js';
|
|
14
|
+
import { EnhancedAgentDBMemory, Episode } from './enhanced-memory.js';
|
|
15
|
+
import { FlowOrchestrator, AgentTask } from './flow-orchestrator.js';
|
|
16
|
+
|
|
17
|
+
export interface EnhancedROS3McpServerConfig {
|
|
18
|
+
name?: string;
|
|
19
|
+
version?: string;
|
|
20
|
+
dbPath?: string;
|
|
21
|
+
enableFlow?: boolean;
|
|
22
|
+
numAgents?: number;
|
|
23
|
+
enableReasoning?: boolean;
|
|
24
|
+
enableLearning?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class EnhancedROS3McpServer {
|
|
28
|
+
private ros3: ROS3Interface;
|
|
29
|
+
private memory: EnhancedAgentDBMemory;
|
|
30
|
+
private orchestrator: FlowOrchestrator;
|
|
31
|
+
private name: string;
|
|
32
|
+
private version: string;
|
|
33
|
+
private config: EnhancedROS3McpServerConfig;
|
|
34
|
+
|
|
35
|
+
constructor(config: EnhancedROS3McpServerConfig = {}) {
|
|
36
|
+
const {
|
|
37
|
+
name = 'enhanced-ros3-mcp-server',
|
|
38
|
+
version = '2.0.0',
|
|
39
|
+
dbPath = './ros3-agentdb.db',
|
|
40
|
+
enableFlow = true,
|
|
41
|
+
numAgents = 66,
|
|
42
|
+
enableReasoning = true,
|
|
43
|
+
enableLearning = true,
|
|
44
|
+
} = config;
|
|
45
|
+
|
|
46
|
+
this.name = name;
|
|
47
|
+
this.version = version;
|
|
48
|
+
this.config = config;
|
|
49
|
+
|
|
50
|
+
// Initialize components
|
|
51
|
+
this.ros3 = new ROS3Interface();
|
|
52
|
+
this.memory = new EnhancedAgentDBMemory(dbPath);
|
|
53
|
+
|
|
54
|
+
if (enableFlow) {
|
|
55
|
+
this.orchestrator = new FlowOrchestrator({
|
|
56
|
+
numAgents,
|
|
57
|
+
strategy: 'adaptive',
|
|
58
|
+
reasoningEnabled: enableReasoning,
|
|
59
|
+
learningEnabled: enableLearning,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async start(): Promise<void> {
|
|
65
|
+
console.error(`🚀 ${this.name} v${this.version} starting...`);
|
|
66
|
+
|
|
67
|
+
// Initialize AgentDB
|
|
68
|
+
await this.memory.initialize();
|
|
69
|
+
console.error('✅ AgentDB initialized (150x faster memory)');
|
|
70
|
+
|
|
71
|
+
// Initialize agentic-flow if enabled
|
|
72
|
+
if (this.config.enableFlow && this.orchestrator) {
|
|
73
|
+
await this.orchestrator.initialize();
|
|
74
|
+
console.error(`✅ agentic-flow initialized (${this.config.numAgents} agents, 213 tools)`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
console.error('');
|
|
78
|
+
console.error('📋 Available Capabilities:');
|
|
79
|
+
console.error('');
|
|
80
|
+
console.error(' ROBOT CONTROL:');
|
|
81
|
+
console.error(' • move_robot - Move robot with learning');
|
|
82
|
+
console.error(' • get_pose - Get current pose');
|
|
83
|
+
console.error(' • get_status - Get robot status');
|
|
84
|
+
console.error('');
|
|
85
|
+
console.error(' SENSING:');
|
|
86
|
+
console.error(' • read_lidar - Read LIDAR with memory');
|
|
87
|
+
console.error(' • detect_objects - Detect objects with learning');
|
|
88
|
+
console.error('');
|
|
89
|
+
console.error(' MEMORY & LEARNING (AgentDB):');
|
|
90
|
+
console.error(' • query_memory - Query past experiences');
|
|
91
|
+
console.error(' • search_skills - Search skill library');
|
|
92
|
+
console.error(' • consolidate_skills - Auto-learn from success');
|
|
93
|
+
console.error(' • get_memory_stats - Performance metrics');
|
|
94
|
+
console.error(' • optimize_memory - Database optimization');
|
|
95
|
+
console.error('');
|
|
96
|
+
console.error(' ORCHESTRATION (agentic-flow):');
|
|
97
|
+
console.error(' • execute_task - Single task with 66 agents');
|
|
98
|
+
console.error(' • execute_swarm - Multi-task swarm coordination');
|
|
99
|
+
console.error(' • coordinate_robots - Multi-robot coordination');
|
|
100
|
+
console.error(' • reason_about_task - Causal reasoning');
|
|
101
|
+
console.error(' • list_mcp_tools - Show all 213 MCP tools');
|
|
102
|
+
console.error('');
|
|
103
|
+
console.error(' ADVANCED:');
|
|
104
|
+
console.error(' • query_with_reasoning - Context + causal reasoning');
|
|
105
|
+
console.error(' • self_critique - Generate self-critique');
|
|
106
|
+
console.error(' • benchmark - Performance benchmarks');
|
|
107
|
+
console.error('');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async stop(): Promise<void> {
|
|
111
|
+
await this.memory.close();
|
|
112
|
+
if (this.orchestrator) {
|
|
113
|
+
await this.orchestrator.close();
|
|
114
|
+
}
|
|
115
|
+
console.error(`${this.name} stopped`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// ===== ROBOT CONTROL TOOLS =====
|
|
119
|
+
|
|
120
|
+
async moveRobot(params: {
|
|
121
|
+
x: number;
|
|
122
|
+
y: number;
|
|
123
|
+
z: number;
|
|
124
|
+
roll: number;
|
|
125
|
+
pitch: number;
|
|
126
|
+
yaw: number;
|
|
127
|
+
speed?: number;
|
|
128
|
+
frame?: 'base' | 'world';
|
|
129
|
+
useMemory?: boolean;
|
|
130
|
+
}): Promise<string> {
|
|
131
|
+
const { x, y, z, roll, pitch, yaw, speed = 0.5, frame = 'world', useMemory = true } = params;
|
|
132
|
+
const startTime = Date.now();
|
|
133
|
+
|
|
134
|
+
// Query similar past movements if enabled
|
|
135
|
+
let pastExperiences = '';
|
|
136
|
+
if (useMemory) {
|
|
137
|
+
const similar = await this.memory.retrieveMemories(
|
|
138
|
+
`move to [${x}, ${y}, ${z}]`,
|
|
139
|
+
3,
|
|
140
|
+
{ onlySuccesses: true, synthesizeContext: true }
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
if (similar.length > 0) {
|
|
144
|
+
pastExperiences = `\nLearning from ${similar.length} past experiences...`;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
try {
|
|
149
|
+
await this.ros3.moveToPose({ x, y, z, roll, pitch, yaw }, speed, frame);
|
|
150
|
+
const latency = Date.now() - startTime;
|
|
151
|
+
|
|
152
|
+
// Store episode with self-critique
|
|
153
|
+
await this.memory.storeEpisode({
|
|
154
|
+
sessionId: `motion-${Date.now()}`,
|
|
155
|
+
taskName: 'move_robot',
|
|
156
|
+
confidence: 0.9,
|
|
157
|
+
success: true,
|
|
158
|
+
outcome: `Moved to [${x}, ${y}, ${z}] in ${latency}ms`,
|
|
159
|
+
strategy: `speed_${speed}_frame_${frame}`,
|
|
160
|
+
metadata: { x, y, z, roll, pitch, yaw, speed, frame, latency },
|
|
161
|
+
reasoning: `Target position reachable, speed ${speed} appropriate for distance`,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
return `Robot moved to [${x}, ${y}, ${z}] in ${frame} frame. Completed in ${latency}ms.${pastExperiences}`;
|
|
165
|
+
} catch (error: any) {
|
|
166
|
+
await this.memory.storeEpisode({
|
|
167
|
+
sessionId: `motion-${Date.now()}`,
|
|
168
|
+
taskName: 'move_robot',
|
|
169
|
+
confidence: 0.0,
|
|
170
|
+
success: false,
|
|
171
|
+
outcome: `Failed: ${error.message}`,
|
|
172
|
+
metadata: { x, y, z, roll, pitch, yaw, speed, frame },
|
|
173
|
+
reasoning: `Movement failed, possibly due to obstacles or unreachable target`,
|
|
174
|
+
critique: 'Should validate target reachability before attempting movement',
|
|
175
|
+
});
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
async getPose(): Promise<string> {
|
|
181
|
+
const pose = await this.ros3.getCurrentPose();
|
|
182
|
+
return `Current pose: [${pose.x}, ${pose.y}, ${pose.z}] (roll=${pose.roll}, pitch=${pose.pitch}, yaw=${pose.yaw})`;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async getStatus(): Promise<string> {
|
|
186
|
+
const status = await this.ros3.getStatus();
|
|
187
|
+
return `Robot status: ${status.status}, Health: ${status.health}`;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// ===== SENSING TOOLS =====
|
|
191
|
+
|
|
192
|
+
async readLidar(params: {
|
|
193
|
+
filter?: string;
|
|
194
|
+
max_points?: number;
|
|
195
|
+
useMemory?: boolean;
|
|
196
|
+
}): Promise<string> {
|
|
197
|
+
const { filter = 'all', max_points = 10000, useMemory = true } = params;
|
|
198
|
+
const startTime = Date.now();
|
|
199
|
+
|
|
200
|
+
const cloud = await this.ros3.getLidarData(
|
|
201
|
+
filter as 'all' | 'obstacles' | 'ground',
|
|
202
|
+
max_points
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
const latency = Date.now() - startTime;
|
|
206
|
+
|
|
207
|
+
if (useMemory) {
|
|
208
|
+
await this.memory.storeEpisode({
|
|
209
|
+
sessionId: `lidar-${Date.now()}`,
|
|
210
|
+
taskName: 'read_lidar',
|
|
211
|
+
confidence: 1.0,
|
|
212
|
+
success: true,
|
|
213
|
+
outcome: `Retrieved ${cloud.points.length} points in ${latency}ms`,
|
|
214
|
+
metadata: { filter, max_points, num_points: cloud.points.length, latency },
|
|
215
|
+
reasoning: `LIDAR scan successful, ${cloud.points.length} points within expected range`,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return `LIDAR data: ${cloud.points.length} points (filter: ${filter}, latency: ${latency}ms)`;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async detectObjects(params: {
|
|
223
|
+
camera: string;
|
|
224
|
+
confidence_threshold?: number;
|
|
225
|
+
useMemory?: boolean;
|
|
226
|
+
}): Promise<string> {
|
|
227
|
+
const { camera, confidence_threshold = 0.5, useMemory = true } = params;
|
|
228
|
+
const startTime = Date.now();
|
|
229
|
+
|
|
230
|
+
const detections = await this.ros3.detectObjects(
|
|
231
|
+
camera as 'front' | 'left' | 'right' | 'rear',
|
|
232
|
+
confidence_threshold
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
const latency = Date.now() - startTime;
|
|
236
|
+
|
|
237
|
+
if (useMemory) {
|
|
238
|
+
await this.memory.storeEpisode({
|
|
239
|
+
sessionId: `vision-${Date.now()}`,
|
|
240
|
+
taskName: 'detect_objects',
|
|
241
|
+
confidence: 0.9,
|
|
242
|
+
success: true,
|
|
243
|
+
outcome: `Detected ${detections.length} objects in ${latency}ms`,
|
|
244
|
+
metadata: { camera, confidence_threshold, num_detections: detections.length, latency },
|
|
245
|
+
reasoning: `Object detection successful from ${camera} camera`,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return `Detected ${detections.length} objects from ${camera} camera:\n${JSON.stringify(detections, null, 2)}`;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// ===== MEMORY & LEARNING TOOLS =====
|
|
253
|
+
|
|
254
|
+
async queryMemory(params: {
|
|
255
|
+
query: string;
|
|
256
|
+
k?: number;
|
|
257
|
+
only_successes?: boolean;
|
|
258
|
+
min_confidence?: number;
|
|
259
|
+
enable_reasoning?: boolean;
|
|
260
|
+
}): Promise<string> {
|
|
261
|
+
const { query, k = 5, only_successes = false, min_confidence = 0.0, enable_reasoning = true } = params;
|
|
262
|
+
|
|
263
|
+
const result = await this.memory.queryWithContext(query, {
|
|
264
|
+
k,
|
|
265
|
+
minConfidence: min_confidence,
|
|
266
|
+
synthesizeReasoning: enable_reasoning,
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
const filteredMemories = only_successes
|
|
270
|
+
? result.memories.filter((m) => m.success)
|
|
271
|
+
: result.memories;
|
|
272
|
+
|
|
273
|
+
let response = `Found ${filteredMemories.length} memories for "${query}":\n`;
|
|
274
|
+
response += JSON.stringify(filteredMemories, null, 2);
|
|
275
|
+
|
|
276
|
+
if (result.reasoning) {
|
|
277
|
+
response += `\n\nCausal Reasoning:\n${result.reasoning}`;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return response;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
async searchSkills(params: {
|
|
284
|
+
query: string;
|
|
285
|
+
k?: number;
|
|
286
|
+
min_success_rate?: number;
|
|
287
|
+
sort_by?: string;
|
|
288
|
+
}): Promise<string> {
|
|
289
|
+
const { query, k = 10, min_success_rate = 0.5, sort_by = 'success_rate' } = params;
|
|
290
|
+
|
|
291
|
+
const skills = await this.memory.searchSkills(query, {
|
|
292
|
+
k,
|
|
293
|
+
minSuccessRate: min_success_rate,
|
|
294
|
+
sortBy: sort_by as any,
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
return `Found ${skills.length} skills for "${query}":\n${JSON.stringify(skills, null, 2)}`;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async consolidateSkills(params?: {
|
|
301
|
+
min_attempts?: number;
|
|
302
|
+
min_reward?: number;
|
|
303
|
+
time_window_days?: number;
|
|
304
|
+
enable_pruning?: boolean;
|
|
305
|
+
}): Promise<string> {
|
|
306
|
+
const { min_attempts = 3, min_reward = 0.7, time_window_days = 7, enable_pruning = true } = params || {};
|
|
307
|
+
|
|
308
|
+
const numSkills = await this.memory.consolidateSkills({
|
|
309
|
+
minAttempts: min_attempts,
|
|
310
|
+
minReward: min_reward,
|
|
311
|
+
timeWindowDays: time_window_days,
|
|
312
|
+
enablePruning: enable_pruning,
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
return `Skills consolidated: ${numSkills} new skills learned (min_attempts: ${min_attempts}, min_reward: ${min_reward}, window: ${time_window_days} days)`;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
async getMemoryStats(): Promise<string> {
|
|
319
|
+
const stats = await this.memory.getStats();
|
|
320
|
+
|
|
321
|
+
return `AgentDB Statistics:
|
|
322
|
+
Total Episodes: ${stats.totalEpisodes}
|
|
323
|
+
Total Skills: ${stats.totalSkills}
|
|
324
|
+
Avg Retrieval Time: ${stats.avgRetrievalTime}ms
|
|
325
|
+
Cache Hit Rate: ${stats.cacheHitRate}%
|
|
326
|
+
Database Size: ${(stats.dbSize / 1024 / 1024).toFixed(2)}MB`;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
async optimizeMemory(): Promise<string> {
|
|
330
|
+
await this.memory.optimize();
|
|
331
|
+
return 'Database optimized (vacuum, reindex, vector optimization complete)';
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// ===== ORCHESTRATION TOOLS (agentic-flow) =====
|
|
335
|
+
|
|
336
|
+
async executeTask(params: {
|
|
337
|
+
task_type: string;
|
|
338
|
+
priority: 'low' | 'medium' | 'high' | 'critical';
|
|
339
|
+
task_params: Record<string, any>;
|
|
340
|
+
timeout?: number;
|
|
341
|
+
}): Promise<string> {
|
|
342
|
+
if (!this.orchestrator) {
|
|
343
|
+
return 'agentic-flow not enabled. Enable with enableFlow: true';
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const task: AgentTask = {
|
|
347
|
+
id: `task-${Date.now()}`,
|
|
348
|
+
type: params.task_type,
|
|
349
|
+
priority: params.priority,
|
|
350
|
+
params: params.task_params,
|
|
351
|
+
timeout: params.timeout,
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
const result = await this.orchestrator.executeTask(task);
|
|
355
|
+
|
|
356
|
+
return `Task ${result.taskId} ${result.success ? 'completed' : 'failed'}:
|
|
357
|
+
Execution Time: ${result.executionTime}ms
|
|
358
|
+
Agents Used: ${result.agentsUsed.join(', ')}
|
|
359
|
+
Tools Used: ${result.toolsUsed.join(', ')}
|
|
360
|
+
Result: ${JSON.stringify(result.result, null, 2)}
|
|
361
|
+
${result.reasoning ? `\nReasoning: ${result.reasoning}` : ''}`;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
async executeSwarm(params: {
|
|
365
|
+
tasks: Array<{ type: string; priority: string; params: Record<string, any> }>;
|
|
366
|
+
}): Promise<string> {
|
|
367
|
+
if (!this.orchestrator) {
|
|
368
|
+
return 'agentic-flow not enabled';
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const tasks: AgentTask[] = params.tasks.map((t, i) => ({
|
|
372
|
+
id: `swarm-${i}`,
|
|
373
|
+
type: t.type,
|
|
374
|
+
priority: t.priority as any,
|
|
375
|
+
params: t.params,
|
|
376
|
+
}));
|
|
377
|
+
|
|
378
|
+
const results = await this.orchestrator.executeSwarm(tasks);
|
|
379
|
+
|
|
380
|
+
const successful = results.filter(r => r.success).length;
|
|
381
|
+
return `Swarm execution complete: ${successful}/${results.length} tasks successful\n${JSON.stringify(results, null, 2)}`;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
async coordinateRobots(params: {
|
|
385
|
+
robots: string[];
|
|
386
|
+
mission_type: string;
|
|
387
|
+
objectives: string[];
|
|
388
|
+
constraints?: Record<string, any>;
|
|
389
|
+
}): Promise<string> {
|
|
390
|
+
if (!this.orchestrator) {
|
|
391
|
+
return 'agentic-flow not enabled';
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
const result = await this.orchestrator.coordinateRobots(params.robots, {
|
|
395
|
+
type: params.mission_type,
|
|
396
|
+
objectives: params.objectives,
|
|
397
|
+
constraints: params.constraints,
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
return `Robot coordination ${result.success ? 'successful' : 'failed'}:
|
|
401
|
+
Assignments: ${JSON.stringify(result.assignments, null, 2)}
|
|
402
|
+
Estimated Time: ${result.estimatedTime}ms
|
|
403
|
+
Execution Plan: ${JSON.stringify(result.executionPlan, null, 2)}`;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
async reasonAboutTask(params: {
|
|
407
|
+
context: string;
|
|
408
|
+
use_memory?: boolean;
|
|
409
|
+
synthesize_strategy?: boolean;
|
|
410
|
+
explain_reasoning?: boolean;
|
|
411
|
+
}): Promise<string> {
|
|
412
|
+
if (!this.orchestrator) {
|
|
413
|
+
return 'agentic-flow not enabled';
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const result = await this.orchestrator.reasonAboutTask(params.context, {
|
|
417
|
+
useMemory: params.use_memory,
|
|
418
|
+
synthesizeStrategy: params.synthesize_strategy,
|
|
419
|
+
explainReasoning: params.explain_reasoning,
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
return `Decision: ${result.decision}
|
|
423
|
+
Confidence: ${(result.confidence * 100).toFixed(1)}%
|
|
424
|
+
Reasoning: ${result.reasoning}
|
|
425
|
+
Alternatives: ${result.alternatives.join(', ')}`;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
async listMcpTools(): Promise<string> {
|
|
429
|
+
if (!this.orchestrator) {
|
|
430
|
+
return 'agentic-flow not enabled';
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const tools = await this.orchestrator.getAvailableTools();
|
|
434
|
+
return `Available MCP Tools (${tools.length}/213):\n${tools.join('\n')}`;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// ===== ADVANCED TOOLS =====
|
|
438
|
+
|
|
439
|
+
async queryWithReasoning(params: {
|
|
440
|
+
query: string;
|
|
441
|
+
k?: number;
|
|
442
|
+
domain?: string;
|
|
443
|
+
}): Promise<string> {
|
|
444
|
+
const result = await this.memory.queryWithContext(params.query, {
|
|
445
|
+
k: params.k || 5,
|
|
446
|
+
domain: params.domain,
|
|
447
|
+
synthesizeReasoning: true,
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
return `Query Results:
|
|
451
|
+
Memories: ${result.memories.length} found
|
|
452
|
+
Context: ${result.context}
|
|
453
|
+
Causal Reasoning: ${result.reasoning}
|
|
454
|
+
|
|
455
|
+
Details:
|
|
456
|
+
${JSON.stringify(result.memories, null, 2)}`;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
async benchmark(params?: { iterations?: number }): Promise<string> {
|
|
460
|
+
const { iterations = 100 } = params || {};
|
|
461
|
+
|
|
462
|
+
const start = Date.now();
|
|
463
|
+
|
|
464
|
+
// Quick benchmark
|
|
465
|
+
const storePromises = [];
|
|
466
|
+
for (let i = 0; i < iterations; i++) {
|
|
467
|
+
storePromises.push(
|
|
468
|
+
this.memory.storeEpisode({
|
|
469
|
+
sessionId: `bench-${i}`,
|
|
470
|
+
taskName: 'test',
|
|
471
|
+
confidence: 0.9,
|
|
472
|
+
success: true,
|
|
473
|
+
outcome: 'test',
|
|
474
|
+
})
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
await Promise.all(storePromises);
|
|
478
|
+
|
|
479
|
+
const storeTime = Date.now() - start;
|
|
480
|
+
|
|
481
|
+
const retrieveStart = Date.now();
|
|
482
|
+
for (let i = 0; i < iterations; i++) {
|
|
483
|
+
await this.memory.retrieveMemories('test', 5);
|
|
484
|
+
}
|
|
485
|
+
const retrieveTime = Date.now() - retrieveStart;
|
|
486
|
+
|
|
487
|
+
return `Benchmark Results (${iterations} iterations):
|
|
488
|
+
Store: ${(storeTime / iterations).toFixed(3)}ms avg
|
|
489
|
+
Retrieve: ${(retrieveTime / iterations).toFixed(3)}ms avg
|
|
490
|
+
Total: ${storeTime + retrieveTime}ms`;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// Get server info
|
|
494
|
+
getInfo() {
|
|
495
|
+
const tools = [
|
|
496
|
+
'move_robot', 'get_pose', 'get_status',
|
|
497
|
+
'read_lidar', 'detect_objects',
|
|
498
|
+
'query_memory', 'search_skills', 'consolidate_skills',
|
|
499
|
+
'get_memory_stats', 'optimize_memory',
|
|
500
|
+
'query_with_reasoning', 'benchmark',
|
|
501
|
+
];
|
|
502
|
+
|
|
503
|
+
if (this.config.enableFlow) {
|
|
504
|
+
tools.push(
|
|
505
|
+
'execute_task', 'execute_swarm', 'coordinate_robots',
|
|
506
|
+
'reason_about_task', 'list_mcp_tools'
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
return {
|
|
511
|
+
name: this.name,
|
|
512
|
+
version: this.version,
|
|
513
|
+
tools,
|
|
514
|
+
features: {
|
|
515
|
+
agentdb: true,
|
|
516
|
+
agenticFlow: this.config.enableFlow,
|
|
517
|
+
numAgents: this.config.numAgents,
|
|
518
|
+
reasoningEnabled: this.config.enableReasoning,
|
|
519
|
+
learningEnabled: this.config.enableLearning,
|
|
520
|
+
},
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
}
|