export function validateProviderDecision(input) {
    const disallowedKnownToolSelection = input.threadMode !== "plan"
        ? input.selectedToolCalls.find((toolCall) => input.knownToolNames.includes(toolCall.toolName) &&
            !input.profileAllowedToolNames.includes(toolCall.toolName))
        : undefined;
    if (disallowedKnownToolSelection) {
        return {
            errorCode: "TOOL_NOT_ALLOWED",
            invalidToolCall: disallowedKnownToolSelection,
            message: `Tool ${disallowedKnownToolSelection.toolName} is not allowed by the ${input.profileName} profile.`,
            ok: false,
            reasonCode: "tool-not-allowed",
            source: "profile",
        };
    }
    const requiredToolConstraint = input.requiredToolConstraint;
    const forbiddenToolSelection = requiredToolConstraint
        ? input.selectedToolCalls.find((toolCall) => input.knownToolNames.includes(toolCall.toolName) &&
            requiredToolConstraint.forbiddenToolNames.includes(toolCall.toolName))
        : undefined;
    if (requiredToolConstraint && forbiddenToolSelection) {
        return {
            errorCode: "TOOL_NOT_ALLOWED",
            invalidToolCall: forbiddenToolSelection,
            message: `Tool ${forbiddenToolSelection.toolName} is explicitly forbidden for this turn.`,
            ok: false,
            reasonCode: "tool-not-allowed",
            source: "required-tool",
        };
    }
    const unavailableToolSelection = input.selectedToolCalls.find((toolCall) => !input.visibleTools.some((tool) => tool.name === toolCall.toolName));
    if (unavailableToolSelection) {
        return {
            errorCode: "TOOL_NOT_ALLOWED",
            invalidToolCall: unavailableToolSelection,
            message: `Tool ${unavailableToolSelection.toolName} is not available for this turn.`,
            ok: false,
            reasonCode: "tool-not-visible",
            source: "visibility",
        };
    }
    return { ok: true };
}
//# sourceMappingURL=provider-decision-validator.js.map