Orb

Publishers

One hook, every turn

harness -> hook -> topic

Most harnesses:

can you read https://orbnet.app/publishers and help me get final turn hooks sending to my t_… topic?

Paste that into the agent you already have. It reads this page, finds its own section and writes the config. The topic id above is a placeholder — swap in yours before you send it.

Every harness below can publish its final answer to an Orb topic at the end of a turn, without the agent knowing Orb exists: the harness fires an end-of-turn event, and orb-cli publish -harness-input pulls the assistant's prose out of the event and posts it. Two of these we run ourselves every day. The rest are built from each vendor's documentation and are marked untested — the configuration is a best reading of their docs, not something we have watched work.

Plain text of this page, ready to paste into an agent. Each harness section below has its own copy button too.

Marks are simplified glyphs drawn for identification. Names and logos belong to their owners. Each card jumps to its section and opens the detail below; every code block has a copy button.

The order of operations

The hook runs unattended, in the harness's environment, with no terminal to prompt on. Get this order wrong and the hook fails silently on every turn — which is exactly what -ignore-errors is for, and exactly why the failure is invisible.

  1. Install the CLI, on the machine that runs the harness.
    brew install orbnet-app/tap/orb-cli   # macOS
    orb-cli version
    Elsewhere, take the release binary from download.orbnet.app/#cli. Note the absolute path — a hook does not get your login shell's PATH.
  2. Get a credential the hook can read with nobody watching.
    orb-cli auth login
    orb-cli auth status   # {"logged_in":true,"mode":"stored","source":"keychain",…}
    A stored session is the easy answer and the wrong one on some machines — it expires in 30 days and an unattended process cannot always read the keychain it lives in. How the hook authenticates has the three options and the case for each.
  3. Make the topic and copy its id. A private topic is the right default: the hook publishes with your stored session, so no key sits on disk. Create it in the web inbox and copy the t_….
  4. Prove the publish works before wiring the hook.
    printf 'hook smoke test' | orb-cli publish -topic t_…
    orb-cli list -topic t_…
    If this fails, the hook will fail identically, only quieter.
  5. Add the hook, restart the harness, send one message. Then check orb-cli list -topic t_… again. Not the inbox UI — you want to know the publish landed, not that a client rendered it.
The long part: three traps and how the hook authenticates

Three traps that account for most "the hook did not fire"

  • An exported credential overrides the stored session. If ORB_AK, ORB_SESSION, ORB_PUBLISH_KEY or ORB_KEYS is set in the shell that launched the harness, the hook publishes as that key and never touches the session from auth login. Run orb-cli auth status in the same shell, not in another terminal.
  • The harness's PATH is not yours. Use the absolute path to orb-cli in every config below. A bare orb-cli plus -ignore-errors is a publish that never happens and never complains.
  • Nothing to publish is not an error. An empty or tool-only final message publishes nothing and exits 0. A hook that returns in ~40 ms never made a network call; a real publish takes 300–400 ms.

How the hook authenticates

This is the part that decides whether the integration still works in a month, so it is worth more than the two commands in step 2. A hook has nobody to answer a login prompt, so the real question is not how do I log in but which credential will still be readable, and still valid, in the harness's own environment, unattended, later. There are three answers, and the right one depends on where the harness runs.

The device flow, once

orb-cli auth login                # prints a code and a URL, opens a browser if there is a display
orb-cli auth login --no-browser   # print only; approve from any other device
orb-cli auth logout               # revoke on the server, then delete the local copy

login prints a short user code, a verification URL, and how long the code is good for, then polls until you approve it in a browser — on that machine, on your phone, or on a laptop, it makes no difference. It is the one step that needs a human, and it is meant to be run once. On a headless box over SSH the browser is simply not opened; copy the printed URL to whatever device has one.

login is a no-op when the stored session is already good: it prints the status object and exits without minting a new code. So it doubles as "confirm this machine is still authenticated" — but it never extends a session, it only reports one, which is why expiry below still applies.

Where the session lives, and why the user matters

The session goes into the OS keychain (macOS Keychain, Linux Secret Service); if that write fails there is a fallback file at $XDG_STATE_HOME/orb/session — ~/.local/state/orb/session by default — in a 0700 directory, mode 0600. One session per OS user, stored as one blob.

