@nightowlsdev/storage-supabase 0.3.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
- import { AgentVersion, ContainerFloor, StorageAdapter } from '@nightowlsdev/core';
1
+ import { AgentVersionContent, SwarmActor, AgentVersionInfo, VersionedRepo, ThreadStore, SwarmEvent, SwarmContext, BundleRepo, BundleWritableRepo, ContainerFloor, StorageAdapter } from '@nightowlsdev/core';
2
+ export { AgentVersionInfo } from '@nightowlsdev/core';
2
3
  import { Pool } from 'pg';
3
4
  import { SupabaseClient } from '@supabase/supabase-js';
4
5
  import { PostgresStore, PgVector } from '@mastra/pg';
@@ -30,23 +31,48 @@ declare function createMastraVectorStore(opts: {
30
31
  dbUrl: string;
31
32
  }): PgVector;
32
33
 
33
- /** The shape callers pass — `version` is derived, not supplied. */
34
- type PublishAgentDef = Omit<AgentVersion, "version"> & {
34
+ /**
35
+ * The WRITABLE agent definition repo (SP6) — the core `VersionedRepo` contract backed by Postgres. Extends the
36
+ * read-only repo with the append-only `publish`/`rollback`/`listVersions` surface. The supabase adapter wires
37
+ * its `agents` field to this (a `VersionedRepo` IS an `AgentRepo`) and also surfaces it as `agentsWritable`.
38
+ *
39
+ * SECURITY: every mutation calls `assertActorMayMutateDefinition(actor)` FIRST (inside the standalone
40
+ * functions) — the non-bypassable agent-bar. The removable `guardDefinitionMutation` POLICY hook is layered on
41
+ * by the caller that owns a `HookDispatcher` (the no-code builder); the storage layer only enforces the
42
+ * framework invariant, which no hook can weaken.
43
+ */
44
+ declare function makeVersionedRepo(ctx: Ctx$1): VersionedRepo;
45
+ /** The shape callers pass — `version` is derived, not supplied. `actor` is the typed `SwarmActor` principal
46
+ * (the agent-bar inspects it); omit it ⇒ the seed system actor. */
47
+ type PublishAgentDef = AgentVersionContent & {
35
48
  tenantId: string;
36
- actor?: string;
49
+ actor?: SwarmActor;
37
50
  version?: number;
38
51
  };
39
- /** Insert a new agent version, flip the head pointer, audit. Used by seeding/CLI (not in the core interface).
40
- * Takes the typed `Ctx` directly (no `__ctx` any-cast); call via `publishAgentVersion(storage.ctx, def)`. */
41
- declare function publishAgentVersion(ctx: Ctx$1, def: PublishAgentDef): Promise<void>;
42
- /** One row of an agent's version history (for rollback UX). */
43
- interface AgentVersionInfo {
52
+ /** Insert a new agent version, flip the head pointer, audit. Used by seeding/CLI (and `makeVersionedRepo`).
53
+ * Takes the typed `Ctx` directly (no `__ctx` any-cast); call via `publishAgentVersion(storage.ctx, def)`.
54
+ * Enforces the non-bypassable agent-bar (SP6): an `agent` principal can NEVER publish. Returns the derived
55
+ * (max+1) version number. */
56
+ declare function publishAgentVersion(ctx: Ctx$1, def: PublishAgentDef): Promise<{
44
57
  version: number;
45
- role: string;
46
- modelId: string;
47
- status: string;
48
- isCurrent: boolean;
49
- }
58
+ }>;
59
+ /**
60
+ * FR-016 — idempotently publish an agent version ONLY if the tenant has no head for that slug yet. The "seed a
61
+ * crew for tenant X if absent" primitive a host loops over `listTenants()` for backfill, so it never re-publishes
62
+ * (no version churn) on a tenant that already has the agent. Returns the head version + whether THIS call created
63
+ * it. (Use `publishAgentVersion` directly when you intentionally want a new version every time.)
64
+ *
65
+ * ATOMIC: the existence check + the publish run in ONE transaction under a per-(tenant,slug) advisory lock, so two
66
+ * concurrent backfill workers for the same slug can't both observe "absent" and each append a version — the second
67
+ * waiter sees v1 already present and returns `created:false`.
68
+ */
69
+ declare function ensureAgentVersion(ctx: Ctx$1, def: PublishAgentDef): Promise<{
70
+ version: number;
71
+ created: boolean;
72
+ }>;
73
+ /** FR-016 — enumerate the engine's tenants (the `orgs` the engine knows), so a host can backfill each tenant's
74
+ * crew without raw SQL against whatever host table happens to hold tenants. Ordered oldest→newest. */
75
+ declare function listTenants(ctx: Ctx$1): Promise<string[]>;
50
76
  /** List an agent's versions (oldest→newest), flagging the current head. Tenant-scoped. Read-only — use it to
51
77
  * pick a `toVersion` for `rollbackAgentVersion`. Returns [] for an unknown agent. */
52
78
  declare function listAgentVersions(ctx: Ctx$1, tenantId: string, slug: string): Promise<AgentVersionInfo[]>;
@@ -61,12 +87,58 @@ declare function rollbackAgentVersion(ctx: Ctx$1, args: {
61
87
  tenantId: string;
62
88
  slug: string;
63
89
  toVersion: number;
64
- actor?: string;
90
+ actor?: SwarmActor;
65
91
  }): Promise<{
66
92
  version: number;
67
93
  restoredFrom: number;
68
94
  }>;
69
95
 
96
+ /**
97
+ * FR-009 — the supported, schema-private way to create the `threads` row a run FK-references. `runs.thread_id` is
98
+ * a NOT NULL FK to `threads(id)`, and `messages.append` throws `unknown thread` without it, so a host previously
99
+ * had to reach into the raw pool and hardcode the engine's private column names. `ensure` does an insert-or-ignore
100
+ * on the primary key, so it is safe to call before every run (the engine calls it at run start). `org_id` /
101
+ * `user_id` are NOT NULL in the schema; `project_id` is the optional host-owned sub-scope.
102
+ */
103
+ declare function makeThreadStore(ctx: Ctx$1): ThreadStore;
104
+
105
+ /** A flat row to upsert: column name → value. Column names are HOST code (trusted), validated to a safe identifier. */
106
+ type UsageRow = Record<string, string | number | boolean | null>;
107
+ interface SupabaseUsageSinkOpts {
108
+ /** The pg pool to write through (e.g. `storage.ctx.pool`). */
109
+ pool: Pool;
110
+ /** Destination table (schema-qualified if needed, e.g. `"public.llm_usage_logs"`). */
111
+ table: string;
112
+ /**
113
+ * The column that carries the engine's per-generation `generationId`. The sink upserts `on conflict (<this>) do
114
+ * nothing`, so a re-delivered usage event (realtime replay, retry) inserts at most once. Must be UNIQUE/PK in
115
+ * the table. Default `"generation_id"`.
116
+ */
117
+ conflictColumn?: string;
118
+ /**
119
+ * Map ONE `swarm.usage` event → the row to insert. Defaults to a sensible shape
120
+ * (`generation_id`, `run_id`, `org_id`, `agent_slug`, `model_id`, `input_tokens`, `output_tokens`, `cost_usd`).
121
+ * Override to match your table. Return `null` to skip an event.
122
+ */
123
+ map?: (ev: Extract<SwarmEvent, {
124
+ type: "swarm.usage";
125
+ }>, ctx: SwarmContext) => UsageRow | null;
126
+ }
127
+ /**
128
+ * FR-004 — an `onEvent` handler that records each per-generation `swarm.usage` into a host Supabase table, keyed
129
+ * idempotently by the engine's stable `generationId` (no double-count under delegation, no OTel pipeline). Wire it
130
+ * onto `defineSwarm({ onEvent })` (compose with your own observer if you have one). Failures are the caller's to
131
+ * handle — the engine swallows a throwing `onEvent` so a sink hiccup never breaks a run, but you should log your own.
132
+ *
133
+ * NOTE: this records the engine's METERED (token-priced) cost — the framework never knows a provider's post-hoc
134
+ * BILLED amount. Use `generationId` to reconcile "actual" cost later if your provider exposes it (see FR-004).
135
+ *
136
+ * @example
137
+ * const sink = supabaseUsageSink({ pool: storage.ctx.pool, table: "llm_usage_logs" });
138
+ * defineSwarm({ ..., onEvent: sink });
139
+ */
140
+ declare function supabaseUsageSink(opts: SupabaseUsageSinkOpts): (ev: SwarmEvent, ctx: SwarmContext) => Promise<void>;
141
+
70
142
  /** A single Night Owls migration: a stable `version`, a human `name`, and fully-qualified `nightowls.*` SQL.
71
143
  * Night Owls contributes these to the host's `supabase/migrations/` (via `owl install`/`db eject`);
72
144
  * the host applies them with its own tooling — Night Owls never runs DDL itself. */
@@ -77,6 +149,37 @@ interface Migration {
77
149
  }
78
150
  declare const MIGRATIONS: Migration[];
79
151
 
152
+ interface HostOrgSourceOpts {
153
+ /** The engine schema the override targets (the deployed name). Default `"nightowls"`. */
154
+ schema?: string;
155
+ /** The host membership table, schema-qualified, e.g. `"public.organization_members"`. */
156
+ membershipTable: string;
157
+ /** The org-id column on the membership table. Default `"organization_id"`. */
158
+ orgIdColumn?: string;
159
+ /** The user-id column on the membership table (compared to `userIdExpr`). Default `"user_id"`. */
160
+ userIdColumn?: string;
161
+ /** The SQL expression for the current user id (must match `userIdColumn`'s type). Default `(select auth.uid())`. */
162
+ userIdExpr?: string;
163
+ /** Migration version label. Default `"host_org_source"`. */
164
+ version?: string;
165
+ }
166
+ /** Generate the SQL that overrides `<schema>.is_org_member` to read the host's membership table (+ the GRANT the
167
+ * Realtime gate needs to read it as the `authenticated` role during a private subscribe). */
168
+ declare function hostOwnedOrgMembershipSql(opts: HostOrgSourceOpts): string;
169
+ /** The same override packaged as a `Migration` so a host can append it to its migration set AFTER `0001_core`
170
+ * (it `create or replace`s the function the core migration defined). */
171
+ declare function hostOwnedOrgMigration(opts: HostOrgSourceOpts): Migration;
172
+
173
+ /** The READ-ONLY bundle repo (head/getVersion/listSlugs). The writable surface lives in `makeBundleWritableRepo`. */
174
+ declare function makeBundleRepo(ctx: Ctx$1): BundleRepo;
175
+ /**
176
+ * The WRITABLE bundle definition repo (BN2) — the core `BundleWritableRepo` contract backed by Postgres. Extends
177
+ * the read repo with the append-only `publish`/`rollback`/`listVersions` surface, on the SAME shared
178
+ * `appendVersion` primitive as agents (so a bundle gets the same race-safe append-and-flip + audit + the
179
+ * published-row immutability trigger). Every mutation enforces the non-bypassable agent-bar first.
180
+ */
181
+ declare function makeBundleWritableRepo(ctx: Ctx$1): BundleWritableRepo;
182
+
80
183
  /**
81
184
  * The Night Owls adapter plugin manifest. `@nightowlsdev/cli` discovers this from the host's installed
82
185
  * `@nightowlsdev/*` deps, dynamic-imports it, and acts on it declaratively:
@@ -162,4 +265,4 @@ interface SupabaseStorage extends StorageAdapter {
162
265
  }
163
266
  declare function createSupabaseStorage(opts: SupabaseStorageOpts): SupabaseStorage;
164
267
 
165
- export { type AgentVersionInfo, type Ctx$1 as Ctx, MIGRATIONS, type Migration, type PostgresFloorOpts, type SupabaseStorage, type SupabaseStorageOpts, createMastraPgStore, createMastraVectorStore, createPostgresFloor, createSupabaseStorage, listAgentVersions, nightOwlsPlugin, publishAgentVersion, rollbackAgentVersion };
268
+ export { type Ctx$1 as Ctx, type HostOrgSourceOpts, MIGRATIONS, type Migration, type PostgresFloorOpts, type PublishAgentDef, type SupabaseStorage, type SupabaseStorageOpts, type SupabaseUsageSinkOpts, type UsageRow, createMastraPgStore, createMastraVectorStore, createPostgresFloor, createSupabaseStorage, ensureAgentVersion, hostOwnedOrgMembershipSql, hostOwnedOrgMigration, listAgentVersions, listTenants, makeBundleRepo, makeBundleWritableRepo, makeThreadStore, makeVersionedRepo, nightOwlsPlugin, publishAgentVersion, rollbackAgentVersion, supabaseUsageSink };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { AgentVersion, ContainerFloor, StorageAdapter } from '@nightowlsdev/core';
1
+ import { AgentVersionContent, SwarmActor, AgentVersionInfo, VersionedRepo, ThreadStore, SwarmEvent, SwarmContext, BundleRepo, BundleWritableRepo, ContainerFloor, StorageAdapter } from '@nightowlsdev/core';
2
+ export { AgentVersionInfo } from '@nightowlsdev/core';
2
3
  import { Pool } from 'pg';
3
4
  import { SupabaseClient } from '@supabase/supabase-js';
4
5
  import { PostgresStore, PgVector } from '@mastra/pg';
@@ -30,23 +31,48 @@ declare function createMastraVectorStore(opts: {
30
31
  dbUrl: string;
31
32
  }): PgVector;
32
33
 
33
- /** The shape callers pass — `version` is derived, not supplied. */
34
- type PublishAgentDef = Omit<AgentVersion, "version"> & {
34
+ /**
35
+ * The WRITABLE agent definition repo (SP6) — the core `VersionedRepo` contract backed by Postgres. Extends the
36
+ * read-only repo with the append-only `publish`/`rollback`/`listVersions` surface. The supabase adapter wires
37
+ * its `agents` field to this (a `VersionedRepo` IS an `AgentRepo`) and also surfaces it as `agentsWritable`.
38
+ *
39
+ * SECURITY: every mutation calls `assertActorMayMutateDefinition(actor)` FIRST (inside the standalone
40
+ * functions) — the non-bypassable agent-bar. The removable `guardDefinitionMutation` POLICY hook is layered on
41
+ * by the caller that owns a `HookDispatcher` (the no-code builder); the storage layer only enforces the
42
+ * framework invariant, which no hook can weaken.
43
+ */
44
+ declare function makeVersionedRepo(ctx: Ctx$1): VersionedRepo;
45
+ /** The shape callers pass — `version` is derived, not supplied. `actor` is the typed `SwarmActor` principal
46
+ * (the agent-bar inspects it); omit it ⇒ the seed system actor. */
47
+ type PublishAgentDef = AgentVersionContent & {
35
48
  tenantId: string;
36
- actor?: string;
49
+ actor?: SwarmActor;
37
50
  version?: number;
38
51
  };
39
- /** Insert a new agent version, flip the head pointer, audit. Used by seeding/CLI (not in the core interface).
40
- * Takes the typed `Ctx` directly (no `__ctx` any-cast); call via `publishAgentVersion(storage.ctx, def)`. */
41
- declare function publishAgentVersion(ctx: Ctx$1, def: PublishAgentDef): Promise<void>;
42
- /** One row of an agent's version history (for rollback UX). */
43
- interface AgentVersionInfo {
52
+ /** Insert a new agent version, flip the head pointer, audit. Used by seeding/CLI (and `makeVersionedRepo`).
53
+ * Takes the typed `Ctx` directly (no `__ctx` any-cast); call via `publishAgentVersion(storage.ctx, def)`.
54
+ * Enforces the non-bypassable agent-bar (SP6): an `agent` principal can NEVER publish. Returns the derived
55
+ * (max+1) version number. */
56
+ declare function publishAgentVersion(ctx: Ctx$1, def: PublishAgentDef): Promise<{
44
57
  version: number;
45
- role: string;
46
- modelId: string;
47
- status: string;
48
- isCurrent: boolean;
49
- }
58
+ }>;
59
+ /**
60
+ * FR-016 — idempotently publish an agent version ONLY if the tenant has no head for that slug yet. The "seed a
61
+ * crew for tenant X if absent" primitive a host loops over `listTenants()` for backfill, so it never re-publishes
62
+ * (no version churn) on a tenant that already has the agent. Returns the head version + whether THIS call created
63
+ * it. (Use `publishAgentVersion` directly when you intentionally want a new version every time.)
64
+ *
65
+ * ATOMIC: the existence check + the publish run in ONE transaction under a per-(tenant,slug) advisory lock, so two
66
+ * concurrent backfill workers for the same slug can't both observe "absent" and each append a version — the second
67
+ * waiter sees v1 already present and returns `created:false`.
68
+ */
69
+ declare function ensureAgentVersion(ctx: Ctx$1, def: PublishAgentDef): Promise<{
70
+ version: number;
71
+ created: boolean;
72
+ }>;
73
+ /** FR-016 — enumerate the engine's tenants (the `orgs` the engine knows), so a host can backfill each tenant's
74
+ * crew without raw SQL against whatever host table happens to hold tenants. Ordered oldest→newest. */
75
+ declare function listTenants(ctx: Ctx$1): Promise<string[]>;
50
76
  /** List an agent's versions (oldest→newest), flagging the current head. Tenant-scoped. Read-only — use it to
51
77
  * pick a `toVersion` for `rollbackAgentVersion`. Returns [] for an unknown agent. */
52
78
  declare function listAgentVersions(ctx: Ctx$1, tenantId: string, slug: string): Promise<AgentVersionInfo[]>;
@@ -61,12 +87,58 @@ declare function rollbackAgentVersion(ctx: Ctx$1, args: {
61
87
  tenantId: string;
62
88
  slug: string;
63
89
  toVersion: number;
64
- actor?: string;
90
+ actor?: SwarmActor;
65
91
  }): Promise<{
66
92
  version: number;
67
93
  restoredFrom: number;
68
94
  }>;
69
95
 
96
+ /**
97
+ * FR-009 — the supported, schema-private way to create the `threads` row a run FK-references. `runs.thread_id` is
98
+ * a NOT NULL FK to `threads(id)`, and `messages.append` throws `unknown thread` without it, so a host previously
99
+ * had to reach into the raw pool and hardcode the engine's private column names. `ensure` does an insert-or-ignore
100
+ * on the primary key, so it is safe to call before every run (the engine calls it at run start). `org_id` /
101
+ * `user_id` are NOT NULL in the schema; `project_id` is the optional host-owned sub-scope.
102
+ */
103
+ declare function makeThreadStore(ctx: Ctx$1): ThreadStore;
104
+
105
+ /** A flat row to upsert: column name → value. Column names are HOST code (trusted), validated to a safe identifier. */
106
+ type UsageRow = Record<string, string | number | boolean | null>;
107
+ interface SupabaseUsageSinkOpts {
108
+ /** The pg pool to write through (e.g. `storage.ctx.pool`). */
109
+ pool: Pool;
110
+ /** Destination table (schema-qualified if needed, e.g. `"public.llm_usage_logs"`). */
111
+ table: string;
112
+ /**
113
+ * The column that carries the engine's per-generation `generationId`. The sink upserts `on conflict (<this>) do
114
+ * nothing`, so a re-delivered usage event (realtime replay, retry) inserts at most once. Must be UNIQUE/PK in
115
+ * the table. Default `"generation_id"`.
116
+ */
117
+ conflictColumn?: string;
118
+ /**
119
+ * Map ONE `swarm.usage` event → the row to insert. Defaults to a sensible shape
120
+ * (`generation_id`, `run_id`, `org_id`, `agent_slug`, `model_id`, `input_tokens`, `output_tokens`, `cost_usd`).
121
+ * Override to match your table. Return `null` to skip an event.
122
+ */
123
+ map?: (ev: Extract<SwarmEvent, {
124
+ type: "swarm.usage";
125
+ }>, ctx: SwarmContext) => UsageRow | null;
126
+ }
127
+ /**
128
+ * FR-004 — an `onEvent` handler that records each per-generation `swarm.usage` into a host Supabase table, keyed
129
+ * idempotently by the engine's stable `generationId` (no double-count under delegation, no OTel pipeline). Wire it
130
+ * onto `defineSwarm({ onEvent })` (compose with your own observer if you have one). Failures are the caller's to
131
+ * handle — the engine swallows a throwing `onEvent` so a sink hiccup never breaks a run, but you should log your own.
132
+ *
133
+ * NOTE: this records the engine's METERED (token-priced) cost — the framework never knows a provider's post-hoc
134
+ * BILLED amount. Use `generationId` to reconcile "actual" cost later if your provider exposes it (see FR-004).
135
+ *
136
+ * @example
137
+ * const sink = supabaseUsageSink({ pool: storage.ctx.pool, table: "llm_usage_logs" });
138
+ * defineSwarm({ ..., onEvent: sink });
139
+ */
140
+ declare function supabaseUsageSink(opts: SupabaseUsageSinkOpts): (ev: SwarmEvent, ctx: SwarmContext) => Promise<void>;
141
+
70
142
  /** A single Night Owls migration: a stable `version`, a human `name`, and fully-qualified `nightowls.*` SQL.
71
143
  * Night Owls contributes these to the host's `supabase/migrations/` (via `owl install`/`db eject`);
72
144
  * the host applies them with its own tooling — Night Owls never runs DDL itself. */
@@ -77,6 +149,37 @@ interface Migration {
77
149
  }
78
150
  declare const MIGRATIONS: Migration[];
79
151
 
152
+ interface HostOrgSourceOpts {
153
+ /** The engine schema the override targets (the deployed name). Default `"nightowls"`. */
154
+ schema?: string;
155
+ /** The host membership table, schema-qualified, e.g. `"public.organization_members"`. */
156
+ membershipTable: string;
157
+ /** The org-id column on the membership table. Default `"organization_id"`. */
158
+ orgIdColumn?: string;
159
+ /** The user-id column on the membership table (compared to `userIdExpr`). Default `"user_id"`. */
160
+ userIdColumn?: string;
161
+ /** The SQL expression for the current user id (must match `userIdColumn`'s type). Default `(select auth.uid())`. */
162
+ userIdExpr?: string;
163
+ /** Migration version label. Default `"host_org_source"`. */
164
+ version?: string;
165
+ }
166
+ /** Generate the SQL that overrides `<schema>.is_org_member` to read the host's membership table (+ the GRANT the
167
+ * Realtime gate needs to read it as the `authenticated` role during a private subscribe). */
168
+ declare function hostOwnedOrgMembershipSql(opts: HostOrgSourceOpts): string;
169
+ /** The same override packaged as a `Migration` so a host can append it to its migration set AFTER `0001_core`
170
+ * (it `create or replace`s the function the core migration defined). */
171
+ declare function hostOwnedOrgMigration(opts: HostOrgSourceOpts): Migration;
172
+
173
+ /** The READ-ONLY bundle repo (head/getVersion/listSlugs). The writable surface lives in `makeBundleWritableRepo`. */
174
+ declare function makeBundleRepo(ctx: Ctx$1): BundleRepo;
175
+ /**
176
+ * The WRITABLE bundle definition repo (BN2) — the core `BundleWritableRepo` contract backed by Postgres. Extends
177
+ * the read repo with the append-only `publish`/`rollback`/`listVersions` surface, on the SAME shared
178
+ * `appendVersion` primitive as agents (so a bundle gets the same race-safe append-and-flip + audit + the
179
+ * published-row immutability trigger). Every mutation enforces the non-bypassable agent-bar first.
180
+ */
181
+ declare function makeBundleWritableRepo(ctx: Ctx$1): BundleWritableRepo;
182
+
80
183
  /**
81
184
  * The Night Owls adapter plugin manifest. `@nightowlsdev/cli` discovers this from the host's installed
82
185
  * `@nightowlsdev/*` deps, dynamic-imports it, and acts on it declaratively:
@@ -162,4 +265,4 @@ interface SupabaseStorage extends StorageAdapter {
162
265
  }
163
266
  declare function createSupabaseStorage(opts: SupabaseStorageOpts): SupabaseStorage;
164
267
 
165
- export { type AgentVersionInfo, type Ctx$1 as Ctx, MIGRATIONS, type Migration, type PostgresFloorOpts, type SupabaseStorage, type SupabaseStorageOpts, createMastraPgStore, createMastraVectorStore, createPostgresFloor, createSupabaseStorage, listAgentVersions, nightOwlsPlugin, publishAgentVersion, rollbackAgentVersion };
268
+ export { type Ctx$1 as Ctx, type HostOrgSourceOpts, MIGRATIONS, type Migration, type PostgresFloorOpts, type PublishAgentDef, type SupabaseStorage, type SupabaseStorageOpts, type SupabaseUsageSinkOpts, type UsageRow, createMastraPgStore, createMastraVectorStore, createPostgresFloor, createSupabaseStorage, ensureAgentVersion, hostOwnedOrgMembershipSql, hostOwnedOrgMigration, listAgentVersions, listTenants, makeBundleRepo, makeBundleWritableRepo, makeThreadStore, makeVersionedRepo, nightOwlsPlugin, publishAgentVersion, rollbackAgentVersion, supabaseUsageSink };