Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions extensions/agent-night-watch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
dist/
.DS_Store
*.log
41 changes: 41 additions & 0 deletions extensions/agent-night-watch/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Changelog

## [Hardened Privileged Guard] - {PR_MERGE_DATE}

- Embed the fixed guard program into the authorization command before showing
the password dialog instead of executing a user-writable script pathname.
- Make the privileged process read-only toward user session paths and restrict
its executable allowlist to absolute `pmset`, `grep`, and `sleep` paths.
- Use `pmset -g` and verified launcher identity for readiness and ownership.
- Add adversarial regression coverage for path replacement, symlink writes,
shell injection, and privileged command allowlisting.

## [Direct Coffee-Cup Toggle] - {PR_MERGE_DATE}

- Click the coffee cup once to toggle Night Watch directly in normal states.
- Keep external ownership and transition states behind a safe recovery menu.
- Remove continuous two-second polling and redraw after completed operations.
- Release duplicate-mount suppression after one second so later clicks are not
mistaken for the previous background refresh.

## [Fixed Live Menu Status] - {PR_MERGE_DATE}

- Fixed the steaming menu-bar icon remaining visible after normal sleep had
already been restored.
- Added live `SleepDisabled` calibration while Raycast keeps the menu command
loaded.

## [Fixed Lock Recovery] - {PR_MERGE_DATE}

- Fixed an abandoned toggle lock that could block both the hotkey and menu from
disabling Night Watch.
- Added token-checked lock release and prompt stale-lock recovery.

## [Initial Version] - {PR_MERGE_DATE}

- Add a menu-bar coffee cup for closed-lid awake status.
- Add a manual toggle command suitable for a user-assigned hotkey.
- Read `SleepDisabled` as the source of truth and distinguish owned sessions
from external sleep-disabled state.
- Require administrator authorization on enable and verify normal sleep on
disable.
35 changes: 35 additions & 0 deletions extensions/agent-night-watch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Agent Night Watch

Keep local agents running when a MacBook lid is closed, using a coffee-cup
switch in the Raycast menu bar.

- Empty cup: normal closed-lid sleep.
- Steaming cup: Agent Night Watch is active.
- Click the cup once to toggle directly during normal operation.
- Enabling asks for macOS administrator authorization every time.
- Disabling an owned session does not ask again.
- The display can still turn off according to macOS settings.

Unlike Coffee and other `caffeinate` wrappers, Agent Night Watch controls the
closed-lid `SleepDisabled` setting and reads it back before reporting success.

## Setup

1. Run **Night Watch Menu Bar** once to keep the coffee cup visible.
2. Optionally assign `⌥S` to **Toggle Night Watch** in Raycast Settings.
3. Click the coffee cup and approve the macOS dialog to enable it.
4. Click the coffee cup again to disable it when the job finishes.

## Safety

Closed-lid work can increase heat and battery use. Keep the MacBook on a hard,
ventilated surface. This extension does not add a timer or battery cutoff, so
you remain responsible for turning it off.

If sleep was disabled by another tool, Agent Night Watch will not claim that
session. In that exceptional state, clicking the cup opens a separately
confirmed, administrator-authorized recovery menu instead of toggling directly.

No password is stored. No privileged helper, sudoers rule, analytics, or
network request is used. The fixed privileged guard is embedded before the
authorization dialog and never executes or writes a user-controlled path.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions extensions/agent-night-watch/assets/coffee-off.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/agent-night-watch/assets/coffee-on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions extensions/agent-night-watch/assets/coffee-on.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions extensions/agent-night-watch/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import raycastConfig from "@raycast/eslint-config";

export default [...raycastConfig];
Loading
Loading