agent-tank 0.9.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 +675 -0
- package/bin/agent-tank.js +301 -0
- package/media/www-preview.png +0 -0
- package/package.json +65 -0
- package/src/activity-monitor.js +312 -0
- package/src/agents/api-response-parser.js +255 -0
- package/src/agents/base.js +396 -0
- package/src/agents/claude.js +388 -0
- package/src/agents/codex-pty-helpers.js +226 -0
- package/src/agents/codex-rpc-helpers.js +167 -0
- package/src/agents/codex.js +383 -0
- package/src/agents/gemini.js +302 -0
- package/src/agents/keepalive-helper.js +115 -0
- package/src/agents/oauth-helper.js +210 -0
- package/src/agents/pty-output-parser.js +301 -0
- package/src/auto-refresh-manager.js +246 -0
- package/src/client-auto-refresh-helpers.js +143 -0
- package/src/client-auto-refresh.js +321 -0
- package/src/client-favicon.js +198 -0
- package/src/client-monitor.js +242 -0
- package/src/client-script.js +147 -0
- package/src/discovery.js +128 -0
- package/src/history-store.js +273 -0
- package/src/http-handler.js +182 -0
- package/src/icons.js +67 -0
- package/src/index.js +376 -0
- package/src/json-rpc-client.js +285 -0
- package/src/keepalive-manager.js +163 -0
- package/src/logger.js +213 -0
- package/src/pace-attachment.js +104 -0
- package/src/pace-evaluator.js +269 -0
- package/src/public-status.js +276 -0
- package/src/server.js +144 -0
- package/src/snapshot-metrics.js +79 -0
- package/src/status-page.css +1149 -0
- package/src/status-page.js +128 -0
- package/src/usage-formatters.js +259 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Rinalds Uzkalns (https://propr.dev)
|
|
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,675 @@
|
|
|
1
|
+
# Agent Tank
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Monitor and query usage limits for LLM CLI tools (Claude, Gemini, Codex) via a simple HTTP API.
|
|
6
|
+
|
|
7
|
+
> **Note:** Agent Tank is designed for **AI coding agent subscriptions** such as Claude Code Pro/Max, Google Gemini CLI (with Advanced/Max plans), and ChatGPT Codex (with Plus/Pro plans). It tracks **active session and rate limit usage**—not API key consumption or pay-per-use billing. If you're using API keys with pay-as-you-go pricing, this tool won't help you track costs; check your provider's billing dashboard instead.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Privacy-first** - Runs entirely locally with no external data transmission
|
|
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
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Basic Usage
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Auto-discover and monitor all available LLM agents
|
|
26
|
+
agent-tank
|
|
27
|
+
|
|
28
|
+
# Monitor specific agents only
|
|
29
|
+
agent-tank --claude --gemini
|
|
30
|
+
|
|
31
|
+
# Use a custom port (default: 3456)
|
|
32
|
+
agent-tank --port 8080
|
|
33
|
+
|
|
34
|
+
# Fetch usage once and exit (no HTTP server)
|
|
35
|
+
agent-tank --once
|
|
36
|
+
|
|
37
|
+
# Output pure JSON for scripting/piping
|
|
38
|
+
agent-tank --once --json
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Command Line Options
|
|
42
|
+
|
|
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
|
+
```
|
|
68
|
+
|
|
69
|
+
### Environment Variables
|
|
70
|
+
|
|
71
|
+
Environment variables override CLI flags and config file settings:
|
|
72
|
+
|
|
73
|
+
| Variable | Description |
|
|
74
|
+
|----------|-------------|
|
|
75
|
+
| `AGENT_TANK_USER` | Basic auth username (overrides `--auth-user`) |
|
|
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) |
|
|
88
|
+
|
|
89
|
+
### Configuration File
|
|
90
|
+
|
|
91
|
+
You can use a JSON configuration file:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"claude": true,
|
|
96
|
+
"gemini": true,
|
|
97
|
+
"codex": false,
|
|
98
|
+
"port": 8080,
|
|
99
|
+
"history": {
|
|
100
|
+
"retentionDays": 7
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
agent-tank -c config.json
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Claude API Mode
|
|
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).
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
agent-tank --claude --claude-api
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### How It Works
|
|
118
|
+
|
|
119
|
+
- Uses the OAuth token from `~/.claude/.credentials.json` (the same credentials Claude Code uses)
|
|
120
|
+
- Calls the `api.anthropic.com/api/oauth/usage` endpoint with the `anthropic-beta: oauth-2025-04-20` header
|
|
121
|
+
- Automatically refreshes expired tokens using the OAuth refresh token flow
|
|
122
|
+
- Falls back to PTY mode if the API call fails
|
|
123
|
+
|
|
124
|
+
### Configuration
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"claude": true,
|
|
129
|
+
"claudeApi": true
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Or via environment variable:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
AGENT_TANK_CLAUDE_API=1 agent-tank --claude
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Activity-Based Polling
|
|
140
|
+
|
|
141
|
+
Agent Tank supports intelligent activity-based polling that monitors local log directories for LLM CLI activity. Instead of polling on a fixed interval (which can waste resources during idle periods), activity mode only triggers usage refreshes when you're actively using the CLI tools.
|
|
142
|
+
|
|
143
|
+
### How It Works
|
|
144
|
+
|
|
145
|
+
1. **Log Directory Monitoring**: Agent Tank watches the following directories for file changes:
|
|
146
|
+
- Claude: `~/.config/claude/projects/`, `~/.claude/`
|
|
147
|
+
- Codex: `~/.codex/sessions/`, `~/.codex/`
|
|
148
|
+
- Gemini: `~/.config/gemini/`, `~/.gemini/`
|
|
149
|
+
|
|
150
|
+
2. **Debounced Detection**: When activity is detected, a configurable debounce timer starts. This prevents excessive refreshes during bursts of activity.
|
|
151
|
+
|
|
152
|
+
3. **On-Demand Refresh Cycles**: After the debounce period, a refresh cycle begins and continues at the configured interval while activity is ongoing.
|
|
153
|
+
|
|
154
|
+
4. **Idle State**: When no more activity is detected, polling stops to conserve resources.
|
|
155
|
+
|
|
156
|
+
### Auto-Refresh Modes
|
|
157
|
+
|
|
158
|
+
Agent Tank supports three refresh modes:
|
|
159
|
+
|
|
160
|
+
| Mode | Description |
|
|
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` |
|
|
165
|
+
|
|
166
|
+
### Configuration
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Use activity-based polling (default)
|
|
170
|
+
agent-tank
|
|
171
|
+
|
|
172
|
+
# Use activity mode with custom debounce (wait 10 seconds after activity)
|
|
173
|
+
agent-tank --activity-debounce 10000
|
|
174
|
+
|
|
175
|
+
# Use traditional interval-based polling
|
|
176
|
+
agent-tank --auto-refresh-mode interval
|
|
177
|
+
|
|
178
|
+
# Disable all auto-refresh (manual only)
|
|
179
|
+
agent-tank --auto-refresh-mode none
|
|
180
|
+
|
|
181
|
+
# Via environment variables
|
|
182
|
+
AGENT_TANK_AUTO_REFRESH_MODE=activity agent-tank
|
|
183
|
+
AGENT_TANK_ACTIVITY_DEBOUNCE=10000 agent-tank
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Notes
|
|
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
|
|
194
|
+
|
|
195
|
+
Agent Tank includes an automatic session keepalive feature that prevents LLM CLI sessions from expiring due to inactivity. This is especially useful for Claude and Codex, which have session timeouts that require periodic activity.
|
|
196
|
+
|
|
197
|
+
### How It Works
|
|
198
|
+
|
|
199
|
+
The keepalive manager runs in the background and periodically sends lightweight "ping" commands to each agent's PTY session. This maintains the connection without triggering API calls or affecting rate limits.
|
|
200
|
+
|
|
201
|
+
### Configuration
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
# Use default keepalive (every 5 minutes)
|
|
205
|
+
agent-tank
|
|
206
|
+
|
|
207
|
+
# Custom keepalive interval (every 10 minutes)
|
|
208
|
+
agent-tank --keepalive-interval 600
|
|
209
|
+
|
|
210
|
+
# Disable keepalive
|
|
211
|
+
agent-tank --no-keepalive
|
|
212
|
+
|
|
213
|
+
# Via environment variable
|
|
214
|
+
AGENT_TANK_KEEPALIVE_INTERVAL=600 agent-tank
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Notes
|
|
218
|
+
|
|
219
|
+
- Keepalive is automatically disabled in fresh process mode (`--fresh-process`) since there are no persistent sessions to maintain
|
|
220
|
+
- Keepalive is also disabled in one-shot mode (`--once`)
|
|
221
|
+
- The feature only affects PTY-based sessions; JSON-RPC mode (used by Codex when available) doesn't require keepalive
|
|
222
|
+
|
|
223
|
+
## Usage History & Pace Evaluation
|
|
224
|
+
|
|
225
|
+
Agent Tank automatically tracks usage history and evaluates whether you're burning through your rate limits faster than expected.
|
|
226
|
+
|
|
227
|
+
### Features
|
|
228
|
+
|
|
229
|
+
- **Historical Snapshots**: Usage percentages are stored in `~/.agent-tank/history.json` with timestamps
|
|
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
|
|
236
|
+
|
|
237
|
+
### Configuration
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
# Keep 7 days of history instead of default 14
|
|
241
|
+
agent-tank --history-retention-days 7
|
|
242
|
+
|
|
243
|
+
# Via environment variable
|
|
244
|
+
AGENT_TANK_HISTORY_RETENTION_DAYS=7 agent-tank
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### API Endpoints
|
|
248
|
+
|
|
249
|
+
- `GET /history` - Get history statistics (total records, per-agent counts, date ranges)
|
|
250
|
+
- `GET /history/:agent` - Get full history for a specific agent
|
|
251
|
+
|
|
252
|
+
### Example Pace Evaluation Data
|
|
253
|
+
|
|
254
|
+
When an agent is burning faster than expected, the `paceEval` object is attached to each metric:
|
|
255
|
+
|
|
256
|
+
```json
|
|
257
|
+
{
|
|
258
|
+
"session": {
|
|
259
|
+
"percent": 60,
|
|
260
|
+
"resetsInSeconds": 9000,
|
|
261
|
+
"paceEval": {
|
|
262
|
+
"expectedPercent": 50,
|
|
263
|
+
"isBurningFast": true,
|
|
264
|
+
"etaSeconds": 6000,
|
|
265
|
+
"paceRatio": 1.2,
|
|
266
|
+
"elapsedPercent": 50,
|
|
267
|
+
"deltaPercent": 10
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
This example shows: 50% of the 5-hour session has elapsed, but 60% of usage is consumed. At this pace (1.2x), you'll hit 100% in approximately 6000 seconds (1h 40m).
|
|
274
|
+
|
|
275
|
+
## Installation
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
npm install -g agent-tank
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Or run directly with npx:
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
npx agent-tank
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## HTTP API
|
|
288
|
+
|
|
289
|
+
### Endpoints
|
|
290
|
+
|
|
291
|
+
| Method | Endpoint | Description |
|
|
292
|
+
|--------|----------|-------------|
|
|
293
|
+
| GET | `/` | HTML status page |
|
|
294
|
+
| GET | `/status` | JSON status for all agents |
|
|
295
|
+
| GET | `/status/:agent` | JSON status for specific agent |
|
|
296
|
+
| GET | `/config` | Auto-refresh and history configuration (JSON) |
|
|
297
|
+
| GET | `/history` | Usage history statistics (JSON) |
|
|
298
|
+
| GET | `/history/:agent` | Usage history for specific agent (JSON) |
|
|
299
|
+
| POST | `/refresh` | Refresh all agents |
|
|
300
|
+
| POST | `/refresh/:agent` | Refresh specific agent |
|
|
301
|
+
|
|
302
|
+
### Example Responses
|
|
303
|
+
|
|
304
|
+
#### GET /status
|
|
305
|
+
|
|
306
|
+
```json
|
|
307
|
+
{
|
|
308
|
+
"claude": {
|
|
309
|
+
"name": "claude",
|
|
310
|
+
"usage": {
|
|
311
|
+
"session": {
|
|
312
|
+
"label": "Current session",
|
|
313
|
+
"percent": 42,
|
|
314
|
+
"resetsAt": "10pm (Europe/London)",
|
|
315
|
+
"resetsIn": "12m",
|
|
316
|
+
"resetsInSeconds": 764
|
|
317
|
+
},
|
|
318
|
+
"weeklyAll": {
|
|
319
|
+
"label": "Current week (all models)",
|
|
320
|
+
"percent": 31,
|
|
321
|
+
"resetsAt": "Mar 13, 3am (Europe/London)",
|
|
322
|
+
"resetsIn": "4d 5h",
|
|
323
|
+
"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
|
+
}
|
|
332
|
+
},
|
|
333
|
+
"metadata": {
|
|
334
|
+
"sessionId": "0b34aa59-...",
|
|
335
|
+
"cwd": "/tmp",
|
|
336
|
+
"organization": "Your Organization",
|
|
337
|
+
"email": "user@example.com",
|
|
338
|
+
"version": "2.1.71"
|
|
339
|
+
},
|
|
340
|
+
"lastUpdated": "2026-03-08T21:47:15.090Z",
|
|
341
|
+
"error": null,
|
|
342
|
+
"isRefreshing": false
|
|
343
|
+
},
|
|
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
|
+
"codex": {
|
|
380
|
+
"name": "codex",
|
|
381
|
+
"usage": {
|
|
382
|
+
"fiveHour": {
|
|
383
|
+
"percentLeft": 100,
|
|
384
|
+
"resetsAt": "02:44 on 9 Mar",
|
|
385
|
+
"label": "5h limit",
|
|
386
|
+
"percentUsed": 0,
|
|
387
|
+
"resetsIn": "4h 56m",
|
|
388
|
+
"resetsInSeconds": 17807
|
|
389
|
+
},
|
|
390
|
+
"weekly": {
|
|
391
|
+
"percentLeft": 100,
|
|
392
|
+
"resetsAt": "21:44 on 15 Mar",
|
|
393
|
+
"label": "Weekly limit",
|
|
394
|
+
"percentUsed": 0,
|
|
395
|
+
"resetsIn": "6d 23h",
|
|
396
|
+
"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"
|
|
425
|
+
},
|
|
426
|
+
"metadata": {
|
|
427
|
+
"directory": "/tmp",
|
|
428
|
+
"sessionId": "019ccf68-...",
|
|
429
|
+
"collaborationMode": "Default",
|
|
430
|
+
"model": "gpt-5.3-codex",
|
|
431
|
+
"email": "user@example.com"
|
|
432
|
+
},
|
|
433
|
+
"lastUpdated": "2026-03-08T21:47:12.648Z",
|
|
434
|
+
"error": null,
|
|
435
|
+
"isRefreshing": false
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
#### GET /status/claude
|
|
441
|
+
|
|
442
|
+
```json
|
|
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
|
+
```
|
|
480
|
+
|
|
481
|
+
## Developer & Advanced Setup
|
|
482
|
+
|
|
483
|
+
### Prerequisites
|
|
484
|
+
|
|
485
|
+
#### Build Requirements
|
|
486
|
+
|
|
487
|
+
The `node-pty` dependency requires native compilation. You'll need:
|
|
488
|
+
|
|
489
|
+
- **Python 3.8+** (Python 3.11 recommended)
|
|
490
|
+
- **C++ build tools** (gcc, g++, make)
|
|
491
|
+
- **Node.js development headers**
|
|
492
|
+
|
|
493
|
+
##### Linux (Ubuntu/Debian)
|
|
494
|
+
```bash
|
|
495
|
+
sudo apt-get install python3.11 python3.11-dev build-essential nodejs-dev
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
##### Linux (Fedora/RHEL/CentOS)
|
|
499
|
+
```bash
|
|
500
|
+
sudo dnf install python3.11 python3.11-devel gcc gcc-c++ make nodejs-devel
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
##### Linux (openSUSE)
|
|
504
|
+
```bash
|
|
505
|
+
sudo zypper install python311 python311-devel gcc gcc-c++ make nodejs20-devel
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
##### macOS
|
|
509
|
+
```bash
|
|
510
|
+
# Install Xcode Command Line Tools if not already installed
|
|
511
|
+
xcode-select --install
|
|
512
|
+
|
|
513
|
+
# Install Python 3.11
|
|
514
|
+
brew install python@3.11
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
##### Windows
|
|
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)
|
|
520
|
+
|
|
521
|
+
#### LLM CLI Tools
|
|
522
|
+
|
|
523
|
+
You need at least one of these CLI tools installed and authenticated:
|
|
524
|
+
|
|
525
|
+
- [Claude Code](https://claude.ai/download) (`claude`) - **Version 2.0+ required** for `/usage` command support
|
|
526
|
+
- [Gemini CLI](https://github.com/anthropics/gemini-cli) (`gemini`) - **Version 0.24.5+ required** for `/stats` command support
|
|
527
|
+
- [OpenAI Codex](https://platform.openai.com/docs/codex) (`codex`)
|
|
528
|
+
|
|
529
|
+
**Version Requirements:**
|
|
530
|
+
|
|
531
|
+
**Claude Code:** Version 1.x does not support the `/usage` command.
|
|
532
|
+
```bash
|
|
533
|
+
# Check version
|
|
534
|
+
claude --version
|
|
535
|
+
|
|
536
|
+
# Update to latest
|
|
537
|
+
npm update -g @anthropic-ai/claude-code
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
**Gemini CLI:** Version 0.24.4 and below do not support the `/stats` command properly.
|
|
541
|
+
```bash
|
|
542
|
+
# Check version
|
|
543
|
+
gemini --version
|
|
544
|
+
|
|
545
|
+
# Update to latest
|
|
546
|
+
npm update -g gemini
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
### Programmatic Usage
|
|
550
|
+
|
|
551
|
+
```javascript
|
|
552
|
+
const { AgentTank } = require('agent-tank');
|
|
553
|
+
|
|
554
|
+
const watcher = new AgentTank({
|
|
555
|
+
agents: ['claude', 'gemini'], // or null for auto-discover
|
|
556
|
+
port: 3456,
|
|
557
|
+
autoDiscover: true
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
await watcher.start();
|
|
561
|
+
|
|
562
|
+
// Get status programmatically
|
|
563
|
+
const status = watcher.getStatus();
|
|
564
|
+
console.log(status.claude.usage);
|
|
565
|
+
|
|
566
|
+
// Refresh a specific agent
|
|
567
|
+
await watcher.refreshAgent('claude');
|
|
568
|
+
|
|
569
|
+
// Stop the server
|
|
570
|
+
watcher.stop();
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
### How It Works: Privacy-First Local Execution
|
|
574
|
+
|
|
575
|
+
Agent Tank is designed with privacy and security as core principles. Understanding how it collects usage data is essential for users evaluating the tool's security posture.
|
|
576
|
+
|
|
577
|
+
#### Local Execution Architecture
|
|
578
|
+
|
|
579
|
+
The tool operates entirely on your local machine using two different approaches depending on the CLI tool's capabilities:
|
|
580
|
+
|
|
581
|
+
**JSON-RPC Mode (Codex)**
|
|
582
|
+
|
|
583
|
+
For the Codex CLI, Agent Tank uses a structured JSON-RPC protocol when available:
|
|
584
|
+
|
|
585
|
+
1. **Starts the app-server** - Launches `codex -s read-only -a untrusted app-server`
|
|
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)
|
|
589
|
+
|
|
590
|
+
This approach provides more reliable data parsing and is the preferred method for Codex.
|
|
591
|
+
|
|
592
|
+
**PTY-Based Mode (Claude, Gemini, Codex fallback)**
|
|
593
|
+
|
|
594
|
+
For other CLI tools (and as a fallback for Codex), Agent Tank spawns instances within a pseudo-terminal (PTY). This approach is functionally equivalent to you opening a terminal window and typing commands yourself:
|
|
595
|
+
|
|
596
|
+
1. **Spawns a local PTY** - Creates a pseudo-terminal session on your machine
|
|
597
|
+
2. **Launches the CLI tool** - Starts the authenticated CLI (e.g., `claude`, `gemini`, or `codex`)
|
|
598
|
+
3. **Sends usage commands** - Types the appropriate command (`/usage`, `/stats`, or `/status`)
|
|
599
|
+
4. **Parses the output** - Reads and structures the text response from the terminal
|
|
600
|
+
5. **Exposes via local HTTP** - Makes the parsed data available through a localhost API
|
|
601
|
+
|
|
602
|
+
#### What Agent Tank Does NOT Do
|
|
603
|
+
|
|
604
|
+
To be explicit about what this tool avoids:
|
|
605
|
+
|
|
606
|
+
- **No browser cookie access** - Agent Tank never reads, parses, or transmits browser cookies
|
|
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
|
|
611
|
+
|
|
612
|
+
#### Why This Approach?
|
|
613
|
+
|
|
614
|
+
LLM usage data is sensitive—it can reveal work patterns, subscription tiers, and usage intensity. By operating through local CLI tools that you've already authenticated, Agent Tank inherits the security model you've already established with each provider. The tool acts as a local automation layer, not a data collection service.
|
|
615
|
+
|
|
616
|
+
#### Supported Commands
|
|
617
|
+
|
|
618
|
+
| Agent | Method | Command/RPC | Output |
|
|
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 % |
|
|
624
|
+
|
|
625
|
+
## Troubleshooting
|
|
626
|
+
|
|
627
|
+
### Installation fails with "gyp ERR!"
|
|
628
|
+
|
|
629
|
+
This indicates missing build dependencies. Make sure you have:
|
|
630
|
+
|
|
631
|
+
1. **Python 3.8+**: Check with `python3 --version`. If you have multiple Python versions, set the PYTHON environment variable:
|
|
632
|
+
```bash
|
|
633
|
+
PYTHON=/usr/bin/python3.11 npm install
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
2. **Build tools**: Install gcc, g++, and make for your platform (see Prerequisites above)
|
|
637
|
+
|
|
638
|
+
3. **Node.js headers**: Install the nodejs-devel or nodejs-dev package for your distribution
|
|
639
|
+
|
|
640
|
+
If you still have issues, try rebuilding:
|
|
641
|
+
```bash
|
|
642
|
+
npm run rebuild
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
### Agent shows "Timeout waiting for usage data"
|
|
646
|
+
|
|
647
|
+
- Ensure the CLI tool is properly authenticated
|
|
648
|
+
- Try running the CLI tool manually to verify it works
|
|
649
|
+
- Check if there are any prompts requiring user input
|
|
650
|
+
|
|
651
|
+
### Codex fails with cursor position error
|
|
652
|
+
|
|
653
|
+
This is handled automatically. If you still see issues, ensure your terminal supports standard escape sequences.
|
|
654
|
+
|
|
655
|
+
### Port already in use
|
|
656
|
+
|
|
657
|
+
```bash
|
|
658
|
+
agent-tank --port 8080
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
## Community
|
|
662
|
+
|
|
663
|
+
[r/agenttank](https://www.reddit.com/r/agenttank)
|
|
664
|
+
|
|
665
|
+
## Author
|
|
666
|
+
|
|
667
|
+
[Rinalds Uzkalns](https://propr.dev)
|
|
668
|
+
|
|
669
|
+
## License
|
|
670
|
+
|
|
671
|
+
MIT
|
|
672
|
+
|
|
673
|
+
## Contributing
|
|
674
|
+
|
|
675
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|