Add User Model Service and Temporal Recall for MeMind V0.1.
Introduce UMS ingest/snapshot pipeline, Context Planner with multi-source recall, runtime context injection, canonical user mapping, and session snapshot loading on auth/me. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+33
-1
@@ -5,6 +5,7 @@ import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { createAuthManager } from './auth.mjs';
|
||||
import { createDbPool, isDatabaseConfigured } from './db.mjs';
|
||||
import { createUmsPool, isUmsDatabaseConfigured } from './user-model-service/db.mjs';
|
||||
import { attachMindSpaceImageGenerationRoutes } from './mindspace-image-generation-routes.mjs';
|
||||
import { sanitizeSessionConversationPublicHtmlLinks } from './tkmind-proxy.mjs';
|
||||
import { createWikiAuth } from './wiki-auth.mjs';
|
||||
@@ -70,6 +71,8 @@ import { createPortalAuthSessionHelpers } from './server/portal-auth-session-hel
|
||||
import { createPortalSessionCoordinator } from './server/portal-session-coordinator.mjs';
|
||||
import { attachPortalSessionRoutes } from './server/portal-session-routes.mjs';
|
||||
import { attachPortalUserMemoryRoutes } from './server/portal-user-memory-routes.mjs';
|
||||
import { attachPortalUserModelRoutes } from './server/portal-user-model-routes.mjs';
|
||||
import { attachPortalTemporalRecallRoutes } from './server/portal-temporal-recall-routes.mjs';
|
||||
import { attachPortalGoalRunRoutes } from './server/portal-goal-run-routes.mjs';
|
||||
import { assertMindSpaceRoute, mindspaceFlags } from './mindspace-flags.mjs';
|
||||
import { loadMindSpaceConfigCached } from './mindspace-config.mjs';
|
||||
@@ -330,12 +333,24 @@ let scheduledTaskWorker = null;
|
||||
let llmProviderService = null;
|
||||
let wordFilterService = null;
|
||||
let authPool = null;
|
||||
let umsPool = null;
|
||||
let pageDataService = null;
|
||||
let pageDataPublicService = null;
|
||||
let mindSpaceAnalyticsConfig = resolveMindSpaceAnalyticsConfig();
|
||||
|
||||
async function bootstrapUserAuth() {
|
||||
try {
|
||||
if (isUmsDatabaseConfigured()) {
|
||||
try {
|
||||
umsPool = createUmsPool();
|
||||
console.log('[UMS] user model pool ready');
|
||||
} catch (err) {
|
||||
console.warn(
|
||||
'[UMS] pool init failed:',
|
||||
err instanceof Error ? err.message : err,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!isDatabaseConfigured()) return false;
|
||||
const pool = createDbPool();
|
||||
const domainServices =
|
||||
@@ -470,6 +485,7 @@ async function bootstrapUserAuth() {
|
||||
llmProviderService,
|
||||
userAuth,
|
||||
sessionAccess,
|
||||
getUmsPool: () => umsPool,
|
||||
logger: console,
|
||||
});
|
||||
memoryV2ConfigService =
|
||||
@@ -528,6 +544,7 @@ async function bootstrapUserAuth() {
|
||||
syncUserGeneratedPages,
|
||||
isSessionPageDeliveryActive,
|
||||
experienceService,
|
||||
getUmsPool: () => umsPool,
|
||||
});
|
||||
tkmindProxy = gatewayServices.tkmindProxy;
|
||||
toolGateway = gatewayServices.toolGateway;
|
||||
@@ -678,6 +695,7 @@ attachPortalAccountFeedbackRoutes({
|
||||
getLegacyAuth: () => legacyAuth,
|
||||
getSubscriptionService: () => subscriptionService,
|
||||
getFeedbackService: () => feedbackService,
|
||||
getUmsPool: () => umsPool,
|
||||
userToken,
|
||||
legacySessionToken,
|
||||
clearUserLoginCookies,
|
||||
@@ -753,6 +771,10 @@ api.use(createPortalApiAuthMiddleware({
|
||||
isLegacyPageDataApiPath,
|
||||
isProductAnalyticsPublicPath: (requestPath, method) =>
|
||||
method === 'GET' && requestPath === '/analytics/context',
|
||||
isUmsIngestPublicPath: (requestPath, method) =>
|
||||
method === 'POST' && requestPath === '/v1/user-model/ingest',
|
||||
isTemporalRecallInfoPublicPath: (requestPath, method) =>
|
||||
method === 'GET' && requestPath === '/v1/temporal-recall/info',
|
||||
accessPolicyMode: portalAccessPolicyMode,
|
||||
accessEnforcementConfig: portalAccessEnforcementConfig,
|
||||
accessShadowReporter: portalAccessShadowReporter,
|
||||
@@ -859,7 +881,7 @@ async function resolveUserMemoryItems(userId, { sessionId = null, limit = 200 }
|
||||
attachPortalUserMemoryRoutes(api, {
|
||||
getMemoryV2: () => memoryV2,
|
||||
getTkmindProxy: () => tkmindProxy,
|
||||
getPool: () => pool,
|
||||
getPool: () => authPool,
|
||||
ensureUserMemoryCapability,
|
||||
ownsAgentSession,
|
||||
loadUserVisibleConversation,
|
||||
@@ -867,6 +889,16 @@ attachPortalUserMemoryRoutes(api, {
|
||||
resolveUserMemoryItems,
|
||||
});
|
||||
|
||||
attachPortalUserModelRoutes(api, {
|
||||
getUmsPool: () => umsPool,
|
||||
getUserAuth: () => userAuth,
|
||||
});
|
||||
|
||||
attachPortalTemporalRecallRoutes(api, {
|
||||
getPool: () => authPool,
|
||||
getUserAuth: () => userAuth,
|
||||
});
|
||||
|
||||
attachPortalGoalRunRoutes(api, {
|
||||
getGoalRunService: () => goalRunService,
|
||||
getAgentRunGateway: () => agentRunGateway,
|
||||
|
||||
Reference in New Issue
Block a user