@totalreclaw/mcp-server 2.6.1 → 3.0.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 +47 -7
- package/dist/claims-helper.d.ts +79 -31
- package/dist/claims-helper.d.ts.map +1 -1
- package/dist/claims-helper.js +125 -45
- package/dist/claims-helper.js.map +1 -1
- package/dist/consolidation.d.ts +10 -7
- package/dist/consolidation.d.ts.map +1 -1
- package/dist/consolidation.js +105 -32
- package/dist/consolidation.js.map +1 -1
- package/dist/index.js +177 -40
- package/dist/index.js.map +1 -1
- package/dist/prompts.d.ts +13 -13
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +111 -178
- package/dist/prompts.js.map +1 -1
- package/dist/subgraph/store.d.ts +5 -2
- package/dist/subgraph/store.d.ts.map +1 -1
- package/dist/subgraph/store.js +6 -3
- package/dist/subgraph/store.js.map +1 -1
- package/dist/tools/consolidate.js +12 -12
- package/dist/tools/consolidate.js.map +1 -1
- package/dist/tools/debrief.d.ts.map +1 -1
- package/dist/tools/debrief.js +11 -3
- package/dist/tools/debrief.js.map +1 -1
- package/dist/tools/export.d.ts.map +1 -1
- package/dist/tools/export.js +61 -12
- package/dist/tools/export.js.map +1 -1
- package/dist/tools/forget.d.ts +14 -0
- package/dist/tools/forget.d.ts.map +1 -1
- package/dist/tools/forget.js +8 -2
- package/dist/tools/forget.js.map +1 -1
- package/dist/tools/import-batch.d.ts.map +1 -1
- package/dist/tools/import-batch.js +10 -3
- package/dist/tools/import-batch.js.map +1 -1
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +15 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/pin.d.ts +8 -0
- package/dist/tools/pin.d.ts.map +1 -1
- package/dist/tools/pin.js +44 -12
- package/dist/tools/pin.js.map +1 -1
- package/dist/tools/recall.d.ts.map +1 -1
- package/dist/tools/recall.js +63 -10
- package/dist/tools/recall.js.map +1 -1
- package/dist/tools/remember.d.ts +44 -3
- package/dist/tools/remember.d.ts.map +1 -1
- package/dist/tools/remember.js +97 -10
- package/dist/tools/remember.js.map +1 -1
- package/dist/tools/retype.d.ts +119 -0
- package/dist/tools/retype.d.ts.map +1 -0
- package/dist/tools/retype.js +360 -0
- package/dist/tools/retype.js.map +1 -0
- package/dist/tools/set-scope.d.ts +57 -0
- package/dist/tools/set-scope.d.ts.map +1 -0
- package/dist/tools/set-scope.js +118 -0
- package/dist/tools/set-scope.js.map +1 -0
- package/dist/v1-types.d.ts +79 -0
- package/dist/v1-types.d.ts.map +1 -0
- package/dist/v1-types.js +104 -0
- package/dist/v1-types.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
|
|
25
25
|
End-to-end encrypted memory vault as an MCP server. Your memories are encrypted on your device before leaving -- no one can read them, not even us.
|
|
26
26
|
|
|
27
|
+
**v3.0.0 ships Memory Taxonomy v1** — 6 speech-act types + source / scope / volatility axes on every memory. Four new tools (`totalreclaw_pin`, `totalreclaw_unpin`, `totalreclaw_retype`, `totalreclaw_set_scope`) let agents override categorization via natural language. Source-weighted reranking ranks user-authored claims above assistant-regurgitated noise. See [memory types guide](../docs/guides/memory-types-guide.md).
|
|
28
|
+
|
|
27
29
|
**Requirements:** Node.js 18+
|
|
28
30
|
|
|
29
31
|
## Quick Start
|
|
@@ -117,18 +119,49 @@ The server only ever sees ciphertext and hashed tokens.
|
|
|
117
119
|
|
|
118
120
|
## Available Tools
|
|
119
121
|
|
|
122
|
+
All 19 tools are invoked by the host agent from natural language context. Tool schemas include v1 taxonomy fields (`type`, `source`, `scope`, `reasoning`).
|
|
123
|
+
|
|
120
124
|
| Tool | Description |
|
|
121
125
|
|------|-------------|
|
|
122
|
-
| `totalreclaw_remember` | Store a fact in encrypted memory |
|
|
123
|
-
| `totalreclaw_recall` | Search memories by natural language query |
|
|
126
|
+
| `totalreclaw_remember` | Store a fact in encrypted memory. Supports v1 taxonomy (`type`, `scope`, `reasoning`) + legacy types for migration |
|
|
127
|
+
| `totalreclaw_recall` | Search memories by natural language query. Source-weighted ranking (Retrieval v2 Tier 1) |
|
|
124
128
|
| `totalreclaw_forget` | Delete a specific memory by ID |
|
|
129
|
+
| `totalreclaw_pin` | Pin a memory so auto-resolution never supersedes it. Accepts `fact_id` or `memory_id` |
|
|
130
|
+
| `totalreclaw_unpin` | Remove the pin, returning the memory to active status |
|
|
131
|
+
| `totalreclaw_retype` *(new in v3.0.0)* | Change the v1 type of a memory (e.g. `preference` → `directive`) via supersession |
|
|
132
|
+
| `totalreclaw_set_scope` *(new in v3.0.0)* | Change the v1 scope of a memory (e.g. set to `work` / `personal`) |
|
|
125
133
|
| `totalreclaw_export` | Export all memories decrypted as Markdown or JSON |
|
|
126
134
|
| `totalreclaw_status` | Check billing status and quota usage |
|
|
127
135
|
| `totalreclaw_import` | Re-import previously exported memories |
|
|
128
|
-
| `totalreclaw_import_from` | Import from Mem0
|
|
136
|
+
| `totalreclaw_import_from` | Import from Mem0, MCP Memory Server, ChatGPT, Claude, or generic JSON/CSV |
|
|
137
|
+
| `totalreclaw_import_batch` | Batch import with background polling |
|
|
129
138
|
| `totalreclaw_consolidate` | Merge duplicate and related memories |
|
|
139
|
+
| `totalreclaw_debrief` | End-of-conversation summary to capture broader context |
|
|
130
140
|
| `totalreclaw_upgrade` | Get a link to upgrade to Pro |
|
|
131
141
|
| `totalreclaw_migrate` | Migrate testnet memories to mainnet after Pro upgrade |
|
|
142
|
+
| `totalreclaw_account` | View account details (wallet, tier, quota, phrase hint) |
|
|
143
|
+
| `totalreclaw_support` | Troubleshooting help + contact links |
|
|
144
|
+
| `totalreclaw_setup` | Generate or import a recovery phrase (first-run flow) |
|
|
145
|
+
|
|
146
|
+
Users invoke the new v1 tools naturally: *"pin that"*, *"that was actually a rule, not a preference"*, *"file that under work"*. Tool descriptions teach the host LLM to match utterances to tools.
|
|
147
|
+
|
|
148
|
+
### Memory Taxonomy v1 (`@totalreclaw/core 2.0`)
|
|
149
|
+
|
|
150
|
+
MCP server v3.0.0 writes v1 inner blobs (outer protobuf wrapper `version = 4`).
|
|
151
|
+
The six v1 types correspond to Searle's speech-act classes:
|
|
152
|
+
|
|
153
|
+
- **claim** — assertive ("lives in Lisbon", "chose PostgreSQL"). Absorbs legacy fact/context/decision.
|
|
154
|
+
- **preference** — expressive ("likes dark mode").
|
|
155
|
+
- **directive** — imperative ("always check d.get(errors)"). Replaces legacy `rule`.
|
|
156
|
+
- **commitment** — commissive ("will ship v2 Friday"). Replaces legacy `goal`.
|
|
157
|
+
- **episode** — narrative ("deployed v1.0 on March 15"). Replaces legacy `episodic`.
|
|
158
|
+
- **summary** — derived synthesis (debrief pipelines only).
|
|
159
|
+
|
|
160
|
+
v0 types (`fact`, `context`, `decision`, `rule`, `goal`, `episodic`) are still
|
|
161
|
+
accepted by the `remember` tool and auto-mapped to v1 equivalents. Recall
|
|
162
|
+
output includes `source` and `scope` when available.
|
|
163
|
+
|
|
164
|
+
See [`docs/specs/totalreclaw/memory-taxonomy-v1.md`](../docs/specs/totalreclaw/memory-taxonomy-v1.md).
|
|
132
165
|
|
|
133
166
|
## Environment Variables
|
|
134
167
|
|
|
@@ -137,7 +170,10 @@ The server only ever sees ciphertext and hashed tokens.
|
|
|
137
170
|
| `TOTALRECLAW_RECOVERY_PHRASE` | 12-word BIP-39 recovery phrase | Required |
|
|
138
171
|
| `TOTALRECLAW_SERVER_URL` | TotalReclaw server URL (only needed for self-hosted) | `https://api.totalreclaw.xyz` |
|
|
139
172
|
| `TOTALRECLAW_SELF_HOSTED` | Use a self-hosted server instead of the managed service | `false` |
|
|
140
|
-
| `
|
|
173
|
+
| `TOTALRECLAW_CREDENTIALS_PATH` | Override credentials file location | `~/.totalreclaw/credentials.json` |
|
|
174
|
+
| `TOTALRECLAW_CACHE_PATH` | Override encrypted cache file location | `~/.totalreclaw/cache.enc` |
|
|
175
|
+
|
|
176
|
+
> **v1 env cleanup:** `TOTALRECLAW_CHAIN_ID`, `TOTALRECLAW_EMBEDDING_MODEL`, `TOTALRECLAW_STORE_DEDUP`, `TOTALRECLAW_LLM_MODEL`, `TOTALRECLAW_SESSION_ID`, `TOTALRECLAW_TAXONOMY_VERSION`, `TOTALRECLAW_CLAIM_FORMAT`, and `TOTALRECLAW_DIGEST_MODE` were removed. Chain is auto-detected from billing tier (free = Base Sepolia, Pro = Gnosis). The MCP server silently ignores these vars for a transition period. See the [env vars reference](../docs/guides/env-vars-reference.md).
|
|
141
177
|
|
|
142
178
|
## Free Tier & Pricing
|
|
143
179
|
|
|
@@ -158,10 +194,14 @@ npm run lint # Lint
|
|
|
158
194
|
|
|
159
195
|
## Learn More
|
|
160
196
|
|
|
161
|
-
- [
|
|
162
|
-
- [
|
|
197
|
+
- [Client setup guide (v1)](../docs/guides/client-setup-v1.md) — one install command per client
|
|
198
|
+
- [Memory types guide](../docs/guides/memory-types-guide.md) — what gets stored and natural-language overrides
|
|
199
|
+
- [v1 migration guide](../docs/guides/v1-migration.md) — upgrading from v0
|
|
200
|
+
- [Environment variables](../docs/guides/env-vars-reference.md) — the 5 env vars that matter
|
|
201
|
+
- [Feature comparison](../docs/guides/feature-comparison.md) — what works on each client
|
|
202
|
+
- [IronClaw setup guide](../docs/guides/ironclaw-setup.md) — full walkthrough for IronClaw (NEAR AI) agents
|
|
163
203
|
- [totalreclaw.xyz](https://totalreclaw.xyz)
|
|
164
|
-
- [Main
|
|
204
|
+
- [Main repository](https://github.com/p-diogo/totalreclaw)
|
|
165
205
|
|
|
166
206
|
## License
|
|
167
207
|
|
package/dist/claims-helper.d.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* - No dependency on a plugin-local `ExtractedFact` type — MCP accepts
|
|
14
14
|
* raw tool arguments, so the builder takes a small `ClaimInput` struct.
|
|
15
15
|
*/
|
|
16
|
+
import type { MemoryTypeV1, MemorySource, MemoryScope, MemoryVolatility, MemoryEntityV1 } from './v1-types.js';
|
|
16
17
|
import type { MemoryType } from './memory-types.js';
|
|
17
18
|
/**
|
|
18
19
|
* Legacy alias for `MemoryType`, preserved so existing code that imports
|
|
@@ -38,16 +39,6 @@ export interface ClaimInput {
|
|
|
38
39
|
/** Optional structured entities that surface on search. */
|
|
39
40
|
entities?: ExtractedEntity[];
|
|
40
41
|
}
|
|
41
|
-
export type ClaimFormat = 'claim' | 'legacy';
|
|
42
|
-
/**
|
|
43
|
-
* Resolve the claim-format mode from the TOTALRECLAW_CLAIM_FORMAT env var.
|
|
44
|
-
*
|
|
45
|
-
* - `claim` (default, or unset): new canonical Claim blob, entity trapdoors added.
|
|
46
|
-
* - `legacy`: old {text, metadata} doc shape; entity trapdoors still added.
|
|
47
|
-
*
|
|
48
|
-
* Read on every call so tests can toggle via env without module reload.
|
|
49
|
-
*/
|
|
50
|
-
export declare function resolveClaimFormat(): ClaimFormat;
|
|
51
42
|
import { mapTypeToCategory } from './memory-types.js';
|
|
52
43
|
export { mapTypeToCategory };
|
|
53
44
|
export interface BuildClaimInput {
|
|
@@ -67,19 +58,6 @@ export interface BuildClaimInput {
|
|
|
67
58
|
* etc.). Encrypt this string directly — do not re-stringify it.
|
|
68
59
|
*/
|
|
69
60
|
export declare function buildCanonicalClaim(input: BuildClaimInput): string;
|
|
70
|
-
export interface BuildLegacyDocInput {
|
|
71
|
-
fact: ClaimInput;
|
|
72
|
-
importance: number;
|
|
73
|
-
source: string;
|
|
74
|
-
createdAt?: string;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Build the legacy `{text, metadata}` document shape.
|
|
78
|
-
*
|
|
79
|
-
* Kept so the TOTALRECLAW_CLAIM_FORMAT=legacy fallback writes blobs that
|
|
80
|
-
* the existing parseClaimOrLegacy read path has always handled.
|
|
81
|
-
*/
|
|
82
|
-
export declare function buildLegacyDoc(input: BuildLegacyDocInput): string;
|
|
83
61
|
/**
|
|
84
62
|
* Well-known blind index marker used to locate digest claims on the subgraph.
|
|
85
63
|
* Computed as plain SHA-256("type:digest") — same primitive as word trapdoors
|
|
@@ -93,16 +71,14 @@ export declare const DIGEST_CATEGORY = "dig";
|
|
|
93
71
|
export declare const DIGEST_SOURCE_AGENT = "mcp-server-digest";
|
|
94
72
|
export type DigestMode = 'on' | 'off' | 'template';
|
|
95
73
|
/**
|
|
96
|
-
*
|
|
74
|
+
* Digest injection is always ON in v1. TOTALRECLAW_DIGEST_MODE was removed
|
|
75
|
+
* from the user-facing env var surface — the G-pipeline ships a digest on
|
|
76
|
+
* every recall with a template fallback.
|
|
97
77
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* - `off`: legacy individual-fact search path, no digest injection.
|
|
101
|
-
* - `template`: same as `on` for MCP (MCP never compiles digests — the flag
|
|
102
|
-
* is accepted for parity with the plugin so operators can use the same env
|
|
103
|
-
* var across clients).
|
|
78
|
+
* Kept as a function returning `'on'` so any legacy call-site continues to
|
|
79
|
+
* compile.
|
|
104
80
|
*
|
|
105
|
-
*
|
|
81
|
+
* @deprecated v1 always returns `'on'`.
|
|
106
82
|
*/
|
|
107
83
|
export declare function resolveDigestMode(): DigestMode;
|
|
108
84
|
export interface BlobReadResult {
|
|
@@ -157,4 +133,76 @@ export declare function computeEntityTrapdoor(name: string): string;
|
|
|
157
133
|
* Returns an empty array when the fact has no entities.
|
|
158
134
|
*/
|
|
159
135
|
export declare function computeEntityTrapdoors(entities: readonly ExtractedEntity[] | undefined): string[];
|
|
136
|
+
/**
|
|
137
|
+
* Input shape for building a Memory Taxonomy v1 blob. All fields mirror the
|
|
138
|
+
* MemoryClaimV1 schema; the builder fills in required timestamps/UUIDs so
|
|
139
|
+
* callers can pass the subset they know about.
|
|
140
|
+
*/
|
|
141
|
+
export interface BuildV1ClaimInput {
|
|
142
|
+
text: string;
|
|
143
|
+
type: MemoryTypeV1;
|
|
144
|
+
source: MemorySource;
|
|
145
|
+
id?: string;
|
|
146
|
+
createdAt?: string;
|
|
147
|
+
scope?: MemoryScope;
|
|
148
|
+
volatility?: MemoryVolatility;
|
|
149
|
+
reasoning?: string;
|
|
150
|
+
entities?: MemoryEntityV1[];
|
|
151
|
+
expiresAt?: string;
|
|
152
|
+
importance?: number;
|
|
153
|
+
confidence?: number;
|
|
154
|
+
supersededBy?: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Construct a v1 canonical claim JSON string, validated through the core
|
|
158
|
+
* `validateMemoryClaimV1` WASM export. The output is UTF-8 JSON ready to be
|
|
159
|
+
* encrypted as the inner blob of a protobuf-v4 fact (wrapper `version = 4`).
|
|
160
|
+
*
|
|
161
|
+
* Returns the canonical JSON (not the parsed object) so callers can encrypt
|
|
162
|
+
* it directly without risking non-deterministic key ordering.
|
|
163
|
+
*
|
|
164
|
+
* Throws if the input is malformed (missing required field, invalid enum
|
|
165
|
+
* value). The MCP tool handlers narrow with `isValidMemoryTypeV1` etc. before
|
|
166
|
+
* calling in, so this should be unreachable from the tool schema path.
|
|
167
|
+
*/
|
|
168
|
+
export declare function buildV1ClaimBlob(input: BuildV1ClaimInput): string;
|
|
169
|
+
/**
|
|
170
|
+
* Per-blob read result surfaced through the legacy-friendly reader. Extends
|
|
171
|
+
* `BlobReadResult` with v1-specific fields when present.
|
|
172
|
+
*/
|
|
173
|
+
export interface V1BlobReadResult {
|
|
174
|
+
/** The decrypted text payload. */
|
|
175
|
+
text: string;
|
|
176
|
+
/** 1-10 normalized importance. Defaults to 5. */
|
|
177
|
+
importance: number;
|
|
178
|
+
/**
|
|
179
|
+
* Category short-key for back-compat reporting (e.g. `pref`, `rule`). For v1
|
|
180
|
+
* blobs this is derived from the v1 `type` via V1_TYPE_TO_SHORT_CATEGORY.
|
|
181
|
+
*/
|
|
182
|
+
category: string;
|
|
183
|
+
/** Raw v1 metadata when the blob is a MemoryClaimV1. */
|
|
184
|
+
v1?: {
|
|
185
|
+
type: MemoryTypeV1;
|
|
186
|
+
source: MemorySource;
|
|
187
|
+
scope?: MemoryScope;
|
|
188
|
+
volatility?: MemoryVolatility;
|
|
189
|
+
reasoning?: string;
|
|
190
|
+
expires_at?: string;
|
|
191
|
+
confidence?: number;
|
|
192
|
+
superseded_by?: string;
|
|
193
|
+
entities?: MemoryEntityV1[];
|
|
194
|
+
created_at: string;
|
|
195
|
+
};
|
|
196
|
+
/** Whatever metadata the blob carried (v0 or v1). Used by callers that want raw access. */
|
|
197
|
+
metadata: Record<string, unknown>;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Parse a decrypted blob into a uniform structure supporting v1, canonical v0
|
|
201
|
+
* (`{t, c, i, ...}`), and legacy plugin (`{text, metadata: {...}}`).
|
|
202
|
+
*
|
|
203
|
+
* The v0 reader at `readClaimFromBlob` is retained as a separate function so
|
|
204
|
+
* the pin-chain logic in `pin.ts` (which mutates short-key claims) keeps its
|
|
205
|
+
* exact behaviour. Callers that need the full v1 surface should use this one.
|
|
206
|
+
*/
|
|
207
|
+
export declare function readBlobUnified(decryptedJson: string): V1BlobReadResult;
|
|
160
208
|
//# sourceMappingURL=claims-helper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claims-helper.d.ts","sourceRoot":"","sources":["../src/claims-helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"claims-helper.d.ts","sourceRoot":"","sources":["../src/claims-helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,cAAc,EAEf,MAAM,eAAe,CAAC;AAqBvB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC;AAElC,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAEzF,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AgB;IAC/B,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,EAAE,CAAC,EAAE;QACH,IAAI,EAAE,YAAY,CAAC;QACnB,MAAM,EAAE,YAAY,CAAC;QACrB,KAAK,CAAC,EAAE,WAAW,CAAC;QACpB,UAAU,CAAC,EAAE,gBAAgB,CAAC;QAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;QAC5B,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,2FAA2F;IAC3F,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,gBAAgB,CA2EvE"}
|
package/dist/claims-helper.js
CHANGED
|
@@ -19,9 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.DIGEST_SOURCE_AGENT = exports.DIGEST_CATEGORY = exports.DIGEST_TRAPDOOR = exports.mapTypeToCategory = void 0;
|
|
22
|
-
exports.resolveClaimFormat = resolveClaimFormat;
|
|
23
22
|
exports.buildCanonicalClaim = buildCanonicalClaim;
|
|
24
|
-
exports.buildLegacyDoc = buildLegacyDoc;
|
|
25
23
|
exports.resolveDigestMode = resolveDigestMode;
|
|
26
24
|
exports.readClaimFromBlob = readClaimFromBlob;
|
|
27
25
|
exports.buildDigestClaim = buildDigestClaim;
|
|
@@ -29,7 +27,10 @@ exports.extractDigestFromClaim = extractDigestFromClaim;
|
|
|
29
27
|
exports.isDigestBlob = isDigestBlob;
|
|
30
28
|
exports.computeEntityTrapdoor = computeEntityTrapdoor;
|
|
31
29
|
exports.computeEntityTrapdoors = computeEntityTrapdoors;
|
|
30
|
+
exports.buildV1ClaimBlob = buildV1ClaimBlob;
|
|
31
|
+
exports.readBlobUnified = readBlobUnified;
|
|
32
32
|
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
33
|
+
const v1_types_js_1 = require("./v1-types.js");
|
|
33
34
|
// The core WASM package ships as CJS. Jest (ts-jest) compiles MCP sources to
|
|
34
35
|
// commonjs so a plain `require` works there; TSC with `NodeNext` rewrites
|
|
35
36
|
// this to a dynamic import in ESM. Lazy-init so tests can spin up without
|
|
@@ -43,18 +44,6 @@ function getWasm() {
|
|
|
43
44
|
}
|
|
44
45
|
return _wasm;
|
|
45
46
|
}
|
|
46
|
-
/**
|
|
47
|
-
* Resolve the claim-format mode from the TOTALRECLAW_CLAIM_FORMAT env var.
|
|
48
|
-
*
|
|
49
|
-
* - `claim` (default, or unset): new canonical Claim blob, entity trapdoors added.
|
|
50
|
-
* - `legacy`: old {text, metadata} doc shape; entity trapdoors still added.
|
|
51
|
-
*
|
|
52
|
-
* Read on every call so tests can toggle via env without module reload.
|
|
53
|
-
*/
|
|
54
|
-
function resolveClaimFormat() {
|
|
55
|
-
const raw = (process.env.TOTALRECLAW_CLAIM_FORMAT ?? '').trim().toLowerCase();
|
|
56
|
-
return raw === 'legacy' ? 'legacy' : 'claim';
|
|
57
|
-
}
|
|
58
47
|
// ---------------------------------------------------------------------------
|
|
59
48
|
// Category mapping — lives in memory-types.ts now (single source of truth for
|
|
60
49
|
// the MCP package). Phase 2.2.6 eliminated the duplicate that used to be
|
|
@@ -89,24 +78,6 @@ function buildCanonicalClaim(input) {
|
|
|
89
78
|
}
|
|
90
79
|
return getWasm().canonicalizeClaim(JSON.stringify(claim));
|
|
91
80
|
}
|
|
92
|
-
/**
|
|
93
|
-
* Build the legacy `{text, metadata}` document shape.
|
|
94
|
-
*
|
|
95
|
-
* Kept so the TOTALRECLAW_CLAIM_FORMAT=legacy fallback writes blobs that
|
|
96
|
-
* the existing parseClaimOrLegacy read path has always handled.
|
|
97
|
-
*/
|
|
98
|
-
function buildLegacyDoc(input) {
|
|
99
|
-
const { fact, importance, source, createdAt } = input;
|
|
100
|
-
return JSON.stringify({
|
|
101
|
-
text: fact.text,
|
|
102
|
-
metadata: {
|
|
103
|
-
type: fact.type ?? 'fact',
|
|
104
|
-
importance: importance / 10,
|
|
105
|
-
source,
|
|
106
|
-
created_at: createdAt ?? new Date().toISOString(),
|
|
107
|
-
},
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
81
|
// ---------------------------------------------------------------------------
|
|
111
82
|
// Digest helpers (read-only in MCP scope)
|
|
112
83
|
// ---------------------------------------------------------------------------
|
|
@@ -125,23 +96,16 @@ exports.DIGEST_CATEGORY = 'dig';
|
|
|
125
96
|
/** Distinctive source marker so operators can grep for digest writes. */
|
|
126
97
|
exports.DIGEST_SOURCE_AGENT = 'mcp-server-digest';
|
|
127
98
|
/**
|
|
128
|
-
*
|
|
99
|
+
* Digest injection is always ON in v1. TOTALRECLAW_DIGEST_MODE was removed
|
|
100
|
+
* from the user-facing env var surface — the G-pipeline ships a digest on
|
|
101
|
+
* every recall with a template fallback.
|
|
129
102
|
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* - `off`: legacy individual-fact search path, no digest injection.
|
|
133
|
-
* - `template`: same as `on` for MCP (MCP never compiles digests — the flag
|
|
134
|
-
* is accepted for parity with the plugin so operators can use the same env
|
|
135
|
-
* var across clients).
|
|
103
|
+
* Kept as a function returning `'on'` so any legacy call-site continues to
|
|
104
|
+
* compile.
|
|
136
105
|
*
|
|
137
|
-
*
|
|
106
|
+
* @deprecated v1 always returns `'on'`.
|
|
138
107
|
*/
|
|
139
108
|
function resolveDigestMode() {
|
|
140
|
-
const raw = (process.env.TOTALRECLAW_DIGEST_MODE ?? '').trim().toLowerCase();
|
|
141
|
-
if (raw === 'off')
|
|
142
|
-
return 'off';
|
|
143
|
-
if (raw === 'template')
|
|
144
|
-
return 'template';
|
|
145
109
|
return 'on';
|
|
146
110
|
}
|
|
147
111
|
function readClaimFromBlob(decryptedJson) {
|
|
@@ -284,4 +248,120 @@ function computeEntityTrapdoors(entities) {
|
|
|
284
248
|
}
|
|
285
249
|
return out;
|
|
286
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* Construct a v1 canonical claim JSON string, validated through the core
|
|
253
|
+
* `validateMemoryClaimV1` WASM export. The output is UTF-8 JSON ready to be
|
|
254
|
+
* encrypted as the inner blob of a protobuf-v4 fact (wrapper `version = 4`).
|
|
255
|
+
*
|
|
256
|
+
* Returns the canonical JSON (not the parsed object) so callers can encrypt
|
|
257
|
+
* it directly without risking non-deterministic key ordering.
|
|
258
|
+
*
|
|
259
|
+
* Throws if the input is malformed (missing required field, invalid enum
|
|
260
|
+
* value). The MCP tool handlers narrow with `isValidMemoryTypeV1` etc. before
|
|
261
|
+
* calling in, so this should be unreachable from the tool schema path.
|
|
262
|
+
*/
|
|
263
|
+
function buildV1ClaimBlob(input) {
|
|
264
|
+
const claim = {
|
|
265
|
+
id: input.id ?? node_crypto_1.default.randomUUID(),
|
|
266
|
+
text: input.text,
|
|
267
|
+
type: input.type,
|
|
268
|
+
source: input.source,
|
|
269
|
+
created_at: input.createdAt ?? new Date().toISOString(),
|
|
270
|
+
schema_version: v1_types_js_1.MEMORY_CLAIM_V1_SCHEMA_VERSION,
|
|
271
|
+
};
|
|
272
|
+
if (input.scope && input.scope !== 'unspecified')
|
|
273
|
+
claim.scope = input.scope;
|
|
274
|
+
if (input.volatility && input.volatility !== 'updatable')
|
|
275
|
+
claim.volatility = input.volatility;
|
|
276
|
+
if (input.entities && input.entities.length > 0)
|
|
277
|
+
claim.entities = input.entities;
|
|
278
|
+
if (input.reasoning)
|
|
279
|
+
claim.reasoning = input.reasoning;
|
|
280
|
+
if (input.expiresAt)
|
|
281
|
+
claim.expires_at = input.expiresAt;
|
|
282
|
+
if (typeof input.importance === 'number')
|
|
283
|
+
claim.importance = input.importance;
|
|
284
|
+
if (typeof input.confidence === 'number')
|
|
285
|
+
claim.confidence = input.confidence;
|
|
286
|
+
if (input.supersededBy)
|
|
287
|
+
claim.superseded_by = input.supersededBy;
|
|
288
|
+
// Canonicalise + validate via core. Throws on any schema violation.
|
|
289
|
+
return getWasm().validateMemoryClaimV1(JSON.stringify(claim));
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Parse a decrypted blob into a uniform structure supporting v1, canonical v0
|
|
293
|
+
* (`{t, c, i, ...}`), and legacy plugin (`{text, metadata: {...}}`).
|
|
294
|
+
*
|
|
295
|
+
* The v0 reader at `readClaimFromBlob` is retained as a separate function so
|
|
296
|
+
* the pin-chain logic in `pin.ts` (which mutates short-key claims) keeps its
|
|
297
|
+
* exact behaviour. Callers that need the full v1 surface should use this one.
|
|
298
|
+
*/
|
|
299
|
+
function readBlobUnified(decryptedJson) {
|
|
300
|
+
try {
|
|
301
|
+
const obj = JSON.parse(decryptedJson);
|
|
302
|
+
// v1 path: presence of top-level `text` + `type` (closed 6-value enum)
|
|
303
|
+
// is the v1 signature. `schema_version` is omitted when it equals the
|
|
304
|
+
// default (per skip_serializing_if in the Rust struct), so we can't
|
|
305
|
+
// require it — any v1 enum value distinguishes v1 from legacy.
|
|
306
|
+
const v1Types = new Set([
|
|
307
|
+
'claim',
|
|
308
|
+
'preference',
|
|
309
|
+
'directive',
|
|
310
|
+
'commitment',
|
|
311
|
+
'episode',
|
|
312
|
+
'summary',
|
|
313
|
+
]);
|
|
314
|
+
if (typeof obj.text === 'string' &&
|
|
315
|
+
typeof obj.type === 'string' &&
|
|
316
|
+
v1Types.has(String(obj.type)) &&
|
|
317
|
+
// Optional `schema_version`: when present must be the v1 constant.
|
|
318
|
+
(typeof obj.schema_version !== 'string' ||
|
|
319
|
+
obj.schema_version === v1_types_js_1.MEMORY_CLAIM_V1_SCHEMA_VERSION)) {
|
|
320
|
+
const importance = typeof obj.importance === 'number' ? Math.max(1, Math.min(10, Math.round(obj.importance))) : 5;
|
|
321
|
+
const typeStr = String(obj.type);
|
|
322
|
+
const sourceStr = typeof obj.source === 'string' ? obj.source : 'user-inferred';
|
|
323
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
324
|
+
const wasm = require('@totalreclaw/core');
|
|
325
|
+
// `parseMemoryTypeV1` returns the enum string unwrapped (e.g. "directive"),
|
|
326
|
+
// not JSON — do not JSON.parse the return value.
|
|
327
|
+
const v1Type = wasm.parseMemoryTypeV1(typeStr);
|
|
328
|
+
const v1Source = wasm.parseMemorySource(sourceStr);
|
|
329
|
+
// Map v1 type to legacy short-key for recall display. Inline import to
|
|
330
|
+
// avoid a circular dep between v1-types and claims-helper.
|
|
331
|
+
const shortMap = {
|
|
332
|
+
claim: 'claim',
|
|
333
|
+
preference: 'pref',
|
|
334
|
+
directive: 'rule',
|
|
335
|
+
commitment: 'goal',
|
|
336
|
+
episode: 'epi',
|
|
337
|
+
summary: 'sum',
|
|
338
|
+
};
|
|
339
|
+
const short = shortMap[v1Type] ?? 'claim';
|
|
340
|
+
return {
|
|
341
|
+
text: obj.text,
|
|
342
|
+
importance,
|
|
343
|
+
category: short,
|
|
344
|
+
v1: {
|
|
345
|
+
type: v1Type,
|
|
346
|
+
source: v1Source,
|
|
347
|
+
scope: typeof obj.scope === 'string' ? obj.scope : undefined,
|
|
348
|
+
volatility: typeof obj.volatility === 'string' ? obj.volatility : undefined,
|
|
349
|
+
reasoning: typeof obj.reasoning === 'string' ? obj.reasoning : undefined,
|
|
350
|
+
expires_at: typeof obj.expires_at === 'string' ? obj.expires_at : undefined,
|
|
351
|
+
confidence: typeof obj.confidence === 'number' ? obj.confidence : undefined,
|
|
352
|
+
superseded_by: typeof obj.superseded_by === 'string' ? obj.superseded_by : undefined,
|
|
353
|
+
entities: Array.isArray(obj.entities) ? obj.entities : undefined,
|
|
354
|
+
created_at: typeof obj.created_at === 'string' ? obj.created_at : '',
|
|
355
|
+
},
|
|
356
|
+
metadata: obj,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
catch {
|
|
361
|
+
// fall through to v0 / legacy parser
|
|
362
|
+
}
|
|
363
|
+
// Fall back to the legacy parser for v0 canonical + plugin-legacy shapes.
|
|
364
|
+
// This preserves the older category mapping (`fact`, `pref`, etc.).
|
|
365
|
+
return readClaimFromBlob(decryptedJson);
|
|
366
|
+
}
|
|
287
367
|
//# sourceMappingURL=claims-helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claims-helper.js","sourceRoot":"","sources":["../src/claims-helper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;
|
|
1
|
+
{"version":3,"file":"claims-helper.js","sourceRoot":"","sources":["../src/claims-helper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;AA6FH,kDAqBC;AAmCD,8CAEC;AAeD,8CAmCC;AAcD,4CAWC;AAOD,wDAgBC;AASD,oCAOC;AAoBD,sDAMC;AAMD,wDAcC;AAuCD,4CAqBC;AAyCD,0CA2EC;AAreD,8DAAiC;AASjC,+CAA+D;AAE/D,6EAA6E;AAC7E,0EAA0E;AAC1E,0EAA0E;AAC1E,mCAAmC;AACnC,8DAA8D;AAC9D,IAAI,KAAK,GAA8C,IAAI,CAAC;AAC5D,SAAS,OAAO;IACd,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,8DAA8D;QAC9D,KAAK,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,KAAM,CAAC;AAChB,CAAC;AAoCD,8EAA8E;AAC9E,8EAA8E;AAC9E,yEAAyE;AACzE,wBAAwB;AACxB,8EAA8E;AAE9E,uDAAsD;AAG7C,kGAHA,mCAAiB,OAGA;AAgB1B;;;;;;GAMG;AACH,SAAgB,mBAAmB,CA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,CAAE,GAAG,CAAC,UAA+B,CAAC,CAAC,CAAC,SAAS;oBACvF,SAAS,EAAE,OAAO,GAAG,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;oBACxE,UAAU,EAAE,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;oBAC3E,UAAU,EAAE,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;oBAC3E,aAAa,EACX,OAAO,GAAG,CAAC,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;oBACvE,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,QAA6B,CAAC,CAAC,CAAC,SAAS;oBACtF,UAAU,EAAE,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;iBACrE;gBACD,QAAQ,EAAE,GAA8B;aACzC,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,qCAAqC;IACvC,CAAC;IAED,0EAA0E;IAC1E,oEAAoE;IACpE,OAAO,iBAAiB,CAAC,aAAa,CAAC,CAAC;AAC1C,CAAC"}
|
package/dist/consolidation.d.ts
CHANGED
|
@@ -11,11 +11,13 @@
|
|
|
11
11
|
* 3. Bulk consolidation — cluster all facts in the vault and identify
|
|
12
12
|
* groups of near-duplicates for cleanup (clusterFacts).
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Delegates core computation to `@totalreclaw/core` Rust WASM module where
|
|
15
|
+
* bindings are available. `shouldSupersede` uses the core directly.
|
|
16
|
+
* `findNearDuplicate` and `clusterFacts` use the core's `findBestNearDuplicate`
|
|
17
|
+
* and `clusterFacts` WASM functions when available, falling back to local
|
|
18
|
+
* implementations that use WASM-backed `cosineSimilarity`.
|
|
17
19
|
*
|
|
18
|
-
*
|
|
20
|
+
* Threshold helpers remain local (they read process.env).
|
|
19
21
|
*/
|
|
20
22
|
/**
|
|
21
23
|
* Get the cosine similarity threshold for store-time dedup.
|
|
@@ -82,9 +84,10 @@ export declare function shouldSupersede(newImportance: number, existingFact: Dec
|
|
|
82
84
|
/**
|
|
83
85
|
* Cluster facts by semantic similarity using greedy single-pass clustering.
|
|
84
86
|
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
87
|
+
* Delegates to `@totalreclaw/core` WASM `clusterFacts` which performs the
|
|
88
|
+
* same greedy single-pass algorithm and representative selection. The WASM
|
|
89
|
+
* function returns ID-only clusters; this wrapper maps IDs back to full
|
|
90
|
+
* `DecryptedCandidate` objects for callers.
|
|
88
91
|
*
|
|
89
92
|
* Only returns clusters that have duplicates (i.e. more than one member).
|
|
90
93
|
* Facts without embeddings are not clustered.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consolidation.d.ts","sourceRoot":"","sources":["../src/consolidation.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"consolidation.d.ts","sourceRoot":"","sources":["../src/consolidation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAqBH;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAO/C;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAOlD;AAED,qEAAqE;AACrE,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAM9C,4EAA4E;AAC5E,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EA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