@aeriondyseti/vector-memory-mcp 0.2.4 → 0.4.0

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.
Files changed (52) hide show
  1. package/README.md +37 -11
  2. package/package.json +18 -13
  3. package/scripts/warmup.ts +73 -0
  4. package/src/index.ts +8 -0
  5. package/src/mcp/handlers.ts +2 -1
  6. package/src/mcp/tools.ts +12 -1
  7. package/src/services/embeddings.service.ts +16 -36
  8. package/src/services/memory.service.ts +7 -2
  9. package/dist/config/index.d.ts +0 -8
  10. package/dist/config/index.d.ts.map +0 -1
  11. package/dist/config/index.js +0 -14
  12. package/dist/config/index.js.map +0 -1
  13. package/dist/db/connection.d.ts +0 -3
  14. package/dist/db/connection.d.ts.map +0 -1
  15. package/dist/db/connection.js +0 -10
  16. package/dist/db/connection.js.map +0 -1
  17. package/dist/db/memory.repository.d.ts +0 -12
  18. package/dist/db/memory.repository.d.ts.map +0 -1
  19. package/dist/db/memory.repository.js +0 -79
  20. package/dist/db/memory.repository.js.map +0 -1
  21. package/dist/db/schema.d.ts +0 -4
  22. package/dist/db/schema.d.ts.map +0 -1
  23. package/dist/db/schema.js +0 -12
  24. package/dist/db/schema.js.map +0 -1
  25. package/dist/index.d.ts +0 -3
  26. package/dist/index.d.ts.map +0 -1
  27. package/dist/index.js +0 -19
  28. package/dist/index.js.map +0 -1
  29. package/dist/mcp/handlers.d.ts +0 -8
  30. package/dist/mcp/handlers.d.ts.map +0 -1
  31. package/dist/mcp/handlers.js +0 -81
  32. package/dist/mcp/handlers.js.map +0 -1
  33. package/dist/mcp/server.d.ts +0 -5
  34. package/dist/mcp/server.d.ts.map +0 -1
  35. package/dist/mcp/server.js +0 -22
  36. package/dist/mcp/server.js.map +0 -1
  37. package/dist/mcp/tools.d.ts +0 -7
  38. package/dist/mcp/tools.d.ts.map +0 -1
  39. package/dist/mcp/tools.js +0 -73
  40. package/dist/mcp/tools.js.map +0 -1
  41. package/dist/services/embeddings.service.d.ts +0 -12
  42. package/dist/services/embeddings.service.d.ts.map +0 -1
  43. package/dist/services/embeddings.service.js +0 -55
  44. package/dist/services/embeddings.service.js.map +0 -1
  45. package/dist/services/memory.service.d.ts +0 -14
  46. package/dist/services/memory.service.d.ts.map +0 -1
  47. package/dist/services/memory.service.js +0 -80
  48. package/dist/services/memory.service.js.map +0 -1
  49. package/dist/types/memory.d.ts +0 -18
  50. package/dist/types/memory.d.ts.map +0 -1
  51. package/dist/types/memory.js +0 -18
  52. package/dist/types/memory.js.map +0 -1
package/README.md CHANGED
@@ -57,21 +57,38 @@ A production-ready MCP (Model Context Protocol) server that provides semantic me
57
57
 
58
58
  > **Note:** This server requires Bun to run.
59
59
 
60
- ### Installation
60
+ ### Installation & Configuration
61
61
 
62
+ #### Option 1: Global Install (Recommended)
63
+
64
+ **Install:**
62
65
  ```bash
63
- # Clone the repository
64
- git clone https://github.com/AerionDyseti/vector-memory-mcp.git
65
- cd vector-memory-mcp
66
+ bun install -g @aeriondyseti/vector-memory-mcp
67
+ ```
66
68
 
67
- # Install dependencies
68
- bun install
69
+ > **Note:** The installation automatically downloads ML models (~90MB) and verifies native dependencies. This may take a minute on first install.
70
+
71
+ **Configure Claude Code** - Add to `~/.claude/config.json`:
72
+ ```json
73
+ {
74
+ "mcpServers": {
75
+ "memory": {
76
+ "command": "vector-memory-mcp"
77
+ }
78
+ }
79
+ }
69
80
  ```
70
81
 
71
- ### Configure Claude Code
82
+ #### Option 2: Local Development
72
83
 
73
- Add to your `~/.claude/config.json`:
84
+ **Install:**
85
+ ```bash
86
+ git clone https://github.com/AerionDyseti/vector-memory-mcp.git
87
+ cd vector-memory-mcp
88
+ bun install
89
+ ```
74
90
 
91
+ **Configure Claude Code** - Add to `~/.claude/config.json`:
75
92
  ```json
76
93
  {
77
94
  "mcpServers": {
@@ -82,8 +99,17 @@ Add to your `~/.claude/config.json`:
82
99
  }
83
100
  }
84
101
  ```
102
+ *Replace `/absolute/path/to/` with your actual installation path.*
103
+
104
+ ---
105
+
106
+ **What gets installed:**
107
+ - The vector-memory-mcp package and all dependencies
108
+ - Native binaries for ONNX Runtime (~32MB) and image processing (~10MB)
109
+ - ML model files automatically downloaded during installation (~90MB, cached in `~/.cache/huggingface/`)
110
+ - **Total first-time setup:** ~130MB of downloads
85
111
 
86
- Replace `/absolute/path/to/` with your actual installation path.
112
+ > 💡 **Tip:** If you need to re-download models or verify dependencies, run: `vector-memory-mcp warmup`
87
113
 
88
114
  ### Start Using It
89
115
 
@@ -161,7 +187,7 @@ vector-memory-mcp/
161
187
  │ ├── config/ # Configuration management
162
188
  │ ├── db/ # Database layer (LanceDB)
163
189
  │ ├── services/
164
- │ │ ├── embeddings.service.ts # Embeddings via @xenova/transformers
190
+ │ │ ├── embeddings.service.ts # Embeddings via @huggingface/transformers
165
191
  │ │ └── memory.service.ts # Core memory operations
166
192
  │ └── mcp/
167
193
  │ ├── server.ts # MCP server setup
@@ -285,7 +311,7 @@ bun run build
285
311
 
286
312
  ### ✅ Phase 1: Foundation (Current)
287
313
  - ✅ Core database with LanceDB
