From 2938571acbfc935381f32a7af8cad3343e21c97e Mon Sep 17 00:00:00 2001 From: seemeroland Date: Wed, 15 Jul 2026 12:23:14 -0700 Subject: [PATCH 1/3] Add hook for StopFailure --- plugins/warp/hooks/hooks.json | 10 +++++ plugins/warp/scripts/on-stop-failure.sh | 55 +++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100755 plugins/warp/scripts/on-stop-failure.sh diff --git a/plugins/warp/hooks/hooks.json b/plugins/warp/hooks/hooks.json index b2273b4..ba32f28 100644 --- a/plugins/warp/hooks/hooks.json +++ b/plugins/warp/hooks/hooks.json @@ -62,6 +62,16 @@ } ] } + ], + "StopFailure": [ + { + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PLUGIN_ROOT}/scripts/on-stop-failure.sh" + } + ] + } ] } } diff --git a/plugins/warp/scripts/on-stop-failure.sh b/plugins/warp/scripts/on-stop-failure.sh new file mode 100755 index 0000000..f380bcc --- /dev/null +++ b/plugins/warp/scripts/on-stop-failure.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# Hook script for Claude Code StopFailure event +# Sends a structured Warp notification when Claude's turn ends due to an API error + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "$SCRIPT_DIR/should-use-structured.sh" + +# Legacy Warp clients that don't support structured events don't get a +# stop_failure notification — they have no UI to act on it. +if ! should_use_structured; then + exit 0 +fi + +source "$SCRIPT_DIR/build-payload.sh" + +# Read hook input from stdin +INPUT=$(cat) + +# Try to extract an error message from the hook input. +# Claude Code may surface the error under different field names depending on +# the version, so check the most likely candidates. +ERROR_MESSAGE=$(echo "$INPUT" | jq -r ' + .error_message // .error // .message // empty +' 2>/dev/null) + +# Also try to extract the last user query from the transcript so Warp can +# show it as the notification title, matching the Stop hook behaviour. +TRANSCRIPT_PATH=$(echo "$INPUT" | jq -r '.transcript_path // empty' 2>/dev/null) +QUERY="" +if [ -n "$TRANSCRIPT_PATH" ] && [ -f "$TRANSCRIPT_PATH" ]; then + QUERY=$(jq -rs ' + [ + .[] | select(.type == "user") | + if .message.content | type == "string" then . + elif [.message.content[] | select(.type == "text")] | length > 0 then . + else empty + end + ] | last | + if .message.content | type == "array" + then [.message.content[] | select(.type == "text") | .text] | join(" ") + else .message.content // empty + end + ' "$TRANSCRIPT_PATH" 2>/dev/null) + + if [ -n "$QUERY" ] && [ ${#QUERY} -gt 200 ]; then + QUERY="${QUERY:0:197}..." + fi +fi + +BODY=$(build_payload "$INPUT" "stop_failure" \ + --arg query "$QUERY" \ + --arg response "$ERROR_MESSAGE" \ + --arg transcript_path "$TRANSCRIPT_PATH") + +"$SCRIPT_DIR/warp-notify.sh" "warp://cli-agent" "$BODY" From d6f06409cf60b857ee5f689898049a0b85c0a566 Mon Sep 17 00:00:00 2001 From: seemeroland Date: Wed, 15 Jul 2026 12:37:25 -0700 Subject: [PATCH 2/3] Extract both error type and message --- plugins/warp/scripts/on-stop-failure.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/warp/scripts/on-stop-failure.sh b/plugins/warp/scripts/on-stop-failure.sh index f380bcc..b170326 100755 --- a/plugins/warp/scripts/on-stop-failure.sh +++ b/plugins/warp/scripts/on-stop-failure.sh @@ -16,12 +16,9 @@ source "$SCRIPT_DIR/build-payload.sh" # Read hook input from stdin INPUT=$(cat) -# Try to extract an error message from the hook input. -# Claude Code may surface the error under different field names depending on -# the version, so check the most likely candidates. -ERROR_MESSAGE=$(echo "$INPUT" | jq -r ' - .error_message // .error // .message // empty -' 2>/dev/null) +# Extract the error type (e.g. "rate_limit") and human-readable message. +ERROR_TYPE=$(echo "$INPUT" | jq -r '.error // empty' 2>/dev/null) +ERROR_MESSAGE=$(echo "$INPUT" | jq -r '.last_assistant_message // empty' 2>/dev/null) # Also try to extract the last user query from the transcript so Warp can # show it as the notification title, matching the Stop hook behaviour. @@ -50,6 +47,7 @@ fi BODY=$(build_payload "$INPUT" "stop_failure" \ --arg query "$QUERY" \ --arg response "$ERROR_MESSAGE" \ + --arg error_type "$ERROR_TYPE" \ --arg transcript_path "$TRANSCRIPT_PATH") "$SCRIPT_DIR/warp-notify.sh" "warp://cli-agent" "$BODY" From eee84f86b092680289bfb0640900f55e91d7ffe5 Mon Sep 17 00:00:00 2001 From: seemeroland Date: Wed, 15 Jul 2026 17:43:05 -0700 Subject: [PATCH 3/3] bump version --- .claude-plugin/marketplace.json | 2 +- plugins/warp/.claude-plugin/plugin.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index c898bff..ab081b9 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -10,7 +10,7 @@ "name": "warp", "description": "Native Warp notifications when Claude completes tasks or needs input", "source": "./plugins/warp", - "version": "2.1.0", + "version": "2.2.0", "category": "productivity", "tags": ["notifications", "terminal", "warp"] }, diff --git a/plugins/warp/.claude-plugin/plugin.json b/plugins/warp/.claude-plugin/plugin.json index 8dd9247..1e29217 100644 --- a/plugins/warp/.claude-plugin/plugin.json +++ b/plugins/warp/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "warp", "description": "Warp terminal integration for Claude Code - native notifications, and more to come", - "version": "2.1.0", + "version": "2.2.0", "author": { "name": "Warp", "url": "https://warp.dev"