piece-signal-cli-rest-api 0.2.15 → 0.2.17
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piece-signal-cli-rest-api",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "echo \"piece-signal-cli-rest-api: kein zusätzlicher Build-Schritt erforderlich (bereits als JS ausgeliefert)\"",
|
|
6
6
|
"publish:npm": "npm publish --access public"
|
|
@@ -85,6 +85,9 @@ exports.requestApprovalMessage = (0, pieces_framework_1.createAction)({
|
|
|
85
85
|
// Create store key using milliseconds for precise matching
|
|
86
86
|
// Store-Key mit Timestamp + eindeutiger Flow-Run-ID
|
|
87
87
|
// flowRunId ist pro Flow-Ausführung eindeutig, verhindert Kollisionen
|
|
88
|
+
// #region agent log
|
|
89
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'request-approval-message.js:88',message:'Store-Key creation - checking context.run.id',data:{flowRunId:context.run.id,flowRunIdType:typeof context.run.id,messageTimestampMs,timestampSeconds,recipients:Array.isArray(recipients)?recipients.length:'not-array',recipientsType:typeof recipients},timestamp:Date.now(),hypothesisId:'A'})}).catch(()=>{});
|
|
90
|
+
// #endregion
|
|
88
91
|
const storeKey = `approval:${messageTimestampMs}:${context.run.id}`;
|
|
89
92
|
// DEBUG: Log storing approval mapping
|
|
90
93
|
console.log('[RequestApprovalMessage] DEBUG - Storing approval mapping:', {
|
|
@@ -119,9 +122,15 @@ exports.requestApprovalMessage = (0, pieces_framework_1.createAction)({
|
|
|
119
122
|
// DEBUG: Verify it was stored
|
|
120
123
|
const verifyMapping = yield context.store.get(storeKey, pieces_framework_1.StoreScope.PROJECT);
|
|
121
124
|
console.log('[RequestApprovalMessage] DEBUG - Verified stored mapping:', verifyMapping);
|
|
125
|
+
// #region agent log
|
|
126
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'request-approval-message.js:118',message:'Mapping stored - verifying recipients format',data:{storeKey,recipients:verifyMapping?.recipients,recipientsType:typeof verifyMapping?.recipients,recipientsIsArray:Array.isArray(verifyMapping?.recipients),messageTimestampMs:verifyMapping?.messageTimestampMs},timestamp:Date.now(),hypothesisId:'C'})}).catch(()=>{});
|
|
127
|
+
// #endregion
|
|
122
128
|
// Add key to approval keys list
|
|
123
129
|
const keysListKey = 'approval:keys';
|
|
124
130
|
const existingKeys = (yield context.store.get(keysListKey, pieces_framework_1.StoreScope.PROJECT)) || [];
|
|
131
|
+
// #region agent log
|
|
132
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'request-approval-message.js:123',message:'Adding key to approval keys list',data:{storeKey,existingKeysCount:existingKeys.length,keyAlreadyExists:existingKeys.includes(storeKey)},timestamp:Date.now(),hypothesisId:'D'})}).catch(()=>{});
|
|
133
|
+
// #endregion
|
|
125
134
|
if (!existingKeys.includes(storeKey)) {
|
|
126
135
|
existingKeys.push(storeKey);
|
|
127
136
|
yield context.store.put(keysListKey, existingKeys, pieces_framework_1.StoreScope.PROJECT);
|
|
@@ -18,11 +18,19 @@ function cleanupExpiredApprovals(store) {
|
|
|
18
18
|
const currentTimestamp = Math.floor(Date.now() / 1000);
|
|
19
19
|
const validKeys = [];
|
|
20
20
|
const keysToDelete = [];
|
|
21
|
+
// #region agent log
|
|
22
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'message-utils.js:19',message:'Cleanup started',data:{existingKeysCount:existingKeys.length,currentTimestamp},timestamp:Date.now(),hypothesisId:'E'})}).catch(()=>{});
|
|
23
|
+
// #endregion
|
|
21
24
|
for (const key of existingKeys) {
|
|
22
25
|
const mapping = yield store.get(key, pieces_framework_1.StoreScope.PROJECT);
|
|
23
26
|
if (mapping) {
|
|
24
27
|
// Check if expired
|
|
25
|
-
|
|
28
|
+
const ageInSeconds = currentTimestamp - mapping.createdAt;
|
|
29
|
+
const isExpired = ageInSeconds > mapping.timeoutSeconds;
|
|
30
|
+
// #region agent log
|
|
31
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'message-utils.js:26',message:'Checking expiration',data:{key,ageInSeconds,timeoutSeconds:mapping.timeoutSeconds,isExpired,createdAt:mapping.createdAt},timestamp:Date.now(),hypothesisId:'E'})}).catch(()=>{});
|
|
32
|
+
// #endregion
|
|
33
|
+
if (isExpired) {
|
|
26
34
|
// Expired - delete it and flowRunId mapping
|
|
27
35
|
yield store.delete(key, pieces_framework_1.StoreScope.PROJECT);
|
|
28
36
|
const flowRunMappingKey = `approval:flowRun:${mapping.flowRunId}`;
|
|
@@ -42,6 +50,9 @@ function cleanupExpiredApprovals(store) {
|
|
|
42
50
|
if (keysToDelete.length > 0) {
|
|
43
51
|
yield store.put(keysListKey, validKeys, pieces_framework_1.StoreScope.PROJECT);
|
|
44
52
|
}
|
|
53
|
+
// #region agent log
|
|
54
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'message-utils.js:42',message:'Cleanup completed',data:{validKeysCount:validKeys.length,deletedKeysCount:keysToDelete.length},timestamp:Date.now(),hypothesisId:'E'})}).catch(()=>{});
|
|
55
|
+
// #endregion
|
|
45
56
|
});
|
|
46
57
|
}
|
|
47
58
|
// Function to automatically resume approval flows
|
|
@@ -75,6 +86,9 @@ function tryResumeApprovalFlow(message, store, apiUrl) {
|
|
|
75
86
|
const keysListKey = 'approval:keys';
|
|
76
87
|
const existingKeys = (yield store.get(keysListKey, pieces_framework_1.StoreScope.PROJECT)) || [];
|
|
77
88
|
const currentTimestamp = Math.floor(Date.now() / 1000);
|
|
89
|
+
// #region agent log
|
|
90
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'message-utils.js:76',message:'After cleanup - checking available keys',data:{existingKeysCount:existingKeys.length,existingKeys:existingKeys.slice(0,5),isReaction,isTextReply,isGroupMessage},timestamp:Date.now(),hypothesisId:'D'})}).catch(()=>{});
|
|
91
|
+
// #endregion
|
|
78
92
|
// Try to find matching approval
|
|
79
93
|
let mapping = null;
|
|
80
94
|
let storeKey = null;
|
|
@@ -97,6 +111,9 @@ function tryResumeApprovalFlow(message, store, apiUrl) {
|
|
|
97
111
|
messageSource,
|
|
98
112
|
isGroupMessage,
|
|
99
113
|
});
|
|
114
|
+
// #region agent log
|
|
115
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'message-utils.js:93',message:'Emoji reaction - starting matching loop',data:{targetTimestampMs,targetTimestampSeconds,existingKeysCount:existingKeys.length,messageSource,isGroupMessage},timestamp:Date.now(),hypothesisId:'B'})}).catch(()=>{});
|
|
116
|
+
// #endregion
|
|
100
117
|
|
|
101
118
|
// Alle Approvals durchsuchen: Exakter Timestamp-Match + Empfänger-Validierung
|
|
102
119
|
for (const key of existingKeys) {
|
|
@@ -104,6 +121,9 @@ function tryResumeApprovalFlow(message, store, apiUrl) {
|
|
|
104
121
|
if (!candidateMapping) continue;
|
|
105
122
|
|
|
106
123
|
// Exakter Timestamp-Match (beide vom Signal-Netzwerk, müssen identisch sein)
|
|
124
|
+
// #region agent log
|
|
125
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'message-utils.js:102',message:'Checking timestamp match',data:{key,candidateTimestampMs:candidateMapping.messageTimestampMs,targetTimestampMs,timestampMatch:candidateMapping.messageTimestampMs===targetTimestampMs},timestamp:Date.now(),hypothesisId:'B'})}).catch(()=>{});
|
|
126
|
+
// #endregion
|
|
107
127
|
if (candidateMapping.messageTimestampMs !== targetTimestampMs) continue;
|
|
108
128
|
|
|
109
129
|
console.log('[ReceiveMessages] DEBUG - Timestamp match found, checking recipient:', {
|
|
@@ -115,6 +135,9 @@ function tryResumeApprovalFlow(message, store, apiUrl) {
|
|
|
115
135
|
// Empfänger-Validierung (1:1 vs. Gruppe)
|
|
116
136
|
const recipients = candidateMapping.recipients || [];
|
|
117
137
|
let isValidRecipient = false;
|
|
138
|
+
// #region agent log
|
|
139
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'message-utils.js:110',message:'Checking recipient validation',data:{key,recipients,recipientsType:typeof recipients,recipientsIsArray:Array.isArray(recipients),isGroupMessage,messageSource},timestamp:Date.now(),hypothesisId:'C'})}).catch(()=>{});
|
|
140
|
+
// #endregion
|
|
118
141
|
|
|
119
142
|
if (isGroupMessage) {
|
|
120
143
|
// Bei Gruppen: Prüfe Gruppen-ID
|
|
@@ -124,6 +147,9 @@ function tryResumeApprovalFlow(message, store, apiUrl) {
|
|
|
124
147
|
groupId,
|
|
125
148
|
isValidRecipient,
|
|
126
149
|
});
|
|
150
|
+
// #region agent log
|
|
151
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'message-utils.js:117',message:'Group recipient validation result',data:{key,groupId,recipients,isValidRecipient},timestamp:Date.now(),hypothesisId:'C'})}).catch(()=>{});
|
|
152
|
+
// #endregion
|
|
127
153
|
} else {
|
|
128
154
|
// Bei 1:1: Prüfe, ob Absender in recipients-Liste steht
|
|
129
155
|
isValidRecipient = Array.isArray(recipients) && recipients.includes(messageSource);
|
|
@@ -131,6 +157,9 @@ function tryResumeApprovalFlow(message, store, apiUrl) {
|
|
|
131
157
|
messageSource,
|
|
132
158
|
isValidRecipient,
|
|
133
159
|
});
|
|
160
|
+
// #region agent log
|
|
161
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'message-utils.js:125',message:'1:1 recipient validation result',data:{key,messageSource,recipients,isValidRecipient},timestamp:Date.now(),hypothesisId:'C'})}).catch(()=>{});
|
|
162
|
+
// #endregion
|
|
134
163
|
}
|
|
135
164
|
|
|
136
165
|
if (!isValidRecipient) continue;
|
|
@@ -172,6 +201,9 @@ function tryResumeApprovalFlow(message, store, apiUrl) {
|
|
|
172
201
|
messageSource,
|
|
173
202
|
isGroupMessage,
|
|
174
203
|
});
|
|
204
|
+
// #region agent log
|
|
205
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'message-utils.js:145',message:'Text reply - starting matching loop',data:{quoteTimestampMs,quoteTimestampSeconds,existingKeysCount:existingKeys.length,messageSource,isGroupMessage},timestamp:Date.now(),hypothesisId:'B'})}).catch(()=>{});
|
|
206
|
+
// #endregion
|
|
175
207
|
|
|
176
208
|
// Alle Approvals durchsuchen: Exakter Timestamp-Match + Empfänger-Validierung
|
|
177
209
|
for (const key of existingKeys) {
|
|
@@ -179,6 +211,9 @@ function tryResumeApprovalFlow(message, store, apiUrl) {
|
|
|
179
211
|
if (!candidateMapping) continue;
|
|
180
212
|
|
|
181
213
|
// Exakter Timestamp-Match (beide vom Signal-Netzwerk, müssen identisch sein)
|
|
214
|
+
// #region agent log
|
|
215
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'message-utils.js:154',message:'Checking timestamp match (quote)',data:{key,candidateTimestampMs:candidateMapping.messageTimestampMs,quoteTimestampMs,timestampMatch:candidateMapping.messageTimestampMs===quoteTimestampMs},timestamp:Date.now(),hypothesisId:'B'})}).catch(()=>{});
|
|
216
|
+
// #endregion
|
|
182
217
|
if (candidateMapping.messageTimestampMs !== quoteTimestampMs) continue;
|
|
183
218
|
|
|
184
219
|
console.log('[ReceiveMessages] DEBUG - Timestamp match found, checking recipient:', {
|
|
@@ -190,6 +225,9 @@ function tryResumeApprovalFlow(message, store, apiUrl) {
|
|
|
190
225
|
// Empfänger-Validierung (1:1 vs. Gruppe)
|
|
191
226
|
const recipients = candidateMapping.recipients || [];
|
|
192
227
|
let isValidRecipient = false;
|
|
228
|
+
// #region agent log
|
|
229
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'message-utils.js:162',message:'Checking recipient validation (quote)',data:{key,recipients,recipientsType:typeof recipients,recipientsIsArray:Array.isArray(recipients),isGroupMessage,messageSource},timestamp:Date.now(),hypothesisId:'C'})}).catch(()=>{});
|
|
230
|
+
// #endregion
|
|
193
231
|
|
|
194
232
|
if (isGroupMessage) {
|
|
195
233
|
// Bei Gruppen: Prüfe Gruppen-ID
|
|
@@ -199,6 +237,9 @@ function tryResumeApprovalFlow(message, store, apiUrl) {
|
|
|
199
237
|
groupId,
|
|
200
238
|
isValidRecipient,
|
|
201
239
|
});
|
|
240
|
+
// #region agent log
|
|
241
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'message-utils.js:169',message:'Group recipient validation result (quote)',data:{key,groupId,recipients,isValidRecipient},timestamp:Date.now(),hypothesisId:'C'})}).catch(()=>{});
|
|
242
|
+
// #endregion
|
|
202
243
|
} else {
|
|
203
244
|
// Bei 1:1: Prüfe, ob Absender in recipients-Liste steht
|
|
204
245
|
isValidRecipient = Array.isArray(recipients) && recipients.includes(messageSource);
|
|
@@ -206,6 +247,9 @@ function tryResumeApprovalFlow(message, store, apiUrl) {
|
|
|
206
247
|
messageSource,
|
|
207
248
|
isValidRecipient,
|
|
208
249
|
});
|
|
250
|
+
// #region agent log
|
|
251
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'message-utils.js:177',message:'1:1 recipient validation result (quote)',data:{key,messageSource,recipients,isValidRecipient},timestamp:Date.now(),hypothesisId:'C'})}).catch(()=>{});
|
|
252
|
+
// #endregion
|
|
209
253
|
}
|
|
210
254
|
|
|
211
255
|
if (!isValidRecipient) continue;
|
|
@@ -271,6 +315,9 @@ function tryResumeApprovalFlow(message, store, apiUrl) {
|
|
|
271
315
|
}
|
|
272
316
|
}
|
|
273
317
|
// If no matching approval found, return
|
|
318
|
+
// #region agent log
|
|
319
|
+
fetch('http://10.3.0.249:7243/ingest/103f08fb-273f-440d-bbe5-4f1e30168ab7',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'message-utils.js:200',message:'Matching result check',data:{mappingFound:!!mapping,responseContent:!!responseContent,reactionType,existingKeysCount:existingKeys.length},timestamp:Date.now(),hypothesisId:'D'})}).catch(()=>{});
|
|
320
|
+
// #endregion
|
|
274
321
|
if (!mapping || !responseContent) {
|
|
275
322
|
return { resumed: false };
|
|
276
323
|
}
|