claude-cortex 1.0.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.
- package/README.md +291 -0
- package/dist/api/events.d.ts +134 -0
- package/dist/api/events.d.ts.map +1 -0
- package/dist/api/events.js +73 -0
- package/dist/api/events.js.map +1 -0
- package/dist/api/visualization-server.d.ts +11 -0
- package/dist/api/visualization-server.d.ts.map +1 -0
- package/dist/api/visualization-server.js +653 -0
- package/dist/api/visualization-server.js.map +1 -0
- package/dist/context/project-context.d.ts +57 -0
- package/dist/context/project-context.d.ts.map +1 -0
- package/dist/context/project-context.js +135 -0
- package/dist/context/project-context.js.map +1 -0
- package/dist/database/init.d.ts +49 -0
- package/dist/database/init.d.ts.map +1 -0
- package/dist/database/init.js +336 -0
- package/dist/database/init.js.map +1 -0
- package/dist/embeddings/generator.d.ts +20 -0
- package/dist/embeddings/generator.d.ts.map +1 -0
- package/dist/embeddings/generator.js +77 -0
- package/dist/embeddings/generator.js.map +1 -0
- package/dist/embeddings/index.d.ts +2 -0
- package/dist/embeddings/index.d.ts.map +1 -0
- package/dist/embeddings/index.js +2 -0
- package/dist/embeddings/index.js.map +1 -0
- package/dist/errors.d.ts +74 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +131 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +83 -0
- package/dist/index.js.map +1 -0
- package/dist/memory/activation.d.ts +69 -0
- package/dist/memory/activation.d.ts.map +1 -0
- package/dist/memory/activation.js +168 -0
- package/dist/memory/activation.js.map +1 -0
- package/dist/memory/consolidate.d.ts +96 -0
- package/dist/memory/consolidate.d.ts.map +1 -0
- package/dist/memory/consolidate.js +400 -0
- package/dist/memory/consolidate.js.map +1 -0
- package/dist/memory/contradiction.d.ts +69 -0
- package/dist/memory/contradiction.d.ts.map +1 -0
- package/dist/memory/contradiction.js +286 -0
- package/dist/memory/contradiction.js.map +1 -0
- package/dist/memory/decay.d.ts +62 -0
- package/dist/memory/decay.d.ts.map +1 -0
- package/dist/memory/decay.js +184 -0
- package/dist/memory/decay.js.map +1 -0
- package/dist/memory/salience.d.ts +36 -0
- package/dist/memory/salience.d.ts.map +1 -0
- package/dist/memory/salience.js +200 -0
- package/dist/memory/salience.js.map +1 -0
- package/dist/memory/similarity.d.ts +57 -0
- package/dist/memory/similarity.d.ts.map +1 -0
- package/dist/memory/similarity.js +114 -0
- package/dist/memory/similarity.js.map +1 -0
- package/dist/memory/store.d.ts +170 -0
- package/dist/memory/store.d.ts.map +1 -0
- package/dist/memory/store.js +973 -0
- package/dist/memory/store.js.map +1 -0
- package/dist/memory/types.d.ts +91 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +30 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/server.d.ts +12 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +466 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/context.d.ts +135 -0
- package/dist/tools/context.d.ts.map +1 -0
- package/dist/tools/context.js +273 -0
- package/dist/tools/context.js.map +1 -0
- package/dist/tools/forget.d.ts +53 -0
- package/dist/tools/forget.d.ts.map +1 -0
- package/dist/tools/forget.js +179 -0
- package/dist/tools/forget.js.map +1 -0
- package/dist/tools/recall.d.ts +74 -0
- package/dist/tools/recall.d.ts.map +1 -0
- package/dist/tools/recall.js +140 -0
- package/dist/tools/recall.js.map +1 -0
- package/dist/tools/remember.d.ts +65 -0
- package/dist/tools/remember.d.ts.map +1 -0
- package/dist/tools/remember.js +147 -0
- package/dist/tools/remember.js.map +1 -0
- package/dist/worker/brain-worker.d.ts +100 -0
- package/dist/worker/brain-worker.d.ts.map +1 -0
- package/dist/worker/brain-worker.js +261 -0
- package/dist/worker/brain-worker.js.map +1 -0
- package/dist/worker/link-discovery.d.ts +47 -0
- package/dist/worker/link-discovery.d.ts.map +1 -0
- package/dist/worker/link-discovery.js +103 -0
- package/dist/worker/link-discovery.js.map +1 -0
- package/dist/worker/predictive-consolidation.d.ts +46 -0
- package/dist/worker/predictive-consolidation.d.ts.map +1 -0
- package/dist/worker/predictive-consolidation.js +110 -0
- package/dist/worker/predictive-consolidation.js.map +1 -0
- package/dist/worker/types.d.ts +91 -0
- package/dist/worker/types.d.ts.map +1 -0
- package/dist/worker/types.js +22 -0
- package/dist/worker/types.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate embedding vector for text
|
|
3
|
+
* @param text - Text to embed (title + content recommended)
|
|
4
|
+
* @returns Float32Array of 384 dimensions
|
|
5
|
+
*/
|
|
6
|
+
export declare function generateEmbedding(text: string): Promise<Float32Array>;
|
|
7
|
+
/**
|
|
8
|
+
* Calculate cosine similarity between two embeddings
|
|
9
|
+
* @returns Similarity score 0-1 (1 = identical)
|
|
10
|
+
*/
|
|
11
|
+
export declare function cosineSimilarity(a: Float32Array, b: Float32Array): number;
|
|
12
|
+
/**
|
|
13
|
+
* Check if embedding model is loaded
|
|
14
|
+
*/
|
|
15
|
+
export declare function isModelLoaded(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Preload the model (call during startup if desired)
|
|
18
|
+
*/
|
|
19
|
+
export declare function preloadModel(): Promise<void>;
|
|
20
|
+
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/embeddings/generator.ts"],"names":[],"mappings":"AAiCA;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAY3E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,MAAM,CAmBzE;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAElD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { pipeline, env } from '@xenova/transformers';
|
|
2
|
+
// Configure for local-only operation
|
|
3
|
+
env.allowRemoteModels = true;
|
|
4
|
+
env.allowLocalModels = true;
|
|
5
|
+
let embeddingPipeline = null;
|
|
6
|
+
let isLoading = false;
|
|
7
|
+
let loadPromise = null;
|
|
8
|
+
/**
|
|
9
|
+
* Lazy-load the embedding model
|
|
10
|
+
* Model: all-MiniLM-L6-v2 (22MB, 384 dimensions)
|
|
11
|
+
*/
|
|
12
|
+
async function getEmbeddingPipeline() {
|
|
13
|
+
if (embeddingPipeline)
|
|
14
|
+
return embeddingPipeline;
|
|
15
|
+
if (isLoading && loadPromise) {
|
|
16
|
+
return loadPromise;
|
|
17
|
+
}
|
|
18
|
+
isLoading = true;
|
|
19
|
+
loadPromise = pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2');
|
|
20
|
+
try {
|
|
21
|
+
embeddingPipeline = await loadPromise;
|
|
22
|
+
return embeddingPipeline;
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
isLoading = false;
|
|
26
|
+
loadPromise = null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Generate embedding vector for text
|
|
31
|
+
* @param text - Text to embed (title + content recommended)
|
|
32
|
+
* @returns Float32Array of 384 dimensions
|
|
33
|
+
*/
|
|
34
|
+
export async function generateEmbedding(text) {
|
|
35
|
+
const extractor = await getEmbeddingPipeline();
|
|
36
|
+
// Truncate to ~512 tokens worth (~2000 chars) for model limits
|
|
37
|
+
const truncated = text.slice(0, 2000);
|
|
38
|
+
const output = await extractor(truncated, {
|
|
39
|
+
pooling: 'mean',
|
|
40
|
+
normalize: true,
|
|
41
|
+
});
|
|
42
|
+
return new Float32Array(output.data);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Calculate cosine similarity between two embeddings
|
|
46
|
+
* @returns Similarity score 0-1 (1 = identical)
|
|
47
|
+
*/
|
|
48
|
+
export function cosineSimilarity(a, b) {
|
|
49
|
+
if (a.length !== b.length) {
|
|
50
|
+
throw new Error(`Embedding dimension mismatch: ${a.length} vs ${b.length}`);
|
|
51
|
+
}
|
|
52
|
+
let dotProduct = 0;
|
|
53
|
+
let normA = 0;
|
|
54
|
+
let normB = 0;
|
|
55
|
+
for (let i = 0; i < a.length; i++) {
|
|
56
|
+
dotProduct += a[i] * b[i];
|
|
57
|
+
normA += a[i] * a[i];
|
|
58
|
+
normB += b[i] * b[i];
|
|
59
|
+
}
|
|
60
|
+
const magnitude = Math.sqrt(normA) * Math.sqrt(normB);
|
|
61
|
+
if (magnitude === 0)
|
|
62
|
+
return 0;
|
|
63
|
+
return dotProduct / magnitude;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Check if embedding model is loaded
|
|
67
|
+
*/
|
|
68
|
+
export function isModelLoaded() {
|
|
69
|
+
return embeddingPipeline !== null;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Preload the model (call during startup if desired)
|
|
73
|
+
*/
|
|
74
|
+
export async function preloadModel() {
|
|
75
|
+
await getEmbeddingPipeline();
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/embeddings/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAErD,qCAAqC;AACrC,GAAG,CAAC,iBAAiB,GAAG,IAAI,CAAC;AAC7B,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAAC;AAE5B,IAAI,iBAAiB,GAAQ,IAAI,CAAC;AAClC,IAAI,SAAS,GAAG,KAAK,CAAC;AACtB,IAAI,WAAW,GAAwB,IAAI,CAAC;AAE5C;;;GAGG;AACH,KAAK,UAAU,oBA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,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1B,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACrB,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtD,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAE9B,OAAO,UAAU,GAAG,SAAS,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,iBAAiB,KAAK,IAAI,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,oBAAoB,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/embeddings/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/embeddings/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Error Classes
|
|
3
|
+
*
|
|
4
|
+
* Provides actionable error messages that help users understand
|
|
5
|
+
* what went wrong and how to fix it.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Base class for Claude Memory errors
|
|
9
|
+
*/
|
|
10
|
+
export declare class MemoryError extends Error {
|
|
11
|
+
readonly code: string;
|
|
12
|
+
readonly suggestion: string;
|
|
13
|
+
constructor(message: string, code: string, suggestion: string);
|
|
14
|
+
toUserMessage(): string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Database blocked due to size limits
|
|
18
|
+
*/
|
|
19
|
+
export declare class DatabaseBlockedError extends MemoryError {
|
|
20
|
+
constructor(currentSize: string);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Database size warning (approaching limit)
|
|
24
|
+
*/
|
|
25
|
+
export declare class DatabaseSizeWarning extends MemoryError {
|
|
26
|
+
constructor(currentSize: string);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Memory not found
|
|
30
|
+
*/
|
|
31
|
+
export declare class MemoryNotFoundError extends MemoryError {
|
|
32
|
+
constructor(id: number);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Invalid search query
|
|
36
|
+
*/
|
|
37
|
+
export declare class InvalidQueryError extends MemoryError {
|
|
38
|
+
constructor(query: string, reason: string);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Content too large
|
|
42
|
+
*/
|
|
43
|
+
export declare class ContentTooLargeError extends MemoryError {
|
|
44
|
+
constructor(contentSize: number, maxSize: number);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Bulk delete safety guard
|
|
48
|
+
*/
|
|
49
|
+
export declare class BulkDeleteSafetyError extends MemoryError {
|
|
50
|
+
constructor(count: number);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Database not initialized
|
|
54
|
+
*/
|
|
55
|
+
export declare class DatabaseNotInitializedError extends MemoryError {
|
|
56
|
+
constructor();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Session not found
|
|
60
|
+
*/
|
|
61
|
+
export declare class SessionNotFoundError extends MemoryError {
|
|
62
|
+
constructor(sessionId: number);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Invalid memory relationship
|
|
66
|
+
*/
|
|
67
|
+
export declare class InvalidRelationshipError extends MemoryError {
|
|
68
|
+
constructor(sourceId: number, targetId: number, reason: string);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Format error for MCP tool output
|
|
72
|
+
*/
|
|
73
|
+
export declare function formatErrorForMcp(error: unknown): string;
|
|
74
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,UAAU,EAAE,MAAM,CAAC;gBAEvB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAO7D,aAAa,IAAI,MAAM;CAGxB;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,WAAW;gBACvC,WAAW,EAAE,MAAM;CAQhC;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;gBACtC,WAAW,EAAE,MAAM;CAQhC;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;gBACtC,EAAE,EAAE,MAAM;CAQvB;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;gBACpC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAQ1C;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,WAAW;gBACvC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAUjD;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,WAAW;gBACxC,KAAK,EAAE,MAAM;CAQ1B;AAED;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,WAAW;;CAS3D;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,WAAW;gBACvC,SAAS,EAAE,MAAM;CAQ9B;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,WAAW;gBAC3C,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAQ/D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAwBxD"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Error Classes
|
|
3
|
+
*
|
|
4
|
+
* Provides actionable error messages that help users understand
|
|
5
|
+
* what went wrong and how to fix it.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Base class for Claude Memory errors
|
|
9
|
+
*/
|
|
10
|
+
export class MemoryError extends Error {
|
|
11
|
+
code;
|
|
12
|
+
suggestion;
|
|
13
|
+
constructor(message, code, suggestion) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'MemoryError';
|
|
16
|
+
this.code = code;
|
|
17
|
+
this.suggestion = suggestion;
|
|
18
|
+
}
|
|
19
|
+
toUserMessage() {
|
|
20
|
+
return `${this.message}\n\nSuggestion: ${this.suggestion}`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Database blocked due to size limits
|
|
25
|
+
*/
|
|
26
|
+
export class DatabaseBlockedError extends MemoryError {
|
|
27
|
+
constructor(currentSize) {
|
|
28
|
+
super(`Database blocked: ${currentSize} exceeds the 100MB limit`, 'DB_BLOCKED', 'Run "consolidate" to clean up old memories, or use "forget" to remove memories you no longer need.');
|
|
29
|
+
this.name = 'DatabaseBlockedError';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Database size warning (approaching limit)
|
|
34
|
+
*/
|
|
35
|
+
export class DatabaseSizeWarning extends MemoryError {
|
|
36
|
+
constructor(currentSize) {
|
|
37
|
+
super(`Database size warning: ${currentSize} is approaching the 100MB limit`, 'DB_SIZE_WARNING', 'Consider running "consolidate" to clean up old memories before reaching the limit.');
|
|
38
|
+
this.name = 'DatabaseSizeWarning';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Memory not found
|
|
43
|
+
*/
|
|
44
|
+
export class MemoryNotFoundError extends MemoryError {
|
|
45
|
+
constructor(id) {
|
|
46
|
+
super(`Memory with ID ${id} not found`, 'MEMORY_NOT_FOUND', 'Use "recall" to search for existing memories, or check if the memory was deleted by consolidation.');
|
|
47
|
+
this.name = 'MemoryNotFoundError';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Invalid search query
|
|
52
|
+
*/
|
|
53
|
+
export class InvalidQueryError extends MemoryError {
|
|
54
|
+
constructor(query, reason) {
|
|
55
|
+
super(`Invalid search query "${query}": ${reason}`, 'INVALID_QUERY', 'Try simpler search terms. Avoid special characters like *, ^, ( ). Use quotes around phrases.');
|
|
56
|
+
this.name = 'InvalidQueryError';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Content too large
|
|
61
|
+
*/
|
|
62
|
+
export class ContentTooLargeError extends MemoryError {
|
|
63
|
+
constructor(contentSize, maxSize) {
|
|
64
|
+
const sizeKB = (contentSize / 1024).toFixed(1);
|
|
65
|
+
const maxKB = (maxSize / 1024).toFixed(1);
|
|
66
|
+
super(`Content size (${sizeKB}KB) exceeds maximum allowed (${maxKB}KB)`, 'CONTENT_TOO_LARGE', 'Split large content into multiple smaller memories. Focus on the key points rather than storing everything.');
|
|
67
|
+
this.name = 'ContentTooLargeError';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Bulk delete safety guard
|
|
72
|
+
*/
|
|
73
|
+
export class BulkDeleteSafetyError extends MemoryError {
|
|
74
|
+
constructor(count) {
|
|
75
|
+
super(`Bulk delete blocked: ${count} memories would be deleted`, 'BULK_DELETE_BLOCKED', 'This operation would delete many memories. Use "dryRun: true" first to preview what would be deleted, then set "confirm: true" to proceed.');
|
|
76
|
+
this.name = 'BulkDeleteSafetyError';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Database not initialized
|
|
81
|
+
*/
|
|
82
|
+
export class DatabaseNotInitializedError extends MemoryError {
|
|
83
|
+
constructor() {
|
|
84
|
+
super('Database not initialized', 'DB_NOT_INIT', 'This usually means the MCP server failed to start properly. Check that the database path is accessible and try restarting the server.');
|
|
85
|
+
this.name = 'DatabaseNotInitializedError';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Session not found
|
|
90
|
+
*/
|
|
91
|
+
export class SessionNotFoundError extends MemoryError {
|
|
92
|
+
constructor(sessionId) {
|
|
93
|
+
super(`Session ${sessionId} not found`, 'SESSION_NOT_FOUND', 'The session may have already ended or was never started. Use "start_session" to begin a new session.');
|
|
94
|
+
this.name = 'SessionNotFoundError';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Invalid memory relationship
|
|
99
|
+
*/
|
|
100
|
+
export class InvalidRelationshipError extends MemoryError {
|
|
101
|
+
constructor(sourceId, targetId, reason) {
|
|
102
|
+
super(`Cannot create relationship between memory ${sourceId} and ${targetId}: ${reason}`, 'INVALID_RELATIONSHIP', 'Ensure both memories exist and are not the same memory. Use "get_memory" to verify the memory IDs.');
|
|
103
|
+
this.name = 'InvalidRelationshipError';
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Format error for MCP tool output
|
|
108
|
+
*/
|
|
109
|
+
export function formatErrorForMcp(error) {
|
|
110
|
+
if (error instanceof MemoryError) {
|
|
111
|
+
return error.toUserMessage();
|
|
112
|
+
}
|
|
113
|
+
if (error instanceof Error) {
|
|
114
|
+
// Try to make common errors more helpful
|
|
115
|
+
if (error.message.includes('SQLITE_BUSY')) {
|
|
116
|
+
return 'Database is busy (another operation in progress). Please try again in a moment.';
|
|
117
|
+
}
|
|
118
|
+
if (error.message.includes('SQLITE_LOCKED')) {
|
|
119
|
+
return 'Database is locked. This may happen if multiple processes are accessing the database. Wait a moment and try again.';
|
|
120
|
+
}
|
|
121
|
+
if (error.message.includes('SQLITE_CORRUPT')) {
|
|
122
|
+
return 'Database corruption detected. Try running "consolidate" to repair, or restore from backup.';
|
|
123
|
+
}
|
|
124
|
+
if (error.message.includes('no such table')) {
|
|
125
|
+
return 'Database schema error. The database may need to be reinitialized. Try restarting the MCP server.';
|
|
126
|
+
}
|
|
127
|
+
return `Error: ${error.message}`;
|
|
128
|
+
}
|
|
129
|
+
return 'An unknown error occurred. Please try again or check the server logs.';
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpB,IAAI,CAAS;IACb,UAAU,CAAS;IAEnC,YAAY,OAAe,EAAE,IAAY,EAAE,UAAkB;QAC3D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,aAAa;QACX,OAAO,GAAG,IAAI,CAAC,OAAO,mBAAmB,IAAI,CAAC,UAAU,EAAE,CAAC;IAC7D,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IACnD,YAAY,WAAmB;QAC7B,KAAK,CACH,qBAAqB,WAAW,0BAA0B,EAC1D,YAAY,EACZ,oGAAoG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AAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC7C,OAAO,4FAA4F,CAAC;QACtG,CAAC;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;YAC5C,OAAO,kGAAkG,CAAC;QAC5G,CAAC;QAED,OAAO,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,uEAAuE,CAAC;AACjF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Claude Memory - Brain-like Memory System for Claude Code
|
|
4
|
+
*
|
|
5
|
+
* This server provides persistent, intelligent memory for Claude Code,
|
|
6
|
+
* solving the context compaction and session persistence problems.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* npx claude-cortex # Start MCP server (default)
|
|
10
|
+
* npx claude-cortex --mode mcp # Start MCP server
|
|
11
|
+
* npx claude-cortex --mode api # Start visualization API server
|
|
12
|
+
* npx claude-cortex --mode both # Start both servers
|
|
13
|
+
* npx claude-cortex --db /path/to.db # Custom database path
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;GAYG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Claude Memory - Brain-like Memory System for Claude Code
|
|
4
|
+
*
|
|
5
|
+
* This server provides persistent, intelligent memory for Claude Code,
|
|
6
|
+
* solving the context compaction and session persistence problems.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* npx claude-cortex # Start MCP server (default)
|
|
10
|
+
* npx claude-cortex --mode mcp # Start MCP server
|
|
11
|
+
* npx claude-cortex --mode api # Start visualization API server
|
|
12
|
+
* npx claude-cortex --mode both # Start both servers
|
|
13
|
+
* npx claude-cortex --db /path/to.db # Custom database path
|
|
14
|
+
*/
|
|
15
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
16
|
+
import { createServer } from './server.js';
|
|
17
|
+
import { startVisualizationServer } from './api/visualization-server.js';
|
|
18
|
+
// Parse command line arguments
|
|
19
|
+
function parseArgs() {
|
|
20
|
+
const args = process.argv.slice(2);
|
|
21
|
+
const result = { mode: 'mcp' };
|
|
22
|
+
for (let i = 0; i < args.length; i++) {
|
|
23
|
+
if (args[i] === '--db' && args[i + 1]) {
|
|
24
|
+
result.dbPath = args[i + 1];
|
|
25
|
+
i++;
|
|
26
|
+
}
|
|
27
|
+
else if (args[i] === '--mode' && args[i + 1]) {
|
|
28
|
+
const mode = args[i + 1].toLowerCase();
|
|
29
|
+
if (mode === 'mcp' || mode === 'api' || mode === 'both') {
|
|
30
|
+
result.mode = mode;
|
|
31
|
+
}
|
|
32
|
+
i++;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Start MCP server for Claude Code integration
|
|
39
|
+
*/
|
|
40
|
+
async function startMcpServer(dbPath) {
|
|
41
|
+
// Create the MCP server
|
|
42
|
+
const server = createServer(dbPath);
|
|
43
|
+
// Connect via stdio transport
|
|
44
|
+
const transport = new StdioServerTransport();
|
|
45
|
+
await server.connect(transport);
|
|
46
|
+
// Handle graceful shutdown
|
|
47
|
+
process.on('SIGINT', async () => {
|
|
48
|
+
await server.close();
|
|
49
|
+
process.exit(0);
|
|
50
|
+
});
|
|
51
|
+
process.on('SIGTERM', async () => {
|
|
52
|
+
await server.close();
|
|
53
|
+
process.exit(0);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Main entry point
|
|
58
|
+
*/
|
|
59
|
+
async function main() {
|
|
60
|
+
const { dbPath, mode } = parseArgs();
|
|
61
|
+
if (mode === 'api') {
|
|
62
|
+
// API mode only - for dashboard visualization
|
|
63
|
+
console.log('Starting Claude Memory in API mode...');
|
|
64
|
+
startVisualizationServer(dbPath);
|
|
65
|
+
}
|
|
66
|
+
else if (mode === 'both') {
|
|
67
|
+
// Both modes - API in background, MCP in foreground
|
|
68
|
+
console.log('Starting Claude Memory in both modes...');
|
|
69
|
+
startVisualizationServer(dbPath);
|
|
70
|
+
await startMcpServer(dbPath);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// MCP mode (default) - for Claude Code integration
|
|
74
|
+
await startMcpServer(dbPath);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Run
|
|
78
|
+
main().catch((error) => {
|
|
79
|
+
// Log to stderr to avoid corrupting MCP protocol
|
|
80
|
+
console.error('Failed to start claude-cortex server:', error);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AASzE,+BAA+B;AAC/B,SAAS,SAAS;IAChB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,MAAM,GAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IAErC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,IAAI,CAA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EG;AACH,KAAK,UAAU,IAAI;IACjB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,EAAE,CAAC;IAErC,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACnB,8CAA8C;QAC9C,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;QACrD,wBAAwB,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;SAAM,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QAC3B,oDAAoD;QACpD,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;QACvD,wBAAwB,CAAC,MAAM,CAAC,CAAC;QACjC,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,mDAAmD;QACnD,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC;AAED,MAAM;AACN,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,iDAAiD;IACjD,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAC;IAC9D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spreading Activation System
|
|
3
|
+
*
|
|
4
|
+
* Implements brain-like spreading activation where accessing a memory
|
|
5
|
+
* "primes" related memories, making them easier to recall.
|
|
6
|
+
*
|
|
7
|
+
* EPHEMERAL: This cache is session-only and does not persist to disk.
|
|
8
|
+
* Each MCP server restart starts with a fresh activation state.
|
|
9
|
+
*
|
|
10
|
+
* Based on spreading activation theory in cognitive psychology:
|
|
11
|
+
* - Collins & Loftus (1975) semantic network model
|
|
12
|
+
* - Activation spreads through associative links
|
|
13
|
+
* - Activation decays over time (exponential decay)
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Activate a memory and spread activation to linked memories
|
|
17
|
+
*
|
|
18
|
+
* When a memory is accessed, it becomes fully activated (1.0).
|
|
19
|
+
* Linked memories receive partial activation based on link strength.
|
|
20
|
+
*
|
|
21
|
+
* @param memoryId - The ID of the memory being accessed
|
|
22
|
+
*/
|
|
23
|
+
export declare function activateMemory(memoryId: number): void;
|
|
24
|
+
/**
|
|
25
|
+
* Get the activation boost for a memory in search scoring
|
|
26
|
+
*
|
|
27
|
+
* Returns 0 if memory is not activated or activation has fully decayed.
|
|
28
|
+
* Returns up to MAX_ACTIVATION_BOOST for fully activated memories.
|
|
29
|
+
*
|
|
30
|
+
* @param memoryId - The ID of the memory to check
|
|
31
|
+
* @returns Activation boost (0 to MAX_ACTIVATION_BOOST)
|
|
32
|
+
*/
|
|
33
|
+
export declare function getActivationBoost(memoryId: number): number;
|
|
34
|
+
/**
|
|
35
|
+
* Get current activation level for a memory (for debugging/dashboard)
|
|
36
|
+
*
|
|
37
|
+
* @param memoryId - The ID of the memory to check
|
|
38
|
+
* @returns Current activation level (0-1) or null if not activated
|
|
39
|
+
*/
|
|
40
|
+
export declare function getActivationLevel(memoryId: number): number | null;
|
|
41
|
+
/**
|
|
42
|
+
* Get all currently activated memories with their levels
|
|
43
|
+
* Useful for dashboard visualization
|
|
44
|
+
*
|
|
45
|
+
* @returns Array of {memoryId, activationLevel} for all activated memories
|
|
46
|
+
*/
|
|
47
|
+
export declare function getActiveMemories(): Array<{
|
|
48
|
+
memoryId: number;
|
|
49
|
+
activationLevel: number;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Clear the activation cache
|
|
53
|
+
* Useful for testing or manual reset
|
|
54
|
+
*/
|
|
55
|
+
export declare function clearActivationCache(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Prune stale entries from the activation cache
|
|
58
|
+
* Call periodically to prevent memory bloat
|
|
59
|
+
*/
|
|
60
|
+
export declare function pruneActivationCache(): number;
|
|
61
|
+
/**
|
|
62
|
+
* Get activation cache statistics
|
|
63
|
+
*/
|
|
64
|
+
export declare function getActivationStats(): {
|
|
65
|
+
totalEntries: number;
|
|
66
|
+
activeEntries: number;
|
|
67
|
+
averageActivation: number;
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=activation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activation.d.ts","sourceRoot":"","sources":["../../src/memory/activation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAyBH;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAqCrD;AAaD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAe3D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQlE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,KAAK,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC,CAYxF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAY7C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAWA"}
|