import { DisposeCallback, ReadonlySubject } from "@iyio/common";
import { Observable } from "rxjs";
import { Conversation, ConversationOptions } from "./Conversation.js";
import { ConvoNodeGraphResult, ConvoNodeGraphState } from "./convo-node-graph-types.js";
import { ConvoCompletion } from "./convo-types.js";
export type ConvoNodeGraphStepCompletionHandler = (completion: ConvoCompletion) => void | Promise<void>;
export interface ConvoNodeGraphCtrlOptions {
    convo: Conversation | string;
    convoOptions?: ConversationOptions;
    maxSteps?: number;
    initCtrl?: (ctrl: ConvoNodeGraphCtrl) => void;
}
export declare class ConvoNodeGraphCtrl {
    readonly conversation: Conversation;
    private readonly options;
    private readonly _onStepComplete;
    get onStepComplete(): Observable<ConvoCompletion>;
    private readonly _result;
    get resultSubject(): ReadonlySubject<ConvoNodeGraphResult | null>;
    get result(): ConvoNodeGraphResult | null;
    private readonly onStepCompleteCallbacks;
    addStepCompletionListener(listener: ConvoNodeGraphStepCompletionHandler): DisposeCallback;
    removeStepCompletionListener(listener: ConvoNodeGraphStepCompletionHandler): void;
    private readonly _state;
    get stateSubject(): ReadonlySubject<ConvoNodeGraphState>;
    get state(): ConvoNodeGraphState;
    private readonly _stepIndex;
    get stepIndexSubject(): ReadonlySubject<number>;
    get stepIndex(): number;
    constructor({ maxSteps, convoOptions, convo, initCtrl, }: ConvoNodeGraphCtrlOptions);
    private _isDisposed;
    get isDisposed(): boolean;
    dispose(): void;
    shouldContinue(): boolean;
    private runPromise?;
    /**
     * Runs a convo node graph by calling `Conversation.completeAsync` in a loop until the graph
     * exists. `runAsync` is guaranteed to not throw an error, the returned result object will
     * contain an error if an error is thrown inside the function.
     */
    runAsync(): Promise<ConvoNodeGraphResult>;
    private _runAsync;
}
