@agent-wechat/cli 0.6.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.
Files changed (2) hide show
  1. package/dist/cli.js +78 -1
  2. package/package.json +1 -1
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.6.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;
@@ -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
  });
@@ -8417,6 +8418,82 @@ async function cmdSessionDelete(client, idOrName) {
8417
8418
  process.exit(1);
8418
8419
  }
8419
8420
  }
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
+ }
8420
8497
  async function cmdUp(opts = {}) {
8421
8498
  let image = getImageTag();
8422
8499
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-wechat/cli",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "wx": "./dist/cli.js"