import { ConfigReferenceError } from "@earendil-works/pi-ai/utils/config-reference";
import type { McpServerConfig, McpServerDeclaredConfig, ResolvedMcpServer } from "./config-schema.ts";
import { ConnectError } from "./errors.ts";
type Env = Readonly<Record<string, string | undefined>>;
export interface McpConfigGeneration {
    readonly config: McpServerConfig;
    readonly configHash: string;
}
export interface McpGenerationScope {
    readonly serverName: string;
    readonly declared: McpServerDeclaredConfig;
    readonly env?: Env;
    readonly agentDir?: string;
}
export interface McpGenerationRenewal {
    readonly resolveConfig: () => Promise<McpServerConfig>;
    readonly changed: () => Promise<boolean>;
}
/** A renewal whose snapshot no longer matches the admitted identity opens no transport; its owners re-key. */
export declare class McpConfigGenerationChangedError extends ConnectError {
    constructor(serverName: string);
}
/** One connection generation: every reference resolved into an immutable snapshot, then keyed by it. */
export declare function resolveMcpConfigGeneration(scope: McpGenerationScope): Promise<McpConfigGeneration>;
/** For a server that declares references: every transport re-reads them, and a changed snapshot re-keys. */
export declare function mcpGenerationRenewal(scope: McpGenerationScope, admittedHash: string, rekey: () => void): McpGenerationRenewal | undefined;
/**
 * Resolves every wanted server's generation. A server whose reference fails is recorded in `failures` and
 * removed from `wanted`, so it never connects and never aborts its siblings.
 */
export declare function resolveWantedMcpGenerations(wanted: Map<string, ResolvedMcpServer>, scopeOf: (name: string) => Pick<McpGenerationScope, "env" | "agentDir"> & {
    readonly logDir?: string;
}, failures: Map<string, ConfigReferenceError>): Promise<Map<string, McpConfigGeneration>>;
/**
 * A connection's identity: the declaration hash (which carries a project server's policy identity) plus the
 * resolved generation hash when resolution changed anything. A server without references keeps its plain hash, so
 * existing keys and cached catalogs stay valid.
 */
export declare function mcpConnectionIdentity(declared: string, generation: string | undefined): string;
export {};
//# sourceMappingURL=config-generation.d.ts.map