coss.comshipyard

Events and gates

Every event Shipyard announces, the gates that can refuse actions, and the variables hooks get.

The envelope

{ "type": "worktree.created", "time": "2026-10-03T09:12:44Z", "box": "devl", "origin": "app",
  "data": { "location": "shop", "name": "checkout", "path": "/home/me/work/shop-checkout", "branch": "checkout" } }

Box events reach the laptop too: the laptop agent relays every online box's events with box set. berth events and GET /v1/events stream them.

A box keeps its events in a journal (~/.berth/box/journal/, files of up to 16 MB, at most 256 MB and 14 days in all), so nothing that follows its events loses one in a burst, and GET /v1/events?since=SEQ replays what came after SEQ before streaming. The laptop agent uses it to catch up after a reconnect or a sleep.

Anything can announce its own: berth emit TYPE key=value… on the laptop, berthd emit TYPE key=value… --origin TOOL on a box. A type is two words of lowercase letters, digits and dashes joined by a dot, each starting with a letter and at most 32 characters; an origin is lowercase letters, digits and dashes.

Box events

Agents and sessions

Agent events come from the agents' own hooks (berthd integrations install), with the tool as their origin and the agent's own conversation id as agent_session_id (Claude Code also sends session_id, Codex turn_id, Cursor conversation_id and status). A hook names the Shipyard session it runs in as session, from $BERTH_SESSION. Hooks spooled while berthd was down carry spooled: true and the time they ran. Shipyard does not publish a tool use (agent.started with signal: "tool") for an agent that is already working: it would change nothing. When an agent's hooks cannot tell, Shipyard reads the terminal and sends these itself with origin: "screen" and source: "screen". See turns.

Locations and worktrees

Reviews

A pull request opened for review. Its worktree also has the usual worktree.created (with review: true), setup and removal events.

Automation, config and the box

Flows triggered by a schedule, GitHub or a webhook receive schedule.fired, github.review_comment, github.pr_review, github.check_failed, github.pr_merged, github.issue_labeled, github.issue_assigned or webhook.received as their event; these start the flow directly and are not announced to hooks.

A flow's scope is box or repo:<location>, whichever layer (committed, kit or the box's own) the flow comes from; only the flow that wins its id runs, so flow and scope name one flow.

Laptop events

Gates

Gates are before: hooks on a box. They run before the action, in order (the box's hooks.json and plugins, then the repository's), and one that exits non-zero refuses it with what it printed. Gates in a laptop's hooks.json never run.

A gate's BERTH_EVENT_ORIGIN is what the box can vouch for: the tool named by a caller on the box's own socket, or laptop:<name> for a paired laptop and remote for the phone, whatever origin they claim. So a gate scoped to a tool cannot be skipped from another machine by claiming to be that tool. Gates stop mistakes and keep automations inside the lines you draw; they are not a boundary against a paired laptop, which can already run commands on the box.

A task runs before:task.create, then the worktree's and the session's own gates.

What a hook gets

The event is also on stdin as JSON. Hooks from a repository's config get the worktree's environment as well; see files and environment.

Last updated