288
- - ✅ Embedding generation with @xenova/transformers
314
+ - ✅ Embedding generation with @huggingface/transformers
289
315
  - ✅ Basic MCP tools (store, search, get, delete)
290
316
  - ✅ TypeScript implementation with Drizzle ORM
291
317
 
package/package.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "@aeriondyseti/vector-memory-mcp",
3
- "version": "0.2.4",
3
+ "version": "0.4.0",
4
4
  "description": "A zero-configuration RAG memory server for MCP clients",
5
5
  "type": "module",
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
6
+ "main": "src/index.ts",
8
7
  "bin": {
9
- "vector-memory-mcp": "dist/index.js"
8
+ "vector-memory-mcp": "src/index.ts"
10
9
  },
11
10
  "files": [
12
11
  "src",
13
- "dist",
12
+ "scripts",
14
13
  "README.md",
15
14
  "LICENSE"
16
15
  ],
@@ -26,22 +25,28 @@
26
25
  "scripts": {
27
26
  "start": "bun run src/index.ts",
28
27
  "dev": "bun --watch run src/index.ts",
29
- "build": "tsc",
30
- "prepublishOnly": "npm run build",
31
- "typecheck": "tsc --noEmit",
32
- "test": "bun test",
33
- "test:coverage": "bun test --coverage"
28
+ "typecheck": "bunx tsc --noEmit",
29
+ "test": "bun test --preload ./tests/preload.ts",
30
+ "test:quick": "bun test",
31
+ "test:coverage": "bun test --preload ./tests/preload.ts --coverage",
32
+ "test:preload": "bun run tests/preload.ts",
33
+ "warmup": "bun run scripts/warmup.ts",
34
+ "postinstall": "bun run scripts/warmup.ts"
34
35
  },
35
36
  "keywords": ["mcp", "memory", "rag", "embeddings", "lancedb"],
36
37
  "license": "MIT",
37
38
  "dependencies": {
38
39
  "@lancedb/lancedb": "^0.22.3",
39
40
  "@modelcontextprotocol/sdk": "^1.0.0",
40
- "@huggingface/transformers": "^3.8.0",
41
- "apache-arrow": "^18.1.0"
41
+ "@huggingface/transformers": "^3.8.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/bun": "latest",
45
45
  "typescript": "^5.0.0"
46
- }
46
+ },
47
+ "trustedDependencies": [
48
+ "onnxruntime-node",
49
+ "protobufjs",
50
+ "sharp"
51
+ ]
47
52
  }
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env bun
2
+
3
+ /**
4
+ * Warmup script to pre-download ML models and verify dependencies
5
+ * This runs during installation to ensure everything is ready to use
6
+ */
7
+
8
+ import { config } from "../src/config/index.js";
9
+ import { EmbeddingsService } from "../src/services/embeddings.service.js";
10
+
11
+ async function warmup(): Promise<void> {
12
+ console.log("🔥 Warming up vector-memory-mcp...");
13
+ console.log();
14
+
15
+ try {
16
+ // Check native dependencies
17
+ console.log("✓ Checking native dependencies...");
18
+ try {
19
+ await import("onnxruntime-node");
20
+ console.log(" ✓ onnxruntime-node loaded");
21
+ } catch (e) {
22
+ console.error(" ✗ onnxruntime-node failed:", (e as Error).message);
23
+ process.exit(1);
24
+ }
25
+
26
+ try {
27
+ await import("sharp");
28
+ console.log(" ✓ sharp loaded");
29
+ } catch (e) {
30
+ console.error(" ✗ sharp failed:", (e as Error).message);
31
+ process.exit(1);
32
+ }
33
+
34
+ console.log();
35
+
36
+ // Initialize embeddings service to download model
37
+ console.log("📥 Downloading ML model (this may take a minute)...");
38
+ console.log(` Model: ${config.embeddingModel}`);
39
+ console.log(` Cache: ~/.cache/huggingface/`);
40
+ console.log();
41
+
42
+ const embeddings = new EmbeddingsService(
43
+ config.embeddingModel,
44
+ config.embeddingDimension
45
+ );
46
+
47
+ // Trigger model download by generating a test embedding
48
+ const startTime = Date.now();
49
+ await embeddings.embed("warmup test");
50
+ const duration = ((Date.now() - startTime) / 1000).toFixed(2);
51
+
52
+ console.log();
53
+ console.log(`✅ Warmup complete! (${duration}s)`);
54
+ console.log();
55
+ console.log("Ready to use! Configure Claude Code and restart to get started.");
56
+ console.log("See: https://github.com/AerionDyseti/vector-memory-mcp#configure-claude-code");
57
+ console.log();
58
+ } catch (error) {
59
+ console.error();
60
+ console.error("❌ Warmup failed:", error);
61
+ console.error();
62
+ console.error("This is not a critical error - the server will download models on first run.");
63
+ console.error("You can try running 'vector-memory-mcp warmup' manually later.");
64
+ process.exit(0); // Exit successfully to not block installation
65
+ }
66
+ }
67
+
68
+ // Only run if this is the main module
69
+ if (import.meta.url === `file://${process.argv[1]}`) {
70
+ warmup();
71
+ }
72
+
73
+ export { warmup };
package/src/index.ts CHANGED
@@ -8,6 +8,14 @@ import { MemoryService } from "./services/memory.service.js";
8
8
  import { startServer } from "./mcp/server.js";
9
9
 
