@ruvector/rvagent-wasm 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.
@@ -0,0 +1,1539 @@
1
+ /* @ts-self-types="./rvagent_wasm.d.ts" */
2
+
3
+ /**
4
+ * A model provider that delegates to a JavaScript callback function.
5
+ *
6
+ * The JS callback receives a JSON string of messages and must return
7
+ * a Promise that resolves to a JSON string response.
8
+ *
9
+ * # JavaScript usage
10
+ * ```js
11
+ * const provider = new JsModelProvider(async (messagesJson) => {
12
+ * const messages = JSON.parse(messagesJson);
13
+ * const response = await callMyModel(messages);
14
+ * return JSON.stringify(response);
15
+ * });
16
+ * ```
17
+ */
18
+ export class JsModelProvider {
19
+ __destroy_into_raw() {
20
+ const ptr = this.__wbg_ptr;
21
+ this.__wbg_ptr = 0;
22
+ JsModelProviderFinalization.unregister(this);
23
+ return ptr;
24
+ }
25
+ free() {
26
+ const ptr = this.__destroy_into_raw();
27
+ wasm.__wbg_jsmodelprovider_free(ptr, 0);
28
+ }
29
+ /**
30
+ * Send messages to the JS model provider and get a response.
31
+ *
32
+ * `messages_json` is a JSON-serialized array of message objects.
33
+ * Returns the model's response as a JSON string.
34
+ * @param {string} messages_json
35
+ * @returns {Promise<string>}
36
+ */
37
+ complete(messages_json) {
38
+ const ptr0 = passStringToWasm0(messages_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
39
+ const len0 = WASM_VECTOR_LEN;
40
+ const ret = wasm.jsmodelprovider_complete(this.__wbg_ptr, ptr0, len0);
41
+ return takeObject(ret);
42
+ }
43
+ /**
44
+ * Create a new provider wrapping a JavaScript async function.
45
+ *
46
+ * The function must accept a JSON string and return a Promise<string>.
47
+ * @param {Function} callback
48
+ */
49
+ constructor(callback) {
50
+ try {
51
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
52
+ wasm.jsmodelprovider_new(retptr, addHeapObject(callback));
53
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
54
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
55
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
56
+ if (r2) {
57
+ throw takeObject(r1);
58
+ }
59
+ this.__wbg_ptr = r0 >>> 0;
60
+ JsModelProviderFinalization.register(this, this.__wbg_ptr, this);
61
+ return this;
62
+ } finally {
63
+ wasm.__wbindgen_add_to_stack_pointer(16);
64
+ }
65
+ }
66
+ }
67
+ if (Symbol.dispose) JsModelProvider.prototype[Symbol.dispose] = JsModelProvider.prototype.free;
68
+
69
+ /**
70
+ * rvAgent WASM — browser and Node.js agent execution.
71
+ *
72
+ * Create with `new WasmAgent(configJson)` from JavaScript.
73
+ */
74
+ export class WasmAgent {
75
+ __destroy_into_raw() {
76
+ const ptr = this.__wbg_ptr;
77
+ this.__wbg_ptr = 0;
78
+ WasmAgentFinalization.unregister(this);
79
+ return ptr;
80
+ }
81
+ free() {
82
+ const ptr = this.__destroy_into_raw();
83
+ wasm.__wbg_wasmagent_free(ptr, 0);
84
+ }
85
+ /**
86
+ * Execute a tool directly by passing a JSON tool request.
87
+ * @param {string} tool_json
88
+ * @returns {any}
89
+ */
90
+ execute_tool(tool_json) {
91
+ try {
92
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
93
+ const ptr0 = passStringToWasm0(tool_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
94
+ const len0 = WASM_VECTOR_LEN;
95
+ wasm.wasmagent_execute_tool(retptr, this.__wbg_ptr, ptr0, len0);
96
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
97
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
98
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
99
+ if (r2) {
100
+ throw takeObject(r1);
101
+ }
102
+ return takeObject(r0);
103
+ } finally {
104
+ wasm.__wbindgen_add_to_stack_pointer(16);
105
+ }
106
+ }
107
+ /**
108
+ * Get the number of files in the virtual filesystem.
109
+ * @returns {number}
110
+ */
111
+ file_count() {
112
+ const ret = wasm.wasmagent_file_count(this.__wbg_ptr);
113
+ return ret >>> 0;
114
+ }
115
+ /**
116
+ * Get the current agent state as JSON.
117
+ * @returns {any}
118
+ */
119
+ get_state() {
120
+ try {
121
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
122
+ wasm.wasmagent_get_state(retptr, this.__wbg_ptr);
123
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
124
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
125
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
126
+ if (r2) {
127
+ throw takeObject(r1);
128
+ }
129
+ return takeObject(r0);
130
+ } finally {
131
+ wasm.__wbindgen_add_to_stack_pointer(16);
132
+ }
133
+ }
134
+ /**
135
+ * Get the todo list as JSON.
136
+ * @returns {any}
137
+ */
138
+ get_todos() {
139
+ try {
140
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
141
+ wasm.wasmagent_get_todos(retptr, this.__wbg_ptr);
142
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
143
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
144
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
145
+ if (r2) {
146
+ throw takeObject(r1);
147
+ }
148
+ return takeObject(r0);
149
+ } finally {
150
+ wasm.__wbindgen_add_to_stack_pointer(16);
151
+ }
152
+ }
153
+ /**
154
+ * Get the list of available tools.
155
+ * @returns {any}
156
+ */
157
+ get_tools() {
158
+ try {
159
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
160
+ wasm.wasmagent_get_tools(retptr, this.__wbg_ptr);
161
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
162
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
163
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
164
+ if (r2) {
165
+ throw takeObject(r1);
166
+ }
167
+ return takeObject(r0);
168
+ } finally {
169
+ wasm.__wbindgen_add_to_stack_pointer(16);
170
+ }
171
+ }
172
+ /**
173
+ * Check whether the agent is stopped.
174
+ * @returns {boolean}
175
+ */
176
+ is_stopped() {
177
+ const ret = wasm.wasmagent_is_stopped(this.__wbg_ptr);
178
+ return ret !== 0;
179
+ }
180
+ /**
181
+ * Get the configured model identifier.
182
+ * @returns {string}
183
+ */
184
+ model() {
185
+ let deferred1_0;
186
+ let deferred1_1;
187
+ try {
188
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
189
+ wasm.wasmagent_model(retptr, this.__wbg_ptr);
190
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
191
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
192
+ deferred1_0 = r0;
193
+ deferred1_1 = r1;
194
+ return getStringFromWasm0(r0, r1);
195
+ } finally {
196
+ wasm.__wbindgen_add_to_stack_pointer(16);
197
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
198
+ }
199
+ }
200
+ /**
201
+ * Get the agent name, if configured.
202
+ * @returns {string | undefined}
203
+ */
204
+ name() {
205
+ try {
206
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
207
+ wasm.wasmagent_name(retptr, this.__wbg_ptr);
208
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
209
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
210
+ let v1;
211
+ if (r0 !== 0) {
212
+ v1 = getStringFromWasm0(r0, r1).slice();
213
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
214
+ }
215
+ return v1;
216
+ } finally {
217
+ wasm.__wbindgen_add_to_stack_pointer(16);
218
+ }
219
+ }
220
+ /**
221
+ * Create a new WasmAgent from a JSON configuration string.
222
+ *
223
+ * # Example (JavaScript)
224
+ * ```js
225
+ * const agent = new WasmAgent('{"model": "anthropic:claude-sonnet-4-20250514"}');
226
+ * ```
227
+ * @param {string} config_json
228
+ */
229
+ constructor(config_json) {
230
+ try {
231
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
232
+ const ptr0 = passStringToWasm0(config_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
233
+ const len0 = WASM_VECTOR_LEN;
234
+ wasm.wasmagent_new(retptr, ptr0, len0);
235
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
236
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
237
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
238
+ if (r2) {
239
+ throw takeObject(r1);
240
+ }
241
+ this.__wbg_ptr = r0 >>> 0;
242
+ WasmAgentFinalization.register(this, this.__wbg_ptr, this);
243
+ return this;
244
+ } finally {
245
+ wasm.__wbindgen_add_to_stack_pointer(16);
246
+ }
247
+ }
248
+ /**
249
+ * Send a prompt and get a response.
250
+ *
251
+ * If a model provider is set, the prompt is sent to the JS model.
252
+ * Otherwise, returns an echo response for testing.
253
+ * @param {string} input
254
+ * @returns {Promise<any>}
255
+ */
256
+ prompt(input) {
257
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
258
+ const len0 = WASM_VECTOR_LEN;
259
+ const ret = wasm.wasmagent_prompt(this.__wbg_ptr, ptr0, len0);
260
+ return takeObject(ret);
261
+ }
262
+ /**
263
+ * Reset the agent state, clearing messages and turn count.
264
+ */
265
+ reset() {
266
+ wasm.wasmagent_reset(this.__wbg_ptr);
267
+ }
268
+ /**
269
+ * Attach a JavaScript model provider callback.
270
+ *
271
+ * The callback receives a JSON string of messages and must return
272
+ * a `Promise<string>` with the model response.
273
+ * @param {Function} callback
274
+ */
275
+ set_model_provider(callback) {
276
+ try {
277
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
278
+ wasm.wasmagent_set_model_provider(retptr, this.__wbg_ptr, addHeapObject(callback));
279
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
280
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
281
+ if (r1) {
282
+ throw takeObject(r0);
283
+ }
284
+ } finally {
285
+ wasm.__wbindgen_add_to_stack_pointer(16);
286
+ }
287
+ }
288
+ /**
289
+ * Get the current turn count.
290
+ * @returns {number}
291
+ */
292
+ turn_count() {
293
+ const ret = wasm.wasmagent_turn_count(this.__wbg_ptr);
294
+ return ret >>> 0;
295
+ }
296
+ /**
297
+ * Get the crate version.
298
+ * @returns {string}
299
+ */
300
+ static version() {
301
+ let deferred1_0;
302
+ let deferred1_1;
303
+ try {
304
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
305
+ wasm.wasmagent_version(retptr);
306
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
307
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
308
+ deferred1_0 = r0;
309
+ deferred1_1 = r1;
310
+ return getStringFromWasm0(r0, r1);
311
+ } finally {
312
+ wasm.__wbindgen_add_to_stack_pointer(16);
313
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
314
+ }
315
+ }
316
+ }
317
+ if (Symbol.dispose) WasmAgent.prototype[Symbol.dispose] = WasmAgent.prototype.free;
318
+
319
+ /**
320
+ * RVF App Gallery — browse, load, and configure agent templates.
321
+ *
322
+ * # Example (JavaScript)
323
+ * ```js
324
+ * const gallery = new WasmGallery();
325
+ *
326
+ * // List all templates
327
+ * const templates = gallery.list();
328
+ *
329
+ * // Search by tags
330
+ * const results = gallery.search("security testing");
331
+ *
332
+ * // Get template details
333
+ * const template = gallery.get("coder");
334
+ *
335
+ * // Load as RVF container
336
+ * const rvfBytes = gallery.loadRvf("coder");
337
+ *
338
+ * // Configure template
339
+ * gallery.configure("coder", { maxTurns: 100 });
340
+ * ```
341
+ */
342
+ export class WasmGallery {
343
+ __destroy_into_raw() {
344
+ const ptr = this.__wbg_ptr;
345
+ this.__wbg_ptr = 0;
346
+ WasmGalleryFinalization.unregister(this);
347
+ return ptr;
348
+ }
349
+ free() {
350
+ const ptr = this.__destroy_into_raw();
351
+ wasm.__wbg_wasmgallery_free(ptr, 0);
352
+ }
353
+ /**
354
+ * Add a custom template to the gallery.
355
+ * @param {string} template_json
356
+ */
357
+ addCustom(template_json) {
358
+ try {
359
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
360
+ const ptr0 = passStringToWasm0(template_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
361
+ const len0 = WASM_VECTOR_LEN;
362
+ wasm.wasmgallery_addCustom(retptr, this.__wbg_ptr, ptr0, len0);
363
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
364
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
365
+ if (r1) {
366
+ throw takeObject(r0);
367
+ }
368
+ } finally {
369
+ wasm.__wbindgen_add_to_stack_pointer(16);
370
+ }
371
+ }
372
+ /**
373
+ * Configure the active template with overrides.
374
+ * @param {string} config_json
375
+ */
376
+ configure(config_json) {
377
+ try {
378
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
379
+ const ptr0 = passStringToWasm0(config_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
380
+ const len0 = WASM_VECTOR_LEN;
381
+ wasm.wasmgallery_configure(retptr, this.__wbg_ptr, ptr0, len0);
382
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
383
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
384
+ if (r1) {
385
+ throw takeObject(r0);
386
+ }
387
+ } finally {
388
+ wasm.__wbindgen_add_to_stack_pointer(16);
389
+ }
390
+ }
391
+ /**
392
+ * Get the number of templates in the gallery.
393
+ * @returns {number}
394
+ */
395
+ count() {
396
+ const ret = wasm.wasmgallery_count(this.__wbg_ptr);
397
+ return ret >>> 0;
398
+ }
399
+ /**
400
+ * Export all custom templates as JSON.
401
+ * @returns {any}
402
+ */
403
+ exportCustom() {
404
+ try {
405
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
406
+ wasm.wasmgallery_exportCustom(retptr, this.__wbg_ptr);
407
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
408
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
409
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
410
+ if (r2) {
411
+ throw takeObject(r1);
412
+ }
413
+ return takeObject(r0);
414
+ } finally {
415
+ wasm.__wbindgen_add_to_stack_pointer(16);
416
+ }
417
+ }
418
+ /**
419
+ * Get a template by ID.
420
+ * @param {string} id
421
+ * @returns {any}
422
+ */
423
+ get(id) {
424
+ try {
425
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
426
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
427
+ const len0 = WASM_VECTOR_LEN;
428
+ wasm.wasmgallery_get(retptr, this.__wbg_ptr, ptr0, len0);
429
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
430
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
431
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
432
+ if (r2) {
433
+ throw takeObject(r1);
434
+ }
435
+ return takeObject(r0);
436
+ } finally {
437
+ wasm.__wbindgen_add_to_stack_pointer(16);
438
+ }
439
+ }
440
+ /**
441
+ * Get the currently active template ID.
442
+ * @returns {string | undefined}
443
+ */
444
+ getActive() {
445
+ try {
446
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
447
+ wasm.wasmgallery_getActive(retptr, this.__wbg_ptr);
448
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
449
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
450
+ let v1;
451
+ if (r0 !== 0) {
452
+ v1 = getStringFromWasm0(r0, r1).slice();
453
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
454
+ }
455
+ return v1;
456
+ } finally {
457
+ wasm.__wbindgen_add_to_stack_pointer(16);
458
+ }
459
+ }
460
+ /**
461
+ * Get all categories with template counts.
462
+ * @returns {any}
463
+ */
464
+ getCategories() {
465
+ try {
466
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
467
+ wasm.wasmgallery_getCategories(retptr, this.__wbg_ptr);
468
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
469
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
470
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
471
+ if (r2) {
472
+ throw takeObject(r1);
473
+ }
474
+ return takeObject(r0);
475
+ } finally {
476
+ wasm.__wbindgen_add_to_stack_pointer(16);
477
+ }
478
+ }
479
+ /**
480
+ * Get configuration overrides for active template.
481
+ * @returns {any}
482
+ */
483
+ getConfig() {
484
+ try {
485
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
486
+ wasm.wasmgallery_getConfig(retptr, this.__wbg_ptr);
487
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
488
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
489
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
490
+ if (r2) {
491
+ throw takeObject(r1);
492
+ }
493
+ return takeObject(r0);
494
+ } finally {
495
+ wasm.__wbindgen_add_to_stack_pointer(16);
496
+ }
497
+ }
498
+ /**
499
+ * Import custom templates from JSON.
500
+ * @param {string} templates_json
501
+ * @returns {number}
502
+ */
503
+ importCustom(templates_json) {
504
+ try {
505
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
506
+ const ptr0 = passStringToWasm0(templates_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
507
+ const len0 = WASM_VECTOR_LEN;
508
+ wasm.wasmgallery_importCustom(retptr, this.__wbg_ptr, ptr0, len0);
509
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
510
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
511
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
512
+ if (r2) {
513
+ throw takeObject(r1);
514
+ }
515
+ return r0 >>> 0;
516
+ } finally {
517
+ wasm.__wbindgen_add_to_stack_pointer(16);
518
+ }
519
+ }
520
+ /**
521
+ * List all available templates.
522
+ * @returns {any}
523
+ */
524
+ list() {
525
+ try {
526
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
527
+ wasm.wasmgallery_list(retptr, this.__wbg_ptr);
528
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
529
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
530
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
531
+ if (r2) {
532
+ throw takeObject(r1);
533
+ }
534
+ return takeObject(r0);
535
+ } finally {
536
+ wasm.__wbindgen_add_to_stack_pointer(16);
537
+ }
538
+ }
539
+ /**
540
+ * List templates by category.
541
+ * @param {string} category
542
+ * @returns {any}
543
+ */
544
+ listByCategory(category) {
545
+ try {
546
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
547
+ const ptr0 = passStringToWasm0(category, wasm.__wbindgen_export, wasm.__wbindgen_export2);
548
+ const len0 = WASM_VECTOR_LEN;
549
+ wasm.wasmgallery_listByCategory(retptr, this.__wbg_ptr, ptr0, len0);
550
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
551
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
552
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
553
+ if (r2) {
554
+ throw takeObject(r1);
555
+ }
556
+ return takeObject(r0);
557
+ } finally {
558
+ wasm.__wbindgen_add_to_stack_pointer(16);
559
+ }
560
+ }
561
+ /**
562
+ * Load a template as an RVF container (returns Uint8Array).
563
+ * @param {string} id
564
+ * @returns {Uint8Array}
565
+ */
566
+ loadRvf(id) {
567
+ try {
568
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
569
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
570
+ const len0 = WASM_VECTOR_LEN;
571
+ wasm.wasmgallery_loadRvf(retptr, this.__wbg_ptr, ptr0, len0);
572
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
573
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
574
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
575
+ if (r2) {
576
+ throw takeObject(r1);
577
+ }
578
+ return takeObject(r0);
579
+ } finally {
580
+ wasm.__wbindgen_add_to_stack_pointer(16);
581
+ }
582
+ }
583
+ /**
584
+ * Create a new gallery with built-in templates.
585
+ */
586
+ constructor() {
587
+ const ret = wasm.wasmgallery_new();
588
+ this.__wbg_ptr = ret >>> 0;
589
+ WasmGalleryFinalization.register(this, this.__wbg_ptr, this);
590
+ return this;
591
+ }
592
+ /**
593
+ * Remove a custom template by ID.
594
+ * @param {string} id
595
+ */
596
+ removeCustom(id) {
597
+ try {
598
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
599
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
600
+ const len0 = WASM_VECTOR_LEN;
601
+ wasm.wasmgallery_removeCustom(retptr, this.__wbg_ptr, ptr0, len0);
602
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
603
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
604
+ if (r1) {
605
+ throw takeObject(r0);
606
+ }
607
+ } finally {
608
+ wasm.__wbindgen_add_to_stack_pointer(16);
609
+ }
610
+ }
611
+ /**
612
+ * Search templates by query (matches name, description, tags).
613
+ * @param {string} query
614
+ * @returns {any}
615
+ */
616
+ search(query) {
617
+ try {
618
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
619
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
620
+ const len0 = WASM_VECTOR_LEN;
621
+ wasm.wasmgallery_search(retptr, this.__wbg_ptr, ptr0, len0);
622
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
623
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
624
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
625
+ if (r2) {
626
+ throw takeObject(r1);
627
+ }
628
+ return takeObject(r0);
629
+ } finally {
630
+ wasm.__wbindgen_add_to_stack_pointer(16);
631
+ }
632
+ }
633
+ /**
634
+ * Set a template as active for use.
635
+ * @param {string} id
636
+ */
637
+ setActive(id) {
638
+ try {
639
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
640
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
641
+ const len0 = WASM_VECTOR_LEN;
642
+ wasm.wasmgallery_setActive(retptr, this.__wbg_ptr, ptr0, len0);
643
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
644
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
645
+ if (r1) {
646
+ throw takeObject(r0);
647
+ }
648
+ } finally {
649
+ wasm.__wbindgen_add_to_stack_pointer(16);
650
+ }
651
+ }
652
+ }
653
+ if (Symbol.dispose) WasmGallery.prototype[Symbol.dispose] = WasmGallery.prototype.free;
654
+
655
+ /**
656
+ * WASM MCP Server — runs the MCP protocol entirely in the browser.
657
+ *
658
+ * This server exposes rvAgent tools via MCP JSON-RPC, enabling integration
659
+ * with MCP clients without requiring a separate server process.
660
+ *
661
+ * # Example (JavaScript)
662
+ * ```js
663
+ * const mcp = new WasmMcpServer("rvagent-wasm");
664
+ *
665
+ * // Handle request
666
+ * const response = mcp.handleRequest(JSON.stringify({
667
+ * jsonrpc: "2.0",
668
+ * id: 1,
669
+ * method: "tools/list",
670
+ * params: {}
671
+ * }));
672
+ * console.log(response);
673
+ * ```
674
+ */
675
+ export class WasmMcpServer {
676
+ __destroy_into_raw() {
677
+ const ptr = this.__wbg_ptr;
678
+ this.__wbg_ptr = 0;
679
+ WasmMcpServerFinalization.unregister(this);
680
+ return ptr;
681
+ }
682
+ free() {
683
+ const ptr = this.__destroy_into_raw();
684
+ wasm.__wbg_wasmmcpserver_free(ptr, 0);
685
+ }
686
+ /**
687
+ * Execute a tool by name with JSON parameters.
688
+ * @param {string} name
689
+ * @param {string} params_json
690
+ * @returns {any}
691
+ */
692
+ call_tool(name, params_json) {
693
+ try {
694
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
695
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
696
+ const len0 = WASM_VECTOR_LEN;
697
+ const ptr1 = passStringToWasm0(params_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
698
+ const len1 = WASM_VECTOR_LEN;
699
+ wasm.wasmmcpserver_call_tool(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
700
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
701
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
702
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
703
+ if (r2) {
704
+ throw takeObject(r1);
705
+ }
706
+ return takeObject(r0);
707
+ } finally {
708
+ wasm.__wbindgen_add_to_stack_pointer(16);
709
+ }
710
+ }
711
+ /**
712
+ * Get the gallery instance for direct access.
713
+ * @returns {any}
714
+ */
715
+ gallery() {
716
+ try {
717
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
718
+ wasm.wasmmcpserver_gallery(retptr, this.__wbg_ptr);
719
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
720
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
721
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
722
+ if (r2) {
723
+ throw takeObject(r1);
724
+ }
725
+ return takeObject(r0);
726
+ } finally {
727
+ wasm.__wbindgen_add_to_stack_pointer(16);
728
+ }
729
+ }
730
+ /**
731
+ * Handle a JSON-RPC request and return a JSON-RPC response.
732
+ * @param {string} request_json
733
+ * @returns {any}
734
+ */
735
+ handle_request(request_json) {
736
+ try {
737
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
738
+ const ptr0 = passStringToWasm0(request_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
739
+ const len0 = WASM_VECTOR_LEN;
740
+ wasm.wasmmcpserver_handle_request(retptr, this.__wbg_ptr, ptr0, len0);
741
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
742
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
743
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
744
+ if (r2) {
745
+ throw takeObject(r1);
746
+ }
747
+ return takeObject(r0);
748
+ } finally {
749
+ wasm.__wbindgen_add_to_stack_pointer(16);
750
+ }
751
+ }
752
+ /**
753
+ * Check if the server has been initialized.
754
+ * @returns {boolean}
755
+ */
756
+ is_initialized() {
757
+ const ret = wasm.wasmmcpserver_is_initialized(this.__wbg_ptr);
758
+ return ret !== 0;
759
+ }
760
+ /**
761
+ * Get the list of available tools as JSON.
762
+ * @returns {any}
763
+ */
764
+ list_tools() {
765
+ try {
766
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
767
+ wasm.wasmmcpserver_list_tools(retptr, this.__wbg_ptr);
768
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
769
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
770
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
771
+ if (r2) {
772
+ throw takeObject(r1);
773
+ }
774
+ return takeObject(r0);
775
+ } finally {
776
+ wasm.__wbindgen_add_to_stack_pointer(16);
777
+ }
778
+ }
779
+ /**
780
+ * Get the server name.
781
+ * @returns {string}
782
+ */
783
+ name() {
784
+ let deferred1_0;
785
+ let deferred1_1;
786
+ try {
787
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
788
+ wasm.wasmmcpserver_name(retptr, this.__wbg_ptr);
789
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
790
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
791
+ deferred1_0 = r0;
792
+ deferred1_1 = r1;
793
+ return getStringFromWasm0(r0, r1);
794
+ } finally {
795
+ wasm.__wbindgen_add_to_stack_pointer(16);
796
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
797
+ }
798
+ }
799
+ /**
800
+ * Create a new WasmMcpServer with the given name.
801
+ * @param {string} name
802
+ */
803
+ constructor(name) {
804
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
805
+ const len0 = WASM_VECTOR_LEN;
806
+ const ret = wasm.wasmmcpserver_new(ptr0, len0);
807
+ this.__wbg_ptr = ret >>> 0;
808
+ WasmMcpServerFinalization.register(this, this.__wbg_ptr, this);
809
+ return this;
810
+ }
811
+ /**
812
+ * Get the server version.
813
+ * @returns {string}
814
+ */
815
+ version() {
816
+ let deferred1_0;
817
+ let deferred1_1;
818
+ try {
819
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
820
+ wasm.wasmmcpserver_version(retptr, this.__wbg_ptr);
821
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
822
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
823
+ deferred1_0 = r0;
824
+ deferred1_1 = r1;
825
+ return getStringFromWasm0(r0, r1);
826
+ } finally {
827
+ wasm.__wbindgen_add_to_stack_pointer(16);
828
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
829
+ }
830
+ }
831
+ }
832
+ if (Symbol.dispose) WasmMcpServer.prototype[Symbol.dispose] = WasmMcpServer.prototype.free;
833
+
834
+ /**
835
+ * RVF Container Builder for WASM.
836
+ *
837
+ * Build RVF cognitive containers that package tools, prompts, skills,
838
+ * orchestrator configs, MCP tools, and Ruvix capabilities.
839
+ *
840
+ * # Example (JavaScript)
841
+ * ```js
842
+ * const builder = new WasmRvfBuilder();
843
+ * builder.addTool({ name: "search", description: "Web search", parameters: {} });
844
+ * builder.addPrompt({ name: "coder", system_prompt: "You are a coder", version: "1.0" });
845
+ * const container = builder.build();
846
+ * // container is Uint8Array with RVF magic bytes
847
+ * ```
848
+ */
849
+ export class WasmRvfBuilder {
850
+ __destroy_into_raw() {
851
+ const ptr = this.__wbg_ptr;
852
+ this.__wbg_ptr = 0;
853
+ WasmRvfBuilderFinalization.unregister(this);
854
+ return ptr;
855
+ }
856
+ free() {
857
+ const ptr = this.__destroy_into_raw();
858
+ wasm.__wbg_wasmrvfbuilder_free(ptr, 0);
859
+ }
860
+ /**
861
+ * Add Ruvix capability definitions.
862
+ * @param {string} caps_json
863
+ */
864
+ addCapabilities(caps_json) {
865
+ try {
866
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
867
+ const ptr0 = passStringToWasm0(caps_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
868
+ const len0 = WASM_VECTOR_LEN;
869
+ wasm.wasmrvfbuilder_addCapabilities(retptr, this.__wbg_ptr, ptr0, len0);
870
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
871
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
872
+ if (r1) {
873
+ throw takeObject(r0);
874
+ }
875
+ } finally {
876
+ wasm.__wbindgen_add_to_stack_pointer(16);
877
+ }
878
+ }
879
+ /**
880
+ * Add MCP tool entries.
881
+ * @param {string} tools_json
882
+ */
883
+ addMcpTools(tools_json) {
884
+ try {
885
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
886
+ const ptr0 = passStringToWasm0(tools_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
887
+ const len0 = WASM_VECTOR_LEN;
888
+ wasm.wasmrvfbuilder_addMcpTools(retptr, this.__wbg_ptr, ptr0, len0);
889
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
890
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
891
+ if (r1) {
892
+ throw takeObject(r0);
893
+ }
894
+ } finally {
895
+ wasm.__wbindgen_add_to_stack_pointer(16);
896
+ }
897
+ }
898
+ /**
899
+ * Add an agent prompt.
900
+ * @param {string} prompt_json
901
+ */
902
+ addPrompt(prompt_json) {
903
+ try {
904
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
905
+ const ptr0 = passStringToWasm0(prompt_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
906
+ const len0 = WASM_VECTOR_LEN;
907
+ wasm.wasmrvfbuilder_addPrompt(retptr, this.__wbg_ptr, ptr0, len0);
908
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
909
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
910
+ if (r1) {
911
+ throw takeObject(r0);
912
+ }
913
+ } finally {
914
+ wasm.__wbindgen_add_to_stack_pointer(16);
915
+ }
916
+ }
917
+ /**
918
+ * Add multiple prompts from JSON array.
919
+ * @param {string} prompts_json
920
+ */
921
+ addPrompts(prompts_json) {
922
+ try {
923
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
924
+ const ptr0 = passStringToWasm0(prompts_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
925
+ const len0 = WASM_VECTOR_LEN;
926
+ wasm.wasmrvfbuilder_addPrompts(retptr, this.__wbg_ptr, ptr0, len0);
927
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
928
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
929
+ if (r1) {
930
+ throw takeObject(r0);
931
+ }
932
+ } finally {
933
+ wasm.__wbindgen_add_to_stack_pointer(16);
934
+ }
935
+ }
936
+ /**
937
+ * Add a skill definition.
938
+ * @param {string} skill_json
939
+ */
940
+ addSkill(skill_json) {
941
+ try {
942
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
943
+ const ptr0 = passStringToWasm0(skill_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
944
+ const len0 = WASM_VECTOR_LEN;
945
+ wasm.wasmrvfbuilder_addSkill(retptr, this.__wbg_ptr, ptr0, len0);
946
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
947
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
948
+ if (r1) {
949
+ throw takeObject(r0);
950
+ }
951
+ } finally {
952
+ wasm.__wbindgen_add_to_stack_pointer(16);
953
+ }
954
+ }
955
+ /**
956
+ * Add multiple skills from JSON array.
957
+ * @param {string} skills_json
958
+ */
959
+ addSkills(skills_json) {
960
+ try {
961
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
962
+ const ptr0 = passStringToWasm0(skills_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
963
+ const len0 = WASM_VECTOR_LEN;
964
+ wasm.wasmrvfbuilder_addSkills(retptr, this.__wbg_ptr, ptr0, len0);
965
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
966
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
967
+ if (r1) {
968
+ throw takeObject(r0);
969
+ }
970
+ } finally {
971
+ wasm.__wbindgen_add_to_stack_pointer(16);
972
+ }
973
+ }
974
+ /**
975
+ * Add a tool definition.
976
+ * @param {string} tool_json
977
+ */
978
+ addTool(tool_json) {
979
+ try {
980
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
981
+ const ptr0 = passStringToWasm0(tool_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
982
+ const len0 = WASM_VECTOR_LEN;
983
+ wasm.wasmrvfbuilder_addTool(retptr, this.__wbg_ptr, ptr0, len0);
984
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
985
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
986
+ if (r1) {
987
+ throw takeObject(r0);
988
+ }
989
+ } finally {
990
+ wasm.__wbindgen_add_to_stack_pointer(16);
991
+ }
992
+ }
993
+ /**
994
+ * Add multiple tools from JSON array.
995
+ * @param {string} tools_json
996
+ */
997
+ addTools(tools_json) {
998
+ try {
999
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1000
+ const ptr0 = passStringToWasm0(tools_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1001
+ const len0 = WASM_VECTOR_LEN;
1002
+ wasm.wasmrvfbuilder_addTools(retptr, this.__wbg_ptr, ptr0, len0);
1003
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1004
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1005
+ if (r1) {
1006
+ throw takeObject(r0);
1007
+ }
1008
+ } finally {
1009
+ wasm.__wbindgen_add_to_stack_pointer(16);
1010
+ }
1011
+ }
1012
+ /**
1013
+ * Build the RVF container as bytes.
1014
+ *
1015
+ * Returns a Uint8Array containing the RVF binary:
1016
+ * - Magic bytes: "RVF\x01" (4 bytes)
1017
+ * - Segment count: u32 LE (4 bytes)
1018
+ * - Segments: type(1) + tag(2) + len(4) + data
1019
+ * - Checksum: SHA3-256 (32 bytes)
1020
+ * @returns {Uint8Array}
1021
+ */
1022
+ build() {
1023
+ try {
1024
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1025
+ wasm.wasmrvfbuilder_build(retptr, this.__wbg_ptr);
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
+ return takeObject(r0);
1033
+ } finally {
1034
+ wasm.__wbindgen_add_to_stack_pointer(16);
1035
+ }
1036
+ }
1037
+ /**
1038
+ * Get the RVF magic bytes for detection.
1039
+ * @returns {Uint8Array}
1040
+ */
1041
+ static getMagic() {
1042
+ const ret = wasm.wasmrvfbuilder_getMagic();
1043
+ return takeObject(ret);
1044
+ }
1045
+ /**
1046
+ * Create a new RVF container builder.
1047
+ */
1048
+ constructor() {
1049
+ const ret = wasm.wasmrvfbuilder_new();
1050
+ this.__wbg_ptr = ret >>> 0;
1051
+ WasmRvfBuilderFinalization.register(this, this.__wbg_ptr, this);
1052
+ return this;
1053
+ }
1054
+ /**
1055
+ * Parse an RVF container from bytes.
1056
+ * @param {Uint8Array} data
1057
+ * @returns {any}
1058
+ */
1059
+ static parse(data) {
1060
+ try {
1061
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1062
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
1063
+ const len0 = WASM_VECTOR_LEN;
1064
+ wasm.wasmrvfbuilder_parse(retptr, ptr0, len0);
1065
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1066
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1067
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1068
+ if (r2) {
1069
+ throw takeObject(r1);
1070
+ }
1071
+ return takeObject(r0);
1072
+ } finally {
1073
+ wasm.__wbindgen_add_to_stack_pointer(16);
1074
+ }
1075
+ }
1076
+ /**
1077
+ * Set orchestrator configuration.
1078
+ * @param {string} config_json
1079
+ */
1080
+ setOrchestrator(config_json) {
1081
+ try {
1082
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1083
+ const ptr0 = passStringToWasm0(config_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1084
+ const len0 = WASM_VECTOR_LEN;
1085
+ wasm.wasmrvfbuilder_setOrchestrator(retptr, this.__wbg_ptr, ptr0, len0);
1086
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1087
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1088
+ if (r1) {
1089
+ throw takeObject(r0);
1090
+ }
1091
+ } finally {
1092
+ wasm.__wbindgen_add_to_stack_pointer(16);
1093
+ }
1094
+ }
1095
+ /**
1096
+ * Validate an RVF container (check magic and checksum).
1097
+ * @param {Uint8Array} data
1098
+ * @returns {boolean}
1099
+ */
1100
+ static validate(data) {
1101
+ try {
1102
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1103
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
1104
+ const len0 = WASM_VECTOR_LEN;
1105
+ wasm.wasmrvfbuilder_validate(retptr, ptr0, len0);
1106
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1107
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1108
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1109
+ if (r2) {
1110
+ throw takeObject(r1);
1111
+ }
1112
+ return r0 !== 0;
1113
+ } finally {
1114
+ wasm.__wbindgen_add_to_stack_pointer(16);
1115
+ }
1116
+ }
1117
+ }
1118
+ if (Symbol.dispose) WasmRvfBuilder.prototype[Symbol.dispose] = WasmRvfBuilder.prototype.free;
1119
+
1120
+ function __wbg_get_imports() {
1121
+ const import0 = {
1122
+ __proto__: null,
1123
+ __wbg___wbindgen_is_function_d633e708baf0d146: function(arg0) {
1124
+ const ret = typeof(getObject(arg0)) === 'function';
1125
+ return ret;
1126
+ },
1127
+ __wbg___wbindgen_is_undefined_c18285b9fc34cb7d: function(arg0) {
1128
+ const ret = getObject(arg0) === undefined;
1129
+ return ret;
1130
+ },
1131
+ __wbg___wbindgen_string_get_3e5751597f39a112: function(arg0, arg1) {
1132
+ const obj = getObject(arg1);
1133
+ const ret = typeof(obj) === 'string' ? obj : undefined;
1134
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1135
+ var len1 = WASM_VECTOR_LEN;
1136
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1137
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1138
+ },
1139
+ __wbg___wbindgen_throw_39bc967c0e5a9b58: function(arg0, arg1) {
1140
+ throw new Error(getStringFromWasm0(arg0, arg1));
1141
+ },
1142
+ __wbg__wbg_cb_unref_b6d832240a919168: function(arg0) {
1143
+ getObject(arg0)._wbg_cb_unref();
1144
+ },
1145
+ __wbg_call_08ad0d89caa7cb79: function() { return handleError(function (arg0, arg1, arg2) {
1146
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
1147
+ return addHeapObject(ret);
1148
+ }, arguments); },
1149
+ __wbg_instanceof_Promise_44e4f673e91c710d: function(arg0) {
1150
+ let result;
1151
+ try {
1152
+ result = getObject(arg0) instanceof Promise;
1153
+ } catch (_) {
1154
+ result = false;
1155
+ }
1156
+ const ret = result;
1157
+ return ret;
1158
+ },
1159
+ __wbg_new_from_slice_d7e202fdbee3c396: function(arg0, arg1) {
1160
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
1161
+ return addHeapObject(ret);
1162
+ },
1163
+ __wbg_new_typed_8258a0d8488ef2a2: function(arg0, arg1) {
1164
+ try {
1165
+ var state0 = {a: arg0, b: arg1};
1166
+ var cb0 = (arg0, arg1) => {
1167
+ const a = state0.a;
1168
+ state0.a = 0;
1169
+ try {
1170
+ return __wasm_bindgen_func_elem_535(a, state0.b, arg0, arg1);
1171
+ } finally {
1172
+ state0.a = a;
1173
+ }
1174
+ };
1175
+ const ret = new Promise(cb0);
1176
+ return addHeapObject(ret);
1177
+ } finally {
1178
+ state0.a = state0.b = 0;
1179
+ }
1180
+ },
1181
+ __wbg_parse_6dfe891b5bafb5cd: function() { return handleError(function (arg0, arg1) {
1182
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
1183
+ return addHeapObject(ret);
1184
+ }, arguments); },
1185
+ __wbg_queueMicrotask_2c8dfd1056f24fdc: function(arg0) {
1186
+ const ret = getObject(arg0).queueMicrotask;
1187
+ return addHeapObject(ret);
1188
+ },
1189
+ __wbg_queueMicrotask_8985ad63815852e7: function(arg0) {
1190
+ queueMicrotask(getObject(arg0));
1191
+ },
1192
+ __wbg_resolve_5d61e0d10c14730a: function(arg0) {
1193
+ const ret = Promise.resolve(getObject(arg0));
1194
+ return addHeapObject(ret);
1195
+ },
1196
+ __wbg_static_accessor_GLOBAL_THIS_14325d8cca34bb77: function() {
1197
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
1198
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
1199
+ },
1200
+ __wbg_static_accessor_GLOBAL_f3a1e69f9c5a7e8e: function() {
1201
+ const ret = typeof global === 'undefined' ? null : global;
1202
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
1203
+ },
1204
+ __wbg_static_accessor_SELF_50cdb5b517789aca: function() {
1205
+ const ret = typeof self === 'undefined' ? null : self;
1206
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
1207
+ },
1208
+ __wbg_static_accessor_WINDOW_d6c4126e4c244380: function() {
1209
+ const ret = typeof window === 'undefined' ? null : window;
1210
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
1211
+ },
1212
+ __wbg_then_d4163530723f56f4: function(arg0, arg1, arg2) {
1213
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
1214
+ return addHeapObject(ret);
1215
+ },
1216
+ __wbg_then_f1c954fe00733701: function(arg0, arg1) {
1217
+ const ret = getObject(arg0).then(getObject(arg1));
1218
+ return addHeapObject(ret);
1219
+ },
1220
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1221
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 64, function: Function { arguments: [Externref], shim_idx: 65, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1222
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_497, __wasm_bindgen_func_elem_498);
1223
+ return addHeapObject(ret);
1224
+ },
1225
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
1226
+ // Cast intrinsic for `Ref(String) -> Externref`.
1227
+ const ret = getStringFromWasm0(arg0, arg1);
1228
+ return addHeapObject(ret);
1229
+ },
1230
+ __wbindgen_object_clone_ref: function(arg0) {
1231
+ const ret = getObject(arg0);
1232
+ return addHeapObject(ret);
1233
+ },
1234
+ __wbindgen_object_drop_ref: function(arg0) {
1235
+ takeObject(arg0);
1236
+ },
1237
+ };
1238
+ return {
1239
+ __proto__: null,
1240
+ "./rvagent_wasm_bg.js": import0,
1241
+ };
1242
+ }
1243
+
1244
+ function __wasm_bindgen_func_elem_498(arg0, arg1, arg2) {
1245
+ try {
1246
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1247
+ wasm.__wasm_bindgen_func_elem_498(retptr, arg0, arg1, addHeapObject(arg2));
1248
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1249
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1250
+ if (r1) {
1251
+ throw takeObject(r0);
1252
+ }
1253
+ } finally {
1254
+ wasm.__wbindgen_add_to_stack_pointer(16);
1255
+ }
1256
+ }
1257
+
1258
+ function __wasm_bindgen_func_elem_535(arg0, arg1, arg2, arg3) {
1259
+ wasm.__wasm_bindgen_func_elem_535(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1260
+ }
1261
+
1262
+ const JsModelProviderFinalization = (typeof FinalizationRegistry === 'undefined')
1263
+ ? { register: () => {}, unregister: () => {} }
1264
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsmodelprovider_free(ptr >>> 0, 1));
1265
+ const WasmAgentFinalization = (typeof FinalizationRegistry === 'undefined')
1266
+ ? { register: () => {}, unregister: () => {} }
1267
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmagent_free(ptr >>> 0, 1));
1268
+ const WasmGalleryFinalization = (typeof FinalizationRegistry === 'undefined')
1269
+ ? { register: () => {}, unregister: () => {} }
1270
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmgallery_free(ptr >>> 0, 1));
1271
+ const WasmMcpServerFinalization = (typeof FinalizationRegistry === 'undefined')
1272
+ ? { register: () => {}, unregister: () => {} }
1273
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmmcpserver_free(ptr >>> 0, 1));
1274
+ const WasmRvfBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
1275
+ ? { register: () => {}, unregister: () => {} }
1276
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmrvfbuilder_free(ptr >>> 0, 1));
1277
+
1278
+ function addHeapObject(obj) {
1279
+ if (heap_next === heap.length) heap.push(heap.length + 1);
1280
+ const idx = heap_next;
1281
+ heap_next = heap[idx];
1282
+
1283
+ heap[idx] = obj;
1284
+ return idx;
1285
+ }
1286
+
1287
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
1288
+ ? { register: () => {}, unregister: () => {} }
1289
+ : new FinalizationRegistry(state => state.dtor(state.a, state.b));
1290
+
1291
+ function dropObject(idx) {
1292
+ if (idx < 1028) return;
1293
+ heap[idx] = heap_next;
1294
+ heap_next = idx;
1295
+ }
1296
+
1297
+ function getArrayU8FromWasm0(ptr, len) {
1298
+ ptr = ptr >>> 0;
1299
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1300
+ }
1301
+
1302
+ let cachedDataViewMemory0 = null;
1303
+ function getDataViewMemory0() {
1304
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
1305
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
1306
+ }
1307
+ return cachedDataViewMemory0;
1308
+ }
1309
+
1310
+ function getStringFromWasm0(ptr, len) {
1311
+ ptr = ptr >>> 0;
1312
+ return decodeText(ptr, len);
1313
+ }
1314
+
1315
+ let cachedUint8ArrayMemory0 = null;
1316
+ function getUint8ArrayMemory0() {
1317
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1318
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1319
+ }
1320
+ return cachedUint8ArrayMemory0;
1321
+ }
1322
+
1323
+ function getObject(idx) { return heap[idx]; }
1324
+
1325
+ function handleError(f, args) {
1326
+ try {
1327
+ return f.apply(this, args);
1328
+ } catch (e) {
1329
+ wasm.__wbindgen_export3(addHeapObject(e));
1330
+ }
1331
+ }
1332
+
1333
+ let heap = new Array(1024).fill(undefined);
1334
+ heap.push(undefined, null, true, false);
1335
+
1336
+ let heap_next = heap.length;
1337
+
1338
+ function isLikeNone(x) {
1339
+ return x === undefined || x === null;
1340
+ }
1341
+
1342
+ function makeMutClosure(arg0, arg1, dtor, f) {
1343
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
1344
+ const real = (...args) => {
1345
+
1346
+ // First up with a closure we increment the internal reference
1347
+ // count. This ensures that the Rust closure environment won't
1348
+ // be deallocated while we're invoking it.
1349
+ state.cnt++;
1350
+ const a = state.a;
1351
+ state.a = 0;
1352
+ try {
1353
+ return f(a, state.b, ...args);
1354
+ } finally {
1355
+ state.a = a;
1356
+ real._wbg_cb_unref();
1357
+ }
1358
+ };
1359
+ real._wbg_cb_unref = () => {
1360
+ if (--state.cnt === 0) {
1361
+ state.dtor(state.a, state.b);
1362
+ state.a = 0;
1363
+ CLOSURE_DTORS.unregister(state);
1364
+ }
1365
+ };
1366
+ CLOSURE_DTORS.register(real, state, state);
1367
+ return real;
1368
+ }
1369
+
1370
+ function passArray8ToWasm0(arg, malloc) {
1371
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
1372
+ getUint8ArrayMemory0().set(arg, ptr / 1);
1373
+ WASM_VECTOR_LEN = arg.length;
1374
+ return ptr;
1375
+ }
1376
+
1377
+ function passStringToWasm0(arg, malloc, realloc) {
1378
+ if (realloc === undefined) {
1379
+ const buf = cachedTextEncoder.encode(arg);
1380
+ const ptr = malloc(buf.length, 1) >>> 0;
1381
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1382
+ WASM_VECTOR_LEN = buf.length;
1383
+ return ptr;
1384
+ }
1385
+
1386
+ let len = arg.length;
1387
+ let ptr = malloc(len, 1) >>> 0;
1388
+
1389
+ const mem = getUint8ArrayMemory0();
1390
+
1391
+ let offset = 0;
1392
+
1393
+ for (; offset < len; offset++) {
1394
+ const code = arg.charCodeAt(offset);
1395
+ if (code > 0x7F) break;
1396
+ mem[ptr + offset] = code;
1397
+ }
1398
+ if (offset !== len) {
1399
+ if (offset !== 0) {
1400
+ arg = arg.slice(offset);
1401
+ }
1402
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1403
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1404
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1405
+
1406
+ offset += ret.written;
1407
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1408
+ }
1409
+
1410
+ WASM_VECTOR_LEN = offset;
1411
+ return ptr;
1412
+ }
1413
+
1414
+ function takeObject(idx) {
1415
+ const ret = getObject(idx);
1416
+ dropObject(idx);
1417
+ return ret;
1418
+ }
1419
+
1420
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1421
+ cachedTextDecoder.decode();
1422
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1423
+ let numBytesDecoded = 0;
1424
+ function decodeText(ptr, len) {
1425
+ numBytesDecoded += len;
1426
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1427
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1428
+ cachedTextDecoder.decode();
1429
+ numBytesDecoded = len;
1430
+ }
1431
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1432
+ }
1433
+
1434
+ const cachedTextEncoder = new TextEncoder();
1435
+
1436
+ if (!('encodeInto' in cachedTextEncoder)) {
1437
+ cachedTextEncoder.encodeInto = function (arg, view) {
1438
+ const buf = cachedTextEncoder.encode(arg);
1439
+ view.set(buf);
1440
+ return {
1441
+ read: arg.length,
1442
+ written: buf.length
1443
+ };
1444
+ };
1445
+ }
1446
+
1447
+ let WASM_VECTOR_LEN = 0;
1448
+
1449
+ let wasmModule, wasm;
1450
+ function __wbg_finalize_init(instance, module) {
1451
+ wasm = instance.exports;
1452
+ wasmModule = module;
1453
+ cachedDataViewMemory0 = null;
1454
+ cachedUint8ArrayMemory0 = null;
1455
+ return wasm;
1456
+ }
1457
+
1458
+ async function __wbg_load(module, imports) {
1459
+ if (typeof Response === 'function' && module instanceof Response) {
1460
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1461
+ try {
1462
+ return await WebAssembly.instantiateStreaming(module, imports);
1463
+ } catch (e) {
1464
+ const validResponse = module.ok && expectedResponseType(module.type);
1465
+
1466
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1467
+ 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);
1468
+
1469
+ } else { throw e; }
1470
+ }
1471
+ }
1472
+
1473
+ const bytes = await module.arrayBuffer();
1474
+ return await WebAssembly.instantiate(bytes, imports);
1475
+ } else {
1476
+ const instance = await WebAssembly.instantiate(module, imports);
1477
+
1478
+ if (instance instanceof WebAssembly.Instance) {
1479
+ return { instance, module };
1480
+ } else {
1481
+ return instance;
1482
+ }
1483
+ }
1484
+
1485
+ function expectedResponseType(type) {
1486
+ switch (type) {
1487
+ case 'basic': case 'cors': case 'default': return true;
1488
+ }
1489
+ return false;
1490
+ }
1491
+ }
1492
+
1493
+ function initSync(module) {
1494
+ if (wasm !== undefined) return wasm;
1495
+
1496
+
1497
+ if (module !== undefined) {
1498
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1499
+ ({module} = module)
1500
+ } else {
1501
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1502
+ }
1503
+ }
1504
+
1505
+ const imports = __wbg_get_imports();
1506
+ if (!(module instanceof WebAssembly.Module)) {
1507
+ module = new WebAssembly.Module(module);
1508
+ }
1509
+ const instance = new WebAssembly.Instance(module, imports);
1510
+ return __wbg_finalize_init(instance, module);
1511
+ }
1512
+
1513
+ async function __wbg_init(module_or_path) {
1514
+ if (wasm !== undefined) return wasm;
1515
+
1516
+
1517
+ if (module_or_path !== undefined) {
1518
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1519
+ ({module_or_path} = module_or_path)
1520
+ } else {
1521
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1522
+ }
1523
+ }
1524
+
1525
+ if (module_or_path === undefined) {
1526
+ module_or_path = new URL('rvagent_wasm_bg.wasm', import.meta.url);
1527
+ }
1528
+ const imports = __wbg_get_imports();
1529
+
1530
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1531
+ module_or_path = fetch(module_or_path);
1532
+ }
1533
+
1534
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1535
+
1536
+ return __wbg_finalize_init(instance, module);
1537
+ }
1538
+
1539
+ export { initSync, __wbg_init as default };