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-agentsToolsInterfaces & integrations
Browser clientRouting & middlewareVoiceBrowser toolsMCPEmailObservabilityCLI
Command overviewnewdevrunbuildcompilemigratedeployAPI reference
AgentAgentClientWorkflow classesLocal & cloudMigrationsExamplesCallable methods
Expose a deliberately small typed RPC surface to browser and mobile clients.
Start from a fresh project
This guide is self-contained. Create an empty Ayjnt project, then replace the starter agent with the files shown below. Run commands from the new project directory unless a step says otherwise.
bunx ayjnt new try-callable-methods --empty
cd try-callable-methods
bun install
# remove agents/alive once you are ready to add the guide's filesUse @callable for external clients
Decorate methods that a browser should call through agent.stub. Arguments and return values must be serializable. Plain public methods remain available to internal Durable Object RPC without becoming browser-callable.
import { Agent, callable } from "ayjnt";
export default class ReviewAgent extends Agent {
@callable({ description: "Submit a document for review." })
async submit(documentId: string): Promise<{ accepted: true }> {
await this.queue("review", { documentId });
return { accepted: true };
}
// Internal RPC only: no decorator.
async review(payload: { documentId: string }) {
// ...
}
}Streaming and failures
Use @callable({ streaming: true }) with StreamingResponse for incremental results. Throwing rejects the client call; prefer stable, structured error shapes for failures a UI is expected to handle.
Callable RPC travels over the Agent WebSocket protocol. Agent-to-agent calls use Durable Object RPC instead, which is more direct and does not require the decorator.
Run it and verify the result
Open the co-located browser UI and call the decorated method through agent.stub. TypeScript should autocomplete its arguments and return type.
bun run build
bun run dev
# the local app is now available at http://localhost:8787