@totalreclaw/core 1.5.0 → 2.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/package.json +1 -1
- package/totalreclaw_core.d.ts +55 -2
- package/totalreclaw_core.js +143 -3
- package/totalreclaw_core_bg.wasm +0 -0
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": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
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.
|
|
@@ -527,6 +530,12 @@ export function hexBlobToBase64(hex_blob: string): string | undefined;
|
|
|
527
530
|
*/
|
|
528
531
|
export function isPinnedClaim(claim_json: string): boolean;
|
|
529
532
|
|
|
533
|
+
/**
|
|
534
|
+
* Return the v1 legacy-claim fallback weight (applied to candidates that
|
|
535
|
+
* have no `source` field).
|
|
536
|
+
*/
|
|
537
|
+
export function legacyClaimFallbackWeight(): number;
|
|
538
|
+
|
|
530
539
|
/**
|
|
531
540
|
* Normalize an entity name (NFC, lowercase, trim, collapse whitespace).
|
|
532
541
|
*/
|
|
@@ -564,6 +573,16 @@ export function parseDebriefResponse(response: string): any;
|
|
|
564
573
|
*/
|
|
565
574
|
export function parseDigestResponse(raw: string): string;
|
|
566
575
|
|
|
576
|
+
/**
|
|
577
|
+
* Case-insensitive parse of a memory source string. Unknown input returns "user-inferred".
|
|
578
|
+
*/
|
|
579
|
+
export function parseMemorySource(s: string): string;
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Case-insensitive parse of a memory type string. Unknown input returns "claim".
|
|
583
|
+
*/
|
|
584
|
+
export function parseMemoryTypeV1(s: string): string;
|
|
585
|
+
|
|
567
586
|
/**
|
|
568
587
|
* Parse a batch profiling LLM response into a PartialProfile.
|
|
569
588
|
*
|
|
@@ -639,11 +658,23 @@ export function readFeedbackJsonl(content: string): string;
|
|
|
639
658
|
/**
|
|
640
659
|
* Rerank candidates using BM25 + Cosine + RRF fusion.
|
|
641
660
|
*
|
|
642
|
-
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp }` objects.
|
|
661
|
+
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
|
|
643
662
|
* Returns a JsValue (array of `RankedResult` objects).
|
|
644
663
|
*/
|
|
645
664
|
export function rerank(query: string, query_embedding: Float32Array, candidates_json: string, top_k: number): any;
|
|
646
665
|
|
|
666
|
+
/**
|
|
667
|
+
* Rerank candidates with a config flag (Retrieval v2 Tier 1).
|
|
668
|
+
*
|
|
669
|
+
* When `apply_source_weights` is `true`, each candidate's final score is
|
|
670
|
+
* multiplied by the provenance weight from its `source` field (legacy
|
|
671
|
+
* candidates without `source` use the v0 fallback weight).
|
|
672
|
+
*
|
|
673
|
+
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
|
|
674
|
+
* Returns a JsValue (array of `RankedResult` objects including `source_weight`).
|
|
675
|
+
*/
|
|
676
|
+
export function rerankWithConfig(query: string, query_embedding: Float32Array, candidates_json: string, top_k: number, apply_source_weights: boolean): any;
|
|
677
|
+
|
|
647
678
|
/**
|
|
648
679
|
* Run the resolution formula on two contradicting claims; returns ResolutionOutcome JSON.
|
|
649
680
|
*/
|
|
@@ -685,3 +716,25 @@ export function shouldSupersede(new_importance: number, existing_importance: num
|
|
|
685
716
|
* Returns 65-byte signature as hex string (r + s + v).
|
|
686
717
|
*/
|
|
687
718
|
export function signUserOp(hash_hex: string, private_key_hex: string): string;
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Return the source weight multiplier for a given source string.
|
|
722
|
+
*
|
|
723
|
+
* Accepted values: "user" | "user-inferred" | "assistant" | "external" | "derived".
|
|
724
|
+
*
|
|
725
|
+
* Unknown input is routed through `MemorySource::from_str_lossy` which
|
|
726
|
+
* falls back to `user-inferred` (weight 0.90). Callers who need the
|
|
727
|
+
* "no source field at all" fallback (weight 0.85) should call
|
|
728
|
+
* `legacyClaimFallbackWeight()` instead.
|
|
729
|
+
*/
|
|
730
|
+
export function sourceWeight(source: string): number;
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Validate a Memory Taxonomy v1 claim (JSON in, JSON out — canonicalised).
|
|
734
|
+
*
|
|
735
|
+
* Returns the canonical JSON encoding on success. Throws on any schema
|
|
736
|
+
* violation (wrong type token, missing required field, wrong schema_version).
|
|
737
|
+
*
|
|
738
|
+
* See `docs/specs/totalreclaw/memory-taxonomy-v1.md`.
|
|
739
|
+
*/
|
|
740
|
+
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;
|
|
@@ -1730,6 +1734,17 @@ function isPinnedClaim(claim_json) {
|
|
|
1730
1734
|
}
|
|
1731
1735
|
exports.isPinnedClaim = isPinnedClaim;
|
|
1732
1736
|
|
|
1737
|
+
/**
|
|
1738
|
+
* Return the v1 legacy-claim fallback weight (applied to candidates that
|
|
1739
|
+
* have no `source` field).
|
|
1740
|
+
* @returns {number}
|
|
1741
|
+
*/
|
|
1742
|
+
function legacyClaimFallbackWeight() {
|
|
1743
|
+
const ret = wasm.legacyClaimFallbackWeight();
|
|
1744
|
+
return ret;
|
|
1745
|
+
}
|
|
1746
|
+
exports.legacyClaimFallbackWeight = legacyClaimFallbackWeight;
|
|
1747
|
+
|
|
1733
1748
|
/**
|
|
1734
1749
|
* Normalize an entity name (NFC, lowercase, trim, collapse whitespace).
|
|
1735
1750
|
* @param {string} name
|
|
@@ -1865,6 +1880,48 @@ function parseDigestResponse(raw) {
|
|
|
1865
1880
|
}
|
|
1866
1881
|
exports.parseDigestResponse = parseDigestResponse;
|
|
1867
1882
|
|
|
1883
|
+
/**
|
|
1884
|
+
* Case-insensitive parse of a memory source string. Unknown input returns "user-inferred".
|
|
1885
|
+
* @param {string} s
|
|
1886
|
+
* @returns {string}
|
|
1887
|
+
*/
|
|
1888
|
+
function parseMemorySource(s) {
|
|
1889
|
+
let deferred2_0;
|
|
1890
|
+
let deferred2_1;
|
|
1891
|
+
try {
|
|
1892
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1893
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1894
|
+
const ret = wasm.parseMemorySource(ptr0, len0);
|
|
1895
|
+
deferred2_0 = ret[0];
|
|
1896
|
+
deferred2_1 = ret[1];
|
|
1897
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1898
|
+
} finally {
|
|
1899
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
exports.parseMemorySource = parseMemorySource;
|
|
1903
|
+
|
|
1904
|
+
/**
|
|
1905
|
+
* Case-insensitive parse of a memory type string. Unknown input returns "claim".
|
|
1906
|
+
* @param {string} s
|
|
1907
|
+
* @returns {string}
|
|
1908
|
+
*/
|
|
1909
|
+
function parseMemoryTypeV1(s) {
|
|
1910
|
+
let deferred2_0;
|
|
1911
|
+
let deferred2_1;
|
|
1912
|
+
try {
|
|
1913
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1914
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1915
|
+
const ret = wasm.parseMemoryTypeV1(ptr0, len0);
|
|
1916
|
+
deferred2_0 = ret[0];
|
|
1917
|
+
deferred2_1 = ret[1];
|
|
1918
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1919
|
+
} finally {
|
|
1920
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
exports.parseMemoryTypeV1 = parseMemoryTypeV1;
|
|
1924
|
+
|
|
1868
1925
|
/**
|
|
1869
1926
|
* Parse a batch profiling LLM response into a PartialProfile.
|
|
1870
1927
|
*
|
|
@@ -2105,7 +2162,7 @@ exports.readFeedbackJsonl = readFeedbackJsonl;
|
|
|
2105
2162
|
/**
|
|
2106
2163
|
* Rerank candidates using BM25 + Cosine + RRF fusion.
|
|
2107
2164
|
*
|
|
2108
|
-
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp }` objects.
|
|
2165
|
+
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
|
|
2109
2166
|
* Returns a JsValue (array of `RankedResult` objects).
|
|
2110
2167
|
* @param {string} query
|
|
2111
2168
|
* @param {Float32Array} query_embedding
|
|
@@ -2128,6 +2185,37 @@ function rerank(query, query_embedding, candidates_json, top_k) {
|
|
|
2128
2185
|
}
|
|
2129
2186
|
exports.rerank = rerank;
|
|
2130
2187
|
|
|
2188
|
+
/**
|
|
2189
|
+
* Rerank candidates with a config flag (Retrieval v2 Tier 1).
|
|
2190
|
+
*
|
|
2191
|
+
* When `apply_source_weights` is `true`, each candidate's final score is
|
|
2192
|
+
* multiplied by the provenance weight from its `source` field (legacy
|
|
2193
|
+
* candidates without `source` use the v0 fallback weight).
|
|
2194
|
+
*
|
|
2195
|
+
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
|
|
2196
|
+
* Returns a JsValue (array of `RankedResult` objects including `source_weight`).
|
|
2197
|
+
* @param {string} query
|
|
2198
|
+
* @param {Float32Array} query_embedding
|
|
2199
|
+
* @param {string} candidates_json
|
|
2200
|
+
* @param {number} top_k
|
|
2201
|
+
* @param {boolean} apply_source_weights
|
|
2202
|
+
* @returns {any}
|
|
2203
|
+
*/
|
|
2204
|
+
function rerankWithConfig(query, query_embedding, candidates_json, top_k, apply_source_weights) {
|
|
2205
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2206
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2207
|
+
const ptr1 = passArrayF32ToWasm0(query_embedding, wasm.__wbindgen_malloc);
|
|
2208
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2209
|
+
const ptr2 = passStringToWasm0(candidates_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2210
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2211
|
+
const ret = wasm.rerankWithConfig(ptr0, len0, ptr1, len1, ptr2, len2, top_k, apply_source_weights);
|
|
2212
|
+
if (ret[2]) {
|
|
2213
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2214
|
+
}
|
|
2215
|
+
return takeFromExternrefTable0(ret[0]);
|
|
2216
|
+
}
|
|
2217
|
+
exports.rerankWithConfig = rerankWithConfig;
|
|
2218
|
+
|
|
2131
2219
|
/**
|
|
2132
2220
|
* Run the resolution formula on two contradicting claims; returns ResolutionOutcome JSON.
|
|
2133
2221
|
* @param {string} claim_a_json
|
|
@@ -2348,6 +2436,58 @@ function signUserOp(hash_hex, private_key_hex) {
|
|
|
2348
2436
|
}
|
|
2349
2437
|
exports.signUserOp = signUserOp;
|
|
2350
2438
|
|
|
2439
|
+
/**
|
|
2440
|
+
* Return the source weight multiplier for a given source string.
|
|
2441
|
+
*
|
|
2442
|
+
* Accepted values: "user" | "user-inferred" | "assistant" | "external" | "derived".
|
|
2443
|
+
*
|
|
2444
|
+
* Unknown input is routed through `MemorySource::from_str_lossy` which
|
|
2445
|
+
* falls back to `user-inferred` (weight 0.90). Callers who need the
|
|
2446
|
+
* "no source field at all" fallback (weight 0.85) should call
|
|
2447
|
+
* `legacyClaimFallbackWeight()` instead.
|
|
2448
|
+
* @param {string} source
|
|
2449
|
+
* @returns {number}
|
|
2450
|
+
*/
|
|
2451
|
+
function sourceWeight(source) {
|
|
2452
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2453
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2454
|
+
const ret = wasm.sourceWeight(ptr0, len0);
|
|
2455
|
+
return ret;
|
|
2456
|
+
}
|
|
2457
|
+
exports.sourceWeight = sourceWeight;
|
|
2458
|
+
|
|
2459
|
+
/**
|
|
2460
|
+
* Validate a Memory Taxonomy v1 claim (JSON in, JSON out — canonicalised).
|
|
2461
|
+
*
|
|
2462
|
+
* Returns the canonical JSON encoding on success. Throws on any schema
|
|
2463
|
+
* violation (wrong type token, missing required field, wrong schema_version).
|
|
2464
|
+
*
|
|
2465
|
+
* See `docs/specs/totalreclaw/memory-taxonomy-v1.md`.
|
|
2466
|
+
* @param {string} claim_json
|
|
2467
|
+
* @returns {string}
|
|
2468
|
+
*/
|
|
2469
|
+
function validateMemoryClaimV1(claim_json) {
|
|
2470
|
+
let deferred3_0;
|
|
2471
|
+
let deferred3_1;
|
|
2472
|
+
try {
|
|
2473
|
+
const ptr0 = passStringToWasm0(claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2474
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2475
|
+
const ret = wasm.validateMemoryClaimV1(ptr0, len0);
|
|
2476
|
+
var ptr2 = ret[0];
|
|
2477
|
+
var len2 = ret[1];
|
|
2478
|
+
if (ret[3]) {
|
|
2479
|
+
ptr2 = 0; len2 = 0;
|
|
2480
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2481
|
+
}
|
|
2482
|
+
deferred3_0 = ptr2;
|
|
2483
|
+
deferred3_1 = len2;
|
|
2484
|
+
return getStringFromWasm0(ptr2, len2);
|
|
2485
|
+
} finally {
|
|
2486
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
exports.validateMemoryClaimV1 = validateMemoryClaimV1;
|
|
2490
|
+
|
|
2351
2491
|
function __wbg_get_imports() {
|
|
2352
2492
|
const import0 = {
|
|
2353
2493
|
__proto__: null,
|
package/totalreclaw_core_bg.wasm
CHANGED
|
Binary file
|