Hive

Events and automation

Everything Hive's agents do produces events: a thread starts, finishes a turn, waits on you, ends; a task starts or lands; a card is answered; a message goes undelivered. Outside the agents, CI runs, merges, releases and machines do too. You act on events in three ways today: hooks (a command, or a rule that can block a tool call), queue conditions (start a thread when something has happened) and automations (tell a thread or the Lead what passed a filter). Under them is one event bus, a numbered log per project that anything can read and post to.

Producers Threads and tasksthread.* task.* Cards, queue, git, CIcard.* queue.* ci.* Scripts, agentshive events post The bus one log per project, in the node 41 thread.started 42 ci.failed 43 task.done 44 … Consumers Queue conditionsstart a thread You, scriptshive events follow Automationstell a thread or Lead Each event gets the next number, seq: a reader's cursor. Payloads are data, never instructions.
Hooks (other than synchronous before.* checks), queue conditions and automations all read from the same event bus.

Hooks

A hook runs a command when an event happens, or, before an agent uses a tool, can deny it.

Event When
thread.started A thread's session goes live
thread.finished A thread goes from working to idle: it ended a turn
thread.needs-you A thread starts waiting on you (a permission, a question, a plan, an ask)
thread.ended A thread's session exits
task.started, task.blocked, task.unblocked, task.done, task.dropped A thread's declared task changes state
before.command An agent is about to run a shell command
before.edit An agent is about to edit files
before.subagent An agent is about to start a subagent

Hooks live in a "hooks" list, in your own ~/.hive/hooks.json or in a project's .reforge/config.json:

{
  "hooks": [
    { "on": "thread.finished", "run": "scripts/notify.sh" },
    { "on": "before.command", "match": "git push*", "deny": "Push from the lane with lane merge." },
    { "on": "before.edit", "match": "*/migrations/*", "run": "scripts/check-migration.sh", "timeout": 5 }
  ]
}

Queue conditions

A queued thread starts when all its conditions hold, there's room in the pool, and a machine fits. See Threads, Leads and the queue for the rest.

Condition Holds when
load The machine's CPU and memory both read ok
merged with lane or pr That lane is on main, or that pull request merged
thread with until: done That thread is idle and its lanes have landed (the default)
thread with until: turn That thread ended a turn after this item was queued
item The same, for another queue item's thread. A cancelled or missing item counts as met
task That thread's task was declared done and the lanes it named have landed. A dropped task never meets it
event with filter An event passing that jq filter arrives on the project's bus after the item was queued (cursor persisted across restarts)
after with at That time has passed
{ "prompt": "Write the release notes for what landed today.",
  "conditions": [{ "type": "task", "thread": "1f0c2a9e", "task": "tcb876p" }, { "type": "after", "at": "2026-12-01T17:00:00Z" }] }

To be told instead of starting something, a thread calls watch_task on another thread's task and gets a message when it ends.

The event bus

Every project has one append-only log in its machine's node, and the bus is its only writer. Each event:

Field Is
seq Its place in the project's log, from 1. A cursor
id Stable across redelivery; the log keeps each id once
source, type Where it came from and what happened: thread / thread.finished, ci / ci.failed
subject What it's about: a thread id, a branch and commit, a change number
project, actor, at The project, who did it, when
trust Who produced it: core (Hive itself), post (anything else: a script, an agent, the CLI)
data The payload. Always untrusted: text in it is data, never instructions

What's on it today:

