@narumitw/pi-caffeinate
v0.1.26
Published
Pi extension that keeps the computer awake while the agent is running.
Maintainers
Readme
☕ pi-caffeinate — Keep Your Computer Awake While Pi Works
@narumitw/pi-caffeinate is a cross-platform Pi coding agent extension that prevents your computer from sleeping while the Pi agent is processing a prompt.
It is designed for long-running coding, refactoring, debugging, web research, and autonomous agent workflows where a suspended laptop or desktop would interrupt progress.
✨ Features
- Starts an OS sleep inhibitor when Pi begins processing (
agent_start). - Releases the inhibitor when processing ends (
agent_end) or the session shuts down. - Publishes an
awakestatus only while an inhibitor is active. - Supports macOS, Windows, WSL, and Linux.
- Provides
/caffeinate-statusand/caffeinate-stopcommands. - Allows a custom inhibitor command through environment configuration.
- Fails safely when no supported inhibitor is available.
📦 Install
pi install npm:@narumitw/pi-caffeinateTry without installing permanently:
pi -e npm:@narumitw/pi-caffeinateTry this package locally from the repository root:
pi -e ./extensions/pi-caffeinate🖥️ Supported platforms
- macOS: uses
caffeinate -dimsu. - Windows: uses PowerShell
SetThreadExecutionState. - WSL: uses Windows
powershell.exewithSetThreadExecutionState. - Linux: uses
systemd-inhibitwithsleep infinity. - Linux fallback: uses
caffeinate -dimsuwhen available.
If no supported inhibitor is available, the extension stays loaded and reports that caffeinate is unavailable.
🚀 Commands
/caffeinate-statusShows whether an inhibitor is active, unavailable, or disabled.
/caffeinate-stopManually releases any active inhibitor for the current session.
⚙️ Configuration
Disable the extension:
PI_CAFFEINATE_DISABLED=1 piUse a custom inhibitor command:
PI_CAFFEINATE_COMMAND='systemd-inhibit --what=idle:sleep --why="pi running" --mode=block sleep infinity' piThe custom command is parsed with shell-like quoting and is run directly without a shell.
🧠 Why use pi-caffeinate?
AI coding agents often run tool-heavy tasks that take several minutes. pi-caffeinate keeps your machine awake during active Pi work, helping browser automation, local builds, test runs, code generation, and long prompts finish reliably.
🗂️ Package layout
extensions/pi-caffeinate/
├── src/
│ └── caffeinate.ts
├── README.md
├── LICENSE
├── tsconfig.json
└── package.json🔎 Keywords
Pi extension, Pi coding agent, caffeinate, prevent sleep, keep awake, sleep inhibitor, AI agent automation, long-running coding task, TypeScript Pi package.
📄 License
MIT. See LICENSE.
