@waynesutton/agent-memory 0.0.1
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/.claude/settings.json +9 -0
- package/.claude/settings.local.json +7 -0
- package/AGENTS.md +113 -0
- package/CLAUDE.md +79 -0
- package/README.md +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +192 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/parsers/claude-code.d.ts +3 -0
- package/dist/cli/parsers/claude-code.d.ts.map +1 -0
- package/dist/cli/parsers/claude-code.js +75 -0
- package/dist/cli/parsers/claude-code.js.map +1 -0
- package/dist/cli/parsers/codex.d.ts +3 -0
- package/dist/cli/parsers/codex.d.ts.map +1 -0
- package/dist/cli/parsers/codex.js +42 -0
- package/dist/cli/parsers/codex.js.map +1 -0
- package/dist/cli/parsers/conductor.d.ts +3 -0
- package/dist/cli/parsers/conductor.d.ts.map +1 -0
- package/dist/cli/parsers/conductor.js +43 -0
- package/dist/cli/parsers/conductor.js.map +1 -0
- package/dist/cli/parsers/cursor.d.ts +3 -0
- package/dist/cli/parsers/cursor.d.ts.map +1 -0
- package/dist/cli/parsers/cursor.js +50 -0
- package/dist/cli/parsers/cursor.js.map +1 -0
- package/dist/cli/parsers/index.d.ts +12 -0
- package/dist/cli/parsers/index.d.ts.map +1 -0
- package/dist/cli/parsers/index.js +27 -0
- package/dist/cli/parsers/index.js.map +1 -0
- package/dist/cli/parsers/opencode.d.ts +3 -0
- package/dist/cli/parsers/opencode.d.ts.map +1 -0
- package/dist/cli/parsers/opencode.js +72 -0
- package/dist/cli/parsers/opencode.js.map +1 -0
- package/dist/cli/parsers/parsers.test.d.ts +2 -0
- package/dist/cli/parsers/parsers.test.d.ts.map +1 -0
- package/dist/cli/parsers/parsers.test.js +151 -0
- package/dist/cli/parsers/parsers.test.js.map +1 -0
- package/dist/cli/parsers/pi.d.ts +3 -0
- package/dist/cli/parsers/pi.d.ts.map +1 -0
- package/dist/cli/parsers/pi.js +43 -0
- package/dist/cli/parsers/pi.js.map +1 -0
- package/dist/cli/parsers/types.d.ts +25 -0
- package/dist/cli/parsers/types.d.ts.map +1 -0
- package/dist/cli/parsers/types.js +2 -0
- package/dist/cli/parsers/types.js.map +1 -0
- package/dist/cli/parsers/vscode-copilot.d.ts +3 -0
- package/dist/cli/parsers/vscode-copilot.d.ts.map +1 -0
- package/dist/cli/parsers/vscode-copilot.js +69 -0
- package/dist/cli/parsers/vscode-copilot.js.map +1 -0
- package/dist/cli/parsers/zed.d.ts +3 -0
- package/dist/cli/parsers/zed.d.ts.map +1 -0
- package/dist/cli/parsers/zed.js +43 -0
- package/dist/cli/parsers/zed.js.map +1 -0
- package/dist/cli/sync.d.ts +21 -0
- package/dist/cli/sync.d.ts.map +1 -0
- package/dist/cli/sync.js +78 -0
- package/dist/cli/sync.js.map +1 -0
- package/dist/cli/type-extractor.d.ts +25 -0
- package/dist/cli/type-extractor.d.ts.map +1 -0
- package/dist/cli/type-extractor.js +254 -0
- package/dist/cli/type-extractor.js.map +1 -0
- package/dist/cli/type-extractor.test.d.ts +2 -0
- package/dist/cli/type-extractor.test.d.ts.map +1 -0
- package/dist/cli/type-extractor.test.js +173 -0
- package/dist/cli/type-extractor.test.js.map +1 -0
- package/dist/client/http.d.ts +44 -0
- package/dist/client/http.d.ts.map +1 -0
- package/dist/client/http.js +311 -0
- package/dist/client/http.js.map +1 -0
- package/dist/client/index.d.ts +158 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +256 -0
- package/dist/client/index.js.map +1 -0
- package/dist/component/_generated/api.d.ts +12 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +13 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +18 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +42 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +39 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/actions.d.ts +42 -0
- package/dist/component/actions.d.ts.map +1 -0
- package/dist/component/actions.js +405 -0
- package/dist/component/actions.js.map +1 -0
- package/dist/component/apiKeyMutations.d.ts +29 -0
- package/dist/component/apiKeyMutations.d.ts.map +1 -0
- package/dist/component/apiKeyMutations.js +149 -0
- package/dist/component/apiKeyMutations.js.map +1 -0
- package/dist/component/apiKeyQueries.d.ts +37 -0
- package/dist/component/apiKeyQueries.d.ts.map +1 -0
- package/dist/component/apiKeyQueries.js +127 -0
- package/dist/component/apiKeyQueries.js.map +1 -0
- package/dist/component/checksum.d.ts +6 -0
- package/dist/component/checksum.d.ts.map +1 -0
- package/dist/component/checksum.js +14 -0
- package/dist/component/checksum.js.map +1 -0
- package/dist/component/checksum.test.d.ts +2 -0
- package/dist/component/checksum.test.d.ts.map +1 -0
- package/dist/component/checksum.test.js +27 -0
- package/dist/component/checksum.test.js.map +1 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +4 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/cronActions.d.ts +3 -0
- package/dist/component/cronActions.d.ts.map +1 -0
- package/dist/component/cronActions.js +38 -0
- package/dist/component/cronActions.js.map +1 -0
- package/dist/component/cronQueries.d.ts +6 -0
- package/dist/component/cronQueries.d.ts.map +1 -0
- package/dist/component/cronQueries.js +38 -0
- package/dist/component/cronQueries.js.map +1 -0
- package/dist/component/crons.d.ts +3 -0
- package/dist/component/crons.d.ts.map +1 -0
- package/dist/component/crons.js +18 -0
- package/dist/component/crons.js.map +1 -0
- package/dist/component/format.d.ts +11 -0
- package/dist/component/format.d.ts.map +1 -0
- package/dist/component/format.js +175 -0
- package/dist/component/format.js.map +1 -0
- package/dist/component/format.test.d.ts +2 -0
- package/dist/component/format.test.d.ts.map +1 -0
- package/dist/component/format.test.js +118 -0
- package/dist/component/format.test.js.map +1 -0
- package/dist/component/mutations.d.ts +158 -0
- package/dist/component/mutations.d.ts.map +1 -0
- package/dist/component/mutations.js +745 -0
- package/dist/component/mutations.js.map +1 -0
- package/dist/component/queries.d.ts +94 -0
- package/dist/component/queries.d.ts.map +1 -0
- package/dist/component/queries.js +574 -0
- package/dist/component/queries.js.map +1 -0
- package/dist/component/schema.d.ts +278 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +161 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/mcp/server.d.ts +11 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +571 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/shared.d.ts +126 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +67 -0
- package/dist/shared.js.map +1 -0
- package/dist/test.d.ts +23 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +21 -0
- package/dist/test.js.map +1 -0
- package/eslint.config.js +15 -0
- package/example/convex/convex.config.ts +7 -0
- package/example/convex/memory.ts +129 -0
- package/llms.md +175 -0
- package/llms.txt +126 -0
- package/package.json +72 -0
- package/prds/API-REFERENCE.md +935 -0
- package/prds/README.md +988 -0
- package/prds/SETUP.md +682 -0
- package/src/cli/index.ts +254 -0
- package/src/cli/parsers/claude-code.ts +80 -0
- package/src/cli/parsers/codex.ts +45 -0
- package/src/cli/parsers/conductor.ts +47 -0
- package/src/cli/parsers/cursor.ts +55 -0
- package/src/cli/parsers/index.ts +30 -0
- package/src/cli/parsers/opencode.ts +84 -0
- package/src/cli/parsers/parsers.test.ts +201 -0
- package/src/cli/parsers/pi.ts +47 -0
- package/src/cli/parsers/types.ts +26 -0
- package/src/cli/parsers/vscode-copilot.ts +78 -0
- package/src/cli/parsers/zed.ts +47 -0
- package/src/cli/sync.ts +110 -0
- package/src/cli/type-extractor.test.ts +241 -0
- package/src/cli/type-extractor.ts +331 -0
- package/src/client/http.ts +415 -0
- package/src/client/index.ts +519 -0
- package/src/component/_generated/api.ts +14 -0
- package/src/component/_generated/dataModel.ts +20 -0
- package/src/component/_generated/server.ts +64 -0
- package/src/component/actions.ts +558 -0
- package/src/component/apiKeyMutations.ts +175 -0
- package/src/component/apiKeyQueries.ts +156 -0
- package/src/component/checksum.test.ts +31 -0
- package/src/component/checksum.ts +13 -0
- package/src/component/convex.config.ts +5 -0
- package/src/component/cronActions.ts +52 -0
- package/src/component/cronQueries.ts +42 -0
- package/src/component/crons.ts +34 -0
- package/src/component/format.test.ts +133 -0
- package/src/component/format.ts +232 -0
- package/src/component/mutations.ts +824 -0
- package/src/component/queries.ts +684 -0
- package/src/component/schema.ts +207 -0
- package/src/mcp/server.ts +695 -0
- package/src/shared.ts +251 -0
- package/src/test.ts +32 -0
- package/tsconfig.json +21 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,935 @@
|
|
|
1
|
+
# API Reference — @waynesutton/agent-memory
|
|
2
|
+
|
|
3
|
+
Complete reference for all exports, methods, types, CLI commands, and MCP tools.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Package Exports
|
|
8
|
+
|
|
9
|
+
| Import Path | Description |
|
|
10
|
+
|-------------|-------------|
|
|
11
|
+
| `@waynesutton/agent-memory` | `AgentMemory` class + types |
|
|
12
|
+
| `@waynesutton/agent-memory/http` | `MemoryHttpApi` class for read-only HTTP API |
|
|
13
|
+
| `@waynesutton/agent-memory/convex.config.js` | Convex component config |
|
|
14
|
+
| `@waynesutton/agent-memory/test` | Test helper for convex-test |
|
|
15
|
+
| `@waynesutton/agent-memory/cli` | CLI entry point |
|
|
16
|
+
| `@waynesutton/agent-memory/mcp` | MCP server entry point |
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## AgentMemory Class
|
|
21
|
+
|
|
22
|
+
### Constructor
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
new AgentMemory(component: ComponentApi, config: AgentMemoryConfig)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### AgentMemoryConfig
|
|
29
|
+
|
|
30
|
+
| Property | Type | Required | Default | Description |
|
|
31
|
+
|----------|------|----------|---------|-------------|
|
|
32
|
+
| `projectId` | `string` | Yes | — | Unique project identifier |
|
|
33
|
+
| `defaultScope` | `"project" \| "user" \| "org"` | No | `"project"` | Default scope for operations |
|
|
34
|
+
| `userId` | `string` | No | — | User ID for user-scoped memories |
|
|
35
|
+
| `agentId` | `string` | No | — | Agent identifier (e.g. "claude-code", "cursor-agent") |
|
|
36
|
+
| `sessionId` | `string` | No | — | Session/conversation ID for session-scoped memories |
|
|
37
|
+
| `embeddingApiKey` | `string` | No | — | OpenAI API key for vector search |
|
|
38
|
+
| `embeddingModel` | `string` | No | `"text-embedding-3-small"` | Embedding model to use |
|
|
39
|
+
| `llmApiKey` | `string` | No | — | OpenAI-compatible API key for intelligent ingest |
|
|
40
|
+
| `llmModel` | `string` | No | `"gpt-4.1-nano"` | LLM model for fact extraction |
|
|
41
|
+
| `llmBaseUrl` | `string` | No | `"https://api.openai.com/v1"` | Custom LLM API endpoint |
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### Methods
|
|
46
|
+
|
|
47
|
+
#### Read Operations (query context)
|
|
48
|
+
|
|
49
|
+
##### `list(ctx: QueryCtx, opts?): Promise<Memory[]>`
|
|
50
|
+
|
|
51
|
+
| Option | Type | Default | Description |
|
|
52
|
+
|--------|------|---------|-------------|
|
|
53
|
+
| `memoryType` | `MemoryType` | — | Filter by type |
|
|
54
|
+
| `scope` | `Scope` | config default | Filter by scope |
|
|
55
|
+
| `agentId` | `string` | config default | Filter by agent |
|
|
56
|
+
| `sessionId` | `string` | config default | Filter by session |
|
|
57
|
+
| `source` | `string` | — | Filter by source tool |
|
|
58
|
+
| `tags` | `string[]` | — | Filter by tags (any match) |
|
|
59
|
+
| `minPriority` | `number` | — | Minimum priority 0-1 |
|
|
60
|
+
| `archived` | `boolean` | `false` | Include archived |
|
|
61
|
+
| `createdAfter` | `number` | — | Filter by creation timestamp |
|
|
62
|
+
| `createdBefore` | `number` | — | Filter by creation timestamp |
|
|
63
|
+
| `limit` | `number` | `100` | Max results |
|
|
64
|
+
|
|
65
|
+
##### `get(ctx: QueryCtx, memoryId: string): Promise<Memory | null>`
|
|
66
|
+
|
|
67
|
+
Returns a single memory by ID, or `null` if not found.
|
|
68
|
+
|
|
69
|
+
##### `search(ctx: QueryCtx, query: string, opts?): Promise<Memory[]>`
|
|
70
|
+
|
|
71
|
+
Full-text search on memory content.
|
|
72
|
+
|
|
73
|
+
| Option | Type | Default | Description |
|
|
74
|
+
|--------|------|---------|-------------|
|
|
75
|
+
| `memoryType` | `MemoryType` | — | Filter by type |
|
|
76
|
+
| `scope` | `Scope` | — | Filter by scope |
|
|
77
|
+
| `limit` | `number` | `20` | Max results |
|
|
78
|
+
|
|
79
|
+
##### `getContextBundle(ctx: QueryCtx, opts?): Promise<ContextBundle>`
|
|
80
|
+
|
|
81
|
+
Returns 3-tier progressive context with feedback-boosted priority scoring.
|
|
82
|
+
|
|
83
|
+
| Option | Type | Default | Description |
|
|
84
|
+
|--------|------|---------|-------------|
|
|
85
|
+
| `activePaths` | `string[]` | — | Currently open file paths for relevance matching |
|
|
86
|
+
| `maxTokens` | `number` | — | Token budget (reserved for future use) |
|
|
87
|
+
| `agentId` | `string` | config default | Agent filter |
|
|
88
|
+
|
|
89
|
+
**Returns:**
|
|
90
|
+
```typescript
|
|
91
|
+
{
|
|
92
|
+
pinned: Memory[], // effective priority >= 0.8 (boosted by positive feedback)
|
|
93
|
+
relevant: Memory[], // path-matched against activePaths
|
|
94
|
+
available: Array<{ // everything else (summaries only, sorted by priority)
|
|
95
|
+
_id: string,
|
|
96
|
+
title: string,
|
|
97
|
+
memoryType: MemoryType,
|
|
98
|
+
priority: number,
|
|
99
|
+
}>
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
##### `exportForTool(ctx: QueryCtx, format: ToolFormat, opts?): Promise<ExportedFile[]>`
|
|
104
|
+
|
|
105
|
+
Export memories as tool-native files.
|
|
106
|
+
|
|
107
|
+
| Option | Type | Default | Description |
|
|
108
|
+
|--------|------|---------|-------------|
|
|
109
|
+
| `since` | `number` | — | Only export memories created/synced after this timestamp |
|
|
110
|
+
|
|
111
|
+
##### `history(ctx: QueryCtx, memoryId: string, opts?): Promise<MemoryHistoryEntry[]>`
|
|
112
|
+
|
|
113
|
+
Get the change history (audit trail) of a specific memory.
|
|
114
|
+
|
|
115
|
+
| Option | Type | Default | Description |
|
|
116
|
+
|--------|------|---------|-------------|
|
|
117
|
+
| `limit` | `number` | `50` | Max entries |
|
|
118
|
+
|
|
119
|
+
**Returns:** Array of history entries with `event`, `actor`, `previousContent`, `newContent`, `timestamp`.
|
|
120
|
+
|
|
121
|
+
##### `projectHistory(ctx: QueryCtx, opts?): Promise<MemoryHistoryEntry[]>`
|
|
122
|
+
|
|
123
|
+
Get recent change history across all memories in the project.
|
|
124
|
+
|
|
125
|
+
| Option | Type | Default | Description |
|
|
126
|
+
|--------|------|---------|-------------|
|
|
127
|
+
| `limit` | `number` | `100` | Max entries |
|
|
128
|
+
|
|
129
|
+
##### `getFeedback(ctx: QueryCtx, memoryId: string, opts?): Promise<MemoryFeedbackEntry[]>`
|
|
130
|
+
|
|
131
|
+
Get feedback entries for a memory.
|
|
132
|
+
|
|
133
|
+
| Option | Type | Default | Description |
|
|
134
|
+
|--------|------|---------|-------------|
|
|
135
|
+
| `limit` | `number` | `50` | Max entries |
|
|
136
|
+
|
|
137
|
+
##### `getRelations(ctx: QueryCtx, memoryId: string, opts?): Promise<MemoryRelation[]>`
|
|
138
|
+
|
|
139
|
+
Get relationships of a memory (graph connections).
|
|
140
|
+
|
|
141
|
+
| Option | Type | Default | Description |
|
|
142
|
+
|--------|------|---------|-------------|
|
|
143
|
+
| `direction` | `"from" \| "to" \| "both"` | `"both"` | Direction filter |
|
|
144
|
+
| `relationship` | `string` | — | Filter by relationship type |
|
|
145
|
+
| `limit` | `number` | `50` | Max results |
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
#### Write Operations (mutation context)
|
|
150
|
+
|
|
151
|
+
##### `remember(ctx: MutationCtx, memory): Promise<string>`
|
|
152
|
+
|
|
153
|
+
Save a new memory. Returns the memory ID. Automatically records history.
|
|
154
|
+
|
|
155
|
+
| Field | Type | Required | Description |
|
|
156
|
+
|-------|------|----------|-------------|
|
|
157
|
+
| `title` | `string` | Yes | Short title/slug |
|
|
158
|
+
| `content` | `string` | Yes | Markdown content |
|
|
159
|
+
| `memoryType` | `MemoryType` | Yes | Category |
|
|
160
|
+
| `tags` | `string[]` | No | Searchable tags |
|
|
161
|
+
| `paths` | `string[]` | No | File glob patterns |
|
|
162
|
+
| `priority` | `number` | No | 0-1 (>= 0.8 = pinned) |
|
|
163
|
+
| `source` | `string` | No | Origin tool name |
|
|
164
|
+
| `agentId` | `string` | No | Agent that created this memory |
|
|
165
|
+
| `sessionId` | `string` | No | Session/conversation ID |
|
|
166
|
+
|
|
167
|
+
##### `update(ctx: MutationCtx, memoryId: string, updates): Promise<void>`
|
|
168
|
+
|
|
169
|
+
Partial update. Only provided fields are changed. Records history for content/title changes.
|
|
170
|
+
|
|
171
|
+
| Field | Type | Description |
|
|
172
|
+
|-------|------|-------------|
|
|
173
|
+
| `content` | `string` | New markdown content |
|
|
174
|
+
| `title` | `string` | New title |
|
|
175
|
+
| `tags` | `string[]` | Replace tags |
|
|
176
|
+
| `paths` | `string[]` | Replace paths |
|
|
177
|
+
| `priority` | `number` | New priority |
|
|
178
|
+
| `memoryType` | `MemoryType` | New type |
|
|
179
|
+
|
|
180
|
+
##### `forget(ctx: MutationCtx, memoryId: string): Promise<void>`
|
|
181
|
+
|
|
182
|
+
Archives a memory (soft delete). Records history.
|
|
183
|
+
|
|
184
|
+
##### `restore(ctx: MutationCtx, memoryId: string): Promise<void>`
|
|
185
|
+
|
|
186
|
+
Restores a previously archived memory. Records history.
|
|
187
|
+
|
|
188
|
+
##### `batchArchive(ctx: MutationCtx, memoryIds: string[]): Promise<{ archived: number, failed: number }>`
|
|
189
|
+
|
|
190
|
+
Archive multiple memories at once. Records history for each.
|
|
191
|
+
|
|
192
|
+
##### `batchUpdate(ctx: MutationCtx, updates: Array<{...}>): Promise<{ updated: number, failed: number }>`
|
|
193
|
+
|
|
194
|
+
Update multiple memories at once. Each update object takes the same fields as `update()` plus `memoryId`.
|
|
195
|
+
|
|
196
|
+
##### `addFeedback(ctx: MutationCtx, memoryId: string, sentiment: FeedbackSentiment, opts?): Promise<void>`
|
|
197
|
+
|
|
198
|
+
Rate a memory. Feedback aggregation affects priority scoring in context bundles.
|
|
199
|
+
|
|
200
|
+
| Option | Type | Description |
|
|
201
|
+
|--------|------|-------------|
|
|
202
|
+
| `comment` | `string` | Optional comment explaining the rating |
|
|
203
|
+
| `actor` | `string` | Who gave the feedback (defaults to config agentId/userId) |
|
|
204
|
+
|
|
205
|
+
##### `addRelation(ctx: MutationCtx, fromMemoryId, toMemoryId, relationship, opts?): Promise<string>`
|
|
206
|
+
|
|
207
|
+
Create a directional relationship between two memories. Returns the relation ID.
|
|
208
|
+
|
|
209
|
+
| Option | Type | Description |
|
|
210
|
+
|--------|------|-------------|
|
|
211
|
+
| `confidence` | `number` | Confidence score (0-1) |
|
|
212
|
+
| `createdBy` | `string` | Who created the relation |
|
|
213
|
+
|
|
214
|
+
##### `removeRelation(ctx: MutationCtx, relationId: string): Promise<void>`
|
|
215
|
+
|
|
216
|
+
Remove a relationship between memories.
|
|
217
|
+
|
|
218
|
+
##### `recordAccess(ctx: MutationCtx, memoryIds: string[]): Promise<void>`
|
|
219
|
+
|
|
220
|
+
Record that memories were accessed. Updates `accessCount` and `lastAccessedAt` for relevance tracking.
|
|
221
|
+
|
|
222
|
+
##### `importLocal(ctx: MutationCtx, memories): Promise<ImportResult>`
|
|
223
|
+
|
|
224
|
+
Bulk upsert by `projectId + title`. Compares checksums to skip unchanged. Records history.
|
|
225
|
+
|
|
226
|
+
**Returns:** `{ created: number, updated: number, unchanged: number }`
|
|
227
|
+
|
|
228
|
+
##### `ingestTypes(ctx: MutationCtx, typeMemories): Promise<ImportResult>`
|
|
229
|
+
|
|
230
|
+
Import TypeScript type documentation as reference memories.
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
#### Embedding Operations (action context)
|
|
235
|
+
|
|
236
|
+
##### `embed(ctx: ActionCtx, memoryId: string): Promise<void>`
|
|
237
|
+
|
|
238
|
+
Generate and store an embedding for one memory. Requires `embeddingApiKey` in config.
|
|
239
|
+
|
|
240
|
+
##### `embedAll(ctx: ActionCtx): Promise<{ embedded: number, skipped: number }>`
|
|
241
|
+
|
|
242
|
+
Batch-embed all un-embedded memories. Requires `embeddingApiKey` in config.
|
|
243
|
+
|
|
244
|
+
##### `semanticSearch(ctx: ActionCtx, query: string, opts?): Promise<Memory[]>`
|
|
245
|
+
|
|
246
|
+
Vector similarity search. Falls back to full-text if no API key.
|
|
247
|
+
|
|
248
|
+
| Option | Type | Default | Description |
|
|
249
|
+
|--------|------|---------|-------------|
|
|
250
|
+
| `limit` | `number` | `10` | Max results |
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
#### Intelligent Ingest (action context)
|
|
255
|
+
|
|
256
|
+
##### `ingest(ctx: ActionCtx, content: string, opts?): Promise<IngestResult>`
|
|
257
|
+
|
|
258
|
+
The core "smart memory" feature. Takes raw text and:
|
|
259
|
+
1. Extracts discrete facts/learnings via LLM
|
|
260
|
+
2. Searches existing memories for overlap
|
|
261
|
+
3. Decides per-fact: ADD new, UPDATE existing, DELETE contradicted, or SKIP
|
|
262
|
+
4. Returns a structured changelog
|
|
263
|
+
|
|
264
|
+
Requires `llmApiKey` in config.
|
|
265
|
+
|
|
266
|
+
| Option | Type | Default | Description |
|
|
267
|
+
|--------|------|---------|-------------|
|
|
268
|
+
| `scope` | `Scope` | config default | Scope for new memories |
|
|
269
|
+
| `agentId` | `string` | config default | Agent performing the ingest |
|
|
270
|
+
| `sessionId` | `string` | config default | Session/conversation ID |
|
|
271
|
+
| `customExtractionPrompt` | `string` | — | Override fact extraction prompt |
|
|
272
|
+
| `customUpdatePrompt` | `string` | — | Override update decision prompt |
|
|
273
|
+
|
|
274
|
+
**Returns:**
|
|
275
|
+
```typescript
|
|
276
|
+
{
|
|
277
|
+
results: Array<{
|
|
278
|
+
memoryId: string,
|
|
279
|
+
content: string,
|
|
280
|
+
event: "added" | "updated" | "deleted" | "skipped",
|
|
281
|
+
previousContent?: string,
|
|
282
|
+
}>,
|
|
283
|
+
totalProcessed: number,
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
#### API Key Management (mutation/query context)
|
|
290
|
+
|
|
291
|
+
##### `createApiKey(ctx: MutationCtx, opts): Promise<ApiKeyCreateResult>`
|
|
292
|
+
|
|
293
|
+
Create an API key for the read-only HTTP API. The plaintext key is only returned once.
|
|
294
|
+
|
|
295
|
+
| Option | Type | Required | Description |
|
|
296
|
+
|--------|------|----------|-------------|
|
|
297
|
+
| `name` | `string` | Yes | Human-readable label |
|
|
298
|
+
| `permissions` | `string[]` | Yes | Allowed endpoints: `"list"`, `"get"`, `"search"`, `"context"`, `"export"`, `"history"`, `"relations"` |
|
|
299
|
+
| `rateLimitOverride` | `{ requestsPerWindow: number, windowMs: number }` | No | Override default rate limit |
|
|
300
|
+
| `expiresAt` | `number` | No | Expiration timestamp (ms) |
|
|
301
|
+
|
|
302
|
+
**Returns:**
|
|
303
|
+
```typescript
|
|
304
|
+
{
|
|
305
|
+
key: string, // plaintext key (am_<40 chars>) — only returned once
|
|
306
|
+
keyHash: string, // stored hash for future lookups
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
##### `revokeApiKey(ctx: MutationCtx, keyHash: string): Promise<void>`
|
|
311
|
+
|
|
312
|
+
Revoke an API key. Immediately invalidates all future requests using this key.
|
|
313
|
+
|
|
314
|
+
##### `listApiKeys(ctx: QueryCtx): Promise<ApiKeyInfo[]>`
|
|
315
|
+
|
|
316
|
+
List all non-revoked API keys for the project. Never exposes plaintext keys.
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## MemoryHttpApi Class
|
|
321
|
+
|
|
322
|
+
Read-only HTTP API with bearer token authentication and rate limiting. The component cannot expose HTTP routes directly — this class generates `httpAction` handlers that the consuming app mounts on its own `httpRouter`.
|
|
323
|
+
|
|
324
|
+
### Constructor
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
import { MemoryHttpApi } from "@waynesutton/agent-memory/http";
|
|
328
|
+
|
|
329
|
+
const memoryApi = new MemoryHttpApi(components.agentMemory, {
|
|
330
|
+
corsOrigins: ["https://myapp.com"], // optional, defaults to ["*"]
|
|
331
|
+
});
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### `mount(http: HttpRouter, prefix: string): void`
|
|
335
|
+
|
|
336
|
+
Registers all read-only endpoints on the given router.
|
|
337
|
+
|
|
338
|
+
```typescript
|
|
339
|
+
// convex/http.ts
|
|
340
|
+
import { httpRouter } from "convex/server";
|
|
341
|
+
import { MemoryHttpApi } from "@waynesutton/agent-memory/http";
|
|
342
|
+
import { components } from "./_generated/api";
|
|
343
|
+
|
|
344
|
+
const http = httpRouter();
|
|
345
|
+
const memoryApi = new MemoryHttpApi(components.agentMemory);
|
|
346
|
+
memoryApi.mount(http, "/api/memory");
|
|
347
|
+
export default http;
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Endpoints
|
|
351
|
+
|
|
352
|
+
All endpoints require `Authorization: Bearer am_<key>` header.
|
|
353
|
+
|
|
354
|
+
| Method | Path | Permission | Description |
|
|
355
|
+
|--------|------|------------|-------------|
|
|
356
|
+
| GET | `{prefix}/list` | `list` | List memories with query param filters |
|
|
357
|
+
| GET | `{prefix}/get?id=<memoryId>` | `get` | Get single memory |
|
|
358
|
+
| GET | `{prefix}/search?q=<query>` | `search` | Full-text search |
|
|
359
|
+
| GET | `{prefix}/context` | `context` | Progressive context bundle |
|
|
360
|
+
| GET | `{prefix}/export?format=<format>` | `export` | Export in tool format |
|
|
361
|
+
| GET | `{prefix}/history?id=<memoryId>` | `history` | Memory audit trail |
|
|
362
|
+
| GET | `{prefix}/relations?id=<memoryId>` | `relations` | Memory graph connections |
|
|
363
|
+
|
|
364
|
+
All endpoints also respond to OPTIONS for CORS preflight.
|
|
365
|
+
|
|
366
|
+
### Query Parameters
|
|
367
|
+
|
|
368
|
+
#### `/list`
|
|
369
|
+
|
|
370
|
+
| Param | Type | Description |
|
|
371
|
+
|-------|------|-------------|
|
|
372
|
+
| `memoryType` | `string` | Filter by type |
|
|
373
|
+
| `scope` | `string` | Filter by scope |
|
|
374
|
+
| `agentId` | `string` | Filter by agent |
|
|
375
|
+
| `sessionId` | `string` | Filter by session |
|
|
376
|
+
| `source` | `string` | Filter by source tool |
|
|
377
|
+
| `tags` | `string` | Comma-separated tags |
|
|
378
|
+
| `archived` | `"true"` | Include archived |
|
|
379
|
+
| `minPriority` | `number` | Minimum priority |
|
|
380
|
+
| `limit` | `number` | Max results |
|
|
381
|
+
|
|
382
|
+
#### `/search`
|
|
383
|
+
|
|
384
|
+
| Param | Type | Description |
|
|
385
|
+
|-------|------|-------------|
|
|
386
|
+
| `q` | `string` | Search query (required) |
|
|
387
|
+
| `memoryType` | `string` | Filter by type |
|
|
388
|
+
| `scope` | `string` | Filter by scope |
|
|
389
|
+
| `limit` | `number` | Max results |
|
|
390
|
+
|
|
391
|
+
#### `/context`
|
|
392
|
+
|
|
393
|
+
| Param | Type | Description |
|
|
394
|
+
|-------|------|-------------|
|
|
395
|
+
| `scope` | `string` | Scope (default: "project") |
|
|
396
|
+
| `userId` | `string` | User filter |
|
|
397
|
+
| `agentId` | `string` | Agent filter |
|
|
398
|
+
| `activePaths` | `string` | Comma-separated file paths |
|
|
399
|
+
| `maxTokens` | `number` | Token budget |
|
|
400
|
+
|
|
401
|
+
#### `/export`
|
|
402
|
+
|
|
403
|
+
| Param | Type | Description |
|
|
404
|
+
|-------|------|-------------|
|
|
405
|
+
| `format` | `string` | Tool format (required) |
|
|
406
|
+
| `scope` | `string` | Scope filter |
|
|
407
|
+
| `userId` | `string` | User filter |
|
|
408
|
+
| `since` | `number` | Timestamp filter |
|
|
409
|
+
|
|
410
|
+
#### `/history` and `/relations`
|
|
411
|
+
|
|
412
|
+
| Param | Type | Description |
|
|
413
|
+
|-------|------|-------------|
|
|
414
|
+
| `id` | `string` | Memory ID (required) |
|
|
415
|
+
| `limit` | `number` | Max results |
|
|
416
|
+
| `direction` | `string` | Relations only: "from", "to", or "both" |
|
|
417
|
+
| `relationship` | `string` | Relations only: filter by type |
|
|
418
|
+
|
|
419
|
+
### Error Responses
|
|
420
|
+
|
|
421
|
+
| Status | Meaning |
|
|
422
|
+
|--------|---------|
|
|
423
|
+
| 400 | Missing required query parameter |
|
|
424
|
+
| 401 | Missing/invalid/expired/revoked API key |
|
|
425
|
+
| 403 | API key lacks required permission |
|
|
426
|
+
| 404 | Memory not found |
|
|
427
|
+
| 429 | Rate limit exceeded (includes `retryAfterMs`) |
|
|
428
|
+
|
|
429
|
+
### Rate Limiting
|
|
430
|
+
|
|
431
|
+
Rate limits use a fixed-window token bucket (self-contained, no external dependency):
|
|
432
|
+
|
|
433
|
+
- **Default:** 100 requests per 60 seconds
|
|
434
|
+
- **Priority:** per-key override > per-project setting > global default
|
|
435
|
+
- Rate limit state is stored in the `rateLimitTokens` table
|
|
436
|
+
- Old window records are cleaned up by cron
|
|
437
|
+
|
|
438
|
+
---
|
|
439
|
+
|
|
440
|
+
## Types
|
|
441
|
+
|
|
442
|
+
### ApiKeyInfo
|
|
443
|
+
|
|
444
|
+
```typescript
|
|
445
|
+
interface ApiKeyInfo {
|
|
446
|
+
_id: string;
|
|
447
|
+
keyHash: string;
|
|
448
|
+
projectId: string;
|
|
449
|
+
name: string;
|
|
450
|
+
permissions: string[];
|
|
451
|
+
rateLimitOverride?: {
|
|
452
|
+
requestsPerWindow: number;
|
|
453
|
+
windowMs: number;
|
|
454
|
+
};
|
|
455
|
+
lastUsedAt?: number;
|
|
456
|
+
expiresAt?: number;
|
|
457
|
+
revoked: boolean;
|
|
458
|
+
}
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
### ApiKeyCreateResult
|
|
462
|
+
|
|
463
|
+
```typescript
|
|
464
|
+
interface ApiKeyCreateResult {
|
|
465
|
+
key: string; // plaintext key — only returned once
|
|
466
|
+
keyHash: string;
|
|
467
|
+
}
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
### ApiPermission
|
|
471
|
+
|
|
472
|
+
```typescript
|
|
473
|
+
type ApiPermission = "list" | "get" | "search" | "context" | "export" | "history" | "relations";
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
### Memory
|
|
477
|
+
|
|
478
|
+
```typescript
|
|
479
|
+
interface Memory {
|
|
480
|
+
_id: string;
|
|
481
|
+
_creationTime: number;
|
|
482
|
+
projectId: string;
|
|
483
|
+
scope: Scope;
|
|
484
|
+
userId?: string;
|
|
485
|
+
agentId?: string;
|
|
486
|
+
sessionId?: string;
|
|
487
|
+
title: string;
|
|
488
|
+
content: string;
|
|
489
|
+
memoryType: MemoryType;
|
|
490
|
+
tags: string[];
|
|
491
|
+
paths?: string[];
|
|
492
|
+
priority?: number;
|
|
493
|
+
source?: string;
|
|
494
|
+
lastSyncedAt?: number;
|
|
495
|
+
checksum: string;
|
|
496
|
+
archived: boolean;
|
|
497
|
+
embeddingId?: string;
|
|
498
|
+
accessCount?: number;
|
|
499
|
+
lastAccessedAt?: number;
|
|
500
|
+
positiveCount?: number;
|
|
501
|
+
negativeCount?: number;
|
|
502
|
+
}
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
### MemoryType
|
|
506
|
+
|
|
507
|
+
```typescript
|
|
508
|
+
type MemoryType = "instruction" | "learning" | "reference" | "feedback" | "journal";
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
### Scope
|
|
512
|
+
|
|
513
|
+
```typescript
|
|
514
|
+
type Scope = "project" | "user" | "org";
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
### ToolFormat
|
|
518
|
+
|
|
519
|
+
```typescript
|
|
520
|
+
type ToolFormat =
|
|
521
|
+
| "claude-code" | "cursor" | "opencode" | "codex"
|
|
522
|
+
| "conductor" | "zed" | "vscode-copilot" | "pi" | "raw";
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
### ContextBundle
|
|
526
|
+
|
|
527
|
+
```typescript
|
|
528
|
+
interface ContextBundle {
|
|
529
|
+
pinned: Memory[];
|
|
530
|
+
relevant: Memory[];
|
|
531
|
+
available: Array<{
|
|
532
|
+
_id: string;
|
|
533
|
+
title: string;
|
|
534
|
+
memoryType: MemoryType;
|
|
535
|
+
priority: number;
|
|
536
|
+
}>;
|
|
537
|
+
}
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
### MemoryHistoryEntry
|
|
541
|
+
|
|
542
|
+
```typescript
|
|
543
|
+
interface MemoryHistoryEntry {
|
|
544
|
+
_id: string;
|
|
545
|
+
_creationTime: number;
|
|
546
|
+
memoryId: string;
|
|
547
|
+
projectId: string;
|
|
548
|
+
previousContent?: string;
|
|
549
|
+
newContent?: string;
|
|
550
|
+
previousTitle?: string;
|
|
551
|
+
newTitle?: string;
|
|
552
|
+
event: "created" | "updated" | "archived" | "restored" | "merged";
|
|
553
|
+
actor: string;
|
|
554
|
+
timestamp: number;
|
|
555
|
+
}
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
### MemoryFeedbackEntry
|
|
559
|
+
|
|
560
|
+
```typescript
|
|
561
|
+
interface MemoryFeedbackEntry {
|
|
562
|
+
_id: string;
|
|
563
|
+
_creationTime: number;
|
|
564
|
+
memoryId: string;
|
|
565
|
+
projectId: string;
|
|
566
|
+
sentiment: "positive" | "negative" | "very_negative";
|
|
567
|
+
comment?: string;
|
|
568
|
+
actor: string;
|
|
569
|
+
timestamp: number;
|
|
570
|
+
}
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
### MemoryRelation
|
|
574
|
+
|
|
575
|
+
```typescript
|
|
576
|
+
interface MemoryRelation {
|
|
577
|
+
_id: string;
|
|
578
|
+
_creationTime: number;
|
|
579
|
+
projectId: string;
|
|
580
|
+
fromMemoryId: string;
|
|
581
|
+
toMemoryId: string;
|
|
582
|
+
relationship: string;
|
|
583
|
+
metadata?: {
|
|
584
|
+
confidence?: number;
|
|
585
|
+
createdBy?: string;
|
|
586
|
+
};
|
|
587
|
+
timestamp: number;
|
|
588
|
+
}
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
### IngestResult
|
|
592
|
+
|
|
593
|
+
```typescript
|
|
594
|
+
interface IngestResult {
|
|
595
|
+
results: Array<{
|
|
596
|
+
memoryId: string;
|
|
597
|
+
content: string;
|
|
598
|
+
event: "added" | "updated" | "deleted" | "skipped";
|
|
599
|
+
previousContent?: string;
|
|
600
|
+
}>;
|
|
601
|
+
totalProcessed: number;
|
|
602
|
+
}
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
### FeedbackSentiment
|
|
606
|
+
|
|
607
|
+
```typescript
|
|
608
|
+
type FeedbackSentiment = "positive" | "negative" | "very_negative";
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
### ExportedFile
|
|
612
|
+
|
|
613
|
+
```typescript
|
|
614
|
+
interface ExportedFile {
|
|
615
|
+
path: string;
|
|
616
|
+
content: string;
|
|
617
|
+
checksum: string;
|
|
618
|
+
}
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
### ImportResult
|
|
622
|
+
|
|
623
|
+
```typescript
|
|
624
|
+
interface ImportResult {
|
|
625
|
+
created: number;
|
|
626
|
+
updated: number;
|
|
627
|
+
unchanged: number;
|
|
628
|
+
}
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
---
|
|
632
|
+
|
|
633
|
+
## CLI Commands
|
|
634
|
+
|
|
635
|
+
All commands require `CONVEX_URL` environment variable.
|
|
636
|
+
|
|
637
|
+
### `agent-memory init`
|
|
638
|
+
|
|
639
|
+
```
|
|
640
|
+
agent-memory init [options]
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
| Option | Default | Description |
|
|
644
|
+
|--------|---------|-------------|
|
|
645
|
+
| `--project <id>` | `"default"` | Project ID |
|
|
646
|
+
| `--name <name>` | project ID | Display name |
|
|
647
|
+
|
|
648
|
+
### `agent-memory push`
|
|
649
|
+
|
|
650
|
+
```
|
|
651
|
+
agent-memory push [options]
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
| Option | Default | Description |
|
|
655
|
+
|--------|---------|-------------|
|
|
656
|
+
| `--project <id>` | `"default"` | Project ID |
|
|
657
|
+
| `--format <format>` | all detected | Specific tool format |
|
|
658
|
+
| `--user <id>` | — | User ID for user-scoped |
|
|
659
|
+
|
|
660
|
+
### `agent-memory pull`
|
|
661
|
+
|
|
662
|
+
```
|
|
663
|
+
agent-memory pull [options]
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
| Option | Default | Description |
|
|
667
|
+
|--------|---------|-------------|
|
|
668
|
+
| `--project <id>` | `"default"` | Project ID |
|
|
669
|
+
| `--format <format>` | `"raw"` | Output format |
|
|
670
|
+
| `--user <id>` | — | User ID for user-scoped |
|
|
671
|
+
|
|
672
|
+
### `agent-memory list`
|
|
673
|
+
|
|
674
|
+
```
|
|
675
|
+
agent-memory list [options]
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
| Option | Default | Description |
|
|
679
|
+
|--------|---------|-------------|
|
|
680
|
+
| `--project <id>` | `"default"` | Project ID |
|
|
681
|
+
| `--type <type>` | — | Filter by memory type |
|
|
682
|
+
|
|
683
|
+
### `agent-memory search <query>`
|
|
684
|
+
|
|
685
|
+
```
|
|
686
|
+
agent-memory search <query> [options]
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
| Option | Default | Description |
|
|
690
|
+
|--------|---------|-------------|
|
|
691
|
+
| `--project <id>` | `"default"` | Project ID |
|
|
692
|
+
| `--limit <n>` | `10` | Max results |
|
|
693
|
+
|
|
694
|
+
### `agent-memory mcp`
|
|
695
|
+
|
|
696
|
+
```
|
|
697
|
+
agent-memory mcp [options]
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
| Option | Default | Description |
|
|
701
|
+
|--------|---------|-------------|
|
|
702
|
+
| `--project <id>` | `"default"` | Project ID |
|
|
703
|
+
| `--read-only` | `false` | Disable write tools |
|
|
704
|
+
| `--disable-tools <list>` | — | Comma-separated tool names |
|
|
705
|
+
| `--embedding-api-key <key>` | — | Enable vector search |
|
|
706
|
+
| `--llm-api-key <key>` | — | Enable intelligent ingest via `memory_ingest` tool |
|
|
707
|
+
| `--llm-model <model>` | `"gpt-4.1-nano"` | LLM model for ingest |
|
|
708
|
+
|
|
709
|
+
---
|
|
710
|
+
|
|
711
|
+
## MCP Tools Reference
|
|
712
|
+
|
|
713
|
+
### memory_remember
|
|
714
|
+
|
|
715
|
+
Save a new memory.
|
|
716
|
+
|
|
717
|
+
| Param | Type | Required | Description |
|
|
718
|
+
|-------|------|----------|-------------|
|
|
719
|
+
| `title` | `string` | Yes | Short title |
|
|
720
|
+
| `content` | `string` | Yes | Markdown content |
|
|
721
|
+
| `memoryType` | `string` | Yes | One of: instruction, learning, reference, feedback, journal |
|
|
722
|
+
| `tags` | `string[]` | No | Tags |
|
|
723
|
+
| `priority` | `number` | No | 0-1 (>= 0.8 = pinned) |
|
|
724
|
+
| `agentId` | `string` | No | Agent that created this |
|
|
725
|
+
| `sessionId` | `string` | No | Session/conversation ID |
|
|
726
|
+
|
|
727
|
+
### memory_recall
|
|
728
|
+
|
|
729
|
+
Search by keyword (full-text).
|
|
730
|
+
|
|
731
|
+
| Param | Type | Required | Description |
|
|
732
|
+
|-------|------|----------|-------------|
|
|
733
|
+
| `query` | `string` | Yes | Search query |
|
|
734
|
+
| `memoryType` | `string` | No | Filter by type |
|
|
735
|
+
| `limit` | `number` | No | Max results |
|
|
736
|
+
|
|
737
|
+
### memory_semantic_recall
|
|
738
|
+
|
|
739
|
+
Search by meaning (vector similarity). Falls back to full-text if no embedding key.
|
|
740
|
+
|
|
741
|
+
| Param | Type | Required | Description |
|
|
742
|
+
|-------|------|----------|-------------|
|
|
743
|
+
| `query` | `string` | Yes | Search query |
|
|
744
|
+
| `limit` | `number` | No | Max results |
|
|
745
|
+
|
|
746
|
+
### memory_list
|
|
747
|
+
|
|
748
|
+
List all memories with filters.
|
|
749
|
+
|
|
750
|
+
| Param | Type | Required | Description |
|
|
751
|
+
|-------|------|----------|-------------|
|
|
752
|
+
| `memoryType` | `string` | No | Filter by type |
|
|
753
|
+
| `minPriority` | `number` | No | Minimum priority |
|
|
754
|
+
| `agentId` | `string` | No | Filter by agent |
|
|
755
|
+
| `sessionId` | `string` | No | Filter by session |
|
|
756
|
+
| `source` | `string` | No | Filter by source tool |
|
|
757
|
+
| `tags` | `string[]` | No | Filter by tags |
|
|
758
|
+
| `limit` | `number` | No | Max results |
|
|
759
|
+
|
|
760
|
+
### memory_context
|
|
761
|
+
|
|
762
|
+
Get context bundle (pinned + relevant memories) for the session.
|
|
763
|
+
|
|
764
|
+
| Param | Type | Required | Description |
|
|
765
|
+
|-------|------|----------|-------------|
|
|
766
|
+
| `activePaths` | `string[]` | No | Currently open files |
|
|
767
|
+
| `maxTokens` | `number` | No | Token budget |
|
|
768
|
+
|
|
769
|
+
### memory_forget
|
|
770
|
+
|
|
771
|
+
Archive a memory.
|
|
772
|
+
|
|
773
|
+
| Param | Type | Required | Description |
|
|
774
|
+
|-------|------|----------|-------------|
|
|
775
|
+
| `memoryId` | `string` | Yes | Memory ID |
|
|
776
|
+
|
|
777
|
+
### memory_restore
|
|
778
|
+
|
|
779
|
+
Restore a previously archived memory.
|
|
780
|
+
|
|
781
|
+
| Param | Type | Required | Description |
|
|
782
|
+
|-------|------|----------|-------------|
|
|
783
|
+
| `memoryId` | `string` | Yes | Memory ID |
|
|
784
|
+
|
|
785
|
+
### memory_update
|
|
786
|
+
|
|
787
|
+
Update an existing memory.
|
|
788
|
+
|
|
789
|
+
| Param | Type | Required | Description |
|
|
790
|
+
|-------|------|----------|-------------|
|
|
791
|
+
| `memoryId` | `string` | Yes | Memory ID |
|
|
792
|
+
| `content` | `string` | No | New content |
|
|
793
|
+
| `title` | `string` | No | New title |
|
|
794
|
+
| `tags` | `string[]` | No | New tags |
|
|
795
|
+
| `priority` | `number` | No | New priority |
|
|
796
|
+
|
|
797
|
+
### memory_history
|
|
798
|
+
|
|
799
|
+
View the change history of a memory (audit trail).
|
|
800
|
+
|
|
801
|
+
| Param | Type | Required | Description |
|
|
802
|
+
|-------|------|----------|-------------|
|
|
803
|
+
| `memoryId` | `string` | Yes | Memory ID |
|
|
804
|
+
| `limit` | `number` | No | Max entries (default 20) |
|
|
805
|
+
|
|
806
|
+
### memory_feedback
|
|
807
|
+
|
|
808
|
+
Rate a memory as helpful or unhelpful. Affects priority scoring.
|
|
809
|
+
|
|
810
|
+
| Param | Type | Required | Description |
|
|
811
|
+
|-------|------|----------|-------------|
|
|
812
|
+
| `memoryId` | `string` | Yes | Memory ID |
|
|
813
|
+
| `sentiment` | `string` | Yes | "positive", "negative", or "very_negative" |
|
|
814
|
+
| `comment` | `string` | No | Explanation |
|
|
815
|
+
|
|
816
|
+
### memory_relate
|
|
817
|
+
|
|
818
|
+
Create a relationship between two memories.
|
|
819
|
+
|
|
820
|
+
| Param | Type | Required | Description |
|
|
821
|
+
|-------|------|----------|-------------|
|
|
822
|
+
| `fromMemoryId` | `string` | Yes | Source memory ID |
|
|
823
|
+
| `toMemoryId` | `string` | Yes | Target memory ID |
|
|
824
|
+
| `relationship` | `string` | Yes | e.g. "contradicts", "extends", "replaces", "related_to" |
|
|
825
|
+
|
|
826
|
+
### memory_relations
|
|
827
|
+
|
|
828
|
+
View relationships of a memory (graph connections).
|
|
829
|
+
|
|
830
|
+
| Param | Type | Required | Description |
|
|
831
|
+
|-------|------|----------|-------------|
|
|
832
|
+
| `memoryId` | `string` | Yes | Memory ID |
|
|
833
|
+
| `relationship` | `string` | No | Filter by relationship type |
|
|
834
|
+
| `direction` | `string` | No | "from", "to", or "both" |
|
|
835
|
+
|
|
836
|
+
### memory_batch_archive
|
|
837
|
+
|
|
838
|
+
Archive multiple memories at once.
|
|
839
|
+
|
|
840
|
+
| Param | Type | Required | Description |
|
|
841
|
+
|-------|------|----------|-------------|
|
|
842
|
+
| `memoryIds` | `string[]` | Yes | Memory IDs to archive |
|
|
843
|
+
|
|
844
|
+
### memory_ingest
|
|
845
|
+
|
|
846
|
+
Intelligently extract memories from raw text. Requires `--llm-api-key`.
|
|
847
|
+
|
|
848
|
+
| Param | Type | Required | Description |
|
|
849
|
+
|-------|------|----------|-------------|
|
|
850
|
+
| `content` | `string` | Yes | Raw text to extract memories from |
|
|
851
|
+
| `agentId` | `string` | No | Agent performing the ingest |
|
|
852
|
+
| `sessionId` | `string` | No | Session/conversation ID |
|
|
853
|
+
|
|
854
|
+
---
|
|
855
|
+
|
|
856
|
+
## MCP Resources
|
|
857
|
+
|
|
858
|
+
### `memory://project/{projectId}/pinned`
|
|
859
|
+
|
|
860
|
+
Returns all high-priority (>= 0.8) memories as markdown. Auto-loaded by clients that support MCP resources.
|
|
861
|
+
|
|
862
|
+
**MIME type:** `text/markdown`
|
|
863
|
+
|
|
864
|
+
---
|
|
865
|
+
|
|
866
|
+
## Convex Component Functions
|
|
867
|
+
|
|
868
|
+
These are the raw Convex functions exposed by the component. Typically accessed through the `AgentMemory` client class, but can be called directly via `ctx.runQuery(components.agentMemory.queries.list, {...})`.
|
|
869
|
+
|
|
870
|
+
### Queries
|
|
871
|
+
|
|
872
|
+
| Function | Description |
|
|
873
|
+
|----------|-------------|
|
|
874
|
+
| `queries.list` | List memories with filters (agentId, sessionId, source, tags, date range) |
|
|
875
|
+
| `queries.get` | Get single memory by ID |
|
|
876
|
+
| `queries.search` | Full-text search |
|
|
877
|
+
| `queries.getContextBundle` | 3-tier progressive context with feedback-boosted scoring |
|
|
878
|
+
| `queries.exportForTool` | Format conversion for tool export |
|
|
879
|
+
| `queries.history` | Change history for a specific memory |
|
|
880
|
+
| `queries.projectHistory` | Recent changes across entire project |
|
|
881
|
+
| `queries.getFeedback` | Feedback entries for a memory |
|
|
882
|
+
| `queries.getRelations` | Graph relationships of a memory |
|
|
883
|
+
|
|
884
|
+
### Mutations
|
|
885
|
+
|
|
886
|
+
| Function | Description |
|
|
887
|
+
|----------|-------------|
|
|
888
|
+
| `mutations.create` | Create a memory (with history tracking) |
|
|
889
|
+
| `mutations.update` | Partial update (with history tracking) |
|
|
890
|
+
| `mutations.archive` | Soft delete (with history tracking) |
|
|
891
|
+
| `mutations.restore` | Un-archive a memory |
|
|
892
|
+
| `mutations.batchArchive` | Archive multiple memories |
|
|
893
|
+
| `mutations.batchUpdate` | Update multiple memories |
|
|
894
|
+
| `mutations.addFeedback` | Rate a memory (positive/negative) |
|
|
895
|
+
| `mutations.addRelation` | Create relationship between memories |
|
|
896
|
+
| `mutations.removeRelation` | Remove a relationship |
|
|
897
|
+
| `mutations.recordAccess` | Track memory access for relevance |
|
|
898
|
+
| `mutations.importFromLocal` | Bulk upsert |
|
|
899
|
+
| `mutations.upsertProject` | Register/update project (with custom prompts, decay settings) |
|
|
900
|
+
| `mutations.recordSync` | Log sync event |
|
|
901
|
+
| `mutations.storeEmbedding` | Store vector embedding |
|
|
902
|
+
|
|
903
|
+
### Actions
|
|
904
|
+
|
|
905
|
+
| Function | Description |
|
|
906
|
+
|----------|-------------|
|
|
907
|
+
| `actions.generateEmbedding` | Generate embedding for one memory |
|
|
908
|
+
| `actions.semanticSearch` | Vector similarity search |
|
|
909
|
+
| `actions.embedAll` | Batch embed all un-embedded memories |
|
|
910
|
+
| `actions.ingest` | Intelligent fact extraction + dedup pipeline |
|
|
911
|
+
|
|
912
|
+
### API Key Queries
|
|
913
|
+
|
|
914
|
+
| Function | Description |
|
|
915
|
+
|----------|-------------|
|
|
916
|
+
| `apiKeyQueries.validateApiKey` | Validate a bearer token and return permissions + rate limit |
|
|
917
|
+
| `apiKeyQueries.listApiKeys` | List non-revoked API keys for a project |
|
|
918
|
+
| `apiKeyQueries.updateKeyLastUsed` | Update lastUsedAt timestamp on a key |
|
|
919
|
+
|
|
920
|
+
### API Key Mutations
|
|
921
|
+
|
|
922
|
+
| Function | Description |
|
|
923
|
+
|----------|-------------|
|
|
924
|
+
| `apiKeyMutations.createApiKey` | Create an API key with permissions and optional expiry |
|
|
925
|
+
| `apiKeyMutations.revokeApiKey` | Revoke an API key |
|
|
926
|
+
| `apiKeyMutations.consumeRateLimit` | Atomically check and consume a rate limit token |
|
|
927
|
+
| `apiKeyMutations.cleanupRateLimitTokens` | Remove expired rate limit window records |
|
|
928
|
+
|
|
929
|
+
### Cron Jobs
|
|
930
|
+
|
|
931
|
+
| Job | Schedule | Description |
|
|
932
|
+
|-----|----------|-------------|
|
|
933
|
+
| `relevance-decay` | Daily at 3 AM UTC | Reduces priority of stale, low-access memories |
|
|
934
|
+
| `cleanup-old-history` | Weekly (Sunday 4 AM UTC) | Removes history entries older than 90 days |
|
|
935
|
+
| `cleanup-rate-limit-tokens` | Hourly | Removes expired rate limit window records |
|