utils

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExampleManifestMerger

func ExampleManifestMerger()

func FormatTimeout

func FormatTimeout(ctx context.Context, d time.Duration) (string, error)

func SanitizeString

func SanitizeString(s string) string

func ValidatePath added in v0.6.0

func ValidatePath(path string, baseDir string) error

func ValidatePort

func ValidatePort(port int) error

Types

type AuthConfig

type AuthConfig struct {
	Token  string    `json:"token" yaml:"token"`
	Header string    `json:"header" yaml:"header"`
	Expiry time.Time `json:"expiry" yaml:"expiry"`
	Scopes []string  `json:"scopes" yaml:"scopes"`
	Meta   Metadata  `json:"_meta,omitempty" yaml:"_meta,omitempty"`
}

type Clock added in v0.6.0

type Clock interface {
	Now() time.Time
	Since(time.Time) time.Duration
}

type ComparisonResult added in v0.3.0

type ComparisonResult struct {
	NativeMCPTokens int                      `json:"native_mcp_tokens"`
	LeanProxyTokens int                      `json:"leanproxy_tokens"`
	SavedTokens     int                      `json:"saved_tokens"`
	SavingsPercent  float64                  `json:"savings_percent"`
	ServerBreakdown []MCPServerAnalysis      `json:"server_breakdown"`
	MonthlySavings  map[string]MonthlySaving `json:"monthly_savings"`
}

type Config

type Config struct {
	Version string         `json:"version" yaml:"version"`
	Name    string         `json:"name" yaml:"name"`
	Servers []ServerConfig `json:"servers" yaml:"servers"`
	Auth    *AuthConfig    `json:"auth,omitempty" yaml:"auth,omitempty"`
	Limits  *LimitsConfig  `json:"limits,omitempty" yaml:"limits,omitempty"`
	Logging *LoggingConfig `json:"logging,omitempty" yaml:"logging,omitempty"`
	Meta    Metadata       `json:"_meta,omitempty" yaml:"_meta,omitempty"`
}

type CumulativeSavings added in v0.2.0

type CumulativeSavings struct {
	TotalOriginal     int64
	TotalOptimized    int64
	TotalSaved        int64
	SessionDuration   time.Duration
	RequestsProcessed int
}

type FakeClock added in v0.6.0

type FakeClock struct {
	// contains filtered or unexported fields
}

func NewFakeClock added in v0.6.0

func NewFakeClock(t time.Time) *FakeClock

func (*FakeClock) Add added in v0.6.0

func (fc *FakeClock) Add(d time.Duration)

func (*FakeClock) Now added in v0.6.0

func (fc *FakeClock) Now() time.Time

func (*FakeClock) Set added in v0.6.0

func (fc *FakeClock) Set(t time.Time)

func (*FakeClock) Since added in v0.6.0

func (fc *FakeClock) Since(t time.Time) time.Duration

type Layer

type Layer struct {
	Source string
	Config *Config
}

type LimitsConfig

type LimitsConfig struct {
	MaxConnections int      `json:"maxConnections" yaml:"maxConnections"`
	TimeoutSeconds int      `json:"timeoutSeconds" yaml:"timeoutSeconds"`
	Meta           Metadata `json:"_meta,omitempty" yaml:"_meta,omitempty"`
}

type LoggingConfig

type LoggingConfig struct {
	Level      string   `json:"level" yaml:"level"`
	Format     string   `json:"format" yaml:"format"`
	OutputPath string   `json:"outputPath" yaml:"outputPath"`
	Meta       Metadata `json:"_meta,omitempty" yaml:"_meta,omitempty"`
}

type MCPServerAnalysis added in v0.3.0

type MCPServerAnalysis struct {
	Name             string `json:"name"`
	EstimatedTokens  int    `json:"estimated_tokens"`
	ToolCount        int    `json:"tool_count"`
	EstimatedPerTool int    `json:"estimated_per_tool"`
}

type MCPServerConfig added in v0.3.0

type MCPServerConfig struct {
	Command string   `json:"command"`
	Args    []string `json:"args"`
}

type ManifestMerger

type ManifestMerger struct {
	// contains filtered or unexported fields
}

func NewManifestMerger

func NewManifestMerger(logger *slog.Logger) *ManifestMerger

func (*ManifestMerger) Merge

func (m *ManifestMerger) Merge(ctx context.Context, configs ...*Config) (*Config, error)

func (*ManifestMerger) MergeFiles

func (m *ManifestMerger) MergeFiles(ctx context.Context, paths ...string) (*Config, error)

func (*ManifestMerger) MergeWithLayers

func (m *ManifestMerger) MergeWithLayers(ctx context.Context, layers ...Layer) (*MergedConfig, error)

func (*ManifestMerger) Validate

func (m *ManifestMerger) Validate(cfg *Config) error

type MergedConfig

type MergedConfig struct {
	Config    *Config             `json:"config"`
	Sources   map[string][]string `json:"sources"`
	Timestamp time.Time           `json:"timestamp"`
}

type Metadata

type Metadata struct {
	Source   string   `json:"source" yaml:"source"`
	Priority int      `json:"priority" yaml:"priority"`
	Sources  []string `json:"sources" yaml:"sources"`
}

type MonthlySaving added in v0.3.0

type MonthlySaving struct {
	Model      string  `json:"model"`
	Sessions   int     `json:"sessions"`
	SavingsUSD float64 `json:"savings_usd"`
	InputRate  float64 `json:"input_rate"`
	OutputRate float64 `json:"output_rate"`
}

type RealClock added in v0.6.0

type RealClock struct{}

