@relayplane/proxy 0.2.0 → 1.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 +221 -120
- package/dist/server.d.ts +8 -204
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +562 -1014
- package/dist/server.js.map +1 -1
- package/package.json +30 -29
- package/__tests__/server.test.ts +0 -512
- package/__tests__/telemetry.test.ts +0 -126
- package/dist/cli.d.ts +0 -36
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -304
- package/dist/cli.js.map +0 -1
- package/dist/config.d.ts +0 -80
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -208
- package/dist/config.js.map +0 -1
- package/dist/index.d.ts +0 -36
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -74
- package/dist/index.js.map +0 -1
- package/dist/streaming.d.ts +0 -80
- package/dist/streaming.d.ts.map +0 -1
- package/dist/streaming.js +0 -271
- package/dist/streaming.js.map +0 -1
- package/dist/telemetry.d.ts +0 -111
- package/dist/telemetry.d.ts.map +0 -1
- package/dist/telemetry.js +0 -315
- package/dist/telemetry.js.map +0 -1
- package/src/cli.ts +0 -341
- package/src/config.ts +0 -206
- package/src/index.ts +0 -82
- package/src/server.ts +0 -1328
- package/src/streaming.ts +0 -331
- package/src/telemetry.ts +0 -343
- package/tsconfig.json +0 -19
- package/vitest.config.ts +0 -21
package/README.md
CHANGED
|
@@ -1,185 +1,286 @@
|
|
|
1
1
|
# @relayplane/proxy
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Local LLM proxy server for RelayPlane - route requests through multiple AI providers.
|
|
4
|
+
|
|
5
|
+
## What's New in 1.1
|
|
6
|
+
|
|
7
|
+
- 🩺 **Health Endpoint** — `GET /health` with uptime, stats, and provider status
|
|
8
|
+
- ⚠️ **Usage Warnings** — Console and header warnings at 80%, 90%, 100% of limits
|
|
9
|
+
- 📊 **Response Headers** — `X-RelayPlane-Daily-Usage`, `X-RelayPlane-Monthly-Usage`, `X-RelayPlane-Usage-Warning`
|
|
10
|
+
- 💰 **Spending Limits** — Configure `limits.daily` and `limits.monthly` with 429 when exceeded
|
|
11
|
+
- 🏷️ **Model Aliases** — `rp:fast`, `rp:cheap`, `rp:best`, `rp:balanced` shortcuts
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **OpenAI-compatible API** - Drop-in replacement for OpenAI SDK
|
|
16
|
+
- **Multi-provider routing** - Automatically routes to OpenAI, Anthropic, Groq, Together, OpenRouter
|
|
17
|
+
- **Model aliases** - `rp:fast`, `rp:cheap`, `rp:best` shortcuts
|
|
18
|
+
- **Dry-run mode** - Test routing without making API calls
|
|
19
|
+
- **Usage tracking** - Track tokens, cost, and latency
|
|
20
|
+
- **Spending limits** - Daily/monthly cost limits with warnings
|
|
21
|
+
- **Health endpoint** - `/health` for monitoring and uptime checks
|
|
4
22
|
|
|
5
23
|
## Installation
|
|
6
24
|
|
|
7
25
|
```bash
|
|
8
|
-
npm install
|
|
26
|
+
npm install @relayplane/proxy
|
|
9
27
|
```
|
|
10
28
|
|
|
11
|
-
|
|
29
|
+
Or use via the CLI:
|
|
12
30
|
|
|
13
31
|
```bash
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
32
|
+
npm install -g @relayplane/cli
|
|
33
|
+
relayplane proxy start
|
|
34
|
+
```
|
|
17
35
|
|
|
18
|
-
|
|
19
|
-
relayplane-proxy
|
|
36
|
+
## Quick Start
|
|
20
37
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export
|
|
38
|
+
```bash
|
|
39
|
+
# Set API keys
|
|
40
|
+
export OPENAI_API_KEY=sk-...
|
|
41
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
24
42
|
|
|
25
|
-
#
|
|
43
|
+
# Start the proxy
|
|
44
|
+
npx @relayplane/proxy
|
|
45
|
+
|
|
46
|
+
# Make requests
|
|
47
|
+
curl http://localhost:8787/v1/chat/completions \
|
|
48
|
+
-H "Content-Type: application/json" \
|
|
49
|
+
-d '{
|
|
50
|
+
"model": "gpt-4o",
|
|
51
|
+
"messages": [{"role": "user", "content": "Hello!"}]
|
|
52
|
+
}'
|
|
26
53
|
```
|
|
27
54
|
|
|
28
|
-
##
|
|
55
|
+
## Endpoints
|
|
29
56
|
|
|
30
|
-
|
|
31
|
-
- **Cost Tracking**: Tracks and reports API costs across all providers
|
|
32
|
-
- **Provider Agnostic**: Works with Anthropic, OpenAI, Gemini, xAI, and more
|
|
33
|
-
- **Local Learning**: Learns from your usage patterns to improve routing
|
|
34
|
-
- **Privacy First**: Never sees your prompts or responses
|
|
57
|
+
### `GET /health`
|
|
35
58
|
|
|
36
|
-
|
|
59
|
+
Health check endpoint for monitoring.
|
|
37
60
|
|
|
38
61
|
```bash
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Commands:
|
|
42
|
-
(default) Start the proxy server
|
|
43
|
-
telemetry [on|off|status] Manage telemetry settings
|
|
44
|
-
stats Show usage statistics
|
|
45
|
-
config Show configuration
|
|
46
|
-
|
|
47
|
-
Options:
|
|
48
|
-
--port <number> Port to listen on (default: 3001)
|
|
49
|
-
--host <string> Host to bind to (default: 127.0.0.1)
|
|
50
|
-
--offline Disable all network calls except LLM endpoints
|
|
51
|
-
--audit Show telemetry payloads before sending
|
|
52
|
-
-v, --verbose Enable verbose logging
|
|
53
|
-
-h, --help Show this help message
|
|
54
|
-
--version Show version
|
|
62
|
+
curl http://localhost:8787/health
|
|
55
63
|
```
|
|
56
64
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
RelayPlane collects anonymous telemetry to improve model routing. This data helps us understand usage patterns and optimize routing decisions.
|
|
60
|
-
|
|
61
|
-
### What We Collect (Exact Schema)
|
|
62
|
-
|
|
65
|
+
Response:
|
|
63
66
|
```json
|
|
64
67
|
{
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
"status": "ok",
|
|
69
|
+
"uptime": 3600,
|
|
70
|
+
"version": "1.1.0",
|
|
71
|
+
"providers": {
|
|
72
|
+
"openai": "configured",
|
|
73
|
+
"anthropic": "configured",
|
|
74
|
+
"groq": "not_configured",
|
|
75
|
+
"together": "not_configured",
|
|
76
|
+
"openrouter": "not_configured"
|
|
77
|
+
},
|
|
78
|
+
"requestsHandled": 150,
|
|
79
|
+
"requestsSuccessful": 148,
|
|
80
|
+
"requestsFailed": 2,
|
|
81
|
+
"dailyCost": 1.25,
|
|
82
|
+
"dailyLimit": 10.00,
|
|
83
|
+
"monthlyCost": 25.50,
|
|
84
|
+
"monthlyLimit": 100.00,
|
|
85
|
+
"usage": {
|
|
86
|
+
"inputTokens": 50000,
|
|
87
|
+
"outputTokens": 25000,
|
|
88
|
+
"totalCost": 1.25
|
|
89
|
+
}
|
|
73
90
|
}
|
|
74
91
|
```
|
|
75
92
|
|
|
76
|
-
###
|
|
93
|
+
### `GET /v1/models`
|
|
77
94
|
|
|
78
|
-
|
|
79
|
-
|-------|------|-------------|
|
|
80
|
-
| `device_id` | string | Anonymous random ID (not fingerprintable) |
|
|
81
|
-
| `task_type` | string | Inferred from token patterns, NOT prompt content |
|
|
82
|
-
| `model` | string | The model that handled the request |
|
|
83
|
-
| `tokens_in` | number | Input token count |
|
|
84
|
-
| `tokens_out` | number | Output token count |
|
|
85
|
-
| `latency_ms` | number | Request latency in milliseconds |
|
|
86
|
-
| `success` | boolean | Whether the request succeeded |
|
|
87
|
-
| `cost_usd` | number | Estimated cost in USD |
|
|
95
|
+
List available models including aliases.
|
|
88
96
|
|
|
89
|
-
|
|
97
|
+
```bash
|
|
98
|
+
curl http://localhost:8787/v1/models
|
|
99
|
+
```
|
|
90
100
|
|
|
91
|
-
|
|
101
|
+
### `POST /v1/chat/completions`
|
|
92
102
|
|
|
93
|
-
-
|
|
94
|
-
- `code_review` - Medium-long input, medium output
|
|
95
|
-
- `generation` - High output/input ratio
|
|
96
|
-
- `classification` - Low output/input ratio, short output
|
|
97
|
-
- `long_context` - Input > 10,000 tokens
|
|
98
|
-
- `content_generation` - Output > 1,000 tokens
|
|
99
|
-
- `tool_use` - Request includes tool calls
|
|
100
|
-
- `general` - Default classification
|
|
103
|
+
OpenAI-compatible chat completions.
|
|
101
104
|
|
|
102
|
-
|
|
105
|
+
```bash
|
|
106
|
+
curl http://localhost:8787/v1/chat/completions \
|
|
107
|
+
-H "Content-Type: application/json" \
|
|
108
|
+
-d '{
|
|
109
|
+
"model": "rp:best",
|
|
110
|
+
"messages": [{"role": "user", "content": "Hello!"}]
|
|
111
|
+
}'
|
|
112
|
+
```
|
|
103
113
|
|
|
104
|
-
|
|
105
|
-
- ❌ Model responses
|
|
106
|
-
- ❌ File paths or contents
|
|
107
|
-
- ❌ Anything that could identify you or your project
|
|
114
|
+
## Model Aliases
|
|
108
115
|
|
|
109
|
-
|
|
116
|
+
| Alias | Resolves To | Provider | Use Case |
|
|
117
|
+
|-------|-------------|----------|----------|
|
|
118
|
+
| `rp:fast` | llama-3.1-8b-instant | Groq | Lowest latency |
|
|
119
|
+
| `rp:cheap` | llama-3.1-8b-instant | Groq | Lowest cost |
|
|
120
|
+
| `rp:best` | claude-3-5-sonnet-20241022 | Anthropic | Highest quality |
|
|
121
|
+
| `rp:balanced` | gpt-4o-mini | OpenAI | Good balance |
|
|
110
122
|
|
|
111
|
-
|
|
123
|
+
## Dry-Run Mode
|
|
112
124
|
|
|
113
|
-
|
|
114
|
-
# See telemetry payloads before they're sent
|
|
115
|
-
relayplane-proxy --audit
|
|
125
|
+
Test routing logic without making API calls:
|
|
116
126
|
|
|
117
|
-
|
|
118
|
-
|
|
127
|
+
```bash
|
|
128
|
+
curl http://localhost:8787/v1/chat/completions \
|
|
129
|
+
-H "Content-Type: application/json" \
|
|
130
|
+
-H "X-Dry-Run: true" \
|
|
131
|
+
-d '{
|
|
132
|
+
"model": "gpt-4o",
|
|
133
|
+
"messages": [{"role": "user", "content": "Hello!"}]
|
|
134
|
+
}'
|
|
135
|
+
```
|
|
119
136
|
|
|
120
|
-
|
|
121
|
-
|
|
137
|
+
Response:
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"dry_run": true,
|
|
141
|
+
"routing": {
|
|
142
|
+
"model": "gpt-4o",
|
|
143
|
+
"provider": "openai",
|
|
144
|
+
"endpoint": "https://api.openai.com/v1/chat/completions"
|
|
145
|
+
},
|
|
146
|
+
"estimate": {
|
|
147
|
+
"inputTokens": 10,
|
|
148
|
+
"expectedOutputTokens": 500,
|
|
149
|
+
"estimatedCost": 0.0125,
|
|
150
|
+
"currency": "USD"
|
|
151
|
+
},
|
|
152
|
+
"limits": {
|
|
153
|
+
"daily": 10.00,
|
|
154
|
+
"dailyUsed": 1.25,
|
|
155
|
+
"dailyRemaining": 8.75,
|
|
156
|
+
"monthly": 100.00,
|
|
157
|
+
"monthlyUsed": 25.50,
|
|
158
|
+
"monthlyRemaining": 74.50
|
|
159
|
+
}
|
|
160
|
+
}
|
|
122
161
|
```
|
|
123
162
|
|
|
124
|
-
|
|
163
|
+
## Response Headers
|
|
125
164
|
|
|
126
|
-
|
|
165
|
+
The proxy adds usage information to response headers:
|
|
127
166
|
|
|
128
|
-
|
|
129
|
-
|
|
167
|
+
| Header | Description |
|
|
168
|
+
|--------|-------------|
|
|
169
|
+
| `X-RelayPlane-Cost` | Cost of this request |
|
|
170
|
+
| `X-RelayPlane-Latency` | Request latency in ms |
|
|
171
|
+
| `X-RelayPlane-Daily-Usage` | Daily usage (e.g., "1.25/10.00") |
|
|
172
|
+
| `X-RelayPlane-Monthly-Usage` | Monthly usage (e.g., "25.50/100.00") |
|
|
173
|
+
| `X-RelayPlane-Usage-Warning` | Warning when approaching limits (80%, 90%, 100%) |
|
|
174
|
+
|
|
175
|
+
Example warning header:
|
|
176
|
+
```
|
|
177
|
+
X-RelayPlane-Usage-Warning: ⚠️ You've used $8.50 of your $10 daily limit
|
|
130
178
|
```
|
|
131
179
|
|
|
132
|
-
|
|
180
|
+
Console warnings are also logged when approaching limits:
|
|
181
|
+
```
|
|
182
|
+
⚠️ Daily spending at 80%: $8.00 / $10
|
|
183
|
+
⚠️ Daily spending at 90%: $9.00 / $10
|
|
184
|
+
⚠️ DAILY LIMIT REACHED: $10.00 / $10 (100%)
|
|
185
|
+
```
|
|
133
186
|
|
|
134
|
-
|
|
135
|
-
|
|
187
|
+
## Spending Limits
|
|
188
|
+
|
|
189
|
+
Configure limits in `~/.relayplane/config.json`:
|
|
190
|
+
|
|
191
|
+
```json
|
|
192
|
+
{
|
|
193
|
+
"limits": {
|
|
194
|
+
"daily": 10.00,
|
|
195
|
+
"monthly": 100.00
|
|
196
|
+
}
|
|
197
|
+
}
|
|
136
198
|
```
|
|
137
199
|
|
|
138
|
-
|
|
200
|
+
When limits are reached, the proxy returns HTTP `429 Too Many Requests`:
|
|
139
201
|
|
|
140
|
-
```
|
|
141
|
-
|
|
202
|
+
```json
|
|
203
|
+
{
|
|
204
|
+
"error": {
|
|
205
|
+
"message": "Daily spending limit reached ($10.00 / $10.00)",
|
|
206
|
+
"code": "spending_limit_exceeded",
|
|
207
|
+
"type": "rate_limit_error"
|
|
208
|
+
}
|
|
209
|
+
}
|
|
142
210
|
```
|
|
143
211
|
|
|
144
|
-
|
|
212
|
+
Headers included with 429 response:
|
|
213
|
+
- `Retry-After: 86400` (seconds until daily reset)
|
|
214
|
+
- `X-RelayPlane-Daily-Usage: 10.00/10.00`
|
|
145
215
|
|
|
146
|
-
|
|
216
|
+
## Usage Tracking
|
|
147
217
|
|
|
148
|
-
|
|
218
|
+
Usage is logged to `~/.relayplane/usage.jsonl`:
|
|
149
219
|
|
|
150
|
-
```
|
|
151
|
-
|
|
220
|
+
```jsonl
|
|
221
|
+
{"timestamp":"2024-01-15T12:00:00Z","model":"gpt-4o","provider":"openai","inputTokens":100,"outputTokens":50,"cost":0.00125,"latencyMs":1500,"success":true}
|
|
152
222
|
```
|
|
153
223
|
|
|
154
|
-
|
|
224
|
+
Daily totals are tracked in `~/.relayplane/daily-usage.json`:
|
|
155
225
|
|
|
156
|
-
```
|
|
157
|
-
|
|
226
|
+
```json
|
|
227
|
+
{
|
|
228
|
+
"date": "2024-01-15",
|
|
229
|
+
"cost": 1.25,
|
|
230
|
+
"requests": 50
|
|
231
|
+
}
|
|
158
232
|
```
|
|
159
233
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
View your usage statistics:
|
|
234
|
+
Monthly totals are tracked in `~/.relayplane/monthly-usage.json`:
|
|
163
235
|
|
|
164
|
-
```
|
|
165
|
-
|
|
236
|
+
```json
|
|
237
|
+
{
|
|
238
|
+
"month": "2024-01",
|
|
239
|
+
"cost": 25.50,
|
|
240
|
+
"requests": 1200
|
|
241
|
+
}
|
|
166
242
|
```
|
|
167
243
|
|
|
168
|
-
This shows:
|
|
169
|
-
- Total requests and cost
|
|
170
|
-
- Success rate
|
|
171
|
-
- Breakdown by model
|
|
172
|
-
- Breakdown by task type
|
|
173
|
-
|
|
174
244
|
## Environment Variables
|
|
175
245
|
|
|
176
|
-
| Variable | Description |
|
|
177
|
-
|
|
178
|
-
| `
|
|
179
|
-
| `
|
|
180
|
-
| `
|
|
181
|
-
| `
|
|
182
|
-
| `
|
|
246
|
+
| Variable | Default | Description |
|
|
247
|
+
|----------|---------|-------------|
|
|
248
|
+
| `RELAYPLANE_PROXY_PORT` | 8787 | Port to listen on |
|
|
249
|
+
| `RELAYPLANE_PROXY_HOST` | 127.0.0.1 | Host to bind to |
|
|
250
|
+
| `RELAYPLANE_CONFIG_DIR` | ~/.relayplane | Config directory |
|
|
251
|
+
| `OPENAI_API_KEY` | - | OpenAI API key |
|
|
252
|
+
| `ANTHROPIC_API_KEY` | - | Anthropic API key |
|
|
253
|
+
| `GROQ_API_KEY` | - | Groq API key |
|
|
254
|
+
| `TOGETHER_API_KEY` | - | Together AI API key |
|
|
255
|
+
| `OPENROUTER_API_KEY` | - | OpenRouter API key |
|
|
256
|
+
|
|
257
|
+
## Provider Detection
|
|
258
|
+
|
|
259
|
+
Models are automatically routed to the correct provider:
|
|
260
|
+
|
|
261
|
+
| Pattern | Provider |
|
|
262
|
+
|---------|----------|
|
|
263
|
+
| `gpt-*`, `o1-*` | OpenAI |
|
|
264
|
+
| `claude-*` | Anthropic |
|
|
265
|
+
| `llama-*`, `mixtral-*` | Groq |
|
|
266
|
+
| `meta-llama/*`, `mistralai/*` | Together |
|
|
267
|
+
| Contains `/` | OpenRouter |
|
|
268
|
+
|
|
269
|
+
## Using with OpenAI SDK
|
|
270
|
+
|
|
271
|
+
```python
|
|
272
|
+
from openai import OpenAI
|
|
273
|
+
|
|
274
|
+
client = OpenAI(
|
|
275
|
+
base_url="http://localhost:8787/v1",
|
|
276
|
+
api_key="not-needed" # API keys are configured on the proxy
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
response = client.chat.completions.create(
|
|
280
|
+
model="rp:best", # Uses Claude 3.5 Sonnet
|
|
281
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
282
|
+
)
|
|
283
|
+
```
|
|
183
284
|
|
|
184
285
|
## License
|
|
185
286
|
|
package/dist/server.d.ts
CHANGED
|
@@ -1,209 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
/**
|
|
2
|
-
* RelayPlane
|
|
3
|
-
*
|
|
4
|
-
* OpenAI-compatible proxy server with integrated observability via the Learning Ledger
|
|
5
|
-
* and auth enforcement via Auth Gate.
|
|
3
|
+
* RelayPlane Local LLM Proxy Server
|
|
6
4
|
*
|
|
5
|
+
* Routes OpenAI-compatible requests to multiple providers.
|
|
7
6
|
* Features:
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
12
|
-
* - Structured error handling
|
|
13
|
-
*
|
|
14
|
-
* @packageDocumentation
|
|
15
|
-
*/
|
|
16
|
-
import { Ledger } from '@relayplane/ledger';
|
|
17
|
-
import { AuthGate, type AuthProfileStorage } from '@relayplane/auth-gate';
|
|
18
|
-
import { PolicyEngine, type PolicyStorage } from '@relayplane/policy-engine';
|
|
19
|
-
import { RoutingEngine, type CapabilityRegistry, type ProviderManager } from '@relayplane/routing-engine';
|
|
20
|
-
import { ExplanationEngine, RunComparator, Simulator } from '@relayplane/explainability';
|
|
21
|
-
import type { AuthEnforcementMode } from '@relayplane/ledger';
|
|
22
|
-
/**
|
|
23
|
-
* Proxy server configuration
|
|
24
|
-
*/
|
|
25
|
-
export interface ProxyServerConfig {
|
|
26
|
-
port?: number;
|
|
27
|
-
host?: string;
|
|
28
|
-
ledger?: Ledger;
|
|
29
|
-
authStorage?: AuthProfileStorage;
|
|
30
|
-
policyStorage?: PolicyStorage;
|
|
31
|
-
policyEngine?: PolicyEngine;
|
|
32
|
-
verbose?: boolean;
|
|
33
|
-
defaultWorkspaceId?: string;
|
|
34
|
-
defaultAgentId?: string;
|
|
35
|
-
defaultAuthEnforcementMode?: AuthEnforcementMode;
|
|
36
|
-
enforcePolicies?: boolean;
|
|
37
|
-
routingEngine?: RoutingEngine;
|
|
38
|
-
capabilityRegistry?: CapabilityRegistry;
|
|
39
|
-
providerManager?: ProviderManager;
|
|
40
|
-
/** Enable capability-based routing (Phase 3) */
|
|
41
|
-
enableRouting?: boolean;
|
|
42
|
-
providers?: {
|
|
43
|
-
anthropic?: {
|
|
44
|
-
apiKey: string;
|
|
45
|
-
baseUrl?: string;
|
|
46
|
-
};
|
|
47
|
-
openai?: {
|
|
48
|
-
apiKey: string;
|
|
49
|
-
baseUrl?: string;
|
|
50
|
-
};
|
|
51
|
-
openrouter?: {
|
|
52
|
-
apiKey: string;
|
|
53
|
-
baseUrl?: string;
|
|
54
|
-
};
|
|
55
|
-
google?: {
|
|
56
|
-
apiKey: string;
|
|
57
|
-
baseUrl?: string;
|
|
58
|
-
};
|
|
59
|
-
together?: {
|
|
60
|
-
apiKey: string;
|
|
61
|
-
baseUrl?: string;
|
|
62
|
-
};
|
|
63
|
-
deepseek?: {
|
|
64
|
-
apiKey: string;
|
|
65
|
-
baseUrl?: string;
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* RelayPlane Agent Ops Proxy Server
|
|
71
|
-
*/
|
|
72
|
-
export declare class ProxyServer {
|
|
73
|
-
private server;
|
|
74
|
-
private ledger;
|
|
75
|
-
private authGate;
|
|
76
|
-
private policyEngine;
|
|
77
|
-
private routingEngine;
|
|
78
|
-
private capabilityRegistry;
|
|
79
|
-
private providerManager;
|
|
80
|
-
private explainer;
|
|
81
|
-
private comparator;
|
|
82
|
-
private simulator;
|
|
83
|
-
private config;
|
|
84
|
-
constructor(config?: ProxyServerConfig);
|
|
85
|
-
/**
|
|
86
|
-
* Build provider overrides from config
|
|
87
|
-
*/
|
|
88
|
-
private buildProviderOverrides;
|
|
89
|
-
/**
|
|
90
|
-
* Configure provider API keys from config
|
|
91
|
-
*/
|
|
92
|
-
private configureProviderApiKeys;
|
|
93
|
-
/**
|
|
94
|
-
* Start the proxy server
|
|
95
|
-
*/
|
|
96
|
-
start(): Promise<void>;
|
|
97
|
-
/**
|
|
98
|
-
* Stop the proxy server
|
|
99
|
-
*/
|
|
100
|
-
stop(): Promise<void>;
|
|
101
|
-
/**
|
|
102
|
-
* Handle incoming request
|
|
103
|
-
*/
|
|
104
|
-
private handleRequest;
|
|
105
|
-
private handleListPolicies;
|
|
106
|
-
private handleCreatePolicy;
|
|
107
|
-
private handleGetPolicy;
|
|
108
|
-
private handleUpdatePolicy;
|
|
109
|
-
private handleDeletePolicy;
|
|
110
|
-
private handlePolicyTest;
|
|
111
|
-
private handleGetBudget;
|
|
112
|
-
/**
|
|
113
|
-
* Handle GET /v1/runs/{id}/explain - Full decision chain explanation
|
|
114
|
-
*/
|
|
115
|
-
private handleExplainRun;
|
|
116
|
-
/**
|
|
117
|
-
* Handle GET /v1/runs/{id}/timeline - Timeline view only
|
|
118
|
-
*/
|
|
119
|
-
private handleRunTimeline;
|
|
120
|
-
/**
|
|
121
|
-
* Handle GET /v1/runs/{id}/decisions - Raw decision chain
|
|
122
|
-
*/
|
|
123
|
-
private handleRunDecisions;
|
|
124
|
-
/**
|
|
125
|
-
* Handle GET /v1/runs/{id} - Run inspector (all details)
|
|
126
|
-
*/
|
|
127
|
-
private handleRunInspector;
|
|
128
|
-
/**
|
|
129
|
-
* Handle GET /v1/runs/compare?ids=run1,run2 - Run comparison
|
|
130
|
-
*/
|
|
131
|
-
private handleCompareRuns;
|
|
132
|
-
/**
|
|
133
|
-
* Handle POST /v1/simulate/policy - Policy simulation
|
|
134
|
-
*/
|
|
135
|
-
private handleSimulatePolicy;
|
|
136
|
-
/**
|
|
137
|
-
* Handle POST /v1/simulate/routing - Routing simulation
|
|
138
|
-
*/
|
|
139
|
-
private handleSimulateRouting;
|
|
140
|
-
/**
|
|
141
|
-
* Handle /v1/chat/completions
|
|
142
|
-
*/
|
|
143
|
-
private handleChatCompletions;
|
|
144
|
-
/**
|
|
145
|
-
* Forward request to provider
|
|
146
|
-
*/
|
|
147
|
-
private forwardToProvider;
|
|
148
|
-
/**
|
|
149
|
-
* Detect auth type from Authorization header
|
|
150
|
-
*/
|
|
151
|
-
private detectAuthType;
|
|
152
|
-
/**
|
|
153
|
-
* Estimate cost based on provider and usage
|
|
154
|
-
*/
|
|
155
|
-
private estimateCost;
|
|
156
|
-
/**
|
|
157
|
-
* Read request body
|
|
158
|
-
*/
|
|
159
|
-
private readBody;
|
|
160
|
-
/**
|
|
161
|
-
* Send error response
|
|
162
|
-
*/
|
|
163
|
-
private sendError;
|
|
164
|
-
/**
|
|
165
|
-
* Log message
|
|
166
|
-
*/
|
|
167
|
-
private log;
|
|
168
|
-
/**
|
|
169
|
-
* Get the ledger instance (useful for testing)
|
|
170
|
-
*/
|
|
171
|
-
getLedger(): Ledger;
|
|
172
|
-
/**
|
|
173
|
-
* Get the auth gate instance (useful for testing)
|
|
174
|
-
*/
|
|
175
|
-
getAuthGate(): AuthGate;
|
|
176
|
-
/**
|
|
177
|
-
* Get the policy engine instance (useful for testing and policy management)
|
|
178
|
-
*/
|
|
179
|
-
getPolicyEngine(): PolicyEngine;
|
|
180
|
-
/**
|
|
181
|
-
* Get the routing engine instance (Phase 3)
|
|
182
|
-
*/
|
|
183
|
-
getRoutingEngine(): RoutingEngine;
|
|
184
|
-
/**
|
|
185
|
-
* Get the capability registry instance (Phase 3)
|
|
186
|
-
*/
|
|
187
|
-
getCapabilityRegistry(): CapabilityRegistry;
|
|
188
|
-
/**
|
|
189
|
-
* Get the provider manager instance (Phase 3)
|
|
190
|
-
*/
|
|
191
|
-
getProviderManager(): ProviderManager;
|
|
192
|
-
/**
|
|
193
|
-
* Get the explanation engine instance (Phase 4)
|
|
194
|
-
*/
|
|
195
|
-
getExplainer(): ExplanationEngine;
|
|
196
|
-
/**
|
|
197
|
-
* Get the run comparator instance (Phase 4)
|
|
198
|
-
*/
|
|
199
|
-
getComparator(): RunComparator;
|
|
200
|
-
/**
|
|
201
|
-
* Get the simulator instance (Phase 4)
|
|
202
|
-
*/
|
|
203
|
-
getSimulator(): Simulator;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Create a new proxy server
|
|
7
|
+
* - /health endpoint for monitoring
|
|
8
|
+
* - Usage tracking with spending warnings
|
|
9
|
+
* - Model aliases (rp:fast, rp:cheap, rp:best)
|
|
10
|
+
* - Dry-run mode for testing
|
|
207
11
|
*/
|
|
208
|
-
export
|
|
12
|
+
export {};
|
|
209
13
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG"}
|