From 6dcb4a888c6b8c9a6093dbe93b48fa58b0e39bb8 Mon Sep 17 00:00:00 2001 From: RichardDillman Date: Sun, 23 Nov 2025 14:53:23 -0500 Subject: [PATCH] feat: add optional permission notification hook for AFK mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added optional hook that sends Telegram notifications when Claude requests tool permissions, solving the issue where users in AFK mode don't get notified about pending permission prompts. Features: - Self-contained hook in hooks/PermissionRequest.sh - Easy installation script (scripts/install-hook.sh) - Opt-in per project - users choose where to install - Sends Telegram alert with tool name and description - Shows ⏸️ warning icon for permission requests Installation: Users can now run ./scripts/install-hook.sh from any project to enable permission notifications. The hook integrates with the existing InnerVoice bridge. Documentation: - Added "Optional: Install Permission Notification Hook" section - Includes installation and uninstallation instructions - Example notification message format This keeps InnerVoice self-contained while allowing users to opt-in to enhanced AFK mode notifications. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- README.md | 24 ++++++++++++++++++++++++ hooks/PermissionRequest.sh | 21 +++++++++++++++++++++ scripts/install-hook.sh | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 hooks/PermissionRequest.sh create mode 100755 scripts/install-hook.sh diff --git a/README.md b/README.md index b1e6099..fb558a6 100644 --- a/README.md +++ b/README.md @@ -224,6 +224,30 @@ This is perfect for: The toggle state is preserved while the bridge is running, and you'll get a Telegram message confirming each change. +#### Optional: Install Permission Notification Hook + +By default, AFK mode only sends notifications when Claude explicitly uses notification tools. If you want to receive Telegram alerts when **permission prompts** appear (so you know Claude is waiting for approval), install the permission hook: + +```bash +# From the innervoice directory +cd /path/to/innervoice + +# Install in a specific project +./scripts/install-hook.sh /path/to/your/project + +# Or install in current directory +cd /path/to/your/project +/path/to/innervoice/scripts/install-hook.sh +``` + +This will send you a Telegram message like: +> ⏸️ **Claude needs permission** +> **Tool:** `Bash` +> **Action:** Check scraped sets files +> Check your terminal to approve or deny. + +**To uninstall:** Simply delete `.claude/hooks/PermissionRequest.sh` from your project. + ### 8. Verify Global Setup After adding the MCP server, verify it's available globally: diff --git a/hooks/PermissionRequest.sh b/hooks/PermissionRequest.sh new file mode 100644 index 0000000..321fc1d --- /dev/null +++ b/hooks/PermissionRequest.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Hook that fires when Claude needs permission +# Sends a Telegram notification if AFK mode is enabled + +# Get the hook input +INPUT=$(cat) + +# Extract tool name and description +TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // "unknown"') +DESCRIPTION=$(echo "$INPUT" | jq -r '.description // "N/A"') + +# Send notification via InnerVoice bridge +curl -s -X POST http://localhost:3456/notify \ + -H "Content-Type: application/json" \ + -d "{ + \"message\": \"⏸️ *Claude needs permission*\n\n**Tool:** \`$TOOL_NAME\`\n**Action:** $DESCRIPTION\n\nCheck your terminal to approve or deny.\", + \"priority\": \"warning\" + }" > /dev/null 2>&1 + +# Return empty response (don't block the permission request) +echo "{}" diff --git a/scripts/install-hook.sh b/scripts/install-hook.sh new file mode 100755 index 0000000..f436b86 --- /dev/null +++ b/scripts/install-hook.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Install the InnerVoice permission notification hook in a project + +set -e + +HOOK_NAME="PermissionRequest.sh" +INNERVOICE_DIR="$(cd "$(dirname "$0")/.." && pwd)" +SOURCE_HOOK="$INNERVOICE_DIR/hooks/$HOOK_NAME" + +# Get target project directory (default to current directory) +TARGET_DIR="${1:-.}" +TARGET_HOOK_DIR="$TARGET_DIR/.claude/hooks" + +echo "📦 Installing InnerVoice Permission Notification Hook" +echo "" +echo "Source: $SOURCE_HOOK" +echo "Target: $TARGET_HOOK_DIR/$HOOK_NAME" +echo "" + +# Validate source hook exists +if [ ! -f "$SOURCE_HOOK" ]; then + echo "❌ Error: Source hook not found at $SOURCE_HOOK" + exit 1 +fi + +# Create target directory if needed +mkdir -p "$TARGET_HOOK_DIR" + +# Copy the hook +cp "$SOURCE_HOOK" "$TARGET_HOOK_DIR/$HOOK_NAME" +chmod +x "$TARGET_HOOK_DIR/$HOOK_NAME" + +echo "✅ Hook installed successfully!" +echo "" +echo "🔔 Now when you're in AFK mode, you'll get Telegram notifications" +echo " whenever Claude requests permission for a tool." +echo "" +echo "To uninstall: rm $TARGET_HOOK_DIR/$HOOK_NAME"