That last sentence is the whole reason this section exists. A hook inherits the environment of the process that started the harness. If that is a different user than the one you are logged in as — a service account, a container, a launchd or systemd unit, a different login on the same box — the hook cannot see your session no matter how many times you run login in your own shell.

It expires in 30 days

Sessions are minted with a 30-day lifetime. After that the hook does not degrade subtly — every publish fails with session expired and exit 1, which under -ignore-errors means no output you will ever see. The exact strings, so you can grep a log:

SymptomWhat it meansFix
session expired — run orb-cli auth login The 30 days are up. Log in again, as the harness's user.
session rejected — stored credential kept; run orb-cli auth logout to clear it The server returned 401 without naming a reason. A revoked session has its own string: session revoked — run orb-cli auth login. auth logout, then auth login.
exit 4, {"error":"login_required"} No session found at all — including when the keychain exists but the process cannot read it. Fix the credential, not the hook. It will not open a browser.

Practical consequence: a stored session suits a hook on a machine you use interactively, where re-logging in once a month is an annoyance you will notice. On a build box or a server, the next option is better.

Or skip auth entirely: a topic publish key

A publish key belongs to one topic, reaches that topic only, has no expiry, and can be revoked on its own without touching your account or your other machines. It cannot read. Mint one in the web inbox under the topic's Publish keys — it is shown once — then hand it to the hook through the environment it already has:

# where the harness runs — e.g. a systemd unit, a container, a launchd plist
ORB_PUBLISH_KEY=orb_pk_…   # one machine, one key
ORB_TOPIC_ID=t_…           # both are required; either alone is partial_config

No auth login at all. The hook then publishes as that key, which is the point: a key you can revoke per machine is a better fit for an unattended process than a shared session you have to keep alive. orb-cli auth status reports it as "mode":"funnel","source":"env:ORB_PUBLISH_KEY".

The trade-off is real: a publish key cannot read, so a hook using one cannot list to verify itself, and it only covers one topic. If a machine publishes to two topics, use ORB_KEYS — a JSON map of topic id to token, inline or a path to that file.

Which one, by where the harness runs

SituationUseBecause
Your own laptop, terminal harness stored session Keychain is unlocked while you are logged in; one auth login a month.
launchd agent, systemd unit, cron publish key These can run before the login keychain is unlocked. The stored session then reads as login_required, exit 4, silently.
Container, CI runner, throwaway VM publish key A device flow needs a human and a secret store that survives the container.
Several machines, one topic one publish key each Revoke one without disturbing the rest; each machine is independently auditable.
Server that only publishes to your own topics ORB_AK account key Publish and read across every topic you own, no login. Broader than a hook needs, so treat it as the exception.

Verify it the way the hook will see it

auth status prints one JSON object and never the credential. Run it in the harness's environment, not your shell — that is the only reading that predicts what the hook will do:

# good — a stored session
{"logged_in":true,"email":"you@example.com","account_id":"a_…","expires_at":"2026-12-11T05:27:25Z","mode":"stored","source":"keychain"}

# good — a publish key, and no login anywhere on this machine
{"logged_in":true,"mode":"funnel","source":"env:ORB_PUBLISH_KEY"}

# bad — nothing to publish with (exit 1)
{"logged_in":false}

# bad — a session exists, but for a different API base (exit 1)
{"logged_in":false,"mode":"stored","source":"keychain","reason":"api_base_mismatch",
 "message":"stored session was minted by https://api.example.com, not this API base — run ORB_API_BASE=https://api.example.com orb-cli auth logout to clear it"}

expires_at is the field worth watching on a hook you set up months ago: it is the date the integration stops working.

dev and prod are separate logins

There is one session slot per OS user, and the stored session is bound to the API base that minted it. A command pointed at a different base does not send the token there — it exits 1 with api_base_mismatch and names the base to clear. So using dev and prod on one machine is a logout/login cycle, not two parallel sessions:

ORB_ENV=dev orb-cli auth logout   # clears the dev session
orb-cli auth login                # then log in to prod

