Commit graph

310 commits

Author SHA1 Message Date
Resham Joshi
32f0eee2a2 fix(antigravity): treat an unreadable output total as absent
An RPC usage entry whose outputTokens is present but not a number (an empty
string) was reconciled as NaN and produced NaN output. A total that does not
parse to a finite number now counts as absent and the split stands. On the
SQLite path a varint cannot be non-numeric; a field 3 of the wrong wire type
(no varint value) is likewise treated as absent.
2026-11-06 06:26:33 -08:00
Resham Joshi
f89fe26e02 fix(antigravity): keep the split when the output total is absent
The previous commit treated a missing output total like an explicit 0 and cut
a recorded thinking/response split down to nothing. An absent total (no
outputTokens key on the RPC path, field 3 not set in the SQLite proto) now
keeps the split as before; a total that is present, 0 included, still wins
over a split that disagrees. Same rule on both paths.
2026-11-06 06:23:38 -08:00
Resham Joshi
93af1add2a fix(antigravity): apply the output-total rule to a total of 0 as well
A record with output total 0 beside a nonzero thinking/response split kept
the split, against the total-wins rule. Antigravity never writes that shape:
a read-only scan of every gen_metadata row in the owner's Antigravity
conversation databases (166 rows, 9 files) found 165 whose split sums exactly
to the total and none with a zero total beside a nonzero split. The .pb
conversations are readable only through the running app, so they were not
scanned. A total of 0 now caps the split at 0 like any other total.
2026-11-06 06:21:47 -08:00
Resham Joshi
8ea9ba8966 fix(antigravity): let the output total win whenever the split disagrees
Rule: ModelUsageStats' output total (field 3 / outputTokens, documented as
thinking + response) is authoritative whenever it is set. The existing
reconciliation already trusted it over a disagreeing split, but skipped the
case where thinking alone exceeded the total, so outputTokens 100 with
thinking 200 and response 50 kept 250. That case now caps thinking at the
total and leaves response at 0. One shared helper applies the rule on the RPC
and SQLite paths; the unreleased rpc-output-total-v1 bump already re-parses
cached cascades.
2026-11-06 06:20:07 -08:00
Resham Joshi
1692778bb5 test(vercel-gateway): pin every retryable status and the refused-credential case 2026-11-06 06:02:08 -08:00
Resham Joshi
cf3f0fa90a test(grokbot): a removed import's rows go while the mirror's rows stay 2026-11-06 05:54:36 -08:00
Resham Joshi
c08c0f2bc2 fix(vercel-gateway): treat 408, 409 and 425 as retryable report failures
A request timeout, conflict or too-early answer was read as a definitive empty
report. They now keep the cached report and retry like 429 and 5xx: the
statuses Vercel's own AI SDK retries, plus 425, which asks for a retry.
2026-11-06 05:53:42 -08:00
Resham Joshi
924fba8679 fix(vercel-gateway): stop retrying a gateway that keeps failing every refresh
A permanently unreachable gateway (DNS failure, persistent 5xx) deferred
every refresh forever: stale rows served, the run never fully hydrated. A
network source now counts consecutive retryable failures on its cache entry;
the third marks it failed with its rows kept, so it serves those rows without
fetching until the next day (a credential change still invalidates it) and
shows in doctor as a cached failure. A successful fetch resets the count.
2026-11-06 05:50:38 -08:00
Resham Joshi
7e67d64c73 fix(warp): probe Warp's Linux paths only on Linux
Every non-macOS, non-Windows platform fell through to the Linux locations.
Candidates are now exact per platform: macOS bundles, Linux state dirs,
Windows LOCALAPPDATA, and none elsewhere.
2026-11-06 05:49:31 -08:00
Resham Joshi
e6c60b592d fix(vercel-gateway): keep the cached report when a refresh cannot fetch it
An unreachable gateway, a rate limit or a server error parsed as an empty
report, so the run showed $0 of gateway spend with nothing but a stderr line.
Those failures now defer the source the way a busy SQLite store does: the
cached report keeps serving, the run is marked not fully hydrated, and the
next refresh retries. A refused credential still reads as no report.
2026-11-06 04:56:33 -08:00
Resham Joshi
e613f61f55 fix(grokbot): keep requests that slide out of Grok Bot's mirror window
The app mirrors only about the last 200 transcript entries per bot, and each
re-parse replaced the cached calls with the current window, so older requests
vanished from live views as a busy bot kept working. Grok Bot sources are now
durable: requests the window dropped stay cached, ones still in it are
refreshed in place.
2026-11-06 04:55:46 -08:00
Resham Joshi
99eafef13a fix(quickdesk): stop counting a session's estimate after its metrics arrive
Quick Desktop sources are merged durably, so a sessions.db estimate cached
before the session's metrics landed was never removed and the session counted
twice from then on. The sessions.db source is now marked as a snapshot of the
store, replaced on each re-parse; a locked store defers the parse (cached rows
kept, retried next refresh) instead of reading as empty. Parse version bumped
so cached double counts re-parse.
2026-11-06 04:55:18 -08:00
Resham Joshi
9e5f729d8b fix(zed): defer a locked threads.db instead of reading it as empty
Zed's whole history is one source, so a SQLITE_BUSY on open or on the threads
query parsed as zero calls and replaced every cached Zed thread for the run.
Busy errors now reach the parse loop, which keeps the cached rows and retries
on the next refresh, like the other SQLite providers.
2026-11-06 04:54:25 -08:00
Resham Joshi
46a521cc56 fix(warp): discover Warp on Linux and Windows
Only the macOS group-container paths were tried, so Warp on Linux or Windows
reported nothing unless WARP_DB_PATH was set. Adds the default locations from
Warp's file-locations docs: $XDG_STATE_HOME/warp-terminal (and -preview) on
Linux, %LOCALAPPDATA%\warp\Warp\data on Windows. Both variables join warp's
cache fingerprint.
2026-11-06 04:53:59 -08:00
Resham Joshi
68a2684b4f fix(parser): label Devin and Antigravity token-priced costs as calculated
Both providers keep the cost they priced from tokens at parse time through the
cache, and that kept cost was served with costBasis 'recorded', the label for
a tool's own billed figure. They now serve as 'calculated'. Decided at serve
time, so cached calls change label without a re-parse and totals are
unchanged; serve-time re-pricing still needs the pricing id stored.
2026-11-06 04:52:33 -08:00
Resham Joshi
f232d8712c fix(antigravity): keep RPC output tokens when the response/thinking split is absent
Generator metadata from the language server omits unset proto3 fields, so an
entry carrying only outputTokens was stored and priced with 0 output. The RPC
path now reconciles the split the way the SQLite path already does. Results
cache v11 and an antigravity parse-version bump re-read cached cascades.
2026-11-06 04:52:04 -08:00
Resham Joshi
25ea32e85b fix(cline): key Cline-family tasks on ui_messages.json, not the task directory
Cline rewrites ui_messages.json in place, which never moves the task
directory's mtime or size, so a growing task kept serving its first cached
snapshot. The source is now the file itself; the new path re-parses every
task once on its own, so no parse-version bump is needed.
2026-11-06 04:51:31 -08:00
Resham Joshi
7721a1dcef
chore: drop the no-zstd fallbacks the 22.15 floor made unreachable (#1855)
* 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
2026-11-04 19:29:18 +01:00
Resham Joshi
a36ccfacc2
fix(codex): price requests on the ultrafast service tier (#1851) 2026-11-04 19:08:36 +01:00
Resham Joshi
cae926db37
fix(cursor): count a bubble once when it is copied into several conversations (#1852) 2026-11-04 19:08:31 +01:00
Aaron Bronow
faf554e1de
fix(antigravity): attribute CLI .db sessions to workspace projectPath (#1840) (#1841)
* fix(antigravity): attribute CLI .db sessions to workspace projectPath (#1840)

* fix(antigravity): populate workingDirectory for sync --attribution (#1840)

* fix(antigravity): keep the RPC cache generation and the project-only scope

The CACHE_VERSION bump is dropped because applyAntigravityProject re-runs on every cache read, so cached cascades pick up the new project without discarding the durable RPC-only cache. The workingDirectory lines are dropped because they changed Desktop and IDE sessions outside #1840, and the fallback delete of projectPath was a no-op since only this function ever sets it.

* test(antigravity): build the workspace file URL for the running platform

---------

Co-authored-by: Resham Joshi <65915470+iamtoruk@users.noreply.github.com>
2026-11-04 19:08:18 +01:00
Resham Joshi
fb95c4bca8
fix(hermes): count helper-model usage recorded in session_model_usage (#1849)
* fix(hermes): count helper-model usage recorded in session_model_usage

Hermes records auxiliary calls (compression, title generation, vision and
other helper tasks) only in session_model_usage, under the helper model and
a task name, and never adds them to the sessions totals the provider reads.
Those tokens and dollars were missing. Each helper row now becomes a call on
its own session, priced through the same cost path with the helper model id,
tracked by the session ledger so later growth lands as a delta, and marked as
supplementary accounting so it adds no requests or turns. Rows with an empty
task are the main loop and voice_chat is already in the sessions totals, so
both are skipped.

Measured on this machine's Hermes state.db: 12 sessions, 12 calls, $2.0834
before and after. Its 12 session_model_usage rows are all main-loop rows that
equal the sessions totals, so nothing changes there. On a copy of that DB with
a compression row and a title row added (plus a voice_chat row that must stay
out): before 12 calls, $2.0834; after 14 calls, $2.1660, helper share $0.0826.
Growing the compression row by 10,000 input tokens added one $0.0100 delta.

* fix(hermes): keep a recorded zero helper cost

session_model_usage stores actual_cost_usd as NOT NULL DEFAULT 0, while the
sessions column is nullable, so a 0 on a helper row usually means nothing
was recorded. When the row's cost_status says the amount is actual, that 0
is a recorded free line and now stays $0 (metered) like a sessions row,
instead of being re-priced from tokens.
2026-11-04 19:08:14 +01:00
Resham Joshi
3faea16a60
fix(codex): match mcp-cli only in command position (#1845)
Some checks are pending
CI / semgrep (push) Waiting to run
Tests / test (22) (push) Waiting to run
Tests / test (22.13.0) (push) Waiting to run
Tests / test (24) (push) Waiting to run
Tests / test (26) (push) Waiting to run
Tests / test-platforms (macos-latest) (push) Waiting to run
Tests / test-platforms (windows-latest) (push) Waiting to run
Tests / desktop (push) Waiting to run
Tests / vscode (push) Waiting to run
MCP_CLI_CALL matched `mcp-cli ... call <server> <tool>` anywhere in a shell
command's text. A command that only mentions the phrase became an MCP tool
call, and `codeburn sync` sent the name upstream: `git commit -m "mcp-cli
call orion-merger initech-term-sheet"` produced the tool
`mcp__orion-merger__initech-term-sheet` on the wire. The same happened for
an echo, a shell comment or a quoted mention inside a longer command.

The matcher now requires mcp-cli to be the command being run, the first word
of a command segment: the start of the text, after a shell separator, `(`,
`$(` or a backtick, after a `-c`/`-lc` shell flag, or after the exec custom
tool's `cmd:`, optionally behind a directory prefix such as `./`. The server
and tool must be identifier-shaped tokens with balanced quotes, so free text
with spaces no longer yields a name. Option skipping and the `foo-mcp-cli`
lookbehind are unchanged, and every existing invocation shape still matches.

Bumps CODEX_CACHE_VERSION to 24 and PROVIDER_PARSE_VERSIONS.codex
(mcp-cli-command-v1) so cached sessions that already hold fake names are
re-parsed instead of re-sent.
2026-11-03 17:58:38 +01:00
Enclavet
9a4541670e
fix(kiro): stop reading tool names from modern execution message text (#1844)
The IDE modern-execution parser ran the `<tool_use><name>X</name>` markup
scan over the text of every message and over the top-level response field.
Message text includes tool OUTPUT (file contents, command output) on `tool`
messages, plus model prose. So any content containing that markup became a
tool call, and `codeburn sync` sent the name upstream: a file holding
`<tool_use><name>orion_merger_initech</name>` produced the tool
`orion_merger_initech` on the wire. sanitizeToolIdentifiers cannot catch
this, because the injected name is shaped like a valid identifier.

Real execution files never need the scan. They record tool calls as
structured data (toolUse entries, toolCalls, usageSummary[].usedTools), and
none of 319 local execution files contain the markup, so the scan only ever
produced false names. Tool names in this path now come from structured fields
only.

The legacy `.chat` format has no structured tool record, so parseChatFile
keeps its bot-message-only markup scan; a test pins that as unchanged.

Bumps PROVIDER_PARSE_VERSIONS.kiro (no-text-tools-v1) so cached entries that
already hold injected names are re-parsed instead of re-sent.

Two existing tests asserted tools derived from markup in modern-file text;
they now assert the structured toolCalls entry instead.

AI-Origin: human

Co-authored-by: Andrew Lee <andklee@amazon.com>
2026-11-03 17:38:14 +01:00
Resham Joshi
f846b63097
fix(copilot): stop billing cached tokens twice on OTel spans (#1830)
Some checks failed
CI / semgrep (push) Waiting to run
Tests / test-platforms (macos-latest) (push) Waiting to run
Tests / test (22) (push) Waiting to run
Tests / test (22.13.0) (push) Waiting to run
Tests / test (24) (push) Waiting to run
Tests / test (26) (push) Waiting to run
Tests / test-platforms (windows-latest) (push) Waiting to run
Tests / desktop (push) Waiting to run
Tests / vscode (push) Waiting to run
macOS Menubar CI / test (push) Has been cancelled
Windows Menubar CI / check (ubuntu-latest) (push) Has been cancelled
Windows Menubar CI / check (windows-latest) (push) Has been cancelled
* fix(copilot): stop billing cached tokens twice on OTel spans

VS Code Copilot Chat writes gen_ai.usage.input_tokens on agent-traces.db
spans as the full prompt, cache reads and writes included. The OTel parser
passed it to calculateCost as uncached input, so every cached token was
billed at the input rate on top of its cache rate. The parser now subtracts
the cache counts the way the chatSessions path does, and keeps an input
below them as written.

Bumps the copilot parse version so cached OTel calls re-parse. Calls whose
spans the extension already pruned keep the old input.

* test(upgrade-path): expect the copilot OTel cache subtraction across the bump

The parse-version bump re-parses the surviving agent-traces.db spans with
the cache counts taken out of input, so input and cost drop by design while
the pruned calls keep the 0.9.20 figure. Calls, output and cache reads stay
exact; input must drop by exactly the cache counts of the surviving
cache-inclusive spans, and cost must drop.
2026-11-02 20:26:36 +01:00
Uttam Deb
38f71ab35e
fix(codex): attribute native Codex tool events (#1767)
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.
2026-11-02 17:15:31 +01:00
Dan Caldr
ad7332f591
feat(antigravity): extract initial user prompt and attribute userMessage (#1793)
Antigravity calls carried no user message, so every turn classified as
conversation. The provider now reads the cascade's first USER_INPUT from
the brain transcript (first 50 lines, <USER_REQUEST> unwrapped, cut to
500 chars), with the SQLite steps row as the fallback for .db sources,
and sets it as userMessage on every call of the cascade, the way the
cline-cli, goose, codewhale and mistral-vibe providers already do.

Calls, tokens and cost do not change. The activity split does: on real
data the last 30 days go from 128 conversation turns to 2, with 126 now
exploration. ANTIGRAVITY_CACHE_VERSION moves 9 to 10 and the antigravity
parse tag gets user-msg-v1, so only Antigravity re-parses once. Session
titles and optimize are unchanged. Follow-up prompts in a cascade are not
read yet; the first prompt stands for the whole cascade.

Closes #1792
2026-10-31 03:45:34 +01:00
Resham Joshi
cef7c17621
fix(warp): price conversations from total_billed_cost_in_cents (#1787)
Some checks are pending
CI / semgrep (push) Waiting to run
Tests / test (22) (push) Waiting to run
Tests / test (22.13.0) (push) Waiting to run
Tests / test (24) (push) Waiting to run
Tests / test (26) (push) Waiting to run
Tests / test-platforms (macos-latest) (push) Waiting to run
Tests / test-platforms (windows-latest) (push) Waiting to run
Tests / desktop (push) Waiting to run
Tests / vscode (push) Waiting to run
Warp 0.2026.10 removed total_provider_cost_in_cents and now persists
total_billed_cost_in_cents. Read it after total_charged_usage, as Warp
does, so conversations without streamed charges keep their billed dollars
instead of the credits estimate. Bump the warp parse version and
DAILY_CACHE_VERSION to 77 (76 on a Node without zstd, so it re-derives
too and a zstd Node still adopts its file).
2026-10-26 13:30:21 +01:00
Resham Joshi
b4974351dc
fix(codex): read Zstandard-compressed rollouts (#1786)
Codex now moves cold rollouts to rollout-*.jsonl.zst. Discovery, the
first-line probe, the parser, fork parent lookup, codex-tps and the context
view read them through a zstd decode; a session present in both forms
counts once from the plain file. Compressed files are parsed whole and never
resumed by byte offset. Without node:zlib zstd (Node < 22.15) they are
skipped with one notice. DAILY_CACHE_VERSION 76 so settled days pick up the
recovered Codex usage. Without zstd it stays 75, so a later Node upgrade
still adopts that cache and re-derives it.
2026-10-26 02:40:29 +01:00
Resham Joshi
354492e500
Copilot: count every agent round and bill exact credits in VS Code chat sessions (#1752)
Some checks are pending
CI / semgrep (push) Waiting to run
Tests / test (22) (push) Waiting to run
Tests / test (22.13.0) (push) Waiting to run
Tests / test (24) (push) Waiting to run
Tests / test (26) (push) Waiting to run
Tests / test-platforms (macos-latest) (push) Waiting to run
Tests / test-platforms (windows-latest) (push) Waiting to run
Tests / desktop (push) Waiting to run
Tests / vscode (push) Waiting to run
* 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.
2026-10-13 01:02:04 +02:00
Dan Caldr
26c99ed860
fix(antigravity): fall back to the chat model and map Gemini 3.8 Flash placeholders (#1712)
Some checks are pending
CI / semgrep (push) Waiting to run
macOS Menubar CI / test (push) Waiting to run
Tests / test (22) (push) Waiting to run
Tests / test (22.13.0) (push) Waiting to run
Tests / test (24) (push) Waiting to run
Tests / test (26) (push) Waiting to run
Tests / test-platforms (macos-latest) (push) Waiting to run
Tests / desktop (push) Waiting to run
Tests / vscode (push) Waiting to run
Tests / test-platforms (windows-latest) (push) Waiting to run
Windows Menubar CI / check (ubuntu-latest) (push) Waiting to run
Windows Menubar CI / check (windows-latest) (push) Waiting to run
When an Antigravity response left out the model, the parser crashed on the legacy .pb path and the whole session was skipped. It now falls back to the chat's own model and passes it through the live model map.

Maps the Gemini 3.8 Flash placeholders M318/M319/M320 to the high/medium/low ids from Antigravity's model catalog, and the gemini-3-flash-a/-d family strings to gemini-3-flash-preview (LiteLLM prices, nothing hardcoded). Parse version, results cache v9 and daily cache v74 bumped so cached rows re-parse; calls and cost only rise.

Thanks @dcaldr.
2026-10-10 11:34:13 +02:00
Resham Joshi
aa85ed2312
fix(optimize): stop flagging delivered and editing sessions as low-worth (#1719)
The delivered check read bashBreakdown keys, which are base names (git), so
git commit / gh pr create never matched; it now reads the full command from
each call's tool sequence (Kimi Code now records one) and allows git global
options. Devin and cursor-agent edit tools count as edits, and the retry
share divides by edit steps instead of user prompts.
2026-10-10 07:05:47 +02:00
Resham Joshi
89bc4598f8
fix(cursor-agent): leave Cursor IDE chat transcripts to the cursor provider (#1717)
* 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.
2026-10-10 07:05:35 +02:00
Resham Joshi
f5906a0c68
fix(copilot): price JetBrains claude-opus-4.7 as Opus 4.7 (#1705)
The dot-minor lookahead from #1531 stops claude-opus-4 matching
claude-opus-4.7, and 4.7 was not in the token list, so those turns fell
back to copilot-anthropic-auto (Sonnet 4.5 rates). Add the token and bump
the copilot session-cache parse tag so cached turns re-parse.
2026-10-10 02:55:34 +02:00
Resham Joshi
687ca2f19c
fix(kimicode): use state.json cwd when workDir is absent (#1688)
Kimi Code now writes cwd instead of workDir. Without it the project path
was decoded from the wd_ directory name, so /x/crewroom-app-mem5 became
crewroom/app/mem5 and never joined its repository. Cost is unchanged;
only the per-project split moves.
2026-10-08 05:48:17 +02:00
Resham Joshi
1284290743
fix(codex): mask fork replay records against the parent rollout (#1678)
* fix(codex): mask fork replay records against the parent rollout

A fork's replay burst was dropped whole, losing calls that exist only in
the fork. Drop a burst record only when the parent rollout recorded it
before the fork, and count the rest as their own calls. Parent missing or
a burst that does not open with a parent record keeps the old behavior.

Bumps CODEX_CACHE_VERSION to 22 and DAILY_CACHE_VERSION to 66.

* fix(codex): bump the codex parse version for fork masking, fix the comments

Cached forks that dropped the whole burst need to re-parse, so the codex
parse version gains codex-fork-mask-v1. The burst records that now count
are the parent's work its rollout kept only inside a running total, not
fork-only usage.
2026-10-08 00:27:52 +02:00
Resham Joshi
3c186491c3
fix(grok): read per-request usage from logs/unified.jsonl (#1677)
* fix(grok): read per-inference usage from logs/unified.jsonl

Grok Build keeps logging every inference to ~/.grok/logs/unified.jsonl after
its session dirs are gone, so CodeBurn showed $0 for that usage. Read
shell.turn.inference_done records (prompt includes cached, completion includes
reasoning), with the model from the session's model changed event and the
project from session created. Sessions that still have a session dir are
skipped so they are not counted twice. DAILY_CACHE_VERSION 65.

* fix(grok): prefer the unified log over session-dir rollups

A session with inference records in logs/unified.jsonl is now read from the
log, one call per request, and its session dir is skipped. Session dirs only
count for sessions the log no longer holds. This keeps history when session
dirs are deleted after the log was cached, and prices grok-4.6's long-context
tier per request instead of on a session total. Logged calls can move to an
earlier day than the rollup, so grok joins PENDING_REDERIVE at 65.

* fix(grok): re-read skipped session dirs after log rotation, keep their tools

A session dir the unified log holds parses to nothing, and its fingerprint
does not track the log, so a rotated or truncated log left that empty
result cached. Empty grok session-dir entries now re-parse.

The skipped dir's summary, tools, bash commands and subagents now ride on
that session's first logged call, and its model and cwd fill in when the
log names neither. A call whose model nothing names is priced as
grok-build and marked estimated.
2026-10-08 00:14:53 +02:00
Resham Joshi
c826f1a479
fix(models): price kimi-for-coding by the model it served on the call date (#1676)
* fix(models): price kimi-for-coding by the model it served on the call date

kimi-for-coding is a moving alias. It priced as retired K2 Thinking for
every call. It now prices as K2.5 from 27 Jan 2026, K2.6 from 13 Apr and
K2.7 Code from 12 Jun (K2.8 Preview from 11 Sep has no published price,
so it stays on K2.7 Code). kimi-for-coding-highspeed prices at Moonshot's
K2.7 Code HighSpeed rate instead of $0. Daily cache v64.

* fix(models): mark K2.8 Preview kimi-for-coding calls as estimated

From 11 Sep 2026 kimi-for-coding served K2.8 Preview, which has no
published rate and prices as K2.7 Code. Those calls now carry the
estimated flag. The legacy kimi provider prices by the dated model too.

* fix(models): flag the K2.8 Preview stand-in where every call is read

cachedCallToApiCall now marks kimi-for-coding calls from 11 Sep 2026
estimated, so the flag reaches every provider and cached reads without a
parse bump. Calls with a reported cost are left alone. The kimi provider's
own flag and its parse version entry go, as they only duplicated this.
2026-10-08 00:02:38 +02:00
Resham Joshi
d049b38255
fix(cline-cli): stop billing cache tokens twice (#1675)
Cline CLI's metrics.inputTokens is the full prompt, cache reads and writes
included; Cline's own pricing bills max(0, input - cacheRead - cacheWrite)
at the input rate. We treated it as uncached input, so every cache read was
also charged at the full input rate. The split now happens in parseMetrics,
covering per-message and rollup calls.

Bumps the cline-cli parse version so cached calls re-parse and the daily
cache to v63 so settled days re-derive. Call counts are unchanged.
2026-10-07 23:51:10 +02:00
Resham Joshi
d4933ed391
fix(devin): price SWE-2 at Cognition's list rate (#1674)
SWE-2 calls showed $0. Cognition publishes SWE-2 list pricing at
docs.devin.ai/desktop/models: $3 input, $15 output, $0.30 cache read per
1M tokens. swe-1-7-lightning now normalizes to swe-1.7-lightning so it
prices too. Devin caches parse-time cost, so its parse version and the
daily cache version are bumped.
2026-10-07 23:33:39 +02:00
Abdul Kapti
c87d299a74
fix(claude): discover macOS Claude-3p Cowork sessions (#1579)
Read Claude Desktop 3p usage-ledger records for the Cowork and Code surfaces, drop a ledger call that matches a transcript call, daily cache v61.
2026-10-07 20:30:50 +02:00
Resham Joshi
063e42796d
feat(providers): add Command Code (#1658)
* 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
2026-10-07 00:18:50 +02:00
ozymandiashh
e22664ecbe
Restore usage from Mistral Vibe Unified Harness sessions (#1599)
* 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>
2026-10-06 21:15:06 +02:00
Resham Joshi
253c9fe85a
fix(antigravity): count cache reads and price the standalone app's model (#1655)
* 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.
2026-10-06 20:58:31 +02:00
Resham Joshi
2444afb610
fix(cursor): stop counting billed CLI sessions twice, mark guessed-model sync rows estimated (#1654)
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.
2026-10-06 20:43:24 +02:00
Resham Joshi
3afcbd9480
fix(codex): price Flex tier turns and the gpt-reserve / gpt-5.3-spark ids (#1642)
* fix(codex): price Flex tier turns and the gpt-reserve / gpt-5.3-spark ids

Flex turns (service_tier "flex") billed at standard rates. They now bill at
the model's published `<rate>_flex` rates, carried as an optional seventh
snapshot slot (only the flex fields were added to the bundled snapshot). A
model without flex rates still bills Flex at standard.

gpt-reserve (Luna Reserve) prices as GPT-5.6 Luna and gpt-5.3-spark as
GPT-5.3 Codex Spark; both showed $0 with an unknown-model warning.

* fix(codex): mark gpt-reserve cost as estimated
2026-10-05 21:18:59 +02:00
Resham Joshi
6d9d233d4b
fix(codex): price Codex Auto Review by date (#1641) 2026-10-05 19:43:33 +02:00
ozymandiashh
ee23e94726
Price Codex Fast (priority tier) turns at priority rates (#1628)
Some checks are pending
CI / semgrep (push) Waiting to run
Tests / test (22.13.0) (push) Waiting to run
Tests / test (22) (push) Waiting to run
Tests / test (24) (push) Waiting to run
Tests / test (26) (push) Waiting to run
Tests / test-platforms (macos-latest) (push) Waiting to run
Tests / test-platforms (windows-latest) (push) Waiting to run
Tests / desktop (push) Waiting to run
* fix(codex): price Fast (priority tier) turns at priority rates

Codex bills turns run under the Fast speed setting through the priority
service tier, which the rollout files record per thread in
thread_settings_applied events. Track that tier through the parse (and
across append resumes and fork replays), mark the affected turns as
fast, and derive a fast multiplier from the LiteLLM priority rate keys
so those turns are priced at the priority rates instead of the standard
ones. Cache versions are bumped so already-cached Codex results are
re-priced.

* snapshot: priority slots only, no upstream drift

---------

Co-authored-by: Resham Joshi <65915470+iamtoruk@users.noreply.github.com>
2026-10-05 12:15:30 +02:00
Resham Joshi
47087b0d53
Mark Cursor Agent transcript costs as estimated; align Cursor import coverage to local days (#1634)
Cursor Agent transcript calls are priced from character counts but were not
flagged costIsEstimated like the store.db path. Flag them and bump the
cursor-agent parse version so cached sessions pick it up. Cost is unchanged.

The Cursor CSV import inferred coverage from UTC days and read a bare
--from/--to date as a UTC day. Reports bucket by local day, so outside UTC the
coverage spilled into neighbouring local days (dropping their local estimates
with no imported events to replace them), and an export of one local day was
rejected as outside its own --from/--to. Use local day bounds instead.
2026-10-05 11:59:07 +02:00
ozymandiashh
78d9cea13c
Read DSH session format v4 written by dsh 0.2.0-rc.2 (#1612)
* 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>
2026-10-05 11:54:55 +02:00