import { type ChildProcess } from 'child_process';
import { TelemetryService } from './TelemetryService';
import { type HostedDemoSessionPersistedRuntimeState, type HostedDemoSessionStore } from './HostedDemoSessionStore';
export type HostedDemoSession = {
    sessionId: string;
    userId: string;
    createdAt: number;
    expiresAt: number;
    lastActionAt: number;
    worktreePath: string;
    projectPath: string;
    rivetPort: number;
    runtimeState: HostedDemoSessionPersistedRuntimeState;
};
export type HostedDemoSessionWithUrl = HostedDemoSession & {
    sessionUrl: string;
};
type RuntimeStartParams = {
    projectPath: string;
    rivetPort: number;
    sessionId: string;
};
type HostedDemoRuntimeDeps = {
    now?: () => number;
    runGitCommand?: (repoPath: string, args: string[]) => Promise<void>;
    startRuntime?: (params: RuntimeStartParams) => Promise<ChildProcess>;
    stopRuntime?: (runtimeProcess: ChildProcess) => Promise<void>;
    waitForRuntimeHealth?: (rivetPort: number) => Promise<void>;
};
export type HostedDemoSessionConfig = {
    repoPath: string;
    templateProjectPath: string;
    telemetry?: TelemetryService;
    worktreesRootPath?: string;
    sessionTtlMs?: number;
    sessionIdleTtlMs?: number;
    maxActiveSessions?: number;
    baseRivetPort?: number;
    publicBaseUrl?: string;
    sessionMetadataStore?: HostedDemoSessionStore;
};
export declare class HostedDemoSessionService {
    private readonly config;
    private readonly deps;
    private readonly telemetry;
    private readonly sessionStore;
    private readonly sessions;
    private pendingSessionCreations;
    private readonly cleanupTimer;
    private readonly rehydrationLocks;
    constructor(config: HostedDemoSessionConfig, deps?: HostedDemoRuntimeDeps);
    /**
     * Loads durable session rows into memory so stopped sessions can be rehydrated after deploy.
     */
    initialize(): Promise<void>;
    createSession(userId: string): Promise<HostedDemoSessionWithUrl>;
    getActiveSessionCount(): number;
    getTemplateProjectPath(): string;
    getSession(sessionId: string): HostedDemoSession | null;
    getSessionOwnerUserId(sessionId: string): string | null;
    /**
     * Records a Rivet user action for idle TTL (does not extend idle on passive polling).
     */
    recordSessionAction(sessionId: string): Promise<void>;
    getSessionProxyTarget(sessionId: string): string | null;
    /**
     * Starts the per-session runtime when it was stopped for idle or after process restart.
     */
    ensureRuntimeReady(sessionId: string): Promise<void>;
    closeSession(sessionId: string, options?: {
        removeWorktree?: boolean;
    }): Promise<void>;
    shutdown(): Promise<void>;
    private readonly countRunningOrStartingSessions;
    private readonly persistSession;
    private readonly toPersisted;
    private readonly internalFromPersisted;
    private readonly runRehydration;
    private readonly stopRuntimeForIdle;
    private readonly cleanupExpiredSessions;
    private readonly safeRemoveWorktree;
    private readonly toErrorType;
    getSessionUrl(sessionId: string): string;
    private readonly toPublicSession;
    private readonly defaultRunGitCommand;
    private readonly defaultStartRuntime;
    private readonly defaultStopRuntime;
    private readonly defaultWaitForRuntimeHealth;
}
export {};
//# sourceMappingURL=HostedDemoSessionService.d.ts.map