Runtime API Overview
The exhaustive reference manual covering all C-compiled bash commands and Javascript modules exposed directly from the hardware loops.
Installation
Fetch the single-binary executable for your architecture.
# 1. Direct curl installation pipeline$ curl -fsSL https://get.sofuu.xyz | bash# 2. Or, manually compile the C-headers$ git clone https://github.com/sofuu-runtime/sofuu.git$ cd sofuu && make release
Quickstart Guide
Sofuu runs `.js` files utilizing native OS bindings bypassing V8-JIT limits. Here is how to create a highly efficient Edge Server that natively proxies a local LLM directly to a web socket.
// Create a file: app.jsconst server = sofuu.http.createServer((req, res) => {if (req.url === "/chat") {const stream = sofuu.ai.stream("Explain quantum mechanics.", {provider: "ollama", model: "llama3"});res.writeHead(200, { "Content-Type": "text/event-stream" });// Background polling bridges the LLM socket directly to the web clientfor await (const chunk of stream) res.write(chunk.text);res.end();} else {res.writeHead(200);res.end("AI Edge Runtime Active");}});server.listen(8080, "0.0.0.0");console.log("Server bound on port 8080.");
Execute the script dynamically from your terminal: $ sofuu run app.js. The background worker threads handle all HTTP/LLM polling continuously!
CLI Toolchain
The executable acts as your compiler, package manager, and REPL all simultaneously. Under the hood, these hit main.c switch cases seamlessly.
| Command Argument | Execution Details |
|---|---|
sofuu | Boots the interactive Read-Eval-Print-Loop (REPL) directly attached to the C-memory pool. |
sofuu run <file.ts|js> | Primary subroutine execution hook. Runs via QuickJS AST evaluation bypassing V8 JIT delays. |
sofuu eval "code" | Evaluates a pure JS string inline from standard bash terminals. |
sofuu bundle <entry> -o <out> | Bundles multiple runtime files/modules into a singular, minified distribution package. |
sofuu install | Native C-based package.json resolution strictly avoiding `node_modules` depth boundaries. |
sofuu add <pkg> | Pulls and registers external module tarballs straight from the public registry. |
Global OS Sandbox
Primitives automatically injected into the root scope upon boot without requiring import statements.
| Primitive Binding | Usage & Details |
|---|---|
sleep(ms) | Synchronous hardware thread-halt blocking the entire event loop natively. |
setTimeout(cb, ms) | Pulls the callback into the libuv non-blocking asynchronous event loop queue. |
setInterval(cb, ms) | Continuous background loop scheduler. Cancel with clearInterval(id). |
process.cwd() | Returns the cwd path natively mapped via standard POSIX. |
process.exit(code) | Hard halts the C-binary execution and cleans the memory pools abruptly. |
process.stdout.write(s) | Raw buffer flushes natively bypassing \n carriage defaults. |
console.time(id) | High resolution performance tracking using hardware clock ticks. Halt with console.timeEnd(). |
console.log() | Standard stringified terminal output multiplexed over OS file descriptors. |
sofuu.ai
The flagship native AI bridge. Connect hardware SIMD registers to multi-host LLMs using Native curl polling without node-http overheads.
| Native Export | Function Behavior |
|---|---|
sofuu.ai.complete(prompt, config) | Returns a Promise<{ text }>. Multiplexes asynchronous inference. Config objects support provider: 'ollama' | 'openai' | 'anthropic'. |
sofuu.ai.stream(prompt, config) | Returns a standard AsyncIterator. The boundary automatically parses SSE protocol natively in C, avoiding heavy regex mapping latency in JS arrays. |
sofuu.ai.similarity(a, b) | Calculates Cosine Similarity directly over the CPU's vector hardware registers mapping two Float32Array operands. |
sofuu.ai.dot(a, b) | Performs raw 32-bit floating point dot product accumulation locally. |
sofuu.ai.l2(a, b) | Computes instantaneous L2 distance geometry bounds on memory arrays. |
sofuu.http & fetch
| Native Export | Function Behavior |
|---|---|
sofuu.fetch(url, opts) | Detached worker pipeline executing HTTP fetching via background polling boundaries. Supports infinite timeout hooks. Provides .text(), .json() resolving buffers. |
sofuu.http.createServer(cb) | Binds a multi-socket HTTP routing listener bypassing traditional Apache overheads. The callback supplies explicit req and res instances. |
res.writeHead(status, hdrs) | Flashes header status values directly across the TCP bound connection stream. |
res.end(data) / res.send(data) | Flushes payload values and detaches the stream from the listening proxy native layer. |
sofuu.http.serve(path) | Static proxy configuration mounting pure filesystem directories onto the event listener. |
sofuu.fs & OS Bridging
| Native Export | Function Behavior |
|---|---|
sofuu.fs.readFile(path) | Loads POSIX mapped text nodes straight from the storage bounds identically bypassing standard containerized sandboxing rules. |
sofuu.fs.writeFile(path, str) | Overwrites OS system file directories aggressively directly interacting with C standard libraries. |
sofuu.fs.appendFile(path, str) | Safe file-boundary appending optimized for local log collection nodes. |
sofuu.fs.readdir(path) | Exposes directory recursive mapping hooks dynamically mapping arrays onto Javascript memory structures. |
sofuu.spawn(args) | Forks POSIX execution instances independent of the Sofuu logic loop. Spawning triggers isolated memory pipelines per shell call natively. |