11import { storeKnowledge } from './handlers/store' ;
22import { searchKnowledge } from './handlers/search' ;
3+ import { closeDatabase } from './database' ;
34import type { StoreKnowledgeInput , SearchKnowledgeInput , StoreKnowledgeResult , SearchKnowledgeResult } from './types' ;
45
56export { storeKnowledge , searchKnowledge } ;
@@ -21,23 +22,31 @@ export interface MemorySearchOptions {
2122}
2223
2324export function memoryStoreCommand ( options : MemoryStoreOptions ) : StoreKnowledgeResult {
24- const input : StoreKnowledgeInput = {
25- title : options . title ,
26- content : options . content ,
27- tags : options . tags ? options . tags . split ( ',' ) . map ( t => t . trim ( ) ) : undefined ,
28- scope : options . scope ,
29- } ;
25+ try {
26+ const input : StoreKnowledgeInput = {
27+ title : options . title ,
28+ content : options . content ,
29+ tags : options . tags ? options . tags . split ( ',' ) . map ( t => t . trim ( ) ) : undefined ,
30+ scope : options . scope ,
31+ } ;
3032
31- return storeKnowledge ( input ) ;
33+ return storeKnowledge ( input ) ;
34+ } finally {
35+ closeDatabase ( ) ;
36+ }
3237}
3338
3439export function memorySearchCommand ( options : MemorySearchOptions ) : SearchKnowledgeResult {
35- const input : SearchKnowledgeInput = {
36- query : options . query ,
37- contextTags : options . tags ? options . tags . split ( ',' ) . map ( t => t . trim ( ) ) : undefined ,
38- scope : options . scope ,
39- limit : options . limit ,
40- } ;
40+ try {
41+ const input : SearchKnowledgeInput = {
42+ query : options . query ,
43+ contextTags : options . tags ? options . tags . split ( ',' ) . map ( t => t . trim ( ) ) : undefined ,
44+ scope : options . scope ,
45+ limit : options . limit ,
46+ } ;
4147
42- return searchKnowledge ( input ) ;
48+ return searchKnowledge ( input ) ;
49+ } finally {
50+ closeDatabase ( ) ;
51+ }
4352}
0 commit comments