@claude-flow/plugin-neural-coordination 3.0.0-alpha.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 +265 -0
- package/dist/bridges/attention-bridge.d.ts +100 -0
- package/dist/bridges/attention-bridge.d.ts.map +1 -0
- package/dist/bridges/attention-bridge.js +236 -0
- package/dist/bridges/attention-bridge.js.map +1 -0
- package/dist/bridges/index.d.ts +8 -0
- package/dist/bridges/index.d.ts.map +1 -0
- package/dist/bridges/index.js +8 -0
- package/dist/bridges/index.js.map +1 -0
- package/dist/bridges/nervous-system-bridge.d.ts +93 -0
- package/dist/bridges/nervous-system-bridge.d.ts.map +1 -0
- package/dist/bridges/nervous-system-bridge.js +240 -0
- package/dist/bridges/nervous-system-bridge.js.map +1 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +127 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-tools.d.ts +22 -0
- package/dist/mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools.js +915 -0
- package/dist/mcp-tools.js.map +1 -0
- package/dist/types.d.ts +730 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +229 -0
- package/dist/types.js.map +1 -0
- package/package.json +84 -0
package/README.md
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# @claude-flow/plugin-neural-coordination
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@claude-flow/plugin-neural-coordination)
|
|
4
|
+
[](https://github.com/ruvnet/claude-flow/blob/main/LICENSE)
|
|
5
|
+
[](https://www.npmjs.com/package/@claude-flow/plugin-neural-coordination)
|
|
6
|
+
|
|
7
|
+
A cutting-edge multi-agent coordination plugin combining the SONA self-optimizing neural architecture with graph neural networks for agent communication topology optimization. The plugin enables emergent protocol development, neural consensus mechanisms, collective memory formation, and adaptive swarm behavior while maintaining interpretability of agent interactions.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
### npm
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @claude-flow/plugin-neural-coordination
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### CLI
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx claude-flow plugins install --name @claude-flow/plugin-neural-coordination
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { NeuralCoordinationPlugin } from '@claude-flow/plugin-neural-coordination';
|
|
27
|
+
|
|
28
|
+
// Initialize the plugin
|
|
29
|
+
const plugin = new NeuralCoordinationPlugin();
|
|
30
|
+
await plugin.initialize();
|
|
31
|
+
|
|
32
|
+
// Achieve consensus among agents
|
|
33
|
+
const consensus = await plugin.neuralConsensus({
|
|
34
|
+
proposal: {
|
|
35
|
+
topic: 'architecture-decision',
|
|
36
|
+
options: [
|
|
37
|
+
{ id: 'microservices', value: { pattern: 'microservices', complexity: 'high' } },
|
|
38
|
+
{ id: 'monolith', value: { pattern: 'monolith', complexity: 'low' } }
|
|
39
|
+
],
|
|
40
|
+
constraints: { maxLatency: 100, minReliability: 0.99 }
|
|
41
|
+
},
|
|
42
|
+
agents: [
|
|
43
|
+
{ id: 'architect', preferences: { scalability: 0.8, simplicity: 0.2 } },
|
|
44
|
+
{ id: 'ops', preferences: { scalability: 0.3, simplicity: 0.7 } },
|
|
45
|
+
{ id: 'developer', preferences: { scalability: 0.5, simplicity: 0.5 } }
|
|
46
|
+
],
|
|
47
|
+
protocol: 'iterative_refinement',
|
|
48
|
+
maxRounds: 10
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
console.log('Consensus reached:', consensus.decision);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Available MCP Tools
|
|
55
|
+
|
|
56
|
+
### 1. `coordination/neural-consensus`
|
|
57
|
+
|
|
58
|
+
Achieve agent consensus using neural negotiation protocols.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
const result = await mcp.call('coordination/neural-consensus', {
|
|
62
|
+
proposal: {
|
|
63
|
+
topic: 'resource-allocation',
|
|
64
|
+
options: [
|
|
65
|
+
{ id: 'option-a', value: { cpus: 4, memory: '8GB' } },
|
|
66
|
+
{ id: 'option-b', value: { cpus: 8, memory: '4GB' } }
|
|
67
|
+
],
|
|
68
|
+
constraints: { budget: 100 }
|
|
69
|
+
},
|
|
70
|
+
agents: [
|
|
71
|
+
{ id: 'agent-1', preferences: { performance: 0.9 }, constraints: {} },
|
|
72
|
+
{ id: 'agent-2', preferences: { cost: 0.8 }, constraints: {} }
|
|
73
|
+
],
|
|
74
|
+
protocol: 'neural_voting',
|
|
75
|
+
maxRounds: 5
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Returns:** Consensus decision with voting breakdown, confidence scores, and round-by-round negotiation history.
|
|
80
|
+
|
|
81
|
+
### 2. `coordination/topology-optimize`
|
|
82
|
+
|
|
83
|
+
Optimize agent communication topology for efficiency using GNN analysis.
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
const result = await mcp.call('coordination/topology-optimize', {
|
|
87
|
+
agents: [
|
|
88
|
+
{ id: 'coordinator', capabilities: ['planning', 'delegation'], location: { zone: 'us-east' } },
|
|
89
|
+
{ id: 'worker-1', capabilities: ['coding'], location: { zone: 'us-east' } },
|
|
90
|
+
{ id: 'worker-2', capabilities: ['testing'], location: { zone: 'us-west' } }
|
|
91
|
+
],
|
|
92
|
+
objective: 'minimize_latency',
|
|
93
|
+
constraints: {
|
|
94
|
+
maxConnections: 10,
|
|
95
|
+
minRedundancy: 2,
|
|
96
|
+
preferredTopology: 'hybrid'
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Returns:** Optimized communication graph with connection weights and routing recommendations.
|
|
102
|
+
|
|
103
|
+
### 3. `coordination/collective-memory`
|
|
104
|
+
|
|
105
|
+
Manage shared collective memory across agent swarms.
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
const result = await mcp.call('coordination/collective-memory', {
|
|
109
|
+
action: 'store',
|
|
110
|
+
memory: {
|
|
111
|
+
key: 'project-context',
|
|
112
|
+
value: { requirements: [...], decisions: [...] },
|
|
113
|
+
importance: 0.9,
|
|
114
|
+
expiry: '2025-12-31T23:59:59Z'
|
|
115
|
+
},
|
|
116
|
+
scope: 'team',
|
|
117
|
+
consolidationStrategy: 'ewc'
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Returns:** Memory operation status with synchronization metadata across agents.
|
|
122
|
+
|
|
123
|
+
### 4. `coordination/emergent-protocol`
|
|
124
|
+
|
|
125
|
+
Develop emergent communication protocols through multi-agent reinforcement learning.
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
const result = await mcp.call('coordination/emergent-protocol', {
|
|
129
|
+
task: {
|
|
130
|
+
type: 'cooperative_search',
|
|
131
|
+
objectives: ['find_target', 'minimize_time'],
|
|
132
|
+
constraints: { maxSteps: 100 }
|
|
133
|
+
},
|
|
134
|
+
communicationBudget: {
|
|
135
|
+
symbolsPerMessage: 10,
|
|
136
|
+
messagesPerRound: 3
|
|
137
|
+
},
|
|
138
|
+
trainingEpisodes: 1000,
|
|
139
|
+
interpretability: true
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Returns:** Learned communication protocol with symbol vocabulary and usage patterns.
|
|
144
|
+
|
|
145
|
+
### 5. `coordination/swarm-behavior`
|
|
146
|
+
|
|
147
|
+
Orchestrate emergent swarm behaviors using neural coordination.
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
const result = await mcp.call('coordination/swarm-behavior', {
|
|
151
|
+
behavior: 'task_allocation',
|
|
152
|
+
parameters: {
|
|
153
|
+
taskQueue: [...],
|
|
154
|
+
priorityWeights: { urgency: 0.7, complexity: 0.3 }
|
|
155
|
+
},
|
|
156
|
+
adaptiveRules: true,
|
|
157
|
+
observability: {
|
|
158
|
+
recordTrajectories: true,
|
|
159
|
+
measureEmergence: true
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**Returns:** Swarm behavior execution plan with agent assignments and adaptation metrics.
|
|
165
|
+
|
|
166
|
+
## Configuration Options
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
interface NeuralCoordinationConfig {
|
|
170
|
+
// Maximum number of agents in coordination (default: 1000)
|
|
171
|
+
maxAgents: number;
|
|
172
|
+
|
|
173
|
+
// Memory limit per agent (default: 1GB)
|
|
174
|
+
memoryLimitPerAgent: number;
|
|
175
|
+
|
|
176
|
+
// Consensus timeout per round in ms (default: 60000)
|
|
177
|
+
consensusTimeoutMs: number;
|
|
178
|
+
|
|
179
|
+
// Enable Byzantine fault tolerance (default: true)
|
|
180
|
+
enableBFT: boolean;
|
|
181
|
+
|
|
182
|
+
// Message signing for security (default: true)
|
|
183
|
+
signMessages: boolean;
|
|
184
|
+
|
|
185
|
+
// Supported consensus protocols
|
|
186
|
+
protocols: ('neural_voting' | 'iterative_refinement' | 'auction' | 'contract_net')[];
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Performance Targets
|
|
191
|
+
|
|
192
|
+
| Metric | Target | Improvement vs Baseline |
|
|
193
|
+
|--------|--------|------------------------|
|
|
194
|
+
| Consensus convergence (100 agents) | <100 rounds | 10x faster |
|
|
195
|
+
| Communication overhead | <10% of total compute | 3x reduction |
|
|
196
|
+
| Topology optimization (1000 nodes) | <1s | 60x faster |
|
|
197
|
+
| Memory synchronization | <100ms eventual consistency | 10x faster |
|
|
198
|
+
| Emergent protocol training | <1 hour for basic tasks | Novel capability |
|
|
199
|
+
|
|
200
|
+
## Security Considerations
|
|
201
|
+
|
|
202
|
+
- **Agent Authentication**: Every agent must be authenticated with signed credentials before joining coordination
|
|
203
|
+
- **Message Signing**: All inter-agent messages are cryptographically signed (Ed25519) to prevent spoofing
|
|
204
|
+
- **Byzantine Fault Tolerance**: Consensus tolerates up to f < n/3 malicious/faulty agents
|
|
205
|
+
- **Sybil Attack Prevention**: Agent credential verification and rate limiting prevent fake agent multiplication
|
|
206
|
+
- **Memory Encryption**: Collective memory is encrypted at rest (AES-256-GCM) with session-specific keys
|
|
207
|
+
- **Input Validation**: All inputs validated with Zod schemas to prevent injection attacks
|
|
208
|
+
|
|
209
|
+
### WASM Security Constraints
|
|
210
|
+
|
|
211
|
+
| Constraint | Value | Rationale |
|
|
212
|
+
|------------|-------|-----------|
|
|
213
|
+
| Memory Limit per Agent | 1GB max | Prevent resource exhaustion |
|
|
214
|
+
| CPU Time per Round | 60 seconds | Prevent consensus deadlock |
|
|
215
|
+
| No External Network | Enforced | Isolated agent communication only |
|
|
216
|
+
| Signed Messages | Ed25519 required | Prevent message tampering |
|
|
217
|
+
| Session Isolation | Per-coordination | Prevent cross-session leakage |
|
|
218
|
+
|
|
219
|
+
### Rate Limits
|
|
220
|
+
|
|
221
|
+
| Tool | Requests/Minute | Max Concurrent |
|
|
222
|
+
|------|-----------------|----------------|
|
|
223
|
+
| `neural-consensus` | 10 | 2 |
|
|
224
|
+
| `topology-optimize` | 5 | 1 |
|
|
225
|
+
| `collective-memory` | 100 | 10 |
|
|
226
|
+
| `emergent-protocol` | 1 | 1 |
|
|
227
|
+
| `swarm-behavior` | 10 | 2 |
|
|
228
|
+
|
|
229
|
+
### Input Limits
|
|
230
|
+
|
|
231
|
+
| Constraint | Limit |
|
|
232
|
+
|------------|-------|
|
|
233
|
+
| Max agents per coordination | 1,000 |
|
|
234
|
+
| Max message size | 1MB |
|
|
235
|
+
| Max rounds per consensus | 1,000 |
|
|
236
|
+
| Memory limit per agent | 1GB |
|
|
237
|
+
| CPU time per round | 60 seconds |
|
|
238
|
+
|
|
239
|
+
## Dependencies
|
|
240
|
+
|
|
241
|
+
- `sona` - Self-Optimizing Neural Architecture for agent adaptation
|
|
242
|
+
- `ruvector-gnn-wasm` - Communication graph optimization and message routing
|
|
243
|
+
- `ruvector-nervous-system-wasm` - Neural coordination layer for collective behavior
|
|
244
|
+
- `ruvector-attention-wasm` - Multi-head attention for agent-to-agent communication
|
|
245
|
+
- `ruvector-learning-wasm` - Multi-agent reinforcement learning (MARL)
|
|
246
|
+
|
|
247
|
+
## Use Cases
|
|
248
|
+
|
|
249
|
+
1. **Distributed Problem Solving**: Coordinate agents to solve complex decomposed problems
|
|
250
|
+
2. **Negotiation Systems**: Multi-party negotiation with optimal outcomes
|
|
251
|
+
3. **Swarm Robotics**: Emergent collective behaviors for physical agents
|
|
252
|
+
4. **Federated Learning**: Coordinate model training across distributed agents
|
|
253
|
+
5. **Market Simulation**: Agent-based modeling with realistic interactions
|
|
254
|
+
|
|
255
|
+
## Related Plugins
|
|
256
|
+
|
|
257
|
+
| Plugin | Description | Synergy |
|
|
258
|
+
|--------|-------------|---------|
|
|
259
|
+
| [@claude-flow/plugin-cognitive-kernel](https://www.npmjs.com/package/@claude-flow/plugin-cognitive-kernel) | Cognitive augmentation with working memory | Enhances individual agent reasoning within coordinated swarms |
|
|
260
|
+
| [@claude-flow/plugin-quantum-optimizer](https://www.npmjs.com/package/@claude-flow/plugin-quantum-optimizer) | Quantum-inspired optimization | Optimizes task allocation and resource scheduling across agents |
|
|
261
|
+
| [@claude-flow/plugin-hyperbolic-reasoning](https://www.npmjs.com/package/@claude-flow/plugin-hyperbolic-reasoning) | Hierarchical reasoning | Enables hierarchical agent organization and taxonomic coordination |
|
|
262
|
+
|
|
263
|
+
## License
|
|
264
|
+
|
|
265
|
+
MIT
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attention Bridge
|
|
3
|
+
*
|
|
4
|
+
* Bridge to ruvector-attention-wasm for multi-head attention computation.
|
|
5
|
+
* Enables agent-to-agent communication weighting and focus management.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* WASM module status
|
|
9
|
+
*/
|
|
10
|
+
export type WasmModuleStatus = 'unloaded' | 'loading' | 'ready' | 'error';
|
|
11
|
+
/**
|
|
12
|
+
* Attention configuration
|
|
13
|
+
*/
|
|
14
|
+
export interface AttentionConfig {
|
|
15
|
+
/** Dimension of each attention head */
|
|
16
|
+
headDim: number;
|
|
17
|
+
/** Number of attention heads */
|
|
18
|
+
numHeads: number;
|
|
19
|
+
/** Sequence length */
|
|
20
|
+
seqLength: number;
|
|
21
|
+
/** Whether to use causal masking */
|
|
22
|
+
causal: boolean;
|
|
23
|
+
/** Dropout rate (0-1) */
|
|
24
|
+
dropout: number;
|
|
25
|
+
/** Temperature for softmax scaling */
|
|
26
|
+
temperature: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Attention output
|
|
30
|
+
*/
|
|
31
|
+
export interface AttentionOutput {
|
|
32
|
+
values: Float32Array;
|
|
33
|
+
weights: Float32Array;
|
|
34
|
+
attended: string[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* WASM attention module interface
|
|
38
|
+
*/
|
|
39
|
+
interface AttentionModule {
|
|
40
|
+
flashAttention(query: Float32Array, key: Float32Array, value: Float32Array, config: AttentionConfig): Float32Array;
|
|
41
|
+
multiHeadAttention(query: Float32Array, key: Float32Array, value: Float32Array, config: AttentionConfig): Float32Array;
|
|
42
|
+
selfAttention(input: Float32Array, config: AttentionConfig): Float32Array;
|
|
43
|
+
computeWeights(query: Float32Array, keys: Float32Array[], config: AttentionConfig): Float32Array;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Attention Bridge implementation
|
|
47
|
+
*/
|
|
48
|
+
export declare class AttentionBridge {
|
|
49
|
+
readonly name = "ruvector-attention-wasm";
|
|
50
|
+
readonly version = "0.1.0";
|
|
51
|
+
private _status;
|
|
52
|
+
private _module;
|
|
53
|
+
private config;
|
|
54
|
+
constructor(config?: Partial<AttentionConfig>);
|
|
55
|
+
get status(): WasmModuleStatus;
|
|
56
|
+
get initialized(): boolean;
|
|
57
|
+
init(): Promise<void>;
|
|
58
|
+
destroy(): Promise<void>;
|
|
59
|
+
isReady(): boolean;
|
|
60
|
+
getModule(): AttentionModule | null;
|
|
61
|
+
/**
|
|
62
|
+
* Compute flash attention (optimized for long sequences)
|
|
63
|
+
* Achieves 2.49x-7.47x speedup over standard attention
|
|
64
|
+
*/
|
|
65
|
+
flashAttention(query: Float32Array, key: Float32Array, value: Float32Array, config?: Partial<AttentionConfig>): Float32Array;
|
|
66
|
+
/**
|
|
67
|
+
* Compute multi-head attention
|
|
68
|
+
*/
|
|
69
|
+
multiHeadAttention(query: Float32Array, key: Float32Array, value: Float32Array, config?: Partial<AttentionConfig>): Float32Array;
|
|
70
|
+
/**
|
|
71
|
+
* Compute self-attention
|
|
72
|
+
*/
|
|
73
|
+
selfAttention(input: Float32Array, config?: Partial<AttentionConfig>): Float32Array;
|
|
74
|
+
/**
|
|
75
|
+
* Compute attention weights for agent-to-agent communication
|
|
76
|
+
* Returns normalized weights indicating how much each key should be attended to
|
|
77
|
+
*/
|
|
78
|
+
computeWeights(query: Float32Array, keys: Float32Array[], config?: Partial<AttentionConfig>): number[];
|
|
79
|
+
/**
|
|
80
|
+
* Compute attention-weighted aggregation of agent states
|
|
81
|
+
*/
|
|
82
|
+
aggregateWithAttention(query: Float32Array, agentStates: Float32Array[], agentValues: Float32Array[]): Float32Array;
|
|
83
|
+
/**
|
|
84
|
+
* Find top-k most relevant agents based on attention
|
|
85
|
+
*/
|
|
86
|
+
findMostRelevant(query: Float32Array, agentStates: Float32Array[], k: number): Array<{
|
|
87
|
+
index: number;
|
|
88
|
+
weight: number;
|
|
89
|
+
}>;
|
|
90
|
+
/**
|
|
91
|
+
* Create mock module for development without WASM
|
|
92
|
+
*/
|
|
93
|
+
private createMockModule;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Create a new attention bridge
|
|
97
|
+
*/
|
|
98
|
+
export declare function createAttentionBridge(config?: Partial<AttentionConfig>): AttentionBridge;
|
|
99
|
+
export default AttentionBridge;
|
|
100
|
+
//# sourceMappingURL=attention-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attention-bridge.d.ts","sourceRoot":"","sources":["../../src/bridges/attention-bridge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAC;CACrB;AAcD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,UAAU,eAAe;IACvB,cAAc,CACZ,KAAK,EAAE,YAAY,EACnB,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,eAAe,GACtB,YAAY,CAAC;IAEhB,kBAAkB,CAChB,KAAK,EAAE,YAAY,EACnB,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,eAAe,GACtB,YAAY,CAAC;IAEhB,aAAa,CACX,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,eAAe,GACtB,YAAY,CAAC;IAEhB,cAAc,CACZ,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,YAAY,EAAE,EACpB,MAAM,EAAE,eAAe,GACtB,YAAY,CAAC;CACjB;AAED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AAY,EAAE,EAC3B,CAAC,EAAE,MAAM,GACR,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAS3C;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAuHzB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAExF;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attention Bridge
|
|
3
|
+
*
|
|
4
|
+
* Bridge to ruvector-attention-wasm for multi-head attention computation.
|
|
5
|
+
* Enables agent-to-agent communication weighting and focus management.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default configuration
|
|
9
|
+
*/
|
|
10
|
+
const DEFAULT_CONFIG = {
|
|
11
|
+
headDim: 64,
|
|
12
|
+
numHeads: 8,
|
|
13
|
+
seqLength: 512,
|
|
14
|
+
causal: false,
|
|
15
|
+
dropout: 0,
|
|
16
|
+
temperature: 1.0,
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Attention Bridge implementation
|
|
20
|
+
*/
|
|
21
|
+
export class AttentionBridge {
|
|
22
|
+
name = 'ruvector-attention-wasm';
|
|
23
|
+
version = '0.1.0';
|
|
24
|
+
_status = 'unloaded';
|
|
25
|
+
_module = null;
|
|
26
|
+
config;
|
|
27
|
+
constructor(config) {
|
|
28
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
29
|
+
}
|
|
30
|
+
get status() {
|
|
31
|
+
return this._status;
|
|
32
|
+
}
|
|
33
|
+
get initialized() {
|
|
34
|
+
return this._status === 'ready';
|
|
35
|
+
}
|
|
36
|
+
async init() {
|
|
37
|
+
if (this._status === 'ready')
|
|
38
|
+
return;
|
|
39
|
+
if (this._status === 'loading')
|
|
40
|
+
return;
|
|
41
|
+
this._status = 'loading';
|
|
42
|
+
try {
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
const wasmModule = await import('@ruvector/attention-wasm').catch(() => null);
|
|
45
|
+
if (wasmModule) {
|
|
46
|
+
this._module = wasmModule;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this._module = this.createMockModule();
|
|
50
|
+
}
|
|
51
|
+
this._status = 'ready';
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
this._status = 'error';
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async destroy() {
|
|
59
|
+
this._module = null;
|
|
60
|
+
this._status = 'unloaded';
|
|
61
|
+
}
|
|
62
|
+
isReady() {
|
|
63
|
+
return this._status === 'ready';
|
|
64
|
+
}
|
|
65
|
+
getModule() {
|
|
66
|
+
return this._module;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Compute flash attention (optimized for long sequences)
|
|
70
|
+
* Achieves 2.49x-7.47x speedup over standard attention
|
|
71
|
+
*/
|
|
72
|
+
flashAttention(query, key, value, config) {
|
|
73
|
+
if (!this._module)
|
|
74
|
+
throw new Error('Attention module not initialized');
|
|
75
|
+
const mergedConfig = { ...this.config, ...config };
|
|
76
|
+
return this._module.flashAttention(query, key, value, mergedConfig);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Compute multi-head attention
|
|
80
|
+
*/
|
|
81
|
+
multiHeadAttention(query, key, value, config) {
|
|
82
|
+
if (!this._module)
|
|
83
|
+
throw new Error('Attention module not initialized');
|
|
84
|
+
const mergedConfig = { ...this.config, ...config };
|
|
85
|
+
return this._module.multiHeadAttention(query, key, value, mergedConfig);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Compute self-attention
|
|
89
|
+
*/
|
|
90
|
+
selfAttention(input, config) {
|
|
91
|
+
if (!this._module)
|
|
92
|
+
throw new Error('Attention module not initialized');
|
|
93
|
+
const mergedConfig = { ...this.config, ...config };
|
|
94
|
+
return this._module.selfAttention(input, mergedConfig);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Compute attention weights for agent-to-agent communication
|
|
98
|
+
* Returns normalized weights indicating how much each key should be attended to
|
|
99
|
+
*/
|
|
100
|
+
computeWeights(query, keys, config) {
|
|
101
|
+
if (!this._module)
|
|
102
|
+
throw new Error('Attention module not initialized');
|
|
103
|
+
const mergedConfig = { ...this.config, ...config };
|
|
104
|
+
const weightsArray = this._module.computeWeights(query, keys, mergedConfig);
|
|
105
|
+
return Array.from(weightsArray);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Compute attention-weighted aggregation of agent states
|
|
109
|
+
*/
|
|
110
|
+
aggregateWithAttention(query, agentStates, agentValues) {
|
|
111
|
+
if (agentStates.length === 0 || agentValues.length === 0) {
|
|
112
|
+
return new Float32Array(0);
|
|
113
|
+
}
|
|
114
|
+
// Compute attention weights
|
|
115
|
+
const weights = this.computeWeights(query, agentStates);
|
|
116
|
+
// Aggregate values using attention weights
|
|
117
|
+
const dim = agentValues[0]?.length ?? 0;
|
|
118
|
+
const result = new Float32Array(dim);
|
|
119
|
+
for (let d = 0; d < dim; d++) {
|
|
120
|
+
let sum = 0;
|
|
121
|
+
for (let i = 0; i < agentValues.length; i++) {
|
|
122
|
+
sum += (weights[i] ?? 0) * (agentValues[i]?.[d] ?? 0);
|
|
123
|
+
}
|
|
124
|
+
result[d] = sum;
|
|
125
|
+
}
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Find top-k most relevant agents based on attention
|
|
130
|
+
*/
|
|
131
|
+
findMostRelevant(query, agentStates, k) {
|
|
132
|
+
const weights = this.computeWeights(query, agentStates);
|
|
133
|
+
const indexed = weights.map((weight, index) => ({ index, weight }));
|
|
134
|
+
indexed.sort((a, b) => b.weight - a.weight);
|
|
135
|
+
return indexed.slice(0, k);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Create mock module for development without WASM
|
|
139
|
+
*/
|
|
140
|
+
createMockModule() {
|
|
141
|
+
return {
|
|
142
|
+
flashAttention(query, key, value, config) {
|
|
143
|
+
const seqLen = config.seqLength;
|
|
144
|
+
const headDim = config.headDim;
|
|
145
|
+
const scale = 1 / Math.sqrt(headDim) / config.temperature;
|
|
146
|
+
// Simplified attention computation
|
|
147
|
+
const output = new Float32Array(seqLen * headDim);
|
|
148
|
+
for (let i = 0; i < seqLen; i++) {
|
|
149
|
+
// Compute attention scores
|
|
150
|
+
const scores = new Float32Array(seqLen);
|
|
151
|
+
let maxScore = -Infinity;
|
|
152
|
+
for (let j = 0; j < seqLen; j++) {
|
|
153
|
+
if (config.causal && j > i) {
|
|
154
|
+
scores[j] = -Infinity;
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
let score = 0;
|
|
158
|
+
for (let d = 0; d < headDim; d++) {
|
|
159
|
+
score += (query[i * headDim + d] ?? 0) * (key[j * headDim + d] ?? 0);
|
|
160
|
+
}
|
|
161
|
+
scores[j] = score * scale;
|
|
162
|
+
maxScore = Math.max(maxScore, scores[j] ?? -Infinity);
|
|
163
|
+
}
|
|
164
|
+
// Softmax
|
|
165
|
+
let expSum = 0;
|
|
166
|
+
for (let j = 0; j < seqLen; j++) {
|
|
167
|
+
if (scores[j] !== -Infinity) {
|
|
168
|
+
scores[j] = Math.exp((scores[j] ?? 0) - maxScore);
|
|
169
|
+
expSum += scores[j] ?? 0;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
scores[j] = 0;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
for (let j = 0; j < seqLen; j++) {
|
|
176
|
+
scores[j] = (scores[j] ?? 0) / expSum;
|
|
177
|
+
}
|
|
178
|
+
// Apply attention to values
|
|
179
|
+
for (let d = 0; d < headDim; d++) {
|
|
180
|
+
let sum = 0;
|
|
181
|
+
for (let j = 0; j < seqLen; j++) {
|
|
182
|
+
sum += (scores[j] ?? 0) * (value[j * headDim + d] ?? 0);
|
|
183
|
+
}
|
|
184
|
+
output[i * headDim + d] = sum;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return output;
|
|
188
|
+
},
|
|
189
|
+
multiHeadAttention(query, key, value, config) {
|
|
190
|
+
// For simplicity, just use flash attention
|
|
191
|
+
return this.flashAttention(query, key, value, config);
|
|
192
|
+
},
|
|
193
|
+
selfAttention(input, config) {
|
|
194
|
+
return this.flashAttention(input, input, input, config);
|
|
195
|
+
},
|
|
196
|
+
computeWeights(query, keys, config) {
|
|
197
|
+
const n = keys.length;
|
|
198
|
+
if (n === 0)
|
|
199
|
+
return new Float32Array(0);
|
|
200
|
+
const scale = 1 / Math.sqrt(query.length) / config.temperature;
|
|
201
|
+
const scores = new Float32Array(n);
|
|
202
|
+
let maxScore = -Infinity;
|
|
203
|
+
// Compute dot products
|
|
204
|
+
for (let i = 0; i < n; i++) {
|
|
205
|
+
const key = keys[i];
|
|
206
|
+
if (!key)
|
|
207
|
+
continue;
|
|
208
|
+
let score = 0;
|
|
209
|
+
for (let d = 0; d < Math.min(query.length, key.length); d++) {
|
|
210
|
+
score += (query[d] ?? 0) * (key[d] ?? 0);
|
|
211
|
+
}
|
|
212
|
+
scores[i] = score * scale;
|
|
213
|
+
maxScore = Math.max(maxScore, scores[i] ?? -Infinity);
|
|
214
|
+
}
|
|
215
|
+
// Softmax
|
|
216
|
+
let expSum = 0;
|
|
217
|
+
for (let i = 0; i < n; i++) {
|
|
218
|
+
scores[i] = Math.exp((scores[i] ?? 0) - maxScore);
|
|
219
|
+
expSum += scores[i] ?? 0;
|
|
220
|
+
}
|
|
221
|
+
for (let i = 0; i < n; i++) {
|
|
222
|
+
scores[i] = (scores[i] ?? 0) / expSum;
|
|
223
|
+
}
|
|
224
|
+
return scores;
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Create a new attention bridge
|
|
231
|
+
*/
|
|
232
|
+
export function createAttentionBridge(config) {
|
|
233
|
+
return new AttentionBridge(config);
|
|
234
|
+
}
|
|
235
|
+
export default AttentionBridge;
|
|
236
|
+
//# sourceMappingURL=attention-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attention-bridge.js","sourceRoot":"","sources":["../../src/bridges/attention-bridge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyBH;;GAEG;AACH,MAAM,cAAc,GAAoB;IACtC,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,CAAC;IACX,SAAS,EAAE,GAAG;IACd,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,CAAC;IACV,WAAW,EAAE,GAAG;CACjB,CAAC;AAyCF;;GAEG;AACH,MAAM,OAAO,eAAe;IACjB,IAAI,GAAG,yBAAyB,CAAC;IACjC,OAAO,GAAG,OAAO,CAAC;IAEnB,OAAO,GAAqB,UAAU,CAAC;IACvC,OAAO,GAA2B,IAAI,CAAC;IACvC,MAAM,CAAkB;IAEhC,YAAY,MAAiC;QAC3C,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,MAAM,EAAE,CAAC;IACjD,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,OAAO,KAAK,OAAO,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,IAAI,CAAC,OAAO,KAAK,OAAO;YAAE,OAAO;QACrC,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;YAAE,OAAO;QAEvC,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QAEzB,IAAI,CAAC;YACH,8DAA8D;YAC9D,MAAM,UAAU,GAAG,MAAO,MAAM,CAAC,0BAAiC,CAAsB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;YAE3G,IAAI,UAAU,EAAE,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AK,CAAC;oBAC1B,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACxD,CAAC;gBAED,UAAU;gBACV,IAAI,MAAM,GAAG,CAAC,CAAC;gBACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;oBAC3B,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC;oBAClD,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAC3B,CAAC;gBAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;oBAC3B,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC;gBACxC,CAAC;gBAED,OAAO,MAAM,CAAC;YAChB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAiC;IACrE,OAAO,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Neural Coordination Bridges Index
|
|
3
|
+
*
|
|
4
|
+
* Exports all WASM bridges for neural coordination.
|
|
5
|
+
*/
|
|
6
|
+
export { NervousSystemBridge, createNervousSystemBridge, type WasmModuleStatus, type NervousSystemConfig, type NeuralSignal, type CoordinationResult, } from './nervous-system-bridge.js';
|
|
7
|
+
export { AttentionBridge, createAttentionBridge, type AttentionConfig, type AttentionOutput, } from './attention-bridge.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bridges/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,kBAAkB,GACxB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Neural Coordination Bridges Index
|
|
3
|
+
*
|
|
4
|
+
* Exports all WASM bridges for neural coordination.
|
|
5
|
+
*/
|
|
6
|
+
export { NervousSystemBridge, createNervousSystemBridge, } from './nervous-system-bridge.js';
|
|
7
|
+
export { AttentionBridge, createAttentionBridge, } from './attention-bridge.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bridges/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,mBAAmB,EACnB,yBAAyB,GAK1B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,eAAe,EACf,qBAAqB,GAGtB,MAAM,uBAAuB,CAAC"}
|