agenttop 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +351 -0
- package/dist/chunk-4I4UZNKS.js +1019 -0
- package/dist/chunk-4I4UZNKS.js.map +1 -0
- package/dist/index.js +1390 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server.js +14 -0
- package/dist/mcp-server.js.map +1 -0
- package/hooks/agenttop-guard.py +120 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matt Hesketh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
# agenttop
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/agenttop)
|
|
4
|
+
[](https://www.npmjs.com/package/agenttop)
|
|
5
|
+
[](https://github.com/wrxck/agenttop/actions/workflows/ci.yml)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://nodejs.org)
|
|
8
|
+
[](https://www.typescriptlang.org/)
|
|
9
|
+
[](https://github.com/wrxck/agenttop/pulls)
|
|
10
|
+
[](https://bundlephobia.com/package/agenttop)
|
|
11
|
+
|
|
12
|
+
Real-time terminal dashboard for monitoring AI coding agent sessions — like `htop` for agents.
|
|
13
|
+
|
|
14
|
+
Currently supports [Claude Code](https://docs.anthropic.com/en/docs/claude-code). Reads local session data only — no network requests, no API keys.
|
|
15
|
+
|
|
16
|
+
> **Experimental** — this project is under active development. APIs and configuration may change between releases. Feature requests, bug reports, and contributions are very welcome. See [Contributing](#contributing).
|
|
17
|
+
|
|
18
|
+
## Table of contents
|
|
19
|
+
|
|
20
|
+
- [Install](#install)
|
|
21
|
+
- [Usage](#usage)
|
|
22
|
+
- [Token usage](#token-usage)
|
|
23
|
+
- [Session nicknames](#session-nicknames)
|
|
24
|
+
- [Session filtering](#session-filtering)
|
|
25
|
+
- [Session detail view](#session-detail-view)
|
|
26
|
+
- [Streaming modes](#streaming-modes)
|
|
27
|
+
- [Active protection](#active-protection)
|
|
28
|
+
- [Security rules](#security-rules)
|
|
29
|
+
- [MCP server](#mcp-server)
|
|
30
|
+
- [Notifications](#notifications)
|
|
31
|
+
- [Alert logging](#alert-logging)
|
|
32
|
+
- [Auto-updates](#auto-updates)
|
|
33
|
+
- [Configuration](#configuration)
|
|
34
|
+
- [Keybindings](#keybindings)
|
|
35
|
+
- [How it works](#how-it-works)
|
|
36
|
+
- [Multi-user support](#multi-user-support)
|
|
37
|
+
- [Contributing](#contributing)
|
|
38
|
+
- [Trademark notice](#trademark-notice)
|
|
39
|
+
- [License](#license)
|
|
40
|
+
|
|
41
|
+
## Install
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx agenttop
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or install globally:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install -g agenttop
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
Run `agenttop` in one terminal while running Claude Code sessions in other tabs.
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
-- agenttop v0.3.0 ---- 3 sessions ---- 14:32:08 ---------------------
|
|
59
|
+
| SESSIONS | ACTIVITY (cuddly-wiggling-sundae) |
|
|
60
|
+
| | |
|
|
61
|
+
| > cuddly-wiggling-sundae | 14:32:05 Bash ls /tmp/claude-0/ |
|
|
62
|
+
| /home/matt | opus | 14:32:03 Read /root/.claude/CLAUDE.md |
|
|
63
|
+
| CPU 20% | 542MB | 3 ag | 14:31:58 Grep pattern="sessionId" |
|
|
64
|
+
| 1.2k in | 340 out | 14:31:55 Write /home/matt/app/src/... |
|
|
65
|
+
| | 14:31:52 Bash npm test |
|
|
66
|
+
| jolly-dancing-pickle | |
|
|
67
|
+
| /home/matt/fleet | son | |
|
|
68
|
+
|--------------------------|---------------------------------------------|
|
|
69
|
+
| ALERTS |
|
|
70
|
+
| [!] 14:31:52 jolly-dancing-pickle: curl to unknown external URL |
|
|
71
|
+
| [!] 14:31:40 cuddly-wiggling-sundae: Reading .env file |
|
|
72
|
+
|-- q:quit j/k:nav tab:panel /:filter n:name enter:detail ---------|
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Options
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
agenttop [options]
|
|
79
|
+
|
|
80
|
+
--all-users Monitor all users (root only)
|
|
81
|
+
--no-security Disable security analysis
|
|
82
|
+
--json Stream events as JSON lines (no TUI)
|
|
83
|
+
--plain Stream events as plain text (no TUI)
|
|
84
|
+
--alert-level <l> Minimum: info|warn|high|critical (default: warn)
|
|
85
|
+
--no-notify Disable all notifications
|
|
86
|
+
--no-alert-log Disable alert file logging
|
|
87
|
+
--no-updates Disable update checks
|
|
88
|
+
--poll-interval <ms> Session discovery interval (default: 10000)
|
|
89
|
+
--mcp Start as MCP server (for Claude Code integration)
|
|
90
|
+
--install-mcp Register agenttop as MCP server in Claude Code
|
|
91
|
+
--install-hooks Install Claude Code PostToolUse hook for active protection
|
|
92
|
+
--uninstall-hooks Remove agenttop hooks from Claude Code
|
|
93
|
+
--version Show version
|
|
94
|
+
--help Show this help
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Token usage
|
|
98
|
+
|
|
99
|
+
Each session displays real-time token consumption directly in the session list:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
> cuddly-wiggling-sundae
|
|
103
|
+
/home/matt | opus
|
|
104
|
+
CPU 20% | 542MB | 3 ag
|
|
105
|
+
1.2k in | 340 out
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Press `Enter` on a session to see the full breakdown including cache creation, cache read, and cache hit rate percentage.
|
|
109
|
+
|
|
110
|
+
## Session nicknames
|
|
111
|
+
|
|
112
|
+
Press `n` on a selected session to assign a nickname. The nickname replaces the slug in the session list and persists across restarts.
|
|
113
|
+
|
|
114
|
+
Press `N` to clear a nickname.
|
|
115
|
+
|
|
116
|
+
Nicknames are stored in `~/.config/agenttop/config.json`.
|
|
117
|
+
|
|
118
|
+
## Session filtering
|
|
119
|
+
|
|
120
|
+
Press `/` to open the filter input. Type to filter sessions by slug, nickname, project, or model. Case-insensitive substring match.
|
|
121
|
+
|
|
122
|
+
Press `Esc` to clear the filter.
|
|
123
|
+
|
|
124
|
+
## Session detail view
|
|
125
|
+
|
|
126
|
+
Press `Enter` on a session to open the detail view, which shows:
|
|
127
|
+
|
|
128
|
+
- Slug, nickname, model, cwd, git branch, version, PID
|
|
129
|
+
- CPU, memory, uptime, agent count
|
|
130
|
+
- Full token usage breakdown with cache hit rate
|
|
131
|
+
|
|
132
|
+
Press `Esc` or `Enter` to return to the activity feed.
|
|
133
|
+
|
|
134
|
+
## Streaming modes
|
|
135
|
+
|
|
136
|
+
For piping into other tools or integrating with external systems, agenttop supports two non-TUI streaming modes:
|
|
137
|
+
|
|
138
|
+
### JSON mode
|
|
139
|
+
|
|
140
|
+
Stream events as JSONL (one JSON object per line):
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
agenttop --json | jq 'select(.type == "alert")'
|
|
144
|
+
agenttop --json --no-security # tool calls and usage only
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Event types: `sessions`, `tool_call`, `alert`, `usage`.
|
|
148
|
+
|
|
149
|
+
### Plain text mode
|
|
150
|
+
|
|
151
|
+
Stream events as human-readable lines:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
agenttop --plain | grep ALERT
|
|
155
|
+
agenttop --plain > session.log
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Output format:
|
|
159
|
+
```
|
|
160
|
+
SESSION cuddly-wiggling-sundae | opus | /home/matt | CPU 20% | 542MB | 1.2k in / 340 out
|
|
161
|
+
14:32:05 cuddly-wiggling-sundae Bash ls /tmp/claude-0/
|
|
162
|
+
ALERT 14:32:10 [warn] cuddly-wiggling-sundae: curl to external URL
|
|
163
|
+
USAGE abc123 +100 in / +50 out
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Active protection
|
|
167
|
+
|
|
168
|
+
agenttop can install a Claude Code `PostToolUse` hook that blocks prompt injection attempts before they reach the model — it doesn't just detect, it prevents.
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
agenttop --install-hooks
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Once installed, every tool result (Bash output, file contents, web fetches, grep results) is scanned for prompt injection patterns. If injection is detected, the tool result is blocked and the agent sees an error instead of the malicious content.
|
|
175
|
+
|
|
176
|
+
What it catches:
|
|
177
|
+
|
|
178
|
+
- **Instruction override** — "ignore previous instructions" and variants
|
|
179
|
+
- **Fake tags** — `<system>`, `[INST]`, `BEGIN HIDDEN INSTRUCTIONS`
|
|
180
|
+
- **Role reassignment** — "you are now...", "act as...", "pretend to be..."
|
|
181
|
+
- **Encoded payloads** — base64-encoded injection attempts, HTML entities
|
|
182
|
+
- **Exfiltration** — base64+curl, pipe-to-remote patterns in tool output
|
|
183
|
+
|
|
184
|
+
The hook is a standalone Python script with no dependencies. Remove it with `agenttop --uninstall-hooks`.
|
|
185
|
+
|
|
186
|
+
## Security rules
|
|
187
|
+
|
|
188
|
+
The TUI and streaming modes passively monitor all sessions for suspicious activity:
|
|
189
|
+
|
|
190
|
+
| Rule | Watches | Severity |
|
|
191
|
+
|------|---------|----------|
|
|
192
|
+
| **Network** | `curl`/`wget`/`nc` to external URLs | warn |
|
|
193
|
+
| **Exfiltration** | base64+curl, tar+upload, pipe to remote | high |
|
|
194
|
+
| **Sensitive files** | `.env`, `.ssh/*`, credentials, `/etc/shadow` | warn |
|
|
195
|
+
| **Shell escape** | `eval`, `chmod 777`, `sudo`, writes to `/etc/*` | high/critical |
|
|
196
|
+
| **Prompt injection** | Injection patterns in tool inputs and results | critical |
|
|
197
|
+
|
|
198
|
+
Individual rules can be disabled in the config file under `security.rules`.
|
|
199
|
+
|
|
200
|
+
Alerts are deduplicated within a 30-second window.
|
|
201
|
+
|
|
202
|
+
## MCP server
|
|
203
|
+
|
|
204
|
+
agenttop can run as an MCP server, letting Claude Code query session status, alerts, and usage directly:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
agenttop --install-mcp # register in Claude Code settings
|
|
208
|
+
agenttop --mcp # start the MCP server (usually done automatically)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Available tools:
|
|
212
|
+
|
|
213
|
+
| Tool | Description |
|
|
214
|
+
|------|-------------|
|
|
215
|
+
| `agenttop_sessions` | List active sessions with model, CPU, MEM, tokens |
|
|
216
|
+
| `agenttop_alerts` | Get recent security alerts (filterable by severity) |
|
|
217
|
+
| `agenttop_usage` | Get token usage for a session or all sessions |
|
|
218
|
+
| `agenttop_activity` | Get recent tool calls for a session |
|
|
219
|
+
|
|
220
|
+
You can also run the MCP server directly via `agenttop-mcp` (installed as a separate bin).
|
|
221
|
+
|
|
222
|
+
## Notifications
|
|
223
|
+
|
|
224
|
+
When security alerts are raised:
|
|
225
|
+
|
|
226
|
+
- **Terminal bell** — `\x07` on high/critical alerts (configurable)
|
|
227
|
+
- **Desktop notification** — via `notify-send` (linux) or `osascript` (macOS) for critical alerts
|
|
228
|
+
|
|
229
|
+
Rate-limited to max 1 desktop notification per 30 seconds.
|
|
230
|
+
|
|
231
|
+
Configure in `config.json` under `notifications`, or disable entirely with `--no-notify`.
|
|
232
|
+
|
|
233
|
+
## Alert logging
|
|
234
|
+
|
|
235
|
+
Alerts are logged to `~/.config/agenttop/alerts.jsonl` by default. One JSON line per alert.
|
|
236
|
+
|
|
237
|
+
The log file rotates when it exceeds 10MB (keeps 2 rotated files).
|
|
238
|
+
|
|
239
|
+
Disable with `--no-alert-log` or set `alerts.enabled: false` in config.
|
|
240
|
+
|
|
241
|
+
## Auto-updates
|
|
242
|
+
|
|
243
|
+
On launch, agenttop checks npm for newer versions (5-second timeout, silent on failure). If a newer version is available, a banner appears in the status bar.
|
|
244
|
+
|
|
245
|
+
Press `u` to install the update in the background. Restart to apply.
|
|
246
|
+
|
|
247
|
+
Background re-checks every 6 hours while running.
|
|
248
|
+
|
|
249
|
+
Disable with `--no-updates` or set `updates.checkOnLaunch: false` in config.
|
|
250
|
+
|
|
251
|
+
## Configuration
|
|
252
|
+
|
|
253
|
+
Config file at `~/.config/agenttop/config.json` (respects `XDG_CONFIG_HOME`):
|
|
254
|
+
|
|
255
|
+
```json
|
|
256
|
+
{
|
|
257
|
+
"pollInterval": 10000,
|
|
258
|
+
"maxEvents": 200,
|
|
259
|
+
"maxAlerts": 100,
|
|
260
|
+
"alertLevel": "warn",
|
|
261
|
+
"notifications": {
|
|
262
|
+
"bell": true,
|
|
263
|
+
"desktop": false,
|
|
264
|
+
"minSeverity": "high"
|
|
265
|
+
},
|
|
266
|
+
"alerts": {
|
|
267
|
+
"logFile": "~/.config/agenttop/alerts.jsonl",
|
|
268
|
+
"enabled": true
|
|
269
|
+
},
|
|
270
|
+
"updates": {
|
|
271
|
+
"checkOnLaunch": true,
|
|
272
|
+
"checkInterval": 21600000
|
|
273
|
+
},
|
|
274
|
+
"keybindings": {
|
|
275
|
+
"quit": "q",
|
|
276
|
+
"navUp": "k",
|
|
277
|
+
"navDown": "j",
|
|
278
|
+
"panelNext": "tab",
|
|
279
|
+
"panelPrev": "shift+tab",
|
|
280
|
+
"scrollTop": "g",
|
|
281
|
+
"scrollBottom": "G",
|
|
282
|
+
"filter": "/",
|
|
283
|
+
"nickname": "n",
|
|
284
|
+
"clearNickname": "N",
|
|
285
|
+
"detail": "enter",
|
|
286
|
+
"update": "u"
|
|
287
|
+
},
|
|
288
|
+
"nicknames": {},
|
|
289
|
+
"security": {
|
|
290
|
+
"enabled": true,
|
|
291
|
+
"rules": {
|
|
292
|
+
"network": true,
|
|
293
|
+
"exfiltration": true,
|
|
294
|
+
"sensitiveFiles": true,
|
|
295
|
+
"shellEscape": true,
|
|
296
|
+
"injection": true
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
CLI flags override config values. Config is created with defaults on first run. New fields are auto-populated on upgrade.
|
|
303
|
+
|
|
304
|
+
## Keybindings
|
|
305
|
+
|
|
306
|
+
All keybindings are configurable via `keybindings` in the config file. The footer bar updates to reflect your custom bindings.
|
|
307
|
+
|
|
308
|
+
Default keybindings:
|
|
309
|
+
|
|
310
|
+
| Key | Action |
|
|
311
|
+
|-----|--------|
|
|
312
|
+
| `j` / `k` / arrows | Navigate sessions / scroll activity |
|
|
313
|
+
| `Tab` / left / right | Switch panel focus |
|
|
314
|
+
| `Enter` | Open session detail view |
|
|
315
|
+
| `Esc` | Close detail view / clear filter |
|
|
316
|
+
| `/` | Filter sessions |
|
|
317
|
+
| `n` | Set nickname for selected session |
|
|
318
|
+
| `N` | Clear nickname |
|
|
319
|
+
| `u` | Install available update |
|
|
320
|
+
| `g` / `G` | Scroll to top / bottom of activity |
|
|
321
|
+
| `q` | Quit |
|
|
322
|
+
|
|
323
|
+
## How it works
|
|
324
|
+
|
|
325
|
+
agenttop reads Claude Code's task output files from `/tmp/claude-<uid>/` using inotify-based file watching via [chokidar](https://github.com/paulmillr/chokidar). Each session writes JSONL events containing tool calls, tool results, and token usage, which agenttop parses and displays in real-time.
|
|
326
|
+
|
|
327
|
+
Three runtime dependencies: [ink](https://github.com/vadimdemedes/ink) (React-based TUI), chokidar (file watching), and [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk) (MCP server). Everything else is Node built-ins.
|
|
328
|
+
|
|
329
|
+
## Multi-user support
|
|
330
|
+
|
|
331
|
+
- **Non-root** — monitors your own sessions only
|
|
332
|
+
- **Root** — use `--all-users` to monitor all users' sessions on the machine
|
|
333
|
+
|
|
334
|
+
## Contributing
|
|
335
|
+
|
|
336
|
+
This project is experimental and contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, code standards, and PR guidelines.
|
|
337
|
+
|
|
338
|
+
Ideas for contributions:
|
|
339
|
+
|
|
340
|
+
- Support for additional agent platforms beyond Claude Code
|
|
341
|
+
- New security rules
|
|
342
|
+
- Themes and colour customisation
|
|
343
|
+
- Windows support
|
|
344
|
+
|
|
345
|
+
## Trademark notice
|
|
346
|
+
|
|
347
|
+
"Claude" is a trademark of Anthropic, PBC. This project is not affiliated with, endorsed by, or sponsored by Anthropic. It monitors Claude Code sessions by reading locally-stored session data.
|
|
348
|
+
|
|
349
|
+
## License
|
|
350
|
+
|
|
351
|
+
MIT
|