esp32agent 0.0.0-stage → 0.1.1
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/bin/esp32agent.js +12 -0
- package/install.js +53 -0
- package/package.json +13 -4
- package/README.md +0 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Runs the binary install.js put next to this file.
|
|
3
|
+
const { spawnSync } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const exe = path.join(__dirname, process.platform === "win32" ? "esp32agent.exe" : "esp32agent");
|
|
7
|
+
const r = spawnSync(exe, process.argv.slice(2), { stdio: "inherit" });
|
|
8
|
+
if (r.error) {
|
|
9
|
+
console.error(`esp32agent: ${r.error.message} (reinstall: npm install -g esp32agent)`);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
process.exit(r.status ?? 1);
|
package/install.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// postinstall: downloads the esp32agent binary (binaryVersion, else this package's version) from GitHub Releases and checks its
|
|
2
|
+
// SHA-256 against checksums.txt. ESP32AGENT_ARCHIVE=/path installs a local build (checksums.txt next to it).
|
|
3
|
+
const { createHash } = require("crypto");
|
|
4
|
+
const { execFileSync } = require("child_process");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const os = require("os");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
|
|
9
|
+
const pkg = require("./package.json");
|
|
10
|
+
const version = pkg.binaryVersion || pkg.version; // a metadata-only npm release reuses the last binaries
|
|
11
|
+
const goos = { darwin: "darwin", linux: "linux", win32: "windows" }[process.platform];
|
|
12
|
+
const goarch = { x64: "amd64", arm64: "arm64" }[process.arch];
|
|
13
|
+
if (!goos || !goarch) throw new Error(`esp32agent: unsupported platform ${process.platform}/${process.arch}`);
|
|
14
|
+
const name = `esp32agent_${goos}_${goarch}.${goos === "windows" ? "zip" : "tar.gz"}`;
|
|
15
|
+
const base = `https://github.com/onehumanbeing/esp32-iphone-agent/releases/download/cli-v${version}`;
|
|
16
|
+
|
|
17
|
+
async function fetchBytes(url) {
|
|
18
|
+
const res = await fetch(url);
|
|
19
|
+
if (!res.ok) throw new Error(`esp32agent: download failed (${res.status}): ${url}`);
|
|
20
|
+
return Buffer.from(await res.arrayBuffer());
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function main() {
|
|
24
|
+
const local = process.env.ESP32AGENT_ARCHIVE;
|
|
25
|
+
const archive = local ? fs.readFileSync(local) : await fetchBytes(`${base}/${name}`);
|
|
26
|
+
const sums = local
|
|
27
|
+
? fs.readFileSync(process.env.ESP32AGENT_CHECKSUMS || path.join(path.dirname(local), "checksums.txt"), "utf8")
|
|
28
|
+
: (await fetchBytes(`${base}/checksums.txt`)).toString("utf8");
|
|
29
|
+
const line = sums.split("\n").find((l) => [name, `*${name}`].includes(l.trim().split(/\s+/)[1]));
|
|
30
|
+
if (!line) throw new Error(`esp32agent: ${name} is not in checksums.txt`);
|
|
31
|
+
const got = createHash("sha256").update(archive).digest("hex");
|
|
32
|
+
if (line.trim().split(/\s+/)[0].toLowerCase() !== got) throw new Error(`esp32agent: checksum mismatch for ${name}`);
|
|
33
|
+
|
|
34
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "esp32agent-"));
|
|
35
|
+
const file = path.join(tmp, name);
|
|
36
|
+
fs.writeFileSync(file, archive);
|
|
37
|
+
execFileSync("tar", ["-xf", file, "-C", tmp]); // bsdtar on Windows 10+ reads zip too
|
|
38
|
+
const exe = goos === "windows" ? "esp32agent.exe" : "esp32agent";
|
|
39
|
+
const dest = path.join(__dirname, "bin", exe);
|
|
40
|
+
fs.copyFileSync(path.join(tmp, exe), dest);
|
|
41
|
+
fs.chmodSync(dest, 0o755);
|
|
42
|
+
fs.rmSync(tmp, { recursive: true, force: true });
|
|
43
|
+
try {
|
|
44
|
+
execFileSync("ffmpeg", ["-version"], { stdio: "ignore" });
|
|
45
|
+
} catch {
|
|
46
|
+
console.warn("esp32agent: ffmpeg not found; install it for screenshots (brew/apt/dnf install ffmpeg, winget install Gyan.FFmpeg)");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
main().catch((e) => {
|
|
51
|
+
console.error(e.message);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esp32agent",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"mcpName": "io.github.onehumanbeing/esp32agent",
|
|
5
|
+
"binaryVersion": "0.1.0",
|
|
6
|
+
"description": "See and drive an iPhone through an ESP32 Agent board over Bluetooth (CLI + MCP server for coding agents)",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": { "type": "git", "url": "git+https://github.com/onehumanbeing/esp32-iphone-agent.git", "directory": "cli" },
|
|
9
|
+
"bin": { "esp32agent": "bin/esp32agent.js" },
|
|
10
|
+
"scripts": { "postinstall": "node install.js" },
|
|
11
|
+
"files": ["bin/esp32agent.js", "install.js"],
|
|
12
|
+
"os": ["darwin", "linux", "win32"],
|
|
13
|
+
"cpu": ["x64", "arm64"],
|
|
14
|
+
"engines": { "node": ">=18" }
|
|
15
|
+
}
|
package/README.md
DELETED