Squashed 'vendor/ruvector/' content from commit b64c2172

git-subtree-dir: vendor/ruvector
git-subtree-split: b64c21726f2bb37286d9ee36a7869fef60cc6900
This commit is contained in:
ruv
2026-02-28 14:39:40 -05:00
commit d803bfe2b1
7854 changed files with 3522914 additions and 0 deletions

View File

@@ -0,0 +1,207 @@
#!/bin/bash
# Offline Toolchain Cache for RuvLLM ESP32
#
# Downloads and caches the ESP32 toolchain for air-gapped environments.
# Run this on a machine with internet, then transfer the cache folder.
#
# Usage:
# ./offline-cache.sh create # Create cache
# ./offline-cache.sh install # Install from cache
# ./offline-cache.sh verify # Verify cache integrity
set -e
CACHE_DIR="${RUVLLM_CACHE_DIR:-$HOME/.ruvllm-cache}"
TOOLCHAIN_VERSION="1.90.0.0"
ESPFLASH_VERSION="4.3.0"
LDPROXY_VERSION="0.3.4"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
log_info() { echo -e "${CYAN}[INFO]${NC} $1"; }
log_success() { echo -e "${GREEN}[OK]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
detect_platform() {
case "$(uname -s)" in
Linux*) PLATFORM="linux" ;;
Darwin*) PLATFORM="macos" ;;
MINGW*|CYGWIN*|MSYS*) PLATFORM="windows" ;;
*) PLATFORM="unknown" ;;
esac
case "$(uname -m)" in
x86_64|amd64) ARCH="x86_64" ;;
aarch64|arm64) ARCH="aarch64" ;;
*) ARCH="unknown" ;;
esac
echo "Platform: $PLATFORM-$ARCH"
}
create_cache() {
log_info "Creating offline cache in $CACHE_DIR"
mkdir -p "$CACHE_DIR"/{toolchain,binaries,checksums}
detect_platform
# Download espup
log_info "Downloading espup..."
case "$PLATFORM" in
linux)
ESPUP_URL="https://github.com/esp-rs/espup/releases/download/v$TOOLCHAIN_VERSION/espup-${ARCH}-unknown-linux-gnu"
;;
macos)
ESPUP_URL="https://github.com/esp-rs/espup/releases/download/v$TOOLCHAIN_VERSION/espup-${ARCH}-apple-darwin"
;;
windows)
ESPUP_URL="https://github.com/esp-rs/espup/releases/download/v$TOOLCHAIN_VERSION/espup-${ARCH}-pc-windows-msvc.exe"
;;
esac
curl -L "$ESPUP_URL" -o "$CACHE_DIR/binaries/espup"
chmod +x "$CACHE_DIR/binaries/espup"
log_success "Downloaded espup"
# Download espflash
log_info "Downloading espflash..."
ESPFLASH_URL="https://github.com/esp-rs/espflash/releases/download/v$ESPFLASH_VERSION/espflash-${ARCH}-unknown-linux-gnu.zip"
curl -L "$ESPFLASH_URL" -o "$CACHE_DIR/binaries/espflash.zip" || log_warn "espflash download may have failed"
# Run espup to download toolchain components
log_info "Downloading ESP toolchain (this may take a while)..."
RUSTUP_HOME="$CACHE_DIR/toolchain/rustup" \
CARGO_HOME="$CACHE_DIR/toolchain/cargo" \
"$CACHE_DIR/binaries/espup" install --export-file "$CACHE_DIR/export-esp.sh"
# Create checksums
log_info "Creating checksums..."
cd "$CACHE_DIR"
find . -type f -exec sha256sum {} \; > checksums/manifest.sha256
log_success "Checksums created"
# Create metadata
cat > "$CACHE_DIR/metadata.json" << EOF
{
"version": "1.0.0",
"created": "$(date -Iseconds)",
"platform": "$PLATFORM",
"arch": "$ARCH",
"toolchain_version": "$TOOLCHAIN_VERSION",
"espflash_version": "$ESPFLASH_VERSION"
}
EOF
log_success "Cache created at $CACHE_DIR"
du -sh "$CACHE_DIR"
echo ""
log_info "To use on offline machine:"
echo " 1. Copy $CACHE_DIR to the target machine"
echo " 2. Run: ./offline-cache.sh install"
}
install_from_cache() {
if [ ! -d "$CACHE_DIR" ]; then
log_error "Cache not found at $CACHE_DIR"
exit 1
fi
log_info "Installing from offline cache..."
# Verify cache
verify_cache || { log_error "Cache verification failed"; exit 1; }
# Copy toolchain to user directories
RUSTUP_HOME="${RUSTUP_HOME:-$HOME/.rustup}"
CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}"
log_info "Installing Rust toolchain..."
mkdir -p "$RUSTUP_HOME" "$CARGO_HOME"
cp -r "$CACHE_DIR/toolchain/rustup/"* "$RUSTUP_HOME/"
cp -r "$CACHE_DIR/toolchain/cargo/"* "$CARGO_HOME/"
# Install binaries
log_info "Installing espup and espflash..."
cp "$CACHE_DIR/binaries/espup" "$CARGO_HOME/bin/"
if [ -f "$CACHE_DIR/binaries/espflash.zip" ]; then
unzip -o "$CACHE_DIR/binaries/espflash.zip" -d "$CARGO_HOME/bin/"
fi
# Copy export script
cp "$CACHE_DIR/export-esp.sh" "$HOME/"
log_success "Installation complete!"
echo ""
log_info "Run this command to set up your environment:"
echo " source ~/export-esp.sh"
}
verify_cache() {
if [ ! -f "$CACHE_DIR/checksums/manifest.sha256" ]; then
log_error "Checksum manifest not found"
return 1
fi
log_info "Verifying cache integrity..."
cd "$CACHE_DIR"
# Verify a subset of files (full verification can be slow)
head -20 checksums/manifest.sha256 | sha256sum -c --quiet 2>/dev/null
if [ $? -eq 0 ]; then
log_success "Cache integrity verified"
return 0
else
log_error "Cache integrity check failed"
return 1
fi
}
show_info() {
if [ ! -f "$CACHE_DIR/metadata.json" ]; then
log_error "Cache not found"
exit 1
fi
echo "=== RuvLLM ESP32 Offline Cache ==="
cat "$CACHE_DIR/metadata.json"
echo ""
echo "Cache size: $(du -sh "$CACHE_DIR" | cut -f1)"
}
# Main
case "${1:-help}" in
create)
create_cache
;;
install)
install_from_cache
;;
verify)
verify_cache
;;
info)
show_info
;;
*)
echo "RuvLLM ESP32 Offline Toolchain Cache"
echo ""
echo "Usage: $0 <command>"
echo ""
echo "Commands:"
echo " create - Download and cache toolchain (requires internet)"
echo " install - Install from cache (works offline)"
echo " verify - Verify cache integrity"
echo " info - Show cache information"
echo ""
echo "Environment variables:"
echo " RUVLLM_CACHE_DIR - Cache directory (default: ~/.ruvllm-cache)"
;;
esac

