# Tin > Tin 0.1.0 is a small, statically typed language that compiles to WebAssembly. `tool fn`, `agent` and `guarded` are keywords: the compiler generates the JSON schema a model sees from the function's types and /// docs, and rejects any call path to a guarded tool that does not pass through an agent asking a person first. Programs run under Node, in the browser, under WASI, or as a native binary (agents need the JavaScript host today; see status/). Every code example on this site is compiled and run by the real compiler when the site is built, and every benchmark number comes from bench/results/latest.json. Every page is also available as Markdown: add index.md to its URL (for example https://tin.ad/docs/learn/hello/index.md). The whole of Learn and the reference in one file: https://tin.ad/docs/llms-full.txt ## Learn - [The language: Hello, Tin](https://tin.ad/docs/learn/hello/): Write a program, run it, and read an error message. - [The language: Values and types](https://tin.ad/docs/learn/values/): let, var, numbers, strings and how Tin infers types. - [The language: Functions](https://tin.ad/docs/learn/functions/): Parameters, return types and functions that are one expression. - [The language: Control flow](https://tin.ad/docs/learn/control/): if, loops and ranges. Most things are expressions. - [The language: Structs and methods](https://tin.ad/docs/learn/structs/): Group values into a type and give it methods. - [The language: Sum types and match](https://tin.ad/docs/learn/enums/): A value that is one of several shapes, and a match that handles every one. - [The language: Option, Result and ?](https://tin.ad/docs/learn/errors/): No null and no exceptions: missing values and failures are ordinary values. - [The language: Arrays and maps](https://tin.ad/docs/learn/collections/): Lists of values, lookups by key, and the methods you use every day. - [The language: Closures and pipelines](https://tin.ad/docs/learn/closures/): Functions as values, and |> to chain them. - [The language: Generics](https://tin.ad/docs/learn/generics/): One function or type for many element types. - [The language: Values, var and inout](https://tin.ad/docs/learn/values-not-references/): Every value is a copy. How you change things anyway, and why it helps. - [The language: Durations and frequencies](https://tin.ad/docs/learn/units/): Units are types: 250ms + 3 does not compile. - [The language: Modules](https://tin.ad/docs/learn/modules/): Split a program across files with import. - [The language: Tests](https://tin.ad/docs/learn/tests/): test blocks next to the code, run with tin test. - [Agents: Your first agent](https://tin.ad/docs/learn/first-agent/): An agent block, called like a function. - [Agents: Tools](https://tin.ad/docs/learn/tools/): Give an agent functions to call. Their schemas come from your types. - [Agents: Typed replies](https://tin.ad/docs/learn/typed-replies/): Ask for a struct and get a struct back, not text to parse. - [Agents: Guarded tools and approval](https://tin.ad/docs/learn/approval/): A person approves every call to a dangerous tool. - [Agents: Capabilities](https://tin.ad/docs/learn/capabilities/): The compiler proves what each agent can reach. - [Agents: Sub-agents and teams](https://tin.ad/docs/learn/teams/): Agents that call agents: planners, workers and critics. - [Agents: spawn, await and within](https://tin.ad/docs/learn/concurrency/): Run agents at the same time, cancel them, and give them a time budget. - [Agents: Code as action](https://tin.ad/docs/learn/code-as-action/): An agent that answers with a small, checked Tin program. - [Agents: Record and replay](https://tin.ad/docs/learn/replay/): Save every model answer to a tape and run it again offline. - [Agents: Real models](https://tin.ad/docs/learn/real-models/): Swap the mock for a real model. Nothing else changes. - [Real programs: Calling JavaScript](https://tin.ad/docs/learn/js-interop/): import js and extern fn, checked at the boundary. - [Real programs: A fleet of agents](https://tin.ad/docs/learn/fleet/): A larger program, read piece by piece. - [Real programs: A command-line tool](https://tin.ad/docs/learn/cli/): tin new, input, formatting and building a .wasm. - [Real programs: Tin in the browser](https://tin.ad/docs/learn/browser/): What runs in the playground and how agents work there. - [Real programs: Talking agents](https://tin.ad/docs/learn/voice/): A voice agent holds a live conversation: speech in, speech out, tools in between. - [Real programs: Servers](https://tin.ad/docs/learn/server/): A server where request input is untrusted like a model's reply: injection does not compile, and every agent is an endpoint. - [Real programs: Seeing what an agent did](https://tin.ad/docs/learn/telemetry/): OpenTelemetry traces of every agent question, model call and tool call, with one environment variable. - [Robots: Robots](https://tin.ad/docs/learn/robots/): robot Arm = so101: joints by name, checked at compile time, angles as units. - [Robots: Policies and the control loop](https://tin.ad/docs/learn/policies/): arm.run(policy, 5s, 50Hz): holds, sequences, noise, and tapes that replay exactly. - [Robots: Safety and agents](https://tin.ad/docs/learn/robot-safety/): One gate for every write, and an agent that moves an arm only through it. ## Reference - [The language](https://tin.ad/docs/ref/language/): Everything Tin has, on one page. Every example here is compiled and run when the docs are built. - [Agents and tools](https://tin.ad/docs/ref/agents/): What the compiler generates from a tool fn and an agent, and exactly what the agent loop does at run time. - [Model providers](https://tin.ad/docs/ref/providers/): Every model an agent can use: Anthropic, OpenAI and any OpenAI-compatible server, Gemini, Mistral, local Ollama and llama.cpp, and more, plus fallback and routing. - [The Anthropic API](https://tin.ad/docs/ref/anthropic/): import "std/anthropic": count tokens, list models, upload files, send Message Batches, and the handlers behind Claude's memory and text editor tools, in Tin. - [Talking agents](https://tin.ad/docs/ref/bidi/): Voice agents: speech-to-speech sessions with tools, barge-in and restarts. Implemented for OpenAI Realtime, Gemini Live and Nova Sonic and tested against a mock; no real provider has produced a spoken reply yet. - [Standard library](https://tin.ad/docs/ref/stdlib/): Every function and type available without an import, generated from the library source. - [Glossary](https://tin.ad/docs/ref/glossary/): Tin’s own words, each in one sentence, with where to read more. - [Package docs](https://tin.ad/docs/ref/api/): API documentation generated by tin doc from a package's source and its /// comments. Below: the example package examples/packages/geometry. - [Telemetry](https://tin.ad/docs/ref/telemetry/): OpenTelemetry built in: every agent question, model call and tool call is a span by the GenAI conventions, with metrics and trace context, exported over OTLP from every host. - [Robots](https://tin.ad/docs/ref/robot/): robot declarations, Pose and Angle, the built-in kinematic world and MuJoCo, the control loop and policy forms, the safety gate, arm.drive for agents, and run tapes. - [Servers](https://tin.ad/docs/ref/server/): The server declaration: routes, Request and Response, request taint and its sinks, grants, agent endpoints over HTTP, SSE, WebSocket and MCP, limits and the handler contract. - [Deploying](https://tin.ad/docs/ref/deploy/): tin deploy: a Tin program on Cloudflare, Vercel, Cloud Run, Azure or Lambda, with the target checked like a capability and keys kept out of the build. - [tin.ad](https://tin.ad/docs/ref/cloud/): tin deploy with no target: a URL like brisk-otter-k3m9.tin.ad in one command, each deployment in its own isolate, an EIP-8004 file per agent. - [The tin command](https://tin.ad/docs/ref/cli/): Running, checking, fixing and inspecting programs from the terminal. - [How it works](https://tin.ad/docs/ref/internals/): From source text to a WebAssembly module: the compiler pipeline, the memory layout and the runtime. ## Tour - [Hello, Tin](https://tin.ad/docs/tour/hello/): A program is a file with a main. Strings interpolate, and everything is an expression. - [Structs and sum types](https://tin.ad/docs/tour/types/): Data is described with type. A sum type lists every shape a value can take, and match must handle all of them. Every value is copied, never shared. - [No null, no exceptions](https://tin.ad/docs/tour/errors/): A value that may be missing is an Option. An operation that may fail returns a Result. ? passes the failure up. - [Functions, pipelines and closures](https://tin.ad/docs/tour/functions/): x |> f(y) means f(x, y), and so does x.f(y). Use whichever reads better. - [Generics](https://tin.ad/docs/tour/generics/): Generic code is specialised at compile time. Stack and Stack become separate WebAssembly functions. - [Concurrency without colours](https://tin.ad/docs/tour/concurrency/): There is no async keyword. Any function can suspend, and callers don’t have to know. spawn starts a task, await waits for it, and no task outlives its parent. - [Tools and agents](https://tin.ad/docs/tour/agents/): A tool fn is a function the compiler also describes to a model. An agent is called like a function. - [Guarded tools and teams](https://tin.ad/docs/tour/teams/): Put a human in the loop with one word. Compose agents with the tools you already know: sub-agents, spawn and |>. ## Optional - [Coming from Python or TypeScript](https://tin.ad/docs/from/): the same programs side by side - [Examples](https://tin.ad/docs/examples/): every program in examples/, with its output - [Benchmarks](https://tin.ad/docs/bench/): Tin vs JavaScript, Python and Rust: method, machine, medians and spread, including where Tin loses - [Playground](https://tin.ad/docs/play/): compile and run Tin in the browser - [Status](https://tin.ad/docs/status/): what works today, what is in progress and what is planned, with dates and evidence