Stately
Packages

Stately Agent

Stately Agent is XState plus typed model requests, decisions, and host executors. The state machine remains the single portable agent-logic artifact.

Mental model

  • XState owns states, events, actors, snapshots, persistence semantics, inspection, timers, parallelism, and durable execution.
  • Stately Agent owns model request logic, decision constraints, executor binding, interactions, streaming, eval helpers, and Agent-specific lint.
  • The host framework owns storage, retries, queues, interruption recovery, and provider SDK behavior.

Start here

Core APIs

APIPurpose
setupAgentSchema-first XState setup with Agent request actors
runAgentRun one in-process leg to done, idle, or error
runAgentStreamObserve requests, chunks, transitions, emissions, and settle
initialAgentStep / transitionAgentStepThe pure step API: (state, event) => (state, requests)
getInteraction / eventFromInteractionRender and validate human interactions
isAgentIdleDefault composable idle-state predicate
ContextOf / EventOf / other *Of typesExtract setup and machine types

Entry points

EntryPurpose
@statelyai/agentAuthoring, running, human interaction, and the executor contract
@statelyai/agent/testinglintAgentMachine, simulateAgent, canReach, trajectories, seams
@statelyai/agent/logThe event log: replay, forkEventLog, hand-built entries, stores
@statelyai/agent/ai-sdkcreateAiSdkExecutors, the Vercel AI SDK adapter
@statelyai/agent/openaiExecutors over the raw openai package
@statelyai/agent/machinesPreset machines: tool loop, sequential, parallel, router, supervisor, handoff
@statelyai/agent/otelOpenTelemetry trace handler
@statelyai/agent/validateJSON workflow config validation

Core has no runtime dependency on the AI SDK.

On this page