View File

@@ -0,0 +1,124 @@
# build.ps1 - Auto-configure and build RuvLLM ESP32
# Automatically detects toolchain paths - no manual configuration needed
param(
[string]$Target = "xtensa-esp32-espidf",
[switch]$Release = $true,
[string]$Features = ""
)
$ErrorActionPreference = "Stop"
Write-Host "`n=== RuvLLM ESP32 Build ===" -ForegroundColor Cyan
Write-Host ""
# Auto-detect paths
$rustupHome = if ($env:RUSTUP_HOME) { $env:RUSTUP_HOME } else { "$env:USERPROFILE\.rustup" }
$cargoHome = if ($env:CARGO_HOME) { $env:CARGO_HOME } else { "$env:USERPROFILE\.cargo" }
# Find ESP toolchain
$espToolchain = (Get-ChildItem "$rustupHome\toolchains" -Directory -ErrorAction SilentlyContinue |
Where-Object { $_.Name -like "esp*" } |
Select-Object -First 1)
if (-not $espToolchain) {
Write-Error "ESP toolchain not found. Run .\setup.ps1 first"
}
$espToolchainPath = $espToolchain.FullName
# Find libclang dynamically
$libclang = Get-ChildItem "$espToolchainPath" -Recurse -Filter "libclang.dll" -ErrorAction SilentlyContinue |
Select-Object -First 1
if (-not $libclang) {
Write-Error "libclang.dll not found in $espToolchainPath"
}
# Find Python
$python = Get-Command python -ErrorAction SilentlyContinue
if (-not $python) {
$python = Get-Command python3 -ErrorAction SilentlyContinue
}
if (-not $python) {
Write-Error "Python not found. Please install Python 3.8+"
}
$pythonPath = Split-Path $python.Source
# Find clang and xtensa-esp-elf paths
$clangBin = Get-ChildItem "$espToolchainPath" -Recurse -Directory -Filter "esp-clang" -ErrorAction SilentlyContinue |
Select-Object -First 1
$clangBinPath = if ($clangBin) { "$($clangBin.FullName)\bin" } else { "" }
$xtensaBin = Get-ChildItem "$espToolchainPath" -Recurse -Directory -Filter "xtensa-esp-elf" -ErrorAction SilentlyContinue |
Select-Object -First 1
$xtensaBinPath = if ($xtensaBin) { "$($xtensaBin.FullName)\bin" } else { "" }
# Set environment variables
$env:LIBCLANG_PATH = Split-Path $libclang.FullName
$env:RUSTUP_TOOLCHAIN = "esp"
$env:ESP_IDF_VERSION = "v5.1.2"
# Build PATH with all required directories
$pathParts = @(
$pythonPath,
"$pythonPath\Scripts",
$clangBinPath,
$xtensaBinPath,
"$cargoHome\bin"
) | Where-Object { $_ -ne "" }
$env:PATH = ($pathParts -join ";") + ";" + $env:PATH
Write-Host "Build Configuration:" -ForegroundColor Gray
Write-Host " Target: $Target"
Write-Host " Release: $Release"
Write-Host " Toolchain: $($espToolchain.Name)"
Write-Host " LIBCLANG_PATH: $($env:LIBCLANG_PATH)"
Write-Host ""
# Navigate to project directory
$projectDir = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
Push-Location $projectDir
try {
# Build cargo command
$cargoArgs = @("build")
if ($Release) {
$cargoArgs += "--release"
}
if ($Features) {
$cargoArgs += "--features"
$cargoArgs += $Features
}
Write-Host "Running: cargo $($cargoArgs -join ' ')" -ForegroundColor Gray
Write-Host ""
& cargo @cargoArgs
if ($LASTEXITCODE -ne 0) {
throw "Build failed with exit code $LASTEXITCODE"
}
Write-Host ""
Write-Host "Build successful!" -ForegroundColor Green
# Find the built binary
$buildDir = if ($Release) { "release" } else { "debug" }
$binary = Get-ChildItem "$projectDir\target\$Target\$buildDir" -Filter "*.elf" -ErrorAction SilentlyContinue |
Where-Object { $_.Name -notmatch "deps" } |
Select-Object -First 1
if ($binary) {
Write-Host "Binary: $($binary.FullName)" -ForegroundColor Cyan
}
Write-Host ""
Write-Host "Next: Run .\flash.ps1 to flash to device" -ForegroundColor Yellow
} finally {
Pop-Location
}

