using CursorLang.Core.Services; namespace CursorLang.Agent; internal static class Program { /// /// A single-threaded apartment because of the caret: AccessibleObjectFromWindow /// and UI Automation both go through COM, and both expect the thread that calls them /// to be an STA one. /// [STAThread] private static int Main(string[] arguments) { bool automatic = StartupLaunch.IsAutomatic(arguments); var gate = new SingleInstanceGate(SingleInstanceGate.AgentName); // A second launch is the user asking for the application, so the one already // running opens the settings window and this one steps aside. A second launch // by Windows at sign-in asks for nothing and gets nothing if (!gate.TryAcquire(showRunningInstance: !automatic)) { gate.Dispose(); return 0; } try { using var agent = new Agent(gate); return agent.Run(automatic); } finally { gate.Dispose(); } } }