@prmichaelsen/remember-mcp 2.6.2 → 2.6.4
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/CHANGELOG.md +61 -0
- package/agent/progress.yaml +163 -13
- package/agent/tasks/task-62-fix-confirmation-response-storage.md +323 -0
- package/agent/tasks/task-63-fix-fetchobjectbyid-missing-properties.md +397 -0
- package/agent/tasks/task-64-prevent-implicit-content-type-filtering.md +289 -0
- package/dist/server-factory.js +67 -6
- package/dist/server.js +67 -6
- package/dist/weaviate/client.d.ts +16 -0
- package/package.json +1 -1
- package/src/tools/confirm.ts +7 -2
- package/src/tools/publish.ts +6 -2
- package/src/tools/query-memory.ts +5 -0
- package/src/tools/query-space.ts +8 -1
- package/src/tools/search-memory.ts +5 -0
- package/src/tools/search-space.ts +8 -1
- package/src/weaviate/client.ts +47 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,67 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.6.4] - 2026-02-16
|
|
9
|
+
|
|
10
|
+
### 🔧 Improved
|
|
11
|
+
|
|
12
|
+
- **Enhanced Tool Descriptions to Prevent Over-Filtering**
|
|
13
|
+
- Added explicit warnings to all search/query tools about content type filtering
|
|
14
|
+
- Agents now instructed to NOT add content_type filters unless explicitly requested by user
|
|
15
|
+
- Prevents missed results from over-filtering by content type
|
|
16
|
+
- Improves search quality and user experience
|
|
17
|
+
|
|
18
|
+
### 📝 Changed
|
|
19
|
+
|
|
20
|
+
- Updated `remember_search_memory` description with content type filtering guidance
|
|
21
|
+
- Updated `remember_query_memory` description with content type filtering guidance
|
|
22
|
+
- Updated `remember_search_space` description with content type filtering guidance
|
|
23
|
+
- Updated `remember_query_space` description with content type filtering guidance
|
|
24
|
+
- Added ✅ CORRECT and ❌ WRONG examples to clarify when to filter
|
|
25
|
+
|
|
26
|
+
### 🎯 Impact
|
|
27
|
+
|
|
28
|
+
- **Better Search Results**: No more over-filtering by content type
|
|
29
|
+
- **More Relevant Memories**: All types included unless user specifies
|
|
30
|
+
- **Clearer Agent Behavior**: Explicit guidance on when to use filters
|
|
31
|
+
- **Improved UX**: Users get comprehensive results by default
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## [2.6.3] - 2026-02-16
|
|
36
|
+
|
|
37
|
+
### 🐛 Fixed
|
|
38
|
+
|
|
39
|
+
- **CRITICAL: Fixed Empty Published Memories Bug**
|
|
40
|
+
- Published memories were empty shells with no content, title, or properties
|
|
41
|
+
- Root cause: `fetchObjectById()` calls missing `returnProperties` parameter
|
|
42
|
+
- Fixed in `remember_publish` and `remember_confirm` (executePublishMemory)
|
|
43
|
+
- All published memories now include complete property data
|
|
44
|
+
|
|
45
|
+
### ✨ Added
|
|
46
|
+
|
|
47
|
+
- **New Utility Function**: `fetchMemoryWithAllProperties()`
|
|
48
|
+
- Centralized helper in `src/weaviate/client.ts`
|
|
49
|
+
- Ensures all memory properties are fetched consistently
|
|
50
|
+
- Prevents future bugs from missing properties
|
|
51
|
+
- Includes `ALL_MEMORY_PROPERTIES` constant (20+ properties)
|
|
52
|
+
|
|
53
|
+
### 🔧 Improved
|
|
54
|
+
|
|
55
|
+
- Enhanced debug logging in publish flow
|
|
56
|
+
- Added property count verification
|
|
57
|
+
- Added hasTitle and hasContent checks
|
|
58
|
+
- Better diagnostics for troubleshooting
|
|
59
|
+
|
|
60
|
+
### 🎯 Impact
|
|
61
|
+
|
|
62
|
+
- **Fixes**: All published memories since v2.4.0 were empty
|
|
63
|
+
- **Search**: Published memories now searchable (have content)
|
|
64
|
+
- **Discovery**: Space functionality now works as designed
|
|
65
|
+
- **Note**: Existing empty memories need to be re-published
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
8
69
|
## [2.6.2] - 2026-02-16
|
|
9
70
|
|
|
10
71
|
### 🔒 Security
|
package/agent/progress.yaml
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
project:
|
|
4
4
|
name: remember-mcp
|
|
5
|
-
version: 2.
|
|
5
|
+
version: 2.6.3
|
|
6
6
|
started: 2026-02-11
|
|
7
7
|
status: in_progress
|
|
8
|
-
current_milestone:
|
|
8
|
+
current_milestone: M12
|
|
9
9
|
last_updated: 2026-02-16
|
|
10
10
|
|
|
11
11
|
milestones:
|
|
@@ -162,7 +162,26 @@ milestones:
|
|
|
162
162
|
✅ No memory duplication across spaces
|
|
163
163
|
✅ All tests passing with multi-space support
|
|
164
164
|
✅ Documentation updated with multi-space examples
|
|
165
|
-
|
|
165
|
+
|
|
166
|
+
- id: M12
|
|
167
|
+
name: Comment System (Phase 1)
|
|
168
|
+
status: in_progress
|
|
169
|
+
progress: 60%
|
|
170
|
+
started: 2026-02-16
|
|
171
|
+
completed: null
|
|
172
|
+
estimated_weeks: 1
|
|
173
|
+
tasks_completed: 3
|
|
174
|
+
tasks_total: 5
|
|
175
|
+
notes: |
|
|
176
|
+
✅ Task 55: Added 3 comment fields to schema (parent_id, thread_root_id, moderation_flags)
|
|
177
|
+
✅ Task 56: Updated remember_search_space with include_comments parameter
|
|
178
|
+
✅ Task 57: Updated remember_query_space with include_comments parameter
|
|
179
|
+
📋 Task 58: Add Comment Unit Tests (pending)
|
|
180
|
+
📋 Task 59: Update Documentation for Comments (pending)
|
|
181
|
+
✅ Zero new tools required - reuses existing infrastructure
|
|
182
|
+
✅ Backward compatible - comments excluded by default
|
|
183
|
+
✅ Released v2.6.0 with comment system foundation
|
|
184
|
+
|
|
166
185
|
- id: M7
|
|
167
186
|
name: Trust & Permissions
|
|
168
187
|
status: not_started
|
|
@@ -406,11 +425,97 @@ tasks:
|
|
|
406
425
|
✅ Context inclusion toggle
|
|
407
426
|
✅ Integrated into server.ts and server-factory.ts
|
|
408
427
|
|
|
428
|
+
milestone_12:
|
|
429
|
+
- id: task-55
|
|
430
|
+
name: Add Comment Fields to Weaviate Schema
|
|
431
|
+
status: completed
|
|
432
|
+
file: agent/tasks/task-55-add-comment-fields-to-schema.md
|
|
433
|
+
estimated_hours: 2
|
|
434
|
+
completed_date: 2026-02-16
|
|
435
|
+
notes: |
|
|
436
|
+
✅ Added 3 fields to Memory schema: parent_id, thread_root_id, moderation_flags
|
|
437
|
+
✅ Added same fields to Memory_public collection
|
|
438
|
+
✅ Enables infinite comment nesting
|
|
439
|
+
✅ Per-space moderation support
|
|
440
|
+
✅ Released in v2.6.0
|
|
441
|
+
|
|
442
|
+
- id: task-56
|
|
443
|
+
name: Update remember_search_space for Comments
|
|
444
|
+
status: completed
|
|
445
|
+
file: agent/tasks/task-56-update-search-space-for-comments.md
|
|
446
|
+
estimated_hours: 2
|
|
447
|
+
completed_date: 2026-02-16
|
|
448
|
+
notes: |
|
|
449
|
+
✅ Added include_comments parameter (default: false)
|
|
450
|
+
✅ Comments excluded from search by default
|
|
451
|
+
✅ Opt-in via include_comments: true
|
|
452
|
+
✅ Backward compatible
|
|
453
|
+
✅ Released in v2.6.0
|
|
454
|
+
|
|
455
|
+
- id: task-57
|
|
456
|
+
name: Update remember_query_space for Comments
|
|
457
|
+
status: completed
|
|
458
|
+
file: agent/tasks/task-57-update-query-space-for-comments.md
|
|
459
|
+
estimated_hours: 1
|
|
460
|
+
completed_date: 2026-02-16
|
|
461
|
+
notes: |
|
|
462
|
+
✅ Added include_comments parameter (default: false)
|
|
463
|
+
✅ Same filtering logic as search_space
|
|
464
|
+
✅ Backward compatible
|
|
465
|
+
✅ Released in v2.6.0
|
|
466
|
+
|
|
467
|
+
- id: task-58
|
|
468
|
+
name: Add Comment Unit Tests
|
|
469
|
+
status: not_started
|
|
470
|
+
file: agent/tasks/task-58-add-comment-unit-tests.md
|
|
471
|
+
estimated_hours: 3
|
|
472
|
+
notes: |
|
|
473
|
+
📋 Pending: Schema tests, filtering tests, edge cases
|
|
474
|
+
📋 Test infinite nesting support
|
|
475
|
+
📋 Test moderation flags
|
|
476
|
+
|
|
477
|
+
- id: task-59
|
|
478
|
+
name: Update Documentation for Comments
|
|
479
|
+
status: not_started
|
|
480
|
+
file: agent/tasks/task-59-update-documentation-for-comments.md
|
|
481
|
+
estimated_hours: 2
|
|
482
|
+
notes: |
|
|
483
|
+
📋 Pending: README updates, CHANGELOG entry, examples
|
|
484
|
+
📋 Document comment creation workflow
|
|
485
|
+
📋 Add threading examples
|
|
486
|
+
|
|
487
|
+
- id: task-60
|
|
488
|
+
name: Standardize Structured Logging
|
|
489
|
+
status: completed
|
|
490
|
+
file: agent/tasks/task-60-standardize-structured-logging.md
|
|
491
|
+
estimated_hours: 3
|
|
492
|
+
completed_date: 2026-02-16
|
|
493
|
+
notes: |
|
|
494
|
+
✅ Replaced 54 console.log/error/warn calls with structured logger
|
|
495
|
+
✅ Updated 8 files: confirmation-token.service, publish, confirm, deny, weaviate client/schema/space-schema, firestore init, config
|
|
496
|
+
✅ All logs include context objects (service, module, tool names)
|
|
497
|
+
✅ Fixed circular dependency in config.ts with dynamic import
|
|
498
|
+
✅ Released in v2.6.1
|
|
499
|
+
|
|
500
|
+
- id: task-61
|
|
501
|
+
name: Enhance Confirmation Tool Safety Guidelines
|
|
502
|
+
status: completed
|
|
503
|
+
file: agent/tasks/task-61-enhance-confirmation-tool-descriptions.md
|
|
504
|
+
estimated_hours: 1
|
|
505
|
+
completed_date: 2026-02-16
|
|
506
|
+
notes: |
|
|
507
|
+
✅ Enhanced remember_confirm tool description with 5 critical safety requirements
|
|
508
|
+
✅ Enhanced remember_deny tool description with same safety guidelines
|
|
509
|
+
✅ Added JSDoc comments explaining proper workflow
|
|
510
|
+
✅ Prevents agents from bypassing user consent
|
|
511
|
+
✅ Visual indicators (⚠️) for critical requirements
|
|
512
|
+
✅ Released in v2.6.2
|
|
513
|
+
|
|
409
514
|
documentation:
|
|
410
515
|
design_documents: 23
|
|
411
|
-
milestone_documents:
|
|
516
|
+
milestone_documents: 11
|
|
412
517
|
pattern_documents: 5
|
|
413
|
-
task_documents:
|
|
518
|
+
task_documents: 61
|
|
414
519
|
|
|
415
520
|
progress:
|
|
416
521
|
planning: 100%
|
|
@@ -418,6 +523,33 @@ progress:
|
|
|
418
523
|
overall: 50%
|
|
419
524
|
|
|
420
525
|
recent_work:
|
|
526
|
+
- date: 2026-02-16
|
|
527
|
+
description: Comment System, Structured Logging, and Safety Guidelines (v2.6.0-v2.6.2)
|
|
528
|
+
items:
|
|
529
|
+
- 🎉 M12 STARTED: Comment System (Phase 1) - 60% complete (3/5 tasks)
|
|
530
|
+
- ✅ Task 55: Added 3 comment fields to Weaviate schema
|
|
531
|
+
- ✅ parent_id, thread_root_id, moderation_flags fields added
|
|
532
|
+
- ✅ Enables infinite comment nesting with no depth limit
|
|
533
|
+
- ✅ Per-space moderation flags support
|
|
534
|
+
- ✅ Task 56: Updated remember_search_space with include_comments parameter
|
|
535
|
+
- ✅ Comments excluded by default for clean discovery
|
|
536
|
+
- ✅ Opt-in via include_comments: true
|
|
537
|
+
- ✅ Task 57: Updated remember_query_space with include_comments parameter
|
|
538
|
+
- ✅ Same filtering logic as search_space
|
|
539
|
+
- ✅ Released v2.6.0 with comment system foundation
|
|
540
|
+
- ✅ Task 60: Standardized structured logging across 8 files
|
|
541
|
+
- ✅ Replaced 54 console.log/error/warn calls with logger.info/error/warn/debug
|
|
542
|
+
- ✅ All logs include context objects (service, module, tool names)
|
|
543
|
+
- ✅ Fixed circular dependency in config.ts with dynamic import
|
|
544
|
+
- ✅ Released v2.6.1 with structured logging
|
|
545
|
+
- ✅ Task 61: Enhanced confirmation tool safety guidelines
|
|
546
|
+
- ✅ Added 5 critical safety requirements to remember_confirm and remember_deny
|
|
547
|
+
- ✅ Prevents agents from chaining confirmations without user consent
|
|
548
|
+
- ✅ Visual indicators (⚠️) and JSDoc comments added
|
|
549
|
+
- ✅ Released v2.6.2 with safety enhancements
|
|
550
|
+
- 📋 Next: Complete M12 with Tasks 58-59 (tests + documentation)
|
|
551
|
+
- 📋 6 commits ready to push to origin
|
|
552
|
+
|
|
421
553
|
- date: 2026-02-16
|
|
422
554
|
description: ACP Initialization Complete - Multi-Space Architecture Verified (v2.5.1)
|
|
423
555
|
items:
|
|
@@ -743,18 +875,21 @@ recent_work:
|
|
|
743
875
|
- ✅ Build successful
|
|
744
876
|
|
|
745
877
|
next_steps:
|
|
746
|
-
-
|
|
747
|
-
-
|
|
748
|
-
-
|
|
749
|
-
-
|
|
750
|
-
-
|
|
751
|
-
-
|
|
878
|
+
- Complete Task 58: Add Comment Unit Tests (3 hours)
|
|
879
|
+
- Complete Task 59: Update Documentation for Comments (2 hours)
|
|
880
|
+
- Push 6 commits to origin (v2.6.0, v2.6.1, v2.6.2)
|
|
881
|
+
- Deploy v2.6.2 to Cloud Run
|
|
882
|
+
- Test comment system end-to-end (create, search, thread fetching)
|
|
883
|
+
- Test structured logging in Cloud Run logs
|
|
884
|
+
- Verify confirmation tool safety guidelines in production
|
|
885
|
+
- Complete M12: Comment System (Phase 1)
|
|
752
886
|
- Start M5: Template System (15 default templates + auto-suggestion)
|
|
753
887
|
- Optional: Create integration tests (Task 6)
|
|
754
888
|
- Optional: Add development documentation (Task 7)
|
|
755
889
|
- Consider M6: Auth & Multi-Tenancy
|
|
756
890
|
|
|
757
891
|
notes:
|
|
892
|
+
- 🚀 Milestone 12 (Comment System Phase 1) IN PROGRESS - 60% complete!
|
|
758
893
|
- 🎉 Milestone 11 (Unified Public Collection) COMPLETED!
|
|
759
894
|
- 🎉 Milestone 10 (Shared Spaces & Confirmation Flow) COMPLETED!
|
|
760
895
|
- 🎉 Milestone 4 (User Preferences) COMPLETED!
|
|
@@ -769,6 +904,10 @@ notes:
|
|
|
769
904
|
- ✅ M4: 2/2 preference tools complete (100% progress)
|
|
770
905
|
- ✅ M10: 10/10 shared space tools complete (100% progress)
|
|
771
906
|
- ✅ M11: 9/9 multi-space architecture tasks complete (100% progress)
|
|
907
|
+
- 🚀 M12: 3/5 comment system tasks complete (60% progress)
|
|
908
|
+
- ✅ Comment system foundation implemented (v2.6.0)
|
|
909
|
+
- ✅ Structured logging standardized (v2.6.1)
|
|
910
|
+
- ✅ Confirmation tool safety enhanced (v2.6.2)
|
|
772
911
|
- ✅ Complete memory CRUD operations (create, read, update, delete)
|
|
773
912
|
- ✅ Complete relationship CRUD operations (create, read, update, delete)
|
|
774
913
|
- ✅ Advanced search capabilities (hybrid, similarity, RAG queries)
|
|
@@ -833,8 +972,10 @@ build_status:
|
|
|
833
972
|
- ✅ Source maps generated
|
|
834
973
|
- ✅ Type definitions generated (.d.ts files)
|
|
835
974
|
- ✅ Package exports configured for both entry points
|
|
836
|
-
- ✅ Version 2.
|
|
837
|
-
- ✅
|
|
975
|
+
- ✅ Version 2.6.2 published (patch release - safety guidelines)
|
|
976
|
+
- ✅ Version 2.6.1 published (patch release - structured logging)
|
|
977
|
+
- ✅ Version 2.6.0 published (minor release - comment system)
|
|
978
|
+
- ✅ 30 TypeScript source files
|
|
838
979
|
- ✅ All 12 tools implemented
|
|
839
980
|
- ✅ Weaviate v3 filter API implemented
|
|
840
981
|
- ✅ Or/And operator validation implemented
|
|
@@ -857,6 +998,12 @@ tools_status:
|
|
|
857
998
|
preference_tools:
|
|
858
999
|
- ✅ remember_set_preference (src/tools/set-preference.ts)
|
|
859
1000
|
- ✅ remember_get_preferences (src/tools/get-preferences.ts)
|
|
1001
|
+
space_tools:
|
|
1002
|
+
- ✅ remember_publish (src/tools/publish.ts) - Multi-space support
|
|
1003
|
+
- ✅ remember_confirm (src/tools/confirm.ts) - Enhanced safety guidelines
|
|
1004
|
+
- ✅ remember_deny (src/tools/deny.ts) - Enhanced safety guidelines
|
|
1005
|
+
- ✅ remember_search_space (src/tools/search-space.ts) - Comment filtering
|
|
1006
|
+
- ✅ remember_query_space (src/tools/query-space.ts) - Comment filtering
|
|
860
1007
|
|
|
861
1008
|
implementation_notes:
|
|
862
1009
|
- All 12 core tools implemented and integrated
|
|
@@ -899,3 +1046,6 @@ task_20_completion:
|
|
|
899
1046
|
releases:
|
|
900
1047
|
- v1.0.0: Major release with breaking change (async createServer)
|
|
901
1048
|
- v1.0.1: Patch release with Or operator bug fix
|
|
1049
|
+
- v2.6.0: Minor release with comment system foundation
|
|
1050
|
+
- v2.6.1: Patch release with structured logging
|
|
1051
|
+
- v2.6.2: Patch release with confirmation tool safety guidelines
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
# Task 62: Fix Confirmation Response Storage
|
|
2
|
+
|
|
3
|
+
**Milestone**: M12 (Comment System / Bug Fixes)
|
|
4
|
+
**Estimated Time**: 2 hours
|
|
5
|
+
**Dependencies**: None
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
**Priority**: High
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Objective
|
|
12
|
+
|
|
13
|
+
Fix bug where `remember_confirm` executes actions successfully but doesn't store the response data in the Firestore confirmation record. This prevents agents and users from verifying action results and breaks the audit trail.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Context
|
|
18
|
+
|
|
19
|
+
**Current Behavior:**
|
|
20
|
+
1. `remember_confirm` validates token and marks request as "confirmed"
|
|
21
|
+
2. Action executes successfully (e.g., `executePublishMemory`)
|
|
22
|
+
3. Response data (space_memory_id, etc.) is returned to agent
|
|
23
|
+
4. **BUG**: Response data is NOT saved to Firestore
|
|
24
|
+
5. Database record shows `status: confirmed` but no response/result data
|
|
25
|
+
|
|
26
|
+
**Impact:**
|
|
27
|
+
- ⚠️ Agents cannot verify publication success
|
|
28
|
+
- ⚠️ No space_memory_id available for reference
|
|
29
|
+
- ⚠️ Audit trail incomplete
|
|
30
|
+
- ⚠️ Cannot track what happened after confirmation
|
|
31
|
+
|
|
32
|
+
**Root Cause:**
|
|
33
|
+
- `ConfirmationRequest` interface lacks `response` field
|
|
34
|
+
- `confirmRequest()` method only updates status, not response
|
|
35
|
+
- `executePublishMemory()` returns data but doesn't persist it
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Steps
|
|
40
|
+
|
|
41
|
+
### 1. Update ConfirmationRequest Interface
|
|
42
|
+
|
|
43
|
+
Add response field to store action results:
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
// src/services/confirmation-token.service.ts
|
|
47
|
+
|
|
48
|
+
export interface ConfirmationRequest {
|
|
49
|
+
user_id: string;
|
|
50
|
+
token: string;
|
|
51
|
+
action: string;
|
|
52
|
+
target_collection?: string;
|
|
53
|
+
payload: any;
|
|
54
|
+
created_at: string;
|
|
55
|
+
expires_at: string;
|
|
56
|
+
status: 'pending' | 'confirmed' | 'denied' | 'expired' | 'retracted';
|
|
57
|
+
confirmed_at?: string;
|
|
58
|
+
response?: any; // ✅ ADD THIS - Stores action execution result
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 2. Add storeResponse Method
|
|
63
|
+
|
|
64
|
+
Create method to store response data after action execution:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
// src/services/confirmation-token.service.ts
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Store response data for a confirmed request
|
|
71
|
+
*
|
|
72
|
+
* @param userId - User ID
|
|
73
|
+
* @param requestId - Request ID
|
|
74
|
+
* @param response - Response data from action execution
|
|
75
|
+
*/
|
|
76
|
+
async storeResponse(
|
|
77
|
+
userId: string,
|
|
78
|
+
requestId: string,
|
|
79
|
+
response: any
|
|
80
|
+
): Promise<void> {
|
|
81
|
+
logger.info('Storing confirmation response', {
|
|
82
|
+
service: 'ConfirmationTokenService',
|
|
83
|
+
userId,
|
|
84
|
+
requestId,
|
|
85
|
+
hasResponse: !!response,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const docPath = `users/${userId}/requests/${requestId}`;
|
|
89
|
+
|
|
90
|
+
await updateDocument(docPath, {
|
|
91
|
+
response,
|
|
92
|
+
updated_at: new Date().toISOString(),
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
logger.info('Response stored successfully', {
|
|
96
|
+
service: 'ConfirmationTokenService',
|
|
97
|
+
requestId,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 3. Update handleConfirm to Store Response
|
|
103
|
+
|
|
104
|
+
Modify `remember_confirm` to persist response data:
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
// src/tools/confirm.ts
|
|
108
|
+
|
|
109
|
+
export async function handleConfirm(
|
|
110
|
+
args: ConfirmArgs,
|
|
111
|
+
userId: string
|
|
112
|
+
): Promise<string> {
|
|
113
|
+
try {
|
|
114
|
+
logger.info('Starting confirmation', {
|
|
115
|
+
tool: 'remember_confirm',
|
|
116
|
+
userId,
|
|
117
|
+
token: args.token,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Validate and confirm token
|
|
121
|
+
const request = await confirmationTokenService.confirmRequest(userId, args.token);
|
|
122
|
+
|
|
123
|
+
if (!request) {
|
|
124
|
+
logger.info('Token invalid or expired', {
|
|
125
|
+
tool: 'remember_confirm',
|
|
126
|
+
userId,
|
|
127
|
+
});
|
|
128
|
+
return JSON.stringify({
|
|
129
|
+
success: false,
|
|
130
|
+
error: 'Invalid or expired token',
|
|
131
|
+
message: 'The confirmation token is invalid, expired, or has already been used.',
|
|
132
|
+
}, null, 2);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
logger.info('Executing confirmed action', {
|
|
136
|
+
tool: 'remember_confirm',
|
|
137
|
+
action: request.action,
|
|
138
|
+
userId,
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// Execute action based on type
|
|
142
|
+
let responseJson: string;
|
|
143
|
+
if (request.action === 'publish_memory') {
|
|
144
|
+
responseJson = await executePublishMemory(request, userId);
|
|
145
|
+
} else {
|
|
146
|
+
throw new Error(`Unknown action type: ${request.action}`);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// ✅ NEW: Parse and store response data
|
|
150
|
+
try {
|
|
151
|
+
const responseData = JSON.parse(responseJson);
|
|
152
|
+
|
|
153
|
+
logger.info('Storing action response', {
|
|
154
|
+
tool: 'remember_confirm',
|
|
155
|
+
requestId: request.request_id,
|
|
156
|
+
success: responseData.success,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
await confirmationTokenService.storeResponse(
|
|
160
|
+
userId,
|
|
161
|
+
request.request_id,
|
|
162
|
+
responseData
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
logger.info('Response stored successfully', {
|
|
166
|
+
tool: 'remember_confirm',
|
|
167
|
+
requestId: request.request_id,
|
|
168
|
+
});
|
|
169
|
+
} catch (parseError) {
|
|
170
|
+
logger.warn('Failed to parse/store response', {
|
|
171
|
+
tool: 'remember_confirm',
|
|
172
|
+
error: parseError instanceof Error ? parseError.message : String(parseError),
|
|
173
|
+
});
|
|
174
|
+
// Don't fail the whole operation if storage fails
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Return response to agent
|
|
178
|
+
return responseJson;
|
|
179
|
+
} catch (error) {
|
|
180
|
+
handleToolError(error, {
|
|
181
|
+
toolName: 'remember_confirm',
|
|
182
|
+
userId,
|
|
183
|
+
operation: 'confirm action',
|
|
184
|
+
token: args.token,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### 4. Update Tests
|
|
191
|
+
|
|
192
|
+
Add tests for response storage:
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
// tests/unit/confirmation-token.service.test.ts
|
|
196
|
+
|
|
197
|
+
describe('ConfirmationTokenService', () => {
|
|
198
|
+
describe('storeResponse', () => {
|
|
199
|
+
it('should store response data for confirmed request', async () => {
|
|
200
|
+
const service = new ConfirmationTokenService();
|
|
201
|
+
const userId = 'test-user';
|
|
202
|
+
const requestId = 'test-request';
|
|
203
|
+
const response = {
|
|
204
|
+
success: true,
|
|
205
|
+
space_memory_id: 'space-123',
|
|
206
|
+
spaces: ['the_void'],
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
await service.storeResponse(userId, requestId, response);
|
|
210
|
+
|
|
211
|
+
// Verify response was stored
|
|
212
|
+
const request = await getDocument(`users/${userId}/requests/${requestId}`);
|
|
213
|
+
expect(request.response).toEqual(response);
|
|
214
|
+
expect(request.updated_at).toBeDefined();
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### 5. Update Documentation
|
|
221
|
+
|
|
222
|
+
Document the response field in design docs:
|
|
223
|
+
|
|
224
|
+
```markdown
|
|
225
|
+
# agent/design/publish-tools-confirmation-flow.md
|
|
226
|
+
|
|
227
|
+
## Confirmation Record Structure
|
|
228
|
+
|
|
229
|
+
After confirmation, the record includes:
|
|
230
|
+
- `status`: 'confirmed'
|
|
231
|
+
- `confirmed_at`: ISO timestamp
|
|
232
|
+
- `response`: Action execution result (NEW)
|
|
233
|
+
- For publish_memory: { success, space_memory_id, spaces }
|
|
234
|
+
- For other actions: Action-specific response data
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Verification
|
|
240
|
+
|
|
241
|
+
- [ ] ConfirmationRequest interface has `response?: any` field
|
|
242
|
+
- [ ] `storeResponse()` method exists in ConfirmationTokenService
|
|
243
|
+
- [ ] `handleConfirm` calls `storeResponse()` after action execution
|
|
244
|
+
- [ ] Response data is persisted to Firestore
|
|
245
|
+
- [ ] Agent receives response data in tool output
|
|
246
|
+
- [ ] Database record contains response field after confirmation
|
|
247
|
+
- [ ] Tests pass for response storage
|
|
248
|
+
- [ ] TypeScript compiles without errors
|
|
249
|
+
- [ ] Build successful
|
|
250
|
+
- [ ] Manual test: Publish memory and verify response in Firestore
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Expected Output
|
|
255
|
+
|
|
256
|
+
**Before Fix:**
|
|
257
|
+
```json
|
|
258
|
+
{
|
|
259
|
+
"status": "confirmed",
|
|
260
|
+
"confirmed_at": "2026-02-16T21:44:39.154Z",
|
|
261
|
+
"action": "publish_memory",
|
|
262
|
+
"payload": { "memory_id": "...", "spaces": ["the_void"] }
|
|
263
|
+
// ❌ No response field
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**After Fix:**
|
|
268
|
+
```json
|
|
269
|
+
{
|
|
270
|
+
"status": "confirmed",
|
|
271
|
+
"confirmed_at": "2026-02-16T21:44:39.154Z",
|
|
272
|
+
"action": "publish_memory",
|
|
273
|
+
"payload": { "memory_id": "...", "spaces": ["the_void"] },
|
|
274
|
+
"response": {
|
|
275
|
+
"success": true,
|
|
276
|
+
"space_memory_id": "9b536938-1188-4e69-b3cd-4362d84fff1c",
|
|
277
|
+
"spaces": ["the_void"]
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## Common Issues and Solutions
|
|
285
|
+
|
|
286
|
+
### Issue 1: Response not storing
|
|
287
|
+
|
|
288
|
+
**Cause**: Parse error or Firestore write failure
|
|
289
|
+
**Solution**: Check logs for errors, verify Firestore permissions
|
|
290
|
+
|
|
291
|
+
### Issue 2: Response field undefined
|
|
292
|
+
|
|
293
|
+
**Cause**: Old records don't have response field
|
|
294
|
+
**Solution**: This is expected - only new confirmations will have response
|
|
295
|
+
|
|
296
|
+
### Issue 3: Response too large for Firestore
|
|
297
|
+
|
|
298
|
+
**Cause**: Response data exceeds Firestore document size limit (1MB)
|
|
299
|
+
**Solution**: Store only essential fields (space_memory_id, success, spaces)
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## Resources
|
|
304
|
+
|
|
305
|
+
- [Firestore Document Limits](https://firebase.google.com/docs/firestore/quotas)
|
|
306
|
+
- [ConfirmationTokenService](../src/services/confirmation-token.service.ts)
|
|
307
|
+
- [remember_confirm Tool](../src/tools/confirm.ts)
|
|
308
|
+
- [Confirmation Flow Design](../design/publish-tools-confirmation-flow.md)
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## Notes
|
|
313
|
+
|
|
314
|
+
- This is a backward-compatible change - old records without response field will continue to work
|
|
315
|
+
- Response storage is best-effort - if it fails, the action still succeeds
|
|
316
|
+
- Response data is primarily for audit trail and debugging
|
|
317
|
+
- Agents receive response data regardless of storage success
|
|
318
|
+
- Consider adding response field to remember_deny as well (for consistency)
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
**Status**: Not Started
|
|
323
|
+
**Recommendation**: Implement this fix before completing M12 to ensure proper audit trail
|