@relayplane/proxy 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 RelayPlane
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,156 @@
1
+ # @relayplane/proxy
2
+
3
+ **100% Local. Zero Cloud. Full Control.**
4
+
5
+ Intelligent AI model routing that cuts costs by 50-80% while maintaining quality.
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@relayplane/proxy)](https://www.npmjs.com/package/@relayplane/proxy)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install @relayplane/proxy
14
+ ```
15
+
16
+ Or run directly:
17
+
18
+ ```bash
19
+ npx @relayplane/proxy
20
+ ```
21
+
22
+ ## Quick Start
23
+
24
+ ### 1. Set your API keys
25
+
26
+ ```bash
27
+ export ANTHROPIC_API_KEY="sk-ant-..."
28
+ export OPENAI_API_KEY="sk-..."
29
+ # Optional: GEMINI_API_KEY, XAI_API_KEY, MOONSHOT_API_KEY
30
+ ```
31
+
32
+ ### 2. Start the proxy
33
+
34
+ ```bash
35
+ npx @relayplane/proxy --port 3001
36
+ ```
37
+
38
+ ### 3. Point your tools to the proxy
39
+
40
+ ```bash
41
+ export ANTHROPIC_BASE_URL=http://localhost:3001
42
+ export OPENAI_BASE_URL=http://localhost:3001
43
+
44
+ # Now run OpenClaw, Cursor, Aider, or any tool
45
+ openclaw
46
+ ```
47
+
48
+ That's it. All API calls now route through RelayPlane for intelligent model selection.
49
+
50
+ ## How It Works
51
+
52
+ ```
53
+ Your Tool (OpenClaw, Cursor, etc.)
54
+
55
+
56
+ RelayPlane Proxy
57
+ ├── Infers task type (code_review, analysis, etc.)
58
+ ├── Checks routing rules
59
+ ├── Selects optimal model (Haiku for simple, Opus for complex)
60
+ └── Tracks outcomes for learning
61
+
62
+
63
+ Provider (Anthropic, OpenAI, etc.)
64
+ ```
65
+
66
+ ## Supported Providers
67
+
68
+ | Provider | Models | Streaming | Tools |
69
+ |----------|--------|-----------|-------|
70
+ | **Anthropic** | Claude Opus, Sonnet, Haiku | ✓ | ✓ |
71
+ | **OpenAI** | GPT-4o, GPT-4o-mini, o1, o3 | ✓ | ✓ |
72
+ | **Google** | Gemini 2.0 Flash, 1.5 Pro | ✓ | — |
73
+ | **xAI** | Grok-2, Grok-2-mini | ✓ | ✓ |
74
+ | **Moonshot** | v1-8k, v1-32k, v1-128k | ✓ | ✓ |
75
+
76
+ ## Routing Modes
77
+
78
+ | Model | Description |
79
+ |-------|-------------|
80
+ | `relayplane:auto` | Infers task type, routes to optimal model |
81
+ | `relayplane:cost` | Prioritizes cheapest models (maximum savings) |
82
+ | `relayplane:quality` | Uses best available model |
83
+
84
+ Or pass through explicit models: `claude-3-5-sonnet-latest`, `gpt-4o`, etc.
85
+
86
+ ## Why RelayPlane?
87
+
88
+ | Without RelayPlane | With RelayPlane |
89
+ |-------------------|-----------------|
90
+ | Pay Opus prices for simple tasks | Route simple tasks to Haiku (1/10 cost) |
91
+ | Static model selection | Learns from outcomes over time |
92
+ | Manual optimization | Automatic cost-quality balance |
93
+ | No visibility into spend | Built-in savings tracking |
94
+
95
+ ## Key Features
96
+
97
+ - **100% Local** — All data in SQLite (`~/.relayplane/data.db`)
98
+ - **Zero Friction** — Set 2 env vars, done
99
+ - **Learning** — Improves routing based on outcomes
100
+ - **Full Streaming** — SSE support for all providers
101
+ - **Tool Calls** — Function calling across providers
102
+
103
+ ## Programmatic Usage
104
+
105
+ ```typescript
106
+ import { startProxy, RelayPlane, calculateSavings } from '@relayplane/proxy';
107
+
108
+ // Start the proxy
109
+ await startProxy({ port: 3001, verbose: true });
110
+
111
+ // Or use RelayPlane directly
112
+ const relay = new RelayPlane({});
113
+ const result = await relay.run({ prompt: 'Review this code...' });
114
+ console.log(result.taskType); // 'code_review'
115
+ console.log(result.model); // 'anthropic:claude-3-5-haiku-latest'
116
+
117
+ // Check savings
118
+ const savings = calculateSavings(relay.store, 30);
119
+ console.log(`Saved ${savings.savingsPercent}% this month`);
120
+
121
+ relay.close();
122
+ ```
123
+
124
+ ## CLI Options
125
+
126
+ ```bash
127
+ npx @relayplane/proxy [options]
128
+
129
+ Options:
130
+ --port <number> Port to listen on (default: 3001)
131
+ --host <string> Host to bind to (default: 127.0.0.1)
132
+ -v, --verbose Enable verbose logging
133
+ -h, --help Show help
134
+ ```
135
+
136
+ ## Data Storage
137
+
138
+ All data stored locally at `~/.relayplane/data.db` (SQLite).
139
+
140
+ ```bash
141
+ # View recent runs
142
+ sqlite3 ~/.relayplane/data.db "SELECT * FROM runs ORDER BY timestamp DESC LIMIT 10"
143
+
144
+ # Check routing rules
145
+ sqlite3 ~/.relayplane/data.db "SELECT * FROM routing_rules"
146
+ ```
147
+
148
+ ## Links
149
+
150
+ - [Documentation](https://relayplane.com/integrations/openclaw)
151
+ - [GitHub](https://github.com/RelayPlane/proxy)
152
+ - [RelayPlane SDK](https://github.com/RelayPlane/sdk)
153
+
154
+ ## License
155
+
156
+ MIT
package/dist/cli.d.mts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node