@inference-gateway/cli 0.119.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.
- package/LICENSE +201 -0
- package/README.md +1264 -0
- package/bin/install.js +125 -0
- package/bin/run.js +35 -0
- package/package.json +52 -0
package/bin/install.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// Downloads the native `infer` binary that matches the host platform from the
|
|
5
|
+
// GitHub release matching this package's version, and places it next to this
|
|
6
|
+
// script so `bin/run.js` can exec it. Runs as an npm `postinstall` hook.
|
|
7
|
+
//
|
|
8
|
+
// The CLI publishes raw executables (e.g. `infer-linux-amd64`) plus a
|
|
9
|
+
// `checksums.txt`, so this downloads the binary directly - no archive to extract.
|
|
10
|
+
|
|
11
|
+
const fs = require("fs");
|
|
12
|
+
const path = require("path");
|
|
13
|
+
const https = require("https");
|
|
14
|
+
const crypto = require("crypto");
|
|
15
|
+
|
|
16
|
+
const REPO = "inference-gateway/cli";
|
|
17
|
+
const { version } = require("../package.json");
|
|
18
|
+
const BASE_URL =
|
|
19
|
+
process.env.INFER_CLI_BASE_URL ||
|
|
20
|
+
`https://github.com/${REPO}/releases/download/v${version}`;
|
|
21
|
+
|
|
22
|
+
// Maps Node's process.platform / process.arch onto the release asset names.
|
|
23
|
+
const PLATFORMS = { linux: "linux", darwin: "darwin" };
|
|
24
|
+
const ARCHES = { x64: "amd64", arm64: "arm64" };
|
|
25
|
+
|
|
26
|
+
const binName = process.platform === "win32" ? "infer.exe" : "infer";
|
|
27
|
+
const binPath = path.join(__dirname, binName);
|
|
28
|
+
|
|
29
|
+
function fail(message) {
|
|
30
|
+
console.error(`\n@inference-gateway/cli: ${message}\n`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function resolveAsset() {
|
|
35
|
+
const goos = PLATFORMS[process.platform];
|
|
36
|
+
const goarch = ARCHES[process.arch];
|
|
37
|
+
if (!goos || !goarch) {
|
|
38
|
+
fail(
|
|
39
|
+
`unsupported platform ${process.platform}/${process.arch}. ` +
|
|
40
|
+
`Prebuilt binaries are published for linux and darwin on amd64/arm64 only. ` +
|
|
41
|
+
`Install from source instead: https://github.com/${REPO}#installation`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return `infer-${goos}-${goarch}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function download(url) {
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
https
|
|
50
|
+
.get(url, { headers: { "User-Agent": "inference-gateway-cli-npm" } }, (res) => {
|
|
51
|
+
const { statusCode, headers } = res;
|
|
52
|
+
if (statusCode >= 300 && statusCode < 400 && headers.location) {
|
|
53
|
+
res.resume();
|
|
54
|
+
resolve(download(headers.location));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (statusCode !== 200) {
|
|
58
|
+
res.resume();
|
|
59
|
+
reject(new Error(`request to ${url} failed with status ${statusCode}`));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const chunks = [];
|
|
63
|
+
res.on("data", (chunk) => chunks.push(chunk));
|
|
64
|
+
res.on("end", () => resolve(Buffer.concat(chunks)));
|
|
65
|
+
})
|
|
66
|
+
.on("error", reject);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function verifyChecksum(binary, assetName) {
|
|
71
|
+
let checksums;
|
|
72
|
+
try {
|
|
73
|
+
checksums = (await download(`${BASE_URL}/checksums.txt`)).toString("utf8");
|
|
74
|
+
} catch (err) {
|
|
75
|
+
console.warn(
|
|
76
|
+
`@inference-gateway/cli: could not fetch checksums.txt (${err.message}); skipping integrity check`
|
|
77
|
+
);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const line = checksums.split("\n").find((l) => l.trim().endsWith(assetName));
|
|
81
|
+
if (!line) {
|
|
82
|
+
console.warn(
|
|
83
|
+
`@inference-gateway/cli: no checksum entry for ${assetName}; skipping integrity check`
|
|
84
|
+
);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const expected = line.trim().split(/\s+/)[0];
|
|
88
|
+
const actual = crypto.createHash("sha256").update(binary).digest("hex");
|
|
89
|
+
if (expected !== actual) {
|
|
90
|
+
fail(`checksum mismatch for ${assetName} (expected ${expected}, got ${actual})`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function main() {
|
|
95
|
+
if (process.env.INFER_CLI_SKIP_DOWNLOAD) {
|
|
96
|
+
console.log("@inference-gateway/cli: INFER_CLI_SKIP_DOWNLOAD set, skipping binary download");
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (fs.existsSync(binPath)) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const assetName = resolveAsset();
|
|
104
|
+
const url = `${BASE_URL}/${assetName}`;
|
|
105
|
+
console.log(`@inference-gateway/cli: downloading ${assetName} (v${version})`);
|
|
106
|
+
|
|
107
|
+
let binary;
|
|
108
|
+
try {
|
|
109
|
+
binary = await download(url);
|
|
110
|
+
} catch (err) {
|
|
111
|
+
fail(
|
|
112
|
+
`failed to download ${url}: ${err.message}. ` +
|
|
113
|
+
`If you are offline, install from source: https://github.com/${REPO}#installation`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
await verifyChecksum(binary, assetName);
|
|
118
|
+
|
|
119
|
+
fs.mkdirSync(path.dirname(binPath), { recursive: true });
|
|
120
|
+
fs.writeFileSync(binPath, binary, { mode: 0o755 });
|
|
121
|
+
fs.chmodSync(binPath, 0o755);
|
|
122
|
+
console.log(`@inference-gateway/cli: installed infer ${version} to ${binPath}`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
main().catch((err) => fail(err.message));
|
package/bin/run.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// Locates the native `infer` binary fetched by bin/install.js and execs it,
|
|
5
|
+
// forwarding all arguments, stdio, and the exit code.
|
|
6
|
+
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const { spawnSync } = require("child_process");
|
|
10
|
+
|
|
11
|
+
const binName = process.platform === "win32" ? "infer.exe" : "infer";
|
|
12
|
+
const binPath = path.join(__dirname, binName);
|
|
13
|
+
|
|
14
|
+
if (!fs.existsSync(binPath)) {
|
|
15
|
+
const install = spawnSync(process.execPath, [path.join(__dirname, "install.js")], {
|
|
16
|
+
stdio: "inherit",
|
|
17
|
+
});
|
|
18
|
+
if (install.status !== 0 || !fs.existsSync(binPath)) {
|
|
19
|
+
console.error(
|
|
20
|
+
"@inference-gateway/cli: native binary not found and could not be installed. " +
|
|
21
|
+
"Reinstall the package or install from source: " +
|
|
22
|
+
"https://github.com/inference-gateway/cli#installation"
|
|
23
|
+
);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const result = spawnSync(binPath, process.argv.slice(2), { stdio: "inherit" });
|
|
29
|
+
|
|
30
|
+
if (result.error) {
|
|
31
|
+
console.error(`@inference-gateway/cli: failed to run binary: ${result.error.message}`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@inference-gateway/cli",
|
|
3
|
+
"version": "0.119.0",
|
|
4
|
+
"description": "A Git-first CLI coding agent that turns ideas, issues, and tasks into real code changes.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"infer": "bin/run.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node bin/install.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin/run.js",
|
|
13
|
+
"bin/install.js",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"inference-gateway",
|
|
19
|
+
"cli",
|
|
20
|
+
"llm",
|
|
21
|
+
"ai",
|
|
22
|
+
"agent",
|
|
23
|
+
"chat",
|
|
24
|
+
"tui",
|
|
25
|
+
"a2a",
|
|
26
|
+
"mcp"
|
|
27
|
+
],
|
|
28
|
+
"homepage": "https://github.com/inference-gateway/cli#readme",
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/inference-gateway/cli/issues"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/inference-gateway/cli.git"
|
|
35
|
+
},
|
|
36
|
+
"license": "Apache-2.0",
|
|
37
|
+
"author": "Inference Gateway",
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18"
|
|
40
|
+
},
|
|
41
|
+
"os": [
|
|
42
|
+
"linux",
|
|
43
|
+
"darwin"
|
|
44
|
+
],
|
|
45
|
+
"cpu": [
|
|
46
|
+
"x64",
|
|
47
|
+
"arm64"
|
|
48
|
+
],
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
}
|
|
52
|
+
}
|