Skip to content

Latest commit

 

History

2,220 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zttp

Website - Documentation

zttp

The agent writes only what the compiler can prove.

zttp is an agent-compiler: a restricted TypeScript profile with bounded static analyses, a compiler-in-the-loop coding agent, and a local runtime. Describe the handler you want in plain English. The agent drafts it, and the compiler simulates every draft before it reaches disk. A draft that adds a violation is vetoed; supported repairs are normalized or applied before the edit can land. A deployed binary carries the resulting certificate, and an independent consumer checker decides which claims meet the runtime's policy before the handler can serve. The binary needs no npm or Node.

zttp init my-app --expert
# then: "add a GET /health route and a POST /echo that validates JSON"

The agent proposes a compiler-verified edit and you approve only code that passes. When your intent is ambiguous, it asks one question instead of guessing.

Prefer to write the handler yourself? The same compiler runs the watch loop:

zttp dev      # recompile and print a proof card on every save
zttp test
zttp deploy   # self-contained binary, proof ledger entry, signed receipt

Install

Pre-built binaries are published for macOS and Linux on x86_64 and aarch64:

curl -fsSL https://raw.githubusercontent.com/srdjan/zigttp/main/install.sh | sh

Or build from source with Zig 0.16.0:

git clone https://github.com/srdjan/zigttp.git
cd zigttp
zig build -Doptimize=ReleaseFast

First Handler

structural Guardrails<T> = Proof<T,
    | "deterministic"
    | "no_secret_leakage"
    | "injection_safe"
>;

function HomePage(): JSX.Element {
    return (
        <html>
            <head><title>Hello</title></head>
            <body><h1>Hello from zttp</h1></body>
        </html>
    );
}

function handler(req: Request): Guardrails<Response> {
    if (req.path === "/") {
        return Response.html(renderToString(<HomePage />));
    }
    if (req.path === "/api/echo") {
        return Response.json({ method: req.method, path: req.path });
    }
    return Response.text("Not Found", { status: 404 });
}

See examples/ for routing, JSX/TSX, SQL, fetch, durable workflows, and proof examples.

Current Surface

  • Five core commands: init, dev, test, expert, deploy. Advanced commands are listed by zttp help --all.
  • Handler API: function handler(req): Response, plus Response.text, Response.json, and Response.html, and resource(data, affordances) for content-negotiated HAL-JSON and HTMX from one declaration.
  • Language profile: a restricted JS/TS/TSX subset with no var, while, class, or try/catch; unsupported constructs fail at compile time.
  • Proofs: response-path verification, Result/optional checks, state-isolation checks, active Proof<T, P> obligations, flow checks, proof traces, witnesses, proof receipts, and artifact-level proof certificates. Production startup reconstructs the required obligations and executable graph with an independent checker instead of trusting the compiler's serialized verdict.
  • Virtual modules: native modules under zttp:* for env, crypto, auth, validation, cache, SQL, fetch, service calls, routing, durable and multi-handler workflows, structured I/O, logging, IDs, time, text, and more.
  • Local deploy: self-contained binary output under .zttp/deploy/<project-name> with mandatory certificate acceptance and default-on provenance attestation.

Security model

Read the Threat Model before running untrusted code or exposing a binary publicly. Two boundaries are easy to miss:

  • dev and serve from source are not a sandbox. They run handler code with your user's permissions for fast iteration. The enforced surfaces are the precompiled (-Dhandler=) and deploy binaries, which carry and enforce the contract-derived capability allowlist (egress, env, cache, SQL). A policy entry in zttp.json narrows that allowlist at analysis time instead: every project-backed command checks the handler against it, and a policy that cannot be read is an error rather than an unrestricted verdict. See Contracts and Sandboxing.
  • A contract that matches the loaded bytes is still a set of compiler claims. Deployed artifacts must also pass certificate acceptance before startup. Only properties that clear the production policy can enable proof-authoritative caching, pooling, check elision, or durable-workflow guarantees. -Dhandler builds enforce their capability policy but carry no certificate and receive no proof promotion.
  • No TLS. The runtime serves plain HTTP and binds 127.0.0.1 by default. Terminate TLS at a reverse proxy and set the host explicitly before exposing a deployed binary to public traffic.
  • expert defaults to DeepSeek, so a turn sends handler source to a third party. The destination line under the banner states this before the first turn. Select --provider local to keep the source on the machine, through LiquidAI/LFM2.5-2.6B-MLX-8bit on a developer-managed loopback MLX-LM server. Zttp checks readiness but never manages the process or falls back to another provider. Attestation is on by default and publishes a stable per-user public-key fingerprint at /.well-known/zttp-attest.

Numbers

Benchmark claims are kept in Performance. The measured baseline is roughly a 3.5 ms cold-start floor, 7-15 ms typical cold start depending on host load, about 13 MB RSS after first response, and about 112k req/s on the documented HTTP benchmark. These numbers are pending receipt-backed measurement in this repo; zig build bench covers the in-process benchmark suite, while cold-start/RSS/HTTP-throughput evidence still comes from the external/manual harness noted in the performance docs.

Documentation

Start at the Documentation Index.

Contributing

See CONTRIBUTING.md. Security reports go through SECURITY.md.

License

MIT.

About

Native Zig TypeScript runtime that started as port of mquickjs to Zig... and... grew up to something bigger

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

18 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages