import type { Server } from "node:http"; import type { RunningChrome } from "./chrome.js"; import type { BrowserTab } from "./client.js"; import type { ResolvedBrowserConfig, ResolvedBrowserProfile } from "./config.js"; export type { BrowserTab }; /** * Runtime state for a single profile's Chrome instance. */ export type ProfileRuntimeState = { profile: ResolvedBrowserProfile; running: RunningChrome | null; /** Sticky tab selection when callers omit targetId (keeps snapshot+act consistent). */ lastTargetId?: string | null; }; export type BrowserServerState = { server: Server; port: number; resolved: ResolvedBrowserConfig; profiles: Map; }; export type BrowserRouteContext = { state: () => BrowserServerState; forProfile: (profileName?: string) => ProfileContext; listProfiles: () => Promise; // Legacy methods delegate to default profile for backward compatibility ensureBrowserAvailable: () => Promise; ensureTabAvailable: (targetId?: string) => Promise; isHttpReachable: (timeoutMs?: number) => Promise; isReachable: (timeoutMs?: number) => Promise; listTabs: () => Promise; openTab: (url: string) => Promise; focusTab: (targetId: string) => Promise; closeTab: (targetId: string) => Promise; stopRunningBrowser: () => Promise<{ stopped: boolean }>; resetProfile: () => Promise<{ moved: boolean; from: string; to?: string; }>; mapTabError: (err: unknown) => { status: number; message: string } | null; }; export type ProfileContext = { profile: ResolvedBrowserProfile; ensureBrowserAvailable: () => Promise; ensureTabAvailable: (targetId?: string) => Promise; isHttpReachable: (timeoutMs?: number) => Promise; isReachable: (timeoutMs?: number) => Promise; listTabs: () => Promise; openTab: (url: string) => Promise; focusTab: (targetId: string) => Promise; closeTab: (targetId: string) => Promise; stopRunningBrowser: () => Promise<{ stopped: boolean }>; resetProfile: () => Promise<{ moved: boolean; from: string; to?: string }>; }; export type ProfileStatus = { name: string; cdpPort: number; cdpUrl: string; color: string; running: boolean; tabCount: number; isDefault: boolean; isRemote: boolean; }; export type ContextOptions = { getState: () => BrowserServerState | null; onEnsureAttachTarget?: (profile: ResolvedBrowserProfile) => Promise; };