@totalreclaw/core 2.7.0 → 2.8.0-rc.2

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 CHANGED
@@ -13,7 +13,6 @@ Probably not directly. If you want encrypted memory for an AI agent, install the
13
13
  | OpenClaw | [`@totalreclaw/totalreclaw`](https://www.npmjs.com/package/@totalreclaw/totalreclaw) | [OpenClaw setup](https://github.com/graphprotocol/totalreclaw/blob/main/docs/guides/openclaw-setup.md) |
14
14
  | Claude Code, Claude Desktop, Cursor, other MCP hosts | [`@totalreclaw/mcp-server`](https://www.npmjs.com/package/@totalreclaw/mcp-server) | [Claude Code setup](https://github.com/graphprotocol/totalreclaw/blob/main/docs/guides/claude-code-setup.md) |
15
15
  | Hermes | [`totalreclaw`](https://pypi.org/project/totalreclaw/) on PyPI | [Hermes setup](https://github.com/graphprotocol/totalreclaw/blob/main/docs/guides/hermes-setup.md) |
16
- | NanoClaw | [`@totalreclaw/skill-nanoclaw`](https://www.npmjs.com/package/@totalreclaw/skill-nanoclaw) | [NanoClaw guide](https://github.com/graphprotocol/totalreclaw/blob/main/docs/guides/nanoclaw-getting-started.md) |
17
16
 
18
17
  Install `@totalreclaw/core` yourself only if you are building a TotalReclaw client or tool and need the same primitives.
19
18
 
@@ -16,6 +16,32 @@ export function DECISION_LOG_MAX_LINES(): number;
16
16
  */
17
17
  export function TIE_ZONE_SCORE_TOLERANCE(): number;
18
18
 
19
+ /**
20
+ * Keyed blind-tag generator (index scheme 1). Construct from the vault's
21
+ * `encryptionKey`; `indexKey` is derived inside core and never exposed (no
22
+ * key getter, no string conversion).
23
+ */
24
+ export class WasmBlindIndexer {
25
+ free(): void;
26
+ [Symbol.dispose](): void;
27
+ /**
28
+ * Tag of the digest-fact marker.
29
+ */
30
+ digestMarkerTag(): string;
31
+ /**
32
+ * Tag of an entity name (normalised in core).
33
+ */
34
+ entityTag(name: string): string;
35
+ /**
36
+ * `encryption_key_hex`: 64-char hex string (32 bytes).
37
+ */
38
+ constructor(encryption_key_hex: string);
39
+ /**
40
+ * Stem tags of a text, sorted and deduplicated. JSON array of hex strings.
41
+ */
42
+ stemTags(text: string): any;
43
+ }
44
+
19
45
  /**
20
46
  * Random Hyperplane LSH hasher (WASM wrapper).
21
47
  *
@@ -32,6 +58,13 @@ export class WasmLshHasher {
32
58
  * Returns a JSON array of hex strings (one per table).
33
59
  */
34
60
  hash(embedding: Float64Array): any;
61
+ /**
62
+ * Hash an embedding vector to KEYED bucket tags (index scheme 1).
63
+ *
64
+ * Returns a JSON array of hex strings (one per table). `lshBucketKey` is
65
+ * derived from the seed inside core and never exposed.
66
+ */
67
+ hashKeyed(embedding: Float64Array): any;
35
68
  /**
36
69
  * Create a new LSH hasher with default parameters (20 tables, 32 bits).
37
70
  *
@@ -225,6 +258,17 @@ export function computeContentFingerprint(text: string, dedup_key_hex: string):
225
258
  */
226
259
  export function computeScoreComponents(claim_json: string, now_unix_seconds: bigint, weights_json: string): string;
227
260
 
261
+ /**
262
+ * State of one fact: `"active"`, `"inactive"` or `"missing"`. `"missing"` is
263
+ * not a confirmed delete. Throws on an unreadable response or a bad id/owner.
264
+ */
265
+ export function confirmLookupParse(owner: string, id: string, response_json: string): string;
266
+
267
+ /**
268
+ * GraphQL query (`$ids` = `lookupIds`, `$owner`) for `confirmLookupParse`.
269
+ */
270
+ export function confirmLookupQuery(): string;
271
+
228
272
  /**
229
273
  * Cosine similarity between two f32 vectors.
230
274
  */
@@ -402,6 +446,13 @@ export function encodeEmbeddingCanonical(embedding: Float32Array): string;
402
446
  */
403
447
  export function encodeFactProtobuf(json: string): Uint8Array;
404
448
 
449
+ /**
450
+ * Encode a scheme-1 fact: field 5 sorted and deduplicated, field 14 `index_scheme = 1`,
451
+ * outer version always 4 (any `version` in the JSON is ignored). Same JSON as
452
+ * `encodeFactProtobuf`; throws unless every `blind_indices` entry is 64 lowercase hex.
453
+ */
454
+ export function encodeFactProtobufKeyed(json: string): Uint8Array;
455
+
405
456
  /**
406
457
  * Encode a single fact submission as SimpleAccount.execute() calldata.
407
458
  *
@@ -429,6 +480,11 @@ export function encodeSingleCallTo(protobuf_payload: Uint8Array, data_edge_addre
429
480
  */
430
481
  export function encodeTombstoneProtobuf(fact_id: string, owner: string, version?: number | null): Uint8Array;
431
482
 
483
+ /**
484
+ * Encode a scheme-1 tombstone: outer version 4 plus field 14 `index_scheme = 1`.
485
+ */
486
+ export function encodeTombstoneProtobufKeyed(fact_id: string, owner: string): Uint8Array;
487
+
432
488
  /**
433
489
  * Encrypt a UTF-8 plaintext with XChaCha20-Poly1305.
434
490
  *
@@ -542,6 +598,12 @@ export function generateBlindIndices(text: string): any;
542
598
  */
543
599
  export function generateContentFingerprint(plaintext: string, dedup_key_hex: string): string;
544
600
 
601
+ /**
602
+ * Content fingerprint v2 (index scheme 1): HMAC under `fpKeyV2`, which core
603
+ * derives from `dedupKey`. Not interchangeable with `generateContentFingerprint`.
604
+ */
605
+ export function generateContentFingerprintV2(plaintext: string, dedup_key_hex: string): string;
606
+
545
607
  /**
546
608
  * Generate trapdoors for multiple query reformulations (expansion pipeline).
547
609
  *
@@ -564,6 +626,13 @@ export function generateExpansionTrapdoors(queries_json: string, embeddings_json
564
626
  */
565
627
  export function generateSearchTrapdoors(query: string, query_embedding: Float32Array, lsh_hasher: WasmLshHasher): any;
566
628
 
629
+ /**
630
+ * Keyed search trapdoors (index scheme 1): stem tags + one entity tag per name +
631
+ * keyed LSH tags, sorted and deduplicated. `entity_names`: JSON array of strings.
632
+ * Returns a JsValue (JSON array of hex strings); final, batch as is.
633
+ */
634
+ export function generateSearchTrapdoorsKeyed(query: string, entity_names: any, query_embedding: Float32Array, indexer: WasmBlindIndexer, lsh_hasher: WasmLshHasher): any;
635
+
567
636
  /**
568
637
  * Get the GraphQL query string for broadened (fallback) search.
569
638
  */
@@ -734,12 +803,31 @@ export function isPinnedClaimJson(claim_json: string): boolean;
734
803
  */
735
804
  export function isValidMemoryType(value: string): boolean;
736
805
 
806
+ /**
807
+ * The same-fact judge prompt for one pair: JSON `{system, user}`. Line
808
+ * breaks in either text are collapsed to spaces.
809
+ */
810
+ export function judgePrompt(existing: string, candidate: string): string;
811
+
737
812
  /**
738
813
  * Return the v1 legacy-claim fallback weight (applied to candidates that
739
814
  * have no `source` field).
740
815
  */
741
816
  export function legacyClaimFallbackWeight(): number;
742
817
 
818
+ /**
819
+ * On-chain `decayScore` for every LIVE fact (always `1.0`; #789).
820
+ *
821
+ * `0` = tombstone, `1.0` = live; carries no importance. Never use for tombstones.
822
+ */
823
+ export function liveDecayScore(): number;
824
+
825
+ /**
826
+ * Ids to request for one fact on V1 or V2 (`id_in`), in precedence order.
827
+ * Throws like `toSubgraphId`.
828
+ */
829
+ export function lookupIds(owner: string, id: string): string[];
830
+
743
831
  /**
744
832
  * Map a v1 type to its short-form category key.
745
833
  *
@@ -828,6 +916,12 @@ export function parseDigestResponse(raw: string): string;
828
916
  */
829
917
  export function parseGemini(input: string): any;
830
918
 
919
+ /**
920
+ * Parse a judge reply. Returns JSON: `"SAME"` (one of the seven relation
921
+ * words, upper case) or `null`.
922
+ */
923
+ export function parseJudgeAnswer(raw: string): string;
924
+
831
925
  /**
832
926
  * Case-insensitive parse of a memory source string. Unknown input returns "user-inferred".
833
927
  */
@@ -901,6 +995,24 @@ export function piiFilter(text: string): string;
901
995
  */
902
996
  export function pinBoost(tier_json: string, now_unix: bigint, config_json: string): number;
903
997
 
998
+ /**
999
+ * Pick the forgotten entries the LLM should judge for a candidate.
1000
+ *
1001
+ * `entriesJson`: JSON array of `{id, text, embedding?}`. Returns a plan:
1002
+ * `{"kind":"decided","match":null|{...}}` or
1003
+ * `{"kind":"ask","pairs":[...],"fallback":...,"unjudged":...}`.
1004
+ */
1005
+ export function planForgetJudge(text: string, embedding_json: string, entries_json: string): string;
1006
+
1007
+ /**
1008
+ * Pick the pairs the LLM should judge for a new fact (auto mode).
1009
+ *
1010
+ * `candidatesJson`: JSON array of `{id, text, embedding?, pinned?, pending?}`.
1011
+ * Returns a plan: `{"kind":"decided","decision":{...}}` or
1012
+ * `{"kind":"ask","pairs":[...],"fallback":{...}}`.
1013
+ */
1014
+ export function planJudgedWrite(text: string, embedding_json: string, candidates_json: string): string;
1015
+
904
1016
  /**
905
1017
  * Prepare a fact for on-chain storage.
906
1018
  *
@@ -971,6 +1083,17 @@ export function rerank(query: string, query_embedding: Float32Array, candidates_
971
1083
  */
972
1084
  export function rerankWithConfig(query: string, query_embedding: Float32Array, candidates_json: string, top_k: number, apply_source_weights: boolean, pin_boost?: number | null): any;
973
1085
 
1086
+ /**
1087
+ * Map the verdicts to `null` (store) or the blocking match `{id, reason, cosine}`.
1088
+ */
1089
+ export function resolveForgetJudge(plan_json: string, verdicts_json: string): string;
1090
+
1091
+ /**
1092
+ * Map the verdicts (JSON array, one relation word or `null` per pair) to a
1093
+ * decision `{action, match, relation, judged}`.
1094
+ */
1095
+ export function resolveJudgedWrite(text: string, plan_json: string, verdicts_json: string): string;
1096
+
974
1097
  /**
975
1098
  * Run the resolution formula on two contradicting claims; returns ResolutionOutcome JSON.
976
1099
  */
@@ -1013,6 +1136,13 @@ export function rotateFeedbackLog(content: string, max_lines: bigint): string;
1013
1136
  */
1014
1137
  export function segmentSessions(timestamps_json: string, embeddings_json: string, gap_seconds: number, sim_threshold: number): any;
1015
1138
 
1139
+ /**
1140
+ * JSON text of the fact's row, byte for byte, or `undefined` when the subgraph
1141
+ * answered without one. For any `facts(where: {id_in, owner})` query that
1142
+ * selects `id`, `owner` and `isActive`. Throws like `confirmLookupParse`.
1143
+ */
1144
+ export function selectFactRow(owner: string, id: string, response_json: string): string | undefined;
1145
+
1016
1146
  /**
1017
1147
  * Serialize a WeightsFile JSON to pretty-printed JSON (2-space indent).
1018
1148
  */
@@ -1032,6 +1162,11 @@ export function shouldSupersede(new_importance: number, existing_importance: num
1032
1162
  */
1033
1163
  export function signUserOp(hash_hex: string, private_key_hex: string): string;
1034
1164
 
1165
+ /**
1166
+ * Sort ascending and deduplicate a list of tags (call before batching a query).
1167
+ */
1168
+ export function sortDedupTags(tags: any): any;
1169
+
1035
1170
  /**
1036
1171
  * Return the source weight multiplier for a given source string.
1037
1172
  *
@@ -1044,6 +1179,18 @@ export function signUserOp(hash_hex: string, private_key_hex: string): string;
1044
1179
  */
1045
1180
  export function sourceWeight(source: string): number;
1046
1181
 
1182
+ /**
1183
+ * Payload id: `id` without the owner's own prefix. Use it for every write and
1184
+ * every stored id. Throws on a non-address owner or an empty id.
1185
+ */
1186
+ export function toPayloadId(owner: string, id: string): string;
1187
+
1188
+ /**
1189
+ * V2 subgraph id `<owner>:<payload id>` from either form of a fact id.
1190
+ * Throws on a non-address owner, an empty id or another account's prefix.
1191
+ */
1192
+ export function toSubgraphId(owner: string, id: string): string;
1193
+
1047
1194
  /**
1048
1195
  * Validate a `derived-bundle-v1` JSON string against every invariant in
1049
1196
  * derived-bundle-v1.md §4.7. Throws on any violation; resolves to nothing