@prmichaelsen/remember-mcp 2.2.1 → 2.3.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 (61) hide show
  1. package/AGENT.md +4 -4
  2. package/CHANGELOG.md +45 -0
  3. package/README.md +43 -3
  4. package/agent/commands/acp.init.md +376 -0
  5. package/agent/commands/acp.proceed.md +311 -0
  6. package/agent/commands/acp.status.md +280 -0
  7. package/agent/commands/acp.version-check-for-updates.md +275 -0
  8. package/agent/commands/acp.version-check.md +190 -0
  9. package/agent/commands/acp.version-update.md +288 -0
  10. package/agent/commands/command.template.md +273 -0
  11. package/agent/design/core-memory-user-profile.md +1253 -0
  12. package/agent/design/ghost-profiles-pseudonymous-identity.md +194 -0
  13. package/agent/design/publish-tools-confirmation-flow.md +922 -0
  14. package/agent/milestones/milestone-10-shared-spaces.md +169 -0
  15. package/agent/progress.yaml +90 -4
  16. package/agent/scripts/install.sh +118 -0
  17. package/agent/scripts/update.sh +22 -10
  18. package/agent/scripts/version.sh +35 -0
  19. package/agent/tasks/task-27-implement-llm-provider-interface.md +51 -0
  20. package/agent/tasks/task-28-implement-llm-provider-factory.md +64 -0
  21. package/agent/tasks/task-29-update-config-for-llm.md +71 -0
  22. package/agent/tasks/task-30-implement-bedrock-provider.md +147 -0
  23. package/agent/tasks/task-31-implement-background-job-service.md +120 -0
  24. package/agent/tasks/task-32-test-llm-provider-integration.md +152 -0
  25. package/agent/tasks/task-34-create-confirmation-token-service.md +191 -0
  26. package/agent/tasks/task-35-create-space-memory-types-schema.md +183 -0
  27. package/agent/tasks/task-36-implement-remember-publish.md +227 -0
  28. package/agent/tasks/task-37-implement-remember-confirm.md +225 -0
  29. package/agent/tasks/task-38-implement-remember-deny.md +161 -0
  30. package/agent/tasks/task-39-implement-remember-search-space.md +188 -0
  31. package/agent/tasks/task-40-implement-remember-query-space.md +193 -0
  32. package/agent/tasks/task-41-configure-firestore-ttl.md +188 -0
  33. package/agent/tasks/task-42-create-tests-shared-spaces.md +216 -0
  34. package/agent/tasks/task-43-update-documentation.md +255 -0
  35. package/dist/llm/types.d.ts +1 -0
  36. package/dist/server-factory.js +914 -1
  37. package/dist/server.js +916 -3
  38. package/dist/services/confirmation-token.service.d.ts +99 -0
  39. package/dist/services/confirmation-token.service.spec.d.ts +5 -0
  40. package/dist/tools/confirm.d.ts +20 -0
  41. package/dist/tools/deny.d.ts +19 -0
  42. package/dist/tools/publish.d.ts +22 -0
  43. package/dist/tools/query-space.d.ts +28 -0
  44. package/dist/tools/search-space.d.ts +29 -0
  45. package/dist/types/space-memory.d.ts +80 -0
  46. package/dist/weaviate/space-schema.d.ts +59 -0
  47. package/dist/weaviate/space-schema.spec.d.ts +5 -0
  48. package/package.json +1 -1
  49. package/src/llm/types.ts +0 -0
  50. package/src/server-factory.ts +33 -0
  51. package/src/server.ts +33 -0
  52. package/src/services/confirmation-token.service.spec.ts +254 -0
  53. package/src/services/confirmation-token.service.ts +232 -0
  54. package/src/tools/confirm.ts +176 -0
  55. package/src/tools/deny.ts +70 -0
  56. package/src/tools/publish.ts +167 -0
  57. package/src/tools/query-space.ts +197 -0
  58. package/src/tools/search-space.ts +189 -0
  59. package/src/types/space-memory.ts +94 -0
  60. package/src/weaviate/space-schema.spec.ts +131 -0
  61. package/src/weaviate/space-schema.ts +275 -0
@@ -12,6 +12,9 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
12
12
  return require.apply(this, arguments);
13
13
  throw Error('Dynamic require of "' + x + '" is not supported');
14
14
  });
15
+ var __esm = (fn, res) => function __init() {
16
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
17
+ };
15
18
  var __commonJS = (cb, mod) => function __require2() {
16
19
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
20
  };
@@ -390,6 +393,15 @@ var require_main = __commonJS({
390
393
  }
391
394
  });
392
395
 
396
+ // src/types/space-memory.ts
397
+ var SUPPORTED_SPACES;
398
+ var init_space_memory = __esm({
399
+ "src/types/space-memory.ts"() {
400
+ "use strict";
401
+ SUPPORTED_SPACES = ["the_void"];
402
+ }
403
+ });
404
+
393
405
  // src/server-factory.ts