View File

@@ -0,0 +1,60 @@
# env.ps1 - Set up ESP32 Rust environment for the current session
# Source this script: . .\env.ps1
$ErrorActionPreference = "SilentlyContinue"
# Find paths
$rustupHome = if ($env:RUSTUP_HOME) { $env:RUSTUP_HOME } else { "$env:USERPROFILE\.rustup" }
$cargoHome = if ($env:CARGO_HOME) { $env:CARGO_HOME } else { "$env:USERPROFILE\.cargo" }
# Find ESP toolchain
$espToolchain = (Get-ChildItem "$rustupHome\toolchains" -Directory |
Where-Object { $_.Name -like "esp*" } |
Select-Object -First 1)
if (-not $espToolchain) {
Write-Host "ESP toolchain not found. Run setup.ps1 first." -ForegroundColor Red
return
}
$espToolchainPath = $espToolchain.FullName
# Find libclang
$libclang = Get-ChildItem "$espToolchainPath" -Recurse -Filter "libclang.dll" |
Select-Object -First 1
# Find clang bin
$clangBin = Get-ChildItem "$espToolchainPath" -Recurse -Directory -Filter "esp-clang" |
Select-Object -First 1
# Find xtensa-esp-elf bin
$xtensaBin = Get-ChildItem "$espToolchainPath" -Recurse -Directory -Filter "xtensa-esp-elf" |
Select-Object -First 1
# Find Python
$python = Get-Command python -ErrorAction SilentlyContinue
$pythonPath = if ($python) { Split-Path $python.Source } else { "" }
# Set environment variables
$env:LIBCLANG_PATH = if ($libclang) { Split-Path $libclang.FullName } else { "" }
$env:RUSTUP_TOOLCHAIN = "esp"
$env:ESP_IDF_VERSION = "v5.1.2"
# Build PATH
$pathAdditions = @()
if ($pythonPath) { $pathAdditions += $pythonPath; $pathAdditions += "$pythonPath\Scripts" }
if ($clangBin) { $pathAdditions += "$($clangBin.FullName)\bin" }
if ($xtensaBin) { $pathAdditions += "$($xtensaBin.FullName)\bin" }
$pathAdditions += "$cargoHome\bin"
$env:PATH = ($pathAdditions -join ";") + ";" + $env:PATH
# Display status
Write-Host ""
Write-Host "ESP32 Rust environment loaded" -ForegroundColor Green
Write-Host ""
Write-Host " RUSTUP_TOOLCHAIN: $($env:RUSTUP_TOOLCHAIN)" -ForegroundColor Gray
Write-Host " LIBCLANG_PATH: $($env:LIBCLANG_PATH)" -ForegroundColor Gray
Write-Host " ESP_IDF_VERSION: $($env:ESP_IDF_VERSION)" -ForegroundColor Gray
Write-Host ""
Write-Host "Ready to build! Run: .\build.ps1" -ForegroundColor Cyan

