/** * Guard Manager * * Central coordinator for rate limiting, concurrency control, IP filtering, * and timeout within a scope. SDK-agnostic — built on StorageAdapter. */ import type { NamespacedStorage } from '@frontmcp/utils'; import type { GuardConfig } from './types'; import type { RateLimitConfig, RateLimitResult } from '../rate-limit/types'; import type { ConcurrencyConfig, SemaphoreTicket } from '../concurrency/types'; import type { PartitionKeyContext } from '../partition-key/types'; import type { IpFilterResult } from '../ip-filter/types'; export declare class GuardManager { private readonly storage; private readonly rateLimiter; private readonly semaphore; private readonly ipFilter?; readonly config: GuardConfig; constructor(storage: NamespacedStorage, config: GuardConfig); /** * Check if a client IP is allowed by the IP filter. * Returns undefined if no IP filter is configured. */ checkIpFilter(clientIp: string | undefined): IpFilterResult | undefined; /** * Check if a client IP is on the allow list (bypasses rate limiting). */ isIpAllowListed(clientIp: string | undefined): boolean; /** * Check per-entity rate limit. * Merges entity config with app-level defaults (entity takes precedence). */ checkRateLimit(entityName: string, entityConfig: RateLimitConfig | undefined, context: PartitionKeyContext | undefined): Promise; /** * Check global rate limit. */ checkGlobalRateLimit(context: PartitionKeyContext | undefined): Promise; /** * Acquire a concurrency slot for an entity. */ acquireSemaphore(entityName: string, entityConfig: ConcurrencyConfig | undefined, context: PartitionKeyContext | undefined): Promise; /** * Acquire a global concurrency slot. */ acquireGlobalSemaphore(context: PartitionKeyContext | undefined): Promise; destroy(): Promise; }