394
406
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
395
407
  import {
@@ -525,6 +537,9 @@ function sanitizeUserId(userId) {
525
537
  }
526
538
  return sanitized.charAt(0).toUpperCase() + sanitized.slice(1);
527
539
  }
540
+ function getMemoryCollectionName(userId) {
541
+ return `Memory_${sanitizeUserId(userId)}`;
542
+ }
528
543
 
529
544
  // src/firestore/init.ts
530
545
  import { initializeApp } from "@prmichaelsen/firebase-admin-sdk-v8";
@@ -3205,6 +3220,883 @@ async function handleGetPreferences(args, userId) {
3205
3220
  }
3206
3221
  }
3207
3222
 
3223
+ // src/services/confirmation-token.service.ts
3224
+ import { randomUUID } from "crypto";
3225
+ var ConfirmationTokenService = class {
3226
+ EXPIRY_MINUTES = 5;
3227
+ /**
3228
+ * Create a new confirmation request
3229
+ *
3230
+ * @param userId - User ID who initiated the request
3231
+ * @param action - Action type (e.g., 'publish_memory')
3232
+ * @param payload - Data to store with the request
3233
+ * @param targetCollection - Optional target collection (e.g., 'the_void')
3234
+ * @returns Request ID and token
3235
+ */
3236
+ async createRequest(userId, action, payload, targetCollection) {
3237
+ const token = randomUUID();
3238
+ const now = /* @__PURE__ */ new Date();
3239
+ const expiresAt = new Date(now.getTime() + this.EXPIRY_MINUTES * 60 * 1e3);
3240
+ const request = {
3241
+ user_id: userId,
3242
+ token,
3243
+ action,
3244
+ target_collection: targetCollection,
3245
+ payload,
3246
+ created_at: now.toISOString(),
3247
+ expires_at: expiresAt.toISOString(),
3248
+ status: "pending"
3249
+ };
3250
+ const collectionPath = `users/${userId}/requests`;
3251
+ const docRef = await addDocument(collectionPath, request);
3252
+ return { requestId: docRef.id, token };
3253
+ }
3254
+ /**
3255
+ * Validate and retrieve a confirmation request
3256
+ *
3257
+ * @param userId - User ID
3258
+ * @param token - Confirmation token
3259
+ * @returns Request with request_id if valid, null otherwise
3260
+ */
3261
+ async validateToken(userId, token) {
3262
+ const collectionPath = `users/${userId}/requests`;
3263
+ const queryOptions = {
3264
+ where: [
3265
+ { field: "token", op: "==", value: token },
3266
+ { field: "status", op: "==", value: "pending" }
3267
+ ],
3268
+ limit: 1
3269
+ };
3270
+ const results = await queryDocuments(collectionPath, queryOptions);
3271
+ if (results.length === 0) {
3272
+ return null;
3273
+ }
3274
+ const doc = results[0];
3275
+ const request = doc.data;
3276
+ const expiresAt = new Date(request.expires_at);
3277
+ if (expiresAt.getTime() < Date.now()) {
3278
+ await this.updateStatus(userId, doc.id, "expired");
3279
+ return null;
3280
+ }
3281
+ return {
3282
+ ...request,
3283
+ request_id: doc.id
3284
+ };
3285
+ }
3286
+ /**
3287
+ * Confirm a request
3288
+ *
3289
+ * @param userId - User ID
3290
+ * @param token - Confirmation token
3291
+ * @returns Confirmed request if valid, null otherwise
3292
+ */
3293
+ async confirmRequest(userId, token) {
3294
+ const request = await this.validateToken(userId, token);
3295
+ if (!request) {
3296
+ return null;
3297
+ }
3298
+ await this.updateStatus(userId, request.request_id, "confirmed");
3299
+ return {
3300
+ ...request,
3301
+ status: "confirmed",
3302
+ confirmed_at: (/* @__PURE__ */ new Date()).toISOString()
3303
+ };
3304
+ }
3305
+ /**
3306
+ * Deny a request
3307
+ *
3308
+ * @param userId - User ID
3309
+ * @param token - Confirmation token
3310
+ * @returns True if denied successfully, false otherwise
3311
+ */
3312
+ async denyRequest(userId, token) {
3313
+ const request = await this.validateToken(userId, token);
3314
+ if (!request) {
3315
+ return false;
3316
+ }
3317
+ await this.updateStatus(userId, request.request_id, "denied");
3318
+ return true;
3319
+ }
3320
+ /**
3321
+ * Retract a request
3322
+ *
3323
+ * @param userId - User ID
3324
+ * @param token - Confirmation token
3325
+ * @returns True if retracted successfully, false otherwise
3326
+ */
3327
+ async retractRequest(userId, token) {
3328
+ const request = await this.validateToken(userId, token);
3329
+ if (!request) {
3330
+ return false;
3331
+ }
3332
+ await this.updateStatus(userId, request.request_id, "retracted");
3333
+ return true;
3334
+ }
3335
+ /**
3336
+ * Update request status
3337
+ *
3338
+ * @param userId - User ID
3339
+ * @param requestId - Request document ID
3340
+ * @param status - New status
3341
+ */
3342
+ async updateStatus(userId, requestId, status) {
3343
+ const collectionPath = `users/${userId}/requests`;
3344
+ const updateData = {
3345
+ status
3346
+ };
3347
+ if (status === "confirmed") {
3348
+ updateData.confirmed_at = (/* @__PURE__ */ new Date()).toISOString();
3349
+ }
3350
+ await updateDocument(collectionPath, requestId, updateData);
3351
+ }
3352
+ /**
3353
+ * Clean up expired requests (optional - Firestore TTL handles deletion)
3354
+ *
3355
+ * Note: Configure Firestore TTL policy on 'requests' collection group
3356
+ * with 'expires_at' field for automatic deletion within 24 hours.
3357
+ *
3358
+ * This method is optional for immediate cleanup if needed.
3359
+ *
3360
+ * @returns Count of deleted requests
3361
+ */
3362
+ async cleanupExpired() {
3363
+ console.warn("[ConfirmationTokenService] cleanupExpired not implemented - rely on Firestore TTL");
3364
+ return 0;
3365
+ }
3366
+ };
3367
+ var confirmationTokenService = new ConfirmationTokenService();
3368
+
3369
+ // src/weaviate/space-schema.ts
3370
+ init_space_memory();
3371
+ import weaviate3 from "weaviate-client";
3372
+ function getSpaceCollectionName(spaceId) {
3373
+ return `Memory_${spaceId}`;
3374
+ }
3375
+ function isValidSpaceId(spaceId) {
3376
+ return SUPPORTED_SPACES.includes(spaceId);
3377
+ }
3378
+ async function createSpaceCollection(client2, spaceId) {
3379
+ const collectionName = getSpaceCollectionName(spaceId);
3380
+ console.log(`[Weaviate] Creating space collection ${collectionName}...`);
3381
+ await client2.collections.create({
3382
+ name: collectionName,
3383
+ // Vectorizer configuration
3384
+ vectorizers: weaviate3.configure.vectorizer.text2VecOpenAI({
3385
+ model: "text-embedding-3-small",
3386
+ // Vectorize content for semantic search
3387
+ sourceProperties: ["content", "observation"]
3388
+ }),
3389
+ properties: [
3390
+ // Discriminator
3391
+ {
3392
+ name: "doc_type",
3393
+ dataType: "text",
3394
+ description: 'Document type: "space_memory"'
3395
+ },
3396
+ // Space identity
3397
+ {
3398
+ name: "space_id",
3399
+ dataType: "text",
3400
+ description: 'Space identifier (e.g., "the_void")'
3401
+ },
3402
+ {
3403
+ name: "author_id",
3404
+ dataType: "text",
3405
+ description: "Original author user_id (for permissions)"
3406
+ },
3407
+ {
3408
+ name: "ghost_id",
3409
+ dataType: "text",
3410
+ description: "Optional ghost profile ID for pseudonymous publishing"
3411
+ },
3412
+ {
3413
+ name: "attribution",
3414
+ dataType: "text",
3415
+ description: 'Attribution type: "user" or "ghost"'
3416
+ },
3417
+ // Discovery metadata
3418
+ {
3419
+ name: "published_at",
3420
+ dataType: "text",
3421
+ description: "When published to space (ISO 8601)"
3422
+ },
3423
+ {
3424
+ name: "discovery_count",
3425
+ dataType: "number",
3426
+ description: "How many times discovered"
3427
+ },
3428
+ // Memory fields (same as personal memories)
3429
+ {
3430
+ name: "content",
3431
+ dataType: "text",
3432
+ description: "Main memory content (vectorized)"
3433
+ },
3434
+ {
3435
+ name: "title",
3436
+ dataType: "text",
3437
+ description: "Optional short title"
3438
+ },
3439
+ {
3440
+ name: "summary",
3441
+ dataType: "text",
3442
+ description: "Optional brief summary"
3443
+ },
3444
+ {
3445
+ name: "type",
3446
+ dataType: "text",
3447
+ description: "Content type (note, event, person, etc.)"
3448
+ },
3449
+ // Scoring fields
3450
+ {
3451
+ name: "weight",
3452
+ dataType: "number",
3453
+ description: "Significance/priority (0-1)"
3454
+ },
3455
+ {
3456
+ name: "trust",
3457
+ dataType: "number",
3458
+ description: "Access control level (0-1)"
3459
+ },
3460
+ {
3461
+ name: "confidence",
3462
+ dataType: "number",
3463
+ description: "System confidence in accuracy (0-1)"
3464
+ },
3465
+ // Location fields (flattened)
3466
+ {
3467
+ name: "location_gps_latitude",
3468
+ dataType: "number",
3469
+ description: "GPS latitude"
3470
+ },
3471
+ {
3472
+ name: "location_gps_longitude",
3473
+ dataType: "number",
3474
+ description: "GPS longitude"
3475
+ },
3476
+ {
3477
+ name: "location_address_formatted",
3478
+ dataType: "text",
3479
+ description: "Formatted address"
3480
+ },
3481
+ {
3482
+ name: "location_address_city",
3483
+ dataType: "text",
3484
+ description: "City"
3485
+ },
3486
+ {
3487
+ name: "location_address_country",
3488
+ dataType: "text",
3489
+ description: "Country"
3490
+ },
3491
+ // Context fields (flattened)
3492
+ {
3493
+ name: "context_conversation_id",
3494
+ dataType: "text",
3495
+ description: "Conversation ID"
3496
+ },
3497
+ {
3498
+ name: "context_platform",
3499
+ dataType: "text",
3500
+ description: "Platform where created"
3501
+ },
3502
+ // Tags and relationships
3503
+ {
3504
+ name: "tags",
3505
+ dataType: "text[]",
3506
+ description: "Tags for categorization"
3507
+ },
3508
+ {
3509
+ name: "related_memory_ids",
3510
+ dataType: "text[]",
3511
+ description: "IDs of related memories"
3512
+ },
3513
+ // Timestamps
3514
+ {
3515
+ name: "created_at",
3516
+ dataType: "text",
3517
+ description: "Original creation timestamp (ISO 8601)"
3518
+ },
3519
+ {
3520
+ name: "updated_at",
3521
+ dataType: "text",
3522
+ description: "Last update timestamp (ISO 8601)"
3523
+ },
3524
+ // Versioning
3525
+ {
3526
+ name: "version",
3527
+ dataType: "number",
3528
+ description: "Version number (increments on update)"
3529
+ }
3530
+ ]
3531
+ });
3532
+ console.log(`[Weaviate] Space collection ${collectionName} created successfully`);
3533
+ }
3534
+ async function ensureSpaceCollection(client2, spaceId) {
3535
+ if (!isValidSpaceId(spaceId)) {
3536
+ throw new Error(`Invalid space ID: ${spaceId}. Supported spaces: ${SUPPORTED_SPACES.join(", ")}`);
3537
+ }
3538
+ const collectionName = getSpaceCollectionName(spaceId);
3539
+ const exists = await client2.collections.exists(collectionName);
3540
+ if (!exists) {
3541
+ await createSpaceCollection(client2, spaceId);
3542
+ }
3543
+ return client2.collections.get(collectionName);
3544
+ }
3545
+
3546
+ // src/tools/publish.ts
3547
+ init_space_memory();
3548
+ var publishTool = {
3549
+ name: "remember_publish",
3550
+ description: 'Publish a memory to a shared space (like "The Void"). The memory will be COPIED (not moved) from your personal collection. Generates a confirmation token. Use remember_confirm to execute.',
3551
+ inputSchema: {
3552
+ type: "object",
3553
+ properties: {
3554
+ memory_id: {
3555
+ type: "string",
3556
+ description: "ID of the memory from your personal collection to publish"
3557
+ },
3558
+ target: {
3559
+ type: "string",
3560
+ description: "Target space to publish to (snake_case ID)",
3561
+ enum: SUPPORTED_SPACES,
3562
+ default: "the_void"
3563
+ },
3564
+ additional_tags: {
3565
+ type: "array",
3566
+ items: { type: "string" },
3567
+ description: "Additional tags for discovery (merged with original tags)",
3568
+ default: []
3569
+ }
3570
+ },
3571
+ required: ["memory_id", "target"]
3572
+ }
3573
+ };
3574
+ async function handlePublish(args, userId) {
3575
+ try {
3576
+ if (!isValidSpaceId(args.target)) {
3577
+ return JSON.stringify(
3578
+ {
3579
+ success: false,
3580
+ error: "Invalid space ID",
3581
+ message: `Space "${args.target}" is not supported. Supported spaces: ${SUPPORTED_SPACES.join(", ")}`,
3582
+ context: {
3583
+ provided_space: args.target,
3584
+ supported_spaces: SUPPORTED_SPACES
3585
+ }
3586
+ },
3587
+ null,
3588
+ 2
3589
+ );
3590
+ }
3591
+ const weaviateClient = getWeaviateClient();
3592
+ const userCollection = weaviateClient.collections.get(
3593
+ getMemoryCollectionName(userId)
3594
+ );
3595
+ const memory = await userCollection.query.fetchObjectById(args.memory_id);
3596
+ if (!memory) {
3597
+ return JSON.stringify(
3598
+ {
3599
+ success: false,
3600
+ error: "Memory not found",
3601
+ message: `No memory found with ID: ${args.memory_id}`,
3602
+ context: {
3603
+ collection_name: getMemoryCollectionName(userId),
3604
+ memory_id: args.memory_id
3605
+ }
3606
+ },
3607
+ null,
3608
+ 2
3609
+ );
3610
+ }
3611
+ if (memory.properties.user_id !== userId) {
3612
+ return JSON.stringify(
3613
+ {
3614
+ success: false,
3615
+ error: "Permission denied",
3616
+ message: "You can only publish your own memories",
3617
+ context: {
3618
+ memory_id: args.memory_id,
3619
+ memory_owner: memory.properties.user_id,
3620
+ requesting_user: userId
3621
+ }
3622
+ },
3623
+ null,
3624
+ 2
3625
+ );
3626
+ }
3627
+ if (memory.properties.doc_type !== "memory") {
3628
+ return JSON.stringify(
3629
+ {
3630
+ success: false,
3631
+ error: "Invalid document type",
3632
+ message: "Only memories can be published (not relationships)",
3633
+ context: {
3634
+ memory_id: args.memory_id,
3635
+ doc_type: memory.properties.doc_type
3636
+ }
3637
+ },
3638
+ null,
3639
+ 2
3640
+ );
3641
+ }
3642
+ const payload = {
3643
+ memory_id: args.memory_id,
3644
+ additional_tags: args.additional_tags || []
3645
+ };
3646
+ const { requestId, token } = await confirmationTokenService.createRequest(
3647
+ userId,
3648
+ "publish_memory",
3649
+ payload,
3650
+ args.target
3651
+ );
3652
+ return JSON.stringify(
3653
+ {
3654
+ success: true,
3655
+ token
3656
+ },
3657
+ null,
3658
+ 2
3659
+ );
3660
+ } catch (error) {
3661
+ handleToolError(error, {
3662
+ toolName: "remember_publish",
3663
+ userId,
3664
+ operation: "publish memory",
3665
+ memory_id: args.memory_id,
3666
+ target: args.target
3667
+ });
3668
+ }
3669
+ }
3670
+
3671
+ // src/tools/confirm.ts
3672
+ var confirmTool = {
3673
+ name: "remember_confirm",
3674
+ description: "Confirm and execute a pending action using the token. Works for any action that requires confirmation (publish, delete, etc.).",
3675
+ inputSchema: {
3676
+ type: "object",
3677
+ properties: {
3678
+ token: {
3679
+ type: "string",
3680
+ description: "The confirmation token from the action tool"
3681
+ }
3682
+ },
3683
+ required: ["token"]
3684
+ }
3685
+ };
3686
+ async function handleConfirm(args, userId) {
3687
+ try {
3688
+ const request = await confirmationTokenService.confirmRequest(userId, args.token);
3689
+ if (!request) {
3690
+ return JSON.stringify(
3691
+ {
3692
+ success: false,
3693
+ error: "Invalid or expired token",
3694
+ message: "The confirmation token is invalid, expired, or has already been used."
3695
+ },
3696
+ null,
3697
+ 2
3698
+ );
3699
+ }
3700
+ if (request.action === "publish_memory") {
3701
+ return await executePublishMemory(request, userId);
3702
+ }
3703
+ throw new Error(`Unknown action type: ${request.action}`);
3704
+ } catch (error) {
3705
+ handleToolError(error, {
3706
+ toolName: "remember_confirm",
3707
+ userId,
3708
+ operation: "confirm action",
3709
+ token: args.token
3710
+ });
3711
+ }
3712
+ }
3713
+ async function executePublishMemory(request, userId) {
3714
+ try {
3715
+ const weaviateClient = getWeaviateClient();
3716
+ const userCollection = weaviateClient.collections.get(
3717
+ getMemoryCollectionName(userId)
3718
+ );
3719
+ const originalMemory = await userCollection.query.fetchObjectById(
3720
+ request.payload.memory_id
3721
+ );
3722
+ if (!originalMemory) {
3723
+ return JSON.stringify(
3724
+ {
3725
+ success: false,
3726
+ error: "Memory not found",
3727
+ message: `Original memory ${request.payload.memory_id} no longer exists`
3728
+ },
3729
+ null,
3730
+ 2
3731
+ );
3732
+ }
3733
+ if (originalMemory.properties.user_id !== userId) {
3734
+ return JSON.stringify(
3735
+ {
3736
+ success: false,
3737
+ error: "Permission denied",
3738
+ message: "You can only publish your own memories"
3739
+ },
3740
+ null,
3741
+ 2
3742
+ );
3743
+ }
3744
+ const targetCollection = await ensureSpaceCollection(
3745
+ weaviateClient,
3746
+ request.target_collection || "the_void"
3747
+ );
3748
+ const originalTags = Array.isArray(originalMemory.properties.tags) ? originalMemory.properties.tags : [];
3749
+ const additionalTags = Array.isArray(request.payload.additional_tags) ? request.payload.additional_tags : [];
3750
+ const publishedMemory = {
3751
+ ...originalMemory.properties,
3752
+ // Override specific fields
3753
+ space_id: request.target_collection || "the_void",
3754
+ author_id: userId,
3755
+ // Always attributed
3756
+ published_at: (/* @__PURE__ */ new Date()).toISOString(),
3757
+ discovery_count: 0,
3758
+ doc_type: "space_memory",
3759
+ attribution: "user",
3760
+ // Merge additional tags
3761
+ tags: [...originalTags, ...additionalTags],
3762
+ // Update timestamps
3763
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
3764
+ updated_at: (/* @__PURE__ */ new Date()).toISOString(),
3765
+ version: 1
3766
+ };
3767
+ const result = await targetCollection.data.insert({
3768
+ properties: publishedMemory
3769
+ });
3770
+ return JSON.stringify(
3771
+ {
3772
+ success: true,
3773
+ space_memory_id: result
3774
+ },
3775
+ null,
3776
+ 2
3777
+ );
3778
+ } catch (error) {
3779
+ handleToolError(error, {
3780
+ toolName: "remember_confirm",
3781
+ userId,
3782
+ operation: "execute publish_memory",
3783
+ action: "publish_memory"
3784
+ });
3785
+ }
3786
+ }
3787
+
3788
+ // src/tools/deny.ts
3789
+ var denyTool = {
3790
+ name: "remember_deny",
3791
+ description: "Deny a pending action. The request will be marked as denied and the token invalidated. Works for any action that requires confirmation.",
3792
+ inputSchema: {
3793
+ type: "object",
3794
+ properties: {
3795
+ token: {
3796
+ type: "string",
3797
+ description: "The confirmation token from the action tool"
3798
+ }
3799
+ },
3800
+ required: ["token"]
3801
+ }
3802
+ };
3803
+ async function handleDeny(args, userId) {
3804
+ try {
3805
+ const success = await confirmationTokenService.denyRequest(userId, args.token);
3806
+ if (!success) {
3807
+ return JSON.stringify(
3808
+ {
3809
+ success: false,
3810
+ error: "Invalid token",
3811
+ message: "Token not found or already used"
3812
+ },
3813
+ null,
3814
+ 2
3815
+ );
3816
+ }
3817
+ return JSON.stringify(
3818
+ {
3819
+ success: true
3820
+ },
3821
+ null,
3822
+ 2
3823
+ );
3824
+ } catch (error) {
3825
+ handleToolError(error, {
3826
+ toolName: "remember_deny",
3827
+ userId,
3828
+ operation: "deny action",
3829
+ token: args.token
3830
+ });
3831
+ }
3832
+ }
3833
+
3834
+ // src/tools/search-space.ts
3835
+ import { Filters as Filters3 } from "weaviate-client";
3836
+ init_space_memory();
3837
+ var searchSpaceTool = {
3838
+ name: "remember_search_space",
3839
+ description: "Search shared spaces to discover thoughts, ideas, and memories. Works like remember_search_memory but searches shared spaces instead of personal memories.",
3840
+ inputSchema: {
3841
+ type: "object",
3842
+ properties: {
3843
+ query: {
3844
+ type: "string",
3845
+ description: "Search query (semantic + keyword hybrid)"
3846
+ },
3847
+ space: {
3848
+ type: "string",
3849
+ description: "Which space to search",
3850
+ enum: SUPPORTED_SPACES,
3851
+ default: "the_void"
3852
+ },
3853
+ content_type: {
3854
+ type: "string",
3855
+ description: "Filter by content type"
3856
+ },
3857
+ tags: {
3858
+ type: "array",
3859
+ items: { type: "string" },
3860
+ description: "Filter by tags (must have all specified tags)"
3861
+ },
3862
+ min_weight: {
3863
+ type: "number",
3864
+ minimum: 0,
3865
+ maximum: 1,
3866
+ description: "Minimum weight/significance (0-1)"
3867
+ },
3868
+ max_weight: {
3869
+ type: "number",
3870
+ minimum: 0,
3871
+ maximum: 1,
3872
+ description: "Maximum weight/significance (0-1)"
3873
+ },
3874
+ date_from: {
3875
+ type: "string",
3876
+ description: "Filter memories created after this date (ISO 8601)"
3877
+ },
3878
+ date_to: {
3879
+ type: "string",
3880
+ description: "Filter memories created before this date (ISO 8601)"
3881
+ },
3882
+ limit: {
3883
+ type: "number",
3884
+ default: 10,
3885
+ description: "Maximum number of results"
3886
+ },
3887
+ offset: {
3888
+ type: "number",
3889
+ default: 0,
3890
+ description: "Offset for pagination"
3891
+ }
3892
+ },
3893
+ required: ["query", "space"]
3894
+ }
3895
+ };
3896
+ async function handleSearchSpace(args, userId) {
3897
+ try {
3898
+ if (!isValidSpaceId(args.space)) {
3899
+ return JSON.stringify(
3900
+ {
3901
+ success: false,
3902
+ error: "Invalid space ID",
3903
+ message: `Space "${args.space}" is not supported. Supported spaces: ${SUPPORTED_SPACES.join(", ")}`
3904
+ },
3905
+ null,
3906
+ 2
3907
+ );
3908
+ }
3909
+ const weaviateClient = getWeaviateClient();
3910
+ const spaceCollection = await ensureSpaceCollection(weaviateClient, args.space);
3911
+ const filterList = [];
3912
+ filterList.push(spaceCollection.filter.byProperty("space_id").equal(args.space));
3913
+ filterList.push(spaceCollection.filter.byProperty("doc_type").equal("space_memory"));
3914
+ if (args.content_type) {
3915
+ filterList.push(spaceCollection.filter.byProperty("type").equal(args.content_type));
3916
+ }
3917
+ if (args.tags && args.tags.length > 0) {
3918
+ args.tags.forEach((tag) => {
3919
+ filterList.push(spaceCollection.filter.byProperty("tags").containsAny([tag]));
3920
+ });
3921
+ }
3922
+ if (args.min_weight !== void 0) {
3923
+ filterList.push(spaceCollection.filter.byProperty("weight").greaterOrEqual(args.min_weight));
3924
+ }
3925
+ if (args.max_weight !== void 0) {
3926
+ filterList.push(spaceCollection.filter.byProperty("weight").lessOrEqual(args.max_weight));
3927
+ }
3928
+ if (args.date_from) {
3929
+ filterList.push(spaceCollection.filter.byProperty("created_at").greaterOrEqual(new Date(args.date_from)));
3930
+ }
3931
+ if (args.date_to) {
3932
+ filterList.push(spaceCollection.filter.byProperty("created_at").lessOrEqual(new Date(args.date_to)));
3933
+ }
3934
+ const whereFilter = filterList.length > 0 ? Filters3.and(...filterList) : void 0;
3935
+ const searchResults = await spaceCollection.query.hybrid(args.query, {
3936
+ limit: args.limit || 10,
3937
+ offset: args.offset || 0,
3938
+ ...whereFilter && { where: whereFilter }
3939
+ });
3940
+ const memories = searchResults.objects.map((obj) => ({
3941
+ id: obj.uuid,
3942
+ ...obj.properties,
3943
+ _score: obj.metadata?.score
3944
+ }));
3945
+ const result = {
3946
+ space: args.space,
3947
+ query: args.query,
3948
+ memories,
3949
+ total: memories.length,
3950
+ offset: args.offset || 0,
3951
+ limit: args.limit || 10
3952
+ };
3953
+ return JSON.stringify(result, null, 2);
3954
+ } catch (error) {
3955
+ handleToolError(error, {
3956
+ toolName: "remember_search_space",
3957
+ operation: "search space",
3958
+ space: args.space,
3959
+ query: args.query
3960
+ });
3961
+ }
3962
+ }
3963
+
3964
+ // src/tools/query-space.ts
3965
+ import { Filters as Filters4 } from "weaviate-client";
3966
+ init_space_memory();
3967
+ var querySpaceTool = {
3968
+ name: "remember_query_space",
3969
+ description: "Ask natural language questions about memories in shared spaces. Works like remember_query_memory but queries shared spaces.",
3970
+ inputSchema: {
3971
+ type: "object",
3972
+ properties: {
3973
+ question: {
3974
+ type: "string",
3975
+ description: "Natural language question"
3976
+ },
3977
+ space: {
3978
+ type: "string",
3979
+ description: "Which space to query",
3980
+ enum: SUPPORTED_SPACES,
3981
+ default: "the_void"
3982
+ },
3983
+ content_type: {
3984
+ type: "string",
3985
+ description: "Filter by content type"
3986
+ },
3987
+ tags: {
3988
+ type: "array",
3989
+ items: { type: "string" },
3990
+ description: "Filter by tags"
3991
+ },
3992
+ min_weight: {
3993
+ type: "number",
3994
+ minimum: 0,
3995
+ maximum: 1,
3996
+ description: "Minimum weight/significance (0-1)"
3997
+ },
3998
+ date_from: {
3999
+ type: "string",
4000
+ description: "Filter memories created after this date (ISO 8601)"
4001
+ },
4002
+ date_to: {
4003
+ type: "string",
4004
+ description: "Filter memories created before this date (ISO 8601)"
4005
+ },
4006
+ limit: {
4007
+ type: "number",
4008
+ default: 10,
4009
+ description: "Maximum number of results"
4010
+ },
4011
+ format: {
4012
+ type: "string",
4013
+ enum: ["detailed", "compact"],
4014
+ default: "detailed",
4015
+ description: "Output format: detailed (full objects) or compact (text summary)"
4016
+ }
4017
+ },
4018
+ required: ["question", "space"]
4019
+ }
4020
+ };
4021
+ async function handleQuerySpace(args, userId) {
4022
+ try {
4023
+ if (!isValidSpaceId(args.space)) {
4024
+ return JSON.stringify(
4025
+ {
4026
+ success: false,
4027
+ error: "Invalid space ID",
4028
+ message: `Space "${args.space}" is not supported. Supported spaces: ${SUPPORTED_SPACES.join(", ")}`
4029
+ },
4030
+ null,
4031
+ 2
4032
+ );
4033
+ }
4034
+ const weaviateClient = getWeaviateClient();
4035
+ const spaceCollection = await ensureSpaceCollection(weaviateClient, args.space);
4036
+ const filterList = [];
4037
+ filterList.push(spaceCollection.filter.byProperty("space_id").equal(args.space));
4038
+ filterList.push(spaceCollection.filter.byProperty("doc_type").equal("space_memory"));
4039
+ if (args.content_type) {
4040
+ filterList.push(spaceCollection.filter.byProperty("type").equal(args.content_type));
4041
+ }
4042
+ if (args.tags && args.tags.length > 0) {
4043
+ args.tags.forEach((tag) => {
4044
+ filterList.push(spaceCollection.filter.byProperty("tags").containsAny([tag]));
4045
+ });
4046
+ }
4047
+ if (args.min_weight !== void 0) {
4048
+ filterList.push(spaceCollection.filter.byProperty("weight").greaterOrEqual(args.min_weight));
4049
+ }
4050
+ if (args.date_from) {
4051
+ filterList.push(spaceCollection.filter.byProperty("created_at").greaterOrEqual(new Date(args.date_from)));
4052
+ }
4053
+ if (args.date_to) {
4054
+ filterList.push(spaceCollection.filter.byProperty("created_at").lessOrEqual(new Date(args.date_to)));
4055
+ }
4056
+ const whereFilter = filterList.length > 0 ? Filters4.and(...filterList) : void 0;
4057
+ const searchResults = await spaceCollection.query.nearText(args.question, {
4058
+ limit: args.limit || 10,
4059
+ ...whereFilter && { where: whereFilter }
4060
+ });
4061
+ const format = args.format || "detailed";
4062
+ if (format === "compact") {
4063
+ const summaries = searchResults.objects.map((obj, idx) => {
4064
+ const props = obj.properties;
4065
+ return `${idx + 1}. ${props.title || props.content?.substring(0, 100) || "Untitled"}`;
4066
+ });
4067
+ const result = {
4068
+ question: args.question,
4069
+ space: args.space,
4070
+ format: "compact",
4071
+ summary: summaries.join("\n"),
4072
+ count: searchResults.objects.length
4073
+ };
4074
+ return JSON.stringify(result, null, 2);
4075
+ } else {
4076
+ const memories = searchResults.objects.map((obj) => ({
4077
+ id: obj.uuid,
4078
+ ...obj.properties,
4079
+ _distance: obj.metadata?.distance
4080
+ }));
4081
+ const result = {
4082
+ question: args.question,
4083
+ space: args.space,
4084
+ format: "detailed",
4085
+ memories,
4086
+ total: memories.length
4087
+ };
4088
+ return JSON.stringify(result, null, 2);
4089
+ }
4090
+ } catch (error) {
4091
+ handleToolError(error, {
4092
+ toolName: "remember_query_space",
4093
+ operation: "query space",
4094
+ space: args.space,
4095
+ question: args.question
4096
+ });
4097
+ }
4098
+ }
4099
+
3208
4100
  // src/server-factory.ts
3209
4101
  var databasesInitialized = false;
3210
4102
  var initializationPromise = null;
@@ -3275,7 +4167,13 @@ function registerHandlers(server, userId, accessToken) {
3275
4167
  deleteRelationshipTool,
3276
4168
  // Preference tools
3277
4169
  setPreferenceTool,
3278
- getPreferencesTool
4170
+ getPreferencesTool,
4171
+ // Space tools
4172
+ publishTool,
4173
+ confirmTool,
4174
+ denyTool,
4175
+ searchSpaceTool,
4176
+ querySpaceTool
3279
4177
  ]
3280
4178
  };
3281
4179
  });
@@ -3320,6 +4218,21 @@ function registerHandlers(server, userId, accessToken) {
3320
4218
  case "remember_get_preferences":
3321
4219
  result = await handleGetPreferences(args, userId);
3322
4220
  break;
4221
+ case "remember_publish":
4222
+ result = await handlePublish(args, userId);
4223
+ break;
4224
+ case "remember_confirm":
4225
+ result = await handleConfirm(args, userId);
4226
+ break;
4227
+ case "remember_deny":
4228
+ result = await handleDeny(args, userId);
4229
+ break;
4230
+ case "remember_search_space":
4231
+ result = await handleSearchSpace(args, userId);
4232
+ break;
4233
+ case "remember_query_space":
4234
+ result = await handleQuerySpace(args, userId);
4235
+ break;
3323
4236
  default:
3324
4237
  throw new McpError(
3325
4238
  ErrorCode.MethodNotFound,