Two modes
The Treasury store (src/lib/hermesco/store.ts) has two backends and picks one at runtime:
| Condition | Backend | Behaviour |
|---|---|---|
NEXT_PUBLIC_CONVEX_URL is set | Convex | Durable, real-time, survives restarts and scales across instances |
| Otherwise | In-memory | Survives across requests within a single server instance |
Why Convex
On a serverless platform, an in-memory store can reset between requests, which would let a balance appear to jump back to its starting value. Convex gives durable persistence and real-time push, so the Command Center’s Treasury and ledger update live as the agent earns and spends. The schema and functions live in theconvex/ directory.
anyApi from convex/server, so the app compiles and runs whether or not a Convex deployment is connected.
Single-instance deployments
The live deployment runs as a single Fly machine, so even without Convex the in-memory Treasury persists across requests for the life of that instance. Setting a Convex URL upgrades this to durable, multi-instance persistence. See Deployment.Deposit crediting is idempotent on the Stripe session id. When Convex is connected, the idempotency check and the credit are performed in a single mutation so two near-simultaneous returns cannot double-count a deposit.