@elsium-ai/gateway 0.1.6
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/dist/bulkhead.d.ts +14 -0
- package/dist/bulkhead.d.ts.map +1 -0
- package/dist/gateway.d.ts +32 -0
- package/dist/gateway.d.ts.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2591 -0
- package/dist/middleware.d.ts +19 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/pricing.d.ts +5 -0
- package/dist/pricing.d.ts.map +1 -0
- package/dist/provider.d.ts +31 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/providers/anthropic.d.ts +4 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/google.d.ts +4 -0
- package/dist/providers/google.d.ts.map +1 -0
- package/dist/providers/openai.d.ts +4 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/router.d.ts +38 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/security.d.ts +33 -0
- package/dist/security.d.ts.map +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Middleware } from '@elsium-ai/core';
|
|
2
|
+
export interface BulkheadConfig {
|
|
3
|
+
maxConcurrent?: number;
|
|
4
|
+
maxQueued?: number;
|
|
5
|
+
queueTimeoutMs?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface Bulkhead {
|
|
8
|
+
execute<T>(fn: () => Promise<T>): Promise<T>;
|
|
9
|
+
readonly active: number;
|
|
10
|
+
readonly queued: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function createBulkhead(config?: BulkheadConfig): Bulkhead;
|
|
13
|
+
export declare function bulkheadMiddleware(config?: BulkheadConfig): Middleware;
|
|
14
|
+
//# sourceMappingURL=bulkhead.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bulkhead.d.ts","sourceRoot":"","sources":["../src/bulkhead.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAqC,MAAM,iBAAiB,CAAA;AAGpF,MAAM,WAAW,cAAc;IAC9B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,QAAQ;IACxB,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACvB;AAED,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,QAAQ,CAgGhE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,UAAU,CAMtE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CompletionRequest, LLMResponse, Middleware, ProviderConfig, XRayData } from '@elsium-ai/core';
|
|
2
|
+
import { type ElsiumStream } from '@elsium-ai/core';
|
|
3
|
+
import type { z } from 'zod';
|
|
4
|
+
import type { LLMProvider } from './provider';
|
|
5
|
+
export interface GatewayConfig {
|
|
6
|
+
provider: string;
|
|
7
|
+
model?: string;
|
|
8
|
+
apiKey: string;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
timeout?: number;
|
|
11
|
+
maxRetries?: number;
|
|
12
|
+
middleware?: Middleware[];
|
|
13
|
+
xray?: boolean | {
|
|
14
|
+
maxHistory?: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface Gateway {
|
|
18
|
+
complete(request: CompletionRequest): Promise<LLMResponse>;
|
|
19
|
+
stream(request: CompletionRequest): ElsiumStream;
|
|
20
|
+
generate<T>(request: CompletionRequest & {
|
|
21
|
+
schema: z.ZodType<T>;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
data: T;
|
|
24
|
+
response: LLMResponse;
|
|
25
|
+
}>;
|
|
26
|
+
readonly provider: LLMProvider;
|
|
27
|
+
lastCall(): XRayData | null;
|
|
28
|
+
callHistory(limit?: number): XRayData[];
|
|
29
|
+
}
|
|
30
|
+
export declare function registerProviderFactory(name: string, factory: (config: ProviderConfig) => LLMProvider): void;
|
|
31
|
+
export declare function gateway(config: GatewayConfig): Gateway;
|
|
32
|
+
//# sourceMappingURL=gateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,iBAAiB,EACjB,WAAW,EACX,UAAU,EAEV,cAAc,EACd,QAAQ,EACR,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAe,KAAK,YAAY,EAAiC,MAAM,iBAAiB,CAAA;AAC/F,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAI5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAM7C,MAAM,WAAW,aAAa;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,UAAU,EAAE,CAAA;IACzB,IAAI,CAAC,EAAE,OAAO,GAAG;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CACxC;AAED,MAAM,WAAW,OAAO;IACvB,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;IAC1D,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,YAAY,CAAA;IAChD,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,iBAAiB,GAAG;QAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC;QAC3E,IAAI,EAAE,CAAC,CAAA;QACP,QAAQ,EAAE,WAAW,CAAA;KACrB,CAAC,CAAA;IACF,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAA;IAC9B,QAAQ,IAAI,QAAQ,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,EAAE,CAAA;CACvC;AAQD,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,WAAW,GAC9C,IAAI,CAEN;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CA6JtD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { gateway, registerProviderFactory } from './gateway';
|
|
2
|
+
export type { GatewayConfig, Gateway } from './gateway';
|
|
3
|
+
export type { LLMProvider, ProviderFactory, ProviderMetadata, ModelPricing, ModelTier, } from './provider';
|
|
4
|
+
export { registerProvider, getProviderFactory, listProviders, registerProviderMetadata, getProviderMetadata, } from './provider';
|
|
5
|
+
export { createAnthropicProvider } from './providers/anthropic';
|
|
6
|
+
export { createOpenAIProvider } from './providers/openai';
|
|
7
|
+
export { createGoogleProvider } from './providers/google';
|
|
8
|
+
export { composeMiddleware, loggingMiddleware, costTrackingMiddleware, xrayMiddleware, } from './middleware';
|
|
9
|
+
export type { XRayStore } from './middleware';
|
|
10
|
+
export { securityMiddleware, detectPromptInjection, detectJailbreak, redactSecrets, checkBlockedPatterns, classifyContent, } from './security';
|
|
11
|
+
export type { SecurityMiddlewareConfig, SecurityViolation, SecurityResult, DataClassification, ClassificationResult, } from './security';
|
|
12
|
+
export { createBulkhead, bulkheadMiddleware } from './bulkhead';
|
|
13
|
+
export type { BulkheadConfig, Bulkhead } from './bulkhead';
|
|
14
|
+
export { calculateCost, registerPricing } from './pricing';
|
|
15
|
+
export { createProviderMesh } from './router';
|
|
16
|
+
export type { ProviderMeshConfig, ProviderEntry, RoutingStrategy, ProviderMesh } from './router';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AAC5D,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGvD,YAAY,EACX,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,SAAS,GACT,MAAM,YAAY,CAAA;AACnB,OAAO,EACN,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,wBAAwB,EACxB,mBAAmB,GACnB,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAGzD,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,GACd,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAG7C,OAAO,EACN,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,eAAe,GACf,MAAM,YAAY,CAAA;AACnB,YAAY,EACX,wBAAwB,EACxB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,oBAAoB,GACpB,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/D,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAG1D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAG1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC7C,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA"}
|