Skip to main content

klein

klein lets you watch a running BehaviorTree.CPP v4 tree live in your browser. You see which nodes are running, succeeding or failing, plus the current blackboard values, as the robot ticks.

klein showing a live CrossDoor behavior tree: running nodes pulse, the blackboard updates, and the Timeline below draws each node's RUNNING spans as the robot ticks

Install

Install it from PyPI with uv:

uv tool install klein-bt

uv fetches a newer Python by itself if yours is older than the 3.10 klein needs. pipx works too:

pipx install klein-bt

This gives you two commands: klein-bt (the dashboard) and klein-bt-mock (a fake robot for trying it out).

Run it

klein-bt                                          # robot on 127.0.0.1:1667
klein-bt --robot-host 10.0.0.5 --robot-port 1667  # robot somewhere else
klein-bt --port 8080 --no-browser                 # don't open a browser
klein-bt --host 0.0.0.0                           # let other machines open it
klein-bt --open run.btlog                         # a saved recording, no robot
Flag Default Meaning
--robot-host 127.0.0.1 IP address of the robot
--robot-port 1667 Groot2 publisher port on the robot
--host 127.0.0.1 interface the dashboard is served on; 0.0.0.0 opens it to the network
--port 8080 port the dashboard is served on
--no-browser off don't open the browser automatically
--record-buffer 10m how much recent history to record (90s, 30m, 1h); 0 turns recording off
--open FILE show a saved .btlog (and FILE.bb.jsonl beside it) instead of a robot

klein opens http://localhost:8080 for you. You can start it before the robot is up; it keeps retrying until the robot appears.

By default only this machine can open the dashboard. To watch from another computer (klein on the robot, the browser on your laptop), pass --host 0.0.0.0 and open http://<this machine's address>:8080 there. There is no password: anyone who can reach that port sees the live tree and blackboard values and can download the recording. Do this only on a network you trust, or use an SSH tunnel instead (ssh -L 8080:localhost:8080 robot, then http://localhost:8080).

Using the dashboard

  • Node colours show status: green is SUCCESS, pulsing amber is RUNNING, red is FAILURE, grey is IDLE.
  • Scroll to zoom and drag to pan. Click a node to fold or unfold its children.
  • Press R to see the whole tree again, or F to jump to whatever is running.
  • Hover a node to see its ports.
  • Layout switches between a vertical and a horizontal tree.
  • The Blackboards list shows every subtree's values. A value that just changed gets a thin amber edge that fades; a key that changes all the time (a position, a counter) gets a steady dim edge and a ~ instead. Click a row to expand it, or hover a board to find its node in the tree. See docs/blackboards.md for how values are shown.
  • Hover a key to see which nodes use it: writers outlined solid, readers dashed. Hover a node to ring its keys. Writers get a small amber dot when the key changes.
  • Drag the side panel's right edge to make it wider or narrower, or fold it away with its ◂ button (or a double-click on the edge) for more room. klein remembers both.

If the robot loads a different tree, the dashboard switches to it by itself.

Record, rewind and replay

klein records everything the robot does (BehaviorTree.CPP 4.3.3 or newer), blackboard included, and keeps the last 10 minutes. Change that with --record-buffer (30m, 1h, or 0 to turn recording off). Don't log from Groot2 against the same robot at the same time: each would get only some of the transitions.

klein rewinding a live robot: hover the minimap (its scrollbar shows), drag its box back, click a burst, scrub, step, hover a key, play, back to live

