agentic-memory 0.1.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.
@@ -0,0 +1,131 @@
1
+ type MemoryType = 'preference' | 'fact' | 'task' | 'episodic' | 'constraint';
2
+ type ImportanceLevel = 'hard' | 'soft' | 'ephemeral';
3
+ type DecayPolicy = 'none' | 'linear' | 'exponential' | 'step';
4
+ interface MemoryEntry {
5
+ /** Unique identifier */
6
+ id: string;
7
+ /** The content of the memory */
8
+ content: string;
9
+ /** Semantic type - determines decay and conflict behavior */
10
+ type: MemoryType;
11
+ /** Namespace for isolation (e.g., 'user:123', 'agent:planner') */
12
+ scope: string;
13
+ /** How important this memory is - 'hard' never decays */
14
+ importance: ImportanceLevel;
15
+ /** Numeric confidence score 0-1 */
16
+ confidence: number;
17
+ /** Embedding vector (populated by retriever) */
18
+ embedding?: number[];
19
+ /** Arbitrary metadata */
20
+ metadata: Record<string, unknown>;
21
+ /** ISO timestamp of creation */
22
+ createdAt: string;
23
+ /** ISO timestamp of last update */
24
+ updatedAt: string;
25
+ /** Version counter for optimistic concurrency */
26
+ version: number;
27
+ }
28
+ type RetrievalSignal = 'similarity' | 'recency' | 'importance' | 'taskRelevance';
29
+ interface RetrievalQuery {
30
+ /** The search query text */
31
+ query: string;
32
+ /** Current task context for task-relevance scoring */
33
+ taskContext?: string;
34
+ /** Scope to search within */
35
+ scope?: string;
36
+ /** Memory types to include */
37
+ types?: MemoryType[];
38
+ /** Signals to combine for ranking */
39
+ signals?: RetrievalSignal[];
40
+ /** Max results to return */
41
+ limit?: number;
42
+ /** Minimum combined score threshold (0-1) */
43
+ threshold?: number;
44
+ }
45
+ interface RetrievalResult {
46
+ entry: MemoryEntry;
47
+ /** Combined score from all signals */
48
+ score: number;
49
+ /** Breakdown of individual signal scores */
50
+ signalScores: Partial<Record<RetrievalSignal, number>>;
51
+ }
52
+ interface ConflictResult {
53
+ /** The new content that conflicts */
54
+ incoming: string;
55
+ /** The stored entry it conflicts with */
56
+ stored: MemoryEntry;
57
+ /** Confidence that this is a real conflict (0-1) */
58
+ confidence: number;
59
+ /** Suggested action */
60
+ action: 'clarify' | 'override' | 'keep_both' | 'ignore';
61
+ /** Reason for the suggestion */
62
+ reason: string;
63
+ }
64
+ interface Checkpoint {
65
+ id: string;
66
+ /** Structured task state */
67
+ taskGraph: TaskNode[];
68
+ /** Compressed summary of conversation so far */
69
+ summary: string;
70
+ /** Key tool outputs to preserve */
71
+ toolOutputs: Record<string, unknown>;
72
+ /** Memories that were in active use */
73
+ activeMemoryIds: string[];
74
+ /** ISO timestamp */
75
+ createdAt: string;
76
+ }
77
+ interface TaskNode {
78
+ id: string;
79
+ description: string;
80
+ status: 'pending' | 'in_progress' | 'done' | 'failed' | 'skipped';
81
+ result?: unknown;
82
+ dependencies: string[];
83
+ }
84
+ interface StorageBackend {
85
+ get(id: string): Promise<MemoryEntry | null>;
86
+ getAll(scope?: string): Promise<MemoryEntry[]>;
87
+ set(entry: MemoryEntry): Promise<void>;
88
+ delete(id: string): Promise<boolean>;
89
+ clear(scope?: string): Promise<void>;
90
+ search(query: RetrievalQuery): Promise<MemoryEntry[]>;
91
+ }
92
+ interface Embedder {
93
+ embed(text: string): Promise<number[]>;
94
+ embedBatch(texts: string[]): Promise<number[][]>;
95
+ dimensions(): number;
96
+ }
97
+ interface DecayConfig {
98
+ /** Policy per memory type */
99
+ policies: Partial<Record<MemoryType, {
100
+ policy: DecayPolicy;
101
+ /** Half-life in milliseconds (for exponential) */
102
+ halfLife?: number;
103
+ /** Linear decay rate per day (0-1) */
104
+ ratePerDay?: number;
105
+ /** Step function: drop to 0 after this many ms */
106
+ maxAge?: number;
107
+ }>>;
108
+ /** Default policy for unlisted types */
109
+ defaultPolicy: DecayPolicy;
110
+ /** Default half-life in ms */
111
+ defaultHalfLife: number;
112
+ }
113
+ interface AgentMemoryConfig {
114
+ /** Storage backend - 'local' uses in-memory Map */
115
+ store?: 'local' | StorageBackend;
116
+ /** Embedder for similarity search */
117
+ embedder?: 'builtin' | Embedder;
118
+ /** Decay configuration */
119
+ decay?: Partial<DecayConfig>;
120
+ /** Auto-checkpoint config */
121
+ checkpoint?: {
122
+ /** Context usage ratio to trigger checkpoint (0-1) */
123
+ threshold?: number;
124
+ /** Max checkpoints to retain */
125
+ maxCheckpoints?: number;
126
+ };
127
+ /** Default scope for entries without explicit scope */
128
+ defaultScope?: string;
129
+ }
130
+
131
+ export type { AgentMemoryConfig as A, ConflictResult as C, DecayConfig as D, Embedder as E, ImportanceLevel as I, MemoryType as M, RetrievalQuery as R, StorageBackend as S, TaskNode as T, MemoryEntry as a, RetrievalResult as b, Checkpoint as c, RetrievalSignal as d, DecayPolicy as e };
@@ -0,0 +1,131 @@
1
+ type MemoryType = 'preference' | 'fact' | 'task' | 'episodic' | 'constraint';
2
+ type ImportanceLevel = 'hard' | 'soft' | 'ephemeral';
3
+ type DecayPolicy = 'none' | 'linear' | 'exponential' | 'step';
4
+ interface MemoryEntry {
5
+ /** Unique identifier */
6
+ id: string;
7
+ /** The content of the memory */
8
+ content: string;
9
+ /** Semantic type - determines decay and conflict behavior */
10
+ type: MemoryType;
11
+ /** Namespace for isolation (e.g., 'user:123', 'agent:planner') */
12
+ scope: string;
13
+ /** How important this memory is - 'hard' never decays */
14
+ importance: ImportanceLevel;
15
+ /** Numeric confidence score 0-1 */
16
+ confidence: number;
17
+ /** Embedding vector (populated by retriever) */
18
+ embedding?: number[];
19
+ /** Arbitrary metadata */
20
+ metadata: Record<string, unknown>;
21
+ /** ISO timestamp of creation */
22
+ createdAt: string;
23
+ /** ISO timestamp of last update */
24
+ updatedAt: string;
25
+ /** Version counter for optimistic concurrency */
26
+ version: number;
27
+ }
28
+ type RetrievalSignal = 'similarity' | 'recency' | 'importance' | 'taskRelevance';
29
+ interface RetrievalQuery {
30
+ /** The search query text */
31
+ query: string;
32
+ /** Current task context for task-relevance scoring */
33
+ taskContext?: string;
34
+ /** Scope to search within */
35
+ scope?: string;
36
+ /** Memory types to include */
37
+ types?: MemoryType[];
38
+ /** Signals to combine for ranking */
39
+ signals?: RetrievalSignal[];
40
+ /** Max results to return */
41
+ limit?: number;
42
+ /** Minimum combined score threshold (0-1) */
43
+ threshold?: number;
44
+ }
45
+ interface RetrievalResult {
46
+ entry: MemoryEntry;
47
+ /** Combined score from all signals */
48
+ score: number;
49
+ /** Breakdown of individual signal scores */
50
+ signalScores: Partial<Record<RetrievalSignal, number>>;
51
+ }
52
+ interface ConflictResult {
53
+ /** The new content that conflicts */
54
+ incoming: string;
55
+ /** The stored entry it conflicts with */
56
+ stored: MemoryEntry;
57
+ /** Confidence that this is a real conflict (0-1) */
58
+ confidence: number;
59
+ /** Suggested action */
60
+ action: 'clarify' | 'override' | 'keep_both' | 'ignore';
61
+ /** Reason for the suggestion */
62
+ reason: string;
63
+ }
64
+ interface Checkpoint {
65
+ id: string;
66
+ /** Structured task state */
67
+ taskGraph: TaskNode[];
68
+ /** Compressed summary of conversation so far */
69
+ summary: string;
70
+ /** Key tool outputs to preserve */
71
+ toolOutputs: Record<string, unknown>;
72
+ /** Memories that were in active use */
73
+ activeMemoryIds: string[];
74
+ /** ISO timestamp */
75
+ createdAt: string;
76
+ }
77
+ interface TaskNode {
78
+ id: string;
79
+ description: string;
80
+ status: 'pending' | 'in_progress' | 'done' | 'failed' | 'skipped';
81
+ result?: unknown;
82
+ dependencies: string[];
83
+ }
84
+ interface StorageBackend {
85
+ get(id: string): Promise<MemoryEntry | null>;
86
+ getAll(scope?: string): Promise<MemoryEntry[]>;
87
+ set(entry: MemoryEntry): Promise<void>;
88
+ delete(id: string): Promise<boolean>;
89
+ clear(scope?: string): Promise<void>;
90
+ search(query: RetrievalQuery): Promise<MemoryEntry[]>;
91
+ }
92
+ interface Embedder {
93
+ embed(text: string): Promise<number[]>;
94
+ embedBatch(texts: string[]): Promise<number[][]>;
95
+ dimensions(): number;
96
+ }
97
+ interface DecayConfig {
98
+ /** Policy per memory type */
99
+ policies: Partial<Record<MemoryType, {
100
+ policy: DecayPolicy;
101
+ /** Half-life in milliseconds (for exponential) */
102
+ halfLife?: number;
103
+ /** Linear decay rate per day (0-1) */
104
+ ratePerDay?: number;
105
+ /** Step function: drop to 0 after this many ms */
106
+ maxAge?: number;
107
+ }>>;
108
+ /** Default policy for unlisted types */
109
+ defaultPolicy: DecayPolicy;
110
+ /** Default half-life in ms */
111
+ defaultHalfLife: number;
112
+ }
113
+ interface AgentMemoryConfig {
114
+ /** Storage backend - 'local' uses in-memory Map */
115
+ store?: 'local' | StorageBackend;
116
+ /** Embedder for similarity search */
117
+ embedder?: 'builtin' | Embedder;
118
+ /** Decay configuration */
119
+ decay?: Partial<DecayConfig>;
120
+ /** Auto-checkpoint config */
121
+ checkpoint?: {
122
+ /** Context usage ratio to trigger checkpoint (0-1) */
123
+ threshold?: number;
124
+ /** Max checkpoints to retain */
125
+ maxCheckpoints?: number;
126
+ };
127
+ /** Default scope for entries without explicit scope */
128
+ defaultScope?: string;
129
+ }
130
+
131
+ export type { AgentMemoryConfig as A, ConflictResult as C, DecayConfig as D, Embedder as E, ImportanceLevel as I, MemoryType as M, RetrievalQuery as R, StorageBackend as S, TaskNode as T, MemoryEntry as a, RetrievalResult as b, Checkpoint as c, RetrievalSignal as d, DecayPolicy as e };
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "agentic-memory",
3
+ "version": "0.1.0",
4
+ "description": "Framework-agnostic memory layer for AI agents. Multi-signal retrieval, conflict detection, typed decay, checkpointing. Zero dependencies.",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ },
14
+ "./adapters/openai": {
15
+ "types": "./dist/adapters/openai.d.ts",
16
+ "import": "./dist/adapters/openai.mjs",
17
+ "require": "./dist/adapters/openai.js"
18
+ },
19
+ "./adapters/voyageai": {
20
+ "types": "./dist/adapters/voyageai.d.ts",
21
+ "import": "./dist/adapters/voyageai.mjs",
22
+ "require": "./dist/adapters/voyageai.js"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "README.md",
28
+ "LICENSE"
29
+ ],
30
+ "scripts": {
31
+ "build": "tsup src/index.ts src/adapters/openai.ts src/adapters/voyageai.ts --format cjs,esm --dts --clean",
32
+ "dev": "tsup src/index.ts src/adapters/openai.ts src/adapters/voyageai.ts --format cjs,esm --dts --watch",
33
+ "test": "vitest run",
34
+ "test:watch": "vitest",
35
+ "lint": "tsc --noEmit",
36
+ "prepublishOnly": "npm run build && npm run test"
37
+ },
38
+ "keywords": [
39
+ "ai",
40
+ "agent",
41
+ "memory",
42
+ "agentic",
43
+ "llm",
44
+ "context-management",
45
+ "multi-agent",
46
+ "state-management",
47
+ "conflict-detection",
48
+ "checkpoint",
49
+ "retrieval",
50
+ "rag",
51
+ "anthropic",
52
+ "openai",
53
+ "langchain",
54
+ "vercel-ai"
55
+ ],
56
+ "author": "genieincodebottle",
57
+ "license": "MIT",
58
+ "repository": {
59
+ "type": "git",
60
+ "url": "https://github.com/genieincodebottle/agentic-memory"
61
+ },
62
+ "homepage": "https://github.com/genieincodebottle/agentic-memory#readme",
63
+ "bugs": {
64
+ "url": "https://github.com/genieincodebottle/agentic-memory/issues"
65
+ },
66
+ "devDependencies": {
67
+ "@rollup/rollup-win32-x64-msvc": "^4.60.1",
68
+ "@types/node": "^25.5.2",
69
+ "tsup": "^8.0.0",
70
+ "typescript": "^5.4.0",
71
+ "vitest": "^1.6.0"
72
+ },
73
+ "engines": {
74
+ "node": ">=18.0.0"
75
+ }
76
+ }