@sparkleideas/ruv-swarm 1.0.18-patch.1
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 +1565 -0
- package/bin/ruv-swarm-clean.js +1872 -0
- package/bin/ruv-swarm-memory.js +119 -0
- package/bin/ruv-swarm-secure-heartbeat.js +1549 -0
- package/bin/ruv-swarm-secure.js +1689 -0
- package/package.json +221 -0
- package/src/agent.ts +342 -0
- package/src/benchmark.js +267 -0
- package/src/claude-flow-enhanced.js +839 -0
- package/src/claude-integration/advanced-commands.js +561 -0
- package/src/claude-integration/core.js +112 -0
- package/src/claude-integration/docs.js +1548 -0
- package/src/claude-integration/env-template.js +39 -0
- package/src/claude-integration/index.js +209 -0
- package/src/claude-integration/remote.js +408 -0
- package/src/cli-diagnostics.js +364 -0
- package/src/cognitive-pattern-evolution.js +1317 -0
- package/src/daa-cognition.js +977 -0
- package/src/daa-service.d.ts +298 -0
- package/src/daa-service.js +1116 -0
- package/src/diagnostics.js +533 -0
- package/src/errors.js +528 -0
- package/src/github-coordinator/README.md +193 -0
- package/src/github-coordinator/claude-hooks.js +162 -0
- package/src/github-coordinator/gh-cli-coordinator.js +260 -0
- package/src/hooks/cli.js +82 -0
- package/src/hooks/index.js +1900 -0
- package/src/index-enhanced.d.ts +371 -0
- package/src/index-enhanced.js +734 -0
- package/src/index.d.ts +287 -0
- package/src/index.js +405 -0
- package/src/index.ts +457 -0
- package/src/logger.js +182 -0
- package/src/logging-config.js +179 -0
- package/src/mcp-daa-tools.js +735 -0
- package/src/mcp-tools-benchmarks.js +328 -0
- package/src/mcp-tools-enhanced.js +2863 -0
- package/src/memory-config.js +42 -0
- package/src/meta-learning-framework.js +1359 -0
- package/src/neural-agent.js +830 -0
- package/src/neural-coordination-protocol.js +1363 -0
- package/src/neural-models/README.md +118 -0
- package/src/neural-models/autoencoder.js +543 -0
- package/src/neural-models/base.js +269 -0
- package/src/neural-models/cnn.js +497 -0
- package/src/neural-models/gnn.js +447 -0
- package/src/neural-models/gru.js +536 -0
- package/src/neural-models/index.js +273 -0
- package/src/neural-models/lstm.js +551 -0
- package/src/neural-models/neural-presets-complete.js +1306 -0
- package/src/neural-models/presets/graph.js +392 -0
- package/src/neural-models/presets/index.js +279 -0
- package/src/neural-models/presets/nlp.js +328 -0
- package/src/neural-models/presets/timeseries.js +368 -0
- package/src/neural-models/presets/vision.js +387 -0
- package/src/neural-models/resnet.js +534 -0
- package/src/neural-models/transformer.js +515 -0
- package/src/neural-models/vae.js +489 -0
- package/src/neural-network-manager.js +1938 -0
- package/src/neural-network.ts +296 -0
- package/src/neural.js +574 -0
- package/src/performance-benchmarks.js +898 -0
- package/src/performance.js +458 -0
- package/src/persistence-pooled.js +695 -0
- package/src/persistence.js +480 -0
- package/src/schemas.js +864 -0
- package/src/security.js +218 -0
- package/src/singleton-container.js +183 -0
- package/src/sqlite-pool.js +587 -0
- package/src/sqlite-worker.js +141 -0
- package/src/types.ts +164 -0
- package/src/utils.ts +286 -0
- package/src/wasm-loader.js +601 -0
- package/src/wasm-loader2.js +404 -0
- package/src/wasm-memory-optimizer.js +783 -0
- package/src/wasm-types.d.ts +63 -0
- package/wasm/README.md +347 -0
- package/wasm/neuro-divergent.wasm +0 -0
- package/wasm/package.json +18 -0
- package/wasm/ruv-fann.wasm +0 -0
- package/wasm/ruv_swarm_simd.wasm +0 -0
- package/wasm/ruv_swarm_wasm.d.ts +391 -0
- package/wasm/ruv_swarm_wasm.js +2164 -0
- package/wasm/ruv_swarm_wasm_bg.wasm +0 -0
- package/wasm/ruv_swarm_wasm_bg.wasm.d.ts +123 -0
- package/wasm/wasm-bindings-loader.mjs +435 -0
- package/wasm/wasm-updates.md +684 -0
|
@@ -0,0 +1,735 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DAA (Decentralized Autonomous Agents) MCP Tools
|
|
3
|
+
* Exposes DAA capabilities through the MCP interface
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { daaService } from './daa-service.js';
|
|
7
|
+
|
|
8
|
+
export class DAA_MCPTools {
|
|
9
|
+
constructor(enhancedMcpTools) {
|
|
10
|
+
this.mcpTools = enhancedMcpTools;
|
|
11
|
+
this.daaInitialized = false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async ensureInitialized() {
|
|
15
|
+
if (!this.daaInitialized) {
|
|
16
|
+
await daaService.initialize();
|
|
17
|
+
this.daaInitialized = true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* DAA MCP Tool: daa_init
|
|
23
|
+
* Initialize the DAA service with autonomous agent capabilities
|
|
24
|
+
*/
|
|
25
|
+
async daa_init(params) {
|
|
26
|
+
const startTime = performance.now();
|
|
27
|
+
try {
|
|
28
|
+
await this.ensureInitialized();
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
enableLearning = true,
|
|
32
|
+
enableCoordination = true,
|
|
33
|
+
persistenceMode = 'auto',
|
|
34
|
+
} = params;
|
|
35
|
+
|
|
36
|
+
const result = {
|
|
37
|
+
success: true,
|
|
38
|
+
initialized: true,
|
|
39
|
+
features: {
|
|
40
|
+
autonomousLearning: enableLearning,
|
|
41
|
+
peerCoordination: enableCoordination,
|
|
42
|
+
persistenceMode,
|
|
43
|
+
neuralIntegration: true,
|
|
44
|
+
cognitivePatterns: 6,
|
|
45
|
+
},
|
|
46
|
+
capabilities: daaService.getCapabilities(),
|
|
47
|
+
timestamp: new Date().toISOString(),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
51
|
+
this.mcpTools.recordToolMetrics('daa_init', startTime, 'success');
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
56
|
+
this.mcpTools.recordToolMetrics('daa_init', startTime, 'error', error.message);
|
|
57
|
+
}
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* DAA MCP Tool: daa_agent_create
|
|
64
|
+
* Create an autonomous agent with DAA capabilities
|
|
65
|
+
*/
|
|
66
|
+
async daa_agent_create(params) {
|
|
67
|
+
const startTime = performance.now();
|
|
68
|
+
try {
|
|
69
|
+
await this.ensureInitialized();
|
|
70
|
+
|
|
71
|
+
const {
|
|
72
|
+
id,
|
|
73
|
+
capabilities = [],
|
|
74
|
+
cognitivePattern = 'adaptive',
|
|
75
|
+
learningRate = 0.001,
|
|
76
|
+
enableMemory = true,
|
|
77
|
+
} = params;
|
|
78
|
+
|
|
79
|
+
if (!id) {
|
|
80
|
+
throw new Error('Agent ID is required');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const agent = await daaService.createAgent({
|
|
84
|
+
id,
|
|
85
|
+
capabilities,
|
|
86
|
+
cognitivePattern,
|
|
87
|
+
config: {
|
|
88
|
+
learningRate,
|
|
89
|
+
enableMemory,
|
|
90
|
+
autonomousMode: true,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Find or create a swarm for the agent
|
|
95
|
+
let swarmId = null;
|
|
96
|
+
if (this.mcpTools?.activeSwarms) {
|
|
97
|
+
for (const [id, swarm] of this.mcpTools.activeSwarms) {
|
|
98
|
+
if (swarm.agents.size < swarm.maxAgents) {
|
|
99
|
+
swarmId = id;
|
|
100
|
+
swarm.agents.set(agent.id, agent);
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
// Create a virtual swarm if none exists
|
|
106
|
+
swarmId = 'daa-default-swarm';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Persist DAA agent to database
|
|
110
|
+
if (this.mcpTools?.persistence) {
|
|
111
|
+
try {
|
|
112
|
+
await this.mcpTools.persistence.createAgent({
|
|
113
|
+
id: agent.id,
|
|
114
|
+
swarmId: swarmId || 'daa-default-swarm',
|
|
115
|
+
name: `DAA-${agent.id}`,
|
|
116
|
+
type: 'daa',
|
|
117
|
+
capabilities: Array.from(agent.capabilities || capabilities),
|
|
118
|
+
neuralConfig: {
|
|
119
|
+
cognitivePattern: agent.cognitivePattern || cognitivePattern,
|
|
120
|
+
learningRate,
|
|
121
|
+
enableMemory,
|
|
122
|
+
daaEnabled: true,
|
|
123
|
+
},
|
|
124
|
+
metadata: {
|
|
125
|
+
createdAt: new Date().toISOString(),
|
|
126
|
+
autonomousMode: true,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
this.mcpTools.logger?.info('DAA agent persisted successfully', {
|
|
131
|
+
agentId: agent.id,
|
|
132
|
+
swarmId,
|
|
133
|
+
});
|
|
134
|
+
} catch (persistError) {
|
|
135
|
+
this.mcpTools.logger?.warn('Failed to persist DAA agent', {
|
|
136
|
+
agentId: agent.id,
|
|
137
|
+
error: persistError.message,
|
|
138
|
+
});
|
|
139
|
+
// Continue execution even if persistence fails
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const result = {
|
|
144
|
+
agent: {
|
|
145
|
+
id: agent.id,
|
|
146
|
+
cognitive_pattern: agent.cognitivePattern || cognitivePattern,
|
|
147
|
+
capabilities: Array.from(agent.capabilities || capabilities),
|
|
148
|
+
status: 'active',
|
|
149
|
+
created_at: new Date().toISOString(),
|
|
150
|
+
},
|
|
151
|
+
swarm_id: swarmId,
|
|
152
|
+
learning_enabled: learningRate > 0,
|
|
153
|
+
memory_enabled: enableMemory,
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
157
|
+
this.mcpTools.recordToolMetrics('daa_agent_create', startTime, 'success');
|
|
158
|
+
}
|
|
159
|
+
return result;
|
|
160
|
+
} catch (error) {
|
|
161
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
162
|
+
this.mcpTools.recordToolMetrics('daa_agent_create', startTime, 'error', error.message);
|
|
163
|
+
}
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* DAA MCP Tool: daa_agent_adapt
|
|
170
|
+
* Trigger agent adaptation based on feedback
|
|
171
|
+
*/
|
|
172
|
+
async daa_agent_adapt(params) {
|
|
173
|
+
const startTime = performance.now();
|
|
174
|
+
try {
|
|
175
|
+
await this.ensureInitialized();
|
|
176
|
+
|
|
177
|
+
const {
|
|
178
|
+
agent_id,
|
|
179
|
+
agentId,
|
|
180
|
+
feedback,
|
|
181
|
+
performanceScore = 0.5,
|
|
182
|
+
suggestions = [],
|
|
183
|
+
} = params;
|
|
184
|
+
|
|
185
|
+
const id = agent_id || agentId;
|
|
186
|
+
if (!id) {
|
|
187
|
+
throw new Error('Agent ID is required');
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const adaptationResult = await daaService.adaptAgent(id, {
|
|
191
|
+
feedback,
|
|
192
|
+
performanceScore,
|
|
193
|
+
suggestions,
|
|
194
|
+
timestamp: new Date().toISOString(),
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
const result = {
|
|
198
|
+
agent_id: id,
|
|
199
|
+
adaptation_complete: true,
|
|
200
|
+
previous_pattern: adaptationResult.previousPattern,
|
|
201
|
+
new_pattern: adaptationResult.newPattern,
|
|
202
|
+
performance_improvement: adaptationResult.improvement,
|
|
203
|
+
learning_insights: adaptationResult.insights,
|
|
204
|
+
timestamp: new Date().toISOString(),
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
208
|
+
this.mcpTools.recordToolMetrics('daa_agent_adapt', startTime, 'success');
|
|
209
|
+
}
|
|
210
|
+
return result;
|
|
211
|
+
} catch (error) {
|
|
212
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
213
|
+
this.mcpTools.recordToolMetrics('daa_agent_adapt', startTime, 'error', error.message);
|
|
214
|
+
}
|
|
215
|
+
throw error;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* DAA MCP Tool: daa_workflow_create
|
|
221
|
+
* Create an autonomous workflow with DAA coordination
|
|
222
|
+
*/
|
|
223
|
+
async daa_workflow_create(params) {
|
|
224
|
+
const startTime = performance.now();
|
|
225
|
+
try {
|
|
226
|
+
await this.ensureInitialized();
|
|
227
|
+
|
|
228
|
+
const {
|
|
229
|
+
id,
|
|
230
|
+
name,
|
|
231
|
+
steps = [],
|
|
232
|
+
dependencies = {},
|
|
233
|
+
strategy = 'parallel',
|
|
234
|
+
} = params;
|
|
235
|
+
|
|
236
|
+
if (!id || !name) {
|
|
237
|
+
throw new Error('Workflow ID and name are required');
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const workflow = await daaService.createWorkflow(id, steps, dependencies);
|
|
241
|
+
|
|
242
|
+
const result = {
|
|
243
|
+
workflow_id: workflow.id,
|
|
244
|
+
name,
|
|
245
|
+
total_steps: workflow.steps.length,
|
|
246
|
+
execution_strategy: strategy,
|
|
247
|
+
dependencies_count: Object.keys(workflow.dependencies).length,
|
|
248
|
+
status: workflow.status,
|
|
249
|
+
created_at: new Date().toISOString(),
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
253
|
+
this.mcpTools.recordToolMetrics('daa_workflow_create', startTime, 'success');
|
|
254
|
+
}
|
|
255
|
+
return result;
|
|
256
|
+
} catch (error) {
|
|
257
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
258
|
+
this.mcpTools.recordToolMetrics('daa_workflow_create', startTime, 'error', error.message);
|
|
259
|
+
}
|
|
260
|
+
throw error;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* DAA MCP Tool: daa_workflow_execute
|
|
266
|
+
* Execute a DAA workflow with autonomous agents
|
|
267
|
+
*/
|
|
268
|
+
async daa_workflow_execute(params) {
|
|
269
|
+
const startTime = performance.now();
|
|
270
|
+
try {
|
|
271
|
+
await this.ensureInitialized();
|
|
272
|
+
|
|
273
|
+
const {
|
|
274
|
+
workflow_id,
|
|
275
|
+
workflowId,
|
|
276
|
+
agentIds = [],
|
|
277
|
+
parallelExecution = true,
|
|
278
|
+
} = params;
|
|
279
|
+
|
|
280
|
+
const id = workflow_id || workflowId;
|
|
281
|
+
if (!id) {
|
|
282
|
+
throw new Error('Workflow ID is required');
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const executionResult = await daaService.executeWorkflow(id, {
|
|
286
|
+
agentIds,
|
|
287
|
+
parallel: parallelExecution,
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
const result = {
|
|
291
|
+
workflow_id: id,
|
|
292
|
+
execution_complete: executionResult.complete,
|
|
293
|
+
steps_completed: executionResult.stepsCompleted,
|
|
294
|
+
total_steps: executionResult.totalSteps,
|
|
295
|
+
execution_time_ms: executionResult.executionTime,
|
|
296
|
+
agents_involved: executionResult.agentsInvolved,
|
|
297
|
+
results: executionResult.stepResults,
|
|
298
|
+
timestamp: new Date().toISOString(),
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
302
|
+
this.mcpTools.recordToolMetrics('daa_workflow_execute', startTime, 'success');
|
|
303
|
+
}
|
|
304
|
+
return result;
|
|
305
|
+
} catch (error) {
|
|
306
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
307
|
+
this.mcpTools.recordToolMetrics('daa_workflow_execute', startTime, 'error', error.message);
|
|
308
|
+
}
|
|
309
|
+
throw error;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* DAA MCP Tool: daa_knowledge_share
|
|
315
|
+
* Share knowledge between autonomous agents
|
|
316
|
+
*/
|
|
317
|
+
async daa_knowledge_share(params) {
|
|
318
|
+
const startTime = performance.now();
|
|
319
|
+
try {
|
|
320
|
+
await this.ensureInitialized();
|
|
321
|
+
|
|
322
|
+
const {
|
|
323
|
+
source_agent,
|
|
324
|
+
sourceAgentId,
|
|
325
|
+
target_agents,
|
|
326
|
+
targetAgentIds,
|
|
327
|
+
knowledgeDomain,
|
|
328
|
+
knowledgeContent,
|
|
329
|
+
} = params;
|
|
330
|
+
|
|
331
|
+
const sourceId = source_agent || sourceAgentId;
|
|
332
|
+
const targetIds = target_agents || targetAgentIds || [];
|
|
333
|
+
|
|
334
|
+
if (!sourceId || targetIds.length === 0) {
|
|
335
|
+
throw new Error('Source and target agent IDs are required');
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
const sharingResults = await daaService.shareKnowledge(
|
|
339
|
+
sourceId,
|
|
340
|
+
targetIds,
|
|
341
|
+
{
|
|
342
|
+
domain: knowledgeDomain,
|
|
343
|
+
content: knowledgeContent,
|
|
344
|
+
timestamp: new Date().toISOString(),
|
|
345
|
+
},
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
const result = {
|
|
349
|
+
source_agent: sourceId,
|
|
350
|
+
target_agents: targetIds,
|
|
351
|
+
knowledge_domain: knowledgeDomain,
|
|
352
|
+
sharing_complete: true,
|
|
353
|
+
agents_updated: sharingResults.updatedAgents,
|
|
354
|
+
knowledge_transfer_rate: sharingResults.transferRate,
|
|
355
|
+
timestamp: new Date().toISOString(),
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
359
|
+
this.mcpTools.recordToolMetrics('daa_knowledge_share', startTime, 'success');
|
|
360
|
+
}
|
|
361
|
+
return result;
|
|
362
|
+
} catch (error) {
|
|
363
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
364
|
+
this.mcpTools.recordToolMetrics('daa_knowledge_share', startTime, 'error', error.message);
|
|
365
|
+
}
|
|
366
|
+
throw error;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* DAA MCP Tool: daa_learning_status
|
|
372
|
+
* Get learning progress and status for DAA agents
|
|
373
|
+
*/
|
|
374
|
+
async daa_learning_status(params) {
|
|
375
|
+
const startTime = performance.now();
|
|
376
|
+
try {
|
|
377
|
+
await this.ensureInitialized();
|
|
378
|
+
|
|
379
|
+
const { agentId, detailed = false } = params;
|
|
380
|
+
|
|
381
|
+
let learningStatus;
|
|
382
|
+
if (agentId) {
|
|
383
|
+
// Get specific agent learning status
|
|
384
|
+
learningStatus = await daaService.getAgentLearningStatus(agentId);
|
|
385
|
+
} else {
|
|
386
|
+
// Get overall system learning status
|
|
387
|
+
learningStatus = await daaService.getSystemLearningStatus();
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const result = {
|
|
391
|
+
agent_id: agentId || 'all',
|
|
392
|
+
total_learning_cycles: learningStatus.totalCycles,
|
|
393
|
+
average_proficiency: learningStatus.avgProficiency,
|
|
394
|
+
knowledge_domains: learningStatus.domains,
|
|
395
|
+
adaptation_rate: learningStatus.adaptationRate,
|
|
396
|
+
neural_models_active: learningStatus.neuralModelsCount,
|
|
397
|
+
cross_session_memory: learningStatus.persistentMemorySize,
|
|
398
|
+
performance_trend: learningStatus.performanceTrend,
|
|
399
|
+
timestamp: new Date().toISOString(),
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
if (detailed) {
|
|
403
|
+
result.detailed_metrics = learningStatus.detailedMetrics;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
407
|
+
this.mcpTools.recordToolMetrics('daa_learning_status', startTime, 'success');
|
|
408
|
+
}
|
|
409
|
+
return result;
|
|
410
|
+
} catch (error) {
|
|
411
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
412
|
+
this.mcpTools.recordToolMetrics('daa_learning_status', startTime, 'error', error.message);
|
|
413
|
+
}
|
|
414
|
+
throw error;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* DAA MCP Tool: daa_cognitive_pattern
|
|
420
|
+
* Analyze or change cognitive patterns for agents
|
|
421
|
+
*/
|
|
422
|
+
async daa_cognitive_pattern(params) {
|
|
423
|
+
const startTime = performance.now();
|
|
424
|
+
try {
|
|
425
|
+
await this.ensureInitialized();
|
|
426
|
+
|
|
427
|
+
const {
|
|
428
|
+
agent_id,
|
|
429
|
+
agentId,
|
|
430
|
+
pattern,
|
|
431
|
+
action,
|
|
432
|
+
analyze = false,
|
|
433
|
+
} = params;
|
|
434
|
+
|
|
435
|
+
const id = agent_id || agentId;
|
|
436
|
+
const shouldAnalyze = action === 'analyze' || analyze;
|
|
437
|
+
|
|
438
|
+
if (shouldAnalyze) {
|
|
439
|
+
// Analyze current cognitive patterns
|
|
440
|
+
const analysis = await daaService.analyzeCognitivePatterns(agentId);
|
|
441
|
+
const result = {
|
|
442
|
+
analysis_type: 'cognitive_pattern',
|
|
443
|
+
agent_id: id || 'all',
|
|
444
|
+
current_patterns: analysis.patterns,
|
|
445
|
+
pattern_effectiveness: analysis.effectiveness,
|
|
446
|
+
recommendations: analysis.recommendations,
|
|
447
|
+
optimization_potential: analysis.optimizationScore,
|
|
448
|
+
timestamp: new Date().toISOString(),
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
452
|
+
this.mcpTools.recordToolMetrics('daa_cognitive_pattern', startTime, 'success');
|
|
453
|
+
}
|
|
454
|
+
return result;
|
|
455
|
+
}
|
|
456
|
+
// Change cognitive pattern
|
|
457
|
+
if (!agentId || !pattern) {
|
|
458
|
+
throw new Error('Agent ID and pattern are required for pattern change');
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
const changeResult = await daaService.setCognitivePattern(agentId, pattern);
|
|
462
|
+
|
|
463
|
+
const result = {
|
|
464
|
+
agent_id: agentId,
|
|
465
|
+
previous_pattern: changeResult.previousPattern,
|
|
466
|
+
new_pattern: pattern,
|
|
467
|
+
adaptation_success: changeResult.success,
|
|
468
|
+
expected_improvement: changeResult.expectedImprovement,
|
|
469
|
+
timestamp: new Date().toISOString(),
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
473
|
+
this.mcpTools.recordToolMetrics('daa_cognitive_pattern', startTime, 'success');
|
|
474
|
+
}
|
|
475
|
+
return result;
|
|
476
|
+
|
|
477
|
+
} catch (error) {
|
|
478
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
479
|
+
this.mcpTools.recordToolMetrics('daa_cognitive_pattern', startTime, 'error', error.message);
|
|
480
|
+
}
|
|
481
|
+
throw error;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* DAA MCP Tool: daa_meta_learning
|
|
487
|
+
* Enable meta-learning capabilities across domains
|
|
488
|
+
*/
|
|
489
|
+
async daa_meta_learning(params) {
|
|
490
|
+
const startTime = performance.now();
|
|
491
|
+
try {
|
|
492
|
+
await this.ensureInitialized();
|
|
493
|
+
|
|
494
|
+
const {
|
|
495
|
+
sourceDomain,
|
|
496
|
+
targetDomain,
|
|
497
|
+
transferMode = 'adaptive',
|
|
498
|
+
agentIds = [],
|
|
499
|
+
} = params;
|
|
500
|
+
|
|
501
|
+
const metaLearningResult = await daaService.performMetaLearning({
|
|
502
|
+
sourceDomain,
|
|
503
|
+
targetDomain,
|
|
504
|
+
transferMode,
|
|
505
|
+
agentIds: agentIds.length > 0 ? agentIds : undefined,
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
const result = {
|
|
509
|
+
meta_learning_complete: true,
|
|
510
|
+
source_domain: sourceDomain,
|
|
511
|
+
target_domain: targetDomain,
|
|
512
|
+
transfer_mode: transferMode,
|
|
513
|
+
knowledge_transferred: metaLearningResult.knowledgeItems,
|
|
514
|
+
agents_updated: metaLearningResult.updatedAgents,
|
|
515
|
+
domain_proficiency_gain: metaLearningResult.proficiencyGain,
|
|
516
|
+
cross_domain_insights: metaLearningResult.insights,
|
|
517
|
+
timestamp: new Date().toISOString(),
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
521
|
+
this.mcpTools.recordToolMetrics('daa_meta_learning', startTime, 'success');
|
|
522
|
+
}
|
|
523
|
+
return result;
|
|
524
|
+
} catch (error) {
|
|
525
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
526
|
+
this.mcpTools.recordToolMetrics('daa_meta_learning', startTime, 'error', error.message);
|
|
527
|
+
}
|
|
528
|
+
throw error;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* DAA MCP Tool: daa_performance_metrics
|
|
534
|
+
* Get comprehensive DAA performance metrics
|
|
535
|
+
*/
|
|
536
|
+
async daa_performance_metrics(params) {
|
|
537
|
+
const startTime = performance.now();
|
|
538
|
+
try {
|
|
539
|
+
await this.ensureInitialized();
|
|
540
|
+
|
|
541
|
+
const { category = 'all', timeRange = '1h' } = params;
|
|
542
|
+
|
|
543
|
+
const metrics = await daaService.getPerformanceMetrics({
|
|
544
|
+
category,
|
|
545
|
+
timeRange,
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
const result = {
|
|
549
|
+
metrics_category: category,
|
|
550
|
+
time_range: timeRange,
|
|
551
|
+
system_metrics: {
|
|
552
|
+
total_agents: metrics.totalAgents,
|
|
553
|
+
active_agents: metrics.activeAgents,
|
|
554
|
+
autonomous_tasks_completed: metrics.tasksCompleted,
|
|
555
|
+
average_task_time_ms: metrics.avgTaskTime,
|
|
556
|
+
learning_cycles_completed: metrics.learningCycles,
|
|
557
|
+
},
|
|
558
|
+
performance_metrics: {
|
|
559
|
+
task_success_rate: metrics.successRate,
|
|
560
|
+
adaptation_effectiveness: metrics.adaptationScore,
|
|
561
|
+
knowledge_sharing_events: metrics.knowledgeSharingCount,
|
|
562
|
+
cross_domain_transfers: metrics.crossDomainTransfers,
|
|
563
|
+
},
|
|
564
|
+
efficiency_metrics: {
|
|
565
|
+
token_reduction: metrics.tokenReduction,
|
|
566
|
+
parallel_execution_gain: metrics.parallelGain,
|
|
567
|
+
memory_optimization: metrics.memoryOptimization,
|
|
568
|
+
},
|
|
569
|
+
neural_metrics: {
|
|
570
|
+
models_active: metrics.neuralModelsActive,
|
|
571
|
+
inference_speed_ms: metrics.avgInferenceTime,
|
|
572
|
+
training_iterations: metrics.totalTrainingIterations,
|
|
573
|
+
},
|
|
574
|
+
timestamp: new Date().toISOString(),
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
578
|
+
this.mcpTools.recordToolMetrics('daa_performance_metrics', startTime, 'success');
|
|
579
|
+
}
|
|
580
|
+
return result;
|
|
581
|
+
} catch (error) {
|
|
582
|
+
if (this.mcpTools?.recordToolMetrics) {
|
|
583
|
+
this.mcpTools.recordToolMetrics('daa_performance_metrics', startTime, 'error', error.message);
|
|
584
|
+
}
|
|
585
|
+
throw error;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Get all DAA tool definitions for MCP
|
|
591
|
+
*/
|
|
592
|
+
getToolDefinitions() {
|
|
593
|
+
return [
|
|
594
|
+
{
|
|
595
|
+
name: 'daa_init',
|
|
596
|
+
description: 'Initialize DAA (Decentralized Autonomous Agents) service',
|
|
597
|
+
inputSchema: {
|
|
598
|
+
type: 'object',
|
|
599
|
+
properties: {
|
|
600
|
+
enableLearning: { type: 'boolean', description: 'Enable autonomous learning' },
|
|
601
|
+
enableCoordination: { type: 'boolean', description: 'Enable peer coordination' },
|
|
602
|
+
persistenceMode: { type: 'string', enum: ['auto', 'memory', 'disk'], description: 'Persistence mode' },
|
|
603
|
+
},
|
|
604
|
+
},
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
name: 'daa_agent_create',
|
|
608
|
+
description: 'Create an autonomous agent with DAA capabilities',
|
|
609
|
+
inputSchema: {
|
|
610
|
+
type: 'object',
|
|
611
|
+
properties: {
|
|
612
|
+
id: { type: 'string', description: 'Unique agent identifier' },
|
|
613
|
+
capabilities: { type: 'array', items: { type: 'string' }, description: 'Agent capabilities' },
|
|
614
|
+
cognitivePattern: { type: 'string', enum: ['convergent', 'divergent', 'lateral', 'systems', 'critical', 'adaptive'], description: 'Cognitive thinking pattern' },
|
|
615
|
+
learningRate: { type: 'number', description: 'Learning rate (0-1)' },
|
|
616
|
+
enableMemory: { type: 'boolean', description: 'Enable persistent memory' },
|
|
617
|
+
},
|
|
618
|
+
required: ['id'],
|
|
619
|
+
},
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
name: 'daa_agent_adapt',
|
|
623
|
+
description: 'Trigger agent adaptation based on feedback',
|
|
624
|
+
inputSchema: {
|
|
625
|
+
type: 'object',
|
|
626
|
+
properties: {
|
|
627
|
+
agent_id: { type: 'string', description: 'Agent ID to adapt' },
|
|
628
|
+
agentId: { type: 'string', description: 'Agent ID to adapt (legacy)' },
|
|
629
|
+
feedback: { type: 'string', description: 'Feedback message' },
|
|
630
|
+
performanceScore: { type: 'number', description: 'Performance score (0-1)' },
|
|
631
|
+
suggestions: { type: 'array', items: { type: 'string' }, description: 'Improvement suggestions' },
|
|
632
|
+
},
|
|
633
|
+
required: ['agentId'],
|
|
634
|
+
},
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
name: 'daa_workflow_create',
|
|
638
|
+
description: 'Create an autonomous workflow with DAA coordination',
|
|
639
|
+
inputSchema: {
|
|
640
|
+
type: 'object',
|
|
641
|
+
properties: {
|
|
642
|
+
id: { type: 'string', description: 'Workflow ID' },
|
|
643
|
+
name: { type: 'string', description: 'Workflow name' },
|
|
644
|
+
steps: { type: 'array', description: 'Workflow steps' },
|
|
645
|
+
dependencies: { type: 'object', description: 'Step dependencies' },
|
|
646
|
+
strategy: { type: 'string', enum: ['parallel', 'sequential', 'adaptive'], description: 'Execution strategy' },
|
|
647
|
+
},
|
|
648
|
+
required: ['id', 'name'],
|
|
649
|
+
},
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
name: 'daa_workflow_execute',
|
|
653
|
+
description: 'Execute a DAA workflow with autonomous agents',
|
|
654
|
+
inputSchema: {
|
|
655
|
+
type: 'object',
|
|
656
|
+
properties: {
|
|
657
|
+
workflow_id: { type: 'string', description: 'Workflow ID to execute' },
|
|
658
|
+
workflowId: { type: 'string', description: 'Workflow ID to execute (legacy)' },
|
|
659
|
+
agentIds: { type: 'array', items: { type: 'string' }, description: 'Agent IDs to use' },
|
|
660
|
+
parallelExecution: { type: 'boolean', description: 'Enable parallel execution' },
|
|
661
|
+
},
|
|
662
|
+
required: ['workflowId'],
|
|
663
|
+
},
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
name: 'daa_knowledge_share',
|
|
667
|
+
description: 'Share knowledge between autonomous agents',
|
|
668
|
+
inputSchema: {
|
|
669
|
+
type: 'object',
|
|
670
|
+
properties: {
|
|
671
|
+
source_agent: { type: 'string', description: 'Source agent ID' },
|
|
672
|
+
sourceAgentId: { type: 'string', description: 'Source agent ID (legacy)' },
|
|
673
|
+
target_agents: { type: 'array', items: { type: 'string' }, description: 'Target agent IDs' },
|
|
674
|
+
targetAgentIds: { type: 'array', items: { type: 'string' }, description: 'Target agent IDs (legacy)' },
|
|
675
|
+
knowledgeDomain: { type: 'string', description: 'Knowledge domain' },
|
|
676
|
+
knowledgeContent: { type: 'object', description: 'Knowledge to share' },
|
|
677
|
+
},
|
|
678
|
+
required: ['sourceAgentId', 'targetAgentIds'],
|
|
679
|
+
},
|
|
680
|
+
},
|
|
681
|
+
{
|
|
682
|
+
name: 'daa_learning_status',
|
|
683
|
+
description: 'Get learning progress and status for DAA agents',
|
|
684
|
+
inputSchema: {
|
|
685
|
+
type: 'object',
|
|
686
|
+
properties: {
|
|
687
|
+
agentId: { type: 'string', description: 'Specific agent ID (optional)' },
|
|
688
|
+
detailed: { type: 'boolean', description: 'Include detailed metrics' },
|
|
689
|
+
},
|
|
690
|
+
},
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
name: 'daa_cognitive_pattern',
|
|
694
|
+
description: 'Analyze or change cognitive patterns for agents',
|
|
695
|
+
inputSchema: {
|
|
696
|
+
type: 'object',
|
|
697
|
+
properties: {
|
|
698
|
+
agent_id: { type: 'string', description: 'Agent ID' },
|
|
699
|
+
agentId: { type: 'string', description: 'Agent ID (legacy)' },
|
|
700
|
+
action: { type: 'string', enum: ['analyze', 'change'], description: 'Action to perform' },
|
|
701
|
+
pattern: { type: 'string', enum: ['convergent', 'divergent', 'lateral', 'systems', 'critical', 'adaptive'], description: 'New pattern to set' },
|
|
702
|
+
analyze: { type: 'boolean', description: 'Analyze patterns instead of changing' },
|
|
703
|
+
},
|
|
704
|
+
},
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
name: 'daa_meta_learning',
|
|
708
|
+
description: 'Enable meta-learning capabilities across domains',
|
|
709
|
+
inputSchema: {
|
|
710
|
+
type: 'object',
|
|
711
|
+
properties: {
|
|
712
|
+
sourceDomain: { type: 'string', description: 'Source knowledge domain' },
|
|
713
|
+
targetDomain: { type: 'string', description: 'Target knowledge domain' },
|
|
714
|
+
transferMode: { type: 'string', enum: ['adaptive', 'direct', 'gradual'], description: 'Transfer mode' },
|
|
715
|
+
agentIds: { type: 'array', items: { type: 'string' }, description: 'Specific agents to update' },
|
|
716
|
+
},
|
|
717
|
+
},
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
name: 'daa_performance_metrics',
|
|
721
|
+
description: 'Get comprehensive DAA performance metrics',
|
|
722
|
+
inputSchema: {
|
|
723
|
+
type: 'object',
|
|
724
|
+
properties: {
|
|
725
|
+
category: { type: 'string', enum: ['all', 'system', 'performance', 'efficiency', 'neural'], description: 'Metrics category' },
|
|
726
|
+
timeRange: { type: 'string', description: 'Time range (e.g., 1h, 24h, 7d)' },
|
|
727
|
+
},
|
|
728
|
+
},
|
|
729
|
+
},
|
|
730
|
+
];
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// Export singleton instance
|
|
735
|
+
export const daaMcpTools = new DAA_MCPTools(null);
|