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 & cloudMigrationsExamplesWorkflow APIs
Co-located durable workflows without repeated agent classes or binding names.
AgentWorkflow<Params, Progress?>
Use this for a workflow.ts beside an agent. Params types event.payload and the agent’s this.workflow(params) call. Progress optionally types reportProgress().
import { AgentWorkflow } from "ayjnt/workflows";
import type {
AgentWorkflowEvent,
AgentWorkflowStep,
} from "ayjnt/workflows";
type Params = { documentId: string };
export default class ReviewWorkflow extends AgentWorkflow<Params> {
async run(
event: Readonly<AgentWorkflowEvent<Params>>,
step: AgentWorkflowStep,
) {
const result = await step.do("review", async () => {
return { documentId: event.payload.documentId, approved: true };
});
await step.reportComplete(result);
return result;
}
}Start it from the co-located agent
Co-location supplies the workflow binding. The generated declarations connect the workflow’s Params to this.workflow(), so a missing or misspelled field is a TypeScript error.
import { Agent, callable } from "ayjnt";
export default class ReviewAgent extends Agent {
@callable()
async review(documentId: string) {
return this.workflow({ documentId });
}
async onWorkflowComplete(
workflowName: string,
workflowId: string,
result?: unknown,
) {
console.log({ workflowName, workflowId, result });
}
}Workflow<Params, Env?>
Use Workflow for a plain Cloudflare Workflow without an originating agent. Its first generic is still the payload type; the generated environment is the default second generic.
import { Workflow } from "ayjnt/workflows";
export default class NightlyWorkflow
extends Workflow<{ date: string }> {
async run(event: WorkflowEvent<{ date: string }>, step: WorkflowStep) {
return step.do("summarize", () => summarize(event.payload.date));
}
}Exports and escape hatches
| Export | Base | Use |
|---|---|---|
| AgentWorkflow | agents/workflows AgentWorkflow | Co-located agent workflow; Params first |
| Workflow | cloudflare:workers WorkflowEntrypoint | Plain workflow; Params first |
| CloudflareAgentWorkflow | direct upstream export | Escape hatch |
| WorkflowEntrypoint | direct upstream export | Escape hatch |