@prmichaelsen/remember-mcp 2.2.1 → 2.3.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/AGENT.md +98 -5
- package/CHANGELOG.md +45 -0
- package/README.md +43 -3
- package/agent/commands/acp.init.md +376 -0
- package/agent/commands/acp.package-install.md +347 -0
- package/agent/commands/acp.proceed.md +311 -0
- package/agent/commands/acp.report.md +392 -0
- package/agent/commands/acp.status.md +280 -0
- package/agent/commands/acp.sync.md +323 -0
- package/agent/commands/acp.update.md +301 -0
- package/agent/commands/acp.validate.md +385 -0
- package/agent/commands/acp.version-check-for-updates.md +275 -0
- package/agent/commands/acp.version-check.md +190 -0
- package/agent/commands/acp.version-update.md +288 -0
- package/agent/commands/command.template.md +273 -0
- package/agent/design/core-memory-user-profile.md +1253 -0
- package/agent/design/ghost-profiles-pseudonymous-identity.md +194 -0
- package/agent/design/publish-tools-confirmation-flow.md +922 -0
- package/agent/milestones/milestone-10-shared-spaces.md +169 -0
- package/agent/progress.yaml +90 -4
- package/agent/scripts/install.sh +118 -0
- package/agent/scripts/update.sh +22 -10
- package/agent/scripts/version.sh +35 -0
- package/agent/tasks/task-27-implement-llm-provider-interface.md +51 -0
- package/agent/tasks/task-28-implement-llm-provider-factory.md +64 -0
- package/agent/tasks/task-29-update-config-for-llm.md +71 -0
- package/agent/tasks/task-30-implement-bedrock-provider.md +147 -0
- package/agent/tasks/task-31-implement-background-job-service.md +120 -0
- package/agent/tasks/task-32-test-llm-provider-integration.md +152 -0
- package/agent/tasks/task-34-create-confirmation-token-service.md +191 -0
- package/agent/tasks/task-35-create-space-memory-types-schema.md +183 -0
- package/agent/tasks/task-36-implement-remember-publish.md +227 -0
- package/agent/tasks/task-37-implement-remember-confirm.md +225 -0
- package/agent/tasks/task-38-implement-remember-deny.md +161 -0
- package/agent/tasks/task-39-implement-remember-search-space.md +188 -0
- package/agent/tasks/task-40-implement-remember-query-space.md +193 -0
- package/agent/tasks/task-41-configure-firestore-ttl.md +188 -0
- package/agent/tasks/task-42-create-tests-shared-spaces.md +216 -0
- package/agent/tasks/task-43-update-documentation.md +255 -0
- package/agent/tasks/task-44-implement-remember-retract.md +263 -0
- package/agent/tasks/task-45-fix-publish-false-success-bug.md +230 -0
- package/dist/llm/types.d.ts +1 -0
- package/dist/server-factory.js +1000 -1
- package/dist/server.js +1002 -3
- package/dist/services/confirmation-token.service.d.ts +99 -0
- package/dist/services/confirmation-token.service.spec.d.ts +5 -0
- package/dist/tools/confirm.d.ts +20 -0
- package/dist/tools/deny.d.ts +19 -0
- package/dist/tools/publish.d.ts +22 -0
- package/dist/tools/query-space.d.ts +28 -0
- package/dist/tools/search-space.d.ts +29 -0
- package/dist/types/space-memory.d.ts +80 -0
- package/dist/weaviate/space-schema.d.ts +59 -0
- package/dist/weaviate/space-schema.spec.d.ts +5 -0
- package/package.json +1 -1
- package/src/llm/types.ts +0 -0
- package/src/server-factory.ts +33 -0
- package/src/server.ts +33 -0
- package/src/services/confirmation-token.service.spec.ts +254 -0
- package/src/services/confirmation-token.service.ts +265 -0
- package/src/tools/confirm.ts +219 -0
- package/src/tools/create-memory.ts +7 -0
- package/src/tools/deny.ts +70 -0
- package/src/tools/publish.ts +190 -0
- package/src/tools/query-space.ts +197 -0
- package/src/tools/search-space.ts +189 -0
- package/src/types/space-memory.ts +94 -0
- package/src/weaviate/space-schema.spec.ts +131 -0
- package/src/weaviate/space-schema.ts +275 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Task 35: Create Space Memory Types and Schema
|
|
2
|
+
|
|
3
|
+
**Milestone**: M10 - Shared Spaces & Confirmation Flow
|
|
4
|
+
**Estimated Time**: 3 hours
|
|
5
|
+
**Dependencies**: Task 34 (Token Service), M2 (Memory types)
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Objective
|
|
11
|
+
|
|
12
|
+
Create TypeScript types for space memories and Weaviate schema for shared space collections. Space memories are similar to personal memories but stored in shared collections with additional metadata for discovery and attribution.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Steps
|
|
17
|
+
|
|
18
|
+
### 1. Create SpaceMemory Type Definitions
|
|
19
|
+
|
|
20
|
+
Create `src/types/space-memory.ts` with space-specific types.
|
|
21
|
+
|
|
22
|
+
**Actions**:
|
|
23
|
+
- Import base Memory type from `memory.ts`
|
|
24
|
+
- Define SpaceMemory interface extending Memory
|
|
25
|
+
- Add space-specific fields: `space_id`, `author_id`, `ghost_id`, `published_at`, `discovery_count`
|
|
26
|
+
- Define SpaceSearchOptions and SpaceSearchResult types
|
|
27
|
+
- Add JSDoc comments
|
|
28
|
+
|
|
29
|
+
**Expected Outcome**: SpaceMemory types defined
|
|
30
|
+
|
|
31
|
+
### 2. Create Space Schema File
|
|
32
|
+
|
|
33
|
+
Create `src/weaviate/space-schema.ts` for space collection management.
|
|
34
|
+
|
|
35
|
+
**Actions**:
|
|
36
|
+
- Import Weaviate client utilities
|
|
37
|
+
- Create `ensureSpaceCollection` function
|
|
38
|
+
- Define space collection schema (similar to Memory schema)
|
|
39
|
+
- Handle collection creation if doesn't exist
|
|
40
|
+
- Export helper functions
|
|
41
|
+
|
|
42
|
+
**Expected Outcome**: Space schema utilities created
|
|
43
|
+
|
|
44
|
+
### 3. Implement ensureSpaceCollection Function
|
|
45
|
+
|
|
46
|
+
Ensure a space collection exists, creating it if needed.
|
|
47
|
+
|
|
48
|
+
**Actions**:
|
|
49
|
+
- Accept space_id parameter (e.g., "the_void")
|
|
50
|
+
- Generate collection name: `Memory_{space_id}`
|
|
51
|
+
- Check if collection exists
|
|
52
|
+
- If not, create with schema
|
|
53
|
+
- Return collection reference
|
|
54
|
+
- Handle errors gracefully
|
|
55
|
+
|
|
56
|
+
**Expected Outcome**: Collections can be created on-demand
|
|
57
|
+
|
|
58
|
+
### 4. Define Space Collection Schema
|
|
59
|
+
|
|
60
|
+
Create Weaviate schema for space collections.
|
|
61
|
+
|
|
62
|
+
**Actions**:
|
|
63
|
+
- Use same properties as Memory collection
|
|
64
|
+
- Add space-specific properties: `space_id`, `author_id`, `ghost_id`, `published_at`, `discovery_count`
|
|
65
|
+
- Configure OpenAI vectorizer
|
|
66
|
+
- Set vectorization properties
|
|
67
|
+
- Add indexes for common queries
|
|
68
|
+
|
|
69
|
+
**Expected Outcome**: Space collections have proper schema
|
|
70
|
+
|
|
71
|
+
### 5. Create Collection Name Utilities
|
|
72
|
+
|
|
73
|
+
Helper functions for space collection naming.
|
|
74
|
+
|
|
75
|
+
**Actions**:
|
|
76
|
+
- `getSpaceCollectionName(space_id)` - Returns `Memory_{space_id}`
|
|
77
|
+
- `sanitizeSpaceId(display_name)` - Converts "The Void" → "the_void"
|
|
78
|
+
- `getSpaceDisplayName(space_id)` - Maps IDs to display names
|
|
79
|
+
- Add validation for space IDs
|
|
80
|
+
|
|
81
|
+
**Expected Outcome**: Naming utilities available
|
|
82
|
+
|
|
83
|
+
### 6. Add Space ID Constants
|
|
84
|
+
|
|
85
|
+
Define supported space IDs as constants.
|
|
86
|
+
|
|
87
|
+
**Actions**:
|
|
88
|
+
- Create `SUPPORTED_SPACES` constant
|
|
89
|
+
- Map space IDs to display names
|
|
90
|
+
- Export for use in tools
|
|
91
|
+
- Add type for space IDs
|
|
92
|
+
|
|
93
|
+
**Expected Outcome**: Space IDs centralized
|
|
94
|
+
|
|
95
|
+
### 7. Create Unit Tests
|
|
96
|
+
|
|
97
|
+
Test space schema and utilities.
|
|
98
|
+
|
|
99
|
+
**Actions**:
|
|
100
|
+
- Create `tests/unit/space-schema.test.ts`
|
|
101
|
+
- Test `ensureSpaceCollection` function
|
|
102
|
+
- Test collection name generation
|
|
103
|
+
- Test space ID sanitization
|
|
104
|
+
- Test display name mapping
|
|
105
|
+
- Mock Weaviate client
|
|
106
|
+
|
|
107
|
+
**Expected Outcome**: All tests passing
|
|
108
|
+
|
|
109
|
+
### 8. Update Type Exports
|
|
110
|
+
|
|
111
|
+
Export new types from main types file.
|
|
112
|
+
|
|
113
|
+
**Actions**:
|
|
114
|
+
- Add exports to `src/types/memory.ts` or create index
|
|
115
|
+
- Ensure SpaceMemory types are accessible
|
|
116
|
+
- Update any type documentation
|
|
117
|
+
|
|
118
|
+
**Expected Outcome**: Types properly exported
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Verification
|
|
123
|
+
|
|
124
|
+
- [ ] `src/types/space-memory.ts` created with SpaceMemory interface
|
|
125
|
+
- [ ] `src/weaviate/space-schema.ts` created
|
|
126
|
+
- [ ] `ensureSpaceCollection` function implemented
|
|
127
|
+
- [ ] Space collection schema defined
|
|
128
|
+
- [ ] Collection naming utilities created
|
|
129
|
+
- [ ] Space ID constants defined
|
|
130
|
+
- [ ] Unit tests created and passing
|
|
131
|
+
- [ ] TypeScript compiles without errors
|
|
132
|
+
- [ ] Types properly exported
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Code Example
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
// src/types/space-memory.ts
|
|
140
|
+
export interface SpaceMemory extends Memory {
|
|
141
|
+
space_id: string; // "the_void", "public_space"
|
|
142
|
+
author_id: string; // Original user_id (for permissions)
|
|
143
|
+
ghost_id?: string; // Optional ghost profile
|
|
144
|
+
published_at: string; // ISO 8601 timestamp
|
|
145
|
+
discovery_count: number; // How many times discovered
|
|
146
|
+
attribution: 'user' | 'ghost';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// src/weaviate/space-schema.ts
|
|
150
|
+
export async function ensureSpaceCollection(
|
|
151
|
+
client: WeaviateClient,
|
|
152
|
+
spaceId: string
|
|
153
|
+
): Promise<Collection> {
|
|
154
|
+
const collectionName = getSpaceCollectionName(spaceId);
|
|
155
|
+
|
|
156
|
+
const exists = await client.collections.exists(collectionName);
|
|
157
|
+
if (!exists) {
|
|
158
|
+
await createSpaceCollection(client, spaceId);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return client.collections.get(collectionName);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function getSpaceCollectionName(spaceId: string): string {
|
|
165
|
+
return `Memory_${spaceId}`;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function sanitizeSpaceId(displayName: string): string {
|
|
169
|
+
return displayName.toLowerCase().replace(/\s+/g, '_');
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Related Files
|
|
176
|
+
|
|
177
|
+
- Design: [`agent/design/publish-tools-confirmation-flow.md`](../design/publish-tools-confirmation-flow.md)
|
|
178
|
+
- Memory types: [`src/types/memory.ts`](../../src/types/memory.ts)
|
|
179
|
+
- Memory schema: [`src/weaviate/schema.ts`](../../src/weaviate/schema.ts)
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
**Next Task**: Task 36 - Implement remember_publish Tool
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# Task 36: Implement remember_publish Tool
|
|
2
|
+
|
|
3
|
+
**Milestone**: M10 - Shared Spaces & Confirmation Flow
|
|
4
|
+
**Estimated Time**: 4 hours
|
|
5
|
+
**Dependencies**: Task 34 (Token Service), Task 35 (Space Types)
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Objective
|
|
11
|
+
|
|
12
|
+
Implement the `remember_publish` tool that generates a confirmation token for publishing a memory to a shared space. This is the first step in the two-phase publish workflow.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Steps
|
|
17
|
+
|
|
18
|
+
### 1. Create Tool File
|
|
19
|
+
|
|
20
|
+
Create `src/tools/publish.ts` with tool definition and handler.
|
|
21
|
+
|
|
22
|
+
**Actions**:
|
|
23
|
+
- Import required dependencies (token service, Weaviate client, types)
|
|
24
|
+
- Define tool schema with MCP Tool interface
|
|
25
|
+
- Create handler function signature
|
|
26
|
+
- Export both tool definition and handler
|
|
27
|
+
|
|
28
|
+
**Expected Outcome**: Tool file structure created
|
|
29
|
+
|
|
30
|
+
### 2. Define Tool Schema
|
|
31
|
+
|
|
32
|
+
Create MCP tool definition for remember_publish.
|
|
33
|
+
|
|
34
|
+
**Actions**:
|
|
35
|
+
- Set tool name: `remember_publish`
|
|
36
|
+
- Write clear description for LLM
|
|
37
|
+
- Define input schema with properties:
|
|
38
|
+
- `memory_id` (required): ID of memory to publish
|
|
39
|
+
- `target` (required): Space ID (enum: ['the_void'])
|
|
40
|
+
- `additional_tags` (optional): Extra tags for discovery
|
|
41
|
+
- Set default values
|
|
42
|
+
- Add helpful descriptions
|
|
43
|
+
|
|
44
|
+
**Expected Outcome**: Tool schema complete
|
|
45
|
+
|
|
46
|
+
### 3. Implement Memory Validation
|
|
47
|
+
|
|
48
|
+
Verify the memory exists and user owns it.
|
|
49
|
+
|
|
50
|
+
**Actions**:
|
|
51
|
+
- Get user's Weaviate collection
|
|
52
|
+
- Fetch memory by ID
|
|
53
|
+
- Check if memory exists
|
|
54
|
+
- Verify `user_id` matches
|
|
55
|
+
- Return detailed error if validation fails
|
|
56
|
+
- Include context in error response
|
|
57
|
+
|
|
58
|
+
**Expected Outcome**: Memory ownership verified
|
|
59
|
+
|
|
60
|
+
### 4. Create Confirmation Payload
|
|
61
|
+
|
|
62
|
+
Build the payload to store with the token.
|
|
63
|
+
|
|
64
|
+
**Actions**:
|
|
65
|
+
- Extract memory_id from args
|
|
66
|
+
- Include additional_tags
|
|
67
|
+
- Store only IDs (not full content)
|
|
68
|
+
- Content will be fetched fresh during confirmation
|
|
69
|
+
- Keep payload minimal
|
|
70
|
+
|
|
71
|
+
**Expected Outcome**: Payload structure defined
|
|
72
|
+
|
|
73
|
+
### 5. Generate Confirmation Token
|
|
74
|
+
|
|
75
|
+
Use token service to create confirmation request.
|
|
76
|
+
|
|
77
|
+
**Actions**:
|
|
78
|
+
- Call `confirmationTokenService.createRequest()`
|
|
79
|
+
- Pass userId, action='publish_memory', payload, target
|
|
80
|
+
- Receive requestId and token
|
|
81
|
+
- Handle any errors from token service
|
|
82
|
+
|
|
83
|
+
**Expected Outcome**: Token generated successfully
|
|
84
|
+
|
|
85
|
+
### 6. Format Success Response
|
|
86
|
+
|
|
87
|
+
Return token and payload to agent.
|
|
88
|
+
|
|
89
|
+
**Actions**:
|
|
90
|
+
- Create response object with success flag
|
|
91
|
+
- Include token
|
|
92
|
+
- Include payload summary (action, memory_id, target, tags)
|
|
93
|
+
- Format as JSON string
|
|
94
|
+
- Use pretty printing for readability
|
|
95
|
+
|
|
96
|
+
**Expected Outcome**: Clear response format
|
|
97
|
+
|
|
98
|
+
### 7. Implement Error Handling
|
|
99
|
+
|
|
100
|
+
Handle all error cases gracefully.
|
|
101
|
+
|
|
102
|
+
**Actions**:
|
|
103
|
+
- Memory not found error
|
|
104
|
+
- Permission denied error
|
|
105
|
+
- Token service errors
|
|
106
|
+
- Weaviate connection errors
|
|
107
|
+
- Use `handleToolError` utility
|
|
108
|
+
- Include context in all errors
|
|
109
|
+
|
|
110
|
+
**Expected Outcome**: Comprehensive error handling
|
|
111
|
+
|
|
112
|
+
### 8. Add Tool to Server
|
|
113
|
+
|
|
114
|
+
Register tool in both server files.
|
|
115
|
+
|
|
116
|
+
**Actions**:
|
|
117
|
+
- Import tool in `src/server.ts`
|
|
118
|
+
- Add to tools list in ListToolsRequestSchema handler
|
|
119
|
+
- Add to CallToolRequestSchema handler
|
|
120
|
+
- Repeat for `src/server-factory.ts`
|
|
121
|
+
- Test tool registration
|
|
122
|
+
|
|
123
|
+
**Expected Outcome**: Tool available in MCP server
|
|
124
|
+
|
|
125
|
+
### 9. Create Unit Tests
|
|
126
|
+
|
|
127
|
+
Test the publish tool thoroughly.
|
|
128
|
+
|
|
129
|
+
**Actions**:
|
|
130
|
+
- Create `tests/unit/publish.test.ts`
|
|
131
|
+
- Test successful token generation
|
|
132
|
+
- Test memory not found error
|
|
133
|
+
- Test permission denied error
|
|
134
|
+
- Test invalid space ID
|
|
135
|
+
- Mock Weaviate and token service
|
|
136
|
+
- Verify response format
|
|
137
|
+
|
|
138
|
+
**Expected Outcome**: All tests passing
|
|
139
|
+
|
|
140
|
+
### 10. Update Tool Count
|
|
141
|
+
|
|
142
|
+
Update documentation with new tool count.
|
|
143
|
+
|
|
144
|
+
**Actions**:
|
|
145
|
+
- Update README.md (13 tools now)
|
|
146
|
+
- Update progress.yaml
|
|
147
|
+
- Note in milestone documentation
|
|
148
|
+
|
|
149
|
+
**Expected Outcome**: Documentation current
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Verification
|
|
154
|
+
|
|
155
|
+
- [ ] `src/tools/publish.ts` created
|
|
156
|
+
- [ ] Tool schema defined with correct parameters
|
|
157
|
+
- [ ] Memory validation implemented
|
|
158
|
+
- [ ] Token generation working
|
|
159
|
+
- [ ] Success response formatted correctly
|
|
160
|
+
- [ ] Error handling comprehensive
|
|
161
|
+
- [ ] Tool registered in server.ts
|
|
162
|
+
- [ ] Tool registered in server-factory.ts
|
|
163
|
+
- [ ] Unit tests created and passing
|
|
164
|
+
- [ ] TypeScript compiles without errors
|
|
165
|
+
- [ ] Build successful
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Tool Schema
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
export const publishTool = {
|
|
173
|
+
name: 'remember_publish',
|
|
174
|
+
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.',
|
|
175
|
+
inputSchema: {
|
|
176
|
+
type: 'object',
|
|
177
|
+
properties: {
|
|
178
|
+
memory_id: {
|
|
179
|
+
type: 'string',
|
|
180
|
+
description: 'ID of the memory from your personal collection to publish'
|
|
181
|
+
},
|
|
182
|
+
target: {
|
|
183
|
+
type: 'string',
|
|
184
|
+
description: 'Target space to publish to (snake_case ID)',
|
|
185
|
+
enum: ['the_void'],
|
|
186
|
+
default: 'the_void'
|
|
187
|
+
},
|
|
188
|
+
additional_tags: {
|
|
189
|
+
type: 'array',
|
|
190
|
+
items: { type: 'string' },
|
|
191
|
+
description: 'Additional tags for discovery (merged with original tags)',
|
|
192
|
+
default: []
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
required: ['memory_id', 'target']
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Response Format
|
|
203
|
+
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"success": true,
|
|
207
|
+
"token": "550e8400-e29b-41d4-a716-446655440000",
|
|
208
|
+
"payload": {
|
|
209
|
+
"action": "publish_memory",
|
|
210
|
+
"memory_id": "uuid-original",
|
|
211
|
+
"target": "the_void",
|
|
212
|
+
"additional_tags": []
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Related Files
|
|
220
|
+
|
|
221
|
+
- Design: [`agent/design/publish-tools-confirmation-flow.md`](../design/publish-tools-confirmation-flow.md)
|
|
222
|
+
- Token Service: [`src/services/confirmation-token.service.ts`](../../src/services/confirmation-token.service.ts)
|
|
223
|
+
- Space Types: [`src/types/space-memory.ts`](../../src/types/space-memory.ts)
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
**Next Task**: Task 37 - Implement remember_confirm Tool
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# Task 37: Implement remember_confirm Tool
|
|
2
|
+
|
|
3
|
+
**Milestone**: M10 - Shared Spaces & Confirmation Flow
|
|
4
|
+
**Estimated Time**: 5 hours
|
|
5
|
+
**Dependencies**: Task 34 (Token Service), Task 35 (Space Types), Task 36 (Publish Tool)
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Objective
|
|
11
|
+
|
|
12
|
+
Implement the generic `remember_confirm` tool that executes any pending action using a confirmation token. This is the second phase of the confirmation workflow and is designed to be extensible to other confirmable actions.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Steps
|
|
17
|
+
|
|
18
|
+
### 1. Create Tool File
|
|
19
|
+
|
|
20
|
+
Create `src/tools/confirm.ts` with generic confirmation logic.
|
|
21
|
+
|
|
22
|
+
**Actions**:
|
|
23
|
+
- Import required dependencies
|
|
24
|
+
- Define tool schema
|
|
25
|
+
- Create main handler function
|
|
26
|
+
- Create action-specific executor functions
|
|
27
|
+
- Export tool definition and handler
|
|
28
|
+
|
|
29
|
+
**Expected Outcome**: Tool file structure created
|
|
30
|
+
|
|
31
|
+
### 2. Define Tool Schema
|
|
32
|
+
|
|
33
|
+
Create MCP tool definition for remember_confirm.
|
|
34
|
+
|
|
35
|
+
**Actions**:
|
|
36
|
+
- Set tool name: `remember_confirm`
|
|
37
|
+
- Write clear description emphasizing generic nature
|
|
38
|
+
- Define input schema with single parameter:
|
|
39
|
+
- `token` (required): Confirmation token from action tool
|
|
40
|
+
- Add helpful description
|
|
41
|
+
|
|
42
|
+
**Expected Outcome**: Tool schema complete
|
|
43
|
+
|
|
44
|
+
### 3. Implement Token Validation
|
|
45
|
+
|
|
46
|
+
Validate and confirm the token.
|
|
47
|
+
|
|
48
|
+
**Actions**:
|
|
49
|
+
- Call `confirmationTokenService.confirmRequest()`
|
|
50
|
+
- Pass userId and token
|
|
51
|
+
- Check if request is valid (not null)
|
|
52
|
+
- Handle invalid/expired token error
|
|
53
|
+
- Return detailed error with context
|
|
54
|
+
|
|
55
|
+
**Expected Outcome**: Token validation working
|
|
56
|
+
|
|
57
|
+
### 4. Create Action Dispatcher
|
|
58
|
+
|
|
59
|
+
Route to appropriate executor based on action type.
|
|
60
|
+
|
|
61
|
+
**Actions**:
|
|
62
|
+
- Check `request.action` field
|
|
63
|
+
- If 'publish_memory': call `executePublishMemory()`
|
|
64
|
+
- If 'retract_memory': call `executeRetractMemory()` (future)
|
|
65
|
+
- Add other action types as needed
|
|
66
|
+
- Throw error for unknown action types
|
|
67
|
+
- Make extensible for future actions
|
|
68
|
+
|
|
69
|
+
**Expected Outcome**: Generic dispatch pattern established
|
|
70
|
+
|
|
71
|
+
### 5. Implement executePublishMemory Function
|
|
72
|
+
|
|
73
|
+
Execute the publish action.
|
|
74
|
+
|
|
75
|
+
**Actions**:
|
|
76
|
+
- Fetch original memory from user collection (fresh, not from payload)
|
|
77
|
+
- Verify memory still exists
|
|
78
|
+
- Verify user still owns it
|
|
79
|
+
- Get target space collection via `ensureSpaceCollection()`
|
|
80
|
+
- Create published memory object (copy with modifications)
|
|
81
|
+
- Set space-specific fields: `space_id`, `author_id`, `published_at`, `discovery_count`
|
|
82
|
+
- Merge additional_tags
|
|
83
|
+
- Insert into space collection
|
|
84
|
+
- Return space_memory_id
|
|
85
|
+
|
|
86
|
+
**Expected Outcome**: Publish action executes successfully
|
|
87
|
+
|
|
88
|
+
### 6. Format Success Response
|
|
89
|
+
|
|
90
|
+
Return minimal success response.
|
|
91
|
+
|
|
92
|
+
**Actions**:
|
|
93
|
+
- Create response with success flag
|
|
94
|
+
- Include payload with:
|
|
95
|
+
- action: 'publish_memory'
|
|
96
|
+
- space: target space ID
|
|
97
|
+
- space_memory_id: new ID in space collection
|
|
98
|
+
- Keep response minimal (agent already knows original memory)
|
|
99
|
+
- Format as JSON string
|
|
100
|
+
|
|
101
|
+
**Expected Outcome**: Clear, minimal response
|
|
102
|
+
|
|
103
|
+
### 7. Implement Error Handling
|
|
104
|
+
|
|
105
|
+
Handle all error cases.
|
|
106
|
+
|
|
107
|
+
**Actions**:
|
|
108
|
+
- Invalid/expired token error
|
|
109
|
+
- Memory no longer exists error
|
|
110
|
+
- Permission denied error
|
|
111
|
+
- Space collection creation error
|
|
112
|
+
- Weaviate insertion error
|
|
113
|
+
- Use `handleToolError` utility
|
|
114
|
+
- Include detailed context
|
|
115
|
+
|
|
116
|
+
**Expected Outcome**: Comprehensive error handling
|
|
117
|
+
|
|
118
|
+
### 8. Add Tool to Server
|
|
119
|
+
|
|
120
|
+
Register tool in both server files.
|
|
121
|
+
|
|
122
|
+
**Actions**:
|
|
123
|
+
- Import tool in `src/server.ts`
|
|
124
|
+
- Add to tools list
|
|
125
|
+
- Add to call handler
|
|
126
|
+
- Repeat for `src/server-factory.ts`
|
|
127
|
+
- Test tool registration
|
|
128
|
+
|
|
129
|
+
**Expected Outcome**: Tool available in MCP server
|
|
130
|
+
|
|
131
|
+
### 9. Create Unit Tests
|
|
132
|
+
|
|
133
|
+
Test the confirm tool thoroughly.
|
|
134
|
+
|
|
135
|
+
**Actions**:
|
|
136
|
+
- Create `tests/unit/confirm.test.ts`
|
|
137
|
+
- Test successful publish execution
|
|
138
|
+
- Test invalid token error
|
|
139
|
+
- Test memory no longer exists error
|
|
140
|
+
- Test permission denied error
|
|
141
|
+
- Test unknown action type error
|
|
142
|
+
- Mock Weaviate, Firestore, token service
|
|
143
|
+
- Verify response format
|
|
144
|
+
|
|
145
|
+
**Expected Outcome**: All tests passing
|
|
146
|
+
|
|
147
|
+
### 10. Test End-to-End Flow
|
|
148
|
+
|
|
149
|
+
Test complete publish workflow.
|
|
150
|
+
|
|
151
|
+
**Actions**:
|
|
152
|
+
- Call remember_publish to get token
|
|
153
|
+
- Call remember_confirm with token
|
|
154
|
+
- Verify memory appears in space collection
|
|
155
|
+
- Verify original memory unchanged
|
|
156
|
+
- Test with actual Weaviate instance if available
|
|
157
|
+
|
|
158
|
+
**Expected Outcome**: Full workflow verified
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Verification
|
|
163
|
+
|
|
164
|
+
- [ ] `src/tools/confirm.ts` created
|
|
165
|
+
- [ ] Tool schema defined
|
|
166
|
+
- [ ] Token validation implemented
|
|
167
|
+
- [ ] Action dispatcher created
|
|
168
|
+
- [ ] executePublishMemory function working
|
|
169
|
+
- [ ] Success response formatted correctly
|
|
170
|
+
- [ ] Error handling comprehensive
|
|
171
|
+
- [ ] Tool registered in server.ts
|
|
172
|
+
- [ ] Tool registered in server-factory.ts
|
|
173
|
+
- [ ] Unit tests created and passing
|
|
174
|
+
- [ ] End-to-end flow tested
|
|
175
|
+
- [ ] TypeScript compiles without errors
|
|
176
|
+
- [ ] Build successful
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Tool Schema
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
export const confirmTool = {
|
|
184
|
+
name: 'remember_confirm',
|
|
185
|
+
description: 'Confirm and execute a pending action using the token. Works for any action that requires confirmation (publish, delete, etc.).',
|
|
186
|
+
inputSchema: {
|
|
187
|
+
type: 'object',
|
|
188
|
+
properties: {
|
|
189
|
+
token: {
|
|
190
|
+
type: 'string',
|
|
191
|
+
description: 'The confirmation token from the action tool'
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
required: ['token']
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Response Format
|
|
202
|
+
|
|
203
|
+
```json
|
|
204
|
+
{
|
|
205
|
+
"success": true,
|
|
206
|
+
"payload": {
|
|
207
|
+
"action": "publish_memory",
|
|
208
|
+
"space": "the_void",
|
|
209
|
+
"space_memory_id": "uuid-new-in-space"
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Related Files
|
|
217
|
+
|
|
218
|
+
- Design: [`agent/design/publish-tools-confirmation-flow.md`](../design/publish-tools-confirmation-flow.md)
|
|
219
|
+
- Token Service: [`src/services/confirmation-token.service.ts`](../../src/services/confirmation-token.service.ts)
|
|
220
|
+
- Space Schema: [`src/weaviate/space-schema.ts`](../../src/weaviate/space-schema.ts)
|
|
221
|
+
- Publish Tool: [`src/tools/publish.ts`](../../src/tools/publish.ts)
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
**Next Task**: Task 38 - Implement remember_deny Tool
|