import { readRunMetaBySlug } from './run-meta.js';
export function resolveRetryMetadataFromRunMeta(runMeta) {
    if (!runMeta) {
        return {};
    }
    const resumePoint = runMeta.resumePoint;
    const rootStep = resumePoint?.stack[0]?.step ?? runMeta.currentStep;
    const currentIteration = resumePoint?.iteration ?? runMeta.currentIteration;
    return {
        ...(rootStep ? { startStep: rootStep } : {}),
        ...(resumePoint ? { resumePoint } : {}),
        ...(currentIteration !== undefined ? { currentIteration } : {}),
    };
}
export function readRetryMetadataByRunSlug(cwd, runSlug, onWarning) {
    let parseFailed = false;
    const runMeta = readRunMetaBySlug(cwd, runSlug, (warning) => {
        parseFailed = true;
        onWarning?.(warning);
    });
    if (!runMeta) {
        return parseFailed ? { preserveExisting: true } : {};
    }
    return resolveRetryMetadataFromRunMeta(runMeta);
}
//# sourceMappingURL=retry-metadata.js.map