agentic-flow 2.0.0-alpha → 2.0.1-alpha

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.
Files changed (81) hide show
  1. package/README.md +320 -23
  2. package/agentic-flow/.claude/agents/base-template-generator.md +229 -3
  3. package/agentic-flow/.claude/agents/core/coder.md +212 -7
  4. package/agentic-flow/.claude/agents/core/planner.md +228 -7
  5. package/agentic-flow/.claude/agents/core/researcher.md +205 -10
  6. package/agentic-flow/.claude/agents/core/reviewer.md +216 -5
  7. package/agentic-flow/.claude/agents/core/tester.md +213 -3
  8. package/agentic-flow/.claude/agents/data/ml/data-ml-model.md +256 -5
  9. package/agentic-flow/.claude/agents/development/backend/dev-backend-api.md +209 -6
  10. package/agentic-flow/.claude/agents/documentation/api-docs/docs-api-openapi.md +185 -5
  11. package/agentic-flow/.claude/agents/github/code-review-swarm.md +307 -468
  12. package/agentic-flow/.claude/agents/github/issue-tracker.md +270 -13
  13. package/agentic-flow/.claude/agents/github/pr-manager.md +259 -12
  14. package/agentic-flow/.claude/agents/github/release-manager.md +253 -15
  15. package/agentic-flow/.claude/agents/github/workflow-automation.md +277 -9
  16. package/agentic-flow/.claude/agents/sona/sona-learning-optimizer.md +496 -0
  17. package/agentic-flow/.claude/agents/sparc/architecture.md +231 -4
  18. package/agentic-flow/.claude/agents/sparc/pseudocode.md +206 -4
  19. package/agentic-flow/.claude/agents/sparc/refinement.md +283 -6
  20. package/agentic-flow/.claude/agents/sparc/specification.md +205 -3
  21. package/agentic-flow/.claude/agents/swarm/adaptive-coordinator.md +731 -0
  22. package/agentic-flow/.claude/agents/swarm/hierarchical-coordinator.md +455 -1
  23. package/agentic-flow/.claude/agents/swarm/mesh-coordinator.md +571 -0
  24. package/agentic-flow/.claude/agents/templates/sparc-coordinator.md +336 -5
  25. package/agentic-flow/dist/cli/commands/sona-train.d.ts.map +1 -0
  26. package/agentic-flow/dist/cli/commands/sona-train.js +295 -0
  27. package/agentic-flow/dist/cli/commands/sona-train.js.map +1 -0
  28. package/agentic-flow/dist/cli/commands/sona.d.ts.map +1 -0
  29. package/agentic-flow/dist/cli/commands/sona.js +290 -0
  30. package/agentic-flow/dist/cli/commands/sona.js.map +1 -0
  31. package/agentic-flow/dist/core/agentdb-fast.d.ts.map +1 -0
  32. package/agentic-flow/dist/core/agentdb-fast.js +299 -0
  33. package/agentic-flow/dist/core/agentdb-fast.js.map +1 -0
  34. package/agentic-flow/dist/core/attention-fallbacks.d.ts.map +1 -0
  35. package/agentic-flow/dist/core/attention-fallbacks.js +321 -0
  36. package/agentic-flow/dist/core/attention-fallbacks.js.map +1 -0
  37. package/agentic-flow/dist/core/embedding-service.d.ts.map +1 -0
  38. package/agentic-flow/dist/core/embedding-service.js +370 -0
  39. package/agentic-flow/dist/core/embedding-service.js.map +1 -0
  40. package/agentic-flow/dist/core/gnn-wrapper.d.ts.map +1 -0
  41. package/agentic-flow/dist/core/gnn-wrapper.js +236 -0
  42. package/agentic-flow/dist/core/gnn-wrapper.js.map +1 -0
  43. package/agentic-flow/dist/core/index.d.ts.map +1 -1
  44. package/agentic-flow/dist/core/index.js +80 -3
  45. package/agentic-flow/dist/core/index.js.map +1 -1
  46. package/agentic-flow/dist/mcp/claudeFlowSdkServer.d.ts.map +1 -1
  47. package/agentic-flow/dist/mcp/claudeFlowSdkServer.js +109 -0
  48. package/agentic-flow/dist/mcp/claudeFlowSdkServer.js.map +1 -1
  49. package/agentic-flow/dist/mcp/tools/agent-booster-tools.d.ts.map +1 -0
  50. package/agentic-flow/dist/mcp/tools/agent-booster-tools.js +262 -0
  51. package/agentic-flow/dist/mcp/tools/agent-booster-tools.js.map +1 -0
  52. package/agentic-flow/dist/mcp/tools/sona-tools.d.ts.map +1 -0
  53. package/agentic-flow/dist/mcp/tools/sona-tools.js +560 -0
  54. package/agentic-flow/dist/mcp/tools/sona-tools.js.map +1 -0
  55. package/agentic-flow/dist/optimizations/agent-booster-migration.d.ts.map +1 -0
  56. package/agentic-flow/dist/optimizations/agent-booster-migration.js +323 -0
  57. package/agentic-flow/dist/optimizations/agent-booster-migration.js.map +1 -0
  58. package/agentic-flow/dist/optimizations/configuration-tuning.d.ts.map +1 -0
  59. package/agentic-flow/dist/optimizations/configuration-tuning.js +422 -0
  60. package/agentic-flow/dist/optimizations/configuration-tuning.js.map +1 -0
  61. package/agentic-flow/dist/optimizations/ruvector-backend.d.ts.map +1 -0
  62. package/agentic-flow/dist/optimizations/ruvector-backend.js +464 -0
  63. package/agentic-flow/dist/optimizations/ruvector-backend.js.map +1 -0
  64. package/agentic-flow/dist/services/embedding-service.d.ts.map +1 -0
  65. package/agentic-flow/dist/services/embedding-service.js +367 -0
  66. package/agentic-flow/dist/services/embedding-service.js.map +1 -0
  67. package/agentic-flow/dist/services/sona-agent-training.d.ts.map +1 -0
  68. package/agentic-flow/dist/services/sona-agent-training.js +382 -0
  69. package/agentic-flow/dist/services/sona-agent-training.js.map +1 -0
  70. package/agentic-flow/dist/services/sona-agentdb-integration.d.ts.map +1 -0
  71. package/agentic-flow/dist/services/sona-agentdb-integration.js +346 -0
  72. package/agentic-flow/dist/services/sona-agentdb-integration.js.map +1 -0
  73. package/agentic-flow/dist/services/sona-service.d.ts.map +1 -0
  74. package/agentic-flow/dist/services/sona-service.js +448 -0
  75. package/agentic-flow/dist/services/sona-service.js.map +1 -0
  76. package/agentic-flow/dist/services/sona-types.d.ts.map +1 -0
  77. package/agentic-flow/dist/services/sona-types.js +59 -0
  78. package/agentic-flow/dist/services/sona-types.js.map +1 -0
  79. package/docs/README.md +27 -2
  80. package/package.json +12 -2
  81. package/docs/AGENTIC_JUJUTSU_QUICKSTART.md +0 -491
