@wipcomputer/memory-crystal 0.7.29 → 0.7.30

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.
Files changed (70) hide show
  1. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/.env.example +20 -0
  2. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/.publish-skill.json +1 -0
  3. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/CHANGELOG.md +1297 -0
  4. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/CLA.md +19 -0
  5. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/LICENSE +52 -0
  6. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/README-ENTERPRISE.md +226 -0
  7. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/README.md +151 -0
  8. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/RELAY.md +199 -0
  9. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/SKILL.md +462 -0
  10. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/TECHNICAL.md +656 -0
  11. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/_trash/RELEASE-NOTES-v0-7-23.md +48 -0
  12. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/_trash/RELEASE-NOTES-v0-7-25.md +24 -0
  13. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/_trash/RELEASE-NOTES-v0-7-26.md +7 -0
  14. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/_trash/RELEASE-NOTES-v0-7-28.md +31 -0
  15. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/_trash/RELEASE-NOTES-v0-7-29.md +28 -0
  16. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/_trash/RELEASE-NOTES-v0-7-4.md +64 -0
  17. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/_trash/RELEASE-NOTES-v0-7-5.md +19 -0
  18. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/cloud/README.md +116 -0
  19. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/cloud/docs/gpt-system-instructions.md +69 -0
  20. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/cloud/migrations/0001_init.sql +52 -0
  21. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/migrations/0001_init.sql +51 -0
  22. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/migrations/0002_cloud_storage.sql +49 -0
  23. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/openclaw.plugin.json +11 -0
  24. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/package-lock.json +4169 -0
  25. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/package.json +61 -0
  26. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/scripts/crystal-capture.sh +29 -0
  27. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/scripts/deploy-cloud.sh +153 -0
  28. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/scripts/ldm-backup.sh +116 -0
  29. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/scripts/migrate-lance-to-sqlite.mjs +218 -0
  30. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/skills/memory/SKILL.md +438 -0
  31. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/wrangler-demo.toml +8 -0
  32. package/.worktrees/memory-crystal-private--cc-mini-fix-home-fallback/wrangler-mcp.toml +24 -0
  33. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/.env.example +20 -0
  34. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/.publish-skill.json +1 -0
  35. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/CHANGELOG.md +1297 -0
  36. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/CLA.md +19 -0
  37. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/LICENSE +52 -0
  38. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/README-ENTERPRISE.md +226 -0
  39. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/README.md +151 -0
  40. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/RELAY.md +199 -0
  41. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/RELEASE-NOTES-v0.7.30.md +29 -0
  42. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/SKILL.md +462 -0
  43. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/TECHNICAL.md +656 -0
  44. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/_trash/RELEASE-NOTES-v0-7-23.md +48 -0
  45. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/_trash/RELEASE-NOTES-v0-7-25.md +24 -0
  46. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/_trash/RELEASE-NOTES-v0-7-26.md +7 -0
  47. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/_trash/RELEASE-NOTES-v0-7-28.md +31 -0
  48. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/_trash/RELEASE-NOTES-v0-7-29.md +28 -0
  49. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/_trash/RELEASE-NOTES-v0-7-4.md +64 -0
  50. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/_trash/RELEASE-NOTES-v0-7-5.md +19 -0
  51. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/cloud/README.md +116 -0
  52. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/cloud/docs/gpt-system-instructions.md +69 -0
  53. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/cloud/migrations/0001_init.sql +52 -0
  54. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/migrations/0001_init.sql +51 -0
  55. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/migrations/0002_cloud_storage.sql +49 -0
  56. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/openclaw.plugin.json +11 -0
  57. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/package-lock.json +4169 -0
  58. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/package.json +61 -0
  59. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/scripts/crystal-capture.sh +29 -0
  60. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/scripts/deploy-cloud.sh +153 -0
  61. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/scripts/ldm-backup.sh +116 -0
  62. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/scripts/migrate-lance-to-sqlite.mjs +218 -0
  63. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/skills/memory/SKILL.md +438 -0
  64. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/wrangler-demo.toml +8 -0
  65. package/.worktrees/memory-crystal-private--cc-mini-release-notes-v0.7.30/wrangler-mcp.toml +24 -0
  66. package/CHANGELOG.md +32 -0
  67. package/SKILL.md +1 -1
  68. package/_trash/RELEASE-NOTES-v0.7.30.md +29 -0
  69. package/package.json +1 -1
  70. package/scripts/migrate-lance-to-sqlite.mjs +2 -1
