@agent-wechat/cli 0.5.0 → 0.7.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/README.md +12 -1
- package/dist/cli.js +90 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ wx messages send <chatId> --text "Hello"
|
|
|
43
43
|
|
|
44
44
|
| Command | Description |
|
|
45
45
|
|---------|-------------|
|
|
46
|
-
| `wx up` | Start the agent-wechat container |
|
|
46
|
+
| `wx up [--proxy user:pass@host:port]` | Start the agent-wechat container |
|
|
47
47
|
| `wx down` | Stop and remove the container |
|
|
48
48
|
| `wx logs` | Tail container logs |
|
|
49
49
|
| `wx status` | Show container and login status |
|
|
@@ -146,6 +146,14 @@ This starts a container named `agent-wechat` with:
|
|
|
146
146
|
- Persistent volumes for data and WeChat home directory
|
|
147
147
|
- Auth token from `~/.config/agent-wechat/token` (auto-generated on first run)
|
|
148
148
|
|
|
149
|
+
To route all container traffic through a proxy:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
wx up --proxy user:pass@host:port
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
This sets up a transparent proxy (redsocks + iptables) inside the container — invisible to WeChat. Prefix with `socks5://` for SOCKS5 proxies.
|
|
156
|
+
|
|
149
157
|
### Option 2: Docker Compose (production / networked)
|
|
150
158
|
|
|
151
159
|
For production or when running alongside other services (e.g., OpenClaw), use the `docker-compose.yml` in the repo root as a reference:
|
|
@@ -159,6 +167,7 @@ services:
|
|
|
159
167
|
- seccomp=unconfined
|
|
160
168
|
cap_add:
|
|
161
169
|
- SYS_PTRACE
|
|
170
|
+
- NET_ADMIN
|
|
162
171
|
ports:
|
|
163
172
|
- "6174:6174"
|
|
164
173
|
- "127.0.0.1:5900:5900"
|
|
@@ -166,6 +175,8 @@ services:
|
|
|
166
175
|
- agent-wechat-data:/data
|
|
167
176
|
- agent-wechat-home:/home/wechat
|
|
168
177
|
- ~/.config/agent-wechat/token:/data/auth-token:ro
|
|
178
|
+
environment:
|
|
179
|
+
- PROXY=${PROXY:-} # optional: user:pass@host:port
|
|
169
180
|
restart: unless-stopped
|
|
170
181
|
|
|
171
182
|
volumes:
|
package/dist/cli.js
CHANGED
|
@@ -7904,7 +7904,7 @@ import qrTerminal from "qrcode-terminal";
|
|
|
7904
7904
|
import os from "os";
|
|
7905
7905
|
import path from "path";
|
|
7906
7906
|
import { fileURLToPath } from "url";
|
|
7907
|
-
var VERSION = "0.
|
|
7907
|
+
var VERSION = "0.7.0";
|
|
7908
7908
|
var CONTAINER_NAME = "agent-wechat";
|
|
7909
7909
|
var GHCR_IMAGE = "ghcr.io/thisnick/agent-wechat";
|
|
7910
7910
|
var DEFAULT_PORT = 6174;
|
|
@@ -7962,7 +7962,7 @@ function getSubscriptionOptions() {
|
|
|
7962
7962
|
sessionId: opts.session
|
|
7963
7963
|
};
|
|
7964
7964
|
}
|
|
7965
|
-
program2.command("up").description("Start the WeChat container").action(cmdUp);
|
|
7965
|
+
program2.command("up").description("Start the WeChat container").option("--proxy <url>", "Transparent proxy (user:pass@host:port)").action((opts) => cmdUp(opts));
|
|
7966
7966
|
program2.command("down").description("Stop and remove the container").action(cmdDown);
|
|
7967
7967
|
program2.command("logs").description("Show container logs").action(cmdLogs);
|
|
7968
7968
|
var sessionCmd = program2.command("session").description("Manage sessions");
|
|
@@ -8066,6 +8066,7 @@ messagesCmd.command("send <chatId>").description("Send a message to a chat").opt
|
|
|
8066
8066
|
}
|
|
8067
8067
|
await cmdSend(getClient(), chatId, opts.text, image, file);
|
|
8068
8068
|
});
|
|
8069
|
+
program2.command("update").description("Update the agent-server binary in the running container to match CLI version").action(cmdUpdate);
|
|
8069
8070
|
program2.command("screenshot").description("Save screenshot to file").argument("[file]", "Output file path", "screenshot.png").action(async (file) => {
|
|
8070
8071
|
await cmdScreenshot(getClient(), file);
|
|
8071
8072
|
});
|
|
@@ -8096,7 +8097,10 @@ async function cmdLogin(options, timeoutMs = 3e5, newAccount = false) {
|
|
|
8096
8097
|
try {
|
|
8097
8098
|
await new Promise((resolve, reject) => {
|
|
8098
8099
|
subscription = client.status.loginSubscription.subscribe(
|
|
8099
|
-
{
|
|
8100
|
+
{
|
|
8101
|
+
timeoutMs,
|
|
8102
|
+
newAccount
|
|
8103
|
+
},
|
|
8100
8104
|
{
|
|
8101
8105
|
onData: (event) => {
|
|
8102
8106
|
switch (event.type) {
|
|
@@ -8414,7 +8418,83 @@ async function cmdSessionDelete(client, idOrName) {
|
|
|
8414
8418
|
process.exit(1);
|
|
8415
8419
|
}
|
|
8416
8420
|
}
|
|
8417
|
-
async function
|
|
8421
|
+
async function cmdUpdate() {
|
|
8422
|
+
const version = VERSION;
|
|
8423
|
+
console.log(`Updating agent-server to v${version}...`);
|
|
8424
|
+
let container;
|
|
8425
|
+
try {
|
|
8426
|
+
container = execSync(
|
|
8427
|
+
`docker ps --filter "name=agent-wechat" --format "{{.Names}}" | head -1`,
|
|
8428
|
+
{ encoding: "utf-8" }
|
|
8429
|
+
).trim();
|
|
8430
|
+
} catch {
|
|
8431
|
+
container = "";
|
|
8432
|
+
}
|
|
8433
|
+
if (!container) {
|
|
8434
|
+
console.error("No running agent-wechat container found.");
|
|
8435
|
+
process.exit(1);
|
|
8436
|
+
}
|
|
8437
|
+
let arch;
|
|
8438
|
+
const containerArch = execSync(
|
|
8439
|
+
`docker inspect --format "{{.Architecture}}" "${container}"`,
|
|
8440
|
+
{ encoding: "utf-8" }
|
|
8441
|
+
).trim();
|
|
8442
|
+
switch (containerArch) {
|
|
8443
|
+
case "amd64":
|
|
8444
|
+
arch = "amd64";
|
|
8445
|
+
break;
|
|
8446
|
+
case "arm64":
|
|
8447
|
+
arch = "arm64";
|
|
8448
|
+
break;
|
|
8449
|
+
default:
|
|
8450
|
+
const uname = execSync("uname -m", { encoding: "utf-8" }).trim();
|
|
8451
|
+
arch = uname === "x86_64" ? "amd64" : "arm64";
|
|
8452
|
+
}
|
|
8453
|
+
const assetName = `agent-server-${version}-linux-${arch}`;
|
|
8454
|
+
const tmpFile = path.join(os.tmpdir(), assetName);
|
|
8455
|
+
console.log(`Downloading ${assetName}...`);
|
|
8456
|
+
try {
|
|
8457
|
+
execSync(
|
|
8458
|
+
`gh release download "v${version}" --repo thisnick/agent-wechat -p "${assetName}" -D "${os.tmpdir()}" --clobber`,
|
|
8459
|
+
{ stdio: "inherit" }
|
|
8460
|
+
);
|
|
8461
|
+
} catch {
|
|
8462
|
+
console.error(
|
|
8463
|
+
`Failed to download ${assetName} from GitHub Releases.
|
|
8464
|
+
Make sure v${version} has been released with binary assets.
|
|
8465
|
+
You may need to install the GitHub CLI: https://cli.github.com`
|
|
8466
|
+
);
|
|
8467
|
+
process.exit(1);
|
|
8468
|
+
}
|
|
8469
|
+
console.log(`Deploying to ${container}...`);
|
|
8470
|
+
execSync(`docker cp "${tmpFile}" "${container}:/opt/agent-server/agent-server"`, {
|
|
8471
|
+
stdio: "inherit"
|
|
8472
|
+
});
|
|
8473
|
+
execSync(
|
|
8474
|
+
`docker exec "${container}" pkill -f "/opt/agent-server/agent-server" 2>/dev/null || true`,
|
|
8475
|
+
{ stdio: "inherit" }
|
|
8476
|
+
);
|
|
8477
|
+
try {
|
|
8478
|
+
fs.unlinkSync(tmpFile);
|
|
8479
|
+
} catch {
|
|
8480
|
+
}
|
|
8481
|
+
console.log("Server restarting with new binary.");
|
|
8482
|
+
console.log("Waiting for server...");
|
|
8483
|
+
const config = getConfig();
|
|
8484
|
+
for (let i = 0; i < 15; i++) {
|
|
8485
|
+
await new Promise((r) => setTimeout(r, 1e3));
|
|
8486
|
+
try {
|
|
8487
|
+
const resp = await fetch(`${config.serverUrl}/health`);
|
|
8488
|
+
if (resp.ok) {
|
|
8489
|
+
console.log("Server is ready!");
|
|
8490
|
+
return;
|
|
8491
|
+
}
|
|
8492
|
+
} catch {
|
|
8493
|
+
}
|
|
8494
|
+
}
|
|
8495
|
+
console.log("Server did not become ready in time. Check logs with: wx logs");
|
|
8496
|
+
}
|
|
8497
|
+
async function cmdUp(opts = {}) {
|
|
8418
8498
|
let image = getImageTag();
|
|
8419
8499
|
try {
|
|
8420
8500
|
const existingId = execSync(`docker ps -aq -f "name=^${CONTAINER_NAME}$"`, { encoding: "utf-8" }).trim();
|
|
@@ -8467,6 +8547,7 @@ async function cmdUp() {
|
|
|
8467
8547
|
"--security-opt",
|
|
8468
8548
|
"seccomp=unconfined",
|
|
8469
8549
|
"--cap-add=SYS_PTRACE",
|
|
8550
|
+
"--cap-add=NET_ADMIN",
|
|
8470
8551
|
"-p",
|
|
8471
8552
|
`${DEFAULT_PORT}:${DEFAULT_PORT}`,
|
|
8472
8553
|
"-p",
|
|
@@ -8476,9 +8557,12 @@ async function cmdUp() {
|
|
|
8476
8557
|
"-v",
|
|
8477
8558
|
`${CONTAINER_NAME}-wechat-home:/home/wechat`,
|
|
8478
8559
|
"-v",
|
|
8479
|
-
`${TOKEN_PATH}:/data/auth-token:ro
|
|
8480
|
-
image
|
|
8560
|
+
`${TOKEN_PATH}:/data/auth-token:ro`
|
|
8481
8561
|
];
|
|
8562
|
+
if (opts.proxy) {
|
|
8563
|
+
dockerArgs.push("-e", `PROXY=${opts.proxy}`);
|
|
8564
|
+
}
|
|
8565
|
+
dockerArgs.push(image);
|
|
8482
8566
|
try {
|
|
8483
8567
|
execSync(`docker ${dockerArgs.join(" ")}`, { stdio: "inherit" });
|
|
8484
8568
|
console.log(`
|