import type { MessageList } from '../../../message-list/index.js';
import type { RunRegistryEntry } from '../../types.js';
/**
 * A background tool result this process applied, kept so later steps can write it into their transcript.
 *
 * `onResult` writes a finished task into the message list the tool-call step held. Later steps rebuild
 * the transcript from workflow state, which still holds the placeholder, so without this the next model
 * call would see the placeholder and the final save would write it over the stored result.
 */
export type BackgroundResultRecord = {
    toolCallId: string;
    /** Resolves once `onResult` has finished, whether or not it applied the result. */
    settled: Promise<unknown>;
    done?: boolean;
    /** Writes the result into a transcript without saving it. Set by `onResult`. */
    apply?: (messageList: MessageList) => Promise<void>;
};
/** Returns the record for `taskId`, replacing one left by an earlier attempt of the tool-call step. */
export declare function recordBackgroundResult(entry: RunRegistryEntry, taskId: string, toolCallId: string, settled: Promise<unknown>): BackgroundResultRecord;
/** Whether `onResult` has applied any result that a transcript may still need. */
export declare function hasAppliedBackgroundResults(entry: RunRegistryEntry | undefined): boolean;
/**
 * Writes every result `onResult` has applied into `messageList` where it still shows that task's
 * placeholder. Returns whether anything changed.
 */
export declare function foldBackgroundResults(entry: RunRegistryEntry | undefined, messageList: MessageList): Promise<boolean>;
/**
 * A task's status turns terminal before its `onResult` hook runs. Waits for the hooks of recorded tasks
 * that `isFinished` reports done, giving up after `timeoutMs` so a lost completion event cannot hang the step.
 */
export declare function settleFinishedBackgroundResults(entry: RunRegistryEntry | undefined, isFinished: (taskId: string) => Promise<boolean>, timeoutMs: number): Promise<void>;
//# sourceMappingURL=background-results.d.ts.map