@nightowlsdev/storage-supabase
Adapter/StorageMastraA Supabase/Postgres-backed StorageAdapter for Night Owls, agents, runs, events, messages, a Realtime event bus, a versioned agent repo, and a durable Mastra store.
What it does
`createSupabaseStorage(opts)` returns a `StorageAdapter` implementing the core `agents` / `runs` / `events` / `messages` / `scratchpad` seams plus suspend/resume followup tracking, a redacted Realtime broadcast event bus (`events.subscribe`), cross-process cache invalidation via Postgres LISTEN/NOTIFY (`subscribeInvalidations`, so a `publishAgentVersion` on one instance evicts every other instance's RowCache), and a writable versioned agent repo (`agentsWritable`, surfaced as `agents`). It authenticates with the secret (BYPASSRLS) key and is the real authz boundary, scoping every query by tenant in code. Use the Session/Direct Postgres port 5432 (never the 6543 transaction pooler, it throws). `createMastraPgStore` provides a Postgres-backed Mastra store (defaults `disableInit:true`, schema `nightowls`) for durable suspend/resume, injected via `defineSwarm`/`SwarmEngine({ mastraStore })`; `createMastraVectorStore` + `createPostgresFloor` cover vector memory and the multi-lane turn-serialization floor. Ships inlined `MIGRATIONS` and a `nightOwlsPlugin` manifest the CLI ejects into `supabase/migrations/` (you apply them with your own tooling; Night Owls never runs DDL). Management helpers like `publishAgentVersion` reuse the adapter's typed `ctx` handle. There is no credit/billing ledger here, credit metering is host-owned in the platform app, not in this OSS package.
Install
pnpm add @nightowlsdev/storage-supabaseKey exports
- createSupabaseStorage
- SupabaseStorage
- createMastraPgStore
- createMastraVectorStore
- createPostgresFloor
- publishAgentVersion
- rollbackAgentVersion
- listAgentVersions
- makeVersionedRepo
- MIGRATIONS
- nightOwlsPlugin
Usage
import { createSupabaseStorage, createMastraPgStore } from "@nightowlsdev/storage-supabase";
import { defineSwarm } from "@nightowlsdev/core";
// Use the Session/Direct Postgres port 5432 (never the 6543 pooler).
const storage = createSupabaseStorage({ url: process.env.SUPABASE_URL!, secretKey: process.env.SUPABASE_SECRET_KEY! });
const mastraStore = createMastraPgStore({ connectionString: process.env.DATABASE_URL! });
const swarm = defineSwarm({ agents, mastraStore });
// Also exports applyBundle / upgradeBundle, publish a capability bundle version, then apply it into
// a tenant's live agents and upgrade downstream. Full guide → /docs/capability-bundles