@totalreclaw/core 2.5.5 → 2.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{totalreclaw_core.d.ts → nodejs/totalreclaw_core.d.ts} +23 -0
- package/{totalreclaw_core.js → nodejs/totalreclaw_core.js} +47 -3
- package/nodejs/totalreclaw_core_bg.wasm +0 -0
- package/nodejs/totalreclaw_core_bg.wasm.d.ts +141 -0
- package/package.json +18 -9
- package/web/README.md +40 -0
- package/web/package.json +3 -0
- package/web/totalreclaw_core.d.ts +1116 -0
- package/web/totalreclaw_core.js +3311 -0
- package/web/totalreclaw_core_bg.wasm +0 -0
- package/web/totalreclaw_core_bg.wasm.d.ts +141 -0
- package/totalreclaw_core_bg.wasm +0 -0
- /package/{README.md → nodejs/README.md} +0 -0
|
@@ -0,0 +1,1116 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
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
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Random Hyperplane LSH hasher (WASM wrapper).
|
|
21
|
+
*
|
|
22
|
+
* Construct with `new WasmLshHasher(seedHex, dims)`.
|
|
23
|
+
* Call `hash(embeddingFloat64Array)` to get bucket IDs.
|
|
24
|
+
*/
|
|
25
|
+
export class WasmLshHasher {
|
|
26
|
+
free(): void;
|
|
27
|
+
[Symbol.dispose](): void;
|
|
28
|
+
/**
|
|
29
|
+
* Hash an embedding vector to blind-hashed bucket IDs.
|
|
30
|
+
*
|
|
31
|
+
* `embedding`: Float64Array of length `dims`.
|
|
32
|
+
* Returns a JSON array of hex strings (one per table).
|
|
33
|
+
*/
|
|
34
|
+
hash(embedding: Float64Array): any;
|
|
35
|
+
/**
|
|
36
|
+
* Create a new LSH hasher with default parameters (20 tables, 32 bits).
|
|
37
|
+
*
|
|
38
|
+
* `seed_hex`: hex-encoded seed (>= 32 chars = 16 bytes).
|
|
39
|
+
* `dims`: embedding dimensionality (e.g. 640).
|
|
40
|
+
*/
|
|
41
|
+
constructor(seed_hex: string, dims: number);
|
|
42
|
+
/**
|
|
43
|
+
* Create a new LSH hasher with custom parameters.
|
|
44
|
+
*
|
|
45
|
+
* `seed_hex`: hex-encoded seed.
|
|
46
|
+
* `dims`: embedding dimensionality.
|
|
47
|
+
* `n_tables`: number of hash tables.
|
|
48
|
+
* `n_bits`: bits per table.
|
|
49
|
+
*/
|
|
50
|
+
static withParams(seed_hex: string, dims: number, n_tables: number, n_bits: number): WasmLshHasher;
|
|
51
|
+
/**
|
|
52
|
+
* Bits per table.
|
|
53
|
+
*/
|
|
54
|
+
readonly bits: number;
|
|
55
|
+
/**
|
|
56
|
+
* Embedding dimensionality.
|
|
57
|
+
*/
|
|
58
|
+
readonly dimensions: number;
|
|
59
|
+
/**
|
|
60
|
+
* Number of hash tables.
|
|
61
|
+
*/
|
|
62
|
+
readonly tables: number;
|
|
63
|
+
}
|
|
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
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Append one feedback entry to existing JSONL content.
|
|
72
|
+
*/
|
|
73
|
+
export function appendFeedbackToJsonl(existing: string, entry_json: string): string;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Apply a single counterexample to the weights; returns updated ResolutionWeights JSON.
|
|
77
|
+
*/
|
|
78
|
+
export function applyFeedback(weights_json: string, counterexample_json: string): string;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Assemble a full Digest from a parsed LLM response and source claims.
|
|
82
|
+
*/
|
|
83
|
+
export function assembleDigestFromLlm(parsed_json: string, claims_json: string, now_unix_seconds: bigint): string;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Build ABI-encoded calldata for a batch of prepared facts.
|
|
87
|
+
*
|
|
88
|
+
* `prepared_array_json`: JSON array of `PreparedFact` objects.
|
|
89
|
+
* Returns ABI-encoded calldata (Uint8Array).
|
|
90
|
+
*/
|
|
91
|
+
export function buildBatchCalldataFromPrepared(prepared_array_json: string): Uint8Array;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Build the debrief prompt with already-stored facts filled in.
|
|
95
|
+
*
|
|
96
|
+
* `stored_facts_json`: JSON array of strings (fact texts already stored).
|
|
97
|
+
*/
|
|
98
|
+
export function buildDebriefPrompt(stored_facts_json: string): string;
|
|
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
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Build the LLM prompt for digest compilation.
|
|
109
|
+
* `claims_json`: JSON array of Claim (must be non-empty).
|
|
110
|
+
*/
|
|
111
|
+
export function buildDigestPrompt(claims_json: string): string;
|
|
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
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Build the profiling prompt for a batch of conversation summaries.
|
|
121
|
+
*
|
|
122
|
+
* `summaries_json`: JSON array of ChunkSummary objects.
|
|
123
|
+
* Returns the prompt string.
|
|
124
|
+
*/
|
|
125
|
+
export function buildProfileBatchPrompt(summaries_json: string): string;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Build the merge prompt that combines partial profiles.
|
|
129
|
+
*
|
|
130
|
+
* `partials_json`: JSON array of PartialProfile objects.
|
|
131
|
+
* Returns the prompt string.
|
|
132
|
+
*/
|
|
133
|
+
export function buildProfileMergePrompt(partials_json: string): string;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Build ABI-encoded calldata for a single prepared fact.
|
|
137
|
+
*
|
|
138
|
+
* `prepared_json`: JSON string of a `PreparedFact`.
|
|
139
|
+
* Returns ABI-encoded calldata (Uint8Array).
|
|
140
|
+
*/
|
|
141
|
+
export function buildSingleCalldataFromPrepared(prepared_json: string): Uint8Array;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Build a template digest from an array of active claims.
|
|
145
|
+
* `claims_json`: JSON array of Claim. Returns JSON-serialized Digest.
|
|
146
|
+
*/
|
|
147
|
+
export function buildTemplateDigest(claims_json: string, now_unix_seconds: bigint): string;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Build the triage prompt for classifying chunks.
|
|
151
|
+
*
|
|
152
|
+
* `profile_json`: JSON string of a UserProfile.
|
|
153
|
+
* `summaries_json`: JSON array of ChunkSummary objects.
|
|
154
|
+
* Returns the prompt string.
|
|
155
|
+
*/
|
|
156
|
+
export function buildTriagePrompt(profile_json: string, summaries_json: string): string;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Canonicalize a Claim JSON: strict-parse as Claim, re-serialize to canonical bytes.
|
|
160
|
+
* Rejects legacy or malformed input. Use before encryption so TS/Python/Rust all
|
|
161
|
+
* produce byte-identical blobs for the same logical claim.
|
|
162
|
+
*/
|
|
163
|
+
export function canonicalizeClaim(claim_json: string): string;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Convert conversation chunks to summaries.
|
|
167
|
+
*
|
|
168
|
+
* `chunks_json`: JSON array of ConversationChunk objects.
|
|
169
|
+
* Returns a JsValue (JSON array of ChunkSummary objects).
|
|
170
|
+
*/
|
|
171
|
+
export function chunksToSummaries(chunks_json: string): any;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Classify natural-language pin/unpin intent from a user utterance.
|
|
175
|
+
*
|
|
176
|
+
* Returns JSON of [`PinIntent`] when a trigger phrase matches, or `null` when
|
|
177
|
+
* the utterance contains no recognised pin gesture. Lowercase normalization
|
|
178
|
+
* is applied internally — callers pass the raw user text.
|
|
179
|
+
*/
|
|
180
|
+
export function classifyPinIntent(text: string): string;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* WASM binding for `cluster_facts`.
|
|
184
|
+
*
|
|
185
|
+
* `candidates_json`: JSON array of `ConsolidationCandidate` objects.
|
|
186
|
+
* `threshold`: Cosine similarity threshold for clustering.
|
|
187
|
+
*
|
|
188
|
+
* Returns JSON array of `{ representative: string, duplicates: string[] }`.
|
|
189
|
+
*/
|
|
190
|
+
export function clusterFacts(candidates_json: string, threshold: number): any;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Compute SHA-256(authKey) as a hex string.
|
|
194
|
+
*
|
|
195
|
+
* `auth_key_hex`: 64-char hex string (32 bytes).
|
|
196
|
+
*/
|
|
197
|
+
export function computeAuthKeyHash(auth_key_hex: string): string;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Compute the content fingerprint for dedup checks.
|
|
201
|
+
*
|
|
202
|
+
* `dedup_key_hex`: 64-char hex string (32 bytes).
|
|
203
|
+
* Returns 64-char hex fingerprint.
|
|
204
|
+
*/
|
|
205
|
+
export function computeContentFingerprint(text: string, dedup_key_hex: string): string;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Compute a claim's score components for contradiction resolution.
|
|
209
|
+
*/
|
|
210
|
+
export function computeScoreComponents(claim_json: string, now_unix_seconds: bigint, weights_json: string): string;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Cosine similarity between two f32 vectors.
|
|
214
|
+
*/
|
|
215
|
+
export function cosineSimilarity(a: Float32Array, b: Float32Array): number;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Decrypt a base64-encoded XChaCha20-Poly1305 blob.
|
|
219
|
+
*
|
|
220
|
+
* `encryption_key_hex`: 64-char hex string (32 bytes).
|
|
221
|
+
* Returns the plaintext UTF-8 string.
|
|
222
|
+
*/
|
|
223
|
+
export function decrypt(encrypted_base64: string, encryption_key_hex: string): string;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Decrypt and rerank search candidates.
|
|
227
|
+
*
|
|
228
|
+
* Takes raw SubgraphFacts (as JSON), decrypts their content + embeddings,
|
|
229
|
+
* and returns top-K ranked results using BM25 + Cosine + RRF fusion.
|
|
230
|
+
*
|
|
231
|
+
* `facts_json`: JSON array of SubgraphFact objects.
|
|
232
|
+
* `query`: The search query text.
|
|
233
|
+
* `query_embedding`: Float32Array of the query embedding.
|
|
234
|
+
* `encryption_key_hex`: 64-char hex string (32 bytes).
|
|
235
|
+
* `top_k`: Number of top results to return.
|
|
236
|
+
*
|
|
237
|
+
* Returns a JsValue (JSON array of RankedResult objects).
|
|
238
|
+
*/
|
|
239
|
+
export function decryptAndRerank(facts_json: string, query: string, query_embedding: Float32Array, encryption_key_hex: string, top_k: number): any;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Return the locked-default [`PinConfig`] as JSON. Clients that don't want
|
|
243
|
+
* to retune can pass this verbatim to [`wasm_pin_boost`].
|
|
244
|
+
*/
|
|
245
|
+
export function defaultPinConfig(): string;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Default P2-3 resolution weights as JSON.
|
|
249
|
+
*/
|
|
250
|
+
export function defaultResolutionWeights(): string;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Build a fresh default WeightsFile JSON with the given timestamp.
|
|
254
|
+
*/
|
|
255
|
+
export function defaultWeightsFile(now_unix_seconds: bigint): string;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Derive an Ethereum EOA wallet from a BIP-39 mnemonic via BIP-44.
|
|
259
|
+
*
|
|
260
|
+
* Path: m/44'/60'/0'/0/0 (standard Ethereum derivation path).
|
|
261
|
+
* Returns a JS object: `{ private_key: "hex...", address: "0x..." }`.
|
|
262
|
+
*/
|
|
263
|
+
export function deriveEoa(mnemonic: string): any;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Derive just the Ethereum EOA address from a BIP-39 mnemonic.
|
|
267
|
+
*
|
|
268
|
+
* Returns: `"0x..."` (lowercase hex).
|
|
269
|
+
*/
|
|
270
|
+
export function deriveEoaAddress(mnemonic: string): string;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Derive encryption keys from a BIP-39 mnemonic (strict checksum validation).
|
|
274
|
+
*
|
|
275
|
+
* Returns a JSON object with hex-encoded keys:
|
|
276
|
+
* `{ auth_key, encryption_key, dedup_key, salt }`
|
|
277
|
+
*/
|
|
278
|
+
export function deriveKeysFromMnemonic(mnemonic: string): any;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Derive encryption keys from a BIP-39 mnemonic (lenient -- skips checksum).
|
|
282
|
+
*
|
|
283
|
+
* Same return format as `deriveKeysFromMnemonic`.
|
|
284
|
+
*/
|
|
285
|
+
export function deriveKeysFromMnemonicLenient(mnemonic: string): any;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Derive the 32-byte LSH seed from a BIP-39 mnemonic and salt.
|
|
289
|
+
*
|
|
290
|
+
* `salt_hex`: 64-char hex string (32 bytes).
|
|
291
|
+
* Returns hex-encoded 32-byte seed.
|
|
292
|
+
*/
|
|
293
|
+
export function deriveLshSeed(mnemonic: string, salt_hex: string): string;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Detect contradictions between a new claim and existing claims (JSON array of {claim, id, embedding}).
|
|
297
|
+
*/
|
|
298
|
+
export function detectContradictions(new_claim_json: string, new_claim_id: string, new_embedding_json: string, existing_json: string, lower_threshold: number, upper_threshold: number): string;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Deterministic entity ID from a name (first 8 bytes of SHA256 as hex).
|
|
302
|
+
*/
|
|
303
|
+
export function deterministicEntityId(name: string): string;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Encode multiple fact submissions as SimpleAccount.executeBatch() calldata.
|
|
307
|
+
*
|
|
308
|
+
* `payloads_json`: JSON array of hex-encoded payload strings (e.g. `["deadbeef", "cafebabe"]`).
|
|
309
|
+
* Returns ABI-encoded calldata (Uint8Array).
|
|
310
|
+
*/
|
|
311
|
+
export function encodeBatchCall(payloads_json: string): Uint8Array;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Like `encodeBatchCall` but targets an explicit DataEdge address (#366).
|
|
315
|
+
*/
|
|
316
|
+
export function encodeBatchCallTo(payloads_json: string, data_edge_address: string): Uint8Array;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Encode a fact payload as minimal protobuf wire format.
|
|
320
|
+
*
|
|
321
|
+
* `json`: JSON string with shape:
|
|
322
|
+
* ```json
|
|
323
|
+
* {
|
|
324
|
+
* "id": "...", "timestamp": "...", "owner": "...",
|
|
325
|
+
* "encrypted_blob_hex": "...", "blind_indices": ["..."],
|
|
326
|
+
* "decay_score": 0.8, "source": "...", "content_fp": "...",
|
|
327
|
+
* "agent_id": "...", "encrypted_embedding": "..." (optional)
|
|
328
|
+
* }
|
|
329
|
+
* ```
|
|
330
|
+
*
|
|
331
|
+
* Returns the protobuf bytes as a Uint8Array.
|
|
332
|
+
*/
|
|
333
|
+
export function encodeFactProtobuf(json: string): Uint8Array;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Encode a single fact submission as SimpleAccount.execute() calldata.
|
|
337
|
+
*
|
|
338
|
+
* `protobuf_payload`: raw protobuf bytes (Uint8Array).
|
|
339
|
+
* Returns ABI-encoded calldata (Uint8Array).
|
|
340
|
+
*/
|
|
341
|
+
export function encodeSingleCall(protobuf_payload: Uint8Array): Uint8Array;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Like `encodeSingleCall` but targets an explicit DataEdge address.
|
|
345
|
+
*
|
|
346
|
+
* Chain/environment-aware clients pass the authoritative address from the
|
|
347
|
+
* relay's `/v1/billing/status` `data_edge_address` (#366) — the isolated
|
|
348
|
+
* staging Gnosis DataEdge differs from prod's. Throws on a bad address.
|
|
349
|
+
*/
|
|
350
|
+
export function encodeSingleCallTo(protobuf_payload: Uint8Array, data_edge_address: string): Uint8Array;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Encode a tombstone protobuf for soft-deleting a fact.
|
|
354
|
+
*
|
|
355
|
+
* `version` is optional; missing/0 defaults to `DEFAULT_PROTOBUF_VERSION` (3).
|
|
356
|
+
* Pass `4` to emit a v1-taxonomy tombstone (outer protobuf version = 4).
|
|
357
|
+
*
|
|
358
|
+
* Returns the protobuf bytes as a Uint8Array.
|
|
359
|
+
*/
|
|
360
|
+
export function encodeTombstoneProtobuf(fact_id: string, owner: string, version?: number | null): Uint8Array;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Encrypt a UTF-8 plaintext with XChaCha20-Poly1305.
|
|
364
|
+
*
|
|
365
|
+
* `encryption_key_hex`: 64-char hex string (32 bytes).
|
|
366
|
+
* Returns base64-encoded ciphertext (wire format: nonce || tag || ciphertext).
|
|
367
|
+
*/
|
|
368
|
+
export function encrypt(plaintext: string, encryption_key_hex: string): string;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Enrich an extraction prompt with user profile context.
|
|
372
|
+
*
|
|
373
|
+
* `profile_json`: JSON string of a UserProfile.
|
|
374
|
+
* `base_prompt`: The base extraction prompt to enrich.
|
|
375
|
+
* Returns the enriched prompt string.
|
|
376
|
+
*/
|
|
377
|
+
export function enrichExtractionPrompt(profile_json: string, base_prompt: string): string;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Convert a feedback entry into a counterexample for weight tuning. Returns
|
|
381
|
+
* JSON Counterexample or the literal string "null" if the entry has no signal.
|
|
382
|
+
*/
|
|
383
|
+
export function feedbackToCounterexample(entry_json: string): string;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Filter resolution actions by mode ("active" passes through, "shadow"/"off" returns empty).
|
|
387
|
+
*
|
|
388
|
+
* Returns a JSON array of `ResolutionAction`.
|
|
389
|
+
*/
|
|
390
|
+
export function filterShadowMode(actions_json: string, mode: string): string;
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* WASM binding for `find_best_near_duplicate`.
|
|
394
|
+
*
|
|
395
|
+
* `new_embedding_json`: JSON array of floats (embedding vector).
|
|
396
|
+
* `existing_json`: JSON array of `{ id: string, embedding: number[] }` objects.
|
|
397
|
+
* `threshold`: Cosine similarity threshold.
|
|
398
|
+
*
|
|
399
|
+
* Returns JSON `{ fact_id: string, similarity: number }` or null.
|
|
400
|
+
*/
|
|
401
|
+
export function findBestNearDuplicate(new_embedding_json: string, existing_json: string, threshold: number): any;
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Find a decision-log entry matching a fact as winner or loser.
|
|
405
|
+
* Returns the JSON-serialized DecisionLogEntry, or the literal string "null".
|
|
406
|
+
*/
|
|
407
|
+
export function findDecisionForPin(fact_id: string, role: string, log_content: string): string;
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Find the loser claim JSON from the decision log for a given fact ID.
|
|
411
|
+
* Returns the loser_claim_json string, or the literal string "null" if not found.
|
|
412
|
+
*/
|
|
413
|
+
export function findLoserClaimInDecisionLog(fact_id: string, log_content: string): string;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* WASM binding for `find_near_duplicate` (deprecated — use `findBestNearDuplicate`).
|
|
417
|
+
*
|
|
418
|
+
* **Deprecated since core 1.5.0; scheduled for removal in core 3.0.** Returns
|
|
419
|
+
* the *first* match above `threshold`, not the highest-similarity one. Migrate
|
|
420
|
+
* npm consumers to `findBestNearDuplicate`.
|
|
421
|
+
*
|
|
422
|
+
* `new_embedding`: Float32Array of the new fact's embedding.
|
|
423
|
+
* `existing_json`: JSON array of `{ id: string, embedding: number[] }` objects.
|
|
424
|
+
* `threshold`: Cosine similarity threshold.
|
|
425
|
+
*
|
|
426
|
+
* Returns `null` if no duplicate found, or a string (the duplicate fact ID).
|
|
427
|
+
*/
|
|
428
|
+
export function findNearDuplicate(new_embedding: Float32Array, existing_json: string, threshold: number): any;
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Unix seconds → `"YYYY-MM-DD"` (UTC). Returns `""` for `0` or negative.
|
|
432
|
+
*
|
|
433
|
+
* Maps directly to [`crate::recall_context::format_memory_date`].
|
|
434
|
+
*/
|
|
435
|
+
export function formatMemoryDate(created_at_unix: bigint): string;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Build the full recall-context block: header + one line per memory item.
|
|
439
|
+
*
|
|
440
|
+
* `items_json`: JSON array of `{ category, text, created_at }`. Any field
|
|
441
|
+
* may be absent (defaults to empty string / 0). Bad or empty JSON → header
|
|
442
|
+
* only (no panic).
|
|
443
|
+
*
|
|
444
|
+
* Output line format:
|
|
445
|
+
* - With date: `"- [category] (YYYY-MM-DD) text"`
|
|
446
|
+
* - Without date: `"- [category] text"`
|
|
447
|
+
*
|
|
448
|
+
* `now_unix`: current time as Unix seconds (used in the header date).
|
|
449
|
+
*/
|
|
450
|
+
export function formatRecallContext(items_json: string, now_unix: bigint): string;
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Generate blind indices (SHA-256 token hashes) for a text string.
|
|
454
|
+
*
|
|
455
|
+
* Returns a JSON array of hex strings.
|
|
456
|
+
*/
|
|
457
|
+
export function generateBlindIndices(text: string): any;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Compute HMAC-SHA256 content fingerprint.
|
|
461
|
+
*
|
|
462
|
+
* `dedup_key_hex`: 64-char hex string (32 bytes).
|
|
463
|
+
* Returns 64-char hex fingerprint.
|
|
464
|
+
*/
|
|
465
|
+
export function generateContentFingerprint(plaintext: string, dedup_key_hex: string): string;
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Generate trapdoors for multiple query reformulations (expansion pipeline).
|
|
469
|
+
*
|
|
470
|
+
* `queries_json`: JSON array of query strings (original + reformulations).
|
|
471
|
+
* `embeddings_json`: JSON array of Float32Array-compatible arrays (one per query).
|
|
472
|
+
* `lsh_hasher`: A `WasmLshHasher` instance.
|
|
473
|
+
*
|
|
474
|
+
* Returns a JsValue (JSON array of trapdoor-string arrays, one per query).
|
|
475
|
+
*/
|
|
476
|
+
export function generateExpansionTrapdoors(queries_json: string, embeddings_json: string, lsh_hasher: WasmLshHasher): any;
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Generate all search trapdoors for a query (word hashes + LSH bucket hashes).
|
|
480
|
+
*
|
|
481
|
+
* `query`: The search query text.
|
|
482
|
+
* `query_embedding`: Float32Array of the query embedding.
|
|
483
|
+
* `lsh_hasher`: A `WasmLshHasher` instance.
|
|
484
|
+
*
|
|
485
|
+
* Returns a JsValue (JSON array of hex-encoded trapdoor strings).
|
|
486
|
+
*/
|
|
487
|
+
export function generateSearchTrapdoors(query: string, query_embedding: Float32Array, lsh_hasher: WasmLshHasher): any;
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Get the GraphQL query string for broadened (fallback) search.
|
|
491
|
+
*/
|
|
492
|
+
export function getBroadenedSearchQuery(): string;
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Get the canonical v1 compaction system prompt.
|
|
496
|
+
*
|
|
497
|
+
* Used on end-of-context surfaces where the importance floor is 5 rather
|
|
498
|
+
* than the default 6.
|
|
499
|
+
*/
|
|
500
|
+
export function getCompactionSystemPrompt(): string;
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* WASM binding: get the consolidation cosine threshold constant.
|
|
504
|
+
*/
|
|
505
|
+
export function getConsolidationCosineThreshold(): number;
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Get the GraphQL query string for fact count.
|
|
509
|
+
*/
|
|
510
|
+
export function getCountQuery(): string;
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Get the DataEdge contract address constant.
|
|
514
|
+
*/
|
|
515
|
+
export function getDataEdgeAddress(): string;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Source tag for debrief items.
|
|
519
|
+
*/
|
|
520
|
+
export function getDebriefSource(): string;
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Get the canonical debrief system prompt template.
|
|
524
|
+
*
|
|
525
|
+
* Contains `{already_stored_facts}` placeholder.
|
|
526
|
+
*/
|
|
527
|
+
export function getDebriefSystemPrompt(): string;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Get the EntryPoint v0.7 address constant.
|
|
531
|
+
*/
|
|
532
|
+
export function getEntryPointAddress(): string;
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Get the GraphQL query string for paginated export.
|
|
536
|
+
*/
|
|
537
|
+
export function getExportQuery(): string;
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Get the canonical v1 merged-topic extraction system prompt.
|
|
541
|
+
*
|
|
542
|
+
* Single source of truth across all TotalReclaw clients — TS/WASM
|
|
543
|
+
* callers get the same bytes the Python `totalreclaw_core` module
|
|
544
|
+
* returns from `get_extraction_system_prompt()`. Includes the Rule 6
|
|
545
|
+
* meta-request filter (see the docstring on `prompts.rs`).
|
|
546
|
+
*/
|
|
547
|
+
export function getExtractionSystemPrompt(): string;
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Get the maximum batch size constant.
|
|
551
|
+
*/
|
|
552
|
+
export function getMaxBatchSize(): number;
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Maximum debrief items (5).
|
|
556
|
+
*/
|
|
557
|
+
export function getMaxDebriefItems(): number;
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Minimum messages for debrief (8 = 4 turns).
|
|
561
|
+
*/
|
|
562
|
+
export function getMinDebriefMessages(): number;
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Get the page size constant.
|
|
566
|
+
*/
|
|
567
|
+
export function getPageSize(): number;
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Get the GraphQL query string for blind index search.
|
|
571
|
+
*/
|
|
572
|
+
export function getSearchQuery(): string;
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Get the SimpleAccountFactory address constant.
|
|
576
|
+
*/
|
|
577
|
+
export function getSimpleAccountFactory(): string;
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* WASM binding: get the store-time dedup cosine threshold constant.
|
|
581
|
+
*/
|
|
582
|
+
export function getStoreDedupCosineThreshold(): number;
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* WASM binding: get the store-time dedup max candidates constant.
|
|
586
|
+
*/
|
|
587
|
+
export function getStoreDedupMaxCandidates(): number;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Get the trapdoor batch size constant.
|
|
591
|
+
*/
|
|
592
|
+
export function getTrapdoorBatchSize(): number;
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Get the v1 type → short-form category mapping.
|
|
596
|
+
*
|
|
597
|
+
* Returns a plain JS object `{ claim: "claim", preference: "pref",
|
|
598
|
+
* directive: "rule", commitment: "goal", episode: "epi",
|
|
599
|
+
* summary: "sum" }`.
|
|
600
|
+
*
|
|
601
|
+
* Uses `js_sys::Object.set` directly so the result is a plain JS
|
|
602
|
+
* object (not a `Map`) regardless of serde-wasm-bindgen defaults,
|
|
603
|
+
* matching how TypeScript clients consume the mapping via bracket
|
|
604
|
+
* access (`map[type]`).
|
|
605
|
+
*/
|
|
606
|
+
export function getTypeToCategory(): any;
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Get the canonical list of v1 memory types.
|
|
610
|
+
*
|
|
611
|
+
* Returns a JS array of six strings: `["claim", "preference",
|
|
612
|
+
* "directive", "commitment", "episode", "summary"]`.
|
|
613
|
+
*/
|
|
614
|
+
export function getValidMemoryTypes(): any;
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Compute the ERC-4337 v0.7 UserOp hash for signing.
|
|
618
|
+
*
|
|
619
|
+
* `userop_json`: JSON string of a UserOperationV7 struct.
|
|
620
|
+
* `entrypoint`: EntryPoint address (0x-prefixed).
|
|
621
|
+
* `chain_id`: Chain ID (e.g. 84532 for Base Sepolia).
|
|
622
|
+
* Returns 32-byte hash as hex string.
|
|
623
|
+
*/
|
|
624
|
+
export function hashUserOp(userop_json: string, entrypoint: string, chain_id: bigint): string;
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* Convert a subgraph hex blob to base64 for decryption.
|
|
628
|
+
*
|
|
629
|
+
* `hex_blob`: Hex string (optionally `0x`-prefixed) from the subgraph.
|
|
630
|
+
* Returns base64-encoded bytes, or null if the hex is invalid.
|
|
631
|
+
*/
|
|
632
|
+
export function hexBlobToBase64(hex_blob: string): string | undefined;
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Check whether a JSON-serialized claim has pinned status.
|
|
636
|
+
*/
|
|
637
|
+
export function isPinnedClaim(claim_json: string): boolean;
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Check whether a JSON-encoded claim is pinned, recognizing both the v0
|
|
641
|
+
* short-key sentinel (`st == "p"`) and the v1.1 field (`pin_status ==
|
|
642
|
+
* "pinned"`). Returns `false` on any parse failure.
|
|
643
|
+
*
|
|
644
|
+
* Wrapper around [`crate::claims::is_pinned_json`] for TS clients.
|
|
645
|
+
*/
|
|
646
|
+
export function isPinnedClaimJson(claim_json: string): boolean;
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Runtime guard: is `value` a valid v1 memory type?
|
|
650
|
+
*/
|
|
651
|
+
export function isValidMemoryType(value: string): boolean;
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Return the v1 legacy-claim fallback weight (applied to candidates that
|
|
655
|
+
* have no `source` field).
|
|
656
|
+
*/
|
|
657
|
+
export function legacyClaimFallbackWeight(): number;
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Map a v1 type to its short-form category key.
|
|
661
|
+
*
|
|
662
|
+
* Returns `null` if `value` is not one of the six v1 types.
|
|
663
|
+
*/
|
|
664
|
+
export function mapTypeToCategory(value: string): any;
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* Merge multiple SubgraphFact sets from parallel query reformulations via RRF.
|
|
668
|
+
*
|
|
669
|
+
* `fact_sets_json`: JSON array of SubgraphFact arrays (one array per reformulation).
|
|
670
|
+
* `rrf_k`: RRF k-parameter (use 60.0 for default behaviour).
|
|
671
|
+
*
|
|
672
|
+
* Returns a JsValue (merged, deduplicated SubgraphFact array sorted by RRF score).
|
|
673
|
+
*/
|
|
674
|
+
export function mergeExpansionResults(fact_sets_json: string, rrf_k: number): any;
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Normalize an entity name (NFC, lowercase, trim, collapse whitespace).
|
|
678
|
+
*/
|
|
679
|
+
export function normalizeEntityName(name: string): string;
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Normalize text (NFC, lowercase, collapse whitespace, trim).
|
|
683
|
+
*/
|
|
684
|
+
export function normalizeText(text: string): string;
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Parse a broadened search GraphQL response into SubgraphFact list.
|
|
688
|
+
*
|
|
689
|
+
* `response_json`: Raw JSON string from the GraphQL response.
|
|
690
|
+
* Returns a JsValue (JSON array of SubgraphFact objects).
|
|
691
|
+
*/
|
|
692
|
+
export function parseBroadenedResponse(response_json: string): any;
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Parse a decrypted blob as a Claim, falling back to legacy formats.
|
|
696
|
+
* Returns JSON-serialized Claim.
|
|
697
|
+
*/
|
|
698
|
+
export function parseClaimOrLegacy(decrypted: string): string;
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Parse a debrief LLM response into validated items.
|
|
702
|
+
*
|
|
703
|
+
* Returns a JSON array of `{ text, type, importance }` objects.
|
|
704
|
+
*/
|
|
705
|
+
export function parseDebriefResponse(response: string): any;
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* Parse an LLM digest response.
|
|
709
|
+
* Returns JSON-serialized ParsedDigestResponse.
|
|
710
|
+
*/
|
|
711
|
+
export function parseDigestResponse(raw: string): string;
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Parse a Gemini export (JSON or saved-info text) into a `ParseResult`.
|
|
715
|
+
*/
|
|
716
|
+
export function parseGemini(input: string): any;
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Case-insensitive parse of a memory source string. Unknown input returns "user-inferred".
|
|
720
|
+
*/
|
|
721
|
+
export function parseMemorySource(s: string): string;
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Case-insensitive parse of a memory type string. Unknown input returns "claim".
|
|
725
|
+
*/
|
|
726
|
+
export function parseMemoryTypeV1(s: string): string;
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* Case-insensitive parse of a v1.1 pin_status string. Unknown input returns "unpinned".
|
|
730
|
+
*/
|
|
731
|
+
export function parsePinStatus(s: string): string;
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Parse a batch profiling LLM response into a PartialProfile.
|
|
735
|
+
*
|
|
736
|
+
* `llm_output`: Raw LLM response string.
|
|
737
|
+
* Returns a JsValue (PartialProfile object).
|
|
738
|
+
*/
|
|
739
|
+
export function parseProfileBatchResponse(llm_output: string): any;
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* Parse the merge LLM response into a UserProfile.
|
|
743
|
+
*
|
|
744
|
+
* `llm_output`: Raw LLM response string.
|
|
745
|
+
* Returns a JsValue (UserProfile object).
|
|
746
|
+
*/
|
|
747
|
+
export function parseProfileResponse(llm_output: string): any;
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* Parse a blind index search GraphQL response into SubgraphFact list.
|
|
751
|
+
*
|
|
752
|
+
* `response_json`: Raw JSON string from the GraphQL response.
|
|
753
|
+
* Returns a JsValue (JSON array of SubgraphFact objects).
|
|
754
|
+
*/
|
|
755
|
+
export function parseSearchResponse(response_json: string): any;
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Parse the triage LLM response into chunk decisions.
|
|
759
|
+
*
|
|
760
|
+
* `llm_output`: Raw LLM response string.
|
|
761
|
+
* Returns a JsValue (JSON array of ChunkDecision objects).
|
|
762
|
+
*/
|
|
763
|
+
export function parseTriageResponse(llm_output: string): any;
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Parse a WeightsFile from JSON; rejects unknown versions and malformed input.
|
|
767
|
+
*/
|
|
768
|
+
export function parseWeightsFile(content: string): string;
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Compute the [`PinTier`]'s multiplicative boost at a given timestamp.
|
|
772
|
+
*
|
|
773
|
+
* `tier_json`: internally-tagged JSON, e.g. `{"tier":"soft","pinned_at":1716000000}`,
|
|
774
|
+
* `{"tier":"hard"}`, `{"tier":"none"}`.
|
|
775
|
+
* `now_unix`: seconds since epoch.
|
|
776
|
+
* `config_json`: JSON of [`PinConfig`], e.g. `{"soft_half_life_days":90,"soft_max_boost":1.5,"hard_boost":1.5}`.
|
|
777
|
+
*
|
|
778
|
+
* Returns the multiplicative boost factor (1.0 for `none`).
|
|
779
|
+
*/
|
|
780
|
+
export function pinBoost(tier_json: string, now_unix: bigint, config_json: string): number;
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* Prepare a fact for on-chain storage.
|
|
784
|
+
*
|
|
785
|
+
* Pure computation: encrypt, generate indices, encode protobuf.
|
|
786
|
+
* Does NOT submit -- the host handles I/O.
|
|
787
|
+
*
|
|
788
|
+
* `encryption_key_hex`: 64-char hex string (32 bytes).
|
|
789
|
+
* `dedup_key_hex`: 64-char hex string (32 bytes).
|
|
790
|
+
* `lsh_hasher`: A `WasmLshHasher` instance.
|
|
791
|
+
* `embedding`: Float32Array of the pre-computed embedding vector.
|
|
792
|
+
* `importance`: Importance score on 1-10 scale (normalized to 0.0-1.0).
|
|
793
|
+
*
|
|
794
|
+
* Returns a JSON string with `PreparedFact` fields.
|
|
795
|
+
*/
|
|
796
|
+
export function prepareFact(text: string, encryption_key_hex: string, dedup_key_hex: string, lsh_hasher: WasmLshHasher, embedding: Float32Array, importance: number, source: string, owner: string, agent_id: string): any;
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Prepare a fact with a pre-normalized decay score (already 0.0-1.0).
|
|
800
|
+
*
|
|
801
|
+
* Same as `prepareFact()` but takes a raw decay score.
|
|
802
|
+
*/
|
|
803
|
+
export function prepareFactWithDecayScore(text: string, encryption_key_hex: string, dedup_key_hex: string, lsh_hasher: WasmLshHasher, embedding: Float32Array, decay_score: number, source: string, owner: string, agent_id: string): any;
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Prepare a tombstone (soft-delete) protobuf.
|
|
807
|
+
*
|
|
808
|
+
* Returns the protobuf bytes as a Uint8Array.
|
|
809
|
+
*/
|
|
810
|
+
export function prepareTombstone(fact_id: string, owner: string): Uint8Array;
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* Parse JSONL content. Returns JSON: `{"entries": [...], "warnings": [...]}`.
|
|
814
|
+
*/
|
|
815
|
+
export function readFeedbackJsonl(content: string): string;
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* Build the recall-context header string (current-date + temporal-reasoning nudge).
|
|
819
|
+
*
|
|
820
|
+
* `now_unix`: current time as Unix seconds.
|
|
821
|
+
* Returns the header with a trailing newline, e.g.:
|
|
822
|
+
* `"## Relevant memories from TotalReclaw\nThe current date is 2024-01-15. ..."`
|
|
823
|
+
*/
|
|
824
|
+
export function recallContextHeader(now_unix: bigint): string;
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* Rerank candidates using BM25 + Cosine + RRF fusion.
|
|
828
|
+
*
|
|
829
|
+
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
|
|
830
|
+
* Returns a JsValue (array of `RankedResult` objects).
|
|
831
|
+
*/
|
|
832
|
+
export function rerank(query: string, query_embedding: Float32Array, candidates_json: string, top_k: number): any;
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Rerank candidates with a config flag (Retrieval v2 Tier 1).
|
|
836
|
+
*
|
|
837
|
+
* When `apply_source_weights` is `true`, each candidate's final score is
|
|
838
|
+
* multiplied by the provenance weight from its `source` field (legacy
|
|
839
|
+
* candidates without `source` use the v0 fallback weight).
|
|
840
|
+
*
|
|
841
|
+
* `candidates_json`: JSON array of `{ id, text, embedding, timestamp, source? }` objects.
|
|
842
|
+
* Returns a JsValue (array of `RankedResult` objects including `source_weight`).
|
|
843
|
+
*/
|
|
844
|
+
export function rerankWithConfig(query: string, query_embedding: Float32Array, candidates_json: string, top_k: number, apply_source_weights: boolean): any;
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* Run the resolution formula on two contradicting claims; returns ResolutionOutcome JSON.
|
|
848
|
+
*/
|
|
849
|
+
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;
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* Orchestrate contradiction detection + resolution for a new claim against candidates.
|
|
853
|
+
*
|
|
854
|
+
* Returns a JSON array of `ResolutionAction`.
|
|
855
|
+
*/
|
|
856
|
+
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;
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* Apply pin-status and tie-zone checks to a resolution outcome.
|
|
860
|
+
* Returns a JSON-serialized `ResolutionAction`.
|
|
861
|
+
*/
|
|
862
|
+
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;
|
|
863
|
+
|
|
864
|
+
/**
|
|
865
|
+
* Keep only the most recent `max_lines` non-empty feedback log lines. Non-falliable.
|
|
866
|
+
*/
|
|
867
|
+
export function rotateFeedbackLog(content: string, max_lines: bigint): string;
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* Centroid-walk session segmentation over time-ordered turns.
|
|
871
|
+
*
|
|
872
|
+
* Mirrors `session_segmentation.py:segment_sessions` byte-for-byte.
|
|
873
|
+
*
|
|
874
|
+
* # Inputs (JSON strings, per this module's convention)
|
|
875
|
+
* - `timestamps_json`: JSON array of Unix seconds or `null`, e.g.
|
|
876
|
+
* `"[0.0, null, 5000.0]"`. `null` = 0-gap to the previous turn.
|
|
877
|
+
* - `embeddings_json`: JSON array of L2-normalised vectors, e.g.
|
|
878
|
+
* `"[[1.0,0.0],[0.9,0.1]]"`.
|
|
879
|
+
* - `gap_seconds`: min time gap (strict `>`) forcing a new session (e.g. 1800).
|
|
880
|
+
* - `sim_threshold`: cosine threshold (strict `<` splits; e.g. 0.55).
|
|
881
|
+
*
|
|
882
|
+
* # Returns
|
|
883
|
+
* A `JsValue` — array of sessions, each an array of turn indices
|
|
884
|
+
* (`number[][]`), contiguous and ascending. Bad JSON → `JsError`.
|
|
885
|
+
*/
|
|
886
|
+
export function segmentSessions(timestamps_json: string, embeddings_json: string, gap_seconds: number, sim_threshold: number): any;
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* Serialize a WeightsFile JSON to pretty-printed JSON (2-space indent).
|
|
890
|
+
*/
|
|
891
|
+
export function serializeWeightsFile(file_json: string): string;
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* WASM binding: determine if a new fact should supersede an existing one.
|
|
895
|
+
*/
|
|
896
|
+
export function shouldSupersede(new_importance: number, existing_importance: number): boolean;
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* Sign a UserOp hash with an ECDSA private key (EIP-191 prefixed).
|
|
900
|
+
*
|
|
901
|
+
* `hash_hex`: 64-char hex string (32-byte UserOp hash).
|
|
902
|
+
* `private_key_hex`: 64-char hex string (32-byte private key).
|
|
903
|
+
* Returns 65-byte signature as hex string (r + s + v).
|
|
904
|
+
*/
|
|
905
|
+
export function signUserOp(hash_hex: string, private_key_hex: string): string;
|
|
906
|
+
|
|
907
|
+
/**
|
|
908
|
+
* Return the source weight multiplier for a given source string.
|
|
909
|
+
*
|
|
910
|
+
* Accepted values: "user" | "user-inferred" | "assistant" | "external" | "derived".
|
|
911
|
+
*
|
|
912
|
+
* Unknown input is routed through `MemorySource::from_str_lossy` which
|
|
913
|
+
* falls back to `user-inferred` (v2-lenient weight 0.95). Callers who need
|
|
914
|
+
* the "no source field at all" fallback (weight 0.85) should call
|
|
915
|
+
* `legacyClaimFallbackWeight()` instead.
|
|
916
|
+
*/
|
|
917
|
+
export function sourceWeight(source: string): number;
|
|
918
|
+
|
|
919
|
+
/**
|
|
920
|
+
* Validate a Memory Taxonomy v1 claim (JSON in, JSON out — canonicalised).
|
|
921
|
+
*
|
|
922
|
+
* Returns the canonical JSON encoding on success. Throws on any schema
|
|
923
|
+
* violation (wrong type token, missing required field, wrong schema_version).
|
|
924
|
+
*
|
|
925
|
+
* See `docs/specs/totalreclaw/memory-taxonomy-v1.md`.
|
|
926
|
+
*/
|
|
927
|
+
export function validateMemoryClaimV1(claim_json: string): string;
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* Default polling interval (ms) — exposed so host adapters share the same
|
|
931
|
+
* default without re-declaring the constant.
|
|
932
|
+
*/
|
|
933
|
+
export function wasmConfirmIndexedDefaultPollMs(): number;
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* Default total timeout (ms) — exposed so host adapters share the same default.
|
|
937
|
+
*/
|
|
938
|
+
export function wasmConfirmIndexedDefaultTimeoutMs(): number;
|
|
939
|
+
|
|
940
|
+
/**
|
|
941
|
+
* Parse a subgraph response JSON and return whether the fact is indexed +
|
|
942
|
+
* active. Returns `true` when the read-after-write loop can stop.
|
|
943
|
+
*/
|
|
944
|
+
export function wasmConfirmIndexedParse(response_json: string): boolean;
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* GraphQL query string used to confirm a fact id has been indexed.
|
|
948
|
+
* Pair with `wasmConfirmIndexedParse` in a host-side polling loop.
|
|
949
|
+
*/
|
|
950
|
+
export function wasmConfirmIndexedQuery(): string;
|
|
951
|
+
|
|
952
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
953
|
+
|
|
954
|
+
export interface InitOutput {
|
|
955
|
+
readonly memory: WebAssembly.Memory;
|
|
956
|
+
readonly CONTRADICTION_CANDIDATE_CAP: () => number;
|
|
957
|
+
readonly DECISION_LOG_MAX_LINES: () => number;
|
|
958
|
+
readonly TIE_ZONE_SCORE_TOLERANCE: () => number;
|
|
959
|
+
readonly appendDecisionEntry: (a: number, b: number, c: number, d: number) => [number, number];
|
|
960
|
+
readonly appendFeedbackToJsonl: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
961
|
+
readonly applyFeedback: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
962
|
+
readonly assembleDigestFromLlm: (a: number, b: number, c: number, d: number, e: bigint) => [number, number, number, number];
|
|
963
|
+
readonly buildDecisionLogEntries: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: bigint) => [number, number, number, number];
|
|
964
|
+
readonly buildDigestPrompt: (a: number, b: number) => [number, number, number, number];
|
|
965
|
+
readonly buildFeedbackFromDecision: (a: number, b: number, c: number, d: number, e: bigint) => [number, number];
|
|
966
|
+
readonly buildTemplateDigest: (a: number, b: number, c: bigint) => [number, number, number, number];
|
|
967
|
+
readonly canonicalizeClaim: (a: number, b: number) => [number, number, number, number];
|
|
968
|
+
readonly computeAuthKeyHash: (a: number, b: number) => [number, number, number, number];
|
|
969
|
+
readonly computeScoreComponents: (a: number, b: number, c: bigint, d: number, e: number) => [number, number, number, number];
|
|
970
|
+
readonly decrypt: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
971
|
+
readonly defaultResolutionWeights: () => [number, number, number, number];
|
|
972
|
+
readonly defaultWeightsFile: (a: bigint) => [number, number, number, number];
|
|
973
|
+
readonly deriveKeysFromMnemonic: (a: number, b: number) => [number, number, number];
|
|
974
|
+
readonly deriveKeysFromMnemonicLenient: (a: number, b: number) => [number, number, number];
|
|
975
|
+
readonly deriveLshSeed: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
976
|
+
readonly detectContradictions: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number, number, number];
|
|
977
|
+
readonly deterministicEntityId: (a: number, b: number) => [number, number];
|
|
978
|
+
readonly encodeBatchCall: (a: number, b: number) => [number, number, number, number];
|
|
979
|
+
readonly encodeBatchCallTo: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
980
|
+
readonly encodeSingleCall: (a: number, b: number) => [number, number];
|
|
981
|
+
readonly encodeSingleCallTo: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
982
|
+
readonly encrypt: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
983
|
+
readonly feedbackToCounterexample: (a: number, b: number) => [number, number, number, number];
|
|
984
|
+
readonly filterShadowMode: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
985
|
+
readonly findDecisionForPin: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
986
|
+
readonly findLoserClaimInDecisionLog: (a: number, b: number, c: number, d: number) => [number, number];
|
|
987
|
+
readonly generateBlindIndices: (a: number, b: number) => [number, number, number];
|
|
988
|
+
readonly generateContentFingerprint: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
989
|
+
readonly getDataEdgeAddress: () => [number, number];
|
|
990
|
+
readonly getEntryPointAddress: () => [number, number];
|
|
991
|
+
readonly getMaxBatchSize: () => number;
|
|
992
|
+
readonly getSimpleAccountFactory: () => [number, number];
|
|
993
|
+
readonly hashUserOp: (a: number, b: number, c: number, d: number, e: bigint) => [number, number, number, number];
|
|
994
|
+
readonly isPinnedClaim: (a: number, b: number) => number;
|
|
995
|
+
readonly normalizeEntityName: (a: number, b: number) => [number, number];
|
|
996
|
+
readonly normalizeText: (a: number, b: number) => [number, number];
|
|
997
|
+
readonly parseClaimOrLegacy: (a: number, b: number) => [number, number, number, number];
|
|
998
|
+
readonly parseDigestResponse: (a: number, b: number) => [number, number, number, number];
|
|
999
|
+
readonly parseWeightsFile: (a: number, b: number) => [number, number, number, number];
|
|
1000
|
+
readonly readFeedbackJsonl: (a: number, b: number) => [number, number, number, number];
|
|
1001
|
+
readonly resolvePair: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: bigint, j: number, k: number) => [number, number, number, number];
|
|
1002
|
+
readonly resolveWithCandidates: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: bigint, n: number) => [number, number, number, number];
|
|
1003
|
+
readonly respectPinInResolution: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number, number, number];
|
|
1004
|
+
readonly rotateFeedbackLog: (a: number, b: number, c: bigint) => [number, number];
|
|
1005
|
+
readonly serializeWeightsFile: (a: number, b: number) => [number, number, number, number];
|
|
1006
|
+
readonly signUserOp: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
1007
|
+
readonly decryptAndRerank: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number];
|
|
1008
|
+
readonly generateExpansionTrapdoors: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
1009
|
+
readonly generateSearchTrapdoors: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
1010
|
+
readonly getBroadenedSearchQuery: () => [number, number];
|
|
1011
|
+
readonly getCountQuery: () => [number, number];
|
|
1012
|
+
readonly getExportQuery: () => [number, number];
|
|
1013
|
+
readonly getPageSize: () => number;
|
|
1014
|
+
readonly getSearchQuery: () => [number, number];
|
|
1015
|
+
readonly getTrapdoorBatchSize: () => number;
|
|
1016
|
+
readonly hexBlobToBase64: (a: number, b: number) => [number, number];
|
|
1017
|
+
readonly mergeExpansionResults: (a: number, b: number, c: number) => [number, number, number];
|
|
1018
|
+
readonly parseBroadenedResponse: (a: number, b: number) => [number, number, number];
|
|
1019
|
+
readonly parseSearchResponse: (a: number, b: number) => [number, number, number];
|
|
1020
|
+
readonly __wbg_wasmlshhasher_free: (a: number, b: number) => void;
|
|
1021
|
+
readonly deriveEoa: (a: number, b: number) => [number, number, number];
|
|
1022
|
+
readonly deriveEoaAddress: (a: number, b: number) => [number, number, number, number];
|
|
1023
|
+
readonly getTypeToCategory: () => [number, number, number];
|
|
1024
|
+
readonly getValidMemoryTypes: () => [number, number, number];
|
|
1025
|
+
readonly isValidMemoryType: (a: number, b: number) => number;
|
|
1026
|
+
readonly mapTypeToCategory: (a: number, b: number) => any;
|
|
1027
|
+
readonly wasmlshhasher_bits: (a: number) => number;
|
|
1028
|
+
readonly wasmlshhasher_dimensions: (a: number) => number;
|
|
1029
|
+
readonly wasmlshhasher_hash: (a: number, b: number, c: number) => [number, number, number];
|
|
1030
|
+
readonly wasmlshhasher_new: (a: number, b: number, c: number) => [number, number, number];
|
|
1031
|
+
readonly wasmlshhasher_tables: (a: number) => number;
|
|
1032
|
+
readonly wasmlshhasher_withParams: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
1033
|
+
readonly classifyPinIntent: (a: number, b: number) => [number, number, number, number];
|
|
1034
|
+
readonly cosineSimilarity: (a: number, b: number, c: number, d: number) => number;
|
|
1035
|
+
readonly defaultPinConfig: () => [number, number, number, number];
|
|
1036
|
+
readonly isPinnedClaimJson: (a: number, b: number) => number;
|
|
1037
|
+
readonly legacyClaimFallbackWeight: () => number;
|
|
1038
|
+
readonly parseMemorySource: (a: number, b: number) => [number, number];
|
|
1039
|
+
readonly parseMemoryTypeV1: (a: number, b: number) => [number, number];
|
|
1040
|
+
readonly parsePinStatus: (a: number, b: number) => [number, number];
|
|
1041
|
+
readonly pinBoost: (a: number, b: number, c: bigint, d: number, e: number) => [number, number, number];
|
|
1042
|
+
readonly rerank: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
1043
|
+
readonly rerankWithConfig: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
|
|
1044
|
+
readonly sourceWeight: (a: number, b: number) => number;
|
|
1045
|
+
readonly validateMemoryClaimV1: (a: number, b: number) => [number, number, number, number];
|
|
1046
|
+
readonly buildBatchCalldataFromPrepared: (a: number, b: number) => [number, number, number, number];
|
|
1047
|
+
readonly buildSingleCalldataFromPrepared: (a: number, b: number) => [number, number, number, number];
|
|
1048
|
+
readonly computeContentFingerprint: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
1049
|
+
readonly encodeFactProtobuf: (a: number, b: number) => [number, number, number, number];
|
|
1050
|
+
readonly encodeTombstoneProtobuf: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
1051
|
+
readonly prepareFact: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number) => [number, number, number];
|
|
1052
|
+
readonly prepareFactWithDecayScore: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number) => [number, number, number];
|
|
1053
|
+
readonly prepareTombstone: (a: number, b: number, c: number, d: number) => [number, number];
|
|
1054
|
+
readonly buildDebriefPrompt: (a: number, b: number) => [number, number, number, number];
|
|
1055
|
+
readonly buildProfileBatchPrompt: (a: number, b: number) => [number, number, number, number];
|
|
1056
|
+
readonly buildProfileMergePrompt: (a: number, b: number) => [number, number, number, number];
|
|
1057
|
+
readonly buildTriagePrompt: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
1058
|
+
readonly chunksToSummaries: (a: number, b: number) => [number, number, number];
|
|
1059
|
+
readonly clusterFacts: (a: number, b: number, c: number) => [number, number, number];
|
|
1060
|
+
readonly enrichExtractionPrompt: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
1061
|
+
readonly findBestNearDuplicate: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
1062
|
+
readonly findNearDuplicate: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
1063
|
+
readonly getCompactionSystemPrompt: () => [number, number];
|
|
1064
|
+
readonly getConsolidationCosineThreshold: () => number;
|
|
1065
|
+
readonly getDebriefSource: () => [number, number];
|
|
1066
|
+
readonly getDebriefSystemPrompt: () => [number, number];
|
|
1067
|
+
readonly getExtractionSystemPrompt: () => [number, number];
|
|
1068
|
+
readonly getMaxDebriefItems: () => number;
|
|
1069
|
+
readonly getMinDebriefMessages: () => number;
|
|
1070
|
+
readonly getStoreDedupCosineThreshold: () => number;
|
|
1071
|
+
readonly getStoreDedupMaxCandidates: () => number;
|
|
1072
|
+
readonly parseDebriefResponse: (a: number, b: number) => [number, number, number];
|
|
1073
|
+
readonly parseProfileBatchResponse: (a: number, b: number) => [number, number, number];
|
|
1074
|
+
readonly parseProfileResponse: (a: number, b: number) => [number, number, number];
|
|
1075
|
+
readonly parseTriageResponse: (a: number, b: number) => [number, number, number];
|
|
1076
|
+
readonly shouldSupersede: (a: number, b: number) => number;
|
|
1077
|
+
readonly formatMemoryDate: (a: bigint) => [number, number];
|
|
1078
|
+
readonly formatRecallContext: (a: number, b: number, c: bigint) => [number, number];
|
|
1079
|
+
readonly parseGemini: (a: number, b: number) => [number, number, number];
|
|
1080
|
+
readonly recallContextHeader: (a: bigint) => [number, number];
|
|
1081
|
+
readonly segmentSessions: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
1082
|
+
readonly wasmConfirmIndexedDefaultPollMs: () => number;
|
|
1083
|
+
readonly wasmConfirmIndexedDefaultTimeoutMs: () => number;
|
|
1084
|
+
readonly wasmConfirmIndexedParse: (a: number, b: number) => [number, number, number];
|
|
1085
|
+
readonly wasmConfirmIndexedQuery: () => [number, number];
|
|
1086
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
1087
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
1088
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
1089
|
+
readonly __externref_table_alloc: () => number;
|
|
1090
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
1091
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
1092
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
1093
|
+
readonly __wbindgen_start: () => void;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
1100
|
+
* a precompiled `WebAssembly.Module`.
|
|
1101
|
+
*
|
|
1102
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
1103
|
+
*
|
|
1104
|
+
* @returns {InitOutput}
|
|
1105
|
+
*/
|
|
1106
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
1107
|
+
|
|
1108
|
+
/**
|
|
1109
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
1110
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
1111
|
+
*
|
|
1112
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
1113
|
+
*
|
|
1114
|
+
* @returns {Promise<InitOutput>}
|
|
1115
|
+
*/
|
|
1116
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|