@ruvector/edge-full 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/LICENSE +21 -0
- package/README.md +390 -0
- package/dag/ruvector_dag_wasm.d.ts +105 -0
- package/dag/ruvector_dag_wasm.js +466 -0
- package/dag/ruvector_dag_wasm_bg.wasm +0 -0
- package/dag/ruvector_dag_wasm_bg.wasm.d.ts +20 -0
- package/edge/ruvector_edge.d.ts +351 -0
- package/edge/ruvector_edge.js +1452 -0
- package/edge/ruvector_edge_bg.wasm +0 -0
- package/edge/ruvector_edge_bg.wasm.d.ts +71 -0
- package/generator.html +2009 -0
- package/graph/ruvector_graph_wasm.d.ts +380 -0
- package/graph/ruvector_graph_wasm.js +1787 -0
- package/graph/ruvector_graph_wasm_bg.wasm +0 -0
- package/graph/ruvector_graph_wasm_bg.wasm.d.ts +80 -0
- package/index.d.ts +64 -0
- package/index.js +182 -0
- package/onnx/ruvector_onnx_embeddings_wasm.d.ts +112 -0
- package/onnx/ruvector_onnx_embeddings_wasm.js +635 -0
- package/onnx/ruvector_onnx_embeddings_wasm_bg.js +629 -0
- package/onnx/ruvector_onnx_embeddings_wasm_bg.wasm +0 -0
- package/onnx/ruvector_onnx_embeddings_wasm_bg.wasm.d.ts +29 -0
- package/package.json +86 -0
- package/rvlite/rvlite.d.ts +556 -0
- package/rvlite/rvlite.js +2366 -0
- package/rvlite/rvlite_bg.wasm +0 -0
- package/rvlite/rvlite_bg.wasm.d.ts +128 -0
- package/sona/ruvector_sona.d.ts +513 -0
- package/sona/ruvector_sona.js +1290 -0
- package/sona/ruvector_sona_bg.wasm +0 -0
- package/sona/ruvector_sona_bg.wasm.d.ts +53 -0
|
@@ -0,0 +1,1290 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
function addHeapObject(obj) {
|
|
4
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
5
|
+
const idx = heap_next;
|
|
6
|
+
heap_next = heap[idx];
|
|
7
|
+
|
|
8
|
+
heap[idx] = obj;
|
|
9
|
+
return idx;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function debugString(val) {
|
|
13
|
+
// primitive types
|
|
14
|
+
const type = typeof val;
|
|
15
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
16
|
+
return `${val}`;
|
|
17
|
+
}
|
|
18
|
+
if (type == 'string') {
|
|
19
|
+
return `"${val}"`;
|
|
20
|
+
}
|
|
21
|
+
if (type == 'symbol') {
|
|
22
|
+
const description = val.description;
|
|
23
|
+
if (description == null) {
|
|
24
|
+
return 'Symbol';
|
|
25
|
+
} else {
|
|
26
|
+
return `Symbol(${description})`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (type == 'function') {
|
|
30
|
+
const name = val.name;
|
|
31
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
32
|
+
return `Function(${name})`;
|
|
33
|
+
} else {
|
|
34
|
+
return 'Function';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// objects
|
|
38
|
+
if (Array.isArray(val)) {
|
|
39
|
+
const length = val.length;
|
|
40
|
+
let debug = '[';
|
|
41
|
+
if (length > 0) {
|
|
42
|
+
debug += debugString(val[0]);
|
|
43
|
+
}
|
|
44
|
+
for(let i = 1; i < length; i++) {
|
|
45
|
+
debug += ', ' + debugString(val[i]);
|
|
46
|
+
}
|
|
47
|
+
debug += ']';
|
|
48
|
+
return debug;
|
|
49
|
+
}
|
|
50
|
+
// Test for built-in
|
|
51
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
52
|
+
let className;
|
|
53
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
54
|
+
className = builtInMatches[1];
|
|
55
|
+
} else {
|
|
56
|
+
// Failed to match the standard '[object ClassName]'
|
|
57
|
+
return toString.call(val);
|
|
58
|
+
}
|
|
59
|
+
if (className == 'Object') {
|
|
60
|
+
// we're a user defined class or Object
|
|
61
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
62
|
+
// easier than looping through ownProperties of `val`.
|
|
63
|
+
try {
|
|
64
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
65
|
+
} catch (_) {
|
|
66
|
+
return 'Object';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// errors
|
|
70
|
+
if (val instanceof Error) {
|
|
71
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
72
|
+
}
|
|
73
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
74
|
+
return className;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function dropObject(idx) {
|
|
78
|
+
if (idx < 132) return;
|
|
79
|
+
heap[idx] = heap_next;
|
|
80
|
+
heap_next = idx;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
84
|
+
ptr = ptr >>> 0;
|
|
85
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let cachedDataViewMemory0 = null;
|
|
89
|
+
function getDataViewMemory0() {
|
|
90
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
91
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
92
|
+
}
|
|
93
|
+
return cachedDataViewMemory0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
97
|
+
function getFloat32ArrayMemory0() {
|
|
98
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
99
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
100
|
+
}
|
|
101
|
+
return cachedFloat32ArrayMemory0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function getStringFromWasm0(ptr, len) {
|
|
105
|
+
ptr = ptr >>> 0;
|
|
106
|
+
return decodeText(ptr, len);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let cachedUint8ArrayMemory0 = null;
|
|
110
|
+
function getUint8ArrayMemory0() {
|
|
111
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
112
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
113
|
+
}
|
|
114
|
+
return cachedUint8ArrayMemory0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function getObject(idx) { return heap[idx]; }
|
|
118
|
+
|
|
119
|
+
function handleError(f, args) {
|
|
120
|
+
try {
|
|
121
|
+
return f.apply(this, args);
|
|
122
|
+
} catch (e) {
|
|
123
|
+
wasm.__wbindgen_export3(addHeapObject(e));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let heap = new Array(128).fill(undefined);
|
|
128
|
+
heap.push(undefined, null, true, false);
|
|
129
|
+
|
|
130
|
+
let heap_next = heap.length;
|
|
131
|
+
|
|
132
|
+
function isLikeNone(x) {
|
|
133
|
+
return x === undefined || x === null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function passArrayF32ToWasm0(arg, malloc) {
|
|
137
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
138
|
+
getFloat32ArrayMemory0().set(arg, ptr / 4);
|
|
139
|
+
WASM_VECTOR_LEN = arg.length;
|
|
140
|
+
return ptr;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
144
|
+
if (realloc === undefined) {
|
|
145
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
146
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
147
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
148
|
+
WASM_VECTOR_LEN = buf.length;
|
|
149
|
+
return ptr;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
let len = arg.length;
|
|
153
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
154
|
+
|
|
155
|
+
const mem = getUint8ArrayMemory0();
|
|
156
|
+
|
|
157
|
+
let offset = 0;
|
|
158
|
+
|
|
159
|
+
for (; offset < len; offset++) {
|
|
160
|
+
const code = arg.charCodeAt(offset);
|
|
161
|
+
if (code > 0x7F) break;
|
|
162
|
+
mem[ptr + offset] = code;
|
|
163
|
+
}
|
|
164
|
+
if (offset !== len) {
|
|
165
|
+
if (offset !== 0) {
|
|
166
|
+
arg = arg.slice(offset);
|
|
167
|
+
}
|
|
168
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
169
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
170
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
171
|
+
|
|
172
|
+
offset += ret.written;
|
|
173
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
WASM_VECTOR_LEN = offset;
|
|
177
|
+
return ptr;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function takeObject(idx) {
|
|
181
|
+
const ret = getObject(idx);
|
|
182
|
+
dropObject(idx);
|
|
183
|
+
return ret;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
187
|
+
cachedTextDecoder.decode();
|
|
188
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
189
|
+
let numBytesDecoded = 0;
|
|
190
|
+
function decodeText(ptr, len) {
|
|
191
|
+
numBytesDecoded += len;
|
|
192
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
193
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
194
|
+
cachedTextDecoder.decode();
|
|
195
|
+
numBytesDecoded = len;
|
|
196
|
+
}
|
|
197
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const cachedTextEncoder = new TextEncoder();
|
|
201
|
+
|
|
202
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
203
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
204
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
205
|
+
view.set(buf);
|
|
206
|
+
return {
|
|
207
|
+
read: arg.length,
|
|
208
|
+
written: buf.length
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
let WASM_VECTOR_LEN = 0;
|
|
214
|
+
|
|
215
|
+
const WasmEphemeralAgentFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
216
|
+
? { register: () => {}, unregister: () => {} }
|
|
217
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmephemeralagent_free(ptr >>> 0, 1));
|
|
218
|
+
|
|
219
|
+
const WasmFederatedCoordinatorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
220
|
+
? { register: () => {}, unregister: () => {} }
|
|
221
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmfederatedcoordinator_free(ptr >>> 0, 1));
|
|
222
|
+
|
|
223
|
+
const WasmSonaEngineFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
224
|
+
? { register: () => {}, unregister: () => {} }
|
|
225
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmsonaengine_free(ptr >>> 0, 1));
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* WASM-compatible Ephemeral Agent for federated learning
|
|
229
|
+
*
|
|
230
|
+
* Lightweight agent wrapper (~5MB footprint) for distributed training.
|
|
231
|
+
* Agents process tasks, collect trajectories, and export state for aggregation.
|
|
232
|
+
*
|
|
233
|
+
* # Example
|
|
234
|
+
* ```javascript
|
|
235
|
+
* const agent = new WasmEphemeralAgent("agent-1");
|
|
236
|
+
*
|
|
237
|
+
* // Process tasks
|
|
238
|
+
* const embedding = new Float32Array(256).fill(0.1);
|
|
239
|
+
* agent.process_task(embedding, 0.85);
|
|
240
|
+
*
|
|
241
|
+
* // Export state for coordinator
|
|
242
|
+
* const state = agent.export_state();
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
export class WasmEphemeralAgent {
|
|
246
|
+
static __wrap(ptr) {
|
|
247
|
+
ptr = ptr >>> 0;
|
|
248
|
+
const obj = Object.create(WasmEphemeralAgent.prototype);
|
|
249
|
+
obj.__wbg_ptr = ptr;
|
|
250
|
+
WasmEphemeralAgentFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
251
|
+
return obj;
|
|
252
|
+
}
|
|
253
|
+
__destroy_into_raw() {
|
|
254
|
+
const ptr = this.__wbg_ptr;
|
|
255
|
+
this.__wbg_ptr = 0;
|
|
256
|
+
WasmEphemeralAgentFinalization.unregister(this);
|
|
257
|
+
return ptr;
|
|
258
|
+
}
|
|
259
|
+
free() {
|
|
260
|
+
const ptr = this.__destroy_into_raw();
|
|
261
|
+
wasm.__wbg_wasmephemeralagent_free(ptr, 0);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Force learning cycle on agent's engine
|
|
265
|
+
* @returns {string}
|
|
266
|
+
*/
|
|
267
|
+
forceLearn() {
|
|
268
|
+
let deferred1_0;
|
|
269
|
+
let deferred1_1;
|
|
270
|
+
try {
|
|
271
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
272
|
+
wasm.wasmephemeralagent_forceLearn(retptr, this.__wbg_ptr);
|
|
273
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
274
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
275
|
+
deferred1_0 = r0;
|
|
276
|
+
deferred1_1 = r1;
|
|
277
|
+
return getStringFromWasm0(r0, r1);
|
|
278
|
+
} finally {
|
|
279
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
280
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Create agent with custom configuration
|
|
285
|
+
*
|
|
286
|
+
* # Arguments
|
|
287
|
+
* * `agent_id` - Unique identifier
|
|
288
|
+
* * `config` - JSON configuration object
|
|
289
|
+
*
|
|
290
|
+
* # Example
|
|
291
|
+
* ```javascript
|
|
292
|
+
* const config = {
|
|
293
|
+
* hidden_dim: 256,
|
|
294
|
+
* trajectory_capacity: 500,
|
|
295
|
+
* pattern_clusters: 25
|
|
296
|
+
* };
|
|
297
|
+
* const agent = WasmEphemeralAgent.with_config("agent-1", config);
|
|
298
|
+
* ```
|
|
299
|
+
* @param {string} agent_id
|
|
300
|
+
* @param {any} config
|
|
301
|
+
* @returns {WasmEphemeralAgent}
|
|
302
|
+
*/
|
|
303
|
+
static withConfig(agent_id, config) {
|
|
304
|
+
try {
|
|
305
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
306
|
+
const ptr0 = passStringToWasm0(agent_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
307
|
+
const len0 = WASM_VECTOR_LEN;
|
|
308
|
+
wasm.wasmephemeralagent_withConfig(retptr, ptr0, len0, addHeapObject(config));
|
|
309
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
310
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
311
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
312
|
+
if (r2) {
|
|
313
|
+
throw takeObject(r1);
|
|
314
|
+
}
|
|
315
|
+
return WasmEphemeralAgent.__wrap(r0);
|
|
316
|
+
} finally {
|
|
317
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Export agent state for coordinator aggregation
|
|
322
|
+
*
|
|
323
|
+
* # Returns
|
|
324
|
+
* JSON object containing agent state, trajectories, and statistics
|
|
325
|
+
*
|
|
326
|
+
* # Example
|
|
327
|
+
* ```javascript
|
|
328
|
+
* const state = agent.export_state();
|
|
329
|
+
* console.log('Trajectories:', state.trajectories.length);
|
|
330
|
+
* coordinator.aggregate(state);
|
|
331
|
+
* ```
|
|
332
|
+
* @returns {any}
|
|
333
|
+
*/
|
|
334
|
+
exportState() {
|
|
335
|
+
const ret = wasm.wasmephemeralagent_exportState(this.__wbg_ptr);
|
|
336
|
+
return takeObject(ret);
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Get learned patterns from agent
|
|
340
|
+
* @returns {any}
|
|
341
|
+
*/
|
|
342
|
+
getPatterns() {
|
|
343
|
+
const ret = wasm.wasmephemeralagent_getPatterns(this.__wbg_ptr);
|
|
344
|
+
return takeObject(ret);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Process a task and record trajectory
|
|
348
|
+
*
|
|
349
|
+
* # Arguments
|
|
350
|
+
* * `embedding` - Query embedding as Float32Array
|
|
351
|
+
* * `quality` - Task quality score [0.0, 1.0]
|
|
352
|
+
*
|
|
353
|
+
* # Example
|
|
354
|
+
* ```javascript
|
|
355
|
+
* const embedding = new Float32Array(256).fill(0.1);
|
|
356
|
+
* agent.process_task(embedding, 0.85);
|
|
357
|
+
* ```
|
|
358
|
+
* @param {Float32Array} embedding
|
|
359
|
+
* @param {number} quality
|
|
360
|
+
*/
|
|
361
|
+
processTask(embedding, quality) {
|
|
362
|
+
const ptr0 = passArrayF32ToWasm0(embedding, wasm.__wbindgen_export);
|
|
363
|
+
const len0 = WASM_VECTOR_LEN;
|
|
364
|
+
wasm.wasmephemeralagent_processTask(this.__wbg_ptr, ptr0, len0, quality);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Get agent uptime in seconds
|
|
368
|
+
* @returns {bigint}
|
|
369
|
+
*/
|
|
370
|
+
uptimeSeconds() {
|
|
371
|
+
const ret = wasm.wasmephemeralagent_uptimeSeconds(this.__wbg_ptr);
|
|
372
|
+
return BigInt.asUintN(64, ret);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Get average quality of collected trajectories
|
|
376
|
+
* @returns {number}
|
|
377
|
+
*/
|
|
378
|
+
averageQuality() {
|
|
379
|
+
const ret = wasm.wasmephemeralagent_averageQuality(this.__wbg_ptr);
|
|
380
|
+
return ret;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Get number of collected trajectories
|
|
384
|
+
* @returns {number}
|
|
385
|
+
*/
|
|
386
|
+
trajectoryCount() {
|
|
387
|
+
const ret = wasm.wasmephemeralagent_trajectoryCount(this.__wbg_ptr);
|
|
388
|
+
return ret >>> 0;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Process task with model route information
|
|
392
|
+
*
|
|
393
|
+
* # Arguments
|
|
394
|
+
* * `embedding` - Query embedding
|
|
395
|
+
* * `quality` - Quality score
|
|
396
|
+
* * `route` - Model route used (e.g., "gpt-4", "claude-3")
|
|
397
|
+
* @param {Float32Array} embedding
|
|
398
|
+
* @param {number} quality
|
|
399
|
+
* @param {string} route
|
|
400
|
+
*/
|
|
401
|
+
processTaskWithRoute(embedding, quality, route) {
|
|
402
|
+
const ptr0 = passArrayF32ToWasm0(embedding, wasm.__wbindgen_export);
|
|
403
|
+
const len0 = WASM_VECTOR_LEN;
|
|
404
|
+
const ptr1 = passStringToWasm0(route, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
405
|
+
const len1 = WASM_VECTOR_LEN;
|
|
406
|
+
wasm.wasmephemeralagent_processTaskWithRoute(this.__wbg_ptr, ptr0, len0, quality, ptr1, len1);
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Create a new ephemeral agent with default config
|
|
410
|
+
*
|
|
411
|
+
* # Arguments
|
|
412
|
+
* * `agent_id` - Unique identifier for this agent
|
|
413
|
+
*
|
|
414
|
+
* # Example
|
|
415
|
+
* ```javascript
|
|
416
|
+
* const agent = new WasmEphemeralAgent("agent-1");
|
|
417
|
+
* ```
|
|
418
|
+
* @param {string} agent_id
|
|
419
|
+
*/
|
|
420
|
+
constructor(agent_id) {
|
|
421
|
+
try {
|
|
422
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
423
|
+
const ptr0 = passStringToWasm0(agent_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
424
|
+
const len0 = WASM_VECTOR_LEN;
|
|
425
|
+
wasm.wasmephemeralagent_new(retptr, ptr0, len0);
|
|
426
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
427
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
428
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
429
|
+
if (r2) {
|
|
430
|
+
throw takeObject(r1);
|
|
431
|
+
}
|
|
432
|
+
this.__wbg_ptr = r0 >>> 0;
|
|
433
|
+
WasmEphemeralAgentFinalization.register(this, this.__wbg_ptr, this);
|
|
434
|
+
return this;
|
|
435
|
+
} finally {
|
|
436
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Clear collected trajectories (after export)
|
|
441
|
+
*/
|
|
442
|
+
clear() {
|
|
443
|
+
wasm.wasmephemeralagent_clear(this.__wbg_ptr);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Get agent statistics
|
|
447
|
+
*
|
|
448
|
+
* # Returns
|
|
449
|
+
* JSON object with trajectory count, quality stats, uptime
|
|
450
|
+
* @returns {any}
|
|
451
|
+
*/
|
|
452
|
+
getStats() {
|
|
453
|
+
const ret = wasm.wasmephemeralagent_getStats(this.__wbg_ptr);
|
|
454
|
+
return takeObject(ret);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
if (Symbol.dispose) WasmEphemeralAgent.prototype[Symbol.dispose] = WasmEphemeralAgent.prototype.free;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* WASM-compatible Federated Coordinator
|
|
461
|
+
*
|
|
462
|
+
* Central aggregator for federated learning with quality filtering.
|
|
463
|
+
* Coordinates multiple ephemeral agents using star topology.
|
|
464
|
+
*
|
|
465
|
+
* # Example
|
|
466
|
+
* ```javascript
|
|
467
|
+
* const coordinator = new WasmFederatedCoordinator("central");
|
|
468
|
+
*
|
|
469
|
+
* // Aggregate agent exports
|
|
470
|
+
* const agentState = agent.export_state();
|
|
471
|
+
* const result = coordinator.aggregate(agentState);
|
|
472
|
+
*
|
|
473
|
+
* // Check stats
|
|
474
|
+
* const stats = coordinator.get_stats();
|
|
475
|
+
* console.log('Total agents:', stats.total_agents);
|
|
476
|
+
* ```
|
|
477
|
+
*/
|
|
478
|
+
export class WasmFederatedCoordinator {
|
|
479
|
+
static __wrap(ptr) {
|
|
480
|
+
ptr = ptr >>> 0;
|
|
481
|
+
const obj = Object.create(WasmFederatedCoordinator.prototype);
|
|
482
|
+
obj.__wbg_ptr = ptr;
|
|
483
|
+
WasmFederatedCoordinatorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
484
|
+
return obj;
|
|
485
|
+
}
|
|
486
|
+
__destroy_into_raw() {
|
|
487
|
+
const ptr = this.__wbg_ptr;
|
|
488
|
+
this.__wbg_ptr = 0;
|
|
489
|
+
WasmFederatedCoordinatorFinalization.unregister(this);
|
|
490
|
+
return ptr;
|
|
491
|
+
}
|
|
492
|
+
free() {
|
|
493
|
+
const ptr = this.__destroy_into_raw();
|
|
494
|
+
wasm.__wbg_wasmfederatedcoordinator_free(ptr, 0);
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Apply coordinator's learned LoRA to input
|
|
498
|
+
* @param {Float32Array} input
|
|
499
|
+
* @returns {Float32Array}
|
|
500
|
+
*/
|
|
501
|
+
applyLora(input) {
|
|
502
|
+
try {
|
|
503
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
504
|
+
const ptr0 = passArrayF32ToWasm0(input, wasm.__wbindgen_export);
|
|
505
|
+
const len0 = WASM_VECTOR_LEN;
|
|
506
|
+
wasm.wasmfederatedcoordinator_applyLora(retptr, this.__wbg_ptr, ptr0, len0);
|
|
507
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
508
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
509
|
+
var v2 = getArrayF32FromWasm0(r0, r1).slice();
|
|
510
|
+
wasm.__wbindgen_export4(r0, r1 * 4, 4);
|
|
511
|
+
return v2;
|
|
512
|
+
} finally {
|
|
513
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Get total number of contributing agents
|
|
518
|
+
* @returns {number}
|
|
519
|
+
*/
|
|
520
|
+
agentCount() {
|
|
521
|
+
const ret = wasm.wasmfederatedcoordinator_agentCount(this.__wbg_ptr);
|
|
522
|
+
return ret >>> 0;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Consolidate learning from all aggregated trajectories
|
|
526
|
+
*
|
|
527
|
+
* Should be called periodically after aggregating multiple agents.
|
|
528
|
+
*
|
|
529
|
+
* # Returns
|
|
530
|
+
* Learning result as JSON string
|
|
531
|
+
* @returns {string}
|
|
532
|
+
*/
|
|
533
|
+
consolidate() {
|
|
534
|
+
let deferred1_0;
|
|
535
|
+
let deferred1_1;
|
|
536
|
+
try {
|
|
537
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
538
|
+
wasm.wasmfederatedcoordinator_consolidate(retptr, this.__wbg_ptr);
|
|
539
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
540
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
541
|
+
deferred1_0 = r0;
|
|
542
|
+
deferred1_1 = r1;
|
|
543
|
+
return getStringFromWasm0(r0, r1);
|
|
544
|
+
} finally {
|
|
545
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
546
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Create coordinator with custom configuration
|
|
551
|
+
*
|
|
552
|
+
* # Arguments
|
|
553
|
+
* * `coordinator_id` - Unique identifier
|
|
554
|
+
* * `config` - JSON configuration object
|
|
555
|
+
*
|
|
556
|
+
* # Example
|
|
557
|
+
* ```javascript
|
|
558
|
+
* const config = {
|
|
559
|
+
* hidden_dim: 256,
|
|
560
|
+
* trajectory_capacity: 50000,
|
|
561
|
+
* pattern_clusters: 200,
|
|
562
|
+
* ewc_lambda: 2000.0
|
|
563
|
+
* };
|
|
564
|
+
* const coordinator = WasmFederatedCoordinator.with_config("central", config);
|
|
565
|
+
* ```
|
|
566
|
+
* @param {string} coordinator_id
|
|
567
|
+
* @param {any} config
|
|
568
|
+
* @returns {WasmFederatedCoordinator}
|
|
569
|
+
*/
|
|
570
|
+
static withConfig(coordinator_id, config) {
|
|
571
|
+
try {
|
|
572
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
573
|
+
const ptr0 = passStringToWasm0(coordinator_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
574
|
+
const len0 = WASM_VECTOR_LEN;
|
|
575
|
+
wasm.wasmfederatedcoordinator_withConfig(retptr, ptr0, len0, addHeapObject(config));
|
|
576
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
577
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
578
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
579
|
+
if (r2) {
|
|
580
|
+
throw takeObject(r1);
|
|
581
|
+
}
|
|
582
|
+
return WasmFederatedCoordinator.__wrap(r0);
|
|
583
|
+
} finally {
|
|
584
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Get all learned patterns from coordinator
|
|
589
|
+
* @returns {any}
|
|
590
|
+
*/
|
|
591
|
+
getPatterns() {
|
|
592
|
+
const ret = wasm.wasmfederatedcoordinator_getPatterns(this.__wbg_ptr);
|
|
593
|
+
return takeObject(ret);
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Find similar patterns to query
|
|
597
|
+
*
|
|
598
|
+
* # Arguments
|
|
599
|
+
* * `query_embedding` - Query vector
|
|
600
|
+
* * `k` - Number of patterns to return
|
|
601
|
+
* @param {Float32Array} query_embedding
|
|
602
|
+
* @param {number} k
|
|
603
|
+
* @returns {any}
|
|
604
|
+
*/
|
|
605
|
+
findPatterns(query_embedding, k) {
|
|
606
|
+
const ptr0 = passArrayF32ToWasm0(query_embedding, wasm.__wbindgen_export);
|
|
607
|
+
const len0 = WASM_VECTOR_LEN;
|
|
608
|
+
const ret = wasm.wasmfederatedcoordinator_findPatterns(this.__wbg_ptr, ptr0, len0, k);
|
|
609
|
+
return takeObject(ret);
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Get total trajectories aggregated
|
|
613
|
+
* @returns {number}
|
|
614
|
+
*/
|
|
615
|
+
totalTrajectories() {
|
|
616
|
+
const ret = wasm.wasmfederatedcoordinator_totalTrajectories(this.__wbg_ptr);
|
|
617
|
+
return ret >>> 0;
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Set quality threshold for accepting trajectories
|
|
621
|
+
*
|
|
622
|
+
* # Arguments
|
|
623
|
+
* * `threshold` - Minimum quality [0.0, 1.0], default 0.4
|
|
624
|
+
* @param {number} threshold
|
|
625
|
+
*/
|
|
626
|
+
setQualityThreshold(threshold) {
|
|
627
|
+
wasm.wasmfederatedcoordinator_setQualityThreshold(this.__wbg_ptr, threshold);
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Create a new federated coordinator with default config
|
|
631
|
+
*
|
|
632
|
+
* # Arguments
|
|
633
|
+
* * `coordinator_id` - Unique identifier for this coordinator
|
|
634
|
+
*
|
|
635
|
+
* # Example
|
|
636
|
+
* ```javascript
|
|
637
|
+
* const coordinator = new WasmFederatedCoordinator("central");
|
|
638
|
+
* ```
|
|
639
|
+
* @param {string} coordinator_id
|
|
640
|
+
*/
|
|
641
|
+
constructor(coordinator_id) {
|
|
642
|
+
try {
|
|
643
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
644
|
+
const ptr0 = passStringToWasm0(coordinator_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
645
|
+
const len0 = WASM_VECTOR_LEN;
|
|
646
|
+
wasm.wasmfederatedcoordinator_new(retptr, ptr0, len0);
|
|
647
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
648
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
649
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
650
|
+
if (r2) {
|
|
651
|
+
throw takeObject(r1);
|
|
652
|
+
}
|
|
653
|
+
this.__wbg_ptr = r0 >>> 0;
|
|
654
|
+
WasmFederatedCoordinatorFinalization.register(this, this.__wbg_ptr, this);
|
|
655
|
+
return this;
|
|
656
|
+
} finally {
|
|
657
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Clear all agent contributions (reset coordinator)
|
|
662
|
+
*/
|
|
663
|
+
clear() {
|
|
664
|
+
wasm.wasmfederatedcoordinator_clear(this.__wbg_ptr);
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Aggregate agent export into coordinator
|
|
668
|
+
*
|
|
669
|
+
* # Arguments
|
|
670
|
+
* * `agent_export` - JSON export from agent.export_state()
|
|
671
|
+
*
|
|
672
|
+
* # Returns
|
|
673
|
+
* JSON aggregation result with accepted/rejected counts
|
|
674
|
+
*
|
|
675
|
+
* # Example
|
|
676
|
+
* ```javascript
|
|
677
|
+
* const agentState = agent.export_state();
|
|
678
|
+
* const result = coordinator.aggregate(agentState);
|
|
679
|
+
* console.log('Accepted:', result.accepted);
|
|
680
|
+
* ```
|
|
681
|
+
* @param {any} agent_export
|
|
682
|
+
* @returns {any}
|
|
683
|
+
*/
|
|
684
|
+
aggregate(agent_export) {
|
|
685
|
+
const ret = wasm.wasmfederatedcoordinator_aggregate(this.__wbg_ptr, addHeapObject(agent_export));
|
|
686
|
+
return takeObject(ret);
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Get coordinator statistics
|
|
690
|
+
*
|
|
691
|
+
* # Returns
|
|
692
|
+
* JSON object with agent count, trajectory count, quality stats
|
|
693
|
+
* @returns {any}
|
|
694
|
+
*/
|
|
695
|
+
getStats() {
|
|
696
|
+
const ret = wasm.wasmfederatedcoordinator_getStats(this.__wbg_ptr);
|
|
697
|
+
return takeObject(ret);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
if (Symbol.dispose) WasmFederatedCoordinator.prototype[Symbol.dispose] = WasmFederatedCoordinator.prototype.free;
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* WASM-compatible SONA Engine wrapper
|
|
704
|
+
*
|
|
705
|
+
* Provides JavaScript bindings for the SONA adaptive learning system.
|
|
706
|
+
*/
|
|
707
|
+
export class WasmSonaEngine {
|
|
708
|
+
static __wrap(ptr) {
|
|
709
|
+
ptr = ptr >>> 0;
|
|
710
|
+
const obj = Object.create(WasmSonaEngine.prototype);
|
|
711
|
+
obj.__wbg_ptr = ptr;
|
|
712
|
+
WasmSonaEngineFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
713
|
+
return obj;
|
|
714
|
+
}
|
|
715
|
+
__destroy_into_raw() {
|
|
716
|
+
const ptr = this.__wbg_ptr;
|
|
717
|
+
this.__wbg_ptr = 0;
|
|
718
|
+
WasmSonaEngineFinalization.unregister(this);
|
|
719
|
+
return ptr;
|
|
720
|
+
}
|
|
721
|
+
free() {
|
|
722
|
+
const ptr = this.__destroy_into_raw();
|
|
723
|
+
wasm.__wbg_wasmsonaengine_free(ptr, 0);
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Apply LoRA transformation to input vector
|
|
727
|
+
*
|
|
728
|
+
* # Arguments
|
|
729
|
+
* * `input` - Input vector as Float32Array
|
|
730
|
+
*
|
|
731
|
+
* # Returns
|
|
732
|
+
* Transformed vector as Float32Array
|
|
733
|
+
*
|
|
734
|
+
* # Example
|
|
735
|
+
* ```javascript
|
|
736
|
+
* const input = new Float32Array(256).fill(1.0);
|
|
737
|
+
* const output = engine.apply_lora(input);
|
|
738
|
+
* ```
|
|
739
|
+
* @param {Float32Array} input
|
|
740
|
+
* @returns {Float32Array}
|
|
741
|
+
*/
|
|
742
|
+
applyLora(input) {
|
|
743
|
+
try {
|
|
744
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
745
|
+
const ptr0 = passArrayF32ToWasm0(input, wasm.__wbindgen_export);
|
|
746
|
+
const len0 = WASM_VECTOR_LEN;
|
|
747
|
+
wasm.wasmsonaengine_applyLora(retptr, this.__wbg_ptr, ptr0, len0);
|
|
748
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
749
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
750
|
+
var v2 = getArrayF32FromWasm0(r0, r1).slice();
|
|
751
|
+
wasm.__wbindgen_export4(r0, r1 * 4, 4);
|
|
752
|
+
return v2;
|
|
753
|
+
} finally {
|
|
754
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Get configuration
|
|
759
|
+
*
|
|
760
|
+
* # Returns
|
|
761
|
+
* Configuration as JSON object
|
|
762
|
+
* @returns {any}
|
|
763
|
+
*/
|
|
764
|
+
getConfig() {
|
|
765
|
+
const ret = wasm.wasmsonaengine_getConfig(this.__wbg_ptr);
|
|
766
|
+
return takeObject(ret);
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Check if engine is enabled
|
|
770
|
+
*
|
|
771
|
+
* # Returns
|
|
772
|
+
* true if enabled, false otherwise
|
|
773
|
+
* @returns {boolean}
|
|
774
|
+
*/
|
|
775
|
+
isEnabled() {
|
|
776
|
+
const ret = wasm.wasmsonaengine_isEnabled(this.__wbg_ptr);
|
|
777
|
+
return ret !== 0;
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Force background learning cycle
|
|
781
|
+
*
|
|
782
|
+
* # Returns
|
|
783
|
+
* Learning statistics as JSON string
|
|
784
|
+
*
|
|
785
|
+
* # Example
|
|
786
|
+
* ```javascript
|
|
787
|
+
* const stats = engine.force_learn();
|
|
788
|
+
* console.log('Learning results:', stats);
|
|
789
|
+
* ```
|
|
790
|
+
* @returns {string}
|
|
791
|
+
*/
|
|
792
|
+
forceLearn() {
|
|
793
|
+
let deferred1_0;
|
|
794
|
+
let deferred1_1;
|
|
795
|
+
try {
|
|
796
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
797
|
+
wasm.wasmsonaengine_forceLearn(retptr, this.__wbg_ptr);
|
|
798
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
799
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
800
|
+
deferred1_0 = r0;
|
|
801
|
+
deferred1_1 = r1;
|
|
802
|
+
return getStringFromWasm0(r0, r1);
|
|
803
|
+
} finally {
|
|
804
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
805
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Record a step in the trajectory
|
|
810
|
+
*
|
|
811
|
+
* # Arguments
|
|
812
|
+
* * `trajectory_id` - ID returned from start_trajectory
|
|
813
|
+
* * `node_id` - Graph node visited
|
|
814
|
+
* * `score` - Step quality score [0.0, 1.0]
|
|
815
|
+
* * `latency_us` - Step latency in microseconds
|
|
816
|
+
*
|
|
817
|
+
* # Example
|
|
818
|
+
* ```javascript
|
|
819
|
+
* engine.record_step(trajectoryId, 42, 0.8, 1000);
|
|
820
|
+
* ```
|
|
821
|
+
* @param {bigint} trajectory_id
|
|
822
|
+
* @param {number} node_id
|
|
823
|
+
* @param {number} score
|
|
824
|
+
* @param {bigint} latency_us
|
|
825
|
+
*/
|
|
826
|
+
recordStep(trajectory_id, node_id, score, latency_us) {
|
|
827
|
+
wasm.wasmsonaengine_recordStep(this.__wbg_ptr, trajectory_id, node_id, score, latency_us);
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Enable or disable the engine
|
|
831
|
+
*
|
|
832
|
+
* # Arguments
|
|
833
|
+
* * `enabled` - Whether to enable the engine
|
|
834
|
+
*
|
|
835
|
+
* # Example
|
|
836
|
+
* ```javascript
|
|
837
|
+
* engine.set_enabled(false); // Pause learning
|
|
838
|
+
* ```
|
|
839
|
+
* @param {boolean} enabled
|
|
840
|
+
*/
|
|
841
|
+
setEnabled(enabled) {
|
|
842
|
+
wasm.wasmsonaengine_setEnabled(this.__wbg_ptr, enabled);
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* Create engine with custom configuration
|
|
846
|
+
*
|
|
847
|
+
* # Arguments
|
|
848
|
+
* * `config` - JSON configuration object
|
|
849
|
+
*
|
|
850
|
+
* # Example
|
|
851
|
+
* ```javascript
|
|
852
|
+
* const config = {
|
|
853
|
+
* hidden_dim: 256,
|
|
854
|
+
* embedding_dim: 256,
|
|
855
|
+
* micro_lora_rank: 2,
|
|
856
|
+
* base_lora_rank: 16,
|
|
857
|
+
* micro_lora_lr: 0.001,
|
|
858
|
+
* base_lora_lr: 0.0001,
|
|
859
|
+
* ewc_lambda: 1000.0,
|
|
860
|
+
* pattern_clusters: 128,
|
|
861
|
+
* trajectory_capacity: 10000,
|
|
862
|
+
* quality_threshold: 0.6
|
|
863
|
+
* };
|
|
864
|
+
* const engine = WasmSonaEngine.with_config(config);
|
|
865
|
+
* ```
|
|
866
|
+
* @param {any} config
|
|
867
|
+
* @returns {WasmSonaEngine}
|
|
868
|
+
*/
|
|
869
|
+
static withConfig(config) {
|
|
870
|
+
try {
|
|
871
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
872
|
+
wasm.wasmsonaengine_withConfig(retptr, addHeapObject(config));
|
|
873
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
874
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
875
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
876
|
+
if (r2) {
|
|
877
|
+
throw takeObject(r1);
|
|
878
|
+
}
|
|
879
|
+
return WasmSonaEngine.__wrap(r0);
|
|
880
|
+
} finally {
|
|
881
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Find similar patterns to query
|
|
886
|
+
*
|
|
887
|
+
* # Arguments
|
|
888
|
+
* * `query_embedding` - Query vector as Float32Array
|
|
889
|
+
* * `k` - Number of patterns to return
|
|
890
|
+
*
|
|
891
|
+
* # Returns
|
|
892
|
+
* Array of similar patterns as JSON
|
|
893
|
+
*
|
|
894
|
+
* # Example
|
|
895
|
+
* ```javascript
|
|
896
|
+
* const query = new Float32Array(256).fill(0.5);
|
|
897
|
+
* const patterns = engine.find_patterns(query, 5);
|
|
898
|
+
* console.log('Similar patterns:', patterns);
|
|
899
|
+
* ```
|
|
900
|
+
* @param {Float32Array} query_embedding
|
|
901
|
+
* @param {number} k
|
|
902
|
+
* @returns {any}
|
|
903
|
+
*/
|
|
904
|
+
findPatterns(query_embedding, k) {
|
|
905
|
+
const ptr0 = passArrayF32ToWasm0(query_embedding, wasm.__wbindgen_export);
|
|
906
|
+
const len0 = WASM_VECTOR_LEN;
|
|
907
|
+
const ret = wasm.wasmsonaengine_findPatterns(this.__wbg_ptr, ptr0, len0, k);
|
|
908
|
+
return takeObject(ret);
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* End the trajectory and submit for learning
|
|
912
|
+
*
|
|
913
|
+
* # Arguments
|
|
914
|
+
* * `trajectory_id` - ID returned from start_trajectory
|
|
915
|
+
* * `final_score` - Overall trajectory quality [0.0, 1.0]
|
|
916
|
+
*
|
|
917
|
+
* # Example
|
|
918
|
+
* ```javascript
|
|
919
|
+
* engine.end_trajectory(trajectoryId, 0.85);
|
|
920
|
+
* ```
|
|
921
|
+
* @param {bigint} trajectory_id
|
|
922
|
+
* @param {number} final_score
|
|
923
|
+
*/
|
|
924
|
+
endTrajectory(trajectory_id, final_score) {
|
|
925
|
+
wasm.wasmsonaengine_endTrajectory(this.__wbg_ptr, trajectory_id, final_score);
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* Apply LoRA transformation to specific layer
|
|
929
|
+
*
|
|
930
|
+
* # Arguments
|
|
931
|
+
* * `layer_idx` - Layer index
|
|
932
|
+
* * `input` - Input vector as Float32Array
|
|
933
|
+
*
|
|
934
|
+
* # Returns
|
|
935
|
+
* Transformed vector as Float32Array
|
|
936
|
+
* @param {number} layer_idx
|
|
937
|
+
* @param {Float32Array} input
|
|
938
|
+
* @returns {Float32Array}
|
|
939
|
+
*/
|
|
940
|
+
applyLoraLayer(layer_idx, input) {
|
|
941
|
+
try {
|
|
942
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
943
|
+
const ptr0 = passArrayF32ToWasm0(input, wasm.__wbindgen_export);
|
|
944
|
+
const len0 = WASM_VECTOR_LEN;
|
|
945
|
+
wasm.wasmsonaengine_applyLoraLayer(retptr, this.__wbg_ptr, layer_idx, ptr0, len0);
|
|
946
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
947
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
948
|
+
var v2 = getArrayF32FromWasm0(r0, r1).slice();
|
|
949
|
+
wasm.__wbindgen_export4(r0, r1 * 4, 4);
|
|
950
|
+
return v2;
|
|
951
|
+
} finally {
|
|
952
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Start recording a new trajectory
|
|
957
|
+
*
|
|
958
|
+
* # Arguments
|
|
959
|
+
* * `query_embedding` - Query vector as Float32Array
|
|
960
|
+
*
|
|
961
|
+
* # Returns
|
|
962
|
+
* Trajectory ID (u64)
|
|
963
|
+
*
|
|
964
|
+
* # Example
|
|
965
|
+
* ```javascript
|
|
966
|
+
* const embedding = new Float32Array(256).fill(0.1);
|
|
967
|
+
* const trajectoryId = engine.start_trajectory(embedding);
|
|
968
|
+
* ```
|
|
969
|
+
* @param {Float32Array} query_embedding
|
|
970
|
+
* @returns {bigint}
|
|
971
|
+
*/
|
|
972
|
+
startTrajectory(query_embedding) {
|
|
973
|
+
const ptr0 = passArrayF32ToWasm0(query_embedding, wasm.__wbindgen_export);
|
|
974
|
+
const len0 = WASM_VECTOR_LEN;
|
|
975
|
+
const ret = wasm.wasmsonaengine_startTrajectory(this.__wbg_ptr, ptr0, len0);
|
|
976
|
+
return BigInt.asUintN(64, ret);
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* Run instant learning cycle
|
|
980
|
+
*
|
|
981
|
+
* Flushes accumulated micro-LoRA updates
|
|
982
|
+
*
|
|
983
|
+
* # Example
|
|
984
|
+
* ```javascript
|
|
985
|
+
* engine.run_instant_cycle();
|
|
986
|
+
* ```
|
|
987
|
+
*/
|
|
988
|
+
runInstantCycle() {
|
|
989
|
+
wasm.wasmsonaengine_runInstantCycle(this.__wbg_ptr);
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Apply learning from user feedback
|
|
993
|
+
*
|
|
994
|
+
* # Arguments
|
|
995
|
+
* * `success` - Whether the operation succeeded
|
|
996
|
+
* * `latency_ms` - Operation latency in milliseconds
|
|
997
|
+
* * `quality` - User-perceived quality [0.0, 1.0]
|
|
998
|
+
*
|
|
999
|
+
* # Example
|
|
1000
|
+
* ```javascript
|
|
1001
|
+
* engine.learn_from_feedback(true, 50.0, 0.9);
|
|
1002
|
+
* ```
|
|
1003
|
+
* @param {boolean} success
|
|
1004
|
+
* @param {number} latency_ms
|
|
1005
|
+
* @param {number} quality
|
|
1006
|
+
*/
|
|
1007
|
+
learnFromFeedback(success, latency_ms, quality) {
|
|
1008
|
+
wasm.wasmsonaengine_learnFromFeedback(this.__wbg_ptr, success, latency_ms, quality);
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Create a new SONA engine with specified hidden dimension
|
|
1012
|
+
*
|
|
1013
|
+
* # Arguments
|
|
1014
|
+
* * `hidden_dim` - Size of hidden layer (typically 256, 512, or 1024)
|
|
1015
|
+
*
|
|
1016
|
+
* # Example
|
|
1017
|
+
* ```javascript
|
|
1018
|
+
* const engine = new WasmSonaEngine(256);
|
|
1019
|
+
* ```
|
|
1020
|
+
* @param {number} hidden_dim
|
|
1021
|
+
*/
|
|
1022
|
+
constructor(hidden_dim) {
|
|
1023
|
+
try {
|
|
1024
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1025
|
+
wasm.wasmsonaengine_new(retptr, hidden_dim);
|
|
1026
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1027
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1028
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1029
|
+
if (r2) {
|
|
1030
|
+
throw takeObject(r1);
|
|
1031
|
+
}
|
|
1032
|
+
this.__wbg_ptr = r0 >>> 0;
|
|
1033
|
+
WasmSonaEngineFinalization.register(this, this.__wbg_ptr, this);
|
|
1034
|
+
return this;
|
|
1035
|
+
} finally {
|
|
1036
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
/**
|
|
1040
|
+
* Try to run background learning cycle
|
|
1041
|
+
*
|
|
1042
|
+
* Returns true if cycle was executed, false if not due yet
|
|
1043
|
+
*
|
|
1044
|
+
* # Example
|
|
1045
|
+
* ```javascript
|
|
1046
|
+
* if (engine.tick()) {
|
|
1047
|
+
* console.log('Background learning completed');
|
|
1048
|
+
* }
|
|
1049
|
+
* ```
|
|
1050
|
+
* @returns {boolean}
|
|
1051
|
+
*/
|
|
1052
|
+
tick() {
|
|
1053
|
+
const ret = wasm.wasmsonaengine_tick(this.__wbg_ptr);
|
|
1054
|
+
return ret !== 0;
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Get engine statistics
|
|
1058
|
+
*
|
|
1059
|
+
* # Returns
|
|
1060
|
+
* Statistics as JSON object
|
|
1061
|
+
*
|
|
1062
|
+
* # Example
|
|
1063
|
+
* ```javascript
|
|
1064
|
+
* const stats = engine.get_stats();
|
|
1065
|
+
* console.log('Trajectories buffered:', stats.trajectories_buffered);
|
|
1066
|
+
* console.log('Patterns learned:', stats.patterns_learned);
|
|
1067
|
+
* ```
|
|
1068
|
+
* @returns {any}
|
|
1069
|
+
*/
|
|
1070
|
+
getStats() {
|
|
1071
|
+
const ret = wasm.wasmsonaengine_getStats(this.__wbg_ptr);
|
|
1072
|
+
return takeObject(ret);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
if (Symbol.dispose) WasmSonaEngine.prototype[Symbol.dispose] = WasmSonaEngine.prototype.free;
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* Initialize WASM module (called automatically)
|
|
1079
|
+
*/
|
|
1080
|
+
export function wasm_init() {
|
|
1081
|
+
wasm.wasm_init();
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
1085
|
+
|
|
1086
|
+
async function __wbg_load(module, imports) {
|
|
1087
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
1088
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
1089
|
+
try {
|
|
1090
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1091
|
+
} catch (e) {
|
|
1092
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
1093
|
+
|
|
1094
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
1095
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
1096
|
+
|
|
1097
|
+
} else {
|
|
1098
|
+
throw e;
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
const bytes = await module.arrayBuffer();
|
|
1104
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1105
|
+
} else {
|
|
1106
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
1107
|
+
|
|
1108
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1109
|
+
return { instance, module };
|
|
1110
|
+
} else {
|
|
1111
|
+
return instance;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
function __wbg_get_imports() {
|
|
1117
|
+
const imports = {};
|
|
1118
|
+
imports.wbg = {};
|
|
1119
|
+
imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
|
|
1120
|
+
const ret = debugString(getObject(arg1));
|
|
1121
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1122
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1123
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1124
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1125
|
+
};
|
|
1126
|
+
imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
|
|
1127
|
+
const ret = getObject(arg0) === undefined;
|
|
1128
|
+
return ret;
|
|
1129
|
+
};
|
|
1130
|
+
imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
|
|
1131
|
+
const obj = getObject(arg1);
|
|
1132
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
1133
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1134
|
+
var len1 = WASM_VECTOR_LEN;
|
|
1135
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1136
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1137
|
+
};
|
|
1138
|
+
imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
|
1139
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1140
|
+
};
|
|
1141
|
+
imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
|
|
1142
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
1143
|
+
return addHeapObject(ret);
|
|
1144
|
+
}, arguments) };
|
|
1145
|
+
imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
|
|
1146
|
+
let deferred0_0;
|
|
1147
|
+
let deferred0_1;
|
|
1148
|
+
try {
|
|
1149
|
+
deferred0_0 = arg0;
|
|
1150
|
+
deferred0_1 = arg1;
|
|
1151
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
1152
|
+
} finally {
|
|
1153
|
+
wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
|
|
1154
|
+
}
|
|
1155
|
+
};
|
|
1156
|
+
imports.wbg.__wbg_error_7bc7d576a6aaf855 = function(arg0) {
|
|
1157
|
+
console.error(getObject(arg0));
|
|
1158
|
+
};
|
|
1159
|
+
imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
|
|
1160
|
+
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
1161
|
+
return addHeapObject(ret);
|
|
1162
|
+
}, arguments) };
|
|
1163
|
+
imports.wbg.__wbg_instanceof_Performance_da835352e1f7d1fd = function(arg0) {
|
|
1164
|
+
let result;
|
|
1165
|
+
try {
|
|
1166
|
+
result = getObject(arg0) instanceof Performance;
|
|
1167
|
+
} catch (_) {
|
|
1168
|
+
result = false;
|
|
1169
|
+
}
|
|
1170
|
+
const ret = result;
|
|
1171
|
+
return ret;
|
|
1172
|
+
};
|
|
1173
|
+
imports.wbg.__wbg_log_1d990106d99dacb7 = function(arg0) {
|
|
1174
|
+
console.log(getObject(arg0));
|
|
1175
|
+
};
|
|
1176
|
+
imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
|
|
1177
|
+
const ret = new Error();
|
|
1178
|
+
return addHeapObject(ret);
|
|
1179
|
+
};
|
|
1180
|
+
imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) {
|
|
1181
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
1182
|
+
return addHeapObject(ret);
|
|
1183
|
+
};
|
|
1184
|
+
imports.wbg.__wbg_now_69d776cd24f5215b = function() {
|
|
1185
|
+
const ret = Date.now();
|
|
1186
|
+
return ret;
|
|
1187
|
+
};
|
|
1188
|
+
imports.wbg.__wbg_now_8cf15d6e317793e1 = function(arg0) {
|
|
1189
|
+
const ret = getObject(arg0).now();
|
|
1190
|
+
return ret;
|
|
1191
|
+
};
|
|
1192
|
+
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
1193
|
+
const ret = getObject(arg1).stack;
|
|
1194
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1195
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1196
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1197
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1198
|
+
};
|
|
1199
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() {
|
|
1200
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
1201
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
1202
|
+
};
|
|
1203
|
+
imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() {
|
|
1204
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
1205
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
1206
|
+
};
|
|
1207
|
+
imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() {
|
|
1208
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
1209
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
1210
|
+
};
|
|
1211
|
+
imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() {
|
|
1212
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
1213
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
1214
|
+
};
|
|
1215
|
+
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
1216
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1217
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
1218
|
+
return addHeapObject(ret);
|
|
1219
|
+
};
|
|
1220
|
+
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
|
1221
|
+
const ret = getObject(arg0);
|
|
1222
|
+
return addHeapObject(ret);
|
|
1223
|
+
};
|
|
1224
|
+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
1225
|
+
takeObject(arg0);
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1228
|
+
return imports;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
function __wbg_finalize_init(instance, module) {
|
|
1232
|
+
wasm = instance.exports;
|
|
1233
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
1234
|
+
cachedDataViewMemory0 = null;
|
|
1235
|
+
cachedFloat32ArrayMemory0 = null;
|
|
1236
|
+
cachedUint8ArrayMemory0 = null;
|
|
1237
|
+
|
|
1238
|
+
|
|
1239
|
+
wasm.__wbindgen_start();
|
|
1240
|
+
return wasm;
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
function initSync(module) {
|
|
1244
|
+
if (wasm !== undefined) return wasm;
|
|
1245
|
+
|
|
1246
|
+
|
|
1247
|
+
if (typeof module !== 'undefined') {
|
|
1248
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
1249
|
+
({module} = module)
|
|
1250
|
+
} else {
|
|
1251
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
const imports = __wbg_get_imports();
|
|
1256
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
1257
|
+
module = new WebAssembly.Module(module);
|
|
1258
|
+
}
|
|
1259
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
1260
|
+
return __wbg_finalize_init(instance, module);
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
async function __wbg_init(module_or_path) {
|
|
1264
|
+
if (wasm !== undefined) return wasm;
|
|
1265
|
+
|
|
1266
|
+
|
|
1267
|
+
if (typeof module_or_path !== 'undefined') {
|
|
1268
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1269
|
+
({module_or_path} = module_or_path)
|
|
1270
|
+
} else {
|
|
1271
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
if (typeof module_or_path === 'undefined') {
|
|
1276
|
+
module_or_path = new URL('ruvector_sona_bg.wasm', import.meta.url);
|
|
1277
|
+
}
|
|
1278
|
+
const imports = __wbg_get_imports();
|
|
1279
|
+
|
|
1280
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
1281
|
+
module_or_path = fetch(module_or_path);
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
1285
|
+
|
|
1286
|
+
return __wbg_finalize_init(instance, module);
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
export { initSync };
|
|
1290
|
+
export default __wbg_init;
|