import { type AttachedBrowserDevice as AttachedBrowserDeviceValue, type AttachedBrowserDeviceListResponse as AttachedBrowserDeviceListResponseValue, type AttachedBrowserInventorySnapshot as AttachedBrowserInventorySnapshotValue } from "@opengeni/contracts"; import { type Database } from "./database.js"; import * as schema from "./schema.js"; type ConnectionHistoryEntry = schema.AttachedBrowserConnectionHistoryEntry; /** Merge newly observed connection ends into a profile's bounded history. * One entry per generation: the machine bridge's own observation replaces a * server inference, never the reverse. Returns null when nothing changed, * including an addition too old to survive the bound. */ export declare function mergeAttachedBrowserConnectionHistory(history: readonly ConnectionHistoryEntry[], additions: readonly ConnectionHistoryEntry[]): ConnectionHistoryEntry[] | null; export declare class AttachedBrowserDeviceNotFoundError extends Error { readonly name = "AttachedBrowserDeviceNotFoundError"; } export declare class AttachedBrowserInventoryConflictError extends Error { readonly name = "AttachedBrowserInventoryConflictError"; } export type ReconcileAttachedBrowserInventoryResult = { accepted: boolean; changed: boolean; revision: number; }; /** Who is looking at a workspace's attached browsers. Personal (Only me) * machines show their browsers only to their owner, exactly like the machines * themselves; for an agent this is the person its turn acts for. */ export type AttachedBrowserViewer = { accountId: string; workspaceId: string; subjectId: string; }; /** Reconcile one full browser-bridge snapshot. The enrollment row serializes * concurrent heartbeats; a lower revision from the same bridge generation is * ignored, and a replay only refreshes liveness. */ export declare function reconcileAttachedBrowserInventory(db: Database, input: { accountId: string; workspaceId: string; enrollmentId: string; snapshot: AttachedBrowserInventorySnapshotValue; }): Promise; /** Lock the device row first (same order as inventory) and prove the live * physical generation still matches this controller placement. The device * row lives in `deviceWorkspaceId`, which is the session's own workspace * unless the session runs on a machine shared from another workspace. * When Chrome has restarted (or its profile is gone), every live session in * this workspace on the old generation is marked lost here, in place: the * inventory heartbeat ends them eagerly only in the profile's own workspace. */ export declare function attachedDeviceGenerationMatches(tx: Database, input: { accountId: string; workspaceId: string; deviceWorkspaceId: string; deviceId: string; placementInstanceId: string; }): Promise; /** Immediately mark every live Chrome profile on a cleanly disconnected agent * offline. Historical endpoint rows remain discoverable and reconnect in place. */ export declare function disconnectAttachedBrowserDevices(db: Database, input: { accountId: string; workspaceId: string; enrollmentId: string; }): Promise<{ changed: boolean; revision: number; }>; /** Every Chrome profile on a machine this viewer can use, wherever that * machine is enrolled: the same machines the viewer's Machines list shows. */ export declare function listAttachedBrowserDevices(db: Database, input: AttachedBrowserViewer & { includeDisconnected?: boolean; }): Promise; /** One Chrome profile this viewer can use. `deviceWorkspaceId` pins the * copy an existing session was placed on; without it, the copy a new * session would use, which is not found when the id is announced by * different machines and none of them is the viewer's own. */ export declare function getAttachedBrowserDevice(db: Database, input: AttachedBrowserViewer & { deviceId: string; deviceWorkspaceId?: string | null; }): Promise; /** Where a browser or computer's controller runs, as far as ending it needs. */ export type InteractionControllerPlacement = { kind: "connected_machine"; sandboxId: string; } | { kind: "attached_device"; deviceId: string; deviceWorkspaceId?: string | null; /** The Chrome generation the session's controller is bound to. */ placementInstanceId?: string | null; } | { kind: string; }; /** True when a browser or computer's controller can never be reached again, * so ending it completes in the control plane: * - on a Connected Machine that was removed (revoked); that machine can no * longer run or keep it; * - in a person's own Chrome whose profile is disconnected, has restarted * since the session was placed, is gone, or is no longer reachable from * this viewer's workspace (its machine was removed or stopped being shared * here). Such a session holds no Opengeni process or profile, and nobody * here can reach the controller to end it there; the tabs it opened stay * with the person as ordinary tabs, and completing under the bound * generation fences that controller off. * A Connected Machine that is only offline, or hidden from this viewer, still * holds its sessions' processes and private profiles, so it is not gone. */ export declare function interactionControllerGone(db: Database, viewer: AttachedBrowserViewer, placement: InteractionControllerPlacement | null): Promise; export {};