/**
 * Extension Loader and Registry
 *
 * Supports three-tier extension storage:
 * 1. Workspace level (workspace/.extensions/) - highest priority
 * 2. Global level (~/.xopc/extensions/) - shared across workspaces
 * 3. Bundled level (xopc/extensions/) - shipped with xopc
 */
import type { Config } from '../config/config-surface.js';
import type { MessageBus } from '../infra/bus/index.js';
import type { SessionIndex } from '../session/manager.js';
import type { ExtensionApi, ExtensionManifest, ResolvedExtensionConfig, DiscoveredExtension } from './types/index.js';
import type { ActivationContext } from './activation-planner.js';
import { ActivationPlanner, type ActivationLoadPhase } from './activation-planner.js';
import { type ExtensionLoaderOptions } from './discover-extensions.js';
import type { ExtensionMetadataSnapshot } from './extension-metadata-snapshot.js';
import { ManifestRegistry } from './manifest-registry.js';
import { type SecurityConfig } from './security.js';
import { type ProviderPluginRegistry } from '../providers/plugin-registry.js';
import { type SlotRegistry } from './slots.js';
import { type ExtensionDiagnostics } from './diagnostics.js';
export type { ExtensionLoaderOptions, ExtensionSourceOrigin } from './discover-extensions.js';
export { areExtensionsGloballyDisabled } from './discover-extensions.js';
export { ExtensionRegistryImpl } from './extension-registry-impl.js';
import { ExtensionRegistryImpl } from './extension-registry-impl.js';
export interface ActivationPlanLoadOptions extends Partial<ActivationContext> {
    phase?: ActivationLoadPhase | 'all';
}
export declare class ExtensionLoader {
    private registry;
    private options;
    private extensionInstances;
    private jiti;
    private _appConfig?;
    private _runtimeContext?;
    private securityConfig;
    private providerRegistry;
    private slotRegistry;
    private slotsConfig;
    private cache;
    private diagnostics;
    /** Manifest-only registry cache (no runtime module load). */
    private manifestRegistry;
    private manifestSnapshot;
    constructor(options?: ExtensionLoaderOptions);
    /**
     * Reuse a pre-built metadata snapshot (avoids duplicate filesystem discovery).
     */
    setManifestSnapshot(snapshot: ExtensionMetadataSnapshot | null): void;
    getManifestSnapshot(): ExtensionMetadataSnapshot | null;
    /**
     * Set security configuration
     */
    setSecurityConfig(config: Partial<SecurityConfig>): void;
    /**
     * Get security configuration
     */
    getSecurityConfig(): SecurityConfig;
    /**
     * Get provider registry
     */
    getProviderRegistry(): ProviderPluginRegistry;
    /**
     * Get slot registry
     */
    getSlotRegistry(): SlotRegistry;
    /**
     * Get diagnostics
     */
    getDiagnostics(): ExtensionDiagnostics;
    /**
     * Set configuration from main Config object
     */
    setConfig(config: Config): void;
    /**
     * Inject MessageBus and optional SessionManager for ExtensionApi.runtime (Gateway).
     */
    setRuntimeContext(ctx: {
        bus: MessageBus;
        sessionManager?: SessionIndex;
        scheduleWebchatContinuation?: (sessionKey: string, message: string) => void;
    }): void;
    getRegistry(): ExtensionRegistryImpl;
    /**
     * Phase 1: build manifest registry (filesystem manifests only, no extension code load).
     */
    buildManifestRegistry(): ManifestRegistry;
    /**
     * Phase 2: activation planner over the manifest registry (pure logic).
     */
    planActivation(_context?: Partial<ActivationContext>): ActivationPlanner;
    /**
     * Phase 3: load only extensions selected by the activation plan.
     */
    loadByActivationPlan(context?: ActivationPlanLoadOptions): Promise<void>;
    getManifestRegistry(): ManifestRegistry;
    invalidateManifestCache(): void;
    private resolveExtensionConfig;
    /**
     * Discover extensions from all three tiers:
     * 1. Workspace (.extensions/) - highest priority
     * 2. Global (~/.xopc/extensions/) - shared
     * 3. Bundled (xopc/extensions/) - lowest priority
     */
    discoverExtensions(): DiscoveredExtension[];
    /**
     * Load all discovered extensions
     */
    loadAllExtensions(enabledIds?: string[]): Promise<void>;
    loadExtensions(configs: ResolvedExtensionConfig[]): Promise<void>;
    loadExtension(config: ResolvedExtensionConfig): Promise<ExtensionApi | null>;
    /**
     *  Claim extension slots based on manifest kind
     * Respects configured preferred plugin from config.extensions.slots
     */
    private claimExtensionSlots;
    loadManifest(extensionPath: string): ExtensionManifest | null;
    /**
     * Build candidate extension entry paths. After `tsdown`, manifests may still
     * point at `*.ts` while the shipped tree only contains the emitted `*.js`.
     */
    private moduleEntryCandidates;
    private loadModule;
    private createExtensionApi;
    private initializeExtension;
    startServices(): Promise<void>;
    stopServices(): Promise<void>;
    /**
     * Basic type validation for config values
     */
    private validateType;
}
export declare function resolveExtensionPath(id: string, _options: ExtensionLoaderOptions): string | null;
export declare function normalizeExtensionConfig(rawConfig: Record<string, unknown>): ResolvedExtensionConfig[];
