import type { Context } from "@steve.kite/stdlib"; import type { ManagedProcessStatus, ProcessKillOptions, ProcessRunOptions, ProcessRunResult, ProcessSnapshot, ProcessStartOptions } from "./types.js"; export declare class NativeProcessManager { #private; start(ctx: Context, options: ProcessStartOptions): Promise; run(ctx: Context, options: ProcessRunOptions): Promise; get(id: string): ManagedProcess | undefined; snapshots(): ProcessSnapshot[]; activeCount(): number; writeStdin(ctx: Context, id: string, data: string | Uint8Array): Promise; kill(ctx: Context, id: string, options?: ProcessKillOptions): Promise; /** * Stops running work. * * Detached work — a command the agent deliberately left running in the * background — is spared unless the caller is shutting everything down, in * which case whole process groups go too, including anything that outlived * the shell that launched it. */ killAll(ctx: Context, options?: ProcessKillOptions): Promise; /** Process groups that a shutdown would still have to take down. */ pendingProcessGroups(): readonly number[]; /** * How much running work a shutdown would still find. * * A live command and the group it leads are one thing, so the group of an * active process is not counted twice. What this adds are the groups that * outlived the command that started them: `nohup server &` leaves nothing * running under our watch, but the server is very much still there. */ reapableCount(): number; } export interface ManagedProcessHooks { /** The whole process group is known to be gone. */ onGroupTerminated: (processGroupId: number) => void; /** No more output or exit information can arrive. */ onSettled: (id: string) => void; } export declare class ManagedProcess { #private; readonly id: `${string}-${string}-${string}-${string}-${string}`; readonly command: string; readonly cwd: string; readonly pid: number | null; /** The agent left this running on purpose; an interrupted turn spares it. */ detached: boolean; private constructor(); static start(ctx: Context, options: ProcessStartOptions, hooks: ManagedProcessHooks): Promise; get status(): ManagedProcessStatus; snapshot(): ProcessSnapshot; readOutput(stdoutOffset: number, stderrOffset: number, consume?: boolean): ProcessSnapshot & { stderrDelta: string; stderrDeltaBytes: number; stderrDeltaOmittedBytes: number; stderrOffset: number; stdoutDelta: string; stdoutDeltaBytes: number; stdoutDeltaOmittedBytes: number; stdoutOffset: number; }; writeStdin(ctx: Context, data: string | Uint8Array): Promise; endStdin(ctx: Context, data?: string | Uint8Array): Promise; interrupt(ctx: Context): Promise; kill(ctx: Context, signal?: NodeJS.Signals, options?: ProcessKillOptions): Promise; wait(ctx: Context): Promise; }