@mettlelabs/mettle 0.0.0-beta.1-darwin-arm64 → 0.0.0-beta.10

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 (61) hide show
  1. package/LICENSE +22 -0
  2. package/bin/mettle.cjs +152 -0
  3. package/package.json +28 -13
  4. package/THIRD_PARTY_NOTICES.md +0 -11479
  5. package/bin/mettle +0 -4
  6. package/harness/audit-investigation.mjs +0 -203
  7. package/harness/chunk-13tgmdey.mjs +0 -33761
  8. package/harness/chunk-1sygmp11.mjs +0 -18142
  9. package/harness/chunk-1ykxpmaz.mjs +0 -7887
  10. package/harness/chunk-2gt4cy7x.mjs +0 -2290
  11. package/harness/chunk-2pm2sayw.mjs +0 -248
  12. package/harness/chunk-32y07kkp.mjs +0 -3747
  13. package/harness/chunk-3m7jn5ac.mjs +0 -16242
  14. package/harness/chunk-3wvjs93w.mjs +0 -538
  15. package/harness/chunk-4bepyxmq.mjs +0 -113
  16. package/harness/chunk-4jtnt9k5.mjs +0 -95
  17. package/harness/chunk-50sbrf09.mjs +0 -18972
  18. package/harness/chunk-56csr8sw.mjs +0 -322
  19. package/harness/chunk-5cvb1jnb.mjs +0 -41
  20. package/harness/chunk-5wgmv4np.mjs +0 -585
  21. package/harness/chunk-65eyq32y.mjs +0 -225
  22. package/harness/chunk-6fnh6qhk.mjs +0 -195
  23. package/harness/chunk-6kgqw9ny.mjs +0 -32303
  24. package/harness/chunk-7b242j0n.mjs +0 -14
  25. package/harness/chunk-7bg2gnv2.mjs +0 -7540
  26. package/harness/chunk-ageqxj9v.mjs +0 -63008
  27. package/harness/chunk-b0qbt5jd.mjs +0 -14
  28. package/harness/chunk-b5g1r3fz.mjs +0 -4785
  29. package/harness/chunk-b71gpkxg.mjs +0 -1514
  30. package/harness/chunk-bdv1rx4a.mjs +0 -20364
  31. package/harness/chunk-c1631s2x.mjs +0 -12241
  32. package/harness/chunk-d5xgxsnp.mjs +0 -74
  33. package/harness/chunk-erg1fbh0.mjs +0 -0
  34. package/harness/chunk-fh78v9vn.mjs +0 -19366
  35. package/harness/chunk-fjx29qvp.mjs +0 -50
  36. package/harness/chunk-gryka6kg.mjs +0 -39
  37. package/harness/chunk-jb0r19et.mjs +0 -180
  38. package/harness/chunk-mfn574ss.mjs +0 -179
  39. package/harness/chunk-msg872ea.mjs +0 -334
  40. package/harness/chunk-nz5sv9as.mjs +0 -1642
  41. package/harness/chunk-p9d3cgvq.mjs +0 -452
  42. package/harness/chunk-pq6wvwxr.mjs +0 -12
  43. package/harness/chunk-qcm9arf8.mjs +0 -7736
  44. package/harness/chunk-qr8zfqjd.mjs +0 -24
  45. package/harness/chunk-rz2tz6jp.mjs +0 -26
  46. package/harness/chunk-sbkgc3kn.mjs +0 -8
  47. package/harness/chunk-v66qvpnb.mjs +0 -169
  48. package/harness/chunk-vjaxzab3.mjs +0 -136
  49. package/harness/chunk-vr1n5nza.mjs +0 -1045
  50. package/harness/chunk-vsf2zajv.mjs +0 -3867
  51. package/harness/chunk-wq253fj4.mjs +0 -19041
  52. package/harness/chunk-wyv7ceq4.mjs +0 -0
  53. package/harness/chunk-xnqknk2r.mjs +0 -198
  54. package/harness/chunk-xqyc4ca2.mjs +0 -1890
  55. package/harness/chunk-z6n9thea.mjs +0 -45146
  56. package/harness/chunk-zty0d3bw.mjs +0 -0
  57. package/harness/chunk-zvkxtj82.mjs +0 -42
  58. package/harness/issue-api-token.mjs +0 -35
  59. package/harness/launcher.mjs +0 -159
  60. package/harness/sandbox.mjs +0 -132
  61. package/harness/server.mjs +0 -66322
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 mettle
4
+ Copyright (c) 2025 opencode
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/bin/mettle.cjs ADDED
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env node
2
+
3
+ const childProcess = require("node:child_process")
4
+ const fs = require("node:fs")
5
+ const path = require("node:path")
6
+ const os = require("node:os")
7
+
8
+ const forwardedSignals =
9
+ process.platform === "win32" ? ["SIGINT", "SIGTERM", "SIGHUP"] : ["SIGINT", "SIGTERM", "SIGHUP", "SIGUSR1"]
10
+
11
+ function run(target) {
12
+ // Tell the CLI which npm package launched it, so the self-updater can detect its install
13
+ // method. The native binary lives in a per-platform package (@mettlelabs/mettle-<suffix>)
14
+ // without a bin field, so the updater cannot rediscover the wrapper from its own path.
15
+ const env = { ...process.env, METTLE_NPM_ROOT: wrapperDir }
16
+ const child = childProcess.spawn(target, process.argv.slice(2), { stdio: "inherit", env })
17
+ child.on("error", (error) => {
18
+ console.error(error.message)
19
+ process.exit(1)
20
+ })
21
+ const forwarders = {}
22
+ for (const signal of forwardedSignals) {
23
+ forwarders[signal] = () => {
24
+ try {
25
+ child.kill(signal)
26
+ } catch {}
27
+ }
28
+ process.on(signal, forwarders[signal])
29
+ }
30
+ child.on("exit", (code, signal) => {
31
+ for (const forwardedSignal of forwardedSignals) process.removeListener(forwardedSignal, forwarders[forwardedSignal])
32
+ if (signal) return process.kill(process.pid, signal)
33
+ process.exit(typeof code === "number" ? code : 0)
34
+ })
35
+ }
36
+
37
+ const envPath = process.env.METTLE_BIN_PATH
38
+ const scriptDir = path.dirname(fs.realpathSync(__filename))
39
+ const wrapperDir = path.dirname(scriptDir)
40
+ const command = path.basename(__filename).replace(/\.cjs$/, "")
41
+ const platform = { darwin: "darwin", linux: "linux", win32: "windows" }[os.platform()] || os.platform()
42
+ const arch = { x64: "x64", arm64: "arm64", arm: "arm" }[os.arch()] || os.arch()
43
+ const base = `@mettlelabs/mettle-${platform}-${arch}`
44
+ const binary = platform === "windows" ? "mettle.exe" : "mettle"
45
+
46
+ // AVX2 support is a fixed property of the machine, so probe it once and cache the result next
47
+ // to the launcher. The Windows probe spawns PowerShell, which is too slow to run on every
48
+ // invocation. Binary resolution itself stays dynamic so an `npm update` is picked up at once.
49
+ function supportsAvx2() {
50
+ if (arch !== "x64") return false
51
+ const cacheFile = path.join(scriptDir, `.${command}-avx2`)
52
+ try {
53
+ const value = fs.readFileSync(cacheFile, "utf8").trim()
54
+ if (value === "1") return true
55
+ if (value === "0") return false
56
+ } catch {}
57
+ const result = detectAvx2()
58
+ try {
59
+ fs.writeFileSync(cacheFile, result ? "1" : "0")
60
+ } catch {}
61
+ return result
62
+ }
63
+
64
+ function detectAvx2() {
65
+ if (arch !== "x64") return false
66
+ if (platform === "linux") {
67
+ try {
68
+ return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
69
+ } catch {
70
+ return false
71
+ }
72
+ }
73
+ if (platform === "darwin") {
74
+ try {
75
+ const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], { encoding: "utf8", timeout: 1500 })
76
+ return result.status === 0 && (result.stdout || "").trim() === "1"
77
+ } catch {
78
+ return false
79
+ }
80
+ }
81
+ if (platform === "windows") {
82
+ const command =
83
+ '(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
84
+ for (const executable of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
85
+ try {
86
+ const result = childProcess.spawnSync(executable, ["-NoProfile", "-NonInteractive", "-Command", command], {
87
+ encoding: "utf8",
88
+ timeout: 3000,
89
+ windowsHide: true,
90
+ })
91
+ if (result.status !== 0) continue
92
+ const output = (result.stdout || "").trim().toLowerCase()
93
+ if (output === "true" || output === "1") return true
94
+ if (output === "false" || output === "0") return false
95
+ } catch {}
96
+ }
97
+ }
98
+ return false
99
+ }
100
+
101
+ const names = (() => {
102
+ const baseline = arch === "x64" && !supportsAvx2()
103
+ if (platform === "linux") {
104
+ const musl = (() => {
105
+ try {
106
+ if (fs.existsSync("/etc/alpine-release")) return true
107
+ const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
108
+ return ((result.stdout || "") + (result.stderr || "")).toLowerCase().includes("musl")
109
+ } catch {
110
+ return false
111
+ }
112
+ })()
113
+ if (musl)
114
+ return arch === "x64"
115
+ ? baseline
116
+ ? [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
117
+ : [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
118
+ : [`${base}-musl`, base]
119
+ return arch === "x64"
120
+ ? baseline
121
+ ? [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
122
+ : [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
123
+ : [base, `${base}-musl`]
124
+ }
125
+ return arch === "x64" ? (baseline ? [`${base}-baseline`, base] : [base, `${base}-baseline`]) : [base]
126
+ })()
127
+
128
+ function findBinary(startDir) {
129
+ let current = startDir
130
+ for (;;) {
131
+ const modules = path.join(current, "node_modules")
132
+ if (fs.existsSync(modules))
133
+ for (const name of names) {
134
+ const candidate = path.join(modules, name, "bin", binary)
135
+ if (fs.existsSync(candidate)) return candidate
136
+ }
137
+ const parent = path.dirname(current)
138
+ if (parent === current) return
139
+ current = parent
140
+ }
141
+ }
142
+
143
+ const resolved = envPath || findBinary(scriptDir)
144
+ if (!resolved) {
145
+ console.error(
146
+ `It seems that your package manager failed to install the right ${command} CLI package. Try manually installing ` +
147
+ names.map((name) => `"${name}"`).join(" or ") +
148
+ " package",
149
+ )
150
+ process.exit(1)
151
+ }
152
+ run(resolved)
package/package.json CHANGED
@@ -1,20 +1,35 @@
1
1
  {
2
2
  "name": "@mettlelabs/mettle",
3
- "version": "0.0.0-beta.1-darwin-arm64",
4
- "license": "UNLICENSED",
3
+ "version": "0.0.0-beta.10",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/prolabsinc/mettle-cli.git"
8
+ },
9
+ "bin": {
10
+ "mettle": "./bin/mettle.cjs"
11
+ },
5
12
  "os": [
6
- "darwin"
13
+ "darwin",
14
+ "linux",
15
+ "win32"
7
16
  ],
8
17
  "cpu": [
9
- "arm64"
10
- ],
11
- "files": [
12
- "bin",
13
- "harness",
14
- "THIRD_PARTY_NOTICES.md"
18
+ "arm64",
19
+ "x64"
15
20
  ],
16
- "repository": {
17
- "type": "git",
18
- "url": "git+https://github.com/prolabsinc/mettle-cli.git"
21
+ "optionalDependencies": {
22
+ "@mettlelabs/mettle-darwin-arm64": "0.0.0-beta.10",
23
+ "@mettlelabs/mettle-darwin-x64": "0.0.0-beta.10",
24
+ "@mettlelabs/mettle-darwin-x64-baseline": "0.0.0-beta.10",
25
+ "@mettlelabs/mettle-linux-arm64": "0.0.0-beta.10",
26
+ "@mettlelabs/mettle-linux-arm64-musl": "0.0.0-beta.10",
27
+ "@mettlelabs/mettle-linux-x64": "0.0.0-beta.10",
28
+ "@mettlelabs/mettle-linux-x64-baseline": "0.0.0-beta.10",
29
+ "@mettlelabs/mettle-linux-x64-baseline-musl": "0.0.0-beta.10",
30
+ "@mettlelabs/mettle-linux-x64-musl": "0.0.0-beta.10",
31
+ "@mettlelabs/mettle-windows-arm64": "0.0.0-beta.10",
32
+ "@mettlelabs/mettle-windows-x64": "0.0.0-beta.10",
33
+ "@mettlelabs/mettle-windows-x64-baseline": "0.0.0-beta.10"
19
34
  }
20
- }
35
+ }