* feat(claude): attribute usage to the account that was active
* fix(claude): identify by organization and keep the identity field under a filter
* test(claude): check the log file mode on POSIX only
With only the desktop app installed from the Homebrew cask, the menu bar
failed to load Today with "nonZeroExit (code: 127, stderr: env: codeburn:
No such file or directory)". The menu bar looked for a codeburn in the
path recorded for it and in package-manager folders, then fell back to the
bare name. A desktop-only machine has nothing in those folders, so when the
record was missing or no longer ran, nothing was found and the error named
nothing.
The packaged desktop app now carries a plain launcher at
CodeBurn.app/Contents/Resources/cli/codeburn that runs its bundled CLI
through its own executable and finds its own bundle. The menu bar checks
it, in /Applications and ~/Applications, after the recorded path and the
package-manager folders. When none of them runs, Today says which paths
were tried. The CLI's menubar installer records the same launcher instead
of refusing the install when nothing named codeburn is on PATH.
* feat(optimize): flag an autoCompactWindow that blocks idle compaction
* fix(optimize): render a finding without a dollar figure cleanly and gate the idle-compaction rule on the one-hour cache
* fix(optimize): group headers without a figure when the group has none
* feat(sessions): mark sessions kept after their transcript was deleted
When a write refresh keeps a cached session whose source file is gone
(a Claude session with PR links, or a copilot or quickdesk entry inside
its 90-day window), the cache entry now records retainedSince, the local
date of the first refresh that found the file missing. It is set once and
kept on later refreshes. Offline WSL roots are not deletions and stay
unmarked.
Sessions served from such an entry carry retained.since. The sessions
JSON rows include it, the sessions table puts * after the start time with
a legend line, and the export adds a last retained column to records and
sessions in JSON and CSV. The desktop Sessions list and drawer show a
muted note naming the tool and the date.
Behaviour does not change: the same entries are kept and evicted, and
every total and the by-PR numbers are unchanged. The field is optional,
so the cache version stays.
* fix(sessions): say when the transcript was found missing, not deleted
The desktop note, the sessions table legend, the export readme and the docs no longer give a deletion date. retainedSince is the day CodeBurn first found the transcript missing, so the note now reads that the transcript has been missing since that date.
* fix(export): give the JSON export stable keys
The JSON export reused the CSV row builders, so its keys were display
headers with spaces and parentheses, and the money keys changed name
with the configured currency. A program had to reshape the file before
it could read it.
The builders now produce one camelCase row, and a single key to header
map writes the CSV, so every CSV header line stays byte-identical. The
JSON schema moves to codeburn.export.v3; the currency is stated once in
currency.code and the money values stay converted to it.
Before (v2, EUR):
{"Period":"7 Days","Date":"2026-11-02","Cost (EUR)":1.1,"Saved (EUR)":0,"API Calls":1,"Sessions":1,"Input Tokens":100000,"Output Tokens":50000,"Cache Read Tokens":200000,"Cache Write Tokens":30000,"costBasis":{"calculated":1}}
After (v3, EUR):
{"period":"7 Days","date":"2026-11-02","cost":1.1,"saved":0,"apiCalls":1,"sessions":1,"inputTokens":100000,"outputTokens":50000,"cacheReadTokens":200000,"cacheWriteTokens":30000,"costBasis":{"calculated":1}}
v2 consumers must rename keys. New keys can still appear under v3.
* docs: changelog entry for the v3 export JSON
* test: read the v3 export keys
Every served call now carries a costBasis: recorded when the tool wrote
its own figure, calculated when CodeBurn priced measured tokens,
estimated when the tokens or price are a guess, included when a
subscription covered it at $0, and unpriced when the model has no known
price. It is derived from fields the cache already stores, so no parse
or cache version moves.
The export JSON gives each record its basis and gives sessions and days
the share of cost from recorded, calculated and estimated; records.csv
gets the column. sessions --format json, the menubar payload and MCP
get_usage carry the same shares. Sync now sets ai.cost_estimated from
the basis instead of guessing from the provider name.
* fix(optimize): price findings from the calls they point at
Every finding's dollar figure was its token estimate times one blended
rate: 70% of the period's spend over all input-side tokens. That rate is
close to a cache-read price, so it misprices anything that is not a cache
read. Schema findings already weight cache reads at 0.1, so their reads
were discounted twice; findings whose tokens include output were priced
as input.
A finding can now carry savingsUSD, computed from the calls it names.
Every surface reads it through findingUSD: the CLI and TUI optimize
views, the JSON report (and so the desktop Optimize page), the menubar
payload and MCP get_savings, and the --apply list. classTotals sums it,
scaled to the apply-able share for fix findings. Findings without it keep
tokensSaved times the blended rate, and any token whose session or model
has no price still falls back to that rate.
Measured now:
- low-worth-sessions: each session's real cost times its recovery fraction
- retry-heavy-capabilities: the retry turns' real cost times the fraction
- redundant-rereads, build-folder-reads: the reads at the input rate of
their session's most-called model
- warmup-heavy: the excess cache writes at the session model's write rate
- mcp-low-coverage, mcp-project-scope: each call's charged schema tokens
at that call model's cache-write or cache-read rate
- unused-mcp, mcp-deferral-off, mcp-alwaysload-hygiene,
mcp-defer-threshold: the per-session schema at the input rate of the
sessions charged
Still on the blended rate, because no calls can be named: read-edit-ratio
(reads that never happened), context-heavy-sessions, cost-outliers,
low-cache-hit-sessions, claude-md-too-long, bash-output-cap,
recurring-context and the unused agents, skills and commands.
* feat(optimize): flag one-hour cache writes the next request never needed
A one-hour prompt-cache write is billed at 1.6 times the five-minute
rate and only earns that back when the same model's cache is next used
after a pause of more than five minutes but less than an hour. Reads
refresh either TTL, so a write is judged by the first such pause after
it, not just by the very next call.
The new one-hour-cache-unused nudge walks each session per model in
time order, prices the 60% premium on every one-hour write that never
reached such a pause from the call's own model and tier, and fires at
one dollar or more. Unpriced models and five-minute writes add nothing.
* test(optimize): pin one-hour writes that later hits kept warm
Every cache hit refreshes the TTL, so a one-hour write followed by more
than an hour of steady activity and then a twenty-minute pause still
needed the hour. The detector already judges the length of the first
pause over five minutes, not its distance from the write; this test
pins that. A pause that itself runs past the hour still counts as
wasted, because the one-hour entry expires inside it either way.
Also lists one-hour-cache-unused among the measured findings.
* feat(guard): warn and stop identical-call loops and failing-command retries
The PreToolUse hook now watches two more signals next to the dollar caps.
The same tool called with the same input (hashed as JSON with sorted keys)
4 times in a row gets a one-time warning and the 8th call is denied. A shell
command (Bash or PowerShell) that already failed 3 times in the session gets
a one-time warning and is denied once it has failed 5 times; successful runs
do not reset the count. Both pairs are guard.json settings (loopWarnAfter,
loopStopAfter, retryWarnAfter, retryStopAfter), validated like the dollar
caps, null turns one off, and guard status prints them.
The incoming call is read from the hook payload and recorded by tool_use_id,
since the transcript can lag. The session cache (version 4) keeps a rolling
window of the last 16 calls, pending shell calls and failure counts per
command, folded from the same incremental tail read as the cost. When a loop
or retry warning fired, the Stop note adds one line with the count and what
the calls after the first warning cost.
On a generated 20 MB transcript the warm hook takes about 13 ms (median of 5);
the first cold read of the whole file takes about 480 ms, as before.
* fix(guard): let allow lift loop blocks and tell the agent at the warning
codeburn guard allow now lifts the loop and retry stops as well as the hard
cap, for that session only, so polling a CI job on purpose has the same way
out. The deny reasons name it.
Loop and retry warnings now also reach the agent through PreToolUse
additionalContext, with the same sentence plus "Change approach or ask the
user." It is sent without a permissionDecision, since "allow" would also
skip the user's permission prompt. The docs now say the loop count tops out
at 17 (16 earlier calls plus the incoming one).
* chore: drop the no-zstd fallbacks the 22.15 floor made unreachable
The dsh, zed and openclaw providers still guarded against a Node whose
node:zlib has no zstd. The floor is 22.15 now, so they call
zlib.zstdDecompressSync directly like the shared helpers do. The tests that
exercised the missing-zstd path and the guards that skipped zstd cases on old
Nodes are gone.
* docs: state the 22.15 zstd floor plainly and name the tools degraded mode cannot read
* chore: raise the Node floor to 22.15 and make zstd unconditional
Node's built-in zstd in node:zlib arrived in 22.15. With the floor at 22.13
every reader of Codex's compressed .jsonl.zst rollouts had to check for it,
and the daily cache kept a separate generation for Nodes without it so a later
Node upgrade would still re-derive their days. That split could not survive
another cache bump.
The engines field, the launcher's version check, .nvmrc, the README and the
CI pins now say 22.15. The VS Code extension applies the same floor when it
picks a Node to run the CLI, and its runtime notice names it.
Removed: the optional zstd exports, zstdSupported and requireZstd in
fs-utils, the skipped-compressed-rollouts notice in launcher-homes, and the
76/77 split in the daily cache, which is now 77 for every Node.
* docs: say 22.15 wherever the Node floor is stated
codeburn web only answers to loopback Host and Origin values, which makes it unreachable behind a reverse proxy even when that proxy authenticates (oauth2-proxy, Authelia, Traefik with Keycloak). A repeatable --allowed-host flag adds exact hostnames to the guard, matched case-insensitively and without the port, against both Host and Origin. Without the flag nothing changes.
The guard lives in two exported helpers, isAllowedHost and isAllowedOrigin, with unit tests for the loopback default, exact matching (dash.example.org.evil.example and evil-dash.example.org are refused), Origin limited to http and https, and null refused, plus server tests for a proxied Host and allowed and refused Origins. docs/web.md gains a section on running behind a reverse proxy.
The --host flag from the original proposal is dropped. The dashboard has no authentication, so a non-loopback bind would give any LAN client that sends Host: localhost every route, the share and pairing POSTs included. The bind stays on 127.0.0.1; a proxy on the same machine forwards to it and its Host and Origin pass the guard. Access control is the proxy's job and the docs say so.
Authored by @MarcelRoozekrans. Reviewed and tested locally against real data; the maintainer commit on top removes --host.
Codex writes native web_search_call, tool_search_call and image_generation_call items, and newer builds record a completed WebSearch item as type Extension with kind web.search. None of these counted as tool activity, so Codex sessions showed shell calls but no searches. They are now attributed as WebSearch, ToolSearch and ImageGeneration, with stable item identities deduplicated across status updates, mirrors, append checkpoints and fork replay, so a fork keeps its own new activity and never double counts the parent's.
Three maintainer commits sit on top. Codex builds of May 2026 write every search twice in a row, an item_completed WebSearch with its id and then a web_search_call with no id, so an id-less web_search_call directly after a WebSearch item is treated as that item. The depth-1 payload type scan now runs only for lines whose first payload type names a native tool or item_completed, which keeps the cold parse of compacted history from slowing by a fifth. The daily cache version is left alone: native tool items change which activity a turn lands in, never its calls, tokens or cost, and the Codex results file version already re-parses every session once; settled days pick up the new split at the next DAILY_CACHE_VERSION bump, which is reserved for the Node 22.15 floor.
Verified on a real session: usage, tokens and cost identical before and after, one WebSearch where there was none.
Authored by @uttamdeb.
Cursor 3.27 can store its app session as cursor-safe-storage:v1 ciphertext
(Chromium v10, key in the "Cursor Safe Storage" keychain item), behind
Cursor's own cursor.storage.authTokenEncryptionAtRest flag. CodeBurn read it
as an expired login. The CLI and the menu bar now unlock it with that item
and run the usual JWT checks; the newline `security -w` appends is trimmed
before the KDF.
Keychain consent is user-initiated, as for Claude: the first read happens on
`codeburn import cursor --sync`, `codeburn quota`, or Retry/Reconnect on the
menu bar's Cursor quota. Background syncs and dock refreshes read only after
one such read succeeded, reuse the opened token per blob, and the first
refused read switches that off again. Status never reads the keychain. No
service-only keychain lookup, since after a Deny it asks again.
Windows and Linux say CodeBurn cannot unlock the session there yet; the
desktop app, VS Code and the Windows tray show the new `locked` line in all
locales. Docs describe the prompt and what Always Allow grants.
Closes#1801
* Copilot: count every agent round and exact credits in VS Code chat sessions
Copilot Chat 0.69 keeps only the last model call of an agent request in result.metadata. Read the request's modelTotals (input, cache reads, output over every call) first, then root completionTokens, then metadata. Carry copilotCredits as nanoAiu so plan credits are exact. Bump the copilot parse tag so cached chat sessions re-parse.
modelKeyMatches no longer lets claude-sonnet-4 capture claude-sonnet-4-6.
* Copilot: bill chat-session credits exactly and skip agent-host twins
A chat-session request that records copilotCredits now costs credits x $0.01 through costFromBilling; requests without it stay priced from tokens. A chat session whose id matches a session-state dir is left to the agent-host path so it is counted once.
* Copilot: drop agent-host twins at serve time, rate chat requests one by one, re-derive past days
A chat-session journal request is left out when the same session has billed agent-host usage (session-state calls with tokens or nanoAiu, or session-store rows). Plan credits rate chat-session requests individually, so older requests in a mixed session keep their estimate. DAILY_CACHE_VERSION 75 with copilot pending re-derive so settled days pick up the new counts.
* fix(cursor-agent): leave Cursor IDE chat transcripts to the cursor provider
Cursor IDE agent chats write agent transcripts too, so on days without a
Cursor import they were counted by both cursor (state.vscdb) and
cursor-agent. Discovery now skips a transcript or store whose id is an IDE
composerData key; cursor keeps them with per-bubble times and models.
Daily cache v73 lets cursor-agent days shrink once.
* fix(cache): drop old cursor-agent slices the IDE parse now explains
On an existing cache, settled days kept their old cursor-agent slice after
v73 because the fresh parse no longer has one there and the merge carries
missing slices forward. While cursor-agent is pending its v73 re-derive, a
day the fresh parse explains with a cursor slice and no cursor-agent slice
drops the old cursor-agent slice; days with no fresh cursor slice keep it.
* feat: Google AI plan presets and the Antigravity tier label (#1614)
Plan presets google-ai-pro, google-ai-ultra-5x and google-ai-ultra-20x
at Google's US monthly prices, scoped to Antigravity usage.
The Antigravity quota readers (CLI, desktop, menu bar) now also ask
GetUserStatus when the summary answers and label the windows with
userTier.name. planStatus.planInfo is not used: it says Pro on a free
tier account.
* docs: Antigravity probe comments and README preset list
* refactor(app): move the bridge handlers out of main.ts
createBridgeHandlers and the argv builders now live in
app/electron/bridge-handlers.ts with no electron import, so a host other
than Electron can run the same channel to argv mapping. main.ts keeps its
default deps and re-exports, so the desktop app and its tests are unchanged.
Two additive hooks for that host: scopeProjectFilter narrows the saved
project filter before it becomes argv, and CODEBURN_NODE_BIN runs the
bundled CLI with a named Node instead of Electron-as-Node.
* feat(app): let the renderer run inside an editor
The bridge can now say it is the VS Code host. When it does, the chord
shortcuts and their hints step aside for the editor's own, Settings hands
theme, language, default period and refresh to the editor's settings,
the top bar shows a this workspace / all projects switch, and the editor
can send a section, a period or a refresh to an open dashboard.
formatResetTime moves to lib/format.ts so the status bar and the summary
use the Plans wording. New strings are in all six locales. Nothing
changes in the desktop app.
* feat(app): build the renderer for VS Code webviews
app/vite.vscode.config.ts builds two webview entries into
vscode/dist/webview: the whole dashboard and the activity bar summary.
renderer/vscode/bridge.ts implements window.codeburn over postMessage,
forwarding only the channels in channels.ts; telemetry, update checks and
the desktop companions are answered in the webview. localStorage is
prefixed per scope so one workspace's cached views never paint in
another's, and the theme follows the editor's light, dark and high
contrast kinds through its --vscode-* tokens.
* feat(vscode): CodeBurn extension for VS Code and its forks
A status bar item with today's spend (~ when estimated) and a tooltip
with the week, the month, this workspace, the top model and plan quotas;
an activity bar summary; the desktop dashboard in an editor tab, scoped
to the open workspace; eight commands and eight settings.
The bundled CLI runs as the desktop's resident serve child through the
shared client. Current VS Code, Cursor and Antigravity ship Node 24, so
it runs on the editor's own Node; an older editor gets a system Node
22.13+ or a degraded run that says what it cannot read. A workspace
folder maps to a rooted --project the way the CLI keys sessions,
worktrees folding into their main repository.
npm run package:vscode builds the .vsix. Unit tests cover the bridge
host, status bar formatting, workspace mapping, settings and runtime
choice; test:smoke drives a real VS Code against a fixture home.
* ci, docs: build, test and package the VS Code extension
A vscode job typechecks, unit tests, packages the .vsix, runs the smoke
test in VS Code under xvfb and uploads the .vsix. docs/vscode.md covers
the architecture, the measured editor runtimes and how to test.
* fix(vscode): keep the currency setting out of workspace settings
Changing codeburn.currency runs the CLI's own currency command, which
every CodeBurn app shares, so a repository's .vscode/settings.json must
not be able to set it: the setting is application scoped now.
The smoke test also checks that the dashboard's renderer booted inside
the webview and called the host, not only that its tab opened.
* feat(vscode): version the extension 1.0.0, apart from the CLI
The extension carried the CLI's 0.9.25. It now has its own version,
1.0.0. The host passes it to the webview, and the dashboard's nav
footer, About dialog and Settings show it there instead of the
renderer's package version; Settings adds "Bundled CLI 0.9.25" beneath
it. The desktop app is unchanged. Nothing in the build or packaging
writes the extension's version from the CLI.
* fix(vscode): run the smoke test in Cursor, keep the demo shim out
Cursor 3 opens its Agents window on a fresh profile, which starts no
extension host, so the smoke run against Cursor.app hung; it now passes
--classic for Cursor. The webview build no longer copies
renderer/public/demo-shim.js, a browser demo harness, into the .vsix.
* feat(vscode): a quiet star line in the summary, and a Star on GitHub command
From the third day of use, the activity bar summary ends with the
desktop's "Enjoying CodeBurn? Star us on GitHub" line, in the same six
languages, with a close button. Clicking it or closing it hides it for
good (kept in the extension's globalState). It is never a notification.
The new "CodeBurn: Star on GitHub" command opens the repository page.
No tracking parameters, no telemetry.
* docs(vscode): marketplace screenshots in the README
Five screenshots of the extension on real data (Overview in dark and
light, the why it cost view, the status bar hover and the activity bar
summary), 1600 px wide, each with a one-line caption. They live in
vscode/media/screenshots, stay out of the .vsix, and the package script
points vsce at the raw GitHub URLs on main.
* fix(vscode): review fixes for settings trust, serve lifecycle and the tooltip
- codeburn.provider and codeburn.quotaProviders are application scoped,
like currency, so a repository's settings cannot turn quota requests
back on, even in Restricted Mode.
- deactivate removes the serve pid file once the child is stopped, and
changing codeburn.nodePath restarts the serve child on the new Node.
- codeburn.currency is applied at startup when the CLI's currency
differs, not only when the setting changes.
- The dashboard's Settings no longer shows per-plan quota switches in the
editor, where the editor setting rewrites them on every boot; it points
to the editor settings instead.
- Workspace and model names are escaped in the status bar tooltip.
- The README lists the dashboard actions that reach the network.
- The staged CLI drops its dependencies' tests and TypeScript sources
(466 files, 9.9 MB to 9.2 MB).
* feat: Command Code support
Reads the cmd CLI's session transcripts at
~/.commandcode/projects/<slug>/<id>.jsonl (CODEBURN_COMMANDCODE_DIR moves
the root). Checkpoint and prompt sidecars are skipped.
usage.inputTokens includes cacheReadTokens, so fresh input is
inputTokens - cacheReadTokens. The recorded costUsd is kept per call
(costFromBilling); a call without one is priced from tokens and marked
estimated. Forks copy parent message ids into a new file, so calls dedupe
by message id across sessions.
Desktop: Electron sandbox read path, macOS and Windows change watchers,
Windows tab colour. No quota adapter.
* fix(command-code): dedupe on meta.messageId, not the 8-hex line id
The top-level id is randomUUID().slice(0, 8) and only unique within one
file, so calls from unrelated sessions could collide and vanish.
meta.messageId is a full uuid that survives forks. Fixture ids now use
the real 8-hex shape.
* test(command-code): check sidecar skipping by file name, not a posix path
* Restore usage from Mistral Vibe Unified Harness sessions
* fix(mistral-vibe): read unpinned Vibe 2.26 unified sessions exactly
An unpinned session has session_metadata.active_model null, so the parser
dropped it entirely. Fall back to config.toml's active_model, then Vibe's
default mistral-medium-3.5.
Split the rotated journal prefix into as many calls as runtime state lists
completions, so call counts match. Drop the tool group prefix from history
names (file_system.bash) and attach a turn's tools to its first call only.
Re-derive settled days (DAILY_CACHE_VERSION 58). Adds a redacted fixture from
a real 2.26.0 session.
---------
Co-authored-by: Resham Joshi <65915470+iamtoruk@users.noreply.github.com>
* fix(antigravity): count cache reads and price the standalone app's model
The standalone Antigravity app (2.19) stores usage as ModelUsageStats in
gen_metadata. Field 5 (cache_read_tokens) was never read, on the SQLite
path or the RPC path, so every cached prompt token was dropped. Fields 9
and 10 are thinking and response output, the reverse of what the SQLite
path assumed. The rows carry only MODEL_PLACEHOLDER_M16 and
"gemini-pro-default", so the model priced at $0.
Read cache read (and cache write) in both paths, read 9/10 in the right
order, drop the input fallback to field 1 (the model enum), and map the
placeholders seen in the app's own model catalog, flagged as estimated.
Bump the antigravity results cache, its parse version and the daily cache.
* fix(antigravity): keep .pb history across the cache bump, step times, 200k tier
With the results cache at v8 and Antigravity closed, .pb cascades had no
entry and no server, so they vanished until the app was next opened.
Serve the v7 entry meanwhile, stored with mtimeMs -1, and preload the
results cache so the session cache reparses such sources and the next run
with the server up re-fetches them with cache reads.
Standalone .db rows without created_at take their first step's time
(steps.metadata #1), which equals created_at wherever both exist, instead
of the file mtime.
Price antigravity at the Gemini long-context tier: add it to
TIERED_PRICING_PROVIDERS and pass the provider at both calculateCost sites.
Cursor Agent transcripts dated every turn at the session's last write. A
synced usage export ends its coverage at its newest billed event, so a
session that started before it and finished after it kept all its local
estimates on top of the billed rows. Date transcript turns by their
prompt's <timestamp> tag instead, like store.db turns already are. On a
real account this removed 101 double-counted calls on the last synced day,
and 2,748 of the 2,767 calls stamped on 22 Sep moved back to 17-20 Sep,
where Cursor billed them.
Synced plan rows carry no dollars (Included, Free), and Auto and Grok Bot
rows never name the model that served them, so their list price is a
stand-in: mark them costIsEstimated. Named models stay exact.
Daily cache to v58; cursor-agent joins PENDING_REDERIVE at 58 since a day's
call count can drop when turns move to their prompt day.
Session-store rows carried output only for compaction requests; every
other request's output was left to the per-turn assistant.message or the
shutdown rollup residual. CLI 1.0.8x and ACP hosts (JetBrains AI Chat via
copilot --acp) write no per-turn output, and an ACP session usually ends
without session.shutdown, so its whole output was lost. Rows now carry
their own output_tokens; at serve time a row that pairs with a per-turn
call carrying output (older CLIs) serves with output 0, so output counts
once in every shape.
grok-4.6 priced at $1.25/M input: LiteLLM has no bare grok-4.6 row and
the stripped azure_ai/grok-4.6 row claims the bare id ahead of
xai/grok-4.6, in the bundler and the live fetch alike. A builtin price
pins xAI's list rate ($2/$6/$0.50 per M), which is what GitHub bills.
On real data every Copilot model's cost now equals GitHub's
total_nano_aiu to the digit.
* fix(copilot): count VS Code agent-host requests and their output
VS Code now runs Copilot's agent through the Copilot CLI engine. Its
assistant.message events carry no outputTokens (CLI 1.0.8x writes the same
shape), so every request was skipped and the shutdown rollup, which assumed
per-turn events own output, dropped it: 0 calls and 0 output.
Tokenless messages now count as calls with zero tokens, and a leg with no
per-turn output takes its output from the rollup. The rollup also carries
modelMetrics totalNanoAiu, so the session's credits are exact. Tokens and
credits appear when the session ends.
* test(copilot): serve an open agent-host session
* fix(copilot): serve store-session output via the residual, count credit requests
CLI 1.0.8x sessions with session-store rows lost their output: the rows
replace the rollup and carry output only for compaction requests. The
per-leg residual now carries rollup output minus compaction-row output.
The credits note counted store rows, rollups and per-turn twins as separate
requests. It now counts requests by behavioral weight, rated when the
session carries an exact figure.
* fix(copilot): keep paired store-row credits, running nanoAiu delta
A behavioral store row (compaction or crash tail) made the credit sum drop
every paired row. Store rows now always count; a rollup counts only when
nothing behavioral carries nanoAiu.
totalNanoAiu is a running bill that does not reset at compaction, so its
per-leg delta uses its own sentinel instead of the token reset.
copilot's PENDING_REDERIVE contract moves to 56: a store row and its
message straddling midnight can move one call to the next day.
* feat(cursor): show the cursor.com sync in the apps, with an off switch
status --format menubar-json gains an additive cursorSync block (enabled,
state, lastSuccessAt, and a fixed errorCode/error on failure), read from
the sync sidecar, the config and the Cursor app's login. It never syncs,
never makes a request and never carries the token, the account hash or
server text. It is absent when Cursor is not signed in and has never
synced, and it is attached after the snapshot and per-device payloads.
With the Cursor provider selected, the desktop overview, the macOS menu
bar and the Windows tray show one line under the total: "Synced from
cursor.com 12 min ago", or the error in a muted warning colour. A
"Sync Cursor usage from cursor.com" switch writes config cursorSync:
Settings > Providers > Cursor on the desktop, the Cursor settings pane
on macOS and Windows. Desktop and mac strings are in all six locales;
the tray stays English until its localization lands.
* fix(cursor): guard config writes, show the env override in the switches
The tray's shared config writer now refuses to write over a config.json
that does not parse or is not an object (it used to replace it with an
empty map plus the one key), which also protects the currency, budget
and Claude config directory writers. The desktop writer rejects null
and array configs the same way.
With CODEBURN_CURSOR_SYNC=0 set, the desktop, mac and tray switches show
"Turned off by CODEBURN_CURSOR_SYNC=0" and are disabled. A failed mac
save now says so under the switch. The tray hero note uses the warning
ink and maps errorCode to its own messages.
* Sync Cursor usage from cursor.com automatically (#1545)
Reports that show Cursor dollars download the account's own usage export
with the Cursor app's session, at most every 15 minutes, and merge it into
the Cursor import store as source-tagged events. Manual CSV imports are
never replaced; synced rows dedupe against them by hash. codeburn import
cursor --sync forces one. Off with cursorSync: false or
CODEBURN_CURSOR_SYNC=0.
* Cursor sync: hourly with jitter, keep every account's history
The throttle is now an hour plus up to 5 minutes of jitter, and three
failed requests in a row back off 6 hours. After the first month, a sync
starts at the day of the newest synced event, and a quiet account
remembers that it synced, so closed days are downloaded once.
Synced rows and ranges carry the hashed account. An account change no
longer drops the earlier account's rows; the new account's window starts
after their coverage. A closed synced day stays in the daily cache when
a later sync fails or the store goes missing.
* Cursor sync: longer first backfill, safer merges, provider gate
The month-long first backfill gets 45s (it took 11-12.5s on a real
account and could hit the old 15s cap); incrementals keep 15s. The sync
heartbeats through the download for the app watchdogs. An incremental
starts the day before the newest synced event so late rows land, and
rows from before the window are ignored instead of failing the sync.
A manual import of a row a sync stored first turns it into a manual
row, so a later sync can never delete what manual coverage relies on.
The sidecar records the account only after the request. Commands
filtered to a non-Cursor provider no longer sync.
* Cursor sync: manual coverage wins inside its range
A sync skips rows dated inside a manual import's coverage, so a row
Cursor revised there is not priced twice. Rows after the manual
coverage end still land.
* Read DSH session format v4 written by dsh 0.2.0-rc.2
dsh 0.2.0-rc.2 stamps every session log v4, so discovery skipped each one
and DeepSeek Harness contributed no usage anywhere (#1584).
Admitting v4 only after verifying the reader's whole consumption surface
against DSH's official sessionFormatCatalog (recovery: 'strict',
validation: 'current', @deepseek-ai/dsh-session-format-catalog@0.2.0-rc.2),
per the semantic-update rule docs/providers/dsh.md prescribes for format
bumps: dense seq, usage at assistant/message data.usage (plus a new
informational totalTokens sum) or the embedded stream, tagged end-seed
inheritance, and llm/retry-started attempt slots are all unchanged. What
v4 does change (tool-result role lift, plugin: tag namespacing, surfaceOp
append/replace metadata, new header fields, untagged end-seed markers in
unseeded sessions) is ignored or already handled.
Adds catalog-validated v4 fixtures (same buckets as v0-v3 plus the
informational totalTokens) and extends the per-version parse tests to v4.
Bumps the dsh parse version so cached skip-era sessions recompute.
Verified end to end against a real 0.2.0-rc.2 log: doctor reports the
session readable, and the parsed totals (12 calls, input 11783, output
3699, cache read 107520) match the official catalog artifact exactly.
* daily cache v52; drop unused field
---------
Co-authored-by: Resham Joshi <65915470+iamtoruk@users.noreply.github.com>
Local Cursor rows are priced from IDE composer bubbles, which never see
the context Cursor re-sends on every request, so the figure can sit far
below the dashboard bill (about 2% on the account that reported #1545),
yet overview printed it like any exact total. The import from #1558
answers this for the time an export covers; outside it nothing said the
number was not the bill.
overview now prints one dim line under the bottom line whenever the
period still holds local cursor/cursor-agent dollars that no import
covers — covered local calls are already dropped at serve time, so any
non-imported Cursor call that survives the walk is an uncovered
estimate. The line names the amount and points at
codeburn import cursor <file.csv>.
* Add regressions for redirected editor storage roots
* Honor redirected data roots for Copilot and Cursor
* Verify redirected Copilot OTel discovery on Linux
* Reproduce Cursor cache collisions across storage roots
* Bind Cursor result caches to their database and backfill redirected history
* Verify redirected discovery against the latest daily cache
* Update env guard and document editor storage overrides
* Add Hermes Windows home regression tests
* Resolve Hermes home from Windows local app data
* Re-derive Hermes data from Windows home
---------
Co-authored-by: Resham Joshi <65915470+iamtoruk@users.noreply.github.com>
* Add regressions for request-level Copilot journal usage
* Read request-level input tokens from Copilot journals
* Refresh cached Copilot journal usage and settled days
* Use local date keys in the journal cache regression
* feat(devin): read usage from sessions.db
Devin keeps every request in sessions.db message_nodes; the transcript
exports hold only a few sessions. Usage now comes from the store, one
source per non-hidden session, read in node_id keyset batches with only
the needed JSON fields pulled. Sibling retries share a request_id and
dedup on it; off-main-chain requests count. SQLITE_BUSY is rethrown so
the refresh retries. Transcripts are read only when the database is
missing or has no message_nodes, so the two never double count.
The legacy metadata.metrics path no longer carves cache reads out of an
input_tokens count that never included them.
sessions.db sources rely on the WAL-folded fingerprint instead of a
forced reparse. Parse version sessions-db-v1; daily cache v43 with devin
in PENDING_REDERIVE, since transcript-era days dated steps on the
session's last activity.
* fix(devin): take only text user content as the prompt
* test(daily-cache): include devin in pending re-derive expectations
* Add regression coverage for Claude queued prompts
* Count queued Claude human prompts in turn grouping
* Cover queued prompts through Claude session cache
* Reparse cached Claude turns for queued prompts
* Refresh daily categories after Claude turn regrouping
* fix(claude): count only human queued prompts, skip peer agent messages
---------
Co-authored-by: Resham Joshi <65915470+iamtoruk@users.noreply.github.com>
* feat: Amp support - read the local thread mirror (#1572)
Amp (Sourcegraph's coding agent) mirrors every thread it serves as one
JSON document per thread at ~/.local/share/amp/threads/ (AMP_DATA_DIR
honored, comma-separated). Each file is { id, messages,
usageLedger?{events} }; the ledger's events are the per-request record
(tokens.input/output, cache tokens joined from the billed message
through toMessageId -> messages[].messageId), with a per-assistant-
message usage fallback for threads without a ledger and a total-only
record billing as output.
Amp bills a subscription and records no charged dollars, so every call
is priced from the underlying model's token rates and marked
costIsEstimated; the recorded credits field is ignored (no published
per-credit dollar rate). Thread files carry no cwd, so sessions group
under the provider name. Registered eager; parse version
usage-ledger-v1; no artwork yet (mono-initial fallback, like Codebuff).
Surfaces: CLI registry + doctor probe roots, Electron sandbox read
paths + menubar catalog (Amp after Cursor, matching the Swift order),
Windows tray tab color + usage_guard root, GNOME prefs dropdown, macOS
ProviderConnectionCatalog, docs/providers/amp.md, README tool list,
CHANGELOG.
* fix: address Amp provider review feedback
* fix(openclaw): read the per-agent sqlite transcript store the 2026-09-01 migration writes
OpenClaw 2026.8.1 moved sessions from agents/<agent>/sessions/*.jsonl to
agents/<agent>/agent/openclaw-agent.sqlite, so discovery resolved to zero
sources and doctor reported the provider empty (#1259).
transcript_events keeps each JSONL envelope verbatim in event_json, so the
JSONL event reducer is extracted and shared: both eras parse, dedup and
cost identically, and migrated sessions keep their original ids. Sessions
are listed per store and parsed in keyset batches of 2000 rows so a
gigabyte store never loads whole. agent-schema 23 lets a row carry its
event as an event_zstd BLOB instead; those decode on Node 22.15+ and skip
with one notice below that.
Fixes#1259
* test(openclaw): batch fixture inserts in a transaction; hash id-less events before the created_at fallback
---------
Co-authored-by: ozymandiashh <ozymandiashh@users.noreply.github.com>
Co-authored-by: Resham Joshi <65915470+iamtoruk@users.noreply.github.com>
* feat(dock): one Claude ring per config directory, with its own sessions and today (#1523)
Rate limits are per account, so a machine with a work and a personal
~/.claude cannot be served by one Claude ring. When the CLI knows two or
more Claude config directories:
- `codeburn quota --format json` adds a top-level `claudeProfiles` array,
one entry per directory (`providers[]` unchanged). Each entry carries
the directory's own windows, read from its own `<dir>/.credentials.json`
(the macOS Keychain fallback stays reserved for the default ~/.claude),
plus that directory's own today totals from a single Claude-only,
cache-backed parse of today's range, filtered per source id exactly like
the menubar's per-config payloads.
- Live sessions carry `claudeConfigSourceId`, so a per-profile ring claims
only its own sessions. Claude Desktop sessions keep their own bucket id
and belong to no profile.
- The Windows Capacity Dock gains a `claudeProfiles` preference (combined,
default; separate draws one captioned ring per directory). Profile rings
keep addressing the `claude` provider id for the provider set, glyphs,
colors and the connect button; the settings row appears only when the
CLI reports more than one profile.
- Captioned rows are taller by two new metrics (caption line + gap),
mirrored in TS and Rust: the page tells Rust the rail is captioned in
the layout request, and the frame carries the effective row extent the
hit-test uses. Non-captioned rails are pixel-identical to before.
- The desktop app's shared dock-prefs schema parses and sanitizes the new
key, so its pane cannot strip it from windows-dock.json.
Closes#1523
* review: opt-in profile reads, today timeout, missing-dir filter (#1570)
- `quota --claude-profiles` gates the per-directory reads: without it the
payload lists profiles ({id,label,path}) only, so a combined rail and
WSL users pay nothing; the Windows dock passes the flag only while its
claudeProfiles preference is separate, and an unknown option from an
older CLI reads as CliOutdated.
- The default ~/.claude profile reuses the claude provider row's result —
no second request, no second macOS Keychain read.
- claudeTodayBySource races the same timeoutMs and answers an empty map
on loss, so a silent child cannot cost the dock every provider's quota.
- Missing config directories are filtered before the >1 check.
- `captioned` applies only while a Claude ring is in the selected set;
profile rows tolerate a list-mode answer; comments trimmed; merge with
#1560 keeps both keepExpanded and claudeProfiles.
* test(quota): set USERPROFILE for the default-dir check; drop issue refs
---------
Co-authored-by: Resham Joshi <65915470+iamtoruk@users.noreply.github.com>
Consumption-share split in `codeburn models`, reworked per review:
- First-party routes only: the split applies to `dsh` (DeepSeek API) and
`zcode` (Z.ai plan) calls. The same model behind a gateway never had
the vendor discount, and reported-cost providers may already carry it;
the gate set stays disjoint from REPORTED_COST_PROVIDERS.
- The numbers agree by construction: both legs are shares of the stored
list-rate cost (peakUSD + offPeakUSD == costUSD, pinned in tests).
The 0.5x off-peak discount stays on the vendors' bills; nothing is
repriced here. peakCostMultiplier and OFF_PEAK_MULTIPLIER are gone.
- Calendars: unverified 2027 projections dropped; the Z.ai
2026-09-25..10-07 all-day off-peak promotion is honored as a temporary
range; deepSeekHolidayCoverageYears() plus a test fail when the
current year falls out of the holiday list.
- Output shape: JSON carries the five peak keys only on rows with a
split, so a report without DeepSeek/Z.ai first-party usage keeps its
exact historical shape; the Z.ai quota note is removed.
- The `codeburn peak` live-status command is left out (scheduling tool,
not usage tracking); it survives on a separate branch for its own PR.
* menubar: dock preference for the hover bubble's surface
* menubar: let the dock's hover bubble keep its own surface
* menubar: setting for the dock's hover bubble surface
* docs: dock hover bubble surface setting
* feat(cursor): import Cursor's usage export to replace local estimates (#1545)
* Price Cursor-hosted grok-4.6-high like grok-4.6 in the Cursor import
* Skip no-op Cursor re-imports and price cursor-grok-4.6-high ids locally
* test(cursor-import): write agent fixtures under os.homedir() so Windows finds them
* fix(cursor-agent): read CLI sessions that exist only in ~/.cursor/chats store.db (#986)
A session with no exported transcript is read from its store.db; one with
a transcript is read from the transcript alone, so nothing counts twice.
Store turns follow the transcript accounting, take their time from the
prompt's <timestamp> tag and their model from the reasoning block, and
merge every conversation root so summarized history is kept. Daily cache
moves to v39 so settled days re-derive.
* cursor-agent: price store.db turns at the Cursor (auto) rate like transcripts
* feat(copilot): legacy JSON chat session parser and auto-mode resolution
* fixed copilot naming
* revert: remove unrelated jetbrains and env-isolation changes
* revert priority change
* fix(copilot): route legacy JSON chat sessions cleanly and fix calculateCost web search param
* fix(copilot): legacy chat session parsing and pricing
* fix(copilot): strip github.copilot-chat/ namespace from legacy model ids
found github.copilot-chat prefix in my chat sessions
* fix(copilot): revert comments
* fix(copilot): model names
* fix(copilot): model display name edge cases
* feat(copilot): only keep legacy parser source
* fix(copilot): legacy sessions skip binary tool outputs and use recorded thinking tokens
A screenshot or other binary tool result was base64-decoded as UTF-8 and
char-counted as input, so one 200 KB PNG billed 50k input tokens. Only
text/* payloads count now.
A round's recorded thinking.tokens was compared with the char estimate of
the same text via Math.max, so the estimate won whenever it was larger.
Each round now uses its recorded count when present and the estimate only
otherwise, summed across rounds.
Docs list the flat .json files and the transcript gate covering them.
* fix(models): price Copilot's dotted spellings of Claude 3.5, 3.7 and Opus 4.1
Copilot writes claude-3.5-sonnet, claude-3.7-sonnet,
claude-3.7-sonnet-thought and claude-opus-4.1, which resolved to no
pricing row and billed $0. They alias to the dashed rows now.
---------
Co-authored-by: Resham Joshi <65915470+iamtoruk@users.noreply.github.com>
* fix(opencode): price Vertex turns on a Vertex row and keep an unpriceable recorded cost through the cache (#1547)
OpenCode records the cost of each turn. For an id CodeBurn cannot price the
parser fell back to that cost, but the session cache stored no cost and
re-priced the cached tokens on every read, so the call showed $0. The
recorded cost now rides on the cached call as fallbackCostUSD and applies
only while the tokens price at $0, so a later catalog row or price
override still wins.
The session-level rollup used provider/model while per-message turns use
the bare id since #1543; it now uses the bare id too. google-vertex and
google-vertex-anthropic map to a metered Vertex route.
OpenCode and Kilo Code re-parse once; daily cache v37 re-derives settled days.
* fix(opencode): keep a declared-free id at $0 instead of its recorded cost
A model the user marked flat-rate, priced at a zero rate, or that looks
local prices at $0 on purpose. The recorded-cost fallback now skips those
ids at parse time and on cache read, through one guard in models.ts.
* fix: count every Cursor Agent assistant message instead of one turn per user message
Agentic loops emit dozens of assistant messages per user message and
the parser kept only the first (on one real corpus: 247 of 4,946
messages, ~4% of assistant text). Each message now carries the last
user message forward, tool_use inputs join the output text, and input
tokens use the full user text while the display stays truncated at
500 chars. Parse version bumped so cached sessions re-parse.
* cursor-agent: a transcript that ended before any assistant message is not an unrecognized format
* cursor-agent: bill the user text once per user message, not once per assistant message
* cursor-agent: re-derive finalized days and cached sessions under the new accounting
---------
Co-authored-by: Resham Joshi <65915470+iamtoruk@users.noreply.github.com>