"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getValidAiQueryLimit = getValidAiQueryLimit;
exports.validateAgentSuggestion = validateAgentSuggestion;
function getValidAiQueryLimit(limit, maxLimit) {
    if (!limit) {
        return maxLimit;
    }
    return Math.min(limit, maxLimit);
}
// Drops chips that point at things the user can't actually reach — explores
// they don't have, navigate URLs that didn't resolve. This is the floor —
// even if the system prompt drifts, the model literally cannot land a chip
// referencing a made-up explore or an unresolvable thread.
function validateAgentSuggestion(chip, catalog) {
    if (chip.kind === 'navigate') {
        if (!chip.url || chip.url.length === 0) {
            return { valid: false, reason: 'navigate chip missing url' };
        }
        return { valid: true };
    }
    if (chip.defaults.explore !== null) {
        if (!catalog.exploreNames.has(chip.defaults.explore)) {
            return {
                valid: false,
                reason: `unknown explore "${chip.defaults.explore}"`,
            };
        }
    }
    return { valid: true };
}
//# sourceMappingURL=validators.js.map