Versions in this module Expand all Collapse all v0 v0.1.0 Sep 10, 2026 Changes in this version + const APIKeyHeader + const AgentIDHeader + const ProjectHeader + var ErrInvalidKey = errors.New("proxy: invalid API key") + var MaxBodyBytes int64 = 10 << 20 + func DashboardHandler() http.Handler + func HashAPIKey(raw string) string + func MetricsHandler(m *Metrics, det circuitbreaker.Detector) http.Handler + func Middleware(a Authenticator, next http.Handler) http.Handler + func NewHandler(upstream *url.URL, det circuitbreaker.Detector, price pricing.PriceSource, ...) http.Handler + func WithCaller(ctx context.Context, c Caller) context.Context + type Authenticator interface + Authenticate func(rawKey string) (Caller, error) + func NewAuthenticator(store CallerStore) Authenticator + func Noop() Authenticator + type BudgetConfig struct + DailyBudgetMicro int64 + ThresholdPct []int + type BudgetLedger interface + SumActualCostForKeySince func(ctx context.Context, keyID string, since int64) (int64, error) + SumActualCostSince func(ctx context.Context, since int64) (int64, error) + type BudgetMonitor struct + func NewBudgetMonitor(cfg BudgetConfig) *BudgetMonitor + func (m *BudgetMonitor) Spend(spentMicro int64, now time.Time, emit func(Event) bool) + type BudgetSpender interface + Spend func(spentMicro int64, now time.Time, emit func(Event) bool) + type Caller struct + DailyBudgetMicro int64 + ID string + MonthlyBudgetMicro int64 + Name string + func CallerFrom(ctx context.Context) (Caller, bool) + type CallerStore interface + CallerByKeyHash func(ctx context.Context, hash string) (Caller, error) + type CostThresholdReader interface + CostAlertThresholdMicro func() int64 + type Emitter interface + Emit func(PayloadEvent) + type Event struct + AgentID string + BudgetMicroUSD int64 + IntentScore float64 + Model string + Project string + QuotaID string + QuotaKind string + Reason string + RetryAfter int + SavedCostMicro int64 + Similarity float64 + SpentMicroUSD int64 + ThresholdPct int + Timestamp int64 + Type EventType + type EventType string + const EventBudgetLevel + const EventIntentDrift + const EventLoopBlocked + const EventQuotaLevel + const EventSemanticLoop + type HandlerOption func(*handler) + func WithAuth(a Authenticator) HandlerOption + func WithBudget(cfg BudgetConfig) HandlerOption + func WithBudgetLedger(l BudgetLedger) HandlerOption + func WithBudgetSpender(s BudgetSpender) HandlerOption + func WithCostThreshold(r CostThresholdReader) HandlerOption + func WithEmitter(e Emitter) HandlerOption + func WithIncidentRecorder(r IncidentRecorder) HandlerOption + func WithLogStream(hub *logstream.Hub) HandlerOption + func WithMetrics(m *Metrics) HandlerOption + func WithNotifier(n Notifier) HandlerOption + func WithRequestLogStore(s RequestLogStore) HandlerOption + func WithStore(s Store) HandlerOption + type IncidentInput struct + AgentID string + CostMicro int64 + Fingerprint string + KeyID string + Model string + ProjectName string + type IncidentRecorder interface + RecordIncident func(ctx context.Context, in IncidentInput) error + type LoopAlertGate interface + LoopAlertsEnabled func() bool + type Metrics struct + func NewMetrics() *Metrics + func (m *Metrics) Snapshot() MetricsSnapshot + type MetricsSnapshot struct + ActiveRequests int64 + AvgLatencyMicro int64 + BlockedAgents int + LoopBlocks int64 + RecentTriggers []TriggerEvent + SavedCostMicroUSD int64 + TokenSeries []TokenPoint + TokenVelocity float64 + TotalRequests int64 + UptimeSeconds int64 + type Notifier interface + Close func() + Notify func(event Event) + func NoopNotifier() Notifier + type PayloadEvent struct + AgentID string + Body []byte + Fingerprint string + KeyID string + Model string + Project string + Timestamp int64 + type RequestLogStore interface + LogRequest func(ctx context.Context, r RequestRecord) error + type RequestRecord struct + AgentID string + CompletionTokens int64 + CostUSD int64 + IsLoopBlocked bool + KeyID string + Model string + ProjectName string + PromptTokens int64 + Timestamp int64 + type SettingsRow struct + CostAlertThresholdMicro int64 + LoopThresholdCount int + type SettingsStore interface + GetSettings func(ctx context.Context) (SettingsRow, error) + UpdateSettings func(ctx context.Context, s SettingsRow) error + type Store interface + type TokenPoint struct + Second int64 + Tokens int64 + type TriggerEvent struct + AgentID string + Model string + Reason string + SavedMicro int64 + Timestamp int64