ruflo 3.6.11 → 3.6.13

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.
Files changed (29) hide show
  1. package/package.json +4 -1
  2. package/src/ruvocal/.claude-flow/data/pending-insights.jsonl +25 -0
  3. package/src/ruvocal/.claude-flow/neural/stats.json +6 -0
  4. package/src/ruvocal/.dockerignore +5 -1
  5. package/src/ruvocal/.gcloudignore +18 -0
  6. package/src/ruvocal/README.md +107 -133
  7. package/src/ruvocal/cloudbuild.yaml +68 -0
  8. package/src/ruvocal/config/branding.env.example +19 -0
  9. package/src/ruvocal/mcp-bridge/index.js +15 -1
  10. package/src/ruvocal/src/lib/components/FoundationBackground.svelte +242 -0
  11. package/src/ruvocal/src/lib/components/NavMenu.svelte +18 -0
  12. package/src/ruvocal/src/lib/components/RufloHelpModal.svelte +411 -0
  13. package/src/ruvocal/src/lib/components/chat/ChatWindow.svelte +122 -4
  14. package/src/ruvocal/src/lib/components/wasm/GalleryPanel.svelte +357 -0
  15. package/src/ruvocal/src/lib/constants/mcpExamples.ts +56 -77
  16. package/src/ruvocal/src/lib/constants/routerExamples.ts +51 -127
  17. package/src/ruvocal/src/lib/constants/rvagentPresets.ts +206 -0
  18. package/src/ruvocal/src/lib/server/textGeneration/mcp/wasmTools.test.ts +633 -0
  19. package/src/ruvocal/src/lib/stores/mcpServers.ts +195 -6
  20. package/src/ruvocal/src/lib/stores/wasmMcp.ts +472 -0
  21. package/src/ruvocal/src/lib/types/Settings.ts +7 -0
  22. package/src/ruvocal/src/lib/types/Tool.ts +4 -1
  23. package/src/ruvocal/src/lib/wasm/idb.ts +438 -0
  24. package/src/ruvocal/src/lib/wasm/index.ts +1213 -0
  25. package/src/ruvocal/src/lib/wasm/tests/wasm-capabilities.test.ts +565 -0
  26. package/src/ruvocal/src/lib/wasm/wasm.worker.ts +332 -0
  27. package/src/ruvocal/src/lib/wasm/workerClient.ts +166 -0
  28. package/src/ruvocal/static/wasm/rvagent_wasm.js +1539 -0
  29. package/src/ruvocal/static/wasm/rvagent_wasm_bg.wasm +0 -0
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * MCP Servers Store
3
- * Manages base (env-configured) and custom (user-added) MCP servers
3
+ * Manages base (env-configured), custom (user-added), and WASM (browser-local) MCP servers
4
4
  * Stores custom servers and selection state in browser localStorage
5
+ * WASM servers run entirely in-browser via rvagent-wasm with IndexedDB persistence
5
6
  */
6
7
 
7
8
  import { writable, derived, get } from "svelte/store";
@@ -9,6 +10,13 @@ import { base } from "$app/paths";
9
10
  import { env as publicEnv } from "$env/dynamic/public";
10
11
  import { browser } from "$app/environment";
11
12
  import type { MCPServer, ServerStatus, MCPTool } from "$lib/types/Tool";
13
+ import {
14
+ initWasmMcp,
15
+ callMcp as callWasmMcp,
16
+ listGalleryTemplates,
17
+ loadGalleryTemplate,
18
+ activeTemplate,
19
+ } from "./wasmMcp";
12
20
 
13
21
  // Namespace storage by app identity to avoid collisions across apps
