@totalreclaw/core 2.5.5 → 2.6.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3369 @@
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
+ * Decode any embedding payload into a Float32Array (the forever-reader).
731
+ *
732
+ * Dispatch mirrors `decode_embedding_universal`: a payload beginning with `[`
733
+ * is parsed as a JSON float array (legacy TS plugin); otherwise base64-decode
734
+ * and infer width from the byte count (`640*2` → f16 upcast to f32, else a
735
+ * multiple of 4 → f32). Bad input → `JsError`, never a wrong-dim vector.
736
+ * @param {string} payload
737
+ * @returns {Float32Array}
738
+ */
739
+ export function decodeEmbeddingUniversal(payload) {
740
+ const ptr0 = passStringToWasm0(payload, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
741
+ const len0 = WASM_VECTOR_LEN;
742
+ const ret = wasm.decodeEmbeddingUniversal(ptr0, len0);
743
+ if (ret[3]) {
744
+ throw takeFromExternrefTable0(ret[2]);
745
+ }
746
+ var v2 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
747
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
748
+ return v2;
749
+ }
750
+
751
+ /**
752
+ * Decrypt a base64-encoded XChaCha20-Poly1305 blob.
753
+ *
754
+ * `encryption_key_hex`: 64-char hex string (32 bytes).
755
+ * Returns the plaintext UTF-8 string.
756
+ * @param {string} encrypted_base64
757
+ * @param {string} encryption_key_hex
758
+ * @returns {string}
759
+ */
760
+ export function decrypt(encrypted_base64, encryption_key_hex) {
761
+ let deferred4_0;
762
+ let deferred4_1;
763
+ try {
764
+ const ptr0 = passStringToWasm0(encrypted_base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
765
+ const len0 = WASM_VECTOR_LEN;
766
+ const ptr1 = passStringToWasm0(encryption_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
767
+ const len1 = WASM_VECTOR_LEN;
768
+ const ret = wasm.decrypt(ptr0, len0, ptr1, len1);
769
+ var ptr3 = ret[0];
770
+ var len3 = ret[1];
771
+ if (ret[3]) {
772
+ ptr3 = 0; len3 = 0;
773
+ throw takeFromExternrefTable0(ret[2]);
774
+ }
775
+ deferred4_0 = ptr3;
776
+ deferred4_1 = len3;
777
+ return getStringFromWasm0(ptr3, len3);
778
+ } finally {
779
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
780
+ }
781
+ }
782
+
783
+ /**
784
+ * Decrypt and rerank search candidates.
785
+ *
786
+ * Takes raw SubgraphFacts (as JSON), decrypts their content + embeddings,
787
+ * and returns top-K ranked results using BM25 + Cosine + RRF fusion.
788
+ *
789
+ * `facts_json`: JSON array of SubgraphFact objects.
790
+ * `query`: The search query text.
791
+ * `query_embedding`: Float32Array of the query embedding.
792
+ * `encryption_key_hex`: 64-char hex string (32 bytes).
793
+ * `top_k`: Number of top results to return.
794
+ *
795
+ * Returns a JsValue (JSON array of RankedResult objects).
796
+ * @param {string} facts_json
797
+ * @param {string} query
798
+ * @param {Float32Array} query_embedding
799
+ * @param {string} encryption_key_hex
800
+ * @param {number} top_k
801
+ * @returns {any}
802
+ */
803
+ export function decryptAndRerank(facts_json, query, query_embedding, encryption_key_hex, top_k) {
804
+ const ptr0 = passStringToWasm0(facts_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
805
+ const len0 = WASM_VECTOR_LEN;
806
+ const ptr1 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
807
+ const len1 = WASM_VECTOR_LEN;
808
+ const ptr2 = passArrayF32ToWasm0(query_embedding, wasm.__wbindgen_malloc);
809
+ const len2 = WASM_VECTOR_LEN;
810
+ const ptr3 = passStringToWasm0(encryption_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
811
+ const len3 = WASM_VECTOR_LEN;
812
+ const ret = wasm.decryptAndRerank(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, top_k);
813
+ if (ret[2]) {
814
+ throw takeFromExternrefTable0(ret[1]);
815
+ }
816
+ return takeFromExternrefTable0(ret[0]);
817
+ }
818
+
819
+ /**
820
+ * Return the locked-default [`PinConfig`] as JSON. Clients that don't want
821
+ * to retune can pass this verbatim to [`wasm_pin_boost`].
822
+ * @returns {string}
823
+ */
824
+ export function defaultPinConfig() {
825
+ let deferred2_0;
826
+ let deferred2_1;
827
+ try {
828
+ const ret = wasm.defaultPinConfig();
829
+ var ptr1 = ret[0];
830
+ var len1 = ret[1];
831
+ if (ret[3]) {
832
+ ptr1 = 0; len1 = 0;
833
+ throw takeFromExternrefTable0(ret[2]);
834
+ }
835
+ deferred2_0 = ptr1;
836
+ deferred2_1 = len1;
837
+ return getStringFromWasm0(ptr1, len1);
838
+ } finally {
839
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
840
+ }
841
+ }
842
+
843
+ /**
844
+ * Default P2-3 resolution weights as JSON.
845
+ * @returns {string}
846
+ */
847
+ export function defaultResolutionWeights() {
848
+ let deferred2_0;
849
+ let deferred2_1;
850
+ try {
851
+ const ret = wasm.defaultResolutionWeights();
852
+ var ptr1 = ret[0];
853
+ var len1 = ret[1];
854
+ if (ret[3]) {
855
+ ptr1 = 0; len1 = 0;
856
+ throw takeFromExternrefTable0(ret[2]);
857
+ }
858
+ deferred2_0 = ptr1;
859
+ deferred2_1 = len1;
860
+ return getStringFromWasm0(ptr1, len1);
861
+ } finally {
862
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
863
+ }
864
+ }
865
+
866
+ /**
867
+ * Build a fresh default WeightsFile JSON with the given timestamp.
868
+ * @param {bigint} now_unix_seconds
869
+ * @returns {string}
870
+ */
871
+ export function defaultWeightsFile(now_unix_seconds) {
872
+ let deferred2_0;
873
+ let deferred2_1;
874
+ try {
875
+ const ret = wasm.defaultWeightsFile(now_unix_seconds);
876
+ var ptr1 = ret[0];
877
+ var len1 = ret[1];
878
+ if (ret[3]) {
879
+ ptr1 = 0; len1 = 0;
880
+ throw takeFromExternrefTable0(ret[2]);
881
+ }
882
+ deferred2_0 = ptr1;
883
+ deferred2_1 = len1;
884
+ return getStringFromWasm0(ptr1, len1);
885
+ } finally {
886
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
887
+ }
888
+ }
889
+
890
+ /**
891
+ * Derive an Ethereum EOA wallet from a BIP-39 mnemonic via BIP-44.
892
+ *
893
+ * Path: m/44'/60'/0'/0/0 (standard Ethereum derivation path).
894
+ * Returns a JS object: `{ private_key: "hex...", address: "0x..." }`.
895
+ * @param {string} mnemonic
896
+ * @returns {any}
897
+ */
898
+ export function deriveEoa(mnemonic) {
899
+ const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
900
+ const len0 = WASM_VECTOR_LEN;
901
+ const ret = wasm.deriveEoa(ptr0, len0);
902
+ if (ret[2]) {
903
+ throw takeFromExternrefTable0(ret[1]);
904
+ }
905
+ return takeFromExternrefTable0(ret[0]);
906
+ }
907
+
908
+ /**
909
+ * Derive just the Ethereum EOA address from a BIP-39 mnemonic.
910
+ *
911
+ * Returns: `"0x..."` (lowercase hex).
912
+ * @param {string} mnemonic
913
+ * @returns {string}
914
+ */
915
+ export function deriveEoaAddress(mnemonic) {
916
+ let deferred3_0;
917
+ let deferred3_1;
918
+ try {
919
+ const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
920
+ const len0 = WASM_VECTOR_LEN;
921
+ const ret = wasm.deriveEoaAddress(ptr0, len0);
922
+ var ptr2 = ret[0];
923
+ var len2 = ret[1];
924
+ if (ret[3]) {
925
+ ptr2 = 0; len2 = 0;
926
+ throw takeFromExternrefTable0(ret[2]);
927
+ }
928
+ deferred3_0 = ptr2;
929
+ deferred3_1 = len2;
930
+ return getStringFromWasm0(ptr2, len2);
931
+ } finally {
932
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
933
+ }
934
+ }
935
+
936
+ /**
937
+ * Derive encryption keys from a BIP-39 mnemonic (strict checksum validation).
938
+ *
939
+ * Returns a JSON object with hex-encoded keys:
940
+ * `{ auth_key, encryption_key, dedup_key, salt }`
941
+ * @param {string} mnemonic
942
+ * @returns {any}
943
+ */
944
+ export function deriveKeysFromMnemonic(mnemonic) {
945
+ const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
946
+ const len0 = WASM_VECTOR_LEN;
947
+ const ret = wasm.deriveKeysFromMnemonic(ptr0, len0);
948
+ if (ret[2]) {
949
+ throw takeFromExternrefTable0(ret[1]);
950
+ }
951
+ return takeFromExternrefTable0(ret[0]);
952
+ }
953
+
954
+ /**
955
+ * Derive encryption keys from a BIP-39 mnemonic (lenient -- skips checksum).
956
+ *
957
+ * Same return format as `deriveKeysFromMnemonic`.
958
+ * @param {string} mnemonic
959
+ * @returns {any}
960
+ */
961
+ export function deriveKeysFromMnemonicLenient(mnemonic) {
962
+ const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
963
+ const len0 = WASM_VECTOR_LEN;
964
+ const ret = wasm.deriveKeysFromMnemonicLenient(ptr0, len0);
965
+ if (ret[2]) {
966
+ throw takeFromExternrefTable0(ret[1]);
967
+ }
968
+ return takeFromExternrefTable0(ret[0]);
969
+ }
970
+
971
+ /**
972
+ * Derive the 32-byte LSH seed from a BIP-39 mnemonic and salt.
973
+ *
974
+ * `salt_hex`: 64-char hex string (32 bytes).
975
+ * Returns hex-encoded 32-byte seed.
976
+ * @param {string} mnemonic
977
+ * @param {string} salt_hex
978
+ * @returns {string}
979
+ */
980
+ export function deriveLshSeed(mnemonic, salt_hex) {
981
+ let deferred4_0;
982
+ let deferred4_1;
983
+ try {
984
+ const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
985
+ const len0 = WASM_VECTOR_LEN;
986
+ const ptr1 = passStringToWasm0(salt_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
987
+ const len1 = WASM_VECTOR_LEN;
988
+ const ret = wasm.deriveLshSeed(ptr0, len0, ptr1, len1);
989
+ var ptr3 = ret[0];
990
+ var len3 = ret[1];
991
+ if (ret[3]) {
992
+ ptr3 = 0; len3 = 0;
993
+ throw takeFromExternrefTable0(ret[2]);
994
+ }
995
+ deferred4_0 = ptr3;
996
+ deferred4_1 = len3;
997
+ return getStringFromWasm0(ptr3, len3);
998
+ } finally {
999
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1000
+ }
1001
+ }
1002
+
1003
+ /**
1004
+ * Detect contradictions between a new claim and existing claims (JSON array of {claim, id, embedding}).
1005
+ * @param {string} new_claim_json
1006
+ * @param {string} new_claim_id
1007
+ * @param {string} new_embedding_json
1008
+ * @param {string} existing_json
1009
+ * @param {number} lower_threshold
1010
+ * @param {number} upper_threshold
1011
+ * @returns {string}
1012
+ */
1013
+ export function detectContradictions(new_claim_json, new_claim_id, new_embedding_json, existing_json, lower_threshold, upper_threshold) {
1014
+ let deferred6_0;
1015
+ let deferred6_1;
1016
+ try {
1017
+ const ptr0 = passStringToWasm0(new_claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1018
+ const len0 = WASM_VECTOR_LEN;
1019
+ const ptr1 = passStringToWasm0(new_claim_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1020
+ const len1 = WASM_VECTOR_LEN;
1021
+ const ptr2 = passStringToWasm0(new_embedding_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1022
+ const len2 = WASM_VECTOR_LEN;
1023
+ const ptr3 = passStringToWasm0(existing_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1024
+ const len3 = WASM_VECTOR_LEN;
1025
+ const ret = wasm.detectContradictions(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, lower_threshold, upper_threshold);
1026
+ var ptr5 = ret[0];
1027
+ var len5 = ret[1];
1028
+ if (ret[3]) {
1029
+ ptr5 = 0; len5 = 0;
1030
+ throw takeFromExternrefTable0(ret[2]);
1031
+ }
1032
+ deferred6_0 = ptr5;
1033
+ deferred6_1 = len5;
1034
+ return getStringFromWasm0(ptr5, len5);
1035
+ } finally {
1036
+ wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
1037
+ }
1038
+ }
1039
+
1040
+ /**
1041
+ * Deterministic entity ID from a name (first 8 bytes of SHA256 as hex).
1042
+ * @param {string} name
1043
+ * @returns {string}
1044
+ */
1045
+ export function deterministicEntityId(name) {
1046
+ let deferred2_0;
1047
+ let deferred2_1;
1048
+ try {
1049
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1050
+ const len0 = WASM_VECTOR_LEN;
1051
+ const ret = wasm.deterministicEntityId(ptr0, len0);
1052
+ deferred2_0 = ret[0];
1053
+ deferred2_1 = ret[1];
1054
+ return getStringFromWasm0(ret[0], ret[1]);
1055
+ } finally {
1056
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1057
+ }
1058
+ }
1059
+
1060
+ /**
1061
+ * Encode multiple fact submissions as SimpleAccount.executeBatch() calldata.
1062
+ *
1063
+ * `payloads_json`: JSON array of hex-encoded payload strings (e.g. `["deadbeef", "cafebabe"]`).
1064
+ * Returns ABI-encoded calldata (Uint8Array).
1065
+ * @param {string} payloads_json
1066
+ * @returns {Uint8Array}
1067
+ */
1068
+ export function encodeBatchCall(payloads_json) {
1069
+ const ptr0 = passStringToWasm0(payloads_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1070
+ const len0 = WASM_VECTOR_LEN;
1071
+ const ret = wasm.encodeBatchCall(ptr0, len0);
1072
+ if (ret[3]) {
1073
+ throw takeFromExternrefTable0(ret[2]);
1074
+ }
1075
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1076
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1077
+ return v2;
1078
+ }
1079
+
1080
+ /**
1081
+ * Like `encodeBatchCall` but targets an explicit DataEdge address (#366).
1082
+ * @param {string} payloads_json
1083
+ * @param {string} data_edge_address
1084
+ * @returns {Uint8Array}
1085
+ */
1086
+ export function encodeBatchCallTo(payloads_json, data_edge_address) {
1087
+ const ptr0 = passStringToWasm0(payloads_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1088
+ const len0 = WASM_VECTOR_LEN;
1089
+ const ptr1 = passStringToWasm0(data_edge_address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1090
+ const len1 = WASM_VECTOR_LEN;
1091
+ const ret = wasm.encodeBatchCallTo(ptr0, len0, ptr1, len1);
1092
+ if (ret[3]) {
1093
+ throw takeFromExternrefTable0(ret[2]);
1094
+ }
1095
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1096
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1097
+ return v3;
1098
+ }
1099
+
1100
+ /**
1101
+ * Pack an embedding into the canonical pre-encryption payload string.
1102
+ *
1103
+ * `embedding`: the f32 vector (production = 640-d Harrier output). A 640-d
1104
+ * vector is packed little-endian f16; any other length is packed f32 (the
1105
+ * 640 guard — see `embedding_codec`). Returns the base64 ASCII string that
1106
+ * the client encrypts before storage.
1107
+ * @param {Float32Array} embedding
1108
+ * @returns {string}
1109
+ */
1110
+ export function encodeEmbeddingCanonical(embedding) {
1111
+ let deferred3_0;
1112
+ let deferred3_1;
1113
+ try {
1114
+ const ptr0 = passArrayF32ToWasm0(embedding, wasm.__wbindgen_malloc);
1115
+ const len0 = WASM_VECTOR_LEN;
1116
+ const ret = wasm.encodeEmbeddingCanonical(ptr0, len0);
1117
+ var ptr2 = ret[0];
1118
+ var len2 = ret[1];
1119
+ if (ret[3]) {
1120
+ ptr2 = 0; len2 = 0;
1121
+ throw takeFromExternrefTable0(ret[2]);
1122
+ }
1123
+ deferred3_0 = ptr2;
1124
+ deferred3_1 = len2;
1125
+ return getStringFromWasm0(ptr2, len2);
1126
+ } finally {
1127
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1128
+ }
1129
+ }
1130
+
1131
+ /**
1132
+ * Encode a fact payload as minimal protobuf wire format.
1133
+ *
1134
+ * `json`: JSON string with shape:
1135
+ * ```json
1136
+ * {
1137
+ * "id": "...", "timestamp": "...", "owner": "...",
1138
+ * "encrypted_blob_hex": "...", "blind_indices": ["..."],
1139
+ * "decay_score": 0.8, "source": "...", "content_fp": "...",
1140
+ * "agent_id": "...", "encrypted_embedding": "..." (optional)
1141
+ * }
1142
+ * ```
1143
+ *
1144
+ * Returns the protobuf bytes as a Uint8Array.
1145
+ * @param {string} json
1146
+ * @returns {Uint8Array}
1147
+ */
1148
+ export function encodeFactProtobuf(json) {
1149
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1150
+ const len0 = WASM_VECTOR_LEN;
1151
+ const ret = wasm.encodeFactProtobuf(ptr0, len0);
1152
+ if (ret[3]) {
1153
+ throw takeFromExternrefTable0(ret[2]);
1154
+ }
1155
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1156
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1157
+ return v2;
1158
+ }
1159
+
1160
+ /**
1161
+ * Encode a single fact submission as SimpleAccount.execute() calldata.
1162
+ *
1163
+ * `protobuf_payload`: raw protobuf bytes (Uint8Array).
1164
+ * Returns ABI-encoded calldata (Uint8Array).
1165
+ * @param {Uint8Array} protobuf_payload
1166
+ * @returns {Uint8Array}
1167
+ */
1168
+ export function encodeSingleCall(protobuf_payload) {
1169
+ const ptr0 = passArray8ToWasm0(protobuf_payload, wasm.__wbindgen_malloc);
1170
+ const len0 = WASM_VECTOR_LEN;
1171
+ const ret = wasm.encodeSingleCall(ptr0, len0);
1172
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1173
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1174
+ return v2;
1175
+ }
1176
+
1177
+ /**
1178
+ * Like `encodeSingleCall` but targets an explicit DataEdge address.
1179
+ *
1180
+ * Chain/environment-aware clients pass the authoritative address from the
1181
+ * relay's `/v1/billing/status` `data_edge_address` (#366) — the isolated
1182
+ * staging Gnosis DataEdge differs from prod's. Throws on a bad address.
1183
+ * @param {Uint8Array} protobuf_payload
1184
+ * @param {string} data_edge_address
1185
+ * @returns {Uint8Array}
1186
+ */
1187
+ export function encodeSingleCallTo(protobuf_payload, data_edge_address) {
1188
+ const ptr0 = passArray8ToWasm0(protobuf_payload, wasm.__wbindgen_malloc);
1189
+ const len0 = WASM_VECTOR_LEN;
1190
+ const ptr1 = passStringToWasm0(data_edge_address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1191
+ const len1 = WASM_VECTOR_LEN;
1192
+ const ret = wasm.encodeSingleCallTo(ptr0, len0, ptr1, len1);
1193
+ if (ret[3]) {
1194
+ throw takeFromExternrefTable0(ret[2]);
1195
+ }
1196
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1197
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1198
+ return v3;
1199
+ }
1200
+
1201
+ /**
1202
+ * Encode a tombstone protobuf for soft-deleting a fact.
1203
+ *
1204
+ * `version` is optional; missing/0 defaults to `DEFAULT_PROTOBUF_VERSION` (3).
1205
+ * Pass `4` to emit a v1-taxonomy tombstone (outer protobuf version = 4).
1206
+ *
1207
+ * Returns the protobuf bytes as a Uint8Array.
1208
+ * @param {string} fact_id
1209
+ * @param {string} owner
1210
+ * @param {number | null} [version]
1211
+ * @returns {Uint8Array}
1212
+ */
1213
+ export function encodeTombstoneProtobuf(fact_id, owner, version) {
1214
+ const ptr0 = passStringToWasm0(fact_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1215
+ const len0 = WASM_VECTOR_LEN;
1216
+ const ptr1 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1217
+ const len1 = WASM_VECTOR_LEN;
1218
+ const ret = wasm.encodeTombstoneProtobuf(ptr0, len0, ptr1, len1, isLikeNone(version) ? 0x100000001 : (version) >>> 0);
1219
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1220
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1221
+ return v3;
1222
+ }
1223
+
1224
+ /**
1225
+ * Encrypt a UTF-8 plaintext with XChaCha20-Poly1305.
1226
+ *
1227
+ * `encryption_key_hex`: 64-char hex string (32 bytes).
1228
+ * Returns base64-encoded ciphertext (wire format: nonce || tag || ciphertext).
1229
+ * @param {string} plaintext
1230
+ * @param {string} encryption_key_hex
1231
+ * @returns {string}
1232
+ */
1233
+ export function encrypt(plaintext, encryption_key_hex) {
1234
+ let deferred4_0;
1235
+ let deferred4_1;
1236
+ try {
1237
+ const ptr0 = passStringToWasm0(plaintext, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1238
+ const len0 = WASM_VECTOR_LEN;
1239
+ const ptr1 = passStringToWasm0(encryption_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1240
+ const len1 = WASM_VECTOR_LEN;
1241
+ const ret = wasm.encrypt(ptr0, len0, ptr1, len1);
1242
+ var ptr3 = ret[0];
1243
+ var len3 = ret[1];
1244
+ if (ret[3]) {
1245
+ ptr3 = 0; len3 = 0;
1246
+ throw takeFromExternrefTable0(ret[2]);
1247
+ }
1248
+ deferred4_0 = ptr3;
1249
+ deferred4_1 = len3;
1250
+ return getStringFromWasm0(ptr3, len3);
1251
+ } finally {
1252
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1253
+ }
1254
+ }
1255
+
1256
+ /**
1257
+ * Enrich an extraction prompt with user profile context.
1258
+ *
1259
+ * `profile_json`: JSON string of a UserProfile.
1260
+ * `base_prompt`: The base extraction prompt to enrich.
1261
+ * Returns the enriched prompt string.
1262
+ * @param {string} profile_json
1263
+ * @param {string} base_prompt
1264
+ * @returns {string}
1265
+ */
1266
+ export function enrichExtractionPrompt(profile_json, base_prompt) {
1267
+ let deferred4_0;
1268
+ let deferred4_1;
1269
+ try {
1270
+ const ptr0 = passStringToWasm0(profile_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1271
+ const len0 = WASM_VECTOR_LEN;
1272
+ const ptr1 = passStringToWasm0(base_prompt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1273
+ const len1 = WASM_VECTOR_LEN;
1274
+ const ret = wasm.enrichExtractionPrompt(ptr0, len0, ptr1, len1);
1275
+ var ptr3 = ret[0];
1276
+ var len3 = ret[1];
1277
+ if (ret[3]) {
1278
+ ptr3 = 0; len3 = 0;
1279
+ throw takeFromExternrefTable0(ret[2]);
1280
+ }
1281
+ deferred4_0 = ptr3;
1282
+ deferred4_1 = len3;
1283
+ return getStringFromWasm0(ptr3, len3);
1284
+ } finally {
1285
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1286
+ }
1287
+ }
1288
+
1289
+ /**
1290
+ * Convert a feedback entry into a counterexample for weight tuning. Returns
1291
+ * JSON Counterexample or the literal string "null" if the entry has no signal.
1292
+ * @param {string} entry_json
1293
+ * @returns {string}
1294
+ */
1295
+ export function feedbackToCounterexample(entry_json) {
1296
+ let deferred3_0;
1297
+ let deferred3_1;
1298
+ try {
1299
+ const ptr0 = passStringToWasm0(entry_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1300
+ const len0 = WASM_VECTOR_LEN;
1301
+ const ret = wasm.feedbackToCounterexample(ptr0, len0);
1302
+ var ptr2 = ret[0];
1303
+ var len2 = ret[1];
1304
+ if (ret[3]) {
1305
+ ptr2 = 0; len2 = 0;
1306
+ throw takeFromExternrefTable0(ret[2]);
1307
+ }
1308
+ deferred3_0 = ptr2;
1309
+ deferred3_1 = len2;
1310
+ return getStringFromWasm0(ptr2, len2);
1311
+ } finally {
1312
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1313
+ }
1314
+ }
1315
+
1316
+ /**
1317
+ * Filter resolution actions by mode ("active" passes through, "shadow"/"off" returns empty).
1318
+ *
1319
+ * Returns a JSON array of `ResolutionAction`.
1320
+ * @param {string} actions_json
1321
+ * @param {string} mode
1322
+ * @returns {string}
1323
+ */
1324
+ export function filterShadowMode(actions_json, mode) {
1325
+ let deferred4_0;
1326
+ let deferred4_1;
1327
+ try {
1328
+ const ptr0 = passStringToWasm0(actions_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1329
+ const len0 = WASM_VECTOR_LEN;
1330
+ const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1331
+ const len1 = WASM_VECTOR_LEN;
1332
+ const ret = wasm.filterShadowMode(ptr0, len0, ptr1, len1);
1333
+ var ptr3 = ret[0];
1334
+ var len3 = ret[1];
1335
+ if (ret[3]) {
1336
+ ptr3 = 0; len3 = 0;
1337
+ throw takeFromExternrefTable0(ret[2]);
1338
+ }
1339
+ deferred4_0 = ptr3;
1340
+ deferred4_1 = len3;
1341
+ return getStringFromWasm0(ptr3, len3);
1342
+ } finally {
1343
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1344
+ }
1345
+ }
1346
+
1347
+ /**
1348
+ * WASM binding for `find_best_near_duplicate`.
1349
+ *
1350
+ * `new_embedding_json`: JSON array of floats (embedding vector).
1351
+ * `existing_json`: JSON array of `{ id: string, embedding: number[] }` objects.
1352
+ * `threshold`: Cosine similarity threshold.
1353
+ *
1354
+ * Returns JSON `{ fact_id: string, similarity: number }` or null.
1355
+ * @param {string} new_embedding_json
1356
+ * @param {string} existing_json
1357
+ * @param {number} threshold
1358
+ * @returns {any}
1359
+ */
1360
+ export function findBestNearDuplicate(new_embedding_json, existing_json, threshold) {
1361
+ const ptr0 = passStringToWasm0(new_embedding_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1362
+ const len0 = WASM_VECTOR_LEN;
1363
+ const ptr1 = passStringToWasm0(existing_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1364
+ const len1 = WASM_VECTOR_LEN;
1365
+ const ret = wasm.findBestNearDuplicate(ptr0, len0, ptr1, len1, threshold);
1366
+ if (ret[2]) {
1367
+ throw takeFromExternrefTable0(ret[1]);
1368
+ }
1369
+ return takeFromExternrefTable0(ret[0]);
1370
+ }
1371
+
1372
+ /**
1373
+ * Find a decision-log entry matching a fact as winner or loser.
1374
+ * Returns the JSON-serialized DecisionLogEntry, or the literal string "null".
1375
+ * @param {string} fact_id
1376
+ * @param {string} role
1377
+ * @param {string} log_content
1378
+ * @returns {string}
1379
+ */
1380
+ export function findDecisionForPin(fact_id, role, log_content) {
1381
+ let deferred4_0;
1382
+ let deferred4_1;
1383
+ try {
1384
+ const ptr0 = passStringToWasm0(fact_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1385
+ const len0 = WASM_VECTOR_LEN;
1386
+ const ptr1 = passStringToWasm0(role, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1387
+ const len1 = WASM_VECTOR_LEN;
1388
+ const ptr2 = passStringToWasm0(log_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1389
+ const len2 = WASM_VECTOR_LEN;
1390
+ const ret = wasm.findDecisionForPin(ptr0, len0, ptr1, len1, ptr2, len2);
1391
+ deferred4_0 = ret[0];
1392
+ deferred4_1 = ret[1];
1393
+ return getStringFromWasm0(ret[0], ret[1]);
1394
+ } finally {
1395
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1396
+ }
1397
+ }
1398
+
1399
+ /**
1400
+ * Find the loser claim JSON from the decision log for a given fact ID.
1401
+ * Returns the loser_claim_json string, or the literal string "null" if not found.
1402
+ * @param {string} fact_id
1403
+ * @param {string} log_content
1404
+ * @returns {string}
1405
+ */
1406
+ export function findLoserClaimInDecisionLog(fact_id, log_content) {
1407
+ let deferred3_0;
1408
+ let deferred3_1;
1409
+ try {
1410
+ const ptr0 = passStringToWasm0(fact_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1411
+ const len0 = WASM_VECTOR_LEN;
1412
+ const ptr1 = passStringToWasm0(log_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1413
+ const len1 = WASM_VECTOR_LEN;
1414
+ const ret = wasm.findLoserClaimInDecisionLog(ptr0, len0, ptr1, len1);
1415
+ deferred3_0 = ret[0];
1416
+ deferred3_1 = ret[1];
1417
+ return getStringFromWasm0(ret[0], ret[1]);
1418
+ } finally {
1419
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1420
+ }
1421
+ }
1422
+
1423
+ /**
1424
+ * WASM binding for `find_near_duplicate` (deprecated — use `findBestNearDuplicate`).
1425
+ *
1426
+ * **Deprecated since core 1.5.0; scheduled for removal in core 3.0.** Returns
1427
+ * the *first* match above `threshold`, not the highest-similarity one. Migrate
1428
+ * npm consumers to `findBestNearDuplicate`.
1429
+ *
1430
+ * `new_embedding`: Float32Array of the new fact's embedding.
1431
+ * `existing_json`: JSON array of `{ id: string, embedding: number[] }` objects.
1432
+ * `threshold`: Cosine similarity threshold.
1433
+ *
1434
+ * Returns `null` if no duplicate found, or a string (the duplicate fact ID).
1435
+ * @param {Float32Array} new_embedding
1436
+ * @param {string} existing_json
1437
+ * @param {number} threshold
1438
+ * @returns {any}
1439
+ */
1440
+ export function findNearDuplicate(new_embedding, existing_json, threshold) {
1441
+ const ptr0 = passArrayF32ToWasm0(new_embedding, wasm.__wbindgen_malloc);
1442
+ const len0 = WASM_VECTOR_LEN;
1443
+ const ptr1 = passStringToWasm0(existing_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1444
+ const len1 = WASM_VECTOR_LEN;
1445
+ const ret = wasm.findNearDuplicate(ptr0, len0, ptr1, len1, threshold);
1446
+ if (ret[2]) {
1447
+ throw takeFromExternrefTable0(ret[1]);
1448
+ }
1449
+ return takeFromExternrefTable0(ret[0]);
1450
+ }
1451
+
1452
+ /**
1453
+ * Unix seconds → `"YYYY-MM-DD"` (UTC). Returns `""` for `0` or negative.
1454
+ *
1455
+ * Maps directly to [`crate::recall_context::format_memory_date`].
1456
+ * @param {bigint} created_at_unix
1457
+ * @returns {string}
1458
+ */
1459
+ export function formatMemoryDate(created_at_unix) {
1460
+ let deferred1_0;
1461
+ let deferred1_1;
1462
+ try {
1463
+ const ret = wasm.formatMemoryDate(created_at_unix);
1464
+ deferred1_0 = ret[0];
1465
+ deferred1_1 = ret[1];
1466
+ return getStringFromWasm0(ret[0], ret[1]);
1467
+ } finally {
1468
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1469
+ }
1470
+ }
1471
+
1472
+ /**
1473
+ * Build the full recall-context block: header + one line per memory item.
1474
+ *
1475
+ * `items_json`: JSON array of `{ category, text, created_at }`. Any field
1476
+ * may be absent (defaults to empty string / 0). Bad or empty JSON → header
1477
+ * only (no panic).
1478
+ *
1479
+ * Output line format:
1480
+ * - With date: `"- [category] (YYYY-MM-DD) text"`
1481
+ * - Without date: `"- [category] text"`
1482
+ *
1483
+ * `now_unix`: current time as Unix seconds (used in the header date).
1484
+ * @param {string} items_json
1485
+ * @param {bigint} now_unix
1486
+ * @returns {string}
1487
+ */
1488
+ export function formatRecallContext(items_json, now_unix) {
1489
+ let deferred2_0;
1490
+ let deferred2_1;
1491
+ try {
1492
+ const ptr0 = passStringToWasm0(items_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1493
+ const len0 = WASM_VECTOR_LEN;
1494
+ const ret = wasm.formatRecallContext(ptr0, len0, now_unix);
1495
+ deferred2_0 = ret[0];
1496
+ deferred2_1 = ret[1];
1497
+ return getStringFromWasm0(ret[0], ret[1]);
1498
+ } finally {
1499
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1500
+ }
1501
+ }
1502
+
1503
+ /**
1504
+ * Generate blind indices (SHA-256 token hashes) for a text string.
1505
+ *
1506
+ * Returns a JSON array of hex strings.
1507
+ * @param {string} text
1508
+ * @returns {any}
1509
+ */
1510
+ export function generateBlindIndices(text) {
1511
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1512
+ const len0 = WASM_VECTOR_LEN;
1513
+ const ret = wasm.generateBlindIndices(ptr0, len0);
1514
+ if (ret[2]) {
1515
+ throw takeFromExternrefTable0(ret[1]);
1516
+ }
1517
+ return takeFromExternrefTable0(ret[0]);
1518
+ }
1519
+
1520
+ /**
1521
+ * Compute HMAC-SHA256 content fingerprint.
1522
+ *
1523
+ * `dedup_key_hex`: 64-char hex string (32 bytes).
1524
+ * Returns 64-char hex fingerprint.
1525
+ * @param {string} plaintext
1526
+ * @param {string} dedup_key_hex
1527
+ * @returns {string}
1528
+ */
1529
+ export function generateContentFingerprint(plaintext, dedup_key_hex) {
1530
+ let deferred4_0;
1531
+ let deferred4_1;
1532
+ try {
1533
+ const ptr0 = passStringToWasm0(plaintext, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1534
+ const len0 = WASM_VECTOR_LEN;
1535
+ const ptr1 = passStringToWasm0(dedup_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1536
+ const len1 = WASM_VECTOR_LEN;
1537
+ const ret = wasm.generateContentFingerprint(ptr0, len0, ptr1, len1);
1538
+ var ptr3 = ret[0];
1539
+ var len3 = ret[1];
1540
+ if (ret[3]) {
1541
+ ptr3 = 0; len3 = 0;
1542
+ throw takeFromExternrefTable0(ret[2]);
1543
+ }
1544
+ deferred4_0 = ptr3;
1545
+ deferred4_1 = len3;
1546
+ return getStringFromWasm0(ptr3, len3);
1547
+ } finally {
1548
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1549
+ }
1550
+ }
1551
+
1552
+ /**
1553
+ * Generate trapdoors for multiple query reformulations (expansion pipeline).
1554
+ *
1555
+ * `queries_json`: JSON array of query strings (original + reformulations).
1556
+ * `embeddings_json`: JSON array of Float32Array-compatible arrays (one per query).
1557
+ * `lsh_hasher`: A `WasmLshHasher` instance.
1558
+ *
1559
+ * Returns a JsValue (JSON array of trapdoor-string arrays, one per query).
1560
+ * @param {string} queries_json
1561
+ * @param {string} embeddings_json
1562
+ * @param {WasmLshHasher} lsh_hasher
1563
+ * @returns {any}
1564
+ */
1565
+ export function generateExpansionTrapdoors(queries_json, embeddings_json, lsh_hasher) {
1566
+ const ptr0 = passStringToWasm0(queries_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1567
+ const len0 = WASM_VECTOR_LEN;
1568
+ const ptr1 = passStringToWasm0(embeddings_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1569
+ const len1 = WASM_VECTOR_LEN;
1570
+ _assertClass(lsh_hasher, WasmLshHasher);
1571
+ const ret = wasm.generateExpansionTrapdoors(ptr0, len0, ptr1, len1, lsh_hasher.__wbg_ptr);
1572
+ if (ret[2]) {
1573
+ throw takeFromExternrefTable0(ret[1]);
1574
+ }
1575
+ return takeFromExternrefTable0(ret[0]);
1576
+ }
1577
+
1578
+ /**
1579
+ * Generate all search trapdoors for a query (word hashes + LSH bucket hashes).
1580
+ *
1581
+ * `query`: The search query text.
1582
+ * `query_embedding`: Float32Array of the query embedding.
1583
+ * `lsh_hasher`: A `WasmLshHasher` instance.
1584
+ *
1585
+ * Returns a JsValue (JSON array of hex-encoded trapdoor strings).
1586
+ * @param {string} query
1587
+ * @param {Float32Array} query_embedding
1588
+ * @param {WasmLshHasher} lsh_hasher
1589
+ * @returns {any}
1590
+ */
1591
+ export function generateSearchTrapdoors(query, query_embedding, lsh_hasher) {
1592
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1593
+ const len0 = WASM_VECTOR_LEN;
1594
+ const ptr1 = passArrayF32ToWasm0(query_embedding, wasm.__wbindgen_malloc);
1595
+ const len1 = WASM_VECTOR_LEN;
1596
+ _assertClass(lsh_hasher, WasmLshHasher);
1597
+ const ret = wasm.generateSearchTrapdoors(ptr0, len0, ptr1, len1, lsh_hasher.__wbg_ptr);
1598
+ if (ret[2]) {
1599
+ throw takeFromExternrefTable0(ret[1]);
1600
+ }
1601
+ return takeFromExternrefTable0(ret[0]);
1602
+ }
1603
+
1604
+ /**
1605
+ * Get the GraphQL query string for broadened (fallback) search.
1606
+ * @returns {string}
1607
+ */
1608
+ export function getBroadenedSearchQuery() {
1609
+ let deferred1_0;
1610
+ let deferred1_1;
1611
+ try {
1612
+ const ret = wasm.getBroadenedSearchQuery();
1613
+ deferred1_0 = ret[0];
1614
+ deferred1_1 = ret[1];
1615
+ return getStringFromWasm0(ret[0], ret[1]);
1616
+ } finally {
1617
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1618
+ }
1619
+ }
1620
+
1621
+ /**
1622
+ * Get the canonical v1 compaction system prompt.
1623
+ *
1624
+ * Used on end-of-context surfaces where the importance floor is 5 rather
1625
+ * than the default 6.
1626
+ * @returns {string}
1627
+ */
1628
+ export function getCompactionSystemPrompt() {
1629
+ let deferred1_0;
1630
+ let deferred1_1;
1631
+ try {
1632
+ const ret = wasm.getCompactionSystemPrompt();
1633
+ deferred1_0 = ret[0];
1634
+ deferred1_1 = ret[1];
1635
+ return getStringFromWasm0(ret[0], ret[1]);
1636
+ } finally {
1637
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1638
+ }
1639
+ }
1640
+
1641
+ /**
1642
+ * WASM binding: get the consolidation cosine threshold constant.
1643
+ * @returns {number}
1644
+ */
1645
+ export function getConsolidationCosineThreshold() {
1646
+ const ret = wasm.getConsolidationCosineThreshold();
1647
+ return ret;
1648
+ }
1649
+
1650
+ /**
1651
+ * Get the GraphQL query string for fact count.
1652
+ * @returns {string}
1653
+ */
1654
+ export function getCountQuery() {
1655
+ let deferred1_0;
1656
+ let deferred1_1;
1657
+ try {
1658
+ const ret = wasm.getCountQuery();
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 DataEdge contract address constant.
1669
+ * @returns {string}
1670
+ */
1671
+ export function getDataEdgeAddress() {
1672
+ let deferred1_0;
1673
+ let deferred1_1;
1674
+ try {
1675
+ const ret = wasm.getDataEdgeAddress();
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
+ * Source tag for debrief items.
1686
+ * @returns {string}
1687
+ */
1688
+ export function getDebriefSource() {
1689
+ let deferred1_0;
1690
+ let deferred1_1;
1691
+ try {
1692
+ const ret = wasm.getDebriefSource();
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 debrief system prompt template.
1703
+ *
1704
+ * Contains `{already_stored_facts}` placeholder.
1705
+ * @returns {string}
1706
+ */
1707
+ export function getDebriefSystemPrompt() {
1708
+ let deferred1_0;
1709
+ let deferred1_1;
1710
+ try {
1711
+ const ret = wasm.getDebriefSystemPrompt();
1712
+ deferred1_0 = ret[0];
1713
+ deferred1_1 = ret[1];
1714
+ return getStringFromWasm0(ret[0], ret[1]);
1715
+ } finally {
1716
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1717
+ }
1718
+ }
1719
+
1720
+ /**
1721
+ * Get the EntryPoint v0.7 address constant.
1722
+ * @returns {string}
1723
+ */
1724
+ export function getEntryPointAddress() {
1725
+ let deferred1_0;
1726
+ let deferred1_1;
1727
+ try {
1728
+ const ret = wasm.getEntryPointAddress();
1729
+ deferred1_0 = ret[0];
1730
+ deferred1_1 = ret[1];
1731
+ return getStringFromWasm0(ret[0], ret[1]);
1732
+ } finally {
1733
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1734
+ }
1735
+ }
1736
+
1737
+ /**
1738
+ * Get the GraphQL query string for paginated export.
1739
+ * @returns {string}
1740
+ */
1741
+ export function getExportQuery() {
1742
+ let deferred1_0;
1743
+ let deferred1_1;
1744
+ try {
1745
+ const ret = wasm.getExportQuery();
1746
+ deferred1_0 = ret[0];
1747
+ deferred1_1 = ret[1];
1748
+ return getStringFromWasm0(ret[0], ret[1]);
1749
+ } finally {
1750
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1751
+ }
1752
+ }
1753
+
1754
+ /**
1755
+ * Get the canonical v1 merged-topic extraction system prompt.
1756
+ *
1757
+ * Single source of truth across all TotalReclaw clients — TS/WASM
1758
+ * callers get the same bytes the Python `totalreclaw_core` module
1759
+ * returns from `get_extraction_system_prompt()`. Includes the Rule 6
1760
+ * meta-request filter (see the docstring on `prompts.rs`).
1761
+ * @returns {string}
1762
+ */
1763
+ export function getExtractionSystemPrompt() {
1764
+ let deferred1_0;
1765
+ let deferred1_1;
1766
+ try {
1767
+ const ret = wasm.getExtractionSystemPrompt();
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 maximum batch size constant.
1778
+ * @returns {number}
1779
+ */
1780
+ export function getMaxBatchSize() {
1781
+ const ret = wasm.getMaxBatchSize();
1782
+ return ret >>> 0;
1783
+ }
1784
+
1785
+ /**
1786
+ * Maximum debrief items (5).
1787
+ * @returns {number}
1788
+ */
1789
+ export function getMaxDebriefItems() {
1790
+ const ret = wasm.getMaxDebriefItems();
1791
+ return ret >>> 0;
1792
+ }
1793
+
1794
+ /**
1795
+ * Minimum messages for debrief (8 = 4 turns).
1796
+ * @returns {number}
1797
+ */
1798
+ export function getMinDebriefMessages() {
1799
+ const ret = wasm.getMinDebriefMessages();
1800
+ return ret >>> 0;
1801
+ }
1802
+
1803
+ /**
1804
+ * Get the page size constant.
1805
+ * @returns {number}
1806
+ */
1807
+ export function getPageSize() {
1808
+ const ret = wasm.getPageSize();
1809
+ return ret >>> 0;
1810
+ }
1811
+
1812
+ /**
1813
+ * Get the GraphQL query string for blind index search.
1814
+ * @returns {string}
1815
+ */
1816
+ export function getSearchQuery() {
1817
+ let deferred1_0;
1818
+ let deferred1_1;
1819
+ try {
1820
+ const ret = wasm.getSearchQuery();
1821
+ deferred1_0 = ret[0];
1822
+ deferred1_1 = ret[1];
1823
+ return getStringFromWasm0(ret[0], ret[1]);
1824
+ } finally {
1825
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1826
+ }
1827
+ }
1828
+
1829
+ /**
1830
+ * Get the SimpleAccountFactory address constant.
1831
+ * @returns {string}
1832
+ */
1833
+ export function getSimpleAccountFactory() {
1834
+ let deferred1_0;
1835
+ let deferred1_1;
1836
+ try {
1837
+ const ret = wasm.getSimpleAccountFactory();
1838
+ deferred1_0 = ret[0];
1839
+ deferred1_1 = ret[1];
1840
+ return getStringFromWasm0(ret[0], ret[1]);
1841
+ } finally {
1842
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1843
+ }
1844
+ }
1845
+
1846
+ /**
1847
+ * WASM binding: get the store-time dedup cosine threshold constant.
1848
+ * @returns {number}
1849
+ */
1850
+ export function getStoreDedupCosineThreshold() {
1851
+ const ret = wasm.getStoreDedupCosineThreshold();
1852
+ return ret;
1853
+ }
1854
+
1855
+ /**
1856
+ * WASM binding: get the store-time dedup max candidates constant.
1857
+ * @returns {number}
1858
+ */
1859
+ export function getStoreDedupMaxCandidates() {
1860
+ const ret = wasm.getStoreDedupMaxCandidates();
1861
+ return ret >>> 0;
1862
+ }
1863
+
1864
+ /**
1865
+ * Get the trapdoor batch size constant.
1866
+ * @returns {number}
1867
+ */
1868
+ export function getTrapdoorBatchSize() {
1869
+ const ret = wasm.getTrapdoorBatchSize();
1870
+ return ret >>> 0;
1871
+ }
1872
+
1873
+ /**
1874
+ * Get the v1 type → short-form category mapping.
1875
+ *
1876
+ * Returns a plain JS object `{ claim: "claim", preference: "pref",
1877
+ * directive: "rule", commitment: "goal", episode: "epi",
1878
+ * summary: "sum" }`.
1879
+ *
1880
+ * Uses `js_sys::Object.set` directly so the result is a plain JS
1881
+ * object (not a `Map`) regardless of serde-wasm-bindgen defaults,
1882
+ * matching how TypeScript clients consume the mapping via bracket
1883
+ * access (`map[type]`).
1884
+ * @returns {any}
1885
+ */
1886
+ export function getTypeToCategory() {
1887
+ const ret = wasm.getTypeToCategory();
1888
+ if (ret[2]) {
1889
+ throw takeFromExternrefTable0(ret[1]);
1890
+ }
1891
+ return takeFromExternrefTable0(ret[0]);
1892
+ }
1893
+
1894
+ /**
1895
+ * Get the canonical list of v1 memory types.
1896
+ *
1897
+ * Returns a JS array of six strings: `["claim", "preference",
1898
+ * "directive", "commitment", "episode", "summary"]`.
1899
+ * @returns {any}
1900
+ */
1901
+ export function getValidMemoryTypes() {
1902
+ const ret = wasm.getValidMemoryTypes();
1903
+ if (ret[2]) {
1904
+ throw takeFromExternrefTable0(ret[1]);
1905
+ }
1906
+ return takeFromExternrefTable0(ret[0]);
1907
+ }
1908
+
1909
+ /**
1910
+ * Compute the ERC-4337 v0.7 UserOp hash for signing.
1911
+ *
1912
+ * `userop_json`: JSON string of a UserOperationV7 struct.
1913
+ * `entrypoint`: EntryPoint address (0x-prefixed).
1914
+ * `chain_id`: Chain ID (e.g. 84532 for Base Sepolia).
1915
+ * Returns 32-byte hash as hex string.
1916
+ * @param {string} userop_json
1917
+ * @param {string} entrypoint
1918
+ * @param {bigint} chain_id
1919
+ * @returns {string}
1920
+ */
1921
+ export function hashUserOp(userop_json, entrypoint, chain_id) {
1922
+ let deferred4_0;
1923
+ let deferred4_1;
1924
+ try {
1925
+ const ptr0 = passStringToWasm0(userop_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1926
+ const len0 = WASM_VECTOR_LEN;
1927
+ const ptr1 = passStringToWasm0(entrypoint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1928
+ const len1 = WASM_VECTOR_LEN;
1929
+ const ret = wasm.hashUserOp(ptr0, len0, ptr1, len1, chain_id);
1930
+ var ptr3 = ret[0];
1931
+ var len3 = ret[1];
1932
+ if (ret[3]) {
1933
+ ptr3 = 0; len3 = 0;
1934
+ throw takeFromExternrefTable0(ret[2]);
1935
+ }
1936
+ deferred4_0 = ptr3;
1937
+ deferred4_1 = len3;
1938
+ return getStringFromWasm0(ptr3, len3);
1939
+ } finally {
1940
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1941
+ }
1942
+ }
1943
+
1944
+ /**
1945
+ * Convert a subgraph hex blob to base64 for decryption.
1946
+ *
1947
+ * `hex_blob`: Hex string (optionally `0x`-prefixed) from the subgraph.
1948
+ * Returns base64-encoded bytes, or null if the hex is invalid.
1949
+ * @param {string} hex_blob
1950
+ * @returns {string | undefined}
1951
+ */
1952
+ export function hexBlobToBase64(hex_blob) {
1953
+ const ptr0 = passStringToWasm0(hex_blob, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1954
+ const len0 = WASM_VECTOR_LEN;
1955
+ const ret = wasm.hexBlobToBase64(ptr0, len0);
1956
+ let v2;
1957
+ if (ret[0] !== 0) {
1958
+ v2 = getStringFromWasm0(ret[0], ret[1]).slice();
1959
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1960
+ }
1961
+ return v2;
1962
+ }
1963
+
1964
+ /**
1965
+ * Check whether a JSON-serialized claim has pinned status.
1966
+ * @param {string} claim_json
1967
+ * @returns {boolean}
1968
+ */
1969
+ export function isPinnedClaim(claim_json) {
1970
+ const ptr0 = passStringToWasm0(claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1971
+ const len0 = WASM_VECTOR_LEN;
1972
+ const ret = wasm.isPinnedClaim(ptr0, len0);
1973
+ return ret !== 0;
1974
+ }
1975
+
1976
+ /**
1977
+ * Check whether a JSON-encoded claim is pinned, recognizing both the v0
1978
+ * short-key sentinel (`st == "p"`) and the v1.1 field (`pin_status ==
1979
+ * "pinned"`). Returns `false` on any parse failure.
1980
+ *
1981
+ * Wrapper around [`crate::claims::is_pinned_json`] for TS clients.
1982
+ * @param {string} claim_json
1983
+ * @returns {boolean}
1984
+ */
1985
+ export function isPinnedClaimJson(claim_json) {
1986
+ const ptr0 = passStringToWasm0(claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1987
+ const len0 = WASM_VECTOR_LEN;
1988
+ const ret = wasm.isPinnedClaimJson(ptr0, len0);
1989
+ return ret !== 0;
1990
+ }
1991
+
1992
+ /**
1993
+ * Runtime guard: is `value` a valid v1 memory type?
1994
+ * @param {string} value
1995
+ * @returns {boolean}
1996
+ */
1997
+ export function isValidMemoryType(value) {
1998
+ const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1999
+ const len0 = WASM_VECTOR_LEN;
2000
+ const ret = wasm.isValidMemoryType(ptr0, len0);
2001
+ return ret !== 0;
2002
+ }
2003
+
2004
+ /**
2005
+ * Return the v1 legacy-claim fallback weight (applied to candidates that
2006
+ * have no `source` field).
2007
+ * @returns {number}
2008
+ */
2009
+ export function legacyClaimFallbackWeight() {
2010
+ const ret = wasm.legacyClaimFallbackWeight();
2011
+ return ret;
2012
+ }
2013
+
2014
+ /**
2015
+ * Map a v1 type to its short-form category key.
2016
+ *
2017
+ * Returns `null` if `value` is not one of the six v1 types.
2018
+ * @param {string} value
2019
+ * @returns {any}
2020
+ */
2021
+ export function mapTypeToCategory(value) {
2022
+ const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2023
+ const len0 = WASM_VECTOR_LEN;
2024
+ const ret = wasm.mapTypeToCategory(ptr0, len0);
2025
+ return ret;
2026
+ }
2027
+
2028
+ /**
2029
+ * Merge multiple SubgraphFact sets from parallel query reformulations via RRF.
2030
+ *
2031
+ * `fact_sets_json`: JSON array of SubgraphFact arrays (one array per reformulation).
2032
+ * `rrf_k`: RRF k-parameter (use 60.0 for default behaviour).
2033
+ *
2034
+ * Returns a JsValue (merged, deduplicated SubgraphFact array sorted by RRF score).
2035
+ * @param {string} fact_sets_json
2036
+ * @param {number} rrf_k
2037
+ * @returns {any}
2038
+ */
2039
+ export function mergeExpansionResults(fact_sets_json, rrf_k) {
2040
+ const ptr0 = passStringToWasm0(fact_sets_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2041
+ const len0 = WASM_VECTOR_LEN;
2042
+ const ret = wasm.mergeExpansionResults(ptr0, len0, rrf_k);
2043
+ if (ret[2]) {
2044
+ throw takeFromExternrefTable0(ret[1]);
2045
+ }
2046
+ return takeFromExternrefTable0(ret[0]);
2047
+ }
2048
+
2049
+ /**
2050
+ * Normalize an entity name (NFC, lowercase, trim, collapse whitespace).
2051
+ * @param {string} name
2052
+ * @returns {string}
2053
+ */
2054
+ export function normalizeEntityName(name) {
2055
+ let deferred2_0;
2056
+ let deferred2_1;
2057
+ try {
2058
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2059
+ const len0 = WASM_VECTOR_LEN;
2060
+ const ret = wasm.normalizeEntityName(ptr0, len0);
2061
+ deferred2_0 = ret[0];
2062
+ deferred2_1 = ret[1];
2063
+ return getStringFromWasm0(ret[0], ret[1]);
2064
+ } finally {
2065
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
2066
+ }
2067
+ }
2068
+
2069
+ /**
2070
+ * Normalize text (NFC, lowercase, collapse whitespace, trim).
2071
+ * @param {string} text
2072
+ * @returns {string}
2073
+ */
2074
+ export function normalizeText(text) {
2075
+ let deferred2_0;
2076
+ let deferred2_1;
2077
+ try {
2078
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2079
+ const len0 = WASM_VECTOR_LEN;
2080
+ const ret = wasm.normalizeText(ptr0, len0);
2081
+ deferred2_0 = ret[0];
2082
+ deferred2_1 = ret[1];
2083
+ return getStringFromWasm0(ret[0], ret[1]);
2084
+ } finally {
2085
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
2086
+ }
2087
+ }
2088
+
2089
+ /**
2090
+ * Parse a broadened search GraphQL response into SubgraphFact list.
2091
+ *
2092
+ * `response_json`: Raw JSON string from the GraphQL response.
2093
+ * Returns a JsValue (JSON array of SubgraphFact objects).
2094
+ * @param {string} response_json
2095
+ * @returns {any}
2096
+ */
2097
+ export function parseBroadenedResponse(response_json) {
2098
+ const ptr0 = passStringToWasm0(response_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2099
+ const len0 = WASM_VECTOR_LEN;
2100
+ const ret = wasm.parseBroadenedResponse(ptr0, len0);
2101
+ if (ret[2]) {
2102
+ throw takeFromExternrefTable0(ret[1]);
2103
+ }
2104
+ return takeFromExternrefTable0(ret[0]);
2105
+ }
2106
+
2107
+ /**
2108
+ * Parse a decrypted blob as a Claim, falling back to legacy formats.
2109
+ * Returns JSON-serialized Claim.
2110
+ * @param {string} decrypted
2111
+ * @returns {string}
2112
+ */
2113
+ export function parseClaimOrLegacy(decrypted) {
2114
+ let deferred3_0;
2115
+ let deferred3_1;
2116
+ try {
2117
+ const ptr0 = passStringToWasm0(decrypted, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2118
+ const len0 = WASM_VECTOR_LEN;
2119
+ const ret = wasm.parseClaimOrLegacy(ptr0, len0);
2120
+ var ptr2 = ret[0];
2121
+ var len2 = ret[1];
2122
+ if (ret[3]) {
2123
+ ptr2 = 0; len2 = 0;
2124
+ throw takeFromExternrefTable0(ret[2]);
2125
+ }
2126
+ deferred3_0 = ptr2;
2127
+ deferred3_1 = len2;
2128
+ return getStringFromWasm0(ptr2, len2);
2129
+ } finally {
2130
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2131
+ }
2132
+ }
2133
+
2134
+ /**
2135
+ * Parse a debrief LLM response into validated items.
2136
+ *
2137
+ * Returns a JSON array of `{ text, type, importance }` objects.
2138
+ * @param {string} response
2139
+ * @returns {any}
2140
+ */
2141
+ export function parseDebriefResponse(response) {
2142
+ const ptr0 = passStringToWasm0(response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2143
+ const len0 = WASM_VECTOR_LEN;
2144
+ const ret = wasm.parseDebriefResponse(ptr0, len0);
2145
+ if (ret[2]) {
2146
+ throw takeFromExternrefTable0(ret[1]);
2147
+ }
2148
+ return takeFromExternrefTable0(ret[0]);
2149
+ }
2150
+
2151
+ /**
2152
+ * Parse an LLM digest response.
2153
+ * Returns JSON-serialized ParsedDigestResponse.
2154
+ * @param {string} raw
2155
+ * @returns {string}
2156
+ */
2157
+ export function parseDigestResponse(raw) {
2158
+ let deferred3_0;
2159
+ let deferred3_1;
2160
+ try {
2161
+ const ptr0 = passStringToWasm0(raw, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2162
+ const len0 = WASM_VECTOR_LEN;
2163
+ const ret = wasm.parseDigestResponse(ptr0, len0);
2164
+ var ptr2 = ret[0];
2165
+ var len2 = ret[1];
2166
+ if (ret[3]) {
2167
+ ptr2 = 0; len2 = 0;
2168
+ throw takeFromExternrefTable0(ret[2]);
2169
+ }
2170
+ deferred3_0 = ptr2;
2171
+ deferred3_1 = len2;
2172
+ return getStringFromWasm0(ptr2, len2);
2173
+ } finally {
2174
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2175
+ }
2176
+ }
2177
+
2178
+ /**
2179
+ * Parse a Gemini export (JSON or saved-info text) into a `ParseResult`.
2180
+ * @param {string} input
2181
+ * @returns {any}
2182
+ */
2183
+ export function parseGemini(input) {
2184
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2185
+ const len0 = WASM_VECTOR_LEN;
2186
+ const ret = wasm.parseGemini(ptr0, len0);
2187
+ if (ret[2]) {
2188
+ throw takeFromExternrefTable0(ret[1]);
2189
+ }
2190
+ return takeFromExternrefTable0(ret[0]);
2191
+ }
2192
+
2193
+ /**
2194
+ * Case-insensitive parse of a memory source string. Unknown input returns "user-inferred".
2195
+ * @param {string} s
2196
+ * @returns {string}
2197
+ */
2198
+ export function parseMemorySource(s) {
2199
+ let deferred2_0;
2200
+ let deferred2_1;
2201
+ try {
2202
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2203
+ const len0 = WASM_VECTOR_LEN;
2204
+ const ret = wasm.parseMemorySource(ptr0, len0);
2205
+ deferred2_0 = ret[0];
2206
+ deferred2_1 = ret[1];
2207
+ return getStringFromWasm0(ret[0], ret[1]);
2208
+ } finally {
2209
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
2210
+ }
2211
+ }
2212
+
2213
+ /**
2214
+ * Case-insensitive parse of a memory type string. Unknown input returns "claim".
2215
+ * @param {string} s
2216
+ * @returns {string}
2217
+ */
2218
+ export function parseMemoryTypeV1(s) {
2219
+ let deferred2_0;
2220
+ let deferred2_1;
2221
+ try {
2222
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2223
+ const len0 = WASM_VECTOR_LEN;
2224
+ const ret = wasm.parseMemoryTypeV1(ptr0, len0);
2225
+ deferred2_0 = ret[0];
2226
+ deferred2_1 = ret[1];
2227
+ return getStringFromWasm0(ret[0], ret[1]);
2228
+ } finally {
2229
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
2230
+ }
2231
+ }
2232
+
2233
+ /**
2234
+ * Case-insensitive parse of a v1.1 pin_status string. Unknown input returns "unpinned".
2235
+ * @param {string} s
2236
+ * @returns {string}
2237
+ */
2238
+ export function parsePinStatus(s) {
2239
+ let deferred2_0;
2240
+ let deferred2_1;
2241
+ try {
2242
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2243
+ const len0 = WASM_VECTOR_LEN;
2244
+ const ret = wasm.parsePinStatus(ptr0, len0);
2245
+ deferred2_0 = ret[0];
2246
+ deferred2_1 = ret[1];
2247
+ return getStringFromWasm0(ret[0], ret[1]);
2248
+ } finally {
2249
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
2250
+ }
2251
+ }
2252
+
2253
+ /**
2254
+ * Parse a batch profiling LLM response into a PartialProfile.
2255
+ *
2256
+ * `llm_output`: Raw LLM response string.
2257
+ * Returns a JsValue (PartialProfile object).
2258
+ * @param {string} llm_output
2259
+ * @returns {any}
2260
+ */
2261
+ export function parseProfileBatchResponse(llm_output) {
2262
+ const ptr0 = passStringToWasm0(llm_output, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2263
+ const len0 = WASM_VECTOR_LEN;
2264
+ const ret = wasm.parseProfileBatchResponse(ptr0, len0);
2265
+ if (ret[2]) {
2266
+ throw takeFromExternrefTable0(ret[1]);
2267
+ }
2268
+ return takeFromExternrefTable0(ret[0]);
2269
+ }
2270
+
2271
+ /**
2272
+ * Parse the merge LLM response into a UserProfile.
2273
+ *
2274
+ * `llm_output`: Raw LLM response string.
2275
+ * Returns a JsValue (UserProfile object).
2276
+ * @param {string} llm_output
2277
+ * @returns {any}
2278
+ */
2279
+ export function parseProfileResponse(llm_output) {
2280
+ const ptr0 = passStringToWasm0(llm_output, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2281
+ const len0 = WASM_VECTOR_LEN;
2282
+ const ret = wasm.parseProfileResponse(ptr0, len0);
2283
+ if (ret[2]) {
2284
+ throw takeFromExternrefTable0(ret[1]);
2285
+ }
2286
+ return takeFromExternrefTable0(ret[0]);
2287
+ }
2288
+
2289
+ /**
2290
+ * Parse a blind index search GraphQL response into SubgraphFact list.
2291
+ *
2292
+ * `response_json`: Raw JSON string from the GraphQL response.
2293
+ * Returns a JsValue (JSON array of SubgraphFact objects).
2294
+ * @param {string} response_json
2295
+ * @returns {any}
2296
+ */
2297
+ export function parseSearchResponse(response_json) {
2298
+ const ptr0 = passStringToWasm0(response_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2299
+ const len0 = WASM_VECTOR_LEN;
2300
+ const ret = wasm.parseSearchResponse(ptr0, len0);
2301
+ if (ret[2]) {
2302
+ throw takeFromExternrefTable0(ret[1]);
2303
+ }
2304
+ return takeFromExternrefTable0(ret[0]);
2305
+ }
2306
+
2307
+ /**
2308
+ * Parse the triage LLM response into chunk decisions.
2309
+ *
2310
+ * `llm_output`: Raw LLM response string.
2311
+ * Returns a JsValue (JSON array of ChunkDecision objects).
2312
+ * @param {string} llm_output
2313
+ * @returns {any}
2314
+ */
2315
+ export function parseTriageResponse(llm_output) {
2316
+ const ptr0 = passStringToWasm0(llm_output, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2317
+ const len0 = WASM_VECTOR_LEN;
2318
+ const ret = wasm.parseTriageResponse(ptr0, len0);
2319
+ if (ret[2]) {
2320
+ throw takeFromExternrefTable0(ret[1]);
2321
+ }
2322
+ return takeFromExternrefTable0(ret[0]);
2323
+ }
2324
+
2325
+ /**
2326
+ * Parse a WeightsFile from JSON; rejects unknown versions and malformed input.
2327
+ * @param {string} content
2328
+ * @returns {string}
2329
+ */
2330
+ export function parseWeightsFile(content) {
2331
+ let deferred3_0;
2332
+ let deferred3_1;
2333
+ try {
2334
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2335
+ const len0 = WASM_VECTOR_LEN;
2336
+ const ret = wasm.parseWeightsFile(ptr0, len0);
2337
+ var ptr2 = ret[0];
2338
+ var len2 = ret[1];
2339
+ if (ret[3]) {
2340
+ ptr2 = 0; len2 = 0;
2341
+ throw takeFromExternrefTable0(ret[2]);
2342
+ }
2343
+ deferred3_0 = ptr2;
2344
+ deferred3_1 = len2;
2345
+ return getStringFromWasm0(ptr2, len2);
2346
+ } finally {
2347
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2348
+ }
2349
+ }
2350
+
2351
+ /**
2352
+ * Compute the [`PinTier`]'s multiplicative boost at a given timestamp.
2353
+ *
2354
+ * `tier_json`: internally-tagged JSON, e.g. `{"tier":"soft","pinned_at":1716000000}`,
2355
+ * `{"tier":"hard"}`, `{"tier":"none"}`.
2356
+ * `now_unix`: seconds since epoch.
2357
+ * `config_json`: JSON of [`PinConfig`], e.g. `{"soft_half_life_days":90,"soft_max_boost":1.5,"hard_boost":1.5}`.
2358
+ *
2359
+ * Returns the multiplicative boost factor (1.0 for `none`).
2360
+ * @param {string} tier_json
2361
+ * @param {bigint} now_unix
2362
+ * @param {string} config_json
2363
+ * @returns {number}
2364
+ */
2365
+ export function pinBoost(tier_json, now_unix, config_json) {
2366
+ const ptr0 = passStringToWasm0(tier_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2367
+ const len0 = WASM_VECTOR_LEN;
2368
+ const ptr1 = passStringToWasm0(config_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2369
+ const len1 = WASM_VECTOR_LEN;
2370
+ const ret = wasm.pinBoost(ptr0, len0, now_unix, ptr1, len1);
2371
+ if (ret[2]) {
2372
+ throw takeFromExternrefTable0(ret[1]);
2373
+ }
2374
+ return ret[0];
2375
+ }
2376
+
2377
+ /**
2378
+ * Prepare a fact for on-chain storage.
2379
+ *
2380
+ * Pure computation: encrypt, generate indices, encode protobuf.
2381
+ * Does NOT submit -- the host handles I/O.
2382
+ *
2383
+ * `encryption_key_hex`: 64-char hex string (32 bytes).
2384
+ * `dedup_key_hex`: 64-char hex string (32 bytes).
2385
+ * `lsh_hasher`: A `WasmLshHasher` instance.
2386
+ * `embedding`: Float32Array of the pre-computed embedding vector.
2387
+ * `importance`: Importance score on 1-10 scale (normalized to 0.0-1.0).
2388
+ *
2389
+ * Returns a JSON string with `PreparedFact` fields.
2390
+ * @param {string} text
2391
+ * @param {string} encryption_key_hex
2392
+ * @param {string} dedup_key_hex
2393
+ * @param {WasmLshHasher} lsh_hasher
2394
+ * @param {Float32Array} embedding
2395
+ * @param {number} importance
2396
+ * @param {string} source
2397
+ * @param {string} owner
2398
+ * @param {string} agent_id
2399
+ * @returns {any}
2400
+ */
2401
+ export function prepareFact(text, encryption_key_hex, dedup_key_hex, lsh_hasher, embedding, importance, source, owner, agent_id) {
2402
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2403
+ const len0 = WASM_VECTOR_LEN;
2404
+ const ptr1 = passStringToWasm0(encryption_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2405
+ const len1 = WASM_VECTOR_LEN;
2406
+ const ptr2 = passStringToWasm0(dedup_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2407
+ const len2 = WASM_VECTOR_LEN;
2408
+ _assertClass(lsh_hasher, WasmLshHasher);
2409
+ const ptr3 = passArrayF32ToWasm0(embedding, wasm.__wbindgen_malloc);
2410
+ const len3 = WASM_VECTOR_LEN;
2411
+ const ptr4 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2412
+ const len4 = WASM_VECTOR_LEN;
2413
+ const ptr5 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2414
+ const len5 = WASM_VECTOR_LEN;
2415
+ const ptr6 = passStringToWasm0(agent_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2416
+ const len6 = WASM_VECTOR_LEN;
2417
+ const ret = wasm.prepareFact(ptr0, len0, ptr1, len1, ptr2, len2, lsh_hasher.__wbg_ptr, ptr3, len3, importance, ptr4, len4, ptr5, len5, ptr6, len6);
2418
+ if (ret[2]) {
2419
+ throw takeFromExternrefTable0(ret[1]);
2420
+ }
2421
+ return takeFromExternrefTable0(ret[0]);
2422
+ }
2423
+
2424
+ /**
2425
+ * Prepare a fact with a pre-normalized decay score (already 0.0-1.0).
2426
+ *
2427
+ * Same as `prepareFact()` but takes a raw decay score.
2428
+ * @param {string} text
2429
+ * @param {string} encryption_key_hex
2430
+ * @param {string} dedup_key_hex
2431
+ * @param {WasmLshHasher} lsh_hasher
2432
+ * @param {Float32Array} embedding
2433
+ * @param {number} decay_score
2434
+ * @param {string} source
2435
+ * @param {string} owner
2436
+ * @param {string} agent_id
2437
+ * @returns {any}
2438
+ */
2439
+ export function prepareFactWithDecayScore(text, encryption_key_hex, dedup_key_hex, lsh_hasher, embedding, decay_score, source, owner, agent_id) {
2440
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2441
+ const len0 = WASM_VECTOR_LEN;
2442
+ const ptr1 = passStringToWasm0(encryption_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2443
+ const len1 = WASM_VECTOR_LEN;
2444
+ const ptr2 = passStringToWasm0(dedup_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2445
+ const len2 = WASM_VECTOR_LEN;
2446
+ _assertClass(lsh_hasher, WasmLshHasher);
2447
+ const ptr3 = passArrayF32ToWasm0(embedding, wasm.__wbindgen_malloc);
2448
+ const len3 = WASM_VECTOR_LEN;
2449
+ const ptr4 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2450
+ const len4 = WASM_VECTOR_LEN;
2451
+ const ptr5 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2452
+ const len5 = WASM_VECTOR_LEN;
2453
+ const ptr6 = passStringToWasm0(agent_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2454
+ const len6 = WASM_VECTOR_LEN;
2455
+ const ret = wasm.prepareFactWithDecayScore(ptr0, len0, ptr1, len1, ptr2, len2, lsh_hasher.__wbg_ptr, ptr3, len3, decay_score, ptr4, len4, ptr5, len5, ptr6, len6);
2456
+ if (ret[2]) {
2457
+ throw takeFromExternrefTable0(ret[1]);
2458
+ }
2459
+ return takeFromExternrefTable0(ret[0]);
2460
+ }
2461
+
2462
+ /**
2463
+ * Prepare a tombstone (soft-delete) protobuf.
2464
+ *
2465
+ * Returns the protobuf bytes as a Uint8Array.
2466
+ * @param {string} fact_id
2467
+ * @param {string} owner
2468
+ * @returns {Uint8Array}
2469
+ */
2470
+ export function prepareTombstone(fact_id, owner) {
2471
+ const ptr0 = passStringToWasm0(fact_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2472
+ const len0 = WASM_VECTOR_LEN;
2473
+ const ptr1 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2474
+ const len1 = WASM_VECTOR_LEN;
2475
+ const ret = wasm.prepareTombstone(ptr0, len0, ptr1, len1);
2476
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
2477
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2478
+ return v3;
2479
+ }
2480
+
2481
+ /**
2482
+ * Parse JSONL content. Returns JSON: `{"entries": [...], "warnings": [...]}`.
2483
+ * @param {string} content
2484
+ * @returns {string}
2485
+ */
2486
+ export function readFeedbackJsonl(content) {
2487
+ let deferred3_0;
2488
+ let deferred3_1;
2489
+ try {
2490
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2491
+ const len0 = WASM_VECTOR_LEN;
2492
+ const ret = wasm.readFeedbackJsonl(ptr0, len0);
2493
+ var ptr2 = ret[0];
2494
+ var len2 = ret[1];
2495
+ if (ret[3]) {
2496
+ ptr2 = 0; len2 = 0;
2497
+ throw takeFromExternrefTable0(ret[2]);
2498
+ }
2499
+ deferred3_0 = ptr2;
2500
+ deferred3_1 = len2;
2501
+ return getStringFromWasm0(ptr2, len2);
2502
+ } finally {
2503
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2504
+ }
2505
+ }
2506
+
2507
+ /**
2508
+ * Build the recall-context header string (current-date + temporal-reasoning nudge).
2509
+ *
2510
+ * `now_unix`: current time as Unix seconds.
2511
+ * Returns the header with a trailing newline, e.g.:
2512
+ * `"## Relevant memories from TotalReclaw\nThe current date is 2024-01-15. ..."`
2513
+ * @param {bigint} now_unix
2514
+ * @returns {string}
2515
+ */
2516
+ export function recallContextHeader(now_unix) {
2517
+ let deferred1_0;
2518
+ let deferred1_1;
2519
+ try {
2520
+ const ret = wasm.recallContextHeader(now_unix);
2521
+ deferred1_0 = ret[0];
2522
+ deferred1_1 = ret[1];
2523
+ return getStringFromWasm0(ret[0], ret[1]);
2524
+ } finally {
2525
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2526
+ }
2527
+ }
2528
+
2529
+ /**
2530
+ * Rerank candidates using BM25 + Cosine + RRF fusion.
2531
+ *
2532
+ * `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
2533
+ * Returns a JsValue (array of `RankedResult` objects).
2534
+ * @param {string} query
2535
+ * @param {Float32Array} query_embedding
2536
+ * @param {string} candidates_json
2537
+ * @param {number} top_k
2538
+ * @returns {any}
2539
+ */
2540
+ export function rerank(query, query_embedding, candidates_json, top_k) {
2541
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2542
+ const len0 = WASM_VECTOR_LEN;
2543
+ const ptr1 = passArrayF32ToWasm0(query_embedding, wasm.__wbindgen_malloc);
2544
+ const len1 = WASM_VECTOR_LEN;
2545
+ const ptr2 = passStringToWasm0(candidates_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2546
+ const len2 = WASM_VECTOR_LEN;
2547
+ const ret = wasm.rerank(ptr0, len0, ptr1, len1, ptr2, len2, top_k);
2548
+ if (ret[2]) {
2549
+ throw takeFromExternrefTable0(ret[1]);
2550
+ }
2551
+ return takeFromExternrefTable0(ret[0]);
2552
+ }
2553
+
2554
+ /**
2555
+ * Rerank candidates with a config flag (Retrieval v2 Tier 1).
2556
+ *
2557
+ * When `apply_source_weights` is `true`, each candidate's final score is
2558
+ * multiplied by the provenance weight from its `source` field (legacy
2559
+ * candidates without `source` use the v0 fallback weight).
2560
+ *
2561
+ * `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
2562
+ * Returns a JsValue (array of `RankedResult` objects including `source_weight`).
2563
+ * @param {string} query
2564
+ * @param {Float32Array} query_embedding
2565
+ * @param {string} candidates_json
2566
+ * @param {number} top_k
2567
+ * @param {boolean} apply_source_weights
2568
+ * @returns {any}
2569
+ */
2570
+ export function rerankWithConfig(query, query_embedding, candidates_json, top_k, apply_source_weights) {
2571
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2572
+ const len0 = WASM_VECTOR_LEN;
2573
+ const ptr1 = passArrayF32ToWasm0(query_embedding, wasm.__wbindgen_malloc);
2574
+ const len1 = WASM_VECTOR_LEN;
2575
+ const ptr2 = passStringToWasm0(candidates_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2576
+ const len2 = WASM_VECTOR_LEN;
2577
+ const ret = wasm.rerankWithConfig(ptr0, len0, ptr1, len1, ptr2, len2, top_k, apply_source_weights);
2578
+ if (ret[2]) {
2579
+ throw takeFromExternrefTable0(ret[1]);
2580
+ }
2581
+ return takeFromExternrefTable0(ret[0]);
2582
+ }
2583
+
2584
+ /**
2585
+ * Run the resolution formula on two contradicting claims; returns ResolutionOutcome JSON.
2586
+ * @param {string} claim_a_json
2587
+ * @param {string} claim_a_id
2588
+ * @param {string} claim_b_json
2589
+ * @param {string} claim_b_id
2590
+ * @param {bigint} now_unix_seconds
2591
+ * @param {string} weights_json
2592
+ * @returns {string}
2593
+ */
2594
+ export function resolvePair(claim_a_json, claim_a_id, claim_b_json, claim_b_id, now_unix_seconds, weights_json) {
2595
+ let deferred7_0;
2596
+ let deferred7_1;
2597
+ try {
2598
+ const ptr0 = passStringToWasm0(claim_a_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2599
+ const len0 = WASM_VECTOR_LEN;
2600
+ const ptr1 = passStringToWasm0(claim_a_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2601
+ const len1 = WASM_VECTOR_LEN;
2602
+ const ptr2 = passStringToWasm0(claim_b_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2603
+ const len2 = WASM_VECTOR_LEN;
2604
+ const ptr3 = passStringToWasm0(claim_b_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2605
+ const len3 = WASM_VECTOR_LEN;
2606
+ const ptr4 = passStringToWasm0(weights_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2607
+ const len4 = WASM_VECTOR_LEN;
2608
+ const ret = wasm.resolvePair(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, now_unix_seconds, ptr4, len4);
2609
+ var ptr6 = ret[0];
2610
+ var len6 = ret[1];
2611
+ if (ret[3]) {
2612
+ ptr6 = 0; len6 = 0;
2613
+ throw takeFromExternrefTable0(ret[2]);
2614
+ }
2615
+ deferred7_0 = ptr6;
2616
+ deferred7_1 = len6;
2617
+ return getStringFromWasm0(ptr6, len6);
2618
+ } finally {
2619
+ wasm.__wbindgen_free(deferred7_0, deferred7_1, 1);
2620
+ }
2621
+ }
2622
+
2623
+ /**
2624
+ * Orchestrate contradiction detection + resolution for a new claim against candidates.
2625
+ *
2626
+ * Returns a JSON array of `ResolutionAction`.
2627
+ * @param {string} new_claim_json
2628
+ * @param {string} new_claim_id
2629
+ * @param {string} new_embedding_json
2630
+ * @param {string} candidates_json
2631
+ * @param {string} weights_json
2632
+ * @param {number} threshold_lower
2633
+ * @param {number} threshold_upper
2634
+ * @param {bigint} now_unix
2635
+ * @param {number} tie_tolerance
2636
+ * @returns {string}
2637
+ */
2638
+ export function resolveWithCandidates(new_claim_json, new_claim_id, new_embedding_json, candidates_json, weights_json, threshold_lower, threshold_upper, now_unix, tie_tolerance) {
2639
+ let deferred7_0;
2640
+ let deferred7_1;
2641
+ try {
2642
+ const ptr0 = passStringToWasm0(new_claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2643
+ const len0 = WASM_VECTOR_LEN;
2644
+ const ptr1 = passStringToWasm0(new_claim_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2645
+ const len1 = WASM_VECTOR_LEN;
2646
+ const ptr2 = passStringToWasm0(new_embedding_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2647
+ const len2 = WASM_VECTOR_LEN;
2648
+ const ptr3 = passStringToWasm0(candidates_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2649
+ const len3 = WASM_VECTOR_LEN;
2650
+ const ptr4 = passStringToWasm0(weights_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2651
+ const len4 = WASM_VECTOR_LEN;
2652
+ const ret = wasm.resolveWithCandidates(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, threshold_lower, threshold_upper, now_unix, tie_tolerance);
2653
+ var ptr6 = ret[0];
2654
+ var len6 = ret[1];
2655
+ if (ret[3]) {
2656
+ ptr6 = 0; len6 = 0;
2657
+ throw takeFromExternrefTable0(ret[2]);
2658
+ }
2659
+ deferred7_0 = ptr6;
2660
+ deferred7_1 = len6;
2661
+ return getStringFromWasm0(ptr6, len6);
2662
+ } finally {
2663
+ wasm.__wbindgen_free(deferred7_0, deferred7_1, 1);
2664
+ }
2665
+ }
2666
+
2667
+ /**
2668
+ * Apply pin-status and tie-zone checks to a resolution outcome.
2669
+ * Returns a JSON-serialized `ResolutionAction`.
2670
+ * @param {string} existing_claim_json
2671
+ * @param {string} new_claim_id
2672
+ * @param {string} existing_claim_id
2673
+ * @param {string} resolution_winner
2674
+ * @param {number} score_gap
2675
+ * @param {number} similarity
2676
+ * @param {number} tie_tolerance
2677
+ * @returns {string}
2678
+ */
2679
+ export function respectPinInResolution(existing_claim_json, new_claim_id, existing_claim_id, resolution_winner, score_gap, similarity, tie_tolerance) {
2680
+ let deferred6_0;
2681
+ let deferred6_1;
2682
+ try {
2683
+ const ptr0 = passStringToWasm0(existing_claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2684
+ const len0 = WASM_VECTOR_LEN;
2685
+ const ptr1 = passStringToWasm0(new_claim_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2686
+ const len1 = WASM_VECTOR_LEN;
2687
+ const ptr2 = passStringToWasm0(existing_claim_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2688
+ const len2 = WASM_VECTOR_LEN;
2689
+ const ptr3 = passStringToWasm0(resolution_winner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2690
+ const len3 = WASM_VECTOR_LEN;
2691
+ const ret = wasm.respectPinInResolution(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, score_gap, similarity, tie_tolerance);
2692
+ var ptr5 = ret[0];
2693
+ var len5 = ret[1];
2694
+ if (ret[3]) {
2695
+ ptr5 = 0; len5 = 0;
2696
+ throw takeFromExternrefTable0(ret[2]);
2697
+ }
2698
+ deferred6_0 = ptr5;
2699
+ deferred6_1 = len5;
2700
+ return getStringFromWasm0(ptr5, len5);
2701
+ } finally {
2702
+ wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
2703
+ }
2704
+ }
2705
+
2706
+ /**
2707
+ * Keep only the most recent `max_lines` non-empty feedback log lines. Non-falliable.
2708
+ * @param {string} content
2709
+ * @param {bigint} max_lines
2710
+ * @returns {string}
2711
+ */
2712
+ export function rotateFeedbackLog(content, max_lines) {
2713
+ let deferred2_0;
2714
+ let deferred2_1;
2715
+ try {
2716
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2717
+ const len0 = WASM_VECTOR_LEN;
2718
+ const ret = wasm.rotateFeedbackLog(ptr0, len0, max_lines);
2719
+ deferred2_0 = ret[0];
2720
+ deferred2_1 = ret[1];
2721
+ return getStringFromWasm0(ret[0], ret[1]);
2722
+ } finally {
2723
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
2724
+ }
2725
+ }
2726
+
2727
+ /**
2728
+ * Centroid-walk session segmentation over time-ordered turns.
2729
+ *
2730
+ * Mirrors `session_segmentation.py:segment_sessions` byte-for-byte.
2731
+ *
2732
+ * # Inputs (JSON strings, per this module's convention)
2733
+ * - `timestamps_json`: JSON array of Unix seconds or `null`, e.g.
2734
+ * `"[0.0, null, 5000.0]"`. `null` = 0-gap to the previous turn.
2735
+ * - `embeddings_json`: JSON array of L2-normalised vectors, e.g.
2736
+ * `"[[1.0,0.0],[0.9,0.1]]"`.
2737
+ * - `gap_seconds`: min time gap (strict `>`) forcing a new session (e.g. 1800).
2738
+ * - `sim_threshold`: cosine threshold (strict `<` splits; e.g. 0.55).
2739
+ *
2740
+ * # Returns
2741
+ * A `JsValue` — array of sessions, each an array of turn indices
2742
+ * (`number[][]`), contiguous and ascending. Bad JSON → `JsError`.
2743
+ * @param {string} timestamps_json
2744
+ * @param {string} embeddings_json
2745
+ * @param {number} gap_seconds
2746
+ * @param {number} sim_threshold
2747
+ * @returns {any}
2748
+ */
2749
+ export function segmentSessions(timestamps_json, embeddings_json, gap_seconds, sim_threshold) {
2750
+ const ptr0 = passStringToWasm0(timestamps_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2751
+ const len0 = WASM_VECTOR_LEN;
2752
+ const ptr1 = passStringToWasm0(embeddings_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2753
+ const len1 = WASM_VECTOR_LEN;
2754
+ const ret = wasm.segmentSessions(ptr0, len0, ptr1, len1, gap_seconds, sim_threshold);
2755
+ if (ret[2]) {
2756
+ throw takeFromExternrefTable0(ret[1]);
2757
+ }
2758
+ return takeFromExternrefTable0(ret[0]);
2759
+ }
2760
+
2761
+ /**
2762
+ * Serialize a WeightsFile JSON to pretty-printed JSON (2-space indent).
2763
+ * @param {string} file_json
2764
+ * @returns {string}
2765
+ */
2766
+ export function serializeWeightsFile(file_json) {
2767
+ let deferred3_0;
2768
+ let deferred3_1;
2769
+ try {
2770
+ const ptr0 = passStringToWasm0(file_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2771
+ const len0 = WASM_VECTOR_LEN;
2772
+ const ret = wasm.serializeWeightsFile(ptr0, len0);
2773
+ var ptr2 = ret[0];
2774
+ var len2 = ret[1];
2775
+ if (ret[3]) {
2776
+ ptr2 = 0; len2 = 0;
2777
+ throw takeFromExternrefTable0(ret[2]);
2778
+ }
2779
+ deferred3_0 = ptr2;
2780
+ deferred3_1 = len2;
2781
+ return getStringFromWasm0(ptr2, len2);
2782
+ } finally {
2783
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2784
+ }
2785
+ }
2786
+
2787
+ /**
2788
+ * WASM binding: determine if a new fact should supersede an existing one.
2789
+ * @param {number} new_importance
2790
+ * @param {number} existing_importance
2791
+ * @returns {boolean}
2792
+ */
2793
+ export function shouldSupersede(new_importance, existing_importance) {
2794
+ const ret = wasm.shouldSupersede(new_importance, existing_importance);
2795
+ return ret !== 0;
2796
+ }
2797
+
2798
+ /**
2799
+ * Sign a UserOp hash with an ECDSA private key (EIP-191 prefixed).
2800
+ *
2801
+ * `hash_hex`: 64-char hex string (32-byte UserOp hash).
2802
+ * `private_key_hex`: 64-char hex string (32-byte private key).
2803
+ * Returns 65-byte signature as hex string (r + s + v).
2804
+ * @param {string} hash_hex
2805
+ * @param {string} private_key_hex
2806
+ * @returns {string}
2807
+ */
2808
+ export function signUserOp(hash_hex, private_key_hex) {
2809
+ let deferred4_0;
2810
+ let deferred4_1;
2811
+ try {
2812
+ const ptr0 = passStringToWasm0(hash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2813
+ const len0 = WASM_VECTOR_LEN;
2814
+ const ptr1 = passStringToWasm0(private_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2815
+ const len1 = WASM_VECTOR_LEN;
2816
+ const ret = wasm.signUserOp(ptr0, len0, ptr1, len1);
2817
+ var ptr3 = ret[0];
2818
+ var len3 = ret[1];
2819
+ if (ret[3]) {
2820
+ ptr3 = 0; len3 = 0;
2821
+ throw takeFromExternrefTable0(ret[2]);
2822
+ }
2823
+ deferred4_0 = ptr3;
2824
+ deferred4_1 = len3;
2825
+ return getStringFromWasm0(ptr3, len3);
2826
+ } finally {
2827
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
2828
+ }
2829
+ }
2830
+
2831
+ /**
2832
+ * Return the source weight multiplier for a given source string.
2833
+ *
2834
+ * Accepted values: "user" | "user-inferred" | "assistant" | "external" | "derived".
2835
+ *
2836
+ * Unknown input is routed through `MemorySource::from_str_lossy` which
2837
+ * falls back to `user-inferred` (v2-lenient weight 0.95). Callers who need
2838
+ * the "no source field at all" fallback (weight 0.85) should call
2839
+ * `legacyClaimFallbackWeight()` instead.
2840
+ * @param {string} source
2841
+ * @returns {number}
2842
+ */
2843
+ export function sourceWeight(source) {
2844
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2845
+ const len0 = WASM_VECTOR_LEN;
2846
+ const ret = wasm.sourceWeight(ptr0, len0);
2847
+ return ret;
2848
+ }
2849
+
2850
+ /**
2851
+ * Validate a Memory Taxonomy v1 claim (JSON in, JSON out — canonicalised).
2852
+ *
2853
+ * Returns the canonical JSON encoding on success. Throws on any schema
2854
+ * violation (wrong type token, missing required field, wrong schema_version).
2855
+ *
2856
+ * See `docs/specs/totalreclaw/memory-taxonomy-v1.md`.
2857
+ * @param {string} claim_json
2858
+ * @returns {string}
2859
+ */
2860
+ export function validateMemoryClaimV1(claim_json) {
2861
+ let deferred3_0;
2862
+ let deferred3_1;
2863
+ try {
2864
+ const ptr0 = passStringToWasm0(claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2865
+ const len0 = WASM_VECTOR_LEN;
2866
+ const ret = wasm.validateMemoryClaimV1(ptr0, len0);
2867
+ var ptr2 = ret[0];
2868
+ var len2 = ret[1];
2869
+ if (ret[3]) {
2870
+ ptr2 = 0; len2 = 0;
2871
+ throw takeFromExternrefTable0(ret[2]);
2872
+ }
2873
+ deferred3_0 = ptr2;
2874
+ deferred3_1 = len2;
2875
+ return getStringFromWasm0(ptr2, len2);
2876
+ } finally {
2877
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
2878
+ }
2879
+ }
2880
+
2881
+ /**
2882
+ * Default polling interval (ms) — exposed so host adapters share the same
2883
+ * default without re-declaring the constant.
2884
+ * @returns {number}
2885
+ */
2886
+ export function wasmConfirmIndexedDefaultPollMs() {
2887
+ const ret = wasm.wasmConfirmIndexedDefaultPollMs();
2888
+ return ret >>> 0;
2889
+ }
2890
+
2891
+ /**
2892
+ * Default total timeout (ms) — exposed so host adapters share the same default.
2893
+ * @returns {number}
2894
+ */
2895
+ export function wasmConfirmIndexedDefaultTimeoutMs() {
2896
+ const ret = wasm.wasmConfirmIndexedDefaultTimeoutMs();
2897
+ return ret >>> 0;
2898
+ }
2899
+
2900
+ /**
2901
+ * Parse a subgraph response JSON and return whether the fact is indexed +
2902
+ * active. Returns `true` when the read-after-write loop can stop.
2903
+ * @param {string} response_json
2904
+ * @returns {boolean}
2905
+ */
2906
+ export function wasmConfirmIndexedParse(response_json) {
2907
+ const ptr0 = passStringToWasm0(response_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2908
+ const len0 = WASM_VECTOR_LEN;
2909
+ const ret = wasm.wasmConfirmIndexedParse(ptr0, len0);
2910
+ if (ret[2]) {
2911
+ throw takeFromExternrefTable0(ret[1]);
2912
+ }
2913
+ return ret[0] !== 0;
2914
+ }
2915
+
2916
+ /**
2917
+ * GraphQL query string used to confirm a fact id has been indexed.
2918
+ * Pair with `wasmConfirmIndexedParse` in a host-side polling loop.
2919
+ * @returns {string}
2920
+ */
2921
+ export function wasmConfirmIndexedQuery() {
2922
+ let deferred1_0;
2923
+ let deferred1_1;
2924
+ try {
2925
+ const ret = wasm.wasmConfirmIndexedQuery();
2926
+ deferred1_0 = ret[0];
2927
+ deferred1_1 = ret[1];
2928
+ return getStringFromWasm0(ret[0], ret[1]);
2929
+ } finally {
2930
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2931
+ }
2932
+ }
2933
+
2934
+ function __wbg_get_imports() {
2935
+ const import0 = {
2936
+ __proto__: null,
2937
+ __wbg_Error_2e59b1b37a9a34c3: function(arg0, arg1) {
2938
+ const ret = Error(getStringFromWasm0(arg0, arg1));
2939
+ return ret;
2940
+ },
2941
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
2942
+ const ret = String(arg1);
2943
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2944
+ const len1 = WASM_VECTOR_LEN;
2945
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2946
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2947
+ },
2948
+ __wbg___wbindgen_is_function_49868bde5eb1e745: function(arg0) {
2949
+ const ret = typeof(arg0) === 'function';
2950
+ return ret;
2951
+ },
2952
+ __wbg___wbindgen_is_object_40c5a80572e8f9d3: function(arg0) {
2953
+ const val = arg0;
2954
+ const ret = typeof(val) === 'object' && val !== null;
2955
+ return ret;
2956
+ },
2957
+ __wbg___wbindgen_is_string_b29b5c5a8065ba1a: function(arg0) {
2958
+ const ret = typeof(arg0) === 'string';
2959
+ return ret;
2960
+ },
2961
+ __wbg___wbindgen_is_undefined_c0cca72b82b86f4d: function(arg0) {
2962
+ const ret = arg0 === undefined;
2963
+ return ret;
2964
+ },
2965
+ __wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
2966
+ throw new Error(getStringFromWasm0(arg0, arg1));
2967
+ },
2968
+ __wbg_call_d578befcc3145dee: function() { return handleError(function (arg0, arg1, arg2) {
2969
+ const ret = arg0.call(arg1, arg2);
2970
+ return ret;
2971
+ }, arguments); },
2972
+ __wbg_crypto_38df2bab126b63dc: function(arg0) {
2973
+ const ret = arg0.crypto;
2974
+ return ret;
2975
+ },
2976
+ __wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
2977
+ arg0.getRandomValues(arg1);
2978
+ }, arguments); },
2979
+ __wbg_getRandomValues_d49329ff89a07af1: function() { return handleError(function (arg0, arg1) {
2980
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
2981
+ }, arguments); },
2982
+ __wbg_getTime_f6ac312467f7cf09: function(arg0) {
2983
+ const ret = arg0.getTime();
2984
+ return ret;
2985
+ },
2986
+ __wbg_length_0c32cb8543c8e4c8: function(arg0) {
2987
+ const ret = arg0.length;
2988
+ return ret;
2989
+ },
2990
+ __wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
2991
+ const ret = arg0.msCrypto;
2992
+ return ret;
2993
+ },
2994
+ __wbg_new_0_bfa2ef4bc447daa2: function() {
2995
+ const ret = new Date();
2996
+ return ret;
2997
+ },
2998
+ __wbg_new_4f9fafbb3909af72: function() {
2999
+ const ret = new Object();
3000
+ return ret;
3001
+ },
3002
+ __wbg_new_f3c9df4f38f3f798: function() {
3003
+ const ret = new Array();
3004
+ return ret;
3005
+ },
3006
+ __wbg_new_with_length_9cedd08484b73942: function(arg0) {
3007
+ const ret = new Uint8Array(arg0 >>> 0);
3008
+ return ret;
3009
+ },
3010
+ __wbg_node_84ea875411254db1: function(arg0) {
3011
+ const ret = arg0.node;
3012
+ return ret;
3013
+ },
3014
+ __wbg_now_6798946be0e6fe2b: function() { return handleError(function () {
3015
+ const ret = Date.now();
3016
+ return ret;
3017
+ }, arguments); },
3018
+ __wbg_process_44c7a14e11e9f69e: function(arg0) {
3019
+ const ret = arg0.process;
3020
+ return ret;
3021
+ },
3022
+ __wbg_prototypesetcall_3e05eb9545565046: function(arg0, arg1, arg2) {
3023
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
3024
+ },
3025
+ __wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
3026
+ arg0.randomFillSync(arg1);
3027
+ }, arguments); },
3028
+ __wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
3029
+ const ret = module.require;
3030
+ return ret;
3031
+ }, arguments); },
3032
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
3033
+ arg0[arg1] = arg2;
3034
+ },
3035
+ __wbg_set_6c60b2e8ad0e9383: function(arg0, arg1, arg2) {
3036
+ arg0[arg1 >>> 0] = arg2;
3037
+ },
3038
+ __wbg_set_8ee2d34facb8466e: function() { return handleError(function (arg0, arg1, arg2) {
3039
+ const ret = Reflect.set(arg0, arg1, arg2);
3040
+ return ret;
3041
+ }, arguments); },
3042
+ __wbg_static_accessor_GLOBAL_THIS_a1248013d790bf5f: function() {
3043
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
3044
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
3045
+ },
3046
+ __wbg_static_accessor_GLOBAL_f2e0f995a21329ff: function() {
3047
+ const ret = typeof global === 'undefined' ? null : global;
3048
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
3049
+ },
3050
+ __wbg_static_accessor_SELF_24f78b6d23f286ea: function() {
3051
+ const ret = typeof self === 'undefined' ? null : self;
3052
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
3053
+ },
3054
+ __wbg_static_accessor_WINDOW_59fd959c540fe405: function() {
3055
+ const ret = typeof window === 'undefined' ? null : window;
3056
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
3057
+ },
3058
+ __wbg_subarray_0f98d3fb634508ad: function(arg0, arg1, arg2) {
3059
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
3060
+ return ret;
3061
+ },
3062
+ __wbg_versions_276b2795b1c6a219: function(arg0) {
3063
+ const ret = arg0.versions;
3064
+ return ret;
3065
+ },
3066
+ __wbindgen_cast_0000000000000001: function(arg0) {
3067
+ // Cast intrinsic for `F64 -> Externref`.
3068
+ const ret = arg0;
3069
+ return ret;
3070
+ },
3071
+ __wbindgen_cast_0000000000000002: function(arg0) {
3072
+ // Cast intrinsic for `I64 -> Externref`.
3073
+ const ret = arg0;
3074
+ return ret;
3075
+ },
3076
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
3077
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
3078
+ const ret = getArrayU8FromWasm0(arg0, arg1);
3079
+ return ret;
3080
+ },
3081
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
3082
+ // Cast intrinsic for `Ref(String) -> Externref`.
3083
+ const ret = getStringFromWasm0(arg0, arg1);
3084
+ return ret;
3085
+ },
3086
+ __wbindgen_cast_0000000000000005: function(arg0) {
3087
+ // Cast intrinsic for `U64 -> Externref`.
3088
+ const ret = BigInt.asUintN(64, arg0);
3089
+ return ret;
3090
+ },
3091
+ __wbindgen_init_externref_table: function() {
3092
+ const table = wasm.__wbindgen_externrefs;
3093
+ const offset = table.grow(4);
3094
+ table.set(0, undefined);
3095
+ table.set(offset + 0, undefined);
3096
+ table.set(offset + 1, null);
3097
+ table.set(offset + 2, true);
3098
+ table.set(offset + 3, false);
3099
+ },
3100
+ };
3101
+ return {
3102
+ __proto__: null,
3103
+ "./totalreclaw_core_bg.js": import0,
3104
+ };
3105
+ }
3106
+
3107
+ const WasmLshHasherFinalization = (typeof FinalizationRegistry === 'undefined')
3108
+ ? { register: () => {}, unregister: () => {} }
3109
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmlshhasher_free(ptr >>> 0, 1));
3110
+
3111
+ function addToExternrefTable0(obj) {
3112
+ const idx = wasm.__externref_table_alloc();
3113
+ wasm.__wbindgen_externrefs.set(idx, obj);
3114
+ return idx;
3115
+ }
3116
+
3117
+ function _assertClass(instance, klass) {
3118
+ if (!(instance instanceof klass)) {
3119
+ throw new Error(`expected instance of ${klass.name}`);
3120
+ }
3121
+ }
3122
+
3123
+ function getArrayF32FromWasm0(ptr, len) {
3124
+ ptr = ptr >>> 0;
3125
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
3126
+ }
3127
+
3128
+ function getArrayU8FromWasm0(ptr, len) {
3129
+ ptr = ptr >>> 0;
3130
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
3131
+ }
3132
+
3133
+ let cachedDataViewMemory0 = null;
3134
+ function getDataViewMemory0() {
3135
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
3136
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
3137
+ }
3138
+ return cachedDataViewMemory0;
3139
+ }
3140
+
3141
+ let cachedFloat32ArrayMemory0 = null;
3142
+ function getFloat32ArrayMemory0() {
3143
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
3144
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
3145
+ }
3146
+ return cachedFloat32ArrayMemory0;
3147
+ }
3148
+
3149
+ let cachedFloat64ArrayMemory0 = null;
3150
+ function getFloat64ArrayMemory0() {
3151
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
3152
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
3153
+ }
3154
+ return cachedFloat64ArrayMemory0;
3155
+ }
3156
+
3157
+ function getStringFromWasm0(ptr, len) {
3158
+ ptr = ptr >>> 0;
3159
+ return decodeText(ptr, len);
3160
+ }
3161
+
3162
+ let cachedUint8ArrayMemory0 = null;
3163
+ function getUint8ArrayMemory0() {
3164
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
3165
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
3166
+ }
3167
+ return cachedUint8ArrayMemory0;
3168
+ }
3169
+
3170
+ function handleError(f, args) {
3171
+ try {
3172
+ return f.apply(this, args);
3173
+ } catch (e) {
3174
+ const idx = addToExternrefTable0(e);
3175
+ wasm.__wbindgen_exn_store(idx);
3176
+ }
3177
+ }
3178
+
3179
+ function isLikeNone(x) {
3180
+ return x === undefined || x === null;
3181
+ }
3182
+
3183
+ function passArray8ToWasm0(arg, malloc) {
3184
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
3185
+ getUint8ArrayMemory0().set(arg, ptr / 1);
3186
+ WASM_VECTOR_LEN = arg.length;
3187
+ return ptr;
3188
+ }
3189
+
3190
+ function passArrayF32ToWasm0(arg, malloc) {
3191
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
3192
+ getFloat32ArrayMemory0().set(arg, ptr / 4);
3193
+ WASM_VECTOR_LEN = arg.length;
3194
+ return ptr;
3195
+ }
3196
+
3197
+ function passArrayF64ToWasm0(arg, malloc) {
3198
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
3199
+ getFloat64ArrayMemory0().set(arg, ptr / 8);
3200
+ WASM_VECTOR_LEN = arg.length;
3201
+ return ptr;
3202
+ }
3203
+
3204
+ function passStringToWasm0(arg, malloc, realloc) {
3205
+ if (realloc === undefined) {
3206
+ const buf = cachedTextEncoder.encode(arg);
3207
+ const ptr = malloc(buf.length, 1) >>> 0;
3208
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
3209
+ WASM_VECTOR_LEN = buf.length;
3210
+ return ptr;
3211
+ }
3212
+
3213
+ let len = arg.length;
3214
+ let ptr = malloc(len, 1) >>> 0;
3215
+
3216
+ const mem = getUint8ArrayMemory0();
3217
+
3218
+ let offset = 0;
3219
+
3220
+ for (; offset < len; offset++) {
3221
+ const code = arg.charCodeAt(offset);
3222
+ if (code > 0x7F) break;
3223
+ mem[ptr + offset] = code;
3224
+ }
3225
+ if (offset !== len) {
3226
+ if (offset !== 0) {
3227
+ arg = arg.slice(offset);
3228
+ }
3229
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
3230
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
3231
+ const ret = cachedTextEncoder.encodeInto(arg, view);
3232
+
3233
+ offset += ret.written;
3234
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
3235
+ }
3236
+
3237
+ WASM_VECTOR_LEN = offset;
3238
+ return ptr;
3239
+ }
3240
+
3241
+ function takeFromExternrefTable0(idx) {
3242
+ const value = wasm.__wbindgen_externrefs.get(idx);
3243
+ wasm.__externref_table_dealloc(idx);
3244
+ return value;
3245
+ }
3246
+
3247
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
3248
+ cachedTextDecoder.decode();
3249
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
3250
+ let numBytesDecoded = 0;
3251
+ function decodeText(ptr, len) {
3252
+ numBytesDecoded += len;
3253
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
3254
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
3255
+ cachedTextDecoder.decode();
3256
+ numBytesDecoded = len;
3257
+ }
3258
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
3259
+ }
3260
+
3261
+ const cachedTextEncoder = new TextEncoder();
3262
+
3263
+ if (!('encodeInto' in cachedTextEncoder)) {
3264
+ cachedTextEncoder.encodeInto = function (arg, view) {
3265
+ const buf = cachedTextEncoder.encode(arg);
3266
+ view.set(buf);
3267
+ return {
3268
+ read: arg.length,
3269
+ written: buf.length
3270
+ };
3271
+ };
3272
+ }
3273
+
3274
+ let WASM_VECTOR_LEN = 0;
3275
+
3276
+ let wasmModule, wasm;
3277
+ function __wbg_finalize_init(instance, module) {
3278
+ wasm = instance.exports;
3279
+ wasmModule = module;
3280
+ cachedDataViewMemory0 = null;
3281
+ cachedFloat32ArrayMemory0 = null;
3282
+ cachedFloat64ArrayMemory0 = null;
3283
+ cachedUint8ArrayMemory0 = null;
3284
+ wasm.__wbindgen_start();
3285
+ return wasm;
3286
+ }
3287
+
3288
+ async function __wbg_load(module, imports) {
3289
+ if (typeof Response === 'function' && module instanceof Response) {
3290
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
3291
+ try {
3292
+ return await WebAssembly.instantiateStreaming(module, imports);
3293
+ } catch (e) {
3294
+ const validResponse = module.ok && expectedResponseType(module.type);
3295
+
3296
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
3297
+ 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);
3298
+
3299
+ } else { throw e; }
3300
+ }
3301
+ }
3302
+
3303
+ const bytes = await module.arrayBuffer();
3304
+ return await WebAssembly.instantiate(bytes, imports);
3305
+ } else {
3306
+ const instance = await WebAssembly.instantiate(module, imports);
3307
+
3308
+ if (instance instanceof WebAssembly.Instance) {
3309
+ return { instance, module };
3310
+ } else {
3311
+ return instance;
3312
+ }
3313
+ }
3314
+
3315
+ function expectedResponseType(type) {
3316
+ switch (type) {
3317
+ case 'basic': case 'cors': case 'default': return true;
3318
+ }
3319
+ return false;
3320
+ }
3321
+ }
3322
+
3323
+ function initSync(module) {
3324
+ if (wasm !== undefined) return wasm;
3325
+
3326
+
3327
+ if (module !== undefined) {
3328
+ if (Object.getPrototypeOf(module) === Object.prototype) {
3329
+ ({module} = module)
3330
+ } else {
3331
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
3332
+ }
3333
+ }
3334
+
3335
+ const imports = __wbg_get_imports();
3336
+ if (!(module instanceof WebAssembly.Module)) {
3337
+ module = new WebAssembly.Module(module);
3338
+ }
3339
+ const instance = new WebAssembly.Instance(module, imports);
3340
+ return __wbg_finalize_init(instance, module);
3341
+ }
3342
+
3343
+ async function __wbg_init(module_or_path) {
3344
+ if (wasm !== undefined) return wasm;
3345
+
3346
+
3347
+ if (module_or_path !== undefined) {
3348
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
3349
+ ({module_or_path} = module_or_path)
3350
+ } else {
3351
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
3352
+ }
3353
+ }
3354
+
3355
+ if (module_or_path === undefined) {
3356
+ module_or_path = new URL('totalreclaw_core_bg.wasm', import.meta.url);
3357
+ }
3358
+ const imports = __wbg_get_imports();
3359
+
3360
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
3361
+ module_or_path = fetch(module_or_path);
3362
+ }
3363
+
3364
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
3365
+
3366
+ return __wbg_finalize_init(instance, module);
3367
+ }
3368
+
3369
+ export { initSync, __wbg_init as default };