@@ -142,6 +142,460 @@ WORKERS WORKERS WORKERS WORKERS
142
142
  - Lessons learned documentation
143
143
  ```
144
144
 
145
+ ## 🧠 Advanced Attention Mechanisms (v2.0.0-alpha)
146
+
147
+ ### Hyperbolic Attention for Hierarchical Coordination
148
+
149
+ Hierarchical swarms use **hyperbolic attention** to model natural queen-worker relationships with topology-aware coordination:
150
+
151
+ ```typescript
152
+ import { AttentionService } from 'agentdb';
153
+
154
+ // Initialize attention service for hierarchical coordination
155
+ const attentionService = new AttentionService({
156
+ embeddingDim: 384,
157
+ runtime: 'napi' // 2.49x-7.47x faster than standard attention
158
+ });
159
+
160
+ // Queen-worker hierarchical coordination with 1.5x influence weight
161
+ class HierarchicalCoordinator {
162
+ constructor(
163
+ private attentionService: AttentionService,
164
+ private queenWeight: number = 1.5
165
+ ) {}
166
+
167
+ /**
168
+ * Coordinate using hyperbolic attention for hierarchical structures
169
+ * Queens have 1.5x influence weight over workers
170
+ */
171
+ async coordinateHierarchy(
172
+ queenOutputs: AgentOutput[],
173
+ workerOutputs: AgentOutput[],
174
+ curvature: number = -1.0 // Hyperbolic space curvature
175
+ ): Promise<CoordinationResult> {
176
+ // Convert outputs to embeddings
177
+ const queenEmbeddings = await this.outputsToEmbeddings(queenOutputs);
178
+ const workerEmbeddings = await this.outputsToEmbeddings(workerOutputs);
179
+
180
+ // Apply queen influence weight
181
+ const weightedQueenEmbeddings = queenEmbeddings.map(emb =>
182
+ emb.map(v => v * this.queenWeight)
183
+ );
184
+
185
+ // Combine queens and workers
186
+ const allEmbeddings = [...weightedQueenEmbeddings, ...workerEmbeddings];
187
+
188
+ // Use hyperbolic attention for hierarchy-aware coordination
189
+ const result = await this.attentionService.hyperbolicAttention(
190
+ allEmbeddings,
191
+ allEmbeddings,
192
+ allEmbeddings,
193
+ { curvature }
194
+ );
195
+
196
+ // Extract attention weights for each agent
197
+ const attentionWeights = this.extractAttentionWeights(result);
198
+
199
+ // Generate consensus with hierarchical influence
200
+ const consensus = this.generateConsensus(
201
+ [...queenOutputs, ...workerOutputs],
202
+ attentionWeights
203
+ );
204
+
205
+ return {
206
+ consensus,
207
+ attentionWeights,
208
+ topAgents: this.rankAgentsByInfluence(attentionWeights),
209
+ hierarchyDepth: this.calculateHierarchyDepth(attentionWeights),
210
+ executionTimeMs: result.executionTimeMs,
211
+ memoryUsage: result.memoryUsage
212
+ };
213
+ }
214
+
215
+ /**
216
+ * GraphRoPE: Topology-aware position embeddings
217
+ * Models hierarchical swarm structure as a graph
218
+ */
219
+ async topologyAwareCoordination(
220
+ agentOutputs: AgentOutput[],
221
+ topologyType: 'hierarchical' | 'tree' | 'star'
222
+ ): Promise<CoordinationResult> {
223
+ // Build graph representation of hierarchy
224
+ const graphContext = this.buildHierarchyGraph(agentOutputs, topologyType);
225
+
226
+ const embeddings = await this.outputsToEmbeddings(agentOutputs);
227
+
228
+ // Apply GraphRoPE for topology-aware position encoding
229
+ const positionEncodedEmbeddings = this.applyGraphRoPE(
230
+ embeddings,
231
+ graphContext
232
+ );
233
+
234
+ // Hyperbolic attention with topology awareness
235
+ const result = await this.attentionService.hyperbolicAttention(
236
+ positionEncodedEmbeddings,
237
+ positionEncodedEmbeddings,
238
+ positionEncodedEmbeddings,
239
+ { curvature: -1.0 }
240
+ );
241
+
242
+ return this.processCoordinationResult(result, agentOutputs);
243
+ }
244
+
245
+ /**
246
+ * Build hierarchical graph structure
247
+ */
248
+ private buildHierarchyGraph(
249
+ outputs: AgentOutput[],
250
+ topology: 'hierarchical' | 'tree' | 'star'
251
+ ): GraphContext {
252
+ const nodes = outputs.map((output, idx) => ({
253
+ id: idx,
254
+ label: output.agentType,
255
+ level: output.hierarchyLevel || 0
256
+ }));
257
+
258
+ const edges: [number, number][] = [];
259
+ const edgeWeights: number[] = [];
260
+
261
+ // Build edges based on topology
262
+ if (topology === 'hierarchical' || topology === 'tree') {
263
+ // Queens at level 0 connect to workers at level 1
264
+ const queens = nodes.filter(n => n.level === 0);
265
+ const workers = nodes.filter(n => n.level === 1);
266
+
267
+ queens.forEach(queen => {
268
+ workers.forEach(worker => {
269
+ edges.push([queen.id, worker.id]);
270
+ edgeWeights.push(this.queenWeight); // Queen influence
271
+ });
272
+ });
273
+ } else if (topology === 'star') {
274
+ // Central queen connects to all workers
275
+ const queen = nodes[0]; // First is queen
276
+ nodes.slice(1).forEach(worker => {
277
+ edges.push([queen.id, worker.id]);
278
+ edgeWeights.push(this.queenWeight);
279
+ });
280
+ }
281
+
282
+ return {
283
+ nodes: nodes.map(n => n.id),
284
+ edges,
285
+ edgeWeights,
286
+ nodeLabels: nodes.map(n => n.label)
287
+ };
288
+ }
289
+
290
+ /**
291
+ * Apply GraphRoPE position embeddings based on graph structure
292
+ */
293
+ private applyGraphRoPE(
294
+ embeddings: number[][],
295
+ graphContext: GraphContext
296
+ ): number[][] {
297
+ return embeddings.map((emb, idx) => {
298
+ // Find position in hierarchy
299
+ const depth = this.calculateNodeDepth(idx, graphContext);
300
+ const siblings = this.findSiblingCount(idx, graphContext);
301
+
302
+ // Position encoding based on depth and sibling position
303
+ const positionEncoding = this.generatePositionEncoding(
304
+ emb.length,
305
+ depth,
306
+ siblings
307
+ );
308
+
309
+ // Add position encoding to embedding
310
+ return emb.map((v, i) => v + positionEncoding[i] * 0.1);
311
+ });
312
+ }
313
+
314
+ private calculateNodeDepth(nodeId: number, graph: GraphContext): number {
315
+ // BFS to calculate depth from queens (level 0)
316
+ const visited = new Set<number>();
317
+ const queue: [number, number][] = [[nodeId, 0]];
318
+
319
+ while (queue.length > 0) {
320
+ const [current, depth] = queue.shift()!;
321
+ if (visited.has(current)) continue;
322
+ visited.add(current);
323
+
324
+ // Find parent edges (reverse direction)
325
+ graph.edges.forEach(([from, to], edgeIdx) => {
326
+ if (to === current && !visited.has(from)) {
327
+ queue.push([from, depth + 1]);
328
+ }
329
+ });
330
+ }
331
+
332
+ return visited.size;
333
+ }
334
+
335
+ private findSiblingCount(nodeId: number, graph: GraphContext): number {
336
+ // Find parent
337
+ const parent = graph.edges.find(([_, to]) => to === nodeId)?.[0];
338
+ if (parent === undefined) return 0;
339
+
340
+ // Count siblings (other nodes with same parent)
341
+ return graph.edges.filter(([from, to]) =>
342
+ from === parent && to !== nodeId
343
+ ).length;
344
+ }
345
+
346
+ private generatePositionEncoding(
347
+ dim: number,
348
+ depth: number,
349
+ siblings: number
350
+ ): number[] {
351
+ // Sinusoidal position encoding
352
+ return Array.from({ length: dim }, (_, i) => {
353
+ const freq = 1 / Math.pow(10000, i / dim);
354
+ return Math.sin(depth * freq) + Math.cos(siblings * freq);
355
+ });
356
+ }
357
+
358
+ private async outputsToEmbeddings(
359
+ outputs: AgentOutput[]
360
+ ): Promise<number[][]> {
361
+ // Convert agent outputs to embeddings (simplified)
362
+ // In production, use actual embedding model
363
+ return outputs.map(output =>
364
+ Array.from({ length: 384 }, () => Math.random())
365
+ );
366
+ }
367
+
368
+ private extractAttentionWeights(result: any): number[] {
369
+ // Extract attention weights from result
370
+ return Array.from(result.output.slice(0, result.output.length / 384))
371
+ .map((_, i) => result.output[i]);
372
+ }
373
+
374
+ private generateConsensus(
375
+ outputs: AgentOutput[],
376
+ weights: number[]
377
+ ): string {
378
+ // Weighted consensus based on attention scores
379
+ const weightedOutputs = outputs.map((output, idx) => ({
380
+ output: output.content,
381
+ weight: weights[idx]
382
+ }));
383
+
384
+ // Return highest weighted output
385
+ const best = weightedOutputs.reduce((max, curr) =>
386
+ curr.weight > max.weight ? curr : max
387
+ );
388
+
389
+ return best.output;
390
+ }
391
+
392
+ private rankAgentsByInfluence(weights: number[]): AgentRanking[] {
393
+ return weights
394
+ .map((weight, idx) => ({ agentId: idx, influence: weight }))
395
+ .sort((a, b) => b.influence - a.influence);
396
+ }
397
+
398
+ private calculateHierarchyDepth(weights: number[]): number {
399
+ // Estimate hierarchy depth from weight distribution
400
+ const queenWeights = weights.slice(0, Math.ceil(weights.length * 0.2));
401
+ const avgQueenWeight = queenWeights.reduce((a, b) => a + b, 0) / queenWeights.length;
402
+ const workerWeights = weights.slice(Math.ceil(weights.length * 0.2));
403
+ const avgWorkerWeight = workerWeights.reduce((a, b) => a + b, 0) / workerWeights.length;
404
+
405
+ return avgQueenWeight / avgWorkerWeight;
406
+ }
407
+
408
+ private processCoordinationResult(
409
+ result: any,
410
+ outputs: AgentOutput[]
411
+ ): CoordinationResult {
412
+ return {
413
+ consensus: this.generateConsensus(outputs, this.extractAttentionWeights(result)),
414
+ attentionWeights: this.extractAttentionWeights(result),
415
+ topAgents: this.rankAgentsByInfluence(this.extractAttentionWeights(result)),
416
+ executionTimeMs: result.executionTimeMs,
417
+ memoryUsage: result.memoryUsage
418
+ };
419
+ }
420
+ }
421
+
422
+ // Type definitions
423
+ interface AgentOutput {
424
+ agentType: string;
425
+ content: string;
426
+ hierarchyLevel?: number;
427
+ }
428
+
429
+ interface GraphContext {
430
+ nodes: number[];
431
+ edges: [number, number][];
432
+ edgeWeights: number[];
433
+ nodeLabels: string[];
434
+ }
435
+
436
+ interface CoordinationResult {
437
+ consensus: string;
438
+ attentionWeights: number[];
439
+ topAgents: AgentRanking[];
440
+ hierarchyDepth?: number;
441
+ executionTimeMs: number;
442
+ memoryUsage?: number;
443
+ }
444
+
445
+ interface AgentRanking {
446
+ agentId: number;
447
+ influence: number;
448
+ }
449
+ ```
450
+
451
+ ### Usage Example: Hierarchical Coordination
452
+
453
+ ```typescript
454
+ // Initialize hierarchical coordinator
455
+ const coordinator = new HierarchicalCoordinator(attentionService, 1.5);
456
+
457
+ // Queen agents (strategic planning)
458
+ const queenOutputs = [
459
+ {
460
+ agentType: 'planner',
461
+ content: 'Build authentication service with OAuth2 and JWT',
462
+ hierarchyLevel: 0
463
+ },
464
+ {
465
+ agentType: 'architect',
466
+ content: 'Use microservices architecture with API gateway',
467
+ hierarchyLevel: 0
468
+ }
469
+ ];
470
+
471
+ // Worker agents (execution)
472
+ const workerOutputs = [
473
+ {
474
+ agentType: 'coder',
475
+ content: 'Implement OAuth2 provider with Passport.js',
476
+ hierarchyLevel: 1
477
+ },
478
+ {
479
+ agentType: 'tester',
480
+ content: 'Create integration tests for authentication flow',
481
+ hierarchyLevel: 1
482
+ },
483
+ {
484
+ agentType: 'reviewer',
485
+ content: 'Review security best practices for JWT storage',
486
+ hierarchyLevel: 1
487
+ }
488
+ ];
489
+
490
+ // Coordinate with hyperbolic attention (queens have 1.5x influence)
491
+ const result = await coordinator.coordinateHierarchy(
492
+ queenOutputs,
493
+ workerOutputs,
494
+ -1.0 // Hyperbolic curvature
495
+ );
496
+
497
+ console.log('Consensus:', result.consensus);
498
+ console.log('Queen influence:', result.hierarchyDepth);
499
+ console.log('Top contributors:', result.topAgents.slice(0, 3));
500
+ console.log(`Processed in ${result.executionTimeMs}ms (${2.49}x-${7.47}x faster)`);
501
+ ```
502
+
503
+ ### Self-Learning Integration (ReasoningBank)
504
+
505
+ ```typescript
506
+ import { ReasoningBank } from 'agentdb';
507
+
508
+ class LearningHierarchicalCoordinator extends HierarchicalCoordinator {
509
+ constructor(
510
+ attentionService: AttentionService,
511
+ private reasoningBank: ReasoningBank,
512
+ queenWeight: number = 1.5
513
+ ) {
514
+ super(attentionService, queenWeight);
515
+ }
516
+
517
+ /**
518
+ * Learn from past hierarchical coordination patterns
519
+ */
520
+ async coordinateWithLearning(
521
+ taskDescription: string,
522
+ queenOutputs: AgentOutput[],
523
+ workerOutputs: AgentOutput[]
524
+ ): Promise<CoordinationResult> {
525
+ // 1. Search for similar past coordination patterns
526
+ const similarPatterns = await this.reasoningBank.searchPatterns({
527
+ task: taskDescription,
528
+ k: 5,
529
+ minReward: 0.8
530
+ });
531
+
532
+ if (similarPatterns.length > 0) {
533
+ console.log('📚 Learning from past hierarchical coordinations:');
534
+ similarPatterns.forEach(pattern => {
535
+ console.log(`- ${pattern.task}: ${pattern.reward} success rate`);
536
+ console.log(` Critique: ${pattern.critique}`);
537
+ });
538
+ }
539
+
540
+ // 2. Coordinate with hyperbolic attention
541
+ const result = await this.coordinateHierarchy(
542
+ queenOutputs,
543
+ workerOutputs,
544
+ -1.0
545
+ );
546
+
547
+ // 3. Calculate success metrics
548
+ const reward = this.calculateCoordinationReward(result);
549
+ const success = reward > 0.8;
550
+
551
+ // 4. Store learning pattern for future improvement
552
+ await this.reasoningBank.storePattern({
553
+ sessionId: `hierarchy-${Date.now()}`,
554
+ task: taskDescription,
555
+ input: JSON.stringify({ queens: queenOutputs, workers: workerOutputs }),
556
+ output: result.consensus,
557
+ reward,
558
+ success,
559
+ critique: this.generateCritique(result),
560
+ tokensUsed: this.estimateTokens(result),
561
+ latencyMs: result.executionTimeMs
562
+ });
563
+
564
+ return result;
565
+ }
566
+
567
+ private calculateCoordinationReward(result: CoordinationResult): number {
568
+ // Reward based on:
569
+ // - Hierarchy depth (queens should have more influence)
570
+ // - Attention weight distribution
571
+ // - Execution time
572
+
573
+ const hierarchyScore = Math.min(result.hierarchyDepth || 1, 2) / 2; // 0-1
574
+ const speedScore = Math.max(0, 1 - result.executionTimeMs / 10000); // Faster is better
575
+
576
+ return (hierarchyScore * 0.6 + speedScore * 0.4);
577
+ }
578
+
579
+ private generateCritique(result: CoordinationResult): string {
580
+ const critiques: string[] = [];
581
+
582
+ if (result.hierarchyDepth && result.hierarchyDepth < 1.3) {
583
+ critiques.push('Queens need more influence - consider increasing queen weight');
584
+ }
585
+
586
+ if (result.executionTimeMs > 5000) {
587
+ critiques.push('Coordination took too long - consider using flash attention');
588
+ }
589
+
590
+ return critiques.join('; ') || 'Good hierarchical coordination';
591
+ }
592
+
593
+ private estimateTokens(result: CoordinationResult): number {
594
+ return result.consensus.split(' ').length * 1.3;
595
+ }
596
+ }
597
+ ```
598
+
145
599
  ## MCP Tool Integration
146
600
 
147
601
  ### Swarm Management
@@ -151,7 +605,7 @@ mcp__claude-flow__swarm_init hierarchical --maxAgents=10 --strategy=centralized
151
605
 
152
606
  # Spawn specialized workers
153
607
  mcp__claude-flow__agent_spawn researcher --capabilities="research,analysis"
154
- mcp__claude-flow__agent_spawn coder --capabilities="implementation,testing"
608
+ mcp__claude-flow__agent_spawn coder --capabilities="implementation,testing"
155
609
  mcp__claude-flow__agent_spawn analyst --capabilities="data_analysis,reporting"
156
610
 
157
611
  # Monitor swarm health