@agent-wechat/cli 0.7.2 → 0.7.4

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 +17 -21
  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.7.2";
7907
+ var VERSION = "0.7.4";
7908
7908
  var CONTAINER_NAME = "agent-wechat";
7909
7909
  var GHCR_IMAGE = "ghcr.io/thisnick/agent-wechat";
7910
7910
  var DEFAULT_PORT = 6174;
@@ -8434,35 +8434,28 @@ async function cmdUpdate() {
8434
8434
  console.error("No running agent-wechat container found.");
8435
8435
  process.exit(1);
8436
8436
  }
8437
- let arch;
8438
- const containerArch = execSync(
8439
- `docker inspect --format "{{.Architecture}}" "${container}"`,
8437
+ const uname = execSync(
8438
+ `docker exec "${container}" uname -m`,
8440
8439
  { encoding: "utf-8" }
8441
8440
  ).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
- }
8441
+ const arch = uname === "x86_64" ? "amd64" : "arm64";
8453
8442
  const assetName = `agent-server-${version}-linux-${arch}`;
8454
8443
  const tmpFile = path.join(os.tmpdir(), assetName);
8444
+ const releaseUrl = `https://github.com/thisnick/agent-wechat/releases/download/v${version}/${assetName}`;
8455
8445
  console.log(`Downloading ${assetName}...`);
8456
8446
  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 {
8447
+ const resp = await fetch(releaseUrl, { redirect: "follow" });
8448
+ if (!resp.ok) {
8449
+ throw new Error(`HTTP ${resp.status}: ${resp.statusText}`);
8450
+ }
8451
+ const buffer = Buffer.from(await resp.arrayBuffer());
8452
+ fs.writeFileSync(tmpFile, buffer, { mode: 493 });
8453
+ } catch (err) {
8462
8454
  console.error(
8463
8455
  `Failed to download ${assetName} from GitHub Releases.
8464
8456
  Make sure v${version} has been released with binary assets.
8465
- You may need to install the GitHub CLI: https://cli.github.com`
8457
+ URL: ${releaseUrl}
8458
+ Error: ${err instanceof Error ? err.message : String(err)}`
8466
8459
  );
8467
8460
  process.exit(1);
8468
8461
  }
@@ -8470,6 +8463,9 @@ You may need to install the GitHub CLI: https://cli.github.com`
8470
8463
  execSync(`docker cp "${tmpFile}" "${container}:/opt/agent-server/agent-server"`, {
8471
8464
  stdio: "inherit"
8472
8465
  });
8466
+ execSync(`docker exec "${container}" chmod +x /opt/agent-server/agent-server`, {
8467
+ stdio: "inherit"
8468
+ });
8473
8469
  execSync(
8474
8470
  `docker exec "${container}" pkill -f "/opt/agent-server/agent-server" 2>/dev/null || true`,
8475
8471
  { stdio: "inherit" }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-wechat/cli",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "wx": "./dist/cli.js"