nunmai 0.1.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/README.md +25 -0
  2. package/bin/nunmai.js +147 -0
  3. package/package.json +47 -0
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # nunmai
2
+
3
+ Install [Nunmai Engine](https://nunmai.in) with npm — everything included.
4
+
5
+ ```bash
6
+ npm install -g nunmai
7
+ nunmai
8
+ ```
9
+
10
+ `npm install` runs the official installer (https://nunmai-engine.nunmai.in) in
11
+ **full, non-interactive** mode: the engine, Python, git, Node.js, browser and
12
+ computer-use tools are all provisioned automatically into Nunmai's own
13
+ directories — your system toolchain is never modified. Then `nunmai` starts the
14
+ engine; the first run opens the AI-account wizard (Claude, ChatGPT, Kimi,
15
+ Gemini, OpenRouter).
16
+
17
+ - macOS, Linux, Windows 10/11 (PowerShell), Android (Termux). `npx nunmai` works too.
18
+ - If npm ran with `--ignore-scripts` (or `CI` is set), the install happens on the
19
+ first `nunmai` run instead.
20
+ - Lightweight install (no browser/computer-use): `NUNMAI_INSTALL_LITE=1 npm i -g nunmai`.
21
+ - Extra installer flags: `NUNMAI_INSTALL_ARGS="--branch dev" npm i -g nunmai`.
22
+ - Updates: `nunmai update`. Remove: `nunmai uninstall`, then `npm uninstall -g nunmai`.
23
+
24
+ This package only contains the launcher; the engine's source lives at
25
+ https://github.com/Nunmai-Private-Limited/nunmai-engine.
package/bin/nunmai.js ADDED
@@ -0,0 +1,147 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /*
4
+ * npm bootstrap for Nunmai Engine.
5
+ *
6
+ * Nunmai Engine is a Python application (managed by uv), so this package is a
7
+ * small launcher around the official installer (https://nunmai-engine.nunmai.in):
8
+ *
9
+ * npm install -g nunmai -> postinstall runs the FULL, non-interactive install
10
+ * (engine, Python, git, Node, browser + computer-use
11
+ * tools). Nothing on the system is modified — every
12
+ * dependency is provisioned into Nunmai's own dirs.
13
+ * nunmai -> launches the installed engine (first run opens the
14
+ * AI-account wizard). If the engine is missing (e.g.
15
+ * npm ran with --ignore-scripts), it installs first.
16
+ *
17
+ * NUNMAI_HOME respected (Windows launchers: %NUNMAI_HOME%\bin)
18
+ * NUNMAI_INSTALL_LITE=1 lightweight install instead of --full
19
+ * NUNMAI_INSTALL_ARGS="..." extra installer flags (appended)
20
+ * NUNMAI_NPM_NO_POSTINSTALL=1 skip the install at `npm install` time
21
+ * NUNMAI_BOOTSTRAP_DRY_RUN=1 print what would run instead of installing
22
+ */
23
+ const fs = require("fs");
24
+ const os = require("os");
25
+ const path = require("path");
26
+ const { spawnSync } = require("child_process");
27
+
28
+ const INSTALL_SH = "https://nunmai-engine.nunmai.in/install.sh";
29
+ const INSTALL_PS1 = "https://nunmai-engine.nunmai.in/install.ps1";
30
+ const IS_WIN = process.platform === "win32";
31
+ const SELF = fs.realpathSync(__filename);
32
+ const DRY = process.env.NUNMAI_BOOTSTRAP_DRY_RUN === "1";
33
+
34
+ function candidates() {
35
+ const home = os.homedir();
36
+ if (IS_WIN) {
37
+ const nunmaiHome = process.env.NUNMAI_HOME || path.join(process.env.LOCALAPPDATA || path.join(home, "AppData", "Local"), "nunmai");
38
+ const bin = path.join(nunmaiHome, "bin");
39
+ return [path.join(bin, "nunmai.exe"), path.join(bin, "nunmai.cmd")];
40
+ }
41
+ const list = [];
42
+ if (process.env.PREFIX && fs.existsSync(path.join(process.env.PREFIX, "bin"))) {
43
+ list.push(path.join(process.env.PREFIX, "bin", "nunmai")); // Termux
44
+ }
45
+ list.push(path.join(home, ".local", "bin", "nunmai"), "/usr/local/bin/nunmai");
46
+ return list;
47
+ }
48
+
49
+ function findLauncher() {
50
+ for (const p of candidates()) {
51
+ try {
52
+ if (fs.realpathSync(p) === SELF) continue; // never recurse into this shim
53
+ fs.accessSync(p, fs.constants.X_OK);
54
+ return p;
55
+ } catch (_) { /* not there */ }
56
+ }
57
+ return null;
58
+ }
59
+
60
+ function run(cmd, args, opts) {
61
+ const env = Object.assign({}, process.env, { NUNMAI_NPM_SHIM: "1" });
62
+ const r = spawnSync(cmd, args, Object.assign({ stdio: "inherit", env }, opts || {}));
63
+ if (r.error) {
64
+ console.error(`nunmai: could not start ${cmd}: ${r.error.message}`);
65
+ return 127;
66
+ }
67
+ return r.status == null ? 1 : r.status;
68
+ }
69
+
70
+ function installerFlags(nonInteractive) {
71
+ const flags = [];
72
+ if (process.env.NUNMAI_INSTALL_LITE !== "1") flags.push(IS_WIN ? "-Full" : "--full");
73
+ if (nonInteractive) flags.push(IS_WIN ? "-NonInteractive" : "--non-interactive", IS_WIN ? "-SkipSetup" : "--skip-setup");
74
+ const extra = (process.env.NUNMAI_INSTALL_ARGS || "").trim();
75
+ if (extra) flags.push(extra);
76
+ return flags.join(" ");
77
+ }
78
+
79
+ function install(nonInteractive) {
80
+ const flags = installerFlags(nonInteractive);
81
+ let cmd, args, shown;
82
+ if (IS_WIN) {
83
+ const ps = `& ([scriptblock]::Create((irm ${INSTALL_PS1}))) ${flags}`.trim();
84
+ cmd = "powershell";
85
+ args = ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", ps];
86
+ shown = `powershell -NoProfile -ExecutionPolicy Bypass -Command "${ps}"`;
87
+ } else {
88
+ const sh = `curl -fsSL ${INSTALL_SH} | bash -s -- ${flags}`.trim();
89
+ cmd = "bash";
90
+ args = ["-c", sh];
91
+ shown = sh;
92
+ }
93
+ console.log(nonInteractive
94
+ ? "Installing Nunmai Engine and all of its dependencies (this can take a few minutes)…"
95
+ : "Nunmai Engine is not installed on this machine yet — installing it now.");
96
+ console.log(` ${shown}\n`);
97
+ if (DRY) return 0;
98
+ return run(cmd, args);
99
+ }
100
+
101
+ function manualHint() {
102
+ return IS_WIN ? ` irm ${INSTALL_PS1} | iex` : ` curl -fsSL ${INSTALL_SH} | bash`;
103
+ }
104
+
105
+ function postinstall() {
106
+ // Runs from `npm install -g nunmai`. Must never fail the npm install: on any
107
+ // problem we exit 0 and the first `nunmai` run retries interactively.
108
+ if (process.env.NUNMAI_NPM_NO_POSTINSTALL === "1" || process.env.CI) {
109
+ console.log("nunmai: engine install deferred to first run.");
110
+ return 0;
111
+ }
112
+ if (findLauncher()) {
113
+ console.log("nunmai: engine already installed — run `nunmai` to start.");
114
+ return 0;
115
+ }
116
+ const code = install(true);
117
+ if (code !== 0) {
118
+ console.error(`\nnunmai: installer exited with code ${code}. Run \`nunmai\` to retry, or install manually:\n${manualHint()}`);
119
+ return 0;
120
+ }
121
+ console.log("\n✓ Nunmai Engine installed. Open a new terminal and run: nunmai");
122
+ return 0;
123
+ }
124
+
125
+ function main() {
126
+ const argv = process.argv.slice(2);
127
+ if (argv[0] === "--bootstrap-postinstall") process.exit(postinstall());
128
+
129
+ let launcher = findLauncher();
130
+ if (!launcher) {
131
+ const code = install(false);
132
+ if (code !== 0) {
133
+ console.error(`\nnunmai: installer exited with code ${code}. You can retry it manually:\n${manualHint()}`);
134
+ process.exit(code);
135
+ }
136
+ if (DRY) process.exit(0);
137
+ launcher = findLauncher();
138
+ if (!launcher) {
139
+ console.error("nunmai: install finished but the launcher was not found. Open a new terminal and run `nunmai`.");
140
+ process.exit(1);
141
+ }
142
+ if (argv.length === 0) console.log("\nInstalled. Starting Nunmai Engine…\n");
143
+ }
144
+ process.exit(run(launcher, argv, IS_WIN && launcher.endsWith(".cmd") ? { shell: true } : {}));
145
+ }
146
+
147
+ main();
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "nunmai",
3
+ "version": "0.1.0",
4
+ "description": "Nunmai Engine — `npm i -g nunmai` installs the engine with all features and dependencies; run `nunmai` to start.",
5
+ "license": "MIT",
6
+ "homepage": "https://nunmai.in",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/Nunmai-Private-Limited/nunmai-engine.git",
10
+ "directory": "deploy/npm-bootstrap"
11
+ },
12
+ "bugs": "https://github.com/Nunmai-Private-Limited/nunmai-engine/issues",
13
+ "keywords": [
14
+ "nunmai",
15
+ "ai",
16
+ "agent",
17
+ "assistant",
18
+ "cli",
19
+ "claude",
20
+ "chatgpt",
21
+ "gemini",
22
+ "whatsapp",
23
+ "telegram"
24
+ ],
25
+ "bin": {
26
+ "nunmai": "bin/nunmai.js"
27
+ },
28
+ "files": [
29
+ "bin/",
30
+ "README.md"
31
+ ],
32
+ "engines": {
33
+ "node": ">=18"
34
+ },
35
+ "os": [
36
+ "darwin",
37
+ "linux",
38
+ "win32",
39
+ "android"
40
+ ],
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "scripts": {
45
+ "postinstall": "node bin/nunmai.js --bootstrap-postinstall"
46
+ }
47
+ }