agent-tank 0.9.3 → 0.9.5
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/README.md +325 -438
- package/bin/agent-tank.js +28 -1
- package/package.json +1 -1
- package/src/agents/base.js +1 -1
- package/src/agents/claude.js +10 -28
- package/src/agents/gemini.js +20 -18
- package/src/auto-refresh-manager.js +4 -5
- package/src/client-auto-refresh.js +2 -2
- package/src/index.js +199 -11
- package/src/server.js +7 -3
- package/src/usage-formatters.js +3 -3
package/README.md
CHANGED
|
@@ -2,286 +2,268 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Agent Tank is a local dashboard and HTTP API for monitoring usage limits in AI coding agent CLIs.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
It supports:
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- Claude Code
|
|
10
|
+
- Gemini CLI
|
|
11
|
+
- OpenAI Codex
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
- **Auto-discovery** - Automatically detects installed LLM CLI tools
|
|
13
|
-
- **HTTP API** - Query usage limits via REST endpoints
|
|
14
|
-
- **Unified Web UI** - All-in-one dashboard showing Claude, Gemini, and Codex usage at a glance
|
|
15
|
-
- **Instant Tab Tracking** - Pin the dashboard to your browser tab and see live usage updates via favicon and title changes
|
|
16
|
-
- **Lightweight** - Single dependency (node-pty)
|
|
17
|
-
- **Multi-agent** - Monitor Claude, Gemini, and Codex simultaneously
|
|
18
|
-
- **Secure by design** - No browser cookies, web scraping, or credential access
|
|
13
|
+
## How It Gets the Data
|
|
19
14
|
|
|
20
|
-
|
|
15
|
+
This is the part that matters.
|
|
21
16
|
|
|
22
|
-
|
|
17
|
+
Agent Tank reads usage directly from the local CLI tools you already use. It launches the installed CLIs locally, runs their built-in usage commands, and parses the output into a unified web UI and JSON API.
|
|
23
18
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
- Claude: runs `/usage`
|
|
20
|
+
- Gemini: runs `/stats`
|
|
21
|
+
- Codex: prefers JSON-RPC `account/rateLimits/read`, falls back to `/status`
|
|
27
22
|
|
|
28
|
-
|
|
29
|
-
agent-tank --claude --gemini
|
|
23
|
+
What it does not do:
|
|
30
24
|
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
- It does not scrape provider websites
|
|
26
|
+
- It does not read browser cookies
|
|
27
|
+
- It does not depend on a logged-in browser session
|
|
28
|
+
- It does not MITM or inspect your network traffic
|
|
29
|
+
- It does not send your usage data to a remote service
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
agent-tank --once
|
|
31
|
+
If you have seen other tools built around log-file heuristics or browser-session scraping, Agent Tank is deliberately not that.
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
agent-tank --once --json
|
|
39
|
-
```
|
|
33
|
+
## Who It Is For
|
|
40
34
|
|
|
41
|
-
|
|
35
|
+
Agent Tank is meant for subscription-based coding agent products where the CLI itself exposes session or limit information.
|
|
42
36
|
|
|
43
|
-
|
|
44
|
-
Options:
|
|
45
|
-
--claude Enable Claude monitoring
|
|
46
|
-
--gemini Enable Gemini monitoring
|
|
47
|
-
--codex Enable Codex monitoring
|
|
48
|
-
--port <port> HTTP server port (default: 3456)
|
|
49
|
-
--host <host> Bind address (default: 127.0.0.1)
|
|
50
|
-
--auth-user <user> HTTP Basic Auth username
|
|
51
|
-
--auth-pass <pass> HTTP Basic Auth password
|
|
52
|
-
--auth-token <token> API key for Bearer token auth
|
|
53
|
-
--fresh-process Spawn a new process per refresh (default: false)
|
|
54
|
-
--claude-api Use direct Anthropic API for Claude usage (faster, 60s refresh)
|
|
55
|
-
--config, -c Path to config file (JSON)
|
|
56
|
-
--auto-discover Auto-discover available agents (default: true)
|
|
57
|
-
--auto-refresh Enable/disable background auto-refresh (default: true)
|
|
58
|
-
--auto-refresh-mode <mode> Refresh mode: none, interval, activity (default: activity)
|
|
59
|
-
--auto-refresh-interval <seconds> Auto-refresh interval in seconds (default: 60)
|
|
60
|
-
--activity-debounce <ms> Activity debounce interval in milliseconds (default: 5000)
|
|
61
|
-
--keepalive Enable/disable session keepalive (default: true)
|
|
62
|
-
--keepalive-interval <seconds> Session keepalive interval in seconds (default: 300)
|
|
63
|
-
--history-retention-days <days> Days to retain usage history (default: 14)
|
|
64
|
-
--once Fetch usage once and exit (no HTTP server)
|
|
65
|
-
--json Output pure JSON (suppress logging, use with --once)
|
|
66
|
-
--help, -h Show this help message
|
|
67
|
-
```
|
|
37
|
+
Examples:
|
|
68
38
|
|
|
69
|
-
|
|
39
|
+
- Claude Code Pro / Max
|
|
40
|
+
- Gemini CLI with supported subscription plans
|
|
41
|
+
- ChatGPT Codex with supported plans
|
|
70
42
|
|
|
71
|
-
|
|
43
|
+
It is not for:
|
|
72
44
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
| `AGENT_TANK_PASS` | Basic auth password (overrides `--auth-pass`) |
|
|
77
|
-
| `AGENT_TANK_TOKEN` | API key (overrides `--auth-token`) |
|
|
78
|
-
| `AGENT_TANK_HOST` | Bind address (overrides `--host`) |
|
|
79
|
-
| `AGENT_TANK_FRESH_PROCESS` | Use fresh process per refresh (`1` or `true`) |
|
|
80
|
-
| `AGENT_TANK_CLAUDE_API` | Use direct Anthropic API for Claude usage (`1` or `true`) |
|
|
81
|
-
| `AGENT_TANK_AUTO_REFRESH` | Enable/disable background auto-refresh (`1`/`true` or `0`/`false`) |
|
|
82
|
-
| `AGENT_TANK_AUTO_REFRESH_MODE` | Refresh mode: `none`, `interval`, or `activity` (default: `activity`) |
|
|
83
|
-
| `AGENT_TANK_AUTO_REFRESH_INTERVAL` | Auto-refresh interval in seconds |
|
|
84
|
-
| `AGENT_TANK_ACTIVITY_DEBOUNCE` | Activity debounce interval in milliseconds (default: 5000) |
|
|
85
|
-
| `AGENT_TANK_KEEPALIVE` | Enable/disable session keepalive (`1`/`true` or `0`/`false`) |
|
|
86
|
-
| `AGENT_TANK_KEEPALIVE_INTERVAL` | Session keepalive interval in seconds (default: 300) |
|
|
87
|
-
| `AGENT_TANK_HISTORY_RETENTION_DAYS` | Days to retain usage history (default: 14) |
|
|
45
|
+
- pay-as-you-go API key billing
|
|
46
|
+
- cost tracking for API requests
|
|
47
|
+
- provider billing dashboards
|
|
88
48
|
|
|
89
|
-
|
|
49
|
+
If you need API spend tracking, use the provider’s billing tools instead.
|
|
90
50
|
|
|
91
|
-
|
|
51
|
+
## Quick Start
|
|
92
52
|
|
|
93
|
-
|
|
94
|
-
{
|
|
95
|
-
"claude": true,
|
|
96
|
-
"gemini": true,
|
|
97
|
-
"codex": false,
|
|
98
|
-
"port": 8080,
|
|
99
|
-
"history": {
|
|
100
|
-
"retentionDays": 7
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
```
|
|
53
|
+
### Install
|
|
104
54
|
|
|
105
55
|
```bash
|
|
106
|
-
agent-tank
|
|
56
|
+
npm install -g agent-tank
|
|
107
57
|
```
|
|
108
58
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
By default, Claude usage data is fetched by spawning a PTY session and running the `/usage` command. With `--claude-api`, Agent Tank fetches usage directly from the Anthropic OAuth API instead, which is faster and allows a 60-second refresh interval (vs 10 minutes for PTY).
|
|
59
|
+
Or run it directly:
|
|
112
60
|
|
|
113
61
|
```bash
|
|
114
|
-
agent-tank
|
|
62
|
+
npx agent-tank
|
|
115
63
|
```
|
|
116
64
|
|
|
117
|
-
###
|
|
65
|
+
### First Run
|
|
118
66
|
|
|
119
|
-
|
|
120
|
-
-
|
|
121
|
-
-
|
|
122
|
-
|
|
67
|
+
```bash
|
|
68
|
+
# Auto-discover installed agents and start the web UI + API
|
|
69
|
+
agent-tank
|
|
70
|
+
```
|
|
123
71
|
|
|
124
|
-
|
|
72
|
+
By default it starts on:
|
|
125
73
|
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
"claude": true,
|
|
129
|
-
"claudeApi": true
|
|
130
|
-
}
|
|
74
|
+
```text
|
|
75
|
+
http://127.0.0.1:3456
|
|
131
76
|
```
|
|
132
77
|
|
|
133
|
-
|
|
78
|
+
If Docker is available, Agent Tank asks Docker for the active bridge gateway addresses and binds them by default so containers on the same host can reach it without exposing it on the public interface. If Docker is unavailable, it falls back to local bridge interface detection.
|
|
79
|
+
|
|
80
|
+
Use this if you want localhost only:
|
|
134
81
|
|
|
135
82
|
```bash
|
|
136
|
-
|
|
83
|
+
agent-tank --no-docker
|
|
137
84
|
```
|
|
138
85
|
|
|
139
|
-
|
|
86
|
+
### Most Common Commands
|
|
140
87
|
|
|
141
|
-
|
|
88
|
+
```bash
|
|
89
|
+
# Monitor only specific agents
|
|
90
|
+
agent-tank --claude --gemini
|
|
142
91
|
|
|
143
|
-
|
|
92
|
+
# Use a custom port
|
|
93
|
+
agent-tank --port 8080
|
|
144
94
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
- Codex: `~/.codex/sessions/`, `~/.codex/`
|
|
148
|
-
- Gemini: `~/.config/gemini/`, `~/.gemini/`
|
|
95
|
+
# Fetch once and print JSON
|
|
96
|
+
agent-tank --once --json
|
|
149
97
|
|
|
150
|
-
|
|
98
|
+
# Show the installed Agent Tank version
|
|
99
|
+
agent-tank --version
|
|
151
100
|
|
|
152
|
-
|
|
101
|
+
# Require at least 60 seconds between refreshes for the same agent
|
|
102
|
+
agent-tank --refresh-cooldown 60
|
|
103
|
+
```
|
|
153
104
|
|
|
154
|
-
|
|
105
|
+
## What You Get
|
|
155
106
|
|
|
156
|
-
###
|
|
107
|
+
### Web UI
|
|
157
108
|
|
|
158
|
-
|
|
109
|
+
- Single-page dashboard for all supported agents
|
|
110
|
+
- Live refresh
|
|
111
|
+
- Reset countdowns
|
|
112
|
+
- Pace indicators
|
|
113
|
+
- Browser-tab tracking via title and favicon updates
|
|
159
114
|
|
|
160
|
-
|
|
161
|
-
|------|-------------|
|
|
162
|
-
| `activity` | (Default) Monitors log directories and refreshes when CLI activity is detected |
|
|
163
|
-
| `interval` | Traditional interval-based polling at fixed intervals |
|
|
164
|
-
| `none` | No automatic refresh; manual refresh only via `POST /refresh` |
|
|
115
|
+
### HTTP API
|
|
165
116
|
|
|
166
|
-
|
|
117
|
+
- `GET /status`
|
|
118
|
+
- `GET /status/:agent`
|
|
119
|
+
- `POST /refresh`
|
|
120
|
+
- `POST /refresh/:agent`
|
|
121
|
+
- `GET /config`
|
|
122
|
+
- `GET /history`
|
|
123
|
+
- `GET /history/:agent`
|
|
167
124
|
|
|
168
|
-
|
|
169
|
-
# Use activity-based polling (default)
|
|
170
|
-
agent-tank
|
|
125
|
+
### Supported Metrics
|
|
171
126
|
|
|
172
|
-
|
|
173
|
-
|
|
127
|
+
| Agent | Method | Metrics |
|
|
128
|
+
|---|---|---|
|
|
129
|
+
| Claude | PTY `/usage` or Anthropic OAuth API | Current session, weekly all-models, weekly Sonnet-only |
|
|
130
|
+
| Gemini | PTY `/stats` | Per-model usage and reset windows |
|
|
131
|
+
| Codex | JSON-RPC preferred, PTY fallback | 5-hour limits, weekly limits, model/account info |
|
|
174
132
|
|
|
175
|
-
|
|
176
|
-
agent-tank --auto-refresh-mode interval
|
|
133
|
+
## Basic Usage
|
|
177
134
|
|
|
178
|
-
|
|
179
|
-
agent-tank --auto-refresh-mode none
|
|
135
|
+
### Auto-Discover Everything
|
|
180
136
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
AGENT_TANK_ACTIVITY_DEBOUNCE=10000 agent-tank
|
|
137
|
+
```bash
|
|
138
|
+
agent-tank
|
|
184
139
|
```
|
|
185
140
|
|
|
186
|
-
###
|
|
187
|
-
|
|
188
|
-
- Activity mode automatically falls back to interval mode if no log directories are found
|
|
189
|
-
- The debounce interval is specified in milliseconds (default: 5000ms = 5 seconds)
|
|
190
|
-
- During active usage, refreshes occur at the `--auto-refresh-interval` rate (default: 60 seconds)
|
|
191
|
-
- Activity mode is disabled in one-shot mode (`--once`)
|
|
192
|
-
|
|
193
|
-
## Session Keepalive
|
|
141
|
+
### Monitor Specific Agents
|
|
194
142
|
|
|
195
|
-
|
|
143
|
+
```bash
|
|
144
|
+
agent-tank --claude --codex
|
|
145
|
+
```
|
|
196
146
|
|
|
197
|
-
###
|
|
147
|
+
### One-Shot Scripting Mode
|
|
198
148
|
|
|
199
|
-
|
|
149
|
+
```bash
|
|
150
|
+
agent-tank --once --json
|
|
151
|
+
```
|
|
200
152
|
|
|
201
|
-
###
|
|
153
|
+
### Bind to a Different Host or Port
|
|
202
154
|
|
|
203
155
|
```bash
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
# Custom keepalive interval (every 10 minutes)
|
|
208
|
-
agent-tank --keepalive-interval 600
|
|
156
|
+
agent-tank --host 0.0.0.0 --port 8080
|
|
157
|
+
```
|
|
209
158
|
|
|
210
|
-
|
|
211
|
-
agent-tank --no-keepalive
|
|
159
|
+
### Disable Docker Bridge Binding
|
|
212
160
|
|
|
213
|
-
|
|
214
|
-
|
|
161
|
+
```bash
|
|
162
|
+
agent-tank --no-docker
|
|
215
163
|
```
|
|
216
164
|
|
|
217
|
-
###
|
|
165
|
+
### Disable Background Refresh
|
|
218
166
|
|
|
219
|
-
|
|
220
|
-
-
|
|
221
|
-
|
|
167
|
+
```bash
|
|
168
|
+
agent-tank --auto-refresh-mode none
|
|
169
|
+
```
|
|
222
170
|
|
|
223
|
-
|
|
171
|
+
### Slow Down Agent Refreshes
|
|
224
172
|
|
|
225
|
-
Agent Tank
|
|
173
|
+
By default, Agent Tank will not refresh the same agent more than once every 30 seconds, even if the refresh is triggered manually or by detected CLI activity. This reduces unnecessary polling and helps avoid CLI-side rate limiting.
|
|
226
174
|
|
|
227
|
-
|
|
175
|
+
```bash
|
|
176
|
+
agent-tank --refresh-cooldown 60
|
|
177
|
+
```
|
|
228
178
|
|
|
229
|
-
|
|
230
|
-
- **Automatic Pruning**: Records older than the retention period (default: 14 days) are automatically removed
|
|
231
|
-
- **Pace Evaluation**: Each metric includes a `paceEval` object that calculates:
|
|
232
|
-
- `expectedPercent`: What your usage should be based on linear pace
|
|
233
|
-
- `isBurningFast`: Whether you're using faster than the 1.2x threshold
|
|
234
|
-
- `etaSeconds`: Estimated seconds until you hit 100% (if burning fast)
|
|
235
|
-
- `deltaPercent`: Difference between actual and expected usage
|
|
179
|
+
Set it to `0` to disable the cooldown entirely.
|
|
236
180
|
|
|
237
|
-
|
|
181
|
+
## Command Line Options
|
|
238
182
|
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
183
|
+
```text
|
|
184
|
+
Options:
|
|
185
|
+
--claude Enable Claude monitoring
|
|
186
|
+
--gemini Enable Gemini monitoring
|
|
187
|
+
--codex Enable Codex monitoring
|
|
188
|
+
--port <port> HTTP server port (default: 3456)
|
|
189
|
+
--host <host> Bind address (default: 127.0.0.1 + Docker bridge when available)
|
|
190
|
+
--docker Enable Docker bridge bind when --host is omitted (default: true)
|
|
191
|
+
--auth-user <user> HTTP Basic Auth username
|
|
192
|
+
--auth-pass <pass> HTTP Basic Auth password
|
|
193
|
+
--auth-token <token> API key for Bearer token auth
|
|
194
|
+
--fresh-process Spawn a new process per refresh (default: false)
|
|
195
|
+
--claude-api Use direct Anthropic API for Claude usage (faster, 60s refresh)
|
|
196
|
+
--config, -c Path to config file (JSON)
|
|
197
|
+
--version, -v Show version
|
|
198
|
+
--auto-discover Auto-discover available agents (default: true)
|
|
199
|
+
--auto-refresh Enable/disable background auto-refresh (default: true)
|
|
200
|
+
--auto-refresh-mode <mode> Refresh mode: none, interval, activity (default: activity)
|
|
201
|
+
--auto-refresh-interval <seconds> Auto-refresh interval in seconds (default: 60)
|
|
202
|
+
--refresh-cooldown <seconds> Minimum time between refreshes per agent (default: 30, 0 = disabled)
|
|
203
|
+
--activity-debounce <ms> Activity debounce interval in milliseconds (default: 5000)
|
|
204
|
+
--keepalive Enable/disable session keepalive (default: true)
|
|
205
|
+
--keepalive-interval <seconds> Session keepalive interval in seconds (default: 300)
|
|
206
|
+
--history-retention-days <days> Days to retain usage history (default: 14)
|
|
207
|
+
--once Fetch usage once and exit (no HTTP server)
|
|
208
|
+
--json Output pure JSON (suppress logging, use with --once)
|
|
209
|
+
--help, -h Show this help message
|
|
245
210
|
```
|
|
246
211
|
|
|
247
|
-
|
|
212
|
+
## Configuration
|
|
248
213
|
|
|
249
|
-
|
|
250
|
-
|
|
214
|
+
### Environment Variables
|
|
215
|
+
|
|
216
|
+
Environment variables override CLI flags and config file values.
|
|
251
217
|
|
|
252
|
-
|
|
218
|
+
| Variable | Description |
|
|
219
|
+
|---|---|
|
|
220
|
+
| `AGENT_TANK_USER` | Basic auth username |
|
|
221
|
+
| `AGENT_TANK_PASS` | Basic auth password |
|
|
222
|
+
| `AGENT_TANK_TOKEN` | Bearer token auth |
|
|
223
|
+
| `AGENT_TANK_HOST` | Bind address |
|
|
224
|
+
| `AGENT_TANK_DOCKER` | Enable/disable Docker bridge bind when `--host` is omitted |
|
|
225
|
+
| `AGENT_TANK_FRESH_PROCESS` | Use fresh process per refresh (`1`/`true`) |
|
|
226
|
+
| `AGENT_TANK_CLAUDE_API` | Use Claude API mode (`1`/`true`) |
|
|
227
|
+
| `AGENT_TANK_AUTO_REFRESH` | Enable/disable auto-refresh |
|
|
228
|
+
| `AGENT_TANK_AUTO_REFRESH_MODE` | `none`, `interval`, or `activity` |
|
|
229
|
+
| `AGENT_TANK_AUTO_REFRESH_INTERVAL` | Auto-refresh interval in seconds |
|
|
230
|
+
| `AGENT_TANK_REFRESH_COOLDOWN` | Minimum time between refreshes per agent in seconds |
|
|
231
|
+
| `AGENT_TANK_ACTIVITY_DEBOUNCE` | Activity debounce interval in milliseconds |
|
|
232
|
+
| `AGENT_TANK_KEEPALIVE` | Enable/disable keepalive |
|
|
233
|
+
| `AGENT_TANK_KEEPALIVE_INTERVAL` | Keepalive interval in seconds |
|
|
234
|
+
| `AGENT_TANK_HISTORY_RETENTION_DAYS` | History retention window |
|
|
253
235
|
|
|
254
|
-
|
|
236
|
+
### Config File
|
|
255
237
|
|
|
256
238
|
```json
|
|
257
239
|
{
|
|
258
|
-
"
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
240
|
+
"claude": true,
|
|
241
|
+
"gemini": true,
|
|
242
|
+
"codex": false,
|
|
243
|
+
"port": 8080,
|
|
244
|
+
"dockerAccess": true,
|
|
245
|
+
"claudeApi": false,
|
|
246
|
+
"refreshCooldown": 30,
|
|
247
|
+
"autoRefresh": {
|
|
248
|
+
"mode": "activity",
|
|
249
|
+
"interval": 60,
|
|
250
|
+
"activityDebounce": 5000,
|
|
251
|
+
"refreshCooldown": 30
|
|
252
|
+
},
|
|
253
|
+
"keepalive": {
|
|
254
|
+
"enabled": true,
|
|
255
|
+
"interval": 300
|
|
256
|
+
},
|
|
257
|
+
"history": {
|
|
258
|
+
"retentionDays": 14
|
|
269
259
|
}
|
|
270
260
|
}
|
|
271
261
|
```
|
|
272
262
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
## Installation
|
|
276
|
-
|
|
277
|
-
```bash
|
|
278
|
-
npm install -g agent-tank
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
Or run directly with npx:
|
|
263
|
+
Run with:
|
|
282
264
|
|
|
283
265
|
```bash
|
|
284
|
-
|
|
266
|
+
agent-tank -c config.json
|
|
285
267
|
```
|
|
286
268
|
|
|
287
269
|
## HTTP API
|
|
@@ -289,19 +271,17 @@ npx agent-tank
|
|
|
289
271
|
### Endpoints
|
|
290
272
|
|
|
291
273
|
| Method | Endpoint | Description |
|
|
292
|
-
|
|
274
|
+
|---|---|---|
|
|
293
275
|
| GET | `/` | HTML status page |
|
|
294
276
|
| GET | `/status` | JSON status for all agents |
|
|
295
|
-
| GET | `/status/:agent` | JSON status for
|
|
296
|
-
| GET | `/config` | Auto-refresh and history
|
|
297
|
-
| GET | `/history` |
|
|
298
|
-
| GET | `/history/:agent` |
|
|
277
|
+
| GET | `/status/:agent` | JSON status for one agent |
|
|
278
|
+
| GET | `/config` | Auto-refresh and history config |
|
|
279
|
+
| GET | `/history` | History summary |
|
|
280
|
+
| GET | `/history/:agent` | History for one agent |
|
|
299
281
|
| POST | `/refresh` | Refresh all agents |
|
|
300
|
-
| POST | `/refresh/:agent` | Refresh
|
|
282
|
+
| POST | `/refresh/:agent` | Refresh one agent |
|
|
301
283
|
|
|
302
|
-
### Example
|
|
303
|
-
|
|
304
|
-
#### GET /status
|
|
284
|
+
### Example `GET /status`
|
|
305
285
|
|
|
306
286
|
```json
|
|
307
287
|
{
|
|
@@ -321,19 +301,9 @@ npx agent-tank
|
|
|
321
301
|
"resetsAt": "Mar 13, 3am (Europe/London)",
|
|
322
302
|
"resetsIn": "4d 5h",
|
|
323
303
|
"resetsInSeconds": 364364
|
|
324
|
-
},
|
|
325
|
-
"weeklySonnet": {
|
|
326
|
-
"label": "Current week (Sonnet only)",
|
|
327
|
-
"percent": 5,
|
|
328
|
-
"resetsAt": "Mar 13, 10am (Europe/London)",
|
|
329
|
-
"resetsIn": "4d 12h",
|
|
330
|
-
"resetsInSeconds": 389564
|
|
331
304
|
}
|
|
332
305
|
},
|
|
333
306
|
"metadata": {
|
|
334
|
-
"sessionId": "0b34aa59-...",
|
|
335
|
-
"cwd": "/tmp",
|
|
336
|
-
"organization": "Your Organization",
|
|
337
307
|
"email": "user@example.com",
|
|
338
308
|
"version": "2.1.71"
|
|
339
309
|
},
|
|
@@ -341,94 +311,25 @@ npx agent-tank
|
|
|
341
311
|
"error": null,
|
|
342
312
|
"isRefreshing": false
|
|
343
313
|
},
|
|
344
|
-
"gemini": {
|
|
345
|
-
"name": "gemini",
|
|
346
|
-
"usage": {
|
|
347
|
-
"models": [
|
|
348
|
-
{
|
|
349
|
-
"model": "gemini-2.5-flash",
|
|
350
|
-
"usageLeft": 100,
|
|
351
|
-
"resetsIn": "24h",
|
|
352
|
-
"percentUsed": 0,
|
|
353
|
-
"resetsInSeconds": 86400
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
"model": "gemini-2.5-pro",
|
|
357
|
-
"usageLeft": 99.5,
|
|
358
|
-
"resetsIn": "12h 16m",
|
|
359
|
-
"percentUsed": 0.5,
|
|
360
|
-
"resetsInSeconds": 44160
|
|
361
|
-
}
|
|
362
|
-
]
|
|
363
|
-
},
|
|
364
|
-
"metadata": {
|
|
365
|
-
"version": "0.24.5",
|
|
366
|
-
"email": "user@example.com",
|
|
367
|
-
"authMethod": "OAuth",
|
|
368
|
-
"model": "auto-gemini-2.5",
|
|
369
|
-
"os": "linux",
|
|
370
|
-
"updateAvailable": {
|
|
371
|
-
"current": "0.24.5",
|
|
372
|
-
"latest": "0.32.1"
|
|
373
|
-
}
|
|
374
|
-
},
|
|
375
|
-
"lastUpdated": "2026-03-08T21:47:14.138Z",
|
|
376
|
-
"error": null,
|
|
377
|
-
"isRefreshing": false
|
|
378
|
-
},
|
|
379
314
|
"codex": {
|
|
380
315
|
"name": "codex",
|
|
381
316
|
"usage": {
|
|
382
317
|
"fiveHour": {
|
|
383
|
-
"percentLeft": 100,
|
|
384
|
-
"resetsAt": "02:44 on 9 Mar",
|
|
385
|
-
"label": "5h limit",
|
|
386
318
|
"percentUsed": 0,
|
|
319
|
+
"resetsAt": "02:44 on 9 Mar",
|
|
387
320
|
"resetsIn": "4h 56m",
|
|
388
321
|
"resetsInSeconds": 17807
|
|
389
322
|
},
|
|
390
323
|
"weekly": {
|
|
391
|
-
"percentLeft": 100,
|
|
392
|
-
"resetsAt": "21:44 on 15 Mar",
|
|
393
|
-
"label": "Weekly limit",
|
|
394
324
|
"percentUsed": 0,
|
|
325
|
+
"resetsAt": "21:44 on 15 Mar",
|
|
395
326
|
"resetsIn": "6d 23h",
|
|
396
327
|
"resetsInSeconds": 604607
|
|
397
|
-
}
|
|
398
|
-
"version": {
|
|
399
|
-
"current": "0.107.0",
|
|
400
|
-
"latest": "0.111.0"
|
|
401
|
-
},
|
|
402
|
-
"modelLimits": [
|
|
403
|
-
{
|
|
404
|
-
"name": "GPT-5.3-Codex-Spark",
|
|
405
|
-
"fiveHour": {
|
|
406
|
-
"percentLeft": 100,
|
|
407
|
-
"resetsAt": "02:46 on 9 Mar",
|
|
408
|
-
"label": "5h limit",
|
|
409
|
-
"percentUsed": 0,
|
|
410
|
-
"resetsIn": "4h 58m",
|
|
411
|
-
"resetsInSeconds": 17927
|
|
412
|
-
},
|
|
413
|
-
"weekly": {
|
|
414
|
-
"percentLeft": 100,
|
|
415
|
-
"resetsAt": "21:46 on 15 Mar",
|
|
416
|
-
"label": "Weekly limit",
|
|
417
|
-
"percentUsed": 0,
|
|
418
|
-
"resetsIn": "6d 23h",
|
|
419
|
-
"resetsInSeconds": 604727
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
],
|
|
423
|
-
"model": "gpt-5.3-codex",
|
|
424
|
-
"account": "user@example.com"
|
|
328
|
+
}
|
|
425
329
|
},
|
|
426
330
|
"metadata": {
|
|
427
|
-
"
|
|
428
|
-
"
|
|
429
|
-
"collaborationMode": "Default",
|
|
430
|
-
"model": "gpt-5.3-codex",
|
|
431
|
-
"email": "user@example.com"
|
|
331
|
+
"email": "user@example.com",
|
|
332
|
+
"model": "gpt-5.3-codex"
|
|
432
333
|
},
|
|
433
334
|
"lastUpdated": "2026-03-08T21:47:12.648Z",
|
|
434
335
|
"error": null,
|
|
@@ -437,220 +338,206 @@ npx agent-tank
|
|
|
437
338
|
}
|
|
438
339
|
```
|
|
439
340
|
|
|
440
|
-
|
|
341
|
+
## Claude API Mode
|
|
441
342
|
|
|
442
|
-
|
|
443
|
-
{
|
|
444
|
-
"name": "claude",
|
|
445
|
-
"usage": {
|
|
446
|
-
"session": {
|
|
447
|
-
"label": "Current session",
|
|
448
|
-
"percent": 42,
|
|
449
|
-
"resetsAt": "10pm (Europe/London)",
|
|
450
|
-
"resetsIn": "12m",
|
|
451
|
-
"resetsInSeconds": 764
|
|
452
|
-
},
|
|
453
|
-
"weeklyAll": {
|
|
454
|
-
"label": "Current week (all models)",
|
|
455
|
-
"percent": 31,
|
|
456
|
-
"resetsAt": "Mar 13, 3am (Europe/London)",
|
|
457
|
-
"resetsIn": "4d 5h",
|
|
458
|
-
"resetsInSeconds": 364364
|
|
459
|
-
},
|
|
460
|
-
"weeklySonnet": {
|
|
461
|
-
"label": "Current week (Sonnet only)",
|
|
462
|
-
"percent": 5,
|
|
463
|
-
"resetsAt": "Mar 13, 10am (Europe/London)",
|
|
464
|
-
"resetsIn": "4d 12h",
|
|
465
|
-
"resetsInSeconds": 389564
|
|
466
|
-
}
|
|
467
|
-
},
|
|
468
|
-
"metadata": {
|
|
469
|
-
"sessionId": "0b34aa59-...",
|
|
470
|
-
"cwd": "/tmp",
|
|
471
|
-
"organization": "Your Organization",
|
|
472
|
-
"email": "user@example.com",
|
|
473
|
-
"version": "2.1.71"
|
|
474
|
-
},
|
|
475
|
-
"lastUpdated": "2026-03-08T21:47:15.090Z",
|
|
476
|
-
"error": null,
|
|
477
|
-
"isRefreshing": false
|
|
478
|
-
}
|
|
479
|
-
```
|
|
343
|
+
By default, Claude usage is collected via PTY by running `/usage`.
|
|
480
344
|
|
|
481
|
-
|
|
345
|
+
With `--claude-api`, Agent Tank uses the Anthropic OAuth usage API instead. This is usually faster and supports a shorter refresh interval.
|
|
482
346
|
|
|
483
|
-
|
|
347
|
+
```bash
|
|
348
|
+
agent-tank --claude --claude-api
|
|
349
|
+
```
|
|
484
350
|
|
|
485
|
-
|
|
351
|
+
How it works:
|
|
486
352
|
|
|
487
|
-
|
|
353
|
+
- reads the same Claude OAuth credentials the CLI already uses
|
|
354
|
+
- calls `https://api.anthropic.com/api/oauth/usage`
|
|
355
|
+
- refreshes expired OAuth tokens when needed
|
|
356
|
+
- falls back to PTY mode if the API path fails
|
|
488
357
|
|
|
489
|
-
|
|
490
|
-
- **C++ build tools** (gcc, g++, make)
|
|
491
|
-
- **Node.js development headers**
|
|
358
|
+
You can also enable it with:
|
|
492
359
|
|
|
493
|
-
##### Linux (Ubuntu/Debian)
|
|
494
360
|
```bash
|
|
495
|
-
|
|
361
|
+
AGENT_TANK_CLAUDE_API=1 agent-tank --claude
|
|
496
362
|
```
|
|
497
363
|
|
|
498
|
-
|
|
499
|
-
```bash
|
|
500
|
-
sudo dnf install python3.11 python3.11-devel gcc gcc-c++ make nodejs-devel
|
|
501
|
-
```
|
|
364
|
+
## Auto-Refresh Modes
|
|
502
365
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
366
|
+
Agent Tank supports three refresh strategies:
|
|
367
|
+
|
|
368
|
+
| Mode | Description |
|
|
369
|
+
|---|---|
|
|
370
|
+
| `activity` | Default. Watches known local agent directories and refreshes when activity is detected |
|
|
371
|
+
| `interval` | Refreshes on a fixed timer |
|
|
372
|
+
| `none` | No background refresh. Use manual refresh only |
|
|
373
|
+
|
|
374
|
+
Examples:
|
|
507
375
|
|
|
508
|
-
##### macOS
|
|
509
376
|
```bash
|
|
510
|
-
#
|
|
511
|
-
|
|
377
|
+
# Default mode
|
|
378
|
+
agent-tank
|
|
512
379
|
|
|
513
|
-
#
|
|
514
|
-
|
|
380
|
+
# Interval polling
|
|
381
|
+
agent-tank --auto-refresh-mode interval
|
|
382
|
+
|
|
383
|
+
# Manual-only mode
|
|
384
|
+
agent-tank --auto-refresh-mode none
|
|
385
|
+
|
|
386
|
+
# Longer activity debounce
|
|
387
|
+
agent-tank --activity-debounce 10000
|
|
515
388
|
```
|
|
516
389
|
|
|
517
|
-
|
|
518
|
-
- Install [Python 3.11+](https://www.python.org/downloads/)
|
|
519
|
-
- Install [Visual Studio Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022)
|
|
390
|
+
### Activity-Based Polling
|
|
520
391
|
|
|
521
|
-
|
|
392
|
+
In activity mode, Agent Tank watches common local directories:
|
|
522
393
|
|
|
523
|
-
|
|
394
|
+
- Claude: `~/.config/claude/projects/`, `~/.claude/`
|
|
395
|
+
- Codex: `~/.codex/sessions/`, `~/.codex/`
|
|
396
|
+
- Gemini: `~/.config/gemini/`, `~/.gemini/`
|
|
524
397
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
398
|
+
If no suitable directories are found, it falls back to interval mode.
|
|
399
|
+
|
|
400
|
+
## Session Keepalive
|
|
528
401
|
|
|
529
|
-
|
|
402
|
+
Keepalive helps persistent PTY-backed sessions stay warm.
|
|
530
403
|
|
|
531
|
-
**Claude Code:** Version 1.x does not support the `/usage` command.
|
|
532
404
|
```bash
|
|
533
|
-
#
|
|
534
|
-
|
|
405
|
+
# Default keepalive
|
|
406
|
+
agent-tank
|
|
407
|
+
|
|
408
|
+
# Every 10 minutes
|
|
409
|
+
agent-tank --keepalive-interval 600
|
|
535
410
|
|
|
536
|
-
#
|
|
537
|
-
|
|
411
|
+
# Disable keepalive
|
|
412
|
+
agent-tank --no-keepalive
|
|
538
413
|
```
|
|
539
414
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
415
|
+
Notes:
|
|
416
|
+
|
|
417
|
+
- disabled automatically in `--fresh-process`
|
|
418
|
+
- disabled automatically in `--once`
|
|
419
|
+
- not needed for Codex JSON-RPC mode
|
|
420
|
+
|
|
421
|
+
## Usage History and Pace
|
|
422
|
+
|
|
423
|
+
Agent Tank stores usage snapshots and calculates whether a metric is being consumed faster than the time window would suggest.
|
|
424
|
+
|
|
425
|
+
You can configure retention:
|
|
544
426
|
|
|
545
|
-
|
|
546
|
-
|
|
427
|
+
```bash
|
|
428
|
+
agent-tank --history-retention-days 7
|
|
547
429
|
```
|
|
548
430
|
|
|
549
|
-
|
|
431
|
+
History endpoints:
|
|
550
432
|
|
|
551
|
-
|
|
552
|
-
|
|
433
|
+
- `GET /history`
|
|
434
|
+
- `GET /history/:agent`
|
|
553
435
|
|
|
554
|
-
|
|
555
|
-
agents: ['claude', 'gemini'], // or null for auto-discover
|
|
556
|
-
port: 3456,
|
|
557
|
-
autoDiscover: true
|
|
558
|
-
});
|
|
436
|
+
## Installation Notes
|
|
559
437
|
|
|
560
|
-
|
|
438
|
+
### Build Requirements
|
|
561
439
|
|
|
562
|
-
|
|
563
|
-
const status = watcher.getStatus();
|
|
564
|
-
console.log(status.claude.usage);
|
|
440
|
+
`node-pty` requires native compilation support.
|
|
565
441
|
|
|
566
|
-
|
|
567
|
-
await watcher.refreshAgent('claude');
|
|
442
|
+
You need:
|
|
568
443
|
|
|
569
|
-
|
|
570
|
-
|
|
444
|
+
- Python 3.8+
|
|
445
|
+
- C/C++ build tools
|
|
446
|
+
- Node.js development headers
|
|
447
|
+
|
|
448
|
+
#### Ubuntu / Debian
|
|
449
|
+
|
|
450
|
+
```bash
|
|
451
|
+
sudo apt-get install python3.11 python3.11-dev build-essential nodejs-dev
|
|
571
452
|
```
|
|
572
453
|
|
|
573
|
-
|
|
454
|
+
#### Fedora / RHEL / CentOS
|
|
574
455
|
|
|
575
|
-
|
|
456
|
+
```bash
|
|
457
|
+
sudo dnf install python3.11 python3.11-devel gcc gcc-c++ make nodejs-devel
|
|
458
|
+
```
|
|
576
459
|
|
|
577
|
-
####
|
|
460
|
+
#### openSUSE
|
|
578
461
|
|
|
579
|
-
|
|
462
|
+
```bash
|
|
463
|
+
sudo zypper install python311 python311-devel gcc gcc-c++ make nodejs20-devel
|
|
464
|
+
```
|
|
580
465
|
|
|
581
|
-
|
|
466
|
+
#### macOS
|
|
582
467
|
|
|
583
|
-
|
|
468
|
+
```bash
|
|
469
|
+
xcode-select --install
|
|
470
|
+
brew install python@3.11
|
|
471
|
+
```
|
|
584
472
|
|
|
585
|
-
|
|
586
|
-
2. **Sends JSON-RPC requests** - Calls `account/rateLimits/read` via stdin
|
|
587
|
-
3. **Receives structured data** - Parses JSON responses with precise rate limit information
|
|
588
|
-
4. **Falls back to PTY** - Automatically uses PTY mode if JSON-RPC is unavailable (older CLI versions)
|
|
473
|
+
#### Windows
|
|
589
474
|
|
|
590
|
-
|
|
475
|
+
- Install [Python 3.11+](https://www.python.org/downloads/)
|
|
476
|
+
- Install [Visual Studio Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022)
|
|
591
477
|
|
|
592
|
-
|
|
478
|
+
## CLI Requirements
|
|
593
479
|
|
|
594
|
-
|
|
480
|
+
You need at least one supported CLI installed and authenticated.
|
|
595
481
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
482
|
+
- [Claude Code](https://claude.ai/download) as `claude`
|
|
483
|
+
- Version 2.0+ required for `/usage`
|
|
484
|
+
- Gemini CLI as `gemini`
|
|
485
|
+
- Version 0.24.5+ required for `/stats`
|
|
486
|
+
- OpenAI Codex as `codex`
|
|
601
487
|
|
|
602
|
-
|
|
488
|
+
Useful checks:
|
|
603
489
|
|
|
604
|
-
|
|
490
|
+
```bash
|
|
491
|
+
claude --version
|
|
492
|
+
gemini --version
|
|
493
|
+
codex --version
|
|
494
|
+
```
|
|
605
495
|
|
|
606
|
-
|
|
607
|
-
- **No web scraping** - The tool does not access web interfaces or scrape HTML pages
|
|
608
|
-
- **No credential extraction** - Your API keys, tokens, or passwords are never accessed or stored
|
|
609
|
-
- **No network interception** - There is no proxy, MITM, or traffic inspection involved
|
|
610
|
-
- **No external data transmission** - Usage data stays on your machine; nothing is sent to external servers
|
|
496
|
+
## Programmatic Usage
|
|
611
497
|
|
|
612
|
-
|
|
498
|
+
```javascript
|
|
499
|
+
const { AgentTank } = require('agent-tank');
|
|
613
500
|
|
|
614
|
-
|
|
501
|
+
const watcher = new AgentTank({
|
|
502
|
+
agents: ['claude', 'gemini'],
|
|
503
|
+
port: 3456,
|
|
504
|
+
autoDiscover: true
|
|
505
|
+
});
|
|
615
506
|
|
|
616
|
-
|
|
507
|
+
await watcher.start();
|
|
617
508
|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
| Claude | PTY | `/usage` | Session %, Weekly % |
|
|
621
|
-
| Gemini | PTY | `/stats` | Model-specific usage % |
|
|
622
|
-
| Codex | JSON-RPC | `account/rateLimits/read` | 5h limit %, Weekly % |
|
|
623
|
-
| Codex | PTY (fallback) | `/status` | 5h limit %, Weekly % |
|
|
509
|
+
const status = watcher.getStatus();
|
|
510
|
+
console.log(status);
|
|
624
511
|
|
|
625
|
-
|
|
512
|
+
await watcher.refreshAgent('claude');
|
|
626
513
|
|
|
627
|
-
|
|
514
|
+
watcher.stop();
|
|
515
|
+
```
|
|
628
516
|
|
|
629
|
-
|
|
517
|
+
## Troubleshooting
|
|
630
518
|
|
|
631
|
-
|
|
632
|
-
```bash
|
|
633
|
-
PYTHON=/usr/bin/python3.11 npm install
|
|
634
|
-
```
|
|
519
|
+
### `gyp ERR!` during install
|
|
635
520
|
|
|
636
|
-
|
|
521
|
+
This usually means your system is missing Python, compiler tools, or Node headers.
|
|
637
522
|
|
|
638
|
-
|
|
523
|
+
Try:
|
|
639
524
|
|
|
640
|
-
If you still have issues, try rebuilding:
|
|
641
525
|
```bash
|
|
526
|
+
PYTHON=/usr/bin/python3.11 npm install
|
|
642
527
|
npm run rebuild
|
|
643
528
|
```
|
|
644
529
|
|
|
645
|
-
###
|
|
530
|
+
### `Timeout waiting for usage data`
|
|
646
531
|
|
|
647
|
-
-
|
|
648
|
-
-
|
|
649
|
-
-
|
|
532
|
+
- make sure the CLI works on its own
|
|
533
|
+
- make sure the CLI is authenticated
|
|
534
|
+
- check for trust prompts, auth prompts, or update prompts
|
|
535
|
+
- try `--fresh-process`
|
|
536
|
+
- try disabling keepalive or background refresh while debugging
|
|
650
537
|
|
|
651
|
-
###
|
|
538
|
+
### No agents found
|
|
652
539
|
|
|
653
|
-
|
|
540
|
+
Make sure at least one supported CLI is installed and on your `PATH`.
|
|
654
541
|
|
|
655
542
|
### Port already in use
|
|
656
543
|
|
|
@@ -672,4 +559,4 @@ MIT
|
|
|
672
559
|
|
|
673
560
|
## Contributing
|
|
674
561
|
|
|
675
|
-
|
|
562
|
+
Pull requests are welcome.
|