Implementation:0xranx OpenContext NAPI Platform Loader
| Knowledge Sources | |
|---|---|
| Domains | Native_Bindings, Node_js |
| Last Updated | 2026-10-24 00:00 GMT |
Overview
Platform-specific native binding loader that resolves and requires the correct precompiled NAPI-RS binary for the current OS and architecture, then re-exports all OpenContext store and search functions to Node.js.
Description
The auto-generated index.js in crates/opencontext-node/ detects the runtime platform (win32, darwin, linux, freebsd, android) and CPU architecture (x64, arm64, arm, ia32, riscv64, s390x), then loads the matching .node binary — either from a local file or from a platform-specific npm package. On Linux it detects musl vs glibc via process.report or ldd to select the correct ABI variant. All store operations (initEnvironment, listFolders, createDoc, etc.) and search classes (Searcher, Indexer) are destructured and re-exported on module.exports.
Usage
Import this module from Node.js when you need direct access to the Rust core store and search APIs without going through the higher-level src/core/ adapter layer.
Code Reference
Source Location
- Repository: 0xranx_OpenContext
- File: crates/opencontext-node/index.js
- Lines: 1-337
Signature
// Auto-generated by NAPI-RS
module.exports = {
initEnvironment, listFolders, createFolder, renameFolder,
moveFolder, removeFolder, listDocs, createDoc, moveDoc,
renameDoc, removeDoc, setDocDescription, getDocContent,
getDocMeta, getDocByStableId, saveDocContent, generateManifest,
Searcher, Indexer, loadSearchConfig,
startIndexSync, isIndexSyncRunning, getIndexSyncStatus
}
Import
const native = require('@aicontextlab/core-native');
// or: const native = require('opencontext-node');
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| platform | process.platform | Yes | Detected automatically (win32, darwin, linux, etc.) |
| arch | process.arch | Yes | Detected automatically (x64, arm64, arm, etc.) |
| musl check | boolean | No (Linux only) | Detected via process.report or ldd |
Outputs
| Name | Type | Description |
|---|---|---|
| module.exports | All store + search functions re-exported | |
| Searcher | Async search executor class | |
| Indexer | Async index builder class |
Usage Examples
Using Store Operations
const native = require('./crates/opencontext-node/index.js');
// Initialize the environment
const info = native.initEnvironment();
console.log(info.contexts_root);
// Create a folder
native.createFolder({ path: 'myproject', description: 'Project docs' });
// Create a document with stable_id
const doc = native.createDoc({
folderPath: 'myproject',
name: 'readme',
description: 'Project README'
});
Using Search
const native = require('./crates/opencontext-node/index.js');
// Create a searcher and run a query
const searcher = await native.Searcher.create();
const results = await searcher.search({
query: 'model training',
limit: 10,
mode: 'hybrid',
aggregateBy: 'doc'
});
console.log(results.count, results.results);
Related Pages
- Principle:0xranx_OpenContext_Document_Lifecycle_Management
- Principle:0xranx_OpenContext_Context_Discovery
- Principle:0xranx_OpenContext_Hybrid_Search
- Environment:0xranx_OpenContext_Node_Native
</content> </invoke>