@totalreclaw/core 1.0.0 → 1.2.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 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": "1.0.0",
4
+ "version": "1.2.0",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,7 +21,7 @@ export class WasmLshHasher {
21
21
  * Create a new LSH hasher with default parameters (20 tables, 32 bits).
22
22
  *
23
23
  * `seed_hex`: hex-encoded seed (>= 32 chars = 16 bytes).
24
- * `dims`: embedding dimensionality (e.g. 1024).
24
+ * `dims`: embedding dimensionality (e.g. 640).
25
25
  */
26
26
  constructor(seed_hex: string, dims: number);
27
27
  /**
@@ -62,6 +62,22 @@ export function buildBatchCalldataFromPrepared(prepared_array_json: string): Uin
62
62
  */
63
63
  export function buildDebriefPrompt(stored_facts_json: string): string;
64
64
 
65
+ /**
66
+ * Build the profiling prompt for a batch of conversation summaries.
67
+ *
68
+ * `summaries_json`: JSON array of ChunkSummary objects.
69
+ * Returns the prompt string.
70
+ */
71
+ export function buildProfileBatchPrompt(summaries_json: string): string;
72
+
73
+ /**
74
+ * Build the merge prompt that combines partial profiles.
75
+ *
76
+ * `partials_json`: JSON array of PartialProfile objects.
77
+ * Returns the prompt string.
78
+ */
79
+ export function buildProfileMergePrompt(partials_json: string): string;
80
+
65
81
  /**
66
82
  * Build ABI-encoded calldata for a single prepared fact.
67
83
  *
@@ -70,6 +86,23 @@ export function buildDebriefPrompt(stored_facts_json: string): string;
70
86
  */
71
87
  export function buildSingleCalldataFromPrepared(prepared_json: string): Uint8Array;
72
88
 
89
+ /**
90
+ * Build the triage prompt for classifying chunks.
91
+ *
92
+ * `profile_json`: JSON string of a UserProfile.
93
+ * `summaries_json`: JSON array of ChunkSummary objects.
94
+ * Returns the prompt string.
95
+ */
96
+ export function buildTriagePrompt(profile_json: string, summaries_json: string): string;
97
+
98
+ /**
99
+ * Convert conversation chunks to summaries.
100
+ *
101
+ * `chunks_json`: JSON array of ConversationChunk objects.
102
+ * Returns a JsValue (JSON array of ChunkSummary objects).
103
+ */
104
+ export function chunksToSummaries(chunks_json: string): any;
105
+
73
106
  /**
74
107
  * Compute SHA-256(authKey) as a hex string.
75
108
  *
@@ -91,7 +124,7 @@ export function computeContentFingerprint(text: string, dedup_key_hex: string):
91
124
  export function cosineSimilarity(a: Float32Array, b: Float32Array): number;
92
125
 
93
126
  /**
94
- * Decrypt a base64-encoded AES-256-GCM blob.
127
+ * Decrypt a base64-encoded XChaCha20-Poly1305 blob.
95
128
  *
96
129
  * `encryption_key_hex`: 64-char hex string (32 bytes).
97
130
  * Returns the plaintext UTF-8 string.
@@ -193,13 +226,22 @@ export function encodeSingleCall(protobuf_payload: Uint8Array): Uint8Array;
193
226
  export function encodeTombstoneProtobuf(fact_id: string, owner: string): Uint8Array;
194
227
 
195
228
  /**
196
- * Encrypt a UTF-8 plaintext with AES-256-GCM.
229
+ * Encrypt a UTF-8 plaintext with XChaCha20-Poly1305.
197
230
  *
198
231
  * `encryption_key_hex`: 64-char hex string (32 bytes).
199
- * Returns base64-encoded ciphertext (wire format: iv || tag || ciphertext).
232
+ * Returns base64-encoded ciphertext (wire format: nonce || tag || ciphertext).
200
233
  */
201
234
  export function encrypt(plaintext: string, encryption_key_hex: string): string;
202
235
 
236
+ /**
237
+ * Enrich an extraction prompt with user profile context.
238
+ *
239
+ * `profile_json`: JSON string of a UserProfile.
240
+ * `base_prompt`: The base extraction prompt to enrich.
241
+ * Returns the enriched prompt string.
242
+ */
243
+ export function enrichExtractionPrompt(profile_json: string, base_prompt: string): string;
244
+
203
245
  /**
204
246
  * WASM binding for `find_near_duplicate`.
205
247
  *
@@ -362,6 +404,22 @@ export function parseBroadenedResponse(response_json: string): any;
362
404
  */
363
405
  export function parseDebriefResponse(response: string): any;
364
406
 
407
+ /**
408
+ * Parse a batch profiling LLM response into a PartialProfile.
409
+ *
410
+ * `llm_output`: Raw LLM response string.
411
+ * Returns a JsValue (PartialProfile object).
412
+ */
413
+ export function parseProfileBatchResponse(llm_output: string): any;
414
+
415
+ /**
416
+ * Parse the merge LLM response into a UserProfile.
417
+ *
418
+ * `llm_output`: Raw LLM response string.
419
+ * Returns a JsValue (UserProfile object).
420
+ */
421
+ export function parseProfileResponse(llm_output: string): any;
422
+
365
423
  /**
366
424
  * Parse a blind index search GraphQL response into SubgraphFact list.
367
425
  *
@@ -370,6 +428,14 @@ export function parseDebriefResponse(response: string): any;
370
428
  */
371
429
  export function parseSearchResponse(response_json: string): any;
372
430
 
431
+ /**
432
+ * Parse the triage LLM response into chunk decisions.
433
+ *
434
+ * `llm_output`: Raw LLM response string.
435
+ * Returns a JsValue (JSON array of ChunkDecision objects).
436
+ */
437
+ export function parseTriageResponse(llm_output: string): any;
438
+
373
439
  /**
374
440
  * Prepare a fact for on-chain storage.
375
441
  *
@@ -61,7 +61,7 @@ class WasmLshHasher {
61
61
  * Create a new LSH hasher with default parameters (20 tables, 32 bits).
62
62
  *
63
63
  * `seed_hex`: hex-encoded seed (>= 32 chars = 16 bytes).
64
- * `dims`: embedding dimensionality (e.g. 1024).
64
+ * `dims`: embedding dimensionality (e.g. 640).
65
65
  * @param {string} seed_hex
66
66
  * @param {number} dims
67
67
  */
@@ -160,6 +160,66 @@ function buildDebriefPrompt(stored_facts_json) {
160
160
  }
161
161
  exports.buildDebriefPrompt = buildDebriefPrompt;
162
162
 
163
+ /**
164
+ * Build the profiling prompt for a batch of conversation summaries.
165
+ *
166
+ * `summaries_json`: JSON array of ChunkSummary objects.
167
+ * Returns the prompt string.
168
+ * @param {string} summaries_json
169
+ * @returns {string}
170
+ */
171
+ function buildProfileBatchPrompt(summaries_json) {
172
+ let deferred3_0;
173
+ let deferred3_1;
174
+ try {
175
+ const ptr0 = passStringToWasm0(summaries_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
176
+ const len0 = WASM_VECTOR_LEN;
177
+ const ret = wasm.buildProfileBatchPrompt(ptr0, len0);
178
+ var ptr2 = ret[0];
179
+ var len2 = ret[1];
180
+ if (ret[3]) {
181
+ ptr2 = 0; len2 = 0;
182
+ throw takeFromExternrefTable0(ret[2]);
183
+ }
184
+ deferred3_0 = ptr2;
185
+ deferred3_1 = len2;
186
+ return getStringFromWasm0(ptr2, len2);
187
+ } finally {
188
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
189
+ }
190
+ }
191
+ exports.buildProfileBatchPrompt = buildProfileBatchPrompt;
192
+
193
+ /**
194
+ * Build the merge prompt that combines partial profiles.
195
+ *
196
+ * `partials_json`: JSON array of PartialProfile objects.
197
+ * Returns the prompt string.
198
+ * @param {string} partials_json
199
+ * @returns {string}
200
+ */
201
+ function buildProfileMergePrompt(partials_json) {
202
+ let deferred3_0;
203
+ let deferred3_1;
204
+ try {
205
+ const ptr0 = passStringToWasm0(partials_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
206
+ const len0 = WASM_VECTOR_LEN;
207
+ const ret = wasm.buildProfileMergePrompt(ptr0, len0);
208
+ var ptr2 = ret[0];
209
+ var len2 = ret[1];
210
+ if (ret[3]) {
211
+ ptr2 = 0; len2 = 0;
212
+ throw takeFromExternrefTable0(ret[2]);
213
+ }
214
+ deferred3_0 = ptr2;
215
+ deferred3_1 = len2;
216
+ return getStringFromWasm0(ptr2, len2);
217
+ } finally {
218
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
219
+ }
220
+ }
221
+ exports.buildProfileMergePrompt = buildProfileMergePrompt;
222
+
163
223
  /**
164
224
  * Build ABI-encoded calldata for a single prepared fact.
165
225
  *
@@ -181,6 +241,59 @@ function buildSingleCalldataFromPrepared(prepared_json) {
181
241
  }
182
242
  exports.buildSingleCalldataFromPrepared = buildSingleCalldataFromPrepared;
183
243
 
244
+ /**
245
+ * Build the triage prompt for classifying chunks.
246
+ *
247
+ * `profile_json`: JSON string of a UserProfile.
248
+ * `summaries_json`: JSON array of ChunkSummary objects.
249
+ * Returns the prompt string.
250
+ * @param {string} profile_json
251
+ * @param {string} summaries_json
252
+ * @returns {string}
253
+ */
254
+ function buildTriagePrompt(profile_json, summaries_json) {
255
+ let deferred4_0;
256
+ let deferred4_1;
257
+ try {
258
+ const ptr0 = passStringToWasm0(profile_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
259
+ const len0 = WASM_VECTOR_LEN;
260
+ const ptr1 = passStringToWasm0(summaries_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
261
+ const len1 = WASM_VECTOR_LEN;
262
+ const ret = wasm.buildTriagePrompt(ptr0, len0, ptr1, len1);
263
+ var ptr3 = ret[0];
264
+ var len3 = ret[1];
265
+ if (ret[3]) {
266
+ ptr3 = 0; len3 = 0;
267
+ throw takeFromExternrefTable0(ret[2]);
268
+ }
269
+ deferred4_0 = ptr3;
270
+ deferred4_1 = len3;
271
+ return getStringFromWasm0(ptr3, len3);
272
+ } finally {
273
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
274
+ }
275
+ }
276
+ exports.buildTriagePrompt = buildTriagePrompt;
277
+
278
+ /**
279
+ * Convert conversation chunks to summaries.
280
+ *
281
+ * `chunks_json`: JSON array of ConversationChunk objects.
282
+ * Returns a JsValue (JSON array of ChunkSummary objects).
283
+ * @param {string} chunks_json
284
+ * @returns {any}
285
+ */
286
+ function chunksToSummaries(chunks_json) {
287
+ const ptr0 = passStringToWasm0(chunks_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
288
+ const len0 = WASM_VECTOR_LEN;
289
+ const ret = wasm.chunksToSummaries(ptr0, len0);
290
+ if (ret[2]) {
291
+ throw takeFromExternrefTable0(ret[1]);
292
+ }
293
+ return takeFromExternrefTable0(ret[0]);
294
+ }
295
+ exports.chunksToSummaries = chunksToSummaries;
296
+
184
297
  /**
185
298
  * Compute SHA-256(authKey) as a hex string.
186
299
  *
@@ -260,7 +373,7 @@ function cosineSimilarity(a, b) {
260
373
  exports.cosineSimilarity = cosineSimilarity;
261
374
 
262
375
  /**
263
- * Decrypt a base64-encoded AES-256-GCM blob.
376
+ * Decrypt a base64-encoded XChaCha20-Poly1305 blob.
264
377
  *
265
378
  * `encryption_key_hex`: 64-char hex string (32 bytes).
266
379
  * Returns the plaintext UTF-8 string.
@@ -537,10 +650,10 @@ function encodeTombstoneProtobuf(fact_id, owner) {
537
650
  exports.encodeTombstoneProtobuf = encodeTombstoneProtobuf;
538
651
 
539
652
  /**
540
- * Encrypt a UTF-8 plaintext with AES-256-GCM.
653
+ * Encrypt a UTF-8 plaintext with XChaCha20-Poly1305.
541
654
  *
542
655
  * `encryption_key_hex`: 64-char hex string (32 bytes).
543
- * Returns base64-encoded ciphertext (wire format: iv || tag || ciphertext).
656
+ * Returns base64-encoded ciphertext (wire format: nonce || tag || ciphertext).
544
657
  * @param {string} plaintext
545
658
  * @param {string} encryption_key_hex
546
659
  * @returns {string}
@@ -569,6 +682,40 @@ function encrypt(plaintext, encryption_key_hex) {
569
682
  }
570
683
  exports.encrypt = encrypt;
571
684
 
685
+ /**
686
+ * Enrich an extraction prompt with user profile context.
687
+ *
688
+ * `profile_json`: JSON string of a UserProfile.
689
+ * `base_prompt`: The base extraction prompt to enrich.
690
+ * Returns the enriched prompt string.
691
+ * @param {string} profile_json
692
+ * @param {string} base_prompt
693
+ * @returns {string}
694
+ */
695
+ function enrichExtractionPrompt(profile_json, base_prompt) {
696
+ let deferred4_0;
697
+ let deferred4_1;
698
+ try {
699
+ const ptr0 = passStringToWasm0(profile_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
700
+ const len0 = WASM_VECTOR_LEN;
701
+ const ptr1 = passStringToWasm0(base_prompt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
702
+ const len1 = WASM_VECTOR_LEN;
703
+ const ret = wasm.enrichExtractionPrompt(ptr0, len0, ptr1, len1);
704
+ var ptr3 = ret[0];
705
+ var len3 = ret[1];
706
+ if (ret[3]) {
707
+ ptr3 = 0; len3 = 0;
708
+ throw takeFromExternrefTable0(ret[2]);
709
+ }
710
+ deferred4_0 = ptr3;
711
+ deferred4_1 = len3;
712
+ return getStringFromWasm0(ptr3, len3);
713
+ } finally {
714
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
715
+ }
716
+ }
717
+ exports.enrichExtractionPrompt = enrichExtractionPrompt;
718
+
572
719
  /**
573
720
  * WASM binding for `find_near_duplicate`.
574
721
  *
@@ -1032,6 +1179,44 @@ function parseDebriefResponse(response) {
1032
1179
  }
1033
1180
  exports.parseDebriefResponse = parseDebriefResponse;
1034
1181
 
1182
+ /**
1183
+ * Parse a batch profiling LLM response into a PartialProfile.
1184
+ *
1185
+ * `llm_output`: Raw LLM response string.
1186
+ * Returns a JsValue (PartialProfile object).
1187
+ * @param {string} llm_output
1188
+ * @returns {any}
1189
+ */
1190
+ function parseProfileBatchResponse(llm_output) {
1191
+ const ptr0 = passStringToWasm0(llm_output, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1192
+ const len0 = WASM_VECTOR_LEN;
1193
+ const ret = wasm.parseProfileBatchResponse(ptr0, len0);
1194
+ if (ret[2]) {
1195
+ throw takeFromExternrefTable0(ret[1]);
1196
+ }
1197
+ return takeFromExternrefTable0(ret[0]);
1198
+ }
1199
+ exports.parseProfileBatchResponse = parseProfileBatchResponse;
1200
+
1201
+ /**
1202
+ * Parse the merge LLM response into a UserProfile.
1203
+ *
1204
+ * `llm_output`: Raw LLM response string.
1205
+ * Returns a JsValue (UserProfile object).
1206
+ * @param {string} llm_output
1207
+ * @returns {any}
1208
+ */
1209
+ function parseProfileResponse(llm_output) {
1210
+ const ptr0 = passStringToWasm0(llm_output, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1211
+ const len0 = WASM_VECTOR_LEN;
1212
+ const ret = wasm.parseProfileResponse(ptr0, len0);
1213
+ if (ret[2]) {
1214
+ throw takeFromExternrefTable0(ret[1]);
1215
+ }
1216
+ return takeFromExternrefTable0(ret[0]);
1217
+ }
1218
+ exports.parseProfileResponse = parseProfileResponse;
1219
+
1035
1220
  /**
1036
1221
  * Parse a blind index search GraphQL response into SubgraphFact list.
1037
1222
  *
@@ -1051,6 +1236,25 @@ function parseSearchResponse(response_json) {
1051
1236
  }
1052
1237
  exports.parseSearchResponse = parseSearchResponse;
1053
1238
 
1239
+ /**
1240
+ * Parse the triage LLM response into chunk decisions.
1241
+ *
1242
+ * `llm_output`: Raw LLM response string.
1243
+ * Returns a JsValue (JSON array of ChunkDecision objects).
1244
+ * @param {string} llm_output
1245
+ * @returns {any}
1246
+ */
1247
+ function parseTriageResponse(llm_output) {
1248
+ const ptr0 = passStringToWasm0(llm_output, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1249
+ const len0 = WASM_VECTOR_LEN;
1250
+ const ret = wasm.parseTriageResponse(ptr0, len0);
1251
+ if (ret[2]) {
1252
+ throw takeFromExternrefTable0(ret[1]);
1253
+ }
1254
+ return takeFromExternrefTable0(ret[0]);
1255
+ }
1256
+ exports.parseTriageResponse = parseTriageResponse;
1257
+
1054
1258
  /**
1055
1259
  * Prepare a fact for on-chain storage.
1056
1260
  *
@@ -1377,6 +1581,11 @@ function __wbg_get_imports() {
1377
1581
  const ret = getStringFromWasm0(arg0, arg1);
1378
1582
  return ret;
1379
1583
  },
1584
+ __wbindgen_cast_0000000000000004: function(arg0) {
1585
+ // Cast intrinsic for `U64 -> Externref`.
1586
+ const ret = BigInt.asUintN(64, arg0);
1587
+ return ret;
1588
+ },
1380
1589
  __wbindgen_init_externref_table: function() {
1381
1590
  const table = wasm.__wbindgen_externrefs;
1382
1591
  const offset = table.grow(4);
Binary file