mnemocyte 0.1.2 → 0.1.3
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 +137 -103
- package/dist/index.mjs +141 -59
- package/dist/index.mjs.map +1 -1
- package/migrations/0000_initial.sql +33 -44
- package/migrations/meta/0000_snapshot.json +284 -0
- package/migrations/meta/_journal.json +13 -0
- package/package.json +19 -15
|
@@ -1,46 +1,35 @@
|
|
|
1
|
-
CREATE
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
type text NOT NULL DEFAULT 'fact',
|
|
8
|
-
importance text NOT NULL DEFAULT 'normal',
|
|
9
|
-
tags text[] NOT NULL DEFAULT '{}',
|
|
10
|
-
source text,
|
|
11
|
-
metadata jsonb NOT NULL DEFAULT '{}',
|
|
12
|
-
confidence real NOT NULL DEFAULT 1.0,
|
|
13
|
-
embedding vector(1536),
|
|
14
|
-
embedding_model text NOT NULL,
|
|
15
|
-
embedding_dimensions integer NOT NULL,
|
|
16
|
-
superseded_by text REFERENCES mnemocyte_memories(id),
|
|
17
|
-
superseded_at timestamptz,
|
|
18
|
-
expires_at timestamptz,
|
|
19
|
-
last_accessed_at timestamptz,
|
|
20
|
-
access_count integer NOT NULL DEFAULT 0,
|
|
21
|
-
created_at timestamptz NOT NULL DEFAULT now(),
|
|
22
|
-
updated_at timestamptz NOT NULL DEFAULT now()
|
|
1
|
+
CREATE TABLE "mnemocyte_events" (
|
|
2
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
3
|
+
"entity_id" text NOT NULL,
|
|
4
|
+
"description" text NOT NULL,
|
|
5
|
+
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
6
|
+
"timestamp" timestamp with time zone DEFAULT now() NOT NULL
|
|
23
7
|
);
|
|
24
|
-
|
|
25
|
-
CREATE TABLE
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
8
|
+
--> statement-breakpoint
|
|
9
|
+
CREATE TABLE "mnemocyte_memories" (
|
|
10
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
11
|
+
"entity_id" text NOT NULL,
|
|
12
|
+
"content" text NOT NULL,
|
|
13
|
+
"type" text DEFAULT 'fact' NOT NULL,
|
|
14
|
+
"importance" text DEFAULT 'normal' NOT NULL,
|
|
15
|
+
"tags" text[] DEFAULT '{}'::text[] NOT NULL,
|
|
16
|
+
"source" text,
|
|
17
|
+
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
18
|
+
"confidence" real DEFAULT 1 NOT NULL,
|
|
19
|
+
"embedding" vector(1536),
|
|
20
|
+
"embedding_model" text NOT NULL,
|
|
21
|
+
"embedding_dimensions" integer NOT NULL,
|
|
22
|
+
"superseded_by" text,
|
|
23
|
+
"superseded_at" timestamp with time zone,
|
|
24
|
+
"expires_at" timestamp with time zone,
|
|
25
|
+
"last_accessed_at" timestamp with time zone,
|
|
26
|
+
"access_count" integer DEFAULT 0 NOT NULL,
|
|
27
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
28
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
31
29
|
);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
CREATE INDEX
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
CREATE INDEX IF NOT EXISTS mnemocyte_events_entity_time_idx
|
|
40
|
-
ON mnemocyte_events (entity_id, timestamp DESC);
|
|
41
|
-
|
|
42
|
-
CREATE INDEX IF NOT EXISTS mnemocyte_memories_fts_idx
|
|
43
|
-
ON mnemocyte_memories USING gin (to_tsvector('english', content));
|
|
44
|
-
|
|
45
|
-
CREATE INDEX IF NOT EXISTS mnemocyte_memories_embedding_hnsw_idx
|
|
46
|
-
ON mnemocyte_memories USING hnsw (embedding vector_cosine_ops);
|
|
30
|
+
--> statement-breakpoint
|
|
31
|
+
ALTER TABLE "mnemocyte_memories" ADD CONSTRAINT "mnemocyte_memories_superseded_by_mnemocyte_memories_id_fk" FOREIGN KEY ("superseded_by") REFERENCES "public"."mnemocyte_memories"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
|
32
|
+
CREATE INDEX "mnemocyte_events_entity_time_idx" ON "mnemocyte_events" USING btree ("entity_id","timestamp");--> statement-breakpoint
|
|
33
|
+
CREATE INDEX "mnemocyte_memories_entity_idx" ON "mnemocyte_memories" USING btree ("entity_id");--> statement-breakpoint
|
|
34
|
+
CREATE INDEX "mnemocyte_memories_entity_type_idx" ON "mnemocyte_memories" USING btree ("entity_id","type");--> statement-breakpoint
|
|
35
|
+
CREATE INDEX "mnemocyte_memories_embedding_hnsw_idx" ON "mnemocyte_memories" USING hnsw ("embedding" vector_cosine_ops);
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "feeb327d-c000-40d3-9c3c-3eb82b2e2e81",
|
|
3
|
+
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
4
|
+
"version": "7",
|
|
5
|
+
"dialect": "postgresql",
|
|
6
|
+
"tables": {
|
|
7
|
+
"public.mnemocyte_events": {
|
|
8
|
+
"name": "mnemocyte_events",
|
|
9
|
+
"schema": "",
|
|
10
|
+
"columns": {
|
|
11
|
+
"id": {
|
|
12
|
+
"name": "id",
|
|
13
|
+
"type": "text",
|
|
14
|
+
"primaryKey": true,
|
|
15
|
+
"notNull": true
|
|
16
|
+
},
|
|
17
|
+
"entity_id": {
|
|
18
|
+
"name": "entity_id",
|
|
19
|
+
"type": "text",
|
|
20
|
+
"primaryKey": false,
|
|
21
|
+
"notNull": true
|
|
22
|
+
},
|
|
23
|
+
"description": {
|
|
24
|
+
"name": "description",
|
|
25
|
+
"type": "text",
|
|
26
|
+
"primaryKey": false,
|
|
27
|
+
"notNull": true
|
|
28
|
+
},
|
|
29
|
+
"metadata": {
|
|
30
|
+
"name": "metadata",
|
|
31
|
+
"type": "jsonb",
|
|
32
|
+
"primaryKey": false,
|
|
33
|
+
"notNull": true,
|
|
34
|
+
"default": "'{}'::jsonb"
|
|
35
|
+
},
|
|
36
|
+
"timestamp": {
|
|
37
|
+
"name": "timestamp",
|
|
38
|
+
"type": "timestamp with time zone",
|
|
39
|
+
"primaryKey": false,
|
|
40
|
+
"notNull": true,
|
|
41
|
+
"default": "now()"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"indexes": {
|
|
45
|
+
"mnemocyte_events_entity_time_idx": {
|
|
46
|
+
"name": "mnemocyte_events_entity_time_idx",
|
|
47
|
+
"columns": [
|
|
48
|
+
{
|
|
49
|
+
"expression": "entity_id",
|
|
50
|
+
"isExpression": false,
|
|
51
|
+
"asc": true,
|
|
52
|
+
"nulls": "last"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"expression": "timestamp",
|
|
56
|
+
"isExpression": false,
|
|
57
|
+
"asc": true,
|
|
58
|
+
"nulls": "last"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"isUnique": false,
|
|
62
|
+
"concurrently": false,
|
|
63
|
+
"method": "btree",
|
|
64
|
+
"with": {}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"foreignKeys": {},
|
|
68
|
+
"compositePrimaryKeys": {},
|
|
69
|
+
"uniqueConstraints": {},
|
|
70
|
+
"policies": {},
|
|
71
|
+
"checkConstraints": {},
|
|
72
|
+
"isRLSEnabled": false
|
|
73
|
+
},
|
|
74
|
+
"public.mnemocyte_memories": {
|
|
75
|
+
"name": "mnemocyte_memories",
|
|
76
|
+
"schema": "",
|
|
77
|
+
"columns": {
|
|
78
|
+
"id": {
|
|
79
|
+
"name": "id",
|
|
80
|
+
"type": "text",
|
|
81
|
+
"primaryKey": true,
|
|
82
|
+
"notNull": true
|
|
83
|
+
},
|
|
84
|
+
"entity_id": {
|
|
85
|
+
"name": "entity_id",
|
|
86
|
+
"type": "text",
|
|
87
|
+
"primaryKey": false,
|
|
88
|
+
"notNull": true
|
|
89
|
+
},
|
|
90
|
+
"content": {
|
|
91
|
+
"name": "content",
|
|
92
|
+
"type": "text",
|
|
93
|
+
"primaryKey": false,
|
|
94
|
+
"notNull": true
|
|
95
|
+
},
|
|
96
|
+
"type": {
|
|
97
|
+
"name": "type",
|
|
98
|
+
"type": "text",
|
|
99
|
+
"primaryKey": false,
|
|
100
|
+
"notNull": true,
|
|
101
|
+
"default": "'fact'"
|
|
102
|
+
},
|
|
103
|
+
"importance": {
|
|
104
|
+
"name": "importance",
|
|
105
|
+
"type": "text",
|
|
106
|
+
"primaryKey": false,
|
|
107
|
+
"notNull": true,
|
|
108
|
+
"default": "'normal'"
|
|
109
|
+
},
|
|
110
|
+
"tags": {
|
|
111
|
+
"name": "tags",
|
|
112
|
+
"type": "text[]",
|
|
113
|
+
"primaryKey": false,
|
|
114
|
+
"notNull": true,
|
|
115
|
+
"default": "'{}'::text[]"
|
|
116
|
+
},
|
|
117
|
+
"source": {
|
|
118
|
+
"name": "source",
|
|
119
|
+
"type": "text",
|
|
120
|
+
"primaryKey": false,
|
|
121
|
+
"notNull": false
|
|
122
|
+
},
|
|
123
|
+
"metadata": {
|
|
124
|
+
"name": "metadata",
|
|
125
|
+
"type": "jsonb",
|
|
126
|
+
"primaryKey": false,
|
|
127
|
+
"notNull": true,
|
|
128
|
+
"default": "'{}'::jsonb"
|
|
129
|
+
},
|
|
130
|
+
"confidence": {
|
|
131
|
+
"name": "confidence",
|
|
132
|
+
"type": "real",
|
|
133
|
+
"primaryKey": false,
|
|
134
|
+
"notNull": true,
|
|
135
|
+
"default": 1
|
|
136
|
+
},
|
|
137
|
+
"embedding": {
|
|
138
|
+
"name": "embedding",
|
|
139
|
+
"type": "vector(1536)",
|
|
140
|
+
"primaryKey": false,
|
|
141
|
+
"notNull": false
|
|
142
|
+
},
|
|
143
|
+
"embedding_model": {
|
|
144
|
+
"name": "embedding_model",
|
|
145
|
+
"type": "text",
|
|
146
|
+
"primaryKey": false,
|
|
147
|
+
"notNull": true
|
|
148
|
+
},
|
|
149
|
+
"embedding_dimensions": {
|
|
150
|
+
"name": "embedding_dimensions",
|
|
151
|
+
"type": "integer",
|
|
152
|
+
"primaryKey": false,
|
|
153
|
+
"notNull": true
|
|
154
|
+
},
|
|
155
|
+
"superseded_by": {
|
|
156
|
+
"name": "superseded_by",
|
|
157
|
+
"type": "text",
|
|
158
|
+
"primaryKey": false,
|
|
159
|
+
"notNull": false
|
|
160
|
+
},
|
|
161
|
+
"superseded_at": {
|
|
162
|
+
"name": "superseded_at",
|
|
163
|
+
"type": "timestamp with time zone",
|
|
164
|
+
"primaryKey": false,
|
|
165
|
+
"notNull": false
|
|
166
|
+
},
|
|
167
|
+
"expires_at": {
|
|
168
|
+
"name": "expires_at",
|
|
169
|
+
"type": "timestamp with time zone",
|
|
170
|
+
"primaryKey": false,
|
|
171
|
+
"notNull": false
|
|
172
|
+
},
|
|
173
|
+
"last_accessed_at": {
|
|
174
|
+
"name": "last_accessed_at",
|
|
175
|
+
"type": "timestamp with time zone",
|
|
176
|
+
"primaryKey": false,
|
|
177
|
+
"notNull": false
|
|
178
|
+
},
|
|
179
|
+
"access_count": {
|
|
180
|
+
"name": "access_count",
|
|
181
|
+
"type": "integer",
|
|
182
|
+
"primaryKey": false,
|
|
183
|
+
"notNull": true,
|
|
184
|
+
"default": 0
|
|
185
|
+
},
|
|
186
|
+
"created_at": {
|
|
187
|
+
"name": "created_at",
|
|
188
|
+
"type": "timestamp with time zone",
|
|
189
|
+
"primaryKey": false,
|
|
190
|
+
"notNull": true,
|
|
191
|
+
"default": "now()"
|
|
192
|
+
},
|
|
193
|
+
"updated_at": {
|
|
194
|
+
"name": "updated_at",
|
|
195
|
+
"type": "timestamp with time zone",
|
|
196
|
+
"primaryKey": false,
|
|
197
|
+
"notNull": true,
|
|
198
|
+
"default": "now()"
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
"indexes": {
|
|
202
|
+
"mnemocyte_memories_entity_idx": {
|
|
203
|
+
"name": "mnemocyte_memories_entity_idx",
|
|
204
|
+
"columns": [
|
|
205
|
+
{
|
|
206
|
+
"expression": "entity_id",
|
|
207
|
+
"isExpression": false,
|
|
208
|
+
"asc": true,
|
|
209
|
+
"nulls": "last"
|
|
210
|
+
}
|
|
211
|
+
],
|
|
212
|
+
"isUnique": false,
|
|
213
|
+
"concurrently": false,
|
|
214
|
+
"method": "btree",
|
|
215
|
+
"with": {}
|
|
216
|
+
},
|
|
217
|
+
"mnemocyte_memories_entity_type_idx": {
|
|
218
|
+
"name": "mnemocyte_memories_entity_type_idx",
|
|
219
|
+
"columns": [
|
|
220
|
+
{
|
|
221
|
+
"expression": "entity_id",
|
|
222
|
+
"isExpression": false,
|
|
223
|
+
"asc": true,
|
|
224
|
+
"nulls": "last"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"expression": "type",
|
|
228
|
+
"isExpression": false,
|
|
229
|
+
"asc": true,
|
|
230
|
+
"nulls": "last"
|
|
231
|
+
}
|
|
232
|
+
],
|
|
233
|
+
"isUnique": false,
|
|
234
|
+
"concurrently": false,
|
|
235
|
+
"method": "btree",
|
|
236
|
+
"with": {}
|
|
237
|
+
},
|
|
238
|
+
"mnemocyte_memories_embedding_hnsw_idx": {
|
|
239
|
+
"name": "mnemocyte_memories_embedding_hnsw_idx",
|
|
240
|
+
"columns": [
|
|
241
|
+
{
|
|
242
|
+
"expression": "embedding",
|
|
243
|
+
"isExpression": false,
|
|
244
|
+
"asc": true,
|
|
245
|
+
"nulls": "last",
|
|
246
|
+
"opclass": "vector_cosine_ops"
|
|
247
|
+
}
|
|
248
|
+
],
|
|
249
|
+
"isUnique": false,
|
|
250
|
+
"concurrently": false,
|
|
251
|
+
"method": "hnsw",
|
|
252
|
+
"with": {}
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
"foreignKeys": {
|
|
256
|
+
"mnemocyte_memories_superseded_by_mnemocyte_memories_id_fk": {
|
|
257
|
+
"name": "mnemocyte_memories_superseded_by_mnemocyte_memories_id_fk",
|
|
258
|
+
"tableFrom": "mnemocyte_memories",
|
|
259
|
+
"tableTo": "mnemocyte_memories",
|
|
260
|
+
"columnsFrom": ["superseded_by"],
|
|
261
|
+
"columnsTo": ["id"],
|
|
262
|
+
"onDelete": "no action",
|
|
263
|
+
"onUpdate": "no action"
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
"compositePrimaryKeys": {},
|
|
267
|
+
"uniqueConstraints": {},
|
|
268
|
+
"policies": {},
|
|
269
|
+
"checkConstraints": {},
|
|
270
|
+
"isRLSEnabled": false
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
"enums": {},
|
|
274
|
+
"schemas": {},
|
|
275
|
+
"sequences": {},
|
|
276
|
+
"roles": {},
|
|
277
|
+
"policies": {},
|
|
278
|
+
"views": {},
|
|
279
|
+
"_meta": {
|
|
280
|
+
"columns": {},
|
|
281
|
+
"schemas": {},
|
|
282
|
+
"tables": {}
|
|
283
|
+
}
|
|
284
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mnemocyte",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Persistent memory for TypeScript AI apps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -51,24 +51,28 @@
|
|
|
51
51
|
"@types/node": "^25.9.0",
|
|
52
52
|
"drizzle-kit": "^0.31.10",
|
|
53
53
|
"tsdown": "^0.22.0",
|
|
54
|
-
"typescript": "^6.0.3"
|
|
54
|
+
"typescript": "^6.0.3",
|
|
55
|
+
"vitest": "4.1.6"
|
|
55
56
|
},
|
|
56
57
|
"scripts": {
|
|
57
58
|
"build": "tsdown src/index.ts",
|
|
58
59
|
"dev": "tsdown src/index.ts --watch",
|
|
59
|
-
"checktypes": "tsc --noEmit",
|
|
60
|
-
"test
|
|
61
|
-
"test:
|
|
62
|
-
"test:
|
|
63
|
-
"test:
|
|
64
|
-
"test:
|
|
65
|
-
"test:
|
|
66
|
-
"test:
|
|
67
|
-
"test:
|
|
68
|
-
"test:
|
|
69
|
-
"test:
|
|
70
|
-
"test:
|
|
71
|
-
"
|
|
60
|
+
"checktypes": "tsc --noEmit && tsc --noEmit --project tsconfig.test.json",
|
|
61
|
+
"test": "pnpm run test:ci",
|
|
62
|
+
"test:ci": "pnpm build && vitest run --typecheck --project unit --project package",
|
|
63
|
+
"test:unit": "vitest run --project unit",
|
|
64
|
+
"test:exports": "pnpm build && vitest run --typecheck --project package",
|
|
65
|
+
"test:observability": "vitest run --project unit test/observability/hooks.test.ts",
|
|
66
|
+
"test:resilience": "vitest run --project unit test/resilience/resilience.test.ts",
|
|
67
|
+
"test:prune": "vitest run --project unit test/prune/prune.test.ts",
|
|
68
|
+
"test:lifecycle": "vitest run --project unit test/lifecycle/close.test.ts",
|
|
69
|
+
"test:dedup": "vitest run --project unit test/dedup/find-duplicates.test.ts",
|
|
70
|
+
"test:audit": "vitest run --project unit test/audit/audit-log.test.ts",
|
|
71
|
+
"test:consolidate": "vitest run --project unit test/consolidate/consolidate.test.ts",
|
|
72
|
+
"test:retrieval": "vitest run --project unit test/retrieval/quality.test.ts",
|
|
73
|
+
"test:context": "vitest run --project unit test/context/builder.test.ts",
|
|
74
|
+
"test:integration": "vitest run --project integration",
|
|
75
|
+
"bench:retrieval": "vitest bench --project unit test/benchmarks/retrieval.bench.ts",
|
|
72
76
|
"lint": "biome lint --write",
|
|
73
77
|
"format": "biome format --write",
|
|
74
78
|
"db:generate": "drizzle-kit generate",
|