@agent-wechat/cli 0.12.2 → 0.13.0
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/dist/cli.js +11 -10
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -3576,8 +3576,8 @@ var WeChatClient = class {
|
|
|
3576
3576
|
async listMessages(chatId, limit, offset) {
|
|
3577
3577
|
return this.get(`/api/messages/${encodeURIComponent(chatId)}${qs({ limit, offset })}`);
|
|
3578
3578
|
}
|
|
3579
|
-
async getMedia(chatId, localId) {
|
|
3580
|
-
return this.get(`/api/messages/${encodeURIComponent(chatId)}/media/${localId}`);
|
|
3579
|
+
async getMedia(chatId, localId, quality) {
|
|
3580
|
+
return this.get(`/api/messages/${encodeURIComponent(chatId)}/media/${localId}${qs({ quality })}`);
|
|
3581
3581
|
}
|
|
3582
3582
|
async sendMessage(params) {
|
|
3583
3583
|
return this.post("/api/messages/send", params);
|
|
@@ -7849,10 +7849,11 @@ var sendResultSchema = external_exports.object({
|
|
|
7849
7849
|
});
|
|
7850
7850
|
var getMediaParamsSchema = external_exports.object({
|
|
7851
7851
|
chatId: external_exports.string().min(1),
|
|
7852
|
-
localId: external_exports.number().int()
|
|
7852
|
+
localId: external_exports.number().int(),
|
|
7853
|
+
quality: external_exports.enum(["full", "thumbnail"]).optional()
|
|
7853
7854
|
});
|
|
7854
7855
|
var mediaResultSchema = external_exports.object({
|
|
7855
|
-
type: external_exports.enum(["image", "emoji", "voice", "video", "unsupported"]),
|
|
7856
|
+
type: external_exports.enum(["image", "emoji", "voice", "video", "file", "pending", "unsupported"]),
|
|
7856
7857
|
data: external_exports.string().optional(),
|
|
7857
7858
|
url: external_exports.string().optional(),
|
|
7858
7859
|
format: external_exports.string(),
|
|
@@ -7911,7 +7912,7 @@ import qrTerminal from "qrcode-terminal";
|
|
|
7911
7912
|
import os from "os";
|
|
7912
7913
|
import path from "path";
|
|
7913
7914
|
import { fileURLToPath } from "url";
|
|
7914
|
-
var VERSION = "0.
|
|
7915
|
+
var VERSION = "0.13.0";
|
|
7915
7916
|
var CONTAINER_NAME = "agent-wechat";
|
|
7916
7917
|
var GHCR_IMAGE = "ghcr.io/thisnick/agent-wechat";
|
|
7917
7918
|
var DEFAULT_PORT = 6174;
|
|
@@ -8057,8 +8058,8 @@ var messagesCmd = program2.command("messages").description("Message commands");
|
|
|
8057
8058
|
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) => {
|
|
8058
8059
|
await cmdMessages(getClient(), chatId, parseInt(opts.limit, 10), parseInt(opts.offset, 10), opts.json ?? false);
|
|
8059
8060
|
});
|
|
8060
|
-
messagesCmd.command("media <chatId> <localId>").description("Save media attachment (image
|
|
8061
|
-
await cmdMedia(getClient(), chatId, parseInt(localIdStr, 10), opts.output);
|
|
8061
|
+
messagesCmd.command("media <chatId> <localId>").description("Save a media attachment (full-resolution image, file, or voice)").option("--thumbnail", "Retrieve an image thumbnail instead of full resolution").option("-o, --output <path>", "Output file path").action(async (chatId, localIdStr, opts) => {
|
|
8062
|
+
await cmdMedia(getClient(), chatId, parseInt(localIdStr, 10), opts.output, opts.thumbnail);
|
|
8062
8063
|
});
|
|
8063
8064
|
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").action(async (chatId, opts) => {
|
|
8064
8065
|
if (!opts.text && !opts.image && !opts.file) {
|
|
@@ -8335,8 +8336,8 @@ async function cmdMessages(client, chatId, limit = 50, offset = 0, json = false)
|
|
|
8335
8336
|
console.log(`
|
|
8336
8337
|
${messages.length} message(s) shown.`);
|
|
8337
8338
|
}
|
|
8338
|
-
async function cmdMedia(client, chatId, localId, outputPath) {
|
|
8339
|
-
const result = await client.getMedia(chatId, localId);
|
|
8339
|
+
async function cmdMedia(client, chatId, localId, outputPath, thumbnail = false) {
|
|
8340
|
+
const result = await client.getMedia(chatId, localId, thumbnail ? "thumbnail" : "full");
|
|
8340
8341
|
if (result.type === "unsupported") {
|
|
8341
8342
|
console.error("No media found for this message (unsupported type or not found).");
|
|
8342
8343
|
process.exit(1);
|
|
@@ -8351,7 +8352,7 @@ async function cmdMedia(client, chatId, localId, outputPath) {
|
|
|
8351
8352
|
fs.writeFileSync(outFile, buffer);
|
|
8352
8353
|
console.log(`Saved ${result.type} to ${outFile} (${buffer.length} bytes)`);
|
|
8353
8354
|
} else if (result.type === "image") {
|
|
8354
|
-
console.error(
|
|
8355
|
+
console.error(`Requested image ${thumbnail ? "thumbnail" : "full resolution"} is not yet available.`);
|
|
8355
8356
|
process.exit(1);
|
|
8356
8357
|
} else if (result.type === "video") {
|
|
8357
8358
|
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.
|
|
3
|
+
"version": "0.13.0",
|
|
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.
|
|
20
|
+
"@agent-wechat/shared": "0.2.0"
|
|
21
21
|
},
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public",
|