import type { SessionRealtimeModel } from "@opengeni/contracts"; import { type Database } from "./database.js"; /** One provider connection of a live-voice mode, bounded by server observation. */ export type SessionRealtimeBillableConnection = { id: string; startedAt: Date; observedUntil: Date; }; export type SessionRealtimeBillingFacts = { accountId: string; workspaceId: string; sessionId: string; realtimeId: string; model: SessionRealtimeModel; ownerSubjectId: string; state: "preparing" | "active" | "ended"; connections: SessionRealtimeBillableConnection[]; }; /** * The last instant the server itself observed the voice owner alive. An * explicit owner-proven end is observed at `endedAt`; an expired lease only up * to its last heartbeat (late lazy settlement never extends the bill); an * active mode up to `now`, bounded by its lease. */ export declare function sessionRealtimeObservedUntil(mode: { state: string; endReason: string | null; endedAt: Date | null; lastHeartbeatAt: Date; leaseExpiresAt: Date; }, now: Date): Date; /** * Server-observed lifetime of every provider connection that was actually * issued (an SDP answer or a minted client secret was returned). Failed or * never-completed negotiations issued nothing billable. */ export declare function loadSessionRealtimeBillingFacts(db: Database, input: { workspaceId: string; sessionId: string; realtimeId: string; now?: Date; }): Promise; /** Which of these usage idempotency keys are already recorded for the account. */ export declare function existingUsageEventIdempotencyKeys(db: Database, input: { accountId: string; workspaceId: string; keys: readonly string[]; }): Promise>;