@unicitylabs/openclaw-unicity 0.5.2 → 0.5.3
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 +1 -1
- package/src/channel.ts +11 -5
package/package.json
CHANGED
package/src/channel.ts
CHANGED
|
@@ -248,8 +248,19 @@ export const unicityChannelPlugin = {
|
|
|
248
248
|
const seenDmIds = new Set<string>();
|
|
249
249
|
const DM_SEEN_MAX = 1000;
|
|
250
250
|
|
|
251
|
+
// Collect all known representations of "self" so we can detect echoed-back
|
|
252
|
+
// messages. The SDK's built-in self-check compares transport pubkey against
|
|
253
|
+
// chainPubkey, but those may differ in format (33-byte compressed vs 32-byte
|
|
254
|
+
// x-only Nostr key), letting self-messages slip through.
|
|
255
|
+
const selfPubkeys = new Set<string>();
|
|
256
|
+
if (sphere.identity?.chainPubkey) selfPubkeys.add(sphere.identity.chainPubkey);
|
|
257
|
+
const myNostrPubkey = sphere.groupChat?.getMyPublicKey?.() ?? null;
|
|
258
|
+
if (myNostrPubkey) selfPubkeys.add(myNostrPubkey);
|
|
251
259
|
|
|
252
260
|
const unsub = sphere.communications.onDirectMessage((msg) => {
|
|
261
|
+
// Skip messages from self (own DMs echoed back by the relay)
|
|
262
|
+
if (selfPubkeys.has(msg.senderPubkey)) return;
|
|
263
|
+
|
|
253
264
|
// Deduplicate: skip already-processed messages (relays may deliver dupes)
|
|
254
265
|
if (msg.id && seenDmIds.has(msg.id)) return;
|
|
255
266
|
if (msg.id) {
|
|
@@ -480,11 +491,6 @@ export const unicityChannelPlugin = {
|
|
|
480
491
|
replyToId?: string;
|
|
481
492
|
};
|
|
482
493
|
|
|
483
|
-
// Nostr pubkey for self-message detection and reply-to-self detection.
|
|
484
|
-
// Group messages use the 32-byte x-only Nostr pubkey (event.pubkey),
|
|
485
|
-
// NOT the 33-byte compressed chainPubkey.
|
|
486
|
-
const myNostrPubkey = sphere.groupChat?.getMyPublicKey?.() ?? null;
|
|
487
|
-
|
|
488
494
|
// Detect if a group message is a reply to one of the agent's own messages.
|
|
489
495
|
// Used to set WasMentioned so the mention gate treats replies-to-self as
|
|
490
496
|
// implicit mentions (same pattern Discord uses for thread replies).
|