- TypeScript 93.8%
- JavaScript 5.4%
- Python 0.8%
| .github/workflows | ||
| docs | ||
| integrations/claude-code | ||
| migrations | ||
| scripts | ||
| src | ||
| tests | ||
| .dev.vars.example | ||
| .env.example | ||
| .gitignore | ||
| AGENTS.md | ||
| biome.json | ||
| CLAUDE.md | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| README.zh-CN.md | ||
| SECRETS.md | ||
| SECURITY.md | ||
| tsconfig.json | ||
| tsconfig.tests.json | ||
| wrangler.toml | ||
Aelios
A long-term memory for your AI. Switch windows, switch clients, and switch models while keeping one continuous memory.
English | 简体中文 · QQ group 1091783659
Aelios runs on Cloudflare Workers as a memory gateway. Your Chatbox, Claude Code, Codex, or custom agent connects to Aelios, and Aelios forwards the request to your model while recording conversations and bringing back relevant context on every turn.
your client → Aelios (identify, recall, record) → upstream model
Let an AI set it up
If you use Claude Code, Codex, Cursor, or an AI connected to the Cloudflare MCP server, send it this prompt.
Install and set up Aelios (my AI memory gateway) for me. Read https://git.dan9.si/Aelios-project/Aelios/raw/branch/main/docs/setup-with-ai.md first and follow it. When I need to click something in the browser or enter a key myself, stop and tell me where.
This works from a blank Cloudflare account or an existing deployment. The AI copies Aelios into your own GitHub repository and deploys it, creates the Cloudflare API token, configures your first assistant, and optionally imports old memories or chat logs, then hands you a Base URL, API Key, and model name. You only need a free Cloudflare account and a model provider key. You approve login in the browser and store provider keys in your Cloudflare dashboard so credentials stay out of chat. The guide is written in Chinese, and the AI will talk to you in your language.
The recommended setup pairs API mode with the MCP connector. API mode records and recalls automatically on every turn, while MCP lets the assistant actively search, remember, and manage its own notes. If you only have a Claude subscription without API access, connect MCP on its own (and add the Claude Code hook if you use Claude Code).
To install manually, follow the three steps below.
Quick start
1. Deploy
Aelios lives at git.dan9.si/Aelios-project/Aelios. Copy it into a GitHub repository of your own, then let Cloudflare build that repository. Later updates come from the Update button in /admin or a manual pull (see Updating to the latest version).
-
Copy Aelios to your GitHub. The easiest way is GitHub's importer: open https://github.com/new/import, enter
https://git.dan9.si/Aelios-project/Aelios.gitas the source, and pick a name (private is fine). From a terminal, this does the same:git clone https://git.dan9.si/Aelios-project/Aelios.git aelios && cd aelios git remote rename origin dan9 git remote add origin https://github.com/<you>/<your-repo>.git git push -u origin main -
In the Cloudflare dashboard, open Workers & Pages → Create → Import a repository, connect GitHub, and select your repository. Keep the project name
companion-memory-proxy, set the build command tonpm ci, and set the deploy command tonpm run deploy. The deploy script creates the D1 database, Vectorize index, and Queue automatically and applies all migrations. -
Open your Worker's Settings → Variables and Secrets and add a Secret named
CHATBOX_API_KEYwith a strong random password (for exampleopenssl rand -base64 32). This is the only required secret. Optional keys are documented in SECRETS.md.
After deployment, Cloudflare gives you a Worker URL like the following.
https://companion-memory-proxy.<your-subdomain>.workers.dev
Always deploy through npm run deploy. Running a bare wrangler deploy skips resource provisioning and migrations.
The Deploy to Cloudflare button has been removed for now because it needs the source on GitHub. Deployments made with it keep working and update the same way as any other copy.
2. Add an assistant
Open your admin panel in a browser.
https://<your-worker-url>/admin
Sign in with your Worker URL and CHATBOX_API_KEY, then open Settings.
-
Under Models & upstream, enter your 32-character Cloudflare account ID (or a custom OpenAI-compatible base URL). For full chat forwarding through Cloudflare AI Gateway, also add
CLOUDFLARE_API_TOKENas a Worker Secret. -
Under Assistants, click Add assistant and fill in the fields.
Field Purpose Example Name ( slug)URL segment in lowercase letters coderPrimary models Only matching models recall and record memory (supports *)anthropic/claude-opus-4-5,*deepseek*Keys Which Worker API keys may use this assistant check Main key ( CHATBOX_API_KEY) -
Click Save.
Each assistant gets its own URL path. An assistant named coder is served at the following base URL.
https://<your-worker-url>/coder/v1
Only registered primary models trigger recall and recording. Utility models such as background classifiers or lightweight sub-models pass through quietly.
Aelios filters code and work tools from automatic conversation capture for every client by default. It skips code-only input, replaces fenced code blocks within conversation with [code], and omits shell and file-editing tool payloads. To opt out, turn off the code and work-tool filter in the assistant's advanced options.
3. Connect your client
Use CHATBOX_API_KEY as the API key and include the provider prefix in the model name (for example anthropic/claude-opus-4-5 or deepseek/deepseek-chat).
| Client | Configuration |
|---|---|
| Chatbox, Cherry Studio, OpenAI-compatible apps | Base URL https://<your-worker-url>/coder/v1 |
| Claude Code | ANTHROPIC_BASE_URL=https://<your-worker-url>/coder |
| Codex | base_url = "https://<your-worker-url>/coder/v1" with wire_api = "responses" |
Calling /v1 without an assistant slug routes to the first assistant authorized for that API key.
Test the loop by sending "Please remember my test codeword is apple-star-0428.", then asking "What is my test codeword?" in a fresh conversation.
Updating to the latest version
Deployed without a GitHub repository (straight from source with npm run deploy): Update at the top right of /admin installs the newest signed release from git.dan9.si, no GitHub involved. The first time it asks for a Cloudflare token (its button opens the right page: click Create, copy, paste back). Memories and settings stay.
The rest of this section is for deployments built from a GitHub repository.
Your repository stays on the commit you copied until you pull the upstream again. Every way below merges main from git.dan9.si into your main; Cloudflare then builds, runs npm run deploy, applies any new D1 migrations, and deploys.
Your memories, settings, assistants, and secrets live inside your Cloudflare account. Keep runtime configuration inside /admin so updates never hit merge conflicts.
Update from the admin panel
Deploy with Workers Builds on the production main branch and sign in to that Worker's /admin with the main key. Forks and independent copies both work. When an update is available, click Connect GitHub the first time. Create the private update app on GitHub, choose Only select repositories, and install it on your repository. Approve the installation once. Aelios requests fresh one-hour installation tokens from GitHub as needed.
Click Update to run the Sync from dan9 workflow (.github/workflows/sync-from-dan9.yml) in your repository. It fetches the upstream, fast-forwards or merges, and pushes to main. The button follows the workflow run and then the Cloudflare build, and disappears when the new Worker is serving requests. If the merge conflicts, nothing is pushed and the run's summary lists the files and how to fix them by hand.
- The update app needs Actions: Read and write to start the workflow. Apps connected before this change don't have it: on GitHub open Settings → Developer settings → GitHub Apps → your Aelios update app → Permissions, set Actions to Read and write, save, and approve the new permission on the installation page.
- Enable workflows on your repository's Actions tab if GitHub has them switched off (it does for new forks).
- GitHub refuses pushes from the default
GITHUB_TOKENthat change.github/workflows/. When an update touches a workflow file, the run stops and asks for a repository secretAELIOS_SYNC_TOKEN: a personal access token with theworkflowscope (fine-grained: this repository only, Contents and Workflows set to Read and write). Add it under Settings → Secrets and variables → Actions and run again. - You can also start the workflow yourself from the Actions tab. To run it weekly, add the repository variable
AELIOS_AUTO_SYNCwith the valuetrue. To pull from another upstream, setAELIOS_UPSTREAM_URLas a repository variable for the workflow and as a Worker variable for the button.
See the update settings for optional build retries and token-based setup.
Update by hand
From a clone of your repository:
git remote add dan9 https://git.dan9.si/Aelios-project/Aelios.git
git pull --no-rebase dan9 main
git push
The first line is needed only once. The push triggers the Cloudflare build.
Moving an existing deployment
Deployments from a GitHub fork of Aelios-project/Aelios can no longer use Sync fork or the old update button, because the GitHub upstream is gone. Your Cloudflare data is not affected.
- Run the three commands in Update by hand once. This brings in the sync workflow and the new update button.
- Wait for Cloudflare to deploy, then add Actions: Read and write to your update app as described above (or to
AELIOS_UPDATE_GITHUB_TOKENif you use a token). - From then on, use Update in
/admin.
If you renamed the D1 database or Vectorize index during a button setup, keep CMP_D1_NAME and CMP_VECTORIZE_NAME under Settings → Build → Build Variables and Secrets so the deploy script reuses them.
How Aelios works
- Per-turn recall On every human turn to a primary model, Aelios searches Vectorize (
memo-kb) and D1 full-text indexes, scores passages in one batch with Workers AI reranker (@cf/baai/bge-reranker-base), and appends the relevant clean originals to that turn. No generative LLM runs on the recall hot path. - Daytime Dream Enabled by default (
ROLLING_DREAM). As new chats accumulate (10 messages or 8,000 characters by default),@cf/cloudflare/clef-flashchecks whether the stretch contains anything worth keeping, andDREAM_MODEL(defaultworkers-ai/@cf/zai-org/glm-4.7-flash) queues review candidates. Repeated explicit decisions on the same subject share one candidate for the day. Nightly review sees the last confirmation after the day's extraction is complete. - Nightly Dream and Clef review A daily cron (
10 20 * * *UTC) processes the previous day's remaining chats, reviews pending candidates with@cf/cloudflare/clef(CLEF_AUTO_REVIEW, on by default and undoable per item), and writes the daily journal. It uses the remaining time to catch up older dates within a three-day window. The cron also handles weekly and monthly journals and retention. - Multi-space reading Each assistant writes to one
namespaceand can read up to 8 spaces viareadNamespaces(for example reading an archived space or shared documentation alongside its own space). - Provenance and cleanup Raw chat lines live for 7 days by default (
MESSAGES_RETENTION_DAYS). Unused memories expire after 180 days (pinned, identity, and persona memories never expire) and are hard-deleted 30 days later. The trash button on each line in/adminoffers Delete this line, which keeps memories made from it, or Delete with its memories, which also removes memories that explicitly cited that line.
For the full storage, Dream, provenance, and current-decision architecture, read docs/memory-lifecycle.md.
Daily management in /admin
Open /admin to inspect and manage every memory space. The sidebar switches between Chinese and English (following your browser language by default) and between light and dark themes.
| Page | Purpose |
|---|---|
| Home | Today's conversations and the latest Daytime Dream result. Last night’s card shows chat processing, candidate review, and journal writing for the same dialogue date |
| Review | Pending memory candidates. Clef classifies unfamiliar Daytime Dream operations during its nightly evidence review. Proposals it cannot resolve stay visible with a reason. Memory changes appear under Auto-handled this week with one-click undo. When Clef is off, candidates wait for manual or MCP review; an unclassified proposal can be kept as a new memory or discarded. Imported candidates always wait under Imported |
| Journal | Daily, weekly, and monthly entries (weeks older than ~5 weeks fold into the monthly entry), with Rewrite from the originals for days still within transcript retention |
| Memories | Browse, search, edit, merge, and inspect version history across Core, Keepsakes, Our words, Notebook, Handoff, and World facts |
| Star map | Interactive 3D memory graph opened in its own page (/admin/starmap) |
| Dream activity | Daytime retries, nightly batch history, and actual memory changes by date. Open technical details for model names and run IDs. Continue a date from its saved progress |
| Import & export | Backup export (md or jsonl), structured entry import, chat log extraction, and zero-LLM chat archiving |
| Settings | Common settings, assistants, models & upstream (including ChatGPT plan and model list), all settings, keys, and troubleshooting (recall excerpts with original messages and vector maintenance) |
Set First met under Settings → Assistants to see how many days you’ve known the selected assistant on Home. The card uses your browser’s calendar date. A brief shower of ✨ marks day 520, each 100-day milestone, and each anniversary of the date you met (Feb 29 falls on Feb 28 in other years). On those days the gateway also tells the assistant, in that memory space's first three messages of the day by DREAM_TIME_ZONE, so it can bring it up. Coding sessions are left out.
Running Dream by hand
To catch up a missed night or run a specific date right away, follow these steps.
- Open Dream activity and check the memory space under Viewing.
- Choose a chat date under Continue by date. Continue processing on Home fills in the date and turns off preview for you.
- Turn off Preview only if it is selected, then click Continue. The background task picks up from saved progress. You can close the page once it is queued.
- Each run handles one batch (
DREAM_MAX_MESSAGES, default40). Repeat if more chats remain. If the date's extraction is already complete, continuing can run review and write a missing journal without extracting those chats again.
If a task remains unconfirmed for 20 minutes and you have confirmed it stopped, click Mark as stopped to continue from its saved progress.
Export, import, and chat archive
Everything on Import & export operates on the currently selected space.
- Export Downloads
mdorjsonl. Markdown puts one memory per line with date, content,#tags, and a backtick key. Editing and re-importing updates matching keys in place while preserving revision history. - Import entries Accepts lines like
- 2025-12-15 [preference] Likes oolong tea #drinks(date, type, and tags are optional) as well as plain lists or paragraphs. You can save directly (exact duplicates skip, close matches route to Review) or send everything to Review. - Import chat logs Parses ChatGPT and Claude
conversations.json, SillyTavern.jsonl, andName: messagetranscripts in the browser, chunks by day, and extracts candidates viaDREAM_MODELinto Review → Imported. Only lines cited by candidates are stored alongside them, independent of 7-day raw chat cleanup. Re-selecting the same file resumes where you left off. - Chat archive Selecting Archive originals only for keyword search saves full transcripts with zero model calls. Turn on Archive new chats (
CHAT_ARCHIVE_ENABLED) under Settings → Data retention to archive new conversations automatically. MCP clients search archived text withsearch_chat(2 to 120 characters) and pass a hit ID tosearch_chat'saroundparameter to view nearby messages in the same conversation. Archives stay indefinitely by default (CHAT_ARCHIVE_RETENTION_DAYS).
Integrations and optional features
Full Cloudflare AI Gateway and custom model list
- In Cloudflare AI → AI Gateway, create a gateway and store your provider keys (BYOK).
- Add
CLOUDFLARE_API_TOKENas a Worker Secret (permissionsAI Gateway Run,AI Gateway Read,Workers AI Read, and optionallyVectorize Read). - Enter your 32-character Cloudflare account ID under
/admin→ Settings → Models & upstream, then configure your assistants.
Without AI Gateway or a Cloudflare token, memory recall, MCP, and Workers AI Dream still run out of the box.
To keep client model pickers uncluttered, open Settings → Models & upstream → Model list → Edit to pick the models you actually use, add custom provider or dynamic-route names, and test connectivity per model. GET /v1/models then returns that exact list in order while keeping all other models callable by name.
Use your ChatGPT Plus or Pro plan
Connect your personal ChatGPT plan via OpenAI's Sign in with ChatGPT without an OpenAI API key.
- Open
/admin→ Settings → Models & upstream → ChatGPT plan → Manage → Continue with ChatGPT and sign in. - Your browser redirects to an unreachable
127.0.0.1URL. Copy that full address from the address bar, paste it back into/admin, and click Finish sign-in. - Call models as
chatgpt/<model>(click Test to inspect available models) and addchatgpt/*to an assistant's primary models to enable memory.
Tokens are encrypted in D1 with a key derived from CHATBOX_API_KEY (rotating that key requires signing in again). Chat Completions, Anthropic Messages, and Responses clients all work on this route, including function tools and web search, while hosted tools (image generation, file search, code interpreter, remote MCP) are unsupported. You can also set DREAM_MODEL or DIARY_MODEL to chatgpt/<model>, which counts toward your plan usage. Technical details on GPT prompt caching and recall placement live in docs/memory-gateway.md.
MCP connector (Claude app, Claude Code, Codex)
Connect any remote Streamable HTTP MCP client to the following URL.
https://<your-worker-url>/mcp?token=<CHATBOX_API_KEY>
Prefer MEMORY_MCP_API_KEY when sharing connector URLs across devices because ?token= is stored by clients.
- Claude web and mobile apps Add a custom connector at
claude.ai/customize/connectorswith the URL above and set read-only tools to Always allow. Because the official Claude app ignores server-supplied MCP instructions, paste the guidance below into your user preferences or project instructions.
You have access to my Aelios memory connector for long-term memory. Call wake_up at the start of every new conversation before replying. Call recall whenever I mention people, past events, or preferences, or before guessing something about me. Call remember right away when I share new facts, change my mind, or make a promise. Call log_conversation as the chat winds down so tonight's diary and memory pass can reflect on it.
- Direct-chat clients Chats in the official Claude app skip the gateway, so
log_conversationhands the transcript to Aelios for daytime/nightly Dream and journals. Gateway clients record automatically and skiplog_conversation. - Tool sets Twelve everyday tools are listed by default. Append
&tools=allto include maintenance tools (memory_getandmemory_export).
Magpie gateway plugin
If your agents already route through magpie, its Aelios plugin integrates via GET /v1/hook/identities, POST /v1/hook/recall, and POST /v1/hook/record without changing the agent's model upstream. See docs/memory-gateway.md.
Claude Code hook (subscription-only)
If you use Claude Code with a subscription and cannot route through API mode, install the Python hook in integrations/claude-code/README.md for automatic per-message recall and batched transcript ingestion.
Vision proxy (guide-dog)
Add the GUIDE_DOG_API_KEY Worker Secret and point image-description requests to https://<your-worker-url>/v1/guide-dog/chat/completions (or base URL https://<your-worker-url>/v1/guide-dog with model companion). This route describes images and writes no memory.
Companion Worker (Aelios-resident)
Aelios-resident is a separate Durable Object companion running on Cloudflare Workers Free with Telegram and web chat unified into one thread. Point its settings page at your Aelios URL, API key, and assistant slug to give it shared long-term memory, handoff letters, web search, and scheduled check-ins.
Common pitfalls and Workers Free notes
- Deploy command Always run
npm run deployso D1, Vectorize, Queue, and migrations stay provisioned. - Workers Free plan budget Daytime Dream (
ROLLING_DREAM, on by default) and nightly Dream share Workers AI's 10,000 daily neurons. On the Free plan, switch off Daytime Dream in/adminSettings if you want all extraction to run once at night. - Model naming Include the provider prefix (
anthropic/claude-opus-4-5,deepseek/deepseek-chat), and list only primary chat models under an assistant so utility models stay out of memory. - Assistant slugs Use lowercase URL-safe English names with no spaces.
- Vectorize index Keep
memo-kb(1024-dim cosine) intact.
Documentation map
- AI-assisted installation runbook docs/setup-with-ai.md
- Gateway architecture, upstream routing, GPT caching, and magpie hooks docs/memory-gateway.md
- Memory storage, recall, daytime/nightly Dream, provenance, and retention docs/memory-lifecycle.md
- Request sanitization, schema validation, and Anthropic thinking matrix docs/request-contract.md
- Secrets vs. variables and legacy key rotation SECRETS.md
- Security policy and vulnerability reporting SECURITY.md
For maintainers
Cloudflare resources
| Resource | Default name |
|---|---|
| Worker | companion-memory-proxy |
| D1 database | companion_memory_proxy |
| Vectorize index | memo-kb (1024-dim, cosine) |
| Queue | companion-memory (max_batch_size = 1) |
| Embedding model | workers-ai/@cf/baai/bge-m3 |
| Reranker model | @cf/baai/bge-reranker-base |
| Default Dream / Diary model | workers-ai/@cf/zai-org/glm-4.7-flash |
| Triage / Review models | @cf/cloudflare/clef-flash / @cf/cloudflare/clef |
When helping someone deploy, always deploy from the user's own GitHub repository and keep all secrets inside their Cloudflare account.
Endpoints
All endpoints other than /health and /admin require Authorization: Bearer <key> (or ?token= on /mcp). Gateway routes authorize by assistant key lists, and memory APIs enforce memory:read / memory:write scopes.
| Method | Path | Purpose |
|---|---|---|
GET |
/health |
Health and binding status |
GET |
/admin, /admin/starmap |
Admin panel and 3D memory star map |
GET |
/v1/models |
Upstream model catalog or saved modelList |
POST |
/<slug>/v1/chat/completions, /messages, /responses |
Memory-aware model gateway (bare /v1/... uses key's first assistant) |
GET / PATCH |
/api/gateway/config, /env, /spaces, /recalls |
Owner configuration, defaults, spaces, and recall diagnostics |
GET / POST |
/api/gateway/models, /models/test, /chatgpt/* |
Model catalog, single-model test, and ChatGPT plan sign-in |
GET / POST |
/v1/hook/identities, /recall, /record |
External gateway hook endpoints (magpie plugin) |
GET / POST |
/mcp |
Streamable HTTP MCP server |
GET / POST / PATCH / DELETE |
/v1/memories, /v1/memories/:id, /revisions, /export |
Memory CRUD, revision history, and md/jsonl export |
POST |
/v1/memory/recall, /v1/search/memories, /v1/ingest/messages |
Dynamic recall, unmetered raw search, and chat ingest |
DELETE |
/v1/raw/:id |
Delete a raw chat line (?mode=clean default, or ?mode=withdraw to withdraw cited derived memories) |
GET |
/v1/memory_boot |
Cold-start pack (omits current handoff) |
GET / PUT / DELETE |
/v1/handoff |
Current handoff letter with expected_revision optimistic lock |
GET / POST / PATCH / DELETE |
/v1/notebook, /v1/notebook/:id |
Named working-note pages (DELETE ?confirm=all clears the space) |
GET / POST / DELETE |
/v1/precious, /v1/glossary |
Keepsake originals (a client_key on POST /v1/precious writes one once; the same key again returns it, and one with the same content written without a key takes the key) and shared glossary |
GET / POST |
/v1/diary, /v1/diary/recent, /admin/diary-rewrite |
Journal reads and rewriting a retained day from raw chat |
GET / POST |
/v1/dream/status, /run, /resolve, /admin/dream/harvest |
Dream status, sync or queued manual runs, stale-run resolution, and per-night harvest |
GET / POST |
/v1/candidates, /decisions, /:id/undo, /:id/sources |
Candidate review queue, Clef auto-decisions, undo, and cited lines |
GET / POST |
/v1/import/* |
Transfer endpoints (info, entries/preview, entries, batches, chat/chunk, candidates) |
MCP tools
- Default 12 tools
wake_up,recall,remember,keep_moment,forget,learn_word,read_diary,search_chat,log_conversation,list_memories,handoff,notebook - When
CLEF_AUTO_REVIEWis off Also listsmemory_candidatesandmemory_review - With
&tools=allAlso listsmemory_getandmemory_export - Legacy aliases
memory_boot,memory_recall,memory_search,memory_upsert,memory_supersede,memory_archive,memory_delete,memory_ingest,memory_pin,glossary_set,diary_get, andmemory_liststay callable for older scripts while remaining hidden fromtools/list
Dream model and output budget
Background extraction, daytime Dream, weekly summaries, and chat imports use DREAM_MODEL (default workers-ai/@cf/zai-org/glm-4.7-flash). Daily journals and monthly summaries optionally override this with DIARY_MODEL. Output length is configured via DREAM_MAX_TOKENS (1 to 65,536). Leaving any text setting blank in /admin falls back to the effective default displayed beside that field. The repository wrangler.toml sets DREAM_MAX_TOKENS to 8000. If neither the deployment nor Settings provides a current or legacy value, Workers AI uses 8000 and other gateways use the upstream provider's default. The ChatGPT plan route always applies its own limit.
Local verification
Tests require Node.js 22+.
npm ci
npm run verify
npm run lint
npm run verify runs TypeScript typechecks, the full test suite, and five verification scripts including applying every D1 migration in migrations/ to a local database. CI requires npm run lint to pass with zero errors. Existing noNonNullAssertion warnings are non-blocking, and bulk Biome autofix must be avoided because converting x!.y to x?.y hides unexpected nulls.
License
AGPL-3.0. You are free to use and modify Aelios. If you offer a modified version as a network service, publish your modified source code under the same license. The final v1 release is tagged v1-final (licensed under MIT at the time).
Community
QQ group 1091783659