View File

@@ -0,0 +1,99 @@
# flash.ps1 - Auto-detect COM port and flash RuvLLM ESP32
# Automatically finds connected ESP32 devices
param(
[string]$Port = "",
[switch]$Monitor = $true,
[string]$Target = "xtensa-esp32-espidf",
[switch]$Release = $true
)
$ErrorActionPreference = "Stop"
Write-Host "`n=== RuvLLM ESP32 Flash ===" -ForegroundColor Cyan
Write-Host ""
# Auto-detect COM port if not specified
if (-not $Port) {
# Get available COM ports
Add-Type -AssemblyName System.IO.Ports
$ports = [System.IO.Ports.SerialPort]::GetPortNames() |
Where-Object { $_ -match "COM\d+" } |
Sort-Object { [int]($_ -replace "COM", "") }
if ($ports.Count -eq 0) {
Write-Error "No COM ports found. Is the ESP32 connected via USB?"
} elseif ($ports.Count -eq 1) {
$Port = $ports[0]
Write-Host "Auto-detected port: $Port" -ForegroundColor Green
} else {
Write-Host "Multiple COM ports found:" -ForegroundColor Yellow
Write-Host ""
for ($i = 0; $i -lt $ports.Count; $i++) {
Write-Host " [$i] $($ports[$i])"
}
Write-Host ""
$selection = Read-Host "Select port (0-$($ports.Count - 1))"
if ($selection -match "^\d+$" -and [int]$selection -lt $ports.Count) {
$Port = $ports[[int]$selection]
} else {
Write-Error "Invalid selection"
}
}
}
Write-Host "Using port: $Port" -ForegroundColor Cyan
Write-Host ""
# Find binary
$projectDir = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
$buildDir = if ($Release) { "release" } else { "debug" }
$targetDir = "$projectDir\target\$Target\$buildDir"
# Look for ELF or binary file
$binary = Get-ChildItem $targetDir -Filter "*.elf" -ErrorAction SilentlyContinue |
Where-Object { $_.Name -notmatch "deps" } |
Select-Object -First 1
if (-not $binary) {
$binary = Get-ChildItem $targetDir -Filter "ruvllm-esp32*" -ErrorAction SilentlyContinue |
Where-Object { $_.Name -notmatch "\." -or $_.Name -match "\.elf$" } |
Select-Object -First 1
}
if (-not $binary) {
Write-Host "Available files in $targetDir`:" -ForegroundColor Yellow
Get-ChildItem $targetDir -ErrorAction SilentlyContinue | ForEach-Object { Write-Host " $($_.Name)" }
Write-Error "No binary found. Run .\build.ps1 first"
}
Write-Host "Binary: $($binary.Name)" -ForegroundColor Gray
Write-Host ""
# Check for espflash
$espflash = Get-Command espflash -ErrorAction SilentlyContinue
if (-not $espflash) {
Write-Error "espflash not found. Run .\setup.ps1 first"
}
# Build espflash command
$espflashArgs = @("flash", "--port", $Port, $binary.FullName)
if ($Monitor) {
$espflashArgs += "--monitor"
}
Write-Host "Flashing..." -ForegroundColor Cyan
Write-Host "Command: espflash $($espflashArgs -join ' ')" -ForegroundColor Gray
Write-Host ""
# Flash the device
& espflash @espflashArgs
if ($LASTEXITCODE -ne 0) {
Write-Error "Flash failed with exit code $LASTEXITCODE"
}
Write-Host ""
Write-Host "Flash complete!" -ForegroundColor Green

