@shenhh/popo 0.1.17 → 0.1.19

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": "@shenhh/popo",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "type": "module",
5
5
  "description": "OpenClaw POPO channel plugin",
6
6
  "license": "MIT",
@@ -237,6 +237,16 @@ Common errors:
237
237
 
238
238
  Recall (retract) a sent message within the allowed time window.
239
239
 
240
+ ```json
241
+ {
242
+ "action": "recall",
243
+ "msgId": "794076f2-68b1-4d0e-94eb-c15946580b56",
244
+ "target": "user@corp.netease.com"
245
+ }
246
+ ```
247
+
248
+ Or using POPO-specific parameters:
249
+
240
250
  ```json
241
251
  {
242
252
  "action": "recall",
@@ -248,8 +258,11 @@ Recall (retract) a sent message within the allowed time window.
248
258
 
249
259
  **Parameters:**
250
260
  - `msgId` (required): Message ID to recall
251
- - `sessionId` (required): Session ID (user email for P2P, group ID for group)
252
- - `sessionType` (required): `1` for P2P, `3` for group
261
+ - `target` (required*): Target user email or group ID (OpenClaw standard)
262
+ - `sessionId` (required*): Session ID (user email for P2P, group ID for group) - alias for target
263
+ - `sessionType` (optional): `1` for P2P, `3` for group (auto-detected from target if not provided)
264
+
265
+ \* Either `target` or `sessionId` must be provided.
253
266
 
254
267
  **Note:** Messages can only be recalled within a limited time (typically 2 minutes).
255
268
 
@@ -257,6 +270,20 @@ Recall (retract) a sent message within the allowed time window.
257
270
 
258
271
  Query read/unread status for group messages.
259
272
 
273
+ ```json
274
+ {
275
+ "action": "read-ack",
276
+ "msgId": "1000016836-0000000004",
277
+ "target": "group:1234567",
278
+ "type": 1,
279
+ "st": 1672221224000,
280
+ "page": 1,
281
+ "size": 30
282
+ }
283
+ ```
284
+
285
+ Or using POPO-specific parameters:
286
+
260
287
  ```json
261
288
  {
262
289
  "action": "read-ack",
@@ -271,12 +298,15 @@ Query read/unread status for group messages.
271
298
 
272
299
  **Parameters:**
273
300
  - `msgId` (required): Message ID
274
- - `sessionType` (required): Must be `3` (group)
275
- - `type` (required): `1` for read list, `2` for unread list
276
- - `st` (required): Query end timestamp (milliseconds)
301
+ - `target` (optional): Group ID for context (e.g., `group:1234567` or `1234567`)
302
+ - `sessionType` (optional): Must be `3` (group), default is 3
303
+ - `type` (optional): `1` for read list, `2` for unread list, default 1
304
+ - `st` (optional): Query end timestamp (milliseconds), default is current time
277
305
  - `page` (optional): Page number, default 1
278
306
  - `size` (optional): Page size, default 30
279
307
 
308
+ **Note:** Read-ack only works for group messages, not P2P.
309
+
280
310
  **Response:**
281
311
  ```json
282
312
  {
package/src/channel.ts CHANGED
@@ -313,12 +313,14 @@ export const popoPlugin: ChannelPlugin<ResolvedPopoAccount> = {
313
313
  // Handle recall action
314
314
  if (action === "recall") {
315
315
  const msgId = typeof params.msgId === "string" ? params.msgId : typeof params.messageId === "string" ? params.messageId : "";
316
- const sessionId = typeof params.sessionId === "string" ? params.sessionId : "";
317
- const sessionType = typeof params.sessionType === "number" ? params.sessionType : 1;
316
+ // Support both target (OpenClaw standard) and sessionId (POPO-specific)
317
+ const target = typeof params.target === "string" ? params.target : "";
318
+ const sessionId = typeof params.sessionId === "string" ? params.sessionId : target;
319
+ const sessionType = typeof params.sessionType === "number" ? params.sessionType : (target.includes("@") ? 1 : 3);
318
320
  if (!msgId || !sessionId) {
319
321
  return {
320
322
  isError: true,
321
- content: [{ type: "text", text: "Recall requires msgId and sessionId." }],
323
+ content: [{ type: "text", text: "Recall requires msgId and target (or sessionId)." }],
322
324
  };
323
325
  }
324
326
  const result = await recallMessagePopo({ cfg, msgId, sessionId, sessionType: sessionType as 1 | 3 });
@@ -339,6 +341,8 @@ export const popoPlugin: ChannelPlugin<ResolvedPopoAccount> = {
339
341
  // Handle read-ack action
340
342
  if (action === "read-ack") {
341
343
  const msgId = typeof params.msgId === "string" ? params.msgId : "";
344
+ // Support target (OpenClaw standard) for group identification
345
+ const target = typeof params.target === "string" ? params.target : "";
342
346
  const type = typeof params.type === "number" ? params.type : 1;
343
347
  const st = typeof params.st === "number" ? params.st : Date.now();
344
348
  const page = typeof params.page === "number" ? params.page : 1;
@@ -349,6 +353,13 @@ export const popoPlugin: ChannelPlugin<ResolvedPopoAccount> = {
349
353
  content: [{ type: "text", text: "Read-ack requires msgId." }],
350
354
  };
351
355
  }
356
+ // If target is provided, validate it's a group (read-ack only works for groups)
357
+ if (target && target.includes("@")) {
358
+ return {
359
+ isError: true,
360
+ content: [{ type: "text", text: "Read-ack only works for group messages, not P2P." }],
361
+ };
362
+ }
352
363
  const result = await getMessageReadAckPopo({
353
364
  cfg,
354
365
  msgId,