Skip to content

About

Notifications from herdr agents (herdr app and TUI) to Telegram, Discord, Slack, ntfy, Bark or any webhook. Reply on Telegram to answer the agent.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

herdr-push

Get a message on your phone when a herdr agent needs you or finishes, in the app you already use: Telegram, Discord, Slack, ntfy, Bark, or any webhook. With Telegram, reply to the message to answer the agent.

It works with both herdr runtimes:

  • the herdr app (herdr-core, hc)
  • the herdr TUI (herdr server)
⚠️ api / 1 · claude-code needs permission
Fix the flaky login test — Run rm -rf build?
┌──────────────────────────────┐
│ Allow this command?          │
│ 1. Yes  2. No                │
└──────────────────────────────┘
Reply to answer · /keys esc · /read

The herdr mobile app shows a banner only while it is open, because iOS closes SSH in the background. herdr-push runs next to your agents and pushes through a service your phone already listens to.

Install

Homebrew (macOS, Linux):

brew install --cask yatping/tap/herdr-push

Download a binary for macOS, Linux or Windows from Releases, unpack it, and put herdr-push on your PATH.

Go 1.26 or newer:

go install github.com/yatping/herdr-push@latest

herdr-push is one binary with no runtime dependencies.

go install puts it in $(go env GOPATH)/bin (usually ~/go/bin). If your shell says command not found, add that folder to your PATH, or link it next to hc:

ln -s ~/go/bin/herdr-push ~/.local/bin/herdr-push

Quick start

herdr-push init      # writes ~/.config/herdr-push/config.toml
$EDITOR ~/.config/herdr-push/config.toml   # uncomment a service
herdr-push test      # sends a test message to every service
herdr-push           # follows herdr and notifies

By default herdr-push follows every herdr it finds running (source = "auto"). Set source = "core" or source = "tui" to pick one.

What notifies

Event When
blocked an agent starts waiting for you: a permission, a question, a login
done an agent finishes a turn. herdr reports a turn finished in the pane you are looking at as idle instead of done, so working → idle counts too
error an agent reports an error

Only changes notify. Starting herdr-push does not replay what is already on screen, and the same event for the same agent is quiet for cooldown seconds (default 10). A finished turn notifies only when the agent worked on it for at least min_working seconds (default 30, waiting for you included), so quick answers you watched come in stay quiet; blocked always notifies. Set min_working = 0 to hear about every turn. Each notification includes the last screen_lines lines of the agent's screen (default 8), so you can see what it asks. Set screen_lines = 0 for services you share with others, because the screen can show code or secrets.

Services

Several services can be on at once, and each can take its own events (on = ["blocked"]). Secrets can come from the environment: token = "${TELEGRAM_BOT_TOKEN}".

Telegram

  1. Message @BotFather, send /newbot, and copy the token.
  2. Send your new bot any message, then open https://api.telegram.org/bot<token>/getUpdates and copy message.chat.id.
[[notify]]
type = "telegram"
token = "${TELEGRAM_BOT_TOKEN}"
chat_id = "123456789"
reply = true   # optional, see below

Discord

Go to channel settings → Integrations → Webhooks → New Webhook, then copy the URL.

[[notify]]
type = "discord"
url = "${DISCORD_WEBHOOK_URL}"

Slack

Create an app with an incoming webhook for a channel.

[[notify]]
type = "slack"
url = "${SLACK_WEBHOOK_URL}"

ntfy

Install the ntfy app and subscribe to a topic. On the public server anyone who knows the topic name can read it, so pick a long random one, or use your own server.

[[notify]]
type = "ntfy"
topic = "herdr-7f3c9a1e5b2d"
# server = "https://ntfy.example.com"
# token = "${NTFY_TOKEN}"

blocked and error are sent with high priority.

Bark (iOS)

Install Bark and copy your device key.

[[notify]]
type = "bark"
device_key = "${BARK_DEVICE_KEY}"
# server = "https://api.day.app"

blocked and error are sent as time-sensitive.

Webhook

