@totalreclaw/core 2.7.0 → 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
package/web/totalreclaw_core.js
CHANGED
|
@@ -27,6 +27,89 @@ export function TIE_ZONE_SCORE_TOLERANCE() {
|
|
|
27
27
|
return ret;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Keyed blind-tag generator (index scheme 1). Construct from the vault's
|
|
32
|
+
* `encryptionKey`; `indexKey` is derived inside core and never exposed (no
|
|
33
|
+
* key getter, no string conversion).
|
|
34
|
+
*/
|
|
35
|
+
export class WasmBlindIndexer {
|
|
36
|
+
__destroy_into_raw() {
|
|
37
|
+
const ptr = this.__wbg_ptr;
|
|
38
|
+
this.__wbg_ptr = 0;
|
|
39
|
+
WasmBlindIndexerFinalization.unregister(this);
|
|
40
|
+
return ptr;
|
|
41
|
+
}
|
|
42
|
+
free() {
|
|
43
|
+
const ptr = this.__destroy_into_raw();
|
|
44
|
+
wasm.__wbg_wasmblindindexer_free(ptr, 0);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Tag of the digest-fact marker.
|
|
48
|
+
* @returns {string}
|
|
49
|
+
*/
|
|
50
|
+
digestMarkerTag() {
|
|
51
|
+
let deferred1_0;
|
|
52
|
+
let deferred1_1;
|
|
53
|
+
try {
|
|
54
|
+
const ret = wasm.wasmblindindexer_digestMarkerTag(this.__wbg_ptr);
|
|
55
|
+
deferred1_0 = ret[0];
|
|
56
|
+
deferred1_1 = ret[1];
|
|
57
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
58
|
+
} finally {
|
|
59
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Tag of an entity name (normalised in core).
|
|
64
|
+
* @param {string} name
|
|
65
|
+
* @returns {string}
|
|
66
|
+
*/
|
|
67
|
+
entityTag(name) {
|
|
68
|
+
let deferred2_0;
|
|
69
|
+
let deferred2_1;
|
|
70
|
+
try {
|
|
71
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
72
|
+
const len0 = WASM_VECTOR_LEN;
|
|
73
|
+
const ret = wasm.wasmblindindexer_entityTag(this.__wbg_ptr, ptr0, len0);
|
|
74
|
+
deferred2_0 = ret[0];
|
|
75
|
+
deferred2_1 = ret[1];
|
|
76
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
77
|
+
} finally {
|
|
78
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* `encryption_key_hex`: 64-char hex string (32 bytes).
|
|
83
|
+
* @param {string} encryption_key_hex
|
|
84
|
+
*/
|
|
85
|
+
constructor(encryption_key_hex) {
|
|
86
|
+
const ptr0 = passStringToWasm0(encryption_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
87
|
+
const len0 = WASM_VECTOR_LEN;
|
|
88
|
+
const ret = wasm.wasmblindindexer_new(ptr0, len0);
|
|
89
|
+
if (ret[2]) {
|
|
90
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
91
|
+
}
|
|
92
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
93
|
+
WasmBlindIndexerFinalization.register(this, this.__wbg_ptr, this);
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Stem tags of a text, sorted and deduplicated. JSON array of hex strings.
|
|
98
|
+
* @param {string} text
|
|
99
|
+
* @returns {any}
|
|
100
|
+
*/
|
|
101
|
+
stemTags(text) {
|
|
102
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
103
|
+
const len0 = WASM_VECTOR_LEN;
|
|
104
|
+
const ret = wasm.wasmblindindexer_stemTags(this.__wbg_ptr, ptr0, len0);
|
|
105
|
+
if (ret[2]) {
|
|
106
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
107
|
+
}
|
|
108
|
+
return takeFromExternrefTable0(ret[0]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (Symbol.dispose) WasmBlindIndexer.prototype[Symbol.dispose] = WasmBlindIndexer.prototype.free;
|
|
112
|
+
|
|
30
113
|
/**
|
|
31
114
|
* Random Hyperplane LSH hasher (WASM wrapper).
|
|
32
115
|
*
|
|
@@ -84,6 +167,23 @@ export class WasmLshHasher {
|
|
|
84
167
|
}
|
|
85
168
|
return takeFromExternrefTable0(ret[0]);
|
|
86
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Hash an embedding vector to KEYED bucket tags (index scheme 1).
|
|
172
|
+
*
|
|
173
|
+
* Returns a JSON array of hex strings (one per table). `lshBucketKey` is
|
|
174
|
+
* derived from the seed inside core and never exposed.
|
|
175
|
+
* @param {Float64Array} embedding
|
|
176
|
+
* @returns {any}
|
|
177
|
+
*/
|
|
178
|
+
hashKeyed(embedding) {
|
|
179
|
+
const ptr0 = passArrayF64ToWasm0(embedding, wasm.__wbindgen_malloc);
|
|
180
|
+
const len0 = WASM_VECTOR_LEN;
|
|
181
|
+
const ret = wasm.wasmlshhasher_hashKeyed(this.__wbg_ptr, ptr0, len0);
|
|
182
|
+
if (ret[2]) {
|
|
183
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
184
|
+
}
|
|
185
|
+
return takeFromExternrefTable0(ret[0]);
|
|
186
|
+
}
|
|
87
187
|
/**
|
|
88
188
|
* Create a new LSH hasher with default parameters (20 tables, 32 bits).
|
|
89
189
|
*
|
|
@@ -1298,6 +1398,25 @@ export function encodeFactProtobuf(json) {
|
|
|
1298
1398
|
return v2;
|
|
1299
1399
|
}
|
|
1300
1400
|
|
|
1401
|
+
/**
|
|
1402
|
+
* Encode a scheme-1 fact: field 5 sorted and deduplicated, field 14 `index_scheme = 1`,
|
|
1403
|
+
* outer version always 4 (any `version` in the JSON is ignored). Same JSON as
|
|
1404
|
+
* `encodeFactProtobuf`; throws unless every `blind_indices` entry is 64 lowercase hex.
|
|
1405
|
+
* @param {string} json
|
|
1406
|
+
* @returns {Uint8Array}
|
|
1407
|
+
*/
|
|
1408
|
+
export function encodeFactProtobufKeyed(json) {
|
|
1409
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1410
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1411
|
+
const ret = wasm.encodeFactProtobufKeyed(ptr0, len0);
|
|
1412
|
+
if (ret[3]) {
|
|
1413
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1414
|
+
}
|
|
1415
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1416
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1417
|
+
return v2;
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1301
1420
|
/**
|
|
1302
1421
|
* Encode a single fact submission as SimpleAccount.execute() calldata.
|
|
1303
1422
|
*
|
|
@@ -1362,6 +1481,23 @@ export function encodeTombstoneProtobuf(fact_id, owner, version) {
|
|
|
1362
1481
|
return v3;
|
|
1363
1482
|
}
|
|
1364
1483
|
|
|
1484
|
+
/**
|
|
1485
|
+
* Encode a scheme-1 tombstone: outer version 4 plus field 14 `index_scheme = 1`.
|
|
1486
|
+
* @param {string} fact_id
|
|
1487
|
+
* @param {string} owner
|
|
1488
|
+
* @returns {Uint8Array}
|
|
1489
|
+
*/
|
|
1490
|
+
export function encodeTombstoneProtobufKeyed(fact_id, owner) {
|
|
1491
|
+
const ptr0 = passStringToWasm0(fact_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1492
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1493
|
+
const ptr1 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1494
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1495
|
+
const ret = wasm.encodeTombstoneProtobufKeyed(ptr0, len0, ptr1, len1);
|
|
1496
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1497
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1498
|
+
return v3;
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1365
1501
|
/**
|
|
1366
1502
|
* Encrypt a UTF-8 plaintext with XChaCha20-Poly1305.
|
|
1367
1503
|
*
|
|
@@ -1725,6 +1861,36 @@ export function generateContentFingerprint(plaintext, dedup_key_hex) {
|
|
|
1725
1861
|
}
|
|
1726
1862
|
}
|
|
1727
1863
|
|
|
1864
|
+
/**
|
|
1865
|
+
* Content fingerprint v2 (index scheme 1): HMAC under `fpKeyV2`, which core
|
|
1866
|
+
* derives from `dedupKey`. Not interchangeable with `generateContentFingerprint`.
|
|
1867
|
+
* @param {string} plaintext
|
|
1868
|
+
* @param {string} dedup_key_hex
|
|
1869
|
+
* @returns {string}
|
|
1870
|
+
*/
|
|
1871
|
+
export function generateContentFingerprintV2(plaintext, dedup_key_hex) {
|
|
1872
|
+
let deferred4_0;
|
|
1873
|
+
let deferred4_1;
|
|
1874
|
+
try {
|
|
1875
|
+
const ptr0 = passStringToWasm0(plaintext, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1876
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1877
|
+
const ptr1 = passStringToWasm0(dedup_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1878
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1879
|
+
const ret = wasm.generateContentFingerprintV2(ptr0, len0, ptr1, len1);
|
|
1880
|
+
var ptr3 = ret[0];
|
|
1881
|
+
var len3 = ret[1];
|
|
1882
|
+
if (ret[3]) {
|
|
1883
|
+
ptr3 = 0; len3 = 0;
|
|
1884
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1885
|
+
}
|
|
1886
|
+
deferred4_0 = ptr3;
|
|
1887
|
+
deferred4_1 = len3;
|
|
1888
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1889
|
+
} finally {
|
|
1890
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1728
1894
|
/**
|
|
1729
1895
|
* Generate trapdoors for multiple query reformulations (expansion pipeline).
|
|
1730
1896
|
*
|
|
@@ -1777,6 +1943,31 @@ export function generateSearchTrapdoors(query, query_embedding, lsh_hasher) {
|
|
|
1777
1943
|
return takeFromExternrefTable0(ret[0]);
|
|
1778
1944
|
}
|
|
1779
1945
|
|
|
1946
|
+
/**
|
|
1947
|
+
* Keyed search trapdoors (index scheme 1): stem tags + one entity tag per name +
|
|
1948
|
+
* keyed LSH tags, sorted and deduplicated. `entity_names`: JSON array of strings.
|
|
1949
|
+
* Returns a JsValue (JSON array of hex strings); final, batch as is.
|
|
1950
|
+
* @param {string} query
|
|
1951
|
+
* @param {any} entity_names
|
|
1952
|
+
* @param {Float32Array} query_embedding
|
|
1953
|
+
* @param {WasmBlindIndexer} indexer
|
|
1954
|
+
* @param {WasmLshHasher} lsh_hasher
|
|
1955
|
+
* @returns {any}
|
|
1956
|
+
*/
|
|
1957
|
+
export function generateSearchTrapdoorsKeyed(query, entity_names, query_embedding, indexer, lsh_hasher) {
|
|
1958
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1959
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1960
|
+
const ptr1 = passArrayF32ToWasm0(query_embedding, wasm.__wbindgen_malloc);
|
|
1961
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1962
|
+
_assertClass(indexer, WasmBlindIndexer);
|
|
1963
|
+
_assertClass(lsh_hasher, WasmLshHasher);
|
|
1964
|
+
const ret = wasm.generateSearchTrapdoorsKeyed(ptr0, len0, entity_names, ptr1, len1, indexer.__wbg_ptr, lsh_hasher.__wbg_ptr);
|
|
1965
|
+
if (ret[2]) {
|
|
1966
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1967
|
+
}
|
|
1968
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1780
1971
|
/**
|
|
1781
1972
|
* Get the GraphQL query string for broadened (fallback) search.
|
|
1782
1973
|
* @returns {string}
|
|
@@ -2190,6 +2381,36 @@ export function isValidMemoryType(value) {
|
|
|
2190
2381
|
return ret !== 0;
|
|
2191
2382
|
}
|
|
2192
2383
|
|
|
2384
|
+
/**
|
|
2385
|
+
* The same-fact judge prompt for one pair: JSON `{system, user}`. Line
|
|
2386
|
+
* breaks in either text are collapsed to spaces.
|
|
2387
|
+
* @param {string} existing
|
|
2388
|
+
* @param {string} candidate
|
|
2389
|
+
* @returns {string}
|
|
2390
|
+
*/
|
|
2391
|
+
export function judgePrompt(existing, candidate) {
|
|
2392
|
+
let deferred4_0;
|
|
2393
|
+
let deferred4_1;
|
|
2394
|
+
try {
|
|
2395
|
+
const ptr0 = passStringToWasm0(existing, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2396
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2397
|
+
const ptr1 = passStringToWasm0(candidate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2398
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2399
|
+
const ret = wasm.judgePrompt(ptr0, len0, ptr1, len1);
|
|
2400
|
+
var ptr3 = ret[0];
|
|
2401
|
+
var len3 = ret[1];
|
|
2402
|
+
if (ret[3]) {
|
|
2403
|
+
ptr3 = 0; len3 = 0;
|
|
2404
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2405
|
+
}
|
|
2406
|
+
deferred4_0 = ptr3;
|
|
2407
|
+
deferred4_1 = len3;
|
|
2408
|
+
return getStringFromWasm0(ptr3, len3);
|
|
2409
|
+
} finally {
|
|
2410
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2193
2414
|
/**
|
|
2194
2415
|
* Return the v1 legacy-claim fallback weight (applied to candidates that
|
|
2195
2416
|
* have no `source` field).
|
|
@@ -2200,6 +2421,17 @@ export function legacyClaimFallbackWeight() {
|
|
|
2200
2421
|
return ret;
|
|
2201
2422
|
}
|
|
2202
2423
|
|
|
2424
|
+
/**
|
|
2425
|
+
* On-chain `decayScore` for every LIVE fact (always `1.0`; #789).
|
|
2426
|
+
*
|
|
2427
|
+
* `0` = tombstone, `1.0` = live; carries no importance. Never use for tombstones.
|
|
2428
|
+
* @returns {number}
|
|
2429
|
+
*/
|
|
2430
|
+
export function liveDecayScore() {
|
|
2431
|
+
const ret = wasm.liveDecayScore();
|
|
2432
|
+
return ret;
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2203
2435
|
/**
|
|
2204
2436
|
* Map a v1 type to its short-form category key.
|
|
2205
2437
|
*
|
|
@@ -2460,6 +2692,33 @@ export function parseGemini(input) {
|
|
|
2460
2692
|
return takeFromExternrefTable0(ret[0]);
|
|
2461
2693
|
}
|
|
2462
2694
|
|
|
2695
|
+
/**
|
|
2696
|
+
* Parse a judge reply. Returns JSON: `"SAME"` (one of the seven relation
|
|
2697
|
+
* words, upper case) or `null`.
|
|
2698
|
+
* @param {string} raw
|
|
2699
|
+
* @returns {string}
|
|
2700
|
+
*/
|
|
2701
|
+
export function parseJudgeAnswer(raw) {
|
|
2702
|
+
let deferred3_0;
|
|
2703
|
+
let deferred3_1;
|
|
2704
|
+
try {
|
|
2705
|
+
const ptr0 = passStringToWasm0(raw, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2706
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2707
|
+
const ret = wasm.parseJudgeAnswer(ptr0, len0);
|
|
2708
|
+
var ptr2 = ret[0];
|
|
2709
|
+
var len2 = ret[1];
|
|
2710
|
+
if (ret[3]) {
|
|
2711
|
+
ptr2 = 0; len2 = 0;
|
|
2712
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2713
|
+
}
|
|
2714
|
+
deferred3_0 = ptr2;
|
|
2715
|
+
deferred3_1 = len2;
|
|
2716
|
+
return getStringFromWasm0(ptr2, len2);
|
|
2717
|
+
} finally {
|
|
2718
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2463
2722
|
/**
|
|
2464
2723
|
* Case-insensitive parse of a memory source string. Unknown input returns "user-inferred".
|
|
2465
2724
|
* @param {string} s
|
|
@@ -2668,6 +2927,78 @@ export function pinBoost(tier_json, now_unix, config_json) {
|
|
|
2668
2927
|
return ret[0];
|
|
2669
2928
|
}
|
|
2670
2929
|
|
|
2930
|
+
/**
|
|
2931
|
+
* Pick the forgotten entries the LLM should judge for a candidate.
|
|
2932
|
+
*
|
|
2933
|
+
* `entriesJson`: JSON array of `{id, text, embedding?}`. Returns a plan:
|
|
2934
|
+
* `{"kind":"decided","match":null|{...}}` or
|
|
2935
|
+
* `{"kind":"ask","pairs":[...],"fallback":...,"unjudged":...}`.
|
|
2936
|
+
* @param {string} text
|
|
2937
|
+
* @param {string} embedding_json
|
|
2938
|
+
* @param {string} entries_json
|
|
2939
|
+
* @returns {string}
|
|
2940
|
+
*/
|
|
2941
|
+
export function planForgetJudge(text, embedding_json, entries_json) {
|
|
2942
|
+
let deferred5_0;
|
|
2943
|
+
let deferred5_1;
|
|
2944
|
+
try {
|
|
2945
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2946
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2947
|
+
const ptr1 = passStringToWasm0(embedding_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2948
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2949
|
+
const ptr2 = passStringToWasm0(entries_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2950
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2951
|
+
const ret = wasm.planForgetJudge(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
2952
|
+
var ptr4 = ret[0];
|
|
2953
|
+
var len4 = ret[1];
|
|
2954
|
+
if (ret[3]) {
|
|
2955
|
+
ptr4 = 0; len4 = 0;
|
|
2956
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2957
|
+
}
|
|
2958
|
+
deferred5_0 = ptr4;
|
|
2959
|
+
deferred5_1 = len4;
|
|
2960
|
+
return getStringFromWasm0(ptr4, len4);
|
|
2961
|
+
} finally {
|
|
2962
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
2963
|
+
}
|
|
2964
|
+
}
|
|
2965
|
+
|
|
2966
|
+
/**
|
|
2967
|
+
* Pick the pairs the LLM should judge for a new fact (auto mode).
|
|
2968
|
+
*
|
|
2969
|
+
* `candidatesJson`: JSON array of `{id, text, embedding?, pinned?, pending?}`.
|
|
2970
|
+
* Returns a plan: `{"kind":"decided","decision":{...}}` or
|
|
2971
|
+
* `{"kind":"ask","pairs":[...],"fallback":{...}}`.
|
|
2972
|
+
* @param {string} text
|
|
2973
|
+
* @param {string} embedding_json
|
|
2974
|
+
* @param {string} candidates_json
|
|
2975
|
+
* @returns {string}
|
|
2976
|
+
*/
|
|
2977
|
+
export function planJudgedWrite(text, embedding_json, candidates_json) {
|
|
2978
|
+
let deferred5_0;
|
|
2979
|
+
let deferred5_1;
|
|
2980
|
+
try {
|
|
2981
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2982
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2983
|
+
const ptr1 = passStringToWasm0(embedding_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2984
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2985
|
+
const ptr2 = passStringToWasm0(candidates_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2986
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2987
|
+
const ret = wasm.planJudgedWrite(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
2988
|
+
var ptr4 = ret[0];
|
|
2989
|
+
var len4 = ret[1];
|
|
2990
|
+
if (ret[3]) {
|
|
2991
|
+
ptr4 = 0; len4 = 0;
|
|
2992
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2993
|
+
}
|
|
2994
|
+
deferred5_0 = ptr4;
|
|
2995
|
+
deferred5_1 = len4;
|
|
2996
|
+
return getStringFromWasm0(ptr4, len4);
|
|
2997
|
+
} finally {
|
|
2998
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
2999
|
+
}
|
|
3000
|
+
}
|
|
3001
|
+
|
|
2671
3002
|
/**
|
|
2672
3003
|
* Prepare a fact for on-chain storage.
|
|
2673
3004
|
*
|
|
@@ -2882,6 +3213,68 @@ export function rerankWithConfig(query, query_embedding, candidates_json, top_k,
|
|
|
2882
3213
|
return takeFromExternrefTable0(ret[0]);
|
|
2883
3214
|
}
|
|
2884
3215
|
|
|
3216
|
+
/**
|
|
3217
|
+
* Map the verdicts to `null` (store) or the blocking match `{id, reason, cosine}`.
|
|
3218
|
+
* @param {string} plan_json
|
|
3219
|
+
* @param {string} verdicts_json
|
|
3220
|
+
* @returns {string}
|
|
3221
|
+
*/
|
|
3222
|
+
export function resolveForgetJudge(plan_json, verdicts_json) {
|
|
3223
|
+
let deferred4_0;
|
|
3224
|
+
let deferred4_1;
|
|
3225
|
+
try {
|
|
3226
|
+
const ptr0 = passStringToWasm0(plan_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3227
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3228
|
+
const ptr1 = passStringToWasm0(verdicts_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3229
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3230
|
+
const ret = wasm.resolveForgetJudge(ptr0, len0, ptr1, len1);
|
|
3231
|
+
var ptr3 = ret[0];
|
|
3232
|
+
var len3 = ret[1];
|
|
3233
|
+
if (ret[3]) {
|
|
3234
|
+
ptr3 = 0; len3 = 0;
|
|
3235
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
3236
|
+
}
|
|
3237
|
+
deferred4_0 = ptr3;
|
|
3238
|
+
deferred4_1 = len3;
|
|
3239
|
+
return getStringFromWasm0(ptr3, len3);
|
|
3240
|
+
} finally {
|
|
3241
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
|
|
3245
|
+
/**
|
|
3246
|
+
* Map the verdicts (JSON array, one relation word or `null` per pair) to a
|
|
3247
|
+
* decision `{action, match, relation, judged}`.
|
|
3248
|
+
* @param {string} text
|
|
3249
|
+
* @param {string} plan_json
|
|
3250
|
+
* @param {string} verdicts_json
|
|
3251
|
+
* @returns {string}
|
|
3252
|
+
*/
|
|
3253
|
+
export function resolveJudgedWrite(text, plan_json, verdicts_json) {
|
|
3254
|
+
let deferred5_0;
|
|
3255
|
+
let deferred5_1;
|
|
3256
|
+
try {
|
|
3257
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3258
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3259
|
+
const ptr1 = passStringToWasm0(plan_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3260
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3261
|
+
const ptr2 = passStringToWasm0(verdicts_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3262
|
+
const len2 = WASM_VECTOR_LEN;
|
|
3263
|
+
const ret = wasm.resolveJudgedWrite(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
3264
|
+
var ptr4 = ret[0];
|
|
3265
|
+
var len4 = ret[1];
|
|
3266
|
+
if (ret[3]) {
|
|
3267
|
+
ptr4 = 0; len4 = 0;
|
|
3268
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
3269
|
+
}
|
|
3270
|
+
deferred5_0 = ptr4;
|
|
3271
|
+
deferred5_1 = len4;
|
|
3272
|
+
return getStringFromWasm0(ptr4, len4);
|
|
3273
|
+
} finally {
|
|
3274
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
|
|
2885
3278
|
/**
|
|
2886
3279
|
* Run the resolution formula on two contradicting claims; returns ResolutionOutcome JSON.
|
|
2887
3280
|
* @param {string} claim_a_json
|
|
@@ -3129,6 +3522,19 @@ export function signUserOp(hash_hex, private_key_hex) {
|
|
|
3129
3522
|
}
|
|
3130
3523
|
}
|
|
3131
3524
|
|
|
3525
|
+
/**
|
|
3526
|
+
* Sort ascending and deduplicate a list of tags (call before batching a query).
|
|
3527
|
+
* @param {any} tags
|
|
3528
|
+
* @returns {any}
|
|
3529
|
+
*/
|
|
3530
|
+
export function sortDedupTags(tags) {
|
|
3531
|
+
const ret = wasm.sortDedupTags(tags);
|
|
3532
|
+
if (ret[2]) {
|
|
3533
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3534
|
+
}
|
|
3535
|
+
return takeFromExternrefTable0(ret[0]);
|
|
3536
|
+
}
|
|
3537
|
+
|
|
3132
3538
|
/**
|
|
3133
3539
|
* Return the source weight multiplier for a given source string.
|
|
3134
3540
|
*
|
|
@@ -3261,6 +3667,18 @@ function __wbg_get_imports() {
|
|
|
3261
3667
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
3262
3668
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
3263
3669
|
},
|
|
3670
|
+
__wbg___wbindgen_boolean_get_a86c216575a75c30: function(arg0) {
|
|
3671
|
+
const v = arg0;
|
|
3672
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
3673
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
3674
|
+
},
|
|
3675
|
+
__wbg___wbindgen_debug_string_dd5d2d07ce9e6c57: function(arg0, arg1) {
|
|
3676
|
+
const ret = debugString(arg1);
|
|
3677
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3678
|
+
const len1 = WASM_VECTOR_LEN;
|
|
3679
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
3680
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
3681
|
+
},
|
|
3264
3682
|
__wbg___wbindgen_is_function_49868bde5eb1e745: function(arg0) {
|
|
3265
3683
|
const ret = typeof(arg0) === 'function';
|
|
3266
3684
|
return ret;
|
|
@@ -3278,9 +3696,31 @@ function __wbg_get_imports() {
|
|
|
3278
3696
|
const ret = arg0 === undefined;
|
|
3279
3697
|
return ret;
|
|
3280
3698
|
},
|
|
3699
|
+
__wbg___wbindgen_jsval_loose_eq_3a72ae764d46d944: function(arg0, arg1) {
|
|
3700
|
+
const ret = arg0 == arg1;
|
|
3701
|
+
return ret;
|
|
3702
|
+
},
|
|
3703
|
+
__wbg___wbindgen_number_get_7579aab02a8a620c: function(arg0, arg1) {
|
|
3704
|
+
const obj = arg1;
|
|
3705
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
3706
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
3707
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
3708
|
+
},
|
|
3709
|
+
__wbg___wbindgen_string_get_914df97fcfa788f2: function(arg0, arg1) {
|
|
3710
|
+
const obj = arg1;
|
|
3711
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
3712
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3713
|
+
var len1 = WASM_VECTOR_LEN;
|
|
3714
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
3715
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
3716
|
+
},
|
|
3281
3717
|
__wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
|
|
3282
3718
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
3283
3719
|
},
|
|
3720
|
+
__wbg_call_7f2987183bb62793: function() { return handleError(function (arg0, arg1) {
|
|
3721
|
+
const ret = arg0.call(arg1);
|
|
3722
|
+
return ret;
|
|
3723
|
+
}, arguments); },
|
|
3284
3724
|
__wbg_call_d578befcc3145dee: function() { return handleError(function (arg0, arg1, arg2) {
|
|
3285
3725
|
const ret = arg0.call(arg1, arg2);
|
|
3286
3726
|
return ret;
|
|
@@ -3289,6 +3729,10 @@ function __wbg_get_imports() {
|
|
|
3289
3729
|
const ret = arg0.crypto;
|
|
3290
3730
|
return ret;
|
|
3291
3731
|
},
|
|
3732
|
+
__wbg_done_547d467e97529006: function(arg0) {
|
|
3733
|
+
const ret = arg0.done;
|
|
3734
|
+
return ret;
|
|
3735
|
+
},
|
|
3292
3736
|
__wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
|
|
3293
3737
|
arg0.getRandomValues(arg1);
|
|
3294
3738
|
}, arguments); },
|
|
@@ -3299,10 +3743,50 @@ function __wbg_get_imports() {
|
|
|
3299
3743
|
const ret = arg0.getTime();
|
|
3300
3744
|
return ret;
|
|
3301
3745
|
},
|
|
3746
|
+
__wbg_get_ed0642c4b9d31ddf: function() { return handleError(function (arg0, arg1) {
|
|
3747
|
+
const ret = Reflect.get(arg0, arg1);
|
|
3748
|
+
return ret;
|
|
3749
|
+
}, arguments); },
|
|
3750
|
+
__wbg_get_unchecked_7d7babe32e9e6a54: function(arg0, arg1) {
|
|
3751
|
+
const ret = arg0[arg1 >>> 0];
|
|
3752
|
+
return ret;
|
|
3753
|
+
},
|
|
3754
|
+
__wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a: function(arg0) {
|
|
3755
|
+
let result;
|
|
3756
|
+
try {
|
|
3757
|
+
result = arg0 instanceof ArrayBuffer;
|
|
3758
|
+
} catch (_) {
|
|
3759
|
+
result = false;
|
|
3760
|
+
}
|
|
3761
|
+
const ret = result;
|
|
3762
|
+
return ret;
|
|
3763
|
+
},
|
|
3764
|
+
__wbg_instanceof_Uint8Array_4b8da683deb25d72: function(arg0) {
|
|
3765
|
+
let result;
|
|
3766
|
+
try {
|
|
3767
|
+
result = arg0 instanceof Uint8Array;
|
|
3768
|
+
} catch (_) {
|
|
3769
|
+
result = false;
|
|
3770
|
+
}
|
|
3771
|
+
const ret = result;
|
|
3772
|
+
return ret;
|
|
3773
|
+
},
|
|
3774
|
+
__wbg_isArray_db61795ad004c139: function(arg0) {
|
|
3775
|
+
const ret = Array.isArray(arg0);
|
|
3776
|
+
return ret;
|
|
3777
|
+
},
|
|
3778
|
+
__wbg_iterator_de403ef31815a3e6: function() {
|
|
3779
|
+
const ret = Symbol.iterator;
|
|
3780
|
+
return ret;
|
|
3781
|
+
},
|
|
3302
3782
|
__wbg_length_0c32cb8543c8e4c8: function(arg0) {
|
|
3303
3783
|
const ret = arg0.length;
|
|
3304
3784
|
return ret;
|
|
3305
3785
|
},
|
|
3786
|
+
__wbg_length_6e821edde497a532: function(arg0) {
|
|
3787
|
+
const ret = arg0.length;
|
|
3788
|
+
return ret;
|
|
3789
|
+
},
|
|
3306
3790
|
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
|
3307
3791
|
const ret = arg0.msCrypto;
|
|
3308
3792
|
return ret;
|
|
@@ -3319,6 +3803,10 @@ function __wbg_get_imports() {
|
|
|
3319
3803
|
const ret = new Map();
|
|
3320
3804
|
return ret;
|
|
3321
3805
|
},
|
|
3806
|
+
__wbg_new_a560378ea1240b14: function(arg0) {
|
|
3807
|
+
const ret = new Uint8Array(arg0);
|
|
3808
|
+
return ret;
|
|
3809
|
+
},
|
|
3322
3810
|
__wbg_new_f3c9df4f38f3f798: function() {
|
|
3323
3811
|
const ret = new Array();
|
|
3324
3812
|
return ret;
|
|
@@ -3327,6 +3815,14 @@ function __wbg_get_imports() {
|
|
|
3327
3815
|
const ret = new Uint8Array(arg0 >>> 0);
|
|
3328
3816
|
return ret;
|
|
3329
3817
|
},
|
|
3818
|
+
__wbg_next_01132ed6134b8ef5: function(arg0) {
|
|
3819
|
+
const ret = arg0.next;
|
|
3820
|
+
return ret;
|
|
3821
|
+
},
|
|
3822
|
+
__wbg_next_b3713ec761a9dbfd: function() { return handleError(function (arg0) {
|
|
3823
|
+
const ret = arg0.next();
|
|
3824
|
+
return ret;
|
|
3825
|
+
}, arguments); },
|
|
3330
3826
|
__wbg_node_84ea875411254db1: function(arg0) {
|
|
3331
3827
|
const ret = arg0.node;
|
|
3332
3828
|
return ret;
|
|
@@ -3383,6 +3879,10 @@ function __wbg_get_imports() {
|
|
|
3383
3879
|
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
3384
3880
|
return ret;
|
|
3385
3881
|
},
|
|
3882
|
+
__wbg_value_7f6052747ccf940f: function(arg0) {
|
|
3883
|
+
const ret = arg0.value;
|
|
3884
|
+
return ret;
|
|
3885
|
+
},
|
|
3386
3886
|
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
|
3387
3887
|
const ret = arg0.versions;
|
|
3388
3888
|
return ret;
|
|
@@ -3428,6 +3928,9 @@ function __wbg_get_imports() {
|
|
|
3428
3928
|
};
|
|
3429
3929
|
}
|
|
3430
3930
|
|
|
3931
|
+
const WasmBlindIndexerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3932
|
+
? { register: () => {}, unregister: () => {} }
|
|
3933
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmblindindexer_free(ptr >>> 0, 1));
|
|
3431
3934
|
const WasmLshHasherFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3432
3935
|
? { register: () => {}, unregister: () => {} }
|
|
3433
3936
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmlshhasher_free(ptr >>> 0, 1));
|
|
@@ -3444,6 +3947,71 @@ function _assertClass(instance, klass) {
|
|
|
3444
3947
|
}
|
|
3445
3948
|
}
|
|
3446
3949
|
|
|
3950
|
+
function debugString(val) {
|
|
3951
|
+
// primitive types
|
|
3952
|
+
const type = typeof val;
|
|
3953
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
3954
|
+
return `${val}`;
|
|
3955
|
+
}
|
|
3956
|
+
if (type == 'string') {
|
|
3957
|
+
return `"${val}"`;
|
|
3958
|
+
}
|
|
3959
|
+
if (type == 'symbol') {
|
|
3960
|
+
const description = val.description;
|
|
3961
|
+
if (description == null) {
|
|
3962
|
+
return 'Symbol';
|
|
3963
|
+
} else {
|
|
3964
|
+
return `Symbol(${description})`;
|
|
3965
|
+
}
|
|
3966
|
+
}
|
|
3967
|
+
if (type == 'function') {
|
|
3968
|
+
const name = val.name;
|
|
3969
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
3970
|
+
return `Function(${name})`;
|
|
3971
|
+
} else {
|
|
3972
|
+
return 'Function';
|
|
3973
|
+
}
|
|
3974
|
+
}
|
|
3975
|
+
// objects
|
|
3976
|
+
if (Array.isArray(val)) {
|
|
3977
|
+
const length = val.length;
|
|
3978
|
+
let debug = '[';
|
|
3979
|
+
if (length > 0) {
|
|
3980
|
+
debug += debugString(val[0]);
|
|
3981
|
+
}
|
|
3982
|
+
for(let i = 1; i < length; i++) {
|
|
3983
|
+
debug += ', ' + debugString(val[i]);
|
|
3984
|
+
}
|
|
3985
|
+
debug += ']';
|
|
3986
|
+
return debug;
|
|
3987
|
+
}
|
|
3988
|
+
// Test for built-in
|
|
3989
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
3990
|
+
let className;
|
|
3991
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
3992
|
+
className = builtInMatches[1];
|
|
3993
|
+
} else {
|
|
3994
|
+
// Failed to match the standard '[object ClassName]'
|
|
3995
|
+
return toString.call(val);
|
|
3996
|
+
}
|
|
3997
|
+
if (className == 'Object') {
|
|
3998
|
+
// we're a user defined class or Object
|
|
3999
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
4000
|
+
// easier than looping through ownProperties of `val`.
|
|
4001
|
+
try {
|
|
4002
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
4003
|
+
} catch (_) {
|
|
4004
|
+
return 'Object';
|
|
4005
|
+
}
|
|
4006
|
+
}
|
|
4007
|
+
// errors
|
|
4008
|
+
if (val instanceof Error) {
|
|
4009
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
4010
|
+
}
|
|
4011
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
4012
|
+
return className;
|
|
4013
|
+
}
|
|
4014
|
+
|
|
3447
4015
|
function getArrayF32FromWasm0(ptr, len) {
|
|
3448
4016
|
ptr = ptr >>> 0;
|
|
3449
4017
|
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|