@totalreclaw/core 2.5.4 → 2.5.6
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/{totalreclaw_core.d.ts → nodejs/totalreclaw_core.d.ts} +23 -0
- package/{totalreclaw_core.js → nodejs/totalreclaw_core.js} +47 -3
- package/nodejs/totalreclaw_core_bg.wasm +0 -0
- package/nodejs/totalreclaw_core_bg.wasm.d.ts +141 -0
- package/package.json +18 -9
- package/web/README.md +40 -0
- package/web/package.json +3 -0
- package/web/totalreclaw_core.d.ts +1116 -0
- package/web/totalreclaw_core.js +3311 -0
- package/web/totalreclaw_core_bg.wasm +0 -0
- package/web/totalreclaw_core_bg.wasm.d.ts +141 -0
- package/totalreclaw_core_bg.wasm +0 -0
- /package/{README.md → nodejs/README.md} +0 -0
|
@@ -0,0 +1,3311 @@
|
|
|
1
|
+
/* @ts-self-types="./totalreclaw_core.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Contradiction candidate cap constant.
|
|
5
|
+
* @returns {number}
|
|
6
|
+
*/
|
|
7
|
+
export function CONTRADICTION_CANDIDATE_CAP() {
|
|
8
|
+
const ret = wasm.CONTRADICTION_CANDIDATE_CAP();
|
|
9
|
+
return ret >>> 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Decision log max lines constant.
|
|
14
|
+
* @returns {number}
|
|
15
|
+
*/
|
|
16
|
+
export function DECISION_LOG_MAX_LINES() {
|
|
17
|
+
const ret = wasm.DECISION_LOG_MAX_LINES();
|
|
18
|
+
return ret >>> 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Tie-zone score tolerance constant.
|
|
23
|
+
* @returns {number}
|
|
24
|
+
*/
|
|
25
|
+
export function TIE_ZONE_SCORE_TOLERANCE() {
|
|
26
|
+
const ret = wasm.TIE_ZONE_SCORE_TOLERANCE();
|
|
27
|
+
return ret;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Random Hyperplane LSH hasher (WASM wrapper).
|
|
32
|
+
*
|
|
33
|
+
* Construct with `new WasmLshHasher(seedHex, dims)`.
|
|
34
|
+
* Call `hash(embeddingFloat64Array)` to get bucket IDs.
|
|
35
|
+
*/
|
|
36
|
+
export class WasmLshHasher {
|
|
37
|
+
static __wrap(ptr) {
|
|
38
|
+
ptr = ptr >>> 0;
|
|
39
|
+
const obj = Object.create(WasmLshHasher.prototype);
|
|
40
|
+
obj.__wbg_ptr = ptr;
|
|
41
|
+
WasmLshHasherFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
42
|
+
return obj;
|
|
43
|
+
}
|
|
44
|
+
__destroy_into_raw() {
|
|
45
|
+
const ptr = this.__wbg_ptr;
|
|
46
|
+
this.__wbg_ptr = 0;
|
|
47
|
+
WasmLshHasherFinalization.unregister(this);
|
|
48
|
+
return ptr;
|
|
49
|
+
}
|
|
50
|
+
free() {
|
|
51
|
+
const ptr = this.__destroy_into_raw();
|
|
52
|
+
wasm.__wbg_wasmlshhasher_free(ptr, 0);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Bits per table.
|
|
56
|
+
* @returns {number}
|
|
57
|
+
*/
|
|
58
|
+
get bits() {
|
|
59
|
+
const ret = wasm.wasmlshhasher_bits(this.__wbg_ptr);
|
|
60
|
+
return ret >>> 0;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Embedding dimensionality.
|
|
64
|
+
* @returns {number}
|
|
65
|
+
*/
|
|
66
|
+
get dimensions() {
|
|
67
|
+
const ret = wasm.wasmlshhasher_dimensions(this.__wbg_ptr);
|
|
68
|
+
return ret >>> 0;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Hash an embedding vector to blind-hashed bucket IDs.
|
|
72
|
+
*
|
|
73
|
+
* `embedding`: Float64Array of length `dims`.
|
|
74
|
+
* Returns a JSON array of hex strings (one per table).
|
|
75
|
+
* @param {Float64Array} embedding
|
|
76
|
+
* @returns {any}
|
|
77
|
+
*/
|
|
78
|
+
hash(embedding) {
|
|
79
|
+
const ptr0 = passArrayF64ToWasm0(embedding, wasm.__wbindgen_malloc);
|
|
80
|
+
const len0 = WASM_VECTOR_LEN;
|
|
81
|
+
const ret = wasm.wasmlshhasher_hash(this.__wbg_ptr, ptr0, len0);
|
|
82
|
+
if (ret[2]) {
|
|
83
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
84
|
+
}
|
|
85
|
+
return takeFromExternrefTable0(ret[0]);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Create a new LSH hasher with default parameters (20 tables, 32 bits).
|
|
89
|
+
*
|
|
90
|
+
* `seed_hex`: hex-encoded seed (>= 32 chars = 16 bytes).
|
|
91
|
+
* `dims`: embedding dimensionality (e.g. 640).
|
|
92
|
+
* @param {string} seed_hex
|
|
93
|
+
* @param {number} dims
|
|
94
|
+
*/
|
|
95
|
+
constructor(seed_hex, dims) {
|
|
96
|
+
const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
97
|
+
const len0 = WASM_VECTOR_LEN;
|
|
98
|
+
const ret = wasm.wasmlshhasher_new(ptr0, len0, dims);
|
|
99
|
+
if (ret[2]) {
|
|
100
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
101
|
+
}
|
|
102
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
103
|
+
WasmLshHasherFinalization.register(this, this.__wbg_ptr, this);
|
|
104
|
+
return this;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Number of hash tables.
|
|
108
|
+
* @returns {number}
|
|
109
|
+
*/
|
|
110
|
+
get tables() {
|
|
111
|
+
const ret = wasm.wasmlshhasher_tables(this.__wbg_ptr);
|
|
112
|
+
return ret >>> 0;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Create a new LSH hasher with custom parameters.
|
|
116
|
+
*
|
|
117
|
+
* `seed_hex`: hex-encoded seed.
|
|
118
|
+
* `dims`: embedding dimensionality.
|
|
119
|
+
* `n_tables`: number of hash tables.
|
|
120
|
+
* `n_bits`: bits per table.
|
|
121
|
+
* @param {string} seed_hex
|
|
122
|
+
* @param {number} dims
|
|
123
|
+
* @param {number} n_tables
|
|
124
|
+
* @param {number} n_bits
|
|
125
|
+
* @returns {WasmLshHasher}
|
|
126
|
+
*/
|
|
127
|
+
static withParams(seed_hex, dims, n_tables, n_bits) {
|
|
128
|
+
const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
129
|
+
const len0 = WASM_VECTOR_LEN;
|
|
130
|
+
const ret = wasm.wasmlshhasher_withParams(ptr0, len0, dims, n_tables, n_bits);
|
|
131
|
+
if (ret[2]) {
|
|
132
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
133
|
+
}
|
|
134
|
+
return WasmLshHasher.__wrap(ret[0]);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (Symbol.dispose) WasmLshHasher.prototype[Symbol.dispose] = WasmLshHasher.prototype.free;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Append one decision entry to existing JSONL content. Non-fallible.
|
|
141
|
+
* @param {string} existing_content
|
|
142
|
+
* @param {string} entry_json
|
|
143
|
+
* @returns {string}
|
|
144
|
+
*/
|
|
145
|
+
export function appendDecisionEntry(existing_content, entry_json) {
|
|
146
|
+
let deferred3_0;
|
|
147
|
+
let deferred3_1;
|
|
148
|
+
try {
|
|
149
|
+
const ptr0 = passStringToWasm0(existing_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
150
|
+
const len0 = WASM_VECTOR_LEN;
|
|
151
|
+
const ptr1 = passStringToWasm0(entry_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
152
|
+
const len1 = WASM_VECTOR_LEN;
|
|
153
|
+
const ret = wasm.appendDecisionEntry(ptr0, len0, ptr1, len1);
|
|
154
|
+
deferred3_0 = ret[0];
|
|
155
|
+
deferred3_1 = ret[1];
|
|
156
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
157
|
+
} finally {
|
|
158
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Append one feedback entry to existing JSONL content.
|
|
164
|
+
* @param {string} existing
|
|
165
|
+
* @param {string} entry_json
|
|
166
|
+
* @returns {string}
|
|
167
|
+
*/
|
|
168
|
+
export function appendFeedbackToJsonl(existing, entry_json) {
|
|
169
|
+
let deferred4_0;
|
|
170
|
+
let deferred4_1;
|
|
171
|
+
try {
|
|
172
|
+
const ptr0 = passStringToWasm0(existing, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
173
|
+
const len0 = WASM_VECTOR_LEN;
|
|
174
|
+
const ptr1 = passStringToWasm0(entry_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
175
|
+
const len1 = WASM_VECTOR_LEN;
|
|
176
|
+
const ret = wasm.appendFeedbackToJsonl(ptr0, len0, ptr1, len1);
|
|
177
|
+
var ptr3 = ret[0];
|
|
178
|
+
var len3 = ret[1];
|
|
179
|
+
if (ret[3]) {
|
|
180
|
+
ptr3 = 0; len3 = 0;
|
|
181
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
182
|
+
}
|
|
183
|
+
deferred4_0 = ptr3;
|
|
184
|
+
deferred4_1 = len3;
|
|
185
|
+
return getStringFromWasm0(ptr3, len3);
|
|
186
|
+
} finally {
|
|
187
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Apply a single counterexample to the weights; returns updated ResolutionWeights JSON.
|
|
193
|
+
* @param {string} weights_json
|
|
194
|
+
* @param {string} counterexample_json
|
|
195
|
+
* @returns {string}
|
|
196
|
+
*/
|
|
197
|
+
export function applyFeedback(weights_json, counterexample_json) {
|
|
198
|
+
let deferred4_0;
|
|
199
|
+
let deferred4_1;
|
|
200
|
+
try {
|
|
201
|
+
const ptr0 = passStringToWasm0(weights_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
202
|
+
const len0 = WASM_VECTOR_LEN;
|
|
203
|
+
const ptr1 = passStringToWasm0(counterexample_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
204
|
+
const len1 = WASM_VECTOR_LEN;
|
|
205
|
+
const ret = wasm.applyFeedback(ptr0, len0, ptr1, len1);
|
|
206
|
+
var ptr3 = ret[0];
|
|
207
|
+
var len3 = ret[1];
|
|
208
|
+
if (ret[3]) {
|
|
209
|
+
ptr3 = 0; len3 = 0;
|
|
210
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
211
|
+
}
|
|
212
|
+
deferred4_0 = ptr3;
|
|
213
|
+
deferred4_1 = len3;
|
|
214
|
+
return getStringFromWasm0(ptr3, len3);
|
|
215
|
+
} finally {
|
|
216
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Assemble a full Digest from a parsed LLM response and source claims.
|
|
222
|
+
* @param {string} parsed_json
|
|
223
|
+
* @param {string} claims_json
|
|
224
|
+
* @param {bigint} now_unix_seconds
|
|
225
|
+
* @returns {string}
|
|
226
|
+
*/
|
|
227
|
+
export function assembleDigestFromLlm(parsed_json, claims_json, now_unix_seconds) {
|
|
228
|
+
let deferred4_0;
|
|
229
|
+
let deferred4_1;
|
|
230
|
+
try {
|
|
231
|
+
const ptr0 = passStringToWasm0(parsed_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
232
|
+
const len0 = WASM_VECTOR_LEN;
|
|
233
|
+
const ptr1 = passStringToWasm0(claims_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
234
|
+
const len1 = WASM_VECTOR_LEN;
|
|
235
|
+
const ret = wasm.assembleDigestFromLlm(ptr0, len0, ptr1, len1, now_unix_seconds);
|
|
236
|
+
var ptr3 = ret[0];
|
|
237
|
+
var len3 = ret[1];
|
|
238
|
+
if (ret[3]) {
|
|
239
|
+
ptr3 = 0; len3 = 0;
|
|
240
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
241
|
+
}
|
|
242
|
+
deferred4_0 = ptr3;
|
|
243
|
+
deferred4_1 = len3;
|
|
244
|
+
return getStringFromWasm0(ptr3, len3);
|
|
245
|
+
} finally {
|
|
246
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Build ABI-encoded calldata for a batch of prepared facts.
|
|
252
|
+
*
|
|
253
|
+
* `prepared_array_json`: JSON array of `PreparedFact` objects.
|
|
254
|
+
* Returns ABI-encoded calldata (Uint8Array).
|
|
255
|
+
* @param {string} prepared_array_json
|
|
256
|
+
* @returns {Uint8Array}
|
|
257
|
+
*/
|
|
258
|
+
export function buildBatchCalldataFromPrepared(prepared_array_json) {
|
|
259
|
+
const ptr0 = passStringToWasm0(prepared_array_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
260
|
+
const len0 = WASM_VECTOR_LEN;
|
|
261
|
+
const ret = wasm.buildBatchCalldataFromPrepared(ptr0, len0);
|
|
262
|
+
if (ret[3]) {
|
|
263
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
264
|
+
}
|
|
265
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
266
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
267
|
+
return v2;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Build the debrief prompt with already-stored facts filled in.
|
|
272
|
+
*
|
|
273
|
+
* `stored_facts_json`: JSON array of strings (fact texts already stored).
|
|
274
|
+
* @param {string} stored_facts_json
|
|
275
|
+
* @returns {string}
|
|
276
|
+
*/
|
|
277
|
+
export function buildDebriefPrompt(stored_facts_json) {
|
|
278
|
+
let deferred3_0;
|
|
279
|
+
let deferred3_1;
|
|
280
|
+
try {
|
|
281
|
+
const ptr0 = passStringToWasm0(stored_facts_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
282
|
+
const len0 = WASM_VECTOR_LEN;
|
|
283
|
+
const ret = wasm.buildDebriefPrompt(ptr0, len0);
|
|
284
|
+
var ptr2 = ret[0];
|
|
285
|
+
var len2 = ret[1];
|
|
286
|
+
if (ret[3]) {
|
|
287
|
+
ptr2 = 0; len2 = 0;
|
|
288
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
289
|
+
}
|
|
290
|
+
deferred3_0 = ptr2;
|
|
291
|
+
deferred3_1 = len2;
|
|
292
|
+
return getStringFromWasm0(ptr2, len2);
|
|
293
|
+
} finally {
|
|
294
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Build decision log entries from resolution actions.
|
|
300
|
+
*
|
|
301
|
+
* Returns a JSON array of `DecisionLogEntry`.
|
|
302
|
+
* @param {string} actions_json
|
|
303
|
+
* @param {string} new_claim_json
|
|
304
|
+
* @param {string} existing_claims_json
|
|
305
|
+
* @param {string} mode
|
|
306
|
+
* @param {bigint} now_unix
|
|
307
|
+
* @returns {string}
|
|
308
|
+
*/
|
|
309
|
+
export function buildDecisionLogEntries(actions_json, new_claim_json, existing_claims_json, mode, now_unix) {
|
|
310
|
+
let deferred6_0;
|
|
311
|
+
let deferred6_1;
|
|
312
|
+
try {
|
|
313
|
+
const ptr0 = passStringToWasm0(actions_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
314
|
+
const len0 = WASM_VECTOR_LEN;
|
|
315
|
+
const ptr1 = passStringToWasm0(new_claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
316
|
+
const len1 = WASM_VECTOR_LEN;
|
|
317
|
+
const ptr2 = passStringToWasm0(existing_claims_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
318
|
+
const len2 = WASM_VECTOR_LEN;
|
|
319
|
+
const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
320
|
+
const len3 = WASM_VECTOR_LEN;
|
|
321
|
+
const ret = wasm.buildDecisionLogEntries(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, now_unix);
|
|
322
|
+
var ptr5 = ret[0];
|
|
323
|
+
var len5 = ret[1];
|
|
324
|
+
if (ret[3]) {
|
|
325
|
+
ptr5 = 0; len5 = 0;
|
|
326
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
327
|
+
}
|
|
328
|
+
deferred6_0 = ptr5;
|
|
329
|
+
deferred6_1 = len5;
|
|
330
|
+
return getStringFromWasm0(ptr5, len5);
|
|
331
|
+
} finally {
|
|
332
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Build the LLM prompt for digest compilation.
|
|
338
|
+
* `claims_json`: JSON array of Claim (must be non-empty).
|
|
339
|
+
* @param {string} claims_json
|
|
340
|
+
* @returns {string}
|
|
341
|
+
*/
|
|
342
|
+
export function buildDigestPrompt(claims_json) {
|
|
343
|
+
let deferred3_0;
|
|
344
|
+
let deferred3_1;
|
|
345
|
+
try {
|
|
346
|
+
const ptr0 = passStringToWasm0(claims_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
347
|
+
const len0 = WASM_VECTOR_LEN;
|
|
348
|
+
const ret = wasm.buildDigestPrompt(ptr0, len0);
|
|
349
|
+
var ptr2 = ret[0];
|
|
350
|
+
var len2 = ret[1];
|
|
351
|
+
if (ret[3]) {
|
|
352
|
+
ptr2 = 0; len2 = 0;
|
|
353
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
354
|
+
}
|
|
355
|
+
deferred3_0 = ptr2;
|
|
356
|
+
deferred3_1 = len2;
|
|
357
|
+
return getStringFromWasm0(ptr2, len2);
|
|
358
|
+
} finally {
|
|
359
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Build a FeedbackEntry JSON from a decision-log entry JSON + pin action.
|
|
365
|
+
* Returns the JSON string, or the literal string "null" on failure.
|
|
366
|
+
* @param {string} decision_json
|
|
367
|
+
* @param {string} action
|
|
368
|
+
* @param {bigint} now_unix
|
|
369
|
+
* @returns {string}
|
|
370
|
+
*/
|
|
371
|
+
export function buildFeedbackFromDecision(decision_json, action, now_unix) {
|
|
372
|
+
let deferred3_0;
|
|
373
|
+
let deferred3_1;
|
|
374
|
+
try {
|
|
375
|
+
const ptr0 = passStringToWasm0(decision_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
376
|
+
const len0 = WASM_VECTOR_LEN;
|
|
377
|
+
const ptr1 = passStringToWasm0(action, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
378
|
+
const len1 = WASM_VECTOR_LEN;
|
|
379
|
+
const ret = wasm.buildFeedbackFromDecision(ptr0, len0, ptr1, len1, now_unix);
|
|
380
|
+
deferred3_0 = ret[0];
|
|
381
|
+
deferred3_1 = ret[1];
|
|
382
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
383
|
+
} finally {
|
|
384
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Build the profiling prompt for a batch of conversation summaries.
|
|
390
|
+
*
|
|
391
|
+
* `summaries_json`: JSON array of ChunkSummary objects.
|
|
392
|
+
* Returns the prompt string.
|
|
393
|
+
* @param {string} summaries_json
|
|
394
|
+
* @returns {string}
|
|
395
|
+
*/
|
|
396
|
+
export function buildProfileBatchPrompt(summaries_json) {
|
|
397
|
+
let deferred3_0;
|
|
398
|
+
let deferred3_1;
|
|
399
|
+
try {
|
|
400
|
+
const ptr0 = passStringToWasm0(summaries_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
401
|
+
const len0 = WASM_VECTOR_LEN;
|
|
402
|
+
const ret = wasm.buildProfileBatchPrompt(ptr0, len0);
|
|
403
|
+
var ptr2 = ret[0];
|
|
404
|
+
var len2 = ret[1];
|
|
405
|
+
if (ret[3]) {
|
|
406
|
+
ptr2 = 0; len2 = 0;
|
|
407
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
408
|
+
}
|
|
409
|
+
deferred3_0 = ptr2;
|
|
410
|
+
deferred3_1 = len2;
|
|
411
|
+
return getStringFromWasm0(ptr2, len2);
|
|
412
|
+
} finally {
|
|
413
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Build the merge prompt that combines partial profiles.
|
|
419
|
+
*
|
|
420
|
+
* `partials_json`: JSON array of PartialProfile objects.
|
|
421
|
+
* Returns the prompt string.
|
|
422
|
+
* @param {string} partials_json
|
|
423
|
+
* @returns {string}
|
|
424
|
+
*/
|
|
425
|
+
export function buildProfileMergePrompt(partials_json) {
|
|
426
|
+
let deferred3_0;
|
|
427
|
+
let deferred3_1;
|
|
428
|
+
try {
|
|
429
|
+
const ptr0 = passStringToWasm0(partials_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
430
|
+
const len0 = WASM_VECTOR_LEN;
|
|
431
|
+
const ret = wasm.buildProfileMergePrompt(ptr0, len0);
|
|
432
|
+
var ptr2 = ret[0];
|
|
433
|
+
var len2 = ret[1];
|
|
434
|
+
if (ret[3]) {
|
|
435
|
+
ptr2 = 0; len2 = 0;
|
|
436
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
437
|
+
}
|
|
438
|
+
deferred3_0 = ptr2;
|
|
439
|
+
deferred3_1 = len2;
|
|
440
|
+
return getStringFromWasm0(ptr2, len2);
|
|
441
|
+
} finally {
|
|
442
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Build ABI-encoded calldata for a single prepared fact.
|
|
448
|
+
*
|
|
449
|
+
* `prepared_json`: JSON string of a `PreparedFact`.
|
|
450
|
+
* Returns ABI-encoded calldata (Uint8Array).
|
|
451
|
+
* @param {string} prepared_json
|
|
452
|
+
* @returns {Uint8Array}
|
|
453
|
+
*/
|
|
454
|
+
export function buildSingleCalldataFromPrepared(prepared_json) {
|
|
455
|
+
const ptr0 = passStringToWasm0(prepared_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
456
|
+
const len0 = WASM_VECTOR_LEN;
|
|
457
|
+
const ret = wasm.buildSingleCalldataFromPrepared(ptr0, len0);
|
|
458
|
+
if (ret[3]) {
|
|
459
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
460
|
+
}
|
|
461
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
462
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
463
|
+
return v2;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Build a template digest from an array of active claims.
|
|
468
|
+
* `claims_json`: JSON array of Claim. Returns JSON-serialized Digest.
|
|
469
|
+
* @param {string} claims_json
|
|
470
|
+
* @param {bigint} now_unix_seconds
|
|
471
|
+
* @returns {string}
|
|
472
|
+
*/
|
|
473
|
+
export function buildTemplateDigest(claims_json, now_unix_seconds) {
|
|
474
|
+
let deferred3_0;
|
|
475
|
+
let deferred3_1;
|
|
476
|
+
try {
|
|
477
|
+
const ptr0 = passStringToWasm0(claims_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
478
|
+
const len0 = WASM_VECTOR_LEN;
|
|
479
|
+
const ret = wasm.buildTemplateDigest(ptr0, len0, now_unix_seconds);
|
|
480
|
+
var ptr2 = ret[0];
|
|
481
|
+
var len2 = ret[1];
|
|
482
|
+
if (ret[3]) {
|
|
483
|
+
ptr2 = 0; len2 = 0;
|
|
484
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
485
|
+
}
|
|
486
|
+
deferred3_0 = ptr2;
|
|
487
|
+
deferred3_1 = len2;
|
|
488
|
+
return getStringFromWasm0(ptr2, len2);
|
|
489
|
+
} finally {
|
|
490
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Build the triage prompt for classifying chunks.
|
|
496
|
+
*
|
|
497
|
+
* `profile_json`: JSON string of a UserProfile.
|
|
498
|
+
* `summaries_json`: JSON array of ChunkSummary objects.
|
|
499
|
+
* Returns the prompt string.
|
|
500
|
+
* @param {string} profile_json
|
|
501
|
+
* @param {string} summaries_json
|
|
502
|
+
* @returns {string}
|
|
503
|
+
*/
|
|
504
|
+
export function buildTriagePrompt(profile_json, summaries_json) {
|
|
505
|
+
let deferred4_0;
|
|
506
|
+
let deferred4_1;
|
|
507
|
+
try {
|
|
508
|
+
const ptr0 = passStringToWasm0(profile_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
509
|
+
const len0 = WASM_VECTOR_LEN;
|
|
510
|
+
const ptr1 = passStringToWasm0(summaries_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
511
|
+
const len1 = WASM_VECTOR_LEN;
|
|
512
|
+
const ret = wasm.buildTriagePrompt(ptr0, len0, ptr1, len1);
|
|
513
|
+
var ptr3 = ret[0];
|
|
514
|
+
var len3 = ret[1];
|
|
515
|
+
if (ret[3]) {
|
|
516
|
+
ptr3 = 0; len3 = 0;
|
|
517
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
518
|
+
}
|
|
519
|
+
deferred4_0 = ptr3;
|
|
520
|
+
deferred4_1 = len3;
|
|
521
|
+
return getStringFromWasm0(ptr3, len3);
|
|
522
|
+
} finally {
|
|
523
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Canonicalize a Claim JSON: strict-parse as Claim, re-serialize to canonical bytes.
|
|
529
|
+
* Rejects legacy or malformed input. Use before encryption so TS/Python/Rust all
|
|
530
|
+
* produce byte-identical blobs for the same logical claim.
|
|
531
|
+
* @param {string} claim_json
|
|
532
|
+
* @returns {string}
|
|
533
|
+
*/
|
|
534
|
+
export function canonicalizeClaim(claim_json) {
|
|
535
|
+
let deferred3_0;
|
|
536
|
+
let deferred3_1;
|
|
537
|
+
try {
|
|
538
|
+
const ptr0 = passStringToWasm0(claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
539
|
+
const len0 = WASM_VECTOR_LEN;
|
|
540
|
+
const ret = wasm.canonicalizeClaim(ptr0, len0);
|
|
541
|
+
var ptr2 = ret[0];
|
|
542
|
+
var len2 = ret[1];
|
|
543
|
+
if (ret[3]) {
|
|
544
|
+
ptr2 = 0; len2 = 0;
|
|
545
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
546
|
+
}
|
|
547
|
+
deferred3_0 = ptr2;
|
|
548
|
+
deferred3_1 = len2;
|
|
549
|
+
return getStringFromWasm0(ptr2, len2);
|
|
550
|
+
} finally {
|
|
551
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Convert conversation chunks to summaries.
|
|
557
|
+
*
|
|
558
|
+
* `chunks_json`: JSON array of ConversationChunk objects.
|
|
559
|
+
* Returns a JsValue (JSON array of ChunkSummary objects).
|
|
560
|
+
* @param {string} chunks_json
|
|
561
|
+
* @returns {any}
|
|
562
|
+
*/
|
|
563
|
+
export function chunksToSummaries(chunks_json) {
|
|
564
|
+
const ptr0 = passStringToWasm0(chunks_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
565
|
+
const len0 = WASM_VECTOR_LEN;
|
|
566
|
+
const ret = wasm.chunksToSummaries(ptr0, len0);
|
|
567
|
+
if (ret[2]) {
|
|
568
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
569
|
+
}
|
|
570
|
+
return takeFromExternrefTable0(ret[0]);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Classify natural-language pin/unpin intent from a user utterance.
|
|
575
|
+
*
|
|
576
|
+
* Returns JSON of [`PinIntent`] when a trigger phrase matches, or `null` when
|
|
577
|
+
* the utterance contains no recognised pin gesture. Lowercase normalization
|
|
578
|
+
* is applied internally — callers pass the raw user text.
|
|
579
|
+
* @param {string} text
|
|
580
|
+
* @returns {string}
|
|
581
|
+
*/
|
|
582
|
+
export function classifyPinIntent(text) {
|
|
583
|
+
let deferred3_0;
|
|
584
|
+
let deferred3_1;
|
|
585
|
+
try {
|
|
586
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
587
|
+
const len0 = WASM_VECTOR_LEN;
|
|
588
|
+
const ret = wasm.classifyPinIntent(ptr0, len0);
|
|
589
|
+
var ptr2 = ret[0];
|
|
590
|
+
var len2 = ret[1];
|
|
591
|
+
if (ret[3]) {
|
|
592
|
+
ptr2 = 0; len2 = 0;
|
|
593
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
594
|
+
}
|
|
595
|
+
deferred3_0 = ptr2;
|
|
596
|
+
deferred3_1 = len2;
|
|
597
|
+
return getStringFromWasm0(ptr2, len2);
|
|
598
|
+
} finally {
|
|
599
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* WASM binding for `cluster_facts`.
|
|
605
|
+
*
|
|
606
|
+
* `candidates_json`: JSON array of `ConsolidationCandidate` objects.
|
|
607
|
+
* `threshold`: Cosine similarity threshold for clustering.
|
|
608
|
+
*
|
|
609
|
+
* Returns JSON array of `{ representative: string, duplicates: string[] }`.
|
|
610
|
+
* @param {string} candidates_json
|
|
611
|
+
* @param {number} threshold
|
|
612
|
+
* @returns {any}
|
|
613
|
+
*/
|
|
614
|
+
export function clusterFacts(candidates_json, threshold) {
|
|
615
|
+
const ptr0 = passStringToWasm0(candidates_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
616
|
+
const len0 = WASM_VECTOR_LEN;
|
|
617
|
+
const ret = wasm.clusterFacts(ptr0, len0, threshold);
|
|
618
|
+
if (ret[2]) {
|
|
619
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
620
|
+
}
|
|
621
|
+
return takeFromExternrefTable0(ret[0]);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Compute SHA-256(authKey) as a hex string.
|
|
626
|
+
*
|
|
627
|
+
* `auth_key_hex`: 64-char hex string (32 bytes).
|
|
628
|
+
* @param {string} auth_key_hex
|
|
629
|
+
* @returns {string}
|
|
630
|
+
*/
|
|
631
|
+
export function computeAuthKeyHash(auth_key_hex) {
|
|
632
|
+
let deferred3_0;
|
|
633
|
+
let deferred3_1;
|
|
634
|
+
try {
|
|
635
|
+
const ptr0 = passStringToWasm0(auth_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
636
|
+
const len0 = WASM_VECTOR_LEN;
|
|
637
|
+
const ret = wasm.computeAuthKeyHash(ptr0, len0);
|
|
638
|
+
var ptr2 = ret[0];
|
|
639
|
+
var len2 = ret[1];
|
|
640
|
+
if (ret[3]) {
|
|
641
|
+
ptr2 = 0; len2 = 0;
|
|
642
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
643
|
+
}
|
|
644
|
+
deferred3_0 = ptr2;
|
|
645
|
+
deferred3_1 = len2;
|
|
646
|
+
return getStringFromWasm0(ptr2, len2);
|
|
647
|
+
} finally {
|
|
648
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Compute the content fingerprint for dedup checks.
|
|
654
|
+
*
|
|
655
|
+
* `dedup_key_hex`: 64-char hex string (32 bytes).
|
|
656
|
+
* Returns 64-char hex fingerprint.
|
|
657
|
+
* @param {string} text
|
|
658
|
+
* @param {string} dedup_key_hex
|
|
659
|
+
* @returns {string}
|
|
660
|
+
*/
|
|
661
|
+
export function computeContentFingerprint(text, dedup_key_hex) {
|
|
662
|
+
let deferred4_0;
|
|
663
|
+
let deferred4_1;
|
|
664
|
+
try {
|
|
665
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
666
|
+
const len0 = WASM_VECTOR_LEN;
|
|
667
|
+
const ptr1 = passStringToWasm0(dedup_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
668
|
+
const len1 = WASM_VECTOR_LEN;
|
|
669
|
+
const ret = wasm.computeContentFingerprint(ptr0, len0, ptr1, len1);
|
|
670
|
+
var ptr3 = ret[0];
|
|
671
|
+
var len3 = ret[1];
|
|
672
|
+
if (ret[3]) {
|
|
673
|
+
ptr3 = 0; len3 = 0;
|
|
674
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
675
|
+
}
|
|
676
|
+
deferred4_0 = ptr3;
|
|
677
|
+
deferred4_1 = len3;
|
|
678
|
+
return getStringFromWasm0(ptr3, len3);
|
|
679
|
+
} finally {
|
|
680
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Compute a claim's score components for contradiction resolution.
|
|
686
|
+
* @param {string} claim_json
|
|
687
|
+
* @param {bigint} now_unix_seconds
|
|
688
|
+
* @param {string} weights_json
|
|
689
|
+
* @returns {string}
|
|
690
|
+
*/
|
|
691
|
+
export function computeScoreComponents(claim_json, now_unix_seconds, weights_json) {
|
|
692
|
+
let deferred4_0;
|
|
693
|
+
let deferred4_1;
|
|
694
|
+
try {
|
|
695
|
+
const ptr0 = passStringToWasm0(claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
696
|
+
const len0 = WASM_VECTOR_LEN;
|
|
697
|
+
const ptr1 = passStringToWasm0(weights_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
698
|
+
const len1 = WASM_VECTOR_LEN;
|
|
699
|
+
const ret = wasm.computeScoreComponents(ptr0, len0, now_unix_seconds, ptr1, len1);
|
|
700
|
+
var ptr3 = ret[0];
|
|
701
|
+
var len3 = ret[1];
|
|
702
|
+
if (ret[3]) {
|
|
703
|
+
ptr3 = 0; len3 = 0;
|
|
704
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
705
|
+
}
|
|
706
|
+
deferred4_0 = ptr3;
|
|
707
|
+
deferred4_1 = len3;
|
|
708
|
+
return getStringFromWasm0(ptr3, len3);
|
|
709
|
+
} finally {
|
|
710
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* Cosine similarity between two f32 vectors.
|
|
716
|
+
* @param {Float32Array} a
|
|
717
|
+
* @param {Float32Array} b
|
|
718
|
+
* @returns {number}
|
|
719
|
+
*/
|
|
720
|
+
export function cosineSimilarity(a, b) {
|
|
721
|
+
const ptr0 = passArrayF32ToWasm0(a, wasm.__wbindgen_malloc);
|
|
722
|
+
const len0 = WASM_VECTOR_LEN;
|
|
723
|
+
const ptr1 = passArrayF32ToWasm0(b, wasm.__wbindgen_malloc);
|
|
724
|
+
const len1 = WASM_VECTOR_LEN;
|
|
725
|
+
const ret = wasm.cosineSimilarity(ptr0, len0, ptr1, len1);
|
|
726
|
+
return ret;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Decrypt a base64-encoded XChaCha20-Poly1305 blob.
|
|
731
|
+
*
|
|
732
|
+
* `encryption_key_hex`: 64-char hex string (32 bytes).
|
|
733
|
+
* Returns the plaintext UTF-8 string.
|
|
734
|
+
* @param {string} encrypted_base64
|
|
735
|
+
* @param {string} encryption_key_hex
|
|
736
|
+
* @returns {string}
|
|
737
|
+
*/
|
|
738
|
+
export function decrypt(encrypted_base64, encryption_key_hex) {
|
|
739
|
+
let deferred4_0;
|
|
740
|
+
let deferred4_1;
|
|
741
|
+
try {
|
|
742
|
+
const ptr0 = passStringToWasm0(encrypted_base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
743
|
+
const len0 = WASM_VECTOR_LEN;
|
|
744
|
+
const ptr1 = passStringToWasm0(encryption_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
745
|
+
const len1 = WASM_VECTOR_LEN;
|
|
746
|
+
const ret = wasm.decrypt(ptr0, len0, ptr1, len1);
|
|
747
|
+
var ptr3 = ret[0];
|
|
748
|
+
var len3 = ret[1];
|
|
749
|
+
if (ret[3]) {
|
|
750
|
+
ptr3 = 0; len3 = 0;
|
|
751
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
752
|
+
}
|
|
753
|
+
deferred4_0 = ptr3;
|
|
754
|
+
deferred4_1 = len3;
|
|
755
|
+
return getStringFromWasm0(ptr3, len3);
|
|
756
|
+
} finally {
|
|
757
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* Decrypt and rerank search candidates.
|
|
763
|
+
*
|
|
764
|
+
* Takes raw SubgraphFacts (as JSON), decrypts their content + embeddings,
|
|
765
|
+
* and returns top-K ranked results using BM25 + Cosine + RRF fusion.
|
|
766
|
+
*
|
|
767
|
+
* `facts_json`: JSON array of SubgraphFact objects.
|
|
768
|
+
* `query`: The search query text.
|
|
769
|
+
* `query_embedding`: Float32Array of the query embedding.
|
|
770
|
+
* `encryption_key_hex`: 64-char hex string (32 bytes).
|
|
771
|
+
* `top_k`: Number of top results to return.
|
|
772
|
+
*
|
|
773
|
+
* Returns a JsValue (JSON array of RankedResult objects).
|
|
774
|
+
* @param {string} facts_json
|
|
775
|
+
* @param {string} query
|
|
776
|
+
* @param {Float32Array} query_embedding
|
|
777
|
+
* @param {string} encryption_key_hex
|
|
778
|
+
* @param {number} top_k
|
|
779
|
+
* @returns {any}
|
|
780
|
+
*/
|
|
781
|
+
export function decryptAndRerank(facts_json, query, query_embedding, encryption_key_hex, top_k) {
|
|
782
|
+
const ptr0 = passStringToWasm0(facts_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
783
|
+
const len0 = WASM_VECTOR_LEN;
|
|
784
|
+
const ptr1 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
785
|
+
const len1 = WASM_VECTOR_LEN;
|
|
786
|
+
const ptr2 = passArrayF32ToWasm0(query_embedding, wasm.__wbindgen_malloc);
|
|
787
|
+
const len2 = WASM_VECTOR_LEN;
|
|
788
|
+
const ptr3 = passStringToWasm0(encryption_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
789
|
+
const len3 = WASM_VECTOR_LEN;
|
|
790
|
+
const ret = wasm.decryptAndRerank(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, top_k);
|
|
791
|
+
if (ret[2]) {
|
|
792
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
793
|
+
}
|
|
794
|
+
return takeFromExternrefTable0(ret[0]);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Return the locked-default [`PinConfig`] as JSON. Clients that don't want
|
|
799
|
+
* to retune can pass this verbatim to [`wasm_pin_boost`].
|
|
800
|
+
* @returns {string}
|
|
801
|
+
*/
|
|
802
|
+
export function defaultPinConfig() {
|
|
803
|
+
let deferred2_0;
|
|
804
|
+
let deferred2_1;
|
|
805
|
+
try {
|
|
806
|
+
const ret = wasm.defaultPinConfig();
|
|
807
|
+
var ptr1 = ret[0];
|
|
808
|
+
var len1 = ret[1];
|
|
809
|
+
if (ret[3]) {
|
|
810
|
+
ptr1 = 0; len1 = 0;
|
|
811
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
812
|
+
}
|
|
813
|
+
deferred2_0 = ptr1;
|
|
814
|
+
deferred2_1 = len1;
|
|
815
|
+
return getStringFromWasm0(ptr1, len1);
|
|
816
|
+
} finally {
|
|
817
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* Default P2-3 resolution weights as JSON.
|
|
823
|
+
* @returns {string}
|
|
824
|
+
*/
|
|
825
|
+
export function defaultResolutionWeights() {
|
|
826
|
+
let deferred2_0;
|
|
827
|
+
let deferred2_1;
|
|
828
|
+
try {
|
|
829
|
+
const ret = wasm.defaultResolutionWeights();
|
|
830
|
+
var ptr1 = ret[0];
|
|
831
|
+
var len1 = ret[1];
|
|
832
|
+
if (ret[3]) {
|
|
833
|
+
ptr1 = 0; len1 = 0;
|
|
834
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
835
|
+
}
|
|
836
|
+
deferred2_0 = ptr1;
|
|
837
|
+
deferred2_1 = len1;
|
|
838
|
+
return getStringFromWasm0(ptr1, len1);
|
|
839
|
+
} finally {
|
|
840
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Build a fresh default WeightsFile JSON with the given timestamp.
|
|
846
|
+
* @param {bigint} now_unix_seconds
|
|
847
|
+
* @returns {string}
|
|
848
|
+
*/
|
|
849
|
+
export function defaultWeightsFile(now_unix_seconds) {
|
|
850
|
+
let deferred2_0;
|
|
851
|
+
let deferred2_1;
|
|
852
|
+
try {
|
|
853
|
+
const ret = wasm.defaultWeightsFile(now_unix_seconds);
|
|
854
|
+
var ptr1 = ret[0];
|
|
855
|
+
var len1 = ret[1];
|
|
856
|
+
if (ret[3]) {
|
|
857
|
+
ptr1 = 0; len1 = 0;
|
|
858
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
859
|
+
}
|
|
860
|
+
deferred2_0 = ptr1;
|
|
861
|
+
deferred2_1 = len1;
|
|
862
|
+
return getStringFromWasm0(ptr1, len1);
|
|
863
|
+
} finally {
|
|
864
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
/**
|
|
869
|
+
* Derive an Ethereum EOA wallet from a BIP-39 mnemonic via BIP-44.
|
|
870
|
+
*
|
|
871
|
+
* Path: m/44'/60'/0'/0/0 (standard Ethereum derivation path).
|
|
872
|
+
* Returns a JS object: `{ private_key: "hex...", address: "0x..." }`.
|
|
873
|
+
* @param {string} mnemonic
|
|
874
|
+
* @returns {any}
|
|
875
|
+
*/
|
|
876
|
+
export function deriveEoa(mnemonic) {
|
|
877
|
+
const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
878
|
+
const len0 = WASM_VECTOR_LEN;
|
|
879
|
+
const ret = wasm.deriveEoa(ptr0, len0);
|
|
880
|
+
if (ret[2]) {
|
|
881
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
882
|
+
}
|
|
883
|
+
return takeFromExternrefTable0(ret[0]);
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* Derive just the Ethereum EOA address from a BIP-39 mnemonic.
|
|
888
|
+
*
|
|
889
|
+
* Returns: `"0x..."` (lowercase hex).
|
|
890
|
+
* @param {string} mnemonic
|
|
891
|
+
* @returns {string}
|
|
892
|
+
*/
|
|
893
|
+
export function deriveEoaAddress(mnemonic) {
|
|
894
|
+
let deferred3_0;
|
|
895
|
+
let deferred3_1;
|
|
896
|
+
try {
|
|
897
|
+
const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
898
|
+
const len0 = WASM_VECTOR_LEN;
|
|
899
|
+
const ret = wasm.deriveEoaAddress(ptr0, len0);
|
|
900
|
+
var ptr2 = ret[0];
|
|
901
|
+
var len2 = ret[1];
|
|
902
|
+
if (ret[3]) {
|
|
903
|
+
ptr2 = 0; len2 = 0;
|
|
904
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
905
|
+
}
|
|
906
|
+
deferred3_0 = ptr2;
|
|
907
|
+
deferred3_1 = len2;
|
|
908
|
+
return getStringFromWasm0(ptr2, len2);
|
|
909
|
+
} finally {
|
|
910
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* Derive encryption keys from a BIP-39 mnemonic (strict checksum validation).
|
|
916
|
+
*
|
|
917
|
+
* Returns a JSON object with hex-encoded keys:
|
|
918
|
+
* `{ auth_key, encryption_key, dedup_key, salt }`
|
|
919
|
+
* @param {string} mnemonic
|
|
920
|
+
* @returns {any}
|
|
921
|
+
*/
|
|
922
|
+
export function deriveKeysFromMnemonic(mnemonic) {
|
|
923
|
+
const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
924
|
+
const len0 = WASM_VECTOR_LEN;
|
|
925
|
+
const ret = wasm.deriveKeysFromMnemonic(ptr0, len0);
|
|
926
|
+
if (ret[2]) {
|
|
927
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
928
|
+
}
|
|
929
|
+
return takeFromExternrefTable0(ret[0]);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
/**
|
|
933
|
+
* Derive encryption keys from a BIP-39 mnemonic (lenient -- skips checksum).
|
|
934
|
+
*
|
|
935
|
+
* Same return format as `deriveKeysFromMnemonic`.
|
|
936
|
+
* @param {string} mnemonic
|
|
937
|
+
* @returns {any}
|
|
938
|
+
*/
|
|
939
|
+
export function deriveKeysFromMnemonicLenient(mnemonic) {
|
|
940
|
+
const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
941
|
+
const len0 = WASM_VECTOR_LEN;
|
|
942
|
+
const ret = wasm.deriveKeysFromMnemonicLenient(ptr0, len0);
|
|
943
|
+
if (ret[2]) {
|
|
944
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
945
|
+
}
|
|
946
|
+
return takeFromExternrefTable0(ret[0]);
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* Derive the 32-byte LSH seed from a BIP-39 mnemonic and salt.
|
|
951
|
+
*
|
|
952
|
+
* `salt_hex`: 64-char hex string (32 bytes).
|
|
953
|
+
* Returns hex-encoded 32-byte seed.
|
|
954
|
+
* @param {string} mnemonic
|
|
955
|
+
* @param {string} salt_hex
|
|
956
|
+
* @returns {string}
|
|
957
|
+
*/
|
|
958
|
+
export function deriveLshSeed(mnemonic, salt_hex) {
|
|
959
|
+
let deferred4_0;
|
|
960
|
+
let deferred4_1;
|
|
961
|
+
try {
|
|
962
|
+
const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
963
|
+
const len0 = WASM_VECTOR_LEN;
|
|
964
|
+
const ptr1 = passStringToWasm0(salt_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
965
|
+
const len1 = WASM_VECTOR_LEN;
|
|
966
|
+
const ret = wasm.deriveLshSeed(ptr0, len0, ptr1, len1);
|
|
967
|
+
var ptr3 = ret[0];
|
|
968
|
+
var len3 = ret[1];
|
|
969
|
+
if (ret[3]) {
|
|
970
|
+
ptr3 = 0; len3 = 0;
|
|
971
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
972
|
+
}
|
|
973
|
+
deferred4_0 = ptr3;
|
|
974
|
+
deferred4_1 = len3;
|
|
975
|
+
return getStringFromWasm0(ptr3, len3);
|
|
976
|
+
} finally {
|
|
977
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* Detect contradictions between a new claim and existing claims (JSON array of {claim, id, embedding}).
|
|
983
|
+
* @param {string} new_claim_json
|
|
984
|
+
* @param {string} new_claim_id
|
|
985
|
+
* @param {string} new_embedding_json
|
|
986
|
+
* @param {string} existing_json
|
|
987
|
+
* @param {number} lower_threshold
|
|
988
|
+
* @param {number} upper_threshold
|
|
989
|
+
* @returns {string}
|
|
990
|
+
*/
|
|
991
|
+
export function detectContradictions(new_claim_json, new_claim_id, new_embedding_json, existing_json, lower_threshold, upper_threshold) {
|
|
992
|
+
let deferred6_0;
|
|
993
|
+
let deferred6_1;
|
|
994
|
+
try {
|
|
995
|
+
const ptr0 = passStringToWasm0(new_claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
996
|
+
const len0 = WASM_VECTOR_LEN;
|
|
997
|
+
const ptr1 = passStringToWasm0(new_claim_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
998
|
+
const len1 = WASM_VECTOR_LEN;
|
|
999
|
+
const ptr2 = passStringToWasm0(new_embedding_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1000
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1001
|
+
const ptr3 = passStringToWasm0(existing_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1002
|
+
const len3 = WASM_VECTOR_LEN;
|
|
1003
|
+
const ret = wasm.detectContradictions(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, lower_threshold, upper_threshold);
|
|
1004
|
+
var ptr5 = ret[0];
|
|
1005
|
+
var len5 = ret[1];
|
|
1006
|
+
if (ret[3]) {
|
|
1007
|
+
ptr5 = 0; len5 = 0;
|
|
1008
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1009
|
+
}
|
|
1010
|
+
deferred6_0 = ptr5;
|
|
1011
|
+
deferred6_1 = len5;
|
|
1012
|
+
return getStringFromWasm0(ptr5, len5);
|
|
1013
|
+
} finally {
|
|
1014
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* Deterministic entity ID from a name (first 8 bytes of SHA256 as hex).
|
|
1020
|
+
* @param {string} name
|
|
1021
|
+
* @returns {string}
|
|
1022
|
+
*/
|
|
1023
|
+
export function deterministicEntityId(name) {
|
|
1024
|
+
let deferred2_0;
|
|
1025
|
+
let deferred2_1;
|
|
1026
|
+
try {
|
|
1027
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1028
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1029
|
+
const ret = wasm.deterministicEntityId(ptr0, len0);
|
|
1030
|
+
deferred2_0 = ret[0];
|
|
1031
|
+
deferred2_1 = ret[1];
|
|
1032
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1033
|
+
} finally {
|
|
1034
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Encode multiple fact submissions as SimpleAccount.executeBatch() calldata.
|
|
1040
|
+
*
|
|
1041
|
+
* `payloads_json`: JSON array of hex-encoded payload strings (e.g. `["deadbeef", "cafebabe"]`).
|
|
1042
|
+
* Returns ABI-encoded calldata (Uint8Array).
|
|
1043
|
+
* @param {string} payloads_json
|
|
1044
|
+
* @returns {Uint8Array}
|
|
1045
|
+
*/
|
|
1046
|
+
export function encodeBatchCall(payloads_json) {
|
|
1047
|
+
const ptr0 = passStringToWasm0(payloads_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1048
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1049
|
+
const ret = wasm.encodeBatchCall(ptr0, len0);
|
|
1050
|
+
if (ret[3]) {
|
|
1051
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1052
|
+
}
|
|
1053
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1054
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1055
|
+
return v2;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* Like `encodeBatchCall` but targets an explicit DataEdge address (#366).
|
|
1060
|
+
* @param {string} payloads_json
|
|
1061
|
+
* @param {string} data_edge_address
|
|
1062
|
+
* @returns {Uint8Array}
|
|
1063
|
+
*/
|
|
1064
|
+
export function encodeBatchCallTo(payloads_json, data_edge_address) {
|
|
1065
|
+
const ptr0 = passStringToWasm0(payloads_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1066
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1067
|
+
const ptr1 = passStringToWasm0(data_edge_address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1068
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1069
|
+
const ret = wasm.encodeBatchCallTo(ptr0, len0, ptr1, len1);
|
|
1070
|
+
if (ret[3]) {
|
|
1071
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1072
|
+
}
|
|
1073
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1074
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1075
|
+
return v3;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
/**
|
|
1079
|
+
* Encode a fact payload as minimal protobuf wire format.
|
|
1080
|
+
*
|
|
1081
|
+
* `json`: JSON string with shape:
|
|
1082
|
+
* ```json
|
|
1083
|
+
* {
|
|
1084
|
+
* "id": "...", "timestamp": "...", "owner": "...",
|
|
1085
|
+
* "encrypted_blob_hex": "...", "blind_indices": ["..."],
|
|
1086
|
+
* "decay_score": 0.8, "source": "...", "content_fp": "...",
|
|
1087
|
+
* "agent_id": "...", "encrypted_embedding": "..." (optional)
|
|
1088
|
+
* }
|
|
1089
|
+
* ```
|
|
1090
|
+
*
|
|
1091
|
+
* Returns the protobuf bytes as a Uint8Array.
|
|
1092
|
+
* @param {string} json
|
|
1093
|
+
* @returns {Uint8Array}
|
|
1094
|
+
*/
|
|
1095
|
+
export function encodeFactProtobuf(json) {
|
|
1096
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1097
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1098
|
+
const ret = wasm.encodeFactProtobuf(ptr0, len0);
|
|
1099
|
+
if (ret[3]) {
|
|
1100
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1101
|
+
}
|
|
1102
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1103
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1104
|
+
return v2;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
/**
|
|
1108
|
+
* Encode a single fact submission as SimpleAccount.execute() calldata.
|
|
1109
|
+
*
|
|
1110
|
+
* `protobuf_payload`: raw protobuf bytes (Uint8Array).
|
|
1111
|
+
* Returns ABI-encoded calldata (Uint8Array).
|
|
1112
|
+
* @param {Uint8Array} protobuf_payload
|
|
1113
|
+
* @returns {Uint8Array}
|
|
1114
|
+
*/
|
|
1115
|
+
export function encodeSingleCall(protobuf_payload) {
|
|
1116
|
+
const ptr0 = passArray8ToWasm0(protobuf_payload, wasm.__wbindgen_malloc);
|
|
1117
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1118
|
+
const ret = wasm.encodeSingleCall(ptr0, len0);
|
|
1119
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1120
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1121
|
+
return v2;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
/**
|
|
1125
|
+
* Like `encodeSingleCall` but targets an explicit DataEdge address.
|
|
1126
|
+
*
|
|
1127
|
+
* Chain/environment-aware clients pass the authoritative address from the
|
|
1128
|
+
* relay's `/v1/billing/status` `data_edge_address` (#366) — the isolated
|
|
1129
|
+
* staging Gnosis DataEdge differs from prod's. Throws on a bad address.
|
|
1130
|
+
* @param {Uint8Array} protobuf_payload
|
|
1131
|
+
* @param {string} data_edge_address
|
|
1132
|
+
* @returns {Uint8Array}
|
|
1133
|
+
*/
|
|
1134
|
+
export function encodeSingleCallTo(protobuf_payload, data_edge_address) {
|
|
1135
|
+
const ptr0 = passArray8ToWasm0(protobuf_payload, wasm.__wbindgen_malloc);
|
|
1136
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1137
|
+
const ptr1 = passStringToWasm0(data_edge_address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1138
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1139
|
+
const ret = wasm.encodeSingleCallTo(ptr0, len0, ptr1, len1);
|
|
1140
|
+
if (ret[3]) {
|
|
1141
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1142
|
+
}
|
|
1143
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1144
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1145
|
+
return v3;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* Encode a tombstone protobuf for soft-deleting a fact.
|
|
1150
|
+
*
|
|
1151
|
+
* `version` is optional; missing/0 defaults to `DEFAULT_PROTOBUF_VERSION` (3).
|
|
1152
|
+
* Pass `4` to emit a v1-taxonomy tombstone (outer protobuf version = 4).
|
|
1153
|
+
*
|
|
1154
|
+
* Returns the protobuf bytes as a Uint8Array.
|
|
1155
|
+
* @param {string} fact_id
|
|
1156
|
+
* @param {string} owner
|
|
1157
|
+
* @param {number | null} [version]
|
|
1158
|
+
* @returns {Uint8Array}
|
|
1159
|
+
*/
|
|
1160
|
+
export function encodeTombstoneProtobuf(fact_id, owner, version) {
|
|
1161
|
+
const ptr0 = passStringToWasm0(fact_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1162
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1163
|
+
const ptr1 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1164
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1165
|
+
const ret = wasm.encodeTombstoneProtobuf(ptr0, len0, ptr1, len1, isLikeNone(version) ? 0x100000001 : (version) >>> 0);
|
|
1166
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1167
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1168
|
+
return v3;
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* Encrypt a UTF-8 plaintext with XChaCha20-Poly1305.
|
|
1173
|
+
*
|
|
1174
|
+
* `encryption_key_hex`: 64-char hex string (32 bytes).
|
|
1175
|
+
* Returns base64-encoded ciphertext (wire format: nonce || tag || ciphertext).
|
|
1176
|
+
* @param {string} plaintext
|
|
1177
|
+
* @param {string} encryption_key_hex
|
|
1178
|
+
* @returns {string}
|
|
1179
|
+
*/
|
|
1180
|
+
export function encrypt(plaintext, encryption_key_hex) {
|
|
1181
|
+
let deferred4_0;
|
|
1182
|
+
let deferred4_1;
|
|
1183
|
+
try {
|
|
1184
|
+
const ptr0 = passStringToWasm0(plaintext, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1185
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1186
|
+
const ptr1 = passStringToWasm0(encryption_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1187
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1188
|
+
const ret = wasm.encrypt(ptr0, len0, ptr1, len1);
|
|
1189
|
+
var ptr3 = ret[0];
|
|
1190
|
+
var len3 = ret[1];
|
|
1191
|
+
if (ret[3]) {
|
|
1192
|
+
ptr3 = 0; len3 = 0;
|
|
1193
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1194
|
+
}
|
|
1195
|
+
deferred4_0 = ptr3;
|
|
1196
|
+
deferred4_1 = len3;
|
|
1197
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1198
|
+
} finally {
|
|
1199
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/**
|
|
1204
|
+
* Enrich an extraction prompt with user profile context.
|
|
1205
|
+
*
|
|
1206
|
+
* `profile_json`: JSON string of a UserProfile.
|
|
1207
|
+
* `base_prompt`: The base extraction prompt to enrich.
|
|
1208
|
+
* Returns the enriched prompt string.
|
|
1209
|
+
* @param {string} profile_json
|
|
1210
|
+
* @param {string} base_prompt
|
|
1211
|
+
* @returns {string}
|
|
1212
|
+
*/
|
|
1213
|
+
export function enrichExtractionPrompt(profile_json, base_prompt) {
|
|
1214
|
+
let deferred4_0;
|
|
1215
|
+
let deferred4_1;
|
|
1216
|
+
try {
|
|
1217
|
+
const ptr0 = passStringToWasm0(profile_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1218
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1219
|
+
const ptr1 = passStringToWasm0(base_prompt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1220
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1221
|
+
const ret = wasm.enrichExtractionPrompt(ptr0, len0, ptr1, len1);
|
|
1222
|
+
var ptr3 = ret[0];
|
|
1223
|
+
var len3 = ret[1];
|
|
1224
|
+
if (ret[3]) {
|
|
1225
|
+
ptr3 = 0; len3 = 0;
|
|
1226
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1227
|
+
}
|
|
1228
|
+
deferred4_0 = ptr3;
|
|
1229
|
+
deferred4_1 = len3;
|
|
1230
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1231
|
+
} finally {
|
|
1232
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
/**
|
|
1237
|
+
* Convert a feedback entry into a counterexample for weight tuning. Returns
|
|
1238
|
+
* JSON Counterexample or the literal string "null" if the entry has no signal.
|
|
1239
|
+
* @param {string} entry_json
|
|
1240
|
+
* @returns {string}
|
|
1241
|
+
*/
|
|
1242
|
+
export function feedbackToCounterexample(entry_json) {
|
|
1243
|
+
let deferred3_0;
|
|
1244
|
+
let deferred3_1;
|
|
1245
|
+
try {
|
|
1246
|
+
const ptr0 = passStringToWasm0(entry_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1247
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1248
|
+
const ret = wasm.feedbackToCounterexample(ptr0, len0);
|
|
1249
|
+
var ptr2 = ret[0];
|
|
1250
|
+
var len2 = ret[1];
|
|
1251
|
+
if (ret[3]) {
|
|
1252
|
+
ptr2 = 0; len2 = 0;
|
|
1253
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1254
|
+
}
|
|
1255
|
+
deferred3_0 = ptr2;
|
|
1256
|
+
deferred3_1 = len2;
|
|
1257
|
+
return getStringFromWasm0(ptr2, len2);
|
|
1258
|
+
} finally {
|
|
1259
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* Filter resolution actions by mode ("active" passes through, "shadow"/"off" returns empty).
|
|
1265
|
+
*
|
|
1266
|
+
* Returns a JSON array of `ResolutionAction`.
|
|
1267
|
+
* @param {string} actions_json
|
|
1268
|
+
* @param {string} mode
|
|
1269
|
+
* @returns {string}
|
|
1270
|
+
*/
|
|
1271
|
+
export function filterShadowMode(actions_json, mode) {
|
|
1272
|
+
let deferred4_0;
|
|
1273
|
+
let deferred4_1;
|
|
1274
|
+
try {
|
|
1275
|
+
const ptr0 = passStringToWasm0(actions_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1276
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1277
|
+
const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1278
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1279
|
+
const ret = wasm.filterShadowMode(ptr0, len0, ptr1, len1);
|
|
1280
|
+
var ptr3 = ret[0];
|
|
1281
|
+
var len3 = ret[1];
|
|
1282
|
+
if (ret[3]) {
|
|
1283
|
+
ptr3 = 0; len3 = 0;
|
|
1284
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1285
|
+
}
|
|
1286
|
+
deferred4_0 = ptr3;
|
|
1287
|
+
deferred4_1 = len3;
|
|
1288
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1289
|
+
} finally {
|
|
1290
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
/**
|
|
1295
|
+
* WASM binding for `find_best_near_duplicate`.
|
|
1296
|
+
*
|
|
1297
|
+
* `new_embedding_json`: JSON array of floats (embedding vector).
|
|
1298
|
+
* `existing_json`: JSON array of `{ id: string, embedding: number[] }` objects.
|
|
1299
|
+
* `threshold`: Cosine similarity threshold.
|
|
1300
|
+
*
|
|
1301
|
+
* Returns JSON `{ fact_id: string, similarity: number }` or null.
|
|
1302
|
+
* @param {string} new_embedding_json
|
|
1303
|
+
* @param {string} existing_json
|
|
1304
|
+
* @param {number} threshold
|
|
1305
|
+
* @returns {any}
|
|
1306
|
+
*/
|
|
1307
|
+
export function findBestNearDuplicate(new_embedding_json, existing_json, threshold) {
|
|
1308
|
+
const ptr0 = passStringToWasm0(new_embedding_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1309
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1310
|
+
const ptr1 = passStringToWasm0(existing_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1311
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1312
|
+
const ret = wasm.findBestNearDuplicate(ptr0, len0, ptr1, len1, threshold);
|
|
1313
|
+
if (ret[2]) {
|
|
1314
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1315
|
+
}
|
|
1316
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* Find a decision-log entry matching a fact as winner or loser.
|
|
1321
|
+
* Returns the JSON-serialized DecisionLogEntry, or the literal string "null".
|
|
1322
|
+
* @param {string} fact_id
|
|
1323
|
+
* @param {string} role
|
|
1324
|
+
* @param {string} log_content
|
|
1325
|
+
* @returns {string}
|
|
1326
|
+
*/
|
|
1327
|
+
export function findDecisionForPin(fact_id, role, log_content) {
|
|
1328
|
+
let deferred4_0;
|
|
1329
|
+
let deferred4_1;
|
|
1330
|
+
try {
|
|
1331
|
+
const ptr0 = passStringToWasm0(fact_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1332
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1333
|
+
const ptr1 = passStringToWasm0(role, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1334
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1335
|
+
const ptr2 = passStringToWasm0(log_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1336
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1337
|
+
const ret = wasm.findDecisionForPin(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1338
|
+
deferred4_0 = ret[0];
|
|
1339
|
+
deferred4_1 = ret[1];
|
|
1340
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1341
|
+
} finally {
|
|
1342
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
/**
|
|
1347
|
+
* Find the loser claim JSON from the decision log for a given fact ID.
|
|
1348
|
+
* Returns the loser_claim_json string, or the literal string "null" if not found.
|
|
1349
|
+
* @param {string} fact_id
|
|
1350
|
+
* @param {string} log_content
|
|
1351
|
+
* @returns {string}
|
|
1352
|
+
*/
|
|
1353
|
+
export function findLoserClaimInDecisionLog(fact_id, log_content) {
|
|
1354
|
+
let deferred3_0;
|
|
1355
|
+
let deferred3_1;
|
|
1356
|
+
try {
|
|
1357
|
+
const ptr0 = passStringToWasm0(fact_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1358
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1359
|
+
const ptr1 = passStringToWasm0(log_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1360
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1361
|
+
const ret = wasm.findLoserClaimInDecisionLog(ptr0, len0, ptr1, len1);
|
|
1362
|
+
deferred3_0 = ret[0];
|
|
1363
|
+
deferred3_1 = ret[1];
|
|
1364
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1365
|
+
} finally {
|
|
1366
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
/**
|
|
1371
|
+
* WASM binding for `find_near_duplicate` (deprecated — use `findBestNearDuplicate`).
|
|
1372
|
+
*
|
|
1373
|
+
* **Deprecated since core 1.5.0; scheduled for removal in core 3.0.** Returns
|
|
1374
|
+
* the *first* match above `threshold`, not the highest-similarity one. Migrate
|
|
1375
|
+
* npm consumers to `findBestNearDuplicate`.
|
|
1376
|
+
*
|
|
1377
|
+
* `new_embedding`: Float32Array of the new fact's embedding.
|
|
1378
|
+
* `existing_json`: JSON array of `{ id: string, embedding: number[] }` objects.
|
|
1379
|
+
* `threshold`: Cosine similarity threshold.
|
|
1380
|
+
*
|
|
1381
|
+
* Returns `null` if no duplicate found, or a string (the duplicate fact ID).
|
|
1382
|
+
* @param {Float32Array} new_embedding
|
|
1383
|
+
* @param {string} existing_json
|
|
1384
|
+
* @param {number} threshold
|
|
1385
|
+
* @returns {any}
|
|
1386
|
+
*/
|
|
1387
|
+
export function findNearDuplicate(new_embedding, existing_json, threshold) {
|
|
1388
|
+
const ptr0 = passArrayF32ToWasm0(new_embedding, wasm.__wbindgen_malloc);
|
|
1389
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1390
|
+
const ptr1 = passStringToWasm0(existing_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1391
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1392
|
+
const ret = wasm.findNearDuplicate(ptr0, len0, ptr1, len1, threshold);
|
|
1393
|
+
if (ret[2]) {
|
|
1394
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1395
|
+
}
|
|
1396
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
/**
|
|
1400
|
+
* Unix seconds → `"YYYY-MM-DD"` (UTC). Returns `""` for `0` or negative.
|
|
1401
|
+
*
|
|
1402
|
+
* Maps directly to [`crate::recall_context::format_memory_date`].
|
|
1403
|
+
* @param {bigint} created_at_unix
|
|
1404
|
+
* @returns {string}
|
|
1405
|
+
*/
|
|
1406
|
+
export function formatMemoryDate(created_at_unix) {
|
|
1407
|
+
let deferred1_0;
|
|
1408
|
+
let deferred1_1;
|
|
1409
|
+
try {
|
|
1410
|
+
const ret = wasm.formatMemoryDate(created_at_unix);
|
|
1411
|
+
deferred1_0 = ret[0];
|
|
1412
|
+
deferred1_1 = ret[1];
|
|
1413
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1414
|
+
} finally {
|
|
1415
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
/**
|
|
1420
|
+
* Build the full recall-context block: header + one line per memory item.
|
|
1421
|
+
*
|
|
1422
|
+
* `items_json`: JSON array of `{ category, text, created_at }`. Any field
|
|
1423
|
+
* may be absent (defaults to empty string / 0). Bad or empty JSON → header
|
|
1424
|
+
* only (no panic).
|
|
1425
|
+
*
|
|
1426
|
+
* Output line format:
|
|
1427
|
+
* - With date: `"- [category] (YYYY-MM-DD) text"`
|
|
1428
|
+
* - Without date: `"- [category] text"`
|
|
1429
|
+
*
|
|
1430
|
+
* `now_unix`: current time as Unix seconds (used in the header date).
|
|
1431
|
+
* @param {string} items_json
|
|
1432
|
+
* @param {bigint} now_unix
|
|
1433
|
+
* @returns {string}
|
|
1434
|
+
*/
|
|
1435
|
+
export function formatRecallContext(items_json, now_unix) {
|
|
1436
|
+
let deferred2_0;
|
|
1437
|
+
let deferred2_1;
|
|
1438
|
+
try {
|
|
1439
|
+
const ptr0 = passStringToWasm0(items_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1440
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1441
|
+
const ret = wasm.formatRecallContext(ptr0, len0, now_unix);
|
|
1442
|
+
deferred2_0 = ret[0];
|
|
1443
|
+
deferred2_1 = ret[1];
|
|
1444
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1445
|
+
} finally {
|
|
1446
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
/**
|
|
1451
|
+
* Generate blind indices (SHA-256 token hashes) for a text string.
|
|
1452
|
+
*
|
|
1453
|
+
* Returns a JSON array of hex strings.
|
|
1454
|
+
* @param {string} text
|
|
1455
|
+
* @returns {any}
|
|
1456
|
+
*/
|
|
1457
|
+
export function generateBlindIndices(text) {
|
|
1458
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1459
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1460
|
+
const ret = wasm.generateBlindIndices(ptr0, len0);
|
|
1461
|
+
if (ret[2]) {
|
|
1462
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1463
|
+
}
|
|
1464
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
/**
|
|
1468
|
+
* Compute HMAC-SHA256 content fingerprint.
|
|
1469
|
+
*
|
|
1470
|
+
* `dedup_key_hex`: 64-char hex string (32 bytes).
|
|
1471
|
+
* Returns 64-char hex fingerprint.
|
|
1472
|
+
* @param {string} plaintext
|
|
1473
|
+
* @param {string} dedup_key_hex
|
|
1474
|
+
* @returns {string}
|
|
1475
|
+
*/
|
|
1476
|
+
export function generateContentFingerprint(plaintext, dedup_key_hex) {
|
|
1477
|
+
let deferred4_0;
|
|
1478
|
+
let deferred4_1;
|
|
1479
|
+
try {
|
|
1480
|
+
const ptr0 = passStringToWasm0(plaintext, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1481
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1482
|
+
const ptr1 = passStringToWasm0(dedup_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1483
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1484
|
+
const ret = wasm.generateContentFingerprint(ptr0, len0, ptr1, len1);
|
|
1485
|
+
var ptr3 = ret[0];
|
|
1486
|
+
var len3 = ret[1];
|
|
1487
|
+
if (ret[3]) {
|
|
1488
|
+
ptr3 = 0; len3 = 0;
|
|
1489
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1490
|
+
}
|
|
1491
|
+
deferred4_0 = ptr3;
|
|
1492
|
+
deferred4_1 = len3;
|
|
1493
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1494
|
+
} finally {
|
|
1495
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
/**
|
|
1500
|
+
* Generate trapdoors for multiple query reformulations (expansion pipeline).
|
|
1501
|
+
*
|
|
1502
|
+
* `queries_json`: JSON array of query strings (original + reformulations).
|
|
1503
|
+
* `embeddings_json`: JSON array of Float32Array-compatible arrays (one per query).
|
|
1504
|
+
* `lsh_hasher`: A `WasmLshHasher` instance.
|
|
1505
|
+
*
|
|
1506
|
+
* Returns a JsValue (JSON array of trapdoor-string arrays, one per query).
|
|
1507
|
+
* @param {string} queries_json
|
|
1508
|
+
* @param {string} embeddings_json
|
|
1509
|
+
* @param {WasmLshHasher} lsh_hasher
|
|
1510
|
+
* @returns {any}
|
|
1511
|
+
*/
|
|
1512
|
+
export function generateExpansionTrapdoors(queries_json, embeddings_json, lsh_hasher) {
|
|
1513
|
+
const ptr0 = passStringToWasm0(queries_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1514
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1515
|
+
const ptr1 = passStringToWasm0(embeddings_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1516
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1517
|
+
_assertClass(lsh_hasher, WasmLshHasher);
|
|
1518
|
+
const ret = wasm.generateExpansionTrapdoors(ptr0, len0, ptr1, len1, lsh_hasher.__wbg_ptr);
|
|
1519
|
+
if (ret[2]) {
|
|
1520
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1521
|
+
}
|
|
1522
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
/**
|
|
1526
|
+
* Generate all search trapdoors for a query (word hashes + LSH bucket hashes).
|
|
1527
|
+
*
|
|
1528
|
+
* `query`: The search query text.
|
|
1529
|
+
* `query_embedding`: Float32Array of the query embedding.
|
|
1530
|
+
* `lsh_hasher`: A `WasmLshHasher` instance.
|
|
1531
|
+
*
|
|
1532
|
+
* Returns a JsValue (JSON array of hex-encoded trapdoor strings).
|
|
1533
|
+
* @param {string} query
|
|
1534
|
+
* @param {Float32Array} query_embedding
|
|
1535
|
+
* @param {WasmLshHasher} lsh_hasher
|
|
1536
|
+
* @returns {any}
|
|
1537
|
+
*/
|
|
1538
|
+
export function generateSearchTrapdoors(query, query_embedding, lsh_hasher) {
|
|
1539
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1540
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1541
|
+
const ptr1 = passArrayF32ToWasm0(query_embedding, wasm.__wbindgen_malloc);
|
|
1542
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1543
|
+
_assertClass(lsh_hasher, WasmLshHasher);
|
|
1544
|
+
const ret = wasm.generateSearchTrapdoors(ptr0, len0, ptr1, len1, lsh_hasher.__wbg_ptr);
|
|
1545
|
+
if (ret[2]) {
|
|
1546
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1547
|
+
}
|
|
1548
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
/**
|
|
1552
|
+
* Get the GraphQL query string for broadened (fallback) search.
|
|
1553
|
+
* @returns {string}
|
|
1554
|
+
*/
|
|
1555
|
+
export function getBroadenedSearchQuery() {
|
|
1556
|
+
let deferred1_0;
|
|
1557
|
+
let deferred1_1;
|
|
1558
|
+
try {
|
|
1559
|
+
const ret = wasm.getBroadenedSearchQuery();
|
|
1560
|
+
deferred1_0 = ret[0];
|
|
1561
|
+
deferred1_1 = ret[1];
|
|
1562
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1563
|
+
} finally {
|
|
1564
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
/**
|
|
1569
|
+
* Get the canonical v1 compaction system prompt.
|
|
1570
|
+
*
|
|
1571
|
+
* Used on end-of-context surfaces where the importance floor is 5 rather
|
|
1572
|
+
* than the default 6.
|
|
1573
|
+
* @returns {string}
|
|
1574
|
+
*/
|
|
1575
|
+
export function getCompactionSystemPrompt() {
|
|
1576
|
+
let deferred1_0;
|
|
1577
|
+
let deferred1_1;
|
|
1578
|
+
try {
|
|
1579
|
+
const ret = wasm.getCompactionSystemPrompt();
|
|
1580
|
+
deferred1_0 = ret[0];
|
|
1581
|
+
deferred1_1 = ret[1];
|
|
1582
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1583
|
+
} finally {
|
|
1584
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
/**
|
|
1589
|
+
* WASM binding: get the consolidation cosine threshold constant.
|
|
1590
|
+
* @returns {number}
|
|
1591
|
+
*/
|
|
1592
|
+
export function getConsolidationCosineThreshold() {
|
|
1593
|
+
const ret = wasm.getConsolidationCosineThreshold();
|
|
1594
|
+
return ret;
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
/**
|
|
1598
|
+
* Get the GraphQL query string for fact count.
|
|
1599
|
+
* @returns {string}
|
|
1600
|
+
*/
|
|
1601
|
+
export function getCountQuery() {
|
|
1602
|
+
let deferred1_0;
|
|
1603
|
+
let deferred1_1;
|
|
1604
|
+
try {
|
|
1605
|
+
const ret = wasm.getCountQuery();
|
|
1606
|
+
deferred1_0 = ret[0];
|
|
1607
|
+
deferred1_1 = ret[1];
|
|
1608
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1609
|
+
} finally {
|
|
1610
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
/**
|
|
1615
|
+
* Get the DataEdge contract address constant.
|
|
1616
|
+
* @returns {string}
|
|
1617
|
+
*/
|
|
1618
|
+
export function getDataEdgeAddress() {
|
|
1619
|
+
let deferred1_0;
|
|
1620
|
+
let deferred1_1;
|
|
1621
|
+
try {
|
|
1622
|
+
const ret = wasm.getDataEdgeAddress();
|
|
1623
|
+
deferred1_0 = ret[0];
|
|
1624
|
+
deferred1_1 = ret[1];
|
|
1625
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1626
|
+
} finally {
|
|
1627
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
/**
|
|
1632
|
+
* Source tag for debrief items.
|
|
1633
|
+
* @returns {string}
|
|
1634
|
+
*/
|
|
1635
|
+
export function getDebriefSource() {
|
|
1636
|
+
let deferred1_0;
|
|
1637
|
+
let deferred1_1;
|
|
1638
|
+
try {
|
|
1639
|
+
const ret = wasm.getDebriefSource();
|
|
1640
|
+
deferred1_0 = ret[0];
|
|
1641
|
+
deferred1_1 = ret[1];
|
|
1642
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1643
|
+
} finally {
|
|
1644
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
/**
|
|
1649
|
+
* Get the canonical debrief system prompt template.
|
|
1650
|
+
*
|
|
1651
|
+
* Contains `{already_stored_facts}` placeholder.
|
|
1652
|
+
* @returns {string}
|
|
1653
|
+
*/
|
|
1654
|
+
export function getDebriefSystemPrompt() {
|
|
1655
|
+
let deferred1_0;
|
|
1656
|
+
let deferred1_1;
|
|
1657
|
+
try {
|
|
1658
|
+
const ret = wasm.getDebriefSystemPrompt();
|
|
1659
|
+
deferred1_0 = ret[0];
|
|
1660
|
+
deferred1_1 = ret[1];
|
|
1661
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1662
|
+
} finally {
|
|
1663
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
/**
|
|
1668
|
+
* Get the EntryPoint v0.7 address constant.
|
|
1669
|
+
* @returns {string}
|
|
1670
|
+
*/
|
|
1671
|
+
export function getEntryPointAddress() {
|
|
1672
|
+
let deferred1_0;
|
|
1673
|
+
let deferred1_1;
|
|
1674
|
+
try {
|
|
1675
|
+
const ret = wasm.getEntryPointAddress();
|
|
1676
|
+
deferred1_0 = ret[0];
|
|
1677
|
+
deferred1_1 = ret[1];
|
|
1678
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1679
|
+
} finally {
|
|
1680
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
/**
|
|
1685
|
+
* Get the GraphQL query string for paginated export.
|
|
1686
|
+
* @returns {string}
|
|
1687
|
+
*/
|
|
1688
|
+
export function getExportQuery() {
|
|
1689
|
+
let deferred1_0;
|
|
1690
|
+
let deferred1_1;
|
|
1691
|
+
try {
|
|
1692
|
+
const ret = wasm.getExportQuery();
|
|
1693
|
+
deferred1_0 = ret[0];
|
|
1694
|
+
deferred1_1 = ret[1];
|
|
1695
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1696
|
+
} finally {
|
|
1697
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
/**
|
|
1702
|
+
* Get the canonical v1 merged-topic extraction system prompt.
|
|
1703
|
+
*
|
|
1704
|
+
* Single source of truth across all TotalReclaw clients — TS/WASM
|
|
1705
|
+
* callers get the same bytes the Python `totalreclaw_core` module
|
|
1706
|
+
* returns from `get_extraction_system_prompt()`. Includes the Rule 6
|
|
1707
|
+
* meta-request filter (see the docstring on `prompts.rs`).
|
|
1708
|
+
* @returns {string}
|
|
1709
|
+
*/
|
|
1710
|
+
export function getExtractionSystemPrompt() {
|
|
1711
|
+
let deferred1_0;
|
|
1712
|
+
let deferred1_1;
|
|
1713
|
+
try {
|
|
1714
|
+
const ret = wasm.getExtractionSystemPrompt();
|
|
1715
|
+
deferred1_0 = ret[0];
|
|
1716
|
+
deferred1_1 = ret[1];
|
|
1717
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1718
|
+
} finally {
|
|
1719
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
/**
|
|
1724
|
+
* Get the maximum batch size constant.
|
|
1725
|
+
* @returns {number}
|
|
1726
|
+
*/
|
|
1727
|
+
export function getMaxBatchSize() {
|
|
1728
|
+
const ret = wasm.getMaxBatchSize();
|
|
1729
|
+
return ret >>> 0;
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
/**
|
|
1733
|
+
* Maximum debrief items (5).
|
|
1734
|
+
* @returns {number}
|
|
1735
|
+
*/
|
|
1736
|
+
export function getMaxDebriefItems() {
|
|
1737
|
+
const ret = wasm.getMaxDebriefItems();
|
|
1738
|
+
return ret >>> 0;
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
/**
|
|
1742
|
+
* Minimum messages for debrief (8 = 4 turns).
|
|
1743
|
+
* @returns {number}
|
|
1744
|
+
*/
|
|
1745
|
+
export function getMinDebriefMessages() {
|
|
1746
|
+
const ret = wasm.getMinDebriefMessages();
|
|
1747
|
+
return ret >>> 0;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
/**
|
|
1751
|
+
* Get the page size constant.
|
|
1752
|
+
* @returns {number}
|
|
1753
|
+
*/
|
|
1754
|
+
export function getPageSize() {
|
|
1755
|
+
const ret = wasm.getPageSize();
|
|
1756
|
+
return ret >>> 0;
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
/**
|
|
1760
|
+
* Get the GraphQL query string for blind index search.
|
|
1761
|
+
* @returns {string}
|
|
1762
|
+
*/
|
|
1763
|
+
export function getSearchQuery() {
|
|
1764
|
+
let deferred1_0;
|
|
1765
|
+
let deferred1_1;
|
|
1766
|
+
try {
|
|
1767
|
+
const ret = wasm.getSearchQuery();
|
|
1768
|
+
deferred1_0 = ret[0];
|
|
1769
|
+
deferred1_1 = ret[1];
|
|
1770
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1771
|
+
} finally {
|
|
1772
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
/**
|
|
1777
|
+
* Get the SimpleAccountFactory address constant.
|
|
1778
|
+
* @returns {string}
|
|
1779
|
+
*/
|
|
1780
|
+
export function getSimpleAccountFactory() {
|
|
1781
|
+
let deferred1_0;
|
|
1782
|
+
let deferred1_1;
|
|
1783
|
+
try {
|
|
1784
|
+
const ret = wasm.getSimpleAccountFactory();
|
|
1785
|
+
deferred1_0 = ret[0];
|
|
1786
|
+
deferred1_1 = ret[1];
|
|
1787
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1788
|
+
} finally {
|
|
1789
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
/**
|
|
1794
|
+
* WASM binding: get the store-time dedup cosine threshold constant.
|
|
1795
|
+
* @returns {number}
|
|
1796
|
+
*/
|
|
1797
|
+
export function getStoreDedupCosineThreshold() {
|
|
1798
|
+
const ret = wasm.getStoreDedupCosineThreshold();
|
|
1799
|
+
return ret;
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
/**
|
|
1803
|
+
* WASM binding: get the store-time dedup max candidates constant.
|
|
1804
|
+
* @returns {number}
|
|
1805
|
+
*/
|
|
1806
|
+
export function getStoreDedupMaxCandidates() {
|
|
1807
|
+
const ret = wasm.getStoreDedupMaxCandidates();
|
|
1808
|
+
return ret >>> 0;
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
/**
|
|
1812
|
+
* Get the trapdoor batch size constant.
|
|
1813
|
+
* @returns {number}
|
|
1814
|
+
*/
|
|
1815
|
+
export function getTrapdoorBatchSize() {
|
|
1816
|
+
const ret = wasm.getTrapdoorBatchSize();
|
|
1817
|
+
return ret >>> 0;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
/**
|
|
1821
|
+
* Get the v1 type → short-form category mapping.
|
|
1822
|
+
*
|
|
1823
|
+
* Returns a plain JS object `{ claim: "claim", preference: "pref",
|
|
1824
|
+
* directive: "rule", commitment: "goal", episode: "epi",
|
|
1825
|
+
* summary: "sum" }`.
|
|
1826
|
+
*
|
|
1827
|
+
* Uses `js_sys::Object.set` directly so the result is a plain JS
|
|
1828
|
+
* object (not a `Map`) regardless of serde-wasm-bindgen defaults,
|
|
1829
|
+
* matching how TypeScript clients consume the mapping via bracket
|
|
1830
|
+
* access (`map[type]`).
|
|
1831
|
+
* @returns {any}
|
|
1832
|
+
*/
|
|
1833
|
+
export function getTypeToCategory() {
|
|
1834
|
+
const ret = wasm.getTypeToCategory();
|
|
1835
|
+
if (ret[2]) {
|
|
1836
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1837
|
+
}
|
|
1838
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
/**
|
|
1842
|
+
* Get the canonical list of v1 memory types.
|
|
1843
|
+
*
|
|
1844
|
+
* Returns a JS array of six strings: `["claim", "preference",
|
|
1845
|
+
* "directive", "commitment", "episode", "summary"]`.
|
|
1846
|
+
* @returns {any}
|
|
1847
|
+
*/
|
|
1848
|
+
export function getValidMemoryTypes() {
|
|
1849
|
+
const ret = wasm.getValidMemoryTypes();
|
|
1850
|
+
if (ret[2]) {
|
|
1851
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1852
|
+
}
|
|
1853
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
/**
|
|
1857
|
+
* Compute the ERC-4337 v0.7 UserOp hash for signing.
|
|
1858
|
+
*
|
|
1859
|
+
* `userop_json`: JSON string of a UserOperationV7 struct.
|
|
1860
|
+
* `entrypoint`: EntryPoint address (0x-prefixed).
|
|
1861
|
+
* `chain_id`: Chain ID (e.g. 84532 for Base Sepolia).
|
|
1862
|
+
* Returns 32-byte hash as hex string.
|
|
1863
|
+
* @param {string} userop_json
|
|
1864
|
+
* @param {string} entrypoint
|
|
1865
|
+
* @param {bigint} chain_id
|
|
1866
|
+
* @returns {string}
|
|
1867
|
+
*/
|
|
1868
|
+
export function hashUserOp(userop_json, entrypoint, chain_id) {
|
|
1869
|
+
let deferred4_0;
|
|
1870
|
+
let deferred4_1;
|
|
1871
|
+
try {
|
|
1872
|
+
const ptr0 = passStringToWasm0(userop_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1873
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1874
|
+
const ptr1 = passStringToWasm0(entrypoint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1875
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1876
|
+
const ret = wasm.hashUserOp(ptr0, len0, ptr1, len1, chain_id);
|
|
1877
|
+
var ptr3 = ret[0];
|
|
1878
|
+
var len3 = ret[1];
|
|
1879
|
+
if (ret[3]) {
|
|
1880
|
+
ptr3 = 0; len3 = 0;
|
|
1881
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1882
|
+
}
|
|
1883
|
+
deferred4_0 = ptr3;
|
|
1884
|
+
deferred4_1 = len3;
|
|
1885
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1886
|
+
} finally {
|
|
1887
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
/**
|
|
1892
|
+
* Convert a subgraph hex blob to base64 for decryption.
|
|
1893
|
+
*
|
|
1894
|
+
* `hex_blob`: Hex string (optionally `0x`-prefixed) from the subgraph.
|
|
1895
|
+
* Returns base64-encoded bytes, or null if the hex is invalid.
|
|
1896
|
+
* @param {string} hex_blob
|
|
1897
|
+
* @returns {string | undefined}
|
|
1898
|
+
*/
|
|
1899
|
+
export function hexBlobToBase64(hex_blob) {
|
|
1900
|
+
const ptr0 = passStringToWasm0(hex_blob, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1901
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1902
|
+
const ret = wasm.hexBlobToBase64(ptr0, len0);
|
|
1903
|
+
let v2;
|
|
1904
|
+
if (ret[0] !== 0) {
|
|
1905
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
1906
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1907
|
+
}
|
|
1908
|
+
return v2;
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
/**
|
|
1912
|
+
* Check whether a JSON-serialized claim has pinned status.
|
|
1913
|
+
* @param {string} claim_json
|
|
1914
|
+
* @returns {boolean}
|
|
1915
|
+
*/
|
|
1916
|
+
export function isPinnedClaim(claim_json) {
|
|
1917
|
+
const ptr0 = passStringToWasm0(claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1918
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1919
|
+
const ret = wasm.isPinnedClaim(ptr0, len0);
|
|
1920
|
+
return ret !== 0;
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
/**
|
|
1924
|
+
* Check whether a JSON-encoded claim is pinned, recognizing both the v0
|
|
1925
|
+
* short-key sentinel (`st == "p"`) and the v1.1 field (`pin_status ==
|
|
1926
|
+
* "pinned"`). Returns `false` on any parse failure.
|
|
1927
|
+
*
|
|
1928
|
+
* Wrapper around [`crate::claims::is_pinned_json`] for TS clients.
|
|
1929
|
+
* @param {string} claim_json
|
|
1930
|
+
* @returns {boolean}
|
|
1931
|
+
*/
|
|
1932
|
+
export function isPinnedClaimJson(claim_json) {
|
|
1933
|
+
const ptr0 = passStringToWasm0(claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1934
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1935
|
+
const ret = wasm.isPinnedClaimJson(ptr0, len0);
|
|
1936
|
+
return ret !== 0;
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
/**
|
|
1940
|
+
* Runtime guard: is `value` a valid v1 memory type?
|
|
1941
|
+
* @param {string} value
|
|
1942
|
+
* @returns {boolean}
|
|
1943
|
+
*/
|
|
1944
|
+
export function isValidMemoryType(value) {
|
|
1945
|
+
const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1946
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1947
|
+
const ret = wasm.isValidMemoryType(ptr0, len0);
|
|
1948
|
+
return ret !== 0;
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
/**
|
|
1952
|
+
* Return the v1 legacy-claim fallback weight (applied to candidates that
|
|
1953
|
+
* have no `source` field).
|
|
1954
|
+
* @returns {number}
|
|
1955
|
+
*/
|
|
1956
|
+
export function legacyClaimFallbackWeight() {
|
|
1957
|
+
const ret = wasm.legacyClaimFallbackWeight();
|
|
1958
|
+
return ret;
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
/**
|
|
1962
|
+
* Map a v1 type to its short-form category key.
|
|
1963
|
+
*
|
|
1964
|
+
* Returns `null` if `value` is not one of the six v1 types.
|
|
1965
|
+
* @param {string} value
|
|
1966
|
+
* @returns {any}
|
|
1967
|
+
*/
|
|
1968
|
+
export function mapTypeToCategory(value) {
|
|
1969
|
+
const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1970
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1971
|
+
const ret = wasm.mapTypeToCategory(ptr0, len0);
|
|
1972
|
+
return ret;
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
/**
|
|
1976
|
+
* Merge multiple SubgraphFact sets from parallel query reformulations via RRF.
|
|
1977
|
+
*
|
|
1978
|
+
* `fact_sets_json`: JSON array of SubgraphFact arrays (one array per reformulation).
|
|
1979
|
+
* `rrf_k`: RRF k-parameter (use 60.0 for default behaviour).
|
|
1980
|
+
*
|
|
1981
|
+
* Returns a JsValue (merged, deduplicated SubgraphFact array sorted by RRF score).
|
|
1982
|
+
* @param {string} fact_sets_json
|
|
1983
|
+
* @param {number} rrf_k
|
|
1984
|
+
* @returns {any}
|
|
1985
|
+
*/
|
|
1986
|
+
export function mergeExpansionResults(fact_sets_json, rrf_k) {
|
|
1987
|
+
const ptr0 = passStringToWasm0(fact_sets_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1988
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1989
|
+
const ret = wasm.mergeExpansionResults(ptr0, len0, rrf_k);
|
|
1990
|
+
if (ret[2]) {
|
|
1991
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1992
|
+
}
|
|
1993
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
/**
|
|
1997
|
+
* Normalize an entity name (NFC, lowercase, trim, collapse whitespace).
|
|
1998
|
+
* @param {string} name
|
|
1999
|
+
* @returns {string}
|
|
2000
|
+
*/
|
|
2001
|
+
export function normalizeEntityName(name) {
|
|
2002
|
+
let deferred2_0;
|
|
2003
|
+
let deferred2_1;
|
|
2004
|
+
try {
|
|
2005
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2006
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2007
|
+
const ret = wasm.normalizeEntityName(ptr0, len0);
|
|
2008
|
+
deferred2_0 = ret[0];
|
|
2009
|
+
deferred2_1 = ret[1];
|
|
2010
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2011
|
+
} finally {
|
|
2012
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
/**
|
|
2017
|
+
* Normalize text (NFC, lowercase, collapse whitespace, trim).
|
|
2018
|
+
* @param {string} text
|
|
2019
|
+
* @returns {string}
|
|
2020
|
+
*/
|
|
2021
|
+
export function normalizeText(text) {
|
|
2022
|
+
let deferred2_0;
|
|
2023
|
+
let deferred2_1;
|
|
2024
|
+
try {
|
|
2025
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2026
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2027
|
+
const ret = wasm.normalizeText(ptr0, len0);
|
|
2028
|
+
deferred2_0 = ret[0];
|
|
2029
|
+
deferred2_1 = ret[1];
|
|
2030
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2031
|
+
} finally {
|
|
2032
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
/**
|
|
2037
|
+
* Parse a broadened search GraphQL response into SubgraphFact list.
|
|
2038
|
+
*
|
|
2039
|
+
* `response_json`: Raw JSON string from the GraphQL response.
|
|
2040
|
+
* Returns a JsValue (JSON array of SubgraphFact objects).
|
|
2041
|
+
* @param {string} response_json
|
|
2042
|
+
* @returns {any}
|
|
2043
|
+
*/
|
|
2044
|
+
export function parseBroadenedResponse(response_json) {
|
|
2045
|
+
const ptr0 = passStringToWasm0(response_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2046
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2047
|
+
const ret = wasm.parseBroadenedResponse(ptr0, len0);
|
|
2048
|
+
if (ret[2]) {
|
|
2049
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2050
|
+
}
|
|
2051
|
+
return takeFromExternrefTable0(ret[0]);
|
|
2052
|
+
}
|
|
2053
|
+
|
|
2054
|
+
/**
|
|
2055
|
+
* Parse a decrypted blob as a Claim, falling back to legacy formats.
|
|
2056
|
+
* Returns JSON-serialized Claim.
|
|
2057
|
+
* @param {string} decrypted
|
|
2058
|
+
* @returns {string}
|
|
2059
|
+
*/
|
|
2060
|
+
export function parseClaimOrLegacy(decrypted) {
|
|
2061
|
+
let deferred3_0;
|
|
2062
|
+
let deferred3_1;
|
|
2063
|
+
try {
|
|
2064
|
+
const ptr0 = passStringToWasm0(decrypted, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2065
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2066
|
+
const ret = wasm.parseClaimOrLegacy(ptr0, len0);
|
|
2067
|
+
var ptr2 = ret[0];
|
|
2068
|
+
var len2 = ret[1];
|
|
2069
|
+
if (ret[3]) {
|
|
2070
|
+
ptr2 = 0; len2 = 0;
|
|
2071
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2072
|
+
}
|
|
2073
|
+
deferred3_0 = ptr2;
|
|
2074
|
+
deferred3_1 = len2;
|
|
2075
|
+
return getStringFromWasm0(ptr2, len2);
|
|
2076
|
+
} finally {
|
|
2077
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
/**
|
|
2082
|
+
* Parse a debrief LLM response into validated items.
|
|
2083
|
+
*
|
|
2084
|
+
* Returns a JSON array of `{ text, type, importance }` objects.
|
|
2085
|
+
* @param {string} response
|
|
2086
|
+
* @returns {any}
|
|
2087
|
+
*/
|
|
2088
|
+
export function parseDebriefResponse(response) {
|
|
2089
|
+
const ptr0 = passStringToWasm0(response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2090
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2091
|
+
const ret = wasm.parseDebriefResponse(ptr0, len0);
|
|
2092
|
+
if (ret[2]) {
|
|
2093
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2094
|
+
}
|
|
2095
|
+
return takeFromExternrefTable0(ret[0]);
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
/**
|
|
2099
|
+
* Parse an LLM digest response.
|
|
2100
|
+
* Returns JSON-serialized ParsedDigestResponse.
|
|
2101
|
+
* @param {string} raw
|
|
2102
|
+
* @returns {string}
|
|
2103
|
+
*/
|
|
2104
|
+
export function parseDigestResponse(raw) {
|
|
2105
|
+
let deferred3_0;
|
|
2106
|
+
let deferred3_1;
|
|
2107
|
+
try {
|
|
2108
|
+
const ptr0 = passStringToWasm0(raw, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2109
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2110
|
+
const ret = wasm.parseDigestResponse(ptr0, len0);
|
|
2111
|
+
var ptr2 = ret[0];
|
|
2112
|
+
var len2 = ret[1];
|
|
2113
|
+
if (ret[3]) {
|
|
2114
|
+
ptr2 = 0; len2 = 0;
|
|
2115
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2116
|
+
}
|
|
2117
|
+
deferred3_0 = ptr2;
|
|
2118
|
+
deferred3_1 = len2;
|
|
2119
|
+
return getStringFromWasm0(ptr2, len2);
|
|
2120
|
+
} finally {
|
|
2121
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
/**
|
|
2126
|
+
* Parse a Gemini export (JSON or saved-info text) into a `ParseResult`.
|
|
2127
|
+
* @param {string} input
|
|
2128
|
+
* @returns {any}
|
|
2129
|
+
*/
|
|
2130
|
+
export function parseGemini(input) {
|
|
2131
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2132
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2133
|
+
const ret = wasm.parseGemini(ptr0, len0);
|
|
2134
|
+
if (ret[2]) {
|
|
2135
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2136
|
+
}
|
|
2137
|
+
return takeFromExternrefTable0(ret[0]);
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
/**
|
|
2141
|
+
* Case-insensitive parse of a memory source string. Unknown input returns "user-inferred".
|
|
2142
|
+
* @param {string} s
|
|
2143
|
+
* @returns {string}
|
|
2144
|
+
*/
|
|
2145
|
+
export function parseMemorySource(s) {
|
|
2146
|
+
let deferred2_0;
|
|
2147
|
+
let deferred2_1;
|
|
2148
|
+
try {
|
|
2149
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2150
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2151
|
+
const ret = wasm.parseMemorySource(ptr0, len0);
|
|
2152
|
+
deferred2_0 = ret[0];
|
|
2153
|
+
deferred2_1 = ret[1];
|
|
2154
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2155
|
+
} finally {
|
|
2156
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
/**
|
|
2161
|
+
* Case-insensitive parse of a memory type string. Unknown input returns "claim".
|
|
2162
|
+
* @param {string} s
|
|
2163
|
+
* @returns {string}
|
|
2164
|
+
*/
|
|
2165
|
+
export function parseMemoryTypeV1(s) {
|
|
2166
|
+
let deferred2_0;
|
|
2167
|
+
let deferred2_1;
|
|
2168
|
+
try {
|
|
2169
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2170
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2171
|
+
const ret = wasm.parseMemoryTypeV1(ptr0, len0);
|
|
2172
|
+
deferred2_0 = ret[0];
|
|
2173
|
+
deferred2_1 = ret[1];
|
|
2174
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2175
|
+
} finally {
|
|
2176
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
/**
|
|
2181
|
+
* Case-insensitive parse of a v1.1 pin_status string. Unknown input returns "unpinned".
|
|
2182
|
+
* @param {string} s
|
|
2183
|
+
* @returns {string}
|
|
2184
|
+
*/
|
|
2185
|
+
export function parsePinStatus(s) {
|
|
2186
|
+
let deferred2_0;
|
|
2187
|
+
let deferred2_1;
|
|
2188
|
+
try {
|
|
2189
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2190
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2191
|
+
const ret = wasm.parsePinStatus(ptr0, len0);
|
|
2192
|
+
deferred2_0 = ret[0];
|
|
2193
|
+
deferred2_1 = ret[1];
|
|
2194
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2195
|
+
} finally {
|
|
2196
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2200
|
+
/**
|
|
2201
|
+
* Parse a batch profiling LLM response into a PartialProfile.
|
|
2202
|
+
*
|
|
2203
|
+
* `llm_output`: Raw LLM response string.
|
|
2204
|
+
* Returns a JsValue (PartialProfile object).
|
|
2205
|
+
* @param {string} llm_output
|
|
2206
|
+
* @returns {any}
|
|
2207
|
+
*/
|
|
2208
|
+
export function parseProfileBatchResponse(llm_output) {
|
|
2209
|
+
const ptr0 = passStringToWasm0(llm_output, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2210
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2211
|
+
const ret = wasm.parseProfileBatchResponse(ptr0, len0);
|
|
2212
|
+
if (ret[2]) {
|
|
2213
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2214
|
+
}
|
|
2215
|
+
return takeFromExternrefTable0(ret[0]);
|
|
2216
|
+
}
|
|
2217
|
+
|
|
2218
|
+
/**
|
|
2219
|
+
* Parse the merge LLM response into a UserProfile.
|
|
2220
|
+
*
|
|
2221
|
+
* `llm_output`: Raw LLM response string.
|
|
2222
|
+
* Returns a JsValue (UserProfile object).
|
|
2223
|
+
* @param {string} llm_output
|
|
2224
|
+
* @returns {any}
|
|
2225
|
+
*/
|
|
2226
|
+
export function parseProfileResponse(llm_output) {
|
|
2227
|
+
const ptr0 = passStringToWasm0(llm_output, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2228
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2229
|
+
const ret = wasm.parseProfileResponse(ptr0, len0);
|
|
2230
|
+
if (ret[2]) {
|
|
2231
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2232
|
+
}
|
|
2233
|
+
return takeFromExternrefTable0(ret[0]);
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
/**
|
|
2237
|
+
* Parse a blind index search GraphQL response into SubgraphFact list.
|
|
2238
|
+
*
|
|
2239
|
+
* `response_json`: Raw JSON string from the GraphQL response.
|
|
2240
|
+
* Returns a JsValue (JSON array of SubgraphFact objects).
|
|
2241
|
+
* @param {string} response_json
|
|
2242
|
+
* @returns {any}
|
|
2243
|
+
*/
|
|
2244
|
+
export function parseSearchResponse(response_json) {
|
|
2245
|
+
const ptr0 = passStringToWasm0(response_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2246
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2247
|
+
const ret = wasm.parseSearchResponse(ptr0, len0);
|
|
2248
|
+
if (ret[2]) {
|
|
2249
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2250
|
+
}
|
|
2251
|
+
return takeFromExternrefTable0(ret[0]);
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
/**
|
|
2255
|
+
* Parse the triage LLM response into chunk decisions.
|
|
2256
|
+
*
|
|
2257
|
+
* `llm_output`: Raw LLM response string.
|
|
2258
|
+
* Returns a JsValue (JSON array of ChunkDecision objects).
|
|
2259
|
+
* @param {string} llm_output
|
|
2260
|
+
* @returns {any}
|
|
2261
|
+
*/
|
|
2262
|
+
export function parseTriageResponse(llm_output) {
|
|
2263
|
+
const ptr0 = passStringToWasm0(llm_output, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2264
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2265
|
+
const ret = wasm.parseTriageResponse(ptr0, len0);
|
|
2266
|
+
if (ret[2]) {
|
|
2267
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2268
|
+
}
|
|
2269
|
+
return takeFromExternrefTable0(ret[0]);
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
/**
|
|
2273
|
+
* Parse a WeightsFile from JSON; rejects unknown versions and malformed input.
|
|
2274
|
+
* @param {string} content
|
|
2275
|
+
* @returns {string}
|
|
2276
|
+
*/
|
|
2277
|
+
export function parseWeightsFile(content) {
|
|
2278
|
+
let deferred3_0;
|
|
2279
|
+
let deferred3_1;
|
|
2280
|
+
try {
|
|
2281
|
+
const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2282
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2283
|
+
const ret = wasm.parseWeightsFile(ptr0, len0);
|
|
2284
|
+
var ptr2 = ret[0];
|
|
2285
|
+
var len2 = ret[1];
|
|
2286
|
+
if (ret[3]) {
|
|
2287
|
+
ptr2 = 0; len2 = 0;
|
|
2288
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2289
|
+
}
|
|
2290
|
+
deferred3_0 = ptr2;
|
|
2291
|
+
deferred3_1 = len2;
|
|
2292
|
+
return getStringFromWasm0(ptr2, len2);
|
|
2293
|
+
} finally {
|
|
2294
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
/**
|
|
2299
|
+
* Compute the [`PinTier`]'s multiplicative boost at a given timestamp.
|
|
2300
|
+
*
|
|
2301
|
+
* `tier_json`: internally-tagged JSON, e.g. `{"tier":"soft","pinned_at":1716000000}`,
|
|
2302
|
+
* `{"tier":"hard"}`, `{"tier":"none"}`.
|
|
2303
|
+
* `now_unix`: seconds since epoch.
|
|
2304
|
+
* `config_json`: JSON of [`PinConfig`], e.g. `{"soft_half_life_days":90,"soft_max_boost":1.5,"hard_boost":1.5}`.
|
|
2305
|
+
*
|
|
2306
|
+
* Returns the multiplicative boost factor (1.0 for `none`).
|
|
2307
|
+
* @param {string} tier_json
|
|
2308
|
+
* @param {bigint} now_unix
|
|
2309
|
+
* @param {string} config_json
|
|
2310
|
+
* @returns {number}
|
|
2311
|
+
*/
|
|
2312
|
+
export function pinBoost(tier_json, now_unix, config_json) {
|
|
2313
|
+
const ptr0 = passStringToWasm0(tier_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2314
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2315
|
+
const ptr1 = passStringToWasm0(config_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2316
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2317
|
+
const ret = wasm.pinBoost(ptr0, len0, now_unix, ptr1, len1);
|
|
2318
|
+
if (ret[2]) {
|
|
2319
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2320
|
+
}
|
|
2321
|
+
return ret[0];
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
/**
|
|
2325
|
+
* Prepare a fact for on-chain storage.
|
|
2326
|
+
*
|
|
2327
|
+
* Pure computation: encrypt, generate indices, encode protobuf.
|
|
2328
|
+
* Does NOT submit -- the host handles I/O.
|
|
2329
|
+
*
|
|
2330
|
+
* `encryption_key_hex`: 64-char hex string (32 bytes).
|
|
2331
|
+
* `dedup_key_hex`: 64-char hex string (32 bytes).
|
|
2332
|
+
* `lsh_hasher`: A `WasmLshHasher` instance.
|
|
2333
|
+
* `embedding`: Float32Array of the pre-computed embedding vector.
|
|
2334
|
+
* `importance`: Importance score on 1-10 scale (normalized to 0.0-1.0).
|
|
2335
|
+
*
|
|
2336
|
+
* Returns a JSON string with `PreparedFact` fields.
|
|
2337
|
+
* @param {string} text
|
|
2338
|
+
* @param {string} encryption_key_hex
|
|
2339
|
+
* @param {string} dedup_key_hex
|
|
2340
|
+
* @param {WasmLshHasher} lsh_hasher
|
|
2341
|
+
* @param {Float32Array} embedding
|
|
2342
|
+
* @param {number} importance
|
|
2343
|
+
* @param {string} source
|
|
2344
|
+
* @param {string} owner
|
|
2345
|
+
* @param {string} agent_id
|
|
2346
|
+
* @returns {any}
|
|
2347
|
+
*/
|
|
2348
|
+
export function prepareFact(text, encryption_key_hex, dedup_key_hex, lsh_hasher, embedding, importance, source, owner, agent_id) {
|
|
2349
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2350
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2351
|
+
const ptr1 = passStringToWasm0(encryption_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2352
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2353
|
+
const ptr2 = passStringToWasm0(dedup_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2354
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2355
|
+
_assertClass(lsh_hasher, WasmLshHasher);
|
|
2356
|
+
const ptr3 = passArrayF32ToWasm0(embedding, wasm.__wbindgen_malloc);
|
|
2357
|
+
const len3 = WASM_VECTOR_LEN;
|
|
2358
|
+
const ptr4 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2359
|
+
const len4 = WASM_VECTOR_LEN;
|
|
2360
|
+
const ptr5 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2361
|
+
const len5 = WASM_VECTOR_LEN;
|
|
2362
|
+
const ptr6 = passStringToWasm0(agent_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2363
|
+
const len6 = WASM_VECTOR_LEN;
|
|
2364
|
+
const ret = wasm.prepareFact(ptr0, len0, ptr1, len1, ptr2, len2, lsh_hasher.__wbg_ptr, ptr3, len3, importance, ptr4, len4, ptr5, len5, ptr6, len6);
|
|
2365
|
+
if (ret[2]) {
|
|
2366
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2367
|
+
}
|
|
2368
|
+
return takeFromExternrefTable0(ret[0]);
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
/**
|
|
2372
|
+
* Prepare a fact with a pre-normalized decay score (already 0.0-1.0).
|
|
2373
|
+
*
|
|
2374
|
+
* Same as `prepareFact()` but takes a raw decay score.
|
|
2375
|
+
* @param {string} text
|
|
2376
|
+
* @param {string} encryption_key_hex
|
|
2377
|
+
* @param {string} dedup_key_hex
|
|
2378
|
+
* @param {WasmLshHasher} lsh_hasher
|
|
2379
|
+
* @param {Float32Array} embedding
|
|
2380
|
+
* @param {number} decay_score
|
|
2381
|
+
* @param {string} source
|
|
2382
|
+
* @param {string} owner
|
|
2383
|
+
* @param {string} agent_id
|
|
2384
|
+
* @returns {any}
|
|
2385
|
+
*/
|
|
2386
|
+
export function prepareFactWithDecayScore(text, encryption_key_hex, dedup_key_hex, lsh_hasher, embedding, decay_score, source, owner, agent_id) {
|
|
2387
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2388
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2389
|
+
const ptr1 = passStringToWasm0(encryption_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2390
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2391
|
+
const ptr2 = passStringToWasm0(dedup_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2392
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2393
|
+
_assertClass(lsh_hasher, WasmLshHasher);
|
|
2394
|
+
const ptr3 = passArrayF32ToWasm0(embedding, wasm.__wbindgen_malloc);
|
|
2395
|
+
const len3 = WASM_VECTOR_LEN;
|
|
2396
|
+
const ptr4 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2397
|
+
const len4 = WASM_VECTOR_LEN;
|
|
2398
|
+
const ptr5 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2399
|
+
const len5 = WASM_VECTOR_LEN;
|
|
2400
|
+
const ptr6 = passStringToWasm0(agent_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2401
|
+
const len6 = WASM_VECTOR_LEN;
|
|
2402
|
+
const ret = wasm.prepareFactWithDecayScore(ptr0, len0, ptr1, len1, ptr2, len2, lsh_hasher.__wbg_ptr, ptr3, len3, decay_score, ptr4, len4, ptr5, len5, ptr6, len6);
|
|
2403
|
+
if (ret[2]) {
|
|
2404
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2405
|
+
}
|
|
2406
|
+
return takeFromExternrefTable0(ret[0]);
|
|
2407
|
+
}
|
|
2408
|
+
|
|
2409
|
+
/**
|
|
2410
|
+
* Prepare a tombstone (soft-delete) protobuf.
|
|
2411
|
+
*
|
|
2412
|
+
* Returns the protobuf bytes as a Uint8Array.
|
|
2413
|
+
* @param {string} fact_id
|
|
2414
|
+
* @param {string} owner
|
|
2415
|
+
* @returns {Uint8Array}
|
|
2416
|
+
*/
|
|
2417
|
+
export function prepareTombstone(fact_id, owner) {
|
|
2418
|
+
const ptr0 = passStringToWasm0(fact_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2419
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2420
|
+
const ptr1 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2421
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2422
|
+
const ret = wasm.prepareTombstone(ptr0, len0, ptr1, len1);
|
|
2423
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
2424
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
2425
|
+
return v3;
|
|
2426
|
+
}
|
|
2427
|
+
|
|
2428
|
+
/**
|
|
2429
|
+
* Parse JSONL content. Returns JSON: `{"entries": [...], "warnings": [...]}`.
|
|
2430
|
+
* @param {string} content
|
|
2431
|
+
* @returns {string}
|
|
2432
|
+
*/
|
|
2433
|
+
export function readFeedbackJsonl(content) {
|
|
2434
|
+
let deferred3_0;
|
|
2435
|
+
let deferred3_1;
|
|
2436
|
+
try {
|
|
2437
|
+
const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2438
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2439
|
+
const ret = wasm.readFeedbackJsonl(ptr0, len0);
|
|
2440
|
+
var ptr2 = ret[0];
|
|
2441
|
+
var len2 = ret[1];
|
|
2442
|
+
if (ret[3]) {
|
|
2443
|
+
ptr2 = 0; len2 = 0;
|
|
2444
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2445
|
+
}
|
|
2446
|
+
deferred3_0 = ptr2;
|
|
2447
|
+
deferred3_1 = len2;
|
|
2448
|
+
return getStringFromWasm0(ptr2, len2);
|
|
2449
|
+
} finally {
|
|
2450
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
|
|
2454
|
+
/**
|
|
2455
|
+
* Build the recall-context header string (current-date + temporal-reasoning nudge).
|
|
2456
|
+
*
|
|
2457
|
+
* `now_unix`: current time as Unix seconds.
|
|
2458
|
+
* Returns the header with a trailing newline, e.g.:
|
|
2459
|
+
* `"## Relevant memories from TotalReclaw\nThe current date is 2024-01-15. ..."`
|
|
2460
|
+
* @param {bigint} now_unix
|
|
2461
|
+
* @returns {string}
|
|
2462
|
+
*/
|
|
2463
|
+
export function recallContextHeader(now_unix) {
|
|
2464
|
+
let deferred1_0;
|
|
2465
|
+
let deferred1_1;
|
|
2466
|
+
try {
|
|
2467
|
+
const ret = wasm.recallContextHeader(now_unix);
|
|
2468
|
+
deferred1_0 = ret[0];
|
|
2469
|
+
deferred1_1 = ret[1];
|
|
2470
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2471
|
+
} finally {
|
|
2472
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
/**
|
|
2477
|
+
* Rerank candidates using BM25 + Cosine + RRF fusion.
|
|
2478
|
+
*
|
|
2479
|
+
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
|
|
2480
|
+
* Returns a JsValue (array of `RankedResult` objects).
|
|
2481
|
+
* @param {string} query
|
|
2482
|
+
* @param {Float32Array} query_embedding
|
|
2483
|
+
* @param {string} candidates_json
|
|
2484
|
+
* @param {number} top_k
|
|
2485
|
+
* @returns {any}
|
|
2486
|
+
*/
|
|
2487
|
+
export function rerank(query, query_embedding, candidates_json, top_k) {
|
|
2488
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2489
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2490
|
+
const ptr1 = passArrayF32ToWasm0(query_embedding, wasm.__wbindgen_malloc);
|
|
2491
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2492
|
+
const ptr2 = passStringToWasm0(candidates_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2493
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2494
|
+
const ret = wasm.rerank(ptr0, len0, ptr1, len1, ptr2, len2, top_k);
|
|
2495
|
+
if (ret[2]) {
|
|
2496
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2497
|
+
}
|
|
2498
|
+
return takeFromExternrefTable0(ret[0]);
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
/**
|
|
2502
|
+
* Rerank candidates with a config flag (Retrieval v2 Tier 1).
|
|
2503
|
+
*
|
|
2504
|
+
* When `apply_source_weights` is `true`, each candidate's final score is
|
|
2505
|
+
* multiplied by the provenance weight from its `source` field (legacy
|
|
2506
|
+
* candidates without `source` use the v0 fallback weight).
|
|
2507
|
+
*
|
|
2508
|
+
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
|
|
2509
|
+
* Returns a JsValue (array of `RankedResult` objects including `source_weight`).
|
|
2510
|
+
* @param {string} query
|
|
2511
|
+
* @param {Float32Array} query_embedding
|
|
2512
|
+
* @param {string} candidates_json
|
|
2513
|
+
* @param {number} top_k
|
|
2514
|
+
* @param {boolean} apply_source_weights
|
|
2515
|
+
* @returns {any}
|
|
2516
|
+
*/
|
|
2517
|
+
export function rerankWithConfig(query, query_embedding, candidates_json, top_k, apply_source_weights) {
|
|
2518
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2519
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2520
|
+
const ptr1 = passArrayF32ToWasm0(query_embedding, wasm.__wbindgen_malloc);
|
|
2521
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2522
|
+
const ptr2 = passStringToWasm0(candidates_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2523
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2524
|
+
const ret = wasm.rerankWithConfig(ptr0, len0, ptr1, len1, ptr2, len2, top_k, apply_source_weights);
|
|
2525
|
+
if (ret[2]) {
|
|
2526
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2527
|
+
}
|
|
2528
|
+
return takeFromExternrefTable0(ret[0]);
|
|
2529
|
+
}
|
|
2530
|
+
|
|
2531
|
+
/**
|
|
2532
|
+
* Run the resolution formula on two contradicting claims; returns ResolutionOutcome JSON.
|
|
2533
|
+
* @param {string} claim_a_json
|
|
2534
|
+
* @param {string} claim_a_id
|
|
2535
|
+
* @param {string} claim_b_json
|
|
2536
|
+
* @param {string} claim_b_id
|
|
2537
|
+
* @param {bigint} now_unix_seconds
|
|
2538
|
+
* @param {string} weights_json
|
|
2539
|
+
* @returns {string}
|
|
2540
|
+
*/
|
|
2541
|
+
export function resolvePair(claim_a_json, claim_a_id, claim_b_json, claim_b_id, now_unix_seconds, weights_json) {
|
|
2542
|
+
let deferred7_0;
|
|
2543
|
+
let deferred7_1;
|
|
2544
|
+
try {
|
|
2545
|
+
const ptr0 = passStringToWasm0(claim_a_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2546
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2547
|
+
const ptr1 = passStringToWasm0(claim_a_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2548
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2549
|
+
const ptr2 = passStringToWasm0(claim_b_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2550
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2551
|
+
const ptr3 = passStringToWasm0(claim_b_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2552
|
+
const len3 = WASM_VECTOR_LEN;
|
|
2553
|
+
const ptr4 = passStringToWasm0(weights_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2554
|
+
const len4 = WASM_VECTOR_LEN;
|
|
2555
|
+
const ret = wasm.resolvePair(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, now_unix_seconds, ptr4, len4);
|
|
2556
|
+
var ptr6 = ret[0];
|
|
2557
|
+
var len6 = ret[1];
|
|
2558
|
+
if (ret[3]) {
|
|
2559
|
+
ptr6 = 0; len6 = 0;
|
|
2560
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2561
|
+
}
|
|
2562
|
+
deferred7_0 = ptr6;
|
|
2563
|
+
deferred7_1 = len6;
|
|
2564
|
+
return getStringFromWasm0(ptr6, len6);
|
|
2565
|
+
} finally {
|
|
2566
|
+
wasm.__wbindgen_free(deferred7_0, deferred7_1, 1);
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2570
|
+
/**
|
|
2571
|
+
* Orchestrate contradiction detection + resolution for a new claim against candidates.
|
|
2572
|
+
*
|
|
2573
|
+
* Returns a JSON array of `ResolutionAction`.
|
|
2574
|
+
* @param {string} new_claim_json
|
|
2575
|
+
* @param {string} new_claim_id
|
|
2576
|
+
* @param {string} new_embedding_json
|
|
2577
|
+
* @param {string} candidates_json
|
|
2578
|
+
* @param {string} weights_json
|
|
2579
|
+
* @param {number} threshold_lower
|
|
2580
|
+
* @param {number} threshold_upper
|
|
2581
|
+
* @param {bigint} now_unix
|
|
2582
|
+
* @param {number} tie_tolerance
|
|
2583
|
+
* @returns {string}
|
|
2584
|
+
*/
|
|
2585
|
+
export function resolveWithCandidates(new_claim_json, new_claim_id, new_embedding_json, candidates_json, weights_json, threshold_lower, threshold_upper, now_unix, tie_tolerance) {
|
|
2586
|
+
let deferred7_0;
|
|
2587
|
+
let deferred7_1;
|
|
2588
|
+
try {
|
|
2589
|
+
const ptr0 = passStringToWasm0(new_claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2590
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2591
|
+
const ptr1 = passStringToWasm0(new_claim_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2592
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2593
|
+
const ptr2 = passStringToWasm0(new_embedding_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2594
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2595
|
+
const ptr3 = passStringToWasm0(candidates_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2596
|
+
const len3 = WASM_VECTOR_LEN;
|
|
2597
|
+
const ptr4 = passStringToWasm0(weights_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2598
|
+
const len4 = WASM_VECTOR_LEN;
|
|
2599
|
+
const ret = wasm.resolveWithCandidates(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, threshold_lower, threshold_upper, now_unix, tie_tolerance);
|
|
2600
|
+
var ptr6 = ret[0];
|
|
2601
|
+
var len6 = ret[1];
|
|
2602
|
+
if (ret[3]) {
|
|
2603
|
+
ptr6 = 0; len6 = 0;
|
|
2604
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2605
|
+
}
|
|
2606
|
+
deferred7_0 = ptr6;
|
|
2607
|
+
deferred7_1 = len6;
|
|
2608
|
+
return getStringFromWasm0(ptr6, len6);
|
|
2609
|
+
} finally {
|
|
2610
|
+
wasm.__wbindgen_free(deferred7_0, deferred7_1, 1);
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
/**
|
|
2615
|
+
* Apply pin-status and tie-zone checks to a resolution outcome.
|
|
2616
|
+
* Returns a JSON-serialized `ResolutionAction`.
|
|
2617
|
+
* @param {string} existing_claim_json
|
|
2618
|
+
* @param {string} new_claim_id
|
|
2619
|
+
* @param {string} existing_claim_id
|
|
2620
|
+
* @param {string} resolution_winner
|
|
2621
|
+
* @param {number} score_gap
|
|
2622
|
+
* @param {number} similarity
|
|
2623
|
+
* @param {number} tie_tolerance
|
|
2624
|
+
* @returns {string}
|
|
2625
|
+
*/
|
|
2626
|
+
export function respectPinInResolution(existing_claim_json, new_claim_id, existing_claim_id, resolution_winner, score_gap, similarity, tie_tolerance) {
|
|
2627
|
+
let deferred6_0;
|
|
2628
|
+
let deferred6_1;
|
|
2629
|
+
try {
|
|
2630
|
+
const ptr0 = passStringToWasm0(existing_claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2631
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2632
|
+
const ptr1 = passStringToWasm0(new_claim_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2633
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2634
|
+
const ptr2 = passStringToWasm0(existing_claim_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2635
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2636
|
+
const ptr3 = passStringToWasm0(resolution_winner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2637
|
+
const len3 = WASM_VECTOR_LEN;
|
|
2638
|
+
const ret = wasm.respectPinInResolution(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, score_gap, similarity, tie_tolerance);
|
|
2639
|
+
var ptr5 = ret[0];
|
|
2640
|
+
var len5 = ret[1];
|
|
2641
|
+
if (ret[3]) {
|
|
2642
|
+
ptr5 = 0; len5 = 0;
|
|
2643
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2644
|
+
}
|
|
2645
|
+
deferred6_0 = ptr5;
|
|
2646
|
+
deferred6_1 = len5;
|
|
2647
|
+
return getStringFromWasm0(ptr5, len5);
|
|
2648
|
+
} finally {
|
|
2649
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
/**
|
|
2654
|
+
* Keep only the most recent `max_lines` non-empty feedback log lines. Non-falliable.
|
|
2655
|
+
* @param {string} content
|
|
2656
|
+
* @param {bigint} max_lines
|
|
2657
|
+
* @returns {string}
|
|
2658
|
+
*/
|
|
2659
|
+
export function rotateFeedbackLog(content, max_lines) {
|
|
2660
|
+
let deferred2_0;
|
|
2661
|
+
let deferred2_1;
|
|
2662
|
+
try {
|
|
2663
|
+
const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2664
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2665
|
+
const ret = wasm.rotateFeedbackLog(ptr0, len0, max_lines);
|
|
2666
|
+
deferred2_0 = ret[0];
|
|
2667
|
+
deferred2_1 = ret[1];
|
|
2668
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2669
|
+
} finally {
|
|
2670
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
|
|
2674
|
+
/**
|
|
2675
|
+
* Centroid-walk session segmentation over time-ordered turns.
|
|
2676
|
+
*
|
|
2677
|
+
* Mirrors `session_segmentation.py:segment_sessions` byte-for-byte.
|
|
2678
|
+
*
|
|
2679
|
+
* # Inputs (JSON strings, per this module's convention)
|
|
2680
|
+
* - `timestamps_json`: JSON array of Unix seconds or `null`, e.g.
|
|
2681
|
+
* `"[0.0, null, 5000.0]"`. `null` = 0-gap to the previous turn.
|
|
2682
|
+
* - `embeddings_json`: JSON array of L2-normalised vectors, e.g.
|
|
2683
|
+
* `"[[1.0,0.0],[0.9,0.1]]"`.
|
|
2684
|
+
* - `gap_seconds`: min time gap (strict `>`) forcing a new session (e.g. 1800).
|
|
2685
|
+
* - `sim_threshold`: cosine threshold (strict `<` splits; e.g. 0.55).
|
|
2686
|
+
*
|
|
2687
|
+
* # Returns
|
|
2688
|
+
* A `JsValue` — array of sessions, each an array of turn indices
|
|
2689
|
+
* (`number[][]`), contiguous and ascending. Bad JSON → `JsError`.
|
|
2690
|
+
* @param {string} timestamps_json
|
|
2691
|
+
* @param {string} embeddings_json
|
|
2692
|
+
* @param {number} gap_seconds
|
|
2693
|
+
* @param {number} sim_threshold
|
|
2694
|
+
* @returns {any}
|
|
2695
|
+
*/
|
|
2696
|
+
export function segmentSessions(timestamps_json, embeddings_json, gap_seconds, sim_threshold) {
|
|
2697
|
+
const ptr0 = passStringToWasm0(timestamps_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2698
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2699
|
+
const ptr1 = passStringToWasm0(embeddings_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2700
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2701
|
+
const ret = wasm.segmentSessions(ptr0, len0, ptr1, len1, gap_seconds, sim_threshold);
|
|
2702
|
+
if (ret[2]) {
|
|
2703
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2704
|
+
}
|
|
2705
|
+
return takeFromExternrefTable0(ret[0]);
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
/**
|
|
2709
|
+
* Serialize a WeightsFile JSON to pretty-printed JSON (2-space indent).
|
|
2710
|
+
* @param {string} file_json
|
|
2711
|
+
* @returns {string}
|
|
2712
|
+
*/
|
|
2713
|
+
export function serializeWeightsFile(file_json) {
|
|
2714
|
+
let deferred3_0;
|
|
2715
|
+
let deferred3_1;
|
|
2716
|
+
try {
|
|
2717
|
+
const ptr0 = passStringToWasm0(file_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2718
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2719
|
+
const ret = wasm.serializeWeightsFile(ptr0, len0);
|
|
2720
|
+
var ptr2 = ret[0];
|
|
2721
|
+
var len2 = ret[1];
|
|
2722
|
+
if (ret[3]) {
|
|
2723
|
+
ptr2 = 0; len2 = 0;
|
|
2724
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2725
|
+
}
|
|
2726
|
+
deferred3_0 = ptr2;
|
|
2727
|
+
deferred3_1 = len2;
|
|
2728
|
+
return getStringFromWasm0(ptr2, len2);
|
|
2729
|
+
} finally {
|
|
2730
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
/**
|
|
2735
|
+
* WASM binding: determine if a new fact should supersede an existing one.
|
|
2736
|
+
* @param {number} new_importance
|
|
2737
|
+
* @param {number} existing_importance
|
|
2738
|
+
* @returns {boolean}
|
|
2739
|
+
*/
|
|
2740
|
+
export function shouldSupersede(new_importance, existing_importance) {
|
|
2741
|
+
const ret = wasm.shouldSupersede(new_importance, existing_importance);
|
|
2742
|
+
return ret !== 0;
|
|
2743
|
+
}
|
|
2744
|
+
|
|
2745
|
+
/**
|
|
2746
|
+
* Sign a UserOp hash with an ECDSA private key (EIP-191 prefixed).
|
|
2747
|
+
*
|
|
2748
|
+
* `hash_hex`: 64-char hex string (32-byte UserOp hash).
|
|
2749
|
+
* `private_key_hex`: 64-char hex string (32-byte private key).
|
|
2750
|
+
* Returns 65-byte signature as hex string (r + s + v).
|
|
2751
|
+
* @param {string} hash_hex
|
|
2752
|
+
* @param {string} private_key_hex
|
|
2753
|
+
* @returns {string}
|
|
2754
|
+
*/
|
|
2755
|
+
export function signUserOp(hash_hex, private_key_hex) {
|
|
2756
|
+
let deferred4_0;
|
|
2757
|
+
let deferred4_1;
|
|
2758
|
+
try {
|
|
2759
|
+
const ptr0 = passStringToWasm0(hash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2760
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2761
|
+
const ptr1 = passStringToWasm0(private_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2762
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2763
|
+
const ret = wasm.signUserOp(ptr0, len0, ptr1, len1);
|
|
2764
|
+
var ptr3 = ret[0];
|
|
2765
|
+
var len3 = ret[1];
|
|
2766
|
+
if (ret[3]) {
|
|
2767
|
+
ptr3 = 0; len3 = 0;
|
|
2768
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2769
|
+
}
|
|
2770
|
+
deferred4_0 = ptr3;
|
|
2771
|
+
deferred4_1 = len3;
|
|
2772
|
+
return getStringFromWasm0(ptr3, len3);
|
|
2773
|
+
} finally {
|
|
2774
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2778
|
+
/**
|
|
2779
|
+
* Return the source weight multiplier for a given source string.
|
|
2780
|
+
*
|
|
2781
|
+
* Accepted values: "user" | "user-inferred" | "assistant" | "external" | "derived".
|
|
2782
|
+
*
|
|
2783
|
+
* Unknown input is routed through `MemorySource::from_str_lossy` which
|
|
2784
|
+
* falls back to `user-inferred` (v2-lenient weight 0.95). Callers who need
|
|
2785
|
+
* the "no source field at all" fallback (weight 0.85) should call
|
|
2786
|
+
* `legacyClaimFallbackWeight()` instead.
|
|
2787
|
+
* @param {string} source
|
|
2788
|
+
* @returns {number}
|
|
2789
|
+
*/
|
|
2790
|
+
export function sourceWeight(source) {
|
|
2791
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2792
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2793
|
+
const ret = wasm.sourceWeight(ptr0, len0);
|
|
2794
|
+
return ret;
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2797
|
+
/**
|
|
2798
|
+
* Validate a Memory Taxonomy v1 claim (JSON in, JSON out — canonicalised).
|
|
2799
|
+
*
|
|
2800
|
+
* Returns the canonical JSON encoding on success. Throws on any schema
|
|
2801
|
+
* violation (wrong type token, missing required field, wrong schema_version).
|
|
2802
|
+
*
|
|
2803
|
+
* See `docs/specs/totalreclaw/memory-taxonomy-v1.md`.
|
|
2804
|
+
* @param {string} claim_json
|
|
2805
|
+
* @returns {string}
|
|
2806
|
+
*/
|
|
2807
|
+
export function validateMemoryClaimV1(claim_json) {
|
|
2808
|
+
let deferred3_0;
|
|
2809
|
+
let deferred3_1;
|
|
2810
|
+
try {
|
|
2811
|
+
const ptr0 = passStringToWasm0(claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2812
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2813
|
+
const ret = wasm.validateMemoryClaimV1(ptr0, len0);
|
|
2814
|
+
var ptr2 = ret[0];
|
|
2815
|
+
var len2 = ret[1];
|
|
2816
|
+
if (ret[3]) {
|
|
2817
|
+
ptr2 = 0; len2 = 0;
|
|
2818
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2819
|
+
}
|
|
2820
|
+
deferred3_0 = ptr2;
|
|
2821
|
+
deferred3_1 = len2;
|
|
2822
|
+
return getStringFromWasm0(ptr2, len2);
|
|
2823
|
+
} finally {
|
|
2824
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
|
|
2828
|
+
/**
|
|
2829
|
+
* Default polling interval (ms) — exposed so host adapters share the same
|
|
2830
|
+
* default without re-declaring the constant.
|
|
2831
|
+
* @returns {number}
|
|
2832
|
+
*/
|
|
2833
|
+
export function wasmConfirmIndexedDefaultPollMs() {
|
|
2834
|
+
const ret = wasm.wasmConfirmIndexedDefaultPollMs();
|
|
2835
|
+
return ret >>> 0;
|
|
2836
|
+
}
|
|
2837
|
+
|
|
2838
|
+
/**
|
|
2839
|
+
* Default total timeout (ms) — exposed so host adapters share the same default.
|
|
2840
|
+
* @returns {number}
|
|
2841
|
+
*/
|
|
2842
|
+
export function wasmConfirmIndexedDefaultTimeoutMs() {
|
|
2843
|
+
const ret = wasm.wasmConfirmIndexedDefaultTimeoutMs();
|
|
2844
|
+
return ret >>> 0;
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
/**
|
|
2848
|
+
* Parse a subgraph response JSON and return whether the fact is indexed +
|
|
2849
|
+
* active. Returns `true` when the read-after-write loop can stop.
|
|
2850
|
+
* @param {string} response_json
|
|
2851
|
+
* @returns {boolean}
|
|
2852
|
+
*/
|
|
2853
|
+
export function wasmConfirmIndexedParse(response_json) {
|
|
2854
|
+
const ptr0 = passStringToWasm0(response_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2855
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2856
|
+
const ret = wasm.wasmConfirmIndexedParse(ptr0, len0);
|
|
2857
|
+
if (ret[2]) {
|
|
2858
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2859
|
+
}
|
|
2860
|
+
return ret[0] !== 0;
|
|
2861
|
+
}
|
|
2862
|
+
|
|
2863
|
+
/**
|
|
2864
|
+
* GraphQL query string used to confirm a fact id has been indexed.
|
|
2865
|
+
* Pair with `wasmConfirmIndexedParse` in a host-side polling loop.
|
|
2866
|
+
* @returns {string}
|
|
2867
|
+
*/
|
|
2868
|
+
export function wasmConfirmIndexedQuery() {
|
|
2869
|
+
let deferred1_0;
|
|
2870
|
+
let deferred1_1;
|
|
2871
|
+
try {
|
|
2872
|
+
const ret = wasm.wasmConfirmIndexedQuery();
|
|
2873
|
+
deferred1_0 = ret[0];
|
|
2874
|
+
deferred1_1 = ret[1];
|
|
2875
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2876
|
+
} finally {
|
|
2877
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2878
|
+
}
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2881
|
+
function __wbg_get_imports() {
|
|
2882
|
+
const import0 = {
|
|
2883
|
+
__proto__: null,
|
|
2884
|
+
__wbg_Error_2e59b1b37a9a34c3: function(arg0, arg1) {
|
|
2885
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
2886
|
+
return ret;
|
|
2887
|
+
},
|
|
2888
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
2889
|
+
const ret = String(arg1);
|
|
2890
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2891
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2892
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
2893
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
2894
|
+
},
|
|
2895
|
+
__wbg___wbindgen_is_function_49868bde5eb1e745: function(arg0) {
|
|
2896
|
+
const ret = typeof(arg0) === 'function';
|
|
2897
|
+
return ret;
|
|
2898
|
+
},
|
|
2899
|
+
__wbg___wbindgen_is_object_40c5a80572e8f9d3: function(arg0) {
|
|
2900
|
+
const val = arg0;
|
|
2901
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
2902
|
+
return ret;
|
|
2903
|
+
},
|
|
2904
|
+
__wbg___wbindgen_is_string_b29b5c5a8065ba1a: function(arg0) {
|
|
2905
|
+
const ret = typeof(arg0) === 'string';
|
|
2906
|
+
return ret;
|
|
2907
|
+
},
|
|
2908
|
+
__wbg___wbindgen_is_undefined_c0cca72b82b86f4d: function(arg0) {
|
|
2909
|
+
const ret = arg0 === undefined;
|
|
2910
|
+
return ret;
|
|
2911
|
+
},
|
|
2912
|
+
__wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
|
|
2913
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
2914
|
+
},
|
|
2915
|
+
__wbg_call_d578befcc3145dee: function() { return handleError(function (arg0, arg1, arg2) {
|
|
2916
|
+
const ret = arg0.call(arg1, arg2);
|
|
2917
|
+
return ret;
|
|
2918
|
+
}, arguments); },
|
|
2919
|
+
__wbg_crypto_38df2bab126b63dc: function(arg0) {
|
|
2920
|
+
const ret = arg0.crypto;
|
|
2921
|
+
return ret;
|
|
2922
|
+
},
|
|
2923
|
+
__wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
|
|
2924
|
+
arg0.getRandomValues(arg1);
|
|
2925
|
+
}, arguments); },
|
|
2926
|
+
__wbg_getRandomValues_d49329ff89a07af1: function() { return handleError(function (arg0, arg1) {
|
|
2927
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
2928
|
+
}, arguments); },
|
|
2929
|
+
__wbg_getTime_f6ac312467f7cf09: function(arg0) {
|
|
2930
|
+
const ret = arg0.getTime();
|
|
2931
|
+
return ret;
|
|
2932
|
+
},
|
|
2933
|
+
__wbg_length_0c32cb8543c8e4c8: function(arg0) {
|
|
2934
|
+
const ret = arg0.length;
|
|
2935
|
+
return ret;
|
|
2936
|
+
},
|
|
2937
|
+
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
|
2938
|
+
const ret = arg0.msCrypto;
|
|
2939
|
+
return ret;
|
|
2940
|
+
},
|
|
2941
|
+
__wbg_new_0_bfa2ef4bc447daa2: function() {
|
|
2942
|
+
const ret = new Date();
|
|
2943
|
+
return ret;
|
|
2944
|
+
},
|
|
2945
|
+
__wbg_new_4f9fafbb3909af72: function() {
|
|
2946
|
+
const ret = new Object();
|
|
2947
|
+
return ret;
|
|
2948
|
+
},
|
|
2949
|
+
__wbg_new_f3c9df4f38f3f798: function() {
|
|
2950
|
+
const ret = new Array();
|
|
2951
|
+
return ret;
|
|
2952
|
+
},
|
|
2953
|
+
__wbg_new_with_length_9cedd08484b73942: function(arg0) {
|
|
2954
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
2955
|
+
return ret;
|
|
2956
|
+
},
|
|
2957
|
+
__wbg_node_84ea875411254db1: function(arg0) {
|
|
2958
|
+
const ret = arg0.node;
|
|
2959
|
+
return ret;
|
|
2960
|
+
},
|
|
2961
|
+
__wbg_now_6798946be0e6fe2b: function() { return handleError(function () {
|
|
2962
|
+
const ret = Date.now();
|
|
2963
|
+
return ret;
|
|
2964
|
+
}, arguments); },
|
|
2965
|
+
__wbg_process_44c7a14e11e9f69e: function(arg0) {
|
|
2966
|
+
const ret = arg0.process;
|
|
2967
|
+
return ret;
|
|
2968
|
+
},
|
|
2969
|
+
__wbg_prototypesetcall_3e05eb9545565046: function(arg0, arg1, arg2) {
|
|
2970
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
2971
|
+
},
|
|
2972
|
+
__wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
|
|
2973
|
+
arg0.randomFillSync(arg1);
|
|
2974
|
+
}, arguments); },
|
|
2975
|
+
__wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
|
|
2976
|
+
const ret = module.require;
|
|
2977
|
+
return ret;
|
|
2978
|
+
}, arguments); },
|
|
2979
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
2980
|
+
arg0[arg1] = arg2;
|
|
2981
|
+
},
|
|
2982
|
+
__wbg_set_6c60b2e8ad0e9383: function(arg0, arg1, arg2) {
|
|
2983
|
+
arg0[arg1 >>> 0] = arg2;
|
|
2984
|
+
},
|
|
2985
|
+
__wbg_set_8ee2d34facb8466e: function() { return handleError(function (arg0, arg1, arg2) {
|
|
2986
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
2987
|
+
return ret;
|
|
2988
|
+
}, arguments); },
|
|
2989
|
+
__wbg_static_accessor_GLOBAL_THIS_a1248013d790bf5f: function() {
|
|
2990
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
2991
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
2992
|
+
},
|
|
2993
|
+
__wbg_static_accessor_GLOBAL_f2e0f995a21329ff: function() {
|
|
2994
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
2995
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
2996
|
+
},
|
|
2997
|
+
__wbg_static_accessor_SELF_24f78b6d23f286ea: function() {
|
|
2998
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
2999
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
3000
|
+
},
|
|
3001
|
+
__wbg_static_accessor_WINDOW_59fd959c540fe405: function() {
|
|
3002
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
3003
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
3004
|
+
},
|
|
3005
|
+
__wbg_subarray_0f98d3fb634508ad: function(arg0, arg1, arg2) {
|
|
3006
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
3007
|
+
return ret;
|
|
3008
|
+
},
|
|
3009
|
+
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
|
3010
|
+
const ret = arg0.versions;
|
|
3011
|
+
return ret;
|
|
3012
|
+
},
|
|
3013
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
3014
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
3015
|
+
const ret = arg0;
|
|
3016
|
+
return ret;
|
|
3017
|
+
},
|
|
3018
|
+
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
3019
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
3020
|
+
const ret = arg0;
|
|
3021
|
+
return ret;
|
|
3022
|
+
},
|
|
3023
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
3024
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
3025
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
3026
|
+
return ret;
|
|
3027
|
+
},
|
|
3028
|
+
__wbindgen_cast_0000000000000004: function(arg0, arg1) {
|
|
3029
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
3030
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
3031
|
+
return ret;
|
|
3032
|
+
},
|
|
3033
|
+
__wbindgen_cast_0000000000000005: function(arg0) {
|
|
3034
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
3035
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
3036
|
+
return ret;
|
|
3037
|
+
},
|
|
3038
|
+
__wbindgen_init_externref_table: function() {
|
|
3039
|
+
const table = wasm.__wbindgen_externrefs;
|
|
3040
|
+
const offset = table.grow(4);
|
|
3041
|
+
table.set(0, undefined);
|
|
3042
|
+
table.set(offset + 0, undefined);
|
|
3043
|
+
table.set(offset + 1, null);
|
|
3044
|
+
table.set(offset + 2, true);
|
|
3045
|
+
table.set(offset + 3, false);
|
|
3046
|
+
},
|
|
3047
|
+
};
|
|
3048
|
+
return {
|
|
3049
|
+
__proto__: null,
|
|
3050
|
+
"./totalreclaw_core_bg.js": import0,
|
|
3051
|
+
};
|
|
3052
|
+
}
|
|
3053
|
+
|
|
3054
|
+
const WasmLshHasherFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3055
|
+
? { register: () => {}, unregister: () => {} }
|
|
3056
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmlshhasher_free(ptr >>> 0, 1));
|
|
3057
|
+
|
|
3058
|
+
function addToExternrefTable0(obj) {
|
|
3059
|
+
const idx = wasm.__externref_table_alloc();
|
|
3060
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
3061
|
+
return idx;
|
|
3062
|
+
}
|
|
3063
|
+
|
|
3064
|
+
function _assertClass(instance, klass) {
|
|
3065
|
+
if (!(instance instanceof klass)) {
|
|
3066
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
3067
|
+
}
|
|
3068
|
+
}
|
|
3069
|
+
|
|
3070
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
3071
|
+
ptr = ptr >>> 0;
|
|
3072
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
let cachedDataViewMemory0 = null;
|
|
3076
|
+
function getDataViewMemory0() {
|
|
3077
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
3078
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
3079
|
+
}
|
|
3080
|
+
return cachedDataViewMemory0;
|
|
3081
|
+
}
|
|
3082
|
+
|
|
3083
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
3084
|
+
function getFloat32ArrayMemory0() {
|
|
3085
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
3086
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
3087
|
+
}
|
|
3088
|
+
return cachedFloat32ArrayMemory0;
|
|
3089
|
+
}
|
|
3090
|
+
|
|
3091
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
3092
|
+
function getFloat64ArrayMemory0() {
|
|
3093
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
3094
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
3095
|
+
}
|
|
3096
|
+
return cachedFloat64ArrayMemory0;
|
|
3097
|
+
}
|
|
3098
|
+
|
|
3099
|
+
function getStringFromWasm0(ptr, len) {
|
|
3100
|
+
ptr = ptr >>> 0;
|
|
3101
|
+
return decodeText(ptr, len);
|
|
3102
|
+
}
|
|
3103
|
+
|
|
3104
|
+
let cachedUint8ArrayMemory0 = null;
|
|
3105
|
+
function getUint8ArrayMemory0() {
|
|
3106
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
3107
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
3108
|
+
}
|
|
3109
|
+
return cachedUint8ArrayMemory0;
|
|
3110
|
+
}
|
|
3111
|
+
|
|
3112
|
+
function handleError(f, args) {
|
|
3113
|
+
try {
|
|
3114
|
+
return f.apply(this, args);
|
|
3115
|
+
} catch (e) {
|
|
3116
|
+
const idx = addToExternrefTable0(e);
|
|
3117
|
+
wasm.__wbindgen_exn_store(idx);
|
|
3118
|
+
}
|
|
3119
|
+
}
|
|
3120
|
+
|
|
3121
|
+
function isLikeNone(x) {
|
|
3122
|
+
return x === undefined || x === null;
|
|
3123
|
+
}
|
|
3124
|
+
|
|
3125
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
3126
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
3127
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
3128
|
+
WASM_VECTOR_LEN = arg.length;
|
|
3129
|
+
return ptr;
|
|
3130
|
+
}
|
|
3131
|
+
|
|
3132
|
+
function passArrayF32ToWasm0(arg, malloc) {
|
|
3133
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
3134
|
+
getFloat32ArrayMemory0().set(arg, ptr / 4);
|
|
3135
|
+
WASM_VECTOR_LEN = arg.length;
|
|
3136
|
+
return ptr;
|
|
3137
|
+
}
|
|
3138
|
+
|
|
3139
|
+
function passArrayF64ToWasm0(arg, malloc) {
|
|
3140
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
3141
|
+
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
3142
|
+
WASM_VECTOR_LEN = arg.length;
|
|
3143
|
+
return ptr;
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3146
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
3147
|
+
if (realloc === undefined) {
|
|
3148
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
3149
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
3150
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
3151
|
+
WASM_VECTOR_LEN = buf.length;
|
|
3152
|
+
return ptr;
|
|
3153
|
+
}
|
|
3154
|
+
|
|
3155
|
+
let len = arg.length;
|
|
3156
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
3157
|
+
|
|
3158
|
+
const mem = getUint8ArrayMemory0();
|
|
3159
|
+
|
|
3160
|
+
let offset = 0;
|
|
3161
|
+
|
|
3162
|
+
for (; offset < len; offset++) {
|
|
3163
|
+
const code = arg.charCodeAt(offset);
|
|
3164
|
+
if (code > 0x7F) break;
|
|
3165
|
+
mem[ptr + offset] = code;
|
|
3166
|
+
}
|
|
3167
|
+
if (offset !== len) {
|
|
3168
|
+
if (offset !== 0) {
|
|
3169
|
+
arg = arg.slice(offset);
|
|
3170
|
+
}
|
|
3171
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
3172
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
3173
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
3174
|
+
|
|
3175
|
+
offset += ret.written;
|
|
3176
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
3177
|
+
}
|
|
3178
|
+
|
|
3179
|
+
WASM_VECTOR_LEN = offset;
|
|
3180
|
+
return ptr;
|
|
3181
|
+
}
|
|
3182
|
+
|
|
3183
|
+
function takeFromExternrefTable0(idx) {
|
|
3184
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
3185
|
+
wasm.__externref_table_dealloc(idx);
|
|
3186
|
+
return value;
|
|
3187
|
+
}
|
|
3188
|
+
|
|
3189
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
3190
|
+
cachedTextDecoder.decode();
|
|
3191
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
3192
|
+
let numBytesDecoded = 0;
|
|
3193
|
+
function decodeText(ptr, len) {
|
|
3194
|
+
numBytesDecoded += len;
|
|
3195
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
3196
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
3197
|
+
cachedTextDecoder.decode();
|
|
3198
|
+
numBytesDecoded = len;
|
|
3199
|
+
}
|
|
3200
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
3201
|
+
}
|
|
3202
|
+
|
|
3203
|
+
const cachedTextEncoder = new TextEncoder();
|
|
3204
|
+
|
|
3205
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
3206
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
3207
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
3208
|
+
view.set(buf);
|
|
3209
|
+
return {
|
|
3210
|
+
read: arg.length,
|
|
3211
|
+
written: buf.length
|
|
3212
|
+
};
|
|
3213
|
+
};
|
|
3214
|
+
}
|
|
3215
|
+
|
|
3216
|
+
let WASM_VECTOR_LEN = 0;
|
|
3217
|
+
|
|
3218
|
+
let wasmModule, wasm;
|
|
3219
|
+
function __wbg_finalize_init(instance, module) {
|
|
3220
|
+
wasm = instance.exports;
|
|
3221
|
+
wasmModule = module;
|
|
3222
|
+
cachedDataViewMemory0 = null;
|
|
3223
|
+
cachedFloat32ArrayMemory0 = null;
|
|
3224
|
+
cachedFloat64ArrayMemory0 = null;
|
|
3225
|
+
cachedUint8ArrayMemory0 = null;
|
|
3226
|
+
wasm.__wbindgen_start();
|
|
3227
|
+
return wasm;
|
|
3228
|
+
}
|
|
3229
|
+
|
|
3230
|
+
async function __wbg_load(module, imports) {
|
|
3231
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
3232
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
3233
|
+
try {
|
|
3234
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
3235
|
+
} catch (e) {
|
|
3236
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
3237
|
+
|
|
3238
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
3239
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
3240
|
+
|
|
3241
|
+
} else { throw e; }
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
|
|
3245
|
+
const bytes = await module.arrayBuffer();
|
|
3246
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
3247
|
+
} else {
|
|
3248
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
3249
|
+
|
|
3250
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
3251
|
+
return { instance, module };
|
|
3252
|
+
} else {
|
|
3253
|
+
return instance;
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
|
|
3257
|
+
function expectedResponseType(type) {
|
|
3258
|
+
switch (type) {
|
|
3259
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
3260
|
+
}
|
|
3261
|
+
return false;
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
|
|
3265
|
+
function initSync(module) {
|
|
3266
|
+
if (wasm !== undefined) return wasm;
|
|
3267
|
+
|
|
3268
|
+
|
|
3269
|
+
if (module !== undefined) {
|
|
3270
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
3271
|
+
({module} = module)
|
|
3272
|
+
} else {
|
|
3273
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
|
|
3277
|
+
const imports = __wbg_get_imports();
|
|
3278
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
3279
|
+
module = new WebAssembly.Module(module);
|
|
3280
|
+
}
|
|
3281
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
3282
|
+
return __wbg_finalize_init(instance, module);
|
|
3283
|
+
}
|
|
3284
|
+
|
|
3285
|
+
async function __wbg_init(module_or_path) {
|
|
3286
|
+
if (wasm !== undefined) return wasm;
|
|
3287
|
+
|
|
3288
|
+
|
|
3289
|
+
if (module_or_path !== undefined) {
|
|
3290
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
3291
|
+
({module_or_path} = module_or_path)
|
|
3292
|
+
} else {
|
|
3293
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
3294
|
+
}
|
|
3295
|
+
}
|
|
3296
|
+
|
|
3297
|
+
if (module_or_path === undefined) {
|
|
3298
|
+
module_or_path = new URL('totalreclaw_core_bg.wasm', import.meta.url);
|
|
3299
|
+
}
|
|
3300
|
+
const imports = __wbg_get_imports();
|
|
3301
|
+
|
|
3302
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
3303
|
+
module_or_path = fetch(module_or_path);
|
|
3304
|
+
}
|
|
3305
|
+
|
|
3306
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
3307
|
+
|
|
3308
|
+
return __wbg_finalize_init(instance, module);
|
|
3309
|
+
}
|
|
3310
|
+
|
|
3311
|
+
export { initSync, __wbg_init as default };
|