@totalreclaw/core 1.5.0 → 2.1.0-rc.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 +89 -2
- package/totalreclaw_core.js +209 -3
- 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": "1.
|
|
4
|
+
"version": "2.1.0-rc.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
|
@@ -323,9 +323,12 @@ export function encodeSingleCall(protobuf_payload: Uint8Array): Uint8Array;
|
|
|
323
323
|
/**
|
|
324
324
|
* Encode a tombstone protobuf for soft-deleting a fact.
|
|
325
325
|
*
|
|
326
|
+
* `version` is optional; missing/0 defaults to `DEFAULT_PROTOBUF_VERSION` (3).
|
|
327
|
+
* Pass `4` to emit a v1-taxonomy tombstone (outer protobuf version = 4).
|
|
328
|
+
*
|
|
326
329
|
* Returns the protobuf bytes as a Uint8Array.
|
|
327
330
|
*/
|
|
328
|
-
export function encodeTombstoneProtobuf(fact_id: string, owner: string): Uint8Array;
|
|
331
|
+
export function encodeTombstoneProtobuf(fact_id: string, owner: string, version?: number | null): Uint8Array;
|
|
329
332
|
|
|
330
333
|
/**
|
|
331
334
|
* Encrypt a UTF-8 plaintext with XChaCha20-Poly1305.
|
|
@@ -504,6 +507,28 @@ export function getStoreDedupMaxCandidates(): number;
|
|
|
504
507
|
*/
|
|
505
508
|
export function getTrapdoorBatchSize(): number;
|
|
506
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
|
+
|
|
507
532
|
/**
|
|
508
533
|
* Compute the ERC-4337 v0.7 UserOp hash for signing.
|
|
509
534
|
*
|
|
@@ -527,6 +552,24 @@ export function hexBlobToBase64(hex_blob: string): string | undefined;
|
|
|
527
552
|
*/
|
|
528
553
|
export function isPinnedClaim(claim_json: string): boolean;
|
|
529
554
|
|
|
555
|
+
/**
|
|
556
|
+
* Runtime guard: is `value` a valid v1 memory type?
|
|
557
|
+
*/
|
|
558
|
+
export function isValidMemoryType(value: string): boolean;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Return the v1 legacy-claim fallback weight (applied to candidates that
|
|
562
|
+
* have no `source` field).
|
|
563
|
+
*/
|
|
564
|
+
export function legacyClaimFallbackWeight(): number;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Map a v1 type to its short-form category key.
|
|
568
|
+
*
|
|
569
|
+
* Returns `null` if `value` is not one of the six v1 types.
|
|
570
|
+
*/
|
|
571
|
+
export function mapTypeToCategory(value: string): any;
|
|
572
|
+
|
|
530
573
|
/**
|
|
531
574
|
* Normalize an entity name (NFC, lowercase, trim, collapse whitespace).
|
|
532
575
|
*/
|
|
@@ -564,6 +607,16 @@ export function parseDebriefResponse(response: string): any;
|
|
|
564
607
|
*/
|
|
565
608
|
export function parseDigestResponse(raw: string): string;
|
|
566
609
|
|
|
610
|
+
/**
|
|
611
|
+
* Case-insensitive parse of a memory source string. Unknown input returns "user-inferred".
|
|
612
|
+
*/
|
|
613
|
+
export function parseMemorySource(s: string): string;
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Case-insensitive parse of a memory type string. Unknown input returns "claim".
|
|
617
|
+
*/
|
|
618
|
+
export function parseMemoryTypeV1(s: string): string;
|
|
619
|
+
|
|
567
620
|
/**
|
|
568
621
|
* Parse a batch profiling LLM response into a PartialProfile.
|
|
569
622
|
*
|
|
@@ -639,11 +692,23 @@ export function readFeedbackJsonl(content: string): string;
|
|
|
639
692
|
/**
|
|
640
693
|
* Rerank candidates using BM25 + Cosine + RRF fusion.
|
|
641
694
|
*
|
|
642
|
-
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp }` objects.
|
|
695
|
+
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
|
|
643
696
|
* Returns a JsValue (array of `RankedResult` objects).
|
|
644
697
|
*/
|
|
645
698
|
export function rerank(query: string, query_embedding: Float32Array, candidates_json: string, top_k: number): any;
|
|
646
699
|
|
|
700
|
+
/**
|
|
701
|
+
* Rerank candidates with a config flag (Retrieval v2 Tier 1).
|
|
702
|
+
*
|
|
703
|
+
* When `apply_source_weights` is `true`, each candidate's final score is
|
|
704
|
+
* multiplied by the provenance weight from its `source` field (legacy
|
|
705
|
+
* candidates without `source` use the v0 fallback weight).
|
|
706
|
+
*
|
|
707
|
+
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
|
|
708
|
+
* Returns a JsValue (array of `RankedResult` objects including `source_weight`).
|
|
709
|
+
*/
|
|
710
|
+
export function rerankWithConfig(query: string, query_embedding: Float32Array, candidates_json: string, top_k: number, apply_source_weights: boolean): any;
|
|
711
|
+
|
|
647
712
|
/**
|
|
648
713
|
* Run the resolution formula on two contradicting claims; returns ResolutionOutcome JSON.
|
|
649
714
|
*/
|
|
@@ -685,3 +750,25 @@ export function shouldSupersede(new_importance: number, existing_importance: num
|
|
|
685
750
|
* Returns 65-byte signature as hex string (r + s + v).
|
|
686
751
|
*/
|
|
687
752
|
export function signUserOp(hash_hex: string, private_key_hex: string): string;
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Return the source weight multiplier for a given source string.
|
|
756
|
+
*
|
|
757
|
+
* Accepted values: "user" | "user-inferred" | "assistant" | "external" | "derived".
|
|
758
|
+
*
|
|
759
|
+
* Unknown input is routed through `MemorySource::from_str_lossy` which
|
|
760
|
+
* falls back to `user-inferred` (weight 0.90). Callers who need the
|
|
761
|
+
* "no source field at all" fallback (weight 0.85) should call
|
|
762
|
+
* `legacyClaimFallbackWeight()` instead.
|
|
763
|
+
*/
|
|
764
|
+
export function sourceWeight(source: string): number;
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Validate a Memory Taxonomy v1 claim (JSON in, JSON out — canonicalised).
|
|
768
|
+
*
|
|
769
|
+
* Returns the canonical JSON encoding on success. Throws on any schema
|
|
770
|
+
* violation (wrong type token, missing required field, wrong schema_version).
|
|
771
|
+
*
|
|
772
|
+
* See `docs/specs/totalreclaw/memory-taxonomy-v1.md`.
|
|
773
|
+
*/
|
|
774
|
+
export function validateMemoryClaimV1(claim_json: string): string;
|
package/totalreclaw_core.js
CHANGED
|
@@ -1089,17 +1089,21 @@ exports.encodeSingleCall = encodeSingleCall;
|
|
|
1089
1089
|
/**
|
|
1090
1090
|
* Encode a tombstone protobuf for soft-deleting a fact.
|
|
1091
1091
|
*
|
|
1092
|
+
* `version` is optional; missing/0 defaults to `DEFAULT_PROTOBUF_VERSION` (3).
|
|
1093
|
+
* Pass `4` to emit a v1-taxonomy tombstone (outer protobuf version = 4).
|
|
1094
|
+
*
|
|
1092
1095
|
* Returns the protobuf bytes as a Uint8Array.
|
|
1093
1096
|
* @param {string} fact_id
|
|
1094
1097
|
* @param {string} owner
|
|
1098
|
+
* @param {number | null} [version]
|
|
1095
1099
|
* @returns {Uint8Array}
|
|
1096
1100
|
*/
|
|
1097
|
-
function encodeTombstoneProtobuf(fact_id, owner) {
|
|
1101
|
+
function encodeTombstoneProtobuf(fact_id, owner, version) {
|
|
1098
1102
|
const ptr0 = passStringToWasm0(fact_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1099
1103
|
const len0 = WASM_VECTOR_LEN;
|
|
1100
1104
|
const ptr1 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1101
1105
|
const len1 = WASM_VECTOR_LEN;
|
|
1102
|
-
const ret = wasm.encodeTombstoneProtobuf(ptr0, len0, ptr1, len1);
|
|
1106
|
+
const ret = wasm.encodeTombstoneProtobuf(ptr0, len0, ptr1, len1, isLikeNone(version) ? 0x100000001 : (version) >>> 0);
|
|
1103
1107
|
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1104
1108
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1105
1109
|
return v3;
|
|
@@ -1660,6 +1664,44 @@ function getTrapdoorBatchSize() {
|
|
|
1660
1664
|
}
|
|
1661
1665
|
exports.getTrapdoorBatchSize = getTrapdoorBatchSize;
|
|
1662
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
|
+
|
|
1663
1705
|
/**
|
|
1664
1706
|
* Compute the ERC-4337 v0.7 UserOp hash for signing.
|
|
1665
1707
|
*
|
|
@@ -1730,6 +1772,45 @@ function isPinnedClaim(claim_json) {
|
|
|
1730
1772
|
}
|
|
1731
1773
|
exports.isPinnedClaim = isPinnedClaim;
|
|
1732
1774
|
|
|
1775
|
+
/**
|
|
1776
|
+
* Runtime guard: is `value` a valid v1 memory type?
|
|
1777
|
+
* @param {string} value
|
|
1778
|
+
* @returns {boolean}
|
|
1779
|
+
*/
|
|
1780
|
+
function isValidMemoryType(value) {
|
|
1781
|
+
const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1782
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1783
|
+
const ret = wasm.isValidMemoryType(ptr0, len0);
|
|
1784
|
+
return ret !== 0;
|
|
1785
|
+
}
|
|
1786
|
+
exports.isValidMemoryType = isValidMemoryType;
|
|
1787
|
+
|
|
1788
|
+
/**
|
|
1789
|
+
* Return the v1 legacy-claim fallback weight (applied to candidates that
|
|
1790
|
+
* have no `source` field).
|
|
1791
|
+
* @returns {number}
|
|
1792
|
+
*/
|
|
1793
|
+
function legacyClaimFallbackWeight() {
|
|
1794
|
+
const ret = wasm.legacyClaimFallbackWeight();
|
|
1795
|
+
return ret;
|
|
1796
|
+
}
|
|
1797
|
+
exports.legacyClaimFallbackWeight = legacyClaimFallbackWeight;
|
|
1798
|
+
|
|
1799
|
+
/**
|
|
1800
|
+
* Map a v1 type to its short-form category key.
|
|
1801
|
+
*
|
|
1802
|
+
* Returns `null` if `value` is not one of the six v1 types.
|
|
1803
|
+
* @param {string} value
|
|
1804
|
+
* @returns {any}
|
|
1805
|
+
*/
|
|
1806
|
+
function mapTypeToCategory(value) {
|
|
1807
|
+
const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1808
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1809
|
+
const ret = wasm.mapTypeToCategory(ptr0, len0);
|
|
1810
|
+
return ret;
|
|
1811
|
+
}
|
|
1812
|
+
exports.mapTypeToCategory = mapTypeToCategory;
|
|
1813
|
+
|
|
1733
1814
|
/**
|
|
1734
1815
|
* Normalize an entity name (NFC, lowercase, trim, collapse whitespace).
|
|
1735
1816
|
* @param {string} name
|
|
@@ -1865,6 +1946,48 @@ function parseDigestResponse(raw) {
|
|
|
1865
1946
|
}
|
|
1866
1947
|
exports.parseDigestResponse = parseDigestResponse;
|
|
1867
1948
|
|
|
1949
|
+
/**
|
|
1950
|
+
* Case-insensitive parse of a memory source string. Unknown input returns "user-inferred".
|
|
1951
|
+
* @param {string} s
|
|
1952
|
+
* @returns {string}
|
|
1953
|
+
*/
|
|
1954
|
+
function parseMemorySource(s) {
|
|
1955
|
+
let deferred2_0;
|
|
1956
|
+
let deferred2_1;
|
|
1957
|
+
try {
|
|
1958
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1959
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1960
|
+
const ret = wasm.parseMemorySource(ptr0, len0);
|
|
1961
|
+
deferred2_0 = ret[0];
|
|
1962
|
+
deferred2_1 = ret[1];
|
|
1963
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1964
|
+
} finally {
|
|
1965
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
exports.parseMemorySource = parseMemorySource;
|
|
1969
|
+
|
|
1970
|
+
/**
|
|
1971
|
+
* Case-insensitive parse of a memory type string. Unknown input returns "claim".
|
|
1972
|
+
* @param {string} s
|
|
1973
|
+
* @returns {string}
|
|
1974
|
+
*/
|
|
1975
|
+
function parseMemoryTypeV1(s) {
|
|
1976
|
+
let deferred2_0;
|
|
1977
|
+
let deferred2_1;
|
|
1978
|
+
try {
|
|
1979
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1980
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1981
|
+
const ret = wasm.parseMemoryTypeV1(ptr0, len0);
|
|
1982
|
+
deferred2_0 = ret[0];
|
|
1983
|
+
deferred2_1 = ret[1];
|
|
1984
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1985
|
+
} finally {
|
|
1986
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
exports.parseMemoryTypeV1 = parseMemoryTypeV1;
|
|
1990
|
+
|
|
1868
1991
|
/**
|
|
1869
1992
|
* Parse a batch profiling LLM response into a PartialProfile.
|
|
1870
1993
|
*
|
|
@@ -2105,7 +2228,7 @@ exports.readFeedbackJsonl = readFeedbackJsonl;
|
|
|
2105
2228
|
/**
|
|
2106
2229
|
* Rerank candidates using BM25 + Cosine + RRF fusion.
|
|
2107
2230
|
*
|
|
2108
|
-
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp }` objects.
|
|
2231
|
+
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
|
|
2109
2232
|
* Returns a JsValue (array of `RankedResult` objects).
|
|
2110
2233
|
* @param {string} query
|
|
2111
2234
|
* @param {Float32Array} query_embedding
|
|
@@ -2128,6 +2251,37 @@ function rerank(query, query_embedding, candidates_json, top_k) {
|
|
|
2128
2251
|
}
|
|
2129
2252
|
exports.rerank = rerank;
|
|
2130
2253
|
|
|
2254
|
+
/**
|
|
2255
|
+
* Rerank candidates with a config flag (Retrieval v2 Tier 1).
|
|
2256
|
+
*
|
|
2257
|
+
* When `apply_source_weights` is `true`, each candidate's final score is
|
|
2258
|
+
* multiplied by the provenance weight from its `source` field (legacy
|
|
2259
|
+
* candidates without `source` use the v0 fallback weight).
|
|
2260
|
+
*
|
|
2261
|
+
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
|
|
2262
|
+
* Returns a JsValue (array of `RankedResult` objects including `source_weight`).
|
|
2263
|
+
* @param {string} query
|
|
2264
|
+
* @param {Float32Array} query_embedding
|
|
2265
|
+
* @param {string} candidates_json
|
|
2266
|
+
* @param {number} top_k
|
|
2267
|
+
* @param {boolean} apply_source_weights
|
|
2268
|
+
* @returns {any}
|
|
2269
|
+
*/
|
|
2270
|
+
function rerankWithConfig(query, query_embedding, candidates_json, top_k, apply_source_weights) {
|
|
2271
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2272
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2273
|
+
const ptr1 = passArrayF32ToWasm0(query_embedding, wasm.__wbindgen_malloc);
|
|
2274
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2275
|
+
const ptr2 = passStringToWasm0(candidates_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2276
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2277
|
+
const ret = wasm.rerankWithConfig(ptr0, len0, ptr1, len1, ptr2, len2, top_k, apply_source_weights);
|
|
2278
|
+
if (ret[2]) {
|
|
2279
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2280
|
+
}
|
|
2281
|
+
return takeFromExternrefTable0(ret[0]);
|
|
2282
|
+
}
|
|
2283
|
+
exports.rerankWithConfig = rerankWithConfig;
|
|
2284
|
+
|
|
2131
2285
|
/**
|
|
2132
2286
|
* Run the resolution formula on two contradicting claims; returns ResolutionOutcome JSON.
|
|
2133
2287
|
* @param {string} claim_a_json
|
|
@@ -2348,6 +2502,58 @@ function signUserOp(hash_hex, private_key_hex) {
|
|
|
2348
2502
|
}
|
|
2349
2503
|
exports.signUserOp = signUserOp;
|
|
2350
2504
|
|
|
2505
|
+
/**
|
|
2506
|
+
* Return the source weight multiplier for a given source string.
|
|
2507
|
+
*
|
|
2508
|
+
* Accepted values: "user" | "user-inferred" | "assistant" | "external" | "derived".
|
|
2509
|
+
*
|
|
2510
|
+
* Unknown input is routed through `MemorySource::from_str_lossy` which
|
|
2511
|
+
* falls back to `user-inferred` (weight 0.90). Callers who need the
|
|
2512
|
+
* "no source field at all" fallback (weight 0.85) should call
|
|
2513
|
+
* `legacyClaimFallbackWeight()` instead.
|
|
2514
|
+
* @param {string} source
|
|
2515
|
+
* @returns {number}
|
|
2516
|
+
*/
|
|
2517
|
+
function sourceWeight(source) {
|
|
2518
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2519
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2520
|
+
const ret = wasm.sourceWeight(ptr0, len0);
|
|
2521
|
+
return ret;
|
|
2522
|
+
}
|
|
2523
|
+
exports.sourceWeight = sourceWeight;
|
|
2524
|
+
|
|
2525
|
+
/**
|
|
2526
|
+
* Validate a Memory Taxonomy v1 claim (JSON in, JSON out — canonicalised).
|
|
2527
|
+
*
|
|
2528
|
+
* Returns the canonical JSON encoding on success. Throws on any schema
|
|
2529
|
+
* violation (wrong type token, missing required field, wrong schema_version).
|
|
2530
|
+
*
|
|
2531
|
+
* See `docs/specs/totalreclaw/memory-taxonomy-v1.md`.
|
|
2532
|
+
* @param {string} claim_json
|
|
2533
|
+
* @returns {string}
|
|
2534
|
+
*/
|
|
2535
|
+
function validateMemoryClaimV1(claim_json) {
|
|
2536
|
+
let deferred3_0;
|
|
2537
|
+
let deferred3_1;
|
|
2538
|
+
try {
|
|
2539
|
+
const ptr0 = passStringToWasm0(claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2540
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2541
|
+
const ret = wasm.validateMemoryClaimV1(ptr0, len0);
|
|
2542
|
+
var ptr2 = ret[0];
|
|
2543
|
+
var len2 = ret[1];
|
|
2544
|
+
if (ret[3]) {
|
|
2545
|
+
ptr2 = 0; len2 = 0;
|
|
2546
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2547
|
+
}
|
|
2548
|
+
deferred3_0 = ptr2;
|
|
2549
|
+
deferred3_1 = len2;
|
|
2550
|
+
return getStringFromWasm0(ptr2, len2);
|
|
2551
|
+
} finally {
|
|
2552
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
exports.validateMemoryClaimV1 = validateMemoryClaimV1;
|
|
2556
|
+
|
|
2351
2557
|
function __wbg_get_imports() {
|
|
2352
2558
|
const import0 = {
|
|
2353
2559
|
__proto__: null,
|
package/totalreclaw_core_bg.wasm
CHANGED
|
Binary file
|