@totalreclaw/core 0.1.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 +28 -0
- package/totalreclaw_core.d.ts +174 -0
- package/totalreclaw_core.js +793 -0
- package/totalreclaw_core_bg.wasm +0 -0
- package/totalreclaw_core_bg.wasm.d.ts +35 -0
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@totalreclaw/core",
|
|
3
|
+
"description": "TotalReclaw core crypto primitives (WASM) — E2EE, LSH, blind indices, protobuf encoding. Single source of truth for all TotalReclaw clients.",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/p-diogo/totalreclaw",
|
|
9
|
+
"directory": "rust/totalreclaw-core"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"totalreclaw_core_bg.wasm",
|
|
13
|
+
"totalreclaw_core.js",
|
|
14
|
+
"totalreclaw_core.d.ts",
|
|
15
|
+
"totalreclaw_core_bg.wasm.d.ts"
|
|
16
|
+
],
|
|
17
|
+
"main": "totalreclaw_core.js",
|
|
18
|
+
"types": "totalreclaw_core.d.ts",
|
|
19
|
+
"keywords": [
|
|
20
|
+
"totalreclaw",
|
|
21
|
+
"crypto",
|
|
22
|
+
"wasm",
|
|
23
|
+
"aes-256-gcm",
|
|
24
|
+
"lsh",
|
|
25
|
+
"blind-indices",
|
|
26
|
+
"e2ee"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Random Hyperplane LSH hasher (WASM wrapper).
|
|
6
|
+
*
|
|
7
|
+
* Construct with `new WasmLshHasher(seedHex, dims)`.
|
|
8
|
+
* Call `hash(embeddingFloat64Array)` to get bucket IDs.
|
|
9
|
+
*/
|
|
10
|
+
export class WasmLshHasher {
|
|
11
|
+
free(): void;
|
|
12
|
+
[Symbol.dispose](): void;
|
|
13
|
+
/**
|
|
14
|
+
* Hash an embedding vector to blind-hashed bucket IDs.
|
|
15
|
+
*
|
|
16
|
+
* `embedding`: Float64Array of length `dims`.
|
|
17
|
+
* Returns a JSON array of hex strings (one per table).
|
|
18
|
+
*/
|
|
19
|
+
hash(embedding: Float64Array): any;
|
|
20
|
+
/**
|
|
21
|
+
* Create a new LSH hasher with default parameters (20 tables, 32 bits).
|
|
22
|
+
*
|
|
23
|
+
* `seed_hex`: hex-encoded seed (>= 32 chars = 16 bytes).
|
|
24
|
+
* `dims`: embedding dimensionality (e.g. 1024).
|
|
25
|
+
*/
|
|
26
|
+
constructor(seed_hex: string, dims: number);
|
|
27
|
+
/**
|
|
28
|
+
* Create a new LSH hasher with custom parameters.
|
|
29
|
+
*
|
|
30
|
+
* `seed_hex`: hex-encoded seed.
|
|
31
|
+
* `dims`: embedding dimensionality.
|
|
32
|
+
* `n_tables`: number of hash tables.
|
|
33
|
+
* `n_bits`: bits per table.
|
|
34
|
+
*/
|
|
35
|
+
static withParams(seed_hex: string, dims: number, n_tables: number, n_bits: number): WasmLshHasher;
|
|
36
|
+
/**
|
|
37
|
+
* Bits per table.
|
|
38
|
+
*/
|
|
39
|
+
readonly bits: number;
|
|
40
|
+
/**
|
|
41
|
+
* Embedding dimensionality.
|
|
42
|
+
*/
|
|
43
|
+
readonly dimensions: number;
|
|
44
|
+
/**
|
|
45
|
+
* Number of hash tables.
|
|
46
|
+
*/
|
|
47
|
+
readonly tables: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Build the debrief prompt with already-stored facts filled in.
|
|
52
|
+
*
|
|
53
|
+
* `stored_facts_json`: JSON array of strings (fact texts already stored).
|
|
54
|
+
*/
|
|
55
|
+
export function buildDebriefPrompt(stored_facts_json: string): string;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Compute SHA-256(authKey) as a hex string.
|
|
59
|
+
*
|
|
60
|
+
* `auth_key_hex`: 64-char hex string (32 bytes).
|
|
61
|
+
*/
|
|
62
|
+
export function computeAuthKeyHash(auth_key_hex: string): string;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Decrypt a base64-encoded AES-256-GCM blob.
|
|
66
|
+
*
|
|
67
|
+
* `encryption_key_hex`: 64-char hex string (32 bytes).
|
|
68
|
+
* Returns the plaintext UTF-8 string.
|
|
69
|
+
*/
|
|
70
|
+
export function decrypt(encrypted_base64: string, encryption_key_hex: string): string;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Derive encryption keys from a BIP-39 mnemonic (strict checksum validation).
|
|
74
|
+
*
|
|
75
|
+
* Returns a JSON object with hex-encoded keys:
|
|
76
|
+
* `{ auth_key, encryption_key, dedup_key, salt }`
|
|
77
|
+
*/
|
|
78
|
+
export function deriveKeysFromMnemonic(mnemonic: string): any;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Derive encryption keys from a BIP-39 mnemonic (lenient -- skips checksum).
|
|
82
|
+
*
|
|
83
|
+
* Same return format as `deriveKeysFromMnemonic`.
|
|
84
|
+
*/
|
|
85
|
+
export function deriveKeysFromMnemonicLenient(mnemonic: string): any;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Derive the 32-byte LSH seed from a BIP-39 mnemonic and salt.
|
|
89
|
+
*
|
|
90
|
+
* `salt_hex`: 64-char hex string (32 bytes).
|
|
91
|
+
* Returns hex-encoded 32-byte seed.
|
|
92
|
+
*/
|
|
93
|
+
export function deriveLshSeed(mnemonic: string, salt_hex: string): string;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Encode a fact payload as minimal protobuf wire format.
|
|
97
|
+
*
|
|
98
|
+
* `json`: JSON string with shape:
|
|
99
|
+
* ```json
|
|
100
|
+
* {
|
|
101
|
+
* "id": "...", "timestamp": "...", "owner": "...",
|
|
102
|
+
* "encrypted_blob_hex": "...", "blind_indices": ["..."],
|
|
103
|
+
* "decay_score": 0.8, "source": "...", "content_fp": "...",
|
|
104
|
+
* "agent_id": "...", "encrypted_embedding": "..." (optional)
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* Returns the protobuf bytes as a Uint8Array.
|
|
109
|
+
*/
|
|
110
|
+
export function encodeFactProtobuf(json: string): Uint8Array;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Encode a tombstone protobuf for soft-deleting a fact.
|
|
114
|
+
*
|
|
115
|
+
* Returns the protobuf bytes as a Uint8Array.
|
|
116
|
+
*/
|
|
117
|
+
export function encodeTombstoneProtobuf(fact_id: string, owner: string): Uint8Array;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Encrypt a UTF-8 plaintext with AES-256-GCM.
|
|
121
|
+
*
|
|
122
|
+
* `encryption_key_hex`: 64-char hex string (32 bytes).
|
|
123
|
+
* Returns base64-encoded ciphertext (wire format: iv || tag || ciphertext).
|
|
124
|
+
*/
|
|
125
|
+
export function encrypt(plaintext: string, encryption_key_hex: string): string;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Generate blind indices (SHA-256 token hashes) for a text string.
|
|
129
|
+
*
|
|
130
|
+
* Returns a JSON array of hex strings.
|
|
131
|
+
*/
|
|
132
|
+
export function generateBlindIndices(text: string): any;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Compute HMAC-SHA256 content fingerprint.
|
|
136
|
+
*
|
|
137
|
+
* `dedup_key_hex`: 64-char hex string (32 bytes).
|
|
138
|
+
* Returns 64-char hex fingerprint.
|
|
139
|
+
*/
|
|
140
|
+
export function generateContentFingerprint(plaintext: string, dedup_key_hex: string): string;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Source tag for debrief items.
|
|
144
|
+
*/
|
|
145
|
+
export function getDebriefSource(): string;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Get the canonical debrief system prompt template.
|
|
149
|
+
*
|
|
150
|
+
* Contains `{already_stored_facts}` placeholder.
|
|
151
|
+
*/
|
|
152
|
+
export function getDebriefSystemPrompt(): string;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Maximum debrief items (5).
|
|
156
|
+
*/
|
|
157
|
+
export function getMaxDebriefItems(): number;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Minimum messages for debrief (8 = 4 turns).
|
|
161
|
+
*/
|
|
162
|
+
export function getMinDebriefMessages(): number;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Normalize text (NFC, lowercase, collapse whitespace, trim).
|
|
166
|
+
*/
|
|
167
|
+
export function normalizeText(text: string): string;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Parse a debrief LLM response into validated items.
|
|
171
|
+
*
|
|
172
|
+
* Returns a JSON array of `{ text, type, importance }` objects.
|
|
173
|
+
*/
|
|
174
|
+
export function parseDebriefResponse(response: string): any;
|
|
@@ -0,0 +1,793 @@
|
|
|
1
|
+
/* @ts-self-types="./totalreclaw_core.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Random Hyperplane LSH hasher (WASM wrapper).
|
|
5
|
+
*
|
|
6
|
+
* Construct with `new WasmLshHasher(seedHex, dims)`.
|
|
7
|
+
* Call `hash(embeddingFloat64Array)` to get bucket IDs.
|
|
8
|
+
*/
|
|
9
|
+
class WasmLshHasher {
|
|
10
|
+
static __wrap(ptr) {
|
|
11
|
+
ptr = ptr >>> 0;
|
|
12
|
+
const obj = Object.create(WasmLshHasher.prototype);
|
|
13
|
+
obj.__wbg_ptr = ptr;
|
|
14
|
+
WasmLshHasherFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
15
|
+
return obj;
|
|
16
|
+
}
|
|
17
|
+
__destroy_into_raw() {
|
|
18
|
+
const ptr = this.__wbg_ptr;
|
|
19
|
+
this.__wbg_ptr = 0;
|
|
20
|
+
WasmLshHasherFinalization.unregister(this);
|
|
21
|
+
return ptr;
|
|
22
|
+
}
|
|
23
|
+
free() {
|
|
24
|
+
const ptr = this.__destroy_into_raw();
|
|
25
|
+
wasm.__wbg_wasmlshhasher_free(ptr, 0);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Bits per table.
|
|
29
|
+
* @returns {number}
|
|
30
|
+
*/
|
|
31
|
+
get bits() {
|
|
32
|
+
const ret = wasm.wasmlshhasher_bits(this.__wbg_ptr);
|
|
33
|
+
return ret >>> 0;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Embedding dimensionality.
|
|
37
|
+
* @returns {number}
|
|
38
|
+
*/
|
|
39
|
+
get dimensions() {
|
|
40
|
+
const ret = wasm.wasmlshhasher_dimensions(this.__wbg_ptr);
|
|
41
|
+
return ret >>> 0;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Hash an embedding vector to blind-hashed bucket IDs.
|
|
45
|
+
*
|
|
46
|
+
* `embedding`: Float64Array of length `dims`.
|
|
47
|
+
* Returns a JSON array of hex strings (one per table).
|
|
48
|
+
* @param {Float64Array} embedding
|
|
49
|
+
* @returns {any}
|
|
50
|
+
*/
|
|
51
|
+
hash(embedding) {
|
|
52
|
+
const ptr0 = passArrayF64ToWasm0(embedding, wasm.__wbindgen_malloc);
|
|
53
|
+
const len0 = WASM_VECTOR_LEN;
|
|
54
|
+
const ret = wasm.wasmlshhasher_hash(this.__wbg_ptr, ptr0, len0);
|
|
55
|
+
if (ret[2]) {
|
|
56
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
57
|
+
}
|
|
58
|
+
return takeFromExternrefTable0(ret[0]);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create a new LSH hasher with default parameters (20 tables, 32 bits).
|
|
62
|
+
*
|
|
63
|
+
* `seed_hex`: hex-encoded seed (>= 32 chars = 16 bytes).
|
|
64
|
+
* `dims`: embedding dimensionality (e.g. 1024).
|
|
65
|
+
* @param {string} seed_hex
|
|
66
|
+
* @param {number} dims
|
|
67
|
+
*/
|
|
68
|
+
constructor(seed_hex, dims) {
|
|
69
|
+
const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
70
|
+
const len0 = WASM_VECTOR_LEN;
|
|
71
|
+
const ret = wasm.wasmlshhasher_new(ptr0, len0, dims);
|
|
72
|
+
if (ret[2]) {
|
|
73
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
74
|
+
}
|
|
75
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
76
|
+
WasmLshHasherFinalization.register(this, this.__wbg_ptr, this);
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Number of hash tables.
|
|
81
|
+
* @returns {number}
|
|
82
|
+
*/
|
|
83
|
+
get tables() {
|
|
84
|
+
const ret = wasm.wasmlshhasher_tables(this.__wbg_ptr);
|
|
85
|
+
return ret >>> 0;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Create a new LSH hasher with custom parameters.
|
|
89
|
+
*
|
|
90
|
+
* `seed_hex`: hex-encoded seed.
|
|
91
|
+
* `dims`: embedding dimensionality.
|
|
92
|
+
* `n_tables`: number of hash tables.
|
|
93
|
+
* `n_bits`: bits per table.
|
|
94
|
+
* @param {string} seed_hex
|
|
95
|
+
* @param {number} dims
|
|
96
|
+
* @param {number} n_tables
|
|
97
|
+
* @param {number} n_bits
|
|
98
|
+
* @returns {WasmLshHasher}
|
|
99
|
+
*/
|
|
100
|
+
static withParams(seed_hex, dims, n_tables, n_bits) {
|
|
101
|
+
const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
102
|
+
const len0 = WASM_VECTOR_LEN;
|
|
103
|
+
const ret = wasm.wasmlshhasher_withParams(ptr0, len0, dims, n_tables, n_bits);
|
|
104
|
+
if (ret[2]) {
|
|
105
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
106
|
+
}
|
|
107
|
+
return WasmLshHasher.__wrap(ret[0]);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (Symbol.dispose) WasmLshHasher.prototype[Symbol.dispose] = WasmLshHasher.prototype.free;
|
|
111
|
+
exports.WasmLshHasher = WasmLshHasher;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Build the debrief prompt with already-stored facts filled in.
|
|
115
|
+
*
|
|
116
|
+
* `stored_facts_json`: JSON array of strings (fact texts already stored).
|
|
117
|
+
* @param {string} stored_facts_json
|
|
118
|
+
* @returns {string}
|
|
119
|
+
*/
|
|
120
|
+
function buildDebriefPrompt(stored_facts_json) {
|
|
121
|
+
let deferred3_0;
|
|
122
|
+
let deferred3_1;
|
|
123
|
+
try {
|
|
124
|
+
const ptr0 = passStringToWasm0(stored_facts_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
125
|
+
const len0 = WASM_VECTOR_LEN;
|
|
126
|
+
const ret = wasm.buildDebriefPrompt(ptr0, len0);
|
|
127
|
+
var ptr2 = ret[0];
|
|
128
|
+
var len2 = ret[1];
|
|
129
|
+
if (ret[3]) {
|
|
130
|
+
ptr2 = 0; len2 = 0;
|
|
131
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
132
|
+
}
|
|
133
|
+
deferred3_0 = ptr2;
|
|
134
|
+
deferred3_1 = len2;
|
|
135
|
+
return getStringFromWasm0(ptr2, len2);
|
|
136
|
+
} finally {
|
|
137
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.buildDebriefPrompt = buildDebriefPrompt;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Compute SHA-256(authKey) as a hex string.
|
|
144
|
+
*
|
|
145
|
+
* `auth_key_hex`: 64-char hex string (32 bytes).
|
|
146
|
+
* @param {string} auth_key_hex
|
|
147
|
+
* @returns {string}
|
|
148
|
+
*/
|
|
149
|
+
function computeAuthKeyHash(auth_key_hex) {
|
|
150
|
+
let deferred3_0;
|
|
151
|
+
let deferred3_1;
|
|
152
|
+
try {
|
|
153
|
+
const ptr0 = passStringToWasm0(auth_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
154
|
+
const len0 = WASM_VECTOR_LEN;
|
|
155
|
+
const ret = wasm.computeAuthKeyHash(ptr0, len0);
|
|
156
|
+
var ptr2 = ret[0];
|
|
157
|
+
var len2 = ret[1];
|
|
158
|
+
if (ret[3]) {
|
|
159
|
+
ptr2 = 0; len2 = 0;
|
|
160
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
161
|
+
}
|
|
162
|
+
deferred3_0 = ptr2;
|
|
163
|
+
deferred3_1 = len2;
|
|
164
|
+
return getStringFromWasm0(ptr2, len2);
|
|
165
|
+
} finally {
|
|
166
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.computeAuthKeyHash = computeAuthKeyHash;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Decrypt a base64-encoded AES-256-GCM blob.
|
|
173
|
+
*
|
|
174
|
+
* `encryption_key_hex`: 64-char hex string (32 bytes).
|
|
175
|
+
* Returns the plaintext UTF-8 string.
|
|
176
|
+
* @param {string} encrypted_base64
|
|
177
|
+
* @param {string} encryption_key_hex
|
|
178
|
+
* @returns {string}
|
|
179
|
+
*/
|
|
180
|
+
function decrypt(encrypted_base64, encryption_key_hex) {
|
|
181
|
+
let deferred4_0;
|
|
182
|
+
let deferred4_1;
|
|
183
|
+
try {
|
|
184
|
+
const ptr0 = passStringToWasm0(encrypted_base64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
185
|
+
const len0 = WASM_VECTOR_LEN;
|
|
186
|
+
const ptr1 = passStringToWasm0(encryption_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
187
|
+
const len1 = WASM_VECTOR_LEN;
|
|
188
|
+
const ret = wasm.decrypt(ptr0, len0, ptr1, len1);
|
|
189
|
+
var ptr3 = ret[0];
|
|
190
|
+
var len3 = ret[1];
|
|
191
|
+
if (ret[3]) {
|
|
192
|
+
ptr3 = 0; len3 = 0;
|
|
193
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
194
|
+
}
|
|
195
|
+
deferred4_0 = ptr3;
|
|
196
|
+
deferred4_1 = len3;
|
|
197
|
+
return getStringFromWasm0(ptr3, len3);
|
|
198
|
+
} finally {
|
|
199
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.decrypt = decrypt;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Derive encryption keys from a BIP-39 mnemonic (strict checksum validation).
|
|
206
|
+
*
|
|
207
|
+
* Returns a JSON object with hex-encoded keys:
|
|
208
|
+
* `{ auth_key, encryption_key, dedup_key, salt }`
|
|
209
|
+
* @param {string} mnemonic
|
|
210
|
+
* @returns {any}
|
|
211
|
+
*/
|
|
212
|
+
function deriveKeysFromMnemonic(mnemonic) {
|
|
213
|
+
const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
214
|
+
const len0 = WASM_VECTOR_LEN;
|
|
215
|
+
const ret = wasm.deriveKeysFromMnemonic(ptr0, len0);
|
|
216
|
+
if (ret[2]) {
|
|
217
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
218
|
+
}
|
|
219
|
+
return takeFromExternrefTable0(ret[0]);
|
|
220
|
+
}
|
|
221
|
+
exports.deriveKeysFromMnemonic = deriveKeysFromMnemonic;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Derive encryption keys from a BIP-39 mnemonic (lenient -- skips checksum).
|
|
225
|
+
*
|
|
226
|
+
* Same return format as `deriveKeysFromMnemonic`.
|
|
227
|
+
* @param {string} mnemonic
|
|
228
|
+
* @returns {any}
|
|
229
|
+
*/
|
|
230
|
+
function deriveKeysFromMnemonicLenient(mnemonic) {
|
|
231
|
+
const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
232
|
+
const len0 = WASM_VECTOR_LEN;
|
|
233
|
+
const ret = wasm.deriveKeysFromMnemonicLenient(ptr0, len0);
|
|
234
|
+
if (ret[2]) {
|
|
235
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
236
|
+
}
|
|
237
|
+
return takeFromExternrefTable0(ret[0]);
|
|
238
|
+
}
|
|
239
|
+
exports.deriveKeysFromMnemonicLenient = deriveKeysFromMnemonicLenient;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Derive the 32-byte LSH seed from a BIP-39 mnemonic and salt.
|
|
243
|
+
*
|
|
244
|
+
* `salt_hex`: 64-char hex string (32 bytes).
|
|
245
|
+
* Returns hex-encoded 32-byte seed.
|
|
246
|
+
* @param {string} mnemonic
|
|
247
|
+
* @param {string} salt_hex
|
|
248
|
+
* @returns {string}
|
|
249
|
+
*/
|
|
250
|
+
function deriveLshSeed(mnemonic, salt_hex) {
|
|
251
|
+
let deferred4_0;
|
|
252
|
+
let deferred4_1;
|
|
253
|
+
try {
|
|
254
|
+
const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
255
|
+
const len0 = WASM_VECTOR_LEN;
|
|
256
|
+
const ptr1 = passStringToWasm0(salt_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
257
|
+
const len1 = WASM_VECTOR_LEN;
|
|
258
|
+
const ret = wasm.deriveLshSeed(ptr0, len0, ptr1, len1);
|
|
259
|
+
var ptr3 = ret[0];
|
|
260
|
+
var len3 = ret[1];
|
|
261
|
+
if (ret[3]) {
|
|
262
|
+
ptr3 = 0; len3 = 0;
|
|
263
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
264
|
+
}
|
|
265
|
+
deferred4_0 = ptr3;
|
|
266
|
+
deferred4_1 = len3;
|
|
267
|
+
return getStringFromWasm0(ptr3, len3);
|
|
268
|
+
} finally {
|
|
269
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
exports.deriveLshSeed = deriveLshSeed;
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Encode a fact payload as minimal protobuf wire format.
|
|
276
|
+
*
|
|
277
|
+
* `json`: JSON string with shape:
|
|
278
|
+
* ```json
|
|
279
|
+
* {
|
|
280
|
+
* "id": "...", "timestamp": "...", "owner": "...",
|
|
281
|
+
* "encrypted_blob_hex": "...", "blind_indices": ["..."],
|
|
282
|
+
* "decay_score": 0.8, "source": "...", "content_fp": "...",
|
|
283
|
+
* "agent_id": "...", "encrypted_embedding": "..." (optional)
|
|
284
|
+
* }
|
|
285
|
+
* ```
|
|
286
|
+
*
|
|
287
|
+
* Returns the protobuf bytes as a Uint8Array.
|
|
288
|
+
* @param {string} json
|
|
289
|
+
* @returns {Uint8Array}
|
|
290
|
+
*/
|
|
291
|
+
function encodeFactProtobuf(json) {
|
|
292
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
293
|
+
const len0 = WASM_VECTOR_LEN;
|
|
294
|
+
const ret = wasm.encodeFactProtobuf(ptr0, len0);
|
|
295
|
+
if (ret[3]) {
|
|
296
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
297
|
+
}
|
|
298
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
299
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
300
|
+
return v2;
|
|
301
|
+
}
|
|
302
|
+
exports.encodeFactProtobuf = encodeFactProtobuf;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Encode a tombstone protobuf for soft-deleting a fact.
|
|
306
|
+
*
|
|
307
|
+
* Returns the protobuf bytes as a Uint8Array.
|
|
308
|
+
* @param {string} fact_id
|
|
309
|
+
* @param {string} owner
|
|
310
|
+
* @returns {Uint8Array}
|
|
311
|
+
*/
|
|
312
|
+
function encodeTombstoneProtobuf(fact_id, owner) {
|
|
313
|
+
const ptr0 = passStringToWasm0(fact_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
314
|
+
const len0 = WASM_VECTOR_LEN;
|
|
315
|
+
const ptr1 = passStringToWasm0(owner, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
316
|
+
const len1 = WASM_VECTOR_LEN;
|
|
317
|
+
const ret = wasm.encodeTombstoneProtobuf(ptr0, len0, ptr1, len1);
|
|
318
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
319
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
320
|
+
return v3;
|
|
321
|
+
}
|
|
322
|
+
exports.encodeTombstoneProtobuf = encodeTombstoneProtobuf;
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Encrypt a UTF-8 plaintext with AES-256-GCM.
|
|
326
|
+
*
|
|
327
|
+
* `encryption_key_hex`: 64-char hex string (32 bytes).
|
|
328
|
+
* Returns base64-encoded ciphertext (wire format: iv || tag || ciphertext).
|
|
329
|
+
* @param {string} plaintext
|
|
330
|
+
* @param {string} encryption_key_hex
|
|
331
|
+
* @returns {string}
|
|
332
|
+
*/
|
|
333
|
+
function encrypt(plaintext, encryption_key_hex) {
|
|
334
|
+
let deferred4_0;
|
|
335
|
+
let deferred4_1;
|
|
336
|
+
try {
|
|
337
|
+
const ptr0 = passStringToWasm0(plaintext, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
338
|
+
const len0 = WASM_VECTOR_LEN;
|
|
339
|
+
const ptr1 = passStringToWasm0(encryption_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
340
|
+
const len1 = WASM_VECTOR_LEN;
|
|
341
|
+
const ret = wasm.encrypt(ptr0, len0, ptr1, len1);
|
|
342
|
+
var ptr3 = ret[0];
|
|
343
|
+
var len3 = ret[1];
|
|
344
|
+
if (ret[3]) {
|
|
345
|
+
ptr3 = 0; len3 = 0;
|
|
346
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
347
|
+
}
|
|
348
|
+
deferred4_0 = ptr3;
|
|
349
|
+
deferred4_1 = len3;
|
|
350
|
+
return getStringFromWasm0(ptr3, len3);
|
|
351
|
+
} finally {
|
|
352
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
exports.encrypt = encrypt;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Generate blind indices (SHA-256 token hashes) for a text string.
|
|
359
|
+
*
|
|
360
|
+
* Returns a JSON array of hex strings.
|
|
361
|
+
* @param {string} text
|
|
362
|
+
* @returns {any}
|
|
363
|
+
*/
|
|
364
|
+
function generateBlindIndices(text) {
|
|
365
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
366
|
+
const len0 = WASM_VECTOR_LEN;
|
|
367
|
+
const ret = wasm.generateBlindIndices(ptr0, len0);
|
|
368
|
+
if (ret[2]) {
|
|
369
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
370
|
+
}
|
|
371
|
+
return takeFromExternrefTable0(ret[0]);
|
|
372
|
+
}
|
|
373
|
+
exports.generateBlindIndices = generateBlindIndices;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Compute HMAC-SHA256 content fingerprint.
|
|
377
|
+
*
|
|
378
|
+
* `dedup_key_hex`: 64-char hex string (32 bytes).
|
|
379
|
+
* Returns 64-char hex fingerprint.
|
|
380
|
+
* @param {string} plaintext
|
|
381
|
+
* @param {string} dedup_key_hex
|
|
382
|
+
* @returns {string}
|
|
383
|
+
*/
|
|
384
|
+
function generateContentFingerprint(plaintext, dedup_key_hex) {
|
|
385
|
+
let deferred4_0;
|
|
386
|
+
let deferred4_1;
|
|
387
|
+
try {
|
|
388
|
+
const ptr0 = passStringToWasm0(plaintext, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
389
|
+
const len0 = WASM_VECTOR_LEN;
|
|
390
|
+
const ptr1 = passStringToWasm0(dedup_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
391
|
+
const len1 = WASM_VECTOR_LEN;
|
|
392
|
+
const ret = wasm.generateContentFingerprint(ptr0, len0, ptr1, len1);
|
|
393
|
+
var ptr3 = ret[0];
|
|
394
|
+
var len3 = ret[1];
|
|
395
|
+
if (ret[3]) {
|
|
396
|
+
ptr3 = 0; len3 = 0;
|
|
397
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
398
|
+
}
|
|
399
|
+
deferred4_0 = ptr3;
|
|
400
|
+
deferred4_1 = len3;
|
|
401
|
+
return getStringFromWasm0(ptr3, len3);
|
|
402
|
+
} finally {
|
|
403
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
exports.generateContentFingerprint = generateContentFingerprint;
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Source tag for debrief items.
|
|
410
|
+
* @returns {string}
|
|
411
|
+
*/
|
|
412
|
+
function getDebriefSource() {
|
|
413
|
+
let deferred1_0;
|
|
414
|
+
let deferred1_1;
|
|
415
|
+
try {
|
|
416
|
+
const ret = wasm.getDebriefSource();
|
|
417
|
+
deferred1_0 = ret[0];
|
|
418
|
+
deferred1_1 = ret[1];
|
|
419
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
420
|
+
} finally {
|
|
421
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
exports.getDebriefSource = getDebriefSource;
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Get the canonical debrief system prompt template.
|
|
428
|
+
*
|
|
429
|
+
* Contains `{already_stored_facts}` placeholder.
|
|
430
|
+
* @returns {string}
|
|
431
|
+
*/
|
|
432
|
+
function getDebriefSystemPrompt() {
|
|
433
|
+
let deferred1_0;
|
|
434
|
+
let deferred1_1;
|
|
435
|
+
try {
|
|
436
|
+
const ret = wasm.getDebriefSystemPrompt();
|
|
437
|
+
deferred1_0 = ret[0];
|
|
438
|
+
deferred1_1 = ret[1];
|
|
439
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
440
|
+
} finally {
|
|
441
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
exports.getDebriefSystemPrompt = getDebriefSystemPrompt;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Maximum debrief items (5).
|
|
448
|
+
* @returns {number}
|
|
449
|
+
*/
|
|
450
|
+
function getMaxDebriefItems() {
|
|
451
|
+
const ret = wasm.getMaxDebriefItems();
|
|
452
|
+
return ret >>> 0;
|
|
453
|
+
}
|
|
454
|
+
exports.getMaxDebriefItems = getMaxDebriefItems;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Minimum messages for debrief (8 = 4 turns).
|
|
458
|
+
* @returns {number}
|
|
459
|
+
*/
|
|
460
|
+
function getMinDebriefMessages() {
|
|
461
|
+
const ret = wasm.getMinDebriefMessages();
|
|
462
|
+
return ret >>> 0;
|
|
463
|
+
}
|
|
464
|
+
exports.getMinDebriefMessages = getMinDebriefMessages;
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Normalize text (NFC, lowercase, collapse whitespace, trim).
|
|
468
|
+
* @param {string} text
|
|
469
|
+
* @returns {string}
|
|
470
|
+
*/
|
|
471
|
+
function normalizeText(text) {
|
|
472
|
+
let deferred2_0;
|
|
473
|
+
let deferred2_1;
|
|
474
|
+
try {
|
|
475
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
476
|
+
const len0 = WASM_VECTOR_LEN;
|
|
477
|
+
const ret = wasm.normalizeText(ptr0, len0);
|
|
478
|
+
deferred2_0 = ret[0];
|
|
479
|
+
deferred2_1 = ret[1];
|
|
480
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
481
|
+
} finally {
|
|
482
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
exports.normalizeText = normalizeText;
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Parse a debrief LLM response into validated items.
|
|
489
|
+
*
|
|
490
|
+
* Returns a JSON array of `{ text, type, importance }` objects.
|
|
491
|
+
* @param {string} response
|
|
492
|
+
* @returns {any}
|
|
493
|
+
*/
|
|
494
|
+
function parseDebriefResponse(response) {
|
|
495
|
+
const ptr0 = passStringToWasm0(response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
496
|
+
const len0 = WASM_VECTOR_LEN;
|
|
497
|
+
const ret = wasm.parseDebriefResponse(ptr0, len0);
|
|
498
|
+
if (ret[2]) {
|
|
499
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
500
|
+
}
|
|
501
|
+
return takeFromExternrefTable0(ret[0]);
|
|
502
|
+
}
|
|
503
|
+
exports.parseDebriefResponse = parseDebriefResponse;
|
|
504
|
+
|
|
505
|
+
function __wbg_get_imports() {
|
|
506
|
+
const import0 = {
|
|
507
|
+
__proto__: null,
|
|
508
|
+
__wbg_Error_2e59b1b37a9a34c3: function(arg0, arg1) {
|
|
509
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
510
|
+
return ret;
|
|
511
|
+
},
|
|
512
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
513
|
+
const ret = String(arg1);
|
|
514
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
515
|
+
const len1 = WASM_VECTOR_LEN;
|
|
516
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
517
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
518
|
+
},
|
|
519
|
+
__wbg___wbindgen_is_function_49868bde5eb1e745: function(arg0) {
|
|
520
|
+
const ret = typeof(arg0) === 'function';
|
|
521
|
+
return ret;
|
|
522
|
+
},
|
|
523
|
+
__wbg___wbindgen_is_object_40c5a80572e8f9d3: function(arg0) {
|
|
524
|
+
const val = arg0;
|
|
525
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
526
|
+
return ret;
|
|
527
|
+
},
|
|
528
|
+
__wbg___wbindgen_is_string_b29b5c5a8065ba1a: function(arg0) {
|
|
529
|
+
const ret = typeof(arg0) === 'string';
|
|
530
|
+
return ret;
|
|
531
|
+
},
|
|
532
|
+
__wbg___wbindgen_is_undefined_c0cca72b82b86f4d: function(arg0) {
|
|
533
|
+
const ret = arg0 === undefined;
|
|
534
|
+
return ret;
|
|
535
|
+
},
|
|
536
|
+
__wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
|
|
537
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
538
|
+
},
|
|
539
|
+
__wbg_call_d578befcc3145dee: function() { return handleError(function (arg0, arg1, arg2) {
|
|
540
|
+
const ret = arg0.call(arg1, arg2);
|
|
541
|
+
return ret;
|
|
542
|
+
}, arguments); },
|
|
543
|
+
__wbg_crypto_38df2bab126b63dc: function(arg0) {
|
|
544
|
+
const ret = arg0.crypto;
|
|
545
|
+
return ret;
|
|
546
|
+
},
|
|
547
|
+
__wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
|
|
548
|
+
arg0.getRandomValues(arg1);
|
|
549
|
+
}, arguments); },
|
|
550
|
+
__wbg_getTime_f6ac312467f7cf09: function(arg0) {
|
|
551
|
+
const ret = arg0.getTime();
|
|
552
|
+
return ret;
|
|
553
|
+
},
|
|
554
|
+
__wbg_length_0c32cb8543c8e4c8: function(arg0) {
|
|
555
|
+
const ret = arg0.length;
|
|
556
|
+
return ret;
|
|
557
|
+
},
|
|
558
|
+
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
|
559
|
+
const ret = arg0.msCrypto;
|
|
560
|
+
return ret;
|
|
561
|
+
},
|
|
562
|
+
__wbg_new_0_bfa2ef4bc447daa2: function() {
|
|
563
|
+
const ret = new Date();
|
|
564
|
+
return ret;
|
|
565
|
+
},
|
|
566
|
+
__wbg_new_4f9fafbb3909af72: function() {
|
|
567
|
+
const ret = new Object();
|
|
568
|
+
return ret;
|
|
569
|
+
},
|
|
570
|
+
__wbg_new_f3c9df4f38f3f798: function() {
|
|
571
|
+
const ret = new Array();
|
|
572
|
+
return ret;
|
|
573
|
+
},
|
|
574
|
+
__wbg_new_with_length_9cedd08484b73942: function(arg0) {
|
|
575
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
576
|
+
return ret;
|
|
577
|
+
},
|
|
578
|
+
__wbg_node_84ea875411254db1: function(arg0) {
|
|
579
|
+
const ret = arg0.node;
|
|
580
|
+
return ret;
|
|
581
|
+
},
|
|
582
|
+
__wbg_process_44c7a14e11e9f69e: function(arg0) {
|
|
583
|
+
const ret = arg0.process;
|
|
584
|
+
return ret;
|
|
585
|
+
},
|
|
586
|
+
__wbg_prototypesetcall_3e05eb9545565046: function(arg0, arg1, arg2) {
|
|
587
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
588
|
+
},
|
|
589
|
+
__wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
|
|
590
|
+
arg0.randomFillSync(arg1);
|
|
591
|
+
}, arguments); },
|
|
592
|
+
__wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
|
|
593
|
+
const ret = module.require;
|
|
594
|
+
return ret;
|
|
595
|
+
}, arguments); },
|
|
596
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
597
|
+
arg0[arg1] = arg2;
|
|
598
|
+
},
|
|
599
|
+
__wbg_set_6c60b2e8ad0e9383: function(arg0, arg1, arg2) {
|
|
600
|
+
arg0[arg1 >>> 0] = arg2;
|
|
601
|
+
},
|
|
602
|
+
__wbg_set_8ee2d34facb8466e: function() { return handleError(function (arg0, arg1, arg2) {
|
|
603
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
604
|
+
return ret;
|
|
605
|
+
}, arguments); },
|
|
606
|
+
__wbg_static_accessor_GLOBAL_THIS_a1248013d790bf5f: function() {
|
|
607
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
608
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
609
|
+
},
|
|
610
|
+
__wbg_static_accessor_GLOBAL_f2e0f995a21329ff: function() {
|
|
611
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
612
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
613
|
+
},
|
|
614
|
+
__wbg_static_accessor_SELF_24f78b6d23f286ea: function() {
|
|
615
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
616
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
617
|
+
},
|
|
618
|
+
__wbg_static_accessor_WINDOW_59fd959c540fe405: function() {
|
|
619
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
620
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
621
|
+
},
|
|
622
|
+
__wbg_subarray_0f98d3fb634508ad: function(arg0, arg1, arg2) {
|
|
623
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
624
|
+
return ret;
|
|
625
|
+
},
|
|
626
|
+
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
|
627
|
+
const ret = arg0.versions;
|
|
628
|
+
return ret;
|
|
629
|
+
},
|
|
630
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
631
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
632
|
+
const ret = arg0;
|
|
633
|
+
return ret;
|
|
634
|
+
},
|
|
635
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
636
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
637
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
638
|
+
return ret;
|
|
639
|
+
},
|
|
640
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
641
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
642
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
643
|
+
return ret;
|
|
644
|
+
},
|
|
645
|
+
__wbindgen_init_externref_table: function() {
|
|
646
|
+
const table = wasm.__wbindgen_externrefs;
|
|
647
|
+
const offset = table.grow(4);
|
|
648
|
+
table.set(0, undefined);
|
|
649
|
+
table.set(offset + 0, undefined);
|
|
650
|
+
table.set(offset + 1, null);
|
|
651
|
+
table.set(offset + 2, true);
|
|
652
|
+
table.set(offset + 3, false);
|
|
653
|
+
},
|
|
654
|
+
};
|
|
655
|
+
return {
|
|
656
|
+
__proto__: null,
|
|
657
|
+
"./totalreclaw_core_bg.js": import0,
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
const WasmLshHasherFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
662
|
+
? { register: () => {}, unregister: () => {} }
|
|
663
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmlshhasher_free(ptr >>> 0, 1));
|
|
664
|
+
|
|
665
|
+
function addToExternrefTable0(obj) {
|
|
666
|
+
const idx = wasm.__externref_table_alloc();
|
|
667
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
668
|
+
return idx;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
672
|
+
ptr = ptr >>> 0;
|
|
673
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
let cachedDataViewMemory0 = null;
|
|
677
|
+
function getDataViewMemory0() {
|
|
678
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
679
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
680
|
+
}
|
|
681
|
+
return cachedDataViewMemory0;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
685
|
+
function getFloat64ArrayMemory0() {
|
|
686
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
687
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
688
|
+
}
|
|
689
|
+
return cachedFloat64ArrayMemory0;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
function getStringFromWasm0(ptr, len) {
|
|
693
|
+
ptr = ptr >>> 0;
|
|
694
|
+
return decodeText(ptr, len);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
let cachedUint8ArrayMemory0 = null;
|
|
698
|
+
function getUint8ArrayMemory0() {
|
|
699
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
700
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
701
|
+
}
|
|
702
|
+
return cachedUint8ArrayMemory0;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
function handleError(f, args) {
|
|
706
|
+
try {
|
|
707
|
+
return f.apply(this, args);
|
|
708
|
+
} catch (e) {
|
|
709
|
+
const idx = addToExternrefTable0(e);
|
|
710
|
+
wasm.__wbindgen_exn_store(idx);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
function isLikeNone(x) {
|
|
715
|
+
return x === undefined || x === null;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
function passArrayF64ToWasm0(arg, malloc) {
|
|
719
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
720
|
+
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
721
|
+
WASM_VECTOR_LEN = arg.length;
|
|
722
|
+
return ptr;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
726
|
+
if (realloc === undefined) {
|
|
727
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
728
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
729
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
730
|
+
WASM_VECTOR_LEN = buf.length;
|
|
731
|
+
return ptr;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
let len = arg.length;
|
|
735
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
736
|
+
|
|
737
|
+
const mem = getUint8ArrayMemory0();
|
|
738
|
+
|
|
739
|
+
let offset = 0;
|
|
740
|
+
|
|
741
|
+
for (; offset < len; offset++) {
|
|
742
|
+
const code = arg.charCodeAt(offset);
|
|
743
|
+
if (code > 0x7F) break;
|
|
744
|
+
mem[ptr + offset] = code;
|
|
745
|
+
}
|
|
746
|
+
if (offset !== len) {
|
|
747
|
+
if (offset !== 0) {
|
|
748
|
+
arg = arg.slice(offset);
|
|
749
|
+
}
|
|
750
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
751
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
752
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
753
|
+
|
|
754
|
+
offset += ret.written;
|
|
755
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
WASM_VECTOR_LEN = offset;
|
|
759
|
+
return ptr;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
function takeFromExternrefTable0(idx) {
|
|
763
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
764
|
+
wasm.__externref_table_dealloc(idx);
|
|
765
|
+
return value;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
769
|
+
cachedTextDecoder.decode();
|
|
770
|
+
function decodeText(ptr, len) {
|
|
771
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
const cachedTextEncoder = new TextEncoder();
|
|
775
|
+
|
|
776
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
777
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
778
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
779
|
+
view.set(buf);
|
|
780
|
+
return {
|
|
781
|
+
read: arg.length,
|
|
782
|
+
written: buf.length
|
|
783
|
+
};
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
let WASM_VECTOR_LEN = 0;
|
|
788
|
+
|
|
789
|
+
const wasmPath = `${__dirname}/totalreclaw_core_bg.wasm`;
|
|
790
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
791
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
792
|
+
let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
793
|
+
wasm.__wbindgen_start();
|
|
Binary file
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const deriveKeysFromMnemonic: (a: number, b: number) => [number, number, number];
|
|
5
|
+
export const deriveKeysFromMnemonicLenient: (a: number, b: number) => [number, number, number];
|
|
6
|
+
export const deriveLshSeed: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
7
|
+
export const computeAuthKeyHash: (a: number, b: number) => [number, number, number, number];
|
|
8
|
+
export const encrypt: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
9
|
+
export const decrypt: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
10
|
+
export const generateBlindIndices: (a: number, b: number) => [number, number, number];
|
|
11
|
+
export const generateContentFingerprint: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
12
|
+
export const normalizeText: (a: number, b: number) => [number, number];
|
|
13
|
+
export const __wbg_wasmlshhasher_free: (a: number, b: number) => void;
|
|
14
|
+
export const wasmlshhasher_new: (a: number, b: number, c: number) => [number, number, number];
|
|
15
|
+
export const wasmlshhasher_withParams: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
16
|
+
export const wasmlshhasher_hash: (a: number, b: number, c: number) => [number, number, number];
|
|
17
|
+
export const wasmlshhasher_tables: (a: number) => number;
|
|
18
|
+
export const wasmlshhasher_bits: (a: number) => number;
|
|
19
|
+
export const wasmlshhasher_dimensions: (a: number) => number;
|
|
20
|
+
export const encodeFactProtobuf: (a: number, b: number) => [number, number, number, number];
|
|
21
|
+
export const encodeTombstoneProtobuf: (a: number, b: number, c: number, d: number) => [number, number];
|
|
22
|
+
export const parseDebriefResponse: (a: number, b: number) => [number, number, number];
|
|
23
|
+
export const getDebriefSystemPrompt: () => [number, number];
|
|
24
|
+
export const buildDebriefPrompt: (a: number, b: number) => [number, number, number, number];
|
|
25
|
+
export const getMinDebriefMessages: () => number;
|
|
26
|
+
export const getMaxDebriefItems: () => number;
|
|
27
|
+
export const getDebriefSource: () => [number, number];
|
|
28
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
29
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
30
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
31
|
+
export const __externref_table_alloc: () => number;
|
|
32
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
33
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
34
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
35
|
+
export const __wbindgen_start: () => void;
|