import type { CoreDependencies, CoreProjectPaths, CoreRelay } from '../commands/core.js'; type UpOptions = { spawn?: boolean; background?: boolean; verbose?: boolean; workspaceKey?: string; stateDir?: string; brokerName?: string; }; type DownOptions = { force?: boolean; all?: boolean; timeout?: string; stateDir?: string; }; export interface BrokerConnection { url: string; port: number; api_key: string; pid: number; } /** * Read the broker's connection.json file from the data directory. * Returns null if the file doesn't exist or is invalid. */ export declare function readBrokerConnection(dataDir: string): BrokerConnection | null; /** * Extract a human-meaningful detail string from an error, walking `err.cause`. * * Node's native `fetch()` throws `TypeError: fetch failed` for any network * problem and stuffs the real reason (ECONNREFUSED, ENOTFOUND, AbortError, * UND_ERR_CONNECT_TIMEOUT, …) into `err.cause`. Without unwrapping, every * outbound HTTP failure looks identical to the user. * * Exported for testing. */ export declare function describeError(err: unknown): string; /** * Pick the best `error_class` for telemetry. Prefer a network-style code from * `err.cause` (ECONNREFUSED etc.) over the generic constructor name (TypeError) * — a code is more actionable in PostHog and matches the schema's example * values for `BrokerStartFailedEvent.error_class`. * * Exported for testing. */ export declare function classifyBrokerStartError(err: unknown): string; /** Exported for testing. */ export declare function classifyBrokerStartStage(_err: unknown, message: string): string; /** * The broker base port. `AGENT_RELAY_BROKER_PORT` overrides the default so * multiple brokers can run side by side (e.g. in tests); the broker HTTP API * binds near `basePort + 1` with fallback scanning. */ export declare function resolveBrokerBasePort(deps: Pick): number; export declare function startBrokerWithPortFallback(paths: CoreProjectPaths, basePort: number, deps: CoreDependencies, brokerName?: string): Promise<{ relay: CoreRelay; apiPort: number; }>; export declare function runUpCommand(options: UpOptions, deps: CoreDependencies): Promise; export declare function runDownCommand(options: DownOptions, deps: CoreDependencies): Promise; export declare function runStatusCommand(deps: CoreDependencies, options?: { stateDir?: string; waitFor?: string; }): Promise; export {}; //# sourceMappingURL=broker-lifecycle.d.ts.map