Building blocks for frontier OpenAI agents in Rust. Nanocodex empowers you with Codex-level performance anywhere.
Building blocks for frontier OpenAI agents in Rust. Nanocodex empowers you with Codex-level performance anywhere.
Nanocodex is a headless, library-first SDK for building products around one deliberately supported OpenAI coding-agent stack. It is not a provider abstraction and it is not an app server. The public product is an embeddable agent with an owned lifecycle; the native CLI/TUI, browser apps, Python and JavaScript packages, durable actors, sandboxes, voice client, and evaluation harness are consumers that prove the same contract.
The important difference from assembling a model client and a loop is what the caller does not have to rebuild:
The interface is deliberately not part of that list. Consume ordered typed events in a native TUI, wterm, xterm.js, React, logs, or something that only your product could have. The included renderers are complete consumers, not a UI protocol every embedding must adopt.
The native SwiftUI/AppKit macOS app is Nanocodex's only desktop
app. It owns the tiled workspace, persistent sidebar or top tabs, streamed
conversations, agent activity menu bar, and automatic background Mac Hand.
Choosing a folder and sending automatically connects compute for that thread.
Its managed-agent transport and local, VM, and cloud Hand lifecycle live in
@nanocodex/desktop-runtime.
The separate mobile Inbox targets iPhone and iPad only.
Build the desktop app with pnpm build:macos after preparing the documented
bundled Node runtime. The macOS README describes account setup,
native controls, and real-service verification.
Choose the host language; each path runs the Rust-owned agent lifecycle. The
Rust crates and core JavaScript nanocodex binding are registry releases. The
Python binding and JavaScript companion packages under js/ are currently
built from the repository checkout.
…rust,no_run use nanocodex::{Nanocodex, OpenAi};
#[tokio::main] async fn main() -> Result> { let openai = OpenAi::new(std::env::var("OPENAI_API_KEY")?)?; let (agent, _events) = Nanocodex::builder(openai) .instructions( "You are a Rust coding agent. Preserve unrelated work and run relevant tests.", ) .workspace(std::env::current_dir()?) .build()?;
let turn = agent.prompt("Find and fix the failing parser test.").await?;
let result = turn.await?;
println!("{}", result.final_message());
agent.shutdown().await?;
Ok(())
}
…text your application ├─ cheap Nanocodex command handle ── prompt / steer / cancel / fork ├─ optional typed events ─────────── UI / persistence / telemetry ├─ caller-defined tools ──────────── your data and capabilities ├─ optional durability layer ─────── total state / recovery / stores └─ private driver ├─ ordered turns and typed committed history ├─ persistent OpenAI Responses WebSocket + typed retries ├─ Code Mode, MCP, shell sessions, and process cleanup └─ snapshots, compaction, branches, and task-tree children
…rust,no_run use nanocodex::{Nanocodex, OpenAi, Tools, tool};
#[tool(description = "Multiplies two signed integers.")] async fn multiply(left: i64, right: i64) -> Result { left.checked_mul(right).ok_or("integer overflow") }
let tools = Tools::builder().without_defaults().tool(multiply).build()?; let (_agent, _events) = Nanocodex::builder(openai).tools(tools).build()?;
…sh OPENAI_API_KEY=... cargo run -p nanocodex-examples --bin custom-tool OPENAI_API_KEY=... cargo run -p nanocodex-examples --bin mcp
…js import { Agent, Transport } from "nanocodex/node";
const agent = await Agent.create({ transport: Transport.openAi({ apiKey: process.env.OPENAI_API_KEY }), instructions: "You are a coding agent. Make focused changes and verify them.", workspace: process.cwd(), tools: [{ name: "lookup_issue", description: "Return one issue by number.", parameters: { type: "object", properties: { number: { type: "integer" } }, required: ["number"], additionalProperties: false, }, handler: ({ number }) => issueTracker.get(number), }], });
try { const turn = agent.turn.prompt({ input: "Fix issue 42." }); try { const result = await turn.result(); try { console.log(result.finalMessage, await result.usage()); } finally { result.dispose(); } } finally { turn.dispose(); } } finally { await agent.session.shutdown(); }
…js import { Agent, Subagents, Transport } from "nanocodex/browser"; import { browser } from "nanocodex/tools/browser";
const runtime = await browser({ threadId: "project-42", recentImages, rememberImage, });
const agent = await Agent.create({ transport: Transport.hostManaged({ websocketUrl: "/api/responses", createWebSocket: (url) => new WebSocket(url), }), filesystem: runtime.filesystem, instructions: runtime.instructions, executionEnvironment: { currentDate: "2026-08-19", timezone: "America/Los_Angeles", projectInstructions: runtime.projectInstructions, }, tools: [...runtime.tools, ...Subagents.create({ maxConcurrency: 8 })], });
…python import os from nanocodex import Nanocodex
agent, events = Nanocodex( os.environ["OPENAI_API_KEY"], instructions="You are a coding agent. Preserve unrelated work.", )
first = agent.prompt("Remember the identifier PYO3_17.").result() second = agent.prompt("Return the identifier I asked you to remember.").result() print(second.final_message)
branch, branch_events = agent.fork_from(first) print(branch.prompt("What was the identifier?").result().final_message)
branch.shutdown() agent.shutdown()
…rust,ignore use nanocodex::{Nanocodex, OpenAi, Tools}; use nanocodex_browser::BrowserTool;
let tools = Tools::builder().provider(BrowserTool::new()?).build()?; let (_agent, _events) = Nanocodex::builder(openai).tools(tools).build()?;
…sh
just build-vm-guest
nanocodex run "inspect the repository"
--vm .nanocodex/vm/session-rootfs.ext4
--vm-guest-runtime target/aarch64-unknown-linux-musl/debug/nanocodex-vm-guest
--vm-workspace /app
…sh
nanocodex auth login
cargo run -p nanocodex-examples --bin voice
cargo run -p nanocodex-examples --bin realtime-pipe
speaker.pcm
…sh
nanocodex eval add local-smoke --recipe local-smoke
nanocodex eval status local-smoke --json
nanocodex eval run local-smoke nanocodex eval benchmark local-smoke
…text crates/ ├── nanocodex/ facade and prelude ├── nanocodex-oai-api/ OpenAI protocol, context, transport, Tower ├── nanocodex-tools/ tools, Code Mode, MCP, process runtime ├── nanocodex-agent/ owned agent lifecycle ├── nanocodex-subagents/ optional task-tree extension ├── nanocodex-observability/ optional tracing and OTLP setup ├── nanocodex-browser/ Chromium automation ├── nanocodex-vm/ VM lifecycle and guest tools ├── nanocodex-egress/ authenticated HTTP proxy ├── nanocodex-hand/ native capture and input ├── nanocodex-voice*/ voice lifecycle, protocol, native client, C ABI └── experimental/ computer, eval, eval adapters js/ npm packages, account/Connect apps, Workers py/ native Python binding bin/nanocodex/ CLI and Ratatui product consumer examples/ native, language, browser, actor, sandbox proofs evals/ and tasks/ deterministic evaluation inputs benchmarks/ retained measurements and regression gates
Further reading:
- [Facade API documentation](https://docs.rs/nanocodex)
- [Examples and runnable commands](examples/README.md)
- [Rust 0.5 → 0.6 API changelog and migration guide](docs/MIGRATING_0_6.md)
- [Older migration guide (0.2.x)](docs/MIGRATING.md)
- [Responses + Tower design](docs/RESPONSES_TOWER.md)
- [Observability contract](docs/OBSERVABILITY.md)
- [Subagent design](docs/SUBAGENTS.md)
- [VM operations](docs/VM.md)
- [Benchmarks and executable regression gates](benchmarks/)
## License
Licensed under either the Apache License, Version 2.0 or the MIT License, at
your option.No open issues yet, or sync has not completed.