openzca 0.1.48 → 0.1.49
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/README.md +78 -1
- package/dist/cli.js +2793 -97
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -42,6 +42,30 @@ openzca msg send GROUP_ID "Hi @123456789" --group
|
|
|
42
42
|
|
|
43
43
|
# Listen for incoming messages
|
|
44
44
|
openzca listen
|
|
45
|
+
|
|
46
|
+
# Enable the local SQLite DB for this profile
|
|
47
|
+
openzca db enable
|
|
48
|
+
|
|
49
|
+
# Backfill full group history plus recent DM/chat windows into the DB
|
|
50
|
+
openzca db sync
|
|
51
|
+
|
|
52
|
+
# List stored groups
|
|
53
|
+
openzca db group list --json
|
|
54
|
+
|
|
55
|
+
# Show stored info for one group
|
|
56
|
+
openzca db group info GROUP_ID --json
|
|
57
|
+
|
|
58
|
+
# Read the last 24 hours for one group
|
|
59
|
+
openzca db group messages GROUP_ID --since 24h --json
|
|
60
|
+
|
|
61
|
+
# Read an explicit date range
|
|
62
|
+
openzca db group messages GROUP_ID --from 2026-03-21T00:00:00+07:00 --to 2026-03-22T00:00:00+07:00 --json
|
|
63
|
+
|
|
64
|
+
# Read the latest 20 stored rows by default
|
|
65
|
+
openzca db group messages GROUP_ID --json
|
|
66
|
+
|
|
67
|
+
# Read all matching rows
|
|
68
|
+
openzca db group messages GROUP_ID --all --json
|
|
45
69
|
```
|
|
46
70
|
|
|
47
71
|
## Commands
|
|
@@ -81,7 +105,7 @@ You can also open the saved file manually (for example: `open qr.png` on macOS).
|
|
|
81
105
|
| `openzca msg edit <msgId> <cliMsgId> <threadId> <message>` | Edit message (undo + resend shim) |
|
|
82
106
|
| `openzca msg undo <msgId> <cliMsgId> <threadId>` | Recall a sent message |
|
|
83
107
|
| `openzca msg upload <arg1> [arg2]` | Upload and send file(s) |
|
|
84
|
-
| `openzca msg recent <threadId>` | List recent messages (`-n`, `--json`, newest-first); group mode prefers direct group-history endpoint (websocket fallback) |
|
|
108
|
+
| `openzca msg recent <threadId>` | List recent messages (`-n`, `--json`, newest-first); defaults to live history, supports `--source live|db|auto`; group mode prefers direct group-history endpoint (websocket fallback) |
|
|
85
109
|
| `openzca msg pin <threadId>` | Pin a conversation |
|
|
86
110
|
| `openzca msg unpin <threadId>` | Unpin a conversation |
|
|
87
111
|
| `openzca msg list-pins` | List pinned conversations |
|
|
@@ -91,6 +115,7 @@ Media commands accept local files, `file://` paths, and repeatable `--url` optio
|
|
|
91
115
|
`openzca msg video` attempts native video send for a single `.mp4` input by uploading the video and thumbnail to Zalo first. If `ffmpeg` is unavailable, the input is not a single `.mp4`, or native send fails, it falls back to the normal attachment send path. Use `--thumbnail <path-or-url>` to supply the preview image explicitly.
|
|
92
116
|
Local paths using `~` are expanded automatically (for positional file args, `--url`, and `OPENZCA_LISTEN_MEDIA_DIR`).
|
|
93
117
|
Group text sends via `openzca msg send --group` resolve unique `@Name` or `@userId` mentions against the current group member list using member ids, display names, and usernames. Mention offsets are computed after formatting markers are parsed, so messages like `**@Alice Nguyen** hello` work. If multiple members share the same label, the command fails instead of guessing.
|
|
118
|
+
`msg recent` keeps the previous live behavior by default. Use `--source db` to read only from the local SQLite store, or `--source auto` to try DB first and fall back to live history.
|
|
94
119
|
|
|
95
120
|
### Debug Logging
|
|
96
121
|
|
|
@@ -197,6 +222,54 @@ Poll creation currently targets group threads only and maps to the existing `zca
|
|
|
197
222
|
| `openzca me status <online\|offline>` | Set online status |
|
|
198
223
|
| `openzca me last-online <userId>` | Check last online time |
|
|
199
224
|
|
|
225
|
+
### db — Local SQLite source-of-truth
|
|
226
|
+
|
|
227
|
+
| Command | Description |
|
|
228
|
+
|---------|-------------|
|
|
229
|
+
| `openzca db enable` | Enable profile-scoped SQLite persistence (`--path <sqlite-file>` optional) |
|
|
230
|
+
| `openzca db disable` | Disable automatic DB persistence for the active profile |
|
|
231
|
+
| `openzca db status` | Show DB status, counts, and configured path |
|
|
232
|
+
| `openzca db me info` | Show the stored self profile snapshot |
|
|
233
|
+
| `openzca db me id` | Show the stored self user ID |
|
|
234
|
+
| `openzca db group list` | List groups stored in the DB |
|
|
235
|
+
| `openzca db group info <groupId>` | Show stored info for a group |
|
|
236
|
+
| `openzca db group members <groupId>` | List the stored member snapshot for a group |
|
|
237
|
+
| `openzca db group messages <groupId>` | List stored messages for a group (defaults to latest 20 newest-first; use `--all`, `--since <duration>`, `--from`/`--to`, `--limit`, or `--oldest-first`) |
|
|
238
|
+
| `openzca db friend list` | List friends stored in the DB |
|
|
239
|
+
| `openzca db friend find <query>` | Find stored friends by user ID or name |
|
|
240
|
+
| `openzca db friend info <userId>` | Show stored info for a friend |
|
|
241
|
+
| `openzca db friend messages <userId>` | List stored direct-message rows for a friend (defaults to latest 20 newest-first; use `--all`, `--since <duration>`, `--from`/`--to`, `--limit`, or `--oldest-first`) |
|
|
242
|
+
| `openzca db chat list` | List all chats stored in the DB |
|
|
243
|
+
| `openzca db chat info <chatId>` | Show stored info for a chat (`-g` to force group lookup) |
|
|
244
|
+
| `openzca db chat messages <chatId>` | List stored messages for any chat (`-g`; defaults to latest 20 newest-first; use `--all`, `--since <duration>`, `--from`/`--to`, `--limit`, or `--oldest-first`) |
|
|
245
|
+
| `openzca db message get <id>` | Read a single stored message by `msgId`, `cliMsgId`, or internal message uid |
|
|
246
|
+
| `openzca db sync` | Sync full group history, friend directory, and recent DM/chat windows into the DB |
|
|
247
|
+
| `openzca db sync all` | Explicit full sync |
|
|
248
|
+
| `openzca db sync groups` | Sync group directory, members, and full group history |
|
|
249
|
+
| `openzca db sync friends` | Sync friend directory only |
|
|
250
|
+
| `openzca db sync chats` | Sync discoverable chats and recent DM windows |
|
|
251
|
+
| `openzca db sync group <groupId>` | Sync one group with full group history |
|
|
252
|
+
| `openzca db sync chat <chatId>` | Sync one chat |
|
|
253
|
+
|
|
254
|
+
The DB is per-profile and is intended to be a factual local store for later querying. By default it lives at:
|
|
255
|
+
|
|
256
|
+
```text
|
|
257
|
+
~/.openzca/profiles/<profile>/messages.sqlite
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Notes:
|
|
261
|
+
|
|
262
|
+
- DB reads are explicit. Existing live commands keep their current default behavior.
|
|
263
|
+
- If DB is enabled, successful send commands and `listen` write in the background on a best-effort path so normal CLI flow is not blocked by SQLite work.
|
|
264
|
+
- Group sync is thread-scoped and more reliable because it uses the dedicated group history API when available.
|
|
265
|
+
- DM/chat sync is best-effort only. `zca-js` exposes old DM messages by user-message stream, not by exact DM thread, so `db sync chats` and `db sync chat <id>` should be treated as recent-window fills, not perfect historical mirrors.
|
|
266
|
+
- For DMs, the DB stores messages under a stable peer-based conversation key rather than trusting the raw listener `threadId` alone.
|
|
267
|
+
- Time filters accept:
|
|
268
|
+
- exact timestamps like `2026-03-21T10:00:00+07:00`
|
|
269
|
+
- unix seconds or milliseconds
|
|
270
|
+
- unix seconds or milliseconds
|
|
271
|
+
- relative durations like `7m`, `24h`, `1d`, or `1d2h30m`
|
|
272
|
+
|
|
200
273
|
### listen — Real-time listener
|
|
201
274
|
|
|
202
275
|
| Command | Description |
|
|
@@ -206,6 +279,8 @@ Poll creation currently targets group threads only and maps to the existing `zca
|
|
|
206
279
|
| `openzca listen --prefix <prefix>` | Only process messages matching prefix |
|
|
207
280
|
| `openzca listen --webhook <url>` | POST message payload to a webhook URL |
|
|
208
281
|
| `openzca listen --raw` | Output raw JSON per line |
|
|
282
|
+
| `openzca listen --db` | Force DB writes for this listener session |
|
|
283
|
+
| `openzca listen --no-db` | Disable DB writes for this listener session |
|
|
209
284
|
| `openzca listen --keep-alive` | Auto-reconnect on disconnect |
|
|
210
285
|
| `openzca listen --supervised --raw` | Supervisor mode with lifecycle JSON events (`session_id`, `connected`, `heartbeat`, `error`, `closed`) |
|
|
211
286
|
| `openzca listen --keep-alive --recycle-ms <ms>` | Periodically recycle listener process to avoid stale sessions |
|
|
@@ -358,6 +433,8 @@ Profile data is stored in `~/.openzca/` (override with `OPENZCA_HOME`):
|
|
|
358
433
|
profiles.json
|
|
359
434
|
profiles/<name>/credentials.json
|
|
360
435
|
profiles/<name>/cache/*.json
|
|
436
|
+
profiles/<name>/db.json
|
|
437
|
+
profiles/<name>/messages.sqlite
|
|
361
438
|
```
|
|
362
439
|
|
|
363
440
|
## Development
|