agentskit.js
Packages

@agentskit/statechart

Deterministic, serializable interaction state without a UI or execution-engine dependency.

@agentskit/statechart is a small, framework-neutral primitive for interactive agent experiences that need explicit states and resumable JSON snapshots.

#When to reach for it

  • A chat or agent UI has deterministic interaction states.
  • The same state contract must work across web, native, server, and terminal hosts.
  • A host needs to save and restore interaction state with its own storage.
  • Replay must not depend on hidden clocks or random IDs.

Use @agentskit/runtime instead when you need durable execution, tools, effects, or flow orchestration.

#Install

npm install @agentskit/statechart

#Core operations

  • defineStatechart β€” validate and freeze a trusted definition.
  • createStatechartInstance β€” create validated JSON state with a host-supplied ID and timestamp.
  • transitionStatechart β€” run one pure transition and receive an accepted / rejected result.
  • serializeStatechart β€” produce a versioned JSON-compatible snapshot.
  • restoreStatechart β€” validate an unknown snapshot against the trusted definition and injected context parser.
  • notifyStatechartObserver β€” deliver a completed result without putting observation inside the transition core.

#Ownership boundary

The package owns transition and snapshot semantics. Hosts own persistence, event delivery, deduplication, clocks, IDs, and side effects. Framework adapters own rendering. Runtime owns agent and tool execution.

#Stability

  • Version: 0.1.0
  • Tier: alpha
  • Contract: ADR-0020

#Source

repo: packages/statechart

Explore nearby

✎ Edit this page on GitHubΒ·Found a problem? Open an issue β†’Β·How to contribute β†’

On this page

Ask the docs
Ask anything about AgentsKit. Answers come from the docs corpus and cite their sources.