@meowo/aproxy 0.1.0-alpha.9 → 0.1.0-rc.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/bin/aproxy.js +63 -20
- package/package.json +11 -11
- package/skills/aproxy-skills.zip +0 -0
package/bin/aproxy.js
CHANGED
|
@@ -3,18 +3,28 @@
|
|
|
3
3
|
|
|
4
4
|
// aProxy npm 入口转发器(esbuild/rollup 同款多平台包模式)。
|
|
5
5
|
//
|
|
6
|
-
// 原理:npm
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
6
|
+
// 原理:npm 主包(@meowo/aproxy / @meowo/aproxy-format)只含这个 JS 脚本;
|
|
7
|
+
// 真正的二进制在各平台子包里(optionalDependencies),npm install 时按
|
|
8
|
+
// os/cpu/libc 字段自动只装当前平台的那一个——全程 registry 内分发,无二次
|
|
9
|
+
// 网络下载。本脚本运行时解析出平台子包内的二进制路径,spawn 并透传参数/
|
|
10
|
+
// stdio/退出码。
|
|
11
|
+
//
|
|
12
|
+
// 包名自检测:wrapper 由主包 package.json 的 name 推导子包前缀与二进制名
|
|
13
|
+
// (@meowo/aproxy → 子包 @meowo/aproxy-*、二进制 aproxy;@meowo/aproxy-format
|
|
14
|
+
// → 同理)——一份脚本两组通用,改包名时无需同步此处。
|
|
10
15
|
|
|
11
16
|
const { spawnSync } = require('child_process');
|
|
12
17
|
const path = require('path');
|
|
13
18
|
|
|
14
|
-
const
|
|
19
|
+
const SELF_NAME = path.basename(require('../package.json').name); // aproxy | aproxy-format
|
|
20
|
+
const PKG_PREFIX = require('../package.json').name + '-';
|
|
21
|
+
|
|
22
|
+
// gnu 产物能运行的 glibc 下限。必须与 .github/workflows/release.yml 里 gnu 构建的
|
|
23
|
+
// glibc 下限、scripts/install.sh 的 MIN_GLIBC 保持一致;低于它的系统改用 musl 产物。
|
|
24
|
+
const MIN_GLIBC = '2.28';
|
|
15
25
|
|
|
16
|
-
// 平台 → 子包后缀。linux 需区分 glibc/musl
|
|
17
|
-
function platformPackage() {
|
|
26
|
+
// 平台 → 子包后缀。linux 需区分 glibc/musl(两套产物);forceMusl 用于 glibc 过老的系统。
|
|
27
|
+
function platformPackage(forceMusl) {
|
|
18
28
|
const { platform, arch } = process;
|
|
19
29
|
if (platform === 'win32') {
|
|
20
30
|
if (arch === 'x64') return PKG_PREFIX + 'windows-x64';
|
|
@@ -26,29 +36,40 @@ function platformPackage() {
|
|
|
26
36
|
if (arch === 'x64') return PKG_PREFIX + 'darwin-x64';
|
|
27
37
|
}
|
|
28
38
|
if (platform === 'linux' && arch === 'x64') {
|
|
29
|
-
return PKG_PREFIX + 'linux-x64' + (
|
|
39
|
+
return PKG_PREFIX + 'linux-x64' + (forceMusl ? '-musl' : '');
|
|
30
40
|
}
|
|
31
41
|
if (platform === 'linux' && arch === 'arm64') {
|
|
32
|
-
return PKG_PREFIX + 'linux-arm64' + (
|
|
42
|
+
return PKG_PREFIX + 'linux-arm64' + (forceMusl ? '-musl' : '');
|
|
33
43
|
}
|
|
34
44
|
return null;
|
|
35
45
|
}
|
|
36
46
|
|
|
37
|
-
// process.report 的 glibcVersionRuntime 只在 glibc 构建的 Node 上有值;
|
|
38
|
-
//
|
|
39
|
-
|
|
47
|
+
// process.report 的 glibcVersionRuntime 只在 glibc 构建的 Node 上有值;musl 环境
|
|
48
|
+
// (Alpine 等)拿不到它。返回值:版本字符串(glibc)/ null(report 可用但无 glibc,
|
|
49
|
+
// 即 musl)/ undefined(report 不可用,无法判断,保守按 gnu 处理)。
|
|
50
|
+
function glibcRuntime() {
|
|
40
51
|
try {
|
|
41
|
-
if (!process.report || !process.report.getReport) return
|
|
42
|
-
return
|
|
52
|
+
if (!process.report || !process.report.getReport) return undefined;
|
|
53
|
+
return process.report.getReport().header.glibcVersionRuntime || null;
|
|
43
54
|
} catch {
|
|
44
|
-
return
|
|
55
|
+
return undefined;
|
|
45
56
|
}
|
|
46
57
|
}
|
|
47
58
|
|
|
48
|
-
|
|
59
|
+
// 'X.Y' 版本比较:a 是否严格低于 b
|
|
60
|
+
function versionLt(a, b) {
|
|
61
|
+
const [a1, a2] = a.split('.').map((n) => parseInt(n, 10) || 0);
|
|
62
|
+
const [b1, b2] = b.split('.').map((n) => parseInt(n, 10) || 0);
|
|
63
|
+
return a1 < b1 || (a1 === b1 && a2 < b2);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const glibc = process.platform === 'linux' ? glibcRuntime() : undefined;
|
|
67
|
+
const glibcTooOld = typeof glibc === 'string' && versionLt(glibc, MIN_GLIBC);
|
|
68
|
+
|
|
69
|
+
const pkg = platformPackage(glibc === null || glibcTooOld);
|
|
49
70
|
if (!pkg) {
|
|
50
71
|
console.error(
|
|
51
|
-
|
|
72
|
+
`${SELF_NAME}: 不支持的平台 ${process.platform}-${process.arch}。` +
|
|
52
73
|
'请从 https://github.com/MoYeRanqianzhi/aProxy/releases 直接下载二进制。'
|
|
53
74
|
);
|
|
54
75
|
process.exit(1);
|
|
@@ -57,18 +78,40 @@ if (!pkg) {
|
|
|
57
78
|
let bin;
|
|
58
79
|
try {
|
|
59
80
|
const pkgDir = path.dirname(require.resolve(pkg + '/package.json'));
|
|
60
|
-
bin = path.join(pkgDir, 'bin', process.platform === 'win32' ?
|
|
81
|
+
bin = path.join(pkgDir, 'bin', process.platform === 'win32' ? `${SELF_NAME}.exe` : SELF_NAME);
|
|
61
82
|
} catch {
|
|
83
|
+
if (glibcTooOld) {
|
|
84
|
+
// 不 spawn 一个必然在动态加载阶段失败的 gnu 二进制(报错晦涩):直接说清原因与补救办法。
|
|
85
|
+
// npm 按 libc 字段过滤平台包,glibc 系统上默认不会装 musl 子包,所以这里通常走到。
|
|
86
|
+
const forceMusl = `npm install -g ${pkg} --force(npm 默认按 libc 过滤,不会在 glibc 系统上装它)`;
|
|
87
|
+
const remedies =
|
|
88
|
+
SELF_NAME === 'aproxy'
|
|
89
|
+
? [
|
|
90
|
+
'改用安装脚本(会自动选用静态链接的 musl 产物):',
|
|
91
|
+
' curl -fsSL https://raw.githubusercontent.com/MoYeRanqianzhi/aProxy/main/scripts/install.sh | sh',
|
|
92
|
+
`或强制安装 musl 平台包:${forceMusl}`,
|
|
93
|
+
]
|
|
94
|
+
: [`强制安装 musl 平台包:${forceMusl}`];
|
|
95
|
+
console.error(
|
|
96
|
+
[
|
|
97
|
+
`${SELF_NAME}: 本机 glibc ${glibc} 低于 ${MIN_GLIBC},预编译的 gnu 二进制无法运行,且未安装 musl 平台包 ${pkg}。`,
|
|
98
|
+
'补救办法:',
|
|
99
|
+
...remedies.map((r) => (r.startsWith(' ') ? r : ` - ${r}`)),
|
|
100
|
+
'或从 https://github.com/MoYeRanqianzhi/aProxy/releases 下载文件名含 unknown-linux-musl 的产物。',
|
|
101
|
+
].join('\n')
|
|
102
|
+
);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
62
105
|
// optionalDependencies 被 --omit=optional 跳过、或 npm 平台过滤未装上时走到这里
|
|
63
106
|
console.error(
|
|
64
|
-
|
|
107
|
+
`${SELF_NAME}: 平台包 ${pkg} 未安装。请重新安装:npm install -g ${PKG_PREFIX.replace(/-$/, '')}`
|
|
65
108
|
);
|
|
66
109
|
process.exit(1);
|
|
67
110
|
}
|
|
68
111
|
|
|
69
112
|
const result = spawnSync(bin, process.argv.slice(2), { stdio: 'inherit' });
|
|
70
113
|
if (result.error) {
|
|
71
|
-
console.error(
|
|
114
|
+
console.error(`${SELF_NAME}: 无法启动二进制:` + result.error.message);
|
|
72
115
|
process.exit(1);
|
|
73
116
|
}
|
|
74
117
|
process.exit(result.status === null ? 1 : result.status);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meowo/aproxy",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-rc.1",
|
|
4
4
|
"description": "Local API proxy with infinite retries for agent workloads",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -11,19 +11,19 @@
|
|
|
11
11
|
"bin": {
|
|
12
12
|
"aproxy": "bin/aproxy.js"
|
|
13
13
|
},
|
|
14
|
-
"files": ["bin/", "README.md"],
|
|
14
|
+
"files": ["bin/", "README.md", "skills/"],
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": ">=18"
|
|
17
17
|
},
|
|
18
18
|
"optionalDependencies": {
|
|
19
|
-
"@meowo/aproxy-windows-x64": "0.1.0-
|
|
20
|
-
"@meowo/aproxy-windows-ia32": "0.1.0-
|
|
21
|
-
"@meowo/aproxy-windows-arm64": "0.1.0-
|
|
22
|
-
"@meowo/aproxy-linux-x64": "0.1.0-
|
|
23
|
-
"@meowo/aproxy-linux-x64-musl": "0.1.0-
|
|
24
|
-
"@meowo/aproxy-linux-arm64": "0.1.0-
|
|
25
|
-
"@meowo/aproxy-linux-arm64-musl": "0.1.0-
|
|
26
|
-
"@meowo/aproxy-darwin-arm64": "0.1.0-
|
|
27
|
-
"@meowo/aproxy-darwin-x64": "0.1.0-
|
|
19
|
+
"@meowo/aproxy-windows-x64": "0.1.0-rc.1",
|
|
20
|
+
"@meowo/aproxy-windows-ia32": "0.1.0-rc.1",
|
|
21
|
+
"@meowo/aproxy-windows-arm64": "0.1.0-rc.1",
|
|
22
|
+
"@meowo/aproxy-linux-x64": "0.1.0-rc.1",
|
|
23
|
+
"@meowo/aproxy-linux-x64-musl": "0.1.0-rc.1",
|
|
24
|
+
"@meowo/aproxy-linux-arm64": "0.1.0-rc.1",
|
|
25
|
+
"@meowo/aproxy-linux-arm64-musl": "0.1.0-rc.1",
|
|
26
|
+
"@meowo/aproxy-darwin-arm64": "0.1.0-rc.1",
|
|
27
|
+
"@meowo/aproxy-darwin-x64": "0.1.0-rc.1"
|
|
28
28
|
}
|
|
29
29
|
}
|
|
Binary file
|