Mayor Michael R. Bloomberg said yesterday that the city had reached agreements with six out-of-state gun dealers, who agreed to let court officials monitor their operations to prevent illegal gun sales. He said that New York had sued 12 additional gun stores to demand similar oversight.