#!/bin/bash # postToolUseFailure: log when a tool fails (shell, etc.) HOOKS_DIR="$(cd "$(dirname "$0")" && pwd)" # shellcheck source=lib.sh . "${HOOKS_DIR}/lib.sh" input=$(cat) tool_name=$(echo "$input" | jq -r '.tool_name // "?"') failure_type=$(echo "$input" | jq -r '.failure_type // "?"') error_message=$(echo "$input" | jq -r '.error_message // ""') command=$(echo "$input" | jq -r '.tool_input.command // .tool_input // ""' 2>/dev/null || echo "") log_event "postToolUseFailure" "tool=$tool_name failure=$failure_type" log_json_truncated "postToolUseFailure_error" "$error_message" 500 if [ -n "$command" ]; then log_event "postToolUseFailure" "command=${command:0:150}" fi echo '{}' exit 0