openmax-cli 0.0.0-stage → 2026.10.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/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ /node_modules
2
+
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Open Max contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,227 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="docs/assets/openmax-wordmark-dark.svg">
4
+ <img src="docs/assets/openmax-wordmark.svg" alt="Open Max">
5
+ </picture>
6
+ </p>
2
7
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
8
+ <p align="center"><strong>A self-extending Rust agent harness for coding in the terminal.</strong></p>
9
+
10
+ <p align="center">
11
+ <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT"></a>
12
+ <a href="https://www.rust-lang.org/"><img src="https://img.shields.io/badge/language-Rust-orange.svg" alt="Rust"></a>
13
+ </p>
14
+
15
+ Open Max is a single binary that runs a focused agent loop in your project directory and streams every tool call to the terminal. Point it at the model server you choose: local, cloud, or a private proxy. No desktop shell, no heavyweight runtime, no telemetry.
16
+
17
+ The endpoint must return structured API `tool_calls` to use tools. For local servers, configure the model's tool parser and chat template. Call markup in assistant text is displayed as text and never executed. Responses are limited to 16 MiB and 128 tool calls.
18
+
19
+
20
+ You own the endpoints, the tools, the skills, and the context.
21
+
22
+ ## Features
23
+
24
+ - **Small by default.** Seven built-in tools (`list_dir`, `read_file`, `write_file`, `edit_file`, `glob`, `grep`, `bash`) and a short system prompt. Old tool output is dropped before your task is, and dropped context is summarized by your own model into a compact note (heuristic digest as fallback) whose address points at the lossless archive of everything dropped — compaction is a bounded view over a record you can always read back.
25
+ - **Your model, your server.** One `base_url`, or several named endpoints in `providers.json` switched with `/model`. Works with local servers (Ollama, LM Studio, vLLM, llama.cpp), cloud gateways (OpenRouter and similar), and private proxies.
26
+ - **Trust before execution.** An exact canonical project root must be trusted before any agent turn or project behavior starts. Interactive use asks once; headless and stdio runs fail closed until a human grants trust with `--trust-project`.
27
+ - **Newly trusted projects run in auto.** Trusting a project records its approval mode, `auto` unless you pick another: tools and extensions run without per-call approval while deny rules, hooks, and execution reports stay active. Pick `ask` to have `write_file`, `edit_file`, and `bash` wait for approval, or `readonly` to block mutating tools. Approvals and permissions decide whether Open Max dispatches a tool call; they are not OS isolation.
28
+ - **File based extensions.** Drop TOML tools, `SKILL.md` skills, prompt templates, and process hooks under project or home config. No fork required. The agent writes them itself and the harness re-freezes as soon as a mutating call lands, so a tool the agent writes is a tool the agent uses on its very next step.
29
+ - **File based memory.** One durable fact per file in `.openmax/memory/`, written by the agent, surfaced as an index line in future sessions, ranked by recency and frequency of observed use. Old entries fade from the index and remain searchable on disk until the user or agent deletes them. No database, no daemon, no embeddings; zero prompt cost when empty.
30
+ - **Recall over everything kept.** `openmax --recall "<query>"` searches this project's past sessions, compaction archives, digests, and memories in one bounded streaming pass — BM25 relevance fused with the same recency law, ranked excerpts, each citing the file with the full record. No index to build or maintain: the stores on disk stay the single source of truth.
31
+ - **Visible work.** Reads, greps, diffs, and shell commands stream as they happen in a fullscreen TUI. Headless print mode for scripts and CI.
32
+ - **Local sessions.** Conversation state lives under `~/.openmax/`. The harness contacts only the model endpoint you configure.
33
+
34
+ ## Design
35
+
36
+ The design starts with one question: **What is the smallest capability Open Max must provide so the agent can construct richer behavior itself?** The answer is one focused native loop, seven primitive tools, a fast event-driven TUI, context management, and stable file and process contracts.
37
+
38
+ | Need | Construct it with |
39
+ | --- | --- |
40
+ | External service or specialized capability | A CLI-backed TOML tool plus an on-demand skill, without an MCP runtime |
41
+ | Reusable workflow or command | A `SKILL.md` package or prompt template slash command |
42
+ | Isolated or parallel work | A child `openmax -p` or interactive `openmax --stdio` process, usually in tmux |
43
+ | Durable background work | A named tmux session that the agent can inspect and reattach |
44
+ | Planning and task state | `PLAN.md` and `TODO.md`, visible to the user and every tool |
45
+ | Lifecycle policy and events | Process hooks and permission files |
46
+ | Compaction integration | The built-in model summary plus the `compaction` hook event |
47
+ | Model endpoints | `providers.json`, including local servers, gateways, and private proxies |
48
+ | Shortcuts or a completely different UI | Prompt templates, or a custom frontend speaking `openmax-stdio/6` |
49
+
50
+ These are deliberate boundaries, not placeholders for hidden orchestration products. Open Max does not carry an MCP host, nested-agent scheduler, plan mode, background-job product, built-in TODO database, user-keybinding engine, pluggable compactor, or TUI plugin ABI. The agent composes those richer workflows from the same host tools a developer can inspect, edit, test, and remove.
51
+
52
+ ## Install
53
+
54
+ Homebrew, on macOS or Linux:
55
+
56
+ ```sh
57
+ brew install Max17190/tap/openmax
58
+ ```
59
+
60
+ Or without Homebrew:
61
+
62
+ ```sh
63
+ curl -fsSL https://useopenmax.dev/install.sh | sh
64
+ ```
65
+
66
+ Or with bun or npm, if you already have a JavaScript runtime:
67
+
68
+ ```sh
69
+ bun install -g openmax-cli # or: npm install -g openmax-cli
70
+ ```
71
+
72
+ The command is `openmax` either way; only the package name carries the `-cli`,
73
+ because `openmax` on npm belongs to an unrelated 2015 package. This path fetches
74
+ the same native binary through a small launcher script that runs under `node`,
75
+ so it is the one install that needs Node.js on your `PATH`, even when bun did the
76
+ installing. Bun blocks install scripts by default, which is fine here: the binary
77
+ is fetched on first run instead, once, and cached.
78
+
79
+ Either way there is no Rust toolchain and no build. The script picks the right
80
+ prebuilt binary for your machine, checks it against the published SHA-256
81
+ (skipped, with a message, on a system with no `sha256sum`), and puts `openmax`
82
+ in `~/.openmax/bin` next to the settings and sessions the harness already keeps
83
+ there. It adds that directory to your `PATH` through your shell profile, so
84
+ open a new shell (or `source ~/.openmax/bin/env`) and run `openmax`.
85
+
86
+ macOS and Linux, x86_64 and arm64. Linux gets a glibc build, or a static musl
87
+ build automatically when glibc is older than 2.35, so it also runs on Alpine and
88
+ inside slim containers. Windows is not supported.
89
+
90
+ Set `OPENMAX_NO_MODIFY_PATH=1` to leave your `PATH` alone, or
91
+ `OPENMAX_INSTALL_DIR` to install somewhere else:
92
+
93
+ ```sh
94
+ curl -fsSL https://useopenmax.dev/install.sh | OPENMAX_NO_MODIFY_PATH=1 sh
95
+ ```
96
+
97
+ `useopenmax.dev/install.sh` redirects to the current release's installer, so it
98
+ follows new releases without the link changing.
99
+
100
+ Every [release](https://github.com/Max17190/open-max/releases) also carries the
101
+ plain tarballs and a `sha256.sum`, so you can download and verify by hand
102
+ instead of piping a script into a shell.
103
+
104
+ **From source** instead, which needs [Rust](https://rustup.rs) 1.89 or newer:
105
+
106
+ ```sh
107
+ git clone https://github.com/Max17190/open-max.git
108
+ cd open-max
109
+ cargo install --path crates/tui --locked
110
+ ```
111
+
112
+ Or run it in place with `cargo run --release -p openmax`.
113
+
114
+ ## Configure
115
+
116
+ Edit `~/.openmax/settings.json`:
117
+
118
+ ```json
119
+ {
120
+ "base_url": "http://127.0.0.1:11434/v1",
121
+ "model": "qwen2.5-coder:7b",
122
+ "api_key": null,
123
+ "approval_mode": "ask",
124
+ "context_tokens": 32768,
125
+ "max_parallel_tools": 4
126
+ }
127
+ ```
128
+
129
+ `base_url` is the root of your model's HTTP API (the harness calls `chat/completions` on it). Set `model` to the id that server expects. Set `api_key` to a literal or `$ENV_VAR`, or export `OPENMAX_API_KEY`. Set `context_tokens` to the context window the server actually serves for that model; nothing is queried, and a guessed window is wrong in one direction or the other. There is no default endpoint, model, or window: until all three are configured (here or through a named provider), Open Max refuses to start a turn with an error that says exactly what to set.
130
+
131
+ Trusting a project records its approval mode: `auto` unless you pick `ask` or
132
+ `readonly` at the trust prompt. Auto covers extension creation and repair
133
+ without further confirmation; validation, deny rules, and execution reports
134
+ remain active. `/approvals auto|ask|readonly`, Shift+Tab, and the approval
135
+ card's Auto for project choice change the saved mode for the current trusted
136
+ project. `approval_mode` in settings.json applies only to a project with no
137
+ saved mode, such as one trusted by an earlier version. See
138
+ [approval modes](docs/configuration.md#approvals).
139
+
140
+ A settings file that exists but does not parse, uses an unknown key, or sets an unrecognized `approval_mode` is a startup error (fail closed): Open Max exits with the parse reason instead of silently reverting your endpoint and approval policy to defaults.
141
+
142
+ Named endpoints in `providers.json` and `compat` flags for picky gateways are covered in [configuration](docs/configuration.md).
143
+
144
+ ## Use
145
+
146
+ ```sh
147
+ cd ~/code/my-app
148
+ openmax
149
+ ```
150
+
151
+ On the first interactive run, inspect the project and answer the trust prompt: `y` trusts it in `auto` mode, `a` in `ask`, and `r` in `readonly`. Headless and stdio runs never prompt: grant trust once from a terminal with `--trust-project`, which records `auto`, and later runs, including a frontend's `openmax --stdio`, need no flag:
152
+
153
+ ```sh
154
+ openmax --continue # resume latest session here
155
+ openmax --trust-project -p "summarize this repo" # from a terminal
156
+ openmax --stdio # a frontend, once trusted
157
+ ```
158
+
159
+ A frontend's stdin is its protocol pipe, not a terminal, so it cannot grant trust itself. For CI and other automation a human runs, see [project trust](docs/configuration.md#project-trust).
160
+
161
+ In print mode, text goes to stdout and tool progress to stderr; with `--json`, each `AgentEvent` is one JSON line. Press **/** for slash commands and **@** to mention a project file. Full flags, keybindings, and commands are in [usage](docs/usage.md).
162
+
163
+ ## Extend
164
+
165
+ With nothing installed, extensions cost zero tokens. Project paths win over global ones on name collision. Each surface is a file the agent can write, `openmax --check` can validate, and the next turn picks up automatically.
166
+
167
+ | Surface | Location | What it is |
168
+ | --- | --- | --- |
169
+ | **Tools** | `.openmax/tools/*.toml` | Schema-described native processes; args on stdin, result on stdout |
170
+ | **Skills** | `.agents/skills/*/SKILL.md` | On-demand workflow packages; only name and description cost prompt tokens |
171
+ | **Prompt templates** | `.agents/prompts/*.md` | User-invoked messages; the file stem becomes a slash command |
172
+ | **Hooks** | `.openmax/hooks/` | Process gates on a fixed set of lifecycle events; two of them can block |
173
+ | **Permissions** | `.openmax/permissions.toml` | Allow, deny, or ask rules matched against tool arguments; fail closed |
174
+
175
+ ```toml
176
+ # .openmax/tools/todo_scan.toml
177
+ name = "todo_scan"
178
+ description = "List TODO/FIXME comments with file and line"
179
+ command = "sh"
180
+ args = ["./scripts/todo-scan.sh"]
181
+ timeout_secs = 30
182
+ mutating = false
183
+
184
+ [params]
185
+ type = "object"
186
+ required = ["path"]
187
+ [params.properties.path]
188
+ type = "string"
189
+ description = "Directory to scan"
190
+ ```
191
+
192
+ Unknown keys are rejected everywhere, so a misspelled field surfaces in `openmax --check` rather than silently changing behavior. `openmax --spec <surface>` prints the complete authoring contract for any one of them, and the frozen prompt carries only a one-line pointer to it, so that contract costs zero tokens until the agent reads it.
193
+
194
+ File formats, hook events, permission rule syntax (including the in-session repair path for a broken permissions file), self-description, and the freezing model are documented in [extending](docs/extending.md).
195
+
196
+ ## Native execution and privacy
197
+
198
+ The built-in file tools (`list_dir`, `read_file`, `write_file`, `edit_file`, `glob`, and `grep`) are confined to the project root by the harness. `bash`, external TOML tools, and hooks are native processes: they are not confined by that path check and inherit the host filesystem, environment, credentials, and network access of Open Max. They run without a controlling terminal, so a command that prompts on the terminal (a password, an ssh host key) fails at once instead of drawing over the TUI and waiting out its timeout. `bash` and hooks also get `GIT_TERMINAL_PROMPT=0`, so git names the cause. Permissions, approvals, and `mutating` metadata control dispatch and user experience, not operating-system isolation.
199
+
200
+ Open Max itself does not phone home. Apart from native child processes, the harness contacts only the model endpoint you configure.
201
+
202
+ Sessions, settings, tools, and skills stay under `~/.openmax/` and your project directory. `/status` lists the destinations configured by the harness and detailed runtime information; it does not enforce or enumerate child-process network access, and external tools you install may open their own network connections.
203
+
204
+ ## Documentation
205
+
206
+ - [Configuration](docs/configuration.md): settings, approvals, providers, project trust
207
+ - [Usage](docs/usage.md): CLI flags, keybindings, slash commands
208
+ - [Extending](docs/extending.md): tools, skills, templates, hooks, permissions, validation, freezing
209
+ - [stdio protocol](docs/stdio-protocol.md): the `openmax-stdio/6` contract for custom frontends
210
+
211
+ ## Development
212
+
213
+ ```sh
214
+ cargo check
215
+ cargo test
216
+ cargo build --release -p openmax
217
+ ```
218
+
219
+ Set `OPENMAX_PERF=1` while running the TUI to log frame, transcript-layout, and selection-overlay timings. Core logic is in `open-max-core` (`crates/core/src/agent.rs`); the TUI is `crates/tui/src/app.rs`.
220
+
221
+ ## Status
222
+
223
+ Open Max is early software. File an issue or send a PR if something breaks.
224
+
225
+ ## License
226
+
227
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,348 @@
1
+ const {
2
+ createWriteStream,
3
+ existsSync,
4
+ mkdirSync,
5
+ mkdtemp,
6
+ rmSync,
7
+ } = require("fs");
8
+ const { join, sep } = require("path");
9
+ const { spawnSync } = require("child_process");
10
+ const { tmpdir } = require("os");
11
+
12
+ const https = require("node:https");
13
+ const http = require("node:http");
14
+
15
+ const tmpDir = tmpdir();
16
+
17
+ const error = (msg) => {
18
+ console.error(msg);
19
+ process.exit(1);
20
+ };
21
+
22
+ function getProxyForUrl(urlString) {
23
+ const url = new URL(urlString);
24
+ const isHttps = url.protocol === "https:";
25
+
26
+ const noProxy = process.env.NO_PROXY || process.env.no_proxy || "";
27
+ if (noProxy === "*") return null;
28
+ if (noProxy) {
29
+ const hostname = url.hostname.toLowerCase();
30
+ const noProxyList = noProxy.split(",").map((s) => s.trim().toLowerCase());
31
+ for (const entry of noProxyList) {
32
+ if (hostname === entry || hostname.endsWith("." + entry)) {
33
+ return null;
34
+ }
35
+ }
36
+ }
37
+
38
+ const proxyEnv = isHttps
39
+ ? process.env.HTTPS_PROXY || process.env.https_proxy
40
+ : process.env.HTTP_PROXY || process.env.http_proxy;
41
+
42
+ if (!proxyEnv) return null;
43
+
44
+ const proxyUrl = new URL(proxyEnv);
45
+
46
+ let auth = null;
47
+ if (proxyUrl.username || proxyUrl.password) {
48
+ auth = `${proxyUrl.username}:${proxyUrl.password}`;
49
+ }
50
+
51
+ return {
52
+ hostname: proxyUrl.hostname,
53
+ port: proxyUrl.port || (proxyUrl.protocol === "https:" ? 443 : 80),
54
+ auth: auth,
55
+ };
56
+ }
57
+
58
+ function connectThroughProxy(proxy, target) {
59
+ return new Promise((resolve, reject) => {
60
+ const headers = {};
61
+ if (proxy.auth) {
62
+ headers["Proxy-Authorization"] =
63
+ "Basic " + Buffer.from(proxy.auth).toString("base64");
64
+ }
65
+
66
+ const connectReq = http.request({
67
+ hostname: proxy.hostname,
68
+ port: proxy.port,
69
+ method: "CONNECT",
70
+ path: `${target.hostname}:${target.port || 443}`,
71
+ headers,
72
+ });
73
+ connectReq.on("connect", (res, socket) => {
74
+ if (res.statusCode === 200) {
75
+ resolve(socket);
76
+ } else {
77
+ reject(new Error(`Proxy CONNECT failed with status ${res.statusCode}`));
78
+ }
79
+ });
80
+ connectReq.on("error", reject);
81
+ connectReq.end();
82
+ });
83
+ }
84
+
85
+ function download(urlString, maxRedirects) {
86
+ if (maxRedirects === undefined) maxRedirects = 5;
87
+ return new Promise((resolve, reject) => {
88
+ if (maxRedirects < 0) {
89
+ return reject(new Error("Too many redirects"));
90
+ }
91
+
92
+ const parsed = new URL(urlString);
93
+ const isHttps = parsed.protocol === "https:";
94
+ const mod = isHttps ? https : http;
95
+ const proxy = getProxyForUrl(urlString);
96
+
97
+ const doRequest = (extraOptions) => {
98
+ const options = Object.assign(
99
+ {
100
+ hostname: parsed.hostname,
101
+ port: parsed.port || (isHttps ? 443 : 80),
102
+ path: parsed.pathname + parsed.search,
103
+ method: "GET",
104
+ headers: { "User-Agent": "cargo-dist-npm-installer" },
105
+ },
106
+ extraOptions || {},
107
+ );
108
+
109
+ if (proxy && !isHttps) {
110
+ // HTTP through HTTP proxy: request the full URL via the proxy
111
+ options.hostname = proxy.hostname;
112
+ options.port = proxy.port;
113
+ options.path = urlString;
114
+ if (proxy.auth) {
115
+ options.headers["Proxy-Authorization"] =
116
+ "Basic " + Buffer.from(proxy.auth).toString("base64");
117
+ }
118
+ }
119
+
120
+ const req = mod.request(options, (res) => {
121
+ if (
122
+ res.statusCode >= 300 &&
123
+ res.statusCode < 400 &&
124
+ res.headers.location
125
+ ) {
126
+ res.resume();
127
+ const nextUrl = new URL(res.headers.location, urlString).toString();
128
+ return download(nextUrl, maxRedirects - 1).then(resolve, reject);
129
+ }
130
+ if (res.statusCode < 200 || res.statusCode >= 300) {
131
+ res.resume();
132
+ return reject(new Error(`HTTP ${res.statusCode} from ${urlString}`));
133
+ }
134
+ resolve(res);
135
+ });
136
+ req.on("error", reject);
137
+ req.end();
138
+ };
139
+
140
+ if (proxy && isHttps) {
141
+ connectThroughProxy(proxy, parsed).then(
142
+ (socket) => doRequest({ socket, agent: false }),
143
+ reject,
144
+ );
145
+ } else {
146
+ doRequest();
147
+ }
148
+ });
149
+ }
150
+
151
+ class Package {
152
+ constructor(platform, name, url, filename, zipExt, binaries) {
153
+ let errors = [];
154
+ if (typeof url !== "string") {
155
+ errors.push("url must be a string");
156
+ } else {
157
+ try {
158
+ new URL(url);
159
+ } catch (e) {
160
+ errors.push(e);
161
+ }
162
+ }
163
+ if (name && typeof name !== "string") {
164
+ errors.push("package name must be a string");
165
+ }
166
+ if (!name) {
167
+ errors.push("You must specify the name of your package");
168
+ }
169
+ if (binaries && typeof binaries !== "object") {
170
+ errors.push("binaries must be a string => string map");
171
+ }
172
+ if (!binaries) {
173
+ errors.push("You must specify the binaries in the package");
174
+ }
175
+
176
+ if (errors.length > 0) {
177
+ let errorMsg =
178
+ "One or more of the parameters you passed to the Binary constructor are invalid:\n";
179
+ errors.forEach((error) => {
180
+ errorMsg += error;
181
+ });
182
+ errorMsg +=
183
+ '\n\nCorrect usage: new Package("my-binary", "https://example.com/binary/download.tar.gz", {"my-binary": "my-binary"})';
184
+ error(errorMsg);
185
+ }
186
+
187
+ this.platform = platform;
188
+ this.url = url;
189
+ this.name = name;
190
+ this.filename = filename;
191
+ this.zipExt = zipExt;
192
+ this.installDirectory = join(__dirname, "node_modules", ".bin_real");
193
+ this.binaries = binaries;
194
+
195
+ if (!existsSync(this.installDirectory)) {
196
+ mkdirSync(this.installDirectory, { recursive: true });
197
+ }
198
+ }
199
+
200
+ exists() {
201
+ for (const binaryName in this.binaries) {
202
+ const binRelPath = this.binaries[binaryName];
203
+ const binPath = join(this.installDirectory, binRelPath);
204
+ if (!existsSync(binPath)) {
205
+ return false;
206
+ }
207
+ }
208
+ return true;
209
+ }
210
+
211
+ install(suppressLogs = false) {
212
+ if (this.exists()) {
213
+ if (!suppressLogs) {
214
+ console.error(
215
+ `${this.name} is already installed, skipping installation.`,
216
+ );
217
+ }
218
+ return Promise.resolve();
219
+ }
220
+
221
+ try {
222
+ rmSync(this.installDirectory, { recursive: true, force: true });
223
+ } catch {
224
+ // ignore - directory may not exist
225
+ }
226
+
227
+ mkdirSync(this.installDirectory, { recursive: true });
228
+
229
+ if (!suppressLogs) {
230
+ console.error(`Downloading release from ${this.url}`);
231
+ }
232
+
233
+ return download(this.url)
234
+ .then((res) => {
235
+ return new Promise((resolve, reject) => {
236
+ mkdtemp(`${tmpDir}${sep}`, (err, directory) => {
237
+ if (err) return reject(err);
238
+ let tempFile = join(directory, this.filename);
239
+ const sink = res.pipe(createWriteStream(tempFile));
240
+ sink.on("error", (err) => reject(err));
241
+ sink.on("close", () => {
242
+ if (/\.tar\.*/.test(this.zipExt)) {
243
+ const result = spawnSync("tar", [
244
+ "xf",
245
+ tempFile,
246
+ // The tarballs are stored with a leading directory
247
+ // component; we strip one component in the
248
+ // shell installers too.
249
+ "--strip-components",
250
+ "1",
251
+ "-C",
252
+ this.installDirectory,
253
+ ]);
254
+ if (result.status == 0) {
255
+ resolve();
256
+ } else if (result.error) {
257
+ reject(result.error);
258
+ } else {
259
+ reject(
260
+ new Error(
261
+ `An error occurred untarring the artifact: stdout: ${result.stdout}; stderr: ${result.stderr}`,
262
+ ),
263
+ );
264
+ }
265
+ } else if (this.zipExt == ".zip") {
266
+ let result;
267
+ if (this.platform.artifactName.includes("windows")) {
268
+ // Windows does not have "unzip" by default on many installations, instead
269
+ // we use Expand-Archive from powershell
270
+ result = spawnSync("powershell.exe", [
271
+ "-NoProfile",
272
+ "-NonInteractive",
273
+ "-Command",
274
+ `& {
275
+ param([string]$LiteralPath, [string]$DestinationPath)
276
+ Expand-Archive -LiteralPath $LiteralPath -DestinationPath $DestinationPath -Force
277
+ }`,
278
+ tempFile,
279
+ this.installDirectory,
280
+ ]);
281
+ } else {
282
+ result = spawnSync("unzip", [
283
+ "-q",
284
+ tempFile,
285
+ "-d",
286
+ this.installDirectory,
287
+ ]);
288
+ }
289
+
290
+ if (result.status == 0) {
291
+ resolve();
292
+ } else if (result.error) {
293
+ reject(result.error);
294
+ } else {
295
+ reject(
296
+ new Error(
297
+ `An error occurred unzipping the artifact: stdout: ${result.stdout}; stderr: ${result.stderr}`,
298
+ ),
299
+ );
300
+ }
301
+ } else {
302
+ reject(
303
+ new Error(`Unrecognized file extension: ${this.zipExt}`),
304
+ );
305
+ }
306
+ });
307
+ });
308
+ });
309
+ })
310
+ .then(() => {
311
+ if (!suppressLogs) {
312
+ console.error(`${this.name} has been installed!`);
313
+ }
314
+ })
315
+ .catch((e) => {
316
+ error(`Error fetching release: ${e.message}`);
317
+ });
318
+ }
319
+
320
+ run(binaryName) {
321
+ const promise = !this.exists() ? this.install(true) : Promise.resolve();
322
+
323
+ promise
324
+ .then(() => {
325
+ const [, , ...args] = process.argv;
326
+
327
+ const options = { cwd: process.cwd(), stdio: "inherit" };
328
+
329
+ const binRelPath = this.binaries[binaryName];
330
+ if (!binRelPath) {
331
+ error(`${binaryName} is not a known binary in ${this.name}`);
332
+ }
333
+ const binPath = join(this.installDirectory, binRelPath);
334
+ const result = spawnSync(binPath, args, options);
335
+
336
+ if (result.error) {
337
+ error(result.error);
338
+ }
339
+
340
+ process.exit(result.status);
341
+ })
342
+ .catch((e) => {
343
+ error(e.message);
344
+ });
345
+ }
346
+ }
347
+
348
+ module.exports.Package = Package;
package/binary.js ADDED
@@ -0,0 +1,124 @@
1
+ const { Package } = require("./binary-install");
2
+ const os = require("os");
3
+ const libc = require("detect-libc");
4
+
5
+ const error = (msg) => {
6
+ console.error(msg);
7
+ process.exit(1);
8
+ };
9
+
10
+ const {
11
+ name,
12
+ artifactDownloadUrls,
13
+ supportedPlatforms,
14
+ glibcMinimum,
15
+ } = require("./package.json");
16
+
17
+ // FIXME: implement NPM installer handling of fallback download URLs
18
+ const artifactDownloadUrl = artifactDownloadUrls[0];
19
+ const builderGlibcMajorVersion = glibcMinimum.major;
20
+ const builderGlibcMinorVersion = glibcMinimum.series;
21
+
22
+ const getPlatform = () => {
23
+ const rawOsType = os.type();
24
+ const rawArchitecture = os.arch();
25
+
26
+ // We want to use rust-style target triples as the canonical key
27
+ // for a platform, so translate the "os" library's concepts into rust ones
28
+ let osType = "";
29
+ switch (rawOsType) {
30
+ case "Windows_NT":
31
+ osType = "pc-windows-msvc";
32
+ break;
33
+ case "Darwin":
34
+ osType = "apple-darwin";
35
+ break;
36
+ case "Linux":
37
+ osType = "unknown-linux-gnu";
38
+ break;
39
+ }
40
+
41
+ let arch = "";
42
+ switch (rawArchitecture) {
43
+ case "x64":
44
+ arch = "x86_64";
45
+ break;
46
+ case "arm64":
47
+ arch = "aarch64";
48
+ break;
49
+ }
50
+
51
+ if (rawOsType === "Linux") {
52
+ if (libc.familySync() == "musl") {
53
+ osType = "unknown-linux-musl-dynamic";
54
+ } else if (libc.isNonGlibcLinuxSync()) {
55
+ console.warn(
56
+ "Your libc is neither glibc nor musl; trying static musl binary instead",
57
+ );
58
+ osType = "unknown-linux-musl-static";
59
+ } else {
60
+ let libcVersion = libc.versionSync();
61
+ let splitLibcVersion = libcVersion.split(".");
62
+ let libcMajorVersion = splitLibcVersion[0];
63
+ let libcMinorVersion = splitLibcVersion[1];
64
+ if (
65
+ libcMajorVersion != builderGlibcMajorVersion ||
66
+ libcMinorVersion < builderGlibcMinorVersion
67
+ ) {
68
+ // We can't run the glibc binaries, but we can run the static musl ones
69
+ // if they exist
70
+ console.warn(
71
+ "Your glibc isn't compatible; trying static musl binary instead",
72
+ );
73
+ osType = "unknown-linux-musl-static";
74
+ }
75
+ }
76
+ }
77
+
78
+ // Assume the above succeeded and build a target triple to look things up with.
79
+ // If any of it failed, this lookup will fail and we'll handle it like normal.
80
+ let targetTriple = `${arch}-${osType}`;
81
+ let platform = supportedPlatforms[targetTriple];
82
+
83
+ if (!platform) {
84
+ error(
85
+ `Platform with type "${rawOsType}" and architecture "${rawArchitecture}" is not supported by ${name}.\nYour system must be one of the following:\n\n${Object.keys(
86
+ supportedPlatforms,
87
+ ).join(",")}`,
88
+ );
89
+ }
90
+
91
+ return platform;
92
+ };
93
+
94
+ const getPackage = () => {
95
+ const platform = getPlatform();
96
+ const url = `${artifactDownloadUrl}/${platform.artifactName}`;
97
+ let filename = platform.artifactName;
98
+ let ext = platform.zipExt;
99
+ let binary = new Package(platform, name, url, filename, ext, platform.bins);
100
+
101
+ return binary;
102
+ };
103
+
104
+ const install = (suppressLogs) => {
105
+ if (!artifactDownloadUrl || artifactDownloadUrl.length === 0) {
106
+ console.warn("in demo mode, not installing binaries");
107
+ return;
108
+ }
109
+ const pkg = getPackage();
110
+
111
+ return pkg.install(suppressLogs);
112
+ };
113
+
114
+ const run = (binaryName) => {
115
+ const pkg = getPackage();
116
+
117
+ pkg.run(binaryName);
118
+ };
119
+
120
+ module.exports = {
121
+ install,
122
+ run,
123
+ getPackage,
124
+ };
package/install.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { install } = require("./binary");
4
+ install(false);
@@ -0,0 +1,52 @@
1
+ {
2
+ "lockfileVersion": 3,
3
+ "name": "openmax-cli",
4
+ "packages": {
5
+ "": {
6
+ "bin": {
7
+ "openmax": "run-openmax.js"
8
+ },
9
+ "dependencies": {
10
+ "detect-libc": "^2.1.2"
11
+ },
12
+ "devDependencies": {
13
+ "prettier": "^3.8.3"
14
+ },
15
+ "engines": {
16
+ "node": ">=14.14",
17
+ "npm": ">=6"
18
+ },
19
+ "hasInstallScript": true,
20
+ "license": "MIT",
21
+ "name": "openmax-cli",
22
+ "version": "2026.10.1"
23
+ },
24
+ "node_modules/detect-libc": {
25
+ "engines": {
26
+ "node": ">=8"
27
+ },
28
+ "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
29
+ "license": "Apache-2.0",
30
+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
31
+ "version": "2.1.2"
32
+ },
33
+ "node_modules/prettier": {
34
+ "bin": {
35
+ "prettier": "bin/prettier.cjs"
36
+ },
37
+ "dev": true,
38
+ "engines": {
39
+ "node": ">=14"
40
+ },
41
+ "funding": {
42
+ "url": "https://github.com/prettier/prettier?sponsor=1"
43
+ },
44
+ "integrity": "sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw==",
45
+ "license": "MIT",
46
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.3.tgz",
47
+ "version": "3.8.3"
48
+ }
49
+ },
50
+ "requires": true,
51
+ "version": "2026.10.1"
52
+ }
package/package.json CHANGED
@@ -1,6 +1,97 @@
1
1
  {
2
+ "artifactDownloadUrls": [
3
+ "https://github.com/Max17190/open-max/releases/download/v2026.10.1"
4
+ ],
5
+ "author": "Open Max contributors",
6
+ "bin": {
7
+ "openmax": "run-openmax.js"
8
+ },
9
+ "dependencies": {
10
+ "detect-libc": "^2.1.2"
11
+ },
12
+ "description": "Open Max: barebones high-performance agent harness TUI",
13
+ "devDependencies": {
14
+ "prettier": "^3.8.3"
15
+ },
16
+ "engines": {
17
+ "node": ">=14.14",
18
+ "npm": ">=6"
19
+ },
20
+ "glibcMinimum": {
21
+ "major": 2,
22
+ "series": 35
23
+ },
24
+ "homepage": "https://github.com/Max17190/open-max",
25
+ "license": "MIT",
2
26
  "name": "openmax-cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
27
+ "preferUnplugged": true,
28
+ "repository": "https://github.com/Max17190/open-max",
29
+ "scripts": {
30
+ "fmt": "prettier --write **/*.js",
31
+ "fmt:check": "prettier --check **/*.js",
32
+ "postinstall": "node ./install.js"
33
+ },
34
+ "supportedPlatforms": {
35
+ "aarch64-apple-darwin": {
36
+ "artifactName": "openmax-aarch64-apple-darwin.tar.xz",
37
+ "bins": {
38
+ "openmax": "openmax"
39
+ },
40
+ "zipExt": ".tar.xz"
41
+ },
42
+ "aarch64-unknown-linux-gnu": {
43
+ "artifactName": "openmax-aarch64-unknown-linux-gnu.tar.xz",
44
+ "bins": {
45
+ "openmax": "openmax"
46
+ },
47
+ "zipExt": ".tar.xz"
48
+ },
49
+ "aarch64-unknown-linux-musl-dynamic": {
50
+ "artifactName": "openmax-aarch64-unknown-linux-musl.tar.xz",
51
+ "bins": {
52
+ "openmax": "openmax"
53
+ },
54
+ "zipExt": ".tar.xz"
55
+ },
56
+ "aarch64-unknown-linux-musl-static": {
57
+ "artifactName": "openmax-aarch64-unknown-linux-musl.tar.xz",
58
+ "bins": {
59
+ "openmax": "openmax"
60
+ },
61
+ "zipExt": ".tar.xz"
62
+ },
63
+ "x86_64-apple-darwin": {
64
+ "artifactName": "openmax-x86_64-apple-darwin.tar.xz",
65
+ "bins": {
66
+ "openmax": "openmax"
67
+ },
68
+ "zipExt": ".tar.xz"
69
+ },
70
+ "x86_64-unknown-linux-gnu": {
71
+ "artifactName": "openmax-x86_64-unknown-linux-gnu.tar.xz",
72
+ "bins": {
73
+ "openmax": "openmax"
74
+ },
75
+ "zipExt": ".tar.xz"
76
+ },
77
+ "x86_64-unknown-linux-musl-dynamic": {
78
+ "artifactName": "openmax-x86_64-unknown-linux-musl.tar.xz",
79
+ "bins": {
80
+ "openmax": "openmax"
81
+ },
82
+ "zipExt": ".tar.xz"
83
+ },
84
+ "x86_64-unknown-linux-musl-static": {
85
+ "artifactName": "openmax-x86_64-unknown-linux-musl.tar.xz",
86
+ "bins": {
87
+ "openmax": "openmax"
88
+ },
89
+ "zipExt": ".tar.xz"
90
+ }
91
+ },
92
+ "version": "2026.10.1",
93
+ "volta": {
94
+ "node": "18.14.1",
95
+ "npm": "9.5.0"
96
+ }
6
97
  }
package/run-openmax.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { run } = require("./binary");
4
+ run("openmax");