@narumitw/pi-caffeinate

Pi extension that keeps the computer awake while the agent is running.

Packages

Package details

extension

Install @narumitw/pi-caffeinate from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@narumitw/pi-caffeinate
Package
@narumitw/pi-caffeinate
Version
0.1.34
Published
May 24, 2026
Downloads
3,770/mo · 2,328/wk
Author
narumitw
License
MIT
Types
extension
Size
14.3 KB
Dependencies
0 dependencies · 0 peers
Pi manifest JSON
{
  "extensions": [
    "./src/caffeinate.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

☕ pi-caffeinate — Keep Your Computer Awake While Pi Works

npm Pi extension License: MIT

@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 awake status only while an inhibitor is active.
  • Supports macOS, Windows, WSL, and Linux.
  • Provides /caffeinate-status and /caffeinate-stop commands.
  • Allows a custom inhibitor command through environment configuration.
  • Fails safely when no supported inhibitor is available.

📦 Install

pi install npm:@narumitw/pi-caffeinate

Try without installing permanently:

pi -e npm:@narumitw/pi-caffeinate

Try 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.exe with SetThreadExecutionState.
  • Linux: uses systemd-inhibit with sleep infinity.
  • Linux fallback: uses caffeinate -dimsu when available.

If no supported inhibitor is available, the extension stays loaded and reports that caffeinate is unavailable.

🚀 Commands

/caffeinate-status

Shows whether an inhibitor is active, unavailable, or disabled.

/caffeinate-stop

Manually releases any active inhibitor for the current session.

⚙️ Configuration

Disable the extension:

PI_CAFFEINATE_DISABLED=1 pi

Use a custom inhibitor command:

PI_CAFFEINATE_COMMAND='systemd-inhibit --what=idle:sleep --why="pi running" --mode=block sleep infinity' pi

The 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.