/**
 * Build the isError response returned when a tool is called without
 * clarificationAnswers while a pending token exists.
 *
 * The mandate text names AskUserQuestion explicitly so the LLM knows
 * exactly what to do. The structuredContent provides machine-readable
 * context for retrying.
 */
export function buildGateError(token) {
    const n = token.questions.length;
    const mandate = `Must call AskUserQuestion first. Cannot proceed without user answers to ` +
        `the ${String(n)} question${n === 1 ? '' : 's'} emitted on ${token.emittedAt}. ` +
        `Use Claude Code's AskUserQuestion tool, collect the user's selections, ` +
        `then retry ${token.toolName} with clarificationAnswers: { <questionKey>: <optionValue>, ... }.`;
    const exampleAnswers = {};
    for (const q of token.questions) {
        const key = q.header;
        const firstOption = q.options[0]?.label ?? '<value>';
        exampleAnswers[key] = firstOption;
    }
    return {
        isError: true,
        content: [{ type: 'text', text: mandate }],
        structuredContent: {
            pendingQuestions: token.questions,
            retryExample: {
                toolName: token.toolName,
                arguments: { clarificationAnswers: exampleAnswers },
            },
        },
    };
}
//# sourceMappingURL=error-builder.js.map