@cerefox/memory 0.11.0 → 1.0.0-beta.1
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/AGENT_GUIDE.md +1 -1
- package/AGENT_QUICK_REFERENCE.md +1 -1
- package/dist/bin/cerefox.js +1089 -846
- package/dist/frontend/assets/index-CCkg5PXt.js +125 -0
- package/dist/frontend/assets/index-CCkg5PXt.js.map +1 -0
- package/dist/frontend/index.html +1 -1
- package/dist/server-assets/_shared/ef-auth/index.ts +134 -0
- package/dist/server-assets/_shared/ef-meta/index.ts +1 -1
- package/dist/server-assets/_shared/embeddings/index.ts +42 -2
- package/dist/server-assets/_shared/ingest/chunker.ts +210 -0
- package/dist/server-assets/_shared/ingest/index.ts +32 -0
- package/dist/server-assets/_shared/ingest/pipeline-helpers.ts +135 -0
- package/dist/server-assets/_shared/mcp-auth/index.ts +352 -0
- package/dist/server-assets/_shared/mcp-tools/_chunker.ts +16 -170
- package/dist/server-assets/_shared/mcp-tools/get-help-content.ts +2 -2
- package/dist/server-assets/_shared/mcp-tools/ingest.ts +17 -5
- package/dist/server-assets/db/migrations/0012_content_format.sql +20 -0
- package/dist/server-assets/db/rpcs.sql +88 -13
- package/dist/server-assets/db/schema.sql +7 -1
- package/dist/server-assets/supabase/functions/cerefox-get-audit-log/index.ts +8 -0
- package/dist/server-assets/supabase/functions/cerefox-get-document/index.ts +8 -0
- package/dist/server-assets/supabase/functions/cerefox-ingest/index.ts +29 -173
- package/dist/server-assets/supabase/functions/cerefox-list-projects/index.ts +8 -0
- package/dist/server-assets/supabase/functions/cerefox-list-versions/index.ts +8 -0
- package/dist/server-assets/supabase/functions/cerefox-mcp/index.ts +54 -0
- package/dist/server-assets/supabase/functions/cerefox-mcp/oauth.ts +121 -0
- package/dist/server-assets/supabase/functions/cerefox-metadata/index.ts +8 -0
- package/dist/server-assets/supabase/functions/cerefox-metadata-search/index.ts +8 -0
- package/dist/server-assets/supabase/functions/cerefox-search/index.ts +11 -1
- package/docs/guides/access-paths.md +81 -30
- package/docs/guides/cli.md +32 -3
- package/docs/guides/configuration.md +4 -1
- package/docs/guides/connect-agents.md +102 -54
- package/docs/guides/content-format.md +55 -0
- package/docs/guides/migration-1.0.md +87 -0
- package/docs/guides/ops-scripts.md +1 -1
- package/docs/guides/quickstart.md +20 -0
- package/docs/guides/setup-supabase.md +154 -13
- package/docs/guides/upgrading.md +4 -3
- package/package.json +1 -1
- package/dist/frontend/assets/index-ojNhWSxm.js +0 -125
- package/dist/frontend/assets/index-ojNhWSxm.js.map +0 -1
|
@@ -48,7 +48,7 @@ You need three values from Supabase: a URL, an API key, and a direct Postgres co
|
|
|
48
48
|
See the **[Supabase API keys (2026)](#supabase-api-keys-2026)** section near the end of this guide for the full picture. The short version:
|
|
49
49
|
|
|
50
50
|
- For `CEREFOX_SUPABASE_KEY` (this guide, the web UI, and the CLI): use the new **secret key** (`sb_secret_…`) from **Project Settings → API Keys → Secret key**. The legacy `service_role` JWT also still works during the transition.
|
|
51
|
-
-
|
|
51
|
+
- To call Edge Functions / remote MCP / GPT Actions you need the **Cerefox access token** (`cfx_pat_…`), not a Supabase key. Generate it later with `cerefox token generate` (Step 7 covers the server-side setup). The legacy Supabase anon JWT is retired for Edge Function auth (iter-28E), and `CEREFOX_SUPABASE_ANON_KEY` is no longer used.
|
|
52
52
|
|
|
53
53
|
Either way: keep this key secret — it bypasses Row Level Security and grants full database access.
|
|
54
54
|
|
|
@@ -78,9 +78,9 @@ cerefox init
|
|
|
78
78
|
|
|
79
79
|
When prompted, supply the three values from Step 3 (URL, secret key, database
|
|
80
80
|
URL) plus your `OPENAI_API_KEY`. If you plan to connect AI agents via the
|
|
81
|
-
remote MCP / GPT Actions path,
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
remote MCP / GPT Actions path, you'll add a **Cerefox access token** later by
|
|
82
|
+
running `cerefox token generate` (it upserts `CEREFOX_ACCESS_TOKEN` into this
|
|
83
|
+
same `.env` and sets the accepted set on Supabase — see Step 7).
|
|
84
84
|
|
|
85
85
|
A minimal `~/.cerefox/.env` looks like:
|
|
86
86
|
|
|
@@ -89,8 +89,8 @@ CEREFOX_SUPABASE_URL=https://your-project-ref.supabase.co
|
|
|
89
89
|
CEREFOX_SUPABASE_KEY=sb_secret_...your-secret-key...
|
|
90
90
|
CEREFOX_DATABASE_URL=postgresql://postgres.yourref:yourpassword@aws-N-region.pooler.supabase.com:5432/postgres?sslmode=require
|
|
91
91
|
OPENAI_API_KEY=sk-...
|
|
92
|
-
# Only needed for Edge Functions / MCP / GPT Actions —
|
|
93
|
-
#
|
|
92
|
+
# Only needed for Edge Functions / MCP / GPT Actions — written by `cerefox token generate`:
|
|
93
|
+
# CEREFOX_ACCESS_TOKEN=cfx_pat_...your-cerefox-token...
|
|
94
94
|
```
|
|
95
95
|
|
|
96
96
|
> **Contributors** (repo clone): copy `cp .env.example .env` in the project root
|
|
@@ -131,6 +131,22 @@ Your project ref is in the Supabase dashboard URL:
|
|
|
131
131
|
After it finishes, verify in the Supabase Dashboard → **Edge Functions** — all 9
|
|
132
132
|
functions should appear with a green "Active" status.
|
|
133
133
|
|
|
134
|
+
**Now generate the Edge Function access token.** The Edge Functions authenticate
|
|
135
|
+
callers with a Cerefox access token. Generate one if you'll use **GPT Actions** or a
|
|
136
|
+
**remote HTTP MCP** client, or want a fully-green `cerefox doctor`:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
cerefox token generate
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
This sets the `CEREFOX_ACCESS_TOKENS` secret on Supabase and writes
|
|
143
|
+
`CEREFOX_ACCESS_TOKEN` into your `.env`. It prints the token **once** — store it. You
|
|
144
|
+
paste it by hand only if you connect a **Custom GPT** (Action → Authentication → API
|
|
145
|
+
Key) or a **remote HTTP MCP** client. The **local MCP**, **cloud Claude** (OAuth), and
|
|
146
|
+
the CLI/web reach Supabase over the Data API and don't need it, so this step is
|
|
147
|
+
optional for a local-MCP-only or OAuth-only setup. Lose it → `cerefox token rotate`.
|
|
148
|
+
Re-run `cerefox doctor` — the "edge functions" check goes green.
|
|
149
|
+
|
|
134
150
|
> **`WARNING: Docker is not running` is expected and harmless.** The Supabase CLI checks for
|
|
135
151
|
> Docker (its older local bundler ran in a container) but falls back to bundling the functions
|
|
136
152
|
> server-side — it uploads the source assets (you'll see `Uploading asset (…)` lines) and
|
|
@@ -164,9 +180,10 @@ This points the client at the local stdio server (`cerefox mcp`). To edit
|
|
|
164
180
|
configs by hand or use the remote (Edge Function) HTTP transport, see
|
|
165
181
|
[`connect-agents.md`](connect-agents.md).
|
|
166
182
|
|
|
167
|
-
**For cloud Claude.ai** — connect
|
|
168
|
-
|
|
169
|
-
|
|
183
|
+
**For cloud Claude.ai / Claude mobile** — connect over OAuth to your own
|
|
184
|
+
`cerefox-mcp` Edge Function with the **full hybrid-search tool surface** (not the
|
|
185
|
+
FTS-only `mcp.supabase.com` path). This needs a one-time OAuth setup — see
|
|
186
|
+
[Step 7](#step-7--oauth-for-cloud-agents-claudeai--mobile-optional) below.
|
|
170
187
|
|
|
171
188
|
**For cloud ChatGPT** — create a Custom GPT with GPT Actions pointing at the Edge Functions.
|
|
172
189
|
|
|
@@ -175,6 +192,129 @@ architecture explanation, and ChatGPT GPT Actions setup.
|
|
|
175
192
|
|
|
176
193
|
---
|
|
177
194
|
|
|
195
|
+
## Step 7 — Connect cloud & mobile Claude over OAuth (optional) <a id="step-7--oauth-for-cloud-agents-claudeai--mobile-optional"></a>
|
|
196
|
+
|
|
197
|
+
> **This whole section is optional.** You only need it to connect **claude.ai web and
|
|
198
|
+
> the Claude mobile app** (and any other OAuth-only cloud MCP client). Everything in
|
|
199
|
+
> Step 6 — the local MCP, Claude Desktop, Cursor, Claude Code, Codex, Gemini — works
|
|
200
|
+
> **without** any of this. Skipping Step 7 costs you nothing except cloud/mobile Claude.
|
|
201
|
+
>
|
|
202
|
+
> The one extra moving part OAuth adds is a **hosted consent page** — the screen where
|
|
203
|
+
> you approve the connection. A Supabase Edge Function can't serve it (Supabase rewrites
|
|
204
|
+
> HTML to `text/plain` on the default `*.supabase.co` domain), so this repo ships the
|
|
205
|
+
> page as a **free Cloudflare Worker** with a one-command deploy. Full design + the
|
|
206
|
+
> gotchas we hit: [`docs/specs/oauth-mcp-server-design.md`](../specs/oauth-mcp-server-design.md).
|
|
207
|
+
|
|
208
|
+
Cloud AI agents can only connect to a custom MCP server over **OAuth** — they cannot send
|
|
209
|
+
a static token. Supabase's native **OAuth 2.1 Server** (beta; free on all plans) makes
|
|
210
|
+
`cerefox-mcp` an OAuth-protected resource, so claude.ai and the mobile app get the full
|
|
211
|
+
hybrid-search tool surface (not the FTS-only `mcp.supabase.com` path).
|
|
212
|
+
|
|
213
|
+
**Prerequisite — asymmetric signing keys.** Token validation uses your project's public
|
|
214
|
+
JWKS, so the JWT signing key must be **asymmetric (ES256 or RS256)**, not the HS256
|
|
215
|
+
default. Check **Project Settings → JWT Keys**; if it says HS256, migrate to ES256 first
|
|
216
|
+
(a Supabase-managed key rotation). Existing clients are unaffected (they treat the key as
|
|
217
|
+
an opaque string). New projects often already default to ES256.
|
|
218
|
+
|
|
219
|
+
### 7a. Enable the OAuth 2.1 Server
|
|
220
|
+
|
|
221
|
+
Supabase Dashboard → **Authentication → OAuth Server** (under Configuration):
|
|
222
|
+
|
|
223
|
+
- **Enable** the OAuth 2.1 Server.
|
|
224
|
+
- **Authorization Path**: set to `/consent` (combines with the Site URL in 7b to form the
|
|
225
|
+
consent-page URL).
|
|
226
|
+
- **Dynamic Client Registration (DCR): leave DISABLED.** The dashboard flags open DCR as a
|
|
227
|
+
security risk (any client could self-register), a single-user setup only needs one
|
|
228
|
+
client, and claude.ai's DCR against Supabase is currently unreliable. Register the one
|
|
229
|
+
client by hand in 7d instead.
|
|
230
|
+
|
|
231
|
+
### 7b. Deploy the consent page (free Cloudflare Worker) and point Site URL at it
|
|
232
|
+
|
|
233
|
+
The consent page is a single static file that talks only to Supabase Auth. It embeds a
|
|
234
|
+
**publishable** key (`sb_publishable_…`) — **never the legacy anon JWT**. (The anon JWT is a
|
|
235
|
+
full-KB credential; the publishable key is public-safe — it's rejected by the Edge Function
|
|
236
|
+
gateway and, since schema 0.7.0, cannot call the Data API RPCs either. See the
|
|
237
|
+
[security model](../specs/security-model.md).)
|
|
238
|
+
|
|
239
|
+
Add your publishable key to `~/.cerefox/.env` as the single source
|
|
240
|
+
(`deploy.sh` reads it). Grab it from the dashboard (**Project Settings → API Keys →
|
|
241
|
+
Publishable**) or the CLI:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
npx supabase projects api-keys --project-ref <ref> # find the "publishable" entry
|
|
245
|
+
echo 'CEREFOX_SUPABASE_PUBLISHABLE_KEY=sb_publishable_…' >> ~/.cerefox/.env
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Then deploy to a free Cloudflare Worker (needs a free Cloudflare account — no domain, no
|
|
249
|
+
card):
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
cd cloudflare/cerefox-consent
|
|
253
|
+
./deploy.sh # reads CEREFOX_SUPABASE_URL + CEREFOX_SUPABASE_PUBLISHABLE_KEY from ~/.cerefox/.env
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
See [`cloudflare/cerefox-consent/README.md`](../../cloudflare/cerefox-consent/README.md)
|
|
257
|
+
for the manual `wrangler` commands. It prints your Worker URL, e.g.
|
|
258
|
+
`https://cerefox-consent.<your-subdomain>.workers.dev`.
|
|
259
|
+
|
|
260
|
+
Then Dashboard → **Authentication → URL Configuration → Site URL** = that Worker origin.
|
|
261
|
+
With Authorization Path `/consent`, the consent page lands at `…workers.dev/consent`. (If
|
|
262
|
+
your Site URL was the default `http://localhost:3000`, repointing is safe.)
|
|
263
|
+
|
|
264
|
+
### 7c. Create the owner user + pin it
|
|
265
|
+
|
|
266
|
+
1. **Owner user** — Dashboard → **Authentication → Users → Add user**: your email + a
|
|
267
|
+
strong password. This is the login you type on the consent page (unrelated to your
|
|
268
|
+
Supabase dashboard login). Copy the new user's **UUID**.
|
|
269
|
+
2. **Owner pin** — the only Function secret this feature needs:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
supabase secrets set CEREFOX_OAUTH_OWNER_ID='<owner-user-uuid>' --project-ref <ref>
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
This is the **authorization boundary**, and a server-side value only (never entered
|
|
276
|
+
into claude.ai). The OAuth path **fails closed when this is unset** — the function
|
|
277
|
+
rejects every OAuth token — because otherwise, with Supabase's default email sign-ups
|
|
278
|
+
on, anyone who self-registers could get an accepted token. For a deliberate multi-user
|
|
279
|
+
setup (with sign-ups disabled), opt out explicitly:
|
|
280
|
+
`supabase secrets set CEREFOX_OAUTH_ALLOW_ANY_USER=true`.
|
|
281
|
+
|
|
282
|
+
### 7d. Register the Claude client — **use `client_secret_post`**
|
|
283
|
+
|
|
284
|
+
Dashboard → **Authentication → OAuth Apps → New OAuth App**:
|
|
285
|
+
|
|
286
|
+
- **Client type**: Confidential.
|
|
287
|
+
- **Redirect URI** (exact match, no wildcards): `https://claude.ai/api/mcp/auth_callback`
|
|
288
|
+
- **Token endpoint auth method: `request body` (`client_secret_post`)** — **not** HTTP
|
|
289
|
+
Basic. Claude sends its client secret in the request body; the Basic default silently
|
|
290
|
+
fails the token exchange with an opaque `ofid_…` error and no usable token. **This is
|
|
291
|
+
the single most common setup mistake — get it right here.**
|
|
292
|
+
- Save, then copy the **Client ID** and **Client Secret** (the secret is shown once). You
|
|
293
|
+
paste both into the claude.ai connector — see
|
|
294
|
+
[`connect-agents.md` → Cloud Claude](connect-agents.md#cloud-claude-claudeai-web--mobile-oauth).
|
|
295
|
+
|
|
296
|
+
### 7e. Deploy the function
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
cerefox server deploy --functions-only
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
Deploys `cerefox-mcp` with `--no-verify-jwt` (in-function auth). Then wire the claude.ai
|
|
303
|
+
connector per
|
|
304
|
+
[`connect-agents.md` → Cloud Claude](connect-agents.md#cloud-claude-claudeai-web--mobile-oauth).
|
|
305
|
+
|
|
306
|
+
> **Note — the Cerefox access token (iter-28E).** All nine data Edge Functions (the 8
|
|
307
|
+
> primitives + `cerefox-mcp`) now deploy `--no-verify-jwt` and authenticate the **Cerefox
|
|
308
|
+
> access token** in-function; the legacy anon JWT is retired for Edge Function auth. Before
|
|
309
|
+
> your first token-gated deploy, run `cerefox token generate` — it sets the accepted set
|
|
310
|
+
> (`CEREFOX_ACCESS_TOKENS`, a Supabase Function secret) and writes `CEREFOX_ACCESS_TOKEN` to
|
|
311
|
+
> your local `.env`. Deploying token-gated functions with no token set locks every caller
|
|
312
|
+
> out, so generate the token first. `cerefox-mcp` also accepts an owner-pinned OAuth token
|
|
313
|
+
> (the arm this Step 7 configures); the OAuth path fails closed until `CEREFOX_OAUTH_OWNER_ID`
|
|
314
|
+
> is set (7c).
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
178
318
|
## Troubleshooting
|
|
179
319
|
|
|
180
320
|
### "could not connect to server"
|
|
@@ -203,18 +343,19 @@ In 2026 Supabase rolled out a new API key system. The dashboard now shows two ke
|
|
|
203
343
|
| Family | What you'll see in the dashboard | Use it for |
|
|
204
344
|
|---|---|---|
|
|
205
345
|
| **New (recommended)** | "Publishable key" (`sb_publishable_…`) and "Secret key" (`sb_secret_…`) | `CEREFOX_SUPABASE_KEY` — works end-to-end through the Data API. |
|
|
206
|
-
| **Legacy** | "anon" and "service_role" JWTs (`eyJ…`), filed under a "Legacy" section | `
|
|
346
|
+
| **Legacy** | "anon" and "service_role" JWTs (`eyJ…`), filed under a "Legacy" section | `service_role` still works for `CEREFOX_SUPABASE_KEY` (Data API). The **anon** JWT is **no longer used** for Edge Function auth (retired in iter-28E — see below). |
|
|
207
347
|
|
|
208
348
|
### What goes where in `.env`
|
|
209
349
|
|
|
210
350
|
| Variable | Recommended value | Why |
|
|
211
351
|
|---|---|---|
|
|
212
352
|
| `CEREFOX_SUPABASE_KEY` | New **secret key** (`sb_secret_…`). Legacy `service_role` JWT also works. | Used by `db/client.py` to reach the Data API (PostgREST). Both formats are accepted by the gateway. |
|
|
213
|
-
| `
|
|
353
|
+
| `CEREFOX_ACCESS_TOKEN` | **Cerefox access token** (`cfx_pat_…`) from `cerefox token generate`. | The `Authorization: Bearer …` credential for Edge Function calls (remote MCP, GPT Actions, e2e tests, direct curl). Validated in-function; rotatable via `cerefox token rotate`. |
|
|
354
|
+
| `CEREFOX_SUPABASE_ANON_KEY` | *(deprecated / unused)* | Formerly the Edge Function Bearer credential. Retired in iter-28E; retained only so an old `.env` still parses. |
|
|
214
355
|
|
|
215
|
-
### Why
|
|
356
|
+
### Why Edge Functions use a Cerefox token, not a Supabase key
|
|
216
357
|
|
|
217
|
-
The Data API gateway was migrated in 2026 to accept both the new and legacy key formats. The Edge Function gateway was not
|
|
358
|
+
The Data API gateway was migrated in 2026 to accept both the new and legacy key formats. The Edge Function gateway was not — it rejects the new `sb_publishable_…`/`sb_secret_…` keys as non-JWTs. Rather than pin Edge Function auth to the unrotatable legacy anon JWT (revoke-only on ES256-migrated projects), iter-28E deploys every data Edge Function with `verify_jwt = false` and validates a **Cerefox-managed access token** in-function — a secret, rotatable credential independent of Supabase's key lifecycle. See `docs/specs/ef-auth-migration-design.md`.
|
|
218
359
|
|
|
219
360
|
### Is the legacy key going away?
|
|
220
361
|
|
package/docs/guides/upgrading.md
CHANGED
|
@@ -84,7 +84,8 @@ if you need it.
|
|
|
84
84
|
|
|
85
85
|
**ChatGPT Custom GPT (GPT Actions):** after an upgrade, check the OpenAPI schema
|
|
86
86
|
version in [`connect-agents.md`](connect-agents.md); if it changed, paste the new
|
|
87
|
-
schema into the Custom GPT editor and **re-enter your
|
|
88
|
-
as the Bearer token. (The editor
|
|
89
|
-
|
|
87
|
+
schema into the Custom GPT editor and **re-enter your Cerefox access token**
|
|
88
|
+
(`cfx_pat_…`, from `cerefox token generate`) as the Bearer token. (The editor
|
|
89
|
+
clears the key on every schema save. The legacy Supabase anon JWT is retired for
|
|
90
|
+
Edge Function auth as of iter-28E — see
|
|
90
91
|
[`setup-supabase.md`](setup-supabase.md#supabase-api-keys-2026).)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerefox/memory",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"description": "Cerefox — user-owned shared memory for AI agents. The local TypeScript runtime: stdio MCP server in v0.4; CLI binary added in v0.5; in-process web server in v0.6; ingestion pipeline in v0.7.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/fstamatelopoulos/cerefox",
|