memwarden 0.0.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/LICENSE +202 -0
- package/README.md +402 -0
- package/dist/bundle/bundle.d.ts +28 -0
- package/dist/bundle/bundle.js +85 -0
- package/dist/cli/bin.d.ts +2 -0
- package/dist/cli/bin.js +593 -0
- package/dist/cli/connect.d.ts +63 -0
- package/dist/cli/connect.js +121 -0
- package/dist/cli/hook.d.ts +24 -0
- package/dist/cli/hook.js +186 -0
- package/dist/cli/tools.d.ts +47 -0
- package/dist/cli/tools.js +246 -0
- package/dist/daemon/ensure.d.ts +12 -0
- package/dist/daemon/ensure.js +54 -0
- package/dist/daemon/service.d.ts +15 -0
- package/dist/daemon/service.js +210 -0
- package/dist/embedding/index.d.ts +10 -0
- package/dist/embedding/index.js +33 -0
- package/dist/embedding/local-embedding.d.ts +14 -0
- package/dist/embedding/local-embedding.js +80 -0
- package/dist/functions/access-tracker.d.ts +13 -0
- package/dist/functions/access-tracker.js +92 -0
- package/dist/functions/audit.d.ts +46 -0
- package/dist/functions/audit.js +0 -0
- package/dist/functions/cjk-segmenter.d.ts +6 -0
- package/dist/functions/cjk-segmenter.js +120 -0
- package/dist/functions/compress-synthetic.d.ts +2 -0
- package/dist/functions/compress-synthetic.js +104 -0
- package/dist/functions/config.d.ts +68 -0
- package/dist/functions/config.js +231 -0
- package/dist/functions/conflicts.d.ts +19 -0
- package/dist/functions/conflicts.js +328 -0
- package/dist/functions/context.d.ts +3 -0
- package/dist/functions/context.js +155 -0
- package/dist/functions/dedup.d.ts +11 -0
- package/dist/functions/dedup.js +51 -0
- package/dist/functions/dejafix.d.ts +96 -0
- package/dist/functions/dejafix.js +356 -0
- package/dist/functions/doctor.d.ts +29 -0
- package/dist/functions/doctor.js +137 -0
- package/dist/functions/forget.d.ts +3 -0
- package/dist/functions/forget.js +87 -0
- package/dist/functions/hybrid-search.d.ts +17 -0
- package/dist/functions/hybrid-search.js +205 -0
- package/dist/functions/index.d.ts +32 -0
- package/dist/functions/index.js +44 -0
- package/dist/functions/keyed-mutex.d.ts +1 -0
- package/dist/functions/keyed-mutex.js +21 -0
- package/dist/functions/logger.d.ts +6 -0
- package/dist/functions/logger.js +37 -0
- package/dist/functions/memory-utils.d.ts +2 -0
- package/dist/functions/memory-utils.js +29 -0
- package/dist/functions/observe.d.ts +5 -0
- package/dist/functions/observe.js +326 -0
- package/dist/functions/paths.d.ts +1 -0
- package/dist/functions/paths.js +38 -0
- package/dist/functions/privacy.d.ts +1 -0
- package/dist/functions/privacy.js +30 -0
- package/dist/functions/provenance.d.ts +9 -0
- package/dist/functions/provenance.js +57 -0
- package/dist/functions/quantized-vector-index.d.ts +60 -0
- package/dist/functions/quantized-vector-index.js +275 -0
- package/dist/functions/receipt.d.ts +31 -0
- package/dist/functions/receipt.js +95 -0
- package/dist/functions/search-index.d.ts +27 -0
- package/dist/functions/search-index.js +217 -0
- package/dist/functions/search.d.ts +25 -0
- package/dist/functions/search.js +523 -0
- package/dist/functions/stemmer.d.ts +1 -0
- package/dist/functions/stemmer.js +110 -0
- package/dist/functions/synonyms.d.ts +1 -0
- package/dist/functions/synonyms.js +69 -0
- package/dist/functions/turboquant.d.ts +53 -0
- package/dist/functions/turboquant.js +278 -0
- package/dist/functions/types.d.ts +217 -0
- package/dist/functions/types.js +8 -0
- package/dist/functions/vector-index.d.ts +25 -0
- package/dist/functions/vector-index.js +125 -0
- package/dist/functions/vector-persistence.d.ts +14 -0
- package/dist/functions/vector-persistence.js +75 -0
- package/dist/functions/verify.d.ts +13 -0
- package/dist/functions/verify.js +104 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +219 -0
- package/dist/kernel/http.d.ts +24 -0
- package/dist/kernel/http.js +261 -0
- package/dist/kernel/index.d.ts +19 -0
- package/dist/kernel/index.js +21 -0
- package/dist/kernel/kernel.d.ts +80 -0
- package/dist/kernel/kernel.js +297 -0
- package/dist/kernel/pubsub.d.ts +21 -0
- package/dist/kernel/pubsub.js +38 -0
- package/dist/kernel/types.d.ts +139 -0
- package/dist/kernel/types.js +20 -0
- package/dist/mcp/bin.d.ts +2 -0
- package/dist/mcp/bin.js +27 -0
- package/dist/mcp/server.d.ts +34 -0
- package/dist/mcp/server.js +377 -0
- package/dist/observability/metrics.d.ts +26 -0
- package/dist/observability/metrics.js +104 -0
- package/dist/proxy/server.d.ts +30 -0
- package/dist/proxy/server.js +331 -0
- package/dist/state/kv.d.ts +41 -0
- package/dist/state/kv.js +50 -0
- package/dist/state/oplog.d.ts +25 -0
- package/dist/state/oplog.js +57 -0
- package/dist/state/schema.d.ts +60 -0
- package/dist/state/schema.js +88 -0
- package/dist/state/store-libsql.d.ts +46 -0
- package/dist/state/store-libsql.js +263 -0
- package/dist/state/store-memory.d.ts +23 -0
- package/dist/state/store-memory.js +121 -0
- package/dist/state/store.d.ts +87 -0
- package/dist/state/store.js +58 -0
- package/dist/triggers/api.d.ts +14 -0
- package/dist/triggers/api.js +510 -0
- package/dist/triggers/auth.d.ts +1 -0
- package/dist/triggers/auth.js +13 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# 🧠 memwarden
|
|
4
|
+
|
|
5
|
+
### The memory firewall for AI coding agents.
|
|
6
|
+
|
|
7
|
+
**Your agent's memory is lying to you. Prove yours isn't.**
|
|
8
|
+
|
|
9
|
+
memwarden is verified, self-custodied memory for AI coding agents. It is local-first,
|
|
10
|
+
dependency-light, and works across every tool you use — Claude Code, Codex, Cursor, Kiro,
|
|
11
|
+
Antigravity, OpenCode, OpenClaw. The point isn't to remember *more*. It's that nothing gets
|
|
12
|
+
injected into your agent's context without provenance that still checks out.
|
|
13
|
+
|
|
14
|
+
`memory firewall` · `verified recall` · `tamper-evident` · `self-custodied` · `cross-tool` · `no API key`
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## The problem: is the memory still true?
|
|
21
|
+
|
|
22
|
+
Most memory layers are built to *remember more.* memwarden is built around a harder question:
|
|
23
|
+
**is the memory still true?**
|
|
24
|
+
|
|
25
|
+
The failure mode that hurts isn't forgetting — it's **confidently wrong recall**. A stored fact
|
|
26
|
+
silently goes stale: it points at code you've since changed or deleted, and the agent injects it
|
|
27
|
+
with full confidence anyway. The industry has started naming this class of risk — OWASP added
|
|
28
|
+
Memory Poisoning (ASI06) to its 2026 Agentic Top 10 — yet memory still tends to store everything
|
|
29
|
+
and trust everything.
|
|
30
|
+
|
|
31
|
+
A memory that points at code you deleted, or that nothing backs up, is worse than no memory at
|
|
32
|
+
all — because the agent injects it with full confidence.
|
|
33
|
+
|
|
34
|
+
memwarden is built around the opposite default: **memory is untrusted until its source still
|
|
35
|
+
checks out.**
|
|
36
|
+
|
|
37
|
+
## Three reasons it exists
|
|
38
|
+
|
|
39
|
+
**1. Verified Recall — the anti-feature.** Memory is firewalled before it reaches a model.
|
|
40
|
+
A memory whose source file was deleted or changed since capture is `stale` and never injected.
|
|
41
|
+
Run `memwarden doctor` against any memory store and get a red/yellow/green audit of what's
|
|
42
|
+
verified, what's merely sourced, what's stale, and what has no provenance at all. It's a
|
|
43
|
+
shareable artifact you can point at your own existing memory and watch it light up yellow.
|
|
44
|
+
|
|
45
|
+
**2. Self-custodied and portable.** Your second brain shouldn't depend on a vendor's roadmap.
|
|
46
|
+
memwarden is local-first, tamper-evident, and portable: one `export` produces a Brain Bundle you
|
|
47
|
+
can move between machines or agents. Zero cloud. The data lives at `~/.memwarden` and nowhere else.
|
|
48
|
+
|
|
49
|
+
**3. The memory firewall.** Nothing enters your agent's context without provenance that still
|
|
50
|
+
holds. The unique lever — possible only for a coding-agent tool because the repo is ground
|
|
51
|
+
truth — is tying memory validity to **source-file content hashes**. The repo tells us, on every
|
|
52
|
+
recall, whether a memory is still earned.
|
|
53
|
+
|
|
54
|
+
## Source-file hashes: the ground truth
|
|
55
|
+
|
|
56
|
+
A coding agent has something general-purpose memory doesn't: the repository on disk is the source
|
|
57
|
+
of truth. When memwarden captures a code-backed memory, it records a SHA-256 content hash for
|
|
58
|
+
each referenced file (best-effort, files up to ~2 MB). On recall it re-hashes the live file and
|
|
59
|
+
compares. If the file is gone or its content moved, the memory is provably stale — not by
|
|
60
|
+
heuristic, by hash.
|
|
61
|
+
|
|
62
|
+
Tying memory validity to source-file content hashes is what lets the repo tell us, on every
|
|
63
|
+
recall, whether a memory is still earned.
|
|
64
|
+
|
|
65
|
+
## Verified Recall — what the four states mean
|
|
66
|
+
|
|
67
|
+
Every memory is classified against the live repo:
|
|
68
|
+
|
|
69
|
+
- **verified** — a captured source-file hash still matches the file on disk (code-backed and
|
|
70
|
+
current).
|
|
71
|
+
- **sourced_unverified** — it has a source (a command, or files that were present but not
|
|
72
|
+
hashable), but no content hash to re-check. Allowed, but not content-verified.
|
|
73
|
+
- **stale** — a referenced file was deleted, or its content changed since capture.
|
|
74
|
+
- **unsourced** — no provenance at all: no files, no command, not user-confirmed.
|
|
75
|
+
|
|
76
|
+
**The firewall drops `stale` before injecting. It does not drop `unsourced`** — unsourced means
|
|
77
|
+
*unverified*, not *dangerous*, so it stays available for explicit lookups. `memory_resume`, the
|
|
78
|
+
`/recall` prompt, the Claude Code SessionStart hook, and the proxy all run recall with the
|
|
79
|
+
firewall on. It scans a wide window to backfill lower-ranked safe results and warns (rather than
|
|
80
|
+
silently capping) if that window is exhausted. It also drops an older memory that a newer safe
|
|
81
|
+
memory contradicts, using conservative subject/value claims — no LLM, no fuzzy black box. Plain
|
|
82
|
+
`memory_search` stays unfiltered for deliberate lookups; the REST API refuses `safe_only` without
|
|
83
|
+
a `cwd` to verify against rather than pass memory through unchecked.
|
|
84
|
+
|
|
85
|
+
## The shareable audit: `memwarden doctor`
|
|
86
|
+
|
|
87
|
+
Point it at a repo and it runs the exact same check as a report, plus conservative conflict
|
|
88
|
+
detection:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
node dist/cli/bin.js doctor .
|
|
92
|
+
|
|
93
|
+
VERIFIED: 8 memories (code-backed, current)
|
|
94
|
+
SOURCED: 3 memories (sourced, not content-verified)
|
|
95
|
+
STALE: 2 memories reference files that changed/deleted
|
|
96
|
+
UNSOURCED: 1 memory has no evidence
|
|
97
|
+
CONFLICTS: 1 possible contradiction
|
|
98
|
+
|
|
99
|
+
[stale] Edit — references files that no longer match (changed: src/legacy.ts)
|
|
100
|
+
[conflict] Edit may contradict Edit — same subject "auth" has incompatible values
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
This is the artifact. Run it against your current memory store and see how much of it is still
|
|
104
|
+
earned.
|
|
105
|
+
|
|
106
|
+
## Déjà Fix — never solve the same error twice, across every tool
|
|
107
|
+
|
|
108
|
+
memwarden is the one process that sees **every** agent's sessions on your machine, so it can do
|
|
109
|
+
something no per-tool memory can: when any agent (Claude Code, Codex, Cursor, …) resolves an
|
|
110
|
+
error, it captures `{error signature → root cause + fix}` with the same provenance file-hashes.
|
|
111
|
+
When **any** agent later hits a matching error, the verified fix is surfaced automatically —
|
|
112
|
+
but only if its referenced files still hash-match. A stale fix is never surfaced.
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Codex solved a failing test yesterday. Today Claude Code hits the same failure:
|
|
116
|
+
# Déjà Fix (memwarden): this error was solved by codex on 2026-06-09 and the fix
|
|
117
|
+
# is verified current against your working tree.
|
|
118
|
+
# Root cause: clock skew · Fix: mock NTP in conftest
|
|
119
|
+
|
|
120
|
+
# scriptable too — pipe any failing command's output straight in:
|
|
121
|
+
npm test 2>&1 | node dist/cli/bin.js dejafix lookup
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Three properties, all load-bearing: it is **cross-agent** (a fix learned in Codex helps Claude
|
|
125
|
+
Code), **project-scoped** (a fix never leaks across repos), and **safe by construction** — it
|
|
126
|
+
reuses Verified Recall, so file drift or deletion auto-suppresses the fix. The hook auto-injects
|
|
127
|
+
only `verified current` fixes; `sourced, unverified` ones stay available via `dejafix lookup`,
|
|
128
|
+
`/recall`, and the `dejafix_lookup` MCP tool but are never silently pushed into your context.
|
|
129
|
+
|
|
130
|
+
## Tamper-evident, honestly
|
|
131
|
+
|
|
132
|
+
Every write lands in an append-only, SHA-256 hash-chained oplog. `memory_verify` walks the chain
|
|
133
|
+
and recomputes every hash, so an **edit or a reorder** of any past entry breaks the chain at the
|
|
134
|
+
first touched entry.
|
|
135
|
+
|
|
136
|
+
It is **tamper-evident, not tamper-proof.** There is no signing. The chain detects edits and
|
|
137
|
+
reorders, but it does **not** detect tail-truncation — dropping the newest entries leaves a
|
|
138
|
+
shorter, still-valid chain. We say "tamper-evident" and mean exactly that.
|
|
139
|
+
|
|
140
|
+
**Deletion comes with a receipt.** `memwarden forget <id>` removes a memory from the store and
|
|
141
|
+
every index, and prints a receipt citing the oplog entries that recorded the original write and
|
|
142
|
+
the deletion, plus whole-chain verification — proof the delete actually happened, without
|
|
143
|
+
re-disclosing the deleted content. An unknown id reports failure honestly; there is no
|
|
144
|
+
`{deleted: 0, success: true}` theater here.
|
|
145
|
+
|
|
146
|
+
## Start here: audit the memory you already have
|
|
147
|
+
|
|
148
|
+
You don't have to install anything or trust any claim — point the auditor at the memory store
|
|
149
|
+
you already use and the repo it talks about:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
npx memwarden audit ~/.claude-mem/claude-mem.db --root ~/code/my-repo # claude-mem (any SQLite store)
|
|
153
|
+
npx memwarden audit CLAUDE.md # a CLAUDE.md / AGENTS.md / rules pile
|
|
154
|
+
npx memwarden audit mem0-export.json --root ~/code/my-repo # a Mem0-style JSON export
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
No daemon, no setup, read-only (SQLite stores are copied before opening). The report classifies
|
|
158
|
+
every memory: **MISSING** (red — references files that no longer exist), **DRIFTED** (yellow —
|
|
159
|
+
files changed after the memory was recorded, when the store has timestamps), **PRESENT** (files
|
|
160
|
+
exist — which is the strongest claim a store without content hashes can make), **UNANCHORED**
|
|
161
|
+
(no file evidence at all). Every red and yellow memory is one your agent would have injected
|
|
162
|
+
with full confidence.
|
|
163
|
+
|
|
164
|
+
## Setup is one command
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
npx memwarden up
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
(From a checkout: `npm install && npm run build && node dist/cli/bin.js up`.)
|
|
171
|
+
|
|
172
|
+
`memwarden up` is the whole thing. It:
|
|
173
|
+
|
|
174
|
+
- **starts a self-healing daemon** in the background (one global brain at `~/.memwarden`) and
|
|
175
|
+
registers it as an OS service (macOS LaunchAgent / Linux systemd `--user`) so it restarts on
|
|
176
|
+
crash and starts at login,
|
|
177
|
+
- **detects your installed tools** and writes the memwarden MCP server into each one's config,
|
|
178
|
+
in that tool's own schema, without clobbering servers you already have,
|
|
179
|
+
- **writes an `AGENTS.md`** block so tools without a hook system still recall and save on every
|
|
180
|
+
task.
|
|
181
|
+
|
|
182
|
+
| Tool | What `up` writes | How memory flows |
|
|
183
|
+
| --- | --- | --- |
|
|
184
|
+
| **Claude Code** | `~/.claude.json` + `~/.claude/settings.json` hooks | mechanical (auto inject + auto capture) |
|
|
185
|
+
| **Codex** | `~/.codex/config.toml` | standing instruction + `/recall` |
|
|
186
|
+
| **Cursor** | `~/.cursor/mcp.json` | standing instruction + `/recall` |
|
|
187
|
+
| **Kiro** | `~/.kiro/settings/mcp.json` | standing instruction + `/recall` |
|
|
188
|
+
| **Antigravity** | `~/.gemini/config/mcp_config.json` | standing instruction + `/recall` |
|
|
189
|
+
| **OpenCode** | `~/.config/opencode/opencode.json` | standing instruction + `/recall` |
|
|
190
|
+
| **OpenClaw** | `~/.openclaw/openclaw.json` | standing instruction + `/recall` |
|
|
191
|
+
|
|
192
|
+
Restart each tool once so it loads the new server. `memwarden down` removes the service.
|
|
193
|
+
|
|
194
|
+
**You stay in charge of the automatic paths.** `MEMWARDEN_INJECT=off` starts sessions with a
|
|
195
|
+
clean slate (no auto-injection anywhere — explicit `/recall` and the MCP tools still work);
|
|
196
|
+
`MEMWARDEN_CAPTURE=off` stops auto-capture. `memwarden exclude <path>` firewalls a project
|
|
197
|
+
completely — no capture from it, no injection into it, across hooks and proxy alike, effective
|
|
198
|
+
immediately (the list is re-read per request, so there is no "excluded but still summarized"
|
|
199
|
+
failure mode). `memwarden include <path>` undoes it; `memwarden exclude --list` shows the list.
|
|
200
|
+
|
|
201
|
+
## How memory crosses your tools
|
|
202
|
+
|
|
203
|
+
Cross-tool reach is table stakes — the trust layer above is the point. Still, the mechanics
|
|
204
|
+
matter, so here they are honestly. There are exactly three ways memory reaches a tool, and
|
|
205
|
+
`memwarden up` wires whichever ones each tool supports:
|
|
206
|
+
|
|
207
|
+
1. **Hooks (Claude Code).** Mechanical. A `SessionStart` hook injects this project's verified
|
|
208
|
+
memory before you type a word; a `PostToolUse` hook captures your work as it happens. The
|
|
209
|
+
agent cannot forget to do it.
|
|
210
|
+
2. **Standing instruction (Codex, Cursor, Kiro, Antigravity, OpenCode, OpenClaw).** `up` writes
|
|
211
|
+
an `AGENTS.md` block telling the agent to recall at the start of every task and save what it
|
|
212
|
+
learns. This is the same mechanism every cross-tool memory layer uses for these tools: they
|
|
213
|
+
expose no deeper hook, so "automatic" means a standing instruction the agent follows, backed
|
|
214
|
+
by the `/recall` command when you want to force it.
|
|
215
|
+
3. **Proxy (model-configurable tools).** Mechanical at the API boundary, but only where you
|
|
216
|
+
control the model endpoint — OpenCode, OpenClaw, Ollama, LM Studio, or any custom OpenAI base
|
|
217
|
+
URL. Point the tool's base URL at the memwarden proxy on `:3113` and every turn is recalled
|
|
218
|
+
and captured with no agent cooperation. It does **not** intercept Claude Code (own protocol —
|
|
219
|
+
covered by hooks) or Cursor/Kiro/Antigravity (their own backends).
|
|
220
|
+
|
|
221
|
+
So: capture in Claude Code, then open Cursor or Codex and they pull up what Claude learned. On
|
|
222
|
+
Claude Code that handoff is mechanical via hooks; on the MCP tools the agent does it via the
|
|
223
|
+
standing instruction (or you type `/recall`); through the proxy it is mechanical for any model
|
|
224
|
+
endpoint you control.
|
|
225
|
+
|
|
226
|
+
## The 60-second trust demo
|
|
227
|
+
|
|
228
|
+
Run the product thesis locally without starting a daemon:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
npm run demo:trust
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
It creates a temp repo, captures a code-backed memory, changes the file, and proves `safe_only`
|
|
235
|
+
recall refuses the now-stale memory while plain search can still find it. Then it captures two
|
|
236
|
+
sourced claims (`runtime uses node 22` / `runtime uses bun runtime`), proves safe recall keeps
|
|
237
|
+
**both** (it never silently drops a true fact), and shows `memwarden doctor` flagging the
|
|
238
|
+
contradiction as an advisory.
|
|
239
|
+
|
|
240
|
+
## Self-healing
|
|
241
|
+
|
|
242
|
+
Once it is up, you never touch it.
|
|
243
|
+
|
|
244
|
+
- **On use** — if the daemon is down, the next tool that launches the MCP server revives it
|
|
245
|
+
automatically (it spawns the daemon and retries the request).
|
|
246
|
+
- **On crash or reboot** — the OS service (macOS LaunchAgent / Linux systemd `--user`) restarts
|
|
247
|
+
it on failure and starts it at login.
|
|
248
|
+
- **Race-safe** — a second daemon on the same port exits cleanly instead of crash-looping.
|
|
249
|
+
|
|
250
|
+
## How it works
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
your tool ──observe──▶ compress (on-device) ──▶ libSQL store + hash-chained oplog
|
|
254
|
+
│
|
|
255
|
+
MiniLM embed ──▶ TurboQuant 4-bit codes ──▶ vector index │ (tamper-evident)
|
|
256
|
+
▼
|
|
257
|
+
your tool ◀──verified recall── BM25 + vector (RRF), firewalled, packed under a token budget
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
1. **Capture.** `observe` compresses raw tool output into a compact record (no LLM call), and
|
|
261
|
+
hashes the source files it references.
|
|
262
|
+
2. **Embed and compress.** text → `all-MiniLM-L6-v2` vector → **TurboQuant** 2/4-bit codes
|
|
263
|
+
(Google's quantization algorithm, [arXiv:2504.19874](https://arxiv.org/abs/2504.19874),
|
|
264
|
+
implemented from scratch in pure TypeScript).
|
|
265
|
+
3. **Store and chain.** Every write lands in the SHA-256 hash-chained oplog, so the store is
|
|
266
|
+
tamper-evident and `memory_verify` can confirm the chain is intact.
|
|
267
|
+
4. **Verified recall.** Hybrid BM25 + vector search (RRF), scoped to your project by canonical
|
|
268
|
+
path (symlinks and path spellings resolved, so recall never silently misses), firewalled so
|
|
269
|
+
stale memory never reaches the model, packed under a token budget. (Contradictions are
|
|
270
|
+
surfaced by `doctor` as advisories — recall never silently drops a true memory.)
|
|
271
|
+
|
|
272
|
+
## The numbers
|
|
273
|
+
|
|
274
|
+
Measured on this machine with the real on-device model (`all-MiniLM-L6-v2`), 30 coding
|
|
275
|
+
memories, 14 **paraphrased** queries (worded differently than the answers). Reproduce with
|
|
276
|
+
`npm run benchmark`:
|
|
277
|
+
|
|
278
|
+
| Retrieval (gold answer in top-k) | R@5 | R@10 |
|
|
279
|
+
| --- | --- | --- |
|
|
280
|
+
| Full-precision vectors | 100% | 100% |
|
|
281
|
+
| **TurboQuant (4-bit, compressed)** | **100%** | **100%** |
|
|
282
|
+
| Keyword search (lexical baseline) | 71% | 79% |
|
|
283
|
+
|
|
284
|
+
- **Compression costs zero recall** — TurboQuant matches full-precision exactly.
|
|
285
|
+
- **Meaning beats keywords by ~25 points** — paraphrased questions that share no words with
|
|
286
|
+
the answer still resolve.
|
|
287
|
+
- **5.9× smaller** vectors (384-dim @ 4-bit; ~11× at 2-bit), **~1ms** per search.
|
|
288
|
+
|
|
289
|
+
> The 100% figures are on a small, clean corpus. The point is that compression is free
|
|
290
|
+
> (quantized == full-precision) and semantic recall beats lexical. Larger, noisier corpora
|
|
291
|
+
> land below 100%, but the relationship holds.
|
|
292
|
+
|
|
293
|
+
## What it does
|
|
294
|
+
|
|
295
|
+
| Capability | How |
|
|
296
|
+
| --- | --- |
|
|
297
|
+
| Memory firewall — stale memory never injected | Verified Recall (`safe_only`) |
|
|
298
|
+
| Trust audit — stale / unsourced / conflicts | `memwarden doctor` |
|
|
299
|
+
| Validity tied to source-file content | per-file SHA-256, re-checked on recall |
|
|
300
|
+
| Tamper-evident store | hash-chained oplog + `memory_verify` |
|
|
301
|
+
| One-command setup across every tool | `memwarden up` (7 tools) |
|
|
302
|
+
| Self-healing daemon (use + crash + reboot) | LaunchAgent / systemd + revive-on-use |
|
|
303
|
+
| Self-custodied, portable | `export` / `import` Brain Bundle, zero cloud |
|
|
304
|
+
| Compressed storage | TurboQuant, ~6–11× smaller |
|
|
305
|
+
| Lean footprint | 2 runtime deps (libSQL, zod); embeddings + MCP add nothing native |
|
|
306
|
+
|
|
307
|
+
## MCP tools and the `/recall` command
|
|
308
|
+
|
|
309
|
+
| Tool | What it does |
|
|
310
|
+
| --- | --- |
|
|
311
|
+
| `memory_resume` | Verified recall of what was worked on in this project, across all past sessions and tools |
|
|
312
|
+
| `memory_search` | Hybrid semantic + keyword search (unfiltered, for explicit lookups) |
|
|
313
|
+
| `memory_remember` | Save a memory explicitly |
|
|
314
|
+
| `memory_verify` | Confirm the oplog hash chain is intact (tamper-evident; not signed) |
|
|
315
|
+
| `memory_stats` | Live counts, compression ratio, token reduction, latency |
|
|
316
|
+
|
|
317
|
+
Plus an MCP **prompt**, `recall`, surfaced as a slash command (`/mcp__memwarden__recall <query>`
|
|
318
|
+
in Claude Code): type it mid-chat to pull this project's matching, verified memory into the
|
|
319
|
+
conversation.
|
|
320
|
+
|
|
321
|
+
## The proxy — one memory layer for the models you control
|
|
322
|
+
|
|
323
|
+
An OpenAI-compatible gateway on `:3113` that any model-configurable tool can point its base URL
|
|
324
|
+
at. It injects relevant verified memory, captures the answer, and is blind to the model behind
|
|
325
|
+
it. Local (Ollama, LM Studio) and paid (OpenAI, OpenRouter, Together) all speak the same
|
|
326
|
+
`/v1/chat/completions`, so it is one memory layer for all of them. Streaming (SSE) passes
|
|
327
|
+
straight through. It applies only where you control the model endpoint — tools with their own
|
|
328
|
+
protocol or backend (Claude Code, Cursor, Kiro, Antigravity) are covered by hooks or the
|
|
329
|
+
standing instruction instead.
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
# paid upstream:
|
|
333
|
+
MEMWARDEN_UPSTREAM_URL=https://api.openai.com/v1 MEMWARDEN_UPSTREAM_KEY=sk-... node dist/index.js
|
|
334
|
+
# local model, no key:
|
|
335
|
+
MEMWARDEN_UPSTREAM_URL=http://localhost:11434/v1 node dist/index.js
|
|
336
|
+
# then point your tool's OpenAI base URL at: http://localhost:3113/v1
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
When the install has a secret (`memwarden up` generates one), the proxy requires it from
|
|
340
|
+
clients too: set your tool's API key to the secret (`cat ~/.memwarden/secret`). The proxy
|
|
341
|
+
strips it before forwarding, so it never reaches the upstream. Without this, any local
|
|
342
|
+
process could spend your upstream key and poison capture.
|
|
343
|
+
|
|
344
|
+
## Portability — your memory survives the next pivot
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
node dist/cli/bin.js export brain.json # on machine A
|
|
348
|
+
node dist/cli/bin.js import brain.json # on machine B
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
Your memory is a portable JSON Brain Bundle. No cloud, no vendor in the loop. When the next
|
|
352
|
+
memory startup gets acquired or sunset, you keep your brain.
|
|
353
|
+
|
|
354
|
+
## Layout
|
|
355
|
+
|
|
356
|
+
```
|
|
357
|
+
src/kernel/ in-process runtime: function registry, trigger dispatch, pubsub, HTTP
|
|
358
|
+
src/state/ StateKV, memory + libSQL stores, append-only hash-chained oplog
|
|
359
|
+
src/functions/ observe / search (BM25 + TurboQuant vector + RRF) / doctor / conflicts / dejafix / context / forget
|
|
360
|
+
src/functions/verify.ts Verified Recall: content-hash provenance -> verified / sourced_unverified / stale / unsourced
|
|
361
|
+
src/functions/paths.ts canonical project/cwd scoping (recall never silently misses)
|
|
362
|
+
src/embedding/ on-device embedding provider (transformers.js, optional)
|
|
363
|
+
src/mcp/ dependency-free MCP server (stdio JSON-RPC) + the recall prompt
|
|
364
|
+
src/proxy/ OpenAI-compatible memory gateway (for model endpoints you control)
|
|
365
|
+
src/daemon/ ensure (self-heal on use) + service (self-heal on crash/reboot)
|
|
366
|
+
src/cli/ up / down / connect / doctor / audit / forget / exclude / dejafix / hooks / export / import
|
|
367
|
+
src/cli/tools.ts per-tool adapters: Claude Code, Codex, Cursor, Kiro, Antigravity, OpenCode, OpenClaw
|
|
368
|
+
src/bundle/ portable Brain Bundle export & import
|
|
369
|
+
benchmark/ reproducible recall benchmark
|
|
370
|
+
test/ 290 tests: kernel, store parity, oplog, quantizer, MCP, proxy, tool-wiring,
|
|
371
|
+
Verified Recall, Déjà Fix, foreign-store audit, delete receipts, injection
|
|
372
|
+
controls, conflict audit, HTTP security (auth/host/content-type),
|
|
373
|
+
path scoping, self-heal, cross-tool reliability harness, e2e
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## Configuration
|
|
377
|
+
|
|
378
|
+
| Env | Default | Purpose |
|
|
379
|
+
| --- | --- | --- |
|
|
380
|
+
| `MEMWARDEN_DATA_DIR` | `~/.memwarden` | where the brain lives |
|
|
381
|
+
| `MEMWARDEN_EMBEDDING_PROVIDER` | `local` | `local` (on-device MiniLM) or `none` (keyword-only) |
|
|
382
|
+
| `MEMWARDEN_QUANT_VECTOR` | follows embeddings | force TurboQuant on/off |
|
|
383
|
+
| `MEMWARDEN_QUANT_BITS` | `4` | `2` or `4` bits per dimension |
|
|
384
|
+
| `MEMWARDEN_FORGET_TTL_DAYS` | `30` | retention window for the forget sweep |
|
|
385
|
+
| `MEMWARDEN_SECRET` | unset | bearer token for the REST API and the proxy (clients send it as their API key) |
|
|
386
|
+
| `MEMWARDEN_INJECT` | on | `off` disables ALL auto-injection (SessionStart, Déjà Fix, proxy); `/recall` and MCP still work |
|
|
387
|
+
| `MEMWARDEN_CAPTURE` | on | `off` disables ALL auto-capture (PostToolUse hook, proxy tee) |
|
|
388
|
+
| `MEMWARDEN_UPSTREAM_URL` | unset | upstream OpenAI-compatible base URL; enables the proxy |
|
|
389
|
+
| `MEMWARDEN_UPSTREAM_KEY` | unset | API key forwarded to the upstream (omit for local models) |
|
|
390
|
+
| `MEMWARDEN_PROXY_PORT` | `3113` | port the memory proxy listens on |
|
|
391
|
+
|
|
392
|
+
## Not built yet (so this README does not pretend otherwise)
|
|
393
|
+
|
|
394
|
+
Verified Recall checks deletion and content drift; `doctor` additionally flags conservative
|
|
395
|
+
subject/value conflicts as advisories (it never drops them from recall).
|
|
396
|
+
Tamper-*evidence* ships via the hash chain, but oplog *signing* (Ed25519), *encrypted* Brain
|
|
397
|
+
Bundles, and an ANN index for >1M-memory scale are not. These are candidates, not claims. The
|
|
398
|
+
hash chain detects edits and reorders; it does not detect tail-truncation.
|
|
399
|
+
|
|
400
|
+
## License
|
|
401
|
+
|
|
402
|
+
Apache-2.0
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { StateKV } from "../state/kv.js";
|
|
2
|
+
import type { CompressedObservation, Memory, Session } from "../functions/types.js";
|
|
3
|
+
export declare const BRAIN_BUNDLE_KIND = "memwarden.brain";
|
|
4
|
+
export declare const BRAIN_BUNDLE_VERSION = 1;
|
|
5
|
+
export interface BrainBundle {
|
|
6
|
+
kind: typeof BRAIN_BUNDLE_KIND;
|
|
7
|
+
version: number;
|
|
8
|
+
exportedAt?: string;
|
|
9
|
+
sessions: Session[];
|
|
10
|
+
memories: Memory[];
|
|
11
|
+
observations: Record<string, CompressedObservation[]>;
|
|
12
|
+
quantBlob?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface BundleCounts {
|
|
15
|
+
sessions: number;
|
|
16
|
+
memories: number;
|
|
17
|
+
observations: number;
|
|
18
|
+
}
|
|
19
|
+
/** Gather the durable store into a portable bundle. */
|
|
20
|
+
export declare function exportBundle(kv: StateKV): Promise<BrainBundle>;
|
|
21
|
+
/** Validate a parsed object is a bundle we can import. */
|
|
22
|
+
export declare function isBrainBundle(value: unknown): value is BrainBundle;
|
|
23
|
+
/**
|
|
24
|
+
* Write a bundle into a (typically fresh) store. Existing keys are
|
|
25
|
+
* overwritten (last-write-wins), matching the store's own semantics. The
|
|
26
|
+
* search/vector indexes rebuild lazily on the next mem::search.
|
|
27
|
+
*/
|
|
28
|
+
export declare function importBundle(kv: StateKV, bundle: BrainBundle): Promise<BundleCounts>;
|