@xulongzhe/clawbench 0.57.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/bin/clawbench.js +63 -0
- package/install.js +39 -0
- package/package.json +27 -0
package/bin/clawbench.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from "child_process";
|
|
3
|
+
import { resolve, dirname } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import os from "os";
|
|
6
|
+
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
|
|
9
|
+
const PLATFORM_MAP = {
|
|
10
|
+
"linux-x64": "@xulongzhe/clawbench-linux-x64",
|
|
11
|
+
"linux-arm64": "@xulongzhe/clawbench-linux-arm64",
|
|
12
|
+
"darwin-x64": "@xulongzhe/clawbench-darwin-x64",
|
|
13
|
+
"darwin-arm64": "@xulongzhe/clawbench-darwin-arm64",
|
|
14
|
+
"win32-x64": "@xulongzhe/clawbench-win32-x64",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const key = `${process.platform}-${process.arch}`;
|
|
18
|
+
const pkg = PLATFORM_MAP[key];
|
|
19
|
+
|
|
20
|
+
if (!pkg) {
|
|
21
|
+
console.error(`clawbench: 不支持的平台 ${key}`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const binName = process.platform === "win32" ? "clawbench.exe" : "clawbench";
|
|
26
|
+
|
|
27
|
+
let binPath;
|
|
28
|
+
if (process.env.CLAWBENCH_BINARY_PATH) {
|
|
29
|
+
binPath = process.env.CLAWBENCH_BINARY_PATH;
|
|
30
|
+
} else {
|
|
31
|
+
try {
|
|
32
|
+
const platformPkgPath = require.resolve(`${pkg}/package.json`);
|
|
33
|
+
const platformDir = dirname(platformPkgPath);
|
|
34
|
+
binPath = resolve(platformDir, "bin", binName);
|
|
35
|
+
} catch {
|
|
36
|
+
console.error(`clawbench: 平台包 "${pkg}" 未安装`);
|
|
37
|
+
console.error(` 请运行: npm install ${pkg}`);
|
|
38
|
+
console.error(` 或设置环境变量: CLAWBENCH_BINARY_PATH=/path/to/clawbench`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const child = spawn(binPath, process.argv.slice(2), {
|
|
44
|
+
stdio: "inherit",
|
|
45
|
+
env: { ...process.env },
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// 转发信号到子进程
|
|
49
|
+
process.on("SIGINT", () => child.kill("SIGINT"));
|
|
50
|
+
process.on("SIGTERM", () => child.kill("SIGTERM"));
|
|
51
|
+
|
|
52
|
+
child.on("exit", (code, signal) => {
|
|
53
|
+
if (signal) {
|
|
54
|
+
const sigNum = os.constants.signals[signal] ?? 0;
|
|
55
|
+
process.exit(128 + sigNum);
|
|
56
|
+
}
|
|
57
|
+
process.exit(code ?? 1);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
child.on("error", (err) => {
|
|
61
|
+
console.error(`clawbench: 启动失败: ${err.message}`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
});
|
package/install.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// postinstall fallback: 当 optionalDependencies 被禁用时,
|
|
3
|
+
// 提示用户手动安装平台包。
|
|
4
|
+
import { readFileSync } from "fs";
|
|
5
|
+
import { dirname, join } from "path";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
|
|
10
|
+
const PLATFORM_MAP = {
|
|
11
|
+
"linux-x64": "@xulongzhe/clawbench-linux-x64",
|
|
12
|
+
"linux-arm64": "@xulongzhe/clawbench-linux-arm64",
|
|
13
|
+
"darwin-x64": "@xulongzhe/clawbench-darwin-x64",
|
|
14
|
+
"darwin-arm64": "@xulongzhe/clawbench-darwin-arm64",
|
|
15
|
+
"win32-x64": "@xulongzhe/clawbench-win32-x64",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const key = `${process.platform}-${process.arch}`;
|
|
19
|
+
const pkg = PLATFORM_MAP[key];
|
|
20
|
+
|
|
21
|
+
if (!pkg) {
|
|
22
|
+
// 不支持的平台,静默跳过
|
|
23
|
+
process.exit(0);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 检查平台包是否已通过 optionalDependencies 安装
|
|
27
|
+
try {
|
|
28
|
+
require.resolve(`${pkg}/package.json`);
|
|
29
|
+
process.exit(0); // 已安装
|
|
30
|
+
} catch {
|
|
31
|
+
// 未安装
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 读取主包版本
|
|
35
|
+
const mainPkg = JSON.parse(readFileSync(join(__dirname, "package.json"), "utf8"));
|
|
36
|
+
const version = mainPkg.version;
|
|
37
|
+
|
|
38
|
+
console.log(`clawbench: 平台包未安装,请手动安装: npm install ${pkg}@${version}`);
|
|
39
|
+
console.log(` 或设置环境变量: CLAWBENCH_BINARY_PATH=/path/to/clawbench`);
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xulongzhe/clawbench",
|
|
3
|
+
"version": "0.57.2",
|
|
4
|
+
"description": "Mobile-first AI workstation — Go backend + Vue3 frontend",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"clawbench": "bin/clawbench.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/",
|
|
11
|
+
"install.js"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"postinstall": "node install.js"
|
|
15
|
+
},
|
|
16
|
+
"optionalDependencies": {
|
|
17
|
+
"@xulongzhe/clawbench-linux-x64": "0.57.2",
|
|
18
|
+
"@xulongzhe/clawbench-linux-arm64": "0.57.2",
|
|
19
|
+
"@xulongzhe/clawbench-darwin-x64": "0.57.2",
|
|
20
|
+
"@xulongzhe/clawbench-darwin-arm64": "0.57.2",
|
|
21
|
+
"@xulongzhe/clawbench-win32-x64": "0.57.2"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=14"
|
|
25
|
+
},
|
|
26
|
+
"license": "MIT"
|
|
27
|
+
}
|