optrex 0.2.2
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/LICENSE +21 -0
- package/README.md +45 -0
- package/bin/cornea.js +32 -0
- package/install.js +101 -0
- package/package.json +45 -0
- package/test.js +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AbduljabbarBXR
|
|
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
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# optrex (Cornea npm installer)
|
|
2
|
+
|
|
3
|
+
Installs the prebuilt [Cornea](https://github.com/AbduljabbarBXR/cornea) binary for your platform and exposes the `cornea` command. Cornea is deterministic visual inspection for AI agents: overlap, overflow, contrast and quality as token-cheap geometry instead of pixel dumps. No Chromium.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install -g optrex
|
|
7
|
+
cornea --help
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
On install, the matching binary is downloaded from GitHub Releases into the package `bin/` folder. No Rust toolchain needed.
|
|
11
|
+
|
|
12
|
+
## Supported platforms
|
|
13
|
+
|
|
14
|
+
| OS | Arch | Asset |
|
|
15
|
+
|----|------|-------|
|
|
16
|
+
| Linux (glibc) | x64 | `cornea-x86_64-unknown-linux-gnu` |
|
|
17
|
+
| Linux (glibc) | arm64 | `cornea-aarch64-unknown-linux-gnu` |
|
|
18
|
+
| macOS | arm64 | `cornea-aarch64-apple-darwin` |
|
|
19
|
+
| macOS | x64 | `cornea-x86_64-apple-darwin` |
|
|
20
|
+
| Windows | x64 | `cornea-x86_64-pc-windows-msvc.exe` |
|
|
21
|
+
|
|
22
|
+
Not listed, e.g. Android, or musl/Alpine: the installer stops with a clear error. Install from source instead (`cargo install cornea`) or pick a build from the [releases page](https://github.com/AbduljabbarBXR/cornea/releases).
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
Same as the native binary:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
cornea page.html 360
|
|
30
|
+
cornea --serve # MCP server over stdio for agents
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Versions
|
|
34
|
+
|
|
35
|
+
npm package version tracks the Cornea release version. `optrex@0.2.2` installs Cornea 0.2.2.
|
|
36
|
+
|
|
37
|
+
## Uninstall
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm uninstall -g optrex
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
MIT. See [LICENSE](./LICENSE). Binary builds follow the [Cornea repo license](https://github.com/AbduljabbarBXR/cornea).
|
package/bin/cornea.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* cornea launcher. Runs the platform binary downloaded by postinstall. */
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { spawnSync } = require("child_process");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
|
|
9
|
+
function binaryPath() {
|
|
10
|
+
const exe = process.platform === "win32" ? "cornea.exe" : "cornea";
|
|
11
|
+
return path.join(__dirname, exe);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function main() {
|
|
15
|
+
const bin = binaryPath();
|
|
16
|
+
if (!fs.existsSync(bin)) {
|
|
17
|
+
console.error("cornea: binary not found. Reinstall with: npm install -g optrex");
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
const result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
21
|
+
if (result.error) {
|
|
22
|
+
console.error(`cornea: could not run the binary (${result.error.message}).`);
|
|
23
|
+
console.error("Your platform may need a different build:");
|
|
24
|
+
console.error("https://github.com/AbduljabbarBXR/cornea/releases");
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
process.exit(result.status === null ? 1 : result.status);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (require.main === module) main();
|
|
31
|
+
|
|
32
|
+
module.exports = { binaryPath };
|
package/install.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* Cornea npm installer (package: optrex).
|
|
4
|
+
* Downloads the prebuilt Cornea binary for the current platform from
|
|
5
|
+
* GitHub Releases into ./bin/ next to the launcher.
|
|
6
|
+
*/
|
|
7
|
+
"use strict";
|
|
8
|
+
|
|
9
|
+
const fs = require("fs");
|
|
10
|
+
const https = require("https");
|
|
11
|
+
const path = require("path");
|
|
12
|
+
|
|
13
|
+
const VERSION = require("./package.json").version;
|
|
14
|
+
const REPO = "AbduljabbarBXR/cornea";
|
|
15
|
+
const BIN_NAME = "cornea";
|
|
16
|
+
|
|
17
|
+
const ASSETS = {
|
|
18
|
+
"linux-x64": "cornea-x86_64-unknown-linux-gnu",
|
|
19
|
+
"linux-arm64": "cornea-aarch64-unknown-linux-gnu",
|
|
20
|
+
"darwin-arm64": "cornea-aarch64-apple-darwin",
|
|
21
|
+
"darwin-x64": "cornea-x86_64-apple-darwin",
|
|
22
|
+
"win32-x64": "cornea-x86_64-pc-windows-msvc.exe",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function currentKey() {
|
|
26
|
+
if (process.env.CORNEA_TEST_PLATFORM) return process.env.CORNEA_TEST_PLATFORM;
|
|
27
|
+
return `${process.platform}-${process.arch}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function assetFor(key) {
|
|
31
|
+
return ASSETS[key] || null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function exeName() {
|
|
35
|
+
return process.platform === "win32" ? `${BIN_NAME}.exe` : BIN_NAME;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function isMusl() {
|
|
39
|
+
try {
|
|
40
|
+
if (fs.existsSync("/etc/alpine-release")) return true;
|
|
41
|
+
const osRelease = fs.readFileSync("/etc/os-release", "utf8");
|
|
42
|
+
return /(^|\n)ID_LIKE=.*musl/.test(osRelease) || /(^|\n)ID=alpine/.test(osRelease);
|
|
43
|
+
} catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function download(url, dest, redirects = 5) {
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
https
|
|
51
|
+
.get(url, { headers: { "User-Agent": "optrex-npm-installer" } }, (res) => {
|
|
52
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
53
|
+
if (redirects === 0) return reject(new Error("too many redirects"));
|
|
54
|
+
res.resume();
|
|
55
|
+
return resolve(download(res.headers.location, dest, redirects - 1));
|
|
56
|
+
}
|
|
57
|
+
if (res.statusCode !== 200) {
|
|
58
|
+
res.resume();
|
|
59
|
+
return reject(new Error(`download failed: HTTP ${res.statusCode} for ${url}`));
|
|
60
|
+
}
|
|
61
|
+
const out = fs.createWriteStream(dest, { mode: 0o755 });
|
|
62
|
+
res.pipe(out);
|
|
63
|
+
out.on("finish", () => resolve());
|
|
64
|
+
out.on("error", reject);
|
|
65
|
+
})
|
|
66
|
+
.on("error", reject);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function main() {
|
|
71
|
+
const key = currentKey();
|
|
72
|
+
const asset = assetFor(key);
|
|
73
|
+
if (!asset) {
|
|
74
|
+
console.error(`cornea: no prebuilt binary for ${process.platform}-${process.arch}.`);
|
|
75
|
+
console.error("Install from source instead: cargo install cornea");
|
|
76
|
+
console.error(`Or pick a build manually: https://github.com/${REPO}/releases`);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
if (process.platform === "linux" && isMusl()) {
|
|
80
|
+
console.error("cornea: prebuilt binaries are glibc linked and will not run on musl (Alpine).");
|
|
81
|
+
console.error("Install from source instead: cargo install cornea");
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
const binDir = path.join(__dirname, "bin");
|
|
85
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
86
|
+
const dest = path.join(binDir, exeName());
|
|
87
|
+
const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${asset}`;
|
|
88
|
+
console.log(`cornea: downloading ${asset} ...`);
|
|
89
|
+
await download(url, dest);
|
|
90
|
+
if (process.platform !== "win32") fs.chmodSync(dest, 0o755);
|
|
91
|
+
console.log(`cornea: installed ${dest}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (require.main === module) {
|
|
95
|
+
main().catch((err) => {
|
|
96
|
+
console.error(`cornea install failed: ${err.message}`);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
module.exports = { assetFor, currentKey, exeName, isMusl, VERSION };
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "optrex",
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "Cornea installer. Downloads the prebuilt Cornea binary for your platform and exposes the cornea command. Deterministic visual inspection for AI agents.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"cornea": "bin/cornea.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node ./install.js",
|
|
10
|
+
"test": "node ./test.js"
|
|
11
|
+
},
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=18"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"cornea",
|
|
18
|
+
"optrex",
|
|
19
|
+
"visual",
|
|
20
|
+
"inspection",
|
|
21
|
+
"layout",
|
|
22
|
+
"mcp",
|
|
23
|
+
"model-context-protocol",
|
|
24
|
+
"ai-agents",
|
|
25
|
+
"cli",
|
|
26
|
+
"binary"
|
|
27
|
+
],
|
|
28
|
+
"author": "AbduljabbarBXR",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/AbduljabbarBXR/cornea.git",
|
|
32
|
+
"directory": "npm"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/AbduljabbarBXR/cornea#readme",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/AbduljabbarBXR/cornea/issues"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"bin/",
|
|
40
|
+
"install.js",
|
|
41
|
+
"test.js",
|
|
42
|
+
"README.md",
|
|
43
|
+
"LICENSE"
|
|
44
|
+
]
|
|
45
|
+
}
|
package/test.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Unit tests for the installer mapping. No dependencies. Run: npm test
|
|
3
|
+
const assert = require("assert");
|
|
4
|
+
const { assetFor } = require("./install.js");
|
|
5
|
+
|
|
6
|
+
assert.strictEqual(assetFor("linux-x64"), "cornea-x86_64-unknown-linux-gnu");
|
|
7
|
+
assert.strictEqual(assetFor("linux-arm64"), "cornea-aarch64-unknown-linux-gnu");
|
|
8
|
+
assert.strictEqual(assetFor("darwin-arm64"), "cornea-aarch64-apple-darwin");
|
|
9
|
+
assert.strictEqual(assetFor("darwin-x64"), "cornea-x86_64-apple-darwin");
|
|
10
|
+
assert.strictEqual(assetFor("win32-x64"), "cornea-x86_64-pc-windows-msvc.exe");
|
|
11
|
+
assert.strictEqual(assetFor("android-arm64"), null);
|
|
12
|
+
assert.strictEqual(assetFor("freebsd-x64"), null);
|
|
13
|
+
|
|
14
|
+
console.log("cornea installer mapping: 7/7 ok");
|