14
22
  function toKeyPart(s: string | undefined): string {
@@ -26,6 +34,22 @@ const STORAGE_KEYS = {
26
34
  DISABLED_BASE_IDS: `${KEY_PREFIX}:mcp:disabled-base-ids`,
27
35
  } as const;
28
36
 
37
+ // WASM MCP Server ID (constant, always available)
38
+ export const WASM_SERVER_ID = "wasm-rvagent";
39
+
40
+ // Create the WASM MCP server entry
41
+ function createWasmServer(): MCPServer {
42
+ return {
43
+ id: WASM_SERVER_ID,
44
+ name: "RVAgent Local (WASM)",
45
+ url: "wasm://local",
46
+ type: "wasm",
47
+ status: "disconnected",
48
+ isLocked: false,
49
+ tools: [],
50
+ };
51
+ }
52
+
29
53
  // No migration needed per request — read/write only namespaced keys
30
54
 
31
55
  // Load custom servers from localStorage
@@ -138,7 +162,7 @@ export const allBaseServersEnabled = derived(
138
162
  // is applied server-side when enabled via MCP_FORWARD_HF_USER_TOKEN.
139
163
 
140
164
  /**
141
- * Refresh base servers from API and merge with custom servers
165
+ * Refresh base servers from API and merge with custom servers + WASM server
142
166
  */
143
167
  export async function refreshMcpServers() {
144
168
  try {
@@ -150,8 +174,11 @@ export async function refreshMcpServers() {
150
174
  const baseServers: MCPServer[] = await response.json();
151
175
  const customServers = loadCustomServers();
152
176
 
153
- // Merge base and custom servers
154
- const merged = [...baseServers, ...customServers];
177
+ // Create WASM server and add to the list
178
+ const wasmServer = createWasmServer();
179
+
180
+ // Merge base, custom, and WASM servers
181
+ const merged = [wasmServer, ...baseServers, ...customServers];
155
182
  allMcpServers.set(merged);
156
183
 
157
184
  // Load disabled base servers
@@ -159,10 +186,14 @@ export async function refreshMcpServers() {
159
186
 
160
187
  // Auto-enable all base servers that aren't explicitly disabled
161
188
  // Plus keep any custom servers that were previously selected
189
+ // WASM server is auto-enabled by default
162
190
  const validIds = new Set(merged.map((s) => s.id));
163
191
  selectedServerIds.update(($currentIds) => {
164
192
  const newSelection = new Set<string>();
165
193
 
194
+ // Auto-enable WASM server
195
+ newSelection.add(WASM_SERVER_ID);
196
+
166
197
  // Add all base servers that aren't disabled
167
198
  for (const server of baseServers) {
168
199
  if (!disabledBaseIds.has(server.id)) {
@@ -180,11 +211,70 @@ export async function refreshMcpServers() {
180
211
  return newSelection;
181
212
  });
182
213
  mcpServersLoaded.set(true);
214
+
215
+ // Initialize WASM MCP server in background
216
+ initWasmServer();
183
217
  } catch (error) {
184
218
  console.error("Failed to refresh MCP servers:", error);
185
- // On error, just use custom servers
186
- allMcpServers.set(loadCustomServers());
219
+ // On error, use custom servers + WASM server
220
+ const wasmServer = createWasmServer();
221
+ allMcpServers.set([wasmServer, ...loadCustomServers()]);
187
222
  mcpServersLoaded.set(true);
223
+
224
+ // Still try to init WASM
225
+ initWasmServer();
226
+ }
227
+ }
228
+
229
+ /**
230
+ * Initialize the WASM MCP server
231
+ */
232
+ async function initWasmServer() {
233
+ if (!browser) return;
234
+
235
+ updateServerStatus(WASM_SERVER_ID, "connecting");
236
+
237
+ try {
238
+ const success = await initWasmMcp();
239
+
240
+ if (success) {
241
+ // Get tools from WASM server
242
+ const toolsResponse = await callWasmMcp("tools/list");
243
+ const tools: MCPTool[] = [];
244
+
245
+ if (!toolsResponse.error && toolsResponse.result) {
246
+ const result = toolsResponse.result as { tools: MCPTool[] };
247
+ if (result.tools) {
248
+ tools.push(...result.tools);
249
+ }
250
+ }
251
+
252
+ // Get active template info
253
+ const template = get(activeTemplate);
254
+
255
+ updateServerStatus(WASM_SERVER_ID, "connected", undefined, tools);
256
+
257
+ // Update template info
258
+ allMcpServers.update(($servers) =>
259
+ $servers.map((s) =>
260
+ s.id === WASM_SERVER_ID
261
+ ? {
262
+ ...s,
263
+ wasmTemplateId: template.id || undefined,
264
+ wasmTemplateName: template.name || undefined,
265
+ }
266
+ : s
267
+ )
268
+ );
269
+
270
+ console.log(`[MCP] WASM server initialized with ${tools.length} tools`);
271
+ } else {
272
+ updateServerStatus(WASM_SERVER_ID, "error", "Failed to load WASM module");
273
+ }
274
+ } catch (error) {
275
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
276
+ updateServerStatus(WASM_SERVER_ID, "error", errorMessage);
277
+ console.error("[MCP] WASM server initialization failed:", error);
188
278
  }
189
279
  }
190
280
 
@@ -314,6 +404,11 @@ export function updateServerStatus(
314
404
  export async function healthCheckServer(
315
405
  server: MCPServer
316
406
  ): Promise<{ ready: boolean; tools?: MCPTool[]; error?: string }> {
407
+ // Handle WASM servers locally
408
+ if (server.type === "wasm") {
409
+ return healthCheckWasmServer();
410
+ }
411
+
317
412
  try {
318
413
  updateServerStatus(server.id, "connecting");
319
414
 
@@ -339,6 +434,100 @@ export async function healthCheckServer(
339
434
  }
340
435
  }
341
436
 
437
+ /**
438
+ * Health check for WASM MCP server (runs locally)
439
+ */
440
+ async function healthCheckWasmServer(): Promise<{ ready: boolean; tools?: MCPTool[]; error?: string }> {
441
+ try {
442
+ updateServerStatus(WASM_SERVER_ID, "connecting");
443
+
444
+ const success = await initWasmMcp();
445
+
446
+ if (!success) {
447
+ updateServerStatus(WASM_SERVER_ID, "error", "Failed to load WASM module");
448
+ return { ready: false, error: "Failed to load WASM module" };
449
+ }
450
+
451
+ // Get tools from WASM server
452
+ const toolsResponse = await callWasmMcp("tools/list");
453
+ const tools: MCPTool[] = [];
454
+
455
+ if (!toolsResponse.error && toolsResponse.result) {
456
+ const result = toolsResponse.result as { tools: MCPTool[] };
457
+ if (result.tools) {
458
+ tools.push(...result.tools);
459
+ }
460
+ }
461
+
462
+ // Get active template info
463
+ const template = get(activeTemplate);
464
+
465
+ updateServerStatus(WASM_SERVER_ID, "connected", undefined, tools);
466
+
467
+ // Update template info
468
+ allMcpServers.update(($servers) =>
469
+ $servers.map((s) =>
470
+ s.id === WASM_SERVER_ID
471
+ ? {
472
+ ...s,
473
+ wasmTemplateId: template.id || undefined,
474
+ wasmTemplateName: template.name || undefined,
475
+ }
476
+ : s
477
+ )
478
+ );
479
+
480
+ return { ready: true, tools };
481
+ } catch (error) {
482
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
483
+ updateServerStatus(WASM_SERVER_ID, "error", errorMessage);
484
+ return { ready: false, error: errorMessage };
485
+ }
486
+ }
487
+
488
+ /**
489
+ * Load a gallery template for the WASM MCP server
490
+ */
491
+ export async function loadWasmTemplate(templateId: string): Promise<boolean> {
492
+ try {
493
+ const success = await loadGalleryTemplate(templateId);
494
+
495
+ if (success) {
496
+ // Refresh tools after loading template
497
+ await healthCheckWasmServer();
498
+ return true;
499
+ }
500
+
501
+ return false;
502
+ } catch (error) {
503
+ console.error("[MCP] Failed to load WASM template:", error);
504
+ return false;
505
+ }
506
+ }
507
+
508
+ /**
509
+ * Get available gallery templates for WASM server
510
+ */
511
+ export function getWasmGalleryTemplates() {
512
+ return listGalleryTemplates();
513
+ }
514
+
515
+ /**
516
+ * Execute a tool on the WASM MCP server
517
+ */
518
+ export async function executeWasmTool(
519
+ name: string,
520
+ args: Record<string, unknown>
521
+ ): Promise<{ success: boolean; result?: unknown; error?: string }> {
522
+ const response = await callWasmMcp("tools/call", { name, arguments: args });
523
+
524
+ if (response.error) {
525
+ return { success: false, error: response.error.message };
526
+ }
527
+
528
+ return { success: true, result: response.result };
529
+ }
530
+
342
531
  // Initialize on module load
343
532
  if (browser) {
344
533
  refreshMcpServers();