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 & cloudMigrationsExamplesAgentClient API
A route-aware subclass of Cloudflare AgentClient for non-React browser clients.
Constructor
route replaces the upstream default /agents/<class>/<name> path with Ayjnt’s file route. name is encoded as one path segment.
In a browser on the same origin, omit host and protocol. Supply them when a separate frontend connects to a deployed agent.
import { AgentClient } from "ayjnt/client";
import type SupportAgent from "../../agents/support/agent";
const client = new AgentClient<SupportAgent>({
route: "/support",
name: "customer-42",
onStateUpdate(state, source) {
console.log("state changed", source, state);
},
onIdentity(name, agentType) {
console.log("connected", { name, agentType });
},
});
await client.ready;Inherited client surface
Prefer client.stub.method(...) for normal callable functions: the imported agent type supplies argument and return autocomplete. Use call() only when you need the lower-level RPC options.
| Member | Meaning |
|---|---|
| ready | Promise resolved after server identity arrives |
| state | Latest synchronized state |
| stub.method(...) | Typed callable RPC |
| call(name, args, options) | Lower-level RPC including streaming options |
| setState(next) | Request a client-originated state update |
| close(code?, reason?) | Close and reject pending calls |
// Callable methods are inferred from SupportAgent.
const reply = await client.stub.answer("Where is my order?");
// Read the latest synchronized state.
console.log(client.state);
// If the agent permits client state updates:
client.setState({ ...client.state, draft: "" });
client.close();