@@ -0,0 +1,48 @@
1
+ # Release Notes: Memory Crystal v0.7.23
2
+
3
+ **Date:** 2026-03-15
4
+
5
+ ## Search Quality v2 + MLX Local LLM
6
+
7
+ This release adds six search quality features ported from the QMD v2.0 analysis, plus the complete MLX local LLM infrastructure for Apple Silicon. Deep search is now disambiguatable, cacheable, debuggable, and can run entirely offline on Apple Silicon.
8
+
9
+ ### Intent parameter
10
+
11
+ Disambiguates queries without adding search terms. `crystal search "security" --intent "1Password"` steers results toward 1Password-related security instead of repo permissions or agent secrets. Intent flows through the expansion prompt (guides LLM variations), disables strong-signal bypass (keyword match might not be what the caller wants), and is prepended to the rerank query. Available via CLI `--intent` and MCP `intent`.
12
+
13
+ ### Persistent LLM cache
14
+
15
+ Expansion and reranking results are now cached in crystal.db (`llm_cache` table) with a 7-day TTL. Same query = instant on repeat searches. Reranking cache is content-addressable (keyed by query + sorted passage hashes), so identical content from different sessions shares cached scores. Configurable via `CRYSTAL_CACHE_TTL_DAYS` env var.
16
+
17
+ ### Explain mode
18
+
19
+ Per-result scoring breakdown showing FTS score, vector score, RRF rank, reranker score, recency weight, and final blended score. `crystal search "query" --explain`. Available via CLI `--explain` and MCP `explain`. Makes search quality transparent and debuggable.
20
+
21
+ ### candidateLimit
22
+
23
+ Tunable rerank pool size. `crystal search "query" --candidates 60`. Default stays 40. More candidates = better recall, slower reranking. Available via CLI `--candidates` and MCP `candidate_limit`.
24
+
25
+ ### Structured search API
26
+
27
+ `crystal.structuredSearch(queries)` accepts pre-expanded StructuredQuery[] with typed sub-queries (lex, vec, hyde). Skips LLM expansion entirely. Agents construct their own queries when they already know what they want. RRF fusion with first list weighted 2x.
28
+
29
+ ### MLX local LLM (Phase 3)
30
+
31
+ Complete auto-install infrastructure for running a local LLM on Apple Silicon:
32
+
33
+ - `crystal mlx setup` detects Apple Silicon, installs mlx-lm (uv > pip3 > pip3 --user), creates LaunchAgent for always-on server
34
+ - Model: `mlx-community/Qwen2.5-3B-Instruct-4bit` (~1.5 GB, fast on M-series)
35
+ - Port 18791 (18789 OpenClaw, 18790 Crystal Core, 18791 MLX)
36
+ - `crystal mlx status` and `crystal mlx stop` for server management
37
+ - `crystal doctor` check #13: MLX health (not installed / down / running)
38
+ - `crystal init` detects Apple Silicon and suggests MLX setup
39
+ - State file at `~/.ldm/state/mlx-server.json`
40
+
41
+ ### Also in this release
42
+
43
+ - QMD v2.0 analysis documented (`ai/product/notes/`)
44
+ - Search quality plan written (`ai/product/plans-prds/current/`)
45
+ - MLX plan moved from upcoming to current
46
+ - Stashed roadmap + readme-first updates recovered (PR #74)
47
+
48
+ Closes #57, #63, #64.
@@ -0,0 +1,24 @@
1
+ # Release Notes: memory-crystal v0.7.25
2
+
3
+ Bump SKILL.md version and name to match package branding.
4
+
5
+ ## What changed
6
+
7
+ - SKILL.md version bumped from 0.4.0 to 0.7.24 (was stuck at the original version)
8
+ - SKILL.md name changed from `memory` to `wip-memory-crystal` (matches branded convention)
9
+ - Forces deploy to public repo, triggering auto-publish to wip.computer/install/
10
+
11
+ ## Why
12
+
13
+ The SKILL.md version was out of sync with the package version. The name didn't match the `wip-` branding convention used across all install files on wip.computer.
14
+
15
+ ## Issues closed
16
+
17
+ - #80
18
+
19
+ ## How to verify
20
+
21
+ ```bash
22
+ crystal --version
23
+ head -4 ~/.ldm/extensions/memory-crystal/skills/memory/SKILL.md
24
+ ```
@@ -0,0 +1,7 @@
1
+ # Memory Crystal v0.7.26
2
+
3
+ Add repository field to package.json. GitHub Packages needs this to link packages to the repo.
4
+
5
+ ## Issues closed
6
+
7
+ - Closes #50
@@ -0,0 +1,31 @@
1
+ # Release Notes: memory-crystal v0.7.28
2
+
3
+ **Move all log paths from /tmp/ to ~/.ldm/logs/ so logs survive reboots.**
4
+
5
+ ## What changed
6
+
7
+ - Cron entry for crystal-capture now logs to `~/.ldm/logs/crystal-capture.log` instead of `/tmp/ldm-dev-tools/`
8
+ - LaunchAgent plist template for ldm-backup now logs to `~/.ldm/logs/ldm-backup.log`
9
+ - `mkdirSync` ensures `~/.ldm/logs/` exists instead of creating `/tmp/ldm-dev-tools/`
10
+ - CLI output shows the correct log path
11
+
12
+ ## Why
13
+
14
+ macOS clears `/tmp/` on every reboot. All cron and LaunchAgent logs were lost after restart, making it impossible to debug issues. `~/.ldm/logs/` persists across reboots and is the correct home for LDM OS logs.
15
+
16
+ ## Issues closed
17
+
18
+ - wipcomputer/wip-ldm-os#120
19
+
20
+ ## How to verify
21
+
22
+ ```bash
23
+ # After install, check that cron entry points to ~/.ldm/logs/
24
+ crystal init --dry-run 2>&1 | grep crystal-capture
25
+
26
+ # Check backup setup points to ~/.ldm/logs/
27
+ crystal backup setup --dry-run 2>&1 | grep ldm-backup
28
+
29
+ # Verify logs land in the right place
30
+ ls ~/.ldm/logs/
31
+ ```
@@ -0,0 +1,28 @@
1
+ # Release Notes: memory-crystal v0.7.29
2
+
3
+ **Doc audit: MLX setup, deep search params, log paths, role clarification.**
4
+
5
+ ## What changed
6
+
7
+ SKILL.md and TECHNICAL.md updated for 2 weeks of undocumented features:
8
+
9
+ - **MLX local LLM:** Added as Option A in SKILL.md Step 2. CLI commands (setup, status, stop) added to TECHNICAL.md.
10
+ - **Deep search parameters:** `--intent`, `--explain`, `--candidates` documented in both SKILL.md (crystal_search tool) and TECHNICAL.md (CLI reference + new sections for intent, explain, candidate limit, LLM cache).
11
+ - **Log paths:** Fixed obsolete `/tmp/ldm-dev-tools/` reference to `~/.ldm/logs/`. Added logs/ to directory structure.
12
+ - **Role clarification:** Two-role architecture (Core and Node) explicitly stated. Standalone role was removed in v0.7.22.
13
+
14
+ ## Why
15
+
16
+ 29 releases in 13 days. Docs didn't keep pace. Agents using crystal_search didn't know about --intent (query disambiguation) or --explain (scoring transparency).
17
+
18
+ ## Issues closed
19
+
20
+ - #57
21
+
22
+ ## How to verify
23
+
24
+ ```bash
25
+ grep "intent" SKILL.md TECHNICAL.md
26
+ grep "mlx" SKILL.md TECHNICAL.md
27
+ grep "ldm/logs" TECHNICAL.md
28
+ ```
@@ -0,0 +1,64 @@
1
+ # Memory Crystal v0.7.4 ... MCP Fix + AgentId Config
2
+
3
+ **Date:** 2026-03-11
4
+ **Authors:** Parker Todd Brooks, Lēsa, Claude Code
5
+
6
+ ---
7
+
8
+ ## What's in this release
9
+
10
+ ### Agent identity reads from config, not hardcoded strings
11
+
12
+ The agent_id used when ingesting conversations was hardcoded in three places: `cc-mini` in the CC hook, `main` in the OpenClaw plugin, and `cc-mini` as the fallback in `ldm.ts`. This caused ID drift. The same agent got recorded under multiple IDs, and we had to manually merge 141K+ chunks in the database.
13
+
14
+ Now `getAgentId()` scans `~/.ldm/agents/*/config.json` for a matching harness type. The CC hook passes `'claude-code'`, the OC plugin passes `'openclaw'`, and the config file is the source of truth. `CRYSTAL_AGENT_ID` env var still works as an override.
15
+
16
+ New exports: `AgentConfig`, `loadAgentConfig()`, `saveAgentConfig()`. The installer writes `agentId` to config.json during `crystal init`.
17
+
18
+ **Closes #33.**
19
+
20
+ ### MCP registrations moved to user-level
21
+
22
+ MCP server registrations moved from project-level `~/.openclaw/.mcp.json` to user-level `~/.claude.json`. The old file was a Claude Code convention that only loaded when running from `~/.openclaw/`. Now all 4 MCP servers (memory-crystal, lesa-bridge, wip-agent-pay, wip-repos) load from any directory as "User MCPs".
23
+
24
+ OpenClaw doesn't read `.mcp.json` at all. It uses its own plugin system. The file was moved to `~/.openclaw/_trash/`.
25
+
26
+ ### OPENCLAW_HOME env var fix (v0.7.3)
27
+
28
+ The MCP server registration was missing the `OPENCLAW_HOME` env var. Without it, the memory-crystal MCP server couldn't find Lēsa's OpenClaw installation for private-mode checks. Fixed in v0.7.3, deployed in this release.
29
+
30
+ ### Branch cleanup
31
+
32
+ 33 stale branches renamed with `--merged-` suffix. Zero active branches besides main.
33
+
34
+ ### QMD v1.1.6 analysis documented
35
+
36
+ Deep analysis of the search quality system with four recommendations: intent parameter for search, structured search API, persistent reranker cache, and explain mode for debugging. See `ai/product/notes/2026-03-09--cc-mini--qmd-v1.1.6-analysis-and-recommendations.md`.
37
+
38
+ ---
39
+
40
+ ## Files changed
41
+
42
+ | File | What |
43
+ |------|------|
44
+ | `src/ldm.ts` | `AgentConfig` interface, `loadAgentConfig()`, `saveAgentConfig()`, `getAgentId()` now scans config |
45
+ | `src/cc-hook.ts` | Uses `getAgentId('claude-code')` instead of hardcoded fallback |
46
+ | `src/openclaw.ts` | Uses `OC_AGENT_ID` instead of `'main'` fallback |
47
+ | `src/installer.ts` | Writes `agentId` to config.json during install |
48
+
49
+ ---
50
+
51
+ ## Install
52
+
53
+ ```bash
54
+ npm install -g memory-crystal@0.7.4
55
+ ```
56
+
57
+ Or update your local clone:
58
+ ```bash
59
+ git pull origin main
60
+ ```
61
+
62
+ ---
63
+
64
+ Built by Parker Todd Brooks, Lēsa (OpenClaw, Claude Opus 4.6), Claude Code (Claude Opus 4.6).
@@ -0,0 +1,19 @@
1
+ # Release Notes: Memory Crystal v0.7.5
2
+
3
+ ## LDM OS Integration
4
+
5
+ Memory Crystal now works with LDM OS when it's available.
6
+
7
+ ### crystal init delegates to ldm install
8
+
9
+ When the `ldm` CLI exists on PATH, `crystal init` delegates generic deployment to it. LDM OS handles the scaffold, interface detection, and extension deployment. Memory Crystal keeps its own setup: database backup, role configuration, pairing, cron jobs.
10
+
11
+ When `ldm` isn't available, `crystal init` works standalone like it always has. No new dependencies. No breaking changes.
12
+
13
+ ### LDM OS tip
14
+
15
+ After install completes, Memory Crystal prints a tip: "Run `ldm install` to see more skills you can add." Helps users discover the rest of the ecosystem.
16
+
17
+ ### Part of LDM OS
18
+
19
+ README now includes a "Part of LDM OS" section linking back to the LDM OS repo. Memory Crystal installs into LDM OS, the local runtime for AI agents.
@@ -0,0 +1,116 @@
1
+ # Memory Crystal Cloud
2
+
3
+ Remote MCP server for ChatGPT + Claude. Persistent memory across sessions on all six surfaces (macOS, iOS, web for both ChatGPT and Claude).
4
+
5
+ ## Architecture
6
+
7
+ One MCP server, two tiers:
8
+
9
+ **Tier 1 (Sovereign):** Write-only relay. Memories are encrypted (AES-256-GCM) and relayed to your home machine. The cloud cannot read your data. Search is available only on local devices.
10
+
11
+ **Tier 2 (Convenience):** Cloud search enabled. A mirror of your memory database is pushed to Cloudflare D1 + Vectorize. ChatGPT/Claude can search your memories directly. Privacy trade-off is clearly disclosed.
12
+
13
+ ## Data Flow
14
+
15
+ Every conversation turn, attachment, and explicit memory flows to the Mini:
16
+
17
+ ```
18
+ ChatGPT/Claude → memory_log (every turn) → [encrypt] → R2 relay → Mini poller → crystal.db
19
+ memory_remember (explicit) → [encrypt] → R2 relay → Mini poller → crystal.db
20
+ memory_upload (files/media) → [encrypt] → R2 relay → Mini poller → attachments/
21
+ memory_forget (deprecation) → [encrypt] → R2 relay → Mini poller → crystal.db
22
+ ```
23
+
24
+ The Mini receives the same data it would have if this was a local Claude Code or OpenClaw session:
25
+ - Full conversation JSON (raw messages, tool calls, results)
26
+ - Inline images and file references
27
+ - Binary attachments (images, audio, video, documents)
28
+ - Explicit memories and deprecations
29
+
30
+ ## Setup
31
+
32
+ ```bash
33
+ # From the memory-crystal-private root:
34
+
35
+ # 1. Create D1 database
36
+ cd cloud && npx wrangler d1 create memory-crystal-cloud
37
+ # Copy the database_id into cloud/wrangler.toml
38
+
39
+ # 2. Run migrations
40
+ npm run cloud:db:migrate
41
+
42
+ # 3. Set secrets
43
+ cd cloud
44
+ npx wrangler secret put CRYSTAL_RELAY_KEY # base64, 32 bytes (same as relay)
45
+ npx wrangler secret put OAUTH_SIGNING_SECRET # any random string
46
+ npx wrangler secret put OPENAI_API_KEY # for Tier 2 embeddings
47
+
48
+ # 4. Deploy
49
+ npm run cloud:deploy
50
+ ```
51
+
52
+ ## Development
53
+
54
+ ```bash
55
+ npm run cloud:dev # local dev server
56
+ npm run cloud:db:migrate # apply D1 migrations locally
57
+ ```
58
+
59
+ ## Endpoints
60
+
61
+ | Path | Method | Auth | Description |
62
+ |------|--------|------|-------------|
63
+ | `/health` | GET | No | Health check |
64
+ | `/.well-known/oauth-protected-resource` | GET | No | OAuth resource metadata |
65
+ | `/.well-known/oauth-authorization-server` | GET | No | OAuth server metadata |
66
+ | `/oauth/register` | POST | No | Dynamic Client Registration |
67
+ | `/oauth/authorize` | GET/POST | No | Authorization + consent page |
68
+ | `/oauth/token` | POST | No | Token exchange (PKCE S256) |
69
+ | `/mcp` | POST | Bearer | MCP JSON-RPC endpoint |
70
+
71
+ ## MCP Tools
72
+
73
+ | Tool | Description | Annotation |
74
+ |------|-------------|-----------|
75
+ | `memory_search` | Search memories | readOnly |
76
+ | `memory_remember` | Store a memory (fact, preference, event, opinion, skill) | write |
77
+ | `memory_forget` | Deprecate a memory by ID | destructive |
78
+ | `memory_status` | Show status, pending drops, tier info | readOnly |
79
+ | `memory_log` | Log a conversation turn (call every exchange) | write, idempotent |
80
+ | `memory_upload` | Upload a file attachment (image, audio, video, doc) | write |
81
+
82
+ ### memory_log
83
+
84
+ This is the key tool for full data capture. The system prompt instructs the AI to call `memory_log` after every exchange with:
85
+ - `role` + `content` (the text)
86
+ - `raw_json` (the complete message object as JSON string)
87
+ - `tool_calls` (any tools called in the turn)
88
+ - `attachments` (inline images, files, audio)
89
+ - `session_id` + `turn_index` (for conversation grouping)
90
+
91
+ The Mini processes these through the same chunking and embedding pipeline used for local sessions.
92
+
93
+ ### memory_upload
94
+
95
+ Handles binary files. The AI encodes the file as base64 and calls this tool. The file is encrypted (AES-256-GCM) and stored as a separate R2 object. A metadata drop references the blob. The Mini poller picks up both.
96
+
97
+ Supports: images (png, jpg, webp, gif), audio (mp3, mp4, wav, ogg), video (mp4, webm, mov), documents (pdf, txt, csv).
98
+
99
+ Max file size: 100MB (R2 single-put limit).
100
+
101
+ ## Files
102
+
103
+ ```
104
+ cloud/
105
+ wrangler.toml -- Cloudflare Worker config
106
+ migrations/
107
+ 0001_init.sql -- D1 schema (OAuth + users)
108
+ README.md -- this file
109
+
110
+ src/cloud/
111
+ index.ts -- Worker entry point, request router
112
+ auth.ts -- OAuth 2.1 (DCR, authorize, token)
113
+ mcp.ts -- MCP tool definitions + handlers (6 tools)
114
+ relay.ts -- Encrypt + drop to relay (Web Crypto)
115
+ types.ts -- Shared types
116
+ ```
@@ -0,0 +1,69 @@
1
+ # Memory Crystal - System Instructions
2
+
3
+ These instructions are for the Custom GPT / Claude connector that uses the Memory Crystal MCP server.
4
+
5
+ ---
6
+
7
+ ## Identity
8
+
9
+ You are Memory Crystal, a persistent memory layer for your conversations. Every message in this conversation is captured and sent to the user's home machine, where it becomes part of their searchable memory.
10
+
11
+ ## Core Behavior
12
+
13
+ ### 1. Log Every Turn
14
+
15
+ After EVERY user message and EVERY assistant response, call `memory_log` with:
16
+
17
+ - `role`: "user" or "assistant"
18
+ - `content`: the full message text
19
+ - `session_id`: generate a unique ID at the start of each conversation (e.g. UUID) and reuse it for all turns
20
+ - `turn_index`: increment from 0 for each message in the conversation
21
+ - `model`: your model name (assistant turns only, e.g. "gpt-4o")
22
+
23
+ If the user's message includes images, files, or audio:
24
+ - Include them in the `attachments` array with `type`, `filename`, and `mime_type`
25
+ - For small files (under 64KB), include `data_base64`
26
+ - For larger files, note the reference in `context`
27
+
28
+ If your response includes tool calls:
29
+ - Include them in the `tool_calls` array with `tool_name`, `arguments`, and `result`
30
+
31
+ ### 2. Remember When Asked
32
+
33
+ When the user says things like "remember this", "save this", "note that":
34
+ - Call `memory_remember` with the specific fact/preference/observation
35
+ - Choose the right category: fact, preference, event, opinion, skill
36
+
37
+ ### 3. Forget When Asked
38
+
39
+ When the user says "forget that" or "remove that memory":
40
+ - Call `memory_forget` with the memory ID
41
+
42
+ ### 4. Search When Asked
43
+
44
+ When the user asks "do you remember...", "what did I say about...", "find my notes on...":
45
+ - Call `memory_search` with their query
46
+ - If in Sovereign mode, explain that search is available on their local devices
47
+
48
+ ### 5. Upload Files
49
+
50
+ When the user shares images, documents, audio, or video:
51
+ - Call `memory_upload` with the file data (base64 encoded)
52
+ - Include `filename`, `mime_type`, and optional `context`
53
+ - This ensures all media gets saved to their home machine
54
+
55
+ ## Important Rules
56
+
57
+ - ALWAYS log both sides of the conversation. Never skip a turn.
58
+ - The `session_id` must be consistent within a single conversation.
59
+ - Do not mention the logging process unless the user asks about it.
60
+ - When Memory Crystal is in Sovereign mode, search returns a guidance message. This is by design. The user's data stays on their hardware.
61
+ - Be concise. The memory system captures everything automatically.
62
+
63
+ ## Status
64
+
65
+ Call `memory_status` when the user asks about their memory system, connection health, or tier information.
66
+
67
+ ## Privacy
68
+
69
+ All data is encrypted in transit (AES-256-GCM). In Sovereign mode, the cloud cannot read any data. Memories flow to the user's home machine and are deleted from the relay after pickup.
@@ -0,0 +1,52 @@
1
+ -- Memory Crystal Cloud: initial schema
2
+ -- OAuth tables for auth + user accounts
3
+ -- Tier 1: relay-only (sovereign)
4
+ -- Tier 2: adds chunks + memories tables (separate migration)
5
+
6
+ -- ── OAuth Clients (Dynamic Client Registration) ──
7
+ CREATE TABLE IF NOT EXISTS oauth_clients (
8
+ client_id TEXT PRIMARY KEY,
9
+ redirect_uris TEXT NOT NULL DEFAULT '[]',
10
+ client_name TEXT,
11
+ created_at TEXT NOT NULL,
12
+ last_used_at TEXT
13
+ );
14
+
15
+ -- ── Authorization Codes (PKCE flow) ──
16
+ CREATE TABLE IF NOT EXISTS authorization_codes (
17
+ code TEXT PRIMARY KEY,
18
+ client_id TEXT NOT NULL,
19
+ user_id TEXT NOT NULL,
20
+ code_challenge TEXT NOT NULL,
21
+ code_challenge_method TEXT NOT NULL DEFAULT 'S256',
22
+ redirect_uri TEXT NOT NULL,
23
+ scope TEXT,
24
+ expires_at TEXT NOT NULL,
25
+ used INTEGER DEFAULT 0
26
+ );
27
+
28
+ -- ── Access Tokens ──
29
+ CREATE TABLE IF NOT EXISTS access_tokens (
30
+ token_hash TEXT PRIMARY KEY,
31
+ client_id TEXT NOT NULL,
32
+ user_id TEXT NOT NULL,
33
+ scope TEXT,
34
+ tier TEXT NOT NULL DEFAULT 'sovereign',
35
+ expires_at TEXT NOT NULL,
36
+ created_at TEXT NOT NULL
37
+ );
38
+
39
+ -- ── Users ──
40
+ CREATE TABLE IF NOT EXISTS users (
41
+ user_id TEXT PRIMARY KEY,
42
+ email TEXT NOT NULL UNIQUE,
43
+ tier TEXT NOT NULL DEFAULT 'sovereign',
44
+ relay_token TEXT,
45
+ created_at TEXT NOT NULL
46
+ );
47
+
48
+ -- ── Indexes ──
49
+ CREATE INDEX IF NOT EXISTS idx_auth_codes_client ON authorization_codes(client_id);
50
+ CREATE INDEX IF NOT EXISTS idx_tokens_user ON access_tokens(user_id);
51
+ CREATE INDEX IF NOT EXISTS idx_tokens_expires ON access_tokens(expires_at);
52
+ CREATE INDEX IF NOT EXISTS idx_clients_last_used ON oauth_clients(last_used_at);
@@ -0,0 +1,51 @@
1
+ -- Memory Crystal Cloud: OAuth + User tables
2
+ -- Applied to D1 database: memory-crystal-cloud
3
+
4
+ -- OAuth dynamic client registration
5
+ CREATE TABLE IF NOT EXISTS oauth_clients (
6
+ client_id TEXT PRIMARY KEY,
7
+ client_secret_hash TEXT,
8
+ redirect_uris TEXT NOT NULL,
9
+ client_name TEXT,
10
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
11
+ last_used_at TEXT
12
+ );
13
+
14
+ -- Authorization codes (short-lived, PKCE)
15
+ CREATE TABLE IF NOT EXISTS authorization_codes (
16
+ code TEXT PRIMARY KEY,
17
+ client_id TEXT NOT NULL,
18
+ user_id TEXT NOT NULL,
19
+ code_challenge TEXT NOT NULL,
20
+ code_challenge_method TEXT NOT NULL DEFAULT 'S256',
21
+ redirect_uri TEXT NOT NULL,
22
+ scope TEXT,
23
+ expires_at TEXT NOT NULL,
24
+ used INTEGER DEFAULT 0,
25
+ FOREIGN KEY (client_id) REFERENCES oauth_clients(client_id)
26
+ );
27
+
28
+ -- Access tokens (hashed, never stored raw)
29
+ CREATE TABLE IF NOT EXISTS access_tokens (
30
+ token_hash TEXT PRIMARY KEY,
31
+ client_id TEXT NOT NULL,
32
+ user_id TEXT NOT NULL,
33
+ scope TEXT,
34
+ tier TEXT NOT NULL DEFAULT 'sovereign',
35
+ expires_at TEXT NOT NULL,
36
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
37
+ FOREIGN KEY (client_id) REFERENCES oauth_clients(client_id)
38
+ );
39
+
40
+ -- Users
41
+ CREATE TABLE IF NOT EXISTS users (
42
+ user_id TEXT PRIMARY KEY,
43
+ email TEXT NOT NULL UNIQUE,
44
+ tier TEXT NOT NULL DEFAULT 'sovereign',
45
+ relay_token TEXT,
46
+ created_at TEXT NOT NULL DEFAULT (datetime('now'))
47
+ );
48
+
49
+ -- Index for token lookup
50
+ CREATE INDEX IF NOT EXISTS idx_access_tokens_expires ON access_tokens(expires_at);
51
+ CREATE INDEX IF NOT EXISTS idx_authorization_codes_expires ON authorization_codes(expires_at);
@@ -0,0 +1,49 @@
1
+ -- Memory Crystal Cloud: Tier 2 cloud storage tables
2
+ -- Chunks and memories for cloud search (D1 + Vectorize)
3
+
4
+ CREATE TABLE IF NOT EXISTS chunks (
5
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
6
+ user_id TEXT NOT NULL,
7
+ text TEXT NOT NULL,
8
+ role TEXT NOT NULL DEFAULT 'user',
9
+ source_type TEXT NOT NULL DEFAULT 'chatgpt',
10
+ source_id TEXT NOT NULL DEFAULT '',
11
+ agent_id TEXT NOT NULL DEFAULT 'gpt',
12
+ token_count INTEGER DEFAULT 0,
13
+ created_at TEXT NOT NULL DEFAULT (datetime('now'))
14
+ );
15
+
16
+ CREATE TABLE IF NOT EXISTS memories (
17
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
18
+ user_id TEXT NOT NULL,
19
+ text TEXT NOT NULL,
20
+ category TEXT NOT NULL DEFAULT 'fact',
21
+ confidence REAL NOT NULL DEFAULT 1.0,
22
+ source_ids TEXT DEFAULT '[]',
23
+ status TEXT NOT NULL DEFAULT 'active',
24
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
25
+ updated_at TEXT NOT NULL DEFAULT (datetime('now'))
26
+ );
27
+
28
+ -- FTS5 for BM25 text search
29
+ CREATE VIRTUAL TABLE IF NOT EXISTS chunks_fts USING fts5(
30
+ text,
31
+ content='chunks',
32
+ content_rowid='id'
33
+ );
34
+
35
+ -- Triggers to keep FTS in sync
36
+ CREATE TRIGGER IF NOT EXISTS chunks_ai AFTER INSERT ON chunks BEGIN
37
+ INSERT INTO chunks_fts(rowid, text) VALUES (new.id, new.text);
38
+ END;
39
+
40
+ CREATE TRIGGER IF NOT EXISTS chunks_ad AFTER DELETE ON chunks BEGIN
41
+ INSERT INTO chunks_fts(chunks_fts, rowid, text) VALUES ('delete', old.id, old.text);
42
+ END;
43
+
44
+ -- Indexes
45
+ CREATE INDEX IF NOT EXISTS idx_chunks_user ON chunks(user_id);
46
+ CREATE INDEX IF NOT EXISTS idx_chunks_agent ON chunks(agent_id);
47
+ CREATE INDEX IF NOT EXISTS idx_chunks_created ON chunks(created_at);
48
+ CREATE INDEX IF NOT EXISTS idx_memories_user ON memories(user_id);
49
+ CREATE INDEX IF NOT EXISTS idx_memories_status ON memories(status);
@@ -0,0 +1,11 @@
1
+ {
2
+ "id": "memory-crystal",
3
+ "name": "Memory Crystal",
4
+ "description": "Sovereign memory system — search, remember, forget across all agent conversations and files.",
5
+ "skills": ["./skills"],
6
+ "configSchema": {
7
+ "type": "object",
8
+ "additionalProperties": false,
9
+ "properties": {}
10
+ }
11
+ }