@claude-flow/integration

Deep agentic-flow@alpha integration module for Claude Flow V3 - ADR-001 compliance, code deduplication, SONA adapter, and Flash Attention coordinator.
Features
- ADR-001 Compliance - Eliminates 10,000+ duplicate lines by building on agentic-flow
- SONA Adapter - Seamless integration with SONA learning systems
- Flash Attention - 2.49x-7.47x speedup with attention coordination
- SDK Bridge - Version negotiation and API compatibility layer
- Feature Flags - Dynamic feature enabling/disabling
- Runtime Detection - Auto-select optimal runtime (NAPI, WASM, JS)
- Graceful Fallback - Works with or without agentic-flow installed
Installation
npm install @claude-flow/integration
npm install agentic-flow@alpha
Quick Start
import { AgenticFlowBridge, createAgenticFlowBridge } from '@claude-flow/integration';
const bridge = await createAgenticFlowBridge({
features: {
enableSONA: true,
enableFlashAttention: true,
enableAgentDB: true
}
});
if (bridge.isAgenticFlowConnected()) {
console.log('Using optimized agentic-flow implementation');
} else {
console.log('Using local fallback implementation');
}
const sona = await bridge.getSONAAdapter();
await sona.setMode('balanced');
const attention = await bridge.getAttentionCoordinator();
const result = await attention.compute({ query, key, value });
API Reference
AgenticFlowBridge
import { AgenticFlowBridge } from '@claude-flow/integration';
const bridge = new AgenticFlowBridge({
sona: {
mode: 'balanced',
learningRate: 0.001,
similarityThreshold: 0.7
},
attention: {
mechanism: 'flash',
numHeads: 8,
flashOptLevel: 2
},
agentdb: {
dimension: 1536,
indexType: 'hnsw',
metric: 'cosine'
},
features: {
enableSONA: true,
enableFlashAttention: true,
enableAgentDB: true
},
runtimePreference: ['napi', 'wasm', 'js'],
lazyLoad: true,
debug: false
});
await bridge.initialize();
const sona = await bridge.getSONAAdapter();
const attention = await bridge.getAttentionCoordinator();
const sdk = await bridge.getSDKBridge();
bridge.isFeatureEnabled('enableSONA');
await bridge.enableFeature('enableFlashAttention');
await bridge.disableFeature('enableAgentDB');
const status = bridge.getStatus();
const health = await bridge.healthCheck();
const flags = bridge.getFeatureFlags();
const core = bridge.getAgenticFlowCore();
if (core) {
const patterns = await core.sona.findPatterns(query);
}
await bridge.shutdown();
SONA Adapter
const sona = await bridge.getSONAAdapter();
await sona.setMode('real-time');
const patternId = await sona.storePattern({
context: 'code-review',
strategy: 'analyze-then-comment',
embedding: vector
});
const patterns = await sona.findPatterns(queryEmbedding, {
limit: 5,
threshold: 0.7
});
const stats = await sona.getStats();
Attention Coordinator
const attention = await bridge.getAttentionCoordinator();
await attention.setMechanism('flash');
const result = await attention.compute({
query: queryTensor,
key: keyTensor,
value: valueTensor,
mask: optionalMask
});
const metrics = await attention.getMetrics();
SDK Bridge
const sdk = await bridge.getSDKBridge();
const version = sdk.getVersion();
const isCompatible = sdk.isCompatible('0.1.0');
await sdk.ping();
Feature Flags
const flags = bridge.getFeatureFlags();
{
enableSONA: true,
enableFlashAttention: true,
enableAgentDB: true,
enableTrajectoryTracking: true,
enableGNN: true,
enableIntelligenceBridge: true,
enableQUICTransport: false,
enableNightlyLearning: false,
enableAutoConsolidation: true
}
Runtime Detection
The bridge automatically selects the best runtime:
| NAPI | Optimal | Native bindings, non-Windows or x64 |
| WASM | Good | WebAssembly support |
| JS | Fallback | Always available |
const status = bridge.getStatus();
console.log(status.runtime);
Event System
bridge.on('initialized', ({ duration, components, agenticFlowConnected }) => {
console.log(`Initialized in ${duration}ms`);
});
bridge.on('agentic-flow:connected', ({ version, features }) => {
console.log(`Connected to agentic-flow ${version}`);
});
bridge.on('agentic-flow:fallback', ({ reason }) => {
console.log(`Using fallback: ${reason}`);
});
bridge.on('feature-enabled', ({ feature }) => {
console.log(`Enabled: ${feature}`);
});
bridge.on('health-check', ({ results }) => {
console.log(`Health: ${JSON.stringify(results)}`);
});
Performance Targets
| Flash Attention speedup | 2.49x-7.47x |
| AgentDB search | 150x-12,500x faster |
| SONA adaptation | <0.05ms |
| Memory reduction | 50-75% |
TypeScript Types
import type {
IntegrationConfig,
IntegrationStatus,
RuntimeInfo,
ComponentHealth,
FeatureFlags,
AgenticFlowCore
} from '@claude-flow/integration';
Peer Dependencies
agentic-flow@^0.1.0 (optional, for optimal performance)
Related Packages
License
MIT