Skip to content
skyfallsinPublic

About

A webhook inbox for coding agents. Runs locally & remotely.

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

32 Commits

Folders and files

Repository files navigation

A friendly blue hawk holding an envelope

agenthook

A webhook inbox for coding agents.

Tests

Built by jo · Pradeep24

agenthook is a webhook inbox for coding agents, designed for Pi, Claude Code, and Codex (but can likely be used for all kinds of different non-coding-agent stuff). It receives authenticated events from external services or other agents, so agents can get updates without blocking their work.

Setup is simple: point your agent at this repo and ask it to set up agenthook. SKILL.md has the instructions.

How does it work?

  1. Your agent creates a 'topic' with agenthook.
  2. Something else (agents, external services) posts to agenthook's server endpoint at http://127.0.0.1:$PORT for that topic
  3. Your agent gets a notification inside its session that there's been an update.
  4. Agent does something with that info.

Subscription lifecycle

By default a subscription is one-shot: it delivers events normally, then unsubscribes itself after the first terminal event — one whose status is completed, success, failed, error, or cancelled. This fits the common case of waiting for a single job to finish, and it stops a stale listener from grabbing stray events from the next run on the same topic. Progress updates and heartbeats are not terminal, so the listener stays put until the real end.

For an ongoing feed — a continuous webhook stream, or one topic carrying completions from several background workers — opt into streaming to keep listening for every event (stream: true on the Pi subscribe tool, /agenthook <topic> stream, or AGENTHOOK_MODE=stream at startup). Background worker topics always stream, since one topic carries every worker's result.

Delivery is a queue, not a broadcast: each event goes to exactly one listener. Two sessions on the same topic compete for events rather than both receiving a copy.

What is it useful for?

A few simple ideas:

  • Have an agent wait for GitHub deploys
  • Ask an agent to create a subagent tree powered by agenthooks
  • Ask a long-running service somewhere to ping your agent with updates
  • Have your suite of agents talk to each other
  • Run a local command and receive progress plus a final result
  • and so much more..

Pi, Claude Code, and Codex work today.

Run a local command

Wrap a local command to notify an agenthook topic when it starts, while it runs, and when it finishes:

./bin/agenthook.js run local.build --heartbeat-every-secs 30 --label "nightly build" -- npm test

The executable and its arguments must follow --; agenthook does not invoke a shell. --heartbeat-every-secs defaults to 30; set it to 0 to disable progress events. --label is optional: a short human-readable string attached to every event so a listener can tell concurrent runs apart. Each event has a runId that ties the lifecycle together. The final callback reports inbox acceptance only, not proof that an agent read or acted on it. Events never cause the receiving agenthook runtime to run code.

Claude Code setup

Claude Code uses agenthook as an MCP channel. From a checkout, add the adapter:

claude mcp add agenthook -- node /absolute/path/to/agenthook/extensions/claude-code.ts

Then start Claude Code with its development channel enabled:

claude --dangerously-load-development-channels server:agenthook

Claude Code starts the adapter itself. Ask it to subscribe to a topic once your local agenthook inbox is running. The Claude Code guide has project-scope setup and the details for restricted tool policies.

Codex setup

From a checkout, install the Codex skill with:

npm run codex:install

This copies the checkout to $CODEX_HOME/skills/agenthook, or ~/.codex/skills/agenthook when CODEX_HOME is not set. If an older install already exists, refresh it with:

npm run codex:install -- --force

For local development, use a symlink instead of a copy:

npm run codex:install -- --link --force

If you are installing directly from GitHub through Codex's skill installer, use repo skyfallsin/agenthook, path ., and name agenthook. The root-path name matters because the skill lives at the repository root.

Connect GitHub Actions

For a real deployment, GitHub needs an HTTPS address it can reach. Put a tunnel such as ngrok in front of the local inbox; keep agenthook itself on loopback. If the hostname already serves another app, preserve its default upstream and route only /agenthook/ to this inbox. Use the namespaced base URL, such as https://<host>/agenthook, for callbacks.

Then configure the repository's Actions secrets and add a final workflow job that sends the deployment result. The setup command handles the secrets, but does not edit the workflow. If an agent is doing this for you, approve the exact repository and callback URL before it makes those changes.

Follow the GitHub Actions setup for the command and callback example. Use the same topic in GitHub and Pi.

This repository's test workflow sends results to agenthook after push builds. Pull request builds do not send callbacks. The callback requires the three Actions secrets described in the setup guide and a reachable listener. If sending fails, the callback job fails separately from the tests.

Act on an event with a local agent

Events never make agenthook run code, but a listener you write can. The resume-from-web example waits on a topic and, for each takeover event from jojo (a ticket you took over, or a fix pushed to a repository with no GitHub build), creates a worktree on the ticket's branch, writes the brief to PROMPT.md, and starts the agent command you pass. The agent reviews and builds locally, then reports its verdict back to jojo through its API. Adapt the checkout map and the command to your setup.

Agent swarms

You can use agenthook to coordinate a swarm of agents. A coordinator subscribes to a report topic, delegates work, and receives findings as workers finish. The coordinator decides what happens next; agenthook carries the updates.

Only the coordinator subscribes to the report topic. Workers send to it without subscribing, or they can consume reports meant for the coordinator. Workers that need incoming messages use separate topics. Give each worker a short human-readable label so its start, progress, and completion events are easy to tell apart when several run at once.

Task assignment, review, and recovery are left as an exercise for the reader. For Codex-specific subagent reporting rules, including when to use the App Server adapter and when a bounded CLI wait is only a smoke test, see the Codex adapter guide.

Limits and security

Queued events survive restarts, expire after 24 hours, and are limited to 1,000. The current inbox removes events on delivery; it does not wait for the agent to acknowledge them. Don't use it where losing an update is unacceptable.

Keep the access token private. Incoming payloads are external data, not user instructions.

Run the tests with npm test.

About

A webhook inbox for coding agents. Runs locally & remotely.

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages