@prmichaelsen/remember-mcp 3.12.0 → 3.14.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.
Files changed (62) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/agent/milestones/milestone-17-remember-core-migration.md +140 -0
  3. package/agent/progress.yaml +123 -6
  4. package/agent/tasks/milestone-17-remember-core-migration/task-193-foundation-setup.md +58 -0
  5. package/agent/tasks/milestone-17-remember-core-migration/task-194-migrate-relationship-tools.md +47 -0
  6. package/agent/tasks/milestone-17-remember-core-migration/task-195-migrate-preference-tools.md +34 -0
  7. package/agent/tasks/milestone-17-remember-core-migration/task-196-migrate-memory-tools.md +46 -0
  8. package/agent/tasks/milestone-17-remember-core-migration/task-197-migrate-space-confirmation-tools.md +49 -0
  9. package/agent/tasks/milestone-17-remember-core-migration/task-198-migrate-space-search-moderate.md +46 -0
  10. package/agent/tasks/milestone-17-remember-core-migration/task-199-migrate-delete-memory.md +43 -0
  11. package/agent/tasks/milestone-17-remember-core-migration/task-200-code-cleanup-verification.md +52 -0
  12. package/dist/core-services.d.ts +25 -0
  13. package/dist/server-factory.js +3578 -4485
  14. package/dist/server.js +3070 -3973
  15. package/dist/tools/confirm-publish-moderation.spec.d.ts +3 -2
  16. package/dist/tools/create-memory.d.ts +1 -1
  17. package/dist/tools/query-space.d.ts +1 -1
  18. package/dist/tools/search-space.d.ts +10 -14
  19. package/jest.config.js +11 -0
  20. package/package.json +2 -1
  21. package/src/core-services.ts +50 -0
  22. package/src/tools/confirm-publish-moderation.spec.ts +120 -176
  23. package/src/tools/confirm.ts +70 -1035
  24. package/src/tools/create-memory.ts +16 -67
  25. package/src/tools/create-relationship.ts +13 -181
  26. package/src/tools/delete-memory.ts +7 -72
  27. package/src/tools/delete-relationship.ts +7 -91
  28. package/src/tools/deny.ts +4 -14
  29. package/src/tools/find-similar.ts +16 -110
  30. package/src/tools/get-preferences.ts +3 -8
  31. package/src/tools/moderate.spec.ts +65 -81
  32. package/src/tools/moderate.ts +18 -121
  33. package/src/tools/publish.ts +7 -204
  34. package/src/tools/query-space.ts +28 -140
  35. package/src/tools/retract.ts +7 -185
  36. package/src/tools/revise.ts +4 -136
  37. package/src/tools/search-relationship.ts +17 -116
  38. package/src/tools/search-space.ts +58 -304
  39. package/src/tools/set-preference.ts +3 -8
  40. package/src/tools/update-memory.ts +22 -190
  41. package/src/tools/update-relationship.ts +16 -90
  42. package/src/v2-smoke.e2e.ts +3 -2
  43. package/dist/collections/composite-ids.d.ts +0 -106
  44. package/dist/collections/core-infrastructure.spec.d.ts +0 -11
  45. package/dist/collections/dot-notation.d.ts +0 -106
  46. package/dist/collections/tracking-arrays.d.ts +0 -176
  47. package/dist/constants/content-types.d.ts +0 -61
  48. package/dist/services/confirmation-token.service.d.ts +0 -99
  49. package/dist/services/confirmation-token.service.spec.d.ts +0 -5
  50. package/dist/services/preferences-database.service.d.ts +0 -22
  51. package/dist/services/space-config.service.d.ts +0 -23
  52. package/dist/services/space-config.service.spec.d.ts +0 -2
  53. package/src/collections/composite-ids.ts +0 -193
  54. package/src/collections/core-infrastructure.spec.ts +0 -353
  55. package/src/collections/dot-notation.ts +0 -212
  56. package/src/collections/tracking-arrays.ts +0 -298
  57. package/src/constants/content-types.ts +0 -490
  58. package/src/services/confirmation-token.service.spec.ts +0 -254
  59. package/src/services/confirmation-token.service.ts +0 -328
  60. package/src/services/preferences-database.service.ts +0 -120
  61. package/src/services/space-config.service.spec.ts +0 -102
  62. package/src/services/space-config.service.ts +0 -79
