@totalreclaw/core 2.0.0 → 2.1.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/README.md +40 -0
- package/package.json +10 -2
- package/totalreclaw_core.d.ts +48 -0
- package/totalreclaw_core.js +104 -0
- package/totalreclaw_core_bg.wasm +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# totalreclaw-core
|
|
2
|
+
|
|
3
|
+
Shared core library powering every TotalReclaw client — a single source of truth for crypto, search, reranking, wallet derivation, UserOp construction, and store pipelines.
|
|
4
|
+
|
|
5
|
+
Used natively by [`totalreclaw-memory`](https://crates.io/crates/totalreclaw-memory) (Rust / ZeroClaw), and exposed via WASM (`@totalreclaw/core` on npm) and PyO3 (`totalreclaw-core` on PyPI) bindings for TypeScript and Python clients.
|
|
6
|
+
|
|
7
|
+
## What's in the box
|
|
8
|
+
|
|
9
|
+
- **Crypto** — XChaCha20-Poly1305 envelope encryption, HKDF key derivation, BIP-39 mnemonic + BIP-44 wallet derivation, Keccak256.
|
|
10
|
+
- **Reranker** — BM25 + cosine + RRF with intent-weighted scoring.
|
|
11
|
+
- **Store / Search pipelines** — canonical claim construction, LSH blind indexing, fingerprinting.
|
|
12
|
+
- **Dedup & KG** — best-match near-duplicate detection, cluster facts, contradiction detection orchestration, pin semantics, decision log.
|
|
13
|
+
- **ERC-4337** — UserOp construction (feature-gated via `managed`), signing verified byte-for-byte against viem.
|
|
14
|
+
- **Hot cache + consolidation + debrief + stemmer**.
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- `managed` (default) — ERC-4337 UserOp support via `alloy-primitives` / `alloy-sol-types`.
|
|
19
|
+
- `wasm` — WASM bindings via `wasm-bindgen` (consumed by `@totalreclaw/core` npm package).
|
|
20
|
+
- `python` / `python-extension` — PyO3 bindings (consumed by `totalreclaw-core` PyPI package).
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```toml
|
|
25
|
+
[dependencies]
|
|
26
|
+
totalreclaw-core = "2.0"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Most Rust users should depend on [`totalreclaw-memory`](https://crates.io/crates/totalreclaw-memory), which bundles core into a high-level `Memory` trait.
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
MIT
|
|
34
|
+
|
|
35
|
+
## Links
|
|
36
|
+
|
|
37
|
+
- Homepage: <https://totalreclaw.xyz>
|
|
38
|
+
- Repository: <https://github.com/p-diogo/totalreclaw>
|
|
39
|
+
- npm (WASM): [`@totalreclaw/core`](https://www.npmjs.com/package/@totalreclaw/core)
|
|
40
|
+
- PyPI (PyO3): [`totalreclaw-core`](https://pypi.org/project/totalreclaw-core/)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totalreclaw/core",
|
|
3
3
|
"description": "TotalReclaw core — E2EE crypto, reranker, wallet, UserOp, store/search pipelines. Single source of truth for all clients.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.1.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -13,5 +13,13 @@
|
|
|
13
13
|
"totalreclaw_core.d.ts"
|
|
14
14
|
],
|
|
15
15
|
"main": "totalreclaw_core.js",
|
|
16
|
-
"
|
|
16
|
+
"homepage": "https://totalreclaw.xyz",
|
|
17
|
+
"types": "totalreclaw_core.d.ts",
|
|
18
|
+
"keywords": [
|
|
19
|
+
"e2ee",
|
|
20
|
+
"memory",
|
|
21
|
+
"crypto",
|
|
22
|
+
"erc4337",
|
|
23
|
+
"ai"
|
|
24
|
+
]
|
|
17
25
|
}
|
package/totalreclaw_core.d.ts
CHANGED
|
@@ -507,6 +507,28 @@ export function getStoreDedupMaxCandidates(): number;
|
|
|
507
507
|
*/
|
|
508
508
|
export function getTrapdoorBatchSize(): number;
|
|
509
509
|
|
|
510
|
+
/**
|
|
511
|
+
* Get the v1 type → short-form category mapping.
|
|
512
|
+
*
|
|
513
|
+
* Returns a plain JS object `{ claim: "claim", preference: "pref",
|
|
514
|
+
* directive: "rule", commitment: "goal", episode: "epi",
|
|
515
|
+
* summary: "sum" }`.
|
|
516
|
+
*
|
|
517
|
+
* Uses `js_sys::Object.set` directly so the result is a plain JS
|
|
518
|
+
* object (not a `Map`) regardless of serde-wasm-bindgen defaults,
|
|
519
|
+
* matching how TypeScript clients consume the mapping via bracket
|
|
520
|
+
* access (`map[type]`).
|
|
521
|
+
*/
|
|
522
|
+
export function getTypeToCategory(): any;
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Get the canonical list of v1 memory types.
|
|
526
|
+
*
|
|
527
|
+
* Returns a JS array of six strings: `["claim", "preference",
|
|
528
|
+
* "directive", "commitment", "episode", "summary"]`.
|
|
529
|
+
*/
|
|
530
|
+
export function getValidMemoryTypes(): any;
|
|
531
|
+
|
|
510
532
|
/**
|
|
511
533
|
* Compute the ERC-4337 v0.7 UserOp hash for signing.
|
|
512
534
|
*
|
|
@@ -530,12 +552,33 @@ export function hexBlobToBase64(hex_blob: string): string | undefined;
|
|
|
530
552
|
*/
|
|
531
553
|
export function isPinnedClaim(claim_json: string): boolean;
|
|
532
554
|
|
|
555
|
+
/**
|
|
556
|
+
* Check whether a JSON-encoded claim is pinned, recognizing both the v0
|
|
557
|
+
* short-key sentinel (`st == "p"`) and the v1.1 field (`pin_status ==
|
|
558
|
+
* "pinned"`). Returns `false` on any parse failure.
|
|
559
|
+
*
|
|
560
|
+
* Wrapper around [`crate::claims::is_pinned_json`] for TS clients.
|
|
561
|
+
*/
|
|
562
|
+
export function isPinnedClaimJson(claim_json: string): boolean;
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Runtime guard: is `value` a valid v1 memory type?
|
|
566
|
+
*/
|
|
567
|
+
export function isValidMemoryType(value: string): boolean;
|
|
568
|
+
|
|
533
569
|
/**
|
|
534
570
|
* Return the v1 legacy-claim fallback weight (applied to candidates that
|
|
535
571
|
* have no `source` field).
|
|
536
572
|
*/
|
|
537
573
|
export function legacyClaimFallbackWeight(): number;
|
|
538
574
|
|
|
575
|
+
/**
|
|
576
|
+
* Map a v1 type to its short-form category key.
|
|
577
|
+
*
|
|
578
|
+
* Returns `null` if `value` is not one of the six v1 types.
|
|
579
|
+
*/
|
|
580
|
+
export function mapTypeToCategory(value: string): any;
|
|
581
|
+
|
|
539
582
|
/**
|
|
540
583
|
* Normalize an entity name (NFC, lowercase, trim, collapse whitespace).
|
|
541
584
|
*/
|
|
@@ -583,6 +626,11 @@ export function parseMemorySource(s: string): string;
|
|
|
583
626
|
*/
|
|
584
627
|
export function parseMemoryTypeV1(s: string): string;
|
|
585
628
|
|
|
629
|
+
/**
|
|
630
|
+
* Case-insensitive parse of a v1.1 pin_status string. Unknown input returns "unpinned".
|
|
631
|
+
*/
|
|
632
|
+
export function parsePinStatus(s: string): string;
|
|
633
|
+
|
|
586
634
|
/**
|
|
587
635
|
* Parse a batch profiling LLM response into a PartialProfile.
|
|
588
636
|
*
|
package/totalreclaw_core.js
CHANGED
|
@@ -1664,6 +1664,44 @@ function getTrapdoorBatchSize() {
|
|
|
1664
1664
|
}
|
|
1665
1665
|
exports.getTrapdoorBatchSize = getTrapdoorBatchSize;
|
|
1666
1666
|
|
|
1667
|
+
/**
|
|
1668
|
+
* Get the v1 type → short-form category mapping.
|
|
1669
|
+
*
|
|
1670
|
+
* Returns a plain JS object `{ claim: "claim", preference: "pref",
|
|
1671
|
+
* directive: "rule", commitment: "goal", episode: "epi",
|
|
1672
|
+
* summary: "sum" }`.
|
|
1673
|
+
*
|
|
1674
|
+
* Uses `js_sys::Object.set` directly so the result is a plain JS
|
|
1675
|
+
* object (not a `Map`) regardless of serde-wasm-bindgen defaults,
|
|
1676
|
+
* matching how TypeScript clients consume the mapping via bracket
|
|
1677
|
+
* access (`map[type]`).
|
|
1678
|
+
* @returns {any}
|
|
1679
|
+
*/
|
|
1680
|
+
function getTypeToCategory() {
|
|
1681
|
+
const ret = wasm.getTypeToCategory();
|
|
1682
|
+
if (ret[2]) {
|
|
1683
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1684
|
+
}
|
|
1685
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1686
|
+
}
|
|
1687
|
+
exports.getTypeToCategory = getTypeToCategory;
|
|
1688
|
+
|
|
1689
|
+
/**
|
|
1690
|
+
* Get the canonical list of v1 memory types.
|
|
1691
|
+
*
|
|
1692
|
+
* Returns a JS array of six strings: `["claim", "preference",
|
|
1693
|
+
* "directive", "commitment", "episode", "summary"]`.
|
|
1694
|
+
* @returns {any}
|
|
1695
|
+
*/
|
|
1696
|
+
function getValidMemoryTypes() {
|
|
1697
|
+
const ret = wasm.getValidMemoryTypes();
|
|
1698
|
+
if (ret[2]) {
|
|
1699
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1700
|
+
}
|
|
1701
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1702
|
+
}
|
|
1703
|
+
exports.getValidMemoryTypes = getValidMemoryTypes;
|
|
1704
|
+
|
|
1667
1705
|
/**
|
|
1668
1706
|
* Compute the ERC-4337 v0.7 UserOp hash for signing.
|
|
1669
1707
|
*
|
|
@@ -1734,6 +1772,36 @@ function isPinnedClaim(claim_json) {
|
|
|
1734
1772
|
}
|
|
1735
1773
|
exports.isPinnedClaim = isPinnedClaim;
|
|
1736
1774
|
|
|
1775
|
+
/**
|
|
1776
|
+
* Check whether a JSON-encoded claim is pinned, recognizing both the v0
|
|
1777
|
+
* short-key sentinel (`st == "p"`) and the v1.1 field (`pin_status ==
|
|
1778
|
+
* "pinned"`). Returns `false` on any parse failure.
|
|
1779
|
+
*
|
|
1780
|
+
* Wrapper around [`crate::claims::is_pinned_json`] for TS clients.
|
|
1781
|
+
* @param {string} claim_json
|
|
1782
|
+
* @returns {boolean}
|
|
1783
|
+
*/
|
|
1784
|
+
function isPinnedClaimJson(claim_json) {
|
|
1785
|
+
const ptr0 = passStringToWasm0(claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1786
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1787
|
+
const ret = wasm.isPinnedClaimJson(ptr0, len0);
|
|
1788
|
+
return ret !== 0;
|
|
1789
|
+
}
|
|
1790
|
+
exports.isPinnedClaimJson = isPinnedClaimJson;
|
|
1791
|
+
|
|
1792
|
+
/**
|
|
1793
|
+
* Runtime guard: is `value` a valid v1 memory type?
|
|
1794
|
+
* @param {string} value
|
|
1795
|
+
* @returns {boolean}
|
|
1796
|
+
*/
|
|
1797
|
+
function isValidMemoryType(value) {
|
|
1798
|
+
const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1799
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1800
|
+
const ret = wasm.isValidMemoryType(ptr0, len0);
|
|
1801
|
+
return ret !== 0;
|
|
1802
|
+
}
|
|
1803
|
+
exports.isValidMemoryType = isValidMemoryType;
|
|
1804
|
+
|
|
1737
1805
|
/**
|
|
1738
1806
|
* Return the v1 legacy-claim fallback weight (applied to candidates that
|
|
1739
1807
|
* have no `source` field).
|
|
@@ -1745,6 +1813,21 @@ function legacyClaimFallbackWeight() {
|
|
|
1745
1813
|
}
|
|
1746
1814
|
exports.legacyClaimFallbackWeight = legacyClaimFallbackWeight;
|
|
1747
1815
|
|
|
1816
|
+
/**
|
|
1817
|
+
* Map a v1 type to its short-form category key.
|
|
1818
|
+
*
|
|
1819
|
+
* Returns `null` if `value` is not one of the six v1 types.
|
|
1820
|
+
* @param {string} value
|
|
1821
|
+
* @returns {any}
|
|
1822
|
+
*/
|
|
1823
|
+
function mapTypeToCategory(value) {
|
|
1824
|
+
const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1825
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1826
|
+
const ret = wasm.mapTypeToCategory(ptr0, len0);
|
|
1827
|
+
return ret;
|
|
1828
|
+
}
|
|
1829
|
+
exports.mapTypeToCategory = mapTypeToCategory;
|
|
1830
|
+
|
|
1748
1831
|
/**
|
|
1749
1832
|
* Normalize an entity name (NFC, lowercase, trim, collapse whitespace).
|
|
1750
1833
|
* @param {string} name
|
|
@@ -1922,6 +2005,27 @@ function parseMemoryTypeV1(s) {
|
|
|
1922
2005
|
}
|
|
1923
2006
|
exports.parseMemoryTypeV1 = parseMemoryTypeV1;
|
|
1924
2007
|
|
|
2008
|
+
/**
|
|
2009
|
+
* Case-insensitive parse of a v1.1 pin_status string. Unknown input returns "unpinned".
|
|
2010
|
+
* @param {string} s
|
|
2011
|
+
* @returns {string}
|
|
2012
|
+
*/
|
|
2013
|
+
function parsePinStatus(s) {
|
|
2014
|
+
let deferred2_0;
|
|
2015
|
+
let deferred2_1;
|
|
2016
|
+
try {
|
|
2017
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2018
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2019
|
+
const ret = wasm.parsePinStatus(ptr0, len0);
|
|
2020
|
+
deferred2_0 = ret[0];
|
|
2021
|
+
deferred2_1 = ret[1];
|
|
2022
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2023
|
+
} finally {
|
|
2024
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
exports.parsePinStatus = parsePinStatus;
|
|
2028
|
+
|
|
1925
2029
|
/**
|
|
1926
2030
|
* Parse a batch profiling LLM response into a PartialProfile.
|
|
1927
2031
|
*
|
package/totalreclaw_core_bg.wasm
CHANGED
|
Binary file
|