@@ -21,8 +21,8 @@ export class MemoryRoutes {
2121 */
2222 app . post ( '/api/memories/:id/extract/run' , api ( async ( req ) => {
2323 const memoryId = requireMemoryId ( req . params . id ) ;
24- const ran = memoryServicePool . forceExtract ( memoryId ) ;
25- return { memoryId, ran } ;
24+ await memoryServicePool . forceExtract ( memoryId ) ;
25+ return { memoryId } ;
2626 } ) ) ;
2727
2828 /**
@@ -31,8 +31,7 @@ export class MemoryRoutes {
3131 */
3232 app . get ( '/api/memories/:id/list' , api ( async ( req ) => {
3333 const memoryId = requireMemoryId ( req . params . id ) ;
34- const service = memoryServicePool . acquire ( memoryId ) ;
35- if ( ! service ) return { memoryId, memories : [ ] } ;
34+ const service = await memoryServicePool . acquire ( memoryId ) ;
3635 try {
3736 const rows = await service . listAll ( ) ;
3837 // body 不返回(避免响应膨胀);admin UI 单击行后再走 read_memory 取全文
@@ -57,24 +56,23 @@ export class MemoryRoutes {
5756 app . get ( '/api/memories/:id/jobs' , api ( async ( req ) => {
5857 const memoryId = requireMemoryId ( req . params . id ) ;
5958 const limit = Math . max ( 1 , Math . min ( Number ( req . query . limit ?? 50 ) || 50 , 200 ) ) ;
60- const jobs = memoryServicePool . listPendingJobs ( memoryId , limit ) ;
59+ const jobs = await memoryServicePool . listPendingJobs ( memoryId , limit ) ;
6160 return { memoryId, jobs } ;
6261 } ) ) ;
6362
6463 /** 手动整理:入队合并重复、删除明显冗余、压缩过长 memory 的后台 job。 */
6564 app . post ( '/api/memories/:id/consolidate/run' , api ( async ( req ) => {
6665 const memoryId = requireMemoryId ( req . params . id ) ;
67- const jobId = memoryServicePool . forceConsolidate ( memoryId ) ;
68- return { memoryId, jobId, queued : jobId != null } ;
66+ const jobId = await memoryServicePool . forceConsolidate ( memoryId ) ;
67+ return { memoryId, jobId } ;
6968 } ) ) ;
7069
7170 /** 单条 memory 全文。 */
7271 app . get ( '/api/memories/:id/entries/:slug' , api ( async ( req ) => {
7372 const memoryId = requireMemoryId ( req . params . id ) ;
7473 const slug = String ( req . params . slug ?? '' ) . trim ( ) ;
7574 if ( ! slug ) throwBad ( 'Missing slug' ) ;
76- const service = memoryServicePool . acquire ( memoryId ) ;
77- if ( ! service ) throwBad ( `MemoryProfile "${ memoryId } " not initialized` ) ;
75+ const service = await memoryServicePool . acquire ( memoryId ) ;
7876 try {
7977 const row = ( await service . listAll ( ) ) . find ( r => r . slug === slug ) ?? null ;
8078 if ( ! row ) throwBad ( `Memory "${ slug } " not found` ) ;
@@ -89,8 +87,7 @@ export class MemoryRoutes {
8987 const memoryId = requireMemoryId ( req . params . id ) ;
9088 const slug = String ( req . params . slug ?? '' ) . trim ( ) ;
9189 if ( ! slug ) throwBad ( 'Missing slug' ) ;
92- const service = memoryServicePool . acquire ( memoryId ) ;
93- if ( ! service ) throwBad ( `MemoryProfile "${ memoryId } " not initialized` ) ;
90+ const service = await memoryServicePool . acquire ( memoryId ) ;
9491 try {
9592 const archive = await service . deleteMemory ( slug ) ;
9693 return { memoryId, slug, archive } ;
@@ -106,8 +103,7 @@ export class MemoryRoutes {
106103 */
107104 app . post ( '/api/memories/:id/reconcile/run' , api ( async ( req ) => {
108105 const memoryId = requireMemoryId ( req . params . id ) ;
109- const service = memoryServicePool . acquire ( memoryId ) ;
110- if ( ! service ) throwBad ( `MemoryProfile "${ memoryId } " not initialized` ) ;
106+ const service = await memoryServicePool . acquire ( memoryId ) ;
111107 try {
112108 const stats = await service . reconcile ( ) ;
113109 return { memoryId, ...stats } ;
0 commit comments