@tty-pt/sepal logo

@tty-pt/sepal

npm version License: BSD-2-Clause TypeScript Ready Node.js Native WebAssembly Zero Dependencies

Universal Node.js and Browser bindings for libsepal, the pure-C dense vector similarity, bitwise Hamming sketch, and two-stage ANN search engine. Represents the canonical Meaning / Semantic Axis in the Corm Recall Kernel. Canonical C header: <ttypt/sepal.h>.

๐Ÿ“– Full C & Vector Engine Documentation: See the main libsepal GitHub README for two-stage bitwise sign-sketch pre-filtering, SIMD cosine similarity, and C vector store APIs.


1. Quickstart & Installation

npm config set @tty-pt:registry https://tty.pt/npm/
npm install @tty-pt/sepal

Native OS & Mobile Packages (tty.pt): Prebuilt native C packages (libsepal) for Linux (apt, apk, pacman, dnf), macOS (brew), Windows (winget, MSYS2), and OpenBSD (pkg_add), plus static mobile sysroots for Android (https://tty.pt/android/) and iOS (https://tty.pt/ios/ โ€” libsepal.xcframework) are available via the tty.pt package repositories.

import { cosineSimilarity, VectorIndex } from "@tty-pt/sepal";

// 1. Normalized vector cosine similarity calculation
const sim = cosineSimilarity([0.1, 0.9, 0.0], [0.0, 1.0, 0.0]);
console.log("Similarity:", sim); // ~0.99

// 2. Vector indexing & two-stage ANN search
const index = new VectorIndex("./embeddings.sepal");
index.put(101, [0.12, 0.85, 0.44]);
index.put(102, [0.90, 0.10, 0.05]);

// Query top-5 nearest candidates above 0.5 minimum similarity:
const hits = index.search([0.10, 0.80, 0.40], 5, 0.5);
console.log("Top matches:", hits); // [{ ref: 101, score: 0.99 }, ...]

2. Practical Use Cases


3. JavaScript / TypeScript API Reference

cosineSimilarity(vecA: number[] | Float32Array, vecB: number[] | Float32Array): number

Computes the normalized cosine similarity $\frac{\vec{A} \cdot \vec{B}}{\|\vec{A}\| \|\vec{B}\|}$ between two dense float vectors. Executes strictly in compiled WebAssembly / C via sepal_cosine().

VectorIndex

Persistent or in-memory vector index:

SepalVectorAxis

Plug-and-play Semantic Vector Axis adapter for the Corm Recall Kernel (@tty-pt/corm):

getSepalWasm(): WebAssembly.Instance

Returns the WebAssembly instance loaded on the Stele shared-memory substrate.


4. Dual-Engine Runtime


5. C Development Headers & Native Integration

CFLAGS += -I./node_modules/@tty-pt/sepal/include
LDLIBS += -lsepal

License

BSD-2-Clause โ€” Copyright (c) 2026, Paulo Quirino <quirinpa@gmail.com>. See LICENSE.