agentdb 1.0.5 โ†’ 1.0.8

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,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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentdb",
3
- "version": "1.0.5",
3
+ "version": "1.0.8",
4
4
  "description": "Ultra-fast agent memory and vector database with ReasoningBank for AI agents. Built on SQLite with QUIC sync. From ruv.io - Advanced AI Infrastructure.",
5
5
  "keywords": [
6
6
  "agent",