/// import type EventEmitter from 'events'; import type Dockerode from 'dockerode'; import type { RestartPolicy } from '@nosana/sdk'; type ContainerState = 'starting' | 'running' | 'exited' | 'restarting'; export declare class ContainerStateManager { private container; private controller; private emitter; private restartPolicy; /** * Whether a failed liveness probe may restart this container. Like a * restart policy it means a stop is not necessarily the op finishing, so * the container has to be polled rather than waited on. */ private restartsOnUnhealthy; private state; private exitedCheckCount; private lastLogTimestamp; private logRemainder; private readonly EXITED_CHECKS_REQUIRED; private currentLogStream; private currentStatsStream; private pollingInterval; private restarting; constructor(container: Dockerode.Container, controller: AbortController, emitter: EventEmitter, restartPolicy: RestartPolicy | undefined, /** * Whether a failed liveness probe may restart this container. Like a * restart policy it means a stop is not necessarily the op finishing, so * the container has to be polled rather than waited on. */ restartsOnUnhealthy?: boolean); getState(): ContainerState; startMonitoring(): Promise; private attachLogStream; /** * Restart the container in place after a failed liveness probe, keeping the * op alive across it. Returns whether the container came back. */ restartContainer(): Promise; waitForExit(): Promise; /** * Wait for the followed log stream to finish delivering its final buffered * frames after the container has exited. * * `container.wait()` (which drives `waitForExit`) and the log stream are * independent connections, so when `wait()` reports the exit the stream may * still be flushing the last lines (e.g. an op's final result line). Reading * logs or tearing the stream down at that point loses them. The stream's * `close` handler nulls `currentLogStream`, and it won't re-attach once the * container has exited, so a null stream means the flush is complete. Bounded * so a stream that never closes can't stall completion. */ waitForLogsDrained(timeoutMs?: number): Promise; stopMonitoring(): void; private readonly STATS_INTERVAL_MS; private attachStatsStream; } export {};