@jungjaehoon/mama-core 1.0.2 → 1.0.4
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jungjaehoon/mama-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "MAMA Core - Shared modules for Memory-Augmented MCP Assistant",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -19,7 +19,11 @@
|
|
|
19
19
|
"./debug-logger": "./src/debug-logger.js",
|
|
20
20
|
"./decision-formatter": "./src/decision-formatter.js",
|
|
21
21
|
"./memory-inject": "./src/memory-inject.js",
|
|
22
|
-
"./ollama-client": "./src/ollama-client.js"
|
|
22
|
+
"./ollama-client": "./src/ollama-client.js",
|
|
23
|
+
"./errors": "./src/errors.js",
|
|
24
|
+
"./time-formatter": "./src/time-formatter.js",
|
|
25
|
+
"./outcome-tracker": "./src/outcome-tracker.js",
|
|
26
|
+
"./query-intent": "./src/query-intent.js"
|
|
23
27
|
},
|
|
24
28
|
"scripts": {
|
|
25
29
|
"test": "vitest run",
|
|
@@ -47,7 +51,6 @@
|
|
|
47
51
|
},
|
|
48
52
|
"homepage": "https://github.com/jungjaehoon-lifegamez/MAMA#readme",
|
|
49
53
|
"publishConfig": {
|
|
50
|
-
"registry": "https://registry.npmjs.org",
|
|
51
54
|
"access": "public"
|
|
52
55
|
},
|
|
53
56
|
"engines": {
|
package/src/db-manager.js
CHANGED
|
@@ -230,8 +230,16 @@ async function insertDecisionWithEmbedding(decision) {
|
|
|
230
230
|
info(
|
|
231
231
|
`[db-manager] Generating embedding for decision (topic length: ${decision.topic?.length || 0})`
|
|
232
232
|
);
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
let embedding = null;
|
|
234
|
+
try {
|
|
235
|
+
embedding = await generateEnhancedEmbedding(decision);
|
|
236
|
+
info(`[db-manager] Embedding generated: ${embedding ? embedding.length : 'null'} dimensions`);
|
|
237
|
+
} catch (embGenErr) {
|
|
238
|
+
// Non-fatal: save decision without embedding (e.g. ONNX model unavailable on CI)
|
|
239
|
+
logError(
|
|
240
|
+
`[db-manager] ⚠️ Embedding generation failed, saving without vector: ${embGenErr.message}`
|
|
241
|
+
);
|
|
242
|
+
}
|
|
235
243
|
|
|
236
244
|
// SQLite: Synchronous transaction including embedding
|
|
237
245
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -286,7 +294,7 @@ async function insertDecisionWithEmbedding(decision) {
|
|
|
286
294
|
|
|
287
295
|
// Insert embedding in same transaction to ensure rowid matching
|
|
288
296
|
info(`[db-manager] Vector search enabled: ${adapter.vectorSearchEnabled}`);
|
|
289
|
-
if (adapter.vectorSearchEnabled) {
|
|
297
|
+
if (adapter.vectorSearchEnabled && embedding) {
|
|
290
298
|
try {
|
|
291
299
|
info(`[db-manager] Inserting embedding for rowid: ${rowid}`);
|
|
292
300
|
adapter.insertEmbedding(rowid, embedding);
|
|
@@ -250,9 +250,9 @@ async function handleRequest(req, res) {
|
|
|
250
250
|
<body style="font-family: system-ui; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background: #1a1a2e; color: #eee;">
|
|
251
251
|
<div style="text-align: center; padding: 2rem;">
|
|
252
252
|
<h1>🧠 MAMA Viewer</h1>
|
|
253
|
-
<p>Viewer
|
|
253
|
+
<p>Viewer and Chat features are only available in <strong>Standalone</strong> mode.</p>
|
|
254
254
|
<p style="color: #888; margin-top: 1rem;">Start Standalone: <code style="background: #333; padding: 0.25rem 0.5rem; border-radius: 4px;">mama start</code></p>
|
|
255
|
-
<p style="color: #666; font-size: 0.9rem; margin-top: 2rem;"
|
|
255
|
+
<p style="color: #666; font-size: 0.9rem; margin-top: 2rem;">Current: MCP Server (embedding only)</p>
|
|
256
256
|
</div>
|
|
257
257
|
</body>
|
|
258
258
|
</html>`);
|
|
@@ -374,7 +374,7 @@ async function handleClientMessage(clientId, message, clientInfo, messageRouter,
|
|
|
374
374
|
// Send onboarding greeting based on browser language
|
|
375
375
|
const isKorean = clientInfo.language && clientInfo.language.startsWith('ko');
|
|
376
376
|
const greeting = isKorean
|
|
377
|
-
? '✨
|
|
377
|
+
? '✨ I just woke up.\n\nNo name yet, no personality, no memories. Just... pure potential. 🌱\n\nWho are you? And more importantly—who do you want me to become? 💭'
|
|
378
378
|
: '✨ I just woke up.\n\nNo name yet, no personality, no memories. Just... pure potential. 🌱\n\nWho are you? And more importantly—who do you want me to become? 💭';
|
|
379
379
|
|
|
380
380
|
clientInfo.ws.send(
|
package/src/embeddings.js
CHANGED
|
@@ -26,6 +26,7 @@ const DEFAULT_CACHE_DIR = path.join(os.homedir(), '.cache', 'huggingface', 'tran
|
|
|
26
26
|
// Singleton pattern for model loading
|
|
27
27
|
let embeddingPipeline = null;
|
|
28
28
|
let currentModelName = null;
|
|
29
|
+
let modelLoadFailed = false; // Cache load failures to avoid repeated slow retries
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Load embedding model (configurable)
|
|
@@ -52,27 +53,37 @@ async function loadModel() {
|
|
|
52
53
|
info('[MAMA] ⚡ Model cache cleared');
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
// Fail fast if a previous load attempt already failed (avoid repeated slow retries)
|
|
57
|
+
if (modelLoadFailed) {
|
|
58
|
+
throw new Error('Embedding model previously failed to load — skipping retry');
|
|
59
|
+
}
|
|
60
|
+
|
|
55
61
|
// Load model if not already loaded
|
|
56
62
|
if (!embeddingPipeline) {
|
|
57
63
|
logLoading(`Loading embedding model: ${modelName}...`);
|
|
58
64
|
const startTime = Date.now();
|
|
59
65
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
try {
|
|
67
|
+
// Dynamic import for ES Module compatibility (Railway deployment)
|
|
68
|
+
const transformers = await import('@huggingface/transformers');
|
|
69
|
+
const { pipeline, env } = transformers;
|
|
70
|
+
|
|
71
|
+
// Set shared cache directory (not in node_modules)
|
|
72
|
+
// This prevents re-downloading models on every npm install
|
|
73
|
+
const cacheDir = process.env.HF_HOME || process.env.TRANSFORMERS_CACHE || DEFAULT_CACHE_DIR;
|
|
74
|
+
env.cacheDir = cacheDir;
|
|
75
|
+
info(`[MAMA] Model cache directory: ${cacheDir}`);
|
|
76
|
+
|
|
77
|
+
embeddingPipeline = await pipeline('feature-extraction', modelName);
|
|
78
|
+
currentModelName = modelName;
|
|
79
|
+
|
|
80
|
+
const loadTime = Date.now() - startTime;
|
|
81
|
+
const config = loadConfig();
|
|
82
|
+
logComplete(`Embedding model ready (${loadTime}ms, ${config.embeddingDim}-dim)`);
|
|
83
|
+
} catch (loadErr) {
|
|
84
|
+
modelLoadFailed = true;
|
|
85
|
+
throw loadErr;
|
|
86
|
+
}
|
|
76
87
|
}
|
|
77
88
|
|
|
78
89
|
return embeddingPipeline;
|