View File

@@ -0,0 +1,41 @@
# monitor.ps1 - Open serial monitor for ESP32
# Auto-detects COM port
param(
[string]$Port = "",
[int]$Baud = 115200
)
$ErrorActionPreference = "Stop"
Write-Host "`n=== RuvLLM ESP32 Serial Monitor ===" -ForegroundColor Cyan
Write-Host ""
# Auto-detect COM port if not specified
if (-not $Port) {
Add-Type -AssemblyName System.IO.Ports
$ports = [System.IO.Ports.SerialPort]::GetPortNames() |
Where-Object { $_ -match "COM\d+" } |
Sort-Object { [int]($_ -replace "COM", "") }
if ($ports.Count -eq 0) {
Write-Error "No COM ports found. Is the ESP32 connected?"
} elseif ($ports.Count -eq 1) {
$Port = $ports[0]
Write-Host "Auto-detected port: $Port" -ForegroundColor Green
} else {
Write-Host "Multiple COM ports found:" -ForegroundColor Yellow
for ($i = 0; $i -lt $ports.Count; $i++) {
Write-Host " [$i] $($ports[$i])"
}
$selection = Read-Host "Select port (0-$($ports.Count - 1))"
$Port = $ports[[int]$selection]
}
}
Write-Host "Opening monitor on $Port at $Baud baud..." -ForegroundColor Cyan
Write-Host "Press Ctrl+C to exit" -ForegroundColor Gray
Write-Host ""
# Use espflash monitor
& espflash monitor --port $Port --baud $Baud

View File

