@meowo/aproxy-format 0.1.0
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 +42 -0
- package/bin/aproxy-format.js +80 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
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 x64/x86/arm64, linux x64/arm64 with glibc
|
|
18
|
+
or musl, macOS arm64/x64) is installed automatically via
|
|
19
|
+
`optionalDependencies` — no postinstall downloads, everything comes from the
|
|
20
|
+
npm registry.
|
|
21
|
+
|
|
22
|
+
## Quick start
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
# 1. Configure the upstream (writes ~/.aproxy/config.toml)
|
|
26
|
+
aproxy config --baseurl https://api.anthropic.com --api-key sk-ant-...
|
|
27
|
+
|
|
28
|
+
# 2. Start (background daemon)
|
|
29
|
+
aproxy
|
|
30
|
+
|
|
31
|
+
# 3. Point your agent's API base URL at the local proxy
|
|
32
|
+
# https://api.anthropic.com → http://127.0.0.1:12345
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Links
|
|
36
|
+
|
|
37
|
+
- Full documentation: <https://github.com/MoYeRanqianzhi/aProxy>
|
|
38
|
+
- Releases: <https://github.com/MoYeRanqianzhi/aProxy/releases>
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
MIT
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// aProxy npm 入口转发器(esbuild/rollup 同款多平台包模式)。
|
|
5
|
+
//
|
|
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
|
+
// → 同理)——一份脚本两组通用,改包名时无需同步此处。
|
|
15
|
+
|
|
16
|
+
const { spawnSync } = require('child_process');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
|
|
19
|
+
const SELF_NAME = path.basename(require('../package.json').name); // aproxy | aproxy-format
|
|
20
|
+
const PKG_PREFIX = require('../package.json').name + '-';
|
|
21
|
+
|
|
22
|
+
// 平台 → 子包后缀。linux 需区分 glibc/musl(两套静态链接产物)。
|
|
23
|
+
function platformPackage() {
|
|
24
|
+
const { platform, arch } = process;
|
|
25
|
+
if (platform === 'win32') {
|
|
26
|
+
if (arch === 'x64') return PKG_PREFIX + 'windows-x64';
|
|
27
|
+
if (arch === 'ia32') return PKG_PREFIX + 'windows-ia32';
|
|
28
|
+
if (arch === 'arm64') return PKG_PREFIX + 'windows-arm64';
|
|
29
|
+
}
|
|
30
|
+
if (platform === 'darwin') {
|
|
31
|
+
if (arch === 'arm64') return PKG_PREFIX + 'darwin-arm64';
|
|
32
|
+
if (arch === 'x64') return PKG_PREFIX + 'darwin-x64';
|
|
33
|
+
}
|
|
34
|
+
if (platform === 'linux' && arch === 'x64') {
|
|
35
|
+
return PKG_PREFIX + 'linux-x64' + (isMusl() ? '-musl' : '');
|
|
36
|
+
}
|
|
37
|
+
if (platform === 'linux' && arch === 'arm64') {
|
|
38
|
+
return PKG_PREFIX + 'linux-arm64' + (isMusl() ? '-musl' : '');
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// process.report 的 glibcVersionRuntime 只在 glibc 构建的 Node 上有值;
|
|
44
|
+
// musl 环境(Alpine 等)拿不到它。report 不可用时保守回退 gnu(更常见)。
|
|
45
|
+
function isMusl() {
|
|
46
|
+
try {
|
|
47
|
+
if (!process.report || !process.report.getReport) return false;
|
|
48
|
+
return !process.report.getReport().header.glibcVersionRuntime;
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const pkg = platformPackage();
|
|
55
|
+
if (!pkg) {
|
|
56
|
+
console.error(
|
|
57
|
+
`${SELF_NAME}: 不支持的平台 ${process.platform}-${process.arch}。` +
|
|
58
|
+
'请从 https://github.com/MoYeRanqianzhi/aProxy/releases 直接下载二进制。'
|
|
59
|
+
);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let bin;
|
|
64
|
+
try {
|
|
65
|
+
const pkgDir = path.dirname(require.resolve(pkg + '/package.json'));
|
|
66
|
+
bin = path.join(pkgDir, 'bin', process.platform === 'win32' ? `${SELF_NAME}.exe` : SELF_NAME);
|
|
67
|
+
} catch {
|
|
68
|
+
// optionalDependencies 被 --omit=optional 跳过、或 npm 平台过滤未装上时走到这里
|
|
69
|
+
console.error(
|
|
70
|
+
`${SELF_NAME}: 平台包 ${pkg} 未安装。请重新安装:npm install -g ${PKG_PREFIX.replace(/-$/, '')}`
|
|
71
|
+
);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const result = spawnSync(bin, process.argv.slice(2), { stdio: 'inherit' });
|
|
76
|
+
if (result.error) {
|
|
77
|
+
console.error(`${SELF_NAME}: 无法启动二进制:` + result.error.message);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@meowo/aproxy-format",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official example format program for aProxy (protocol conversion, key rotation, multi-channel aggregation)",
|
|
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-format": "bin/aproxy-format.js"
|
|
13
|
+
},
|
|
14
|
+
"files": ["bin/"],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18"
|
|
17
|
+
},
|
|
18
|
+
"optionalDependencies": {
|
|
19
|
+
"@meowo/aproxy-format-windows-x64": "0.1.0",
|
|
20
|
+
"@meowo/aproxy-format-windows-ia32": "0.1.0",
|
|
21
|
+
"@meowo/aproxy-format-windows-arm64": "0.1.0",
|
|
22
|
+
"@meowo/aproxy-format-linux-x64": "0.1.0",
|
|
23
|
+
"@meowo/aproxy-format-linux-x64-musl": "0.1.0",
|
|
24
|
+
"@meowo/aproxy-format-linux-arm64": "0.1.0",
|
|
25
|
+
"@meowo/aproxy-format-linux-arm64-musl": "0.1.0",
|
|
26
|
+
"@meowo/aproxy-format-darwin-arm64": "0.1.0",
|
|
27
|
+
"@meowo/aproxy-format-darwin-x64": "0.1.0"
|
|
28
|
+
}
|
|
29
|
+
}
|