The drawer under the tree shows the recording. Its top row works in every tab, even with the drawer folded:

  • |◀ ▶| step to the previous or next transition, and ▶ plays at 1×. While live it reads ❚❚: press it to freeze the tree, the blackboard and the clock right where they are.
  • The green ● Live says you are live. In the past it turns into Go live, which takes you back; the tree gets a thin amber edge, and the clock beside the bar says which moment you see. Changes are marked in the past too: stepping or clicking shows which values just changed.
  • The bar is a minimap of the recording, eight of the Timeline's windows long (live, now is its right edge): amber columns show how busy the robot was, hatched stretches are outages, and a pink dashed line marks where the robot started another tree. Click or drag it to go to that moment; hover it for the time. On the Timeline tab a box on it is the Timeline's window: drag it (or turn the wheel) to pan. While the pointer is over the bar, a thin scrollbar for the whole recording shows underneath.
  • The keys: ←/→ step, Space plays or pauses, Home goes to the oldest moment kept, End or Esc goes live, and \ zooms the Timeline to fit everything kept (also its ⤢ button).

Below it are two tabs, a filter and the recording pill:

  • Log: every transition. Click a row to see the tree and blackboard at that moment.
  • Timeline: each node's running time as bars, so every retry shows. Drag the playhead to go back in time; − and + change the window.
  • The Filter beside the tabs narrows both tabs, and stepping, to the nodes and subtrees you name.
  • Save, on the recording pill (● Recording 10 min · 148 kB), downloads one .zip with a .btlog per tree run (Groot2 opens these) and its blackboard in a .bb.jsonl beside it.

klein-bt --open FILE.btlog shows a saved recording without a robot, in the same Log and Timeline; Go to end takes you to its end. Unzip a saved .zip first; the .bb.jsonl beside the file brings its blackboard along.

Set up your robot

klein talks to the Groot2 publisher that comes with BehaviorTree.CPP v4. If Groot2 can connect to your robot, klein can too. If not, add a publisher after you create the tree:

#include "behaviortree_cpp/loggers/groot2_publisher.h"

auto tree = factory.createTreeFromFile("my_tree.xml");
BT::Groot2Publisher publisher(tree, 1667);

The publisher also uses the next port up (1668), so leave that one free.

Try it without a robot

klein-bt-mock --port 1777        # in one terminal
klein-bt --robot-port 1777       # in another

Add --switch-every 200 to the mock to make it swap between two trees every 20 seconds or so.

Docs

License

klein is released under the MIT License — see LICENSE.

The dashboard bundles D3.js v7 (ISC License, © Mike Bostock), served locally so it works on air-gapped networks.

Disclaimer

klein is an independent tool. It is not affiliated with, endorsed by, or sponsored by the BehaviorTree.CPP project or the authors of Groot / Groot2. "BehaviorTree.CPP", "Groot", and "Groot2" are the property of their respective owners. klein interoperates over the Groot2 publisher wire protocol that is part of the open-source, MIT-licensed BehaviorTree.CPP library; it contains no code copied from those projects.

Metadata

Release files for klein-bt 0.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for klein-bt 0.8.1
File Size Uploaded Provenance Actions
klein_bt-0.8.1.tar.gz 246.5 kB With provenance Details for klein_bt-0.8.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for klein-bt 0.8.1
File Interpreter ABI Platform Actions
klein_bt-0.8.1-py3-none-any.whl Python 3 none any Details for klein_bt-0.8.1-py3-none-any.whl

Total release size: 503.3 kB

Release files / klein_bt-0.8.1.tar.gz

Download URL klein_bt-0.8.1.tar.gz
Size 246.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6a73ca91e5708a0eae50fd5d7ee3eebb348dccec24b0ce72162ebdc01e668aa4
BLAKE2b-256 checksum
How to use checksums
af4c5a0024f42dee20f32dbe573d3b22da5ca8dd5ca30f0c7e3ce7b53a736ec5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / klein_bt-0.8.1-py3-none-any.whl

Download URL klein_bt-0.8.1-py3-none-any.whl
Size 256.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1736baae6471d697cdb7e238616eacaec4ce05f5fdea1871b1af4cb29dc68c86
BLAKE2b-256 checksum
How to use checksums
ee4d11cd44bf8ff337a44404163f995e340107b8160f6c65a4e0e8862ef6f8e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Security for klein-bt 0.8.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for klein_bt-0.8.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page