@membank/core 0.6.1 → 0.8.0
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/index.cjs +230 -40
- package/dist/index.d.cts +233 -61
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +233 -61
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +217 -41
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import BetterSqlite3 from "better-sqlite3";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
|
|
3
4
|
//#region src/db/errors.d.ts
|
|
4
5
|
declare class MembankError extends Error {
|
|
@@ -21,65 +22,234 @@ declare class DatabaseManager {
|
|
|
21
22
|
close(): void;
|
|
22
23
|
}
|
|
23
24
|
//#endregion
|
|
24
|
-
//#region src/
|
|
25
|
-
type MemoryType = "correction" | "preference" | "decision" | "learning" | "fact";
|
|
25
|
+
//#region src/schemas.d.ts
|
|
26
26
|
declare const MEMORY_TYPE_VALUES: readonly ["correction", "preference", "decision", "learning", "fact"];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
27
|
+
declare const MemoryTypeSchema: z.ZodEnum<{
|
|
28
|
+
correction: "correction";
|
|
29
|
+
preference: "preference";
|
|
30
|
+
decision: "decision";
|
|
31
|
+
learning: "learning";
|
|
32
|
+
fact: "fact";
|
|
33
|
+
}>;
|
|
34
|
+
type MemoryType = z.infer<typeof MemoryTypeSchema>;
|
|
35
|
+
declare const TagsJsonSchema: z.ZodArray<z.ZodString>;
|
|
36
|
+
declare const ProjectSchema: z.ZodObject<{
|
|
37
|
+
id: z.ZodString;
|
|
38
|
+
name: z.ZodString;
|
|
39
|
+
scopeHash: z.ZodString;
|
|
40
|
+
createdAt: z.ZodString;
|
|
41
|
+
updatedAt: z.ZodString;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
type Project = z.infer<typeof ProjectSchema>;
|
|
44
|
+
declare const ReviewReasonSchema: z.ZodEnum<{
|
|
45
|
+
similarity_dedup: "similarity_dedup";
|
|
46
|
+
}>;
|
|
47
|
+
type ReviewReason = z.infer<typeof ReviewReasonSchema>;
|
|
48
|
+
declare const ReviewEventSchema: z.ZodObject<{
|
|
49
|
+
id: z.ZodString;
|
|
50
|
+
memoryId: z.ZodString;
|
|
51
|
+
conflictingMemoryId: z.ZodNullable<z.ZodString>;
|
|
52
|
+
similarity: z.ZodNumber;
|
|
53
|
+
conflictContentSnapshot: z.ZodString;
|
|
54
|
+
reason: z.ZodEnum<{
|
|
55
|
+
similarity_dedup: "similarity_dedup";
|
|
56
|
+
}>;
|
|
57
|
+
createdAt: z.ZodString;
|
|
58
|
+
resolvedAt: z.ZodNullable<z.ZodString>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
type ReviewEvent = z.infer<typeof ReviewEventSchema>;
|
|
61
|
+
declare const ReviewEventRowSchema: z.ZodObject<{
|
|
62
|
+
id: z.ZodString;
|
|
63
|
+
memory_id: z.ZodString;
|
|
64
|
+
conflicting_memory_id: z.ZodNullable<z.ZodString>;
|
|
65
|
+
similarity: z.ZodNumber;
|
|
66
|
+
conflict_content_snapshot: z.ZodString;
|
|
67
|
+
reason: z.ZodEnum<{
|
|
68
|
+
similarity_dedup: "similarity_dedup";
|
|
69
|
+
}>;
|
|
70
|
+
created_at: z.ZodString;
|
|
71
|
+
resolved_at: z.ZodNullable<z.ZodString>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
type ReviewEventRow = z.infer<typeof ReviewEventRowSchema>;
|
|
74
|
+
declare const MemorySchema: z.ZodObject<{
|
|
75
|
+
id: z.ZodString;
|
|
76
|
+
content: z.ZodString;
|
|
77
|
+
type: z.ZodEnum<{
|
|
78
|
+
correction: "correction";
|
|
79
|
+
preference: "preference";
|
|
80
|
+
decision: "decision";
|
|
81
|
+
learning: "learning";
|
|
82
|
+
fact: "fact";
|
|
83
|
+
}>;
|
|
84
|
+
tags: z.ZodArray<z.ZodString>;
|
|
85
|
+
projects: z.ZodArray<z.ZodObject<{
|
|
86
|
+
id: z.ZodString;
|
|
87
|
+
name: z.ZodString;
|
|
88
|
+
scopeHash: z.ZodString;
|
|
89
|
+
createdAt: z.ZodString;
|
|
90
|
+
updatedAt: z.ZodString;
|
|
91
|
+
}, z.core.$strip>>;
|
|
92
|
+
sourceHarness: z.ZodNullable<z.ZodString>;
|
|
93
|
+
accessCount: z.ZodNumber;
|
|
94
|
+
pinned: z.ZodBoolean;
|
|
95
|
+
reviewEvents: z.ZodArray<z.ZodObject<{
|
|
96
|
+
id: z.ZodString;
|
|
97
|
+
memoryId: z.ZodString;
|
|
98
|
+
conflictingMemoryId: z.ZodNullable<z.ZodString>;
|
|
99
|
+
similarity: z.ZodNumber;
|
|
100
|
+
conflictContentSnapshot: z.ZodString;
|
|
101
|
+
reason: z.ZodEnum<{
|
|
102
|
+
similarity_dedup: "similarity_dedup";
|
|
103
|
+
}>;
|
|
104
|
+
createdAt: z.ZodString;
|
|
105
|
+
resolvedAt: z.ZodNullable<z.ZodString>;
|
|
106
|
+
}, z.core.$strip>>;
|
|
107
|
+
createdAt: z.ZodString;
|
|
108
|
+
updatedAt: z.ZodString;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
type Memory = z.infer<typeof MemorySchema>;
|
|
111
|
+
declare const QueryOptionsSchema: z.ZodObject<{
|
|
112
|
+
query: z.ZodString;
|
|
113
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
114
|
+
correction: "correction";
|
|
115
|
+
preference: "preference";
|
|
116
|
+
decision: "decision";
|
|
117
|
+
learning: "learning";
|
|
118
|
+
fact: "fact";
|
|
119
|
+
}>>;
|
|
120
|
+
projectHash: z.ZodOptional<z.ZodString>;
|
|
121
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
122
|
+
includePinned: z.ZodOptional<z.ZodBoolean>;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
type QueryOptions = z.infer<typeof QueryOptionsSchema>;
|
|
125
|
+
declare const SaveOptionsSchema: z.ZodObject<{
|
|
126
|
+
content: z.ZodString;
|
|
127
|
+
type: z.ZodEnum<{
|
|
128
|
+
correction: "correction";
|
|
129
|
+
preference: "preference";
|
|
130
|
+
decision: "decision";
|
|
131
|
+
learning: "learning";
|
|
132
|
+
fact: "fact";
|
|
133
|
+
}>;
|
|
134
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
135
|
+
projectScope: z.ZodOptional<z.ZodObject<{
|
|
136
|
+
hash: z.ZodString;
|
|
137
|
+
name: z.ZodString;
|
|
138
|
+
}, z.core.$strip>>;
|
|
139
|
+
sourceHarness: z.ZodOptional<z.ZodString>;
|
|
140
|
+
}, z.core.$strip>;
|
|
141
|
+
type SaveOptions = z.infer<typeof SaveOptionsSchema>;
|
|
142
|
+
declare const MemoryPatchSchema: z.ZodObject<{
|
|
143
|
+
content: z.ZodOptional<z.ZodString>;
|
|
144
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
145
|
+
}, z.core.$strip>;
|
|
146
|
+
type MemoryPatch = z.infer<typeof MemoryPatchSchema>;
|
|
147
|
+
declare const SessionContextSchema: z.ZodObject<{
|
|
148
|
+
stats: z.ZodRecord<z.ZodEnum<{
|
|
149
|
+
correction: "correction";
|
|
150
|
+
preference: "preference";
|
|
151
|
+
decision: "decision";
|
|
152
|
+
learning: "learning";
|
|
153
|
+
fact: "fact";
|
|
154
|
+
}>, z.ZodNumber>;
|
|
155
|
+
pinnedGlobal: z.ZodArray<z.ZodObject<{
|
|
156
|
+
id: z.ZodString;
|
|
157
|
+
content: z.ZodString;
|
|
158
|
+
type: z.ZodEnum<{
|
|
159
|
+
correction: "correction";
|
|
160
|
+
preference: "preference";
|
|
161
|
+
decision: "decision";
|
|
162
|
+
learning: "learning";
|
|
163
|
+
fact: "fact";
|
|
164
|
+
}>;
|
|
165
|
+
tags: z.ZodArray<z.ZodString>;
|
|
166
|
+
projects: z.ZodArray<z.ZodObject<{
|
|
167
|
+
id: z.ZodString;
|
|
168
|
+
name: z.ZodString;
|
|
169
|
+
scopeHash: z.ZodString;
|
|
170
|
+
createdAt: z.ZodString;
|
|
171
|
+
updatedAt: z.ZodString;
|
|
172
|
+
}, z.core.$strip>>;
|
|
173
|
+
sourceHarness: z.ZodNullable<z.ZodString>;
|
|
174
|
+
accessCount: z.ZodNumber;
|
|
175
|
+
pinned: z.ZodBoolean;
|
|
176
|
+
reviewEvents: z.ZodArray<z.ZodObject<{
|
|
177
|
+
id: z.ZodString;
|
|
178
|
+
memoryId: z.ZodString;
|
|
179
|
+
conflictingMemoryId: z.ZodNullable<z.ZodString>;
|
|
180
|
+
similarity: z.ZodNumber;
|
|
181
|
+
conflictContentSnapshot: z.ZodString;
|
|
182
|
+
reason: z.ZodEnum<{
|
|
183
|
+
similarity_dedup: "similarity_dedup";
|
|
184
|
+
}>;
|
|
185
|
+
createdAt: z.ZodString;
|
|
186
|
+
resolvedAt: z.ZodNullable<z.ZodString>;
|
|
187
|
+
}, z.core.$strip>>;
|
|
188
|
+
createdAt: z.ZodString;
|
|
189
|
+
updatedAt: z.ZodString;
|
|
190
|
+
}, z.core.$strip>>;
|
|
191
|
+
pinnedProject: z.ZodArray<z.ZodObject<{
|
|
192
|
+
id: z.ZodString;
|
|
193
|
+
content: z.ZodString;
|
|
194
|
+
type: z.ZodEnum<{
|
|
195
|
+
correction: "correction";
|
|
196
|
+
preference: "preference";
|
|
197
|
+
decision: "decision";
|
|
198
|
+
learning: "learning";
|
|
199
|
+
fact: "fact";
|
|
200
|
+
}>;
|
|
201
|
+
tags: z.ZodArray<z.ZodString>;
|
|
202
|
+
projects: z.ZodArray<z.ZodObject<{
|
|
203
|
+
id: z.ZodString;
|
|
204
|
+
name: z.ZodString;
|
|
205
|
+
scopeHash: z.ZodString;
|
|
206
|
+
createdAt: z.ZodString;
|
|
207
|
+
updatedAt: z.ZodString;
|
|
208
|
+
}, z.core.$strip>>;
|
|
209
|
+
sourceHarness: z.ZodNullable<z.ZodString>;
|
|
210
|
+
accessCount: z.ZodNumber;
|
|
211
|
+
pinned: z.ZodBoolean;
|
|
212
|
+
reviewEvents: z.ZodArray<z.ZodObject<{
|
|
213
|
+
id: z.ZodString;
|
|
214
|
+
memoryId: z.ZodString;
|
|
215
|
+
conflictingMemoryId: z.ZodNullable<z.ZodString>;
|
|
216
|
+
similarity: z.ZodNumber;
|
|
217
|
+
conflictContentSnapshot: z.ZodString;
|
|
218
|
+
reason: z.ZodEnum<{
|
|
219
|
+
similarity_dedup: "similarity_dedup";
|
|
220
|
+
}>;
|
|
221
|
+
createdAt: z.ZodString;
|
|
222
|
+
resolvedAt: z.ZodNullable<z.ZodString>;
|
|
223
|
+
}, z.core.$strip>>;
|
|
224
|
+
createdAt: z.ZodString;
|
|
225
|
+
updatedAt: z.ZodString;
|
|
226
|
+
}, z.core.$strip>>;
|
|
227
|
+
}, z.core.$strip>;
|
|
228
|
+
type SessionContext = z.infer<typeof SessionContextSchema>;
|
|
229
|
+
declare const MemoryRowSchema: z.ZodObject<{
|
|
230
|
+
id: z.ZodString;
|
|
231
|
+
content: z.ZodString;
|
|
232
|
+
type: z.ZodString;
|
|
233
|
+
tags: z.ZodString;
|
|
234
|
+
source: z.ZodNullable<z.ZodString>;
|
|
235
|
+
access_count: z.ZodNumber;
|
|
236
|
+
pinned: z.ZodNumber;
|
|
237
|
+
created_at: z.ZodString;
|
|
238
|
+
updated_at: z.ZodString;
|
|
239
|
+
}, z.core.$strip>;
|
|
240
|
+
type MemoryRow = z.infer<typeof MemoryRowSchema>;
|
|
241
|
+
declare const ProjectRowSchema: z.ZodObject<{
|
|
242
|
+
id: z.ZodString;
|
|
243
|
+
name: z.ZodString;
|
|
244
|
+
scope_hash: z.ZodString;
|
|
245
|
+
created_at: z.ZodString;
|
|
246
|
+
updated_at: z.ZodString;
|
|
247
|
+
}, z.core.$strip>;
|
|
248
|
+
type ProjectRow = z.infer<typeof ProjectRowSchema>;
|
|
68
249
|
//#endregion
|
|
69
250
|
//#region src/db/row-types.d.ts
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
content: string;
|
|
73
|
-
type: string;
|
|
74
|
-
tags: string;
|
|
75
|
-
source: string | null;
|
|
76
|
-
access_count: number;
|
|
77
|
-
pinned: number;
|
|
78
|
-
needs_review: number;
|
|
79
|
-
created_at: string;
|
|
80
|
-
updated_at: string;
|
|
81
|
-
}
|
|
82
|
-
declare function rowToMemory(row: MemoryRow, projects: Project[]): Memory;
|
|
251
|
+
declare function rowToMemory(row: MemoryRow, projects: Project[], reviewEvents?: ReviewEvent[]): Memory;
|
|
252
|
+
declare function rowToProject(row: ProjectRow): Project;
|
|
83
253
|
//#endregion
|
|
84
254
|
//#region src/embedding/service.d.ts
|
|
85
255
|
type ProgressCallback = (progress: {
|
|
@@ -114,15 +284,17 @@ declare class MemoryRepository {
|
|
|
114
284
|
#private;
|
|
115
285
|
constructor(db: DatabaseManager, embeddingService: EmbeddingService, projects: ProjectRepository);
|
|
116
286
|
save(options: SaveOptions): Promise<Memory>;
|
|
117
|
-
update(id: string, patch:
|
|
118
|
-
content?: string;
|
|
119
|
-
tags?: string[];
|
|
120
|
-
}): Promise<Memory>;
|
|
287
|
+
update(id: string, patch: MemoryPatch): Promise<Memory>;
|
|
121
288
|
delete(id: string): Promise<void>;
|
|
122
289
|
list(opts?: {
|
|
123
290
|
type?: MemoryType;
|
|
124
291
|
pinned?: boolean;
|
|
125
292
|
}): Memory[];
|
|
293
|
+
listFlagged(): Memory[];
|
|
294
|
+
listReviewEvents(memoryId: string, opts?: {
|
|
295
|
+
unresolvedOnly?: boolean;
|
|
296
|
+
}): ReviewEvent[];
|
|
297
|
+
resolveReviewEvents(memoryId: string): void;
|
|
126
298
|
stats(): {
|
|
127
299
|
byType: Record<MemoryType, number>;
|
|
128
300
|
total: number;
|
|
@@ -170,5 +342,5 @@ declare class SessionContextBuilder {
|
|
|
170
342
|
getSessionContext(projectHash: string): SessionContext;
|
|
171
343
|
}
|
|
172
344
|
//#endregion
|
|
173
|
-
export { DatabaseError, DatabaseManager, EmbeddingService, MEMORY_TYPE_VALUES, MIGRATIONS, MembankError, Memory, MemoryRepository,
|
|
345
|
+
export { DatabaseError, DatabaseManager, EmbeddingService, MEMORY_TYPE_VALUES, MIGRATIONS, MembankError, Memory, MemoryPatch, MemoryPatchSchema, MemoryRepository, MemoryRow, MemoryRowSchema, MemorySchema, MemoryType, MemoryTypeSchema, MigrationMeta, ProgressCallback, Project, ProjectRepository, ProjectRow, ProjectRowSchema, ProjectSchema, QueryEngine, QueryOptions, QueryOptionsSchema, ReviewEvent, ReviewEventRow, ReviewEventRowSchema, ReviewEventSchema, ReviewReason, ReviewReasonSchema, SaveOptions, SaveOptionsSchema, ScopeToProjectsResult, SessionContext, SessionContextBuilder, SessionContextSchema, TagsJsonSchema, listMemoryTypes, resolveProject, resolveScope, rowToMemory, rowToProject, runScopeToProjectsMigration };
|
|
174
346
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/db/errors.ts","../src/db/manager.ts","../src/
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/db/errors.ts","../src/db/manager.ts","../src/schemas.ts","../src/db/row-types.ts","../src/embedding/service.ts","../src/project/repository.ts","../src/memory/repository.ts","../src/migrations/index.ts","../src/query/engine.ts","../src/scope/resolver.ts","../src/session/builder.ts"],"mappings":";;;;cAAa,YAAA,SAAqB,KAAA;cACpB,OAAA,UAAiB,OAAA,GAAU,YAAA;AAAA;AAAA,cAM5B,aAAA,SAAsB,YAAA;cACrB,OAAA,UAAiB,OAAA,GAAU,YAAA;AAAA;;;KCCpC,SAAA,IAAa,EAAA,EAAI,aAAA,CAAc,QAAA;AAAA,cAoFvB,eAAA;EAAA;UAGJ,WAAA,CAAA;EAAA,OAIA,IAAA,CAAK,MAAA,YAAkB,eAAA;EAAA,OAOvB,YAAA,CAAA,GAAgB,eAAA;ED3Gc;EAAA,OCgH9B,uBAAA,CAAwB,MAAA,EAAQ,SAAA,GAAY,eAAA;EAAA,IAmD/C,EAAA,CAAA,GAAM,aAAA,CAAc,QAAA;EAIxB,KAAA,CAAA;AAAA;;;cCrKW,kBAAA;AAAA,cAQA,gBAAA,EAAgB,CAAA,CAAA,OAAA;;;;;;;KACjB,UAAA,GAAa,CAAA,CAAE,KAAA,QAAa,gBAAA;AAAA,cAE3B,cAAA,EAAc,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,SAAA;AAAA,cAEd,aAAA,EAAa,CAAA,CAAA,SAAA;;;;;;;KAOd,OAAA,GAAU,CAAA,CAAE,KAAA,QAAa,aAAA;AAAA,cAExB,kBAAA,EAAkB,CAAA,CAAA,OAAA;;;KACnB,YAAA,GAAe,CAAA,CAAE,KAAA,QAAa,kBAAA;AAAA,cAE7B,iBAAA,EAAiB,CAAA,CAAA,SAAA;;;;;;;;;;;;KAUlB,WAAA,GAAc,CAAA,CAAE,KAAA,QAAa,iBAAA;AAAA,cAE5B,oBAAA,EAAoB,CAAA,CAAA,SAAA;;;;;;;;;;;;KAUrB,cAAA,GA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AA,EAAY,aAAA;AAAA,iBAQH,2BAAA,CACpB,QAAA,EAAU,iBAAA,GACT,OAAA,CAAQ,qBAAA;;;cCNE,WAAA;EAAA;cAKC,EAAA,EAAI,eAAA,EAAiB,gBAAA,EAAkB,gBAAA,EAAkB,IAAA,EAAM,gBAAA;EAMrE,KAAA,CAAM,OAAA,EAAS,YAAA,GAAe,OAAA,CAAQ,KAAA,CAAM,MAAA;IAAW,KAAA;EAAA;AAAA;;;iBCpBzC,cAAA,CAAA,GAAkB,OAAA;EAAU,IAAA;EAAc,IAAA;AAAA;AAAA,iBAwB1C,YAAA,CAAA,GAAgB,OAAA;;;iBCxBtB,eAAA,CAAA,GAAmB,UAAA;AAAA,cAItB,qBAAA;EAAA;cAGC,EAAA,EAAI,eAAA;EAIhB,iBAAA,CAAkB,WAAA,WAAsB,cAAA;AAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import BetterSqlite3 from "better-sqlite3";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
|
|
3
4
|
//#region src/db/errors.d.ts
|
|
4
5
|
declare class MembankError extends Error {
|
|
@@ -21,65 +22,234 @@ declare class DatabaseManager {
|
|
|
21
22
|
close(): void;
|
|
22
23
|
}
|
|
23
24
|
//#endregion
|
|
24
|
-
//#region src/
|
|
25
|
-
type MemoryType = "correction" | "preference" | "decision" | "learning" | "fact";
|
|
25
|
+
//#region src/schemas.d.ts
|
|
26
26
|
declare const MEMORY_TYPE_VALUES: readonly ["correction", "preference", "decision", "learning", "fact"];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
27
|
+
declare const MemoryTypeSchema: z.ZodEnum<{
|
|
28
|
+
correction: "correction";
|
|
29
|
+
preference: "preference";
|
|
30
|
+
decision: "decision";
|
|
31
|
+
learning: "learning";
|
|
32
|
+
fact: "fact";
|
|
33
|
+
}>;
|
|
34
|
+
type MemoryType = z.infer<typeof MemoryTypeSchema>;
|
|
35
|
+
declare const TagsJsonSchema: z.ZodArray<z.ZodString>;
|
|
36
|
+
declare const ProjectSchema: z.ZodObject<{
|
|
37
|
+
id: z.ZodString;
|
|
38
|
+
name: z.ZodString;
|
|
39
|
+
scopeHash: z.ZodString;
|
|
40
|
+
createdAt: z.ZodString;
|
|
41
|
+
updatedAt: z.ZodString;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
type Project = z.infer<typeof ProjectSchema>;
|
|
44
|
+
declare const ReviewReasonSchema: z.ZodEnum<{
|
|
45
|
+
similarity_dedup: "similarity_dedup";
|
|
46
|
+
}>;
|
|
47
|
+
type ReviewReason = z.infer<typeof ReviewReasonSchema>;
|
|
48
|
+
declare const ReviewEventSchema: z.ZodObject<{
|
|
49
|
+
id: z.ZodString;
|
|
50
|
+
memoryId: z.ZodString;
|
|
51
|
+
conflictingMemoryId: z.ZodNullable<z.ZodString>;
|
|
52
|
+
similarity: z.ZodNumber;
|
|
53
|
+
conflictContentSnapshot: z.ZodString;
|
|
54
|
+
reason: z.ZodEnum<{
|
|
55
|
+
similarity_dedup: "similarity_dedup";
|
|
56
|
+
}>;
|
|
57
|
+
createdAt: z.ZodString;
|
|
58
|
+
resolvedAt: z.ZodNullable<z.ZodString>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
type ReviewEvent = z.infer<typeof ReviewEventSchema>;
|
|
61
|
+
declare const ReviewEventRowSchema: z.ZodObject<{
|
|
62
|
+
id: z.ZodString;
|
|
63
|
+
memory_id: z.ZodString;
|
|
64
|
+
conflicting_memory_id: z.ZodNullable<z.ZodString>;
|
|
65
|
+
similarity: z.ZodNumber;
|
|
66
|
+
conflict_content_snapshot: z.ZodString;
|
|
67
|
+
reason: z.ZodEnum<{
|
|
68
|
+
similarity_dedup: "similarity_dedup";
|
|
69
|
+
}>;
|
|
70
|
+
created_at: z.ZodString;
|
|
71
|
+
resolved_at: z.ZodNullable<z.ZodString>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
type ReviewEventRow = z.infer<typeof ReviewEventRowSchema>;
|
|
74
|
+
declare const MemorySchema: z.ZodObject<{
|
|
75
|
+
id: z.ZodString;
|
|
76
|
+
content: z.ZodString;
|
|
77
|
+
type: z.ZodEnum<{
|
|
78
|
+
correction: "correction";
|
|
79
|
+
preference: "preference";
|
|
80
|
+
decision: "decision";
|
|
81
|
+
learning: "learning";
|
|
82
|
+
fact: "fact";
|
|
83
|
+
}>;
|
|
84
|
+
tags: z.ZodArray<z.ZodString>;
|
|
85
|
+
projects: z.ZodArray<z.ZodObject<{
|
|
86
|
+
id: z.ZodString;
|
|
87
|
+
name: z.ZodString;
|
|
88
|
+
scopeHash: z.ZodString;
|
|
89
|
+
createdAt: z.ZodString;
|
|
90
|
+
updatedAt: z.ZodString;
|
|
91
|
+
}, z.core.$strip>>;
|
|
92
|
+
sourceHarness: z.ZodNullable<z.ZodString>;
|
|
93
|
+
accessCount: z.ZodNumber;
|
|
94
|
+
pinned: z.ZodBoolean;
|
|
95
|
+
reviewEvents: z.ZodArray<z.ZodObject<{
|
|
96
|
+
id: z.ZodString;
|
|
97
|
+
memoryId: z.ZodString;
|
|
98
|
+
conflictingMemoryId: z.ZodNullable<z.ZodString>;
|
|
99
|
+
similarity: z.ZodNumber;
|
|
100
|
+
conflictContentSnapshot: z.ZodString;
|
|
101
|
+
reason: z.ZodEnum<{
|
|
102
|
+
similarity_dedup: "similarity_dedup";
|
|
103
|
+
}>;
|
|
104
|
+
createdAt: z.ZodString;
|
|
105
|
+
resolvedAt: z.ZodNullable<z.ZodString>;
|
|
106
|
+
}, z.core.$strip>>;
|
|
107
|
+
createdAt: z.ZodString;
|
|
108
|
+
updatedAt: z.ZodString;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
type Memory = z.infer<typeof MemorySchema>;
|
|
111
|
+
declare const QueryOptionsSchema: z.ZodObject<{
|
|
112
|
+
query: z.ZodString;
|
|
113
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
114
|
+
correction: "correction";
|
|
115
|
+
preference: "preference";
|
|
116
|
+
decision: "decision";
|
|
117
|
+
learning: "learning";
|
|
118
|
+
fact: "fact";
|
|
119
|
+
}>>;
|
|
120
|
+
projectHash: z.ZodOptional<z.ZodString>;
|
|
121
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
122
|
+
includePinned: z.ZodOptional<z.ZodBoolean>;
|
|
123
|
+
}, z.core.$strip>;
|
|
124
|
+
type QueryOptions = z.infer<typeof QueryOptionsSchema>;
|
|
125
|
+
declare const SaveOptionsSchema: z.ZodObject<{
|
|
126
|
+
content: z.ZodString;
|
|
127
|
+
type: z.ZodEnum<{
|
|
128
|
+
correction: "correction";
|
|
129
|
+
preference: "preference";
|
|
130
|
+
decision: "decision";
|
|
131
|
+
learning: "learning";
|
|
132
|
+
fact: "fact";
|
|
133
|
+
}>;
|
|
134
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
135
|
+
projectScope: z.ZodOptional<z.ZodObject<{
|
|
136
|
+
hash: z.ZodString;
|
|
137
|
+
name: z.ZodString;
|
|
138
|
+
}, z.core.$strip>>;
|
|
139
|
+
sourceHarness: z.ZodOptional<z.ZodString>;
|
|
140
|
+
}, z.core.$strip>;
|
|
141
|
+
type SaveOptions = z.infer<typeof SaveOptionsSchema>;
|
|
142
|
+
declare const MemoryPatchSchema: z.ZodObject<{
|
|
143
|
+
content: z.ZodOptional<z.ZodString>;
|
|
144
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
145
|
+
}, z.core.$strip>;
|
|
146
|
+
type MemoryPatch = z.infer<typeof MemoryPatchSchema>;
|
|
147
|
+
declare const SessionContextSchema: z.ZodObject<{
|
|
148
|
+
stats: z.ZodRecord<z.ZodEnum<{
|
|
149
|
+
correction: "correction";
|
|
150
|
+
preference: "preference";
|
|
151
|
+
decision: "decision";
|
|
152
|
+
learning: "learning";
|
|
153
|
+
fact: "fact";
|
|
154
|
+
}>, z.ZodNumber>;
|
|
155
|
+
pinnedGlobal: z.ZodArray<z.ZodObject<{
|
|
156
|
+
id: z.ZodString;
|
|
157
|
+
content: z.ZodString;
|
|
158
|
+
type: z.ZodEnum<{
|
|
159
|
+
correction: "correction";
|
|
160
|
+
preference: "preference";
|
|
161
|
+
decision: "decision";
|
|
162
|
+
learning: "learning";
|
|
163
|
+
fact: "fact";
|
|
164
|
+
}>;
|
|
165
|
+
tags: z.ZodArray<z.ZodString>;
|
|
166
|
+
projects: z.ZodArray<z.ZodObject<{
|
|
167
|
+
id: z.ZodString;
|
|
168
|
+
name: z.ZodString;
|
|
169
|
+
scopeHash: z.ZodString;
|
|
170
|
+
createdAt: z.ZodString;
|
|
171
|
+
updatedAt: z.ZodString;
|
|
172
|
+
}, z.core.$strip>>;
|
|
173
|
+
sourceHarness: z.ZodNullable<z.ZodString>;
|
|
174
|
+
accessCount: z.ZodNumber;
|
|
175
|
+
pinned: z.ZodBoolean;
|
|
176
|
+
reviewEvents: z.ZodArray<z.ZodObject<{
|
|
177
|
+
id: z.ZodString;
|
|
178
|
+
memoryId: z.ZodString;
|
|
179
|
+
conflictingMemoryId: z.ZodNullable<z.ZodString>;
|
|
180
|
+
similarity: z.ZodNumber;
|
|
181
|
+
conflictContentSnapshot: z.ZodString;
|
|
182
|
+
reason: z.ZodEnum<{
|
|
183
|
+
similarity_dedup: "similarity_dedup";
|
|
184
|
+
}>;
|
|
185
|
+
createdAt: z.ZodString;
|
|
186
|
+
resolvedAt: z.ZodNullable<z.ZodString>;
|
|
187
|
+
}, z.core.$strip>>;
|
|
188
|
+
createdAt: z.ZodString;
|
|
189
|
+
updatedAt: z.ZodString;
|
|
190
|
+
}, z.core.$strip>>;
|
|
191
|
+
pinnedProject: z.ZodArray<z.ZodObject<{
|
|
192
|
+
id: z.ZodString;
|
|
193
|
+
content: z.ZodString;
|
|
194
|
+
type: z.ZodEnum<{
|
|
195
|
+
correction: "correction";
|
|
196
|
+
preference: "preference";
|
|
197
|
+
decision: "decision";
|
|
198
|
+
learning: "learning";
|
|
199
|
+
fact: "fact";
|
|
200
|
+
}>;
|
|
201
|
+
tags: z.ZodArray<z.ZodString>;
|
|
202
|
+
projects: z.ZodArray<z.ZodObject<{
|
|
203
|
+
id: z.ZodString;
|
|
204
|
+
name: z.ZodString;
|
|
205
|
+
scopeHash: z.ZodString;
|
|
206
|
+
createdAt: z.ZodString;
|
|
207
|
+
updatedAt: z.ZodString;
|
|
208
|
+
}, z.core.$strip>>;
|
|
209
|
+
sourceHarness: z.ZodNullable<z.ZodString>;
|
|
210
|
+
accessCount: z.ZodNumber;
|
|
211
|
+
pinned: z.ZodBoolean;
|
|
212
|
+
reviewEvents: z.ZodArray<z.ZodObject<{
|
|
213
|
+
id: z.ZodString;
|
|
214
|
+
memoryId: z.ZodString;
|
|
215
|
+
conflictingMemoryId: z.ZodNullable<z.ZodString>;
|
|
216
|
+
similarity: z.ZodNumber;
|
|
217
|
+
conflictContentSnapshot: z.ZodString;
|
|
218
|
+
reason: z.ZodEnum<{
|
|
219
|
+
similarity_dedup: "similarity_dedup";
|
|
220
|
+
}>;
|
|
221
|
+
createdAt: z.ZodString;
|
|
222
|
+
resolvedAt: z.ZodNullable<z.ZodString>;
|
|
223
|
+
}, z.core.$strip>>;
|
|
224
|
+
createdAt: z.ZodString;
|
|
225
|
+
updatedAt: z.ZodString;
|
|
226
|
+
}, z.core.$strip>>;
|
|
227
|
+
}, z.core.$strip>;
|
|
228
|
+
type SessionContext = z.infer<typeof SessionContextSchema>;
|
|
229
|
+
declare const MemoryRowSchema: z.ZodObject<{
|
|
230
|
+
id: z.ZodString;
|
|
231
|
+
content: z.ZodString;
|
|
232
|
+
type: z.ZodString;
|
|
233
|
+
tags: z.ZodString;
|
|
234
|
+
source: z.ZodNullable<z.ZodString>;
|
|
235
|
+
access_count: z.ZodNumber;
|
|
236
|
+
pinned: z.ZodNumber;
|
|
237
|
+
created_at: z.ZodString;
|
|
238
|
+
updated_at: z.ZodString;
|
|
239
|
+
}, z.core.$strip>;
|
|
240
|
+
type MemoryRow = z.infer<typeof MemoryRowSchema>;
|
|
241
|
+
declare const ProjectRowSchema: z.ZodObject<{
|
|
242
|
+
id: z.ZodString;
|
|
243
|
+
name: z.ZodString;
|
|
244
|
+
scope_hash: z.ZodString;
|
|
245
|
+
created_at: z.ZodString;
|
|
246
|
+
updated_at: z.ZodString;
|
|
247
|
+
}, z.core.$strip>;
|
|
248
|
+
type ProjectRow = z.infer<typeof ProjectRowSchema>;
|
|
68
249
|
//#endregion
|
|
69
250
|
//#region src/db/row-types.d.ts
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
content: string;
|
|
73
|
-
type: string;
|
|
74
|
-
tags: string;
|
|
75
|
-
source: string | null;
|
|
76
|
-
access_count: number;
|
|
77
|
-
pinned: number;
|
|
78
|
-
needs_review: number;
|
|
79
|
-
created_at: string;
|
|
80
|
-
updated_at: string;
|
|
81
|
-
}
|
|
82
|
-
declare function rowToMemory(row: MemoryRow, projects: Project[]): Memory;
|
|
251
|
+
declare function rowToMemory(row: MemoryRow, projects: Project[], reviewEvents?: ReviewEvent[]): Memory;
|
|
252
|
+
declare function rowToProject(row: ProjectRow): Project;
|
|
83
253
|
//#endregion
|
|
84
254
|
//#region src/embedding/service.d.ts
|
|
85
255
|
type ProgressCallback = (progress: {
|
|
@@ -114,15 +284,17 @@ declare class MemoryRepository {
|
|
|
114
284
|
#private;
|
|
115
285
|
constructor(db: DatabaseManager, embeddingService: EmbeddingService, projects: ProjectRepository);
|
|
116
286
|
save(options: SaveOptions): Promise<Memory>;
|
|
117
|
-
update(id: string, patch:
|
|
118
|
-
content?: string;
|
|
119
|
-
tags?: string[];
|
|
120
|
-
}): Promise<Memory>;
|
|
287
|
+
update(id: string, patch: MemoryPatch): Promise<Memory>;
|
|
121
288
|
delete(id: string): Promise<void>;
|
|
122
289
|
list(opts?: {
|
|
123
290
|
type?: MemoryType;
|
|
124
291
|
pinned?: boolean;
|
|
125
292
|
}): Memory[];
|
|
293
|
+
listFlagged(): Memory[];
|
|
294
|
+
listReviewEvents(memoryId: string, opts?: {
|
|
295
|
+
unresolvedOnly?: boolean;
|
|
296
|
+
}): ReviewEvent[];
|
|
297
|
+
resolveReviewEvents(memoryId: string): void;
|
|
126
298
|
stats(): {
|
|
127
299
|
byType: Record<MemoryType, number>;
|
|
128
300
|
total: number;
|
|
@@ -170,5 +342,5 @@ declare class SessionContextBuilder {
|
|
|
170
342
|
getSessionContext(projectHash: string): SessionContext;
|
|
171
343
|
}
|
|
172
344
|
//#endregion
|
|
173
|
-
export { DatabaseError, DatabaseManager, EmbeddingService, MEMORY_TYPE_VALUES, MIGRATIONS, MembankError, Memory, MemoryRepository,
|
|
345
|
+
export { DatabaseError, DatabaseManager, EmbeddingService, MEMORY_TYPE_VALUES, MIGRATIONS, MembankError, Memory, MemoryPatch, MemoryPatchSchema, MemoryRepository, MemoryRow, MemoryRowSchema, MemorySchema, MemoryType, MemoryTypeSchema, MigrationMeta, ProgressCallback, Project, ProjectRepository, ProjectRow, ProjectRowSchema, ProjectSchema, QueryEngine, QueryOptions, QueryOptionsSchema, ReviewEvent, ReviewEventRow, ReviewEventRowSchema, ReviewEventSchema, ReviewReason, ReviewReasonSchema, SaveOptions, SaveOptionsSchema, ScopeToProjectsResult, SessionContext, SessionContextBuilder, SessionContextSchema, TagsJsonSchema, listMemoryTypes, resolveProject, resolveScope, rowToMemory, rowToProject, runScopeToProjectsMigration };
|
|
174
346
|
//# sourceMappingURL=index.d.mts.map
|