Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0335e0e6bc | |||
| 18614f378d | |||
| 63ed90ba05 | |||
| 3ed88062d6 | |||
| 27313d4413 | |||
| d4b949a6f4 | |||
| 8930865376 | |||
| 29858ddccb |
+74
-1
@@ -30,12 +30,64 @@ dashboard, run it from source, or stay on Node 20.
|
|||||||
| Node.js | 20+ (22+ recommended) | Required for server and client |
|
| Node.js | 20+ (22+ recommended) | Required for server and client |
|
||||||
| npm | 9+ | Comes with Node.js |
|
| npm | 9+ | Comes with Node.js |
|
||||||
| Claude Code | 2.x+ | Required for hook integration |
|
| Claude Code | 2.x+ | Required for hook integration |
|
||||||
|
| Git | Any | Cloning the repository, and every lane operation (worktrees, branch/status reads) |
|
||||||
|
| **tmux** | 3.x | **Required for the run console** — the browser terminal, `agenthub lanes shell`, typing `/reload-plugins` into a live pane, and the Codex nudge. See [Step 0](#step-0--system-packages) |
|
||||||
|
| Codex CLI | Any | Optional — only for lanes whose tool is `codex` |
|
||||||
|
| GitHub CLI (`gh`) | Any | Optional — only for `agenthub lanes ci status` and the PR stages of `/agenthub:ship-full` |
|
||||||
| Python | 3.6+ | Optional — only for `scripts/expand-ts-module-docs.py` (doc generation) |
|
| Python | 3.6+ | Optional — only for `scripts/expand-ts-module-docs.py` (doc generation) |
|
||||||
| Git | Any | For cloning the repository |
|
|
||||||
| `superpowers` plugin | Any | Optional — required only by `/agenthub:ship-feature` and `/agenthub:ship-feature-lane`, which drive its skills step by step (and which the built-in pipeline templates name as their per-node commands). Nothing else in AgentHub needs it; `/agenthub-doctor` reports it as `WARN` when absent. **Installed automatically** by the plugin's `SessionStart` bootstrap (opt out with `AGENTHUB_AUTO_INSTALL_PLUGINS=0`); by hand: `claude plugin install superpowers@claude-plugins-official` |
|
| `superpowers` plugin | Any | Optional — required only by `/agenthub:ship-feature` and `/agenthub:ship-feature-lane`, which drive its skills step by step (and which the built-in pipeline templates name as their per-node commands). Nothing else in AgentHub needs it; `/agenthub-doctor` reports it as `WARN` when absent. **Installed automatically** by the plugin's `SessionStart` bootstrap (opt out with `AGENTHUB_AUTO_INSTALL_PLUGINS=0`); by hand: `claude plugin install superpowers@claude-plugins-official` |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Step 0 — System packages
|
||||||
|
|
||||||
|
Node and npm are not enough: `git` backs every lane operation, and **`tmux`
|
||||||
|
backs the run console**. The dashboard shells out to the `tmux` binary and has
|
||||||
|
no bundled fallback, so without it **Start Run** and `agenthub lanes shell`
|
||||||
|
fail while everything else keeps working.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt install git tmux # Debian / Ubuntu
|
||||||
|
sudo dnf install git tmux # Fedora / RHEL
|
||||||
|
brew install git tmux # macOS
|
||||||
|
sudo pacman -S git tmux # Arch
|
||||||
|
```
|
||||||
|
|
||||||
|
Windows has no native tmux. Run AgentHub under **WSL2** and install it inside
|
||||||
|
the WSL distro — a tmux from Git Bash or MSYS is not what the server executes.
|
||||||
|
|
||||||
|
Check it:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tmux -V # e.g. tmux 3.4
|
||||||
|
git --version
|
||||||
|
node -v # v20.x / v22.x / v24.x
|
||||||
|
```
|
||||||
|
|
||||||
|
Once the server is up you can ask it directly — this is the same probe the
|
||||||
|
dashboard uses:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -s localhost:4820/api/run/tmux # {"available":true}
|
||||||
|
```
|
||||||
|
|
||||||
|
**No configuration is needed.** AgentHub creates its own session per lane,
|
||||||
|
named `agenthub-lane-<id>`, and never reads your `~/.tmux.conf` for anything it
|
||||||
|
depends on (mouse mode is set on the session explicitly). You can attach to the
|
||||||
|
exact same pane from a normal terminal:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
agenthub lanes shell # from inside the lane's directory
|
||||||
|
tmux attach -t agenthub-lane-7 # or by name
|
||||||
|
tmux ls # every dashboard session is prefixed agenthub-lane-
|
||||||
|
```
|
||||||
|
|
||||||
|
Detaching is `Ctrl-b d` — it leaves the run alive, which is the whole point:
|
||||||
|
the browser terminal and your local terminal are two clients on one pane, and
|
||||||
|
restarting the dashboard never stops a run.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Step 1 — Clone the repository
|
## Step 1 — Clone the repository
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -261,6 +313,27 @@ npm run setup
|
|||||||
|
|
||||||
The Vite dev server and Express server run on different ports. Make sure both are running (`npm run dev` starts both). Open **http://localhost:5173**, not `http://localhost:4820`, during development.
|
The Vite dev server and Express server run on different ports. Make sure both are running (`npm run dev` starts both). Open **http://localhost:5173**, not `http://localhost:4820`, during development.
|
||||||
|
|
||||||
|
### "Start Run" fails, or the terminal never attaches
|
||||||
|
|
||||||
|
The run console is tmux-backed. Check, in this order:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tmux -V # not installed → see Step 0
|
||||||
|
curl -s localhost:4820/api/run/tmux # {"available":false} → the SERVER cannot see tmux
|
||||||
|
curl -s "localhost:4820/api/run/binary?tool=claude" # {"found":true,"path":"…"}
|
||||||
|
```
|
||||||
|
|
||||||
|
`{"available":false}` while your own shell finds tmux means the server runs with
|
||||||
|
a different `PATH` — most often a systemd `--user` service, which does not read
|
||||||
|
your shell profile. Fix it by installing tmux system-wide (`/usr/bin/tmux`)
|
||||||
|
rather than into a shell-managed prefix, then `agenthub service uninstall &&
|
||||||
|
agenthub service install`.
|
||||||
|
|
||||||
|
The same `PATH` rule applies to `claude` and `codex`: a run starts the binary by
|
||||||
|
name, so a `claude` installed only through an interactive shell's profile is
|
||||||
|
invisible to a service-managed server. `{"found":false}` for the lane's tool is
|
||||||
|
that case.
|
||||||
|
|
||||||
### No sessions appearing after starting Claude Code
|
### No sessions appearing after starting Claude Code
|
||||||
|
|
||||||
See [SETUP.md — Troubleshooting](./SETUP.md#troubleshooting) for detailed hook debugging steps.
|
See [SETUP.md — Troubleshooting](./SETUP.md#troubleshooting) for detailed hook debugging steps.
|
||||||
|
|||||||
@@ -13,10 +13,24 @@ Internal build — all rights reserved.
|
|||||||
|
|
||||||
*(Tiếng Việt: [README.vi.md](README.vi.md))*
|
*(Tiếng Việt: [README.vi.md](README.vi.md))*
|
||||||
|
|
||||||
## What it does
|
## Main features
|
||||||
|
|
||||||
|
**Observe**
|
||||||
|
|
||||||
- **Sessions, agents, events.** Everything Claude Code emits, recorded and
|
- **Sessions, agents, events.** Everything Claude Code emits, recorded and
|
||||||
searchable: tool calls, token usage, cost, subagent trees, transcripts.
|
searchable: tool calls, token usage, cost, subagent trees, transcripts.
|
||||||
|
- **Analytics and cost.** Per-model token totals and estimated cost, with
|
||||||
|
editable pricing rules; top tools, agent types, and workflow patterns.
|
||||||
|
- **Activity feed and alerts.** A live event stream, alert rules, and webhook
|
||||||
|
targets that fire on them.
|
||||||
|
- **History import.** Every session under `~/.claude/projects/` is imported on
|
||||||
|
startup; archives from another machine come in through Settings → Import
|
||||||
|
History (idempotent, never double-counts tokens).
|
||||||
|
- **Remote sources.** Pull session history from other machines over SSH
|
||||||
|
(`agenthub remote-sources`).
|
||||||
|
|
||||||
|
**Drive**
|
||||||
|
|
||||||
- **Lanes.** One lane per working directory, surviving session restarts. A lane
|
- **Lanes.** One lane per working directory, surviving session restarts. A lane
|
||||||
moves through pipeline stages and the dashboard shows where it is.
|
moves through pipeline stages and the dashboard shows where it is.
|
||||||
- **Stage detection.** The stage is inferred from the tool stream, so a session
|
- **Stage detection.** The stage is inferred from the tool stream, so a session
|
||||||
@@ -26,15 +40,72 @@ Internal build — all rights reserved.
|
|||||||
PTY, rendered with xterm.js) attached to a lane's directory — the exact TUI
|
PTY, rendered with xterm.js) attached to a lane's directory — the exact TUI
|
||||||
you'd see locally, fully interactive, resumable, and attachable from a real
|
you'd see locally, fully interactive, resumable, and attachable from a real
|
||||||
terminal too via `agenthub lanes shell`. Which CLI it starts is the lane's own
|
terminal too via `agenthub lanes shell`. Which CLI it starts is the lane's own
|
||||||
setting.
|
setting. **This is the part that needs `tmux` installed** — see
|
||||||
- **Analytics (in-dashboard tab), alerts, and a workflow view**, plus a CLI.
|
[Prerequisites](#prerequisites).
|
||||||
|
- **Per-lane app stacks.** A repo that declares `.agenthub/profile/` gets its own
|
||||||
|
slot, ports and services per lane (`agenthub lanes up|down|logs`).
|
||||||
|
- **Ship pipelines.** `/agenthub:ship-full` and `/agenthub:ship-quick` drive a
|
||||||
|
feature from intake to PR, declaring every stage to the dashboard as it goes.
|
||||||
|
|
||||||
## Requirements
|
**Configure**
|
||||||
|
|
||||||
Node **>= 20** (`engines` in `package.json`). Node **24** is what the test suites
|
- **Claude Code + Codex configuration explorer.** Settings hosts one panel per
|
||||||
are verified on — node 25 currently breaks 6 server tests through a
|
tool: every plugin, skill, subagent, slash command, MCP server, hook, settings
|
||||||
|
file, memory file, marketplace, keybinding and statusline Claude Code knows
|
||||||
|
about — read for all of them, edit/create/delete for the text-file surfaces
|
||||||
|
(skills, agents, commands, output styles, `CLAUDE.md`). Plugins, MCP, hooks and
|
||||||
|
`settings.json` stay read-only: they race with the live CLI.
|
||||||
|
- **Updates.** Release-based update detection with an in-UI **Update all**
|
||||||
|
(marketplaces → every plugin → AgentHub last → one session reload).
|
||||||
|
- **A CLI for all of it** (`agenthub`, plus `agenthub repl`), a PWA install, and
|
||||||
|
a UI in English, Vietnamese, Chinese and Korean.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
| Need | Version | Required for |
|
||||||
|
|---|---|---|
|
||||||
|
| **Node.js** | >= 20 (>= 22.5 for a plugin install) | Everything. Both suites are verified green on **24** and **26** |
|
||||||
|
| **npm** | 9+ | Ships with Node |
|
||||||
|
| **git** | any | Cloning, and every lane operation (worktrees, branch/status reads) |
|
||||||
|
| **tmux** | 3.x | The browser run console, `agenthub lanes shell`, typing `/reload-plugins` into a live pane, the Codex nudge |
|
||||||
|
| **Claude Code** | 2.x | Hook ingestion — the whole monitoring side |
|
||||||
|
| **Codex CLI** | any | Optional — only for `codex` lanes |
|
||||||
|
| **GitHub CLI (`gh`)** | any | Optional — only for `agenthub lanes ci status` and the PR stages of the ship pipelines |
|
||||||
|
| **systemd (user)** | — | Optional — only for `agenthub service install` (Linux auto-start on boot) |
|
||||||
|
|
||||||
|
Node **25** is the one version to avoid: it breaks 6 server tests through a
|
||||||
better-sqlite3 ABI mismatch and 20 client tests through a global `localStorage`
|
better-sqlite3 ABI mismatch and 20 client tests through a global `localStorage`
|
||||||
change.
|
change. Both were gone again by 26 (1712 server + 488 client tests green on
|
||||||
|
v26.8.1).
|
||||||
|
|
||||||
|
### Installing tmux
|
||||||
|
|
||||||
|
The dashboard shells out to the `tmux` binary; there is no bundled fallback, so
|
||||||
|
**Start Run** and `agenthub lanes shell` fail without it. Everything else
|
||||||
|
(sessions, analytics, lanes, stage detection, the CLI) works fine.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt install tmux # Debian / Ubuntu
|
||||||
|
sudo dnf install tmux # Fedora / RHEL
|
||||||
|
brew install tmux # macOS
|
||||||
|
sudo pacman -S tmux # Arch
|
||||||
|
```
|
||||||
|
|
||||||
|
Windows has no native tmux — run AgentHub under WSL2 and install it there.
|
||||||
|
|
||||||
|
Verify, both from your shell and from the server's point of view:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tmux -V # e.g. tmux 3.4
|
||||||
|
curl -s localhost:4820/api/run/tmux # {"available":true}
|
||||||
|
```
|
||||||
|
|
||||||
|
A lane's run lives in a tmux session named `agenthub-lane-<id>`, so the browser
|
||||||
|
terminal and a local `tmux attach -t agenthub-lane-<id>` (or `agenthub lanes
|
||||||
|
shell`) are two clients on the same pane — they stay in sync, and killing the
|
||||||
|
dashboard never kills the run.
|
||||||
|
|
||||||
|
### The superpowers plugin
|
||||||
|
|
||||||
The **`superpowers` plugin is required by the ship-feature pipelines only**, not
|
The **`superpowers` plugin is required by the ship-feature pipelines only**, not
|
||||||
by the dashboard. `/agenthub:ship-feature` and `/agenthub:ship-feature-lane` drive
|
by the dashboard. `/agenthub:ship-feature` and `/agenthub:ship-feature-lane` drive
|
||||||
|
|||||||
+93
-7
@@ -13,10 +13,24 @@ Internal build — all rights reserved.
|
|||||||
|
|
||||||
*(Bản dịch tiếng Việt của [README.md](README.md), tham khảo — README.md gốc là bản chính thức.)*
|
*(Bản dịch tiếng Việt của [README.md](README.md), tham khảo — README.md gốc là bản chính thức.)*
|
||||||
|
|
||||||
## Làm được gì
|
## Chức năng chính
|
||||||
|
|
||||||
|
**Quan sát**
|
||||||
|
|
||||||
- **Session, agent, event.** Mọi thứ Claude Code emit ra, ghi lại và tìm kiếm
|
- **Session, agent, event.** Mọi thứ Claude Code emit ra, ghi lại và tìm kiếm
|
||||||
được: tool call, token usage, cost, cây subagent, transcript.
|
được: tool call, token usage, cost, cây subagent, transcript.
|
||||||
|
- **Analytics và chi phí.** Token và cost ước tính theo từng model, với bảng
|
||||||
|
pricing sửa được; top tool, agent type và workflow pattern.
|
||||||
|
- **Activity feed và alert.** Luồng event trực tiếp, alert rule, và webhook
|
||||||
|
target bắn khi rule khớp.
|
||||||
|
- **Import lịch sử.** Mọi session dưới `~/.claude/projects/` được import lúc
|
||||||
|
khởi động; lịch sử từ máy khác đưa vào qua Settings → Import History
|
||||||
|
(idempotent, không bao giờ đếm trùng token).
|
||||||
|
- **Remote source.** Kéo lịch sử session từ máy khác qua SSH
|
||||||
|
(`agenthub remote-sources`).
|
||||||
|
|
||||||
|
**Điều khiển**
|
||||||
|
|
||||||
- **Lane.** Mỗi working directory một lane, sống sót qua session restart. Lane
|
- **Lane.** Mỗi working directory một lane, sống sót qua session restart. Lane
|
||||||
đi qua các pipeline stage và dashboard hiển thị nó đang ở đâu.
|
đi qua các pipeline stage và dashboard hiển thị nó đang ở đâu.
|
||||||
- **Stage detection.** Stage được suy luận (infer) từ tool stream, nên một
|
- **Stage detection.** Stage được suy luận (infer) từ tool stream, nên một
|
||||||
@@ -26,14 +40,86 @@ Internal build — all rights reserved.
|
|||||||
- **Chạy Claude Code hoặc Codex từ trình duyệt.** Một terminal thật (tmux + PTY
|
- **Chạy Claude Code hoặc Codex từ trình duyệt.** Một terminal thật (tmux + PTY
|
||||||
thật, render bằng xterm.js) gắn vào thư mục của lane — đúng cái TUI bạn thấy ở
|
thật, render bằng xterm.js) gắn vào thư mục của lane — đúng cái TUI bạn thấy ở
|
||||||
máy, tương tác đầy đủ, resume được, và attach được từ terminal thật qua
|
máy, tương tác đầy đủ, resume được, và attach được từ terminal thật qua
|
||||||
`agenthub lanes shell`. Chạy CLI nào là thiết lập riêng của từng lane.
|
`agenthub lanes shell`. Chạy CLI nào là thiết lập riêng của từng lane. **Đây
|
||||||
- **Analytics (tab trong dashboard), alert và workflow view**, cộng thêm CLI.
|
chính là phần cần cài `tmux`** — xem [Yêu cầu hệ thống](#yêu-cầu-hệ-thống).
|
||||||
|
- **App stack riêng cho từng lane.** Repo khai báo `.agenthub/profile/` thì mỗi
|
||||||
|
lane được cấp slot, port và service riêng (`agenthub lanes up|down|logs`).
|
||||||
|
- **Ship pipeline.** `/agenthub:ship-full` và `/agenthub:ship-quick` đưa một
|
||||||
|
feature từ intake tới PR, khai báo từng stage về dashboard trên đường đi.
|
||||||
|
|
||||||
## Yêu cầu
|
**Cấu hình**
|
||||||
|
|
||||||
Node **>= 20** (`engines` trong `package.json`). Node **24** là bản test suite
|
- **Trình khám phá cấu hình Claude Code + Codex.** Trang Settings có một panel
|
||||||
được verify — node 25 hiện đang làm gãy 6 test server do lệch ABI
|
cho mỗi tool: mọi plugin, skill, subagent, slash command, MCP server, hook,
|
||||||
`better-sqlite3` và 20 test client do thay đổi global `localStorage`.
|
settings file, memory file, marketplace, keybinding và statusline mà Claude
|
||||||
|
Code biết — đọc được tất cả, còn sửa/tạo/xóa thì chỉ cho các bề mặt dạng file
|
||||||
|
text (skill, agent, command, output style, `CLAUDE.md`). Plugin, MCP, hook và
|
||||||
|
`settings.json` để read-only: chúng tranh ghi với CLI đang chạy.
|
||||||
|
- **Cập nhật.** Phát hiện bản mới dựa trên release, kèm nút **Update all** ngay
|
||||||
|
trong UI (marketplace → mọi plugin → AgentHub sau cùng → reload session).
|
||||||
|
- **CLI cho toàn bộ** (`agenthub`, và `agenthub repl`), cài được như PWA, UI có
|
||||||
|
tiếng Anh, Việt, Trung và Hàn.
|
||||||
|
|
||||||
|
## Yêu cầu hệ thống
|
||||||
|
|
||||||
|
| Cần | Phiên bản | Dùng cho |
|
||||||
|
|---|---|---|
|
||||||
|
| **Node.js** | >= 20 (>= 22.5 nếu cài qua plugin) | Tất cả. Cả hai test suite verify xanh trên Node **24** và **26** |
|
||||||
|
| **npm** | 9+ | Đi kèm Node |
|
||||||
|
| **git** | bất kỳ | Clone repo, và mọi thao tác lane (worktree, đọc branch/status) |
|
||||||
|
| **tmux** | 3.x | Run console trên trình duyệt, `agenthub lanes shell`, gõ `/reload-plugins` vào pane đang sống, nhắc nhở Codex |
|
||||||
|
| **Claude Code** | 2.x | Hook ingestion — toàn bộ phần monitoring |
|
||||||
|
| **Codex CLI** | bất kỳ | Tùy chọn — chỉ cho lane dùng `codex` |
|
||||||
|
| **GitHub CLI (`gh`)** | bất kỳ | Tùy chọn — chỉ cho `agenthub lanes ci status` và các stage PR của ship pipeline |
|
||||||
|
| **systemd (user)** | — | Tùy chọn — chỉ cho `agenthub service install` (tự khởi động khi boot, Linux) |
|
||||||
|
|
||||||
|
Node **25** là bản duy nhất nên tránh: nó làm gãy 6 test server do lệch ABI
|
||||||
|
`better-sqlite3` và 20 test client do thay đổi global `localStorage`. Tới 26 thì
|
||||||
|
cả hai đã hết (1712 test server + 488 test client xanh trên v26.8.1).
|
||||||
|
|
||||||
|
### Cài tmux
|
||||||
|
|
||||||
|
Dashboard gọi thẳng binary `tmux`, không có bản dự phòng đi kèm, nên thiếu nó
|
||||||
|
thì **Start Run** và `agenthub lanes shell` sẽ lỗi. Phần còn lại (session,
|
||||||
|
analytics, lane, stage detection, CLI) vẫn chạy bình thường.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt install tmux # Debian / Ubuntu
|
||||||
|
sudo dnf install tmux # Fedora / RHEL
|
||||||
|
brew install tmux # macOS
|
||||||
|
sudo pacman -S tmux # Arch
|
||||||
|
```
|
||||||
|
|
||||||
|
Windows không có tmux native — chạy AgentHub trong WSL2 và cài tmux ở trong đó.
|
||||||
|
|
||||||
|
Kiểm tra, cả từ shell của bạn lẫn từ góc nhìn của server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tmux -V # ví dụ: tmux 3.4
|
||||||
|
curl -s localhost:4820/api/run/tmux # {"available":true}
|
||||||
|
```
|
||||||
|
|
||||||
|
Mỗi lane chạy trong một tmux session tên `agenthub-lane-<id>`, nên terminal
|
||||||
|
trên trình duyệt và `tmux attach -t agenthub-lane-<id>` (hoặc `agenthub lanes
|
||||||
|
shell`) ở máy là hai client trên cùng một pane — chúng đồng bộ với nhau, và tắt
|
||||||
|
dashboard không bao giờ giết run đang chạy. Detach bằng `Ctrl-b d`.
|
||||||
|
|
||||||
|
### Plugin superpowers
|
||||||
|
|
||||||
|
Plugin **`superpowers` chỉ cần cho ship-feature pipeline**, không cần cho
|
||||||
|
dashboard. `/agenthub:ship-feature` và `/agenthub:ship-feature-lane` lái các skill
|
||||||
|
của nó theo từng phase. Thiếu nó thì dashboard, hook và CLI vẫn chạy bình thường
|
||||||
|
— chỉ hai skill pipeline là dừng giữa chừng; `/agenthub-doctor` báo dòng `WARN`.
|
||||||
|
|
||||||
|
**Bình thường bạn không phải tự cài.** Bootstrap `SessionStart` của plugin cài
|
||||||
|
giúp một lần trong worker chạy nền, và session hiện tại cần `/reload-plugins`
|
||||||
|
thì skill mới resolve được (session sau tự nhận). Cài tay:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
claude plugin install superpowers@claude-plugins-official
|
||||||
|
```
|
||||||
|
|
||||||
|
Đặt `AGENTHUB_AUTO_INSTALL_PLUGINS=0` để tắt cài tự động.
|
||||||
|
|
||||||
## Cài như Claude Code plugin
|
## Cài như Claude Code plugin
|
||||||
|
|
||||||
|
|||||||
@@ -324,6 +324,26 @@ The SQLite database uses WAL mode with a 5-second busy timeout. If you see lock
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### The run console won't start a run / the terminal never attaches
|
||||||
|
|
||||||
|
Runs are tmux-backed: the server executes the `tmux` binary and has no fallback.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tmux -V # missing → sudo apt install tmux
|
||||||
|
curl -s http://localhost:4820/api/run/tmux # {"available":true}
|
||||||
|
curl -s "http://localhost:4820/api/run/binary?tool=claude" # {"found":true,"path":"…"}
|
||||||
|
```
|
||||||
|
|
||||||
|
`{"available":false}` while your own shell finds tmux means the **server's**
|
||||||
|
`PATH` differs from yours — typically a systemd `--user` service, which never
|
||||||
|
reads your shell profile. Install tmux system-wide (`/usr/bin/tmux`) and
|
||||||
|
re-run `agenthub service uninstall && agenthub service install`. The same
|
||||||
|
applies to `claude` / `codex`: a run launches them by name.
|
||||||
|
|
||||||
|
Install instructions per OS: [INSTALL.md → Step 0](./INSTALL.md#step-0--system-packages).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### No sessions appearing after starting Claude Code
|
### No sessions appearing after starting Claude Code
|
||||||
|
|
||||||
**Check 1 — Is the server running?**
|
**Check 1 — Is the server running?**
|
||||||
|
|||||||
+18
-1
@@ -1279,6 +1279,23 @@ async function cmdDoctor() {
|
|||||||
);
|
);
|
||||||
console.log(`${c.green("✔")} WS connections ${srv.ws_connections ?? 0}`);
|
console.log(`${c.green("✔")} WS connections ${srv.ws_connections ?? 0}`);
|
||||||
|
|
||||||
|
// Asked of the SERVER, not of this shell: a run is a tmux session the server
|
||||||
|
// spawns, so the only PATH that decides whether Start Run works is its own —
|
||||||
|
// a systemd --user service never reads your shell profile. Missing tmux is a
|
||||||
|
// warning, not a failure: it costs the run console and `lanes shell`, nothing
|
||||||
|
// else.
|
||||||
|
try {
|
||||||
|
const { available } = await get("/api/run/tmux");
|
||||||
|
console.log(
|
||||||
|
available
|
||||||
|
? `${c.green("✔")} tmux available to the server`
|
||||||
|
: `${c.yellow("!")} tmux not on the server's PATH — Start Run and \`agenthub lanes shell\` will fail. ` +
|
||||||
|
`Install it (sudo apt install tmux / brew install tmux), then restart the server`
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
console.log(`${c.dim("·")} tmux not reported by this server`);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { sources = [] } = await get("/api/remote-sources");
|
const { sources = [] } = await get("/api/remote-sources");
|
||||||
if (sources.length === 0) {
|
if (sources.length === 0) {
|
||||||
@@ -2995,7 +3012,7 @@ const COMMAND_GROUPS = [
|
|||||||
[
|
[
|
||||||
"Administration",
|
"Administration",
|
||||||
[
|
[
|
||||||
["doctor", "", "Connectivity, hooks, database, and remote sources diagnosis"],
|
["doctor", "", "Connectivity, hooks, database, tmux, and remote sources diagnosis"],
|
||||||
["info", "", "Raw system info JSON"],
|
["info", "", "Raw system info JSON"],
|
||||||
["export", "[file.json]", "Export all data as JSON"],
|
["export", "[file.json]", "Export all data as JSON"],
|
||||||
["cleanup", "--hours N --days M", "Abandon stale / purge old sessions"],
|
["cleanup", "--hours N --days M", "Abandon stale / purge old sessions"],
|
||||||
|
|||||||
@@ -9537,7 +9537,7 @@ exports[`screen snapshots > Settings 1`] = `
|
|||||||
<p
|
<p
|
||||||
class="text-[10px] text-status-warning/90 mt-1"
|
class="text-[10px] text-status-warning/90 mt-1"
|
||||||
>
|
>
|
||||||
UI build v1.5.4 (rebuild client to match)
|
UI build v1.5.6 (rebuild client to match)
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -245,6 +245,8 @@ All fields are optional. The tool (CLI invoked) comes from the lane itself, neve
|
|||||||
- **`approval`** — one of `on-request` or `never`, or omitted/empty for no approval prompt. Passed to `codex -a <value>`.
|
- **`approval`** — one of `on-request` or `never`, or omitted/empty for no approval prompt. Passed to `codex -a <value>`.
|
||||||
- **`resumeSessionId`** or **`resumeLast: true`** — resume an earlier run instead of starting new. For Codex lanes specifically, `resumeLast: true` uses `codex resume --last`; `resumeSessionId` uses `codex resume <sessionId>`. For Claude lanes, `resumeSessionId` re-attaches a Claude session by id.
|
- **`resumeSessionId`** or **`resumeLast: true`** — resume an earlier run instead of starting new. For Codex lanes specifically, `resumeLast: true` uses `codex resume --last`; `resumeSessionId` uses `codex resume <sessionId>`. For Claude lanes, `resumeSessionId` re-attaches a Claude session by id.
|
||||||
|
|
||||||
|
Error `503 ETMUXMISSING` is returned when the host has no `tmux` binary. Every run the dashboard starts is a tmux session, so this is a missing dependency rather than a bad request — the message carries the install command, and the same code comes back from `POST /api/run`. Nothing else in the dashboard is affected.
|
||||||
|
|
||||||
Error `409 ERUNLIVE` is returned if the lane already has a live run; stop it first with the `stop` action. The same code and status come back when the lane's tmux pane is already running an agent while a `prompt` or `resumeSessionId` was sent — that argv cannot be typed over a live agent, so the request is refused instead of answered 200 with nothing done. A start that asks for neither still adopts the existing pane silently.
|
Error `409 ERUNLIVE` is returned if the lane already has a live run; stop it first with the `stop` action. The same code and status come back when the lane's tmux pane is already running an agent while a `prompt` or `resumeSessionId` was sent — that argv cannot be typed over a live agent, so the request is refused instead of answered 200 with nothing done. A start that asks for neither still adopts the existing pane silently.
|
||||||
|
|
||||||
#### Preflight a destructive lane action
|
#### Preflight a destructive lane action
|
||||||
|
|||||||
+1
-1
@@ -272,7 +272,7 @@ Because a lane's services are fully detached, restarting the dashboard (or `agen
|
|||||||
|
|
||||||
| Command | Description |
|
| Command | Description |
|
||||||
| ------- | ----------- |
|
| ------- | ----------- |
|
||||||
| `agenthub doctor` | Diagnosis: API reachability, hook installation status + path, database path/size/row counts, server uptime and Node version, WS connections |
|
| `agenthub doctor` | Diagnosis: API reachability, hook installation status + path, database path/size/row counts, server uptime and Node version, WS connections, whether `tmux` is on **the server's** PATH (asked via `GET /api/run/tmux` — a systemd `--user` service does not read your shell profile), remote-source status |
|
||||||
| `agenthub info` | The raw `/api/settings/info` JSON (pipe it to `jq`) |
|
| `agenthub info` | The raw `/api/settings/info` JSON (pipe it to `jq`) |
|
||||||
| `agenthub export [file.json]` | Full JSON data export (sessions, agents, events, tokens, workflows, dashboard runs, alert rules, pricing) — defaults to a dated filename. Re-importable via `agenthub import-data` |
|
| `agenthub export [file.json]` | Full JSON data export (sessions, agents, events, tokens, workflows, dashboard runs, alert rules, pricing) — defaults to a dated filename. Re-importable via `agenthub import-data` |
|
||||||
| `agenthub cleanup --hours N --days M` | Abandon active sessions idle for `N` hours and/or purge completed sessions older than `M` days |
|
| `agenthub cleanup --hours N --days M` | Abandon active sessions idle for `N` hours and/or purge completed sessions older than `M` days |
|
||||||
|
|||||||
@@ -139,6 +139,11 @@ graph TB
|
|||||||
|
|
||||||
- Node.js >= 20.0.0
|
- Node.js >= 20.0.0
|
||||||
- npm >= 9.0.0
|
- npm >= 9.0.0
|
||||||
|
- git — every lane operation shells out to it
|
||||||
|
- tmux — only for the browser run console and `agenthub lanes shell`; both
|
||||||
|
execute the binary directly and have no fallback. Per-OS install commands and
|
||||||
|
the two-sided check (your PATH vs the server's) are in
|
||||||
|
[INSTALL.md → Step 0](../INSTALL.md#step-0--system-packages).
|
||||||
|
|
||||||
### Setup
|
### Setup
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
# AgentHub — Plugin Marketplace
|
# AgentHub — Plugin Marketplace
|
||||||
|
|
||||||
Official Claude Code plugins for the Agent Monitor dashboard. The **`agenthub`** plugin _is_ the dashboard — hooks, server, `agenthub` CLI and MCP tools, no checkout required. On top of it, **10 focused plugins** extend Claude Code with skills, agents, slash commands, hooks, and CLI tools for deep analytics, cost guardrails, productivity automation, developer tools, AI-powered insights, session forensics, workflow/fleet intelligence, reliability & SLOs, config & memory governance, and dashboard connectivity.
|
Official Claude Code plugins for the Agent Monitor dashboard. The **`agenthub`** plugin _is_ the dashboard — hooks, server and the `agenthub` CLI, no checkout required. (It shipped an MCP server until `c7dbaf2`, which dropped it; the dashboard reads Claude Code's MCP configuration in the config explorer but no longer serves one.) On top of it, **10 focused plugins** extend Claude Code with skills, agents, slash commands, hooks, and CLI tools for deep analytics, cost guardrails, productivity automation, developer tools, AI-powered insights, session forensics, workflow/fleet intelligence, reliability & SLOs, config & memory governance, and dashboard connectivity.
|
||||||
|
|
||||||
Every plugin is powered by the local Agent Monitor REST API at `http://localhost:4820`. They are read-only advisors unless a skill explicitly documents a mutating endpoint (and those preview + confirm before acting).
|
Every plugin is powered by the local Agent Monitor REST API at `http://localhost:4820`. They are read-only advisors unless a skill explicitly documents a mutating endpoint (and those preview + confirm before acting).
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ waits on an install:
|
|||||||
4. **Install** — `npm install --omit=dev --ignore-scripts` into the runtime dir (never into the plugin cache, which is garbage-collected and replaced on every update). `--ignore-scripts` keeps the root `postinstall` from pulling the whole Vite client toolchain.
|
4. **Install** — `npm install --omit=dev --ignore-scripts` into the runtime dir (never into the plugin cache, which is garbage-collected and replaced on every update). `--ignore-scripts` keeps the root `postinstall` from pulling the whole Vite client toolchain.
|
||||||
5. **Legacy hook cleanup** — see above.
|
5. **Legacy hook cleanup** — see above.
|
||||||
6. **CLI** — write the `~/.local/bin/agenthub` launcher, never clobbering a `agenthub` the bootstrap did not write.
|
6. **CLI** — write the `~/.local/bin/agenthub` launcher, never clobbering a `agenthub` the bootstrap did not write.
|
||||||
7. **UI build** — `client/` is copied into the runtime dir and built there (`npm ci --include=dev`, falling back to `npm install --include=dev`, then `npm run build`), landing in `runtime/client-dist` — the same directory the server serves from. `--include=dev` is required, not tidy: the entire build toolchain (`vite`, `typescript`, `@vitejs/plugin-react`, `tailwindcss`, `@types/*`) is a devDependency, and npm reads an inherited `NODE_ENV=production` as `--omit=dev`. Every bootstrap descended from the running server carries that env — the self-update chain, and any `SessionStart` fired by a `claude` inside a tmux pane the server started — so without the flag the install drops `vite` and the build dies on missing types. Skipped when a bundle for the current version already exists; a failure here does not fail the bootstrap (API and MCP still work, and `/agenthub-open` can retry) but does mean `/run` 404s until it's fixed — and when a bundle from the PREVIOUS version is still on disk the failure is quieter still: the dashboard keeps serving the old UI against the new API, visible only as the Settings page's `UI build vX (rebuild client to match)` line.
|
7. **UI build** — `client/` is copied into the runtime dir and built there (`npm ci --include=dev`, falling back to `npm install --include=dev`, then `npm run build`), landing in `runtime/client-dist` — the same directory the server serves from. `--include=dev` is required, not tidy: the entire build toolchain (`vite`, `typescript`, `@vitejs/plugin-react`, `tailwindcss`, `@types/*`) is a devDependency, and npm reads an inherited `NODE_ENV=production` as `--omit=dev`. Every bootstrap descended from the running server carries that env — the self-update chain, and any `SessionStart` fired by a `claude` inside a tmux pane the server started — so without the flag the install drops `vite` and the build dies on missing types. Skipped when a bundle for the current version already exists; a failure here does not fail the bootstrap (the API still works, and `/agenthub-open` can retry) but does mean `/run` 404s until it's fixed — and when a bundle from the PREVIOUS version is still on disk the failure is quieter still: the dashboard keeps serving the old UI against the new API, visible only as the Settings page's `UI build vX (rebuild client to match)` line.
|
||||||
8. **Server** — on Linux with `systemd --user` available, install/refresh a
|
8. **Server** — on Linux with `systemd --user` available, install/refresh a
|
||||||
`agenthub.service` unit (see [Auto-start on boot](#auto-start-on-boot)) instead
|
`agenthub.service` unit (see [Auto-start on boot](#auto-start-on-boot)) instead
|
||||||
of a bare spawn, so the server is supervised and comes back after a reboot
|
of a bare spawn, so the server is supervised and comes back after a reboot
|
||||||
@@ -176,7 +176,7 @@ reboot, same as always.
|
|||||||
|
|
||||||
| Command | Does |
|
| Command | Does |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `/agenthub-doctor` | Node version, bootstrap state, runtime deps, server liveness, duplicate hooks, CLI launcher + PATH, **skill plugins** (see below), MCP build freshness, UI bundle |
|
| `/agenthub-doctor` | Node version, bootstrap state, runtime deps, server liveness, duplicate hooks, CLI launcher + PATH, **tmux** (`WARN` when absent — only the run console, `agenthub lanes shell` and session reloads need it), **skill plugins** (see below), UI bundle |
|
||||||
| `/agenthub-update` | Pull the latest `agenthub` release via `claude plugin marketplace update` + `claude plugin update agenthub@<marketplace> -y`, then reinstall dependencies and restart the server (`plugin-bootstrap.js --force`). The plugin pull needs a manual `/reload-plugins` afterward to take effect in the current session — not scriptable from a command. |
|
| `/agenthub-update` | Pull the latest `agenthub` release via `claude plugin marketplace update` + `claude plugin update agenthub@<marketplace> -y`, then reinstall dependencies and restart the server (`plugin-bootstrap.js --force`). The plugin pull needs a manual `/reload-plugins` afterward to take effect in the current session — not scriptable from a command. |
|
||||||
| `/agenthub-open` | Rebuild the UI bundle and print the dashboard URL. Re-runs the bootstrap first when the server is down or still executing a plugin root that a mid-session `/plugin` update retired, so a fresh bundle never talks to an older server's routes |
|
| `/agenthub-open` | Rebuild the UI bundle and print the dashboard URL. Re-runs the bootstrap first when the server is down or still executing a plugin root that a mid-session `/plugin` update retired, so a fresh bundle never talks to an older server's routes |
|
||||||
| `/ship-full <requirement>` | Put the lane on the 16-node `ship-feature` template, then run `/agenthub:ship-feature-lane` **in this session**. The in-session twin of `agenthub ship-full` (which spawns its own `claude` from a terminal) |
|
| `/ship-full <requirement>` | Put the lane on the 16-node `ship-feature` template, then run `/agenthub:ship-feature-lane` **in this session**. The in-session twin of `agenthub ship-full` (which spawns its own `claude` from a terminal) |
|
||||||
|
|||||||
+6
-4
@@ -70,10 +70,12 @@ graph LR
|
|||||||
|
|
||||||
**Quick Start:**
|
**Quick Start:**
|
||||||
|
|
||||||
1. Read [SETUP.md](../SETUP.md)
|
1. Install the system packages — `node` (20+), `git`, and `tmux` (the run
|
||||||
2. Run `npm run setup`
|
console has no fallback without it): [INSTALL.md → Step 0](../INSTALL.md#step-0--system-packages)
|
||||||
3. Run `npm run dev`
|
2. Read [SETUP.md](../SETUP.md)
|
||||||
4. Open browser to `http://localhost:5173`
|
3. Run `npm run setup`
|
||||||
|
4. Run `npm run dev`
|
||||||
|
5. Open browser to `http://localhost:5173`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
openapi: 3.0.3
|
openapi: 3.0.3
|
||||||
info:
|
info:
|
||||||
title: Agent Dashboard for Claude Code API
|
title: Agent Dashboard for Claude Code API
|
||||||
version: 1.5.4
|
version: 1.5.6
|
||||||
description: HTTP API for real-time Claude Code session monitoring, agent lifecycle tracking, analytics, pricing, hooks ingestion, and workflow intelligence.
|
description: HTTP API for real-time Claude Code session monitoring, agent lifecycle tracking, analytics, pricing, hooks ingestion, and workflow intelligence.
|
||||||
contact:
|
contact:
|
||||||
name: Nguyễn Ngọc Trí Vĩ
|
name: Nguyễn Ngọc Trí Vĩ
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "agenthub",
|
"name": "agenthub",
|
||||||
"version": "1.5.4",
|
"version": "1.5.6",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "agenthub",
|
"name": "agenthub",
|
||||||
"version": "1.5.4",
|
"version": "1.5.6",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "agenthub",
|
"name": "agenthub",
|
||||||
"version": "1.5.4",
|
"version": "1.5.6",
|
||||||
"bin": {
|
"bin": {
|
||||||
"agenthub": "bin/agenthub.js"
|
"agenthub": "bin/agenthub.js"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
description: Diagnose a plugin-installed AgentHub — Node, npm, disk, bootstrap, server, hooks, CLI, UI build
|
description: Diagnose a plugin-installed AgentHub — Node, npm, disk, bootstrap, server, hooks, CLI, tmux, UI build
|
||||||
---
|
---
|
||||||
|
|
||||||
Run the diagnostic and report what it found. Do not fix anything unless the user
|
Run the diagnostic and report what it found. Do not fix anything unless the user
|
||||||
@@ -31,6 +31,11 @@ Print the output verbatim, then add at most three lines of guidance based on the
|
|||||||
means that attempt has not run or did not succeed — say `/agenthub-update` retries
|
means that attempt has not run or did not succeed — say `/agenthub-update` retries
|
||||||
it, and print the `claude plugin install …` line from the output as the manual
|
it, and print the `claude plugin install …` line from the output as the manual
|
||||||
route.
|
route.
|
||||||
|
- `WARN tmux` → only the run console, `agenthub lanes shell` and the
|
||||||
|
session-reload keystrokes are affected; monitoring, lanes and the CLI are not.
|
||||||
|
Print the install command from the output. If the row says `ok` but Start Run
|
||||||
|
still fails, the server has a different PATH than this check — ask it directly
|
||||||
|
with `curl -s localhost:4820/api/run/tmux`.
|
||||||
- `WARN Dashboard UI` → run `/agenthub-open` to build the bundle. When the row
|
- `WARN Dashboard UI` → run `/agenthub-open` to build the bundle. When the row
|
||||||
quotes a build error, report that error — it is the actual problem.
|
quotes a build error, report that error — it is the actual problem.
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
* npm, free disk on the data dir, bootstrap state, runtime dependencies (every
|
* npm, free disk on the data dir, bootstrap state, runtime dependencies (every
|
||||||
* declared package, not just that node_modules exists), server liveness,
|
* declared package, not just that node_modules exists), server liveness,
|
||||||
* duplicate hook entries (the one failure that silently doubles every token and
|
* duplicate hook entries (the one failure that silently doubles every token and
|
||||||
* cost figure), the `agenthub` CLI launcher and its PATH, whether the slash
|
* cost figure), the `agenthub` CLI launcher and its PATH, the `tmux` binary
|
||||||
|
* every browser-started run depends on, whether the slash
|
||||||
* commands the pipeline templates name as node drivers are actually resolvable
|
* commands the pipeline templates name as node drivers are actually resolvable
|
||||||
* (the `superpowers` plugin, today), and the dashboard bundle — quoting the last
|
* (the `superpowers` plugin, today), and the dashboard bundle — quoting the last
|
||||||
* build error when it is missing.
|
* build error when it is missing.
|
||||||
@@ -82,6 +83,7 @@ function diagnose() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
add(...cliStatus());
|
add(...cliStatus());
|
||||||
|
add(...tmuxStatus());
|
||||||
add(...skillPluginStatus());
|
add(...skillPluginStatus());
|
||||||
|
|
||||||
add(...dashboardUiStatus(rt));
|
add(...dashboardUiStatus(rt));
|
||||||
@@ -218,6 +220,29 @@ function skillPluginStatus() {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WARN (never FAIL) when `tmux` is absent: every run the dashboard starts is a
|
||||||
|
* tmux session (`server/lib/tmux.js`), so without the binary the run console,
|
||||||
|
* `agenthub lanes shell` and the session-reload keystrokes all fail — while
|
||||||
|
* sessions, analytics, lanes and the CLI keep working. Same reasoning as the
|
||||||
|
* skill-plugins row: a partial feature loss must not fail a doctor run.
|
||||||
|
*
|
||||||
|
* This checks the doctor's own PATH. A server started as a systemd `--user`
|
||||||
|
* service can still see a different one — `GET /api/run/tmux` is the server's
|
||||||
|
* own answer, and `agenthub doctor` reports that.
|
||||||
|
*/
|
||||||
|
function tmuxStatus() {
|
||||||
|
if (require("../server/lib/tmux").isTmuxAvailable()) {
|
||||||
|
return ["ok", "tmux", "on PATH — the run console can start sessions"];
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
"warn",
|
||||||
|
"tmux",
|
||||||
|
"not found — Start Run and `agenthub lanes shell` will fail (everything else is unaffected). " +
|
||||||
|
"Install it: sudo apt install tmux / brew install tmux (Windows: run AgentHub under WSL2)",
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
function countLegacyHookEntries() {
|
function countLegacyHookEntries() {
|
||||||
try {
|
try {
|
||||||
const settings = JSON.parse(fs.readFileSync(getSettingsPath(), "utf8"));
|
const settings = JSON.parse(fs.readFileSync(getSettingsPath(), "utf8"));
|
||||||
|
|||||||
@@ -369,7 +369,7 @@ describe("agenthub CLI — import & administration", () => {
|
|||||||
assert.match(err, /Usage: agenthub import/);
|
assert.match(err, /Usage: agenthub import/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("doctor reports API, hooks, database, remotes, and uptime lines", async () => {
|
it("doctor reports API, hooks, database, tmux, remotes, and uptime lines", async () => {
|
||||||
const { code, out } = await agenthub("doctor");
|
const { code, out } = await agenthub("doctor");
|
||||||
// Exit 1 when hooks are missing (common in the test harness) — still prints a full report.
|
// Exit 1 when hooks are missing (common in the test harness) — still prints a full report.
|
||||||
assert.ok(code === 0 || code === 1, `unexpected exit ${code}`);
|
assert.ok(code === 0 || code === 1, `unexpected exit ${code}`);
|
||||||
@@ -377,6 +377,10 @@ describe("agenthub CLI — import & administration", () => {
|
|||||||
assert.match(out, /Claude Code hooks/);
|
assert.match(out, /Claude Code hooks/);
|
||||||
assert.match(out, /Database/);
|
assert.match(out, /Database/);
|
||||||
assert.match(out, /Server uptime/);
|
assert.match(out, /Server uptime/);
|
||||||
|
// Asked of the server (GET /api/run/tmux), not of this shell: a missing
|
||||||
|
// tmux is why Start Run fails, and the server's PATH is the one that
|
||||||
|
// decides. Reported either way, and never fatal.
|
||||||
|
assert.match(out, /tmux/);
|
||||||
assert.match(out, /Remote sources/);
|
assert.match(out, /Remote sources/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* @file Tests the `tmux` row of scripts/plugin-doctor.js — the check that tells
|
||||||
|
* an install its browser run console cannot work, because every run the
|
||||||
|
* dashboard starts is a tmux session (server/lib/tmux.js). The row must WARN
|
||||||
|
* and never FAIL: sessions, analytics, lanes and the CLI all work without the
|
||||||
|
* binary, so failing a doctor run over it would cry wolf. tmux is faked through
|
||||||
|
* the module's own exec seam, so the test never depends on the host having it.
|
||||||
|
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
||||||
|
*/
|
||||||
|
|
||||||
|
const { describe, it, after } = require("node:test");
|
||||||
|
const assert = require("node:assert/strict");
|
||||||
|
const fs = require("node:fs");
|
||||||
|
const os = require("node:os");
|
||||||
|
const path = require("node:path");
|
||||||
|
|
||||||
|
const TMP_HOME = fs.mkdtempSync(path.join(os.tmpdir(), "agenthub-doctor-tmux-"));
|
||||||
|
process.env.CLAUDE_HOME = TMP_HOME;
|
||||||
|
|
||||||
|
const tmux = require("../lib/tmux");
|
||||||
|
const { diagnose } = require("../../scripts/plugin-doctor");
|
||||||
|
|
||||||
|
after(() => {
|
||||||
|
tmux.__reset();
|
||||||
|
fs.rmSync(TMP_HOME, { recursive: true, force: true });
|
||||||
|
delete process.env.CLAUDE_HOME;
|
||||||
|
});
|
||||||
|
|
||||||
|
/** Fake the tmux binary as present or absent, then read back the row. */
|
||||||
|
function rowWithTmux(present) {
|
||||||
|
tmux.__setExecImpl(() => {
|
||||||
|
if (!present) throw new Error("spawnSync tmux ENOENT");
|
||||||
|
return "tmux 3.4\n";
|
||||||
|
});
|
||||||
|
const row = diagnose().find((r) => r.label === "tmux");
|
||||||
|
assert.ok(row, "the doctor must always emit a tmux row");
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("plugin-doctor: tmux row", () => {
|
||||||
|
it("warns, never fails, when tmux is not on PATH", () => {
|
||||||
|
const row = rowWithTmux(false);
|
||||||
|
|
||||||
|
assert.equal(row.level, "warn", "a missing tmux must not fail the doctor run");
|
||||||
|
assert.match(row.detail, /lanes shell/, "the reader needs to know WHAT breaks");
|
||||||
|
assert.match(row.detail, /install/i, "and how to fix it");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("passes when tmux is available", () => {
|
||||||
|
const row = rowWithTmux(true);
|
||||||
|
|
||||||
|
assert.equal(row.level, "ok", row.detail);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -58,6 +58,29 @@ describe("pty-run", () => {
|
|||||||
assert.ok(newSessionCall.includes("opus"));
|
assert.ok(newSessionCall.includes("opus"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("spawnRun refuses with ETMUXMISSING, naming the fix, when tmux is not installed", () => {
|
||||||
|
// Before this guard the ENOENT escaped from three calls down as
|
||||||
|
// `spawnSync tmux ENOENT` and the route answered 400 — blaming the request
|
||||||
|
// for a missing host package, with no hint of what to install.
|
||||||
|
const calls = [];
|
||||||
|
tmux.__setExecImpl((args) => {
|
||||||
|
calls.push(args);
|
||||||
|
const e = new Error("spawnSync tmux ENOENT");
|
||||||
|
e.code = "ENOENT";
|
||||||
|
throw e;
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
() => pty.spawnRun({ laneId: 42, cwd: "/tmp/repo" }),
|
||||||
|
(err) => err.code === "ETMUXMISSING" && /install/i.test(err.message),
|
||||||
|
"a missing tmux must be reported as such, with the install command"
|
||||||
|
);
|
||||||
|
assert.ok(
|
||||||
|
!calls.some((c) => c[0] === "new-session"),
|
||||||
|
"must not attempt a session it already knows cannot be created"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("spawnRun is a no-op (adopts) when the existing session's pane runs claude", () => {
|
it("spawnRun is a no-op (adopts) when the existing session's pane runs claude", () => {
|
||||||
const calls = [];
|
const calls = [];
|
||||||
tmux.__setExecImpl((args) => {
|
tmux.__setExecImpl((args) => {
|
||||||
|
|||||||
@@ -118,6 +118,23 @@ describe("/api/run", () => {
|
|||||||
assert.equal(body.error.code, "EBADCWD");
|
assert.equal(body.error.code, "EBADCWD");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("POST / answers 503, not 400, when the host has no tmux", async () => {
|
||||||
|
// The request is fine; the dependency is absent. 400 would tell the user to
|
||||||
|
// fix their input, and the body must carry the install line the UI shows.
|
||||||
|
tmux.__setExecImpl(() => {
|
||||||
|
const e = new Error("spawnSync tmux ENOENT");
|
||||||
|
e.code = "ENOENT";
|
||||||
|
throw e;
|
||||||
|
});
|
||||||
|
const { status, body } = await fetchJson("/api/run", {
|
||||||
|
method: "POST",
|
||||||
|
body: { laneId: 9, cwd: TMP },
|
||||||
|
});
|
||||||
|
assert.equal(status, 503);
|
||||||
|
assert.equal(body.error.code, "ETMUXMISSING");
|
||||||
|
assert.match(body.error.message, /install/i);
|
||||||
|
});
|
||||||
|
|
||||||
it("POST / spawns a tmux session and GET /:id finds it", async () => {
|
it("POST / spawns a tmux session and GET /:id finds it", async () => {
|
||||||
let hasSessionCalls = 0;
|
let hasSessionCalls = 0;
|
||||||
tmux.__setExecImpl((args) => {
|
tmux.__setExecImpl((args) => {
|
||||||
|
|||||||
@@ -176,8 +176,15 @@ describe("getUpdatesStatus — plugin cache with no .git", () => {
|
|||||||
|
|
||||||
const s = await getUpdatesStatus(root, { latestRelease: release("v1.5.1") });
|
const s = await getUpdatesStatus(root, { latestRelease: release("v1.5.1") });
|
||||||
|
|
||||||
// The old behaviour: message set, everything else absent.
|
// The old behaviour: the not-a-git-clone message, everything else absent.
|
||||||
assert.equal(s.message, null, "must not fall through to the not-a-git-clone payload");
|
// Asserted on the message's CONTENT, not on it being null — a plugin
|
||||||
|
// install now carries its own sentence, and null was only ever a proxy for
|
||||||
|
// "did not fall through here".
|
||||||
|
assert.doesNotMatch(
|
||||||
|
s.message,
|
||||||
|
/not a git clone/i,
|
||||||
|
"must not fall through to the not-a-git-clone payload"
|
||||||
|
);
|
||||||
assert.equal(s.release_check, "ok", "the release layer must actually run");
|
assert.equal(s.release_check, "ok", "the release layer must actually run");
|
||||||
assert.equal(s.install_kind, "plugin");
|
assert.equal(s.install_kind, "plugin");
|
||||||
assert.equal(s.plugin_marketplace, "sg");
|
assert.equal(s.plugin_marketplace, "sg");
|
||||||
@@ -208,6 +215,31 @@ describe("getUpdatesStatus — plugin cache with no .git", () => {
|
|||||||
assert.ok(s.plugin_marketplace && s.plugin_name && s.repo_root);
|
assert.ok(s.plugin_marketplace && s.plugin_name && s.repo_root);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("carries a human-readable message in every outcome, never a null", async () => {
|
||||||
|
// `agenthub update-check` prints `message` as its headline. Null here made
|
||||||
|
// it print the literal "null" on every plugin-cache install — the one kind
|
||||||
|
// that has no commit count to fall back on.
|
||||||
|
const cases = [
|
||||||
|
[makePluginInstall("msg-newer").root, { latestRelease: release("v1.6.0") }, /v1\.6\.0/],
|
||||||
|
[makePluginInstall("msg-current").root, { latestRelease: release("v1.5.0") }, /newest/i],
|
||||||
|
[
|
||||||
|
makePluginInstall("msg-failed").root,
|
||||||
|
{ latestRelease: { ok: false, reason: "unreachable" } },
|
||||||
|
/unreachable/,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
makePluginInstall("msg-noversion", { version: null }).root,
|
||||||
|
{ latestRelease: release("v1.6.0") },
|
||||||
|
/no version|cannot be compared/i,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
for (const [root, opts, expected] of cases) {
|
||||||
|
const s = await getUpdatesStatus(root, opts);
|
||||||
|
assert.equal(typeof s.message, "string", `message must be a string, got ${s.message}`);
|
||||||
|
assert.match(s.message, expected);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it("does not treat an older published release as an update", async () => {
|
it("does not treat an older published release as an update", async () => {
|
||||||
const { root } = makePluginInstall("older");
|
const { root } = makePluginInstall("older");
|
||||||
const s = await getUpdatesStatus(root, { latestRelease: release("v1.4.0") });
|
const s = await getUpdatesStatus(root, { latestRelease: release("v1.4.0") });
|
||||||
|
|||||||
@@ -181,6 +181,21 @@ function spawnRun(args) {
|
|||||||
throw makeErr("EBADSESSION", "resumeSessionId is not a valid session id");
|
throw makeErr("EBADSESSION", "resumeSessionId is not a valid session id");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A run IS a tmux session, so an absent binary is a precondition failure, not
|
||||||
|
// a spawn failure. Without this the caller gets `spawnSync tmux ENOENT` from
|
||||||
|
// three directories down — a message that names no fix — and the route maps
|
||||||
|
// it to 400, blaming the request for the host's missing package. Checked here
|
||||||
|
// rather than in each route because both spawn paths (POST /api/run and
|
||||||
|
// POST /api/lanes/:id/start) come through this function.
|
||||||
|
if (!tmux.isTmuxAvailable()) {
|
||||||
|
throw makeErr(
|
||||||
|
"ETMUXMISSING",
|
||||||
|
"tmux is not installed, and every run the dashboard starts is a tmux session. " +
|
||||||
|
"Install it (sudo apt install tmux / brew install tmux; on Windows run AgentHub under WSL2), " +
|
||||||
|
"then restart the dashboard. Everything else keeps working without it."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const id = runIdForLane(laneId);
|
const id = runIdForLane(laneId);
|
||||||
const startedAt = Date.now();
|
const startedAt = Date.now();
|
||||||
const argv = buildArgv({
|
const argv = buildArgv({
|
||||||
|
|||||||
@@ -402,7 +402,17 @@ async function pluginStatus(root, pluginInstall, options = {}) {
|
|||||||
`commands — "Update now" runs them for you and restarts the dashboard. An already-open ` +
|
`commands — "Update now" runs them for you and restarts the dashboard. An already-open ` +
|
||||||
`Claude Code session still needs '/reload-plugins' to pick up new skills and commands.`,
|
`Claude Code session still needs '/reload-plugins' to pick up new skills and commands.`,
|
||||||
manual_command: manualParts.join(" && "),
|
manual_command: manualParts.join(" && "),
|
||||||
message: null,
|
// A plugin install compares versions exactly like a checkout does, so it
|
||||||
|
// gets the same sentence. Left null, `agenthub update-check` printed the
|
||||||
|
// literal "null" as its headline on every plugin-cache install — the one
|
||||||
|
// install kind that cannot fall back to a commit count.
|
||||||
|
message: releaseIsNewer
|
||||||
|
? `Release ${release.tag} is available (this install reports ${localVersion || "no version"}).`
|
||||||
|
: comparable
|
||||||
|
? `Running the newest release (${release.tag}).`
|
||||||
|
: release.ok
|
||||||
|
? `This install reports no version, so it cannot be compared with release ${release.tag}.`
|
||||||
|
: `Could not read the latest release (${release.reason}); version comparison unavailable.`,
|
||||||
|
|
||||||
install_kind: "plugin",
|
install_kind: "plugin",
|
||||||
plugin_marketplace: pluginInstall.marketplace,
|
plugin_marketplace: pluginInstall.marketplace,
|
||||||
|
|||||||
@@ -1360,6 +1360,12 @@ router.post("/:id/:action", sameOriginGuard, async (req, res) => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
// A host with no tmux cannot start a run, but nothing is broken on this
|
||||||
|
// side — 503 plus the install line, not a 500 the reader can only read as a
|
||||||
|
// dashboard bug.
|
||||||
|
if (err.code === "ETMUXMISSING") {
|
||||||
|
return res.status(503).json({ error: { code: err.code, message: err.message } });
|
||||||
|
}
|
||||||
return res.status(500).json({ error: { code: err.code, message: err.message } });
|
return res.status(500).json({ error: { code: err.code, message: err.message } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -260,6 +260,11 @@ router.post("/", (req, res) => {
|
|||||||
if (err.code === "ERUNLIVE") {
|
if (err.code === "ERUNLIVE") {
|
||||||
return res.status(409).json({ error: { code: err.code, message: err.message } });
|
return res.status(409).json({ error: { code: err.code, message: err.message } });
|
||||||
}
|
}
|
||||||
|
// Nor is a host missing tmux: the request was fine, the dependency is not
|
||||||
|
// installed. 400 would tell the user to fix their input.
|
||||||
|
if (err.code === "ETMUXMISSING") {
|
||||||
|
return res.status(503).json({ error: { code: err.code, message: err.message } });
|
||||||
|
}
|
||||||
if (err.code && err.code.startsWith("E")) {
|
if (err.code && err.code.startsWith("E")) {
|
||||||
return res.status(400).json({ error: { code: err.code, message: err.message } });
|
return res.status(400).json({ error: { code: err.code, message: err.message } });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user