Skip to content

src/ and tests/ — hand-authored TypeScript handlers

OpenAPI and MCP cover what an external system already exposes. Realms can also ship hand-authored TypeScript under src/api/, in two forms:

  • Namespace functions — an exported async function becomes a gateway.<namespace>.<name>(...) method. Use these to shape, guard, or compose raw API primitives. Covered in Handler signature.
  • Type methods — an exported class that extends Entity defines a type whose async methods are callable on an in-scope object (movie.streaming({ country })). Use these to give a realm’s entities behaviour. Covered in Type methods.

Both compile to the same dist/ and run in the same sandbox as LLM-generated code (no in-server JS engine), calling back through gateway.<raw-api>.* for primitives — no HTTP-from-inside-HTTP overhead, no second auth dance.