feat: add optional permission notification hook for AFK mode
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 <noreply@anthropic.com>
This commit is contained in:
24
README.md
24
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:
|
||||
|
||||
21
hooks/PermissionRequest.sh
Normal file
21
hooks/PermissionRequest.sh
Normal file
@@ -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 "{}"
|
||||
38
scripts/install-hook.sh
Executable file
38
scripts/install-hook.sh
Executable file
@@ -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"
|
||||
Reference in New Issue
Block a user