@nxuss/lemma 1.22.1 → 1.23.0
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/README.md +33 -7
- package/dist/cjs/cloud/store/FileBrainStore.d.ts.map +1 -1
- package/dist/cjs/cloud/store/FileBrainStore.js +5 -2
- package/dist/cjs/cloud/store/FileBrainStore.js.map +1 -1
- package/dist/cjs/mcp/tool-profiles.d.ts.map +1 -1
- package/dist/cjs/mcp/tool-profiles.js +3 -0
- package/dist/cjs/mcp/tool-profiles.js.map +1 -1
- package/dist/cjs/mcp/tools/memory.d.ts.map +1 -1
- package/dist/cjs/mcp/tools/memory.js +212 -7
- package/dist/cjs/mcp/tools/memory.js.map +1 -1
- package/dist/cjs/mcp/tools.d.ts +9 -0
- package/dist/cjs/mcp/tools.d.ts.map +1 -1
- package/dist/cjs/mcp/tools.js +25 -4
- package/dist/cjs/mcp/tools.js.map +1 -1
- package/dist/cjs/security/scrubForStorage.d.ts +16 -0
- package/dist/cjs/security/scrubForStorage.d.ts.map +1 -0
- package/dist/cjs/security/scrubForStorage.js +35 -0
- package/dist/cjs/security/scrubForStorage.js.map +1 -0
- package/dist/cjs/subconscious/BrainEncryption.d.ts +38 -0
- package/dist/cjs/subconscious/BrainEncryption.d.ts.map +1 -0
- package/dist/cjs/subconscious/BrainEncryption.js +137 -0
- package/dist/cjs/subconscious/BrainEncryption.js.map +1 -0
- package/dist/cjs/subconscious/TheBrainV2.d.ts +294 -0
- package/dist/cjs/subconscious/TheBrainV2.d.ts.map +1 -1
- package/dist/cjs/subconscious/TheBrainV2.js +1070 -111
- package/dist/cjs/subconscious/TheBrainV2.js.map +1 -1
- package/dist/esm/cloud/store/FileBrainStore.d.ts.map +1 -1
- package/dist/esm/cloud/store/FileBrainStore.js +5 -2
- package/dist/esm/cloud/store/FileBrainStore.js.map +1 -1
- package/dist/esm/mcp/tool-profiles.d.ts.map +1 -1
- package/dist/esm/mcp/tool-profiles.js +3 -0
- package/dist/esm/mcp/tool-profiles.js.map +1 -1
- package/dist/esm/mcp/tools/memory.d.ts.map +1 -1
- package/dist/esm/mcp/tools/memory.js +212 -7
- package/dist/esm/mcp/tools/memory.js.map +1 -1
- package/dist/esm/mcp/tools.d.ts +9 -0
- package/dist/esm/mcp/tools.d.ts.map +1 -1
- package/dist/esm/mcp/tools.js +25 -5
- package/dist/esm/mcp/tools.js.map +1 -1
- package/dist/esm/security/scrubForStorage.d.ts +16 -0
- package/dist/esm/security/scrubForStorage.d.ts.map +1 -0
- package/dist/esm/security/scrubForStorage.js +32 -0
- package/dist/esm/security/scrubForStorage.js.map +1 -0
- package/dist/esm/subconscious/BrainEncryption.d.ts +38 -0
- package/dist/esm/subconscious/BrainEncryption.d.ts.map +1 -0
- package/dist/esm/subconscious/BrainEncryption.js +126 -0
- package/dist/esm/subconscious/BrainEncryption.js.map +1 -0
- package/dist/esm/subconscious/TheBrainV2.d.ts +294 -0
- package/dist/esm/subconscious/TheBrainV2.d.ts.map +1 -1
- package/dist/esm/subconscious/TheBrainV2.js +1068 -111
- package/dist/esm/subconscious/TheBrainV2.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,6 +52,23 @@ lemma start # gateway + dashboard on http://localhost:8081
|
|
|
52
52
|
real usage (`hits`), explicit negative feedback (`downvote_memory`), and `cognitive_map` domain
|
|
53
53
|
tags; a passing `test_oracle` run over an uncommitted diff auto-captures itself; two memories
|
|
54
54
|
about the same symbol that disagree on outcome are flagged, not silently both suggested.
|
|
55
|
+
Every hit explains itself (`whyShown` ranking signals + cited `evidence` files/symbols), and
|
|
56
|
+
every reuse books its savings onto the memory itself — `brain_stats` names which memories
|
|
57
|
+
actually pay for the Brain (`totalTokensSaved`, top savers).
|
|
58
|
+
- **A memory that maintains itself** — `brain_upkeep` revalidates the most-reused memories,
|
|
59
|
+
surfaces exact duplicates and merge candidates, dead weight, and savings in one read-only
|
|
60
|
+
pass, each finding with its fix. `brain_merge` folds near-duplicate fragments into one
|
|
61
|
+
canonical entry (fragments survive as evidence-carrying claims). `forget_memory` moves to a
|
|
62
|
+
trash (`brain_trash`: list/restore/purge) instead of destroying, automatic snapshots roll
|
|
63
|
+
back every forget/import/clear/merge, and `brain_import dryRun:true` previews a bundle —
|
|
64
|
+
counts plus opposite-outcome conflicts — before a byte is written. Session onboarding
|
|
65
|
+
re-checks freshness of the memories it lists, so a day-one answer never starts stale.
|
|
66
|
+
- **Integrity and encryption at rest** — the corpus carries a sha256 sidecar with `.prev`
|
|
67
|
+
backup rotation: a half-written or rotted file serves its intact lines, falls back to the
|
|
68
|
+
backup on total loss, and quarantines (never deletes) the bad bytes, with the incident
|
|
69
|
+
surfaced in `brain_stats`. `LEMMA_BRAIN_ENCRYPT=1` (or `LEMMA_BRAIN_KEY`) stores the
|
|
70
|
+
corpus AES-256-GCM encrypted under a local 0600 key; secrets never reach disk at all —
|
|
71
|
+
scrub-on-store redacts credentials one-way before indexing or persisting.
|
|
55
72
|
- **Verifiable caching, not marketing numbers** — `state_hash_cache` only hits when the files an
|
|
56
73
|
answer depends on are byte-identical; `token_receipt` gives a real per-session breakdown of how
|
|
57
74
|
each answer was produced instead of an invented "% saved."
|
|
@@ -66,7 +83,7 @@ lemma start # gateway + dashboard on http://localhost:8081
|
|
|
66
83
|
compiler-verified AST location instead of asking the model to output a full-file rewrite.
|
|
67
84
|
- **Infrastructure Command Center** — 22 free tools for Jenkins, OKD/OpenShift, and Terraform:
|
|
68
85
|
discover, connect, deploy, diagnose, and detect drift, all via MCP.
|
|
69
|
-
- **Scoped tool surface** — of the
|
|
86
|
+
- **Scoped tool surface** — of the 108 registered tools, only the ones your project shows evidence
|
|
70
87
|
of needing are advertised to the model each turn; the rest stay one `lemma_toolbox` call away.
|
|
71
88
|
|
|
72
89
|
See [`CHANGELOG.md`](CHANGELOG.md) for the full, per-version history.
|
|
@@ -75,13 +92,14 @@ See [`CHANGELOG.md`](CHANGELOG.md) for the full, per-version history.
|
|
|
75
92
|
|
|
76
93
|
## 💎 Free vs Pro
|
|
77
94
|
|
|
78
|
-
|
|
79
|
-
code (`FREE_TOOLS` in `src/mcp/tools.ts
|
|
80
|
-
even advertise the Pro tools — they stay registered and
|
|
95
|
+
58 of the 108 registered tools work with no license; 50 require Pro. Enforced by one allowlist in
|
|
96
|
+
code (`FREE_TOOLS` in `src/mcp/tools.ts`, including all 22 infrastructure tools), not by narrative.
|
|
97
|
+
A session without a license doesn't even advertise the Pro tools — they stay registered and
|
|
98
|
+
discoverable via `lemma_toolbox`.
|
|
81
99
|
|
|
82
|
-
| | Free (
|
|
100
|
+
| | Free (58) | Pro (50) |
|
|
83
101
|
| :--- | :--- | :--- |
|
|
84
|
-
| **Caching & memory** | `smarter_cache`, `state_hash_cache`, `token_receipt`, `search_memory`, `store_memory`, `downvote_memory`, `verify_memory`, `token_budget` | `get_telepathic_hints`, `query_hybrid_consensus`, `semantic_dedup_guard`, `local_semantic_autofix` |
|
|
102
|
+
| **Caching & memory** | `smarter_cache`, `state_hash_cache`, `token_receipt`, `search_memory`, `store_memory`, `downvote_memory`, `verify_memory`, `token_budget`, `brain_upkeep`, `brain_trash`, `brain_merge` | `get_telepathic_hints`, `query_hybrid_consensus`, `semantic_dedup_guard`, `local_semantic_autofix` |
|
|
85
103
|
| **Reading & context** | `read_workspace_file`, `scrub_privacy`, `import_tree_context`, `bulk_file_digest`, `auto_context_bundle`, `git_blame_heat`, `type_coverage_report` | `get_ast_hologram`, `smart_file_slice`, `get_symbol_surgical_context`, `diff_only` |
|
|
86
104
|
| **Writing & workspace** | — | `write_workspace_file`, `apply_workspace_patch`, `multi_file_patch`, `search_workspace`, `run_workspace_command`, `validate_patch_sandbox`, `surgical_ast_insert` |
|
|
87
105
|
| **Static analysis** | — | `entropy_score`, `coupling_radar`, `pattern_fossil`, `precrime_static`, `dead_export_necromancer`, `depgraph`, `refactor`, `ast_flow_visualizer`, `cognitive_map` |
|
|
@@ -96,7 +114,7 @@ Full per-tool listing: `lemma_toolbox { "action": "list" }`.
|
|
|
96
114
|
|
|
97
115
|
## 🎚️ Tool profiles
|
|
98
116
|
|
|
99
|
-
Every advertised tool schema is re-sent on **every request** of the session — advertising all
|
|
117
|
+
Every advertised tool schema is re-sent on **every request** of the session — advertising all 108
|
|
100
118
|
costs ~11,600 tokens/turn. Lemma advertises a scoped surface instead: core tools always, situational
|
|
101
119
|
groups (e.g. infrastructure) only when the repo shows evidence for them. Nothing is removed —
|
|
102
120
|
everything stays registered and reachable via `lemma_toolbox`.
|
|
@@ -194,6 +212,14 @@ JS/TS, Python, Go, Rust, Ruby, JVM, `make`, git/gh, read-only shell utilities, a
|
|
|
194
212
|
CLIs. Extend via `lemma.config.json` → `mcp.allowedCommandPrefixes`. See
|
|
195
213
|
[`.env.security.example`](.env.security.example) for every security-related env var.
|
|
196
214
|
|
|
215
|
+
**Brain at rest.** Secrets are redacted one-way before a memory is indexed or persisted
|
|
216
|
+
(scrub-on-store, same patterns as the traffic firewall — the token map is discarded, there is
|
|
217
|
+
no unmask step). `LEMMA_BRAIN_ENCRYPT=1` additionally stores the corpus AES-256-GCM encrypted
|
|
218
|
+
under `<brainDir>/.brain.key` (0600, auto-generated); `LEMMA_BRAIN_KEY` (64 hex chars or base64
|
|
219
|
+
of 32 bytes) overrides it for teams sharing one key. A malformed key fails loud at startup;
|
|
220
|
+
a wrong key flows into the integrity fallback (backup → quarantine → fresh start), never an
|
|
221
|
+
exception, never half a corpus.
|
|
222
|
+
|
|
197
223
|
---
|
|
198
224
|
|
|
199
225
|
## 🦜 SDK integrations & proxy mode
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileBrainStore.d.ts","sourceRoot":"","sources":["../../../../src/cloud/store/FileBrainStore.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"FileBrainStore.d.ts","sourceRoot":"","sources":["../../../../src/cloud/store/FileBrainStore.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAY9D,MAAM,WAAW,qBAAqB;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA4CD,qBAAa,cAAe,YAAW,UAAU;IAMnC,OAAO,CAAC,OAAO;IAL3B,QAAQ,CAAC,IAAI,OAAO;IAEpB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,KAAK,CAAoG;gBAE7F,OAAO,GAAE,qBAA0B;IAKvD,OAAO,CAAC,IAAI;IAoBZ;;;mFAG+E;IAC/E,OAAO,CAAC,IAAI;IAcZ,OAAO,CAAC,QAAQ;IAIV,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAwCvD,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAS1D,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAmDtF,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAczE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAU7D;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -25,6 +25,7 @@ const os_1 = __importDefault(require("os"));
|
|
|
25
25
|
const path_1 = __importDefault(require("path"));
|
|
26
26
|
const crypto_1 = __importDefault(require("crypto"));
|
|
27
27
|
const TheBrainV2_1 = require("../../subconscious/TheBrainV2");
|
|
28
|
+
const scrubForStorage_1 = require("../../security/scrubForStorage");
|
|
28
29
|
const DEFAULT_TENANT = 'default';
|
|
29
30
|
function isRecord(v) {
|
|
30
31
|
return typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
@@ -108,8 +109,10 @@ class FileBrainStore {
|
|
|
108
109
|
}
|
|
109
110
|
async put(tenantId, memory) {
|
|
110
111
|
const m = isRecord(memory) ? memory : {};
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
// Same one-way redaction as the local Brain: the cloud lane must not be the path
|
|
113
|
+
// that persists live credentials.
|
|
114
|
+
const query = typeof m.query === 'string' ? (0, scrubForStorage_1.scrubSecretsForStorage)(m.query).text : '';
|
|
115
|
+
const response = typeof m.response === 'string' ? (0, scrubForStorage_1.scrubSecretsForStorage)(m.response).text : '';
|
|
113
116
|
const id = typeof m.id === 'string' && m.id.length > 0 ? m.id : generateId(query || response);
|
|
114
117
|
const terms = Array.isArray(m.terms) && m.terms.length > 0
|
|
115
118
|
? [...new Set(m.terms.filter((t) => typeof t === 'string'))]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileBrainStore.js","sourceRoot":"","sources":["../../../../src/cloud/store/FileBrainStore.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,oDAA4B;AAG5B,8DAKuC;
|
|
1
|
+
{"version":3,"file":"FileBrainStore.js","sourceRoot":"","sources":["../../../../src/cloud/store/FileBrainStore.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,oDAA4B;AAG5B,8DAKuC;AACvC,oEAAwE;AAExE,MAAM,cAAc,GAAG,SAAS,CAAC;AAiBjC,SAAS,QAAQ,CAAC,CAAU;IAC1B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK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AjLD,wCAiLC;AAED,kBAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-profiles.d.ts","sourceRoot":"","sources":["../../../src/mcp/tool-profiles.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEnD;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"tool-profiles.d.ts","sourceRoot":"","sources":["../../../src/mcp/tool-profiles.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEnD;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,EA0CnC,CAAC;AAsHF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,UAAoE,CAAC;AAkBnG,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE;IAC7D,OAAO,EAAE,WAAW,CAAC;IACrB,wCAAwC;IACxC,UAAU,EAAE,CAAC,EAAE,CAAC;IAChB,uFAAuF;IACvF,MAAM,EAAE,CAAC,EAAE,CAAC;IACZ,oDAAoD;IACpD,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CACxC;AAED,wBAAgB,kBAAkB,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,EACjF,cAAc,EAAE,CAAC,EAAE,EACnB,GAAG,GAAE,MAAsB,EAC3B,OAAO,GAAE,cAAmB,GAC3B,mBAAmB,CAAC,CAAC,CAAC,CAqDxB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,EACrD,KAAK,CAAC,EAAE,MAAM,GACb,MAAM,CAuDR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-profiles.js","sourceRoot":"","sources":["../../../src/mcp/tool-profiles.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"tool-profiles.js","sourceRoot":"","sources":["../../../src/mcp/tool-profiles.ts"],"names":[],"mappings":";;;;;;AAyOA,gDAyDC;AAMD,kDA0DC;AAlWD,4CAAoB;AACpB,gDAAwB;AACxB,kDAAiD;AAsBjD;;;;GAIG;AACU,QAAA,eAAe,GAAa;IACvC,8BAA8B;IAC9B,qBAAqB;IACrB,oBAAoB;IACpB,kBAAkB;IAClB,kBAAkB;IAClB,uBAAuB;IACvB,eAAe;IACf,oDAAoD;IACpD,uBAAuB;IACvB,sBAAsB;IACtB,uBAAuB;IACvB,qBAAqB;IACrB,wBAAwB;IACxB,wCAAwC;IACxC,kBAAkB;IAClB,6BAA6B;IAC7B,wBAAwB;IACxB,oFAAoF;IACpF,uCAAuC;IACvC,gBAAgB;IAChB,6CAA6C;IAC7C,kBAAkB;IAClB,eAAe;IACf,yFAAyF;IACzF,2FAA2F;IAC3F,yFAAyF;IACzF,yFAAyF;IACzF,uCAAuC;IACvC,eAAe;IACf,YAAY;IACZ,cAAc;IACd,eAAe;IACf,eAAe;IACf,gBAAgB;IAChB,eAAe;IACf,cAAc;IACd,aAAa;IACb,aAAa;IACb,uBAAuB;IACvB,eAAe;IACf,oBAAoB;CACrB,CAAC;AAaF;;;;;;;;;;GAUG;AACH,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAClC,MAAM,4BAA4B,GAAG,IAAI,CAAC;AAE1C,SAAS,gBAAgB,CAAC,GAAW,EAAE,cAA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+1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/memory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhE,eAAO,MAAM,uBAAuB,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../../src/mcp/tools/memory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhE,eAAO,MAAM,uBAAuB,EAAE,cAAc,EAmTnD,CAAC;AA0oBF,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAe5D,CAAC"}
|
|
@@ -205,7 +205,7 @@ exports.MEMORY_TOOL_DEFINITIONS = [
|
|
|
205
205
|
{
|
|
206
206
|
name: "forget_memory",
|
|
207
207
|
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
208
|
-
description: "
|
|
208
|
+
description: "Delete one memory from the Brain by id. Use when a memory is flat wrong, was captured by mistake, or should never have been stored — not when it is merely a poor match for one query (that is downvote_memory, which keeps it around for a different question later). The memory moves to the trash (restorable with brain_trash action=restore) and a corpus snapshot is taken first, so a mistaken delete is recoverable two ways; the id stays deleted and will not come back from another session's copy. The deleted body is returned in the result for the record.",
|
|
209
209
|
inputSchema: {
|
|
210
210
|
type: "object",
|
|
211
211
|
properties: {
|
|
@@ -214,6 +214,51 @@ exports.MEMORY_TOOL_DEFINITIONS = [
|
|
|
214
214
|
required: ["id"],
|
|
215
215
|
},
|
|
216
216
|
},
|
|
217
|
+
{
|
|
218
|
+
name: "brain_trash",
|
|
219
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
220
|
+
description: "Undo and rollback for the Brain. Actions: list/restore/purge forgotten memories, snapshots/restore-snapshot for corpus rollback points (auto-taken before forget/import/clear/merge; a restore snapshots first, so it is undoable too).",
|
|
221
|
+
inputSchema: {
|
|
222
|
+
type: "object",
|
|
223
|
+
properties: {
|
|
224
|
+
action: {
|
|
225
|
+
type: "string",
|
|
226
|
+
enum: ["list", "restore", "purge", "snapshots", "restore-snapshot"],
|
|
227
|
+
description: "What to do with the trash / snapshots.",
|
|
228
|
+
},
|
|
229
|
+
id: { type: "string", description: "Memory id to restore (action=restore)." },
|
|
230
|
+
olderThanDays: { type: "number", description: "With action=purge: only permanently drop deletions older than N days. Omit to empty the whole trash." },
|
|
231
|
+
name: { type: "string", description: "Snapshot name to roll back to (action=restore-snapshot, from action=snapshots)." },
|
|
232
|
+
},
|
|
233
|
+
required: ["action"],
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: "brain_merge",
|
|
238
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
|
|
239
|
+
description: "Fold near-duplicate memories into one canonical keeper (text untouched; fragments become evidence-carrying claims, counters inherited, fragments trashed, pre-merge snapshot taken). Use on brain_upkeep merge candidates — never merge memories that merely share a topic but assert different things.",
|
|
240
|
+
inputSchema: {
|
|
241
|
+
type: "object",
|
|
242
|
+
properties: {
|
|
243
|
+
keepId: { type: "string", description: "Id of the canonical memory that survives." },
|
|
244
|
+
foldIds: { type: "array", items: { type: "string" }, description: "Ids of the fragments to fold into the keeper (1 or more, all must exist)." },
|
|
245
|
+
},
|
|
246
|
+
required: ["keepId", "foldIds"],
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: "brain_upkeep",
|
|
251
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
252
|
+
description: "Tend the Brain in one read-only call: revalidates the most-reused memories, lists duplicates/merge candidates/dead weight/savings, each with its fix (refresh_memory, brain_merge, forget_memory). Never deletes or rewrites anything. Run when returning to a repo after a while.",
|
|
253
|
+
inputSchema: {
|
|
254
|
+
type: "object",
|
|
255
|
+
properties: {
|
|
256
|
+
topN: { type: "number", description: "How many of the most-reused memories to revalidate. Default 20.", default: 20 },
|
|
257
|
+
sample: { type: "number", description: "How many entries to sweep for duplicates. Default 50 (bounded: each issues one internal search).", default: 50 },
|
|
258
|
+
deep: { type: "boolean", description: "Also re-hash all tracked evidence for a corpus-wide stale ratio. Slow on large Brains.", default: false },
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
},
|
|
217
262
|
{
|
|
218
263
|
name: "refresh_memory",
|
|
219
264
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
@@ -268,11 +313,12 @@ exports.MEMORY_TOOL_DEFINITIONS = [
|
|
|
268
313
|
{
|
|
269
314
|
name: "brain_import",
|
|
270
315
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
271
|
-
description: "Merge a bundle written by brain_export into this Brain. Additive and non-destructive: an id already present keeps the newer version, and anything previously deleted with forget_memory stays deleted. Imported memories track the paths of the machine they came from, so most will read as stale here until refresh_memory re-anchors them.",
|
|
316
|
+
description: "Merge a bundle written by brain_export into this Brain. Additive and non-destructive: an id already present keeps the newer version, and anything previously deleted with forget_memory stays deleted. Imported memories track the paths of the machine they came from, so most will read as stale here until refresh_memory re-anchors them. Pass dryRun:true first on any bundle you did not write yourself — it reports exactly what would be imported, updated, skipped, and which entries conflict with live memories, without writing anything.",
|
|
272
317
|
inputSchema: {
|
|
273
318
|
type: "object",
|
|
274
319
|
properties: {
|
|
275
320
|
path: { type: "string", description: "Path to the bundle file (relative to the workspace root)." },
|
|
321
|
+
dryRun: { type: "boolean", description: "Preview only: report what would happen without writing anything.", default: false },
|
|
276
322
|
},
|
|
277
323
|
required: ["path"],
|
|
278
324
|
},
|
|
@@ -317,7 +363,16 @@ async function handleSearchMemory(args) {
|
|
|
317
363
|
const staleCount = r.claims.filter((c) => !c.fresh).length;
|
|
318
364
|
return `\nClaims (${r.claims.length - staleCount}/${r.claims.length} still fresh — trust only the ✓ ones):\n${lines.join("\n")}`;
|
|
319
365
|
};
|
|
320
|
-
const formatResult = (r, i) => `Result ${i + 1} (id: ${r.id}, Similarity: ${(r.similarity * 100).toFixed(1)}%)${r.outcome === "failed" ? "\n⚠️ TAGGED AS A FAILED ATTEMPT — this was tried before and did NOT work. Do not repeat it; treat this as a warning, not a suggestion." : ""}
|
|
366
|
+
const formatResult = (r, i) => `Result ${i + 1} (id: ${r.id}, Similarity: ${(r.similarity * 100).toFixed(1)}%)${r.outcome === "failed" ? "\n⚠️ TAGGED AS A FAILED ATTEMPT — this was tried before and did NOT work. Do not repeat it; treat this as a warning, not a suggestion." : ""}${typeof r.tokensSaved === "number" && r.tokensSaved > 0
|
|
367
|
+
? `\n💰 This memory has saved ${r.tokensSaved} tokens across ${r.hits || "?"} reuse(s) — prefer it over re-deriving.`
|
|
368
|
+
: ""}\nPrompt: ${r.query.substring(0, 300)}...\nResponse: ${typeof r.response === "string" ? r.response : JSON.stringify(r.response, null, 2)}${formatClaims(r)}${Array.isArray(r.evidence) && r.evidence.length > 0
|
|
369
|
+
? `\nEvidence: ${r.evidence.map((e) => {
|
|
370
|
+
const sep = e.lastIndexOf("::");
|
|
371
|
+
return sep > 0 ? `${relLabel(e.substring(0, sep))}::${e.substring(sep + 2)}` : relLabel(e);
|
|
372
|
+
}).join(", ")}`
|
|
373
|
+
: ""}${Array.isArray(r.whyShown) && r.whyShown.length > 0
|
|
374
|
+
? `\nWhy shown: ${r.whyShown.join(" · ")}`
|
|
375
|
+
: ""}${Array.isArray(r.cosmeticChanges) && r.cosmeticChanges.length > 0
|
|
321
376
|
? `\n(comment/whitespace-only change, ignored under semanticDiff: ${r.cosmeticChanges.join(", ")})`
|
|
322
377
|
: ""}`;
|
|
323
378
|
if (fresh.length > 0) {
|
|
@@ -326,10 +381,15 @@ async function handleSearchMemory(args) {
|
|
|
326
381
|
const bestFresh = fresh[0];
|
|
327
382
|
const tokensSaved = Math.max(100, Math.floor(String(bestFresh.response).length / 4));
|
|
328
383
|
(0, reportSavings_1.reportSavings)({ source: "cache", tokens: tokensSaved, toolName: "search_memory", query: query.substring(0, 100) });
|
|
384
|
+
// Attribute the saving to the memory itself: the per-entry ROI ledger lives on the
|
|
385
|
+
// entry (persisted, merged, imported), booked on the same event as the ledger above
|
|
386
|
+
// so the two can never disagree about whether a reuse happened.
|
|
387
|
+
brain.creditSavings(bestFresh.id, tokensSaved);
|
|
329
388
|
(0, TokenReceipt_1.recordReceiptEvent)("semantic_cache_hit", query.substring(0, 100), {
|
|
330
389
|
tool: "search_memory",
|
|
331
390
|
similarity: bestFresh.similarity,
|
|
332
391
|
tokensSaved,
|
|
392
|
+
memoryId: bestFresh.id,
|
|
333
393
|
});
|
|
334
394
|
}
|
|
335
395
|
else {
|
|
@@ -532,7 +592,10 @@ async function handleStoreMemory(args) {
|
|
|
532
592
|
// later store, verify_memory, refresh_memory, forget_memory. Without it the caller had
|
|
533
593
|
// to search for the memory it had just written to do anything with it.
|
|
534
594
|
const idNote = storeRes.id ? ` (id: ${storeRes.id})` : "";
|
|
535
|
-
|
|
595
|
+
const scrubNote = storeRes.redactions > 0
|
|
596
|
+
? ` 🛡 ${storeRes.redactions} secret(s) redacted before storage — credentials are never persisted, only their placeholders.`
|
|
597
|
+
: "";
|
|
598
|
+
return { content: [{ type: "text", text: `Success: Memory stored${idNote}. ${storeRes.reason}${trackingNote}${symbolNote}${outcomeNote}${claimsNote}${domainNote}${derivedFromNote}${conflictsNote}${scrubNote}` }] };
|
|
536
599
|
}
|
|
537
600
|
catch (e) {
|
|
538
601
|
(0, utils_1.logError)("store_memory", e);
|
|
@@ -567,7 +630,7 @@ async function handleForgetMemory(args) {
|
|
|
567
630
|
if (preview?.status === "unknown") {
|
|
568
631
|
return { content: [{ type: "text", text: `No memory with id "${id}" in the Brain — nothing to delete.` }] };
|
|
569
632
|
}
|
|
570
|
-
const elicited = await (0, utils_1.tryElicitConfirmation)(`
|
|
633
|
+
const elicited = await (0, utils_1.tryElicitConfirmation)(`Delete Brain memory "${id}"? It moves to the trash (restorable with brain_trash), and a corpus snapshot is taken first.`);
|
|
571
634
|
if (elicited.supported && !elicited.confirmed) {
|
|
572
635
|
return { content: [{ type: "text", text: `Memory "${id}" was not deleted: declined during confirmation.` }] };
|
|
573
636
|
}
|
|
@@ -579,8 +642,8 @@ async function handleForgetMemory(args) {
|
|
|
579
642
|
// the header — and since forget_memory is the last step of correcting a long-lived
|
|
580
643
|
// memory, the text it dropped on the floor was often the only copy in existence.
|
|
581
644
|
const archiveNote = result.archivePath
|
|
582
|
-
? `\n\
|
|
583
|
-
: `\n\nThe Brain's
|
|
645
|
+
? `\n\nMoved to the trash (${result.archivePath}) — restore it with brain_trash action=restore, or roll the whole corpus back with action=restore-snapshot. The id stays deleted (brain_import will not resurrect it).`
|
|
646
|
+
: `\n\nThe Brain's trash file could not be written, so the text above is the only remaining copy.`;
|
|
584
647
|
return {
|
|
585
648
|
content: [{
|
|
586
649
|
type: "text",
|
|
@@ -593,6 +656,117 @@ async function handleForgetMemory(args) {
|
|
|
593
656
|
return { content: [{ type: "text", text: `Failed to delete memory: ${e.message}` }] };
|
|
594
657
|
}
|
|
595
658
|
}
|
|
659
|
+
async function handleBrainTrash(args) {
|
|
660
|
+
const action = args?.action;
|
|
661
|
+
try {
|
|
662
|
+
const brain = (0, TheBrainV2_1.getBrain)();
|
|
663
|
+
switch (action) {
|
|
664
|
+
case "list": {
|
|
665
|
+
const items = brain.listForgotten();
|
|
666
|
+
if (items.length === 0) {
|
|
667
|
+
return { content: [{ type: "text", text: "The trash is empty — every forgotten memory was purged or never deleted." }] };
|
|
668
|
+
}
|
|
669
|
+
const lines = items.map((t) => `- ${t.id}: ${t.query} (stored ${t.timestamp}, reused ${t.hits}x, forgotten ${t.forgottenAt})`);
|
|
670
|
+
return { content: [{ type: "text", text: `${items.length} forgotten ${items.length === 1 ? "memory" : "memories"} (restorable with action=restore):\n${lines.join("\n")}` }] };
|
|
671
|
+
}
|
|
672
|
+
case "restore": {
|
|
673
|
+
const id = args?.id;
|
|
674
|
+
if (!id)
|
|
675
|
+
throw new Error("id is required for action=restore");
|
|
676
|
+
const result = brain.restoreForgotten(id);
|
|
677
|
+
return { content: [{ type: "text", text: result.message }] };
|
|
678
|
+
}
|
|
679
|
+
case "purge": {
|
|
680
|
+
const olderThanDays = typeof args?.olderThanDays === "number" ? args.olderThanDays : undefined;
|
|
681
|
+
const result = brain.purgeForgotten(olderThanDays);
|
|
682
|
+
const scope = olderThanDays !== undefined ? ` older than ${olderThanDays} day(s)` : "";
|
|
683
|
+
return { content: [{ type: "text", text: `Purged ${result.purged} archived deletion(s)${scope}. ${result.remaining} remain restorable. Purged ids stay deleted — this removed the restore path, not the deletion.` }] };
|
|
684
|
+
}
|
|
685
|
+
case "snapshots": {
|
|
686
|
+
const snaps = brain.listSnapshots();
|
|
687
|
+
if (snaps.length === 0) {
|
|
688
|
+
return { content: [{ type: "text", text: "No snapshots yet — one is taken automatically before every forget, import, clear, and merge." }] };
|
|
689
|
+
}
|
|
690
|
+
const lines = snaps.map((s) => `- ${s.name} (${(s.bytes / 1024).toFixed(1)} KB, ${s.mtime})`);
|
|
691
|
+
return { content: [{ type: "text", text: `${snaps.length} rollback snapshot(s), newest last (restore with action=restore-snapshot):\n${lines.join("\n")}` }] };
|
|
692
|
+
}
|
|
693
|
+
case "restore-snapshot": {
|
|
694
|
+
const name = args?.name;
|
|
695
|
+
if (!name)
|
|
696
|
+
throw new Error("name is required for action=restore-snapshot (see action=snapshots)");
|
|
697
|
+
const result = brain.restoreSnapshot(name);
|
|
698
|
+
return { content: [{ type: "text", text: result.message }] };
|
|
699
|
+
}
|
|
700
|
+
default:
|
|
701
|
+
throw new Error(`Unknown action "${action}" — use list, restore, purge, snapshots, or restore-snapshot.`);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
catch (e) {
|
|
705
|
+
(0, utils_1.logError)("brain_trash", e);
|
|
706
|
+
return { content: [{ type: "text", text: `Trash operation failed: ${e.message}` }] };
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
async function handleBrainMerge(args) {
|
|
710
|
+
const keepId = args?.keepId;
|
|
711
|
+
const foldIds = Array.isArray(args?.foldIds) ? args.foldIds.filter((id) => typeof id === "string" && id) : [];
|
|
712
|
+
if (!keepId)
|
|
713
|
+
throw new Error("keepId is required");
|
|
714
|
+
if (foldIds.length === 0)
|
|
715
|
+
throw new Error("foldIds is required and must be a non-empty array");
|
|
716
|
+
try {
|
|
717
|
+
const result = (0, TheBrainV2_1.getBrain)().mergeEntries(keepId, foldIds);
|
|
718
|
+
return { content: [{ type: "text", text: result.message }] };
|
|
719
|
+
}
|
|
720
|
+
catch (e) {
|
|
721
|
+
(0, utils_1.logError)("brain_merge", e);
|
|
722
|
+
return { content: [{ type: "text", text: `Merge failed: ${e.message}` }] };
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
async function handleBrainUpkeep(args) {
|
|
726
|
+
try {
|
|
727
|
+
const report = (0, TheBrainV2_1.getBrain)().upkeep({
|
|
728
|
+
topN: typeof args?.topN === "number" ? args.topN : undefined,
|
|
729
|
+
sample: typeof args?.sample === "number" ? args.sample : undefined,
|
|
730
|
+
deep: args?.deep === true,
|
|
731
|
+
});
|
|
732
|
+
const lines = [];
|
|
733
|
+
lines.push(`# Brain upkeep (${report.totalEntries} entries, checked ${report.checkedAt})`);
|
|
734
|
+
const r = report.revalidated;
|
|
735
|
+
lines.push(`Revalidated top ${r.checked}: ${r.fresh.length} fresh, ${r.stale.length} stale, ${r.untracked.length} untracked, ${r.unverified.length} unverified.`);
|
|
736
|
+
for (const s of r.stale)
|
|
737
|
+
lines.push(` ✗ STALE ${s.id}: ${s.query} (changed: ${s.staleFiles.join(", ") || "upstream memory"}) → ${s.action}`);
|
|
738
|
+
for (const u of r.untracked)
|
|
739
|
+
lines.push(` ? UNTRACKED ${u.id}: ${u.query} → ${u.action}`);
|
|
740
|
+
for (const u of r.unverified)
|
|
741
|
+
lines.push(` ? UNVERIFIED ${u.id}: ${u.query} → ${u.action}`);
|
|
742
|
+
if (report.duplicatePairs.length > 0) {
|
|
743
|
+
lines.push(`Exact duplicates (${report.duplicatePairs.length}):`);
|
|
744
|
+
for (const d of report.duplicatePairs) {
|
|
745
|
+
lines.push(` = ${d.ids.join(" + ")} (${(d.similarity * 100).toFixed(0)}%): "${d.queries[0]}" / "${d.queries[1]}" → ${d.action}`);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
if (report.mergeCandidates.length > 0) {
|
|
749
|
+
lines.push(`Merge candidates (${report.mergeCandidates.length}):`);
|
|
750
|
+
for (const m of report.mergeCandidates.slice(0, 10)) {
|
|
751
|
+
lines.push(` ~ ${m.ids.join(" + ")} (${(m.similarity * 100).toFixed(0)}%): "${m.queries[0]}" / "${m.queries[1]}" → ${m.action}`);
|
|
752
|
+
}
|
|
753
|
+
if (report.mergeCandidates.length > 10)
|
|
754
|
+
lines.push(` ...and ${report.mergeCandidates.length - 10} more`);
|
|
755
|
+
}
|
|
756
|
+
const dw = report.deadWeight;
|
|
757
|
+
lines.push(`Dead weight: ${dw.neverHit} never reused, ${dw.downvoted.length} downvoted. ${dw.action}`);
|
|
758
|
+
lines.push(`Lifetime savings: ${report.savings.totalTokensSaved} tokens.`);
|
|
759
|
+
for (const s of report.savings.topSavers)
|
|
760
|
+
lines.push(` 💰 ${s.id}: ${s.tokensSaved} tokens — ${s.query}`);
|
|
761
|
+
if (report.deep)
|
|
762
|
+
lines.push(`Deep stale ratio: ${report.deep.staleEntries} stale (${(report.deep.staleRatio * 100).toFixed(1)}%). ${report.deep.action}`);
|
|
763
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
764
|
+
}
|
|
765
|
+
catch (e) {
|
|
766
|
+
(0, utils_1.logError)("brain_upkeep", e);
|
|
767
|
+
return { content: [{ type: "text", text: `Upkeep pass failed: ${e.message}` }] };
|
|
768
|
+
}
|
|
769
|
+
}
|
|
596
770
|
async function handleRefreshMemory(args) {
|
|
597
771
|
const id = args?.id;
|
|
598
772
|
if (!id)
|
|
@@ -646,6 +820,22 @@ async function handleBrainStats(args) {
|
|
|
646
820
|
else {
|
|
647
821
|
lines.push(`(stale ratio not computed — pass deep:true)`);
|
|
648
822
|
}
|
|
823
|
+
if ((stats.totalTokensSaved || 0) > 0) {
|
|
824
|
+
lines.push(`Lifetime savings from memory reuse: ${stats.totalTokensSaved} tokens`);
|
|
825
|
+
for (const s of stats.topSavers || []) {
|
|
826
|
+
lines.push(` 💰 ${s.id}: ${s.tokensSaved} tokens over ${s.hits} reuse(s) — ${s.query}`);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
else {
|
|
830
|
+
lines.push(`Lifetime savings from memory reuse: 0 tokens yet — reuse a fresh memory and search_memory books it here.`);
|
|
831
|
+
}
|
|
832
|
+
if (stats.integrity) {
|
|
833
|
+
const integ = stats.integrity;
|
|
834
|
+
const encNote = integ.encrypted ? ", encrypted at rest" : "";
|
|
835
|
+
lines.push(integ.ok
|
|
836
|
+
? `Integrity: OK${integ.backups ? " (backup present)" : ""}${integ.snapshots > 0 ? `, ${integ.snapshots} snapshot(s)` : ""}${encNote}`
|
|
837
|
+
: `Integrity: DEGRADED — ${integ.lastIssue?.action}: ${integ.lastIssue?.detail || "unknown cause"}${encNote}`);
|
|
838
|
+
}
|
|
649
839
|
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
650
840
|
}
|
|
651
841
|
catch (e) {
|
|
@@ -686,6 +876,18 @@ async function handleBrainImport(args) {
|
|
|
686
876
|
try {
|
|
687
877
|
const { resolved } = (0, utils_1.safeResolvePath)(process.cwd(), bundlePath);
|
|
688
878
|
const text = fs_1.default.readFileSync(resolved, "utf8");
|
|
879
|
+
if (args?.dryRun === true) {
|
|
880
|
+
const preview = (0, TheBrainV2_1.getBrain)().previewImport(text);
|
|
881
|
+
if (!preview.ok)
|
|
882
|
+
return { content: [{ type: "text", text: preview.message }] };
|
|
883
|
+
const lines = preview.items.map((i) => `- [${i.action}] ${i.id}: ${i.query || "(no query)"} (${i.reason})`);
|
|
884
|
+
if (preview.truncated)
|
|
885
|
+
lines.push(`...and ${preview.wouldImport + preview.wouldUpdate + preview.wouldSkip - preview.items.length} more`);
|
|
886
|
+
for (const c of preview.conflicts) {
|
|
887
|
+
lines.push(`⚠️ CONFLICT: bundle entry ${c.against} disagrees with live [${c.outcome}] ${c.id}: ${c.query.slice(0, 100)}`);
|
|
888
|
+
}
|
|
889
|
+
return { content: [{ type: "text", text: `${preview.message}\n${lines.join("\n")}` }] };
|
|
890
|
+
}
|
|
689
891
|
const result = (0, TheBrainV2_1.getBrain)().importBundle(text);
|
|
690
892
|
return { content: [{ type: "text", text: result.message }] };
|
|
691
893
|
}
|
|
@@ -741,5 +943,8 @@ exports.MEMORY_TOOL_HANDLERS = {
|
|
|
741
943
|
brain_stats: handleBrainStats,
|
|
742
944
|
brain_export: handleBrainExport,
|
|
743
945
|
brain_import: handleBrainImport,
|
|
946
|
+
brain_trash: handleBrainTrash,
|
|
947
|
+
brain_upkeep: handleBrainUpkeep,
|
|
948
|
+
brain_merge: handleBrainMerge,
|
|
744
949
|
};
|
|
745
950
|
//# sourceMappingURL=memory.js.map
|