@tty-pt/axil logo

@tty-pt/axil

npm version License: BSD-2-Clause TypeScript Ready WebAssembly Zero Dependencies

Universal Node.js and Browser client and N-API daemon host for axil network transport, persistent WebSocket multiplexing, Xylem module hosting, and the WebAssembly transport bridge (createAxilBridge). Canonical C header: <ttypt/axil.h>.

๐Ÿ“– Full C & Systems Documentation: See the main axil GitHub README for the C event-driven HTTP/WebSocket daemon architecture, module hooks, and chroot security model.


1. Quickstart & Installation

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

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

Launch the Native axil Daemon via CLI (bin/axil.js)

@tty-pt/axil bundles the native C axil server as a Node-API addon (axil.node) loaded with RTLD_GLOBAL. It automatically resolves -m module names across installed @tty-pt/* prebuilds/<platform>-<arch>/ directories:

# Start axil-auren in the background on port 4242 (detaches cleanly)
npx axil -A -p 4242 -m axil-auren

# Run in foreground (-d)
npx axil -A -d -p 4242 -m axil-auren

Connect with AxilClient (Browser & Node.js)

import { AxilClient, createAxilBridge } from "@tty-pt/axil";

// 1. Connect a multiplexed WebSocket client
const client = new AxilClient({ url: "/ws" });

// 2. Subscribe to raw frames or specific multiplexed channels:
//    Channel 0: Text frames
//    Channel 1: Binary Chunk Protocol (#b)
//    Channel 2: Remote Procedure Call (#r)
client.subscribeChannel(1, (bytes) => {
  console.log("BCP frame bytes:", bytes.byteLength);
});

// 3. Send data over the persistent connection
client.send("hello");

2. JavaScript / TypeScript API Reference

N-API Daemon Host & Module Resolution (Node.js)

Native String & HTTP Utilities (N-API with Pure-JS Fallback)

AxilClient

Persistent WebSocket multiplexer supporting text and binary protocol channels:

createAxilBridge (@tty-pt/axil/bridge) & axil-cap.js

Registers WebAssembly host transport imports on a Stele CapabilityRegistry or WASM environment โ€” and registers stele:ws_* runtime capability handlers via registerSteleMainHandler / registerSteleWorkerHandler โ€” so isomorphic C modules can open, send, and receive over axil channels directly.


3. C Development Headers & Native Integration

The C library also provides embedded server and privilege-separation primitives (axil_stop, axil_post_bind, axil_proxy_prefix, axil_deny_prefix, axil_peer_cred, axil_privsep_key, axil_drop_ids, AXIL_LOOPBACK) for desktop, server, and mobile apps:

CFLAGS += -I./node_modules/@tty-pt/axil/include
LDLIBS += -laxil

License

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