agentdb 1.0.7 → 1.0.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.
- package/README.md +1 -1
- package/bin/agentdb.js +24 -13
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -0
- package/dist/presets.d.ts +65 -0
- package/dist/presets.d.ts.map +1 -0
- package/dist/presets.js +145 -0
- package/dist/presets.js.map +1 -0
- package/dist/presets.mjs +140 -0
- package/examples/test-v1.0.7-cdn.html +190 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ npm install agentdb
|
|
|
78
78
|
**Quick Setup (Recommended):**
|
|
79
79
|
|
|
80
80
|
```bash
|
|
81
|
-
claude mcp add agentdb npx agentdb@1.0.
|
|
81
|
+
claude mcp add agentdb npx agentdb@1.0.7 mcp
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
This automatically configures Claude Code with all 20 AgentDB tools (10 core + 10 learning tools).
|
package/bin/agentdb.js
CHANGED
|
@@ -370,28 +370,34 @@ function initDatabase(path) {
|
|
|
370
370
|
console.log('');
|
|
371
371
|
|
|
372
372
|
try {
|
|
373
|
-
const {
|
|
373
|
+
const { SQLiteVectorDB, Presets } = require('../dist/index.js');
|
|
374
374
|
|
|
375
375
|
// Create a small test database
|
|
376
376
|
const config = Presets.smallDataset(1536, path);
|
|
377
|
-
const db =
|
|
377
|
+
const db = new SQLiteVectorDB(config);
|
|
378
378
|
|
|
379
379
|
console.log('✅ Database initialized successfully!');
|
|
380
380
|
console.log('');
|
|
381
381
|
console.log('Configuration:');
|
|
382
382
|
console.log(` Path: ${path}`);
|
|
383
|
-
console.log(`
|
|
384
|
-
console.log(`
|
|
383
|
+
console.log(` Mode: ${config.memoryMode ? 'in-memory' : 'persistent'}`);
|
|
384
|
+
console.log(` Cache Size: ${config.cacheSize}MB`);
|
|
385
|
+
console.log(` WAL Mode: ${config.walMode ? 'enabled' : 'disabled'}`);
|
|
385
386
|
console.log('');
|
|
386
387
|
console.log('Next steps:');
|
|
387
|
-
console.log(' 1. Import the library: const {
|
|
388
|
-
console.log(' 2. Insert vectors:
|
|
389
|
-
console.log(' 3. Search:
|
|
388
|
+
console.log(' 1. Import the library: const { SQLiteVectorDB } = require("agentdb")');
|
|
389
|
+
console.log(' 2. Insert vectors: db.insert({ embedding: [...], metadata: {...} })');
|
|
390
|
+
console.log(' 3. Search: db.search(queryVector, 5, "cosine", 0.0)');
|
|
391
|
+
console.log(' 4. View the documentation: https://github.com/ruvnet/agentic-flow/tree/main/packages/agentdb');
|
|
390
392
|
console.log('');
|
|
391
393
|
|
|
392
394
|
db.close();
|
|
393
395
|
} catch (error) {
|
|
394
396
|
console.error('❌ Failed to initialize database:', error.message);
|
|
397
|
+
if (error.stack) {
|
|
398
|
+
console.error('\nStack trace:');
|
|
399
|
+
console.error(error.stack);
|
|
400
|
+
}
|
|
395
401
|
process.exit(1);
|
|
396
402
|
}
|
|
397
403
|
}
|
|
@@ -438,16 +444,21 @@ function runBenchmark() {
|
|
|
438
444
|
process.exit(code);
|
|
439
445
|
});
|
|
440
446
|
} catch (tsError) {
|
|
441
|
-
console.error('❌ Benchmarks not available');
|
|
447
|
+
console.error('❌ Benchmarks not available in npm package');
|
|
442
448
|
console.error('');
|
|
443
|
-
console.error('To run benchmarks:');
|
|
444
|
-
console.error(' 1. Build the project: npm run build');
|
|
445
|
-
console.error(' 2. Run benchmarks: npx agentdb benchmark');
|
|
449
|
+
console.error('To run benchmarks, clone the source repository:');
|
|
446
450
|
console.error('');
|
|
447
|
-
console.error('
|
|
448
|
-
console.error('
|
|
451
|
+
console.error(' git clone https://github.com/ruvnet/agentic-flow.git');
|
|
452
|
+
console.error(' cd agentic-flow/packages/agentdb');
|
|
453
|
+
console.error(' npm install');
|
|
449
454
|
console.error(' npm run bench:comprehensive');
|
|
450
455
|
console.error('');
|
|
456
|
+
console.error('Or create a custom benchmark script:');
|
|
457
|
+
console.error('');
|
|
458
|
+
console.error(' const { SQLiteVectorDB } = require("agentdb");');
|
|
459
|
+
console.error(' const db = new SQLiteVectorDB({ memoryMode: true });');
|
|
460
|
+
console.error(' // Add your benchmark code here');
|
|
461
|
+
console.error('');
|
|
451
462
|
process.exit(1);
|
|
452
463
|
}
|
|
453
464
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,10 +16,12 @@ import { NativeBackend } from './core/native-backend';
|
|
|
16
16
|
import { WasmBackend } from './core/wasm-backend';
|
|
17
17
|
import { BackendType, ExtendedDatabaseConfig, VectorBackend } from './core/backend-interface';
|
|
18
18
|
import { initWasm, initSQL, getWasm, isInitialized, resetWasm } from './wasm-loader';
|
|
19
|
+
import { Presets } from './presets';
|
|
19
20
|
export { SQLiteVectorDB };
|
|
20
21
|
export { NativeBackend };
|
|
21
22
|
export { WasmBackend };
|
|
22
23
|
export { BackendType };
|
|
24
|
+
export { Presets };
|
|
23
25
|
export type { VectorBackend, ExtendedDatabaseConfig };
|
|
24
26
|
export { HNSWIndex, DEFAULT_HNSW_CONFIG } from './index/hnsw';
|
|
25
27
|
export { OptimizedHNSWIndex } from './index/hnsw-optimized';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;GAIG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;GAIG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,CAAC;AACnB,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAE,CAAC;AAGtD,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAGjE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,YAAY,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAGpG,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,YAAY,EACV,qBAAqB,EACrB,eAAe,EACf,uBAAuB,EACxB,MAAM,oCAAoC,CAAC;AAG5C,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGvE,OAAO,EACL,eAAe,EACf,qBAAqB,EACtB,MAAM,oCAAoC,CAAC;AAC5C,YAAY,EACV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,oCAAoC,CAAC;AAG5C,YAAY,EACV,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,OAAO,EACP,UAAU,EACV,OAAO,EACP,eAAe,EAChB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AACjD,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,CAAC;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;;GAGG;AACH,wBAAsB,cAAc,CAAC,MAAM,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,cAAc,CAAC,CAS7F;;;;;;;AAGD,wBAKE"}
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @license MIT OR Apache-2.0
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.AgentDBMCPServer = exports.isWasmInitialized = exports.resetWasm = exports.getWasm = exports.initSQL = exports.initWasm = exports.createBinaryQuantizer = exports.BinaryQuantizer = exports.QuantizationUtils = exports.QuantizationProfiles = exports.ImprovedProductQuantizer = exports.ScalarQuantizer = exports.ProductQuantizer = exports.VectorQueryBuilder = exports.QueryCache = exports.OptimizedHNSWIndex = exports.DEFAULT_HNSW_CONFIG = exports.HNSWIndex = exports.BackendType = exports.WasmBackend = exports.NativeBackend = exports.SQLiteVectorDB = void 0;
|
|
11
|
+
exports.AgentDBMCPServer = exports.isWasmInitialized = exports.resetWasm = exports.getWasm = exports.initSQL = exports.initWasm = exports.createBinaryQuantizer = exports.BinaryQuantizer = exports.QuantizationUtils = exports.QuantizationProfiles = exports.ImprovedProductQuantizer = exports.ScalarQuantizer = exports.ProductQuantizer = exports.VectorQueryBuilder = exports.QueryCache = exports.OptimizedHNSWIndex = exports.DEFAULT_HNSW_CONFIG = exports.HNSWIndex = exports.Presets = exports.BackendType = exports.WasmBackend = exports.NativeBackend = exports.SQLiteVectorDB = void 0;
|
|
12
12
|
exports.createVectorDB = createVectorDB;
|
|
13
13
|
/**
|
|
14
14
|
* SQLiteVector - Ultra-fast vector database with dual backend support
|
|
@@ -30,6 +30,8 @@ Object.defineProperty(exports, "initSQL", { enumerable: true, get: function () {
|
|
|
30
30
|
Object.defineProperty(exports, "getWasm", { enumerable: true, get: function () { return wasm_loader_1.getWasm; } });
|
|
31
31
|
Object.defineProperty(exports, "isWasmInitialized", { enumerable: true, get: function () { return wasm_loader_1.isInitialized; } });
|
|
32
32
|
Object.defineProperty(exports, "resetWasm", { enumerable: true, get: function () { return wasm_loader_1.resetWasm; } });
|
|
33
|
+
const presets_1 = require("./presets");
|
|
34
|
+
Object.defineProperty(exports, "Presets", { enumerable: true, get: function () { return presets_1.Presets; } });
|
|
33
35
|
// HNSW indexing for high-performance search
|
|
34
36
|
var hnsw_1 = require("./index/hnsw");
|
|
35
37
|
Object.defineProperty(exports, "HNSWIndex", { enumerable: true, get: function () { return hnsw_1.HNSWIndex; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAiGH,wCASC;AAxGD;;;;GAIG;AAEH,mBAAmB;AACnB,gDAAkD;AAQzC,+FARA,0BAAc,OAQA;AAPvB,0DAAsD;AAQ7C,8FARA,8BAAa,OAQA;AAPtB,sDAAkD;AAQzC,4FARA,0BAAW,OAQA;AAPpB,gEAA8F;AAQrF,4FARA,+BAAW,OAQA;AAPpB,+CAAqF;AA0E5E,yFA1EA,sBAAQ,OA0EA;AAAE,wFA1EA,qBAAO,OA0EA;AAAE,wFA1EA,qBAAO,OA0EA;AACT,kGA3EW,2BAAa,OA2EP;AADN,0FA1Ee,uBAAS,OA0Ef;AAzE9C,uCAAoC;AAO3B,wFAPA,iBAAO,OAOA;AAGhB,4CAA4C;AAC5C,qCAA8D;AAArD,iGAAA,SAAS,OAAA;AAAE,2GAAA,mBAAmB,OAAA;AACvC,yDAA4D;AAAnD,oHAAA,kBAAkB,OAAA;AAI3B,wDAAwD;AACxD,mDAAiD;AAAxC,yGAAA,UAAU,OAAA;AAGnB,8CAA8C;AAC9C,uDAA2D;AAAlD,mHAAA,kBAAkB,OAAA;AAG3B,4CAA4C;AAC5C,4EAAuE;AAA9D,wHAAA,gBAAgB,OAAA;AAGzB,+EAA+E;AAC/E,0EAAqE;AAA5D,sHAAA,eAAe,OAAA;AAOxB,gDAAgD;AAChD,4DAIqC;AAHnC,wHAAA,wBAAwB,OAAA;AACxB,oHAAA,oBAAoB,OAAA;AACpB,iHAAA,iBAAiB,OAAA;AAInB,iEAAiE;AACjE,0EAG4C;AAF1C,sHAAA,eAAe,OAAA;AACf,4HAAA,qBAAqB,OAAA;AA6BvB,aAAa;AACb,iDAAmD;AAA1C,iHAAA,gBAAgB,OAAA;AAEzB;;;GAGG;AACI,KAAK,UAAU,cAAc,CAAC,MAA+B;IAClE,MAAM,EAAE,GAAG,IAAI,0BAAc,CAAC,MAAM,CAAC,CAAC;IAEtC,mCAAmC;IACnC,IAAI,EAAE,CAAC,cAAc,EAAE,KAAK,+BAAW,CAAC,IAAI,EAAE,CAAC;QAC7C,MAAM,EAAE,CAAC,eAAe,EAAE,CAAC;IAC7B,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,iCAAiC;AACjC,kBAAe;IACb,cAAc,EAAd,0BAAc;IACd,cAAc;IACd,WAAW,EAAX,+BAAW;IACX,QAAQ,EAAR,sBAAQ;CACT,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -17,11 +17,13 @@ import { NativeBackend } from './core/native-backend.mjs';
|
|
|
17
17
|
import { WasmBackend } from './core/wasm-backend.mjs';
|
|
18
18
|
import { BackendType } from './core/backend-interface.mjs';
|
|
19
19
|
import { initWasm, initSQL, getWasm, isInitialized, resetWasm } from './wasm-loader.mjs';
|
|
20
|
+
import { Presets } from './presets.mjs';
|
|
20
21
|
// Re-export everything
|
|
21
22
|
export { SQLiteVectorDB };
|
|
22
23
|
export { NativeBackend };
|
|
23
24
|
export { WasmBackend };
|
|
24
25
|
export { BackendType };
|
|
26
|
+
export { Presets };
|
|
25
27
|
// HNSW indexing for high-performance search
|
|
26
28
|
export { HNSWIndex, DEFAULT_HNSW_CONFIG } from './index/hnsw.mjs';
|
|
27
29
|
export { OptimizedHNSWIndex } from './index/hnsw-optimized.mjs';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database configuration presets for common use cases
|
|
3
|
+
* Provides convenient factory functions for different dataset sizes
|
|
4
|
+
*
|
|
5
|
+
* Note: Vector dimension is not part of DatabaseConfig - it's determined
|
|
6
|
+
* by the actual vectors inserted. These presets configure database behavior,
|
|
7
|
+
* caching, and optimization settings.
|
|
8
|
+
*/
|
|
9
|
+
import { DatabaseConfig } from './types';
|
|
10
|
+
export declare class Presets {
|
|
11
|
+
/**
|
|
12
|
+
* Small dataset preset (< 10K vectors)
|
|
13
|
+
* Optimized for quick initialization and small-scale testing
|
|
14
|
+
*
|
|
15
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
16
|
+
* @param path - Database file path (omit or use undefined for in-memory)
|
|
17
|
+
* @returns Database configuration optimized for small datasets
|
|
18
|
+
*/
|
|
19
|
+
static smallDataset(dimension?: number, path?: string): DatabaseConfig;
|
|
20
|
+
/**
|
|
21
|
+
* Medium dataset preset (10K - 100K vectors)
|
|
22
|
+
* Balanced configuration for moderate-scale applications
|
|
23
|
+
*
|
|
24
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
25
|
+
* @param path - Database file path (omit or use undefined for in-memory)
|
|
26
|
+
* @returns Database configuration optimized for medium datasets
|
|
27
|
+
*/
|
|
28
|
+
static mediumDataset(dimension?: number, path?: string): DatabaseConfig;
|
|
29
|
+
/**
|
|
30
|
+
* Large dataset preset (100K+ vectors)
|
|
31
|
+
* High-performance configuration for large-scale production use
|
|
32
|
+
*
|
|
33
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
34
|
+
* @param path - Database file path
|
|
35
|
+
* @returns Database configuration optimized for large datasets
|
|
36
|
+
*/
|
|
37
|
+
static largeDataset(dimension?: number, path?: string): DatabaseConfig;
|
|
38
|
+
/**
|
|
39
|
+
* In-memory preset
|
|
40
|
+
* Fast, ephemeral database for testing and temporary operations
|
|
41
|
+
*
|
|
42
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
43
|
+
* @returns Database configuration for in-memory database
|
|
44
|
+
*/
|
|
45
|
+
static inMemory(dimension?: number): DatabaseConfig;
|
|
46
|
+
/**
|
|
47
|
+
* High-accuracy preset
|
|
48
|
+
* Larger cache and longer TTL for better accuracy
|
|
49
|
+
*
|
|
50
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
51
|
+
* @param path - Database file path
|
|
52
|
+
* @returns Database configuration optimized for accuracy
|
|
53
|
+
*/
|
|
54
|
+
static highAccuracy(dimension?: number, path?: string): DatabaseConfig;
|
|
55
|
+
/**
|
|
56
|
+
* Fast search preset
|
|
57
|
+
* Optimized for speed with minimal caching
|
|
58
|
+
*
|
|
59
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
60
|
+
* @param path - Database file path
|
|
61
|
+
* @returns Database configuration optimized for speed
|
|
62
|
+
*/
|
|
63
|
+
static fastSearch(dimension?: number, path?: string): DatabaseConfig;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=presets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,qBAAa,OAAO;IAClB;;;;;;;OAOG;IACH,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc;IAetE;;;;;;;OAOG;IACH,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc;IAevE;;;;;;;OAOG;IACH,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc;IAgBtE;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,cAAc;IAanD;;;;;;;OAOG;IACH,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc;IAetE;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc;CAcrE"}
|
package/dist/presets.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Database configuration presets for common use cases
|
|
4
|
+
* Provides convenient factory functions for different dataset sizes
|
|
5
|
+
*
|
|
6
|
+
* Note: Vector dimension is not part of DatabaseConfig - it's determined
|
|
7
|
+
* by the actual vectors inserted. These presets configure database behavior,
|
|
8
|
+
* caching, and optimization settings.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.Presets = void 0;
|
|
12
|
+
class Presets {
|
|
13
|
+
/**
|
|
14
|
+
* Small dataset preset (< 10K vectors)
|
|
15
|
+
* Optimized for quick initialization and small-scale testing
|
|
16
|
+
*
|
|
17
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
18
|
+
* @param path - Database file path (omit or use undefined for in-memory)
|
|
19
|
+
* @returns Database configuration optimized for small datasets
|
|
20
|
+
*/
|
|
21
|
+
static smallDataset(dimension, path) {
|
|
22
|
+
return {
|
|
23
|
+
path: path || undefined,
|
|
24
|
+
memoryMode: !path || path === ':memory:',
|
|
25
|
+
cacheSize: 100, // 100MB cache for small datasets
|
|
26
|
+
walMode: true,
|
|
27
|
+
queryCache: {
|
|
28
|
+
enabled: true,
|
|
29
|
+
maxSize: 1000,
|
|
30
|
+
ttl: 60000, // 1 minute
|
|
31
|
+
enableStats: true
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Medium dataset preset (10K - 100K vectors)
|
|
37
|
+
* Balanced configuration for moderate-scale applications
|
|
38
|
+
*
|
|
39
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
40
|
+
* @param path - Database file path (omit or use undefined for in-memory)
|
|
41
|
+
* @returns Database configuration optimized for medium datasets
|
|
42
|
+
*/
|
|
43
|
+
static mediumDataset(dimension, path) {
|
|
44
|
+
return {
|
|
45
|
+
path: path || undefined,
|
|
46
|
+
memoryMode: !path || path === ':memory:',
|
|
47
|
+
cacheSize: 500, // 500MB cache for medium datasets
|
|
48
|
+
walMode: true,
|
|
49
|
+
queryCache: {
|
|
50
|
+
enabled: true,
|
|
51
|
+
maxSize: 5000,
|
|
52
|
+
ttl: 300000, // 5 minutes
|
|
53
|
+
enableStats: true
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Large dataset preset (100K+ vectors)
|
|
59
|
+
* High-performance configuration for large-scale production use
|
|
60
|
+
*
|
|
61
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
62
|
+
* @param path - Database file path
|
|
63
|
+
* @returns Database configuration optimized for large datasets
|
|
64
|
+
*/
|
|
65
|
+
static largeDataset(dimension, path) {
|
|
66
|
+
return {
|
|
67
|
+
path: path || undefined,
|
|
68
|
+
memoryMode: !path || path === ':memory:',
|
|
69
|
+
cacheSize: 2000, // 2GB cache for large datasets
|
|
70
|
+
walMode: true,
|
|
71
|
+
mmapSize: 1073741824, // 1GB mmap
|
|
72
|
+
queryCache: {
|
|
73
|
+
enabled: true,
|
|
74
|
+
maxSize: 10000,
|
|
75
|
+
ttl: 600000, // 10 minutes
|
|
76
|
+
enableStats: true
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* In-memory preset
|
|
82
|
+
* Fast, ephemeral database for testing and temporary operations
|
|
83
|
+
*
|
|
84
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
85
|
+
* @returns Database configuration for in-memory database
|
|
86
|
+
*/
|
|
87
|
+
static inMemory(dimension) {
|
|
88
|
+
return {
|
|
89
|
+
memoryMode: true,
|
|
90
|
+
cacheSize: 100,
|
|
91
|
+
queryCache: {
|
|
92
|
+
enabled: true,
|
|
93
|
+
maxSize: 500,
|
|
94
|
+
ttl: 60000,
|
|
95
|
+
enableStats: true
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* High-accuracy preset
|
|
101
|
+
* Larger cache and longer TTL for better accuracy
|
|
102
|
+
*
|
|
103
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
104
|
+
* @param path - Database file path
|
|
105
|
+
* @returns Database configuration optimized for accuracy
|
|
106
|
+
*/
|
|
107
|
+
static highAccuracy(dimension, path) {
|
|
108
|
+
return {
|
|
109
|
+
path: path || undefined,
|
|
110
|
+
memoryMode: !path || path === ':memory:',
|
|
111
|
+
cacheSize: 1000,
|
|
112
|
+
walMode: true,
|
|
113
|
+
queryCache: {
|
|
114
|
+
enabled: true,
|
|
115
|
+
maxSize: 20000,
|
|
116
|
+
ttl: 1800000, // 30 minutes
|
|
117
|
+
enableStats: true
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Fast search preset
|
|
123
|
+
* Optimized for speed with minimal caching
|
|
124
|
+
*
|
|
125
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
126
|
+
* @param path - Database file path
|
|
127
|
+
* @returns Database configuration optimized for speed
|
|
128
|
+
*/
|
|
129
|
+
static fastSearch(dimension, path) {
|
|
130
|
+
return {
|
|
131
|
+
path: path || undefined,
|
|
132
|
+
memoryMode: !path || path === ':memory:',
|
|
133
|
+
cacheSize: 50, // Minimal cache
|
|
134
|
+
walMode: true,
|
|
135
|
+
queryCache: {
|
|
136
|
+
enabled: true,
|
|
137
|
+
maxSize: 100,
|
|
138
|
+
ttl: 10000, // 10 seconds
|
|
139
|
+
enableStats: false
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.Presets = Presets;
|
|
145
|
+
//# sourceMappingURL=presets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAIH,MAAa,OAAO;IAClB;;;;;;;OAOG;IACH,MAAM,CAAC,YAAY,CAAC,SAAkB,EAAE,IAAa;QACnD,OAAO;YACL,IAAI,EAAE,IAAI,IAAI,SAAS;YACvB,UAAU,EAAE,CAAC,IAAI,IAAI,IAAI,KAAK,UAAU;YACxC,SAAS,EAAE,GAAG,EAAE,iCAAiC;YACjD,OAAO,EAAE,IAAI;YACb,UAAU,EAAE;gBACV,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,IAAI;gBACb,GAAG,EAAE,KAAK,EAAE,WAAW;gBACvB,WAAW,EAAE,IAAI;aAClB;SACF,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,aAAa,CAAC,SAAkB,EAAE,IAAa;QACpD,OAAO;YACL,IAAI,EAAE,IAAI,IAAI,SAAS;YACvB,UAAU,EAAE,CAAC,IAAI,IAAI,IAAI,KAAK,UAAU;YACxC,SAAS,EAAE,GAAG,EAAE,kCAAkC;YAClD,OAAO,EAAE,IAAI;YACb,UAAU,EAAE;gBACV,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,IAAI;gBACb,GAAG,EAAE,MAAM,EAAE,YAAY;gBACzB,WAAW,EAAE,IAAI;aAClB;SACF,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,YAAY,CAAC,SAAkB,EAAE,IAAa;QACnD,OAAO;YACL,IAAI,EAAE,IAAI,IAAI,SAAS;YACvB,UAAU,EAAE,CAAC,IAAI,IAAI,IAAI,KAAK,UAAU;YACxC,SAAS,EAAE,IAAI,EAAE,+BAA+B;YAChD,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,UAAU,EAAE,WAAW;YACjC,UAAU,EAAE;gBACV,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,KAAK;gBACd,GAAG,EAAE,MAAM,EAAE,aAAa;gBAC1B,WAAW,EAAE,IAAI;aAClB;SACF,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,CAAC,SAAkB;QAChC,OAAO;YACL,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE,GAAG;YACd,UAAU,EAAE;gBACV,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,GAAG;gBACZ,GAAG,EAAE,KAAK;gBACV,WAAW,EAAE,IAAI;aAClB;SACF,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,YAAY,CAAC,SAAkB,EAAE,IAAa;QACnD,OAAO;YACL,IAAI,EAAE,IAAI,IAAI,SAAS;YACvB,UAAU,EAAE,CAAC,IAAI,IAAI,IAAI,KAAK,UAAU;YACxC,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,IAAI;YACb,UAAU,EAAE;gBACV,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,KAAK;gBACd,GAAG,EAAE,OAAO,EAAE,aAAa;gBAC3B,WAAW,EAAE,IAAI;aAClB;SACF,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAC,SAAkB,EAAE,IAAa;QACjD,OAAO;YACL,IAAI,EAAE,IAAI,IAAI,SAAS;YACvB,UAAU,EAAE,CAAC,IAAI,IAAI,IAAI,KAAK,UAAU;YACxC,SAAS,EAAE,EAAE,EAAE,gBAAgB;YAC/B,OAAO,EAAE,IAAI;YACb,UAAU,EAAE;gBACV,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,GAAG;gBACZ,GAAG,EAAE,KAAK,EAAE,aAAa;gBACzB,WAAW,EAAE,KAAK;aACnB;SACF,CAAC;IACJ,CAAC;CACF;AAxID,0BAwIC"}
|
package/dist/presets.mjs
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database configuration presets for common use cases
|
|
3
|
+
* Provides convenient factory functions for different dataset sizes
|
|
4
|
+
*
|
|
5
|
+
* Note: Vector dimension is not part of DatabaseConfig - it's determined
|
|
6
|
+
* by the actual vectors inserted. These presets configure database behavior,
|
|
7
|
+
* caching, and optimization settings.
|
|
8
|
+
*/
|
|
9
|
+
export class Presets {
|
|
10
|
+
/**
|
|
11
|
+
* Small dataset preset (< 10K vectors)
|
|
12
|
+
* Optimized for quick initialization and small-scale testing
|
|
13
|
+
*
|
|
14
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
15
|
+
* @param path - Database file path (omit or use undefined for in-memory)
|
|
16
|
+
* @returns Database configuration optimized for small datasets
|
|
17
|
+
*/
|
|
18
|
+
static smallDataset(dimension, path) {
|
|
19
|
+
return {
|
|
20
|
+
path: path || undefined,
|
|
21
|
+
memoryMode: !path || path === ':memory:',
|
|
22
|
+
cacheSize: 100, // 100MB cache for small datasets
|
|
23
|
+
walMode: true,
|
|
24
|
+
queryCache: {
|
|
25
|
+
enabled: true,
|
|
26
|
+
maxSize: 1000,
|
|
27
|
+
ttl: 60000, // 1 minute
|
|
28
|
+
enableStats: true
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Medium dataset preset (10K - 100K vectors)
|
|
34
|
+
* Balanced configuration for moderate-scale applications
|
|
35
|
+
*
|
|
36
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
37
|
+
* @param path - Database file path (omit or use undefined for in-memory)
|
|
38
|
+
* @returns Database configuration optimized for medium datasets
|
|
39
|
+
*/
|
|
40
|
+
static mediumDataset(dimension, path) {
|
|
41
|
+
return {
|
|
42
|
+
path: path || undefined,
|
|
43
|
+
memoryMode: !path || path === ':memory:',
|
|
44
|
+
cacheSize: 500, // 500MB cache for medium datasets
|
|
45
|
+
walMode: true,
|
|
46
|
+
queryCache: {
|
|
47
|
+
enabled: true,
|
|
48
|
+
maxSize: 5000,
|
|
49
|
+
ttl: 300000, // 5 minutes
|
|
50
|
+
enableStats: true
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Large dataset preset (100K+ vectors)
|
|
56
|
+
* High-performance configuration for large-scale production use
|
|
57
|
+
*
|
|
58
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
59
|
+
* @param path - Database file path
|
|
60
|
+
* @returns Database configuration optimized for large datasets
|
|
61
|
+
*/
|
|
62
|
+
static largeDataset(dimension, path) {
|
|
63
|
+
return {
|
|
64
|
+
path: path || undefined,
|
|
65
|
+
memoryMode: !path || path === ':memory:',
|
|
66
|
+
cacheSize: 2000, // 2GB cache for large datasets
|
|
67
|
+
walMode: true,
|
|
68
|
+
mmapSize: 1073741824, // 1GB mmap
|
|
69
|
+
queryCache: {
|
|
70
|
+
enabled: true,
|
|
71
|
+
maxSize: 10000,
|
|
72
|
+
ttl: 600000, // 10 minutes
|
|
73
|
+
enableStats: true
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* In-memory preset
|
|
79
|
+
* Fast, ephemeral database for testing and temporary operations
|
|
80
|
+
*
|
|
81
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
82
|
+
* @returns Database configuration for in-memory database
|
|
83
|
+
*/
|
|
84
|
+
static inMemory(dimension) {
|
|
85
|
+
return {
|
|
86
|
+
memoryMode: true,
|
|
87
|
+
cacheSize: 100,
|
|
88
|
+
queryCache: {
|
|
89
|
+
enabled: true,
|
|
90
|
+
maxSize: 500,
|
|
91
|
+
ttl: 60000,
|
|
92
|
+
enableStats: true
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* High-accuracy preset
|
|
98
|
+
* Larger cache and longer TTL for better accuracy
|
|
99
|
+
*
|
|
100
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
101
|
+
* @param path - Database file path
|
|
102
|
+
* @returns Database configuration optimized for accuracy
|
|
103
|
+
*/
|
|
104
|
+
static highAccuracy(dimension, path) {
|
|
105
|
+
return {
|
|
106
|
+
path: path || undefined,
|
|
107
|
+
memoryMode: !path || path === ':memory:',
|
|
108
|
+
cacheSize: 1000,
|
|
109
|
+
walMode: true,
|
|
110
|
+
queryCache: {
|
|
111
|
+
enabled: true,
|
|
112
|
+
maxSize: 20000,
|
|
113
|
+
ttl: 1800000, // 30 minutes
|
|
114
|
+
enableStats: true
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Fast search preset
|
|
120
|
+
* Optimized for speed with minimal caching
|
|
121
|
+
*
|
|
122
|
+
* @param dimension - Vector dimension (for backward compatibility, not used)
|
|
123
|
+
* @param path - Database file path
|
|
124
|
+
* @returns Database configuration optimized for speed
|
|
125
|
+
*/
|
|
126
|
+
static fastSearch(dimension, path) {
|
|
127
|
+
return {
|
|
128
|
+
path: path || undefined,
|
|
129
|
+
memoryMode: !path || path === ':memory:',
|
|
130
|
+
cacheSize: 50, // Minimal cache
|
|
131
|
+
walMode: true,
|
|
132
|
+
queryCache: {
|
|
133
|
+
enabled: true,
|
|
134
|
+
maxSize: 100,
|
|
135
|
+
ttl: 10000, // 10 seconds
|
|
136
|
+
enableStats: false
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>AgentDB v1.0.7 CDN Test - better-sqlite3 Fix Validation</title>
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
10
|
+
max-width: 1000px;
|
|
11
|
+
margin: 50px auto;
|
|
12
|
+
padding: 20px;
|
|
13
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
14
|
+
color: white;
|
|
15
|
+
}
|
|
16
|
+
.container {
|
|
17
|
+
background: rgba(255, 255, 255, 0.95);
|
|
18
|
+
border-radius: 15px;
|
|
19
|
+
padding: 30px;
|
|
20
|
+
box-shadow: 0 10px 40px rgba(0,0,0,0.3);
|
|
21
|
+
color: #333;
|
|
22
|
+
}
|
|
23
|
+
h1 {
|
|
24
|
+
color: #667eea;
|
|
25
|
+
margin-bottom: 10px;
|
|
26
|
+
}
|
|
27
|
+
.status {
|
|
28
|
+
padding: 15px;
|
|
29
|
+
margin: 15px 0;
|
|
30
|
+
border-radius: 8px;
|
|
31
|
+
font-weight: bold;
|
|
32
|
+
}
|
|
33
|
+
.loading { background: #fff3cd; color: #856404; }
|
|
34
|
+
.success { background: #d4edda; color: #155724; }
|
|
35
|
+
.error { background: #f8d7da; color: #721c24; }
|
|
36
|
+
pre {
|
|
37
|
+
background: #f8f9fa;
|
|
38
|
+
padding: 15px;
|
|
39
|
+
border-radius: 8px;
|
|
40
|
+
overflow-x: auto;
|
|
41
|
+
font-size: 14px;
|
|
42
|
+
}
|
|
43
|
+
.version {
|
|
44
|
+
color: #6c757d;
|
|
45
|
+
font-size: 0.9em;
|
|
46
|
+
}
|
|
47
|
+
.test-results {
|
|
48
|
+
margin-top: 20px;
|
|
49
|
+
}
|
|
50
|
+
.test-item {
|
|
51
|
+
padding: 10px;
|
|
52
|
+
margin: 10px 0;
|
|
53
|
+
border-left: 4px solid #667eea;
|
|
54
|
+
background: #f8f9fa;
|
|
55
|
+
border-radius: 4px;
|
|
56
|
+
}
|
|
57
|
+
.pass { border-left-color: #28a745; }
|
|
58
|
+
.fail { border-left-color: #dc3545; }
|
|
59
|
+
</style>
|
|
60
|
+
</head>
|
|
61
|
+
<body>
|
|
62
|
+
<div class="container">
|
|
63
|
+
<h1>🚀 AgentDB v1.0.7 CDN Test</h1>
|
|
64
|
+
<p class="version">Testing better-sqlite3 fix via unpkg.com CDN</p>
|
|
65
|
+
|
|
66
|
+
<div id="status" class="status loading">
|
|
67
|
+
⏳ Loading AgentDB from CDN...
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<div class="test-results">
|
|
71
|
+
<h3>Test Results:</h3>
|
|
72
|
+
<div id="results"></div>
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<h3>Console Output:</h3>
|
|
76
|
+
<pre id="console"></pre>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<script type="module">
|
|
80
|
+
const statusEl = document.getElementById('status');
|
|
81
|
+
const resultsEl = document.getElementById('results');
|
|
82
|
+
const consoleEl = document.getElementById('console');
|
|
83
|
+
|
|
84
|
+
let logs = [];
|
|
85
|
+
function log(message, type = 'info') {
|
|
86
|
+
const timestamp = new Date().toLocaleTimeString();
|
|
87
|
+
const logMessage = `[${timestamp}] ${message}`;
|
|
88
|
+
logs.push(logMessage);
|
|
89
|
+
consoleEl.textContent = logs.join('\n');
|
|
90
|
+
console.log(message);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function addTestResult(name, passed, details) {
|
|
94
|
+
const div = document.createElement('div');
|
|
95
|
+
div.className = `test-item ${passed ? 'pass' : 'fail'}`;
|
|
96
|
+
div.innerHTML = `
|
|
97
|
+
<strong>${passed ? '✅' : '❌'} ${name}</strong>
|
|
98
|
+
${details ? `<br><small>${details}</small>` : ''}
|
|
99
|
+
`;
|
|
100
|
+
resultsEl.appendChild(div);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function runTests() {
|
|
104
|
+
try {
|
|
105
|
+
log('🔍 Attempting to import AgentDB v1.0.7 from unpkg CDN...');
|
|
106
|
+
|
|
107
|
+
// Import from unpkg CDN
|
|
108
|
+
const { SQLiteVectorDB, createVectorDB } = await import('https://unpkg.com/agentdb@1.0.7/dist/agentdb.min.js');
|
|
109
|
+
|
|
110
|
+
log('✅ Successfully loaded AgentDB module!');
|
|
111
|
+
addTestResult('Module Import', true, 'No better-sqlite3 import errors!');
|
|
112
|
+
|
|
113
|
+
// Test 1: Create database instance
|
|
114
|
+
log('🧪 Test 1: Creating SQLiteVectorDB instance...');
|
|
115
|
+
const db = new SQLiteVectorDB({
|
|
116
|
+
memoryMode: true,
|
|
117
|
+
backend: 'wasm'
|
|
118
|
+
});
|
|
119
|
+
addTestResult('Database Instance Creation', true, 'Backend set to WASM');
|
|
120
|
+
|
|
121
|
+
// Test 2: Initialize WASM backend
|
|
122
|
+
log('🧪 Test 2: Initializing WASM backend...');
|
|
123
|
+
await db.initializeAsync();
|
|
124
|
+
log('✅ WASM backend initialized successfully!');
|
|
125
|
+
addTestResult('WASM Initialization', true, 'sql.js loaded without errors');
|
|
126
|
+
|
|
127
|
+
// Test 3: Insert vector
|
|
128
|
+
log('🧪 Test 3: Inserting test vector...');
|
|
129
|
+
const vector1 = {
|
|
130
|
+
id: 'vec1',
|
|
131
|
+
embedding: [0.1, 0.2, 0.3, 0.4, 0.5],
|
|
132
|
+
metadata: { test: 'v1.0.7-fix', type: 'validation' }
|
|
133
|
+
};
|
|
134
|
+
const id1 = db.insert(vector1);
|
|
135
|
+
log(`✅ Inserted vector with ID: ${id1}`);
|
|
136
|
+
addTestResult('Vector Insert', true, `ID: ${id1}`);
|
|
137
|
+
|
|
138
|
+
// Test 4: Search
|
|
139
|
+
log('🧪 Test 4: Searching for similar vectors...');
|
|
140
|
+
const results = db.search([0.1, 0.2, 0.3, 0.4, 0.5], 1);
|
|
141
|
+
log(`✅ Found ${results.length} results, score: ${results[0]?.score}`);
|
|
142
|
+
addTestResult('Vector Search', results.length > 0, `Score: ${results[0]?.score?.toFixed(4)}`);
|
|
143
|
+
|
|
144
|
+
// Test 5: Verify backend type
|
|
145
|
+
log('🧪 Test 5: Verifying backend type...');
|
|
146
|
+
const backendType = db.getBackendType();
|
|
147
|
+
log(`✅ Backend type: ${backendType}`);
|
|
148
|
+
addTestResult('Backend Type Check', backendType === 'wasm', `Using: ${backendType}`);
|
|
149
|
+
|
|
150
|
+
// Test 6: Stats
|
|
151
|
+
log('🧪 Test 6: Getting database stats...');
|
|
152
|
+
const stats = db.stats();
|
|
153
|
+
log(`✅ Database has ${stats.count} vectors, size: ${stats.size} bytes`);
|
|
154
|
+
addTestResult('Database Stats', stats.count === 1, `Vectors: ${stats.count}, Size: ${stats.size}B`);
|
|
155
|
+
|
|
156
|
+
// All tests passed!
|
|
157
|
+
statusEl.textContent = '🎉 All tests passed! The better-sqlite3 fix works perfectly!';
|
|
158
|
+
statusEl.className = 'status success';
|
|
159
|
+
|
|
160
|
+
log('');
|
|
161
|
+
log('=' .repeat(60));
|
|
162
|
+
log('🎉 VALIDATION SUCCESSFUL!');
|
|
163
|
+
log('✅ No better-sqlite3 import errors');
|
|
164
|
+
log('✅ WASM backend works correctly');
|
|
165
|
+
log('✅ All vector operations functional');
|
|
166
|
+
log('✅ AgentDB v1.0.7 ready for production use in browsers!');
|
|
167
|
+
log('=' .repeat(60));
|
|
168
|
+
|
|
169
|
+
} catch (error) {
|
|
170
|
+
log(`❌ ERROR: ${error.message}`, 'error');
|
|
171
|
+
log(`Stack: ${error.stack}`, 'error');
|
|
172
|
+
|
|
173
|
+
statusEl.textContent = `❌ Test failed: ${error.message}`;
|
|
174
|
+
statusEl.className = 'status error';
|
|
175
|
+
|
|
176
|
+
addTestResult('Error Occurred', false, error.message);
|
|
177
|
+
|
|
178
|
+
// Check if it's the better-sqlite3 error
|
|
179
|
+
if (error.message.includes('better-sqlite3')) {
|
|
180
|
+
log('🚨 CRITICAL: better-sqlite3 dependency still present in bundle!');
|
|
181
|
+
addTestResult('better-sqlite3 Fix', false, 'Module still contains Node.js dependency');
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Run tests when page loads
|
|
187
|
+
runTests();
|
|
188
|
+
</script>
|
|
189
|
+
</body>
|
|
190
|
+
</html>
|
package/package.json
CHANGED