@brokkai/mjolnir 1.5.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.
Files changed (3) hide show
  1. package/README.md +13 -0
  2. package/bin/mj.js +100 -0
  3. package/package.json +31 -0
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # Mjolnir
2
+
3
+ Mjolnir is the self-hosted power frontend for Codex and other ACP agents.
4
+
5
+ ```sh
6
+ npm install -g @brokkai/mjolnir
7
+ mj
8
+ ```
9
+
10
+ For a one-shot run, use `npx -y @brokkai/mjolnir`. The package installs the
11
+ native release bundle for the current platform; it does not download Mjolnir at
12
+ first launch. See https://mjolnir.brokk.ai/install/ for supported platforms,
13
+ updates, and alternatives.
package/bin/mj.js ADDED
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { createRequire } from "node:module";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { spawn } from "node:child_process";
7
+
8
+ const require = createRequire(import.meta.url);
9
+
10
+ export function platformPackageName(platform = process.platform, arch = process.arch) {
11
+ if (platform === "darwin" && (arch === "arm64" || arch === "x64")) {
12
+ return "@brokkai/mjolnir-darwin-universal";
13
+ }
14
+ if (platform === "linux" && arch === "x64") {
15
+ return "@brokkai/mjolnir-linux-x64-gnu";
16
+ }
17
+ if (platform === "linux" && arch === "arm64") {
18
+ return "@brokkai/mjolnir-linux-arm64-gnu";
19
+ }
20
+ if (platform === "android" && arch === "arm64") {
21
+ return "@brokkai/mjolnir-android-arm64";
22
+ }
23
+ if (platform === "win32" && arch === "x64") {
24
+ return "@brokkai/mjolnir-win32-x64";
25
+ }
26
+ throw new Error(`Mjolnir does not publish an npm bundle for ${platform}/${arch}.`);
27
+ }
28
+
29
+ export function resolveBundle(resolve = require.resolve, platform = process.platform, arch = process.arch) {
30
+ const packageName = platformPackageName(platform, arch);
31
+ try {
32
+ return path.dirname(resolve(`${packageName}/package.json`));
33
+ } catch (error) {
34
+ throw new Error(
35
+ `The ${packageName} native bundle was not installed. Reinstall @brokkai/mjolnir for ${platform}/${arch}.`,
36
+ { cause: error },
37
+ );
38
+ }
39
+ }
40
+
41
+ export function nativeBinaryPath(bundleRoot, platform = process.platform) {
42
+ return path.join(bundleRoot, "bin", platform === "win32" ? "mj.exe" : "mj");
43
+ }
44
+
45
+ const SIGNAL_EXIT_CODES = {
46
+ SIGHUP: 129,
47
+ SIGINT: 130,
48
+ SIGTERM: 143,
49
+ };
50
+
51
+ export function launch(
52
+ bundleRoot,
53
+ args,
54
+ platform = process.platform,
55
+ spawnProcess = spawn,
56
+ exitProcess = process.exit,
57
+ ) {
58
+ const bundleBin = path.join(bundleRoot, "bin");
59
+ const child = spawnProcess(nativeBinaryPath(bundleRoot, platform), args, {
60
+ stdio: "inherit",
61
+ env: {
62
+ ...process.env,
63
+ PATH: `${bundleBin}${path.delimiter}${process.env.PATH ?? ""}`,
64
+ // npm owns upgrades. Replacing files under node_modules would corrupt its
65
+ // package database and can leave sibling binaries at different versions.
66
+ MJOLNIR_NO_UPDATE_CHECK: "1",
67
+ },
68
+ });
69
+
70
+ const signalHandlers = new Map();
71
+ for (const signal of Object.keys(SIGNAL_EXIT_CODES)) {
72
+ const handler = () => child.kill(signal);
73
+ signalHandlers.set(signal, handler);
74
+ process.on(signal, handler);
75
+ }
76
+ const removeSignalHandlers = () => {
77
+ for (const [signal, handler] of signalHandlers) process.off(signal, handler);
78
+ };
79
+ child.on("error", (error) => {
80
+ removeSignalHandlers();
81
+ console.error(`mj: could not start native bundle: ${error.message}`);
82
+ process.exitCode = 1;
83
+ });
84
+ child.on("exit", (code, signal) => {
85
+ removeSignalHandlers();
86
+ if (signal) {
87
+ exitProcess(SIGNAL_EXIT_CODES[signal] ?? 1);
88
+ return;
89
+ }
90
+ process.exitCode = code ?? 1;
91
+ });
92
+ }
93
+
94
+ function main() {
95
+ launch(resolveBundle(), process.argv.slice(2));
96
+ }
97
+
98
+ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
99
+ main();
100
+ }
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@brokkai/mjolnir",
3
+ "version": "1.5.1",
4
+ "description": "Mjolnir terminal client for Agent Client Protocol servers",
5
+ "license": "GPL-3.0-only",
6
+ "repository": "https://github.com/BrokkAi/mjolnir",
7
+ "homepage": "https://mjolnir.brokk.ai/",
8
+ "bugs": "https://github.com/BrokkAi/mjolnir/issues",
9
+ "type": "module",
10
+ "bin": {
11
+ "mj": "bin/mj.js"
12
+ },
13
+ "files": [
14
+ "bin/",
15
+ "README.md",
16
+ "LICENSE"
17
+ ],
18
+ "optionalDependencies": {
19
+ "@brokkai/mjolnir-darwin-universal": "1.5.1",
20
+ "@brokkai/mjolnir-linux-x64-gnu": "1.5.1",
21
+ "@brokkai/mjolnir-linux-arm64-gnu": "1.5.1",
22
+ "@brokkai/mjolnir-android-arm64": "1.5.1",
23
+ "@brokkai/mjolnir-win32-x64": "1.5.1"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "engines": {
29
+ "node": ">=18"
30
+ }
31
+ }