Metadata-Version: 2.4
Name: apeawake
Version: 0.1.0
Summary: Keep your laptop awake while an AI agent finishes its task
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: textual>=0.60
Dynamic: license-file

# 🦍 ApeAwake

Keep your laptop awake while an AI agent finishes its task. Close the lid, take a walk — ApeAwake holds the sleep lock until the job is done, then lets your machine sleep normally.

Works on **macOS**, **Linux**, and **Windows** with no external Python dependencies.

---

## Install

```bash
pip install -e .
```

This registers the `apeawake` command globally.

---

## Usage

### Wrap mode — launch and own the process

```bash
apeawake -- claude --task "refactor the auth module"
apeawake -- aider --model gpt-4o --file src/main.py
apeawake -- python train.py
```

ApeAwake spawns your command, acquires the sleep lock, and releases it the moment the process exits.

### Watch mode — attach to a running process

```bash
# Start your agent in one terminal
claude --task "build the dashboard" &
AGENT_PID=$!

# Attach ApeAwake in another (or the same)
apeawake --watch $AGENT_PID
```

### Options

| Flag | Description | Default |
|---|---|---|
| `--watch PID` | Watch an existing process by PID | — |
| `--interval N` | Poll interval in seconds | `2.0` |

---

## How it works

| OS | Mechanism |
|---|---|
| macOS | `caffeinate -dims` (prevents display, idle, disk, and system sleep) |
| Linux | `systemd-inhibit --what=sleep:idle:handle-lid-switch` |
| Linux (fallback) | `xdg-screensaver reset` loop (screensaver only, no lid-close) |
| Windows | `SetThreadExecutionState` with `ES_SYSTEM_REQUIRED \| ES_AWAYMODE_REQUIRED` |

The sleep lock lifetime is tied directly to your process — no manual `--stop` needed. Ctrl+C also releases cleanly.

---

## Example session

```
$ apeawake -- claude --task "write unit tests for billing.py"

🦍  ApeAwake — wrap mode
    Backend : caffeinate (macOS)
    Command : claude --task write unit tests for billing.py

✓  Sleep lock acquired (PID 48291). Laptop will stay awake.
   Close the lid freely — ApeAwake has you covered.

   ⏱  Running... 4m 12s
   ✓  Task finished in 4m 12s. Releasing sleep lock.
   Exit code: 0
```
