@totalreclaw/core 2.7.0 → 2.8.0-rc.2

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.
@@ -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
  *
@@ -781,6 +882,58 @@ function computeScoreComponents(claim_json, now_unix_seconds, weights_json) {
781
882
  }
782
883
  exports.computeScoreComponents = computeScoreComponents;
783
884
 
885
+ /**
886
+ * State of one fact: `"active"`, `"inactive"` or `"missing"`. `"missing"` is
887
+ * not a confirmed delete. Throws on an unreadable response or a bad id/owner.
888
+ * @param {string} owner
889
+ * @param {string} id
890
+ * @param {string} response_json
891
+ * @returns {string}
892
+ */
893
+ function confirmLookupParse(owner, id, response_json) {
894
+ let deferred5_0;
895
+ let deferred5_1;
896
+ try {
897
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
898
+ const len0 = WASM_VECTOR_LEN;
899
+ const ptr1 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
900
+ const len1 = WASM_VECTOR_LEN;
901
+ const ptr2 = passStringToWasm0(response_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
902
+ const len2 = WASM_VECTOR_LEN;
903
+ const ret = wasm.confirmLookupParse(ptr0, len0, ptr1, len1, ptr2, len2);
904
+ var ptr4 = ret[0];
905
+ var len4 = ret[1];
906
+ if (ret[3]) {
907
+ ptr4 = 0; len4 = 0;
908
+ throw takeFromExternrefTable0(ret[2]);
909
+ }
910
+ deferred5_0 = ptr4;
911
+ deferred5_1 = len4;
912
+ return getStringFromWasm0(ptr4, len4);
913
+ } finally {
914
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
915
+ }
916
+ }
917
+ exports.confirmLookupParse = confirmLookupParse;
918
+
919
+ /**
920
+ * GraphQL query (`$ids` = `lookupIds`, `$owner`) for `confirmLookupParse`.
921
+ * @returns {string}
922
+ */
923
+ function confirmLookupQuery() {
924
+ let deferred1_0;
925
+ let deferred1_1;
926
+ try {
927
+ const ret = wasm.confirmLookupQuery();
928
+ deferred1_0 = ret[0];
929
+ deferred1_1 = ret[1];
930
+ return getStringFromWasm0(ret[0], ret[1]);
931
+ } finally {
932
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
933
+ }
934
+ }
935
+ exports.confirmLookupQuery = confirmLookupQuery;
936
+
784
937
  /**
785
938
  * Cosine similarity between two f32 vectors.
786
939
  * @param {Float32Array} a
@@ -1345,6 +1498,26 @@ function encodeFactProtobuf(json) {
1345
1498
  }
1346
1499
  exports.encodeFactProtobuf = encodeFactProtobuf;
1347
1500
 
1501
+ /**
1502
+ * Encode a scheme-1 fact: field 5 sorted and deduplicated, field 14 `index_scheme = 1`,
1503
+ * outer version always 4 (any `version` in the JSON is ignored). Same JSON as
1504
+ * `encodeFactProtobuf`; throws unless every `blind_indices` entry is 64 lowercase hex.
1505
+ * @param {string} json
1506
+ * @returns {Uint8Array}
1507
+ */
1508
+ function encodeFactProtobufKeyed(json) {
1509
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1510
+ const len0 = WASM_VECTOR_LEN;
1511
+ const ret = wasm.encodeFactProtobufKeyed(ptr0, len0);
1512
+ if (ret[3]) {
1513
+ throw takeFromExternrefTable0(ret[2]);
1514
+ }
1515
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1516
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1517
+ return v2;
1518
+ }
1519
+ exports.encodeFactProtobufKeyed = encodeFactProtobufKeyed;
1520
+
1348
1521
  /**
1349
1522
  * Encode a single fact submission as SimpleAccount.execute() calldata.
1350
1523
  *
@@ -1412,6 +1585,24 @@ function encodeTombstoneProtobuf(fact_id, owner, version) {
1412
1585
  }
1413
1586
  exports.encodeTombstoneProtobuf = encodeTombstoneProtobuf;
1414
1587
 
1588
+ /**
1589
+ * Encode a scheme-1 tombstone: outer version 4 plus field 14 `index_scheme = 1`.
1590
+ * @param {string} fact_id
1591
+ * @param {string} owner
1592
+ * @returns {Uint8Array}
1593
+ */
1594
+ function encodeTombstoneProtobufKeyed(fact_id, owner) {
1595
+ const ptr0 = passStringToWasm0(fact_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1596
+ const len0 = WASM_VECTOR_LEN;
1597
+ const ptr1 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1598
+ const len1 = WASM_VECTOR_LEN;
1599
+ const ret = wasm.encodeTombstoneProtobufKeyed(ptr0, len0, ptr1, len1);
1600
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1601
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1602
+ return v3;
1603
+ }
1604
+ exports.encodeTombstoneProtobufKeyed = encodeTombstoneProtobufKeyed;
1605
+
1415
1606
  /**
1416
1607
  * Encrypt a UTF-8 plaintext with XChaCha20-Poly1305.
1417
1608
  *
@@ -1788,6 +1979,37 @@ function generateContentFingerprint(plaintext, dedup_key_hex) {
1788
1979
  }
1789
1980
  exports.generateContentFingerprint = generateContentFingerprint;
1790
1981
 
1982
+ /**
1983
+ * Content fingerprint v2 (index scheme 1): HMAC under `fpKeyV2`, which core
1984
+ * derives from `dedupKey`. Not interchangeable with `generateContentFingerprint`.
1985
+ * @param {string} plaintext
1986
+ * @param {string} dedup_key_hex
1987
+ * @returns {string}
1988
+ */
1989
+ function generateContentFingerprintV2(plaintext, dedup_key_hex) {
1990
+ let deferred4_0;
1991
+ let deferred4_1;
1992
+ try {
1993
+ const ptr0 = passStringToWasm0(plaintext, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1994
+ const len0 = WASM_VECTOR_LEN;
1995
+ const ptr1 = passStringToWasm0(dedup_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1996
+ const len1 = WASM_VECTOR_LEN;
1997
+ const ret = wasm.generateContentFingerprintV2(ptr0, len0, ptr1, len1);
1998
+ var ptr3 = ret[0];
1999
+ var len3 = ret[1];
2000
+ if (ret[3]) {
2001
+ ptr3 = 0; len3 = 0;
2002
+ throw takeFromExternrefTable0(ret[2]);
2003
+ }
2004
+ deferred4_0 = ptr3;
2005
+ deferred4_1 = len3;
2006
+ return getStringFromWasm0(ptr3, len3);
2007
+ } finally {
2008
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
2009
+ }
2010
+ }
2011
+ exports.generateContentFingerprintV2 = generateContentFingerprintV2;
2012
+
1791
2013
  /**
1792
2014
  * Generate trapdoors for multiple query reformulations (expansion pipeline).
1793
2015
  *
@@ -1842,6 +2064,32 @@ function generateSearchTrapdoors(query, query_embedding, lsh_hasher) {
1842
2064
  }
1843
2065
  exports.generateSearchTrapdoors = generateSearchTrapdoors;
1844
2066
 
2067
+ /**
2068
+ * Keyed search trapdoors (index scheme 1): stem tags + one entity tag per name +
2069
+ * keyed LSH tags, sorted and deduplicated. `entity_names`: JSON array of strings.
2070
+ * Returns a JsValue (JSON array of hex strings); final, batch as is.
2071
+ * @param {string} query
2072
+ * @param {any} entity_names
2073
+ * @param {Float32Array} query_embedding
2074
+ * @param {WasmBlindIndexer} indexer
2075
+ * @param {WasmLshHasher} lsh_hasher
2076
+ * @returns {any}
2077
+ */
2078
+ function generateSearchTrapdoorsKeyed(query, entity_names, query_embedding, indexer, lsh_hasher) {
2079
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2080
+ const len0 = WASM_VECTOR_LEN;
2081
+ const ptr1 = passArrayF32ToWasm0(query_embedding, wasm.__wbindgen_malloc);
2082
+ const len1 = WASM_VECTOR_LEN;
2083
+ _assertClass(indexer, WasmBlindIndexer);
2084
+ _assertClass(lsh_hasher, WasmLshHasher);
2085
+ const ret = wasm.generateSearchTrapdoorsKeyed(ptr0, len0, entity_names, ptr1, len1, indexer.__wbg_ptr, lsh_hasher.__wbg_ptr);
2086
+ if (ret[2]) {
2087
+ throw takeFromExternrefTable0(ret[1]);
2088
+ }
2089
+ return takeFromExternrefTable0(ret[0]);
2090
+ }
2091
+ exports.generateSearchTrapdoorsKeyed = generateSearchTrapdoorsKeyed;
2092
+
1845
2093
  /**
1846
2094
  * Get the GraphQL query string for broadened (fallback) search.
1847
2095
  * @returns {string}
@@ -2282,6 +2530,37 @@ function isValidMemoryType(value) {
2282
2530
  }
2283
2531
  exports.isValidMemoryType = isValidMemoryType;
2284
2532
 
2533
+ /**
2534
+ * The same-fact judge prompt for one pair: JSON `{system, user}`. Line
2535
+ * breaks in either text are collapsed to spaces.
2536
+ * @param {string} existing
2537
+ * @param {string} candidate
2538
+ * @returns {string}
2539
+ */
2540
+ function judgePrompt(existing, candidate) {
2541
+ let deferred4_0;
2542
+ let deferred4_1;
2543
+ try {
2544
+ const ptr0 = passStringToWasm0(existing, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2545
+ const len0 = WASM_VECTOR_LEN;
2546
+ const ptr1 = passStringToWasm0(candidate, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2547
+ const len1 = WASM_VECTOR_LEN;
2548
+ const ret = wasm.judgePrompt(ptr0, len0, ptr1, len1);
2549
+ var ptr3 = ret[0];
2550
+ var len3 = ret[1];
2551
+ if (ret[3]) {
2552
+ ptr3 = 0; len3 = 0;
2553
+ throw takeFromExternrefTable0(ret[2]);
2554
+ }
2555
+ deferred4_0 = ptr3;
2556
+ deferred4_1 = len3;
2557
+ return getStringFromWasm0(ptr3, len3);
2558
+ } finally {
2559
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
2560
+ }
2561
+ }
2562
+ exports.judgePrompt = judgePrompt;
2563
+
2285
2564
  /**
2286
2565
  * Return the v1 legacy-claim fallback weight (applied to candidates that
2287
2566
  * have no `source` field).
@@ -2293,6 +2572,40 @@ function legacyClaimFallbackWeight() {
2293
2572
  }
2294
2573
  exports.legacyClaimFallbackWeight = legacyClaimFallbackWeight;
2295
2574
 
2575
+ /**
2576
+ * On-chain `decayScore` for every LIVE fact (always `1.0`; #789).
2577
+ *
2578
+ * `0` = tombstone, `1.0` = live; carries no importance. Never use for tombstones.
2579
+ * @returns {number}
2580
+ */
2581
+ function liveDecayScore() {
2582
+ const ret = wasm.liveDecayScore();
2583
+ return ret;
2584
+ }
2585
+ exports.liveDecayScore = liveDecayScore;
2586
+
2587
+ /**
2588
+ * Ids to request for one fact on V1 or V2 (`id_in`), in precedence order.
2589
+ * Throws like `toSubgraphId`.
2590
+ * @param {string} owner
2591
+ * @param {string} id
2592
+ * @returns {string[]}
2593
+ */
2594
+ function lookupIds(owner, id) {
2595
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2596
+ const len0 = WASM_VECTOR_LEN;
2597
+ const ptr1 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2598
+ const len1 = WASM_VECTOR_LEN;
2599
+ const ret = wasm.lookupIds(ptr0, len0, ptr1, len1);
2600
+ if (ret[3]) {
2601
+ throw takeFromExternrefTable0(ret[2]);
2602
+ }
2603
+ var v3 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
2604
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
2605
+ return v3;
2606
+ }
2607
+ exports.lookupIds = lookupIds;
2608
+
2296
2609
  /**
2297
2610
  * Map a v1 type to its short-form category key.
2298
2611
  *
@@ -2565,6 +2878,34 @@ function parseGemini(input) {
2565
2878
  }
2566
2879
  exports.parseGemini = parseGemini;
2567
2880
 
2881
+ /**
2882
+ * Parse a judge reply. Returns JSON: `"SAME"` (one of the seven relation
2883
+ * words, upper case) or `null`.
2884
+ * @param {string} raw
2885
+ * @returns {string}
2886
+ */
2887
+ function parseJudgeAnswer(raw) {
2888
+ let deferred3_0;
2889
+ let deferred3_1;
2890
+ try {
2891
+ const ptr0 = passStringToWasm0(raw, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2892
+ const len0 = WASM_VECTOR_LEN;
2893
+ const ret = wasm.parseJudgeAnswer(ptr0, len0);
2894
+ var ptr2 = ret[0];
2895
+ var len2 = ret[1];
2896
+ if (ret[3]) {
2897
+ ptr2 = 0; len2 = 0;
2898
+ throw takeFromExternrefTable0(ret[2]);
2899
+ }
2900
+ deferred3_0 = ptr2;
2901
+ deferred3_1 = len2;
2902
+ return getStringFromWasm0(ptr2, len2);
2903
+ } finally {
2904
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2905
+ }
2906
+ }
2907
+ exports.parseJudgeAnswer = parseJudgeAnswer;
2908
+
2568
2909
  /**
2569
2910
  * Case-insensitive parse of a memory source string. Unknown input returns "user-inferred".
2570
2911
  * @param {string} s
@@ -2783,6 +3124,80 @@ function pinBoost(tier_json, now_unix, config_json) {
2783
3124
  }
2784
3125
  exports.pinBoost = pinBoost;
2785
3126
 
3127
+ /**
3128
+ * Pick the forgotten entries the LLM should judge for a candidate.
3129
+ *
3130
+ * `entriesJson`: JSON array of `{id, text, embedding?}`. Returns a plan:
3131
+ * `{"kind":"decided","match":null|{...}}` or
3132
+ * `{"kind":"ask","pairs":[...],"fallback":...,"unjudged":...}`.
3133
+ * @param {string} text
3134
+ * @param {string} embedding_json
3135
+ * @param {string} entries_json
3136
+ * @returns {string}
3137
+ */
3138
+ function planForgetJudge(text, embedding_json, entries_json) {
3139
+ let deferred5_0;
3140
+ let deferred5_1;
3141
+ try {
3142
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3143
+ const len0 = WASM_VECTOR_LEN;
3144
+ const ptr1 = passStringToWasm0(embedding_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3145
+ const len1 = WASM_VECTOR_LEN;
3146
+ const ptr2 = passStringToWasm0(entries_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3147
+ const len2 = WASM_VECTOR_LEN;
3148
+ const ret = wasm.planForgetJudge(ptr0, len0, ptr1, len1, ptr2, len2);
3149
+ var ptr4 = ret[0];
3150
+ var len4 = ret[1];
3151
+ if (ret[3]) {
3152
+ ptr4 = 0; len4 = 0;
3153
+ throw takeFromExternrefTable0(ret[2]);
3154
+ }
3155
+ deferred5_0 = ptr4;
3156
+ deferred5_1 = len4;
3157
+ return getStringFromWasm0(ptr4, len4);
3158
+ } finally {
3159
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
3160
+ }
3161
+ }
3162
+ exports.planForgetJudge = planForgetJudge;
3163
+
3164
+ /**
3165
+ * Pick the pairs the LLM should judge for a new fact (auto mode).
3166
+ *
3167
+ * `candidatesJson`: JSON array of `{id, text, embedding?, pinned?, pending?}`.
3168
+ * Returns a plan: `{"kind":"decided","decision":{...}}` or
3169
+ * `{"kind":"ask","pairs":[...],"fallback":{...}}`.
3170
+ * @param {string} text
3171
+ * @param {string} embedding_json
3172
+ * @param {string} candidates_json
3173
+ * @returns {string}
3174
+ */
3175
+ function planJudgedWrite(text, embedding_json, candidates_json) {
3176
+ let deferred5_0;
3177
+ let deferred5_1;
3178
+ try {
3179
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3180
+ const len0 = WASM_VECTOR_LEN;
3181
+ const ptr1 = passStringToWasm0(embedding_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3182
+ const len1 = WASM_VECTOR_LEN;
3183
+ const ptr2 = passStringToWasm0(candidates_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3184
+ const len2 = WASM_VECTOR_LEN;
3185
+ const ret = wasm.planJudgedWrite(ptr0, len0, ptr1, len1, ptr2, len2);
3186
+ var ptr4 = ret[0];
3187
+ var len4 = ret[1];
3188
+ if (ret[3]) {
3189
+ ptr4 = 0; len4 = 0;
3190
+ throw takeFromExternrefTable0(ret[2]);
3191
+ }
3192
+ deferred5_0 = ptr4;
3193
+ deferred5_1 = len4;
3194
+ return getStringFromWasm0(ptr4, len4);
3195
+ } finally {
3196
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
3197
+ }
3198
+ }
3199
+ exports.planJudgedWrite = planJudgedWrite;
3200
+
2786
3201
  /**
2787
3202
  * Prepare a fact for on-chain storage.
2788
3203
  *
@@ -3004,6 +3419,70 @@ function rerankWithConfig(query, query_embedding, candidates_json, top_k, apply_
3004
3419
  }
3005
3420
  exports.rerankWithConfig = rerankWithConfig;
3006
3421
 
3422
+ /**
3423
+ * Map the verdicts to `null` (store) or the blocking match `{id, reason, cosine}`.
3424
+ * @param {string} plan_json
3425
+ * @param {string} verdicts_json
3426
+ * @returns {string}
3427
+ */
3428
+ function resolveForgetJudge(plan_json, verdicts_json) {
3429
+ let deferred4_0;
3430
+ let deferred4_1;
3431
+ try {
3432
+ const ptr0 = passStringToWasm0(plan_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3433
+ const len0 = WASM_VECTOR_LEN;
3434
+ const ptr1 = passStringToWasm0(verdicts_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3435
+ const len1 = WASM_VECTOR_LEN;
3436
+ const ret = wasm.resolveForgetJudge(ptr0, len0, ptr1, len1);
3437
+ var ptr3 = ret[0];
3438
+ var len3 = ret[1];
3439
+ if (ret[3]) {
3440
+ ptr3 = 0; len3 = 0;
3441
+ throw takeFromExternrefTable0(ret[2]);
3442
+ }
3443
+ deferred4_0 = ptr3;
3444
+ deferred4_1 = len3;
3445
+ return getStringFromWasm0(ptr3, len3);
3446
+ } finally {
3447
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
3448
+ }
3449
+ }
3450
+ exports.resolveForgetJudge = resolveForgetJudge;
3451
+
3452
+ /**
3453
+ * Map the verdicts (JSON array, one relation word or `null` per pair) to a
3454
+ * decision `{action, match, relation, judged}`.
3455
+ * @param {string} text
3456
+ * @param {string} plan_json
3457
+ * @param {string} verdicts_json
3458
+ * @returns {string}
3459
+ */
3460
+ function resolveJudgedWrite(text, plan_json, verdicts_json) {
3461
+ let deferred5_0;
3462
+ let deferred5_1;
3463
+ try {
3464
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3465
+ const len0 = WASM_VECTOR_LEN;
3466
+ const ptr1 = passStringToWasm0(plan_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3467
+ const len1 = WASM_VECTOR_LEN;
3468
+ const ptr2 = passStringToWasm0(verdicts_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3469
+ const len2 = WASM_VECTOR_LEN;
3470
+ const ret = wasm.resolveJudgedWrite(ptr0, len0, ptr1, len1, ptr2, len2);
3471
+ var ptr4 = ret[0];
3472
+ var len4 = ret[1];
3473
+ if (ret[3]) {
3474
+ ptr4 = 0; len4 = 0;
3475
+ throw takeFromExternrefTable0(ret[2]);
3476
+ }
3477
+ deferred5_0 = ptr4;
3478
+ deferred5_1 = len4;
3479
+ return getStringFromWasm0(ptr4, len4);
3480
+ } finally {
3481
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
3482
+ }
3483
+ }
3484
+ exports.resolveJudgedWrite = resolveJudgedWrite;
3485
+
3007
3486
  /**
3008
3487
  * Run the resolution formula on two contradicting claims; returns ResolutionOutcome JSON.
3009
3488
  * @param {string} claim_a_json
@@ -3186,6 +3665,35 @@ function segmentSessions(timestamps_json, embeddings_json, gap_seconds, sim_thre
3186
3665
  }
3187
3666
  exports.segmentSessions = segmentSessions;
3188
3667
 
3668
+ /**
3669
+ * JSON text of the fact's row, byte for byte, or `undefined` when the subgraph
3670
+ * answered without one. For any `facts(where: {id_in, owner})` query that
3671
+ * selects `id`, `owner` and `isActive`. Throws like `confirmLookupParse`.
3672
+ * @param {string} owner
3673
+ * @param {string} id
3674
+ * @param {string} response_json
3675
+ * @returns {string | undefined}
3676
+ */
3677
+ function selectFactRow(owner, id, response_json) {
3678
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3679
+ const len0 = WASM_VECTOR_LEN;
3680
+ const ptr1 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3681
+ const len1 = WASM_VECTOR_LEN;
3682
+ const ptr2 = passStringToWasm0(response_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3683
+ const len2 = WASM_VECTOR_LEN;
3684
+ const ret = wasm.selectFactRow(ptr0, len0, ptr1, len1, ptr2, len2);
3685
+ if (ret[3]) {
3686
+ throw takeFromExternrefTable0(ret[2]);
3687
+ }
3688
+ let v4;
3689
+ if (ret[0] !== 0) {
3690
+ v4 = getStringFromWasm0(ret[0], ret[1]).slice();
3691
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
3692
+ }
3693
+ return v4;
3694
+ }
3695
+ exports.selectFactRow = selectFactRow;
3696
+
3189
3697
  /**
3190
3698
  * Serialize a WeightsFile JSON to pretty-printed JSON (2-space indent).
3191
3699
  * @param {string} file_json
@@ -3259,6 +3767,20 @@ function signUserOp(hash_hex, private_key_hex) {
3259
3767
  }
3260
3768
  exports.signUserOp = signUserOp;
3261
3769
 
3770
+ /**
3771
+ * Sort ascending and deduplicate a list of tags (call before batching a query).
3772
+ * @param {any} tags
3773
+ * @returns {any}
3774
+ */
3775
+ function sortDedupTags(tags) {
3776
+ const ret = wasm.sortDedupTags(tags);
3777
+ if (ret[2]) {
3778
+ throw takeFromExternrefTable0(ret[1]);
3779
+ }
3780
+ return takeFromExternrefTable0(ret[0]);
3781
+ }
3782
+ exports.sortDedupTags = sortDedupTags;
3783
+
3262
3784
  /**
3263
3785
  * Return the source weight multiplier for a given source string.
3264
3786
  *
@@ -3279,6 +3801,68 @@ function sourceWeight(source) {
3279
3801
  }
3280
3802
  exports.sourceWeight = sourceWeight;
3281
3803
 
3804
+ /**
3805
+ * Payload id: `id` without the owner's own prefix. Use it for every write and
3806
+ * every stored id. Throws on a non-address owner or an empty id.
3807
+ * @param {string} owner
3808
+ * @param {string} id
3809
+ * @returns {string}
3810
+ */
3811
+ function toPayloadId(owner, id) {
3812
+ let deferred4_0;
3813
+ let deferred4_1;
3814
+ try {
3815
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3816
+ const len0 = WASM_VECTOR_LEN;
3817
+ const ptr1 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3818
+ const len1 = WASM_VECTOR_LEN;
3819
+ const ret = wasm.toPayloadId(ptr0, len0, ptr1, len1);
3820
+ var ptr3 = ret[0];
3821
+ var len3 = ret[1];
3822
+ if (ret[3]) {
3823
+ ptr3 = 0; len3 = 0;
3824
+ throw takeFromExternrefTable0(ret[2]);
3825
+ }
3826
+ deferred4_0 = ptr3;
3827
+ deferred4_1 = len3;
3828
+ return getStringFromWasm0(ptr3, len3);
3829
+ } finally {
3830
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
3831
+ }
3832
+ }
3833
+ exports.toPayloadId = toPayloadId;
3834
+
3835
+ /**
3836
+ * V2 subgraph id `<owner>:<payload id>` from either form of a fact id.
3837
+ * Throws on a non-address owner, an empty id or another account's prefix.
3838
+ * @param {string} owner
3839
+ * @param {string} id
3840
+ * @returns {string}
3841
+ */
3842
+ function toSubgraphId(owner, id) {
3843
+ let deferred4_0;
3844
+ let deferred4_1;
3845
+ try {
3846
+ const ptr0 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3847
+ const len0 = WASM_VECTOR_LEN;
3848
+ const ptr1 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3849
+ const len1 = WASM_VECTOR_LEN;
3850
+ const ret = wasm.toSubgraphId(ptr0, len0, ptr1, len1);
3851
+ var ptr3 = ret[0];
3852
+ var len3 = ret[1];
3853
+ if (ret[3]) {
3854
+ ptr3 = 0; len3 = 0;
3855
+ throw takeFromExternrefTable0(ret[2]);
3856
+ }
3857
+ deferred4_0 = ptr3;
3858
+ deferred4_1 = len3;
3859
+ return getStringFromWasm0(ptr3, len3);
3860
+ } finally {
3861
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
3862
+ }
3863
+ }
3864
+ exports.toSubgraphId = toSubgraphId;
3865
+
3282
3866
  /**
3283
3867
  * Validate a `derived-bundle-v1` JSON string against every invariant in
3284
3868
  * derived-bundle-v1.md §4.7. Throws on any violation; resolves to nothing
@@ -3398,6 +3982,18 @@ function __wbg_get_imports() {
3398
3982
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3399
3983
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3400
3984
  },
3985
+ __wbg___wbindgen_boolean_get_a86c216575a75c30: function(arg0) {
3986
+ const v = arg0;
3987
+ const ret = typeof(v) === 'boolean' ? v : undefined;
3988
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
3989
+ },
3990
+ __wbg___wbindgen_debug_string_dd5d2d07ce9e6c57: function(arg0, arg1) {
3991
+ const ret = debugString(arg1);
3992
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3993
+ const len1 = WASM_VECTOR_LEN;
3994
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3995
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3996
+ },
3401
3997
  __wbg___wbindgen_is_function_49868bde5eb1e745: function(arg0) {
3402
3998
  const ret = typeof(arg0) === 'function';
3403
3999
  return ret;
@@ -3415,9 +4011,31 @@ function __wbg_get_imports() {
3415
4011
  const ret = arg0 === undefined;
3416
4012
  return ret;
3417
4013
  },
4014
+ __wbg___wbindgen_jsval_loose_eq_3a72ae764d46d944: function(arg0, arg1) {
4015
+ const ret = arg0 == arg1;
4016
+ return ret;
4017
+ },
4018
+ __wbg___wbindgen_number_get_7579aab02a8a620c: function(arg0, arg1) {
4019
+ const obj = arg1;
4020
+ const ret = typeof(obj) === 'number' ? obj : undefined;
4021
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
4022
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
4023
+ },
4024
+ __wbg___wbindgen_string_get_914df97fcfa788f2: function(arg0, arg1) {
4025
+ const obj = arg1;
4026
+ const ret = typeof(obj) === 'string' ? obj : undefined;
4027
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4028
+ var len1 = WASM_VECTOR_LEN;
4029
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
4030
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
4031
+ },
3418
4032
  __wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
3419
4033
  throw new Error(getStringFromWasm0(arg0, arg1));
3420
4034
  },
4035
+ __wbg_call_7f2987183bb62793: function() { return handleError(function (arg0, arg1) {
4036
+ const ret = arg0.call(arg1);
4037
+ return ret;
4038
+ }, arguments); },
3421
4039
  __wbg_call_d578befcc3145dee: function() { return handleError(function (arg0, arg1, arg2) {
3422
4040
  const ret = arg0.call(arg1, arg2);
3423
4041
  return ret;
@@ -3426,6 +4044,10 @@ function __wbg_get_imports() {
3426
4044
  const ret = arg0.crypto;
3427
4045
  return ret;
3428
4046
  },
4047
+ __wbg_done_547d467e97529006: function(arg0) {
4048
+ const ret = arg0.done;
4049
+ return ret;
4050
+ },
3429
4051
  __wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
3430
4052
  arg0.getRandomValues(arg1);
3431
4053
  }, arguments); },
@@ -3436,10 +4058,50 @@ function __wbg_get_imports() {
3436
4058
  const ret = arg0.getTime();
3437
4059
  return ret;
3438
4060
  },
4061
+ __wbg_get_ed0642c4b9d31ddf: function() { return handleError(function (arg0, arg1) {
4062
+ const ret = Reflect.get(arg0, arg1);
4063
+ return ret;
4064
+ }, arguments); },
4065
+ __wbg_get_unchecked_7d7babe32e9e6a54: function(arg0, arg1) {
4066
+ const ret = arg0[arg1 >>> 0];
4067
+ return ret;
4068
+ },
4069
+ __wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a: function(arg0) {
4070
+ let result;
4071
+ try {
4072
+ result = arg0 instanceof ArrayBuffer;
4073
+ } catch (_) {
4074
+ result = false;
4075
+ }
4076
+ const ret = result;
4077
+ return ret;
4078
+ },
4079
+ __wbg_instanceof_Uint8Array_4b8da683deb25d72: function(arg0) {
4080
+ let result;
4081
+ try {
4082
+ result = arg0 instanceof Uint8Array;
4083
+ } catch (_) {
4084
+ result = false;
4085
+ }
4086
+ const ret = result;
4087
+ return ret;
4088
+ },
4089
+ __wbg_isArray_db61795ad004c139: function(arg0) {
4090
+ const ret = Array.isArray(arg0);
4091
+ return ret;
4092
+ },
4093
+ __wbg_iterator_de403ef31815a3e6: function() {
4094
+ const ret = Symbol.iterator;
4095
+ return ret;
4096
+ },
3439
4097
  __wbg_length_0c32cb8543c8e4c8: function(arg0) {
3440
4098
  const ret = arg0.length;
3441
4099
  return ret;
3442
4100
  },
4101
+ __wbg_length_6e821edde497a532: function(arg0) {
4102
+ const ret = arg0.length;
4103
+ return ret;
4104
+ },
3443
4105
  __wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
3444
4106
  const ret = arg0.msCrypto;
3445
4107
  return ret;
@@ -3456,6 +4118,14 @@ function __wbg_get_imports() {
3456
4118
  const ret = new Map();
3457
4119
  return ret;
3458
4120
  },
4121
+ __wbg_new_a560378ea1240b14: function(arg0) {
4122
+ const ret = new Uint8Array(arg0);
4123
+ return ret;
4124
+ },
4125
+ __wbg_new_e3b04b4d53d1b593: function(arg0, arg1) {
4126
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
4127
+ return ret;
4128
+ },
3459
4129
  __wbg_new_f3c9df4f38f3f798: function() {
3460
4130
  const ret = new Array();
3461
4131
  return ret;
@@ -3464,6 +4134,14 @@ function __wbg_get_imports() {
3464
4134
  const ret = new Uint8Array(arg0 >>> 0);
3465
4135
  return ret;
3466
4136
  },
4137
+ __wbg_next_01132ed6134b8ef5: function(arg0) {
4138
+ const ret = arg0.next;
4139
+ return ret;
4140
+ },
4141
+ __wbg_next_b3713ec761a9dbfd: function() { return handleError(function (arg0) {
4142
+ const ret = arg0.next();
4143
+ return ret;
4144
+ }, arguments); },
3467
4145
  __wbg_node_84ea875411254db1: function(arg0) {
3468
4146
  const ret = arg0.node;
3469
4147
  return ret;
@@ -3500,6 +4178,9 @@ function __wbg_get_imports() {
3500
4178
  const ret = Reflect.set(arg0, arg1, arg2);
3501
4179
  return ret;
3502
4180
  }, arguments); },
4181
+ __wbg_set_name_ab9c98596fd7310a: function(arg0, arg1, arg2) {
4182
+ arg0.name = getStringFromWasm0(arg1, arg2);
4183
+ },
3503
4184
  __wbg_static_accessor_GLOBAL_THIS_a1248013d790bf5f: function() {
3504
4185
  const ret = typeof globalThis === 'undefined' ? null : globalThis;
3505
4186
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
@@ -3520,6 +4201,10 @@ function __wbg_get_imports() {
3520
4201
  const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
3521
4202
  return ret;
3522
4203
  },
4204
+ __wbg_value_7f6052747ccf940f: function(arg0) {
4205
+ const ret = arg0.value;
4206
+ return ret;
4207
+ },
3523
4208
  __wbg_versions_276b2795b1c6a219: function(arg0) {
3524
4209
  const ret = arg0.versions;
3525
4210
  return ret;
@@ -3565,6 +4250,9 @@ function __wbg_get_imports() {
3565
4250
  };
3566
4251
  }
3567
4252
 
4253
+ const WasmBlindIndexerFinalization = (typeof FinalizationRegistry === 'undefined')
4254
+ ? { register: () => {}, unregister: () => {} }
4255
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmblindindexer_free(ptr >>> 0, 1));
3568
4256
  const WasmLshHasherFinalization = (typeof FinalizationRegistry === 'undefined')
3569
4257
  ? { register: () => {}, unregister: () => {} }
3570
4258
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmlshhasher_free(ptr >>> 0, 1));
@@ -3581,11 +4269,87 @@ function _assertClass(instance, klass) {
3581
4269
  }
3582
4270
  }
3583
4271
 
4272
+ function debugString(val) {
4273
+ // primitive types
4274
+ const type = typeof val;
4275
+ if (type == 'number' || type == 'boolean' || val == null) {
4276
+ return `${val}`;
4277
+ }
4278
+ if (type == 'string') {
4279
+ return `"${val}"`;
4280
+ }
4281
+ if (type == 'symbol') {
4282
+ const description = val.description;
4283
+ if (description == null) {
4284
+ return 'Symbol';
4285
+ } else {
4286
+ return `Symbol(${description})`;
4287
+ }
4288
+ }
4289
+ if (type == 'function') {
4290
+ const name = val.name;
4291
+ if (typeof name == 'string' && name.length > 0) {
4292
+ return `Function(${name})`;
4293
+ } else {
4294
+ return 'Function';
4295
+ }
4296
+ }
4297
+ // objects
4298
+ if (Array.isArray(val)) {
4299
+ const length = val.length;
4300
+ let debug = '[';
4301
+ if (length > 0) {
4302
+ debug += debugString(val[0]);
4303
+ }
4304
+ for(let i = 1; i < length; i++) {
4305
+ debug += ', ' + debugString(val[i]);
4306
+ }
4307
+ debug += ']';
4308
+ return debug;
4309
+ }
4310
+ // Test for built-in
4311
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
4312
+ let className;
4313
+ if (builtInMatches && builtInMatches.length > 1) {
4314
+ className = builtInMatches[1];
4315
+ } else {
4316
+ // Failed to match the standard '[object ClassName]'
4317
+ return toString.call(val);
4318
+ }
4319
+ if (className == 'Object') {
4320
+ // we're a user defined class or Object
4321
+ // JSON.stringify avoids problems with cycles, and is generally much
4322
+ // easier than looping through ownProperties of `val`.
4323
+ try {
4324
+ return 'Object(' + JSON.stringify(val) + ')';
4325
+ } catch (_) {
4326
+ return 'Object';
4327
+ }
4328
+ }
4329
+ // errors
4330
+ if (val instanceof Error) {
4331
+ return `${val.name}: ${val.message}\n${val.stack}`;
4332
+ }
4333
+ // TODO we could test for more things here, like `Set`s and `Map`s.
4334
+ return className;
4335
+ }
4336
+
3584
4337
  function getArrayF32FromWasm0(ptr, len) {
3585
4338
  ptr = ptr >>> 0;
3586
4339
  return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
3587
4340
  }
3588
4341
 
4342
+ function getArrayJsValueFromWasm0(ptr, len) {
4343
+ ptr = ptr >>> 0;
4344
+ const mem = getDataViewMemory0();
4345
+ const result = [];
4346
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
4347
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
4348
+ }
4349
+ wasm.__externref_drop_slice(ptr, len);
4350
+ return result;
4351
+ }
4352
+
3589
4353
  function getArrayU8FromWasm0(ptr, len) {
3590
4354
  ptr = ptr >>> 0;
3591
4355
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);