history:// search out of the box.
Where the file lives
With a custom agent directory (
ATOMIC_CODING_AGENT_DIR), paths resolve under that directory’s storage home instead of ~/.atomic.
The default file is named
workflows/journal.sqlite for historical compatibility—it stores your sessions, not retired pre-0.10 workflow runs. To keep sessions local while sharing Intercom over PostgreSQL, set sessions.storage to {} rather than top-level storage: {}. See Sharing storage across hosts..atomic/settings.json:
Sidecar files and runtime behavior
Atomic automatically enables SQLite WAL mode, full disk syncs on commit (synchronous=FULL), and foreign keys. Alongside <file>.sqlite, Atomic and SQLite create several coordination files in the same directory:
Atomic uses the SQLite library bundled with its runtime: package-manager installs use Node.js’s built-in SQLite, while macOS standalone releases ship a matching SQLite build so they do not depend on the older system SQLite on macOS. Run
atomic storage status to inspect the active version on its library: line.
Tuning for many concurrent agents
A SQLite file allows one writer at a time, and there are no concurrency settings to tune insettings.json. When multiple agents on the same machine write concurrently, Atomic queues their write transactions first-come-first-served across all processes. Reads run on a separate connection so they do not wait behind writes.
When multiple agents open a brand-new SQLite file simultaneously, one creates each table while the others wait without piling up on the write lock.
For sustained concurrent writes from many agents—on one machine or across a fleet—use PostgreSQL.
SDK and local SQLite API
This section is for SDK applications that open a SQLite handle directly. To pass a session store to
createAgentSession(), see SDK session storage. To read, branch, and list sessions, see the SessionManager API.openNodeSqliteDatabase() opens a local SQLite file with Atomic’s WAL, durability, foreign-key, and cross-process writer-queue settings:
Queries and transactions
exec,run,get, andallare asynchronous.runreturns{ changes },getreturns one row orundefined, andallreturns an array of rows.- Bindings use positional
?placeholders acceptingnull,number,bigint,string, orUint8Array. Atomic copiesUint8Arrayarguments on call. Integers return asnumberwhen within safe integer range andbigintotherwise. - Strings containing U+0000 fail before execution with
StorageInvalidTextError(reason: "nul-character"). Encode such text as JSON (JSON.stringify) or store it as aUint8Array. - Inside
database.transaction(callback), use only thetransactionhandle passed to the callback. Calling methods on the outerdatabaseinside the callback deadlocks waiting for the active transaction. The transaction handle expires once the callback settles. - Throwing inside the callback rolls back the transaction. Failed commits reject with
StorageUnavailableError; failed rollbacks reject withStorageRollbackError(causeandrollbackCause). close()drains accepted work and is idempotent. Calls made afterclose()reject withStoreClosedError.
Options
openNodeSqliteDatabase(path, options?) creates parent directories automatically. Pass ":memory:" for an in-memory database.
Handle behavior:
- File-backed handles execute statements off the main event-loop thread so lock waits and disk syncs do not block your application.
- Each connection caches up to 256 prepared statements.
openReader()opens a dedicated read-only connection that sees the latest commit without waiting behind writes. Closing the main handle closes its readers.- All file handles targeting the same database on the machine share the same first-come-first-served writer queue.
wrapNodeSqliteDatabase(connection) adapts an existing Node.js DatabaseSync instance. It runs on the calling thread, does not cache prepared statements, and leaves your underlying connection open on close(). Do not interleave raw DatabaseSync calls with wrapper calls.
Diagnostics
getWriterQueueStats(database)reports the fraction of the last 10 seconds that a writer held the lock, queued writer count, wait latency (p50WaitMs,p95WaitMs), andcommitsPerSecond.getWriterQueueDegradation(database)returns anyStorageWriterQueueDegradedErrorwarnings observed on the handle (also logged when debug mode is enabled).- Both functions throw
StorageUnsupportedOperationErroron handles that are not local SQLite handles.
Path helpers
@bastani/atomic/storage (and @bastani/atomic) export sync and async helpers that resolve Atomic’s default paths:
storageHomeDir/storageHomeDirAsyncworkflowsStorageDir/workflowsStorageDirAsyncdefaultSessionDatabasePath/defaultSessionDatabasePathAsyncdefaultSharedStoragePath/defaultSharedStoragePathAsyncstoragePathBaseDir/storagePathBaseDirAsync