@totalreclaw/core 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/totalreclaw_core.d.ts +147 -3
- package/totalreclaw_core.js +494 -4
- package/totalreclaw_core_bg.wasm +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totalreclaw/core",
|
|
3
3
|
"description": "TotalReclaw core — E2EE crypto, reranker, wallet, UserOp, store/search pipelines. Single source of truth for all clients.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
package/totalreclaw_core.d.ts
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Contradiction candidate cap constant.
|
|
6
|
+
*/
|
|
7
|
+
export function CONTRADICTION_CANDIDATE_CAP(): number;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Decision log max lines constant.
|
|
11
|
+
*/
|
|
12
|
+
export function DECISION_LOG_MAX_LINES(): number;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Tie-zone score tolerance constant.
|
|
16
|
+
*/
|
|
17
|
+
export function TIE_ZONE_SCORE_TOLERANCE(): number;
|
|
18
|
+
|
|
4
19
|
/**
|
|
5
20
|
* Random Hyperplane LSH hasher (WASM wrapper).
|
|
6
21
|
*
|
|
@@ -47,6 +62,11 @@ export class WasmLshHasher {
|
|
|
47
62
|
readonly tables: number;
|
|
48
63
|
}
|
|
49
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Append one decision entry to existing JSONL content. Non-fallible.
|
|
67
|
+
*/
|
|
68
|
+
export function appendDecisionEntry(existing_content: string, entry_json: string): string;
|
|
69
|
+
|
|
50
70
|
/**
|
|
51
71
|
* Append one feedback entry to existing JSONL content.
|
|
52
72
|
*/
|
|
@@ -77,12 +97,25 @@ export function buildBatchCalldataFromPrepared(prepared_array_json: string): Uin
|
|
|
77
97
|
*/
|
|
78
98
|
export function buildDebriefPrompt(stored_facts_json: string): string;
|
|
79
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Build decision log entries from resolution actions.
|
|
102
|
+
*
|
|
103
|
+
* Returns a JSON array of `DecisionLogEntry`.
|
|
104
|
+
*/
|
|
105
|
+
export function buildDecisionLogEntries(actions_json: string, new_claim_json: string, existing_claims_json: string, mode: string, now_unix: bigint): string;
|
|
106
|
+
|
|
80
107
|
/**
|
|
81
108
|
* Build the LLM prompt for digest compilation.
|
|
82
109
|
* `claims_json`: JSON array of Claim (must be non-empty).
|
|
83
110
|
*/
|
|
84
111
|
export function buildDigestPrompt(claims_json: string): string;
|
|
85
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Build a FeedbackEntry JSON from a decision-log entry JSON + pin action.
|
|
115
|
+
* Returns the JSON string, or the literal string "null" on failure.
|
|
116
|
+
*/
|
|
117
|
+
export function buildFeedbackFromDecision(decision_json: string, action: string, now_unix: bigint): string;
|
|
118
|
+
|
|
86
119
|
/**
|
|
87
120
|
* Build the profiling prompt for a batch of conversation summaries.
|
|
88
121
|
*
|
|
@@ -137,6 +170,16 @@ export function canonicalizeClaim(claim_json: string): string;
|
|
|
137
170
|
*/
|
|
138
171
|
export function chunksToSummaries(chunks_json: string): any;
|
|
139
172
|
|
|
173
|
+
/**
|
|
174
|
+
* WASM binding for `cluster_facts`.
|
|
175
|
+
*
|
|
176
|
+
* `candidates_json`: JSON array of `ConsolidationCandidate` objects.
|
|
177
|
+
* `threshold`: Cosine similarity threshold for clustering.
|
|
178
|
+
*
|
|
179
|
+
* Returns JSON array of `{ representative: string, duplicates: string[] }`.
|
|
180
|
+
*/
|
|
181
|
+
export function clusterFacts(candidates_json: string, threshold: number): any;
|
|
182
|
+
|
|
140
183
|
/**
|
|
141
184
|
* Compute SHA-256(authKey) as a hex string.
|
|
142
185
|
*
|
|
@@ -280,9 +323,12 @@ export function encodeSingleCall(protobuf_payload: Uint8Array): Uint8Array;
|
|
|
280
323
|
/**
|
|
281
324
|
* Encode a tombstone protobuf for soft-deleting a fact.
|
|
282
325
|
*
|
|
326
|
+
* `version` is optional; missing/0 defaults to `DEFAULT_PROTOBUF_VERSION` (3).
|
|
327
|
+
* Pass `4` to emit a v1-taxonomy tombstone (outer protobuf version = 4).
|
|
328
|
+
*
|
|
283
329
|
* Returns the protobuf bytes as a Uint8Array.
|
|
284
330
|
*/
|
|
285
|
-
export function encodeTombstoneProtobuf(fact_id: string, owner: string): Uint8Array;
|
|
331
|
+
export function encodeTombstoneProtobuf(fact_id: string, owner: string, version?: number | null): Uint8Array;
|
|
286
332
|
|
|
287
333
|
/**
|
|
288
334
|
* Encrypt a UTF-8 plaintext with XChaCha20-Poly1305.
|
|
@@ -308,7 +354,37 @@ export function enrichExtractionPrompt(profile_json: string, base_prompt: string
|
|
|
308
354
|
export function feedbackToCounterexample(entry_json: string): string;
|
|
309
355
|
|
|
310
356
|
/**
|
|
311
|
-
*
|
|
357
|
+
* Filter resolution actions by mode ("active" passes through, "shadow"/"off" returns empty).
|
|
358
|
+
*
|
|
359
|
+
* Returns a JSON array of `ResolutionAction`.
|
|
360
|
+
*/
|
|
361
|
+
export function filterShadowMode(actions_json: string, mode: string): string;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* WASM binding for `find_best_near_duplicate`.
|
|
365
|
+
*
|
|
366
|
+
* `new_embedding_json`: JSON array of floats (embedding vector).
|
|
367
|
+
* `existing_json`: JSON array of `{ id: string, embedding: number[] }` objects.
|
|
368
|
+
* `threshold`: Cosine similarity threshold.
|
|
369
|
+
*
|
|
370
|
+
* Returns JSON `{ fact_id: string, similarity: number }` or null.
|
|
371
|
+
*/
|
|
372
|
+
export function findBestNearDuplicate(new_embedding_json: string, existing_json: string, threshold: number): any;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Find a decision-log entry matching a fact as winner or loser.
|
|
376
|
+
* Returns the JSON-serialized DecisionLogEntry, or the literal string "null".
|
|
377
|
+
*/
|
|
378
|
+
export function findDecisionForPin(fact_id: string, role: string, log_content: string): string;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Find the loser claim JSON from the decision log for a given fact ID.
|
|
382
|
+
* Returns the loser_claim_json string, or the literal string "null" if not found.
|
|
383
|
+
*/
|
|
384
|
+
export function findLoserClaimInDecisionLog(fact_id: string, log_content: string): string;
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* WASM binding for `find_near_duplicate` (deprecated — use `findBestNearDuplicate`).
|
|
312
388
|
*
|
|
313
389
|
* `new_embedding`: Float32Array of the new fact's embedding.
|
|
314
390
|
* `existing_json`: JSON array of `{ id: string, embedding: number[] }` objects.
|
|
@@ -449,6 +525,17 @@ export function hashUserOp(userop_json: string, entrypoint: string, chain_id: bi
|
|
|
449
525
|
*/
|
|
450
526
|
export function hexBlobToBase64(hex_blob: string): string | undefined;
|
|
451
527
|
|
|
528
|
+
/**
|
|
529
|
+
* Check whether a JSON-serialized claim has pinned status.
|
|
530
|
+
*/
|
|
531
|
+
export function isPinnedClaim(claim_json: string): boolean;
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Return the v1 legacy-claim fallback weight (applied to candidates that
|
|
535
|
+
* have no `source` field).
|
|
536
|
+
*/
|
|
537
|
+
export function legacyClaimFallbackWeight(): number;
|
|
538
|
+
|
|
452
539
|
/**
|
|
453
540
|
* Normalize an entity name (NFC, lowercase, trim, collapse whitespace).
|
|
454
541
|
*/
|
|
@@ -486,6 +573,16 @@ export function parseDebriefResponse(response: string): any;
|
|
|
486
573
|
*/
|
|
487
574
|
export function parseDigestResponse(raw: string): string;
|
|
488
575
|
|
|
576
|
+
/**
|
|
577
|
+
* Case-insensitive parse of a memory source string. Unknown input returns "user-inferred".
|
|
578
|
+
*/
|
|
579
|
+
export function parseMemorySource(s: string): string;
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Case-insensitive parse of a memory type string. Unknown input returns "claim".
|
|
583
|
+
*/
|
|
584
|
+
export function parseMemoryTypeV1(s: string): string;
|
|
585
|
+
|
|
489
586
|
/**
|
|
490
587
|
* Parse a batch profiling LLM response into a PartialProfile.
|
|
491
588
|
*
|
|
@@ -561,16 +658,41 @@ export function readFeedbackJsonl(content: string): string;
|
|
|
561
658
|
/**
|
|
562
659
|
* Rerank candidates using BM25 + Cosine + RRF fusion.
|
|
563
660
|
*
|
|
564
|
-
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp }` objects.
|
|
661
|
+
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
|
|
565
662
|
* Returns a JsValue (array of `RankedResult` objects).
|
|
566
663
|
*/
|
|
567
664
|
export function rerank(query: string, query_embedding: Float32Array, candidates_json: string, top_k: number): any;
|
|
568
665
|
|
|
666
|
+
/**
|
|
667
|
+
* Rerank candidates with a config flag (Retrieval v2 Tier 1).
|
|
668
|
+
*
|
|
669
|
+
* When `apply_source_weights` is `true`, each candidate's final score is
|
|
670
|
+
* multiplied by the provenance weight from its `source` field (legacy
|
|
671
|
+
* candidates without `source` use the v0 fallback weight).
|
|
672
|
+
*
|
|
673
|
+
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
|
|
674
|
+
* Returns a JsValue (array of `RankedResult` objects including `source_weight`).
|
|
675
|
+
*/
|
|
676
|
+
export function rerankWithConfig(query: string, query_embedding: Float32Array, candidates_json: string, top_k: number, apply_source_weights: boolean): any;
|
|
677
|
+
|
|
569
678
|
/**
|
|
570
679
|
* Run the resolution formula on two contradicting claims; returns ResolutionOutcome JSON.
|
|
571
680
|
*/
|
|
572
681
|
export function resolvePair(claim_a_json: string, claim_a_id: string, claim_b_json: string, claim_b_id: string, now_unix_seconds: bigint, weights_json: string): string;
|
|
573
682
|
|
|
683
|
+
/**
|
|
684
|
+
* Orchestrate contradiction detection + resolution for a new claim against candidates.
|
|
685
|
+
*
|
|
686
|
+
* Returns a JSON array of `ResolutionAction`.
|
|
687
|
+
*/
|
|
688
|
+
export function resolveWithCandidates(new_claim_json: string, new_claim_id: string, new_embedding_json: string, candidates_json: string, weights_json: string, threshold_lower: number, threshold_upper: number, now_unix: bigint, tie_tolerance: number): string;
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Apply pin-status and tie-zone checks to a resolution outcome.
|
|
692
|
+
* Returns a JSON-serialized `ResolutionAction`.
|
|
693
|
+
*/
|
|
694
|
+
export function respectPinInResolution(existing_claim_json: string, new_claim_id: string, existing_claim_id: string, resolution_winner: string, score_gap: number, similarity: number, tie_tolerance: number): string;
|
|
695
|
+
|
|
574
696
|
/**
|
|
575
697
|
* Keep only the most recent `max_lines` non-empty feedback log lines. Non-falliable.
|
|
576
698
|
*/
|
|
@@ -594,3 +716,25 @@ export function shouldSupersede(new_importance: number, existing_importance: num
|
|
|
594
716
|
* Returns 65-byte signature as hex string (r + s + v).
|
|
595
717
|
*/
|
|
596
718
|
export function signUserOp(hash_hex: string, private_key_hex: string): string;
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Return the source weight multiplier for a given source string.
|
|
722
|
+
*
|
|
723
|
+
* Accepted values: "user" | "user-inferred" | "assistant" | "external" | "derived".
|
|
724
|
+
*
|
|
725
|
+
* Unknown input is routed through `MemorySource::from_str_lossy` which
|
|
726
|
+
* falls back to `user-inferred` (weight 0.90). Callers who need the
|
|
727
|
+
* "no source field at all" fallback (weight 0.85) should call
|
|
728
|
+
* `legacyClaimFallbackWeight()` instead.
|
|
729
|
+
*/
|
|
730
|
+
export function sourceWeight(source: string): number;
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Validate a Memory Taxonomy v1 claim (JSON in, JSON out — canonicalised).
|
|
734
|
+
*
|
|
735
|
+
* Returns the canonical JSON encoding on success. Throws on any schema
|
|
736
|
+
* violation (wrong type token, missing required field, wrong schema_version).
|
|
737
|
+
*
|
|
738
|
+
* See `docs/specs/totalreclaw/memory-taxonomy-v1.md`.
|
|
739
|
+
*/
|
|
740
|
+
export function validateMemoryClaimV1(claim_json: string): string;
|
package/totalreclaw_core.js
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
/* @ts-self-types="./totalreclaw_core.d.ts" */
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Contradiction candidate cap constant.
|
|
5
|
+
* @returns {number}
|
|
6
|
+
*/
|
|
7
|
+
function CONTRADICTION_CANDIDATE_CAP() {
|
|
8
|
+
const ret = wasm.CONTRADICTION_CANDIDATE_CAP();
|
|
9
|
+
return ret >>> 0;
|
|
10
|
+
}
|
|
11
|
+
exports.CONTRADICTION_CANDIDATE_CAP = CONTRADICTION_CANDIDATE_CAP;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Decision log max lines constant.
|
|
15
|
+
* @returns {number}
|
|
16
|
+
*/
|
|
17
|
+
function DECISION_LOG_MAX_LINES() {
|
|
18
|
+
const ret = wasm.DECISION_LOG_MAX_LINES();
|
|
19
|
+
return ret >>> 0;
|
|
20
|
+
}
|
|
21
|
+
exports.DECISION_LOG_MAX_LINES = DECISION_LOG_MAX_LINES;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Tie-zone score tolerance constant.
|
|
25
|
+
* @returns {number}
|
|
26
|
+
*/
|
|
27
|
+
function TIE_ZONE_SCORE_TOLERANCE() {
|
|
28
|
+
const ret = wasm.TIE_ZONE_SCORE_TOLERANCE();
|
|
29
|
+
return ret;
|
|
30
|
+
}
|
|
31
|
+
exports.TIE_ZONE_SCORE_TOLERANCE = TIE_ZONE_SCORE_TOLERANCE;
|
|
32
|
+
|
|
3
33
|
/**
|
|
4
34
|
* Random Hyperplane LSH hasher (WASM wrapper).
|
|
5
35
|
*
|
|
@@ -110,6 +140,30 @@ class WasmLshHasher {
|
|
|
110
140
|
if (Symbol.dispose) WasmLshHasher.prototype[Symbol.dispose] = WasmLshHasher.prototype.free;
|
|
111
141
|
exports.WasmLshHasher = WasmLshHasher;
|
|
112
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Append one decision entry to existing JSONL content. Non-fallible.
|
|
145
|
+
* @param {string} existing_content
|
|
146
|
+
* @param {string} entry_json
|
|
147
|
+
* @returns {string}
|
|
148
|
+
*/
|
|
149
|
+
function appendDecisionEntry(existing_content, entry_json) {
|
|
150
|
+
let deferred3_0;
|
|
151
|
+
let deferred3_1;
|
|
152
|
+
try {
|
|
153
|
+
const ptr0 = passStringToWasm0(existing_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
154
|
+
const len0 = WASM_VECTOR_LEN;
|
|
155
|
+
const ptr1 = passStringToWasm0(entry_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
156
|
+
const len1 = WASM_VECTOR_LEN;
|
|
157
|
+
const ret = wasm.appendDecisionEntry(ptr0, len0, ptr1, len1);
|
|
158
|
+
deferred3_0 = ret[0];
|
|
159
|
+
deferred3_1 = ret[1];
|
|
160
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
161
|
+
} finally {
|
|
162
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.appendDecisionEntry = appendDecisionEntry;
|
|
166
|
+
|
|
113
167
|
/**
|
|
114
168
|
* Append one feedback entry to existing JSONL content.
|
|
115
169
|
* @param {string} existing
|
|
@@ -251,6 +305,45 @@ function buildDebriefPrompt(stored_facts_json) {
|
|
|
251
305
|
}
|
|
252
306
|
exports.buildDebriefPrompt = buildDebriefPrompt;
|
|
253
307
|
|
|
308
|
+
/**
|
|
309
|
+
* Build decision log entries from resolution actions.
|
|
310
|
+
*
|
|
311
|
+
* Returns a JSON array of `DecisionLogEntry`.
|
|
312
|
+
* @param {string} actions_json
|
|
313
|
+
* @param {string} new_claim_json
|
|
314
|
+
* @param {string} existing_claims_json
|
|
315
|
+
* @param {string} mode
|
|
316
|
+
* @param {bigint} now_unix
|
|
317
|
+
* @returns {string}
|
|
318
|
+
*/
|
|
319
|
+
function buildDecisionLogEntries(actions_json, new_claim_json, existing_claims_json, mode, now_unix) {
|
|
320
|
+
let deferred6_0;
|
|
321
|
+
let deferred6_1;
|
|
322
|
+
try {
|
|
323
|
+
const ptr0 = passStringToWasm0(actions_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
324
|
+
const len0 = WASM_VECTOR_LEN;
|
|
325
|
+
const ptr1 = passStringToWasm0(new_claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
326
|
+
const len1 = WASM_VECTOR_LEN;
|
|
327
|
+
const ptr2 = passStringToWasm0(existing_claims_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
328
|
+
const len2 = WASM_VECTOR_LEN;
|
|
329
|
+
const ptr3 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
330
|
+
const len3 = WASM_VECTOR_LEN;
|
|
331
|
+
const ret = wasm.buildDecisionLogEntries(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, now_unix);
|
|
332
|
+
var ptr5 = ret[0];
|
|
333
|
+
var len5 = ret[1];
|
|
334
|
+
if (ret[3]) {
|
|
335
|
+
ptr5 = 0; len5 = 0;
|
|
336
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
337
|
+
}
|
|
338
|
+
deferred6_0 = ptr5;
|
|
339
|
+
deferred6_1 = len5;
|
|
340
|
+
return getStringFromWasm0(ptr5, len5);
|
|
341
|
+
} finally {
|
|
342
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
exports.buildDecisionLogEntries = buildDecisionLogEntries;
|
|
346
|
+
|
|
254
347
|
/**
|
|
255
348
|
* Build the LLM prompt for digest compilation.
|
|
256
349
|
* `claims_json`: JSON array of Claim (must be non-empty).
|
|
@@ -279,6 +372,32 @@ function buildDigestPrompt(claims_json) {
|
|
|
279
372
|
}
|
|
280
373
|
exports.buildDigestPrompt = buildDigestPrompt;
|
|
281
374
|
|
|
375
|
+
/**
|
|
376
|
+
* Build a FeedbackEntry JSON from a decision-log entry JSON + pin action.
|
|
377
|
+
* Returns the JSON string, or the literal string "null" on failure.
|
|
378
|
+
* @param {string} decision_json
|
|
379
|
+
* @param {string} action
|
|
380
|
+
* @param {bigint} now_unix
|
|
381
|
+
* @returns {string}
|
|
382
|
+
*/
|
|
383
|
+
function buildFeedbackFromDecision(decision_json, action, now_unix) {
|
|
384
|
+
let deferred3_0;
|
|
385
|
+
let deferred3_1;
|
|
386
|
+
try {
|
|
387
|
+
const ptr0 = passStringToWasm0(decision_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
388
|
+
const len0 = WASM_VECTOR_LEN;
|
|
389
|
+
const ptr1 = passStringToWasm0(action, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
390
|
+
const len1 = WASM_VECTOR_LEN;
|
|
391
|
+
const ret = wasm.buildFeedbackFromDecision(ptr0, len0, ptr1, len1, now_unix);
|
|
392
|
+
deferred3_0 = ret[0];
|
|
393
|
+
deferred3_1 = ret[1];
|
|
394
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
395
|
+
} finally {
|
|
396
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
exports.buildFeedbackFromDecision = buildFeedbackFromDecision;
|
|
400
|
+
|
|
282
401
|
/**
|
|
283
402
|
* Build the profiling prompt for a batch of conversation summaries.
|
|
284
403
|
*
|
|
@@ -471,6 +590,28 @@ function chunksToSummaries(chunks_json) {
|
|
|
471
590
|
}
|
|
472
591
|
exports.chunksToSummaries = chunksToSummaries;
|
|
473
592
|
|
|
593
|
+
/**
|
|
594
|
+
* WASM binding for `cluster_facts`.
|
|
595
|
+
*
|
|
596
|
+
* `candidates_json`: JSON array of `ConsolidationCandidate` objects.
|
|
597
|
+
* `threshold`: Cosine similarity threshold for clustering.
|
|
598
|
+
*
|
|
599
|
+
* Returns JSON array of `{ representative: string, duplicates: string[] }`.
|
|
600
|
+
* @param {string} candidates_json
|
|
601
|
+
* @param {number} threshold
|
|
602
|
+
* @returns {any}
|
|
603
|
+
*/
|
|
604
|
+
function clusterFacts(candidates_json, threshold) {
|
|
605
|
+
const ptr0 = passStringToWasm0(candidates_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
606
|
+
const len0 = WASM_VECTOR_LEN;
|
|
607
|
+
const ret = wasm.clusterFacts(ptr0, len0, threshold);
|
|
608
|
+
if (ret[2]) {
|
|
609
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
610
|
+
}
|
|
611
|
+
return takeFromExternrefTable0(ret[0]);
|
|
612
|
+
}
|
|
613
|
+
exports.clusterFacts = clusterFacts;
|
|
614
|
+
|
|
474
615
|
/**
|
|
475
616
|
* Compute SHA-256(authKey) as a hex string.
|
|
476
617
|
*
|
|
@@ -948,17 +1089,21 @@ exports.encodeSingleCall = encodeSingleCall;
|
|
|
948
1089
|
/**
|
|
949
1090
|
* Encode a tombstone protobuf for soft-deleting a fact.
|
|
950
1091
|
*
|
|
1092
|
+
* `version` is optional; missing/0 defaults to `DEFAULT_PROTOBUF_VERSION` (3).
|
|
1093
|
+
* Pass `4` to emit a v1-taxonomy tombstone (outer protobuf version = 4).
|
|
1094
|
+
*
|
|
951
1095
|
* Returns the protobuf bytes as a Uint8Array.
|
|
952
1096
|
* @param {string} fact_id
|
|
953
1097
|
* @param {string} owner
|
|
1098
|
+
* @param {number | null} [version]
|
|
954
1099
|
* @returns {Uint8Array}
|
|
955
1100
|
*/
|
|
956
|
-
function encodeTombstoneProtobuf(fact_id, owner) {
|
|
1101
|
+
function encodeTombstoneProtobuf(fact_id, owner, version) {
|
|
957
1102
|
const ptr0 = passStringToWasm0(fact_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
958
1103
|
const len0 = WASM_VECTOR_LEN;
|
|
959
1104
|
const ptr1 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
960
1105
|
const len1 = WASM_VECTOR_LEN;
|
|
961
|
-
const ret = wasm.encodeTombstoneProtobuf(ptr0, len0, ptr1, len1);
|
|
1106
|
+
const ret = wasm.encodeTombstoneProtobuf(ptr0, len0, ptr1, len1, isLikeNone(version) ? 0x100000001 : (version) >>> 0);
|
|
962
1107
|
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
963
1108
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
964
1109
|
return v3;
|
|
@@ -1061,7 +1206,118 @@ function feedbackToCounterexample(entry_json) {
|
|
|
1061
1206
|
exports.feedbackToCounterexample = feedbackToCounterexample;
|
|
1062
1207
|
|
|
1063
1208
|
/**
|
|
1064
|
-
*
|
|
1209
|
+
* Filter resolution actions by mode ("active" passes through, "shadow"/"off" returns empty).
|
|
1210
|
+
*
|
|
1211
|
+
* Returns a JSON array of `ResolutionAction`.
|
|
1212
|
+
* @param {string} actions_json
|
|
1213
|
+
* @param {string} mode
|
|
1214
|
+
* @returns {string}
|
|
1215
|
+
*/
|
|
1216
|
+
function filterShadowMode(actions_json, mode) {
|
|
1217
|
+
let deferred4_0;
|
|
1218
|
+
let deferred4_1;
|
|
1219
|
+
try {
|
|
1220
|
+
const ptr0 = passStringToWasm0(actions_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1221
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1222
|
+
const ptr1 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1223
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1224
|
+
const ret = wasm.filterShadowMode(ptr0, len0, ptr1, len1);
|
|
1225
|
+
var ptr3 = ret[0];
|
|
1226
|
+
var len3 = ret[1];
|
|
1227
|
+
if (ret[3]) {
|
|
1228
|
+
ptr3 = 0; len3 = 0;
|
|
1229
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1230
|
+
}
|
|
1231
|
+
deferred4_0 = ptr3;
|
|
1232
|
+
deferred4_1 = len3;
|
|
1233
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1234
|
+
} finally {
|
|
1235
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
exports.filterShadowMode = filterShadowMode;
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* WASM binding for `find_best_near_duplicate`.
|
|
1242
|
+
*
|
|
1243
|
+
* `new_embedding_json`: JSON array of floats (embedding vector).
|
|
1244
|
+
* `existing_json`: JSON array of `{ id: string, embedding: number[] }` objects.
|
|
1245
|
+
* `threshold`: Cosine similarity threshold.
|
|
1246
|
+
*
|
|
1247
|
+
* Returns JSON `{ fact_id: string, similarity: number }` or null.
|
|
1248
|
+
* @param {string} new_embedding_json
|
|
1249
|
+
* @param {string} existing_json
|
|
1250
|
+
* @param {number} threshold
|
|
1251
|
+
* @returns {any}
|
|
1252
|
+
*/
|
|
1253
|
+
function findBestNearDuplicate(new_embedding_json, existing_json, threshold) {
|
|
1254
|
+
const ptr0 = passStringToWasm0(new_embedding_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1255
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1256
|
+
const ptr1 = passStringToWasm0(existing_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1257
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1258
|
+
const ret = wasm.findBestNearDuplicate(ptr0, len0, ptr1, len1, threshold);
|
|
1259
|
+
if (ret[2]) {
|
|
1260
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1261
|
+
}
|
|
1262
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1263
|
+
}
|
|
1264
|
+
exports.findBestNearDuplicate = findBestNearDuplicate;
|
|
1265
|
+
|
|
1266
|
+
/**
|
|
1267
|
+
* Find a decision-log entry matching a fact as winner or loser.
|
|
1268
|
+
* Returns the JSON-serialized DecisionLogEntry, or the literal string "null".
|
|
1269
|
+
* @param {string} fact_id
|
|
1270
|
+
* @param {string} role
|
|
1271
|
+
* @param {string} log_content
|
|
1272
|
+
* @returns {string}
|
|
1273
|
+
*/
|
|
1274
|
+
function findDecisionForPin(fact_id, role, log_content) {
|
|
1275
|
+
let deferred4_0;
|
|
1276
|
+
let deferred4_1;
|
|
1277
|
+
try {
|
|
1278
|
+
const ptr0 = passStringToWasm0(fact_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1279
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1280
|
+
const ptr1 = passStringToWasm0(role, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1281
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1282
|
+
const ptr2 = passStringToWasm0(log_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1283
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1284
|
+
const ret = wasm.findDecisionForPin(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1285
|
+
deferred4_0 = ret[0];
|
|
1286
|
+
deferred4_1 = ret[1];
|
|
1287
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1288
|
+
} finally {
|
|
1289
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
exports.findDecisionForPin = findDecisionForPin;
|
|
1293
|
+
|
|
1294
|
+
/**
|
|
1295
|
+
* Find the loser claim JSON from the decision log for a given fact ID.
|
|
1296
|
+
* Returns the loser_claim_json string, or the literal string "null" if not found.
|
|
1297
|
+
* @param {string} fact_id
|
|
1298
|
+
* @param {string} log_content
|
|
1299
|
+
* @returns {string}
|
|
1300
|
+
*/
|
|
1301
|
+
function findLoserClaimInDecisionLog(fact_id, log_content) {
|
|
1302
|
+
let deferred3_0;
|
|
1303
|
+
let deferred3_1;
|
|
1304
|
+
try {
|
|
1305
|
+
const ptr0 = passStringToWasm0(fact_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1306
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1307
|
+
const ptr1 = passStringToWasm0(log_content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1308
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1309
|
+
const ret = wasm.findLoserClaimInDecisionLog(ptr0, len0, ptr1, len1);
|
|
1310
|
+
deferred3_0 = ret[0];
|
|
1311
|
+
deferred3_1 = ret[1];
|
|
1312
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1313
|
+
} finally {
|
|
1314
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
exports.findLoserClaimInDecisionLog = findLoserClaimInDecisionLog;
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* WASM binding for `find_near_duplicate` (deprecated — use `findBestNearDuplicate`).
|
|
1065
1321
|
*
|
|
1066
1322
|
* `new_embedding`: Float32Array of the new fact's embedding.
|
|
1067
1323
|
* `existing_json`: JSON array of `{ id: string, embedding: number[] }` objects.
|
|
@@ -1465,6 +1721,30 @@ function hexBlobToBase64(hex_blob) {
|
|
|
1465
1721
|
}
|
|
1466
1722
|
exports.hexBlobToBase64 = hexBlobToBase64;
|
|
1467
1723
|
|
|
1724
|
+
/**
|
|
1725
|
+
* Check whether a JSON-serialized claim has pinned status.
|
|
1726
|
+
* @param {string} claim_json
|
|
1727
|
+
* @returns {boolean}
|
|
1728
|
+
*/
|
|
1729
|
+
function isPinnedClaim(claim_json) {
|
|
1730
|
+
const ptr0 = passStringToWasm0(claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1731
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1732
|
+
const ret = wasm.isPinnedClaim(ptr0, len0);
|
|
1733
|
+
return ret !== 0;
|
|
1734
|
+
}
|
|
1735
|
+
exports.isPinnedClaim = isPinnedClaim;
|
|
1736
|
+
|
|
1737
|
+
/**
|
|
1738
|
+
* Return the v1 legacy-claim fallback weight (applied to candidates that
|
|
1739
|
+
* have no `source` field).
|
|
1740
|
+
* @returns {number}
|
|
1741
|
+
*/
|
|
1742
|
+
function legacyClaimFallbackWeight() {
|
|
1743
|
+
const ret = wasm.legacyClaimFallbackWeight();
|
|
1744
|
+
return ret;
|
|
1745
|
+
}
|
|
1746
|
+
exports.legacyClaimFallbackWeight = legacyClaimFallbackWeight;
|
|
1747
|
+
|
|
1468
1748
|
/**
|
|
1469
1749
|
* Normalize an entity name (NFC, lowercase, trim, collapse whitespace).
|
|
1470
1750
|
* @param {string} name
|
|
@@ -1600,6 +1880,48 @@ function parseDigestResponse(raw) {
|
|
|
1600
1880
|
}
|
|
1601
1881
|
exports.parseDigestResponse = parseDigestResponse;
|
|
1602
1882
|
|
|
1883
|
+
/**
|
|
1884
|
+
* Case-insensitive parse of a memory source string. Unknown input returns "user-inferred".
|
|
1885
|
+
* @param {string} s
|
|
1886
|
+
* @returns {string}
|
|
1887
|
+
*/
|
|
1888
|
+
function parseMemorySource(s) {
|
|
1889
|
+
let deferred2_0;
|
|
1890
|
+
let deferred2_1;
|
|
1891
|
+
try {
|
|
1892
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1893
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1894
|
+
const ret = wasm.parseMemorySource(ptr0, len0);
|
|
1895
|
+
deferred2_0 = ret[0];
|
|
1896
|
+
deferred2_1 = ret[1];
|
|
1897
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1898
|
+
} finally {
|
|
1899
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
exports.parseMemorySource = parseMemorySource;
|
|
1903
|
+
|
|
1904
|
+
/**
|
|
1905
|
+
* Case-insensitive parse of a memory type string. Unknown input returns "claim".
|
|
1906
|
+
* @param {string} s
|
|
1907
|
+
* @returns {string}
|
|
1908
|
+
*/
|
|
1909
|
+
function parseMemoryTypeV1(s) {
|
|
1910
|
+
let deferred2_0;
|
|
1911
|
+
let deferred2_1;
|
|
1912
|
+
try {
|
|
1913
|
+
const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1914
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1915
|
+
const ret = wasm.parseMemoryTypeV1(ptr0, len0);
|
|
1916
|
+
deferred2_0 = ret[0];
|
|
1917
|
+
deferred2_1 = ret[1];
|
|
1918
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1919
|
+
} finally {
|
|
1920
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
exports.parseMemoryTypeV1 = parseMemoryTypeV1;
|
|
1924
|
+
|
|
1603
1925
|
/**
|
|
1604
1926
|
* Parse a batch profiling LLM response into a PartialProfile.
|
|
1605
1927
|
*
|
|
@@ -1840,7 +2162,7 @@ exports.readFeedbackJsonl = readFeedbackJsonl;
|
|
|
1840
2162
|
/**
|
|
1841
2163
|
* Rerank candidates using BM25 + Cosine + RRF fusion.
|
|
1842
2164
|
*
|
|
1843
|
-
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp }` objects.
|
|
2165
|
+
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
|
|
1844
2166
|
* Returns a JsValue (array of `RankedResult` objects).
|
|
1845
2167
|
* @param {string} query
|
|
1846
2168
|
* @param {Float32Array} query_embedding
|
|
@@ -1863,6 +2185,37 @@ function rerank(query, query_embedding, candidates_json, top_k) {
|
|
|
1863
2185
|
}
|
|
1864
2186
|
exports.rerank = rerank;
|
|
1865
2187
|
|
|
2188
|
+
/**
|
|
2189
|
+
* Rerank candidates with a config flag (Retrieval v2 Tier 1).
|
|
2190
|
+
*
|
|
2191
|
+
* When `apply_source_weights` is `true`, each candidate's final score is
|
|
2192
|
+
* multiplied by the provenance weight from its `source` field (legacy
|
|
2193
|
+
* candidates without `source` use the v0 fallback weight).
|
|
2194
|
+
*
|
|
2195
|
+
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
|
|
2196
|
+
* Returns a JsValue (array of `RankedResult` objects including `source_weight`).
|
|
2197
|
+
* @param {string} query
|
|
2198
|
+
* @param {Float32Array} query_embedding
|
|
2199
|
+
* @param {string} candidates_json
|
|
2200
|
+
* @param {number} top_k
|
|
2201
|
+
* @param {boolean} apply_source_weights
|
|
2202
|
+
* @returns {any}
|
|
2203
|
+
*/
|
|
2204
|
+
function rerankWithConfig(query, query_embedding, candidates_json, top_k, apply_source_weights) {
|
|
2205
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2206
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2207
|
+
const ptr1 = passArrayF32ToWasm0(query_embedding, wasm.__wbindgen_malloc);
|
|
2208
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2209
|
+
const ptr2 = passStringToWasm0(candidates_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2210
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2211
|
+
const ret = wasm.rerankWithConfig(ptr0, len0, ptr1, len1, ptr2, len2, top_k, apply_source_weights);
|
|
2212
|
+
if (ret[2]) {
|
|
2213
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2214
|
+
}
|
|
2215
|
+
return takeFromExternrefTable0(ret[0]);
|
|
2216
|
+
}
|
|
2217
|
+
exports.rerankWithConfig = rerankWithConfig;
|
|
2218
|
+
|
|
1866
2219
|
/**
|
|
1867
2220
|
* Run the resolution formula on two contradicting claims; returns ResolutionOutcome JSON.
|
|
1868
2221
|
* @param {string} claim_a_json
|
|
@@ -1903,6 +2256,91 @@ function resolvePair(claim_a_json, claim_a_id, claim_b_json, claim_b_id, now_uni
|
|
|
1903
2256
|
}
|
|
1904
2257
|
exports.resolvePair = resolvePair;
|
|
1905
2258
|
|
|
2259
|
+
/**
|
|
2260
|
+
* Orchestrate contradiction detection + resolution for a new claim against candidates.
|
|
2261
|
+
*
|
|
2262
|
+
* Returns a JSON array of `ResolutionAction`.
|
|
2263
|
+
* @param {string} new_claim_json
|
|
2264
|
+
* @param {string} new_claim_id
|
|
2265
|
+
* @param {string} new_embedding_json
|
|
2266
|
+
* @param {string} candidates_json
|
|
2267
|
+
* @param {string} weights_json
|
|
2268
|
+
* @param {number} threshold_lower
|
|
2269
|
+
* @param {number} threshold_upper
|
|
2270
|
+
* @param {bigint} now_unix
|
|
2271
|
+
* @param {number} tie_tolerance
|
|
2272
|
+
* @returns {string}
|
|
2273
|
+
*/
|
|
2274
|
+
function resolveWithCandidates(new_claim_json, new_claim_id, new_embedding_json, candidates_json, weights_json, threshold_lower, threshold_upper, now_unix, tie_tolerance) {
|
|
2275
|
+
let deferred7_0;
|
|
2276
|
+
let deferred7_1;
|
|
2277
|
+
try {
|
|
2278
|
+
const ptr0 = passStringToWasm0(new_claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2279
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2280
|
+
const ptr1 = passStringToWasm0(new_claim_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2281
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2282
|
+
const ptr2 = passStringToWasm0(new_embedding_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2283
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2284
|
+
const ptr3 = passStringToWasm0(candidates_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2285
|
+
const len3 = WASM_VECTOR_LEN;
|
|
2286
|
+
const ptr4 = passStringToWasm0(weights_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2287
|
+
const len4 = WASM_VECTOR_LEN;
|
|
2288
|
+
const ret = wasm.resolveWithCandidates(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, threshold_lower, threshold_upper, now_unix, tie_tolerance);
|
|
2289
|
+
var ptr6 = ret[0];
|
|
2290
|
+
var len6 = ret[1];
|
|
2291
|
+
if (ret[3]) {
|
|
2292
|
+
ptr6 = 0; len6 = 0;
|
|
2293
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2294
|
+
}
|
|
2295
|
+
deferred7_0 = ptr6;
|
|
2296
|
+
deferred7_1 = len6;
|
|
2297
|
+
return getStringFromWasm0(ptr6, len6);
|
|
2298
|
+
} finally {
|
|
2299
|
+
wasm.__wbindgen_free(deferred7_0, deferred7_1, 1);
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
exports.resolveWithCandidates = resolveWithCandidates;
|
|
2303
|
+
|
|
2304
|
+
/**
|
|
2305
|
+
* Apply pin-status and tie-zone checks to a resolution outcome.
|
|
2306
|
+
* Returns a JSON-serialized `ResolutionAction`.
|
|
2307
|
+
* @param {string} existing_claim_json
|
|
2308
|
+
* @param {string} new_claim_id
|
|
2309
|
+
* @param {string} existing_claim_id
|
|
2310
|
+
* @param {string} resolution_winner
|
|
2311
|
+
* @param {number} score_gap
|
|
2312
|
+
* @param {number} similarity
|
|
2313
|
+
* @param {number} tie_tolerance
|
|
2314
|
+
* @returns {string}
|
|
2315
|
+
*/
|
|
2316
|
+
function respectPinInResolution(existing_claim_json, new_claim_id, existing_claim_id, resolution_winner, score_gap, similarity, tie_tolerance) {
|
|
2317
|
+
let deferred6_0;
|
|
2318
|
+
let deferred6_1;
|
|
2319
|
+
try {
|
|
2320
|
+
const ptr0 = passStringToWasm0(existing_claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2321
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2322
|
+
const ptr1 = passStringToWasm0(new_claim_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2323
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2324
|
+
const ptr2 = passStringToWasm0(existing_claim_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2325
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2326
|
+
const ptr3 = passStringToWasm0(resolution_winner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2327
|
+
const len3 = WASM_VECTOR_LEN;
|
|
2328
|
+
const ret = wasm.respectPinInResolution(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, score_gap, similarity, tie_tolerance);
|
|
2329
|
+
var ptr5 = ret[0];
|
|
2330
|
+
var len5 = ret[1];
|
|
2331
|
+
if (ret[3]) {
|
|
2332
|
+
ptr5 = 0; len5 = 0;
|
|
2333
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2334
|
+
}
|
|
2335
|
+
deferred6_0 = ptr5;
|
|
2336
|
+
deferred6_1 = len5;
|
|
2337
|
+
return getStringFromWasm0(ptr5, len5);
|
|
2338
|
+
} finally {
|
|
2339
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
exports.respectPinInResolution = respectPinInResolution;
|
|
2343
|
+
|
|
1906
2344
|
/**
|
|
1907
2345
|
* Keep only the most recent `max_lines` non-empty feedback log lines. Non-falliable.
|
|
1908
2346
|
* @param {string} content
|
|
@@ -1998,6 +2436,58 @@ function signUserOp(hash_hex, private_key_hex) {
|
|
|
1998
2436
|
}
|
|
1999
2437
|
exports.signUserOp = signUserOp;
|
|
2000
2438
|
|
|
2439
|
+
/**
|
|
2440
|
+
* Return the source weight multiplier for a given source string.
|
|
2441
|
+
*
|
|
2442
|
+
* Accepted values: "user" | "user-inferred" | "assistant" | "external" | "derived".
|
|
2443
|
+
*
|
|
2444
|
+
* Unknown input is routed through `MemorySource::from_str_lossy` which
|
|
2445
|
+
* falls back to `user-inferred` (weight 0.90). Callers who need the
|
|
2446
|
+
* "no source field at all" fallback (weight 0.85) should call
|
|
2447
|
+
* `legacyClaimFallbackWeight()` instead.
|
|
2448
|
+
* @param {string} source
|
|
2449
|
+
* @returns {number}
|
|
2450
|
+
*/
|
|
2451
|
+
function sourceWeight(source) {
|
|
2452
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2453
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2454
|
+
const ret = wasm.sourceWeight(ptr0, len0);
|
|
2455
|
+
return ret;
|
|
2456
|
+
}
|
|
2457
|
+
exports.sourceWeight = sourceWeight;
|
|
2458
|
+
|
|
2459
|
+
/**
|
|
2460
|
+
* Validate a Memory Taxonomy v1 claim (JSON in, JSON out — canonicalised).
|
|
2461
|
+
*
|
|
2462
|
+
* Returns the canonical JSON encoding on success. Throws on any schema
|
|
2463
|
+
* violation (wrong type token, missing required field, wrong schema_version).
|
|
2464
|
+
*
|
|
2465
|
+
* See `docs/specs/totalreclaw/memory-taxonomy-v1.md`.
|
|
2466
|
+
* @param {string} claim_json
|
|
2467
|
+
* @returns {string}
|
|
2468
|
+
*/
|
|
2469
|
+
function validateMemoryClaimV1(claim_json) {
|
|
2470
|
+
let deferred3_0;
|
|
2471
|
+
let deferred3_1;
|
|
2472
|
+
try {
|
|
2473
|
+
const ptr0 = passStringToWasm0(claim_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2474
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2475
|
+
const ret = wasm.validateMemoryClaimV1(ptr0, len0);
|
|
2476
|
+
var ptr2 = ret[0];
|
|
2477
|
+
var len2 = ret[1];
|
|
2478
|
+
if (ret[3]) {
|
|
2479
|
+
ptr2 = 0; len2 = 0;
|
|
2480
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2481
|
+
}
|
|
2482
|
+
deferred3_0 = ptr2;
|
|
2483
|
+
deferred3_1 = len2;
|
|
2484
|
+
return getStringFromWasm0(ptr2, len2);
|
|
2485
|
+
} finally {
|
|
2486
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
exports.validateMemoryClaimV1 = validateMemoryClaimV1;
|
|
2490
|
+
|
|
2001
2491
|
function __wbg_get_imports() {
|
|
2002
2492
|
const import0 = {
|
|
2003
2493
|
__proto__: null,
|
package/totalreclaw_core_bg.wasm
CHANGED
|
Binary file
|