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.
- package/CHANGELOG.md +26 -0
- package/README.md +34 -7
- package/bin/agentdb.js +13 -7
- package/dist/agentdb.js +2670 -9755
- package/dist/agentdb.js.map +4 -4
- package/dist/agentdb.min.js +46 -138
- package/dist/agentdb.min.js.map +4 -4
- package/dist/core/vector-db.d.ts.map +1 -1
- package/dist/core/vector-db.js +14 -10
- package/dist/core/vector-db.js.map +1 -1
- package/dist/core/vector-db.mjs +13 -9
- package/dist/index.browser.d.ts +47 -0
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/index.browser.js +72 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.browser.mjs +54 -0
- 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/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