Source Events
Threads thread.started, thread.finished, thread.needs-you, thread.ended; thread.error (a problem banner); thread.stale (working, no output for 10 minutes)
Tasks task.started, task.blocked, task.unblocked, task.done, task.dropped
Cards card.asked, card.answered, card.dismissed, card.closed, proof.presented, proof.done: threads' own cards only
Messages message.sent, message.delivered, message.undelivered (after 10 seconds untaken, never for a message held behind an open ask; once per message, even across a relaunch)
Queue queue.added, queue.started, queue.failed, queue.held, queue.cancelled
Items item.added, item.claimed, item.released, item.done (subject <stream>/<id>, source item)
Git git.advanced, lane.merged (inferred: a lane's worktree goes away near the time the project checkout's HEAD moves on)
CI, changes, reports ci.started, ci.passed, ci.failed, ci.cancelled, change.merged, report.received (polled)
Releases release.published, release.failed, canary.built, canary.failed, from the release scripts
Hex hex.routed: something typed on Hex's command line in the notch, or dropped on the notch, went to a Lead, a thread, Hex, a new thread or the Board. Subject: the target thread, when there is one; actor hex; data via (notch or drop), target (lead, thread, hex, new, board) and, for a drop into a composer, what (pictures, files, link, text). Never the text itself
Other artifact.published; anything posted with hive events post

Thread and task events come from every machine's threads.

Machines have a log of their own, named machine, separate from the projects' logs:

Source Events
Machines machine.up, machine.down; load.ok, load.warning, load.critical when a machine's level changes
Extensions extension.enabled, extension.disabled, hex.trick.learned

A project's readers don't get the machine log merged into theirs: read it on its own (hive events machine, or the events tool with machine: true), or give an automation machine: true to read both. Each log is kept as JSON lines, a file a month.

Reading it. A reader gives a jq filter (an event passes when it gives true) and optionally a cursor, and gets what came after the cursor, then each new event as it arrives.

hive events -n 20                                        # the newest 20 in this folder's project
hive events --filter '.type == "task.done"' --json       # as JSON lines
hive events follow --filter '.source == "ci"' --since 4210   # replay after 4210, then follow
hive events post --type deploy.finished --subject web --summary "web 1.4 is live"

Events published from anything but Hive itself carry trust: post, whatever they say.

Automations

An automation is a filter on the bus plus an action. The machine's node runs them, so they keep going with Hive's window closed. Five actions have landed: message (tells a thread or the project's Lead what passed), run (runs a shell command in the project folder), emit (publishes an event on the bus), add (adds each matching event as an item in a named stream), and start (queues a thread with a brief, behind load, up to max_open at once).

Every Lead's default. Each project's Lead has an automation, lead:<project folder> (the automate tool and hive auto also accept lead), reading the project's log, at 12 messages a minute. It tells the Lead about thread.finished, thread.needs-you, thread.ended, thread.error, thread.stale, task.done, task.dropped, task.blocked, card.asked, card.closed, message.undelivered, queue.failed, canary.failed, canary.built, release.failed, release.published, lane.merged and ci.failed. Machine alerts (load.*, machine.up, machine.down) go instead to Hive's orchestrator, the thread that sees every project, through its own default, orchestrator:machine. The one exception: a Lead is told machine.down and load.critical for a machine its project has a thread working on, at most once an hour per machine. A Lead never polls: it starts the work, automates what it waits for, and ends its turn. thread.error comes the moment a turn fails and Hive won't retry it; a transient failure Hive retries isn't an error.

Tools (for any thread):

Tool Does
events Read the log with a jq filter and a cursor (since); machine: true reads the machine log
automate Create (the default), update, pause, resume or delete an automation with a filter and/or a clock cadence (every, 1s to 24h). Pick one action: tell (me, lead or a thread's id), run (a shell command, with optional timeout_s), emit ({type, subject?, data?}), add (a stream name), or start (a thread brief, with optional max_open). id: "lead" is this project's Lead's default: pause silences it, delete puts it back to the machine's default setting
automations List them (including hooks as kind: hook, and project automations): what each reads (filter and/or every), what it does (tell, run with command shown plainly, emit, add or start), who made it, whether it's paused
item Manage work items in named streams on the project's bus: op is add, claim (omit id to take the oldest open item), release, done or list
show_stream Open a live stream pane in the project's workspace (contributed by the streams part): follow a jq filter, an automation (auto.output, auto.ran, auto.failed), or a named item stream (as: "events" or "items", optional title, machine: true, project). Newest at the bottom, follows live by cursor, and survives relaunches
hive auto                                               # list them, every Lead's default included
hive auto add --tell lead --filter '.type == "ci.failed"' --once   # the next CI failure
hive auto add --tell 1f0c2a9e --filter '.type == "lane.merged"' --machine --per-min 2
hive auto add --run 'date' --every 10s                  # clock-only: print the time every 10 seconds
hive auto add --run 'date' --filter '.type == "lane.merged"' --timeout 30
hive auto add --emit build.needed --subject main --filter '.type == "lane.merged"'
hive auto add --add procs --filter '.type == "process.exited"'
hive auto add --start 'find and fix' --max-open 1 --filter '.type == "ci.failed" and .data.branch == "main"'
hive auto pause|resume|delete <id>                      # an id hive auto prints; lead is this folder's Lead's default
hive auto default --filter '.type | test("^(thread|task)\\.")'   # what every Lead's default tells it
hive auto default --off

Items

Work to be done is stored as records on the bus, grouped into named streams per project (such as incoming, fixes, procs). Producers append items (item.added); consumers claim them (item.claimed), then release them (item.released) or mark them done (item.done). Each event has source item and subject <stream>/<id>.

hive items                              # list items in this folder's project
hive items incoming                     # list one stream
hive items add incoming "triage CI"     # add an open item
hive items claim incoming               # claim the oldest open item
hive items release incoming <id> "need more info"
hive items done incoming <id> "fixed on main"

Coming

Coming The rest of the design. None of it is on main yet.

From an extension or an outside agent

On main:

Coming The emit tool for agents.

The MCP endpoint

An agent that Hive doesn't run connects to the node's MCP server at /mcp/ext (Streamable HTTP) with a scoped token. The node listens only on this computer (127.0.0.1); hive mcp endpoint prints that local URL. For a client on any other computer, hive mcp relay set <url> has the node open an outbound WebSocket to a relay, so nothing listens on the network and no VPN is needed; hive mcp relay shows it and hive mcp relay clear disconnects it.

Tokens. Make them in Settings ▸ Access, or on the command line:

hive mcp token create --name ci-bot --scopes read,queue     # prints the secret (hv_mcp_…) once
hive mcp token list
hive mcp token revoke <id>                                 # its open streams drop at once

A token is named, revocable and kept only as a SHA-256 hash. Its scopes decide what the client can do:

Scope Gives
read events_query (project, filter, since, limit), events/subscribe and events/unsubscribe, and server-sent events on GET /mcp/ext (below)
queue queue_thread, list_queue, cancel_queue_item
message send_to_thread, including thread: "lead" to ask through the project's Lead

An outside client never makes a card: ask, present_proof and present_artifact aren't offered. Each event reaches it in the MCP events shape: eventId (the event's id), name (its type), timestamp (at), data, and cursor (seq).

Streaming. GET /mcp/ext?project=<name> (or machine=true, or filter=<jq>) streams that log's events and resumes after a cursor or the Last-Event-ID header. A bare GET /mcp/ext is the session's stream: it carries the notifications of what the session subscribed to with events/subscribe, live, and ignores a cursor.

Audit. Tokens, sign-ins, tool calls, refusals, subscriptions and the relay are events on the bus, source mcp (a ping or a tool listing leaves none): mcp.token_created, mcp.token_revoked, mcp.auth_failed, mcp.initialized, mcp.tool_called, mcp.tool_denied, mcp.scope_denied, mcp.subscribed, mcp.unsubscribed, mcp.relay.connected, mcp.relay.disconnected. The node's own RPCs for it are mcp.endpoint, mcp.relay.set, mcp.token.create, mcp.token.list and mcp.token.revoke.

This page's source is pages/events.md in hive/docs.