@@ -0,0 +1,118 @@
# setup.ps1 - One-time Windows setup for RuvLLM ESP32
# Run this once to install/configure the ESP32 Rust toolchain
$ErrorActionPreference = "Stop"
Write-Host "`n=== RuvLLM ESP32 Windows Setup ===" -ForegroundColor Cyan
Write-Host ""
# Find Rust ESP toolchain dynamically
$rustupHome = if ($env:RUSTUP_HOME) { $env:RUSTUP_HOME } else { "$env:USERPROFILE\.rustup" }
$cargoHome = if ($env:CARGO_HOME) { $env:CARGO_HOME } else { "$env:USERPROFILE\.cargo" }
# Check if Rust is installed
$rustc = Get-Command rustc -ErrorAction SilentlyContinue
if (-not $rustc) {
Write-Host "Rust not found. Installing rustup..." -ForegroundColor Yellow
Invoke-WebRequest -Uri "https://win.rustup.rs/x86_64" -OutFile rustup-init.exe
.\rustup-init.exe -y --default-toolchain stable
Remove-Item rustup-init.exe
$env:PATH = "$cargoHome\bin;" + $env:PATH
Write-Host "Rust installed successfully" -ForegroundColor Green
}
# Find or install ESP toolchain
$espToolchain = Get-ChildItem "$rustupHome\toolchains" -Directory -ErrorAction SilentlyContinue |
Where-Object { $_.Name -like "esp*" } |
Select-Object -First 1
if (-not $espToolchain) {
Write-Host "ESP toolchain not found. Installing espup..." -ForegroundColor Yellow
# Download espup
$espupUrl = "https://github.com/esp-rs/espup/releases/latest/download/espup-x86_64-pc-windows-msvc.exe"
$espupPath = "$env:TEMP\espup.exe"
Write-Host "Downloading espup..." -ForegroundColor Gray
Invoke-WebRequest -Uri $espupUrl -OutFile $espupPath
Write-Host "Running espup install (this may take several minutes)..." -ForegroundColor Gray
& $espupPath install
if ($LASTEXITCODE -ne 0) {
Write-Error "espup install failed with exit code $LASTEXITCODE"
}
Remove-Item $espupPath -ErrorAction SilentlyContinue
# Re-check for toolchain
$espToolchain = Get-ChildItem "$rustupHome\toolchains" -Directory |
Where-Object { $_.Name -like "esp*" } |
Select-Object -First 1
}
if (-not $espToolchain) {
Write-Error "ESP toolchain installation failed. Please install manually: https://esp-rs.github.io/book/"
}
Write-Host "Found ESP toolchain: $($espToolchain.Name)" -ForegroundColor Green
# Find Python
$python = Get-Command python -ErrorAction SilentlyContinue
if (-not $python) {
$python = Get-Command python3 -ErrorAction SilentlyContinue
}
if (-not $python) {
Write-Error "Python not found. Please install Python 3.8+ from https://python.org"
}
Write-Host "Found Python: $($python.Source)" -ForegroundColor Green
# Find libclang
$libclang = Get-ChildItem "$($espToolchain.FullName)" -Recurse -Filter "libclang.dll" -ErrorAction SilentlyContinue |
Select-Object -First 1
if ($libclang) {
Write-Host "Found libclang: $($libclang.FullName)" -ForegroundColor Green
} else {
Write-Host "Warning: libclang.dll not found in toolchain" -ForegroundColor Yellow
}
# Install espflash if not present
$espflash = Get-Command espflash -ErrorAction SilentlyContinue
if (-not $espflash) {
Write-Host "Installing espflash..." -ForegroundColor Yellow
cargo install espflash
if ($LASTEXITCODE -ne 0) {
Write-Error "espflash installation failed"
}
Write-Host "espflash installed successfully" -ForegroundColor Green
} else {
Write-Host "Found espflash: $($espflash.Source)" -ForegroundColor Green
}
# Install ldproxy if not present
$ldproxy = Get-Command ldproxy -ErrorAction SilentlyContinue
if (-not $ldproxy) {
Write-Host "Installing ldproxy..." -ForegroundColor Yellow
cargo install ldproxy
if ($LASTEXITCODE -ne 0) {
Write-Error "ldproxy installation failed"
}
Write-Host "ldproxy installed successfully" -ForegroundColor Green
}
Write-Host ""
Write-Host "=== Setup Complete ===" -ForegroundColor Green
Write-Host ""
Write-Host "Summary:" -ForegroundColor Cyan
Write-Host " Toolchain: $($espToolchain.Name)"
Write-Host " Python: $($python.Source)"
if ($libclang) {
Write-Host " Libclang: $($libclang.FullName)"
}
Write-Host ""
Write-Host "Next steps:" -ForegroundColor Yellow
Write-Host " 1. Run: .\build.ps1"
Write-Host " 2. Connect ESP32 via USB"
Write-Host " 3. Run: .\flash.ps1"
Write-Host ""