ORB_API_BASE wins over ORB_ENV. An ORB_API_BASE exported in a shell profile silently makes ORB_ENV=prod a no-op — you will be talking to dev while believing you are on prod, and the only clue is the one-line note orb-cli prints on stderr when the base is dev. Set one or the other, not both.

If you would rather not have a credential in the hook at all

Every option above puts a credential in the harness's environment or keychain. The alternative is the local MCP server: orb-mcp runs beside the agent, holds the secret in its own environment, and the agent chooses when to publish. Nothing in a shell config, nothing in a hook file — see the MCP how-to. The cost is the thing that made hooks attractive in the first place: the publish is now a decision the model makes, not a guarantee.

Claude Code

Tested here

A Stop hook fires when a turn genuinely completes. Its stdin is the event as one line of JSON, with last_assistant_message already holding the prose — the exact field -harness-input reads. No wrapper, no transcript scraping.

Config file: ~/.claude/settings.json, merged with whatever is already there:

{
  "theme": "auto",
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "/Users/you/.local/bin/orb-cli",
            "args": ["publish", "-harness-input", "-ignore-errors", "-topic", "t_…"],
            "timeout": 35
          }
        ]
      }
    ]
  }
}

Grok Build

Tested here

Same model, one extra structural layer: Grok reads hook files from ~/.grok/hooks/, one JSON file per file, each able to register several handlers. It sends lastAssistantMessage (and the last_assistant_message alias) with reason: "end_turn".

Config file: ~/.grok/hooks/orb-stop.json:

{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "/opt/homebrew/bin/orb-cli",
            "args": ["publish", "-harness-input", "-ignore-errors", "-topic", "t_…"],
            "timeout": 35
          }
        ]
      }
    ]
  }
}

Codex

Untested

Codex has two mechanisms, and only one of them is the one you want. The newer hooks.json lifecycle system has a real Stop event whose payload carries last_assistant_message — a direct match for -harness-input. The older notify key runs a program with the event JSON as a single argument and only fires for agent-turn-complete.

Preferred — ~/.codex/hooks.json:

{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "/usr/local/bin/orb-cli publish -harness-input -ignore-errors -topic t_…",
            "timeout": 30
          }
        ]
      }
    ]
  }
}

OpenCode

Untested

OpenCode has no config-file stop hook. It has plugins, which run inside its server and can subscribe to its event stream. The event that marks the end of a turn, session.idle, carries only the session id — the prose arrives on message.part.updated — so the plugin keeps the latest assistant text and publishes it when the session goes idle.

File: ~/.config/opencode/plugins/orb-turn.ts (global) or .opencode/plugins/orb-turn.ts (one project):

import { Plugin } from "@opencode/plugin"
import { spawn } from "node:child_process"

const ORB_CLI = "/usr/local/bin/orb-cli"
const TOPIC = "t_…"

const latest = new Map<string, string>()

function publish(text: string) {
  const child = spawn(ORB_CLI, ["publish", "-ignore-errors", "-topic", TOPIC, text], {
    stdio: "ignore",
    detached: true,
  })
  child.on("error", () => {})
  child.unref()
}

export default Plugin.define({
  id: "orb-turn",
  setup(ctx) {
    const controller = new AbortController()
    void (async () => {
      for await (const event of ctx.event.subscribe({
        types: ["message.part.updated", "session.idle"],
        signal: controller.signal,
      })) {
        if (event.type === "message.part.updated") {
          const part = event.properties.part
          if (part?.type === "text" && part.text) latest.set(part.sessionID, part.text)
        } else if (event.type === "session.idle") {
          const text = latest.get(event.properties.sessionID)
          latest.delete(event.properties.sessionID)
          if (text && text.trim()) publish(text)
        }
      }
    })()
    return () => controller.abort()
  },
})

Cursor

Tested on Windows

Cursor's hooks.json is close to what we want and slightly awkward: stop fires when the agent loop ends but its input is only { status, loop_count } — no prose. afterAgentResponse receives the text. So this is a two-hook recipe: one stashes the answer, the next publishes it.

Verified end to end on Windows 10/11 with Cursor 3.30.8 and orb-cli 0.3.2: a real final turn produced a desktop notification on the topic. The sh recipe below is the same design; the Windows variant follows it.

