@wipcomputer/memory-crystal 0.7.32 → 0.7.33

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 (155) hide show
  1. package/SKILL.md +1 -1
  2. package/cloud/wrangler.toml +30 -0
  3. package/dist/bridge.d.ts +7 -0
  4. package/dist/bridge.js +14 -0
  5. package/dist/bulk-copy.d.ts +17 -0
  6. package/dist/bulk-copy.js +90 -0
  7. package/dist/cc-hook.d.ts +8 -0
  8. package/dist/cc-hook.js +368 -0
  9. package/dist/cc-poller.d.ts +1 -0
  10. package/dist/cc-poller.js +550 -0
  11. package/dist/chunk-25LXQJ4Z.js +110 -0
  12. package/dist/chunk-2DRXIRQW.js +97 -0
  13. package/dist/chunk-2GBYLMEF.js +1385 -0
  14. package/dist/chunk-2ZNH5F6E.js +1281 -0
  15. package/dist/chunk-3G3SFYYI.js +288 -0
  16. package/dist/chunk-3RG5ZIWI.js +10 -0
  17. package/dist/chunk-3S6TI23B.js +97 -0
  18. package/dist/chunk-3VFIJYS4.js +818 -0
  19. package/dist/chunk-437F27T6.js +97 -0
  20. package/dist/chunk-52QE3YI3.js +1169 -0
  21. package/dist/chunk-57RP3DIN.js +1205 -0
  22. package/dist/chunk-5HSZ4W2P.js +62 -0
  23. package/dist/chunk-5I7GMRDN.js +146 -0
  24. package/dist/chunk-645IPXW3.js +290 -0
  25. package/dist/chunk-7A7ELD4C.js +1205 -0
  26. package/dist/chunk-7FYY4GZM.js +1205 -0
  27. package/dist/chunk-7IUE7ODU.js +254 -0
  28. package/dist/chunk-7RMLKZIS.js +108 -0
  29. package/dist/chunk-AA3OPP4Z.js +432 -0
  30. package/dist/chunk-AEWLSYPH.js +72 -0
  31. package/dist/chunk-ASSZDR6I.js +108 -0
  32. package/dist/chunk-AYRJVWUC.js +1205 -0
  33. package/dist/chunk-CCYI5O3D.js +148 -0
  34. package/dist/chunk-CGIDSAJB.js +288 -0
  35. package/dist/chunk-D3I3ZSE2.js +411 -0
  36. package/dist/chunk-D3MACYZ4.js +108 -0
  37. package/dist/chunk-DACSKLY6.js +219 -0
  38. package/dist/chunk-DFQ72B7M.js +248 -0
  39. package/dist/chunk-DW5B4BL7.js +108 -0
  40. package/dist/chunk-EKSACBTJ.js +1070 -0
  41. package/dist/chunk-EXEZZADG.js +248 -0
  42. package/dist/chunk-F3Y7EL7K.js +83 -0
  43. package/dist/chunk-FBQWSDPC.js +1328 -0
  44. package/dist/chunk-FHRZNOMW.js +1205 -0
  45. package/dist/chunk-IM7N24MT.js +129 -0
  46. package/dist/chunk-IPNYIXFK.js +1178 -0
  47. package/dist/chunk-J7MRSZIO.js +167 -0
  48. package/dist/chunk-JITKI2OI.js +106 -0
  49. package/dist/chunk-JWZXYVET.js +1068 -0
  50. package/dist/chunk-KCQUXVYT.js +108 -0
  51. package/dist/chunk-KOQ43OX6.js +1281 -0
  52. package/dist/chunk-KYVWO6ZM.js +1069 -0
  53. package/dist/chunk-L3VHARQH.js +413 -0
  54. package/dist/chunk-LBWDS6BE.js +288 -0
  55. package/dist/chunk-LOVAHSQV.js +411 -0
  56. package/dist/chunk-LQOYCAGG.js +446 -0
  57. package/dist/chunk-LWAIPJ2W.js +146 -0
  58. package/dist/chunk-M5DHKW7M.js +127 -0
  59. package/dist/chunk-MBKCIJHM.js +1328 -0
  60. package/dist/chunk-MK42FMEG.js +147 -0
  61. package/dist/chunk-MOBMYHKL.js +1205 -0
  62. package/dist/chunk-MPLTNMRG.js +67 -0
  63. package/dist/chunk-NIJCVN3O.js +147 -0
  64. package/dist/chunk-NX647OM3.js +310 -0
  65. package/dist/chunk-NZCFSZQ7.js +1205 -0
  66. package/dist/chunk-O2UITJGH.js +465 -0
  67. package/dist/chunk-OCRA44AZ.js +108 -0
  68. package/dist/chunk-P3KJR66H.js +117 -0
  69. package/dist/chunk-PEK6JH65.js +432 -0
  70. package/dist/chunk-PJ6FFKEX.js +77 -0
  71. package/dist/chunk-PLUBBZYR.js +800 -0
  72. package/dist/chunk-PNKVD2UK.js +26 -0
  73. package/dist/chunk-PSQZURHO.js +229 -0
  74. package/dist/chunk-SGL6ISBJ.js +1061 -0
  75. package/dist/chunk-SJABZZT5.js +97 -0
  76. package/dist/chunk-TD3P3K32.js +1199 -0
  77. package/dist/chunk-TMDZJJKV.js +288 -0
  78. package/dist/chunk-UNHVZB5G.js +411 -0
  79. package/dist/chunk-VAFTWSTE.js +1061 -0
  80. package/dist/chunk-VNFXFQBB.js +217 -0
  81. package/dist/chunk-X3GVFKSJ.js +1205 -0
  82. package/dist/chunk-XZ3S56RQ.js +1061 -0
  83. package/dist/chunk-Y72C7F6O.js +148 -0
  84. package/dist/chunk-YLICP577.js +1205 -0
  85. package/dist/chunk-YX6AXLVK.js +159 -0
  86. package/dist/chunk-ZCQYHTNU.js +146 -0
  87. package/dist/cli.d.ts +1 -0
  88. package/dist/cli.js +1160 -0
  89. package/dist/cloud-crystal.js +6 -0
  90. package/dist/core.d.ts +252 -0
  91. package/dist/core.js +12 -0
  92. package/dist/crypto.d.ts +20 -0
  93. package/dist/crypto.js +27 -0
  94. package/dist/crystal-capture.sh +29 -0
  95. package/dist/crystal-serve.d.ts +4 -0
  96. package/dist/crystal-serve.js +252 -0
  97. package/dist/dev-update-SZ2Z4WCQ.js +6 -0
  98. package/dist/discover.d.ts +30 -0
  99. package/dist/discover.js +177 -0
  100. package/dist/doctor.d.ts +9 -0
  101. package/dist/doctor.js +342 -0
  102. package/dist/dream-weaver.d.ts +8 -0
  103. package/dist/dream-weaver.js +56 -0
  104. package/dist/file-sync.d.ts +48 -0
  105. package/dist/file-sync.js +18 -0
  106. package/dist/installer.d.ts +61 -0
  107. package/dist/installer.js +772 -0
  108. package/dist/ldm-backup.sh +116 -0
  109. package/dist/ldm.d.ts +50 -0
  110. package/dist/ldm.js +32 -0
  111. package/dist/llm-XXLYPIOF.js +16 -0
  112. package/dist/mcp-server.d.ts +1 -0
  113. package/dist/mcp-server.js +277 -0
  114. package/dist/migrate.d.ts +1 -0
  115. package/dist/migrate.js +89 -0
  116. package/dist/mirror-sync.d.ts +1 -0
  117. package/dist/mirror-sync.js +159 -0
  118. package/dist/mlx-setup-XKU67WCT.js +289 -0
  119. package/dist/oc-backfill.d.ts +19 -0
  120. package/dist/oc-backfill.js +74 -0
  121. package/dist/openclaw.d.ts +5 -0
  122. package/dist/openclaw.js +434 -0
  123. package/dist/pair.d.ts +4 -0
  124. package/dist/pair.js +75 -0
  125. package/dist/poller.d.ts +1 -0
  126. package/dist/poller.js +634 -0
  127. package/dist/role.d.ts +24 -0
  128. package/dist/role.js +13 -0
  129. package/dist/search-pipeline-4K4OJSSS.js +255 -0
  130. package/dist/search-pipeline-4PRS6LI7.js +280 -0
  131. package/dist/search-pipeline-7UJMXPLO.js +280 -0
  132. package/dist/search-pipeline-CBV25NX7.js +99 -0
  133. package/dist/search-pipeline-DQTRLGBH.js +74 -0
  134. package/dist/search-pipeline-HNG37REH.js +282 -0
  135. package/dist/search-pipeline-IZFPLBUB.js +280 -0
  136. package/dist/search-pipeline-MID6F26Q.js +73 -0
  137. package/dist/search-pipeline-N52JZFNN.js +282 -0
  138. package/dist/search-pipeline-OPB2PRQQ.js +280 -0
  139. package/dist/search-pipeline-VXTE5HAD.js +262 -0
  140. package/dist/search-pipeline-XHFKADRG.js +73 -0
  141. package/dist/staging.d.ts +29 -0
  142. package/dist/staging.js +21 -0
  143. package/dist/summarize.d.ts +19 -0
  144. package/dist/summarize.js +10 -0
  145. package/dist/worker-demo.js +186 -0
  146. package/dist/worker-mcp.js +404 -0
  147. package/dist/worker.js +137 -0
  148. package/package.json +15 -1
  149. package/.env.example +0 -20
  150. package/.publish-skill.json +0 -1
  151. package/CHANGELOG.md +0 -1372
  152. package/README-ENTERPRISE.md +0 -226
  153. package/RELAY.md +0 -199
  154. package/wrangler-demo.toml +0 -8
  155. package/wrangler-mcp.toml +0 -24
