7bf16500a1
Expose /health and /api/health/observations behind MEMIND_HEALTH_ENABLED, redirect ordinary chat health intents without persisting, and run a dedicated WeChat menu flow with confirm-before-write semantics. Co-authored-by: Cursor <cursoragent@cursor.com>
29 lines
701 B
JavaScript
29 lines
701 B
JavaScript
const IDLE_TTL_MS = 30 * 60 * 1000;
|
|
|
|
export function createHealthChannelSessionStore({ ttlMs = IDLE_TTL_MS } = {}) {
|
|
const sessions = new Map();
|
|
|
|
return {
|
|
ttlMs,
|
|
get(userId) {
|
|
const key = String(userId);
|
|
const current = sessions.get(key);
|
|
if (!current) return null;
|
|
if (Date.now() - current.updatedAt > ttlMs) {
|
|
sessions.delete(key);
|
|
return { expired: true, session: current };
|
|
}
|
|
return { expired: false, session: current };
|
|
},
|
|
set(userId, session) {
|
|
sessions.set(String(userId), {
|
|
...session,
|
|
updatedAt: Date.now(),
|
|
});
|
|
},
|
|
clear(userId) {
|
|
sessions.delete(String(userId));
|
|
},
|
|
};
|
|
}
|