func (RealClock) Now added in v0.6.0

func (RealClock) Now() time.Time

func (RealClock) Since added in v0.6.0

func (RealClock) Since(t time.Time) time.Duration

type ReportGenerator added in v0.2.0

type ReportGenerator struct{}

func NewReportGenerator added in v0.2.0

func NewReportGenerator() *ReportGenerator

func (*ReportGenerator) GenerateJSONReport added in v0.2.0

func (rg *ReportGenerator) GenerateJSONReport(sessionData SessionMetrics) string

func (*ReportGenerator) GenerateMarkdownReport added in v0.2.0

func (rg *ReportGenerator) GenerateMarkdownReport(sessionData SessionMetrics) string

func (*ReportGenerator) NewEmptySessionMetrics added in v0.2.0

func (rg *ReportGenerator) NewEmptySessionMetrics() SessionMetrics

func (*ReportGenerator) NewSessionMetrics added in v0.2.0

func (rg *ReportGenerator) NewSessionMetrics() SessionMetrics

type SavingsResult added in v0.2.0

type SavingsResult struct {
	OriginalTokens  int
	OptimizedTokens int
	SavedTokens     int
	SavingsPercent  float64
	Breakdown       map[string]int
}

type SavingsTracker added in v0.2.0

type SavingsTracker struct {
	// contains filtered or unexported fields
}

func NewSavingsTracker added in v0.2.0

func NewSavingsTracker() *SavingsTracker

func (*SavingsTracker) GetCumulativeSavings added in v0.2.0

func (s *SavingsTracker) GetCumulativeSavings() CumulativeSavings

func (*SavingsTracker) GetServerBreakdown added in v0.2.0

func (s *SavingsTracker) GetServerBreakdown() map[string]ServerSavings

func (*SavingsTracker) RecordRequest added in v0.2.0

func (s *SavingsTracker) RecordRequest(serverName string, original, optimized string) error

func (*SavingsTracker) Reset added in v0.2.0

func (s *SavingsTracker) Reset()

type SecurityEvent added in v0.2.0

type SecurityEvent struct {
	Timestamp      time.Time
	EventType      string
	PatternMatched string
	ServerName     string
	Redacted       bool
}

type ServerConfig

type ServerConfig struct {
	ID       string   `json:"id" yaml:"id"`
	Command  []string `json:"command" yaml:"command"`
	Env      []string `json:"env,omitempty" yaml:"env,omitempty"`
	Port     int      `json:"port" yaml:"port"`
	Metadata Metadata `json:"_meta,omitempty" yaml:"_meta,omitempty"`
}

type ServerMetrics added in v0.2.0

type ServerMetrics struct {
	ServerName      string
	RequestsHandled int
	Uptime          time.Duration
	Errors          int
	TokenSavings    ServerTokenSavings
}

type ServerSavings added in v0.2.0

type ServerSavings struct {
	ServerName      string
	OriginalTokens  int64
	OptimizedTokens int64
	SavedTokens     int64
}

type ServerTokenSavings added in v0.2.0

type ServerTokenSavings struct {
	ServerName      string
	OriginalTokens  int64
	OptimizedTokens int64
	SavedTokens     int64
}

type SessionMetrics added in v0.2.0

type SessionMetrics struct {
	SessionID      string
	SessionStart   time.Time
	SessionEnd     time.Time
	TotalRequests  int
	TokenSavings   TokenSavingsSummary
	SecurityEvents []SecurityEvent
	ServerMetrics  map[string]ServerMetrics
}

type StatusDisplay added in v0.2.0

type StatusDisplay struct {
	// contains filtered or unexported fields
}

func NewStatusDisplay added in v0.2.0

func NewStatusDisplay() *StatusDisplay

func (*StatusDisplay) RenderCompact added in v0.2.0

func (sd *StatusDisplay) RenderCompact(status proxy.ServerStatus) string

func (*StatusDisplay) RenderJSON added in v0.2.0

func (sd *StatusDisplay) RenderJSON(statusList proxy.ServerStatusList) (string, error)

func (*StatusDisplay) RenderTable added in v0.2.0

func (sd *StatusDisplay) RenderTable(statusList proxy.ServerStatusList) string

func (*StatusDisplay) RenderVerbose added in v0.2.0

func (sd *StatusDisplay) RenderVerbose(statusList proxy.ServerStatusList) string

type TokenEstimator added in v0.2.0

type TokenEstimator struct{}

func NewTokenEstimator added in v0.2.0

func NewTokenEstimator() *TokenEstimator

func (*TokenEstimator) CalculateSavings added in v0.2.0

func (t *TokenEstimator) CalculateSavings(original, optimized string) (SavingsResult, error)

func (*TokenEstimator) CompareMCPConfigurations added in v0.3.0

func (t *TokenEstimator) CompareMCPConfigurations(servers map[string]MCPServerConfig) ComparisonResult

func (*TokenEstimator) EstimateLeanProxySchemaTokens added in v0.3.0

func (t *TokenEstimator) EstimateLeanProxySchemaTokens() int

func (*TokenEstimator) EstimateNativeMCPOverhead added in v0.3.0

func (t *TokenEstimator) EstimateNativeMCPOverhead(serverName string, toolCount int) int

func (*TokenEstimator) EstimateTokens added in v0.2.0

func (t *TokenEstimator) EstimateTokens(content string) int

type TokenSavingsSummary added in v0.2.0

type TokenSavingsSummary struct {
	OriginalTokens    int64
	OptimizedTokens   int64
	SavedTokens       int64
	SavingsPercentage float64
	ByServer          map[string]ServerTokenSavings
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL