@braedonsaunders/appkit-desk 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/host.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"host.js","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAEtD,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,GAGV,MAAM,QAAQ,CAAA;AACf,OAAO,EACL,sBAAsB,GAIvB,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GAGjB,MAAM,YAAY,CAAA;AAenB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAA;AACjC,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,GAAG,MAAM,CAAA;AACjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,GAAG,MAAM,CAAA;AAC3C,sEAAsE;AACtE,MAAM,CAAC,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KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QAAC,MAAM,KAAK,CAAA;IAAC,CAAC;AACpG,CAAC;AACD,KAAK,UAAU,sBAAsB,CAAC,SAAiB,EAAE,SAAiB;IACxE,MAAM,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,sBAAsB,CAAC,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;AACtF,CAAC","sourcesContent":["/**\n * The desk host: lifecycle, leases, and the screen service over a backend.\n *\n * One host manages many desks against one capacity budget. A desk is\n * headless by default; the screen is a service started on demand on the\n * machine the agent is already using. The host owns lease accounting (idle\n * suspend, a hard concurrency cap with a FIFO queue beyond it), event\n * emission to the consumer's ports, and the handover masking contract. It\n * never touches a database and knows nothing about tenants or approvals.\n */\nimport { existsSync } from 'node:fs'\nimport { execFile } from 'node:child_process'\nimport { mkdir, readFile, rm, statfs, writeFile } from 'node:fs/promises'\nimport { arch, cpus, release, tmpdir } from 'node:os'\nimport { dirname, join } from 'node:path'\nimport { createHash, randomUUID } from 'node:crypto'\nimport { Buffer } from 'node:buffer'\nimport { connect as tcpConnect, isIP } from 'node:net'\nimport type { Duplex } from 'node:stream'\nimport {\n buildDeskLaunchPlan,\n cleanDeskId,\n DEFAULT_KVM_PATH,\n DEFAULT_VMM_PATH,\n DeskError,\n type DeskLauncherIdentity,\n type DeskGuestNetworkOptions,\n} from './plan'\nimport {\n cloudHypervisorBackend,\n type DeskBackend,\n type DeskConnectionChange,\n type DeskMachine,\n} from './backend'\nimport {\n parseCapabilities,\n parseClipboardText,\n parseExecResult,\n parseHandoverBegun,\n parseJobStarted,\n parseObservation,\n type GuestEventMessage,\n type GuestInput,\n} from './protocol'\nimport type {\n A11yNode,\n DeskEventDetail,\n DeskEventKind,\n DeskFrameFormat,\n DeskHandoverEndReason,\n DeskHandoverScope,\n DeskPoint,\n DeskPointerButton,\n DeskPorts,\n DeskVideoChunkKind,\n WindowInfo,\n} from './events'\n\nexport const DEFAULT_CAPACITY = 4\nexport const DEFAULT_IDLE_SUSPEND_MS = 5 * 60_000\nexport const DEFAULT_LEASE_MS = 15 * 60_000\n/** The in-guest trim run before a desk suspends — see `trimGuest`. */\nexport const DEFAULT_TRIM_COMMAND = '/usr/sbin/fstrim'\nexport const DEFAULT_TRIM_ARGS: readonly string[] = ['/']\nexport const DEFAULT_TRIM_TIMEOUT_MS = 60_000\nexport const DEFAULT_CID_BASE = 100\nconst MAX_BUFFERED_FRAMES = 60\n/**\n * Video chunks a slow consumer may fall behind by before its stream is ended.\n * Larger than the frame bound because a fragment is a fraction of a frame's\n * bytes, and enforced by ENDING rather than by dropping — see the comment at\n * the overrun.\n */\nconst MAX_BUFFERED_VIDEO_CHUNKS = 600\nconst MIN_TIMER_DELAY_MS = 25\n\n/**\n * Event kinds that must never reach the recording port while a handover is\n * active. Human input and everything derived from watching the human act is\n * masked; only the handover boundaries themselves cross.\n */\nconst HANDOVER_MASKED_KINDS: ReadonlySet<DeskEventKind> = new Set([\n 'click',\n 'type',\n 'key',\n 'scroll',\n 'drag',\n 'window_focus',\n 'app_launch',\n])\n\nexport interface DeskHostOptions {\n /** Root of the golden base image and per-desk assets. */\n imageRoot: string\n vmmPath?: string\n kvmPath?: string\n /** Guest kernel; defaults to `<imageRoot>/vmlinux`. */\n kernelPath?: string\n /**\n * Initramfs the guest kernel boots with. A modular distro cloud kernel needs\n * one to mount root; omit only for a kernel with virtio/ext4 built in. When\n * unset it defaults to `<imageRoot>/initrd` if that file exists, else none.\n */\n initramfsPath?: string\n /**\n * Kernel command line every desk boots with. Defaults to\n * `DEFAULT_KERNEL_CMDLINE`; override it for partitioned cloud images whose\n * root is not `/dev/vda` (e.g. `root=/dev/vda3 rw quiet`).\n */\n kernelCmdline?: string\n /** Directory holding vsock and API control sockets. */\n runtimeDir?: string\n launcherIdentity?: DeskLauncherIdentity\n backend?: DeskBackend\n guestNetwork?: DeskGuestNetworkOptions\n ports: DeskPorts\n /** Override TCP dialing for tests or a host-specific transport. */\n connectGuest?: (address: string, port: number) => Promise<Duplex>\n /** Hard cap on concurrently resident desks; starts beyond it queue FIFO. */\n capacity?: number\n idleSuspendMs?: number\n defaultLeaseMs?: number\n /** First guest vsock CID handed out; each boot takes the next one. */\n cidBase?: number\n now?: () => number\n pathExists?: (path: string) => boolean\n deviceExists?: (path: string) => boolean\n /**\n * Delete a destroyed desk's overlay. Injectable so the destroy path is\n * testable without a filesystem; defaults to `rm(path, { force: true })`.\n */\n removeOverlay?: (path: string) => Promise<void>\n /**\n * Park a desk by snapshotting its memory instead of shutting it down, so\n * resuming continues the guest's process tree rather than cold booting it.\n *\n * Off by default, because turning it on is a real operational change and not\n * only a behavioural one: each parked desk holds a snapshot roughly the size\n * of its guest RAM on the overlay volume, and the backend must offer `park`.\n * A deployment opts in once it has sized for that.\n *\n * What it buys is the difference between a desk that is \"parked\" and one that\n * was switched off. Shutdown parking means nothing inside the guest survives\n * between runs: an agent that installs a daemon and believes it is watching\n * something continuously is wrong, and the cold boot on every scheduled\n * occurrence is indistinguishable, from inside the guest, from a failing host.\n */\n parkWithMemory?: boolean\n /** Identifies the host CPU for conservative snapshot portability checks. */\n cpuSignature?: () => Promise<string>\n readSnapshotSignature?: (directory: string) => Promise<string | null>\n writeSnapshotSignature?: (directory: string, signature: string) => Promise<void>\n /** Create a snapshot directory; defaults to `mkdir(path, { recursive: true })`. */\n makeSnapshotDir?: (path: string) => Promise<void>\n /**\n * Destroy a snapshot; defaults to `rm(path, { recursive: true, force: true })`.\n *\n * Called at the one moment it is safe to — a restored guest still paused — so\n * a failure here is not cosmetic. It is the reason the restore is abandoned.\n */\n removeSnapshot?: (path: string) => Promise<void>\n /**\n * Bytes that must remain free on the overlay filesystem AFTER admitting a\n * desk. A desk whose overlay cannot be grown fails deep inside the guest —\n * ENOSPC surfaces as a corrupt filesystem or a boot that hangs, which reads\n * as a product bug rather than as a full disk. Refusing the lease up front\n * turns that into one clear error. Zero disables the check.\n */\n minFreeBytes?: number\n /**\n * Free bytes on the filesystem holding `path`. Injectable for tests;\n * defaults to `statfs`.\n */\n freeBytes?: (path: string) => Promise<number>\n /**\n * Run `fstrim` in the guest just before it suspends, returning the blocks it\n * has freed to the host filesystem. On by default: an overlay that is never\n * trimmed only grows. Set false for a guest without the binary, or one whose\n * filesystem should never be discarded.\n */\n trimOnSuspend?: boolean\n /** The in-guest trim binary. */\n trimCommand?: string\n /** Arguments for the trim binary; defaults to trimming the guest root. */\n trimArgs?: readonly string[]\n /** Bound on the trim; a slow trim must not hold up a suspend indefinitely. */\n trimTimeoutMs?: number\n}\n\nexport interface DeskStartOptions {\n deskId: string\n /** Absolute path of the golden base image this desk boots from. */\n baseImage: string\n /** Absolute path of this desk's copy-on-write overlay. */\n overlayPath: string\n memoryMb?: number\n vcpus?: number\n leaseMs?: number\n network?: { tapDevice?: string; macAddress?: string; guestAddress?: string }\n}\n\nexport interface DeskExecOptions {\n command: string\n args?: readonly string[]\n cwd?: string\n env?: Readonly<Record<string, string>>\n timeoutMs?: number\n /** Survive the call as a background job; the job dies with the lease. */\n keepAlive?: boolean\n}\n\nexport interface DeskExecSnapshot {\n deskId: string\n command: string\n args: readonly string[]\n exitCode: number | null\n signal: string | null\n stdout: string\n stderr: string\n truncated: boolean\n startedAt: string\n finishedAt: string\n}\n\nexport interface DeskJob {\n jobId: string\n deskId: string\n command: string\n args: readonly string[]\n startedAt: string\n status: 'running' | 'exited'\n exitCode: number | null\n signal: string | null\n}\n\nexport interface DeskObservation {\n png: Buffer\n width: number\n height: number\n a11y: A11yNode | null\n windows: readonly WindowInfo[]\n focused: WindowInfo | null\n}\n\nexport interface DeskFrame {\n seq: number\n width: number\n height: number\n data: Buffer\n /**\n * How `data` is encoded. A consumer must not assume PNG — it builds the\n * media type it hands on (a `data:` URL, a decoder) from this.\n */\n format: DeskFrameFormat\n at: string\n}\n\n/**\n * One unit of the live video stream: the init segment, or one media fragment.\n *\n * Video is deliberately NOT modelled as a kind of frame. A frame is a picture\n * that stands alone; a video chunk is meaningless without the init segment\n * before it and, for a media chunk, without the keyframe its group of pictures\n * began at. Pretending otherwise produces a consumer that appends bytes in any\n * order and renders black with no error to explain it.\n */\nexport interface DeskVideoChunk {\n seq: number\n kind: DeskVideoChunkKind\n /** RFC 6381, e.g. `avc1.42C020`. What a MediaSource must be told. */\n codec: string\n width: number\n height: number\n /** True when a `media` chunk begins at a sync sample. Always false on `init`. */\n keyframe: boolean\n data: Buffer\n at: string\n}\n\nexport interface DeskScreenInput {\n move(x: number, y: number): Promise<void>\n click(x: number, y: number, button?: DeskPointerButton, clicks?: 1 | 2): Promise<void>\n type(text: string): Promise<void>\n key(combo: string): Promise<void>\n scroll(x: number, y: number, dx: number, dy: number): Promise<void>\n drag(from: DeskPoint, to: DeskPoint): Promise<void>\n}\n\nexport interface DeskScreenHandle {\n observe(): Promise<DeskObservation>\n /**\n * Coordinate contract: all coordinates are in the pixel space of the most\n * recent view of the screen — an `observe()`, a frame from `frames()`, or a\n * chunk from `video()` — one to one. All three anchor it, because the caller\n * aims at whatever it was last shown, and a live viewer is shown a stream\n * rather than an observation. That holds whatever the encoding is: a lossy\n * frame and an H.264 fragment are both true-size views of the screen, so they\n * anchor exactly as a lossless PNG does. Input before any view, or outside\n * its bounds, throws.\n */\n input: DeskScreenInput\n a11y: { invoke(nodeId: string, action: string): Promise<void> }\n launch(appId: string, args?: readonly string[]): Promise<void>\n clipboard: { read(): Promise<string>; write(text: string): Promise<void> }\n /**\n * The live frame stream. `format` picks how the guest encodes each frame and\n * is a bytes-for-fidelity trade: `jpeg` is roughly an order of magnitude\n * smaller per frame, which is what a human driving the screen needs, while\n * `png` stays exact. Omitted leaves the choice to the guest. `observe()` is\n * unaffected and always lossless.\n *\n * The stream also ends when the desk reconnects to its guest agent: the\n * capture behind it did not survive, so the iterator completes rather than\n * waiting on frames that are never coming. Start another one to resume.\n */\n frames(options?: {\n fps?: number\n width?: number\n height?: number\n format?: DeskFrameFormat\n }): AsyncIterable<DeskFrame>\n /**\n * The live screen as encoded VIDEO rather than as a sequence of pictures.\n *\n * This is what a person driving the desk should watch. `frames()` ships a\n * whole independent image per tick; a video codec ships the DIFFERENCE, and a\n * desktop is mostly still — which is roughly two orders of magnitude fewer\n * bytes on the transport between the guest and here, the one place the live\n * view was actually bounded.\n *\n * The stream anchors the coordinate space exactly as `observe()` and\n * `frames()` do, from the first chunk onwards, because a viewer driving by\n * video is aiming at what the video showed it.\n *\n * Masked like frames: nothing is emitted while a handover is active. And\n * ended like frames when the desk reconnects to its guest agent — a video\n * consumer resumed on a fresh encoder, without its init segment and away\n * from a keyframe, decodes nothing at all and says so nowhere.\n */\n video(options?: {\n fps?: number\n width?: number\n height?: number\n }): AsyncIterable<DeskVideoChunk>\n handover: {\n begin(options: {\n ttlMs: number\n scope?: DeskHandoverScope\n actor?: string\n }): Promise<{ url: string }>\n end(): Promise<void>\n readonly active: boolean\n }\n}\n\nexport interface DeskScreenService {\n start(options: { width: number; height: number }): Promise<DeskScreenHandle>\n stop(): Promise<void>\n readonly running: boolean\n}\n\n/**\n * One leased desk.\n *\n * The handle stays valid across a lost guest connection: the host reconnects\n * underneath it and later calls work, so a guest agent restart or a dropped\n * vsock bridge no longer costs the rest of the lease. Two consequences a\n * caller must actually handle:\n *\n * - A call that was IN FLIGHT when the connection dropped rejects with\n * `DeskRequestFateUnknownError` — it may already have run in the guest.\n * Nothing retries it for you.\n * - A reconnect does not restore guest-side capture state. Live `frames()` and\n * `video()` iterators END, and the coordinate anchor is dropped, so the\n * caller must `observe()` (or take a new frame) before aiming again.\n *\n * When the connection cannot be recovered at all the desk is suspended, so the\n * handle goes dead and `resume()` boots a fresh one — rather than the handle\n * answering \"no longer connected\" for the rest of the lease.\n */\nexport interface DeskHandle {\n readonly deskId: string\n renewLease(ms: number): void\n /** Open a host-to-guest TCP stream; the caller owns and closes it. */\n connect(port: number): Promise<Duplex>\n exec(options: DeskExecOptions & { keepAlive: true }): Promise<DeskJob>\n exec(options: DeskExecOptions): Promise<DeskExecSnapshot>\n /** The keepAlive processes still running on this desk. */\n jobs(): DeskJob[]\n screen: DeskScreenService\n}\n\nexport interface DeskHostStats {\n /** Desks currently resident (booted or booting) against the capacity cap. */\n resident: number\n /** Starts waiting in the FIFO queue for capacity. */\n queued: number\n capacity: number\n suspended: number\n lastStartedAt: string | null\n lastSuspendedAt: string | null\n /**\n * Times a resident desk lost its guest connection mid-lease and got it back.\n * One is a blip; a number that climbs is a desk FLAPPING — a guest agent\n * restarting in a loop, a failing vsock bridge — and that is the difference\n * between \"the desk is slow\" and a diagnosis.\n */\n reconnects: number\n lastReconnectAt: string | null\n /** Which desk reconnected last: enough to go and look at the right one. */\n lastReconnectDeskId: string | null\n lastError: string | null\n snapshotCpuFallbacks: number\n lastSnapshotCpuFallback: { deskId: string; at: string; reason: 'signature_mismatch' | 'incompatible_cpuid' } | null\n}\n\nexport interface DeskHost {\n start(options: DeskStartOptions): Promise<DeskHandle>\n resume(deskId: string): Promise<DeskHandle>\n suspend(deskId: string): Promise<void>\n /**\n * Stop a desk WITHOUT its memory, keeping its overlay: the next `start` or\n * `resume` cold boots from disk. This is a restart, not a destroy — the disk\n * is the desk and stays exactly where it is. A resident desk is synced and\n * shut down rather than parked; a suspended desk's parked memory snapshot is\n * discarded. Unknown desks are a no-op.\n */\n shutdown(deskId: string): Promise<void>\n destroy(deskId: string): Promise<void>\n stats(): DeskHostStats\n /**\n * Enforce every time-based rule now: expire handovers past their TTL and\n * suspend desks past their lease or idle deadline. Returns the number of\n * desks suspended. Timers call this automatically; tests with an injected\n * clock call it directly.\n */\n sweep(): Promise<number>\n}\n\ninterface HandoverState {\n actor: string | null\n scope: DeskHandoverScope\n beganAt: number\n deadline: number\n}\n\ninterface ScreenState {\n running: boolean\n width: number\n height: number\n lastObservation: { width: number; height: number } | null\n lastFocusedId: string | null\n handover: HandoverState | null\n handle: DeskScreenHandle\n}\n\ninterface DeskRecord {\n deskId: string\n startOptions: DeskStartOptions\n status: 'resident' | 'suspending' | 'suspended'\n machine: DeskMachine | null\n epoch: number\n leaseDeadline: number\n lastActivityAt: number\n jobs: Map<string, DeskJob>\n screen: ScreenState | null\n unsubscribe: (() => void) | null\n unwatchConnection: (() => void) | null\n handle: DeskHandle | null\n timer: NodeJS.Timeout | null\n streamStops: Set<() => void>\n relayStops: Set<() => void>\n}\n\ninterface QueueEntry {\n run: () => Promise<DeskHandle>\n resolve: (handle: DeskHandle) => void\n reject: (error: Error) => void\n}\n\nexport function createDeskHost(options: DeskHostOptions): DeskHost {\n const ports = options.ports\n if (typeof ports?.onEvent !== 'function' || typeof ports?.audit !== 'function') {\n throw new DeskError('createDeskHost requires ports with onEvent and audit functions.')\n }\n const backend = options.backend ?? cloudHypervisorBackend\n const now = options.now ?? Date.now\n const pathExists = options.pathExists ?? existsSync\n const deviceExists = options.deviceExists ?? existsSync\n const removeOverlay = options.removeOverlay ?? ((path: string) => rm(path, { force: true }))\n const parkWithMemory = options.parkWithMemory ?? false\n const makeSnapshotDir = options.makeSnapshotDir ?? ((path: string) => mkdir(path, { recursive: true }).then(() => undefined))\n const removeSnapshot =\n options.removeSnapshot ?? ((path: string) => rm(path, { recursive: true, force: true }))\n const freeBytes = options.freeBytes ?? defaultFreeBytes\n const minFreeBytes = nonNegativeInteger(options.minFreeBytes ?? 0, 'minFreeBytes')\n const trimOnSuspend = options.trimOnSuspend ?? true\n const trimCommand = options.trimCommand ?? DEFAULT_TRIM_COMMAND\n const trimArgs = options.trimArgs ?? DEFAULT_TRIM_ARGS\n const trimTimeoutMs = positiveInteger(options.trimTimeoutMs ?? DEFAULT_TRIM_TIMEOUT_MS, 'trimTimeoutMs')\n const capacity = positiveInteger(options.capacity ?? DEFAULT_CAPACITY, 'capacity')\n const idleSuspendMs = positiveInteger(options.idleSuspendMs ?? DEFAULT_IDLE_SUSPEND_MS, 'idleSuspendMs')\n const defaultLeaseMs = positiveInteger(options.defaultLeaseMs ?? DEFAULT_LEASE_MS, 'defaultLeaseMs')\n const kernelPath = options.kernelPath ?? join(options.imageRoot, 'vmlinux')\n // Default the initramfs to <imageRoot>/initrd when present so a modular\n // cloud kernel boots without every caller having to name it; an explicit\n // option always wins.\n const defaultInitramfs = join(options.imageRoot, 'initrd')\n const resolveInitramfsPath = () =>\n options.initramfsPath ?? (pathExists(defaultInitramfs) ? defaultInitramfs : undefined)\n const kernelCmdline = options.kernelCmdline\n\n const records = new Map<string, DeskRecord>()\n /**\n * The last lifecycle transition scheduled for each desk. A desk may only\n * have one VMM child touching its overlay, so boot and teardown are ordered\n * on the desk identity rather than allowed to race through independent API\n * calls. The stored tail always resolves; callers still receive their own\n * operation's result or error.\n */\n const lifecycleTransitions = new Map<string, Promise<void>>()\n const queue: QueueEntry[] = []\n let occupied = 0\n let nextCid = positiveInteger(options.cidBase ?? DEFAULT_CID_BASE, 'cidBase')\n let lastStartedAt: string | null = null\n let lastSuspendedAt: string | null = null\n let lastError: string | null = null\n let snapshotCpuFallbacks = 0\n let lastSnapshotCpuFallback: DeskHostStats['lastSnapshotCpuFallback'] = null\n let reconnects = 0\n let lastReconnectAt: string | null = null\n let lastReconnectDeskId: string | null = null\n\n function iso(timestamp: number): string {\n return new Date(timestamp).toISOString()\n }\n\n function serializeLifecycle<T>(deskId: string, transition: () => Promise<T>): Promise<T> {\n const previous = lifecycleTransitions.get(deskId)\n // Preserve the host's existing synchronous admission semantics when this\n // desk has no transition in flight. Only conflicts need the promise tail;\n // unrelated starts must still appear in queue stats before `start` returns.\n const current = previous ? previous.then(transition, transition) : transition()\n const tail = current.then(\n () => undefined,\n () => undefined,\n )\n lifecycleTransitions.set(deskId, tail)\n return current.finally(() => {\n if (lifecycleTransitions.get(deskId) === tail) lifecycleTransitions.delete(deskId)\n })\n }\n\n function emit(record: DeskRecord, detail: DeskEventDetail): void {\n if (record.screen?.handover && HANDOVER_MASKED_KINDS.has(detail.kind)) return\n ports.onEvent({ ...detail, deskId: record.deskId, at: iso(now()) })\n }\n\n function touch(record: DeskRecord): void {\n record.lastActivityAt = now()\n }\n\n function requireMachine(record: DeskRecord, epoch: number): DeskMachine {\n if (record.status !== 'resident' || record.epoch !== epoch || !record.machine) {\n throw new DeskError(`Desk ${record.deskId} is not resident; resume it first.`)\n }\n return record.machine\n }\n\n function requireScreen(record: DeskRecord, epoch: number): ScreenState {\n requireMachine(record, epoch)\n const screen = record.screen\n if (!screen?.running) {\n throw new DeskError(`Desk ${record.deskId} has no screen running; call screen.start first.`)\n }\n return screen\n }\n\n function assertCoordinates(record: DeskRecord, points: readonly DeskPoint[]): void {\n const observation = record.screen?.lastObservation\n if (!observation) {\n throw new DeskError(\n 'Coordinate input needs a frame of reference: call observe(), or start '\n + 'frames() and wait for one. Coordinates are the pixel space of the '\n + 'most recent of those, one to one.',\n )\n }\n for (const point of points) {\n if (\n !Number.isInteger(point.x)\n || !Number.isInteger(point.y)\n || point.x < 0\n || point.y < 0\n || point.x >= observation.width\n || point.y >= observation.height\n ) {\n throw new DeskError(\n `Coordinates (${point.x}, ${point.y}) are outside the most recent view `\n + `(${observation.width}x${observation.height}); observe() again before targeting.`,\n )\n }\n }\n }\n\n function armTimer(record: DeskRecord): void {\n if (record.timer) clearTimeout(record.timer)\n record.timer = null\n if (record.status !== 'resident') return\n const deadlines = [record.leaseDeadline, record.lastActivityAt + idleSuspendMs]\n const handover = record.screen?.handover\n if (handover) deadlines.push(handover.deadline)\n const delayMs = Math.max(Math.min(...deadlines) - now(), MIN_TIMER_DELAY_MS)\n record.timer = setTimeout(() => {\n sweep()\n .then(() => {\n if (record.status === 'resident') armTimer(record)\n })\n .catch((error: unknown) => {\n lastError = errorMessage(error)\n })\n }, delayMs)\n record.timer.unref()\n }\n\n async function endHandover(record: DeskRecord, reason: DeskHandoverEndReason): Promise<void> {\n const screen = record.screen\n const handover = screen?.handover\n if (!screen || !handover) return\n screen.handover = null\n if (record.machine) {\n try {\n await record.machine.request({ op: 'handover-end' })\n } catch (error) {\n lastError = errorMessage(error)\n }\n }\n const durationMs = Math.max(0, now() - handover.beganAt)\n emit(record, { kind: 'handover_end', actor: handover.actor, durationMs })\n ports.audit({\n kind: 'handover_end',\n deskId: record.deskId,\n actor: handover.actor,\n durationMs,\n reason,\n at: iso(now()),\n })\n }\n\n /**\n * Stop the machine and keep the disk. This is the SUSPEND half of the\n * lifecycle and it is shared by three callers — `suspend`, `sweep`, and\n * `destroy` — so it must never delete, truncate, or rewrite the overlay.\n *\n * That is not a stylistic preference. For a suspended desk the overlay IS\n * the desk: its home directory, its installed state, its half-written work.\n * A desk that comes back from suspend with a fresh disk has silently lost\n * everything, and the loss surfaces long after the code that caused it.\n * Reclaiming the disk is the exclusive business of `reclaimOverlay`, which\n * is called from exactly one place — `destroy` — where the caller has said\n * the desk should cease to exist.\n */\n /**\n * Hand the guest's freed blocks back to the host, as the last thing the\n * guest does before it stops.\n *\n * An overlay only ever GROWS otherwise. A block the guest writes is\n * allocated on the host filesystem forever; deleting the file inside the\n * guest frees it in the guest's own filesystem and tells the host nothing,\n * so a long-lived desk ratchets upward until the volume is full even though\n * the guest reports itself half empty. `fstrim` is what closes that loop:\n * it walks the guest filesystem's free space and issues discards, which\n * Cloud Hypervisor's virtio-blk turns into hole-punches on the raw overlay.\n *\n * Suspend is the right moment for it. The image's own `fstrim.timer` fires\n * WEEKLY, and a desk that idle-suspends after minutes is almost never up\n * when that lands — so on a leased-and-parked desk the scheduled trim\n * effectively never runs. Suspend, by contrast, is exactly when the guest\n * has stopped needing its scratch and the host wants the space back.\n *\n * This does not violate the disk contract on `teardown`. `fstrim` discards\n * only blocks the guest's filesystem already considers free; it cannot\n * remove a suspended desk's state, and a desk resumed afterwards sees an\n * identical filesystem. It is also strictly best-effort and bounded: a\n * guest that is wedged, disconnected, or lacks the binary must still\n * suspend promptly, so every failure here is swallowed into `lastError`.\n */\n async function trimGuest(record: DeskRecord, machine: DeskMachine): Promise<void> {\n if (!trimOnSuspend) return\n try {\n await machine.request({\n op: 'exec',\n command: trimCommand,\n args: trimArgs,\n timeoutMs: trimTimeoutMs,\n })\n } catch (error) {\n lastError = `Trim before suspend failed for ${record.deskId}: ${errorMessage(error)}`\n }\n }\n\n /**\n * Flush the guest's filesystem, immediately before it stops.\n *\n * Only needed when parking keeps memory. A snapshot always matches the disk it\n * was taken with, so the pair is consistent either way — but the disk ON ITS\n * OWN is not, and that is what remains every time a snapshot has to be\n * discarded. Without this, discarding one leaves a filesystem mid-transaction\n * and the next cold boot recovers a journal and loses the last writes. Best\n * effort and bounded: a guest too wedged to sync must still be parked.\n */\n async function syncGuest(record: DeskRecord, machine: DeskMachine): Promise<void> {\n try {\n await machine.request({ op: 'exec', command: 'sync', args: [], timeoutMs: trimTimeoutMs })\n } catch (error) {\n lastError = `Sync before park failed for ${record.deskId}: ${errorMessage(error)}`\n }\n }\n\n /** Where this desk's memory snapshot lives; must agree with the launch plan. */\n function snapshotDirFor(overlayPath: string, deskId: string): string {\n return join(dirname(overlayPath), `${deskId}.snapshot`)\n }\n\n async function teardown(record: DeskRecord, keepMemory = true): Promise<boolean> {\n if (record.status !== 'resident') return false\n await endHandover(record, 'revoked')\n for (const stop of [...record.streamStops]) stop()\n record.streamStops.clear()\n for (const stop of record.relayStops) stop()\n record.relayStops.clear()\n if (record.screen?.running) {\n record.screen.running = false\n emit(record, { kind: 'screen_close' })\n }\n record.screen = null\n for (const job of record.jobs.values()) {\n if (job.status !== 'running') continue\n job.status = 'exited'\n job.signal = 'SIGKILL'\n emit(record, { kind: 'job_exit', jobId: job.jobId, exitCode: null, signal: 'SIGKILL' })\n }\n record.unsubscribe?.()\n record.unsubscribe = null\n record.unwatchConnection?.()\n record.unwatchConnection = null\n if (record.timer) clearTimeout(record.timer)\n record.timer = null\n const machine = record.machine\n record.machine = null\n // Do not advertise this desk as suspended until its VMM child is actually\n // down. `serializeLifecycle` prevents a new boot from entering while this\n // transitional state still owns the overlay.\n record.status = 'suspending'\n record.handle = null\n if (machine) {\n await trimGuest(record, machine)\n // Flush the guest's filesystem before anything stops.\n //\n // A paused guest still holds dirty pages that exist only in its memory, so\n // a snapshot is consistent with the disk but the DISK ALONE is not — and\n // the disk alone is exactly what is left whenever a snapshot is discarded,\n // which happens on every failed restore. Syncing first makes discarding a\n // snapshot always safe instead of usually safe.\n const parking = keepMemory && parkWithMemory && typeof machine.park === 'function'\n // A shutdown that throws memory away leaves the disk as the only state, so\n // it is flushed exactly as a park is.\n if (parking || !keepMemory) await syncGuest(record, machine)\n try {\n if (parking) {\n const snapshotDir = snapshotDirFor(record.startOptions.overlayPath, record.deskId)\n await makeSnapshotDir(snapshotDir)\n await machine.park!(snapshotDir)\n const signature = await (options.cpuSignature ?? hostCpuSignature)()\n await (options.writeSnapshotSignature ?? writeSnapshotSignature)(snapshotDir, signature)\n } else {\n await machine.shutdown()\n }\n } catch (error) {\n // `park` stops the VMM on its own way out, so the desk is down either\n // way; what is lost is the memory, not the desk. Leave nothing behind\n // that a later boot would try to restore from.\n lastError = errorMessage(error)\n if (parking) {\n await removeSnapshot(snapshotDirFor(record.startOptions.overlayPath, record.deskId)).catch(\n () => undefined,\n )\n }\n }\n }\n lastSuspendedAt = iso(now())\n occupied -= 1\n record.status = 'suspended'\n drainQueue()\n return true\n }\n\n function drainQueue(): void {\n while (occupied < capacity && queue.length > 0) {\n const entry = queue.shift()\n if (!entry) break\n occupied += 1\n entry.run().then(entry.resolve, (error: unknown) => {\n occupied -= 1\n entry.reject(error instanceof Error ? error : new Error(String(error)))\n drainQueue()\n })\n }\n }\n\n function admit(run: () => Promise<DeskHandle>): Promise<DeskHandle> {\n if (occupied < capacity) {\n occupied += 1\n return run().catch((error: unknown) => {\n occupied -= 1\n drainQueue()\n throw error\n })\n }\n return new Promise<DeskHandle>((resolvePromise, rejectPromise) => {\n queue.push({ run, resolve: resolvePromise, reject: rejectPromise })\n })\n }\n\n /**\n * Refuse a desk the overlay filesystem cannot afford. A reflink clone costs\n * almost nothing at creation and then grows as the guest writes, so the\n * moment that matters is not the `cp` — it is every write after it. Checking\n * headroom here converts a mid-boot ENOSPC, which the guest reports as a\n * corrupt disk or a hang, into one refusal naming the actual shortage.\n */\n async function admitDisk(overlayPath: string): Promise<void> {\n if (minFreeBytes <= 0) return\n let free: number\n try {\n free = await freeBytes(overlayPath)\n } catch (error) {\n // Fail OPEN on an unreadable filesystem: a desk refused because statfs\n // hiccuped is a worse outcome than one admitted onto a disk that turns\n // out to be full, which at least fails with a real disk error.\n lastError = `Free-space check failed for ${overlayPath}: ${errorMessage(error)}`\n return\n }\n if (free < minFreeBytes) {\n throw new DeskError(\n `Refusing to start a desk: the overlay filesystem holding ${overlayPath} has `\n + `${free} bytes free, below the ${minFreeBytes}-byte floor. Reclaim destroyed `\n + 'desks’ overlays or grow the volume before leasing another desk.',\n )\n }\n }\n\n async function boot(deskId: string, startOptions: DeskStartOptions): Promise<DeskHandle> {\n // Before the plan, so a full disk is reported as a full disk rather than\n // as whatever the overlay copy fails with.\n await admitDisk(startOptions.overlayPath)\n const snapshotDir = snapshotDirFor(startOptions.overlayPath, deskId)\n // The SAME cid for both attempts below. A restored VM's snapshotted config\n // names its vsock and tap, and a cold-boot retry that renumbered them would\n // come up on a different tap than the one the egress rules were put on.\n const cid = nextCid++\n const initramfsPath = resolveInitramfsPath()\n const planFor = (restore: boolean) =>\n buildDeskLaunchPlan(\n {\n deskId,\n hypervisor: backend.hypervisor ?? 'cloud-hypervisor',\n ...(backend.hypervisor === 'virtualization' ? { guestNetwork: options.guestNetwork } : {}),\n vmmPath: options.vmmPath,\n kvmPath: options.kvmPath,\n kernelPath,\n ...(initramfsPath === undefined ? {} : { initramfsPath }),\n baseImagePath: startOptions.baseImage,\n overlayPath: startOptions.overlayPath,\n memoryMb: startOptions.memoryMb,\n vcpus: startOptions.vcpus,\n vsockCid: cid,\n runtimeDir: options.runtimeDir,\n tapDevice: startOptions.network?.tapDevice,\n macAddress: startOptions.network?.macAddress,\n // Forward the host's cmdline only when set; otherwise the plan falls\n // back to DEFAULT_KERNEL_CMDLINE.\n ...(kernelCmdline === undefined ? {} : { kernelCmdline }),\n launcherIdentity: options.launcherIdentity,\n snapshotDir,\n ...(restore ? { restore: true as const } : {}),\n },\n { pathExists, deviceExists },\n )\n\n let resuming = parkWithMemory && pathExists(snapshotDir)\n if (resuming) {\n const saved = await (options.readSnapshotSignature ?? readSnapshotSignature)(snapshotDir)\n if (saved !== null && saved !== await (options.cpuSignature ?? hostCpuSignature)()) {\n await removeSnapshot(snapshotDir)\n resuming = false\n recordCpuFallback(deskId, 'signature_mismatch')\n }\n }\n let machine: DeskMachine\n try {\n machine = resuming\n ? await backend.boot(planFor(true), {\n // The guest is restored and PAUSED here. Destroying the snapshot in\n // this window is what stops a memory image ever outliving the disk\n // state it belongs to. If it fails the restore is abandoned rather\n // than resumed, because resuming would leave both alive at once.\n onRestored: () => removeSnapshot(snapshotDir),\n })\n : await backend.boot(planFor(false))\n } catch (error) {\n if (resuming) {\n // A snapshot that will not come back is worse than no snapshot: it makes\n // the desk unbootable for as long as it sits there. Drop it and cold\n // boot. Safe by construction — the guest never ran, so the disk is\n // exactly as the pre-park sync left it.\n const why = errorMessage(error)\n await removeSnapshot(snapshotDir)\n if (isIncompatibleCpuSnapshotError(error)) recordCpuFallback(deskId, 'incompatible_cpuid')\n else lastError = `Desk ${deskId} could not resume from its snapshot and was cold booted: ${why}`\n // Falls through to the shared record path below with a cold machine.\n machine = await backend.boot(planFor(false))\n } else {\n lastError = errorMessage(error)\n throw error instanceof DeskError\n ? error\n : new DeskError(`Desk ${deskId} failed to boot: ${errorMessage(error)}`)\n }\n }\n\n let record = records.get(deskId)\n if (!record) {\n record = {\n deskId,\n startOptions,\n status: 'resident',\n machine,\n epoch: 1,\n leaseDeadline: 0,\n lastActivityAt: 0,\n jobs: new Map(),\n screen: null,\n unsubscribe: null,\n unwatchConnection: null,\n handle: null,\n timer: null,\n streamStops: new Set(),\n relayStops: new Set(),\n }\n records.set(deskId, record)\n } else {\n record.startOptions = startOptions\n record.status = 'resident'\n record.machine = machine\n record.epoch += 1\n record.jobs = new Map()\n record.screen = null\n record.streamStops = new Set()\n record.relayStops = new Set()\n }\n const current = record\n const epoch = current.epoch\n current.leaseDeadline = now() + positiveInteger(startOptions.leaseMs ?? defaultLeaseMs, 'leaseMs')\n current.lastActivityAt = now()\n current.unsubscribe = machine.subscribe((event) => {\n handleGuestEvent(current, epoch, event)\n })\n current.unwatchConnection =\n machine.onConnectionChange?.((change) => {\n handleConnectionChange(current, epoch, change)\n }) ?? null\n current.handle = makeHandle(current, epoch)\n lastStartedAt = iso(now())\n armTimer(current)\n return current.handle\n }\n\n function handleGuestEvent(record: DeskRecord, epoch: number, event: GuestEventMessage): void {\n if (record.status !== 'resident' || record.epoch !== epoch) return\n if (event.event === 'job-exit') {\n const job = record.jobs.get(event.jobId)\n if (!job || job.status !== 'running') return\n job.status = 'exited'\n job.exitCode = event.exitCode\n job.signal = event.signal\n emit(record, {\n kind: 'job_exit',\n jobId: event.jobId,\n exitCode: event.exitCode,\n signal: event.signal,\n })\n return\n }\n if (event.event === 'window-focus') {\n if (record.screen) record.screen.lastFocusedId = event.window.id\n emit(record, { kind: 'window_focus', window: event.window })\n }\n }\n\n /**\n * What a desk losing (and regaining) its guest channel means up here.\n *\n * The backend can get the CHANNEL back; it cannot get the GUEST's state\n * back, and pretending otherwise is how a consumer ends up waiting forever\n * on a stream that will never produce another byte. So a reconnect is\n * treated as a discontinuity that the caller is able to see, and a\n * permanent loss retires the desk instead of leaving a dead one leased.\n */\n function handleConnectionChange(\n record: DeskRecord,\n epoch: number,\n change: DeskConnectionChange,\n ): void {\n if (record.status !== 'resident' || record.epoch !== epoch) return\n if (change.state === 'reconnected') {\n reconnects += 1\n lastReconnectAt = iso(now())\n lastReconnectDeskId = record.deskId\n // Never silent. A reconnect that hides a guest agent restarting is a\n // debugging trap: the desk misbehaves and nothing anywhere says why.\n lastError = `Desk ${record.deskId} reconnected to its guest agent after ${change.downtimeMs}ms (${change.reason}).`\n // The guest's capture state did not necessarily come back with the\n // channel. An agent that restarted has no screen, no frame encoder and\n // no video encoder; even one that survived starts a fresh encoder whose\n // sequence numbers and init segment do not continue the old stream. A\n // consumer resumed mid-stream decodes nothing, silently — so every live\n // stream is ENDED. `frames()`/`video()` complete normally, which is how\n // the consumer notices, and it can start a new one on a guest that is\n // now definitely capturing.\n for (const stop of [...record.streamStops]) stop()\n record.streamStops.clear()\n // The coordinate anchor goes with them: the screen behind it may be\n // gone, or recreated at another size, and a click aimed at the pixel\n // space of a screen that no longer exists lands somewhere nobody chose.\n // Input then refuses until the caller observes again — the existing\n // contract, not a new one.\n if (record.screen) {\n record.screen.lastObservation = null\n // The reconnected channel proves the machine is alive, not that the\n // guest compositor survived. Treat the screen as needing an explicit\n // restart so screen.start() reaches the guest instead of returning the\n // stale handle forever. Keep ScreenState itself so an active handover\n // remains masked in the safe direction until its explicit/TTL end.\n record.screen.running = false\n }\n // A handover is deliberately NOT ended here. If a human is still on that\n // screen, dropping the mask would start recording them; letting the TTL\n // expire it fails in the safe direction.\n return\n }\n // Lost for good. Left resident, this desk would answer every call with\n // \"no longer connected\" for the rest of the lease and `resume()` would\n // hand back the same dead handle — the exact product failure this release\n // is about. Suspending it frees the capacity slot and makes the next\n // `resume()` boot a healthy desk.\n lastError = change.reason\n void serializeLifecycle(record.deskId, async () => {\n // The loss belongs to the epoch that registered this watcher. If an\n // earlier queued transition already replaced that machine, this stale\n // signal must not retire the fresh resident.\n if (record.status !== 'resident' || record.epoch !== epoch) return\n await teardown(record)\n }).catch((error: unknown) => {\n lastError = errorMessage(error)\n })\n }\n\n function makeHandle(record: DeskRecord, epoch: number): DeskHandle {\n const execImplementation = async (\n execOptions: DeskExecOptions,\n ): Promise<DeskExecSnapshot | DeskJob> => {\n const machine = requireMachine(record, epoch)\n const command = nonEmptyString(execOptions.command, 'command')\n const args = [...(execOptions.args ?? [])]\n const keepAlive = execOptions.keepAlive === true\n if (ports.policy?.allowExec && !ports.policy.allowExec({\n deskId: record.deskId,\n command,\n args,\n keepAlive,\n })) {\n throw new DeskError(`Policy denied exec of ${command} on desk ${record.deskId}.`)\n }\n touch(record)\n const startedAt = iso(now())\n if (keepAlive) {\n const { jobId } = parseJobStarted(await machine.request({\n op: 'job-start',\n command,\n args,\n cwd: execOptions.cwd,\n env: execOptions.env,\n }))\n const job: DeskJob = {\n jobId,\n deskId: record.deskId,\n command,\n args,\n startedAt,\n status: 'running',\n exitCode: null,\n signal: null,\n }\n record.jobs.set(jobId, job)\n emit(record, { kind: 'job_start', jobId, command, args })\n return { ...job }\n }\n const result = parseExecResult(await machine.request(\n {\n op: 'exec',\n command,\n args,\n cwd: execOptions.cwd,\n env: execOptions.env,\n timeoutMs: execOptions.timeoutMs,\n },\n execOptions.timeoutMs === undefined ? {} : { timeoutMs: execOptions.timeoutMs + 5_000 },\n ))\n emit(record, {\n kind: 'shell_command',\n command,\n args,\n cwd: execOptions.cwd ?? null,\n exitCode: result.exitCode,\n signal: result.signal,\n })\n return {\n deskId: record.deskId,\n command,\n args,\n exitCode: result.exitCode,\n signal: result.signal,\n stdout: result.stdout,\n stderr: result.stderr,\n truncated: result.truncated,\n startedAt,\n finishedAt: iso(now()),\n }\n }\n\n const screenService: DeskScreenService = {\n async start({ width, height }) {\n const machine = requireMachine(record, epoch)\n if (record.screen?.running) return record.screen.handle\n const cleanWidth = positiveInteger(width, 'width')\n const cleanHeight = positiveInteger(height, 'height')\n if (ports.policy?.allowScreen && !ports.policy.allowScreen({\n deskId: record.deskId,\n width: cleanWidth,\n height: cleanHeight,\n })) {\n throw new DeskError(`Policy denied opening a screen on desk ${record.deskId}.`)\n }\n touch(record)\n await machine.request({ op: 'screen-start', width: cleanWidth, height: cleanHeight })\n const existing = record.screen\n if (existing) {\n // A guest-agent reconnect invalidates what the host knew about the\n // compositor without necessarily ending an active handover. Reuse\n // the same handle so existing consumers can recover, and retain the\n // handover mask until its explicit/TTL end rather than briefly\n // exposing a human's private input while the screen restarts.\n existing.running = true\n existing.width = cleanWidth\n existing.height = cleanHeight\n existing.lastObservation = null\n existing.lastFocusedId = null\n emit(record, { kind: 'screen_open', width: cleanWidth, height: cleanHeight })\n return existing.handle\n }\n const handle = makeScreenHandle(record, epoch)\n record.screen = {\n running: true,\n width: cleanWidth,\n height: cleanHeight,\n lastObservation: null,\n lastFocusedId: null,\n handover: null,\n handle,\n }\n emit(record, { kind: 'screen_open', width: cleanWidth, height: cleanHeight })\n return handle\n },\n async stop() {\n const machine = requireMachine(record, epoch)\n const screen = record.screen\n if (!screen?.running) return\n await endHandover(record, 'revoked')\n for (const stop of [...record.streamStops]) stop()\n record.streamStops.clear()\n screen.running = false\n record.screen = null\n touch(record)\n await machine.request({ op: 'screen-stop' })\n emit(record, { kind: 'screen_close' })\n },\n get running() {\n return record.screen?.running === true\n },\n }\n\n return {\n deskId: record.deskId,\n renewLease(ms: number): void {\n requireMachine(record, epoch)\n record.leaseDeadline = now() + positiveInteger(ms, 'ms')\n touch(record)\n armTimer(record)\n },\n async connect(port: number): Promise<Duplex> {\n requireMachine(record, epoch)\n if (!Number.isInteger(port) || port < 1 || port > 65535) throw new DeskError('Guest TCP port must be between 1 and 65535.')\n const machine = requireMachine(record, epoch)\n const address = record.startOptions.network?.guestAddress\n if (!machine.connect && (!address || isIP(address) !== 4)) throw new DeskError('A guest IPv4 address is required to connect to a desk port.')\n touch(record)\n try {\n const stream = machine.connect ? await machine.connect(port) : await (options.connectGuest ?? connectGuestTcp)(address!, port)\n try { requireMachine(record, epoch) } catch (error) { stream.destroy(); throw error }\n const stop = () => stream.destroy()\n record.relayStops.add(stop)\n stream.once('close', () => record.relayStops.delete(stop))\n return stream\n } catch (error) { throw new DeskError(`Cannot connect to guest ${address}:${port}: ${errorMessage(error)}`) }\n },\n exec: execImplementation as DeskHandle['exec'],\n jobs(): DeskJob[] {\n return [...record.jobs.values()]\n .filter((job) => job.status === 'running')\n .map((job) => ({ ...job }))\n },\n screen: screenService,\n }\n }\n\n function makeScreenHandle(record: DeskRecord, epoch: number): DeskScreenHandle {\n async function sendInput(detail: DeskEventDetail | null, input: GuestInput): Promise<void> {\n const machine = requireMachine(record, epoch)\n touch(record)\n await machine.request({ op: 'input', input })\n if (detail) emit(record, detail)\n }\n\n return {\n async observe(): Promise<DeskObservation> {\n const machine = requireMachine(record, epoch)\n const screen = requireScreen(record, epoch)\n touch(record)\n const observation = parseObservation(await machine.request({ op: 'observe' }))\n screen.lastObservation = { width: observation.width, height: observation.height }\n if (observation.focused && observation.focused.id !== screen.lastFocusedId) {\n screen.lastFocusedId = observation.focused.id\n emit(record, { kind: 'window_focus', window: observation.focused })\n }\n return {\n png: Buffer.from(observation.png, 'base64'),\n width: observation.width,\n height: observation.height,\n a11y: observation.a11y,\n windows: observation.windows,\n focused: observation.focused,\n }\n },\n input: {\n async move(x, y) {\n requireScreen(record, epoch)\n assertCoordinates(record, [{ x, y }])\n await sendInput(null, { type: 'move', x, y })\n },\n async click(x, y, button = 'left', clicks = 1) {\n requireScreen(record, epoch)\n assertCoordinates(record, [{ x, y }])\n if (clicks !== 1 && clicks !== 2) throw new DeskError('clicks must be 1 or 2.')\n await sendInput({ kind: 'click', x, y, button, clicks }, { type: 'click', x, y, button, clicks })\n },\n async type(text) {\n requireScreen(record, epoch)\n const cleanText = requireStringValue(text, 'text')\n await sendInput({ kind: 'type', text: cleanText }, { type: 'type', text: cleanText })\n },\n async key(combo) {\n requireScreen(record, epoch)\n const cleanCombo = nonEmptyString(combo, 'combo')\n await sendInput({ kind: 'key', combo: cleanCombo }, { type: 'key', combo: cleanCombo })\n },\n async scroll(x, y, dx, dy) {\n requireScreen(record, epoch)\n assertCoordinates(record, [{ x, y }])\n if (!Number.isInteger(dx) || !Number.isInteger(dy)) {\n throw new DeskError('Scroll deltas must be integers.')\n }\n await sendInput({ kind: 'scroll', x, y, dx, dy }, { type: 'scroll', x, y, dx, dy })\n },\n async drag(from, to) {\n requireScreen(record, epoch)\n assertCoordinates(record, [from, to])\n await sendInput({ kind: 'drag', from, to }, { type: 'drag', from, to })\n },\n },\n a11y: {\n async invoke(nodeId, action) {\n const machine = requireMachine(record, epoch)\n requireScreen(record, epoch)\n touch(record)\n await machine.request({\n op: 'a11y-invoke',\n nodeId: nonEmptyString(nodeId, 'nodeId'),\n action: nonEmptyString(action, 'action'),\n })\n },\n },\n async launch(appId, args = []) {\n const machine = requireMachine(record, epoch)\n requireScreen(record, epoch)\n touch(record)\n const cleanAppId = nonEmptyString(appId, 'appId')\n await machine.request({ op: 'launch', appId: cleanAppId, args: [...args] })\n emit(record, { kind: 'app_launch', appId: cleanAppId, args: [...args] })\n },\n clipboard: {\n async read() {\n const machine = requireMachine(record, epoch)\n const screen = requireScreen(record, epoch)\n if (screen.handover) {\n // The human may have just typed a credential that is now on the\n // clipboard; reading it during a handover would carry it into the\n // agent's context and the consumer's record.\n throw new DeskError('The clipboard is masked while a handover is active.')\n }\n touch(record)\n return parseClipboardText(await machine.request({ op: 'clipboard-read' }))\n },\n async write(text) {\n const machine = requireMachine(record, epoch)\n requireScreen(record, epoch)\n touch(record)\n await machine.request({ op: 'clipboard-write', text: requireStringValue(text, 'text') })\n },\n },\n frames(frameOptions = {}) {\n return {\n [Symbol.asyncIterator]: () => {\n const machine = requireMachine(record, epoch)\n const screen = requireScreen(record, epoch)\n const fps = positiveInteger(frameOptions.fps ?? 10, 'fps')\n const width = positiveInteger(frameOptions.width ?? screen.width, 'width')\n const height = positiveInteger(frameOptions.height ?? screen.height, 'height')\n const format = frameOptions.format\n const buffered: DeskFrame[] = []\n let waiting: ((result: IteratorResult<DeskFrame, undefined>) => void) | null = null\n let finished = false\n const unsubscribe = machine.subscribe((event) => {\n if (finished || event.event !== 'frame') return\n // Masking contract: no frame reaches a recording consumer while\n // a handover is active.\n if (record.screen?.handover) return\n const frame: DeskFrame = {\n seq: event.seq,\n width: event.width,\n height: event.height,\n data: Buffer.from(event.data, 'base64'),\n format: event.format,\n at: iso(now()),\n }\n // A frame anchors coordinates exactly as an observation does.\n // The contract is that a click lands in the pixel space of the\n // most recent thing the caller was SHOWN, and a live view is\n // shown the frame stream, not observe(). Without this a viewer\n // that watches frames and clicks what it sees is refused for\n // never having called observe() — technically true and useless.\n if (record.screen) {\n record.screen.lastObservation = { width: frame.width, height: frame.height }\n }\n if (waiting) {\n const resume = waiting\n waiting = null\n resume({ value: frame, done: false })\n } else {\n buffered.push(frame)\n if (buffered.length > MAX_BUFFERED_FRAMES) buffered.shift()\n }\n })\n const finish = (): void => {\n if (finished) return\n finished = true\n unsubscribe()\n record.streamStops.delete(finish)\n if (record.status === 'resident' && record.machine) {\n record.machine.request({ op: 'frames-stop' }).catch((error: unknown) => {\n lastError = errorMessage(error)\n })\n }\n if (waiting) {\n const resume = waiting\n waiting = null\n resume({ value: undefined, done: true })\n }\n }\n record.streamStops.add(finish)\n const started = machine\n .request({ op: 'frames-start', fps, width, height, format })\n .catch((error: unknown) => {\n finish()\n throw error instanceof Error ? error : new Error(String(error))\n })\n return {\n async next(): Promise<IteratorResult<DeskFrame, undefined>> {\n await started\n const bufferedFrame = buffered.shift()\n if (bufferedFrame) return { value: bufferedFrame, done: false }\n if (finished) return { value: undefined, done: true }\n return new Promise((resolvePromise) => {\n waiting = resolvePromise\n })\n },\n async return(): Promise<IteratorResult<DeskFrame, undefined>> {\n finish()\n return { value: undefined, done: true }\n },\n async throw(error?: unknown): Promise<IteratorResult<DeskFrame, undefined>> {\n finish()\n throw error instanceof Error ? error : new Error(String(error))\n },\n }\n },\n }\n },\n video(videoOptions = {}) {\n return {\n [Symbol.asyncIterator]: () => {\n const machine = requireMachine(record, epoch)\n const screen = requireScreen(record, epoch)\n const fps = positiveInteger(videoOptions.fps ?? 30, 'fps')\n const width = positiveInteger(videoOptions.width ?? screen.width, 'width')\n const height = positiveInteger(videoOptions.height ?? screen.height, 'height')\n const buffered: DeskVideoChunk[] = []\n let waiting: ((result: IteratorResult<DeskVideoChunk, undefined>) => void) | null = null\n let finished = false\n const unsubscribe = machine.subscribe((event) => {\n if (finished || event.event !== 'video-chunk') return\n // The same masking contract frames are held to: while a handover\n // is active a person is on that screen, and nothing derived from\n // watching them may reach a recording consumer.\n if (record.screen?.handover) return\n const chunk: DeskVideoChunk = {\n seq: event.seq,\n kind: event.kind,\n codec: event.codec,\n width: event.width,\n height: event.height,\n keyframe: event.keyframe,\n data: Buffer.from(event.data, 'base64'),\n at: iso(now()),\n }\n // A video chunk anchors coordinates exactly as a frame does, and\n // for the same reason: a viewer driving by video is aiming at the\n // pixel space the video showed it. Anchoring on every chunk, not\n // only the first, is what re-asserts the space when the encoder\n // restarts at a new resolution.\n if (record.screen) {\n record.screen.lastObservation = { width: chunk.width, height: chunk.height }\n }\n if (waiting) {\n const resume = waiting\n waiting = null\n resume({ value: chunk, done: false })\n } else {\n buffered.push(chunk)\n // Dropping the OLDEST would drop the init segment, and a\n // consumer without it decodes nothing at all — so an overrun\n // ends the stream instead. A caller that cannot keep up with a\n // video stream is one that should re-subscribe and be resynced\n // from a keyframe, not one that should be handed a hole.\n if (buffered.length > MAX_BUFFERED_VIDEO_CHUNKS) finish()\n }\n })\n const finish = (): void => {\n if (finished) return\n finished = true\n unsubscribe()\n record.streamStops.delete(finish)\n if (record.status === 'resident' && record.machine) {\n record.machine.request({ op: 'video-stop' }).catch((error: unknown) => {\n lastError = errorMessage(error)\n })\n }\n if (waiting) {\n const resume = waiting\n waiting = null\n resume({ value: undefined, done: true })\n }\n }\n record.streamStops.add(finish)\n const started = machine\n .request({ op: 'video-start', fps, width, height })\n .catch((error: unknown) => {\n finish()\n throw error instanceof Error ? error : new Error(String(error))\n })\n return {\n async next(): Promise<IteratorResult<DeskVideoChunk, undefined>> {\n await started\n const bufferedChunk = buffered.shift()\n if (bufferedChunk) return { value: bufferedChunk, done: false }\n if (finished) return { value: undefined, done: true }\n return new Promise((resolvePromise) => {\n waiting = resolvePromise\n })\n },\n async return(): Promise<IteratorResult<DeskVideoChunk, undefined>> {\n finish()\n return { value: undefined, done: true }\n },\n async throw(error?: unknown): Promise<IteratorResult<DeskVideoChunk, undefined>> {\n finish()\n throw error instanceof Error ? error : new Error(String(error))\n },\n }\n },\n }\n },\n handover: {\n async begin({ ttlMs, scope = 'control', actor }) {\n const machine = requireMachine(record, epoch)\n const screen = requireScreen(record, epoch)\n if (screen.handover) {\n throw new DeskError(`A handover is already active on desk ${record.deskId}.`)\n }\n const cleanTtl = positiveInteger(ttlMs, 'ttlMs')\n if (ports.policy?.allowHandover && !ports.policy.allowHandover({\n deskId: record.deskId,\n scope,\n ttlMs: cleanTtl,\n })) {\n throw new DeskError(`Policy denied a handover on desk ${record.deskId}.`)\n }\n touch(record)\n const begun = parseHandoverBegun(\n await machine.request({ op: 'handover-begin', ttlMs: cleanTtl, scope }),\n )\n const startedAt = now()\n screen.handover = {\n actor: actor ?? null,\n scope,\n beganAt: startedAt,\n deadline: startedAt + cleanTtl,\n }\n // The boundary events are the one thing that crosses the mask.\n emit(record, { kind: 'handover_begin', actor: actor ?? null, scope })\n ports.audit({\n kind: 'handover_begin',\n deskId: record.deskId,\n actor: actor ?? null,\n scope,\n ttlMs: cleanTtl,\n at: iso(startedAt),\n })\n armTimer(record)\n return { url: begun.url }\n },\n async end() {\n requireMachine(record, epoch)\n await endHandover(record, 'ended')\n },\n get active() {\n return record.screen?.handover != null\n },\n },\n }\n }\n\n async function start(startOptions: DeskStartOptions): Promise<DeskHandle> {\n const deskId = cleanDeskId(startOptions.deskId)\n return serializeLifecycle(deskId, async () => {\n const existing = records.get(deskId)\n if (existing?.status === 'resident' && existing.handle) return existing.handle\n return admit(() => boot(deskId, { ...startOptions, deskId }))\n })\n }\n\n async function resume(deskId: string): Promise<DeskHandle> {\n const id = cleanDeskId(deskId)\n return serializeLifecycle(id, async () => {\n const record = records.get(id)\n if (!record) throw new DeskError(`Unknown desk: ${deskId}`)\n if (record.status === 'resident' && record.handle) return record.handle\n return admit(() => boot(record.deskId, record.startOptions))\n })\n }\n\n async function suspend(deskId: string): Promise<void> {\n const id = cleanDeskId(deskId)\n await serializeLifecycle(id, async () => {\n const record = records.get(id)\n if (!record) return\n await teardown(record)\n })\n }\n\n async function shutdown(deskId: string): Promise<void> {\n const id = cleanDeskId(deskId)\n await serializeLifecycle(id, async () => {\n const record = records.get(id)\n if (!record) return\n await teardown(record, false)\n // A desk parked earlier still has its memory image on disk; dropping it is\n // what makes the next boot cold. The overlay is untouched — only `destroy`\n // may remove it.\n await removeSnapshot(snapshotDirFor(record.startOptions.overlayPath, record.deskId))\n })\n }\n\n /**\n * Delete a desk's overlay. The ONLY place in this module that removes a\n * desk's disk, and it is reachable from `destroy` alone — see the contract\n * on `teardown` for why suspend must never come near it.\n *\n * The record is dropped whether or not the unlink succeeds: a desk the\n * caller has destroyed must not stay leaseable because its file was busy.\n * A failed unlink is surfaced through `lastError` and leaves the file for\n * the reaper rather than being retried here.\n */\n async function reclaimOverlay(record: DeskRecord): Promise<void> {\n try {\n await removeOverlay(record.startOptions.overlayPath)\n } catch (error) {\n lastError = `Overlay was not reclaimed for ${record.deskId}: ${errorMessage(error)}`\n }\n // The snapshot goes with the disk, always — not only when parking is on.\n //\n // A snapshot outliving its overlay is the worst state this feature can\n // produce: the next desk created under the same id gets a FRESH overlay and\n // would restore a previous desk's memory on top of it. That is not stale\n // state, it is one machine's RAM over another machine's disk. Teardown just\n // ran, so nothing holds it open.\n try {\n await removeSnapshot(snapshotDirFor(record.startOptions.overlayPath, record.deskId))\n } catch (error) {\n lastError = `Snapshot was not reclaimed for ${record.deskId}: ${errorMessage(error)}`\n }\n }\n\n async function destroy(deskId: string): Promise<void> {\n const id = cleanDeskId(deskId)\n await serializeLifecycle(id, async () => {\n const record = records.get(id)\n if (!record) return\n await teardown(record)\n records.delete(id)\n // Strictly after teardown: the VMM still has the file open until its child\n // has exited, and unlinking underneath a live guest would leave the desk\n // writing into an orphaned inode instead of failing loudly.\n await reclaimOverlay(record)\n })\n }\n\n async function sweep(): Promise<number> {\n const timestamp = now()\n let suspendedCount = 0\n for (const record of [...records.values()]) {\n const suspended = await serializeLifecycle(record.deskId, async () => {\n // A destroy and a later start may have replaced a captured record\n // before its turn in the sweep. Never apply the old deadline to the\n // new desk that happens to share its id.\n if (records.get(record.deskId) !== record || record.status !== 'resident') return false\n const handover = record.screen?.handover\n if (handover && handover.deadline <= timestamp) {\n await endHandover(record, 'expired')\n }\n if (\n record.leaseDeadline <= timestamp\n || timestamp - record.lastActivityAt >= idleSuspendMs\n ) {\n return teardown(record)\n }\n return false\n })\n if (suspended) suspendedCount += 1\n }\n return suspendedCount\n }\n\n function recordCpuFallback(deskId: string, reason: 'signature_mismatch' | 'incompatible_cpuid'): void {\n snapshotCpuFallbacks += 1\n lastSnapshotCpuFallback = { deskId, reason, at: iso(now()) }\n ports.onEvent({ kind: 'snapshot_cpu_fallback', deskId, reason, at: iso(now()) })\n }\n\n function stats(): DeskHostStats {\n let suspended = 0\n for (const record of records.values()) {\n if (record.status === 'suspended') suspended += 1\n }\n return {\n resident: occupied,\n queued: queue.length,\n capacity,\n suspended,\n lastStartedAt,\n lastSuspendedAt,\n reconnects,\n lastReconnectAt,\n lastReconnectDeskId,\n lastError,\n snapshotCpuFallbacks,\n lastSnapshotCpuFallback,\n }\n }\n\n return { start, resume, suspend, shutdown, destroy, stats, sweep }\n}\n\nexport interface VerifyDeskHostOptions {\n kernelPath: string\n /** Initramfs for the probe VM; needed for a modular kernel, as at boot. */\n initramfsPath?: string\n /**\n * Kernel command line for the probe VM. It must match what real desks boot\n * with: a probe that panics because its root is on another partition\n * reports a host that cannot run desks, which is indistinguishable from a\n * host that genuinely cannot.\n */\n kernelCmdline?: string\n baseImagePath: string\n vmmPath?: string\n kvmPath?: string\n /** Where the throwaway probe overlay is created; defaults to the OS tmpdir. */\n scratchDir?: string\n runtimeDir?: string\n backend?: DeskBackend\n launcherIdentity?: DeskLauncherIdentity\n platform?: NodeJS.Platform\n pathExists?: (path: string) => boolean\n deviceExists?: (path: string) => boolean\n idFactory?: () => string\n}\n\nexport interface OverlayReflinkCheck {\n /** Whether `cp --reflink` produced a block-sharing clone in this directory. */\n supported: boolean\n overlayDirectory: string\n /** Why the answer is what it is — the `cp` failure when unsupported. */\n detail: string\n}\n\n/**\n * Whether the overlay directory's filesystem can make reflink clones.\n * On macOS this probes APFS cloning with `cp -c`. On Linux:\n *\n * This exists because `cp --reflink=auto` — what `buildDeskLaunchPlan` uses,\n * deliberately, so a desk still boots on a filesystem without reflink — is\n * SILENT when it falls back. On XFS or Btrfs a 20GB base clones instantly and\n * costs kilobytes; on ext4 the identical command copies all 20GB, slowly, per\n * desk. The failure is invisible until a disk sized for reflink sharing fills\n * after two desks, which looks like a capacity bug rather than the filesystem\n * choice it actually is.\n *\n * So the probe uses `--reflink=always`, which REFUSES to fall back, on a tiny\n * throwaway file. Call it at startup and refuse to serve rather than discover\n * this in production — see `assertOverlayReflink`.\n */\nexport async function verifyOverlayReflink(options: {\n overlayDirectory: string\n idFactory?: () => string\n copy?: (source: string, destination: string) => Promise<void>\n}): Promise<OverlayReflinkCheck> {\n const overlayDirectory = options.overlayDirectory\n const idFactory = options.idFactory ?? randomUUID\n const copy = options.copy ?? reflinkAlways\n const token = idFactory()\n const source = join(overlayDirectory, `.reflink-probe-${token}`)\n const destination = join(overlayDirectory, `.reflink-probe-${token}.clone`)\n try {\n try {\n await writeFile(source, 'reflink probe')\n } catch (error) {\n // A directory that cannot be written to is not a filesystem without\n // reflink — it is a broken deployment, and reporting it as the former\n // would send an operator to reformat a disk over a permissions bug.\n throw new DeskError(\n `The overlay directory ${overlayDirectory} could not be written to, so reflink `\n + `support could not be determined: ${errorMessage(error)}`,\n )\n }\n await copy(source, destination)\n return { supported: true, overlayDirectory, detail: process.platform === 'darwin' ? 'cp -c succeeded.' : 'cp --reflink=always succeeded.' }\n } catch (error) {\n if (error instanceof DeskError) throw error\n return { supported: false, overlayDirectory, detail: errorMessage(error) }\n } finally {\n await rm(source, { force: true }).catch(() => undefined)\n await rm(destination, { force: true }).catch(() => undefined)\n }\n}\n\n/**\n * Fail loudly at startup on a filesystem without reflink support, naming the\n * cost so the operator can act on it.\n */\nexport async function assertOverlayReflink(options: {\n overlayDirectory: string\n idFactory?: () => string\n copy?: (source: string, destination: string) => Promise<void>\n}): Promise<OverlayReflinkCheck> {\n const check = await verifyOverlayReflink(options)\n if (!check.supported) {\n throw new DeskError(\n process.platform === 'darwin'\n ? `The overlay directory ${check.overlayDirectory} does not support cloning. Put it on APFS. Probe said: ${check.detail}`\n : `The overlay directory ${check.overlayDirectory} is on a filesystem without reflink `\n + 'support, so every desk would FULL-COPY the base image instead of sharing its '\n + 'blocks — gigabytes and minutes per desk, and a disk sized for sharing fills after '\n + `a handful of them. Put the overlay directory on XFS or Btrfs. Probe said: ${check.detail}`,\n )\n }\n return check\n}\n\nasync function reflinkAlways(source: string, destination: string): Promise<void> {\n await new Promise<void>((resolvePromise, rejectPromise) => {\n execFile('cp', [process.platform === 'darwin' ? '-c' : '--reflink=always', source, destination], (error, _stdout, stderr) => {\n if (error) {\n rejectPromise(new Error(stderr.trim() || errorMessage(error)))\n return\n }\n resolvePromise()\n })\n })\n}\n\nexport interface DeskHostVerification {\n /** Whether this host can serve desks: KVM present and the guest reachable. */\n supported: boolean\n vmmPath: string\n /** KVM availability; false on macOS, which uses Virtualization.framework. */\n kvm: boolean\n vsock: boolean\n virtioGpu: boolean\n}\n\n/**\n * Boot-time probe. Distinguishes a host that is unusable — wrong platform,\n * missing VMM, missing images — which throws, from capabilities that are\n * merely absent, which are reported as booleans: `kvm` (no boot possible\n * without it), `vsock` (the guest agent answered), and `virtioGpu` (a screen\n * would have hardware-backed rendering). It boots a throwaway microVM through\n * the backend, asks it two questions, and discards it.\n */\nexport async function verifyDeskHost(options: VerifyDeskHostOptions): Promise<DeskHostVerification> {\n const platform = options.platform ?? process.platform\n const pathExists = options.pathExists ?? existsSync\n const deviceExists = options.deviceExists ?? existsSync\n const idFactory = options.idFactory ?? randomUUID\n const backend = options.backend ?? cloudHypervisorBackend\n const isVirtualization = backend.hypervisor === 'virtualization'\n const vmmPath = options.vmmPath ?? backend.vmmPath ?? DEFAULT_VMM_PATH\n const kvmPath = options.kvmPath ?? DEFAULT_KVM_PATH\n\n if (platform !== (isVirtualization ? 'darwin' : 'linux')) {\n throw new DeskError(isVirtualization ? `Virtualization requires macOS; received ${platform}.` : `The AppKit desk requires Linux; received ${platform}.`)\n }\n if (!pathExists(vmmPath)) {\n throw new DeskError(isVirtualization ? `Virtualization helper was not found at ${vmmPath}.` : `Cloud Hypervisor was not found at ${vmmPath}.`)\n }\n if (!pathExists(options.kernelPath)) {\n throw new DeskError(`Guest kernel does not exist: ${options.kernelPath}`)\n }\n if (!pathExists(options.baseImagePath)) {\n throw new DeskError(`Base image does not exist: ${options.baseImagePath}`)\n }\n if (!isVirtualization && !deviceExists(kvmPath)) {\n return { supported: false, vmmPath, kvm: false, vsock: false, virtioGpu: false }\n }\n\n const scratchDir = options.scratchDir ?? tmpdir()\n const deskId = `verify-${idFactory()}`\n const overlayPath = join(scratchDir, `${deskId}.raw`)\n const plan = buildDeskLaunchPlan(\n {\n deskId,\n hypervisor: backend.hypervisor ?? 'cloud-hypervisor',\n vmmPath,\n kvmPath,\n kernelPath: options.kernelPath,\n ...(options.initramfsPath === undefined ? {} : { initramfsPath: options.initramfsPath }),\n ...(options.kernelCmdline === undefined ? {} : { kernelCmdline: options.kernelCmdline }),\n baseImagePath: options.baseImagePath,\n overlayPath,\n vsockCid: 3,\n runtimeDir: options.runtimeDir,\n launcherIdentity: options.launcherIdentity,\n },\n { pathExists, deviceExists },\n )\n\n let machine: DeskMachine\n try {\n machine = await backend.boot(plan)\n } catch (error) {\n throw new DeskError(`Desk verification could not boot a probe VM: ${errorMessage(error)}`)\n }\n let vsock = false\n let virtioGpu = false\n try {\n try {\n await machine.request({ op: 'ping' })\n vsock = true\n } catch {\n vsock = false\n }\n if (vsock) {\n try {\n virtioGpu = parseCapabilities(await machine.request({ op: 'capabilities' })).virtioGpu\n } catch {\n virtioGpu = false\n }\n }\n } finally {\n try {\n await machine.shutdown()\n } catch {\n // The probe VM is discarded regardless of how cleanly it stops.\n }\n await rm(overlayPath, { force: true })\n }\n return { supported: vsock, vmmPath, kvm: !isVirtualization, vsock, virtioGpu }\n}\n\nfunction nonEmptyString(value: string, field: string): string {\n if (typeof value !== 'string' || value.length === 0) {\n throw new DeskError(`${field} must be a non-empty string.`)\n }\n return value\n}\n\nfunction requireStringValue(value: string, field: string): string {\n if (typeof value !== 'string') {\n throw new DeskError(`${field} must be a string.`)\n }\n return value\n}\n\nfunction positiveInteger(value: number, field: string): number {\n if (!Number.isInteger(value) || value < 1) {\n throw new DeskError(`${field} must be a positive integer.`)\n }\n return value\n}\n\nfunction nonNegativeInteger(value: number, field: string): number {\n if (!Number.isInteger(value) || value < 0) {\n throw new DeskError(`${field} must be an integer of zero or more.`)\n }\n return value\n}\n\n/**\n * Free bytes on the filesystem holding `path`, measured against the directory\n * so the answer is the same before and after the overlay itself exists.\n */\nasync function defaultFreeBytes(path: string): Promise<number> {\n const stats = await statfs(dirname(path))\n return Number(stats.bsize) * Number(stats.bavail)\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n\nasync function connectGuestTcp(address: string, port: number): Promise<Duplex> {\n return new Promise((resolve, reject) => {\n const socket = tcpConnect({ host: address, port })\n socket.setTimeout(10_000, () => socket.destroy(new Error('Guest TCP connection timed out.')))\n socket.once('error', reject)\n socket.once('connect', () => { socket.setTimeout(0); socket.removeListener('error', reject); resolve(socket) })\n })\n}\n\n/** Cloud Hypervisor's specific restore error; do not classify generic CPUID mentions. */\nexport function isIncompatibleCpuSnapshotError(error: unknown): boolean {\n return /Detected incompatible CPUID entry/.test(errorMessage(error))\n}\n/** Hash the host's CPU identity and advertised feature set, excluding per-core counters. */\nexport async function hostCpuSignature(): Promise<string> {\n if (process.platform === 'darwin') {\n const model = cpus()[0]?.model\n if (!model) throw new DeskError('Cannot determine host CPU signature.')\n return createHash('sha256').update(`darwin:${arch()}:${release()}:${model}`).digest('hex')\n }\n const cpuinfo = await readFile('/proc/cpuinfo', 'utf8')\n const first = cpuinfo.split(/\\n\\s*\\n/)[0] ?? ''\n const identity = first.split('\\n').filter((line) => /^(vendor_id|cpu family|model\\s|model name|stepping|flags|microcode)\\s*:/.test(line)).join('\\n')\n if (!identity) throw new DeskError('Cannot determine host CPU signature.')\n return createHash('sha256').update(identity).digest('hex')\n}\nasync function readSnapshotSignature(directory: string): Promise<string | null> {\n try { return (await readFile(join(directory, 'appkit-cpu-signature'), 'utf8')).trim() }\n catch (error) { if ((error as NodeJS.ErrnoException).code === 'ENOENT') return null; throw error }\n}\nasync function writeSnapshotSignature(directory: string, signature: string): Promise<void> {\n await writeFile(join(directory, 'appkit-cpu-signature'), signature, { mode: 0o600 })\n}\n"]}
1
+ {"version":3,"file":"host.js","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACvF,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAEtD,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,GAMV,MAAM,QAAQ,CAAA;AACf,OAAO,EACL,sBAAsB,GAIvB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,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AC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAC5F,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC,CAAA;IACvD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IAC/C,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,yEAAyE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACpJ,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,sCAAsC,CAAC,CAAA;IAC1E,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC5D,CAAC;AACD,KAAK,UAAU,qBAAqB,CAAC,SAAiB;IACpD,IAAI,CAAC;QAAC,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,sBAAsB,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IAAC,CAAC;IACvF,OAAO,KAAK,EAAE,CAAC;QAAC,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QAAC,MAAM,KAAK,CAAA;IAAC,CAAC;AACpG,CAAC;AACD,KAAK,UAAU,sBAAsB,CAAC,SAAiB,EAAE,SAAiB;IACxE,MAAM,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,sBAAsB,CAAC,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;AACtF,CAAC","sourcesContent":["/**\n * The desk host: lifecycle, leases, and the screen service over a backend.\n *\n * One host manages many desks against one capacity budget. A desk is\n * headless by default; the screen is a service started on demand on the\n * machine the agent is already using. The host owns lease accounting (idle\n * suspend, a hard concurrency cap with a FIFO queue beyond it), event\n * emission to the consumer's ports, and the handover masking contract. It\n * never touches a database and knows nothing about tenants or approvals.\n */\nimport { createReadStream, existsSync } from 'node:fs'\nimport { execFile } from 'node:child_process'\nimport { mkdir, open, readFile, rename, rm, statfs, writeFile } from 'node:fs/promises'\nimport { arch, cpus, release, tmpdir } from 'node:os'\nimport { dirname, join } from 'node:path'\nimport { createHash, randomUUID } from 'node:crypto'\nimport { Buffer } from 'node:buffer'\nimport { connect as tcpConnect, isIP } from 'node:net'\nimport type { Duplex } from 'node:stream'\nimport {\n buildDeskLaunchPlan,\n cleanDeskId,\n DEFAULT_KVM_PATH,\n DEFAULT_VMM_PATH,\n DeskError,\n type DeskLauncherIdentity,\n type DeskGuestNetworkOptions,\n type DeskShare,\n type DeskReadOnlyAttachment,\n type DeskVirtiofsdSandbox,\n} from './plan'\nimport {\n cloudHypervisorBackend,\n type DeskBackend,\n type DeskConnectionChange,\n type DeskMachine,\n} from './backend'\nimport { readShareManifest } from './machine'\nimport {\n parseCapabilities,\n parseClipboardText,\n parseExecResult,\n parseHandoverBegun,\n parseJobStarted,\n parseObservation,\n type GuestEventMessage,\n type GuestInput,\n} from './protocol'\nimport type {\n A11yNode,\n DeskEventDetail,\n DeskEventKind,\n DeskFrameFormat,\n DeskHandoverEndReason,\n DeskHandoverScope,\n DeskPoint,\n DeskPointerButton,\n DeskPorts,\n DeskVideoChunkKind,\n WindowInfo,\n} from './events'\n\nexport const DEFAULT_CAPACITY = 4\nexport const DEFAULT_IDLE_SUSPEND_MS = 5 * 60_000\nexport const DEFAULT_LEASE_MS = 15 * 60_000\n/** The in-guest trim run before a desk suspends — see `trimGuest`. */\nexport const DEFAULT_TRIM_COMMAND = '/usr/sbin/fstrim'\nexport const DEFAULT_TRIM_ARGS: readonly string[] = ['/']\nexport const DEFAULT_TRIM_TIMEOUT_MS = 60_000\nexport const DEFAULT_CID_BASE = 100\nconst MAX_BUFFERED_FRAMES = 60\n/**\n * Video chunks a slow consumer may fall behind by before its stream is ended.\n * Larger than the frame bound because a fragment is a fraction of a frame's\n * bytes, and enforced by ENDING rather than by dropping — see the comment at\n * the overrun.\n */\nconst MAX_BUFFERED_VIDEO_CHUNKS = 600\nconst MIN_TIMER_DELAY_MS = 25\n\n/**\n * Event kinds that must never reach the recording port while a handover is\n * active. Human input and everything derived from watching the human act is\n * masked; only the handover boundaries themselves cross.\n */\nconst HANDOVER_MASKED_KINDS: ReadonlySet<DeskEventKind> = new Set([\n 'click',\n 'type',\n 'key',\n 'scroll',\n 'drag',\n 'window_focus',\n 'app_launch',\n])\n\nexport interface DeskHostOptions {\n /** Root of the golden base image and per-desk assets. */\n imageRoot: string\n vmmPath?: string\n kvmPath?: string\n /** Guest kernel; defaults to `<imageRoot>/vmlinux`. */\n kernelPath?: string\n /**\n * Initramfs the guest kernel boots with. A modular distro cloud kernel needs\n * one to mount root; omit only for a kernel with virtio/ext4 built in. When\n * unset it defaults to `<imageRoot>/initrd` if that file exists, else none.\n */\n initramfsPath?: string\n /**\n * Kernel command line every desk boots with. Defaults to\n * `DEFAULT_KERNEL_CMDLINE`; override it for partitioned cloud images whose\n * root is not `/dev/vda` (e.g. `root=/dev/vda3 rw quiet`).\n */\n kernelCmdline?: string\n /** Directory holding vsock and API control sockets. */\n runtimeDir?: string\n launcherIdentity?: DeskLauncherIdentity\n backend?: DeskBackend\n guestNetwork?: DeskGuestNetworkOptions\n /**\n * Cloud Hypervisor only: the `virtiofsd` (1.13 or later) behind each share.\n * Defaults to the first on `PATH`, then `/usr/libexec/virtiofsd`.\n */\n virtiofsdPath?: string\n /** Cloud Hypervisor only: how `virtiofsd` confines itself; defaults to `namespace`. */\n virtiofsdSandbox?: DeskVirtiofsdSandbox\n ports: DeskPorts\n /** Override TCP dialing for tests or a host-specific transport. */\n connectGuest?: (address: string, port: number) => Promise<Duplex>\n /** Hard cap on concurrently resident desks; starts beyond it queue FIFO. */\n capacity?: number\n idleSuspendMs?: number\n defaultLeaseMs?: number\n /** First guest vsock CID handed out; each boot takes the next one. */\n cidBase?: number\n now?: () => number\n pathExists?: (path: string) => boolean\n deviceExists?: (path: string) => boolean\n /** Whether a share's path is an existing directory; injectable for tests. */\n isDirectory?: (path: string) => boolean\n /**\n * Delete a destroyed desk's overlay. Injectable so the destroy path is\n * testable without a filesystem; defaults to `rm(path, { force: true })`.\n */\n removeOverlay?: (path: string) => Promise<void>\n /**\n * Park a desk by snapshotting its memory instead of shutting it down, so\n * resuming continues the guest's process tree rather than cold booting it.\n *\n * Off by default, because turning it on is a real operational change and not\n * only a behavioural one: each parked desk holds a snapshot roughly the size\n * of its guest RAM on the overlay volume, and the backend must offer `park`.\n * A deployment opts in once it has sized for that.\n *\n * What it buys is the difference between a desk that is \"parked\" and one that\n * was switched off. Shutdown parking means nothing inside the guest survives\n * between runs: an agent that installs a daemon and believes it is watching\n * something continuously is wrong, and the cold boot on every scheduled\n * occurrence is indistinguishable, from inside the guest, from a failing host.\n */\n parkWithMemory?: boolean\n /** Opt in to Cloud Hypervisor copy-on-write snapshot restore. */\n memoryRestoreMode?: 'copyonwrite'\n /** Atomically retire a parked snapshot and sync its parent directory. */\n retireSnapshot?: (from: string, to: string) => Promise<void>\n /** Identifies the host CPU for conservative snapshot portability checks. */\n cpuSignature?: () => Promise<string>\n readSnapshotSignature?: (directory: string) => Promise<string | null>\n writeSnapshotSignature?: (directory: string, signature: string) => Promise<void>\n /**\n * The shares a parked desk was snapshotted with, which its restore uses in\n * place of the start options' shares. Defaults to the record the backend\n * writes beside the snapshot; a snapshot without one had no shares.\n */\n readSnapshotShares?: (directory: string) => Promise<readonly DeskShare[]>\n /** Create a snapshot directory; defaults to `mkdir(path, { recursive: true })`. */\n makeSnapshotDir?: (path: string) => Promise<void>\n /**\n * Destroy a snapshot; defaults to `rm(path, { recursive: true, force: true })`.\n *\n * Eager restore removes the snapshot while paused. Copy-on-write restore\n * removes its retired source only after the VMM exits.\n */\n removeSnapshot?: (path: string) => Promise<void>\n /**\n * Bytes that must remain free on the overlay filesystem AFTER admitting a\n * desk. A desk whose overlay cannot be grown fails deep inside the guest —\n * ENOSPC surfaces as a corrupt filesystem or a boot that hangs, which reads\n * as a product bug rather than as a full disk. Refusing the lease up front\n * turns that into one clear error. Zero disables the check.\n */\n minFreeBytes?: number\n /**\n * Free bytes on the filesystem holding `path`. Injectable for tests;\n * defaults to `statfs`.\n */\n freeBytes?: (path: string) => Promise<number>\n /**\n * Run `fstrim` in the guest just before it suspends, returning the blocks it\n * has freed to the host filesystem. On by default: an overlay that is never\n * trimmed only grows. Set false for a guest without the binary, or one whose\n * filesystem should never be discarded.\n */\n trimOnSuspend?: boolean\n /** The in-guest trim binary. */\n trimCommand?: string\n /** Arguments for the trim binary; defaults to trimming the guest root. */\n trimArgs?: readonly string[]\n /** Bound on the trim; a slow trim must not hold up a suspend indefinitely. */\n trimTimeoutMs?: number\n}\n\nexport interface DeskStartOptions {\n deskId: string\n /** Absolute path of the golden base image this desk boots from. */\n baseImage: string\n /** Optional kernel and initramfs for this desk; retain them with its disk. */\n kernelPath?: string\n initramfsPath?: string\n /** Absolute path of this desk's copy-on-write overlay. */\n overlayPath: string\n memoryMb?: number\n /** Enable Cloud Hypervisor free-page reporting on cold boot. */\n freePageReporting?: boolean\n vcpus?: number\n leaseMs?: number\n network?: { tapDevice?: string; macAddress?: string; guestAddress?: string }\n /**\n * Host directories shared into the guest over virtio-fs. A desk parked with\n * memory is restored with the shares it was parked with, because a snapshot\n * holds its devices; these take effect on its next cold boot (see\n * `shutdown`). A parked share whose directory is gone makes the restore fail,\n * and the desk cold boots with these instead.\n */\n shares?: readonly DeskShare[]\n /** Immutable attachments; retain their path and contents while a snapshot exists. */\n readOnlyAttachments?: readonly DeskReadOnlyAttachment[]\n}\n\nexport interface DeskExecOptions {\n command: string\n args?: readonly string[]\n cwd?: string\n env?: Readonly<Record<string, string>>\n timeoutMs?: number\n /** Survive the call as a background job; the job dies with the lease. */\n keepAlive?: boolean\n}\n\nexport interface DeskExecSnapshot {\n deskId: string\n command: string\n args: readonly string[]\n exitCode: number | null\n signal: string | null\n stdout: string\n stderr: string\n truncated: boolean\n startedAt: string\n finishedAt: string\n}\n\nexport interface DeskJob {\n jobId: string\n deskId: string\n command: string\n args: readonly string[]\n startedAt: string\n status: 'running' | 'exited'\n exitCode: number | null\n signal: string | null\n}\n\nexport interface DeskObservation {\n png: Buffer\n width: number\n height: number\n a11y: A11yNode | null\n windows: readonly WindowInfo[]\n focused: WindowInfo | null\n}\n\nexport interface DeskFrame {\n seq: number\n width: number\n height: number\n data: Buffer\n /**\n * How `data` is encoded. A consumer must not assume PNG — it builds the\n * media type it hands on (a `data:` URL, a decoder) from this.\n */\n format: DeskFrameFormat\n at: string\n}\n\n/**\n * One unit of the live video stream: the init segment, or one media fragment.\n *\n * Video is deliberately NOT modelled as a kind of frame. A frame is a picture\n * that stands alone; a video chunk is meaningless without the init segment\n * before it and, for a media chunk, without the keyframe its group of pictures\n * began at. Pretending otherwise produces a consumer that appends bytes in any\n * order and renders black with no error to explain it.\n */\nexport interface DeskVideoChunk {\n seq: number\n kind: DeskVideoChunkKind\n /** RFC 6381, e.g. `avc1.42C020`. What a MediaSource must be told. */\n codec: string\n width: number\n height: number\n /** True when a `media` chunk begins at a sync sample. Always false on `init`. */\n keyframe: boolean\n data: Buffer\n at: string\n}\n\nexport interface DeskScreenInput {\n move(x: number, y: number): Promise<void>\n click(x: number, y: number, button?: DeskPointerButton, clicks?: 1 | 2): Promise<void>\n type(text: string): Promise<void>\n key(combo: string): Promise<void>\n scroll(x: number, y: number, dx: number, dy: number): Promise<void>\n drag(from: DeskPoint, to: DeskPoint): Promise<void>\n}\n\nexport interface DeskScreenHandle {\n observe(): Promise<DeskObservation>\n /**\n * Coordinate contract: all coordinates are in the pixel space of the most\n * recent view of the screen — an `observe()`, a frame from `frames()`, or a\n * chunk from `video()` — one to one. All three anchor it, because the caller\n * aims at whatever it was last shown, and a live viewer is shown a stream\n * rather than an observation. That holds whatever the encoding is: a lossy\n * frame and an H.264 fragment are both true-size views of the screen, so they\n * anchor exactly as a lossless PNG does. Input before any view, or outside\n * its bounds, throws.\n */\n input: DeskScreenInput\n a11y: { invoke(nodeId: string, action: string): Promise<void> }\n launch(appId: string, args?: readonly string[]): Promise<void>\n clipboard: { read(): Promise<string>; write(text: string): Promise<void> }\n /**\n * The live frame stream. `format` picks how the guest encodes each frame and\n * is a bytes-for-fidelity trade: `jpeg` is roughly an order of magnitude\n * smaller per frame, which is what a human driving the screen needs, while\n * `png` stays exact. Omitted leaves the choice to the guest. `observe()` is\n * unaffected and always lossless.\n *\n * The stream also ends when the desk reconnects to its guest agent: the\n * capture behind it did not survive, so the iterator completes rather than\n * waiting on frames that are never coming. Start another one to resume.\n */\n frames(options?: {\n fps?: number\n width?: number\n height?: number\n format?: DeskFrameFormat\n }): AsyncIterable<DeskFrame>\n /**\n * The live screen as encoded VIDEO rather than as a sequence of pictures.\n *\n * This is what a person driving the desk should watch. `frames()` ships a\n * whole independent image per tick; a video codec ships the DIFFERENCE, and a\n * desktop is mostly still — which is roughly two orders of magnitude fewer\n * bytes on the transport between the guest and here, the one place the live\n * view was actually bounded.\n *\n * The stream anchors the coordinate space exactly as `observe()` and\n * `frames()` do, from the first chunk onwards, because a viewer driving by\n * video is aiming at what the video showed it.\n *\n * Masked like frames: nothing is emitted while a handover is active. And\n * ended like frames when the desk reconnects to its guest agent — a video\n * consumer resumed on a fresh encoder, without its init segment and away\n * from a keyframe, decodes nothing at all and says so nowhere.\n */\n video(options?: {\n fps?: number\n width?: number\n height?: number\n }): AsyncIterable<DeskVideoChunk>\n handover: {\n begin(options: {\n ttlMs: number\n scope?: DeskHandoverScope\n actor?: string\n }): Promise<{ url: string }>\n end(): Promise<void>\n readonly active: boolean\n }\n}\n\nexport interface DeskScreenService {\n start(options: { width: number; height: number }): Promise<DeskScreenHandle>\n stop(): Promise<void>\n readonly running: boolean\n}\n\n/**\n * One leased desk.\n *\n * The handle stays valid across a lost guest connection: the host reconnects\n * underneath it and later calls work, so a guest agent restart or a dropped\n * vsock bridge no longer costs the rest of the lease. Two consequences a\n * caller must actually handle:\n *\n * - A call that was IN FLIGHT when the connection dropped rejects with\n * `DeskRequestFateUnknownError` — it may already have run in the guest.\n * Nothing retries it for you.\n * - A reconnect does not restore guest-side capture state. Live `frames()` and\n * `video()` iterators END, and the coordinate anchor is dropped, so the\n * caller must `observe()` (or take a new frame) before aiming again.\n *\n * When the connection cannot be recovered at all the desk is suspended, so the\n * handle goes dead and `resume()` boots a fresh one — rather than the handle\n * answering \"no longer connected\" for the rest of the lease.\n */\nexport interface DeskHandle {\n readonly deskId: string\n renewLease(ms: number): void\n /** Open a host-to-guest TCP stream; the caller owns and closes it. */\n connect(port: number, options?: { transport?: 'tcp' | 'vsock' }): Promise<Duplex>\n exec(options: DeskExecOptions & { keepAlive: true }): Promise<DeskJob>\n exec(options: DeskExecOptions): Promise<DeskExecSnapshot>\n /** The keepAlive processes still running on this desk. */\n jobs(): DeskJob[]\n screen: DeskScreenService\n}\n\nexport interface DeskHostStats {\n /** Desks currently resident (booted or booting) against the capacity cap. */\n resident: number\n /** Starts waiting in the FIFO queue for capacity. */\n queued: number\n capacity: number\n suspended: number\n lastStartedAt: string | null\n lastSuspendedAt: string | null\n /**\n * Times a resident desk lost its guest connection mid-lease and got it back.\n * One is a blip; a number that climbs is a desk FLAPPING — a guest agent\n * restarting in a loop, a failing vsock bridge — and that is the difference\n * between \"the desk is slow\" and a diagnosis.\n */\n reconnects: number\n lastReconnectAt: string | null\n /** Which desk reconnected last: enough to go and look at the right one. */\n lastReconnectDeskId: string | null\n lastError: string | null\n snapshotCpuFallbacks: number\n lastSnapshotCpuFallback: { deskId: string; at: string; reason: 'signature_mismatch' | 'incompatible_cpuid' } | null\n}\n\nexport interface DeskHost {\n start(options: DeskStartOptions): Promise<DeskHandle>\n /** True when this resident desk supports in-memory pause. */\n canPause(deskId: string): boolean\n /** Pause a resident desk; its lease and capacity remain in effect. */\n pause(deskId: string): Promise<void>\n /** Resume a paused resident desk or restore a suspended desk. */\n resume(deskId: string): Promise<DeskHandle>\n suspend(deskId: string): Promise<void>\n /**\n * Stop a desk WITHOUT its memory, keeping its overlay: the next `start` or\n * `resume` cold boots from disk. This is a restart, not a destroy — the disk\n * is the desk and stays exactly where it is. A resident desk is synced and\n * shut down rather than parked; a suspended desk's parked memory snapshot is\n * discarded. Unknown desks are a no-op.\n */\n shutdown(deskId: string): Promise<void>\n destroy(deskId: string): Promise<void>\n stats(): DeskHostStats\n /**\n * Enforce every time-based rule now: expire handovers past their TTL and\n * suspend desks past their lease or idle deadline. Returns the number of\n * desks suspended. Timers call this automatically; tests with an injected\n * clock call it directly.\n */\n sweep(): Promise<number>\n}\n\ninterface HandoverState {\n actor: string | null\n scope: DeskHandoverScope\n beganAt: number\n deadline: number\n}\n\ninterface ScreenState {\n running: boolean\n width: number\n height: number\n lastObservation: { width: number; height: number } | null\n lastFocusedId: string | null\n handover: HandoverState | null\n handle: DeskScreenHandle\n}\n\ninterface DeskRecord {\n deskId: string\n startOptions: DeskStartOptions\n status: 'resident' | 'suspending' | 'suspended'\n paused: boolean\n machine: DeskMachine | null\n epoch: number\n leaseDeadline: number\n lastActivityAt: number\n jobs: Map<string, DeskJob>\n screen: ScreenState | null\n unsubscribe: (() => void) | null\n unwatchConnection: (() => void) | null\n handle: DeskHandle | null\n timer: NodeJS.Timeout | null\n streamStops: Set<() => void>\n relayStops: Set<() => void>\n}\n\ninterface QueueEntry {\n run: () => Promise<DeskHandle>\n resolve: (handle: DeskHandle) => void\n reject: (error: Error) => void\n}\n\nexport function createDeskHost(options: DeskHostOptions): DeskHost {\n const ports = options.ports\n if (typeof ports?.onEvent !== 'function' || typeof ports?.audit !== 'function') {\n throw new DeskError('createDeskHost requires ports with onEvent and audit functions.')\n }\n const backend = options.backend ?? cloudHypervisorBackend\n const now = options.now ?? Date.now\n const pathExists = options.pathExists ?? existsSync\n const deviceExists = options.deviceExists ?? existsSync\n const removeOverlay = options.removeOverlay ?? ((path: string) => rm(path, { force: true }))\n const parkWithMemory = options.parkWithMemory ?? false\n if (options.memoryRestoreMode && (!parkWithMemory || backend.hypervisor === 'virtualization')) {\n throw new DeskError('Copy-on-write restore requires Cloud Hypervisor and parkWithMemory.')\n }\n const retireSnapshot = options.retireSnapshot ?? (async (from: string, to: string) => {\n await rename(from, to)\n const directory = await open(dirname(from), 'r')\n try { await directory.sync() } finally { await directory.close() }\n })\n const makeSnapshotDir = options.makeSnapshotDir ?? ((path: string) => mkdir(path, { recursive: true }).then(() => undefined))\n const removeSnapshot =\n options.removeSnapshot ?? ((path: string) => rm(path, { recursive: true, force: true }))\n const freeBytes = options.freeBytes ?? defaultFreeBytes\n const minFreeBytes = nonNegativeInteger(options.minFreeBytes ?? 0, 'minFreeBytes')\n const trimOnSuspend = options.trimOnSuspend ?? true\n const trimCommand = options.trimCommand ?? DEFAULT_TRIM_COMMAND\n const trimArgs = options.trimArgs ?? DEFAULT_TRIM_ARGS\n const trimTimeoutMs = positiveInteger(options.trimTimeoutMs ?? DEFAULT_TRIM_TIMEOUT_MS, 'trimTimeoutMs')\n const capacity = positiveInteger(options.capacity ?? DEFAULT_CAPACITY, 'capacity')\n const idleSuspendMs = positiveInteger(options.idleSuspendMs ?? DEFAULT_IDLE_SUSPEND_MS, 'idleSuspendMs')\n const defaultLeaseMs = positiveInteger(options.defaultLeaseMs ?? DEFAULT_LEASE_MS, 'defaultLeaseMs')\n const kernelPath = options.kernelPath ?? join(options.imageRoot, 'vmlinux')\n // Default the initramfs to <imageRoot>/initrd when present so a modular\n // cloud kernel boots without every caller having to name it; an explicit\n // option always wins.\n const defaultInitramfs = join(options.imageRoot, 'initrd')\n const resolveInitramfsPath = () =>\n options.initramfsPath ?? (pathExists(defaultInitramfs) ? defaultInitramfs : undefined)\n const kernelCmdline = options.kernelCmdline\n\n const records = new Map<string, DeskRecord>()\n /**\n * The last lifecycle transition scheduled for each desk. A desk may only\n * have one VMM child touching its overlay, so boot and teardown are ordered\n * on the desk identity rather than allowed to race through independent API\n * calls. The stored tail always resolves; callers still receive their own\n * operation's result or error.\n */\n const lifecycleTransitions = new Map<string, Promise<void>>()\n const queue: QueueEntry[] = []\n let occupied = 0\n let nextCid = positiveInteger(options.cidBase ?? DEFAULT_CID_BASE, 'cidBase')\n let lastStartedAt: string | null = null\n let lastSuspendedAt: string | null = null\n let lastError: string | null = null\n let snapshotCpuFallbacks = 0\n let lastSnapshotCpuFallback: DeskHostStats['lastSnapshotCpuFallback'] = null\n let reconnects = 0\n let lastReconnectAt: string | null = null\n let lastReconnectDeskId: string | null = null\n\n function iso(timestamp: number): string {\n return new Date(timestamp).toISOString()\n }\n\n function serializeLifecycle<T>(deskId: string, transition: () => Promise<T>): Promise<T> {\n const previous = lifecycleTransitions.get(deskId)\n // Preserve the host's existing synchronous admission semantics when this\n // desk has no transition in flight. Only conflicts need the promise tail;\n // unrelated starts must still appear in queue stats before `start` returns.\n const current = previous ? previous.then(transition, transition) : transition()\n const tail = current.then(\n () => undefined,\n () => undefined,\n )\n lifecycleTransitions.set(deskId, tail)\n return current.finally(() => {\n if (lifecycleTransitions.get(deskId) === tail) lifecycleTransitions.delete(deskId)\n })\n }\n\n function emit(record: DeskRecord, detail: DeskEventDetail): void {\n if (record.screen?.handover && HANDOVER_MASKED_KINDS.has(detail.kind)) return\n ports.onEvent({ ...detail, deskId: record.deskId, at: iso(now()) })\n }\n\n function touch(record: DeskRecord): void {\n record.lastActivityAt = now()\n }\n\n function requireMachine(record: DeskRecord, epoch: number): DeskMachine {\n if (record.status !== 'resident' || record.paused || record.epoch !== epoch || !record.machine) {\n throw new DeskError(`Desk ${record.deskId} is not resident; resume it first.`)\n }\n return record.machine\n }\n\n function requireScreen(record: DeskRecord, epoch: number): ScreenState {\n requireMachine(record, epoch)\n const screen = record.screen\n if (!screen?.running) {\n throw new DeskError(`Desk ${record.deskId} has no screen running; call screen.start first.`)\n }\n return screen\n }\n\n function assertCoordinates(record: DeskRecord, points: readonly DeskPoint[]): void {\n const observation = record.screen?.lastObservation\n if (!observation) {\n throw new DeskError(\n 'Coordinate input needs a frame of reference: call observe(), or start '\n + 'frames() and wait for one. Coordinates are the pixel space of the '\n + 'most recent of those, one to one.',\n )\n }\n for (const point of points) {\n if (\n !Number.isInteger(point.x)\n || !Number.isInteger(point.y)\n || point.x < 0\n || point.y < 0\n || point.x >= observation.width\n || point.y >= observation.height\n ) {\n throw new DeskError(\n `Coordinates (${point.x}, ${point.y}) are outside the most recent view `\n + `(${observation.width}x${observation.height}); observe() again before targeting.`,\n )\n }\n }\n }\n\n function armTimer(record: DeskRecord): void {\n if (record.timer) clearTimeout(record.timer)\n record.timer = null\n if (record.status !== 'resident') return\n const deadlines = [record.leaseDeadline, record.lastActivityAt + idleSuspendMs]\n const handover = record.screen?.handover\n if (handover) deadlines.push(handover.deadline)\n const delayMs = Math.max(Math.min(...deadlines) - now(), MIN_TIMER_DELAY_MS)\n record.timer = setTimeout(() => {\n sweep()\n .then(() => {\n if (record.status === 'resident') armTimer(record)\n })\n .catch((error: unknown) => {\n lastError = errorMessage(error)\n })\n }, delayMs)\n record.timer.unref()\n }\n\n async function endHandover(record: DeskRecord, reason: DeskHandoverEndReason): Promise<void> {\n const screen = record.screen\n const handover = screen?.handover\n if (!screen || !handover) return\n screen.handover = null\n if (record.machine) {\n try {\n await record.machine.request({ op: 'handover-end' })\n } catch (error) {\n lastError = errorMessage(error)\n }\n }\n const durationMs = Math.max(0, now() - handover.beganAt)\n emit(record, { kind: 'handover_end', actor: handover.actor, durationMs })\n ports.audit({\n kind: 'handover_end',\n deskId: record.deskId,\n actor: handover.actor,\n durationMs,\n reason,\n at: iso(now()),\n })\n }\n\n /**\n * Stop the machine and keep the disk. This is the SUSPEND half of the\n * lifecycle and it is shared by three callers — `suspend`, `sweep`, and\n * `destroy` — so it must never delete, truncate, or rewrite the overlay.\n *\n * That is not a stylistic preference. For a suspended desk the overlay IS\n * the desk: its home directory, its installed state, its half-written work.\n * A desk that comes back from suspend with a fresh disk has silently lost\n * everything, and the loss surfaces long after the code that caused it.\n * Reclaiming the disk is the exclusive business of `reclaimOverlay`, which\n * is called from exactly one place — `destroy` — where the caller has said\n * the desk should cease to exist.\n */\n /**\n * Hand the guest's freed blocks back to the host, as the last thing the\n * guest does before it stops.\n *\n * An overlay only ever GROWS otherwise. A block the guest writes is\n * allocated on the host filesystem forever; deleting the file inside the\n * guest frees it in the guest's own filesystem and tells the host nothing,\n * so a long-lived desk ratchets upward until the volume is full even though\n * the guest reports itself half empty. `fstrim` is what closes that loop:\n * it walks the guest filesystem's free space and issues discards, which\n * Cloud Hypervisor's virtio-blk turns into hole-punches on the raw overlay.\n *\n * Suspend is the right moment for it. The image's own `fstrim.timer` fires\n * WEEKLY, and a desk that idle-suspends after minutes is almost never up\n * when that lands — so on a leased-and-parked desk the scheduled trim\n * effectively never runs. Suspend, by contrast, is exactly when the guest\n * has stopped needing its scratch and the host wants the space back.\n *\n * This does not violate the disk contract on `teardown`. `fstrim` discards\n * only blocks the guest's filesystem already considers free; it cannot\n * remove a suspended desk's state, and a desk resumed afterwards sees an\n * identical filesystem. It is also strictly best-effort and bounded: a\n * guest that is wedged, disconnected, or lacks the binary must still\n * suspend promptly, so every failure here is swallowed into `lastError`.\n */\n async function trimGuest(record: DeskRecord, machine: DeskMachine): Promise<void> {\n if (!trimOnSuspend) return\n try {\n await machine.request({\n op: 'exec',\n command: trimCommand,\n args: trimArgs,\n timeoutMs: trimTimeoutMs,\n })\n } catch (error) {\n lastError = `Trim before suspend failed for ${record.deskId}: ${errorMessage(error)}`\n }\n }\n\n /**\n * Flush the guest's filesystem, immediately before it stops.\n *\n * Only needed when parking keeps memory. A snapshot always matches the disk it\n * was taken with, so the pair is consistent either way — but the disk ON ITS\n * OWN is not, and that is what remains every time a snapshot has to be\n * discarded. Without this, discarding one leaves a filesystem mid-transaction\n * and the next cold boot recovers a journal and loses the last writes. Best\n * effort and bounded: a guest too wedged to sync must still be parked.\n */\n async function syncGuest(record: DeskRecord, machine: DeskMachine): Promise<void> {\n try {\n await machine.request({ op: 'exec', command: 'sync', args: [], timeoutMs: trimTimeoutMs })\n } catch (error) {\n lastError = `Sync before park failed for ${record.deskId}: ${errorMessage(error)}`\n }\n }\n\n /** Where this desk's memory snapshot lives; must agree with the launch plan. */\n function snapshotDirFor(overlayPath: string, deskId: string): string {\n return join(dirname(overlayPath), `${deskId}.snapshot`)\n }\n\n async function teardown(record: DeskRecord, keepMemory = true): Promise<boolean> {\n if (record.status === 'suspending' && record.machine) {\n // A previous stop failed. Keep the overlay fenced until a retry confirms\n // the VMM has exited; never boot another VM or delete it underneath one.\n await record.machine.shutdown()\n await removeSnapshot(snapshotDirFor(record.startOptions.overlayPath, record.deskId))\n record.machine = null\n record.status = 'suspended'\n occupied -= 1\n lastSuspendedAt = iso(now())\n drainQueue()\n return true\n }\n if (record.status !== 'resident') return false\n // Resume before issuing trim, sync, or handover commands. On failure leave\n // the resident record intact and fenced so the caller can retry.\n if (record.paused) {\n await record.machine!.resume!()\n record.paused = false\n }\n await endHandover(record, 'revoked')\n for (const stop of [...record.streamStops]) stop()\n record.streamStops.clear()\n for (const stop of record.relayStops) stop()\n record.relayStops.clear()\n if (record.screen?.running) {\n record.screen.running = false\n emit(record, { kind: 'screen_close' })\n }\n record.screen = null\n for (const job of record.jobs.values()) {\n if (job.status !== 'running') continue\n job.status = 'exited'\n job.signal = 'SIGKILL'\n emit(record, { kind: 'job_exit', jobId: job.jobId, exitCode: null, signal: 'SIGKILL' })\n }\n record.unsubscribe?.()\n record.unsubscribe = null\n record.unwatchConnection?.()\n record.unwatchConnection = null\n if (record.timer) clearTimeout(record.timer)\n record.timer = null\n const machine = record.machine\n record.machine = null\n // Do not advertise this desk as suspended until its VMM child is actually\n // down. `serializeLifecycle` prevents a new boot from entering while this\n // transitional state still owns the overlay.\n record.status = 'suspending'\n record.handle = null\n if (machine) {\n await trimGuest(record, machine)\n // Flush the guest's filesystem before anything stops.\n //\n // A paused guest still holds dirty pages that exist only in its memory, so\n // a snapshot is consistent with the disk but the DISK ALONE is not — and\n // the disk alone is exactly what is left whenever a snapshot is discarded,\n // which happens on every failed restore. Syncing first makes discarding a\n // snapshot always safe instead of usually safe.\n const parking = keepMemory && parkWithMemory && typeof machine.park === 'function'\n // A shutdown that throws memory away leaves the disk as the only state, so\n // it is flushed exactly as a park is.\n if (parking || !keepMemory) await syncGuest(record, machine)\n try {\n if (parking) {\n const snapshotDir = snapshotDirFor(record.startOptions.overlayPath, record.deskId)\n await makeSnapshotDir(snapshotDir)\n // Persist attachment identity before the VMM can produce a complete\n // snapshot. A crash must never leave attached VM state with no record.\n if (record.startOptions.readOnlyAttachments?.length) {\n const manifest = join(snapshotDir, 'attachments.json')\n const file = await open(manifest, 'wx', 0o600)\n try {\n await file.writeFile(JSON.stringify(record.startOptions.readOnlyAttachments))\n await file.sync()\n } finally { await file.close() }\n const directory = await open(snapshotDir, 'r')\n try { await directory.sync() } finally { await directory.close() }\n }\n await machine.park!(snapshotDir)\n const signature = await (options.cpuSignature ?? hostCpuSignature)()\n await (options.writeSnapshotSignature ?? writeSnapshotSignature)(snapshotDir, signature)\n } else {\n await machine.shutdown()\n }\n } catch (error) {\n // Preparation can fail before park is called, so confirm the VMM is\n // down even when park itself normally stops on failure.\n lastError = errorMessage(error)\n try { await machine.shutdown() } catch (stopError) {\n record.machine = machine\n throw new DeskError(`Desk ${record.deskId} could not stop after teardown failed: ${errorMessage(stopError)}`)\n }\n if (parking) {\n await removeSnapshot(snapshotDirFor(record.startOptions.overlayPath, record.deskId)).catch(\n () => undefined,\n )\n }\n }\n }\n lastSuspendedAt = iso(now())\n occupied -= 1\n record.status = 'suspended'\n drainQueue()\n return true\n }\n\n function drainQueue(): void {\n while (occupied < capacity && queue.length > 0) {\n const entry = queue.shift()\n if (!entry) break\n occupied += 1\n entry.run().then(entry.resolve, (error: unknown) => {\n occupied -= 1\n entry.reject(error instanceof Error ? error : new Error(String(error)))\n drainQueue()\n })\n }\n }\n\n function admit(run: () => Promise<DeskHandle>): Promise<DeskHandle> {\n if (occupied < capacity) {\n occupied += 1\n return run().catch((error: unknown) => {\n occupied -= 1\n drainQueue()\n throw error\n })\n }\n return new Promise<DeskHandle>((resolvePromise, rejectPromise) => {\n queue.push({ run, resolve: resolvePromise, reject: rejectPromise })\n })\n }\n\n /**\n * Refuse a desk the overlay filesystem cannot afford. A reflink clone costs\n * almost nothing at creation and then grows as the guest writes, so the\n * moment that matters is not the `cp` — it is every write after it. Checking\n * headroom here converts a mid-boot ENOSPC, which the guest reports as a\n * corrupt disk or a hang, into one refusal naming the actual shortage.\n */\n async function admitDisk(overlayPath: string): Promise<void> {\n if (minFreeBytes <= 0) return\n let free: number\n try {\n free = await freeBytes(overlayPath)\n } catch (error) {\n // Fail OPEN on an unreadable filesystem: a desk refused because statfs\n // hiccuped is a worse outcome than one admitted onto a disk that turns\n // out to be full, which at least fails with a real disk error.\n lastError = `Free-space check failed for ${overlayPath}: ${errorMessage(error)}`\n return\n }\n if (free < minFreeBytes) {\n throw new DeskError(\n `Refusing to start a desk: the overlay filesystem holding ${overlayPath} has `\n + `${free} bytes free, below the ${minFreeBytes}-byte floor. Reclaim destroyed `\n + 'desks’ overlays or grow the volume before leasing another desk.',\n )\n }\n }\n\n async function boot(deskId: string, startOptions: DeskStartOptions): Promise<DeskHandle> {\n // Before the plan, so a full disk is reported as a full disk rather than\n // as whatever the overlay copy fails with.\n await admitDisk(startOptions.overlayPath)\n const snapshotDir = snapshotDirFor(startOptions.overlayPath, deskId)\n // The SAME cid for both attempts below. A restored VM's snapshotted config\n // names its vsock and tap, and a cold-boot retry that renumbered them would\n // come up on a different tap than the one the egress rules were put on.\n const cid = nextCid++\n const initramfsPath = startOptions.initramfsPath ?? resolveInitramfsPath()\n let restoreDir = snapshotDir\n const planFor = (restore: boolean, shares = startOptions.shares) =>\n buildDeskLaunchPlan(\n {\n deskId,\n hypervisor: backend.hypervisor ?? 'cloud-hypervisor',\n ...(backend.hypervisor === 'virtualization'\n ? { guestNetwork: options.guestNetwork }\n : { virtiofsdPath: options.virtiofsdPath, virtiofsdSandbox: options.virtiofsdSandbox }),\n vmmPath: options.vmmPath,\n kvmPath: options.kvmPath,\n kernelPath: startOptions.kernelPath ?? kernelPath,\n ...(initramfsPath === undefined ? {} : { initramfsPath }),\n baseImagePath: startOptions.baseImage,\n overlayPath: startOptions.overlayPath,\n memoryMb: startOptions.memoryMb,\n freePageReporting: startOptions.freePageReporting,\n vcpus: startOptions.vcpus,\n vsockCid: cid,\n runtimeDir: options.runtimeDir,\n tapDevice: startOptions.network?.tapDevice,\n macAddress: startOptions.network?.macAddress,\n shares,\n readOnlyAttachments: startOptions.readOnlyAttachments,\n // Forward the host's cmdline only when set; otherwise the plan falls\n // back to DEFAULT_KERNEL_CMDLINE.\n ...(kernelCmdline === undefined ? {} : { kernelCmdline }),\n launcherIdentity: options.launcherIdentity,\n snapshotDir: restore ? restoreDir : snapshotDir,\n ...(restore ? { restore: true as const, ...(options.memoryRestoreMode ? { memoryRestoreMode: options.memoryRestoreMode } : {}) } : {}),\n },\n { pathExists, deviceExists, ...(options.isDirectory ? { isDirectory: options.isDirectory } : {}) },\n )\n const restorePlan = async () => {\n const parked = await (options.readSnapshotShares ?? readShareManifest)(restoreDir)\n try {\n return planFor(true, parked)\n } catch (error) {\n throw new DeskError(`its restore, with the shares it was parked with, could not be planned: ${errorMessage(error)}`)\n }\n }\n\n // Verify bytes, not just the caller's label, before the VMM can map them.\n for (const image of startOptions.readOnlyAttachments ?? []) {\n const hash = createHash('sha256')\n for await (const chunk of createReadStream(image.path)) hash.update(chunk as Buffer)\n if (hash.digest('hex') !== image.sha256) throw new DeskError(`Read-only attachment digest mismatch: ${image.path}`)\n }\n let resuming = parkWithMemory && pathExists(snapshotDir)\n // Shared guest memory, required by virtio-fs, makes Cloud Hypervisor fall\n // back to eager restore. Reject before retiring the snapshot or cold booting.\n if (options.memoryRestoreMode === 'copyonwrite') {\n if (startOptions.shares?.length) throw new DeskError('Copy-on-write restore cannot be combined with virtio-fs shares.')\n if (resuming && (await (options.readSnapshotShares ?? readShareManifest)(snapshotDir)).length) {\n throw new DeskError('The parked snapshot has virtio-fs shares and cannot use copy-on-write restore.')\n }\n }\n if (resuming) {\n let savedAttachments: unknown\n try { savedAttachments = JSON.parse(await readFile(join(snapshotDir, 'attachments.json'), 'utf8')) }\n catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error\n savedAttachments = []\n }\n if (JSON.stringify(savedAttachments) !== JSON.stringify(startOptions.readOnlyAttachments ?? [])) {\n throw new DeskError('Snapshot read-only attachment identity does not match; restore requires the original images.')\n }\n const saved = await (options.readSnapshotSignature ?? readSnapshotSignature)(snapshotDir)\n if (saved !== null && saved !== await (options.cpuSignature ?? hostCpuSignature)()) {\n await removeSnapshot(snapshotDir)\n resuming = false\n recordCpuFallback(deskId, 'signature_mismatch')\n }\n }\n // Retire before starting the VMM: after a crash the old name can never be\n // replayed against a disk the guest may have changed. The retired file is\n // private backing memory, not a restorable snapshot.\n if (resuming && options.memoryRestoreMode === 'copyonwrite') {\n restoreDir = `${snapshotDir}.source-${randomUUID()}`\n await retireSnapshot(snapshotDir, restoreDir)\n }\n let machine: DeskMachine\n try {\n machine = resuming\n ? await backend.boot(await restorePlan(), {\n // Eager restore removes the parked snapshot before resume. A CoW\n // source was already retired durably before the VMM started.\n onRestored: options.memoryRestoreMode === 'copyonwrite' ? async () => {} : () => removeSnapshot(snapshotDir),\n })\n : await backend.boot(planFor(false))\n } catch (error) {\n if (resuming) {\n // A snapshot that will not come back is worse than no snapshot: it makes\n // the desk unbootable for as long as it sits there. Drop it and cold\n // boot. Safe by construction — the guest never ran, so the disk is\n // exactly as the pre-park sync left it.\n const why = errorMessage(error)\n resuming = false\n await removeSnapshot(snapshotDir)\n if (isIncompatibleCpuSnapshotError(error)) recordCpuFallback(deskId, 'incompatible_cpuid')\n else lastError = `Desk ${deskId} could not resume from its snapshot and was cold booted: ${why}`\n // Falls through to the shared record path below with a cold machine.\n machine = await backend.boot(planFor(false))\n } else {\n lastError = errorMessage(error)\n throw error instanceof DeskError\n ? error\n : new DeskError(`Desk ${deskId} failed to boot: ${errorMessage(error)}`)\n }\n }\n\n if (resuming && options.memoryRestoreMode === 'copyonwrite') {\n // The mapping remains file-backed until the VMM has exited. Never remove\n // it after a failed stop; leaking it is safer than invalidating a live VM.\n const restored = machine\n const stop = restored.shutdown.bind(restored)\n const park = restored.park?.bind(restored)\n const releaseSource = async () => {\n try { await removeSnapshot(restoreDir) } catch (error) {\n lastError = `Snapshot source cleanup failed for ${deskId}: ${errorMessage(error)}`\n }\n }\n restored.shutdown = async () => { await stop(); await releaseSource() }\n if (park) restored.park = async (dir) => { await park(dir); await releaseSource() }\n }\n\n let record = records.get(deskId)\n if (!record) {\n record = {\n deskId,\n startOptions,\n status: 'resident',\n paused: false,\n machine,\n epoch: 1,\n leaseDeadline: 0,\n lastActivityAt: 0,\n jobs: new Map(),\n screen: null,\n unsubscribe: null,\n unwatchConnection: null,\n handle: null,\n timer: null,\n streamStops: new Set(),\n relayStops: new Set(),\n }\n records.set(deskId, record)\n } else {\n record.startOptions = startOptions\n record.status = 'resident'\n record.paused = false\n record.machine = machine\n record.epoch += 1\n record.jobs = new Map()\n record.screen = null\n record.streamStops = new Set()\n record.relayStops = new Set()\n }\n const current = record\n const epoch = current.epoch\n current.leaseDeadline = now() + positiveInteger(startOptions.leaseMs ?? defaultLeaseMs, 'leaseMs')\n current.lastActivityAt = now()\n current.unsubscribe = machine.subscribe((event) => {\n handleGuestEvent(current, epoch, event)\n })\n current.unwatchConnection =\n machine.onConnectionChange?.((change) => {\n handleConnectionChange(current, epoch, change)\n }) ?? null\n current.handle = makeHandle(current, epoch)\n lastStartedAt = iso(now())\n armTimer(current)\n return current.handle\n }\n\n function handleGuestEvent(record: DeskRecord, epoch: number, event: GuestEventMessage): void {\n if (record.status !== 'resident' || record.epoch !== epoch) return\n if (event.event === 'job-exit') {\n const job = record.jobs.get(event.jobId)\n if (!job || job.status !== 'running') return\n job.status = 'exited'\n job.exitCode = event.exitCode\n job.signal = event.signal\n emit(record, {\n kind: 'job_exit',\n jobId: event.jobId,\n exitCode: event.exitCode,\n signal: event.signal,\n })\n return\n }\n if (event.event === 'window-focus') {\n if (record.screen) record.screen.lastFocusedId = event.window.id\n emit(record, { kind: 'window_focus', window: event.window })\n }\n }\n\n /**\n * What a desk losing (and regaining) its guest channel means up here.\n *\n * The backend can get the CHANNEL back; it cannot get the GUEST's state\n * back, and pretending otherwise is how a consumer ends up waiting forever\n * on a stream that will never produce another byte. So a reconnect is\n * treated as a discontinuity that the caller is able to see, and a\n * permanent loss retires the desk instead of leaving a dead one leased.\n */\n function handleConnectionChange(\n record: DeskRecord,\n epoch: number,\n change: DeskConnectionChange,\n ): void {\n if (record.status !== 'resident' || record.epoch !== epoch) return\n if (change.state === 'reconnected') {\n reconnects += 1\n lastReconnectAt = iso(now())\n lastReconnectDeskId = record.deskId\n // Never silent. A reconnect that hides a guest agent restarting is a\n // debugging trap: the desk misbehaves and nothing anywhere says why.\n lastError = `Desk ${record.deskId} reconnected to its guest agent after ${change.downtimeMs}ms (${change.reason}).`\n // The guest's capture state did not necessarily come back with the\n // channel. An agent that restarted has no screen, no frame encoder and\n // no video encoder; even one that survived starts a fresh encoder whose\n // sequence numbers and init segment do not continue the old stream. A\n // consumer resumed mid-stream decodes nothing, silently — so every live\n // stream is ENDED. `frames()`/`video()` complete normally, which is how\n // the consumer notices, and it can start a new one on a guest that is\n // now definitely capturing.\n for (const stop of [...record.streamStops]) stop()\n record.streamStops.clear()\n // The coordinate anchor goes with them: the screen behind it may be\n // gone, or recreated at another size, and a click aimed at the pixel\n // space of a screen that no longer exists lands somewhere nobody chose.\n // Input then refuses until the caller observes again — the existing\n // contract, not a new one.\n if (record.screen) {\n record.screen.lastObservation = null\n // The reconnected channel proves the machine is alive, not that the\n // guest compositor survived. Treat the screen as needing an explicit\n // restart so screen.start() reaches the guest instead of returning the\n // stale handle forever. Keep ScreenState itself so an active handover\n // remains masked in the safe direction until its explicit/TTL end.\n record.screen.running = false\n }\n // A handover is deliberately NOT ended here. If a human is still on that\n // screen, dropping the mask would start recording them; letting the TTL\n // expire it fails in the safe direction.\n return\n }\n // Lost for good. Left resident, this desk would answer every call with\n // \"no longer connected\" for the rest of the lease and `resume()` would\n // hand back the same dead handle — the exact product failure this release\n // is about. Suspending it frees the capacity slot and makes the next\n // `resume()` boot a healthy desk.\n lastError = change.reason\n void serializeLifecycle(record.deskId, async () => {\n // The loss belongs to the epoch that registered this watcher. If an\n // earlier queued transition already replaced that machine, this stale\n // signal must not retire the fresh resident.\n if (record.status !== 'resident' || record.epoch !== epoch) return\n await teardown(record)\n }).catch((error: unknown) => {\n lastError = errorMessage(error)\n })\n }\n\n function makeHandle(record: DeskRecord, epoch: number): DeskHandle {\n const execImplementation = async (\n execOptions: DeskExecOptions,\n ): Promise<DeskExecSnapshot | DeskJob> => {\n const machine = requireMachine(record, epoch)\n const command = nonEmptyString(execOptions.command, 'command')\n const args = [...(execOptions.args ?? [])]\n const keepAlive = execOptions.keepAlive === true\n if (ports.policy?.allowExec && !ports.policy.allowExec({\n deskId: record.deskId,\n command,\n args,\n keepAlive,\n })) {\n throw new DeskError(`Policy denied exec of ${command} on desk ${record.deskId}.`)\n }\n touch(record)\n const startedAt = iso(now())\n if (keepAlive) {\n const { jobId } = parseJobStarted(await machine.request({\n op: 'job-start',\n command,\n args,\n cwd: execOptions.cwd,\n env: execOptions.env,\n }))\n const job: DeskJob = {\n jobId,\n deskId: record.deskId,\n command,\n args,\n startedAt,\n status: 'running',\n exitCode: null,\n signal: null,\n }\n record.jobs.set(jobId, job)\n emit(record, { kind: 'job_start', jobId, command, args })\n return { ...job }\n }\n const result = parseExecResult(await machine.request(\n {\n op: 'exec',\n command,\n args,\n cwd: execOptions.cwd,\n env: execOptions.env,\n timeoutMs: execOptions.timeoutMs,\n },\n execOptions.timeoutMs === undefined ? {} : { timeoutMs: execOptions.timeoutMs + 5_000 },\n ))\n emit(record, {\n kind: 'shell_command',\n command,\n args,\n cwd: execOptions.cwd ?? null,\n exitCode: result.exitCode,\n signal: result.signal,\n })\n return {\n deskId: record.deskId,\n command,\n args,\n exitCode: result.exitCode,\n signal: result.signal,\n stdout: result.stdout,\n stderr: result.stderr,\n truncated: result.truncated,\n startedAt,\n finishedAt: iso(now()),\n }\n }\n\n const screenService: DeskScreenService = {\n async start({ width, height }) {\n const machine = requireMachine(record, epoch)\n if (record.screen?.running) return record.screen.handle\n const cleanWidth = positiveInteger(width, 'width')\n const cleanHeight = positiveInteger(height, 'height')\n if (ports.policy?.allowScreen && !ports.policy.allowScreen({\n deskId: record.deskId,\n width: cleanWidth,\n height: cleanHeight,\n })) {\n throw new DeskError(`Policy denied opening a screen on desk ${record.deskId}.`)\n }\n touch(record)\n await machine.request({ op: 'screen-start', width: cleanWidth, height: cleanHeight })\n const existing = record.screen\n if (existing) {\n // A guest-agent reconnect invalidates what the host knew about the\n // compositor without necessarily ending an active handover. Reuse\n // the same handle so existing consumers can recover, and retain the\n // handover mask until its explicit/TTL end rather than briefly\n // exposing a human's private input while the screen restarts.\n existing.running = true\n existing.width = cleanWidth\n existing.height = cleanHeight\n existing.lastObservation = null\n existing.lastFocusedId = null\n emit(record, { kind: 'screen_open', width: cleanWidth, height: cleanHeight })\n return existing.handle\n }\n const handle = makeScreenHandle(record, epoch)\n record.screen = {\n running: true,\n width: cleanWidth,\n height: cleanHeight,\n lastObservation: null,\n lastFocusedId: null,\n handover: null,\n handle,\n }\n emit(record, { kind: 'screen_open', width: cleanWidth, height: cleanHeight })\n return handle\n },\n async stop() {\n const machine = requireMachine(record, epoch)\n const screen = record.screen\n if (!screen?.running) return\n await endHandover(record, 'revoked')\n for (const stop of [...record.streamStops]) stop()\n record.streamStops.clear()\n screen.running = false\n record.screen = null\n touch(record)\n await machine.request({ op: 'screen-stop' })\n emit(record, { kind: 'screen_close' })\n },\n get running() {\n return record.screen?.running === true\n },\n }\n\n return {\n deskId: record.deskId,\n renewLease(ms: number): void {\n // Renewing a lease is host-side and remains valid during resident pause.\n if (record.status !== 'resident' || record.epoch !== epoch || !record.machine) {\n throw new DeskError(`Desk ${record.deskId} is not resident; resume it first.`)\n }\n record.leaseDeadline = now() + positiveInteger(ms, 'ms')\n touch(record)\n armTimer(record)\n },\n async connect(port: number, choice?: { transport?: 'tcp' | 'vsock' }): Promise<Duplex> {\n requireMachine(record, epoch)\n if (!Number.isInteger(port) || port < 1 || port > 65535) throw new DeskError('Guest TCP port must be between 1 and 65535.')\n const machine = requireMachine(record, epoch)\n const address = record.startOptions.network?.guestAddress\n const useVsock = choice?.transport === 'vsock' || (choice?.transport !== 'tcp' && !!machine.connect)\n if (useVsock && !machine.connect) throw new DeskError('This backend has no service vsock connector.')\n if (!useVsock && (!address || isIP(address) !== 4)) throw new DeskError('A guest IPv4 address is required to connect to a desk port.')\n touch(record)\n try {\n const stream = useVsock ? await machine.connect!(port) : await (options.connectGuest ?? connectGuestTcp)(address!, port)\n try { requireMachine(record, epoch) } catch (error) { stream.destroy(); throw error }\n const stop = () => stream.destroy()\n record.relayStops.add(stop)\n stream.once('close', () => record.relayStops.delete(stop))\n return stream\n } catch (error) { throw new DeskError(`Cannot connect to guest ${address}:${port}: ${errorMessage(error)}`) }\n },\n exec: execImplementation as DeskHandle['exec'],\n jobs(): DeskJob[] {\n return [...record.jobs.values()]\n .filter((job) => job.status === 'running')\n .map((job) => ({ ...job }))\n },\n screen: screenService,\n }\n }\n\n function makeScreenHandle(record: DeskRecord, epoch: number): DeskScreenHandle {\n async function sendInput(detail: DeskEventDetail | null, input: GuestInput): Promise<void> {\n const machine = requireMachine(record, epoch)\n touch(record)\n await machine.request({ op: 'input', input })\n if (detail) emit(record, detail)\n }\n\n return {\n async observe(): Promise<DeskObservation> {\n const machine = requireMachine(record, epoch)\n const screen = requireScreen(record, epoch)\n touch(record)\n const observation = parseObservation(await machine.request({ op: 'observe' }))\n screen.lastObservation = { width: observation.width, height: observation.height }\n if (observation.focused && observation.focused.id !== screen.lastFocusedId) {\n screen.lastFocusedId = observation.focused.id\n emit(record, { kind: 'window_focus', window: observation.focused })\n }\n return {\n png: Buffer.from(observation.png, 'base64'),\n width: observation.width,\n height: observation.height,\n a11y: observation.a11y,\n windows: observation.windows,\n focused: observation.focused,\n }\n },\n input: {\n async move(x, y) {\n requireScreen(record, epoch)\n assertCoordinates(record, [{ x, y }])\n await sendInput(null, { type: 'move', x, y })\n },\n async click(x, y, button = 'left', clicks = 1) {\n requireScreen(record, epoch)\n assertCoordinates(record, [{ x, y }])\n if (clicks !== 1 && clicks !== 2) throw new DeskError('clicks must be 1 or 2.')\n await sendInput({ kind: 'click', x, y, button, clicks }, { type: 'click', x, y, button, clicks })\n },\n async type(text) {\n requireScreen(record, epoch)\n const cleanText = requireStringValue(text, 'text')\n await sendInput({ kind: 'type', text: cleanText }, { type: 'type', text: cleanText })\n },\n async key(combo) {\n requireScreen(record, epoch)\n const cleanCombo = nonEmptyString(combo, 'combo')\n await sendInput({ kind: 'key', combo: cleanCombo }, { type: 'key', combo: cleanCombo })\n },\n async scroll(x, y, dx, dy) {\n requireScreen(record, epoch)\n assertCoordinates(record, [{ x, y }])\n if (!Number.isInteger(dx) || !Number.isInteger(dy)) {\n throw new DeskError('Scroll deltas must be integers.')\n }\n await sendInput({ kind: 'scroll', x, y, dx, dy }, { type: 'scroll', x, y, dx, dy })\n },\n async drag(from, to) {\n requireScreen(record, epoch)\n assertCoordinates(record, [from, to])\n await sendInput({ kind: 'drag', from, to }, { type: 'drag', from, to })\n },\n },\n a11y: {\n async invoke(nodeId, action) {\n const machine = requireMachine(record, epoch)\n requireScreen(record, epoch)\n touch(record)\n await machine.request({\n op: 'a11y-invoke',\n nodeId: nonEmptyString(nodeId, 'nodeId'),\n action: nonEmptyString(action, 'action'),\n })\n },\n },\n async launch(appId, args = []) {\n const machine = requireMachine(record, epoch)\n requireScreen(record, epoch)\n touch(record)\n const cleanAppId = nonEmptyString(appId, 'appId')\n await machine.request({ op: 'launch', appId: cleanAppId, args: [...args] })\n emit(record, { kind: 'app_launch', appId: cleanAppId, args: [...args] })\n },\n clipboard: {\n async read() {\n const machine = requireMachine(record, epoch)\n const screen = requireScreen(record, epoch)\n if (screen.handover) {\n // The human may have just typed a credential that is now on the\n // clipboard; reading it during a handover would carry it into the\n // agent's context and the consumer's record.\n throw new DeskError('The clipboard is masked while a handover is active.')\n }\n touch(record)\n return parseClipboardText(await machine.request({ op: 'clipboard-read' }))\n },\n async write(text) {\n const machine = requireMachine(record, epoch)\n requireScreen(record, epoch)\n touch(record)\n await machine.request({ op: 'clipboard-write', text: requireStringValue(text, 'text') })\n },\n },\n frames(frameOptions = {}) {\n return {\n [Symbol.asyncIterator]: () => {\n const machine = requireMachine(record, epoch)\n const screen = requireScreen(record, epoch)\n const fps = positiveInteger(frameOptions.fps ?? 10, 'fps')\n const width = positiveInteger(frameOptions.width ?? screen.width, 'width')\n const height = positiveInteger(frameOptions.height ?? screen.height, 'height')\n const format = frameOptions.format\n const buffered: DeskFrame[] = []\n let waiting: ((result: IteratorResult<DeskFrame, undefined>) => void) | null = null\n let finished = false\n const unsubscribe = machine.subscribe((event) => {\n if (finished || event.event !== 'frame') return\n // Masking contract: no frame reaches a recording consumer while\n // a handover is active.\n if (record.screen?.handover) return\n const frame: DeskFrame = {\n seq: event.seq,\n width: event.width,\n height: event.height,\n data: Buffer.from(event.data, 'base64'),\n format: event.format,\n at: iso(now()),\n }\n // A frame anchors coordinates exactly as an observation does.\n // The contract is that a click lands in the pixel space of the\n // most recent thing the caller was SHOWN, and a live view is\n // shown the frame stream, not observe(). Without this a viewer\n // that watches frames and clicks what it sees is refused for\n // never having called observe() — technically true and useless.\n if (record.screen) {\n record.screen.lastObservation = { width: frame.width, height: frame.height }\n }\n if (waiting) {\n const resume = waiting\n waiting = null\n resume({ value: frame, done: false })\n } else {\n buffered.push(frame)\n if (buffered.length > MAX_BUFFERED_FRAMES) buffered.shift()\n }\n })\n const finish = (): void => {\n if (finished) return\n finished = true\n unsubscribe()\n record.streamStops.delete(finish)\n if (record.status === 'resident' && record.machine) {\n record.machine.request({ op: 'frames-stop' }).catch((error: unknown) => {\n lastError = errorMessage(error)\n })\n }\n if (waiting) {\n const resume = waiting\n waiting = null\n resume({ value: undefined, done: true })\n }\n }\n record.streamStops.add(finish)\n const started = machine\n .request({ op: 'frames-start', fps, width, height, format })\n .catch((error: unknown) => {\n finish()\n throw error instanceof Error ? error : new Error(String(error))\n })\n return {\n async next(): Promise<IteratorResult<DeskFrame, undefined>> {\n await started\n const bufferedFrame = buffered.shift()\n if (bufferedFrame) return { value: bufferedFrame, done: false }\n if (finished) return { value: undefined, done: true }\n return new Promise((resolvePromise) => {\n waiting = resolvePromise\n })\n },\n async return(): Promise<IteratorResult<DeskFrame, undefined>> {\n finish()\n return { value: undefined, done: true }\n },\n async throw(error?: unknown): Promise<IteratorResult<DeskFrame, undefined>> {\n finish()\n throw error instanceof Error ? error : new Error(String(error))\n },\n }\n },\n }\n },\n video(videoOptions = {}) {\n return {\n [Symbol.asyncIterator]: () => {\n const machine = requireMachine(record, epoch)\n const screen = requireScreen(record, epoch)\n const fps = positiveInteger(videoOptions.fps ?? 30, 'fps')\n const width = positiveInteger(videoOptions.width ?? screen.width, 'width')\n const height = positiveInteger(videoOptions.height ?? screen.height, 'height')\n const buffered: DeskVideoChunk[] = []\n let waiting: ((result: IteratorResult<DeskVideoChunk, undefined>) => void) | null = null\n let finished = false\n const unsubscribe = machine.subscribe((event) => {\n if (finished || event.event !== 'video-chunk') return\n // The same masking contract frames are held to: while a handover\n // is active a person is on that screen, and nothing derived from\n // watching them may reach a recording consumer.\n if (record.screen?.handover) return\n const chunk: DeskVideoChunk = {\n seq: event.seq,\n kind: event.kind,\n codec: event.codec,\n width: event.width,\n height: event.height,\n keyframe: event.keyframe,\n data: Buffer.from(event.data, 'base64'),\n at: iso(now()),\n }\n // A video chunk anchors coordinates exactly as a frame does, and\n // for the same reason: a viewer driving by video is aiming at the\n // pixel space the video showed it. Anchoring on every chunk, not\n // only the first, is what re-asserts the space when the encoder\n // restarts at a new resolution.\n if (record.screen) {\n record.screen.lastObservation = { width: chunk.width, height: chunk.height }\n }\n if (waiting) {\n const resume = waiting\n waiting = null\n resume({ value: chunk, done: false })\n } else {\n buffered.push(chunk)\n // Dropping the OLDEST would drop the init segment, and a\n // consumer without it decodes nothing at all — so an overrun\n // ends the stream instead. A caller that cannot keep up with a\n // video stream is one that should re-subscribe and be resynced\n // from a keyframe, not one that should be handed a hole.\n if (buffered.length > MAX_BUFFERED_VIDEO_CHUNKS) finish()\n }\n })\n const finish = (): void => {\n if (finished) return\n finished = true\n unsubscribe()\n record.streamStops.delete(finish)\n if (record.status === 'resident' && record.machine) {\n record.machine.request({ op: 'video-stop' }).catch((error: unknown) => {\n lastError = errorMessage(error)\n })\n }\n if (waiting) {\n const resume = waiting\n waiting = null\n resume({ value: undefined, done: true })\n }\n }\n record.streamStops.add(finish)\n const started = machine\n .request({ op: 'video-start', fps, width, height })\n .catch((error: unknown) => {\n finish()\n throw error instanceof Error ? error : new Error(String(error))\n })\n return {\n async next(): Promise<IteratorResult<DeskVideoChunk, undefined>> {\n await started\n const bufferedChunk = buffered.shift()\n if (bufferedChunk) return { value: bufferedChunk, done: false }\n if (finished) return { value: undefined, done: true }\n return new Promise((resolvePromise) => {\n waiting = resolvePromise\n })\n },\n async return(): Promise<IteratorResult<DeskVideoChunk, undefined>> {\n finish()\n return { value: undefined, done: true }\n },\n async throw(error?: unknown): Promise<IteratorResult<DeskVideoChunk, undefined>> {\n finish()\n throw error instanceof Error ? error : new Error(String(error))\n },\n }\n },\n }\n },\n handover: {\n async begin({ ttlMs, scope = 'control', actor }) {\n const machine = requireMachine(record, epoch)\n const screen = requireScreen(record, epoch)\n if (screen.handover) {\n throw new DeskError(`A handover is already active on desk ${record.deskId}.`)\n }\n const cleanTtl = positiveInteger(ttlMs, 'ttlMs')\n if (ports.policy?.allowHandover && !ports.policy.allowHandover({\n deskId: record.deskId,\n scope,\n ttlMs: cleanTtl,\n })) {\n throw new DeskError(`Policy denied a handover on desk ${record.deskId}.`)\n }\n touch(record)\n const begun = parseHandoverBegun(\n await machine.request({ op: 'handover-begin', ttlMs: cleanTtl, scope }),\n )\n const startedAt = now()\n screen.handover = {\n actor: actor ?? null,\n scope,\n beganAt: startedAt,\n deadline: startedAt + cleanTtl,\n }\n // The boundary events are the one thing that crosses the mask.\n emit(record, { kind: 'handover_begin', actor: actor ?? null, scope })\n ports.audit({\n kind: 'handover_begin',\n deskId: record.deskId,\n actor: actor ?? null,\n scope,\n ttlMs: cleanTtl,\n at: iso(startedAt),\n })\n armTimer(record)\n return { url: begun.url }\n },\n async end() {\n requireMachine(record, epoch)\n await endHandover(record, 'ended')\n },\n get active() {\n return record.screen?.handover != null\n },\n },\n }\n }\n\n async function start(startOptions: DeskStartOptions): Promise<DeskHandle> {\n const deskId = cleanDeskId(startOptions.deskId)\n return serializeLifecycle(deskId, async () => {\n const existing = records.get(deskId)\n if (existing?.status === 'suspending') throw new DeskError(`Desk ${deskId} has not stopped; retry suspend first.`)\n if (existing?.status === 'resident' && existing.handle) {\n if (existing.paused) { await existing.machine!.resume!(); existing.paused = false }\n return existing.handle\n }\n return admit(() => boot(deskId, { ...startOptions, deskId }))\n })\n }\n\n function canPause(deskId: string): boolean {\n const record = records.get(cleanDeskId(deskId))\n return record?.status === 'resident' && typeof record.machine?.pause === 'function' && typeof record.machine?.resume === 'function'\n }\n\n async function pause(deskId: string): Promise<void> {\n const id = cleanDeskId(deskId)\n await serializeLifecycle(id, async () => {\n const record = records.get(id)\n if (!record || record.status !== 'resident' || !canPause(id)) throw new DeskError(`Desk ${id} cannot be paused.`)\n if (record.paused) return\n if (record.screen?.handover) throw new DeskError(`Desk ${id} has an active handover.`)\n record.paused = true\n await record.machine!.pause!()\n })\n }\n\n async function resume(deskId: string): Promise<DeskHandle> {\n const id = cleanDeskId(deskId)\n return serializeLifecycle(id, async () => {\n const record = records.get(id)\n if (!record) throw new DeskError(`Unknown desk: ${deskId}`)\n if (record.status === 'suspending') throw new DeskError(`Desk ${id} has not stopped; retry suspend first.`)\n if (record.status === 'resident' && record.handle) {\n if (record.paused) { await record.machine!.resume!(); record.paused = false }\n return record.handle\n }\n return admit(() => boot(record.deskId, record.startOptions))\n })\n }\n\n async function suspend(deskId: string): Promise<void> {\n const id = cleanDeskId(deskId)\n await serializeLifecycle(id, async () => {\n const record = records.get(id)\n if (!record) return\n await teardown(record)\n })\n }\n\n async function shutdown(deskId: string): Promise<void> {\n const id = cleanDeskId(deskId)\n await serializeLifecycle(id, async () => {\n const record = records.get(id)\n if (!record) return\n await teardown(record, false)\n // A desk parked earlier still has its memory image on disk; dropping it is\n // what makes the next boot cold. The overlay is untouched — only `destroy`\n // may remove it.\n await removeSnapshot(snapshotDirFor(record.startOptions.overlayPath, record.deskId))\n })\n }\n\n /**\n * Delete a desk's overlay. The ONLY place in this module that removes a\n * desk's disk, and it is reachable from `destroy` alone — see the contract\n * on `teardown` for why suspend must never come near it.\n *\n * The record is dropped whether or not the unlink succeeds: a desk the\n * caller has destroyed must not stay leaseable because its file was busy.\n * A failed unlink is surfaced through `lastError` and leaves the file for\n * the reaper rather than being retried here.\n */\n async function reclaimOverlay(record: DeskRecord): Promise<void> {\n try {\n await removeOverlay(record.startOptions.overlayPath)\n } catch (error) {\n lastError = `Overlay was not reclaimed for ${record.deskId}: ${errorMessage(error)}`\n }\n // The snapshot goes with the disk, always — not only when parking is on.\n //\n // A snapshot outliving its overlay is the worst state this feature can\n // produce: the next desk created under the same id gets a FRESH overlay and\n // would restore a previous desk's memory on top of it. That is not stale\n // state, it is one machine's RAM over another machine's disk. Teardown just\n // ran, so nothing holds it open.\n try {\n await removeSnapshot(snapshotDirFor(record.startOptions.overlayPath, record.deskId))\n } catch (error) {\n lastError = `Snapshot was not reclaimed for ${record.deskId}: ${errorMessage(error)}`\n }\n }\n\n async function destroy(deskId: string): Promise<void> {\n const id = cleanDeskId(deskId)\n await serializeLifecycle(id, async () => {\n const record = records.get(id)\n if (!record) return\n await teardown(record)\n records.delete(id)\n // Strictly after teardown: the VMM still has the file open until its child\n // has exited, and unlinking underneath a live guest would leave the desk\n // writing into an orphaned inode instead of failing loudly.\n await reclaimOverlay(record)\n })\n }\n\n async function sweep(): Promise<number> {\n const timestamp = now()\n let suspendedCount = 0\n for (const record of [...records.values()]) {\n const suspended = await serializeLifecycle(record.deskId, async () => {\n // A destroy and a later start may have replaced a captured record\n // before its turn in the sweep. Never apply the old deadline to the\n // new desk that happens to share its id.\n if (records.get(record.deskId) !== record || record.status !== 'resident') return false\n const handover = record.screen?.handover\n if (handover && handover.deadline <= timestamp) {\n await endHandover(record, 'expired')\n }\n if (\n record.leaseDeadline <= timestamp\n || timestamp - record.lastActivityAt >= idleSuspendMs\n ) {\n return teardown(record)\n }\n return false\n })\n if (suspended) suspendedCount += 1\n }\n return suspendedCount\n }\n\n function recordCpuFallback(deskId: string, reason: 'signature_mismatch' | 'incompatible_cpuid'): void {\n snapshotCpuFallbacks += 1\n lastSnapshotCpuFallback = { deskId, reason, at: iso(now()) }\n ports.onEvent({ kind: 'snapshot_cpu_fallback', deskId, reason, at: iso(now()) })\n }\n\n function stats(): DeskHostStats {\n let suspended = 0\n for (const record of records.values()) {\n if (record.status === 'suspended') suspended += 1\n }\n return {\n resident: occupied,\n queued: queue.length,\n capacity,\n suspended,\n lastStartedAt,\n lastSuspendedAt,\n reconnects,\n lastReconnectAt,\n lastReconnectDeskId,\n lastError,\n snapshotCpuFallbacks,\n lastSnapshotCpuFallback,\n }\n }\n\n return { start, canPause, pause, resume, suspend, shutdown, destroy, stats, sweep }\n}\n\nexport interface VerifyDeskHostOptions {\n kernelPath: string\n /** Initramfs for the probe VM; needed for a modular kernel, as at boot. */\n initramfsPath?: string\n /**\n * Kernel command line for the probe VM. It must match what real desks boot\n * with: a probe that panics because its root is on another partition\n * reports a host that cannot run desks, which is indistinguishable from a\n * host that genuinely cannot.\n */\n kernelCmdline?: string\n baseImagePath: string\n vmmPath?: string\n kvmPath?: string\n /** Where the throwaway probe overlay is created; defaults to the OS tmpdir. */\n scratchDir?: string\n runtimeDir?: string\n backend?: DeskBackend\n launcherIdentity?: DeskLauncherIdentity\n platform?: NodeJS.Platform\n pathExists?: (path: string) => boolean\n deviceExists?: (path: string) => boolean\n idFactory?: () => string\n}\n\nexport interface OverlayReflinkCheck {\n /** Whether `cp --reflink` produced a block-sharing clone in this directory. */\n supported: boolean\n overlayDirectory: string\n /** Why the answer is what it is — the `cp` failure when unsupported. */\n detail: string\n}\n\n/**\n * Whether the overlay directory's filesystem can make reflink clones.\n * On macOS this probes APFS cloning with `cp -c`. On Linux:\n *\n * This exists because `cp --reflink=auto` — what `buildDeskLaunchPlan` uses,\n * deliberately, so a desk still boots on a filesystem without reflink — is\n * SILENT when it falls back. On XFS or Btrfs a 20GB base clones instantly and\n * costs kilobytes; on ext4 the identical command copies all 20GB, slowly, per\n * desk. The failure is invisible until a disk sized for reflink sharing fills\n * after two desks, which looks like a capacity bug rather than the filesystem\n * choice it actually is.\n *\n * So the probe uses `--reflink=always`, which REFUSES to fall back, on a tiny\n * throwaway file. Call it at startup and refuse to serve rather than discover\n * this in production — see `assertOverlayReflink`.\n */\nexport async function verifyOverlayReflink(options: {\n overlayDirectory: string\n idFactory?: () => string\n copy?: (source: string, destination: string) => Promise<void>\n}): Promise<OverlayReflinkCheck> {\n const overlayDirectory = options.overlayDirectory\n const idFactory = options.idFactory ?? randomUUID\n const copy = options.copy ?? reflinkAlways\n const token = idFactory()\n const source = join(overlayDirectory, `.reflink-probe-${token}`)\n const destination = join(overlayDirectory, `.reflink-probe-${token}.clone`)\n try {\n try {\n await writeFile(source, 'reflink probe')\n } catch (error) {\n // A directory that cannot be written to is not a filesystem without\n // reflink — it is a broken deployment, and reporting it as the former\n // would send an operator to reformat a disk over a permissions bug.\n throw new DeskError(\n `The overlay directory ${overlayDirectory} could not be written to, so reflink `\n + `support could not be determined: ${errorMessage(error)}`,\n )\n }\n await copy(source, destination)\n return { supported: true, overlayDirectory, detail: process.platform === 'darwin' ? 'cp -c succeeded.' : 'cp --reflink=always succeeded.' }\n } catch (error) {\n if (error instanceof DeskError) throw error\n return { supported: false, overlayDirectory, detail: errorMessage(error) }\n } finally {\n await rm(source, { force: true }).catch(() => undefined)\n await rm(destination, { force: true }).catch(() => undefined)\n }\n}\n\n/**\n * Fail loudly at startup on a filesystem without reflink support, naming the\n * cost so the operator can act on it.\n */\nexport async function assertOverlayReflink(options: {\n overlayDirectory: string\n idFactory?: () => string\n copy?: (source: string, destination: string) => Promise<void>\n}): Promise<OverlayReflinkCheck> {\n const check = await verifyOverlayReflink(options)\n if (!check.supported) {\n throw new DeskError(\n process.platform === 'darwin'\n ? `The overlay directory ${check.overlayDirectory} does not support cloning. Put it on APFS. Probe said: ${check.detail}`\n : `The overlay directory ${check.overlayDirectory} is on a filesystem without reflink `\n + 'support, so every desk would FULL-COPY the base image instead of sharing its '\n + 'blocks — gigabytes and minutes per desk, and a disk sized for sharing fills after '\n + `a handful of them. Put the overlay directory on XFS or Btrfs. Probe said: ${check.detail}`,\n )\n }\n return check\n}\n\nasync function reflinkAlways(source: string, destination: string): Promise<void> {\n await new Promise<void>((resolvePromise, rejectPromise) => {\n execFile('cp', [process.platform === 'darwin' ? '-c' : '--reflink=always', source, destination], (error, _stdout, stderr) => {\n if (error) {\n rejectPromise(new Error(stderr.trim() || errorMessage(error)))\n return\n }\n resolvePromise()\n })\n })\n}\n\nexport interface DeskHostVerification {\n /** Whether this host can serve desks: KVM present and the guest reachable. */\n supported: boolean\n vmmPath: string\n /** KVM availability; false on macOS, which uses Virtualization.framework. */\n kvm: boolean\n vsock: boolean\n virtioGpu: boolean\n}\n\n/**\n * Boot-time probe. Distinguishes a host that is unusable — wrong platform,\n * missing VMM, missing images — which throws, from capabilities that are\n * merely absent, which are reported as booleans: `kvm` (no boot possible\n * without it), `vsock` (the guest agent answered), and `virtioGpu` (a screen\n * would have hardware-backed rendering). It boots a throwaway microVM through\n * the backend, asks it two questions, and discards it.\n */\nexport async function verifyDeskHost(options: VerifyDeskHostOptions): Promise<DeskHostVerification> {\n const platform = options.platform ?? process.platform\n const pathExists = options.pathExists ?? existsSync\n const deviceExists = options.deviceExists ?? existsSync\n const idFactory = options.idFactory ?? randomUUID\n const backend = options.backend ?? cloudHypervisorBackend\n const isVirtualization = backend.hypervisor === 'virtualization'\n const vmmPath = options.vmmPath ?? backend.vmmPath ?? DEFAULT_VMM_PATH\n const kvmPath = options.kvmPath ?? DEFAULT_KVM_PATH\n\n if (platform !== (isVirtualization ? 'darwin' : 'linux')) {\n throw new DeskError(isVirtualization ? `Virtualization requires macOS; received ${platform}.` : `The AppKit desk requires Linux; received ${platform}.`)\n }\n if (!pathExists(vmmPath)) {\n throw new DeskError(isVirtualization ? `Virtualization helper was not found at ${vmmPath}.` : `Cloud Hypervisor was not found at ${vmmPath}.`)\n }\n if (!pathExists(options.kernelPath)) {\n throw new DeskError(`Guest kernel does not exist: ${options.kernelPath}`)\n }\n if (!pathExists(options.baseImagePath)) {\n throw new DeskError(`Base image does not exist: ${options.baseImagePath}`)\n }\n if (!isVirtualization && !deviceExists(kvmPath)) {\n return { supported: false, vmmPath, kvm: false, vsock: false, virtioGpu: false }\n }\n\n const scratchDir = options.scratchDir ?? tmpdir()\n const deskId = `verify-${idFactory()}`\n const overlayPath = join(scratchDir, `${deskId}.raw`)\n const plan = buildDeskLaunchPlan(\n {\n deskId,\n hypervisor: backend.hypervisor ?? 'cloud-hypervisor',\n vmmPath,\n kvmPath,\n kernelPath: options.kernelPath,\n ...(options.initramfsPath === undefined ? {} : { initramfsPath: options.initramfsPath }),\n ...(options.kernelCmdline === undefined ? {} : { kernelCmdline: options.kernelCmdline }),\n baseImagePath: options.baseImagePath,\n overlayPath,\n vsockCid: 3,\n runtimeDir: options.runtimeDir,\n launcherIdentity: options.launcherIdentity,\n },\n { pathExists, deviceExists },\n )\n\n let machine: DeskMachine\n try {\n machine = await backend.boot(plan)\n } catch (error) {\n throw new DeskError(`Desk verification could not boot a probe VM: ${errorMessage(error)}`)\n }\n let vsock = false\n let virtioGpu = false\n try {\n try {\n await machine.request({ op: 'ping' })\n vsock = true\n } catch {\n vsock = false\n }\n if (vsock) {\n try {\n virtioGpu = parseCapabilities(await machine.request({ op: 'capabilities' })).virtioGpu\n } catch {\n virtioGpu = false\n }\n }\n } finally {\n try {\n await machine.shutdown()\n } catch {\n // The probe VM is discarded regardless of how cleanly it stops.\n }\n await rm(overlayPath, { force: true })\n }\n return { supported: vsock, vmmPath, kvm: !isVirtualization, vsock, virtioGpu }\n}\n\nfunction nonEmptyString(value: string, field: string): string {\n if (typeof value !== 'string' || value.length === 0) {\n throw new DeskError(`${field} must be a non-empty string.`)\n }\n return value\n}\n\nfunction requireStringValue(value: string, field: string): string {\n if (typeof value !== 'string') {\n throw new DeskError(`${field} must be a string.`)\n }\n return value\n}\n\nfunction positiveInteger(value: number, field: string): number {\n if (!Number.isInteger(value) || value < 1) {\n throw new DeskError(`${field} must be a positive integer.`)\n }\n return value\n}\n\nfunction nonNegativeInteger(value: number, field: string): number {\n if (!Number.isInteger(value) || value < 0) {\n throw new DeskError(`${field} must be an integer of zero or more.`)\n }\n return value\n}\n\n/**\n * Free bytes on the filesystem holding `path`, measured against the directory\n * so the answer is the same before and after the overlay itself exists.\n */\nasync function defaultFreeBytes(path: string): Promise<number> {\n const stats = await statfs(dirname(path))\n return Number(stats.bsize) * Number(stats.bavail)\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n\nasync function connectGuestTcp(address: string, port: number): Promise<Duplex> {\n return new Promise((resolve, reject) => {\n const socket = tcpConnect({ host: address, port })\n socket.setTimeout(10_000, () => socket.destroy(new Error('Guest TCP connection timed out.')))\n socket.once('error', reject)\n socket.once('connect', () => { socket.setTimeout(0); socket.removeListener('error', reject); resolve(socket) })\n })\n}\n\n/** Cloud Hypervisor's specific restore error; do not classify generic CPUID mentions. */\nexport function isIncompatibleCpuSnapshotError(error: unknown): boolean {\n return /Detected incompatible CPUID entry/.test(errorMessage(error))\n}\n/** Hash the host's CPU identity and advertised feature set, excluding per-core counters. */\nexport async function hostCpuSignature(): Promise<string> {\n if (process.platform === 'darwin') {\n const model = cpus()[0]?.model\n if (!model) throw new DeskError('Cannot determine host CPU signature.')\n return createHash('sha256').update(`darwin:${arch()}:${release()}:${model}`).digest('hex')\n }\n const cpuinfo = await readFile('/proc/cpuinfo', 'utf8')\n const first = cpuinfo.split(/\\n\\s*\\n/)[0] ?? ''\n const identity = first.split('\\n').filter((line) => /^(vendor_id|cpu family|model\\s|model name|stepping|flags|microcode)\\s*:/.test(line)).join('\\n')\n if (!identity) throw new DeskError('Cannot determine host CPU signature.')\n return createHash('sha256').update(identity).digest('hex')\n}\nasync function readSnapshotSignature(directory: string): Promise<string | null> {\n try { return (await readFile(join(directory, 'appkit-cpu-signature'), 'utf8')).trim() }\n catch (error) { if ((error as NodeJS.ErrnoException).code === 'ENOENT') return null; throw error }\n}\nasync function writeSnapshotSignature(directory: string, signature: string): Promise<void> {\n await writeFile(join(directory, 'appkit-cpu-signature'), signature, { mode: 0o600 })\n}\n"]}