Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:0xranx OpenContext Node Native

From Leeroopedia
Knowledge Sources
Domains Infrastructure, Native_Bindings
Last Updated 2026-10-24 10:00 GMT

Overview

Node.js >= 18 environment with NAPI-RS native bindings providing Rust core library access for document store and search operations.

Description

This environment provides the Node.js runtime with prebuilt native Rust bindings loaded via NAPI-RS. The native module (`@aicontextlab/core-native`) exposes SQLite document/folder management and search index operations compiled from the `opencontext-core` Rust crate. Platform-specific binaries are distributed for macOS (x64/arm64), Windows (x64-msvc), and Linux (x64-gnu). The loader tries the npm package first, then falls back to a local development build in `crates/opencontext-node`.

Usage

Use this environment for all CLI and MCP server operations that require the native store (folder/doc CRUD, search, index sync). It is the mandatory prerequisite for any Implementation that calls `src/core/store-native.js` or `src/core/search/native-adapter.js`.

System Requirements

Category Requirement Notes
OS macOS, Windows, Linux Prebuilt binaries for darwin-x64, darwin-arm64, win32-x64-msvc, linux-x64-gnu
Hardware Any modern CPU No GPU required
Disk 50MB for native module Plus SQLite DB and LanceDB index storage

Dependencies

System Packages

  • Node.js >= 18
  • npm or compatible package manager
  • Protobuf compiler (for building from source)

npm Packages

  • `@aicontextlab/core-native` >= 0.2.1 (optional dependency)
  • `better-sqlite3` >= 12.5.0 (fallback native SQLite)
  • `@lancedb/lancedb` >= 0.22.3 (vector store)

Platform-Specific Native Binaries

  • `@aicontextlab/core-native-darwin-x64` (macOS Intel)
  • `@aicontextlab/core-native-darwin-arm64` (macOS Apple Silicon)
  • `@aicontextlab/core-native-win32-x64-msvc` (Windows x64)
  • `@aicontextlab/core-native-linux-x64-gnu` (Linux x64 GNU)

Credentials

No credentials required for the native bindings themselves. The embedding API key (`OPENAI_API_KEY` or `EMBEDDING_API_KEY`) is needed for search index operations.

Quick Install

# Install with native bindings (production)
npm install @aicontextlab/cli --include=optional

# Or build from source (development)
cd crates/opencontext-node
npm ci
npm run build

Code Evidence

Native binding loader fallback logic from `src/core/native.js:24-47`:

function loadNative() {
  if (initialized) return;
  initialized = true;
  // Try 1: Load from npm package (production)
  try {
    native = require('@aicontextlab/core-native');
    loadedFrom = 'npm';
    return;
  } catch (e) {
    npmError = e;
  }
  // Try 2: Load from local build (development)
  try {
    const nativePath = path.join(__dirname, '../../crates/opencontext-node');
    native = require(nativePath);
    loadedFrom = 'local';
  } catch (e) {
    localError = e;
    nativeError = e;
  }
}

Platform detection from `crates/opencontext-node/index.js:31-304`:

switch (platform) {
  case 'darwin':
    // Universal binary, then falls back to arch-specific
    nativeBinding = require('./opencontext-node.darwin-universal.node')
    break
  case 'linux':
    switch (arch) {
      case 'x64':
        if (isMusl()) {
          nativeBinding = require('./opencontext-node.linux-x64-musl.node')
        } else {
          nativeBinding = require('./opencontext-node.linux-x64-gnu.node')
        }
    }
}

Node.js engine constraint from `package.json:48-50`:

"engines": {
  "node": ">=18"
}

Common Errors

Error Message Cause Solution
`OpenContext native bindings not available` Optional dep was skipped during npm install `npm install -g @aicontextlab/cli --include=optional`
`Failed to load native binding` Platform/arch not supported Build from source: `cd crates/opencontext-node && npm run build`
`Unsupported architecture on Linux` Running on unsupported arch (e.g. s390x without musl) Use a supported platform or build from source

Compatibility Notes

  • Alpine Linux (musl): Detected via `isMusl()` check; loads `linux-x64-musl` or `linux-arm64-musl` variant.
  • Windows ARM64: Supported via `win32-arm64-msvc` but not in the default npm optional dependencies list — needs manual build.
  • FreeBSD: x64 only; not in default npm optional dependencies.
  • Development fallback: If npm package is not installed, the loader tries `crates/opencontext-node` local build.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment