/** * Extension loader — topological sort, lifecycle management, preset flattening. * * @module extensions/loader */ import type { ExtensionLogger, ResolvedExtension } from "./types.js"; /** Options for {@link ExtensionLoader.setupAll}. */ export interface SetupAllOptions { /** * Per-extension setup() timeout in milliseconds. * Defaults to 30 000 ms. Pass `0` to disable. */ setupTimeoutMs?: number; /** * @internal Runs after candidate preflight but before this candidate owns the * process-wide transition fence. It may finish cleanup for an already * failed transition, but must not retire the currently active generation. */ beforeTransition?: () => void | Promise; /** * @internal Runs after the candidate plan is fully preflighted but before * any current generation is torn down or candidate side effects begin. * Reserved for the process-wide orchestration coordinator. */ beforeActivate?: () => void | Promise; } /** * Implement extension loader. * * Direct loader instances share the process-global contract registry and must * not run overlapping generations. Production callers should use * `orchestrateExtensions()`, which coordinates generation ownership. */ export declare class ExtensionLoader { private readonly logger; private setupOrder; private primed; private contractGeneration; private contractGenerationActivationFailed; private lifecycleTail; private readonly lateSetups; private quarantineFailure; constructor(logger: ExtensionLogger); /** * Register contracts that will be re-applied after each `setupAll()` * teardown pass. Used by `orchestrateExtensions()` to seed infrastructure * (e.g. `LLMProviderRegistry`) before per-extension `setup()` runs. */ primeContracts(contracts: Record): void; /** * Flatten presets: extensions with `extends` are replaced by their children. * Recurses through nested presets; throws on cyclic `extends` graphs rather * than stack-overflowing. */ flattenPresets(extensions: ResolvedExtension[]): ResolvedExtension[]; private flattenPresetsInner; private snapshotPresetMetadata; /** * Topological sort: priority-winning providers load before consumers. * Throws on duplicate names at equal priority and circular dependencies. */ topologicalSort(extensions: ResolvedExtension[]): ResolvedExtension[]; private topologicalSortWithProviders; private normalizeExtensionNames; /** * Run the full setup lifecycle for all extensions. * Calls on the same loader are serialized; a valid replacement tears down * the previous generation before activation. */ setupAll(extensions: ResolvedExtension[], projectConfig: Record, options?: SetupAllOptions): Promise; private setupAllInternal; private materializeExtensions; private prepareLoadPlan; private snapshotActivationMetadataFor; private snapshotActivationMetadata; private snapshotContractMetadata; private assertRequiredContractsAvailable; private assertWinningContractsWereProvided; private normalizeSetupTimeout; private createExtensionContext; private runExtensionSetup; private registerOwned; private revokeAuthority; private trackTimedOutCleanup; private waitForLateSetups; /** * @internal Wait for setup work that outlived a timeout and its final cleanup. * Used by the orchestration coordinator after `setupAll()` has already * rejected; not a general replacement for `teardownAll()`. */ awaitLateSetupCleanup(): Promise; /** Teardown all loaded extensions in reverse order. */ teardownAll(): Promise; private runTeardownBarrier; private teardownAllInternal; private throwIfQuarantined; private enqueueLifecycle; private assertValidExtension; } //# sourceMappingURL=loader.d.ts.map