psychmem 1.0.3 → 1.0.4
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.
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SQLite Adapter - Runtime-agnostic SQLite interface
|
|
3
3
|
*
|
|
4
|
-
* Supports
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
4
|
+
* Supports:
|
|
5
|
+
* - bun:sqlite (Bun runtime)
|
|
6
|
+
* - node:sqlite (Node.js 22+, no native addons required)
|
|
7
7
|
*/
|
|
8
8
|
declare global {
|
|
9
9
|
var Bun: {
|
|
@@ -29,7 +29,7 @@ export interface SqliteDatabase {
|
|
|
29
29
|
*/
|
|
30
30
|
export declare function isBun(): boolean;
|
|
31
31
|
/**
|
|
32
|
-
* Create a SQLite database connection using the appropriate driver
|
|
32
|
+
* Create a SQLite database connection using the appropriate native driver
|
|
33
33
|
*/
|
|
34
34
|
export declare function createDatabase(dbPath: string): Promise<SqliteDatabase>;
|
|
35
35
|
//# sourceMappingURL=sqlite-adapter.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SQLite Adapter - Runtime-agnostic SQLite interface
|
|
3
3
|
*
|
|
4
|
-
* Supports
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
4
|
+
* Supports:
|
|
5
|
+
* - bun:sqlite (Bun runtime)
|
|
6
|
+
* - node:sqlite (Node.js 22+, no native addons required)
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
9
|
* Detect if running in Bun
|
|
@@ -12,7 +12,7 @@ export function isBun() {
|
|
|
12
12
|
return typeof globalThis.Bun !== 'undefined';
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Create a SQLite database connection using the appropriate driver
|
|
15
|
+
* Create a SQLite database connection using the appropriate native driver
|
|
16
16
|
*/
|
|
17
17
|
export async function createDatabase(dbPath) {
|
|
18
18
|
if (isBun()) {
|
|
@@ -26,11 +26,9 @@ export async function createDatabase(dbPath) {
|
|
|
26
26
|
* Create database using bun:sqlite
|
|
27
27
|
*/
|
|
28
28
|
async function createBunDatabase(dbPath) {
|
|
29
|
-
// Dynamic import for bun:sqlite
|
|
30
29
|
// @ts-expect-error - bun:sqlite is only available in Bun runtime
|
|
31
30
|
const { Database } = await import('bun:sqlite');
|
|
32
31
|
const db = new Database(dbPath);
|
|
33
|
-
// Wrapper to match our interface
|
|
34
32
|
return {
|
|
35
33
|
exec(sql) {
|
|
36
34
|
db.exec(sql);
|
|
@@ -39,11 +37,10 @@ async function createBunDatabase(dbPath) {
|
|
|
39
37
|
const stmt = db.prepare(sql);
|
|
40
38
|
return {
|
|
41
39
|
run(...params) {
|
|
42
|
-
|
|
43
|
-
const result = stmt.run(...params);
|
|
40
|
+
stmt.run(...params);
|
|
44
41
|
return {
|
|
45
|
-
changes: db.changes
|
|
46
|
-
lastInsertRowid: db.lastInsertRowid
|
|
42
|
+
changes: db.changes,
|
|
43
|
+
lastInsertRowid: db.lastInsertRowid,
|
|
47
44
|
};
|
|
48
45
|
},
|
|
49
46
|
get(...params) {
|
|
@@ -58,18 +55,17 @@ async function createBunDatabase(dbPath) {
|
|
|
58
55
|
db.close();
|
|
59
56
|
},
|
|
60
57
|
pragma(pragma) {
|
|
61
|
-
// bun:sqlite handles pragma via exec or query
|
|
62
58
|
return db.query(`PRAGMA ${pragma}`).get();
|
|
63
59
|
},
|
|
64
60
|
};
|
|
65
61
|
}
|
|
66
62
|
/**
|
|
67
|
-
* Create database using
|
|
63
|
+
* Create database using node:sqlite (Node.js 22+)
|
|
68
64
|
*/
|
|
69
65
|
async function createNodeDatabase(dbPath) {
|
|
70
|
-
//
|
|
71
|
-
const
|
|
72
|
-
const db = new
|
|
66
|
+
// node:sqlite is synchronous — dynamic import keeps the async adapter signature uniform
|
|
67
|
+
const { DatabaseSync } = await import('node:sqlite');
|
|
68
|
+
const db = new DatabaseSync(dbPath);
|
|
73
69
|
return {
|
|
74
70
|
exec(sql) {
|
|
75
71
|
db.exec(sql);
|
|
@@ -96,7 +92,7 @@ async function createNodeDatabase(dbPath) {
|
|
|
96
92
|
db.close();
|
|
97
93
|
},
|
|
98
94
|
pragma(pragma) {
|
|
99
|
-
return db.
|
|
95
|
+
return db.prepare(`PRAGMA ${pragma}`).get();
|
|
100
96
|
},
|
|
101
97
|
};
|
|
102
98
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-adapter.js","sourceRoot":"","sources":["../../src/storage/sqlite-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqBH;;GAEG;AACH,MAAM,UAAU,KAAK;IACnB,OAAO,OAAO,UAAU,CAAC,GAAG,KAAK,WAAW,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAc;IACjD,IAAI,KAAK,EAAE,EAAE,CAAC;QACZ,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;SAAM,CAAC;QACN,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,iBAAiB,CAAC,MAAc;IAC7C,
|
|
1
|
+
{"version":3,"file":"sqlite-adapter.js","sourceRoot":"","sources":["../../src/storage/sqlite-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqBH;;GAEG;AACH,MAAM,UAAU,KAAK;IACnB,OAAO,OAAO,UAAU,CAAC,GAAG,KAAK,WAAW,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAc;IACjD,IAAI,KAAK,EAAE,EAAE,CAAC;QACZ,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;SAAM,CAAC;QACN,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;AACH,CAAC;AAED;;GAEG;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AAO;QACL,IAAI,CAAC,GAAW;YACd,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;QAED,OAAO,CAAC,GAAW;YACjB,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC7B,OAAO;gBACL,GAAG,CAAC,GAAG,MAAiB;oBACtB,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;oBACnC,OAAO;wBACL,OAAO,EAAE,MAAM,CAAC,OAAiB;wBACjC,eAAe,EAAE,MAAM,CAAC,eAAkC;qBAC3D,CAAC;gBACJ,CAAC;gBACD,GAAG,CAAC,GAAG,MAAiB;oBACtB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;gBAC7B,CAAC;gBACD,GAAG,CAAC,GAAG,MAAiB;oBACtB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;gBAC7B,CAAC;aACF,CAAC;QACJ,CAAC;QAED,KAAK;YACH,EAAE,CAAC,KAAK,EAAE,CAAC;QACb,CAAC;QAED,MAAM,CAAC,MAAc;YACnB,OAAO,EAAE,CAAC,OAAO,CAAC,UAAU,MAAM,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC;QAC9C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "psychmem",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Psych-grounded selective memory system for AI agents with STM/LTM consolidation, decay curves, and learned importance weights",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -66,12 +66,10 @@
|
|
|
66
66
|
"README.md"
|
|
67
67
|
],
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"better-sqlite3": "^12.6.2",
|
|
70
69
|
"uuid": "^13.0.0"
|
|
71
70
|
},
|
|
72
71
|
"devDependencies": {
|
|
73
|
-
"@types/
|
|
74
|
-
"@types/node": "^25.2.3",
|
|
72
|
+
"@types/node": "^25.3.0",
|
|
75
73
|
"esbuild": "^0.27.3",
|
|
76
74
|
"typescript": "^5.9.3"
|
|
77
75
|
},
|