/**
 * TurtleDB Cloud — in-process usage counters (C1 stub).
 *
 * Per-tenant day buckets for graph I/O, storage, and egress.
 * Report-only — broker pull / Stripe wiring is C1.1.
 *
 * @module trellis/server
 */
import type { TenantPool } from './tenancy.js';
export type MeterName = 'graph_io' | 'storage_bytes' | 'egress_bytes';
export interface DayBucket {
    graph_io: number;
    storage_bytes: number;
    egress_bytes: number;
}
export interface TenantUsageSnapshot {
    tenantId: string;
    day: string;
    meters: DayBucket;
    /** ISO timestamp of last storage sample for this day. */
    storageSampledAt?: string;
}
export interface UsageMeterOptions {
    now?: () => Date;
    /** Daily graph I/O cap per tenant (0 = unlimited). Env: TRELLIS_MCP_GRAPH_IO_LIMIT */
    graphIoLimit?: number;
}
export declare class McpRateLimitError extends Error {
    constructor(message: string);
}
export declare function resolveUsageTenantId(tenantId?: string | null): string;
export declare function dayKey(date: Date): string;
/**
 * Sample on-disk storage for a tenant: SQLite file + optional `blobs/` dir.
 */
export declare function sampleTenantStorage(pool: TenantPool, tenantId?: string | null): number;
/**
 * Verify admin usage requests via `TURTLEDB_ADMIN_KEY`.
 * Accepts `Authorization: Bearer <key>` or `X-Turtledb-Admin-Key`.
 */
export declare function verifyAdminKey(req: Request): boolean;
export declare class UsageMeter {
    private buckets;
    private storageSampledAt;
    private now;
    private graphIoLimit;
    constructor(opts?: UsageMeterOptions);
    /**
     * Enforce per-tenant daily graph I/O budget (MCP + REST).
     * No-op when limit is 0 (unlimited).
     */
    assertGraphIoBudget(tenantId: string): void;
    recordGraphIo(tenantId: string, count?: number): void;
    recordEgress(tenantId: string, bytes: number): void;
    /** Set storage gauge for the current day (from sampler, not incremental). */
    recordStorage(tenantId: string, bytes: number): void;
    sampleStorage(pool: TenantPool, tenantId?: string | null): number;
    getUsage(tenantId: string, day?: string): TenantUsageSnapshot;
    /** All day keys recorded for a tenant (sorted ascending). */
    listDays(tenantId: string): string[];
    private _today;
    private _bucket;
}
//# sourceMappingURL=usage-meter.d.ts.map