Skip to content

meshulga/agentawake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

agentawake

Keep your Mac awake — including with the lid closed — but only while a Claude Code or Codex agent turn is actively running. When the agent is idle, your Mac sleeps normally.

Existing keep-awake tools either don't work with the lid closed (caffeinate, KeepingYouAwake) or trigger on "app is running" — which keeps you awake all day just because the editor is open. agentawake hooks into the agent's turn lifecycle, so wakefulness tracks actual work.

How it works

  • UserPromptSubmit hook → a turn starts → a token is written.
  • Stop hook → the turn ends → the token is removed.
  • An idempotent reconcile (run from every hook and from a ~60s launchd agent) prunes dead/abandoned tokens and toggles pmset disablesleep through a tiny passwordless-sudo root wrapper.

A dead, crashed, or interrupted turn is cleaned up automatically (process-liveness check + a max-age cap), so sleep is never left disabled indefinitely.

Install

brew install meshulga/tap/agentawake
agentawake install   # wires hooks + the privileged toggle; asks for your password once

Restart any running Claude Code / Codex sessions afterwards so they pick up the hooks.

Local development

go build -o agentawake .
./agentawake help
./agentawake version
go test ./...
go test ./internal/reconcile/ -v
go test ./internal/reconcile/ -run TestDecide -v
go vet ./...

To try a command without writing a local binary:

go run . status
go run . version

Commands

Command Purpose
agentawake install / uninstall Set up / remove everything (one password prompt)
agentawake status Show active sessions and current sleep state
agentawake off Emergency reset: clear state, restore normal sleep
agentawake reconcile Re-sync (used by the launchd agent)
agentawake version Print the installed version

Verified configuration

The pmset disablesleep mechanism is undocumented by Apple. It was verified on Apple M4 Pro, macOS 26.5. agentawake install runs a self-check and refuses to proceed if the mechanism does not behave as expected on your machine.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors