import type { PreviewSession } from "./preview.js";
import type { JaitDB } from "../db/connection.js";
export type BrowserSessionMode = "shared" | "isolated";
export type BrowserSessionOrigin = "attached" | "managed" | "direct";
export type BrowserSessionController = "agent" | "user" | "observer";
export type BrowserSessionStatus = "ready" | "running" | "paused" | "intervention-required" | "closed";
export type BrowserInterventionKind = "complete_login" | "enter_secret" | "dismiss_modal" | "confirm_external_prompt" | "custom";
export type BrowserInterventionStatus = "open" | "resolved" | "cancelled";
export interface BrowserSessionRecord {
    id: string;
    name: string;
    workspaceRoot: string | null;
    targetUrl: string | null;
    previewUrl: string | null;
    previewSessionId: string | null;
    browserId: string | null;
    mode: BrowserSessionMode;
    origin: BrowserSessionOrigin;
    controller: BrowserSessionController;
    status: BrowserSessionStatus;
    secretSafe: boolean;
    storageProfile: Record<string, unknown> | null;
    createdBy: string | null;
    createdAt: string;
    updatedAt: string;
}
export interface BrowserInterventionRecord {
    id: string;
    browserSessionId: string;
    threadId: string | null;
    chatSessionId: string | null;
    kind: BrowserInterventionKind;
    reason: string;
    instructions: string;
    status: BrowserInterventionStatus;
    secretSafe: boolean;
    allowUserNote: boolean;
    requestedBy: string | null;
    resolvedBy: string | null;
    userNote: string | null;
    requestedAt: string;
    resolvedAt: string | null;
}
type SessionListener = (session: BrowserSessionRecord) => void;
type InterventionListener = (intervention: BrowserInterventionRecord) => void;
export interface CreateBrowserSessionInput {
    name?: string | null;
    workspaceRoot?: string | null;
    targetUrl?: string | null;
    previewUrl?: string | null;
    previewSessionId?: string | null;
    browserId?: string | null;
    mode?: BrowserSessionMode;
    origin?: BrowserSessionOrigin;
    controller?: BrowserSessionController;
    status?: BrowserSessionStatus;
    secretSafe?: boolean;
    storageProfile?: Record<string, unknown> | null;
    createdBy?: string | null;
}
export interface RequestBrowserInterventionInput {
    browserSessionId: string;
    threadId?: string | null;
    chatSessionId?: string | null;
    kind?: BrowserInterventionKind;
    reason: string;
    instructions: string;
    secretSafe?: boolean;
    allowUserNote?: boolean;
    requestedBy?: string | null;
}
export declare class BrowserCollaborationService {
    private readonly db;
    private readonly sessionListeners;
    private readonly interventionListeners;
    constructor(db: JaitDB);
    onSessionChanged(listener: SessionListener): () => void;
    onInterventionChanged(listener: InterventionListener): () => void;
    listSessions(userId?: string | null): BrowserSessionRecord[];
    getSession(id: string, userId?: string | null): BrowserSessionRecord | null;
    getSessionByBrowserId(browserId: string): BrowserSessionRecord | null;
    getSessionByPreviewSessionId(previewSessionId: string): BrowserSessionRecord | null;
    createSession(input: CreateBrowserSessionInput): BrowserSessionRecord;
    syncPreviewSession(preview: PreviewSession, options?: {
        userId?: string | null;
        workspaceRoot?: string | null;
        mode?: BrowserSessionMode;
        storageProfile?: Record<string, unknown> | null;
    }): BrowserSessionRecord;
    takeControl(id: string, userId?: string | null): BrowserSessionRecord | null;
    returnControl(id: string, userId?: string | null): BrowserSessionRecord | null;
    pause(id: string, userId?: string | null): BrowserSessionRecord | null;
    resume(id: string, userId?: string | null): BrowserSessionRecord | null;
    setSecretSafe(id: string, secretSafe: boolean, userId?: string | null): BrowserSessionRecord | null;
    closePreviewSession(previewSessionId: string): void;
    listInterventions(userId?: string | null, status?: BrowserInterventionStatus): BrowserInterventionRecord[];
    requestIntervention(input: RequestBrowserInterventionInput): BrowserInterventionRecord;
    resolveIntervention(id: string, userId?: string | null, note?: string | null): BrowserInterventionRecord | null;
    cancelIntervention(id: string, userId?: string | null): BrowserInterventionRecord | null;
    assertAgentControl(browserId?: string): void;
    private emitSessionChanged;
    private emitInterventionChanged;
    private rowToSession;
    private rowToIntervention;
    private getIntervention;
}
export {};
//# sourceMappingURL=browser-collaboration.d.ts.map