import type { AdapterLogger } from "./logger.js"; import type { IHostTransport } from "./host-transport.js"; /** An active connection to a PowerLine. */ export interface PowerLineConnection { environmentId: string; port: number; /** * Transport-agnostic host interface. Constructed when the connection is * established and used for all session-level operations. */ transport: IHostTransport; /** * Send a liveness probe to the PowerLine. Resolves on success; rejects on * any transport-layer error. */ ping(): Promise; /** * Tear down the underlying transport (WebSocket + pending RPCs). Idempotent. * Adapters MUST call this from `disconnect()` to avoid socket leaks — * under HR8d the AHP transport is persistent and only closes here. */ close(): Promise; } /** Progress event emitted during environment provisioning. */ export interface ProvisionEvent { stage: string; message: string; progress: number; } /** Base configuration shared by all environment adapters. */ export interface BaseEnvironmentConfig { /** Override the default PowerLine port. */ port?: number; /** Override the host to connect to. */ host?: string; } /** Contract that all environment adapter backends must implement. */ export interface EnvironmentAdapter { type: string; /** Provision infrastructure and yield progress events. */ provision(environmentId: string, config: Record, powerlineToken: string): AsyncGenerator; /** Establish a gRPC connection to the PowerLine running in the environment. */ connect(environmentId: string, config: Record, powerlineToken: string): Promise; /** Release resources associated with a connection without stopping the environment. */ disconnect(environmentId: string): Promise; /** Stop the environment's underlying compute (e.g. stop a Docker container). */ stop(environmentId: string, config: Record): Promise; /** Permanently destroy the environment's underlying compute. */ destroy(environmentId: string, config: Record): Promise; /** Return true if the PowerLine is reachable via ping. */ healthCheck(connection: PowerLineConnection): Promise; /** Attempt fast reconnect without re-bootstrapping. Throws if PowerLine cannot be restarted. */ reconnect?(environmentId: string, config: Record, powerlineToken: string): AsyncGenerator; } /** * Try fast reconnect if the adapter supports it and the environment was * previously bootstrapped, falling back to full provision on any error. * * Yields {@link ProvisionEvent}s from whichever path runs, allowing callers * (gRPC streaming and WebSocket broadcast) to forward them uniformly. */ export declare function reconnectOrProvision(environmentId: string, adapter: EnvironmentAdapter, config: Record, powerlineToken: string, bootstrapped: boolean, force?: boolean, logger?: AdapterLogger): AsyncGenerator; //# sourceMappingURL=adapter.d.ts.map