Skip to content

SocketDev/socket-btm

Socket BTM

Build infrastructure for Socket's binary artifacts and ML models.

Overview

Socket BTM is a monorepo containing build infrastructure for:

  • Binary Tools - Custom C/C++ tools for binary manipulation
  • Node.js - Custom Node.js binaries with Socket security patches
  • WASM - ONNX Runtime and Yoga Layout WebAssembly builds
  • ML Models - Quantized AI models for code analysis

Getting Started

Prerequisites

Before building, ensure you have the required system dependencies installed:

  • Build Tools: Xcode CLI Tools (macOS), GCC/Build Essential (Linux), Visual Studio Build Tools (Windows)
  • Python 3.11+: For ML model building
  • Node.js 18+: For build scripts and infrastructure
  • pnpm: Package manager

See Prerequisites Guide for detailed platform-specific setup instructions.

Quick Start

# Install dependencies
pnpm install

# Build binary tools (required for Node.js builds)
cd packages/binject && make && cd ../..
cd packages/binpress && make && cd ../..
cd packages/binflate && make && cd ../..

Packages

Binary Tools

Core C/C++ tools for binary manipulation:

  • binject - Binary resource injection for Mach-O, ELF, and PE
  • binpress - Binary compression with platform-specific algorithms
  • binflate - Binary decompression and self-extraction

Build Infrastructure

Node.js

  • node-smol-builder - Custom Node.js v24.x with Socket patches
    • 6 security and size-optimization patches
    • SEA (Single Executable Application) support
    • VFS (Virtual Filesystem) support
    • Build Pipeline - Visual guide to build process
# Build Node.js
pnpm --filter node-smol-builder build

# Build for specific mode
pnpm --filter node-smol-builder build --dev   # Development (faster JS, larger)
pnpm --filter node-smol-builder build --prod  # Production (smaller, V8 Lite Mode)

WASM

WebAssembly builds with checkpoint-based caching:

# Build WASM modules
pnpm --filter onnxruntime-builder build
pnpm --filter yoga-layout-builder build

ML Models

Quantized AI models for code analysis:

# Build all models (INT4 quantization, production)
pnpm --filter models build

# Development build (INT8, faster)
pnpm --filter models build --dev

Build Features

Checkpoint System

All builders use incremental checkpoints for fast rebuilds:

  • Incremental Builds: Resume from last successful phase
  • CI Caching: GitHub Actions cache integration
  • Progressive Cleanup: Only keep latest checkpoint in CI (saves disk space)
  • Backward Restoration: Walk backwards to find latest valid checkpoint

See Checkpoint Lifecycle for details.

Build Modes

Most packages support two build modes:

  • dev: Fast JS, debug symbols, inspector enabled (~30-40 MB for Node.js)
  • prod: V8 Lite Mode, stripped, compressed (~8-12 MB for Node.js)

Binary Compression

Node.js binaries can be compressed with binpress:

  • 50-70% size reduction
  • Self-extracting with runtime decompression
  • Cached in ~/.socket/_dlx/ for fast subsequent runs
  • Platform-specific algorithms (LZFSE/LZMA/LZMS)

Documentation

CI/CD

GitHub Actions workflows automatically build and cache artifacts:

  • .github/workflows/node-smol.yml - Node.js builds
  • .github/workflows/models.yml - ML model builds
  • .github/workflows/wasm.yml - WASM builds

Checkpoints are cached and restored using content-addressable keys.

License

MIT

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •