agentdb 1.3.7 → 1.3.9

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 (2) hide show
  1. package/dist/agentdb.min.js +155 -20
  2. package/package.json +5 -1
@@ -1,4 +1,4 @@
1
- /*! AgentDB Browser Bundle v1.3.7 | MIT License | https://agentdb.ruv.io */
1
+ /*! AgentDB Browser Bundle v1.3.9 | MIT License | https://agentdb.ruv.io */
2
2
  /*! Backward compatible with v1.0.7 API | Uses sql.js WASM SQLite */
3
3
 
4
4
  // We are modularizing this manually because the current modularize setting in Emscripten has some issues:
@@ -193,7 +193,7 @@ else if (typeof exports === 'object'){
193
193
  ;(function(global) {
194
194
  'use strict';
195
195
 
196
- // AgentDB v1.3.7 - v1.0.7 Compatible Browser Bundle
196
+ // AgentDB v1.3.9 - v1.0.7 Compatible Browser Bundle
197
197
 
198
198
  var sqlReady = false;
199
199
  var SQL = null;
@@ -267,27 +267,124 @@ else if (typeof exports === 'object'){
267
267
 
268
268
  // Async initialization support (for newer demos)
269
269
  this.initializeAsync = function() {
270
- return Promise.resolve(this);
270
+ var self = this;
271
+ return new Promise(function(resolve) {
272
+ // Ensure all tables are created
273
+ try {
274
+ // Core vectors table
275
+ self.run(`
276
+ CREATE TABLE IF NOT EXISTS vectors (
277
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
278
+ embedding BLOB,
279
+ metadata TEXT,
280
+ text TEXT,
281
+ created_at INTEGER DEFAULT (strftime('%s', 'now'))
282
+ )
283
+ `);
284
+
285
+ // Patterns table (for SkillLibrary)
286
+ self.run(`
287
+ CREATE TABLE IF NOT EXISTS patterns (
288
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
289
+ pattern TEXT NOT NULL,
290
+ metadata TEXT,
291
+ embedding BLOB,
292
+ created_at INTEGER DEFAULT (strftime('%s', 'now'))
293
+ )
294
+ `);
295
+
296
+ // Episodes table (for ReflexionMemory)
297
+ self.run(`
298
+ CREATE TABLE IF NOT EXISTS episodes (
299
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
300
+ trajectory TEXT NOT NULL,
301
+ self_reflection TEXT,
302
+ verdict TEXT,
303
+ metadata TEXT,
304
+ embedding BLOB,
305
+ created_at INTEGER DEFAULT (strftime('%s', 'now'))
306
+ )
307
+ `);
308
+
309
+ // Causal edges table (for CausalMemoryGraph)
310
+ self.run(`
311
+ CREATE TABLE IF NOT EXISTS causal_edges (
312
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
313
+ cause TEXT NOT NULL,
314
+ effect TEXT NOT NULL,
315
+ strength REAL DEFAULT 0.5,
316
+ metadata TEXT,
317
+ created_at INTEGER DEFAULT (strftime('%s', 'now'))
318
+ )
319
+ `);
320
+
321
+ // Skills table
322
+ self.run(`
323
+ CREATE TABLE IF NOT EXISTS skills (
324
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
325
+ skill_name TEXT NOT NULL,
326
+ code TEXT,
327
+ metadata TEXT,
328
+ embedding BLOB,
329
+ created_at INTEGER DEFAULT (strftime('%s', 'now'))
330
+ )
331
+ `);
332
+
333
+ console.log('AgentDB: All tables initialized');
334
+ resolve(self);
335
+ } catch (error) {
336
+ console.error('AgentDB initialization error:', error);
337
+ resolve(self); // Still resolve to maintain compatibility
338
+ }
339
+ });
271
340
  };
272
341
 
273
- // Higher-level insert method (for newer demos)
274
- this.insert = function(table, data) {
275
- if (!table || !data) {
276
- throw new Error('Table name and data are required');
277
- }
342
+ // Higher-level insert method (supports both signatures)
343
+ this.insert = function(textOrTable, metadataOrData) {
344
+ // Detect which signature is being used
345
+ if (typeof textOrTable === 'string' && typeof metadataOrData === 'object') {
346
+ // Check if this looks like insert(text, metadata) or insert(table, data)
347
+ if (arguments.length === 2 && metadataOrData && Object.keys(metadataOrData).length > 0) {
348
+ var firstKey = Object.keys(metadataOrData)[0];
349
+
350
+ // If metadataOrData has SQL column names, treat as insert(table, data)
351
+ if (['id', 'pattern', 'trajectory', 'cause', 'effect', 'skill_name', 'code'].indexOf(firstKey) !== -1) {
352
+ // insert(table, data) signature
353
+ var table = textOrTable;
354
+ var data = metadataOrData;
355
+
356
+ var columns = Object.keys(data);
357
+ var values = Object.values(data);
358
+ var placeholders = columns.map(function() { return '?'; }).join(', ');
359
+ var sql = 'INSERT INTO ' + table + ' (' + columns.join(', ') + ') VALUES (' + placeholders + ')';
360
+
361
+ this.run(sql, values);
362
+
363
+ var result = this.exec('SELECT last_insert_rowid() as id');
364
+ return {
365
+ lastID: result[0].values[0][0],
366
+ changes: 1
367
+ };
368
+ }
369
+ }
278
370
 
279
- var columns = Object.keys(data);
280
- var values = Object.values(data);
281
- var placeholders = columns.map(function() { return '?'; }).join(', ');
282
- var sql = 'INSERT INTO ' + table + ' (' + columns.join(', ') + ') VALUES (' + placeholders + ')';
371
+ // insert(text, metadata) signature - insert into vectors table
372
+ var text = textOrTable;
373
+ var metadata = metadataOrData || {};
283
374
 
284
- this.run(sql, values);
375
+ this.run(
376
+ 'INSERT INTO vectors (text, metadata) VALUES (?, ?)',
377
+ [text, JSON.stringify(metadata)]
378
+ );
285
379
 
286
- var result = this.exec('SELECT last_insert_rowid() as id');
287
- return {
288
- lastID: result[0].values[0][0],
289
- changes: 1
290
- };
380
+ var result = this.exec('SELECT last_insert_rowid() as id');
381
+ return {
382
+ lastID: result[0].values[0][0],
383
+ changes: 1
384
+ };
385
+ }
386
+
387
+ throw new Error('Invalid insert arguments');
291
388
  };
292
389
 
293
390
  // Higher-level search method (for newer demos)
@@ -328,6 +425,44 @@ else if (typeof exports === 'object'){
328
425
  return { changes: 1 };
329
426
  };
330
427
 
428
+ // Controller-style methods for frontier features
429
+ this.storePattern = function(patternData) {
430
+ var data = {
431
+ pattern: patternData.pattern || JSON.stringify(patternData),
432
+ metadata: JSON.stringify(patternData.metadata || {})
433
+ };
434
+ return this.insert('patterns', data);
435
+ };
436
+
437
+ this.storeEpisode = function(episodeData) {
438
+ var data = {
439
+ trajectory: episodeData.trajectory || JSON.stringify(episodeData),
440
+ self_reflection: episodeData.self_reflection || episodeData.reflection || '',
441
+ verdict: episodeData.verdict || 'unknown',
442
+ metadata: JSON.stringify(episodeData.metadata || {})
443
+ };
444
+ return this.insert('episodes', data);
445
+ };
446
+
447
+ this.addCausalEdge = function(edgeData) {
448
+ var data = {
449
+ cause: edgeData.cause || '',
450
+ effect: edgeData.effect || '',
451
+ strength: edgeData.strength || 0.5,
452
+ metadata: JSON.stringify(edgeData.metadata || {})
453
+ };
454
+ return this.insert('causal_edges', data);
455
+ };
456
+
457
+ this.storeSkill = function(skillData) {
458
+ var data = {
459
+ skill_name: skillData.skill_name || skillData.name || '',
460
+ code: skillData.code || '',
461
+ metadata: JSON.stringify(skillData.metadata || {})
462
+ };
463
+ return this.insert('skills', data);
464
+ };
465
+
331
466
  // Initialize with comprehensive schema if new database
332
467
  if (!data) {
333
468
  // Core vectors table
@@ -404,7 +539,7 @@ else if (typeof exports === 'object'){
404
539
 
405
540
  // Create AgentDB namespace with all exports
406
541
  var AgentDB = {
407
- version: '1.3.7',
542
+ version: '1.3.9',
408
543
  Database: Database,
409
544
  ready: false,
410
545
 
@@ -442,6 +577,6 @@ else if (typeof exports === 'object'){
442
577
  global.SQLiteVectorDB = Database;
443
578
  }
444
579
 
445
- console.log('AgentDB v1.3.7 loaded (v1.0.7 API compatible)');
580
+ console.log('AgentDB v1.3.9 loaded (v1.0.7 API compatible)');
446
581
 
447
582
  })(typeof window !== 'undefined' ? window : this);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentdb",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "description": "AgentDB - Frontier Memory Features with MCP Integration: Causal reasoning, reflexion memory, skill library, and automated learning. 150x faster vector search. Full Claude Desktop support via Model Context Protocol.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -26,6 +26,10 @@
26
26
  "build:browser": "node scripts/build-browser.js",
27
27
  "dev": "tsx src/cli/agentdb-cli.ts",
28
28
  "test": "vitest",
29
+ "test:unit": "vitest --run",
30
+ "test:browser": "vitest browser-bundle-unit.test.js --run",
31
+ "test:ci": "npm run test:browser && npm run build && npm run verify:bundle",
32
+ "verify:bundle": "node scripts/verify-bundle.js",
29
33
  "cli": "node dist/cli/agentdb-cli.js"
30
34
  },
31
35
  "keywords": [