herdr-push POSTs the event as JSON: event, headline, detail, source, address, app, title, where, kind, msg, screen and time. With secret set, the body is signed with HMAC-SHA256 in X-Herdr-Push-Signature: sha256=<hex>.

[[notify]]
type = "webhook"
url = "https://example.com/herdr"
secret = "${WEBHOOK_SECRET}"
headers = { Authorization = "Bearer ${HOOK_TOKEN}" }

Reply from Telegram

With reply = true on the Telegram service, a blocked notification comes with buttons: one per numbered choice on the agent's screen (1 · Yes, 2 · No, …), plus Esc and Read. A tap presses that key in the agent, the way you would at the keyboard, and the buttons go away. A choice only works while the agent still waits: tapped later, it does nothing, so it can't land in whatever the agent shows by then.

You can also reply to any notification to type into that agent and press Enter: 1, y, or a sentence.

In a reply:

  • /keys esc, /keys down enter or /keys ctrl+c press keys
  • /read shows the agent's screen now

Anywhere, /agents lists agents and their state.

Replies are a remote keyboard for your machine, so herdr-push limits them:

  • They are off unless you set reply = true.
  • Only messages from the configured chat_id are read. Everything else is dropped unread.
  • A reply reaches only the agent its notification was about. A plain message reaches no agent.
  • Messages sent while herdr-push was not running are skipped, so an old answer can't reach an agent that has moved on.

Anyone who can post in that chat can type into your agents. Use a private chat with your bot, not a group.

The link between a notification and its agent is kept in memory for the last 1,000 notifications. After a restart, reply to a newer notification.

Keep it running

macOS (launchd). Save this as ~/Library/LaunchAgents/dev.herdr-push.plist, then run launchctl load ~/Library/LaunchAgents/dev.herdr-push.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict>
  <key>Label</key><string>dev.herdr-push</string>
  <key>ProgramArguments</key><array><string>/opt/homebrew/bin/herdr-push</string></array>
  <key>EnvironmentVariables</key><dict>
    <key>PATH</key><string>/Users/YOU/.local/bin:/usr/bin:/bin</string>
  </dict>
  <key>RunAtLoad</key><true/>
  <key>KeepAlive</key><true/>
  <key>StandardErrorPath</key><string>/tmp/herdr-push.log</string>
</dict></plist>

Use the path command -v herdr-push prints. PATH must include the folder where hc lives (the herdr app installer puts it in ~/.local/bin).

Linux (systemd user unit). Save this as ~/.config/systemd/user/herdr-push.service, then run systemctl --user enable --now herdr-push:

[Unit]
Description=herdr-push

[Service]
ExecStart=/home/linuxbrew/.linuxbrew/bin/herdr-push
Environment=PATH=%h/.local/bin:/usr/bin:/bin
Restart=always

[Install]
WantedBy=default.target

How it works

  • herdr app: herdr-push follows hc events --json, which gives a snapshot and then one line per change. Agents report their state through OSC 7501. Replies go through hc send (with --force when the agent is blocked, so the text answers its dialog) and hc keys.
  • herdr TUI: herdr-push talks to the server socket (~/.config/herdr/herdr.sock, HERDR_SESSION or HERDR_SOCKET_PATH).
    • It subscribes to pane.created and pane.closed, plus pane.agent_status_changed for every pane. A status subscription names one pane, so it subscribes again when panes come and go, and reconciles with session.snapshot.
    • Replies use pane.send_input and pane.send_keys.

Remote machines that herdr-core manages show up like local ones, with addresses such as vps/t7.

Status

This is early. The herdr app path is tested end to end against herdr-core 0.1.22: an agent that blocks, gets an answer through a reply, and finishes. The TUI path is tested against a fake server that follows the published herdr socket API (protocol 22). Reports from TUI users are very welcome.

Not supported yet:

  • the TUI on native Windows (named pipe)
  • replies from Discord and Slack, which need a bot connection instead of a webhook

Related

License

Apache-2.0

About

Notifications from herdr agents (herdr app and TUI) to Telegram, Discord, Slack, ntfy, Bark or any webhook. Reply on Telegram to answer the agent.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages