# Autolang > An orchestration language designed from the ground up for AI to write correctly the first time - with strict host-governed capabilities. Autolang is an AI-native orchestration language and deterministic virtual machine. It solves the production bottleneck of executing untrusted AI-generated code by providing a safe, statically-typed scripting language with intentional syntax tolerance. Instead of executing untrusted dynamic runtimes (Python or JavaScript), Autolang enforces safety directly at the language layer, executing inside host applications or existing isolation boundaries. ### What Autolang IS / IS NOT - **IS**: A capability-based execution runtime, a deterministic scripting language, a custom VM, and a language-level sandbox for AI. - **IS NOT**: A replacement for Python/JavaScript, Docker, Firecracker, V8 Isolates, or a general-purpose programming language. Host applications (in Node.js, TypeScript, or C++) expose discrete business capabilities. AI scripts orchestrate those capabilities under strict host authority, explicit memory quotas, and opcode instruction budgets. ## Core Architectural Pillars - **Kotlin-Inspired & Syntax-Tolerant:** Adopts familiar syntax patterns (`val`, `var`, `if/else`, `when`, `?.`, `arrayOf()`) so models generate valid code naturally. Unlike Kotlin's rigid compiler, Autolang is designed with intentional syntax tolerance to absorb common formatting drifts and variations, while compile-time static typing and null-safety catch hallucinations before execution. - **Intentional Scope:** Deliberately omits human-scale architectural constructs (interfaces, reflection, deep inheritance, coroutines). Restricting the grammar strictly to workflow control flow eliminates failure surfaces, prevents over-engineering, and minimizes syntax drift. ## 3-Layer Defense Model 1. **Compiler Layer (Static Validation & Diagnostics):** Enforces strict static type checking and symbol resolution before bytecode emission. Absorbs common syntax drift at the compiler boundary and emits structured diagnostics with available capabilities to assist autonomous model self-correction. 2. **Capability Layer (Host Authority & Default Deny):** The AI never receives database credentials, raw network sockets, or OS primitives. The host explicitly registers capabilities. AI scripts execute only registered functions under strict host validation. 3. **VM Layer (Deterministic Resource Bounding):** Executes bytecode inside a custom virtual machine bounded by opcode instruction limits and managed memory quotas. Runaway compute or excessive allocations terminate automatically, protecting host stability. ## Why Autolang Over Tool Calling Tool calling is suitable for single, isolated external queries. When an agent must evaluate collections, process batch records, or execute multi-step business logic, sequential tool calling incurs compounding network latency, escalating token costs, and fragile retry chains. With Autolang: - The model generates the entire orchestration workflow once. - The script compiles and executes locally inside the VM against host capabilities, in a single deterministic pass. - Loops, intermediate variables, and conditional branching resolve deterministically without repeated LLM inference cycles. **Empirical Benchmark Advantage**: In tests across 400 workflows, Autolang achieves a **94.0% zero-shot first-pass success rate**, saving massive token costs associated with tool-calling retries while maintaining a **0.25% runtime failure rate** due to strict compile-time validation. ## System Prompt Snippet When integrating Autolang with AI agents, prepend this system prompt rule to ensure alignment: > You are generating Autolang code, a statically-typed, null-safe orchestration language. You do not have direct access to system I/O, network sockets, or OS primitives. You can ONLY use the capabilities provided in the function signatures given to you. Focus purely on control flow and state management. Do not attempt to use JavaScript or Python dynamic evaluation features. If a compilation error is returned on the next turn, self-correct the variable types or function names based on the error message. ## The Self-Correction Loop Autolang leverages static typing not just for safety, but for autonomous AI error-correction: 1. AI generates script (sometimes with hallucinated names like `email.send()` instead of `mail.sendEmail()`). 2. Autolang compiler halts and emits a strict compiler diagnostic: `Error: Unresolved reference: email`. 3. The host application sends this error back to the AI. 4. The AI immediately sees the type mismatch or missing capability and corrects the call on the second attempt, completely avoiding dangerous execution. ## Quick Syntax Example ```kotlin @import("inventory") @import("notifications") // AI script orchestrating host-registered capabilities val items = inventory.listCurrentStock() var restockCount = 0 items.filter {|item| item.quantity < 5} .forEach {|item| notifications.sendAlert("Ops", "Low stock for " + item.sku) restockCount += 1 } println("Items flagged for restock: " + restockCount) ``` ## Host Integration Example (TypeScript / Node.js) ```typescript import { ACompiler } from 'autolang-compiler'; const compiler = await ACompiler.create(); // Register host capability compiler.registerBuiltInLibrary("notifications", ` @native("sendAlert") fun sendAlert(channel: String, msg: String): Bool `, { autoImport: true }, { sendAlert: (channel, msg) => alertService.dispatch(channel, msg) }); await compiler.compileAndRun("workflow.atl", ` @import("notifications") notifications.sendAlert("Ops", "Batch processing completed successfully") `); ``` ## Primary AI References & Documentation Links - [Full Documentation for LLMs](https://autolang.vercel.app/llms-full.txt): Complete, concatenated documentation text for single-request ingestion. - [AI Agent Language Reference](https://autolang.vercel.app/autolang-ai-reference.md): Complete, single-file reference manual designed for LLMs generating Autolang code. - [Documentation Overview](https://autolang.vercel.app/docs): Introduction to Autolang concepts and runtime architecture. - [Philosophy & Vision](https://autolang.vercel.app/docs/philosophy-vision): Why Autolang exists, capability boundaries, and where it sits relative to container isolation. - [Syntax & Control Flow Guide](https://autolang.vercel.app/docs/language-guide/syntax): Variables, types, functions, control flow (`if`, `when`, `for`, `while`), and closures. - [Classes & Inheritance](https://autolang.vercel.app/docs/language-guide/classes-inheritance): Primary constructors, access modifiers, extension functions, and index operator overloading. - [Standard Library & Modules](https://autolang.vercel.app/docs/language-guide/standard-library): Array, Map, Set, String, Math, Date, and JSON modules. - [Security Model & Sandbox](https://autolang.vercel.app/docs/security-model): Capability isolation, instruction budget caps, and host-managed memory governance. - [System Architecture](https://autolang.vercel.app/docs/architecture): Virtual machine pipeline, bytecode compiler, and embedding host session lifecycle. - [NPM Integration Guide](https://autolang.vercel.app/docs/integration-npm): Embedding Autolang VM into Node.js / TypeScript applications. - [Native Libraries Guide](https://autolang.vercel.app/docs/integration-npm/native-libraries): Creating custom `@native` bindings and host function delegates. - [Best Practices Guide](https://autolang.vercel.app/docs/integration-npm/best-practices): Design patterns for `@js_object`, capability scoping, memory limits, and common mistakes. - [Interactive WebAssembly Playground](https://autolang.vercel.app/docs/editor): In-browser interactive compiler and VM runner.