ominibot 2.0.13 → 3.0.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/README.md +1 -1
- package/package.json +9 -9
- package/postinstall.mjs +84 -93
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ominibot",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Ominibot - Picks the model, plans the work, checks its own output, and ships",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"x64"
|
|
37
37
|
],
|
|
38
38
|
"optionalDependencies": {
|
|
39
|
-
"ominibot-linux-x64": "
|
|
40
|
-
"ominibot-linux-arm64": "
|
|
41
|
-
"ominibot-linux-x64-musl": "
|
|
42
|
-
"ominibot-linux-arm64-musl": "
|
|
43
|
-
"ominibot-darwin-x64": "
|
|
44
|
-
"ominibot-darwin-arm64": "
|
|
45
|
-
"ominibot-windows-x64": "
|
|
46
|
-
"ominibot-windows-arm64": "
|
|
39
|
+
"ominibot-linux-x64": "3.0.1",
|
|
40
|
+
"ominibot-linux-arm64": "3.0.1",
|
|
41
|
+
"ominibot-linux-x64-musl": "3.0.1",
|
|
42
|
+
"ominibot-linux-arm64-musl": "3.0.1",
|
|
43
|
+
"ominibot-darwin-x64": "3.0.1",
|
|
44
|
+
"ominibot-darwin-arm64": "3.0.1",
|
|
45
|
+
"ominibot-windows-x64": "3.0.1",
|
|
46
|
+
"ominibot-windows-arm64": "3.0.1"
|
|
47
47
|
}
|
|
48
48
|
}
|
package/postinstall.mjs
CHANGED
|
@@ -1,36 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import childProcess from "child_process"
|
|
4
|
-
import fs from "fs"
|
|
5
|
-
import os from "os"
|
|
6
|
-
import path from "path"
|
|
7
|
-
import { createRequire } from "module"
|
|
8
|
-
import { fileURLToPath } from "url"
|
|
9
|
-
|
|
10
|
-
const
|
|
3
|
+
import childProcess from "node:child_process"
|
|
4
|
+
import fs from "node:fs"
|
|
5
|
+
import os from "node:os"
|
|
6
|
+
import path from "node:path"
|
|
7
|
+
import { createRequire } from "node:module"
|
|
8
|
+
import { fileURLToPath } from "node:url"
|
|
9
|
+
|
|
10
|
+
const directory = path.dirname(fileURLToPath(import.meta.url))
|
|
11
11
|
const require = createRequire(import.meta.url)
|
|
12
|
-
const packageJson = JSON.parse(fs.readFileSync(path.join(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const platform = platformMap[os.platform()] ?? os.platform()
|
|
26
|
-
const arch = archMap[os.arch()] ?? os.arch()
|
|
27
|
-
const base = `ominibot-${platform}-${arch}`
|
|
28
|
-
const sourceBinary = platform === "windows" ? "ominibot.exe" : "ominibot"
|
|
29
|
-
const targetBinary = path.join(__dirname, "bin", "ominibot.exe")
|
|
12
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(directory, "package.json"), "utf8"))
|
|
13
|
+
const command = Object.keys(packageJson.bin ?? {})[0]
|
|
14
|
+
if (!command) throw new Error("Ominibot package does not declare a binary")
|
|
15
|
+
const sourceCommand = packageJson.ominibotSourceBinary ?? command
|
|
16
|
+
|
|
17
|
+
const platform = { darwin: "darwin", linux: "linux", win32: "windows" }[os.platform()] ?? os.platform()
|
|
18
|
+
const arch = { x64: "x64", arm64: "arm64", arm: "arm" }[os.arch()] ?? os.arch()
|
|
19
|
+
const sourceBinary = platform === "windows" ? `${sourceCommand}.exe` : sourceCommand
|
|
20
|
+
const targetBinary = path.resolve(directory, packageJson.bin[command])
|
|
21
|
+
const dependencies = packageJson.optionalDependencies ?? {}
|
|
22
|
+
const base = Object.keys(dependencies).find((name) => name.endsWith(`-${platform}-${arch}`))
|
|
23
|
+
if (!base) throw new Error(`Ominibot does not provide a binary for ${platform}-${arch}`)
|
|
30
24
|
|
|
31
25
|
function supportsAvx2() {
|
|
32
26
|
if (arch !== "x64") return false
|
|
33
|
-
|
|
34
27
|
if (platform === "linux") {
|
|
35
28
|
try {
|
|
36
29
|
return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
|
|
@@ -38,27 +31,23 @@ function supportsAvx2() {
|
|
|
38
31
|
return false
|
|
39
32
|
}
|
|
40
33
|
}
|
|
41
|
-
|
|
42
34
|
if (platform === "darwin") {
|
|
43
35
|
try {
|
|
44
36
|
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
45
37
|
encoding: "utf8",
|
|
46
38
|
timeout: 1500,
|
|
47
39
|
})
|
|
48
|
-
|
|
49
|
-
return (result.stdout || "").trim() === "1"
|
|
40
|
+
return result.status === 0 && (result.stdout || "").trim() === "1"
|
|
50
41
|
} catch {
|
|
51
42
|
return false
|
|
52
43
|
}
|
|
53
44
|
}
|
|
54
|
-
|
|
55
45
|
if (platform === "windows") {
|
|
56
|
-
const
|
|
46
|
+
const script =
|
|
57
47
|
'(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
|
|
58
|
-
|
|
59
48
|
for (const executable of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
|
|
60
49
|
try {
|
|
61
|
-
const result = childProcess.spawnSync(executable, ["-NoProfile", "-NonInteractive", "-Command",
|
|
50
|
+
const result = childProcess.spawnSync(executable, ["-NoProfile", "-NonInteractive", "-Command", script], {
|
|
62
51
|
encoding: "utf8",
|
|
63
52
|
timeout: 3000,
|
|
64
53
|
windowsHide: true,
|
|
@@ -72,20 +61,13 @@ function supportsAvx2() {
|
|
|
72
61
|
}
|
|
73
62
|
}
|
|
74
63
|
}
|
|
75
|
-
|
|
76
64
|
return false
|
|
77
65
|
}
|
|
78
66
|
|
|
79
67
|
function isMusl() {
|
|
80
68
|
if (platform !== "linux") return false
|
|
81
|
-
|
|
82
69
|
try {
|
|
83
70
|
if (fs.existsSync("/etc/alpine-release")) return true
|
|
84
|
-
} catch {
|
|
85
|
-
// Ignore filesystem probes that are blocked by the host.
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
71
|
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
90
72
|
return `${result.stdout || ""}${result.stderr || ""}`.toLowerCase().includes("musl")
|
|
91
73
|
} catch {
|
|
@@ -95,79 +77,90 @@ function isMusl() {
|
|
|
95
77
|
|
|
96
78
|
function packageNames() {
|
|
97
79
|
const baseline = arch === "x64" && !supportsAvx2()
|
|
80
|
+
const names =
|
|
81
|
+
platform === "linux"
|
|
82
|
+
? isMusl()
|
|
83
|
+
? arch === "x64"
|
|
84
|
+
? baseline
|
|
85
|
+
? [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
86
|
+
: [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
|
|
87
|
+
: [`${base}-musl`, base]
|
|
88
|
+
: arch === "x64"
|
|
89
|
+
? baseline
|
|
90
|
+
? [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
|
|
91
|
+
: [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
|
|
92
|
+
: [base, `${base}-musl`]
|
|
93
|
+
: arch === "x64"
|
|
94
|
+
? baseline
|
|
95
|
+
? [`${base}-baseline`, base]
|
|
96
|
+
: [base, `${base}-baseline`]
|
|
97
|
+
: [base]
|
|
98
|
+
return names.filter((name) => dependencies[name])
|
|
99
|
+
}
|
|
98
100
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (arch === "x64")
|
|
109
|
-
return baseline
|
|
110
|
-
? [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
|
|
111
|
-
: [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
|
|
112
|
-
return [base, `${base}-musl`]
|
|
101
|
+
function copyBinary(source) {
|
|
102
|
+
if (!fs.existsSync(source)) throw new Error(`Binary not found at ${source}`)
|
|
103
|
+
fs.mkdirSync(path.dirname(targetBinary), { recursive: true })
|
|
104
|
+
if (fs.existsSync(targetBinary)) {
|
|
105
|
+
try {
|
|
106
|
+
fs.unlinkSync(targetBinary)
|
|
107
|
+
} catch {}
|
|
113
108
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
109
|
+
try {
|
|
110
|
+
fs.linkSync(source, targetBinary)
|
|
111
|
+
} catch {
|
|
112
|
+
fs.copyFileSync(source, targetBinary)
|
|
113
|
+
}
|
|
114
|
+
fs.chmodSync(targetBinary, 0o755)
|
|
117
115
|
}
|
|
118
116
|
|
|
119
117
|
function resolveBinary(name) {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
const packagePath = require.resolve(`${name}/package.json`)
|
|
119
|
+
// Package managers keep an older platform package when the matching version is not yet on the registry,
|
|
120
|
+
// which would silently install the previous release under the new launcher.
|
|
121
|
+
const version = JSON.parse(fs.readFileSync(packagePath, "utf8")).version
|
|
122
|
+
if (version !== dependencies[name]) throw new Error(`${name} is ${version}, expected ${dependencies[name]}`)
|
|
123
|
+
return path.join(path.dirname(packagePath), "bin", sourceBinary)
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
function installPackage(name) {
|
|
127
|
-
const version = packageJson.optionalDependencies?.[name]
|
|
128
|
-
if (!version) return
|
|
129
|
-
|
|
130
127
|
const temp = fs.mkdtempSync(path.join(os.tmpdir(), "ominibot-install-"))
|
|
131
128
|
try {
|
|
132
129
|
const result = childProcess.spawnSync(
|
|
133
130
|
"npm",
|
|
134
|
-
[
|
|
131
|
+
[
|
|
132
|
+
"install",
|
|
133
|
+
"--ignore-scripts",
|
|
134
|
+
"--no-save",
|
|
135
|
+
"--loglevel=error",
|
|
136
|
+
"--prefix",
|
|
137
|
+
temp,
|
|
138
|
+
`${name}@${dependencies[name]}`,
|
|
139
|
+
],
|
|
135
140
|
{ stdio: "inherit", windowsHide: true },
|
|
136
141
|
)
|
|
137
|
-
if (result.status !== 0) return
|
|
138
|
-
|
|
139
|
-
copyBinary(path.join(packageDir, "bin", sourceBinary), targetBinary)
|
|
142
|
+
if (result.status !== 0) return false
|
|
143
|
+
copyBinary(path.join(temp, "node_modules", name, "bin", sourceBinary))
|
|
140
144
|
return true
|
|
141
145
|
} finally {
|
|
142
146
|
fs.rmSync(temp, { recursive: true, force: true })
|
|
143
147
|
}
|
|
144
148
|
}
|
|
145
149
|
|
|
146
|
-
function copyBinary(source, target) {
|
|
147
|
-
if (!fs.existsSync(source)) throw new Error(`Binary not found at ${source}`)
|
|
148
|
-
fs.mkdirSync(path.dirname(target), { recursive: true })
|
|
149
|
-
if (fs.existsSync(target)) fs.unlinkSync(target)
|
|
150
|
-
try {
|
|
151
|
-
fs.linkSync(source, target)
|
|
152
|
-
} catch {
|
|
153
|
-
fs.copyFileSync(source, target)
|
|
154
|
-
}
|
|
155
|
-
fs.chmodSync(target, 0o755)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
150
|
function verifyBinary() {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
151
|
+
return (
|
|
152
|
+
childProcess.spawnSync(targetBinary, ["--version"], {
|
|
153
|
+
stdio: "ignore",
|
|
154
|
+
windowsHide: true,
|
|
155
|
+
}).status === 0
|
|
156
|
+
)
|
|
165
157
|
}
|
|
166
158
|
|
|
167
159
|
function main() {
|
|
168
|
-
|
|
160
|
+
const names = packageNames()
|
|
161
|
+
for (const name of names) {
|
|
169
162
|
try {
|
|
170
|
-
copyBinary(resolveBinary(name)
|
|
163
|
+
copyBinary(resolveBinary(name))
|
|
171
164
|
if (verifyBinary()) return
|
|
172
165
|
} catch {
|
|
173
166
|
if (installPackage(name) && verifyBinary()) return
|
|
@@ -176,16 +169,14 @@ function main() {
|
|
|
176
169
|
|
|
177
170
|
throw new Error(
|
|
178
171
|
ominibotUnsupportedReason() ??
|
|
179
|
-
`
|
|
180
|
-
.map((name) => JSON.stringify(name))
|
|
181
|
-
.join(" or ")}.`,
|
|
172
|
+
`Failed to install Ominibot. Try manually installing ${names.map((name) => JSON.stringify(name)).join(" or ")}.`,
|
|
182
173
|
)
|
|
183
174
|
}
|
|
184
175
|
|
|
185
176
|
try {
|
|
186
177
|
main()
|
|
187
178
|
} catch (error) {
|
|
188
|
-
console.error(error.message)
|
|
179
|
+
console.error(error instanceof Error ? error.message : String(error))
|
|
189
180
|
process.exit(1)
|
|
190
181
|
}
|
|
191
182
|
|