§ topic
When agents start transacting on your behalf — and they will — make your site speak their protocols. ailang serve-api takes typed AILANG functions and exposes them as REST + MCP + A2A + OpenAPI 3.1 in one command. Your catalogue, your pricing engine, your customer-facing API: contract-verified, agent-discoverable, no glue code.
refreshed daily · last update 2026-06-02 · 18 sketches
Six surfaces an agent looks for on your site. The rubric detects whether you ship each one; ailang serve-api generates most of them from your typed function signatures.
Auto-generated metadata that any agent scanning /.well-known/ will find.
/.well-known/agent.jsonBody mentions /.well-known/agent.json or quotes agent.json.
ailang serve-api writes the A2A agent card automatically from your module exports — capabilities, skills, schemas, authentication metadata. Agents following the A2A discovery convention land on a complete description of what you offer.
Machine-readable spec generated from Hindley-Milner signatures.
openapi.json · /api/_meta/Body mentions openapi.json, openapi.yaml, "swagger", "redoc", or a public API docs route (/api/docs, developers., etc.). Two signals; up to 4 pts combined.
Function types are the spec. Parameters, return type, and effect row determine paths, request bodies, response schemas, and security requirements automatically. Swagger UI lives at /api/_meta/docs; ReDoc at /api/_meta/redoc. No separate spec file to drift.
Your typed functions become tools Claude Desktop, Cursor, and Cline can call.
POST /mcp/Body mentions /mcp/, /mcp/sse, mcp-server, or "model context protocol".
Same module, exposed as MCP tools. Arguments are validated against the same requires contracts the REST endpoint enforces. Run as HTTP at /mcp/ or stdio for desktop hosts.
Event subscriptions modelled as typed handler functions with declared side effects.
/webhooks/...Body mentions webhook, /webhooks, "callback url", or callback_url.
ailang serve-api handles webhooks as typed handler functions. Each handler's effect row declares exactly what it can do; payload schemas come from the input type; retry semantics belong to the handler, not the framework.
Capability budgets are the symmetric server-side primitive for what agents see as 429s.
429 · X-RateLimit-*Body mentions "rate limit", "rate-limit", x-ratelimit, 429, or "throttl…".
Net @limit=N caps each function's outbound calls at compile time. The runtime enforces it, surfacing as 429s. Agents reading your docs get the same contract the type system enforces server-side.
Server-Sent Events and WebSockets as a single typed Stream effect.
text/event-streamBody mentions "server-sent events", text/event-stream, /sse, EventSource, or "streaming endpoint".
std/stream exposes SSE and WebSocket through one Stream effect. Handlers receive typed event values, not raw bytes; back-pressure is in the effect signature. Agents reading incrementally get the same contract as a single-shot request.
Four next-generation agent protocols, each scored 1pt in the rubric. Pre-mass-adoption today; the AILANG primitives they map to are already shipping.
Agent-User Interaction Protocol — 16 typed lifecycle / text / tool-call / state events streamed from agent backend to frontend.
RUN_STARTED · TEXT_MESSAGE_CONTENT · TOOL_CALL_RESULTBody mentions ag-ui, "agent-user interaction", ag-ui-protocol, or agentcore-runtime-ag-ui.
The 16 AG-UI event types map directly to an ADT. std/stream handles SSE/WebSocket transport; AILANG's exhaustive pattern matching makes a skipped event a compile error. AWS Bedrock AgentCore added support in March 2026.
HTTP 402 Payment Required revival — agents pay APIs via signed crypto payment payloads. $600M+ annualised volume on Base/Solana.
PAYMENT-REQUIRED · PAYMENT-SIGNATUREBody mentions x402, x402.org, or "payment-required header".
Net @endpoint-scoped capability budgets bound where the payment payload can flow; requires { amount <= budget } gates the signature; IFC labels keep the signing key tainted away from public sinks. Strong AILANG mapping; high volume on crypto rails today.
Google + Mastercard + 60 orgs — cryptographically signed Mandates (Intent + Cart) authorise agents to spend with price/timing/condition bounds.
intent mandate · cart mandateBody mentions ap2-protocol, "agent payments protocol", "intent mandate", "cart mandate", or "payment mandate".
Mandates are contracts. requires { intent.price <= mandate.maxPrice } + ensures { cart.total <= intent.price } is a one-to-one translation of AP2's Mandate semantics into AILANG. Z3 verifies the bounds at compile time, not at settlement.
MCP alternative. Tools described in a JSON UTCPManual and called via their native protocols (HTTP, gRPC, CLI) — no proxy server.
UTCPManual.jsonBody mentions utcp, "universal tool calling protocol", or utcpmanual.
AILANG function signatures + ailang serve-api emit metadata equivalent to a UTCPManual — name, input/output schema, native endpoint — so consumers can discover and call directly without a proxy in between. Positioned vs MCP; adoption thinner today.