10
10
  async function main(): Promise<void> {
11
+ // Check for warmup command
12
+ const args = process.argv.slice(2);
13
+ if (args[0] === "warmup") {
14
+ const { warmup } = await import("../scripts/warmup.js");
15
+ await warmup();
16
+ return;
17
+ }
18
+
11
19
  // Initialize database
12
20
  const db = await connectToDatabase(config.dbPath);
13
21
 
@@ -6,8 +6,9 @@ export async function handleStoreMemory(
6
6
  service: MemoryService
7
7
  ): Promise<CallToolResult> {
8
8
  const content = args?.content as string;
9
+ const embeddingText = args?.embedding_text as string | undefined;
9
10
  const metadata = (args?.metadata as Record<string, unknown>) ?? {};
10
- const memory = await service.store(content, metadata);
11
+ const memory = await service.store(content, metadata, embeddingText);
11
12
 
12
13
  return {
13
14
  content: [{ type: "text", text: `Memory stored with ID: ${memory.id}` }],
package/src/mcp/tools.ts CHANGED
@@ -2,7 +2,11 @@ import type { Tool } from "@modelcontextprotocol/sdk/types.js";
2
2
 
3
3
  export const storeMemoryTool: Tool = {
4
4
  name: "store_memory",
5
- description: "Store a new memory. Use this to save information for later recall.",
5
+ description:
6
+ "Store a new memory. Use this to save information for later recall. " +
7
+ "IMPORTANT: If the content exceeds 1000 characters, you MUST provide an embedding_text " +
8
+ "parameter with a concise summary (under 1000 characters) that captures the key semantic " +
9
+ "meaning for search purposes. The full content will still be stored and returned in search results.",
6
10
  inputSchema: {
7
11
  type: "object",
8
12
  properties: {
@@ -10,6 +14,13 @@ export const storeMemoryTool: Tool = {
10
14
  type: "string",
11
15
  description: "The text content to store as a memory",
12
16
  },
17
+ embedding_text: {
18
+ type: "string",
19
+ description:
20
+ "A concise summary (under 1000 characters) used for generating the search embedding. " +
21
+ "REQUIRED when content exceeds 1000 characters. If not provided, the full content is used for embedding, " +
22
+ "which may be truncated by the embedding model and result in poor search relevance.",
23
+ },
13
24
  metadata: {
14
25
  type: "object",
15
26
  description: "Optional key-value metadata to attach to the memory",
@@ -3,7 +3,7 @@ import { pipeline, type FeatureExtractionPipeline } from "@huggingface/transform
3
3
  export class EmbeddingsService {
4
4
  private modelName: string;
5
5
  private extractor: FeatureExtractionPipeline | null = null;
6
- private initPromise: Promise<void> | null = null;
6
+ private initPromise: Promise<FeatureExtractionPipeline> | null = null;
7
7
  private _dimension: number;
8
8
 
9
9
  constructor(modelName: string, dimension: number) {
@@ -15,52 +15,32 @@ export class EmbeddingsService {
15
15
  return this._dimension;
16
16
  }
17
17
 
18
- private async init(): Promise<void> {
18
+ private async getExtractor(): Promise<FeatureExtractionPipeline> {
19
19
  if (this.extractor) {
20
- return; // Already initialized
20
+ return this.extractor;
21
21
  }
22
22
 
23
23
  if (!this.initPromise) {
24
- this.initPromise = (async () => {
25
- this.extractor = await pipeline("feature-extraction", this.modelName, {
26
- dtype: "fp32",
27
- });
28
- })();
24
+ this.initPromise = pipeline("feature-extraction", this.modelName, {
25
+ quantized: true,
26
+ }) as Promise<FeatureExtractionPipeline>;
29
27
  }
30
- await this.initPromise;
28
+
29
+ this.extractor = await this.initPromise;
30
+ return this.extractor;
31
31
  }
32
32
 
33
33
  async embed(text: string): Promise<number[]> {
34
- await this.init();
35
- if (!this.extractor) {
36
- throw new Error("Extractor not initialized.");
37
- }
38
-
39
- const output = await this.extractor(text, {
40
- pooling: "mean",
41
- normalize: true,
42
- });
43
-
44
- // output.tolist() returns number[][] for single input, we want the first element
45
- const embeddings = output.tolist() as number[][];
46
- return embeddings[0];
34
+ const extractor = await this.getExtractor();
35
+ const output = await extractor(text, { pooling: "mean", normalize: true });
36
+ return Array.from(output.data as Float32Array);
47
37
  }
48
38
 
49
39
  async embedBatch(texts: string[]): Promise<number[][]> {
50
- await this.init();
51
- if (!this.extractor) {
52
- throw new Error("Extractor not initialized.");
40
+ const results: number[][] = [];
41
+ for (const text of texts) {
42
+ results.push(await this.embed(text));
53
43
  }
54
-
55
- if (texts.length === 0) {
56
- return [];
57
- }
58
-
59
- const output = await this.extractor(texts, {
60
- pooling: "mean",
61
- normalize: true,
62
- });
63
-
64
- return output.tolist() as number[][];
44
+ return results;
65
45
  }
66
46
  }
@@ -10,10 +10,15 @@ export class MemoryService {
10
10
  private embeddings: EmbeddingsService
11
11
  ) {}
12
12
 
13
- async store(content: string, metadata: Record<string, unknown> = {}): Promise<Memory> {
13
+ async store(
14
+ content: string,
15
+ metadata: Record<string, unknown> = {},
16
+ embeddingText?: string
17
+ ): Promise<Memory> {
14
18
  const id = randomUUID();
15
19
  const now = new Date();
16
- const embedding = await this.embeddings.embed(content);
20
+ const textToEmbed = embeddingText ?? content;
21
+ const embedding = await this.embeddings.embed(textToEmbed);
17
22
 
18
23
  const memory: Memory = {
19
24
  id,
@@ -1,8 +0,0 @@
1
- export interface Config {
2
- dbPath: string;
3
- embeddingModel: string;
4
- embeddingDimension: number;
5
- }
6
- export declare function loadConfig(): Config;
7
- export declare const config: Config;
8
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAaD,wBAAgB,UAAU,IAAI,MAAM,CAMnC;AAED,eAAO,MAAM,MAAM,QAAe,CAAC"}
@@ -1,14 +0,0 @@
1
- import { join } from "path";
2
- import { homedir } from "os";
3
- const DEFAULT_DB_PATH = join(homedir(), ".local", "share", "vector-memory-mcp", "memories.db");
4
- const DEFAULT_EMBEDDING_MODEL = "Xenova/all-MiniLM-L6-v2";
5
- const DEFAULT_EMBEDDING_DIMENSION = 384;
6
- export function loadConfig() {
7
- return {
8
- dbPath: process.env.VECTOR_MEMORY_DB_PATH ?? DEFAULT_DB_PATH,
9
- embeddingModel: process.env.VECTOR_MEMORY_MODEL ?? DEFAULT_EMBEDDING_MODEL,
10
- embeddingDimension: DEFAULT_EMBEDDING_DIMENSION,
11
- };
12
- }
13
- export const config = loadConfig();
14
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAQ7B,MAAM,eAAe,GAAG,IAAI,CAC1B,OAAO,EAAE,EACT,QAAQ,EACR,OAAO,EACP,mBAAmB,EACnB,aAAa,CACd,CAAC;AAEF,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAC1D,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAExC,MAAM,UAAU,UAAU;IACxB,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,eAAe;QAC5D,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,uBAAuB;QAC1E,kBAAkB,EAAE,2BAA2B;KAChD,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC"}
@@ -1,3 +0,0 @@
1
- import * as lancedb from "@lancedb/lancedb";
2
- export declare function connectToDatabase(dbPath: string): Promise<lancedb.Connection>;
3
- //# sourceMappingURL=connection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/db/connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAI5C,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAMnF"}
@@ -1,10 +0,0 @@
1
- import * as lancedb from "@lancedb/lancedb";
2
- import { mkdirSync } from "fs";
3
- import { dirname } from "path";
4
- export async function connectToDatabase(dbPath) {
5
- // Ensure directory exists
6
- mkdirSync(dirname(dbPath), { recursive: true });
7
- const db = await lancedb.connect(dbPath);
8
- return db;
9
- }
10
- //# sourceMappingURL=connection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/db/connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,MAAc;IACpD,0BAA0B;IAC1B,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEhD,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACzC,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -1,12 +0,0 @@
1
- import * as lancedb from "@lancedb/lancedb";
2
- import { type Memory, type VectorRow } from "../types/memory.js";
3
- export declare class MemoryRepository {
4
- private db;
5
- constructor(db: lancedb.Connection);
6
- private getTable;
7
- insert(memory: Memory): Promise<void>;
8
- findById(id: string): Promise<Memory | null>;
9
- markDeleted(id: string): Promise<boolean>;
10
- findSimilar(embedding: number[], limit: number): Promise<VectorRow[]>;
11
- }
12
- //# sourceMappingURL=memory.repository.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory.repository.d.ts","sourceRoot":"","sources":["../../src/db/memory.repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EACL,KAAK,MAAM,EACX,KAAK,SAAS,EAEf,MAAM,oBAAoB,CAAC;AAE5B,qBAAa,gBAAgB;IACf,OAAO,CAAC,EAAE;gBAAF,EAAE,EAAE,OAAO,CAAC,UAAU;YAE5B,QAAQ;IAShB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAerC,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IA4B5C,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAqBzC,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;CAS5E"}
@@ -1,79 +0,0 @@
1
- import { TABLE_NAME, memorySchema } from "./schema.js";
2
- import { DELETED_TOMBSTONE, } from "../types/memory.js";
3
- export class MemoryRepository {
4
- db;
5
- constructor(db) {
6
- this.db = db;
7
- }
8
- async getTable() {
9
- const names = await this.db.tableNames();
10
- if (names.includes(TABLE_NAME)) {
11
- return await this.db.openTable(TABLE_NAME);
12
- }
13
- // Create with empty data to initialize schema
14
- return await this.db.createTable(TABLE_NAME, [], { schema: memorySchema });
15
- }
16
- async insert(memory) {
17
- const table = await this.getTable();
18
- await table.add([
19
- {
20
- id: memory.id,
21
- vector: memory.embedding,
22
- content: memory.content,
23
- metadata: JSON.stringify(memory.metadata),
24
- created_at: memory.createdAt.getTime(),
25
- updated_at: memory.updatedAt.getTime(),
26
- superseded_by: memory.supersededBy,
27
- },
28
- ]);
29
- }
30
- async findById(id) {
31
- const table = await this.getTable();
32
- const results = await table.query().where(`id = '${id}'`).limit(1).toArray();
33
- if (results.length === 0) {
34
- return null;
35
- }
36
- const row = results[0];
37
- // Handle Arrow Vector type conversion
38
- // LanceDB returns an Arrow Vector object which is iterable but not an array
39
- const vectorData = row.vector;
40
- const embedding = Array.isArray(vectorData)
41
- ? vectorData
42
- : Array.from(vectorData);
43
- return {
44
- id: row.id,
45
- content: row.content,
46
- embedding,
47
- metadata: JSON.parse(row.metadata),
48
- createdAt: new Date(row.created_at),
49
- updatedAt: new Date(row.updated_at),
50
- supersededBy: row.superseded_by,
51
- };
52
- }
53
- async markDeleted(id) {
54
- const table = await this.getTable();
55
- // Verify existence first to match previous behavior (return false if not found)
56
- const existing = await table.query().where(`id = '${id}'`).limit(1).toArray();
57
- if (existing.length === 0) {
58
- return false;
59
- }
60
- const now = Date.now();
61
- await table.update({
62
- where: `id = '${id}'`,
63
- values: {
64
- superseded_by: DELETED_TOMBSTONE,
65
- updated_at: now,
66
- },
67
- });
68
- return true;
69
- }
70
- async findSimilar(embedding, limit) {
71
- const table = await this.getTable();
72
- const results = await table.vectorSearch(embedding).limit(limit).toArray();
73
- return results.map((r) => ({
74
- id: r.id,
75
- distance: r._distance,
76
- }));
77
- }
78
- }
79
- //# sourceMappingURL=memory.repository.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory.repository.js","sourceRoot":"","sources":["../../src/db/memory.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAGL,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,OAAO,gBAAgB;IACP;IAApB,YAAoB,EAAsB;QAAtB,OAAE,GAAF,EAAE,CAAoB;IAAG,CAAC;IAEtC,KAAK,CAAC,QAAQ;QACpB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC;QACzC,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/B,OAAO,MAAM,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAC7C,CAAC;QACD,8CAA8C;QAC9C,OAAO,MAAM,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAc;QACzB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACpC,MAAM,KAAK,CAAC,GAAG,CAAC;YACd;gBACE,EAAE,EAAE,MAAM,CAAC,EAAE;gBACb,MAAM,EAAE,MAAM,CAAC,SAAS;gBACxB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC;gBACzC,UAAU,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE;gBACtC,UAAU,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE;gBACtC,aAAa,EAAE,MAAM,CAAC,YAAY;aACnC;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,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AQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,KAAK,CAAC,MAAM,CAAC;YACjB,KAAK,EAAE,SAAS,EAAE,GAAG;YACrB,MAAM,EAAE;gBACN,aAAa,EAAE,iBAAiB;gBAChC,UAAU,EAAE,GAAG;aAChB;SACF,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,SAAmB,EAAE,KAAa;QAClD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;QAE3E,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACzB,EAAE,EAAE,CAAC,CAAC,EAAY;YAClB,QAAQ,EAAE,CAAC,CAAC,SAAmB;SAChC,CAAC,CAAC,CAAC;IACN,CAAC;CACF"}
@@ -1,4 +0,0 @@
1
- import { Schema } from "apache-arrow";
2
- export declare const TABLE_NAME = "memories";
3
- export declare const memorySchema: Schema<any>;
4
- //# sourceMappingURL=schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAOP,MAAM,cAAc,CAAC;AAEtB,eAAO,MAAM,UAAU,aAAa,CAAC;AAErC,eAAO,MAAM,YAAY,aAoBvB,CAAC"}
package/dist/db/schema.js DELETED
@@ -1,12 +0,0 @@
1
- import { Schema, Field, FixedSizeList, Float32, Utf8, Timestamp, TimeUnit, } from "apache-arrow";
2
- export const TABLE_NAME = "memories";
3
- export const memorySchema = new Schema([
4
- new Field("id", new Utf8(), false),
5
- new Field("vector", new FixedSizeList(384, new Field("item", new Float32())), false),
6
- new Field("content", new Utf8(), false),
7
- new Field("metadata", new Utf8(), false), // JSON string
8
- new Field("created_at", new Timestamp(TimeUnit.MILLISECOND), false),
9
- new Field("updated_at", new Timestamp(TimeUnit.MILLISECOND), false),
10
- new Field("superseded_by", new Utf8(), true), // Nullable
11
- ]);
12
- //# sourceMappingURL=schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,KAAK,EACL,aAAa,EACb,OAAO,EACP,IAAI,EACJ,SAAS,EACT,QAAQ,GACT,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC;AAErC,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC;IACrC,IAAI,KAAK,CAAC,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE,KAAK,CAAC;IAClC,IAAI,KAAK,CACP,QAAQ,EACR,IAAI,aAAa,CAAC,GAAG,EAAE,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC,EACxD,KAAK,CACN;IACD,IAAI,KAAK,CAAC,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE,KAAK,CAAC;IACvC,IAAI,KAAK,CAAC,UAAU,EAAE,IAAI,IAAI,EAAE,EAAE,KAAK,CAAC,EAAE,cAAc;IACxD,IAAI,KAAK,CACP,YAAY,EACZ,IAAI,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,EACnC,KAAK,CACN;IACD,IAAI,KAAK,CACP,YAAY,EACZ,IAAI,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,EACnC,KAAK,CACN;IACD,IAAI,KAAK,CAAC,eAAe,EAAE,IAAI,IAAI,EAAE,EAAE,IAAI,CAAC,EAAE,WAAW;CAC1D,CAAC,CAAC"}
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js DELETED
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env node
2
- import { config } from "./config/index.js";
3
- import { connectToDatabase } from "./db/connection.js";
4
- import { MemoryRepository } from "./db/memory.repository.js";
5
- import { EmbeddingsService } from "./services/embeddings.service.js";
6
- import { MemoryService } from "./services/memory.service.js";
7
- import { startServer } from "./mcp/server.js";
8
- async function main() {
9
- // Initialize database
10
- const db = await connectToDatabase(config.dbPath);
11
- // Initialize layers
12
- const repository = new MemoryRepository(db);
13
- const embeddings = new EmbeddingsService(config.embeddingModel, config.embeddingDimension);
14
- const memoryService = new MemoryService(repository, embeddings);
15
- // Start MCP server
16
- await startServer(memoryService);
17
- }
18
- main().catch(console.error);
19
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,KAAK,UAAU,IAAI;IACjB,sBAAsB;IACtB,MAAM,EAAE,GAAG,MAAM,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAElD,oBAAoB;IACpB,MAAM,UAAU,GAAG,IAAI,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAAC;IAC3F,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAEhE,mBAAmB;IACnB,MAAM,WAAW,CAAC,aAAa,CAAC,CAAC;AACnC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
@@ -1,8 +0,0 @@
1
- import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
2
- import type { MemoryService } from "../services/memory.service.js";
3
- export declare function handleStoreMemory(args: Record<string, unknown> | undefined, service: MemoryService): Promise<CallToolResult>;
4
- export declare function handleDeleteMemory(args: Record<string, unknown> | undefined, service: MemoryService): Promise<CallToolResult>;
5
- export declare function handleSearchMemories(args: Record<string, unknown> | undefined, service: MemoryService): Promise<CallToolResult>;
6
- export declare function handleGetMemory(args: Record<string, unknown> | undefined, service: MemoryService): Promise<CallToolResult>;
7
- export declare function handleToolCall(name: string, args: Record<string, unknown> | undefined, service: MemoryService): Promise<CallToolResult>;
8
- //# sourceMappingURL=handlers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/mcp/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACzC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,cAAc,CAAC,CAQzB;AAED,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACzC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,cAAc,CAAC,CAczB;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACzC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,cAAc,CAAC,CAsBzB;AAED,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACzC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,cAAc,CAAC,CAuBzB;AAED,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACzC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,cAAc,CAAC,CAgBzB"}
@@ -1,81 +0,0 @@
1
- export async function handleStoreMemory(args, service) {
2
- const content = args?.content;
3
- const metadata = args?.metadata ?? {};
4
- const memory = await service.store(content, metadata);
5
- return {
6
- content: [{ type: "text", text: `Memory stored with ID: ${memory.id}` }],
7
- };
8
- }
9
- export async function handleDeleteMemory(args, service) {
10
- const id = args?.id;
11
- const success = await service.delete(id);
12
- return {
13
- content: [
14
- {
15
- type: "text",
16
- text: success
17
- ? `Memory ${id} deleted successfully`
18
- : `Memory ${id} not found`,
19
- },
20
- ],
21
- };
22
- }
23
- export async function handleSearchMemories(args, service) {
24
- const query = args?.query;
25
- const limit = args?.limit ?? 10;
26
- const memories = await service.search(query, limit);
27
- if (memories.length === 0) {
28
- return {
29
- content: [{ type: "text", text: "No memories found matching your query." }],
30
- };
31
- }
32
- const results = memories.map((mem) => {
33
- let result = `ID: ${mem.id}\nContent: ${mem.content}`;
34
- if (Object.keys(mem.metadata).length > 0) {
35
- result += `\nMetadata: ${JSON.stringify(mem.metadata)}`;
36
- }
37
- return result;
38
- });
39
- return {
40
- content: [{ type: "text", text: results.join("\n\n---\n\n") }],
41
- };
42
- }
43
- export async function handleGetMemory(args, service) {
44
- const id = args?.id;
45
- const memory = await service.get(id);
46
- if (!memory) {
47
- return {
48
- content: [{ type: "text", text: `Memory ${id} not found` }],
49
- };
50
- }
51
- let result = `ID: ${memory.id}\nContent: ${memory.content}`;
52
- if (Object.keys(memory.metadata).length > 0) {
53
- result += `\nMetadata: ${JSON.stringify(memory.metadata)}`;
54
- }
55
- result += `\nCreated: ${memory.createdAt.toISOString()}`;
56
- result += `\nUpdated: ${memory.updatedAt.toISOString()}`;
57
- if (memory.supersededBy) {
58
- result += `\nSuperseded by: ${memory.supersededBy}`;
59
- }
60
- return {
61
- content: [{ type: "text", text: result }],
62
- };
63
- }
64
- export async function handleToolCall(name, args, service) {
65
- switch (name) {
66
- case "store_memory":
67
- return handleStoreMemory(args, service);
68
- case "delete_memory":
69
- return handleDeleteMemory(args, service);
70
- case "search_memories":
71
- return handleSearchMemories(args, service);
72
- case "get_memory":
73
- return handleGetMemory(args, service);
74
- default:
75
- return {
76
- content: [{ type: "text", text: `Unknown tool: ${name}` }],
77
- isError: true,
78
- };
79
- }
80
- }
81
- //# sourceMappingURL=handlers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../src/mcp/handlers.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAyC,EACzC,OAAsB;IAEtB,MAAM,OAAO,GAAG,IAAI,EAAE,OAAiB,CAAC;IACxC,MAAM,QAAQ,GAAI,IAAI,EAAE,QAAoC,IAAI,EAAE,CAAC;IACnE,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAEtD,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,0BAA0B,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC;KACzE,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,IAAyC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,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC1C,KAAK,eAAe;YAClB,OAAO,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC3C,KAAK,iBAAiB;YACpB,OAAO,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7C,KAAK,YAAY;YACf,OAAO,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACxC;YACE,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,IAAI,EAAE,EAAE,CAAC;gBAC1D,OAAO,EAAE,IAAI;aACd,CAAC;IACN,CAAC;AACH,CAAC"}
@@ -1,5 +0,0 @@
1
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
- import type { MemoryService } from "../services/memory.service.js";
3
- export declare function createServer(memoryService: MemoryService): Server;
4
- export declare function startServer(memoryService: MemoryService): Promise<void>;
5
- //# sourceMappingURL=server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AASnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,wBAAgB,YAAY,CAAC,aAAa,EAAE,aAAa,GAAG,MAAM,CAgBjE;AAED,wBAAsB,WAAW,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAI7E"}
@@ -1,22 +0,0 @@
1
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
- import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
4
- import { tools } from "./tools.js";
5
- import { handleToolCall } from "./handlers.js";
6
- export function createServer(memoryService) {
7
- const server = new Server({ name: "vector-memory-mcp", version: "0.2.0" }, { capabilities: { tools: {} } });
8
- server.setRequestHandler(ListToolsRequestSchema, async () => {
9
- return { tools };
10
- });
11
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
12
- const { name, arguments: args } = request.params;
13
- return handleToolCall(name, args, memoryService);
14
- });
15
- return server;
16
- }
17
- export async function startServer(memoryService) {
18
- const server = createServer(memoryService);
19
- const transport = new StdioServerTransport();
20
- await server.connect(transport);
21
- }
22
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,MAAM,UAAU,YAAY,CAAC,aAA4B;IACvD,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,EAC/C,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAChC,CAAC;IAEF,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QAC1D,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAChE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;QACjD,OAAO,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,aAA4B;IAC5D,MAAM,MAAM,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC"}
@@ -1,7 +0,0 @@
1
- import type { Tool } from "@modelcontextprotocol/sdk/types.js";
2
- export declare const storeMemoryTool: Tool;
3
- export declare const deleteMemoryTool: Tool;
4
- export declare const searchMemoriesTool: Tool;
5
- export declare const getMemoryTool: Tool;
6
- export declare const tools: Tool[];
7
- //# sourceMappingURL=tools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE/D,eAAO,MAAM,eAAe,EAAE,IAkB7B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,IAc9B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,IAmBhC,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,IAa3B,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,IAAI,EAKvB,CAAC"}
package/dist/mcp/tools.js DELETED
@@ -1,73 +0,0 @@
1
- export const storeMemoryTool = {
2
- name: "store_memory",
3
- description: "Store a new memory. Use this to save information for later recall.",
4
- inputSchema: {
5
- type: "object",
6
- properties: {
7
- content: {
8
- type: "string",
9
- description: "The text content to store as a memory",
10
- },
11
- metadata: {
12
- type: "object",
13
- description: "Optional key-value metadata to attach to the memory",
14
- additionalProperties: true,
15
- },
16
- },
17
- required: ["content"],
18
- },
19
- };
20
- export const deleteMemoryTool = {
21
- name: "delete_memory",
22
- description: "Delete a memory by its ID. The memory will be soft-deleted and won't appear in search results.",
23
- inputSchema: {
24
- type: "object",
25
- properties: {
26
- id: {
27
- type: "string",
28
- description: "The ID of the memory to delete",
29
- },
30
- },
31
- required: ["id"],
32
- },
33
- };
34
- export const searchMemoriesTool = {
35
- name: "search_memories",
36
- description: "Search for memories using semantic similarity. Returns the most relevant memories for the given query.",
37
- inputSchema: {
38
- type: "object",
39
- properties: {
40
- query: {
41
- type: "string",
42
- description: "The search query to find relevant memories",
43
- },
44
- limit: {
45
- type: "integer",
46
- description: "Maximum number of results to return (default: 10)",
47
- default: 10,
48
- },
49
- },
50
- required: ["query"],
51
- },
52
- };
53
- export const getMemoryTool = {
54
- name: "get_memory",
55
- description: "Retrieve a specific memory by its ID.",
56
- inputSchema: {
57
- type: "object",
58
- properties: {
59
- id: {
60
- type: "string",
61
- description: "The ID of the memory to retrieve",
62
- },
63
- },
64
- required: ["id"],
65
- },
66
- };
67
- export const tools = [
68
- storeMemoryTool,
69
- deleteMemoryTool,
70
- searchMemoriesTool,
71
- getMemoryTool,
72
- ];
73
- //# sourceMappingURL=tools.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAS;IACnC,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,oEAAoE;IACjF,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uCAAuC;aACrD;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,qDAAqD;gBAClE,oBAAoB,EAAE,IAAI;aAC3B;SACF;QACD,QAAQ,EAAE,CAAC,SAAS,CAAC;KACtB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAS;IACpC,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,gGAAgG;IAClG,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,EAAE,EAAE;gBACF,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,gCAAgC;aAC9C;SACF;QACD,QAAQ,EAAE,CAAC,IAAI,CAAC;KACjB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAS;IACtC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACT,wGAAwG;IAC1G,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,4CAA4C;aAC1D;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,mDAAmD;gBAChE,OAAO,EAAE,EAAE;aACZ;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,CAAC;KACpB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAS;IACjC,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,uCAAuC;IACpD,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,EAAE,EAAE;gBACF,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,kCAAkC;aAChD;SACF;QACD,QAAQ,EAAE,CAAC,IAAI,CAAC;KACjB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAW;IAC3B,eAAe;IACf,gBAAgB;IAChB,kBAAkB;IAClB,aAAa;CACd,CAAC"}
@@ -1,12 +0,0 @@
1
- export declare class EmbeddingsService {
2
- private modelName;
3
- private extractor;
4
- private initPromise;
5
- private _dimension;
6
- constructor(modelName: string, dimension: number);
7
- get dimension(): number;
8
- private init;
9
- embed(text: string): Promise<number[]>;
10
- embedBatch(texts: string[]): Promise<number[][]>;
11
- }
12
- //# sourceMappingURL=embeddings.service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"embeddings.service.d.ts","sourceRoot":"","sources":["../../src/services/embeddings.service.ts"],"names":[],"mappings":"AAEA,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,SAAS,CAA0C;IAC3D,OAAO,CAAC,WAAW,CAA8B;IACjD,OAAO,CAAC,UAAU,CAAS;gBAEf,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAKhD,IAAI,SAAS,IAAI,MAAM,CAEtB;YAEa,IAAI;IAeZ,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAgBtC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;CAiBvD"}
@@ -1,55 +0,0 @@
1
- import { pipeline } from "@huggingface/transformers";
2
- export class EmbeddingsService {
3
- modelName;
4
- extractor = null;
5
- initPromise = null;
6
- _dimension;
7
- constructor(modelName, dimension) {
8
- this.modelName = modelName;
9
- this._dimension = dimension;
10
- }
11
- get dimension() {
12
- return this._dimension;
13
- }
14
- async init() {
15
- if (this.extractor) {
16
- return; // Already initialized
17
- }
18
- if (!this.initPromise) {
19
- this.initPromise = (async () => {
20
- this.extractor = await pipeline("feature-extraction", this.modelName, {
21
- dtype: "fp32",
22
- });
23
- })();
24
- }
25
- await this.initPromise;
26
- }
27
- async embed(text) {
28
- await this.init();
29
- if (!this.extractor) {
30
- throw new Error("Extractor not initialized.");
31
- }
32
- const output = await this.extractor(text, {
33
- pooling: "mean",
34
- normalize: true,
35
- });
36
- // output.tolist() returns number[][] for single input, we want the first element
37
- const embeddings = output.tolist();
38
- return embeddings[0];
39
- }
40
- async embedBatch(texts) {
41
- await this.init();
42
- if (!this.extractor) {
43
- throw new Error("Extractor not initialized.");
44
- }
45
- if (texts.length === 0) {
46
- return [];
47
- }
48
- const output = await this.extractor(texts, {
49
- pooling: "mean",
50
- normalize: true,
51
- });
52
- return output.tolist();
53
- }
54
- }
55
- //# sourceMappingURL=embeddings.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"embeddings.service.js","sourceRoot":"","sources":["../../src/services/embeddings.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkC,MAAM,2BAA2B,CAAC;AAErF,MAAM,OAAO,iBAAiB;IACpB,SAAS,CAAS;IAClB,SAAS,GAAqC,IAAI,CAAC;IACnD,WAAW,GAAyB,IAAI,CAAC;IACzC,UAAU,CAAS;IAE3B,YAAY,SAAiB,EAAE,SAAiB;QAC9C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAEO,KAAK,CAAC,IAAI;QAChB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO,CAAC,sBAAsB;QAChC,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,IAAI,CAAC,WAAW,GAAG,CAAC,KAAK,IAAI,EAAE;gBAC7B,IAAI,CAAC,SAAS,GAAG,MAAM,QAAQ,CAAC,oBAAoB,EAAE,IAAI,CAAC,SAAS,EAAE;oBACpE,KAAK,EAAE,MAAM;iBACd,CAAC,CAAC;YACL,CAAC,CAAC,EAAE,CAAC;QACP,CAAC;QACD,MAAM,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,IAAY;QACtB,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;YACxC,OAAO,EAAE,MAAM;YACf,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;QAEH,iFAAiF;QACjF,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAgB,CAAC;QACjD,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,KAAe;QAC9B,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;YACzC,OAAO,EAAE,MAAM;YACf,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC,MAAM,EAAgB,CAAC;IACvC,CAAC;CACF"}
@@ -1,14 +0,0 @@
1
- import type { Memory } from "../types/memory.js";
2
- import type { MemoryRepository } from "../db/memory.repository.js";
3
- import type { EmbeddingsService } from "./embeddings.service.js";
4
- export declare class MemoryService {
5
- private repository;
6
- private embeddings;
7
- constructor(repository: MemoryRepository, embeddings: EmbeddingsService);
8
- store(content: string, metadata?: Record<string, unknown>): Promise<Memory>;
9
- get(id: string): Promise<Memory | null>;
10
- delete(id: string): Promise<boolean>;
11
- search(query: string, limit?: number): Promise<Memory[]>;
12
- private followSupersessionChain;
13
- }
14
- //# sourceMappingURL=memory.service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory.service.d.ts","sourceRoot":"","sources":["../../src/services/memory.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,qBAAa,aAAa;IAEtB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,UAAU;gBADV,UAAU,EAAE,gBAAgB,EAC5B,UAAU,EAAE,iBAAiB;IAGjC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAmB/E,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIvC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIpC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;YAqCpD,uBAAuB;CAyBtC"}
@@ -1,80 +0,0 @@
1
- import { randomUUID } from "crypto";
2
- import { DELETED_TOMBSTONE, isSuperseded } from "../types/memory.js";
3
- export class MemoryService {
4
- repository;
5
- embeddings;
6
- constructor(repository, embeddings) {
7
- this.repository = repository;
8
- this.embeddings = embeddings;
9
- }
10
- async store(content, metadata = {}) {
11
- const id = randomUUID();
12
- const now = new Date();
13
- const embedding = await this.embeddings.embed(content);
14
- const memory = {
15
- id,
16
- content,
17
- embedding,
18
- metadata,
19
- createdAt: now,
20
- updatedAt: now,
21
- supersededBy: null,
22
- };
23
- await this.repository.insert(memory);
24
- return memory;
25
- }
26
- async get(id) {
27
- return await this.repository.findById(id);
28
- }
29
- async delete(id) {
30
- return await this.repository.markDeleted(id);
31
- }
32
- async search(query, limit = 10) {
33
- const queryEmbedding = await this.embeddings.embed(query);
34
- const fetchLimit = limit * 3;
35
- const rows = await this.repository.findSimilar(queryEmbedding, fetchLimit);
36
- const results = [];
37
- const seenIds = new Set();
38
- for (const row of rows) {
39
- let memory = await this.repository.findById(row.id);
40
- if (!memory) {
41
- continue;
42
- }
43
- if (isSuperseded(memory)) {
44
- memory = await this.followSupersessionChain(row.id);
45
- if (!memory) {
46
- continue;
47
- }
48
- }
49
- if (seenIds.has(memory.id)) {
50
- continue;
51
- }
52
- seenIds.add(memory.id);
53
- results.push(memory);
54
- if (results.length >= limit) {
55
- break;
56
- }
57
- }
58
- return results;
59
- }
60
- async followSupersessionChain(memoryId) {
61
- const visited = new Set();
62
- let currentId = memoryId;
63
- while (currentId && !visited.has(currentId)) {
64
- visited.add(currentId);
65
- const memory = await this.repository.findById(currentId);
66
- if (!memory) {
67
- return null;
68
- }
69
- if (memory.supersededBy === null) {
70
- return memory;
71
- }
72
- if (memory.supersededBy === DELETED_TOMBSTONE) {
73
- return null;
74
- }
75
- currentId = memory.supersededBy;
76
- }
77
- return null;
78
- }
79
- }
80
- //# sourceMappingURL=memory.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory.service.js","sourceRoot":"","sources":["../../src/services/memory.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIrE,MAAM,OAAO,aAAa;IAEd;IACA;IAFV,YACU,UAA4B,EAC5B,UAA6B;QAD7B,eAAU,GAAV,UAAU,CAAkB;QAC5B,eAAU,GAAV,UAAU,CAAmB;IACpC,CAAC;IAEJ,KAAK,CAAC,KAAK,CAAC,OAAe,EAAE,WAAoC,EAAE;QACjE,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC;QACxB,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEvD,MAAM,MAAM,GAAW;YACrB,EAAE;YACF,OAAO;YACP,SAAS;YACT,QAAQ;YACR,SAAS,EAAE,GAAG;YACd,SAAS,EAAE,GAAG;YACd,YAAY,EAAE,IAAI;SACnB,CAAC;QAEF,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAA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EvB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACrB,IAAI,OAAO,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;gBAC5B,MAAM;YACR,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,KAAK,CAAC,uBAAuB,CAAC,QAAgB;QACpD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;QAClC,IAAI,SAAS,GAAkB,QAAQ,CAAC;QAExC,OAAO,SAAS,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5C,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACvB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAEzD,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,IAAI,CAAC;YACd,CAAC;YAED,IAAI,MAAM,CAAC,YAAY,KAAK,IAAI,EAAE,CAAC;gBACjC,OAAO,MAAM,CAAC;YAChB,CAAC;YAED,IAAI,MAAM,CAAC,YAAY,KAAK,iBAAiB,EAAE,CAAC;gBAC9C,OAAO,IAAI,CAAC;YACd,CAAC;YAED,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC;QAClC,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -1,18 +0,0 @@
1
- export declare const DELETED_TOMBSTONE = "DELETED";
2
- export interface Memory {
3
- id: string;
4
- content: string;
5
- embedding: number[];
6
- metadata: Record<string, unknown>;
7
- createdAt: Date;
8
- updatedAt: Date;
9
- supersededBy: string | null;
10
- }
11
- export interface VectorRow {
12
- id: string;
13
- distance: number;
14
- }
15
- export declare function isDeleted(memory: Memory): boolean;
16
- export declare function isSuperseded(memory: Memory): boolean;
17
- export declare function memoryToDict(memory: Memory): Record<string, unknown>;
18
- //# sourceMappingURL=memory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/types/memory.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASpE"}
@@ -1,18 +0,0 @@
1
- export const DELETED_TOMBSTONE = "DELETED";
2
- export function isDeleted(memory) {
3
- return memory.supersededBy === DELETED_TOMBSTONE;
4
- }
5
- export function isSuperseded(memory) {
6
- return memory.supersededBy !== null;
7
- }
8
- export function memoryToDict(memory) {
9
- return {
10
- id: memory.id,
11
- content: memory.content,
12
- metadata: memory.metadata,
13
- createdAt: memory.createdAt.toISOString(),
14
- updatedAt: memory.updatedAt.toISOString(),
15
- supersededBy: memory.supersededBy,
16
- };
17
- }
18
- //# sourceMappingURL=memory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/types/memory.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAiB3C,MAAM,UAAU,SAAS,CAAC,MAAc;IACtC,OAAO,MAAM,CAAC,YAAY,KAAK,iBAAiB,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,OAAO,MAAM,CAAC,YAAY,KAAK,IAAI,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE;QACzC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE;QACzC,YAAY,EAAE,MAAM,CAAC,YAAY;KAClC,CAAC;AACJ,CAAC"}