Documentation menu
Start here
IntroductionGetting startedWrite an agentProject anatomyUnderstand Ayjnt
Harness engineeringTwo runtimesHuman interfacesHow agents workHost bridgeAgent capabilities
Callable methodsState & SQLiteSessions & memorySchedulingWorkflowsDurable executionInter-agent RPCSub-agentsToolsWebAssembly modulesInterfaces & integrations
Browser clientRouting & middlewareVoiceBrowser toolsMCPEmailObservabilityCLI
Command overviewnewdevrunbuildcompilemigratedeployAPI reference
AgentAgentClientWorkflow classesLocal & cloudMigrationsExamplesRouting and middleware
The folder tree is the route tree; middleware follows the same hierarchy.
Routes from files
agents/reports/agent.ts maps to /reports/:name. Nested folders create nested prefixes. A folder may contain both an agent and descendants.
Ayjnt routes HTTP and WebSocket upgrades to the named Durable Object instance and serves a co-located app shell on the same route.
Middleware
Place middleware.ts in an agent folder to wrap that route and every descendant. Use it for authentication, tenancy, request context, and policy before an agent wakes.
import type { Middleware } from "ayjnt";
const auth: Middleware = async (context, next) => {
const token = context.request.headers.get("authorization");
if (!token) return new Response("Unauthorized", { status: 401 });
return next();
};
export default auth;