Guides
Compiler
Package JavaScript, TypeScript, or Kaze routines as single-file native executables with profiles, embedded memory, and signing.
On this page9 sections
sofuu compile packages a supported JavaScript, TypeScript, or Kaze program as a single-file native executable. It does not invoke an external linker or archive packager: the compiler appends the program payload to a base runtime and writes one file.
Profiles
The profile selects the base runtime. Pick the smallest one that contains the APIs your program calls.
| Profile | Flags | Base | Includes | Use when |
|---|---|---|---|---|
| Micro | --profile micro, --micro, --mcp | sofuu-micro | Minimal QuickJS, libuv, and the micro-runtime surface for MCP servers and single-purpose tools. | MCP servers, single-purpose tools, microservices. |
| Lean (default) | --profile lean, --lean | sofuu-agent | Full QuickJS, libuv, vector memory, sandboxed tools, policy gates, and the agent loop. Drops the local GGUF engine and CLI developer subcommands. | Agents, background daemons, CLI tools, edge workers. |
| Full | --profile full, --full, --with-inference | sofuu | The complete runtime, including local GGUF inference, raw model loaders, dev servers, robotics, and all CLI subcommands. | Offline applications that embed their own weights. |
Omit the profile to get lean. Sizes vary by platform and profile, so measure the artifact you build rather than relying on a fixed number.
Flags
| Flag | Effect |
|---|---|
-o <path> | Output path. Defaults to the entry file name without its extension. |
--profile <name> | Selects micro, lean, or full. |
--embed-brain <file.qtsq> | Packs an encrypted QTSQ memory container into the executable. |
--no-strip | Preserves debugging symbols in the output. |
--base <path> | Uses a custom base executable instead of a built-in profile base. |
Examples
# Lean profile: agents, memory, tools
sofuu compile agent.js -o dist/my-agent
# Micro profile: a small tool or MCP server
sofuu compile agent.js --profile micro -o dist/tool
# Embed a prebuilt memory archive
sofuu compile agent.js --embed-brain ./brain.qtsq -o dist/agent-with-memory
# Package a Kaze routine
sofuu compile agent.kaze -o dist/kaze-agent
The output runs directly:
./dist/my-agent
Embedded memory
--embed-brain packs the entire .qtsq container, including its manifest and segment directory, into the executable. On first launch the archive is extracted beside the binary if it is absent, and the mounted path is exposed as sofuu.memory.embedded. The archive must already exist before you compile; create and populate it with the memory API covered in the memory guide.
MCP servers
sofuu mcp build is a shortcut for the micro profile:
sofuu mcp build server.ts -o dist/my-mcp-server
It is equivalent to:
sofuu compile server.ts --profile micro -o dist/my-mcp-server
The compiled server is one file, but an external server it launches still needs its own runtime and dependencies.
Signing on macOS
Appending data to a signed Mach-O binary invalidates the signature, and macOS kills the process. The compiler strips the old signature, extends the __LINKEDIT segment over the payload, and applies an ad-hoc codesign -s - -f signature. That signature is local, not a distribution identity.
Linux needs no such step: the kernel loader reads payload data after the ELF boundary. Recompiling replaces the previous payload rather than nesting another.
What the output contains
base runtime executable
bundled dependency graph, TypeScript stripped
precompiled QuickJS bytecode
optional QTSQ brain archive
32-byte trailer: SOFUU_BIN_V1, version, flags,
payload length, CRC32
At startup the binary looks for the trailer. When present, it verifies the payload checksum, loads the bytecode, mounts an embedded brain, maps arguments to process.argv and sofuu.args, and runs the program. Without a trailer it behaves as the normal sofuu CLI. SOFUU_PLAIN=1 forces that CLI path for inspection:
SOFUU_PLAIN=1 ./dist/my-agent doctor
Constraints
Only supported programs compile. Programs outside that surface are not guaranteed to build or run, and there is no general bundling guarantee for arbitrary npm trees.
Compiled artifacts may still link OS libraries such as libcurl and libssl, and model-backed workflows still need a model file, backend, or provider. A separate Node.js or Python installation is not needed for supported code, but the operating system and network remain.
Published builds cover macOS arm64 and Linux x86_64 and arm64. Recompile on the target platform when you need a binary for a platform outside that matrix.