import type { ThinkingLevel } from "@draht/agent-core";
import type { Model } from "@draht/ai";
import { AuthStorage } from "./auth-storage.js";
import type { SessionStartEvent, ToolDefinition } from "./extensions/index.js";
import { ModelRegistry } from "./model-registry.js";
import { type DefaultResourceLoaderOptions, type ResourceLoader } from "./resource-loader.js";
import { type CreateAgentSessionResult } from "./sdk.js";
import { SessionManager } from "./session-manager.js";
import { SettingsManager } from "./settings-manager.js";
import type { Tool } from "./tools/index.js";
/**
 * Stable bootstrap inputs reused whenever the active runtime is replaced.
 *
 * Use this for process-level wiring that should survive `/new`, `/resume`,
 * `/fork`, and import flows. Session-local state belongs in the session file
 * or in settings, not here.
 */
export interface AgentSessionRuntimeBootstrap {
    /** Agent directory used for auth, models, settings, sessions, and resource discovery. */
    agentDir?: string;
    /** Optional shared auth storage. If omitted, file-backed storage under agentDir is used. */
    authStorage?: AuthStorage;
    /** Initial model for the first created session runtime. */
    model?: Model<any>;
    /** Initial thinking level for the first created session runtime. */
    thinkingLevel?: ThinkingLevel;
    /** Optional scoped model list for model cycling and selection. */
    scopedModels?: Array<{
        model: Model<any>;
        thinkingLevel?: ThinkingLevel;
    }>;
    /** Built-in tool set override. */
    tools?: Tool[];
    /** Additional custom tools registered directly through the SDK. */
    customTools?: ToolDefinition[];
    /**
     * Resource loader input used for each created runtime.
     *
     * Pass either a factory that creates a fully custom ResourceLoader for the
     * target cwd, or DefaultResourceLoader options without cwd/agentDir/
     * settingsManager, which are supplied by the runtime.
     */
    resourceLoader?: ((cwd: string, agentDir: string) => Promise<ResourceLoader>) | Omit<DefaultResourceLoaderOptions, "cwd" | "agentDir" | "settingsManager">;
}
/** Options for creating one concrete runtime instance. */
export interface CreateAgentSessionRuntimeOptions {
    /** Working directory for this runtime instance. */
    cwd: string;
    /** Optional preselected session manager. If omitted, normal session resolution applies. */
    sessionManager?: SessionManager;
    /** Optional preloaded resource loader to reuse instead of creating and reloading one. */
    resourceLoader?: ResourceLoader;
    /** Optional session_start metadata to emit when the runtime binds extensions. */
    sessionStartEvent?: SessionStartEvent;
}
type AgentSessionRuntime = CreateAgentSessionResult & {
    cwd: string;
    agentDir: string;
    authStorage: AuthStorage;
    modelRegistry: ModelRegistry;
    settingsManager: SettingsManager;
    resourceLoader: ResourceLoader;
    sessionManager: SessionManager;
};
/**
 * Create one runtime instance containing an AgentSession plus the cwd-bound
 * services it depends on.
 *
 * Most SDK callers should keep the returned value wrapped in an
 * AgentSessionRuntimeHost instead of holding it directly. The host owns
 * replacing the runtime when switching sessions across files or working
 * directories.
 */
export declare function createAgentSessionRuntime(bootstrap: AgentSessionRuntimeBootstrap, options: CreateAgentSessionRuntimeOptions): Promise<AgentSessionRuntime>;
/**
 * Stable wrapper around a replaceable AgentSession runtime.
 *
 * Use this when your application needs `/new`, `/resume`, `/fork`, or import
 * behavior. After replacement, read `session` again and rebind any
 * session-local subscriptions or extension bindings.
 */
export declare class AgentSessionRuntimeHost {
    private readonly bootstrap;
    private runtime;
    constructor(bootstrap: AgentSessionRuntimeBootstrap, runtime: AgentSessionRuntime);
    /** The currently active session instance. Re-read this after runtime replacement. */
    get session(): import("./agent-session.js").AgentSession;
    private emitBeforeSwitch;
    private emitBeforeFork;
    private replace;
    /**
     * Replace the active runtime with one opened from an existing session file.
     *
     * Emits `session_before_switch` before replacement and returns
     * `{ cancelled: true }` if an extension vetoes the switch.
     */
    switchSession(sessionPath: string): Promise<{
        cancelled: boolean;
    }>;
    /**
     * Replace the active runtime with a fresh session in the current cwd.
     *
     * `setup` runs after replacement against the new session manager, which lets
     * callers seed entries before normal use begins.
     */
    newSession(options?: {
        /** Optional parent session path recorded in the new session header. */
        parentSession?: string;
        /** Optional callback for seeding the new session manager after replacement. */
        setup?: (sessionManager: SessionManager) => Promise<void>;
    }): Promise<{
        cancelled: boolean;
    }>;
    /**
     * Replace the active runtime with a fork rooted at the given user-message
     * entry.
     *
     * Returns the selected user text so UIs can restore it into the editor after
     * the fork completes.
     */
    fork(entryId: string): Promise<{
        cancelled: boolean;
        selectedText?: string;
    }>;
    /**
     * Import a JSONL session file into the current session directory and replace
     * the active runtime with the imported session.
     */
    importFromJsonl(inputPath: string): Promise<{
        cancelled: boolean;
    }>;
    /** Emit session shutdown for the active runtime and dispose it permanently. */
    dispose(): Promise<void>;
}
export {};
//# sourceMappingURL=agent-session-runtime.d.ts.map