import type { ProfileName } from '../config.js';
import type { UniversalRuntime } from './universal.js';
import { type NodeRuntimeOptions } from './node.js';
import type { CapabilityModule } from './agentHost.js';
import type { AgentCallbacks } from '../core/agent.js';
import type { ToolRuntimeObserver, ToolSuite } from '../core/toolRuntime.js';
import type { ConversationMessage } from '../core/types.js';
import type { AgentEventUnion, CapabilityManifest, IAgentController, ModelConfig } from '../contracts/v1/agent.js';
interface EventSinkRef {
    current: EventStream<AgentEventUnion> | null;
}
declare class EventStream<T> implements AsyncIterableIterator<T> {
    private readonly queue;
    private pending;
    private closed;
    private failure;
    push(value: T): void;
    close(): void;
    fail(error: Error): void;
    next(): Promise<IteratorResult<T>>;
    return(): Promise<IteratorResult<T>>;
    throw(error: unknown): Promise<IteratorResult<T>>;
    [Symbol.asyncIterator](): AsyncIterableIterator<T>;
}
interface AgentControllerDependencies {
    runtime: UniversalRuntime;
    sinkRef: EventSinkRef;
    externalCallbacks?: AgentCallbacks;
}
export interface AgentControllerCreateOptions extends Omit<NodeRuntimeOptions, 'toolObserver'> {
    profile: ProfileName;
    workspaceContext: string | null;
    workingDir: string;
    modules?: CapabilityModule[];
    callbacks?: AgentCallbacks;
    /** Skip provider discovery for faster startup (used in quick mode) */
    skipProviderDiscovery?: boolean;
}
export declare function createAgentController(options: AgentControllerCreateOptions, additionalObserver?: ToolRuntimeObserver): Promise<AgentController>;
export declare class AgentController implements IAgentController {
    private readonly session;
    private readonly sinkRef;
    private readonly externalCallbacks;
    private activeSink;
    private agent;
    private cachedHistory;
    private selection;
    /** Set of providers that have failed with non-retryable errors in this session */
    private failedProviders;
    /** Maximum fallback attempts per send() call */
    private static readonly MAX_FALLBACK_ATTEMPTS;
    private activeTimeout;
    private inflightReject;
    constructor(dependencies: AgentControllerDependencies);
    private buildInitialSelection;
    private ensureAgent;
    private createAgentCallbacks;
    /**
     * Check if content looks like garbage/leaked reasoning fragments.
     * Returns true if the content should be filtered out.
     * NOTE: Keep this minimal to avoid suppressing legitimate short responses.
     */
    private isGarbageContent;
    private emitDelta;
    private emitError;
    private emitReasoning;
    private emitUsage;
    private handleEditExplanation;
    private handleAssistantMessage;
    private updateCachedHistory;
    cancel(reason?: string): void;
    private clearActiveTimeout;
    private rejectInflight;
    send(message: string): AsyncIterableIterator<AgentEventUnion>;
    switchModel(config: ModelConfig): Promise<void>;
    getCapabilities(): CapabilityManifest;
    registerToolSuite(suiteId: string, suite: ToolSuite): void;
    unregisterToolSuite(suiteId: string): void;
    getHistory(): ConversationMessage[];
    clearHistory(): void;
    /**
     * Check if the controller is currently processing a message.
     */
    isProcessing(): boolean;
    /**
     * Force-clear any lingering active state. Use this before starting a new
     * operation (like attack tournament) to ensure clean state.
     * This will close any active sink without waiting for completion.
     */
    forceReset(): void;
    /**
     * Sanitize history by fixing orphaned tool calls (tool_calls without corresponding tool results).
     * This can happen when a run is interrupted mid-tool-execution.
     * We add placeholder error results for any orphaned tool calls to keep history valid.
     */
    sanitizeHistory(): void;
    private toModelConfig;
    /**
     * Find the next available provider for fallback.
     * Excludes providers that have already failed in this session.
     */
    private findFallbackProvider;
    /**
     * Emit a provider fallback event
     */
    private emitFallbackEvent;
    /**
     * Attempt to switch to a fallback provider
     */
    private attemptFallback;
    getToolSuites(): ToolSuite[];
}
export {};
//# sourceMappingURL=agentController.d.ts.map