Config file: ~/.cursor/hooks.json (user) or .cursor/hooks.json (project — paths run from the project root):

{
  "version": 1,
  "hooks": {
    "afterAgentResponse": [{ "command": "./hooks/orb-stash.sh" }],
    "stop": [{ "command": "./hooks/orb-publish.sh", "timeout": 40 }]
  }
}

Two scripts beside it, both executable — user hooks run from ~/.cursor/:

#!/bin/sh
# ~/.cursor/hooks/orb-stash.sh
jq -r '.text // empty' | tail -c 1000000 > "$HOME/.cursor/hooks/orb-last.md"
#!/bin/sh
# ~/.cursor/hooks/orb-publish.sh
f="$HOME/.cursor/hooks/orb-last.md"
[ -s "$f" ] || exit 0
/usr/local/bin/orb-cli publish -ignore-errors -topic t_… < "$f"
: > "$f"

Windows

The recipe above assumes sh and jq. On Windows neither is guaranteed, and a hook does not get your login shell's PATH, so invoke PowerShell by absolute name and pin the CLI's absolute path.

{
  "version": 1,
  "hooks": {
    "afterAgentResponse": [
      { "command": "powershell -NoProfile -ExecutionPolicy Bypass -File ./hooks/orb-stash.ps1" }
    ],
    "stop": [
      {
        "command": "powershell -NoProfile -ExecutionPolicy Bypass -File ./hooks/orb-publish.ps1",
        "timeout": 40
      }
    ]
  }
}
# C:\Users\you\.cursor\hooks\orb-stash.ps1
$ErrorActionPreference = 'Stop'
try {
  $raw = [Console]::In.ReadToEnd()
  if ([string]::IsNullOrWhiteSpace($raw)) { exit 0 }
  $text = ($raw | ConvertFrom-Json).text
  if ($null -eq $text) { $text = '' }
  if ($text -isnot [string]) { $text = [string]$text }
  $utf8 = [System.Text.Encoding]::UTF8
  $bytes = $utf8.GetBytes($text)
  if ($bytes.Length -gt 1MB) { $text = $utf8.GetString($bytes, 0, 1MB) }
  [System.IO.File]::WriteAllText('C:\Users\you\.cursor\hooks\orb-last.md', $text, $utf8)
} catch { }
exit 0
# C:\Users\you\.cursor\hooks\orb-publish.ps1
$ErrorActionPreference = 'Continue'
try {
  $stash  = 'C:\Users\you\.cursor\hooks\orb-last.md'
  $orbCli = 'C:\Users\you\.local\bin\orb-cli.exe'
  $topic  = 't_…'
  if ((Test-Path $stash) -and ((Get-Item $stash).Length -gt 0)) {
    $env:ORB_ENV = 'prod'
    Get-Content -Raw -Path $stash | & $orbCli publish -ignore-errors -topic $topic | Out-Null
    [System.IO.File]::WriteAllText($stash, '', [System.Text.Encoding]::UTF8)
  }
} catch { }
exit 0

OpenClaw

Untested

OpenClaw's command:stop hook is a user stop — it fires when someone aborts a turn, not when the agent finalizes one, and the docs say so explicitly. The observable end of a turn is message:sent, which carries the delivered content and a success flag.

Files: ~/.openclaw/hooks/orb/HOOK.md and handler.ts, then openclaw hooks enable orb:

<!-- HOOK.md -->
---
name: orb
description: "Publish the delivered reply text to an Orb topic"
metadata:
  openclaw:
    emoji: "🛰"
    events: ["message:sent"]
---
Publishes outbound assistant text to Orb.
// handler.ts
import { spawn } from "node:child_process"

const ORB_CLI = "/usr/local/bin/orb-cli"
const TOPIC = "t_…"

export default async function handler(event: any) {
  const ctx = event?.context ?? event
  if (!ctx?.success || typeof ctx.content !== "string" || !ctx.content.trim()) return
  const child = spawn(ORB_CLI, ["publish", "-ignore-errors", "-topic", TOPIC, ctx.content], {
    stdio: "ignore",
    detached: true,
  })
  child.on("error", () => {})
  child.unref()
}

Hermes

Untested

