openzca 0.1.26 → 0.1.27

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +17 -10
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -273,7 +273,7 @@ Listener resilience override:
273
273
  - Default: enabled.
274
274
  - Set to `0` to keep only quote metadata/URLs without downloading.
275
275
  - `OPENZCA_RECENT_USER_MAX_PAGES`: max websocket history pages to scan for `msg recent` in user/DM mode.
276
- - Default: `6`.
276
+ - Default: `20`.
277
277
  - Increase if a DM thread is old and not found in the first page.
278
278
  - `OPENZCA_LISTEN_ENFORCE_SINGLE_OWNER`: enforce one `listen` owner process per profile.
279
279
  - Default: enabled.
package/dist/cli.js CHANGED
@@ -1582,6 +1582,12 @@ function sortRecentMessagesNewestFirst(messages) {
1582
1582
  return rightCliMsgId.localeCompare(leftCliMsgId);
1583
1583
  });
1584
1584
  }
1585
+ function getRecentMessageCursor(message) {
1586
+ if (!message) return "";
1587
+ const actionId = String(message.data?.actionId ?? "").trim();
1588
+ if (actionId) return actionId;
1589
+ return String(message.data?.msgId ?? "").trim();
1590
+ }
1585
1591
  async function fetchRecentGroupMessagesViaApi(api, threadId, count) {
1586
1592
  const historyApi = api.getGroupChatHistory;
1587
1593
  if (typeof historyApi !== "function") {
@@ -1598,21 +1604,22 @@ async function fetchRecentUserMessagesViaListener(api, threadId, count) {
1598
1604
  let settled = false;
1599
1605
  const collected = [];
1600
1606
  const seenMessageKeys = /* @__PURE__ */ new Set();
1601
- const requestedLastIds = /* @__PURE__ */ new Set();
1602
- const maxPages = parsePositiveIntFromEnv("OPENZCA_RECENT_USER_MAX_PAGES", 6);
1607
+ const requestedCursors = /* @__PURE__ */ new Set();
1608
+ const maxPages = parsePositiveIntFromEnv("OPENZCA_RECENT_USER_MAX_PAGES", 20);
1603
1609
  let pagesRequested = 0;
1604
1610
  const toKey = (message) => {
1605
1611
  const msgId = String(message.data?.msgId ?? "");
1606
1612
  const cliMsgId = String(message.data?.cliMsgId ?? "");
1607
1613
  return `${msgId}:${cliMsgId}`;
1608
1614
  };
1609
- const requestPage = (lastMsgId) => {
1610
- if (lastMsgId) {
1611
- if (requestedLastIds.has(lastMsgId)) return false;
1612
- requestedLastIds.add(lastMsgId);
1615
+ const requestPage = (lastId) => {
1616
+ const cursor = String(lastId ?? "").trim();
1617
+ if (cursor) {
1618
+ if (requestedCursors.has(cursor)) return false;
1619
+ requestedCursors.add(cursor);
1613
1620
  }
1614
1621
  pagesRequested += 1;
1615
- api.listener.requestOldMessages(ThreadType.User, lastMsgId);
1622
+ api.listener.requestOldMessages(ThreadType.User, cursor || null);
1616
1623
  return true;
1617
1624
  };
1618
1625
  const cleanup = () => {
@@ -1676,13 +1683,13 @@ async function fetchRecentUserMessagesViaListener(api, threadId, count) {
1676
1683
  oldest = message;
1677
1684
  }
1678
1685
  }
1679
- const nextLastId = String(oldest?.data?.msgId ?? "").trim();
1680
- if (!nextLastId) {
1686
+ const nextCursor = getRecentMessageCursor(oldest);
1687
+ if (!nextCursor) {
1681
1688
  finish();
1682
1689
  return;
1683
1690
  }
1684
1691
  try {
1685
- const requested = requestPage(nextLastId);
1692
+ const requested = requestPage(nextCursor);
1686
1693
  if (!requested) {
1687
1694
  finish();
1688
1695
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openzca",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "description": "Open-source zca-compatible CLI to integrate Zalo with OpenClaw",
5
5
  "type": "module",
6
6
  "bin": {