ruflo 3.6.12 → 3.6.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -1
- package/src/ruvocal/.claude-flow/data/pending-insights.jsonl +25 -0
- package/src/ruvocal/.claude-flow/neural/stats.json +6 -0
- package/src/ruvocal/.dockerignore +5 -1
- package/src/ruvocal/.gcloudignore +18 -0
- package/src/ruvocal/README.md +107 -133
- package/src/ruvocal/cloudbuild.yaml +68 -0
- package/src/ruvocal/config/branding.env.example +19 -0
- package/src/ruvocal/mcp-bridge/index.js +15 -1
- package/src/ruvocal/src/lib/components/FoundationBackground.svelte +242 -0
- package/src/ruvocal/src/lib/components/NavMenu.svelte +18 -0
- package/src/ruvocal/src/lib/components/RufloHelpModal.svelte +411 -0
- package/src/ruvocal/src/lib/components/chat/ChatWindow.svelte +122 -4
- package/src/ruvocal/src/lib/components/wasm/GalleryPanel.svelte +357 -0
- package/src/ruvocal/src/lib/constants/mcpExamples.ts +56 -77
- package/src/ruvocal/src/lib/constants/routerExamples.ts +51 -127
- package/src/ruvocal/src/lib/constants/rvagentPresets.ts +206 -0
- package/src/ruvocal/src/lib/server/textGeneration/mcp/wasmTools.test.ts +633 -0
- package/src/ruvocal/src/lib/stores/mcpServers.ts +195 -6
- package/src/ruvocal/src/lib/stores/wasmMcp.ts +472 -0
- package/src/ruvocal/src/lib/types/Settings.ts +7 -0
- package/src/ruvocal/src/lib/types/Tool.ts +4 -1
- package/src/ruvocal/src/lib/wasm/idb.ts +438 -0
- package/src/ruvocal/src/lib/wasm/index.ts +1213 -0
- package/src/ruvocal/src/lib/wasm/tests/wasm-capabilities.test.ts +565 -0
- package/src/ruvocal/src/lib/wasm/wasm.worker.ts +332 -0
- package/src/ruvocal/src/lib/wasm/workerClient.ts +166 -0
- package/src/ruvocal/static/wasm/rvagent_wasm.js +1539 -0
- package/src/ruvocal/static/wasm/rvagent_wasm_bg.wasm +0 -0
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IndexedDB Persistence Layer
|
|
3
|
+
* Provides persistent storage for WASM virtual filesystem and RVF containers
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { browser } from "$app/environment";
|
|
7
|
+
|
|
8
|
+
const DB_NAME = "rvagent-wasm-db";
|
|
9
|
+
const DB_VERSION = 1;
|
|
10
|
+
|
|
11
|
+
// Object store names
|
|
12
|
+
const STORES = {
|
|
13
|
+
FILES: "files",
|
|
14
|
+
RVF_CONTAINERS: "rvf-containers",
|
|
15
|
+
GALLERY_CUSTOM: "gallery-custom",
|
|
16
|
+
SETTINGS: "settings",
|
|
17
|
+
SESSIONS: "sessions",
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
// Types
|
|
21
|
+
export interface StoredFile {
|
|
22
|
+
path: string;
|
|
23
|
+
content: string;
|
|
24
|
+
createdAt: number;
|
|
25
|
+
updatedAt: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface StoredRvfContainer {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
data: Uint8Array;
|
|
32
|
+
templateId?: string;
|
|
33
|
+
createdAt: number;
|
|
34
|
+
updatedAt: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface StoredSession {
|
|
38
|
+
id: string;
|
|
39
|
+
activeTemplateId?: string;
|
|
40
|
+
config: unknown;
|
|
41
|
+
files: string[];
|
|
42
|
+
createdAt: number;
|
|
43
|
+
updatedAt: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let db: IDBDatabase | null = null;
|
|
47
|
+
let dbPromise: Promise<IDBDatabase> | null = null;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Open the IndexedDB database
|
|
51
|
+
*/
|
|
52
|
+
export async function openDatabase(): Promise<IDBDatabase> {
|
|
53
|
+
if (!browser) {
|
|
54
|
+
throw new Error("IndexedDB is only available in browser");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (db) {
|
|
58
|
+
return db;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (dbPromise) {
|
|
62
|
+
return dbPromise;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
dbPromise = new Promise((resolve, reject) => {
|
|
66
|
+
const request = indexedDB.open(DB_NAME, DB_VERSION);
|
|
67
|
+
|
|
68
|
+
request.onerror = () => {
|
|
69
|
+
console.error("[IDB] Failed to open database:", request.error);
|
|
70
|
+
dbPromise = null;
|
|
71
|
+
reject(request.error);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
request.onsuccess = () => {
|
|
75
|
+
db = request.result;
|
|
76
|
+
console.log("[IDB] Database opened successfully");
|
|
77
|
+
resolve(db);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
request.onupgradeneeded = (event) => {
|
|
81
|
+
const database = (event.target as IDBOpenDBRequest).result;
|
|
82
|
+
|
|
83
|
+
// Files store (virtual filesystem)
|
|
84
|
+
if (!database.objectStoreNames.contains(STORES.FILES)) {
|
|
85
|
+
const filesStore = database.createObjectStore(STORES.FILES, { keyPath: "path" });
|
|
86
|
+
filesStore.createIndex("updatedAt", "updatedAt", { unique: false });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// RVF containers store
|
|
90
|
+
if (!database.objectStoreNames.contains(STORES.RVF_CONTAINERS)) {
|
|
91
|
+
const rvfStore = database.createObjectStore(STORES.RVF_CONTAINERS, { keyPath: "id" });
|
|
92
|
+
rvfStore.createIndex("name", "name", { unique: false });
|
|
93
|
+
rvfStore.createIndex("templateId", "templateId", { unique: false });
|
|
94
|
+
rvfStore.createIndex("updatedAt", "updatedAt", { unique: false });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Custom gallery templates store
|
|
98
|
+
if (!database.objectStoreNames.contains(STORES.GALLERY_CUSTOM)) {
|
|
99
|
+
const galleryStore = database.createObjectStore(STORES.GALLERY_CUSTOM, { keyPath: "id" });
|
|
100
|
+
galleryStore.createIndex("category", "category", { unique: false });
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Settings store
|
|
104
|
+
if (!database.objectStoreNames.contains(STORES.SETTINGS)) {
|
|
105
|
+
database.createObjectStore(STORES.SETTINGS, { keyPath: "key" });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Sessions store
|
|
109
|
+
if (!database.objectStoreNames.contains(STORES.SESSIONS)) {
|
|
110
|
+
const sessionsStore = database.createObjectStore(STORES.SESSIONS, { keyPath: "id" });
|
|
111
|
+
sessionsStore.createIndex("updatedAt", "updatedAt", { unique: false });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
console.log("[IDB] Database schema created/upgraded");
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
return dbPromise;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Close the database
|
|
123
|
+
*/
|
|
124
|
+
export function closeDatabase(): void {
|
|
125
|
+
if (db) {
|
|
126
|
+
db.close();
|
|
127
|
+
db = null;
|
|
128
|
+
dbPromise = null;
|
|
129
|
+
console.log("[IDB] Database closed");
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// ---------------------------------------------------------------------------
|
|
134
|
+
// File Operations (Virtual Filesystem)
|
|
135
|
+
// ---------------------------------------------------------------------------
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Write a file to IndexedDB
|
|
139
|
+
*/
|
|
140
|
+
export async function writeFile(path: string, content: string): Promise<void> {
|
|
141
|
+
const database = await openDatabase();
|
|
142
|
+
const tx = database.transaction(STORES.FILES, "readwrite");
|
|
143
|
+
const store = tx.objectStore(STORES.FILES);
|
|
144
|
+
|
|
145
|
+
const now = Date.now();
|
|
146
|
+
const existing = await new Promise<StoredFile | undefined>((resolve) => {
|
|
147
|
+
const request = store.get(path);
|
|
148
|
+
request.onsuccess = () => resolve(request.result);
|
|
149
|
+
request.onerror = () => resolve(undefined);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const file: StoredFile = {
|
|
153
|
+
path,
|
|
154
|
+
content,
|
|
155
|
+
createdAt: existing?.createdAt || now,
|
|
156
|
+
updatedAt: now,
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
return new Promise((resolve, reject) => {
|
|
160
|
+
const request = store.put(file);
|
|
161
|
+
request.onsuccess = () => resolve();
|
|
162
|
+
request.onerror = () => reject(request.error);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Read a file from IndexedDB
|
|
168
|
+
*/
|
|
169
|
+
export async function readFile(path: string): Promise<string | null> {
|
|
170
|
+
const database = await openDatabase();
|
|
171
|
+
const tx = database.transaction(STORES.FILES, "readonly");
|
|
172
|
+
const store = tx.objectStore(STORES.FILES);
|
|
173
|
+
|
|
174
|
+
return new Promise((resolve, reject) => {
|
|
175
|
+
const request = store.get(path);
|
|
176
|
+
request.onsuccess = () => resolve(request.result?.content ?? null);
|
|
177
|
+
request.onerror = () => reject(request.error);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Delete a file from IndexedDB
|
|
183
|
+
*/
|
|
184
|
+
export async function deleteFile(path: string): Promise<void> {
|
|
185
|
+
const database = await openDatabase();
|
|
186
|
+
const tx = database.transaction(STORES.FILES, "readwrite");
|
|
187
|
+
const store = tx.objectStore(STORES.FILES);
|
|
188
|
+
|
|
189
|
+
return new Promise((resolve, reject) => {
|
|
190
|
+
const request = store.delete(path);
|
|
191
|
+
request.onsuccess = () => resolve();
|
|
192
|
+
request.onerror = () => reject(request.error);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* List all files in IndexedDB
|
|
198
|
+
*/
|
|
199
|
+
export async function listFiles(): Promise<StoredFile[]> {
|
|
200
|
+
const database = await openDatabase();
|
|
201
|
+
const tx = database.transaction(STORES.FILES, "readonly");
|
|
202
|
+
const store = tx.objectStore(STORES.FILES);
|
|
203
|
+
|
|
204
|
+
return new Promise((resolve, reject) => {
|
|
205
|
+
const request = store.getAll();
|
|
206
|
+
request.onsuccess = () => resolve(request.result);
|
|
207
|
+
request.onerror = () => reject(request.error);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Clear all files
|
|
213
|
+
*/
|
|
214
|
+
export async function clearFiles(): Promise<void> {
|
|
215
|
+
const database = await openDatabase();
|
|
216
|
+
const tx = database.transaction(STORES.FILES, "readwrite");
|
|
217
|
+
const store = tx.objectStore(STORES.FILES);
|
|
218
|
+
|
|
219
|
+
return new Promise((resolve, reject) => {
|
|
220
|
+
const request = store.clear();
|
|
221
|
+
request.onsuccess = () => resolve();
|
|
222
|
+
request.onerror = () => reject(request.error);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Export all files as JSON
|
|
228
|
+
*/
|
|
229
|
+
export async function exportFilesAsJson(): Promise<string> {
|
|
230
|
+
const files = await listFiles();
|
|
231
|
+
const fileMap: Record<string, string> = {};
|
|
232
|
+
for (const file of files) {
|
|
233
|
+
fileMap[file.path] = file.content;
|
|
234
|
+
}
|
|
235
|
+
return JSON.stringify(fileMap);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Import files from JSON
|
|
240
|
+
*/
|
|
241
|
+
export async function importFilesFromJson(json: string): Promise<number> {
|
|
242
|
+
const fileMap: Record<string, string> = JSON.parse(json);
|
|
243
|
+
let count = 0;
|
|
244
|
+
for (const [path, content] of Object.entries(fileMap)) {
|
|
245
|
+
await writeFile(path, content);
|
|
246
|
+
count++;
|
|
247
|
+
}
|
|
248
|
+
return count;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// ---------------------------------------------------------------------------
|
|
252
|
+
// RVF Container Operations
|
|
253
|
+
// ---------------------------------------------------------------------------
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Save an RVF container
|
|
257
|
+
*/
|
|
258
|
+
export async function saveRvfContainer(
|
|
259
|
+
id: string,
|
|
260
|
+
name: string,
|
|
261
|
+
data: Uint8Array,
|
|
262
|
+
templateId?: string
|
|
263
|
+
): Promise<void> {
|
|
264
|
+
const database = await openDatabase();
|
|
265
|
+
const tx = database.transaction(STORES.RVF_CONTAINERS, "readwrite");
|
|
266
|
+
const store = tx.objectStore(STORES.RVF_CONTAINERS);
|
|
267
|
+
|
|
268
|
+
const now = Date.now();
|
|
269
|
+
const existing = await new Promise<StoredRvfContainer | undefined>((resolve) => {
|
|
270
|
+
const request = store.get(id);
|
|
271
|
+
request.onsuccess = () => resolve(request.result);
|
|
272
|
+
request.onerror = () => resolve(undefined);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
const container: StoredRvfContainer = {
|
|
276
|
+
id,
|
|
277
|
+
name,
|
|
278
|
+
data,
|
|
279
|
+
templateId,
|
|
280
|
+
createdAt: existing?.createdAt || now,
|
|
281
|
+
updatedAt: now,
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
return new Promise((resolve, reject) => {
|
|
285
|
+
const request = store.put(container);
|
|
286
|
+
request.onsuccess = () => resolve();
|
|
287
|
+
request.onerror = () => reject(request.error);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Load an RVF container
|
|
293
|
+
*/
|
|
294
|
+
export async function loadRvfContainer(id: string): Promise<StoredRvfContainer | null> {
|
|
295
|
+
const database = await openDatabase();
|
|
296
|
+
const tx = database.transaction(STORES.RVF_CONTAINERS, "readonly");
|
|
297
|
+
const store = tx.objectStore(STORES.RVF_CONTAINERS);
|
|
298
|
+
|
|
299
|
+
return new Promise((resolve, reject) => {
|
|
300
|
+
const request = store.get(id);
|
|
301
|
+
request.onsuccess = () => resolve(request.result ?? null);
|
|
302
|
+
request.onerror = () => reject(request.error);
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* List all RVF containers
|
|
308
|
+
*/
|
|
309
|
+
export async function listRvfContainers(): Promise<StoredRvfContainer[]> {
|
|
310
|
+
const database = await openDatabase();
|
|
311
|
+
const tx = database.transaction(STORES.RVF_CONTAINERS, "readonly");
|
|
312
|
+
const store = tx.objectStore(STORES.RVF_CONTAINERS);
|
|
313
|
+
|
|
314
|
+
return new Promise((resolve, reject) => {
|
|
315
|
+
const request = store.getAll();
|
|
316
|
+
request.onsuccess = () => resolve(request.result);
|
|
317
|
+
request.onerror = () => reject(request.error);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Delete an RVF container
|
|
323
|
+
*/
|
|
324
|
+
export async function deleteRvfContainer(id: string): Promise<void> {
|
|
325
|
+
const database = await openDatabase();
|
|
326
|
+
const tx = database.transaction(STORES.RVF_CONTAINERS, "readwrite");
|
|
327
|
+
const store = tx.objectStore(STORES.RVF_CONTAINERS);
|
|
328
|
+
|
|
329
|
+
return new Promise((resolve, reject) => {
|
|
330
|
+
const request = store.delete(id);
|
|
331
|
+
request.onsuccess = () => resolve();
|
|
332
|
+
request.onerror = () => reject(request.error);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// ---------------------------------------------------------------------------
|
|
337
|
+
// Settings Operations
|
|
338
|
+
// ---------------------------------------------------------------------------
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Get a setting value
|
|
342
|
+
*/
|
|
343
|
+
export async function getSetting<T>(key: string): Promise<T | null> {
|
|
344
|
+
const database = await openDatabase();
|
|
345
|
+
const tx = database.transaction(STORES.SETTINGS, "readonly");
|
|
346
|
+
const store = tx.objectStore(STORES.SETTINGS);
|
|
347
|
+
|
|
348
|
+
return new Promise((resolve, reject) => {
|
|
349
|
+
const request = store.get(key);
|
|
350
|
+
request.onsuccess = () => resolve(request.result?.value ?? null);
|
|
351
|
+
request.onerror = () => reject(request.error);
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Set a setting value
|
|
357
|
+
*/
|
|
358
|
+
export async function setSetting<T>(key: string, value: T): Promise<void> {
|
|
359
|
+
const database = await openDatabase();
|
|
360
|
+
const tx = database.transaction(STORES.SETTINGS, "readwrite");
|
|
361
|
+
const store = tx.objectStore(STORES.SETTINGS);
|
|
362
|
+
|
|
363
|
+
return new Promise((resolve, reject) => {
|
|
364
|
+
const request = store.put({ key, value });
|
|
365
|
+
request.onsuccess = () => resolve();
|
|
366
|
+
request.onerror = () => reject(request.error);
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// ---------------------------------------------------------------------------
|
|
371
|
+
// Session Operations
|
|
372
|
+
// ---------------------------------------------------------------------------
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Save a session
|
|
376
|
+
*/
|
|
377
|
+
export async function saveSession(session: StoredSession): Promise<void> {
|
|
378
|
+
const database = await openDatabase();
|
|
379
|
+
const tx = database.transaction(STORES.SESSIONS, "readwrite");
|
|
380
|
+
const store = tx.objectStore(STORES.SESSIONS);
|
|
381
|
+
|
|
382
|
+
session.updatedAt = Date.now();
|
|
383
|
+
|
|
384
|
+
return new Promise((resolve, reject) => {
|
|
385
|
+
const request = store.put(session);
|
|
386
|
+
request.onsuccess = () => resolve();
|
|
387
|
+
request.onerror = () => reject(request.error);
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Load a session
|
|
393
|
+
*/
|
|
394
|
+
export async function loadSession(id: string): Promise<StoredSession | null> {
|
|
395
|
+
const database = await openDatabase();
|
|
396
|
+
const tx = database.transaction(STORES.SESSIONS, "readonly");
|
|
397
|
+
const store = tx.objectStore(STORES.SESSIONS);
|
|
398
|
+
|
|
399
|
+
return new Promise((resolve, reject) => {
|
|
400
|
+
const request = store.get(id);
|
|
401
|
+
request.onsuccess = () => resolve(request.result ?? null);
|
|
402
|
+
request.onerror = () => reject(request.error);
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Get the most recent session
|
|
408
|
+
*/
|
|
409
|
+
export async function getLatestSession(): Promise<StoredSession | null> {
|
|
410
|
+
const database = await openDatabase();
|
|
411
|
+
const tx = database.transaction(STORES.SESSIONS, "readonly");
|
|
412
|
+
const store = tx.objectStore(STORES.SESSIONS);
|
|
413
|
+
const index = store.index("updatedAt");
|
|
414
|
+
|
|
415
|
+
return new Promise((resolve, reject) => {
|
|
416
|
+
const request = index.openCursor(null, "prev");
|
|
417
|
+
request.onsuccess = () => {
|
|
418
|
+
const cursor = request.result;
|
|
419
|
+
resolve(cursor?.value ?? null);
|
|
420
|
+
};
|
|
421
|
+
request.onerror = () => reject(request.error);
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Delete a session
|
|
427
|
+
*/
|
|
428
|
+
export async function deleteSession(id: string): Promise<void> {
|
|
429
|
+
const database = await openDatabase();
|
|
430
|
+
const tx = database.transaction(STORES.SESSIONS, "readwrite");
|
|
431
|
+
const store = tx.objectStore(STORES.SESSIONS);
|
|
432
|
+
|
|
433
|
+
return new Promise((resolve, reject) => {
|
|
434
|
+
const request = store.delete(id);
|
|
435
|
+
request.onsuccess = () => resolve();
|
|
436
|
+
request.onerror = () => reject(request.error);
|
|
437
|
+
});
|
|
438
|
+
}
|