@cotal-ai/herdr

中文文档
0.157.2发布于 2026/11/11Apache-2.0TypeScriptES Module零依赖构建来源已验证近 30 天下载 5.8万

Cotal Herdr integration: a Herdr Runtime provider for spawning agents into panes of a dedicated Herdr session.

原始使用文档
文档目录7 节
  1. What it does
  2. How a spawn works
  3. Secrets
  4. Not in herdr's Agents sidebar
  5. Usage
  6. Testing
  7. Differences from @cotal-ai/tmux

@cotal-ai/herdr

The Herdr integration: a thin driver over the herdr CLI (start a pane running a command, send keys, close it) plus a self-registering herdr Runtime provider. Importing it registers the provider with the core Registry, so the manager can spawn agents into Herdr panes without depending on this package.

Tier: extensions/. Peer-depends @cotal-ai/core; self-registers on import.

Requires herdr 0.8.0 or later (brew install herdr, or see herdr.dev). 0.7.x exposed agent start --cwd -- <argv> and agent send, both of which 0.8.0 removed, and the two lines share no usable subset. available() reads the version rather than only probing that the binary runs, so an older herdr reports the runtime as unavailable instead of advertising it as ready and then failing every spawn.

What it does

The herdr Runtime gives each agent its own pane in a dedicated named Herdr session, cotal-<space>, with its own server and socket. It never uses your default Herdr session, so no Cotal operation can touch unrelated panes. The session server is started headless on first spawn and owns the panes, so agents keep running when the manager's terminal goes away; watch them with herdr session attach cotal-<space>.

By default every agent gets its own workspace and name-labeled tab; set COTAL_HERDR_LAYOUT=split on the manager to fold agents into one shared tab instead (an unknown value fails loud). Graceful stop types /exit then closes the pane; hard stop closes immediately.

How a spawn works

herdr 0.8.0 has no "create a pane running this command" primitive. agent start attaches a recognized agent kind to an existing pane, pane split needs a pane to split from, and a fresh headless server has no workspace, tab, or pane at all. So a spawn is:

  1. workspace create --cwd <cwd> --label <name> --no-focus: one call yielding a workspace, a tab, and a root pane, with the working directory honoured. This also gives the one-tab-per-agent layout without a follow-up move.
  2. tab rename <tab_id> <name>: --label names the workspace, and the tab strip, which is what an operator reads, would otherwise show a bare number.
  3. pane run <pane_id> "exec <command>". A plain pane run leaves the pane's shell alive after the command exits, so the pane would outlive the agent and an exit could never be proven. exec replaces the shell, so herdr closes the pane when the agent exits.
  4. Poll pane process-info until the process actually appears, bounded. pane run types into a shell, so a successful call proves the keystrokes were delivered, not that anything started; if the process never appears the half-built workspace is torn down and the spawn throws.

Lifecycle is keyed off Herdr's globally-unique terminal_id; the workspace-scoped public pane_id (which changes when a pane is moved) is re-resolved before every pane-scoped call, off the session-wide pane inventory. Exit waits poll that inventory and fail closed on provider errors: a failed inventory throws rather than reporting a false exit.

Secrets

Connector env (identity, credentials, control token) rides an owner-only (0600) launcher script in a private 0700 directory. herdr only sees the node executable and the script path, and the script removes its own directory as soon as it has loaded.

Do not "simplify" this to herdr's native --env KEY=VALUE. It is available on both workspace create and tab create, and it puts the value straight into the pane's scrollback, where herdr pane read returns it verbatim. The launcher exists precisely to avoid that.

Not in herdr's Agents sidebar

Spawned agents do not appear in Herdr's Agents sidebar, and this is a property of 0.8.0 rather than something the driver could fix: herdr reserves its agent registry for a fixed set of recognized kinds (pi, claude, codex, gemini, cursor, …) attached to an existing pane via agent start --kind. A Cotal agent runs an arbitrary launcher, so it is never one of those kinds, and agent get/agent list cannot see it. Agents are identified instead by their tab label and by a cotal metadata token on the pane (visible in pane get and the pane UI).

Usage

cotal ext add @cotal-ai/herdr
cotal supervise --runtime herdr

Library composition roots can instead import it explicitly:

import "@cotal-ai/herdr"; // self-registers; no other setup needed

Testing

pnpm smoke:herdr runs the suite against a real herdr server in isolated named sessions. It skips with a loud notice when herdr is absent or too old, and CI installs herdr so that skip never silently stands in for a pass.

Differences from @cotal-ai/tmux

Same shape (native-watch, no PTY streaming; a shared per-space session), but panes live in a Herdr session whose server also tracks pane status natively, and the runtime is pane-based rather than window-based. A failed server start is detected early via POSIX ps where present; without it (Windows, a ps-less container) death is never assumed, and the same failure surfaces at the bounded startup window, with the server's own stderr either way.

See docs/architecture.mdx (Manager supervision) and the root AGENTS.md for the tier rules.

版本与发布记录

@cotal-ai/herdr 共发布 379 个版本,首次发布于 2026/08/14;过去 12 个月发布了 379 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.157.2latest2026/11/11今天
0.157.12026/11/11今天
0.157.02026/11/11今天
0.156.02026/11/11今天
0.155.22026/11/10今天
0.155.12026/11/10今天

其他发布通道:hack → 0.28.0-hack-20260823234508。

关于 @cotal-ai/herdr 的常见问题

@cotal-ai/herdr 是什么?

Cotal Herdr integration: a Herdr Runtime provider for spawning agents into panes of a dedicated Herdr session.

如何安装 @cotal-ai/herdr?

在项目目录运行 npm install @cotal-ai/herdr,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@cotal-ai/core(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cotal-ai/herdr 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cotal-ai/herdr 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cotal-ai/herdr 可以商用吗?

@cotal-ai/herdr 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@cotal-ai/herdr 的下载量有多少?

根据 npm 官方下载统计,@cotal-ai/herdr 在 2026/10/11 – 2026/11/09 这 30 天内被下载 57,845 次,日均约 1,928 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cotal-ai/herdr 还在维护吗?

最新版本 0.157.2 发布于 2026/11/11(今天);至今共发布 379 个版本,其中过去 12 个月发布了 379 个;首次发布于 2026/08/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。