herdr

repository·master·Indexed 10 days ago

https://github.com/ogulcancelik/herdr

A persistent, agent-native terminal workspace manager and runtime environment for AI coding agents. It provides a background server to ensure sessions persist across disconnects, state awareness (working, blocked, idle), and a Socket API for agent-to-agent interaction. herdr supports a wide range of agents including Claude, Codex, Gemini, and Cursor, allowing them to run within a managed environment with tmux-style controls and a plugin system.

Tokens
219.1K
Snippets
768
Records
1K
Agent score
79%

What's inside herdr

  1. Overview of Herdr capabilities

    master

    Herdr is a terminal-native agent runtime and multiplexer designed to provide persistent terminal workspaces. Key features include:

    • Multiplexing: Real panes, tabs, and mouse control.
    • Persistence: Persistent sessions and the ability to detach safely.
    • Connectivity: Support for local execution, SSH attach, and remote workflows via herdr --remote.
    • Agent Orchestration: State awareness and an API (CLI and local socket) that allows agents to control the runtime themselves.
  2. What is Herdr?

    master

    Herdr is a terminal-native agent runtime and multiplexer. It provides persistent terminal workspaces featuring:

    • Panes and Tabs: Manage multiple terminal views within a single workspace.
    • Mouse Control: Interactive terminal navigation.
    • State Awareness: Support for session state, including detach/attach, restart restore, and pane history replay.
    • Agent Orchestration: An API that allows agents to use the runtime themselves, including native agent resume and live handoff.
    • Connectivity: Support for local execution, SSH attachment, and remote workflows via herdr --remote.
  3. Overview of herdr core features

    master

    herdr is an agent multiplexer that runs directly in your terminal. Key capabilities include:

    • Agent Visibility: Real-time terminal views showing agent states like blocked, working, and done.
    • Session Persistence: Agents continue running even after you disconnect. You can reconnect from any terminal or via SSH.
    • Agent-to-Agent Interaction: Agents can use a pure socket API to create panes, read output, and wait for each other.
    • Flexible Input: Supports both tmux-style prefix keys and mouse interactions (clicking, dragging, splitting).
    • Extensibility: A plugin system to extend panes and workflows.
    • Lightweight: A single Rust binary with no Electron dependency.
  4. Performance improvements in Herdr v0.8.0

    master

    Herdr v0.8.0 introduces significant CPU optimizations by reducing unnecessary rendering. In workloads with multiple agents and clients, total CPU usage for the server and attached clients fell by 89% to 95%.

    Key optimizations include:

    • Static Working States: Replaced animated spinners in the sidebar with static colored marks. This eliminates scheduled animation frames, timer wakeups, and frame patching.
    • Visibility-Aware Rendering: The server now tracks which panes are actually visible to clients (via tabs, zoom, or popups). If a pane producing output is not visible to any client, the server skips the render, serialization, and transmission steps, though it still parses the bytes to keep terminal state (scrollback, cursor, etc.) current.
    • Reduced Mouse Event Repaints: Mouse movement no longer triggers a frame repaint unless the user is interacting with specific modes like the global menu, context menus, or the navigator. Motion events are still forwarded to the application inside the pane, but Herdr's own UI remains static.
  5. Use herdr for agent session management

    master

    herdr is an agent multiplexer that runs in your terminal. It allows you to manage agent workflows with the following features:

    • Visual Status: Monitor agent states like blocked, working, and done through a real terminal view.
    • Session Persistence: Agents continue running even after you detach. You can detach from a session using ctrl+b q and reconnect later by running herdr in the same directory.
    • Remote Access: Sessions can be reconnected to via SSH.
    • Agent Skills: Agents can interact with herdr via a pure socket API to create panes, read output, and wait for other agents.
    • Interaction: Supports tmux-style prefix keys as well as mouse interactions (clicking, dragging, and splitting panes).
  6. Understand Windows beta support and limitations

    master

    Native Windows support is experimental and uses ConPTY instead of the Unix PTY model.

    Supported Capabilities

    • Local persistent sessions
    • Native panes through ConPTY
    • Windows Terminal / PowerShell app attach
    • cmd.exe panes
    • Startup cwd and workspace labels
    • Agent command discovery and process-tree detection
    • Git/worktree detection from known cwd
    • Plugins (in preview)

    Partial Support

    • Live cwd after shell cd (use Herdr integrations or shell integration for reliable reporting)
    • CJK IME composition anchoring
    • Host cursor rendering

    Unsupported Features

    • Direct terminal attach
    • herdr --remote from the Windows binary
    • Live server handoff
    • Unix file-descriptor handoff
    • Unix foreground process groups
    • Remote clipboard image bridge
  7. Core capabilities of the Herdr runtime

    master

    Herdr is a terminal-native agent runtime and multiplexer designed for persistent terminal workspaces. Key features include:

    • Persistence (Detach/Reattach): Panes run in a background session server, allowing agents to continue running even after the UI client detaches.
    • Remote Access: You can attach to a Herdr session over SSH or use herdr --remote from a local terminal to access environments where code and credentials reside.
    • Real Terminal Panes: Supports split layouts, mouse control (clicking panes, dragging borders, selecting text), and right-click menus.
    • Runtime API: Provides visibility into agent status via a sidebar and allows orchestration of workspaces, tabs, panes, waits, and output reads via the CLI or Socket API.
  8. Overview of herdr core concepts

    master

    herdr is a persistent runtime environment designed specifically for coding agents. Key features include:

    • Always Running: It operates as a background server. Terminals live inside the server, meaning sessions persist across network drops, lid closures, or machine restarts.
    • Agent-Native: Agents interact with herdr via a CLI and Socket API to spawn panes, prompt other agents, and manage workflows.
    • State Awareness: Every pane is explicitly marked as working, blocked, or idle, allowing agents to identify when they are stuck or waiting for input.
    • Tool Agnostic: It does not replace existing tools like Claude Code, Cursor, or Codex; instead, it owns their terminals, allowing them to run within the herdr environment.
    • Hybrid Interaction: Supports both tmux-style keyboard prefix keys and mouse interactions (click, drag, split).
    • Extensible: Supports a plugin system to extend panes and workflows.
  9. How visibility-aware rendering works

    master

    To save CPU, Herdr optimizes how it handles output from panes that are not currently being viewed.

    The Workflow in v0.8.0:

    1. A pane produces output via a PTY write.
    2. The server receives a request_pty(pane_id) which identifies the specific source.
    3. The server checks: can any client see pane_id? (considering tabs, zoom, popups, and direct attaches).
    4. If NO: The server stops the render process. Bytes are still parsed to maintain terminal state (scrollback, cursor, OSC metadata), but no frames are prepared, serialized, or transmitted.
    5. If YES: The server renders the output as usual.

    This ensures that switching to a previously hidden tab renders immediately from the correct, current state without the overhead of constant background repainting.

  10. Understand Herdr workspaces, tabs, and panes

    master

    Herdr is a terminal workspace manager that structures real terminal processes.

    • Workspace: The top-level container for a project, task, or investigation. A workspace owns tabs and panes. Its sidebar state reflects the status of the agents within it.
    • Tab: A layout within a workspace used to separate different views (e.g., agents, logs, server, or review). Tabs are addressable via the CLI and socket API.
    • Pane: A real terminal instance. Herdr renders the output, handles input, and preserves the pane even if the client detaches. Panes can be split horizontally (down) or vertically (right), renamed, and closed.
  11. Navigate Herdr using modes

    master

    Herdr utilizes three distinct modes for interaction:

    1. Terminal mode: Sends keystrokes directly to the currently focused pane.
    2. Prefix mode: Triggered by the prefix key (default ctrl+b), this mode waits for a subsequent action key.
    3. Navigate mode: The persistent surface used for workspace navigation.

    Example usage: To create a new tab, press the prefix key (ctrl+b) followed by c. To navigate workspaces, press the prefix key followed by w.