@jungjaehoon/mama-core 1.1.1 → 1.1.3
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/dist/config-loader.d.ts +61 -0
- package/dist/config-loader.js +187 -0
- package/dist/db-adapter/base-adapter.d.ts +76 -0
- package/dist/db-adapter/base-adapter.js +11 -0
- package/dist/db-adapter/index.d.ts +24 -0
- package/dist/db-adapter/index.js +29 -0
- package/dist/db-adapter/sqlite-adapter.d.ts +73 -0
- package/dist/db-adapter/sqlite-adapter.js +330 -0
- package/dist/db-adapter/statement.d.ts +119 -0
- package/dist/db-adapter/statement.js +113 -0
- package/dist/db-manager.d.ts +252 -0
- package/dist/db-manager.js +622 -0
- package/dist/debug-logger.d.ts +32 -0
- package/dist/debug-logger.js +83 -0
- package/dist/decision-formatter.d.ts +172 -0
- package/dist/decision-formatter.js +894 -0
- package/dist/decision-tracker.d.ts +218 -0
- package/dist/decision-tracker.js +531 -0
- package/dist/embedding-cache.d.ts +83 -0
- package/dist/embedding-cache.js +182 -0
- package/dist/embedding-client.d.ts +43 -0
- package/dist/embedding-client.js +132 -0
- package/dist/embedding-server/index.d.ts +65 -0
- package/dist/embedding-server/index.js +397 -0
- package/dist/embedding-server/mobile/auth.d.ts +53 -0
- package/dist/embedding-server/mobile/auth.js +140 -0
- package/dist/embedding-server/mobile/daemon.d.ts +128 -0
- package/dist/embedding-server/mobile/daemon.js +303 -0
- package/dist/embedding-server/mobile/output-parser.d.ts +115 -0
- package/dist/embedding-server/mobile/output-parser.js +241 -0
- package/dist/embedding-server/mobile/session-api.d.ts +57 -0
- package/dist/embedding-server/mobile/session-api.js +261 -0
- package/dist/embedding-server/mobile/session-manager.d.ts +135 -0
- package/dist/embedding-server/mobile/session-manager.js +333 -0
- package/dist/embedding-server/mobile/websocket-handler.d.ts +127 -0
- package/dist/embedding-server/mobile/websocket-handler.js +435 -0
- package/dist/embeddings.d.ts +75 -0
- package/dist/embeddings.js +262 -0
- package/dist/errors.d.ts +131 -0
- package/dist/errors.js +225 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +193 -0
- package/dist/mama-api.d.ts +954 -0
- package/dist/mama-api.js +2210 -0
- package/dist/memory-inject.d.ts +24 -0
- package/dist/memory-inject.js +116 -0
- package/dist/memory-store.d.ts +103 -0
- package/dist/memory-store.js +129 -0
- package/dist/notification-manager.d.ts +7 -0
- package/dist/notification-manager.js +12 -0
- package/dist/ollama-client.d.ts +51 -0
- package/dist/ollama-client.js +308 -0
- package/dist/outcome-tracker.d.ts +165 -0
- package/dist/outcome-tracker.js +315 -0
- package/dist/progress-indicator.d.ts +48 -0
- package/dist/progress-indicator.js +82 -0
- package/dist/query-intent.d.ts +27 -0
- package/dist/query-intent.js +144 -0
- package/dist/relevance-scorer.d.ts +124 -0
- package/dist/relevance-scorer.js +243 -0
- package/dist/test-utils.d.ts +66 -0
- package/dist/test-utils.js +166 -0
- package/dist/tier-validator.d.ts +55 -0
- package/dist/tier-validator.js +216 -0
- package/dist/time-formatter.d.ts +25 -0
- package/dist/time-formatter.js +93 -0
- package/package.json +3 -2
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MAMA (Memory-Augmented MCP Architecture) - Memory Injection Hook
|
|
3
|
+
*
|
|
4
|
+
* UserPromptSubmit hook that injects decision history into Claude's context
|
|
5
|
+
* Tasks: 1.1-1.9 (Hook setup, timeout handling, context injection)
|
|
6
|
+
* AC #1: Query intent → Graph query → Format → Inject (5s timeout for LLM latency)
|
|
7
|
+
* AC #2: No history → null (graceful fallback)
|
|
8
|
+
* AC #3: Timeout → graceful fallback
|
|
9
|
+
*
|
|
10
|
+
* @module memory-inject
|
|
11
|
+
* @version 1.0
|
|
12
|
+
* @date 2025-11-14
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* UserPromptSubmit Hook Handler
|
|
16
|
+
*
|
|
17
|
+
* Task 1.1-1.9: Main entry point for memory injection
|
|
18
|
+
* AC #1, #2, #3: Intent analysis → Query → Format → Inject
|
|
19
|
+
*
|
|
20
|
+
* @param userMessage - User's message from prompt
|
|
21
|
+
* @returns Injected context or null
|
|
22
|
+
*/
|
|
23
|
+
export declare function injectDecisionContext(userMessage: string): Promise<string | null>;
|
|
24
|
+
//# sourceMappingURL=memory-inject.d.ts.map
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MAMA (Memory-Augmented MCP Architecture) - Memory Injection Hook
|
|
4
|
+
*
|
|
5
|
+
* UserPromptSubmit hook that injects decision history into Claude's context
|
|
6
|
+
* Tasks: 1.1-1.9 (Hook setup, timeout handling, context injection)
|
|
7
|
+
* AC #1: Query intent → Graph query → Format → Inject (5s timeout for LLM latency)
|
|
8
|
+
* AC #2: No history → null (graceful fallback)
|
|
9
|
+
* AC #3: Timeout → graceful fallback
|
|
10
|
+
*
|
|
11
|
+
* @module memory-inject
|
|
12
|
+
* @version 1.0
|
|
13
|
+
* @date 2025-11-14
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.injectDecisionContext = injectDecisionContext;
|
|
17
|
+
// Error handling policy:
|
|
18
|
+
// - Timeout errors: thrown (caller handles retry/fallback)
|
|
19
|
+
// - Vector search unavailable: returns empty array (recoverable, not critical)
|
|
20
|
+
const debug_logger_js_1 = require("./debug-logger.js");
|
|
21
|
+
const memory_store_js_1 = require("./memory-store.js");
|
|
22
|
+
const decision_formatter_js_1 = require("./decision-formatter.js");
|
|
23
|
+
// Configuration
|
|
24
|
+
const TIMEOUT_MS = 5000; // LLM-based intent detection, user accepts longer thinking
|
|
25
|
+
const TOKEN_BUDGET = 500; // AC #1: Max 500 tokens per injection
|
|
26
|
+
/**
|
|
27
|
+
* UserPromptSubmit Hook Handler
|
|
28
|
+
*
|
|
29
|
+
* Task 1.1-1.9: Main entry point for memory injection
|
|
30
|
+
* AC #1, #2, #3: Intent analysis → Query → Format → Inject
|
|
31
|
+
*
|
|
32
|
+
* @param userMessage - User's message from prompt
|
|
33
|
+
* @returns Injected context or null
|
|
34
|
+
*/
|
|
35
|
+
async function injectDecisionContext(userMessage) {
|
|
36
|
+
const startTime = Date.now();
|
|
37
|
+
let timeoutId = null;
|
|
38
|
+
try {
|
|
39
|
+
// Task 1.3: Implement timeout wrapper (Promise.race with timeout)
|
|
40
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
41
|
+
timeoutId = setTimeout(() => {
|
|
42
|
+
reject(new Error(`Memory injection timeout (${TIMEOUT_MS}ms)`));
|
|
43
|
+
}, TIMEOUT_MS);
|
|
44
|
+
});
|
|
45
|
+
const context = await Promise.race([
|
|
46
|
+
performMemoryInjection(userMessage, startTime),
|
|
47
|
+
timeoutPromise,
|
|
48
|
+
]);
|
|
49
|
+
// Clear timeout on success to prevent timer leak
|
|
50
|
+
if (timeoutId) {
|
|
51
|
+
clearTimeout(timeoutId);
|
|
52
|
+
}
|
|
53
|
+
return context;
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
// Clear timeout on error to prevent timer leak
|
|
57
|
+
if (timeoutId) {
|
|
58
|
+
clearTimeout(timeoutId);
|
|
59
|
+
}
|
|
60
|
+
// CLAUDE.md Rule #1: NO FALLBACK
|
|
61
|
+
// Errors must be thrown for debugging (including timeout)
|
|
62
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
63
|
+
(0, debug_logger_js_1.error)(`[MAMA] Memory injection FAILED: ${message}`);
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Perform memory injection with all steps
|
|
69
|
+
*
|
|
70
|
+
* Simplified: Direct vector search without LLM intent analysis
|
|
71
|
+
* Faster, more reliable, works with all query types
|
|
72
|
+
*
|
|
73
|
+
* @param userMessage - User's message
|
|
74
|
+
* @param startTime - Start timestamp for latency tracking
|
|
75
|
+
* @returns Formatted context or null
|
|
76
|
+
*/
|
|
77
|
+
async function performMemoryInjection(userMessage, startTime) {
|
|
78
|
+
// 1. Generate query embedding
|
|
79
|
+
const { generateEmbedding } = await import('./embeddings.js');
|
|
80
|
+
const queryEmbedding = await generateEmbedding(userMessage);
|
|
81
|
+
const embeddingLatency = Date.now() - startTime;
|
|
82
|
+
(0, debug_logger_js_1.info)(`[MAMA] Embedding generation: ${embeddingLatency}ms`);
|
|
83
|
+
// 2. Adaptive threshold (shorter queries need higher confidence)
|
|
84
|
+
const wordCount = userMessage.split(/\s+/).length;
|
|
85
|
+
const adaptiveThreshold = wordCount < 3 ? 0.7 : 0.6;
|
|
86
|
+
// 3. Vector search (returns [] on error for graceful degradation)
|
|
87
|
+
let results;
|
|
88
|
+
try {
|
|
89
|
+
results = (await (0, memory_store_js_1.vectorSearch)(queryEmbedding, 10, 0.5)); // Get more candidates
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
// Vector search unavailability should not block the main conversation flow
|
|
93
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
94
|
+
(0, debug_logger_js_1.error)(`[MAMA] Vector search failed: ${message}`);
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
// 4. Filter by adaptive threshold
|
|
98
|
+
results = results.filter((r) => r.similarity >= adaptiveThreshold);
|
|
99
|
+
const searchLatency = Date.now() - startTime;
|
|
100
|
+
(0, debug_logger_js_1.info)(`[MAMA] Vector search: ${searchLatency - embeddingLatency}ms (${results.length} results, threshold: ${adaptiveThreshold})`);
|
|
101
|
+
// 5. Check if we have any decisions
|
|
102
|
+
if (results.length === 0) {
|
|
103
|
+
// Redact user content for privacy - only log length, not content
|
|
104
|
+
(0, debug_logger_js_1.info)(`[MAMA] No relevant decisions found (query length: ${userMessage.length} chars)`);
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
// 6. Format context summary
|
|
108
|
+
const formattedContext = (0, decision_formatter_js_1.formatContext)(results, {
|
|
109
|
+
maxTokens: TOKEN_BUDGET,
|
|
110
|
+
});
|
|
111
|
+
const formatLatency = Date.now() - startTime;
|
|
112
|
+
(0, debug_logger_js_1.info)(`[MAMA] Format context: ${formatLatency - searchLatency}ms (total: ${formatLatency}ms)`);
|
|
113
|
+
// 7. Return formatted context (Claude Code will inject it)
|
|
114
|
+
return formattedContext;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=memory-inject.js.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MAMA Memory Store - Compatibility Wrapper
|
|
3
|
+
*
|
|
4
|
+
* This file now serves as a compatibility layer that re-exports db-manager functions.
|
|
5
|
+
* The actual database logic has been moved to db-manager.js which supports both
|
|
6
|
+
* SQLite (local development) and PostgreSQL (Railway production).
|
|
7
|
+
*
|
|
8
|
+
* Migration Note:
|
|
9
|
+
* - Old: memory-store.js directly used better-sqlite3 + sqlite-vss
|
|
10
|
+
* - New: memory-store.js → db-manager.js → db-adapter (SQLite or PostgreSQL)
|
|
11
|
+
*
|
|
12
|
+
* All MAMA modules can continue to require('memory-store') without changes.
|
|
13
|
+
*
|
|
14
|
+
* @module memory-store
|
|
15
|
+
* @version 2.0
|
|
16
|
+
* @date 2025-11-17
|
|
17
|
+
*/
|
|
18
|
+
import * as dbManager from './db-manager.js';
|
|
19
|
+
import type { PreparedStatement, VectorSearchResult } from './db-manager.js';
|
|
20
|
+
export type { PreparedStatement };
|
|
21
|
+
export interface DatabaseAdapter {
|
|
22
|
+
prepare: (sql: string) => PreparedStatement;
|
|
23
|
+
vectorSearchEnabled?: boolean;
|
|
24
|
+
insertEmbedding?: (rowid: number, embedding: Float32Array | number[]) => void;
|
|
25
|
+
vectorSearch?: (embedding: Float32Array | number[], limit: number) => Promise<VectorSearchResult[] | null>;
|
|
26
|
+
transaction?: <T>(fn: () => T) => T;
|
|
27
|
+
}
|
|
28
|
+
export interface DecisionForStorage {
|
|
29
|
+
id: string;
|
|
30
|
+
topic: string;
|
|
31
|
+
decision: string;
|
|
32
|
+
reasoning?: string | null;
|
|
33
|
+
outcome?: string | null;
|
|
34
|
+
failure_reason?: string | null;
|
|
35
|
+
limitation?: string | null;
|
|
36
|
+
user_involvement?: string | null;
|
|
37
|
+
session_id?: string | null;
|
|
38
|
+
supersedes?: string | null;
|
|
39
|
+
superseded_by?: string | null;
|
|
40
|
+
refined_from?: string[] | null;
|
|
41
|
+
confidence?: number;
|
|
42
|
+
created_at?: number;
|
|
43
|
+
updated_at?: number;
|
|
44
|
+
needs_validation?: number;
|
|
45
|
+
validation_attempts?: number;
|
|
46
|
+
last_validated_at?: number | null;
|
|
47
|
+
usage_count?: number;
|
|
48
|
+
trust_context?: string | null;
|
|
49
|
+
usage_success?: number;
|
|
50
|
+
usage_failure?: number;
|
|
51
|
+
time_saved?: number;
|
|
52
|
+
evidence?: string | null;
|
|
53
|
+
alternatives?: string | null;
|
|
54
|
+
risks?: string | null;
|
|
55
|
+
}
|
|
56
|
+
export interface OutcomeData {
|
|
57
|
+
outcome?: string | null;
|
|
58
|
+
failure_reason?: string | null;
|
|
59
|
+
limitation?: string | null;
|
|
60
|
+
duration_days?: number | null;
|
|
61
|
+
confidence?: number | null;
|
|
62
|
+
}
|
|
63
|
+
export interface VectorSearchParams {
|
|
64
|
+
query: string;
|
|
65
|
+
limit?: number;
|
|
66
|
+
threshold?: number;
|
|
67
|
+
timeWindow?: number;
|
|
68
|
+
}
|
|
69
|
+
export declare const initDB: typeof dbManager.initDB;
|
|
70
|
+
export declare const getDB: typeof dbManager.getDB;
|
|
71
|
+
export declare const getAdapter: typeof dbManager.getAdapter;
|
|
72
|
+
export declare const closeDB: typeof dbManager.closeDB;
|
|
73
|
+
export declare const insertEmbedding: typeof dbManager.insertEmbedding;
|
|
74
|
+
export declare const vectorSearch: typeof dbManager.vectorSearch;
|
|
75
|
+
export declare const queryVectorSearch: typeof dbManager.queryVectorSearch;
|
|
76
|
+
export declare const insertDecisionWithEmbedding: typeof dbManager.insertDecisionWithEmbedding;
|
|
77
|
+
export declare const queryDecisionGraph: typeof dbManager.queryDecisionGraph;
|
|
78
|
+
export declare const querySemanticEdges: typeof dbManager.querySemanticEdges;
|
|
79
|
+
export declare const updateDecisionOutcome: typeof dbManager.updateDecisionOutcome;
|
|
80
|
+
export declare const getPreparedStmt: typeof dbManager.getPreparedStmt;
|
|
81
|
+
export declare const getDbPath: typeof dbManager.getDbPath;
|
|
82
|
+
export declare const traverseDecisionChain: typeof dbManager.queryDecisionGraph;
|
|
83
|
+
/**
|
|
84
|
+
* Get decisions for a specific session
|
|
85
|
+
*/
|
|
86
|
+
export declare function getSessionDecisions(sessionId: string): Promise<unknown[]>;
|
|
87
|
+
/**
|
|
88
|
+
* Increment usage success counter
|
|
89
|
+
*/
|
|
90
|
+
export declare function incrementUsageSuccess(decisionId: string, timeSaved?: number): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Increment usage failure counter
|
|
93
|
+
*/
|
|
94
|
+
export declare function incrementUsageFailure(decisionId: string): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Get decision by ID
|
|
97
|
+
*/
|
|
98
|
+
export declare function getDecisionById(decisionId: string): Promise<unknown>;
|
|
99
|
+
export declare const DB_PATH: string;
|
|
100
|
+
export declare const DB_DIR: string;
|
|
101
|
+
export declare const LEGACY_DB_PATH = "~/.spinelift/memories.db";
|
|
102
|
+
export declare const DEFAULT_DB_PATH = "~/.mama/memories.db";
|
|
103
|
+
//# sourceMappingURL=memory-store.d.ts.map
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MAMA Memory Store - Compatibility Wrapper
|
|
4
|
+
*
|
|
5
|
+
* This file now serves as a compatibility layer that re-exports db-manager functions.
|
|
6
|
+
* The actual database logic has been moved to db-manager.js which supports both
|
|
7
|
+
* SQLite (local development) and PostgreSQL (Railway production).
|
|
8
|
+
*
|
|
9
|
+
* Migration Note:
|
|
10
|
+
* - Old: memory-store.js directly used better-sqlite3 + sqlite-vss
|
|
11
|
+
* - New: memory-store.js → db-manager.js → db-adapter (SQLite or PostgreSQL)
|
|
12
|
+
*
|
|
13
|
+
* All MAMA modules can continue to require('memory-store') without changes.
|
|
14
|
+
*
|
|
15
|
+
* @module memory-store
|
|
16
|
+
* @version 2.0
|
|
17
|
+
* @date 2025-11-17
|
|
18
|
+
*/
|
|
19
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
22
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
23
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(o, k2, desc);
|
|
26
|
+
}) : (function(o, m, k, k2) {
|
|
27
|
+
if (k2 === undefined) k2 = k;
|
|
28
|
+
o[k2] = m[k];
|
|
29
|
+
}));
|
|
30
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
31
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
32
|
+
}) : function(o, v) {
|
|
33
|
+
o["default"] = v;
|
|
34
|
+
});
|
|
35
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
36
|
+
var ownKeys = function(o) {
|
|
37
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
38
|
+
var ar = [];
|
|
39
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
40
|
+
return ar;
|
|
41
|
+
};
|
|
42
|
+
return ownKeys(o);
|
|
43
|
+
};
|
|
44
|
+
return function (mod) {
|
|
45
|
+
if (mod && mod.__esModule) return mod;
|
|
46
|
+
var result = {};
|
|
47
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
48
|
+
__setModuleDefault(result, mod);
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
})();
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.DEFAULT_DB_PATH = exports.LEGACY_DB_PATH = exports.DB_DIR = exports.DB_PATH = exports.traverseDecisionChain = exports.getDbPath = exports.getPreparedStmt = exports.updateDecisionOutcome = exports.querySemanticEdges = exports.queryDecisionGraph = exports.insertDecisionWithEmbedding = exports.queryVectorSearch = exports.vectorSearch = exports.insertEmbedding = exports.closeDB = exports.getAdapter = exports.getDB = exports.initDB = void 0;
|
|
54
|
+
exports.getSessionDecisions = getSessionDecisions;
|
|
55
|
+
exports.incrementUsageSuccess = incrementUsageSuccess;
|
|
56
|
+
exports.incrementUsageFailure = incrementUsageFailure;
|
|
57
|
+
exports.getDecisionById = getDecisionById;
|
|
58
|
+
const dbManager = __importStar(require("./db-manager.js"));
|
|
59
|
+
// Re-export all db-manager functions for backward compatibility
|
|
60
|
+
// These maintain the same interface as the original memory-store.js
|
|
61
|
+
exports.initDB = dbManager.initDB;
|
|
62
|
+
exports.getDB = dbManager.getDB;
|
|
63
|
+
exports.getAdapter = dbManager.getAdapter;
|
|
64
|
+
exports.closeDB = dbManager.closeDB;
|
|
65
|
+
exports.insertEmbedding = dbManager.insertEmbedding;
|
|
66
|
+
exports.vectorSearch = dbManager.vectorSearch;
|
|
67
|
+
exports.queryVectorSearch = dbManager.queryVectorSearch;
|
|
68
|
+
exports.insertDecisionWithEmbedding = dbManager.insertDecisionWithEmbedding;
|
|
69
|
+
exports.queryDecisionGraph = dbManager.queryDecisionGraph;
|
|
70
|
+
exports.querySemanticEdges = dbManager.querySemanticEdges;
|
|
71
|
+
exports.updateDecisionOutcome = dbManager.updateDecisionOutcome;
|
|
72
|
+
exports.getPreparedStmt = dbManager.getPreparedStmt;
|
|
73
|
+
exports.getDbPath = dbManager.getDbPath;
|
|
74
|
+
// Legacy exports (for backward compatibility with old code)
|
|
75
|
+
exports.traverseDecisionChain = dbManager.queryDecisionGraph; // Alias
|
|
76
|
+
/**
|
|
77
|
+
* Get decisions for a specific session
|
|
78
|
+
*/
|
|
79
|
+
async function getSessionDecisions(sessionId) {
|
|
80
|
+
const adapter = dbManager.getAdapter();
|
|
81
|
+
const stmt = adapter.prepare(`
|
|
82
|
+
SELECT * FROM decisions
|
|
83
|
+
WHERE session_id = ?
|
|
84
|
+
ORDER BY created_at DESC
|
|
85
|
+
`);
|
|
86
|
+
return stmt.all(sessionId);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Increment usage success counter
|
|
90
|
+
*/
|
|
91
|
+
async function incrementUsageSuccess(decisionId, timeSaved = 0) {
|
|
92
|
+
const adapter = dbManager.getAdapter();
|
|
93
|
+
const stmt = adapter.prepare(`
|
|
94
|
+
UPDATE decisions
|
|
95
|
+
SET usage_success = usage_success + 1,
|
|
96
|
+
time_saved = time_saved + ?,
|
|
97
|
+
updated_at = ?
|
|
98
|
+
WHERE id = ?
|
|
99
|
+
`);
|
|
100
|
+
stmt.run(timeSaved, Date.now(), decisionId);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Increment usage failure counter
|
|
104
|
+
*/
|
|
105
|
+
async function incrementUsageFailure(decisionId) {
|
|
106
|
+
const adapter = dbManager.getAdapter();
|
|
107
|
+
const stmt = adapter.prepare(`
|
|
108
|
+
UPDATE decisions
|
|
109
|
+
SET usage_failure = usage_failure + 1,
|
|
110
|
+
updated_at = ?
|
|
111
|
+
WHERE id = ?
|
|
112
|
+
`);
|
|
113
|
+
stmt.run(Date.now(), decisionId);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Get decision by ID
|
|
117
|
+
*/
|
|
118
|
+
async function getDecisionById(decisionId) {
|
|
119
|
+
const adapter = dbManager.getAdapter();
|
|
120
|
+
const stmt = adapter.prepare('SELECT * FROM decisions WHERE id = ?');
|
|
121
|
+
return stmt.get(decisionId);
|
|
122
|
+
}
|
|
123
|
+
// Path exports (labels for display/logging, not actual filesystem paths)
|
|
124
|
+
// Note: Actual paths are managed by sqlite-adapter.ts (~/.claude/mama-memory.db)
|
|
125
|
+
exports.DB_PATH = process.env.MAMA_DATABASE_URL ? 'PostgreSQL' : 'SQLite';
|
|
126
|
+
exports.DB_DIR = process.env.MAMA_DATABASE_URL ? 'PostgreSQL' : '~/.mama';
|
|
127
|
+
exports.LEGACY_DB_PATH = '~/.spinelift/memories.db';
|
|
128
|
+
exports.DEFAULT_DB_PATH = '~/.mama/memories.db';
|
|
129
|
+
//# sourceMappingURL=memory-store.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MAMA Notification Manager - Stub module
|
|
4
|
+
*
|
|
5
|
+
* @module notification-manager
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.notifyInsight = notifyInsight;
|
|
9
|
+
function notifyInsight() {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=notification-manager.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MAMA (Memory-Augmented MCP Architecture) - Ollama Client Wrapper
|
|
3
|
+
*
|
|
4
|
+
* Simple wrapper for Ollama API with EXAONE 3.5 support
|
|
5
|
+
*
|
|
6
|
+
* @module ollama-client
|
|
7
|
+
*/
|
|
8
|
+
import type { ToolExecution, SessionContext } from './decision-tracker.js';
|
|
9
|
+
export declare const DEFAULT_MODEL = "exaone3.5:2.4b";
|
|
10
|
+
export declare const FALLBACK_MODEL = "gemma:2b";
|
|
11
|
+
export interface GenerateOptions {
|
|
12
|
+
model?: string;
|
|
13
|
+
format?: string | null;
|
|
14
|
+
temperature?: number;
|
|
15
|
+
max_tokens?: number;
|
|
16
|
+
timeout?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Generate text with EXAONE 3.5
|
|
20
|
+
*/
|
|
21
|
+
export declare function generate(prompt: string, options?: GenerateOptions): Promise<unknown>;
|
|
22
|
+
export interface DecisionAnalysisResult {
|
|
23
|
+
is_decision: boolean;
|
|
24
|
+
topic: string | null;
|
|
25
|
+
decision: string | null;
|
|
26
|
+
reasoning: string;
|
|
27
|
+
confidence: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Analyze decision from tool execution
|
|
31
|
+
*/
|
|
32
|
+
export declare function analyzeDecision(toolExecution: ToolExecution, sessionContext: SessionContext): Promise<DecisionAnalysisResult>;
|
|
33
|
+
export interface QueryIntentResult {
|
|
34
|
+
involves_decision: boolean;
|
|
35
|
+
topic: string | null;
|
|
36
|
+
query_type: 'recall' | 'evolution' | 'none';
|
|
37
|
+
reasoning: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Analyze query intent
|
|
41
|
+
*/
|
|
42
|
+
export declare function analyzeQueryIntent(userMessage: string): Promise<QueryIntentResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Check if Ollama is available
|
|
45
|
+
*/
|
|
46
|
+
export declare function isAvailable(): Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* List available models
|
|
49
|
+
*/
|
|
50
|
+
export declare function listModels(): Promise<string[]>;
|
|
51
|
+
//# sourceMappingURL=ollama-client.d.ts.map
|