import { isRecord, stringField } from "@best-agent/foundation";
export const COMPACTION_FOLLOW_UP_METADATA_KEY = "pendingCompactionFollowUpOperation";
export function readPendingCompactionFollowUpOperation(metadata) {
    const value = metadata?.[COMPACTION_FOLLOW_UP_METADATA_KEY];
    if (value === "manual-compact-followup" || value === "post-compact-followup") {
        return { id: "legacy", operation: value };
    }
    if (!isRecord(value)) {
        return undefined;
    }
    const id = stringField(value, "id");
    const operation = stringField(value, "operation");
    if (typeof id === "string" &&
        (operation === "manual-compact-followup" || operation === "post-compact-followup")) {
        return { id, operation };
    }
    return undefined;
}
//# sourceMappingURL=compaction-follow-up.js.map