Const
Optional
baseDir: stringImplements the async iterator protocol for iterating over entities.
Delegates to the values
method for iteration, enabling for await
loops over entities.
Readonly
baseDir: stringReadonly
entityName: EntityNameRemoves and returns the last entity from the persistent list.
Useful for dequeuing items or retrieving recent entries (e.g., latest event in a SwarmName
log).
Adds an entity to the end of the persistent list with a new unique numeric key.
Useful for appending items like messages or events in swarm operations (e.g., within a SwarmName
).
Reads an entity from storage by its ID, parsing it from a JSON file.
Core method for retrieving persisted data (e.g., alive status for a SessionId
in a SwarmName
context).
Iterates over all entities in storage, sorted numerically by ID.
Yields entities in ascending order, useful for batch processing (e.g., listing all SessionId
s in a SwarmName
).
Initializes the storage directory, creating it if it doesn’t exist, and validates existing entities.
Removes invalid JSON files during initialization to ensure data integrity (e.g., for SwarmName
-based alive status).
Writes an entity to storage with the specified ID, serializing it to JSON.
Uses atomic file writing via writeFileAtomic
to ensure data integrity (e.g., persisting AgentName
for a SwarmName
).
Extends
PersistBase
to provide a persistent list structure with push/pop operations. Manages entities with numeric keys for ordered access, suitable for queues or logs in the swarm system.