mosey-browser 1.0.0 → 1.0.4
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/mosey +41 -4
- package/bin/postinstall.js +43 -0
- package/package.json +9 -1
- package/vendor/mosey +0 -0
package/bin/mosey
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Tiny launcher: exec the vendored compiled binary
|
|
3
|
-
|
|
2
|
+
// Tiny launcher: exec the vendored compiled binary, with a couple of UX wrappers:
|
|
3
|
+
// - `mosey install-deps` : download Chromium / run setup (recovery for postinstall failures)
|
|
4
|
+
// - intercepts stderr to translate "daemon failed to start" into an actionable hint
|
|
5
|
+
const { spawn, spawnSync } = require("child_process");
|
|
4
6
|
const path = require("path");
|
|
5
7
|
const fs = require("fs");
|
|
6
8
|
|
|
@@ -13,5 +15,40 @@ if (!fs.existsSync(bin)) {
|
|
|
13
15
|
process.exit(1);
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
+
const argv = process.argv.slice(2);
|
|
19
|
+
|
|
20
|
+
// Launcher-handled command: re-run the postinstall steps.
|
|
21
|
+
if (argv[0] === "install-deps" || argv[0] === "install") {
|
|
22
|
+
spawnSync(bin, ["setup"], { stdio: "inherit" });
|
|
23
|
+
console.log("Downloading Chromium (~170MB, one-time)…");
|
|
24
|
+
const r = spawnSync(bin, ["navigate", "about:blank"], { stdio: "inherit", timeout: 10 * 60_000 });
|
|
25
|
+
spawnSync(bin, ["stop"], { stdio: "ignore" });
|
|
26
|
+
if (r.status === 0) {
|
|
27
|
+
console.log("✓ Ready. Try: mosey https://example.com");
|
|
28
|
+
process.exit(0);
|
|
29
|
+
} else {
|
|
30
|
+
console.error("✗ Chromium download failed. Check network and try again.");
|
|
31
|
+
process.exit(r.status ?? 1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Normal path: spawn binary, capture stderr so we can translate known failure modes.
|
|
36
|
+
const child = spawn(bin, argv, { stdio: ["inherit", "inherit", "pipe"] });
|
|
37
|
+
|
|
38
|
+
let stderrBuf = "";
|
|
39
|
+
child.stderr.on("data", (chunk) => {
|
|
40
|
+
process.stderr.write(chunk);
|
|
41
|
+
stderrBuf += chunk.toString();
|
|
42
|
+
if (stderrBuf.length > 64 * 1024) stderrBuf = stderrBuf.slice(-32 * 1024);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
child.on("exit", (code) => {
|
|
46
|
+
if (code !== 0 && /daemon failed to start/i.test(stderrBuf)) {
|
|
47
|
+
process.stderr.write(
|
|
48
|
+
"\n[mosey] The daemon failed to start. This usually means Chromium isn't installed yet.\n" +
|
|
49
|
+
"[mosey] Fix: run `mosey install-deps` in a terminal (downloads Chromium ~170MB, one-time), then retry.\n" +
|
|
50
|
+
"[mosey] AI agent: ask the user to run `mosey install-deps` — do not retry the same command first.\n"
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
process.exit(code ?? 1);
|
|
54
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Postinstall: wire up CLAUDE.md and download Chromium so the first `mosey <url>` is instant.
|
|
3
|
+
// Best-effort: any failure here is non-fatal — the user can retry with `mosey install-deps`.
|
|
4
|
+
|
|
5
|
+
const { spawnSync } = require("node:child_process");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
const fs = require("node:fs");
|
|
8
|
+
|
|
9
|
+
const bin = path.join(
|
|
10
|
+
__dirname,
|
|
11
|
+
"..",
|
|
12
|
+
"vendor",
|
|
13
|
+
"mosey" + (process.platform === "win32" ? ".exe" : "")
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
if (!fs.existsSync(bin)) {
|
|
17
|
+
// Binary missing for this platform — silent exit, the bin/mosey launcher will print a clear error later.
|
|
18
|
+
process.exit(0);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
console.log("\n ✓ mosey-browser installed.");
|
|
22
|
+
|
|
23
|
+
// 1. CLAUDE.md wire-up (idempotent — safe to re-run on every install).
|
|
24
|
+
spawnSync(bin, ["setup"], { stdio: "inherit" });
|
|
25
|
+
|
|
26
|
+
// 2. Trigger Chromium download by starting the daemon once against about:blank.
|
|
27
|
+
// Playwright's chromium download is the slow step; daemon startup itself is <1s once Chromium is present.
|
|
28
|
+
console.log(" Downloading Chromium for first run (~170MB, one-time)…");
|
|
29
|
+
const navRes = spawnSync(bin, ["navigate", "about:blank"], {
|
|
30
|
+
stdio: "inherit",
|
|
31
|
+
// generous timeout: cold Playwright Chromium download can take a few minutes on slow links
|
|
32
|
+
timeout: 10 * 60_000,
|
|
33
|
+
});
|
|
34
|
+
spawnSync(bin, ["stop"], { stdio: "ignore" });
|
|
35
|
+
|
|
36
|
+
if (navRes.status === 0) {
|
|
37
|
+
console.log(" ✓ Ready. Try: mosey https://example.com\n");
|
|
38
|
+
} else {
|
|
39
|
+
console.log(
|
|
40
|
+
" ⚠ Chromium not downloaded (network/timeout). Run `mosey install-deps` to retry.\n"
|
|
41
|
+
);
|
|
42
|
+
// Don't fail the npm install for this — user can recover later.
|
|
43
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mosey-browser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Web CLI for AI agents — navigate and interact with pages via snapshots",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
7
7
|
"bin": {
|
|
8
8
|
"mosey": "./bin/mosey"
|
|
9
9
|
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"postinstall": "node ./bin/postinstall.js"
|
|
12
|
+
},
|
|
10
13
|
"files": [
|
|
11
14
|
"bin",
|
|
12
15
|
"vendor",
|
|
@@ -26,6 +29,11 @@
|
|
|
26
29
|
"cpu": [
|
|
27
30
|
"arm64"
|
|
28
31
|
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"commander": "^14.0.3",
|
|
34
|
+
"mosey-browser": "^1.0.1",
|
|
35
|
+
"patchright": "^1.52.0"
|
|
36
|
+
},
|
|
29
37
|
"devDependencies": {
|
|
30
38
|
"@types/bun": "^1.3.0",
|
|
31
39
|
"@types/node": "^25.6.0",
|
package/vendor/mosey
CHANGED
|
Binary file
|