import type { RootFilesystemConfig as VmConfigRootFilesystemConfig, RootFilesystemEntry as VmConfigRootFilesystemEntry, RootFilesystemLowerDescriptor as VmConfigRootFilesystemLowerDescriptor } from "@rivet-dev/agentos-runtime-core/vm-config"; import type { NativeMountConfig, PlainMountConfig, RootFilesystemConfig } from "../agent-os.js"; import type { RootSnapshotExport } from "../layers.js"; import type { ConnectTerminalOptions, KernelExecOptions, KernelExecResult, KernelSpawnOptions, ManagedProcess, OpenShellOptions, ProcessInfo, ShellHandle, VirtualFileSystem, VirtualStat } from "../runtime-compat.js"; import type { AuthenticatedSession, CreatedVm, SidecarPermissionsPolicy, SidecarProcess, SidecarSignalHandlerRegistration } from "./native-process-client.js"; export declare function toSidecarSignalName(signal: number): string; export interface LocalCompatMount { path: string; fs: VirtualFileSystem; readOnly: boolean; sidecarMount?: SidecarMountDescriptor; } interface KernelSocketSnapshot { processId: string; host?: string; port?: number; path?: string; } interface KernelSignalState { handlers: Map; flags: number; }>; } interface NativeSidecarKernelProxyOptions { client: SidecarProcess; session: AuthenticatedSession; vm: CreatedVm; env: Record; cwd: string; defaultExecCwd?: string; localMounts: LocalCompatMount[]; sidecarMounts: SidecarMountDescriptor[]; permissions?: SidecarPermissionsPolicy; commandPermissions?: Parameters[2]["commandPermissions"]; loopbackExemptPorts?: number[]; /** * The boot `configureVm` payload pieces beyond mounts/permissions. Rust * `configure_vm` rebuilds the whole VM configuration from each payload, so * every runtime mount reconfigure must resend these or a post-boot * `mountFs()` silently drops the `/opt/agentos` package projections and * binding shim commands applied at boot. */ packages?: Parameters[2]["packages"]; packagesMountAt?: string; bindingShimCommands?: string[]; commandGuestPaths: ReadonlyMap; onWasmCommandResolved?: (command: string) => void; onDispose?: () => Promise; /** * Whether this proxy owns the underlying sidecar process. When VMs share one * sidecar process (the default for VMs leased from an `AgentOsSidecar` * handle), each proxy tears down only its own VM on `dispose()`; the shared * process is disposed when the sidecar handle is disposed. Defaults to true * for the legacy one-process-per-VM path. */ ownsClient?: boolean; } export declare class NativeSidecarKernelProxy { readonly env: Record; readonly cwd: string; readonly commands: ReadonlyMap; readonly vfs: VirtualFileSystem; readonly processes: Map; private readonly defaultExecCwd; private readonly client; private readonly session; private readonly vm; private readonly ownsClient; private readonly localMounts; private readonly baseSidecarMounts; private readonly dynamicSidecarMounts; private readonly permissions; private readonly commandPermissions; private readonly loopbackExemptPorts; private packages; private readonly packagesMountAt; private readonly bindingShimCommands; private readonly commandDrivers; private readonly onWasmCommandResolved; private readonly onDispose; private readonly trackedProcesses; private readonly trackedProcessesById; private readonly listenerLookups; private readonly boundUdpLookups; private readonly signalStates; private readonly signalRefreshes; private sidecarProcessSnapshot; private processSnapshotRefresh; private readonly observedProcessStartTimes; private readonly rootView; private zombieTimerCountValue; private zombieTimerCountRefresh; private disposed; private pumpError; private mountReconfigurePromise; private nextSyntheticPid; private readonly eventPumpAbortController; private readonly eventPump; constructor(options: NativeSidecarKernelProxyOptions); createRootView(): VirtualFileSystem; get zombieTimerCount(): number; registerCommandGuestPaths(commandGuestPaths: ReadonlyMap): void; /** * Record a runtime-linked package (`linkSoftware`) so mount reconfigures * resend it. Rust `configure_vm` rebuilds the whole VM configuration from * each payload, so a linked package omitted here would be silently * unprojected from `/opt/agentos` by the next `mountFs`/`unmountFs`. */ registerLinkedPackage(descriptor: { path: string; }): void; dispose(): Promise; /** Test-only snapshot of the per-VM tracking collection sizes. */ __trackingSizesForTest(): { trackedProcesses: number; trackedProcessesById: number; signalStates: number; signalRefreshes: number; localMounts: number; }; /** Test-only handle to a tracked entry so its listener Sets can be inspected. */ __trackedEntryForTest(pid: number): { onStdout: ReadonlySet; onStderr: ReadonlySet; } | undefined; /** Test-only join point for in-flight signal-state refreshes. */ __awaitSignalRefreshesForTest(): Promise; exec(command: string, options?: KernelExecOptions): Promise; execArgv(command: string, args?: readonly string[], options?: KernelExecOptions): Promise; spawn(command: string, args: string[], options?: KernelSpawnOptions): ManagedProcess; openShell(options?: OpenShellOptions): ShellHandle; connectTerminal(options?: ConnectTerminalOptions): Promise; readFile(path: string): Promise; writeFile(path: string, content: string | Uint8Array): Promise; mkdir(path: string, recursive?: boolean): Promise; exists(path: string): Promise; stat(path: string): Promise; readdir(path: string): Promise; readdirRecursive(path: string, options?: { maxDepth?: number; }): Promise>; removeFile(path: string): Promise; removeDir(path: string): Promise; removePath(path: string, options?: { recursive?: boolean; }): Promise; copyPath(fromPath: string, toPath: string, options?: { recursive?: boolean; }): Promise; rename(oldPath: string, newPath: string): Promise; movePath(oldPath: string, newPath: string): Promise; mountFs(path: string, driver: VirtualFileSystem, options?: { readOnly?: boolean; sidecarMount?: SidecarMountDescriptor; }): Promise; unmountFs(path: string): Promise; mountDescriptor(mount: SidecarMountDescriptor): Promise; unmountDescriptor(path: string): Promise; listMounts(): Promise>; private desiredSidecarMounts; private reconfigureSidecarMounts; private waitForMountReconfigure; snapshotProcesses(): ProcessInfo[]; findListener(request: { host?: string; port?: number; path?: string; }): KernelSocketSnapshot | null; findBoundUdp(request: { host?: string; port?: number; }): KernelSocketSnapshot | null; getSignalState(pid: number): KernelSignalState; private scheduleSignalStateRefresh; private refreshSocketLookup; private refreshSignalState; private refreshProcessSnapshot; private refreshZombieTimerCount; private drainTrailingProcessOutput; private startTrackedProcess; private runEventPump; private finishProcess; private releaseProcessTrackingAfterDrain; private waitForTrackedProcess; private signalProcess; private flushPendingStdin; private closeTrackedStdin; private handleBackgroundProcessError; private recordCompletedProcessError; private emitBackgroundProcessError; private readdirRecursiveLocal; private removePathLocal; private copyPathLocal; private createFilesystemView; private buildProcessSnapshot; private dispatchRead; private dispatchNativeRead; private dispatchWrite; private resolveLocalMount; private assertGuestPathWritable; private mountedChildNames; private assertLocalWritable; private updateTrackedProcessSnapshot; } export type { AuthenticatedSession, CreatedVm, GuestFilesystemStat, RootFilesystemEntry, SidecarConfigureVmResult, SidecarEventSelector, SidecarLinkPackageResult, SidecarPermissionsPolicy, SidecarProjectedAgent, SidecarRegisteredHostCallbackDefinition, SidecarRequestFrame, SidecarResponsePayload, SidecarSessionState, SidecarSignalHandlerRegistration, SidecarSocketStateEntry, SidecarSpawnOptions, } from "./native-process-client.js"; export { NativeSidecarProcessClient, SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "./native-process-client.js"; export type AgentOsSidecarPlacement = { kind: "shared"; pool?: string; } | { kind: "explicit"; sidecarId: string; }; export type AgentOsSidecarSessionState = "connecting" | "ready" | "disposing" | "disposed" | "failed"; export type AgentOsSidecarVmState = "creating" | "ready" | "disposing" | "disposed" | "failed"; export interface AgentOsSidecarSessionLifecycle { sessionId: string; placement: AgentOsSidecarPlacement; state: AgentOsSidecarSessionState; createdAt: number; connectedAt?: number; disposedAt?: number; lastError?: string; metadata: Record; vmIds: string[]; } export interface AgentOsSidecarVmLifecycle { vmId: string; sessionId: string; state: AgentOsSidecarVmState; createdAt: number; readyAt?: number; disposedAt?: number; lastError?: string; metadata: Record; } export interface AgentOsSidecarSessionOptions { placement?: AgentOsSidecarPlacement; metadata?: Record; signal?: AbortSignal; } export interface AgentOsSidecarVmOptions { metadata?: Record; } export interface AgentOsSidecarSessionBootstrap { sessionId: string; placement: AgentOsSidecarPlacement; metadata: Record; signal?: AbortSignal; } export interface AgentOsSidecarVmBootstrap { vmId: string; sessionId: string; metadata: Record; } export interface AgentOsSidecarTransport { createVm?(bootstrap: AgentOsSidecarVmBootstrap): Promise; disposeVm?(vmId: string): Promise; dispose(): Promise; } export interface AgentOsSidecarClientOptions { createOwnershipTransport(bootstrap: AgentOsSidecarSessionBootstrap): Promise; createId?: () => string; now?: () => number; } export declare class AgentOsSidecarVmHandle { private readonly client; readonly sessionId: string; readonly vmId: string; constructor(client: AgentOsSidecarClient, sessionId: string, vmId: string); describe(): AgentOsSidecarVmLifecycle; dispose(): Promise; } export declare class AgentOsSidecarSessionHandle { private readonly client; readonly sessionId: string; constructor(client: AgentOsSidecarClient, sessionId: string); describe(): AgentOsSidecarSessionLifecycle; listVms(): AgentOsSidecarVmLifecycle[]; createVm(options?: AgentOsSidecarVmOptions): Promise; dispose(): Promise; } export declare class AgentOsSidecarClient { private readonly createOwnershipTransport; private readonly createId; private readonly now; private readonly sessions; private disposed; constructor(options: AgentOsSidecarClientOptions); /** Open a physical sidecar ownership scope, not a durable ACP session. */ createOwnershipSession(options?: AgentOsSidecarSessionOptions): Promise; listSessions(): AgentOsSidecarSessionLifecycle[]; requireSessionLifecycle(sessionId: string): AgentOsSidecarSessionLifecycle; listVms(sessionId: string): AgentOsSidecarVmLifecycle[]; requireVmLifecycle(sessionId: string, vmId: string): AgentOsSidecarVmLifecycle; createVm(sessionId: string, options?: AgentOsSidecarVmOptions): Promise; disposeVm(sessionId: string, vmId: string): Promise; disposeSession(sessionId: string): Promise; dispose(): Promise; private disposeVmEntry; private getSessionEntry; private getVmEntry; private assertActive; } export declare function createAgentOsSidecarClient(options: AgentOsSidecarClientOptions): AgentOsSidecarClient; export type MountConfigJsonValue = string | number | boolean | null | MountConfigJsonObject | MountConfigJsonValue[]; export interface MountConfigJsonObject { [key: string]: MountConfigJsonValue; } export interface SidecarMountPluginDescriptor { id: string; config: MountConfigJsonObject; } export interface SidecarMountDescriptor { guestPath: string; guestSource?: string; guestFstype?: string; readOnly: boolean; plugin: SidecarMountPluginDescriptor; } export declare function serializeMountConfigForSidecar(mount: PlainMountConfig | NativeMountConfig): SidecarMountDescriptor; export type SidecarRootFilesystemDescriptor = VmConfigRootFilesystemConfig; export type SidecarRootFilesystemLowerDescriptor = VmConfigRootFilesystemLowerDescriptor; export type SidecarRootFilesystemEntry = VmConfigRootFilesystemEntry; export declare function serializeRootFilesystemForSidecar(config?: RootFilesystemConfig, bootstrapLower?: RootSnapshotExport | null): SidecarRootFilesystemDescriptor;