UNPKG

@tehreet/conduit

Version:

LLM API gateway with intelligent routing, robust process management, and health monitoring

122 lines 3.25 kB
import { EventEmitter } from 'events'; import { ConduitConfig, RoutingContext, RoutingDecision, SynapseContext, UsageData } from '../types'; export interface SynapseRoutingResult { model: string; provider: string; decision: RoutingDecision; metadata: SynapseRoutingMetadata; } export interface SynapseRoutingMetadata { projectId?: string; agentId?: string; agentType?: string; originalModel?: string; routingReason: string; contextSource: 'project' | 'agent' | 'fallback'; timestamp: string; } export interface SynapseUsageData extends UsageData { projectId?: string; agentId?: string; agentType?: string; originalModel?: string; routedModel: string; provider: string; contextSource: 'project' | 'agent' | 'fallback'; } /** * Synapse integration layer for Conduit */ export declare class SynapseIntegration extends EventEmitter { private router; private usageTracker; private contextExtractor; private config; constructor(config: ConduitConfig); /** * Initialize the Synapse integration */ initialize(): Promise<void>; /** * Route a Claude CLI request with Synapse context */ routeClaudeRequest(args: string[], env?: NodeJS.ProcessEnv): Promise<SynapseRoutingResult>; /** * Track usage data for Synapse integration */ trackUsage(routingResult: SynapseRoutingResult, context: RoutingContext): Promise<void>; /** * Get usage statistics for a project */ getProjectUsage(projectId: string, timeRange?: { start: Date; end: Date; }): Promise<any>; /** * Get usage statistics for an agent */ getAgentUsage(agentId: string, timeRange?: { start: Date; end: Date; }): Promise<any>; /** * Get cost breakdown for a project */ getProjectCostBreakdown(projectId: string): Promise<any>; /** * Update configuration */ updateConfig(config: Partial<ConduitConfig>): Promise<void>; /** * Get current configuration */ getConfig(): ConduitConfig; /** * Get Synapse context from environment */ extractSynapseContext(env?: NodeJS.ProcessEnv): SynapseContext; /** * Test routing with given context */ testRouting(message: string, synapseContext?: Partial<SynapseContext>, options?: { model?: string; thinking?: boolean; }): Promise<SynapseRoutingResult>; /** * Parse Claude CLI arguments */ private parseClaudeArgs; /** * Estimate token count for request */ private estimateTokenCount; /** * Extract provider from model name */ private extractProvider; /** * Determine context source based on routing decision */ private determineContextSource; /** * Calculate cost for usage */ private calculateCost; /** * Generate unique request ID */ private generateRequestId; /** * Generate unique usage ID */ private generateUsageId; /** * Set up event forwarding */ private setupEventForwarding; /** * Cleanup resources */ cleanup(): Promise<void>; } //# sourceMappingURL=synapse.d.ts.map