import * as plugins from './plugins.js'; import { type TControllerMcpBrowserActionResult } from '../dist_ts_interfaces/mcpworkspacerequests.js'; import type { IControllerResourceRuntimeHost } from './classes.resourcecoordinator.js'; import type { IControllerResourceDocument } from './interfaces.projects.js'; import { type IFlexBrowserChannelBinding } from './interfaces.flexipc.js'; import { type TControllerBrowserViewCloseCode } from '../dist_ts_interfaces/browsertransport.js'; /** * Screencast policy for every live browser session. Chrome encodes JPEG at * this quality and scales frames to fit the bounds in device pixels, so a * high-DPI viewer can neither produce frames near the runtime's 4 MiB frame * cap nor spend the client's decode budget on pixels the canvas cannot show. * Every produced frame reaches subscribers; slow human transports retain only * their newest unsent frame. Idle pages produce none. */ export declare const controllerBrowserScreencastOptions: Readonly>; export interface IControllerBrowserResourceHostOptions { videoBackend?: 'chromium' | 'native'; runtimeDirectory: string; authorizeCapability: plugins.browserRuntime.IBrowserRuntimeOptions['authorizeCapability']; /** * Closes the views a resource owns before the host mutates or tears down * its runtime. Every teardown reaches the runtime through this host, so * announcing here covers the paths that never touch a controller request * handler. Human views survive task attachment changes; resource teardown * still announces closure. Without it the streams die under the client, which * reads an intentional teardown as a transport fault, spends its whole * recovery budget, and reports that the view cannot be recovered. */ closeResourceViews?(projectIdArg: string, resourceIdArg: string, closeCodeArg: TControllerBrowserViewCloseCode, signalArg: AbortSignal): Promise; isFlexRunActive?(bindingArg: IFlexBrowserChannelBinding, runIdArg: string): boolean; beforeOperation?: plugins.browserRuntime.IBrowserRuntimeOptions['beforeOperation']; audit?: plugins.browserRuntime.IBrowserRuntimeOptions['audit']; } export interface IControllerBrowserHumanView { lease: plugins.browserRuntime.BrowserRuntimeLease; activate(listenerArg: (eventArg: plugins.browserRuntime.TBrowserRuntimeEvent) => void): Promise; close(): Promise; } export interface IControllerFlexBrowserChannel { binding: IFlexBrowserChannelBinding; capabilityToken: string; } export declare class ControllerBrowserResourceHost implements IControllerResourceRuntimeHost { private readonly options; private runtime?; private started; private unavailable; private stopping; private cleanupTimeoutMs; private startPromise?; private stopPromise?; private readonly flexAuthorizationBindings; private readonly flexChannels; private readonly flexChannelAdmissions; private readonly capabilityRevocationOperations; private readonly lateCapabilityIssuanceTasks; private readonly humanViews; private readonly humanViewAdmissions; private readonly mcpActionAdmissions; private admissionAbortController; private readonly runtimeStopOperations; constructor(options: IControllerBrowserResourceHostOptions); start(signalArg?: AbortSignal): Promise; /** Options for the runtime this host owns; the screencast policy is fixed. */ private runtimeOptions; private performStart; stop(): Promise; private performStop; authorizeFlexCapability(requestArg: plugins.browserRuntime.TBrowserCapabilityAuthorizationRequest): boolean; authorizeMcpCapability(requestArg: plugins.browserRuntime.TBrowserCapabilityAuthorizationRequest): boolean; /** * `actingSessionId` is the conversation the caller acts for, proved upstream against the * attachment set. It is not read off the resource: a resource may be attached to several * conversations, and the binding must name the one this action belongs to. It is a qualified * BrowserRuntime session — an AGL chat, or the `claude` conversation that owns an attached * terminal — and is checked against this resource's own binding here as well. */ executeMcpAction(inputArg: { resource: IControllerResourceDocument; actingSessionId: plugins.browserRuntime.TQualifiedBrowserSessionId; action: plugins.browserRuntime.TBrowserAgentAction; signal: AbortSignal; }): Promise; private performMcpActionAttempt; private drainMcpActionAdmissions; openFlexChannel(inputArg: { resource: IControllerResourceDocument; scopeId: string; sessionId: string; sessionGenerationId: string; sessionGenerationSequence: number; runId: string; channelId: string; peerId: string; signal?: AbortSignal; sendFrame(channelIdArg: string, bytesArg: Buffer): Promise; notifyClosed(channelIdArg: string): Promise; }): Promise; receiveFlexFrame(channelIdArg: string, bytesArg: Buffer, peerIdArg: string): Promise; closeFlexChannel(channelIdArg: string, notifyChildArg?: boolean, peerIdArg?: string, deadlineAtArg?: number): Promise; closeFlexChannelFromPeer(inputArg: { channelId: string; peerId: string; sessionGenerationId: string; sessionGenerationSequence: number; }): Promise; closeAllFlexChannels(peerIdArg?: string, deadlineAtArg?: number): Promise; closeFlexChannelsForRun(projectIdArg: string, sessionIdArg: string, runIdArg: string): Promise; disconnectPeer(peerIdArg: string): Promise; openHumanView(inputArg: { resource: IControllerResourceDocument; actorId: string; peerId: string; signal: AbortSignal; onDisconnect(signalArg: AbortSignal): Promise | void; }): Promise; startResource(resourceArg: IControllerResourceDocument, signalArg: AbortSignal): Promise; stopResource(resourceArg: IControllerResourceDocument, signalArg: AbortSignal): Promise; isRunning(resourceArg: IControllerResourceDocument): boolean; isAvailable(): boolean; reconcileAttachment(resourceArg: IControllerResourceDocument, signalArg: AbortSignal): Promise; retireResource(resourceArg: IControllerResourceDocument, signalArg: AbortSignal): Promise; /** Runs the controller's announced close for this resource, when one is wired. */ private closeResourceViews; get availability(): 'available' | 'unavailable'; private isFlexRunActive; private trackCapabilityRevocation; private awaitCapabilityRevocation; private trackLateCapabilityIssuance; private closeAllHumanViews; private retryPendingCapabilityRevocations; private cancelAndDrainFlexChannelAdmissions; private drainHumanViewAdmissions; private drainLateCapabilityIssuanceTasks; private stopRuntime; }