@kotro-labs/proxy-engine 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.md +72 -0
- package/bin/index.js +30 -0
- package/bin/kotro-proxy-aarch64-apple-darwin +0 -0
- package/bin/kotro-proxy-x86_64-apple-darwin +0 -0
- package/bin/kotro-proxy-x86_64-pc-windows-msvc.exe +0 -0
- package/bin/kotro-proxy-x86_64-unknown-linux-gnu +0 -0
- package/lib/binary-target.js +40 -0
- package/media/icon.png +0 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# @kotro-labs/proxy-engine
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="media/icon.png" alt="Kotro" width="72" height="72" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
npm distribution for the [Kotro Proxy Engine](https://github.com/kotro-labs/kotro-proxy-engine) — a local AI reverse proxy with streaming semantic cache, PII redaction, and context compression for OpenAI and Anthropic SDKs.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Zero-config startup** — precompiled binary with no dependencies
|
|
12
|
+
- **Semantic SSE cache** — faster repeat prompts; `X-Kotro-Cache: HIT` on cache hits
|
|
13
|
+
- **Enterprise failover** — dynamic routing on 429/503 upstream errors
|
|
14
|
+
- **Operator dashboard** — local UI for observability (`http://127.0.0.1:9090/dashboard`)
|
|
15
|
+
- **Isolated telemetry** — `/metrics` binds to loopback by default, separate from LLM traffic
|
|
16
|
+
- **Context-aware cache keys** — prevents false cache hits in multi-turn agent loops
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install -g @kotro-labs/proxy-engine
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick start
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Point at your provider (default upstream is local mock on :9000)
|
|
28
|
+
export KOTRO_UPSTREAM_URL=https://api.openai.com
|
|
29
|
+
|
|
30
|
+
kotro-proxy
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The proxy listens on `:8080` by default. Point your IDE or SDK at `http://localhost:8080/v1`.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
curl -N http://127.0.0.1:8080/v1/chat/completions \
|
|
37
|
+
-H "Content-Type: application/json" \
|
|
38
|
+
-H "Authorization: Bearer $OPENAI_API_KEY" \
|
|
39
|
+
-d '{"model":"gpt-4","stream":true,"messages":[{"role":"user","content":"hello"}]}'
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Cache hits return the `X-Kotro-Cache: HIT` header.
|
|
43
|
+
|
|
44
|
+
## Architecture
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
AI client → localhost:8080/v1/* (LLM proxy — may bind 0.0.0.0 in cluster mode)
|
|
48
|
+
Operator → 127.0.0.1:9090/dashboard (telemetry — loopback only by default)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Configuration
|
|
52
|
+
|
|
53
|
+
| Variable | Default | Purpose |
|
|
54
|
+
|----------|---------|---------|
|
|
55
|
+
| `KOTRO_LISTEN_ADDR` | `:8080` | Proxy bind address |
|
|
56
|
+
| `KOTRO_UPSTREAM_URL` | `http://127.0.0.1:9000` | Provider base URL |
|
|
57
|
+
| `KOTRO_ENABLE_CACHE` | `true` | Semantic SSE cache |
|
|
58
|
+
| `KOTRO_ENABLE_REDACTION` | `true` | PII guardrail |
|
|
59
|
+
| `KOTRO_ENABLE_COMPRESSION` | `true` | Context block dedup |
|
|
60
|
+
| `KOTRO_TRUST_UPSTREAM_GATEWAY` | `false` | Honor `X-Tenant-ID` only from trusted proxy CIDRs |
|
|
61
|
+
|
|
62
|
+
Full documentation: [github.com/kotro-labs/kotro-proxy-engine](https://github.com/kotro-labs/kotro-proxy-engine)
|
|
63
|
+
|
|
64
|
+
## Other install channels
|
|
65
|
+
|
|
66
|
+
- **Homebrew:** `brew tap kotro-labs/tap && brew install kotro-proxy`
|
|
67
|
+
- **VS Code / Cursor:** [Marketplace extension](https://marketplace.visualstudio.com/items?itemName=kotrolabs.kotro-proxy-engine)
|
|
68
|
+
- **GitHub Releases:** [Download binaries](https://github.com/kotro-labs/kotro-proxy-engine/releases)
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
MIT
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const { spawn } = require('child_process');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const { resolveBinaryPath } = require('../lib/binary-target');
|
|
7
|
+
|
|
8
|
+
function main() {
|
|
9
|
+
const binRoot = path.join(__dirname, '..', 'bin');
|
|
10
|
+
const binary = resolveBinaryPath(binRoot);
|
|
11
|
+
const child = spawn(binary, process.argv.slice(2), {
|
|
12
|
+
stdio: 'inherit',
|
|
13
|
+
env: process.env,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
child.on('error', (err) => {
|
|
17
|
+
console.error(`kotro-proxy: ${err.message}`);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
child.on('close', (code, signal) => {
|
|
22
|
+
if (signal) {
|
|
23
|
+
process.kill(process.pid, signal);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
process.exit(code ?? 1);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
main();
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform resolver for the npm CLI package.
|
|
3
|
+
* Keep in sync with distributions/shared/binary-target.js
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
|
|
9
|
+
const BINARY_BASENAMES = {
|
|
10
|
+
'darwin-arm64': 'kotro-proxy-aarch64-apple-darwin',
|
|
11
|
+
'darwin-x64': 'kotro-proxy-x86_64-apple-darwin',
|
|
12
|
+
'linux-x64': 'kotro-proxy-x86_64-unknown-linux-gnu',
|
|
13
|
+
'win32-x64': 'kotro-proxy-x86_64-pc-windows-msvc.exe',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function binaryBasename(platform, arch) {
|
|
17
|
+
if (platform === 'darwin') {
|
|
18
|
+
return arch === 'arm64' ? BINARY_BASENAMES['darwin-arm64'] : BINARY_BASENAMES['darwin-x64'];
|
|
19
|
+
}
|
|
20
|
+
if (platform === 'linux') {
|
|
21
|
+
return BINARY_BASENAMES['linux-x64'];
|
|
22
|
+
}
|
|
23
|
+
if (platform === 'win32') {
|
|
24
|
+
return BINARY_BASENAMES['win32-x64'];
|
|
25
|
+
}
|
|
26
|
+
throw new Error(`Unsupported platform: ${platform}/${arch}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function resolveBinaryPath(binRoot, platform = process.platform, arch = process.arch) {
|
|
30
|
+
const name = binaryBasename(platform, arch);
|
|
31
|
+
const candidate = path.join(binRoot, name);
|
|
32
|
+
if (!fs.existsSync(candidate)) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
`Native binary not found at ${candidate}. Reinstall @kotrolabs/proxy-engine or build from source.`,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return candidate;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = { BINARY_BASENAMES, binaryBasename, resolveBinaryPath };
|
package/media/icon.png
ADDED
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kotro-labs/proxy-engine",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "High-performance semantic caching AI proxy gateway with native Rust runtime.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Ramesh Pandian",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/kotro-labs/kotro-proxy-engine.git",
|
|
10
|
+
"directory": "distributions/npm-cli"
|
|
11
|
+
},
|
|
12
|
+
"bin": {
|
|
13
|
+
"kotro-proxy": "./bin/index.js"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"README.md",
|
|
17
|
+
"media/icon.png",
|
|
18
|
+
"bin/index.js",
|
|
19
|
+
"lib/binary-target.js",
|
|
20
|
+
"bin/kotro-proxy-*"
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=16.0.0"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"ai",
|
|
27
|
+
"proxy",
|
|
28
|
+
"cache",
|
|
29
|
+
"rust",
|
|
30
|
+
"llm",
|
|
31
|
+
"openai",
|
|
32
|
+
"anthropic"
|
|
33
|
+
]
|
|
34
|
+
}
|