@relayplane/proxy 0.2.1 → 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 +13 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +637 -0
- package/dist/server.js.map +1 -0
- package/package.json +34 -38
- package/dist/brain-client.d.ts +0 -87
- package/dist/brain-client.d.ts.map +0 -1
- package/dist/brain-client.js +0 -205
- package/dist/brain-client.js.map +0 -1
- 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 -27
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -60
- package/dist/index.js.map +0 -1
- package/dist/standalone-proxy.d.ts +0 -79
- package/dist/standalone-proxy.d.ts.map +0 -1
- package/dist/standalone-proxy.js +0 -2414
- package/dist/standalone-proxy.js.map +0 -1
- package/dist/telemetry.d.ts +0 -127
- package/dist/telemetry.d.ts.map +0 -1
- package/dist/telemetry.js +0 -426
- package/dist/telemetry.js.map +0 -1
package/dist/index.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @relayplane/proxy
|
|
4
|
-
*
|
|
5
|
-
* RelayPlane Agent Ops Proxy Server
|
|
6
|
-
*
|
|
7
|
-
* Intelligent AI model routing with integrated observability.
|
|
8
|
-
* This is a standalone proxy that routes requests to optimal models
|
|
9
|
-
* based on task type and cost optimization.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* import { startProxy } from '@relayplane/proxy';
|
|
14
|
-
*
|
|
15
|
-
* // Start the proxy server
|
|
16
|
-
* await startProxy({ port: 3001 });
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @packageDocumentation
|
|
20
|
-
*/
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.printTelemetryDisclosure = exports.getTelemetryPath = exports.clearTelemetry = exports.getTelemetryStats = exports.getLocalTelemetry = exports.clearAuditBuffer = exports.getAuditBuffer = exports.isOfflineMode = exports.setOfflineMode = exports.isAuditMode = exports.setAuditMode = exports.estimateCost = exports.inferTaskType = exports.recordTelemetry = exports.getConfigPath = exports.getConfigDir = exports.getApiKey = exports.setApiKey = exports.getDeviceId = exports.disableTelemetry = exports.enableTelemetry = exports.isTelemetryEnabled = exports.markFirstRunComplete = exports.isFirstRun = exports.updateConfig = exports.saveConfig = exports.loadConfig = exports.startProxy = void 0;
|
|
23
|
-
// Standalone proxy (requires only @relayplane/core)
|
|
24
|
-
var standalone_proxy_js_1 = require("./standalone-proxy.js");
|
|
25
|
-
Object.defineProperty(exports, "startProxy", { enumerable: true, get: function () { return standalone_proxy_js_1.startProxy; } });
|
|
26
|
-
// Configuration
|
|
27
|
-
var config_js_1 = require("./config.js");
|
|
28
|
-
Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return config_js_1.loadConfig; } });
|
|
29
|
-
Object.defineProperty(exports, "saveConfig", { enumerable: true, get: function () { return config_js_1.saveConfig; } });
|
|
30
|
-
Object.defineProperty(exports, "updateConfig", { enumerable: true, get: function () { return config_js_1.updateConfig; } });
|
|
31
|
-
Object.defineProperty(exports, "isFirstRun", { enumerable: true, get: function () { return config_js_1.isFirstRun; } });
|
|
32
|
-
Object.defineProperty(exports, "markFirstRunComplete", { enumerable: true, get: function () { return config_js_1.markFirstRunComplete; } });
|
|
33
|
-
Object.defineProperty(exports, "isTelemetryEnabled", { enumerable: true, get: function () { return config_js_1.isTelemetryEnabled; } });
|
|
34
|
-
Object.defineProperty(exports, "enableTelemetry", { enumerable: true, get: function () { return config_js_1.enableTelemetry; } });
|
|
35
|
-
Object.defineProperty(exports, "disableTelemetry", { enumerable: true, get: function () { return config_js_1.disableTelemetry; } });
|
|
36
|
-
Object.defineProperty(exports, "getDeviceId", { enumerable: true, get: function () { return config_js_1.getDeviceId; } });
|
|
37
|
-
Object.defineProperty(exports, "setApiKey", { enumerable: true, get: function () { return config_js_1.setApiKey; } });
|
|
38
|
-
Object.defineProperty(exports, "getApiKey", { enumerable: true, get: function () { return config_js_1.getApiKey; } });
|
|
39
|
-
Object.defineProperty(exports, "getConfigDir", { enumerable: true, get: function () { return config_js_1.getConfigDir; } });
|
|
40
|
-
Object.defineProperty(exports, "getConfigPath", { enumerable: true, get: function () { return config_js_1.getConfigPath; } });
|
|
41
|
-
// Telemetry
|
|
42
|
-
var telemetry_js_1 = require("./telemetry.js");
|
|
43
|
-
Object.defineProperty(exports, "recordTelemetry", { enumerable: true, get: function () { return telemetry_js_1.recordTelemetry; } });
|
|
44
|
-
Object.defineProperty(exports, "inferTaskType", { enumerable: true, get: function () { return telemetry_js_1.inferTaskType; } });
|
|
45
|
-
Object.defineProperty(exports, "estimateCost", { enumerable: true, get: function () { return telemetry_js_1.estimateCost; } });
|
|
46
|
-
Object.defineProperty(exports, "setAuditMode", { enumerable: true, get: function () { return telemetry_js_1.setAuditMode; } });
|
|
47
|
-
Object.defineProperty(exports, "isAuditMode", { enumerable: true, get: function () { return telemetry_js_1.isAuditMode; } });
|
|
48
|
-
Object.defineProperty(exports, "setOfflineMode", { enumerable: true, get: function () { return telemetry_js_1.setOfflineMode; } });
|
|
49
|
-
Object.defineProperty(exports, "isOfflineMode", { enumerable: true, get: function () { return telemetry_js_1.isOfflineMode; } });
|
|
50
|
-
Object.defineProperty(exports, "getAuditBuffer", { enumerable: true, get: function () { return telemetry_js_1.getAuditBuffer; } });
|
|
51
|
-
Object.defineProperty(exports, "clearAuditBuffer", { enumerable: true, get: function () { return telemetry_js_1.clearAuditBuffer; } });
|
|
52
|
-
Object.defineProperty(exports, "getLocalTelemetry", { enumerable: true, get: function () { return telemetry_js_1.getLocalTelemetry; } });
|
|
53
|
-
Object.defineProperty(exports, "getTelemetryStats", { enumerable: true, get: function () { return telemetry_js_1.getTelemetryStats; } });
|
|
54
|
-
Object.defineProperty(exports, "clearTelemetry", { enumerable: true, get: function () { return telemetry_js_1.clearTelemetry; } });
|
|
55
|
-
Object.defineProperty(exports, "getTelemetryPath", { enumerable: true, get: function () { return telemetry_js_1.getTelemetryPath; } });
|
|
56
|
-
Object.defineProperty(exports, "printTelemetryDisclosure", { enumerable: true, get: function () { return telemetry_js_1.printTelemetryDisclosure; } });
|
|
57
|
-
// Note: Advanced features (ProxyServer, streaming, etc.) require additional
|
|
58
|
-
// dependencies. Install @relayplane/ledger, @relayplane/auth-gate, etc.
|
|
59
|
-
// for full functionality. See documentation for details.
|
|
60
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AAEH,oDAAoD;AACpD,6DAAmD;AAA1C,iHAAA,UAAU,OAAA;AAGnB,gBAAgB;AAChB,yCAcqB;AAbnB,uGAAA,UAAU,OAAA;AACV,uGAAA,UAAU,OAAA;AACV,yGAAA,YAAY,OAAA;AACZ,uGAAA,UAAU,OAAA;AACV,iHAAA,oBAAoB,OAAA;AACpB,+GAAA,kBAAkB,OAAA;AAClB,4GAAA,eAAe,OAAA;AACf,6GAAA,gBAAgB,OAAA;AAChB,wGAAA,WAAW,OAAA;AACX,sGAAA,SAAS,OAAA;AACT,sGAAA,SAAS,OAAA;AACT,yGAAA,YAAY,OAAA;AACZ,0GAAA,aAAa,OAAA;AAIf,YAAY;AACZ,+CAewB;AAdtB,+GAAA,eAAe,OAAA;AACf,6GAAA,aAAa,OAAA;AACb,4GAAA,YAAY,OAAA;AACZ,4GAAA,YAAY,OAAA;AACZ,2GAAA,WAAW,OAAA;AACX,8GAAA,cAAc,OAAA;AACd,6GAAA,aAAa,OAAA;AACb,8GAAA,cAAc,OAAA;AACd,gHAAA,gBAAgB,OAAA;AAChB,iHAAA,iBAAiB,OAAA;AACjB,iHAAA,iBAAiB,OAAA;AACjB,8GAAA,cAAc,OAAA;AACd,gHAAA,gBAAgB,OAAA;AAChB,wHAAA,wBAAwB,OAAA;AAO1B,4EAA4E;AAC5E,wEAAwE;AACxE,yDAAyD"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RelayPlane L2/L3 Proxy Server
|
|
3
|
-
*
|
|
4
|
-
* An LLM Gateway proxy that intelligently routes requests
|
|
5
|
-
* to the optimal model using @relayplane/core.
|
|
6
|
-
*
|
|
7
|
-
* Supports:
|
|
8
|
-
* - OpenAI-compatible API (/v1/chat/completions)
|
|
9
|
-
* - Native Anthropic API (/v1/messages) for Claude Code integration
|
|
10
|
-
* - Streaming (SSE) for both OpenAI and Anthropic formats
|
|
11
|
-
* - Auth passthrough for Claude Code (OAuth/subscription billing)
|
|
12
|
-
* - Cross-provider routing (Anthropic, OpenAI, Google, xAI)
|
|
13
|
-
* - Tool/function calling with format conversion
|
|
14
|
-
*
|
|
15
|
-
* Authentication:
|
|
16
|
-
* - Anthropic: Passthrough incoming Authorization header OR ANTHROPIC_API_KEY env
|
|
17
|
-
* - Other providers: Require provider-specific API key env vars
|
|
18
|
-
*
|
|
19
|
-
* @packageDocumentation
|
|
20
|
-
*/
|
|
21
|
-
import * as http from 'node:http';
|
|
22
|
-
import type { Provider } from '@relayplane/core';
|
|
23
|
-
/**
|
|
24
|
-
* Provider endpoint configuration
|
|
25
|
-
*/
|
|
26
|
-
export interface ProviderEndpoint {
|
|
27
|
-
baseUrl: string;
|
|
28
|
-
apiKeyEnv: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Default provider endpoints
|
|
32
|
-
*/
|
|
33
|
-
export declare const DEFAULT_ENDPOINTS: Record<string, ProviderEndpoint>;
|
|
34
|
-
/**
|
|
35
|
-
* Model to provider/model mapping
|
|
36
|
-
*/
|
|
37
|
-
export declare const MODEL_MAPPING: Record<string, {
|
|
38
|
-
provider: Provider;
|
|
39
|
-
model: string;
|
|
40
|
-
}>;
|
|
41
|
-
type RoutingSuffix = 'cost' | 'fast' | 'quality';
|
|
42
|
-
interface ParsedModel {
|
|
43
|
-
baseModel: string;
|
|
44
|
-
suffix: RoutingSuffix | null;
|
|
45
|
-
}
|
|
46
|
-
interface CascadeConfig {
|
|
47
|
-
enabled: boolean;
|
|
48
|
-
models: string[];
|
|
49
|
-
escalateOn: 'uncertainty' | 'refusal' | 'error';
|
|
50
|
-
maxEscalations: number;
|
|
51
|
-
}
|
|
52
|
-
type Complexity = 'simple' | 'moderate' | 'complex';
|
|
53
|
-
/**
|
|
54
|
-
* Proxy server configuration
|
|
55
|
-
*/
|
|
56
|
-
export interface ProxyConfig {
|
|
57
|
-
port?: number;
|
|
58
|
-
host?: string;
|
|
59
|
-
dbPath?: string;
|
|
60
|
-
verbose?: boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Auth passthrough mode for Anthropic requests.
|
|
63
|
-
* - 'passthrough': Forward incoming Authorization header to Anthropic (for Claude Code OAuth)
|
|
64
|
-
* - 'env': Always use ANTHROPIC_API_KEY env var
|
|
65
|
-
* - 'auto' (default): Use incoming auth if present, fallback to env var
|
|
66
|
-
*/
|
|
67
|
-
anthropicAuth?: 'passthrough' | 'env' | 'auto';
|
|
68
|
-
}
|
|
69
|
-
export declare function parseModelSuffix(model: string): ParsedModel;
|
|
70
|
-
export declare function classifyComplexity(messages: Array<{
|
|
71
|
-
content?: unknown;
|
|
72
|
-
}>): Complexity;
|
|
73
|
-
export declare function shouldEscalate(responseText: string, trigger: CascadeConfig['escalateOn']): boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Start the RelayPlane proxy server
|
|
76
|
-
*/
|
|
77
|
-
export declare function startProxy(config?: ProxyConfig): Promise<http.Server>;
|
|
78
|
-
export {};
|
|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