openzca 0.1.24 → 0.1.25

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 +7 -1
  2. package/dist/cli.js +17 -7
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -76,7 +76,7 @@ You can also open the saved file manually (for example: `open qr.png` on macOS).
76
76
  | `openzca msg delete <msgId> <cliMsgId> <uidFrom> <threadId>` | Delete a message |
77
77
  | `openzca msg undo <msgId> <cliMsgId> <threadId>` | Recall a sent message |
78
78
  | `openzca msg upload <arg1> [arg2]` | Upload and send file(s) |
79
- | `openzca msg recent <threadId>` | List recent messages (`-n`, `--json`) |
79
+ | `openzca msg recent <threadId>` | List recent messages (`-n`, `--json`); group mode uses direct group-history API |
80
80
 
81
81
  Media commands accept local files, `file://` paths, and repeatable `--url` options. Add `--group` for group threads.
82
82
  Local paths using `~` are expanded automatically (for positional file args, `--url`, and `OPENZCA_LISTEN_MEDIA_DIR`).
@@ -303,6 +303,12 @@ Upload/listener coordination overrides:
303
303
  - `OPENZCA_UPLOAD_ENFORCE_SINGLE_OWNER`: when an active listener owner exists but IPC is unavailable, fail fast instead of starting a second listener.
304
304
  - Default: enabled.
305
305
  - Set to `0` to allow fallback listener startup (may disconnect active listener due duplicate websocket ownership).
306
+ - `OPENZCA_UPLOAD_AUTO_THREAD_TYPE`: auto-detect `msg upload` thread type (group/user) when `--group` is not provided.
307
+ - Default: disabled (`0`) for safer routing.
308
+ - Set to `1` to enable cache/probe-based detection.
309
+ - `OPENZCA_UPLOAD_GROUP_PROBE`: allow `msg upload` to probe `getGroupInfo` when auto thread-type detection is enabled.
310
+ - Default: enabled.
311
+ - Set to `0` to skip probe and rely only on cache matches.
306
312
 
307
313
  ### account — Multi-account profiles
308
314
 
package/dist/cli.js CHANGED
@@ -1177,7 +1177,7 @@ async function resolveUploadThreadType(api, profile, threadId, groupFlag, comman
1177
1177
  if (groupFlag) {
1178
1178
  return { type: ThreadType.Group, reason: "explicit_group_flag" };
1179
1179
  }
1180
- const autoDetectEnabled = parseBooleanFromEnv("OPENZCA_UPLOAD_AUTO_THREAD_TYPE", true);
1180
+ const autoDetectEnabled = parseBooleanFromEnv("OPENZCA_UPLOAD_AUTO_THREAD_TYPE", false);
1181
1181
  if (!autoDetectEnabled) {
1182
1182
  return { type: ThreadType.User, reason: "auto_detect_disabled" };
1183
1183
  }
@@ -1555,7 +1555,18 @@ async function withUploadListener(api, command, task) {
1555
1555
  api.listener.off("closed", sinkClosed);
1556
1556
  }
1557
1557
  }
1558
- async function fetchRecentMessagesViaListener(api, threadId, threadType, count) {
1558
+ async function fetchRecentGroupMessagesViaApi(api, threadId, count) {
1559
+ const historyApi = api.getGroupChatHistory;
1560
+ if (typeof historyApi !== "function") {
1561
+ throw new Error(
1562
+ "Current zca-js build does not expose getGroupChatHistory(). Upgrade zca-js/openzca."
1563
+ );
1564
+ }
1565
+ const response = await historyApi(threadId, count);
1566
+ const messages = Array.isArray(response?.groupMsgs) ? response.groupMsgs : [];
1567
+ return messages.slice(0, count);
1568
+ }
1569
+ async function fetchRecentUserMessagesViaListener(api, threadId, count) {
1559
1570
  return new Promise((resolve, reject) => {
1560
1571
  let settled = false;
1561
1572
  const collected = [];
@@ -1582,13 +1593,13 @@ async function fetchRecentMessagesViaListener(api, threadId, threadType, count)
1582
1593
  };
1583
1594
  const onConnected = () => {
1584
1595
  try {
1585
- api.listener.requestOldMessages(threadType, null);
1596
+ api.listener.requestOldMessages(ThreadType.User, null);
1586
1597
  } catch (error) {
1587
1598
  finish(error);
1588
1599
  }
1589
1600
  };
1590
1601
  const onOldMessages = (messages, type) => {
1591
- if (type !== threadType) return;
1602
+ if (type !== ThreadType.User) return;
1592
1603
  const typedMessages = messages;
1593
1604
  for (const message of typedMessages) {
1594
1605
  if (message.threadId === threadId) {
@@ -2952,17 +2963,16 @@ msg.command("upload <arg1> [arg2]").option("-u, --url <url>", "File URL (repeata
2952
2963
  }
2953
2964
  )
2954
2965
  );
2955
- msg.command("recent <threadId>").option("-g, --group", "List recent messages for group thread").option("-n, --count <count>", "Number of messages (default: 20)", "20").option("-j, --json", "JSON output").description("List recent messages via websocket history").action(
2966
+ msg.command("recent <threadId>").option("-g, --group", "List recent messages for group thread").option("-n, --count <count>", "Number of messages (default: 20)", "20").option("-j, --json", "JSON output").description("List recent messages (group uses direct history API)").action(
2956
2967
  wrapAction(
2957
2968
  async (threadId, opts, command) => {
2958
2969
  const { api } = await requireApi(command);
2959
2970
  const parsedCount = Number(opts.count);
2960
2971
  const count = Number.isFinite(parsedCount) ? Math.min(Math.max(Math.trunc(parsedCount), 1), 200) : 20;
2961
2972
  const threadType = opts.group ? ThreadType.Group : ThreadType.User;
2962
- const messages = await fetchRecentMessagesViaListener(
2973
+ const messages = opts.group ? await fetchRecentGroupMessagesViaApi(api, threadId, count) : await fetchRecentUserMessagesViaListener(
2963
2974
  api,
2964
2975
  threadId,
2965
- threadType,
2966
2976
  count
2967
2977
  );
2968
2978
  const rows = messages.map((message) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openzca",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "description": "Open-source zca-compatible CLI to integrate Zalo with OpenClaw",
5
5
  "type": "module",
6
6
  "bin": {