mainplane 0.5.8 → 0.5.11

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
+ 70a78da611805e2abc434021ae2e165640543281d8c8790d6e37fbeedf21a2cf CHANGELOG.md
2
+ 1d175cae9f8552ff51711d3151fcc0c891c4f781ad8e1a200b5e9f56cfaec453 THIRD_PARTY_NOTICES
3
+ 9dc6997b78f540ce215639206289ea190afd00d87caf698c20f139b1df357655 install.ps1
4
+ bd64ec1d4ec26bb941edffe460f752d1f473924d8633618396ec6e02f1798ee6 install.sh
5
+ 5f1c630b4b011d64a0d13956c67b9e652629e752b24ead399715fa29d9b1b722 mainplane-darwin-amd64
6
+ 879e36f7ed79f3ffb63de906ea74c44e076223699fbc4c8ac709f18ed700a276 mainplane-darwin-arm64
7
+ d2833f95c6df01258b3a0c8a8375b7d4688511d9d46705c54b9f9ab9f16419bc mainplane-linux-amd64
8
+ 16bb848bbea76dfd7f2182228146b7f900b018c7a934f3932bfccdfc84ae602f mainplane-linux-arm64
9
+ f454dc9718bb064715048b64425b5dd723ce20ab7b0d475aad144e2e5bd8616b mainplane-server-darwin-amd64
10
+ 92e2004c5afaeaa021326a1074e8011bf9d4799a5045bf48c0e655a32977cf0c mainplane-server-darwin-arm64
11
+ 293c39899994b170211273ea210f6518248ee792260034b4810a4ae4d2f0bfa0 mainplane-server-linux-amd64
12
+ 2afbbd92933b2734d9626d451df2b106a51a8b8950a2f3b7649be43740069f5a mainplane-server-linux-arm64
13
+ 00c2ea69c2b41ee4a29c2a6106e40c3c6f57b02dedbb97f9bba22858d47b5444 mainplane-server-windows-amd64.exe
14
+ 501d439d542df6a13dd57aa1b193f7cee066a581e26d5d965570d4487ccc978d mainplane-server-windows-arm64.exe
15
+ 2039e00d8d077418a74183893c4adb12bae6e460a22bcd60ecbaba4475f6828a mainplane-windows-amd64.exe
16
+ 120583605398071bd825d8169757aceb52a01a8c9d14f351a4b31fb77c3dd553 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.11",
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": {