@meowo/aproxy 0.1.0-alpha.7
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 +41 -0
- package/bin/aproxy.js +65 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @meowo/aproxy
|
|
2
|
+
|
|
3
|
+
Local API proxy with **infinite retries** for agent workloads.
|
|
4
|
+
|
|
5
|
+
Upstream rate limits, broken streams, timeouts — aProxy catches the request
|
|
6
|
+
locally: on failure it retries without limit (exponential backoff, capped and
|
|
7
|
+
configurable), keeps streaming responses alive with injected SSE heartbeats,
|
|
8
|
+
and replays the successful response byte-for-byte. Your client never notices
|
|
9
|
+
the storm upstream; it only notices that the request took a little longer.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install -g @meowo/aproxy
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The right platform binary (windows / linux-glibc / linux-musl / macOS, x64 or
|
|
18
|
+
arm64) is installed automatically via `optionalDependencies` — no postinstall
|
|
19
|
+
downloads, everything comes from the npm registry.
|
|
20
|
+
|
|
21
|
+
## Quick start
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
# 1. Configure the upstream (writes ~/.aproxy/config.toml)
|
|
25
|
+
aproxy config --baseurl https://api.anthropic.com --api-key sk-ant-...
|
|
26
|
+
|
|
27
|
+
# 2. Start (background daemon)
|
|
28
|
+
aproxy
|
|
29
|
+
|
|
30
|
+
# 3. Point your agent's API base URL at the local proxy
|
|
31
|
+
# https://api.anthropic.com → http://127.0.0.1:12345
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Links
|
|
35
|
+
|
|
36
|
+
- Full documentation: <https://github.com/MoYeRanqianzhi/aProxy>
|
|
37
|
+
- Releases: <https://github.com/MoYeRanqianzhi/aProxy/releases>
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
MIT
|
package/bin/aproxy.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// aProxy npm 入口转发器(esbuild/rollup 同款多平台包模式)。
|
|
5
|
+
//
|
|
6
|
+
// 原理:npm 主包 @meowo/aproxy 只含这个 JS 脚本;真正的二进制在
|
|
7
|
+
// 各平台子包里(optionalDependencies),npm install 时按 os/cpu/libc 字段
|
|
8
|
+
// 自动只装当前平台的那一个——全程 registry 内分发,无二次网络下载。
|
|
9
|
+
// 本脚本运行时解析出平台子包内的二进制路径,spawn 并透传参数/stdio/退出码。
|
|
10
|
+
|
|
11
|
+
const { spawnSync } = require('child_process');
|
|
12
|
+
const path = require('path');
|
|
13
|
+
|
|
14
|
+
const PKG_PREFIX = '@meowo/aproxy-';
|
|
15
|
+
|
|
16
|
+
// 平台 → 子包后缀。linux 需区分 glibc/musl(两套静态链接产物)。
|
|
17
|
+
function platformPackage() {
|
|
18
|
+
const { platform, arch } = process;
|
|
19
|
+
if (platform === 'win32' && arch === 'x64') return PKG_PREFIX + 'windows-x64';
|
|
20
|
+
if (platform === 'darwin' && arch === 'arm64') return PKG_PREFIX + 'darwin-arm64';
|
|
21
|
+
if (platform === 'darwin' && arch === 'x64') return PKG_PREFIX + 'darwin-x64';
|
|
22
|
+
if (platform === 'linux' && arch === 'x64') {
|
|
23
|
+
return PKG_PREFIX + 'linux-x64' + (isMusl() ? '-musl' : '');
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// process.report 的 glibcVersionRuntime 只在 glibc 构建的 Node 上有值;
|
|
29
|
+
// musl 环境(Alpine 等)拿不到它。report 不可用时保守回退 gnu(更常见)。
|
|
30
|
+
function isMusl() {
|
|
31
|
+
try {
|
|
32
|
+
if (!process.report || !process.report.getReport) return false;
|
|
33
|
+
return !process.report.getReport().header.glibcVersionRuntime;
|
|
34
|
+
} catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const pkg = platformPackage();
|
|
40
|
+
if (!pkg) {
|
|
41
|
+
console.error(
|
|
42
|
+
`aproxy: 不支持的平台 ${process.platform}-${process.arch}。` +
|
|
43
|
+
'请从 https://github.com/MoYeRanqianzhi/aProxy/releases 直接下载二进制。'
|
|
44
|
+
);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let bin;
|
|
49
|
+
try {
|
|
50
|
+
const pkgDir = path.dirname(require.resolve(pkg + '/package.json'));
|
|
51
|
+
bin = path.join(pkgDir, 'bin', process.platform === 'win32' ? 'aproxy.exe' : 'aproxy');
|
|
52
|
+
} catch {
|
|
53
|
+
// optionalDependencies 被 --omit=optional 跳过、或 npm 平台过滤未装上时走到这里
|
|
54
|
+
console.error(
|
|
55
|
+
`aproxy: 平台包 ${pkg} 未安装。请重新安装:npm install -g @meowo/aproxy`
|
|
56
|
+
);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const result = spawnSync(bin, process.argv.slice(2), { stdio: 'inherit' });
|
|
61
|
+
if (result.error) {
|
|
62
|
+
console.error('aproxy: 无法启动二进制:' + result.error.message);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@meowo/aproxy",
|
|
3
|
+
"version": "0.1.0-alpha.7",
|
|
4
|
+
"description": "Local API proxy with infinite retries for agent workloads",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/MoYeRanqianzhi/aProxy.git"
|
|
9
|
+
},
|
|
10
|
+
"keywords": ["proxy", "retry", "api", "agent", "llm", "claude"],
|
|
11
|
+
"bin": {
|
|
12
|
+
"aproxy": "bin/aproxy.js"
|
|
13
|
+
},
|
|
14
|
+
"files": ["bin/", "README.md"],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18"
|
|
17
|
+
},
|
|
18
|
+
"optionalDependencies": {
|
|
19
|
+
"@meowo/aproxy-windows-x64": "0.1.0-alpha.7",
|
|
20
|
+
"@meowo/aproxy-linux-x64": "0.1.0-alpha.7",
|
|
21
|
+
"@meowo/aproxy-linux-x64-musl": "0.1.0-alpha.7",
|
|
22
|
+
"@meowo/aproxy-darwin-arm64": "0.1.0-alpha.7",
|
|
23
|
+
"@meowo/aproxy-darwin-x64": "0.1.0-alpha.7"
|
|
24
|
+
}
|
|
25
|
+
}
|