@prmichaelsen/remember-mcp 2.5.0 → 2.5.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 +2 -2
- package/CHANGELOG.md +21 -0
- package/agent/commands/git.commit.md +511 -0
- package/agent/commands/git.init.md +513 -0
- package/agent/scripts/install.sh +31 -16
- package/agent/scripts/update.sh +32 -17
- package/agent/tasks/task-45-fix-publish-false-success-bug.md +114 -181
- package/dist/server-factory.js +66 -27
- package/dist/server.js +66 -27
- package/package.json +1 -1
- package/src/services/confirmation-token.service.ts +74 -30
package/agent/scripts/update.sh
CHANGED
|
@@ -5,24 +5,34 @@
|
|
|
5
5
|
|
|
6
6
|
set -e
|
|
7
7
|
|
|
8
|
-
# Colors for output
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
# Colors for output using tput (more reliable than ANSI codes)
|
|
9
|
+
if command -v tput >/dev/null 2>&1 && [ -t 1 ]; then
|
|
10
|
+
RED=$(tput setaf 1)
|
|
11
|
+
GREEN=$(tput setaf 2)
|
|
12
|
+
YELLOW=$(tput setaf 3)
|
|
13
|
+
BLUE=$(tput setaf 4)
|
|
14
|
+
BOLD=$(tput bold)
|
|
15
|
+
NC=$(tput sgr0)
|
|
16
|
+
else
|
|
17
|
+
RED=''
|
|
18
|
+
GREEN=''
|
|
19
|
+
YELLOW=''
|
|
20
|
+
BLUE=''
|
|
21
|
+
BOLD=''
|
|
22
|
+
NC=''
|
|
23
|
+
fi
|
|
14
24
|
|
|
15
25
|
# Repository details
|
|
16
26
|
REPO_URL="https://github.com/prmichaelsen/agent-context-protocol.git"
|
|
17
27
|
BRANCH="mainline"
|
|
18
28
|
|
|
19
|
-
echo
|
|
29
|
+
echo "${BLUE}Agent Context Protocol (ACP) Updater${NC}"
|
|
20
30
|
echo "======================================"
|
|
21
31
|
echo ""
|
|
22
32
|
|
|
23
33
|
# Check if AGENT.md exists
|
|
24
34
|
if [ ! -f "AGENT.md" ]; then
|
|
25
|
-
echo
|
|
35
|
+
echo "${RED}Error: AGENT.md not found in current directory${NC}"
|
|
26
36
|
echo "This script should be run from your project root where AGENT.md is located."
|
|
27
37
|
exit 1
|
|
28
38
|
fi
|
|
@@ -33,12 +43,12 @@ trap "rm -rf $TEMP_DIR" EXIT
|
|
|
33
43
|
|
|
34
44
|
echo "Fetching latest ACP files..."
|
|
35
45
|
if ! git clone --depth 1 --branch "$BRANCH" "$REPO_URL" "$TEMP_DIR" &>/dev/null; then
|
|
36
|
-
echo
|
|
46
|
+
echo "${RED}Error: Failed to fetch repository${NC}"
|
|
37
47
|
echo "Please check your internet connection and try again."
|
|
38
48
|
exit 1
|
|
39
49
|
fi
|
|
40
50
|
|
|
41
|
-
echo
|
|
51
|
+
echo "${GREEN}✓${NC} Latest files fetched"
|
|
42
52
|
echo ""
|
|
43
53
|
|
|
44
54
|
# Ensure reports directory exists and is ignored
|
|
@@ -52,7 +62,7 @@ if [ ! -f "agent/.gitignore" ]; then
|
|
|
52
62
|
# Reports directory - generated by @acp.report command
|
|
53
63
|
reports/
|
|
54
64
|
EOF
|
|
55
|
-
echo
|
|
65
|
+
echo "${GREEN}✓${NC} Created agent/.gitignore"
|
|
56
66
|
fi
|
|
57
67
|
|
|
58
68
|
echo "Updating ACP files..."
|
|
@@ -87,17 +97,17 @@ cp "$TEMP_DIR/agent/scripts/version.sh" "agent/scripts/"
|
|
|
87
97
|
cp "$TEMP_DIR/agent/scripts/install.sh" "agent/scripts/"
|
|
88
98
|
chmod +x agent/scripts/*.sh
|
|
89
99
|
|
|
90
|
-
echo
|
|
100
|
+
echo "${GREEN}✓${NC} All files updated"
|
|
91
101
|
echo ""
|
|
92
|
-
echo
|
|
102
|
+
echo "${GREEN}Update complete!${NC}"
|
|
93
103
|
echo ""
|
|
94
|
-
echo
|
|
104
|
+
echo "${BLUE}What was updated:${NC}"
|
|
95
105
|
echo " ✓ AGENT.md (methodology documentation)"
|
|
96
106
|
echo " ✓ Template files (design, milestone, task, pattern)"
|
|
97
107
|
echo " ✓ Command files (all ACP commands)"
|
|
98
108
|
echo " ✓ Utility scripts (update, check-for-updates, version, etc.)"
|
|
99
109
|
echo ""
|
|
100
|
-
echo
|
|
110
|
+
echo "${BLUE}Next steps:${NC}"
|
|
101
111
|
echo "1. Review changes: git diff"
|
|
102
112
|
echo "2. See what changed: git status"
|
|
103
113
|
echo "3. Revert if needed: git checkout <file>"
|
|
@@ -105,7 +115,7 @@ echo ""
|
|
|
105
115
|
echo "For detailed changelog:"
|
|
106
116
|
echo " https://github.com/prmichaelsen/agent-context-protocol/blob/mainline/CHANGELOG.md"
|
|
107
117
|
echo ""
|
|
108
|
-
echo
|
|
118
|
+
echo "${BLUE}ACP Commands Available:${NC}"
|
|
109
119
|
echo ""
|
|
110
120
|
echo " ${GREEN}@acp.init${NC} - Initialize agent context (run after update!)"
|
|
111
121
|
echo " ${GREEN}@acp.proceed${NC} - Continue with next task"
|
|
@@ -119,6 +129,11 @@ echo " ${GREEN}@acp.version-check-for-updates${NC} - Check for ACP updates"
|
|
|
119
129
|
echo " ${GREEN}@acp.version-update${NC} - Update ACP to latest version"
|
|
120
130
|
echo " ${GREEN}@acp.package-install${NC} - Install third-party command packages"
|
|
121
131
|
echo ""
|
|
122
|
-
echo
|
|
132
|
+
echo "${BLUE}Git Commands Available:${NC}"
|
|
133
|
+
echo ""
|
|
134
|
+
echo " ${GREEN}@git.init${NC} - Initialize git repository with smart .gitignore"
|
|
135
|
+
echo " ${GREEN}@git.commit${NC} - Intelligent version-aware git commit"
|
|
136
|
+
echo ""
|
|
137
|
+
echo "${BLUE}For AI agents:${NC}"
|
|
123
138
|
echo "Type '${GREEN}@acp.init${NC}' to reload context with updated files."
|
|
124
139
|
echo ""
|
|
@@ -1,230 +1,163 @@
|
|
|
1
|
-
# Task 45: Fix
|
|
1
|
+
# Task 45: Fix Publish False Success Bug
|
|
2
2
|
|
|
3
|
-
**Milestone**: M10 - Shared Spaces & Confirmation Flow
|
|
4
|
-
**Estimated Time**:
|
|
5
|
-
**Dependencies**:
|
|
3
|
+
**Milestone**: M10 - Shared Spaces & Confirmation Flow
|
|
4
|
+
**Estimated Time**: 1 hour
|
|
5
|
+
**Dependencies**: None
|
|
6
6
|
**Status**: Not Started
|
|
7
|
-
**Priority**:
|
|
7
|
+
**Priority**: CRITICAL
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
## Objective
|
|
12
12
|
|
|
13
|
-
Fix
|
|
13
|
+
Fix critical bug where `remember_publish` reports success even when Firestore request creation fails. The issue is a missing `return` statement in the error handler, causing the function to return `undefined` instead of an error response.
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
17
|
## Problem Statement
|
|
18
18
|
|
|
19
|
-
###
|
|
20
|
-
- `remember_confirm` returns `success: true`
|
|
21
|
-
- Database shows `Memory_the_void` collection has 0 objects
|
|
22
|
-
- Memory only exists in personal collection (not copied)
|
|
23
|
-
- No error is thrown
|
|
24
|
-
- False positive misleads users and agents
|
|
19
|
+
### Observed Behavior
|
|
25
20
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
1. User calls `remember_publish`
|
|
22
|
+
2. Token service tries to create request in Firestore
|
|
23
|
+
3. Firestore operation fails (permissions, network, etc.)
|
|
24
|
+
4. Error is caught but NOT returned
|
|
25
|
+
5. Function returns `undefined`
|
|
26
|
+
6. MCP interprets `undefined` as success
|
|
27
|
+
7. User calls `remember_confirm` with token
|
|
28
|
+
8. Token validation fails (no request exists)
|
|
29
|
+
9. But user already thinks publish succeeded
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
## Steps
|
|
35
|
-
|
|
36
|
-
### 1. Verify Collection Exists
|
|
37
|
-
|
|
38
|
-
Check if `Memory_the_void` collection exists in Weaviate.
|
|
39
|
-
|
|
40
|
-
**Actions**:
|
|
41
|
-
- Query Weaviate for collection list
|
|
42
|
-
- Check if `Memory_the_void` exists
|
|
43
|
-
- Verify collection schema if it exists
|
|
44
|
-
- Check write permissions
|
|
45
|
-
|
|
46
|
-
**Expected Outcome**: Collection status determined
|
|
47
|
-
|
|
48
|
-
### 2. Review executePublishMemory Function
|
|
49
|
-
|
|
50
|
-
Examine the publish execution logic in confirm.ts.
|
|
51
|
-
|
|
52
|
-
**Actions**:
|
|
53
|
-
- Open [`src/tools/confirm.ts`](../../src/tools/confirm.ts)
|
|
54
|
-
- Review `executePublishMemory` function
|
|
55
|
-
- Check if `targetCollection.data.insert()` is called
|
|
56
|
-
- Verify result is returned correctly
|
|
57
|
-
- Check error handling
|
|
58
|
-
|
|
59
|
-
**Expected Outcome**: Code logic understood
|
|
60
|
-
|
|
61
|
-
### 3. Add Debug Logging
|
|
31
|
+
### Root Cause
|
|
62
32
|
|
|
63
|
-
|
|
33
|
+
**File**: `src/tools/publish.ts` line 203-210
|
|
64
34
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
Run publish workflow with logging enabled.
|
|
77
|
-
|
|
78
|
-
**Actions**:
|
|
79
|
-
- Create test memory
|
|
80
|
-
- Call remember_publish
|
|
81
|
-
- Call remember_confirm with token
|
|
82
|
-
- Check logs for execution flow
|
|
83
|
-
- Verify if insert is called
|
|
84
|
-
- Check Weaviate for result
|
|
85
|
-
|
|
86
|
-
**Expected Outcome**: Root cause identified
|
|
87
|
-
|
|
88
|
-
### 5. Fix the Bug
|
|
89
|
-
|
|
90
|
-
Implement the fix based on root cause.
|
|
91
|
-
|
|
92
|
-
**Possible Fixes**:
|
|
93
|
-
- **If collection doesn't exist**: Ensure `ensureSpaceCollection()` creates it
|
|
94
|
-
- **If insert not called**: Fix logic flow to reach insert
|
|
95
|
-
- **If insert fails silently**: Add proper error handling
|
|
96
|
-
- **If permissions issue**: Fix Weaviate configuration
|
|
97
|
-
- **If wrong collection**: Fix collection name generation
|
|
98
|
-
|
|
99
|
-
**Expected Outcome**: Bug fixed
|
|
100
|
-
|
|
101
|
-
### 6. Verify Fix
|
|
35
|
+
```typescript
|
|
36
|
+
} catch (error) {
|
|
37
|
+
return handleToolError(error, { // ✅ HAS return (fixed in v2.3.3)
|
|
38
|
+
toolName: 'remember_publish',
|
|
39
|
+
userId,
|
|
40
|
+
operation: 'publish memory',
|
|
41
|
+
memory_id: args.memory_id,
|
|
42
|
+
spaces: args.spaces,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
```
|
|
102
46
|
|
|
103
|
-
|
|
47
|
+
**Status**: Actually this WAS fixed in v2.3.3! Let me check if there are other places...
|
|
104
48
|
|
|
105
|
-
|
|
106
|
-
- Create test memory
|
|
107
|
-
- Publish to The Void
|
|
108
|
-
- Confirm publication
|
|
109
|
-
- Query `Memory_the_void` collection
|
|
110
|
-
- Verify memory exists in space
|
|
111
|
-
- Verify original memory unchanged
|
|
112
|
-
- Test search_space finds it
|
|
49
|
+
### Additional Investigation Needed
|
|
113
50
|
|
|
114
|
-
**
|
|
51
|
+
1. **Check if `addDocument` is failing silently**
|
|
52
|
+
- Add try-catch in `confirmationTokenService.createRequest`
|
|
53
|
+
- Log success/failure explicitly
|
|
54
|
+
- Return error if Firestore operation fails
|
|
115
55
|
|
|
116
|
-
|
|
56
|
+
2. **Check Firebase Admin SDK initialization**
|
|
57
|
+
- Verify service account has Firestore permissions
|
|
58
|
+
- Check if initialization succeeds
|
|
59
|
+
- Log initialization status
|
|
117
60
|
|
|
118
|
-
|
|
61
|
+
3. **Check Firestore collection creation**
|
|
62
|
+
- Verify `users/{userId}/requests` collection can be created
|
|
63
|
+
- Check if parent document `users/{userId}` needs to exist first
|
|
64
|
+
- Test with actual Firebase project
|
|
119
65
|
|
|
120
|
-
|
|
121
|
-
- Create integration test file
|
|
122
|
-
- Test: create → publish → confirm → verify in space
|
|
123
|
-
- Test: search_space finds published memory
|
|
124
|
-
- Test: original memory still in personal collection
|
|
125
|
-
- Requires live Weaviate instance
|
|
66
|
+
---
|
|
126
67
|
|
|
127
|
-
|
|
68
|
+
## Solution
|
|
128
69
|
|
|
129
|
-
###
|
|
70
|
+
### Step 1: Add Error Handling in Token Service
|
|
130
71
|
|
|
131
|
-
|
|
72
|
+
**File**: `src/services/confirmation-token.service.ts`
|
|
132
73
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
74
|
+
```typescript
|
|
75
|
+
async createRequest(
|
|
76
|
+
userId: string,
|
|
77
|
+
action: string,
|
|
78
|
+
payload: any,
|
|
79
|
+
targetCollection?: string
|
|
80
|
+
): Promise<{ requestId: string; token: string }> {
|
|
81
|
+
try {
|
|
82
|
+
const token = randomUUID();
|
|
83
|
+
// ... create request object
|
|
84
|
+
|
|
85
|
+
console.log('[ConfirmationTokenService] Attempting to create request in Firestore');
|
|
86
|
+
|
|
87
|
+
const docRef = await addDocument(collectionPath, request);
|
|
88
|
+
|
|
89
|
+
if (!docRef || !docRef.id) {
|
|
90
|
+
throw new Error('Failed to create Firestore document - no document ID returned');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
console.log('[ConfirmationTokenService] Request created successfully:', {
|
|
94
|
+
requestId: docRef.id,
|
|
95
|
+
token,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
return { requestId: docRef.id, token };
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.error('[ConfirmationTokenService] Failed to create request:', error);
|
|
101
|
+
console.error('[ConfirmationTokenService] Context:', {
|
|
102
|
+
userId,
|
|
103
|
+
action,
|
|
104
|
+
collectionPath: `users/${userId}/requests`,
|
|
105
|
+
});
|
|
106
|
+
throw error; // Re-throw so caller can handle
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
138
110
|
|
|
139
|
-
|
|
111
|
+
### Step 2: Verify Error Propagation
|
|
140
112
|
|
|
141
|
-
|
|
113
|
+
Ensure errors from token service propagate to tool handler:
|
|
142
114
|
|
|
143
|
-
|
|
115
|
+
**File**: `src/tools/publish.ts`
|
|
144
116
|
|
|
145
|
-
|
|
146
|
-
- Test with large memory
|
|
147
|
-
- Test with memory that has relationships
|
|
148
|
-
- Test with memory that has special characters
|
|
149
|
-
- Test concurrent publishes
|
|
150
|
-
- Test expired token
|
|
117
|
+
The error handler already has `return` (fixed in v2.3.3), so errors should propagate correctly.
|
|
151
118
|
|
|
152
|
-
|
|
119
|
+
### Step 3: Check Firebase Permissions
|
|
153
120
|
|
|
154
|
-
|
|
121
|
+
**Use Firebase MCP tools**:
|
|
122
|
+
```typescript
|
|
123
|
+
// Check if service account has correct permissions
|
|
124
|
+
// Verify Firestore database exists
|
|
125
|
+
// Test write operation
|
|
126
|
+
```
|
|
155
127
|
|
|
156
|
-
|
|
128
|
+
### Step 4: Add Integration Test
|
|
157
129
|
|
|
158
|
-
**
|
|
159
|
-
- Add to CHANGELOG (patch version)
|
|
160
|
-
- Update any affected documentation
|
|
161
|
-
- Note in progress.yaml
|
|
162
|
-
- Document root cause for future reference
|
|
130
|
+
**File**: `tests/integration/publish-flow.test.ts`
|
|
163
131
|
|
|
164
|
-
|
|
132
|
+
Test the full flow:
|
|
133
|
+
1. Create request (should succeed or fail clearly)
|
|
134
|
+
2. Verify request exists in Firestore
|
|
135
|
+
3. Confirm request
|
|
136
|
+
4. Verify memory published
|
|
165
137
|
|
|
166
138
|
---
|
|
167
139
|
|
|
168
140
|
## Verification
|
|
169
141
|
|
|
170
|
-
- [ ]
|
|
171
|
-
- [ ]
|
|
172
|
-
- [ ]
|
|
173
|
-
- [ ]
|
|
174
|
-
- [ ]
|
|
175
|
-
- [ ]
|
|
176
|
-
- [ ]
|
|
177
|
-
- [ ] All tests passing
|
|
178
|
-
- [ ] TypeScript compiles
|
|
179
|
-
- [ ] Build successful
|
|
180
|
-
- [ ] Changes committed and pushed
|
|
142
|
+
- [ ] `addDocument` errors are caught and logged
|
|
143
|
+
- [ ] Errors propagate from token service to tool handler
|
|
144
|
+
- [ ] Tool returns error response (not undefined)
|
|
145
|
+
- [ ] Firebase credentials verified
|
|
146
|
+
- [ ] Service account has Firestore write permissions
|
|
147
|
+
- [ ] Integration test passes
|
|
148
|
+
- [ ] Production logs show clear error messages
|
|
181
149
|
|
|
182
150
|
---
|
|
183
151
|
|
|
184
|
-
##
|
|
185
|
-
|
|
186
|
-
- [ ] Check if `Memory_the_void` collection exists
|
|
187
|
-
- [ ] Verify `ensureSpaceCollection()` is called
|
|
188
|
-
- [ ] Verify `targetCollection.data.insert()` is called
|
|
189
|
-
- [ ] Check if insert returns a result
|
|
190
|
-
- [ ] Verify result is used in response
|
|
191
|
-
- [ ] Check server logs for errors
|
|
192
|
-
- [ ] Test with actual Weaviate instance
|
|
193
|
-
- [ ] Verify Weaviate write permissions
|
|
194
|
-
|
|
195
|
-
---
|
|
152
|
+
## Files Modified
|
|
196
153
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
The bug is likely in [`src/tools/confirm.ts`](../../src/tools/confirm.ts) in the `executePublishMemory` function. The insert operation may not be executing or may be failing silently.
|
|
200
|
-
|
|
201
|
-
**Likely Issue**: Missing await, incorrect API usage, or silent error
|
|
202
|
-
|
|
203
|
-
**Expected Code**:
|
|
204
|
-
```typescript
|
|
205
|
-
const result = await targetCollection.data.insert({
|
|
206
|
-
properties: publishedMemory as any,
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
// Verify result
|
|
210
|
-
if (!result) {
|
|
211
|
-
throw new Error('Failed to insert memory into space collection');
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return JSON.stringify({
|
|
215
|
-
success: true,
|
|
216
|
-
space_memory_id: result,
|
|
217
|
-
}, null, 2);
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
---
|
|
154
|
+
- `src/services/confirmation-token.service.ts` - Add error handling
|
|
155
|
+
- `src/tools/publish.ts` - Verify error propagation (already fixed)
|
|
221
156
|
|
|
222
|
-
##
|
|
157
|
+
## Files Created
|
|
223
158
|
|
|
224
|
-
-
|
|
225
|
-
- Space Schema: [`src/weaviate/space-schema.ts`](../../src/weaviate/space-schema.ts)
|
|
226
|
-
- Design: [`agent/design/publish-tools-confirmation-flow.md`](../design/publish-tools-confirmation-flow.md)
|
|
159
|
+
- `tests/integration/publish-flow.test.ts` - Integration test (optional)
|
|
227
160
|
|
|
228
161
|
---
|
|
229
162
|
|
|
230
|
-
**Next Task**: Investigate
|
|
163
|
+
**Next Task**: Investigate production logs to confirm root cause
|
package/dist/server-factory.js
CHANGED
|
@@ -3241,33 +3241,72 @@ var ConfirmationTokenService = class {
|
|
|
3241
3241
|
* @returns Request ID and token
|
|
3242
3242
|
*/
|
|
3243
3243
|
async createRequest(userId, action, payload, targetCollection) {
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3244
|
+
try {
|
|
3245
|
+
const token = randomUUID();
|
|
3246
|
+
const now = /* @__PURE__ */ new Date();
|
|
3247
|
+
const expiresAt = new Date(now.getTime() + this.EXPIRY_MINUTES * 60 * 1e3);
|
|
3248
|
+
const request = {
|
|
3249
|
+
user_id: userId,
|
|
3250
|
+
token,
|
|
3251
|
+
action,
|
|
3252
|
+
target_collection: targetCollection,
|
|
3253
|
+
payload,
|
|
3254
|
+
created_at: now.toISOString(),
|
|
3255
|
+
expires_at: expiresAt.toISOString(),
|
|
3256
|
+
status: "pending"
|
|
3257
|
+
};
|
|
3258
|
+
const collectionPath = `users/${userId}/requests`;
|
|
3259
|
+
console.log("[ConfirmationTokenService] Creating request:", {
|
|
3260
|
+
userId,
|
|
3261
|
+
action,
|
|
3262
|
+
targetCollection,
|
|
3263
|
+
collectionPath,
|
|
3264
|
+
requestData: {
|
|
3265
|
+
token,
|
|
3266
|
+
action,
|
|
3267
|
+
payloadKeys: Object.keys(payload)
|
|
3268
|
+
}
|
|
3269
|
+
});
|
|
3270
|
+
console.log("[ConfirmationTokenService] Calling addDocument...");
|
|
3271
|
+
const docRef = await addDocument(collectionPath, request);
|
|
3272
|
+
console.log("[ConfirmationTokenService] addDocument returned:", {
|
|
3273
|
+
hasDocRef: !!docRef,
|
|
3274
|
+
hasId: !!docRef?.id,
|
|
3275
|
+
docRefId: docRef?.id
|
|
3276
|
+
});
|
|
3277
|
+
if (!docRef) {
|
|
3278
|
+
const error = new Error("Firestore addDocument returned null/undefined");
|
|
3279
|
+
console.error("[ConfirmationTokenService] CRITICAL: addDocument returned null", {
|
|
3280
|
+
userId,
|
|
3281
|
+
collectionPath
|
|
3282
|
+
});
|
|
3283
|
+
throw error;
|
|
3284
|
+
}
|
|
3285
|
+
if (!docRef.id) {
|
|
3286
|
+
const error = new Error("Firestore addDocument returned docRef without ID");
|
|
3287
|
+
console.error("[ConfirmationTokenService] CRITICAL: docRef has no ID", {
|
|
3288
|
+
userId,
|
|
3289
|
+
collectionPath,
|
|
3290
|
+
docRef
|
|
3291
|
+
});
|
|
3292
|
+
throw error;
|
|
3293
|
+
}
|
|
3294
|
+
console.log("[ConfirmationTokenService] Request created successfully:", {
|
|
3295
|
+
requestId: docRef.id,
|
|
3296
|
+
token,
|
|
3297
|
+
expiresAt: request.expires_at
|
|
3298
|
+
});
|
|
3299
|
+
return { requestId: docRef.id, token };
|
|
3300
|
+
} catch (error) {
|
|
3301
|
+
console.error("[ConfirmationTokenService] FAILED to create request:", {
|
|
3302
|
+
error: error instanceof Error ? error.message : String(error),
|
|
3303
|
+
stack: error instanceof Error ? error.stack : void 0,
|
|
3304
|
+
userId,
|
|
3305
|
+
action,
|
|
3306
|
+
collectionPath: `users/${userId}/requests`
|
|
3307
|
+
});
|
|
3308
|
+
throw error;
|
|
3309
|
+
}
|
|
3271
3310
|
}
|
|
3272
3311
|
/**
|
|
3273
3312
|
* Validate and retrieve a confirmation request
|
package/dist/server.js
CHANGED
|
@@ -3283,33 +3283,72 @@ var ConfirmationTokenService = class {
|
|
|
3283
3283
|
* @returns Request ID and token
|
|
3284
3284
|
*/
|
|
3285
3285
|
async createRequest(userId, action, payload, targetCollection) {
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3286
|
+
try {
|
|
3287
|
+
const token = randomUUID();
|
|
3288
|
+
const now = /* @__PURE__ */ new Date();
|
|
3289
|
+
const expiresAt = new Date(now.getTime() + this.EXPIRY_MINUTES * 60 * 1e3);
|
|
3290
|
+
const request = {
|
|
3291
|
+
user_id: userId,
|
|
3292
|
+
token,
|
|
3293
|
+
action,
|
|
3294
|
+
target_collection: targetCollection,
|
|
3295
|
+
payload,
|
|
3296
|
+
created_at: now.toISOString(),
|
|
3297
|
+
expires_at: expiresAt.toISOString(),
|
|
3298
|
+
status: "pending"
|
|
3299
|
+
};
|
|
3300
|
+
const collectionPath = `users/${userId}/requests`;
|
|
3301
|
+
console.log("[ConfirmationTokenService] Creating request:", {
|
|
3302
|
+
userId,
|
|
3303
|
+
action,
|
|
3304
|
+
targetCollection,
|
|
3305
|
+
collectionPath,
|
|
3306
|
+
requestData: {
|
|
3307
|
+
token,
|
|
3308
|
+
action,
|
|
3309
|
+
payloadKeys: Object.keys(payload)
|
|
3310
|
+
}
|
|
3311
|
+
});
|
|
3312
|
+
console.log("[ConfirmationTokenService] Calling addDocument...");
|
|
3313
|
+
const docRef = await addDocument(collectionPath, request);
|
|
3314
|
+
console.log("[ConfirmationTokenService] addDocument returned:", {
|
|
3315
|
+
hasDocRef: !!docRef,
|
|
3316
|
+
hasId: !!docRef?.id,
|
|
3317
|
+
docRefId: docRef?.id
|
|
3318
|
+
});
|
|
3319
|
+
if (!docRef) {
|
|
3320
|
+
const error = new Error("Firestore addDocument returned null/undefined");
|
|
3321
|
+
console.error("[ConfirmationTokenService] CRITICAL: addDocument returned null", {
|
|
3322
|
+
userId,
|
|
3323
|
+
collectionPath
|
|
3324
|
+
});
|
|
3325
|
+
throw error;
|
|
3326
|
+
}
|
|
3327
|
+
if (!docRef.id) {
|
|
3328
|
+
const error = new Error("Firestore addDocument returned docRef without ID");
|
|
3329
|
+
console.error("[ConfirmationTokenService] CRITICAL: docRef has no ID", {
|
|
3330
|
+
userId,
|
|
3331
|
+
collectionPath,
|
|
3332
|
+
docRef
|
|
3333
|
+
});
|
|
3334
|
+
throw error;
|
|
3335
|
+
}
|
|
3336
|
+
console.log("[ConfirmationTokenService] Request created successfully:", {
|
|
3337
|
+
requestId: docRef.id,
|
|
3338
|
+
token,
|
|
3339
|
+
expiresAt: request.expires_at
|
|
3340
|
+
});
|
|
3341
|
+
return { requestId: docRef.id, token };
|
|
3342
|
+
} catch (error) {
|
|
3343
|
+
console.error("[ConfirmationTokenService] FAILED to create request:", {
|
|
3344
|
+
error: error instanceof Error ? error.message : String(error),
|
|
3345
|
+
stack: error instanceof Error ? error.stack : void 0,
|
|
3346
|
+
userId,
|
|
3347
|
+
action,
|
|
3348
|
+
collectionPath: `users/${userId}/requests`
|
|
3349
|
+
});
|
|
3350
|
+
throw error;
|
|
3351
|
+
}
|
|
3313
3352
|
}
|
|
3314
3353
|
/**
|
|
3315
3354
|
* Validate and retrieve a confirmation request
|