Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Code-Mesh WASM 🌐⚡
WebAssembly bindings for the Code-Mesh distributed swarm intelligence system.
Code-Mesh WASM brings the full power of Rust-based distributed computing to JavaScript and browser environments. Experience blazing-fast performance with native WASM execution while maintaining the rich ecosystem of web technologies.
🌟 Features
🚀 Native WASM Performance
- Rust-to-WASM Compilation: Near-native execution speed in browsers
- SIMD Optimization: Hardware-accelerated operations where supported
- Memory Efficiency: Smart memory management with minimal overhead
- Zero-Copy Operations: Direct memory access for maximum performance
🌐 Universal JavaScript Support
- Browser Compatible: Works in all modern browsers
- Node.js Ready: Full server-side JavaScript support
- TypeScript Definitions: Complete type safety and IntelliSense
- Module Formats: ESM, CommonJS, and UMD builds available
🧠 Neural WASM Networks
- WebAssembly ML: Neural networks compiled to WASM
- Browser-based AI: Client-side machine learning capabilities
- Real-time Processing: Low-latency neural operations
- Offline Capabilities: No server required for AI processing
⚡ Swarm in the Browser
- Web Workers: Multi-threaded agent execution
- Shared Array Buffers: High-performance inter-agent communication
- Service Workers: Background swarm processing
- Progressive Web Apps: Offline-capable distributed applications
🚀 Installation
NPM Package
# Install the npm package
# Or with yarn
# Or with pnpm
Rust Crate
[]
= "0.1"
= "0.2"
CDN (Browser)
<!-- Modern ES6 modules -->
<!-- Traditional script tag -->
🚀 Quick Start
Browser Usage
Code-Mesh WASM Demo
Node.js Usage
import from '@ruvnet/code-mesh';
.;
TypeScript Usage
import {
CodeMesh,
SwarmConfig,
AgentType,
TaskResult
} from '@ruvnet/code-mesh';
interface AnalysisTask {
files: string[];
operation: 'analyze' | 'optimize' | 'test';
options?: {
parallel?: boolean;
neural?: boolean;
};
}
async function analyzeCodebase(): Promise<TaskResult> {
const mesh = new CodeMesh();
await mesh.init();
const config: SwarmConfig = {
topology: 'mesh',
agents: 5,
agentTypes: [
AgentType.Researcher,
AgentType.Coder,
AgentType.Analyst
],
enableNeuralNetworks: true
};
const swarm = await mesh.createSwarm(config);
const task: AnalysisTask = {
files: ['src/**/*.ts'],
operation: 'analyze',
options: {
parallel: true,
neural: true
}
};
return await swarm.executeTask(task);
}
🛠️ API Reference
Core Classes
CodeMesh
Main entry point for the WASM module.
Swarm
Represents a distributed agent swarm.
Agent
Individual agent within a swarm.
Configuration Interfaces
interface SwarmConfig {
topology: 'mesh' | 'hierarchical' | 'ring' | 'star';
agents: number;
agentTypes?: AgentType[];
useWebWorkers?: boolean;
enableSIMD?: boolean;
enableNeuralNetworks?: boolean;
memoryLimit?: string;
}
interface Task {
id?: string;
type: string;
data?: any;
options?: {
timeout?: number;
priority?: 'low' | 'medium' | 'high';
neural?: boolean;
};
}
interface TaskResult {
id: string;
status: 'completed' | 'failed' | 'timeout';
result?: any;
error?: string;
metrics: {
executionTime: number;
memoryUsed: number;
agentsUsed: number;
};
}
🌐 Browser Features
Web Workers Integration
// Main thread
import from '@ruvnet/code-mesh';
const mesh = ;
// Automatic worker management
const swarm = await mesh.;
Shared Array Buffer Support
// Enable high-performance inter-agent communication
const mesh = ;
// Agents can now share data without serialization overhead
const result = await swarm.;
Service Worker Integration
// service-worker.js
import from '@ruvnet/code-mesh';
let backgroundSwarm;
self.;
🏗️ Advanced Usage
Custom Neural Networks
import from '@ruvnet/code-mesh';
// Create custom neural network in WASM
const network = ;
// Train with WASM performance
await network.;
// Deploy to agents
const swarm = await mesh.;
Real-time Streaming
// Process streaming data with WASM agents
const stream = ;
const processor = await mesh.;
processor.;
Performance Monitoring
import from '@ruvnet/code-mesh';
const monitor = ;
// Monitor WASM performance
monitor.;
const metrics = await monitor.;
console.log;
🎯 Performance Optimizations
Browser Optimizations
// Optimize for different browser environments
const mesh = ;
Node.js Optimizations
// Server-side optimizations
const mesh = ;
🔧 Build Configuration
Webpack Integration
// webpack.config.js
module.exports = ;
Vite Configuration
// vite.config.js
export default ;
🎨 Examples
Real-time Data Processing
// Process real-time sensor data
import from '@ruvnet/code-mesh';
const mesh = ;
await mesh.;
const swarm = await mesh.;
// Process sensor data stream
const sensorStream = ;
sensorStream ;
Image Processing
// Client-side image processing with WASM
const mesh = ;
await mesh.;
const imageProcessor = await mesh.;
document..;
🐛 Troubleshooting
Common Issues
Issue: WASM module fails to load Solution: Ensure proper MIME type configuration and CORS headers
Issue: SharedArrayBuffer not available Solution: Serve with proper headers for cross-origin isolation
Issue: Performance slower than expected Solution: Enable SIMD and ensure proper memory allocation
Issue: TypeScript errors
Solution: Install @types/node and ensure proper tsconfig.json
Debug Mode
// Enable debug logging
const mesh = ;
// Monitor WASM memory usage
mesh.;
// Track performance
mesh.;
📚 Documentation
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
📜 License
This project is licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
👨💻 Creator
Created by ruv - Innovator in AI-driven development tools and distributed systems.
Repository: github.com/ruvnet/code-mesh
Code-Mesh WASM - Rust Performance in Every Browser 🌐⚡
Bringing distributed swarm intelligence to the web