@totalreclaw/core 2.7.0-rc.2 → 2.8.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 +0 -1
- package/nodejs/totalreclaw_core.d.ts +111 -0
- package/nodejs/totalreclaw_core.js +581 -0
- package/nodejs/totalreclaw_core_bg.wasm +0 -0
- package/nodejs/totalreclaw_core_bg.wasm.d.ts +104 -86
- package/package.json +1 -1
- package/web/totalreclaw_core.d.ts +215 -86
- package/web/totalreclaw_core.js +568 -0
- package/web/totalreclaw_core_bg.wasm +0 -0
- package/web/totalreclaw_core_bg.wasm.d.ts +104 -86
|
@@ -30,6 +30,90 @@ function TIE_ZONE_SCORE_TOLERANCE() {
|
|
|
30
30
|
}
|
|
31
31
|
exports.TIE_ZONE_SCORE_TOLERANCE = TIE_ZONE_SCORE_TOLERANCE;
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Keyed blind-tag generator (index scheme 1). Construct from the vault's
|
|
35
|
+
* `encryptionKey`; `indexKey` is derived inside core and never exposed (no
|
|
36
|
+
* key getter, no string conversion).
|
|
37
|
+
*/
|
|
38
|
+
class WasmBlindIndexer {
|
|
39
|
+
__destroy_into_raw() {
|
|
40
|
+
const ptr = this.__wbg_ptr;
|
|
41
|
+
this.__wbg_ptr = 0;
|
|
42
|
+
WasmBlindIndexerFinalization.unregister(this);
|
|
43
|
+
return ptr;
|
|
44
|
+
}
|
|
45
|
+
free() {
|
|
46
|
+
const ptr = this.__destroy_into_raw();
|
|
47
|
+
wasm.__wbg_wasmblindindexer_free(ptr, 0);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Tag of the digest-fact marker.
|
|
51
|
+
* @returns {string}
|
|
52
|
+
*/
|
|
53
|
+
digestMarkerTag() {
|
|
54
|
+
let deferred1_0;
|
|
55
|
+
let deferred1_1;
|
|
56
|
+
try {
|
|
57
|
+
const ret = wasm.wasmblindindexer_digestMarkerTag(this.__wbg_ptr);
|
|
58
|
+
deferred1_0 = ret[0];
|
|
59
|
+
deferred1_1 = ret[1];
|
|
60
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
61
|
+
} finally {
|
|
62
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Tag of an entity name (normalised in core).
|
|
67
|
+
* @param {string} name
|
|
68
|
+
* @returns {string}
|
|
69
|
+
*/
|
|
70
|
+
entityTag(name) {
|
|
71
|
+
let deferred2_0;
|
|
72
|
+
let deferred2_1;
|
|
73
|
+
try {
|
|
74
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
75
|
+
const len0 = WASM_VECTOR_LEN;
|
|
76
|
+
const ret = wasm.wasmblindindexer_entityTag(this.__wbg_ptr, ptr0, len0);
|
|
77
|
+
deferred2_0 = ret[0];
|
|
78
|
+
deferred2_1 = ret[1];
|
|
79
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
80
|
+
} finally {
|
|
81
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* `encryption_key_hex`: 64-char hex string (32 bytes).
|
|
86
|
+
* @param {string} encryption_key_hex
|
|
87
|
+
*/
|
|
88
|
+
constructor(encryption_key_hex) {
|
|
89
|
+
const ptr0 = passStringToWasm0(encryption_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
90
|
+
const len0 = WASM_VECTOR_LEN;
|
|
91
|
+
const ret = wasm.wasmblindindexer_new(ptr0, len0);
|
|
92
|
+
if (ret[2]) {
|
|
93
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
94
|
+
}
|
|
95
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
96
|
+
WasmBlindIndexerFinalization.register(this, this.__wbg_ptr, this);
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Stem tags of a text, sorted and deduplicated. JSON array of hex strings.
|
|
101
|
+
* @param {string} text
|
|
102
|
+
* @returns {any}
|
|
103
|
+
*/
|
|
104
|
+
stemTags(text) {
|
|
105
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
106
|
+
const len0 = WASM_VECTOR_LEN;
|
|
107
|
+
const ret = wasm.wasmblindindexer_stemTags(this.__wbg_ptr, ptr0, len0);
|
|
108
|
+
if (ret[2]) {
|
|
109
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
110
|
+
}
|
|
111
|
+
return takeFromExternrefTable0(ret[0]);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (Symbol.dispose) WasmBlindIndexer.prototype[Symbol.dispose] = WasmBlindIndexer.prototype.free;
|
|
115
|
+
exports.WasmBlindIndexer = WasmBlindIndexer;
|
|
116
|
+
|
|
33
117
|
/**
|
|
34
118
|
* Random Hyperplane LSH hasher (WASM wrapper).
|
|
35
119
|
*
|
|
@@ -87,6 +171,23 @@ class WasmLshHasher {
|
|
|
87
171
|
}
|
|
88
172
|
return takeFromExternrefTable0(ret[0]);
|
|
89
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Hash an embedding vector to KEYED bucket tags (index scheme 1).
|
|
176
|
+
*
|
|
177
|
+
* Returns a JSON array of hex strings (one per table). `lshBucketKey` is
|
|
178
|
+
* derived from the seed inside core and never exposed.
|
|
179
|
+
* @param {Float64Array} embedding
|
|
180
|
+
* @returns {any}
|
|
181
|
+
*/
|
|
182
|
+
hashKeyed(embedding) {
|
|
183
|
+
const ptr0 = passArrayF64ToWasm0(embedding, wasm.__wbindgen_malloc);
|
|
184
|
+
const len0 = WASM_VECTOR_LEN;
|
|
185
|
+
const ret = wasm.wasmlshhasher_hashKeyed(this.__wbg_ptr, ptr0, len0);
|
|
186
|
+
if (ret[2]) {
|
|
187
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
188
|
+
}
|
|
189
|
+
return takeFromExternrefTable0(ret[0]);
|
|
190
|
+
}
|
|
90
191
|
/**
|
|
91
192
|
* Create a new LSH hasher with default parameters (20 tables, 32 bits).
|
|
92
193
|
*
|
|
@@ -1345,6 +1446,26 @@ function encodeFactProtobuf(json) {
|
|
|
1345
1446
|
}
|
|
1346
1447
|
exports.encodeFactProtobuf = encodeFactProtobuf;
|
|
1347
1448
|
|
|
1449
|
+
/**
|
|
1450
|
+
* Encode a scheme-1 fact: field 5 sorted and deduplicated, field 14 `index_scheme = 1`,
|
|
1451
|
+
* outer version always 4 (any `version` in the JSON is ignored). Same JSON as
|
|
1452
|
+
* `encodeFactProtobuf`; throws unless every `blind_indices` entry is 64 lowercase hex.
|
|
1453
|
+
* @param {string} json
|
|
1454
|
+
* @returns {Uint8Array}
|
|
1455
|
+
*/
|
|
1456
|
+
function encodeFactProtobufKeyed(json) {
|
|
1457
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1458
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1459
|
+
const ret = wasm.encodeFactProtobufKeyed(ptr0, len0);
|
|
1460
|
+
if (ret[3]) {
|
|
1461
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1462
|
+
}
|
|
1463
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1464
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1465
|
+
return v2;
|
|
1466
|
+
}
|
|
1467
|
+
exports.encodeFactProtobufKeyed = encodeFactProtobufKeyed;
|
|
1468
|
+
|
|
1348
1469
|
/**
|
|
1349
1470
|
* Encode a single fact submission as SimpleAccount.execute() calldata.
|
|
1350
1471
|
*
|
|
@@ -1412,6 +1533,24 @@ function encodeTombstoneProtobuf(fact_id, owner, version) {
|
|
|
1412
1533
|
}
|
|
1413
1534
|
exports.encodeTombstoneProtobuf = encodeTombstoneProtobuf;
|
|
1414
1535
|
|
|
1536
|
+
/**
|
|
1537
|
+
* Encode a scheme-1 tombstone: outer version 4 plus field 14 `index_scheme = 1`.
|
|
1538
|
+
* @param {string} fact_id
|
|
1539
|
+
* @param {string} owner
|
|
1540
|
+
* @returns {Uint8Array}
|
|
1541
|
+
*/
|
|
1542
|
+
function encodeTombstoneProtobufKeyed(fact_id, owner) {
|
|
1543
|
+
const ptr0 = passStringToWasm0(fact_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1544
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1545
|
+
const ptr1 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1546
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1547
|
+
const ret = wasm.encodeTombstoneProtobufKeyed(ptr0, len0, ptr1, len1);
|
|
1548
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1549
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1550
|
+
return v3;
|
|
1551
|
+
}
|
|
1552
|
+
exports.encodeTombstoneProtobufKeyed = encodeTombstoneProtobufKeyed;
|
|
1553
|
+
|
|
1415
1554
|
/**
|
|
1416
1555
|
* Encrypt a UTF-8 plaintext with XChaCha20-Poly1305.
|
|
1417
1556
|
*
|
|
@@ -1788,6 +1927,37 @@ function generateContentFingerprint(plaintext, dedup_key_hex) {
|
|
|
1788
1927
|
}
|
|
1789
1928
|
exports.generateContentFingerprint = generateContentFingerprint;
|
|
1790
1929
|
|
|
1930
|
+
/**
|
|
1931
|
+
* Content fingerprint v2 (index scheme 1): HMAC under `fpKeyV2`, which core
|
|
1932
|
+
* derives from `dedupKey`. Not interchangeable with `generateContentFingerprint`.
|
|
1933
|
+
* @param {string} plaintext
|
|
1934
|
+
* @param {string} dedup_key_hex
|
|
1935
|
+
* @returns {string}
|
|
1936
|
+
*/
|
|
1937
|
+
function generateContentFingerprintV2(plaintext, dedup_key_hex) {
|
|
1938
|
+
let deferred4_0;
|
|
1939
|
+
let deferred4_1;
|
|
1940
|
+
try {
|
|
1941
|
+
const ptr0 = passStringToWasm0(plaintext, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1942
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1943
|
+
const ptr1 = passStringToWasm0(dedup_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1944
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1945
|
+
const ret = wasm.generateContentFingerprintV2(ptr0, len0, ptr1, len1);
|
|
1946
|
+
var ptr3 = ret[0];
|
|
1947
|
+
var len3 = ret[1];
|
|
1948
|
+
if (ret[3]) {
|
|
1949
|
+
ptr3 = 0; len3 = 0;
|
|
1950
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1951
|
+
}
|
|
1952
|
+
deferred4_0 = ptr3;
|
|
1953
|
+
deferred4_1 = len3;
|
|
1954
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1955
|
+
} finally {
|
|
1956
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
exports.generateContentFingerprintV2 = generateContentFingerprintV2;
|
|
1960
|
+
|
|
1791
1961
|
/**
|
|
1792
1962
|
* Generate trapdoors for multiple query reformulations (expansion pipeline).
|
|
1793
1963
|
*
|
|
@@ -1842,6 +2012,32 @@ function generateSearchTrapdoors(query, query_embedding, lsh_hasher) {
|
|
|
1842
2012
|
}
|
|
1843
2013
|
exports.generateSearchTrapdoors = generateSearchTrapdoors;
|
|
1844
2014
|
|
|
2015
|
+
/**
|
|
2016
|
+
* Keyed search trapdoors (index scheme 1): stem tags + one entity tag per name +
|
|
2017
|
+
* keyed LSH tags, sorted and deduplicated. `entity_names`: JSON array of strings.
|
|
2018
|
+
* Returns a JsValue (JSON array of hex strings); final, batch as is.
|
|
2019
|
+
* @param {string} query
|
|
2020
|
+
* @param {any} entity_names
|
|
2021
|
+
* @param {Float32Array} query_embedding
|
|
2022
|
+
* @param {WasmBlindIndexer} indexer
|
|
2023
|
+
* @param {WasmLshHasher} lsh_hasher
|
|
2024
|
+
* @returns {any}
|
|
2025
|
+
*/
|
|
2026
|
+
function generateSearchTrapdoorsKeyed(query, entity_names, query_embedding, indexer, lsh_hasher) {
|
|
2027
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2028
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2029
|
+
const ptr1 = passArrayF32ToWasm0(query_embedding, wasm.__wbindgen_malloc);
|
|
2030
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2031
|
+
_assertClass(indexer, WasmBlindIndexer);
|
|
2032
|
+
_assertClass(lsh_hasher, WasmLshHasher);
|
|
2033
|
+
const ret = wasm.generateSearchTrapdoorsKeyed(ptr0, len0, entity_names, ptr1, len1, indexer.__wbg_ptr, lsh_hasher.__wbg_ptr);
|
|
2034
|
+
if (ret[2]) {
|
|
2035
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2036
|
+
}
|
|
2037
|
+
return takeFromExternrefTable0(ret[0]);
|
|
2038
|
+
}
|
|
2039
|
+
exports.generateSearchTrapdoorsKeyed = generateSearchTrapdoorsKeyed;
|
|
2040
|
+
|
|
1845
2041
|
/**
|
|
1846
2042
|
* Get the GraphQL query string for broadened (fallback) search.
|
|
1847
2043
|
* @returns {string}
|
|
@@ -2282,6 +2478,37 @@ function isValidMemoryType(value) {
|
|
|
2282
2478
|
}
|
|
2283
2479
|
exports.isValidMemoryType = isValidMemoryType;
|
|
2284
2480
|
|
|
2481
|
+
/**
|
|
2482
|
+
* The same-fact judge prompt for one pair: JSON `{system, user}`. Line
|
|
2483
|
+
* breaks in either text are collapsed to spaces.
|
|
2484
|
+
* @param {string} existing
|
|
2485
|
+
* @param {string} candidate
|
|
2486
|
+
* @returns {string}
|
|
2487
|
+
*/
|
|
2488
|
+
function judgePrompt(existing, candidate) {
|
|
2489
|
+
let deferred4_0;
|
|
2490
|
+
let deferred4_1;
|
|
2491
|
+
try {
|
|
2492
|
+
const ptr0 = passStringToWasm0(existing, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2493
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2494
|
+
const ptr1 = passStringToWasm0(candidate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2495
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2496
|
+
const ret = wasm.judgePrompt(ptr0, len0, ptr1, len1);
|
|
2497
|
+
var ptr3 = ret[0];
|
|
2498
|
+
var len3 = ret[1];
|
|
2499
|
+
if (ret[3]) {
|
|
2500
|
+
ptr3 = 0; len3 = 0;
|
|
2501
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2502
|
+
}
|
|
2503
|
+
deferred4_0 = ptr3;
|
|
2504
|
+
deferred4_1 = len3;
|
|
2505
|
+
return getStringFromWasm0(ptr3, len3);
|
|
2506
|
+
} finally {
|
|
2507
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
exports.judgePrompt = judgePrompt;
|
|
2511
|
+
|
|
2285
2512
|
/**
|
|
2286
2513
|
* Return the v1 legacy-claim fallback weight (applied to candidates that
|
|
2287
2514
|
* have no `source` field).
|
|
@@ -2293,6 +2520,18 @@ function legacyClaimFallbackWeight() {
|
|
|
2293
2520
|
}
|
|
2294
2521
|
exports.legacyClaimFallbackWeight = legacyClaimFallbackWeight;
|
|
2295
2522
|
|
|
2523
|
+
/**
|
|
2524
|
+
* On-chain `decayScore` for every LIVE fact (always `1.0`; #789).
|
|
2525
|
+
*
|
|
2526
|
+
* `0` = tombstone, `1.0` = live; carries no importance. Never use for tombstones.
|
|
2527
|
+
* @returns {number}
|
|
2528
|
+
*/
|
|
2529
|
+
function liveDecayScore() {
|
|
2530
|
+
const ret = wasm.liveDecayScore();
|
|
2531
|
+
return ret;
|
|
2532
|
+
}
|
|
2533
|
+
exports.liveDecayScore = liveDecayScore;
|
|
2534
|
+
|
|
2296
2535
|
/**
|
|
2297
2536
|
* Map a v1 type to its short-form category key.
|
|
2298
2537
|
*
|
|
@@ -2565,6 +2804,34 @@ function parseGemini(input) {
|
|
|
2565
2804
|
}
|
|
2566
2805
|
exports.parseGemini = parseGemini;
|
|
2567
2806
|
|
|
2807
|
+
/**
|
|
2808
|
+
* Parse a judge reply. Returns JSON: `"SAME"` (one of the seven relation
|
|
2809
|
+
* words, upper case) or `null`.
|
|
2810
|
+
* @param {string} raw
|
|
2811
|
+
* @returns {string}
|
|
2812
|
+
*/
|
|
2813
|
+
function parseJudgeAnswer(raw) {
|
|
2814
|
+
let deferred3_0;
|
|
2815
|
+
let deferred3_1;
|
|
2816
|
+
try {
|
|
2817
|
+
const ptr0 = passStringToWasm0(raw, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2818
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2819
|
+
const ret = wasm.parseJudgeAnswer(ptr0, len0);
|
|
2820
|
+
var ptr2 = ret[0];
|
|
2821
|
+
var len2 = ret[1];
|
|
2822
|
+
if (ret[3]) {
|
|
2823
|
+
ptr2 = 0; len2 = 0;
|
|
2824
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2825
|
+
}
|
|
2826
|
+
deferred3_0 = ptr2;
|
|
2827
|
+
deferred3_1 = len2;
|
|
2828
|
+
return getStringFromWasm0(ptr2, len2);
|
|
2829
|
+
} finally {
|
|
2830
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
exports.parseJudgeAnswer = parseJudgeAnswer;
|
|
2834
|
+
|
|
2568
2835
|
/**
|
|
2569
2836
|
* Case-insensitive parse of a memory source string. Unknown input returns "user-inferred".
|
|
2570
2837
|
* @param {string} s
|
|
@@ -2783,6 +3050,80 @@ function pinBoost(tier_json, now_unix, config_json) {
|
|
|
2783
3050
|
}
|
|
2784
3051
|
exports.pinBoost = pinBoost;
|
|
2785
3052
|
|
|
3053
|
+
/**
|
|
3054
|
+
* Pick the forgotten entries the LLM should judge for a candidate.
|
|
3055
|
+
*
|
|
3056
|
+
* `entriesJson`: JSON array of `{id, text, embedding?}`. Returns a plan:
|
|
3057
|
+
* `{"kind":"decided","match":null|{...}}` or
|
|
3058
|
+
* `{"kind":"ask","pairs":[...],"fallback":...,"unjudged":...}`.
|
|
3059
|
+
* @param {string} text
|
|
3060
|
+
* @param {string} embedding_json
|
|
3061
|
+
* @param {string} entries_json
|
|
3062
|
+
* @returns {string}
|
|
3063
|
+
*/
|
|
3064
|
+
function planForgetJudge(text, embedding_json, entries_json) {
|
|
3065
|
+
let deferred5_0;
|
|
3066
|
+
let deferred5_1;
|
|
3067
|
+
try {
|
|
3068
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3069
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3070
|
+
const ptr1 = passStringToWasm0(embedding_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3071
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3072
|
+
const ptr2 = passStringToWasm0(entries_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3073
|
+
const len2 = WASM_VECTOR_LEN;
|
|
3074
|
+
const ret = wasm.planForgetJudge(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
3075
|
+
var ptr4 = ret[0];
|
|
3076
|
+
var len4 = ret[1];
|
|
3077
|
+
if (ret[3]) {
|
|
3078
|
+
ptr4 = 0; len4 = 0;
|
|
3079
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
3080
|
+
}
|
|
3081
|
+
deferred5_0 = ptr4;
|
|
3082
|
+
deferred5_1 = len4;
|
|
3083
|
+
return getStringFromWasm0(ptr4, len4);
|
|
3084
|
+
} finally {
|
|
3085
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
3086
|
+
}
|
|
3087
|
+
}
|
|
3088
|
+
exports.planForgetJudge = planForgetJudge;
|
|
3089
|
+
|
|
3090
|
+
/**
|
|
3091
|
+
* Pick the pairs the LLM should judge for a new fact (auto mode).
|
|
3092
|
+
*
|
|
3093
|
+
* `candidatesJson`: JSON array of `{id, text, embedding?, pinned?, pending?}`.
|
|
3094
|
+
* Returns a plan: `{"kind":"decided","decision":{...}}` or
|
|
3095
|
+
* `{"kind":"ask","pairs":[...],"fallback":{...}}`.
|
|
3096
|
+
* @param {string} text
|
|
3097
|
+
* @param {string} embedding_json
|
|
3098
|
+
* @param {string} candidates_json
|
|
3099
|
+
* @returns {string}
|
|
3100
|
+
*/
|
|
3101
|
+
function planJudgedWrite(text, embedding_json, candidates_json) {
|
|
3102
|
+
let deferred5_0;
|
|
3103
|
+
let deferred5_1;
|
|
3104
|
+
try {
|
|
3105
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3106
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3107
|
+
const ptr1 = passStringToWasm0(embedding_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3108
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3109
|
+
const ptr2 = passStringToWasm0(candidates_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3110
|
+
const len2 = WASM_VECTOR_LEN;
|
|
3111
|
+
const ret = wasm.planJudgedWrite(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
3112
|
+
var ptr4 = ret[0];
|
|
3113
|
+
var len4 = ret[1];
|
|
3114
|
+
if (ret[3]) {
|
|
3115
|
+
ptr4 = 0; len4 = 0;
|
|
3116
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
3117
|
+
}
|
|
3118
|
+
deferred5_0 = ptr4;
|
|
3119
|
+
deferred5_1 = len4;
|
|
3120
|
+
return getStringFromWasm0(ptr4, len4);
|
|
3121
|
+
} finally {
|
|
3122
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
exports.planJudgedWrite = planJudgedWrite;
|
|
3126
|
+
|
|
2786
3127
|
/**
|
|
2787
3128
|
* Prepare a fact for on-chain storage.
|
|
2788
3129
|
*
|
|
@@ -3004,6 +3345,70 @@ function rerankWithConfig(query, query_embedding, candidates_json, top_k, apply_
|
|
|
3004
3345
|
}
|
|
3005
3346
|
exports.rerankWithConfig = rerankWithConfig;
|
|
3006
3347
|
|
|
3348
|
+
/**
|
|
3349
|
+
* Map the verdicts to `null` (store) or the blocking match `{id, reason, cosine}`.
|
|
3350
|
+
* @param {string} plan_json
|
|
3351
|
+
* @param {string} verdicts_json
|
|
3352
|
+
* @returns {string}
|
|
3353
|
+
*/
|
|
3354
|
+
function resolveForgetJudge(plan_json, verdicts_json) {
|
|
3355
|
+
let deferred4_0;
|
|
3356
|
+
let deferred4_1;
|
|
3357
|
+
try {
|
|
3358
|
+
const ptr0 = passStringToWasm0(plan_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3359
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3360
|
+
const ptr1 = passStringToWasm0(verdicts_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3361
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3362
|
+
const ret = wasm.resolveForgetJudge(ptr0, len0, ptr1, len1);
|
|
3363
|
+
var ptr3 = ret[0];
|
|
3364
|
+
var len3 = ret[1];
|
|
3365
|
+
if (ret[3]) {
|
|
3366
|
+
ptr3 = 0; len3 = 0;
|
|
3367
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
3368
|
+
}
|
|
3369
|
+
deferred4_0 = ptr3;
|
|
3370
|
+
deferred4_1 = len3;
|
|
3371
|
+
return getStringFromWasm0(ptr3, len3);
|
|
3372
|
+
} finally {
|
|
3373
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3376
|
+
exports.resolveForgetJudge = resolveForgetJudge;
|
|
3377
|
+
|
|
3378
|
+
/**
|
|
3379
|
+
* Map the verdicts (JSON array, one relation word or `null` per pair) to a
|
|
3380
|
+
* decision `{action, match, relation, judged}`.
|
|
3381
|
+
* @param {string} text
|
|
3382
|
+
* @param {string} plan_json
|
|
3383
|
+
* @param {string} verdicts_json
|
|
3384
|
+
* @returns {string}
|
|
3385
|
+
*/
|
|
3386
|
+
function resolveJudgedWrite(text, plan_json, verdicts_json) {
|
|
3387
|
+
let deferred5_0;
|
|
3388
|
+
let deferred5_1;
|
|
3389
|
+
try {
|
|
3390
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3391
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3392
|
+
const ptr1 = passStringToWasm0(plan_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3393
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3394
|
+
const ptr2 = passStringToWasm0(verdicts_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3395
|
+
const len2 = WASM_VECTOR_LEN;
|
|
3396
|
+
const ret = wasm.resolveJudgedWrite(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
3397
|
+
var ptr4 = ret[0];
|
|
3398
|
+
var len4 = ret[1];
|
|
3399
|
+
if (ret[3]) {
|
|
3400
|
+
ptr4 = 0; len4 = 0;
|
|
3401
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
3402
|
+
}
|
|
3403
|
+
deferred5_0 = ptr4;
|
|
3404
|
+
deferred5_1 = len4;
|
|
3405
|
+
return getStringFromWasm0(ptr4, len4);
|
|
3406
|
+
} finally {
|
|
3407
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
3408
|
+
}
|
|
3409
|
+
}
|
|
3410
|
+
exports.resolveJudgedWrite = resolveJudgedWrite;
|
|
3411
|
+
|
|
3007
3412
|
/**
|
|
3008
3413
|
* Run the resolution formula on two contradicting claims; returns ResolutionOutcome JSON.
|
|
3009
3414
|
* @param {string} claim_a_json
|
|
@@ -3259,6 +3664,20 @@ function signUserOp(hash_hex, private_key_hex) {
|
|
|
3259
3664
|
}
|
|
3260
3665
|
exports.signUserOp = signUserOp;
|
|
3261
3666
|
|
|
3667
|
+
/**
|
|
3668
|
+
* Sort ascending and deduplicate a list of tags (call before batching a query).
|
|
3669
|
+
* @param {any} tags
|
|
3670
|
+
* @returns {any}
|
|
3671
|
+
*/
|
|
3672
|
+
function sortDedupTags(tags) {
|
|
3673
|
+
const ret = wasm.sortDedupTags(tags);
|
|
3674
|
+
if (ret[2]) {
|
|
3675
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3676
|
+
}
|
|
3677
|
+
return takeFromExternrefTable0(ret[0]);
|
|
3678
|
+
}
|
|
3679
|
+
exports.sortDedupTags = sortDedupTags;
|
|
3680
|
+
|
|
3262
3681
|
/**
|
|
3263
3682
|
* Return the source weight multiplier for a given source string.
|
|
3264
3683
|
*
|
|
@@ -3398,6 +3817,18 @@ function __wbg_get_imports() {
|
|
|
3398
3817
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
3399
3818
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
3400
3819
|
},
|
|
3820
|
+
__wbg___wbindgen_boolean_get_a86c216575a75c30: function(arg0) {
|
|
3821
|
+
const v = arg0;
|
|
3822
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
3823
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
3824
|
+
},
|
|
3825
|
+
__wbg___wbindgen_debug_string_dd5d2d07ce9e6c57: function(arg0, arg1) {
|
|
3826
|
+
const ret = debugString(arg1);
|
|
3827
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3828
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3829
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
3830
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
3831
|
+
},
|
|
3401
3832
|
__wbg___wbindgen_is_function_49868bde5eb1e745: function(arg0) {
|
|
3402
3833
|
const ret = typeof(arg0) === 'function';
|
|
3403
3834
|
return ret;
|
|
@@ -3415,9 +3846,31 @@ function __wbg_get_imports() {
|
|
|
3415
3846
|
const ret = arg0 === undefined;
|
|
3416
3847
|
return ret;
|
|
3417
3848
|
},
|
|
3849
|
+
__wbg___wbindgen_jsval_loose_eq_3a72ae764d46d944: function(arg0, arg1) {
|
|
3850
|
+
const ret = arg0 == arg1;
|
|
3851
|
+
return ret;
|
|
3852
|
+
},
|
|
3853
|
+
__wbg___wbindgen_number_get_7579aab02a8a620c: function(arg0, arg1) {
|
|
3854
|
+
const obj = arg1;
|
|
3855
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
3856
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
3857
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
3858
|
+
},
|
|
3859
|
+
__wbg___wbindgen_string_get_914df97fcfa788f2: function(arg0, arg1) {
|
|
3860
|
+
const obj = arg1;
|
|
3861
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
3862
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3863
|
+
var len1 = WASM_VECTOR_LEN;
|
|
3864
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
3865
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
3866
|
+
},
|
|
3418
3867
|
__wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
|
|
3419
3868
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
3420
3869
|
},
|
|
3870
|
+
__wbg_call_7f2987183bb62793: function() { return handleError(function (arg0, arg1) {
|
|
3871
|
+
const ret = arg0.call(arg1);
|
|
3872
|
+
return ret;
|
|
3873
|
+
}, arguments); },
|
|
3421
3874
|
__wbg_call_d578befcc3145dee: function() { return handleError(function (arg0, arg1, arg2) {
|
|
3422
3875
|
const ret = arg0.call(arg1, arg2);
|
|
3423
3876
|
return ret;
|
|
@@ -3426,6 +3879,10 @@ function __wbg_get_imports() {
|
|
|
3426
3879
|
const ret = arg0.crypto;
|
|
3427
3880
|
return ret;
|
|
3428
3881
|
},
|
|
3882
|
+
__wbg_done_547d467e97529006: function(arg0) {
|
|
3883
|
+
const ret = arg0.done;
|
|
3884
|
+
return ret;
|
|
3885
|
+
},
|
|
3429
3886
|
__wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
|
|
3430
3887
|
arg0.getRandomValues(arg1);
|
|
3431
3888
|
}, arguments); },
|
|
@@ -3436,10 +3893,50 @@ function __wbg_get_imports() {
|
|
|
3436
3893
|
const ret = arg0.getTime();
|
|
3437
3894
|
return ret;
|
|
3438
3895
|
},
|
|
3896
|
+
__wbg_get_ed0642c4b9d31ddf: function() { return handleError(function (arg0, arg1) {
|
|
3897
|
+
const ret = Reflect.get(arg0, arg1);
|
|
3898
|
+
return ret;
|
|
3899
|
+
}, arguments); },
|
|
3900
|
+
__wbg_get_unchecked_7d7babe32e9e6a54: function(arg0, arg1) {
|
|
3901
|
+
const ret = arg0[arg1 >>> 0];
|
|
3902
|
+
return ret;
|
|
3903
|
+
},
|
|
3904
|
+
__wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a: function(arg0) {
|
|
3905
|
+
let result;
|
|
3906
|
+
try {
|
|
3907
|
+
result = arg0 instanceof ArrayBuffer;
|
|
3908
|
+
} catch (_) {
|
|
3909
|
+
result = false;
|
|
3910
|
+
}
|
|
3911
|
+
const ret = result;
|
|
3912
|
+
return ret;
|
|
3913
|
+
},
|
|
3914
|
+
__wbg_instanceof_Uint8Array_4b8da683deb25d72: function(arg0) {
|
|
3915
|
+
let result;
|
|
3916
|
+
try {
|
|
3917
|
+
result = arg0 instanceof Uint8Array;
|
|
3918
|
+
} catch (_) {
|
|
3919
|
+
result = false;
|
|
3920
|
+
}
|
|
3921
|
+
const ret = result;
|
|
3922
|
+
return ret;
|
|
3923
|
+
},
|
|
3924
|
+
__wbg_isArray_db61795ad004c139: function(arg0) {
|
|
3925
|
+
const ret = Array.isArray(arg0);
|
|
3926
|
+
return ret;
|
|
3927
|
+
},
|
|
3928
|
+
__wbg_iterator_de403ef31815a3e6: function() {
|
|
3929
|
+
const ret = Symbol.iterator;
|
|
3930
|
+
return ret;
|
|
3931
|
+
},
|
|
3439
3932
|
__wbg_length_0c32cb8543c8e4c8: function(arg0) {
|
|
3440
3933
|
const ret = arg0.length;
|
|
3441
3934
|
return ret;
|
|
3442
3935
|
},
|
|
3936
|
+
__wbg_length_6e821edde497a532: function(arg0) {
|
|
3937
|
+
const ret = arg0.length;
|
|
3938
|
+
return ret;
|
|
3939
|
+
},
|
|
3443
3940
|
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
|
3444
3941
|
const ret = arg0.msCrypto;
|
|
3445
3942
|
return ret;
|
|
@@ -3456,6 +3953,10 @@ function __wbg_get_imports() {
|
|
|
3456
3953
|
const ret = new Map();
|
|
3457
3954
|
return ret;
|
|
3458
3955
|
},
|
|
3956
|
+
__wbg_new_a560378ea1240b14: function(arg0) {
|
|
3957
|
+
const ret = new Uint8Array(arg0);
|
|
3958
|
+
return ret;
|
|
3959
|
+
},
|
|
3459
3960
|
__wbg_new_f3c9df4f38f3f798: function() {
|
|
3460
3961
|
const ret = new Array();
|
|
3461
3962
|
return ret;
|
|
@@ -3464,6 +3965,14 @@ function __wbg_get_imports() {
|
|
|
3464
3965
|
const ret = new Uint8Array(arg0 >>> 0);
|
|
3465
3966
|
return ret;
|
|
3466
3967
|
},
|
|
3968
|
+
__wbg_next_01132ed6134b8ef5: function(arg0) {
|
|
3969
|
+
const ret = arg0.next;
|
|
3970
|
+
return ret;
|
|
3971
|
+
},
|
|
3972
|
+
__wbg_next_b3713ec761a9dbfd: function() { return handleError(function (arg0) {
|
|
3973
|
+
const ret = arg0.next();
|
|
3974
|
+
return ret;
|
|
3975
|
+
}, arguments); },
|
|
3467
3976
|
__wbg_node_84ea875411254db1: function(arg0) {
|
|
3468
3977
|
const ret = arg0.node;
|
|
3469
3978
|
return ret;
|
|
@@ -3520,6 +4029,10 @@ function __wbg_get_imports() {
|
|
|
3520
4029
|
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
3521
4030
|
return ret;
|
|
3522
4031
|
},
|
|
4032
|
+
__wbg_value_7f6052747ccf940f: function(arg0) {
|
|
4033
|
+
const ret = arg0.value;
|
|
4034
|
+
return ret;
|
|
4035
|
+
},
|
|
3523
4036
|
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
|
3524
4037
|
const ret = arg0.versions;
|
|
3525
4038
|
return ret;
|
|
@@ -3565,6 +4078,9 @@ function __wbg_get_imports() {
|
|
|
3565
4078
|
};
|
|
3566
4079
|
}
|
|
3567
4080
|
|
|
4081
|
+
const WasmBlindIndexerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4082
|
+
? { register: () => {}, unregister: () => {} }
|
|
4083
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmblindindexer_free(ptr >>> 0, 1));
|
|
3568
4084
|
const WasmLshHasherFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3569
4085
|
? { register: () => {}, unregister: () => {} }
|
|
3570
4086
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmlshhasher_free(ptr >>> 0, 1));
|
|
@@ -3581,6 +4097,71 @@ function _assertClass(instance, klass) {
|
|
|
3581
4097
|
}
|
|
3582
4098
|
}
|
|
3583
4099
|
|
|
4100
|
+
function debugString(val) {
|
|
4101
|
+
// primitive types
|
|
4102
|
+
const type = typeof val;
|
|
4103
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
4104
|
+
return `${val}`;
|
|
4105
|
+
}
|
|
4106
|
+
if (type == 'string') {
|
|
4107
|
+
return `"${val}"`;
|
|
4108
|
+
}
|
|
4109
|
+
if (type == 'symbol') {
|
|
4110
|
+
const description = val.description;
|
|
4111
|
+
if (description == null) {
|
|
4112
|
+
return 'Symbol';
|
|
4113
|
+
} else {
|
|
4114
|
+
return `Symbol(${description})`;
|
|
4115
|
+
}
|
|
4116
|
+
}
|
|
4117
|
+
if (type == 'function') {
|
|
4118
|
+
const name = val.name;
|
|
4119
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
4120
|
+
return `Function(${name})`;
|
|
4121
|
+
} else {
|
|
4122
|
+
return 'Function';
|
|
4123
|
+
}
|
|
4124
|
+
}
|
|
4125
|
+
// objects
|
|
4126
|
+
if (Array.isArray(val)) {
|
|
4127
|
+
const length = val.length;
|
|
4128
|
+
let debug = '[';
|
|
4129
|
+
if (length > 0) {
|
|
4130
|
+
debug += debugString(val[0]);
|
|
4131
|
+
}
|
|
4132
|
+
for(let i = 1; i < length; i++) {
|
|
4133
|
+
debug += ', ' + debugString(val[i]);
|
|
4134
|
+
}
|
|
4135
|
+
debug += ']';
|
|
4136
|
+
return debug;
|
|
4137
|
+
}
|
|
4138
|
+
// Test for built-in
|
|
4139
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
4140
|
+
let className;
|
|
4141
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
4142
|
+
className = builtInMatches[1];
|
|
4143
|
+
} else {
|
|
4144
|
+
// Failed to match the standard '[object ClassName]'
|
|
4145
|
+
return toString.call(val);
|
|
4146
|
+
}
|
|
4147
|
+
if (className == 'Object') {
|
|
4148
|
+
// we're a user defined class or Object
|
|
4149
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
4150
|
+
// easier than looping through ownProperties of `val`.
|
|
4151
|
+
try {
|
|
4152
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
4153
|
+
} catch (_) {
|
|
4154
|
+
return 'Object';
|
|
4155
|
+
}
|
|
4156
|
+
}
|
|
4157
|
+
// errors
|
|
4158
|
+
if (val instanceof Error) {
|
|
4159
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
4160
|
+
}
|
|
4161
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
4162
|
+
return className;
|
|
4163
|
+
}
|
|
4164
|
+
|
|
3584
4165
|
function getArrayF32FromWasm0(ptr, len) {
|
|
3585
4166
|
ptr = ptr >>> 0;
|
|
3586
4167
|
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|