@agent-relay/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,195 @@
1
+ /**
2
+ * Agent Relay Memory Types
3
+ *
4
+ * Core types for the memory adapter system. Memory adapters provide
5
+ * semantic storage and retrieval of agent learnings and context.
6
+ */
7
+ /**
8
+ * A memory entry stored in the system
9
+ */
10
+ export interface MemoryEntry {
11
+ /** Unique identifier for the memory */
12
+ id: string;
13
+ /** The actual content of the memory */
14
+ content: string;
15
+ /** Timestamp when memory was created */
16
+ createdAt: number;
17
+ /** Timestamp when memory was last accessed */
18
+ lastAccessedAt?: number;
19
+ /** Optional metadata tags */
20
+ tags?: string[];
21
+ /** Source of the memory (e.g., 'agent', 'user', 'session') */
22
+ source?: string;
23
+ /** Agent that created the memory */
24
+ agentId?: string;
25
+ /** Project associated with this memory */
26
+ projectId?: string;
27
+ /** Session ID where memory was created */
28
+ sessionId?: string;
29
+ /** Relevance score (when returned from search) */
30
+ score?: number;
31
+ /** Additional structured metadata */
32
+ metadata?: Record<string, unknown>;
33
+ }
34
+ /**
35
+ * Query options for searching memories
36
+ */
37
+ export interface MemorySearchQuery {
38
+ /** Semantic search query text */
39
+ query: string;
40
+ /** Maximum number of results to return */
41
+ limit?: number;
42
+ /** Minimum relevance score threshold (0-1) */
43
+ minScore?: number;
44
+ /** Filter by tags */
45
+ tags?: string[];
46
+ /** Filter by agent ID */
47
+ agentId?: string;
48
+ /** Filter by project ID */
49
+ projectId?: string;
50
+ /** Filter by memories created after this timestamp */
51
+ since?: number;
52
+ /** Filter by memories created before this timestamp */
53
+ before?: number;
54
+ }
55
+ /**
56
+ * Options for adding a memory
57
+ */
58
+ export interface AddMemoryOptions {
59
+ /** Optional tags for the memory */
60
+ tags?: string[];
61
+ /** Source of the memory */
62
+ source?: string;
63
+ /** Agent creating the memory */
64
+ agentId?: string;
65
+ /** Project context */
66
+ projectId?: string;
67
+ /** Session context */
68
+ sessionId?: string;
69
+ /** Additional metadata */
70
+ metadata?: Record<string, unknown>;
71
+ }
72
+ /**
73
+ * Result of a memory operation
74
+ */
75
+ export interface MemoryResult {
76
+ /** Whether the operation succeeded */
77
+ success: boolean;
78
+ /** ID of the affected memory (if applicable) */
79
+ id?: string;
80
+ /** Error message if operation failed */
81
+ error?: string;
82
+ }
83
+ /**
84
+ * Memory adapter interface
85
+ *
86
+ * All memory backends must implement this interface to be used
87
+ * with the agent-relay memory system.
88
+ */
89
+ export interface MemoryAdapter {
90
+ /** Unique identifier for this adapter type */
91
+ readonly type: string;
92
+ /**
93
+ * Initialize the adapter (connect to backend, etc.)
94
+ */
95
+ init(): Promise<void>;
96
+ /**
97
+ * Add a new memory to the system
98
+ * @param content - The content to remember
99
+ * @param options - Optional metadata and context
100
+ * @returns Result with the new memory's ID
101
+ */
102
+ add(content: string, options?: AddMemoryOptions): Promise<MemoryResult>;
103
+ /**
104
+ * Search for relevant memories
105
+ * @param query - Search parameters
106
+ * @returns Array of matching memories, ordered by relevance
107
+ */
108
+ search(query: MemorySearchQuery): Promise<MemoryEntry[]>;
109
+ /**
110
+ * Get a specific memory by ID
111
+ * @param id - The memory ID
112
+ * @returns The memory entry or null if not found
113
+ */
114
+ get(id: string): Promise<MemoryEntry | null>;
115
+ /**
116
+ * Delete a memory
117
+ * @param id - The memory ID to delete
118
+ * @returns Result indicating success/failure
119
+ */
120
+ delete(id: string): Promise<MemoryResult>;
121
+ /**
122
+ * Update an existing memory
123
+ * @param id - The memory ID
124
+ * @param content - New content
125
+ * @param options - Optional updated metadata
126
+ * @returns Result indicating success/failure
127
+ */
128
+ update?(id: string, content: string, options?: Partial<AddMemoryOptions>): Promise<MemoryResult>;
129
+ /**
130
+ * List recent memories
131
+ * @param options - Filter options
132
+ * @returns Array of recent memories
133
+ */
134
+ list?(options?: {
135
+ limit?: number;
136
+ agentId?: string;
137
+ projectId?: string;
138
+ }): Promise<MemoryEntry[]>;
139
+ /**
140
+ * Clear all memories matching criteria
141
+ * @param options - Filter for what to clear
142
+ */
143
+ clear?(options?: {
144
+ agentId?: string;
145
+ projectId?: string;
146
+ before?: number;
147
+ }): Promise<MemoryResult>;
148
+ /**
149
+ * Get statistics about stored memories
150
+ */
151
+ stats?(): Promise<{
152
+ totalCount: number;
153
+ byAgent?: Record<string, number>;
154
+ byProject?: Record<string, number>;
155
+ }>;
156
+ /**
157
+ * Close the adapter and release resources
158
+ */
159
+ close?(): Promise<void>;
160
+ }
161
+ /**
162
+ * Configuration for memory adapters
163
+ */
164
+ export interface MemoryConfig {
165
+ /** Adapter type: 'inmemory', 'supermemory', 'claude', etc. */
166
+ type: string;
167
+ /** API key for external services */
168
+ apiKey?: string;
169
+ /** API endpoint URL (for supermemory, etc.) */
170
+ endpoint?: string;
171
+ /** Default agent ID to use */
172
+ defaultAgentId?: string;
173
+ /** Default project ID to use */
174
+ defaultProjectId?: string;
175
+ /** Additional adapter-specific options */
176
+ options?: Record<string, unknown>;
177
+ }
178
+ /**
179
+ * Memory service interface for hooks
180
+ *
181
+ * This is a simplified interface exposed to hooks for memory operations.
182
+ */
183
+ export interface MemoryService {
184
+ /** Add a memory */
185
+ add(content: string, options?: AddMemoryOptions): Promise<MemoryResult>;
186
+ /** Search for memories */
187
+ search(query: string | MemorySearchQuery): Promise<MemoryEntry[]>;
188
+ /** Delete a memory */
189
+ delete(id: string): Promise<MemoryResult>;
190
+ /** List recent memories */
191
+ list(limit?: number): Promise<MemoryEntry[]>;
192
+ /** Check if memory service is available */
193
+ isAvailable(): boolean;
194
+ }
195
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,uCAAuC;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,wCAAwC;IAC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2BAA2B;IAC3B,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAC7C,2CAA2C;IAC3C,WAAW,IAAI,OAAO,CAAC;CACxB"}
package/dist/types.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Agent Relay Memory Types
3
+ *
4
+ * Core types for the memory adapter system. Memory adapters provide
5
+ * semantic storage and retrieval of agent learnings and context.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@agent-relay/memory",
3
+ "version": "0.1.0",
4
+ "description": "Semantic memory storage and retrieval system for agent-relay with multiple backend support",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "clean": "rm -rf dist",
21
+ "test": "vitest run",
22
+ "test:watch": "vitest"
23
+ },
24
+ "dependencies": {
25
+ "@agent-relay/hooks": "^0.1.0"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^22.19.3",
29
+ "typescript": "^5.9.3",
30
+ "vitest": "^3.2.4"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ }
35
+ }