@relayplane/proxy 1.5.46 → 1.7.2
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 +297 -20
- package/assets/relayplane-proxy.service +20 -0
- package/dist/alerts.d.ts +72 -0
- package/dist/alerts.d.ts.map +1 -0
- package/dist/alerts.js +290 -0
- package/dist/alerts.js.map +1 -0
- package/dist/anomaly.d.ts +65 -0
- package/dist/anomaly.d.ts.map +1 -0
- package/dist/anomaly.js +193 -0
- package/dist/anomaly.js.map +1 -0
- package/dist/budget.d.ts +98 -0
- package/dist/budget.d.ts.map +1 -0
- package/dist/budget.js +356 -0
- package/dist/budget.js.map +1 -0
- package/dist/cli.js +512 -93
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +28 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +122 -24
- package/dist/config.js.map +1 -1
- package/dist/downgrade.d.ts +37 -0
- package/dist/downgrade.d.ts.map +1 -0
- package/dist/downgrade.js +79 -0
- package/dist/downgrade.js.map +1 -0
- package/dist/mesh/capture.d.ts +11 -0
- package/dist/mesh/capture.d.ts.map +1 -0
- package/dist/mesh/capture.js +43 -0
- package/dist/mesh/capture.js.map +1 -0
- package/dist/mesh/fitness.d.ts +14 -0
- package/dist/mesh/fitness.d.ts.map +1 -0
- package/dist/mesh/fitness.js +40 -0
- package/dist/mesh/fitness.js.map +1 -0
- package/dist/mesh/index.d.ts +39 -0
- package/dist/mesh/index.d.ts.map +1 -0
- package/dist/mesh/index.js +118 -0
- package/dist/mesh/index.js.map +1 -0
- package/dist/mesh/store.d.ts +30 -0
- package/dist/mesh/store.d.ts.map +1 -0
- package/dist/mesh/store.js +174 -0
- package/dist/mesh/store.js.map +1 -0
- package/dist/mesh/sync.d.ts +37 -0
- package/dist/mesh/sync.d.ts.map +1 -0
- package/dist/mesh/sync.js +154 -0
- package/dist/mesh/sync.js.map +1 -0
- package/dist/mesh/types.d.ts +57 -0
- package/dist/mesh/types.d.ts.map +1 -0
- package/dist/mesh/types.js +7 -0
- package/dist/mesh/types.js.map +1 -0
- package/dist/rate-limiter.d.ts +64 -0
- package/dist/rate-limiter.d.ts.map +1 -0
- package/dist/rate-limiter.js +159 -0
- package/dist/rate-limiter.js.map +1 -0
- package/dist/relay-config.d.ts +9 -0
- package/dist/relay-config.d.ts.map +1 -1
- package/dist/relay-config.js +2 -0
- package/dist/relay-config.js.map +1 -1
- package/dist/response-cache.d.ts +139 -0
- package/dist/response-cache.d.ts.map +1 -0
- package/dist/response-cache.js +515 -0
- package/dist/response-cache.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +5 -1
- package/dist/server.js.map +1 -1
- package/dist/standalone-proxy.d.ts +2 -1
- package/dist/standalone-proxy.d.ts.map +1 -1
- package/dist/standalone-proxy.js +736 -50
- package/dist/standalone-proxy.js.map +1 -1
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +21 -5
- package/dist/telemetry.js.map +1 -1
- package/dist/utils/model-suggestions.d.ts.map +1 -1
- package/dist/utils/model-suggestions.js +19 -2
- package/dist/utils/model-suggestions.js.map +1 -1
- package/dist/utils/version-status.d.ts +9 -0
- package/dist/utils/version-status.d.ts.map +1 -0
- package/dist/utils/version-status.js +28 -0
- package/dist/utils/version-status.js.map +1 -0
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -3,14 +3,25 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@relayplane/proxy)
|
|
4
4
|
[](https://github.com/RelayPlane/proxy/blob/main/LICENSE)
|
|
5
5
|
|
|
6
|
-
An open-source LLM proxy that sits between your AI agents and providers. Tracks every request, shows where the money goes, and offers configurable task-aware routing — all running locally
|
|
6
|
+
An open-source LLM proxy that sits between your AI agents and providers. Tracks every request, shows where the money goes, and offers configurable task-aware routing — all running **locally, for free**.
|
|
7
7
|
|
|
8
|
-
**
|
|
8
|
+
**Free, open-source proxy features:**
|
|
9
9
|
- 📊 Per-request cost tracking across 11+ providers
|
|
10
|
-
- 💰 **Cache-aware cost tracking** — accurately tracks Anthropic prompt caching with cache read savings, creation costs, and true per-request costs
|
|
10
|
+
- 💰 **Cache-aware cost tracking** — accurately tracks Anthropic prompt caching with cache read savings, creation costs, and true per-request costs
|
|
11
11
|
- 🔀 Configurable task-aware routing (complexity-based, cascade, model overrides)
|
|
12
|
-
- 🛡️ Circuit breaker
|
|
13
|
-
- 📈 Local dashboard
|
|
12
|
+
- 🛡️ Circuit breaker — if the proxy fails, your agent doesn't notice
|
|
13
|
+
- 📈 **Local dashboard** at `localhost:4100` — cost breakdown, savings analysis, provider health
|
|
14
|
+
- 💵 **Budget enforcement** — daily/hourly/per-request spend limits with block, warn, downgrade, or alert actions
|
|
15
|
+
- 🔍 **Anomaly detection** — catches runaway agent loops, cost spikes, and token explosions in real time
|
|
16
|
+
- 🔔 **Cost alerts** — threshold alerts at configurable percentages, webhook delivery, alert history
|
|
17
|
+
- ⬇️ **Auto-downgrade** — automatically switches to cheaper models when budget thresholds are hit
|
|
18
|
+
- 📦 **Aggressive cache** — exact-match response caching with gzipped disk persistence
|
|
19
|
+
- 🧠 **Osmosis mesh** — opt-in collective learning layer that shares anonymized routing signals across users (free, opt-in)
|
|
20
|
+
- 🔧 **systemd/launchd service** — `relayplane service install` for always-on operation with auto-restart
|
|
21
|
+
- 🏥 **Health watchdog** — `/health` endpoint with uptime tracking and active probing
|
|
22
|
+
- 🛡️ **Config resilience** — atomic writes, automatic backup/restore, credential separation
|
|
23
|
+
|
|
24
|
+
> **Cloud dashboard available separately** — see [Cloud Dashboard & Pro Features](#cloud-dashboard--pro-features) below. Your prompts always stay local.
|
|
14
25
|
|
|
15
26
|
## Quick Start
|
|
16
27
|
|
|
@@ -55,29 +66,38 @@ A minimal config file:
|
|
|
55
66
|
|
|
56
67
|
All configuration is optional — sensible defaults are applied for every field. The proxy merges your config with its defaults via deep merge, so you only need to specify what you want to change.
|
|
57
68
|
|
|
58
|
-
## Architecture
|
|
69
|
+
## Architecture
|
|
59
70
|
|
|
60
71
|
```text
|
|
61
72
|
Client (Claude Code / Aider / Cursor)
|
|
62
73
|
|
|
|
63
74
|
| OpenAI/Anthropic-compatible request
|
|
64
75
|
v
|
|
65
|
-
|
|
66
|
-
| RelayPlane Proxy (local)
|
|
67
|
-
|
|
68
|
-
| 1) Parse request
|
|
69
|
-
| 2)
|
|
70
|
-
|
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
| 5)
|
|
76
|
-
|
|
|
77
|
-
|
|
76
|
+
+-------------------------------------------------------+
|
|
77
|
+
| RelayPlane Proxy (local) |
|
|
78
|
+
|-------------------------------------------------------|
|
|
79
|
+
| 1) Parse request |
|
|
80
|
+
| 2) Cache check (exact or aggressive mode) |
|
|
81
|
+
| └─ HIT → return cached response (skip provider) |
|
|
82
|
+
| 3) Budget check (daily/hourly/per-request limits) |
|
|
83
|
+
| └─ BREACH → block / warn / downgrade / alert |
|
|
84
|
+
| 4) Anomaly detection (velocity, cost spike, loops) |
|
|
85
|
+
| └─ DETECTED → alert + optional block |
|
|
86
|
+
| 5) Auto-downgrade (if budget threshold exceeded) |
|
|
87
|
+
| └─ Rewrite model to cheaper alternative |
|
|
88
|
+
| 6) Infer task/complexity (pre-request) |
|
|
89
|
+
| 7) Select route/model |
|
|
90
|
+
| - explicit model / passthrough |
|
|
91
|
+
| - relayplane:auto/cost/fast/quality |
|
|
92
|
+
| - configured complexity/cascade rules |
|
|
93
|
+
| 8) Forward request to provider |
|
|
94
|
+
| 9) Return provider response + cache it |
|
|
95
|
+
| 10) Record telemetry + update budget tracking |
|
|
96
|
+
| 11) Mesh sync (push anonymized routing signals) |
|
|
97
|
+
+-------------------------------------------------------+
|
|
78
98
|
|
|
|
79
99
|
v
|
|
80
|
-
Provider APIs (Anthropic/OpenAI/Gemini/xAI
|
|
100
|
+
Provider APIs (Anthropic/OpenAI/Gemini/xAI/...)
|
|
81
101
|
```
|
|
82
102
|
|
|
83
103
|
## How It Works
|
|
@@ -278,6 +298,15 @@ When enabled, the proxy sends anonymized metadata to `api.relayplane.com`:
|
|
|
278
298
|
|
|
279
299
|
**Never collected:** prompts, responses, file paths, or anything that could identify you or your project. Your prompts go directly to LLM providers, never through RelayPlane servers.
|
|
280
300
|
|
|
301
|
+
> **Cloud dashboard setup:** To see your data at [relayplane.com/dashboard](https://relayplane.com/dashboard), run `relayplane login` then `relayplane telemetry on`. This is the explicit opt-in — you're choosing to send anonymous metadata to power the cloud dashboard. You can disable anytime.
|
|
302
|
+
|
|
303
|
+
When the proxy connects and telemetry is enabled, it will confirm:
|
|
304
|
+
```
|
|
305
|
+
[RelayPlane] Cloud dashboard connected — telemetry enabled.
|
|
306
|
+
Your prompts stay local. Only anonymous metadata (model, tokens, cost) is sent.
|
|
307
|
+
Disable anytime: relayplane telemetry off
|
|
308
|
+
```
|
|
309
|
+
|
|
281
310
|
### Audit mode
|
|
282
311
|
|
|
283
312
|
Audit mode buffers telemetry events in memory so you can inspect exactly what would be sent before it goes anywhere. Useful for compliance review.
|
|
@@ -315,10 +344,258 @@ The dashboard is powered by JSON endpoints you can use directly:
|
|
|
315
344
|
| `GET /v1/telemetry/savings` | Cost savings from smart routing |
|
|
316
345
|
| `GET /v1/telemetry/health` | Provider health and cooldown status |
|
|
317
346
|
|
|
347
|
+
## Budget Enforcement
|
|
348
|
+
|
|
349
|
+
Set spending limits to prevent runaway costs. The budget manager tracks spend in rolling daily and hourly windows using SQLite with an in-memory cache for <5ms hot-path checks.
|
|
350
|
+
|
|
351
|
+
```json
|
|
352
|
+
{
|
|
353
|
+
"budget": {
|
|
354
|
+
"enabled": true,
|
|
355
|
+
"dailyUsd": 50,
|
|
356
|
+
"hourlyUsd": 10,
|
|
357
|
+
"perRequestUsd": 2,
|
|
358
|
+
"onBreach": "downgrade",
|
|
359
|
+
"downgradeTo": "claude-sonnet-4-6",
|
|
360
|
+
"alertThresholds": [50, 80, 95]
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
| Field | Default | Description |
|
|
366
|
+
|-------|---------|-------------|
|
|
367
|
+
| `enabled` | `false` | Enable budget enforcement |
|
|
368
|
+
| `dailyUsd` | `50` | Daily spend limit |
|
|
369
|
+
| `hourlyUsd` | `10` | Hourly spend limit |
|
|
370
|
+
| `perRequestUsd` | `2` | Max cost for a single request |
|
|
371
|
+
| `onBreach` | `"downgrade"` | Action: `block`, `warn`, `downgrade`, or `alert` |
|
|
372
|
+
| `downgradeTo` | `"claude-sonnet-4-6"` | Model to use when downgrading |
|
|
373
|
+
| `alertThresholds` | `[50, 80, 95]` | Fire alerts at these % of daily limit |
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
relayplane budget status # See current spend vs limits
|
|
377
|
+
relayplane budget set --daily 25 # Change daily limit
|
|
378
|
+
relayplane budget set --hourly 5 # Change hourly limit
|
|
379
|
+
relayplane budget reset # Reset spend counters
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
## Anomaly Detection
|
|
383
|
+
|
|
384
|
+
Catches runaway agent loops and cost spikes using a sliding window over the last 100 requests.
|
|
385
|
+
|
|
386
|
+
```json
|
|
387
|
+
{
|
|
388
|
+
"anomaly": {
|
|
389
|
+
"enabled": true,
|
|
390
|
+
"velocityThreshold": 50,
|
|
391
|
+
"tokenExplosionUsd": 5.0,
|
|
392
|
+
"repetitionThreshold": 20,
|
|
393
|
+
"windowMs": 300000
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
**Detection types:**
|
|
399
|
+
|
|
400
|
+
| Type | Triggers when... |
|
|
401
|
+
|------|-------------------|
|
|
402
|
+
| `velocity_spike` | Request rate exceeds threshold in 5-minute window |
|
|
403
|
+
| `cost_acceleration` | Spend rate is doubling every minute |
|
|
404
|
+
| `repetition` | Same model + similar token count >20 times in 5 min |
|
|
405
|
+
| `token_explosion` | Single request estimated cost exceeds $5 |
|
|
406
|
+
|
|
407
|
+
## Cost Alerts
|
|
408
|
+
|
|
409
|
+
Get notified when spending crosses thresholds. Alerts are deduplicated per window and stored in SQLite for history.
|
|
410
|
+
|
|
411
|
+
```json
|
|
412
|
+
{
|
|
413
|
+
"alerts": {
|
|
414
|
+
"enabled": true,
|
|
415
|
+
"webhookUrl": "https://hooks.slack.com/...",
|
|
416
|
+
"cooldownMs": 300000,
|
|
417
|
+
"maxHistory": 500
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
Alert types: `threshold` (budget %), `anomaly` (detection triggers), `breach` (limit exceeded). Severity levels: `info`, `warning`, `critical`.
|
|
423
|
+
|
|
424
|
+
```bash
|
|
425
|
+
relayplane alerts list # Show recent alerts
|
|
426
|
+
relayplane alerts counts # Count by type (threshold/anomaly/breach)
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
## Auto-Downgrade
|
|
430
|
+
|
|
431
|
+
When budget hits a configurable threshold (default 80%), the proxy automatically rewrites expensive models to cheaper alternatives. Adds `X-RelayPlane-Downgraded` headers so your agent knows.
|
|
432
|
+
|
|
433
|
+
```json
|
|
434
|
+
{
|
|
435
|
+
"downgrade": {
|
|
436
|
+
"enabled": true,
|
|
437
|
+
"thresholdPercent": 80,
|
|
438
|
+
"mapping": {
|
|
439
|
+
"claude-opus-4-6": "claude-sonnet-4-6",
|
|
440
|
+
"gpt-4o": "gpt-4o-mini",
|
|
441
|
+
"gemini-2.5-pro": "gemini-2.0-flash"
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
Built-in mappings cover all major Anthropic, OpenAI, and Google models. Override with your own.
|
|
448
|
+
|
|
449
|
+
## Response Cache
|
|
450
|
+
|
|
451
|
+
Caches LLM responses to avoid duplicate API calls. SHA-256 hash of the canonical request → cached response with gzipped disk persistence.
|
|
452
|
+
|
|
453
|
+
```json
|
|
454
|
+
{
|
|
455
|
+
"cache": {
|
|
456
|
+
"enabled": true,
|
|
457
|
+
"mode": "exact",
|
|
458
|
+
"maxSizeMb": 100,
|
|
459
|
+
"defaultTtlSeconds": 3600,
|
|
460
|
+
"onlyWhenDeterministic": true
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
| Mode | Behavior |
|
|
466
|
+
|------|----------|
|
|
467
|
+
| `exact` | Cache only identical requests (default) |
|
|
468
|
+
| `aggressive` | Broader matching with shorter TTL (30 min default) |
|
|
469
|
+
|
|
470
|
+
Only caches deterministic requests (temperature=0) by default. Skips responses with tool calls.
|
|
471
|
+
|
|
472
|
+
```bash
|
|
473
|
+
relayplane cache status # Entries, size, hit rate, saved cost
|
|
474
|
+
relayplane cache stats # Detailed breakdown by model and task type
|
|
475
|
+
relayplane cache clear # Wipe the cache
|
|
476
|
+
relayplane cache on/off # Toggle caching
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
## Osmosis Mesh
|
|
480
|
+
|
|
481
|
+
Opt-in collective learning layer. Share anonymized routing signals (model, task type, tokens, cost — never prompts) and benefit from the network's routing intelligence.
|
|
482
|
+
|
|
483
|
+
```json
|
|
484
|
+
{
|
|
485
|
+
"mesh": {
|
|
486
|
+
"enabled": true,
|
|
487
|
+
"endpoint": "https://osmosis-mesh-dev.fly.dev",
|
|
488
|
+
"sync_interval_ms": 60000,
|
|
489
|
+
"contribute": true
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
Auto-enabled for authenticated users. Contribution is opt-in — set `contribute: false` to consume signals without sharing.
|
|
495
|
+
|
|
496
|
+
```bash
|
|
497
|
+
relayplane mesh status # Atoms local/synced, last sync, endpoint
|
|
498
|
+
relayplane mesh on/off # Enable/disable mesh
|
|
499
|
+
relayplane mesh sync # Force sync now
|
|
500
|
+
relayplane mesh contribute on/off # Toggle contribution
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
## System Service
|
|
504
|
+
|
|
505
|
+
Install RelayPlane as a system service for always-on operation with auto-restart on crash.
|
|
506
|
+
|
|
507
|
+
```bash
|
|
508
|
+
# Linux (systemd)
|
|
509
|
+
sudo relayplane service install # Install + enable + start
|
|
510
|
+
sudo relayplane service uninstall # Stop + disable + remove
|
|
511
|
+
relayplane service status # Check service state
|
|
512
|
+
|
|
513
|
+
# macOS (launchd)
|
|
514
|
+
relayplane service install # Install as LaunchAgent
|
|
515
|
+
relayplane service uninstall # Remove LaunchAgent
|
|
516
|
+
relayplane service status # Check loaded state
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
The service unit includes `WatchdogSec=30` (systemd) and `KeepAlive` (launchd) for automatic health monitoring and restart. API keys from your current environment are captured into the service definition.
|
|
520
|
+
|
|
521
|
+
## Config Resilience
|
|
522
|
+
|
|
523
|
+
Configuration is protected against corruption:
|
|
524
|
+
|
|
525
|
+
- **Atomic writes** — config is written to a `.tmp` file then renamed (no partial writes)
|
|
526
|
+
- **Automatic backup** — `config.json.bak` is updated before every save
|
|
527
|
+
- **Auto-restore** — if `config.json` is corrupt/missing, the proxy restores from backup
|
|
528
|
+
- **Credential separation** — API keys live in `credentials.json`, surviving config resets
|
|
529
|
+
|
|
318
530
|
## Circuit Breaker
|
|
319
531
|
|
|
320
532
|
If the proxy ever fails, all traffic automatically bypasses it — your agent talks directly to the provider. When RelayPlane recovers, traffic resumes. No manual intervention needed.
|
|
321
533
|
|
|
534
|
+
## CLI Reference
|
|
535
|
+
|
|
536
|
+
```
|
|
537
|
+
relayplane [command] [options]
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
| Command | Description |
|
|
541
|
+
|---------|-------------|
|
|
542
|
+
| `(default)` / `start` | Start the proxy server |
|
|
543
|
+
| `init` | Initialize config and show setup instructions |
|
|
544
|
+
| `status` | Show proxy status, plan, and cloud sync info |
|
|
545
|
+
| `login` | Log in to RelayPlane (device OAuth flow) |
|
|
546
|
+
| `logout` | Clear stored credentials |
|
|
547
|
+
| `upgrade` | Open pricing page |
|
|
548
|
+
| `enable` / `disable` | Toggle proxy routing in OpenClaw config |
|
|
549
|
+
| `telemetry on\|off\|status` | Manage telemetry |
|
|
550
|
+
| `stats` | Show usage statistics and savings |
|
|
551
|
+
| `config [set-key <key>]` | Show or update configuration |
|
|
552
|
+
| `budget status\|set\|reset` | Manage spend limits |
|
|
553
|
+
| `alerts list\|counts` | View cost alert history |
|
|
554
|
+
| `cache status\|stats\|clear\|on\|off` | Manage response cache |
|
|
555
|
+
| `mesh status\|on\|off\|sync\|contribute` | Manage Osmosis mesh |
|
|
556
|
+
| `service install\|uninstall\|status` | System service management |
|
|
557
|
+
| `autostart on\|off\|status` | Legacy autostart (systemd) |
|
|
558
|
+
|
|
559
|
+
**Server options:**
|
|
560
|
+
|
|
561
|
+
| Flag | Default | Description |
|
|
562
|
+
|------|---------|-------------|
|
|
563
|
+
| `--port <n>` | `4100` | Port to listen on |
|
|
564
|
+
| `--host <s>` | `127.0.0.1` | Host to bind to |
|
|
565
|
+
| `--offline` | — | No network calls except LLM endpoints |
|
|
566
|
+
| `--audit` | — | Show telemetry payloads before sending |
|
|
567
|
+
| `-v, --verbose` | — | Verbose logging |
|
|
568
|
+
|
|
569
|
+
## Cloud Dashboard & Pro Features
|
|
570
|
+
|
|
571
|
+
The proxy is fully functional without a cloud account. All features above are **local and free**.
|
|
572
|
+
|
|
573
|
+
For teams that want persistent cloud analytics, email digests, and shared routing intelligence, [relayplane.com](https://relayplane.com) offers:
|
|
574
|
+
|
|
575
|
+
| Feature | Plan |
|
|
576
|
+
|---------|------|
|
|
577
|
+
| Cloud dashboard — run history, cost trends, analytics | Starter ($9/mo) |
|
|
578
|
+
| Policy engine — budget rules, model allowlists, approval gates | Starter |
|
|
579
|
+
| Weekly cost digest emails | Starter |
|
|
580
|
+
| Routing recommendations from collective intelligence | Starter |
|
|
581
|
+
| 90-day history, data export | Pro ($29/mo) |
|
|
582
|
+
| Cloud anomaly alerts (email, webhook) | Pro |
|
|
583
|
+
| Team access & shared dashboards | Max ($99/mo) |
|
|
584
|
+
| Governance & compliance rules | Max |
|
|
585
|
+
|
|
586
|
+
**[View pricing →](https://relayplane.com/pricing)**
|
|
587
|
+
|
|
588
|
+
### Connecting to Cloud
|
|
589
|
+
|
|
590
|
+
```bash
|
|
591
|
+
relayplane login # authenticate with your cloud account
|
|
592
|
+
relayplane telemetry on # opt in to send anonymous metadata (model, tokens, cost, latency)
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
> **Privacy-first:** Enabling cloud telemetry sends only anonymous metadata — model name, token counts, cost, latency. Your prompts, inputs, and outputs **never leave your machine**. You can disable anytime: `relayplane telemetry off`.
|
|
596
|
+
|
|
597
|
+
---
|
|
598
|
+
|
|
322
599
|
## Your Keys Stay Yours
|
|
323
600
|
|
|
324
601
|
RelayPlane requires your own provider API keys. Your prompts go directly to LLM providers — never through RelayPlane servers. All proxy execution is local. Telemetry (anonymous metadata only) is opt-in.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[Unit]
|
|
2
|
+
Description=RelayPlane Proxy - Intelligent AI Model Routing
|
|
3
|
+
After=network.target
|
|
4
|
+
StartLimitIntervalSec=300
|
|
5
|
+
StartLimitBurst=5
|
|
6
|
+
|
|
7
|
+
[Service]
|
|
8
|
+
Type=notify
|
|
9
|
+
User=root
|
|
10
|
+
ExecStart=/usr/bin/relayplane
|
|
11
|
+
Restart=always
|
|
12
|
+
RestartSec=5
|
|
13
|
+
WatchdogSec=30
|
|
14
|
+
StandardOutput=journal
|
|
15
|
+
StandardError=journal
|
|
16
|
+
Environment=HOME=/root
|
|
17
|
+
Environment=NODE_ENV=production
|
|
18
|
+
|
|
19
|
+
[Install]
|
|
20
|
+
WantedBy=multi-user.target
|
package/dist/alerts.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RelayPlane Cost Alerts & Webhooks
|
|
3
|
+
*
|
|
4
|
+
* Alert types: threshold (budget %), anomaly, breach.
|
|
5
|
+
* Webhook delivery via POST to configured URL.
|
|
6
|
+
* SQLite storage for alert history.
|
|
7
|
+
* Alert deduplication per window.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import type { AnomalyDetail } from './anomaly.js';
|
|
12
|
+
export interface AlertsConfig {
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
/** Webhook URL for alert delivery */
|
|
15
|
+
webhookUrl?: string;
|
|
16
|
+
/** Alert cooldown in ms to prevent spam (default: 300000 = 5 min) */
|
|
17
|
+
cooldownMs: number;
|
|
18
|
+
/** Max alerts stored in history */
|
|
19
|
+
maxHistory: number;
|
|
20
|
+
}
|
|
21
|
+
export type AlertType = 'threshold' | 'anomaly' | 'breach';
|
|
22
|
+
export interface Alert {
|
|
23
|
+
id: string;
|
|
24
|
+
type: AlertType;
|
|
25
|
+
message: string;
|
|
26
|
+
severity: 'info' | 'warning' | 'critical';
|
|
27
|
+
timestamp: number;
|
|
28
|
+
data: Record<string, unknown>;
|
|
29
|
+
delivered: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare const DEFAULT_ALERTS_CONFIG: AlertsConfig;
|
|
32
|
+
export declare class AlertManager {
|
|
33
|
+
private config;
|
|
34
|
+
private db;
|
|
35
|
+
private _initialized;
|
|
36
|
+
private dedup;
|
|
37
|
+
private memoryAlerts;
|
|
38
|
+
private alertCounter;
|
|
39
|
+
constructor(config?: Partial<AlertsConfig>);
|
|
40
|
+
/** Initialize SQLite storage */
|
|
41
|
+
init(): void;
|
|
42
|
+
updateConfig(config: Partial<AlertsConfig>): void;
|
|
43
|
+
getConfig(): AlertsConfig;
|
|
44
|
+
/**
|
|
45
|
+
* Fire a threshold alert (budget % crossed)
|
|
46
|
+
*/
|
|
47
|
+
fireThreshold(threshold: number, currentPercent: number, currentSpend: number, limit: number): Alert | null;
|
|
48
|
+
/**
|
|
49
|
+
* Fire an anomaly alert
|
|
50
|
+
*/
|
|
51
|
+
fireAnomaly(anomaly: AnomalyDetail): Alert | null;
|
|
52
|
+
/**
|
|
53
|
+
* Fire a breach alert (budget limit exceeded)
|
|
54
|
+
*/
|
|
55
|
+
fireBreach(breachType: string, currentSpend: number, limit: number): Alert | null;
|
|
56
|
+
/**
|
|
57
|
+
* Get recent alerts
|
|
58
|
+
*/
|
|
59
|
+
getRecent(limit?: number): Alert[];
|
|
60
|
+
/**
|
|
61
|
+
* Get alert count by type
|
|
62
|
+
*/
|
|
63
|
+
getCounts(): Record<AlertType, number>;
|
|
64
|
+
close(): void;
|
|
65
|
+
private isDuplicate;
|
|
66
|
+
private createAlert;
|
|
67
|
+
private storeAlert;
|
|
68
|
+
private deliverWebhook;
|
|
69
|
+
}
|
|
70
|
+
export declare function getAlertManager(config?: Partial<AlertsConfig>): AlertManager;
|
|
71
|
+
export declare function resetAlertManager(): void;
|
|
72
|
+
//# sourceMappingURL=alerts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alerts.d.ts","sourceRoot":"","sources":["../src/alerts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAIlD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE3D,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,SAAS,EAAE,OAAO,CAAC;CACpB;AAID,eAAO,MAAM,qBAAqB,EAAE,YAInC,CAAC;AAyBF,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,EAAE,CAAyB;IACnC,OAAO,CAAC,YAAY,CAAS;IAG7B,OAAO,CAAC,KAAK,CAAkC;IAE/C,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,YAAY,CAAK;gBAEb,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC;IAI1C,gCAAgC;IAChC,IAAI,IAAI,IAAI;IAkCZ,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAIjD,SAAS,IAAI,YAAY;IAIzB;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI;IAW3G;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,KAAK,GAAG,IAAI;IAUjD;;OAEG;IACH,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI;IAUjF;;OAEG;IACH,SAAS,CAAC,KAAK,GAAE,MAAW,GAAG,KAAK,EAAE;IAkBtC;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC;IAetC,KAAK,IAAI,IAAI;IAMb,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,WAAW;IAoBnB,OAAO,CAAC,UAAU;IAqBlB,OAAO,CAAC,cAAc;CA8BvB;AAMD,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAK5E;AAED,wBAAgB,iBAAiB,IAAI,IAAI,CAExC"}
|