@aeriondyseti/vector-memory-mcp 0.9.0-dev.2 → 0.9.0-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -1
- package/dist/scripts/publish.d.ts +13 -0
- package/dist/scripts/publish.d.ts.map +1 -0
- package/dist/scripts/publish.js +56 -0
- package/dist/scripts/publish.js.map +1 -0
- package/dist/scripts/test-runner.d.ts +9 -0
- package/dist/scripts/test-runner.d.ts.map +1 -0
- package/dist/scripts/test-runner.js +61 -0
- package/dist/scripts/test-runner.js.map +1 -0
- package/dist/scripts/warmup.d.ts +8 -0
- package/dist/scripts/warmup.d.ts.map +1 -0
- package/dist/scripts/warmup.js +61 -0
- package/dist/scripts/warmup.js.map +1 -0
- package/dist/src/config/index.d.ts +23 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/config/index.js +46 -0
- package/dist/src/config/index.js.map +1 -0
- package/dist/src/db/connection.d.ts +3 -0
- package/dist/src/db/connection.d.ts.map +1 -0
- package/dist/src/db/connection.js +10 -0
- package/dist/src/db/connection.js.map +1 -0
- package/dist/src/db/memory.repository.d.ts +13 -0
- package/dist/src/db/memory.repository.d.ts.map +1 -0
- package/dist/src/db/memory.repository.js +97 -0
- package/dist/src/db/memory.repository.js.map +1 -0
- package/dist/src/db/schema.d.ts +4 -0
- package/dist/src/db/schema.d.ts.map +1 -0
- package/dist/src/db/schema.js +12 -0
- package/dist/src/db/schema.js.map +1 -0
- package/dist/src/http/mcp-transport.d.ts +19 -0
- package/dist/src/http/mcp-transport.d.ts.map +1 -0
- package/dist/src/http/mcp-transport.js +191 -0
- package/dist/src/http/mcp-transport.js.map +1 -0
- package/dist/src/http/server.d.ts +12 -0
- package/dist/src/http/server.d.ts.map +1 -0
- package/dist/src/http/server.js +168 -0
- package/dist/src/http/server.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +59 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mcp/handlers.d.ts +11 -0
- package/dist/src/mcp/handlers.d.ts.map +1 -0
- package/dist/src/mcp/handlers.js +175 -0
- package/dist/src/mcp/handlers.js.map +1 -0
- package/dist/src/mcp/server.d.ts +5 -0
- package/dist/src/mcp/server.d.ts.map +1 -0
- package/dist/src/mcp/server.js +22 -0
- package/dist/src/mcp/server.js.map +1 -0
- package/dist/src/mcp/tools.d.ts +9 -0
- package/dist/src/mcp/tools.d.ts.map +1 -0
- package/dist/src/mcp/tools.js +243 -0
- package/dist/src/mcp/tools.js.map +1 -0
- package/dist/src/services/embeddings.service.d.ts +12 -0
- package/dist/src/services/embeddings.service.d.ts.map +1 -0
- package/dist/src/services/embeddings.service.js +37 -0
- package/dist/src/services/embeddings.service.js.map +1 -0
- package/dist/src/services/memory.service.d.ts +31 -0
- package/dist/src/services/memory.service.d.ts.map +1 -0
- package/dist/src/services/memory.service.js +131 -0
- package/dist/src/services/memory.service.js.map +1 -0
- package/dist/src/types/memory.d.ts +17 -0
- package/dist/src/types/memory.d.ts.map +1 -0
- package/dist/src/types/memory.js +15 -0
- package/dist/src/types/memory.js.map +1 -0
- package/package.json +14 -10
- package/src/config/index.ts +0 -75
- package/src/db/connection.ts +0 -11
- package/src/db/memory.repository.ts +0 -115
- package/src/db/schema.ts +0 -34
- package/src/http/mcp-transport.ts +0 -255
- package/src/http/server.ts +0 -190
- package/src/index.ts +0 -70
- package/src/mcp/handlers.ts +0 -248
- package/src/mcp/server.ts +0 -34
- package/src/mcp/tools.ts +0 -254
- package/src/services/embeddings.service.ts +0 -48
- package/src/services/memory.service.ts +0 -185
- package/src/types/memory.ts +0 -31
package/src/mcp/tools.ts
DELETED
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import type { Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
-
|
|
3
|
-
export const storeMemoriesTool: Tool = {
|
|
4
|
-
name: "store_memories",
|
|
5
|
-
description: `Store memories that persist across conversations. Use after making decisions or learning something worth remembering.
|
|
6
|
-
|
|
7
|
-
RULES:
|
|
8
|
-
- 1 concept per memory, 1-3 sentences (20-75 words)
|
|
9
|
-
- Self-contained with explicit subjects (no "it", "this", "the project")
|
|
10
|
-
- Include dates/versions when relevant
|
|
11
|
-
- Be concrete, not vague
|
|
12
|
-
|
|
13
|
-
MEMORY TYPES (use as metadata.type):
|
|
14
|
-
- decision: what was chosen + why ("Chose libSQL over PostgreSQL for vector support and simpler deployment")
|
|
15
|
-
- implementation: what was built + where + patterns used
|
|
16
|
-
- insight: learning + why it matters
|
|
17
|
-
- blocker: problem encountered + resolution
|
|
18
|
-
- next-step: TODO item + suggested approach
|
|
19
|
-
- context: background info + constraints
|
|
20
|
-
|
|
21
|
-
DON'T STORE: machine-specific paths, local env details, ephemeral states, pleasantries
|
|
22
|
-
|
|
23
|
-
GOOD: "Aerion chose libSQL over PostgreSQL for Resonance (Dec 2024) because of native vector support and simpler deployment."
|
|
24
|
-
BAD: "Uses SQLite" (no context, no subject, no reasoning)
|
|
25
|
-
|
|
26
|
-
For long content (>1000 chars), provide embedding_text with a searchable summary.`,
|
|
27
|
-
inputSchema: {
|
|
28
|
-
type: "object",
|
|
29
|
-
properties: {
|
|
30
|
-
memories: {
|
|
31
|
-
type: "array",
|
|
32
|
-
description: "Memories to store.",
|
|
33
|
-
items: {
|
|
34
|
-
type: "object",
|
|
35
|
-
properties: {
|
|
36
|
-
content: {
|
|
37
|
-
type: "string",
|
|
38
|
-
description: "The content to store.",
|
|
39
|
-
},
|
|
40
|
-
embedding_text: {
|
|
41
|
-
type: "string",
|
|
42
|
-
description:
|
|
43
|
-
"Summary for search embedding (required if content >1000 chars).",
|
|
44
|
-
},
|
|
45
|
-
metadata: {
|
|
46
|
-
type: "object",
|
|
47
|
-
description: "Optional key-value metadata.",
|
|
48
|
-
additionalProperties: true,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
required: ["content"],
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
required: ["memories"],
|
|
56
|
-
},
|
|
57
|
-
};;
|
|
58
|
-
|
|
59
|
-
export const deleteMemoriesTool: Tool = {
|
|
60
|
-
name: "delete_memories",
|
|
61
|
-
description:
|
|
62
|
-
"Remove memories that are no longer needed—outdated info, superseded decisions, or incorrect content. " +
|
|
63
|
-
"Deleted memories can be recovered via search_memories with include_deleted: true.",
|
|
64
|
-
inputSchema: {
|
|
65
|
-
type: "object",
|
|
66
|
-
properties: {
|
|
67
|
-
ids: {
|
|
68
|
-
type: "array",
|
|
69
|
-
description: "IDs of memories to delete.",
|
|
70
|
-
items: {
|
|
71
|
-
type: "string",
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
required: ["ids"],
|
|
76
|
-
},
|
|
77
|
-
};;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const updateMemoriesTool: Tool = {
|
|
81
|
-
name: "update_memories",
|
|
82
|
-
description: `Update existing memories in place. Prefer over delete+create when updating the same conceptual item.
|
|
83
|
-
|
|
84
|
-
BEHAVIOR:
|
|
85
|
-
- Fields omitted/null: left untouched
|
|
86
|
-
- Fields provided: completely overwrite existing value (no merge)
|
|
87
|
-
|
|
88
|
-
Use to correct content, refine embedding text, or replace metadata without changing the memory ID.`,
|
|
89
|
-
inputSchema: {
|
|
90
|
-
type: "object",
|
|
91
|
-
properties: {
|
|
92
|
-
updates: {
|
|
93
|
-
type: "array",
|
|
94
|
-
description: "Updates to apply. Each must include id and at least one field to change.",
|
|
95
|
-
items: {
|
|
96
|
-
type: "object",
|
|
97
|
-
properties: {
|
|
98
|
-
id: {
|
|
99
|
-
type: "string",
|
|
100
|
-
description: "ID of memory to update.",
|
|
101
|
-
},
|
|
102
|
-
content: {
|
|
103
|
-
type: "string",
|
|
104
|
-
description: "New content (triggers embedding regeneration).",
|
|
105
|
-
},
|
|
106
|
-
embedding_text: {
|
|
107
|
-
type: "string",
|
|
108
|
-
description: "New embedding summary (triggers embedding regeneration).",
|
|
109
|
-
},
|
|
110
|
-
metadata: {
|
|
111
|
-
type: "object",
|
|
112
|
-
description: "New metadata (replaces existing entirely).",
|
|
113
|
-
additionalProperties: true,
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
required: ["id"],
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
required: ["updates"],
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export const searchMemoriesTool: Tool = {
|
|
125
|
-
name: "search_memories",
|
|
126
|
-
description: `Search stored memories semantically. Use PROACTIVELY—don't wait to be asked.
|
|
127
|
-
|
|
128
|
-
WHEN TO SEARCH:
|
|
129
|
-
- At conversation start / returning to a project
|
|
130
|
-
- Before making decisions (check for prior decisions on same topic)
|
|
131
|
-
- When user references past work ("what did we decide", "as discussed", "remember when")
|
|
132
|
-
- Before suggesting solutions (check if problem was solved before)
|
|
133
|
-
- When debugging (check for prior blockers/resolutions)
|
|
134
|
-
- When uncertain about patterns or preferences
|
|
135
|
-
|
|
136
|
-
When in doubt, search. Missing relevant context is costlier than an extra query.
|
|
137
|
-
|
|
138
|
-
QUERY TIPS:
|
|
139
|
-
- Include project name, technical terms, or domain keywords
|
|
140
|
-
- Search for concepts, not exact phrases
|
|
141
|
-
- Try multiple queries if first doesn't return useful results`,
|
|
142
|
-
inputSchema: {
|
|
143
|
-
type: "object",
|
|
144
|
-
properties: {
|
|
145
|
-
query: {
|
|
146
|
-
type: "string",
|
|
147
|
-
description:
|
|
148
|
-
"Natural language search query. Include relevant keywords, project names, or technical terms.",
|
|
149
|
-
},
|
|
150
|
-
limit: {
|
|
151
|
-
type: "integer",
|
|
152
|
-
description: "Maximum results to return (default: 10).",
|
|
153
|
-
default: 10,
|
|
154
|
-
},
|
|
155
|
-
include_deleted: {
|
|
156
|
-
type: "boolean",
|
|
157
|
-
description: "Include soft-deleted memories in results (default: false). Useful for recovering prior information.",
|
|
158
|
-
default: false,
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
required: ["query"],
|
|
162
|
-
},
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
export const getMemoriesTool: Tool = {
|
|
166
|
-
name: "get_memories",
|
|
167
|
-
description:
|
|
168
|
-
"Retrieve full memory details by ID. Use when you have specific IDs from search results or prior references—otherwise use search_memories.",
|
|
169
|
-
inputSchema: {
|
|
170
|
-
type: "object",
|
|
171
|
-
properties: {
|
|
172
|
-
ids: {
|
|
173
|
-
type: "array",
|
|
174
|
-
description: "Memory IDs to retrieve.",
|
|
175
|
-
items: { type: "string" },
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
required: ["ids"],
|
|
179
|
-
},
|
|
180
|
-
};;
|
|
181
|
-
|
|
182
|
-
export const storeHandoffTool: Tool = {
|
|
183
|
-
name: "store_handoff",
|
|
184
|
-
description: `Save session state for seamless resumption later. Use at end of work sessions or before context switches.
|
|
185
|
-
|
|
186
|
-
Creates a structured snapshot with:
|
|
187
|
-
- summary: 2-3 sentences on goal and current status
|
|
188
|
-
- completed: what got done (include file paths)
|
|
189
|
-
- in_progress_blocked: work in flight or stuck
|
|
190
|
-
- key_decisions: choices made and WHY (crucial for future context)
|
|
191
|
-
- next_steps: concrete, actionable items
|
|
192
|
-
- memory_ids: link to related memories stored this session
|
|
193
|
-
|
|
194
|
-
Retrievable via get_handoff. Only one handoff per project—new handoffs overwrite previous.`,
|
|
195
|
-
inputSchema: {
|
|
196
|
-
type: "object",
|
|
197
|
-
properties: {
|
|
198
|
-
project: { type: "string", description: "Project name." },
|
|
199
|
-
branch: { type: "string", description: "Branch name (optional)." },
|
|
200
|
-
summary: { type: "string", description: "2-3 sentences: primary goal, current status." },
|
|
201
|
-
completed: {
|
|
202
|
-
type: "array",
|
|
203
|
-
items: { type: "string" },
|
|
204
|
-
description: "Completed items (include file paths where relevant).",
|
|
205
|
-
},
|
|
206
|
-
in_progress_blocked: {
|
|
207
|
-
type: "array",
|
|
208
|
-
items: { type: "string" },
|
|
209
|
-
description: "In progress or blocked items.",
|
|
210
|
-
},
|
|
211
|
-
key_decisions: {
|
|
212
|
-
type: "array",
|
|
213
|
-
items: { type: "string" },
|
|
214
|
-
description: "Decisions made and why.",
|
|
215
|
-
},
|
|
216
|
-
next_steps: {
|
|
217
|
-
type: "array",
|
|
218
|
-
items: { type: "string" },
|
|
219
|
-
description: "Concrete next steps.",
|
|
220
|
-
},
|
|
221
|
-
memory_ids: {
|
|
222
|
-
type: "array",
|
|
223
|
-
items: { type: "string" },
|
|
224
|
-
description: "Memory IDs referenced by this handoff.",
|
|
225
|
-
},
|
|
226
|
-
metadata: {
|
|
227
|
-
type: "object",
|
|
228
|
-
description: "Additional metadata.",
|
|
229
|
-
additionalProperties: true,
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
required: ["project", "summary"],
|
|
233
|
-
},
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
export const getHandoffTool: Tool = {
|
|
237
|
-
name: "get_handoff",
|
|
238
|
-
description:
|
|
239
|
-
"Load the current project handoff snapshot. Call at conversation start or when resuming a project.",
|
|
240
|
-
inputSchema: {
|
|
241
|
-
type: "object",
|
|
242
|
-
properties: {},
|
|
243
|
-
},
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
export const tools: Tool[] = [
|
|
247
|
-
storeMemoriesTool,
|
|
248
|
-
updateMemoriesTool,
|
|
249
|
-
deleteMemoriesTool,
|
|
250
|
-
searchMemoriesTool,
|
|
251
|
-
getMemoriesTool,
|
|
252
|
-
storeHandoffTool,
|
|
253
|
-
getHandoffTool,
|
|
254
|
-
];
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { pipeline, type FeatureExtractionPipeline } from "@huggingface/transformers";
|
|
2
|
-
|
|
3
|
-
export class EmbeddingsService {
|
|
4
|
-
private modelName: string;
|
|
5
|
-
private extractor: FeatureExtractionPipeline | null = null;
|
|
6
|
-
private initPromise: Promise<FeatureExtractionPipeline> | null = null;
|
|
7
|
-
private _dimension: number;
|
|
8
|
-
|
|
9
|
-
constructor(modelName: string, dimension: number) {
|
|
10
|
-
this.modelName = modelName;
|
|
11
|
-
this._dimension = dimension;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
get dimension(): number {
|
|
15
|
-
return this._dimension;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
private async getExtractor(): Promise<FeatureExtractionPipeline> {
|
|
19
|
-
if (this.extractor) {
|
|
20
|
-
return this.extractor;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (!this.initPromise) {
|
|
24
|
-
this.initPromise = pipeline(
|
|
25
|
-
"feature-extraction",
|
|
26
|
-
this.modelName,
|
|
27
|
-
{ dtype: "fp32" } as any
|
|
28
|
-
) as Promise<FeatureExtractionPipeline>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
this.extractor = await this.initPromise;
|
|
32
|
-
return this.extractor;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async embed(text: string): Promise<number[]> {
|
|
36
|
-
const extractor = await this.getExtractor();
|
|
37
|
-
const output = await extractor(text, { pooling: "mean", normalize: true });
|
|
38
|
-
return Array.from(output.data as Float32Array);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async embedBatch(texts: string[]): Promise<number[][]> {
|
|
42
|
-
const results: number[][] = [];
|
|
43
|
-
for (const text of texts) {
|
|
44
|
-
results.push(await this.embed(text));
|
|
45
|
-
}
|
|
46
|
-
return results;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "crypto";
|
|
2
|
-
import type { Memory } from "../types/memory.js";
|
|
3
|
-
import { isDeleted } from "../types/memory.js";
|
|
4
|
-
import type { MemoryRepository } from "../db/memory.repository.js";
|
|
5
|
-
import type { EmbeddingsService } from "./embeddings.service.js";
|
|
6
|
-
|
|
7
|
-
export class MemoryService {
|
|
8
|
-
constructor(
|
|
9
|
-
private repository: MemoryRepository,
|
|
10
|
-
private embeddings: EmbeddingsService
|
|
11
|
-
) {}
|
|
12
|
-
|
|
13
|
-
async store(
|
|
14
|
-
content: string,
|
|
15
|
-
metadata: Record<string, unknown> = {},
|
|
16
|
-
embeddingText?: string
|
|
17
|
-
): Promise<Memory> {
|
|
18
|
-
const id = randomUUID();
|
|
19
|
-
const now = new Date();
|
|
20
|
-
const textToEmbed = embeddingText ?? content;
|
|
21
|
-
const embedding = await this.embeddings.embed(textToEmbed);
|
|
22
|
-
|
|
23
|
-
const memory: Memory = {
|
|
24
|
-
id,
|
|
25
|
-
content,
|
|
26
|
-
embedding,
|
|
27
|
-
metadata,
|
|
28
|
-
createdAt: now,
|
|
29
|
-
updatedAt: now,
|
|
30
|
-
supersededBy: null,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
await this.repository.insert(memory);
|
|
34
|
-
return memory;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async get(id: string): Promise<Memory | null> {
|
|
38
|
-
return await this.repository.findById(id);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async delete(id: string): Promise<boolean> {
|
|
42
|
-
return await this.repository.markDeleted(id);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
async update(
|
|
47
|
-
id: string,
|
|
48
|
-
updates: {
|
|
49
|
-
content?: string;
|
|
50
|
-
embeddingText?: string;
|
|
51
|
-
metadata?: Record<string, unknown>;
|
|
52
|
-
}
|
|
53
|
-
): Promise<Memory | null> {
|
|
54
|
-
const existing = await this.repository.findById(id);
|
|
55
|
-
if (!existing) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const newContent = updates.content ?? existing.content;
|
|
60
|
-
const newMetadata = updates.metadata ?? existing.metadata;
|
|
61
|
-
|
|
62
|
-
// Regenerate embedding if content or embeddingText changed
|
|
63
|
-
let newEmbedding = existing.embedding;
|
|
64
|
-
if (updates.content !== undefined || updates.embeddingText !== undefined) {
|
|
65
|
-
const textToEmbed = updates.embeddingText ?? newContent;
|
|
66
|
-
newEmbedding = await this.embeddings.embed(textToEmbed);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const updatedMemory: Memory = {
|
|
70
|
-
...existing,
|
|
71
|
-
content: newContent,
|
|
72
|
-
embedding: newEmbedding,
|
|
73
|
-
metadata: newMetadata,
|
|
74
|
-
updatedAt: new Date(),
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
await this.repository.upsert(updatedMemory);
|
|
78
|
-
return updatedMemory;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async search(
|
|
82
|
-
query: string,
|
|
83
|
-
limit: number = 10,
|
|
84
|
-
includeDeleted: boolean = false
|
|
85
|
-
): Promise<Memory[]> {
|
|
86
|
-
const queryEmbedding = await this.embeddings.embed(query);
|
|
87
|
-
const fetchLimit = limit * 3;
|
|
88
|
-
|
|
89
|
-
const rows = await this.repository.findSimilar(queryEmbedding, fetchLimit);
|
|
90
|
-
|
|
91
|
-
const results: Memory[] = [];
|
|
92
|
-
|
|
93
|
-
for (const row of rows) {
|
|
94
|
-
const memory = await this.repository.findById(row.id);
|
|
95
|
-
|
|
96
|
-
if (!memory) {
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (!includeDeleted && isDeleted(memory)) {
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
results.push(memory);
|
|
105
|
-
if (results.length >= limit) {
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return results;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
private static readonly UUID_ZERO =
|
|
114
|
-
"00000000-0000-0000-0000-000000000000";
|
|
115
|
-
|
|
116
|
-
async storeHandoff(args: {
|
|
117
|
-
project: string;
|
|
118
|
-
branch?: string;
|
|
119
|
-
summary: string;
|
|
120
|
-
completed?: string[];
|
|
121
|
-
in_progress_blocked?: string[];
|
|
122
|
-
key_decisions?: string[];
|
|
123
|
-
next_steps?: string[];
|
|
124
|
-
memory_ids?: string[];
|
|
125
|
-
metadata?: Record<string, unknown>;
|
|
126
|
-
}): Promise<Memory> {
|
|
127
|
-
const now = new Date();
|
|
128
|
-
const date = now.toISOString().slice(0, 10);
|
|
129
|
-
const time = now.toISOString().slice(11, 16);
|
|
130
|
-
|
|
131
|
-
const list = (items: string[] | undefined) => {
|
|
132
|
-
if (!items || items.length === 0) {
|
|
133
|
-
return "- (none)";
|
|
134
|
-
}
|
|
135
|
-
return items.map((i) => `- ${i}`).join("\n");
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const content = `# Handoff - ${args.project}
|
|
139
|
-
**Date:** ${date} ${time} | **Branch:** ${args.branch ?? "unknown"}
|
|
140
|
-
|
|
141
|
-
## Summary
|
|
142
|
-
${args.summary}
|
|
143
|
-
|
|
144
|
-
## Completed
|
|
145
|
-
${list(args.completed)}
|
|
146
|
-
|
|
147
|
-
## In Progress / Blocked
|
|
148
|
-
${list(args.in_progress_blocked)}
|
|
149
|
-
|
|
150
|
-
## Key Decisions
|
|
151
|
-
${list(args.key_decisions)}
|
|
152
|
-
|
|
153
|
-
## Next Steps
|
|
154
|
-
${list(args.next_steps)}
|
|
155
|
-
|
|
156
|
-
## Memory IDs
|
|
157
|
-
${list(args.memory_ids)}`;
|
|
158
|
-
|
|
159
|
-
const metadata: Record<string, unknown> = {
|
|
160
|
-
...(args.metadata ?? {}),
|
|
161
|
-
type: "handoff",
|
|
162
|
-
project: args.project,
|
|
163
|
-
date,
|
|
164
|
-
branch: args.branch ?? "unknown",
|
|
165
|
-
memory_ids: args.memory_ids ?? [],
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const memory: Memory = {
|
|
169
|
-
id: MemoryService.UUID_ZERO,
|
|
170
|
-
content,
|
|
171
|
-
embedding: new Array(this.embeddings.dimension).fill(0),
|
|
172
|
-
metadata,
|
|
173
|
-
createdAt: now,
|
|
174
|
-
updatedAt: now,
|
|
175
|
-
supersededBy: null,
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
await this.repository.upsert(memory);
|
|
179
|
-
return memory;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
async getLatestHandoff(): Promise<Memory | null> {
|
|
183
|
-
return await this.get(MemoryService.UUID_ZERO);
|
|
184
|
-
}
|
|
185
|
-
}
|
package/src/types/memory.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export const DELETED_TOMBSTONE = "DELETED";
|
|
2
|
-
|
|
3
|
-
export interface Memory {
|
|
4
|
-
id: string;
|
|
5
|
-
content: string;
|
|
6
|
-
embedding: number[];
|
|
7
|
-
metadata: Record<string, unknown>;
|
|
8
|
-
createdAt: Date;
|
|
9
|
-
updatedAt: Date;
|
|
10
|
-
supersededBy: string | null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface VectorRow {
|
|
14
|
-
id: string;
|
|
15
|
-
distance: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function isDeleted(memory: Memory): boolean {
|
|
19
|
-
return memory.supersededBy === DELETED_TOMBSTONE;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function memoryToDict(memory: Memory): Record<string, unknown> {
|
|
23
|
-
return {
|
|
24
|
-
id: memory.id,
|
|
25
|
-
content: memory.content,
|
|
26
|
-
metadata: memory.metadata,
|
|
27
|
-
createdAt: memory.createdAt.toISOString(),
|
|
28
|
-
updatedAt: memory.updatedAt.toISOString(),
|
|
29
|
-
supersededBy: memory.supersededBy,
|
|
30
|
-
};
|
|
31
|
-
}
|