Skip to content

Documentation

SDK reference

TypeScriptNode.js 24No runtime dependencies

The public TypeScript API, its options and its error codes.

EpochAgent

new EpochAgent(options) wires a chain, storage, encryption, a serializer and a journal. executeWithAutosave(fn) runs fn(session), commits a final checkpoint marking the execution completed, and returns an ExecutionResult.

Session

MethodWhat it does
restoreOrInitialize(init)Resumes an interrupted execution from its last verified checkpoint, or starts a new one with init(). Refuses to resume from a checkpoint that fails verification.
step(state, context?)Records progress; commits a SAFE_BOUNDARY checkpoint every checkpointPolicy.everySteps calls.
checkpoint(type, state, context?)Commits a checkpoint now (for example MANUAL).
action(spec)Runs a consequential operation through the action gate, with PRE_ACTION and POST_ACTION checkpoints if configured.
complete()Final COMPLETED checkpoint (called by executeWithAutosave).

Options

OptionMeaning
agentIdOff-chain agent name, written into every manifest and checked on recovery
chainRpcCheckpointChain({ provider, ledger, workflowId, from })
storageReplicatedStorage([...adapters], minCopies)
encryptionLocalAesGcmProvider(key) for development, or LitEncryptionProvider(client, conditionsFor) (not tested against Lit)
serializerStateSerializer({ applicationVersion, schemaVersion, serializers?, migrations? })
journalFileJournal(path) (durable) or MemoryJournal (tests)
checkpointPolicy{ everySteps, beforeExternalAction, afterConfirmedAction }
failurePolicy"halt" (default) stops when a checkpoint cannot be persisted; "degraded" continues and refuses high-risk actions
confirmationsBlocks to wait before a checkpoint counts as committed
validators, approveAction policy; high-risk actions without approve() are refused
reconcilers, compensation, partialEffectsStatus queries and compensation per operation type; keep, compensate or halt
telemetryTelemetry with sinks; only allow-listed fields are emitted

Errors

Failures are EpochError with a stable code, a safe message, retryable and non-sensitive details. Codes include PAYLOAD_INTEGRITY_FAILED, PAYLOAD_UNAVAILABLE, INVALID_CHECKPOINT_LINEAGE, CHECKPOINT_NOT_FINALIZED, RECOVERY_NOT_PERMITTED, RECOVERY_ALREADY_IN_PROGRESS, EXTERNAL_ACTION_STATUS_UNKNOWN, STATE_SCHEMA_INCOMPATIBLE, POLICY_VALIDATION_FAILED, ENCRYPTION_ACCESS_DENIED and UNAUTHORIZED.

Python SDK

sdk-python/ (standard library only) implements hashing, canonical JSON, manifests and independent verification with byte-for-byte parity. It does not run agents or decrypt artifacts yet. See sdk-python/README.md.