/** * Shared plumbing for the browser MCP tools. * * Session registry, CDP connection cache, input validation and result * formatting — used by both `browser-tools.ts` (navigation / interaction) * and the instrument tools (`browser-instrument-tools.ts`, * `browser-profile-tools.ts`). Lives in its own module so the tool files * stay readable and neither has to import the other. */ import type { MCPToolResult } from './types.js'; export declare const MAX_BROWSER_SESSIONS = 5; export declare const SESSION_TTL_MS: number; /** Tracking metadata for a single browser session. */ export interface BrowserSessionInfo { sessionId: string; createdAt: string; lastActivity: string; } export interface BrowserConnection { client: import('@monoes/monobrowse').CdpClient; cdpSessionId: string; refs: Map; /** * When this CDP connection was established. Console/network capture buffers * are armed at connect time and keyed by `cdpSessionId`, so this is the * start of the window those buffers cover — the instrument tools report it * so an agent knows what it is and isn't seeing. */ openedAt: string; } export declare const browserSessions: Map; export declare const connectionCache: Map; export declare function pruneExpiredSessions(): Promise; export declare function touchSession(sessionId: string): void; export declare function getConnection(sessionId: string): Promise; export declare function releaseConnection(sessionId: string): Promise; export declare function closeTarget(conn: BrowserConnection, port: number): Promise; export declare function ok(data?: Record): MCPToolResult; export declare function fail(message: string): MCPToolResult; /** Validate a session ID against a strict allowlist. */ export declare function validateSessionId(value: unknown): string; /** Validate a URL against a scheme allowlist. */ export declare const ALLOWED_URL_SCHEMES: Set; export declare function validateUrl(value: unknown): string; /** * Validate a screenshot path. Resolved path must be within * `/.monomind/screenshots` and must not already exist. */ export declare function validateScreenshotPath(value: unknown): Promise; /** * Resolve the output path for a generated artifact (HAR, CPU profile, heap * snapshot, device screenshot) under `/.monomind//`. * A caller-supplied path is taken relative to that directory, must stay * inside it, and must not already exist. With no path, `fallbackName` is * used. Creates the directory when missing. */ export declare function resolveArtifactPath(subdir: string, value: unknown, fallbackName: string): Promise; /** Reduce an arbitrary label to something safe to use as a file name. */ export declare function safeFileSlug(value: string): string; /** Reject strings starting with '-' (flag-injection defense). */ export declare function rejectFlagLike(value: unknown, field: string): string; /** * Resolve an element target using monobrowse finders. * target: CSS selector string (e.g. "#id", ".class", "button") * locator: "selector" (default) | "role" | "text" | "label" | "placeholder" */ export declare function findElement(conn: BrowserConnection, target: string, locator?: string): Promise; //# sourceMappingURL=browser-session.d.ts.map