Hermes Completion Notification Script Explanation | Generated by AI

Home 2026.05

Question: Can you explain what this Bash script does?

Answer:

This script is a post-processing hook for the Hermes agent on macOS. It’s designed to notify the user whenever Hermes completes a turn in a conversation. Let’s break it down step by step:


1. Script Metadata

#!/usr/bin/env bash
# ~/.hermes/agent-hooks/on-agent-done.sh

2. Bash Safety Options

set -euo pipefail

This makes the script robust and avoids silent errors.


3. Read Payload

payload="$(cat -)"

4. Extract Data Using Python

extracted=$(echo "$payload" | python3 -c "
import json, sys
data = json.load(sys.stdin)

# Directory name from cwd
cwd = data.get('cwd', '')
import os
dirname = os.path.basename(cwd) if cwd else 'unknown'

# First 10 chars of user message
extra = data.get('extra', {})
user_msg = extra.get('user_message', '')[:10]

# Conversation history item count
history = extra.get('conversation_history', [])
hist_count = len(history)

print(f'{dirname}|{user_msg}|{hist_count}')
" 2>/dev/null) || extracted="unknown||0"

5. Split Extracted Values

IFS='|' read -r dirname user_preview hist_count <<< "$extracted"

6. Build Notification Subtitle

subtitle="msg: ${user_preview}  |  turns: ${hist_count}"

7. Send macOS Notification

osascript -e "
display notification \"Hermes has completed one turn.\" with title \"Hermes Agent — ${dirname}\" subtitle \"${subtitle}\" sound name \"Glass\"
" >/dev/null 2>&1 || true

8. Return Empty JSON

printf '{}\n'

Summary

It’s a simple but effective way to keep track of Hermes’ activity visually on macOS.


If you want, I can also draw a small flow diagram showing how JSON moves from Hermes → this script → macOS notification, which makes the flow easier to understand.

Do you want me to do that?


Back Donate