Hermes shell hooks are the closest thing here to Claude Code's: a subprocess per event, JSON on stdin, no Python plugin required. post_llm_call fires on successful, non-interrupted turn finalization — the event you want.

Config: the hooks: block in your profile's config.yaml (default ~/.hermes/config.yaml):

hooks:
  post_llm_call:
    - command: "/Users/you/.hermes/agent-hooks/orb-post-llm.sh"
      timeout: 30

The script, because the prose is nested one level deeper than -harness-input looks:

#!/bin/sh
# ~/.hermes/agent-hooks/orb-post-llm.sh
msg=$(jq -r '.extra.assistant_response // empty')
[ -n "$msg" ] || exit 0
printf '%s' "$msg" | /usr/local/bin/orb-cli publish -ignore-errors -topic t_…

Pi and oh-my-pi

Untested

Worth including because orb-cli's payload reader already understands their events: Pi's agent_end and oh-my-pi's session_stop carry the assistant message as an object or a messages array, and the text blocks are extracted while thinking and tool-call blocks are dropped.

Pi: install the Claude-format adapter, then use the same Stop shape as above in .pi/settings.json or ~/.pi/agent/settings.json:

pi install npm:@hsingjui/pi-hooks
# then add hooks.Stop → command /usr/local/bin/orb-cli args publish -harness-input -topic t_…
# and run /reload in the session

Kiro CLI

Untested

Kiro has a first-class Stop ("Agent Stop") trigger in both the IDE and the CLI, with hooks as standalone files. Its control channel is exit codes rather than JSON on stdout, and a Stop hook can return {"decision":"block","reason":"…"} to ask for another turn — so be careful what you print.

Read the payload before you wire the publish — a hook that only logs:

#!/bin/sh
# ~/.kiro/hooks/orb-probe.sh
date >> "$HOME/.kiro/orb-probe.log"
cat >> "$HOME/.kiro/orb-probe.log"
echo >> "$HOME/.kiro/orb-probe.log"

Register it on the Stop trigger, run one turn, then read ~/.kiro/orb-probe.log. Once you know which field holds the final reply, replace the log with the publish — silence on stdout, exit 0:

#!/bin/sh
# ~/.kiro/hooks/orb-stop.sh  (field name: confirm from the probe first)
jq -r '.assistant_response // .response // empty' \
  | /usr/local/bin/orb-cli publish -ignore-errors -topic t_… > /dev/null
exit 0

Everything else

Harnesses we looked at and did not give a section to, with the honest reason. Where there is no end-of-turn event, the fallback is the same everywhere: an instruction in the project's agent file (AGENTS.md, rules, custom instructions) telling the model to run orb-cli publish itself — less reliable than a hook, because it depends on the model choosing to, and it puts Orb in the prompt.

HarnessWhy it is not aboveWhat we would try
Gemini CLI No documented end-of-turn lifecycle hook; extension surface is commands and tools. MCP registration, or a command the model is instructed to call.
GitHub Copilot CLI Hook support is reported as plugin-bundled and version-dependent; we could not pin down the event set. A plugin that bundles a lifecycle hook, once the docs settle.
Aider Git-native and script-driven; no turn-completion hook. --message runs are already scripts — publish from the caller.
Crush No end-of-turn hook in the docs we read. Same wrapper approach as Aider.
Cline Its headless/SDK path is the integration point, not a hook file. Drive it from a script that publishes the final message.
Warp Terminal application rather than a CLI binary with lifecycle hooks. Nothing clean; use the MCP server.

If you only want it sometimes

Every recipe above publishes every turn. When the agent should decide instead, register the MCP server and let it call publish as a tool: the topic secret lives in the agent's environment and goes only to the Orb API. See the MCP how-to.

What lands on the topic

The assistant's prose, as markdown, one envelope per turn. Not the tool calls, not the thinking, not the transcript. If you want the run grouping that the clients draw, add -run-id to the publish and every turn of one session becomes a group; add -return-url and the envelope carries a single "next action" link. Both are in the CLI how-to.

Something below not working on your build? Send us the harness version, the config file and the first failing line — hello@orbnet.app. The two tested sections are tested on macOS; the other seven are waiting for exactly that report.