import type { ArtifactRef } from "@boardwalk-labs/workflow/runtime"; import type { DesktopSession, DesktopSessionOptions } from "@boardwalk-labs/workflow"; import type { DesktopDriver } from "./desktop_driver.js"; import type { ScreenshotArtifactWriter } from "./browser_session.js"; export type DesktopSessionHandle = DesktopSession; /** Options as they arrive off the wire (already zod-validated to "auto"|"none" by the protocol; * the string widening keeps the manager's own check meaningful for embedded callers). */ export interface DesktopSessionOpenOptions extends Omit { grounding?: string; } /** What the agent's `screenshot` tool needs: image for the model + the artifact ref (best-effort). */ export interface AgentScreenshot { data: string; width: number; height: number; artifact?: ArtifactRef; } export interface DesktopSessionManagerDeps { driver: DesktopDriver; writeArtifact: ScreenshotArtifactWriter; /** Monotonic session-id source (injected for determinism in tests). */ nextId: () => string; /** Best-effort warn sink for non-fatal failures (artifact store hiccups). */ warn?: (message: string, fields: Record) => void; /** OS-permission check run ONCE per session at open (macOS: Accessibility + Screen Recording). * Rejecting here is the whole point — an ungranted Mac otherwise clicks into the void mid-run. * Absent ⇒ nothing to check (Linux). */ preflight?: () => Promise; } /** * Per-run manager of THE desktop session: at most one open at a time (every handle would share the * one screen), reopenable after close, reaped at run end. `driverFor` resolves a bound session back * to the OS driver so the leaf executor can assemble the per-leaf ToolHost desktop hooks. */ export declare class DesktopSessionManager { private readonly deps; private current; constructor(deps: DesktopSessionManagerDeps); open(opts?: DesktopSessionOpenOptions): Promise; /** The OS driver for a bound session handle, or null when it isn't this run's live session. */ driverFor(session: { id: string; }): DesktopDriver | null; /** One capture, two sinks: base64 PNG for the model, the artifact best-effort (a store hiccup * must not fail the agent's screenshot — the model still sees the frame). */ captureForAgent(sessionId: string): Promise; /** Tear down the open session, if any. Called once when the run ends. */ closeAll(): Promise; private assertLive; private writeShot; private makeHandle; }