pagerunner 0.2.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.
Files changed (3) hide show
  1. package/install.js +96 -0
  2. package/package.json +36 -0
  3. package/run.js +13 -0
package/install.js ADDED
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { createHash } = require("crypto");
5
+ const { createWriteStream, chmodSync, existsSync, mkdirSync } = require("fs");
6
+ const { get } = require("https");
7
+ const { join } = require("path");
8
+ const { pipeline } = require("stream/promises");
9
+
10
+ const VERSION = "0.2.0";
11
+ const REPO = "Enreign/pagerunner";
12
+
13
+ const PLATFORMS = {
14
+ "darwin-arm64": "pagerunner-macos-arm64",
15
+ "darwin-x64": "pagerunner-macos-x86_64",
16
+ "linux-x64": "pagerunner-linux-x86_64",
17
+ };
18
+
19
+ function getPlatformAsset() {
20
+ const key = `${process.platform}-${process.arch}`;
21
+ const asset = PLATFORMS[key];
22
+ if (!asset) {
23
+ console.error(
24
+ `Unsupported platform: ${key}. Supported: ${Object.keys(PLATFORMS).join(", ")}`
25
+ );
26
+ process.exit(1);
27
+ }
28
+ return asset;
29
+ }
30
+
31
+ function download(url) {
32
+ return new Promise((resolve, reject) => {
33
+ get(url, (res) => {
34
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
35
+ return download(res.headers.location).then(resolve, reject);
36
+ }
37
+ if (res.statusCode !== 200) {
38
+ return reject(new Error(`HTTP ${res.statusCode} for ${url}`));
39
+ }
40
+ resolve(res);
41
+ }).on("error", reject);
42
+ });
43
+ }
44
+
45
+ async function fetchText(url) {
46
+ const res = await download(url);
47
+ const chunks = [];
48
+ for await (const chunk of res) chunks.push(chunk);
49
+ return Buffer.concat(chunks).toString("utf8").trim();
50
+ }
51
+
52
+ async function main() {
53
+ const asset = getPlatformAsset();
54
+ const baseUrl = `https://github.com/${REPO}/releases/download/v${VERSION}`;
55
+ const binDir = join(__dirname, "bin");
56
+ const binPath = join(binDir, "pagerunner");
57
+
58
+ if (existsSync(binPath)) {
59
+ console.log("pagerunner binary already installed.");
60
+ return;
61
+ }
62
+
63
+ // Fetch expected SHA256
64
+ const shaLine = await fetchText(`${baseUrl}/${asset}.sha256`);
65
+ const expectedHash = shaLine.split(/\s+/)[0];
66
+
67
+ // Download binary
68
+ console.log(`Downloading ${asset} v${VERSION}...`);
69
+ const res = await download(`${baseUrl}/${asset}`);
70
+
71
+ mkdirSync(binDir, { recursive: true });
72
+ const tmpPath = `${binPath}.tmp`;
73
+ await pipeline(res, createWriteStream(tmpPath));
74
+
75
+ // Verify SHA256
76
+ const { readFileSync, renameSync, unlinkSync } = require("fs");
77
+ const fileBuffer = readFileSync(tmpPath);
78
+ const actualHash = createHash("sha256").update(fileBuffer).digest("hex");
79
+
80
+ if (actualHash !== expectedHash) {
81
+ unlinkSync(tmpPath);
82
+ console.error(
83
+ `SHA256 mismatch!\n Expected: ${expectedHash}\n Actual: ${actualHash}`
84
+ );
85
+ process.exit(1);
86
+ }
87
+
88
+ renameSync(tmpPath, binPath);
89
+ chmodSync(binPath, 0o755);
90
+ console.log(`pagerunner v${VERSION} installed successfully.`);
91
+ }
92
+
93
+ main().catch((err) => {
94
+ console.error(`Failed to install pagerunner: ${err.message}`);
95
+ process.exit(1);
96
+ });
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "pagerunner",
3
+ "version": "0.2.0",
4
+ "description": "Chrome browser automation MCP server for AI agents — drives real Chrome with your profiles",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/Enreign/pagerunner.git",
9
+ "directory": "npm"
10
+ },
11
+ "homepage": "https://github.com/Enreign/pagerunner",
12
+ "author": "Enreign",
13
+ "bin": {
14
+ "pagerunner": "run.js"
15
+ },
16
+ "scripts": {
17
+ "postinstall": "node install.js"
18
+ },
19
+ "keywords": [
20
+ "mcp",
21
+ "browser",
22
+ "automation",
23
+ "chrome",
24
+ "ai",
25
+ "cdp",
26
+ "web-scraping"
27
+ ],
28
+ "files": [
29
+ "install.js",
30
+ "run.js"
31
+ ],
32
+ "engines": {
33
+ "node": ">=16"
34
+ },
35
+ "mcpName": "io.github.Enreign/pagerunner"
36
+ }
package/run.js ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { execFileSync } = require("child_process");
5
+ const { join } = require("path");
6
+
7
+ const bin = join(__dirname, "bin", "pagerunner");
8
+
9
+ try {
10
+ execFileSync(bin, process.argv.slice(2), { stdio: "inherit" });
11
+ } catch (err) {
12
+ process.exit(err.status || 1);
13
+ }