Back to List
Adrafinil: A New macOS Utility Designed to Keep Laptops Awake Exclusively During AI Agent Activity
Product LaunchmacOSAI AgentsOpen Source

Adrafinil: A New macOS Utility Designed to Keep Laptops Awake Exclusively During AI Agent Activity

Adrafinil is an innovative macOS menu bar application that introduces a "eugeroic" approach to machine power management. Unlike traditional utilities that keep a computer awake indefinitely, Adrafinil prevents a Mac from sleeping—including in clamshell (lid-closed) mode—only while an AI coding agent is actively performing a task. Supporting popular agents such as Claude Code, Codex, and Cursor, the tool ensures that long-running AI sessions are not interrupted when the user closes the laptop lid. Once the agent completes its work and releases the session, Adrafinil allows the system to return to its normal sleep behavior immediately. By utilizing a secure, audited helper for privileged sleep control and standard system assertions, Adrafinil offers a specialized solution for developers and AI users who require automated, task-aware system wakefulness.

Hacker News

Key Takeaways

  • Agent-Aware Power Management: Adrafinil only prevents sleep when at least one AI agent session is active, distinguishing it from "always-on" utilities.
  • Clamshell Mode Support: The tool allows a Mac to continue working with the lid closed, specifically overriding default macOS sleep behavior for active tasks.
  • Broad Integration: It features hook integration for nine different agents, including Claude Code, Codex, and Cursor.
  • Security-First Architecture: To handle privileged sleep overrides, Adrafinil uses a tiny, audited helper to isolate root-level commands from the main application logic.
  • Automated Efficiency: The system returns to normal sleep settings the moment the last active agent session finishes, ensuring no unnecessary power consumption.

In-Depth Analysis

The "Eugeroic" Philosophy vs. Traditional Stimulants

In the realm of macOS power management, tools like caffeinate and Amphetamine have long served as "stimulants" for hardware, keeping the machine "wired" and awake regardless of whether actual work is being performed. Adrafinil introduces a different philosophy, described by its creators as a "eugeroic" for machines. In medical terms, a eugeroic is a wakefulness-promoting agent; applied to software, Adrafinil acts as a smart intermediary that only intervenes when there is a specific reason for the machine to stay awake.

The primary use case addressed is the late-night developer workflow. When a user starts a complex AI agent session at 3 a.m. and decides to go to sleep, they often close the laptop lid. Under normal circumstances, this would suspend the AI's progress. Adrafinil solves this by monitoring the state of the AI agent. If an agent is "mid-thought," the utility keeps the system active. The moment the agent finishes its task, the utility "gets out of the way," allowing both the user and the machine to sleep normally. This "agent-aware" logic ensures that the hardware state is always synchronized with the software's workload.

Technical Implementation and Security

Overriding the macOS "clamshell" sleep (lid-closed sleep) is a privileged operation that requires root access. To maintain a high standard of security, Adrafinil does not run the entire application with elevated privileges. Instead, it employs a bifurcated architecture. All policy decisions and user interface elements live in an unprivileged daemon. The actual sleep override is handled by a "tiny, audited helper" that only exposes a single function: setSleepBlocked(Bool).

Technically, the application manages sleep through two primary mechanisms. For standard idle sleep, it holds a standard IOPMAssertion. For the more complex task of preventing sleep when the lid is closed, it utilizes the pmset disablesleep command. The developers noted that they verified this approach on-device after determining that cleaner, private IOPMrootDomain paths were insufficient for keeping a displayless, lid-closed Mac awake. This robust technical foundation ensures that the utility works reliably across different macOS power states while minimizing the security surface area.

Integration and User Experience

Adrafinil is designed for ease of use within the modern AI development ecosystem. It includes a one-click installer that wires the utility into a hook system, allowing it to detect sessions from various AI tools automatically. Currently, the project supports nine different agents, specifically mentioning high-profile tools like Claude Code, Codex, and Cursor.

The user experience is centered around a menu bar app that provides a "zero-intervention" workflow. Once installed and configured, the user does not need to manually toggle the app on or off. The transition from "blocked sleep" to "normal sleep" is entirely dependent on the presence of active agent sessions. This automation removes the cognitive load of remembering to disable a wake utility after a task is finished, preventing the common issue of a laptop staying awake in a bag and overheating or draining its battery.

