agentdb 1.3.17 → 1.4.1
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/dist/agentdb.min.js +4 -4
- package/dist/cli/agentdb-cli.js +0 -0
- package/dist/db-fallback.d.ts +4 -6
- package/dist/db-fallback.d.ts.map +1 -1
- package/dist/db-fallback.js +10 -11
- package/dist/db-fallback.js.map +1 -1
- package/package.json +3 -4
- package/scripts/postinstall.cjs +161 -0
- package/src/db-fallback.ts +184 -0
- package/dist/browser.d.ts +0 -3
- package/dist/browser.d.ts.map +0 -1
- package/dist/browser.js +0 -9
- package/dist/browser.js.map +0 -1
- package/dist/types/database.d.ts +0 -26
- package/dist/types/database.d.ts.map +0 -1
- package/dist/types/database.js +0 -6
- package/dist/types/database.js.map +0 -1
package/dist/agentdb.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! AgentDB Browser Bundle v1.
|
|
1
|
+
/*! AgentDB Browser Bundle v1.4.1 | 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.
|
|
196
|
+
// AgentDB v1.4.1 - v1.0.7 Compatible Browser Bundle
|
|
197
197
|
|
|
198
198
|
var sqlReady = false;
|
|
199
199
|
var SQL = null;
|
|
@@ -539,7 +539,7 @@ else if (typeof exports === 'object'){
|
|
|
539
539
|
|
|
540
540
|
// Create AgentDB namespace with all exports
|
|
541
541
|
var AgentDB = {
|
|
542
|
-
version: '1.
|
|
542
|
+
version: '1.4.1',
|
|
543
543
|
Database: Database,
|
|
544
544
|
ready: false,
|
|
545
545
|
|
|
@@ -577,6 +577,6 @@ else if (typeof exports === 'object'){
|
|
|
577
577
|
global.SQLiteVectorDB = Database;
|
|
578
578
|
}
|
|
579
579
|
|
|
580
|
-
console.log('AgentDB v1.
|
|
580
|
+
console.log('AgentDB v1.4.1 loaded (v1.0.7 API compatible)');
|
|
581
581
|
|
|
582
582
|
})(typeof window !== 'undefined' ? window : this);
|
package/dist/cli/agentdb-cli.js
CHANGED
|
File without changes
|
package/dist/db-fallback.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Database System using sql.js WASM
|
|
3
|
-
* Pure JavaScript
|
|
2
|
+
* Database System using sql.js (WASM SQLite)
|
|
3
|
+
* Pure JavaScript implementation with NO build dependencies
|
|
4
4
|
*/
|
|
5
|
-
type DatabaseConstructor = any;
|
|
6
5
|
/**
|
|
7
|
-
* Get sql.js database implementation
|
|
6
|
+
* Get sql.js database implementation (ONLY sql.js, no better-sqlite3)
|
|
8
7
|
*/
|
|
9
|
-
export declare function getDatabaseImplementation(): Promise<
|
|
8
|
+
export declare function getDatabaseImplementation(): Promise<any>;
|
|
10
9
|
/**
|
|
11
10
|
* Create a database instance using sql.js
|
|
12
11
|
*/
|
|
@@ -20,5 +19,4 @@ export declare function getDatabaseInfo(): {
|
|
|
20
19
|
performance: 'high' | 'medium' | 'low';
|
|
21
20
|
requiresBuildTools: boolean;
|
|
22
21
|
};
|
|
23
|
-
export {};
|
|
24
22
|
//# sourceMappingURL=db-fallback.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-fallback.d.ts","sourceRoot":"","sources":["../src/db-fallback.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"db-fallback.d.ts","sourceRoot":"","sources":["../src/db-fallback.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH;;GAEG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,GAAG,CAAC,CAwB9D;AA2HD;;GAEG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAGlF;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACvC,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAOA"}
|
package/dist/db-fallback.js
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Database System using sql.js WASM
|
|
3
|
-
* Pure JavaScript
|
|
2
|
+
* Database System using sql.js (WASM SQLite)
|
|
3
|
+
* Pure JavaScript implementation with NO build dependencies
|
|
4
4
|
*/
|
|
5
|
-
let
|
|
6
|
-
let SqlJsWrapper = null;
|
|
5
|
+
let sqlJsWrapper = null;
|
|
7
6
|
/**
|
|
8
|
-
* Get sql.js database implementation
|
|
7
|
+
* Get sql.js database implementation (ONLY sql.js, no better-sqlite3)
|
|
9
8
|
*/
|
|
10
9
|
export async function getDatabaseImplementation() {
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
// Return cached wrapper
|
|
11
|
+
if (sqlJsWrapper) {
|
|
12
|
+
return sqlJsWrapper;
|
|
13
13
|
}
|
|
14
14
|
try {
|
|
15
|
+
console.log('✅ Using sql.js (WASM SQLite, no build tools required)');
|
|
15
16
|
// sql.js requires async initialization
|
|
16
17
|
const mod = await import('sql.js');
|
|
17
18
|
const SQL = await mod.default();
|
|
18
19
|
// Create database wrapper
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
console.log('✅ Using sql.js (WASM-based SQLite, no build tools required)');
|
|
22
|
-
return SqlJsWrapper;
|
|
20
|
+
sqlJsWrapper = createSqlJsWrapper(SQL);
|
|
21
|
+
return sqlJsWrapper;
|
|
23
22
|
}
|
|
24
23
|
catch (error) {
|
|
25
24
|
console.error('❌ Failed to initialize sql.js:', error.message);
|
package/dist/db-fallback.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-fallback.js","sourceRoot":"","sources":["../src/db-fallback.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,IAAI,
|
|
1
|
+
{"version":3,"file":"db-fallback.js","sourceRoot":"","sources":["../src/db-fallback.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,IAAI,YAAY,GAAQ,IAAI,CAAC;AAE7B;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB;IAC7C,wBAAwB;IACxB,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,uDAAuD,CAAC,CAAC;QAErE,uCAAuC;QACvC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnC,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;QAEhC,0BAA0B;QAC1B,YAAY,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAEvC,OAAO,YAAY,CAAC;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAG,KAAe,CAAC,OAAO,CAAC,CAAC;QAC1E,MAAM,IAAI,KAAK,CACb,mEAAmE;YACnE,oBAAoB,CACrB,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,kBAAkB,CAAC,GAAQ;IAClC,OAAO,MAAM,aAAa;QAChB,EAAE,CAAM;QACR,QAAQ,CAAS;QAEzB,YAAY,QAAgB,EAAE,OAAa;YACzC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAEzB,qBAAqB;YACrB,IAAI,QAAQ,KAAK,UAAU,EAAE,CAAC;gBAC5B,IAAI,CAAC,EAAE,GAAG,IAAI,GAAG,CAAC,QAAQ,EAAE,C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O;QACL,cAAc,EAAE,eAAe;QAC/B,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,QAAQ;QACrB,kBAAkB,EAAE,KAAK;KAC1B,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentdb",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
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",
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
"hnsw",
|
|
51
51
|
"embeddings",
|
|
52
52
|
"sqlite",
|
|
53
|
-
"
|
|
53
|
+
"sql.js",
|
|
54
|
+
"wasm"
|
|
54
55
|
],
|
|
55
56
|
"author": "ruv",
|
|
56
57
|
"license": "MIT",
|
|
@@ -72,7 +73,6 @@
|
|
|
72
73
|
"zod": "^3.25.76"
|
|
73
74
|
},
|
|
74
75
|
"devDependencies": {
|
|
75
|
-
"@types/better-sqlite3": "^7.6.11",
|
|
76
76
|
"@types/node": "^22.10.2",
|
|
77
77
|
"esbuild": "^0.25.11",
|
|
78
78
|
"tsx": "^4.19.2",
|
|
@@ -90,6 +90,5 @@
|
|
|
90
90
|
"LICENSE"
|
|
91
91
|
],
|
|
92
92
|
"optionalDependencies": {
|
|
93
|
-
"better-sqlite3": "^11.7.0"
|
|
94
93
|
}
|
|
95
94
|
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* AgentDB Post-Install Script
|
|
4
|
+
* Handles better-sqlite3 installation in various environments
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { execSync } = require('child_process');
|
|
8
|
+
const { existsSync } = require('fs');
|
|
9
|
+
const { join } = require('path');
|
|
10
|
+
|
|
11
|
+
const packageRoot = join(__dirname, '..');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Check if better-sqlite3 is properly installed
|
|
15
|
+
*/
|
|
16
|
+
function checkBetterSqlite3() {
|
|
17
|
+
try {
|
|
18
|
+
// Try to require better-sqlite3
|
|
19
|
+
const Database = require('better-sqlite3');
|
|
20
|
+
const db = new Database(':memory:');
|
|
21
|
+
db.close();
|
|
22
|
+
console.log('✅ better-sqlite3 is working correctly');
|
|
23
|
+
return true;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.warn('⚠️ better-sqlite3 native binding issue:', (error && error.message) || 'unknown');
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Attempt to rebuild better-sqlite3
|
|
32
|
+
*/
|
|
33
|
+
function rebuildBetterSqlite3() {
|
|
34
|
+
console.log('🔧 Attempting to rebuild better-sqlite3...');
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
// Try to rebuild
|
|
38
|
+
execSync('npm rebuild better-sqlite3', {
|
|
39
|
+
cwd: packageRoot,
|
|
40
|
+
stdio: 'inherit',
|
|
41
|
+
env: Object.assign({}, process.env, { npm_config_build_from_source: 'true' })
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (checkBetterSqlite3()) {
|
|
45
|
+
console.log('✅ Rebuild successful');
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.warn('⚠️ Rebuild failed:', (error && error.message) || 'unknown');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Check for required build tools
|
|
57
|
+
*/
|
|
58
|
+
function checkBuildTools() {
|
|
59
|
+
const tools = {
|
|
60
|
+
python: ['python3 --version', 'python --version'],
|
|
61
|
+
make: ['make --version'],
|
|
62
|
+
compiler: ['g++ --version', 'clang++ --version', 'cl /?']
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const available = {};
|
|
66
|
+
|
|
67
|
+
for (const name in tools) {
|
|
68
|
+
const commands = tools[name];
|
|
69
|
+
available[name] = false;
|
|
70
|
+
for (let i = 0; i < commands.length; i++) {
|
|
71
|
+
try {
|
|
72
|
+
execSync(commands[i], { stdio: 'ignore' });
|
|
73
|
+
available[name] = true;
|
|
74
|
+
break;
|
|
75
|
+
} catch (error) {
|
|
76
|
+
// Continue trying other commands
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return available;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Provide installation guidance
|
|
86
|
+
*/
|
|
87
|
+
function provideGuidance() {
|
|
88
|
+
console.log('\n📋 Installation Guidance for better-sqlite3:\n');
|
|
89
|
+
|
|
90
|
+
const buildTools = checkBuildTools();
|
|
91
|
+
|
|
92
|
+
if (!buildTools.python) {
|
|
93
|
+
console.log('❌ Python not found. Install Python 3:');
|
|
94
|
+
console.log(' - Ubuntu/Debian: sudo apt-get install python3');
|
|
95
|
+
console.log(' - Alpine: apk add python3');
|
|
96
|
+
console.log(' - macOS: brew install python3');
|
|
97
|
+
console.log(' - Windows: https://www.python.org/downloads/\n');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (!buildTools.make) {
|
|
101
|
+
console.log('❌ Make not found. Install build tools:');
|
|
102
|
+
console.log(' - Ubuntu/Debian: sudo apt-get install build-essential');
|
|
103
|
+
console.log(' - Alpine: apk add make');
|
|
104
|
+
console.log(' - macOS: xcode-select --install');
|
|
105
|
+
console.log(' - Windows: npm install --global windows-build-tools\n');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (!buildTools.compiler) {
|
|
109
|
+
console.log('❌ C++ compiler not found. Install compiler:');
|
|
110
|
+
console.log(' - Ubuntu/Debian: sudo apt-get install g++');
|
|
111
|
+
console.log(' - Alpine: apk add g++');
|
|
112
|
+
console.log(' - macOS: xcode-select --install');
|
|
113
|
+
console.log(' - Windows: Install Visual Studio Build Tools\n');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
console.log('📚 For Docker environments, use this base setup:');
|
|
117
|
+
console.log(' Alpine: apk add --no-cache python3 make g++ sqlite sqlite-dev');
|
|
118
|
+
console.log(' Ubuntu: apt-get install -y python3 make g++ sqlite3 libsqlite3-dev\n');
|
|
119
|
+
|
|
120
|
+
console.log('🔗 More info: https://github.com/WiseLibs/better-sqlite3/blob/master/docs/troubleshooting.md\n');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Main installation check
|
|
125
|
+
*/
|
|
126
|
+
function main() {
|
|
127
|
+
console.log('🔍 Verifying AgentDB installation...\n');
|
|
128
|
+
|
|
129
|
+
// Skip in CI environments or if explicitly disabled
|
|
130
|
+
if (process.env.CI || process.env.AGENTDB_SKIP_POSTINSTALL === 'true') {
|
|
131
|
+
console.log('ℹ️ Skipping post-install checks (CI environment)');
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Check if better-sqlite3 is working
|
|
136
|
+
if (checkBetterSqlite3()) {
|
|
137
|
+
console.log('✅ AgentDB installation successful!\n');
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Try to rebuild
|
|
142
|
+
console.log('⚠️ Detected potential installation issue. Attempting automatic fix...\n');
|
|
143
|
+
|
|
144
|
+
if (rebuildBetterSqlite3()) {
|
|
145
|
+
console.log('✅ AgentDB installation fixed!\n');
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Provide guidance
|
|
150
|
+
console.log('⚠️ Could not automatically fix installation.\n');
|
|
151
|
+
provideGuidance();
|
|
152
|
+
|
|
153
|
+
console.log('💡 If you continue to have issues, please report at:');
|
|
154
|
+
console.log(' https://github.com/ruvnet/agentic-flow/issues\n');
|
|
155
|
+
|
|
156
|
+
// Don't fail the installation - allow it to proceed
|
|
157
|
+
// Users can still use sql.js fallback if needed
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Run post-install check
|
|
161
|
+
main();
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database System using sql.js (WASM SQLite)
|
|
3
|
+
* Pure JavaScript implementation with NO build dependencies
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Type-only for compatibility
|
|
7
|
+
type Database = any;
|
|
8
|
+
|
|
9
|
+
let sqlJsWrapper: any = null;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Get sql.js database implementation (ONLY sql.js, no better-sqlite3)
|
|
13
|
+
*/
|
|
14
|
+
export async function getDatabaseImplementation(): Promise<any> {
|
|
15
|
+
// Return cached wrapper
|
|
16
|
+
if (sqlJsWrapper) {
|
|
17
|
+
return sqlJsWrapper;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
console.log('✅ Using sql.js (WASM SQLite, no build tools required)');
|
|
22
|
+
|
|
23
|
+
// sql.js requires async initialization
|
|
24
|
+
const mod = await import('sql.js');
|
|
25
|
+
const SQL = await mod.default();
|
|
26
|
+
|
|
27
|
+
// Create database wrapper
|
|
28
|
+
sqlJsWrapper = createSqlJsWrapper(SQL);
|
|
29
|
+
|
|
30
|
+
return sqlJsWrapper;
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error('❌ Failed to initialize sql.js:', (error as Error).message);
|
|
33
|
+
throw new Error(
|
|
34
|
+
'Failed to initialize SQLite. Please ensure sql.js is installed:\n' +
|
|
35
|
+
'npm install sql.js'
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Create a better-sqlite3 compatible wrapper around sql.js
|
|
42
|
+
* This allows AgentDB to work (with reduced performance) without native compilation
|
|
43
|
+
*/
|
|
44
|
+
function createSqlJsWrapper(SQL: any) {
|
|
45
|
+
return class SqlJsDatabase {
|
|
46
|
+
private db: any;
|
|
47
|
+
private filename: string;
|
|
48
|
+
|
|
49
|
+
constructor(filename: string, options?: any) {
|
|
50
|
+
this.filename = filename;
|
|
51
|
+
|
|
52
|
+
// In-memory database
|
|
53
|
+
if (filename === ':memory:') {
|
|
54
|
+
this.db = new SQL.Database();
|
|
55
|
+
} else {
|
|
56
|
+
// File-based database - use dynamic import workaround
|
|
57
|
+
try {
|
|
58
|
+
// Try to read existing file
|
|
59
|
+
const fs = eval('require')('fs');
|
|
60
|
+
if (fs.existsSync(filename)) {
|
|
61
|
+
const buffer = fs.readFileSync(filename);
|
|
62
|
+
this.db = new SQL.Database(buffer);
|
|
63
|
+
} else {
|
|
64
|
+
this.db = new SQL.Database();
|
|
65
|
+
}
|
|
66
|
+
} catch {
|
|
67
|
+
// If require fails (shouldn't happen in Node), create empty DB
|
|
68
|
+
this.db = new SQL.Database();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
prepare(sql: string) {
|
|
74
|
+
const stmt = this.db.prepare(sql);
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
run: (...params: any[]) => {
|
|
78
|
+
stmt.bind(params);
|
|
79
|
+
stmt.step();
|
|
80
|
+
stmt.reset();
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
changes: this.db.getRowsModified(),
|
|
84
|
+
lastInsertRowid: this.db.exec('SELECT last_insert_rowid()')[0]?.values[0]?.[0] || 0
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
get: (...params: any[]) => {
|
|
89
|
+
stmt.bind(params);
|
|
90
|
+
const hasRow = stmt.step();
|
|
91
|
+
|
|
92
|
+
if (!hasRow) {
|
|
93
|
+
stmt.reset();
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const columns = stmt.getColumnNames();
|
|
98
|
+
const values = stmt.get();
|
|
99
|
+
stmt.reset();
|
|
100
|
+
|
|
101
|
+
const result: any = {};
|
|
102
|
+
columns.forEach((col: string, idx: number) => {
|
|
103
|
+
result[col] = values[idx];
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return result;
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
all: (...params: any[]) => {
|
|
110
|
+
stmt.bind(params);
|
|
111
|
+
const results: any[] = [];
|
|
112
|
+
|
|
113
|
+
while (stmt.step()) {
|
|
114
|
+
const columns = stmt.getColumnNames();
|
|
115
|
+
const values = stmt.get();
|
|
116
|
+
|
|
117
|
+
const result: any = {};
|
|
118
|
+
columns.forEach((col: string, idx: number) => {
|
|
119
|
+
result[col] = values[idx];
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
results.push(result);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
stmt.reset();
|
|
126
|
+
return results;
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
finalize: () => {
|
|
130
|
+
stmt.free();
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
exec(sql: string) {
|
|
136
|
+
return this.db.exec(sql);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
close() {
|
|
140
|
+
// Save to file if needed
|
|
141
|
+
if (this.filename !== ':memory:') {
|
|
142
|
+
try {
|
|
143
|
+
const fs = eval('require')('fs');
|
|
144
|
+
const data = this.db.export();
|
|
145
|
+
fs.writeFileSync(this.filename, Buffer.from(data));
|
|
146
|
+
} catch (error) {
|
|
147
|
+
console.warn('⚠️ Could not save database to file:', (error as Error).message);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
this.db.close();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
pragma(pragma: string, options?: any) {
|
|
155
|
+
const result = this.db.exec(`PRAGMA ${pragma}`);
|
|
156
|
+
return result[0]?.values[0]?.[0];
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Create a database instance using sql.js
|
|
163
|
+
*/
|
|
164
|
+
export async function createDatabase(filename: string, options?: any): Promise<any> {
|
|
165
|
+
const DatabaseImpl = await getDatabaseImplementation();
|
|
166
|
+
return new DatabaseImpl(filename, options);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Get information about current database implementation
|
|
171
|
+
*/
|
|
172
|
+
export function getDatabaseInfo(): {
|
|
173
|
+
implementation: string;
|
|
174
|
+
isNative: boolean;
|
|
175
|
+
performance: 'high' | 'medium' | 'low';
|
|
176
|
+
requiresBuildTools: boolean;
|
|
177
|
+
} {
|
|
178
|
+
return {
|
|
179
|
+
implementation: 'sql.js (WASM)',
|
|
180
|
+
isNative: false,
|
|
181
|
+
performance: 'medium',
|
|
182
|
+
requiresBuildTools: false
|
|
183
|
+
};
|
|
184
|
+
}
|
package/dist/browser.d.ts
DELETED
package/dist/browser.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAG1E,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/dist/browser.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// AgentDB Browser Bundle - Lightweight client
|
|
2
|
-
// Note: Full functionality requires Node.js environment
|
|
3
|
-
// This bundle provides browser-compatible utilities
|
|
4
|
-
export { EmbeddingService } from './dist/controllers/EmbeddingService.js';
|
|
5
|
-
// Browser-compatible version info
|
|
6
|
-
export const version = '1.3.2';
|
|
7
|
-
// Note: SQLite-dependent features require Node.js
|
|
8
|
-
console.log('AgentDB Browser Bundle loaded. Note: Full database features require Node.js environment.');
|
|
9
|
-
//# sourceMappingURL=browser.js.map
|
package/dist/browser.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AACA,8CAA8C;AAC9C,wDAAwD;AACxD,oDAAoD;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAE1E,kCAAkC;AAClC,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,kDAAkD;AAClD,OAAO,CAAC,GAAG,CAAC,0FAA0F,CAAC,CAAC"}
|
package/dist/types/database.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Database type definitions for sql.js compatibility
|
|
3
|
-
* This allows AgentDB to work with sql.js instead of better-sqlite3
|
|
4
|
-
*/
|
|
5
|
-
export interface RunResult {
|
|
6
|
-
changes: number;
|
|
7
|
-
lastInsertRowid: number;
|
|
8
|
-
}
|
|
9
|
-
export interface Statement {
|
|
10
|
-
run(...params: any[]): RunResult;
|
|
11
|
-
get(...params: any[]): any;
|
|
12
|
-
all(...params: any[]): any[];
|
|
13
|
-
finalize(): void;
|
|
14
|
-
}
|
|
15
|
-
export interface Database {
|
|
16
|
-
prepare(sql: string): Statement;
|
|
17
|
-
exec(sql: string): any;
|
|
18
|
-
close(): void;
|
|
19
|
-
pragma(pragma: string, options?: any): any;
|
|
20
|
-
transaction<T>(fn: () => T): () => T;
|
|
21
|
-
}
|
|
22
|
-
export type DatabaseConstructor = new (filename: string, options?: any) => Database;
|
|
23
|
-
export declare namespace Database {
|
|
24
|
-
type Database = import('./database.js').Database;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=database.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/types/database.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;IACjC,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IAC3B,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;IAC7B,QAAQ,IAAI,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACvB,KAAK,IAAI,IAAI,CAAC;IACd,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;IAC3C,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;CACtC;AAGD,MAAM,MAAM,mBAAmB,GAAG,KAAK,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,QAAQ,CAAC;AAGpF,yBAAiB,QAAQ,CAAC;IACxB,KAAY,QAAQ,GAAG,OAAO,eAAe,EAAE,QAAQ,CAAC;CACzD"}
|
package/dist/types/database.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../src/types/database.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|