/** * Sandbox Process Manager (Base Class) * * Abstract base class for sandbox process management. * Wraps all methods with ensureRunning() so the sandbox is * automatically started before any process operation. * Subclasses implement spawn(), list(), get(). */ import type { MastraSandbox } from '../mastra-sandbox.js'; import type { ProcessHandle } from './process-handle.js'; import type { ProcessInfo, SpawnProcessOptions } from './types.js'; /** * Abstract base class for process management in sandboxes. * * Wraps subclass overrides of `spawn()`, `list()`, and `get()` with * `sandbox.ensureRunning()` so the sandbox is lazily started before * any process operation. * * Subclasses implement the actual platform-specific logic for all methods. * * @typeParam TSandbox - The sandbox type. Subclasses narrow this to access * sandbox-specific properties (e.g. `workingDirectory`, `instance`). * * @example * ```typescript * const handle = await sandbox.processes.spawn('node server.js'); * console.log(handle.pid, handle.stdout); * * const all = await sandbox.processes.list(); * const proc = await sandbox.processes.get(handle.pid); * await proc?.kill(); * ``` */ export interface ProcessManagerOptions { env?: Record; } export declare abstract class SandboxProcessManager { /** * The sandbox this process manager belongs to. * Set automatically by MastraSandbox when processes are passed into the constructor. * @internal */ sandbox: TSandbox; protected readonly env: Record; /** Tracked process handles keyed by PID. Populated by spawn(), used by get()/kill(). */ protected readonly _tracked: Map; /** PIDs that have been read after exit and should not be re-discovered by subclass fallbacks. */ protected readonly _dismissed: Set; constructor({ env }?: ProcessManagerOptions); /** Spawn a process. */ spawn(command: string, options?: SpawnProcessOptions): Promise; /** List all tracked processes. */ list(): Promise; /** Get a handle to a process by PID. Subclasses can override for fallback behavior. */ get(pid: string): Promise; /** Kill a process by PID. Returns true if killed, false if not found. */ kill(pid: string): Promise; } //# sourceMappingURL=process-manager.d.ts.map