@simontan/llm-gateway 0.2.1 → 0.3.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.en.md CHANGED
@@ -195,3 +195,27 @@ Add a provider in `config.yaml`, then set `{PROVIDER}_API_KEY` in `.env`. Provid
195
195
  - Put a reverse proxy in front (TLS, WAF, IP controls)
196
196
  - For multi-instance deployments, use distributed rate limiting (Redis / Envoy / Nginx)
197
197
  - Keep API keys in environment variables only, never commit them
198
+
199
+ ## Cross-platform npm packaging (zigbuild)
200
+
201
+ Install Zig and cargo-zigbuild first:
202
+
203
+ ```bash
204
+ brew install zig
205
+ cargo install cargo-zigbuild
206
+ ```
207
+
208
+ Run the following commands to build and pack the npm package:
209
+
210
+ ```bash
211
+ cargo zigbuild --release --target aarch64-apple-darwin
212
+ cargo zigbuild --release --target x86_64-apple-darwin
213
+ cargo zigbuild --release --target x86_64-unknown-linux-gnu
214
+ cargo zigbuild --release --target x86_64-pc-windows-gnu
215
+ npm run prepare:binaries
216
+ npm pack
217
+ ```
218
+
219
+ Artifacts:
220
+ - Rust binaries are generated at `target/<triple>/release/llm-gateway`
221
+ - The npm tarball is generated in the project root by `npm pack`
package/README.zh.md CHANGED
@@ -195,3 +195,27 @@ sequenceDiagram
195
195
  - 建议在网关前加反向代理(TLS、WAF、IP 限制)
196
196
  - 多实例部署时,建议使用分布式限流(Redis / Envoy / Nginx)
197
197
  - API keys 仅放在环境变量,不要提交到仓库
198
+
199
+ ## npm 跨平台打包(zigbuild)
200
+
201
+ 先安装 Zig 和 cargo-zigbuild:
202
+
203
+ ```bash
204
+ brew install zig
205
+ cargo install cargo-zigbuild
206
+ ```
207
+
208
+ 执行以下命令构建并打包 npm 包:
209
+
210
+ ```bash
211
+ cargo zigbuild --release --target aarch64-apple-darwin
212
+ cargo zigbuild --release --target x86_64-apple-darwin
213
+ cargo zigbuild --release --target x86_64-unknown-linux-gnu
214
+ cargo zigbuild --release --target x86_64-pc-windows-gnu
215
+ npm run prepare:binaries
216
+ npm pack
217
+ ```
218
+
219
+ 产物说明:
220
+ - Rust 二进制分别位于 `target/<triple>/release/llm-gateway`
221
+ - npm 包文件由 `npm pack` 生成在项目根目录
@@ -3,11 +3,15 @@ const fs = require('node:fs')
3
3
 
4
4
  function resolveBinary() {
5
5
  const key = `${process.platform}-${process.arch}`
6
- if (process.platform !== 'darwin') {
7
- throw new Error(`Unsupported platform: ${key}. This package only supports macOS.`)
6
+ const supportedPlatforms = new Set(['darwin-arm64', 'darwin-x64', 'linux-x64', 'win32-x64'])
7
+ if (!supportedPlatforms.has(key)) {
8
+ throw new Error(
9
+ `Unsupported platform: ${key}. This package supports darwin-arm64, darwin-x64, linux-x64 (glibc), and win32-x64.`
10
+ )
8
11
  }
9
12
 
10
- const binaryPath = path.resolve(__dirname, '..', 'npm-bin', key, 'llm-gateway')
13
+ const binaryName = process.platform === 'win32' ? 'llm-gateway.exe' : 'llm-gateway'
14
+ const binaryPath = path.resolve(__dirname, '..', 'npm-bin', key, binaryName)
11
15
  if (!fs.existsSync(binaryPath)) {
12
16
  throw new Error(`Missing binary: ${binaryPath}. Run: npm run prepare:binaries`)
13
17
  }
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@simontan/llm-gateway",
3
- "version": "0.2.1",
4
- "description": "Prebuilt llm-gateway binary wrapper for macOS",
3
+ "version": "0.3.0",
4
+ "description": "Prebuilt llm-gateway binary wrapper for macOS, Linux, and Windows",
5
5
  "license": "MIT",
6
6
  "bin": {
7
7
  "llm-gateway": "bin/llm-gateway.js"
@@ -11,6 +11,8 @@
11
11
  "lib/resolve-binary.js",
12
12
  "npm-bin/darwin-arm64/llm-gateway",
13
13
  "npm-bin/darwin-x64/llm-gateway",
14
+ "npm-bin/linux-x64/llm-gateway",
15
+ "npm-bin/win32-x64/llm-gateway.exe",
14
16
  "README.md",
15
17
  "README.en.md",
16
18
  "README.zh.md"