mainplane 0.5.8 → 0.5.10

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 (3) hide show
  1. package/SHA256SUMS +16 -16
  2. package/mainplane.js +16 -6
  3. package/package.json +1 -1
package/SHA256SUMS CHANGED
@@ -1,16 +1,16 @@
1
- f0d873b7d15b3619220ebee9cdda5d2aa949d808785a0126266b3f9d454bcdc3 CHANGELOG.md
2
- 416f0fd1e7c0cc10a0dda91af08a552427e7eb8c049fea557eddb0256191ef2a THIRD_PARTY_NOTICES
3
- 642fdd7c998069dca1b0a9d64d59f012ff68b7bb290f00482d1b7aef13ec76ac install.ps1
4
- 528738d39a2a00c53d07f0f121b346d70cade361f8947a1789d2c68f6bf37739 install.sh
5
- bf9b79c2f3ced86064cb147e990996efd168c74bf41d0be2b7325abb3d021c8f mainplane-darwin-amd64
6
- 10ee6ffcb10e8913a0d4bf3d03878d01b9fb986f7c93e0ea1fa670bd21a15667 mainplane-darwin-arm64
7
- 3118c2791d4ad2462e1c15f23b200beed97c8415ea2cf9fb300009f244aadec8 mainplane-linux-amd64
8
- 4d1ca60b708c3774c490470419135aaae9ce903ed06d09f1913e59b221c99f75 mainplane-linux-arm64
9
- 2b2c48ac138c7d1c90001bddc16cd4bbf68bc6de0f70c43c42b8950c93bb896b mainplane-server-darwin-amd64
10
- 2bd945795bbabaea1ea32d8a9d2a79500c03578bc71779d154d0a0c640ad08d6 mainplane-server-darwin-arm64
11
- 84b24ba0ace69d1ffa8c47257ec1e261473b4561b17e40481a5a983a17353f1f mainplane-server-linux-amd64
12
- 7548ccc1b31a8f173968a1b959c9986e9dc5bddce86b19274af0797a82e110e0 mainplane-server-linux-arm64
13
- 1bcdc698e1654aab13ef4f9ecac85bc95e44062c3da88c16d7aebb0808e808e4 mainplane-server-windows-amd64.exe
14
- 2bfa50f137e41b59dd44ece39dd1d4883f0db2de6cb28ba418dcd39d9503e845 mainplane-server-windows-arm64.exe
15
- d430a12ccd4a66fa1b0f4868a38c9e62bf428b966b6c76e5275de3df6471d1f0 mainplane-windows-amd64.exe
16
- a3727a82a1d1a6f4885cebfefdf7338178a15879a2a6c13870150453a4eafdb5 mainplane-windows-arm64.exe
1
+ c602cf40f04fb578e148373c0f20fd2bdc649679dbbbeaadde1957b3b6a2cf86 CHANGELOG.md
2
+ 1d175cae9f8552ff51711d3151fcc0c891c4f781ad8e1a200b5e9f56cfaec453 THIRD_PARTY_NOTICES
3
+ f303b9a1e3a1362baa38127d92869d19a7e928f1a3184c8378e055a3281fa766 install.ps1
4
+ 7851d86d3cec6b5acf6cc8c108f4ee864cc6522b28675e780068573439117dc2 install.sh
5
+ 296c88d2abdf9562bd8020687b83b35bb424e7e862013e2c003cd866c84bd800 mainplane-darwin-amd64
6
+ c89cc62a13dbc004a52fc3f64ed81ef6d1ca7320873471736cd5a1322d840745 mainplane-darwin-arm64
7
+ 59ac34cb4d7515faa18465ee28541aa84044521f223fa74d01084fe4456a6ea7 mainplane-linux-amd64
8
+ 0ab763fd57f73c908c23caf796b84546bb3fb03d9cde1d841f1081e6c42a8a7e mainplane-linux-arm64
9
+ 5022fab5b59254660cb5be8df50be9a0ee769306521d4cfd8e87b63ad46b2031 mainplane-server-darwin-amd64
10
+ 12186e5cdaaa70ab278137eb412d53b93293956be1fb0adfb741d559a58ae2a5 mainplane-server-darwin-arm64
11
+ 337e467edd4967e106b5e10034389b41f0fe84f90af49d2cdf261332e2f41cc2 mainplane-server-linux-amd64
12
+ 1eea47d94bb6511e63ffa842e9e9b03089c6caac5f49163f74ee77e44b9d7e51 mainplane-server-linux-arm64
13
+ cb33d87414d95ddbad5b0cc70290d8071f1c7ecdc1902ac653bfb781a9a597a0 mainplane-server-windows-amd64.exe
14
+ 05dfc22979109eec3a738e28b8456a8f27307dbf4bc9bfdbdc7a90e19881a3f9 mainplane-server-windows-arm64.exe
15
+ 4fb337cc1f12f78b13dddca353f277ebabedd6a8d381146170ed4319864a2228 mainplane-windows-amd64.exe
16
+ 84c166b9018dc3012f0c2dea13dd0c87fbc24fabd5784c6628bc42b38105de0e mainplane-windows-arm64.exe
package/mainplane.js CHANGED
@@ -19,16 +19,26 @@ async function main() {
19
19
  goos === "windows" ? process.env.LOCALAPPDATA
20
20
  : goos === "darwin" ? path.join(os.homedir(), "Library", "Caches")
21
21
  : process.env.XDG_CACHE_HOME || path.join(os.homedir(), ".cache");
22
- const bin = path.join(cache, "mainplane", v, goos === "windows" ? "mainplane.exe" : "mainplane");
23
- if (!fs.existsSync(bin)) {
22
+ const bin = path.join(cache, "mainplane", v, `${goos}-${arch}`, goos === "windows" ? "mainplane.exe" : "mainplane");
23
+ const sum = line.split(" ")[0];
24
+ const hash = (b) => createHash("sha256").update(b).digest("hex");
25
+ if (!fs.existsSync(bin) || hash(fs.readFileSync(bin)) !== sum) {
24
26
  const url = `https://dl.mainplane.ai/${v}/${name}`;
25
- const res = await fetch(url);
27
+ const res = await fetch(url, { signal: AbortSignal.timeout(300000) });
26
28
  if (!res.ok) throw new Error(`${url}: ${res.status}`);
27
29
  const b = Buffer.from(await res.arrayBuffer());
28
- if (createHash("sha256").update(b).digest("hex") !== line.split(" ")[0]) throw new Error(`${url} does not match SHA256SUMS`);
30
+ if (hash(b) !== sum) throw new Error(`${url} does not match SHA256SUMS`);
29
31
  fs.mkdirSync(path.dirname(bin), { recursive: true });
30
- fs.writeFileSync(bin + ".tmp", b, { mode: 0o755 });
31
- fs.renameSync(bin + ".tmp", bin);
32
+ // A temporary file per process, since first runs may race; the loser keeps the winner's identical file.
33
+ const tmp = `${bin}.${process.pid}`;
34
+ fs.writeFileSync(tmp, b);
35
+ fs.chmodSync(tmp, 0o755);
36
+ try {
37
+ fs.renameSync(tmp, bin);
38
+ } catch (e) {
39
+ fs.rmSync(tmp);
40
+ if (!fs.existsSync(bin) || hash(fs.readFileSync(bin)) !== sum) throw e;
41
+ }
32
42
  }
33
43
  const r = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
34
44
  if (r.error) throw r.error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mainplane",
3
- "version": "0.5.8",
3
+ "version": "0.5.10",
4
4
  "description": "The open-source agent ecosystem. Agents that work across all your computers, browsers and files.",
5
5
  "homepage": "https://mainplane.ai",
6
6
  "repository": {