@mauricode/token-derby 3.1.2 → 4.0.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/README.md CHANGED
@@ -74,11 +74,15 @@ Nothing here asks you to hold work back. A flat-out day still beats a lazy one
74
74
 
75
75
  Stamina is off by default; org owners turn it on and tune it from the Race Settings tab of `token-derby web`. When it's on, the live view shows your horse's stamina as a percentage and bar, plus a multiplier once you're actually losing score to fatigue.
76
76
 
77
- ## Other models (Codex, Gemini)
77
+ ## Other coding agents (Codex CLI, Gemini CLI)
78
78
 
79
- At join you pick one **primary** model Claude, Codex, or Gemini counted 1:1.
80
- The other two count at **10%**. The choice is locked for the whole race and can't
81
- be changed, even by rejoining.
79
+ Every token is worth the same wherever it came from, so you can use one tool or
80
+ all three and nothing needs choosing at join.
81
+
82
+ Tokens are counted per **model family** — Anthropic, OpenAI or Google — rather
83
+ than per tool. The two are usually the same thing today, since each tool runs one
84
+ vendor's models, but they are tracked separately so a tool that can run several
85
+ vendors' models counts each one correctly.
82
86
 
83
87
  - **Codex CLI** — counted from `~/.codex/sessions/**/rollout-*.jsonl` (and
84
88
  `archived_sessions/`). Fresh input = `input_tokens − cached_input_tokens`;
@@ -87,8 +91,37 @@ be changed, even by rejoining.
87
91
  - **Gemini CLI** — counted from `~/.gemini/tmp/<project>/chats/session-*.jsonl`.
88
92
  Fresh input = `input − cached`; output = `output` (thoughts included).
89
93
 
90
- Pick at join with `token-derby join <code> --primary codex` (or the interactive
91
- picker). Overrides: `TOKEN_DERBY_CODEX_DIR`, `TOKEN_DERBY_GEMINI_DIR`.
94
+ A tool you've never run simply contributes nothing no configuration needed.
95
+ Overrides: `TOKEN_DERBY_CODEX_DIR`, `TOKEN_DERBY_GEMINI_DIR`.
96
+
97
+ - **Pi** — counted from `~/.pi/agent/sessions/**/*.jsonl`, and **off until you
98
+ turn it on**: `token-derby harness enable pi`.
99
+
100
+ Pi is the one agent that can run models from several vendors, so its tokens
101
+ are attributed to whichever vendor actually produced them — a Pi session that
102
+ starts on Claude and switches to GPT counts as both. Fresh input is uncached
103
+ input plus cache writes; cache reads are excluded, as everywhere else.
104
+
105
+ Usage on a provider outside those three is not counted, and the race view says
106
+ so rather than leaving you to wonder. That includes gateways such as Bedrock,
107
+ OpenRouter and Cloudflare: they can serve models we score, but their model ids
108
+ do not reliably say which vendor is behind them, so we decline to guess.
109
+
110
+ ### Choosing what gets counted
111
+
112
+ ```
113
+ token-derby harness list # what this machine counts, and what it found
114
+ token-derby harness disable codex-cli # stop counting one
115
+ token-derby harness enable codex-cli # start counting it again
116
+ ```
117
+
118
+ A disabled agent is not scanned at all, which is also the way to keep a very
119
+ large history from eating into the per-beat scan budget. Changes take effect on
120
+ your next heartbeat — no need to rejoin — and the race view marks anything
121
+ turned off, so it is never a mystery why work is not counting.
122
+
123
+ Nothing is lost by turning one off mid-race: your totals hold where they are and
124
+ catch up when you turn it back on.
92
125
 
93
126
  All of this counts **real** tokens you actually generated. Please don't point it
94
127
  at usage you didn't produce.
@@ -97,6 +130,35 @@ at usage you didn't produce.
97
130
 
98
131
  - `~/.token-derby/stable.json` — saved horses
99
132
  - `~/.token-derby/active-races/<join-code>.json` — per-race state for rejoin
133
+ - `~/.token-derby/logs/token-derby.log` — debug log (see below)
134
+
135
+ ## Debug log
136
+
137
+ Every command appends to a rolling log, so a race that stalls overnight can be
138
+ diagnosed afterwards. The race UI takes over the terminal, which is exactly when
139
+ nothing can be printed to the screen.
140
+
141
+ ```bash
142
+ token-derby logs # print the path of the log file
143
+ token-derby logs --tail 100 # print the last 100 lines (default 50)
144
+ ```
145
+
146
+ The log rolls at 2MB and keeps five files (`token-derby.log` plus `.1`–`.4`), so
147
+ it never exceeds ~10MB. Each environment has its own, next to that environment's
148
+ identity.
149
+
150
+ What the lines mean when a race misbehaves:
151
+
152
+ - `beat.prepare.start` with no `beat.prepare.done` after it — the token scan
153
+ hung, and the poller is still waiting on it.
154
+ - repeated `beat.send.err` with a climbing `next_ms` — the heartbeat is
155
+ reaching the network and failing; `retry` counts the attempts.
156
+ - `scan.timeout` — the scan blew its budget; `reason` names the source that was
157
+ still running.
158
+
159
+ Credentials are never written: identity and horse tokens, request headers and
160
+ bodies are all omitted, and claim tokens and admin codes are masked out of the
161
+ URLs they travel in.
100
162
 
101
163
  ## Environment
102
164
 
@@ -107,5 +169,4 @@ at usage you didn't produce.
107
169
 
108
170
  Token Derby counts usage from this machine's filesystem only. If Claude Code runs
109
171
  in a container, over SSH, or on another machine, join the race from there — `join`
110
- warns before entering a race whose primary model has no transcripts to read.
111
- - **Top-5 conversations (primary):** a race can be created so that only each racer's **5 most-active conversations per heartbeat** count toward their **primary** model's score (secondaries unaffected). The race creator opts in at `token-derby create` (prompt) or, for organisation-scheduled races, via the "Primary top-5 cap" option on the schedule tab of `token-derby web`. Off by default (every conversation counts).
172
+ warns before entering a race when none of the three tools has transcripts to read.