/**
 * ExtensionLifecycle — owns extension runner creation, binding, reload,
 * and tool-registry refresh.
 *
 * Extracted from AgentSession to isolate extension lifecycle orchestration
 * behind a clean boundary. No behavior changes — pure refactoring.
 */
import type { Model } from '../../ai/types.js';
import type { AgentModelRegistry } from '../../contracts/agent-model.js';
import type { RuntimeResourceLoader } from '../../contracts/agent-resources.js';
import type { RuntimeSessionStore } from '../../contracts/agent-session-store.js';
import type { RuntimeReloadableSettingsStore } from '../../contracts/agent-settings.js';
import type { AgentMessage, ToolDefinition } from '../../core/index.js';
import type { RuntimePermissionPolicy } from '../../core/permission-policy.js';
import { SessionState } from '../../core/session-state.js';
import type { ExtensionErrorListener, ShutdownHandler } from '../extensions/runner.js';
import { ExtensionRunner } from '../extensions/runner.js';
import type { ContextUsage, ExtensionCommandContextActions, ExtensionUIContext } from '../extensions/types.js';
import type { ToolRegistry } from './tool-registry.js';
export interface ExtensionBindings {
    uiContext?: ExtensionUIContext;
    commandContextActions?: ExtensionCommandContextActions;
    shutdownHandler?: ShutdownHandler;
    onError?: ExtensionErrorListener;
}
/**
 * Callbacks into AgentSession internals that ExtensionLifecycle cannot own
 * directly. Provided at construction time.
 */
export interface ExtensionLifecycleCallbacks {
    getModel(): Model<any> | undefined;
    isIdle(): boolean;
    abort(): Promise<void>;
    hasPendingMessages(): boolean;
    shutdown(): void;
    getContextUsage(): ContextUsage | undefined;
    compact(options?: {
        customInstructions?: string;
        onComplete?: (result: any) => void;
        onError?: (error: Error) => void;
    }): void;
    getSystemPrompt(): string;
    appendEntry(customType: string, data: unknown): void;
    deductChildUsage(usage: {
        input: number;
        output: number;
        turns: number;
    }): void;
    getMessages(): AgentMessage[];
    getTools(): readonly ToolDefinition[];
    getPermissionPolicy(): RuntimePermissionPolicy;
}
export interface ExtensionLifecycleConfig {
    resourceLoader: RuntimeResourceLoader;
    cwd: string;
    extensionRunnerRef?: {
        current?: ExtensionRunner;
    };
    runtimeTools: ToolDefinition[];
    reloadTools?: () => Promise<{
        tools: ToolDefinition[];
        warnings: string[];
    }>;
    sessionManager: RuntimeSessionStore;
    modelRegistry: AgentModelRegistry;
    sessionState: SessionState;
    settingsManager: RuntimeReloadableSettingsStore;
    tools: ToolRegistry;
}
export declare class ExtensionLifecycle {
    private _extensionRunner;
    private _extensionRunnerRef?;
    private _extensionUIContext?;
    private _extensionCommandContextActions?;
    private _extensionShutdownHandler?;
    private _extensionErrorListener?;
    private _extensionErrorUnsubscriber?;
    private _runtimeTools;
    private _reloadTools?;
    private readonly _resourceLoader;
    private readonly _cwd;
    private readonly _sessionManager;
    private readonly _modelRegistry;
    private readonly _sessionState;
    private readonly _settingsManager;
    private readonly _tools;
    private readonly _callbacks;
    constructor(config: ExtensionLifecycleConfig, callbacks: ExtensionLifecycleCallbacks);
    get extensionRunner(): ExtensionRunner | undefined;
    get runtimeTools(): ToolDefinition[];
    /**
     * Build the extension runtime: create the ExtensionRunner, bind core
     * actions, apply UI bindings, and refresh the tool registry.
     */
    buildRuntime(options: {
        toolNames?: string[];
        modeName?: string;
    }): void;
    /**
     * Apply extension bindings (UI context, command context, shutdown, error),
     * emit session_start, and discover extension resources.
     */
    bindExtensions(bindings: ExtensionBindings): Promise<void>;
    /**
     * Reload extensions, settings, model registry, resource loader, and tools.
     * Returns warnings from the reload process.
     */
    reload(): Promise<{
        warnings: string[];
    }>;
    /**
     * Refresh the tool registry with the current extension runner and tools.
     */
    refreshToolRegistry(options?: {
        toolNames?: string[];
        modeName?: string;
    }): void;
    private _extendResourcesFromExtensions;
    private _applyExtensionBindings;
    private _bindExtensionCore;
}
//# sourceMappingURL=extension-lifecycle.d.ts.map