munim-computer-use 0.3.0 → 0.4.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 CHANGED
@@ -6,4 +6,4 @@ npm launcher for [Computer Use](https://github.com/munimtechnologies/munim-compu
6
6
  claude mcp add munim-computer-use -- npx -y munim-computer-use
7
7
  ```
8
8
 
9
- macOS (universal) and Windows x64 are prebuilt. On Linux build from source and set `COMPUTER_USE_BINARY` to the result. Full documentation: https://github.com/munimtechnologies/munim-computer-use
9
+ macOS (universal), Windows x64 and Linux x64/arm64 (glibc 2.39+, X11) are prebuilt. Elsewhere, build from source and set `COMPUTER_USE_BINARY` to the result. Full documentation: https://github.com/munimtechnologies/munim-computer-use
@@ -22,6 +22,8 @@ function assetFor(platform, arch) {
22
22
  return { asset: "munim-computer-use-macos-universal.zip", binary: "munim-computer-use" };
23
23
  if (platform === "win32" && arch === "x64")
24
24
  return { asset: "munim-computer-use-windows-x64.zip", binary: "munim-computer-use.exe" };
25
+ if (platform === "linux" && (arch === "x64" || arch === "arm64"))
26
+ return { asset: `munim-computer-use-linux-${arch}.tar.gz`, binary: "munim-computer-use" };
25
27
  return null;
26
28
  }
27
29
 
@@ -37,8 +39,18 @@ function cacheDir() {
37
39
  return path.join(base, VERSION);
38
40
  }
39
41
 
42
+ // A stalled connection must not hang the MCP client's startup forever.
43
+ const DOWNLOAD_TIMEOUT_MS = Number(process.env.COMPUTER_USE_DOWNLOAD_TIMEOUT_MS) || 120_000;
44
+
40
45
  async function download(url, dest) {
41
- const res = await fetch(url, { redirect: "follow" });
46
+ const res = await fetch(url, {
47
+ redirect: "follow",
48
+ signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS),
49
+ }).catch((error) => {
50
+ if (error && (error.name === "TimeoutError" || error.name === "AbortError"))
51
+ throw new Error(`download timed out after ${DOWNLOAD_TIMEOUT_MS / 1000}s: ${url}`);
52
+ throw error;
53
+ });
42
54
  if (!res.ok) throw new Error(`download failed: ${res.status} ${res.statusText} for ${url}`);
43
55
  const bytes = Buffer.from(await res.arrayBuffer());
44
56
  fs.writeFileSync(dest, bytes);
@@ -52,6 +64,11 @@ function extractZip(zipPath, dir) {
52
64
  }
53
65
 
54
66
  async function ensureBinary() {
67
+ // The override comes first so platforms without a prebuilt binary (Linux,
68
+ // Windows on ARM) can still run a binary built from source.
69
+ const override = process.env.COMPUTER_USE_BINARY;
70
+ if (override) return override;
71
+
55
72
  const target = assetFor(process.platform, process.arch);
56
73
  if (!target) {
57
74
  console.error(
@@ -61,22 +78,40 @@ async function ensureBinary() {
61
78
  );
62
79
  process.exit(1);
63
80
  }
64
- const override = process.env.COMPUTER_USE_BINARY;
65
- if (override) return override;
66
81
 
67
82
  const dir = cacheDir();
68
83
  const binary = path.join(dir, target.binary);
69
84
  if (fs.existsSync(binary)) return binary;
70
85
 
71
- fs.mkdirSync(dir, { recursive: true });
72
- const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${target.asset}`;
73
- const zipPath = path.join(dir, target.asset);
74
- console.error(`munim-computer-use: downloading ${target.asset} (v${VERSION})…`);
75
- await download(url, zipPath);
76
- extractZip(zipPath, dir);
77
- fs.rmSync(zipPath, { force: true });
78
- if (!fs.existsSync(binary)) throw new Error(`archive did not contain ${target.binary}`);
79
- if (process.platform !== "win32") fs.chmodSync(binary, 0o755);
86
+ // Download and extract into a private staging directory, then rename it into
87
+ // place. A crash, a timeout or two MCP clients starting at once can then never
88
+ // leave a half-written binary in the cache that later runs would trust.
89
+ const parent = path.dirname(dir);
90
+ fs.mkdirSync(parent, { recursive: true });
91
+ const staging = fs.mkdtempSync(path.join(parent, `.${VERSION}-download-`));
92
+ try {
93
+ const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${target.asset}`;
94
+ const zipPath = path.join(staging, target.asset);
95
+ console.error(`munim-computer-use: downloading ${target.asset} (v${VERSION})…`);
96
+ await download(url, zipPath);
97
+ extractZip(zipPath, staging);
98
+ fs.rmSync(zipPath, { force: true });
99
+ const staged = path.join(staging, target.binary);
100
+ if (!fs.existsSync(staged)) throw new Error(`archive did not contain ${target.binary}`);
101
+ if (process.platform !== "win32") fs.chmodSync(staged, 0o755);
102
+ // A cache directory without the binary is debris from an older launcher
103
+ // that extracted in place and was interrupted; replace it.
104
+ if (fs.existsSync(dir) && !fs.existsSync(binary)) fs.rmSync(dir, { recursive: true, force: true });
105
+ try {
106
+ fs.renameSync(staging, dir);
107
+ } catch (error) {
108
+ // Another launcher finished first; its copy is just as good.
109
+ if (!fs.existsSync(binary)) throw error;
110
+ }
111
+ } finally {
112
+ fs.rmSync(staging, { recursive: true, force: true });
113
+ }
114
+ if (!fs.existsSync(binary)) throw new Error(`could not install ${target.binary} into ${dir}`);
80
115
  return binary;
81
116
  }
82
117
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "munim-computer-use",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Computer Use MCP server for any coding agent — accessibility-first desktop control on macOS, Windows and Linux, background input, agent pointer, zoom, your signed-in Chrome. Downloads the signed native binary from GitHub Releases on first run.",
5
5
  "keywords": [
6
6
  "accessibility",