@agent-wechat/cli 0.15.0 → 0.15.1
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 +6 -0
- package/dist/cli.js +13 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -90,6 +90,12 @@ Send options:
|
|
|
90
90
|
|
|
91
91
|
Media options:
|
|
92
92
|
- `--output <path>` — save to a specific file path
|
|
93
|
+
- `--full` — require an original-resolution image
|
|
94
|
+
- `--thumbnail` — save the cached preview
|
|
95
|
+
- `--best` — explicitly choose the default best-available image behavior
|
|
96
|
+
|
|
97
|
+
Media retrieval does not open a chat. Use `wx chats open <chatId>` separately
|
|
98
|
+
if WeChat needs to cache a regular photo's standard-size copy.
|
|
93
99
|
|
|
94
100
|
### Sessions
|
|
95
101
|
|
package/dist/cli.js
CHANGED
|
@@ -7929,7 +7929,7 @@ import qrTerminal from "qrcode-terminal";
|
|
|
7929
7929
|
import os from "os";
|
|
7930
7930
|
import path from "path";
|
|
7931
7931
|
import { fileURLToPath } from "url";
|
|
7932
|
-
var VERSION = "0.15.
|
|
7932
|
+
var VERSION = "0.15.1";
|
|
7933
7933
|
var CONTAINER_NAME = "agent-wechat";
|
|
7934
7934
|
var GHCR_IMAGE = "ghcr.io/thisnick/agent-wechat";
|
|
7935
7935
|
var DEFAULT_PORT = 6174;
|
|
@@ -8075,8 +8075,13 @@ var messagesCmd = program2.command("messages").description("Message commands");
|
|
|
8075
8075
|
messagesCmd.command("list <chatId>").description("List messages for a chat").option("-l, --limit <number>", "Maximum number of messages", "50").option("-o, --offset <number>", "Skip first N messages", "0").option("-j, --json", "Output as JSON").action(async (chatId, opts) => {
|
|
8076
8076
|
await cmdMessages(getClient(), chatId, parseInt(opts.limit, 10), parseInt(opts.offset, 10), opts.json ?? false);
|
|
8077
8077
|
});
|
|
8078
|
-
messagesCmd.command("media <chatId> <localId>").description("Save a media attachment (
|
|
8079
|
-
|
|
8078
|
+
messagesCmd.command("media <chatId> <localId>").description("Save a media attachment (best available image, file, or voice)").option("--full", "Require the original-resolution image").option("--thumbnail", "Retrieve an image thumbnail instead of full resolution").option("--best", "Retrieve the best available image (default)").option("-o, --output <path>", "Output file path").action(async (chatId, localIdStr, opts) => {
|
|
8079
|
+
if (Number(!!opts.full) + Number(!!opts.thumbnail) + Number(!!opts.best) > 1) {
|
|
8080
|
+
console.error("Choose only one of --full, --thumbnail, or --best.");
|
|
8081
|
+
process.exit(1);
|
|
8082
|
+
}
|
|
8083
|
+
const quality = opts.full ? "full" : opts.thumbnail ? "thumbnail" : "best";
|
|
8084
|
+
await cmdMedia(getClient(), chatId, parseInt(localIdStr, 10), opts.output, quality);
|
|
8080
8085
|
});
|
|
8081
8086
|
messagesCmd.command("send <chatId>").description("Send a message to a chat").option("--text <text>", "Text message to send").option("--image <path>", "Image file to send").option("--file <path>", "File to send").option("--voice <path>", "Record audio as one or more voice notes").option("--detach", "Return after the voice job is queued").action(async (chatId, opts) => {
|
|
8082
8087
|
if (!opts.text && !opts.image && !opts.file && !opts.voice) {
|
|
@@ -8390,8 +8395,8 @@ async function cmdMessages(client, chatId, limit = 50, offset = 0, json = false)
|
|
|
8390
8395
|
console.log(`
|
|
8391
8396
|
${messages.length} message(s) shown.`);
|
|
8392
8397
|
}
|
|
8393
|
-
async function cmdMedia(client, chatId, localId, outputPath,
|
|
8394
|
-
const result = await client.getMedia(chatId, localId,
|
|
8398
|
+
async function cmdMedia(client, chatId, localId, outputPath, quality = "best") {
|
|
8399
|
+
const result = await client.getMedia(chatId, localId, quality);
|
|
8395
8400
|
if (result.type === "unsupported") {
|
|
8396
8401
|
console.error("No media found for this message (unsupported type or not found).");
|
|
8397
8402
|
process.exit(1);
|
|
@@ -8404,9 +8409,10 @@ async function cmdMedia(client, chatId, localId, outputPath, thumbnail = false)
|
|
|
8404
8409
|
if (result.data) {
|
|
8405
8410
|
const buffer = Buffer.from(result.data, "base64");
|
|
8406
8411
|
fs.writeFileSync(outFile, buffer);
|
|
8407
|
-
|
|
8412
|
+
const variant = result.type === "image" && result.quality ? ` (${result.quality})` : "";
|
|
8413
|
+
console.log(`Saved ${result.type}${variant} to ${outFile} (${buffer.length} bytes)`);
|
|
8408
8414
|
} else if (result.type === "image") {
|
|
8409
|
-
console.error(`Requested image ${
|
|
8415
|
+
console.error(`Requested image ${quality} is not yet available.${quality === "full" ? " Regular phone sends may have no Original copy; try without --full." : ""}`);
|
|
8410
8416
|
process.exit(1);
|
|
8411
8417
|
} else if (result.type === "video") {
|
|
8412
8418
|
console.error("Video not yet downloaded by WeChat. Try playing the video in the app first.");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-wechat/cli",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"wx": "./dist/cli.js"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@types/node": "^22",
|
|
18
18
|
"@types/qrcode-terminal": "^0.12.2",
|
|
19
19
|
"typescript": "^5.4.5",
|
|
20
|
-
"@agent-wechat/shared": "0.3.
|
|
20
|
+
"@agent-wechat/shared": "0.3.1"
|
|
21
21
|
},
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public",
|