Industry Impact

The release of Adrafinil highlights a growing trend in the AI industry: the shift from interactive AI to autonomous, long-running agents. As AI agents move from simple chat interfaces to complex, multi-hour coding and reasoning tasks, the underlying operating systems and hardware management tools must evolve to support these "background" workloads.

Adrafinil represents a niche but essential category of "agent-aware infrastructure." By bridging the gap between high-level AI task states and low-level system power management, it enables a more seamless integration of autonomous agents into the daily lives of developers. Furthermore, its open-source nature and focus on audited, minimal-privilege code set a standard for how third-party utilities should handle sensitive system controls in an era where security is paramount.

Frequently Asked Questions

Question: How does Adrafinil differ from apps like Amphetamine or the native 'caffeinate' command?

Adrafinil is "agent-aware" rather than "always-on." While Amphetamine and caffeinate keep a Mac awake until a timer runs out or a user manually toggles them off, Adrafinil only blocks sleep while an AI agent (like Claude Code or Cursor) is actively working. It automatically allows the Mac to sleep the moment the agent finishes its task.

Question: Does Adrafinil require special permissions to work with the lid closed?

Yes. Preventing a Mac from sleeping when the lid is closed (clamshell mode) requires root privileges. Adrafinil handles this securely by using a small, audited helper tool that specifically manages the setSleepBlocked command, while the rest of the app runs without elevated privileges.

Question: Which AI agents are currently supported by Adrafinil?

Adrafinil features hook integration for nine agents. The documentation specifically highlights support for Claude Code, Codex, and Cursor, ensuring that these tools can maintain active sessions even if the user closes their laptop lid.

Related News

Product Launch

Kimi K3-256k Launch: Optimizing Flagship Coding Performance with Tiered Context Windows

Kimi Code has officially introduced the Kimi K3-256k model, a context-optimized version of its flagship 2.8T parameter Kimi K3 model. This new iteration is designed to deliver identical performance to the 1M context version within a 256k limit while reducing quota consumption by approximately 50%. The update provides a comprehensive overview of the Kimi model ecosystem, including the K2.7 Code series for routine development. Crucially, the documentation outlines specific technical protocols for switching between models, emphasizing the 'compact' process required for context management in tools like Kimi Code CLI and Claude Code. Users are also cautioned regarding the lack of video input support in the K3-256k version, necessitating strategic session management when transitioning between high-capacity and high-efficiency models.

Google DeepMind Launches Lyria 3.5 in Google Flow Music: Advancing AI Musicality and Creative Control
Product Launch

Google DeepMind Launches Lyria 3.5 in Google Flow Music: Advancing AI Musicality and Creative Control

Google DeepMind has officially announced the launch of Lyria 3.5, the latest evolution of its sophisticated music generation model, now integrated into Google Flow Music. This update represents a significant milestone in generative AI, focusing on four primary pillars of improvement: musicality, lyrics, vocals, and creative control. By refining these core elements, Lyria 3.5 aims to bridge the gap between AI-generated content and professional-grade musical composition. The integration within Google Flow Music suggests a streamlined workflow for creators, emphasizing a more intuitive and powerful user experience. This launch underscores Google's ongoing commitment to leading the frontier of AI-driven creative tools, providing users with enhanced capabilities to shape and direct the musical output with greater precision and artistic nuance.

OpenAI Launches Codex Security: A New CLI and TypeScript SDK for Automated Vulnerability Detection and Remediation
Product Launch

OpenAI Launches Codex Security: A New CLI and TypeScript SDK for Automated Vulnerability Detection and Remediation

OpenAI has introduced Codex Security, a powerful toolset designed to identify, validate, and fix security vulnerabilities within codebases. Available as both a Command Line Interface (CLI) and a TypeScript Software Development Kit (SDK), Codex Security enables developers to scan repositories, review code changes, and track security findings over time. The tool is built for modern development workflows, offering seamless integration into Continuous Integration (CI) pipelines. Requiring Node.js 22 and Python 3.10, the system supports multiple authentication methods, including ChatGPT sign-in and API keys. By providing a programmatic way to manage security state and automate remediation, OpenAI aims to streamline the DevSecOps process, allowing teams to maintain more secure codebases through AI-driven analysis.