Skip to content

Persistence actions

This page documents Engine/storage operational APIs, not ActionRegistry categories or invented action names. There is no built-in persist:*, storage:*, or save:* action family in engine/actions.ts.

Attach a StorageAdapter, then use the Engine methods:

import { MemoryAdapter } from "./core/storage/MemoryAdapter.js";

engine.useStorage(new MemoryAdapter());
await engine.persist("round-1", "after setup");
const found = await engine.resume("round-1");
const saves = await engine.listSaves();
await engine.deleteSave("round-1");
  • useStorage(adapter) returns the Engine for chaining.
  • persist(name = "autosave", description?) saves the Chronicle's base64 document and emits engine:saved.
  • resume(name = "autosave") returns true when a save was loaded and false when absent. It is rejected while network or sync is attached.
  • listSaves() returns adapter metadata; deleteSave(name) removes a save.
  • enableAutoSave(intervalMs = 30000, name = "autosave") schedules persistence; disableAutoSave() cancels it.

The adapter contract is save(name, data, description?), load(name), delete(name), and list(). The persisted data is a base64 Automerge document, not an action list. Resume clears stale local history and rehydrates the document-backed facades.