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"