/**
 * Blocked state handler for workflow execution
 *
 * Handles the case when an agent returns a blocked status,
 * requesting user input to continue.
 */
import { extractBlockedPrompt } from './transitions.js';
/**
 * Handle blocked status by requesting user input.
 *
 * @param step - The step that is blocked
 * @param response - The blocked response from the agent
 * @param options - Workflow engine options containing callbacks
 * @returns Result indicating whether to continue and any user input
 */
export async function handleBlocked(step, response, options) {
    // If no user input callback is provided, cannot continue
    if (!options.onUserInput) {
        return { shouldContinue: false };
    }
    // Extract prompt from blocked message
    const prompt = extractBlockedPrompt(response.content);
    // Build the request
    const request = {
        step,
        response,
        prompt,
    };
    // Request user input
    const userInput = await options.onUserInput(request);
    // If user cancels (returns null), abort
    if (userInput === null) {
        return { shouldContinue: false };
    }
    return {
        shouldContinue: true,
        userInput,
    };
}
//# sourceMappingURL=blocked-handler.js.map