Agent security and policy

TheUncharted/

zapcode

TypeScript interpreter in Rust that runs agent-written code in a language-level sandbox, with a claimed 2µs cold start and byte-sized snapshots.

What’s new here

Zapcode needs no container and has no dependency on Node.js or V8. It is a small TypeScript interpreter in Rust, so the sandbox is the language itself: guest code has no filesystem, network, env, eval or import, and the only way out is an external function you register. When guest code calls one, the VM suspends and hands back a snapshot that your code resolves and resumes.

What it does

You give it TypeScript source, optional inputs and a list of external function names. It parses (stripping types with oxc), compiles to a stack-based bytecode and runs it in a VM with resource limits. Defaults are 32 MB of memory, 5 seconds of run time, 512 stack frames and 100,000 heap allocations.

The README reports about 2 µs cold start for a simple expression, snapshots under 2 KB and about 10 KB of memory per execution. These are the author’s numbers, and you can reproduce them with cargo bench.

The language is a subset. Classes, generators, async/await, destructuring and closures work. npm packages, the Node standard library and regex execution do not, and Promise.race is missing. There are bindings for Rust, Node.js, Python and WebAssembly. A separate @unchartedfr/zapcode-ai package returns a { system, tools } pair for the Vercel AI SDK, plus adapters for the OpenAI and Anthropic SDKs. It also has an autoFix mode that returns errors to the model so it can retry.

Who it’s for

Anyone building an agent that writes code instead of chaining tool calls, and who wants to run that code in-process without Docker or V8. It suits loops that run many small snippets. It does not suit workloads that need full Node.js or arbitrary npm packages.

Try it

Install the package for your language:

npm install @unchartedfr/zapcode        # npm / yarn / pnpm / bun
pip install zapcode                     # pip / uv

Then run a snippet (from the README):

import { Zapcode, ZapcodeSnapshotHandle } from '@unchartedfr/zapcode';
 
const b = new Zapcode('1 + 2 * 3');
console.log(b.run().output);  // 7

For the agent integration with the Vercel AI SDK:

npm install @unchartedfr/zapcode-ai ai @ai-sdk/anthropic  # or @ai-sdk/amazon-bedrock, @ai-sdk/openai

For Rust, add zapcode-core to Cargo.toml. For the browser, build the WebAssembly crate with wasm-pack build crates/zapcode-wasm --target web.

How mature is it

The README labels it experimental and warns that APIs may change. The repo was created on 2026-03-11 and has 111 stars, 6 forks and 3 contributors. It has 19 releases, the latest being v1.5.3 on 2026-06-20, and it is MIT licensed. The last push was 2026-08-29, but the facts show no commits in the last 90 days. Two issues and four pull requests are open. The README lists 65 adversarial tests across 19 attack categories and says the core crate has no unsafe blocks. It also names known gaps: Object.freeze() is not implemented.