@jungjaehoon/mama-core 1.1.2 → 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,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MAMA Configuration Loader
|
|
3
|
+
*
|
|
4
|
+
* Story M1.4: Configurable embedding model selection
|
|
5
|
+
* Priority: P1 (Core Feature)
|
|
6
|
+
*
|
|
7
|
+
* Loads user configuration from ~/.mama/config.json with sensible defaults.
|
|
8
|
+
* Supports:
|
|
9
|
+
* - Model selection (default: multilingual-e5-small)
|
|
10
|
+
* - Embedding dimensions
|
|
11
|
+
* - Cache directory configuration
|
|
12
|
+
*
|
|
13
|
+
* @module config-loader
|
|
14
|
+
*/
|
|
15
|
+
export interface MAMAConfig {
|
|
16
|
+
modelName: string;
|
|
17
|
+
embeddingDim: number;
|
|
18
|
+
cacheDir: string;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
export declare const DEFAULT_CONFIG: MAMAConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Load MAMA configuration from ~/.mama/config.json
|
|
24
|
+
*
|
|
25
|
+
* Story M1.4 AC #1: Config parser loads ~/.mama/config.json
|
|
26
|
+
*
|
|
27
|
+
* @param reload - Force reload from disk (default: false)
|
|
28
|
+
* @returns Configuration object with modelName, embeddingDim, cacheDir
|
|
29
|
+
*/
|
|
30
|
+
export declare function loadConfig(reload?: boolean): MAMAConfig;
|
|
31
|
+
/**
|
|
32
|
+
* Get current model name
|
|
33
|
+
*/
|
|
34
|
+
export declare function getModelName(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Get current embedding dimension
|
|
37
|
+
*/
|
|
38
|
+
export declare function getEmbeddingDim(): number;
|
|
39
|
+
/**
|
|
40
|
+
* Get current cache directory
|
|
41
|
+
*/
|
|
42
|
+
export declare function getCacheDir(): string;
|
|
43
|
+
export interface ConfigUpdates {
|
|
44
|
+
modelName?: string;
|
|
45
|
+
embeddingDim?: number;
|
|
46
|
+
cacheDir?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Update configuration and save to file
|
|
50
|
+
*
|
|
51
|
+
* Story M1.4 AC #3: Changing model via config triggers informative log + resets caches
|
|
52
|
+
*
|
|
53
|
+
* @param updates - Configuration updates
|
|
54
|
+
* @returns Success status
|
|
55
|
+
*/
|
|
56
|
+
export declare function updateConfig(updates: ConfigUpdates): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Get config file path
|
|
59
|
+
*/
|
|
60
|
+
export declare function getConfigPath(): string;
|
|
61
|
+
//# sourceMappingURL=config-loader.d.ts.map
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MAMA Configuration Loader
|
|
4
|
+
*
|
|
5
|
+
* Story M1.4: Configurable embedding model selection
|
|
6
|
+
* Priority: P1 (Core Feature)
|
|
7
|
+
*
|
|
8
|
+
* Loads user configuration from ~/.mama/config.json with sensible defaults.
|
|
9
|
+
* Supports:
|
|
10
|
+
* - Model selection (default: multilingual-e5-small)
|
|
11
|
+
* - Embedding dimensions
|
|
12
|
+
* - Cache directory configuration
|
|
13
|
+
*
|
|
14
|
+
* @module config-loader
|
|
15
|
+
*/
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.DEFAULT_CONFIG = void 0;
|
|
21
|
+
exports.loadConfig = loadConfig;
|
|
22
|
+
exports.getModelName = getModelName;
|
|
23
|
+
exports.getEmbeddingDim = getEmbeddingDim;
|
|
24
|
+
exports.getCacheDir = getCacheDir;
|
|
25
|
+
exports.updateConfig = updateConfig;
|
|
26
|
+
exports.getConfigPath = getConfigPath;
|
|
27
|
+
const fs_1 = __importDefault(require("fs"));
|
|
28
|
+
const path_1 = __importDefault(require("path"));
|
|
29
|
+
const os_1 = __importDefault(require("os"));
|
|
30
|
+
const debug_logger_js_1 = require("./debug-logger.js");
|
|
31
|
+
// Default configuration
|
|
32
|
+
exports.DEFAULT_CONFIG = {
|
|
33
|
+
modelName: 'Xenova/multilingual-e5-small',
|
|
34
|
+
embeddingDim: 384,
|
|
35
|
+
cacheDir: path_1.default.join(os_1.default.homedir(), '.cache', 'huggingface', 'transformers'),
|
|
36
|
+
};
|
|
37
|
+
// Config file path
|
|
38
|
+
const CONFIG_DIR = path_1.default.join(os_1.default.homedir(), '.mama');
|
|
39
|
+
const CONFIG_PATH = path_1.default.join(CONFIG_DIR, 'config.json');
|
|
40
|
+
// Cached configuration
|
|
41
|
+
let cachedConfig = null;
|
|
42
|
+
/**
|
|
43
|
+
* Ensure config directory exists
|
|
44
|
+
*/
|
|
45
|
+
function ensureConfigDir() {
|
|
46
|
+
if (!fs_1.default.existsSync(CONFIG_DIR)) {
|
|
47
|
+
fs_1.default.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
48
|
+
(0, debug_logger_js_1.info)(`[config] Created config directory: ${CONFIG_DIR}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create default config file if it doesn't exist
|
|
53
|
+
*/
|
|
54
|
+
function ensureConfigFile() {
|
|
55
|
+
if (!fs_1.default.existsSync(CONFIG_PATH)) {
|
|
56
|
+
ensureConfigDir();
|
|
57
|
+
fs_1.default.writeFileSync(CONFIG_PATH, JSON.stringify(exports.DEFAULT_CONFIG, null, 2), 'utf8');
|
|
58
|
+
(0, debug_logger_js_1.info)(`[config] Created default config file: ${CONFIG_PATH}`);
|
|
59
|
+
(0, debug_logger_js_1.info)(`[config] Model: ${exports.DEFAULT_CONFIG.modelName} (${exports.DEFAULT_CONFIG.embeddingDim}-dim)`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Load MAMA configuration from ~/.mama/config.json
|
|
64
|
+
*
|
|
65
|
+
* Story M1.4 AC #1: Config parser loads ~/.mama/config.json
|
|
66
|
+
*
|
|
67
|
+
* @param reload - Force reload from disk (default: false)
|
|
68
|
+
* @returns Configuration object with modelName, embeddingDim, cacheDir
|
|
69
|
+
*/
|
|
70
|
+
function loadConfig(reload = false) {
|
|
71
|
+
// Return cached config if available and not forcing reload
|
|
72
|
+
if (cachedConfig && !reload) {
|
|
73
|
+
return cachedConfig;
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
// Ensure config file exists
|
|
77
|
+
ensureConfigFile();
|
|
78
|
+
// Read and parse config file
|
|
79
|
+
const configData = fs_1.default.readFileSync(CONFIG_PATH, 'utf8');
|
|
80
|
+
const userConfig = JSON.parse(configData);
|
|
81
|
+
// Merge with defaults (user config overrides)
|
|
82
|
+
const config = {
|
|
83
|
+
...exports.DEFAULT_CONFIG,
|
|
84
|
+
...userConfig,
|
|
85
|
+
};
|
|
86
|
+
// Validate configuration
|
|
87
|
+
if (!config.modelName || typeof config.modelName !== 'string') {
|
|
88
|
+
(0, debug_logger_js_1.warn)('[config] Invalid modelName, using default:', exports.DEFAULT_CONFIG.modelName);
|
|
89
|
+
config.modelName = exports.DEFAULT_CONFIG.modelName;
|
|
90
|
+
}
|
|
91
|
+
if (!Number.isInteger(config.embeddingDim) || config.embeddingDim <= 0) {
|
|
92
|
+
(0, debug_logger_js_1.warn)('[config] Invalid embeddingDim, using default:', exports.DEFAULT_CONFIG.embeddingDim);
|
|
93
|
+
config.embeddingDim = exports.DEFAULT_CONFIG.embeddingDim;
|
|
94
|
+
}
|
|
95
|
+
if (!config.cacheDir || typeof config.cacheDir !== 'string') {
|
|
96
|
+
(0, debug_logger_js_1.warn)('[config] Invalid cacheDir, using default:', exports.DEFAULT_CONFIG.cacheDir);
|
|
97
|
+
config.cacheDir = exports.DEFAULT_CONFIG.cacheDir;
|
|
98
|
+
}
|
|
99
|
+
// Cache the loaded config
|
|
100
|
+
cachedConfig = config;
|
|
101
|
+
// Log loaded configuration
|
|
102
|
+
if (reload) {
|
|
103
|
+
(0, debug_logger_js_1.info)(`[config] Configuration reloaded from ${CONFIG_PATH}`);
|
|
104
|
+
(0, debug_logger_js_1.info)(`[config] Model: ${config.modelName} (${config.embeddingDim}-dim)`);
|
|
105
|
+
(0, debug_logger_js_1.info)(`[config] Cache: ${config.cacheDir}`);
|
|
106
|
+
}
|
|
107
|
+
return config;
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
111
|
+
(0, debug_logger_js_1.error)(`[config] Failed to load config file: ${message}`);
|
|
112
|
+
(0, debug_logger_js_1.error)('[config] Using default configuration');
|
|
113
|
+
// Cache defaults on error
|
|
114
|
+
cachedConfig = { ...exports.DEFAULT_CONFIG };
|
|
115
|
+
return cachedConfig;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get current model name
|
|
120
|
+
*/
|
|
121
|
+
function getModelName() {
|
|
122
|
+
const config = loadConfig();
|
|
123
|
+
return config.modelName;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get current embedding dimension
|
|
127
|
+
*/
|
|
128
|
+
function getEmbeddingDim() {
|
|
129
|
+
const config = loadConfig();
|
|
130
|
+
return config.embeddingDim;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get current cache directory
|
|
134
|
+
*/
|
|
135
|
+
function getCacheDir() {
|
|
136
|
+
const config = loadConfig();
|
|
137
|
+
return config.cacheDir;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Update configuration and save to file
|
|
141
|
+
*
|
|
142
|
+
* Story M1.4 AC #3: Changing model via config triggers informative log + resets caches
|
|
143
|
+
*
|
|
144
|
+
* @param updates - Configuration updates
|
|
145
|
+
* @returns Success status
|
|
146
|
+
*/
|
|
147
|
+
function updateConfig(updates) {
|
|
148
|
+
try {
|
|
149
|
+
ensureConfigFile();
|
|
150
|
+
// Load current config
|
|
151
|
+
const currentConfig = loadConfig();
|
|
152
|
+
// Check if model is changing
|
|
153
|
+
const modelChanged = updates.modelName && updates.modelName !== currentConfig.modelName;
|
|
154
|
+
const dimChanged = updates.embeddingDim && updates.embeddingDim !== currentConfig.embeddingDim;
|
|
155
|
+
// Merge updates
|
|
156
|
+
const newConfig = {
|
|
157
|
+
...currentConfig,
|
|
158
|
+
...updates,
|
|
159
|
+
};
|
|
160
|
+
// Save to file
|
|
161
|
+
fs_1.default.writeFileSync(CONFIG_PATH, JSON.stringify(newConfig, null, 2), 'utf8');
|
|
162
|
+
// Update cache
|
|
163
|
+
cachedConfig = newConfig;
|
|
164
|
+
// Story M1.4 AC #3: Informative log when model changes
|
|
165
|
+
if (modelChanged || dimChanged) {
|
|
166
|
+
(0, debug_logger_js_1.info)('[config] ⚠️ Embedding model configuration changed');
|
|
167
|
+
(0, debug_logger_js_1.info)(`[config] Old: ${currentConfig.modelName} (${currentConfig.embeddingDim}-dim)`);
|
|
168
|
+
(0, debug_logger_js_1.info)(`[config] New: ${newConfig.modelName} (${newConfig.embeddingDim}-dim)`);
|
|
169
|
+
(0, debug_logger_js_1.info)('[config] ⚡ Model cache will be reset on next embedding generation');
|
|
170
|
+
(0, debug_logger_js_1.info)('[config] ⚡ Existing embeddings in database remain unchanged');
|
|
171
|
+
}
|
|
172
|
+
(0, debug_logger_js_1.info)(`[config] Configuration saved to ${CONFIG_PATH}`);
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
177
|
+
(0, debug_logger_js_1.error)(`[config] Failed to update config: ${message}`);
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Get config file path
|
|
183
|
+
*/
|
|
184
|
+
function getConfigPath() {
|
|
185
|
+
return CONFIG_PATH;
|
|
186
|
+
}
|
|
187
|
+
//# sourceMappingURL=config-loader.js.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Database Adapter Interface
|
|
3
|
+
* All adapters must implement these methods
|
|
4
|
+
*/
|
|
5
|
+
import type { Statement, RunResult } from './statement.js';
|
|
6
|
+
export type { Statement, RunResult };
|
|
7
|
+
export interface VectorSearchResult {
|
|
8
|
+
rowid: number;
|
|
9
|
+
similarity?: number;
|
|
10
|
+
distance?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare abstract class DatabaseAdapter {
|
|
13
|
+
/**
|
|
14
|
+
* Connect to database
|
|
15
|
+
* @returns Database connection
|
|
16
|
+
*/
|
|
17
|
+
abstract connect(): unknown;
|
|
18
|
+
/**
|
|
19
|
+
* Disconnect from database
|
|
20
|
+
*/
|
|
21
|
+
abstract disconnect(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Check if connected
|
|
24
|
+
* @returns Connection status
|
|
25
|
+
*/
|
|
26
|
+
abstract isConnected(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Prepare a SQL statement
|
|
29
|
+
* @param sql - SQL query
|
|
30
|
+
* @returns Prepared statement
|
|
31
|
+
*/
|
|
32
|
+
abstract prepare(sql: string): Statement;
|
|
33
|
+
/**
|
|
34
|
+
* Execute raw SQL
|
|
35
|
+
* @param sql - SQL to execute
|
|
36
|
+
*/
|
|
37
|
+
abstract exec(sql: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Execute function in transaction
|
|
40
|
+
* @param fn - Function to execute
|
|
41
|
+
* @returns Function return value
|
|
42
|
+
*/
|
|
43
|
+
abstract transaction<T>(fn: () => T): T;
|
|
44
|
+
/**
|
|
45
|
+
* Vector similarity search
|
|
46
|
+
* @param embedding - Query embedding (384-dim)
|
|
47
|
+
* @param limit - Max results
|
|
48
|
+
* @returns Search results with distance
|
|
49
|
+
*/
|
|
50
|
+
abstract vectorSearch(embedding: Float32Array | number[], limit: number): VectorSearchResult[] | null;
|
|
51
|
+
/**
|
|
52
|
+
* Insert vector embedding
|
|
53
|
+
* @param rowid - Decision rowid
|
|
54
|
+
* @param embedding - Embedding vector
|
|
55
|
+
*/
|
|
56
|
+
abstract insertEmbedding(rowid: number, embedding: Float32Array | number[]): RunResult | null;
|
|
57
|
+
/**
|
|
58
|
+
* Get last inserted row ID
|
|
59
|
+
* @returns Last rowid
|
|
60
|
+
*/
|
|
61
|
+
abstract getLastInsertRowid(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Run migrations
|
|
64
|
+
* @param migrationsDir - Path to migrations directory
|
|
65
|
+
*/
|
|
66
|
+
abstract runMigrations(migrationsDir: string): void;
|
|
67
|
+
/**
|
|
68
|
+
* Check if vector search is enabled
|
|
69
|
+
*/
|
|
70
|
+
abstract get vectorSearchEnabled(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Get database path
|
|
73
|
+
*/
|
|
74
|
+
abstract getDbPath(): string;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=base-adapter.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base Database Adapter Interface
|
|
4
|
+
* All adapters must implement these methods
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DatabaseAdapter = void 0;
|
|
8
|
+
class DatabaseAdapter {
|
|
9
|
+
}
|
|
10
|
+
exports.DatabaseAdapter = DatabaseAdapter;
|
|
11
|
+
//# sourceMappingURL=base-adapter.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database Adapter Factory (SQLite-only)
|
|
3
|
+
*
|
|
4
|
+
* MAMA Plugin uses SQLite exclusively for local storage.
|
|
5
|
+
* PostgreSQL support is only available in the legacy mcp-server.
|
|
6
|
+
*
|
|
7
|
+
* @module db-adapter
|
|
8
|
+
*/
|
|
9
|
+
import { SQLiteAdapter } from './sqlite-adapter.js';
|
|
10
|
+
import { DatabaseAdapter, type VectorSearchResult, type RunResult } from './base-adapter.js';
|
|
11
|
+
import type { Statement } from './statement.js';
|
|
12
|
+
export { DatabaseAdapter, SQLiteAdapter };
|
|
13
|
+
export type { Statement, VectorSearchResult, RunResult };
|
|
14
|
+
export interface AdapterConfig {
|
|
15
|
+
dbPath?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create SQLite database adapter
|
|
19
|
+
*
|
|
20
|
+
* @param config - Database configuration
|
|
21
|
+
* @returns Configured SQLite adapter instance
|
|
22
|
+
*/
|
|
23
|
+
export declare function createAdapter(config?: AdapterConfig): DatabaseAdapter;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Database Adapter Factory (SQLite-only)
|
|
4
|
+
*
|
|
5
|
+
* MAMA Plugin uses SQLite exclusively for local storage.
|
|
6
|
+
* PostgreSQL support is only available in the legacy mcp-server.
|
|
7
|
+
*
|
|
8
|
+
* @module db-adapter
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.SQLiteAdapter = exports.DatabaseAdapter = void 0;
|
|
12
|
+
exports.createAdapter = createAdapter;
|
|
13
|
+
const debug_logger_js_1 = require("../debug-logger.js");
|
|
14
|
+
const sqlite_adapter_js_1 = require("./sqlite-adapter.js");
|
|
15
|
+
Object.defineProperty(exports, "SQLiteAdapter", { enumerable: true, get: function () { return sqlite_adapter_js_1.SQLiteAdapter; } });
|
|
16
|
+
const base_adapter_js_1 = require("./base-adapter.js");
|
|
17
|
+
Object.defineProperty(exports, "DatabaseAdapter", { enumerable: true, get: function () { return base_adapter_js_1.DatabaseAdapter; } });
|
|
18
|
+
/**
|
|
19
|
+
* Create SQLite database adapter
|
|
20
|
+
*
|
|
21
|
+
* @param config - Database configuration
|
|
22
|
+
* @returns Configured SQLite adapter instance
|
|
23
|
+
*/
|
|
24
|
+
function createAdapter(config = {}) {
|
|
25
|
+
(0, debug_logger_js_1.info)('[db-adapter] Using SQLite adapter (plugin mode)');
|
|
26
|
+
const dbPath = config.dbPath || process.env.MAMA_DB_PATH;
|
|
27
|
+
return new sqlite_adapter_js_1.SQLiteAdapter({ dbPath });
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite Database Adapter
|
|
3
|
+
*
|
|
4
|
+
* Implements DatabaseAdapter interface using better-sqlite3 + sqlite-vec
|
|
5
|
+
* This is the current production implementation extracted from memory-store.js
|
|
6
|
+
*
|
|
7
|
+
* @module sqlite-adapter
|
|
8
|
+
*/
|
|
9
|
+
import Database from 'better-sqlite3';
|
|
10
|
+
import { DatabaseAdapter, type VectorSearchResult, type RunResult } from './base-adapter.js';
|
|
11
|
+
import { type Statement } from './statement.js';
|
|
12
|
+
/**
|
|
13
|
+
* Adapter configuration
|
|
14
|
+
*/
|
|
15
|
+
interface SQLiteAdapterConfig {
|
|
16
|
+
dbPath?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare class SQLiteAdapter extends DatabaseAdapter {
|
|
19
|
+
private config;
|
|
20
|
+
private db;
|
|
21
|
+
private _vectorSearchEnabled;
|
|
22
|
+
constructor(config?: SQLiteAdapterConfig);
|
|
23
|
+
/**
|
|
24
|
+
* Check if vector search is enabled
|
|
25
|
+
*/
|
|
26
|
+
get vectorSearchEnabled(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Get database path with backward compatibility
|
|
29
|
+
*/
|
|
30
|
+
getDbPath(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Connect to SQLite database
|
|
33
|
+
*/
|
|
34
|
+
connect(): Database.Database;
|
|
35
|
+
/**
|
|
36
|
+
* Disconnect from database
|
|
37
|
+
*/
|
|
38
|
+
disconnect(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Check if connected
|
|
41
|
+
*/
|
|
42
|
+
isConnected(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Prepare a SQL statement
|
|
45
|
+
*/
|
|
46
|
+
prepare(sql: string): Statement;
|
|
47
|
+
/**
|
|
48
|
+
* Execute raw SQL
|
|
49
|
+
*/
|
|
50
|
+
exec(sql: string): void;
|
|
51
|
+
/**
|
|
52
|
+
* Execute function in transaction
|
|
53
|
+
*/
|
|
54
|
+
transaction<T>(fn: () => T): T;
|
|
55
|
+
/**
|
|
56
|
+
* Vector similarity search using sqlite-vec (vec0 virtual table)
|
|
57
|
+
*/
|
|
58
|
+
vectorSearch(embedding: Float32Array | number[], limit?: number): VectorSearchResult[] | null;
|
|
59
|
+
/**
|
|
60
|
+
* Insert vector embedding
|
|
61
|
+
*/
|
|
62
|
+
insertEmbedding(rowid: number, embedding: Float32Array | number[]): RunResult | null;
|
|
63
|
+
/**
|
|
64
|
+
* Get last inserted row ID
|
|
65
|
+
*/
|
|
66
|
+
getLastInsertRowid(): number;
|
|
67
|
+
/**
|
|
68
|
+
* Run migrations
|
|
69
|
+
*/
|
|
70
|
+
runMigrations(migrationsDir: string): void;
|
|
71
|
+
}
|
|
72
|
+
export default SQLiteAdapter;
|
|
73
|
+
//# sourceMappingURL=sqlite-adapter.d.ts.map
|