@@ -1,226 +0,0 @@
1
- ###### WIP Computer
2
-
3
- # Memory Crystal for Enterprise
4
-
5
- Agent memory infrastructure. Local-first. Encrypted. Inspectable. *In testing.*
6
-
7
- ## The Problem
8
-
9
- Your organization runs AI agents across teams, departments, and tools. Each agent starts every session with no memory. No continuity. No shared context. Conversations with one agent are invisible to every other.
10
-
11
- Your agents can't remember what your people told them. Your people keep re-explaining themselves. Context is lost between sessions, between tools, between teams.
12
-
13
- This is not a convenience problem. It's a reliability problem. An auditability problem. A cost problem.
14
-
15
- ## What Memory Crystal Does
16
-
17
- Memory Crystal is a persistent context layer for AI agents. One shared database. Hybrid search. On your machines. Under your control.
18
-
19
- - **Local-first.** All data stays on-prem. Nothing leaves your network unless you configure it to.
20
- - **Inspectable.** One SQLite file. Open it with any SQLite tool. Audit it. Query it. Back it up with `cp`.
21
- - **Deterministic search.** Hybrid retrieval (BM25 keyword + vector similarity + Reciprocal Rank Fusion). Same query, same results. No black-box ranking.
22
- - **Encrypted sync.** Multi-site deployments use AES-256-GCM encryption with HMAC-SHA256 signing. The relay sees encrypted noise. Keys never leave your machines.
23
- - **Agent isolation.** Each agent gets its own ID, its own transcript archive, its own session summaries. Shared search across agents, isolated storage per agent.
24
- - **Zero cloud dependency.** Runs fully offline with local embeddings (Ollama). No API keys required. No data exfiltration risk.
25
-
26
- ## Five-Layer Memory Stack
27
-
28
- Memory Crystal implements a full memory pipeline, not just search.
29
-
30
- | Layer | What | How |
31
- |-------|------|-----|
32
- | L1: Raw Transcripts | Every conversation archived as JSONL | Automatic. cc-poller (cron), cc-hook (Stop), openclaw.ts (agent_end) |
33
- | L2: Vector Index | Chunks embedded into crystal.db | Automatic. Hybrid search (BM25 + vector + RRF) |
34
- | L3: Structured Memory | Facts, preferences, decisions | `crystal_remember` / `crystal_forget` |
35
- | L4: Narrative Consolidation | Dream Weaver journals, identity, soul | `crystal dream-weave` (imports engine from Dream Weaver Protocol) |
36
- | L5: Active Working Context | Boot sequence files, shared context | Agent reads on startup |
37
-
38
- L1-L3 are fully automated. L4 runs on-demand or via Crystal Core gateway. L5 is consumed by the agent's boot sequence.
39
-
40
- ## Architecture
41
-
42
- ```
43
- sqlite-vec (vectors) + FTS5 (BM25) + SQLite (metadata)
44
- | | |
45
- core.ts ... pure logic, zero framework deps
46
- |-- cli.ts -> crystal search, dream-weave, backfill, serve
47
- |-- mcp-server.ts -> MCP protocol (any compatible client)
48
- |-- openclaw.ts -> OpenClaw plugin + raw data sync to LDM
49
- |-- cc-poller.ts -> Continuous capture (cron, primary)
50
- |-- cc-hook.ts -> Claude Code Stop hook (redundancy) + relay commands
51
- |-- crystal-serve.ts -> Crystal Core gateway (localhost:18790)
52
- |-- dream-weaver.ts -> Dream Weaver integration (narrative consolidation)
53
- |-- staging.ts -> New agent staging pipeline
54
- |-- llm.ts -> LLM provider cascade (MLX > Ollama > OpenAI > Anthropic)
55
- |-- search-pipeline.ts -> Deep search (expand, search, RRF, rerank, blend)
56
- +-- worker.ts -> Encrypted relay (multi-site sync, 3 channels)
57
- ```
58
-
59
- One core module. Multiple interfaces. Every interface calls the same search engine. No inconsistency between access paths.
60
-
61
- ## Security Model
62
-
63
- **Data at rest:** Single SQLite file. Standard filesystem permissions. Encrypt the volume if your compliance requires it.
64
-
65
- **Data in transit:** AES-256-GCM authenticated encryption. HMAC-SHA256 integrity verification. Shared symmetric key generated on-prem, never transmitted to the relay. The relay is a dead drop with no decryption capability.
66
-
67
- **Agent boundaries:** `CRYSTAL_AGENT_ID` isolates each agent's transcript archive, session summaries, and daily logs. Search spans all agents by default, or filters by agent ID.
68
-
69
- **Private mode:** Memory capture can be paused per-agent. When off, nothing is recorded. Resumes from where it left off when re-enabled.
70
-
71
- **No background processes that move data.** No telemetry. No analytics. No phone-home. The code is open source. Audit it.
72
-
73
- ## Retrieval Quality
74
-
75
- Hybrid search is not "we added vectors." It's a two-tier retrieval engine with LLM-powered deep search.
76
-
77
- ### Fast Path (Hybrid Search)
78
- - **FTS5 BM25** for exact keyword matches (Porter stemming)
79
- - **sqlite-vec cosine similarity** for semantic matches
80
- - **Reciprocal Rank Fusion** merges both result lists (k=60, tiered weights: BM25 2x, vector 1x)
81
- - **Recency weighting** ensures fresh context wins decisively: exponential decay `max(0.3, exp(-age_days * 0.1))`
82
- - **Content deduplication** via SHA-256 hash prevents duplicate embeddings
83
- - **Time-filtered search** ... restrict results to last 24h, 7d, 30d, or any date range
84
-
85
- ### Deep Search (LLM-Powered, default)
86
- - **Query expansion** ... LLM generates 3 search variations (lexical, semantic, hypothetical document). Each runs through hybrid search. Results merged via RRF.
87
- - **Strong signal detection** ... BM25 probe skips expansion when the answer is obvious (saves latency).
88
- - **LLM re-ranking** ... top 40 candidates scored by LLM for relevance to the original query.
89
- - **Position-aware blending** ... trusts RRF for top positions, lets the reranker fix ordering in the tail.
90
-
91
- Deep search runs by default. Falls back to fast path silently if no LLM provider is available. For air-gapped environments, MLX (Apple Silicon) or Ollama provides free, fully local deep search with no API keys and no network.
92
-
93
- A search for "deployment policy" finds conversations containing those exact words (BM25), conversations about "shipping code to production" (vector similarity), and conversations about "release workflow" that the LLM recognizes as relevant. All three matter. All three surface.
94
-
95
- ## What Gets Stored
96
-
97
- Every agent conversation produces three artifacts:
98
-
99
- | Artifact | Format | Location |
100
- |----------|--------|----------|
101
- | Raw transcript | JSONL | `~/.ldm/agents/{id}/memory/transcripts/` |
102
- | Session summary | Markdown | `~/.ldm/agents/{id}/memory/sessions/` |
103
- | Embeddings | sqlite-vec | `~/.ldm/memory/crystal.db` |
104
-
105
- Additionally:
106
- - **Explicit memories** stored via `crystal_remember` (facts, preferences, decisions)
107
- - **Source files** indexed as collections (code, documentation, internal knowledge bases)
108
- - **Daily logs** appended per-agent for audit trails
109
- - **Dream Weaver journals** generated by narrative consolidation (identity, soul, context, reference)
110
- - **Workspace files** synced from agent workspace to LDM (OpenClaw .md files)
111
-
112
- ## Embedding Providers
113
-
114
- | Provider | Model | Dimensions | Network Required |
115
- |----------|-------|-----------|-----------------|
116
- | Ollama (recommended for enterprise) | nomic-embed-text | 768 | No. Fully local. |
117
- | OpenAI | text-embedding-3-small | 1536 | Yes. API calls. |
118
- | Google | text-embedding-004 | 768 | Yes. API calls. |
119
-
120
- For air-gapped environments, Ollama is the only option. No data leaves the machine. No API keys. No external dependencies.
121
-
122
- ## Multi-Site Sync
123
-
124
- For organizations with multiple offices or remote teams.
125
-
126
- **Architecture:** One Crystal Core (the primary embedder), many Crystal Nodes (capture and sync). Core is the only machine that writes embeddings. Nodes capture raw conversations and send them to Core. Core embeds, then pushes deltas back.
127
-
128
- **What syncs:**
129
- 1. **Delta chunks** ... only new embeddings since last sync (not the full database)
130
- 2. **Full file tree** ... the entire `~/.ldm/` directory: workspace files, daily logs, journals, media, everything an embedding references
131
- 3. **Commands** ... bidirectional remote operations (run Dream Weaver, trigger backfill, request status)
132
-
133
- **How it works:**
134
- 1. Each site runs Memory Crystal locally
135
- 2. Core embeds all conversations into crystal.db (one source of truth for embeddings)
136
- 3. New chunks + changed files are encrypted (AES-256-GCM) and signed (HMAC-SHA256)
137
- 4. Encrypted deltas are dropped at a relay (hosted or self-hosted)
138
- 5. Other sites poll, decrypt, and insert into their local crystal.db + file tree
139
- 6. The relay deletes blobs after pickup
140
-
141
- **No cloud search.** Every node has the full database and full file tree. All search is local. The relay is pure transport. Nothing is stored or searchable in the cloud.
142
-
143
- **Self-hosted relay:** Deploy the Cloudflare Worker on your own Cloudflare account. Full control. No third-party data exposure.
144
-
145
- **Hosted relay:** Use our infrastructure. Free during beta. Your data is encrypted before it reaches us. We cannot read it.
146
-
147
- ## Compliance
148
-
149
- - **Data residency:** All primary data is local. Relay blobs are encrypted and ephemeral.
150
- - **Auditability:** SQLite is inspectable. Every chunk has a timestamp, source, and SHA-256 hash.
151
- - **Right to delete:** `crystal forget <id>` deprecates specific memories. Database can be wiped entirely with standard file operations.
152
- - **Access control:** Filesystem permissions on the SQLite file. No built-in user auth (it's a local tool, not a SaaS).
153
- - **No vendor lock-in:** MIT licensed (local code). Standard SQLite format. Export with any SQLite tool.
154
-
155
- ## Database
156
-
157
- One file: `crystal.db`. Contains:
158
-
159
- | Table | Purpose |
160
- |-------|---------|
161
- | `chunks` | Chunk text, metadata, SHA-256 hash, timestamps |
162
- | `chunks_vec` | sqlite-vec virtual table (vector search) |
163
- | `chunks_fts` | FTS5 virtual table (keyword search) |
164
- | `memories` | Explicit facts and preferences |
165
- | `capture_state` | Watermarks for incremental ingestion |
166
- | `source_collections` | Indexed directory collections |
167
- | `source_files` | File records with content hashes |
168
-
169
- No migrations server. No schema versioning service. It's SQLite. `sqlite3 crystal.db ".schema"` shows you everything.
170
-
171
- ## Integration
172
-
173
- | Platform | Integration | Auto-Capture |
174
- |----------|------------|-------------|
175
- | Claude Code | Cron poller (`cc-poller.ts`, primary) + Stop hook (`cc-hook.ts`, redundancy) | Yes. Every minute via cron, plus flush on session end. |
176
- | OpenClaw | Plugin (`openclaw.ts`) + `agent_end` hook + raw data sync | Yes. Every turn. Also syncs sessions, workspace, daily logs to LDM. |
177
- | Claude Desktop | MCP server (`mcp-server.ts`) | Search only. Manual capture. |
178
- | Any MCP client | MCP server | Search only. Manual capture. |
179
- | Any shell-accessible tool | CLI (`crystal search`) | Manual. |
180
- | Custom agents | Node.js module (`import from 'memory-crystal'`) | Programmable. |
181
-
182
- ## Crystal Core Gateway
183
-
184
- Crystal Core runs an HTTP gateway (`crystal serve`) on localhost:18790. OpenAI-compatible endpoint for agent-to-agent communication and automated processing.
185
-
186
- - `POST /v1/chat/completions` ... invoke `claude -p` through the gateway
187
- - `POST /process` ... trigger backfill, dream-weave, or staging processing
188
- - `GET /status` ... health check and crystal stats
189
-
190
- Localhost-only binding. Never exposed to the network. Optional bearer token auth.
191
-
192
- ## New Agent Onboarding
193
-
194
- When a new agent connects via relay, Crystal Core automatically:
195
- 1. Detects the unknown agent ID
196
- 2. Routes to staging (`~/.ldm/staging/{agent_id}/`)
197
- 3. Runs backfill (embed all transcripts)
198
- 4. Runs Dream Weaver full mode (generate identity, soul, context, journals)
199
- 5. Moves to live capture
200
-
201
- No manual intervention. The staging pipeline handles the cold-start problem.
202
-
203
- ## Deployment
204
-
205
- ```bash
206
- npm install memory-crystal
207
- crystal init --agent your-agent-id
208
- crystal status
209
- ```
210
-
211
- For enterprise deployments across multiple machines, see [Relay: Memory Sync](https://github.com/wipcomputer/memory-crystal/blob/main/RELAY.md).
212
-
213
- For full technical details, see [Technical Documentation](https://github.com/wipcomputer/memory-crystal/blob/main/TECHNICAL.md).
214
-
215
- ---
216
-
217
- ## License
218
-
219
- ```
220
- src/, skills/, cli.ts, mcp-server.ts MIT (use anywhere, no restrictions)
221
- worker/ AGPL (relay server)
222
- ```
223
-
224
- AGPL for personal use is free.
225
-
226
- Built by Parker Todd Brooks, Lēsa (OpenClaw, Claude Opus 4.6), Claude Code CLI (Claude Opus 4.6).
package/RELAY.md DELETED
@@ -1,199 +0,0 @@
1
- ###### WIP Computer
2
-
3
- # Relay: Memory Sync
4
-
5
- Memory Crystal works on one machine out of the box. Relay lets your memory follow you across machines and surfaces. Conversations captured on your laptop are available on your desktop. Conversations from ChatGPT on your phone are searchable from Claude Code on your Mac.
6
-
7
- Everything is encrypted before it leaves your machine. The relay never sees your data unencrypted.
8
-
9
- ## Crystal Core and Crystal Node
10
-
11
- Memory Crystal uses a Core/Node architecture:
12
-
13
- - **Crystal Core** ... the master memory. All conversations, all embeddings, all memories live here. This is the database you cannot lose. Put it on something permanent: a desktop, a home server, a Mac mini. Treat it like your photo library.
14
- - **Crystal Node** ... a synced copy on any other device. Captures conversations, sends them to the Core via encrypted relay. Gets a mirror back for local search. If a node dies, nothing is lost. The Core has everything.
15
-
16
- One Core, many Nodes. The Core does embeddings. Nodes just capture and sync. You can move the Core later with `crystal promote`.
17
-
18
- ## Two Sync Paths
19
-
20
- ### Encrypted Relay (device-to-device)
21
-
22
- For syncing between your own machines. Fully encrypted. The cloud is blind.
23
-
24
- ```
25
- Crystal Node (laptop) --[encrypt]--> Relay (Cloudflare R2) --[pickup + decrypt]--> Crystal Core (desktop)
26
- Crystal Core --[encrypt mirror]--> Relay --[pickup + decrypt]--> Crystal Node
27
- ```
28
-
29
- Three channels:
30
- - **conversations** (Node to Core) ... encrypted conversation chunks (ephemeral, deleted after pickup)
31
- - **mirror** (Core to Nodes) ... delta chunks (pre-embedded) + file tree deltas
32
- - **commands** (bidirectional) ... Nodes send commands to Core ("run Dream Weaver", "process my data"), Core sends results back
33
-
34
- The relay is a dead drop. It stores encrypted blobs temporarily and serves them on request. It has no decryption capability. If someone compromises the relay, they get encrypted noise.
35
-
36
- ### New Agent Staging
37
-
38
- When the Core's poller receives data from an unknown agent ID, it routes to staging instead of live ingest:
39
- 1. Transcripts written to `~/.ldm/staging/{agent_id}/transcripts/`
40
- 2. Agent marked as "ready" for processing
41
- 3. Staging processor runs backfill + Dream Weaver full mode
42
- 4. Once complete, agent moves to live capture path
43
-
44
- This handles the cold-start problem. A new device connects, sends its history, and Core builds the full memory stack automatically.
45
-
46
- ### Delta Sync (not full mirror)
47
-
48
- The mirror channel uses delta sync. Core pushes only new chunks since last sync, not the entire crystal.db. For a 1.9 GB+ database, this is the difference between a few KB (quiet day) and a few MB (busy day) vs the full database every time.
49
-
50
- - **New node (cold start):** One-time full export of all chunks + all files
51
- - **Ongoing sync:** Delta chunks (pre-embedded by Core) + changed files only
52
- - **Watermark tracking:** Core tracks the last synced chunk ID per node
53
-
54
- ### Full LDM Tree Sync
55
-
56
- The relay syncs the entire `~/.ldm/` file tree, not just the database. Embeddings are pointers to artifacts. If the file isn't on the node, the search result is an orphan.
57
-
58
- What syncs:
59
- - Agent memory files (workspace, daily logs, journals, sessions, transcripts)
60
- - Agent identity files (SOUL.md, IDENTITY.md, CONTEXT.md, REFERENCE.md)
61
- - Shared files (`~/.ldm/shared/`)
62
- - Media (images, videos, any artifact an embedding references)
63
-
64
- File sync uses a manifest (path + SHA-256 hash + size). Only changed files transfer. Core always wins conflicts.
65
-
66
- ## Setup
67
-
68
- ### Pair Your Devices
69
-
70
- ```bash
71
- # On your first machine (generates key if none exists)
72
- crystal pair
73
-
74
- # Displays a QR code and a pairing string:
75
- # mc1:T2hJbGxPZkRhcmtuZXNzTXlPbGRGcmllbmQ=
76
-
77
- # On your second machine
78
- crystal pair --code mc1:T2hJbGxPZkRhcmtuZXNzTXlPbGRGcmllbmQ=
79
- ```
80
-
81
- The QR code transfers the encryption key between devices without touching a server. Physical proximity only. Same security model as AirDrop.
82
-
83
- Alternative: store the key in 1Password and pull from both machines.
84
-
85
- ### Use the WIP.computer Relay (Default)
86
-
87
- We host the relay infrastructure. You just need an encryption key (generated by `crystal pair`).
88
-
89
- ```
90
- Open your AI and say:
91
-
92
- I want to set up multi-device sync for Memory Crystal.
93
- Walk me through the setup step by step.
94
- ```
95
-
96
- Your agent generates your encryption key, configures the connection, and tests it.
97
-
98
- **What you need:**
99
- - Memory Crystal installed on both machines (Core + Node)
100
- - An encryption key (your agent generates this, or use `crystal pair`)
101
-
102
- **Pricing:** Free during beta for individual use. When pricing is introduced, your agent will handle it via [AI CASH](https://github.com/wipcomputer/wip-agent-pay/blob/main/CASH.md).
103
-
104
- ### Self-Host Your Own Relay
105
-
106
- Run your own relay on Cloudflare Workers (free tier). Same code, your infrastructure. Full sovereignty.
107
-
108
- **What you need:**
109
- - A Cloudflare account (free tier works)
110
- - About five minutes
111
-
112
- **Steps:**
113
- 1. Clone the repo and deploy the Worker:
114
- ```bash
115
- cd memory-crystal
116
- npm run build:worker
117
- wrangler deploy --config wrangler.toml
118
- ```
119
- 2. Create an R2 bucket: `wrangler r2 bucket create memory-crystal-relay`
120
- 3. Set auth tokens for your devices:
121
- ```bash
122
- wrangler secret put AUTH_TOKEN_CC_MINI
123
- wrangler secret put AUTH_TOKEN_CC_AIR
124
- ```
125
- 4. Configure Memory Crystal to use your Worker:
126
- ```bash
127
- export CRYSTAL_RELAY_URL=https://your-relay.your-domain.workers.dev
128
- export CRYSTAL_RELAY_TOKEN=your-auth-token
129
- ```
130
-
131
- Full deployment details in [Technical Documentation](https://github.com/wipcomputer/memory-crystal/blob/main/TECHNICAL.md).
132
-
133
- No fees. No dependencies on us. The relay code is open source.
134
-
135
- ### Connecting ChatGPT and Claude
136
-
137
- Every node has the full database and file tree. All search is local. There is no cloud search layer.
138
-
139
- ChatGPT and Claude on iOS/web connect via the MCP server running on your local machine. On platforms where a local MCP server isn't possible (iOS without a Mac nearby), the native Apple app (future) will provide local search via MLX Swift.
140
-
141
- The Cloud MCP demo server (`worker-mcp.ts`, D1 + Vectorize) exists for onboarding and testing but is not the production architecture. With full LDM sync, every device that has Memory Crystal installed can search locally.
142
-
143
- ## Encryption
144
-
145
- - **AES-256-GCM** for encryption (authenticated encryption, no padding oracle attacks)
146
- - **HMAC-SHA256** for signing (integrity verification before decryption)
147
- - Shared key generated locally via `crystal pair`, never transmitted to the relay
148
- - Key must be present on all synced devices
149
-
150
- ### Key Management
151
-
152
- | Method | How | Best for |
153
- |--------|-----|----------|
154
- | `crystal pair` | QR code + pairing string | Two devices in the same room |
155
- | 1Password | Store key, pull via SA token on each machine | Headless, multiple machines |
156
- | Manual | `openssl rand -base64 32`, copy to each device | SSH, air-gapped |
157
-
158
- ## Architecture
159
-
160
- ```
161
- Encrypted Relay (device sync):
162
- src/worker.ts Cloudflare Worker, R2 storage, dead drop (3 channels)
163
- src/crypto.ts AES-256-GCM + HMAC-SHA256
164
- src/poller.ts Crystal Core pickup + ingest + staging detection + commands
165
- src/mirror-sync.ts Delta chunk sync + file tree sync to Crystal Nodes
166
- src/file-sync.ts Manifest-based file tree delta sync
167
- src/cc-hook.ts Claude Code hook (relay mode) + sendCommand()
168
- src/cc-poller.ts Continuous capture (cron, primary local path)
169
- src/staging.ts New agent staging pipeline (detect, stage, process)
170
-
171
- Cloud MCP Demo (deprecated for production):
172
- src/worker-mcp.ts OAuth 2.1 + DCR, MCP protocol, 4 tools
173
- src/cloud-crystal.ts D1 + Vectorize backend (demo/onboarding only)
174
- wrangler-mcp.toml Separate Worker config
175
-
176
- Pairing:
177
- crystal pair QR code key sharing
178
- src/pair.ts Pairing logic, QR display, key save
179
- src/crypto.ts Key generation + pairing string encode/decode
180
- ```
181
-
182
- ## More Info
183
-
184
- - [README.md](https://github.com/wipcomputer/memory-crystal/blob/main/README.md) ... What Memory Crystal is and how to install it.
185
- - [Technical Documentation](https://github.com/wipcomputer/memory-crystal/blob/main/TECHNICAL.md) ... Full technical documentation.
186
- - [QR Pairing Spec](ai/plan/2026-02-27--cc-mini--qr-pairing-spec.md) ... Full spec for the `crystal pair` command.
187
-
188
- ---
189
-
190
- ## License
191
-
192
- ```
193
- src/core.ts, cli.ts, mcp-server.ts, skills/ MIT (use anywhere, no restrictions)
194
- src/worker.ts, src/worker-mcp.ts AGPL (relay + cloud server)
195
- ```
196
-
197
- AGPL for personal use is free.
198
-
199
- Built by Parker Todd Brooks, Lēsa (OpenClaw, Claude Opus 4.6), Claude Code CLI (Claude Opus 4.6).
@@ -1,8 +0,0 @@
1
- name = "memory-crystal-demo"
2
- main = "dist/worker-demo.js"
3
- compatibility_date = "2024-12-01"
4
- compatibility_flags = ["nodejs_compat"]
5
-
6
- [[kv_namespaces]]
7
- binding = "DEMO_KV"
8
- id = "7dab6efe89f443688e178f6135aa3f3b"
package/wrangler-mcp.toml DELETED
@@ -1,24 +0,0 @@
1
- name = "memory-crystal-cloud"
2
- main = "dist/worker-mcp.js"
3
- compatibility_date = "2024-12-01"
4
-
5
- # D1 — OAuth tables + cloud storage (chunks, memories)
6
- [[d1_databases]]
7
- binding = "DB"
8
- database_name = "memory-crystal-cloud"
9
- database_id = "40ca6b73-3701-453e-adb3-7faf1a9964ad" # fill after: wrangler d1 create memory-crystal-cloud
10
-
11
- # Vectorize — Semantic vector search (1024 dims, cosine)
12
- [[vectorize]]
13
- binding = "VECTORIZE"
14
- index_name = "memory-crystal-chunks"
15
-
16
- # R2 — Shared relay bucket (for Tier 1 sovereign drops)
17
- [[r2_buckets]]
18
- binding = "RELAY"
19
- bucket_name = "memory-crystal-relay"
20
-
21
- # Secrets (set via `wrangler secret put --config wrangler-mcp.toml`):
22
- # OPENAI_API_KEY — for embeddings (text-embedding-3-small)
23
- # RELAY_ENCRYPTION_KEY — base64, for Tier 1 relay encryption
24
- # MCP_SIGNING_KEY — for signing OAuth tokens