@rlabs-inc/memory 0.5.1 → 0.5.2
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/package.json +1 -1
- package/src/server/index.ts +23 -0
package/package.json
CHANGED
package/src/server/index.ts
CHANGED
|
@@ -64,6 +64,13 @@ interface CheckpointRequest {
|
|
|
64
64
|
project_path?: string
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Track sessions currently being curated to prevent recursive calls.
|
|
69
|
+
* When Gemini CLI spawns hooks, env vars may not propagate, so we
|
|
70
|
+
* need server-side deduplication.
|
|
71
|
+
*/
|
|
72
|
+
const sessionsBeingCurated = new Set<string>()
|
|
73
|
+
|
|
67
74
|
/**
|
|
68
75
|
* Create and start the memory server
|
|
69
76
|
*/
|
|
@@ -210,6 +217,19 @@ export async function createServer(config: ServerConfig = {}) {
|
|
|
210
217
|
if (path === '/memory/checkpoint' && req.method === 'POST') {
|
|
211
218
|
const body = await req.json() as CheckpointRequest
|
|
212
219
|
|
|
220
|
+
// Prevent recursive curation - Gemini CLI doesn't propagate env vars to hooks
|
|
221
|
+
// so MEMORY_CURATOR_ACTIVE check in hooks doesn't work. Dedupe at server level.
|
|
222
|
+
if (sessionsBeingCurated.has(body.claude_session_id)) {
|
|
223
|
+
logger.debug(`Skipping duplicate curation request for session ${body.claude_session_id}`, 'server')
|
|
224
|
+
return Response.json({
|
|
225
|
+
success: true,
|
|
226
|
+
message: 'Curation already in progress for this session',
|
|
227
|
+
}, { headers: corsHeaders })
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Mark session as being curated BEFORE async work starts
|
|
231
|
+
sessionsBeingCurated.add(body.claude_session_id)
|
|
232
|
+
|
|
213
233
|
logger.logCurationStart(body.claude_session_id, body.trigger)
|
|
214
234
|
|
|
215
235
|
// Fire and forget - don't block the response
|
|
@@ -339,6 +359,9 @@ export async function createServer(config: ServerConfig = {}) {
|
|
|
339
359
|
}
|
|
340
360
|
} catch (error) {
|
|
341
361
|
logger.error(`Curation failed: ${error}`)
|
|
362
|
+
} finally {
|
|
363
|
+
// Release the session lock - allows future curation requests for this session
|
|
364
|
+
sessionsBeingCurated.delete(body.claude_session_id)
|
|
342
365
|
}
|
|
343
366
|
})
|
|
344
367
|
|