@@ -9,18 +9,10 @@
9
9
  */
10
10
 
11
11
  import type { Tool } from '@modelcontextprotocol/sdk/types.js';
12
- import {
13
- getWeaviateClient,
14
- getMemoryCollectionName,
15
- fetchMemoryWithAllProperties,
16
- } from '../weaviate/client.js';
17
- import { confirmationTokenService } from '../services/confirmation-token.service.js';
18
12
  import { handleToolError } from '../utils/error-handler.js';
19
- import { logger } from '../utils/logger.js';
20
13
  import { createDebugLogger } from '../utils/debug.js';
21
- import { CollectionType, getCollectionName } from '../collections/dot-notation.js';
22
- import { generateCompositeId } from '../collections/composite-ids.js';
23
14
  import type { AuthContext } from '../types/auth.js';
15
+ import { createCoreServices } from '../core-services.js';
24
16
 
25
17
  /** Maximum number of revision history entries to retain */
26
18
  const MAX_REVISION_HISTORY = 10;
@@ -128,141 +120,17 @@ export async function handleRevise(
128
120
  debug.info('Tool invoked');
129
121
  debug.trace('Arguments', { args });
130
122
 
131
- logger.info('Starting revise request', {
132
- tool: 'remember_revise',
133
- userId,
134
- memoryId: args.memory_id,
135
- });
136
-
137
- // Load source memory from user's personal collection
138
- const weaviateClient = getWeaviateClient();
139
- const userCollectionName = getMemoryCollectionName(userId);
140
- const userCollection = weaviateClient.collections.get(userCollectionName);
141
-
142
- const sourceMemory = await fetchMemoryWithAllProperties(
143
- userCollection,
144
- args.memory_id
145
- );
146
-
147
- if (!sourceMemory) {
148
- logger.info('Source memory not found', {
149
- tool: 'remember_revise',
150
- memoryId: args.memory_id,
151
- });
152
- return JSON.stringify(
153
- {
154
- success: false,
155
- error: 'Memory not found',
156
- message: `Memory ${args.memory_id} does not exist`,
157
- },
158
- null,
159
- 2
160
- );
161
- }
162
-
163
- // Verify ownership
164
- if (sourceMemory.properties.user_id !== userId) {
165
- logger.warn('Permission denied', {
166
- tool: 'remember_revise',
167
- memoryId: args.memory_id,
168
- memoryOwner: sourceMemory.properties.user_id,
169
- requestingUser: userId,
170
- });
171
- return JSON.stringify(
172
- {
173
- success: false,
174
- error: 'Permission denied',
175
- message: 'You can only revise your own memories',
176
- },
177
- null,
178
- 2
179
- );
180
- }
181
-
182
- // Get tracking arrays
183
- const spaceIds: string[] = Array.isArray(sourceMemory.properties.space_ids)
184
- ? sourceMemory.properties.space_ids
185
- : [];
186
- const groupIds: string[] = Array.isArray(sourceMemory.properties.group_ids)
187
- ? sourceMemory.properties.group_ids
188
- : [];
189
-
190
- // Validate the memory is published somewhere
191
- if (spaceIds.length === 0 && groupIds.length === 0) {
192
- logger.info('Memory has no published copies', {
193
- tool: 'remember_revise',
194
- memoryId: args.memory_id,
195
- });
196
- return JSON.stringify(
197
- {
198
- success: false,
199
- error: 'Not published',
200
- message:
201
- 'Memory has no published copies to revise. Publish first with remember_publish.',
202
- context: {
203
- memory_id: args.memory_id,
204
- space_ids: [],
205
- group_ids: [],
206
- },
207
- },
208
- null,
209
- 2
210
- );
211
- }
212
-
213
- // Create payload for confirmation token
214
- const payload = {
123
+ const { space } = createCoreServices(userId);
124
+ const result = await space.revise({
215
125
  memory_id: args.memory_id,
216
- space_ids: spaceIds,
217
- group_ids: groupIds,
218
- };
219
-
220
- logger.info('Generating confirmation token for revise', {
221
- tool: 'remember_revise',
222
- userId,
223
- memoryId: args.memory_id,
224
- spaceIds,
225
- groupIds,
226
- });
227
-
228
- // Generate confirmation token
229
- const { requestId, token } = await confirmationTokenService.createRequest(
230
- userId,
231
- 'revise_memory',
232
- payload
233
- );
234
-
235
- logger.info('Confirmation token generated for revise', {
236
- tool: 'remember_revise',
237
- requestId,
238
- token,
239
- action: 'revise_memory',
240
- spaceIds,
241
- groupIds,
242
126
  });
243
127
 
244
- // Build destination summary for user
245
- const destinations: string[] = [];
246
- if (spaceIds.length > 0) {
247
- destinations.push(`spaces: ${spaceIds.join(', ')}`);
248
- }
249
- if (groupIds.length > 0) {
250
- destinations.push(`groups: ${groupIds.join(', ')}`);
251
- }
252
-
253
128
  return JSON.stringify(
254
129
  {
255
130
  success: true,
256
- token,
257
- message: 'Revision request created. Please confirm to sync content to all published copies.',
131
+ token: result.token,
258
132
  action: 'revise_memory',
259
133
  memory_id: args.memory_id,
260
- destinations: destinations.join('; '),
261
- revision_details: {
262
- space_ids: spaceIds,
263
- group_ids: groupIds,
264
- total_locations: (spaceIds.length > 0 ? 1 : 0) + groupIds.length,
265
- },
266
134
  confirmation_required: true,
267
135
  },
268
136
  null,
@@ -3,14 +3,11 @@
3
3
  * Search relationships by observation text or type
4
4
  */
5
5
 
6
- import { Filters } from 'weaviate-client';
7
6
  import type { Relationship, DeletedFilter } from '../types/memory.js';
8
- import { getMemoryCollection } from '../weaviate/schema.js';
9
- import { logger } from '../utils/logger.js';
10
7
  import { handleToolError } from '../utils/error-handler.js';
11
8
  import { createDebugLogger } from '../utils/debug.js';
12
- import { buildDeletedFilter, combineFiltersWithAnd } from '../utils/weaviate-filters.js';
13
9
  import type { AuthContext } from '../types/auth.js';
10
+ import { createCoreServices } from '../core-services.js';
14
11
 
15
12
  /**
16
13
  * Tool definition for remember_search_relationship
@@ -118,123 +115,27 @@ export async function handleSearchRelationship(
118
115
  debug.info('Tool invoked');
119
116
  debug.trace('Arguments', { args });
120
117
 
121
- logger.info('Searching relationships', {
122
- userId,
118
+ const { relationship } = createCoreServices(userId);
119
+ const result = await relationship.search({
123
120
  query: args.query,
124
- types: args.relationship_types
125
- });
126
-
127
- const collection = getMemoryCollection(userId);
128
- const limit = args.limit ?? 10;
129
- const offset = args.offset ?? 0;
130
-
131
- // Build deleted filter
132
- const deletedFilter = buildDeletedFilter(collection, args.deleted_filter || 'exclude');
133
-
134
- // Build filters using Weaviate v3 API
135
- const filterList: any[] = [];
136
-
137
- // Add deleted filter if present
138
- if (deletedFilter) {
139
- filterList.push(deletedFilter);
140
- }
141
-
142
- // Always filter by doc_type = 'relationship'
143
- filterList.push(
144
- collection.filter.byProperty('doc_type').equal('relationship')
145
- );
146
-
147
- // Add relationship type filter
148
- if (args.relationship_types && args.relationship_types.length > 0) {
149
- if (args.relationship_types.length === 1) {
150
- filterList.push(
151
- collection.filter.byProperty('relationship_type').equal(args.relationship_types[0])
152
- );
153
- } else {
154
- // Multiple types: use OR logic
155
- const typeFilters = args.relationship_types.map(type =>
156
- collection.filter.byProperty('relationship_type').equal(type)
157
- );
158
- filterList.push(Filters.or(...typeFilters));
159
- }
160
- }
161
-
162
- // Add strength filter
163
- if (args.strength_min !== undefined) {
164
- filterList.push(
165
- collection.filter.byProperty('strength').greaterOrEqual(args.strength_min)
166
- );
167
- }
168
-
169
- // Add confidence filter
170
- if (args.confidence_min !== undefined) {
171
- filterList.push(
172
- collection.filter.byProperty('confidence').greaterOrEqual(args.confidence_min)
173
- );
174
- }
175
-
176
- // Add tags filter
177
- if (args.tags && args.tags.length > 0) {
178
- filterList.push(
179
- collection.filter.byProperty('tags').containsAny(args.tags)
180
- );
181
- }
182
-
183
- // Combine all filters with AND logic using the helper
184
- const combinedFilters = combineFiltersWithAnd(filterList);
185
-
186
- // Build search options
187
- const searchOptions: any = {
188
- alpha: 1.0, // Pure semantic search for relationships
189
- limit: limit + offset, // Get extra for offset
190
- };
191
-
192
- // Add filters
193
- if (combinedFilters) {
194
- searchOptions.filters = combinedFilters;
195
- }
196
-
197
- // Perform hybrid search (semantic search on observation field)
198
- const results = await collection.query.hybrid(args.query, searchOptions);
199
-
200
- // Apply offset manually (Weaviate v4 doesn't have built-in offset for nearText)
201
- const paginatedResults = results.objects.slice(offset, offset + limit);
202
-
203
- // Map results to Relationship type
204
- const relationships: Relationship[] = paginatedResults.map((obj: any) => ({
205
- id: obj.uuid,
206
- user_id: obj.properties.user_id,
207
- doc_type: 'relationship',
208
- memory_ids: obj.properties.related_memory_ids || [],
209
- relationship_type: obj.properties.relationship_type,
210
- observation: obj.properties.observation,
211
- strength: obj.properties.strength,
212
- confidence: obj.properties.confidence,
213
- context: obj.properties.context || {
214
- timestamp: obj.properties.created_at,
215
- source: { type: 'api', platform: 'mcp' },
216
- },
217
- created_at: obj.properties.created_at,
218
- updated_at: obj.properties.updated_at,
219
- version: obj.properties.version,
220
- tags: obj.properties.tags || [],
221
- }));
222
-
223
- logger.info('Relationship search completed', {
224
- userId,
225
- found: relationships.length,
226
- total: results.objects.length
121
+ relationship_types: args.relationship_types,
122
+ strength_min: args.strength_min,
123
+ confidence_min: args.confidence_min,
124
+ tags: args.tags,
125
+ limit: args.limit,
126
+ offset: args.offset,
127
+ deleted_filter: args.deleted_filter,
227
128
  });
228
129
 
229
- const result: SearchRelationshipResult = {
230
- relationships,
231
- total: results.objects.length,
232
- offset,
233
- limit,
234
- message: `Found ${relationships.length} relationship(s) matching query "${args.query}"`,
130
+ const response: SearchRelationshipResult = {
131
+ relationships: result.relationships as unknown as Relationship[],
132
+ total: result.total,
133
+ offset: result.offset,
134
+ limit: result.limit,
135
+ message: `Found ${result.relationships.length} relationship(s) matching query "${args.query}"`,
235
136
  };
236
137
 
237
- return JSON.stringify(result, null, 2);
138
+ return JSON.stringify(response, null, 2);
238
139
  } catch (error) {
239
140
  debug.error('Tool failed', { error: error instanceof Error ? error.message : String(error) });
240
141
  handleToolError(error, {